# HG changeset patch # User Dremov Kirill (Nokia-D-MSW/Tampere) # Date 1277311275 -10800 # Node ID 7f25ef56562d73ba5f0c31bc42617736fcd16927 # Parent bf7481649c981c6aa987b5ff5c56d5adaf8c73de Revision: 201025 Kit: 2010125 diff -r bf7481649c98 -r 7f25ef56562d egl/eglrefimpl/group/egl_ref.iby --- a/egl/eglrefimpl/group/egl_ref.iby Fri Jun 11 14:58:47 2010 +0300 +++ b/egl/eglrefimpl/group/egl_ref.iby Wed Jun 23 19:41:15 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -16,6 +16,6 @@ #ifndef EGL_REF_IBY #define EGL_REF_IBY -file=ABI_DIR\DEBUG_DIR\libegl_ref.dll \sys\bin\libEGL.dll +file=ABI_DIR\BUILD_DIR\libegl_ref.dll \sys\bin\libEGL.dll #endif diff -r bf7481649c98 -r 7f25ef56562d egl/eglrefimpl/test/group/egltestref_helium.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/egl/eglrefimpl/test/group/egltestref_helium.pkg Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,39 @@ +; Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +; All rights reserved. +; This component and the accompanying materials are made available +; under the terms of "Eclipse Public License v1.0" +; which accompanies this distribution, and is available +; at the URL "http://www.eclipse.org/legal/epl-v10.html". +; +; Initial Contributors: +; Nokia Corporation - initial contribution. +; +; Contributors: +; +; Description: +; +;File: bitgdi.pkg; +; +;Auto-generated PKG file by Nokia PKG Wizard for CodeWarrior IDE + +;*Languages +&EN +; +;*Standard SIS file header. This section specifies the package name, +;application UID, and version/build numbers. Add the package TYPE here if needed. +#{"EGLTestRef"},(0x101FB3E8),1,0,1; +; + +;*Unique (Non-Localized) Vendor name +;This is used in combination with signing to prevent the unauthroized +;upgrade of a a package by someone other than the rightful vendor. +:"Nokia" + +;*Localized Vendor Name +;This specifies the localized vendor name(s) corresponding to language(s). +%{"Nokia Test EN"} + +;*Files To Copy... + +"..\scripts\egltest\egltest_t_reference.script"="c:\egltest\egltest_t_reference.script" + diff -r bf7481649c98 -r 7f25ef56562d egl/egltest/endpointtestsuite/automated/group/eglendpointtest_helium.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/egl/egltest/endpointtestsuite/automated/group/eglendpointtest_helium.pkg Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,39 @@ +; Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +; All rights reserved. +; This component and the accompanying materials are made available +; under the terms of "Eclipse Public License v1.0" +; which accompanies this distribution, and is available +; at the URL "http://www.eclipse.org/legal/epl-v10.html". +; +; Initial Contributors: +; Nokia Corporation - initial contribution. +; +; Contributors: +; +; Description: +; +;File: bitgdi.pkg; +; +;Auto-generated PKG file by Nokia PKG Wizard for CodeWarrior IDE + +;*Languages +&EN +; +;*Standard SIS file header. This section specifies the package name, +;application UID, and version/build numbers. Add the package TYPE here if needed. +#{"EGLEndpointTest"},(0x101FB3E8),1,0,1; +; + +;*Unique (Non-Localized) Vendor name +;This is used in combination with signing to prevent the unauthroized +;upgrade of a a package by someone other than the rightful vendor. +:"Nokia" + +;*Localized Vendor Name +;This specifies the localized vendor name(s) corresponding to language(s). +%{"Nokia Test EN"} + +;*Files To Copy... + +"..\scripts\egltest_t_endpoint.script"-"c:\egltest\egltest_t_endpoint.script" + diff -r bf7481649c98 -r 7f25ef56562d egl/egltest/group/egltest_helium.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/egl/egltest/group/egltest_helium.pkg Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,52 @@ +; Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +; All rights reserved. +; This component and the accompanying materials are made available +; under the terms of "Eclipse Public License v1.0" +; which accompanies this distribution, and is available +; at the URL "http://www.eclipse.org/legal/epl-v10.html". +; +; Initial Contributors: +; Nokia Corporation - initial contribution. +; +; Contributors: +; +; Description: +; +;File: bitgdi.pkg; +; +;Auto-generated PKG file by Nokia PKG Wizard for CodeWarrior IDE + +;*Languages +&EN +; +;*Standard SIS file header. This section specifies the package name, +;application UID, and version/build numbers. Add the package TYPE here if needed. +#{"EGLTest"},(0x101FB3E8),1,0,1; +; + +;*Unique (Non-Localized) Vendor name +;This is used in combination with signing to prevent the unauthroized +;upgrade of a a package by someone other than the rightful vendor. +:"Nokia" + +;*Localized Vendor Name +;This specifies the localized vendor name(s) corresponding to language(s). +%{"Nokia Test EN"} + +;*Files To Copy... + +"..\scripts\egltest_t_general.script"-"c:\egltest\egltest_t_general.script" +"..\scripts\egltest_t_geterroranddisplay.script"-"c:\egltest\egltest_t_geterroranddisplay.script" +"..\scripts\egltest_t_syncobject.script"-"c:\egltest\egltest_t_syncobject.script" +"..\scripts\egltest_t_syncobject_flush.script"-"c:\egltest\egltest_t_syncobject_flush.script" +"..\scripts\egltest_t_nativepixmaptype.script"-"c:\egltest\egltest_t_nativepixmaptype.script" +"..\scripts\egltest_t_createpixmapsurface.script"-"c:\egltest\egltest_t_createpixmapsurface.script" +"..\scripts\egltest_t_image.script"-"c:\egltest\egltest_t_image.script" +"..\scripts\egltest_t_sibling.script"-"c:\egltest\egltest_t_sibling.script" +"..\scripts\egltest_t_vgimagetosurfaces.script"-"c:\egltest\egltest_t_vgimagetosurfaces.script" +"..\scripts\egltest_t_image_multithread.script"-"c:\egltest\egltest_t_image_multithread.script" +"..\scripts\egltest_t_image_multiprocess.script"-"c:\egltest\egltest_t_image_multiprocess.script" +"..\scripts\egltest_t_image_negative.script"-"c:\egltest\egltest_t_image_negative.script" +"..\scripts\egltest_t_benchmark_sgimage.script"-"c:\egltest\egltest_t_benchmark_sgimage.script" +"..\scripts\egltest_t_benchmark_swapbuffers.script"-"c:\egltest\egltest_t_benchmark_swapbuffers.script" + diff -r bf7481649c98 -r 7f25ef56562d egl/egltest/inc/egltest_oom_sgimage.h --- a/egl/egltest/inc/egltest_oom_sgimage.h Fri Jun 11 14:58:47 2010 +0300 +++ b/egl/egltest/inc/egltest_oom_sgimage.h Wed Jun 23 19:41:15 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -122,4 +122,24 @@ void doProcessFunctionL(TInt aIdx); }; +_LIT(KOOM_CloseSgImageDifferentProcess, "OOM_CloseSgImageDifferentProcess"); +NONSHARABLE_CLASS(CEglTest_OOM_CloseSgImageDifferentProcess) : public CEglTest_OOM_Base + { +public: + // from CTestStep + TVerdict doTestStepL(); + +protected: + // from CEglTestStep + void doProcessFunctionL(TInt aIdx); + }; + +_LIT(KOOM_CloseSgImageSameThread, "OOM_CloseSgImageSameThread"); +NONSHARABLE_CLASS(CEglTest_OOM_CloseSgImageSameThread) : public CEglTest_OOM_Base + { +public: + // from CTestStep + TVerdict doTestStepL(); + }; + #endif // __EGLTEST_OOM_SGIMAGE_H__ diff -r bf7481649c98 -r 7f25ef56562d egl/egltest/scripts/egltest_t_oom_sgimage.script --- a/egl/egltest/scripts/egltest_t_oom_sgimage.script Fri Jun 11 14:58:47 2010 +0300 +++ b/egl/egltest/scripts/egltest_t_oom_sgimage.script Wed Jun 23 19:41:15 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -22,3 +22,5 @@ RUN_TEST_STEP 400 egltestserver OOM_CloseVGImage RUN_TEST_STEP 400 egltestserver OOM_ClosePixmapSurfaceWithTermination RUN_TEST_STEP 400 egltestserver OOM_ClosePixmapSurface +RUN_TEST_STEP 400 egltestserver OOM_CloseSgImageSameThread +RUN_TEST_STEP 400 egltestserver OOM_CloseSgImageDifferentProcess diff -r bf7481649c98 -r 7f25ef56562d egl/egltest/src/egltest_oom_sgimage.cpp --- a/egl/egltest/src/egltest_oom_sgimage.cpp Fri Jun 11 14:58:47 2010 +0300 +++ b/egl/egltest/src/egltest_oom_sgimage.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -34,6 +34,9 @@ //There is no need to put it into INI file const TUidPixelFormat KOOMPixelFormat = EUidPixelFormatARGB_8888; +// Deviation in per cent for test 0442 and 0443 +const TInt KOOMSgImageDeviation = 5; + CEglTest_OOM_Base::~CEglTest_OOM_Base() { @@ -192,14 +195,14 @@ if(iGPUUsedMemory.Count() > 0) { res = Deviation(iGPUUsedMemory); - TEST(iThresholdGPUUsedMemory >= res); + ASSERT_TRUE(iThresholdGPUUsedMemory >= res); INFO_PRINTF3(_L("GPU used memory deviation %d %%, threshold %d %%"), res, iThresholdGPUUsedMemory); } if(iLastIterations.Count() > 0) { res = Deviation(iLastIterations); - TEST(iThresholdLastIteration >= res); + ASSERT_TRUE(iThresholdLastIteration >= res); INFO_PRINTF3(_L("Last iteration deviation %d %%, threshold %d %%"), res, iThresholdLastIteration); } } @@ -445,7 +448,7 @@ if(res != KErrNone || sgImage.IsNull()) { INFO_PRINTF5(_L("***Fail to create RSgImage after %d attempts, error: %d, expected %d or %d"), index, res, KErrNoMemory, KErrNoGraphicsMemory); - TEST((res == KErrNoMemory) || (res == KErrNoGraphicsMemory)); + ASSERT_TRUE((res == KErrNoMemory) || (res == KErrNoGraphicsMemory)); break; } EGLImageKHR eglImages = iEglSess->eglCreateImageKhrL(iDisplay,EGL_NO_CONTEXT,EGL_NATIVE_PIXMAP_KHR,&sgImage,const_cast (KEglImageAttribsPreservedTrue)); @@ -453,7 +456,7 @@ if((eglImages == EGL_NO_IMAGE_KHR) || (eglError != EGL_SUCCESS)) { INFO_PRINTF4(_L("***Fail to create EGLImage after %d attempts, error: %d, expected: %d"), index, eglError, EGL_BAD_ALLOC); - TEST(eglError == EGL_BAD_ALLOC); + ASSERT_TRUE(eglError == EGL_BAD_ALLOC); break; } @@ -462,7 +465,7 @@ if(vgImage == VG_INVALID_HANDLE || (vgError != VG_NO_ERROR)) { INFO_PRINTF4(_L("***Fail to create VGImage after %d attempts, error: %d, expected: %d"), index, vgError, VG_OUT_OF_MEMORY_ERROR); - TEST(vgError == VG_OUT_OF_MEMORY_ERROR); + ASSERT_TRUE(vgError == VG_OUT_OF_MEMORY_ERROR); break; } } //for @@ -491,7 +494,7 @@ CleanupStack::PopAndDestroy(&messageQueueProcId); RProcess process; - TESTL(process.Open(procId) == KErrNone); + ASSERT_TRUE(process.Open(procId) == KErrNone); process.Kill(KErrNone); process.Close(); @@ -598,7 +601,7 @@ void CEglTest_OOM_CloseVGImage::doProcessFunctionL(TInt aIdx) { - INFO_PRINTF2(_L("CEglTest_OOM_CloseVGImageWithTermination::doProcessFunctionL, Process %d"),aIdx); + INFO_PRINTF2(_L("CEglTest_OOM_CloseVGImage::doProcessFunctionL, Process %d"),aIdx); #ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE GetDisplayL(); CreateEglSessionL(aIdx); @@ -625,7 +628,7 @@ if(res != KErrNone || sgImage.IsNull()) { INFO_PRINTF5(_L("***Fail to create RSgImage after %d attempts, error: %d, expected: %d or %d"), index, res, KErrNoMemory, KErrNoGraphicsMemory); - TEST((res == KErrNoMemory) || (res == KErrNoGraphicsMemory)); + ASSERT_TRUE((res == KErrNoMemory) || (res == KErrNoGraphicsMemory)); break; } iSgImages.AppendL(sgImage); @@ -635,7 +638,7 @@ if((eglImage == EGL_NO_IMAGE_KHR) || (eglError != EGL_SUCCESS)) { INFO_PRINTF4(_L("***Fail to create EGLImage after %d attempts, error: %d, expected: %d"), index, eglError, EGL_BAD_ALLOC); - TEST(eglError == EGL_BAD_ALLOC); + ASSERT_TRUE(eglError == EGL_BAD_ALLOC); break; } iEglImages.AppendL(eglImage); @@ -645,7 +648,7 @@ if(vgImage == VG_INVALID_HANDLE || (vgError != VG_NO_ERROR)) { INFO_PRINTF4(_L("***Fail to create VGImage after %d attempts, error: %d, expected: %d"), index, vgError, VG_OUT_OF_MEMORY_ERROR); - TEST(vgError == VG_OUT_OF_MEMORY_ERROR); + ASSERT_TRUE(vgError == VG_OUT_OF_MEMORY_ERROR); break; } iVgImages.AppendL(vgImage); @@ -777,7 +780,7 @@ if(res != KErrNone || sgImage.IsNull()) { INFO_PRINTF5(_L("***Fail to create RSgImage after %d attempts, error: %d, expected: %d or %d"), index, res, KErrNoMemory, KErrNoGraphicsMemory); - TEST((res == KErrNoMemory) || (res == KErrNoGraphicsMemory)); + ASSERT_TRUE((res == KErrNoMemory) || (res == KErrNoGraphicsMemory)); break; } @@ -797,7 +800,7 @@ if((surface == EGL_NO_SURFACE) || (eglError != EGL_SUCCESS)) { INFO_PRINTF4(_L("***Fail to create Pixmap surface after %d attempts, error: %d, expected: %d"), index, eglError, EGL_BAD_ALLOC); - TEST(eglError == EGL_BAD_ALLOC); + ASSERT_TRUE(eglError == EGL_BAD_ALLOC); break; } } //for @@ -826,7 +829,7 @@ CleanupStack::PopAndDestroy(&messageQueueProcId); RProcess process; - TESTL(process.Open(procId) == KErrNone); + ASSERT_TRUE(process.Open(procId) == KErrNone); process.Kill(KErrNone); process.Close(); @@ -946,7 +949,7 @@ if(res != KErrNone || sgImage.IsNull()) { INFO_PRINTF5(_L("***Fail to create RSgImage after %d attempts, error: %d, expected: %d or %d"), index, res, KErrNoMemory, KErrNoGraphicsMemory); - TEST((res == KErrNoMemory) || (res == KErrNoGraphicsMemory)); + ASSERT_TRUE((res == KErrNoMemory) || (res == KErrNoGraphicsMemory)); break; } iSgImages.AppendL(sgImage); @@ -967,7 +970,7 @@ if((surface == EGL_NO_SURFACE) || (eglError != EGL_SUCCESS)) { INFO_PRINTF4(_L("***Fail to create Pixmap surface after %d attempts, error: %d, expected: %d "), index, eglError, EGL_BAD_ALLOC); - TEST(eglError == EGL_BAD_ALLOC); + ASSERT_TRUE(eglError == EGL_BAD_ALLOC); break; } iSurfaces.AppendL(surface); @@ -980,3 +983,353 @@ #endif } +/** +@SYMTestCaseID GRAPHICS-EGL-0442 + +@SYMTestPriority 1 + +@SYMPREQ 2637 + +@SYMTestCaseDesc + OOM test – Check SgImages are removed when SgImage handles in multiple processes are closed + +@SYMTestActions +Environmental settings: +• Image Size: as per ini file +• List of simulated load: 0% +• List of pixel formats +ESgPixelFormatARGB_8888 +• Client process priorities - all the same +• Client process random parameters: +- None + +The creation of RSgImages and launching of processes is along the lines of the method outlined in GRAPHICS-EGL-RSGIMAGE_LITE-0406 + + From the main process: + Spawn 2 client processes A and B. + Wait until client processes exit + If the test fails not due to the memory allocation record an error code to the log file then set a test result as a failure and skip further actions. + End loop + Exit + + From client process A: + Get EGL display + Initialize EGL + Open RSgDriver + Loop until exit condition met + Start loop: + Create SgImage + Exit condition – SgImage surface creation has failed. + End loop: + Make the process busy by putting it into the indefinite loop. + + From client process B: + Start loop: + Open SgImage + Close SgImage + End loop: + + From client process A: + Start loop: + Close SgImage + End loop: + Check all memory has been deallocated by starting a second loop + Start loop 2: + Create SgImage + Exit condition – SgImage surface creation has failed. + End loop: + Check that the amount of images created within this loop 2 is similar to loop 1, + meaning that all images were correctly freed. + Cleanup everything + + Terminate process A + Terminate process B + +@SYMTestExpectedResults +For each step from 0 to N in the main process, +- Image or surface allocation failure must happen at approximately the same iteration + in process A. +*/ +TVerdict CEglTest_OOM_CloseSgImageDifferentProcess::doTestStepL() + { + SetTestStepID(_L("GRAPHICS-EGL-0442")); + SetTestStepName(KOOM_CloseSgImageDifferentProcess); + INFO_PRINTF1(_L("CEglTest_OOM_CloseSgImageDifferentProcess::doTestStepL")); + +#ifndef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE + INFO_PRINTF1(_L("CEglTest_OOM_CloseSgImageDifferentProcess can only be run with SgImage-Lite")); +#else + TBool ret = CheckForExtensionL(KEGL_RSgimage | KEGL_KHR_image_base | KVG_KHR_EGL_image | KEGL_KHR_image_pixmap); + if(ret) + { + // launch 2 processes + Test_MultiProcessL(KEglTestStepDllName, 2, TestStepName()); + } + INFO_PRINTF1(_L("Exit: CEglTest_OOM_CloseSgImageDifferentProcess::doTestStepL")); +#endif //SYMBIAN_GRAPHICS_EGL_SGIMAGELITE + RecordTestResultL(); + CloseTMSGraphicsStep(); + return TestStepResult(); + } + +void CEglTest_OOM_CloseSgImageDifferentProcess::doProcessFunctionL(TInt aIdx) + { + INFO_PRINTF2(_L("CEglTest_OOM_CloseSgImageDifferentProcess::doProcessFunctionL, Process %d"),aIdx); +#ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE + + GetDisplayL(); + CreateEglSessionL(aIdx); + iEglSess->InitializeL(); + iEglSess->OpenSgDriverL(); + + //create the queue to send/receive SgImage ID between processes + RMsgQueue messageQueueSgId; + User::LeaveIfError(messageQueueSgId.Open(EProcSlotMsgQueueSgId, EOwnerProcess)); + CleanupClosePushL(messageQueueSgId); + + // create as many sgimages until it reaches out of memory + TInt numImages = 0; + if(aIdx == 0) + { + for(;;++numImages) + { + RSgImage sgImage; + TInt res = sgImage.Create(TSgImageInfo(iImageSize, KOOMPixelFormat, ESgUsageBitOpenVgImage)); + if(res != KErrNone || sgImage.IsNull()) + { + INFO_PRINTF5(_L("***Fail to create RSgImage after %d attempts, error: %d, expected: %d or %d"), numImages, res, KErrNoMemory, KErrNoGraphicsMemory); + ASSERT_TRUE((res == KErrNoMemory) || (res == KErrNoGraphicsMemory)); + break; + } + iSgImages.AppendL(sgImage); + } + } + + // Send to process B how many images it needs to wait for + if(aIdx == 0) + { + // send a TInt as a fake SgImage Id + messageQueueSgId.SendBlocking(reinterpret_cast(numImages)); + } + else if (aIdx == 1) + { + // receive the fake SgImage Id and convert it to a TInt + TSgDrawableId fakeId; + messageQueueSgId.ReceiveBlocking(fakeId); + numImages = reinterpret_cast(fakeId); + } + + // Wait for both processes to reach this point + Rendezvous(aIdx); + + // Now process B knows how many images needs to wait for + if(aIdx == 0) + { + for(TInt index = 0; indexCloseSgDriver(); + CleanAll(); +#endif //SYMBIAN_GRAPHICS_EGL_SGIMAGELITE + } + +/** +@SYMTestCaseID GRAPHICS-EGL-0443 + +@SYMTestPriority 1 + +@SYMPREQ 2637 + +@SYMTestCaseDesc + OOM test – Check SgImages are removed when SgImage handles in multiple processes are closed + +@SYMTestActions +Environmental settings: +• Image Size: as per ini file +• List of simulated load: 0% +• List of pixel formats +ESgPixelFormatARGB_8888 +• Client process priorities - all the same +• Client process random parameters: +- None + +The creation of RSgImages and launching of processes is along the lines of the method outlined in GRAPHICS-EGL-RSGIMAGE_LITE-0406 + + From the main process: + From client process A: + Get EGL display + Initialize EGL + Open RSgDriver + Loop until exit condition met + Start loop: + Create SgImage + Exit condition – SgImage surface creation has failed. + End loop: + Start loop: + Open SgImage + Close SgImage + End loop: + Start loop: + Close SgImage + End loop: + Check all memory has been deallocated by starting a second loop + Start loop 2: + Create SgImage + Exit condition – SgImage surface creation has failed. + End loop: + Check that the amount of images created within this loop 2 is similar to loop 1, + meaning that all images were correctly freed. + Cleanup everything + +@SYMTestExpectedResults +For each step from 0 to N in the main process, +- Image or surface allocation failure must happen at approximately the same iteration + in process A. +*/ +TVerdict CEglTest_OOM_CloseSgImageSameThread::doTestStepL() + { + SetTestStepID(_L("GRAPHICS-EGL-0443")); + SetTestStepName(KOOM_CloseSgImageSameThread); + INFO_PRINTF1(_L("CEglTest_OOM_CloseSgImageSameThread::doTestStepL")); + +#ifndef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE + INFO_PRINTF1(_L("CEglTest_OOM_CloseSgImageSameThread can only be run with SgImage-Lite")); +#else + TBool ret = CheckForExtensionL(KEGL_RSgimage | KEGL_KHR_image_base | KVG_KHR_EGL_image | KEGL_KHR_image_pixmap); + if(ret) + { + GetDisplayL(); + CreateEglSessionL(0); + iEglSess->InitializeL(); + iEglSess->OpenSgDriverL(); + + // create as many sgimages until it reaches out of memory + TInt numImages = 0; + for(;;++numImages) + { + RSgImage sgImage; + TInt res = sgImage.Create(TSgImageInfo(iImageSize, KOOMPixelFormat, ESgUsageBitOpenVgImage)); + if(res != KErrNone || sgImage.IsNull()) + { + INFO_PRINTF5(_L("***Fail to create RSgImage after %d attempts, error: %d, expected: %d or %d"), numImages, res, KErrNoMemory, KErrNoGraphicsMemory); + ASSERT_TRUE((res == KErrNoMemory) || (res == KErrNoGraphicsMemory)); + break; + } + iSgImages.AppendL(sgImage); + } + + //open a duplicate handle for the created images (can close straightaway) + for(TInt index = 0; indexCloseSgDriver(); + CleanAll(); + + // check numbers... + INFO_PRINTF2(_L("***Num sgImages created first time: %d."), numImages); + INFO_PRINTF2(_L("***Num sgImages created second time: %d."), numImages2); + TInt deviation = Abs(((numImages2*100) / numImages) - 100); + ASSERT_TRUE(deviation < KOOMSgImageDeviation); + INFO_PRINTF3(_L("***Deviation: %d%% (must be less than %d%%)"), deviation, KOOMSgImageDeviation); + } + INFO_PRINTF1(_L("Exit: CEglTest_OOM_CloseSgImageSameThread::doTestStepL")); +#endif //SYMBIAN_GRAPHICS_EGL_SGIMAGELITE + + RecordTestResultL(); + CloseTMSGraphicsStep(); + return TestStepResult(); + } + diff -r bf7481649c98 -r 7f25ef56562d egl/egltest/src/eglteststep.cpp --- a/egl/egltest/src/eglteststep.cpp Fri Jun 11 14:58:47 2010 +0300 +++ b/egl/egltest/src/eglteststep.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -160,13 +160,15 @@ // Benchmark - SwapBuffers else if (aStepName == KBenchmark_SwapBuffers) testStep = new CEglTest_Benchmark_SwapBuffers; - //OOM + //OOM - SgImage else if (aStepName == KOOM_CloseVGImageWithTermination) testStep = new CEglTest_OOM_CloseVGImageWithTermination; else if (aStepName == KOOM_CloseVGImage) testStep = new CEglTest_OOM_CloseVGImage; else if (aStepName == KOOM_ClosePixmapSurfaceWithTermination) testStep = new CEglTest_OOM_ClosePixmapSurfaceWithTermination; - else if (aStepName == KOOM_ClosePixmapSurface) testStep = new CEglTest_OOM_ClosePixmapSurface; + else if (aStepName == KOOM_ClosePixmapSurface) testStep = new CEglTest_OOM_ClosePixmapSurface; + else if (aStepName == KOOM_CloseSgImageDifferentProcess) testStep = new CEglTest_OOM_CloseSgImageDifferentProcess; + else if (aStepName == KOOM_CloseSgImageSameThread) testStep = new CEglTest_OOM_CloseSgImageSameThread; - //Stress + //Stress - SgImage else if (aStepName == KStress) testStep = new CEglTest_Stress; return testStep; diff -r bf7481649c98 -r 7f25ef56562d fbs/fontandbitmapserver/group/BLD.INF --- a/fbs/fontandbitmapserver/group/BLD.INF Fri Jun 11 14:58:47 2010 +0300 +++ b/fbs/fontandbitmapserver/group/BLD.INF Wed Jun 23 19:41:15 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -48,8 +48,6 @@ ../group/FBSERV.MMP ../group/fbsrasterizerlib.mmp ../group/stubrasterizer.mmp -../group/fbscli_fmm.mmp -../group/fbserv_fmm.mmp PRJ_TESTEXPORTS diff -r bf7481649c98 -r 7f25ef56562d fbs/fontandbitmapserver/group/FBSCLI.MMP --- a/fbs/fontandbitmapserver/group/FBSCLI.MMP Fri Jun 11 14:58:47 2010 +0300 +++ b/fbs/fontandbitmapserver/group/FBSCLI.MMP Wed Jun 23 19:41:15 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 1998-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -28,7 +28,6 @@ SOURCEPATH ../sfbs userinclude ../inc -userinclude ../../../../textandloc/fontservices/fontstore/src OS_LAYER_SYSTEMINCLUDE_SYMBIAN diff -r bf7481649c98 -r 7f25ef56562d fbs/fontandbitmapserver/group/fbscli_fmm.mmp --- a/fbs/fontandbitmapserver/group/fbscli_fmm.mmp Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,85 +0,0 @@ -// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// fbscli.dll Font & Bitmap server client-side library -// -// - -/** - @file -*/ - -target fbscli_fmm.dll -CAPABILITY All -Tcb -targettype DLL - -UID 0x1000008D 0x10003A15 -VENDORID 0x70000001 -SOURCEPATH ../sfbs - -userinclude ../inc -userinclude ../../../../textandloc/fontservices/fontstore/src -OS_LAYER_SYSTEMINCLUDE_SYMBIAN - -source BITBMP.CPP -source BITCOMP.CPP -source BITBMPEX.CPP -source BMPASTR.CPP -source BMPUTIL.CPP -source FBSBMP.CPP -source FBSFONT.CPP -source PILE.CPP -source SESSION.CPP -source TFSTORE.CPP -source FbsRalc.cpp -source fbshelper.cpp -source ShiftedFileStore.cpp -source BitmapCompr.cpp -source patchableconstantscli.cpp - -library euser.lib -library efsrv.lib -library estor.lib -library gdi.lib -library fntstr.lib -library scdv.lib -library palette.lib -library lookuptable.lib -library hal.lib -#if !defined(WINS) -library fbsrasterizer.lib -#endif - -deffile FBSCLI2.DEF - - -START WINS -BASEADDRESS 0x41400000 -END -//configurable value to control bitmap heap management by setting -//large bitmap threshold (requires rebuild) -MACRO KMaxLargeBitmapAlloc=0x4000 -//MACRO SYMBIAN_DISABLE_HARDWARE_BITMAP_WHITEFILL // Uncomment this macro to disable whitefill of hardware bitmaps on creation - -// KCompressionThreshold is used to determine whether a bitmap gets compressed. Values of 0 -> 256 represent 0% to 100% -// where 0% = no compression. A value of 205 means that bitmaps are only compressed when the resulting size is 80% or -// less of the original size. -MACRO KCompressionThreshold=205 - -MACRO FNTSTORE_SUPPORT_FMM - -UNPAGED - - -SMPSAFE - diff -r bf7481649c98 -r 7f25ef56562d fbs/fontandbitmapserver/group/fbserv.iby --- a/fbs/fontandbitmapserver/group/fbserv.iby Fri Jun 11 14:58:47 2010 +0300 +++ b/fbs/fontandbitmapserver/group/fbserv.iby Wed Jun 23 19:41:15 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 1998-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -47,8 +47,8 @@ #define FBSERV_PAGEDDATA_CONFIG unpageddata #endif - file=ABI_DIR\BUILD_DIR\fbserv_fmm.exe \sys\bin\fbserv.exe FBSERV_PAGEDDATA_CONFIG - file=ABI_DIR\BUILD_DIR\fbscli_fmm.dll \sys\bin\fbscli.dll + file=ABI_DIR\BUILD_DIR\fbserv.exe \sys\bin\fbserv.exe FBSERV_PAGEDDATA_CONFIG + file=ABI_DIR\BUILD_DIR\fbscli.dll \sys\bin\fbscli.dll #else file=ABI_DIR\DEBUG_DIR\fbserv.exe sys\bin\fbserv.exe file=ABI_DIR\DEBUG_DIR\fbscli.dll sys\bin\fbscli.dll diff -r bf7481649c98 -r 7f25ef56562d fbs/fontandbitmapserver/group/fbserv_fmm.mmp --- a/fbs/fontandbitmapserver/group/fbserv_fmm.mmp Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,77 +0,0 @@ -// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// fbserv.exe Font & Bitmap server -// -// - -/** - @file -*/ - -// Default stack size(8K) is too small and causes stack overflow -// in the hardware test udeb -EPOCSTACKSIZE 16384 -EPOCHEAPSIZE 0x10000 0x200000 - -target fbserv_fmm.exe - -EPOCFIXEDPROCESS -CAPABILITY ProtServ -targettype exexp - -uid 0x1000008C 0x10003A16 -VENDORID 0x70000001 - -userinclude ../inc -userinclude ../sfbs -userinclude ../../../../textandloc/fontservices/fontstore/src - -OS_LAYER_SYSTEMINCLUDE_SYMBIAN -OS_LAYER_ESTLIB_SYSTEMINCLUDE - -sourcepath ../sfbs - -source FBSCLI.CPP -source FBSMAIN.CPP -source FBSTOP.CPP -source BackGroundCompression.CPP -source SERVER.CPP -source FBSMBMC.CPP -source ShiftedFileStore.cpp -source HASHMAP.CPP -source patchableconstants.cpp - -library euser.lib -library efsrv.lib -library gdi.lib -library fntstr.lib -library fbscli.lib -library estor.lib -library ecom.lib -library hal.lib - -start wins -baseaddress 0x41500000 -end - -deffile fbserv.def - -MACRO KFBSERVInitialHeapSize=0x10000 -MACRO KFBSERVHeapGrowByMultiplier=4 -MACRO KFBSERVSharedBitmapHashTableSizeInBits=12 -MACRO FNTSTORE_SUPPORT_FMM -UNPAGEDCODE //Configure data paging via fbserv.iby - - -SMPSAFE diff -r bf7481649c98 -r 7f25ef56562d fbs/fontandbitmapserver/group/fbservtest_helium.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fbs/fontandbitmapserver/group/fbservtest_helium.pkg Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,184 @@ +; +; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +; All rights reserved. +; This component and the accompanying materials are made available +; under the terms of "Eclipse Public License v1.0" +; which accompanies this distribution, and is available +; at the URL "http://www.eclipse.org/legal/epl-v10.html". +; +; Initial Contributors: +; Nokia Corporation - initial contribution. +; +; Contributors: +; +; Description: +; +;File: bitgdi.pkg; +; +;Auto-generated PKG file by Nokia PKG Wizard for CodeWarrior IDE + +;*Languages +&EN +; +;*Standard SIS file header. This section specifies the package name, +;application UID, and version/build numbers. Add the package TYPE here if needed. +#{"FbservTest"},(0x101FB3E8),1,0,1; +; + +;*Unique (Non-Localized) Vendor name +;This is used in combination with signing to prevent the unauthroized +;upgrade of a a package by someone other than the rightful vendor. +:"Nokia" + +;*Localized Vendor Name +;This specifies the localized vendor name(s) corresponding to language(s). +%{"Nokia Test EN"} + +;*Files To Copy... + +;#include +;#include + +;// batch file that runs all automatic fbserv tests +;data=DATAZ_\fbstest\fbstest_run.bat \fbstest_run.bat +;data=DATAZ_\fbstest\fbstest.bat \fbstest.bat + +;//script files +"..\tfbs\scripts\fbstest_T_Alloc.script"-"c:\fbstest\fbstest_T_Alloc.script" +;"..\tfbs\scripts\fbstest_T_Alloc.ini"-"c:\fbstest\fbstest_T_Alloc.ini" +"..\tfbs\scripts\fbstest_T_Bitmap.script"-"c:\fbstest\fbstest_T_Bitmap.script" +"..\tfbs\scripts\fbstest_T_Fbs.script"-"c:\fbstest\fbstest_T_Fbs.script" +"..\tfbs\scripts\fbstest_T_Compressed.script"-"c:\fbstest\fbstest_T_Compressed.script" +"..\tfbs\scripts\fbstest_T_Ralc.script"-"c:\fbstest\fbstest_T_Ralc.script" +"..\tfbs\scripts\fbstest_T_Defect.script"-"c:\fbstest\fbstest_T_Defect.script" +"..\tfbs\scripts\fbstest_T_StreamIdCache.script"-"c:\fbstest\fbstest_T_StreamIdCache.script" +"..\tfbs\scripts\fbstest_T_Secure.script"-"c:\fbstest\fbstest_T_Secure.script" +"..\tfbs\scripts\fbstest_T_File.script"-"c:\fbstest\fbstest_T_File.script" +"..\tfbs\scripts\fbstest_t_getallbitmapscapability.script"-"c:\fbstest\fbstest_t_getallbitmapscapability.script" +"..\tfbs\scripts\fbstest_T_Clean.script"-"c:\fbstest\fbstest_T_Clean.script" +"..\tfbs\scripts\fbstest_t_fonttable.script"-"c:\fbstest\fbstest_t_fonttable.script" +"..\tfbs\scripts\fbstest_T_IPCTest.script"-"c:\fbstest\fbstest_T_IPCTest.script" +"..\tfbs\scripts\ipctest_config.ini"-"c:\fbstest\ipctest_config.ini" +"..\tfbs\scripts\fbstest_t_extendedbitmap.script"-"c:\fbstest\fbstest_t_extendedbitmap.script" +"..\tfbs\scripts\extendedbitmap_config.ini"-"c:\fbstest\extendedbitmap_config.ini" +"..\tfbs\scripts\fbstest_T_WDP_pagedata.script"-"c:\fbstest\fbstest_T_WDP_pagedata.script" +"..\tfbs\scripts\fbstest_T_WDP_unpagedata.script"-"c:\fbstest\fbstest_T_WDP_unpagedata.script" +"..\tfbs\scripts\fbstest_T_WDP_page_bitmap_data_only.script"-"c:\fbstest\fbstest_T_WDP_page_bitmap_data_only.script" +"..\tfbs\scripts\fbstest_T_WDP_page_bitmap_data_and_shared_heap_only.script"-"c:\fbstest\fbstest_T_WDP_page_bitmap_data_and_shared_heap_only.script" +;"..\tfbs\scripts\wdptest_config.ini"-"c:\fbstest\wdptest_config.ini" + +;// Fbserv WDP Alloc stress test +"..\tfbs\scripts\fbstest_T_WDP_Alloc_Stress.script"-"c:\fbstest\fbstest_T_WDP_Alloc_Stress.script" +;data=DATAZ_\fbstest\fbstest_T_WDP_Alloc_Stress.ini \fbstest\fbstest_T_WDP_Alloc_Stress.ini + +;REM near-duplicate fonts for test CTFnt::TestDuplicateFontFileEntries +;data=DATAZ_\PlatTest\Graphics\TestData\uniquified_fonts\xx_dejavusanscondensed.ttf \PlatTest\Graphics\TestData\uniquified_fonts\xx_dejavusanscondensed.ttf + + +;// TFbsServer.exe needs to be copied into \sys\bin\ and set as data so it will be copied to the c: drive and we can change the capabilities of the .exe +;data=ABI_DIR\DEBUG_DIR\TFbsServer.exe \sys\bin\TFbsServer.exe +; +;data=ZSYSTEM\DATA\24bitSkin.mbm \System\Data\24bitSkin.mbm +;data=ZSYSTEM\DATA\16bitSkin.mbm \System\Data\16bitSkin.mbm +;data=ZSYSTEM\DATA\24bit6col.mbm \System\Data\24bit6col.mbm +;data=ZSYSTEM\DATA\24bit2col.mbm \System\Data\24bit2col.mbm +;data=ZSYSTEM\DATA\24bit3col.mbm \System\Data\24bit3col.mbm +;data=ZSYSTEM\DATA\16bit6col.mbm \System\Data\16bit6col.mbm +;data=ZSYSTEM\DATA\16bit2col.mbm \System\Data\16bit2col.mbm +;data=ZSYSTEM\DATA\16bit3col.mbm \System\Data\16bit3col.mbm +;data=ZSYSTEM\DATA\16bit20col.mbm \System\Data\16bit20col.mbm +;data=ZSYSTEM\DATA\32bitSkin.mbm \System\Data\32bitSkin.mbm +;data=ZSYSTEM\DATA\32bit2col.mbm \System\Data\32bit2col.mbm +;data=ZSYSTEM\DATA\32bit3col.mbm \System\Data\32bit3col.mbm +;data=ZSYSTEM\DATA\32bit6col.mbm \System\Data\32bit6col.mbm +;data=ZSYSTEM\DATA\32bit20col.mbm \System\Data\32bit20col.mbm +;data=ZSYSTEM\DATA\24bit20col.mbm \System\Data\24bit20col.mbm +;data=ZSYSTEM\DATA\tfbs.mbm \System\Data\tfbs.mbm +;data=ZSYSTEM\DATA\testcompression.mbm \System\Data\testcompression.mbm +;data=ZSYSTEM\DATA\tfbs.rbm \System\Data\tfbs.rbm +;data=ZSYSTEM\DATA\8bitNoDither.mbm \System\Data\8bitNoDither.mbm +;data=ZSYSTEM\DATA\8bitDitherFs.mbm \System\Data\8bitDitherFs.mbm +;data=ZSYSTEM\DATA\12bit.mbm \System\Data\12bit.mbm +;data=ZSYSTEM\DATA\16bit.mbm \System\Data\16bit.mbm +;data=ZSYSTEM\DATA\24bit.mbm \System\Data\24bit.mbm +;data=ZSYSTEM\DATA\32bit.mbm \System\Data\32bit.mbm +;data=ZSYSTEM\DATA\file.mbm \System\Data\file.mbm +;data=ZSYSTEM\DATA\filecomp.mbm \System\Data\filecomp.mbm +;data=ZSYSTEM\DATA\rom.mbm \System\Data\rom.mbm +;data=ZSYSTEM\DATA\romcomp.mbm \System\Data\romcomp.mbm +;data=ZSYSTEM\DATA\tfbs_file2.mbm \siuhsiughighifhgidfhguifhguidhfguifhghlarglaghghghghghkrjghszkjg\system\data\tfbs_file2.mbm +;data=ZSYSTEM\DATA\tfbs_file2.mbm \system\data\tfbs_file2.mbm +;data=ZSYSTEM\DATA\tfbs_file1.mbm \siuhsiughighifhgidfhguifhguidhfguifhghlarglaghghghghghkrjghszkjg\system\data\tfbs_file1.mbm +;data=ZSYSTEM\DATA\tfbs_file1.mbm \system\data\tfbs_file1.mbm +;data=ZSYSTEM\DATA\tfbs_file3.mbm \System\Data\tfbs_file3.mbm +;data=ZSYSTEM\DATA\tfbs_file4.mbm \System\Data\tfbs_file4.mbm +;data=ZSYSTEM\DATA\tfbs_file4a.mbm \System\Data\tfbs_file4a.mbm +;data=ZSYSTEM\DATA\tfbs_file4b.mbm \System\Data\tfbs_file4b.mbm +;data=ZSYSTEM\DATA\tfbs_file4c.mbm \System\Data\tfbs_file4c.mbm +;data=ZSYSTEM\DATA\tfbs_file4d.mbm \System\Data\tfbs_file4d.mbm +;data=ZSYSTEM\DATA\tfbs_file4e.mbm \System\Data\tfbs_file4e.mbm +;data=ZSYSTEM\DATA\tfbs_file4f.mbm \System\Data\tfbs_file4f.mbm +;data=ZSYSTEM\DATA\tfbs_file4g.mbm \System\Data\tfbs_file4g.mbm +;data=ZSYSTEM\DATA\tfbs_file4h.mbm \System\Data\tfbs_file4h.mbm +;data=ZSYSTEM\DATA\tfbs_file5.mbm \System\Data\tfbs_file5.mbm +;data=ZSYSTEM\DATA\compr12.mbm \System\Data\compr12.mbm +;data=ZSYSTEM\DATA\compr16.mbm \System\Data\compr16.mbm +;data=ZSYSTEM\DATA\compr24.mbm \System\Data\compr24.mbm +;data=ZSYSTEM\DATA\racompr12.mbm \System\Data\racompr12.mbm +;data=ZSYSTEM\DATA\racompr16.mbm \System\Data\racompr16.mbm +;data=ZSYSTEM\DATA\racompr24.mbm \System\Data\racompr24.mbm +; +;data=ZSYSTEM\DATA\RC_ROM8.mbm System\data\RC_ROM8.mbm +;data=ZSYSTEM\DATA\RC_ROM12.mbm System\data\RC_ROM12.mbm +;data=ZSYSTEM\DATA\RC_ROM16.mbm System\data\RC_ROM16.mbm +;data=ZSYSTEM\DATA\RC_ROM24.mbm System\data\RC_ROM24.mbm +;data=ZSYSTEM\DATA\RC_RAM8.mbm System\data\RC_RAM8.mbm +;data=ZSYSTEM\DATA\RC_RAM12.mbm System\data\RC_RAM12.mbm +;data=ZSYSTEM\DATA\RC_RAM16.mbm System\data\RC_RAM16.mbm +;data=ZSYSTEM\DATA\RC_RAM24.mbm System\data\RC_RAM24.mbm +; +;data=ZSYSTEM\DATA\MONO_M1.mbm System\data\MONO_M1.mbm +;data=ZSYSTEM\DATA\MONO_M2.mbm System\data\MONO_M2.mbm +;data=ZSYSTEM\DATA\MONO_M4.mbm System\data\MONO_M4.mbm +;data=ZSYSTEM\DATA\MONO_M8.mbm System\data\MONO_M8.mbm +;data=ZSYSTEM\DATA\MONO_C4.mbm System\data\MONO_C4.mbm +;data=ZSYSTEM\DATA\MONO_C8.mbm System\data\MONO_C8.mbm +;data=ZSYSTEM\DATA\MONO_C12.mbm System\data\MONO_C12.mbm +;data=ZSYSTEM\DATA\MONO_C16.mbm System\data\MONO_C16.mbm +;data=ZSYSTEM\DATA\MONO_C24.mbm System\data\MONO_C24.mbm +;data=ZSYSTEM\DATA\MONO_C32.mbm System\data\MONO_C32.mbm +.mbm +;data=ZSYSTEM\DATA\MONO_C32.mbm System\data\MONO_C32.mbm +; +;data=ZSYSTEM\DATA\16RAM2.mbm System\data\16RAM2.mbm +;data=ZSYSTEM\DATA\16ROMC2.mbm System\data\16ROMC2.mbm +;data=ZSYSTEM\DATA\RscHeader3.bin System\data\RscHeader3.bin +;data=ZSYSTEM\DATA\DummyRscFile3.rsc System\data\DummyRscFile3.rsc +;data=ZSYSTEM\DATA\tfbs_rsc.rsc System\data\tfbs_rsc.rsc +;data=ZSYSTEM\DATA\blackandwhite.mbm System\data\blackandwhite.mbm +; +;data=ZSYSTEM\DATA\rf1.mbm System\data\rf1.mbm +;data=ZSYSTEM\DATA\rf2.mbm System\data\rf2.mbm +;data=ZSYSTEM\DATA\rf3.mbm System\data\rf3.mbm +;data=ZSYSTEM\DATA\rf123.mbm System\data\rf123.mbm +; +;data=ZSYSTEM\DATA\00_grbmap.mbm \System\Data\00_grbmap.mbm +;data=ZSYSTEM\DATA\01_totalstramsize!.mbm \System\Data\01_totalstramsize!.mbm +;data=ZSYSTEM\DATA\02_headersize.mbm \System\Data\02_headersize.mbm +;data=ZSYSTEM\DATA\03_width!.mbm \System\Data\03_width!.mbm +;data=ZSYSTEM\DATA\04_height!.mbm \System\Data\04_height!.mbm +;data=ZSYSTEM\DATA\05_bitsperpixel.mbm \System\Data\05_bitsperpixel.mbm +;data=ZSYSTEM\DATA\bad_bmpsize.mbm \System\Data\bad_bmpsize.mbm +;data=ZSYSTEM\DATA\bad_colormode.mbm \System\Data\bad_colormode.mbm +;data=ZSYSTEM\DATA\bad_compression.mbm \System\Data\bad_compression.mbm +;data=ZSYSTEM\DATA\bad_paletteentries.mbm \System\Data\bad_paletteentries.mbm +;data=EPOCROOT##epoc32\data\z\PRIVATE\10273364\RC_RAM16.mbm \private\10273364\RC_RAM16.mbm +;data=EPOCROOT##epoc32\data\z\PRIVATE\10273364\RC_ROM12.mbm \private\10273364\RC_ROM12.mbm +;data=EPOCROOT##epoc32\data\z\PRIVATE\10273364\TFBS_RSC.rsc \private\10273364\TFBS_RSC.rsc +;data=EPOCROOT##epoc32\data\z\PRIVATE\10273364\DummyRscFile3.rsc \private\10273364\DummyRscFile3.rsc +;data=EPOCROOT##epoc32\data\z\PRIVATE\10273364\RscHeader3.bin \private\10273364\RscHeader3.bin +;data=EPOCROOT##epoc32\data\z\PRIVATE\00999999\RC_RAM16.mbm \private\00999999\RC_RAM16.mbm +;data=EPOCROOT##epoc32\data\z\PRIVATE\00999999\RC_ROM12.mbm \private\00999999\RC_ROM12.mbm +; +; +;#endif diff -r bf7481649c98 -r 7f25ef56562d fbs/fontandbitmapserver/group/fbsrasterizertests_helium.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fbs/fontandbitmapserver/group/fbsrasterizertests_helium.pkg Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,39 @@ +; Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +; All rights reserved. +; This component and the accompanying materials are made available +; under the terms of "Eclipse Public License v1.0" +; which accompanies this distribution, and is available +; at the URL "http://www.eclipse.org/legal/epl-v10.html". +; +; Initial Contributors: +; Nokia Corporation - initial contribution. +; +; Contributors: +; +; Description: +; +;File: bitgdi.pkg; +; +;Auto-generated PKG file by Nokia PKG Wizard for CodeWarrior IDE + +;*Languages +&EN +; +;*Standard SIS file header. This section specifies the package name, +;application UID, and version/build numbers. Add the package TYPE here if needed. +#{"fbrasterizertests"},(0x101FB3E8),1,0,1; +; + +;*Unique (Non-Localized) Vendor name +;This is used in combination with signing to prevent the unauthroized +;upgrade of a a package by someone other than the rightful vendor. +:"Nokia" + +;*Localized Vendor Name +;This specifies the localized vendor name(s) corresponding to language(s). +%{"Nokia Test EN"} + +;*Files To Copy... + +"..\trasterizer\test\scripts\rasterizer_t_general.script"-"c:\rasterizertest\rasterizer_t_general.script" + diff -r bf7481649c98 -r 7f25ef56562d fbs/fontandbitmapserver/sfbs/FBSCLI.CPP --- a/fbs/fontandbitmapserver/sfbs/FBSCLI.CPP Fri Jun 11 14:58:47 2010 +0300 +++ b/fbs/fontandbitmapserver/sfbs/FBSCLI.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -35,7 +35,7 @@ { if (aAny && aHeapBase) { - return (TInt)aAny - (TInt)aHeapBase; + return reinterpret_cast(aAny) - aHeapBase; } return 0; } @@ -47,11 +47,11 @@ @return A pointer relative to the passed heap base. @see PointerToOffset() */ -LOCAL_C TAny* OffsetToPointer(const TInt aOffset, TInt aHeapBase) +LOCAL_C TAny* OffsetToPointer(TInt aOffset, TInt aHeapBase) { if (aOffset && aHeapBase) { - return (TAny*)(aOffset + (TInt)aHeapBase); + return reinterpret_cast(aOffset + aHeapBase); } return NULL; } diff -r bf7481649c98 -r 7f25ef56562d fbs/fontandbitmapserver/sfbs/FBSFONT.CPP --- a/fbs/fontandbitmapserver/sfbs/FBSFONT.CPP Fri Jun 11 14:58:47 2010 +0300 +++ b/fbs/fontandbitmapserver/sfbs/FBSFONT.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 1995-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -38,7 +38,7 @@ { if (aAny && aHeapBase) { - return (TInt)aAny - (TInt)aHeapBase; + return reinterpret_cast(aAny) - reinterpret_cast(aHeapBase); } return 0; } @@ -50,11 +50,11 @@ @return A pointer relative to the passed heap base. @see PointerToOffset() */ -LOCAL_C TAny* OffsetToPointer(const TInt aOffset, TUint8* aHeapBase) +LOCAL_C TAny* OffsetToPointer(TInt aOffset, TUint8* aHeapBase) { if (aOffset && aHeapBase) { - return (TAny*)(aOffset + (TInt)aHeapBase); + return reinterpret_cast(aOffset + reinterpret_cast(aHeapBase)); } return NULL; } @@ -469,10 +469,10 @@ { // Translate the offsets sent to the server back to pointers relative to // the heap base of the current process - const TOpenFontCharMetrics* temp = (const TOpenFontCharMetrics*)OffsetToPointer(paramsBuf().iMetricsOffset, iFbs->HeapBase()); - if (temp) + const TOpenFontCharMetrics* metrics = (const TOpenFontCharMetrics*)OffsetToPointer(paramsBuf().iMetricsOffset, iFbs->HeapBase()); + if (metrics) { - aMetrics = *temp; + aMetrics = *metrics; } aBitmap = static_cast(OffsetToPointer(paramsBuf().iBitmapPointerOffset, iFbs->HeapBase())); } @@ -587,7 +587,7 @@ EXPORT_C TBool CFbsFont::HasCharacter(TInt aCode) const { if (iHandle) - { + { return iFbs->SendCommand(EFbsMessHasCharacter,iHandle,aCode); } return EFalse; @@ -621,7 +621,7 @@ /** help DoExtendedFunction to perform KFontDeleteShaping function @param aParam Input parameter block -@return KErrNone if successful, KErrBadHandle if the font does not have a valid handle. +@return KErrNone if successful, KErrGeneral if the font does not have a valid handle. */ TInt CFbsFont::DoFontDeleteShaping(TFontShapeDeleteFunctionParameters* aParam) const { @@ -775,3 +775,4 @@ } return CFont::DoExtendedFunction(aFunctionId, aParam); } + diff -r bf7481649c98 -r 7f25ef56562d fbs/fontandbitmapserver/tfbs/TFBS.CPP --- a/fbs/fontandbitmapserver/tfbs/TFBS.CPP Fri Jun 11 14:58:47 2010 +0300 +++ b/fbs/fontandbitmapserver/tfbs/TFBS.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 1995-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -84,7 +84,7 @@ void CTFbs::ConstructL() { ExpandCleanupStackL(); - + User::LeaveIfError(Logger().ShareAuto()); TestConstruction(); AllocScanLineBuf(); @@ -2145,6 +2145,8 @@ are the same, thereby avoiding any unneccessary IPC calls. @SYMTestActions + Try to open a global semaphore called "FBSSessionCacheSemaphore" (this is a temporary measure to + ensure successful propagation of ou1cimx1#250526). Create a large font which consumes a lot of memory. Create a CFbsBitGc and a CFbsBitmap target. Use the CFbsBitGc to render some text, thereby filling the font glyph cache. @@ -2156,6 +2158,7 @@ returned from CBitmapFont::GetCharacterData(). @SYMTestExpectedResults + No global semaphore called "FBSSessionCacheSemaphore" should exist. When using KNullHandle, CharacterNeedsToBeRasterized() with the first character, is expected to pass proving that the font cache is working as expected when glyphs can fit into it. When using KNullHandle, CharacterNeedsToBeRasterized() with the last character, it expected to fail, @@ -2172,6 +2175,11 @@ { INFO_PRINTF1(_L("Test Font Session-cache Lookup")); + // Make sure the global semaphore is gone for good + _LIT(KSessionCacheSemaphoreName, "FBSSessionCacheSemaphore"); + RSemaphore sem; + TEST(sem.OpenGlobal(KSessionCacheSemaphoreName) == KErrNotFound); + User::LeaveIfError(RFbsSession::Connect()); RFbsSession* fbsSession = RFbsSession::GetSession(); CFbsTypefaceStore* ts = CFbsTypefaceStore::NewL(NULL); @@ -2273,170 +2281,96 @@ TEST(KErrNone == iFbs->SendCommand(EFbsMessSetTwipsHeight, fontHandle, 49)); // In a second thread, send a IPC command to set the font's height with the // bitmap's handle. Should panic with FBServ -6. - TFbsTestThreadInfo threadInfo = {EFbsSecondThreadInvalidHandleInIpcCall}; - TExitCategoryName exitCategoryName(KFbsPanicCategory); _LIT(KTestName, "TestInvalidHandlesInIpcCall"); - CreateSecondThreadAndCheckPanicL(threadInfo, -6, exitCategoryName, KTestName); + CreateSecondThreadAndCheckPanicL(SecondThreadPanicInvalidHandleInIpcCallL, KErrArgument, KFbsPanicCategory, KTestName); iTs->ReleaseFont(font); delete bmp; } /** -Creates a second thread and do some panic tests in it. -@param aTestInfo The information for the tests -@param aPanicCode The expected panic code -@param aExitCategory The expected panic category -@param aThreadName The name of the new thread -@leave Gets system wide error code +Second thread function for test GRAPHICS-FBSERV-0650. It should panic with FBSERV -6 if the test is successful. + */ +void CTFbs::SecondThreadPanicInvalidHandleInIpcCallL() + { + User::LeaveIfError(RFbsSession::Connect()); + RFbsSession* fbs = RFbsSession::GetSession(); + CFbsBitmapEx* bmp = new(ELeave) CFbsBitmapEx(); + CleanupStack::PushL(bmp); + User::LeaveIfError(bmp->Create(TSize(1,1), EGray2)); + CFbsTypefaceStore* ts = CFbsTypefaceStore::NewL(NULL); + CleanupStack::PushL(ts); + CFbsFont* font=NULL; + User::LeaveIfError(ts->GetNearestFontToDesignHeightInPixels((CFont*&)font, TFontSpec(KTypefaceName, 15))); + TInt bitmapHandle = bmp->BitmapHandle(); + + // Send a IPC command to set twips height of font with a bitmap handle + (void)fbs->SendCommand(EFbsMessSetTwipsHeight, bitmapHandle, 49); + + ts->ReleaseFont(font); + CleanupStack::PopAndDestroy(2); + RFbsSession::Disconnect(); + } + + +struct TFbsTestDelegator + { + CTFbs* iTestBase; + void (CTFbs::*iMethodPtr)(); + }; + +/** +Creates a second thread and checks that it panics. +@param aMethodL The leaving method of CTFbs that the second thread is going to execute. +@param aPanicCode The expected panic code. +@param aPanicCategory The expected panic category. +@param aThreadName The name of the new thread. */ -void CTFbs::CreateSecondThreadAndCheckPanicL(TFbsTestThreadInfo& aTestInfo, TInt aPanicCode, TExitCategoryName aExitCategory, const TDesC &aThreadName) +void CTFbs::CreateSecondThreadAndCheckPanicL(void (CTFbs::*aMethodL)(), TInt aPanicCode, const TDesC& aPanicCategory, const TDesC& aThreadName) { RThread secondThread; - User::LeaveIfError(secondThread.Create(aThreadName, SecondThreadStart, KDefaultStackSize, 0x1000, 0x1000, &aTestInfo)); + TFbsTestDelegator delegator; + delegator.iTestBase = this; + delegator.iMethodPtr = aMethodL; + User::LeaveIfError(secondThread.Create(aThreadName, MethodDelegatorThreadFunction, KDefaultStackSize, 0x1000, 0x1000, &delegator)); // Launch second thread TRequestStatus statusSecondThread; secondThread.Logon(statusSecondThread); - secondThread.SetPriority(EPriorityLess); - secondThread.Resume(); - + secondThread.Resume(); + // Wait until second thread is finished User::WaitForRequest(statusSecondThread); - - if(EExitPanic != secondThread.ExitType()) + // Check results + if (EExitPanic != secondThread.ExitType()) { - ERR_PRINTF3(_L("Expected exit type: %d, Actual exit type: %d"), EExitPanic, secondThread.ExitType()); + ERR_PRINTF2(_L("Expected exit type: EExitPanic, actual exit type: %d"), secondThread.ExitType()); TEST(EFalse); } - - if(aPanicCode != secondThread.ExitReason()) + if (aPanicCode != secondThread.ExitReason()) { - ERR_PRINTF3(_L("Expected panic code: %d, Actual panic code: %d"), aPanicCode, secondThread.ExitReason()); + ERR_PRINTF3(_L("Expected exit reason: %d, actual exit reason: %d"), aPanicCode, secondThread.ExitReason()); TEST(EFalse); } - TExitCategoryName secondThreadExitCategory = secondThread.ExitCategory(); - if(aExitCategory != secondThreadExitCategory) + if (aPanicCategory != secondThreadExitCategory) { - ERR_PRINTF3(_L("Expected panic category: %S, Actual panic category: %S"), &aExitCategory, &secondThreadExitCategory); + ERR_PRINTF3(_L("Expected exit category: %S, actual exit category: %S"), &aPanicCategory, &secondThreadExitCategory); TEST(EFalse); } - - //Close the handle + // Dispose of the remains of the second thread secondThread.Close(); } -/** -Second thread entry function. -*/ -TInt CTFbs::SecondThreadStart(TAny* aTestInfo) +TInt CTFbs::MethodDelegatorThreadFunction(TAny* aDelegator) { - - __UHEAP_MARK; - TInt procHandles1 =0; - TInt threadHandles1=0; - RThread().HandleCount(procHandles1, threadHandles1); CTrapCleanup* cleanupStack = CTrapCleanup::New(); - if (!cleanupStack) { - __UHEAP_MARKEND; return KErrNoMemory; } - - TInt result = KErrNone; - TRAP(result, SecondThreadMainL(static_cast(aTestInfo))); - + TFbsTestDelegator* delegator = static_cast(aDelegator); + TRAPD(err, (delegator->iTestBase->*delegator->iMethodPtr)()); delete cleanupStack; - - TInt procHandles2 =0; - TInt threadHandles2=0; - RThread().HandleCount(procHandles2,threadHandles2); - if (threadHandles1 != threadHandles2) - { - result = KErrGeneral; // Thread-owned handles not closed - } - __UHEAP_MARKEND; - - return result; - } - -/** -Run the test contained within the TFbsTestThreadInfo object. A new thread is -created for each test and only one of the cases in the switch statements -below will be used. - -@param aTestInfo The parameters for the test -@return One of the system wide error codes or an enumeration of passed tests. - */ -TInt CTFbs::SecondThreadMainL(TFbsTestThreadInfo* aTestInfo) - { - TInt result = 0; - TFbsMultiThreadTestCase testcase = aTestInfo->iTestCase; - - //test cases without the need of an initialised driver - switch (testcase) - { - case EFbsSecondThreadInvalidHandleInIpcCall: - result = SecondThreadPanicInvalidHandleInIpcCall(); - break; - } - return result; - } - -/** -Implementation of SecondThread test EFbsSecondThreadInvalidHandleInIpcCall - -@panic FBSERV -6 If the test is successful - -@return One of the system wide error codes. - */ -TInt CTFbs::SecondThreadPanicInvalidHandleInIpcCall() - { - TInt result = RFbsSession::Connect(); - if (KErrNone != result) - { - return result; - } - RFbsSession* fbs = RFbsSession::GetSession(); - CFbsBitmapEx* bmp = new CFbsBitmapEx(); - if (!bmp) - { - return KErrGeneral; - } - result = bmp->Create(TSize(1,1),EGray2); - if(KErrNone != result) - { - delete bmp; - return KErrGeneral; - } - - CFbsTypefaceStore* ts = NULL; - ts = (CFbsTypefaceStore*)CFbsTypefaceStore::NewL(NULL); - if (!ts) - { - delete bmp; - return KErrGeneral; - } - - CFbsFontEx* font=NULL; - result = ts->GetNearestFontToDesignHeightInPixels((CFont*&)font, TFontSpec(KTypefaceName, 15)); - if (!font) - { - delete bmp; - delete ts; - return KErrGeneral; - } - - TInt fontHandle = font->FontHandle(); - TInt bitmapHandle = bmp->BitmapHandle(); - - // Send a IPC command to set twips height of font with a bitmap handle - result = fbs->SendCommand(EFbsMessSetTwipsHeight, bitmapHandle, 49); - - ts->ReleaseFont(font); - delete bmp; - delete ts; - return result; + return err; } /** diff -r bf7481649c98 -r 7f25ef56562d fbs/fontandbitmapserver/tfbs/TFBS.H --- a/fbs/fontandbitmapserver/tfbs/TFBS.H Fri Jun 11 14:58:47 2010 +0300 +++ b/fbs/fontandbitmapserver/tfbs/TFBS.H Wed Jun 23 19:41:15 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 1995-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -20,7 +20,6 @@ #include #include #include -#include "tfbsmultithread.h" _LIT(KTempFilename,"c:\\temp.mbm"); _LIT(KTestBitmapOnZ,"z:\\system\\data\\tfbs.mbm"); @@ -138,10 +137,9 @@ TInt LoadOpenFontLibraries(); TBool CheckTypefacesSupport(const TTypefaceSupport& aInfo1, const TTypefaceSupport& aInfo2); void LoadFontsL(const TDesC& aFontsDir); - void CreateSecondThreadAndCheckPanicL(TFbsTestThreadInfo& aTestCase, TInt aPanicCode, TExitCategoryName aExitCategory, const TDesC &aThreadName); - static TInt SecondThreadStart(TAny* aTestInfo); - static TInt SecondThreadMainL(TFbsTestThreadInfo* aTestInfo); - static TInt SecondThreadPanicInvalidHandleInIpcCall(); + void SecondThreadPanicInvalidHandleInIpcCallL(); + void CreateSecondThreadAndCheckPanicL(void (CTFbs::*aMethodL)(), TInt aPanicCode, const TDesC& aPanicCategory, const TDesC &aThreadName); + static TInt MethodDelegatorThreadFunction(TAny* aDelegator); private: TInt iHandle; diff -r bf7481649c98 -r 7f25ef56562d fbs/fontandbitmapserver/tfbs/tfbsmultithread.h --- a/fbs/fontandbitmapserver/tfbs/tfbsmultithread.h Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,36 +0,0 @@ -// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -#ifndef TFBSMULTITHREAD_H -#define TFBSMULTITHREAD_H - -/** -* Enums for passing between the test thread and the second thead used in testing, -* used to define which test should be run on the second thread. -*/ -enum TFbsMultiThreadTestCase - { - EFbsSecondThreadInvalidHandleInIpcCall, - }; - -/** - * Class for passing test info to other threads. - */ -struct TFbsTestThreadInfo - { - TFbsMultiThreadTestCase iTestCase; - }; - -#endif // TFBSMULTITHREAD_H diff -r bf7481649c98 -r 7f25ef56562d graphicsapitest/graphicssvs/bitgdi/group/t_bitgdiapi_testdata.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graphicsapitest/graphicssvs/bitgdi/group/t_bitgdiapi_testdata.pkg Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,47 @@ +; Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +; All rights reserved. +; This component and the accompanying materials are made available +; under the terms of "Eclipse Public License v1.0" +; which accompanies this distribution, and is available +; at the URL "http://www.eclipse.org/legal/epl-v10.html". +; +; Initial Contributors: +; Nokia Corporation - initial contribution. +; +; Contributors: +; +; Description: +; +;File: bitgdi.pkg; +; +;Auto-generated PKG file by Nokia PKG Wizard for CodeWarrior IDE + +;*Languages +&EN +; +;*Standard SIS file header. This section specifies the package name, +;application UID, and version/build numbers. Add the package TYPE here if needed. +#{"TBitGDIAPITest"},(0x101FB3E8),1,0,1; +; + +;*Unique (Non-Localized) Vendor name +;This is used in combination with signing to prevent the unauthroized +;upgrade of a a package by someone other than the rightful vendor. +:"Nokia" + +;*Localized Vendor Name +;This specifies the localized vendor name(s) corresponding to language(s). +%{"Nokia Test EN"} + +;*Files To Copy... + +"..\Epoc32\data\z\graphics\setup-t-graphics-bitgdi-publicapi.script"-"graphics\setup-t-graphics-bitgdi-publicapi.script" +"..\Epoc32\data\z\graphics\graphics-bitgdi-fbsdevice-publicapi.script"-"graphics\graphics-bitgdi-fbsdevice-publicapi.script" +"..\Epoc32\data\z\graphics\graphics-bitgdi-fbsscreendevice-publicapi.script"-"graphics\graphics-bitgdi-fbsscreendevice-publicapi.script" +"..\Epoc32\data\z\graphics\graphics-bitgdi-fbsbitmapdevice-publicapi.script"-"graphics\graphics-bitgdi-fbsbitmapdevice-publicapi.script" +"..\Epoc32\data\z\graphics\graphics-bitgdi-fbsbitgc-publicapi.script"-"graphics\graphics-bitgdi-fbsbitgc-publicapi.script" +"..\Epoc32\data\z\graphics\graphics-bitgdi-fbsbitgc-publicapi-manual.script"-"graphics\graphics-bitgdi-fbsbitgc-publicapi-manual.script" +"..\Epoc32\data\z\graphics\GRAPHICS-BITGDI-PolygonFiller-PublicApi.script"-"graphics\GRAPHICS-BITGDI-PolygonFiller-PublicApi.script" +"..\Epoc32\data\z\graphics\GRAPHICS-BITGDI-FbsBitGcBitmap-PublicApi.script"-"graphics\GRAPHICS-BITGDI-FbsBitGcBitmap-PublicApi.script" +"..\Epoc32\data\z\graphics\GRAPHICS-BITGDI-FbsBitGcFont-PublicApi.script"-"graphics\GRAPHICS-BITGDI-FbsBitGcFont-PublicApi.script" + diff -r bf7481649c98 -r 7f25ef56562d graphicsapitest/screendriverhaitest/screendriver/group/t_screendriver_testdata_helium.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graphicsapitest/screendriverhaitest/screendriver/group/t_screendriver_testdata_helium.pkg Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,39 @@ +; Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +; All rights reserved. +; This component and the accompanying materials are made available +; under the terms of "Eclipse Public License v1.0" +; which accompanies this distribution, and is available +; at the URL "http://www.eclipse.org/legal/epl-v10.html". +; +; Initial Contributors: +; Nokia Corporation - initial contribution. +; +; Contributors: +; +; Description: +; +;File: bitgdi.pkg; +; +;Auto-generated PKG file by Nokia PKG Wizard for CodeWarrior IDE + +;*Languages +&EN +; +;*Standard SIS file header. This section specifies the package name, +;application UID, and version/build numbers. Add the package TYPE here if needed. +#{"T_ScreenDriver_TestData"},(0x101FB3E8),1,0,1; +; + +;*Unique (Non-Localized) Vendor name +;This is used in combination with signing to prevent the unauthroized +;upgrade of a a package by someone other than the rightful vendor. +:"Nokia" + +;*Localized Vendor Name +;This specifies the localized vendor name(s) corresponding to language(s). +%{"Nokia Test EN"} + +;*Files To Copy... + +"Epoc32\data\z\graphics\graphics-screendriver-cfbsdrawdevice-automated.script"-"c:\graphics\graphics-screendriver-cfbsdrawdevice-automated.script" + diff -r bf7481649c98 -r 7f25ef56562d graphicscomposition/openwfcinterface/bwins/libWFCu.def --- a/graphicscomposition/openwfcinterface/bwins/libWFCu.def Fri Jun 11 14:58:47 2010 +0300 +++ b/graphicscomposition/openwfcinterface/bwins/libWFCu.def Wed Jun 23 19:41:15 2010 +0300 @@ -26,7 +26,7 @@ wfcGetElementAttribiv @ 25 NONAME wfcGetElementBelow @ 26 NONAME wfcGetError @ 27 NONAME - wfcGetOnScreenStream @ 28 NONAME + extwfcGetOnScreenStream @ 28 NONAME wfcGetStrings @ 29 NONAME wfcInsertElement @ 30 NONAME wfcIsExtensionSupported @ 31 NONAME diff -r bf7481649c98 -r 7f25ef56562d graphicscomposition/openwfcinterface/eabi/libWFCu.def --- a/graphicscomposition/openwfcinterface/eabi/libWFCu.def Fri Jun 11 14:58:47 2010 +0300 +++ b/graphicscomposition/openwfcinterface/eabi/libWFCu.def Wed Jun 23 19:41:15 2010 +0300 @@ -26,7 +26,7 @@ wfcGetElementAttribiv @ 25 NONAME wfcGetElementBelow @ 26 NONAME wfcGetError @ 27 NONAME - wfcGetOnScreenStream @ 28 NONAME + extwfcGetOnScreenStream @ 28 NONAME wfcGetStrings @ 29 NONAME wfcInsertElement @ 30 NONAME wfcIsExtensionSupported @ 31 NONAME diff -r bf7481649c98 -r 7f25ef56562d graphicscomposition/openwfcinterface/include/wfcplatform.h --- a/graphicscomposition/openwfcinterface/include/wfcplatform.h Fri Jun 11 14:58:47 2010 +0300 +++ b/graphicscomposition/openwfcinterface/include/wfcplatform.h Wed Jun 23 19:41:15 2010 +0300 @@ -1,8 +1,8 @@ -/********************************************************************* +/******************************************************************** * * * Sample implementation of wfcplatform.h, version 1.0, draft 18 * * * - * Copyright � 2007-2009 The Khronos Group * + * Copyright (c) 2007-2009 The Khronos Group * * * *********************************************************************/ @@ -30,6 +30,9 @@ #define WFC_DEFAULT_SCREEN_NUMBER (0) #endif +/* for backward compatibility of wfcGetOnScreenStream symbol use */ +#define wfcGetOnScreenStream extwfcGetOnScreenStream + typedef khronos_int32_t WFCint; typedef khronos_float_t WFCfloat; typedef khronos_uint32_t WFCbitfield; diff -r bf7481649c98 -r 7f25ef56562d graphicscomposition/openwfcompositionengine/composition/src/wfcapi.c --- a/graphicscomposition/openwfcompositionengine/composition/src/wfcapi.c Fri Jun 11 14:58:47 2010 +0300 +++ b/graphicscomposition/openwfcompositionengine/composition/src/wfcapi.c Wed Jun 23 19:41:15 2010 +0300 @@ -1,4 +1,4 @@ -/* Copyright (c) 2009 The Khronos Group Inc. +/* Copyright (c) 2009-2010 The Khronos Group Inc. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and/or associated documentation files (the @@ -1001,7 +1001,7 @@ /*=========================================================================*/ WFC_API_CALL WFCNativeStreamType WFC_APIENTRY -wfcGetOnScreenStream(WFCDevice dev, WFCContext ctx) WFC_APIEXIT +extwfcGetOnScreenStream(WFCDevice dev, WFCContext ctx) WFC_APIEXIT { WFC_DEVICE* device; WFC_CONTEXT* context; diff -r bf7481649c98 -r 7f25ef56562d graphicscomposition/openwfcompositionengine/group/bld.inf --- a/graphicscomposition/openwfcompositionengine/group/bld.inf Fri Jun 11 14:58:47 2010 +0300 +++ b/graphicscomposition/openwfcompositionengine/group/bld.inf Wed Jun 23 19:41:15 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -24,9 +24,6 @@ PRJ_MMPFILES openwfc.mmp -PRJ_TESTMMPFILES -owfsharect.mmp - PRJ_TESTEXPORTS ../adaptation/include/owfnativestream.h SYMBIAN_OS_LAYER_PLATFORM_EXPORT_PATH(owfnativestream.h) ../adaptation/include/owfmutex.h SYMBIAN_OS_LAYER_PLATFORM_EXPORT_PATH(owfmutex.h) diff -r bf7481649c98 -r 7f25ef56562d graphicscomposition/openwfcompositionengine/group/owfsharect.mmp --- a/graphicscomposition/openwfcompositionengine/group/owfsharect.mmp Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Static library providing the additional functionality needed for the ct tests. - -target owfsharect.lib -targettype lib -NOEXPORTLIBRARY - -OS_LAYER_SYSTEMINCLUDE_SYMBIAN -OS_LAYER_LIBC_SYSTEMINCLUDE - -USERINCLUDE ..\common\include -USERINCLUDE ..\adaptation\include - -SOURCEPATH ..\common\src -SOURCE owfmemory.c -SOURCE owfdebug.c - -SOURCEPATH ..\adaptation\src\Platform\OS\symbian -SOURCE owfmutex.c -SOURCE owfthread.c -SOURCE owfconsole.cpp - - diff -r bf7481649c98 -r 7f25ef56562d graphicscomposition/openwfsupport/test/group/wfcinterop_tests_helium.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graphicscomposition/openwfsupport/test/group/wfcinterop_tests_helium.pkg Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,40 @@ +; Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +; All rights reserved. +; This component and the accompanying materials are made available +; under the terms of "Eclipse Public License v1.0" +; which accompanies this distribution, and is availableemma.thorogood@uk.pwc.com +; at the URL "http://www.eclipse.org/legal/epl-v10.html". +; +; Initial Contributors: +; Nokia Corporation - initial contribution. +; +; Contributors: +; +; Description: +; +;File: bitgdi.pkg; + +;*Languages +&EN +; +;*Standard SIS file header. This section specifies the package name, +;application UID, and version/build numbers. Add the package TYPE here if needed. +#{"WFCInterop_Tests"},(0x101FB3E8),1,0,1; +; + +;*Unique (Non-Localized) Vendor name +;This is used in combination with signing to prevent the unauthroized +;upgrade of a a package by someone other than the rightful vendor. +:"Nokia" + +;*Localized Vendor Name +;This specifies the localized vendor name(s) corresponding to language(s). +%{"Nokia Test EN"} + +;*Files To Copy... + +;REM OpenWFC adaptation Test Scripts [no plugins] +;//Please execute only the tests appropriate to your hardware capabilities. + +"..\scripts\wfctest\tstreamoperation.script"-"c:\wfctest\tstreamoperation.script" + diff -r bf7481649c98 -r 7f25ef56562d graphicscomposition/surfaceupdate/group/BLD.INF --- a/graphicscomposition/surfaceupdate/group/BLD.INF Fri Jun 11 14:58:47 2010 +0300 +++ b/graphicscomposition/surfaceupdate/group/BLD.INF Wed Jun 23 19:41:15 2010 +0300 @@ -48,8 +48,8 @@ PRJ_TESTMMPFILES -../group/tcompositionbackend.mmp //to emulate composition behaviour +../group/tcompositionbackend.mmp support //to emulate composition behaviour ../group/tsurfaceupdatetestserver.mmp -../group/tsurfaceupdateserver.mmp -../group/tsurfaceupdateclient.mmp +../group/tsurfaceupdateserver.mmp support +../group/tsurfaceupdateclient.mmp support ../group/tsurfaceupdateserverinteg.mmp diff -r bf7481649c98 -r 7f25ef56562d graphicscomposition/surfaceupdate/group/surfaceupdateserver.mmh --- a/graphicscomposition/surfaceupdate/group/surfaceupdateserver.mmh Fri Jun 11 14:58:47 2010 +0300 +++ b/graphicscomposition/surfaceupdate/group/surfaceupdateserver.mmh Wed Jun 23 19:41:15 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" diff -r bf7481649c98 -r 7f25ef56562d graphicscomposition/surfaceupdate/group/surfaceupdateserver.mmp --- a/graphicscomposition/surfaceupdate/group/surfaceupdateserver.mmp Fri Jun 11 14:58:47 2010 +0300 +++ b/graphicscomposition/surfaceupdate/group/surfaceupdateserver.mmp Wed Jun 23 19:41:15 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" diff -r bf7481649c98 -r 7f25ef56562d graphicscomposition/surfaceupdate/group/surfaceupdatetest_helium.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graphicscomposition/surfaceupdate/group/surfaceupdatetest_helium.pkg Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,37 @@ +; Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +; All rights reserved. +; This component and the accompanying materials are made available +; under the terms of "Eclipse Public License v1.0" +; which accompanies this distribution, and is available +; at the URL "http://www.eclipse.org/legal/epl-v10.html". +; +; Initial Contributors: +; Nokia Corporation - initial contribution. +; +; Contributors: +; +; Description: +; +;File: bitgdi.pkg; +; +;*Languages +&EN +; +;*Standard SIS file header. This section specifies the package name, +;application UID, and version/build numbers. Add the package TYPE here if needed. +#{"SurfaceUpdateTest"},(0x101FB3E8),1,0,1; +; + +;*Unique (Non-Localized) Vendor name +;This is used in combination with signing to prevent the unauthroized +;upgrade of a a package by someone other than the rightful vendor. +:"Nokia" + +;*Localized Vendor Name +;This specifies the localized vendor name(s) corresponding to language(s). +%{"Nokia Test EN"} + +;*Files To Copy... + +"..\tsrc\surfaceupdate.script"-"c:\surfaceupdate\surfaceupdate.script" + diff -r bf7481649c98 -r 7f25ef56562d graphicscomposition/surfaceupdate/group/surfaceupdatetest_integ_helium.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graphicscomposition/surfaceupdate/group/surfaceupdatetest_integ_helium.pkg Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,39 @@ +; Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +; All rights reserved. +; This component and the accompanying materials are made available +; under the terms of "Eclipse Public License v1.0" +; which accompanies this distribution, and is available +; at the URL "http://www.eclipse.org/legal/epl-v10.html". +; +; Initial Contributors: +; Nokia Corporation - initial contribution. +; +; Contributors: +; +; Description: +; +;File: bitgdi.pkg; +; +;Auto-generated PKG file by Nokia PKG Wizard for CodeWarrior IDE + +;*Languages +&EN +; +;*Standard SIS file header. This section specifies the package name, +;application UID, and version/build numbers. Add the package TYPE here if needed. +#{"SurfaceUpdateTest_Integ"},(0x101FB3E8),1,0,1; +; + +;*Unique (Non-Localized) Vendor name +;This is used in combination with signing to prevent the unauthroized +;upgrade of a a package by someone other than the rightful vendor. +:"Nokia" + +;*Localized Vendor Name +;This specifies the localized vendor name(s) corresponding to language(s). +%{"Nokia Test EN"} + +;*Files To Copy... + +"..\tsrc\surfaceupdateinteg.script"-"c:\surfaceupdate\surfaceupdateinteg.script" + diff -r bf7481649c98 -r 7f25ef56562d graphicscomposition/surfaceupdate/inc/surfaceupdate.h --- a/graphicscomposition/surfaceupdate/inc/surfaceupdate.h Fri Jun 11 14:58:47 2010 +0300 +++ b/graphicscomposition/surfaceupdate/inc/surfaceupdate.h Wed Jun 23 19:41:15 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -22,7 +22,7 @@ const TUint KSurfaceUpdateServMajorVersionNumber = 1; const TUint KSurfaceUpdateServMinorVersionNumber = 1; -const TUint KSurfaceUpdateServBuildVersionNumber = 2; +const TUint KSurfaceUpdateServBuildVersionNumber = 3; enum TSurfaceUpdateServRqst diff -r bf7481649c98 -r 7f25ef56562d graphicscomposition/surfaceupdate/inc/surfaceupdateserver.h --- a/graphicscomposition/surfaceupdate/inc/surfaceupdateserver.h Fri Jun 11 14:58:47 2010 +0300 +++ b/graphicscomposition/surfaceupdate/inc/surfaceupdateserver.h Wed Jun 23 19:41:15 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -33,6 +33,7 @@ EUpdateServPanicStartUp, EUpdateServPanicDataIntegrity, EUpdateServPanicRegister, + EUpdateServPanicGlobalFastLock, }; enum TSurfaceUpdateEvent diff -r bf7481649c98 -r 7f25ef56562d graphicscomposition/surfaceupdate/src/surfaceupdateserver.cpp --- a/graphicscomposition/surfaceupdate/src/surfaceupdateserver.cpp Fri Jun 11 14:58:47 2010 +0300 +++ b/graphicscomposition/surfaceupdate/src/surfaceupdateserver.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -23,7 +23,6 @@ #ifdef TEST_SURFACE_UPDATE #include "surfaceupdatetest.h" #endif -#include const TUint KDefaultHeapSize=0x10000; @@ -886,9 +885,18 @@ } #endif + +/** +Set number of UpdateReceivers - called when update receivers are added/removed. + +@param aNumUpdateReceivers - new number of update receivers for the batch. + */ void CUpdateReceiverNotificationBatch::SetNumUpdateReceivers(TInt aNumUpdateReceivers) { - __ASSERT_DEBUG(iType == EUpdateSrvReusable, CSurfaceUpdateServer::PanicServer(EUpdateServPanicDataIntegrity)); + __ASSERT_DEBUG(aNumUpdateReceivers >= 0 && aNumUpdateReceivers < 1000 /* arbitrary "large" limit */, + CSurfaceUpdateServer::PanicServer(EUpdateServPanicDataIntegrity)); + __ASSERT_DEBUG(iType == EUpdateSrvReusable, + CSurfaceUpdateServer::PanicServer(EUpdateServPanicDataIntegrity)); iNumUpdateReceivers = aNumUpdateReceivers; } /** @@ -964,7 +972,8 @@ if(thread.Open(iThreadId) == KErrNone) { TInt err = gProviderFastLock.CreateLocal(); - //ignore error on double create. + __ASSERT_ALWAYS(err == KErrNone || err == KErrAlreadyExists, CSurfaceUpdateServer::PanicServer(EUpdateServPanicGlobalFastLock)); + gProviderFastLock.Wait(); gProvider = NULL; if (iServer) @@ -1026,22 +1035,11 @@ thus mustn't delete it. The pointer will be valid until server is operating, i.e. system is up. -@panic KErrAccessDenied If is called from process other than WSERV. @return KErrNone if an operation is successful, any other system error codes otherwise */ EXPORT_C TInt StartSurfaceUpdateServer(MSurfaceUpdateServerProvider*& aSurfaceUpdateServerProvider) { #ifndef TEST_SURFACE_UPDATE - RProcess process; - TUidType uidType = process.Type(); - const TInt32 KWservUid = 268450592; - const TUid& uid1 = uidType[2]; - - if(uid1.iUid != KWservUid) //only wserv process can start the server - {// some malicious client tries to launch the server - process.Panic(_L("Access denied"), KErrAccessDenied); - return KErrAccessDenied; - } TPtrC serverName(KSurfaceUpdateServerName); #else TPtrC serverName(KTestSurfaceUpdateServerName); diff -r bf7481649c98 -r 7f25ef56562d graphicscomposition/surfaceupdate/tsrc/tsurfaceupdate.cpp --- a/graphicscomposition/surfaceupdate/tsrc/tsurfaceupdate.cpp Fri Jun 11 14:58:47 2010 +0300 +++ b/graphicscomposition/surfaceupdate/tsrc/tsurfaceupdate.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -1758,13 +1758,70 @@ session.Close(); } + +/** + @SYMTestCaseID GRAPHICS-SURFACEUPDATE-0019 + + + @SYMPREQ 1007 + + @SYMREQ 8223 + + @SYMTestCaseDesc Starting the surface update server in two different threads. + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions Start the surface update server in two different threads. + + @SYMTestExpectedResults Thread 1: KErrNone + Thread 2: KErrNone + The "provider" returned to both threads should also be the same value! +*/ +void CTSurfaceUpdate::TestCase12L() + { + MSurfaceUpdateServerProvider *surfaceUpdateProvider = NULL; + TInt res = StartSurfaceUpdateServer(surfaceUpdateProvider); + TEST(res == KErrNone); + User::LeaveIfError(res); + + _LIT(KThreadName, "TestServerStartupTwoThreads"); + TTime tm; + TBuf<32> buf; + tm.UniversalTime(); + TRAP(res, tm.FormatL(buf, _L("_%H%T%S%C"))); + TEST(res == KErrNone); + User::LeaveIfError(res); + TBuf<128> threadName(KThreadName); + threadName.Append(buf); //guarantee uniqueness of the thread name + RThread thread; + MSurfaceUpdateServerProvider *surfaceUpdateProvider2 = NULL; + res = thread.Create(threadName, + TestServerStartupTwoThreads, + KDefaultStackSize, + &User::Heap(), + &surfaceUpdateProvider2); + TEST(res == KErrNone); + User::LeaveIfError(res); + TRequestStatus rendezvousStatus; + thread.Rendezvous(rendezvousStatus); + thread.Resume(); + User::WaitForRequest(rendezvousStatus); + TEST(KErrNone == rendezvousStatus.Int()); + // Check that we get the same provider for both threads! + TEST(surfaceUpdateProvider2 == surfaceUpdateProvider); + } + + /** Starting the update server in another thread - called from TestCase12 */ -TInt CTSurfaceUpdate::TestServerStartupTwoThreads(TAny*) +TInt CTSurfaceUpdate::TestServerStartupTwoThreads(TAny *aArgPtr) { - MSurfaceUpdateServerProvider *surfaceUpdateProvider = NULL; - TInt res = StartSurfaceUpdateServer(surfaceUpdateProvider); + MSurfaceUpdateServerProvider **surfaceUpdateProviderPtr = + reinterpret_cast(aArgPtr); + TInt res = StartSurfaceUpdateServer(*surfaceUpdateProviderPtr); return res; } @@ -2200,7 +2257,15 @@ TEST(ret == KErrNone); break; } - case 12: + case 12: + { + ((CTSurfaceUpdateStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEUPDATE-0019")); + INFO_PRINTF1(_L("TestCase12L")); + TRAPD(ret, TestCase12L()); + TEST(ret == KErrNone); + break; + } + case 13: { ((CTSurfaceUpdateStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEUPDATE-0020")); INFO_PRINTF1(_L("TestCase13L")); @@ -2208,14 +2273,14 @@ TEST(ret == KErrNone); break; } - case 13: + case 14: { ((CTSurfaceUpdateStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEUPDATE-0022")); INFO_PRINTF1(_L("TestCase14")); TestCase14(); break; } - case 14: + case 15: { ((CTSurfaceUpdateStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEUPDATE-0023")); INFO_PRINTF1(_L("TestCase15")); @@ -2223,7 +2288,7 @@ TEST(ret == KErrNone); break; } - case 15: + case 16: { ((CTSurfaceUpdateStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEUPDATE-0024")); INFO_PRINTF1(_L("TestCase16")); @@ -2231,7 +2296,7 @@ TEST(ret == KErrNone); break; } - case 16: + case 17: { ((CTSurfaceUpdateStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEUPDATE-0028")); INFO_PRINTF1(_L("TestCase17")); @@ -2239,7 +2304,7 @@ TEST(ret == KErrNone); break; } - case 17: + case 18: { ((CTSurfaceUpdateStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEUPDATE-0025")); INFO_PRINTF1(_L("TestCase18")); @@ -2247,7 +2312,7 @@ TEST(ret == KErrNone); break; } - case 18: + case 19: { ((CTSurfaceUpdateStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEUPDATE-0027")); INFO_PRINTF1(_L("TestCaseNotifyWhenAvailableGlobal")); @@ -2255,7 +2320,7 @@ TEST(ret == KErrNone); break; } - case 19: + case 20: { ((CTSurfaceUpdateStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEUPDATE-0029")); INFO_PRINTF1(_L("TestCaseRegisterIdenticalPrioritiesL")); @@ -2263,7 +2328,7 @@ TEST(ret == KErrNone); break; } - case 20: + case 21: {//should be the last test case ((CTSurfaceUpdateStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEUPDATE-0021")); INFO_PRINTF1(_L("TestCaseTerminateServer")); diff -r bf7481649c98 -r 7f25ef56562d graphicscomposition/surfaceupdate/tsrc/tsurfaceupdate.h --- a/graphicscomposition/surfaceupdate/tsrc/tsurfaceupdate.h Fri Jun 11 14:58:47 2010 +0300 +++ b/graphicscomposition/surfaceupdate/tsrc/tsurfaceupdate.h Wed Jun 23 19:41:15 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -52,6 +52,7 @@ void TestCase9L(); void TestCase10(); void TestCase11(); + void TestCase12L(); void TestCase13L(); void TestCase14(); void TestCase15(); diff -r bf7481649c98 -r 7f25ef56562d graphicsdeviceinterface/bitgdi/group/BitgdiTest.iby --- a/graphicsdeviceinterface/bitgdi/group/BitgdiTest.iby Fri Jun 11 14:58:47 2010 +0300 +++ b/graphicsdeviceinterface/bitgdi/group/BitgdiTest.iby Wed Jun 23 19:41:15 2010 +0300 @@ -21,6 +21,7 @@ // batch file that runs all automatic bitgdi tests data=DATAZ_\bitgdiTest\bitgdiTest_run.bat \bitgdiTest_run.bat data=DATAZ_\bitgdiTest\bitgditest.bat \bitgditest.bat +data=DATAZ_\bitgdiTest\bitgditest_outlineandshadow_run.bat \bitgditest_out.bat //script files data=DATAZ_\bitgdiTest\bitgdiTest_T_All.script \bitgdiTest\bitgdiTest_T_All.script @@ -39,6 +40,10 @@ data=DATAZ_\bitgdiTest\bitgdiTest_T_Scaling.script \bitgdiTest\bitgdiTest_T_Scaling.script data=DATAZ_\bitgdiTest\bitgdiTest_T_Switch.script \bitgdiTest\bitgdiTest_T_Switch.script data=DATAZ_\bitgdiTest\bitgditest_t_extendedbitmap.script \bitgditest\bitgditest_t_extendedbitmap.script +data=DATAZ_\bitgdiTest\bitgditest_t_outlineandshadowfonts.script \bitgdiTest\bitgditest_t_outlineandshadowfonts.script + +data=DATAZ_\bitgdiTest\toutlineandshadow.ini \bitgdiTest\toutlineandshadow.ini + REM BITGDI test programs diff -r bf7481649c98 -r 7f25ef56562d graphicsdeviceinterface/bitgdi/group/bitgdi.pkg --- a/graphicsdeviceinterface/bitgdi/group/bitgdi.pkg Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +0,0 @@ -; -; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -; All rights reserved. -; This component and the accompanying materials are made available -; under the terms of "Eclipse Public License v1.0" -; which accompanies this distribution, and is available -; at the URL "http://www.eclipse.org/legal/epl-v10.html". -; -; Initial Contributors: -; Nokia Corporation - initial contribution. -; -; Contributors: -; -; Description: -; -;File: bitgdi.pkg; -; -;Auto-generated PKG file by Nokia PKG Wizard for CodeWarrior IDE - -;*Languages -&EN -; -;*Standard SIS file header. This section specifies the package name, -;application UID, and version/build numbers. Add the package TYPE here if needed. -#{"BitGDITest"},(0x101FB3E8),1,0,1; -; - -;*Unique (Non-Localized) Vendor name -;This is used in combination with signing to prevent the unauthroized -;upgrade of a a package by someone other than the rightful vendor. -:"Nokia" - -;*Localized Vendor Name -;This specifies the localized vendor name(s) corresponding to language(s). -%{"Nokia Test EN"} - -;*Files To Copy... -"..\tbit\scripts\bitgdiTest_T_Accelerator.script"-"c:\bitgditest\bitgdiTest_T_Accelerator.script" -"..\tbit\scripts\bitgdiTest_T_AlphaBlending.script"-"c:\bitgditest\bitgdiTest_T_AlphaBlending.script" -"..\tbit\scripts\bitgdiTest_T_Auto.script"-"c:\bitgditest\bitgdiTest_T_Auto.script" -"..\tbit\scripts\bitgdiTest_T_BitBlt.script"-"c:\bitgditest\bitgdiTest_T_BitBlt.script" -"..\tbit\scripts\bitgdiTest_T_Clip.script"-"c:\bitgditest\bitgdiTest_T_Clip.script" -"..\tbit\scripts\bitgdiTest_T_Clip2.script"-"c:\bitgditest\bitgdiTest_T_Clip2.script" -"..\tbit\scripts\bitgdiTest_T_Defect.script"-"c:\bitgditest\bitgdiTest_T_Defect.script" -"..\tbit\scripts\bitgdiTest_T_Defect2.script"-"c:\bitgditest\bitgdiTest_T_Defect2.script" -"..\tbit\scripts\bitgdiTest_T_Font.script"-"c:\bitgditest\bitgdiTest_T_Font.script" -"..\tbit\scripts\bitgdiTest_T_FontSelect.script"-"c:\bitgditest\bitgdiTest_T_FontSelect.script" -"..\tbit\scripts\bitgdiTest_T_Gdi.script"-"c:\bitgditest\bitgdiTest_T_Gdi.script" -"..\tbit\scripts\bitgdiTest_T_Param.script"-"c:\bitgditest\bitgdiTest_T_Param.script" -"..\tbit\scripts\bitgdiTest_T_Scaling.script"-"c:\bitgditest\bitgdiTest_T_Scaling.script" -"..\tbit\scripts\bitgdiTest_T_Switch.script"-"c:\bitgditest\bitgdiTest_T_Switch.script" -"..\tbit\scripts\bitgditest_t_outlineandshadowfonts.script"-"c:\bitgditest\bitgditest_t_outlineandshadowfonts.script" - diff -r bf7481649c98 -r 7f25ef56562d graphicsdeviceinterface/bitgdi/group/bitgditest_helium.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graphicsdeviceinterface/bitgdi/group/bitgditest_helium.pkg Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,53 @@ +; Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +; All rights reserved. +; This component and the accompanying materials are made available +; under the terms of "Eclipse Public License v1.0" +; which accompanies this distribution, and is available +; at the URL "http://www.eclipse.org/legal/epl-v10.html". +; +; Initial Contributors: +; Nokia Corporation - initial contribution. +; +; Contributors: +; +; Description: +; +;File: bitgdi.pkg; +; +;*Languages +&EN +; +;*Standard SIS file header. This section specifies the package name, +;application UID, and version/build numbers. Add the package TYPE here if needed. +#{"BitGDITest"},(0x101FB3E8),1,0,1; +; + +;*Unique (Non-Localized) Vendor name +;This is used in combination with signing to prevent the unauthroized +;upgrade of a a package by someone other than the rightful vendor. +:"Nokia" + +;*Localized Vendor Name +;This specifies the localized vendor name(s) corresponding to language(s). +%{"Nokia Test EN"} + +;*Files To Copy... + +;//script files +"..\tbit\scripts\bitgdiTest_T_Accelerator.script"-"c:\bitgdiTest\bitgdiTest_T_Accelerator.script" +"..\tbit\scripts\bitgdiTest_T_AlphaBlending.script"-"c:\bitgdiTest\bitgdiTest_T_AlphaBlending.script" +"..\tbit\scripts\bitgdiTest_T_Auto.script"-"c:\bitgdiTest\bitgdiTest_T_Auto.script" +"..\tbit\scripts\bitgdiTest_T_Clip.script"-"c:\bitgdiTest\bitgdiTest_T_Clip.script" +"..\tbit\scripts\bitgdiTest_T_Clip2.script"-"c:\bitgdiTest\bitgdiTest_T_Clip2.script" +"..\tbit\scripts\bitgdiTest_T_Defect.script"-"c:\bitgdiTest\bitgdiTest_T_Defect.script" +"..\tbit\scripts\bitgdiTest_T_Defect2.script"-"c:\bitgdiTest\bitgdiTest_T_Defect2.script" +"..\tbit\scripts\bitgdiTest_T_Font.script"-"c:\bitgdiTest\bitgdiTest_T_Font.script" +"..\tbit\scripts\bitgdiTest_T_FontSelect.script"-"c:\bitgdiTest\bitgdiTest_T_FontSelect.script" +"..\tbit\scripts\bitgdiTest_T_Gdi.script"-"c:\bitgdiTest\bitgdiTest_T_Gdi.script" +"..\tbit\scripts\bitgdiTest_T_Param.script"-"c:\bitgdiTest\bitgdiTest_T_Param.script" +"..\tbit\scripts\bitgdiTest_T_BitBlt.script"-"c:\bitgdiTest\bitgdiTest_T_BitBlt.script" +"..\tbit\scripts\bitgdiTest_T_Scaling.script"-"c:\bitgdiTest\bitgdiTest_T_Scaling.script" +"..\tbit\scripts\bitgdiTest_T_Switch.script"-"c:\bitgdiTest\bitgdiTest_T_Switch.script" +"..\tbit\scripts\bitgditest_t_extendedbitmap.script"-"c:\bitgditest\bitgditest_t_extendedbitmap.script" +"..\tbit\scripts\bitgditest_t_outlineandshadowfonts.script"-"c:\bitgditest\bitgditest_t_outlineandshadowfonts.script" + diff -r bf7481649c98 -r 7f25ef56562d graphicsdeviceinterface/directgdi/group/directgditest_helium.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graphicsdeviceinterface/directgdi/group/directgditest_helium.pkg Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,39 @@ +; Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +; All rights reserved. +; This component and the accompanying materials are made available +; under the terms of "Eclipse Public License v1.0" +; which accompanies this distribution, and is available +; at the URL "http://www.eclipse.org/legal/epl-v10.html". +; +; Initial Contributors: +; Nokia Corporation - initial contribution. +; +; Contributors: +; +; Description: +; +;File: bitgdi.pkg; +; +;*Languages +&EN +; +;*Standard SIS file header. This section specifies the package name, +;application UID, and version/build numbers. Add the package TYPE here if needed. +#{"DirectGDITest"},(0x101FB3E8),1,0,1; +; + +;*Unique (Non-Localized) Vendor name +;This is used in combination with signing to prevent the unauthroized +;upgrade of a a package by someone other than the rightful vendor. +:"Nokia" + +;*Localized Vendor Name +;This specifies the localized vendor name(s) corresponding to language(s). +%{"Nokia Test EN"} + +;*Files To Copy... + +;//script files +"..\test\scripts\directgditest\directgditest_t_general_hw.script"-"c:\directgditest\directgditest_t_general.script" +"..\test\scripts\directgditest\directgditest_t_no_adapter.script"-"c:\directgditest\directgditest_t_no_adapter.script" + diff -r bf7481649c98 -r 7f25ef56562d graphicsdeviceinterface/gdi/bwins/GDI2U.def --- a/graphicsdeviceinterface/gdi/bwins/GDI2U.def Fri Jun 11 14:58:47 2010 +0300 +++ b/graphicsdeviceinterface/gdi/bwins/GDI2U.def Wed Jun 23 19:41:15 2010 +0300 @@ -316,5 +316,8 @@ ?Open@RGlyphDataIterator@@QAEHAAVCFont@@PBIH@Z @ 315 NONAME ABSENT ; int RGlyphDataIterator::Open(class CFont &, unsigned int const *, int) ?SetName@TTypeface@@QAEXABVTDesC16@@@Z @ 316 NONAME ; void TTypeface::SetName(class TDesC16 const &) ?Name@TTypeface@@QBEABVTDesC16@@XZ @ 317 NONAME ; class TDesC16 const & TTypeface::Name(void) const - + ?At@RHexTreeBase@@IBEPAXI@Z @ 318 NONAME ; void * RHexTreeBase::At(unsigned int) const + ??0RHexTreeBase@@IAE@PAVRHeap@@@Z @ 319 NONAME ; RHexTreeBase::RHexTreeBase(class RHeap *) + ?SetAt@RHexTreeBase@@IAEHIPAX@Z @ 320 NONAME ; int RHexTreeBase::SetAt(unsigned int, void *) + ?ResetAndDestroy@RHexTreeBase@@QAEXXZ @ 321 NONAME ; void RHexTreeBase::ResetAndDestroy(void) diff -r bf7481649c98 -r 7f25ef56562d graphicsdeviceinterface/gdi/eabi/GDI2U.def --- a/graphicsdeviceinterface/gdi/eabi/GDI2U.def Fri Jun 11 14:58:47 2010 +0300 +++ b/graphicsdeviceinterface/gdi/eabi/GDI2U.def Wed Jun 23 19:41:15 2010 +0300 @@ -391,4 +391,9 @@ _ZNK18RGlyphMetricsArrayixEi @ 390 NONAME ABSENT _ZN9TTypeface7SetNameERK7TDesC16 @ 391 NONAME _ZNK9TTypeface4NameEv @ 392 NONAME + _ZN12RHexTreeBase15ResetAndDestroyEv @ 393 NONAME + _ZN12RHexTreeBase5SetAtEjPv @ 394 NONAME + _ZN12RHexTreeBaseC1EP5RHeap @ 395 NONAME + _ZN12RHexTreeBaseC2EP5RHeap @ 396 NONAME + _ZNK12RHexTreeBase2AtEj @ 397 NONAME diff -r bf7481649c98 -r 7f25ef56562d graphicsdeviceinterface/gdi/group/BLD.INF --- a/graphicsdeviceinterface/gdi/group/BLD.INF Fri Jun 11 14:58:47 2010 +0300 +++ b/graphicsdeviceinterface/gdi/group/BLD.INF Wed Jun 23 19:41:15 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 1999-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -46,6 +46,9 @@ ../inc/gdiinline.inl SYMBIAN_OS_LAYER_PLATFORM_EXPORT_PATH(graphics/gdi/gdiinline.inl) ../inc/gdiplatapi.h SYMBIAN_OS_LAYER_PLATFORM_EXPORT_PATH(graphics/gdi/gdiplatapi.h) +../inc/hextree.h SYMBIAN_OS_LAYER_PLATFORM_EXPORT_PATH(hextree.h) +../inc/hextree.inl SYMBIAN_OS_LAYER_PLATFORM_EXPORT_PATH(hextree.inl) + ../group/gdi.iby /epoc32/rom/include/gdi.iby diff -r bf7481649c98 -r 7f25ef56562d graphicsdeviceinterface/gdi/group/GDI.MMP --- a/graphicsdeviceinterface/gdi/group/GDI.MMP Fri Jun 11 14:58:47 2010 +0300 +++ b/graphicsdeviceinterface/gdi/group/GDI.MMP Wed Jun 23 19:41:15 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 1998-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -53,6 +53,7 @@ SOURCE FontIndic.cpp SOURCE ShaperCli.cpp SOURCE GDI.CPP +SOURCE hextree.cpp LIBRARY euser.lib LIBRARY efsrv.lib diff -r bf7481649c98 -r 7f25ef56562d graphicsdeviceinterface/gdi/group/gditest_helium.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graphicsdeviceinterface/gdi/group/gditest_helium.pkg Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,43 @@ +; Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +; All rights reserved. +; This component and the accompanying materials are made available +; under the terms of "Eclipse Public License v1.0" +; which accompanies this distribution, and is available +; at the URL "http://www.eclipse.org/legal/epl-v10.html". +; +; Initial Contributors: +; Nokia Corporation - initial contribution. +; +; Contributors: +; +; Description: +; +;File: bitgdi.pkg; +; +;*Languages +&EN +; +;*Standard SIS file header. This section specifies the package name, +;application UID, and version/build numbers. Add the package TYPE here if needed. +#{"BitGDITest"},(0x101FB3E8),1,0,1; +; + +;*Unique (Non-Localized) Vendor name +;This is used in combination with signing to prevent the unauthroized +;upgrade of a a package by someone other than the rightful vendor. +:"Nokia" + +;*Localized Vendor Name +;This specifies the localized vendor name(s) corresponding to language(s). +%{"Nokia Test EN"} + +;*Files To Copy... + +;//script file +"..\tgdi\scripts\gditest_T_Rgb.script"-"c:\gditest\gditest_T_Rgb.script" +"..\tgdi\scripts\gditest_T_Types.script"-"c:\gditest\gditest_T_Types.script" +"..\tgdi\scripts\gditest_T_BiDiDefect.script"-"c:\gditest\gditest_T_BiDiDefect.script" +"..\tgdi\scripts\gditest_T_LineBreak.script"-"c:\gditest\gditest_T_LineBreak.script" +"..\tgdi\scripts\gditest_T_GlyphSelection.script"-"c:\gditest\gditest_T_GlyphSelection.script" +"..\tgdi\scripts\gditest_T_BiDi.script"-"c:\gditest\gditest_T_BiDi.script" + diff -r bf7481649c98 -r 7f25ef56562d graphicsdeviceinterface/gdi/inc/hextree.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graphicsdeviceinterface/gdi/inc/hextree.h Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,74 @@ +// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Hexadecimal trees - declaration +// + +#ifndef HEXTREE_H +#define HEXTREE_H + +#include + +/** +Base class that provides the implementation for RHexTree, which is just a thin +template. + +An instance of this class can have up to eight 16-way prefix trees, with heights +from 1 to 8. All the values are stored in the leaves. To find a value from a +32-bit key, first the key is decomposed into 8 hexadecimal digits and then the +prefix tree with height matching the number of digits in the key (ignoring zeros +to the left) is traversed using the sequence of digits in the key as the +indexing string. Offsets are internally used instead of pointers to allow +instances to be placed in a heap shared between several processes. +*/ +class RHexTreeBase + { +public: + IMPORT_C void ResetAndDestroy(); +protected: + IMPORT_C RHexTreeBase(RHeap* aHeap); + IMPORT_C TInt SetAt(TUint aKey, TAny* aValue); + IMPORT_C TAny* At(TUint aKey) const; +private: + TInt SetAt(TUint aKey, TAny* aLeaf, TInt aHeight); + TInt SetAt(TUint aKey, TAny* aLeaf, TInt aHeight, TAny* aNode, TInt aLevel); + TAny* At(TUint aKey, TInt aHeight) const; + void ResetAndDestroy(TInt aHeight, TAny* aNode, TInt aLevel); +private: + enum { EMaxNumHexDigits = 8 }; +private: + RHeap* iHeap; + TInt iRootOffsets[EMaxNumHexDigits]; + }; + +/** +An associative array implementation optimised for the case where the keys are +32-bit codes with spatial locality of reference. The values can be of any +self-contained data type (that is, without destructor or clean-up functions). +It allows multiple-readers, single-writer concurrent access from different +processes in an SMP-safe manner without locking, excluding deletion of +individual key-value pairs. +*/ +template +class RHexTree : public RHexTreeBase + { +public: + inline RHexTree(RHeap* aHeap); + inline TInt SetAt(TUint aKey, T* aValue); + inline const T* At(TUint aKey) const; + inline T* At(TUint aKey); + }; + +#include + +#endif // HEXTREE_H diff -r bf7481649c98 -r 7f25ef56562d graphicsdeviceinterface/gdi/inc/hextree.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graphicsdeviceinterface/gdi/inc/hextree.inl Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,83 @@ +// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Hexadecimal trees - inline functions +// + +#ifndef HEXTREE_INL +#define HEXTREE_INL + +/** +Constructor. It constructs an associative array with no key-value pairs. + +@param aHeap A pointer to the heap to be used by the associative array + implementation to allocate memory for internal data structures. This + heap can be shared between several processes. +*/ +template +inline RHexTree::RHexTree(RHeap* aHeap) + : RHexTreeBase(aHeap) + { + } + +/** +Adds a key-value pair to this associative array. + +@param aKey The 32-bit key to add to this associative array. +@param aValue A pointer to the value to associate with aKey. It must have been + allocated on the same heap as the one used by the associative array + implementation to allocate memory for internal data structures. Ownership + is transferred to this associative array. +@return KErrNone if the key-value pair was added successfully. KErrNoMemory if + there was not enough memory in the heap for internal data structures. + KErrAlreadyExists if an attempt was made to add a duplicate key. +*/ +template +inline TInt RHexTree::SetAt(TUint aKey, T* aValue) + { + return RHexTreeBase::SetAt(aKey, aValue); + } + +/** +Looks up a given key in this associative array and returns a pointer to the +corresponding value. + +@param aKey The 32-bit key to look up. +@return A pointer to the corresponding value in this associative array, if the + given key was found. The value may not be modified via this pointer. + NULL if the given key was not found. +*/ +template +inline const T* RHexTree::At(TUint aKey) const + { + return static_cast(RHexTreeBase::At(aKey)); + } + +/** +Looks up a given key in this associative array and returns a pointer to the +corresponding value. Note that if values are modified after being added to an +associative array, then the user is responsible for synchronisation when +concurrent access is needed. + +@param aKey The 32-bit key to look up. +@return A pointer to the corresponding value in this associative array, if the + given key was found. The value may be modified via this pointer. + NULL if the given key was not found. +*/ +template +inline T* RHexTree::At(TUint aKey) + { + return static_cast(RHexTreeBase::At(aKey)); + } + +#endif // HEXTREE_INL diff -r bf7481649c98 -r 7f25ef56562d graphicsdeviceinterface/gdi/sgdi/hextree.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graphicsdeviceinterface/gdi/sgdi/hextree.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,195 @@ +// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Hexadecimal trees - implementation +// + +#include +#include + +EXPORT_C RHexTreeBase::RHexTreeBase(RHeap* aHeap) + : iHeap(aHeap) + { + Mem::FillZ(iRootOffsets, sizeof(iRootOffsets)); + } + +EXPORT_C TInt RHexTreeBase::SetAt(TUint aKey, TAny* aValue) + { + TUint mask = 0xF0000000; + for (TInt height = EMaxNumHexDigits; height > 1; --height) + { + if ((aKey & mask) != 0) + { + return SetAt(aKey, aValue, height); + } + mask >>= 4; + } + return SetAt(aKey, aValue, 1); + } + +EXPORT_C TAny* RHexTreeBase::At(TUint aKey) const + { + TUint mask = 0xF0000000; + for (TInt height = EMaxNumHexDigits; height > 1; --height) + { + if ((aKey & mask) != 0) + { + return At(aKey, height); + } + mask >>= 4; + } + return At(aKey, 1); + } + +/** +Empties this associative array and frees all memory allocated both for the +associative array implementation and for the values that have been added to +this associative array. + +The internal state of this associative array is reset so that it can be reused +or allowed to go out of scope after a call to this function. +*/ +EXPORT_C void RHexTreeBase::ResetAndDestroy() + { + for (TInt height = 1; height <= EMaxNumHexDigits; ++height) + { + TInt offset = iRootOffsets[height - 1]; + if (offset != 0) + { + TAny* root = PtrAdd(this, offset); + ResetAndDestroy(height, root, 1); + iRootOffsets[height - 1] = 0; + } + } + } + +TInt RHexTreeBase::SetAt(TUint aKey, TAny* aLeaf, TInt aHeight) + { + TInt err; + TInt offset = iRootOffsets[aHeight - 1]; + if (offset == 0) + { + TAny* root = iHeap->AllocZ(aHeight > 1 ? sizeof(TInt) * 15 : sizeof(TInt) * 16); + if (!root) + { + return KErrNoMemory; + } + err = SetAt(aKey, aLeaf, aHeight, root, 1); + if (err == KErrNone) + { + __e32_atomic_store_rel32(&iRootOffsets[aHeight - 1], reinterpret_cast(root) - reinterpret_cast(this)); + } + else + { + iHeap->Free(root); + } + } + else + { + TAny* root = PtrAdd(this, offset); + err = SetAt(aKey, aLeaf, aHeight, root, 1); + } + return err; + } + +TInt RHexTreeBase::SetAt(TUint aKey, TAny* aLeaf, TInt aHeight, TAny* aNode, TInt aLevel) + { + TInt err = KErrNone; + TInt branch = (aKey >> ((aHeight - aLevel) << 2)) & 0xF; + if (aLevel == 1 && aHeight > 1) + { + --branch; + } + TInt offset = static_cast(aNode)[branch]; + if (aLevel == aHeight) + { + if (offset == 0) + { + __e32_atomic_store_rel32(&static_cast(aNode)[branch], reinterpret_cast(aLeaf) - reinterpret_cast(aNode)); + } + else + { + err = KErrAlreadyExists; + } + } + else if (offset == 0) + { + TAny* newNode = iHeap->AllocZ(sizeof(TInt) * 16); + if (!newNode) + { + return KErrNoMemory; + } + err = SetAt(aKey, aLeaf, aHeight, newNode, aLevel + 1); + if (err == KErrNone) + { + __e32_atomic_store_rel32(&static_cast(aNode)[branch], reinterpret_cast(newNode) - reinterpret_cast(aNode)); + } + else + { + iHeap->Free(newNode); + } + } + else + { + TAny* nextNode = PtrAdd(aNode, offset); + err = SetAt(aKey, aLeaf, aHeight, nextNode, aLevel + 1); + } + return err; + } + +TAny* RHexTreeBase::At(TUint aKey, TInt aHeight) const + { + TInt offset = __e32_atomic_load_acq32(&iRootOffsets[aHeight - 1]); + if (offset == 0) + { + return NULL; + } + const TAny* node = PtrAdd(this, offset); + for (TInt level = 1; level <= aHeight; ++level) + { + TInt branch = (aKey >> ((aHeight - level) << 2)) & 0xF; + if (level == 1 && aHeight > 1) + { + --branch; + } + offset = __e32_atomic_load_acq32(&static_cast(node)[branch]); + if (offset == 0) + { + return NULL; + } + node = PtrAdd(node, offset); + } + return const_cast(node); + } + +void RHexTreeBase::ResetAndDestroy(TInt aHeight, TAny* aNode, TInt aLevel) + { + TInt maxNumBranches = (aLevel == 1 && aHeight > 1 ? 15 : 16); + for (TInt branch = 0; branch < maxNumBranches; ++branch) + { + TInt offset = static_cast(aNode)[branch]; + if (offset != 0) + { + TAny* nextNode = PtrAdd(aNode, offset); + if (aLevel == aHeight) + { + iHeap->Free(nextNode); + } + else + { + ResetAndDestroy(aHeight, nextNode, aLevel + 1); + } + } + } + iHeap->Free(aNode); + } diff -r bf7481649c98 -r 7f25ef56562d graphicsdeviceinterface/screendriver/group/scdvtest_helium.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graphicsdeviceinterface/screendriver/group/scdvtest_helium.pkg Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,44 @@ +; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +; All rights reserved. +; This component and the accompanying materials are made available +; under the terms of "Eclipse Public License v1.0" +; which accompanies this distribution, and is available +; at the URL "http://www.eclipse.org/legal/epl-v10.html". +; +; Initial Contributors: +; Nokia Corporation - initial contribution. +; +; Contributors: +; +; Description: +; +;File: bitgdi.pkg; +; +;*Languages +&EN +; +;*Standard SIS file header. This section specifies the package name, +;application UID, and version/build numbers. Add the package TYPE here if needed. +#{"ScdvTest"},(0x101FB3E8),1,0,1; +; + +;*Unique (Non-Localized) Vendor name +;This is used in combination with signing to prevent the unauthroized +;upgrade of a a package by someone other than the rightful vendor. +:"Nokia" + +;*Localized Vendor Name +;This specifies the localized vendor name(s) corresponding to language(s). +%{"Nokia Test EN"} + +;*Files To Copy... + +;// script file +"..\tsrc\scripts\scdvtest_t_LowLevel.script"-"c:\scdvtest\scdvtest_t_LowLevel.script" +"..\tsrc\scripts\scdvtest_t_LowLevel1.script"-"c:\scdvtest\scdvtest_t_LowLevel1.script" +"..\tsrc\scripts\scdvtest_t_RWindows.script"-"c:\scdvtest\scdvtest_t_RWindows.script" +"..\tsrc\scripts\scdvtest_t_Scaling.script"-"c:\scdvtest\scdvtest_t_Scaling.script" +"..\tsrc\scripts\scdvtest_t_Scdv.script"-"c:\scdvtest\scdvtest_t_Scdv.script" +"..\tsrc\scripts\scdvtest_t_devorientation.script"-"c:\scdvtest\scdvtest_t_devorientation.script" +"..\tsrc\scripts\scdvtest_t_directscreenbitmap.script"-"c:\scdvtest\scdvtest_t_directscreenbitmap.script" + diff -r bf7481649c98 -r 7f25ef56562d graphicshwdrivers/surfacemgr/test/group/surfacemanagertest_helium.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graphicshwdrivers/surfacemgr/test/group/surfacemanagertest_helium.pkg Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,40 @@ +; Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +; All rights reserved. +; This component and the accompanying materials are made available +; under the terms of "Eclipse Public License v1.0" +; which accompanies this distribution, and is available +; at the URL "http://www.eclipse.org/legal/epl-v10.html". +; +; Initial Contributors: +; Nokia Corporation - initial contribution. +; +; Contributors: +; +; Description: +; +;File: surfacemanagertest.pkg; +; +;*Languages +&EN +; +;*Standard SIS file header. This section specifies the package name, +;application UID, and version/build numbers. Add the package TYPE here if needed. +#{"SurfaceManagerTest"},(0x101FB3E8),1,0,1; +; + +;*Unique (Non-Localized) Vendor name +;This is used in combination with signing to prevent the unauthroized +;upgrade of a a package by someone other than the rightful vendor. +:"Nokia" + +;*Localized Vendor Name +;This specifies the localized vendor name(s) corresponding to language(s). +%{"Nokia Test EN"} + +;*Files To Copy... + +;//script files +"..\scripts\surfacemgtest_T_auto.script"-"c:\surfacemgtest\surfacemgtest_T_auto.script" +"..\scripts\surfacemgtest_T_multiprocess.script"-"c:\surfacemgtest\surfacemgtest_T_multiprocess.script" +"..\scripts\surfacemgtest_T_multithread.script"-"c:\surfacemgtest\surfacemgtest_T_multithread.script" + diff -r bf7481649c98 -r 7f25ef56562d graphicsresourceservices/graphicsresource/group/graphicsresourcetest_helium.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graphicsresourceservices/graphicsresource/group/graphicsresourcetest_helium.pkg Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,39 @@ +; Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +; All rights reserved. +; This component and the accompanying materials are made available +; under the terms of "Eclipse Public License v1.0" +; which accompanies this distribution, and is available +; at the URL "http://www.eclipse.org/legal/epl-v10.html". +; +; Initial Contributors: +; Nokia Corporation - initial contribution. +; +; Contributors: +; +; Description: +; +;File: bitgdi.pkg; +; +;*Languages +&EN +; +;*Standard SIS file header. This section specifies the package name, +;application UID, and version/build numbers. Add the package TYPE here if needed. +#{"GraphicsResourceTest"},(0x101FB3E8),1,0,1; +; + +;*Unique (Non-Localized) Vendor name +;This is used in combination with signing to prevent the unauthroized +;upgrade of a a package by someone other than the rightful vendor. +:"Nokia" + +;*Localized Vendor Name +;This specifies the localized vendor name(s) corresponding to language(s). +%{"Nokia Test EN"} + +;*Files To Copy... + +;// script files +"..\test\scripts\graphicsresourcetest_t_generic.script"-"c:\graphicsresourcetest\graphicsresourcetest_t_generic.script" +"..\test\scripts\graphicsresourcetest_t_##GRAPHICSRESOURCETEST_DRV##.script"-"c:\graphicsresourcetest\graphicsresourcetest_t_##GRAPHICSRESOURCETEST_DRV##.script" + diff -r bf7481649c98 -r 7f25ef56562d graphicsresourceservices/graphicsresourceimplementation/test/group/sgresourcetest_helium.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graphicsresourceservices/graphicsresourceimplementation/test/group/sgresourcetest_helium.pkg Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,39 @@ +; Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +; All rights reserved. +; This component and the accompanying materials are made available +; under the terms of "Eclipse Public License v1.0" +; which accompanies this distribution, and is available +; at the URL "http://www.eclipse.org/legal/epl-v10.html". +; +; Initial Contributors: +; Nokia Corporation - initial contribution. +; +; Contributors: +; +; Description: +; +;File: bitgdi.pkg; +; +;*Languages +&EN +; +;*Standard SIS file header. This section specifies the package name, +;application UID, and version/build numbers. Add the package TYPE here if needed. +#{"SGResourceTest"},(0x101FB3E8),1,0,1; +; + +;*Unique (Non-Localized) Vendor name +;This is used in combination with signing to prevent the unauthroized +;upgrade of a a package by someone other than the rightful vendor. +:"Nokia" + +;*Localized Vendor Name +;This specifies the localized vendor name(s) corresponding to language(s). +%{"Nokia Test EN"} + +;*Files To Copy... + +;//script file +"..\scripts\sgresourcetest_t_generic.script"-"c:\sgresourcetest\sgresourcetest_t_generic.script" +"..\scripts\sgresourcetest_t_internal.script"-"c:\sgresourcetest\sgresourcetest_t_internal.script" + diff -r bf7481649c98 -r 7f25ef56562d graphicstest/graphicstestharness/automation/graphicssystemgui.sysdef.xml --- a/graphicstest/graphicstestharness/automation/graphicssystemgui.sysdef.xml Fri Jun 11 14:58:47 2010 +0300 +++ b/graphicstest/graphicstestharness/automation/graphicssystemgui.sysdef.xml Wed Jun 23 19:41:15 2010 +0300 @@ -89,74 +89,6 @@ ]> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -306,6 +238,9 @@ + + + diff -r bf7481649c98 -r 7f25ef56562d graphicstest/graphicstestharness/automation/h4/tests_29b.txt --- a/graphicstest/graphicstestharness/automation/h4/tests_29b.txt Fri Jun 11 14:58:47 2010 +0300 +++ b/graphicstest/graphicstestharness/automation/h4/tests_29b.txt Wed Jun 23 19:41:15 2010 +0300 @@ -1,4 +1,3 @@ -tests_29b.txt # Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). # All rights reserved. # This component and the accompanying materials are made available diff -r bf7481649c98 -r 7f25ef56562d graphicstest/graphicstestharness/automation/winscw/tests.txt --- a/graphicstest/graphicstestharness/automation/winscw/tests.txt Fri Jun 11 14:58:47 2010 +0300 +++ b/graphicstest/graphicstestharness/automation/winscw/tests.txt Wed Jun 23 19:41:15 2010 +0300 @@ -71,7 +71,7 @@ # FEP TESTS TESTEXECUTE, C:\logs\testexecute\fepbasetest_t_defocusingedwin.htm, , z:\fepbasetest\fepbasetest_t_defocusingedwin.script, 600 -TESTEXECUTE, C:\logs\testexecute\fepbasetest_t_fep1testtarget.htm, , z:\fepbasetest\fepbasetest_t_fep1testtarget.script, 600 +TESTEXECUTE, C:\logs\testexecute\fepbasetest_t_fep1testtarget.htm, , z:\fepbasetest\fepbasetest_t_fep1testtarget.script, 600, , z\graphicstest\minigui.cmd, z\graphicstest\unminigui.cmd TESTEXECUTE, C:\logs\testexecute\fepbasetest_t_keyboardlogger.htm, , z:\fepbasetest\fepbasetest_t_keyboardlogger.script, 600 # GFXTRANSEFFECT TESTS @@ -265,9 +265,9 @@ TESTEXECUTE, C:\logs\testexecute\egltest_t_sibling.htm, , z:\egltest\egltest_t_sibling.script, 600, , z\graphics\t_graphics_config_inifiles.bat install, z\graphics\t_graphics_config_inifiles.bat uninstall TESTEXECUTE, C:\logs\testexecute\egltest_t_vgimagetosurfaces.htm, , z:\egltest\egltest_t_vgimagetosurfaces.script, 600, , z\graphics\t_graphics_config_inifiles.bat install, z\graphics\t_graphics_config_inifiles.bat uninstall TESTEXECUTE, C:\logs\testexecute\egltest_t_benchmark_sgimage.htm, , z:\egltest\egltest_t_benchmark_sgimage.script, 300, , z\graphics\t_graphics_config_inifiles.bat install, z\graphics\t_graphics_config_inifiles.bat uninstall +TESTEXECUTE, C:\logs\testexecute\egltest_t_oom_sgimage.htm, , z:\egltest\egltest_t_oom_sgimage.script, 600, , z\graphics\t_graphics_config_inifiles.bat install, z\graphics\t_graphics_config_inifiles.bat uninstall TESTEXECUTE, C:\logs\testexecute\egltest_t_stress_sgimage.htm, , z:\egltest\egltest_t_stress_sgimage.script, 600, , z\graphics\t_graphics_config_inifiles.bat install, z\graphics\t_graphics_config_inifiles.bat uninstall - # GCE TESTEXECUTE, C:\logs\testexecute\functionaltest_mandatory.htm, , z:\gcetest\functionaltest_mandatory.script, 600, , z\gcetest\gcetest_setup_emu.bat install dabs, z\gcetest\gcetest_setup_emu.bat uninstall dabs TESTEXECUTE, C:\logs\testexecute\functionaltest_optional.htm, , z:\gcetest\functionaltest_optional.script, 600, , z\gcetest\gcetest_setup_emu.bat install dabs, z\gcetest\gcetest_setup_emu.bat uninstall dabs diff -r bf7481649c98 -r 7f25ef56562d graphicstest/graphicstestharness/automation/winscw/tests_smoke.txt --- a/graphicstest/graphicstestharness/automation/winscw/tests_smoke.txt Fri Jun 11 14:58:47 2010 +0300 +++ b/graphicstest/graphicstestharness/automation/winscw/tests_smoke.txt Wed Jun 23 19:41:15 2010 +0300 @@ -71,7 +71,7 @@ # FEP TESTS TESTEXECUTE, C:\logs\testexecute\fepbasetest_t_defocusingedwin.htm, , z:\fepbasetest\fepbasetest_t_defocusingedwin.script, 600 -TESTEXECUTE, C:\logs\testexecute\fepbasetest_t_fep1testtarget.htm, , z:\fepbasetest\fepbasetest_t_fep1testtarget.script, 600 +TESTEXECUTE, C:\logs\testexecute\fepbasetest_t_fep1testtarget.htm, , z:\fepbasetest\fepbasetest_t_fep1testtarget.script, 600, , z\graphicstest\minigui.cmd, z\graphicstest\unminigui.cmd TESTEXECUTE, C:\logs\testexecute\fepbasetest_t_keyboardlogger.htm, , z:\fepbasetest\fepbasetest_t_keyboardlogger.script, 600 # GFXTRANSEFFECT TESTS diff -r bf7481649c98 -r 7f25ef56562d graphicstest/graphicstestharness/group/BLD.INF --- a/graphicstest/graphicstestharness/group/BLD.INF Fri Jun 11 14:58:47 2010 +0300 +++ b/graphicstest/graphicstestharness/group/BLD.INF Wed Jun 23 19:41:15 2010 +0300 @@ -29,6 +29,7 @@ ../rom/graphics_test1.iby /epoc32/rom/include/graphics_test1.iby ../rom/graphics_test2.iby /epoc32/rom/include/graphics_test2.iby ../rom/graphics_testharness.iby /epoc32/rom/include/graphics_testharness.iby +../rom/graphics_testharnessutils.iby /epoc32/rom/include/graphics_testharnessutils.iby ../rom/graphics_autotest.iby /epoc32/rom/include/graphics_autotest.iby ../rom/graphics_testall.iby /epoc32/rom/include/graphics_testall.iby //Contains all but the tests mentioned on the next line ../rom/graphics_testrast.iby /epoc32/rom/include/graphics_testrast.iby //Contains the tests that need to use an alternate rasteriser @@ -39,6 +40,11 @@ ../rom/graphics_tprofiler.iby /epoc32/rom/include/graphics_tprofiler.iby ../rom/graphics_simload.iby /epoc32/rom/include/graphics_simload.iby +// WSINI +../rom/graphics_sirocco_wsini.hby /epoc32/rom/include/graphics_sirocco_wsini.hby +../rom/graphics_sirocco_wsini.iby /epoc32/rom/include/graphics_sirocco_wsini.iby +../wsini/wsini_vasco.ini /epoc32/data/test_wsini/wsini_vasco.ini + // ONB batch files ../batch/retain_files.cmd z:\graphicstest\retain_files.cmd ../batch/minigui.cmd z:\graphicstest\minigui.cmd @@ -80,10 +86,10 @@ ../group/graphicsscreencomparison.mmp ../group/graphicsimagecomparison.mmp ../group/tprofiler.mmp -t_simloadutils.mmp -t_simloadapp1.mmp -t_simloadapp2.mmp -t_simloadapp3.mmp +../group/t_simloadutils.mmp +../group/t_simloadapp1.mmp +../group/t_simloadapp2.mmp +../group/t_simloadapp3.mmp #if defined(WINS) ../group/fontinjector.mmp diff -r bf7481649c98 -r 7f25ef56562d graphicstest/graphicstestharness/rom/graphics_sirocco_wsini.hby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graphicstest/graphicstestharness/rom/graphics_sirocco_wsini.hby Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,28 @@ +// Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#ifndef __GRAPHICS_SIROCCO_WSINI_HBY__ +#define __GRAPHICS_SIROCCO_WSINI_HBY__ + +//Wserv wsini test configurations: + +#define WSERV_TEST_WSINI_ALF 0x0001 +#define WSERV_TEST_WSINI_BITGDIRENDERSTAGE 0x0002 +#define WSERV_TEST_WSINI_CSC 0x0003 +#define WSERV_TEST_WSINI_GENERICPLUGIN 0x0004 +#define WSERV_TEST_WSINI_LAYERCOMPOSITION 0x0005 +#define WSERV_TEST_WSINI_RATELIMITER 0x0006 + +#endif // __GRAPHICS_SIROCCO_WSINI_HBY__ diff -r bf7481649c98 -r 7f25ef56562d graphicstest/graphicstestharness/rom/graphics_sirocco_wsini.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graphicstest/graphicstestharness/rom/graphics_sirocco_wsini.iby Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,37 @@ +// Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#ifndef __GRAPHICS_SIROCCO_WSINI_IBY__ +#define __GRAPHICS_SIROCCO_WSINI_IBY__ + +#include + +#if WSERV_TEST_WSINI == WSERV_TEST_WSINI_ALF + data=DATAZ_\talf\wsini_vasco_alf.ini \system\data\wsini.ini +#elif WSERV_TEST_WSINI == WSERV_TEST_WSINI_BITGDIRENDERSTAGE + data=DATAZ_\wstest\tbitgdirenderstage\arm\wsini_bitgdirenderstage_vasco.ini \system\data\wsini.ini +#elif WSERV_TEST_WSINI == WSERV_TEST_WSINI_CSC + data=DATAZ_\wstest\wsini_vasco_tcsc.ini \system\data\wsini.ini +#elif WSERV_TEST_WSINI == WSERV_TEST_WSINI_GENERICPLUGIN + data=DATAZ_\wstest\genericplugin\wsini_vasco_genericplugin.ini \system\data\wsini.ini +#elif WSERV_TEST_WSINI == WSERV_TEST_WSINI_LAYERCOMPOSITION + data=DATAZ_\tlayercomposition\wsini_vasco_layercomposition.ini \system\data\wsini.ini +#elif WSERV_TEST_WSINI == WSERV_TEST_WSINI_RATELIMITER + data=DATAZ_\wstest\ratelimiter\wsini_vasco_ratelimiter.ini \system\data\wsini.ini +#else + data=EPOCROOT##epoc32\data\test_wsini\wsini_vasco.ini \system\data\wsini.ini +#endif + +#endif // __GRAPHICS_SIROCCO_WSINI_IBY__ diff -r bf7481649c98 -r 7f25ef56562d graphicstest/graphicstestharness/rom/graphics_testharnessutils.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graphicstest/graphicstestharness/rom/graphics_testharnessutils.iby Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,34 @@ +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#ifndef __GRAPHICS_TESTHARNESSUTILS_IBY__ +#define __GRAPHICS_TESTHARNESSUTILS_IBY__ + +#define __GRAPHICS_TESTHARNESS_IBY__ + +#include + +REM Graphics Test Framework utilities +file=ABI_DIR\DEBUG_DIR\TGraphicsHarness.DLL sys\bin\TGraphicsHarness.DLL + +file=ABI_DIR\DEBUG_DIR\GraphicsTestUtilsServer.exe Sys\bin\GraphicsTestUtilsServer.exe +file=ABI_DIR\DEBUG_DIR\GraphicsTestUtils.dll Sys\bin\GraphicsTestUtils.dll + +//mbm files +data=DATAZ_\wstest\spritebitmaps.mbm wstest\spritebitmaps.mbm +data=DATAZ_\wstest\WSAUTOTEST.MBM wstest\WSAUTOTEST.MBM +data=DATAZ_\wstest\testcircles.mbm wstest\testcircles.mbm + +#endif // __GRAPHICS_TESTHARNESSUTILS_IBY__ diff -r bf7481649c98 -r 7f25ef56562d graphicstest/graphicstestharness/wsini/wsini_vasco.ini Binary file graphicstest/graphicstestharness/wsini/wsini_vasco.ini has changed diff -r bf7481649c98 -r 7f25ef56562d graphicstest/uibench/s60/group/te_uibench_s60_helium.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graphicstest/uibench/s60/group/te_uibench_s60_helium.pkg Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,46 @@ +; Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +; All rights reserved. +; This component and the accompanying materials are made available +; under the terms of "Eclipse Public License v1.0" +; which accompanies this distribution, and is available +; at the URL "http://www.eclipse.org/legal/epl-v10.html". +; +; Initial Contributors: +; Nokia Corporation - initial contribution. +; +; Contributors: +; +; Description: +; +;File: bitgdi.pkg; +; +;*Languages +&EN +; +;*Standard SIS file header. This section specifies the package name, +;application UID, and version/build numbers. Add the package TYPE here if needed. +#{"UIBench_S60"},(0x101FB3E8),1,0,1; +; + +;*Unique (Non-Localized) Vendor name +;This is used in combination with signing to prevent the unauthroized +;upgrade of a a package by someone other than the rightful vendor. +:"Nokia" + +;*Localized Vendor Name +;This specifies the localized vendor name(s) corresponding to language(s). +%{"Nokia Test EN"} + +;*Files To Copy... + +"..\scripts\te_uibench_s60_tcopyrect.script"-"c:\uibench_s60\te_uibench_s60_tcopyrect.script" +"..\scripts\te_uibench_s60_tflowwindows.script"-"c:\uibench_s60\te_uibench_s60_tflowwindows.script" +"..\scripts\te_uibench_s60_tfonts.script"-"c:\uibench_s60\te_uibench_s60_tfonts.script" +"..\scripts\te_uibench_s60_tpan.script"-"c:\uibench_s60\te_uibench_s60_tpan.script" +"..\scripts\te_uibench_s60_trotate.script"-"c:\uibench_s60\te_uibench_s60_trotate.script" +"..\scripts\te_uibench_s60_tscale.script"-"c:\uibench_s60\te_uibench_s60_tscale.script" +"..\scripts\te_uibench_s60_tuiandvideo.script"-"c:\uibench_s60\te_uibench_s60_tuiandvideo.script" +"..\scripts\te_uibench_s60_tzorder.script"-"c:\uibench_s60\te_uibench_s60_tzorder.script" +"..\scripts\te_uibench_s60_dphone79.script"-"c:\uibench_s60\te_uibench_s60_dphone79.script" +"..\scripts\te_uibench_s60_techview_emulator.script"-"c:\uibench_s60\te_uibench_s60_techview_emulator.script" + diff -r bf7481649c98 -r 7f25ef56562d graphicstools/gdi_tools/fontcomp/GDSFCOMP.CPP --- a/graphicstools/gdi_tools/fontcomp/GDSFCOMP.CPP Fri Jun 11 14:58:47 2010 +0300 +++ b/graphicstools/gdi_tools/fontcomp/GDSFCOMP.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 1997-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -14,7 +14,7 @@ // #include "GDSFCOMP.H" -#include "toolsver.h" +#include "TOOLSVER.H" int GdsFontCompiler::WriteFont() { diff -r bf7481649c98 -r 7f25ef56562d graphicsutils/commongraphicsheaders/test/group/tcommonheader_helium.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graphicsutils/commongraphicsheaders/test/group/tcommonheader_helium.pkg Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,37 @@ +; Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +; All rights reserved. +; This component and the accompanying materials are made available +; under the terms of "Eclipse Public License v1.0" +; which accompanies this distribution, and is available +; at the URL "http://www.eclipse.org/legal/epl-v10.html". +; +; Initial Contributors: +; Nokia Corporation - initial contribution. +; +; Contributors: +; +; Description: +; +;File: bitgdi.pkg; +; +;*Languages +&EN +; +;*Standard SIS file header. This section specifies the package name, +;application UID, and version/build numbers. Add the package TYPE here if needed. +#{"TCommonHeader"},(0x101FB3E8),1,0,1; +; + +;*Unique (Non-Localized) Vendor name +;This is used in combination with signing to prevent the unauthroized +;upgrade of a a package by someone other than the rightful vendor. +:"Nokia" + +;*Localized Vendor Name +;This specifies the localized vendor name(s) corresponding to language(s). +%{"Nokia Test EN"} + +;*Files To Copy... + +"..\scripts\tdisplayconfiguration.script"-"c:\commonheadertest\tdisplayconfiguration.script" + diff -r bf7481649c98 -r 7f25ef56562d printingservices/printerdriversupport/group/pdrstoretest_helium.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/printingservices/printerdriversupport/group/pdrstoretest_helium.pkg Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,40 @@ +; Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +; All rights reserved. +; This component and the accompanying materials are made available +; under the terms of "Eclipse Public License v1.0" +; which accompanies this distribution, and is available +; at the URL "http://www.eclipse.org/legal/epl-v10.html". +; +; Initial Contributors: +; Nokia Corporation - initial contribution. +; +; Contributors: +; +; Description: +; +;File: bitgdi.pkg; +; +;*Languages +&EN +; +;*Standard SIS file header. This section specifies the package name, +;application UID, and version/build numbers. Add the package TYPE here if needed. +#{"PDrStoreTest"},(0x101FB3E8),1,0,1; +; + +;*Unique (Non-Localized) Vendor name +;This is used in combination with signing to prevent the unauthroized +;upgrade of a a package by someone other than the rightful vendor. +:"Nokia" + +;*Localized Vendor Name +;This specifies the localized vendor name(s) corresponding to language(s). +%{"Nokia Test EN"} + +;*Files To Copy... + +;//script file +"..\tps\scripts\pdrstoretest_T_Pdr.script"-"c:\pdrstoretest\pdrstoretest_T_Pdr.script" +"..\tps\scripts\pdrstoretest_T_PdrLst.script"-"c:\pdrstoretest\pdrstoretest_T_PdrLst.script" +"..\tps\scripts\pdrstoretest_T_PdrMem.script"-"c:\pdrstoretest\pdrstoretest_T_PdrMem.script" + diff -r bf7481649c98 -r 7f25ef56562d printingservices/printerdriversupport/inc/prnpath.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/printingservices/printerdriversupport/inc/prnpath.h Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,30 @@ +// Copyright (c) 1997-2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#ifndef PRNPATH_H +#define PRNPATH_H + +/** +@file +@internalTechnology +@released +*/ + +/* This file is copied from middleware to remove dependency on middleware */ + +_LIT( KDefaultPrinterDriverPath, "\\resource\\printers\\" ); + + +#endif // PRNPATH_H diff -r bf7481649c98 -r 7f25ef56562d printingservices/printerdriversupport/src/PDRBODY.H --- a/printingservices/printerdriversupport/src/PDRBODY.H Fri Jun 11 14:58:47 2010 +0300 +++ b/printingservices/printerdriversupport/src/PDRBODY.H Wed Jun 23 19:41:15 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 1997-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -18,7 +18,7 @@ #include #include -#include +#include /** @internalComponent diff -r bf7481649c98 -r 7f25ef56562d printingservices/printerdriversupport/tps/T_PDR.CPP --- a/printingservices/printerdriversupport/tps/T_PDR.CPP Fri Jun 11 14:58:47 2010 +0300 +++ b/printingservices/printerdriversupport/tps/T_PDR.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -21,6 +21,7 @@ #include "T_PDR.H" #include +#include "prnpath.h" #if defined (__WINS__) @@ -373,10 +374,8 @@ RFs fs; ret=fs.Connect(); TEST(ret==KErrNone); -#if defined(__X86GCC__) _LIT(KPath,"C:\\system\\data\\"); fs.MkDirAll(KPath); -#endif //__X86GCC__ ret=file.Replace(fs,_L("C:\\system\\data\\WIDTHS.TMP"),EFileStream|EFileWrite); if (ret!=KErrNone) { diff -r bf7481649c98 -r 7f25ef56562d printingservices/printerdriversupport/tps/T_PDRLST.CPP --- a/printingservices/printerdriversupport/tps/T_PDRLST.CPP Fri Jun 11 14:58:47 2010 +0300 +++ b/printingservices/printerdriversupport/tps/T_PDRLST.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 1996-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -15,7 +15,7 @@ #include #include "T_PDRLST.H" - +#include "prnpath.h" class CTPdrLst : public CTGraphicsBase { diff -r bf7481649c98 -r 7f25ef56562d printingservices/printerdriversupport/tps/T_PDRMEM.CPP --- a/printingservices/printerdriversupport/tps/T_PDRMEM.CPP Fri Jun 11 14:58:47 2010 +0300 +++ b/printingservices/printerdriversupport/tps/T_PDRMEM.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 1996-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -15,7 +15,7 @@ #include #include "T_PDRMEM.H" - +#include "prnpath.h" _LIT( KDriveName, "z:" ); _LIT( KEpsonFileName, "epson.pdr" ); diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/TClick/CLICK.CPP --- a/windowing/windowserver/TClick/CLICK.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,708 +0,0 @@ -// Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Test Key Click Plug-In DLL -// -// - -#include -#include "W32CLICK.H" -#include "CLICK.H" -#include -#if defined(__WINS__) - #include - #include "LOGWIN.H" -#endif - -#define bufSize 64 - -GLREF_D struct TSharedMemory GSharedMemory; - -class MClickMaker - { -public: - virtual void KeyEvent(TEventCode aType,const TKeyEvent& aEvent)=0; - virtual void PointerEvent(const TPointerEvent& aEvent)=0; - virtual void OtherEvent(TInt aType,TAny* aParam)=0; - }; - -struct TGpWinInfo - { - TBool iInUse; - TInt iServerValue; - TInt iNumGroups; - }; - -struct TGpWinIdData - { - TInt iId; - TInt iClient; - }; - -NONSHARABLE_CLASS(TLogClicks) : public MClickMaker - { -public: - void StartLoggingL(); - inline TBool IsLogging() {return iLogging;} - //Pure virtual functions from MClickMaker - void KeyEvent(TEventCode aType,const TKeyEvent& aEvent); - void PointerEvent(const TPointerEvent& aEvent); - void OtherEvent(TInt aType,TAny* aParam=NULL); -private: - TBool iLogging; - }; - -NONSHARABLE_CLASS(CEventClicks) : public CBase, public MClickMaker - { - enum { - EEventBufferSize=32, - EMaxGroupWinClients=6, - EMaxGroupWinIdData=12 - }; -public: - void ConstructL(); - TInt Add(TWsEvent* aEvent); - inline TInt Failed() {return iFailed;} - inline TInt Events() {return iEventsTested;} - void Reset(); - void ExtendedPointerEvent(const TPointerEventData& aPointerEvent); - void ExpectNewWindowGroup(TInt aClient); - void NewWindowGroup(const TGroupWindowOpenData& aGpWinOpen); - void CheckGpWinId(TInt aId); - void ExpectCloseWindowGroup(TInt aId); - void CloseWindowGroup(TInt aId); - void ExpectCloseWindow(TWindowCloseData& aCloseWin); - void CloseWindow(TWindowCloseData& aCloseWin); - void PointerEventInfo(TPointerEventInfo& aPointerEventInfo); - //Pure virtual functions from MClickMaker - void KeyEvent(TEventCode aType,const TKeyEvent& aEvent); - void PointerEvent(const TPointerEvent& aEvent); - void OtherEvent(TInt aType,TAny* aParam=NULL); -private: - TBool GetEvent(TWsEvent& aEvent); - void Fail(); - void AddGroupWindowId(TInt aClient,TInt aGpWinId); - void RemoveGroupWindowId(TInt aGpWinId); -private: - CCirBuf iEventBuffer; - TInt iFailed; - TInt iEventsTested; - TInt iFailedAt; - TGpWinInfo iGroupWins[EMaxGroupWinClients]; - TGpWinIdData iGroupWinIds[EMaxGroupWinIdData]; - TInt iExpectedEvent; - TInt iExpectedEventData; - TInt iExpectedHandle; - TPointerEventInfo iExpectedPointerEventInfo; - TInt iLastNewGpWinId; - TAdvancedPointerEvent iLastPointerEvent; - TBool iExpectingExtendedPointer; - }; - -NONSHARABLE_CLASS(CMyClickMaker) : public CClickMaker - { -public: - ~CMyClickMaker(); - void ConstructL(); - //Virtual function from CClickMaker - void KeyEvent(TEventCode aType,const TKeyEvent& aEvent); - void PointerEvent(const TPointerEvent& aEvent); - void OtherEvent(TInt aType,TAny* aParam); - TInt CommandReplyL(TInt aOpcode, TAny *aArgs); -private: - void LogToWindowL(); -private: - TClickOutputModes iMode; - MClickMaker* iCurrentClick; - TLogClicks iLogClicks; - CEventClicks* iEventClicks; - }; - - -/*TLogClicks*/ - -void TLogClicks::StartLoggingL() - { -#if defined(__WINS__) - if (!IsLogging()) - { - CreateLogWinThreadL(); - iLogging=ETrue; - } -#else - User::Leave(KErrNotSupported); -#endif - } - -void TLogClicks::KeyEvent(TEventCode aType,const TKeyEvent& aEvent) - { - _LIT(KKeyDown, "KEY DOWN "); - _LIT(KKeyUp, "KEY UP "); - _LIT(KKeyEvent, "KEY EVENT "); - _LIT(KKeyRepeat, "KEY REPEAT "); - _LIT(KKeyUnknown, "KEY Unknown"); - _LIT(KKeyDataFormatChar,"'%c',"); - _LIT(KKeyDataFormatCode," Code=%u,"); - _LIT(KKeyDataFormatScan," Scan=%d,"); - _LIT(KKeyDataFormatModRep," Mod=0x%x, Rep=%d"); - TBuf bufPlusZero; - switch (aType) - { - case EEventKey: - bufPlusZero.Copy(KKeyEvent); - break; - case EEventKeyUp: - bufPlusZero.Copy(KKeyUp); - break; - case EEventKeyDown: - bufPlusZero.Copy(KKeyDown); - break; - case EEventKeyRepeat: - bufPlusZero.Copy(KKeyRepeat); - break; - default: - bufPlusZero.Copy(KKeyUnknown); - break; - } - bufPlusZero.AppendFormat(KKeyDataFormatCode,aEvent.iCode); - if (aEvent.iCode!=0) - bufPlusZero.AppendFormat(KKeyDataFormatChar,aEvent.iCode); - bufPlusZero.AppendFormat(KKeyDataFormatScan,aEvent.iScanCode); - if (aEvent.iScanCode!=0) - bufPlusZero.AppendFormat(KKeyDataFormatChar,aEvent.iScanCode); - bufPlusZero.AppendFormat(KKeyDataFormatModRep,aEvent.iModifiers,aEvent.iRepeats); - bufPlusZero.ZeroTerminate(); -#if defined(__WINS__) - Emulator::Escape(); - SendMessage(GSharedMemory.iHwnd, WM_USER+EAppendText, (bufPlusZero.Length()+1)*sizeof(TText), (TInt32)(bufPlusZero.Ptr())); - Emulator::Reenter(); -#endif - } - -void TLogClicks::PointerEvent(const TPointerEvent& aEvent) - { - _LIT(KButtonDown, "POINTER DOWN "); - _LIT(KButtonUp, "POINTER UP "); - _LIT(KButton2Down, "BUTTON 2 DOWN"); - _LIT(KButton2Up, "BUTTON 2 UP "); - _LIT(KButton3Down, "BUTTON 3 DOWN"); - _LIT(KButton3Up, "BUTTON 3 UP "); - _LIT(KButtonDrag, "POINTER DRAG "); - _LIT(KButtonMove, "POINTER MOVE "); - _LIT(KButtonRepeat, "BUTTON REPEAT"); - _LIT(KSwitchOn, "POINTER ON "); - _LIT(KUnknown, "PTR Unknown "); - //_LIT(KPtrDataFormat," Pos=(%d,%d), ScrPos=(%d,%d), Modifiers=%x"); - _LIT(KPtrDataFormat," Pos=(%d,%d), ScrPos=(%d,%d), Mod=%x"); - TBuf bufPlusZero; - switch (aEvent.iType) - { - case TPointerEvent::EButton1Down: - bufPlusZero.Copy(KButtonDown); - break; - case TPointerEvent::EButton1Up: - bufPlusZero.Copy(KButtonUp); - break; - case TPointerEvent::EButton2Down: - bufPlusZero.Copy(KButton2Down); - break; - case TPointerEvent::EButton2Up: - bufPlusZero.Copy(KButton2Up); - break; - case TPointerEvent::EButton3Down: - bufPlusZero.Copy(KButton3Down); - break; - case TPointerEvent::EButton3Up: - bufPlusZero.Copy(KButton3Up); - break; - case TPointerEvent::EDrag: - bufPlusZero.Copy(KButtonDrag); - break; - case TPointerEvent::EMove: - bufPlusZero.Copy(KButtonMove); - break; - case TPointerEvent::EButtonRepeat: - bufPlusZero.Copy(KButtonRepeat); - break; - case TPointerEvent::ESwitchOn: - bufPlusZero.Copy(KSwitchOn); - break; - default: - bufPlusZero.Copy(KUnknown); - break; - } - bufPlusZero.AppendFormat(KPtrDataFormat,aEvent.iPosition.iX,aEvent.iPosition.iY - ,aEvent.iParentPosition.iX,aEvent.iParentPosition.iY,aEvent.iModifiers); - bufPlusZero.ZeroTerminate(); -#if defined(__WINS__) - Emulator::Escape(); - SendMessage(GSharedMemory.iHwnd, WM_USER+EAppendText, (bufPlusZero.Length()+1)*sizeof(TText), (TInt32)(bufPlusZero.Ptr())); - Emulator::Reenter(); -#endif - } - -void TLogClicks::OtherEvent(TInt aType,TAny* aParam) - { - _LIT(KPointer,"POINTER EVENT Ver=%d, ScrPos=(%d,%d), WinClientHandle=0x%x, WinOrigin=%d, WinGpId=%d"); - _LIT(KScreenDeviceChanged,"SCREEN DEVICE CHANGED EVENT, Mode=%d"); - _LIT(KGroupWindowOpen,"GROUP WINDOW OPEN EVENT WinGpId=%d, Client=%d, NumWinGps=%d"); - _LIT(KGroupWindowClose,"GROUP WINDOW CLOSE EVENT WinGpId=%d"); - _LIT(KWindowClose,"WINDOW CLOSE EVENT Client=%d, WinGpId=%d"); - _LIT(KEventUnknown, "EVENT Unknown"); - TBuf bufPlusZero; - switch (aType) - { - case EEventPointer: - { - TPointerEventData& data=*static_cast(aParam); - bufPlusZero.Format(KPointer,data.iVersion,data.iCurrentPos.iX,data.iCurrentPos.iY,data.iClientHandle - ,data.iWindowOrigin.iX,data.iWindowOrigin.iY,data.iWindowGroupId); - } - break; - case EEventScreenDeviceChanged: - { - TClickMakerData& data=*static_cast(aParam); - bufPlusZero.Format(KScreenDeviceChanged,data.screenDeviceMode); - } - break; - case EEventGroupWindowOpen: - { - TGroupWindowOpenData& data=*static_cast(aParam); - bufPlusZero.Format(KGroupWindowOpen,data.iIdentifier,data.iClient,data.iNumClientWindowGroups); - } - break; - case EEventGroupWindowClose: - bufPlusZero.Format(KGroupWindowClose,reinterpret_cast(aParam)); - break; - case EEventWindowClose: - { - TWindowCloseData& data=*static_cast(aParam); - bufPlusZero.Format(KWindowClose,data.iClientHandle,data.iWindowGroupId); - } - break; - default: - bufPlusZero.Copy(KEventUnknown); - break; - } - bufPlusZero.ZeroTerminate(); -#if defined(__WINS__) - Emulator::Escape(); - SendMessage(GSharedMemory.iHwnd, WM_USER+EAppendText, (bufPlusZero.Length()+1)*sizeof(TText), (TInt32)(bufPlusZero.Ptr())); - Emulator::Reenter(); -#endif - } - -/*CEventClicks*/ - -void CEventClicks::ConstructL() - { - iEventBuffer.SetLengthL(EEventBufferSize); - } - -TInt CEventClicks::Add(TWsEvent* aEvent) - { - return (iEventBuffer.Add(aEvent) ? KErrNone:KErrOverflow); - } - -void CEventClicks::Reset() - { - iFailed=EFalse; - iEventsTested=0; - iExpectedEvent=0; - iLastNewGpWinId=0; - } - -void CEventClicks::ExtendedPointerEvent(const TPointerEventData& aPointerEvent) - { - if (!iExpectingExtendedPointer) - { - Fail(); - return; - } - iExpectingExtendedPointer=EFalse; - TBool match=ETrue; - if (0!=aPointerEvent.iVersion) - match=EFalse; - if (iLastPointerEvent.iType!=aPointerEvent.iPointerEvent.iType) - match=EFalse; - if (iLastPointerEvent.iModifiers!=aPointerEvent.iPointerEvent.iModifiers) - match=EFalse; - if (iLastPointerEvent.iPosition!=aPointerEvent.iPointerEvent.iPosition) - match=EFalse; - if (iLastPointerEvent.iParentPosition!=aPointerEvent.iCurrentPos) - match=EFalse; - if (TPointerEventData::EUnspecified!=aPointerEvent.iSource) - match=EFalse; - if (iExpectedPointerEventInfo.iClientHandle && iExpectedPointerEventInfo.iWinGpId>0) - { - if (iLastPointerEvent.iParentPosition-iExpectedPointerEventInfo.iParentOrigin - !=aPointerEvent.iPointerEvent.iParentPosition) - match=EFalse; - if (iExpectedPointerEventInfo.iParentOrigin+iExpectedPointerEventInfo.iWinOrigin - !=aPointerEvent.iWindowOrigin) - match=EFalse; - if (iExpectedPointerEventInfo.iClientHandle!=aPointerEvent.iClientHandle) - match=EFalse; - if (iExpectedPointerEventInfo.iWinGpId!=aPointerEvent.iWindowGroupId) - match=EFalse; - } - if (!match) - Fail(); - } - -void CEventClicks::ExpectNewWindowGroup(TInt aClient) - { - if (iExpectedEvent>0) - Fail(); - iExpectedEvent=EEventGroupWindowOpen; - iExpectedEventData=aClient; - } - -void CEventClicks::NewWindowGroup(const TGroupWindowOpenData& aGpWinOpen) - { - iLastNewGpWinId=aGpWinOpen.iIdentifier; - if (iExpectedEvent!=EEventGroupWindowOpen) - { - Fail(); - return; - } - iExpectedEvent=0; - if (iExpectedEventData>=EMaxGroupWinClients) - return; - AddGroupWindowId(iExpectedEventData,iLastNewGpWinId); - TGpWinInfo& gpWinInfo=iGroupWins[iExpectedEventData]; - if (gpWinInfo.iInUse) - { - if (aGpWinOpen.iClient!=gpWinInfo.iServerValue) - Fail(); - else - { - if (aGpWinOpen.iNumClientWindowGroups!=gpWinInfo.iNumGroups) - Fail(); - ++gpWinInfo.iNumGroups; - } - } - else - { - gpWinInfo.iInUse=ETrue; - gpWinInfo.iServerValue=aGpWinOpen.iClient; - gpWinInfo.iNumGroups=aGpWinOpen.iNumClientWindowGroups+1; - } - } - -void CEventClicks::CheckGpWinId(TInt aId) - { - if (iLastNewGpWinId!=aId) - Fail(); - } - -void CEventClicks::ExpectCloseWindowGroup(TInt aId) - { - if (iExpectedEvent>0) - Fail(); - iExpectedEvent=EEventGroupWindowClose; - iExpectedEventData=aId; - } - -void CEventClicks::CloseWindowGroup(TInt aId) - { - if (iExpectedEvent!=EEventGroupWindowClose || iExpectedEventData!=aId) - Fail(); - if (iExpectedEvent==EEventGroupWindowClose) - iExpectedEvent=0; - RemoveGroupWindowId(aId); - } - -void CEventClicks::ExpectCloseWindow(TWindowCloseData& aCloseWin) - { - if (iExpectedEvent>0) - Fail(); - iExpectedEvent=EEventWindowClose; - iExpectedEventData=aCloseWin.iWindowGroupId; - iExpectedHandle=aCloseWin.iClientHandle; - } - -void CEventClicks::CloseWindow(TWindowCloseData& aCloseWin) - { - if (iExpectedEvent!=EEventWindowClose || iExpectedEventData!=aCloseWin.iWindowGroupId || iExpectedHandle!=aCloseWin.iClientHandle) - Fail(); - if (iExpectedEvent==EEventWindowClose) - iExpectedEvent=0; - } - -void CEventClicks::PointerEventInfo(TPointerEventInfo& aPointerEventInfo) - { - iExpectedPointerEventInfo=aPointerEventInfo; - } - -TBool CEventClicks::GetEvent(TWsEvent& aEvent) - { - ++iEventsTested; - if (iEventBuffer.Remove(&aEvent)<1) - { - Fail(); - return ETrue; - } - return EFalse; - } - -void CEventClicks::Fail() - { - if (!iFailed) - { - iFailed=iEventsTested; - } - } - -void CEventClicks::AddGroupWindowId(TInt aClient,TInt aGpWinId) - { - TInt ii=0; - while (ii0) - ++ii; - if (ii0); - eType=EEventKey; - break; - default: - pass=EFalse; - } - if (!pass) - { - Fail(); - return; - } - TWsEvent eEvent; - if (GetEvent(eEvent)) - return; - if (eEvent.Type()!=eType) - { - Fail(); - return; - } - TKeyEvent keyEvent=*eEvent.Key(); - TUint mask=~(EModifierAutorepeatable|MODIFIER_FLAGS_TO_IGNOR); - if (keyEvent.iCode!=aEvent.iCode || (keyEvent.iModifiers&mask)!=(aEvent.iModifiers&mask) || keyEvent.iScanCode!=aEvent.iScanCode - || (keyEvent.iRepeats==0)!=(aEvent.iRepeats==0)) - { - Fail(); - return; - } - } - -void CEventClicks::PointerEvent(const TPointerEvent& aEvent) - { - // Click events are now all advanced events so in order to test the modifier bits - // appropriately we need to copy them as TAdvancedPointerEvent not TPointerEvent - if(!aEvent.IsAdvancedPointerEvent()) - { - Fail(); - return; - } - iLastPointerEvent=*aEvent.AdvancedPointerEvent(); - - if (iExpectingExtendedPointer) - Fail(); - else - iExpectingExtendedPointer=ETrue; - TWsEvent eEvent; - if (GetEvent(eEvent)) - return; - TAdvancedPointerEvent pEvent=*eEvent.Pointer(); - TUint mask=~(MODIFIER_FLAGS_TO_IGNOR); - if (pEvent.iType!=aEvent.iType || (pEvent.iModifiers&mask)!=(aEvent.iModifiers&mask) - || pEvent.iPosition!=aEvent.iPosition || pEvent.iParentPosition!=aEvent.iParentPosition) - { - Fail(); - return; - } - } - -void CEventClicks::OtherEvent(TInt aType,TAny* aParam) - { - TBool pass=ETrue; - if (aType!=EEventPointer) - ++iEventsTested; - switch (aType) - { - case EEventPointer: - ExtendedPointerEvent(*static_cast(aParam)); - break; - case EEventScreenDeviceChanged: - break; - case EEventGroupWindowOpen: - NewWindowGroup(*static_cast(aParam)); - break; - case EEventGroupWindowClose: - CloseWindowGroup(reinterpret_cast(aParam)); - break; - case EEventWindowClose: - CloseWindow(*static_cast(aParam)); - break; - default: - pass=EFalse; - } - if (!pass) - Fail(); - //GetEvent() is not call here because CWsGroupWindow::EnableScreenChangeEvents() could not be - //been called.This mean that no EEventScreenDeviceChanged will be put in the client queue. - //Instead this event will be always passed to the click plugin if this is present. - } -#pragma warning(default : 4245) - - -/*CMyClickMaker*/ - -CMyClickMaker::~CMyClickMaker() - { - delete iEventClicks; - } - -void CMyClickMaker::ConstructL() - { - iMode=EClickNone; - iEventClicks=new(ELeave) CEventClicks(); - iEventClicks->ConstructL(); - } - -void CMyClickMaker::KeyEvent(TEventCode aType,const TKeyEvent& aEvent) - { - if (iCurrentClick) - iCurrentClick->KeyEvent(aType,aEvent); - } - -void CMyClickMaker::PointerEvent(const TPointerEvent& aEvent) - { - if (iCurrentClick) - iCurrentClick->PointerEvent(aEvent); - } - -void CMyClickMaker::OtherEvent(TInt aType,TAny* aParam) - { - if (iCurrentClick) - iCurrentClick->OtherEvent(aType,aParam); - } - -TInt CMyClickMaker::CommandReplyL(TInt aOpcode,TAny* aArgs) - { - switch (aOpcode) - { - case EClickCommandToggleOutput: - switch (iMode) - { - case EClickNone: - LogToWindowL(); - break; - case EClickCheck: - case EClickToWindow: - iMode=EClickNone; - iCurrentClick=NULL; - break; - } - break; - case EClickCommandSetOutput: - iMode=*STATIC_CAST(TClickOutputModes*,aArgs); - switch (iMode) - { - case EClickNone: - iCurrentClick=NULL; - break; - case EClickCheck: - iCurrentClick=iEventClicks; - iEventClicks->Reset(); - break; - case EClickToWindow: - LogToWindowL(); - break; - } - break; - case EClickEventAdd: - return iEventClicks->Add(STATIC_CAST(TWsEvent*,aArgs)); - case EClickFailed: - return iEventClicks->Failed(); - case EClickEvents: - return iEventClicks->Events(); - case EClickReset: - iEventClicks->Reset(); - break; - case EClickCreateGroupWin: - iEventClicks->ExpectNewWindowGroup(*static_cast(aArgs)); - break; - case EClickCheckGpWinId: - iEventClicks->CheckGpWinId(*static_cast(aArgs)); - break; - case EClickCloseGroupWin: - iEventClicks->ExpectCloseWindowGroup(*static_cast(aArgs)); - break; - case EClickCloseWin: - iEventClicks->ExpectCloseWindow(*static_cast(aArgs)); - break; - case EClickPointerEvent: - iEventClicks->PointerEventInfo(*static_cast(aArgs)); - break; - default:; - } - return KErrNone; - } - -void CMyClickMaker::LogToWindowL() - { - iMode=EClickNone; - iCurrentClick=NULL; - iLogClicks.StartLoggingL(); - iMode=EClickToWindow; - iCurrentClick=&iLogClicks; - } - - -EXPORT_C CClickMaker* CreateClickMakerL() - { - CMyClickMaker* plugIn=new(ELeave) CMyClickMaker; - CleanupStack::PushL(plugIn); - plugIn->ConstructL(); - CleanupStack::Pop(plugIn); - return plugIn; - } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/TClick/CLICK.H --- a/windowing/windowserver/TClick/CLICK.H Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,57 +0,0 @@ -// Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Client interface to the click plugin. -// -// - -#ifndef __CLICK_H__ -#define __CLICK_H__ - -#define CLICK_THIRD_UID 268455780 - -enum TClickOutputModes - { - EClickNone, - EClickCheck, - EClickToWindow, //For WINS only - }; - -enum TClickCommands - { - // Control Between Plug-in Types - EClickCommandToggleOutput=1, - EClickCommandSetOutput, - // Key and Pointer Testing - EClickEventAdd=100, - EClickFailed, - EClickEvents, - EClickReset, - // Other Event Testing - EClickCreateGroupWin=200, - EClickCheckGpWinId, - EClickCloseGroupWin, - EClickCloseWin, - EClickPointerEvent, - }; - -class TPointerEventInfo - { -public: - TInt iClientHandle; - TInt iWinGpId; - TPoint iWinOrigin; //Relative to parent - TPoint iParentOrigin; //Relative to screen - }; - -#endif //__CLICK_H__ diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/TClick/LOGWIN.CPP --- a/windowing/windowserver/TClick/LOGWIN.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,304 +0,0 @@ -// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Extracted from DEBLOGWN.CPP -// Code to run the WIN32 windows with the output -// -// - -#include -#include -#include -#include "LOGWIN.H" - -GLDEF_D struct TSharedMemory GSharedMemory; -//GLDEF_D struct HWND__ *Hwnd; -//LOCAL_D RSemaphore Sem; - -const TUint KHeapSize=0x8000; - - -TInt numLines(const CArrayVarSeg &aTextArray, TBool aOutOfMemory) - { - return (TInt)(aOutOfMemory)? - aTextArray.Count(): - aTextArray.Count()-1; - } - -TInt numVisibleLines(TInt aHeight, TInt aTextHeight) - { - return aHeight/aTextHeight; - } - -TInt32 __stdcall WndProc(struct HWND__ *aHwnd, TUint aMessage, TUint wParam, TInt32 lParam) - { - HDC hdc; - PAINTSTRUCT ps; - HFONT hfont; - RECT rect; - TInt i, - paintMin, - paintMax; - static LOGFONT logFont; - static TEXTMETRIC tm; - static TInt textHeight, - width, - height, - scrollMin=0, - scrollMax, - numLinesAbove=scrollMin, - prevNumLinesAbove; - static CArrayVarSeg *pmsg; - static TBool outOfMemory=EFalse; - - switch (aMessage) - { - case WM_CREATE: - hdc=GetDC(aHwnd); - - pmsg=new(ELeave) CArrayVarSeg(20); - { - TBuf<0x20> errorMsg; - errorMsg=_L("ERROR: out of memory"); - errorMsg.ZeroTerminate(); - TRAPD(err,pmsg->AppendL(*errorMsg.Ptr(), (errorMsg.Length()+1)*sizeof(TText))); - if (err!=KErrNone) - return(err); - } - GetTextMetrics(hdc, &tm); - textHeight=tm.tmHeight+tm.tmExternalLeading; - GetClientRect(aHwnd, &rect); - width=rect.right; - height=rect.bottom; - scrollMax=numLines(*pmsg, outOfMemory); - SetScrollPos(aHwnd, SB_VERT, numLinesAbove, TRUE); - SetScrollRange(aHwnd, SB_VERT, scrollMin, scrollMax, FALSE); - logFont.lfHeight=8; - wsprintf(logFont.lfFaceName, (LPCTSTR)_S("courier")); - - ReleaseDC(aHwnd, hdc); - return 0; - case WM_USER+EAppendText: - { - TRAPD(err,pmsg->InsertL(pmsg->Count()-1, *(TText *)lParam, wParam)); - if (err!=KErrNone) - { - pmsg->Delete(0, Max(0, (TInt)pmsg->Count()-1)); - numLinesAbove=scrollMax=scrollMin; - SetScrollPos(aHwnd, SB_VERT, numLinesAbove, TRUE); - SetScrollRange(aHwnd, SB_VERT, scrollMin, scrollMax, FALSE); - hdc=GetDC(aHwnd); - PatBlt(hdc, 0, 0, width, height, WHITENESS); - ReleaseDC(aHwnd, hdc); - return(err); - } - // adjust the scroll position so that the last line added is visible - if (numLinesAboveprevNumLinesAbove) - // scrolling towards end, therefore text moves up on screen - { - TInt numLinesToDraw=numLinesAbove-prevNumLinesAbove; - TInt numLinesToBlt=numVisibleLines(height, textHeight)-numLinesToDraw; - if (numLinesToBlt>0) - ScrollWindow(aHwnd, 0, -numLinesToDraw*textHeight, NULL, NULL); - PatBlt(hdc, 0, numLinesToBlt*textHeight, width, numLinesToDraw*textHeight, WHITENESS); - paintMin=Max(Min(numLinesAbove+numLinesToBlt, scrollMax), scrollMin); - paintMax=Min(paintMin+numLinesToDraw, scrollMax); - for (i=paintMin; i0) - ScrollWindow(aHwnd, 0, numLinesToDraw*textHeight, NULL, NULL); - PatBlt(hdc, 0, 0, width, numLinesToDraw*textHeight, WHITENESS); - paintMin=Max(Min(numLinesAbove, scrollMax), scrollMin); - paintMax=Min(paintMin+numLinesToDraw, scrollMax); - for (i=paintMin; i - -GLREF_C void CreateLogWinThreadL(); - -//GLREF_D struct HWND__ *Hwnd; -// static container for sharing data between Symbian & Windows threads -struct TSharedMemory - { - RSemaphore iStartSemaphore; - struct HWND__* iHwnd; - }; - -enum TWindowsUserMessage - { - EAppendText, - EScrollToPos - }; diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/TClick/multiptrclick.cpp --- a/windowing/windowserver/TClick/multiptrclick.cpp Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,246 +0,0 @@ -// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Test Multi Pointer Click Plug-In DLL -// -// - -#include -#include "W32CLICK.H" -#include "multiptrclick.h" - -class CMultiPtrClickMaker : public CClickMaker - { - enum {EEventBufferSize=32}; -public: - ~CMultiPtrClickMaker(); - void ConstructL(); - //Virtual function from CClickMaker - void KeyEvent(TEventCode aType, const TKeyEvent& aEvent); - void PointerEvent(const TPointerEvent& aEvent); - void OtherEvent(TInt aType, TAny* aParam); - TInt CommandReplyL(TInt aOpcode, TAny *aArgs); - -private: - TInt AddEvent(const TWsEvent* aEvent); - TInt AddEvent(const TPointerEventData* aEvent); - TBool ComparePointerEvents(const TPointerEvent* aExpectedEvent, const TPointerEvent* aActualEvent); - TBool CompareOtherEvents(const TPointerEventData* aExpectedEvent, const TPointerEventData* aActualEvent); -private: - CCirBuf iPtrEventBuffer; - CCirBuf iOtherEventBuffer; - TBuf<255> iErrorDes; - TInt iPtrEventCount; - TInt iOtherEventCount; - TInt iError; - }; - - -void CMultiPtrClickMaker::ConstructL() - { - iPtrEventBuffer.SetLengthL(EEventBufferSize); - iOtherEventBuffer.SetLengthL(EEventBufferSize); - } - -CMultiPtrClickMaker::~CMultiPtrClickMaker() - { - } - -void CMultiPtrClickMaker::KeyEvent(TEventCode /*aType*/,const TKeyEvent& /*aEvent*/) - { - } - -TBool CMultiPtrClickMaker::ComparePointerEvents(const TPointerEvent* aExpectedEvent, const TPointerEvent* aActualEvent) - { - // Check pointer type - if (aExpectedEvent->iType != aActualEvent->iType) - { - _LIT(KEventType, "Actual Wserv Event type = %d Expected Wserv Event Type = %d "); - iErrorDes.Format(KEventType, aActualEvent->iType, aExpectedEvent->iType); - return EFalse; - } - - if (aExpectedEvent->iPosition != aActualEvent->iPosition) - { - _LIT(KPointerPosition, "Actual PointerPosition = (%d, %d) Expected PointerPosition = (%d, %d) "); - iErrorDes.Format(KPointerPosition, aActualEvent->iPosition.iX, aActualEvent->iPosition.iY, aExpectedEvent->iPosition.iX, aExpectedEvent->iPosition.iY); - return EFalse; - } - - if (aExpectedEvent->iParentPosition != aActualEvent->iParentPosition) - { - _LIT(KPointerPosition, "Actual parent Position = (%d, %d) Expected parent Position = (%d, %d) "); - iErrorDes.Format(KPointerPosition, aActualEvent->iParentPosition.iX, aActualEvent->iParentPosition.iY, aExpectedEvent->iParentPosition.iX, aExpectedEvent->iParentPosition.iY); - return EFalse; - } - - if (aExpectedEvent->IsAdvancedPointerEvent() != aActualEvent->IsAdvancedPointerEvent()) - { - _LIT(KPointerPosition, "Actual event is TAdvancedPointerEvent = %d Expected event is TAdvancedPointerEvent = %d "); - iErrorDes.Format(KPointerPosition, aActualEvent->IsAdvancedPointerEvent(), aExpectedEvent->IsAdvancedPointerEvent()); - return EFalse; - } - - if (aExpectedEvent->IsAdvancedPointerEvent()) - { - const TAdvancedPointerEvent& expectedAdvancedEvent = *aExpectedEvent->AdvancedPointerEvent(); - const TAdvancedPointerEvent& actualAdvancedEvent = *aActualEvent->AdvancedPointerEvent(); - - if (expectedAdvancedEvent.PointerNumber() != actualAdvancedEvent.PointerNumber()) - { - _LIT(KPointerNumber, "Actual PointerNumber = %d Expected PointerNumber = %d "); - iErrorDes.Format(KPointerNumber, actualAdvancedEvent.PointerNumber(), expectedAdvancedEvent.PointerNumber()); - return EFalse; - } - - if (expectedAdvancedEvent.Pressure() != actualAdvancedEvent.Pressure()) - { - _LIT(KPointerPressure, "Actual Pressure = %d Expected Pressure = %d "); - iErrorDes.Format(KPointerPressure, actualAdvancedEvent.Pressure(), expectedAdvancedEvent.Pressure()); - return EFalse; - } - - if (expectedAdvancedEvent.Proximity() != actualAdvancedEvent.Proximity()) - { - _LIT(KPointerProximity, "Actual Proximity = %d Expected Proximity = %d "); - iErrorDes.Format(KPointerProximity, actualAdvancedEvent.Proximity(), expectedAdvancedEvent.Proximity()); - return EFalse; - } - } - - return ETrue; - } - -// -void CMultiPtrClickMaker::PointerEvent(const TPointerEvent& aEvent) - { - // If it has already failed then do not test other events - // becasue the error value and its descriptor will be over written - if (iError) - { - return; - } - - // Get pointer event from buffer - TWsEvent expectedEvent; - iPtrEventBuffer.Remove(&expectedEvent); - - // Increment event count - iPtrEventCount++; - - // increment this counter in OtherEvent() becasue first pointer event iscalled and then OtherEvent() is called - if (!ComparePointerEvents(expectedEvent.Pointer(), &aEvent)) - { - iError = iPtrEventCount; - } - } - -TBool CMultiPtrClickMaker::CompareOtherEvents(const TPointerEventData* aExpectedEvent, const TPointerEventData* aActualEvent) - { - if (aExpectedEvent->iCurrentPos != aActualEvent->iCurrentPos) - { - _LIT(KCurrentPosition, "Actual CurrentPosition w.r.t screen = (%d,%d) Expected CurrentPosition w.r.t screen = (%d,%d)"); - iErrorDes.Copy(KCurrentPosition); - iErrorDes.Format(KCurrentPosition, aActualEvent->iCurrentPos.iX, aActualEvent->iCurrentPos.iX, aExpectedEvent->iCurrentPos.iX, aExpectedEvent->iCurrentPos.iY); - return EFalse; - } - - if (aExpectedEvent->iClientHandle != aActualEvent->iClientHandle) - { - _LIT(KWindowHandle, "Actual Window Handle = %d Expected Window Handle = %d "); - iErrorDes.Copy(KWindowHandle); - iErrorDes.Format(KWindowHandle, aActualEvent->iClientHandle, aExpectedEvent->iClientHandle); - return EFalse; - } - - return ComparePointerEvents(&aExpectedEvent->iPointerEvent, &aActualEvent->iPointerEvent); - } - -void CMultiPtrClickMaker::OtherEvent(TInt aType, TAny* aParam) - { - if (aType != EEventPointer) - { - return; - } - - if (iError) - { - return; - } - - TPointerEventData expectedEvent; - iOtherEventBuffer.Remove(&expectedEvent); - - iOtherEventCount++; - - TPointerEventData* data=static_cast(aParam); - - if (!CompareOtherEvents(&expectedEvent, data)) - { - iError = iPtrEventCount; - } - } - -TInt CMultiPtrClickMaker::AddEvent(const TWsEvent* aEvent) - { - return iPtrEventBuffer.Add(aEvent); - } - -TInt CMultiPtrClickMaker::AddEvent(const TPointerEventData* aEvent) - { - return iOtherEventBuffer.Add(aEvent); - } - -TInt CMultiPtrClickMaker::CommandReplyL(TInt aOpcode, TAny *aArgs) - { - TMultiPtrClickArgUnion pData; - pData.any=aArgs; - switch (aOpcode) - { - case EMultiPtrClickEventAdd: - return AddEvent(pData.WsEvent); - case EMultiPtrOtherEventAdd: - return AddEvent(pData.OtherEvent); - case EMultiPtrClickEventError: - return iError; - case EMultiPtrClickEventErrorDesc: - if (iError != KErrNone) - { - RChunk chunk; - chunk.OpenGlobal(KMultiPtrClickChunk, ETrue); - TUint8* desPtr = chunk.Base() + *(static_cast(aArgs)); - TPtr8 ptrDes(desPtr, iErrorDes.Length(), iErrorDes.Length()); - ptrDes.Copy(iErrorDes); - chunk.Close(); - return iErrorDes.Length(); - // returns the error description which gets displayed in logs if test failed - } - break; - case EMultiPtrClickEventReset: - iPtrEventBuffer.Reset(); - iError = 0; - iPtrEventCount = 0; - break; - default:; - } - return(KErrNone); - } - -EXPORT_C CClickMaker* CreateMultiPtrClickMakerL() - { - CMultiPtrClickMaker* plugIn=new(ELeave) CMultiPtrClickMaker; - CleanupStack::PushL(plugIn); - plugIn->ConstructL(); - CleanupStack::Pop(plugIn); - return plugIn; - } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/TClick/multiptrclick.h --- a/windowing/windowserver/TClick/multiptrclick.h Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,47 +0,0 @@ -// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Client interface to the pointer click plugin. -// -// - -#ifndef __MULTIPTRCLICK_H__ -#define __MULTIPTRCLICK_H__ - -#ifndef __W32CLICK_H__ -#include -#endif - -#include - -#define MULTIPTR_CLICK_THIRD_UID 268455781 - -_LIT(KMultiPtrClickChunk, "PointerClickChunk"); - -enum TMultiPtrClickCommands - { - EMultiPtrClickEventAdd, - EMultiPtrClickEventError, - EMultiPtrClickEventErrorDesc, - EMultiPtrClickEventReset, - EMultiPtrOtherEventAdd, - }; - -union TMultiPtrClickArgUnion - { - const TAny* any; - const TWsEvent* WsEvent; - const TPointerEventData* OtherEvent; - }; - -#endif //__MULTIPTRCLICK_H__ diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/group/ANIM.MMP --- a/windowing/windowserver/group/ANIM.MMP Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/group/ANIM.MMP Wed Jun 23 19:41:15 2010 +0300 @@ -18,7 +18,7 @@ TARGET tanim.exe TARGETTYPE EXE -SOURCEPATH ../tanim +SOURCEPATH ../test/tanim SOURCE ANIM.CPP OS_LAYER_SYSTEMINCLUDE_SYMBIAN diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/group/ANIMDLL.MMP --- a/windowing/windowserver/group/ANIMDLL.MMP Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/group/ANIMDLL.MMP Wed Jun 23 19:41:15 2010 +0300 @@ -20,10 +20,10 @@ CAPABILITY PowerMgmt ReadDeviceData WriteDeviceData ProtServ -SOURCEPATH ../tanim +SOURCEPATH ../test/tanim SOURCE TANIMDLL.CPP -USERINCLUDE ../inc +USERINCLUDE ../test/inc OS_LAYER_SYSTEMINCLUDE_SYMBIAN LIBRARY euser.lib fbscli.lib gdi.lib diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/group/AUTODLL_nga.MMP --- a/windowing/windowserver/group/AUTODLL_nga.MMP Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/group/AUTODLL_nga.MMP Wed Jun 23 19:41:15 2010 +0300 @@ -23,7 +23,7 @@ CAPABILITY PowerMgmt ReadDeviceData WriteDeviceData ProtServ -SOURCEPATH ../tauto +SOURCEPATH ../test/tauto SOURCE AUTODLL.CPP TAnimdraw.cpp USERINCLUDE ../inc diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/group/AUTODLL_nonnga.MMP --- a/windowing/windowserver/group/AUTODLL_nonnga.MMP Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/group/AUTODLL_nonnga.MMP Wed Jun 23 19:41:15 2010 +0300 @@ -21,7 +21,7 @@ CAPABILITY PowerMgmt ReadDeviceData WriteDeviceData ProtServ -SOURCEPATH ../tauto +SOURCEPATH ../test/tauto SOURCE AUTODLL.CPP TAnimdraw.cpp USERINCLUDE ../inc diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/group/Click.MMP --- a/windowing/windowserver/group/Click.MMP Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/group/Click.MMP Wed Jun 23 19:41:15 2010 +0300 @@ -17,7 +17,7 @@ CAPABILITY PowerMgmt ReadDeviceData WriteDeviceData ProtServ TARGETTYPE DLL -SOURCEPATH ../TClick +SOURCEPATH ../test/TClick SOURCE CLICK.CPP #if defined(WINS) SOURCE LOGWIN.CPP diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/group/INC113743.MMP --- a/windowing/windowserver/group/INC113743.MMP Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/group/INC113743.MMP Wed Jun 23 19:41:15 2010 +0300 @@ -22,7 +22,7 @@ TARGET inc113743.exe TARGETTYPE exe -SOURCEPATH ../tauto +SOURCEPATH ../test/tauto SOURCE topaquechild.cpp OS_LAYER_SYSTEMINCLUDE_SYMBIAN diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/group/TCAP1.MMP --- a/windowing/windowserver/group/TCAP1.MMP Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/group/TCAP1.MMP Wed Jun 23 19:41:15 2010 +0300 @@ -17,7 +17,7 @@ CAPABILITY WriteDeviceData SwEvent TARGETTYPE EXE -SOURCEPATH ../tcapability +SOURCEPATH ../test/tcapability SOURCE TCapTest.CPP OS_LAYER_SYSTEMINCLUDE diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/group/TCAP2.MMP --- a/windowing/windowserver/group/TCAP2.MMP Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/group/TCAP2.MMP Wed Jun 23 19:41:15 2010 +0300 @@ -17,7 +17,7 @@ CAPABILITY PowerMgmt WriteDeviceData TARGETTYPE EXE -SOURCEPATH ../tcapability +SOURCEPATH ../test/tcapability SOURCE TCapTest.CPP OS_LAYER_SYSTEMINCLUDE diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/group/TCAP3.MMP --- a/windowing/windowserver/group/TCAP3.MMP Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/group/TCAP3.MMP Wed Jun 23 19:41:15 2010 +0300 @@ -17,7 +17,7 @@ CAPABILITY PowerMgmt SwEvent TARGETTYPE EXE -SOURCEPATH ../tcapability +SOURCEPATH ../test/tcapability SOURCE TCapTest.CPP OS_LAYER_SYSTEMINCLUDE diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/group/TCAP_ALL.MMP --- a/windowing/windowserver/group/TCAP_ALL.MMP Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/group/TCAP_ALL.MMP Wed Jun 23 19:41:15 2010 +0300 @@ -17,7 +17,7 @@ CAPABILITY PowerMgmt WriteDeviceData SwEvent TARGETTYPE EXE -SOURCEPATH ../tcapability +SOURCEPATH ../test/tcapability SOURCE TCapTest.CPP OS_LAYER_SYSTEMINCLUDE diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/group/TCAP_NONE.MMP --- a/windowing/windowserver/group/TCAP_NONE.MMP Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/group/TCAP_NONE.MMP Wed Jun 23 19:41:15 2010 +0300 @@ -18,7 +18,7 @@ TARGET tcap_none.exe TARGETTYPE EXE -SOURCEPATH ../tcapability +SOURCEPATH ../test/tcapability SOURCE TCapTest.CPP OS_LAYER_SYSTEMINCLUDE diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/group/TLIB.MMP --- a/windowing/windowserver/group/TLIB.MMP Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/group/TLIB.MMP Wed Jun 23 19:41:15 2010 +0300 @@ -20,7 +20,7 @@ CAPABILITY PowerMgmt WriteDeviceData SwEvent ProtServ -SOURCEPATH ../tlib +SOURCEPATH ../test/tlib SOURCE TESTBASE.CPP TLDIALOG.CPP TLEVENT.CPP TLSPRITE.CPP OS_LAYER_SYSTEMINCLUDE_SYMBIAN diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/group/TMAN.MMP --- a/windowing/windowserver/group/TMAN.MMP Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/group/TMAN.MMP Wed Jun 23 19:41:15 2010 +0300 @@ -18,7 +18,7 @@ TARGET tman.exe TARGETTYPE EXE -SOURCEPATH ../tman +SOURCEPATH ../test/tman SOURCE DUMMYM.CPP HOTKEY2.CPP MULTICON.CPP SCALE.CPP SOURCE TKREPEAT.CPP TMAN.CPP TMCAPKEY.CPP TMMODCHG.CPP diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/group/TTIMERS.MMP --- a/windowing/windowserver/group/TTIMERS.MMP Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/group/TTIMERS.MMP Wed Jun 23 19:41:15 2010 +0300 @@ -18,7 +18,7 @@ TARGET ttimers.exe TARGETTYPE EXE -SOURCEPATH ../ttime +SOURCEPATH ../test/ttime SOURCE TTGENRAL.CPP TTGRAPH.CPP TTIME.CPP TTMOVWIN.CPP TTTEXT.CPP OS_LAYER_SYSTEMINCLUDE_SYMBIAN diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/group/TWSGRAPHIC.MMP --- a/windowing/windowserver/group/TWSGRAPHIC.MMP Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/group/TWSGRAPHIC.MMP Wed Jun 23 19:41:15 2010 +0300 @@ -21,11 +21,11 @@ UID 0x00000000 0x10003a3e VENDORID 0x70000001 -SOURCEPATH ../twsgraphic +SOURCEPATH ../test/twsgraphic SOURCE TWsGraphicTest.CPP -USERINCLUDE ../inc ../tlib ../tauto -MW_LAYER_SYSTEMINCLUDE_SYMBIAN +USERINCLUDE ../inc ../test/tlib ../test/tauto +OS_LAYER_SYSTEMINCLUDE LIBRARY euser.lib ws32.lib gdi.lib efsrv.lib diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/group/TWSGRAPHICSHARE.MMP --- a/windowing/windowserver/group/TWSGRAPHICSHARE.MMP Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/group/TWSGRAPHICSHARE.MMP Wed Jun 23 19:41:15 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -19,12 +19,11 @@ UID 0x00000000 0x10003a3f VENDORID 0x70000001 -SOURCEPATH ../twsgraphic +SOURCEPATH ../test/twsgraphic SOURCE TWsGraphicShareTest.CPP -USERINCLUDE ../inc ../tauto -MW_LAYER_SYSTEMINCLUDE_SYMBIAN -OS_LAYER_SYSTEMINCLUDE_SYMBIAN +USERINCLUDE ../inc ../test/tauto +OS_LAYER_SYSTEMINCLUDE LIBRARY euser.lib ws32.lib gdi.lib efsrv.lib LIBRARY w32stdgraphic.lib fbscli.lib tlib.lib diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/group/TWSGRAPHICSHAREGLOBAL.MMP --- a/windowing/windowserver/group/TWSGRAPHICSHAREGLOBAL.MMP Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/group/TWSGRAPHICSHAREGLOBAL.MMP Wed Jun 23 19:41:15 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -19,12 +19,11 @@ UID 0x00000000 0x10003a4a VENDORID 0x70000001 -SOURCEPATH ../twsgraphic +SOURCEPATH ../test/twsgraphic SOURCE TWsGraphicShareTest.CPP -USERINCLUDE ../inc ../tauto -MW_LAYER_SYSTEMINCLUDE_SYMBIAN -OS_LAYER_SYSTEMINCLUDE_SYMBIAN +USERINCLUDE ../inc ../test/tauto +OS_LAYER_SYSTEMINCLUDE LIBRARY euser.lib ws32.lib gdi.lib efsrv.lib LIBRARY w32stdgraphic.lib fbscli.lib tlib.lib diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/group/TWSGRAPHICSHARESECURE.MMP --- a/windowing/windowserver/group/TWSGRAPHICSHARESECURE.MMP Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/group/TWSGRAPHICSHARESECURE.MMP Wed Jun 23 19:41:15 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -19,12 +19,11 @@ UID 0x00000000 0x10003a4b VENDORID 0x70000001 -SOURCEPATH ../twsgraphic +SOURCEPATH ../test/twsgraphic SOURCE TWsGraphicShareTest.CPP -USERINCLUDE ../inc ../tauto -MW_LAYER_SYSTEMINCLUDE_SYMBIAN -OS_LAYER_SYSTEMINCLUDE_SYMBIAN +USERINCLUDE ../inc ../test/tauto +OS_LAYER_SYSTEMINCLUDE LIBRARY euser.lib ws32.lib gdi.lib efsrv.lib LIBRARY w32stdgraphic.lib fbscli.lib tlib.lib diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/group/TWSGRAPHICUNSHAREGLOBAL.MMP --- a/windowing/windowserver/group/TWSGRAPHICUNSHAREGLOBAL.MMP Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/group/TWSGRAPHICUNSHAREGLOBAL.MMP Wed Jun 23 19:41:15 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -19,12 +19,11 @@ UID 0x00000000 0x10003a4c VENDORID 0x70000001 -SOURCEPATH ../twsgraphic +SOURCEPATH ../test/twsgraphic SOURCE TWsGraphicShareTest.CPP -USERINCLUDE ../inc ../tauto -MW_LAYER_SYSTEMINCLUDE_SYMBIAN -OS_LAYER_SYSTEMINCLUDE_SYMBIAN +USERINCLUDE ../inc ../test/tauto +OS_LAYER_SYSTEMINCLUDE LIBRARY euser.lib ws32.lib gdi.lib efsrv.lib LIBRARY w32stdgraphic.lib fbscli.lib tlib.lib diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/group/TWSGRAPHICUNSHARESECURE.MMP --- a/windowing/windowserver/group/TWSGRAPHICUNSHARESECURE.MMP Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/group/TWSGRAPHICUNSHARESECURE.MMP Wed Jun 23 19:41:15 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -19,12 +19,11 @@ UID 0x00000000 0x10003a4b VENDORID 0x70000001 -SOURCEPATH ../twsgraphic +SOURCEPATH ../test/twsgraphic SOURCE TWsGraphicShareTest.CPP -USERINCLUDE ../inc ../tauto -MW_LAYER_SYSTEMINCLUDE_SYMBIAN -OS_LAYER_SYSTEMINCLUDE_SYMBIAN +USERINCLUDE ../inc ../test/tauto +OS_LAYER_SYSTEMINCLUDE LIBRARY euser.lib ws32.lib gdi.lib efsrv.lib LIBRARY w32stdgraphic.lib fbscli.lib tlib.lib diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/group/bufferdrawer.mmp --- a/windowing/windowserver/group/bufferdrawer.mmp Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/group/bufferdrawer.mmp Wed Jun 23 19:41:15 2010 +0300 @@ -29,7 +29,7 @@ OS_LAYER_SYSTEMINCLUDE_SYMBIAN -sourcepath ../tbufferdrawer +sourcepath ../test/tbufferdrawer source proxy.cpp bufferdrawer.cpp resource bufferdrawer.rss diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/group/containdrawer.mmp --- a/windowing/windowserver/group/containdrawer.mmp Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/group/containdrawer.mmp Wed Jun 23 19:41:15 2010 +0300 @@ -28,7 +28,7 @@ userinclude ../inc . OS_LAYER_SYSTEMINCLUDE_SYMBIAN -sourcepath ../tcontaindrawer +sourcepath ../test/tcontaindrawer source proxy.cpp containdrawer.cpp simpledrawer.cpp wsgraphicdrawerngacontext.cpp wsgraphicdrawernonngacontext.cpp resource containdrawer.rss library euser.lib ecom.lib gdi.lib bitgdi.lib fbscli.lib wsgraphicdrawer.lib diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/group/eventdd.mmp --- a/windowing/windowserver/group/eventdd.mmp Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/group/eventdd.mmp Wed Jun 23 19:41:15 2010 +0300 @@ -18,9 +18,9 @@ target eventdd.ldd targettype ldd -userinclude ../tauto +userinclude ../test/tauto -sourcepath ../tauto +sourcepath ../test/tauto source eventdd.cpp uid 0x100000af diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/group/framerate.mmp --- a/windowing/windowserver/group/framerate.mmp Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/group/framerate.mmp Wed Jun 23 19:41:15 2010 +0300 @@ -29,7 +29,7 @@ USERINCLUDE ../inc . OS_LAYER_SYSTEMINCLUDE_SYMBIAN -SOURCEPATH ../tframerate +SOURCEPATH ../test/tframerate SOURCE proxy.cpp framerate.cpp wsgraphicdrawerngacontext.cpp wsgraphicdrawernonngacontext.cpp RESOURCE framerate.RSS diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/group/graphics_wserv.mrp --- a/windowing/windowserver/group/graphics_wserv.mrp Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/group/graphics_wserv.mrp Wed Jun 23 19:41:15 2010 +0300 @@ -7,28 +7,8 @@ ipr D -ipr T \sf\os\graphics\windowing\windowserver\tanim -ipr T \sf\os\graphics\windowing\windowserver\tauto -ipr T \sf\os\graphics\windowing\windowserver\tcapability -ipr T \sf\os\graphics\windowing\windowserver\TClick -ipr T \sf\os\graphics\windowing\windowserver\tcrx ipr T \sf\os\graphics\windowing\windowserver\test -ipr T \sf\os\graphics\windowing\windowserver\tframerate -ipr T \sf\os\graphics\windowing\windowserver\tlib -ipr T \sf\os\graphics\windowing\windowserver\tlisten -ipr T \sf\os\graphics\windowing\windowserver\tman -ipr T \sf\os\graphics\windowing\windowserver\tredir -ipr T \sf\os\graphics\windowing\windowserver\ttime -ipr T \sf\os\graphics\windowing\windowserver\twsgraphic -ipr T \sf\os\graphics\windowing\windowserver\tcontaindrawer ipr F \sf\os\graphics\windowing\windowserver\nga\samplegraphicsurfacedrawer -ipr T \sf\os\graphics\windowing\windowserver\t_integ -ipr T \sf\os\graphics\windowing\windowserver\tgce -ipr T \sf\os\graphics\windowing\windowserver\tgceperf -ipr T \sf\os\graphics\windowing\windowserver\tbufferdrawer -ipr T \sf\os\graphics\windowing\windowserver\tcsc -ipr T \sf\os\graphics\windowing\windowserver\tdynamicres -ipr T \sf\os\graphics\windowing\windowserver\tvalidationrenderstages diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/group/listener.mmp --- a/windowing/windowserver/group/listener.mmp Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/group/listener.mmp Wed Jun 23 19:41:15 2010 +0300 @@ -28,7 +28,7 @@ userinclude ../inc . OS_LAYER_SYSTEMINCLUDE_SYMBIAN -sourcepath ../tlisten +sourcepath ../test/tlisten source proxy.cpp listener.cpp wsgraphicdrawerngacontext.cpp wsgraphicdrawernonngacontext.cpp resource listener.rss library euser.lib ecom.lib gdi.lib bitgdi.lib fbscli.lib wsgraphicdrawer.lib diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/group/multiptrclick.mmp --- a/windowing/windowserver/group/multiptrclick.mmp Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/group/multiptrclick.mmp Wed Jun 23 19:41:15 2010 +0300 @@ -17,7 +17,7 @@ CAPABILITY PowerMgmt ReadDeviceData WriteDeviceData ProtServ TARGETTYPE DLL -SOURCEPATH ../TClick +SOURCEPATH ../test/TClick SOURCE multiptrclick.cpp USERINCLUDE ../inc diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/group/openwfc/BLD.INF --- a/windowing/windowserver/group/openwfc/BLD.INF Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/group/openwfc/BLD.INF Wed Jun 23 19:41:15 2010 +0300 @@ -368,12 +368,12 @@ ../../test/test.mbm z:/wstest/test.mbm ../../test/trom.mbm z:/wstest/trom.mbm ../../test/MAILANIM.MBM z:/wstest/mailanim.mbm -../../tanim/tanim.mbm z:/wstest/tanim.mbm -../../tauto/tauto.mbm z:/wstest/tauto.mbm -../../tauto/Dither.MBM z:/wstest/dither.mbm -../../tauto/mytest.mbm z:/wstest/mytest.mbm -../../tauto/symball.gif z:/wstest/symball.gif -../../tauto/config/graphics-wserv-autotest.ini z:/wstest/graphics-wserv-autotest.ini +../../test/tanim/tanim.mbm z:/wstest/tanim.mbm +../../test/tauto/tauto.mbm z:/wstest/tauto.mbm +../../test/tauto/Dither.MBM z:/wstest/dither.mbm +../../test/tauto/mytest.mbm z:/wstest/mytest.mbm +../../test/tauto/symball.gif z:/wstest/symball.gif +../../test/tauto/config/graphics-wserv-autotest.ini z:/wstest/graphics-wserv-autotest.ini ../../group/DLL_LIST.TXT z:/system/data/dll_list.txt #ifdef SYMBIAN_BUILD_GCE diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/group/redirector.mmp --- a/windowing/windowserver/group/redirector.mmp Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/group/redirector.mmp Wed Jun 23 19:41:15 2010 +0300 @@ -28,7 +28,7 @@ userinclude ../inc . OS_LAYER_SYSTEMINCLUDE_SYMBIAN -sourcepath ../tredir +sourcepath ../test/tredir source proxy.cpp redirector.cpp resource redirector.rss library euser.lib ecom.lib gdi.lib bitgdi.lib fbscli.lib wsgraphicdrawer.lib diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/group/tclosepanicwindow.mmp --- a/windowing/windowserver/group/tclosepanicwindow.mmp Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/group/tclosepanicwindow.mmp Wed Jun 23 19:41:15 2010 +0300 @@ -18,7 +18,7 @@ CAPABILITY PowerMgmt SwEvent WriteDeviceData ProtServ -SOURCEPATH ../tauto +SOURCEPATH ../test/tauto SOURCE tclosepanicwindowprocess.cpp diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/group/tcrx.mmp --- a/windowing/windowserver/group/tcrx.mmp Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/group/tcrx.mmp Wed Jun 23 19:41:15 2010 +0300 @@ -19,9 +19,9 @@ uid 0x100039ce 0x10281e21 vendorid 0x70000001 targetpath /sys/bin -userinclude . ../tredir ../tlisten +userinclude . ../test/tredir ../test/tlisten OS_LAYER_SYSTEMINCLUDE_SYMBIAN -sourcepath ../tcrx +sourcepath ../test/tcrx source tcrx.cpp library euser.lib ws32.lib wsredir.lib wslisten.lib gdi.lib diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/group/tcsc.mmp --- a/windowing/windowserver/group/tcsc.mmp Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,60 +0,0 @@ -// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Name : tcsc.mmp -// Author : -// This is the project specification file for tcsc. -// -// - -TARGET wsgcecscserver.exe -TARGETTYPE exe -UID 0 0xE8B48691 - -// For setting the screen mode: -CAPABILITY WriteDeviceData SwEvent - -USERINCLUDE ../tgce -USERINCLUDE ../inc -USERINCLUDE ../inc/Graphics - -MW_LAYER_SYSTEMINCLUDE_SYMBIAN -OS_LAYER_SYSTEMINCLUDE_SYMBIAN -OS_LAYER_LIBC_SYSTEMINCLUDE - -SOURCEPATH ../tgce -SOURCE surfaceutility.cpp globalsettings.cpp -SOURCEPATH ../tcsc -SOURCE t_gcecscserver.cpp cwsgcecscbase.cpp cwsgcecsc.cpp - - -MACRO SYMBIAN_GRAPHICS_GCE - -STATICLIBRARY tefunit.lib -LIBRARY euser.lib -LIBRARY estlib.lib -LIBRARY testexecuteutils.lib -LIBRARY testexecutelogclient.lib -LIBRARY rfileloggerclient.lib -LIBRARY ws32.lib -LIBRARY surfacemanager.lib -LIBRARY surfaceupdateclient.lib -LIBRARY imageconversion.lib -LIBRARY efsrv.lib -LIBRARY fbscli.lib -LIBRARY gdi.lib -LIBRARY bitgdi.lib -LIBRARY hal.lib -LIBRARY scdv.lib - -SMPSAFE diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/group/wsbufferdrawer.mmp --- a/windowing/windowserver/group/wsbufferdrawer.mmp Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/group/wsbufferdrawer.mmp Wed Jun 23 19:41:15 2010 +0300 @@ -32,7 +32,7 @@ OS_LAYER_SYSTEMINCLUDE_SYMBIAN -sourcepath ../tbufferdrawer +sourcepath ../test/tbufferdrawer source wsbufferdrawer.cpp library euser.lib ws32.lib diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/group/wscons.mmp --- a/windowing/windowserver/group/wscons.mmp Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/group/wscons.mmp Wed Jun 23 19:41:15 2010 +0300 @@ -17,7 +17,7 @@ TARGET wsecons.dll TARGETTYPE dll -SOURCEPATH ../tauto +SOURCEPATH ../test/tauto SOURCE wscons.cpp OS_LAYER_SYSTEMINCLUDE_SYMBIAN diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/group/wscontaindrawer.mmp --- a/windowing/windowserver/group/wscontaindrawer.mmp Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/group/wscontaindrawer.mmp Wed Jun 23 19:41:15 2010 +0300 @@ -31,7 +31,7 @@ userinclude ../inc OS_LAYER_SYSTEMINCLUDE_SYMBIAN -sourcepath ../tcontaindrawer +sourcepath ../test/tcontaindrawer source wscontaindrawer.cpp wssimpledrawer.cpp diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/group/wsframerate.mmp --- a/windowing/windowserver/group/wsframerate.mmp Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/group/wsframerate.mmp Wed Jun 23 19:41:15 2010 +0300 @@ -28,7 +28,7 @@ DEFFILE wsframerate.DEF -SOURCEPATH ../tframerate +SOURCEPATH ../test/tframerate SOURCE wsframerate.cpp diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/group/wslisten.mmp --- a/windowing/windowserver/group/wslisten.mmp Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/group/wslisten.mmp Wed Jun 23 19:41:15 2010 +0300 @@ -31,7 +31,7 @@ userinclude ../inc . OS_LAYER_SYSTEMINCLUDE_SYMBIAN -sourcepath ../tlisten +sourcepath ../test/tlisten source wslisten.cpp library euser.lib ws32.lib diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/group/wsredir.mmp --- a/windowing/windowserver/group/wsredir.mmp Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/group/wsredir.mmp Wed Jun 23 19:41:15 2010 +0300 @@ -31,7 +31,7 @@ userinclude ../inc . OS_LAYER_SYSTEMINCLUDE_SYMBIAN -sourcepath ../tredir +sourcepath ../test/tredir source wsredir.cpp library euser.lib ws32.lib diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/inc/Graphics/openwfc/WSGRAPHICDRAWERINTERFACE.H --- a/windowing/windowserver/inc/Graphics/openwfc/WSGRAPHICDRAWERINTERFACE.H Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/inc/Graphics/openwfc/WSGRAPHICDRAWERINTERFACE.H Wed Jun 23 19:41:15 2010 +0300 @@ -40,6 +40,7 @@ class MEventHandler; class MWsElement; class MWsGraphicsContext; +class MWsAnimationScheduler; /** @publishedPartner @@ -134,57 +135,6 @@ virtual TBool RedrawInvalid(const TArray& aInvalid) = 0; }; -class MWsAnimationScheduler: public MWsObjectProvider -/** A system mechanism for customising the animation timer to a particular hardware variant or to a - particular external compositor e.g. an out-of-scene transition engine. - The default animation scheduler in WSERV does not understand device-dependant parameters e.g. - screen refresh rates - @publishedPartner - @released - to be adapted when WSERV migrates to surfaces -*/ { -public: - /** Called to schedule an animation event for a screen to occur not before some point - A screen may be scheduled to animate several times without actually receiving an animation event from the scheduler - If the scheduler cannot honour the request e.g. device constraints, it ignores the request. - @param aScreen the screen to recieve the event - @param aWhen the point in time the event need not occur before - */ - virtual void ScheduleAnimation(MWsScreen& aScreen,const TTime& aWhen) = 0; - /** Called if a screen determines that it no longer needs to schedule any animation - @param aScreen the screen not needing to receive any animation events - */ - virtual void UnscheduleAnimation(MWsScreen& aScreen) = 0; - /** Called to schedule the redrawing of all screens containing this graphic. - The redrawing of affected screens can be deferred by the scheduler. - @param aId the ID of the graphic to be redrawn. The graphic itself need not exist - (e.g. it has just been deleted, hence the need to redraw all potentially affected screens). */ - virtual void Invalidate(const TGraphicDrawerId& aId) = 0; - /** Called when the Window Server receives a TRawEvent::EInactive event, to signal power-saving */ - virtual void OnInactive() = 0; - /** Called when the Window Server receives a TRawEvent::EActive event, to signal screen back on */ - virtual void OnActive() = 0; - - /** Called to schedule a redraw for a screen which is out of date - A screen may be scheduled to redraw several times without actually receiving aredraw event from the scheduler - If this request is ignored then the screen will be draw incorrectly untill a such a request is not ignored. - @param aScreen the screen to recieve the event - @param aWhen the point in time the event need not occur before - */ - virtual void ScheduleRedraw(MWsScreen& aScreen,const TTime& aWhen) = 0; - /** Called to force a previously scheduled redraw for a screen to happen synchronously - Used when we are about to loose our ability to perform the redraw correctly. - @param aScreen the screen to recieve the event - */ - virtual void DoRedrawNow(MWsScreen& aScreen) = 0; - -protected: - IMPORT_C void Animate(MWsScreen& aScreen); - IMPORT_C void Animate(MWsScreen& aScreen, TRequestStatus* aFinished); - IMPORT_C void Redraw(MWsScreen& aScreen); - IMPORT_C TBool RedrawInvalid(MWsScreen& aScreen,const TArray& aInvalid); - }; - /** @publishedPartner @prototype @@ -245,7 +195,7 @@ /** Get a particular screen by ordinal @return the screen, or NULL if aIndex is out of bounds */ virtual const MWsScreen* Screen(TInt aIndex) const = 0; - /** Set the animation scheduler; this can only be done once by custom code + /** Not supported @return success of overriding the default scheduler */ virtual TBool SetCustomAnimationScheduler(MWsAnimationScheduler* aScheduler) = 0; /** Query whether a custom animation scheduler has been set diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/inc/Graphics/wsgraphicdrawerinternal.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/inc/Graphics/wsgraphicdrawerinternal.h Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,89 @@ +// Copyright (c) 1994-2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#ifndef GRAPHICDRAWER_INTERNAL_H +#define GRAPHICDRAWER_INTERNAL_H + +class MWsAnimationScheduler: public MWsObjectProvider +/** A system mechanism for customising the animation timer to a particular hardware variant or to a + particular external compositor e.g. an out-of-scene transition engine. + The default animation scheduler in WSERV does not understand device-dependant parameters e.g. + screen refresh rates + @internalComponent + @released +*/ { +public: + /** Called to schedule an animation event for a screen to occur not before some point + A screen may be scheduled to animate several times without actually receiving an animation event from the scheduler + If the scheduler cannot honour the request e.g. device constraints, it ignores the request. + @param aScreen the screen to recieve the event + @param aWhen the point in time the event need not occur before + */ + virtual void ScheduleAnimation(MWsScreen& aScreen,const TTime& aWhen) = 0; + /** Called if a screen determines that it no longer needs to schedule any animation + @param aScreen the screen not needing to receive any animation events + */ + virtual void UnscheduleAnimation(MWsScreen& aScreen) = 0; + /** Called to schedule the redrawing of all screens containing this graphic. + The redrawing of affected screens can be deferred by the scheduler. + @param aId the ID of the graphic to be redrawn. The graphic itself need not exist + (e.g. it has just been deleted, hence the need to redraw all potentially affected screens). */ + virtual void Invalidate(const TGraphicDrawerId& aId) = 0; + /** Called when the Window Server receives a TRawEvent::EInactive event, to signal power-saving */ + virtual void OnInactive() = 0; + /** Called when the Window Server receives a TRawEvent::EActive event, to signal screen back on */ + virtual void OnActive() = 0; + + /** Called to schedule a redraw for a screen which is out of date + A screen may be scheduled to redraw several times without actually receiving aredraw event from the scheduler + If this request is ignored then the screen will be draw incorrectly untill a such a request is not ignored. + @param aScreen the screen to recieve the event + @param aWhen the point in time the event need not occur before + */ + virtual void ScheduleRedraw(MWsScreen& aScreen,const TTime& aWhen) = 0; + /** Called to force a previously scheduled redraw for a screen to happen immediately. + Used when we are about to loose our ability to perform the redraw correctly. + @param aScreen the screen to recieve the event + */ + virtual void DoRedrawNow(MWsScreen& aScreen) = 0; + + /** Interface to be implemented by callers of the asynchronous overload of + DoRedrawNow, which takes a reference to this interface as argument to be able + to give a callback once the screen update has been completed. + */ + class MScreenUpdateObserver + { + public: + /** Callback when an asynchronous DoRedrawNow has been completed. */ + virtual void ScreenUpdateComplete(TInt aResult) = 0; + }; + + /** Called to force a previously scheduled redraw for a screen to happen immediately. + @param aScreen the screen to recieve the event + @param aObserver reference which will receive a notification when the screen has been updated + */ + virtual void DoRedrawNow(MWsScreen& aScreen, MScreenUpdateObserver& aObserver) = 0; + + /** Callback to use if aObserver gets deleted before screen update takes place. */ + virtual void ClearScreenUpdateObserver(const MScreenUpdateObserver& aObserver) = 0; + +protected: + IMPORT_C void Animate(MWsScreen& aScreen); + IMPORT_C void Animate(MWsScreen& aScreen, TRequestStatus* aFinished); + IMPORT_C void Redraw(MWsScreen& aScreen); + IMPORT_C TBool RedrawInvalid(MWsScreen& aScreen,const TArray& aInvalid); + }; + +#endif \ No newline at end of file diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/nga/CLIENT/RDirect.CPP --- a/windowing/windowserver/nga/CLIENT/RDirect.CPP Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/nga/CLIENT/RDirect.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -528,7 +528,7 @@ iAbort.Restart(iReason); } -void CDirectScreenAccess::UpdateSizeAndRotation(CFbsBitGc*/* aGc*/) +void CDirectScreenAccess::UpdateSizeAndRotation(CFbsBitGc* aGc) { TPixelsAndRotation sizeAndRotation; iWsScreenDevice->GetDefaultScreenSizeAndRotation(sizeAndRotation); @@ -549,6 +549,8 @@ iScreenDevice->SetDrawDeviceOffset(appAreaInDsa.iTl); } } + + aGc->Activate(iScreenDevice); } void CDirectScreenAccess::RunL() diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/nga/SERVER/EVENT.CPP --- a/windowing/windowserver/nga/SERVER/EVENT.CPP Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/nga/SERVER/EVENT.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 1994-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 1994-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -32,6 +32,7 @@ #include "pointer.h" #include "debugbar.h" #include "advancedpointereventhelper.h" +#include "Graphics/wsgraphicdrawerinternal.h" GLREF_D CDebugLogBase *wsDebugLog; @@ -622,6 +623,21 @@ TWsEvent event; event.SetType(EEventDisplayChanged); event.SetTimeNow(); + + // fill in the handle otherwise CONE will discard the notification + CWsObjectIx* clientObjList = aWsClient->ObjectIndex(); + const TWsObject* ptr=clientObjList->FirstObject(); + const TWsObject* end=ptr+clientObjList->Length(); + while(++ptriObject; + if (obj && obj->Type()==WS_HANDLE_GROUP_WINDOW) + { + event.SetHandle(ptr->iHandle); + break; + } + } + TWsDisplayChangedEvent* dispEvent = event.DisplayChanged(); dispEvent->iDisplayNumber = aDisplayNumber; dispEvent->iConfigurationChangeId = aConfigurationChangeId; @@ -1020,7 +1036,9 @@ case TRawEvent::EKeyDown: { _LIT(KWSERVDebugLogKeyDownArrival,"Key down arrives %d"); - if(CDebugBar* dbg = CWsTop::Screen()->DebugBar()) + CScreen* screen = CWsTop::Screen(); + WS_ASSERT_ALWAYS(screen, EWsPanicNoScreen); + if(CDebugBar* dbg = screen->DebugBar()) dbg->OnKeyEvent(); if (wsDebugLog) wsDebugLog->MiscMessage(CDebugLogBase::ELogEverything,KWSERVDebugLogKeyDownArrival,aRawEvent.ScanCode()); @@ -1036,7 +1054,9 @@ case TRawEvent::EKeyUp: { _LIT(KWSERVDebugLogKeyUpArrival,"Key up arrives %d"); - if(CDebugBar* dbg = CWsTop::Screen()->DebugBar()) + CScreen* screen = CWsTop::Screen(); + WS_ASSERT_ALWAYS(screen, EWsPanicNoScreen); + if(CDebugBar* dbg = screen->DebugBar()) dbg->OnKeyEvent(); if (wsDebugLog) wsDebugLog->MiscMessage(CDebugLogBase::ELogEverything,KWSERVDebugLogKeyUpArrival,aRawEvent.ScanCode()); diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/nga/SERVER/POINTER.CPP --- a/windowing/windowserver/nga/SERVER/POINTER.CPP Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/nga/SERVER/POINTER.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -81,7 +81,9 @@ iEmulatorRotatePointerCoords = WsIniFile->FindVar(KWSERVIniFileVarEmulatorRotPointCoords); #endif - iRootWindow = CWsTop::Screen()->RootWindow(); + const CScreen* screen = CWsTop::Screen(); + WS_ASSERT_ALWAYS(screen, EWsPanicNoScreen); + iRootWindow = screen->RootWindow(); TMachineInfoV1Buf machineInfo; UserHal::MachineInfo(machineInfo); diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/nga/SERVER/REDRAWQ.CPP --- a/windowing/windowserver/nga/SERVER/REDRAWQ.CPP Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/nga/SERVER/REDRAWQ.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -170,7 +170,9 @@ TInt invalidWindows = 0; for (TInt screenNo = 0; screenNo < CWsTop::NumberOfScreens(); ++screenNo) { - CWsRootWindow* rootWindow = CWsTop::Screen(screenNo)->RootWindow(); + const CScreen* screen = CWsTop::Screen(screenNo); + WS_ASSERT_ALWAYS(screen, EWsPanicNoScreen); + CWsRootWindow* rootWindow = screen->RootWindow(); for (CWsWindowGroup *groupWin = rootWindow->Child(); groupWin; groupWin = groupWin->NextSibling()) { if (groupWin->WsOwner() == iWsOwner) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/nga/SERVER/SERVER.CPP --- a/windowing/windowserver/nga/SERVER/SERVER.CPP Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/nga/SERVER/SERVER.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -19,7 +19,6 @@ #include "panics.h" #include "wstop.h" #include "EVENT.H" -#include #include #include #include "inifile.h" @@ -107,6 +106,8 @@ void OnActive(); void ScheduleRedraw(MWsScreen& aScreen,const TTime& aWhen); void DoRedrawNow(MWsScreen& aScreen); + void DoRedrawNow(MWsScreen& aScreen, MWsAnimationScheduler::MScreenUpdateObserver& aObserver); + void ClearScreenUpdateObserver(const MWsAnimationScheduler::MScreenUpdateObserver& aObserver); private: static TBool OnIdleCallBack(TAny* aAny); void ScheduleUpdate (TInt aScreenNumber, TBool aForce); @@ -142,6 +143,8 @@ ~CScreenState(); void SetActive (); + void WaitForRedraws(MWsAnimationScheduler::MScreenUpdateObserver& aObserver, TInt aNumRedraws); + void ClearScreenUpdateObserver(const MWsAnimationScheduler::MScreenUpdateObserver& aObserver); CPeriodic* iUpdateOn; TTime iExpectedTickTime; TScreenUpdateDetails iScreenUpdateDetails; @@ -151,6 +154,8 @@ private: CScreenState (CDefaultAnimationScheduler* aScheduler, TInt aScreenOrdinal); void ConstructL (); + void ReleaseRemainingClients(); + void ReleaseClientsWaitingFor(TUint aCurrentFrame); void RunL(); void DoCancel() @@ -158,6 +163,18 @@ TRequestStatus* tmpTRS = &iStatus; User::RequestComplete(tmpTRS, KErrNone); }; + class TWaitingClient + { + public: + TWaitingClient(MWsAnimationScheduler::MScreenUpdateObserver& aObserver, TInt aTargetFrame) + : iObserver(aObserver), iTargetFrame(aTargetFrame) + { + } + MWsAnimationScheduler::MScreenUpdateObserver& iObserver; + TUint iTargetFrame; + }; + TUint iFrameCount; + RArray iWaitingClients; }; // If using the default animation scheduler on a device, these two numbers may be worth tweaking in the inifile @@ -275,6 +292,7 @@ void CWindowServer::CDefaultAnimationScheduler::CScreenState::ConstructL () { iUpdateOn = CPeriodic::NewL(EComposeCompletePriority); + iWaitingClients.ReserveL(8); CActiveScheduler::Add(this); } @@ -283,19 +301,91 @@ CActive::Cancel(); iInvalidated.Close(); delete iUpdateOn; + TInt i = iWaitingClients.Count(); + while(i--) + { + iWaitingClients[i].iObserver.ScreenUpdateComplete(KErrAbort); + } + iWaitingClients.Close(); } void CWindowServer::CDefaultAnimationScheduler::CScreenState::SetActive() { CActive::SetActive (); } - + +/** +This function is called from CWsClient d'tor to make sure we will not hang on to any deleted objects. +*/ +void CWindowServer::CDefaultAnimationScheduler::CScreenState::ClearScreenUpdateObserver(const MWsAnimationScheduler::MScreenUpdateObserver& aObserver) + { + const TInt count = iWaitingClients.Count(); + for(TInt i = count-1 ; i >= 0; i--) + { + if( &aObserver == &(iWaitingClients[i].iObserver) ) + { + TWaitingClient& client = iWaitingClients[i]; + client.iObserver.ScreenUpdateComplete(KErrCancel); + iWaitingClients.Remove(i); + } + } + } + +void CWindowServer::CDefaultAnimationScheduler::CScreenState::WaitForRedraws(MWsAnimationScheduler::MScreenUpdateObserver& aObserver, TInt aNumRedraws) + { + const TUint targetFrame = iFrameCount + aNumRedraws; + TWaitingClient request(aObserver, targetFrame); + TInt err = iWaitingClients.Append(request); + if(err != KErrNone) + { + //If OOM and already have 8 waiting clients we will not accept a 9th client + aObserver.ScreenUpdateComplete(KErrNoMemory); + } + } + +void CWindowServer::CDefaultAnimationScheduler::CScreenState::ReleaseRemainingClients() + { + const TInt count = iWaitingClients.Count(); + for(TInt i = count-1; i >= 0; i--) + { + TWaitingClient& client = iWaitingClients[i]; + client.iObserver.ScreenUpdateComplete(KErrNone); + iWaitingClients.Remove(i); + } + } + +void CWindowServer::CDefaultAnimationScheduler::CScreenState::ReleaseClientsWaitingFor(TUint aCurrentFrame) + { + const TInt count = iWaitingClients.Count(); + for(TInt i = count-1; i >= 0; i--) + { + TWaitingClient& client = iWaitingClients[i]; + if(aCurrentFrame == client.iTargetFrame) + { + client.iObserver.ScreenUpdateComplete(KErrNone); + iWaitingClients.Remove(i); + } + } + } + /** -Invoked when the rendering pipline signals that it is ready to recieve updated. +Invoked when the rendering pipline signals that it is ready to receive updates. */ void CWindowServer::CDefaultAnimationScheduler::CScreenState::RunL() { + iFrameCount++; + + //Complete any clients waiting for this frame + ReleaseClientsWaitingFor(iFrameCount); + iScreenUpdateDetails.iScheduler->ProcessUpdateCompletion (iScreenUpdateDetails.iScreenNumber); + + if(!IsActive()) + { + //No further pending frames, release all remaining clients + ReleaseRemainingClients(); + } + } void CWindowServer::CDefaultAnimationScheduler::ProcessUpdateCompletion (TInt aScreenNumber) @@ -310,6 +400,49 @@ ScheduleUpdate (aScreenNumber, ETrue); } +void CWindowServer::CDefaultAnimationScheduler::DoRedrawNow(MWsScreen& aScreen, MWsAnimationScheduler::MScreenUpdateObserver& aObserver) + { + TInt screenNumber = ScreenNumber (aScreen); + TInt redrawCount = 0; + + // redrawCount is the number of times we should wait for redraws to complete. + // If a redraw is not currently active then we need to wait (at most) once: for + // any outstanding scheduled update to complete. + // If a redraw is currently active then we need to wait (at most) twice: once for + // the current update to complete, and once for any outstanding scheduled update to complete. + if (!iScreenState[screenNumber]->IsActive()) + { + // No animation in progress, so force a redraw of due updates. + ScheduleUpdate(screenNumber, ETrue); + + // If there is still nothing drawing, set redrawCount to zero to make sure we do not wait. + if (!iScreenState[screenNumber]->IsActive()) + { + redrawCount = 0; + aObserver.ScreenUpdateComplete(KErrNone); + } + else + { + redrawCount = 1; + iScreenState[screenNumber]->WaitForRedraws(aObserver, redrawCount); + } + } + else + { + redrawCount = 2; + iScreenState[screenNumber]->WaitForRedraws(aObserver, redrawCount); + } + } + +void CWindowServer::CDefaultAnimationScheduler::ClearScreenUpdateObserver(const MWsAnimationScheduler::MScreenUpdateObserver& aObserver) + { + const TInt count = iScreenState.Count(); + for(TInt screenNumber=0; screenNumberClearScreenUpdateObserver(aObserver); + } + } + /** Switch to deactivate animation or drawing (based on setting of iInactivityBehaviour). See InvokeDueAnimation(). @@ -359,14 +492,14 @@ /** Perform redraw and return only when completed. NOTE: This method uses CActiveSchedulerWait to run a "modal wait loop" while the - redraw complete signal is pending. When the signal is recieved, AsyncStop() is + redraw complete signal is pending. When the signal is received, AsyncStop() is invoked on all active wait loops for the signalling screen. */ void CWindowServer::CDefaultAnimationScheduler::DoRedrawNow(MWsScreen& aScreen) { TInt screenNumber = ScreenNumber (aScreen); TInt redrawCount = 0; - + // redrawCount is the number of times we should wait for redraws to complete. // If a redraw is not currently active then we need to wait (at most) once: for // any outstanding scheduled update to complete. @@ -735,8 +868,7 @@ iDrawerMasterIndex.Close(); delete iDefaultAnimationScheduler; - iDefaultAnimationScheduler = NULL; //might be called from clients during server destruction - iCustomAnimationScheduler = NULL; // not owned + iDefaultAnimationScheduler = NULL; //might be called from clients during server destruction } void CWindowServer::ConstructL() @@ -799,40 +931,33 @@ /** Custom Animation Scheduler */ -TBool CWindowServer::SetCustomAnimationScheduler(MWsAnimationScheduler* aScheduler) +TBool CWindowServer::SetCustomAnimationScheduler(MWsAnimationScheduler* /*aScheduler*/) { - if(!iCustomAnimationScheduler && aScheduler) - { - iCustomAnimationScheduler = aScheduler; - return ETrue; - } return EFalse; } TBool CWindowServer::HasCustomAnimationScheduler() const { - return !!iCustomAnimationScheduler; + return EFalse; } -TBool CWindowServer::ClearCustomAnimationScheduler(MWsAnimationScheduler* aCurrentScheduler) +TBool CWindowServer::ClearCustomAnimationScheduler(MWsAnimationScheduler* /*aCurrentScheduler*/) { - if(iCustomAnimationScheduler && (iCustomAnimationScheduler == aCurrentScheduler)) - { - iCustomAnimationScheduler = NULL; - return ETrue; - } return EFalse; } MWsAnimationScheduler* CWindowServer::AnimationScheduler() { - if(iCustomAnimationScheduler) - { - return iCustomAnimationScheduler; - } return iDefaultAnimationScheduler; } +void CWindowServer::PrepareShutdown() + { + //Stop the renderloop, i.e. prevent any further calls to MWsAnimationScheduler::Animate() + delete iDefaultAnimationScheduler; + iDefaultAnimationScheduler = NULL; + } + TInt CWindowServer::RegisterEventHandler(CWsGraphicDrawer* aDrawer, MWsEventHandler* aHandler, TUint32 aEventMask) { if (!aDrawer || !aHandler || aEventMask==0) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/nga/SERVER/openwfc/ScreenRedraw.h --- a/windowing/windowserver/nga/SERVER/openwfc/ScreenRedraw.h Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/nga/SERVER/openwfc/ScreenRedraw.h Wed Jun 23 19:41:15 2010 +0300 @@ -24,6 +24,7 @@ #include "wstypes.h" #include "tcursor.h" #include +#include "Graphics/wsgraphicdrawerinternal.h" class CScreen; class CWsRenderStage; diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/nga/SERVER/openwfc/screen.cpp --- a/windowing/windowserver/nga/SERVER/openwfc/screen.cpp Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/nga/SERVER/openwfc/screen.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -1123,6 +1123,15 @@ //updaterotation should not fail after this point (no cleanup) + //update the last set config with the new rotation change so we don't incorrectly + //change the layer extents + if (iDisplayControl) + { + TDisplayConfiguration config; + config.SetRotation(static_cast(newRotation)); + iConfigChangeNotifier->UpdateLastSetConfiguration(config); + } + TWservCrEvent crEvent(TWservCrEvent::EDeviceOrientationChanged,iScreenNumber,&gcOrientation); TWindowServerEvent::NotifyDrawer(crEvent); @@ -1984,14 +1993,20 @@ { TSize oldConfigRes; oldConfig.GetResolution(oldConfigRes); + TDisplayConfiguration newConfig; if (oldConfigRes.iWidth == 0 || oldConfigRes.iHeight == 0) { - TDisplayConfiguration newConfig; iDisplayControl->GetConfiguration(newConfig); RecalculateModeTwips(&newConfig); //needs res and twips information } UpdateDynamicScreenModes(); + //update the last set config in the config change notifier to + //prevent SetConfiguration() from being called again! + newConfig.ClearAll(); + iDisplayControl->GetConfiguration(newConfig); + iConfigChangeNotifier->UpdateLastSetConfiguration(newConfig); + TWindowServerEvent::NotifyDrawer(TWservCrEvent(TWservCrEvent::EScreenSizeModeAboutToChange, iScreenSizeMode)); // This will remove all the DSA elements from the scene AbortAllDirectDrawing(RDirectScreenAccess::ETerminateRotation); @@ -2036,6 +2051,94 @@ return reply; } +/** + * Updates the screen device display properties. This is to ensure the screen device is + * consistent with any configuration changes not made using CScreen::SetConfiguration. + * + * @param aConfigInput a fully populated display configuration + **/ +TInt CScreen::UpdateConfiguration(const TDisplayConfiguration& aConfigInput) + { + TInt reply = KErrNone; + if(iDisplayControl) + { + TDisplayConfiguration config(aConfigInput); + TRect sizeModePosition; + if (iDisplayPolicy) + { //validate config and update to a valid hardware config + reply = iDisplayPolicy->GetSizeModeConfiguration(iScreenSizeMode,config,sizeModePosition); + if (reply >= KErrNone) + {//set appmode in policy + if (iDisplayMapping) + { + iDisplayMapping->SetSizeModeExtent(sizeModePosition,MWsDisplayMapping::KOffsetAll); + } + } + } + else + { //exessive strategy: limit rotation agains curr app mode. + //really we want the system to accept the rotation change regardless of the app mode. + TDisplayConfiguration::TRotation newRot; + if (aConfigInput.GetRotation(newRot)) + { //This should cast between rotation enumertaions "properly" + if (!(iModes[0][iScreenSizeMode]->iAlternativeRotations&(1<SceneRotation(); + TSize newUiSize; + config.GetResolution(newUiSize); + if(iFlags&EHasDynamicSizeModes) + { + reply = iFallbackMap->Resize(newUiSize); + } + + RecalculateModeTwips(&config); //needs res and twips information + UpdateDynamicScreenModes(); + + TWindowServerEvent::NotifyDrawer(TWservCrEvent(TWservCrEvent::EScreenSizeModeAboutToChange, iScreenSizeMode)); + // This will remove all the DSA elements from the scene + AbortAllDirectDrawing(RDirectScreenAccess::ETerminateRotation); + + //SetDigitiserAreas needs revisiting if/when we support dynamic resolutions + //on a screen with touch input. + //SetDigitiserAreas(newUiSize); + + //failure here should only be because of DSA orientation change failure, which shouldn't happen, either. + //Or there may be no change to do. + (void)UpdateOrientation(&oldRotation); + + iWindowElementSet->ResubmitAllElementExtents(); + if(iDsaDevice && iDsaDevice->GraphicsAccelerator()) + { + iDsaDevice->ChangeScreenDevice(iDsaDevice); // orientation has changed, therefore we need to re-initialise the screen device's graphics accelerator + } + + iRootWindow->AdjustCoordsDueToRotation(); + + //TODO jonas: we'd like to not have to clear at all... make the actual change to compositor etc lazily! + if(BlankScreenOnRotation()) + { + iRootWindow->ClearDisplay(); + } + + CWsTop::ClearAllRedrawStores(); + DiscardAllSchedules(); + iRootWindow->InvalidateWholeScreen(); + CWsWindowGroup::SetScreenDeviceValidStates(this); + TWindowServerEvent::SendScreenDeviceChangedEvents(this); + } + else + { + reply = KErrNotSupported; + } + return reply; + } + void CScreen::UpdateDynamicScreenModes() { WS_ASSERT_DEBUG(iDisplayControl,EWsPanicNoDisplayControl); diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/nga/SERVER/openwfc/screen.h --- a/windowing/windowserver/nga/SERVER/openwfc/screen.h Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/nga/SERVER/openwfc/screen.h Wed Jun 23 19:41:15 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -249,6 +249,7 @@ void ClearDsaSurface(const TRect& area, const TRgb& color); void PositionUiElements(const TRect& aExtent, const TRect& aViewport); TInt SetConfiguration(const TDisplayConfiguration& aConfig); + TInt UpdateConfiguration(const TDisplayConfiguration& aConfig); void UpdateDynamicScreenModes(); void RecalculateModeTwips(const TDisplayConfiguration* aConfig = NULL); inline void IncreaseDisplaySpinner(); diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/nga/SERVER/openwfc/server.h --- a/windowing/windowserver/nga/SERVER/openwfc/server.h Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/nga/SERVER/openwfc/server.h Wed Jun 23 19:41:15 2010 +0300 @@ -28,6 +28,7 @@ #include "CLIENT.H" #include "ScrDev.H" #include +#include "Graphics/wsgraphicdrawerinternal.h" #include "WSGRAPHICDRAWERARRAY.H" #include "panics.h" @@ -340,6 +341,7 @@ void StartL(); TInt SessionCount(); MWsAnimationScheduler* AnimationScheduler(); + void PrepareShutdown(); TBool ReleaseMemory(); void DestroySessionsForShutdown(); void SetPinClientDescriptors(TBool aPin); diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/nga/SERVER/wsdisplaychangeao.cpp --- a/windowing/windowserver/nga/SERVER/wsdisplaychangeao.cpp Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/nga/SERVER/wsdisplaychangeao.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -243,6 +243,27 @@ Cancel(); } +void CWsConfigChangeNotifier::UpdateLastSetConfiguration(TDisplayConfiguration& aNewConfig) + { + TSize resolution(0,0); + if (aNewConfig.GetResolution(resolution)) + { + iLastConfig.SetResolution(resolution); + } + + TSize resolutionTwips(0,0); + if (aNewConfig.GetResolutionTwips(resolutionTwips)) + { + iLastConfig.SetResolutionTwips(resolutionTwips); + } + + TDisplayConfiguration1::TRotation rotation; + if (aNewConfig.GetRotation(rotation)) + { + iLastConfig.SetRotation(rotation); + } + } + void CWsConfigChangeNotifier::RunL() { if(iStatus == KErrNone) @@ -259,6 +280,29 @@ iRetry->CancelRetry(); iOwner->IncreaseConfigSpinner(); + + //if the config change comes from a render stage then ensure screen device size + //is also updated + TSize currentRes; + currentConfig.GetResolution(currentRes); + TBool disconnected = (currentRes.iHeight == 0 || currentRes.iWidth == 0) ? ETrue : EFalse; + + //if the config change is due to CScreen::SetConfiguration() being called then we + //don't want to update it again. Only update if the configs are different and the + //display is connected... + TDisplayConfiguration lastSetConfig(iLastSetConfig); + if (!((currentConfig == lastSetConfig) || (disconnected))) + { + TDisplayConfiguration1::TRotation rotation; + if (lastSetConfig.GetRotation(rotation)) + { + //use the latest rotation value to ensure we don't get any + //inconsistencies with the layer extents + currentConfig.SetRotation(rotation); + } + iOwner->UpdateConfiguration(currentConfig); + } + //put config change event on queue RPointerArray clientArray; CleanupClosePushL(clientArray); @@ -282,6 +326,7 @@ iRetry->Retry(KRetryInitialDelay); } } + iNextLevelInterface->GetConfiguration(iLastSetConfig); } else if(iStatus != KErrCancel && iStatus != KErrNotSupported) { diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/nga/SERVER/wsdisplaychangeao.h --- a/windowing/windowserver/nga/SERVER/wsdisplaychangeao.h Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/nga/SERVER/wsdisplaychangeao.h Wed Jun 23 19:41:15 2010 +0300 @@ -1,5 +1,5 @@ /** -* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" @@ -60,6 +60,7 @@ static CWsConfigChangeNotifier* NewL(MWsDisplayControl* aNextLevelInterface, CScreen *aOwner); void IssueNotificationRequest(); void CancelNotificationRequest(); + void UpdateLastSetConfiguration(TDisplayConfiguration& aNewConfig); ~CWsConfigChangeNotifier(); protected: void ConstructL(); @@ -75,6 +76,8 @@ CEventQueueRetry *iRetry; TDisplayConfiguration iLastConfig; + // last set screen device SetConfiguration call + TDisplayConfiguration iLastSetConfig; }; #endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/nga/graphicdrawer/graphicdrawerenvironment.cpp --- a/windowing/windowserver/nga/graphicdrawer/graphicdrawerenvironment.cpp Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/nga/graphicdrawer/graphicdrawerenvironment.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -15,6 +15,7 @@ #include "Graphics/WSGRAPHICDRAWER.H" #include +#include "Graphics/wsgraphicdrawerinternal.h" // TGraphicDrawerId \\\\\\\\\\\\\\\\\\\\\\\\ diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/nonnga/SERVER/EVENT.CPP --- a/windowing/windowserver/nonnga/SERVER/EVENT.CPP Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/nonnga/SERVER/EVENT.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -32,6 +32,8 @@ #include "pointer.h" #include "debugbar.h" #include "wstraces.h" +#include "Graphics/wsgraphicdrawerinternal.h" + GLREF_D CDebugLogBase *wsDebugLog; diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/nonnga/SERVER/SERVER.CPP --- a/windowing/windowserver/nonnga/SERVER/SERVER.CPP Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/nonnga/SERVER/SERVER.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -19,7 +19,6 @@ #include "panics.h" #include "wstop.h" #include "EVENT.H" -#include #include #include #include "inifile.h" @@ -82,6 +81,8 @@ void OnActive(); void ScheduleRedraw(MWsScreen& aScreen,const TTime& aWhen); void DoRedrawNow(MWsScreen& aScreen); + void DoRedrawNow(MWsScreen& aScreen, MWsAnimationScheduler::MScreenUpdateObserver& aObserver); + void ClearScreenUpdateObserver(const MWsAnimationScheduler::MScreenUpdateObserver& /*aObserver*/) {} TInt RemoveGraphicDrawer(const TGraphicDrawerId &aId); private: @@ -326,6 +327,12 @@ OnIdleCallBack(ETrue); } +void CWindowServer::CDefaultAnimationScheduler::DoRedrawNow(MWsScreen& /*aScreen*/, MWsAnimationScheduler::MScreenUpdateObserver& aObserver) + { + OnIdleCallBack(ETrue); + aObserver.ScreenUpdateComplete(KErrNone); + } + void CWindowServer::CDefaultAnimationScheduler::ScheduleAnimation(MWsScreen& aScreen,const TTime& aWhen) { TSchedule schedule; @@ -646,7 +653,6 @@ delete iDefaultAnimationScheduler; iDefaultAnimationScheduler = NULL; // might be called from clients during server destruction - iCustomAnimationScheduler = NULL; // not owned delete iPluginManager; } @@ -714,37 +720,23 @@ /** Custom Animation Scheduler */ -TBool CWindowServer::SetCustomAnimationScheduler(MWsAnimationScheduler* aScheduler) +TBool CWindowServer::SetCustomAnimationScheduler(MWsAnimationScheduler* /*aScheduler*/) { - if(!iCustomAnimationScheduler && aScheduler) - { - iCustomAnimationScheduler = aScheduler; - return ETrue; - } return EFalse; } TBool CWindowServer::HasCustomAnimationScheduler() const { - return !!iCustomAnimationScheduler; + return EFalse; } -TBool CWindowServer::ClearCustomAnimationScheduler(MWsAnimationScheduler* aCurrentScheduler) +TBool CWindowServer::ClearCustomAnimationScheduler(MWsAnimationScheduler* /*aCurrentScheduler*/) { - if(iCustomAnimationScheduler && (iCustomAnimationScheduler == aCurrentScheduler)) - { - iCustomAnimationScheduler = NULL; - return ETrue; - } return EFalse; } MWsAnimationScheduler* CWindowServer::AnimationScheduler() { - if(iCustomAnimationScheduler) - { - return iCustomAnimationScheduler; - } return iDefaultAnimationScheduler; } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/nonnga/SERVER/ScreenRedraw.h --- a/windowing/windowserver/nonnga/SERVER/ScreenRedraw.h Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/nonnga/SERVER/ScreenRedraw.h Wed Jun 23 19:41:15 2010 +0300 @@ -23,6 +23,7 @@ #include #include "wstypes.h" #include +#include "Graphics/wsgraphicdrawerinternal.h" class CScreen; class CWsRenderStage; diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/nonnga/SERVER/server.h --- a/windowing/windowserver/nonnga/SERVER/server.h Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/nonnga/SERVER/server.h Wed Jun 23 19:41:15 2010 +0300 @@ -28,6 +28,7 @@ #include "CLIENT.H" #include "ScrDev.H" #include +#include "Graphics/wsgraphicdrawerinternal.h" #include "WSGRAPHICDRAWERARRAY.H" #include "panics.h" @@ -372,7 +373,6 @@ private: class CDefaultAnimationScheduler; CDefaultAnimationScheduler* iDefaultAnimationScheduler; - MWsAnimationScheduler* iCustomAnimationScheduler; CWsPluginManager* iPluginManager; RPointerArray iMemoryReleases; /** An index to all the CWsGraphicDrawer objects. diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/nonnga/graphicdrawer/graphicdrawerenvironment.cpp --- a/windowing/windowserver/nonnga/graphicdrawer/graphicdrawerenvironment.cpp Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/nonnga/graphicdrawer/graphicdrawerenvironment.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -15,6 +15,7 @@ #include "Graphics/WSGRAPHICDRAWER.H" #include +#include "Graphics/wsgraphicdrawerinternal.h" // TGraphicDrawerId \\\\\\\\\\\\\\\\\\\\\\\\ diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tanim/ANIM.CPP --- a/windowing/windowserver/tanim/ANIM.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,438 +0,0 @@ -// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Test code to tun ANIMDLL.DLL -// -// - -#include -#include -#include -#include "../tlib/testbase.h" -#include "TANIM.H" -#include "ANIMDLL.H" - -#define NONEXISTENT_DLL_NAME _L("Z:\\NONEXISTENT.DLL") -#define ANIM_BITMAP _L("Z:\\WSTEST\\TANIM.MBM") -#define ANIM_DLL_NAME _L("ANIDLL.DLL") - -enum TAnimPanic - { - EAnimPanicBadLoadFailed, - }; - -class CTAnimClient; - -class TestAnim : public RAnim - { -public: - TestAnim(RAnimDll &aDll); - TInt Construct(RWindowBase &aWin,const TPoint &aPos,CFbsBitmap *aBit1,CFbsBitmap *aBit2,CFbsBitmap *aMask,TInt aInterval, CFbsFont *aFont); - void Set(const TPoint &aPos, TInt aInterval); - void TextPos(const TPoint &aPos); - void SetPolyRectL(const TRect &aRect); - void ToggleMask(); - }; - -class CTAnimWindow2 : public CTBlankWindow - { -public: - CTAnimWindow2(RAnimDll &aAnimDll); - ~CTAnimWindow2(); - void ConstructL(CTWinBase &parent, const TPoint &aPos, const TSize &aSize); - void ConstructExtLD(CTWinBase &aParent, const TPoint &aPos, const TSize &aSize); -private: - TestAnim iAnim; - CFbsBitmap iAnimBitmap1; - CFbsBitmap iAnimBitmap2; - }; - -class CTAnimWindow1 : public CTTitledWindow - { -public: - CTAnimWindow1(RAnimDll &aAnimDll); - ~CTAnimWindow1(); - void ConstructL(CTWinBase &parent); - void Draw(); - void AdjustAnimRect(TInt xMove,TInt yMove,TInt modifiers); - void AdjustPolyRectL(TInt xMove,TInt yMove,TInt modifiers); - void ToggleMask(); - TInt SubType(); -private: - TestAnim iAnim; - TPoint iAnimPos; - TRect iAnimPolyRect; - CFbsBitmap iAnimBitmap1; - CFbsBitmap iAnimBitmap2; - CFbsBitmap iMask; - }; - -class CTAnimWindowGroup : public CTWindowGroup - { -public: - CTAnimWindowGroup(CTClient *aClient); - void CursorKeyL(TInt xMove,TInt yMove,TInt modifiers); - void KeyL(const TKeyEvent &aKey, const TTime &aTime); - TInt iCursorMode; - }; - -class CTAnimClient : public CTClient - { -public: - CTAnimClient(); - ~CTAnimClient(); - void ConstructL(); - void KeyL(const TKeyEvent &aKey,const TTime &aTime); - void ExitL(); - void ErrorTests(); - CTBaseWin *CreateTestWindowL(TPoint pos,TSize size,CTWinBase *parent, TInt aType); -private: - TInt iNum; - RAnimDll iAnimDll; - }; - -const TInt Xmove=8; -const TInt Ymove=6; - -void AnimPanic(TInt aPanic) - { - User::Panic(_L("ANIM"),aPanic); - } - -// -// Anim class -// - -TestAnim::TestAnim(RAnimDll &aDll) : RAnim(aDll) - { - } - -TInt TestAnim::Construct(RWindowBase &aWin, const TPoint &aPos, CFbsBitmap *aBit1,CFbsBitmap *aBit2,CFbsBitmap *aMask, TInt aInterval, CFbsFont *aFont) - { - TPckgBuf params; - params().pos=aPos; - params().interval=aInterval; - params().bit1=aBit1->Handle(); - params().bit2=aBit2->Handle(); - params().mask=aMask->Handle(); - params().font=aFont->Handle(); - return(RAnim::Construct(aWin,0,params)); - } - -void TestAnim::Set(const TPoint &aPos, TInt aInterval) - { - TPckgBuf params; - params().pos=aPos; - params().interval=aInterval; - Command(EADllOpcodeMove,params); - } - -void TestAnim::TextPos(const TPoint &aPos) - { - TPckgBuf params; - params()=aPos; - Command(EADllTextPos,params); - } - -void TestAnim::SetPolyRectL(const TRect &aRect) - { - TPckgC params(aRect); - User::LeaveIfError(CommandReply(EADllOpcodePolyLineRect,params)); - } - -void TestAnim::ToggleMask() - { - Command(EADllToggleBitmapMask); - } - -// -// Individual window sub-classes -// - -CTAnimWindow1::CTAnimWindow1(RAnimDll &aAnimDll) : CTTitledWindow(), - iAnim(aAnimDll) - { - } - -CTAnimWindow1::~CTAnimWindow1() - { - iAnim.Close(); - } - -void CTAnimWindow1::ConstructL(CTWinBase &parent) - { - CTTitledWindow::ConstructL(parent); - User::LeaveIfError(iAnimBitmap1.Load(ANIM_BITMAP,EMbmTanimAnim1)); - User::LeaveIfError(iAnimBitmap2.Load(ANIM_BITMAP,EMbmTanimAnim2)); - User::LeaveIfError(iMask.Load(ANIM_BITMAP,EMbmTanimMask)); - iAnimPos=TPoint(10,10); - User::LeaveIfError(iAnim.Construct(iWin, iAnimPos,&iAnimBitmap1,&iAnimBitmap2,&iMask,1,iFont)); - iAnimPolyRect=TRect(TPoint(10,40),TSize(50,50)); - iAnim.SetPolyRectL(iAnimPolyRect); - iAnim.TextPos(TPoint(20,50)); - } - -void CTAnimWindow1::Draw() - { - TInt i; - - CTTitledWindow::Draw(); - iGc->SetPenColor(TRgb::Gray16(8)); - TInt hgt=iSize.iHeight-iTitleHeight; - for(i=0;iDrawLine(TPoint(i,iTitleHeight),TPoint(iSize.iWidth,iTitleHeight+(hgt*i)/iSize.iWidth)); - iGc->DrawLine(TPoint(iSize.iWidth-i,iTitleHeight+hgt),TPoint(iSize.iWidth,iTitleHeight+(hgt*i)/iSize.iWidth)); - iGc->DrawLine(TPoint(iSize.iWidth-i,iTitleHeight+hgt),TPoint(0,iTitleHeight+hgt-(hgt*i)/iSize.iWidth)); - iGc->DrawLine(TPoint(i,iTitleHeight),TPoint(0,iTitleHeight+hgt-(hgt*i)/iSize.iWidth)); - } - } - -void CTAnimWindow1::AdjustAnimRect(TInt xMove,TInt yMove,TInt modifiers) - { - if (modifiers&EModifierCtrl) // 4 times the movement - { - xMove<<=2; - yMove<<=2; - } - iAnimPos+=TPoint(xMove,yMove); - iAnim.Set(iAnimPos,5); - } - -void CTAnimWindow1::AdjustPolyRectL(TInt xMove,TInt yMove,TInt modifiers) - { - if (modifiers&EModifierCtrl) // 4 times the movement - { - xMove<<=2; - yMove<<=2; - } - if (modifiers&EModifierShift) // 4 times the movement - iAnimPolyRect.Grow(xMove,yMove); - else - iAnimPolyRect.Move(TPoint(xMove,yMove)); - iAnim.SetPolyRectL(iAnimPolyRect); - } - -void CTAnimWindow1::ToggleMask() - { - iAnim.ToggleMask(); - } - -TInt CTAnimWindow1::SubType() - { - return(69); - } - -// CTAnimWindow2 // - -CTAnimWindow2::CTAnimWindow2(RAnimDll &aAnimDll) : CTBlankWindow(), - iAnim(aAnimDll) - { - } - -CTAnimWindow2::~CTAnimWindow2() - { - iAnim.Close(); - } - -void CTAnimWindow2::ConstructL(CTWinBase &parent, const TPoint &aPos, const TSize &aSize) - { - CTBlankWindow::ConstructL(parent); - iWin.SetColor(TRgb(128,128,128)); - iWin.SetVisible(EFalse); - SetExt(aPos,aSize); - iWin.Activate(); - User::LeaveIfError(iAnimBitmap1.Load(ANIM_BITMAP,EMbmTanimAnim1)); - User::LeaveIfError(iAnimBitmap2.Load(ANIM_BITMAP,EMbmTanimAnim2)); - User::LeaveIfError(iAnim.Construct(iWin, TPoint(10,10), &iAnimBitmap1, &iAnimBitmap2, &iAnimBitmap1, 1, iFont)); - iWin.SetVisible(ETrue); - } - -void CTAnimWindow2::ConstructExtLD(CTWinBase &aParent, const TPoint &aPos, const TSize &aSize) -// -// Call ConstructL, SetExt and either of these fail destroy this and leave -// - { - TRAPD(err,ConstructL(aParent, aPos, aSize)); - if (err!=KErrNone) - { - delete this; - User::Leave(err); - } - } - -// -// End of CTAnimWindow class // -// - -CTAnimWindowGroup::CTAnimWindowGroup(CTClient *aClient) : CTWindowGroup(aClient) - { - } - -void CTAnimWindowGroup::CursorKeyL(TInt xMove,TInt yMove,TInt modifiers) - { - if (iCursorMode==0) - iCurWin->AdjustSizeL(xMove,yMove,modifiers); - else if (iCurWin->SubType()==69) - { - if (iCursorMode==1) - ((CTAnimWindow1 *)iCurWin)->AdjustAnimRect(xMove,yMove,modifiers); - else - ((CTAnimWindow1 *)iCurWin)->AdjustPolyRectL(xMove,yMove,modifiers); - } - } - -void CTAnimWindowGroup::KeyL(const TKeyEvent &aKey,const TTime &aTime) - { - if (aKey.iModifiers&EModifierCtrl) - { - TInt type=0; - switch(aKey.iCode) - { - case 1: - type=1; - break; - case 2: - type=2; - break; - } - if (type!=0) - { - TPoint pos; - TSize size; - pos.iX=iCurWin->Size().iWidth>>2; - pos.iY=iCurWin->Size().iHeight>>2; - size.iWidth=iCurWin->Size().iWidth>>1; - size.iHeight=iCurWin->Size().iHeight>>1; - SetCurrentWindow(((CTAnimClient *)iClient)->CreateTestWindowL(pos,size,iCurWin,type)); - return; - } - } - if (aKey.iModifiers&EModifierFunc) - { - switch(aKey.iCode) - { - case 'x': - ((CTAnimClient *)iClient)->ExitL(); - break; - } - } - else switch(aKey.iCode) - { - case ' ': - iCursorMode=(iCursorMode+1)%3; - break; - case 8: - CTWin::Delete(iCurWin); - break; - case 9: - if (aKey.iModifiers&EModifierShift) - SetCurrentWindow(iCurWin->Prev()); - else - SetCurrentWindow(iCurWin->Next()); - break; - case 13: - if (iCurWin->SubType()==69) - ((CTAnimWindow1 *)iCurWin)->ToggleMask(); - break; - case EKeyLeftArrow: - CursorKeyL(-Xmove,0,aKey.iModifiers); - break; - case EKeyRightArrow: - CursorKeyL(Xmove,0,aKey.iModifiers); - break; - case EKeyUpArrow: - CursorKeyL(0,-Ymove,aKey.iModifiers); - break; - case EKeyDownArrow: - CursorKeyL(0,Ymove,aKey.iModifiers); - break; - default: - iCurWin->WinKeyL(aKey,aTime); - break; - } - } - -// - -CTAnimClient::CTAnimClient() - { - } - -CTBaseWin *CTAnimClient::CreateTestWindowL(TPoint pos,TSize size,CTWinBase *parent, TInt type) - { - CTBaseWin *win; - if (type==1) - { - win=new(ELeave) CTAnimWindow1(iAnimDll); - win->ConstructExtLD(*parent,pos,size); - win->Activate(); - } - else - { - win=new(ELeave) CTAnimWindow2(iAnimDll); - win->ConstructExtLD(*parent,pos,size); - } - win->AssignGC(*iGc); - return(win); - } - -CTAnimClient::~CTAnimClient() - { - DestroyWindows(); - iAnimDll.Close(); - } - -void CTAnimClient::ErrorTests() - { - RAnimDll animDll=RAnimDll(iWs); - if (animDll.Load(NONEXISTENT_DLL_NAME)!=KErrNotFound) - AnimPanic(EAnimPanicBadLoadFailed); - animDll.Close(); // Close should be harmless, but unnecassary - RAnimDll animDll2=RAnimDll(iWs); - if (animDll2.Load(NONEXISTENT_DLL_NAME)!=KErrNotFound) - AnimPanic(EAnimPanicBadLoadFailed); - } - -void CTAnimClient::ConstructL() - { - CTClient::ConstructL(); - - iGroup=new(ELeave) CTAnimWindowGroup(this); - iGroup->ConstructL(); - - ErrorTests(); - - iAnimDll=RAnimDll(iWs); - User::LeaveIfError(iAnimDll.Load(ANIM_DLL_NAME)); - - CreateTestWindowL(TPoint(30,20),TSize(220,140),iGroup, 1); - CreateTestWindowL(TPoint(260,60),TSize(60,40),iGroup, 2); - iGroup->SetCurrentWindow(iGroup->Child()); - } - -void CTAnimClient::ExitL() - { - CActiveScheduler::Stop(); - User::Leave(0); // Signals RunL not to do another Request() - } - -GLDEF_C CTClient *CreateClientL() - { - return(new(ELeave) CTAnimClient()); - } - -GLDEF_C TInt E32Main() - { - return(TestLibStartUp(CreateClientL)); - } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tanim/ANIM1.PBM Binary file windowing/windowserver/tanim/ANIM1.PBM has changed diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tanim/ANIM2.PBM Binary file windowing/windowserver/tanim/ANIM2.PBM has changed diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tanim/ANIMDLL.H --- a/windowing/windowserver/tanim/ANIMDLL.H Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,34 +0,0 @@ -// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Header defs for ANIMDLL -// -// - -struct CTAParams - { - TPoint pos; - TInt interval; - TInt bit1; - TInt bit2; - TInt mask; - TInt font; - }; - -enum AnimDllOpcodes - { - EADllOpcodeMove, - EADllOpcodePolyLineRect, - EADllToggleBitmapMask, - EADllTextPos, - }; diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tanim/MASK.PBM Binary file windowing/windowserver/tanim/MASK.PBM has changed diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tanim/TANIM.H --- a/windowing/windowserver/tanim/TANIM.H Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,23 +0,0 @@ -// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Generated by BitmapCompiler -// -// - -enum TMbmTanim - { - EMbmTanimAnim1, - EMbmTanimAnim2, - EMbmTanimMask - }; diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tanim/TANIMDLL.CPP --- a/windowing/windowserver/tanim/TANIMDLL.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,317 +0,0 @@ -// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Test Animated DLL -// -// - -#include -#include -#include -#include -#include "ANIMDLL.H" - -#define ANIM_TEST_TEXT _L("Testing 123") - -class CTestAnim : public CWindowAnim - { - enum {ENumPolyPoints=9}; -public: - ~CTestAnim(); - virtual void ConstructL(TAny *aArgs, TBool aHasFocus); - virtual void Animate(TDateTime *aDateTime); - virtual void Redraw(); - virtual void Command(TInt aOpcode, TAny *aArgs); - virtual TInt CommandReplyL(TInt aOpcode, TAny *aArgs); - void SetPolyList(const TRect &aRect); - void DrawPolyLine(); - void DrawBitmap(); - void DrawText(); - void TweakPolyList(TInt aState); - void FocusChanged(TBool aState); - void InvalidateText(); - void InvalidateBitmap(); - //Pure virtual function from MEventHandler - virtual TBool OfferRawEvent(const TRawEvent &aRawEvent); -private: - void AppendTime(TDes& aTimeText,const TTime& aTime) const; -private: - TPoint iPos; - TSize iSize; - TInt iColor; - TBool iMasked; - TRect iPolyRect; - TInt iPolyState; - TInt iWiggleSize; - TPoint iTextPos; - TBool iHasFocus; - CArrayFixFlat *iPolyList; - CFbsBitmap iBitmap1; - CFbsBitmap iBitmap2; - CFbsBitmap iMask; - CFbsFont *iFont; - }; - -class CTestAnimDll : public CAnimDll - { -public: - CAnim *CreateInstanceL(TInt aType); -private: - }; - -/*#if defined(__WINS__) -#pragma data_seg(".E32_UID") -__WINS_UID(0, KWservAnimDllUidValue, 0) -#pragma data_seg() -#endif*/ - -EXPORT_C CAnimDll *CreateCAnimDllL() - { - return(new(ELeave) CTestAnimDll()); - } - -// Instance code // - -void CTestAnim::Animate(TDateTime *) - { - if (!iWindowFunctions->IsHidden()) - { - iWindowFunctions->ActivateGc(); - if (iPolyList) - DrawPolyLine(); - } - if (iPolyList) - { - iPolyState=(iPolyState+1)%4; - TweakPolyList(iPolyState); - } - if (!iWindowFunctions->IsHidden()) - { - if (iPolyList) - DrawPolyLine(); - DrawText(); - DrawBitmap(); - } - iColor=(iColor+16)&0xFF; - } - -void CTestAnim::DrawPolyLine() - { - iGc->SetDrawMode(CGraphicsContext::EDrawModeXOR); - iGc->SetPenColor(TRgb(255,255,255)); - iGc->DrawPolyLine(iPolyList); - iGc->SetDrawMode(CGraphicsContext::EDrawModePEN); - iGc->SetPenColor(TRgb(0,0,0)); - } - -void CTestAnim::DrawBitmap() - { - iGc->SetClippingRegion(TRegionFix<1>(TRect(iPos,iSize))); - CFbsBitmap *bitmap=iFunctions->FlashStateOn() ? &iBitmap1 : &iBitmap2; - if (iMasked) - iGc->BitBltMasked(iPos,bitmap, TRect(iSize), &iMask,EFalse); - else - iGc->BitBlt(iPos,bitmap); - iGc->CancelClippingRegion(); - } - -void CTestAnim::AppendTime(TDes& aTimeText,const TTime& aTime) const - { - _LIT(TimeFormat,"%:0%H%:1%T%:2%S"); - TRAPD(err,aTime.FormatL(aTimeText,TimeFormat)); - if (err!=KErrNone) - { - _LIT(DummyTime,"######"); - aTimeText.Append(DummyTime); - } - } - -void CTestAnim::DrawText() - { - if (iHasFocus) - { - iGc->UseFont(iFont); - TBuf<0x20> timebuf; - TTime time(iFunctions->SystemTime()); - AppendTime(timebuf,time); - TRect rect(iTextPos.iX,iTextPos.iY-iFont->AscentInPixels(),iTextPos.iX+iFont->TextWidthInPixels(timebuf),iTextPos.iY-iFont->AscentInPixels()+iFont->HeightInPixels()); - iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - iGc->DrawText(timebuf,rect,iFont->AscentInPixels()); - time.UniversalTime(); - AppendTime(timebuf,time); - rect.Move(0,iFont->HeightInPixels()); - iGc->DrawText(timebuf,rect,iFont->AscentInPixels()); - } - } - -void CTestAnim::Redraw() - { - DrawText(); - DrawBitmap(); - if (iPolyList) - DrawPolyLine(); - } - -void CTestAnim::ConstructL(TAny *aArgs, TBool aHasFocus) - { - iHasFocus=aHasFocus; - iPos=((CTAParams *)aArgs)->pos; - iFunctions->SetInterval(((CTAParams *)aArgs)->interval); - if (iBitmap1.Duplicate(((CTAParams *)aArgs)->bit1)!=KErrNone || - iBitmap2.Duplicate(((CTAParams *)aArgs)->bit2)!=KErrNone || - iMask.Duplicate(((CTAParams *)aArgs)->mask)!=KErrNone) - iFunctions->Panic(); - iSize.iWidth=Min(iBitmap1.SizeInPixels().iWidth,iBitmap2.SizeInPixels().iWidth); - iSize.iHeight=Min(iBitmap1.SizeInPixels().iHeight,iBitmap2.SizeInPixels().iHeight); - iWiggleSize=10; - iFont=iFunctions->DuplicateFontL(((CTAParams *)aArgs)->font); - } - -void CTestAnim::SetPolyList(const TRect &aRect) - { - iPolyRect=aRect; - TSize halfsize=aRect.Size(); - halfsize.iWidth>>=1; - halfsize.iHeight>>=1; - (*iPolyList)[0]=aRect.iTl; - (*iPolyList)[1]=TPoint(aRect.iTl.iX+iWiggleSize,aRect.iTl.iY+halfsize.iHeight); - (*iPolyList)[2]=TPoint(aRect.iTl.iX,aRect.iBr.iY); - (*iPolyList)[3]=TPoint(aRect.iTl.iX+halfsize.iWidth,aRect.iBr.iY-iWiggleSize); - (*iPolyList)[4]=aRect.iBr; - (*iPolyList)[5]=TPoint(aRect.iBr.iX-iWiggleSize,aRect.iTl.iY+halfsize.iHeight); - (*iPolyList)[6]=TPoint(aRect.iBr.iX,aRect.iTl.iY); - (*iPolyList)[7]=TPoint(aRect.iTl.iX+halfsize.iWidth,aRect.iTl.iY+iWiggleSize); - (*iPolyList)[8]=aRect.iTl; - TweakPolyList(iPolyState); - } - -void CTestAnim::TweakPolyList(TInt aState) - { - TSize halfsize=iPolyRect.Size(); - halfsize.iWidth>>=1; - halfsize.iHeight>>=1; - switch(aState) - { - case 0: - (*iPolyList)[7]=TPoint(iPolyRect.iTl.iX+halfsize.iWidth,iPolyRect.iTl.iY+iWiggleSize); - (*iPolyList)[1]=TPoint(iPolyRect.iTl.iX,iPolyRect.iTl.iY+halfsize.iHeight); - break; - case 1: - (*iPolyList)[1]=TPoint(iPolyRect.iTl.iX+iWiggleSize,iPolyRect.iTl.iY+halfsize.iHeight); - (*iPolyList)[3]=TPoint(iPolyRect.iTl.iX+halfsize.iWidth,iPolyRect.iBr.iY); - break; - case 2: - (*iPolyList)[3]=TPoint(iPolyRect.iTl.iX+halfsize.iWidth,iPolyRect.iBr.iY-iWiggleSize); - (*iPolyList)[5]=TPoint(iPolyRect.iBr.iX,iPolyRect.iTl.iY+halfsize.iHeight); - break; - case 3: - (*iPolyList)[5]=TPoint(iPolyRect.iBr.iX-iWiggleSize,iPolyRect.iTl.iY+halfsize.iHeight); - (*iPolyList)[7]=TPoint(iPolyRect.iTl.iX+halfsize.iWidth,iPolyRect.iTl.iY); - break; - } - } - -void CTestAnim::InvalidateText() - { - TRect invalidate; - invalidate.iTl.iX=iTextPos.iX; - invalidate.iTl.iY=iTextPos.iY-iFont->AscentInPixels(); - invalidate.iBr.iX=iTextPos.iX+iFont->TextWidthInPixels(ANIM_TEST_TEXT); - invalidate.iBr.iY=iTextPos.iY+iFont->DescentInPixels(); - iWindowFunctions->Invalidate(invalidate); - } - -void CTestAnim::InvalidateBitmap() - { - iWindowFunctions->Invalidate(TRect(iPos,iSize)); - } - -void CTestAnim::Command(TInt aOpcode, TAny *aArgs) - { - switch(aOpcode) - { - case EADllOpcodeMove: - { - InvalidateBitmap(); - iPos=((CTAParams *)aArgs)->pos; - iWindowFunctions->ActivateGc(); - DrawBitmap(); - iFunctions->SetInterval(((CTAParams *)aArgs)->interval); - } - break; - case EADllTextPos: - { - InvalidateText(); - iTextPos=((CTAParams *)aArgs)->pos; - iWindowFunctions->ActivateGc(); - DrawText(); - } - break; - case EADllToggleBitmapMask: - iMasked=!iMasked; - InvalidateBitmap(); - break; - } - } - -TInt CTestAnim::CommandReplyL(TInt aOpcode, TAny *aArgs) - { - switch(aOpcode) - { - case EADllOpcodePolyLineRect: - iWindowFunctions->ActivateGc(); - if (!iPolyList) - { - iPolyList=new(ELeave) CArrayFixFlat(ENumPolyPoints); - TPoint zeropoint; - for(TInt i=0;iAppendL(zeropoint); - } - else - DrawPolyLine(); - SetPolyList(*((TRect *)aArgs)); - DrawPolyLine(); - break; - default: - iFunctions->Panic(); - } - return(KErrNone); - } - -CTestAnim::~CTestAnim() - { - delete iPolyList; - iFunctions->CloseFont(iFont); - } - -void CTestAnim::FocusChanged(TBool aNewState) - { - iHasFocus=aNewState; - InvalidateText(); - InvalidateBitmap(); - } - -TBool CTestAnim::OfferRawEvent(const TRawEvent &/*aRawEvent*/) - { - return EFalse; - } - -// DLL code // - -CAnim *CTestAnimDll::CreateInstanceL(TInt ) - { - return(new(ELeave) CTestAnim()); - } - -// Dummy E32Dll needed by E32 to build // - diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tanim/tanim.mbm Binary file windowing/windowserver/tanim/tanim.mbm has changed diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/AUTO.CPP --- a/windowing/windowserver/tauto/AUTO.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2543 +0,0 @@ -// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Automatically test the window server -// -// - - -#include -#include -#include -#include -#include "../tlib/testbase.h" -#include -#include "AUTO.H" - -LOCAL_D const TUint KPanicThreadHeapSize=0x8000; - -GLREF_C TInt ProcPriTestOtherProcess(TAny *aScreenNumber); -GLREF_C TInt ProcToKill(TAny *aScreenNumber); -GLREF_C TInt ProcDirect(TAny *aScreenNumber); -GLREF_C TInt ProcMultiDisplay(TAny *aScreenNumber); - -_LIT(Priority,"ProcPriTest"); -_LIT(ToKill,"ProcToKill"); -_LIT(Direct,"ProcDirect"); -_LIT(MultiDisplay,"ProcMultiDisplay"); - -CProcess::TInitialFunction CProcess::iFunctions[]= - { - TInitialFunction(Priority,ProcPriTestOtherProcess), - TInitialFunction(ToKill,ProcToKill), - TInitialFunction(Direct,ProcDirect), - TInitialFunction(MultiDisplay,ProcMultiDisplay) - }; - -GLDEF_D TestWindow *BaseWin; -GLDEF_D TestWindow *TestWin; -GLDEF_D TestClient *TheClient=NULL; -GLDEF_D CWindowGc *TheGc; -TInt CTestBase::iMaxGrays=0; -TInt CTestBase::iScreenNo=0; -TInt CTestBase::iMaxColors=0; -TInt CTestBase::iNumberTestsPass=0; -TInt CTestBase::iNumberTests=0; -TRect CTestBase::iNormalPointerCursorArea; -TPartialRedrawType CTestBase::iRedrawType=EPartialRedraw_Unknown; -TInt CTestBase::iNumberOfGrpWndsOnPrimaryScreenWithZeroPriority = 0; -TInt CTestDriver::iTestNum=0; - -GLDEF_D TInt TheTestResult=ETestPassed; // start with passed to anticipate empty test table - -const TInt KBorderWinWidth = 5; - -_LIT(Auto,"AUTO "); - -TInt64 TTestRects::iSeed=0; -TRect TTestRects::iList[]={ -// 0-5 - TRect(2,2,2,2), - TRect(2,2,2,2), - TRect(2,2,2,2), - TRect(2,2,2,2), - TRect(2,2,2,2), -// 5-13 - TRect(0,0,0,0), - TRect(2,0,2,0), - TRect(4,0,4,0), - TRect(0,2,0,2), - TRect(2,2,2,2), - TRect(4,2,4,2), - TRect(0,4,0,4), - TRect(2,4,2,4), - TRect(4,4,4,4), -// 13-22 - TRect(0,0,1,1), - TRect(1,0,3,1), - TRect(3,0,4,1), - TRect(0,1,1,3), - TRect(1,1,3,3), - TRect(3,1,4,3), - TRect(0,3,1,4), - TRect(1,3,3,4), - TRect(3,3,4,4), -// 23-31 - TRect(0,0,2,0), - TRect(2,0,4,0), - TRect(0,0,4,0), - TRect(0,2,2,2), - TRect(2,2,4,2), - TRect(0,2,4,2), - TRect(0,4,2,4), - TRect(2,4,4,4), - TRect(0,4,4,4), -// 32-40 - TRect(0,0,0,2), - TRect(0,2,0,4), - TRect(0,0,0,4), - TRect(2,0,2,2), - TRect(2,2,2,4), - TRect(2,0,2,4), - TRect(4,0,4,2), - TRect(4,2,4,4), - TRect(4,0,4,4), -// 41-44 - TRect(0,0,2,2), - TRect(2,0,4,2), - TRect(0,2,2,4), - TRect(2,2,4,4), -// 45-48 - TRect(0,0,3,3), - TRect(1,0,4,3), - TRect(0,1,3,4), - TRect(1,1,4,4), -// 49 - TRect(0,0,4,4), -// 40-53 - TRect(1,2,2,2), - TRect(2,2,3,2), - TRect(2,1,2,2), - TRect(2,2,3,2), -// 54-59 - TRect(1,2,3,2), - TRect(2,1,2,3), - TRect(1,1,2,2), - TRect(1,2,2,3), - TRect(2,2,3,3), - TRect(2,1,3,2), -// 60-63 - TRect(1,1,3,2), - TRect(1,1,2,3), - TRect(1,2,3,3), - TRect(2,1,3,3)}; - -#if defined(__WINS__) -void FindNonMatchingPixelL(TPoint aPt1,TPoint aPt2,TSize aSize) -// This function is purely for use when debugging to find the first non-matching pixel -// when a check of two on screen rects has failed. - { - HBufC8* buf1=HBufC8::NewMaxLC(2*aSize.iWidth); - HBufC8* buf2=HBufC8::NewMaxLC(2*aSize.iWidth); - TPtr8 ptr1=buf1->Des(); - TPtr8 ptr2=buf2->Des(); - TInt row=0; - TBool ret = true; - for (;rowiScreen->GetScanLine(ptr1,aPt1,aSize.iWidth,EColor64K); - TheClient->iScreen->GetScanLine(ptr2,aPt2,aSize.iWidth,EColor64K); - if (ptr1!=ptr2) - break; - ++aPt1.iY; - ++aPt2.iY; - } - TRgb color1,color2; - if (rowiScreen->GetPixel(color1,aPt1); - TheClient->iScreen->GetPixel(color2,aPt2); - if (color1!=color2) - { // Break here to find first pixel that didn't match. - TBuf<256> buf; - _LIT(KFindNonMatchingPixelFmt,"First non matching pixel (%d,%d)"); - buf.Format(KFindNonMatchingPixelFmt,col,row); - TheClient->iWs.LogMessage(buf); - break; - - } - ++aPt1.iX; - ++aPt2.iX; - } - } - CleanupStack::PopAndDestroy(2); - } - -void FindNonMatchingPixel(TPoint aPt1,TPoint aPt2,TSize aSize) - { - TRAPD(ignore,FindNonMatchingPixelL(aPt1,aPt2,aSize)); - } -#endif - -void AutoPanic(TInt aPanic) - { - User::Panic(_L("Auto"),aPanic); - } - -void CleanUpWindow(TAny *aWindow) - { - ((RWindowTreeNode *)aWindow)->Close(); - } - -void PushWindowL(RWindowTreeNode *aWindow) - { - CleanupStack::PushL(TCleanupItem(CleanUpWindow,aWindow)); - } - - -TBool OpacityAndAlphaSupportedL() - { - // If opacity is not implemented, EFalse will be returned - if(TransparencySupportedL()!=KErrNone) - return EFalse; - - const TRgb KTransparencyColor(0,0,0); - RWindow winb(TheClient->iWs); - CleanupClosePushL(winb); - RWindow wint(TheClient->iWs); - CleanupClosePushL(wint); - User::LeaveIfError(winb.Construct(*TheClient->iGroup->GroupWin(), ENullWsHandle)); - User::LeaveIfError(wint.Construct(*TheClient->iGroup->GroupWin(), ENullWsHandle)); - winb.SetExtent(TPoint(0,0), TSize(50,50)); - wint.SetExtent(TPoint(0,0), TSize(50,50)); - winb.SetRequiredDisplayMode(EColor256); - wint.SetRequiredDisplayMode(EColor256); - wint.SetTransparencyFactor(KTransparencyColor); - winb.SetBackgroundColor(TRgb(0,0,255)); - wint.SetBackgroundColor(TRgb(255,0,0)); - winb.Activate(); - wint.Activate(); - - wint.BeginRedraw(); - TheClient->iGc->Activate(wint); - TheClient->iGc->SetOpaque(ETrue); - TheClient->iGc->SetPenStyle(CGraphicsContext::ENullPen); - TheClient->iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - TheClient->iGc->SetBrushColor(TRgb(0,255,0)); - TheClient->iGc->DrawRect(TRect(TPoint(0,0), TSize(50,50))); - TheClient->iGc->SetOpaque(EFalse); - TheClient->iGc->Deactivate(); - wint.EndRedraw(); - TheClient->Flush(); - - // The window should be all green, if opacity is working, or all blue if it isn't. - // If the window has any other colour, then something has broken. - TRgb color; - TheClient->iScreen->GetPixel(color,TPoint(25,25)); - if (color.Red()>0 || ((color.Green()==0) == (color.Blue()==0))) - User::Leave(KErrGeneral); - TBool ret=(color.Green()>0); - - CleanupStack::PopAndDestroy(2,&winb); // wint - return ret; - } - -TInt TransparencySupportedL() - { - // Creates a window and enables alpha transparency, if this feature - // is not enabled, KErrNotSupported will be returned - RWindow win(TheClient->iWs); - User::LeaveIfError(win.Construct(*TheClient->iGroup->GroupWin(), ENullWsHandle)); - win.SetExtent(TPoint(0,0), TSize(50,50)); - TInt ret=win.SetTransparencyAlphaChannel(); - win.Close(); - return ret; - } - -TInt CheckScalingSupportedOrNot() - { - TBool scalingSupported=EFalse; - TSizeMode originalModeData=TheClient->iScreen->GetCurrentScreenModeAttributes(); - TSizeMode tempData=originalModeData; - tempData.iScreenScale=TSize(2,2); - TheClient->iScreen->SetCurrentScreenModeAttributes(tempData); - TSize scale=TheClient->iScreen->GetCurrentScreenModeScale(); - if (scale.iWidth==2 && scale.iHeight==2) - { - scalingSupported=ETrue; - } - TheClient->iScreen->SetCurrentScreenModeAttributes(originalModeData); - TheClient->Flush(); - return scalingSupported; - } - -TBool CheckNonZeroOriginsSupportedOrNot() - { - TBool nonZeroOriginsSupported=EFalse; - TSizeMode sizeMode1=TheClient->iScreen->GetCurrentScreenModeAttributes(); - TSizeMode sizeMode2=sizeMode1; - sizeMode2.iOrigin=TPoint(30,30); - TheClient->iScreen->SetCurrentScreenModeAttributes(sizeMode2); - TPoint origin=TheClient->iScreen->GetCurrentScreenModeScaledOrigin(); - if (origin.iX==30 && origin.iY==30) - { - nonZeroOriginsSupported=ETrue; - } - TheClient->iScreen->SetCurrentScreenModeAttributes(sizeMode1); - TheClient->Flush(); - return nonZeroOriginsSupported; - } - -TPoint PhysicalToLogical(TPoint aPhysicalPtMinusOrigin,TSize aScale) - { - TPoint logicalPt(aPhysicalPtMinusOrigin); - if (aScale.iWidth!=1) - { - logicalPt.iX=(logicalPt.iX>= 0 ? logicalPt.iX/aScale.iWidth : (logicalPt.iX-(aScale.iWidth-1))/aScale.iWidth); - } - if (aScale.iHeight!=1) - { - logicalPt.iY=(logicalPt.iY>= 0 ? logicalPt.iY/aScale.iHeight : (logicalPt.iY-(aScale.iHeight-1))/aScale.iHeight); - } - return logicalPt; - } - -// -// Log window, logs testing // -// - -LogWindow::LogWindow() : CTWin(), iTestTitle(KNullDesC), iSubTitle(KNullDesC), iMessage(KNullDesC) - {} - -void LogWindow::ConstructL(CTWinBase &parent) - { - CTWin::ConstructL(parent); - iTitleHeight=iFont->HeightInPixels()+4; - } - -void LogWindow::DrawSubTitle() - { - iGc->DrawText(iSubTitle, TRect(2,iTitleHeight*2,iSize.iWidth-2,iTitleHeight*3),iFont->AscentInPixels(), CGraphicsContext::ECenter); - } - -void LogWindow::DrawMessage() - { - iGc->DrawText(iMessage, TRect(1,iTitleHeight*4,iSize.iWidth-2,iTitleHeight*5),iFont->AscentInPixels(), CGraphicsContext::ECenter); - } - -void LogWindow::Draw() - { - iGc->SetPenColor(TRgb::Gray16(8)); - iGc->SetPenColor(TRgb::Gray16(0)); - DrawBorder(); - iGc->DrawLine(TPoint(0,iTitleHeight),TPoint(iSize.iWidth,iTitleHeight)); - iGc->DrawText(iTestTitle, TPoint((iSize.iWidth-iFont->TextWidthInPixels(iTestTitle))/2,iFont->AscentInPixels()+2)); - DrawSubTitle(); - DrawMessage(); - } - -/** -This function is not used at the moment but I leave it in in case I need it when I improve the logging in -the log window. -*/ -void LogWindow::LogTest(const TDesC &aTitle,TInt aNum) - { - _LIT(Test,"Test %d,%S"); - iTestTitle.Format(Test,aNum,&aTitle); - TLogMessageText buf; - _LIT(AutoNewTest,"AUTO New Test: "); - buf.Append(AutoNewTest); - buf.Append(iTestTitle); - TheClient->LogMessage(buf); - iMessage.Zero(); - iWin.Invalidate(); - } - -/** -This function is not used at the moment but I leave it in in case I need it when I improve the logging in -the log window. -*/ -const TDesC& LogWindow::LogSubTest(const TDesC &aTitle,TInt aNum) - { - _LIT(SubTest,"Sub-Test[%d], %S"); - iSubTitle.Format(SubTest,aNum,&aTitle); - TLogMessageText buf; - buf.Append(Auto); - buf.Append(iSubTitle); - TheClient->LogMessage(buf); - iMessage.Zero(); - iGc->Activate(iWin); - iGc->UseFont((CFont *)iFont); - iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - DrawSubTitle(); - DrawMessage(); - iGc->Deactivate(); - TheClient->iWs.Flush(); - return iSubTitle; - } - -const TDesC& LogWindow::LogMessage(TBool aLog,const TDesC& aText,TInt aNum) - { - if (aNum!=EDummyValue) - { - _LIT(StringInt,"%S %d"); - iMessage.Format(StringInt,&aText,aNum); - } - else - { - _LIT(String,"%S"); - iMessage.Format(String,&aText); - } - iGc->Activate(iWin); - iGc->UseFont((CFont *)iFont); - iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - DrawMessage(); - iGc->Deactivate(); - if (aLog) - { - TLogMessageText buf; - buf.Append(Auto); - buf.Append(iMessage); - TheClient->LogMessage(buf); - } - TheClient->iWs.Flush(); - return iMessage; - } - - -// -// Test window, simple window used to do test graphics in // -// -TestWindow::TestWindow() : CTWin() - { - } - -TestWindow::~TestWindow() - { - delete iBorderWin; - } - -void TestWindow::SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc) - { - iBorderWin=new(ELeave) CBorderWindow(); - iBorderWin->SetUpL(pos,size,parent,aGc); - TRAPD(err, CTWin::ConstructL(*iBorderWin)); - if (err==KErrNone) - { - SetExt(TPoint(2,2),TSize(size.iWidth-4,size.iHeight-4)); - if (err==KErrNone) - { - Activate(); - AssignGC(aGc); - return; - } - } - delete this; - User::Leave(err); - } - -void TestWindow::Draw() - { - iGc->Clear(); - } - -void TestWindow::ClearWin() - { - TheGc->Activate(*Win()); - TheGc->Clear(); - TheGc->Deactivate(); - } - -void TestWindow::SetBorderExt(TPoint aPos, TSize aSize) - { - iBorderWin->SetExt(aPos, aSize); - } - -CBorderWindow* TestWindow::GetBorderWin() - { - return iBorderWin; - } -// -CBorderWindow::CBorderWindow() : CTWin() - { - } - -void CBorderWindow::ConstructL(CTWinBase &parent) - { - CTWin::ConstructL(parent); - } - -void CBorderWindow::Draw() - { - iGc->SetBrushColor(TRgb::Gray16(0)); - iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - iGc->SetPenStyle(CGraphicsContext::ENullPen); - iGc->DrawRect(TRect(Size())); - } - -// - -TestWindowGroup::TestWindowGroup(CTClient *aClient) : CTWindowGroup(aClient) - { - } - -void TestWindowGroup::BecomeOwning() - { - iGroupWin.DefaultOwningWindow(); - } - -void TestWindowGroup::KeyL(const TKeyEvent &aKey,const TTime &aTime) - { - if (aKey.iModifiers&EModifierFunc) - { - switch(aKey.iCode) - { - case 'f': - TheClient->Driver()->iTest->TriggerFail(); - break; - } - } - else if (iCurWin) - iCurWin->WinKeyL(aKey,aTime); - } - -void TestWindowGroup::KeyDownL(const TKeyEvent &aKey,const TTime &aTime) - { - if (iCurWin) - iCurWin->KeyDownL(aKey,aTime); - } - -void TestWindowGroup::KeyUpL(const TKeyEvent &aKey,const TTime &aTime) - { - if (iCurWin) - iCurWin->KeyUpL(aKey,aTime); - } - -// - -TestClient::TestClient() - {} - -void TestClient::ConstructL() - { - CTClient::ConstructL(); - - iGroup=new(ELeave) TestWindowGroup(this); - iGroup->ConstructL(); - - iScreen->GetScreenSizeModeList(&iScreenModes); - iScreen->SetScreenMode(iScreenModes[0]); - TSize screenSize=iScreen->SizeInPixels(); - - TInt winWidth=(screenSize.iWidth/3)-10; - TInt winHeight=screenSize.iHeight-10; - iStdLogWindow=new(ELeave) LogWindow(); - iStdLogWindow->SetUpL(TPoint(5,5),TSize(winWidth,winHeight),iGroup,*iGc); - BaseWin=new(ELeave) TestWindow(); - BaseWin->SetUpL(TPoint(screenSize.iWidth/3+5,5),TSize(winWidth,winHeight),iGroup,*iGc); - TestWin=new(ELeave) TestWindow(); - TestWin->SetUpL(TPoint(screenSize.iWidth/3*2+5,5),TSize(winWidth,winHeight),iGroup,*iGc); - - iDriver = CTestDriver::CreateL(iScreenNumber); // virtual constructor - - TheGc=new(ELeave) CWindowGc(iScreen); - User::LeaveIfError(TheGc->Construct()); - - _LIT(KTestLog,"WSERV Auto Test Log"); - LogMessage(KTestLog()); - LogAvailableScreenModeL(); - - //This class was designed to be created once and reused by all the tests, now it is created for each test, - //this needs to be changed back so tests like the following are only done once. - TestWsSetBufferSizeL(); - TestWsSetMaxBufferSizeL(); - } - -inline CTestDriver* TestClient::Driver() - { - return iDriver; - } - -TBool TestClient::WaitForEvent() - { - if (iEventHandler->iStatus!=KRequestPending) - return ETrue; - else if (iRedrawEventHandler->iStatus!=KRequestPending) - return EFalse; - User::WaitForRequest(iEventHandler->iStatus,iRedrawEventHandler->iStatus); - TRequestStatus* status=&iEventHandler->iStatus; - TBool ret=ETrue; - if (iEventHandler->iStatus==KRequestPending) - { - status=&iRedrawEventHandler->iStatus; - ret=EFalse; - } - TInt reason=status->Int(); - *status=KRequestPending; - User::RequestComplete(status,reason); - return ret; - } - -TBool TestClient::IsEventWaiting() - { - return (iEventHandler->iStatus!=KRequestPending || iRedrawEventHandler->iStatus!=KRequestPending); - } - -TestClient::~TestClient() - { - iScreenModes.Close(); - delete iDriver; - delete TheGc; - delete iStdLogWindow; - delete BaseWin; - delete TestWin; - } - -void TestClient::LogAvailableScreenModeL() - { - _LIT(KColorModes,"Color Modes: "); - _LIT(KComma,", "); - _LIT(KColor,"Color"); - _LIT(KGrey,"Grey"); - CArrayFixFlat* modeList=new(ELeave) CArrayFixFlat(15); - iWs.GetColorModeList(modeList); - TLogMessageText buf,buf2; - buf.Append(KColorModes); - TDisplayMode mode; - TInt ii=0; - FOREVER - { - mode=STATIC_CAST(TDisplayMode,(*modeList)[ii]); - buf.AppendNum((*modeList)[ii]); - buf2.Append(TDisplayModeUtils::IsDisplayModeColor(mode)?KColor():KGrey()); - buf2.AppendNum(TDisplayModeUtils::NumDisplayModeColors(mode)); - if (mode==EColor16MU) - buf2.Append('U'); - if (++ii==modeList->Count()) - break; - buf.Append(KComma); - buf2.Append(KComma); - } - LogMessage(buf); - LogMessage(buf2); - delete modeList; - } - -void TestClient::TestWsSetBufferSizeL() - { - RWsSession ws; - User::LeaveIfError(ws.Connect()); - ws.SetBufferSizeL(256); // default buffer size 640 - ws.SetBufferSizeL(0x8000); // 16K is max buffer size - ws.SetBufferSizeL(0x4000); - ws.Close(); - } - -void TestClient::TestWsSetMaxBufferSizeL() - { - RWsSession ws; - User::LeaveIfError(ws.Connect()); - // allow buffer to grow bigger than the default 640 bytes - const TInt KBigMessageSize = 800; - ws.SetMaxBufferSizeL(KBigMessageSize + 8); // big message + command header length - - // send the big message to the wserv - TBuf8 bigMessage; - - // LogMessage needs a pointer to a TInt with the message size at the start of the buffer - const TInt szLength = sizeof(TInt); - TInt length = KBigMessageSize - szLength; // length in Unicode characters - bigMessage.Append((TUint8*) &length, szLength); - - _LIT(KLetterA, "a"); - do - { - bigMessage.Append((TUint8*) KLetterA().Ptr(), 2); - } - while (bigMessage.Length() < KBigMessageSize); - - // send to Wserv, note that the message is too long to be logged - ws.TestWrite(ws.WsHandle(), EWsClOpLogMessage, bigMessage.Ptr(), KBigMessageSize); - ws.Flush(); - - ws.Close(); - } - -void TestClient::SetTestClientScreenMode(TInt aMode) - { - iScreen->SetAppScreenMode(aMode); - iScreen->SetScreenMode(aMode); - UpdateTestClientScreenMode(); - } - -void TestClient::UpdateTestClientScreenMode() - { - TSize screenSize=iScreen->SizeInPixels(); - - // Sets new positions and dimensions for the three window and their controlling border windows - - if (screenSize.iHeight > screenSize.iWidth) // Portrait mode - { - TInt winWidth=screenSize.iWidth - (KBorderWinWidth * 2); - TInt winHeight=(screenSize.iHeight/3) - (KBorderWinWidth * 2); - - iStdLogWindow->SetExt(TPoint(KBorderWinWidth,KBorderWinWidth),TSize(winWidth,winHeight)); - BaseWin->SetBorderExt(TPoint(KBorderWinWidth,screenSize.iHeight/3+KBorderWinWidth),TSize(winWidth,winHeight)); - BaseWin->SetExt(TPoint(2,2),TSize(winWidth - (KBorderWinWidth - 1),winHeight - (KBorderWinWidth - 1))); - TestWin->SetBorderExt(TPoint(KBorderWinWidth,screenSize.iHeight/3*2+KBorderWinWidth),TSize(winWidth,winHeight)); - TestWin->SetExt(TPoint(2,2),TSize(winWidth - (KBorderWinWidth - 1),winHeight - (KBorderWinWidth - 1))); - } - else // Landscape modes - { - TInt winWidth=(screenSize.iWidth/3) - (KBorderWinWidth * 2); - TInt winHeight=screenSize.iHeight - (KBorderWinWidth * 2); - - iStdLogWindow->SetExt(TPoint(KBorderWinWidth,KBorderWinWidth),TSize(winWidth,winHeight)); - BaseWin->SetBorderExt(TPoint(screenSize.iWidth/3 + KBorderWinWidth,KBorderWinWidth),TSize(winWidth,winHeight)); - BaseWin->SetExt(TPoint(2,2),TSize(winWidth - (KBorderWinWidth - 1),winHeight - (KBorderWinWidth - 1))); - TestWin->SetBorderExt(TPoint(screenSize.iWidth/3*2+KBorderWinWidth,KBorderWinWidth),TSize(winWidth,winHeight)); - TestWin->SetExt(TPoint(2,2),TSize(winWidth - (KBorderWinWidth - 1),winHeight - (KBorderWinWidth - 1))); - } - - // Remove shading artefacts from window resizing operations - TestWin->Win()->Invalidate(); - TestWin->Win()->BeginRedraw(); - TestWin->ClearWin(); - TestWin->Win()->EndRedraw(); - - BaseWin->Win()->Invalidate(); - BaseWin->Win()->BeginRedraw(); - BaseWin->ClearWin(); - BaseWin->Win()->EndRedraw(); - - TheClient->iWs.Flush(); - } - - -// -// TestDriver, drives the test code // -// -CTestDriver* CTestDriver::CreateL(TInt aScreenNumber) - { - CTestDriver* self = NULL; - if (aScreenNumber==KDefaultScreen) - self = new (ELeave) CTestDriverPrimary(aScreenNumber); - else - self = new (ELeave) CTestDriverSecondary(aScreenNumber); - - return self; - } - -CTestDriver::CTestDriver(TInt aScreenNumber) - : iScreenNumber(aScreenNumber) - { - iStartTime.HomeTime(); - HAL::Get(HALData::EDisplayNumberOfScreens, iNumberOfScreens); - } - -CTestDriver::~CTestDriver() - { - } - -void CTestDriver::DestroyTest() - { - delete iTest; - iTest=NULL; - } - -void CTestDriver::TestComplete2() - { - ++iTestNum; - if (iTestNum==iTestSize) - { - TBuf<64> timeBuf; - TTime endTime; - endTime.HomeTime(); - TTimeIntervalMicroSeconds elapseTime=endTime.MicroSecondsFrom(iStartTime); - TInt64 elapseTime2=elapseTime.Int64()/1000; - TUint diffi = I64LOW(elapseTime2); - _LIT(TestPass,"PASSED"); - _LIT(TestFail,"FAILED"); - TInt noOfTests=CTestBase::iNumberTests; - TInt noOfTestsPass=CTestBase::iNumberTestsPass; - _LIT(TimeBuf,"Elapse Time %d:%02d.%03d %S"); - timeBuf.Format(TimeBuf,diffi/60000,(diffi/1000)%60,diffi%1000000,&(noOfTests==noOfTestsPass?TestPass:TestFail)); - TBuf<60> testReport; - _LIT(Checks,"Checks"); - _LIT(Fails,"Fails"); - _LIT(TestReport,"Tests:%d %S:%d"); - TInt testNumber=(noOfTests==noOfTestsPass? noOfTestsPass : noOfTests-noOfTestsPass); - testReport.Format(TestReport,iTestNum,&(noOfTests==noOfTestsPass?Checks():Fails()),testNumber); - if (noOfTests!=noOfTestsPass) - { - _LIT(NumTests,"/%d"); - testReport.AppendFormat(NumTests,noOfTests); - } - - TBuf<60> logTestReport; - _LIT(LogReport," %S:%d/%d"); - logTestReport.Format(LogReport,&Checks,noOfTestsPass,noOfTests); - TLogMessageText buf; - _LIT(Finished,"AUTO Testing Complete, "); - buf.Append(Finished); - buf.Append(timeBuf); - buf.Append(logTestReport); - TheClient->LogMessage(buf); - - TheTestResult = noOfTests==noOfTestsPass? ETestPassed : ETestFailed; - DoDisplayDialog(timeBuf,testReport); - } - } - -// -// Test driver for primary screen (has digitiser/pointer) -// -CTestDriverPrimary::CTestDriverPrimary(TInt aScreenNumber) : CTestDriver(aScreenNumber) - { - TInt i; - TInt numOfEntries = 1; - for (i=0; i1); - if (aTl>aBr) - { - TInt tmp=aBr; - aBr=aTl; - aTl=tmp; - } - } - -TRect TTestRects::operator[](TInt aIndex) - { - TRect rect; - if (aIndexiTl.iX==pRect->iBr.iX) - RectCoordPair(rect.iTl.iX,rect.iBr.iX,pRect->iTl.iX,iSize.iWidth); - else - { - rect.iTl.iX=RectCoord(pRect->iTl.iX,iSize.iWidth); - rect.iBr.iX=RectCoord(pRect->iBr.iX,iSize.iWidth); - } - if (pRect->iTl.iY==pRect->iBr.iY) - RectCoordPair(rect.iTl.iY,rect.iBr.iY,pRect->iTl.iY,iSize.iHeight); - else - { - rect.iTl.iY=RectCoord(pRect->iTl.iX,iSize.iHeight); - rect.iBr.iY=RectCoord(pRect->iBr.iX,iSize.iHeight); - } - } - else if (aIndexConstructL(aHandle, aSizeInPixels, aDispMode); - return self; - } - -void CBitmap::ConstructL(TInt aHandle,const TSize& aSizeInPixels,TDisplayMode aDispMode) - { - iBitmap=new(ELeave) CFbsBitmap(); - if (aHandle==0) - { - User::LeaveIfError(iBitmap->Create(aSizeInPixels,aDispMode)); - } - else - { - User::LeaveIfError(iBitmap->Duplicate(aHandle)); - } - iDevice=CFbsBitmapDevice::NewL(iBitmap); - User::LeaveIfError(iDevice->CreateContext(iGc)); - } - -CBitmap::~CBitmap() - { - delete iGc; - delete iDevice; - delete iBitmap; - } - - -// CTestBase // - -CTestBase::CTestBase(const TDesC& aTitle,CTWsGraphicsBase* aTestBase) - { - iTestBase=aTestBase; - iTitle.Copy(aTitle); - - iScreenNo = iTestBase->GetScreenFromIni(); - - TheClient=new(ELeave) TestClient(); - - if (CTestBase::iScreenNo == 1) - { - TheClient->SetScreenNumber(1); - iScreenNumber = 1; - } - else - { - TheClient->SetScreenNumber(0); - iScreenNumber = 0; - } - - if (iScreenNumber == 1) - { - iMinWin = new(ELeave) CMinWin(iScreenNumber); - iMinWin->ConstructL(); - } - - iTestNum=CTestDriver::iTestNum; - TheClient->ConstructL(); - TheClient->StdLogWindow().LogTest(iTitle,iTestNum); - iDriver=TheClient->Driver(); - - if (CTestBase::iScreenNo == 1) - { - TheClient->iWs.SetFocusScreen(1); - } - else - { - TheClient->iWs.SetFocusScreen(0); - } - - iTestRects.Construct(*BaseWin->Win()); - iStdTestWindowSize=BaseWin->Size(); - iRedrawType=EPartialRedraw_Unknown; // Reset between tests - if (iMaxGrays+iMaxColors==0) - { - TheClient->iWs.GetDefModeMaxNumColors(iMaxColors,iMaxGrays); - iNormalPointerCursorArea=TheClient->iWs.PointerCursorArea(); - } - } - -CTestBase::~CTestBase() - { - delete iMinWin; - delete TheClient; - } - -void CTestBase::CloseAllPanicWindows() - { - TInt idFocus = TheClient->iWs.GetFocusWindowGroup(); - TWsEvent event; - event.SetType(EEventKey); - TKeyEvent *keyEvent = event.Key(); - keyEvent->iCode = EKeyEscape; - keyEvent->iScanCode = EStdKeyEscape; - keyEvent->iModifiers = 0; - TInt theLimit = 50; - while(idFocus != NULL && (theLimit-- > 0)) - { - TheClient->iWs.SendEventToAllWindowGroups(event); - idFocus = TheClient->iWs.GetFocusWindowGroup(); - } - } - -/** -Returns the size of the standard test windows. -@see iStdTestWindowSize -*/ -const TSize& CTestBase::StdTestWindowSize() - { - return iStdTestWindowSize; - } - -/** Returns the number of greys available in the richest grey mode */ -TInt CTestBase::MaxGrays() const - { - return iMaxGrays; - } - -/** Returns the number of colours available in the richest supported colour mode. */ -TInt CTestBase::MaxColors() const - { - return iMaxColors; - } - -void CTestBase::TriggerFail() - { - iFail=ETrue; - } - -void CTestBase::LogLeave(TInt aErr) - { - TLogMessageText buf; - _LIT(Leave,"AUTO Left with error code %d in "); - buf.AppendFormat(Leave,aErr); - buf.Append(iSubTitle); - TheClient->LogMessage(buf); - } - -void CTestBase::LogSubTest(const TDesC &aSubTitle) - { - Driver()->iSubTestNum++; - iSubTitle=aSubTitle; - iTestBase->Logger().Write(TheClient->StdLogWindow().LogSubTest(aSubTitle,iState)); - } - -void CTestBase::LogMessage(TInt aValue) - { - _LIT(WinID,"Win Id:"); - TheClient->StdLogWindow().LogMessage(EFalse,WinID,aValue); - } - -void CTestBase::LogSubState(TInt aSubState) - { - _LIT(SubTest,"SubState"); - iTestBase->Logger().Write(TheClient->StdLogWindow().LogMessage(ETrue,SubTest,aSubState)); - } - -TBool DoCheckRectRWin(RWindowBase &aWin1,RWindowBase &aWin2,const TRect &aRect) - { - TRect rect1(aRect); - TRect rect2(aRect); - rect1.Move(aWin1.InquireOffset(*TheClient->iGroup->WinTreeNode())); - rect2.Move(aWin2.InquireOffset(*TheClient->iGroup->WinTreeNode())); - TBool match=TheClient->iScreen->RectCompare(rect1,rect2); -#if defined(__WINS__) - if (!match) - FindNonMatchingPixel(rect1.iTl,rect2.iTl,aRect.Size()); -#endif - return match; - } - -TBool DoCheckRectRWin(RWindowBase &aWin1,RWindowBase &aWin2,const TRect &aRect, TUint aFlags) - { - TRect rect1(aRect); - TRect rect2(aRect); - rect1.Move(aWin1.InquireOffset(*TheClient->iGroup->WinTreeNode())); - rect2.Move(aWin2.InquireOffset(*TheClient->iGroup->WinTreeNode())); - TBool match=TheClient->iScreen->RectCompare(rect1,rect2, aFlags); -#if defined(__WINS__) - if (!match) - FindNonMatchingPixel(rect1.iTl,rect2.iTl,aRect.Size()); -#endif - return match; - } - -TBool DoCheckRect(CTBaseWin *aWin1,CTBaseWin *aWin2,const TRect &aRect) - { - return DoCheckRectRWin(*aWin1->BaseWin(), *aWin2->BaseWin(), aRect); - } - -TBool DoCheckRect(CTBaseWin *aWin1,CTBaseWin *aWin2) - { - TSize winSize=aWin1->Size(); - TRect rect1(aWin1->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),winSize); - TRect rect2(aWin2->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),winSize); - return TheClient->iScreen->RectCompare(rect1,rect2); - } - -TBool DoCheckRect(CTBaseWin *aWin1, CTBaseWin *aWin2, const TRect &aRect, TUint aFlags) - { - return DoCheckRectRWin(*aWin1->BaseWin(), *aWin2->BaseWin(), aRect, aFlags); - } - - -/** -Compares the contents of 2 rectangular areas of the screen. - -@param aPos1 The top left corner of the first rectangle. -@param aPos2 The top left corner of the second rectangle. -@param aSize The size of the rectangles -@return ETrue if the 2 areas have the same content, EFalse otherwise. -*/ -TBool DoCheckRect(TPoint aPos1,TPoint aPos2,TSize aSize) - { - return TheClient->iScreen->RectCompare(TRect(aPos1,aSize),TRect(aPos2,aSize)); - } - -void CTestBase::DrawTestBackground(TBool aInvertColors, const TSize &aSize, TInt aGrays/*=16*/) -// -// Draws a standard test background with a mix of colors (shades). -// This is mainly used to test for graphic functions writing outside the intended area. -// -// This code assumes an TheGc is already active on the window to use. -// - { - TheGc->SetBrushColor(TRgb::Gray256(255)); - TInt step=5; - TInt col=0; - TInt colorInc=(aGrays>9 ? 17 : 85); - TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - TheGc->SetPenStyle(CGraphicsContext::ENullPen); - for(TInt row=0;rowSetBrushColor(TRgb::Gray256(aInvertColors ? 255-col:col)); - TheGc->DrawRect(TRect(0,row,aSize.iWidth,row+step)); - col=col+colorInc; - if (col>255) - col=0; - } - } - -void CTestBase::AbortL() - { - CTestDriver* driver=iDriver; - iDriver->DestroyTest(); - driver->TestComplete2(); - User::Leave(ETestFailed); - } - -/*CTWsGraphicsBase*/ - -CTWsGraphicsBase::CTWsGraphicsBase(CTestStep* aStep) : CTGraphicsBase(aStep) - { - } - -CTWsGraphicsBase::~CTWsGraphicsBase() - { - delete iTest; - } - -void CTWsGraphicsBase::CreateTestBaseL(CTTMSGraphicsStep* aTmsStep) - { - __ASSERT_ALWAYS(iTest==NULL,AutoPanic(EAutoPanicRecalledCreateTestBaseL)); - iTest=new(ELeave) CTestBase(iStep->TestStepName(),this); - iTmsStep = aTmsStep; - } -/** -Gets the Screen Number from an .ini file supplied to the RUN_TEST_STEP. Screen number should -be put under the section [useScreen] as screen=0 or screen=1. - -@return Screen number Defined in .ini file, otherwise 0. -*/ -TInt CTWsGraphicsBase::GetScreenFromIni() const - { - _LIT(KUseScreenSection, "useScreen"); - _LIT(KScreen, "screen"); - - TInt screen = 0; - TBool configAvailable = iStep->GetIntFromConfig(KUseScreenSection, KScreen, screen); - if(configAvailable) - { - return screen; - } - else - { - return 0; - } - } - -void CTWsGraphicsBase::TestComplete() - { - _LIT(KTestComplete,"Test complete"); - INFO_PRINTF1(KTestComplete); - CTGraphicsBase::TestComplete(); - } - -void CTWsGraphicsBase::LogMessage(const TText8* aFile,TInt aLine,TRefByValue aFmt,...) - { - TLogMessageText buf; - VA_LIST list; - VA_START(list,aFmt); - buf.AppendFormatList(aFmt,list); - TheClient->LogMessage(buf); - Logger().LogExtra(aFile,aLine,ESevrInfo,buf); - VA_END(list); - } - -TBool CTWsGraphicsBase::CheckRetValue(TBool aPass, const TDesC *aErrorMsg, const TDesC &aErrorFunction) - { - if (!aPass && aErrorMsg) - { - LOG_MESSAGE3(_L("%S %S failed"),aErrorMsg,&aErrorFunction); - iTmsStep->MQCTest(EFalse,((TText8*)__FILE__),__LINE__); - } - iStep->TEST(aPass); - return aPass; - } - -void CTWsGraphicsBase::CompareWindowsSoftFailWinscw(const TText8* aFile, TInt aLine) - { - if (!DoCheckRect(BaseWin, TestWin, BaseWin->Size())) - { -#ifdef __WINS__ - _LIT(KMessage,"ERROR: Test Failed but is ignored on WINSCW"); - Logger().LogExtra(aFile, aLine, ESevrErr, KMessage); -#else // __WINS__ - iStep->TEST(EFalse); - _LIT(KMessage,"ERROR: Test Failed"); - Logger().LogExtra(aFile, aLine, ESevrErr, KMessage); -#endif // __WINS__ - } - } - -void CTWsGraphicsBase::CheckRect(TPoint aPos1,TPoint aPos2,TSize aSize, const TDesC *aErrorMsg) - { - CheckRetValue(DoCheckRect(aPos1,aPos2,aSize),aErrorMsg,_L("CheckRect()")); - } - -void CTWsGraphicsBase::CheckRect(TPoint aPos1,TPoint aPos2,TSize aSize, const TDesC &aErrorMsg) - { - CheckRect(aPos1,aPos2,aSize,&aErrorMsg); - } - -void CTWsGraphicsBase::CheckRectNoMatch(TPoint aPos1,TPoint aPos2,TSize aSize, const TDesC *aErrorMsg) - { - CheckRetValue(!DoCheckRect(aPos1,aPos2,aSize),aErrorMsg,_L("CheckRectNoMatch()")); - } - -void CTWsGraphicsBase::CheckRectNoMatch(TPoint aPos1,TPoint aPos2,TSize aSize, const TDesC &aErrorMsg) - { - CheckRectNoMatch(aPos1,aPos2,aSize,&aErrorMsg); - } - -void CTWsGraphicsBase::CheckRect(CTBaseWin *aWin1,CTBaseWin *aWin2, const TDesC *aErrorMsg) - { - CheckRetValue(DoCheckRect(aWin1,aWin2),aErrorMsg,_L("CheckRect()")); - } - -void CTWsGraphicsBase::CheckRect(CTBaseWin *aWin1,CTBaseWin *aWin2, const TDesC &aErrorMsg) - { - CheckRect(aWin1,aWin2,&aErrorMsg); - } - -void CTWsGraphicsBase::CheckRectNoMatch(CTBaseWin *aWin1,CTBaseWin *aWin2, const TDesC *aErrorMsg) - { - CheckRetValue(!DoCheckRect(aWin1,aWin2),aErrorMsg,_L("CheckRectNoMatch()")); - } - -void CTWsGraphicsBase::CheckRectNoMatch(CTBaseWin *aWin1,CTBaseWin *aWin2, const TDesC &aErrorMsg) - { - CheckRectNoMatch(aWin1,aWin2,&aErrorMsg); - } - -TBool CTWsGraphicsBase::CheckRect(CTBaseWin *aWin1,CTBaseWin *aWin2,const TRect &aRect, const TDesC *aErrorMsg) - { - return CheckRetValue(DoCheckRect(aWin1,aWin2,aRect),aErrorMsg,_L("CheckRect()")); - } - -TBool CTWsGraphicsBase::CheckRect(CTBaseWin *aWin1,CTBaseWin *aWin2,const TRect &aRect, const TDesC &aErrorMsg) - { - return CheckRect(aWin1,aWin2,aRect,&aErrorMsg); - } - -void CTWsGraphicsBase::CheckRectNoMatch(CTBaseWin *aWin1,CTBaseWin *aWin2,const TRect &aRect, const TDesC *aErrorMsg) - { - CheckRetValue(!DoCheckRect(aWin1,aWin2,aRect),aErrorMsg,_L("CheckRectNoMatch()")); - } - -void CTWsGraphicsBase::CheckRectNoMatch(CTBaseWin *aWin1,CTBaseWin *aWin2,const TRect &aRect, const TDesC &aErrorMsg) - { - CheckRectNoMatch(aWin1,aWin2,aRect,&aErrorMsg); - } - -void CTWsGraphicsBase::CompareWindows(const TRect &aRect, const TDesC *aErrorMsg) - { - CheckRetValue(DoCheckRect(BaseWin,TestWin,aRect),aErrorMsg,_L("CompareWindows()")); - } - -TBool CTWsGraphicsBase::CompareWindows(const TDesC *aErrorMsg) - { - return CheckRetValue(DoCheckRect(BaseWin,TestWin,TRect(BaseWin->Size())),aErrorMsg,_L("CompareWindows()")); - } - -void CTWsGraphicsBase::CompareWindows(const TRect &aRect, const TDesC &aErrorMsg) - { - CompareWindows(aRect,&aErrorMsg); - } - -TBool CTWsGraphicsBase::CompareWindows(const TDesC &aErrorMsg) - { - return CompareWindows(&aErrorMsg); - } - -/** -Returns the size of the standard test windows. - -Several tests use 3 windows : one is a log window, one is a reference window -and one is the actual output of the test. All these windows have the same width which is roughly -1/3 of the screen. They also have the same height which is roughly equal to the screen height. -*/ -const TSize& CTWsGraphicsBase::StdTestWindowSize() - { - return iTest->StdTestWindowSize(); - } - -/** Returns the number of greys available in the richest grey mode */ -TInt CTWsGraphicsBase::MaxGrays() const - { - return iTest->MaxGrays(); - } - -/** Returns the number of colours available in the richest supported colour mode. */ -TInt CTWsGraphicsBase::MaxColors() const - { - return iTest->MaxColors(); - } - -// -// Panic testing // -// - -LOCAL_C TInt PanicThreadFunc(TAny *aPtr) - { - CTrapCleanup* CleanUpStack=CTrapCleanup::New(); - SPanicParams *ptr=(SPanicParams *)aPtr; - TInt ret; - TRAP(ret,ret=(*ptr->func)(ptr->num,ptr->ptr)); - delete CleanUpStack; - if (ret==EWsExitReasonBad) - AutoPanic(EAutoPanicPanicFailed); - return(ret); - } - -TInt CTestBase::LaunchPanicThread(RThread &aThread, SPanicParams *aPtr) - { - TBuf<32> threadName; - threadName.Format(TRefByValue(_L("AutoPanicThread%d")),iThreadNumber++); - return(aThread.Create(threadName,PanicThreadFunc,KDefaultStackSize,KPanicThreadHeapSize,KPanicThreadHeapSize,aPtr,EOwnerThread)); - } - -TInt CTestBase::TestPanicL(SPanicParams *aPtr, TInt aExitReason, const TDesC &aCategory, TBool* aTestFinished) - { - RThread thread; - TRequestStatus stat; - TInt err=LaunchPanicThread(thread, aPtr); - if (err==KErrAlreadyExists) - { - // wait for kernel to clear up old threads - // and have several attempts at starting the thread - // if unsuccessful the first time - for (TInt i=0;i<3;i++) - { - User::After(TTimeIntervalMicroSeconds32(100000)); //0.1 secs - err=LaunchPanicThread(thread, aPtr); - if (err!=KErrAlreadyExists) - break; - } - } - User::LeaveIfError(err); - thread.Logon(stat); - User::SetJustInTime(EFalse); - thread.Resume(); - User::WaitForRequest(stat); - User::SetJustInTime(ETrue); - - TBool testFinished=EFalse; - TBool testPassed=ETrue; - if (thread.ExitType()==EExitKill) - { - User::LeaveIfError(thread.ExitReason()); - if(thread.ExitReason()!=EWsExitReasonFinished) - { - testPassed=EFalse; - } - testFinished=ETrue; // Finish tests - } - else - { - if ((thread.ExitCategory().Compare(aCategory)!=0) - || (aExitReason!=EWservNoPanic && thread.ExitReason()!=aExitReason) - || (thread.ExitType()!=EExitPanic)) - { - testPassed=EFalse; - } - } - - if(aTestFinished) - *aTestFinished=testFinished; - thread.Close(); - return(testPassed); - } - -TInt CTestBase::TestWsPanicL(TPanicFunction aFunction, TClientPanic aExitReason, TInt aInt, TAny *aPtr, TBool* aTestFinished) - { - return TestPanicL(aFunction,aExitReason,aInt,aPtr,KWSERV, aTestFinished); - } - -TInt CTestBase::TestW32PanicL(TPanicFunction aFunction, TW32Panic aExitReason, TInt aInt, TAny *aPtr, TBool* aTestFinished) - { - return TestPanicL(aFunction,aExitReason,aInt,aPtr,KW32,aTestFinished); - } - - TInt CTestBase::TestWservPanicL(TPanicFunction aFunction, TWservPanic aExitReason, TInt aInt, TAny *aPtr) - { - _LIT(KWSERV1,"Wserv Internal Panic"); - return TestPanicL(aFunction,aExitReason,aInt,aPtr,KWSERV1); - } - -TInt CTestBase::TestPanicL(TPanicFunction aFunction, TInt aExitReason, TInt aInt, TAny *aPtr, const TDesC &aCategory, TBool* aTestFinished) - { - SPanicParams params; - params.num=aInt; - params.func=aFunction; - params.ptr=aPtr; - return TestPanicL(¶ms, aExitReason, aCategory, aTestFinished); - } - -TBool CTestBase::IsFullRomL() - { - TBool isFullRom = EFalse; - _LIT(KWinName,"EikonServer"); - TInt numWinGroups=TheClient->iWs.NumWindowGroups(); - CArrayFixFlat* list=new(ELeave) CArrayFixFlat(numWinGroups); - TheClient->iWs.WindowGroupList(list); - numWinGroups=list->Count(); // Just in case it changed between originally getting it and getting the actual list - TBuf<64> name; - TInt ii; - for(ii=0;iiiWs.GetWindowGroupNameFromIdentifier((*list)[ii],name); - #ifndef DISABLE_FAIL_DIALOG - TInt ordinalPos=0; - ordinalPos+=ordinalPos; //To stop a warning - ordinalPos= - #endif - TheClient->iWs.GetWindowGroupOrdinalPriority((*list)[ii]); - if (name==KWinName) - { - isFullRom = ETrue; - break; - } - } - delete list; - return isFullRom; - } - -void CTestBase::DelayIfFullRomL() - { - if (IsFullRomL()) - User::After(400000); - } - -TPartialRedrawType CTestBase::RedrawStoreTypeL() - { -/* if (iRedrawType==EPartialRedraw_Unknown) - { - const TRgb KRed=TRgb(255,0,0); - const TRgb KGreen=TRgb(0,255,0); - const TRgb KBlue=TRgb(0,0,255); - CWsScreenDevice* scrDev=TheClient->iScreen; - TSize winSize=scrDev->SizeInPixels(); - CBlankWindow* win=new(ELeave) CBlankWindow(KRed); //Window will be red if WSERV just draws in background color - CleanupStack::PushL(win); - TDisplayMode mode=EColor256; - win->SetUpL(TPoint(),winSize,TheClient->iGroup,*TheClient->iGc,&mode); //Window is activated - win->RealDraw(ETrue); - win->SetColor(KGreen); - CBlankWindow* win2=new(ELeave) CBlankWindow(KRed); - CleanupStack::PushL(win2); - win2->SetUpL(TPoint(),winSize,TheClient->iGroup,*TheClient->iGc,&mode); //New Window completely obscures other window - win2->RealDraw(ETrue); - win->CTWin::DrawNow(); //Window will be green if drawn from stored commands - win2->CTWin::DrawNow(); - win2->SetVisible(EFalse); - TRgb col; - scrDev->GetPixel(col,TPoint(5,5)); //Pixel will be red if storing off by default and green otherwise - if (col==KRed) - { - win->Win()->EnableRedrawStore(ETrue); - win->CTWin::DrawNow(); //Create stored commands - } - else - __ASSERT_ALWAYS(col==KGreen,AutoPanic(EAutoPanicRedrawStoring)); - win->SetColor(KBlue); - TRect redrawRect(TSize(10,10)); - win->Invalidate(redrawRect); - win->Win()->BeginRedraw(redrawRect); - win->DrawNow(redrawRect); //Top left of Window will be blue if it draws itself - win->Win()->EndRedraw(); - win2->SetVisible(ETrue); - win2->SetVisible(EFalse); - scrDev->GetPixel(col,TPoint(5,5)); //Pixel will be red if stored commands were lost - iRedrawType=EPartialRedraw_None; - if (col!=KRed) - { - __ASSERT_ALWAYS(col==KBlue,AutoPanic(EAutoPanicRedrawStoring)); - TheClient->WaitForRedrawsToFinish(); - win2->SetVisible(ETrue); - win2->SetVisible(EFalse); - scrDev->GetPixel(col,TPoint(15,15)); //Pixel will be blue if partial redraw triggers full redraw - iRedrawType=EPartialRedraw_PreserveStoredCmds; - if (col!=KBlue) - { - __ASSERT_ALWAYS(col==KGreen,AutoPanic(EAutoPanicRedrawStoring)); - iRedrawType=EPartialRedraw_FullRedrawSupport; - } - } - CleanupStack::PopAndDestroy(2,win); - } - return iRedrawType;*/ - return EPartialRedraw_FullRedrawSupport; - } - -void CTestBase::SetUpMember(TSpriteMember &aMember) - { - aMember.iMaskBitmap=NULL; - aMember.iInvertMask=EFalse; - aMember.iDrawMode=CGraphicsContext::EDrawModePEN; - aMember.iOffset=TPoint(); - aMember.iInterval=TTimeIntervalMicroSeconds32(0); - } - -void CTestBase::SimulateKeyDownUpWithModifiers(TInt aScanCode,TUint aModifiers) - { - if (aModifiers&EModifierAlt) - SimulateKey(TRawEvent::EKeyDown,EStdKeyLeftFunc); - if (aModifiers&EModifierCtrl) - SimulateKey(TRawEvent::EKeyDown,EStdKeyLeftCtrl); - if (aModifiers&EModifierShift) - SimulateKey(TRawEvent::EKeyDown,EStdKeyLeftShift); - SimulateKeyDownUp(aScanCode); - if (aModifiers&EModifierShift) - SimulateKey(TRawEvent::EKeyUp,EStdKeyLeftShift); - if (aModifiers&EModifierCtrl) - SimulateKey(TRawEvent::EKeyUp,EStdKeyLeftCtrl); - if (aModifiers&EModifierAlt) - SimulateKey(TRawEvent::EKeyUp,EStdKeyLeftFunc); - } - -void CTestBase::SimulateKeyDownUp(TInt aScanCode) - { - __ASSERT_DEBUG(aScanCode<'a' || aScanCode>'z',AutoPanic(EAutoPanicScanCapital)); - SimulateKey(TRawEvent::EKeyDown,aScanCode); - SimulateKey(TRawEvent::EKeyUp,aScanCode); - } - -void CTestBase::SimulatePointerDownUp(TInt aX, TInt aY) - { - SimulatePointer(TRawEvent::EButton1Down,aX,aY); - SimulatePointer(TRawEvent::EButton1Up,aX,aY); - } - -void CTestBase::SimulateKey(TRawEvent::TType aType, TInt aScanCode) - { - TRawEvent rawEvent; - rawEvent.Set(aType,aScanCode); - TheClient->iWs.SimulateRawEvent(rawEvent); - } - -/** - * Determine if the configuration supports pointer event testing. - * - * There are certain circumstances where we want to skip pointer event - * testing because we are simulating pointer events, and don't want to - * simulate a pointer event from an impossible co-ordinate. We'd rather - * just identify that there is no point in doing the test and skip over - * to the next test case. - * - * In particular, when a ROM configured with a digitiser is deployed on a - * Naviengine, with hardware configuration DIP switches which say that there - * is an external screen connected, then no touch pad is active. - * The base port under these conditions returns a digitiser area (0,0,0,0) - * - * @return ETrue if the configuration supports pointer event testing, otherwise - * return EFalse. - */ -TBool CTestBase::ConfigurationSupportsPointerEventTesting() const - { - if (iNormalPointerCursorArea.IsEmpty()) - { - return EFalse; - } - return ETrue; - } - - -void CTestBase::SimulatePointer(TRawEvent::TType aType, TInt aX, TInt aY) - { - __ASSERT_DEBUG(ConfigurationSupportsPointerEventTesting(), AutoPanic(EAutoPanicNoDigitiser)); - - -#ifdef WSERV_TAUTO_LOG_POINTER_EVENTS - TLogMessageText buf; - _LIT(KLog,"SimulatePointer Type=%d Pos=(%d,%d)"); - buf.Format(KLog,aType,aX,aY); - TheClient->LogMessage(buf); -#endif - - TRawEvent rawEvent; - rawEvent.Set(aType,aX,aY); - TheClient->iWs.SimulateRawEvent(rawEvent); - } - -void CTestBase::SimulateEvent(TRawEvent::TType aType) - { - TRawEvent rawEvent; - rawEvent.Set(aType); - TheClient->iWs.SimulateRawEvent(rawEvent); - } - -void CTestBase::LogColors(const CBitmapDevice& aDevice,TPoint aBasePoint, TPoint aStartPoint, TPoint aEndPoint) - { - _LIT(KPixel,"Pixel(%d,%d) R=%d G=%d B=%d"); - TLogMessageText buf; - TBuf8<2560> screen; - const TRgb* pixel; - if (aStartPoint.iX==aEndPoint.iX) - ++aEndPoint.iX; - if (aStartPoint.iY==aEndPoint.iY) - ++aEndPoint.iY; - TInt width=aEndPoint.iX-aStartPoint.iX; - TInt xx,yy; - for (yy=aStartPoint.iY;yyRed(),pixel->Green(),pixel->Blue()); - //RDebug::Print(buf); - TheClient->iWs.LogMessage(buf); - } - } - TheClient->iWs.Flush(); - } - -void CTestBase::LogColors4(const CBitmapDevice& aDevice,TPoint aStartPoint,TInt aLen) - { - _LIT(KValue,"Pixel(%d,%d) Byte %d, Value %d"); - TLogMessageText buf; - TBuf8<2560> screen; - aDevice.GetScanLine(screen,aStartPoint,aLen,EGray4); - TInt len=(aLen+3)/4; - TInt ii; - for (ii=0;iiiWs.LogMessage(buf); - } - } - -void CTestBase::UpdateTestResults(TInt aNoOfTest, TInt aNoOfTestPass) - { - iNumberTests+=aNoOfTest; - iNumberTestsPass+=aNoOfTestPass; - } - -TInt CTestBase::SaveScreen(const TDesC& aFileName) - { - return SaveScreen(aFileName,TheClient->iScreen->SizeInPixels(),TheClient->iScreen->DisplayMode()); - } - -TInt CTestBase::SaveScreen(const TDesC& aFileName,const TSize& aScreenSize,TDisplayMode aColorDepth) - { - TRAPD(err,SaveScreenL(aFileName,aScreenSize,aColorDepth)); - return err; - } - -void CTestBase::SaveScreenL(const TDesC& aFileName,const TSize& aScreenSize,TDisplayMode aColorDepth) - { - CBitmap* copyOfScreen=CBitmap::NewLC(aScreenSize,aColorDepth); - CFbsScreenDevice* scrDevice=CFbsScreenDevice::NewL(iScreenNumber,aColorDepth); - CleanupStack::PushL(scrDevice); - CFbsBitGc* gc; - User::LeaveIfError(scrDevice->CreateContext(gc)); - CleanupStack::PushL(gc); - copyOfScreen->Gc().BitBlt(TPoint(),*gc); - User::LeaveIfError(copyOfScreen->Bitmap().Save(aFileName)); - CleanupStack::PopAndDestroy(3,copyOfScreen); - } - - -/*CProcess*/ -_LIT(KScreenTag,"Screen"); - -void CProcess::GetProcArg(const TWinCommand& aParam,TBufArg& aProcArg) - { - TInt pos = aParam.Find(KScreenTag); - if (pos!=KErrNotFound) - aProcArg = aParam.Left(pos-1); - else - aProcArg = aParam; - } - -void CProcess::GetScreenArg(const TWinCommand& aParam, TInt& aScreenArg) - { - TInt pos = aParam.Find(KScreenTag); - if (pos!=KErrNotFound) - { - TBufArg secondArg(aParam.Right(aParam.Length()-pos)); - if (secondArg.Length()>6) - { - TBuf<1> digit(secondArg.Mid(6,1)); - TLex lex(digit); - lex.Val(aScreenArg); - } - } - } - -TInt CProcess::Start(const TWinCommand& aParam) - { - // parse command line aParam to retrieve value of - // screen number if it is specified - // - // command line format: [screen] - // - TBufArg procArg(_L("")); - TInt screenArg = KDefaultScreen; - - GetProcArg(aParam, procArg); - GetScreenArg(aParam, screenArg); - - TInt ii; - for(ii=0;iiConstructL(aFunctionNo,aScreenNumber); - CleanupStack::Pop(self); - return self; - } - -CProcess* CProcess::NewTL(TInt aFunctionNo,TInt aScreenNumber,TRequestStatus* aStatus /*=NULL*/) - { - CProcess* self=new(ELeave) CProcess(); - CleanupStack::PushL(self); - self->ConstructTL(aFunctionNo,aScreenNumber,aStatus); - CleanupStack::Pop(self); - return self; - } - -CProcess* CProcess::NewThreadL(const TDesC& aName,TThreadFunction aFunction,TThreadStartUp* aPtr - ,TRequestStatus* aStatus) - { - CProcess* self=new(ELeave) CProcess(); - CleanupStack::PushL(self); - self->ConstructL(aName,aFunction,aPtr,aStatus); - CleanupStack::Pop(self); - return self; - } - -CProcess* CProcess::NewThreadRendezvousL(const TDesC& aName,TThreadFunction aFunction,TThreadStartUp* aPtr ,TRequestStatus* aLogonStatus,TRequestStatus& aRendesvouzStatus) - { - CProcess* self=new(ELeave) CProcess(); - CleanupStack::PushL(self); - self->ConstructRendezvousL(aName,aFunction,aPtr,aLogonStatus,aRendesvouzStatus); - CleanupStack::Pop(self); - return self; - } - -CProcess* CProcess::NewThreadRendezvousL(const TDesC& aName,TThreadStartUp* aPtr,TRequestStatus& aRendesvouzStatus) - { - return NewThreadRendezvousL(aName,ThreadInit,aPtr,NULL,aRendesvouzStatus); - } - -CProcess* CProcess::NewThreadL(const TDesC& aName,TThreadStartUp* aPtr) - { - return NewThreadL(aName,ThreadInit,aPtr,NULL); - } - -CProcess* CProcess::NewSimpleThreadL(const TDesC& aName,TThreadStartUp* aPtr,TRequestStatus* aStatus/*=NULL*/) - { - return NewThreadL(aName,SimpleThreadInit,aPtr,aStatus); - } - -_LIT(KSpace," "); -_LIT(KScreenFormat,"%d"); - -void CProcess::ConstructL(TInt aFunctionNo,TInt aScreenNumber/*=KDefaultScreen*/) - { - Close(); - // add screen number into command line param - // format: [screen] - // - TBuf<100> commandLine; - - commandLine = iFunctions[aFunctionNo].iParam; - commandLine.Append(KSpace); - commandLine.Append(KScreenTag); - commandLine.AppendFormat(KScreenFormat,aScreenNumber); - User::LeaveIfError(iOther.Create(RProcess().FileName(),commandLine)); - iCreated|=eOtherCreated; - iOther.Resume(); - } - -void CProcess::ConstructTL(TInt aFunctionNo,TInt aScreenNumber/*=KDefaultScreen*/,TRequestStatus* aStatus) - { - Close(); - TUint flag=eThreadCreated; - TInt err=iThread.Create(iFunctions[aFunctionNo].iParam,iFunctions[aFunctionNo].iFunction - ,KDefaultStackSize,KOtherProcHeapSize,KOtherProcHeapSize,(TAny*)aScreenNumber,EOwnerThread); - User::LeaveIfError(err); - iCreated|=flag; - if (aStatus) - Logon(*aStatus); - iThread.Resume(); - } - - -void CProcess::ConstructL(const TDesC& aName,TThreadFunction aFunction,TThreadStartUp* aPtr,TRequestStatus* aStatus) - { - Close(); - User::LeaveIfError(iThread.Create(aName,aFunction,KDefaultStackSize,KOtherProcHeapSize,KOtherProcHeapSize,aPtr,EOwnerThread)); - iCreated|=eThreadCreated; - if (aStatus) - Logon(*aStatus); - iThread.Resume(); - } - -void CProcess::ConstructRendezvousL(const TDesC& aName,TThreadFunction aFunction,TThreadStartUp* aPtr,TRequestStatus* aLogonStatus,TRequestStatus& aRendezvousStatus) - { - Close(); - User::LeaveIfError(iThread.Create(aName,aFunction,KDefaultStackSize,KOtherProcHeapSize,KOtherProcHeapSize,aPtr,EOwnerThread)); - iCreated|=eThreadCreated; - if (aLogonStatus) - Logon(*aLogonStatus); - - iThread.Rendezvous(aRendezvousStatus); - iThread.Resume(); - } - -void CProcess::Logon(TRequestStatus& aStatus) const - { - if (iCreated&eThreadCreated) - iThread.Logon(aStatus); - else - { - iOther.Logon(aStatus); - } - } - -void CProcess::Terminate(TInt aReason) - { - if (iCreated&eThreadCreated) - iThread.Terminate(aReason); - else - { - iOther.Terminate(aReason); - } - Close(); - } - -void CProcess::Close() - { - if (iCreated&eOtherCreated) - iOther.Close(); - if (iCreated&eThreadCreated) - iThread.Close(); - iCreated=0; - } - -CProcess::~CProcess() - { - Close(); - } - -TBool CProcess::StillAlive() - { - if (iCreated&eOtherCreated) - return iOther.ExitType()==EExitPending; - return iThread.ExitType()==EExitPending; - } - -void CProcess::LeaveIfDied() //Can Leave - { - User::After(200000); //0.2 secs - if (StillAlive()) - return; - if (iCreated&eOtherCreated) - User::Leave(iOther.ExitReason()); - User::Leave(iThread.ExitReason()); - } - -const TInt KFirstInstanceId = 1; -const TInt KOtherInstanceId = 2; - -TBool CProcess::ProcessDied(TInt aScreenNo/*=KDefaultScreen*/) - { - _LIT(pName,"TAutoServer*"); - TFindProcess find(pName); - TFullName name; - - TBool found = EFalse; - TInt instanceId = aScreenNo==KDefaultScreen? KFirstInstanceId : KOtherInstanceId; - // find the correct instance of the process - // required in multi display test - while (!found && find.Next(name)==KErrNone) - { - TPtrC scrId = name.Right(1); - TInt id; - TLex lex(scrId); - lex.Val(id); - if (id==instanceId) - found = ETrue; - } - if (!found) - return EFalse; - - RProcess p; - p.Open(name); - if (p.Id()!=RProcess().Id()) - return EFalse; - p.Close(); - return (find.Next(name)!=KErrNone); - } - -TInt CProcess::ThreadInit(TAny *aPtr) - { - __UHEAP_MARK; - TInt err=KErrNone; - CTrapCleanup* CleanUpStack=CTrapCleanup::New(); - if (CleanUpStack==NULL) - err=KErrNoMemory; - else - { - TRAP(err,InitialiseL(STATIC_CAST(TThreadStartUp*,aPtr))) - delete CleanUpStack; - } - __UHEAP_MARKEND; - return(err); - } - -void CProcess::InitialiseL(TThreadStartUp* aPtr) - { - CActiveScheduler* activeScheduler=new(ELeave) CActiveScheduler; - CActiveScheduler::Install(activeScheduler); - CleanupStack::PushL(activeScheduler); - aPtr->iInitFunction(aPtr->iParam); - CActiveScheduler::Start(); - CleanupStack::PopAndDestroy(activeScheduler); - } - -TInt CProcess::SimpleThreadInit(TAny *aPtr) - { - __UHEAP_MARK; - TInt err=KErrNone; - CTrapCleanup* CleanUpStack=CTrapCleanup::New(); - if (CleanUpStack==NULL) - err=KErrNoMemory; - else - { - TThreadStartUp* ptr=STATIC_CAST(TThreadStartUp*,aPtr); - ptr->iInitFunction(ptr->iParam); - delete CleanUpStack; - } - __UHEAP_MARKEND; - return(err); - } - -/*CMinWin*/ - -CMinWin::CMinWin(TInt aScreenNo): iScreenNo(aScreenNo) - {} - -void CMinWin::ConstructL() - { - User::LeaveIfError(iWs.Connect()); - iScr=new(ELeave) CWsScreenDevice(iWs); - User::LeaveIfError(iScr->Construct(iScreenNo)); - iGroup=RWindowGroup(iWs); - User::LeaveIfError(iGroup.Construct(8970+iScreenNo,ETrue)); - iWin=RWindow(iWs); - User::LeaveIfError(iWin.Construct((RWindowTreeNode)iGroup,(TUint32)this)); - iRect=TSize(10,10); - iWin.SetExtent(TPoint(0,0),iRect.Size()); - iWin.SetRequiredDisplayMode(EColor256); - iWin.SetBackgroundColor(KRgbGreen); - iWin.Activate(); - iGc=new(ELeave) CWindowGc(iScr); - User::LeaveIfError(iGc->Construct()); - - Draw(iRect); - iWs.Flush(); - } - -CMinWin::~CMinWin() - { - delete iGc; - iWin.Close(); - iGroup.Close(); - delete iScr; - iWs.Close(); - } - -void CMinWin::Draw(const TRect& aRect) - { - iWin.BeginRedraw(); - iGc->Activate(iWin); - iGc->SetPenStyle(CGraphicsContext::ENullPen); - iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - iGc->SetBrushColor(KRgbGreen); - iGc->DrawRect(aRect); - iGc->Deactivate(); - iWin.EndRedraw(); - } - - -/*CTimeOut*/ - -void CTimeOut::ConstructL() - { - CTimer::ConstructL(); - CActiveScheduler::Add(this); - } - -void CTimeOut::Start(TTimeIntervalMicroSeconds32 aInterval,TCallBack aCallBack) - { - iCallBack=aCallBack; - After(aInterval); - } - -void CTimeOut::RunL() - { - iCallBack.CallBack(); - } - -/* - * Simply returns the DisplayMode as a string. Used to display mode details on test results. - */ -GLDEF_C TPtrC DisplayModeAsString(TDisplayMode aMode) - { - - TPtrC modeAsString; - - switch(aMode) - { - case ENone: - _LIT(KENoneMode,"ENone"); - modeAsString.Set(KENoneMode); - break; - case EGray2: - _LIT(KEGray2Mode,"EGray2"); - modeAsString.Set(KEGray2Mode); - break; - case EGray4: - _LIT(KEGray4Mode,"EGray4"); - modeAsString.Set(KEGray4Mode); - break; - case EGray16: - _LIT(KEGray16Mode,"EGray16"); - modeAsString.Set(KEGray16Mode); - break; - case EGray256: - _LIT(KEGray256Mode,"EGray256"); - modeAsString.Set(KEGray256Mode); - break; - case EColor16: - _LIT(KEColor16Mode,"EColor16"); - modeAsString.Set(KEColor16Mode); - break; - case EColor256: - _LIT(KEColor256Mode,"EColor256"); - modeAsString.Set(KEColor256Mode); - break; - case EColor64K: - _LIT(KEColor64KMode,"EColor64K"); - modeAsString.Set(KEColor64KMode); - break; - case EColor16M: - _LIT(KEColor16MMode,"EColor16M"); - modeAsString.Set(KEColor16MMode); - break; - case EColor4K: - _LIT(KEColor4KMode,"EColor4K"); - modeAsString.Set(KEColor4KMode); - break; - case EColor16MU: - _LIT(KEColor16MUMode,"EColor16MU"); - modeAsString.Set(KEColor16MUMode); - break; - case EColor16MA: - _LIT(KEColor16MAMode,"EColor16MA"); - modeAsString.Set(KEColor16MAMode); - break; - case EColor16MAP: - _LIT(KEColor16MAPMode,"EColor16MAP"); - modeAsString.Set(KEColor16MAPMode); - break; - default: - _LIT(KUnknownMode,"Unknown"); - modeAsString.Set(KUnknownMode); - break; - } - - return modeAsString; - } - -// Check if an area of a bitmap is of a certain color -GLDEF_C TBool LossyCheckBlankBitmap(const CFbsBitmap& aBitmap, const TRect aArea, const TRgb aCheckColor, TBool aLossyCompare) - { - const TReal errorLimit = (aLossyCompare ? 0.05 : 0.00); //Lossy(default) or exact compare? - - TBool result = ETrue; - /* TInt mismatchedPixels = 0; */ // -- Useful for debugging - TRgb bitmapPix = TRgb(0,0,0,0); //testWin Pixel - for (TInt x = 0; x < aArea.Size().iWidth; x++) - { - for (TInt y = 0; y < aArea.Size().iHeight; y++) - { - aBitmap.GetPixel(bitmapPix, TPoint(x,y)); - - //Check if there are differeces in color between the bitmap and the test color - if(((TReal)abs(bitmapPix.Red() - aCheckColor.Red())/255) > errorLimit || - ((TReal)abs(bitmapPix.Blue() - aCheckColor.Blue())/255) > errorLimit || - ((TReal)abs(bitmapPix.Green() - aCheckColor.Green())/255) > errorLimit || - ((TReal)abs(bitmapPix.Alpha() - aCheckColor.Alpha())/255) > errorLimit) - { - /* mismatchedPixels++; */ // -- Useful for debugging - result = EFalse; - break; - } - } - } - - /* INFO_PRINTF2(_L("Number of different pixels: %i"), mismatchedPixels); */ // -- Useful for debugging - return result; - } - -// Compare a section of two bitmaps -GLDEF_C TBool LossyCompareBitmap(const CFbsBitmap& aBitmap1, const CFbsBitmap& aBitmap2, const TRect aCompareRect, TBool aLossyCompare) - { - const TReal errorLimit = (aLossyCompare ? 0.05 : 0.00); //Lossy or Exact compare? - - TBool result = ETrue; - - if (aBitmap1.DisplayMode() != aBitmap2.DisplayMode()) - { - RDebug::Printf(" DisplayMode difference %d, %d", aBitmap1.DisplayMode(), aBitmap2.DisplayMode()); - } - - TRgb bitmap1Pix = TRgb(0,0,0,0); - TRgb bitmap2Pix = TRgb(0,0,0,0); - for (TInt x = 0; x < aCompareRect.Size().iWidth; x++) - { - for (TInt y = 0; y < aCompareRect.Size().iHeight; y++) - { - aBitmap1.GetPixel(bitmap1Pix, TPoint(x,y)); - aBitmap2.GetPixel(bitmap2Pix, TPoint(x,y)); - - //Check if there are differences between the colors of the two bitmaps - if(((TReal)abs(bitmap1Pix.Red() - bitmap2Pix.Red())/255) > errorLimit || - ((TReal)abs(bitmap1Pix.Blue() - bitmap2Pix.Blue())/255) > errorLimit || - ((TReal)abs(bitmap1Pix.Green() - bitmap2Pix.Green())/255) > errorLimit || - ((TReal)abs(bitmap1Pix.Alpha() - bitmap2Pix.Alpha())/255) > errorLimit) - { - /* - * There was a difference so return without checking the rest of the - * bitmap. If you are seeing Lossy compare errors, and want to diagnose - * further, consider switching over to using a recording version of this - * function, LossyCompareBitmapRecord() - */ - result = EFalse; - break; - } - } - } - - return result; - } - -/** - * Compare two bitmaps, optionally a lossy comparison, recording any differences and saving bitmaps - * - * @param aBitmap1 Bitmap being checked - * @param aBitmap2 Reference Bitmap - * @param aCompareRect Area of bitmap to compare - * @param aLossyCompare ETrue means use a lossy compare strategy, else do an exact compare - * @param aPixelsDifferent Returned value representing the number of pixels which are different - * @param aLogger Facility for logging to be reported by this function - * @return ETrue if the bitmaps are the same (or similar). - * Otherwise EFalse, with logging reporting the differences, and bitmaps saved in c:\logs\ - * @pre c:\logs directory must exist - */ -GLDEF_C TBool LossyCompareBitmapRecord(CFbsBitmap& aBitmap1, CFbsBitmap& aBitmap2, const TRect aCompareRect, TBool aLossyCompare, TInt& aPixelsDifferent, CTestExecuteLogger& aLogger) - { - const TReal errorLimit = (aLossyCompare ? 0.05 : 0.00); //Lossy or Exact compare? - - TBool result = ETrue; - TInt mismatchedPixels = 0; - TRgb bitmap1Pix = TRgb(0,0,0,0); - TRgb bitmap2Pix = TRgb(0,0,0,0); - if (aBitmap1.DisplayMode() != aBitmap2.DisplayMode()) - { - aLogger.LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, - _L(" DisplayMode difference %d, %d"), aBitmap1.DisplayMode(), aBitmap2.DisplayMode()); - } - for (TInt x = 0; x < aCompareRect.Size().iWidth; x++) - { - for (TInt y = 0; y < aCompareRect.Size().iHeight; y++) - { - aBitmap1.GetPixel(bitmap1Pix, TPoint(x,y)); - aBitmap2.GetPixel(bitmap2Pix, TPoint(x,y)); - - //Check if there are differences between the colors of the two bitmaps - if(((TReal)abs(bitmap1Pix.Red() - bitmap2Pix.Red())/255) > errorLimit || - ((TReal)abs(bitmap1Pix.Blue() - bitmap2Pix.Blue())/255) > errorLimit || - ((TReal)abs(bitmap1Pix.Green() - bitmap2Pix.Green())/255) > errorLimit || - ((TReal)abs(bitmap1Pix.Alpha() - bitmap2Pix.Alpha())/255) > errorLimit) - { - mismatchedPixels++; - - aLogger.LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, - _L(" Pixel difference %d,%d: %d"),x,y, bitmap1Pix.Difference(bitmap2Pix)); - result = EFalse; - // we loop around again to pick up all the differences - } - } - } - aPixelsDifferent = mismatchedPixels; - - /* - * When the bitmaps are different, we store them locally in c:\\logs in - * timestamped files. Save() is a non-const method; this is why aBitmap1 - * and aBitmap2 are non-const. Saving can fail, perhaps because we have - * exceeded storage limits. - */ - if (!result) - { - TTime now; - now.UniversalTime(); - TInt timestamp = I64INT(now.Int64() & 0x7fffffffu); - timestamp/=1000; // a millisecond resolution is easier to track - TFileName mbmFileSrc; - mbmFileSrc.Format (_L("c:\\logs\\%d_LossyCompareBitmap1.mbm"), timestamp); - TFileName mbmFileDst; - mbmFileDst.Format (_L("c:\\logs\\%d_LossyCompareBitmap2.mbm"), timestamp); - TInt saveResult1; - TInt saveResult2; - saveResult1 = aBitmap1.Save(mbmFileSrc); - saveResult2 = aBitmap2.Save(mbmFileDst); - if (saveResult1 == KErrNone && saveResult2 == KErrNone) - { - aLogger.LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, - _L(" Bitmaps are different: see %S, %S"), &mbmFileSrc, &mbmFileDst); - } - else - { - aLogger.LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, - _L(" Bitmaps are different, but could not save files into c:\\logs : %d %d"), saveResult1, saveResult2); - } - } - - return result; - } - -// Check if an area of a screen is of a certain color -GLDEF_C TBool LossyCheckBlankWindow(const CWsScreenDevice& aScreen, CFbsBitmap& aBitmap, const TRect aArea, const TRgb aCheckColor) - { - aScreen.CopyScreenToBitmap(&aBitmap, aArea); - return LossyCheckBlankBitmap(aBitmap, aArea, aCheckColor); - } - -// Compare a section of two windows on the screen -GLDEF_C TBool LossyCompareWindow(const CWsScreenDevice& aScreen, CFbsBitmap& aBitmap1, CFbsBitmap& aBitmap2, const TRect aCompareRect) - { - aScreen.CopyScreenToBitmap(&aBitmap1, aCompareRect); - aScreen.CopyScreenToBitmap(&aBitmap2, aCompareRect); - return LossyCompareBitmap(aBitmap1, aBitmap2, aCompareRect); - } - diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/AUTODLL.CPP --- a/windowing/windowserver/tauto/AUTODLL.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2858 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Auto test Animated DLL functions -// -// - -#include -#include -#include -#include -#include "AUTODLL.H" -#include "TAnimDraw.h" -#include "eventdd.h" -#include -#include - -union TAnimArgUnion - { - const TAny* any; - const TBool* Bool; - const TInt* Int; - const TPoint* Point; - const TSize* Size; - const TRect* Rect; - const TSpriteMemberInfo* SpriteMemberInfo; - const TShadowDrawTest* ShadowDrawTest; - const TDrawTestScreen* DrawTestScreen; - const TSyncTests* SyncTests; - const TTimeChangeTest* TimeChangeTest; - const TAnimRawEvent* AnimRawEvent; - const TWindowGroupInfoParms* WindowGroupInfoParms; - const TSetOrdinalParms* SetOrdinalParms; - const TFrameData* FrameData; - const TRawEvent* RawEvent; - }; - -class CPanicAnim : public CWindowAnim - { - enum TSyncState - { - ESyncStateNull, - ESyncStateStarting, - ESyncStateCounting, - ESyncLeave, - ESyncStateTimeChange1, - ESyncStateTimeChange2, - ESyncStateTimeChange3 - }; - enum {ESyncCount=8}; -public: - ~CPanicAnim(); - virtual void ConstructL(TAny *aArgs, TBool aHasFocus); - virtual void Animate(TDateTime *aDateTime); - virtual void Redraw(); - virtual void Command(TInt aOpcode, TAny *aArgs); - virtual TInt CommandReplyL(TInt aOpcode, TAny *aArgs); - virtual void FocusChanged(TBool aState); - //Pure virtual function from MEventHandler - virtual TBool OfferRawEvent(const TRawEvent &aRawEvent); -private: - void StartSyncTest(MAnimGeneralFunctions::TAnimSync aSync); - void StartTimeChangeTest(); - void DoLeaveInActiveCallback(); - static TInt LeaveInActiveCallback(TAny *aThis); -private: - TRequestStatus *iStatusPtr; - TRequestStatus *iStatusPtr2; - TTime iTime; - TInt iSyncCount; - TSyncState iSyncState; - MAnimGeneralFunctions::TAnimSync iSyncMode; - TBool iLeaveInRedraw; - CIdle* iActivePanicIdle; - }; - -class CPanicAnim2 : public CWindowAnim -// -// Simply panics in the ConstructL() -// - { -public: - virtual void ConstructL(TAny *aArgs, TBool aHasFocus); - virtual void Animate(TDateTime *aDateTime); - virtual void Redraw(); - virtual void Command(TInt aOpcode, TAny *aArgs); - virtual TInt CommandReplyL(TInt aOpcode, TAny *aArgs); - virtual void FocusChanged(TBool aState); - //Pure virtual function from MEventHandler - virtual TBool OfferRawEvent(const TRawEvent &aRawEvent); - }; - -class CAutoAnim3 : public CWindowAnim -// -// test drawing/redrawing -// - { -public: - virtual void ConstructL(TAny *aArgs, TBool aHasFocus); - virtual void Animate(TDateTime *aDateTime); - virtual void Redraw(); - virtual void Command(TInt aOpcode, TAny *aArgs); - virtual TInt CommandReplyL(TInt aOpcode, TAny *aArgs); - virtual void FocusChanged(TBool aState); - void Draw(const TRect &aRect); - void DrawTestScreenL(const TDrawTestScreen* aParams); - //Pure virtual function from MEventHandler - virtual TBool OfferRawEvent(const TRawEvent &aRawEvent); -private: - TRequestStatus *iStatusPtr; - CFbsFont *iFont; - TRect iRect; - TRect iBaseRect; - TInt iMode; - }; - -class CAutoAnimScrBack : public CWindowAnim -// -// test anim drawing behind a backed up window -// - { -public: - virtual void ConstructL(TAny *aArgs, TBool aHasFocus); - virtual void Animate(TDateTime *aDateTime); - virtual void Redraw(); - virtual void Command(TInt aOpcode, TAny *aArgs); - virtual TInt CommandReplyL(TInt aOpcode, TAny *aArgs); - virtual void FocusChanged(TBool aState); - void Draw(); - //Pure virtual function from MEventHandler - virtual TBool OfferRawEvent(const TRawEvent &aRawEvent); -private: - TRect iRect; - TInt iMode; - }; - -class CTestSpriteAnim : public CSpriteAnim - { -public: - virtual void ConstructL(TAny *aArgs); - virtual void Animate(TDateTime *aDateTime); - virtual void Command(TInt aOpcode, TAny *aArgs); - virtual TInt CommandReplyL(TInt aOpcode, TAny *aArgs); - //Pure virtual function from MEventHandler - virtual TBool OfferRawEvent(const TRawEvent &aRawEvent); -private: - TBool CheckMember(const TSpriteMemberInfo& aMemInfo); - void DrawMemberL(TInt aMember); - void DrawMemberL(); - }; - -/** -Used by CAnimTimer below -*/ -class MAnimTimerObserver - { -public: - virtual void DisplayNextFrameL()=0; - }; - -/** -This class is used by CTestFreeTimerAnim to determine when to swap the current frame with the next one. -*/ -class CAnimTimer : public CTimer - { -public: - ~CAnimTimer(); - static CAnimTimer* NewL(MAnimTimerObserver& aObserver); - void RunL(); -private: - CAnimTimer(MAnimTimerObserver& aObserver); - void ConstructL(); -private: - MAnimTimerObserver& iAnim; - }; - -class CTestFreeTimerAnim : public CFreeTimerWindowAnim, public MAnimTimerObserver - { -public: - //from CBase - ~CTestFreeTimerAnim(); - //from CAnim - void Animate(TDateTime *aDateTime); - void Command(TInt aOpcode, TAny *aArgs); - TInt CommandReplyL(TInt aOpcode, TAny *aArgs); - //from CWindowAnim - void ConstructL(TAny *aArgs, TBool aHasFocus); - void Redraw(); - void FocusChanged(TBool aState); - //from MEventHandler - TBool OfferRawEvent(const TRawEvent &aRawEvent); -private: - void DisplayNextFrameL(); -private: - CAnimTimer* iTimer; - TInt iFrameTime; - TRgb iColour; - TRect iRect; - }; - -class CEventTestAnimBase : public CWindowAnim - { - enum {EEventBufferSize=40}; -public: - virtual ~CEventTestAnimBase(); - //Pure virtual functions from CAnim - virtual void Animate(TDateTime *aDateTime); - virtual void Command(TInt aOpcode, TAny *aArgs); - virtual TInt CommandReplyL(TInt aOpcode, TAny *aArgs); - //Pure virtual functions from CWindowAnim - virtual void ConstructL(TAny *aArgs, TBool aHasFocus); - virtual void Redraw(); - virtual void FocusChanged(TBool aState); - //Pure virtual function from MEventHandler - virtual TBool OfferRawEvent(const TRawEvent &aRawEvent); -protected: - void Fail(); - TBool IsIgnorableEvent(const TRawEvent& aRawEvent) const; - TBool GetNextExpectedEvent(TAnimRawEvent& aRawEvent); - TBool CompareEvents(const TRawEvent& aExpectedEvent, const TRawEvent& aActualEvent) const; - TBool HandleRecursiveEvent(const TRawEvent& aRawEvent); - - TInt Error() const; - TInt EventCount() const; - void ResetEventCount(); - TInt TotalExpectedEvents() const; - TInt AddEvent(const TAnimRawEvent* event); -private: - virtual TInt AddExpectedEvent(const TAnimRawEvent* event)=0; -private: - CCirBuf iExpectedEvents; - TInt iError; - TInt iEventCount; - }; - -class CEventTestAnim : public CEventTestAnimBase - { -public: - ~CEventTestAnim(); - //Pure virtual functions from CWindowAnim overridden in CEventTestAnimBase - void ConstructL(TAny* aArgs,TBool aHasFocus); - //Pure virtual functions from CAnim overridden in CEventTestAnimBase - TInt CommandReplyL(TInt aOpcode,TAny* aArgs); - void Command(TInt aOpcode,TAny* aArgs); -private: - TInt UnloadDeviceDriver(); - //Pure virtual function from CEventTestAnimBase - TInt AddExpectedEvent(const TAnimRawEvent* event); -private: - TBool iDevDriverLoaded; - REventDD iLdd; - }; - -class CEventPostingAnim : public CEventTestAnimBase - { -public: - ~CEventPostingAnim(); - //Virtual functions from CEventTestAnimBase - virtual void ConstructL(TAny *aArgs, TBool aHasFocus); - //Virtual function from MEventHandler - virtual TBool OfferRawEvent(const TRawEvent &aRawEvent); -private: - //Pure virtual function from CEventTestAnimBase - virtual TInt AddExpectedEvent(const TAnimRawEvent* event); - }; - -class CRemovableAnim : public CEventTestAnimBase - { -public: - ~CRemovableAnim(); - //Virtual functions from CEventTestAnimBase - virtual TInt CommandReplyL(TInt aOpcode, TAny *aArgs); - virtual TBool OfferRawEvent(const TRawEvent &aRawEvent); -private: - //Pure virtual function from CEventTestAnimBase - virtual TInt AddExpectedEvent(const TAnimRawEvent* event); -private: - TInt iLifetime; - }; - -class CTimerTestAnim : public CWindowAnim - { -public: - ~CTimerTestAnim(); - //Pure virtual functions from CAnim - virtual void Animate(TDateTime *aDateTime); - virtual void Command(TInt aOpcode, TAny *aArgs); - virtual TInt CommandReplyL(TInt aOpcode, TAny *aArgs); - //Pure virtual functions from CWindowAnim - virtual void ConstructL(TAny *aArgs, TBool aHasFocus); - virtual void Redraw(); - virtual void FocusChanged(TBool aState); - //Pure virtual function from MEventHandler - virtual TBool OfferRawEvent(const TRawEvent &aRawEvent); -private: - TInt iTimerCount; - TBool iExpectingTicks; - TBool iFail; - }; - -class CWinFunctionTestAnim : public CWindowAnim - { - //enum {EEventBufferSize=40}; -public: - ~CWinFunctionTestAnim(); - //Pure virtual functions from CAnim - virtual void Animate(TDateTime *aDateTime); - virtual void Command(TInt aOpcode, TAny *aArgs); - virtual TInt CommandReplyL(TInt aOpcode, TAny *aArgs); - //Pure virtual functions from CWindowAnim - virtual void ConstructL(TAny *aArgs, TBool aHasFocus); - virtual void Redraw(); - virtual void FocusChanged(TBool aState); - //Pure virtual function from MEventHandler - virtual TBool OfferRawEvent(const TRawEvent &aRawEvent); -private: - MAnimGeneralFunctionsWindowExtension* iWinFunctions; - }; - -class CNotificationTestAnim : public CWindowAnim - { -public: - CNotificationTestAnim(); - ~CNotificationTestAnim(); - //Pure virtual functions from CAnim - virtual void HandleNotification(const TWsEvent& aEvent); - virtual void Animate(TDateTime *aDateTime); - virtual void Command(TInt aOpcode, TAny *aArgs); - virtual TInt CommandReplyL(TInt aOpcode, TAny *aArgs); - //Pure virtual functions from CWindowAnim - virtual void ConstructL(TAny *aArgs, TBool aHasFocus); - virtual void Redraw(); - virtual void FocusChanged(TBool aState); - //Pure virtual function from MEventHandler - virtual TBool OfferRawEvent(const TRawEvent &aRawEvent); -private: - TFixedArray iDSA; - TBool iHeartbeatState; - TBool iScreenDeviceChanged; - TTime iLastAnimTime; - }; - -class CTransAnim : public CWindowAnim -// -// Test drawing/redrawing in Transparent window. -// - { -public: - //Implementaion for pure virtual functions from CAnim - void ConstructL(TAny* aArgs, TBool aHasFocus); - void Animate(TDateTime* aDateTime); - void Redraw(); - void Command(TInt aOpcode, TAny* aArgs); - TInt CommandReplyL(TInt aOpcode, TAny* aArgs); - void FocusChanged(TBool aState); - TBool OfferRawEvent(const TRawEvent &aRawEvent); -private: - CFbsFont* iFont; - TRect iRect; - TInt iMode; - TInt iDraw; - TRgb iColor; - TInt iCount; - }; - -class CTestHandlerAnim : public CWindowAnim - { - public: - ~CTestHandlerAnim(); - void ConstructL(TAny* aArgs, TBool aHasFocus); - void Redraw(); - void FocusChanged(TBool aState); - TInt CommandReplyL(TInt aOpcode, TAny* aArgs); - void Command(TInt aOpcode, TAny* aArgs); - void Animate(TDateTime* aDateTime); - TBool OfferRawEvent(const TRawEvent &aRawEvent); - private: - }; - -class CCoverageAnim : public CWindowAnim -/** - This class adds functional coverage to CWsAnimGc. - The actual work is handled by the 'Draw' method which calls - each method in turn. - Mostly copied from CAutoAnimScrBack and CAutoAnim3. - @SYMTestCaseID - @SYMPREQ 1841 Add Coverage tests. - @SYMTestCaseDesc Functional coverage. - @SYMTestActions Run functional coverage test on CWsAnimGc. - */ - { -public: - ~CCoverageAnim(); - virtual void ConstructL(TAny *aArgs, TBool aHasFocus); - virtual void Animate(TDateTime *aDateTime); - virtual void Redraw(); - virtual void Command(TInt aOpcode, TAny *aArgs); - virtual TInt CommandReplyL(TInt aOpcode, TAny *aArgs); - virtual void FocusChanged(TBool aState); - void Draw(); - //Pure virtual function from MEventHandler - virtual TBool OfferRawEvent(const TRawEvent &aRawEvent); -private: - TRect iRect; /** rectangle used for all draw ops that require one */ - CFbsFont* iFont; - }; - -class CMultiPointerAnim : public CWindowAnim - { - enum {EEventBufferSize=40}; -public: - virtual ~CMultiPointerAnim(); - //Pure virtual functions from CAnim - virtual void Animate(TDateTime *aDateTime); - virtual void Command(TInt aOpcode, TAny *aArgs); - virtual TInt CommandReplyL(TInt aOpcode, TAny *aArgs); - //Pure virtual functions from CWindowAnim - virtual void ConstructL(TAny *aArgs, TBool aHasFocus); - virtual void Redraw(); - virtual void FocusChanged(TBool aState); - //Pure virtual function from MEventHandler - virtual TBool OfferRawEvent(const TRawEvent &aRawEvent); -protected: - TInt AddEvent(const TAnimRawEvent* aEvent); - TBool CompareEvents(const TRawEvent& aExpectedEvent, const TRawEvent& aActualEvent); -private: - CCirBuf iExpectedEvents; - TBuf<255> iErrorDes; - TInt iEventCount; - TInt iError; - }; - -class CTestAnimDll : public CAnimDll - { -public: - CAnim *CreateInstanceL(TInt aType); -private: - }; - -/*#if defined(__WINS__) -#pragma data_seg(".E32_UID") -__WINS_UID(0, KWservAnimDllUidValue, 0) -#pragma data_seg() -#endif*/ - -EXPORT_C CAnimDll *CreateCAnimDllL() - { - return(new(ELeave) CTestAnimDll()); - } - - -// Panic Tests // -void CPanicAnim::ConstructL(TAny *, TBool ) - { - iWindowFunctions->SetRect(TRect(0,0,1,1)); - iFunctions->SetSync(MAnimGeneralFunctions::ESyncSecond); - if (iFunctions->Sync()!=MAnimGeneralFunctions::ESyncSecond) - User::Leave(KErrGeneral); -// Check the anim time is not ahead of and not more than 2 secs behind the system time - TTime now; - now.UniversalTime(); - TDateTime dt=now.DateTime(); - TDateTime adt=iFunctions->SystemTime(); - if (adt.Day()!=dt.Day()) - User::Leave(KErrGeneral); - - iFunctions->SetSync(MAnimGeneralFunctions::ESyncNone); - if (iFunctions->Sync()!=MAnimGeneralFunctions::ESyncNone) - User::Leave(KErrGeneral); - } - -CPanicAnim::~CPanicAnim() - { - delete iActivePanicIdle; - } - -void CPanicAnim::Animate(TDateTime *aDateTime) - { - switch(iSyncState) - { - case ESyncStateNull: - break; - case ESyncStateStarting: - iTime=iFunctions->SystemTime(); - iSyncState=ESyncStateCounting; - iSyncCount=0; - break; - case ESyncStateCounting: - if (aDateTime) - { - TTimeIntervalSeconds interval; - TTime(*aDateTime).SecondsFrom(iTime, interval); - iSyncCount=interval.Int(); - } - else - iSyncCount++; - if (iSyncCount==ESyncCount) - { - TTimeIntervalMicroSeconds minInterval(0); - TTimeIntervalMicroSeconds maxInterval(0); - iSyncState=ESyncStateNull; - switch(iSyncMode) - { - case MAnimGeneralFunctions::ESyncSecond: - minInterval=iSyncCount*1000000-100000; - maxInterval=iSyncCount*1000000+100000; - break; - default:; - } - TTime time(iFunctions->SystemTime()); - TTimeIntervalMicroSeconds interval=time.MicroSecondsFrom(iTime); - TInt ret=KErrNone; - if (intervalmaxInterval) - ret=KErrGeneral; - iFunctions->Client().RequestComplete(iStatusPtr,ret); - } - break; - case ESyncLeave: - User::Leave(KErrGeneral); // Test: Not allowed to leave, will cause a panic - break; - case ESyncStateTimeChange1: - if (!aDateTime) - { - iFunctions->Client().RequestComplete(iStatusPtr,KErrNone); - iSyncState=ESyncStateTimeChange2; - } - break; - case ESyncStateTimeChange2: - if (!aDateTime) - { - iSyncState=ESyncStateTimeChange3; - break; - } - case ESyncStateTimeChange3: - iFunctions->Client().RequestComplete(iStatusPtr2,aDateTime ? KErrNone : KErrGeneral); - iSyncState=ESyncStateNull; - break; - } - } - -void CPanicAnim::Redraw() - { - if (iLeaveInRedraw) - User::Leave(KErrGeneral); //Test: Not allowed to leave, will cause a panic - } - -void CPanicAnim::Command(TInt aOpcode, TAny *) - { - switch(aOpcode) - { - case EADllPanicCallPanic: - iFunctions->Panic(); - break; - case EADllPanicSetInterval: - iFunctions->SetSync(MAnimGeneralFunctions::ESyncSecond); - iFunctions->SetInterval(1); - break; - case EADllPanicSetNextInterval: - iFunctions->SetSync(MAnimGeneralFunctions::ESyncMinute); - iFunctions->SetNextInterval(1); - break; - case EADllPanicDoubleActivateGC: - iWindowFunctions->ActivateGc(); - iWindowFunctions->ActivateGc(); - break; - case EADllPanicDrawRectWithNoGc: - iGc->DrawRect(TRect(0,0,10,10)); - break; - case EADllPanicDrawTextWithNoFont: - iWindowFunctions->ActivateGc(); - iGc->DrawText(_L("Panic"),TPoint(20,20)); - break; - case EADllPanicLeaveInAnimate: - iFunctions->SetSync(MAnimGeneralFunctions::ESyncFlash); - iSyncState=ESyncLeave; - break; - case EADllPanicLeaveInRedraw: - iLeaveInRedraw=ETrue; - iWindowFunctions->Invalidate(TRect(0,0,10,10)); - break; - case EADllPanicLeave: - //tests a leaving function in a non-leaving function and should not be moved to CommandReplyL as it leaves - User::Leave(KErrGeneral); //LeaveScan: intentional test - break; - case EADllPanicSetVisWithGcActive: - iWindowFunctions->ActivateGc(); - iWindowFunctions->SetVisible(EFalse); - iWindowFunctions->SetVisible(ETrue); - break; - case EADllPanicLeaveInActiveCallback: - iActivePanicIdle=CIdle::NewL(EPriorityHigh); - iActivePanicIdle->Start(TCallBack(CPanicAnim::LeaveInActiveCallback,this)); - break; - case EADllPanicSetClippingRectWithNoGc: - { - // currently this test fails because when deactivated iWin is also NULL and is deferenced in function - TRect rect(20,20,20,20); - iGc->SetClippingRect(rect); - } - break; - case EADllPanicCancelClippingRegionWithNoGc: - // currently this test fails because when deactivated iWin is NULL and function leaves - iGc->CancelClippingRegion(); - break; - case EADllPanicCancelClippingRectWithNoGc: - // currently this test fails because when deactivated iWin is also NULL and is deferenced in function - iGc->CancelClippingRect(); - break; - case EADllPanicSetDrawModeWithNoGc: - iGc->SetDrawMode(CGraphicsContext::EDrawModeAND); - break; - case EADllPanicUseFontWithNoGc: - { - // currently this test fails because does not check for NULL font - CFbsFont* font = NULL; - iGc->UseFont(font); - } - break; - case EADllPanicDiscardFontWithNoGc: - iGc->DiscardFont(); - break; - case EADllPanicSetUnderlineStyleWithNoGc: - iGc->SetUnderlineStyle(EUnderlineOff); - break; - case EADllPanicSetStrikeThoughStyleWithNoGc: - iGc->SetStrikethroughStyle(EStrikethroughOff); - break; - case EADllPanicSetWordJustificationWithNoGc: - iGc->SetWordJustification(0,0); - break; - case EADllPanicSetCharJustificationWithNoGc: - iGc->SetCharJustification(0,0); - break; - case EADllPanicSetPenColorWithNoGc: - { - TRgb rgbs; - iGc->SetPenColor(rgbs); - } - break; - case EADllPanicSetPenStyleWithNoGc: - iGc->SetPenStyle(CGraphicsContext::ESolidPen); - break; - case EADllPanicSetPenSizeWithNoGc: - { - const TSize size; - iGc->SetPenSize(size); - } - break; - case EADllPanicSetBrushColorWithNoGc: - { - TRgb rgbs; - iGc->SetBrushColor(rgbs); - } - break; - case EADllPanicSetBrushStyleWithNoGc: - iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - break; - case EADllPanicSetBrushOriginWithNoGc: - { - TPoint point; - iGc->SetBrushOrigin(point); - } - break; - case EADllPanicUseBrushPatterWithNoGc: - { - CFbsBitmap* bitmap = new(ELeave) CFbsBitmap(); - CleanupStack::PushL(bitmap); - User::LeaveIfError(bitmap->Create(TSize(16,16),EGray4)); - iGc->UseBrushPattern(bitmap); - CleanupStack::PopAndDestroy(bitmap); - } - break; - case EADllPanicDiscardBrushPatternWithNoGc: - iGc->DiscardBrushPattern(); - break; - case EADllPanicSetFadedWithNoGc: - iGc->SetFaded(EFalse); - break; - case EADllPanicSetFadingParametersWithNoGc: - iGc->SetFadingParameters(1,1); - break; - case EADllPanicDrawArcWithNoGc: - { - TRect rect; - iGc->DrawArc(rect, - TPoint(rect.Center().iX, rect.iTl.iY), - TPoint(rect.iBr.iX, rect.Center().iY)); - } - break; - case EADllPanicDrawPieWithNoGc: - { - TRect rect; - iGc->DrawPie(rect, TPoint(rect.Center().iX, rect.iTl.iY), TPoint(rect.iBr.iX, rect.Center().iY)); - } - break; - case EADllPanicDrawLineWithNoGc: - { - const TPoint point1; - const TPoint point2; - iGc->DrawLine(point1, point2); - } - break; - case EADllPanicDrawLineToWithNoGc: - { - const TPoint point; - iGc->DrawLineTo(point); - } - break; - case EADllPanicDrawLineByWithNoGc: - { - const TPoint point; - iGc->DrawLineBy(point); - } - break; - case EADllPanicDrawEllipseWithNoGc: - { - TRect rect(20,20,20,20); - iGc->DrawEllipse(rect); - } - break; - case EADllPanicDrawRoundedRecWithNoGc: - { - TRect rect; - iGc->DrawRoundRect(rect, TSize(rect.Width()/8, rect.Height()/8)); - } - break; - case EADllPanicClearWithRectWithNoGc: - { - TRect rect(20,20,20,20); - iGc->Clear(rect); - } - break; - case EADllPanicClearWithNoGc: - iGc->Clear(); - break; - case EADllPanicBitBltWithNoGc: - { - CFbsBitmap* bitmap = new(ELeave) CFbsBitmap(); - CleanupStack::PushL(bitmap); - User::LeaveIfError(bitmap->Create(TSize(16,16),EGray4)); - iGc->BitBlt(TPoint(0, 0), bitmap); - CleanupStack::PopAndDestroy(bitmap); - } - break; - case EADllPanicBitBltWithRectWithNoGc: - { - CFbsBitmap* bitmap = new(ELeave) CFbsBitmap(); - TRect rect; - CleanupStack::PushL(bitmap); - User::LeaveIfError(bitmap->Create(TSize(16,16),EGray4)); - iGc->BitBlt(TPoint(0, 0), bitmap, rect); - CleanupStack::PopAndDestroy(bitmap); - } - break; - case EADllPanicBitBltMaskedWithNoGc: - { - CFbsBitmap* bitmap = new(ELeave) CFbsBitmap(); - TRect rect; - CleanupStack::PushL(bitmap); - User::LeaveIfError(bitmap->Create(TSize(16,16),EGray4)); - iGc->BitBltMasked(TPoint(0, 0), bitmap, rect, bitmap, EFalse); - CleanupStack::PopAndDestroy(bitmap); - } - break; - case EADllPanicDrawBitmapMaskedFbsBitmapWithNoGc: - { - CFbsBitmap* bitmap = new(ELeave) CFbsBitmap(); - TRect rect; - CleanupStack::PushL(bitmap); - User::LeaveIfError(bitmap->Create(TSize(16,16),EGray4)); - iGc->DrawBitmapMasked(rect, bitmap, rect, bitmap, ETrue); - CleanupStack::PopAndDestroy(bitmap); - } - break; - case EADllPanicDrawBitmapMaskedWsBitmapWithNoGc: - { - CWsBitmap* bitmap = NULL; - TRect rect; - iGc->DrawBitmapMasked(rect, bitmap, rect, bitmap, ETrue); - } - break; - case EADllPanicDrawBitmapPointWithNoGc: - { - CWsBitmap* bitmap = NULL; - TRect rect; - iGc->DrawBitmap(rect.iTl, bitmap); - } - break; - case EADllPanicDrawBitmapWithNoGc: - { - CWsBitmap* bitmap = NULL; - TRect rect; - iGc->DrawBitmap(rect, bitmap); - } - break; - case EADllPanicDrawBitmapRectWithNoGc: - { - CWsBitmap* bitmap = NULL; - TRect rect; - iGc->DrawBitmap(rect, bitmap, TRect(0, 0, 16, 16)); - } - break; - case EADllPanicDrawPolyLinePointsWithNoGc: - { - TRect rect; - CArrayFixFlat* polyPoints = new(ELeave) CArrayFixFlat(3); //CArrayFixFlat - CleanupStack::PushL(polyPoints); - polyPoints->AppendL(rect.iTl); - polyPoints->AppendL(rect.Center()); - polyPoints->AppendL(TPoint(rect.iBr.iX, rect.iTl.iY)); - iGc->DrawPolyLine(&polyPoints->At(0), 3); - CleanupStack::PopAndDestroy(polyPoints); - } - break; - case EADllPanicDrawPolyLineArrayWithNoGc: - { - TRect rect; - CArrayFixFlat* polyPoints = new(ELeave) CArrayFixFlat(3); //CArrayFixFlat - CleanupStack::PushL(polyPoints); - polyPoints->AppendL(rect.iTl); - polyPoints->AppendL(rect.Center()); - polyPoints->AppendL(TPoint(rect.iBr.iX, rect.iTl.iY)); - iGc->DrawPolyLine(polyPoints); - CleanupStack::PopAndDestroy(polyPoints); - } - break; - case EADllPanicMoveToWithNoGc: - { - TPoint point; - iGc->MoveTo(point); - } - break; - case EADllPanicMoveByWithNoGc: - { - TPoint point; - iGc->MoveBy(point); - } - break; - case EADllPanicPlotWithNoGc: - { - TPoint point; - iGc->Plot(point); - } - break; - case EADllPanicSetOriginWithNoGc: - { - TPoint point; - iGc->SetOrigin(point); - } - break; - case EADllPanicCopyRectWithNoGc: - { - TPoint point; - TRect rect; - iGc->CopyRect(point, rect); - } - break; - case EADllPanicResetWithNoGc: - iGc->Reset(); - break; - case EADllPanicMapColorsWithNoGc: - { - TRgb rgbs[2]; - TRect rect; - iGc->MapColors(rect, rgbs, 1, ETrue); - } - break; - case EADllPanicDrawTextWithRectWithNoFont: - iWindowFunctions->ActivateGc(); - iGc->DrawText(_L("Panic"),TRect(20,20,20,20),0); - break; - case EADllPanicDrawTextVerticalWithNoFont: - iWindowFunctions->ActivateGc(); - iGc->DrawTextVertical(_L("Panic"),TPoint(20,20), EFalse); - break; - case EADllPanicDrawTextVerticalWithRectWithNoFont: - iWindowFunctions->ActivateGc(); - iGc->DrawTextVertical(_L("Panic"),TRect(20,20,20,20), 0, EFalse); - break; - case EADllPanicInvalidFocusScreenTooBig: - (static_cast(iFunctions->ExtendedInterface(MAnimGeneralFunctions::EWindowExtensionInterface)))->SetFocusScreen(3000); - break; - case EADllPanicInvalidFocusScreenNegative: - (static_cast(iFunctions->ExtendedInterface(MAnimGeneralFunctions::EWindowExtensionInterface)))->SetFocusScreen(-1); - break; - default: - iFunctions->Panic(); - } - } - -void CPanicAnim::DoLeaveInActiveCallback() - { - iWindowFunctions->ActivateGc(); - User::Leave(KErrUnknown); - } - -TInt CPanicAnim::LeaveInActiveCallback(TAny *aThis) - { - CPanicAnim* panicAnim=(CPanicAnim*)aThis; - panicAnim->DoLeaveInActiveCallback(); - return(KErrNone); - } - -void CPanicAnim::StartSyncTest(MAnimGeneralFunctions::TAnimSync aSync) - { - iFunctions->SetSync(aSync); - iSyncMode=aSync; - iSyncState=ESyncStateStarting; - } - -void CPanicAnim::StartTimeChangeTest() - { - iFunctions->SetSync(MAnimGeneralFunctions::ESyncSecond); - iSyncMode=MAnimGeneralFunctions::ESyncSecond; - iSyncState=ESyncStateTimeChange1; - } - -TInt CPanicAnim::CommandReplyL(TInt aOpcode,TAny* aParams) - { - TAnimArgUnion pData; - pData.any=aParams; - switch(aOpcode) - { - case EADllPanicBadFont: - iFunctions->DuplicateFontL(123); - break; - case EADllPanicBadBitmap: - iFunctions->DuplicateBitmapL(123); - break; - case EADllPanicCallPanic: - iFunctions->Panic(); - break; - case EADllReadRemoteDescriptor: - { - TInt ret=0; - const RMessagePtr2& message=*iFunctions->Message(); - TInt bufLength = message.GetDesLength(KIpcSlot); - TUint16* heapCell=static_cast(User::AllocL(bufLength*2)); - TPtr buf(heapCell,bufLength*2,bufLength*2); - const TInt theError=message.Read(KIpcSlot,buf); - if(theError == KErrNone) - { - for (TInt index=0;indexWindowSize()); - case EADllSyncTests: - iStatusPtr=pData.SyncTests->status; - StartSyncTest(pData.SyncTests->syncMode); - break; - case EADllTimeChangedTest: - iStatusPtr=pData.TimeChangeTest->status; - iStatusPtr2=pData.TimeChangeTest->status2; - StartTimeChangeTest(); - break; - case EADllTestSetVisible: - if (iWindowFunctions->IsHidden()) - goto setVisFailed; - iWindowFunctions->SetVisible(EFalse); - if (!iWindowFunctions->IsHidden()) - goto setVisFailed; - iWindowFunctions->SetVisible(ETrue); - if (iWindowFunctions->IsHidden()) -setVisFailed: return(EFalse); - return(ETrue); - case EADllPanicSetVisWithGcActiveReply: - iWindowFunctions->ActivateGc(); - iWindowFunctions->SetVisible(EFalse); - iWindowFunctions->SetVisible(ETrue); - break; - case EADllPanicSetClippingRegionWithNoGc: - { - // currently this test fails because when deactivated iWin is also NULL and is deferenced in function - RRegion region; - TBool err = iGc->SetClippingRegion(region); - } - break; - case EADllPanicDrawPolygonPointsWithNoGc: - { - TRect rect(20,20,20,20); - CArrayFixFlat* polyPoints = new(ELeave) CArrayFixFlat(3); //CArrayFixFlat - CleanupStack::PushL(polyPoints); - polyPoints->AppendL(rect.iTl); - polyPoints->AppendL(rect.Center()); - polyPoints->AppendL(TPoint(rect.iBr.iX, rect.iTl.iY)); - iGc->DrawPolygon(polyPoints, CGraphicsContext::EWinding); - CleanupStack::PopAndDestroy(polyPoints); - } - break; - case EADllPanicDrawPolygonArrayWithNoGc: - { - TRect rect(20,20,20,20); - CArrayFixFlat* polyPoints = new(ELeave) CArrayFixFlat(3); //CArrayFixFlat - CleanupStack::PushL(polyPoints); - polyPoints->AppendL(rect.iTl); - polyPoints->AppendL(rect.Center()); - polyPoints->AppendL(TPoint(rect.iBr.iX, rect.iTl.iY)); - iGc->DrawPolygon(&polyPoints->At(0), 3, CGraphicsContext::EAlternate); - CleanupStack::PopAndDestroy(polyPoints); - } - break; - case EADllPanicAlphaBlendingBitmapsFbsBitmapWithNoGc: - { - TRect rect(20,20,20,20); - CFbsBitmap* bitmap = new(ELeave) CFbsBitmap(); - CleanupStack::PushL(bitmap); - User::LeaveIfError(bitmap->Create(TSize(16,16),EGray4)); - iGc->AlphaBlendBitmaps(TPoint(0, 0), bitmap, rect, bitmap, TPoint(0,0)); - CleanupStack::PopAndDestroy(bitmap); - } - break; - case EADllPanicDevice: - { - CGraphicsDevice *device = iGc->Device(); - } - break; - default: - iFunctions->Panic(); - } - return(KErrNone); - } - -void CPanicAnim::FocusChanged(TBool ) - { - } - -TBool CPanicAnim::OfferRawEvent(const TRawEvent &/*aRawEvent*/) - { - return EFalse; - } - - -// CPanicAnim2 simply panics in the construct // -void CPanicAnim2::ConstructL(TAny *, TBool ) - { - iFunctions->Panic(); - } - -void CPanicAnim2::Animate(TDateTime *) - {} - -void CPanicAnim2::Redraw() - {} - -void CPanicAnim2::Command(TInt , TAny *) - {} - -TInt CPanicAnim2::CommandReplyL(TInt , TAny *) - {return(0);} - -void CPanicAnim2::FocusChanged(TBool ) - {} - -TBool CPanicAnim2::OfferRawEvent(const TRawEvent &/*aRawEvent*/) - { - return EFalse; - } - - -// CAutoAnim3 test drawing/redrawing // -void CAutoAnim3::ConstructL(TAny *aParam, TBool ) - { - iRect=*((TRect *)aParam); - iWindowFunctions->SetRect(iRect); - iMode=0; - iWindowFunctions->Invalidate(iRect); - iFunctions->SetSync(MAnimGeneralFunctions::ESyncSecond); - } - -void CAutoAnim3::Animate(TDateTime *) - { - iWindowFunctions->ActivateGc(); - if (iMode==1) - { - Draw(iRect); - if (iRect.Width()>20 && iRect.Height()>20) - iRect.Shrink(TSize(20,20)); - else - iRect=iBaseRect; - Draw(iRect); - } - else if (iMode==2) - { - Draw(iRect); - iFunctions->Client().RequestComplete(iStatusPtr,KErrNone); - iFunctions->SetSync(MAnimGeneralFunctions::ESyncNone); - } - else if (iMode==3) - { - // flip between two sizes - if (iRect.iTl.iX == 10) - iRect.SetRect(40,40,80,80); - else - iRect.SetRect(10,10,110,110); - Draw(iRect); - } - } - -void CAutoAnim3::Draw(const TRect &aRect) - { - switch(iMode) - { - case 0: - iGc->SetDrawMode(CGraphicsContext::EDrawModeXOR); - iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - iGc->SetBrushColor(TRgb::Gray256(85)); - iGc->SetPenColor(TRgb::Gray256(170)); - iGc->DrawEllipse(aRect); - iGc->SetBrushStyle(CGraphicsContext::ENullBrush); - break; - case 1: // Shrinking box - iGc->SetDrawMode(CGraphicsContext::EDrawModeXOR); - iGc->SetPenColor(TRgb::Gray256(255)); - iGc->DrawRect(aRect); - break; - case 2: - case 3: - iGc->SetDrawMode(CGraphicsContext::EDrawModePEN); - iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - iGc->SetBrushColor(TRgb::Gray256(85)); - iGc->SetPenColor(TRgb::Gray256(170)); - iGc->DrawEllipse(aRect); - iGc->SetBrushStyle(CGraphicsContext::ENullBrush); - break; - default: - break; - } - } - -void CAutoAnim3::Redraw() - { - Draw(iRect); - } - -void CAutoAnim3::Command(TInt aOpcode,TAny* aParam) - { - TAnimArgUnion pData; - pData.any=aParam; - switch(aOpcode) - { - case EADllSetRect: - iWindowFunctions->ActivateGc(); - Draw(iRect); - iRect=*pData.Rect; - iWindowFunctions->SetRect(iRect); - Draw(iRect); - { //Do more extensive testing - TWindowInfo data; - iWindowFunctions->Parameters(data); - } - break; - case EADllStartAnimate: - iWindowFunctions->ActivateGc(); - Draw(iRect); - iMode=1; - iBaseRect=*pData.Rect; - iRect=iBaseRect; - iWindowFunctions->SetRect(iRect); - iFunctions->SetSync(MAnimGeneralFunctions::ESyncFlash); - Draw(iRect); - break; - case EADllCancelAnimate: - iFunctions->SetSync(MAnimGeneralFunctions::ESyncNone); - iWindowFunctions->ActivateGc(); - Draw(iRect); - iMode=-1; - break; - case EADllSetVisible: - iWindowFunctions->SetVisible(*pData.Bool); - break; - case EADllSetShadowDrawMode: - iMode=2; - break; - case EADllDrawTestScreen: - DrawTestScreenL(pData.DrawTestScreen); //Should move to CommandReplyL as it leaves - break; - case EADllSetMode: - iMode = *pData.Int; - break; - } - } - -TInt CAutoAnim3::CommandReplyL(TInt aOpcode, TAny *aParam) - { - TAnimArgUnion pData; - pData.any = aParam; - TInt ret=0; - switch(aOpcode) - { - case EADllShadowAnimTest: - iFunctions->SetSync(MAnimGeneralFunctions::ESyncFlash); - iStatusPtr=((TShadowDrawTest *)aParam)->status; - break; - case EADllParameterRectValueTest: - { - TWindowInfo wininf; - iWindowFunctions->Parameters(wininf); - TRect comp = *(pData.Rect); - ret=(comp==wininf.iScreenPos); - } - break; - case EADllDoSetSync: - iFunctions->SetSync(static_cast(*pData.Int)); - break; - case EADllSetInterval: - iFunctions->SetInterval(*pData.Int); - break; - } - return(ret); - } - -void CAutoAnim3::FocusChanged(TBool ) - {} - -//void CAutoAnim3::DrawTestScreen(TDrawTestScreen *aParams) -//Function now at bottom of file - -TBool CAutoAnim3::OfferRawEvent(const TRawEvent &/*aRawEvent*/) - { - return EFalse; - } - - -// CAutoAnimScrBack test drawing/redrawing // -void CAutoAnimScrBack::ConstructL(TAny *aParam, TBool ) - { - iRect=*((TRect *)aParam); - iWindowFunctions->SetRect(iRect); - iMode=1; - iFunctions->SetSync(MAnimGeneralFunctions::ESyncFlash); - } - -void CAutoAnimScrBack::Animate(TDateTime *) - { - iWindowFunctions->ActivateGc(); - Draw(); - iFunctions->SetSync(MAnimGeneralFunctions::ESyncNone); - } - -void CAutoAnimScrBack::Draw() - { - iGc->SetDrawMode(CGraphicsContext::EDrawModePEN); - if (iMode==2) - iGc->SetPenSize(TSize(3,3)); - iGc->SetPenColor(TRgb::Gray4(iMode==1 ? 2 : 3)); - iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - iGc->SetBrushColor(TRgb::Gray4(iMode==1 ? 1 : 0)); - iGc->DrawRect(iRect); - } - -void CAutoAnimScrBack::Redraw() - { - Draw(); - } - -void CAutoAnimScrBack::Command(TInt aOpcode,TAny* aParam) - { - TAnimArgUnion pData; - pData.any=aParam; - switch(aOpcode) - { - case EADllDrawOtherRect: - { - TRect oldRect(iRect); - if (iMode==2) - oldRect.Grow(1,1); // To allow for 3x3 pen size - iMode=2; - iRect=*pData.Rect; - TRect fullRect(iRect); - fullRect.Grow(1,1); // To allow for 3x3 pen size - iWindowFunctions->Invalidate(oldRect); - iWindowFunctions->SetRect(fullRect); - iWindowFunctions->Invalidate(fullRect); - } -// iFunctions->ActivateGc(); -// Draw(); - break; - } - } - -TInt CAutoAnimScrBack::CommandReplyL(TInt aOpcode, TAny *) - { - switch(aOpcode) - { - case EADllIsHidden: - return iWindowFunctions->IsHidden(); - } - return(0); - } - -void CAutoAnimScrBack::FocusChanged(TBool ) - {} - -TBool CAutoAnimScrBack::OfferRawEvent(const TRawEvent &/*aRawEvent*/) - { - return EFalse; - } - - -// CTestSpriteAnim test sprite access // -void CTestSpriteAnim::ConstructL(TAny* /*aParam*/) - { - iSpriteFunctions->SizeChangedL(); - iSpriteFunctions->Activate(ETrue); - } - -void CTestSpriteAnim::Animate(TDateTime*) - { - } - -void CTestSpriteAnim::Command(TInt aOpcode,TAny* aParam) - { - TAnimArgUnion pData; - pData.any=aParam; - switch (aOpcode) - { - case EADllSizeChanged: - iSpriteFunctions->Activate(EFalse); - iSpriteFunctions->SizeChangedL(); //Should move to CommandReplyL as it leaves - case EADllActivate: - iSpriteFunctions->Activate(ETrue); - break; - case EADllDeactivate: - iSpriteFunctions->Activate(EFalse); - break; - case EADllSetPos: - iSpriteFunctions->SetPosition(*pData.Point); - break; - case EADllDraw1: - case EADllDraw2: - case EADllDraw3: - DrawMemberL(aOpcode-EADllDraw1); //Should move to CommandReplyL as it leaves - break; - case EADllIncDraw: - DrawMemberL(); //Should move to CommandReplyL as it leaves - break; - default:; - } - } - -TInt CTestSpriteAnim::CommandReplyL(TInt aOpcode,TAny* aParam) - { - TAnimArgUnion pData; - pData.any=aParam; - switch (aOpcode) - { - case EADllCheckMember: - return CheckMember(*pData.SpriteMemberInfo); - default:; - } - return(KErrNone); - } - -TBool CTestSpriteAnim::OfferRawEvent(const TRawEvent& /*aRawEvent*/) - { - return EFalse; - } - -TBool CTestSpriteAnim::CheckMember(const TSpriteMemberInfo& aMemInfo) - { - TSpriteMember spriteMember=*iSpriteFunctions->GetSpriteMember(aMemInfo.iMember); - if (spriteMember.iBitmap->Handle()!=aMemInfo.iBitmapHandle) - return EFalse; - if (aMemInfo.iMaskBitmapHandle==0) - { - if (spriteMember.iMaskBitmap!=NULL) - return EFalse; - } - else - { - if (spriteMember.iMaskBitmap->Handle()!=aMemInfo.iMaskBitmapHandle) - return EFalse; - } - if (spriteMember.iInvertMask!=aMemInfo.iInvertMask) - return EFalse; - if (spriteMember.iDrawMode!=aMemInfo.iDrawMode) - return EFalse; - if (spriteMember.iOffset!=aMemInfo.iOffset) - return EFalse; - if (spriteMember.iInterval!=aMemInfo.iInterval) - return EFalse; - return ETrue; - } - -void CTestSpriteAnim::DrawMemberL(TInt aMember) - { - CFbsBitmap *bitmap=iSpriteFunctions->GetSpriteMember(aMember)->iBitmap; - CFbsBitmapDevice *device=CFbsBitmapDevice::NewL(bitmap); - CleanupStack::PushL(device); - CFbsBitGc *gc; - User::LeaveIfError(device->CreateContext(gc)); - CleanupStack::PushL(gc); - //gc->SetBrushColor(TRgb::Gray4((aMember+1)%3)); - gc->SetBrushStyle(CGraphicsContext::ESolidBrush); - gc->SetPenSize(TSize()); - TSize size=bitmap->SizeInPixels(); - size.SetSize(size.iWidth/2,size.iHeight/2); - TPoint point=size.AsPoint(); - gc->SetBrushColor(TRgb::Gray4(0)); - //TRect rect=bitmap->SizeInPixels(); - gc->DrawRect(TRect(TPoint(),size)); - gc->SetBrushColor(TRgb::Gray4(1)); - gc->DrawRect(TRect(TPoint(point.iX,0),size)); - gc->SetBrushColor(TRgb::Gray4(2)); - gc->DrawRect(TRect(TPoint(0,point.iY),size)); - gc->SetBrushColor(TRgb::Gray4(3)); - gc->DrawRect(TRect(point,size)); - iSpriteFunctions->UpdateMember(aMember,TRect(bitmap->SizeInPixels()),ETrue); - CleanupStack::PopAndDestroy(2); - } - -void CTestSpriteAnim::DrawMemberL() - { - CFbsBitmap *bitmap=iSpriteFunctions->GetSpriteMember(0)->iBitmap; - CFbsBitmapDevice *device=CFbsBitmapDevice::NewL(bitmap); - CleanupStack::PushL(device); - CFbsBitGc *gc; - User::LeaveIfError(device->CreateContext(gc)); - CleanupStack::PushL(gc); - gc->SetPenSize(TSize(3,3)); - gc->SetPenColor(TRgb::Gray4(1)); - TPoint corner=bitmap->SizeInPixels().AsPoint(); - gc->DrawLine(TPoint(),corner); - gc->DrawLine(TPoint(0,corner.iY),TPoint(corner.iX,0)); - iSpriteFunctions->UpdateMember(0,TRect(bitmap->SizeInPixels()),EFalse); - CleanupStack::PopAndDestroy(2); - } - - -// CTestFreeTimerAnim test drawing off own timer // -CTestFreeTimerAnim::~CTestFreeTimerAnim() - { - iTimer->Cancel(); - delete iTimer; - } - -void CTestFreeTimerAnim::ConstructL(TAny* /*aParam*/, TBool ) - { - User::LeaveIfNull(iFunctions); - User::LeaveIfNull(iWindowFunctions); - - //Configure free-timer anim (these values should be the default ones) - iFunctions->SetSync( MAnimGeneralFunctions::ESyncNone ); - iFunctions->SetInterval(0); - - iFrameTime = 100000; //default frametime 0.1s - iTimer = CAnimTimer::NewL(*this); - iRect = iWindowFunctions->WindowSize(); - } - -#define MAX(a,b) (((a)>(b))?(a):(b)) - -void CTestFreeTimerAnim::Animate(TDateTime*) - { - TInt max = MAX(iRect.Width(), iRect.Height()); - if(max <= 0) - { - iRect = iWindowFunctions->WindowSize(); - } - else - { - iRect.Shrink(1,1); - } - - //change colour - switch(iColour.Value()) - { - case 0x000000: //black - case 0xffffff: //white - iColour = KRgbRed; - break; - case 0x0000ff: //red - iColour = KRgbGreen; - break; - case 0x00ff00: //green - iColour = KRgbBlue; - break; - case 0xff0000: //blue - iColour = KRgbBlack; - break; - } - } - -void CTestFreeTimerAnim::Redraw() - { - //draw something in the animated colour - iGc->SetBrushColor(iColour); - iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - iGc->SetPenColor(KRgbBlack); - iGc->DrawRect(iRect); - } - -void CTestFreeTimerAnim::Command(TInt aOpcode, TAny* aArgs) - { - switch(aOpcode) - { - case EStartAnimation: - DisplayNextFrameL(); - break; - case EStopAnimation: - iTimer->Cancel(); - break; - case ESetFrameTime: - ASSERT(aArgs); - iFrameTime = *reinterpret_cast(aArgs); - break; - default: - ASSERT(0); - } - } - -TInt CTestFreeTimerAnim::CommandReplyL(TInt aOpcode, TAny* aArgs) - { - switch(aOpcode) - { - case EStartAnimation: - DisplayNextFrameL(); - break; - case EStopAnimation: - iTimer->Cancel(); - break; - case ESetFrameTime: - ASSERT(aArgs); - iFrameTime = *reinterpret_cast(aArgs); - break; - default: - ASSERT(0); - } - return(KErrNone); - } - -void CTestFreeTimerAnim::FocusChanged(TBool /*aState*/) - { - } - -TBool CTestFreeTimerAnim::OfferRawEvent(const TRawEvent& /*aRawEvent*/) - { - return EFalse; - } - - -void CTestFreeTimerAnim::DisplayNextFrameL() - { - //Reschedule timer callback - iTimer->Cancel(); - iTimer->After(iFrameTime); - - Animate(NULL); //wserv don't animate free-timer animations - - //Schedule wserv redraw - MAnimFreeTimerWindowFunctions* windowFunctions = WindowFunctions(); - ASSERT(windowFunctions); - windowFunctions->ActivateGc(); - windowFunctions->DeactivateGc(); - windowFunctions->Update(); - } - -// -// CAnimTimer class -// - -/** - Constructs a new bitmap animation timer object,and adds the specified active object to the current active scheduler. - -@param aObserver a pointer to MAnimTimerObserver -*/ -CAnimTimer::CAnimTimer(MAnimTimerObserver& aObserver) - :CTimer(EPriorityStandard), - iAnim(aObserver) - { - CActiveScheduler::Add(this); - } - -/** - Frees resources owned by the object prior to deletion. -*/ -CAnimTimer::~CAnimTimer() - { - } - -/** - Creates a new bitmap animation timer object. - -@param aObserver A pointer to the MAnimTimerObserver -@return A pointer to the new bitmap animation timer object. -*/ -CAnimTimer* CAnimTimer::NewL(MAnimTimerObserver& aObserver) - { - CAnimTimer* timer=new(ELeave) CAnimTimer(aObserver); - CleanupStack::PushL(timer); - timer->ConstructL(); - CleanupStack::Pop(); - return timer; - } - -/** - Completes construction of the bitmap animation timer object and - constructs a new asynchronous timer. -*/ -void CAnimTimer::ConstructL() - { - CTimer::ConstructL(); - } - -/** - Handles an active object's request completion event. - Invokes the function to draw the next frame -*/ -void CAnimTimer::RunL() - { - iAnim.DisplayNextFrameL(); - } - -// CEventTestAnimBase base class for event test anims // -CEventTestAnimBase::~CEventTestAnimBase() - { - iFunctions->GetRawEvents(EFalse); - } - -void CEventTestAnimBase::ConstructL(TAny* /*aParam*/, TBool ) - { - iExpectedEvents.SetLengthL(EEventBufferSize); - } - -void CEventTestAnimBase::Animate(TDateTime*) - { - } - -void CEventTestAnimBase::Redraw() - { - } - -void CEventTestAnimBase::Command(TInt /*aOpcode*/, TAny* /*aParam*/) - { - /*switch (aOpcode) - { - default:; - }*/ - } - -void CEventTestAnimBase::FocusChanged(TBool /*aState*/) - { - } - -// Base class common client server interface -TInt CEventTestAnimBase::CommandReplyL(TInt aOpcode,TAny* aParam) - { - TAnimArgUnion pData; - pData.any=aParam; - switch (aOpcode) - { - case EADllAddExpectedEvent: - return AddExpectedEvent(pData.AnimRawEvent); - case EADllNumberOfEventsReceived: - return iEventCount; - case EADllErrorCode: - return iError; - case EADllReset: - iExpectedEvents.Reset(); - iError = 0; - iEventCount = 0; - return KErrNone; - default:; - } - return(KErrNone); - } - -TBool CEventTestAnimBase::HandleRecursiveEvent(const TRawEvent& aRawEvent) - { - if (aRawEvent.ScanCode() == 60) - { - TRawEvent rawEvent; - rawEvent.Set(TRawEvent::EKeyUp, 34); - iFunctions->PostRawEvent(rawEvent); - rawEvent.Set(TRawEvent::EKeyUp, 35); - iFunctions->PostRawEvent(rawEvent); - return ETrue; - } - return EFalse; - } - -TBool CEventTestAnimBase::OfferRawEvent(const TRawEvent& aRawEvent) - { - // Do not consume the following types of events - if (IsIgnorableEvent(aRawEvent)) - { - return EFalse; - } - - // Increment event count if not in an error state - if (!Error()) - { - iEventCount++; - } - - // For anim which generates recursive events - if (aRawEvent.Type() == TRawEvent::EKeyDown && aRawEvent.ScanCode() == 60) - { - return HandleRecursiveEvent(aRawEvent); - } - - TAnimRawEvent event; - - if (!GetNextExpectedEvent(event)) - { - Fail(); - return EFalse; - } - - // Fail if wrong event type - if (!CompareEvents(event.iRawEvent, aRawEvent)) - { - Fail(); - } - - return event.iEat; - } - -TBool CEventTestAnimBase::GetNextExpectedEvent(TAnimRawEvent& aRawEvent) - { - // Get next expected event - if (iExpectedEvents.Remove(&aRawEvent)<1) - { - Fail(); - return EFalse; - } - else - { - return ETrue; - } - } - -TBool CEventTestAnimBase::IsIgnorableEvent(const TRawEvent& aRawEvent) const - { - TRawEvent::TType aType=aRawEvent.Type(); - TBool result = (aType==TRawEvent::EActive || aType==TRawEvent::EInactive || aType==TRawEvent::ERedraw - || (iExpectedEvents.Count()==0 && aType==TRawEvent::EPointerMove)); - - return result; - } - -TBool CEventTestAnimBase::CompareEvents(const TRawEvent& aExpectedEvent, const TRawEvent& aActualEvent) const - { - TRawEvent::TType eType=aExpectedEvent.Type(); - TRawEvent::TType aType=aActualEvent.Type(); - if (eType!=aType) - { - return EFalse; - } - else - { - switch (aType) - { - case TRawEvent::EUpdateModifiers: - { - TInt eMod=aExpectedEvent.Modifiers(),aMod=aActualEvent.Modifiers(); - if (eMod!=aMod) - { - return EFalse; - } - break; - } - case TRawEvent::EKeyDown: - case TRawEvent::EKeyUp: - { - TInt eScan=aExpectedEvent.ScanCode(),aScan=aActualEvent.ScanCode(); - if (eScan!=aScan) - { - return EFalse; - } - break; - } - case TRawEvent::EPointerMove: - case TRawEvent::EPointerSwitchOn: - case TRawEvent::EButton1Down: - case TRawEvent::EButton1Up: - case TRawEvent::EButton2Down: - case TRawEvent::EButton2Up: - case TRawEvent::EButton3Down: - case TRawEvent::EButton3Up: - { - TPoint ePoint=aExpectedEvent.Pos(),aPoint=aActualEvent.Pos(); - if (ePoint!=aPoint) - { - return EFalse; - } - break; - } - default:; - } - } - return ETrue; - } - -void CEventTestAnimBase::Fail() - { - if (iError==0) - { - iError=iEventCount; - } - } - -inline TInt CEventTestAnimBase::Error() const - { - return iError; - } - -inline TInt CEventTestAnimBase::EventCount() const - { - return iEventCount; - } - -inline void CEventTestAnimBase::ResetEventCount() - { - iEventCount = 0; - } - -inline TInt CEventTestAnimBase::TotalExpectedEvents() const - { - return iExpectedEvents.Count(); - } - -inline TInt CEventTestAnimBase::AddEvent(const TAnimRawEvent* aEvent) - { - return iExpectedEvents.Add(aEvent); - } - -// CEventTestAnim test drawing off own timer // -CEventTestAnim::~CEventTestAnim() - { - UnloadDeviceDriver(); - } - -void CEventTestAnim::ConstructL(TAny* aParam, TBool aBool) - { - CEventTestAnimBase::ConstructL(aParam, aBool); - iFunctions->GetRawEvents(ETrue); - iDevDriverLoaded=EFalse; - } - -TInt CEventTestAnim::UnloadDeviceDriver() - { - TInt err=KErrNone; - iLdd.Close(); - if (iDevDriverLoaded) - { - err=User::FreeLogicalDevice(REventDD::BinaryName()); - if (err==KErrNone) - iDevDriverLoaded=EFalse; - } - return err; - } - -TInt CEventTestAnim::AddExpectedEvent(const TAnimRawEvent* aEvent) - { - return (AddEvent(aEvent) ? KErrNone : KErrOverflow); - } - -TInt CEventTestAnim::CommandReplyL(TInt aOpcode,TAny* aParam) - { - switch (aOpcode) - { - case EADllNoEventsAndReset: - { - TInt events=EventCount(); - ResetEventCount(); - return events; - } - case EADllLoadDeviceDriver: - { - TInt err=User::LoadLogicalDevice(REventDD::BinaryName()); - if (err==KErrNone || err==KErrAlreadyExists) - { - TInt err2=iLdd.Open(); - if (err==KErrNone) - { - if (err2==KErrNone) - iDevDriverLoaded=ETrue; - else //Only unload if we loaded it - User::FreeLogicalDevice(REventDD::BinaryName()); - } - err=err2; - } - return err; - } - case EADllUnloadDeviceDriver: - return UnloadDeviceDriver(); - case EADllSendEvent: - { - TAnimRawEvent event; - TInt events=*static_cast(aParam); - TInt err=KErrNone; - TInt ii; - for (ii=events;ii>0;--ii) - { - event.iRawEvent.Set(ii/2==0 ? TRawEvent::ECaseOpen : TRawEvent::ECaseClose); - //TInt err=UserSvr::AddEvent(event.iRawEvent); - //Need to do the above line here, but don't have enough capability - //so call a device driver to do it instead - err=iLdd.SendEvent(event.iRawEvent); - if (err!=KErrNone) - return err; - event.iEat=ETrue; - AddExpectedEvent(&event); - } - return KErrNone; - } - default:; - return CEventTestAnimBase::CommandReplyL(aOpcode, aParam); - } - } - -void CEventTestAnim::Command(TInt aOpcode,TAny* /*aParam*/) - { - switch (aOpcode) - { - case EADllAfterEvent: - if (TotalExpectedEvents()>0) - Fail(); - break; - default:; - } - } - -// CEventPostingAnim test posting of anim events // -CEventPostingAnim::~CEventPostingAnim() - { - } - -void CEventPostingAnim::ConstructL(TAny* aParam, TBool aBool) - { - CEventTestAnimBase::ConstructL(aParam, aBool); - iFunctions->GetRawEvents(ETrue); - } - -TInt CEventPostingAnim::AddExpectedEvent(const TAnimRawEvent* aEvent) - { - return (AddEvent(aEvent) ? KErrNone : KErrOverflow); - } - -TBool CEventPostingAnim::OfferRawEvent(const TRawEvent &aRawEvent) - { - // Call PostRawEvent or PostKeyEvent according to type of the event - TBool ret = CEventTestAnimBase::OfferRawEvent(aRawEvent); - if (ret) - { - if (aRawEvent.Type() == TRawEvent::EKeyDown && aRawEvent.ScanCode() == 45) - { - TKeyEvent event; - event.iCode='J'; - event.iScanCode=0; - event.iModifiers=0; - - // This is to check the normal PostKeyEvent API - iFunctions->PostKeyEvent(event); - - // This is to check the newly added API - iFunctions->EventExtension()->PostKeyEvent(event, 2); - } - else - { - iFunctions->PostRawEvent(aRawEvent); - } - } - return ret; - } - -// CTimerTestAnim check that timer events stop // -CTimerTestAnim::~CTimerTestAnim() - { - } - -void CTimerTestAnim::ConstructL(TAny* /*aParam*/, TBool ) - { - iWindowFunctions->SetRect(TRect(0,0,1,1)); - iFunctions->SetSync(MAnimGeneralFunctions::ESyncSecond); - iExpectingTicks=ETrue; - iFail=EFalse; - } - -void CTimerTestAnim::Animate(TDateTime*) - { - ++iTimerCount; - if (!iExpectingTicks) - iFail=iTimerCount; - } - -void CTimerTestAnim::Redraw() - { - } - -void CTimerTestAnim::Command(TInt aOpcode, TAny* /*aParam*/) - { - switch (aOpcode) - { - case EADllResetCount: - iTimerCount=0; - break; - case EADllNoTimer: - iExpectingTicks=EFalse; - iFunctions->SetSync(MAnimGeneralFunctions::ESyncNone); - break; - case EADllTimerStarted: - iExpectingTicks=ETrue; - iFunctions->SetSync(MAnimGeneralFunctions::ESyncSecond); - break; - default:; - } - } - -TInt CTimerTestAnim::CommandReplyL(TInt aOpcode, TAny* /*aParam*/) - { - switch (aOpcode) - { - case EADllCurrentCount: - return iTimerCount; - case EADllFailed: - return iFail; - default:; - } - return(KErrNone); - } - -void CTimerTestAnim::FocusChanged(TBool /*aState*/) - { - } - -TBool CTimerTestAnim::OfferRawEvent(const TRawEvent& /*aRawEvent*/) - { - return EFalse; - } - - -// CWinFunctionTestAnim test drawing off own timer // -CWinFunctionTestAnim::~CWinFunctionTestAnim() - {} - -void CWinFunctionTestAnim::ConstructL(TAny* /*aParam*/,TBool) - { - iWinFunctions=static_cast - (iFunctions->ExtendedInterface(MAnimGeneralFunctions::EWindowExtensionInterface)); - } - -void CWinFunctionTestAnim::Animate(TDateTime*) - {} - -void CWinFunctionTestAnim::Redraw() - {} - -void CWinFunctionTestAnim::Command(TInt /*aOpcode*/,TAny* /*aParam*/) - { - /*switch (aOpcode) - { - default:; - }*/ - } - -TInt CWinFunctionTestAnim::CommandReplyL(TInt aOpcode,TAny* aParam) - { - TAnimArgUnion pData; - pData.any=aParam; - switch (aOpcode) - { - case EADllScreen: - return iWinFunctions->Screens(); - case EADllFocusScreen: - return iWinFunctions->FocusScreens(); - case EADllWindowGroups: - return iWinFunctions->WindowGroups(*pData.Int); - case EADllWindowGroupInfo: - { - const TWindowGroupInfoParms& params=*pData.WindowGroupInfoParms; - TPckgBuf info; - TBool ret=iWinFunctions->WindowGroupInfo(info(),params.iScreen,params.iOrdinalPosition); - /*const TInt theError=*/(*iFunctions->Message()).Write(KIpcSlot,info); - return ret; - } - case EADllWindowGroupName: - { - const TWindowGroupInfoParms& params=*pData.WindowGroupInfoParms; - TPtrC name; - TBool ret=iWinFunctions->WindowGroupName(name,params.iScreen,params.iOrdinalPosition); - /*const TInt theError=*/(*iFunctions->Message()).Write(KIpcSlot,name); - return ret; - } - case EADllSetOrdinalPosition: - { - const TSetOrdinalParms& params=*pData.SetOrdinalParms; - return iWinFunctions->SetOrdinalPosition(params.iIdentifier,params.iOrdinalPosition,params.iOrdinalPriority); - } - case EADllSetFocusScreen: - { - const TInt& params=*pData.Int; - iWinFunctions->SetFocusScreen(params); - break; - } - default:; - } - return(KErrNone); - } - -void CWinFunctionTestAnim::FocusChanged(TBool /*aState*/) - {} - -TBool CWinFunctionTestAnim::OfferRawEvent(const TRawEvent& /*aRawEvent*/) - { - return EFalse; - } - - -// CNotificationTestAnim -CNotificationTestAnim::CNotificationTestAnim() : iHeartbeatState(EFalse) , iScreenDeviceChanged(ETrue) - { - } - -CNotificationTestAnim::~CNotificationTestAnim() - { -// Removed for test case GRAPHICS-WSERV-0139 for DEF12220 -// iFunctions->RegisterForNotifications(EFalse); - } - -void CNotificationTestAnim::ConstructL(TAny* /*aParam*/, TBool ) - { - iWindowFunctions->SetRect(TRect(0,0,1,1)); - iFunctions->RegisterForNotifications(EDirectScreenAccess|EHeartbeatTimer|EScreenDeviceChange); - iFunctions->SetSync(MAnimGeneralFunctions::ESyncSecond); - iLastAnimTime.UniversalTime(); - } - -void CNotificationTestAnim::HandleNotification(const TWsEvent& aEvent) - { - switch (aEvent.Type()) - { - case EEventDirectScreenAccessBegin: - { - TInt screenNum = *(aEvent.Int()); - iDSA[screenNum] = ETrue; - } - break; - case EEventDirectScreenAccessEnd: - { - TInt screenNum = *(aEvent.Int()); - iDSA[screenNum] = EFalse; - } - break; - case EEventHeartbeatTimerStateChange: - { - iHeartbeatState=*aEvent.Int(); - } - break; - case EEventScreenDeviceChanged: - { - iScreenDeviceChanged=!iScreenDeviceChanged; - } - break; - default: - break; - } - } - -void CNotificationTestAnim::Animate(TDateTime*) - { - iLastAnimTime.UniversalTime(); - } - -void CNotificationTestAnim::Redraw() - { - } - -void CNotificationTestAnim::Command(TInt /*aOpcode*/, TAny* /*aParam*/) - { - } - -TInt CNotificationTestAnim::CommandReplyL(TInt aOpcode,TAny* aParam) - { - TAnimArgUnion pData; - pData.any=aParam; - switch (aOpcode) - { - case EADllQueryDSA: - { - TInt screenNum = *pData.Int; - return iDSA[screenNum]; - } - case EADllQueryHeartbeatState: - { - return iHeartbeatState; - } - case EADllIsAnimating: - { - // Check if the anim DLL is currently animating by comparing - // the current time with the last anim time - if this is greater than a second - // then we are not animating - TTime timeNow; - timeNow.UniversalTime(); - TTimeIntervalMicroSeconds microSecs = timeNow.MicroSecondsFrom(iLastAnimTime); - if(microSecs > TTimeIntervalMicroSeconds(1200000)) // 1 sec plus 0.2 secs to cope with any latency - { - return EFalse; - } - else - { - return ETrue; - } - } - default:; - } - return(KErrNone); - } - -void CNotificationTestAnim::FocusChanged(TBool /*aState*/) - { - } - -TBool CNotificationTestAnim::OfferRawEvent(const TRawEvent& /*aRawEvent*/) - { - return EFalse; - } - -// CTransAnim test drawing// -void CTransAnim::ConstructL(TAny* aParam, TBool) - { - iRect=*static_cast(aParam);//Assigns the animation area - iWindowFunctions->SetRect(iRect); - iFunctions->SetSync(MAnimGeneralFunctions::ESyncFlash); - iFont=NULL; - iColor=TRgb(0,0,0); - } - -void CTransAnim::Animate(TDateTime*) - { - iWindowFunctions->ActivateGc(); - if(iMode==1) //Draw line mode - { - DoDraw(iDraw,*iGc,iColor,iRect); - } - else if(iMode==2) //Draw text mode - { - DoDraw(iDraw,*iGc,iColor,iRect,iFont,iCount); - } - } - -void CTransAnim::Redraw() - { - DoDraw(iDraw,*iGc,iColor,iRect,iFont,iCount); - } - -void CTransAnim::Command(TInt aOpcode,TAny* aParam) - { - TAnimArgUnion pData; - pData.any=aParam; - switch(aOpcode) - { - case EADllDrawNow: //Used to draw a single frame - iWindowFunctions->ActivateGc(); - iMode=1; - iDraw=36; - iColor=TRgb(0,0,0); - DoDraw(iDraw,*iGc,iColor,iRect); - break; - case EADllNextFrame: //Used to draw a continous frame - iMode=2; - iColor=pData.FrameData->color; - iDraw=pData.FrameData->draw; - iCount=pData.FrameData->text; - break; - case EADllStartAnimText: //Used to start text animate - iWindowFunctions->ActivateGc(); - iMode=2; - iDraw=37; - iFont=iFunctions->DuplicateFontL(pData.FrameData->font); - iColor=pData.FrameData->color; - iCount=pData.FrameData->text; - if(pData.FrameData->sync==EStateFlash) - iFunctions->SetSync(MAnimGeneralFunctions::ESyncFlash); - else if(pData.FrameData->sync==EStateSecond) - iFunctions->SetSync(MAnimGeneralFunctions::ESyncSecond); - DoDraw(iDraw,*iGc,iColor,iRect,iFont,iCount); - break; - case EADllEndAnimText: //Used to end text animate - iFunctions->SetSync(MAnimGeneralFunctions::ESyncNone); - iWindowFunctions->ActivateGc(); - iCount=0; - iMode=0; - iFunctions->CloseFont(iFont); - iFont=NULL; - break; - } - } - -TInt CTransAnim::CommandReplyL(TInt /*aOpcode*/, TAny* /*aParam*/) - { - return(0); - } - -void CTransAnim::FocusChanged(TBool /*aState*/) - {} - -TBool CTransAnim::OfferRawEvent(const TRawEvent& /*aRawEvent*/) - { - return EFalse; - } - -// an anim dll that doesn't remove itself from the event handler list -CTestHandlerAnim::~CTestHandlerAnim() - { - } - -void CTestHandlerAnim::ConstructL(TAny* /*aArgs*/, TBool /*aHasFocus*/) - { - iFunctions->GetRawEvents(ETrue); - } - -void CTestHandlerAnim::Redraw() - { - } - -void CTestHandlerAnim::FocusChanged(TBool /*aState*/) - { - } - -TInt CTestHandlerAnim::CommandReplyL(TInt /*aOpcode*/, TAny* /*aArgs*/) - { - return KErrNone; - } - -void CTestHandlerAnim::Command(TInt /*aOpcode*/, TAny* /*aArgs*/) - { - } - -void CTestHandlerAnim::Animate(TDateTime* /*aDateTime*/) - { - } - -TBool CTestHandlerAnim::OfferRawEvent(const TRawEvent &/*aRawEvent*/) - { - return EFalse; - } - -// CRemovableAnim Test removal of anim during event handling // -CRemovableAnim::~CRemovableAnim() - { - } - -TInt CRemovableAnim::AddExpectedEvent(const TAnimRawEvent* aEvent) - { - if (TotalExpectedEvents() + EventCount() < iLifetime) - { - return (AddEvent(aEvent) ? KErrNone : KErrOverflow); - } - else - { - return KErrNone; - } - } - -TInt CRemovableAnim::CommandReplyL(TInt aOpcode,TAny* aParam) - { - TAnimArgUnion pData; - pData.any=aParam; - switch (aOpcode) - { - case EADllSetEventHandlerLifetime: - iLifetime = *pData.Int; - return iLifetime; - case EADllEventHandlerLifetime: - return iLifetime; - case EADllAddToEventHandlers: - iFunctions->GetRawEvents(ETrue); - return KErrNone; - case EADllRemoveFromEventHandlers: - iFunctions->GetRawEvents(EFalse); - return KErrNone; - case EADllTestPassed: - { - // If any unexpected events are received, then Error() > 0 - // If fewer than the number of expected events are received, then TotalExpectedEvents() > 0 - TBool passed = (Error() == 0) && (TotalExpectedEvents() == 0); - return passed; - } - default: - return CEventTestAnimBase::CommandReplyL(aOpcode, aParam); - } - } - - -TBool CRemovableAnim::OfferRawEvent(const TRawEvent& aRawEvent) - { - TBool eat = CEventTestAnimBase::OfferRawEvent(aRawEvent); - - // Remove anim from event handlers if lifetime has been exceeded - if (EventCount() >= iLifetime) - { - iFunctions->GetRawEvents(EFalse); - } - return eat; - } - -// CMultiPointerAnim for Testing multipointerevents for anims // -CMultiPointerAnim::~CMultiPointerAnim() - { - iFunctions->GetRawEvents(EFalse); - } - -// Important thing here is to call GetRawEvents() which Switches animation raw event handling on -void CMultiPointerAnim::ConstructL(TAny */*aArgs*/, TBool /*aHasFocus*/) - { - iExpectedEvents.SetLengthL(EEventBufferSize); - iFunctions->GetRawEvents(ETrue); - } - -void CMultiPointerAnim::Animate(TDateTime */*aDateTime*/) - { - } - -void CMultiPointerAnim::Command(TInt /*aOpcode*/, TAny */*aArgs*/) - { - } - -TInt CMultiPointerAnim::CommandReplyL(TInt aOpcode, TAny *aArgs) - { - TAnimArgUnion pData; - pData.any=aArgs; - switch (aOpcode) - { - case EADllAddExpectedMultiPtrEvent: - return AddEvent(pData.AnimRawEvent); - case EADllMultiPtrEventError: - return iError; - case EADllMultiPtrEventErrorDesc: - if (iError != KErrNone) - { - // returns the error description which gets displayed in logs if test failed - const RMessagePtr2& message=*iFunctions->Message(); - const TInt error=message.Write(KIpcSlot, iErrorDes); - if (error != KErrNone) - { - return error; - } - } - break; - case EADllMultiPtrEventReset: - iExpectedEvents.Reset(); - iError = 0; - iEventCount = 0; - break; - default:; - } - return(KErrNone); - } - -void CMultiPointerAnim::Redraw() - { - } - -void CMultiPointerAnim::FocusChanged(TBool /*aState*/) - { - } - -TBool CMultiPointerAnim::OfferRawEvent(const TRawEvent &aRawEvent) - { - // Ignore following raw events - TRawEvent::TType aType=aRawEvent.Type(); - if (aType==TRawEvent::EActive || aType==TRawEvent::EInactive || aType==TRawEvent::ERedraw - || aType==TRawEvent::EPointerSwitchOn || aType==TRawEvent::EUpdateModifiers) - { - return EFalse; - } - - // If it has already failed then do not test other events becasue the error value - // and its descriptor will be over written - if (iError) - { - return EFalse;; - } - - TAnimRawEvent expectedEvent; - if (iExpectedEvents.Remove(&expectedEvent)<1) - { - return EFalse; - } - - // Increment event count - iEventCount++; - - // Call compare events function passing in both the events - if (!CompareEvents(expectedEvent.iRawEvent, aRawEvent)) - { - iError = iEventCount; - } - - return expectedEvent.iEat; - } - -TInt CMultiPointerAnim::AddEvent(const TAnimRawEvent* aEvent) - { - return iExpectedEvents.Add(aEvent); - } - -TBool CMultiPointerAnim::CompareEvents(const TRawEvent& aExpectedEvent, const TRawEvent& aActualEvent) - { - // Check pointer type - if (aExpectedEvent.Type() != aActualEvent.Type()) - { - _LIT(KEventType, "Actual Event type = %d Expected Event Type = %d "); - iErrorDes.Format(KEventType, aActualEvent.Type(), aExpectedEvent.Type()); - return EFalse; - } - - // Here for EOutOfRange we cannot query Pos or Pos3D... - if (aExpectedEvent.Type() != TRawEvent::EPointer3DOutOfRange) - { - // Check 3d position - TPoint3D expected3DPos = aExpectedEvent.Pos3D(); - TPoint3D actual3DPos = aActualEvent.Pos3D(); - if (expected3DPos.iX != actual3DPos.iX) - { - _LIT(KXPosition, "Actual X coordinate = %d Expected X coordinate = %d "); - iErrorDes.Format(KXPosition, actual3DPos.iX, expected3DPos.iX); - return EFalse; - } - if (expected3DPos.iY != actual3DPos.iY) - { - _LIT(KYPosition, "Actual Y coordinate = %d Expected Y coordinate = %d "); - iErrorDes.Format(KYPosition, actual3DPos.iY, expected3DPos.iY); - return EFalse; - } - if (expected3DPos.iZ != actual3DPos.iZ) - { - _LIT(KZPosition, "Actual Z coordinate = %d Expected Z coordinate = %d "); - iErrorDes.Format(KZPosition, actual3DPos.iZ, expected3DPos.iZ); - return EFalse; - } - } - - // Check pointer number - if (aExpectedEvent.PointerNumber() != aActualEvent.PointerNumber()) - { - _LIT(KPointerNumber, "Actual Pointer number = %d Expected Pointer number = %d "); - iErrorDes.Copy(KPointerNumber); - iErrorDes.Format(KPointerNumber, aActualEvent.PointerNumber(), aExpectedEvent.PointerNumber()); - return EFalse; - } - return ETrue; - } - -// CCoverageAnim test drawing/redrawing // -CCoverageAnim::~CCoverageAnim() - { - if(iFont && iFunctions) - iFunctions->CloseFont(iFont); - } - -/** - Initializes members. - */ -void CCoverageAnim::ConstructL(TAny *aParam, TBool ) - { - iRect=*static_cast(aParam); - iWindowFunctions->SetRect(iRect); - iWindowFunctions->Invalidate(iRect); - - iFunctions->SetSync(MAnimGeneralFunctions::ESyncDay); - if (iFunctions->Sync() != MAnimGeneralFunctions::ESyncDay) - User::Leave(KErrGeneral); - - iFunctions->SetSync(MAnimGeneralFunctions::ESyncMinute); - if (iFunctions->Sync() != MAnimGeneralFunctions::ESyncMinute) - User::Leave(KErrGeneral); - - iFunctions->SetSync(MAnimGeneralFunctions::ESyncSecond); - if (iFunctions->Sync() != MAnimGeneralFunctions::ESyncSecond) - User::Leave(KErrGeneral); - - iFunctions->SetSync(MAnimGeneralFunctions::ESyncFlash); - if (iFunctions->Sync() != MAnimGeneralFunctions::ESyncFlash) - User::Leave(KErrGeneral); - - iFunctions->SetSync(MAnimGeneralFunctions::ESyncNone); - if (iFunctions->Sync() != MAnimGeneralFunctions::ESyncNone) - User::Leave(KErrGeneral); - - iFunctions->SetInterval(1); - iFunctions->SetInterval(0); - iFunctions->SetNextInterval(0); - - User::LeaveIfNull(iFunctions->ExtendedInterface(MAnimGeneralFunctions::ENumberOfExtendedInterfaces)); - User::LeaveIfNull(iFunctions->ExtendedInterface(MAnimGeneralFunctions::EWindowExtensionInterface)); - User::LeaveIfNull(iFunctions->ExtendedInterface(MAnimGeneralFunctions::EEventExtentionInterface)); - User::LeaveIfError(iFunctions->ExtendedInterface(MAnimGeneralFunctions::EInterfaceCount) != NULL); - - #if !defined(SYMBIAN_GRAPHICS_GCE) - // Deprecated in NGA but needs to be tested in NONNGA - User::LeaveIfNull((TAny*)iFunctions->ScreenDevice()); - #endif - - iFunctions->Client(); - } - -/** - Copied from CAutoAnimScrBack. - */ -void CCoverageAnim::Animate(TDateTime *) - { - iWindowFunctions->ActivateGc(); - Draw(); - } - -/** - All methods of the graphic-context are executed one by one. - */ -void CCoverageAnim::Draw() - { - iGc->SetClippingRect(iRect); - iGc->Clear(); - iGc->Clear(iRect); - - iGc->SetDrawMode(CGraphicsContext::EDrawModeAND); - iGc->SetBrushStyle(CGraphicsContext::ENullBrush); - iGc->SetBrushColor(TRgb::Gray256(85)); - iGc->SetBrushOrigin(TPoint(0,0)); - iGc->SetPenColor(TRgb::Gray256(170)); - - //primitive method calls - iGc->SetFaded(ETrue); - iGc->SetFadingParameters(1, 1); - - iGc->SetPenStyle(CGraphicsContext::ESolidPen); - iGc->SetStrikethroughStyle(EStrikethroughOff); - iGc->SetUnderlineStyle(EUnderlineOff); - iGc->SetWordJustification(2, 1); - - if(iFont) - iGc->UseFont(iFont); - - iGc->DrawArc(iRect, - TPoint(iRect.Center().iX, iRect.iTl.iY), - TPoint(iRect.iBr.iX, iRect.Center().iY)); - iGc->DrawLine(iRect.iTl,iRect.Center()); - iGc->DrawLineTo(TPoint(iRect.iBr.iX, iRect.iTl.iY)); - - iGc->DrawLineBy(TPoint(iRect.iTl.iX, iRect.iBr.iY)); - iGc->MoveBy(iRect.iTl + TPoint(1,1)); - iGc->MoveTo(iRect.iTl + TPoint(0,0)); - iGc->SetPenSize(TSize(10,10)); - iGc->Plot(iRect.iTl + TPoint(2,2)); - iGc->SetPenSize(TSize(1,1)); - - CArrayFixFlat* polyPoints = new(ELeave) CArrayFixFlat(3); //CArrayFixFlat - CleanupStack::PushL(polyPoints); - polyPoints->AppendL(iRect.iTl); - polyPoints->AppendL(iRect.Center()); - polyPoints->AppendL(TPoint(iRect.iBr.iX, iRect.iTl.iY)); - - iGc->DrawPolyLine(polyPoints); - iGc->DrawPolyLine(&polyPoints->At(0), 3); - iGc->DrawPolygon(polyPoints, CGraphicsContext::EWinding); - iGc->DrawPolygon(&polyPoints->At(0), 3, CGraphicsContext::EAlternate); - - iGc->DrawPie(iRect, TPoint(iRect.Center().iX, iRect.iTl.iY), TPoint(iRect.iBr.iX, iRect.Center().iY)); - iGc->DrawEllipse(iRect); - iGc->DrawRect(iRect); - iGc->DrawRoundRect(iRect, TSize(iRect.Width()/8, iRect.Height()/8)); - - CleanupStack::PopAndDestroy(polyPoints); - - iGc->CopyRect(TPoint(10, 10), iRect); - - CFbsBitmap* bitmap = new(ELeave) CFbsBitmap(); - CleanupStack::PushL(bitmap); - User::LeaveIfError(bitmap->Create(TSize(16,16),EGray4)); - - iGc->UseBrushPattern(bitmap); - iGc->DrawBitmap(iRect.iTl, bitmap); - iGc->DrawBitmap(iRect, bitmap); - iGc->DrawBitmap(iRect, bitmap, TRect(0, 0, 16, 16)); - iGc->DrawBitmapMasked(iRect, bitmap, TRect(0, 0, 16, 16), bitmap, ETrue); - - iGc->BitBlt(TPoint(0, 0), bitmap); - iGc->BitBlt(TPoint(0, 0), bitmap, iRect); - iGc->BitBltMasked(TPoint(0, 0), bitmap, iRect, bitmap, ETrue); - iGc->AlphaBlendBitmaps(TPoint(0, 0), bitmap, iRect, bitmap, TPoint(0,0)); - - CleanupStack::PopAndDestroy(bitmap); - - iGc->SetCharJustification(1,1); - iGc->SetClippingRect(iRect); - if(iFont) - { - _LIT(KHelloWorld,"Hello World"); - iGc->DrawText(*&KHelloWorld, iRect.iTl); - iGc->DrawText(*&KHelloWorld, iRect, 0, CGraphicsContext::ELeft, 0); - iGc->DrawTextVertical(*&KHelloWorld, iRect.iBr, ETrue); - iGc->DrawTextVertical(*&KHelloWorld, iRect, 0, ETrue, CGraphicsContext::ELeft, 0); - } - - TRgb rgbs[2]; - iGc->MapColors(iRect, rgbs, 1, ETrue); - iGc->DiscardBrushPattern(); - - if(iFont) - iGc->DiscardFont(); - - iFunctions->CloseFont(0); - - TDateTime dt = iFunctions->SystemTime(); - } - -/** - Copied from CAutoAnim3. - */ -void CCoverageAnim::Redraw() - { - Draw(); - } - -/** - Copied from CAutoAnim3. - */ -void CCoverageAnim::Command(TInt ,TAny*) - { - } - -/** - Copied from CAutoAnim3. - */ -TInt CCoverageAnim::CommandReplyL(TInt aOpcode , TAny* aParam) - { - TAnimArgUnion pData; - pData.any=aParam; - switch(aOpcode) - { - case EADllDrawNow: - iFunctions->SetSync(MAnimGeneralFunctions::ESyncFlash); - break; - case EADllSetFont: - if(iFont) - { - iFunctions->CloseFont(iFont); - iFont = NULL; - } - iFont = iFunctions->DuplicateFontL(*pData.Int); - break; - } - return(KErrNone); - } - -/** - Copied from CAutoAnim3. - */ -void CCoverageAnim::FocusChanged(TBool ) - {} - -/** - Copied from CAutoAnim3. - */ -TBool CCoverageAnim::OfferRawEvent(const TRawEvent &/*aRawEvent*/) - { - return EFalse; - } - - -// DLL code // - -CAnim *CTestAnimDll::CreateInstanceL(TInt aType) - { - CAnim *anim=NULL; - switch(aType) - { - case EAnimTypeTest1: - anim=new(ELeave) CPanicAnim(); - break; - case EAnimTypeTest2: - anim=new(ELeave) CPanicAnim2(); - break; - case EAnimTypeTest3: - anim=new(ELeave) CAutoAnim3(); - break; - case EAnimTypeScrBackTest: - anim=new(ELeave) CAutoAnimScrBack(); - break; - case EAnimTypeSprite: - anim=new(ELeave) CTestSpriteAnim(); - break; - case EAnimTypeFreeTimer: - anim=new(ELeave) CTestFreeTimerAnim(); - break; - case EAnimTypeEventTest: - anim=new(ELeave) CEventTestAnim(); - break; - case EAnimTypeNotificationTest: - anim=new(ELeave) CNotificationTestAnim(); - break; - case EAnimTypeTimer: - anim=new(ELeave) CTimerTestAnim(); - break; - case EAnimTypeWindowFunctions: - anim=new(ELeave) CWinFunctionTestAnim(); - break; - case EAnimTypeTrans: - anim=new(ELeave) CTransAnim(); - break; - case EAnimTypeEventHandler: - anim = new (ELeave) CTestHandlerAnim(); - break; - case EAnimTypeRemovableAnim: - anim=new(ELeave) CRemovableAnim(); - break; - case EAnimTypeEventPostingTest: - anim=new(ELeave) CEventPostingAnim(); - break; - case EAnimTypeCoverage: - anim=new(ELeave) CCoverageAnim(); - break; - case EAnimTypeMultiPointer: - anim=new(ELeave) CMultiPointerAnim(); - break; - } - return(anim); - } - -// Dummy E32Dll needed by E32 to build // - -void CAutoAnim3::DrawTestScreenL(const TDrawTestScreen* aParams) -//Moved here as the include messes up the debugging of the rest of the file. - { - CFbsBitmap *aBitmap=iFunctions->DuplicateBitmapL(aParams->bitmap); - CleanupStack::PushL(aBitmap); - CFbsBitmap *aMaskBitmap=iFunctions->DuplicateBitmapL(aParams->maskBitmap); - CleanupStack::PushL(aMaskBitmap); - CFbsFont *aFont=iFont=iFunctions->DuplicateFontL(aParams->font); - TSize size(iWindowFunctions->WindowSize()); - iWindowFunctions->ActivateGc(); - CBitmapContext *gc=iGc; - TBool aExtraDrawBitMap=ETrue; -// -#include "DLLDRAW.H" -// - iFunctions->CloseFont(iFont); - iFont=NULL; - CleanupStack::PopAndDestroy(2); - } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/AUTODLL.H --- a/windowing/windowserver/tauto/AUTODLL.H Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,352 +0,0 @@ -// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Header defs for ANIMDLL -// -// - -#ifndef __AUTODLL_H__ -#define __AUTODLL_H__ - - -#if !defined(__W32ADLL_H__) -#include -#endif - -#ifdef SYMBIAN_GRAPHICS_GCE -_LIT(KAnimDLLName,"autodl_nga.dll"); -#else -_LIT(KAnimDLLName,"autodl_nonnga.dll"); -#endif - -const TInt KIpcSlot=1; - -struct CTAParams - { - TPoint pos; - TInt interval; - TInt bit1; - TInt bit2; - }; - -struct TAnimRawEvent - { - //inline TAnimRawEvent(TRawEvent& aRawEvent,TBool aEat) :iRawEvent(aRawEvent), iEat(aEat) {} - TRawEvent iRawEvent; - TBool iEat; - }; - -enum AnimDllPanicOpcodes - { - EADllPanicCallPanic, - EADllPanicSetInterval, - EADllPanicSetNextInterval, - EADllPanicBadFont, - EADllPanicBadBitmap, - EADllPanicLeave, - EADllPanicDestroy, - EADllPanicOpcode, - EADllPanicDoubleActivateGC, - EADllPanicDrawRectWithNoGc, - EADllPanicDrawTextWithNoFont, - EADllPanicLeaveInAnimate, - EADllPanicLeaveInRedraw, - EADllPanicSetVisWithGcActive, - EADllReadRemoteDescriptor, - EADllSyncTests, - EADllTimeChangedTest, - EADllTestWindowSize, - EADllTestSetVisible, - EADllPanicSetVisWithGcActiveReply, - EADllBlankOpCode, - EADllPanicLeaveInActiveCallback, - EADllPanicSetClippingRectWithNoGc, - EADllPanicSetClippingRegionWithNoGc, - EADllPanicCancelClippingRegionWithNoGc, - EADllPanicCancelClippingRectWithNoGc, - EADllPanicSetDrawModeWithNoGc, - EADllPanicUseFontWithNoGc, - EADllPanicDiscardFontWithNoGc, - EADllPanicSetUnderlineStyleWithNoGc, - EADllPanicSetStrikeThoughStyleWithNoGc, - EADllPanicSetWordJustificationWithNoGc, - EADllPanicSetCharJustificationWithNoGc, - EADllPanicSetPenColorWithNoGc, - EADllPanicSetPenStyleWithNoGc, - EADllPanicSetPenSizeWithNoGc, - EADllPanicSetBrushColorWithNoGc, - EADllPanicSetBrushStyleWithNoGc, - EADllPanicSetBrushOriginWithNoGc, - EADllPanicUseBrushPatterWithNoGc, - EADllPanicDiscardBrushPatternWithNoGc, - EADllPanicSetFadedWithNoGc, - EADllPanicSetFadingParametersWithNoGc, - EADllPanicDrawArcWithNoGc, - EADllPanicDrawPieWithNoGc, - EADllPanicDrawLineWithNoGc, - EADllPanicDrawLineToWithNoGc, - EADllPanicDrawLineByWithNoGc, - EADllPanicDrawEllipseWithNoGc, - EADllPanicDrawRoundedRecWithNoGc, - EADllPanicClearWithRectWithNoGc, - EADllPanicClearWithNoGc, - EADllPanicBitBltWithNoGc, - EADllPanicBitBltWithRectWithNoGc, - EADllPanicBitBltMaskedWithNoGc, - EADllPanicDrawBitmapPointWithNoGc, - EADllPanicDrawBitmapWithNoGc, - EADllPanicDrawBitmapRectWithNoGc, - EADllPanicDrawBitmapMaskedFbsBitmapWithNoGc, - EADllPanicDrawBitmapMaskedWsBitmapWithNoGc, - EADllPanicDrawPolyLinePointsWithNoGc, - EADllPanicDrawPolyLineArrayWithNoGc, - EADllPanicDrawPolygonPointsWithNoGc, - EADllPanicDrawPolygonArrayWithNoGc, - EADllPanicMoveToWithNoGc, - EADllPanicMoveByWithNoGc, - EADllPanicPlotWithNoGc, - EADllPanicSetOriginWithNoGc, - EADllPanicCopyRectWithNoGc, - EADllPanicResetWithNoGc, - EADllPanicAlphaBlendingBitmapsFbsBitmapWithNoGc, - EADllPanicMapColorsWithNoGc, - EADllPanicDrawTextWithRectWithNoFont, - EADllPanicDrawTextVerticalWithNoFont, - EADllPanicDrawTextVerticalWithRectWithNoFont, - EADllPanicDevice, - EADllPanicInvalidFocusScreenTooBig, - EADllPanicInvalidFocusScreenNegative, - }; - -enum AnimDllTestOpcodes - { - }; - -enum AnimDllOpcodes3 - { - EADllSetRect, - EADllStartAnimate, - EADllCancelAnimate, - EADllSetVisible, - EADllSetShadowDrawMode, - EADllShadowAnimTest, - EADllDrawTestScreen, - EADllParameterRectValueTest, - EADllDoSetSync, - EADllSetInterval, - EADllSetMode - }; - -enum AnimDllOpcodesScrBack - { - EADllDrawOtherRect, - EADllIsHidden, - }; - -enum AnimDllOpcodesSprite - { - EADllActivate, - EADllDeactivate, - EADllCheckMember, - EADllSizeChanged, - EADllSetPos, - EADllDraw1, - EADllDraw2, - EADllDraw3, - EADllIncDraw, - }; - -enum AnimDllOpcodesFreeTimer - { - EStartAnimation, - EStopAnimation, - ESetFrameTime - }; - -enum AnimDllOpcodesTimer - { - EADllNoTimer, - EADllTimerStarted, - EADllResetCount, - EADllCurrentCount, - EADllFailed, - }; - -enum AnimDllWinFunctions - { - EADllScreen, - EADllFocusScreen, - EADllWindowGroups, - EADllWindowGroupInfo, - EADllWindowGroupName, - EADllSetOrdinalPosition, - EADllSetFocusScreen, - }; - -enum AnimDllOpcodesNotificationTest - { - EADllQueryDSA, - EADllQueryHeartbeatState, - EADllIsAnimating, - }; - -enum AnimDllTransTest - { - EADllDrawNow, - EADllNextFrame, - EADllStartAnimText, - EADllEndAnimText, - EADllSetSync, - EADllSetFont, - }; - -enum TAnimTypes - { - EAnimTypeTest1, - EAnimTypeTest2, - EAnimTypeTest3, - EAnimTypeScrBackTest, - EAnimTypeSprite, - EAnimTypeFreeTimer, - EAnimTypeEventTest, - EAnimTypeEventPostingTest, - EAnimTypeTimer, - EAnimTypeWindowFunctions, - EAnimTypeNotificationTest, - EAnimTypeTrans, - EAnimTypeEventHandler, - EAnimTypeRemovableAnim, - /** CWsAnimGc functional coverage */ - EAnimTypeCoverage, - EAnimTypeMultiPointer, - }; - -enum {ERemoteBufSize=0x10}; -enum FlashState{EStateNone,EStateFlash,EStateSecond,EStateMinute}; - -enum AnimDllOpcodesEventTestAnimBase - { - EADllAddExpectedEvent, - EADllNumberOfEventsReceived, - EADllErrorCode, - EADllReset, - EADllEventAnimBase_EndBaseEnum, - }; - -enum AnimDllOpcodesEventTestAnim - { - EADllNoEventsAndReset=EADllEventAnimBase_EndBaseEnum, - EADllLoadDeviceDriver, - EADllUnloadDeviceDriver, - EADllSendEvent, - EADllAfterEvent, - }; - -enum AnimDllOpcodesRemovableAnim - { - EADllSetEventHandlerLifetime=EADllEventAnimBase_EndBaseEnum, - EADllEventHandlerLifetime, - EADllAddToEventHandlers, - EADllRemoveFromEventHandlers, - EADllTestPassed, - }; - -enum AnimDllOpcodeMultiPointerAnim - { - EADllAddExpectedMultiPtrEvent, - EADllMultiPtrEventError, - EADllMultiPtrEventErrorDesc, - EADllMultiPtrEventReset, - }; - -struct TRemoteBufAddress - { - TAny *descPtr; - }; -struct TSyncTests - { - TRequestStatus *status; - MAnimGeneralFunctions::TAnimSync syncMode; - }; -struct TShadowDrawTest - { - TRequestStatus *status; - }; -struct TTimeChangeTest - { - TRequestStatus *status; - TRequestStatus *status2; - }; -struct TDrawTestScreen - { - TInt bitmap; - TInt maskBitmap; - TInt font; - }; -struct TSpriteMemberInfo - { - inline TSpriteMemberInfo() {} - inline TSpriteMemberInfo(TPoint aSpritePos,TInt aMemberNo,const TSpriteMember& aMember); - TPoint iSpritePos; - TInt iMember; - TInt iBitmapHandle; - TInt iMaskBitmapHandle; - TBool iInvertMask; - CGraphicsContext::TDrawMode iDrawMode; - TPoint iOffset; - TTimeIntervalMicroSeconds32 iInterval; - }; -inline TSpriteMemberInfo::TSpriteMemberInfo(TPoint aSpritePos,TInt aMemberNo,const TSpriteMember& aMember) - :iSpritePos(aSpritePos), iMember(aMemberNo), iBitmapHandle(aMember.iBitmap->Handle()), - iMaskBitmapHandle(aMember.iMaskBitmap ? aMember.iMaskBitmap->Handle():0), iInvertMask(aMember.iInvertMask), - iDrawMode(aMember.iDrawMode), iOffset(aMember.iOffset), iInterval(aMember.iInterval) - {} -struct TWindowGroupInfoParms - { - TInt iScreen; - TInt iOrdinalPosition; - }; -struct TSetOrdinalParms - { - TInt iIdentifier; - TInt iOrdinalPosition; - TInt iOrdinalPriority; - }; -struct TFrameData - { - TInt sync; - TInt font; - TInt bitmap; - TRgb color; - TInt draw; - TInt text; - TRect rect; - }; - -class RTestAnim : public RAnim - { -public: - RTestAnim(); - RTestAnim(RAnimDll &aDll); - inline TInt Construct(const RWindowBase &aWin,TInt aType,const TDesC8 &aParams) {return(RAnim::Construct(aWin,aType,aParams));} - inline TInt Construct(const RWindowBase &aDevice,const TRect &aRect) {return(RAnim::Construct(aDevice, EAnimTypeScrBackTest,TPtrC8((TUint8 *)&aRect,sizeof(aRect))));} - inline TInt Construct(const RWsSprite &aSprite,TInt aType,const TDesC8 &aParams) {return(RAnim::Construct(aSprite,aType,aParams));} - inline TInt CommandReply(TInt aOpcode,const TDesC8& aArgs,const TIpcArgs& aIpcArgs) {return(RAnim::CommandReply(aOpcode,aArgs,aIpcArgs));} - inline TInt CommandReply(TInt aOpcode,const TPtrC8 &aArgs) {return(RAnim::CommandReply(aOpcode,aArgs));} - inline TInt CommandReply(TInt aOpcode) {return(RAnim::CommandReply(aOpcode));} - inline void Command(TInt aOpcode,const TPtrC8 &aArgs) {RAnim::Command(aOpcode,aArgs);} - inline void Command(TInt aOpcode) {RAnim::Command(aOpcode);} - inline void ChangeRect(const TRect &aRect) {RAnim::Command(EADllDrawOtherRect,TPtrC8((TUint8 *)&aRect,sizeof(aRect)));} - }; - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/AUTOTEST.TXT --- a/windowing/windowserver/tauto/AUTOTEST.TXT Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,316 +0,0 @@ -Fully Tested -============ -class RWindow : public RWindowBase - { - IMPORT_C void Scroll(const TPoint &aOffset); - IMPORT_C void Scroll(const TPoint &aOffset, const TRect &aRect); - IMPORT_C void Scroll(const TRect &aClipRect, const TPoint &aOffset); - IMPORT_C void Scroll(const TRect &aClipRect, const TPoint &aOffset, const TRect &aRect); - IMPORT_C TInt OrdinalPosition() const; - IMPORT_C void SetOrdinalPosition(TInt aPos); - IMPORT_C void SetOrdinalPosition(TInt aPos,TOrdinalPriority aOrdinalPriority); - } - -class RWs : public RSessionBase - { - } - -class RBitmap : public RDrawBase - { - } - -class RWindowBase : public RDrawBase - { - } - -class RRootWindow : public RWindowBase - { - } - -class RFont : public RFontBase - { - } - -class RBrush : public RBrushBase - { - } - -class RPalette : public RPaletteBase - { - } - -class RGc : public RGdiBase - { - IMPORT_C void GetPixels(const TPoint &aPoint,TInt aNumOfPixels,TPtr8 &aScanLine)const; - IMPORT_C void DrawLine(const TPoint &aPoint1,const TPoint &aPoint2); - IMPORT_C void ClearDI(TRgb aColour); - IMPORT_C void ClearDI(TRgb aColour,const TRect &aRect); - IMPORT_C void ClearTrapezium(const TRect &aRect,TInt aSkew,TBool aHorizontal); - IMPORT_C void DrawDottedLine(const TPoint &aPoint1,const TPoint &aPoint2,TUint aDashPattern,TInt aDashedLength); - IMPORT_C void DrawTrapezium(const TRect &aRect,TInt aSkew,TBool aHorizontal); - IMPORT_C void FillTrapezium(const TRect &aRect,TInt aSkew,TBool aHorizontal); - IMPORT_C void GdiBltMasked(const TPoint &aDestination,const RDrawBase &aDrawPtr,const TRect &aSource,const RDrawBase &aMask,TRgb aCutoff,TBool aLowMasked); - IMPORT_C void DrawParallelogram(const TRect &aRect,TInt aSkew,TBool aHorizontal); - IMPORT_C void ClearParallelogram(const TRect &aRect,TInt aSkew,TBool aHorizontal); - IMPORT_C void FillParallelogram(const TRect &aRect,TInt aSkew,TBool aHorizontal); - IMPORT_C void PaintParallelogram(const TRect &aRect,TInt aSkew,TBool aHorizontal); - IMPORT_C void PaintTrapezium(const TRect &aRect,TInt aSkew,TBool aHorizontal); - IMPORT_C void ResetDotParam(); - } - -Partially tested -================ -class RWindow : public RWindowBase - { - } - -class RWs : public RSessionBase - { - } - -class RBitmap : public RDrawBase - { - } - -class RWindowBase : public RDrawBase - { - } - -class RRootWindow : public RWindowBase - { - } - -class RFont : public RFontBase - { - } - -class RBrush : public RBrushBase - { - } - -class RPalette : public RPaletteBase - { - } - -class RGc : public RGdiBase - { - } - - -Not tested -========== -class RWs : public RSessionBase - { - IMPORT_C RWs(); - IMPORT_C TInt Connect(TUint32 aHandle); - IMPORT_C void Disconnect(); - IMPORT_C TVersion Version(); - IMPORT_C TInt SetHotKey(THotKeyType aType, TUint aKeycode, TUint aModifier, TUint aModifierMask); - IMPORT_C TInt CaptureKey(TUint keyCode,TUint mod_mask,TUint modifiers); - IMPORT_C void CancelHotKey(TInt aHotKey); - IMPORT_C void CancelCaptureKey(TInt aCaptureKey); - IMPORT_C void DisplayInfo(TUint aMode, TDisplayInfo *aInfo); - IMPORT_C void ComputeMode(TComputeMode mode); - IMPORT_C void Info(TInt aClientHandle,TxInfo &aInfo); - IMPORT_C void ReadEvent(TPckgBuf &aEvent,TInt *stat,TUint blocks=0); - IMPORT_C void ReadEventUpdate(TUint blocks); - IMPORT_C void ReadEventCancel(); - IMPORT_C TInt BufferSize(TInt aBufSize); - IMPORT_C void Flush(); - IMPORT_C TBool SetAutoFlush(TBool aState); - IMPORT_C TInt HeapCount() const; - IMPORT_C void SetTextCursor(RWindow &aWin, const TPoint &aPos, const TTextCursor &aCursor); - IMPORT_C void CancelTextCursor(); - IMPORT_C void MarkStart(); - IMPORT_C void CheckNum(TUint aCount); - IMPORT_C void MarkEnd(TUint aCount); - IMPORT_C TInt ResourceCount(); - inline RBuffer *Buffer() const; - }; - -class RBitmap : public RDrawBase - { - IMPORT_C RBitmap(); - IMPORT_C RBitmap(RWs &aWs); - IMPORT_C void Close(); - IMPORT_C void Destroy(); -// IMPORT_C void Construct(TSize &size,TInt colourBits); - IMPORT_C TInt Construct(TSize &size); - IMPORT_C TInt Load(const TDesC &aFileName,TReadWrite access=EReadOnly); - IMPORT_C void Attributes(TAttributes *attrib); - IMPORT_C TUint Handle() const; - IMPORT_C TGdiAttributes Attributes()const; - IMPORT_C TSize Size()const; - }; - -class RWindowBase : public RDrawBase - { - IMPORT_C RWindowBase(); - IMPORT_C RWindowBase(RWs &aWs); - IMPORT_C void Close(); - IMPORT_C void Destroy(); - IMPORT_C TAttributes Attributes(TInt handle); - IMPORT_C TUint32 Parent() const; - IMPORT_C TUint32 PrevSibling() const; - IMPORT_C TUint32 NextSibling() const; - IMPORT_C TUint32 Child() const; - IMPORT_C TPoint InquireOffset(const RWindowBase &aWindow) const; - IMPORT_C TGdiAttributes Attributes() const; - IMPORT_C TUint Handle() const; - IMPORT_C TSize Size() const; - IMPORT_C TPoint Position() const; - }; - -class RWindow : public RWindowBase - { - IMPORT_C RWindow(); - IMPORT_C RWindow(RWs &aWs); - IMPORT_C TInt Construct(const RWindowBase &parent,TUint32 handle); - IMPORT_C void Activate(); - IMPORT_C TAttributes Attributes(); - IMPORT_C void BeginRedraw(); - IMPORT_C void BeginRedraw(const TRect &rect); - IMPORT_C void EndRedraw(); - IMPORT_C void Invalidate(); - IMPORT_C void Invalidate(const TRect &rect); - IMPORT_C void Validate(); - IMPORT_C void Validate(const TRect &rect); - IMPORT_C void SetPosition(const TPoint &point); - IMPORT_C TInt SetSize(const TSize &size); - IMPORT_C TInt SetExtent(const TPoint &point,const TSize &size); - IMPORT_C TInt SetExtent(TInt tlx,TInt tly,TInt width, TInt height); - IMPORT_C void SetAttributes(TUint flags,const TAttributes &windata); - IMPORT_C void SetTextCursor(const TTextCursor cursor); - IMPORT_C void CancelTextCursor(); - IMPORT_C void PointerFilter(TUint32 aFilter); - IMPORT_C void SetPointerGrab(TBool aState); - IMPORT_C void SetPointerCapture(TBool aState); - IMPORT_C void SetBackgroundColour(TRgb aColour); - IMPORT_C void SetVisible(TBool aState); - IMPORT_C TInt SetCurrentRegion(const TRegion &aRegion); - IMPORT_C void CancelCurrentRegion(); - }; - -class RRootWindow : public RWindowBase - { - IMPORT_C RRootWindow(); - IMPORT_C RRootWindow(RWs &aWs); - IMPORT_C TInt Construct(TUint32 clientHandle); - }; - -class RFont : public RFontBase - { - IMPORT_C RFont(); - IMPORT_C RFont(RWs &aWs); - IMPORT_C void Close(); - IMPORT_C void Destroy(); - IMPORT_C TInt Construct(const TFont &aFont); - IMPORT_C TUint Handle()const; - IMPORT_C TInt Height()const; - IMPORT_C TInt Ascent()const; - IMPORT_C TInt Descent()const; - IMPORT_C TInt AverageWidth()const; - IMPORT_C TInt MaximumWidth()const; - IMPORT_C TBool Bold()const; - IMPORT_C TBool Italic()const; - IMPORT_C TBool Underline()const; - IMPORT_C TBool CrossOut()const; - IMPORT_C void WidthTable(TUint aStartChar,TUint aFinishChar,TPtr8 &)const; - IMPORT_C TInt TextWidth(const TDesC &aBuf)const; - IMPORT_C TInt TextCount(const TDesC &aBuf,TInt aPixelCount)const; - IMPORT_C TInt TextCount(const TDesC &aBuf,TInt aPixelCount,TInt &aWidth)const; - }; - -class RBrush : public RBrushBase - { -public: - IMPORT_C RBrush(); - IMPORT_C RBrush(RWs &aWs); - IMPORT_C void Close(); - IMPORT_C void Destroy(); - IMPORT_C TInt Construct(const TDesC &aFileName,RFs &aFileSys); - IMPORT_C TUint Handle()const; - IMPORT_C TSize Size()const; - IMPORT_C TRgb Pixel(const TPoint &aPoint)const; - IMPORT_C void GetPixels(const TPoint &aPoint,TInt aPelLength,TInt aMode,TPtr8 &aBuffer)const; - IMPORT_C void SetThreshold(TUint aThreshold); -private: - TInt32 iHandle; - RBuffer *iBuffer; - }; - -class RPalette : public RPaletteBase - { - IMPORT_C RPalette(); - IMPORT_C RPalette(RWs &aWs); - IMPORT_C void Close(); - IMPORT_C void Destroy(); - IMPORT_C void Clear(); - IMPORT_C void SetEntry(TInt aPaletteIndex,TRgb aPaletteEntry); - IMPORT_C void SetBlock(TInt aStartIndex,TInt aNumberOfEntries,TPtr8 &aBufferOfEntries); - IMPORT_C TRgb GetEntry(TInt aPaletteIndex) const; - IMPORT_C void GetBlock(TInt aStartIndex,TInt aNumberOfEntries,TPtr8 &aBuffer) const; - IMPORT_C TInt Entries() const; - IMPORT_C TUint Handle()const; - }; - -class RGc : public RGdiBase - { - IMPORT_C RGc(); - IMPORT_C RGc(RWs &aWs); - IMPORT_C void Close(); - IMPORT_C void Destroy(); - IMPORT_C TInt Construct(); - IMPORT_C void Activate(const RDrawBase &aDrawable); - IMPORT_C void Deactivate(); - IMPORT_C void FillRect(const TRect &aRect); - IMPORT_C void PrintText(const TPoint &aPosition,const TDesC &aString); - IMPORT_C void PrintText(const TDesC &aString); - IMPORT_C void SetPenGrey4(TUint aGrey4); - IMPORT_C void SetPenGrey16(TUint aGrey16); - IMPORT_C void SetPenGrey256(TUint aGrey256); - IMPORT_C void Clear(); - IMPORT_C void CopyRect(const TPoint &anOffset,const TRect &aRect); - IMPORT_C void DrawEllipse(const TRect &aRect); - IMPORT_C void DrawRect(const TRect &aRect); - IMPORT_C void ClearRect(const TRect &aRect); - IMPORT_C void FillEllipse(const TRect &aRect); - IMPORT_C void PaintEllipse(const TRect &aRect); - IMPORT_C void ClearEllipse(const TRect &aRect); - IMPORT_C void PaintRect(const TRect &aRect); - IMPORT_C void GdiBlt(const RDrawBase &aDevice); - IMPORT_C void GdiBlt(const TPoint &aDestination,const RDrawBase &aDevice); - IMPORT_C void GdiBlt(const TPoint &aDestination,const RDrawBase &aDevice,const TRect &aSource); - IMPORT_C TInt DisplayMode()const; - IMPORT_C TGdiDrawMode DrawMode()const; -// IMPORT_C TUint DisplayModesAvailable()const; - IMPORT_C TRgb Pixel(const TPoint &aPixel)const; - IMPORT_C TSize Size()const; - IMPORT_C RBrushBase *PatternBrush()const; - IMPORT_C TRgb PenColour()const; - IMPORT_C TRgb BrushColour()const; - IMPORT_C TTextBackGround TextBackGround()const; - IMPORT_C void Plot(const TPoint &aPoint); - IMPORT_C void SetBrushGrey4(TUint aGrey4); - IMPORT_C void SetBrushGrey16(TUint aGrey16); - IMPORT_C void SetBrushGrey256(TUint aGrey256); - IMPORT_C void SetPenColour(const TRgb &aColour); - IMPORT_C void SetBrushColour(const TRgb &aColour); - IMPORT_C TInt SetDisplayMode(TUint aDisplayMode); - IMPORT_C void SetDrawMode(TGdiDrawMode aDrawingMode); - IMPORT_C void SetLineWidth(TInt aWidth); - IMPORT_C void SetPatternBrushOrigin(const TPoint &aOrigin); - IMPORT_C void SetTextBackGround(TTextBackGround aBackGroundSetting); - IMPORT_C RFont Font()const; - IMPORT_C void UseFont(const RFontBase &aFont); - IMPORT_C void UsePalette(const RPaletteBase &aPalette); - IMPORT_C void UsePatternBrush(const RBrushBase &aBrush); - IMPORT_C void DiscardFont(); - IMPORT_C void DiscardPalette(); - IMPORT_C void DiscardPatternBrush(); - IMPORT_C TUint Handle() const; - IMPORT_C TInt LoadBitmap(const TDesC &aFileName, RFs &aFileSys); - IMPORT_C TInt LoadBitmapDI(const TDesC &aFileName,RFs &aFileSys); - IMPORT_C TGdiAttributes Attributes()const; - IMPORT_C void RefreshPalette(); - } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/BLUEHASH.PBM Binary file windowing/windowserver/tauto/BLUEHASH.PBM has changed diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/DLLDRAW.H --- a/windowing/windowserver/tauto/DLLDRAW.H Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,144 +0,0 @@ -// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Lots of different Drawing Commands -// -// - - gc->SetBrushColor(TRgb::Gray4(2)); - gc->Clear(); - gc->SetBrushColor(TRgb::Gray4(0)); - gc->Clear(TRect(2,2,20,5)); - gc->DrawRect(TRect(size)); - gc->SetBrushOrigin(TPoint(1,2)); - gc->SetBrushStyle(CGraphicsContext::EForwardDiagonalHatchBrush); - gc->DrawRect(TRect(30,2,60,8)); - gc->SetBrushOrigin(TPoint(0,0)); - gc->UseBrushPattern(aBitmap); - gc->SetBrushStyle(CGraphicsContext::EPatternedBrush); - gc->DrawRect(TRect(60,2,90,8)); - gc->SetBrushStyle(CGraphicsContext::ENullBrush); - gc->DiscardBrushPattern(); -// - gc->SetPenColor(TRgb::Gray4(1)); - gc->DrawLine(TPoint(10,12),TPoint(22,20)); - gc->SetPenSize(TSize(4,2)); - gc->DrawLine(TPoint(22,10),TPoint(40,20)); - gc->SetPenStyle(CGraphicsContext::EDottedPen); - gc->SetPenSize(TSize(1,1)); - gc->SetPenColor(TRgb::Gray4(0)); - gc->DrawLine(TPoint(40,11),TPoint(60,20)); - gc->SetPenStyle(CGraphicsContext::ESolidPen); - gc->Plot(TPoint(60,10)); -// - gc->BitBlt(TPoint(size.AsPoint()-TPoint(20,20)),aBitmap); - gc->BitBlt(TPoint(10,30),aBitmap,TRect(0,1,8,9)); - gc->BitBltMasked(TPoint(10,40),aBitmap,TRect(1,2,8,9),aMaskBitmap,ETrue); - gc->BitBltMasked(TPoint(20,40),aBitmap,TRect(0,0,9,9),aMaskBitmap,EFalse); - gc->SetOrigin(TPoint(5,50)); - gc->SetDrawMode(CGraphicsContext::EDrawModeXOR); - gc->SetPenColor(TRgb::Gray4(3)); - gc->SetClippingRect(TRect(0,0,20,15)); - //gc->DrawArc(TRect(0,0,20,15),TPoint(10,0),TPoint(1,8)); - gc->CancelClippingRect(); - gc->SetDrawMode(CGraphicsContext::EDrawModePEN); - gc->SetPenColor(TRgb::Gray4(0)); - gc->MoveTo(TPoint(25,0)); - gc->DrawLineTo(TPoint(40,5)); - gc->DrawLineBy(TPoint(-20,10)); -// - CArrayFixFlat* polyLineArray=new(ELeave) CArrayFixFlat(4); - CleanupStack::PushL(polyLineArray); - polyLineArray->AppendL(TPoint(8,0)); - polyLineArray->AppendL(TPoint(16,10)); - polyLineArray->AppendL(TPoint(0,3)); - polyLineArray->AppendL(TPoint(16,3)); - polyLineArray->AppendL(TPoint(0,10)); - polyLineArray->AppendL(TPoint(8,0)); - gc->SetBrushStyle(CGraphicsContext::ESolidBrush); - gc->SetOrigin(TPoint(50,50)); - gc->DrawPolyLine(polyLineArray); - gc->SetOrigin(TPoint(75,50)); - gc->DrawPolyLine(&(polyLineArray->At(0)),polyLineArray->Count()); - polyLineArray->Delete(5); - gc->SetOrigin(TPoint(0,65)); - gc->DrawPolygon(polyLineArray,CGraphicsContext::EWinding); - gc->SetOrigin(TPoint(25,65)); - gc->DrawPolygon(&(polyLineArray->At(0)),polyLineArray->Count(),CGraphicsContext::EWinding); - gc->SetOrigin(TPoint(50,65)); - gc->DrawPolygon(polyLineArray,CGraphicsContext::EAlternate); - gc->SetOrigin(TPoint(75,65)); - gc->DrawPolygon(&(polyLineArray->At(0)),polyLineArray->Count(),CGraphicsContext::EAlternate); - CleanupStack::PopAndDestroy(); - gc->SetBrushStyle(CGraphicsContext::ENullBrush); - gc->SetOrigin(TPoint(0,0)); -// - gc->DrawPie(TRect(5,80,30,100),TPoint(10,65),TPoint(35,80)); - gc->DrawEllipse(TRect(35,80,60,100)); - gc->DrawRoundRect(TRect(65,80,80,100),TSize(5,3)); - gc->DrawBitmap(TRect(10,105,40,120),aBitmap); - gc->DrawBitmap(TRect(45,105,105,125),aBitmap,TRect(5,5,25,20)); -//gc->DrawBitmap(TRect(110,40,205,125),aBitmap,TRect(5,5,25,20)); - if (aExtraDrawBitMap) - gc->DrawBitmap(TPoint(110,70),aBitmap); -// - gc->UseFont(aFont); - TInt height=aFont->HeightInPixels(); - TInt ascent=aFont->AscentInPixels(); - TInt ypos=5; - TInt xpos=100; - gc->DrawText(_L("Test1"),TPoint(xpos,ypos+ascent)); - gc->DrawText(_L("Test2"),TRect(xpos,ypos+height,xpos+50,5+height*2),ascent); - gc->DrawText(_L("Test3"),TRect(xpos,ypos+height*2,xpos+80,5+height*3),ascent,CGraphicsContext::ERight,10); -// - ypos+=ascent+height*3; - gc->SetUnderlineStyle(EUnderlineOn); - gc->DrawText(_L("ULine"),TPoint(xpos,ypos)); - gc->SetUnderlineStyle(EUnderlineOff); -// - gc->SetStrikethroughStyle(EStrikethroughOn); - gc->DrawText(_L("Strike"),TPoint(xpos+50,ypos)); - gc->SetStrikethroughStyle(EStrikethroughOff); - gc->SetCharJustification(15,3); - gc->DrawText(_L("abc"),TPoint(xpos+100,ypos)); -// - gc->SetWordJustification(10,1); - gc->DrawText(_L("Two Words"),TPoint(xpos+5,ypos+height)); -// - xpos = 80; - ypos = 40; - RRegion clipRegion(2); -// - clipRegion.AddRect(TRect(xpos, ypos+10, xpos+30, ypos+20)); - clipRegion.AddRect(TRect(xpos, ypos+30, xpos+30, ypos+40)); - gc->SetClippingRegion(clipRegion); -// - gc->DrawTextVertical(_L("Vertical Text"), TPoint(xpos+10, ypos+10), EFalse); - gc->DrawTextVertical(_L("Vertical Text Box"), TRect(xpos+40, ypos+10, xpos+60, ypos+100), 15, EFalse); -// - gc->CancelClippingRegion(); - clipRegion.Close(); -// - gc->AlphaBlendBitmaps(TPoint(xpos+60, ypos+100), aBitmap, TRect(0, 0, 20,20), aMaskBitmap, TPoint(0, 0)); -// - gc->SetPenColor(TRgb::Gray4(3)); - gc->SetBrushColor(TRgb::Gray4(0)); - gc->SetBrushStyle(CGraphicsContext::ESolidBrush); - xpos = 0; - ypos = 120; - TRect mapColorRect(xpos, ypos, xpos+20, ypos+20); - gc->DrawRect(mapColorRect); - TRgb colours[4] = { TRgb::Gray4(3), TRgb::Gray4(0), TRgb::Gray4(0), TRgb::Gray4(3) }; - gc->MapColors(mapColorRect, colours, 2, ETrue); -// - gc->DiscardFont(); diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/Dither.MBM Binary file windowing/windowserver/tauto/Dither.MBM has changed diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/GREYLINE.PBM Binary file windowing/windowserver/tauto/GREYLINE.PBM has changed diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/MASK0.PBM Binary file windowing/windowserver/tauto/MASK0.PBM has changed diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/MASK1.PBM Binary file windowing/windowserver/tauto/MASK1.PBM has changed diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/MASK2.PBM Binary file windowing/windowserver/tauto/MASK2.PBM has changed diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TALPHAWIN.H --- a/windowing/windowserver/tauto/TALPHAWIN.H Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,136 +0,0 @@ - -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef __TALPHAWIN_H__ -#define __TALPHAWIN_H__ - -#include "AUTO.H" -#include "TGraphicsHarness.h" - -class CTDrawOpWin; -class CTAlphaWindow; -class CTAlphaRefWin; - -class CTAlphaWin : public CTWsGraphicsBase - { -public: - CTAlphaWin(CTestStep* aStep); - ~CTAlphaWin(); - void ConstructL(); - void TestCondition(); - void TestConditionL(); -protected: -//from CTGraphicsStep - virtual void RunTestCaseL(TInt aCurTestCase); -private: - void ConfigureDisplayModes(TDisplayMode aRequiredMode); - // The blending test works as follows: - // On the left, we have a window which draws using an opaque half-red colour - // On the right, we have a window which blends using a semi-transparent full-red colour - // The test compares left and right - void TestSemiTransparentDrawingL(); - void TestTransparentDrawingL(); - - // The transparent window tests work as follows: - // On the left, we have transparent windows, on which we perform various various operations - // On the right, we have a reference window, in which we draw what we think the windows on the left should look like - // The test compares the right and the left - void TestInitialConfiguration(); - void TestMove(); - void TestRedraw(); - void TestInvisible(); - void TestChildrenL(); - void TestAntiAliasedTextTransparentL(); - void CheckRectL(const TRect& rect1, const TRect& rect2, TSize aSize, TDisplayMode aRequiredMode, TInt aTolerance, const TDesC& aErrorMsg); - -private: - TFixedArray iTestWin; - CTAlphaRefWin* iRefWin; - }; - -class CTDrawOpWin : public CTWin - { -public: - static CTDrawOpWin* NewL(CTAlphaWin* aTest, CTWinBase* aParent, TPoint aPos, TSize aSize, TRgb aDrawColour); - CTDrawOpWin(CTAlphaWin* aTest, TRgb aDrawColour); - - //Virtual Function from CTBaseWin - void Draw(); - - void SetDrawOp(TInt aDrawOp); -private: - CTAlphaWin* iTest; - TRgb iDrawColour; - TInt iDrawOp; - }; - - -class CTAlphaWindow : public CTWin - { - friend class CTAlphaRefWin; -public: - inline CTAlphaWindow(CTAlphaWin* aTest) : iTest(aTest) {} - ~CTAlphaWindow(); - static CTAlphaWindow* NewL(CTAlphaWin* aTest, CTWinBase* aParent, TPoint aPos, TSize aSize, TInt aDrawState); - - //Virtual Function from CTBaseWin - void Draw(); - - void SetDrawState(TInt aDrawState); - TInt DrawState(); - - void SetVisible(TBool aVisible); - void CreateChildrenL(TInt aDepth); - void DestroyChildren(); -private: - TInt iDrawState; - CTAlphaWin* iTest; - CTAlphaWindow* iChild1; - CTAlphaWindow* iChild2; - }; - -class CTAlphaRefWin : public CTWin - { - // This class is used to draw what we think things should look like, for comparison with what they actually look like -public: - inline CTAlphaRefWin(TFixedArray& aAlphaWin); - static CTAlphaRefWin* NewL(CTWinBase* aParent, TPoint aPos, TSize aSize, TFixedArray& aAlphaWin); - void Draw(); -private: - void DrawWindow(CTAlphaWindow* aWindow, TPoint aOffset); -private: - TFixedArray& iAlphaWin; - }; - -class CTAlphaWinStep : public CTGraphicsStep - { -public: - CTAlphaWinStep(); -protected: - //from CTGraphicsStep - virtual CTGraphicsBase* CreateTestL(); - }; - -_LIT(KTAlphaWinStep,"TAlphaWin"); - - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TAUTO.H --- a/windowing/windowserver/tauto/TAUTO.H Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,25 +0,0 @@ -// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Generated by BitmapCompiler -// -// - -enum TMbmTauto - { - EMbmTautoBluehash, - EMbmTautoGreyline, - EMbmTautoMask0, - EMbmTautoMask1, - EMbmTautoMask2 - }; diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TAUTODLL.CPP --- a/windowing/windowserver/tauto/TAUTODLL.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2945 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Client side of AUTODLL test code -// -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include "TAUTODLL.H" -#include "TEVENT.H" - -//#define LOGGING - -// - - -CGraphicsContext::TDrawMode CAnimWindow::iEllipseDrawMode; - -CTAnimDll::CTAnimDll(CTestStep* aStep) : CTWsGraphicsBase(aStep) - { - } - -RTestAnim::RTestAnim() : RAnim() - { - } - -RTestAnim::RTestAnim(RAnimDll &aDll) : RAnim(aDll) - { - } - -LOCAL_C TInt DoPanicTest(TInt aInt, TAny *aScreenNumber) - { - RWsSession ws; - User::LeaveIfError(ws.Connect()); - - // assign to the correct screen - CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws); - User::LeaveIfError(screen->Construct((TInt)aScreenNumber)); - - RWindowGroup group(ws); - User::LeaveIfError(group.Construct(333)); - group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close - RAnimDll animDll=RAnimDll(ws); - User::LeaveIfError(animDll.Load(KAnimDLLName)); - RTestAnim panic(animDll); - RWindow window(ws); - RBlankWindow blankwin(ws); - if (aInt==16 || aInt==17) // Use a blank window for this one - { - User::LeaveIfError(blankwin.Construct(group,123)); - blankwin.SetSize(TSize(10,10)); - blankwin.Activate(); - User::LeaveIfError(panic.Construct(blankwin,EAnimTypeTest1,TPtrC8())); - } - else - { - User::LeaveIfError(window.Construct(group,123)); - window.SetSize(TSize(10,10)); - window.Activate(); - window.BeginRedraw(); - window.EndRedraw(); - if (aInt==0) - User::LeaveIfError(panic.Construct(window,EAnimTypeTest2,TPtrC8())); - User::LeaveIfError(panic.Construct(window,EAnimTypeTest1,TPtrC8())); - } - TPckgBuf dummyParam; - switch(aInt) - { - case 1: - panic.Command(EADllPanicCallPanic); - break; - case 2: - panic.Command(EADllPanicCallPanic,dummyParam); - break; - case 3: - panic.CommandReply(EADllPanicCallPanic); - break; - case 4: - panic.CommandReply(EADllPanicCallPanic,dummyParam); - break; - case 5: - panic.Command(EADllPanicSetInterval); - break; - case 6: - panic.Command(EADllPanicSetNextInterval); - break; - case 7: - panic.CommandReply(EADllPanicBadFont); - break; - case 8: - panic.CommandReply(EADllPanicBadBitmap); - break; - case 9: - panic.Command(EADllPanicLeave); - break; - case 10: - panic.Command(EADllPanicDoubleActivateGC); - break; - case 11: - panic.Command(EADllPanicDrawRectWithNoGc); - break; - case 12: - panic.Command(EADllPanicDrawTextWithNoFont); - break; - case 13: - panic.Command(EADllPanicLeaveInAnimate); - ws.Finish(); - panic.CommandReply(EADllBlankOpCode); - break; - case 14: - panic.Command(EADllPanicLeaveInRedraw); - window.BeginRedraw(); - window.EndRedraw(); - ws.Finish(); - panic.CommandReply(EADllBlankOpCode); - break; - case 15: - ws.TestWrite(animDll.WsHandle(),999,NULL,0); - break; - case 16: - panic.Command(EADllPanicSetVisWithGcActive); - break; - case 17: - panic.CommandReply(EADllPanicSetVisWithGcActiveReply); - break; - case 18: - panic.Command(EADllPanicLeaveInActiveCallback); - ws.Flush(); - User::After(2000000); - panic.CommandReply(EADllBlankOpCode); - break; - case 19: - panic.Command(EADllPanicSetClippingRectWithNoGc); - break; - case 20: - panic.CommandReply(EADllPanicSetClippingRegionWithNoGc); - break; - case 21: - panic.Command(EADllPanicCancelClippingRegionWithNoGc); - break; - case 22: - panic.Command(EADllPanicCancelClippingRectWithNoGc); - break; - case 23: - panic.Command(EADllPanicSetDrawModeWithNoGc); - break; - case 24: - panic.Command(EADllPanicUseFontWithNoGc); - break; - case 25: - panic.Command(EADllPanicDiscardFontWithNoGc); - break; - case 26: - panic.Command(EADllPanicSetUnderlineStyleWithNoGc); - break; - case 27: - panic.Command(EADllPanicSetStrikeThoughStyleWithNoGc); - break; - case 28: - panic.Command(EADllPanicSetWordJustificationWithNoGc); - break; - case 29: - panic.Command(EADllPanicSetCharJustificationWithNoGc); - break; - case 30: - panic.Command(EADllPanicSetPenColorWithNoGc); - break; - case 31: - panic.Command(EADllPanicSetPenStyleWithNoGc); - break; - case 32: - panic.Command(EADllPanicSetPenSizeWithNoGc); - break; - case 33: - panic.Command(EADllPanicSetBrushColorWithNoGc); - break; - case 34: - panic.Command(EADllPanicSetBrushStyleWithNoGc); - break; - case 35: - panic.Command(EADllPanicSetBrushOriginWithNoGc); - break; - case 36: - panic.Command(EADllPanicUseBrushPatterWithNoGc); - break; - case 37: - panic.Command(EADllPanicDiscardBrushPatternWithNoGc); - break; - case 38: - panic.Command(EADllPanicSetFadedWithNoGc); - break; - case 39: - panic.Command(EADllPanicSetFadingParametersWithNoGc); - break; - case 40: - panic.Command(EADllPanicDrawArcWithNoGc); - break; - case 41: - panic.Command(EADllPanicDrawPieWithNoGc); - break; - case 42: - panic.Command(EADllPanicDrawLineWithNoGc); - break; - case 43: - panic.Command(EADllPanicDrawLineToWithNoGc); - break; - case 44: - panic.Command(EADllPanicDrawLineByWithNoGc); - break; - case 45: - panic.Command(EADllPanicDrawEllipseWithNoGc); - break; - case 46: - panic.Command(EADllPanicDrawRoundedRecWithNoGc); - break; - case 47: - panic.Command(EADllPanicClearWithRectWithNoGc); - break; - case 48: - panic.Command(EADllPanicClearWithNoGc); - break; - case 49: - panic.Command(EADllPanicBitBltWithNoGc); - break; - case 50: - panic.Command(EADllPanicBitBltWithRectWithNoGc); - break; - case 51: - panic.Command(EADllPanicBitBltMaskedWithNoGc); - break; - case 52: - panic.Command(EADllPanicDrawBitmapPointWithNoGc); - break; - case 53: - panic.Command(EADllPanicDrawBitmapWithNoGc); - break; - case 54: - panic.Command(EADllPanicDrawBitmapRectWithNoGc); - break; - case 55: - panic.Command(EADllPanicDrawBitmapMaskedFbsBitmapWithNoGc); - break; - case 56: - panic.Command(EADllPanicDrawBitmapMaskedWsBitmapWithNoGc); - break; - case 57: - panic.Command(EADllPanicDrawPolyLinePointsWithNoGc); - break; - case 58: - panic.Command(EADllPanicDrawPolyLineArrayWithNoGc); - break; - case 59: - panic.CommandReply(EADllPanicDrawPolygonPointsWithNoGc); - break; - case 60: - panic.CommandReply(EADllPanicDrawPolygonArrayWithNoGc); - break; - case 61: - panic.Command(EADllPanicMoveToWithNoGc); - break; - case 62: - panic.Command(EADllPanicMoveByWithNoGc); - break; - case 63: - panic.Command(EADllPanicPlotWithNoGc); - break; - case 64: - panic.Command(EADllPanicSetOriginWithNoGc); - break; - case 65: - panic.Command(EADllPanicCopyRectWithNoGc); - break; - case 66: - panic.Command(EADllPanicResetWithNoGc); - break; - case 67: - panic.CommandReply(EADllPanicAlphaBlendingBitmapsFbsBitmapWithNoGc); - break; - case 68: - panic.Command(EADllPanicMapColorsWithNoGc); - break; - case 69: - panic.Command(EADllPanicDrawTextWithRectWithNoFont); - break; - case 70: - panic.Command(EADllPanicDrawTextVerticalWithNoFont); - break; - case 71: - panic.Command(EADllPanicDrawTextVerticalWithRectWithNoFont); - break; - case 72: - panic.CommandReply(EADllPanicDevice); - break; - case 73: - panic.Command(EADllPanicInvalidFocusScreenTooBig); - break; - case 74: - panic.Command(EADllPanicInvalidFocusScreenNegative); - break; - default: - return(EWsExitReasonFinished); - } - - ws.Flush(); - return(EWsExitReasonBad); - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-0125 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Panic tests - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions The test creates an animation and animation's client threads. - Each thread calls some - command of the animation which is expected to panic on certain reason. - The test checks that those client threads will panic returning - a proper panic code. Client threads are created and tested for - the following actions: - 1. A Command() call to an animation which executes - iFunctions->Panic() method. Client thread must panic with - code EWservPanicAnimDll. - 2. A Command() call with dummy parameter to an animation which - executes iFunctions->Panic() method. Client thread must panic - with code EWservPanicAnimDll. - 3. A CommandReply() call to an animation which executes - iFunctions->Panic() method. Client thread must panic with code - EWservPanicAnimDll. - 4. A CommandReply() call with dummy parameter to an animation - which executes iFunctions->Panic() method. Client thread must - panic with code EWservPanicAnimDll. - 5. A command that calls MAnimGeneralFunctions::SetInterval() when - the synchronisation mode is not TAnimSync::ESyncNone. Client - thread must panic with code EWservPanicAnimDll. - 6. A command that calls MAnimGeneralFunctions::SetNextInterval() - when the synchronisation mode is not TAnimSync::ESyncNone. Client - thread must panic with code EWservPanicAnimDll. - 7. A command that calls MAnimGeneralFunctions::DuplicateFontL() to - duplicate undefined font. Client thread must panic with code - EWservPanicFont. - 8. A command that calls MAnimGeneralFunctions::DuplicateBitmapL() - to duplicate undefined bitmap. Client thread must panic with code - EWservPanicBitmap. - 9. A command that calls User::Leave(KErrGeneral). Client thread - must panic with code EWservPanicAnimLeave. - 10. A command that activates window animation's graphical context - twice. Client thread must panic with code EWservPanicAnimDll. - 11. A command that tries to draw a rectangle while graphical - context is not defined yet. Client thread must panic with code - EWservPanicAnimLeave. - 12. A command that tries to draw a text whihout a font defined yet. - Client thread must panic with code EWservPanicNoFont. - 13. A command that causes an animation to leave during execution - of CAnim::Animate() method; and a new command call 4 seconds after - that. Client thread must panic with code EWservPanicAnimLeave. - 14. A command that causes an animation to leave during execution - of CAnim::Redraw() method. The client thread initiates it's window - redraw after that. Client thread must panic with code - EWservPanicAnimLeave. - 15. The client thread calls RWsSession::TestWrite() on animation - DLL server-side handle with opcode 999. Client thread must panic with code - EWservPanicOpcode. - 16. A command that activates graphical context and sets the - window to invisible and then to visible. Client thread must panic - with code EWservPanicAnimDll. - - -@SYMTestExpectedResults See test actions. -*/ -void CTAnimDll::TestPanicsL() - { - TInt index=0; - TBool finishTests=EFalse; - do - { - - - TClientPanic panicCode=EWservPanicAnimDll; - switch(index) - { - // panic the server with a KERN-4. When server fixed these this can be removed. - case 19: - case 20: - case 22: - case 24: - goto bypasstest; - - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: - case 6: - case 10: - case 16: - case 17: - case 18: - case 73: - case 74: - panicCode=EWservPanicAnimDll; - break; - case 7: - panicCode=EWservPanicFont; - break; - case 8: - panicCode=EWservPanicBitmap; - break; - case 12: - case 69: - case 70: - case 71: - panicCode=EWservPanicNoFont; - break; - case 15: - panicCode=EWservPanicOpcode; - break; - case 9: - case 11: - case 13: - case 14: - case 72: - default: // cases 19 - 68 - panicCode=EWservPanicAnimLeave; - break; - } - - TEST(iTest->TestWsPanicL(&DoPanicTest,panicCode,index,(TAny*)iTest->iScreenNumber,&finishTests)); -bypasstest: - if (iTest->iScreenNumber == 0) - iTest->CloseAllPanicWindows(); - index++; - } while(!finishTests); - } - -void CTAnimDll::TestSyncModes(MAnimGeneralFunctions::TAnimSync aSyncMode) - { - RTestAnim anim=RTestAnim(iAnimDll); - User::LeaveIfError(anim.Construct(*iTestWin->BaseWin(),EAnimTypeTest1,TPtrC8())); - CleanupClosePushL(anim); - - TPckgBuf params; - TRequestStatus status(KRequestPending); - params().status=&status; - params().syncMode=aSyncMode; - anim.CommandReply(EADllSyncTests,params); - User::WaitForRequest(status); - TEST(status==KErrNone); - - CleanupStack::PopAndDestroy(&anim); - } - -void CTAnimDll::TestTimeChange() - { - RTestAnim anim=RTestAnim(iAnimDll); - User::LeaveIfError(anim.Construct(*iTestWin->BaseWin(),EAnimTypeTest1,TPtrC8())); - CleanupClosePushL(anim); - - TPckgBuf params; - TRequestStatus status(KRequestPending); - TRequestStatus status2(KRequestPending); - params().status=&status; - params().status2=&status2; - anim.CommandReply(EADllTimeChangedTest,params); - User::WaitForRequest(status); - TTime time; - time.HomeTime(); - time+=TTimeIntervalHours(1); - User::SetHomeTime(time); - User::WaitForRequest(status2); - time.HomeTime(); - time-=TTimeIntervalHours(1); - User::SetHomeTime(time); - TEST(status2==KErrNone); - - CleanupStack::PopAndDestroy(&anim); - } - -void CTAnimDll::ConstructL() - { - TheClient->iGroup->WinTreeNode()->SetOrdinalPosition(0); - iRedrawWin=new(ELeave) CAnimWindow(EFalse, CAnimWindow::ERedraw); - iBackedUpTestWin=new(ELeave) CAnimWindow(EFalse, CAnimWindow::EBackedUp); - iBlankTestWin=new(ELeave) CAnimWindow(EFalse, CAnimWindow::EBlank); - iBaseWin=new(ELeave) CAnimWindow(ETrue, CAnimWindow::ERedraw); - -// - TSize screenSize=TheClient->iGroup->Size(); - TInt winWidth=(screenSize.iWidth/3)-10; - TInt winHeight=screenSize.iHeight-10; - iBaseWin->ConstructL(TPoint(screenSize.iWidth/3+5,5),TSize(winWidth,winHeight)); - iBlankTestWin->ConstructL(TPoint(screenSize.iWidth/3*2+5,5),TSize(winWidth,winHeight)); - ((RBlankWindow *)iBlankTestWin->BaseWin())->SetColor(TRgb::Gray4(2)); - iBackedUpTestWin->ConstructL(TPoint(screenSize.iWidth/3*2+5,5),TSize(winWidth,winHeight)); - iRedrawWin->ConstructL(TPoint(screenSize.iWidth/3*2+5,5),TSize(winWidth,winHeight)); -// - iTestWin=iRedrawWin; -// - iAnimDll=RAnimDll(TheClient->iWs); - TInt retVal = iAnimDll.Load(KAnimDLLName); - TEST(retVal==KErrNone); - if (retVal!=KErrNone) - INFO_PRINTF3(_L("iAnimDll.Load(KAnimDLLName) return value - Expected: %d , Actual: %d"), KErrNone, retVal); - } - -CTAnimDll::~CTAnimDll() - { - iAnimDll.Close(); - delete iBackedUpTestWin; - delete iBlankTestWin; - delete iRedrawWin; - delete iBaseWin; - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-0126 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Miscellaneous animation tests. - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Tests window animation's window funtions like WindowSize(), - IsHidden(), SetVisible(). - Tests RAnimDll's constructor, Close(), Load() and copy-constructor. - -@SYMTestExpectedResults Expects window funtions and RAnimDll's methods work properly. -*/ -void CTAnimDll::Misc() - { - RTestAnim anim=RTestAnim(iAnimDll); - User::LeaveIfError(anim.Construct(*iTestWin->BaseWin(),EAnimTypeTest1,TPtrC8())); - CleanupClosePushL(anim); - - TPckgBuf params; - params()=iTestWin->Size(); - TBool retBool = anim.CommandReply(EADllTestWindowSize,params); - TEST(retBool); - if (!retBool) - INFO_PRINTF3(_L("anim.CommandReply(EADllTestWindowSize,params) return value - Expected: %d , Actual: %d"), ETrue, retBool); - TheClient->iWs.Finish(); - retBool = anim.CommandReply(EADllTestSetVisible); - TEST(retBool); - if (!retBool) - INFO_PRINTF3(_L("anim.CommandReply(EADllTestSetVisible) return value - Expected: %d , Actual: %d"), ETrue, retBool); - CleanupStack::PopAndDestroy(&anim); - - RAnimDll closeme(TheClient->iWs); - closeme.Close(); - RAnimDll animdll(TheClient->iWs); - TInt retVal = animdll.Load(KAnimDLLName); - TEST(retVal==KErrNone); - if (retVal!=KErrNone) - INFO_PRINTF3(_L("animdll.Load(KAnimDLLName) return value - Expected: %d , Actual: %d"), KErrNone, retVal); - - RTestAnim anim2(animdll); - anim2.Close(); - animdll.Close(); - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-0127 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test animation's command call with reply - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Puts an array containing a sequnce of numbers into a command argument. - Performs command call to server, assuming that the server-side - should return a sum of the numbers in sequence. - -@SYMTestExpectedResults Checks that server returns the correct sum. -*/ -void CTAnimDll::RemoteBuffer() - { - RTestAnim anim=RTestAnim(iAnimDll); - User::LeaveIfError(anim.Construct(*iTestWin->BaseWin(),EAnimTypeTest1,TPtrC8())); - CleanupClosePushL(anim); - - TBuf buf(ERemoteBufSize); - TInt total=0; - for (TInt8 index=0;indexiWs); - TInt retVal = extraCopy.Load(KAnimDLLName); - TEST(retVal==KErrNone); - if (retVal!=KErrNone) - INFO_PRINTF3(_L("extraCopy.Load(KAnimDLLName) return value - Expected: %d , Actual: %d"), KErrNone, retVal); - - extraCopy.Close(); - } -// -void CTAnimDll::SyncMode1() - { - TestSyncModes(MAnimGeneralFunctions::ESyncSecond); - } - -void CTAnimDll::CheckWindows() - { - CheckRect(iBaseWin->CtBaseWin(),iTestWin->CtBaseWin(),TRect(iBaseWin->Size()),_L("CTAnimDll::CheckWindows() failed")); - } - -void CTAnimDll::InvalidatePauseAndRedraw(const TRect &aRect,TTimeIntervalMicroSeconds32 aInterval) - { - iTestWin->Invalidate(aRect); - TheClient->iWs.Flush(); - User::After(aInterval); - __ASSERT_DEBUG(iTestWin->iWinType==CAnimWindow::ERedraw,AutoPanic(EAutoPanicWindowType)); - RWindow *win=(RWindow *)iTestWin->BaseWin(); - win->BeginRedraw(); - iTestWin->DoDraw(); - win->EndRedraw(); - TheClient->iWs.Flush(); - } - -void CTAnimDll::RedrawAndCheckWindows(TBool aBlankIt) - { - if (iTestWin->iWinType==CAnimWindow::ERedraw) - { - RWindow *win=(RWindow *)iTestWin->BaseWin(); - win->BeginRedraw(); - iTestWin->DoDraw(aBlankIt); - win->EndRedraw(); - } - RWindow *win=(RWindow *)iBaseWin->BaseWin(); - win->BeginRedraw(); - iBaseWin->DoDraw(aBlankIt); - win->EndRedraw(); - TheClient->WaitForRedrawsToFinish(); - CheckWindows(); - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-0129 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Animation drawing test - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Performs animation drawing ontop of redrawable window, backed-up window and blank window. - Draws the same shapes using directly window graphics on an other window (base window). - The following shapes are drawn: - 1. An animation with a small ellipse drawn in XOR mode on top of redrawable - black-lined gray window. - 2. The same with a bigger ellipse but previously invalidating an - area which intersects the old ellipse and the new ellipse. - 3. Runs an animation that continuously moves a rectangle and shrinks another on top of - redrawable black-lined gray window and then cancels an animation. - The test checks that the window will be identical with the gray base window - that contains only black lines. - 4. An animation with a small ellipse drawn in XOR mode on top of backed-up - black-lined gray window. The test also calls Invalidate() method and performs - a check again to make sure that the test-window and base window are identical. - 5. An animation with a small ellipse drawn in XOR mode on top of the blank - gray window. The test also sends commands to the animation that call windows - SetVisible(EFalse) and SetVisible(ETrue) and checks that the - test-window and base window are identical. - - -@SYMTestExpectedResults Each time performs pixelwise comparisons of animated windows - and the base window expecting the windows to be identical. -*/ -void CTAnimDll::DrawingTestL() - { - // draws a little circle on the base window using window graphics and using window animation on the test window. - RTestAnim drawAnim=RTestAnim(iAnimDll); -// - TRect rect; - TPckgBuf rectPckg; - TPckgBuf boolPckg; - -// - _LIT(KLog1,"Draw Ellipse Test1"); - LOG_MESSAGE(KLog1); - rect = TRect(10,10,50,50); - CAnimWindow::SetEllipseDrawMode(CGraphicsContext::EDrawModeXOR); - iTestWin->Invalidate(); - iTestWin->SetRect(rect); - iBaseWin->Invalidate(); - iBaseWin->SetRect(rect); - rectPckg()=rect; - User::LeaveIfError(drawAnim.Construct(*iTestWin->BaseWin(),EAnimTypeTest3,rectPckg)); - RedrawAndCheckWindows(); -// - _LIT(KLog2,"Draw Ellipse Test2"); - LOG_MESSAGE(KLog2); - iTestWin->Invalidate(TRect(20,20,100,40)); - iBaseWin->Invalidate(TRect(20,20,100,40)); - iBaseWin->DoDrawEllipse(); // Should clear old Ellipse (except invalid bits) - rect=TRect(30,30,200,100); - rectPckg()=rect; - iBaseWin->SetRect(rect); - iBaseWin->DoDrawEllipse(); // Should draw new Ellipse (except invalid bits) - drawAnim.Command(EADllSetRect,rectPckg); - RedrawAndCheckWindows(); - iBaseWin->DoDrawEllipse(); // Clear old ellipse -// - _LIT(KLog3,"Window Overlap Anim Test"); - LOG_MESSAGE(KLog3); - - iBaseWin->SetRect(TRect()); - iBaseWin->DoDraw(); - TheClient->iWs.Finish(); - - // create another window on top and check that animation beneath is not visible - TSize screenSize=TheClient->iGroup->Size(); - TInt winWidth=(screenSize.iWidth/3)-10; - TInt winHeight=screenSize.iHeight-10; - TSize size=iTestWin->Size(); - rectPckg()=TRect(size); - drawAnim.Command(EADllStartAnimate,rectPckg); - - CAnimWindow *topWindow = new (ELeave) CAnimWindow(ETrue, CAnimWindow::ERedraw); - CleanupStack::PushL(topWindow); - topWindow->ConstructL(TPoint(screenSize.iWidth/3*2+5,5),TSize(winWidth,winHeight)); - - RWindow *win=(RWindow *)iTestWin->BaseWin(); - win->BeginRedraw(); - topWindow->DoDraw(EFalse); - win->EndRedraw(); - - TheClient->iWs.Flush(); - for(TInt i=0;iWaitForRedrawsToFinish(); - CheckRect(iBaseWin->CtBaseWin(),iTestWin->CtBaseWin(),TRect(iBaseWin->Size())); - - win->BeginRedraw(rect); - drawAnim.Command(EADllCancelAnimate,rectPckg); - win->EndRedraw(); - - CleanupStack::PopAndDestroy(topWindow); -// - iTestWin->BaseWin()->SetVisible(EFalse); - drawAnim.Close(); -// - _LIT(KLog4,"Draw Ellipse Test4&5"); - LOG_MESSAGE(KLog4); - rect=TRect(20,20,50,50); - iBackedUpTestWin->SetRect(rect); - iBackedUpTestWin->DoDraw(); - iBaseWin->SetRect(rect); - win->BeginRedraw(); - iBaseWin->DoDraw(); - win->EndRedraw(); - TheClient->iWs.Finish(); - - rectPckg()=rect; - User::LeaveIfError(drawAnim.Construct(*iBackedUpTestWin->BaseWin(),EAnimTypeTest3,rectPckg)); - TheClient->iWs.Finish(); - TheClient->WaitForRedrawsToFinish(); - CheckWindows(); - iBackedUpTestWin->Invalidate(); - TheClient->iWs.Flush(); - TheClient->WaitForRedrawsToFinish(); - CheckWindows(); - iBackedUpTestWin->BaseWin()->SetVisible(EFalse); -// - _LIT(KLog5,"Draw Ellipse Test6&7"); - LOG_MESSAGE(KLog5); - rect=TRect(20,20,50,50); - TheClient->iWs.Flush(); - RWindow *winBase=(RWindow *)iBaseWin->BaseWin(); - winBase->BeginRedraw(); - iBaseWin->SetRect(rect); - iBaseWin->DoDraw(ETrue); - winBase->EndRedraw(); - rectPckg()=rect; - User::LeaveIfError(drawAnim.Construct(*iBlankTestWin->BaseWin(),EAnimTypeTest3,rectPckg)); - TheClient->iWs.Flush(); - iBlankTestWin->Invalidate(); - TheClient->iWs.Flush(); - TheClient->WaitForRedrawsToFinish(); - CheckWindows(); - boolPckg()=EFalse; - drawAnim.Command(EADllSetVisible,boolPckg); - TheClient->iWs.Flush(); - boolPckg()=ETrue; - drawAnim.Command(EADllSetVisible,boolPckg); - TheClient->WaitForRedrawsToFinish(); - CheckWindows(); - -//This test does functional coverage by calling code that executes each of the -//server's class (CWsAnimGc) members in turn. - - - _LIT(KLog6,"Draw Primitives (Coverage) Test"); - LOG_MESSAGE(KLog6); - rect = TRect(10,10,150,150); - iBaseWin->BaseWin()->SetVisible(ETrue); - iBaseWin->SetRect(TRect(0,0,0,0)); - winBase->BeginRedraw(); - iBaseWin->DoDraw(); - iBaseWin->SetRect(rect); - iBaseWin->DoDrawCoverage(); - winBase->EndRedraw(); - - iTestWin->BaseWin()->SetVisible(ETrue); - iTestWin->SetRect(rect); - win->BeginRedraw(); - iTestWin->DoDraw(); - win->EndRedraw(); - - rectPckg()=rect; - User::LeaveIfError(drawAnim.Construct(*iTestWin->BaseWin(),EAnimTypeCoverage,rectPckg)); - - //set font - CFbsFont* font; - User::LeaveIfError(TheClient->iGc->Device()->GetNearestFontToDesignHeightInTwips((CFont*&)font, TFontSpec())); - TPckgBuf fontHandle; - fontHandle() = font->Handle(); - const TInt err = drawAnim.CommandReply(EADllSetFont, fontHandle); - TheClient->iGc->Device()->ReleaseFont(font); - User::LeaveIfError(err); - - //draw - User::LeaveIfError(drawAnim.CommandReply(EADllDrawNow)); - - TheClient->iWs.Finish(); - TheClient->WaitForRedrawsToFinish(); - CheckWindows(); - drawAnim.Close(); - } - -void CTAnimDll::ShadowDrawingTestL() - { -// Create a blank window to cast a shadow over the animation - TSize scrSize(TheClient->iScreen->SizeInPixels()); - CTBlankWindow *blank=new(ELeave) CTBlankWindow(); - CleanupStack::PushL(blank); - blank->SetUpL(TPoint(0,10), TSize(scrSize.iWidth,scrSize.iHeight/3), TheClient->iGroup, *TheClient->iGc); - blank->BaseWin()->SetShadowHeight(2); - iBlankTestWin->BaseWin()->SetShadowHeight(0); -// - RTestAnim drawAnim=RTestAnim(iAnimDll); - TRect rect(10,scrSize.iHeight/3-20,50,scrSize.iHeight/3+40); - TPckgBuf rectPckg; - rectPckg()=rect; - User::LeaveIfError(drawAnim.Construct(*iBlankTestWin->BaseWin(),EAnimTypeTest3,rectPckg)); - drawAnim.Command(EADllSetShadowDrawMode); - CAnimWindow::SetEllipseDrawMode(CGraphicsContext::EDrawModePEN); -// - iBlankTestWin->Invalidate(); - iBlankTestWin->SetRect(rect); - iBaseWin->Invalidate(); - iBaseWin->SetRect(rect); - RedrawAndCheckWindows(ETrue); -// - for(TInt ypos=10;ypos>0;ypos-=4) - { - blank->SetPos(TPoint(0,ypos)); - TPckgBuf params; - TRequestStatus status(KRequestPending); - params().status=&status; - drawAnim.CommandReply(EADllShadowAnimTest,params); - User::WaitForRequest(status); - RedrawAndCheckWindows(ETrue); - } -// - CleanupStack::PopAndDestroy(blank); // Destroy the shadow window - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-0130 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Complicated drawing test - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Performs complicated drawing both through the animation on - a blank window and through direct fbs drawing on the second - window. - -@SYMTestExpectedResults Expects the both windows to be are identical -*/ -void CTAnimDll::GeneralDrawingTestL() - { - // This test has been removed as it is no longer relevant - // Anims are not allowed to draw immediately to the screen - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-0131 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Animated window destruction test - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Creates a window and a child window inside it, runs an animation - in the child window in ESyncFlash mode, destroys windows. - -@SYMTestExpectedResults Expects the operations not to fail. -*/ -void CTAnimDll::DestroyWindowTestL() - { - RWindow window(TheClient->iWs); - User::LeaveIfError(window.Construct(*TheClient->iGroup->GroupWin(),123)); - CleanupClosePushL(window); - window.SetSize(TSize(100,100)); - window.Activate(); - RWindow window2(TheClient->iWs); - CleanupClosePushL(window2); - User::LeaveIfError(window2.Construct(window,124)); - window2.Activate(); - window2.BeginRedraw(); // Validate it - window2.EndRedraw(); -// - RTestAnim drawAnim; - drawAnim=RTestAnim(iAnimDll); - TRect rect(10,10,50,50); - TPckgBuf rectPckg; - rectPckg()=rect; - User::LeaveIfError(drawAnim.Construct(window2,EAnimTypeTest3,rectPckg)); - drawAnim.Command(EADllStartAnimate,rectPckg); - CleanupStack::Pop(&window2); - CleanupStack::PopAndDestroy(&window); - TheClient->iWs.Flush(); - User::After(TTimeIntervalMicroSeconds32(2000000)); - window2.Close(); - drawAnim.Close(); - } - -void CTAnimDll::SetUpMember(TSpriteMember &aMember,TInt aType) - { - switch (aType) - { - case 1: - iTest->SetUpMember(aMember); - aMember.iOffset=TPoint(); - aMember.iInterval=TTimeIntervalMicroSeconds32(1); - break; - case 2: - aMember.iInvertMask=EFalse; - aMember.iDrawMode=CGraphicsContext::EDrawModeXOR; - aMember.iOffset=TPoint(1,2); - aMember.iInterval=TTimeIntervalMicroSeconds32(2); - break; - case 3: - aMember.iInvertMask=ETrue; - aMember.iDrawMode=CGraphicsContext::EDrawModeOR; - aMember.iOffset=TPoint(3,4); - aMember.iInterval=TTimeIntervalMicroSeconds32(3); - break; - default: - iTest->SetUpMember(aMember); - } - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-0132 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Sprite animation test - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Creates a sprite with three sprite members and a sprite animation - passing the sprite to it. The test updates sprite members' - properties in various ways verifying that the properties are changing - on the server-side as well. - -@SYMTestExpectedResults Expects that operations above do not fail and that client-side - changes to the sprite affect server-side properly. -*/ -#define HALF_SEC 500000 -void CTAnimDll::SpriteAnimL() - { - // create a sprite, add 3 members to it - RWsSprite sprite(TheClient->iWs); - iRedrawWin->BaseWin()->SetVisible(ETrue); - sprite.Construct(*iRedrawWin->CtBaseWin()->BaseWin(),TPoint(),0); - CleanupClosePushL(sprite); - CFbsBitmap* bitmap1=new(ELeave) CFbsBitmap(); - CleanupStack::PushL(bitmap1); - CFbsBitmap* bitmap2=new(ELeave) CFbsBitmap(); - CleanupStack::PushL(bitmap2); - CFbsBitmap* bitmap3=new(ELeave) CFbsBitmap(); - CleanupStack::PushL(bitmap3); - User::LeaveIfError(bitmap1->Create(TSize(10,12),EGray4)); - User::LeaveIfError(bitmap2->Create(TSize(15,17),EGray4)); - User::LeaveIfError(bitmap3->Create(TSize(20,22),EGray4)); - TSpriteMember member1; - TSpriteMember member2; - TSpriteMember member3; - SetUpMember(member1,1); - member1.iBitmap=bitmap1; - member1.iMaskBitmap=bitmap1; - SetUpMember(member2,2); - member2.iBitmap=bitmap2; - member2.iMaskBitmap=bitmap2; - SetUpMember(member3,3); - member3.iBitmap=bitmap3; - member3.iMaskBitmap=bitmap3; - sprite.AppendMember(member1); - sprite.AppendMember(member2); - sprite.AppendMember(member3); - - // create a sprite animation for the sprite - RTestAnim spriteAnim(iAnimDll); - TPtrC8 des(NULL,0); - TPoint pos(1,2); - User::LeaveIfError(spriteAnim.Construct(sprite,EAnimTypeSprite,des)); - CleanupClosePushL(spriteAnim); - - // call EADllCheckMember-command to verify that sprite animation's members - // have the same properties as the sprite instance - TPckgBuf spriteInfo; - spriteInfo()=TSpriteMemberInfo(TPoint(),0,member1); - TBool retBool = spriteAnim.CommandReply(EADllCheckMember,spriteInfo); - TEST(retBool); - if (!retBool) - INFO_PRINTF3(_L("spriteAnim.CommandReply(EADllCheckMember,spriteInfo) return value - Expected: %d , Actual: %d"), ETrue, retBool); - - sprite.SetPosition(pos); - spriteInfo()=TSpriteMemberInfo(pos,1,member2); - retBool = spriteAnim.CommandReply(EADllCheckMember,spriteInfo); - TEST(retBool); - if (!retBool) - INFO_PRINTF3(_L("spriteAnim.CommandReply(EADllCheckMember,spriteInfo) return value - Expected: %d , Actual: %d"), ETrue, retBool); - - pos.SetXY(3,4); - sprite.SetPosition(pos); - spriteInfo()=TSpriteMemberInfo(pos,2,member3); - retBool = spriteAnim.CommandReply(EADllCheckMember,spriteInfo); - TEST(retBool); - if (!retBool) - INFO_PRINTF3(_L("spriteAnim.CommandReply(EADllCheckMember,spriteInfo) return value - Expected: %d , Actual: %d"), ETrue, retBool); - - // call commands to change sprite members' bitmaps and update members - spriteAnim.Command(EADllDraw1); - spriteAnim.Command(EADllDraw2); - spriteAnim.Command(EADllDraw3); - TheClient->iWs.Flush(); - User::After(HALF_SEC); - - // call commands to change sprite's position - TPckgBuf position; - position().SetXY(60,50); - spriteAnim.Command(EADllSetPos,position); - TheClient->iWs.Flush(); - User::After(HALF_SEC); - - // change 1st member's bitmap size and interval, update it and call command to check - // that the new properties are applied - User::LeaveIfError(bitmap1->Resize(TSize(30,32))); - member1.iMaskBitmap=NULL; - member1.iInterval=TTimeIntervalMicroSeconds32(25); - User::LeaveIfError(sprite.UpdateMember(0,member1)); - spriteInfo()=TSpriteMemberInfo(TPoint(),0,member1); - retBool = spriteAnim.CommandReply(EADllCheckMember,spriteInfo); - TEST(retBool); - if (!retBool) - INFO_PRINTF3(_L("spriteAnim.CommandReply(EADllCheckMember,spriteInfo) return value - Expected: %d , Actual: %d"), ETrue, retBool); - - User::After(HALF_SEC); - - // change 1st member's bitmap size and calls command that invokes - // MAnimSpriteFunctions::SizeChangedL(). Check that new property is applied - spriteAnim.CommandReply(EADllDeactivate); - User::LeaveIfError(bitmap1->Resize(TSize(35,37))); - spriteAnim.Command(EADllSizeChanged); - spriteAnim.CommandReply(EADllActivate); - spriteInfo()=TSpriteMemberInfo(TPoint(),0,member1); - retBool = spriteAnim.CommandReply(EADllCheckMember,spriteInfo); - TEST(retBool); - if (!retBool) - INFO_PRINTF3(_L("spriteAnim.CommandReply(EADllCheckMember,spriteInfo) return value - Expected: %d , Actual: %d"), ETrue, retBool); - - User::After(HALF_SEC); - - // call command that changes 1st member's bitmap image - spriteAnim.Command(EADllIncDraw); - TheClient->iWs.Flush(); - User::After(HALF_SEC); - - - CleanupStack::PopAndDestroy(5,&sprite); - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-0133 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Free timer animation test - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions The test creates a free timer window animation that animates - a shrinking filled rect which changes colour in a predefined way. - -@SYMTestExpectedResults The test verifies that the colour changes gets through to the the display. -*/ - -#define NOT_TIMED_OUT timeWaitingForFrame < frametime<<4 -void CTAnimDll::FreeTimerL() - { - RTestAnim freeTimerAnim(iAnimDll); - User::LeaveIfError(freeTimerAnim.Construct(*iRedrawWin->BaseWin(),EAnimTypeFreeTimer,KNullDesC8)); - CleanupClosePushL(freeTimerAnim); - - const TInt frametime = 100000; // 100 ms - const TInt samplingtime = frametime>>1; // 50 ms - - TPckgC frametimeBuf(frametime); - freeTimerAnim.Command(ESetFrameTime, frametimeBuf); - freeTimerAnim.Command(EStartAnimation); - TheClient->iWs.Flush(); - TheClient->iWs.Finish(); - - TInt x = iRedrawWin->BaseWin()->AbsPosition().iX + (iRedrawWin->BaseWin()->Size().iWidth >> 1); - TInt y = iRedrawWin->BaseWin()->AbsPosition().iY + (iRedrawWin->BaseWin()->Size().iHeight >> 1); - TPoint middle(x,y); - - TRgb color = KRgbMagenta; - TBool foundRedFrame = EFalse; - TBool foundGreenFrame = EFalse; - TBool foundBlueFrame = EFalse; - TBool foundBlackFrame = EFalse; - - //The free-timer animates the colour in this predefined way. - //Test that the screen gets updated. - TInt timeWaitingForFrame = 0; - while(NOT_TIMED_OUT && !(foundRedFrame && foundGreenFrame && foundBlueFrame && foundBlackFrame)) //wait max 16*frametime=1280ms - { - //wait for the colour frame - color = PixelColour(middle); - - if(color == KRgbRed) - { - foundRedFrame = ETrue; - } - else if(color == KRgbGreen) - { - foundGreenFrame = ETrue; - } - else if(color == KRgbBlue) - { - foundBlueFrame = ETrue; - } - else if(color == KRgbBlack) - { - foundBlackFrame = ETrue; - } - - timeWaitingForFrame += samplingtime; - User::After(samplingtime); - } - - TEST(foundRedFrame); - TEST(foundGreenFrame); - TEST(foundBlueFrame); - TEST(foundBlackFrame); - - freeTimerAnim.Command(EStopAnimation); - CleanupStack::PopAndDestroy(&freeTimerAnim); - } - -TRgb CTAnimDll::PixelColour(const TPoint& aPoint) const - { - TRgb pixel; - TheClient->iScreen->GetPixel(pixel, aPoint); - return pixel; - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-0134 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Animation's ESyncSecond sync-mode test - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Creates an animation in ESyncSecond sync-mode. - Checks that animation's Animate() method was called either 9, 10 or 11 - times during a 10-seconds-wait. - The test also checks that if RWsSession::PrepareForSwitchOff() - is called then the Animate() method will not be called until - TRawEvent::EActive event is simulated. - -@SYMTestExpectedResults See actions. -*/ -static const TInt K1Second = 1000000; -static const TInt K3Seconds = 3000000; -static const TInt K9Seconds = 9500000; -void CTAnimDll::DisableTimerL() - { - //Defer start of timerAnim until the systen time are close to a full second - TTime now; - now.HomeTime(); - TInt deferTime = K1Second - now.DateTime().MicroSecond(); - User::After(deferTime); - - //Kick off timerAnim - RTestAnim timerAnim(iAnimDll); - User::LeaveIfError(timerAnim.Construct(*iRedrawWin->BaseWin(),EAnimTypeTimer,KNullDesC8)); - - User::After(K9Seconds); - TInt count=timerAnim.CommandReply(EADllCurrentCount); - -#if defined(LOGGING) - TLogMessageText buf; - _LIT(KLog,"Anim DisableTimer Count=%d"); - buf.Format(KLog,count); - TheClient->LogMessage(buf); -#endif - - TEST(count>=9 && count<=11); - if (count != 10) - INFO_PRINTF2(_L("count>=9 && count<=11 - Expected: 9,10 or 11 , Actual: %d"), count); - -#if defined(__WINS__) - TheClient->iWs.SimulateXyInputType(EXYInputNone); //Turn off pen in case it turns on the timer -#endif - - // reset timer's counter and call RWsSession::PrepareForSwitchOff(), - // check that 3 seconds after the counter = 0 - timerAnim.Command(EADllResetCount); - timerAnim.Command(EADllNoTimer); - TheClient->iWs.PrepareForSwitchOff(); - TheClient->iWs.Flush(); - User::After(K3Seconds); - count=timerAnim.CommandReply(EADllCurrentCount); -#if defined(LOGGING) - buf.Format(KLog,count); - TheClient->LogMessage(buf); -#endif - TEST(count==0); - if (count!=0) - INFO_PRINTF3(_L("count==0 - Expected: %d , Actual: %d"), 0, count); - - - // simulates TRawEvent::EActive event, - // check that the timer didn't ticked until the event were simulated - timerAnim.Command(EADllTimerStarted); - TRawEvent event; - event.Set(TRawEvent::EActive); - TheClient->iWs.SimulateRawEvent(event); -#if defined(__WINS__) - TheClient->iWs.SimulateXyInputType(EXYInputPointer); //Turn pen on again -#endif - TInt retVal = timerAnim.CommandReply(EADllFailed); - TEST(retVal==0); - if (retVal!=0) - INFO_PRINTF3(_L("timerAnim.CommandReply(EADllFailed) return value - Expected: %d , Actual: %d"), 0, retVal); - - timerAnim.Close(); - } - - -/** -@SYMTestCaseID GRAPHICS-WSERV-0135 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Multiple animations test - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Creates multiple animations for a window. - -@SYMTestExpectedResults The test doesn't perform any specific validations. -*/ -void CTAnimDll::MultipleAnimsL() - { - RTestAnim anim1(iAnimDll); - RTestAnim anim2(iAnimDll); - RTestAnim anim3(iAnimDll); - RTestAnim anim4(iAnimDll); - RTestAnim anim5(iAnimDll); - RTestAnim anim6(iAnimDll); - TPtrC8 des(NULL,0); - User::LeaveIfError(anim1.Construct(*iRedrawWin->BaseWin(),EAnimTypeTest3,des)); - CleanupClosePushL(anim1); - User::LeaveIfError(anim2.Construct(*iRedrawWin->BaseWin(),EAnimTypeTest3,des)); - CleanupClosePushL(anim2); - User::LeaveIfError(anim3.Construct(*iRedrawWin->BaseWin(),EAnimTypeTest3,des)); - CleanupClosePushL(anim3); - User::LeaveIfError(anim4.Construct(*iRedrawWin->BaseWin(),EAnimTypeTest3,des)); - CleanupClosePushL(anim4); - User::LeaveIfError(anim5.Construct(*iRedrawWin->BaseWin(),EAnimTypeTest3,des)); - CleanupClosePushL(anim5); - User::LeaveIfError(anim6.Construct(*iRedrawWin->BaseWin(),EAnimTypeTest3,des)); - anim6.Close(); - User::LeaveIfError(anim6.Construct(*iRedrawWin->BaseWin(),EAnimTypeTest3,des)); - anim6.Close(); - User::LeaveIfError(anim6.Construct(*iRedrawWin->BaseWin(),EAnimTypeTest3,des)); - CleanupStack::PopAndDestroy(&anim5); - anim6.Close(); - User::LeaveIfError(anim5.Construct(*iRedrawWin->BaseWin(),EAnimTypeTest3,des)); - CleanupClosePushL(anim5); - User::LeaveIfError(anim6.Construct(*iRedrawWin->BaseWin(),EAnimTypeTest3,des)); - CleanupStack::Pop(&anim5); - CleanupStack::PopAndDestroy(&anim4); - anim5.Close(); - anim6.Close(); - User::LeaveIfError(anim4.Construct(*iRedrawWin->BaseWin(),EAnimTypeTest3,des)); - CleanupStack::PopAndDestroy(&anim3); - anim4.Close(); - User::LeaveIfError(anim3.Construct(*iRedrawWin->BaseWin(),EAnimTypeTest3,des)); - CleanupStack::PopAndDestroy(&anim2); - anim3.Close(); - User::LeaveIfError(anim2.Construct(*iRedrawWin->BaseWin(),EAnimTypeTest3,des)); - CleanupStack::PopAndDestroy(&anim1); - anim2.Close(); - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-0136 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Click plugin DLL test - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Created two handles for a click plugin dll (RSoundPlugIn instances). - Plays with Load(), Unload() methods to verify that they affect - IsLoaded() call result. - Checks that CommandReply() for different opcodes - returns RSoundPlugIn::ESoundWrongPlugIn value. - Plays with SetPenClick(), SetKeyClick() to verify that they affect - PenClickEnabled() and KeyClickEnabled() call result. - - -@SYMTestExpectedResults The test checks that RSoundPlugIn's methods work properly - and that both handles behave identically. -*/ -void CTAnimDll::ClickPlugInL() - { - _LIT(KDllName,"CLICK"); - RWsSession ws; - User::LeaveIfError(ws.Connect()); - CleanupClosePushL(ws); - TBool retBool; - TInt retVal; - - // assign to the correct screen - CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws); - CleanupStack::PushL(screen); - User::LeaveIfError(screen->Construct(iTest->iScreenNumber)); - - RSoundPlugIn click1(ws); - RSoundPlugIn click2(TheClient->iWs); - User::LeaveIfError(click1.Construct()); - CleanupClosePushL(click1); - User::LeaveIfError(click2.Construct()); - CleanupClosePushL(click2); - TBool changeable1; - TBool changeable2; - TBool loaded=click1.IsLoaded(changeable1); - //test that either both are loaded or both are not loaded - TEST(!loaded==!click2.IsLoaded(changeable2)); - if (!loaded!=!click2.IsLoaded(changeable2)) - INFO_PRINTF3(_L("!loaded==!click2.IsLoaded(changeable2) - Expected: %d , Actual: %d"), !loaded, !click2.IsLoaded(changeable2)); - - //test that either both are changeable or both are not changeable - TEST(!changeable1==!changeable2); - if (!changeable1!=!changeable2) - INFO_PRINTF3(_L("!changeable1==!changeable2) - Expected: %d , Actual: %d"), !changeable1, !changeable2); - - if (loaded && changeable1) - { - // unload the first one - User::LeaveIfError(click1.Unload()); - // check that the second is not loaded and still changeable - retBool = !click2.IsLoaded(changeable2); - TEST(retBool); - if (!retBool) - INFO_PRINTF3(_L("!click2.IsLoaded(changeable2) return value - Expected: %d , Actual: %d"), ETrue, retBool); - - TEST(changeable2); - if (!changeable2) - INFO_PRINTF3(_L("changeable2 - Expected: %d , Actual: %d"), ETrue, changeable2); - - - // load the first one and check that the second became loaded and is changeable - User::LeaveIfError(click1.Load(KDllName)); - retBool = click2.IsLoaded(changeable2); - TEST(retBool); - if (!retBool) - INFO_PRINTF3(_L("click2.IsLoaded(changeable2) return value - Expected: %d , Actual: %d"), ETrue, retBool); - - TEST(changeable2); - if (!changeable2) - INFO_PRINTF3(_L("changeable2 - Expected: %d , Actual: %d"), ETrue, changeable2); - - // unload the second one - User::LeaveIfError(click2.Unload()); - // check that the first is not loaded and still changeable - retBool = !click1.IsLoaded(changeable1); - TEST(retBool); - if (!retBool) - INFO_PRINTF3(_L("!click1.IsLoaded(changeable1) return value - Expected: %d , Actual: %d"), ETrue, retBool); - - TEST(changeable1); - if (!changeable1) - INFO_PRINTF3(_L("changeable1 - Expected: %d , Actual: %d"), ETrue, changeable1); - - // load the second one and check that the first one became loaded and is changeable - User::LeaveIfError(click2.Load(KDllName)); - loaded=click1.IsLoaded(changeable1); - TEST(loaded); - if (!loaded) - INFO_PRINTF3(_L("loaded - Expected: %d , Actual: %d"), ETrue, loaded); - - TEST(changeable1); - if (!changeable1) - INFO_PRINTF3(_L("changeable1 - Expected: %d , Actual: %d"), ETrue, changeable1); - } - if (loaded) - { - TPtrC8 des(NULL,0); - retVal = click1.CommandReply(0,des); - TEST(RSoundPlugIn::ESoundWrongPlugIn==retVal); - if (RSoundPlugIn::ESoundWrongPlugIn!=retVal) - INFO_PRINTF3(_L("click1.CommandReply(0,des) return value - Expected: %d , Actual: %d"), RSoundPlugIn::ESoundWrongPlugIn, retVal); - - retVal = click1.CommandReply(1,des); - TEST(RSoundPlugIn::ESoundWrongPlugIn==retVal); - if (RSoundPlugIn::ESoundWrongPlugIn!=retVal) - INFO_PRINTF3(_L("click1.CommandReply(1,des) return value - Expected: %d , Actual: %d"), RSoundPlugIn::ESoundWrongPlugIn, retVal); - - retVal = click1.CommandReply(2,des); - TEST(RSoundPlugIn::ESoundWrongPlugIn==retVal); - if (RSoundPlugIn::ESoundWrongPlugIn!=retVal) - INFO_PRINTF3(_L("click1.CommandReply(2,des) return value - Expected: %d , Actual: %d"), RSoundPlugIn::ESoundWrongPlugIn, retVal); - - retVal = click1.CommandReply(-1,des); - TEST(RSoundPlugIn::ESoundWrongPlugIn==retVal); - if (RSoundPlugIn::ESoundWrongPlugIn!=retVal) - INFO_PRINTF3(_L("click1.CommandReply(-1,des) return value - Expected: %d , Actual: %d"), RSoundPlugIn::ESoundWrongPlugIn, retVal); - - retBool = click1.KeyClickEnabled(); - TEST(retBool); - if (!retBool) - INFO_PRINTF3(_L("click1.KeyClickEnabled() return value - Expected: %d , Actual: %d"), ETrue, retBool); - - retBool = click1.PenClickEnabled(); - TEST(retBool); - if (!retBool) - INFO_PRINTF3(_L("click1.PenClickEnabled() return value - Expected: %d , Actual: %d"), ETrue, retBool); - - click1.SetPenClick(EFalse); - retBool = click1.KeyClickEnabled(); - TEST(retBool); - if (!retBool) - INFO_PRINTF3(_L("click1.KeyClickEnabled() return value - Expected: %d , Actual: %d"), ETrue, retBool); - - retBool = !click1.PenClickEnabled(); - TEST(retBool); - if (!retBool) - INFO_PRINTF3(_L("!click1.PenClickEnabled() return value - Expected: %d , Actual: %d"), ETrue, retBool); - - click1.SetKeyClick(EFalse); - - retBool = !click1.KeyClickEnabled(); - TEST(retBool); - if (!retBool) - INFO_PRINTF3(_L("!click1.KeyClickEnabled() return value - Expected: %d , Actual: %d"), ETrue, retBool); - - retBool = !click1.PenClickEnabled(); - TEST(retBool); - if (!retBool) - INFO_PRINTF3(_L("!click1.PenClickEnabled() return value - Expected: %d , Actual: %d"), ETrue, retBool); - - click1.SetPenClick(ETrue); - retBool = !click1.KeyClickEnabled(); - TEST(retBool); - if (!retBool) - INFO_PRINTF3(_L("!click1.KeyClickEnabled() return value - Expected: %d , Actual: %d"), ETrue, retBool); - - retBool = click1.PenClickEnabled(); - TEST(retBool); - if (!retBool) - INFO_PRINTF3(_L("click1.PenClickEnabled() return value - Expected: %d , Actual: %d"), ETrue, retBool); - - click1.SetKeyClick(ETrue); - retBool = click1.KeyClickEnabled(); - TEST(retBool); - if (!retBool) - INFO_PRINTF3(_L("click1.KeyClickEnabled() return value - Expected: %d , Actual: %d"), ETrue, retBool); - - retBool = click1.PenClickEnabled(); - TEST(retBool); - if (!retBool) - INFO_PRINTF3(_L("click1.PenClickEnabled() return value - Expected: %d , Actual: %d"), ETrue, retBool); - - /*RLibrary lib; - TInt err=lib.Load(KDllName); - if (err==KErrNone) - { - TPtrC8 des(NULL,0); - TEST(lib.Type()[2].iUid==click1.CommandReply(0,des)); - lib.Close(); - }*/ - } - CleanupStack::PopAndDestroy(4,&ws); - } - -void CTAnimDll::TestWindowInfo(RTestAnim& aAnim,TInt aScreen,TInt aPos,TInt aId) - { - TPckgBuf params; - params().iScreen=aScreen; - params().iOrdinalPosition=aPos; - TPckgBuf winGpInfo; - TIpcArgs ipcArgs; - ipcArgs.Set(KIpcSlot,&winGpInfo); - TBool retBool = aAnim.CommandReply(EADllWindowGroupInfo,params,ipcArgs); - TEST(retBool); - if (!retBool) - INFO_PRINTF3(_L("aAnim.CommandReply(EADllWindowGroupInfo,params,ipcArgs) return value - Expected: %d , Actual: %d"), ETrue, retBool); - - MAnimGeneralFunctionsWindowExtension::TWindowGroupInfo& info=winGpInfo(); - TEST(info.iId==aId); - if (info.iId!=aId) - INFO_PRINTF3(_L("winGpInfo() return value - Expected: %d , Actual: %d"), aId, info.iId); - - TInt retVal = TheClient->iWs.GetWindowGroupOrdinalPriority(aId); - TEST(info.iOrdinalPriority==retVal); - if (info.iOrdinalPriority!=retVal) - INFO_PRINTF3(_L("TheClient->iWs.GetWindowGroupOrdinalPriority(aId) return value - Expected: %d , Actual: %d"), info.iOrdinalPriority, retVal); - - TBuf<64> windowGroupNameS; - TBuf<64> windowGroupNameA; - TheClient->iWs.GetWindowGroupNameFromIdentifier(aId,windowGroupNameS); - retVal = windowGroupNameS.Length(); - TEST(info.iNameLength==retVal); - if (info.iNameLength!=retVal) - INFO_PRINTF3(_L("windowGroupNameS.Length() return value - Expected: %d , Actual: %d"), info.iNameLength, retVal); - - if (info.iNameLength<64) - { - ipcArgs.Set(KIpcSlot,&windowGroupNameA); - retBool = aAnim.CommandReply(EADllWindowGroupName,params,ipcArgs); - TEST(retBool); - if (!retBool) - INFO_PRINTF3(_L("aAnim.CommandReply(EADllWindowGroupName,params,ipcArgs) return value - Expected: %d , Actual: %d"), ETrue, retBool); - - if (info.iNameLength>0) - { - TEST(windowGroupNameA==windowGroupNameS); - } - else - { - TEST(windowGroupNameA.Length()==0); - if (windowGroupNameA.Length()!=0) - INFO_PRINTF3(_L("iwindowGroupNameA.Length()==0 - Expected: %d, Actual: %d"), 0, windowGroupNameA.Length()); - } - - } - TEST(info.iParentId>=-1); - if (info.iParentId<-1) - INFO_PRINTF3(_L("info.iParentId>=-1 - Expected: %d or greater, Actual: %d"), -1, info.iParentId); - - } - -void CTAnimDll::TestEventHandlerRemovalL() - { - RTestAnim anim(iAnimDll); - User::LeaveIfError(anim.Construct(*iRedrawWin->BaseWin(),EAnimTypeEventHandler,KNullDesC8)); - anim.Close(); - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-0137 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Animation's extended window functions test - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions The test creates a window animation that has a couple of - commands that work with extended window functions encapsulated - into MAnimGeneralFunctionsWindowExtension class instance. - The test calls those commands to compare MAnimGeneralFunctionsWindowExtension's - methods' results with the results retuned by WSERV client classes. - MAnimGeneralFunctionsWindowExtension methods tested here: - Screens(), FocusScreens(), WindowGroups(), WindowGroupInfo(), - WindowGroupName() - -@SYMTestExpectedResults MAnimGeneralFunctionsWindowExtension methods must give the same results as - the corresponding WSERV client methods would. -*/ -void CTAnimDll::WinFunctionsL() - { - RTestAnim anim(iAnimDll); - User::LeaveIfError(anim.Construct(*iRedrawWin->BaseWin(),EAnimTypeWindowFunctions,KNullDesC8)); - CleanupClosePushL(anim); - TInt screens=anim.CommandReply(EADllScreen); - TEST(screens>0); - if (screens<=0) - INFO_PRINTF3(_L("anim.CommandReply(EADllScreen) return value - Expected: %d or greater, Actual: %d"), 1, screens); - - TInt focusScreen=anim.CommandReply(EADllFocusScreen); - TInt retVal = TheClient->iWs.GetFocusScreen(); - TEST(focusScreen==retVal && focusScreen<=screens); - if (focusScreen!=retVal || focusScreen>screens) - INFO_PRINTF4(_L("anim.CommandReply(EADllFocusScreen) return value - Expected: %d and less than or equal to %d, Actual: %d"), retVal, screens, focusScreen); - - TInt ii; - TPckgBuf screen; - CArrayPtrFlat* wins=new(ELeave) CArrayPtrFlat(screens); - CleanupStack::PushL(wins); - // create one window on each screen - for(ii=0;iiConstructL(); - wins->AppendL(win); - } - if (screens>1) - { - for (ii=screens-1;ii>=0;--ii) - { - TheClient->iWs.SetFocusScreen(ii); - retVal = anim.CommandReply(EADllFocusScreen); - TEST(retVal==ii); - if (retVal!=ii) - INFO_PRINTF3(_L("anim.CommandReply(EADllFocusScreen) return value - Expected: %d, Actual: %d"), ii, retVal); - } - for (ii=screens-1;ii>=0;--ii) - { - screen()=ii; - anim.CommandReply(EADllSetFocusScreen,screen); - retVal = anim.CommandReply(EADllFocusScreen); - TEST(retVal==ii); - if (retVal!=ii) - INFO_PRINTF3(_L("anim.CommandReply(EADllFocusScreen) return value - Expected: %d, Actual: %d"), ii, retVal); - } - } - TheClient->iWs.SetFocusScreen(focusScreen); - retVal = anim.CommandReply(EADllFocusScreen); - TEST(retVal==focusScreen); - if (retVal!=focusScreen) - INFO_PRINTF3(_L("anim.CommandReply(EADllFocusScreen) return value - Expected: %d, Actual: %d"), focusScreen, retVal); - - TInt winGroupsAll=0; - for(ii=0;iiiWs.NumWindowGroups(); - TEST(winGroupsAll==winGroupsS); - if (winGroupsAll!=winGroupsS) - INFO_PRINTF3(_L("TheClient->iWs.NumWindowGroups() return value - Expected: %d, Actual: %d"), winGroupsS, winGroupsAll); - - // the remaining test will use winGroupsA and performed on current focus screen only - screen()=iTest->iScreenNumber; - TInt winGroupsA=anim.CommandReply(EADllWindowGroups,screen); - CArrayFixFlat* windowList=new(ELeave) CArrayFixFlat(3); - CleanupStack::PushL(windowList); - // wserv implementation returns window groups from current focus screen, followed by the rest - TheClient->iWs.WindowGroupList(windowList); - // only interested in window group from current focus screen - for (ii=0;iiiScreenNumber,ii,(*windowList)[ii]); - TPckgBuf winGpInfo; - TIpcArgs ipcArgs; - TPckgBuf params; - params().iScreen=iTest->iScreenNumber; - params().iOrdinalPosition=winGroupsA; - ipcArgs.Set(KIpcSlot,&winGpInfo); - TBuf<64> windowGroupName; - TBool retBool = !anim.CommandReply(EADllWindowGroupInfo,params,ipcArgs); - TEST(retBool); - if (!retBool) - INFO_PRINTF3(_L("!anim.CommandReply(EADllWindowGroupInfo,params,ipcArgs) return value - Expected: %d, Actual: %d"), ETrue, retBool); - - ipcArgs.Set(KIpcSlot,&windowGroupName); - retBool = !anim.CommandReply(EADllWindowGroupName,params,ipcArgs); - TEST(retBool); - if (!retBool) - INFO_PRINTF3(_L("!anim.CommandReply(EADllWindowGroupName,params,ipcArgs) return value - Expected: %d, Actual: %d"), ETrue, retBool); - - /*params().iOrdinalPosition=-1; //Behaviour for negative positions not defined - but as writtin this code will pass - ipcArgs.Set(KIpcSlot,&winGpInfo); - TEST(anim.CommandReply(EADllWindowGroupInfo,params,ipcArgs)); - ipcArgs.Set(KIpcSlot,&windowGroupNameA); - TEST(anim.CommandReply(EADllWindowGroupName,params,ipcArgs));*/ - RWindowGroup group(TheClient->iWs); - User::LeaveIfError(group.Construct(ENullWsHandle)); - CleanupClosePushL(group); - _LIT(KGroupName,"Testxyz1234"); - group.SetName(KGroupName); - group.SetOrdinalPosition(0,TheClient->iWs.GetWindowGroupOrdinalPriority((*windowList)[0])+1); - TInt groupId=group.Identifier(); - TestWindowInfo(anim,iTest->iScreenNumber,0,groupId); - group.SetOrdinalPosition(0,TheClient->iWs.GetWindowGroupOrdinalPriority((*windowList)[winGroupsA-1])-1); - TestWindowInfo(anim,iTest->iScreenNumber,winGroupsA,groupId); - CleanupStack::PopAndDestroy(screens+4,&anim); -// Restore us back to the front - TheClient->iGroup->GroupWin()->SetOrdinalPosition(0); - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-0138 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Animation's extended window functions test 2 - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions The test creates a window animation that has a command - for setting window's ordinal position and priority. - The test creates 4 window groups with the same priority and - checks that they have correct ordinal positions after the creation. - After that the test plays with updating ordinal positions and - priorities of the window groups using the animation's command. - -@SYMTestExpectedResults The test checks that the command was executed with no errors - and affected ordinal positions of the window groups properly. -*/ -void CTAnimDll::WinFunctions2L() - { - RTestAnim anim(iAnimDll); - User::LeaveIfError(anim.Construct(*iRedrawWin->BaseWin(),EAnimTypeWindowFunctions,KNullDesC8)); - CleanupClosePushL(anim); - CArrayFixFlat* windowList=new(ELeave) CArrayFixFlat(3); - TheClient->iWs.WindowGroupList(windowList); - TInt priority=TheClient->iWs.GetWindowGroupOrdinalPriority((*windowList)[0])+2; - delete windowList; - RWindowGroup group1(TheClient->iWs); - User::LeaveIfError(group1.Construct(ENullWsHandle)); - CleanupClosePushL(group1); - group1.SetOrdinalPosition(0,priority); - RWindowGroup group2(TheClient->iWs); - User::LeaveIfError(group2.Construct(ENullWsHandle)); - CleanupClosePushL(group2); - group2.SetOrdinalPosition(0,priority); - RWindowGroup group3(TheClient->iWs); - User::LeaveIfError(group3.Construct(ENullWsHandle)); - CleanupClosePushL(group3); - group3.SetOrdinalPosition(0,priority); - RWindowGroup group4(TheClient->iWs); - User::LeaveIfError(group4.Construct(ENullWsHandle)); - CleanupClosePushL(group4); - group4.SetOrdinalPosition(0,priority); - - TInt retVal = group1.OrdinalPosition(); - TEST(retVal==3); - if (retVal!=3) - INFO_PRINTF3(_L("group1.OrdinalPosition() return value - Expected: %d, Actual: %d"), 3, retVal); - - retVal = group2.OrdinalPosition(); - TEST(retVal==2); - if (retVal!=2) - INFO_PRINTF3(_L("group2.OrdinalPosition() return value - Expected: %d, Actual: %d"), 2, retVal); - - retVal = group3.OrdinalPosition(); - TEST(retVal==1); - if (retVal!=1) - INFO_PRINTF3(_L("group3.OrdinalPosition() return value - Expected: %d, Actual: %d"), 1, retVal); - - retVal = group4.OrdinalPosition(); - TEST(retVal==0); - if (retVal!=0) - INFO_PRINTF3(_L("group4.OrdinalPosition() return value - Expected: %d, Actual: %d"), 0, retVal); - - TPckgBuf params; - params().iIdentifier=group4.Identifier(); - params().iOrdinalPriority=priority; - params().iOrdinalPosition=1; - retVal = anim.CommandReply(EADllSetOrdinalPosition,params); - TEST(retVal==KErrNone); - if (retVal!=KErrNone) - INFO_PRINTF3(_L("anim.CommandReply(EADllSetOrdinalPosition,params) return value - Expected: %d, Actual: %d"), KErrNone, retVal); - - retVal = group3.OrdinalPosition(); - TEST(retVal==0); - if (retVal!=0) - INFO_PRINTF3(_L("group3.OrdinalPosition() return value - Expected: %d, Actual: %d"), 0, retVal); - - retVal = group4.OrdinalPosition(); - TEST(retVal==1); - if (retVal!=1) - INFO_PRINTF3(_L("group4.OrdinalPosition() return value - Expected: %d, Actual: %d"), 1, retVal); - - params().iOrdinalPosition=2; - retVal = anim.CommandReply(EADllSetOrdinalPosition,params); - TEST(retVal==KErrNone); - if (retVal!=KErrNone) - INFO_PRINTF3(_L("anim.CommandReply(EADllSetOrdinalPosition,params) return value - Expected: %d, Actual: %d"), KErrNone, retVal); - - retVal = group2.OrdinalPosition(); - TEST(retVal==1); - if (retVal!=1) - INFO_PRINTF3(_L("group2.OrdinalPosition() return value - Expected: %d, Actual: %d"), 1, retVal); - - retVal = group4.OrdinalPosition(); - TEST(retVal==2); - if (retVal!=2) - INFO_PRINTF3(_L("group4.OrdinalPosition() return value - Expected: %d, Actual: %d"), 2, retVal); - - params().iOrdinalPosition=3; - retVal = anim.CommandReply(EADllSetOrdinalPosition,params); - TEST(retVal==KErrNone); - if (retVal!=KErrNone) - INFO_PRINTF3(_L("anim.CommandReply(EADllSetOrdinalPosition,params) return value - Expected: %d, Actual: %d"), KErrNone, retVal); - - retVal = group1.OrdinalPosition(); - TEST(retVal==2); - if (retVal!=2) - INFO_PRINTF3(_L("group1.OrdinalPosition() return value - Expected: %d, Actual: %d"), 2, retVal); - - retVal = group2.OrdinalPosition(); - TEST(retVal==1); - if (retVal!=1) - INFO_PRINTF3(_L("group2.OrdinalPosition() return value - Expected: %d, Actual: %d"), 1, retVal); - - retVal = group3.OrdinalPosition(); - TEST(retVal==0); - if (retVal!=0) - INFO_PRINTF3(_L("group3.OrdinalPosition() return value - Expected: %d, Actual: %d"), 0, retVal); - - retVal = group4.OrdinalPosition(); - TEST(retVal==3); - if (retVal!=3) - INFO_PRINTF3(_L("group4.OrdinalPosition() return value - Expected: %d, Actual: %d"), 3, retVal); - - params().iOrdinalPriority=priority+1; - params().iOrdinalPosition=3; - retVal = anim.CommandReply(EADllSetOrdinalPosition,params); - TEST(retVal==KErrNone); - if (retVal!=KErrNone) - INFO_PRINTF3(_L("anim.CommandReply(EADllSetOrdinalPosition,params) return value - Expected: %d, Actual: %d"), KErrNone, retVal); - - retVal = group4.OrdinalPosition(); - TEST(retVal==0); - if (retVal!=0) - INFO_PRINTF3(_L("group4.OrdinalPosition() return value - Expected: %d, Actual: %d"), 0, retVal); - - params().iOrdinalPriority=priority; - params().iOrdinalPosition=-2; - retVal = anim.CommandReply(EADllSetOrdinalPosition,params); - TEST(retVal==KErrNone); - if (retVal!=KErrNone) - INFO_PRINTF3(_L("anim.CommandReply(EADllSetOrdinalPosition,params) return value - Expected: %d, Actual: %d"), KErrNone, retVal); - - retVal = group4.OrdinalPosition(); - TEST(retVal==3); - if (retVal!=3) - INFO_PRINTF3(_L("group4.OrdinalPosition() return value - Expected: %d, Actual: %d"), 3, retVal); - - params().iOrdinalPosition=0; - retVal = anim.CommandReply(EADllSetOrdinalPosition,params); - TEST(retVal==KErrNone); - if (retVal!=KErrNone) - INFO_PRINTF3(_L("anim.CommandReply(EADllSetOrdinalPosition,params) return value - Expected: %d, Actual: %d"), KErrNone, retVal); - - retVal = group1.OrdinalPosition(); - TEST(retVal==3); - if (retVal!=3) - INFO_PRINTF3(_L("group1.OrdinalPosition() return value - Expected: %d, Actual: %d"), 3, retVal); - - retVal = group2.OrdinalPosition(); - TEST(retVal==2); - if (retVal!=2) - INFO_PRINTF3(_L("group2.OrdinalPosition() return value - Expected: %d, Actual: %d"), 2, retVal); - - retVal = group3.OrdinalPosition(); - TEST(retVal==1); - if (retVal!=1) - INFO_PRINTF3(_L("group3.OrdinalPosition() return value - Expected: %d, Actual: %d"), 1, retVal); - - retVal = group4.OrdinalPosition(); - TEST(retVal==0); - if (retVal!=0) - INFO_PRINTF3(_L("group4.OrdinalPosition() return value - Expected: %d, Actual: %d"), 0, retVal); - - params().iOrdinalPriority=priority-1; - params().iOrdinalPosition=2; - retVal = anim.CommandReply(EADllSetOrdinalPosition,params); - TEST(retVal==KErrNone); - if (retVal!=KErrNone) - INFO_PRINTF3(_L("anim.CommandReply(EADllSetOrdinalPosition,params) return value - Expected: %d, Actual: %d"), KErrNone, retVal); - - retVal = group1.OrdinalPosition(); - TEST(retVal==2); - if (retVal!=2) - INFO_PRINTF3(_L("group1.OrdinalPosition() return value - Expected: %d, Actual: %d"), 2, retVal); - - retVal = group2.OrdinalPosition(); - TEST(retVal==1); - if (retVal!=1) - INFO_PRINTF3(_L("group2.OrdinalPosition() return value - Expected: %d, Actual: %d"), 1, retVal); - - retVal = group3.OrdinalPosition(); - TEST(retVal==0); - if (retVal!=0) - INFO_PRINTF3(_L("group3.OrdinalPosition() return value - Expected: %d, Actual: %d"), 0, retVal); - - retVal = group4.OrdinalPosition(); - TEST(retVal==0); - if (retVal!=0) - INFO_PRINTF3(_L("group4.OrdinalPosition() return value - Expected: %d, Actual: %d"), 0, retVal); - - - params().iOrdinalPriority=priority; - params().iOrdinalPosition=0; - retVal = anim.CommandReply(EADllSetOrdinalPosition,params); - TEST(retVal==KErrNone); - if (retVal!=KErrNone) - INFO_PRINTF3(_L("anim.CommandReply(EADllSetOrdinalPosition,params) return value - Expected: %d, Actual: %d"), KErrNone, retVal); - - retVal = group1.OrdinalPosition(); - TEST(retVal==3); - if (retVal!=3) - INFO_PRINTF3(_L("group1.OrdinalPosition() return value - Expected: %d, Actual: %d"), 3, retVal); - - retVal = group2.OrdinalPosition(); - TEST(retVal==2); - if (retVal!=2) - INFO_PRINTF3(_L("group2.OrdinalPosition() return value - Expected: %d, Actual: %d"), 2, retVal); - - retVal = group3.OrdinalPosition(); - TEST(retVal==1); - if (retVal!=1) - INFO_PRINTF3(_L("group3.OrdinalPosition() return value - Expected: %d, Actual: %d"), 1, retVal); - - retVal = group4.OrdinalPosition(); - TEST(retVal==0); - if (retVal!=0) - INFO_PRINTF3(_L("group4.OrdinalPosition() return value - Expected: %d, Actual: %d"), 0, retVal); - - CleanupStack::PopAndDestroy(5,&anim); - /*TInt pos1=group1.OrdinalPosition(); - TInt pos2=group2.OrdinalPosition(); - TInt pos3=group3.OrdinalPosition(); - TInt pos4=group4.OrdinalPosition();*/ - } - - -/** -@SYMTestCaseID GRAPHICS-WSERV-0139 - -@SYMDEF DEF081259, DEF122220 - -@SYMTestCaseDesc Animation's notifications test - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions The test works with two screens. An animation is created that keeps - track on all notifications about EDirectScreenAccess, EHeartbeatTimer, - EScreenDeviceChange events. - The test generates those events by performing operations on direct - screen access and simulating TRawEvent::EInactive and TRawEvent::EAactive - events. - -@SYMTestExpectedResults The test checks that the animation didn't miss any of EDirectScreenAccess - or EHeartbeatTimer notifications. (The test doesn't check EScreenDeviceChange - notifications however). - The test also makes sure that the animation didn't animate - during inactive state. - For DEF12220, the test will crash when a untidied notifier from a previous RTestAnim object - is accessed if the fix is not present. If the fix is present, the test should not crash. -*/ -void CTAnimDll::TestNotificationsL() - { - RTestAnim anim(iAnimDll); - User::LeaveIfError(anim.Construct(*iRedrawWin->BaseWin(),EAnimTypeNotificationTest,KNullDesC8)); - CleanupClosePushL(anim); - - TPckgBuf screenNum; - - // initial state - test that we have no DSA on either screen - screenNum() = 0; - TInt dsa=anim.CommandReply(EADllQueryDSA, screenNum); - TEST(!dsa); - if (dsa) - INFO_PRINTF3(_L("anim.CommandReply(EADllQueryDSA, screenNum) return value - Expected: %d, Actual: %d"), 0, dsa); - - screenNum() = 1; - dsa=anim.CommandReply(EADllQueryDSA, screenNum); - TEST(!dsa); - if (dsa) - INFO_PRINTF3(_L("anim.CommandReply(EADllQueryDSA, screenNum) return value - Expected: %d, Actual: %d"), 0, dsa); - - // create first DSA, but don't start it - test that we have no DSA on either screen - CScrollText* dsa1 = CScrollText::NewL(iTest->iScreenNumber,1,*TheClient->iGroup,5,EFalse); - CleanupStack::PushL(dsa1); - screenNum() = 0; - dsa=anim.CommandReply(EADllQueryDSA, screenNum); - TEST(!dsa); - if (dsa) - INFO_PRINTF3(_L("anim.CommandReply(EADllQueryDSA, screenNum) return value - Expected: %d, Actual: %d"), 0, dsa); - - screenNum() = 1; - dsa=anim.CommandReply(EADllQueryDSA, screenNum); - TEST(!dsa); - if (dsa) - INFO_PRINTF3(_L("anim.CommandReply(EADllQueryDSA, screenNum) return value - Expected: %d, Actual: %d"), 0, dsa); - - // start first DSA - test that we have DSA on this screen but not other screen - dsa1->StartL(); - screenNum() = 0; - dsa=anim.CommandReply(EADllQueryDSA, screenNum); - TInt retVal = (screenNum() == iTest->iScreenNumber); - TEST(dsa == retVal); - if (dsa != retVal) - INFO_PRINTF3(_L("dsa == (screenNum() == iTest->iScreenNumber) - Expected: %d, Actual: %d"), retVal, dsa); - - screenNum() = 1; - dsa=anim.CommandReply(EADllQueryDSA, screenNum); - retVal = (screenNum() == iTest->iScreenNumber); - TEST(dsa == retVal); - if (dsa != retVal) - INFO_PRINTF3(_L("dsa == (screenNum() == iTest->iScreenNumber) - Expected: %d, Actual: %d"), retVal, dsa); - - // start second DSA - CScrollText* dsa2 = CScrollText::NewL(iTest->iScreenNumber,2,*TheClient->iGroup,5,EFalse); - CleanupStack::PushL(dsa2); - dsa2->StartL(); - screenNum() = 0; - dsa=anim.CommandReply(EADllQueryDSA, screenNum); - retVal = (screenNum() == iTest->iScreenNumber); - TEST(dsa == retVal); - if (dsa != retVal) - INFO_PRINTF3(_L("dsa == (screenNum() == iTest->iScreenNumber) - Expected: %d, Actual: %d"), retVal, dsa); - - screenNum() = 1; - dsa=anim.CommandReply(EADllQueryDSA, screenNum); - retVal = (screenNum() == iTest->iScreenNumber); - TEST(dsa == retVal); - if (dsa != retVal) - INFO_PRINTF3(_L("dsa == (screenNum() == iTest->iScreenNumber) - Expected: %d, Actual: %d"), retVal, dsa); - - // stop second DSA - dsa2->Stop(); - CleanupStack::PopAndDestroy(dsa2); - screenNum() = 0; - dsa=anim.CommandReply(EADllQueryDSA, screenNum); - retVal = (screenNum() == iTest->iScreenNumber); - TEST(dsa == retVal); - if (dsa != retVal) - INFO_PRINTF3(_L("dsa == (screenNum() == iTest->iScreenNumber) - Expected: %d, Actual: %d"), retVal, dsa); - - screenNum() = 1; - dsa=anim.CommandReply(EADllQueryDSA, screenNum); - retVal = (screenNum() == iTest->iScreenNumber); - TEST(dsa == retVal); - if (dsa != retVal) - INFO_PRINTF3(_L("dsa == (screenNum() == iTest->iScreenNumber) - Expected: %d, Actual: %d"), retVal, dsa); - - // stop first DSA - dsa1->Stop(); - CleanupStack::PopAndDestroy(dsa1); - screenNum() = 0; - dsa=anim.CommandReply(EADllQueryDSA, screenNum); - TEST(!dsa); - if (dsa) - INFO_PRINTF3(_L("anim.CommandReply(EADllQueryDSA, screenNum) return value - Expected: %d, Actual: %d"), 0, dsa); - - screenNum() = 1; - dsa=anim.CommandReply(EADllQueryDSA, screenNum); - TEST(!dsa); - if (dsa) - INFO_PRINTF3(_L("anim.CommandReply(EADllQueryDSA, screenNum) return value - Expected: %d, Actual: %d"), 0, dsa); - - // TEST heartbeat timer start\stop notifications - no longer relevant - has been removed - - CleanupStack::PopAndDestroy(&anim); - - // Create second RTestAnim for DEF12220 test - RTestAnim anim2(iAnimDll); - User::LeaveIfError(anim2.Construct(*iRedrawWin->BaseWin(),EAnimTypeNotificationTest,KNullDesC8)); - CleanupClosePushL(anim2); - - // Create third dsa - CScrollText* dsa3 = CScrollText::NewL(iTest->iScreenNumber,1,*TheClient->iGroup,5,EFalse); - CleanupStack::PushL(dsa3); - // If the fix for DEF12220 is not present, starting dsa3 will cause a crash. - dsa3->StartL(); - dsa3->Stop(); - CleanupStack::PopAndDestroy(dsa3); - CleanupStack::PopAndDestroy(&anim2); - } - -/** - A minimal dsa call to a window with a child window, for running coverage on - ClipWindows member funcion. - -@SYMTestCaseID GRAPHICS-WSERV-0410 - -@SYMPREQ PREQ1841 - -@SYMTestExpectedResults Nothing visible, the CWsClientWindow::ClipWindows -should be partially covered. - */ -void CTAnimDll::TestCoverageL() - { - // create first DSA, but don't start it - test that we have no DSA on either screen - CWindowWithChild* dsa1 = CWindowWithChild::NewL(iTest->iScreenNumber, *TheClient->iGroup, EFalse); - CleanupStack::PushL(dsa1); - - // start first DSA - test that we have DSA on this screen but not other screen - dsa1->StartL(); - dsa1->PerformCoverageCalls(); - dsa1->Stop(); - - // cover another trivial case for a non-visible window - RWindow* cwin = dsa1->ChildWindow(); - - cwin->SetTransparencyAlphaChannel(); - dsa1->ContinueL(); - - //ClipWindows with visible and invisible branches - cwin->SetVisible(EFalse); - - //cover CWsWindow::StatusDump (visible and invisible branch) - TheClient->iWs.LogCommand(RWsSession::ELoggingStatusDump); - - dsa1->Stop(); - dsa1->StartL(); - cwin->SetVisible(ETrue); - dsa1->Stop(); - - CleanupStack::PopAndDestroy(dsa1); - } - -/** - Executes a Panic coverage test for a given test-number. - Most of the first lines copied from DoPanicTest. - CWsWindow is tested through CommandL (case 0-3) and other API funcs - */ -LOCAL_C TInt DoPanicTestCoverage(TInt aTestNum, TAny *aScreenNumber) - { - RWsSession ws; - User::LeaveIfError(ws.Connect()); - - // assign to the correct screen - CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws); - User::LeaveIfError(screen->Construct(reinterpret_cast(aScreenNumber))); - - RWindowGroup group(ws); - User::LeaveIfError(group.Construct(333)); - group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close - RAnimDll animDll=RAnimDll(ws); - User::LeaveIfError(animDll.Load(KAnimDLLName)); - - RWindow window(ws); - User::LeaveIfError(window.Construct(group,123)); - window.SetSize(TSize(10,10)); - window.Activate(); - window.BeginRedraw(); - window.EndRedraw(); - - switch (aTestNum) - { - case 0: //non translucent window - //EWsWinOpSetTransparentRegion -> EWservPanicTransparencyObjNotCreated - { - RRegion r; - window.SetTransparentRegion(r); - break; - } - case 1: - //EWsWinOpSetTransparencyPolicy -> EWservPanicTransparencyObjNotCreated - window.SetTransparencyPolicy(ETransparencyDefault); - break; - case 2: - // -> EWservPanicWindowActive - window.Activate(); - break; - case 3: - // -> EWservPanicCornerParams - window.SetCornerType(EWindowCornerSquare, ECornerTypeMask); - break; - case 4: - // -> EWservPanicCornerParams - window.SetCornerType(ECornerTypeMask, 0); - break; - default: - return EWsExitReasonFinished; - } - ws.Flush(); - - return(EWsExitReasonBad); // Should never get here, but it's baaddd if it does - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-0411 - -@SYMPREQ PREQ1841 - -@SYMTestCaseDesc Does functional coverage for code that Panics - -*/ -void CTAnimDll::TestPanicCoverageL() - { - TClientPanic expectedPanicCode[] = - { - EWservPanicTransparencyObjNotCreated, //0 - EWservPanicTransparencyObjNotCreated, //1 - EWservPanicWindowActive, //2 - EWservPanicCornerParams, //3 - EWservPanicCornerParams, //4 - }; - for (TInt i=0; iTestWsPanicL( - DoPanicTestCoverage, //aFunction - expectedPanicCode[i], //aExitReason - i, //aInt - (TAny*)iTest->iScreenNumber, //aPtr - NULL)); //&finishTests //aTestFinished - iTest->CloseAllPanicWindows(); - } - } - - -/** -@SYMTestCaseID GRAPHICS-CODEBASE-WSERV-0056-0001 - -@SYMPREQ PGM027 - -@SYMTestCaseDesc Tests RAnimDll::Load (by passing invalid file name) - -@SYMTestPriority 1 - -@SYMTestStatus Implemented - -@SYMTestActions Call RAnimDll::Load() by passing invalid file name\n - -@SYMTestExpectedResults Should return with appropiate error message. KErrNotFound - */ -void CTAnimDll::TestLoadApiL() - { - RAnimDll* animDll=new(ELeave) RAnimDll(TheClient->iWs); - CleanupStack::PushL(animDll); - TInt ret=0; - _LIT(KAnimFile,"Nothing.dll"); - _LIT(KEmpty,""); - ret=animDll->Load(KAnimFile); - TEST(ret==KErrNotFound); - ret=animDll->Load(KEmpty); - TEST(ret==KErrNotFound); - CleanupStack::PopAndDestroy(animDll); - } - -TInt CTAnimDll::CheckError(TInt aError,TInt aExpected) - { - if (aError!=0) - { - if (aError>0) - { - _LIT(KLog,"The event at position %d did not match, total number of events=%d"); - LOG_MESSAGE3(KLog,aError,aExpected); - } - else - { - _LIT(KLog,"Only recieved %d events, expecting %d events"); - LOG_MESSAGE3(KLog,-aError,aExpected); - } - return EFalse; - } - return ETrue; - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-0448 - -@SYMCR CR1164 - -@SYMTestCaseDesc Test events get to Anims at a higher priorty than commands - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Create a 2nd thread that sends events via kernal, send also commands from client to an Anim - -@SYMTestExpectedResults Check that events intersperse commands from client -*/ -void CTAnimDll::KeyClickPriorityL() - { - _LIT(KFailedAdd,"Device Driver Failed to Add an Event, error=%d"); - REventAnim* anim=REventAnim::NewL(iTestWin->BaseWin(),&iAnimDll); - TPckgBuf events; - TInt err=anim->CommandReply(EADllLoadDeviceDriver); - if (err!=KErrNone) - { - _LIT(KLog,"Failed to load Device Driver for sending Events"); - TEST(EFalse); - LOG_MESSAGE(KLog); - } - TInt error; - TInt ii; - for (ii=1;ii<5;++ii) - { - events()=ii; - error=anim->CommandReply(EADllSendEvent,events); - if (error!=KErrNone) - LOG_MESSAGE2(KFailedAdd,error); - anim->Command(EADllAfterEvent); - TheClient->Flush(); - error=anim->TestFail(ii); - TEST(CheckError(error,ii)); - } - const TInt iterations=15; - const TInt eventsPerIteration=2; - const TInt totalEvents=iterations*eventsPerIteration; - events()=eventsPerIteration; - for (ii=iterations;ii>0;--ii) - { - error=anim->CommandReply(EADllSendEvent,events); - if (error!=KErrNone) - LOG_MESSAGE2(KFailedAdd,error); - anim->Command(EADllAfterEvent); - } - TheClient->Flush(); - error=anim->TestFail(totalEvents); - TEST(CheckError(error,totalEvents)); - anim->CommandReply(EADllUnloadDeviceDriver); - delete anim; - } - -/** -@SYMDEF INC117828 - -@SYMTestCaseDesc Tests Window Rect returned by CWsAnim::Parameters - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions This test creates a new window which overlaps the screen edge - and creates an animation on this window. An additional - CommandReplyL() option has been added to the AnimDLL to compare - the expected value of this rect with the actual value. - - -@SYMTestExpectedResults The result of the EADllTestParameterRect CommandReplyL call will equal ETrue - if the passed Rect matches, EFalse otherwise. -*/ -void CTAnimDll::ParameterValueTestL() - { - //Window Location & Dimension - TPoint winOrigin(-1,15); - TSize winSize(250,65); - - //Create a new window to perform the test; window needs to overlap the left edge of the screen. - CAnimWindow* paramTestWin = new(ELeave) CAnimWindow(EFalse, CAnimWindow::ERedraw); - CleanupStack::PushL(paramTestWin); - paramTestWin->ConstructL(winOrigin, winSize); - - RTestAnim anim = RTestAnim(iAnimDll); - - TPckgBuf rectPckg; - TRect winRect(winOrigin, winSize); - rectPckg() = winRect; - - anim.Construct(*(paramTestWin->BaseWin()), EAnimTypeTest3, rectPckg); - anim.Command(EADllStartAnimate, rectPckg); - - TPckgBuf boolPckg; - boolPckg() = ETrue; - anim.Command(EADllSetVisible, boolPckg); - - TEST(anim.CommandReply(EADllParameterRectValueTest, rectPckg)); - - boolPckg() = EFalse; - anim.Command(EADllSetVisible, boolPckg); - anim.Command(EADllCancelAnimate); - anim.Close(); - CleanupStack::PopAndDestroy(paramTestWin); - } - -/** -@SYMDEF DEF122176 - -@SYMTestCaseDesc Test the operation of SetInterval with both negative and positive intervals - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions This test uses the test anim CAutoAnim3 in mode 3 which alternates - between drawing a large and a small ellipse at each interval. - The large ellipse is drawn first. - Note that the anims are redrawn at the rate of 2 intervals per second, so - setting an interval of 2 will mean that the anim is redrawn every second. - Step 1: The interval is set to be -2 and the test then waits for 0.9 - seconds (to make sure one interval has passed) then checks that - only the large ellipse has been drawn. - Step 2: The interval is set to be 2 (redraw every second) and the test then - waits for 1.2 seconds (to make sure two intervals have passed) and - checks that the small ellipse has been drawn. - -@SYMTestExpectedResults - After Step 1 a large ellipse will be drawn on both windows. - After Step 1 a small ellipse will be drawn on both windows. - -*/ -void CTAnimDll::TestSetIntervalL() - { - RWsSession ws; - User::LeaveIfError(ws.Connect()); - - // draws a little circle on the base window using window graphics and using window animation on the test window. - RTestAnim drawAnim=RTestAnim(iAnimDll); - - _LIT(KLog1,"SetInterval Test"); - LOG_MESSAGE(KLog1); - TRect rect(10,10,110,110); - CAnimWindow::SetEllipseDrawMode(CGraphicsContext::EDrawModePEN); - iTestWin->Invalidate(); - iTestWin->SetRect(rect); - iBaseWin->Invalidate(); - iBaseWin->SetRect(rect); - TPckgBuf rectPckg; - rectPckg()=rect; - User::LeaveIfError(drawAnim.Construct(*iTestWin->BaseWin(),EAnimTypeTest3,rectPckg)); - - TPckgBuf intPckg; - intPckg() = 3; // mode 3 for this anim flips between drawing a large and a small ellipse - drawAnim.Command(EADllSetMode, intPckg); - - intPckg() = MAnimGeneralFunctions::ESyncNone; - drawAnim.CommandReply(EADllDoSetSync, intPckg); - - // Set an interval of -2 then wait 0.9 seconds, after which only the large ellipse should be visible - intPckg() = -2; - drawAnim.CommandReply(EADllSetInterval, intPckg); - // Draw the large ellipse on the base window to match what the anim should be drawing - iBaseWin->SetRect(rect); - iBaseWin->DoDraw(); - ws.Finish(); - // Check Step 1 completed successfully - RedrawAndCheckWindows(); - - // Set an interval of 2 and wait 0.9 seconds, after which the small ellipse should be visible - intPckg() = 2; - drawAnim.CommandReply(EADllSetInterval, intPckg); - // Draw the small ellipse on the base window to match what the anim should be drawing - iBaseWin->SetRect(TRect(40,40,80,80)); - iBaseWin->DoDraw(); - ws.Finish(); - // Check Step 2 completed successfully - RedrawAndCheckWindows(); - - // clean up - drawAnim.Close(); - ws.Close(); - } - -void CTAnimDll::RunTestCaseL(TInt /*aCurTestCase*/) - { - _LIT(KTest0,"RemoteBuffer"); - _LIT(KTest1,"ExtraCopyTest"); - _LIT(KTest2,"Misc"); - _LIT(KTest3,"SyncMode1"); - _LIT(KTest4,"Anim Dll Panics"); - _LIT(KTest5,"Drawing test"); - _LIT(KTest6,"Shadow drawing test"); - _LIT(KTest7,"General drawing test"); - _LIT(KTest8,"Destroy window test"); - _LIT(KTest9,"Sprite Anim test"); - _LIT(KTest10,"Free Timer test"); - _LIT(KTest11,"Disable Timer test"); - _LIT(KTest12,"Multiple Anims"); - _LIT(KTest13,"ReLoad Click PlugIn"); - _LIT(KTest14,"Window Functions"); - _LIT(KTest15,"Window Functions 2"); - _LIT(KTest16,"Notifications"); - _LIT(KTest17,"Event Handler removal"); - _LIT(KTest18,"Anim dll - Load Api Negative Test"); - _LIT(KTest19,"Key Click Priority Test"); - _LIT(KTest20,"CWsAnim::Parameters() WindowRect Value Test"); - _LIT(KTest21,"SetInterval test"); - _LIT(KTest22,"Client Window Coverage"); - _LIT(KTest23,"Client Window Panic Coverage"); - ((CTAnimDllStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); - -// if (iTest->iState==0) iTest->iState=22; //Use this line to start running tests from a particular test - switch(++iTest->iState) - { - case 1: - ((CTAnimDllStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0127")); - iTest->LogSubTest(KTest0); - RemoteBuffer(); - break; - case 2: - ((CTAnimDllStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0128")); - iTest->LogSubTest(KTest1); - ExtraCopyTest(); - break; - case 3: - ((CTAnimDllStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0126")); - iTest->LogSubTest(KTest2); - Misc(); - break; - case 4: -/** -@SYMTestCaseID GRAPHICS-WSERV-0503 -*/ - ((CTAnimDllStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0503")); - iTest->LogSubTest(KTest3); -// Disabled temporarily (process isolation/ RThread::RequestComplete issue) to allow WSERV test to continue - break; - case 5: - ((CTAnimDllStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0125")); - iTest->LogSubTest(KTest4); - TestPanicsL(); - if (iTest->iScreenNumber == 1) - iTest->CloseAllPanicWindows(); - break; - case 6: - ((CTAnimDllStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0129")); - iTest->LogSubTest(KTest5); - DrawingTestL(); - break; - case 7: -/** -@SYMTestCaseID GRAPHICS-WSERV-0504 -*/ - ((CTAnimDllStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0504")); - iTest->LogSubTest(KTest6); -// Disabled temporarily (process isolation/ RThread::RequestComplete issue) to allow WSERV test to continue - break; - case 8: - ((CTAnimDllStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0130")); - iTest->LogSubTest(KTest7); - GeneralDrawingTestL(); - break; - case 9: - ((CTAnimDllStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0131")); - iTest->LogSubTest(KTest8); - DestroyWindowTestL(); - break; - case 10: - ((CTAnimDllStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0132")); - iTest->LogSubTest(KTest9); - SpriteAnimL(); - break; - case 11: - ((CTAnimDllStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0133")); - iTest->LogSubTest(KTest10); - FreeTimerL(); - break; - case 12: - ((CTAnimDllStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0134")); - iTest->LogSubTest(KTest11); - DisableTimerL(); - break; - case 13: - ((CTAnimDllStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0135")); - iTest->LogSubTest(KTest12); - MultipleAnimsL(); - break; - case 14: - ((CTAnimDllStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0136")); - iTest->LogSubTest(KTest13); - ClickPlugInL(); - break; - case 15: - ((CTAnimDllStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0137")); - iTest->LogSubTest(KTest14); - WinFunctionsL(); - break; - case 16: - ((CTAnimDllStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0138")); - iTest->LogSubTest(KTest15); - WinFunctions2L(); - break; - case 17: - ((CTAnimDllStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0139")); - iTest->LogSubTest(KTest16); - TestNotificationsL(); - break; - case 18: - ((CTAnimDllStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0137")); - iTest->LogSubTest(KTest17); - TestEventHandlerRemovalL(); - break; - case 19: - ((CTAnimDllStep*)iStep)->SetTestStepID(_L("GRAPHICS-CODEBASE-WSERV-0056-0001")); - iTest->LogSubTest(KTest18); - TestLoadApiL(); - break; - case 20: - ((CTAnimDllStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0448")); - iTest->LogSubTest(KTest19); - KeyClickPriorityL(); - break; - case 21: - /** -@SYMTestCaseID GRAPHICS-WSERV-0505 -*/ - ((CTAnimDllStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0505")); - iTest->LogSubTest(KTest20); - ParameterValueTestL(); - break; - case 22: -/** -@SYMTestCaseID GRAPHICS-WSERV-0506 -*/ - ((CTAnimDllStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0506")); - iTest->LogSubTest(KTest21); - TestSetIntervalL(); - case 23: - ((CTAnimDllStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0410")); - iTest->LogSubTest(KTest22); - TestCoverageL(); - break; - case 24: - ((CTAnimDllStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0411")); - iTest->LogSubTest(KTest23); - TestPanicCoverageL(); - default: - ((CTAnimDllStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - ((CTAnimDllStep*)iStep)->CloseTMSGraphicsStep(); - TestComplete(); - } - User::Check(); - ((CTAnimDllStep*)iStep)->RecordTestResultL(); - } - -// - -CAnimRedrawWindow::CAnimRedrawWindow(CAnimWindow *aAnimWindow, TBool aIsBase) : CTWin(), - iAnimWindow(aAnimWindow), - iIsBase(aIsBase) - { - } - -CAnimRedrawWindow::~CAnimRedrawWindow() - { - } - -void CAnimRedrawWindow::Draw() - { - CAnimWindow::Draw(Gc(),Size(),iIsBase,iAnimWindow->iRect,EFalse); - } - -// - -CAnimWindow::CAnimWindow(TBool aIsBase, TWinType aWinType) : iWinType(aWinType), iIsBase(aIsBase) - { - } - - -CAnimWindow::~CAnimWindow() - { - delete iCtWin; - } - -void CAnimWindow::ConstructL(const TPoint &aPos, const TSize &aSize) - { - switch(iWinType) - { - case ERedraw: - iCtWin=new(ELeave) CAnimRedrawWindow(this, iIsBase); - break; - case EBlank: - iCtWin=new(ELeave) CTBlankWindow(); - break; - case EBackedUp: - iCtWin=new(ELeave) CTBackedUpWin(EGray4); - break; - } - iCtWin->SetUpL(aPos, aSize, TheClient->iGroup, *TheClient->iGc); - if (iWinType==ERedraw) - { - static_cast(iCtWin)->Win()->EnableRedrawStore(EFalse); - } - } - -void CAnimWindow::SetEllipseDrawMode(CGraphicsContext::TDrawMode aEllipseDrawMode) - { - iEllipseDrawMode=aEllipseDrawMode; - } - -void CAnimWindow::SetRect(const TRect &aRect) - { - iRect=aRect; - } - -void CAnimWindow::DrawEllipse(CBitmapContext *aGc, const TRect &aRect) - { - aGc->SetDrawMode(iEllipseDrawMode); - aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - aGc->SetBrushColor(TRgb(85,85,85)); - aGc->SetPenColor(TRgb(170,170,170)); - aGc->DrawEllipse(aRect); - } - -void CAnimWindow::Draw(CBitmapContext *aGc, const TSize &aSize, TBool aIsBase, const TRect &aRect, TBool aBlankIt) - { - aGc->SetBrushColor(TRgb::Gray4(2)); - aGc->Clear(); - if (!aBlankIt) - for(TInt i=0;iDrawLine(TPoint(i,0),TPoint(i+10,aSize.iHeight)); - if (aIsBase) - DrawEllipse(aGc, aRect); - } - -void CAnimWindow::DoDraw(TBool aBlankIt) - { - __ASSERT_ALWAYS(iWinType!=EBlank,AutoPanic(EAutoPanicWindowType)); - iCtWin->Gc()->Activate(*(RDrawableWindow *)BaseWin()); - Draw(iCtWin->Gc(),Size(),iIsBase,iRect,aBlankIt); - iCtWin->Gc()->Deactivate(); - } - -void CAnimWindow::DoDrawEllipse() - { - __ASSERT_ALWAYS(iWinType!=EBlank,AutoPanic(EAutoPanicWindowType)); - iCtWin->Gc()->Activate(*(RDrawableWindow *)BaseWin()); - DrawEllipse(iCtWin->Gc(),iRect); - iCtWin->Gc()->Deactivate(); - } - -void CAnimWindow::DoDrawCoverage() - { - __ASSERT_ALWAYS(iWinType!=EBlank,AutoPanic(EAutoPanicWindowType)); - CWindowGc *gc = iCtWin->Gc(); - gc->Activate(*(RDrawableWindow *)BaseWin()); - - gc->SetClippingRect(iRect); - gc->Clear(); - gc->Clear(iRect); - - gc->SetDrawMode(CGraphicsContext::EDrawModeAND); - gc->SetBrushStyle(CGraphicsContext::ENullBrush); - gc->SetBrushColor(TRgb::Gray256(85)); - gc->SetBrushOrigin(TPoint(0,0)); - gc->SetPenColor(TRgb::Gray256(170)); - - //primitive method calls - gc->SetFaded(ETrue); - gc->SetFadingParameters(1, 1); - - gc->SetPenStyle(CGraphicsContext::ESolidPen); - gc->SetStrikethroughStyle(EStrikethroughOff); - gc->SetUnderlineStyle(EUnderlineOff); - gc->SetWordJustification(2, 1); - - CFbsFont* font; - gc->Device()->GetNearestFontInTwips((CFont*&)font, TFontSpec()); - - gc->UseFont(font); - - gc->DrawArc(iRect, - TPoint(iRect.Center().iX, iRect.iTl.iY), - TPoint(iRect.iBr.iX, iRect.Center().iY)); - gc->DrawLine(iRect.iTl,iRect.Center()); - gc->DrawLineTo(TPoint(iRect.iBr.iX, iRect.iTl.iY)); - - gc->DrawLineBy(TPoint(iRect.iTl.iX, iRect.iBr.iY)); - gc->MoveBy(iRect.iTl + TPoint(1,1)); - gc->MoveTo(iRect.iTl + TPoint(0,0)); - gc->SetPenSize(TSize(10,10)); - gc->Plot(iRect.iTl + TPoint(2,2)); - gc->SetPenSize(TSize(1,1)); - - CArrayFixFlat* polyPoints = new(ELeave) CArrayFixFlat(3); //CArrayFixFlat - CleanupStack::PushL(polyPoints); - polyPoints->AppendL(iRect.iTl); - polyPoints->AppendL(iRect.Center()); - polyPoints->AppendL(TPoint(iRect.iBr.iX, iRect.iTl.iY)); - - gc->DrawPolyLine(polyPoints); - gc->DrawPolyLine(&polyPoints->At(0), 3); - gc->DrawPolygon(polyPoints, CGraphicsContext::EWinding); - gc->DrawPolygon(&polyPoints->At(0), 3, CGraphicsContext::EAlternate); - - gc->DrawPie(iRect, TPoint(iRect.Center().iX, iRect.iTl.iY), TPoint(iRect.iBr.iX, iRect.Center().iY)); - gc->DrawEllipse(iRect); - gc->DrawRect(iRect); - gc->DrawRoundRect(iRect, TSize(iRect.Width()/8, iRect.Height()/8)); - - CleanupStack::PopAndDestroy(polyPoints); - - gc->CopyRect(TPoint(10, 10), iRect); - - CFbsBitmap* bitmap = new(ELeave) CFbsBitmap(); - CleanupStack::PushL(bitmap); - User::LeaveIfError(bitmap->Create(TSize(16,16),EGray4)); - - gc->UseBrushPattern(bitmap); - gc->DrawBitmap(iRect.iTl, bitmap); - gc->DrawBitmap(iRect, bitmap); - gc->DrawBitmap(iRect, bitmap, TRect(0, 0, 16, 16)); - gc->DrawBitmapMasked(iRect, bitmap, TRect(0, 0, 16, 16), bitmap, ETrue); - - gc->BitBlt(TPoint(0, 0), bitmap); - gc->BitBlt(TPoint(0, 0), bitmap, iRect); - gc->BitBltMasked(TPoint(0, 0), bitmap, iRect, bitmap, ETrue); - gc->AlphaBlendBitmaps(TPoint(0, 0), bitmap, iRect, bitmap, TPoint(0,0)); - - CleanupStack::PopAndDestroy(bitmap); - - _LIT(KHelloWorld,"Hello World"); - gc->SetCharJustification(1,1); - gc->SetClippingRect(iRect); - gc->DrawText(*&KHelloWorld, iRect.iTl); - gc->DrawText(*&KHelloWorld, iRect, 0, CGraphicsContext::ELeft, 0); - gc->DrawTextVertical(*&KHelloWorld, iRect.iBr, ETrue); - gc->DrawTextVertical(*&KHelloWorld, iRect, 0, ETrue, CGraphicsContext::ELeft, 0); - - TRgb rgbs[2]; - gc->MapColors(iRect, rgbs, 1, ETrue); - gc->DiscardBrushPattern(); - - gc->DiscardFont(); - gc->Device()->ReleaseFont(font); - - gc->Deactivate(); - } - -TSize CAnimWindow::Size() - { - return(iCtWin->Size()); - } - -RWindowBase *CAnimWindow::BaseWin() const - { - return(iCtWin->BaseWin()); - } - -CTBaseWin *CAnimWindow::CtBaseWin() - { - return(iCtWin); - } - -void CAnimWindow::Invalidate() - { - CTUser::Splat(TheClient,TRect(iCtWin->Position(),iCtWin->Size()),TRgb::Gray256(0)); - } - -void CAnimWindow::Invalidate(const TRect &aRect) - { - TRect rect(aRect); - rect.Move(iCtWin->Position()); - CTUser::Splat(TheClient,rect,TRgb::Gray256(0)); - } - -void CAnimWindow::DrawTestScreen(CFbsBitmap *aBitmap, CFbsBitmap *aMaskBitmap, CFbsFont *aFont) - { - iCtWin->Gc()->Activate(*(RDrawableWindow *)BaseWin()); - CBitmapContext *gc=iCtWin->Gc(); - TSize size(Size()); - TBool aExtraDrawBitMap=ETrue; -// -#include "DLLDRAW.H" -// - iCtWin->Gc()->Deactivate(); - } - - -__WS_CONSTRUCT_STEP__(AnimDll) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TAUTODLL.H --- a/windowing/windowserver/tauto/TAUTODLL.H Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,162 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef __TAUTODLL_H__ -#define __TAUTODLL_H__ - -#include -#include -#include "../tlib/testbase.h" -#include "AUTO.H" -#include "TGraphicsHarness.h" - - -#include -#include "AUTODLL.H" - -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA -#include "../nonnga/CLIENT/w32comm.h" -#endif - -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA -#include "../nga/CLIENT/w32comm.h" -#endif - -#include "tdirecta.h" - - -class CAnimWindow; - -class CAnimRedrawWindow : public CTWin - { -public: - CAnimRedrawWindow(CAnimWindow *aAnimWindow, TBool aIsBase); - ~CAnimRedrawWindow(); - void Draw(); -private: - CAnimWindow *iAnimWindow; - TBool iIsBase; - }; - -class CAnimWindow : public CBase - { - friend class CTAnimDll; - friend class CAnimRedrawWindow; -public: - enum TWinType - { - ERedraw, - EBlank, - EBackedUp, - }; -public: - CAnimWindow(TBool aIsBase, TWinType aWinType); - ~CAnimWindow(); - void ConstructL(const TPoint &aPos, const TSize &aSize); - void SetRect(const TRect &aRect); - static void Draw(CBitmapContext *aGc, const TSize &aSize, TBool aIsBase,const TRect &aRect, TBool aBlankIt); - static void DrawEllipse(CBitmapContext *aGc, const TRect &aRect); - void DoDraw(TBool aBlankIt=EFalse); - void DoDrawEllipse(); - void DoDrawCoverage(); - TSize Size(); - RWindowBase *BaseWin() const; - CTBaseWin *CtBaseWin(); - void Invalidate(); - void Invalidate(const TRect &aRect); - static void SetEllipseDrawMode(CGraphicsContext::TDrawMode aEllipseDrawMode); - void DrawTestScreen(CFbsBitmap *aBitmap, CFbsBitmap *aMaskBitmap, CFbsFont *aFont); -protected: - CTBaseWin *iCtWin; - TWinType iWinType; - TBool iIsBase; - TRect iRect; - static CGraphicsContext::TDrawMode iEllipseDrawMode; - }; - - - -class CTAnimDll : public CTWsGraphicsBase - { -public: - CTAnimDll(CTestStep* aStep); - ~CTAnimDll(); - void ConstructL(); - - void TestPanicsL(); - void RemoteBuffer(); - void Misc(); - void ExtraCopyTest(); - void SyncMode1(); - void TestSyncModes(MAnimGeneralFunctions::TAnimSync aSyncMode); - void TestTimeChange(); - void TestLoadApiL(); - void KeyClickPriorityL(); -protected: //Pure virtual from MTestCases - void RunTestCaseL(TInt aCurTestCase); -private: - void InvalidatePauseAndRedraw(const TRect &aRect,TTimeIntervalMicroSeconds32 aInterval); - void RedrawAndCheckWindows(TBool aBlankIt=EFalse); - void SetUpMember(TSpriteMember &aMember,TInt aType); - void DrawingTestL(); - void ShadowDrawingTestL(); - void GeneralDrawingTestL(); - void CheckWindows(); - void DestroyWindowTestL(); - void SpriteAnimL(); - void FreeTimerL(); - void DisableTimerL(); - void MultipleAnimsL(); - void ClickPlugInL(); - void WinFunctionsL(); - void WinFunctions2L(); - void TestNotificationsL(); - void TestCoverageL(); - void TestPanicCoverageL(); - void TestWindowInfo(RTestAnim& aAnim,TInt aScreen,TInt aPos,TInt aId); - void TestEventHandlerRemovalL(); - void ParameterValueTestL(); - void TestSetIntervalL(); - TInt CheckError(TInt aError,TInt aExpected); - TRgb PixelColour(const TPoint& aPoint) const; -private: - RAnimDll iAnimDll; - TSize iWinSize; - CAnimWindow *iTestWin; - CAnimWindow *iRedrawWin; - CAnimWindow *iBaseWin; - CAnimWindow *iBackedUpTestWin; - CAnimWindow *iBlankTestWin; - }; - -class CTAnimDllStep : public CTGraphicsStep - { -public: - CTAnimDllStep(); -protected: - //from CTGraphicsStep - virtual CTGraphicsBase* CreateTestL(); - }; - -_LIT(KTAnimDllStep,"TAnimDll"); - - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TAlphaChannel.CPP --- a/windowing/windowserver/tauto/TAlphaChannel.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1936 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// An alpha channel test case. -// Output different graphics primitives in each window using three graphics modes -// for pen and brush : semi-transparent,transparent, opaque -// Test also exercises anti-aliasing and fading for 16MA display mode -// Moves sprite on the window. Tests a sprite functionality. -// Creates RBackedUpWindow window and moves it over transparent window, -// hides and shows it. -// Moves windows on the screen, overlaps them -// Actions: -// Create a background window, and five foreground windows: -// -transparent and semi-transparent -// -transparent with transparency factor -// -not transparent -// -// - -#include "TAlphaChannel.H" - -const TInt KWindowIndention = 2; -const TInt KSizeKoeff = 15; - - -LOCAL_D TPtrC ColumnName[]={ - _L("Opaque"), - _L("Semi-transparent"), - _L("Transparent"), - _L(""), - _L(""), - _L(""), - }; - -LOCAL_D TPtrC RowName[]={ - _L("n"), - _L("and"), - _L("or"), - _L("xor"), - _L(""), - _L(""), - }; - - -// -// -CTAlphaChannel::CTAlphaChannel(CTestStep* aStep): - CTWsGraphicsBase(aStep), iArrWindow(8) - { - } - -CTAlphaChannel::~CTAlphaChannel() - { - delete iBitmap64K_1; - delete iBitmap16MA_1; - delete iBitmap64K_2; - delete iBitmap16MA_2; - delete iBitmap64K_3; - delete iBitmap16MA_3; - - delete iBitmapMask; - delete iBitmapGray256Mask; - - delete iBitmapContext64K_1; - delete iBitmapContext16MA_1; - delete iBitmapContext64K_2; - delete iBitmapContext16MA_2; - delete iBitmapContext64K_3; - delete iBitmapContext16MA_3; - - delete iBitmapDevice64K_1; - delete iBitmapDevice16MA_1; - delete iBitmapDevice64K_2; - delete iBitmapDevice16MA_2; - delete iBitmapDevice64K_3; - delete iBitmapDevice16MA_3; - - delete iBackgroundWindow; - - - iArrWindow.ResetAndDestroy(); - - if(iFont) - TheClient->iScreen->ReleaseFont(iFont); - if(iFont1) - TheClient->iScreen->ReleaseFont(iFont1); - - BaseWin->SetVisible(ETrue); - TestWin->SetVisible(ETrue); - } - -void CTAlphaChannel::ConstructL() - { - const TInt KIndent = 10; - BaseWin->SetVisible(EFalse); - TestWin->SetVisible(EFalse); - - iText = _L("This is a text"); - iBrushStyle = CGraphicsContext::ESolidBrush; - iPenTable = KRgbBlack; - - TSize screenSize=TheClient->iGroup->Size(); - TInt winWidth=(screenSize.iWidth)-KIndent; - TInt winHeight=screenSize.iHeight-KIndent; - TDisplayMode dispMode = EColor64K; - - //background opaque window - iBackgroundWindow = new (ELeave) CTWinAlpha(); - iBackgroundWindow->SetUpL(TPoint(5,5),TSize(winWidth,winHeight),TheClient->iGroup,*TheClient->iGc, &dispMode); - RWindow *theWin = (RWindow*) (iBackgroundWindow->DrawableWin()); - theWin->SetBackgroundColor(TRgb(255, 0, 0)); - iBackgroundWindow->DrawNow(); - - iSizeForegroundWindow.iWidth = (winWidth - KWindowIndention * 4) / 5 ; - iSizeForegroundWindow.iHeight = winHeight; - - CalculateSizePrimitives(iSizeForegroundWindow); - - //-------------create bitmaps - //create 64K bitmap - iBitmap64K_1 = new (ELeave) CFbsBitmap ; - iBitmap64K_1->Create(iBitmapSize,EColor64K); - iBitmap64K_2 = new (ELeave) CFbsBitmap ; - iBitmap64K_2->Create(iBitmapSize,EColor64K); - iBitmap64K_3 = new (ELeave) CFbsBitmap ; - iBitmap64K_3->Create(iBitmapSize,EColor64K); - iBitmapDevice64K_1 = CFbsBitmapDevice::NewL(iBitmap64K_1); - iBitmapDevice64K_1->CreateContext(iBitmapContext64K_1); - iBitmapDevice64K_2 = CFbsBitmapDevice::NewL(iBitmap64K_2); - iBitmapDevice64K_2->CreateContext(iBitmapContext64K_2); - iBitmapDevice64K_3 = CFbsBitmapDevice::NewL(iBitmap64K_3); - iBitmapDevice64K_3->CreateContext(iBitmapContext64K_3); - - //create 16MA bitmap - iBitmap16MA_1 = new (ELeave) CFbsBitmap ; - iBitmap16MA_1->Create(iBitmapSize, EColor16MA); - iBitmap16MA_2 = new (ELeave) CFbsBitmap ; - iBitmap16MA_2->Create(iBitmapSize, EColor16MA); - iBitmap16MA_3 = new (ELeave) CFbsBitmap ; - iBitmap16MA_3->Create(iBitmapSize, EColor16MA); - - iBitmapDevice16MA_1 = CFbsBitmapDevice::NewL(iBitmap16MA_1); - iBitmapDevice16MA_1->CreateContext(iBitmapContext16MA_1); - iBitmapDevice16MA_2 = CFbsBitmapDevice::NewL(iBitmap16MA_2); - iBitmapDevice16MA_2->CreateContext(iBitmapContext16MA_2); - iBitmapDevice16MA_3 = CFbsBitmapDevice::NewL(iBitmap16MA_3); - iBitmapDevice16MA_3->CreateContext(iBitmapContext16MA_3); - - //create mask bitmap - iBitmapMask = new (ELeave) CFbsBitmap ; - iBitmapMask->Create(iBitmapSize, EGray2); - - CFbsBitmapDevice* theBitmapDevice = CFbsBitmapDevice::NewL(iBitmapMask); - CGraphicsContext* theBitmapContext = NULL; - theBitmapDevice->CreateContext(theBitmapContext); - TRect rect = TRect(iBitmapMask->SizeInPixels()); - theBitmapContext->SetBrushColor(KRgbWhite); - theBitmapContext->SetPenColor(KRgbWhite); - theBitmapContext->SetBrushStyle(CGraphicsContext::ESolidBrush); - theBitmapContext->DrawRect(rect); - - rect.Shrink(4, 4); - theBitmapContext->SetBrushColor(KRgbBlack); - theBitmapContext->SetPenColor(KRgbBlack); - theBitmapContext->DrawEllipse(rect); - delete theBitmapContext; - delete theBitmapDevice; - - //create 256gray bitmap mask - iBitmapGray256Mask = new (ELeave) CFbsBitmap; - iBitmapGray256Mask->Create(iBitmapSize, EGray256); - theBitmapDevice = CFbsBitmapDevice::NewL(iBitmapGray256Mask); - theBitmapDevice->CreateContext(theBitmapContext); - - if(iBitmapSize != TSize(0, 0)) - { - //fill bitmap with 256 gradation of gray - TInt theStep = 256 / iBitmapGray256Mask->SizeInPixels().iWidth; - - for(TInt ii = 0; ii < iBitmapGray256Mask->SizeInPixels().iWidth; ii++) - { - TInt theSingleCol = theStep * ii; - TRgb theCol(theSingleCol, theSingleCol, theSingleCol); - theBitmapContext->SetBrushColor(theCol); - theBitmapContext->SetPenColor(theCol); - TPoint ptFrom(ii, 0); - TPoint ptTo(ii, iBitmapGray256Mask->SizeInPixels().iHeight); - theBitmapContext->DrawLine(ptFrom, ptTo); - } - } - delete theBitmapContext; - delete theBitmapDevice; - //-------------- - TFontSpec fontSpec(KTestFontTypefaceName,600); - - fontSpec.iFontStyle.SetStrokeWeight(EStrokeWeightBold); - fontSpec.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap); - - User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips(iFont, fontSpec)); - - TFontSpec fontSpec1(KTestFontTypefaceName,100); - User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips(iFont1, fontSpec1)); - } - -void CTAlphaChannel::CalculateSizePrimitives(const TSize& aSize) - { - TInt theLen = aSize.iWidth / KSizeKoeff; - - iBitmapSize = TSize(2 * theLen, 2 * theLen); - iRectangleSize = TSize(2 * theLen, 2 * theLen); - iEllipseSize = TSize(4 * theLen, 2 * theLen); - iTriangleSize = TSize(3 * theLen, 2 * theLen); - iFirstCellWidth = static_cast (1.2 * theLen); - iFirstCellHeight = static_cast (1.5 * theLen); - } - -void CTAlphaChannel::DrawOffscreenBitmapsL(const TRgb& /*aPen*/, const TRgb& aBrush, - CGraphicsContext* aBitmapContext64K, CGraphicsContext* aBitmapContext16MA, - CFbsBitmap* aBitmap64K, CFbsBitmap* aBitmap16MA) - { - - if(aBitmapContext64K && aBitmap64K) - { - SEpocBitmapHeader header = aBitmap64K->Header(); - TInt source_buffer_size = header.iBitmapSize / header.iSizeInPixels.iHeight * header.iBitsPerPixel ; - TUint8* buffer = new(ELeave) TUint8[source_buffer_size]; - TPtr8 source_ptr(buffer, source_buffer_size, source_buffer_size); - - TUint16* bufferCur = reinterpret_cast (buffer); - TInt ii; - for(ii = 0; ii < header.iSizeInPixels.iWidth; ++ii) - { - *bufferCur = aBrush._Color64K(); - bufferCur ++; - } - - for(ii = 0; ii < header.iSizeInPixels.iHeight; ++ii) - { - aBitmap64K -> SetScanLine(source_ptr, ii); - } - - delete [] buffer; - } - - if(aBitmapContext16MA && aBitmap16MA) - { - SEpocBitmapHeader header = aBitmap16MA -> Header(); - TInt source_buffer_size = header.iBitmapSize / header.iSizeInPixels.iHeight * header.iBitsPerPixel ; - TUint8* buffer = new(ELeave) TUint8[source_buffer_size]; - TPtr8 source_ptr(buffer, source_buffer_size, source_buffer_size); - - TUint32* bufferCur = reinterpret_cast (buffer); - TInt ii; - for(ii = 0; ii < header.iSizeInPixels.iWidth; ++ii) - { - *bufferCur = aBrush._Color16MA(); - bufferCur ++; - } - - for(ii = 0; ii < header.iSizeInPixels.iHeight; ++ii) - { - aBitmap16MA -> SetScanLine(source_ptr, ii); - } - - delete [] buffer; - } - - } - -enum {EOpaque, ESemiTrans, ETrans}; - -TRgb CTAlphaChannel::GetBrush(TInt aIndex) const - { - switch(aIndex) - { - case EOpaque: - return TRgb(0, 0, 255, 255); - case ESemiTrans: - return TRgb(0, 0, 255, 128); - case ETrans: - return TRgb(0, 0, 255, 0); - default : break; - } - - return TRgb(0, 0, 255, 255); - } - -TRgb CTAlphaChannel::GetPen(TInt aIndex) const - { - switch(aIndex) - { - case EOpaque: - return TRgb(0, 0, 255, 255); - case ESemiTrans: - return TRgb(0, 0, 255, 128); - case ETrans: - return TRgb(0, 0, 255, 0); - default : break; - } - - return TRgb(0, 0, 255, 255); - } - -CGraphicsContext::TDrawMode CTAlphaChannel::GetDrawMode(TInt /*aIndex*/) const - { - return CGraphicsContext::EDrawModePEN; - } - -enum {EAll64K, EAll16MA, EAllDifferent};// later may add EAll16M -void CTAlphaChannel::SetDisplayModeConfiguration(TInt aConfig) - { - switch (aConfig) - { - case EAll64K: - if(iForegroundWindowOpaque) - iForegroundWindowOpaque->SetDisplayMode(EColor64K); - if(iForegroundWindowSemiTrans) - iForegroundWindowSemiTrans->SetDisplayMode(EColor64K); - if(iForegroundWindowTrans) - iForegroundWindowTrans->SetDisplayMode(EColor64K); - break; - case EAll16MA: - if(iForegroundWindowOpaque) - iForegroundWindowOpaque->SetDisplayMode(EColor16MA); - if(iForegroundWindowSemiTrans) - iForegroundWindowSemiTrans->SetDisplayMode(EColor16MA); - if(iForegroundWindowTrans) - iForegroundWindowTrans->SetDisplayMode(EColor16MA); - break; - case EAllDifferent: - if(iForegroundWindowOpaque) - iForegroundWindowOpaque->SetDisplayMode(EColor256); - if(iForegroundWindowSemiTrans) - iForegroundWindowSemiTrans->SetDisplayMode(EColor64K); - if(iForegroundWindowTrans) - iForegroundWindowTrans->SetDisplayMode(EColor16MA); - break; - } - } - -enum {ETiled, EOverlapping}; - -void CTAlphaChannel::SetPositionConfiguration(TInt aConfig) - { - TSize screenSize=TheClient->iGroup->Size(); - TInt winWidth=(screenSize.iWidth)-10; - TInt winHeight=screenSize.iHeight-10; - if (aConfig==ETiled) - { - if(iForegroundWindowOpaque) - iForegroundWindowOpaque->SetPos(TPoint(winWidth/5, 0)); - if(iForegroundWindowSemiTrans) - iForegroundWindowSemiTrans->SetPos(TPoint(2*winWidth/5, 0)); - if(iForegroundWindowTrans) - iForegroundWindowTrans->SetPos(TPoint(3*winWidth/5, 0)); - } - else - { - if(iForegroundWindowOpaque) - iForegroundWindowOpaque->SetPos(TPoint(winWidth/3, -winHeight/3)); - if(iForegroundWindowSemiTrans) - iForegroundWindowSemiTrans->SetPos(TPoint(2*winWidth/5, winHeight/3)); - if(iForegroundWindowTrans) - iForegroundWindowTrans->SetPos(TPoint(winWidth/2, -winHeight/3)); - } - if (iForegroundWindowBottom) - iForegroundWindowBottom->SetPos(TPoint(0, 0)); - if (iForegroundWindowTop) - iForegroundWindowTop->SetPos(TPoint(4*winWidth/5, 0)); - } - -enum {EVaryingTransparency, EVaryingColour}; - -void CTAlphaChannel::SetColourConfiguration(TInt aConfig) - { - RWindow* win; - if (aConfig==EVaryingTransparency) - { - // red background, green foregrounds of varying transparency - win = (RWindow*)(iBackgroundWindow->DrawableWin()); - win->SetBackgroundColor(TRgb(255,0,0,255)); - - if(iForegroundWindowOpaque) - iForegroundWindowOpaque->SetBackgroundColor(TRgb(0,255,0,255)); - if(iForegroundWindowSemiTrans) - iForegroundWindowSemiTrans->SetBackgroundColor(TRgb(0,255,0,128)); - if(iForegroundWindowTrans) - iForegroundWindowTrans->SetBackgroundColor(TRgb(0,255,0,0)); - } - else - { - // white background, semi-transparent foregrounds in primary colours - win = (RWindow*)(iBackgroundWindow->DrawableWin()); - win->SetBackgroundColor(TRgb(255,255,255,255)); - - if(iForegroundWindowOpaque) - iForegroundWindowOpaque->SetBackgroundColor(TRgb(255,0,0,128)); - if(iForegroundWindowSemiTrans) - iForegroundWindowSemiTrans->SetBackgroundColor(TRgb(0,255,0,128)); - if(iForegroundWindowTrans) - iForegroundWindowTrans->SetBackgroundColor(TRgb(0,0,255,128)); - } - } - -void CTAlphaChannel::DoMoving() - { - TPoint pos; - for (TInt i = 0; i<20; i++) - { - if (iForegroundWindowBottom) - { - pos = iForegroundWindowBottom->Position(); - pos += TPoint(1,5); - iForegroundWindowBottom->SetPos(pos); - } - - if (iForegroundWindowOpaque) - { - pos = iForegroundWindowOpaque->Position(); - pos += TPoint(1,5); - iForegroundWindowOpaque->SetPos(pos); - } - - if (iForegroundWindowSemiTrans) - { - pos = iForegroundWindowSemiTrans->Position(); - pos += TPoint(1,5); - iForegroundWindowSemiTrans->SetPos(pos); - } - - if (iForegroundWindowTrans) - { - pos = iForegroundWindowTrans->Position(); - pos += TPoint(1,5); - iForegroundWindowTrans->SetPos(pos); - } - - if (iForegroundWindowTop) - { - pos = iForegroundWindowTop->Position(); - pos += TPoint(1,5); - iForegroundWindowTop->SetPos(pos); - } - - TheClient->iWs.Flush(); - User::After(TTimeIntervalMicroSeconds32(50000)); - } - - } - -void CTAlphaChannel::DoMoveBehind() - { - TPoint pos = iBackgroundWindow->Position(); - for (TInt i = 0; i<20; i++) - { - pos += TPoint(0,5); - iBackgroundWindow->SetPos(pos); - - TheClient->iWs.Flush(); - User::After(TTimeIntervalMicroSeconds32(50000)); - } - iBackgroundWindow->SetPos(TPoint(5,5)); - } - -void CTAlphaChannel::DoInvisibility() - { - RWindow* win; - if (iForegroundWindowBottom) - { - win = (RWindow*)(iForegroundWindowBottom->DrawableWin()); - win->SetVisible(EFalse); - TheClient->iWs.Flush(); - User::After(TTimeIntervalMicroSeconds32(1000000)); - - win->SetVisible(ETrue); - TheClient->iWs.Flush(); - User::After(TTimeIntervalMicroSeconds32(1000000)); - } - if (iForegroundWindowOpaque) - { - win = (RWindow*)(iForegroundWindowOpaque->DrawableWin()); - win->SetVisible(EFalse); - TheClient->iWs.Flush(); - User::After(TTimeIntervalMicroSeconds32(1000000)); - - win->SetVisible(ETrue); - TheClient->iWs.Flush(); - User::After(TTimeIntervalMicroSeconds32(1000000)); - } - if (iForegroundWindowSemiTrans) - { - win = (RWindow*)(iForegroundWindowSemiTrans->DrawableWin()); - win->SetVisible(EFalse); - TheClient->iWs.Flush(); - User::After(TTimeIntervalMicroSeconds32(1000000)); - - win->SetVisible(ETrue); - TheClient->iWs.Flush(); - User::After(TTimeIntervalMicroSeconds32(1000000)); - } - if (iForegroundWindowTrans) - { - win = (RWindow*)(iForegroundWindowTrans->DrawableWin()); - win->SetVisible(EFalse); - TheClient->iWs.Flush(); - User::After(TTimeIntervalMicroSeconds32(1000000)); - - win->SetVisible(ETrue); - TheClient->iWs.Flush(); - User::After(TTimeIntervalMicroSeconds32(1000000)); - } - if (iForegroundWindowTop) - { - win = (RWindow*)(iForegroundWindowTop->DrawableWin()); - win->SetVisible(EFalse); - TheClient->iWs.Flush(); - User::After(TTimeIntervalMicroSeconds32(1000000)); - - win->SetVisible(ETrue); - TheClient->iWs.Flush(); - User::After(TTimeIntervalMicroSeconds32(1000000)); - } - } - -/** - @SYMTestCaseID GRAPHICS-WSERV-0328 - - @SYMTestCaseDesc Testing a Fading. - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions - Set fading parameters. Draw all graphics primitives and bitmaps with - various transparency . - - @SYMTestExpectedResults - All windows should be drawn according their fading values. - */ - -void CTAlphaChannel::TestFading() - { - iIsFading = ETrue; - iBlackFading = 0; - iWhiteFading = 128; - iText.Format(_L("Fading. %dX%d"), iBlackFading, iWhiteFading); - INFO_PRINTF1(iText); - DrawTestWindowsNow(); - - User::After(TTimeIntervalMicroSeconds32(1000000 * 1)); - iIsFading = EFalse; - DrawTestWindowsNow(); - iIsFading = ETrue; - iBlackFading = 128; - iWhiteFading = 255; - iText.Format(_L("Fading. %dX%d"), iBlackFading, iWhiteFading); - INFO_PRINTF1(iText); - DrawTestWindowsNow(); - - iIsFading = EFalse; - } - -/** - @SYMTestCaseID GRAPHICS-WSERV-0329 - - @SYMTestCaseDesc Tests moving of foreground windows. - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions - Set fading parameters. Set position of foreground windows as tile . - - @SYMTestExpectedResults - Foreground window has to be redrawn properly. - */ - -void CTAlphaChannel::TestMoving() - { - SetPositionConfiguration(ETiled); - DoMoving(); - SetPositionConfiguration(ETiled); - } - -/** - @SYMTestCaseID GRAPHICS-WSERV-0330 - - @SYMTestCaseDesc Tests moving of foreground windows. - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions - Set fading parameters. Moves foreground windows over the screen . - - @SYMTestExpectedResults - Foreground window has to be redrawn properly. - */ - - -void CTAlphaChannel::TestMovingOverlapping() - { - TPoint pos; - - for (TInt i = 0; i < 20; i++) - { - if (iForegroundWindowOpaque) - { - pos = iForegroundWindowOpaque->Position(); - pos += TPoint(3,0); - iForegroundWindowOpaque->SetPos(pos); - } - if (iForegroundWindowTrans) - { - pos = iForegroundWindowTrans->Position(); - pos -= TPoint(3,0); - iForegroundWindowTrans->SetPos(pos); - } - TheClient->iWs.Flush(); - User::After(TTimeIntervalMicroSeconds32(50000)); - } - } - -/** - @SYMTestCaseID GRAPHICS-WSERV-0331 - - @SYMTestCaseDesc Testing transparency factor for windows with alpha channel. - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions - Sets background colour with various level of transparency . - - @SYMTestExpectedResults - Foreground window must be redrawn properly. - */ -void CTAlphaChannel::TestChangingTransparencyFactor() - { - TInt i = 0; - while (i <= 255) - { - iForegroundWindowOpaque->SetBackgroundColor(TRgb(0,255,0,255-i)); - iForegroundWindowTrans->SetBackgroundColor(TRgb(0,255,0,i)); - iForegroundWindowOpaque->DrawNow(); - iForegroundWindowTrans->DrawNow(); - i+=15; - } - i=0; - while (i <= 255) - { - iForegroundWindowOpaque->SetBackgroundColor(TRgb(0,255,0,i)); - iForegroundWindowTrans->SetBackgroundColor(TRgb(0,255,0,255-i)); - iForegroundWindowOpaque->DrawNow(); - iForegroundWindowTrans->DrawNow(); - User::After(TTimeIntervalMicroSeconds32(50000));// 20 frames per second - i+=15; - } - } - -/** - @SYMTestCaseID GRAPHICS-WSERV-0332 - - @SYMTestCaseDesc Testing redrawing of foreground windows while their positions and - invisibility have been changed. - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions - Sets position of the foreground windows as overlapping, tiled. - Change visability of semi transparent foreground window. . - - @SYMTestExpectedResults - Foreground window must be redrawn properly. - */ - -void CTAlphaChannel::TestInvisibility() - { - RWindow* win = (RWindow*)(iForegroundWindowSemiTrans->DrawableWin()); - SetPositionConfiguration(EOverlapping); - TheClient->iWs.Flush(); - User::After(TTimeIntervalMicroSeconds32(1000000)); - - win->SetVisible(EFalse); - TheClient->iWs.Flush(); - User::After(TTimeIntervalMicroSeconds32(1000000)); - - win->SetVisible(ETrue); - TheClient->iWs.Flush(); - User::After(TTimeIntervalMicroSeconds32(1000000)); - - SetPositionConfiguration(ETiled); - - } - -/** - @SYMTestCaseID GRAPHICS-WSERV-0333 - - @SYMTestCaseDesc Testing redrawing of foreground windows after a - background window has been moved. - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions - Sets position of the foreground windows as tiled. - Moves background window. - - @SYMTestExpectedResults - Foreground windows must be redrawn properly. - */ -void CTAlphaChannel::TestMoveUnderneath() - { - SetPositionConfiguration(ETiled); - DoMoveBehind(); - } -/** - @SYMTestCaseID GRAPHICS-WSERV-0334 - - @SYMTestCaseDesc Testing redrawing of foreground windows after a - background window has been moved. - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions - Sets different position of the foreground windows: tiled, overlapping. - Moves background window. - - @SYMTestExpectedResults - Foreground windows has to be redrawn properly. - */ - -void CTAlphaChannel::TestMoveBehindInvisible() - { - SetPositionConfiguration(ETiled); - RWindow* win; - win = (RWindow*)(iForegroundWindowOpaque->DrawableWin()); - win->SetVisible(EFalse); - win = (RWindow*)(iForegroundWindowSemiTrans->DrawableWin()); - win->SetVisible(EFalse); - win = (RWindow*)(iForegroundWindowTrans->DrawableWin()); - win->SetVisible(EFalse); - TheClient->iWs.Flush(); - - DoMoveBehind(); - - SetPositionConfiguration(EOverlapping); - DoMoveBehind(); - - win = (RWindow*)(iForegroundWindowOpaque->DrawableWin()); - win->SetVisible(ETrue); - win = (RWindow*)(iForegroundWindowSemiTrans->DrawableWin()); - win->SetVisible(ETrue); - win = (RWindow*)(iForegroundWindowTrans->DrawableWin()); - win->SetVisible(ETrue); - TheClient->iWs.Flush(); - } -/** - @SYMTestCaseID GRAPHICS-WSERV-0335 - - @SYMTestCaseDesc Testing redrawing of foreground windows. - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions - Redraws background window - - @SYMTestExpectedResults - Foreground windows should be redrawn properly, if background window - has been redrawn. - */ -void CTAlphaChannel::TestRedrawBehind() - { - TheClient->iWs.Flush(); - iBackgroundWindow->iState += 1; - iBackgroundWindow->DrawNow(); - TheClient->iWs.Flush(); - User::After(TTimeIntervalMicroSeconds32(1000000)); - } -/** - @SYMTestCaseID GRAPHICS-WSERV-0336 - - @SYMTestCaseDesc Testing transparency with RWsSprite class. - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions - Creates RBackedUpWindow window and moves it over transparent window - appears and dissapears set up window as transparent - - @SYMTestExpectedResults - Must work with transparent windows. - */ - -void CTAlphaChannel::TestAnimationL() - { - for(TInt ii = 0; ii < iArrWindow.Count(); ii++) - { - iArrWindow[ii]->StartAnimationL(); - } - } -/** - @SYMTestCaseID GRAPHICS-WSERV-0337 - - @SYMTestCaseDesc Testing transparency with RBackedUpWindow window class. - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions - Creates RBackedUpWindow window and moves it over transparent window - appears and dissapears set up transparent window as transparent - - @SYMTestExpectedResults - Do not expect correct work of alpha channel with - RBackedUpWindow window class. -*/ -void CTAlphaChannel::TestBackedWindowL() - { - for(TInt ii = 0; ii < iArrWindow.Count(); ii++) - { - iArrWindow[ii]->CreateBackedWindowL(); - } - } - -/** - @SYMTestCaseID GRAPHICS-WSERV-0338 - - @SYMTestCaseDesc Implication of setting SetDrawOpaque on drawing with alpha channel. - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions - Change graphic context to opaque and none opaque and rewdraw all test windows - - @SYMTestExpectedResults - must not impact on output with alpha channel - */ - -void CTAlphaChannel::TestEffectSetOpaque() - { - for(TInt ii = 0; ii < 3; ii++) - { - - for(TInt ii = 0; ii < iArrWindow.Count(); ii++) - { - iArrWindow[ii]->SetDrawOpaque(EFalse); - } - - DrawTestWindowsNow(); - User::After(TTimeIntervalMicroSeconds32(1000000)); - - for(TInt jj = 0; jj < iArrWindow.Count(); jj++) - { - iArrWindow[jj]->SetDrawOpaque(ETrue); - } - - DrawTestWindowsNow(); - User::After(TTimeIntervalMicroSeconds32(1000000)); - } - } - -/** - @SYMTestCaseID GRAPHICS-WSERV-0339 - - @SYMTestCaseDesc Redrawing of child windows with transparency. - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions - Creates a few child windows with various levels of transparency. - Moves parent window over the screen. - @SYMTestExpectedResults - Child and parent windows must be redrawn properly - */ - -void CTAlphaChannel::TestChildWindowL() - { - SetPositionConfiguration(ETiled); - SetColourConfiguration(EVaryingColour); - DrawTestWindowsNow(ETrue); - TDisplayMode mode = EColor64K; - CTWinAlphaForeground* childWin[] = {NULL, NULL, NULL, NULL, NULL}; - if (iForegroundWindowBottom) - { - childWin[0] = CTWinAlphaForeground::NewL(*this, TPoint(0,0),TSize(50,50),iForegroundWindowBottom,*TheClient->iGc, &mode, TRgb(0, 255, 0,128), ENonTransparentAlpha); - childWin[0]->DrawNow(); - } - if (iForegroundWindowOpaque) - { - childWin[1] = CTWinAlphaForeground::NewL(*this, TPoint(0,0),TSize(50,50),iForegroundWindowOpaque,*TheClient->iGc, &mode, TRgb(0, 255, 0,128), ETransparencyFactor); - childWin[1]->DrawNow(); - } - if (iForegroundWindowSemiTrans) - { - childWin[2] = CTWinAlphaForeground::NewL(*this, TPoint(0,0),TSize(50,50),iForegroundWindowSemiTrans,*TheClient->iGc, &mode, TRgb(0, 255, 0,128), ETransparencyAlpha); - childWin[2]->DrawNow(); - } - if (iForegroundWindowTrans) - { - childWin[3] = CTWinAlphaForeground::NewL(*this, TPoint(0,0),TSize(50,50),iForegroundWindowTrans,*TheClient->iGc, &mode, TRgb(0, 255, 0,128), ENonTransparentAlpha); - childWin[3]->DrawNow(); - } - if (iForegroundWindowTop) - { - childWin[4] = CTWinAlphaForeground::NewL(*this, TPoint(0,0),TSize(50,50),iForegroundWindowTop,*TheClient->iGc, &mode, TRgb(0, 255, 0,128), ENonTransparentAlpha); - childWin[4]->DrawNow(); - } - TheClient->iWs.Flush(); - - User::After(TTimeIntervalMicroSeconds32(1000000)); - DoMoving(); - - delete childWin[0]; - delete childWin[1]; - delete childWin[2]; - delete childWin[3]; - delete childWin[4]; - } -/** - @SYMTestCaseID GRAPHICS-WSERV-0340 - - @SYMTestCaseDesc Redrawing of multiple child windows with transparency. - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions - Creates multiple child windows with various levels of transparency. - Moves parent windows over the screen. - @SYMTestExpectedResults - Child and parent windows must be redrawn properly - */ - -void CTAlphaChannel::TestMultipleChildrenL() - { - SetPositionConfiguration(ETiled); - SetColourConfiguration(EVaryingColour); - TDisplayMode mode = EColor64K; - CTWinAlphaForeground* childWin[] = {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}; - if (iForegroundWindowBottom) - { - childWin[0] = CTWinAlphaForeground::NewL(*this, TPoint(0,0),TSize(50,50),iForegroundWindowBottom,*TheClient->iGc, &mode, TRgb(255, 255, 255,128), ETransparencyFactor); - childWin[1] = CTWinAlphaForeground::NewL(*this, TPoint(20,20),TSize(50,50),childWin[0],*TheClient->iGc, &mode, TRgb(255, 255, 255,128), ENonTransparentAlpha); - childWin[0]->DrawNow(); - childWin[1]->DrawNow(); - } - if (iForegroundWindowOpaque) - { - childWin[4] = CTWinAlphaForeground::NewL(*this, TPoint(0,0),TSize(100,100),iForegroundWindowOpaque,*TheClient->iGc, &mode, TRgb(255, 255, 255,128), ETransparencyAlpha); - childWin[5] = CTWinAlphaForeground::NewL(*this, TPoint(20,80),TSize(50,50),iForegroundWindowOpaque,*TheClient->iGc, &mode, TRgb(255, 255, 255,128), ENonTransparentAlpha); - childWin[6] = CTWinAlphaForeground::NewL(*this, TPoint(20,20),TSize(60,60),childWin[4],*TheClient->iGc, &mode, TRgb(0, 255, 0,128), ENonTransparentAlpha); - childWin[7] = CTWinAlphaForeground::NewL(*this, TPoint(20,20),TSize(50,50),childWin[6],*TheClient->iGc, &mode, TRgb(0, 255, 0,128), ENonTransparentAlpha); - childWin[4]->DrawNow(); - childWin[5]->DrawNow(); - childWin[6]->DrawNow(); - childWin[7]->DrawNow(); - } - DrawTestWindowsNow(ETrue); - - TestMoving(); - - delete childWin[0]; - delete childWin[1]; - delete childWin[2]; - delete childWin[3]; - delete childWin[4]; - delete childWin[5]; - delete childWin[6]; - delete childWin[7]; - } - -/** - @SYMTestCaseID GRAPHICS-WSERV-0341 - - @SYMTestCaseDesc Test transparent window which positioned under opaque. - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions - Creates an opaque window on the topt of transparent windows. - Moves transparent windows over the screen. - @SYMTestExpectedResults - Transparent windows must be redrawn properly - */ - -void CTAlphaChannel::TestTransparentMovingUnderOpaqueL() - { - SetColourConfiguration(EVaryingColour); - TDisplayMode mode = EColor64K; - CTWinAlphaForeground* win = CTWinAlphaForeground::NewL(*this, TPoint(0,100),TSize(600,40),TheClient->iGroup,*TheClient->iGc, &mode, TRgb(0, 255, 0,128), ENonTransparentAlpha); - win->DrawNow(); - - TestMoving(); - - delete win; - } -/** - @SYMTestCaseID GRAPHICS-WSERV-0342 - - @SYMTestCaseDesc Changing orinary position of the foreground windows. - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions - Set ordinal position of foreground windows. - @SYMTestExpectedResults - Foreground windows must be redrawn properly - */ - -void CTAlphaChannel::TestSetOrdinalPosition() - { - SetColourConfiguration(EVaryingColour); - SetPositionConfiguration(EOverlapping); - DrawTestWindowsNow(ETrue); - TheClient->iWs.Flush(); - User::After(TTimeIntervalMicroSeconds32(1000000)); - RWindow* win; - for (TInt i=0; i<3; i++) - { - if (iForegroundWindowOpaque) - { - win = (RWindow*)(iForegroundWindowOpaque->DrawableWin()); - win->SetOrdinalPosition(0); - TheClient->iWs.Flush(); - User::After(TTimeIntervalMicroSeconds32(1000000)); - } - if (iForegroundWindowSemiTrans) - { - win = (RWindow*)(iForegroundWindowSemiTrans->DrawableWin()); - win->SetOrdinalPosition(0); - TheClient->iWs.Flush(); - User::After(TTimeIntervalMicroSeconds32(1000000)); - } - if (iForegroundWindowTrans) - { - win = (RWindow*)(iForegroundWindowTrans->DrawableWin()); - win->SetOrdinalPosition(0); - TheClient->iWs.Flush(); - User::After(TTimeIntervalMicroSeconds32(1000000)); - } - } - } - -void CTAlphaChannel::RunTestCaseL(TInt aCurTestCase) - { - User::After(TTimeIntervalMicroSeconds32(1000000 * 2)); - - ((CTAlphaChannelStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); - switch (aCurTestCase) - { - case 1: - ((CTAlphaChannelStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - CreateForegroundWindowsL(iSizeForegroundWindow, EColor16MU); - break; - case 2: - { - CreateForegroundWindowsL(iSizeForegroundWindow, EColor64K); - ((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0339")); - TestChildWindowL(); - ((CTAlphaChannelStep*)iStep)->RecordTestResultL(); - ((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0340")); - TestMultipleChildrenL(); - ((CTAlphaChannelStep*)iStep)->RecordTestResultL(); - ((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0342")); - TestSetOrdinalPosition(); - } - break; - case 3: - ((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0336")); - TestAnimationL(); - case 4: - ((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0337")); - TestBackedWindowL(); - break; - case 5: - ((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0338")); - TestEffectSetOpaque(); - break; - case 6: - ((CTAlphaChannelStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - iIsFading = EFalse; - DrawTestWindowsNow(); - INFO_PRINTF1(_L("Anti-aliasing")); - iIsFading = EFalse; - iDrawText = ETrue; - DrawTestWindowsNow(); - break; - case 7: - SetColourConfiguration(EVaryingColour); - SetPositionConfiguration(EOverlapping); - ((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0335")); - TestRedrawBehind(); - ((CTAlphaChannelStep*)iStep)->RecordTestResultL(); - ((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0329")); - TestMoving(); - ((CTAlphaChannelStep*)iStep)->RecordTestResultL(); - ((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0330")); - TestMovingOverlapping(); - ((CTAlphaChannelStep*)iStep)->RecordTestResultL(); - ((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0341")); - TestMoveBehindInvisible(); - ((CTAlphaChannelStep*)iStep)->RecordTestResultL(); - ((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0334")); - TestTransparentMovingUnderOpaqueL(); - ((CTAlphaChannelStep*)iStep)->RecordTestResultL(); - ((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0331")); - TestInvisibility(); - ((CTAlphaChannelStep*)iStep)->RecordTestResultL(); - ((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0332")); - TestChangingTransparencyFactor(); - break; - case 8: - ((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0328")); - TestFading(); - break; - case 9: - { - ((CTAlphaChannelStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - iDrawText = EFalse; - SetDisplayModeConfiguration(EAll16MA); - } - break; - case 10: - ((CTAlphaChannelStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - iIsFading = EFalse; - DrawTestWindowsNow(); - INFO_PRINTF1(_L("Anti-aliasing")); - iIsFading = EFalse; - iDrawText = ETrue; - DrawTestWindowsNow(); - break; - case 11: - SetColourConfiguration(EVaryingColour); - SetPositionConfiguration(EOverlapping); - ((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0333")); - TestMoveUnderneath(); - ((CTAlphaChannelStep*)iStep)->RecordTestResultL(); - ((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0335")); - TestRedrawBehind(); - ((CTAlphaChannelStep*)iStep)->RecordTestResultL(); - ((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0329")); - TestMoving(); - ((CTAlphaChannelStep*)iStep)->RecordTestResultL(); - ((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0332")); - TestInvisibility(); - ((CTAlphaChannelStep*)iStep)->RecordTestResultL(); - ((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0331")); - TestChangingTransparencyFactor(); - break; - case 12: - ((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0328")); - TestFading(); - break; - case 13: - SetDisplayModeConfiguration(EAllDifferent); - SetColourConfiguration(EVaryingColour); - ((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0333")); - TestMoveUnderneath(); - ((CTAlphaChannelStep*)iStep)->RecordTestResultL(); - ((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0335")); - TestRedrawBehind(); - ((CTAlphaChannelStep*)iStep)->RecordTestResultL(); - ((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0332")); - TestInvisibility(); - ((CTAlphaChannelStep*)iStep)->RecordTestResultL(); - ((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0329")); - TestMoving(); - break; - case 14: - ((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0336")); - TestAnimationL(); - break; - case 15: - ((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0337")); - TestBackedWindowL(); - break; - case 16: - ((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0338")); - TestEffectSetOpaque(); - break; - case 17: - ((CTAlphaChannelStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - ((CTAlphaChannelStep*)iStep)->CloseTMSGraphicsStep(); - TestComplete(); - break; - } - ((CTAlphaChannelStep*)iStep)->RecordTestResultL(); - } - -/** Calculate foreground windows margin and create them*/ -void CTAlphaChannel::CreateForegroundWindowsL(const TSize& aSize, TDisplayMode aMode) - { - TPoint pt = TPoint(5, 5); - - //creating foreground windows - //bottom window - TDisplayMode dispMode = aMode; - iForegroundWindowBottom = CTWinAlphaForeground::NewL(*this, pt,aSize,TheClient->iGroup,*TheClient->iGc, &dispMode, TRgb(0, 255, 0,128), ETransparencyFactor); - iArrWindow.AppendL( iForegroundWindowBottom); - - //dispMode = EColor16MA; - pt.iX += aSize.iWidth + KWindowIndention; - //opaque window - iForegroundWindowOpaque = CTWinAlphaForeground::NewL(*this, pt,aSize,TheClient->iGroup,*TheClient->iGc, &dispMode, TRgb(0, 255, 0, 255), ETransparencyAlpha); - iArrWindow.AppendL( iForegroundWindowOpaque); - - pt.iX += aSize.iWidth + KWindowIndention; - //semi-transparent window - iForegroundWindowSemiTrans = CTWinAlphaForeground::NewL(*this, pt,aSize,TheClient->iGroup,*TheClient->iGc, &dispMode, TRgb(0, 255, 0, 128), ETransparencyAlpha); - iArrWindow.AppendL( iForegroundWindowSemiTrans); - - //transparent window - pt.iX += aSize.iWidth + KWindowIndention; - iForegroundWindowTrans = CTWinAlphaForeground::NewL(*this, pt,aSize,TheClient->iGroup,*TheClient->iGc, &dispMode, TRgb(0, 255, 0, 0), ETransparencyAlpha); - iArrWindow.AppendL( iForegroundWindowTrans); - - // top window - pt.iX += aSize.iWidth + KWindowIndention; - iForegroundWindowTop = CTWinAlphaForeground::NewL(*this, pt,aSize,TheClient->iGroup,*TheClient->iGc, &dispMode, TRgb(0, 255, 0,128), ENonTransparentAlpha); - iArrWindow.AppendL( iForegroundWindowTop); - } - -void CTAlphaChannel::DestroyForegroundWindows() - { - iArrWindow.ResetAndDestroy(); - iForegroundWindowBottom = NULL; - iForegroundWindowOpaque = NULL; - iForegroundWindowSemiTrans = NULL; - iForegroundWindowTrans = NULL; - iForegroundWindowTop = NULL; - } - -/** Draw all foreground windows */ -void CTAlphaChannel::DrawTestWindowsNow(TBool aDrawBackgroundWin) - { - if(iBackgroundWindow && aDrawBackgroundWin) - { - iBackgroundWindow->DrawNow(); - } - - for(TInt ii = 0; ii < iArrWindow.Count(); ii++) - { - iArrWindow[ii]->DrawNow(); - } - } - -//------------- - -CTWinAlphaForeground* CTWinAlphaForeground::NewL(CTAlphaChannel& aTest, TPoint aPos, TSize aSize, CTWinBase *aParent, CWindowGc &aGc, TDisplayMode *aMode, TRgb aCol, TInt aTransparencyType) - { - CTWinAlphaForeground* theWin = new(ELeave) CTWinAlphaForeground(aTest); - - theWin->ConstructL(*aParent); - if (aMode) - theWin->SetDisplayMode(*aMode); - theWin->SetExtL(aPos, aSize); - theWin->AssignGC(aGc); - theWin->PrepareForDrawingL(); - - // for hardware testing only we create an additional bitmap -#ifndef __WINS__ - theWin->CreateBackgroundBitmapL(*aMode); -#endif - - RWindow* win = (RWindow*) (theWin->DrawableWin()); - win->SetShadowHeight(0); - win->SetShadowDisabled(ETrue); - switch (aTransparencyType) - { - case ETransparencyFactor: - { - win->SetTransparencyFactor(aCol); - theWin->SetBackgroundColor(aCol); - } - break; - case ETransparencyAlpha: - win->SetTransparencyAlphaChannel(); - // fall through into next case - case ENonTransparentAlpha: - default: - theWin->SetBackgroundColor(aCol); - break; - } - - theWin->Activate(); - - return theWin; - } - -CTWinAlphaForeground::~CTWinAlphaForeground() - { - if(iPolygon) - { - iPolygon->Reset(); - delete iPolygon; - } - delete iBitmapBackground; - delete iBitmapDeviceBackground; - delete iBitmapContextBackground; - } - -CTWinAlphaForeground::CTWinAlphaForeground(CTAlphaChannel& aTest) - : iTest(aTest) - { - } - - -void CTWinAlphaForeground::SetDisplayMode(TDisplayMode aDisplayMode) - { - BaseWin()->SetRequiredDisplayMode(aDisplayMode); - switch (aDisplayMode) - { - case EColor256: - iTitle1 = _L("256"); - break; - case EColor64K: - iTitle1 = _L("64K"); - break; - case EColor16MU: - iTitle1 = _L("16MU"); - break; - case EColor16MA: - iTitle1 = _L("16MA"); - break; - case EColor16MAP: - iTitle1 = _L("16MAP"); - break; - default: - iTitle1 = _L(""); - break; - } - } - -void CTWinAlphaForeground::SetBackgroundColor(TRgb aRgb) - { - switch (aRgb.Alpha()) - { - case 0: - iTitle2 = _L(" trans "); - break; - case 255: - iTitle2 = _L(" opaque "); - break; - case 128: - default: - iTitle2 = _L(" s-trans "); - break; - } - if (aRgb.Red()) - iTitle2 += _L("R"); - if (aRgb.Green()) - iTitle2 += _L("G"); - if (aRgb.Blue()) - iTitle2 += _L("B"); - - iBackgroundColor = aRgb; - ((RWindow*) DrawableWin())->SetBackgroundColor(aRgb); - } - -void CTWinAlphaForeground::Draw() - { - CBitmapContext* theGc = TheClient->iGc; - ((CWindowGc*)theGc)->SetOpaque(iDrawOpaque); - - if(iBitmapContextBackground) - { - //CGraphicsContext - theGc = iBitmapContextBackground; - CleanBackgroundBitmap(); - } - if(iTest.iFont1) - theGc->UseFont(iTest.iFont1); - - - theGc->SetFaded(EFalse); - DrawTable(*theGc); - - TInt numRows = sizeof(iRows) / sizeof(iRows[0]) ; - - theGc->SetBrushStyle(iTest.iBrushStyle); - if(iTest.iFont && iTest.iDrawText) - { - theGc->DiscardFont(); - theGc->UseFont(iTest.iFont); - } - - theGc->SetFaded(iTest.iIsFading); - - // the factor and offset are calculated as follows: - // iFadeMapFactor = iWhiteFading - iBlackFading; - // iFadeMapOffset = iBlackFading; - - theGc->SetFadingParameters(iTest.iBlackFading, iTest.iWhiteFading); //black and white - - for(TInt ii = 0; ii < numRows - 1; ii++) - { - theGc -> SetBrushStyle(iTest.iBrushStyle); - - TRect theRect = TRect(iCol, iRows[ii], Size().iWidth, iRows[ii + 1]); - - TRgb theBrush = iTest.GetBrush(ii); - TRgb thePen = iTest.GetPen(ii); - - CGraphicsContext::TDrawMode theDrawMode = iTest.GetDrawMode(ii); - - theGc->SetBrushColor(theBrush); - theGc->SetPenColor(thePen); - theGc->SetDrawMode(theDrawMode); - - CGraphicsContext* theBitmapContext64K; - CGraphicsContext* theBitmapContext16MA; - CFbsBitmap* theBitmap64K; - CFbsBitmap* theBitmap16MA; - - switch(ii) - { - case 0: - { - theBitmapContext64K = iTest.iBitmapContext64K_1; - theBitmapContext16MA = iTest.iBitmapContext16MA_1; - theBitmap64K = iTest.iBitmap64K_1; - theBitmap16MA = iTest.iBitmap16MA_1; - break; - } - case 1: - { - theBitmapContext64K = iTest.iBitmapContext64K_2; - theBitmapContext16MA = iTest.iBitmapContext16MA_2; - theBitmap64K = iTest.iBitmap64K_2; - theBitmap16MA = iTest.iBitmap16MA_2; - break; - } - default: - { - theBitmapContext64K = iTest.iBitmapContext64K_3; - theBitmapContext16MA = iTest.iBitmapContext16MA_3; - theBitmap64K = iTest.iBitmap64K_3; - theBitmap16MA = iTest.iBitmap16MA_3; - break; - } - } - if(iTest.iDrawText) - { - DrawTextInCell(*theGc, theRect); - } - else - { - TRAP_IGNORE(iTest.DrawOffscreenBitmapsL(thePen, theBrush, theBitmapContext64K, - theBitmapContext16MA, theBitmap64K, theBitmap16MA)); - DrawPrimitivesInCell(*theGc, theRect, theBitmap64K, theBitmap16MA); - } - TheClient->iWs.Flush(); - } - - theGc->DiscardFont(); - - if(iBitmapContextBackground) - { - theGc = TheClient->iGc; - theGc->BitBlt(TPoint(0, 0), iBitmapBackground); - } - } - -void CTWinAlphaForeground::SetPoligonLocation(const TPoint &ptOffset) - { - TRect rect = TRect(iTest.iTriangleSize); - (*iPolygon)[0] = rect.iTl + ptOffset; - (*iPolygon)[1] = TPoint(rect.iTl.iX, rect.iBr.iY) + ptOffset; - (*iPolygon)[2] = rect.iBr + ptOffset; - } - -/** Define boundary of the table*/ -void CTWinAlphaForeground::CalculateTableMargin() - { - TInt numRows = sizeof(iRows) / sizeof(iRows[0]) ; - iRows[0] = iTest.iFirstCellHeight; - TInt theRowHeight = (Size().iHeight - iTest.iFirstCellHeight) / 3; - for(TInt ii = 1; ii < numRows; ii++) - { - iRows[ii] = iRows[ii-1] + theRowHeight; - } - } - -/** Draw a table which comprises 3 rows: for transparent, semi-transparent - and opaque output - -*/ -void CTWinAlphaForeground::DrawTable(CBitmapContext& aGc) const - { - TInt numRows = sizeof(iRows) / sizeof(iRows[0]) ; - - aGc.SetPenColor(iTest.iPenTable); - - for (TInt ii = 0; ii < numRows - 1; ii++) - { - TBuf<4> iBuf; - TPoint pt1 = TPoint(0, iRows[ii]); - TPoint pt2 = TPoint(Size().iWidth, iRows[ii]); - - aGc.DrawLine(pt1, pt2); - - if(iCol) - { - TPoint pt3 = TPoint(0, iRows[ii]) + TPoint(2,(iRows[1] - iRows[0]) / 2); - switch(ii) - { - case 0: iBuf = _L("o"); break; - case 1: iBuf = _L("s"); break; - case 2: iBuf = _L("t"); break; - default : iBuf = _L(""); break; - } - aGc.DrawText(iBuf, pt3); - } - } - if(iCol) - { - TPoint pt3 = TPoint(iCol, iRows[0]) + TPoint(1,-2); - TBuf<32> text = iTitle1; - text += iTitle2; - aGc.DrawText(text, pt3); - - TPoint pt1 = TPoint(iCol, 0); - TPoint pt2 = TPoint(iCol, Size().iHeight); - aGc.DrawLine(pt1, pt2); - } - - } - -/** Draw truetype font to check anti-aliasing*/ -void CTWinAlphaForeground::DrawTextInCell(CBitmapContext& aGc, const TRect& aRect) - { - TPoint pt(aRect.iTl.iX, aRect.iBr.iY); - pt += TPoint(2, -10); - - aGc.DrawText(_L("ABCD"), pt); - } - -/** Draw graphics primitive in a cell: - rectangle, ellipse, triangle, a few lines, bitmaps - - */ -void CTWinAlphaForeground::DrawPrimitivesInCell(CBitmapContext& aGc, const TRect& aRect, - CFbsBitmap* aBitmap64K, CFbsBitmap* aBitmap16MA) - { - TRect theCellRect = aRect; - theCellRect.Shrink(1, 1); - - //rectangle - TRect rect = TRect(iTest.iRectangleSize); - rect.Move(theCellRect.iTl); - aGc.DrawRect(rect); - - //ellipse - rect = TRect(iTest.iEllipseSize); - rect.Move(theCellRect.iTl + TPoint(iTest.iRectangleSize.iWidth + 5, 0)); - aGc.DrawEllipse(rect); - - //triangle - TPoint pt = TPoint(rect.iBr.iX, rect.iTl.iY) + TPoint(5, 0); - SetPoligonLocation(pt); - aGc.DrawPolygon(iPolygon); - - //DrawLine - pt = pt + TPoint (((*iPolygon)[2]).iX - ((*iPolygon)[0]).iX, 0) + TPoint(5, 2); - rect = TRect(iTest.iTriangleSize); - rect.Move(pt); - aGc.DrawLine(rect.iTl, TPoint(rect.iTl.iX, rect.iBr.iY)); - aGc.DrawLine(TPoint(rect.iTl.iX, rect.iBr.iY), rect.iBr); - aGc.DrawLine(rect.iBr, TPoint(rect.iBr.iX, rect.iTl.iY)); - aGc.DrawLine(TPoint(rect.iBr.iX, rect.iTl.iY), rect.iTl); - aGc.DrawLine(rect.iTl, rect.iBr); - aGc.DrawLine(TPoint(rect.iBr.iX, rect.iTl.iY), TPoint(rect.iTl.iX, rect.iBr.iY)); - - //64K bitmap - aGc.SetBrushStyle(CGraphicsContext::ENullBrush); - pt = TPoint(theCellRect.iTl.iX, rect.iBr.iY) + TPoint(0, 5); - if(aBitmap64K) - { - aGc.BitBlt(pt, aBitmap64K); - pt = pt + TPoint( aBitmap64K->SizeInPixels().iWidth, 0) + TPoint(2, 0); - - aGc.BitBltMasked(pt, - aBitmap64K, TRect(aBitmap64K->SizeInPixels()), - iTest.iBitmapGray256Mask, EFalse); - pt = pt + TPoint( aBitmap64K->SizeInPixels().iWidth, 0) + TPoint(2, 0); - - aGc.BitBltMasked(pt, - aBitmap64K, TRect(aBitmap64K->SizeInPixels()), - iTest.iBitmapMask, EFalse); - - pt = pt + TPoint( aBitmap64K->SizeInPixels().iWidth, 0) + TPoint(2, 0); - } - - if(aBitmap16MA) - { - aGc.BitBlt(pt, aBitmap16MA); - - pt = pt + TPoint( aBitmap16MA->SizeInPixels().iWidth, 0) + TPoint(2, 0); - - aGc.BitBltMasked(pt, - aBitmap16MA, TRect(aBitmap16MA->SizeInPixels()), - iTest.iBitmapGray256Mask, EFalse); - - pt = pt + TPoint( aBitmap16MA->SizeInPixels().iWidth, 0) + TPoint(2,0); - - pt = pt + TPoint( 0, aBitmap16MA->SizeInPixels().iHeight); - } - - pt.iX = aRect.iTl.iX + 2; - pt.iY = pt.iY + 18; - - if(aBitmap64K) - { - TSize size = aBitmap64K->SizeInPixels(); - TRect srcRect(TPoint(0,0),size); - size += TSize(5,5); - TRect destRect(pt - TPoint(0, 8), size); - aGc.DrawBitmap(destRect, aBitmap64K, srcRect); - pt = pt + TPoint( size.iWidth, 0) + TPoint(2, 0); - -#ifdef __WINS__ - destRect.Move(TPoint(aBitmap64K->SizeInPixels().iWidth + 8, 0)); - ((CWindowGc&) aGc).DrawBitmapMasked(destRect, - aBitmap64K, srcRect, - iTest.iBitmapGray256Mask, EFalse); - pt = pt + TPoint( aBitmap64K->SizeInPixels().iWidth, 0) + TPoint(2, 0); -#endif - } - - aGc.DrawText(iTest.iText, pt); - -#ifdef __WINS__ - ((CWindowGc&) aGc).DrawTextVertical(iTest.iText, pt, ETrue); -#endif - } - -/** calculate table's size and size of graphics primitieves */ -void CTWinAlphaForeground::PrepareForDrawingL() - { - iCol = iTest.iFirstCellWidth; - - CalculateTableMargin(); - - //create triangle - iPolygon = new (ELeave) CArrayFixFlat (3); - TRect rect = TRect(iTest.iTriangleSize); - iPolygon->AppendL(rect.iTl); - iPolygon->AppendL(TPoint(rect.iTl.iX, rect.iBr.iY)); - iPolygon->AppendL(rect.iBr); - } - -/** Bitmap is intended to use on target only*/ -void CTWinAlphaForeground::CreateBackgroundBitmapL(const TDisplayMode& aDispMode) - { - ASSERT(!iBitmapBackground); - - TSize size = Size(); - - iBitmapBackground = new (ELeave) CFbsBitmap ; - iBitmapBackground->Create(size,aDispMode); - - iBitmapDeviceBackground = CFbsBitmapDevice::NewL(iBitmapBackground); - CGraphicsContext *&theGc = (CGraphicsContext*&)iBitmapContextBackground; - iBitmapDeviceBackground->CreateContext(theGc); - } - -void CTWinAlphaForeground::CleanBackgroundBitmap() - { - ASSERT(iBitmapBackground); - - TRect rect = TRect(iBitmapBackground->SizeInPixels()); - iBitmapContextBackground->SetBrushColor(iBackgroundColor); - iBitmapContextBackground->SetPenColor(iBackgroundColor); - iBitmapContextBackground->SetBrushStyle(CGraphicsContext::ESolidBrush); - iBitmapContextBackground->DrawRect(rect); - } - -void CTWinAlphaForeground::StartAnimationL() - { - __UHEAP_MARK; - RWsSprite theSprite; - - RDrawableWindow *theWin = DrawableWin(); - - theSprite=RWsSprite(TheClient->iWs); - TPoint theSpritePos = TPoint(10, 10); - TInt theFlags = 0; - theSprite.Construct(*theWin, theSpritePos, theFlags); - TDisplayMode dispMode = EColor256; - //create a ball bitmap for animation - CFbsBitmap* theBitmapBall= new (ELeave) CFbsBitmap; - theBitmapBall->Create(TSize(32, 32), dispMode); - CFbsBitmapDevice* theBitmapDeviceBall = CFbsBitmapDevice::NewL(theBitmapBall); - CGraphicsContext* theBitmapContextBall = NULL; - theBitmapDeviceBall->CreateContext(theBitmapContextBall); - //draw a background - theBitmapContextBall->SetBrushColor(TRgb(128, 0, 255)); - theBitmapContextBall->SetPenColor(TRgb(128, 0, 255)); - theBitmapContextBall->SetBrushStyle(CGraphicsContext::ESolidBrush); - theBitmapContextBall->DrawRect(theBitmapBall->SizeInPixels()); - - //create a ball's mask - CFbsBitmap* theBitmapMask= new (ELeave) CFbsBitmap; - theBitmapMask->Create(TSize(32, 32), dispMode); - CFbsBitmapDevice* theBitmapDeviceMask = CFbsBitmapDevice::NewL(theBitmapMask); - CGraphicsContext* theBitmapContextMask = NULL; - theBitmapDeviceMask->CreateContext(theBitmapContextMask); - //draw a mask - theBitmapContextMask->SetBrushColor(TRgb(0, 0, 0)); - theBitmapContextMask->SetPenColor(TRgb(0, 0, 0)); - theBitmapContextMask->SetBrushStyle(CGraphicsContext::ESolidBrush); - theBitmapContextMask->DrawRect(theBitmapMask->SizeInPixels()); - - theBitmapContextMask->SetBrushColor(TRgb(255, 255, 255)); - theBitmapContextMask->SetPenColor(TRgb(255, 255, 255)); - TRect rect = TRect(theBitmapMask->SizeInPixels()); - theBitmapContextMask->SetPenSize(TSize(6,6)); - theBitmapContextMask->DrawLine(rect.iTl, rect.iBr); - theBitmapContextMask->DrawLine(TPoint(0, rect.iBr.iY), TPoint(rect.iBr.iX, 0)); - - //create a second ball's mask - CFbsBitmap* theBitmapMask1= new (ELeave) CFbsBitmap; - theBitmapMask1->Create(TSize(32, 32), dispMode); - CFbsBitmapDevice* theBitmapDeviceMask1 = CFbsBitmapDevice::NewL(theBitmapMask1); - CGraphicsContext* theBitmapContextMask1 = NULL; - theBitmapDeviceMask1->CreateContext(theBitmapContextMask1); - //draw a mask - theBitmapContextMask1->SetBrushColor(TRgb(0, 0, 0)); - theBitmapContextMask1->SetPenColor(TRgb(0, 0, 0)); - theBitmapContextMask1->SetBrushStyle(CGraphicsContext::ESolidBrush); - theBitmapContextMask1->DrawRect(theBitmapMask1->SizeInPixels()); - - theBitmapContextMask1->SetBrushColor(TRgb(255, 255, 255)); - theBitmapContextMask1->SetPenColor(TRgb(255, 255, 255)); - rect = TRect(theBitmapMask1->SizeInPixels()); - theBitmapContextMask1->SetPenSize(TSize(6,6)); - theBitmapContextMask1->DrawLine(TPoint(rect.iBr.iX/2, 0), TPoint(rect.iBr.iX/2, rect.iBr.iY)); - theBitmapContextMask1->DrawLine(TPoint(0, rect.iBr.iY/2), TPoint(rect.iBr.iX, rect.iBr.iY/2)); - - - TSpriteMember theSpriteList; - theSpriteList.iBitmap = theBitmapBall; - theSpriteList.iMaskBitmap = theBitmapMask; - theSpriteList.iInvertMask = EFalse; - theSpriteList.iDrawMode = CGraphicsContext::EDrawModePEN; - theSpriteList.iOffset = TPoint(0, 0); - theSpriteList.iInterval = TTimeIntervalMicroSeconds32(100000); - theSprite.AppendMember(theSpriteList); - - TSpriteMember theSpriteList1; - theSpriteList1.iBitmap = theBitmapBall; - theSpriteList1.iMaskBitmap = theBitmapMask1; - theSpriteList1.iInvertMask = EFalse; - theSpriteList1.iDrawMode = CGraphicsContext::EDrawModePEN; - theSpriteList1.iOffset = TPoint(0, 0); - theSpriteList1.iInterval = TTimeIntervalMicroSeconds32(100000); - - theSprite.AppendMember(theSpriteList1); - - theSprite.Activate(); - - for(TInt ii = 0; ii < 20; ii++) - { - theSpritePos += TPoint(3, 8); - theSprite.SetPosition(theSpritePos); - TheClient->iWs.Flush(); - User::After(TTimeIntervalMicroSeconds32(50000)); - } - - for(TInt jj = 0; jj < 20; jj++) - { - theSpritePos -= TPoint(0, 8); - theSprite.SetPosition(theSpritePos); - TheClient->iWs.Flush(); - User::After(TTimeIntervalMicroSeconds32(50000)); - } - - theSprite.Close(); - - delete theBitmapContextBall; - delete theBitmapDeviceBall; - - delete theBitmapBall; - - delete theBitmapMask; - delete theBitmapContextMask; - delete theBitmapDeviceMask; - - delete theBitmapMask1; - delete theBitmapContextMask1; - delete theBitmapDeviceMask1; - - __UHEAP_MARKEND; - } - -void CTWinAlphaForeground::CreateBackedWindowL() - { - RBackedUpWindow theBackedWindow(TheClient->iWs); - CleanupClosePushL(theBackedWindow); - - TDisplayMode theDisplayMode = EColor16MA; - - RWindow* theWin = (RWindow*) DrawableWin(); - - theBackedWindow.Construct(*theWin,theDisplayMode, ENullWsHandle); - - TPoint pos =TPoint(10, 10); - TSize size = theWin->Size(); - size.SetSize(size.iWidth / 5, size.iHeight/10); - - theBackedWindow.SetExtentErr(pos, size); - theBackedWindow.SetOrdinalPosition(0); - - - //draw to backed window - TRgb color = TRgb(255, 0, 128); - TInt bitmapHandle = theBackedWindow.BitmapHandle(); - CFbsBitmap bitmapWin; - bitmapWin.Duplicate(bitmapHandle); - //Leave poss here - theBackedWindow could leak - CFbsBitmapDevice* theBitmapDevice = CFbsBitmapDevice::NewL(&bitmapWin); - CGraphicsContext* theBitmapContext = NULL; - theBitmapDevice->CreateContext(theBitmapContext); - theBitmapContext->SetBrushColor(color); - theBitmapContext->SetPenColor(color); - theBitmapContext->SetBrushStyle(CGraphicsContext::ESolidBrush); - theBitmapContext->DrawRect(TRect(bitmapWin.SizeInPixels())); - - color = TRgb(0, 0, 0); - theBitmapContext->SetPenColor(color); - for(TInt kk = 0; kk < bitmapWin.SizeInPixels().iWidth; kk += 8) - { - theBitmapContext->DrawLine(TPoint(kk, 0), TPoint(kk, bitmapWin.SizeInPixels().iHeight)); - } - - - theBackedWindow.Activate(); - TheClient->iWs.Flush(); - User::After(TTimeIntervalMicroSeconds32(500000)); - - //hide the window - theBackedWindow.SetVisible(EFalse); - TheClient->iWs.Flush(); - User::After(TTimeIntervalMicroSeconds32(500000)); - theBackedWindow.SetVisible(ETrue); - TheClient->iWs.Flush(); - - for(TInt ii = 0; ii < 7; ii++) - { - User::After(TTimeIntervalMicroSeconds32(100000)); - pos.iX += 5; - pos.iY += 15; - - theBackedWindow.SetExtentErr(pos, size); - TheClient->iWs.Flush(); - } - - User::After(TTimeIntervalMicroSeconds32(500000)); - - //transparent color. don't expect it to work - pos.iX -= 5; - pos.iY -= 15; - - theBackedWindow.SetExtentErr(pos, size); - color = TRgb(255, 255, 128, 128); - theBitmapContext->SetBrushColor(color); - theBitmapContext->SetPenColor(color); - theBitmapContext->DrawRect(TRect(bitmapWin.SizeInPixels())); - TheClient->iWs.Flush(); - User::After(TTimeIntervalMicroSeconds32(500000)); - - //semi-transparent color - pos.iX -= 5; - pos.iY -= 15; - theBackedWindow.SetExtentErr(pos, size); - color = TRgb(255, 255, 128, 255); - theBitmapContext->SetBrushColor(color); - theBitmapContext->SetPenColor(color); - TheClient->iWs.Flush(); - User::After(TTimeIntervalMicroSeconds32(500000)); - - - CleanupStack::PopAndDestroy(); //bitmapWin - delete theBitmapContext; - delete theBitmapDevice; - - } - - -//------------------- -void CTWinAlpha::Draw() - { - CBitmapContext* theGc = TheClient->iGc; - TSize size = Size(); - - for(TInt ii = 0; ii < size.iHeight; ii += (20+iState)) - { - theGc->DrawLine(TPoint(0, ii), TPoint(size.iWidth, ii)); - } - } - -__WS_CONSTRUCT_STEP__(AlphaChannel) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TAlphaChannel.H --- a/windowing/windowserver/tauto/TAlphaChannel.H Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,218 +0,0 @@ - -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// TBITMAP.H -// -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef __TALPHACHANNEL_H__ -#define __TALPHACHANNEL_H__ - -#include "AUTO.H" -#include "../tlib/testbase.h" -#include "TGraphicsHarness.h" - -class CTAlphaChannel; - -/** - Introduces a base class for transparent windows (both background and foreground) -*/ -class CTWinAlpha : public CTWin - { -public: - void Draw(); //we have to overridden it to avoid panic in a based class -public: - TInt iState; - }; - -enum {ETransparencyFactor, ETransparencyAlpha, ENonTransparentAlpha}; - -/** - Introduces a foreground transparent windows. - In order to set any instance of class as transparent it has to be created with - ETransparencyAlpha parameter -*/ -class CTWinAlphaForeground : public CTWin - { -public: - static CTWinAlphaForeground* NewL(CTAlphaChannel& aTest, TPoint aPos, TSize aSize, - CTWinBase* aParent, CWindowGc& aGc, TDisplayMode* aMode, TRgb aCol, TInt aTransparencyType = ENonTransparentAlpha); - ~CTWinAlphaForeground(); - -private: - CTWinAlphaForeground(CTAlphaChannel& aTest); - -public: - void Draw(); - void SetBackgroundColor(TRgb aColor); - void SetDisplayMode(TDisplayMode aDisplayMode); - void StartAnimationL(); - void CreateBackedWindowL(); - inline void SetDrawOpaque(TBool aDrawOpaque = ETrue) - { - iDrawOpaque = aDrawOpaque; - } - -protected: - void DrawTable(CBitmapContext& aGc) const; - void DrawPrimitivesInCell(CBitmapContext& aGc, const TRect& aRect, - CFbsBitmap* aBitmap64K, CFbsBitmap* aBitmap16MA); - void DrawTextInCell(CBitmapContext& aGc, const TRect& aRect); - void PrepareForDrawingL(); - void CalculateTableMargin(); - void SetPoligonLocation(const TPoint &ptOffset); - void CreateBackgroundBitmapL(const TDisplayMode& aDispMode); - void CleanBackgroundBitmap(); - -protected: - TInt iRows[4]; - TInt iCol; // width of the first column - CFbsBitmap* iBitmapBackground; - CFbsBitmapDevice* iBitmapDeviceBackground; - CBitmapContext* iBitmapContextBackground; - TRgb iBackgroundColor; - CArrayFix* iPolygon; - TBuf<16> iTitle1; - TBuf<16> iTitle2; - TBool iDrawOpaque; // this value will set to CWindowGc before drawing, should have any effect on drawing with alpha channel - -private: - CTAlphaChannel& iTest; - }; - -/** Test base class, which exersices drawing graphics operations with alpha channel */ -class CTAlphaChannel : public CTWsGraphicsBase - { -friend class CTWinAlphaForeground; -public: - CTAlphaChannel(CTestStep* aStep); - ~CTAlphaChannel(); - void ConstructL(); - void DrawTestWindowsNow(TBool aDrawBackgroundWin = EFalse); - - void SetWindow64K(); - void SetOpaqueWindow16MA(); - void SetTransparentWindow16MA(); - TInt SetWindow16MAWithMask(); - TInt SetWindow64KWithMask(); - CGraphicsContext::TDrawMode GetDrawMode(TInt aIndex) const; - TRgb GetBrush(TInt aIndex) const; - TRgb GetPen(TInt aIndex) const; - - // test functions - void SetDisplayModeConfiguration(TInt aConfig); - void SetPositionConfiguration(TInt aConfig); - void SetColourConfiguration(TInt aConfig); - void DoMoving(); - void DoMoveBehind(); - void DoInvisibility(); - void TestMoving(); - void TestMovingOverlapping(); - void TestFading(); - void TestChangingTransparencyFactor(); - void TestInvisibility(); - void TestMoveUnderneath(); - void TestMoveBehindInvisible(); - void TestRedrawBehind(); - void TestAnimationL(); - void TestBackedWindowL(); - void TestEffectSetOpaque(); - void TestChildWindowL(); - void TestMultipleChildrenL(); - void TestTransparentMovingUnderOpaqueL(); - void TestSetOrdinalPosition(); - -protected: -//from CTGraphicsStep - virtual void RunTestCaseL(TInt aCurTestCase); - void CreateForegroundWindowsL(const TSize& aSize, TDisplayMode aMode); - void DestroyForegroundWindows(); - void DrawOffscreenBitmapsL(const TRgb& aPen, const TRgb& aBrush, - CGraphicsContext* aBitmapContext64K, CGraphicsContext* aBitmapContext16MA, - CFbsBitmap* aBitmap64K, CFbsBitmap* aBitmap16MA); - void CalculateSizePrimitives(const TSize& aSize); -protected: - TRgb iPenTable; - CGraphicsContext::TBrushStyle iBrushStyle; - CGraphicsContext::TPenStyle iPenStyle; - TSize iSizeForegroundWindow; -private: - CTWinAlpha* iBackgroundWindow; - CTWinAlphaForeground* iForegroundWindowBottom; - CTWinAlphaForeground* iForegroundWindowOpaque; - CTWinAlphaForeground* iForegroundWindowSemiTrans; - CTWinAlphaForeground* iForegroundWindowTrans; - CTWinAlphaForeground* iForegroundWindowTop; - - CArrayPtrFlat iArrWindow; - - - CFbsBitmap* iBitmap64K_1; - CFbsBitmap* iBitmap16MA_1; - CFbsBitmap* iBitmap64K_2; - CFbsBitmap* iBitmap16MA_2; - CFbsBitmap* iBitmap64K_3; - CFbsBitmap* iBitmap16MA_3; - CFbsBitmap* iBitmapMask; - CFbsBitmap* iBitmapGray256Mask; - - CFbsBitmapDevice* iBitmapDevice64K_1; - CFbsBitmapDevice* iBitmapDevice16MA_1; - CFbsBitmapDevice* iBitmapDevice64K_2; - CFbsBitmapDevice* iBitmapDevice16MA_2; - CFbsBitmapDevice* iBitmapDevice64K_3; - CFbsBitmapDevice* iBitmapDevice16MA_3; - - CGraphicsContext* iBitmapContext64K_1; - CGraphicsContext* iBitmapContext16MA_1; - CGraphicsContext* iBitmapContext64K_2; - CGraphicsContext* iBitmapContext16MA_2; - CGraphicsContext* iBitmapContext64K_3; - CGraphicsContext* iBitmapContext16MA_3; - - TBuf<256> iText; - CFont* iFont; // for true type font, needs to exercise anti-aliasing - CFont* iFont1; // title font - - TSize iBitmapSize; - TSize iRectangleSize; - TSize iEllipseSize ; - TSize iTriangleSize ; - TInt iFirstCellWidth ; - TInt iFirstCellHeight; - TBool iDrawText; // if true output text, graphics primitives otherwise - TBool iIsFading; - TUint8 iBlackFading; - TUint8 iWhiteFading; - }; - -class CTAlphaChannelStep : public CTGraphicsStep - { -public: - CTAlphaChannelStep(); -protected: - //from CTGraphicsStep - virtual CTGraphicsBase* CreateTestL(); - }; - -_LIT(KTAlphaChannelStep,"TAlphaChannel"); - - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TAnimDraw.h --- a/windowing/windowserver/tauto/TAnimDraw.h Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,20 +0,0 @@ -// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -#include -#include -#include "W32STD.H" - -GLREF_C void DoDraw(TInt aDraw,CBitmapContext& aGc,TRgb aColor,TRect aRect,CFbsFont *aFont=NULL,TInt aTextVal=0); diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TAnimdraw.cpp --- a/windowing/windowserver/tauto/TAnimdraw.cpp Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,47 +0,0 @@ -// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -#include "TAnimDraw.h" - -GLREF_C void DoDraw(TInt aDraw,CBitmapContext& aGc,TRgb aColor,TRect aRect,CFbsFont *aFont,TInt aTextVal) - { - switch (aDraw) - { - case 36: - { - aGc.Clear(); - aGc.SetPenSize(TSize(15,15)); - aGc.SetPenColor(aColor); - aGc.DrawLine(TPoint(aRect.iTl),TPoint(aRect.iBr)); - break; - } - case 37: - { - TBuf<3> buf; - buf.Format(_L("%d"), aTextVal); - aGc.Clear(); - aGc.SetDrawMode(CGraphicsContext::EDrawModePEN); - aGc.SetPenStyle(CGraphicsContext::ESolidPen); - aGc.SetPenSize(TSize(1,1)); - aGc.SetPenColor(aColor); - aGc.UseFont(aFont); - TInt drawHeight=aFont->AscentInPixels(); - aRect.iTl.iY=aRect.iBr.iY/3; - aGc.DrawText(buf,aRect,drawHeight,CGraphicsContext::ECenter); - break; - } - default:; - } - } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TBACKUPW.CPP --- a/windowing/windowserver/tauto/TBACKUPW.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,953 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Test backed up windows -// -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include "TBACKUPW.H" - -CTBackedUpWindow::CTBackedUpWindow(CTestStep* aStep): - CTWsGraphicsBase(aStep) - { - } - - -void CTBackedUpWindow::CheckWindow(CFbsBitmap *aBitmap) - { - TPoint oldPos=iBackedUpWindow.Position(); - iBackedUpWindow.SetPosition(TPoint(0,0)); - - iCheckWindow.SetVisible(ETrue); - iCheckWindow.SetPosition(iCheckPos); - - iCheckWindow.BeginRedraw(); - TheGc->Activate(iCheckWindow); - TheGc->BitBlt(TPoint(0,0), aBitmap); - TheGc->Deactivate(); - iCheckWindow.EndRedraw(); - - TheClient->iWs.Flush(); - TheClient->WaitForRedrawsToFinish(); - TBool retVal = TheClient->iScreen->RectCompare(TRect(iSize),TRect(iCheckPos,iSize)); - TEST(retVal); - if (!retVal) - INFO_PRINTF3(_L("TheClient->iScreen->RectCompare(TRect(iSize),TRect(iCheckPos,iSize)) return value - Expected: %d , Actual: %d"), ETrue, retVal); - - iCheckWindow.SetVisible(EFalse); - iBackedUpWindow.SetPosition(oldPos); - } - -void CTBackedUpWindow::CheckWindow() - { - CheckWindow(&iBitmap); - } - -void CTBackedUpWindow::Draw(TInt aDrawFunc, TAny *aParam) - { - TheGc->Activate(iBackedUpWindow); - Draw(aDrawFunc, aParam, TheGc, iBitGc); - TheGc->Deactivate(); - } - -void CTBackedUpWindow::DrawWithTwoGcsL() - { - RBlankWindow blank(TheClient->iWs); - User::LeaveIfError(blank.Construct(*(TheClient->iGroup->GroupWin()),ENullWsHandle)); - blank.Activate(); - CWindowGc *gc2; - User::LeaveIfError(TheClient->iScreen->CreateContext(gc2)); - CleanupStack::PushL(gc2); - - CFbsFont *font1; - TFontSpec fspec(KTestFontTypefaceName,200); - User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)font1,fspec)); - CFbsFont *font2; - TFontSpec fspec2(KTestFontTypefaceName,400); - User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)font2,fspec2)); - - gc2->Activate(iBackedUpWindow); - gc2->UseFont(font2); - TheGc->Activate(iBackedUpWindow); - TheGc->UseFont(font1); - _LIT(KText,"Testing123"); - TheGc->DrawText(KText,TPoint(20,20)); - gc2->DrawText(KText,TPoint(20,40)); - iBitGc->UseFont(font1); - iBitGc->DrawText(KText,TPoint(20,20)); - iBitGc->UseFont(font2); - iBitGc->DrawText(KText,TPoint(20,40)); - iBitGc->DiscardFont(); - TheGc->Deactivate(); - TheClient->iScreen->ReleaseFont(font2); - TheClient->iScreen->ReleaseFont(font1); - CleanupStack::PopAndDestroy(); - blank.Close(); - } - -void CTBackedUpWindow::Draw(TInt aDrawFunc, TAny *aParam, CBitmapContext *gc1, CBitmapContext *gc2) //DDD - { - CBitmapContext *gc; - for(TInt mode=0;mode<2;mode++) - { - if (mode==0) - gc=gc1; - else - gc=gc2; - gc->Reset(); - switch(aDrawFunc) - { - case 0: - gc->SetBrushColor(*((TRgb *)aParam)); - gc->SetBrushStyle(CGraphicsContext::ESolidBrush); - gc->SetPenStyle(CGraphicsContext::ENullPen); - gc->DrawRect(TRect(iSize)); - break; - case 1: - { - TSize half(iSize.iWidth/2,iSize.iHeight/2); - gc->DrawEllipse(TRect(half)); - gc->DrawEllipse(TRect(TPoint(0,half.iHeight),half)); - TRect rect1(half); - gc->SetOrigin(TPoint(half.iWidth,0)); - gc->SetClippingRect(rect1); - gc->DrawEllipse(rect1); - gc->SetOrigin(TPoint(half.iWidth,half.iHeight)); - gc->SetClippingRect(rect1); - gc->DrawEllipse(rect1); - gc->SetOrigin(TPoint(0,0)); - gc->CancelClippingRect(); - } - break; - case 2: - { - TInt param= *((TInt *)aParam); - if (param&0x1) - gc->DrawLine(TPoint(param+(param*27)%iSize.iWidth,0), - TPoint(iSize.iWidth-((param<<1)+(param*19)%iSize.iWidth),iSize.iHeight)); - else - gc->DrawLine(TPoint(0, (param<<1)+(param*7)%iSize.iHeight), - TPoint(iSize.iWidth,param+(param*13)%iSize.iHeight)); - } - break; - case 3: - { - TPoint pos; - for(;pos.iXDrawLine(pos,pos+TSize(0,iSize.iHeight)); - for(pos.iX=0;pos.iYDrawLine(pos,pos+TSize(iSize.iWidth,0)); - } - break; - } - } - } - -CTBackedUpWindow::~CTBackedUpWindow() - { - iBackedUpWindow.Close(); - iCheckWindow.Close(); - iOomFrontWindow.Close(); - delete iBitGc; - delete iBitmapDevice; - delete iTestBitmap; - delete iMaskBitmap; - } - -void CopyToGray4L(CFbsBitmap*& aDestBitmap,const CFbsBitmap& aSrcBitmap) - { - aDestBitmap=new(ELeave) CFbsBitmap(); - CleanupStack::PushL(aDestBitmap); - User::LeaveIfError(aDestBitmap->Create(aSrcBitmap.SizeInPixels(),EGray4)); - CFbsBitmapDevice* device=CFbsBitmapDevice::NewL(aDestBitmap); - CleanupStack::PushL(device); - CFbsBitGc* gc; - User::LeaveIfError(device->CreateContext(gc)); - gc->BitBlt(TPoint(),&aSrcBitmap); - delete gc; - CleanupStack::PopAndDestroy(device); - CleanupStack::Pop(aDestBitmap); - } - -void CTBackedUpWindow::ConstructL() - { - iBackedUpWindow=RBackedUpWindow(TheClient->iWs); - iBackedUpWindow.Construct(*(TheClient->iGroup->GroupWin()),EGray4,ENullWsHandle); - TSize size=TheClient->iScreen->SizeInTwips(); - iSize=TheClient->iScreen->SizeInPixels(); - iSize.iWidth>>=1; - iSize.iHeight>>=1; - size.iWidth>>=1; - size.iHeight>>=1; - size.iWidth-=1; //Modification to get the mapping factor the same as the screen - size.iHeight-=1; //Ditto - iWinPos.SetXY(iSize.iWidth>>1,iSize.iHeight>>1); - User::LeaveIfError(iBackedUpWindow.SetExtentErr(iWinPos,iSize)); - iBackedUpWindow.Activate(); - - iCheckPos.SetXY(iSize.iWidth,0); - iCheckWindow=RWindow(TheClient->iWs); - iCheckWindow.Construct(*(TheClient->iGroup->GroupWin()),ENullWsHandle); - iCheckWindow.SetSize(iSize); - iCheckWindow.SetVisible(EFalse); - iCheckWindow.Activate(); - - TInt col,grey; - TDisplayMode defMode=TheClient->iWs.GetDefModeMaxNumColors(col,grey); - User::LeaveIfError(iBitmap.Create(iSize,defMode)); - iBitmap.SetSizeInTwips(size); - iBitmapDevice=CFbsBitmapDevice::NewL(&iBitmap); - User::LeaveIfError(iBitmapDevice->CreateContext(iBitGc)); - - TRgb rgb(TRgb::Gray4(2)); - Draw(0,&rgb); - - iTestBitmap=new(ELeave) CFbsBitmap(); - User::LeaveIfError(iTestBitmap->Load(TEST_BITMAP_NAME,0)); - iTestBitmap->SetSizeInTwips(TSize(1500,750)); - iMaskBitmap=new(ELeave) CFbsBitmap(); - User::LeaveIfError(iMaskBitmap->Load(TEST_BITMAP_NAME,0)); - TDisplayMode defMode2=iMaskBitmap->DisplayMode(); - if (defMode>EGray4) - { - CFbsBitmap* bitmap=iTestBitmap; - CopyToGray4L(iTestBitmap,*bitmap); - delete bitmap; - bitmap=iMaskBitmap; - CopyToGray4L(iMaskBitmap,*bitmap); - delete bitmap; - } - defMode2=iMaskBitmap->DisplayMode(); - defMode2=iMaskBitmap->DisplayMode(); - } - -void CTBackedUpWindow::InvisVis() - { - iBackedUpWindow.SetVisible(EFalse); - TheClient->iWs.Flush(); - iBackedUpWindow.SetVisible(ETrue); - TheClient->iWs.Flush(); - } - -void CTBackedUpWindow::WindowOnTop() - { - RBlankWindow blank(TheClient->iWs); - blank.Construct(*(TheClient->iGroup->GroupWin()),ENullWsHandle); - blank.Activate(); - blank.Close(); - TheClient->iWs.Flush(); - - TPoint pos; - TInt sizeMode=0; - TInt draw=13; - - for(pos.iX=-iSize.iWidth;pos.iXiWs); - blank.Construct(*(TheClient->iGroup->GroupWin()),ENullWsHandle); - blank.SetColor(TRgb::Gray256(220)); - blank.SetShadowHeight(2); - blank.SetExtent(pos+iWinPos,TSize((sizeMode&0x1)?iSize.iWidth>>1:iSize.iWidth<<1,(sizeMode&0x2)?iSize.iHeight>>1:iSize.iHeight<<1)); - sizeMode=(sizeMode+1)%4; - blank.Activate(); - Draw(2,&draw); - TheClient->iWs.Flush(); - draw++; - blank.Close(); - } - } - -void CTBackedUpWindow::Resize() - { - RBlankWindow blank(TheClient->iWs); - blank.Construct(*(TheClient->iGroup->GroupWin()),ENullWsHandle); - blank.SetColor(TRgb::Gray256(128)); - blank.Activate(); - TInt xtop=(iSize.iWidth)-(iSize.iWidth>>2); - TInt ytop=(iSize.iHeight)-(iSize.iHeight>>2); - for(TInt winMode=0;winMode<3;winMode++) - { - switch(winMode) - { - case 0: - blank.SetExtent(TPoint(0,ytop),TSize(iSize.iWidth,iSize.iHeight>>1)); - break; - case 1: - blank.SetExtent(TPoint(xtop,0),TSize(iSize.iWidth>>1,iSize.iHeight)); - break; - case 2: - blank.SetExtent(TPoint(xtop,ytop),TSize(iSize.iWidth>>1,iSize.iHeight>>1)); - break; - } - blank.SetShadowHeight(winMode); - TPoint oldPos=iBackedUpWindow.Position(); - TPoint pos=oldPos; - for(TUint i=0;iiWs.Flush(); - } - iBackedUpWindow.SetPosition(oldPos); - } - blank.Close(); - } - -void CTBackedUpWindow::ChildWindows() - { - TPoint pos; - TInt sizeMode=0; - TInt draw=13; - RBlankWindow blank(TheClient->iWs); - for(pos.iX=-(iSize.iWidth>>1);pos.iX>1);pos.iY>2:iSize.iWidth,(sizeMode&0x2)?iSize.iHeight>>2:iSize.iHeight)); - sizeMode=(sizeMode+1)%4; - blank.Activate(); - Draw(2,&draw); - TheClient->iWs.Flush(); - draw++; - blank.Close(); - } - } - -void CTBackedUpWindow::DupBitmapTestL() - { - INFO_PRINTF1(_L("AUTO Dup Bitmap Test ")); - CFbsBitmap *dup=new(ELeave) CFbsBitmap(); - dup->Duplicate(iBackedUpWindow.BitmapHandle()); - CheckWindow(dup); - TRgb rgb(TRgb::Gray4(1)); - Draw(0,&rgb); - CheckWindow(dup); - INFO_PRINTF1(_L(" Done Window Drawing Test")); - - CFbsBitmapDevice *dupDevice=NULL; - TRAPD(err,dupDevice=CFbsBitmapDevice::NewL(dup)); - CFbsBitGc *gc; - if (err==KErrNone && dupDevice->CreateContext(gc)==KErrNone) - { - Draw(3,NULL,gc,iBitGc); // Draw directly to backup bitmap (and test bitmap) - iBackedUpWindow.UpdateScreen(); - INFO_PRINTF1(_L(" First Bitmap Drawing")); - CheckWindow(); - TRgb rgb(TRgb::Gray256(128)); - TInt col,grey; - if (TheClient->iWs.GetDefModeMaxNumColors(col,grey)>EGray4) - rgb=TRgb::Gray4(2); - Draw(0,&rgb,gc,iBitGc); - Draw(1,NULL,gc,iBitGc); - iBackedUpWindow.UpdateScreen(TRegionFix<1>(TRect(iSize))); - INFO_PRINTF1(_L(" Second Bitmap Drawing")); - CheckWindow(); - delete gc; - } - delete dupDevice; - delete dup; - } - -void CTBackedUpWindow::UpdateBitmapTestL() - { - INFO_PRINTF1(_L("AUTO UpdateBitmap ")); - CheckWindow(); - CFbsBitmap *dup=new(ELeave) CFbsBitmap(); - dup->Duplicate(iBackedUpWindow.BitmapHandle()); - Draw(3,NULL); - iBackedUpWindow.UpdateBackupBitmap(); - INFO_PRINTF1(_L(" First Drawing")); - CheckWindow(dup); - TRgb rgb; - if (iSupState==0) - rgb=TRgb::Gray256(128); - else - rgb=TRgb::Gray4(2); - Draw(0,&rgb); - Draw(1,NULL); - iBackedUpWindow.UpdateBackupBitmap(); - INFO_PRINTF1(_L(" Second Drawing")); - CheckWindow(dup); - delete dup; - } - -void CTBackedUpWindow::OOML() - { - iOomFrontWindow=RBlankWindow(TheClient->iWs); - TSize size(iBackedUpWindow.Size()); - size.iWidth>>=1; - size.iHeight>>=1; - TPoint pos(size.iWidth*3/2,size.iHeight*3/2); - iOomFrontWindow.Construct(*(TheClient->iGroup->GroupWin()),ENullWsHandle); - iOomFrontWindow.SetColor(TRgb(TRgb::Gray4(1))); - iOomFrontWindow.SetExtent(pos,size); - iOomFrontWindow.Activate(); - TheClient->iWs.Flush(); - - TPoint buwPos=iBackedUpWindow.Position(); - TSize buwSize=iBackedUpWindow.Size(); - for(TInt count=0;count<100;count++) - { - iOomFrontWindow.SetVisible(ETrue); - TheClient->iWs.HeapSetFail(RHeap::EDeterministic,count); - iBackedUpWindow.SetPosition(buwPos+TPoint(10,5)); - iBackedUpWindow.SetPosition(buwPos); - iOomFrontWindow.SetSize(size+TSize(10,5)); - iOomFrontWindow.SetSize(size); - iBackedUpWindow.SetSizeErr(buwSize+TSize(13,7)); - iBackedUpWindow.SetSizeErr(buwSize); - iOomFrontWindow.SetVisible(EFalse); - TheClient->iWs.HeapSetFail(RHeap::ENone,0); - User::LeaveIfError(iBackedUpWindow.SetSizeErr(buwSize)); - TheClient->WaitForRedrawsToFinish(); - CheckWindow(); - } - - iOomFrontWindow.Close(); - } - -void CTBackedUpWindow::doGraphicFunctionsL(CBitmapContext *gc,TBool aExtraDrawBitMap) - { - TSize size=iBackedUpWindow.Size(); - CFbsFont *aFont; - _LIT(KFontName,"Swiss"); - TFontSpec fspec(KFontName,190); - User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)aFont,fspec)); - CFbsBitmap* aBitmap=iTestBitmap; - CFbsBitmap* aMaskBitmap=iMaskBitmap; - - #include "DLLDRAW.H" // Draws to a Gc called 'gc' - - TheClient->iScreen->ReleaseFont(aFont); - } - -void CTBackedUpWindow::AllGraphicFunctionsL(RBlankWindow &aBlank,TBool aExtraDrawBitMap/*=ETrue*/) - { - aExtraDrawBitMap=EFalse; //Check out when bitblit scaling has changed again - aBlank.SetVisible(ETrue); - TheGc->Activate(iBackedUpWindow); - TRAPD(err,doGraphicFunctionsL(TheGc,aExtraDrawBitMap)); - TheGc->Deactivate(); - User::LeaveIfError(err); - iBitGc->Reset(); - iBitGc->SetUserDisplayMode(EGray4); - doGraphicFunctionsL(iBitGc,aExtraDrawBitMap); - aBlank.SetVisible(EFalse); - CheckWindow(); - } - -void CTBackedUpWindow::AllGraphicFunctionsTestsL() - { - RBlankWindow blank(TheClient->iWs); - TInt xtop=(iSize.iWidth)-(iSize.iWidth>>1); - TInt ytop=(iSize.iHeight)-(iSize.iHeight>>1); - blank.Construct(*(TheClient->iGroup->GroupWin()),ENullWsHandle); - blank.SetColor(TRgb::Gray256(128)); - blank.Activate(); - blank.SetExtent(TPoint(0,ytop),TSize(iSize.iWidth,iSize.iHeight>>2)); - AllGraphicFunctionsL(blank); - blank.SetExtent(TPoint(0,ytop+10),TSize(iSize.iWidth,iSize.iHeight>>2)); - AllGraphicFunctionsL(blank); - blank.SetExtent(TPoint(xtop,ytop),TSize(iSize.iWidth>>1,iSize.iHeight)); - AllGraphicFunctionsL(blank,EFalse); - blank.SetExtent(TPoint(xtop+(iSize.iWidth>>1),ytop),TSize(iSize.iWidth>>1,iSize.iHeight)); - AllGraphicFunctionsL(blank,EFalse); - blank.SetExtent(TPoint(xtop+10,iSize.iHeight),TSize(iSize.iWidth,iSize.iHeight)); - AllGraphicFunctionsL(blank,EFalse); - blank.SetExtent(TPoint(xtop,ytop),iSize); - AllGraphicFunctionsL(blank,EFalse); - blank.SetExtent(TPoint(0,0),TSize(0,0)); - AllGraphicFunctionsL(blank); - blank.Close(); - } - -void CTBackedUpWindow::RunTestCaseL(TInt /*aCurTestCase*/) - { - switch(iSupState) - { - case 0: - for (TInt iSubTest=0;iSubTestiState=iState; -((CTBackedUpWindowStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); - switch(iState) - { -/** -@SYMTestCaseID GRAPHICS-WSERV-0202-0001 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test drawing in a backed up window - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Draw in a backed up window and a normal window and check - the two drawings are the same - -@SYMTestExpectedResults The two drawings are exactly the same -*/ - case 0: - ((CTBackedUpWindowStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0202-0001")); - iTest->LogSubTest(KTest0); - Draw(1,NULL); - CheckWindow(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0202-0002 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test drawing in a backed up window - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Draw in a backed up window and a normal window and check - the two drawings are the same - -@SYMTestExpectedResults The two drawings are exactly the same -*/ - case 1: - ((CTBackedUpWindowStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0202-0002")); - iTest->LogSubTest(KTest1); - Draw(0,&rgb1); - Draw(3,NULL); - Resize(); - CheckWindow(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0203 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test making a backed up window invisible - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Draw in a backed up window and a normal window, make - the backed up window invisible then visible and - then check the two drawings are the same - -@SYMTestExpectedResults The two drawings are exactly the same -*/ - case 2: - ((CTBackedUpWindowStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0203")); - iTest->LogSubTest(KTest2); - Draw(0,&rgb2); - Draw(1,NULL); - InvisVis(); - CheckWindow(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0204 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test drawing in a backed up window and then placing a - window on top of it - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Draw in a backed up window and a normal window, then - place a window on top of the backed up window and then - check the two drawings are the same - -@SYMTestExpectedResults The two drawings are exactly the same -*/ - case 3: - ((CTBackedUpWindowStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0204")); - iTest->LogSubTest(KTest3); - //TRgb rgb(220,220,220); - Draw(0,&rgb3); - Draw(1,NULL); - WindowOnTop(); - CheckWindow(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0205 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test drawing in a backed up window and then drawing in - a child window - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Draw in a backed up window and a normal window, then - create and draw in a child window and then - check the two original drawings are the same - -@SYMTestExpectedResults The two drawings are exactly the same -*/ - case 4: - ((CTBackedUpWindowStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0205")); - iTest->LogSubTest(KTest4); - Draw(0,&rgb4); - Draw(3,NULL); - ChildWindows(); - CheckWindow(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0206 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Out of memeory test for backed up windows - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Out of memeory test for backed up windows - -@SYMTestExpectedResults Backed up window responds correctly when out - of memory -*/ - case 5: - ((CTBackedUpWindowStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0206")); - iTest->LogSubTest(KTest5); - if (!iTest->IsFullRomL()) - { - Draw(0,&rgb5); - Draw(3,NULL); - OOML(); - CheckWindow(); - } - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0207 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test updating a bitmap in a backed up window - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Update a bitmap in a backed up window and a normal window - and check the two bitmaps are the same - -@SYMTestExpectedResults The two bitmaps are exactly the same -*/ - case 6: - ((CTBackedUpWindowStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0207")); - iTest->LogSubTest(KTest6); - Draw(0,&rgb6); - Draw(1,NULL); - UpdateBitmapTestL(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0208 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test updating a duplicate bitmap in a backed up window - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Update a duplicated bitmap in a backed up window and a normal window - and check the two bitmaps are the same - -@SYMTestExpectedResults The two bitmaps are exactly the same -*/ - case 7: - ((CTBackedUpWindowStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0208")); - if (iSupState==0) //Will fail unless the window is fully backup. - break; - iTest->LogSubTest(KTest7); - Draw(0,&rgb7); - Draw(1,NULL); - DupBitmapTestL(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0209 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test drawing with two graphic contexts in a backed up window - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Draw using two graphic contexts in a backed up window and a normal - window and check the two drawings are the same - -@SYMTestExpectedResults The two drawings are exactly the same -*/ - case 8: - ((CTBackedUpWindowStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0209")); - iTest->LogSubTest(KTest8); - Draw(0,&color); - Draw(1,NULL); - DrawWithTwoGcsL(); - CheckWindow(); - break; - -/** -@SYMTestCaseID GRAPHICS-WSERV-0210 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test drawing using all the graphic functions in a backed up window - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Draw using all the graphic functions in a backed up window and a normal - window and check the two drawings are the same - -@SYMTestExpectedResults The two drawings are exactly the same -*/ - case 9: - ((CTBackedUpWindowStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0210")); - iTest->LogSubTest(KTest9); - if(TheClient->iScreen->SizeInPixels() == TSize(640,240)) - AllGraphicFunctionsTestsL(); - break; - - //A Coverage test, nothing spectacular just making the code - //go into CWsGc::Reactivate - case 10: - { -/** -@SYMTestCaseID GRAPHICS-WSERV-0502 -*/ - ((CTBackedUpWindowStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0502")); - iTest->LogSubTest(KTest10); - TheGc->Deactivate(); - RBackedUpWindow extentWindow; - extentWindow=RBackedUpWindow(TheClient->iWs); - extentWindow.Construct(*(TheClient->iGroup->GroupWin()),EGray4,ENullWsHandle); - TheGc->Activate(extentWindow); - TheClient->Flush(); - User::LeaveIfError(extentWindow.SetExtentErr(TPoint(2,2), TSize(4,4))); - extentWindow.Activate(); - extentWindow.Close(); - TheGc->Deactivate(); - break; - } - - //Coverage for various messages for CWsGc::DoDrawCommand - case 11: - { -/** -@SYMTestCaseID GRAPHICS-WSERV-0507 -*/ - ((CTBackedUpWindowStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0507")); - iTest->LogSubTest(KTest11); - TheGc->Activate(iBackedUpWindow); - TheGc->Reset(); - iBitGc->Reset(); - iBitGc->SetUserDisplayMode(EGray4); - - // EWsGcOpDrawWsGraphic - TheGc->DrawWsGraphic(TWsGraphicId(0), TRect(0,0,10,10)); - - //create a large junk buffer so that messages with Ptr suffix will be sent - RBuf8 junkBuf8; - RBuf junkBuf; - junkBuf8.CreateMax(650); // a large enough buffer to sent as Ptr (this value used to crash the code before) - junkBuf.CreateMax(650); // a large enough buffer to sent as Ptr - for (int i=0; iDrawWsGraphic(TWsGraphicId(0), TRect(0,0,10,10), junkBuf8); - - // Set font for drawing on screen - CFbsFont *font1; - TFontSpec fspec(KTestFontTypefaceName,200); - User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)font1,fspec)); - TheGc->UseFont(font1); - iBitGc->UseFont(font1); - - // EWsGcOpDrawTextPtr - TheGc->DrawText(junkBuf, TPoint(0,0)); - iBitGc->DrawText(junkBuf, TPoint(0,0)); - - // EWsGcOpDrawBoxText - unreachable 299-too lo, 300-too hi - - // EWsGcOpDrawBoxTextPtr - TheGc->DrawText(junkBuf, TRect(0,0,10,10), 0, CGraphicsContext::ELeft, 0); - iBitGc->DrawText(junkBuf, TRect(0,0,10,10), 0, CGraphicsContext::ELeft, 0); - - // EWsGcOpDrawTextVerticalPtr - TheGc->DrawTextVertical(junkBuf, TPoint(0,0), ETrue); - iBitGc->DrawTextVertical(junkBuf, TPoint(0,0), ETrue); - - // EWsGcOpDrawBoxTextVerticalPtr - TheGc->DrawTextVertical(junkBuf, TRect(0,0,10,10), 0, ETrue, CGraphicsContext::ELeft, 0); - iBitGc->DrawTextVertical(junkBuf, TRect(0,0,10,10), 0, ETrue, CGraphicsContext::ELeft, 0); - - // EWsGcOpMoveBy - TheGc->MoveBy(TPoint(2,2)); - iBitGc->MoveBy(TPoint(2,2)); - - // a bitmap for bitblt ops - CWsBitmap bmp(TheClient->iWs); - bmp.Create(TSize(16,16), iBackedUpWindow.DisplayMode()); - - // EWsGcOpGdiWsBlt2 - TheGc->BitBlt(TPoint(0,0), &bmp); - iBitGc->BitBlt(TPoint(0,0), &bmp); - - // EWsGcOpGdiWsBlt3 - TheGc->BitBlt(TPoint(0,0), &bmp, TRect(0,0,10,10)); - iBitGc->BitBlt(TPoint(0,0), &bmp, TRect(0,0,10,10)); - - // EWsGcOpGdiWsBltMasked - TheGc->BitBltMasked(TPoint(0,0), &bmp, TRect(0,0,10,10), &bmp, EFalse); - iBitGc->BitBltMasked(TPoint(0,0), &bmp, TRect(0,0,10,10), &bmp, EFalse); - - // EWsGcOpGdiWsAlphaBlendBitmaps - TheGc->AlphaBlendBitmaps(TPoint(0,0), &bmp, TRect(0,0,10,10), &bmp, TPoint(1,1)); - iBitGc->AlphaBlendBitmaps(TPoint(0,0), &bmp, TRect(0,0,10,10), &bmp, TPoint(1,1)); - - // EWsGcOpWsDrawBitmapMasked - TheGc->DrawBitmapMasked(TRect(0,0,10,10), &bmp, TRect(0,0,8,8), &bmp, ETrue); - iBitGc->DrawBitmapMasked(TRect(0,0,10,10), &bmp, TRect(0,0,8,8), &bmp, ETrue); - - // EWsGcOpDrawBitmap - TheGc->DrawBitmap(TPoint(0,0), &bmp); - iBitGc->DrawBitmap(TPoint(0,0), &bmp); - - // EWsGcOpDrawBitmapMasked - TheGc->DrawBitmapMasked(TRect(0,0,10,10), static_cast(&bmp), - TRect(0,0,8,8), static_cast(&bmp), - EFalse); - iBitGc->DrawBitmapMasked(TRect(0,0,10,10), static_cast(&bmp), - TRect(0,0,8,8), static_cast(&bmp), - EFalse); - - // EWsGcOpDrawPolyLineContinued - TheGc->DrawPolyLine(reinterpret_cast(junkBuf8.Ptr()), - TInt(junkBuf8.Size()/sizeof(TPoint))); - iBitGc->DrawPolyLine(reinterpret_cast(junkBuf8.Ptr()), - TInt(junkBuf8.Size()/sizeof(TPoint))); - - // EWsGcOpCopyRect - TheGc->CopyRect(TPoint(0,0), TRect(0,0,10,10)); - iBitGc->CopyRect(TPoint(0,0), TRect(0,0,10,10)); - - //cleanup - TheClient->Flush(); - TheGc->DiscardFont(); - iBitGc->DiscardFont(); - TheClient->iScreen->ReleaseFont(font1); - junkBuf.Close(); - junkBuf8.Close(); - TheGc->Deactivate(); - - CheckWindow(); - - //the following have no client equivalent methods - // EWsGcOpMapColorsLocal - // EWsGcOpDrawPolyLineLocalBufLen - // EWsGcOpDrawPolyLineLocal - // EWsGcOpDrawPolygonLocalBufLen - // EWsGcOpDrawPolygonLocal - // EWsGcOpDrawBitmapLocal - // EWsGcOpDrawBitmap2Local - // EWsGcOpDrawBitmap3Local - // EWsGcOpDrawBitmapMaskedLocal - // EWsGcOpDrawTextPtr1 - // EWsGcOpDrawBoxTextPtr1 - // EWsGcOpDrawTextVerticalPtr1 - // EWsGcOpDrawBoxTextVerticalPtr1 - // EWsGcOpDrawTextLocal - // EWsGcOpDrawBoxTextLocal - // EWsGcOpGdiBlt2Local - // EWsGcOpGdiBlt3Local - // EWsGcOpGdiBltMaskedLocal - ((CTBackedUpWindowStep*)iStep)->CloseTMSGraphicsStep(); - break; - } - - default: - ((CTBackedUpWindowStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - ((CTBackedUpWindowStep*)iStep)->CloseTMSGraphicsStep(); - break; - } - ((CTBackedUpWindowStep*)iStep)->RecordTestResultL(); - } - -__WS_CONSTRUCT_STEP__(BackedUpWindow) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TBACKUPW.H --- a/windowing/windowserver/tauto/TBACKUPW.H Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,93 +0,0 @@ - -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef __TBACKUPW_H__ -#define __TBACKUPW_H__ - -#include -#include -#include "../tlib/testbase.h" -#include -#include "AUTO.H" -#include "TGraphicsHarness.h" - -const TInt KLastSubtest = 13; - -class CTBackedUpWindow : public CTWsGraphicsBase - { -public: - CTBackedUpWindow(CTestStep* aStep); - ~CTBackedUpWindow(); - void DoTestL(); - void DoSubTestL(TInt iState); - void CheckWindow(); - void CheckWindow(CFbsBitmap *aBitmap); - void Draw(TInt aDrawFunc, TAny *aParam); - void Draw(TInt aDrawFunc, TAny *aParam, CBitmapContext *aGc1, CBitmapContext *aGc2); - void DrawWithTwoGcsL(); - void ConstructL(); - void InvisVis(); - void WindowOnTop(); - void Resize(); - void ChildWindows(); - void DupBitmapTestL(); - void UpdateBitmapTestL(); - void OOML(); - void TestPanicsL(); - void doGraphicFunctionsL(CBitmapContext *gc,TBool aExtraDrawBitMap); - void AllGraphicFunctionsL(RBlankWindow &aBlank,TBool aExtraDrawBitMap=ETrue); - void AllGraphicFunctionsTestsL(); -protected: -//from CTGraphicsStep - virtual void RunTestCaseL(TInt aCurTestCase); -private: - TInt iSupState; - TSize iSize; - TPoint iCheckPos; - TPoint iWinPos; - RWindow iCheckWindow; - RBackedUpWindow iBackedUpWindow; - RBlankWindow iOomFrontWindow; - CFbsBitmap iBitmap; - CFbsBitGc *iBitGc; - CFbsDevice *iBitmapDevice; - CFbsBitmap* iTestBitmap; - CFbsBitmap* iMaskBitmap; - }; - -LOCAL_D const TPoint moveList[]={TPoint(1,0),TPoint(10,20),TPoint(-50,0),TPoint(30,-1),TPoint(-1000,20)}; - - - -class CTBackedUpWindowStep : public CTGraphicsStep - { -public: - CTBackedUpWindowStep(); -protected: - //from CTGraphicsStep - virtual CTGraphicsBase* CreateTestL(); - }; - -_LIT(KTBackedUpWindowStep,"TBackedUpWindow"); - - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TBITMAP.CPP --- a/windowing/windowserver/tauto/TBITMAP.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,226 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Test the window server bitmap class -// Test the window server bitmap class -// -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include "TBITMAP.H" - -// - -CTBitmap::CTBitmap(CTestStep* aStep): - CTWsGraphicsBase(aStep) - { - } - -CTBitmap::~CTBitmap() - { - delete iBitmap1; - delete iBitmap2; - } - -void CTBitmap::ConstructL() - { - } - -void CTBitmap::BasicTestsL() - { - iBitmap1=new(ELeave) CWsBitmap(TheClient->iWs); - iBitmap2=new(ELeave) CWsBitmap(TheClient->iWs); - User::LeaveIfError(iBitmap1->Create(TSize(20,10),EGray4)); -// Re-create should close previous Create - User::LeaveIfError(iBitmap1->Create(TSize(20,10),EGray4)); - User::LeaveIfError(iBitmap2->Duplicate(iBitmap1->Handle())); - TEST(iBitmap1->SizeInPixels()==iBitmap2->SizeInPixels()); - - TInt err=iBitmap2->Load(_L("NOTEXIST.XXX"),0); - TEST(err==KErrNotFound || err==KErrPathNotFound); - if (err!=KErrNotFound && err!=KErrPathNotFound) - INFO_PRINTF4(_L("Bitmap2->Load(_L(NOTEXIST.XXX),0) return value - Expected: %d or %d , Actual: %d"), KErrNotFound, KErrPathNotFound, err); - - TInt retVal = iBitmap2->Handle(); - TEST(retVal==0); - if (retVal!=0) - INFO_PRINTF3(_L("iBitmap2->Handle() return value - Expected: %d , Actual: %d"), 0, retVal); - - RFs fs; - User::LeaveIfError(fs.Connect()); - fs.SetNotifyUser(EFalse); - TInt ret=fs.MkDir(SAVE_BITMAP_NAME); - if (ret!=KErrNone && ret!=KErrAlreadyExists && ret!=KErrPathNotFound) - User::Leave(ret); - fs.Close(); -// - retVal = iBitmap1->Save(SAVE_BITMAP_NAME); - TEST(retVal==KErrNone); - if (retVal!=KErrNone) - INFO_PRINTF3(_L("iBitmap1->Save(SAVE_BITMAP_NAME) return value - Expected: %d , Actual: %d"), KErrNone, retVal); - - retVal = iBitmap2->Load(SAVE_BITMAP_NAME,0); - TEST(retVal==KErrNone); - if (retVal!=KErrNone) - INFO_PRINTF3(_L("iBitmap2->Load(SAVE_BITMAP_NAME,0) return value - Expected: %d , Actual: %d"), KErrNone, retVal); - - TEST(iBitmap1->SizeInPixels()==iBitmap2->SizeInPixels()); - } - - -void CTBitmap::TestFixForPDEF098889L() - { - TRequestStatus status; - TThreadParams params; - params.iScreenNr = TheClient->iWs.GetFocusScreen(); - - RThread thread1; - params.iFunction = Function1PDEF098889L; - TEST(thread1.Create(_L("PDEF098889_1"), ThreadFunction, 0x1000, NULL, ¶ms)==KErrNone); - thread1.Logon(status); - thread1.Resume(); - User::WaitForRequest(status); - TEST(status==KErrNone); - TEST(thread1.ExitType()==EExitKill); - thread1.Close(); - - RThread thread2; - params.iFunction = Function2PDEF098889L; - TEST(thread2.Create(_L("PDEF098889_2"), ThreadFunction, 0x1000, NULL, ¶ms)==KErrNone); - thread2.Logon(status); - thread2.Resume(); - User::WaitForRequest(status); - TEST(status==KErrNone); - TEST(thread2.ExitType()==EExitKill); - thread2.Close(); - } - -TInt CTBitmap::ThreadFunction(TAny* aParams) - { - CTrapCleanup *trap = CTrapCleanup::New(); - __ASSERT_ALWAYS(trap, User::Invariant()); - RWsSession session; - TInt err = session.Connect(); - if (err == KErrNone) - { - CWsScreenDevice *device = new CWsScreenDevice(session); - if (device) - { - err = device->Construct(static_cast(aParams)->iScreenNr); - if (err == KErrNone) - { - TRAP(err, static_cast(aParams)->iFunction(session, *device)); - } - delete device; - } - else - err = KErrNoMemory; - session.Close(); - } - delete trap; - return err; - } - -void CTBitmap::Function1PDEF098889L(RWsSession& aSession, CWsScreenDevice& aDevice) - { - CWindowGc *gc; - User::LeaveIfError(aDevice.CreateContext(gc)); - CleanupStack::PushL(gc); - RWindowGroup group(aSession); - User::LeaveIfError(group.Construct(1, EFalse)); - CWsBitmap *bitmap = new(ELeave) CWsBitmap(aSession); - CleanupStack::PushL(bitmap); - User::LeaveIfError(bitmap->Create(TSize(32, 32), EGray256)); - RWindow window(aSession); - User::LeaveIfError(window.Construct(group, 2)); - window.SetExtent(TPoint(0,0), TSize(32, 32)); - User::LeaveIfError(window.SetRequiredDisplayMode(EColor64K)); - window.Activate(); - window.BeginRedraw(); - gc->Activate(window); - gc->BitBlt(TPoint(0, 0), bitmap); - gc->Deactivate(); - window.EndRedraw(); - CleanupStack::PopAndDestroy(bitmap); - aSession.Flush(); - CleanupStack::PopAndDestroy(gc); - } - -void CTBitmap::Function2PDEF098889L(RWsSession& aSession, CWsScreenDevice& /*aDevice*/) - { - RWindowGroup group(aSession); - User::LeaveIfError(group.Construct(1, EFalse)); - CWsBitmap *bitmap = new(ELeave) CWsBitmap(aSession); - CleanupStack::PushL(bitmap); - User::LeaveIfError(bitmap->Create(TSize(32, 32), EGray256)); - RWindow window(aSession); - User::LeaveIfError(window.Construct(group, 2)); - window.SetExtent(TPoint(0,0), TSize(32, 32)); - User::LeaveIfError(window.SetRequiredDisplayMode(EColor64K)); - User::LeaveIfError(window.SetTransparencyWsBitmap(*bitmap)); - window.Activate(); - CleanupStack::PopAndDestroy(bitmap); - aSession.Flush(); - } - -void CTBitmap::RunTestCaseL(TInt /*aCurTestCase*/) - { - ((CTBitmapStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); - switch(++iTest->iState) - { -/** -@SYMTestCaseID GRAPHICS-WSERV-0201 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test basic bitmap functionality - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Test that bitmaps can be loaded, copied and saved - correctly - -@SYMTestExpectedResults The bitmaps are manipulated withotu error -*/ - case 1: - ((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0201")); - iTest->LogSubTest(_L("Bitmap1")); - BasicTestsL(); - break; - case 2: -/** -@SYMTestCaseID GRAPHICS-WSERV-0532 -*/ - ((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0532")); - if (TransparencySupportedL()==KErrNotSupported) - return; - iTest->LogSubTest(_L("Test fix for PDEF098889")); - TestFixForPDEF098889L(); - break; - default: - ((CTBitmapStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - ((CTBitmapStep*)iStep)->CloseTMSGraphicsStep(); - TestComplete(); - break; - } - ((CTBitmapStep*)iStep)->RecordTestResultL(); - } - -__WS_CONSTRUCT_STEP__(Bitmap) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TBITMAP.H --- a/windowing/windowserver/tauto/TBITMAP.H Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,71 +0,0 @@ - -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef __TBITMAP_H__ -#define __TBITMAP_H__ - -#include -#include -#include "../tlib/testbase.h" -#include "AUTO.H" -#include "TGraphicsHarness.h" - -#define SAVE_BITMAP_NAME _L("C:\\WSTEST\\SAVE.PBM") - -class CTBitmap : public CTWsGraphicsBase - { -public: - CTBitmap(CTestStep* aStep); - ~CTBitmap(); - void ConstructL(); - void BasicTestsL(); - void TestFixForPDEF098889L(); -private: - struct TThreadParams - { - TInt iScreenNr; - void (*iFunction)(RWsSession& aSession, CWsScreenDevice& aDevice); - }; - static TInt ThreadFunction(TAny* aParams); - static void Function1PDEF098889L(RWsSession& aSession, CWsScreenDevice& aDevice); - static void Function2PDEF098889L(RWsSession& aSession, CWsScreenDevice& aDevice); -protected: -//from CTGraphicsStep - virtual void RunTestCaseL(TInt aCurTestCase); -private: - CWsBitmap *iBitmap1; - CWsBitmap *iBitmap2; - }; - -class CTBitmapStep : public CTGraphicsStep - { -public: - CTBitmapStep(); -protected: - //from CTGraphicsStep - virtual CTGraphicsBase* CreateTestL(); - }; - -_LIT(KTBitmapStep,"TBitmap"); - - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TBLANK.CPP --- a/windowing/windowserver/tauto/TBLANK.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,271 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Test blank windows -// -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - - -#include "TBLANK.H" - - -CBaseWindow::CBaseWindow() : CTWin() - {} - -void CBaseWindow::ConstructL(CTWinBase &parent) - { - CTWin::ConstructL(parent); - } - -void CBaseWindow::Draw() - { - iGc->SetBrushColor(iRgb); - iGc->Clear(); - } - -void CBaseWindow::SetColor(const TRgb &aRgb) - { - iRgb=aRgb; - iGc->Activate(iWin); - Draw(); - iGc->Deactivate(); - } - -// - -TInt DestructCallbackBlank(TAny *aParam) - { - ((CTBlank *)aParam)->doDestruct(); - return(0); - } - - -CTBlank::CTBlank(CTestStep* aStep): - CTWsGraphicsBase(aStep) - { - INFO_PRINTF1(_L("Testing TBlank functions")); - } - -void CTBlank::doDestruct() - { - BaseWin->SetVisible(ETrue); - TestWin->SetVisible(ETrue); - delete iBaseWin; - delete iTestWin; - iBaseWin = NULL; - iTestWin = NULL; -// CActiveScheduler::Stop(); - } - -CTBlank::~CTBlank() - { - TCallBack callBack(DestructCallbackBlank,this); - TheClient->SetRedrawCancelFunction(callBack); -// CActiveScheduler::Start(); - } - -void CTBlank::ConstructL() - { - BaseWin->SetVisible(EFalse); - TestWin->SetVisible(EFalse); - } - -void CTBlank::SetColor(const TRgb &aRgb) - { - iTestWin->SetColor(aRgb); - iBaseWin->SetColor(aRgb); - } - -void CTBlank::InvalidateTestWin(const TRect &aRect) - { - TRect rect(aRect); - rect.Move(iTestWin->BaseWin()->InquireOffset(*(TheClient->iGroup->WinTreeNode()))); - CTUser::Splat(TheClient, rect,TRgb(0,0,0)); - } - -void CTBlank::CheckBlankWindows() - { - User::Heap().Check(); - CheckRect(iBaseWin,iTestWin,TRect(BaseWin->Size()),_L("CheckBlankWindows - CheckRect(iBaseWin,iTestWin,TRect(BaseWin->Size()) failed")); - } - -void CTBlank::RunTestCaseL(TInt /*aCurTestCase*/) - { - TSize screenSize; - TInt winWidth; - TInt winHeight; - ((CTBlankStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); - - switch(++iTest->iState) - { -/** -@SYMTestCaseID GRAPHICS-WSERV-0022 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Create a base and test blank windows and invalidate an - area of the test window - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Two windows are created and an area of a window is - invalidated - -@SYMTestExpectedResults Windows create and invalidate without error -*/ - case 1: - ((CTBlankStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0022")); - iTest->LogSubTest(_L("Blank 1")); - screenSize=TheClient->iGroup->Size(); - winWidth=(screenSize.iWidth/3)-10; - winHeight=screenSize.iHeight-10; - iBaseWin=new(ELeave) CBaseWindow(); - iBaseWin->SetUpL(TPoint(screenSize.iWidth/3+5,5),TSize(winWidth,winHeight),TheClient->iGroup,*TheClient->iGc); - iBaseWin->SetColor(TRgb(255,255,255)); - iTestWin=new(ELeave) CTBlankWindow(); - iTestWin->SetUpL(TPoint(screenSize.iWidth/3*2+5,5),TSize(winWidth,winHeight),TheClient->iGroup,*TheClient->iGc); - SetColor(TRgb::Gray4(2)); - InvalidateTestWin(TRect(10,10,50,50)); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0023 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Check that a base blank window is the same as a - test window which has had an area invalidated - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Check the test window is the same as the base window - -@SYMTestExpectedResults The windows are identical -*/ - case 2: - ((CTBlankStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0023")); - iTest->LogSubTest(_L("Check Blank 1")); - CheckBlankWindows(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0024 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Set a color and invalidate two areas of a test blank - window - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Invalidate two areas of a test blank window - -@SYMTestExpectedResults The window areas are invalidated without error -*/ - case 3: - ((CTBlankStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0024")); - iTest->LogSubTest(_L("Blank 2")); - SetColor(TRgb(0,0,0)); - InvalidateTestWin(TRect(1,1,150,20)); - InvalidateTestWin(TRect(10,-10,20,90)); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0025 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Check a base blank window is identical to a test - blank window which has had two areas invalidated - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Check the test window is the same as the base window - -@SYMTestExpectedResults The windows are identical -*/ - case 4: - ((CTBlankStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0025")); - iTest->LogSubTest(_L("Check Blank 2")); - CheckBlankWindows(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0026 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Set a color and invalidate three areas of a test blank - window - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Invalidate three areas of a test blank window - -@SYMTestExpectedResults The window areas are invalidated without error -*/ - case 5: - ((CTBlankStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0026")); - iTest->LogSubTest(_L("Blank 3")); - SetColor(TRgb(255,255,255)); - InvalidateTestWin(TRect(-1000,100,1000,120)); - InvalidateTestWin(TRect(1,1,150,20)); - InvalidateTestWin(TRect(10,30,20,60)); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0027 - -@@SYMDEF DEF081259 - -@SYMTestCaseDesc Check a base blank window is identical to a test - blank window which has had three areas invalidated - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Check the test window is the same as the base window - -@SYMTestExpectedResults The windows are identical -*/ - case 6: - ((CTBlankStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0027")); - iTest->LogSubTest(_L("Check Blank 3")); - CheckBlankWindows(); - delete iBaseWin; - delete iTestWin; - iBaseWin = NULL; - iTestWin = NULL; - break; - case 7: - ((CTBlankStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - ((CTBlankStep*)iStep)->CloseTMSGraphicsStep(); - TestComplete(); - break; - } - ((CTBlankStep*)iStep)->RecordTestResultL(); - } - -__WS_CONSTRUCT_STEP__(Blank) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TBLANK.H --- a/windowing/windowserver/tauto/TBLANK.H Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,76 +0,0 @@ - -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef __TBLANK_H__ -#define __TBLANK_H__ - -#include -#include -#include "../tlib/testbase.h" -#include "AUTO.H" -#include "TGraphicsHarness.h" - -class CBaseWindow : public CTWin - { -public: - CBaseWindow(); - void ConstructL(CTWinBase &parent); - virtual void Draw(); - void SetColor(const TRgb &aRgb); -private: - TRgb iRgb; - }; - -class CTBlank : public CTWsGraphicsBase - { -public: - CTBlank(CTestStep* aStep); - ~CTBlank(); -protected: -//from CTGraphicsStep - virtual void RunTestCaseL(TInt aCurTestCase); -public: - void doDestruct(); - void ConstructL(); - void InvalidateTestWin(const TRect &aRect); - void CheckBlankWindows(); - void SetColor(const TRgb &aRgb); -private: - TBool iDoCheck; - TSize iWinSize; - CBaseWindow *iBaseWin; - CTBlankWindow *iTestWin; - }; - -class CTBlankStep : public CTGraphicsStep - { -public: - CTBlankStep(); -protected: - //from CTGraphicsStep - virtual CTGraphicsBase* CreateTestL(); - }; - -_LIT(KTBlankStep,"TBlank"); - - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TBUFFERSECURITY.CPP --- a/windowing/windowserver/tauto/TBUFFERSECURITY.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,457 +0,0 @@ -// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// DEF075471 buffer security test -// -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include "TBUFFERSECURITY.H" -#include "graphics/windowserverconstants.h" - -//Set this #define in buffersecurity.h to add extra logging to this test case (useful when debugging a test fail) -//#define _TBUFS_LOGGING - -//Set this #define in buffersecurity.h to initiate a long running soak test, this should be done periodically -//#define _TBUFS_TEST_SOAK_TEST - - - -LOCAL_C TInt TestWsThreadFunc(TAny* aPtr) - { - TTestThreadData* data = (TTestThreadData*)aPtr; - RWsSession ws; - - TInt err=ws.Connect(); - if (err!=KErrNone) - return(err); - ws.TestWrite(ws.WsHandle(), data->iOpCode, data->iData, data->iDataLength); - ws.Flush(); - ws.Close(); - - return(KErrNone); - } - -LOCAL_C TInt TestAnimDllThreadFunc(TInt aInt, TAny* /*aPtr*/) - { - TBool useTestWrite = (TBool)aInt; - - RWsSession ws; - TInt err=ws.Connect(); - if (err != KErrNone) - return (err); - if (useTestWrite) - { - TUint32 data[2]; - data[0] = 200; - data[1] = 4; - ws.TestWrite(ws.WsHandle(), EWsClOpCreateAnimDll, REINTERPRET_CAST(TUint8*,data), 8); - ws.Flush(); - } - else - { - RAnimDll animDll(ws); - const TPtrC filename(REINTERPRET_CAST(TUint16*,4),200); - animDll.Load(filename); - animDll.Close(); - } - ws.Close(); - - return(KErrNone); - } - -TInt RTestIpcSession::Connect() - { - TVersion v(KWservMajorVersionNumber,KWservMinorVersionNumber,KWservBuildVersionNumber); - TInt err = CreateSession(KWSERVServerName,v); - if (err == KErrNone) - { - err=iWsHandle=SendReceive(EWservMessInit,TIpcArgs()); - } - return err; - } - -TInt RTestIpcSession::SendBadBuffer() - { - TIpcArgs ipcArgs; - TUint32 iData[2]; - iData[0] = 200; - iData[1] = 4; - ipcArgs.Set(KBufferMessageSlot,&iData); - return SendReceive(EWservMessCommandBuffer,ipcArgs); - } - -LOCAL_C TInt TestIpcThreadFunc(TInt /*aInt*/, TAny* /*aPtr*/) - { - RTestIpcSession server; - - TInt handle=server.Connect(); - if (handle >= KErrNone) - server.SendBadBuffer(); - - return(KErrNone); - } - - -CTBufferSecurity::CTBufferSecurity(CTestStep* aStep): - CTWsGraphicsBase(aStep) - { - } - -CTBufferSecurity::~CTBufferSecurity() - { - } - -void CTBufferSecurity::ConstructL() - { - RProperty securityTesting; - TInt err=securityTesting.Attach(KUidWServSecurityTesting,EWServSecTestBufferSecurity); - User::LeaveIfError(err); - err=securityTesting.Define(KUidWServSecurityTesting,EWServSecTestBufferSecurity,RProperty::EInt,KAllowAllPolicy,KWriteDeviceDataMgmtPolicy); - if (err!=KErrAlreadyExists) - User::LeaveIfError(err); - TInt value = ETrue; - err = securityTesting.Set(value); - User::LeaveIfError(err); - } - -void CTBufferSecurity::TestWsBufferL(TInt aOpCode, TUint aDataFill, TBool aEightBit) - { - // create a new thread in which to test each of the TWsClientOpCode values - // so if the thread is panicked the test will not fail. - RThread testThread; - TTestThreadData data; - TRequestStatus status; - TUint8 storeData[KTestDataMax]; - TTestDataStore store; - store.any=storeData; - - //collect initial values - for (TInt count = 0; count < KTestDataMax; count++) - storeData[count] = 0; - switch (aOpCode) - { - case EWsClOpHeapSetFail: - store.heapSetFail->type = RAllocator::ENone; - break; - case EWsClOpSetPointerCursorArea: - store.cursorArea->area = TheClient->iWs.PointerCursorArea(); - break; - case EWsClOpRawEvent: - //skip switch off (would need a timer to turn it back on again) - if (aDataFill == TRawEvent::ESwitchOff) - aDataFill = TRawEvent::ENone; - break; -#if defined(__WINS__) - case EWsClOpSimulateXyInput: - *store.xyInputType = EXYInputMouse; - break; -#endif - } - - data.iOpCode = aOpCode; - if (aEightBit) - { - for (TInt count = 0; count < KTestDataMax; count++) - data.iData[count] = (TUint8)aDataFill; - } - else - { - for (TInt count = 0; count < KTestDataMax32; count++) - data.iData32[count] = aDataFill; - } - data.iDataLength = KTestDataMax; - _LIT(KThreadNameFormat,"BufSecTestWsThread-%d-%d"); - HBufC* threadName = HBufC::NewLC(KThreadNameFormat().Size() + 32); - TPtr threadNamePtr(threadName->Des()); - threadNamePtr.Format(KThreadNameFormat(), aOpCode, aDataFill); - TInt err = testThread.Create(threadNamePtr, TestWsThreadFunc,KDefaultStackSize,KPanicThreadHeapSize,KPanicThreadHeapSize,(TAny*)&data,EOwnerThread); - - if (err != KErrNone) - { - User::After(100000); - err = testThread.Create(threadNamePtr,TestWsThreadFunc,KDefaultStackSize,KPanicThreadHeapSize,KPanicThreadHeapSize,(TAny*)&data,EOwnerThread); - } - CleanupStack::PopAndDestroy(threadName); - testThread.Logon(status); - User::SetJustInTime(EFalse); - testThread.Resume(); - User::WaitForRequest(status); - User::SetJustInTime(ETrue); -#ifdef _TBUFS_LOGGING - TLogMessageText logMessageText; - TBufSStartLogText("TestWsBufferL"); - logMessageText.Format(_L(" OpCode(%d), ExitReason: %d"),aOpCode,testThread.ExitReason()); - TBufSLogFormat(logMessageText); -#endif - - testThread.Close(); - //reset some values to sensible ones - switch (aOpCode) - { - case EWsClOpHeapSetFail: - case EWsClOpSetPointerCursorArea: -#if defined(__WINS__) - case EWsClOpSimulateXyInput: -#endif - RThread resetThread; - TheClient->iWs.TestWrite(TheClient->iWs.WsHandle(), data.iOpCode, storeData, data.iDataLength); - TheClient->iWs.Flush(); - break; - } - } - -void CTBufferSecurity::TestBadStringAnimDllL() - { - TEST(iTest->TestPanicL(&TestAnimDllThreadFunc,3,EFalse,NULL,KLitKernExec)); - } - -void CTBufferSecurity::TestBadStringL() - { - TEST(iTest->TestWsPanicL(&TestAnimDllThreadFunc,EWservPanicBufferPtr,ETrue,NULL)); - } - -void CTBufferSecurity::TestBadIpcL() - { - TEST(iTest->TestWsPanicL(&TestIpcThreadFunc,EWservPanicDescriptor,1)); - } - -void CTBufferSecurity::RunTestCaseL(TInt /*aCurTestCase*/) - { - TInt ii; - ((CTBufferSecurityStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); - switch(++iTest->iState) - { - case 1: - ((CTBufferSecurityStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0022")); - _LIT(KBuffSecTestBadIpcL,"TestBadIpcL"); - iTest->LogSubTest(KBuffSecTestBadIpcL); - TestBadIpcL(); - break; - case 2: -/** -@SYMTestCaseID GRAPHICS-WSERV-0549 -*/ - ((CTBufferSecurityStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0549")); - _LIT(KBuffSecTestBadStringLRAnimDll,"TestBadStringL use RAnimDll"); - iTest->LogSubTest(KBuffSecTestBadStringLRAnimDll); - TestBadStringAnimDllL(); - break; - case 3: -/** -@SYMTestCaseID GRAPHICS-WSERV-0550 -*/ - ((CTBufferSecurityStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0550")); - _LIT(KBuffSecTestBadStringLTestWrite,"TestBadStringL use TestWrite"); - iTest->LogSubTest(KBuffSecTestBadStringLTestWrite); - TestBadStringL(); - break; -#ifdef _TBUFS_TEST_SOAK_TEST - case 4: -/** -@SYMTestCaseID GRAPHICS-WSERV-0551 -*/ - ((CTBufferSecurityStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0551")); - _LIT(KBuffSecTestWsBufferLSoak8bit,"TestWsBufferL Soak 8bit"); - iTest->LogSubTest(KBuffSecTestWsBufferLSoak8bit); - for(ii = EWsClOpDisconnect; ii < EWsClOpLastEnumValue; ii++) - { - TUint8 soak8=0;//gets set as KMaxTUint8 on first iteration - do - { - --soak8; - TestWsBufferL(ii,soak8); - } - while (soak8>0); - } - break; - case 5: -/** -@SYMTestCaseID GRAPHICS-WSERV-0552 -*/ - ((CTBufferSecurityStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0552")); - _LIT(KBuffSecTestWsBufferLSoak32bit,"TestWsBufferL Soak 32bit"); - iTest->LogSubTest(KBuffSecTestWsBufferLSoak32bit); - for(ii = EWsClOpDisconnect; ii < EWsClOpLastEnumValue; ii++) - { - TUint32 soak32=0;//gets set as KMaxTUint8 on first iteration - do - { - --soak32; - TestWsBufferL(ii,soak32,EFalse); - } - while (soak32>0); - } - break; -#else - case 4: -/** -@SYMTestCaseID GRAPHICS-WSERV-0553 -*/ - ((CTBufferSecurityStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0553")); - _LIT(KBuffSecTestWsBufferL0,"TestWsBufferL 0"); - iTest->LogSubTest(KBuffSecTestWsBufferL0); - for(ii = EWsClOpDisconnect; ii < EWsClOpLastEnumValue; ii++) - { - TestWsBufferL(ii,0); - } - break; - case 5: -/** -@SYMTestCaseID GRAPHICS-WSERV-0554 -*/ - ((CTBufferSecurityStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0554")); - _LIT(KBuffSecTestWsBufferL5,"TestWsBufferL 5"); - iTest->LogSubTest(KBuffSecTestWsBufferL5); - for(ii = EWsClOpDisconnect; ii < EWsClOpLastEnumValue; ii++) - { - TestWsBufferL(ii,5); - } - break; - case 6: -/** -@SYMTestCaseID GRAPHICS-WSERV-0555 -*/ - ((CTBufferSecurityStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0555")); - _LIT(KBuffSecTestWsBufferL32,"TestWsBufferL 32"); - iTest->LogSubTest(KBuffSecTestWsBufferL32); - for(ii = EWsClOpDisconnect; ii < EWsClOpLastEnumValue; ii++) - { - TestWsBufferL(ii,32); - } - break; - case 7: -/** -@SYMTestCaseID GRAPHICS-WSERV-0556 -*/ - ((CTBufferSecurityStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0556")); - _LIT(KBuffSecTestWsBufferL64,"TestWsBufferL 64"); - iTest->LogSubTest(KBuffSecTestWsBufferL64); - for(ii = EWsClOpDisconnect; ii < EWsClOpLastEnumValue; ii++) - { - TestWsBufferL(ii,64); - } - break; - case 8: -/** -@SYMTestCaseID GRAPHICS-WSERV-0557 -*/ - ((CTBufferSecurityStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0557")); - _LIT(KBuffSecTestWsBufferL128,"TestWsBufferL 128"); - iTest->LogSubTest(KBuffSecTestWsBufferL128); - for(ii = EWsClOpDisconnect; ii < EWsClOpLastEnumValue; ii++) - { - TestWsBufferL(ii,128); - } - break; - case 9: -/** -@SYMTestCaseID GRAPHICS-WSERV-0558 -*/ - ((CTBufferSecurityStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0558")); - _LIT(KBuffSecTestWsBufferL255,"TestWsBufferL 255"); - iTest->LogSubTest(KBuffSecTestWsBufferL255); - for(ii = EWsClOpDisconnect; ii < EWsClOpLastEnumValue; ii++) - { - TestWsBufferL(ii,255); - } - break; - case 10: -/** -@SYMTestCaseID GRAPHICS-WSERV-0559 -*/ - ((CTBufferSecurityStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0559")); - _LIT(KBuffSecTestWsBufferL325,"TestWsBufferL 32-5"); - iTest->LogSubTest(KBuffSecTestWsBufferL325); - for(ii = EWsClOpDisconnect; ii < EWsClOpLastEnumValue; ii++) - { - TestWsBufferL(ii,5,EFalse); - } - break; - case 11: -/** -@SYMTestCaseID GRAPHICS-WSERV-0560 -*/ - ((CTBufferSecurityStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0560")); - _LIT(KBuffSecTestWsBufferL32128,"TestWsBufferL 32-128"); - iTest->LogSubTest(KBuffSecTestWsBufferL32128); - for(ii = EWsClOpDisconnect; ii < EWsClOpLastEnumValue; ii++) - { - TestWsBufferL(ii,128,EFalse); - } - break; - case 12: -/** -@SYMTestCaseID GRAPHICS-WSERV-0561 -*/ - ((CTBufferSecurityStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0561")); - _LIT(KBuffSecTestWsBufferL32512,"TestWsBufferL 32-512"); - iTest->LogSubTest(KBuffSecTestWsBufferL32512); - for(ii = EWsClOpDisconnect; ii < EWsClOpLastEnumValue; ii++) - { - TestWsBufferL(ii,512,EFalse); - } - break; - case 13: -/** -@SYMTestCaseID GRAPHICS-WSERV-0562 -*/ - ((CTBufferSecurityStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0562")); - _LIT(KBuffSecTestWsBufferL320x01234567,"TestWsBufferL 32-0x01234567"); - iTest->LogSubTest(KBuffSecTestWsBufferL320x01234567); - for(ii = EWsClOpDisconnect; ii < EWsClOpLastEnumValue; ii++) - { - TestWsBufferL(ii,0x01234567,EFalse); - } - break; - case 14: -/** -@SYMTestCaseID GRAPHICS-WSERV-0563 -*/ - ((CTBufferSecurityStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0563")); - _LIT(KBuffSecTestWsBufferL320x89abcdef,"TestWsBufferL 32-0x89abcdef"); - iTest->LogSubTest(KBuffSecTestWsBufferL320x89abcdef); - for(ii = EWsClOpDisconnect; ii < EWsClOpLastEnumValue; ii++) - { - TestWsBufferL(ii,0x89abcdef,EFalse); - } - break; - case 15: -/** -@SYMTestCaseID GRAPHICS-WSERV-0564 -*/ - ((CTBufferSecurityStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0564")); - _LIT(KBuffSecTestWsBufferL320xCCCCCCCC,"TestWsBufferL 32-0xCCCCCCCC"); - iTest->LogSubTest(KBuffSecTestWsBufferL320xCCCCCCCC); - for(ii = EWsClOpDisconnect; ii < EWsClOpLastEnumValue; ii++) - { - TestWsBufferL(ii,0xCCCCCCCC,EFalse); - } - break; -#endif - default: - ((CTBufferSecurityStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - ((CTBufferSecurityStep*)iStep)->CloseTMSGraphicsStep(); - TInt err = RProperty::Set(KUidWServSecurityTesting,EWServSecTestBufferSecurity,EFalse); - User::LeaveIfError(err); - TestComplete(); - } - ((CTBufferSecurityStep*)iStep)->RecordTestResultL(); - } - -__WS_CONSTRUCT_STEP__(BufferSecurity) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TBUFFERSECURITY.H --- a/windowing/windowserver/tauto/TBUFFERSECURITY.H Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,132 +0,0 @@ -// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// DEF075471 buffer security test -// -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef __TBUFFERSECURITY_H__ -#define __TBUFFERSECURITY_H__ - -#include "AUTO.H" -#include "../tlib/testbase.h" -#include -#include "../SERVER/w32cmd.h" - -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA -#include "../nonnga/CLIENT/w32comm.h" -#endif - -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA -#include "../nga/CLIENT/w32comm.h" -#endif - -#include -#include "TGraphicsHarness.h" - -//Set this #define to add extra logging to this test case (useful when debugging a test fail) -//#define _TBUFS_LOGGING - -//Set this #define to initiate a long running soak test, this should be done periodically -//#define _TBUFS_TEST_SOAK_TEST - -#ifdef _TBUFS_LOGGING -#define TBufSStartLogText StartLogText -#define TBufSLogText LogText -#define TBufSLogFormat LogFormat -#else -#define TBufSStartLogText -#define TBufSLogText -#define TBufSLogFormat -#endif - -LOCAL_D const TUint KPanicThreadHeapSize=0x4000; - -_LIT(KLitKernExec, "KERN-EXEC"); -_LIT(KTestName, "DEF086238 Buffer Security Test"); -static _LIT_SECURITY_POLICY_PASS(KAllowAllPolicy); -static _LIT_SECURITY_POLICY_C1(KWriteDeviceDataMgmtPolicy,ECapabilityWriteDeviceData); -const TInt KTestDataMax = 256; -const TInt KTestDataMax32 = KTestDataMax/4; - -struct TTestThreadData - { - TInt iOpCode; - union - { - TUint8 iData[KTestDataMax]; - TUint32 iData32[KTestDataMax32]; - }; - TInt iDataLength; - }; - -enum KBufSecTestType - { - EBufSecUnInitialised, - EBufSecRandom, - EBufSecZero - }; - -union TTestDataStore - { - TAny *any; - TWsClCmdSetPointerCursorArea* cursorArea; - TWsClCmdHeapSetFail *heapSetFail; - TXYInputType *xyInputType; - }; - -class CTBufferSecurity : public CTWsGraphicsBase - { -public: - CTBufferSecurity(CTestStep* aStep); - ~CTBufferSecurity(); - void TestWsBufferL(TInt aOpCode, TUint aDataFill, TBool aEightBit=ETrue); - void TestBadStringAnimDllL(); - void TestBadStringL(); - void TestBadIpcL(); - void ConstructL(); -protected: -//from CTGraphicsStep - virtual void RunTestCaseL(TInt aCurTestCase); -private: - void TestBufferSecurityL(); - }; - -class RTestIpcSession : public RSessionBase - { -public: - inline RTestIpcSession() {}; - TInt Connect(); - TInt SendBadBuffer(); -private: - TInt iWsHandle; - }; - -class CTBufferSecurityStep : public CTGraphicsStep - { -public: - CTBufferSecurityStep(); -protected: - //from CTGraphicsStep - virtual CTGraphicsBase* CreateTestL(); - }; - -_LIT(KTBufferSecurityStep,"TBufferSecurity"); - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TCAPABILITY.CPP --- a/windowing/windowserver/tauto/TCAPABILITY.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,263 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Capability test -// -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include "TCAPABILITY.H" - -_LIT(KTestResultsFile, "C:\\DATA\\TestResult.Dat"); -_LIT(KSpace, " "); -_LIT(KTest0Name, "All capabilities"); -_LIT(KTest0Exe, "TCAP_ALL.exe"); -_LIT(KTest0Cap, "CAPABILITY_ALL"); -_LIT(KTest1Name, "No capabilities"); -_LIT(KTest1Exe, "TCAP_NONE.exe"); -_LIT(KTest1Cap, "CAPABILITY_NONE"); -_LIT(KTest2Name, "WriteDeviceData and SwEvent capabilities"); -_LIT(KTest2Exe, "TCAP_ONE.exe"); -_LIT(KTest2Cap, "WRITEDATA+SWEVENT"); -_LIT(KTest3Name, "WriteDeviceData and PowerMgnt capabilities"); -_LIT(KTest3Exe, "TCAP_TWO.exe"); -_LIT(KTest3Cap, "WRITEDATA+POWERMGMT"); -_LIT(KTest4Name, "PowerMgnt and SwEvent capabilities"); -_LIT(KTest4Exe, "TCAP_THREE.exe"); -_LIT(KTest4Cap, "POWERMGMT+SWEVENT"); - - -//CCapabilityTest -CTCapability::CTCapability(CTestStep* aStep): - CTWsGraphicsBase(aStep) - { - } - -CTCapability::~CTCapability() - { - } - -void CTCapability::ConstructL() - { - //Empty function ConstructL is pure virtual function and this - //definition required to satisfy the compiler - } - -//Reads the shared files which contains the total tests run and tests passed. -void CTCapability::GetCapabilityTestResultsL(TInt& aNoOfTests, TInt& aNoOfTestsPass) - { - TBuf<256> noOfTest; - TBuf<256> noOfTestPass; - RFs fileSession; - RFile file; - TFileText textFile; - User::LeaveIfError(fileSession.Connect()); - CleanupClosePushL(fileSession); - User::LeaveIfError(file.Open(fileSession,KTestResultsFile,EFileRead)); - CleanupClosePushL(file); - textFile.Set(file); - if(textFile.Read(noOfTest)==KErrNone) - { - TLex lexVar(noOfTest); - lexVar.Val(aNoOfTests); - if(textFile.Read(noOfTestPass)==KErrNone) - { - lexVar=noOfTestPass; - lexVar.Val(aNoOfTestsPass); - } - else - { - aNoOfTestsPass=0; - } - } - CleanupStack::PopAndDestroy(&file); - CleanupStack::PopAndDestroy(&fileSession); - } - - void CTCapability::LaunchNewProcess(const TDesC& aExecutable,const TDesC& aCapability) - { - TBuf<128> args; - args.Append(aCapability); - args.Append(KSpace); - args.AppendNum(TheClient->iGroup->GroupWin()->Identifier()); - RProcess pr; -// TInt noOfTest,noOfTestPass; - if (pr.Create(aExecutable,args)==KErrNone) - { - TRequestStatus status=NULL; - pr.Logon(status); - pr.Resume(); - User::WaitForRequest(status); - //Close all the panic windows to avoid "Hangs the H4" - //PDEF100501: TEF Migrated Test TCapability Hangs the H4 - if (iTest->iScreenNumber == 0) - iTest->CloseAllPanicWindows(); - pr.Close(); -// GetCapabilityTestResultsL(noOfTest,noOfTestPass); -// UpdateTestResults(noOfTest,noOfTestPass); - } - } - -void CTCapability::RunTestCaseL(TInt /*aCurTestCase*/) - { - ((CTCapabilityStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); - switch(++iTest->iState) - { -/** - - @SYMTestCaseID GRAPHICS-WSERV-0305 - - @SYMDEF DEF081259 - - @SYMTestCaseDesc Capability test with a process with all capability - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions The security threat API's are called with all - capability to test whether the API's are accessible or not. - - @SYMTestExpectedResults If the required capability is defined to test code then API should - accessible, otherwise it should panic the test. - -*/ - case 1: - ((CTCapabilityStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0305")); - iTest->LogSubTest(KTest0Name); - LaunchNewProcess(KTest0Exe, KTest0Cap); - break; -/** - - @SYMTestCaseID GRAPHICS-WSERV-0306 - - @SYMDEF DEF081259 - - @SYMTestCaseDesc Capability test with a process with no capability - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions The security threat API's are called with no - capability to test whether the API's are accessible or not. - - @SYMTestExpectedResults If the required capability is defined to test code then API should - accessible, otherwise it should panic the test. - -*/ - case 2: - ((CTCapabilityStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0306")); - //create process with no capability - RDebug::Print(KPlatsecBegin); - iTest->LogSubTest(KTest1Name); - LaunchNewProcess(KTest1Exe,KTest1Cap); - break; -/** - - @SYMTestCaseID GRAPHICS-WSERV-0307 - - @SYMDEF DEF081259 - - @SYMTestCaseDesc Capability test with a process with WriteDevicedata and SwEvent capability - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions The security threat API's are called with WriteDevicedata and SwEvent - capability to test whether the API's are accessible or not. - - @SYMTestExpectedResults If the required capability is defined to test code then API should - accessible, otherwise it should panic the test. - -*/ - case 3: - ((CTCapabilityStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0307")); - //create process with WriteDevicedata and SwEvent capability - iTest->LogSubTest(KTest2Name); - LaunchNewProcess(KTest2Exe,KTest2Cap); - break; -/** - - @SYMTestCaseID GRAPHICS-WSERV-0308 - - @SYMDEF DEF081259 - - @SYMTestCaseDesc Capability test with a process with WriteDevicedata and PowerMgmt capability - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions The security threat API's are called with WriteDevicedata and PowerMgmt - capability to test whether the API's are accessible or not. - - @SYMTestExpectedResults If the required capability is defined to test code then API should - accessible, otherwise it should panic the test. - -*/ - case 4: - ((CTCapabilityStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0308")); - //create process with WriteDevicedata and PowerMgmt capability - iTest->LogSubTest(KTest3Name); - LaunchNewProcess(KTest3Exe,KTest3Cap); - break; -/** - - @SYMTestCaseID GRAPHICS-WSERV-0309 - - @SYMDEF DEF081259 - - @SYMTestCaseDesc Capability test with a process with PowerMgmt and SwEvent capability - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions The security threat API's are called with PowerMgmt and SwEvent - capability to test whether the API's are accessible or not. - - @SYMTestExpectedResults If the required capability is defined to test code then API should - accessible, otherwise it should panic the test. - -*/ - case 5: - ((CTCapabilityStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0309")); - //create process with PowerMgmt and SwEvent capability - iTest->LogSubTest(KTest4Name); - LaunchNewProcess(KTest4Exe, KTest4Cap); - break; - default : - ((CTCapabilityStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - ((CTCapabilityStep*)iStep)->CloseTMSGraphicsStep(); - RDebug::Print(KPlatsecEnd); - RFs fileSession; - User::LeaveIfError(fileSession.Connect()); - CleanupClosePushL(fileSession); - CFileMan *fileMan=CFileMan::NewL(fileSession); - fileMan->Delete(KTestResultsFile); - delete fileMan; - CleanupStack::PopAndDestroy(&fileSession); - TestComplete(); - break; - } - ((CTCapabilityStep*)iStep)->RecordTestResultL(); - } - -__WS_CONSTRUCT_STEP__(Capability) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TCAPABILITY.H --- a/windowing/windowserver/tauto/TCAPABILITY.H Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,56 +0,0 @@ - -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef __TCAPABILITY_H__ -#define __TCAPABILITY_H__ - -#include "AUTO.H" -#include "../tlib/testbase.h" -#include "TGraphicsHarness.h" - -class CTCapability : public CTWsGraphicsBase - { -public: - CTCapability(CTestStep* aStep); - ~CTCapability(); - void ConstructL(); -protected: -//from CTGraphicsStep - virtual void RunTestCaseL(TInt aCurTestCase); -private: - void GetCapabilityTestResultsL(TInt& aNoOfTest, TInt&aNoOfTestPass); - void LaunchNewProcess(const TDesC& aExecutableName,const TDesC& acapability); - }; - -class CTCapabilityStep : public CTGraphicsStep - { -public: - CTCapabilityStep(); -protected: - //from CTGraphicsStep - virtual CTGraphicsBase* CreateTestL(); - }; - -_LIT(KTCapabilityStep,"TCapability"); - - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TCapKey.CPP --- a/windowing/windowserver/tauto/TCapKey.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,877 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Test capture key -// Coverted from TMan test code (TMCAPKEY.CPP) October 2000 -// -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - - -#include "TCapKey.H" - -#define LOGGING on - -// -// CAbortHandler - -CAbortHandler::CAbortHandler(RWsSession *aWs, CCKAbortConnection *aConnection) : CTEventBase(aWs, 10), iConnection(aConnection) - { - } - -CAbortHandler::~CAbortHandler() - { - Cancel(); - } - -void CAbortHandler::Request() - { - iWs->PriorityKeyReady(&iStatus); - SetActive(); - } - -void CAbortHandler::DoCancel() - { - iWs->PriorityKeyReadyCancel(); - } - -void CAbortHandler::doRunL() - { - TWsPriorityKeyEvent abortEvent; - iWs->GetPriorityKey(abortEvent); - iConnection->ReceivedAbortEvent(abortEvent.Handle(),abortEvent.Key()); - } - -// -// CCKConnection - -CCKConnectionBase::CCKConnectionBase(CTCaptureKey *aTest) : iTest(aTest) - { - } - -void CCKConnectionBase::ConstructL() - { - CTClient::SetScreenNumber(iTest->ScreenNumber()); - CTClient::ConstructL(); - iGroup=new(ELeave) CCKWindowGroup(this, iTest); - iGroup->ConstructL(); - } - -CCKConnection::CCKConnection(CTCaptureKey *aTest, TInt aConnIndex) : CCKConnectionBase(aTest), iConnIndex(aConnIndex) - { - } - -CCKConnection::~CCKConnection() - { - for(TInt index=0;indexGroupWin()->CancelCaptureKey(capKeyHandle[index]); - for(TInt index1=0;index1GroupWin()->CancelCaptureKey(capKeyWithPriorityHandle[index1]); - for(TInt index2=0;index2GroupWin()->CancelCaptureKeyUpAndDowns(capUpDownKeyHandle[index2]); - for(TInt index3=0;index3GroupWin()->CancelCaptureKeyUpAndDowns(capUpDownKeyWithPriorityHandle[index3]); - CTWin::Delete(iWin); - } - -void CCKConnection::SubStateChanged() - { - iWin->Invalidate(); - iWs.Flush(); - } - -void CCKConnection::ConstructL() - { - CCKConnectionBase::ConstructL(); - for(TInt index=0;indexGroupWin()->CaptureKey(capKeys[index].keyCode,capKeys[index].modifier_mask,capKeys[index].modifiers)); - for(TInt index1=0;index1GroupWin()->CaptureKey(capKeysWithPriority[index1].keyCode,capKeysWithPriority[index1].modifier_mask,capKeysWithPriority[index1].modifiers,capKeysWithPriority[index1].priority)); - for(TInt index2=0;index2GroupWin()->CaptureKeyUpAndDowns(capUpAndDownKeys[index2].keyCode, - capUpAndDownKeys[index2].modifier_mask,capUpAndDownKeys[index2].modifiers)); - for(TInt index3=0;index3GroupWin()->CaptureKeyUpAndDowns(capUpAndDownKeysWithPriority[index3].keyCode, - capUpAndDownKeysWithPriority[index3].modifier_mask,capUpAndDownKeysWithPriority[index3].modifiers,capUpAndDownKeysWithPriority[index3].priority)); - TSize screenSize=iGroup->Size(); - TInt winWidth=screenSize.iWidth/2; - TInt winHeight=screenSize.iHeight-10; - iGroup->GroupWin()->AutoForeground(EFalse); // Don't allow clicking to cause foreground, might mess up test - CCKWindow *win=new(ELeave) CCKWindow(iTest, iConnIndex); - win->SetUpL(TPoint(5,5),TSize(winWidth,winHeight),iGroup,*iGc); - iWin=win; - } - -void CCKConnection::KeyTestL(TInt aBool) - { - if (!aBool) - { - CTDialog *dialog= new(ELeave) CTDialog(); - TInt ret=0; - if (dialog) - { - dialog->ConstructLD(*iGroup,*iGc); - dialog->SetTitle(_L("Invalid key press")); - dialog->SetLine1(_L("Try again?")); - dialog->SetNumButtons(2); - dialog->SetButtonText(0,_L("Fail")); - dialog->SetButtonText(1,_L("Retry")); - ret=dialog->Display(); - } - User::Leave(ret==1 ? ECapKeyRetry : ECapKeyFail); - } - } - -void CCKConnection::CheckKeyL(const SCapKeyTestParams &aKeyTest, const TKeyEvent &aKey) - { - KeyTestL(aKeyTest.keyCode==aKey.iCode); - KeyTestL(aKeyTest.modifiers==(aKey.iModifiers&aKeyTest.modifier_mask)); - } - -void CCKConnection::CheckUpDownL(const SCapKeyTestParams &aKeyTest, const TKeyEvent &aKey) - { - if(iTest->Mode()==EModeKeyUpsAndDownsWithPriority) - KeyTestL(aKeyTest.connIndex==iTest->SubState()-15); - KeyTestL(aKeyTest.connIndex==iConnIndex); - KeyTestL(aKeyTest.keyCode==(TUint)aKey.iScanCode); - KeyTestL(aKeyTest.modifiers==(aKey.iModifiers&aKeyTest.modifier_mask)); - } - -void CCKConnection::KeyL(const TKeyEvent &aKey,const TTime &) - { -#if defined(LOGGING) - _LIT(KLog,"CCKConnection::KeyL State=%d SubState=%d Mode=%d KeyCode=%d ScanCode=%d Mod=0x%x"); - iTest->LOG_MESSAGE7(KLog,iTest->State(),iTest->SubState(),iTest->Mode(),aKey.iCode,aKey.iScanCode,aKey.iModifiers); -#endif - if (iTest->Mode()==EModeNormalCapture || iTest->Mode()==EModeNormalCaptureWithPriority) - { - //if (aKey.iCode==EKeyEscape) - // iTest->Abort(); - if(iTest->Mode()==EModeNormalCaptureWithPriority) - { - SCapKeyTestParams tmpCapKeyTest=capKeyTests[iTest->SubState()]; - KeyTestL(tmpCapKeyTest.connIndex==iTest->SubState()-8); - } - TRAPD(ret,CheckKeyL(capKeyTests[iTest->SubState()],aKey)); - if (ret==ECapKeyOkay) - iTest->IncSubState(); - else - { - iTest->TEST(ret==ECapKeyRetry); - if (ret!=ECapKeyRetry) - iTest->INFO_PRINTF3(_L("CheckKeyL(capKeyTests[iTest->SubState()],aKey) return value - Expected: %d, Actual: %d"), ECapKeyRetry, ret); - } - - } - } - -void CCKConnection::CheckUpDownL(const TKeyEvent &aKey) - { - CheckUpDownL(capKeyTests[iTest->SubState()],aKey); - } - -CCKAbortConnection::CCKAbortConnection(CTCaptureKey *aTest) : CCKConnectionBase(aTest) - { - } - -CCKAbortConnection::~CCKAbortConnection() - { - iGroup->GroupWin()->RemovePriorityKey(3,EModifierCtrl,EModifierCtrl); - delete iAbortHandler; - } - -void CCKAbortConnection::ConstructL() - { - CCKConnectionBase::ConstructL(); - User::LeaveIfError(iGroup->GroupWin()->AddPriorityKey(abortKeyTests[0].keyCode,abortKeyTests[0].modifier_mask,abortKeyTests[0].modifiers)); - User::LeaveIfError(iGroup->GroupWin()->AddPriorityKey(abortKeyTests[1].keyCode,abortKeyTests[1].modifier_mask,abortKeyTests[1].modifiers)); - User::LeaveIfError(iGroup->GroupWin()->AddPriorityKey(abortKeyTests[2].keyCode,abortKeyTests[2].modifier_mask,abortKeyTests[2].modifiers)); - iAbortHandler=new(ELeave) CAbortHandler(&iWs, this); - iAbortHandler->Construct(); - iWs.Flush(); - } - -void CCKAbortConnection::ReceivedAbortEvent(TInt aHandle,TKeyEvent* aKey) - { -#if defined(LOGGING) - _LIT(KLog,"CCKAbortConnection::ReceivedAbortEvent State=%d SubState=%d Mode=%d KeyCode=%d ScanCode=%d Mod=0x%x"); - iTest->LOG_MESSAGE7(KLog,iTest->State(),iTest->SubState(),iTest->Mode(),aKey->iCode,aKey->iScanCode,aKey->iModifiers); -#endif - TInt group=reinterpret_cast(iGroup); - iTest->TEST(aHandle==group); - if (aHandle!=group) - { - _LIT(KLog,"Event Handle is not for the right group, expected=%d actual=%d"); - iTest->LOG_MESSAGE3(KLog,group,aHandle); - } - - iTest->TEST(aKey->iCode==abortKeyTests[iAbortKeyIndex].keyCode); - if (aKey->iCode!=abortKeyTests[iAbortKeyIndex].keyCode) - { - _LIT(KLog,"The event KeyCode is not right, expected=%d actual=%d"); - iTest->LOG_MESSAGE3(KLog,abortKeyTests[iAbortKeyIndex].keyCode,aKey->iCode); - } - - iTest->TEST((aKey->iModifiers&abortKeyTests[iAbortKeyIndex].modifier_mask)==abortKeyTests[iAbortKeyIndex].modifiers); - if ((aKey->iModifiers&abortKeyTests[iAbortKeyIndex].modifier_mask)!=abortKeyTests[iAbortKeyIndex].modifiers) - { - _LIT(KLog,"The event modifiers are not right, expected=0x%x actual=0x%x (0x%x) mask=0x%x"); - iTest->LOG_MESSAGE5(KLog,abortKeyTests[iAbortKeyIndex].modifiers,aKey->iModifiers&abortKeyTests[iAbortKeyIndex].modifier_mask - ,aKey->iModifiers,abortKeyTests[iAbortKeyIndex].modifier_mask); - } - iAbortKeyIndex++; - iTest->IncSubState(); - } - -void CCKAbortConnection::Foreground() - { - iGroup->GroupWin()->SetOrdinalPosition(0); - iWs.Flush(); - } - -// -// CCKWindowGroup class // -// - -CCKWindowGroup::CCKWindowGroup(CTClient *aClient, CTCaptureKey *aTest) : CTWindowGroup(aClient), iTest(aTest) - {} - -void CCKWindowGroup::KeyL(const TKeyEvent &aKey,const TTime &time) - { -#if defined(LOGGING) - _LIT(KLog,"CCKWindowGroup::KeyL State=%d SubState=%d Mode=%d KeyCode=%d ScanCode=%d Mod=0x%x"); - iTest->LOG_MESSAGE7(KLog,iTest->State(),iTest->SubState(),iTest->Mode(),aKey.iCode,aKey.iScanCode,aKey.iModifiers); -#endif - if (iTest->Mode()==EModeWaitingForFirstNormalCapWithPriority) - iTest->SetMode(EModeNormalCaptureWithPriority); - if (iCurWin) - iCurWin->WinKeyL(aKey,time); - else - ((CCKConnection *)iClient)->KeyL(aKey,time); - } - -void CCKWindowGroup::KeyDownL(const TKeyEvent &aKey,const TTime &) - { -#if defined(LOGGING) - _LIT(KLog,"CCKWindowGroup::KeyDownL State=%d SubState=%d Mode=%d KeyCode=%d ScanCode=%d Mod=0x%x"); - iTest->LOG_MESSAGE7(KLog,iTest->State(),iTest->SubState(),iTest->Mode(),aKey.iCode,aKey.iScanCode,aKey.iModifiers); -#endif - if (aKey.iScanCode!=EStdKeyLeftShift && aKey.iScanCode!=EStdKeyRightShift) - { - if (iTest->Mode()==EModeWaitingForFirstDown) - iTest->SetMode(EModeKeyUpsAndDowns); - if (iTest->Mode()==EModeWaitingForFirstDownWithPriority) - iTest->SetMode(EModeKeyUpsAndDownsWithPriority); - if (iTest->Mode()==EModeKeyUpsAndDowns || iTest->Mode()==EModeKeyUpsAndDownsWithPriority) - ((CCKConnection *)iClient)->CheckUpDownL(aKey); - } - } - -void CCKWindowGroup::KeyUpL(const TKeyEvent &aKey,const TTime &) - { -#if defined(LOGGING) - _LIT(KLog,"CCKWindowGroup::KeyUpL State=%d SubState=%d Mode=%d KeyCode=%d ScanCode=%d Mod=0x%x"); - iTest->LOG_MESSAGE7(KLog,iTest->State(),iTest->SubState(),iTest->Mode(),aKey.iCode,aKey.iScanCode,aKey.iModifiers); -#endif - if (aKey.iScanCode!=EStdKeyLeftShift && aKey.iScanCode!=EStdKeyRightShift) - { - if (iTest->Mode()==EModeKeyUpsAndDowns || iTest->Mode()==EModeKeyUpsAndDownsWithPriority) - { - ((CCKConnection *)iClient)->CheckUpDownL(aKey); - iTest->IncSubState(); - } - } - } - -// -// CCKWindow, class // -// - -CCKWindow::CCKWindow(CTCaptureKey *aTest, TInt aConnIndex) : CTWin(), iConnIndex(aConnIndex), iTest(aTest) - { - iBack=TRgb::Gray256(230); - } - -void CCKWindow::SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc) - { - ConstructExtLD(*parent,pos,size); - iWin.SetBackgroundColor(iBack); - Activate(); - AssignGC(aGc); - } - -void CCKWindow::Draw() - { - iGc->Clear(); - if (iConnIndex==0) - { - TInt test=iTest->SubState(); - if (testDrawText(TPtrC(capKeyTests[test].txt), TPoint(10,20)); - } - } - -// - -CTCaptureKey::CTCaptureKey(CTestStep* aStep) : CTWsGraphicsBase(aStep) - { - } - -CTCaptureKey::~CTCaptureKey() - { - ((CTCaptureKeyStep*)iStep)->CloseTMSGraphicsStep(); - delete iConn1; - delete iConn2; - delete iConn3; - delete iAbortConn; - } - -void CTCaptureKey::ConstructL() - { - iAbortConn=new(ELeave) CCKAbortConnection(this); - iAbortConn->ConstructL(); - iConn3=new(ELeave) CCKConnection(this,2); - iConn3->ConstructL(); - iConn2=new(ELeave) CCKConnection(this,1); - iConn2->ConstructL(); - iConn1=new(ELeave) CCKConnection(this,0); - iConn1->ConstructL(); - iMode=EModeNormalCapture; - SetSelfDrive(ETrue); - TUint mods=TheClient->iWs.GetModifierState(); - _LIT(KLog,"Initial Modifiers state 0x%x (ideally should be zero)"); - LOG_MESSAGE2(KLog,mods); - } - -TInt CTCaptureKey::SubState() const - { - return(iSubState); - } - -void CTCaptureKey::IncSubState() - { - iSubState++; -#if defined(LOGGING) - _LIT(KLog,"IncSubState State=%d SubState=%d Mode=%d"); - LOG_MESSAGE4(KLog,iState,iSubState,iMode); -#endif - iConn1->SubStateChanged(); - iConn2->SubStateChanged(); - iConn3->SubStateChanged(); - switch(iMode) - { - case EModeNormalCapture: - if (iSubState==numCapKeyTests) - { - CaseComplete(); - return; - } - break; - case EModeNormalCaptureWithPriority: - if (iSubState==numCapKeyTests+numCapKeyWithPriorityTests) - { - CaseComplete(); - return; - } - break; - case EModeKeyUpsAndDowns: - if (iSubState==(numCapKeyTests+numCapKeyWithPriorityTests+numUpDownKeyTests)) - { - CaseComplete(); - return; - } - break; - case EModeKeyUpsAndDownsWithPriority: - if (iSubState==(numCapKeyTests+numCapKeyWithPriorityTests+numUpDownKeyTests+numUpDownKeyWithPriorityTests)) - { - SetSelfDrive(EFalse); - return; - } - break; - case EModeAbortKeys: - if (iSubState==(numCapKeyTests+numCapKeyWithPriorityTests+numUpDownKeyTests+numUpDownKeyWithPriorityTests+numAbortKeyTests)) - ++iState; - TheClient->WaitForRedrawsToFinish(); - return; - default: - break; - } - TheClient->WaitForRedrawsToFinish(); - SendEvents(); - } - -void CTCaptureKey::CapKeyPurgingL() - { - TInt base=Client()->iWs.ResourceCount(); - RWindowGroup groupWin(Client()->iWs); - User::LeaveIfError(groupWin.Construct(ENullWsHandle)); - TInt capHandle=User::LeaveIfError(groupWin.CaptureKey('a',EModifierFunc,EModifierFunc)); - User::LeaveIfError(groupWin.CaptureKey('b',EModifierFunc,EModifierFunc)); - TInt retVal = Client()->iWs.ResourceCount(); - TEST(retVal==(base+3)); - if (retVal!=(base+3)) - INFO_PRINTF3(_L("Client()->iWs.ResourceCount() return value - Expected: %d, Actual: %d"), retVal, (base+3)); - - groupWin.CancelCaptureKey(capHandle); - retVal = Client()->iWs.ResourceCount(); - TEST(retVal==(base+2)); - if (retVal!=(base+2)) - INFO_PRINTF3(_L("Client()->iWs.ResourceCount() return value - Expected: %d, Actual: %d"), retVal, (base+2)); - - groupWin.Close(); - // Check it also freed the extra capture key - retVal = Client()->iWs.ResourceCount(); - TEST(retVal==base); - if (retVal!=base) - INFO_PRINTF3(_L("Client()->iWs.ResourceCount() return value - Expected: %d, Actual: %d"), retVal, base); - - } - -void CTCaptureKey::BadParams() - { - TInt retVal; - TInt resCount=Client()->iWs.ResourceCount(); - for(TInt index=0;indexiGroup->GroupWin()->CaptureKey(errorKeys[index].keyCode,errorKeys[index].modifier_mask,errorKeys[index].modifiers); - TEST(retVal==KErrArgument); - if (retVal!=KErrArgument) - INFO_PRINTF3(_L("Client()->iGroup->GroupWin()->CaptureKey() return value - Expected: %d, Actual: %d"), KErrArgument, retVal); - } - retVal = Client()->iWs.ResourceCount(); - TEST(retVal==resCount); - if (retVal!=resCount) - INFO_PRINTF3(_L("Client()->iWs.ResourceCount() return value - Expected: %d, Actual: %d"), resCount, retVal); - } - -void CTCaptureKey::SetMode(TTestMode aMode) - { -#if defined(LOGGING) - _LIT(KLog,"SetMode State=%d SubState=%d OldMode=%d NewMode=%d"); - LOG_MESSAGE5(KLog,State(),SubState(),iMode,aMode); -#endif - iMode=aMode; - } - -TTestMode CTCaptureKey::Mode() - { - return(iMode); - } - -void CTCaptureKey::SetUpPriorityKeyTest() - { - iMode=EModeAbortKeys; - iAbortConn->Foreground(); - } - -void CTCaptureKey::CaptureWithPriorityTest() //normal key capture but with priority - { - iMode=EModeWaitingForFirstNormalCapWithPriority; - } - -void CTCaptureKey::CaptureUpsAndDownsTest() - { - iMode=EModeWaitingForFirstDown; - } - -void CTCaptureKey::CaptureUpsAndDownsWithPriorityTest() - { - iMode=EModeWaitingForFirstDownWithPriority; - } - -void CTCaptureKey::SendEvents() - { -#if defined(LOGGING) - _LIT(KLog,"SendEvents State=%d SubState=%d"); - LOG_MESSAGE3(KLog,iState,iSubState); -#endif - switch (iSubState) - { - case 0: - iTest->SimulateKeyDownUp('Q'); - break; - case 1: - iTest->SimulateKeyDownUpWithModifiers('W',EModifierAlt); - break; - case 2: - iTest->SimulateKeyDownUp('A'); - break; - case 3: - iTest->SimulateKeyDownUpWithModifiers('S',EModifierAlt|EModifierCtrl); - break; - case 4: - iTest->SimulateKeyDownUpWithModifiers('N',EModifierAlt); - break; - case 5: - iTest->SimulateKeyDownUpWithModifiers('B',EModifierAlt|EModifierCtrl); - break; - case 6: - iTest->SimulateKeyDownUpWithModifiers('D',EModifierAlt); - break; - case 7: - iTest->SimulateKeyDownUpWithModifiers('C',EModifierAlt|EModifierCtrl); - break; - case 8: - iTest->SimulateKeyDownUp('H');//state EModeNormalCaptureWithPriority - break; - case 9: - iTest->SimulateKeyDownUp('J'); - break; - case 10: - iTest->SimulateKeyDownUp('K'); - break; - case 11: - iTest->SimulateKeyDownUp(EStdKeySpace); - break; - case 12: - iTest->SimulateKeyDownUp(EStdKeyEnter); - break; - case 13: - iTest->SimulateKeyDownUpWithModifiers(EStdKeySpace,EModifierShift); - break; - case 14: - iTest->SimulateKeyDownUpWithModifiers(EStdKeyEnter,EModifierShift); - break; - case 15: - iTest->SimulateKeyDownUp('H');//state EModeKeyUpsAndDownsWithPriority - break; - case 16: - iTest->SimulateKeyDownUp('J'); - break; - case 17: - iTest->SimulateKeyDownUp('K'); - break; - case 18: - iTest->SimulateKeyDownUpWithModifiers('C',EModifierCtrl); - break; - case 19: - iTest->SimulateKeyDownUpWithModifiers('D',EModifierCtrl); - break; - case 20: - iTest->SimulateKeyDownUp('Z'); - break; - default: - TEST(EFalse); - } - TheClient->iWs.Flush(); - } - -void CTCaptureKey::CapKeyPowerOffL() - { - const TUint protKey=0xF844; //This value needs to be defined in the WSINI.INI file as a key only capturable by a certain application - RWsSession ws; - User::LeaveIfError(ws.Connect()); - CleanupClosePushL(ws); - - // assign to the correct screen - CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws); - CleanupStack::PushL(screen); - User::LeaveIfError(screen->Construct(iTest->iScreenNumber)); - - RWindowGroup group(ws); - group.Construct(ENullWsHandle); - CleanupClosePushL(group); - group.EnableReceiptOfFocus(EFalse); - group.SetOrdinalPosition(0,5); - RBlankWindow blank(ws); - blank.Construct(group,ENullWsHandle); - CleanupClosePushL(blank); - blank.EnableBackup(); - blank.Activate(); - _LIT(kGroupName1,"Hello"); - group.SetName(kGroupName1); - TInt capHandle = group.CaptureKey(EKeyDevice2,EModifierFunc,EModifierFunc); - TEST(capHandle==KErrPermissionDenied); - if (capHandle!=KErrPermissionDenied) - { - _LIT(KLog1,"Capture Key suceeded when it should of failed, Error/Handle=%d (expected: %d)"); - LOG_MESSAGE3(KLog1,capHandle,KErrPermissionDenied); - _LIT(KLog2,"This is indicative of a bad WSINI file"); - LOG_MESSAGE(KLog2); - } - - capHandle=group.CaptureKeyUpAndDowns(protKey,0,0); - TEST(capHandle==KErrPermissionDenied); - if (capHandle!=KErrPermissionDenied) - { - _LIT(KLog,"Capture Key Up & Down suceeded when it should of failed, Error/Handle=%d (expected: %d)"); - LOG_MESSAGE3(KLog,capHandle,KErrPermissionDenied); - } - - _LIT(kGroupName2,"SysApp"); - group.SetName(kGroupName2); - capHandle = group.CaptureKey(EKeyDevice2,EModifierFunc,EModifierFunc); - TEST(capHandle > 0); - if (capHandle<=0) - { - _LIT(KLog,"Capture Key failed when it should of succeeded, Error=%d"); - LOG_MESSAGE2(KLog,capHandle); - } - - group.CancelCaptureKey(capHandle); - capHandle=group.CaptureKeyUpAndDowns(protKey,0,0); - TEST(capHandle > 0); - if (capHandle<=0) - { - _LIT(KLog,"Capture Key Up & Down failed when it should of succeeded, Error=%d"); - LOG_MESSAGE2(KLog,capHandle); - } - - group.CancelCaptureKeyUpAndDowns(capHandle); - CleanupStack::PopAndDestroy(4,&ws); - } - - -void CTCaptureKey::RunTestCaseL(TInt /*aCurTestCase*/) - { - _LIT(Test0,"Normal capture with priority"); - _LIT(TestNormalCaptureWithPriority,"Normal capture with priority"); - _LIT(TestUpDown,"Capture ups and downs"); - _LIT(TestUpDownWithPriority,"Capture ups and downs with priority"); - _LIT(TestAbort,"Abort key"); - _LIT(TestAbort2,"Abort key extended"); - _LIT(TestErrors,"Errors"); - _LIT(TestCaptureKey,"Capture Key"); - _LIT(TestCapturePowerOffKey,"Capture PowerOff Key"); - - iTest->iState=iState; - ((CTCaptureKeyStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); - switch(iState) - { -/** -@SYMTestCaseID GRAPHICS-WSERV-0140 - - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Normal key capture test - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions The test uses 3 wserv clients with their own window groups. The - clients are registered for different keys to capture. The test - simulates key presses. - -@SYMTestExpectedResults Checks that the key presses are captured correctly . -*/ - case 0: // Dummy one to let capture key tests run - ((CTCaptureKeyStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0140")); - iTest->LogSubTest(Test0); - iState++; - SendEvents(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0141 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Normal key capture test with priorities - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions The test uses 3 wserv clients with their own window groups. The - clients are registered for different keys to capture and with - different priorities. The test simulates key presses. - -@SYMTestExpectedResults Checks that the key presses are captured correctly . -*/ - case 1: - ((CTCaptureKeyStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0141")); - iTest->LogSubTest(TestNormalCaptureWithPriority); - CaptureWithPriorityTest(); - iState++; - SendEvents(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0142 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Up-down key capture test - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions The test uses 3 wserv clients with their own window groups. The - clients are registered for different keys to capture their - up and down events. The test simulates key presses and releases. - -@SYMTestExpectedResults Checks that the key presses and releases are captured correctly . -*/ - case 2: - ((CTCaptureKeyStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0142")); - iTest->LogSubTest(TestUpDown); - CaptureUpsAndDownsTest(); - iState++; - SendEvents(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0143 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Up-down key capture test with priorities - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions The test uses 3 wserv clients with their own window groups. The - clients are registered with different priorities for different keys to capture their - up and down events. The test simulates key presses and releases. - -@SYMTestExpectedResults Checks that the key presses and releases are captured correctly . -*/ - case 3: - ((CTCaptureKeyStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0143")); - iTest->LogSubTest(TestUpDownWithPriority); - CaptureUpsAndDownsWithPriorityTest(); - iState++; - SendEvents(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0144 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Priority key events test - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions The test simulates key events and make sure that the events are - recieved by the registered wserv client. - -@SYMTestExpectedResults Makes sure that key code is the same as a key simulated, event modifiers comply - with registered priority key's modifirs and mask, and that event handle - is a window group of the session. - -*/ - case 4: - ((CTCaptureKeyStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0144")); - if (iSubState==numCapKeyTests+numUpDownKeyWithPriorityTests+numUpDownKeyTests+numUpDownKeyWithPriorityTests) - { - iTest->LogSubTest(TestAbort); - SetUpPriorityKeyTest(); - } - else - iTest->LogSubTest(TestAbort2); - //iState++; - SendEvents(); - TheClient->WaitUntilEventPending(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0145 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Invalid capture keys test - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Memorizes amount of objects that the server has allocated for that client. - Tries to register 3 different capture keys with invalid - modifiers and modifirs mask pair. - -@SYMTestExpectedResults Makes sure that the number of server-side objects for the - session didn't change. -*/ - case 5: - ((CTCaptureKeyStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0145")); - iTest->LogSubTest(TestErrors); - BadParams(); - ((CTCaptureKeyStep*)iStep)->RecordTestResultL(); -/** -@SYMTestCaseID GRAPHICS-WSERV-0146 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Capture keys clean up test - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Memorizes amount of objects that the server has allocated for that client. - Creates a window group and requests two keys to be captured. - Cancels one key capture request and closes the window group. - -@SYMTestExpectedResults Checks that creation of the group or registering a capture key - increased this amount by 1 each time. - Makes sure that the number of server-side objects for the - session in the end of the test is the same as in the beginning. -*/ - ((CTCaptureKeyStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0146")); - iTest->LogSubTest(TestCaptureKey); - CapKeyPurgingL(); - iState++; - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0147 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Capture power off key test - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions The test creates a new session, new window group and a new window - in the group. After that the test gives "Hello" name to the group - and tries to register for key capture of FN+EKeyDevice2 and 0xF844 - buttons. Makes sure that registration fails due to KErrPermissionDenied - error. - Then the test changes the name of the window group to "SysApp" - and tries the registration again. Makes sure that operation - completed successfully. - -@SYMTestExpectedResults See actions -*/ - case 6: - ((CTCaptureKeyStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0147")); - iTest->LogSubTest(TestCapturePowerOffKey); - CapKeyPowerOffL(); - iState++; - break; - default: - ((CTCaptureKeyStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - TestComplete(); - } - ((CTCaptureKeyStep*)iStep)->RecordTestResultL(); - - } - - -__WS_CONSTRUCT_STEP__(CaptureKey) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TCapKey.H --- a/windowing/windowserver/tauto/TCapKey.H Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,313 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef __TCAPKEY_H__ -#define __TCAPKEY_H__ - -#include -#include -#include "../tlib/testbase.h" -#include "AUTO.H" -#include "TGraphicsHarness.h" - -enum TTestMode - { - EModeNormalCapture, - EModeNormalCaptureWithPriority, - EModeWaitingForFirstNormalCapWithPriority, - EModeWaitingForFirstDown, - EModeWaitingForFirstDownWithPriority, - EModeKeyUpsAndDowns, - EModeKeyUpsAndDownsWithPriority, - EModeAbortKeys, - }; -enum TCapKeyRetValues - { - ECapKeyOkay, - ECapKeyRetry, - ECapKeyFail, - }; - -struct SCapKeyParams - { - TInt connIndex; // Connection that should capture this key - TUint keyCode; - TUint modifier_mask; - TUint modifiers; - TInt priority; - }; - -struct SCapKeyTestParams - { - TText *txt; // Text message telling user what to do - TInt connIndex; // Connection that receive the key press - TUint keyCode; // Expected key code - TUint modifier_mask;// Modifiers mask for expected modifiers - TUint modifiers; // Expected modifiers - }; - -struct SAbortKeyTests - { - TUint keyCode; // Expected key code - TUint modifier_mask;// Modifiers mask for expected modifiers - TUint modifiers; // Expected modifiers - }; - -LOCAL_D SCapKeyParams capKeys[]={ - {1,19,EModifierFunc|EModifierCtrl,EModifierFunc|EModifierCtrl,0}, - {2,'b',EModifierFunc|EModifierCtrl,EModifierFunc,0}, - {2,'n',EModifierFunc|EModifierCtrl,EModifierFunc,0}, - {0,3,EModifierFunc|EModifierCtrl,EModifierFunc|EModifierCtrl,0}, - {2,'q',0,0,0}, - {2,'w',0,0,0}, - }; - -LOCAL_D SCapKeyParams capKeysWithPriority[]={ - {2,'h',0,0,7}, - {1,'h',EModifierFunc|EModifierCtrl|EModifierShift,0,7}, - {0,'h',EModifierFunc|EModifierCtrl|EModifierShift,0,7}, - {2,'j',EModifierFunc|EModifierCtrl|EModifierShift,0,6}, - {1,'j',EModifierFunc|EModifierCtrl|EModifierShift,0,6}, - {0,'j',EModifierFunc|EModifierCtrl|EModifierShift,0,5}, - {2,'k',EModifierFunc|EModifierCtrl|EModifierShift,0,4}, - {1,'k',EModifierFunc|EModifierCtrl|EModifierShift,0,3}, - {0,'k',EModifierFunc|EModifierCtrl|EModifierShift,0,2}, - }; - -LOCAL_D SCapKeyParams capUpAndDownKeys[]={ - {2,EStdKeySpace,EModifierFunc|EModifierCtrl|EModifierShift,0,0}, - {2,EStdKeyEnter,EModifierFunc|EModifierCtrl|EModifierShift,EModifierShift,0}, - }; - -LOCAL_D SCapKeyParams capUpAndDownKeysWithPriority[]={ - {2,'H',EModifierFunc|EModifierCtrl|EModifierShift,0,7}, - {1,'H',EModifierFunc|EModifierCtrl|EModifierShift,0,7}, - {0,'H',EModifierFunc|EModifierCtrl|EModifierShift,0,7}, - {2,'J',EModifierFunc|EModifierCtrl|EModifierShift,0,6}, - {1,'J',EModifierFunc|EModifierCtrl|EModifierShift,0,6}, - {0,'J',EModifierFunc|EModifierCtrl|EModifierShift,0,5}, - {2,'K',EModifierFunc|EModifierCtrl|EModifierShift,0,4}, - {1,'K',EModifierFunc|EModifierCtrl|EModifierShift,0,3}, - {0,'K',EModifierFunc|EModifierCtrl|EModifierShift,0,2}, - }; - -LOCAL_D SCapKeyTestParams capKeyTests[]={ - {(TText *)_S("Press q"),2,'q',EModifierFunc|EModifierCtrl|EModifierShift,0}, - {(TText *)_S("Press w"),2,'w',EModifierFunc|EModifierCtrl|EModifierShift,EModifierFunc}, - {(TText *)_S("Press a"),0,'a',0}, - {(TText *)_S("Press s"),1,19,EModifierFunc|EModifierCtrl|EModifierShift,EModifierFunc|EModifierCtrl}, - {(TText *)_S("Press n"),2,'n',EModifierFunc|EModifierCtrl|EModifierShift,EModifierFunc}, - {(TText *)_S("Press b"),0,2,EModifierFunc|EModifierCtrl|EModifierShift,EModifierFunc|EModifierCtrl}, - {(TText *)_S("Press d"),0,'d',EModifierFunc|EModifierCtrl|EModifierShift,EModifierFunc}, - {(TText *)_S("Press c"),0,3,EModifierFunc|EModifierCtrl|EModifierShift,EModifierFunc|EModifierCtrl}, -// -// Capture normal keys with priority -// - {(TText *)_S("Press h"),0,'h',EModifierFunc|EModifierCtrl|EModifierShift,0}, - {(TText *)_S("Press j"),1,'j',EModifierFunc|EModifierCtrl|EModifierShift,0}, - {(TText *)_S("Press k"),2,'k',EModifierFunc|EModifierCtrl|EModifierShift,0}, -// -// Capture ups and downs -// - {(TText *)_S("Press "),2,EStdKeySpace,EModifierFunc|EModifierCtrl|EModifierShift,0}, - {(TText *)_S("Press "),0,EStdKeyEnter,EModifierShift,0}, - {(TText *)_S("Press "),0,EStdKeySpace,EModifierFunc|EModifierCtrl|EModifierShift,EModifierShift}, - {(TText *)_S("Press "),2,EStdKeyEnter,EModifierShift,EModifierShift}, - -// -// Capture ups and downs -// - {(TText *)_S("Press H"),0,'H',EModifierFunc|EModifierCtrl|EModifierShift,0}, - {(TText *)_S("Press J"),1,'J',EModifierFunc|EModifierCtrl|EModifierShift,0}, - {(TText *)_S("Press K"),2,'K',EModifierFunc|EModifierCtrl|EModifierShift,0}, -// -// Priority keys -// - {(TText *)_S("Press c"),0,0,0,0}, - {(TText *)_S("Press d"),0,0,0,0}, - {(TText *)_S("Press z"),0,0,0,0}, - }; - -LOCAL_D SAbortKeyTests abortKeyTests[]={ - {3,EModifierCtrl,EModifierCtrl}, - {4,EModifierCtrl,EModifierCtrl}, - {'z',EModifierFunc|EModifierCtrl|EModifierShift,0} - }; - -struct SErrorCapKey - { - TInt keyCode; - TUint modifier_mask; - TUint modifiers; - }; - -LOCAL_D SErrorCapKey errorKeys[]={ - {'a',EModifierFunc|EModifierShift,EModifierFunc|EModifierCtrl}, - {'1',0,EModifierFunc}, - {3,EModifierCtrl,EModifierCtrl|EModifierShift}, - }; - -const TInt numCapKeys=sizeof(capKeys)/sizeof(capKeys[0]); -const TInt numCapKeysWithPriority=sizeof(capKeysWithPriority)/sizeof(capKeysWithPriority[0]); -const TInt numTests=sizeof(capKeyTests)/sizeof(capKeyTests[0]); -const TInt numErrorKeys=sizeof(errorKeys)/sizeof(errorKeys[0]); -const TInt numAbortKeyTests=sizeof(abortKeyTests)/sizeof(abortKeyTests[0]); -const TInt numUpDownKeys=sizeof(capUpAndDownKeys)/sizeof(capUpAndDownKeys[0]); -const TInt numUpDownKeysWithPriority=sizeof(capUpAndDownKeysWithPriority)/sizeof(capUpAndDownKeysWithPriority[0]); -const TInt numUpDownKeyTests=4; -const TInt numUpDownKeyWithPriorityTests=3; -const TInt numCapKeyWithPriorityTests=3; -const TInt numCapKeyTests=numTests-numAbortKeyTests-numUpDownKeyTests-numUpDownKeyWithPriorityTests-numCapKeyWithPriorityTests; - -LOCAL_D TInt capKeyHandle[numCapKeys]; -LOCAL_D TInt capKeyWithPriorityHandle[numCapKeysWithPriority]; -LOCAL_D TInt capUpDownKeyHandle[numUpDownKeys]; -LOCAL_D TInt capUpDownKeyWithPriorityHandle[numUpDownKeysWithPriority]; - -class CCKWindow; -class CTCaptureKey; -class CCKAbortConnection; - -class CCKConnectionBase : public CTClient - { -public: - CCKConnectionBase(CTCaptureKey *aTest); - void ConstructL(); -protected: - CTCaptureKey *iTest; - }; - -class CCKConnection : public CCKConnectionBase - { -public: - CCKConnection(CTCaptureKey *aTest, TInt aConnIndex); - ~CCKConnection(); - void ConstructL(); - void CheckKeyL(const SCapKeyTestParams &aKeyTest, const TKeyEvent &aKey); - void SubStateChanged(); - void KeyTestL(TInt aBool); - void KeyL(const TKeyEvent &aKey,const TTime &aTime); - void CheckUpDownL(const SCapKeyTestParams &aKeyTest, const TKeyEvent &aKey); - void CheckUpDownL(const TKeyEvent &aKey); - inline TInt Index() {return iConnIndex;} -protected: - TInt iConnIndex; - CCKWindow *iWin; - }; - -class CAbortHandler : public CTEventBase - { -public: - CAbortHandler(RWsSession *aWs, CCKAbortConnection *aConnection); - ~CAbortHandler(); - void Request(); -protected: - void DoCancel(); - void doRunL(); -protected: - CCKAbortConnection *iConnection; - }; - -class CCKAbortConnection : public CCKConnectionBase - { -public: - CCKAbortConnection(CTCaptureKey *aTest); - ~CCKAbortConnection(); - void ConstructL(); - void ReceivedAbortEvent(TInt aHandle, TKeyEvent *aKey); - void Foreground(); -protected: - CAbortHandler *iAbortHandler; - TInt iAbortKeyIndex; - }; - -class CCKWindow : public CTWin - { -public: - CCKWindow(CTCaptureKey *aTest, TInt aConnIndex); - void SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc); - void Draw(); -protected: - TInt iConnIndex; - CTCaptureKey *iTest; - TRgb iBack; - }; - -class CCKWindowGroup : public CTWindowGroup - { -public: - CCKWindowGroup(CTClient *aClient, CTCaptureKey *aTest); - void KeyL(const TKeyEvent &aKey,const TTime &aTime); - void KeyDownL(const TKeyEvent &aKey,const TTime &); - void KeyUpL(const TKeyEvent &aKey,const TTime &); - void CheckUpDown(const SCapKeyTestParams &aKeyTest, const TKeyEvent &aKey); -private: - CTCaptureKey *iTest; - }; - -class CTCaptureKey : public CTWsGraphicsBase - { -public: - CTCaptureKey(CTestStep* aStep); - ~CTCaptureKey(); - void ConstructL(); - void EndCaptureKeyTest(); - inline TInt State() {return iState;} - TInt SubState() const; - void IncSubState(); - void BadParams(); - void CapKeyPurgingL(); - void SetUpPriorityKeyTest(); - void CaptureWithPriorityTest(); - void CaptureUpsAndDownsTest(); - void CaptureUpsAndDownsWithPriorityTest(); - TTestMode Mode(); - void SetMode(TTestMode aMode); - inline TestClient* Client() {return TheClient;} - void SendEvents(); - void CapKeyPowerOffL(); - inline TInt ScreenNumber() {return iTest->ScreenNumber();} -protected: - virtual void RunTestCaseL(TInt aCurTestCase); -private: - CCKConnection *iConn1; - CCKConnection *iConn2; - CCKConnection *iConn3; - CCKAbortConnection *iAbortConn; - TSize iWinSize; - TInt iState; - TInt iSubState; - TTestMode iMode; - }; - -class CTCaptureKeyStep : public CTGraphicsStep - { -public: - CTCaptureKeyStep(); -protected: - //from CTGraphicsStep - virtual CTGraphicsBase* CreateTestL(); - }; - -_LIT(KTCaptureKeyStep,"TCaptureKey"); - - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TDERIVED.CPP --- a/windowing/windowserver/tauto/TDERIVED.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,435 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Test classes derived from Wserv client side classes -// -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include "TDERIVED.H" - -CTDerived::CTDerived(CTestStep* aStep) : CTWsGraphicsBase(aStep) - { - } - -CTDerived::~CTDerived() - { - } - -// -// CDerivedWindowGc // -// - -CDerivedWindowGc::CDerivedWindowGc(CWsScreenDevice *aDevice) : CWindowGc(aDevice) - { - } - -CDerivedWindowGc::~CDerivedWindowGc() - { - } - -void CDerivedWindowGc::DrawLine(const TPoint &aPoint1,const TPoint &aPoint2) - { - CWindowGc::DrawLine(aPoint1+TPoint(10,10), aPoint2-TPoint(10,10)); - } - -// -// RDerivedSession // -// - -TInt RDerivedSession::ResourceCount() - { - return(RWsSession::ResourceCount()+1); - } - -void RDerivedSession::EnableAutoFlush() - { - SetAutoFlush(ETrue); - } - -// -// Derived windows // -// - -RDerivedBlankWindow::RDerivedBlankWindow() - {} -RDerivedBlankWindow::RDerivedBlankWindow(RWsSession &aWs) : RBlankWindow(aWs) - { - } - -void RDerivedBlankWindow::SetColor(TRgb aColor) - { - RBlankWindow::SetColor(~aColor); - } - -void RDerivedBlankWindow::SetColorGray() - { - RBlankWindow::SetColor(TRgb::Gray16(8)); - } - -RDerivedWindow::RDerivedWindow() - {} -RDerivedWindow::RDerivedWindow(RWsSession &aWs) : RWindow(aWs) - { - } - -void RDerivedWindow::SetBackgroundColor(TRgb aColor) - { - RWindow::SetBackgroundColor(~aColor); - } - -void RDerivedWindow::SetBackgroundColorGray() - { - RWindow::SetBackgroundColor(TRgb::Gray16(8)); - } - -RDerivedBackedUpWindow::RDerivedBackedUpWindow() - {} -RDerivedBackedUpWindow::RDerivedBackedUpWindow(RWsSession &aWs) : RBackedUpWindow(aWs) - { - } - -TInt RDerivedBackedUpWindow::BitmapHandle() - { - MaintainBackup(); - return(RBackedUpWindow::BitmapHandle()+1); - }; - -RDerivedWindowGroup::RDerivedWindowGroup() - {} - -RDerivedWindowGroup::RDerivedWindowGroup(RWsSession &aWs) : RWindowGroup(aWs) - { - } - -TName RDerivedWindowGroup::Name() const - { - return(_L("Fred")); - } - -// -// CDerivedScreenDevice // -// - -CDerivedScreenDevice::CDerivedScreenDevice() - {} - -CDerivedScreenDevice::CDerivedScreenDevice(RWsSession &aWs) : CWsScreenDevice(aWs) - {} - -TSize CDerivedScreenDevice::SizeInPixels() const - { - TSize size=CWsScreenDevice::SizeInPixels(); - return(TSize(size.iWidth*2,size.iHeight*2)); - } - -// -// Derived Sprite/Pointer cursor // -// - -RDerivedSprite::RDerivedSprite() - { - } - -RDerivedSprite::RDerivedSprite(RWsSession &aWs) : RWsSprite(aWs) - { - } - -RDerivedPointerCursor::RDerivedPointerCursor() - { - } - -RDerivedPointerCursor::RDerivedPointerCursor(RWsSession &aWs) : RWsPointerCursor(aWs) - { - } - -// - -void CTDerived::ConstructL() - { - TheGc->Activate(*BaseWin->Win()); - TheGc->Clear(); - TheGc->SetBrushColor(TRgb::Gray16(12)); - TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - TheGc->SetPenStyle(CGraphicsContext::ENullPen); - TheGc->DrawRect(TRect(BaseWin->Win()->Size())); - TheGc->Deactivate(); - TheGc->Activate(*TestWin->Win()); - TheGc->Clear(); - TheGc->SetBrushColor(TRgb::Gray16(4)); - TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - TheGc->SetPenStyle(CGraphicsContext::ENullPen); - TheGc->DrawRect(TRect(TestWin->Win()->Size())); - TheGc->Deactivate(); - } - -void CTDerived::DerivedWindowGcL() - { - CDerivedWindowGc *dgc=new(ELeave) CDerivedWindowGc(TheClient->iScreen); - dgc->Construct(); - dgc->Activate(*TestWin->Win()); - dgc->SetBrushStyle(CGraphicsContext::ESolidBrush); - TestWin->Win()->BeginRedraw(); - dgc->DrawRect(TRect(TestWin->Win()->Size())); - dgc->DrawLine(TPoint(0,0),TestWin->Win()->Size().AsPoint()); - TestWin->Win()->EndRedraw(); - dgc->Deactivate(); - delete dgc; - dgc = NULL; - CWindowGc *wgc=new(ELeave) CWindowGc(TheClient->iScreen); - wgc->Construct(); - wgc->Activate(*BaseWin->Win()); - wgc->SetBrushStyle(CGraphicsContext::ESolidBrush); - BaseWin->Win()->BeginRedraw(); - wgc->DrawRect(TRect(TestWin->Win()->Size())); - wgc->DrawLine(TPoint(10,10),TestWin->Win()->Size().AsPoint()-TPoint(10,10)); - BaseWin->Win()->EndRedraw(); - wgc->Deactivate(); - delete wgc; - wgc = NULL; - CompareWindows(_L("CTDerived::DerivedWindowGcL()")); - } - -void CTDerived::DerivedSession() - { - TInt err; - err = iDSession.Connect(); - if (err!=KErrNone) - return; - - // use the correct screen - CWsScreenDevice* screen = NULL; - TRAP(err, screen = new (ELeave) CWsScreenDevice(iDSession)); - if (err!=KErrNone) - { - iDSession.Close(); - return; - } - - if ((err=screen->Construct(iTest->iScreenNumber))!=KErrNone) - { - delete screen; - iDSession.Close(); - return; - } - - delete screen; - - TInt retVal = iDSession.ResourceCount(); - TEST(retVal==1); - if (retVal!=1) - INFO_PRINTF3(_L("iDSession.ResourceCount() return value - Expected: %d, Actual: %d"), 1, retVal); - - iDSession.SetAutoFlush(EFalse); - iDSession.EnableAutoFlush(); - - TBool retBool = iDSession.SetAutoFlush(EFalse); - TEST(retBool); - if (!retBool) - INFO_PRINTF3(_L("iDSession.SetAutoFlush(EFalse) return value - Expected: %d, Actual: %d"), ETrue, retBool); - - iDSession.Close(); - } - -void CTDerived::DerivedWindows() - { -// -// Window group -// - iDGroup=RDerivedWindowGroup(TheClient->iWs); - iDGroup.Construct(222); - iDGroup.Name(); -// -// Redraw up window -// - iDRedraw=RDerivedWindow(TheClient->iWs); - iDRedraw.Construct(iDGroup,12); - iDRedraw.SetBackgroundColor(TRgb(1,2,3)); - iDRedraw.SetBackgroundColorGray(); - iDRedraw.Close(); -// -// Blank up window -// - iDBlank=RDerivedBlankWindow(TheClient->iWs); - iDBlank.Construct(iDGroup,123); - iDBlank.SetColor(TRgb(1,20,50)); - iDBlank.SetColorGray(); - iDBlank.Close(); -// -// Backed up window -// - iDBackedUp=RDerivedBackedUpWindow(TheClient->iWs); - iDBackedUp.Construct(iDGroup,EGray4,1234); - iDBackedUp.BitmapHandle(); - iDBackedUp.Close(); -// - iDGroup.Close(); - } - -void CTDerived::DerivedScreenDeviceL() - { - CWsScreenDevice *wsd=new(ELeave) CWsScreenDevice(TheClient->iWs); - User::LeaveIfError(wsd->Construct(iTest->iScreenNumber)); - TSize size1(wsd->SizeInPixels()); - delete wsd; - CDerivedScreenDevice *dsd=new(ELeave) CDerivedScreenDevice(TheClient->iWs); - User::LeaveIfError(dsd->Construct(iTest->iScreenNumber)); - TSize size2(dsd->SizeInPixels()); - delete dsd; - TEST(size2.iWidth==size1.iWidth*2 && size2.iHeight==size1.iHeight*2); - } - -void CTDerived::DerivedSprite() - { - iDSprite=RDerivedSprite(TheClient->iWs); - TSpriteMember spm; - spm.iBitmap=NULL; - spm.iMaskBitmap=NULL; - spm.iInvertMask=EFalse; - spm.iOffset=TPoint(0,0); // Offset from sprites central position - spm.iInterval=TTimeIntervalMicroSeconds32(1000000); - iDSprite.Construct(*TestWin->Win(), TPoint(10,10), 0); - iDSprite.Close(); -// - iDPCursor=RDerivedPointerCursor(TheClient->iWs); - iDPCursor.Construct(0); - iDPCursor.Close(); - }; - -void CTDerived::RunTestCaseL(TInt /*aCurTestCase*/) - { - ((CTDerivedStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); - switch(++iTest->iState) - { -/** -@SYMTestCaseID GRAPHICS-WSERV-0075 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test derived window graphics context - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Draw using a derived window gc and a normal - window gc and check the dawing is the same - -@SYMTestExpectedResults Drawing is the same with a derived window gc -*/ - case 1: - ((CTDerivedStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0075")); - iTest->LogSubTest(_L("Derived Gc")); - DerivedWindowGcL(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0076 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test derived window server session - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Test that a derived window server session functions - the same as a normal window server session - -@SYMTestExpectedResults The derived window server session functions correctly -*/ - case 2: - ((CTDerivedStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0076")); - iTest->LogSubTest(_L("Derived Session")); - DerivedSession(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0077 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test derived windows and window groups function correctly - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Test that a derived windows and window groups function - the same as the classes they are derived from - -@SYMTestExpectedResults The derived windows and window group functions correctly -*/ - case 3: - ((CTDerivedStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0077")); - iTest->LogSubTest(_L("Derived Blank Window")); - DerivedWindows(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0078 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test derived screen devices function correctly - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Test that a derived screen device function - the same as the class it is derived from - -@SYMTestExpectedResults The derived screen device functions correctly -*/ - case 4: - ((CTDerivedStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0078")); - iTest->LogSubTest(_L("Derived Screed Device")); - DerivedScreenDeviceL(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0079 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test derived sprites and pointer cursors function - correctly - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Test that a derived sprite and pointer cursor - function correctly - -@SYMTestExpectedResults The derived sprite and pointer cursor function - correctly -*/ - case 5: - ((CTDerivedStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0079")); - iTest->LogSubTest(_L("Derived Sprites")); - DerivedSprite(); - break; - case 6: - ((CTDerivedStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - ((CTDerivedStep*)iStep)->CloseTMSGraphicsStep(); - TestComplete(); - break; - } - ((CTDerivedStep*)iStep)->RecordTestResultL(); - } - -__WS_CONSTRUCT_STEP__(Derived) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TDERIVED.H --- a/windowing/windowserver/tauto/TDERIVED.H Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,139 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef __TDERIVED_H__ -#define __TDERIVED_H__ - -#include -#include -#include "../tlib/testbase.h" -#include "AUTO.H" -#include "TGraphicsHarness.h" - -class CDerivedWindowGc : public CWindowGc - { -public: - CDerivedWindowGc(CWsScreenDevice *aDevice); - ~CDerivedWindowGc(); - void DrawLine(const TPoint &aPoint1,const TPoint &aPoint2); - }; - -class RDerivedSession : public RWsSession - { -public: - TInt ResourceCount(); - void EnableAutoFlush(); - }; - -class RDerivedBlankWindow : public RBlankWindow - { -public: - RDerivedBlankWindow(); - RDerivedBlankWindow(RWsSession &aWs); - void SetColor(TRgb aColor); - void SetColorGray(); - }; - -class RDerivedWindow : public RWindow - { -public: - RDerivedWindow(); - RDerivedWindow(RWsSession &aWs); - void SetBackgroundColor(TRgb aColor); - void SetBackgroundColorGray(); - }; - -class RDerivedBackedUpWindow : public RBackedUpWindow - { -public: - RDerivedBackedUpWindow(); - RDerivedBackedUpWindow(RWsSession &aWs); - TInt BitmapHandle(); - }; - -class RDerivedWindowGroup : public RWindowGroup - { -public: - RDerivedWindowGroup(); - RDerivedWindowGroup(RWsSession &aWs); - TName Name() const; - }; - -class CDerivedScreenDevice : public CWsScreenDevice - { -public: - CDerivedScreenDevice(RWsSession &aWs); - CDerivedScreenDevice(); - TSize SizeInPixels() const; - }; - -class RDerivedSprite : public RWsSprite - { -public: - RDerivedSprite(); - RDerivedSprite(RWsSession &aWs); - }; - -class RDerivedPointerCursor : public RWsPointerCursor - { -public: - RDerivedPointerCursor(); - RDerivedPointerCursor(RWsSession &aWs); - }; - -class CTDerived : public CTWsGraphicsBase - { -public: - CTDerived(CTestStep* aStep); - void ConstructL(); - void DerivedWindowGcL(); - void DerivedSession(); - void DerivedWindows(); - void DerivedScreenDeviceL(); - void DerivedSprite(); - ~CTDerived(); -protected: -//from CTGraphicsStep - virtual void RunTestCaseL(TInt aCurTestCase); -private: - TSize iWinSize; - RDerivedSession iDSession; - RDerivedWindow iDRedraw; - RDerivedBlankWindow iDBlank; - RDerivedBackedUpWindow iDBackedUp; - RDerivedWindowGroup iDGroup; - RDerivedSprite iDSprite; - RDerivedPointerCursor iDPCursor; - }; - -class CTDerivedStep : public CTGraphicsStep - { -public: - CTDerivedStep(); -protected: - //from CTGraphicsStep - virtual CTGraphicsBase* CreateTestL(); - }; - -_LIT(KTDerivedStep,"TDerived"); - - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TDirectA.CPP --- a/windowing/windowserver/tauto/TDirectA.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,3950 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Test Direct Screen Access -// -// - -#include "tdirecta.h" - -static TRect WinExt; -static TInt WinCol=0; -static TTimeIntervalMicroSeconds32 MoveInterval; -static TTimeIntervalMicroSeconds32 ModeInterval; -static TTimeIntervalMicroSeconds32 FlipInterval; -static TBool ImmediateModeSwitch; -#if defined(LOGGING) - LOCAL_D TLogMessageText LogMessageText; -#endif - -_LIT(SemControl,"Control"); -_LIT(SemNextOp,"TrigerWindow"); -_LIT(FontName,"DejaVu Serif Condensed"); -_LIT(QueueControl,"Queue"); - -LOCAL_D TSize FullScreenModeSize; -LOCAL_D TInt Copy2ndHalfOfScreen; - -const TBool KRegionTrackingOnly = ETrue; -const TBool KDrawingDsa = EFalse; - -const TInt KPanicTestOrdinalPriority=65536; -const TInt KMainTestOrdinalPriority=65535; -const TInt KMainTestBaseWindow=KMainTestOrdinalPriority/3; -const TInt KAboveMainTestBaseWindow = KMainTestBaseWindow +1; - -const TInt KMaxIdlingTime = 25; //used for RegionTrackingOnly DSAs, it represents the maximum number of times the Idling function can be called -//Ids of two RegionTrackingOnly DSAs -const TInt KRegionTrackingOnlyDsaWaitingForAbortSignal = 25; -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA -const TInt KRegionTrackingOnlyDsaNoAbortSignal = 26; -#endif - -const TInt KRegionTrackingOnlyDsaExistLast = 0; -const TInt KDrawingDsaExistLast = 1; -const TInt KShortDelay = 5000; -#define SHORT_DELAY TTimeIntervalMicroSeconds32(KShortDelay) - -_LIT(KSem_DefectFix_KAA_5J3BLW_Name, "DefectFix_KAA_5J3BLW"); - -GLDEF_C TInt ProcDirect(TAny *aScreenNumber) - { - CTrapCleanup* cleanupStack = NULL; - User::LeaveIfNull(cleanupStack = CTrapCleanup::New()); - -#if defined(LOGGING) - _LIT(KWindow,"Window Toggle Vis="); - _LIT(KParams,"%d, Pos=(%d,%d,%d,%d), Col=%d"); -#endif - RSemaphore controlSem; - RSemaphore windowSem; - User::LeaveIfError(controlSem.OpenGlobal(SemControl)); - User::LeaveIfError(windowSem.OpenGlobal(SemNextOp)); - RWsSession ws; - User::LeaveIfError(ws.Connect()); - - // assign to the correct screen - CWsScreenDevice* screen = NULL; - TInt err; - TRAP(err, screen = new (ELeave) CWsScreenDevice(ws)); - if (err!=KErrNone) - return err; - - if ((err=screen->Construct((TInt)aScreenNumber))!=KErrNone) - { - delete screen; - return err; - } - - RWindowGroup group(ws); - User::LeaveIfError(group.Construct(898)); - group.EnableReceiptOfFocus(EFalse); - group.SetOrdinalPosition(0,KAboveMainTestBaseWindow ); - RBlankWindow window(ws); - User::LeaveIfError(window.Construct(group,899)); - TBool vis=EFalse; - window.SetVisible(vis); - window.Activate(); - ws.Flush(); - controlSem.Signal(); - windowSem.Wait(); - RMsgQueueBase queue; - TInt open = queue.OpenGlobal(QueueControl); - TInt data; - while (queue.Receive(&data,sizeof(TInt)) != KErrNone) - { - vis=!vis; - if (vis) - { - window.SetColor(TRgb::Gray4(WinCol)); - window.SetExtent(WinExt.iTl,WinExt.Size()); - #if defined(LOGGING) - LogMessageText.Copy(KWindow); - LogMessageText.AppendFormat(KParams,vis,WinExt.iTl.iX,WinExt.iTl.iY,WinExt.iBr.iX,WinExt.iBr.iY,WinCol); - ws.LogMessage(LogMessageText); - #endif - } - window.SetVisible(vis); - ws.Flush(); - windowSem.Wait(); - } - queue.Close(); - - window.Close(); - group.Close(); - - delete screen; - ws.Close(); - controlSem.Close(); - windowSem.Close(); - - delete cleanupStack; - return(KErrNone); - } - - -/*CDirectScreenAccessOld*/ - -CDirectScreenAccessOld* CDirectScreenAccessOld::NewL(RWsSession& aWs,MAbortDirectScreenAccess& aAborter) - { - CDirectScreenAccessOld* self=new(ELeave) CDirectScreenAccessOld(aWs,aAborter); - CleanupStack::PushL(self); - self->ConstructL(); - CleanupStack::Pop(self); - return self; - } - -CDirectScreenAccessOld::~CDirectScreenAccessOld() - { - __ASSERT_ALWAYS(!iAborting,AutoPanic(EAutoPanicDirect)); - Cancel(); - iDirectAccess.Close(); - } - -void CDirectScreenAccessOld::ConstructL() - { - User::LeaveIfError(iDirectAccess.Construct()); - CActiveScheduler::Add(this); - } - -TInt CDirectScreenAccessOld::Request(RRegion*& aRegion, RWindowBase& aWindow) - { - TInt ret=iDirectAccess.Request(aRegion,iStatus,aWindow); - if (ret==KErrNone) - SetActive(); - return ret; - } - -void CDirectScreenAccessOld::DoCancel() - { - iDirectAccess.Cancel(); - } - -void CDirectScreenAccessOld::RunL() - { - iAborting=ETrue; - iAborter.AbortNow(REINTERPRET_CAST(RDirectScreenAccess::TTerminationReasons&,iStatus)); - iAborting=EFalse; - iDirectAccess.Completed(); - } - - -/*CColorAnimation*/ - -CColorAnimation* CColorAnimation::NewL(TInt aScreenNumber,TInt aId,MAnimCallBacks& aCallBack,CTWinBase& aParent,TRect aExtent,TBool aStart,TBool aRegionTrackingOnly) - { - CColorAnimation* self=new(ELeave) CColorAnimation(aScreenNumber,aId,aCallBack); - CleanupStack::PushL(self); - self->ConstructL(aParent,aExtent,aRegionTrackingOnly); - if (aStart) - self->StartL(); - CleanupStack::Pop(self); - return self; - } - -CColorAnimation::~CColorAnimation() - { - delete iTimer; - delete iDrawer; - delete iWindow; - delete iWindow2; - TheClient->Flush(); - } - -void CColorAnimation::ConstructL(CTWinBase& aParent,TRect aExtent,TBool aRegionTrackingOnly,TInt aTypeWindow/*=0*/,TInt aSingleWinForMultipleDSA/*=0*/) - { - iRegionTrackingOnly = aRegionTrackingOnly; - // Make sure that the top right corner is not 0,0 - if (aTypeWindow && aExtent.iTl==TPoint(0,0)) - { - aExtent.iTl=TPoint(10,10); - } - RWindowBase* win=NULL; - iSingleWinForMultipleDSA=aSingleWinForMultipleDSA; - if (aSingleWinForMultipleDSA) - { - win=iCallBack.iCallBackWin->BaseWin(); - iWinSize=TheClient->iScreen->SizeInPixels(); - } - else - { - iWindow=new(ELeave) CTBlankWindow(); - iWinSize=aExtent.Size(); - iWindow->ConstructExtLD(aParent,aExtent.iTl,iWinSize); - ChangeModeL(iCallBack.DisplayMode(iId)); - win=iWindow->BaseWin(); - win->SetShadowDisabled(ETrue); - win->Activate(); - } - if (!aTypeWindow) - { - if(iRegionTrackingOnly) - { - iDrawer=CDirectScreenAccess::NewL(TheClient->iWs,*TheClient->iScreen,*win,*this,iRegionTrackingOnly); - } - else - { - //needed for the non NGA case: only the old API is allowed to be used - iDrawer=CDirectScreenAccess::NewL(TheClient->iWs,*TheClient->iScreen,*win,*this); - } - } - else - { - TRect childRect(0,0,100,100); - switch(aTypeWindow) - { - case 1: - { - // Create a Blank Window smaller than it's parent and its top left corner within the parent area and withn the screen area - childRect.Shrink(10,10); - break; - } - case 2: - { - // Create a Blank Window with its top left corner being left side of its parent - childRect.Move(-10,0); - break; - } - } - iWindow2=new(ELeave) CTBlankWindow(); - iWindow2->ConstructExtLD(*iWindow,childRect.iTl,childRect.Size()); - // Finish constructing the window - RWindowBase& win=*iWindow2->BaseWin(); - win.SetShadowDisabled(ETrue); - win.Activate(); - // Create the Direct Screen Access object - if(iRegionTrackingOnly) - { - iDrawer=CDirectScreenAccess::NewL(TheClient->iWs,*TheClient->iScreen,win,*this,iRegionTrackingOnly); - } - else - { - //needed for the non NGA case: only the old API is allowed to be used - iDrawer=CDirectScreenAccess::NewL(TheClient->iWs,*TheClient->iScreen,win,*this); - } - } - TheClient->Flush(); - if (iId == 4) - { - // This clause is needed to prevent sub-test 9 from taking an - // exceedingly large amount of time. The CColorAnimation with iId 4 is - // the one which controls when the test stops. This raise in - // priority compared to the other CColorAnimations, allows it's - // callbacks to get through when otherwise they would take much longer - // due to the volume of callbacks generated by the other - // CColorAnimations - iTimer=CPeriodic::NewL(1); - } - else - { - iTimer=CPeriodic::NewL(0); - } - } - -TPoint CColorAnimation::AbsoluteWindowPosition(TInt aWindowId/*=0*/) - { - if (iSingleWinForMultipleDSA) - { - return iCallBack.iCallBackWin->BaseWin()->AbsPosition(); - } - if (!aWindowId) - { - // Return the absolute position of iWindow, if Color Animation is not for Position Relative to Screen test. - return iWindow->BaseWin()->AbsPosition(); - } - else - { - // Return the absolute position of iWindow2, if it is for Position Relative to Screen test. - return iWindow2->BaseWin()->AbsPosition(); - } - } - -TInt CColorAnimation::DrawColorL(TAny* aAnimation) - { - STATIC_CAST(CColorAnimation*,aAnimation)->DrawColorL(); - return(KErrNone); - } - -TInt CColorAnimation::IdlingL(TAny* aAnimation) - { - (static_cast(aAnimation))->IdlingL(); - return(KErrNone); - } - -void CColorAnimation::StartL(TBool aChildWindow/*=EFalse*/) - { - iDrawer->StartL(); - TRect bounding=iDrawer->DrawingRegion()->BoundingRect(); - TRect window; - if (aChildWindow) - { - window.SetRect(AbsoluteWindowPosition(1),iWinSize); - } - else - { - window.SetRect(AbsoluteWindowPosition(),iWinSize); - } - // Check that the window contains the bounding area (a bounding rect of (0,0,0,0) shouldn't fail the test) - if (!(window.Contains(bounding.iTl) && window.Contains(bounding.iBr-TPoint(1,1))) && bounding.Size()!=TSize(0,0)) - { - iCallBack.Fail(); - // iDrawer->Cancel(); - // iDrawer->StartL(); - // bounding=iDrawer->DrawingRegion()->BoundingRect(); - } - if(!iRegionTrackingOnly) - { - iTimer->Start(0,iCallBack.TimerInterval(iId),TCallBack(CColorAnimation::DrawColorL,this)); - iDrawer->Gc()->SetPenStyle(CGraphicsContext::ENullPen); - iDrawer->Gc()->SetBrushStyle(CGraphicsContext::ESolidBrush); - } - else - { - iTimer->Start(0,iCallBack.TimerInterval(iId),TCallBack(CColorAnimation::IdlingL,this)); - } - } - -void CColorAnimation::StartOrPanic() - { - TRAPD(err,StartL()); - if (err!=KErrNone) - { - iCallBack.LogLeave(err); - iCallBack.Fail(); - } - } - -void CColorAnimation::Stop() - { - iTimer->Cancel(); - iDrawer->Cancel(); - } - -void CColorAnimation::BringWindowToFront() - { - iWindow->WinTreeNode()->SetOrdinalPosition(0); - } - -void CColorAnimation::ChangeModeL(TDisplayMode aMode) - { - User::LeaveIfError(iWindow->BaseWin()->SetRequiredDisplayMode(aMode)); - TheClient->Flush(); - } - -void CColorAnimation::FinishTest() - { - iCallBack.Finished(iId); - } - -inline CDirectScreenAccess* CColorAnimation::GetDrawer() - { - return iDrawer; - } - -void CColorAnimation::DrawColorL() - { - TBool aFinished; - iDrawer->Gc()->SetBrushColor(iCallBack.BrushColorL(iId,iColor,aFinished)); - if (iSingleWinForMultipleDSA==1) - { - iDrawer->Gc()->DrawRect(iWinSize-TSize(iWinSize.iWidth/2,iWinSize.iHeight/2)); - } - else if (iSingleWinForMultipleDSA==2) - { - iDrawer->Gc()->DrawRect(TRect(TPoint(iWinSize.iWidth/2,iWinSize.iHeight/2),TSize(iWinSize.iWidth/2,iWinSize.iHeight/2))); - } - else - { - iDrawer->Gc()->DrawRect(iWinSize); - } - iDrawer->ScreenDevice()->Update(); - if (aFinished) - { - if (iId==1) - { - iWindow->SetSize(TSize(48,52)); - TheClient->Flush(); - } - if (aFinished==1) - Stop(); - iCallBack.Finished(iId); - } - } - -void CColorAnimation::IdlingL() - { - iIdling++; - if(iIdling == KMaxIdlingTime) - { - Stop(); - iIdling = 0; - if (iId == KRegionTrackingOnlyDsaWaitingForAbortSignal) - { - _LIT(KErrorAbortNotReceived,"DSA didn't get an abort signal even though the window was opened in front"); - CallBack().Log((TText8*)__FILE__,__LINE__, ESevrErr,KErrorAbortNotReceived); - CallBack().Fail(); - } - iCallBack.Finished(iId); - } - } - -void CColorAnimation::AbortNow(RDirectScreenAccess::TTerminationReasons /*aReason*/) - { - TInt slow=iCallBack.SlowStopping(iId,iCount); - switch (slow) - { - case eAbortAll: - iCallBack.Finished(iId); - case eAbort: - Stop(); - return; - case eStopDelayed: - User::After(750000); //0.75 secs - break; - default:; - } - ++iCount; - iTimer->Cancel(); - } - -void CColorAnimation::Restart(RDirectScreenAccess::TTerminationReasons /*aReason*/) - { - TRAPD(err,StartL()); - if (err!=KErrNone) - iCallBack.FailedReStart(iId,err); - } - - -/*CScrollingTextDrawer*/ - -CScrollingTextDrawer* CScrollingTextDrawer::NewL(TInt aScreenNumber,CFbsScreenDevice*& aDevice,CFbsBitGc& aGc) - { - CScrollingTextDrawer* self=new(ELeave) CScrollingTextDrawer(aDevice,aGc); - CleanupStack::PushL(self); - self->ConstructL(aScreenNumber); - CleanupStack::Pop(self); - return self; - } - -CScrollingTextDrawer::~CScrollingTextDrawer() - { - if(iFontDevice) - { - iFontDevice->ReleaseFont(iFont); - delete iFontDevice; - } - } - -void CScrollingTextDrawer::ConstructL(TInt aScreenNumber) - { - iFontDevice=CFbsScreenDevice::NewL(aScreenNumber,iDevice->DisplayMode()); - _LIT(text,"ABCDEFGHIJKLMNOPQRSTUVWXYZ"); - iText=text; - CreateFontL(); - //iFirstChar=0; - iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); -#if defined(LOGGING) - iWs.Connect(); - // point to correct screen - CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(iWs); - CleanupStack::PushL(screen); - User::LeaveIfError(screen->Construct(aScreenNumber)); - CleanupStack::Pop(screen); - - _LIT(KConstTextDrawer,"Constructed Text Drawer"); - LogMessageText.Copy(KConstTextDrawer); - iWs.LogMessage(LogMessageText); - iWs.Flush(); - - delete screen; - iWs.Close(); -#endif - } - -void CScrollingTextDrawer::CreateFontL() - { - TInt screenHeight=iDevice->SizeInPixels().iHeight; - TFontSpec fontSpec(FontName,screenHeight); - User::LeaveIfError(iFontDevice->GetNearestFontToDesignHeightInPixels(iFont,fontSpec)); - iGc->UseFont(iFont); - TInt fontHeight=iFont->HeightInPixels(); - iDrawRect.iTl.iY=(screenHeight-fontHeight)/2; - iDrawRect.iBr.iY=iDrawRect.iTl.iY+fontHeight; - iDrawHeight=iFont->AscentInPixels(); - iCharWidth=iFont->CharWidthInPixels(iText[iFirstChar]); - iDrawRect.iBr.iX=Max(iDevice->SizeInPixels().iWidth,iDevice->SizeInPixels().iHeight); - iDrawRect.iTl.iX=iDrawRect.iBr.iX-iCharWidth; - } - -void CScrollingTextDrawer::SetBottomOfTest(TInt aBottom) - { - if (iDrawRect.iBr.iY>aBottom) - { - iDrawRect.iTl.iY-=iDrawRect.iBr.iY-aBottom; - iDrawRect.iBr.iY=aBottom; - } - } - -void CScrollingTextDrawer::Scroll() - { - iCharWidth=iFont->CharWidthInPixels(iText[iFirstChar]); - iDrawRect.iTl.iX-=iJump; - iGc->DrawText(iText.Mid(iFirstChar),iDrawRect,iDrawHeight); - iDevice->Update(); - if (iDrawRect.iTl.iX<-iCharWidth) - { - if (++iFirstChar==iText.Length()) - { - iFirstChar=0; - iDrawRect.iTl.iX=iDevice->SizeInPixels().iWidth; - } - else - iDrawRect.iTl.iX+=iCharWidth; - iCharWidth=iFont->CharWidthInPixels(iText[iFirstChar]); - } - } - - -/*CScrollText*/ - -TInt CScrollText::DrawText(TAny* aAnimation) - { - STATIC_CAST(CScrollText*,aAnimation)->ScrollText(); - return(KErrNone); - } - -CScrollText* CScrollText::NewL(TInt aScreenNumber,TInt aId,CTWindowGroup& aParent,TInt aScrollJump,TBool aStart/*=EFalse*/) - { - CScrollText* self=new(ELeave) CScrollText(aId,aScrollJump,aScreenNumber); - CleanupStack::PushL(self); - self->ConstructL(aParent); - if (aStart) - self->StartL(); - CleanupStack::Pop(self); - return self; - } - -CScrollText::~CScrollText() - { - delete iTimer; - delete iTextDraw; - iTextDraw=NULL; - delete iDrawer; - delete iWindow; - TheClient->Flush(); - } - -void CScrollText::ConstructL(CTWindowGroup& aParent) - { - iWindow=new(ELeave) CTBlankWindow(); - iWindow->ConstructL(aParent); - RWindowBase& win=*iWindow->BaseWin(); - win.Activate(); - iDrawer=CDirectScreenAccess::NewL(TheClient->iWs,*TheClient->iScreen,win,*this); - TheClient->Flush(); - iTimer=CPeriodic::NewL(0); - } - -void CScrollText::StartL() - { - DoContinueL(); - iDrawer->Gc()->SetBrushStyle(CGraphicsContext::ESolidBrush); - if (!iTextDraw) - { - iTextDraw=CScrollingTextDrawer::NewL(iScreenNumber,iDrawer->ScreenDevice(),*iDrawer->Gc()); - iTextDraw->SetScrollJump(iScrollJump); - } - } - -void CScrollText::ContinueL() - { - DoContinueL(); - } - -void CScrollText::DoContinueL() - { - iTimer->Start(0,10000,TCallBack(CScrollText::DrawText,this)); - - //0.01secs - iDrawer->StartL(); - TRect bounding=iDrawer->DrawingRegion()->BoundingRect(); -#if defined(LOGGING) - _LIT(KBoundRect,"Continue Scroll Text Rect=(%d,%d,%d,%d)"); - LogMessageText.Zero(); - LogMessageText.AppendFormat(KBoundRect,bounding.iTl.iX,bounding.iTl.iY,bounding.iBr.iX,bounding.iBr.iY); - TheClient->iWs.LogMessage(LogMessageText); - TheClient->Flush(); -#endif - TRect window=TRect(iWindow->BaseWin()->AbsPosition(),iWindow->Size()); - if (!window.Contains(bounding.iTl) || !window.Contains(bounding.iBr-TPoint(1,1))) - AutoPanic(EAutoPanicTestFailed); - } - -void CScrollText::Stop() - { - iTimer->Cancel(); - iDrawer->Cancel(); - } - -void CScrollText::ScrollText() - { - iTextDraw->Scroll(); - } - -void CScrollText::AbortNow(RDirectScreenAccess::TTerminationReasons aReason) - { - iTimer->Cancel(); - if (!iCounting) - return; - if (iAbortCountDown>0) - --iAbortCountDown; - else - { - if (aReason==RDirectScreenAccess::ETerminateRegion) - { - User::After(1500000); //1.5secs - iAbortCountDown=7; - } - } - } - -void CScrollText::Restart(RDirectScreenAccess::TTerminationReasons /*aReason*/) -//This function is pure virtual and so cannot have an 'L' at the end of it's name - { - ContinueL(); - } - -/*CWindowWithChild*/ - -CWindowWithChild* CWindowWithChild::NewL(TInt aScreenNumber, CTWindowGroup& aParent,TBool aStart/*=EFalse*/) - { - CWindowWithChild* self=new(ELeave) CWindowWithChild(aScreenNumber); - CleanupStack::PushL(self); - self->ConstructL(aParent); - if (aStart) - self->StartL(); - CleanupStack::Pop(self); - return self; - } - -CWindowWithChild::~CWindowWithChild() - { - delete iDrawer; - delete iChildWindow; - delete iWindow; - TheClient->Flush(); - } - -void CWindowWithChild::ConstructL(CTWindowGroup& aParent) - { - iWindow=new(ELeave) CTBlankWindow(); - iWindow->ConstructL(aParent); - - iChildWindow = new(ELeave) CTWin(); - iChildWindow->ConstructWin(*iWindow); - - iChildWindow->SetExt(TPoint(0,0), TSize(4,4)); - RWindowBase& cwin=*iChildWindow->BaseWin(); - cwin.Activate(); - - RWindowBase& win=*iWindow->BaseWin(); - win.Activate(); - - iDrawer=CDirectScreenAccess::NewL(TheClient->iWs,*TheClient->iScreen,win,*this); - - TheClient->Flush(); - } - -void CWindowWithChild::StartL() - { - DoContinueL(); - } - -void CWindowWithChild::ContinueL() - { - DoContinueL(); - } - -void CWindowWithChild::DoContinueL() - { - iDrawer->StartL(); - iRunning = ETrue; - } - -void CWindowWithChild::Stop() - { - iDrawer->Cancel(); - } - -void CWindowWithChild::AbortNow(RDirectScreenAccess::TTerminationReasons /*aReason*/) - { - iRunning = EFalse; - } - -void CWindowWithChild::Restart(RDirectScreenAccess::TTerminationReasons /*aReason*/) -//This function is pure virtual and so cannot have an 'L' at the end of it's name - { - ContinueL(); - } - -void CWindowWithChild::PerformCoverageCalls() - { - //add coverage to commands with no/partial coverage - RWindow& cwin=*iChildWindow->Win(); - TInt priority = 0; - - cwin.SetPointerCapturePriority(priority); - __ASSERT_ALWAYS(cwin.GetPointerCapturePriority()==priority, User::Invariant()); - cwin.ClaimPointerGrab(EFalse); - cwin.EnableBackup(0); - __ASSERT_ALWAYS(cwin.PrevSibling()==0, User::Invariant()); - cwin.Invalidate(TRect(0, 0, 10, 10)); - cwin.FadeBehind(ETrue); - TheClient->Flush(); - // cover (empty) False condition in CWsWindow::SetFadeBehind - cwin.FadeBehind(ETrue); - TheClient->Flush(); - } - -/*CWsBase*/ - -void CWsBase::ConstructL(TInt aScreenNumber, TInt aHandle) - { - User::LeaveIfError(iWs.Connect()); - iScrDev=new(ELeave) CWsScreenDevice(iWs); - User::LeaveIfError(iScrDev->Construct(aScreenNumber)); - iGroup=RWindowGroup(iWs); - User::LeaveIfError(iGroup.Construct(aHandle,EFalse)); - iGroup.SetOrdinalPosition(0,KMainTestBaseWindow); - } - -void CWsBase::CreateBlankWindowL(RBlankWindow& iWin,TInt aHandle) - { - iWin=RBlankWindow(iWs); - User::LeaveIfError(iWin.Construct(iGroup,aHandle)); - } - -CWsBase::~CWsBase() - { - iGroup.Close(); - delete iScrDev; - iWs.Close(); - } - - -/*CAnimating*/ - -TInt CAnimating::StartLC(TAny* aScreenNumber) - { - CAnimating* self=new(ELeave) CAnimating(); - CleanupStack::PushL(self); - self->ConstructL((TInt)aScreenNumber); - return KErrNone; - } - -void CAnimating::ConstructL(TInt aScreenNumber) - { - CWsBase::ConstructL(aScreenNumber,798); -#if defined(LOGGING) - _LIT(KAnimate1,"Constructed CWsBase"); - LogMessageText.Copy(KAnimate1); - iWs.LogMessage(LogMessageText); - iWs.Flush(); -#endif - iGroup.EnableReceiptOfFocus(EFalse); - CreateBlankWindowL(iWindow,799); - User::LeaveIfError(iWindow.SetRequiredDisplayMode(EGray16)); - iWindow.Activate(); -#if defined(LOGGING) - _LIT(KAnimate2,"Set up Windows"); - LogMessageText.Copy(KAnimate2); - iWs.LogMessage(LogMessageText); -#endif - iWs.Flush(); - TDisplayMode displayMode=CWsBase::iScrDev->DisplayMode(); - if (displayModeCreateContext(iGc)); -#if defined(LOGGING) - _LIT(KAnimate3,"Created Screen Device"); - LogMessageText.Copy(KAnimate3); - iWs.LogMessage(LogMessageText); - iWs.Flush(); -#endif - iDirect=CDirectScreenAccessOld::NewL(iWs,*this); - iTimer=CPeriodic::NewL(0); - User::LeaveIfError(iControlSem.OpenGlobal(SemControl,EOwnerThread)); //Must be thread relative, since it won't get cleaned up when the thread is killed otherwise - User::LeaveIfError(iControlQueue.OpenGlobal(QueueControl,EOwnerThread)); //Must be thread relative, since it won't get cleaned up when the thread is killed otherwise - iSemCreated=ETrue; -#if defined(LOGGING) - _LIT(KAnimate5,"Created Direct, Timer and Semaphore"); - LogMessageText.Copy(KAnimate5); - iWs.LogMessage(LogMessageText); - iWs.Flush(); -#endif - iScrSize=iScrDev->SizeInPixels(); - iGc->SetPenStyle(CGraphicsContext::ENullPen); - iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - StartAnimatingL(); -#if defined(LOGGING) - _LIT(KAnimate6,"Started Animation"); - LogMessageText.Copy(KAnimate6); - iWs.LogMessage(LogMessageText); - iWs.Flush(); -#endif - } - -CAnimating::~CAnimating() - //This function should never actually get run in practice - { - if (iSemCreated) - { - iControlSem.Close(); - iControlQueue.Close(); - } - if (iDrawingRegion) - iDrawingRegion->Destroy(); - delete iTimer; - delete iDirect; - delete iGc; - delete iScrDev; - iWindow.Close(); - } - -void CAnimating::AbortNow(RDirectScreenAccess::TTerminationReasons /*aReason*/) - { - iTimer->Cancel(); - iControlSem.Signal(); - TInt data = 2; - iControlQueue.Send(&data,sizeof(TInt)); - User::After(10000000); //10 secs - } - -TInt NextColor(TAny* aAnimation) - { - STATIC_CAST(CAnimating*,aAnimation)->DrawFrame(); - return(KErrNone); - } - -void CAnimating::DrawFrame() - { - iColor=(iColor+3)%16; - iGc->SetBrushColor(TRgb::Gray16(iColor)); - iGc->DrawRect(iScrSize); - iScrDev->Update(); - if (iColor==2) - { - iControlSem.Signal(); - TInt data = 1; - iControlQueue.Send(&data,sizeof(TInt)); - } - } - -void CAnimating::StartAnimatingL() - { - iTimer->Start(0,150000,TCallBack(NextColor,this)); //0.15 secs - - User::LeaveIfError(iDirect->Request(iDrawingRegion,iWindow)); - iGc->SetClippingRegion(iDrawingRegion); - } - - -/*CMoveWindow*/ - -TInt CMoveWindow::StartLC(TAny* aScreenNumber) - { - CMoveWindow* self=new(ELeave) CMoveWindow(); - CleanupStack::PushL(self); - self->ConstructL((TInt)aScreenNumber); - return KErrNone; - } - -TInt CMoveWindow::FlipChange(TAny* aMoveWin) - { - Cast(aMoveWin)->FlipChange(); - return(KErrNone); - } - -TInt CMoveWindow::StateChange(TAny* aMoveWin) - { - Cast(aMoveWin)->StateChange(); - return(KErrNone); - } - -CMoveWindow::~CMoveWindow() - { - delete iStateTimer; - delete iTimer; - iWindow.Close(); - iBackUpWin.Close(); - delete iGc; - } - -TInt MoveWin(TAny* aMoveWin) - { - STATIC_CAST(CMoveWindow*,aMoveWin)->MoveWindow(); - return(KErrNone); - } - -void CMoveWindow::ConstructL(TInt aScreenNumber) - { - CWsBase::ConstructL(aScreenNumber,898); - iBounceArea=TRect(iScrDev->SizeInPixels()); - iSize.iHeight=iBounceArea.iBr.iY/5; - iSize.iWidth=iBounceArea.iBr.iX/5; - iBounceArea.iTl.iX=iBounceArea.iBr.iX/6; - iBounceArea.iBr.iX=5*iBounceArea.iBr.iX/6; - iBounceArea.iTl.iY=iBounceArea.iBr.iY/4; - iBounceArea.iBr.iY=3*iBounceArea.iBr.iY/4; - iDelta=TSize(3,3); - iTl=iBounceArea.iTl; - CreateBlankWindowL(iWindow,899); - iWindow.SetExtent(iTl,iSize); - iWindow.SetShadowDisabled(ETrue); - iWindow.SetColor(TRgb::Gray4(2)); - iWindow.Activate(); - iBackUpWin=RBackedUpWindow(iWs); - User::LeaveIfError(iBackUpWin.Construct(iGroup,EGray4,698)); - User::LeaveIfError(iBackUpWin.SetSizeErr(TSize(2,2))); - iGc=new(ELeave) CWindowGc(iScrDev); - User::LeaveIfError(iGc->Construct()); - iDisplayMode=EGray4; - if (MoveInterval>TTimeIntervalMicroSeconds32(0)) - CreateTimerL(); - if (ModeInterval>TTimeIntervalMicroSeconds32(0)) - { - iStateTimer=CPeriodic::NewL(0); - iStateTimer->Start(ModeInterval,ModeInterval,TCallBack(CMoveWindow::StateChange,this)); - } - if (FlipInterval>TTimeIntervalMicroSeconds32(0)) - { - iDevice=new(ELeave) CWsScreenDevice(iWs); - User::LeaveIfError(iDevice->Construct(aScreenNumber)); - iNumOfModes=iDevice->NumScreenModes(); - if (iNumOfModes>1) - { - iFlipTimer=CPeriodic::NewL(0); - iFlipTimer->Start(FlipInterval,FlipInterval,TCallBack(CMoveWindow::FlipChange,this)); - } - } - iStateCountDown=0; - } - -void CMoveWindow::CreateTimerL() - { - iTimer=CPeriodic::NewL(0); - iTimer->Start(0,MoveInterval,TCallBack(MoveWin,this)); - - } - -void CMoveWindow::MoveWindow() - { - if (--iStateCountDown>=0) - { - if (iStateCountDown==2) - ToggleDisplayMode(); - return; - } - TPoint iBr=iTl+iSize; - TSize iDeltaSize; - if ((iDelta.iHeight<0 && iTl.iY<=iBounceArea.iTl.iY) || (iDelta.iHeight>0 && iBr.iY>=iBounceArea.iBr.iY)) - { - iDelta.iHeight=-iDelta.iHeight; - iDeltaSize.iWidth=2; - } - if ((iDelta.iWidth<0 && iTl.iX<=iBounceArea.iTl.iX) || (iDelta.iWidth>0 && iBr.iX>=iBounceArea.iBr.iX)) - { - iDelta.iWidth=-iDelta.iWidth; - if (iDeltaSize.iWidth==0) - iDeltaSize.iHeight=2; - else - iDeltaSize.iWidth=0; - } - iTl+=iDelta; - iSize+=iDeltaSize; - iWindow.SetExtent(iTl,iSize); - iWs.Flush(); - } - -void CMoveWindow::StateChange() - { - if (ImmediateModeSwitch>1) - { - if (MoveInterval>TTimeIntervalMicroSeconds32(0) && iTimer==NULL) - { - TRAPD(err,CreateTimerL()); - if (err==KErrNone) - ImmediateModeSwitch=ETrue; - } - } - if (ImmediateModeSwitch || MoveInterval==TTimeIntervalMicroSeconds32(0)) - ToggleDisplayMode(); - else - { - if (iStateCountDown<-8) - iStateCountDown=6; - } - } - -void CMoveWindow::ToggleDisplayMode() - { - if(iDisplayMode==EColor16MU) - { - return; //Test probably doesn't work with mode EColor16MU - } - iDisplayMode=(iDisplayMode==EColor16M ? EGray4:EColor16M); -#if defined(LOGGING) - TInt newMode= -#endif - iWindow.SetRequiredDisplayMode(iDisplayMode); - iGc->Activate(iBackUpWin); - iBackUpWin.SetPosition(iDisplayMode==EColor16M ? TPoint(1,0):TPoint(0,1)); -#if defined(LOGGING) - TDisplayMode curentMode=iScrDev->DisplayMode(); - _LIT(KToggleMode,"Toggle Display Mode Mode=%d Window=%d Actual=%d"); - LogMessageText.Zero(); - LogMessageText.AppendFormat(KToggleMode,(TInt&)iDisplayMode,newMode,(TInt&)curentMode); - iWs.LogMessage(LogMessageText); - //iWs.LogCommand(RWsSession::ELoggingStatusDump); -#endif - iWs.Flush(); - iGc->Deactivate(); - } - -void CMoveWindow::FlipChange() - { - if (++iCurrentMode==2) //flip between modes 0 and 1 - iCurrentMode=0; - iDevice->SetScreenMode(iCurrentMode); - iWs.Flush(); - } - -// -// CBugFixColorAnimation -// -// This class is used for reproducing a defect found on 6.1: KAA-5J3BLW "Unnecessary Wserv's DSA abort". -// The problem was that a direct screen access client was getting an unnecessary abort notification -// when a new window (or window group) was created but not visible. -// This class will simulate the direct screen access client and it will check whether the first DSA abort -// is not caused by just creating a window. - -CBugFixColorAnimation* CBugFixColorAnimation::NewL(TInt aScreenNumber,TInt aId,MAnimCallBacks& aCallBack,CTWindowGroup& aParent,TRect aExtent,TBool aStart) - { - CBugFixColorAnimation* self=new(ELeave) CBugFixColorAnimation(aScreenNumber, aId,aCallBack); - CleanupStack::PushL(self); - self->ConstructL(aParent,aExtent); - if (aStart) - { - self->StartL(); - self->Started(); - } - CleanupStack::Pop(self); - return self; - } - -CBugFixColorAnimation::CBugFixColorAnimation(TInt aScreenNumber,TInt aId,MAnimCallBacks& aCallBack) - : CColorAnimation(aScreenNumber, aId, aCallBack) - { - iThreadParam.iScreenNumber = aScreenNumber; - } - -CBugFixColorAnimation::~CBugFixColorAnimation() - { - iSem.Close(); - if(iThread) - { - TRequestStatus status; - iThread->Logon(status); - if (iThread->StillAlive()) - { - iThread->Terminate(KErrNone); - User::WaitForRequest(status); - } - delete iThread; - } - iTestFailed->Cancel(); - delete iTestFailed; - } - - -LOCAL_D TInt TestFailed(TAny* aAnimation) - { - CBugFixColorAnimation* anim=reinterpret_cast(aAnimation); - TRAP_IGNORE( - anim->Stop(); - anim->CallBack().Fail(); - anim->FinishTest(); - ); - return KErrNone; - } - -LOCAL_D TInt CreateNewWindowGroup(TAny* aParam) - { - TDirectThreadParam* param = (TDirectThreadParam*)aParam; - TRect rect = param->iRect; - TBool isInFront = param->iIsInFront; - RWsSession ws; - TInt error=ws.Connect(); - - CWsScreenDevice* screen = NULL; - TRAP(error, screen = new (ELeave) CWsScreenDevice(ws)); - if (error!=KErrNone) - { - ws.Close(); - RThread::Rendezvous(error); - return error; - } - - if ((error=screen->Construct(param->iScreenNumber))!=KErrNone) - { - delete screen; - ws.Close(); - RThread::Rendezvous(error); - return error; - } - RSemaphore sem; - error = sem.OpenGlobal(KSem_DefectFix_KAA_5J3BLW_Name, EOwnerThread); - if (error!=KErrNone) - { - ws.Close(); - RThread::Rendezvous(error); - return error; - } - - RThread::Rendezvous(KErrNone); - - // wait for the dsa to start before creating the new window group - sem.Wait(); - sem.Close(); - - - RWindowGroup group(ws); - group.Construct(431,EFalse); - if(isInFront) - { - group.SetOrdinalPosition(0,KAboveMainTestBaseWindow); - } - else - { - group.SetOrdinalPosition(2); - } - RWindow window(ws); - error=window.Construct(group, 432); - if (error==KErrNone) - { - window.SetExtentErr(rect.iTl, rect.Size()); - window.SetOrdinalPosition(0,0); - ws.Flush(); - window.Activate(); - ws.Flush(); - if(!isInFront) - { - group.SetOrdinalPosition(-1); - } - ws.Flush(); - //Wait for wserv to render new window on top of the existing DSA region. - ws.Finish(); - //Now the window has been rendered (and DSA should have been aborted). - window.Close(); - } - - group.Close(); - delete screen; - ws.Close(); - return error; - } - -void CBugFixColorAnimation::ConstructL(CTWindowGroup& aParent,TRect aExtent) - { - CColorAnimation::ConstructL(aParent, aExtent,KDrawingDsa); - _LIT(ThreadName,"Create new Window"); - iAnimRect=aExtent; - TInt error=iSem.CreateGlobal(KSem_DefectFix_KAA_5J3BLW_Name, 0); - if (error==KErrNone) - { - iThreadParam.iRect = iAnimRect; - iThreadParam.iIsInFront = EFalse; - TThreadStartUp function=TThreadStartUp(CreateNewWindowGroup, &iThreadParam); - TRequestStatus status; - iThread=CProcess::NewThreadRendezvousL(ThreadName,&function, status); - User::WaitForRequest(status); - if (status != KErrNone) - { - RDebug::Printf("the request status is returned to be non KErrNone: %d", status.Int()); - TestFailed(this); - } - iTestFailed = CIdle::NewL(0); - } - else - { - TestFailed(this); - } - } - -void CBugFixColorAnimation::AbortNow(RDirectScreenAccess::TTerminationReasons /*aReason*/) - { - Stop(); - if (!iTestFailed->IsActive()) - { - iTestFailed->Start(TCallBack(TestFailed,this)); - } - } - -void CBugFixColorAnimation::Restart(RDirectScreenAccess::TTerminationReasons aReason) - { - AbortNow(aReason); - } - -TInt CPanicDirect::DoTestOnNewSchedulerL(TInt aInt, TAny* aPtr) - { - CActiveScheduler* activeScheduler=new(ELeave) CActiveScheduler; - CActiveScheduler::Install(activeScheduler); - CleanupStack::PushL(activeScheduler); - DoTestNowL(aInt,aPtr); - CleanupStack::PopAndDestroy(activeScheduler); - return(EWsExitReasonBad); //calls to this method currently all ignore the return code anyway. - } - -TInt CPanicDirect::DoTestOnNewScheduler(TInt aInt, TAny* aPtr) - { - TInt rv=EWsExitReasonBad; - TRAP_IGNORE(rv=DoTestOnNewSchedulerL(aInt,aPtr)); - return(rv); //calls to this method currently all ignore the return code anyway. - } - -void CPanicDirect::DoTestNowL(TInt aInt, TAny* aPtr) - { - CPanicDirect* self=new(ELeave) CPanicDirect(); - CleanupStack::PushL(self); - self->ConstructL((TInt)aPtr, aInt); - self->TestL(); - CleanupStack::PopAndDestroy(self); - } - -void CPanicDirect::ConstructL(TInt aScreenNumber, TInt aInt) - { - iScreenNumber = aScreenNumber; - - User::LeaveIfError(iTimer.CreateLocal()); - User::LeaveIfError(iWs.Connect()); - iWsScrDev=new(ELeave) CWsScreenDevice(iWs); - User::LeaveIfError(iWsScrDev->Construct(iScreenNumber)); - -#if defined(LOGGING) - _LIT(KPanicThead1,"PanicThread: Into ConstructL"); - LogMessageText.Copy(KPanicThead1); - iWs.LogMessage(LogMessageText); - iWs.Flush(); -#endif - iGroup=RWindowGroup(iWs); - User::LeaveIfError(iGroup.Construct(2200+aInt,EFalse)); - iGroup.SetOrdinalPosition(0,KPanicTestOrdinalPriority); - iBlankWin=RBlankWindow(iWs); - User::LeaveIfError(iBlankWin.Construct(iGroup,2300+aInt)); - iBlankWin.Activate(); - iDirect=RDirectScreenAccess(iWs); - User::LeaveIfError(iDirect.Construct()); - iDisplayMode=iWsScrDev->DisplayMode(); -#if defined(LOGGING) - _LIT(KPanicThead2,"PanicThread: Creating Screen Device, Mode=%d"); - LogMessageText.Format(KPanicThead2,iDisplayMode); - iWs.LogMessage(LogMessageText); - iWs.Flush(); -#endif - iScreenDevice=CFbsScreenDevice::NewL(aScreenNumber,iDisplayMode); -#if defined(LOGGING) - _LIT(KPanicThead3,"PanicThread: Created Device"); - LogMessageText.Copy(KPanicThead3); - iWs.LogMessage(LogMessageText); - iWs.Flush(); -#endif - User::LeaveIfError(iScreenDevice->CreateContext(iGc)); -#if defined(LOGGING) - _LIT(KPanicThead4,"PanicThread: Created Context"); - LogMessageText.Copy(KPanicThead4); - iWs.LogMessage(LogMessageText); - iWs.Flush(); -#endif - iTextDraw=CScrollingTextDrawer::NewL(iScreenNumber,iScreenDevice,*iGc); -#if defined(LOGGING) - _LIT(KPanicThead5,"PanicThread: Created ScrollDrawer"); - LogMessageText.Copy(KPanicThead5); - iWs.LogMessage(LogMessageText); - iWs.Flush(); -#endif - iTextDraw->SetScrollJump(4); -#if defined(LOGGING) - _LIT(KCreatedDrawer,"PanicThread: CreatedDrawer"); - LogMessageText.Copy(KCreatedDrawer); - iWs.LogMessage(LogMessageText); - iWs.Flush(); -#endif - iTestNo=aInt; - } - -CPanicDirect::~CPanicDirect() - { - iDirect.Close(); - delete iGc; - delete iScreenDevice; - delete iTextDraw; - iBlankWin.Close(); - iGroup.Close(); - delete iWsScrDev; - iWs.Close(); - if (iRegion) - iRegion->Close(); - iTimer.Close(); - } - -void CPanicDirect::TestL() - { - if (iTestNo==2) - { - iDirect.Completed(); - return; - } - TInt err=iDirect.Request(iRegion,iDirectStatus,iBlankWin); - if (err!=KErrNone || !iRegion) - return; - TRect screen(iScreenDevice->SizeInPixels()); - TRect bounding=iRegion->BoundingRect(); - if (!screen.Contains(bounding.iTl) || !screen.Contains(bounding.iBr-TPoint(1,1))) - goto Cancel; - iGc->SetClippingRegion(iRegion); - iDrawingAllowed=ETrue; - iTimer.After(iTimerStatus,50000); //0.05secs - FOREVER - { - User::WaitForRequest(iDirectStatus,iTimerStatus); - if (iDirectStatus!=KRequestPending) - iDrawingAllowed=EFalse; - else if (iTimerStatus!=KRequestPending) - { - if (iDrawingAllowed) - DoDrawingL(); - iTimer.After(iTimerStatus,50000); //0.05secs - } - else - { - Cancel: - iDirect.Cancel(); - return; - } - } - } - -void CPanicDirect::DoDrawingL() - { - ++iCount; - iTextDraw->Scroll(); - if (iTestNo==1 && iCount==8) - { - iDirect.Request(iRegion,iDirectStatus,iBlankWin); - return; - } - if (iTestNo==3 && iCount==12) - { - iDirect.Completed(); - iDirect.Completed(); - return; - } - if (iTestNo==4 && iCount==16) - { - iBlankWin.SetSize(TSize(20,25)); - delete iRegion; - User::LeaveIfError(iDirect.Request(iRegion,iDirectStatus,iBlankWin)); - return; - } - if (iTestNo==5 && iCount==19) - { - iWs.Close(); - return; - } - } - - -/*CTDirect*/ - -CTDirect::CTDirect(CTestStep* aStep): - CTWsGraphicsBase(aStep) - { - iState = 0; - iNextFrameFinished = ETrue; - iPackagingFinished = EFalse; - iTimerRunning = EFalse; - } - -CTDirect::~CTDirect() - { - DeleteMoveWindow(); - DeleteScroll(); - - delete iAnim; - TheClient->WaitForRedrawsToFinish(); - delete iCallBackWin; - // put focus back to current screen as this test changed the focus screen to primary screen - TheClient->iWs.SetFocusScreen(iTest->iScreenNumber); - } - -void CTDirect::ConstructL() - { - _LIT(KCTDirectConstructL,"AUTO Construct Direct Test"); - LOG_MESSAGE(KCTDirectConstructL); - FullScreenModeSize=TheClient->iScreen->SizeInPixels(); - iIsScalingSupported=CheckScalingSupportedOrNot(); - iNumOfCallBack=0; - iCallBackWin=new(ELeave) CTBlankWindow; - iCallBackWin->ConstructL(*TheClient->iGroup); - User::LeaveIfError(iCallBackWin->BaseWin()->SetRequiredDisplayMode(EColor256)); - iCallBackWin->SetExt(TPoint(),TheClient->iScreen->SizeInPixels()); - iCallBackWin->SetVisible(EFalse); - iCallBackWin->Activate(); - // the following line makes sure that a console object hidden outside of - // screens range doesn't affect test results being on top of tested objects - TheClient->iGroup->GroupWin()->SetOrdinalPosition(0, KMainTestBaseWindow); - } - -void CTDirect::ConstrucBlankWindowL() - { - delete iWin; - iWin=new(ELeave) CTBlankWindow; - iWin->ConstructL(*TheClient->iGroup); - iWin->BaseWin()->SetShadowDisabled(ETrue); - iWin->BaseWin()->Activate(); - TheClient->Flush(); - } - -void CTDirect::InitialiseAnimationL() - { - ConstrucBlankWindowL(); - TInt colors,greys; - TDisplayMode dispMode=TheClient->iWs.GetDefModeMaxNumColors(colors,greys); - iScrDev=CFbsScreenDevice::NewL(iTest->iScreenNumber,dispMode); - User::LeaveIfError(iScrDev->CreateContext(iGc)); - INFO_PRINTF1(_L(" Constructed Screen Device")); - iScrSize=iScrDev->SizeInPixels(); - TFontSpec fontSpec(FontName,iScrSize.iHeight); - fontSpec.iFontStyle.SetStrokeWeight(EStrokeWeightBold); - User::LeaveIfError(iScrDev->GetNearestFontToDesignHeightInPixels(iFont,fontSpec)); - iGc->UseFont(iFont); - iFlags|=eFontSet; - iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - TInt fontHeight=iFont->HeightInPixels(); - iDrawRect.iTl.iY=(iScrSize.iHeight-fontHeight)/2; - iDrawRect.SetHeight(fontHeight); - iDrawHeight=iFont->AscentInPixels(); - TSize winSize(25,20); - iWin2=new(ELeave) CTBlankWindow; - iWin2->ConstructL(*TheClient->iGroup); - iWin2->SetExt(TPoint((iScrSize.iWidth-winSize.iWidth)/2,(iScrSize.iHeight-winSize.iHeight)/2),winSize); - iWin2->SetColor(TRgb::Gray4(2)); - iWin2->BaseWin()->Activate(); - INFO_PRINTF1(_L(" Setup Window")); - iScrDev->Update(); - TheClient->iWs.Finish(); - - User::LeaveIfError(iControlSem.CreateGlobal(SemControl,0,KOwnerType)); - User::LeaveIfError(iControlQueue.CreateGlobal(QueueControl,1,sizeof(TInt),KOwnerType)); - - iFlags|=eDirectControlSem; - User::LeaveIfError(iWinSem.CreateGlobal(SemNextOp,0,KOwnerType)); - iFlags|=eDirectWindowSem; - iProcess=CProcess::NewTL(CProcess::eProcessDirectTest,iTest->iScreenNumber,&iThreadStatus); - INFO_PRINTF1(_L(" Constructed Semaphores & Thread")); - iControlSem.Wait(); - - iTimer=CPeriodic::NewL(iTest->EAutoTestPriority); - iRestart=CIdle::NewL(iTest->EAutoTestPriority+5); - iDirect=CDirectScreenAccessOld::NewL(TheClient->iWs,*this); - } - -void CTDirect::DestroyAnimation() - { - ResetScreenSizeMode(); - if(iProcess && iProcess->StillAlive()) - { - if (iFlags&eDirectControlSem) - { - iControlSem.Signal(); - TInt data = 3; - iControlQueue.Send(&data,sizeof(TInt)); - } - if (iFlags&eDirectWindowSem) - iWinSem.Signal(); - } - - delete iTimer; - iTimer=NULL; - delete iRestart; - iRestart=NULL; - delete iDirect; - iDirect=NULL; - delete iChangeScreenModeTimer; - iChangeScreenModeTimer=NULL; - delete iScreenModeTimer; - iScreenModeTimer=NULL; - - if (iFlags&eFontSet) - { - iGc->DiscardFont(); - iScrDev->ReleaseFont(iFont); - } - delete iGc; - if (iDrawingRegion) - iDrawingRegion->Destroy(); - delete iScrDev; - delete iWin; - delete iWin2; - if (iProcess) - { - User::WaitForRequest(iThreadStatus); - delete iProcess; - iProcess = NULL; - } - if (iFlags&eDirectControlSem) - { - iControlSem.Close(); - iControlQueue.Close(); - } - if (iFlags&eDirectWindowSem) - iWinSem.Close(); - } - -void CTDirect::ResetScreenSizeMode() - { - if (iModeBackup!=ESizeEnforcementNone) - { - TheClient->iScreen->SetScreenModeEnforcement(ESizeEnforcementNone); - iModeBackup=ESizeEnforcementNone; - } - TheClient->iScreen->SetCurrentRotations(0,CFbsBitGc::EGraphicsOrientationNormal); - TheClient->iScreen->SetScreenMode(0); - TPixelsAndRotation pixelsAndRotation; - TheClient->iScreen->GetDefaultScreenSizeAndRotation(pixelsAndRotation); - TheClient->iScreen->SetScreenSizeAndRotation(pixelsAndRotation); - User::After(350000); //0.35secs - } - -void CTDirect::ScanTypeFacesL() - { - CFbsScreenDevice* scrdev=CFbsScreenDevice::NewL(iTest->iScreenNumber,EGray4); - TTypefaceSupport typeFace; - TInt numFaces=scrdev->NumTypefaces(); - TInt ii; - for (ii=0;iiTypefaceSupport(typeFace,ii); - } - delete scrdev; - } - -TInt RestartAnimation(TAny* aTest) - { - STATIC_CAST(CTDirect*,aTest)->Restart(); - return(KErrNone); - } - -TInt NextFrame(TAny* aTest) - { - STATIC_CAST(CTDirect*,aTest)->DrawFrame(); - return(KErrNone); - } - -void CTDirect::AbortNow(RDirectScreenAccess::TTerminationReasons aReason) - { - TEST(aReason==RDirectScreenAccess::ETerminateRegion); - - if (iDelay) - User::After(2000000); //2 secs - if (iCancelNext) - { - iFrameNo=eDirectNumFrames; - iTimer->Cancel(); - iDirect->Cancel(); - TheClient->Flush(); - iNextFrameFinished = ETrue; - iState++; - return; - } - iRestart->Start(TCallBack(RestartAnimation,this)); - } - -TBool CTDirect::Restart() - { - StartDirect(); - return ETrue; - } - -#pragma warning( disable : 4244 ) //conversion from 'int' to 'unsigned short', possible loss of data -TBool CTDirect::DrawFrame() - { - if (iFrameNo==eDirectNumFrames) - { - iState++; - iTimer->Cancel(); - if (iFrameNo==eDirectNumFrames) - iDirect->Cancel(); - iNextFrameFinished = ETrue; - return EFalse; - } - _LIT(Text,"A0"); - TBuf<2> iString(Text); //_LIT(Text,"ABCabc123"); - iString[0]+=iFrameNo; - iString[1]+=iFrameNo; - TInt textWidth=iFont->TextWidthInPixels(iString); - TInt maxTextWidth=Max(textWidth,iLastTextWidth); - iLastTextWidth=textWidth; - if (iLastMaxTextWidth!=maxTextWidth) - { - iLastMaxTextWidth=maxTextWidth; - iDrawRect.iTl.iX=(iScrSize.iWidth-iLastMaxTextWidth)/2; - iDrawRect.SetWidth(iLastMaxTextWidth); - } - TInt colorOffset=iFrameNo%2; - iGc->SetPenColor(TRgb::Gray4(colorOffset)); - iGc->DrawText(iString,iDrawRect,iDrawHeight,CGraphicsContext::ECenter); - iGc->SetPenColor(TRgb::Gray4(1+colorOffset)); - iGc->DrawLine(TPoint(),iScrSize.AsPoint()); - iGc->DrawLine(TPoint(iScrSize.iWidth,0),TPoint(0,iScrSize.iHeight)); - iGc->DrawLine(TPoint(iScrSize.iWidth/2,0),TPoint(iScrSize.iWidth/2,iScrSize.iHeight)); - iGc->DrawLine(TPoint(0,iScrSize.iHeight/2),TPoint(iScrSize.iWidth,iScrSize.iHeight/2)); - iScrDev->Update(); - ++iFrameNo; - if (iFrameNo==iFrameToSignalAfter) - SignalWindow(); - return ETrue; - } -#pragma warning( default : 4244 ) - -void CTDirect::SignalWindow() - { - switch(iState) - { - case 0: - switch(iFrameNo) - { - case 0: - iFrameToSignalAfter=0; - } - return; - case 1: - case 3: - switch(iFrameNo) - { - case 0: - iFrameToSignalAfter=3; - iDelay=(iState==3); - return; - case 3: - WinExt.SetSize(TSize(iScrSize.iWidth/2-5,iScrSize.iHeight/2+30)); - iFrameToSignalAfter=5; - break; - case 5: - iFrameToSignalAfter=7; - break; - case 7: - WinExt.SetSize(TSize(iScrSize.iWidth/2+30,iScrSize.iHeight/2-5)); - WinCol=1; - iFrameToSignalAfter=8; - break; - case 8: - iFrameToSignalAfter=0; - iDelay=EFalse; - break; - } - break; - case 2: - switch(iFrameNo) - { - case 0: - iFrameToSignalAfter=2; - return; - case 2: - WinExt.SetRect(TPoint(iScrSize.iWidth/2-15,iScrSize.iHeight/2-20),TSize(iScrSize.iWidth/3,iScrSize.iHeight/3)); - WinCol=2; - iFrameToSignalAfter=5; - break; - case 5: - iFrameToSignalAfter=6; - break; - case 6: - WinExt.SetRect(TPoint(iScrSize.iWidth/2-50,iScrSize.iHeight/3),TSize(iScrSize.iWidth/4,iScrSize.iHeight/3)); - WinCol=3; - iFrameToSignalAfter=8; - break; - case 8: - iFrameToSignalAfter=0; - break; - } - break; - case 4: - switch(iFrameNo) - { - case 0: - iFrameToSignalAfter=3; - return; - case 3: - iFrameToSignalAfter=6; - iWin2->SetVisible(EFalse); - TheClient->Flush(); - return; - case 6: - iFrameToSignalAfter=0; - iWin2->SetVisible(ETrue); - TheClient->Flush(); - return; - } - break; - case 5: - switch(iFrameNo) - { - case 0: - iFrameToSignalAfter=6; - return; - case 6: - iFrameToSignalAfter=0; - WinExt.SetRect(10,10,20,20); - iCancelNext=ETrue; - break; - } - break; - case 6: - switch(iFrameNo) - { - case 0: - iFrameToSignalAfter=7; - iCancelNext=EFalse; - return; - case 7: - iFrameToSignalAfter=0; - delete iWin; - TheClient->Flush(); - iWin=NULL; - iWindowDead=ETrue; - return; - } - break; - } -#if defined(LOGGING) - _LIT(KSignal,"Signaling Move Window"); - LogMessageText.Copy(KSignal); - TheClient->iWs.LogMessage(LogMessageText); - TheClient->Flush(); -#endif - iWinSem.Signal(); - } - -void CTDirect::StartDirect() - { - if (iWin==NULL) - { - TEST(iWindowDead); - if (!iWindowDead) - INFO_PRINTF3(_L("iWindowDead - Expected: %d, Actual: %d"), ETrue, iWindowDead); - - iFrameNo=eDirectNumFrames; - return; - } - TEST(!iWindowDead); - if (iWindowDead) - INFO_PRINTF3(_L("iWindowDead - Expected: %d, Actual: %d"), EFalse, iWindowDead); - - if (iDrawingRegion) - iDrawingRegion->Destroy(); - TInt retVal = iDirect->Request(iDrawingRegion,*iWin->BaseWin()); - TEST(retVal==KErrNone); - if (retVal!=KErrNone) - INFO_PRINTF3(_L("iDirect->Request(iDrawingRegion,*iWin->BaseWin()) return value - Expected: %d, Actual: %d"), KErrNone, retVal); - - iGc->SetClippingRegion(iDrawingRegion); - } - -void CTDirect::LogLeave(TInt aErr) - { - iTest->LogLeave(aErr); - } - -void CTDirect::Fail() - { - TEST(EFalse); - } - -void CTDirect::Finished(TInt aId) - { - //aId refers to the animation, it is not the test number - _LIT(KCTDirectFinished,"Destroying animation number %d"); - LOG_MESSAGE2(KCTDirectFinished,aId); - switch (aId) - { - case 10: - case 11: - ResetScreenSizeMode(); - case 9: - iPackagingFinished = ETrue; - case 8: - DeleteMoveWindow(); - //iPackagingFinished = ETrue; - if (iScroll) - { - DeleteScroll(); - #if defined(LOGGING) - _LIT(KDeleteScroll,"Deleting Scroll Text Id=%d TimerActive=%d"); - LogMessageText.Zero(); - LogMessageText.AppendFormat(KDeleteScroll,aId,iAnim->IsTimerActive()); - TheClient->iWs.LogMessage(LogMessageText); - TheClient->Flush(); - #endif - } - if (aId==8 && iAnim->IsTimerActive()) - return; - case 1: - case 12: - case 25: //case DSA using Region tracking Only (abort signal expceted) - case 26: //case DSA using Region tracking Only (abort signal not expceted) - { - iPackagingFinished = ETrue; - delete iAnim; - iAnim=NULL; -CHECKHANDLES: - TInt numProcessHandles; - TInt numThreadHandles; - RThread().HandleCount(numProcessHandles,numThreadHandles); - TEST(Abs(numThreadHandles-iNumThreadHandles)<2); - if (Abs(numThreadHandles-iNumThreadHandles)>=2) - INFO_PRINTF3(_L("Abs(numThreadHandles-iNumThreadHandles)<2 - Expected: %d or less, Actual: %d"), 2, Abs(numThreadHandles-iNumThreadHandles)); - } - break; - case 16: - case 15: - { - // Stop the animation and delete it, but make sure that you don't increment iState and call Rquest() - // until this is the second call i.e. one of aId = 15 or aId = 16 has already been finished. - TInt index = aId-15; - iAnims[index]->Stop(); - delete iAnims[index]; - iAnims[index]=NULL; - // This test creates two animations iAnims[0] and iAnims[1]. - // Use (index ^ 1 ) = Toggle the Index, to get the index of other animation. - // If iAnims [ index ^ 1] is NULL then this is the second Call and test is finished. - if (iAnims[index ^ 1] != NULL) - { - return; - } - iPackagingFinished = ETrue; - goto CHECKHANDLES; - } - case 13: - { - iPackagingFinished = ETrue; - delete iBlankTopClientWin1; - // delete iBlankTopClientWin2; - TInt jj; - for (jj=0;jj<4;++jj) - iAnims[jj]->Stop(); - for (jj=0;jj<4;++jj) - delete iAnims[jj]; - break; - } - case 14: - { - iPackagingFinished = ETrue; - iAnims[0]->Stop(); - delete iAnims[0]; - if (iNumOfModes==iCurrentMode) - { - ResetScreenSizeMode(); - iCallBackWin->SetVisible(EFalse); - break; - } - break; - } - case 18: - case 17: - { - // Stop the animation and delete it, but make sure that you don't increment iState and call Rquest() - // until this is the second call i.e. one of aId = 17 or aId = 18 has already been finished. - TInt ii = 0; - TBool finished = ETrue; - if (aId == 17) - { - iAnims[0]->Stop(); - delete iAnims[0]; - iAnims[0] = NULL; - for (ii=1;ii<=iNumAnimation;++ii) - { - if (iAnims[ii]) - { - finished = EFalse; - break; - } - } - } - else // aId == 18 - { - for (ii=1;ii<=iNumAnimation;++ii) - { - iAnims[ii]->Stop(); - delete iAnims[ii]; - iAnims[ii] = NULL; - } - if (iAnims[0]) - { - finished = EFalse; - } - } - if (!finished) - { - return; - } - iPackagingFinished = ETrue; - break; - } - case 19: - { - iPackagingFinished = ETrue; - iAnims[0]->Stop(); - delete iAnims[0]; - break; - } - case 21: - case 20: - { - // Stop the animation and delete it, but make sure that you don't increment iState and call Rquest() - // until this is the second call i.e. one of aId = 20 or aId = 21 has already been finished. - TInt index = aId-20; - iAnims[index]->Stop(); - delete iAnims[index]; - iAnims[index]=NULL; - // This test creates two animations iAnims[0] and iAnims[1]. - // Use (index ^ 1 ) = Toggle the Index, to get the index of other animation. - // If iAnims [ index ^ 1] is NULL then this is the second Call and test is finished. - if (iAnims[index ^ 1] != NULL) - { - return; - } - DeleteMoveWindow(); - iPackagingFinished = ETrue; - goto CHECKHANDLES; - } //unreachable line, no need for break - case 24: - iPackagingFinished = ETrue; - iAnim->Stop(); - delete iAnim; - iAnim=NULL; - //don't want to increase state, so decrement, since it is incremented below - //as part of processing normal completions. This is to reenter the test - //to call Fail() if required - iState--; - break; - - case 27: - case 28: - case 29: - case 30: - case 31: - case 32: - iAnims[aId-27]->Stop(); - delete iAnims[aId-27]; - iAnims[aId-27] = NULL; - if(aId != 32) - { - return; - } - DeleteMoveWindow(); - iPackagingFinished = ETrue; - break; - default: - iPackagingFinished = ETrue; - TInt ii; - for (ii=0;ii<6;++ii) - iAnims[ii]->Stop(); - for (ii=0;ii<6;++ii) - delete iAnims[ii]; - DeleteMoveWindow(); - break; - } -#if defined(LOGGING) - _LIT(KRequest,"Signal Start NextTest Id=%d, State=%d(+1)"); - LogMessageText.Zero(); - LogMessageText.AppendFormat(KRequest,aId,iState); - TheClient->iWs.LogMessage(LogMessageText); - TheClient->Flush(); -#endif - iState++; - } - -void CTDirect::DeleteMoveWindow() - { - if (iMoveWin) - { - TRequestStatus status; - iMoveWin->Logon(status); - if (iMoveWin->StillAlive()) - { - iMoveWin->Terminate(KErrNone); - User::WaitForRequest(status); - } - delete iMoveWin; - iMoveWin=NULL; - } - } - -void CTDirect::DeleteScroll() - { - if (iScroll) - { - TheClient->iScreen->SetScreenMode(0); - iScroll->Stop(); - delete iScroll; - iScroll=NULL; - } - } - -TDisplayMode CTDirect::DisplayMode(TInt aId) - { - switch (aId) - { - case 1: - case 13: - case 15: - case 16: - return EColor16; - case 2: - return EGray16; - case 3: - return EColor16; - case 4: - case 14: - case 17: - case 18: - case 19: - case 24: - return EColor256; - case 5: - return EGray256; - case 6: - return EColor4K; - case 7: - return EColor64K; - case 8: - case 9: - case 10: - case 11: - case 12: - { - TInt colors,grays; - /*TDisplayMode mode=*/TheClient->iWs.GetDefModeMaxNumColors(colors,grays); - if (colors==0) - return EGray4; - return (aId==8? EGray16:EColor16); - } - default:; - return TheClient->iScreen->DisplayMode(); - } - } - -void CTDirect::Log(const TText8* aFile, TInt aLine, TInt aSeverity,const TDesC& aString) - { - Logger().LogExtra(((TText8*)aFile), aLine, aSeverity, aString) ; - } - -TRgb CTDirect::BrushColorL(TInt aId,TInt& aColor,TBool& aFinished) - { - aFinished=EFalse; - switch (aId) - { - case 1: - case 13: - case 14: - case 15: - case 16: - case 17: - case 18: - case 19: - case 20: - case 21: - case 27: - aFinished=(aColor==20); - return TRgb::Color16(27 + aColor++); - case 28: - aFinished=(aColor==17); - return TRgb::Color16(28 + aColor++); - case 29: - aFinished=(aColor==15); - return TRgb::Color16(29 + aColor++); - case 8: - if (aColor==15) - { - ++iCycles; - aFinished=(iCycles==5); - } - else if (!iScroll) - aFinished=ETrue; - else if (!iScroll->IsRunning()) - iScroll->ContinueL(); - { - #if defined(LOGGING) - if (aFinished || iScroll==NULL) - { - _LIT(KColor,"Col=%d Cycles=%d Fin=%d iScroll=%d"); - LogMessageText.Zero(); - LogMessageText.AppendFormat(KColor,aColor,iCycles,aFinished,(TInt&)iScroll); - TheClient->iWs.LogMessage(LogMessageText); - TheClient->Flush(); - } - #endif - } - case 2: - if (aColor==16) - aColor=0; - return TRgb::Gray16(aColor++); - case 9: - case 10: - aFinished=iCycles>3; - case 11: - case 3: - if (aColor==16) - { - ++iCycles; - aColor=0; - } - return TRgb::Color16(aColor++); - case 4: - aFinished=(aColor==256); - return TRgb::Color256(aColor++); - case 5: - if (aColor==256) - aColor=0; - return TRgb::Gray256(aColor++); - case 6: - aColor+=127; - if (aColor>4095) - aColor-=4096; - return TRgb::Color4K(aColor); - case 7: - aColor+=211; - if (aColor>65535) - aColor-=65536; - return TRgb::Color64K(aColor++); - case 12: - aFinished=2*(aColor>5); - return TRgb::Color16(aColor++); - case 24: - iCycles++; - if (iCycles==5) - { - aFinished=ETrue; - CheckForTemporaryDeadlock(); - } - return TRgb::Color16(aColor++); - case 30: - aFinished=(aColor==256); - return TRgb::Color16(aColor++); - case 31: - aFinished=(aColor==100); - return TRgb::Color16(aColor++); - case 32: - aFinished=(aColor==300); - return TRgb::Color16(aColor++); - default:; - aFinished=ETrue; - return TRgb::Gray2(1); //White - } - } - -TInt CTDirect::TimerInterval(TInt aId) - { - switch (aId) - { - case 1: - case 15: - case 16: - case 17: - case 18: - case 20: - case 21: - return 143200; - case 27: - return 200000; - case 28: - return 180000; - case 29: - return 170000; - case 30: - return 200000; - case 31: - return 205000; - case 32: - return 300000; - case 2: - case 25: - case 26: - return 234567; - case 3: - return 200000; - case 4: - return 11718; - case 5: - return 13719; - case 6: - return 14719; - case 7: - return 15719; - case 8: - return 275000; - case 9: - return 210000; - case 10: - return 110000; - case 11: - return 123456; - case 12: - return 10627; - case 19: - return 1000000; - default:; - return 1; - } - } - -void CTDirect::FailedReStart(TInt /*aId*/,TInt /*aReason*/) - { - Fail(); - } - -TInt CTDirect::SlowStopping(TInt aId,TInt aCount) - { - if (aId==8) - return (aCount>1 ? CColorAnimation::eAbortAll : CColorAnimation::eStopNow); - if (aId==9 || aId==10) - return CColorAnimation::eStopNow; - TInt ret=(2*aId-3==aCount%12); - if (ret && aId==5) - { - ++iCount; - if (iCount==5) - return CColorAnimation::eAbort; - } - return ret; - } - -void CTDirect::ModeSwitch() - { - TRAPD(err,iAnim->ChangeModeL(EGray4)); - iWin2->SetSize(TSize(20,25)); - TheClient->Flush(); - if (err!=KErrNone) - Fail(); - } - -TestState CTDirect::AnimateWindowL() - { -// if (!iTimer->IsActive()) - { - - - iFrameNo=0; - SignalWindow(); - - - iTimer->Start(0,200000,TCallBack(NextFrame,this)); //0.2 secs - - StartDirect(); - TEST(iDrawingRegion->BoundingRect()==iScrSize); - } -// else -// { -// int i=0; -// } - return EWait; - } - -TestState CTDirect::AnimationDiesL() - { - INFO_PRINTF1(_L("AUTO Animation Dies ")); - _LIT(ThreadName,"AnimationDie"); - iFirstFunction=TThreadStartUp(CAnimating::StartLC,(TAny*)iTest->iScreenNumber); - CProcess* thread=CProcess::NewThreadL(ThreadName,&iFirstFunction); - CleanupStack::PushL(thread); - thread->LeaveIfDied(); - INFO_PRINTF1(_L(" Constructed Thread")); - iControlSem.Wait(); - RWindowGroup group(TheClient->iWs); - group.Construct(431,EFalse); - RBlankWindow win(TheClient->iWs); - win.Construct(group,432); - win.SetExtent(TPoint(12,34),TSize(56,78)); - win.Activate(); - INFO_PRINTF1(_L(" Constructed Windows")); - iControlSem.Wait(); - User::After(1000000); //1 sec - TRequestStatus threadDied; - thread->Logon(threadDied); - thread->Terminate(KErrGeneral); - INFO_PRINTF1(_L(" Waiting for Thread")); - User::WaitForRequest(threadDied); - CleanupStack::PopAndDestroy(thread); - win.Close(); - group.Close(); - INFO_PRINTF1(_L(" Finished")); - return ENext; - } - -TestState CTDirect::PackagingClassL() - { - ConstrucBlankWindowL(); - TInt numProcessHandles; - RThread().HandleCount(numProcessHandles,iNumThreadHandles); - iAnim=CColorAnimation::NewL(iTest->iScreenNumber,1,*this,*TheClient->iGroup,TRect(10,10,630,230),ETrue); - return EWait; - } - -TestState CTDirect::MultipleL() - { - TSize scrSize=TheClient->iScreen->SizeInPixels(); - - iFlags|=eMultiAnim; - iAnims[0]=CColorAnimation::NewL(iTest->iScreenNumber,2,*this,*TheClient->iGroup, - TRect(0,10,scrSize.iWidth/3+20,scrSize.iHeight/2-5),EFalse); - iAnims[1]=CColorAnimation::NewL(iTest->iScreenNumber,3,*this,*TheClient->iGroup, - TRect(10,scrSize.iHeight/2-20,scrSize.iWidth/3-5,scrSize.iHeight),EFalse); - iAnims[3]=CColorAnimation::NewL(iTest->iScreenNumber,5,*this,*TheClient->iGroup, - TRect(scrSize.iWidth/3-20,scrSize.iHeight/2+5,2*scrSize.iWidth/3+20,scrSize.iHeight-10),EFalse); - iAnims[2]=CColorAnimation::NewL(iTest->iScreenNumber,4,*this,*TheClient->iGroup, - TRect(scrSize.iWidth/3+5,0,2*scrSize.iWidth/3-5,scrSize.iHeight/2+20),EFalse); - iAnims[4]=CColorAnimation::NewL(iTest->iScreenNumber,6,*this,*TheClient->iGroup, - TRect(2*scrSize.iWidth/3-20,15,scrSize.iWidth,scrSize.iHeight/2+50),EFalse); - iAnims[5]=CColorAnimation::NewL(iTest->iScreenNumber,7,*this,*TheClient->iGroup, - TRect(2*scrSize.iWidth/3+5,-20,scrSize.iWidth-15,scrSize.iHeight+10),ETrue); - TInt ii; - for (ii=0;ii<5;++ii) - iAnims[ii]->StartL(); - _LIT(ThreadName,"MoveWin"); - - MoveInterval=100000; //0.1 secs - ModeInterval=1200000; //1.2 sec - ImmediateModeSwitch=EFalse; - iFirstFunction=TThreadStartUp(CMoveWindow::StartLC,(TAny*)iTest->iScreenNumber); - iMoveWin=CProcess::NewThreadL(ThreadName,&iFirstFunction); - return EWait; - } - -TestState CTDirect::MixDsaAndRegionTrackingOnlyL(TBool aWhoExitsLast) - { - TSize scrSize=TheClient->iScreen->SizeInPixels(); - - iFlags|=eMultiAnim; - TUint firstRegionTrackinOnlyDsa = (aWhoExitsLast == KRegionTrackingOnlyDsaExistLast ? 0 : 3); - TUint firstDrawingDsa = (aWhoExitsLast == KDrawingDsaExistLast ? 0 : 3); - - //DSAs who use region tracking only - iAnims[firstRegionTrackinOnlyDsa]=CColorAnimation::NewL(iTest->iScreenNumber,firstRegionTrackinOnlyDsa+27,*this,*TheClient->iGroup, - TRect(10,scrSize.iHeight/2-20,scrSize.iWidth/3-5,scrSize.iHeight),EFalse,KRegionTrackingOnly); - iAnims[firstRegionTrackinOnlyDsa+1]=CColorAnimation::NewL(iTest->iScreenNumber,firstRegionTrackinOnlyDsa+28,*this,*TheClient->iGroup, - TRect(2*scrSize.iWidth/3-20,15,scrSize.iWidth,scrSize.iHeight/2+50),EFalse,KRegionTrackingOnly); - iAnims[firstRegionTrackinOnlyDsa+2]=CColorAnimation::NewL(iTest->iScreenNumber,firstRegionTrackinOnlyDsa+29,*this,*TheClient->iGroup, - TRect(2*scrSize.iWidth/3+5,-20,scrSize.iWidth-15,scrSize.iHeight+10),EFalse,KRegionTrackingOnly); - - //DSAs who actually draw - iAnims[firstDrawingDsa]=CColorAnimation::NewL(iTest->iScreenNumber,firstDrawingDsa+27,*this,*TheClient->iGroup, - TRect(0,10,scrSize.iWidth/3+20,scrSize.iHeight/2-5),EFalse,KDrawingDsa); - iAnims[firstDrawingDsa+1]=CColorAnimation::NewL(iTest->iScreenNumber,firstDrawingDsa+28,*this,*TheClient->iGroup, - TRect(scrSize.iWidth/3+5,0,2*scrSize.iWidth/3-5,scrSize.iHeight/2+20),EFalse,KDrawingDsa); - iAnims[firstDrawingDsa+2]=CColorAnimation::NewL(iTest->iScreenNumber,firstDrawingDsa+29,*this,*TheClient->iGroup, - TRect(scrSize.iWidth/3-20,scrSize.iHeight/2+5,2*scrSize.iWidth/3+20,scrSize.iHeight-10),EFalse,KDrawingDsa); - - TInt ii; - for (ii=0;ii<6;++ii) - { - if(iAnims[ii]) - iAnims[ii]->StartL(); - } - - _LIT(ThreadName,"MoveWin"); - - MoveInterval=100000; //0.1 secs - ModeInterval=1200000; //1.2 secs - ImmediateModeSwitch=EFalse; - iFirstFunction=TThreadStartUp(CMoveWindow::StartLC,(TAny*)iTest->iScreenNumber); - iMoveWin=CProcess::NewThreadL(ThreadName,&iFirstFunction); - return EWait; - } - -TestState CTDirect::TryDifferentSupportedModesL() - { - - RWsSession session; - User::LeaveIfError(session.Connect()); - CWsScreenDevice* device = new(ELeave) CWsScreenDevice(session); - CleanupStack::PushL(device); - User::LeaveIfError(device->Construct(iTest->iScreenNumber)); - TUint numOfModes=device->NumScreenModes(); - _LIT(KTryingCurrentMode,"Trying Mode = %d"); - for(TUint currentMode =0; currentMode < numOfModes; currentMode++) - { - LOG_MESSAGE2(KTryingCurrentMode,currentMode); - device->SetScreenMode(currentMode); - TRAPD(err,iAnims[0]=CColorAnimation::NewL(iTest->iScreenNumber,4,*this,*TheClient->iGroup, - TRect(0,0,50,50),ETrue)); - if(err!=KErrNone) - { - TEST(EFalse); - } - else - { - User::After(2000000); - iAnims[0]->Stop(); - delete iAnims[0]; - } - } - CleanupStack::PopAndDestroy(device); - session.Close(); - iState++; - return EWait; - } - - -TestState CTDirect::FailCodesL() - { - __UHEAP_MARK; - TRequestStatus status; - RRegion region(TRect(0,0,10,10),1); - RRegion* pRegion=®ion; - RDirectScreenAccess direct(TheClient->iWs); - User::LeaveIfError(direct.Construct()); - RBlankWindow window(TheClient->iWs); - User::LeaveIfError(window.Construct(*TheClient->iGroup->WinTreeNode(),1234)); - TInt err=direct.Request(pRegion,status,window); - TEST(err==KErrNone); - if (err!=KErrNone) - INFO_PRINTF3(_L("direct.Request(pRegion,status,window) return value - Expected: %d, Actual: %d"), KErrNone, err); - TEST(pRegion!=NULL); - if (pRegion==NULL) - INFO_PRINTF3(_L("pRegion!=NULL - Expected: %d, Actual: %d"), 0, 0); - pRegion->Destroy(); - direct.Cancel(); - User::WaitForRequest(status); - window.Activate(); - window.SetOrdinalPosition(-2); - pRegion=®ion; - err=direct.Request(pRegion,status,window); - TEST(err==KErrNone); - if (err!=KErrNone) - INFO_PRINTF3(_L("direct.Request(pRegion,status,window) return value - Expected: %d, Actual: %d"), KErrNone, err); - TEST(pRegion!=NULL); - if (pRegion==NULL) - INFO_PRINTF3(_L("pRegion!=NULL - Expected: %d, Actual: %d"), 0, 0); - pRegion->Destroy(); - direct.Cancel(); - User::WaitForRequest(status); -#if defined(__WINS__) - // Loop over the allocations done. - // There is one allocating of the rectangle list and - // one of the region holding the list - for (TInt rate = 1; rate <= 2; rate++) - { - window.SetOrdinalPosition(0); - pRegion=®ion; - TheClient->Flush(); - __UHEAP_FAILNEXT(rate); - err=direct.Request(pRegion,status,window); - TEST(err==KErrNoMemory); - if (err!=KErrNoMemory) - INFO_PRINTF3(_L("direct.Request(pRegion,status,window) return value - Expected: %d, Actual: %d"), KErrNoMemory, err); - - TEST(pRegion==NULL); - if (pRegion!=NULL) - INFO_PRINTF3(_L("pRegion!=NULL - Expected: %d, Actual: %d"), 0, 0); - } -#endif - window.Close(); - direct.Close(); - region.Close(); - __UHEAP_MARKEND; - return ENext; - } - -void CTDirect::ScrolingTextL(TInt aId,TRect aWinRect,TBool aStartThread,TInt aScreenMode/*=0*/) - { - INFO_PRINTF1(_L("AUTO Construct ScrolingText ")); - INFO_PRINTF1(_L(" Constructed Window")); - iCycles=0; - TInt numProcessHandles; - RThread().HandleCount(numProcessHandles,iNumThreadHandles); - iAnim=CColorAnimation::NewL(iTest->iScreenNumber,aId,*this,*TheClient->iGroup,aWinRect,EFalse); - iScroll=CScrollText::NewL(iTest->iScreenNumber,1,*TheClient->iGroup,5,EFalse); - INFO_PRINTF1(_L(" Constructed Text Scroller & Animation")); - iAnim->BringWindowToFront(); - if (aStartThread) - { - _LIT(ThreadName,"MoveWin"); - INFO_PRINTF1(_L(" About to constructed Thread")); - iFirstFunction=TThreadStartUp(CMoveWindow::StartLC,(TAny*)iTest->iScreenNumber); - __ASSERT_DEBUG(!iMoveWin,AutoPanic(EAutoPanicDirect)); - iMoveWin=CProcess::NewThreadL(ThreadName,&iFirstFunction); - INFO_PRINTF1(_L(" Constructed Thread")); - } - if (aScreenMode>0) - { - TInt numScreenModes = TheClient->iScreen->NumScreenModes(); - if (aScreenMode < numScreenModes) - TheClient->iScreen->SetScreenMode(aScreenMode); - else - LOG_MESSAGE(_L("WARNING: Failed to change screen mode")); - // We have to run the test anyway to avoid things going wrong later - } - iAnim->StartOrPanic(); - iScroll->StartL(); - INFO_PRINTF1(_L(" Constructed/Started")); -#if defined(LOGGING) - _LIT(KStarted,"Finished StartUp ScrollText"); - LogMessageText.Copy(KStarted); - TheClient->iWs.LogMessage(LogMessageText); - TheClient->Flush(); -#endif - } - -TestState CTDirect::ScrolingText1L() - { - MoveInterval=0; - ModeInterval=1200000; //1.2 sec - ScrolingTextL(8,TRect(20,20,40,40),ETrue); - return EWait; - } - -TestState CTDirect::RClassL() - { -#if defined(LOGGING) - _LIT(KRClass,"Starting Panic test on RClass"); - LogMessageText.Zero(); - LogMessageText.AppendFormat(KRClass); - TheClient->iWs.LogMessage(LogMessageText); - TheClient->Flush(); -#endif - TEST(iTest->TestWsPanicL(CPanicDirect::DoTestOnNewScheduler,EWservPanicDirectMisuse,1,(TAny*)iTest->iScreenNumber)); -#if defined(LOGGING) - _LIT(KPanic1,"Done First Panic"); - LogMessageText.Zero(); - LogMessageText.AppendFormat(KPanic1); - TheClient->iWs.LogMessage(LogMessageText); - TheClient->Flush(); -#endif -#if defined(__WINS__) -#if defined(LOGGING) - _LIT(KPanic2,"Doing 2 debug panics"); - LogMessageText.Zero(); - LogMessageText.AppendFormat(KPanic2); - TheClient->iWs.LogMessage(LogMessageText); - TheClient->Flush(); -#endif - TEST(iTest->TestW32PanicL(CPanicDirect::DoTestOnNewScheduler,EW32PanicDirectMisuse,2,(TAny*)iTest->iScreenNumber)); - TEST(iTest->TestW32PanicL(CPanicDirect::DoTestOnNewScheduler,EW32PanicDirectMisuse,3,(TAny*)iTest->iScreenNumber)); -#endif -#if defined(LOGGING) - _LIT(KPanicTest,"Trying Panic %d"); - LogMessageText.Zero(); - LogMessageText.AppendFormat(KPanicTest,4); - TheClient->iWs.LogMessage(LogMessageText); - TheClient->Flush(); -#endif - TEST(iTest->TestWsPanicL(CPanicDirect::DoTestOnNewScheduler,EWservPanicDirectMisuse,4,(TAny*)iTest->iScreenNumber)); - TEST(iTest->TestW32PanicL(CPanicDirect::DoTestOnNewScheduler,EW32PanicDirectMisuse,5,(TAny*)iTest->iScreenNumber)); - return ENext; - } - -TestState CTDirect::ScrolingText2L() - { - MoveInterval=81234; //0.08 sec - ModeInterval=140123; //0.14 sec - ImmediateModeSwitch=2; - ScrolingTextL(9,TRect(15,25,45,35),ETrue); - iScroll->SetCountDown(5); - return EWait; - } - -TestState CTDirect::ScrolingText3L() - { - iModeBackup=TheClient->iScreen->ScreenModeEnforcement(); - if (iModeBackup!=ESizeEnforcementNone) - TheClient->iScreen->SetScreenModeEnforcement(ESizeEnforcementNone); - MoveInterval=0; - ModeInterval=0; - FlipInterval=1200000; //1.2 secs - ScrolingTextL(10,TRect(25,30,35,45),ETrue,1); - iScroll->SetBottomOfTest(80); //So it can be seen in both screen modes - return EWait; - } - -TestState CTDirect::ScrolingText4L() - { - iModeBackup=TheClient->iScreen->ScreenModeEnforcement(); - if (iModeBackup!=ESizeEnforcementNone) - TheClient->iScreen->SetScreenModeEnforcement(ESizeEnforcementNone); - MoveInterval=876543; //0.88 secs - ModeInterval=2178900; //2.18 secs - FlipInterval=5000000; //5 secs - ScrolingTextL(11,TRect(30,40,55,65),ETrue); - iScroll->SetBottomOfTest(80); //So it can be seen in both screen modes - return EWait; - } - -void CTDirect::CreateAnimForScreenModeL(TInt aAnimIndex,CTWinBase& aParent,TRect aRect,TInt aId) - { - iAnims[aAnimIndex]=CColorAnimation::NewL(iTest->iScreenNumber,aId,*this,aParent,aRect,EFalse); - iAnims[aAnimIndex]->StartL(); - iAnims[aAnimIndex]->BringWindowToFront(); - } - -void CTDirect::BlankTopClientWindowL(CTBlankWindow& aBlankWindow,TRect aRect) - { - aBlankWindow.ConstructExtLD(*TheClient->iGroup,aRect.iTl,aRect.Size()); - User::LeaveIfError(aBlankWindow.BaseWin()->SetRequiredDisplayMode(EColor256)); - aBlankWindow.BaseWin()->SetShadowDisabled(ETrue); - aBlankWindow.Activate(); - } - -static TInt ChangeScreenModeL(TAny* aTest) - { - STATIC_CAST(CTDirect*,aTest)->ChangeToNextScreenModeL(); - return KErrNone; - } - -void CTDirect::ChangeToNextScreenModeL() - { -#if defined(LOGGING) - _LIT(KChangeMode,"AUTO Screen Mode Pos Test2 CallBack"); - LogMessageText.Copy(KChangeMode); - TheClient->LogMessage(LogMessageText); - TheClient->iWs.LogCommand(RWsSession::ELoggingStatusDump); -#endif - iNumOfModes=TheClient->iScreen->NumScreenModes(); - if (iCurrentMode* rotations=new(ELeave) CArrayFixFlat(1); - CleanupStack::PushL(rotations); - User::LeaveIfError(TheClient->iScreen->GetRotationsList(iCurrentMode,rotations)); - TInt count=rotations->Count(); - TInt jj=0; - if (count>1) - { - for (jj=0;jjiScreen->SetCurrentRotations(oldCurrentMode,REINTERPRET_CAST(CFbsBitGc::TGraphicsOrientation&,currentRotation)); - CleanupStack::PopAndDestroy(rotations); - TheClient->iScreen->GetScreenModeSizeAndRotation(oldCurrentMode,pixelsAndRotation); - TInt screenWidth=pixelsAndRotation.iPixelSize.iWidth; - TInt screenHeight=pixelsAndRotation.iPixelSize.iHeight; - TPoint screenModeOrigin=TheClient->iScreen->GetScreenModeScaledOrigin(oldCurrentMode); - TPoint point1(screenModeOrigin.iX,screenModeOrigin.iY+(screenModeOrigin.iY+screenHeight)/2); - TPoint point2(screenModeOrigin.iX+(screenModeOrigin.iX+screenWidth)/2,screenHeight+screenModeOrigin.iY); - TRect rect0(point1,point2); - TRect rect1(TPoint(0,0),rect0.Size()); - CreateAnimForScreenModeL(0,*TheClient->iGroup,rect1,14); - TPoint pos=iAnims[0]->AbsoluteWindowPosition(); - TEST(pos==TPoint(0,0)); - } - } - -TInt ChangeScreenScaleCallBack(TAny* aTest) - { - static_cast(aTest)->ChangeScreenScale(); - return KErrNone; - } - -void CTDirect::ChangeScreenScale() - { - if (!iNumOfCallBack) - { - iCurrentMode=TheClient->iScreen->CurrentScreenMode(); - iModeData=TheClient->iScreen->GetCurrentScreenModeAttributes(); - iModeData.iScreenScale.SetSize(1,1); - } - TSizeMode testMode=iModeData; - if (!iNumOfCallBack) - { - testMode.iScreenScale.SetSize(2,2); - } - else if (iNumOfCallBack==1) - { - testMode.iScreenScale.SetSize(3,2); - } - else if (iNumOfCallBack==2) - { - testMode.iScreenScale.SetSize(2,3); - } - TheClient->iScreen->SetCurrentScreenModeAttributes(testMode); - TheClient->iScreen->SetAppScreenMode(iCurrentMode); - TheClient->iScreen->SetScreenMode(iCurrentMode); - if (iNumOfCallBack==2) - { - iScreenModeTimer->Cancel(); - delete iScreenModeTimer; - iScreenModeTimer=NULL; - } - iNumOfCallBack++; - } - -/* - * Creates a DSA for screen mode 0. After DSA has displayd 2 or 3 frames screen mode - * scale is changed with a timer. The DSA aborts and restarts once again - * and completes itself in different screen mode. - */ -TestState CTDirect::ScreenModeTestForScalingL() - { - CreateAnimForScreenModeL(0,*TheClient->iGroup,TRect(TSize(10,10)),19); - iScreenModeTimer=CPeriodic::NewL(0); - MoveInterval=2000000; - iScreenModeTimer->Start(1000,MoveInterval,TCallBack(ChangeScreenScaleCallBack,this)); - return EWait; - } - -/* - * Creates a DSA for screen mode 0, tests API AbsoluteWindowPosition() - * Then sets screen mode to last(test) screen mode, here it does the same thing as - * done for screenmode 0, but with diffrerent scale (2,2) (2,3) (3,2) (3,3) and - * with different origin (20,30) (30,20) (20,20). - * Lastly copy back the test screen mode values. - */ -TestState CTDirect::ScreenModeScalingTestL() - { -#if defined(LOGGING) -INFO_PRINTF1("AUTO ScreenModeScalingTest "); -#else -// DisabledStartLogText(); -#endif -INFO_PRINTF1(_L(" Switch to mode 0")); - iModeData.iScreenScale.iWidth=1; - iModeData.iScreenScale.iHeight=1; - TheClient->iScreen->SetCurrentScreenModeAttributes(iModeData); - TheClient->iScreen->SetAppScreenMode(0); - TheClient->iScreen->SetScreenMode(0); - iCurrentMode=0; -INFO_PRINTF1(_L(" Get Parameters")); - iCurrentScreenModeOrigin=TheClient->iScreen->GetDefaultScreenModeOrigin(); - iCurrentScreenModeScale=TheClient->iScreen->GetCurrentScreenModeScale(); - Copy2ndHalfOfScreen=(iCurrentScreenModeOrigin.iX>FullScreenModeSize.iWidth/2? 1 : 0); - TRect testWinRect(PhysicalToLogical(TPoint(),iCurrentScreenModeScale), - PhysicalToLogical(TPoint((Copy2ndHalfOfScreen ? FullScreenModeSize.iWidth : - FullScreenModeSize.iWidth/2), - FullScreenModeSize.iHeight)- - iCurrentScreenModeOrigin,iCurrentScreenModeScale) - ); - testWinRect.Shrink(10,10); -INFO_PRINTF1(_L(" Create Animation")); - CreateAnimForScreenModeL(0,*TheClient->iGroup,testWinRect,17); - TPoint pos0=iAnims[0]->AbsoluteWindowPosition(); - TEST(pos0==TPoint(10,10)); - - TInt numOfModes=TheClient->iScreen->NumScreenModes(); - iCurrentMode=numOfModes-1; -INFO_PRINTF1(_L(" Switch to Last Mode")); - TheClient->iScreen->SetAppScreenMode(iCurrentMode); - TheClient->iScreen->SetScreenMode(iCurrentMode); - TSizeMode storeModeData=TheClient->iScreen->GetCurrentScreenModeAttributes(); - TSizeMode testMode=storeModeData; - iNumAnimation=0; - for (TInt xScale=2;xScale<4;xScale++) - { -INFO_PRINTF1(_L(" New X-Scale")); - for (TInt yScale=2;yScale<4;yScale++) - { -INFO_PRINTF1(_L(" New Y-Scale")); - testMode.iScreenScale=TSize(xScale,yScale); - TestDifferentOriginAndScaleL(testMode,TPoint(20,20)); - TestDifferentOriginAndScaleL(testMode,TPoint(20,30)); - TestDifferentOriginAndScaleL(testMode,TPoint(30,20)); - } - } - TheClient->iScreen->SetScreenMode(iCurrentMode); - TheClient->iScreen->SetCurrentScreenModeAttributes(storeModeData); -INFO_PRINTF1(_L(" Set To Mode 0")); - TheClient->iScreen->SetAppScreenMode(0); - TheClient->iScreen->SetScreenMode(0); - return EWait; - } - -void CTDirect::TestDifferentOriginAndScaleL(TSizeMode &aMode,TPoint aOrigin) - { - aMode.iOrigin=aOrigin; - TheClient->iScreen->SetCurrentScreenModeAttributes(aMode); - TheClient->iScreen->SetAppScreenMode(iCurrentMode); - TheClient->iScreen->SetScreenMode(iCurrentMode); - iCurrentScreenModeOrigin=TheClient->iScreen->GetScreenModeOrigin(iCurrentMode); - iCurrentScreenModeScale=TheClient->iScreen->GetScreenModeScale(iCurrentMode); - Copy2ndHalfOfScreen=(iCurrentScreenModeOrigin.iX>FullScreenModeSize.iWidth/2? 1 : 0); - TRect testWinRect(PhysicalToLogical(TPoint(),iCurrentScreenModeScale), - PhysicalToLogical(TPoint((Copy2ndHalfOfScreen ? FullScreenModeSize.iWidth - : FullScreenModeSize.iWidth/2), - FullScreenModeSize.iHeight) - -iCurrentScreenModeOrigin,iCurrentScreenModeScale) - ); - testWinRect.Shrink(10,10); - ++iNumAnimation; - CreateAnimForScreenModeL(iNumAnimation,*TheClient->iGroup,testWinRect,18); - TPoint pos0=iAnims[iNumAnimation]->AbsoluteWindowPosition(); - TEST(pos0==TPoint(10,10)); - } - -//REQUIREMENT: CR PHAR-5SJGAM, PREQ673 -//Tests that DSA works correctly in screen modes with non-zero screen mode origin. -TestState CTDirect::DSAWithScreenModeOffset1L() - { - TPoint screenModeTwoOrigin=TheClient->iScreen->GetScreenModeScaledOrigin(2); - TPixelsAndRotation pixelsAndRotation; - TheClient->iScreen->GetScreenModeSizeAndRotation(2,pixelsAndRotation); - if(pixelsAndRotation.iRotation != CFbsBitGc::EGraphicsOrientationNormal) - { - TheClient->iScreen->SetCurrentRotations(2, CFbsBitGc::EGraphicsOrientationNormal); - } - TheClient->iScreen->GetScreenModeSizeAndRotation(2,pixelsAndRotation); - //check that the current rotation is normal - __ASSERT_DEBUG(pixelsAndRotation.iRotation==CFbsBitGc::EGraphicsOrientationNormal,AutoPanic(EAutoPanicDirect)); - TInt screenWidthMode2=pixelsAndRotation.iPixelSize.iWidth; - TInt screenHeightMode2=pixelsAndRotation.iPixelSize.iHeight; - TPoint point1(screenModeTwoOrigin.iX,screenModeTwoOrigin.iY+(screenModeTwoOrigin.iY+screenHeightMode2)/2); - TPoint point2(screenModeTwoOrigin.iX+(screenModeTwoOrigin.iX+screenWidthMode2)/2,screenHeightMode2+screenModeTwoOrigin.iY); - TPoint point3(screenModeTwoOrigin.iX+screenWidthMode2,screenModeTwoOrigin.iY+screenHeightMode2); - - SetScreenMode(0,pixelsAndRotation); - TRect rect0(point1,point2); - CreateAnimForScreenModeL(0,*TheClient->iGroup,rect0,13); - TPoint pos0=iAnims[0]->AbsoluteWindowPosition(); - TEST(pos0==point1); - - SetScreenMode(2,pixelsAndRotation); - TRect rect1(TPoint(0,0),rect0.Size()); - CreateAnimForScreenModeL(1,*TheClient->iGroup,rect1,13); - TPoint pos1=iAnims[1]->AbsoluteWindowPosition(); - TEST(pos1==rect1.iTl); - - SetScreenMode(0,pixelsAndRotation); - iBlankTopClientWin1=new(ELeave) CTBlankWindow(); -// TInt ordpos = iBlankTopClientWin1->BaseWin()->OrdinalPosition(); - TRect rect2(TPoint(point2.iX,point1.iY),point3); - BlankTopClientWindowL(*iBlankTopClientWin1,rect2); - TInt x=rect2.Size().iWidth/4; - TPoint animWinPt(x,0); - rect2.Shrink(x,0); - CreateAnimForScreenModeL(2,*iBlankTopClientWin1,TRect(animWinPt,rect2.Size()),13); - TPoint pos2=iAnims[2]->AbsoluteWindowPosition(); - TEST(pos2==rect2.iTl); - - SetScreenMode(2,pixelsAndRotation); - iBlankTopClientWin2=new(ELeave) CTBlankWindow(); -// ordpos = iBlankTopClientWin2->BaseWin()->OrdinalPosition(); - TPoint tl(rect1.iBr.iX,0); - TRect rect3(tl,TPoint(screenWidthMode2,rect1.iBr.iY)); - BlankTopClientWindowL(*iBlankTopClientWin2,rect3); - x=rect3.Size().iWidth/4; - animWinPt=TPoint(x,0); - rect3.Shrink(x,0); - CreateAnimForScreenModeL(3,*iBlankTopClientWin2,TRect(animWinPt,rect3.Size()),13); - TPoint pos3=iAnims[3]->AbsoluteWindowPosition(); - TEST(pos3==(animWinPt+tl)); - - SetScreenMode(0,pixelsAndRotation); - return EWait; - } - -//REQUIREMENT: CR PHAR-5SJGAM, PREQ673 -//Tests that DSA works correctly in screen modes with non-zero screen mode origin and different rotations -TestState CTDirect::DSAWithScreenModeOffset2L() - { - iCurrentMode=0; - TTimeIntervalMicroSeconds32 timeBetweenScreenModeChange=3200000; - iCallBackWin->WinTreeNode()->SetOrdinalPosition(0); - iCallBackWin->SetVisible(ETrue); //Used to forsce screen into Color256 so that it will rotate - iChangeScreenModeTimer=CPeriodic::NewL(0); - iChangeScreenModeTimer->Start(0,timeBetweenScreenModeChange,TCallBack(ChangeScreenModeL,this)); - return EWait; - } - -void CTDirect::SetScreenMode(TInt aMode,TPixelsAndRotation& aPixelsAndRotation) - { - TheClient->iScreen->SetScreenMode(aMode); - TheClient->iScreen->SetScreenModeEnforcement(ESizeEnforcementNone); - TheClient->iScreen->GetDefaultScreenSizeAndRotation(aPixelsAndRotation); - TheClient->iScreen->SetScreenSizeAndRotation(aPixelsAndRotation); - TheClient->Flush(); - } - -TestState CTDirect::DefectFix_KAA_5J3BLW_L() - { - TInt numProcessHandles; - RThread().HandleCount(numProcessHandles,iNumThreadHandles); - const TSize screenSize(TheClient->iScreen->SizeInPixels()); - const TRect dsaRect(0,0,screenSize.iWidth>>2,screenSize.iHeight>>2); - iAnim=CBugFixColorAnimation::NewL(iTest->iScreenNumber, 1, *this, *TheClient->iGroup, dsaRect,ETrue); - return EWait; - } - -TestState CTDirect::RegionTrackingOnlyNotificationsL(TUint aId) - { - TInt numProcessHandles; - RThread().HandleCount(numProcessHandles,iNumThreadHandles); - const TSize screenSize(TheClient->iScreen->SizeInPixels()); - const TRect dsaRect(0,0,screenSize.iWidth>>2,screenSize.iHeight>>2); - TBool isWindowOpenedInFrontOfDsa = (aId == KRegionTrackingOnlyDsaWaitingForAbortSignal); - iAnim=CRegionTrackingOnly::NewL(iTest->iScreenNumber, aId, *this, *TheClient->iGroup, dsaRect,ETrue,isWindowOpenedInFrontOfDsa); - return EWait; - } - -// Tests the new function of getting the window's absolute position -TestState CTDirect::WindowPoistionRelativeToScreenL() - { - //.. delete screen mode timer - delete iChangeScreenModeTimer; - iChangeScreenModeTimer=NULL; - - TInt numProcessHandles; - RThread().HandleCount(numProcessHandles,iNumThreadHandles); - TSize screenSize(TheClient->iScreen->SizeInPixels()); - TRect rect(0,0,screenSize.iWidth>>1,screenSize.iHeight); - rect.Shrink(10,10); - // First animation is for showing that child window is within the visible part of the parent window and within the visible screen area - iAnims[0]=new(ELeave) CColorAnimation(iTest->iScreenNumber,15,*this); - iAnims[0]->ConstructL(*TheClient->iGroup,rect,KDrawingDsa,1); - iAnims[0]->StartL(ETrue); - // First animation is for showing that child window is to the side of visible part of parent window - rect.Move(screenSize.iWidth>>1,0); - iAnims[1]=new(ELeave) CColorAnimation(iTest->iScreenNumber,16,*this); - iAnims[1]->ConstructL(*TheClient->iGroup,rect,KDrawingDsa,2); - iAnims[1]->StartL(ETrue); - return EWait; - } - -TestState CTDirect::MultipleDSAsOnSameWindowL() - { - TInt numProcessHandles; - RThread().HandleCount(numProcessHandles,iNumThreadHandles); - iCallBackWin->SetVisible(ETrue); - iCallBackWin->WinTreeNode()->SetOrdinalPosition(0); - iAnims[0]=new(ELeave) CColorAnimation(iTest->iScreenNumber,20,*this); - iAnims[0]->ConstructL(*TheClient->iGroup,TRect(),KDrawingDsa,0,1); - iAnims[0]->StartL(); - iAnims[1]=new(ELeave) CColorAnimation(iTest->iScreenNumber,21,*this); - iAnims[1]->ConstructL(*TheClient->iGroup,TRect(),KDrawingDsa,0,2); - iAnims[1]->StartL(); - _LIT(ThreadName,"MoveWin"); - MoveInterval=100000; - ModeInterval=0; - FlipInterval=0; - ImmediateModeSwitch=EFalse; - iFirstFunction=TThreadStartUp(CMoveWindow::StartLC,(TAny*)iTest->iScreenNumber); - iMoveWin=CProcess::NewThreadL(ThreadName,&iFirstFunction); - return EWait; - } - -TestState CTDirect::KillAnimationL() - { - TInt numProcessHandles; - RThread().HandleCount(numProcessHandles,iNumThreadHandles); - iAnim=CColorAnimation::NewL(iTest->iScreenNumber,12,*this,*TheClient->iGroup,TRect(15,15,625,225),ETrue); - return EWait; - } - -TestState CTDirect::TemporaryDeadlockL() - { - - if (iTestJustCompleted) - { - if (iTestJustFailed) - { - Fail(); - } - iState++; - return ENext; - } - - //make sure this code isn't called a second time - __ASSERT_ALWAYS(iAnim==NULL,AutoPanic(EAutoPanicDirect)); - - TSize screenSize(TheClient->iScreen->SizeInPixels()); - TRect rect(0,0,screenSize.iWidth>>1,screenSize.iHeight); - rect.Shrink(10,10); - iAnim=new(ELeave) CColorAnimation(iTest->iScreenNumber,24,*this); - iAnim->ConstructL(*TheClient->iGroup,rect,KDrawingDsa,1); - iAnim->StartL(ETrue); - return EWait; - } - -void CTDirect::CheckForTemporaryDeadlock() - { - - TBool result=ETrue; - TInt error; - - - //Create a window for placing on top - TTime beforeTime; - beforeTime.HomeTime(); - - RWindow window(TheClient->iWs); - - error=window.Construct(*TheClient->iGroup->GroupWin(), reinterpret_cast(&window)); - if (error==KErrNone) - { - window.SetOrdinalPosition(0); - window.SetExtent(TPoint(30,30),TSize(10,10)); - window.SetBackgroundColor(TRgb(255,0,255)); - - //make sure the basewin is towards the back - iCallBackWin->BaseWin()->SetOrdinalPosition(5); - - window.SetRequiredDisplayMode(EColor256); - window.Activate(); - TheClient->iWs.Flush(); - //need code similar to below, but the status of the active object we - //really want is too private - //if (!iAnim->IsReadyToAbort()) - // { - // result=EFalse; - // } - window.Close(); - } - else - { - result = EFalse; - } - - TTime afterTime; - afterTime.HomeTime(); - TTimeIntervalMicroSeconds difference = afterTime.MicroSecondsFrom(beforeTime); - - //make time difference 350ms, since the two timers to be checked are 400ms and 500ms - if (difference>TTimeIntervalMicroSeconds(1000*350)) - { - result=EFalse; - } - - iTestJustCompleted = ETrue; - if (result==EFalse) - { - iTestJustFailed=ETrue; - } - } - -void CTDirect::RunTestCaseL(TInt /*aCurTestCase*/) - { - _LIT(Animation1,"Animating"); - _LIT(Animation2,"Animating Dies"); - _LIT(Animation3,"Packaging Class"); - _LIT(Animation4,"Many Animations"); - _LIT(Animation5,"Fail Codes"); - _LIT(Animation6,"Cancel The Other"); - _LIT(Animation7,"'R' Class API"); - _LIT(Animation8,"Switch Clear Type"); - _LIT(Animation9,"SizeMode Change"); - _LIT(Animation10,"Soak Testing"); - _LIT(Animation11,"Kill Animation"); - _LIT(Animation12,"Defect-Fix: KAA-5J3BLW"); - _LIT(Animation13,"Screen Mode Positioning DSA Test 1"); - _LIT(Animation14,"Screen Mode Positioning DSA Test 2"); - _LIT(Animation15,"Position Relative to Screen"); - _LIT(Animation16,"Screen mode Scaling DSA Test 1"); - _LIT(Animation17,"Screen mode Scaling DSA Test 2"); - _LIT(Animation18,"Multiple DSAs on same window"); - _LIT(Animation19,"DSA and windows temporary deadlock"); - _LIT(Animation25,"RegionTrackingOnly DSA, window opened in front"); -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA - _LIT(Animation26,"RegionTrackingOnly DSA, window opened behind"); - _LIT(Animation27,"Mixed DSAs, RegionTrackingOnly DSA last to exit"); - _LIT(Animation28,"Mixed DSAs, drawing DSA last to exit"); - _LIT(Animation29,"Trying all the screen supported modes"); -#endif - TestState ret=ENext; - - if (iTimerRunning && !iPackagingFinished) - { - // Prevent test harness from repeatedly running the test case too quickly. - User::After(SHORT_DELAY); - } - - //if (iState==0) iState=18; - iTest->iState=iState; - ((CTDirectStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); - switch(iState) - { -/** -@SYMTestCaseID GRAPHICS-WSERV-0158 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Create seven seperate animations and run them to completion - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Create animations and start them running. Run until the animations finish. - -@SYMTestExpectedResults The animation run to completion without error -*/ - case 0: - ((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0158")); - if (iNextFrameFinished) - InitialiseAnimationL(); - case 1: - ((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0158")); - case 2: - ((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0158")); - case 3: - ((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0158")); - case 4: - ((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0158")); - case 5: - ((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0158")); - case 6: - ((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0158")); - if (iNextFrameFinished) - { - iTest->LogSubTest(Animation1); - ret=AnimateWindowL(); - iNextFrameFinished=EFalse; - } - else - { - // Prevent test harness from repeatedly running the test case too quickly. - User::After(SHORT_DELAY); - } - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0159 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Check animation dies correctly when run in a thread - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Create animation and run in from a thread that dies. Once the thread - has died check the animation has been dealt with correctly. - -@SYMTestExpectedResults The animation dies correctly -*/ - case 7: - ((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0159")); - iTest->LogSubTest(Animation2); - ret=AnimationDiesL(); - ++iState; - DestroyAnimation(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0160 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Check animation runs correctly in blank window - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Create an animation and run it in a blank window - -@SYMTestExpectedResults The animation runs to completion without error -*/ - case 8: - ((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0160")); - if (!iTimerRunning) - { - iTest->LogSubTest(Animation3); - ret=PackagingClassL(); - iTimerRunning = ETrue; - } - if (iPackagingFinished) - { - iPackagingFinished = EFalse; - iTimerRunning = EFalse; - } - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0161 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Check many animations can be run in the same window - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Create multiple animations in a window and run them all - until completion - -@SYMTestExpectedResults The animations run without error -*/ - case 9: - ((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0161")); - if (!iTimerRunning) - { - iTest->LogSubTest(Animation4); - ret=MultipleL(); - iTimerRunning = ETrue; - } - if (iPackagingFinished) - { - iPackagingFinished = EFalse; - iTimerRunning = EFalse; - } - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0162 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Direct screen access out of memory test - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Direct screen access out of memory test - -@SYMTestExpectedResults The out of memory error is handled correctly -*/ - case 10: - ((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0162")); - iTest->LogSubTest(Animation5); - ret=FailCodesL(); - iState++; - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0163 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Two animations, one scrolling text - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Create two animations, one which scrolls text across the screen and - run them to completion - -@SYMTestExpectedResults The animations run without error -*/ - case 11: - ((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0163")); - if (!iTimerRunning) - { - iTest->LogSubTest(Animation6); - ret=ScrolingText1L(); - iTimerRunning = ETrue; - } - if (iPackagingFinished) - { - iPackagingFinished = EFalse; - iTimerRunning = EFalse; - } - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0164 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test direct screen access panic messages - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Call the direct screen access panic's and check they are handled - correctly - -@SYMTestExpectedResults The panic's are handled correctly -*/ - case 12: - ((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0164")); - iTest->LogSubTest(Animation7); - ret=RClassL(); - iTest->CloseAllPanicWindows(); - iState++; - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0165 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Two animations, one scrolling text - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Create two animations, one which scrolls text across the screen and - run them to completion - -@SYMTestExpectedResults The animations run without error -*/ - case 13: - ((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0165")); - if (!iTimerRunning) - { - iTest->LogSubTest(Animation8); - ret=ScrolingText2L(); - iTimerRunning = ETrue; - } - if (iPackagingFinished) - { - iPackagingFinished = EFalse; - iTimerRunning = EFalse; - } - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0166 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Two animations, one scrolling text. Change the screen mode an run. - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Create two animations, one which scrolls text across the screen and - run them to completion while changing the screen mode - -@SYMTestExpectedResults The animations run without error -*/ - - case 14: - ((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0166")); - if (!iTimerRunning) - { - iTest->LogSubTest(Animation9); - ret=ScrolingText3L(); - if (ret == ENext) - iPackagingFinished = ETrue; - else - iTimerRunning = ETrue; - } - if (iPackagingFinished) - { - iPackagingFinished = EFalse; - iTimerRunning = EFalse; - FlipInterval = 0; // Stops the tests (erroneously) flipping for the rest of the run - } - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0167 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Start an animation then kill it - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Start an animation running then kill it. Check the animation dies correctly - -@SYMTestExpectedResults The animations dies correctly -*/ - case 15: - ((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0167")); - if (!iTimerRunning) - { - iTest->LogSubTest(Animation11); - ret=KillAnimationL(); - iTimerRunning = ETrue; - } - if (iPackagingFinished) - { - iPackagingFinished = EFalse; - iTimerRunning = EFalse; - } - break; - case 16: - ((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0167")); - iTest->LogSubTest(Animation10); //This test is designed to be left running for at least several hours - //ret=ScrolingText4L(); - iState++; - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0168 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc CBugFixColorAnimation - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions This class is used for reproducing a defect found on 6.1: KAA-5J3BLW "Unnecessary Wserv's DSA abort". - The problem was that a direct screen access client was getting an unnecessary abort notification - when a new window (or window group) was created but not visible. - This class will simulate the direct screen access client and it will check whether the first DSA abort - is not caused by just creating a window. - -@SYMTestExpectedResults Abort is not caused when creatung a window -*/ - case 17: - ((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0168")); - if (!iTimerRunning) - { - iTest->LogSubTest(Animation12); - ret=DefectFix_KAA_5J3BLW_L(); - iTimerRunning = ETrue; - } - if (iPackagingFinished) - { - iPackagingFinished = EFalse; - iTimerRunning = EFalse; - } - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0169 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Direct screen access in screen modes with non-zero screen mode origin - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Tests that DSA works correctly in screen modes with non-zero screen mode origin - -@SYMTestExpectedResults The DSA works correctly -*/ - case 18: - ((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0169")); - if (!CheckNonZeroOriginsSupportedOrNot()) - { - INFO_PRINTF1(_L("Non Zero Origins not supported\n")); - iState++; - } - else - { - if (!iTimerRunning) - { - iTest->LogSubTest(Animation13); - ret=DSAWithScreenModeOffset1L(); - iTimerRunning = ETrue; - } - if (iPackagingFinished) - { - iPackagingFinished = EFalse; - iTimerRunning = EFalse; - } - } - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0170 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Direct screen access in screen modes with non-zero screen mode origin - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Tests that DSA works correctly in screen modes with non-zero screen mode origin and different rotations - -@SYMTestExpectedResults The DSA works correctly -*/ - case 19: - ((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0170")); - if (!CheckNonZeroOriginsSupportedOrNot()) - { - INFO_PRINTF1(_L("Non Zero Origins not supported\n")); - iState++; - } - else - { - if (!iTimerRunning) - { - iTest->LogSubTest(Animation14); - ret=DSAWithScreenModeOffset2L(); - iTimerRunning = ETrue; - } - if (iPackagingFinished) - { - iPackagingFinished = EFalse; - iTimerRunning = EFalse; - } - } - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0171 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Window absolute position - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Tests the new function of getting the window's absolute position - -@SYMTestExpectedResults Function works correctly -*/ - case 20: - ((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0171")); - if (!iTimerRunning) - { - iTest->LogSubTest(Animation15); - ret=WindowPoistionRelativeToScreenL(); - iTimerRunning = ETrue; - } - if (iPackagingFinished) - { - iPackagingFinished = EFalse; - iTimerRunning = EFalse; - } - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0172 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test direct screen access restart - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Creates a DSA for screen mode 0. After DSA has displayed 2 or 3 frames screen mode - scale is changed with a timer. The DSA aborts and restarts once again - and completes itself in different screen mode. - -@SYMTestExpectedResults DSA restarts and completes correctly -*/ - case 21: - ((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0172")); - if (iIsScalingSupported) - { - if (!iTimerRunning) - { - iTest->LogSubTest(Animation16); - ret=ScreenModeTestForScalingL(); - iTimerRunning = ETrue; - } - if (iPackagingFinished) - { - iPackagingFinished = EFalse; - iTimerRunning = EFalse; - } - break; - } - iState++; - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0173 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test direct screen access scaling - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Creates a DSA for screen mode 0, tests API AbsoluteWindowPosition() - Then sets screen mode to last(test) screen mode, here it does the same thing as - done for screenmode 0, but with diffrerent scale (2,2) (2,3) (3,2) (3,3) and - with different origin (20,30) (30,20) (20,20). - Lastly copy back the test screen mode values. - -@SYMTestExpectedResults DSA scales correctly -*/ - case 22: - ((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0173")); - if (iIsScalingSupported) - { - if (!iTimerRunning) - { - iTest->LogSubTest(Animation17); - ret=ScreenModeScalingTestL(); - iTimerRunning = ETrue; - } - if (iPackagingFinished) - { - iPackagingFinished = EFalse; - iTimerRunning = EFalse; - } - break; - } - iState++; - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0174 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test multiple direct screen access elements on the same window - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Create a number of direct screen access elements on the same window and - check that they work correctly - -@SYMTestExpectedResults DSAs work correctly -*/ - case 23: - ((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0174")); - if (iIsScalingSupported) - { - if (!iTimerRunning) - { - iTest->LogSubTest(Animation18); - ret=MultipleDSAsOnSameWindowL(); - iTimerRunning = ETrue; - } - if (iPackagingFinished) - { - iPackagingFinished = EFalse; - iTimerRunning = EFalse; - } - break; - } - iState++; - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0175 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Create a temporary deadlock on a DSA and resolve it - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Resolve a temporary deadlock on a DSA - -@SYMTestExpectedResults DSA resolves the deadlock -*/ - case 24: - ((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0175")); - if (!iTimerRunning) - { - iTest->LogSubTest(Animation19); - ret=TemporaryDeadlockL();//for INC072887 - removing a 0.5s delay in wserv. - iTimerRunning = ETrue; - } - if (iPackagingFinished) - { - iPackagingFinished = EFalse; - iTimerRunning = EFalse; - iState++; - } - break; -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA - case 25: -/** -@SYMTestCaseID GRAPHICS-WSERV-0533 -*/ - ((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0533")); - if (!iTimerRunning) - { - FlipInterval=0; - iTest->LogSubTest(Animation25); - //Opens a window in front of a region tracking only DSA - ret=RegionTrackingOnlyNotificationsL(KRegionTrackingOnlyDsaWaitingForAbortSignal); - iTimerRunning = ETrue; - } - if (iPackagingFinished) - { - iPackagingFinished = EFalse; - iTimerRunning = EFalse; - } - break; - case 26: -/** -@SYMTestCaseID GRAPHICS-WSERV-0534 -*/ - ((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0534")); - if (!iTimerRunning) - { - iTest->LogSubTest(Animation26); - //Opens a window behind a region tracking only DSA - ret=RegionTrackingOnlyNotificationsL(KRegionTrackingOnlyDsaNoAbortSignal); - iTimerRunning = ETrue; - } - if (iPackagingFinished) - { - iPackagingFinished = EFalse; - iTimerRunning = EFalse; - } - break; - case 27: -/** -@SYMTestCaseID GRAPHICS-WSERV-0535 -*/ - ((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0535")); - if (!iTimerRunning) - { - iTest->LogSubTest(Animation27); - ret=MixDsaAndRegionTrackingOnlyL(KRegionTrackingOnlyDsaExistLast); - iTimerRunning = ETrue; - } - if (iPackagingFinished) - { - iPackagingFinished = EFalse; - iTimerRunning = EFalse; - } - break; - case 28: -/** -@SYMTestCaseID GRAPHICS-WSERV-0536 -*/ - ((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0536")); - if (!iTimerRunning) - { - iTest->LogSubTest(Animation28); - ret=MixDsaAndRegionTrackingOnlyL(KDrawingDsaExistLast); - iTimerRunning = ETrue; - } - if (iPackagingFinished) - { - iPackagingFinished = EFalse; - iTimerRunning = EFalse; - } - break; - case 29: -/** -@SYMTestCaseID GRAPHICS-WSERV-0537 -*/ - ((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0537")); - if (!iTimerRunning) - { - iTest->LogSubTest(Animation29); - ret=TryDifferentSupportedModesL(); - iTimerRunning = ETrue; - } - if (iPackagingFinished) - { - iPackagingFinished = EFalse; - iTimerRunning = EFalse; - } - break; -#else -//NON NGA negative test for RegionTrackingOnly DSA - case 25: -/** -@SYMTestCaseID GRAPHICS-WSERV-0575 -*/ - ((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0575")); - if (!iTimerRunning) - { - FlipInterval=0; - iTest->LogSubTest(Animation25); - CColorAnimation* temp = NULL; - //Attempt to create a RegionTrackingOnly DSA in non NGA code - TRAPD(err,temp = CColorAnimation::NewL(iTest->iScreenNumber,1,*this,*TheClient->iGroup,TRect(10,10,630,230),ETrue,KRegionTrackingOnly)); - if(err!=KErrNotSupported) - { - _LIT(KCTDirectNonNgaError,"Attempt to creat a RegionTrackingOnly DSA did not return KErrNotSupported on non-NGA"); - LOG_MESSAGE(KCTDirectNonNgaError); - if(temp) - { - delete temp; - } - Fail(); - } - else - { - _LIT(KCTDirectNonNgaSuccess,"RegionTrackingOnly DSA not supported on non-NGA as expected"); - LOG_MESSAGE(KCTDirectNonNgaSuccess); - } - iState++; - } - break; -#endif - default: - ((CTDirectStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - ((CTDirectStep*)iStep)->CloseTMSGraphicsStep(); - TestComplete(); - break; - } - ((CTDirectStep*)iStep)->RecordTestResultL(); - } - -CRegionTrackingOnly* CRegionTrackingOnly::NewL(TInt aScreenNumber,TInt aId,MAnimCallBacks& aCallBack,CTWindowGroup& aParent,TRect aExtent,TBool aStart,TBool aOpenWindowInFrontDsa) - { - CRegionTrackingOnly* self=new(ELeave) CRegionTrackingOnly(aScreenNumber, aId,aCallBack); - CleanupStack::PushL(self); - self->ConstructL(aParent,aExtent,aOpenWindowInFrontDsa); - if (aStart) - { - self->StartL(); - self->Started(); - } - CleanupStack::Pop(self); - return self; - } - -CRegionTrackingOnly::CRegionTrackingOnly(TInt aScreenNumber,TInt aId,MAnimCallBacks& aCallBack) - : CColorAnimation(aScreenNumber, aId, aCallBack) - { - iThreadParam.iScreenNumber = aScreenNumber; - } - -void CRegionTrackingOnly::ConstructL(CTWindowGroup& aParent,TRect aExtent,TBool aOpenWindowInFrontDsa) - { - iExpectedToAbort = aOpenWindowInFrontDsa; - CColorAnimation::ConstructL(aParent, aExtent, KRegionTrackingOnly); - _LIT(ThreadName,"Create new Window"); - - TInt error=iSem.CreateGlobal(KSem_DefectFix_KAA_5J3BLW_Name, 0); - if (error==KErrNone) - { - iAnimRect=aExtent; - iThreadParam.iRect = iAnimRect; - iThreadParam.iIsInFront = aOpenWindowInFrontDsa; - TThreadStartUp function=TThreadStartUp(CreateNewWindowGroup, &iThreadParam); - TRequestStatus status; - iThread=CProcess::NewThreadRendezvousL(ThreadName,&function,status); - User::WaitForRequest(status); - if (status != KErrNone) - { - RDebug::Printf("the request status is returned to be non KErrNone: %d", status.Int()); - TestFailed(this); - } - } - else - { - TestFailed(this); - } - } - -TBool CColorAnimation::TestGcAndScreenDeviceValues() - { - TBool succeeded = ETrue; - _LIT(KErrorLogGraphicContext,"GraphicsContext not NULL when using the region tracking feature only"); - _LIT(KErrorLogScreenDevice,"ScreenDevice not NULL when using the region tracking feature only"); - if(iRegionTrackingOnly && iDrawer->Gc() != NULL) - { - CallBack().Log((TText8*)__FILE__,__LINE__, ESevrErr,KErrorLogGraphicContext); - succeeded = EFalse; - } - if(iRegionTrackingOnly && iDrawer->ScreenDevice() != NULL) - { - CallBack().Log((TText8*)__FILE__,__LINE__, ESevrErr,KErrorLogScreenDevice); - succeeded = EFalse; - } - return succeeded; - } - -void CRegionTrackingOnly::AbortNow(RDirectScreenAccess::TTerminationReasons /*aReason*/) - { - Stop(); - } - -void CRegionTrackingOnly::Restart(RDirectScreenAccess::TTerminationReasons/* aReason*/) - { - if(!TestGcAndScreenDeviceValues()) - { - CallBack().Fail(); - } - if (iExpectedToAbort) - { - _LIT(KExpected,"DSA got an abort signal as expected"); - CallBack().Log((TText8*)__FILE__,__LINE__,ESevrInfo,KExpected); - } - else - { - _LIT(KError,"DSA got an abort signal even though the window was opened behind it"); - CallBack().Log((TText8*)__FILE__,__LINE__,ESevrErr,KError); - CallBack().Fail(); - } - FinishTest(); - } - -CRegionTrackingOnly::~CRegionTrackingOnly() - { - iSem.Close(); - if(iThread) - { - TRequestStatus status; - iThread->Logon(status); - if (iThread->StillAlive()) - { - iThread->Terminate(KErrNone); - User::WaitForRequest(status); - } - delete iThread; - } - } - -__WS_CONSTRUCT_STEP__(Direct) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TEVENT.H --- a/windowing/windowserver/tauto/TEVENT.H Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,423 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - - -#ifndef __TEVENT_H__ -#define __TEVENT_H__ - -#include -#include -#include -#include "../tlib/testbase.h" -#include "AUTO.H" -#include "AUTODLL.H" -#include "../TClick/CLICK.H" -#include "TGraphicsHarness.h" -#ifndef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA -#include -#include -#endif //TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - -const TInt EMaxEventQueueSize=32; -const TInt EMinQueueSize = 2; - - -class CTEventTest; -class CTQueueClient; - -class TWsQTEvent : public TWsEvent - { - friend class CTEventTest; -public: - inline TTime& Time() {return iTime;} - }; - -class CTQueueTestEvent : public CTEvent - { - enum {EEventBufferSize=40}; -public: - CTQueueTestEvent(RWsSession *aWs, CTEventTest *aTest); - void ConstructL(); - void AddExpectedEvent(TWsEvent &aEvent); - inline void ResetCount(TInt aSet) {iEventCount=0;iEventSet=aSet;iLastEventError=EFalse;} - TInt EventsLeft(); - inline void SetCheckTimeStamp(TBool aCheck) {iCheckTimeStamp = aCheck;} -protected: - void doRunL(); -private: - void TestL(TInt aTest); -private: - CCirBuf iEventBuffer; - CTEventTest *iTest; - TInt iEventCount; - TInt iEventSet; - TBool iCheckTimeStamp; - TPartialRedrawType iRedrawType; - TBool iLastEventError; - }; - -const TInt EWinPositionX=6; -const TInt EWinPositionY=9; -const TInt EWinWidth=100; -const TInt EWinHeight=50; -// (6,9) -// +----------------------+ -// | (31,21) | -// | +--------------+ | -// | | | | -// | | | | -// | +--------------+ | -// | (81,46) | -// +----------------------+ (106,59) - -class CTQueueClient : public CTClient - { -private: - enum {EMaxKeysDown=50}; -public: - CTQueueClient(CTEventTest *aTest); - ~CTQueueClient(); - void ConstructL(TBool aCreateChild); - void ConstructEventHandlerL(); - void AddExpectedEvent(TWsEvent &aEvent); - TInt WindowGroupIdentifier(); - CTWinBase* GetHandle(TPoint& aPos); - void SetChildCapture(TInt aCaptureFlags); - inline void ResetCount(TInt aSet) {EventQueue()->ResetCount(aSet);} - inline void EnableFocusChangeEvents() {iGroup->GroupWin()->EnableFocusChangeEvents();} - inline void DisableFocusChangeEvents() {iGroup->GroupWin()->DisableFocusChangeEvents();} - inline void EnableGroupListChangeEvents() {iGroup->GroupWin()->EnableGroupListChangeEvents();} - inline void DisableGroupListChangeEvents() {iGroup->GroupWin()->DisableGroupListChangeEvents();} - inline CTQueueTestEvent* EventQueue() {return STATIC_CAST(CTQueueTestEvent*,iEventHandler);} - inline TPoint ChildTopLeft() {return TPoint(EWinWidth/4,EWinHeight/4);} - inline TSize ChildSize() {return TSize(EWinWidth/2,EWinHeight/2);} - void CreateEventTestGroupOnSecondScreenL(); - void CloseEventTestGroupOnSecondScreen(); -private: - inline TPoint ParentTopLeft() {return TPoint(EWinPositionX,EWinPositionY);} - inline TPoint ChildAbsTopLeft() {return ParentTopLeft()+ChildTopLeft();} -private: - TInt iKeysDown[EMaxKeysDown]; - TInt iNumKeysDown; - CTEventTest *iTest; -public: - CTBackedUpWin *iChildWin; - CTBackedUpWin *iWin; - TBool iChildCapturing; - TBool iCapturing; - CWsScreenDevice* iSndScreen; - RWindowGroup* iWinGp1; - RWindowGroup* iWinGp2; - }; - -class REventAnimBase : public RTestAnim - { -public: - enum EAnimationType - { - EEventAnim, - EEventPostingAnim - }; - REventAnimBase(RAnimDll* aDll) :RTestAnim(*aDll) {} - virtual void Destroy(); - void Reset(); - TInt ErrorCode(); - TInt NumberOfEventsReceived(); - TInt AddExpectedEvent(TBool aEat, const TRawEvent& aEvent); - TInt AddExpectedEvent(const TAnimRawEvent& aEvent); - static RAnimDll* LoadL(); - }; - -/** - Client side handle to server-side anim class used for Anim Event tests - @internalComponent - @test - */ -class REventAnim : public REventAnimBase - { -public: - static REventAnim* NewL(RWindowBase* aWin, RAnimDll* aDll, REventAnimBase::EAnimationType aType=EEventAnim); - inline REventAnim(RAnimDll* aDll) : REventAnimBase(aDll) {} - inline TInt AddEvent(const TAnimRawEvent& aEvent) {return REventAnimBase::AddExpectedEvent(aEvent);}; - inline TInt GetError() {return REventAnimBase::ErrorCode();}; - inline TInt GetNumEvents() {return REventAnimBase::NumberOfEventsReceived();}; - TInt TestFail(TInt aNoEvents); - }; - -/** - Client side handle to server-side anim class used for Event Handler Removal tests - - RRemovableAnim is an anim which removes itself from the event handler list - after receiving n events, where n is the 'lifetime' of the anim measured in events received. - - @internalComponent - @test - */ -class RRemovableAnim : public REventAnimBase - { -public: - static RRemovableAnim* NewLC(RWindowBase* aWin, RAnimDll* aDll); - inline RRemovableAnim(RAnimDll* aDll) : REventAnimBase(aDll) {} - inline TInt AddExpectedEvent(const TRawEvent& aEvent) {return REventAnimBase::AddExpectedEvent(EFalse, aEvent);}; - TInt SetEventHandlerLifetime(TInt aEventCount); - TInt EventHandlerLifetime(); - TInt AddToEventHandlers(); - TInt RemoveFromEventHandlers(); - TBool TestPassed(); - }; - -class CTEventTest : public CTWsGraphicsBase - { - enum { - EKeyboardInitialRepeat1=1234567, - EKeyboardRepeat1=555666, - EKeyboardInitialRepeat2=2121212, - EKeyboardRepeat2=20000, - EDoubleClickTime1=900000, - EDoubleClickGap1=10, - EDoubleClickTime2=4000000, - EDoubleClickGap2=5, - ENumVisWins=2, - EPointerCursorUpdateGap=50000, //0.05secs Same as WsPointer::EPointerUpdateGapInMicroSeconds - EKeyboardInitialRepeat3=2147483447, // Max value - EKeyboardRepeat3=8000, // for repeat 3 - EKeyboardInitialRepeat4=-2, // Min value - EKeyboardRepeat4=6000, // for repeat 4 - EKeyboardRepeat5=7000, // for repeat 4z - EKeyboardRepeat6=-30000, // for repeat 4 - EKeyboardRepeat7=2147483447, // for repeat 4 - }; -public: - CTEventTest(CTestStep* aStep); - ~CTEventTest(); - //TestState DoTestL(); - void ConstructL(); - void General(); - void General2(); - void Failed(); - //void QueuePurgingL(); - //void SendEventL(); - //void InvisibleWindowL(); - //void JavaAdditionsL(); - void WindowCapBugL(); - //void XyInputTypeL(); - //void MovingPointerCursorL(); - //void RotatedModeL(); - //void AnimEvent(); - void CheckTimeInterval(const TTimeIntervalMicroSeconds32 &aTime,TInt EKeyboardRepeat1); - void KeyRepeatRate(TInt aInitialRepeat, TInt aRepeat); - void KeyRepeatRateNegTest(TInt aInitialRepeat, TInt aRepeat); - void DoubleClickSettings(TInt aInterval, TInt aDistance); - void NextSetOfEventsL(); - inline void ResetCount(TInt aSet) {iQueueClient->ResetCount(aSet);} -protected: -//from CTGraphicsStep - virtual void RunTestCaseL(TInt aCurTestCase); -private: - enum - { - EDoRot0 =0x01, - EDoRot90 =0x02, - EDoRot180=0x04, - EDoScale=0x80, - }; - enum TClients - { - ETheClient, - EQueueClient, - }; - enum TCaptureKeyApis - { - ECaptureKey1, - ECaptureKey2, - ECaptureKeyUpAndDowns1, - ECaptureKeyUpAndDowns2, - ECaptureLongKey1, - ECaptureLongKey2, - // Add additional enum values before this line - EMaxCaptureKeyApis - }; - enum TCancelCaptureKeyApis - { - ECancelCaptureKey, - ECancelCaptureKeyUpAndDowns, - ECancelCaptureLongKey, - // Add additional enum values before this line - EMaxCancelCaptureKeyApis - }; -private: - void RunTestsL(TBool aNeedChildWindows=EFalse); - void RunTestsRestoreAreaL(TBool aNeedChildWindows); - void QueuePurge_NextSetOfEventsL(); - void InitializeQueueSizeTestL(TBool aEventReadyCancel); - void SendEventTest_NextSetOfEvents(); - void InvisibleWindow_NextSetOfEvents(); - void JavaAdditions_NextSetOfEvents(); - void XyInputType_NextSetOfEvents(); - void MovingPointerCursor_NextSetOfEventsL(); - void WinCap_NextSetOfEvents(); - void RotatedMode_NextSetOfEventsL(); - void ScreenScaling_NextSetOfEventsL(); - void AnimEvent_NextSetOfEventsL(); - void FocusChanged_NextSetOfEventsL(); - void StopEvents_NextSetOfEventsL(); - void VirtualKeyboard_NextSetOfEventsL(); - void KeyClicks_NextSetOfEvents(); - void CaptureLong_NextSetOfEventsL(); - void Password_NextSetOfEvents(); - void GroupListChanged_NextSetOfEventsL(); - void VisibilityChanged_NextSetOfEventsL(); -#ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS -#ifndef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - void SurfaceVisibilityChanged1_NextSetOfEventsL(); - void SurfaceVisibilityChanged2_NextSetOfEventsL(); - void SurfaceVisibilityChanged3_NextSetOfEventsL(); -#endif //TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA -#endif //SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS - void CheckTimeStamp_NextSetOfEventsL(); - void RepeatableKeysL(); - void PointerCapture_NextSetOfEventsL(); - void PointerBufferPurge_NextSetOfEventsL(); - void MismatchedCapture_NextSetOfEventsL(); - void EventHandlerRemoval_NextSetOfEventsL(); - void EventHandlerRemoval_CreateAnimsL(TInt aAnimCount); - void EventHandlerRemoval_PrepareAnims(const TInt* aLifeTimes, TInt aAnimCount); - void EventHandlerRemoval_CreateExpectedEvents(TInt aEventCount, TInt aLiveAnimCount); - void EventHandlerRemoval_AddExpectedEvent(TRawEvent aEvent, TInt aLiveAnimCount); - void EventHandlerRemoval_CheckExpectedEventsReceivedByAnims(); - void EventHandlerRemoval_CheckRecursionOfProcessRawEvent(); - void EventHandlerRemoval_ManuallyRemoveAllAnims(); - void EventHandlerRemoval_ResetAllAnims(); - void EventHandlerRemoval_RemoveAndResetAllAnims(); - void EventHandlerRemoval_DestroyAllAnims(); - void EventHandlerRemoval_AddEventHandlerMultipleTimes(); - void CheckPointerCursorInDifferentScreenMode(TSizeMode aMode,TPoint aOrigin); - void SimulateAndCheck(TPoint aOrigin,TSize aScale,TInt aXOffset,TInt aYOffset,TPointerEvent::TType aEventType,TRect aPointerCursorArea); - void AddExpectedKey(TInt aEventCode, TInt aScanCode, TInt aCode=0, TInt aRepeats=0, TUint aModifiers=0); - void AddExpectedKeyDownUp(TInt aScanCode, TInt aCode=0, TInt aRepeats=0, TUint aModifiers=0); - void AddExpectedEvent(TInt aEventCode, CTWinBase* aWin); - void AddExpectedEvent(TInt aEventCode); - void AddExpectedEvent(TInt aEventCode,RWindowGroup* aWindow); - void AddExpectedErrorMessage(TWsErrorMessage::TErrorCategory aCategory, TInt aError); - void CalculatePointerEvent(TWsEvent& aEvent,TPointerEvent::TType aType, TPoint aPos); - void CalculatePointerCaptureEvent(TWsEvent& aEvent,TPointerEvent::TType aType, TPoint aPos, TInt aHandle=0); - void AddExpectedPointer(TPointerEvent::TType aType, TPoint aPos); - void AddExpectedPointerCapture(TPointerEvent::TType aType, TPoint aPos, TInt aHandle=0); - void AddExpectedPointerClick(TPointerEvent::TType aType, TPoint aPos); - void AddExpectedPointerDownUp(TPoint aPos); - inline void AddExpectedPointerScr(TPointerEvent::TType aType, TPoint aPos); - inline void AddExpectedPointerDownUpScr(TPoint aPos); - void AddExpectedModifiersChanged(TInt aChangedModifiers, TInt aModifiers); - void AddExpectedEnterExit(TInt aEventCode, TPoint aPos); - void AddExpectedKeyAnim(TRawEvent::TType aEventCode, TInt aScanCode,TBool aEat); - void AddExpectedPointerAnim(TRawEvent::TType aEventCode, TPoint aPoint, TBool aEat=ETrue); - void AddExpectedVisibilityChange(TUint aFlags); - void AddExpectedVisibilityChange(TUint aFlags, CTBlankWindow* aWindow); - inline void SimulatePointerWin(TRawEvent::TType aType, TInt aX, TInt aY); - inline void SimulatePointerDownUpWin(TInt aX, TInt aY); - inline void SimulatePointer(TRawEvent::TType aType, TInt aX, TInt aY); - void doSendEvent(TWsEvent &aEvent); - void SendKey(TInt aEventCode, TInt aScanCode, TInt aCode=0, TInt iRepeats=0); - void SendEvent(TInt aEventCode); - void CreateEventTestGroup(); - void CloseEventTestGroup(); - void CreateAndCloseEventTestGroup(); - void TriggerOomMessage(TTimeIntervalMinutes aPeriod); - TBool SetClickType(TClickOutputModes aType); - CTBlankWindow* NewBlueForgroundWindowL(); - CTBlankWindow* NewBlueForgroundWindow(); - TInt KeyRepeatTime() const; - void EventQueuePtrCrashTest(); - TInt ClickCommandReply(TInt aCommand,TInt aData); - TInt CreateGroupWindow(RWindowGroup& aWinGp,TClients aClient,TInt& aWinGpId); - void CloseGroupWindow(RWindowGroup& aWinGp,TInt aWinGpId); - void CloseWindow(RWindowBase& aWin,TInt aHandle,TInt aWinGpId); - void EventQueueExpansionTestL(); - void RawEventRepeatTest_NextSetOfEventsL(); - void SimulateRepeatEvent(TInt aScanCode, TInt aRepeats=0); -#if !defined(TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA) - void SimulateButton1DownWithSimulatedMove(TInt aX, TInt aY); -#endif - void TestCaptureAndCancelCapturePair(TCaptureKeyApis aCaptureApi, TCancelCaptureKeyApis aCancelCaptureApi); - static TInt GenerateAnEvent(TAny* aEventTest); -private: - CTBlankWindow* iBlankWin; - RBlankWindow iBackingWindow; - TSize iPhysicalScreenSize; - TSize iWinSize; - RWindowGroup iEventTestGroup; - CTWindowGroup *iEventTestGroup2; - CTWindowGroup *iEventTestGroup3; - CTWindowGroup *iEventTestGroup4; - TInt iEventSet; - CTQueueClient *iQueueClient; - TBool iFailed; - REventAnim* iAnim; - TUint iScreenModeTests; //currently contains supported rotation and if screen scaling is possible - TInt iNumScrModes; - RSoundPlugIn iClick; - TBool iAddToClick; - TInt iCaptureKey; - TBool iTurnBackOnCapsLock; - TInt iCurrentMode; - TSizeMode iSizeMode; - TBool iTheClientFlush; - TBool iQuequeClientFlush; - CTBlankWindow* iVisWins1; - CTBlankWindow* iVisWins2; - CTBlankWindow* iVisWins3; - CTransWindow* iTransWin; - RAnimDll* iAnimDll; - RPointerArray* iRemovableAnims; - TBool iIs3DPointer; - TBool iPtrPluginLoaded; - TInt iYOffset; -#ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS -#ifndef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - TSurfaceId iSurfaceId; - RSurfaceManager iSurfaceManager; - CPeriodic* iTimeOutCallback; -#endif // TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA -#endif // SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS - }; - -class CTQueueWindowGroup : public CTWindowGroup - { -public: - CTQueueWindowGroup(CTClient *aClient); - void ConstructL(); -private: - TInt iNumOnEvents; - }; - -class CTEventTestStep : public CTGraphicsStep - { -public: - CTEventTestStep(); -protected: - //from CTGraphicsStep - virtual CTGraphicsBase* CreateTestL(); - }; - -_LIT(KTEventTestStep,"TEventTest"); - - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TEvent.CPP --- a/windowing/windowserver/tauto/TEvent.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,7027 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Test window server events -// -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef __INIPARSER_H__ -#define __INIPARSER_H__ -#endif // __INIPARSER_H__ - -#include "PARSEINIDATA.H" -#include "TEVENT.H" -#include "W32CLICK.H" -#include -#include - -#define FAIL_LOGGING on -//#define DETAILED -#define LOGGING 1 //Uncomment this when there is a fail so that you get more logging - -_LIT(KKeyClickPluginDll, "click.dll"); - -CTQueueClient::CTQueueClient(CTEventTest *aTest) : iTest(aTest) - { - } - -CTQueueClient::~CTQueueClient() - { - CloseEventTestGroupOnSecondScreen(); - iGroup->GroupWin()->EnableReceiptOfFocus(EFalse); - delete iChildWin; - delete iWin; - - } - -void CTQueueClient::ConstructL(TBool aCreateChild) - { - CTClient::ConstructL(); - iGroup=new(ELeave) CTQueueWindowGroup(this); - iGroup->ConstructL(); - iWin=new(ELeave) CTBackedUpWin(EGray4); - iWin->ConstructExtLD(*iGroup,TPoint(EWinPositionX,EWinPositionY),TSize(EWinWidth,EWinHeight)); - iWin->Activate(); - if (aCreateChild) - { - iChildWin=new(ELeave) CTBackedUpWin(EGray4); - iChildWin->ConstructExtLD(*iWin,ChildTopLeft(),ChildSize()); - iChildWin->Activate(); - } - iWs.Flush(); - } - -void CTQueueClient::ConstructEventHandlerL() - { - iEventHandler=new(ELeave) CTQueueTestEvent(&iWs, iTest); - ((CTQueueTestEvent *)iEventHandler)->ConstructL(); - } - -TInt CTQueueClient::WindowGroupIdentifier() - { - return(iGroup->GroupWin()->Identifier()); - } - -CTWinBase* CTQueueClient::GetHandle(TPoint& aPos) - { - if (iCapturing) - return iChildWin; - if (iChildWin && TRect(ChildTopLeft(),ChildSize()).Contains(aPos)) - //if (iChildWin && TRect(TPoint(),ChildSize()).Contains(aPos)) - { - aPos-=ChildTopLeft(); - if (iChildCapturing) - iCapturing=ETrue; - return iChildWin; - } - return iWin; - } - -void CTQueueClient::AddExpectedEvent(TWsEvent &aEvent) - { -#if defined(DETAILED) - _LIT(KLog," Adding Event Type=%d"); - TLogMessageText buf; - buf.Format(KLog,aEvent.Type()); - LogMessage(buf); -#endif - ((CTQueueTestEvent *)iEventHandler)->AddExpectedEvent(aEvent); - } - -void CTQueueClient::SetChildCapture(TInt aCaptureFlags) - { - if (!iChildWin) - return; - iChildWin->BaseWin()->SetPointerCapture(aCaptureFlags); - if (aCaptureFlags|RWindowBase::TCaptureFlagEnabled) - iChildCapturing=ETrue; - } -// - -CTQueueTestEvent::CTQueueTestEvent(RWsSession *aWs, CTEventTest *aTest) : CTEvent(aWs) - { - iTest = aTest; - iCheckTimeStamp = EFalse; - iLastEventError = EFalse; - } - -void CTQueueTestEvent::ConstructL() - { - CTEventBase::Construct(); - iEventBuffer.SetLengthL(EEventBufferSize); - iRedrawType=iTest->TestBase()->RedrawStoreTypeL(); - } - -void CTQueueTestEvent::TestL(TInt aTest) - { - if (!aTest) - { - iTest->Failed(); - User::Leave(ETestFailed); - } - } - -//#define FAIL_LOGGING yes -void CTQueueTestEvent::doRunL() - { - TWsEvent wsEvent; - iWs->GetEvent(wsEvent); - TWsEvent expectedEvent; - -#if defined(FAIL_LOGGING) - TInt eType,wsHan,eHan,wsKeyCode,eKeyCode,wsKeyRepeat,eKeyRepeat,wsKeyScan,eKeyScan; - TLogMessageText buf; - _LIT(KStartString,"AUTO EventTestFail "); -#endif - TInt wsType=wsEvent.Type(); - if (wsEvent.Type()==EEventNull) - TestL(wsEvent.Handle()==0); - else - { - TInt count=iEventBuffer.Count(); - if (count==0 && wsType==EEventFocusGained) - goto End; - if (iLastEventError - && (iRedrawType==EPartialRedraw_FullRedrawSupport || iRedrawType==EPartialRedraw_PreserveStoredCmds) - && wsEvent.Type()==EEventErrorMessage /*&& expectedEvent.Type()!=EEventErrorMessage*/) //Should really check if the next expected event is an error but there is no way to do this without removing it from the buffer - { - #if defined(DETAILED) - _LIT(KLog,"Skip Duplicate Error Message"); - iTest->LOG_MESSAGE(KLog); - #endif - return; //Ignore repeated error events - } - do { - TestL(iEventBuffer.Remove(&expectedEvent)); //Loop needed for REL Build with DEB WSERV and W32 - #if defined(DETAILED) - _LIT(KLog,"Skip event while waiting for error message"); - if (expectedEvent.Type()==EEventErrorMessage && wsEvent.Type()!=expectedEvent.Type()) - iTest->LOG_MESSAGE(KLog); - #endif - } while (expectedEvent.Type()==EEventErrorMessage && wsEvent.Type()!=expectedEvent.Type()); - ++iEventCount; //iEventSet - #if defined(FAIL_LOGGING) - wsType=wsEvent.Type(),eType=expectedEvent.Type(),wsHan=wsEvent.Handle(),eHan=expectedEvent.Handle(); - if (wsType!=eType) - { - _LIT(KEventDiff,"Count=%d Events Differ Exp=%d Act=%d"); - buf.Copy(KStartString); - buf.AppendFormat(KEventDiff,iEventCount,eType,wsType); - iTest->LOG_MESSAGE(buf); - } - else - { - #if defined(DETAILED) - _LIT(KLog," Count=%d Event Type=%d"); - iTest->LOG_MESSAGE3(KLog,iEventCount,wsType); - #endif - } - if (wsHan!=eHan) - { - _LIT(KHandlesDiff,"Count=%d Handles Differ"); - buf.Copy(KStartString); - buf.AppendFormat(KHandlesDiff,iEventCount); - iTest->LOG_MESSAGE(buf); - } - #endif - TestL(wsEvent.Type()==expectedEvent.Type() && wsEvent.Handle()==expectedEvent.Handle()); - } - iLastEventError=(wsEvent.Type()==EEventErrorMessage); - switch(wsEvent.Type()) - { - case EEventKey: - #if defined(FAIL_LOGGING) - wsKeyCode=wsEvent.Key()->iCode,eKeyCode=expectedEvent.Key()->iCode; - if (wsKeyCode!=eKeyCode) - { - _LIT(KKeysDiff,"Count=%d Key Code Exp=%d (%c) Act=%d (%c)"); - buf.Copy(KStartString); - buf.AppendFormat(KKeysDiff,iEventCount,iEventCount,eKeyCode,eKeyCode,wsKeyCode,wsKeyCode); - iTest->LOG_MESSAGE(buf); - } - wsKeyRepeat=wsEvent.Key()->iRepeats,eKeyRepeat=expectedEvent.Key()->iRepeats; - if ((wsKeyRepeat>0)!=(eKeyRepeat>0) || wsKeyRepeatLOG_MESSAGE(buf); - } - #endif - TestL(wsEvent.Key()->iCode==expectedEvent.Key()->iCode && wsEvent.Key()->iRepeats>=expectedEvent.Key()->iRepeats - && (wsEvent.Key()->iRepeats>0)==(expectedEvent.Key()->iRepeats>0)); //Fall Through - case EEventKeyDown: - case EEventKeyUp: - #if defined(FAIL_LOGGING) - wsKeyScan=wsEvent.Key()->iScanCode,eKeyScan=expectedEvent.Key()->iScanCode; - if (wsKeyScan!=eKeyScan) - { - _LIT(KScanDiff,"Count=%d Scan Code Exp=%d (%c) Act=%d (%c)"); - buf.Copy(KStartString); - buf.AppendFormat(KScanDiff,iEventCount,eKeyScan,eKeyScan,wsKeyScan,wsKeyScan); - iTest->LOG_MESSAGE(buf); - } - #endif - TestL(wsEvent.Key()->iScanCode==expectedEvent.Key()->iScanCode); - break; - case EEventModifiersChanged: - { - TBool changeModifiersOK=(wsEvent.ModifiersChanged()->iChangedModifiers - ==expectedEvent.ModifiersChanged()->iChangedModifiers); - TBool modifiersOK=((wsEvent.ModifiersChanged()->iModifiers&wsEvent.ModifiersChanged()->iChangedModifiers)== - (expectedEvent.ModifiersChanged()->iModifiers&wsEvent.ModifiersChanged()->iChangedModifiers)); - #if defined(FAIL_LOGGING) - if (!changeModifiersOK || !modifiersOK) - { - _LIT(KModDiff,"Count=%d Modifiers"); - buf.Copy(KStartString); - buf.AppendFormat(KModDiff,iEventCount); - iTest->LOG_MESSAGE(buf); - } - #endif - TestL(changeModifiersOK); - TestL(modifiersOK); - } - break; - case EEventPointer: - case EEventDragDrop: - { - #if defined(FAIL_LOGGING) - TInt expectedType=expectedEvent.Pointer()->iType, actualType=wsEvent.Pointer()->iType; - TPoint expectedPos=expectedEvent.Pointer()->iPosition, actualPos=wsEvent.Pointer()->iPosition; - if (actualType!=expectedType) - { - _LIT(KPointerDiff,"Count=%d Pointer Type Exp=%d Act=%d"); - buf.Copy(KStartString); - buf.AppendFormat(KPointerDiff,iEventCount,expectedType,actualType); - iTest->LOG_MESSAGE(buf); - } - if (actualPos!=expectedPos) - { - _LIT(KPointerPosDiff,"Count=%d Pointer Pos E=(%d,%d) A=(%d,%d)"); - buf.Copy(KStartString); - buf.AppendFormat(KPointerPosDiff,iEventCount,expectedPos.iX,expectedPos.iY - ,actualPos.iX,actualPos.iY); - iTest->LOG_MESSAGE(buf); - } - #endif - TestL(wsEvent.Pointer()->iType==expectedEvent.Pointer()->iType); - TestL(wsEvent.Pointer()->iPosition==expectedEvent.Pointer()->iPosition); - TInt count=iEventBuffer.Count();count++; //Dummy line to help in debugging. - } - break; - case EEventWindowVisibilityChanged: - { - #if defined(FAIL_LOGGING) - TUint expectedFlags=expectedEvent.VisibilityChanged()->iFlags; - TUint actualFlags=wsEvent.VisibilityChanged()->iFlags; - if (actualFlags!=expectedFlags) - { - _LIT(KVisibilityDiff,"Count=%d Visibility Flags Exp=%d Act=%d"); - buf.Copy(KStartString); - buf.AppendFormat(KVisibilityDiff,iEventCount,expectedFlags,actualFlags); - iTest->LOG_MESSAGE(buf); - } - #endif - TestL(wsEvent.VisibilityChanged()->iFlags==expectedEvent.VisibilityChanged()->iFlags); - TInt count=iEventBuffer.Count();count++; //Dummy line to help in debugging. - } - break; - case EEventMessageReady: - { - const SEventMessageReady message = *(SEventMessageReady*)wsEvent.EventData(); - TestL(message.iMessageUid== TUid::Uid(123)); - } - break; - default:; - } - if(iCheckTimeStamp) - { - const TInt KOffset=100000; //0.1secs - TInt64 offset = expectedEvent.Time().Int64() - wsEvent.Time().Int64(); - #if defined(FAIL_LOGGING) - if(Abs(offset)LOG_MESSAGE(buf); - } - #endif - TestL(Abs(offset)NextSetOfEventsL()); //Not allowed to leave - if(err != KErrNone) - { - buf.Copy(KStartString); - buf.AppendFormat(_L("Subtest does not follow rules set by TEvent test framework, leave code: %d"), err); - iTest->TEST(EFalse); - iTest->LOG_MESSAGE(buf); - User::Leave(err); - } - } - - } - -void CTQueueTestEvent::AddExpectedEvent(TWsEvent &aEvent) - { - if(iCheckTimeStamp) - { - static_cast(aEvent).Time().UniversalTime(); - } - iEventBuffer.Add(&aEvent); - } - -TInt CTQueueTestEvent::EventsLeft() - { - return iEventBuffer.Count(); - } -// - -CTQueueWindowGroup::CTQueueWindowGroup(CTClient *aClient) : CTWindowGroup(aClient) - {} - -void CTQueueWindowGroup::ConstructL() - { - CTWindowGroup::ConstructL(); - User::LeaveIfError(iGroupWin.EnableOnEvents(EEventControlAlways)); - User::LeaveIfError(iGroupWin.EnableGroupChangeEvents()); - } - -// - -/** - Closes and deletes anim DLL. - @param aAnimDll Pointer to the anim Dll to be closed and deleted - */ -LOCAL_C void DestroyAnimDll(TAny* aAnimDll) - { - (static_cast(aAnimDll))->Destroy(); - } - -/** - Destroys an REventAnimBase derived anim - @param aAnim REventAnimBase derived client-side handle to anim - */ -LOCAL_C void DestroyAnim(TAny* aAnim) - { - (static_cast(aAnim))->Destroy(); - } - -/** - Loads the DLL containing the test anims and pushes it onto the cleanup stack. - This function leaves if the operation was unsuccessful. - @return A pointer to the DLL containing test anims - */ -RAnimDll* REventAnimBase::LoadL() - { - RAnimDll* animDll=new(ELeave) RAnimDll(TheClient->iWs); - CleanupStack::PushL(TCleanupItem(DestroyAnimDll,animDll)); - User::LeaveIfError(animDll->Load(KAnimDLLName)); - CleanupStack::Pop(animDll); - return animDll; - } - -/** - Closes the client-side handle to the anim, destroys the DLL and deletes itself. - */ -void REventAnimBase::Destroy() - { - Close(); - delete this; - } - -/** - Resets server-side state of anim - */ -void REventAnimBase::Reset() - { - CommandReply(EADllReset); - } - -/** - @return Under non-error conditions, returns 0. - Under error conditions, returns the number of events received - since the first unexpected event was sent. - */ -TInt REventAnimBase::ErrorCode() - { - return CommandReply(EADllErrorCode); - } - -/** - @return The number of events received by the anim since it was last reset. - */ -TInt REventAnimBase::NumberOfEventsReceived() - { - return CommandReply(EADllNumberOfEventsReceived); - } - -/** - Adds an expected event to the list of events expected by the anim. - @param aEat Indicates if event is expected to be eaten (ETrue 'indicates expected to be eaten') - @param aEvent The expected event - @return KErrNone if succcessful, othewise error code. - */ -TInt REventAnimBase::AddExpectedEvent(TBool aEat, const TRawEvent& aEvent) - { - TAnimRawEvent event; - event.iRawEvent=aEvent; - event.iEat=aEat; - return AddExpectedEvent(event); - } - -/** - Adds an expected event to the list of events expected by the anim. - @param aEvent The expected event - @return KErrNone if succcessful, othewise error code. - */ -TInt REventAnimBase::AddExpectedEvent(const TAnimRawEvent& aEvent) - { - TPckgBuf param; - param()=aEvent; - return CommandReply(EADllAddExpectedEvent,param); - } - -// - -/** - Loads the DLL containing the event test anim and creates an anim for event tests - @param aWin the base window to which the anim is associated (this anim is a Window anim) - @return A pointer to the new REventAnim - */ -REventAnim* REventAnim::NewL(RWindowBase* aWin, RAnimDll* aDll, REventAnimBase::EAnimationType aType/*=EEventAnim*/) - { - REventAnim* self=new(ELeave) REventAnim(aDll); - CleanupStack::PushL(TCleanupItem(DestroyAnim,self)); - User::LeaveIfError(self->Construct(*aWin,(aType == EEventAnim ? EAnimTypeEventTest : EAnimTypeEventPostingTest), TPtrC8())); - CleanupStack::Pop(self); - return self; - } - -/** - Checks if the anim has received the correct events, and resets the sever-side state of the anim - @return positive value if events did not match expected showing the first event that didn't match. - negative value if there were the wrong number of events showing the number of events there were - 0 if correct number of events and they all match - */ -TInt REventAnim::TestFail(TInt aNoEvents) - { - TInt events=CommandReply(EADllErrorCode); - if (events>0) - return events; - events=CommandReply(EADllNoEventsAndReset); - if (events==aNoEvents) - return 0; - return -events; - } - -// -/** - Loads the DLL containing the event test anim and creates an anim for event handler removal tests - @param aWin the base window to which the anim is associated (this anim is a Window anim) - @return A pointer to the new REventAnim - */ -RRemovableAnim* RRemovableAnim::NewLC(RWindowBase* aWin, RAnimDll* aDll) - { - RRemovableAnim* self=new(ELeave) RRemovableAnim(aDll); - CleanupStack::PushL(TCleanupItem(DestroyAnim,self)); - User::LeaveIfError(self->Construct(*aWin,EAnimTypeRemovableAnim,TPtrC8())); - return self; - } - -/** - Sets the lifetime of the anim. This anim will remove itself from the - event handler list after receiving this number of events. - @return The lifetime of the anim - */ -TInt RRemovableAnim::SetEventHandlerLifetime(TInt aEventCount) - { - TPckgBuf param; - param()=aEventCount; - return CommandReply(EADllSetEventHandlerLifetime, param); - } - -/** - Retrieves the lifetime of the anim. This anim will remove itself from the - event handler list after receiving this number of events. - @return The lifetime of the anim - */ -TInt RRemovableAnim::EventHandlerLifetime() - { - return CommandReply(EADllEventHandlerLifetime); - } -/** - Adds the anim to the list of event handlers. - This anim should receive any subsequent events. - @return KErrNone on successful addition. - */ -TInt RRemovableAnim::AddToEventHandlers() - { - return CommandReply(EADllAddToEventHandlers); - } - -/** - Removes the anim from the list of event handlers. - This anim should not receive any subsequent events. - @return KErrNone on successful removal. - */ -TInt RRemovableAnim::RemoveFromEventHandlers() - { - return CommandReply(EADllRemoveFromEventHandlers); - } - -/** - Tests if the anim has received the correct number of events, and that - the events received are all the correct events. - @param aNoEvents The total expected number of events since it was last reset/constructed. - @return ETrue if the anim has received the expected events. - */ -TBool RRemovableAnim::TestPassed() - { - return CommandReply(EADllTestPassed); - } - -// - -CTEventTest::CTEventTest(CTestStep* aStep) : CTWsGraphicsBase(aStep) - { - INFO_PRINTF1(_L("Testing Event functions")); - } - -CTEventTest::~CTEventTest() - { - delete iBlankWin; - iBackingWindow.Close(); - delete iVisWins1; - delete iVisWins2; - delete iVisWins3; - delete iTransWin; - delete iQueueClient; - if (iAnim) - iAnim->Destroy(); - delete iEventTestGroup2; //Just in case it doesn't get deleted normally - delete iEventTestGroup3; //Just in case it doesn't get deleted normally - delete iEventTestGroup4; //Just in case it doesn't get deleted normally - if (iPtrPluginLoaded) - { - iClick.Unload(); - } - iClick.Close(); - if (iTurnBackOnCapsLock) - { - TheClient->iWs.SetModifierState(EModifierCapsLock,ETurnOnModifier); - } - if (iRemovableAnims) - { - EventHandlerRemoval_DestroyAllAnims(); - iRemovableAnims->Close(); - delete iRemovableAnims; - } - if (iAnimDll) - { - iAnimDll->Destroy(); - } -#ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS -#ifndef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - if (!iSurfaceId.IsNull()) - { - iSurfaceManager.CloseSurface(iSurfaceId); - } - iSurfaceManager.Close(); - if(iTimeOutCallback) - { - iTimeOutCallback->Cancel(); - delete iTimeOutCallback; - } -#endif // TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA -#endif // SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS - } - -void CTEventTest::ConstructL() - { - _LIT(KWsIniFile, "z:\\system\\data\\wsini.ini"); - CIniData* iniData = CIniData::NewL(KWsIniFile, ' '); - _LIT( KWsiniYShifting, "YSHIFTING"); - iniData->FindVar(KWsiniYShifting, iYOffset); - delete iniData; - TheClient->iScreen->SetAppScreenMode(0); - TheClient->iScreen->SetScreenMode(0); // in mode 0 TheClient->iScreen->SizeInPixels() - iPhysicalScreenSize = TheClient->iScreen->SizeInPixels(); // is equal to physical screen size - BaseWin->Invalidate(); - BaseWin->Win()->BeginRedraw(); - TheGc->Activate(*BaseWin->Win()); - TheGc->SetBrushColor(TRgb::Gray16(12)); - TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - TheGc->SetPenStyle(CGraphicsContext::ENullPen); - TheGc->DrawRect(TRect(BaseWin->Win()->Size())); - TheGc->Deactivate(); - BaseWin->Win()->EndRedraw(); - TheGc->Activate(*TestWin->Win()); - TheGc->SetBrushColor(TRgb::Gray16(4)); - TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - TheGc->SetPenStyle(CGraphicsContext::ENullPen); - TheGc->DrawRect(TRect(TestWin->Win()->Size())); - TheGc->Deactivate(); - iBackingWindow=RBlankWindow(TheClient->iWs); - iBackingWindow.Construct(*TheClient->iGroup->WinTreeNode(),ENullWsHandle); - iBackingWindow.SetColor(TRgb(0,0xDD,0xDD)); - iBackingWindow.SetOrdinalPosition(-1,-25); - iBackingWindow.Activate(); - iBlankWin=new(ELeave) CTBlankWindow(); - iBlankWin->ConstructL(*TheClient->iGroup); - User::LeaveIfError(iBlankWin->BaseWin()->SetRequiredDisplayMode(EColor256)); - iBlankWin->SetExt(TPoint(),iPhysicalScreenSize); - iBlankWin->SetVisible(EFalse); - iBlankWin->Activate(); - CArrayFixFlat *rotations=new(ELeave) CArrayFixFlat(1); - iNumScrModes=TheClient->iScreen->NumScreenModes(); - TInt modes=Min(2,iNumScrModes); - TInt mode; - TInt rot; - CleanupStack::PushL(rotations); - for (mode=0;modeiScreen->GetRotationsList(mode,rotations)); - for (rot=rotations->Count()-1;rot>=0;--rot) - { - iScreenModeTests|=(1<<(*rotations)[rot]); - } - } - if (CheckScalingSupportedOrNot()) - iScreenModeTests|=EDoScale; - - iClick=RSoundPlugIn(TheClient->iWs); - User::LeaveIfError(iClick.Construct(TUid::Uid(CLICK_THIRD_UID))); - TBool ptrPluginLoadable = EFalse; - iClick.IsLoaded(ptrPluginLoadable); - if (ptrPluginLoadable) - { - User::LeaveIfError(iClick.Load(KKeyClickPluginDll)); - iPtrPluginLoaded = ETrue; - } - CleanupStack::PopAndDestroy(); - if (TheClient->iWs.GetModifierState()&EModifierCapsLock) - { - iTurnBackOnCapsLock=ETrue; - TheClient->iWs.SetModifierState(EModifierCapsLock,ETurnOffModifier); - } - iAnimDll = REventAnimBase::LoadL(); - TInt mods=TheClient->iWs.GetModifierState(); - if (mods&EModifierCapsLock) - iTest->SimulateKeyDownUp(EStdKeyCapsLock); - if (mods&EModifierNumLock) - iTest->SimulateKeyDownUp(EStdKeyNumLock); - //Make sure all the keys we test are in the up state - iTest->SimulateKeyDownUp(EStdKeyLeftShift); - iTest->SimulateKeyDownUp(EStdKeyRightShift); - iTest->SimulateKeyDownUp(EStdKeyLeftFunc); - iTest->SimulateKeyDownUp(EStdKeyLeftCtrl); - iTest->SimulateKeyDownUp(EStdKeyRightCtrl); - mods=TheClient->iWs.GetModifierState(); - _LIT(KLog,"Initial Modifiers state 0x%x (ideally should be zero)"); - LOG_MESSAGE2(KLog,mods); - iTest->DelayIfFullRomL(); - -#if !defined(TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA) - // 2d or 3d pointer? - if(HAL::Get(HALData::EPointer3D,iIs3DPointer)!=KErrNone) - { - iIs3DPointer=EFalse; - } -#endif - } - -void CTEventTest::Failed() - { -#ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS -#ifndef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - if(iTimeOutCallback) - { - iTimeOutCallback->Cancel(); - iTimeOutCallback->Deque(); - delete iTimeOutCallback; - iTimeOutCallback = NULL; - } - TEST(EFalse); -#endif // TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA -#endif // SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS - CActiveScheduler::Stop(); - iFailed=ETrue; - } - -void CTEventTest::CheckTimeInterval(const TTimeIntervalMicroSeconds32 &aTime,TInt aCheckTime) - { - TEST(aTime.Int()==aCheckTime); - if (aTime.Int()!=aCheckTime) - INFO_PRINTF3(_L("aTime.Int()==aCheckTime - Expected: %d, Actual: %d"), aCheckTime, aTime.Int()); - } - -void CTEventTest::KeyRepeatRate(TInt aInitialRepeat, TInt aRepeat) - { - TheClient->iWs.SetKeyboardRepeatRate(TTimeIntervalMicroSeconds32(aInitialRepeat), TTimeIntervalMicroSeconds32(aRepeat)); - TTimeIntervalMicroSeconds32 initialTime; - TTimeIntervalMicroSeconds32 time; - TheClient->iWs.GetKeyboardRepeatRate(initialTime,time); - CheckTimeInterval(initialTime,aInitialRepeat); - CheckTimeInterval(time,aRepeat); - } - -void CTEventTest::DoubleClickSettings(TInt aInterval, TInt aDistance) - { - TheClient->iWs.SetDoubleClick(TTimeIntervalMicroSeconds32(aInterval), aDistance); - TTimeIntervalMicroSeconds32 interval; - TInt distance; - TheClient->iWs.GetDoubleClickSettings(interval, distance); - CheckTimeInterval(interval,aInterval); - TEST(aDistance==distance); - if (aDistance!=distance) - INFO_PRINTF3(_L("aDistance==distance - Expected: %d, Actual: %d"), distance, aDistance); - } - -TInt EventCancelFunc(TAny* aClient) - { - TWsQTEvent event; - event.SetType(EEventModifiersChanged); - ((TModifiersChangedEvent *)event.EventData())->iChangedModifiers=0; - ((TModifiersChangedEvent *)event.EventData())->iModifiers=0; - TheClient->iWs.SendEventToWindowGroup(TheClient->iGroup->GroupWin()->Identifier(),event); -// - TRequestStatus status; - ((CTClient *)aClient)->iWs.EventReady(&status); - ((CTClient *)aClient)->iWs.EventReadyCancel(); - User::WaitForRequest(status); - return(KErrNone); - } - -void CTEventTest::General() - { - TWsQTEvent event; - event.SetType(EEventModifiersChanged); - ((TModifiersChangedEvent *)event.EventData())->iChangedModifiers=0; - ((TModifiersChangedEvent *)event.EventData())->iModifiers=0; - TheClient->iWs.SendEventToWindowGroup(TheClient->iGroup->GroupWin()->Identifier(),event); - TCallBack callBack(EventCancelFunc,TheClient); - TheClient->SetCancelFunction(callBack); -// - TTimeIntervalMicroSeconds32 oldInitialTime; - TTimeIntervalMicroSeconds32 oldTime; - TheClient->iWs.GetKeyboardRepeatRate(oldInitialTime,oldTime); -// - KeyRepeatRate(EKeyboardInitialRepeat1, EKeyboardRepeat1); - KeyRepeatRate(EKeyboardInitialRepeat2, EKeyboardRepeat2); - KeyRepeatRate(EKeyboardInitialRepeat3+200, EKeyboardRepeat3); // Max initial repeat with normal keyboard repeat value - KeyRepeatRate(EKeyboardInitialRepeat3, EKeyboardRepeat7+200); // Max key and initial repeat - KeyRepeatRateNegTest(EKeyboardInitialRepeat4, EKeyboardRepeat4); // -ve initial repeat - KeyRepeatRateNegTest(EKeyboardInitialRepeat2, EKeyboardRepeat6); // -ve keyboard repeat - #if defined __WINS__ || defined __WINSCW__ - KeyRepeatRateNegTest(EKeyboardInitialRepeat3+400, EKeyboardRepeat5); // More than max initial repeat - #endif//defined __WINS__ || defined __WINSCW__ - DoubleClickSettings(EDoubleClickTime1,EDoubleClickGap1); - DoubleClickSettings(EDoubleClickTime2,EDoubleClickGap2); - TheClient->iWs.SetKeyboardRepeatRate(oldInitialTime,oldTime); -// - } - -#define UNIQUE_PRIORITY 123 -void CTEventTest::General2() - { - RWindowGroup& group=*TheClient->iGroup->GroupWin(); - TInt priority=group.OrdinalPriority(); - TInt position=group.OrdinalPosition(); - TInt priorityGain=TheClient->iWs.GetWindowGroupOrdinalPriority(group.Identifier())-priority; - group.SetOrdinalPosition(0,UNIQUE_PRIORITY); - TWsQTEvent event; - event.SetType(EEventModifiersChanged); - ((TModifiersChangedEvent *)event.EventData())->iChangedModifiers=0; - ((TModifiersChangedEvent *)event.EventData())->iModifiers=0; - TheClient->iWs.SendEventToAllWindowGroups(UNIQUE_PRIORITY+priorityGain,event); - TCallBack callBack(EventCancelFunc,TheClient); - TheClient->SetCancelFunction(callBack); - group.SetOrdinalPosition(position,priority); - } - -void CTEventTest::AddExpectedKey(TInt aEventCode, TInt aScanCode, TInt aCode/*=0*/, TInt aRepeats/*=0*/, TUint aModifiers/*=0*/) - { - TPckgBuf evtPkg; - TWsEvent& event=evtPkg(); - if (aEventCode==EEventKey && aCode==0) - aCode=aScanCode; - event.SetType(aEventCode); - event.SetHandle((TInt)iQueueClient->iGroup); - event.Key()->iCode=aCode; - event.Key()->iScanCode=aScanCode; - event.Key()->iModifiers=aModifiers; - event.Key()->iRepeats=aRepeats; - iQueueClient->AddExpectedEvent(event); - if (iAddToClick) - iClick.CommandReply(EClickEventAdd,evtPkg); - } - -void CTEventTest::AddExpectedKeyDownUp(TInt aScanCode, TInt aCode/*=0*/, TInt aRepeats/*=0*/, TUint aModifiers/*=0*/) - { - __ASSERT_DEBUG(aScanCode<'a' || aScanCode>'z',AutoPanic(EAutoPanicScanCapital)); - AddExpectedKey(EEventKeyDown,aScanCode,0,aRepeats,aModifiers); - AddExpectedKey(EEventKey,aScanCode,aCode,aRepeats,aModifiers); - AddExpectedKey(EEventKeyUp,aScanCode,0,aRepeats,aModifiers); - } - -void CTEventTest::AddExpectedEvent(TInt aEventCode, CTWinBase* aWin) - { - TWsQTEvent event; - event.iType=aEventCode; - event.iHandle=REINTERPRET_CAST(TInt,aWin); - iQueueClient->AddExpectedEvent(event); - } - -void CTEventTest::AddExpectedEvent(TInt aEventCode, RWindowGroup* aWindow) - { - TWsQTEvent event; - event.iType=aEventCode; - event.iHandle=(TUint32)aWindow; - iQueueClient->AddExpectedEvent(event); - } - -void CTEventTest::AddExpectedEvent(TInt aEventCode) - { - AddExpectedEvent(aEventCode,iQueueClient->iGroup); - } - -void CTEventTest::AddExpectedErrorMessage(TWsErrorMessage::TErrorCategory aCategory, TInt aError) - { - TWsQTEvent event; - event.iType=EEventErrorMessage; - event.iHandle=(TInt)iQueueClient->iGroup; - event.ErrorMessage()->iErrorCategory=aCategory; - event.ErrorMessage()->iError=aError; - iQueueClient->AddExpectedEvent(event); - } - -void CTEventTest::CalculatePointerEvent(TWsEvent& aEvent,TPointerEvent::TType aType, TPoint aPos) - { -#if !defined(TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA) - TAdvancedPointerEvent& ptrEvent=*aEvent.Pointer(); - aEvent.SetType(EEventPointer); - ptrEvent.iParentPosition=aPos; - // SetHandle must be done after iParentPosition is set, but before iPosition is set. - aEvent.SetHandle(reinterpret_cast(iQueueClient->GetHandle(aPos))); - const TPoint3D point3D(aPos.iX, aPos.iY, 0); - const TInt pointerEventModifiers=0; - const TUint8 pointerNumber=0; - aEvent.InitAdvancedPointerEvent(aType,pointerEventModifiers,point3D,pointerNumber); -#else - TPointerEvent& ptrEvent=*aEvent.Pointer(); - aEvent.SetType(EEventPointer); - ptrEvent.iParentPosition=aPos; //Must be done before next line - aEvent.SetHandle(REINTERPRET_CAST(TInt,iQueueClient->GetHandle(aPos))); - ptrEvent.iType=aType; - ptrEvent.iModifiers=0; - ptrEvent.iPosition=aPos; -#endif - } - -void CTEventTest::CalculatePointerCaptureEvent(TWsEvent& aEvent, TPointerEvent::TType aType, TPoint aPos, TInt aHandle) - { - TPointerEvent& ptrEvent=*aEvent.Pointer(); - aEvent.SetType(EEventPointer); - ptrEvent.iParentPosition=aPos; //Must be done before next line - if(iVisWins1 && iVisWins2) - { - if (TRect(iQueueClient->ChildTopLeft(),iQueueClient->ChildSize()).Contains(aPos) && - !TRect(iQueueClient->ChildTopLeft()+TPoint(15,15),iQueueClient->ChildSize()).Contains(aPos)) - { - aPos-=iQueueClient->ChildTopLeft(); //Pointer is on the first window - aEvent.SetHandle((TInt)iVisWins1); - } - else if (TRect(iQueueClient->ChildTopLeft()+TPoint(15,15),iQueueClient->ChildSize()).Contains(aPos)) - { - aPos-=(iQueueClient->ChildTopLeft()+TPoint(15,15)); //Pointer is on the second window - aEvent.SetHandle((TInt)iVisWins2); - } - else if (TRect(TPoint(EWinPositionX,EWinPositionY),TSize(EWinWidth,EWinHeight)).Contains(aPos)) - { - aPos-=TPoint(EWinPositionX,EWinPositionY); //Pointer is on the parent window - aEvent.SetHandle((TInt)iQueueClient->iWin); - } - else - { - aEvent.SetHandle((TInt)0); //Pointer is not in the same window group - } - } - ptrEvent.iType=aType; - ptrEvent.iModifiers=0; - if(aHandle!=0 && aHandle!=aEvent.Handle()) - { - aEvent.SetHandle(aHandle); - ptrEvent.iPosition=ptrEvent.iParentPosition-(iQueueClient->ChildTopLeft()+TPoint(15,15)); - } - else - { - ptrEvent.iPosition=aPos; - } - } - -void CTEventTest::AddExpectedPointerCapture(TPointerEvent::TType aType, TPoint aPos, TInt aHandle) - { - TPckgBuf evtPkg; - CalculatePointerCaptureEvent(evtPkg(),aType,aPos,aHandle); - iQueueClient->AddExpectedEvent(evtPkg()); - } - -void CTEventTest::AddExpectedPointer(TPointerEvent::TType aType, TPoint aPos) - { - TPckgBuf evtPkg; - CalculatePointerEvent(evtPkg(),aType,aPos); - iQueueClient->AddExpectedEvent(evtPkg()); - if (iAddToClick) - { - evtPkg().Pointer()->iParentPosition+=TPoint(EWinPositionX,EWinPositionY); - iClick.CommandReply(EClickEventAdd,evtPkg); - } - } - -void CTEventTest::AddExpectedPointerClick(TPointerEvent::TType aType, TPoint aPos) - { - TPckgBuf evtPkg; - CalculatePointerEvent(evtPkg(),aType,aPos); - evtPkg().Pointer()->iParentPosition+=TPoint(EWinPositionX,EWinPositionY); - iClick.CommandReply(EClickEventAdd,evtPkg); - } - -void CTEventTest::AddExpectedPointerDownUp(TPoint aPos) - { - AddExpectedPointer(TPointerEvent::EButton1Down,aPos); - AddExpectedPointer(TPointerEvent::EButton1Up,aPos); - } - -void CTEventTest::AddExpectedPointerScr(TPointerEvent::TType aType, TPoint aPos) - { - AddExpectedPointer(aType,TPoint(aPos.iX-EWinPositionX,aPos.iY-EWinPositionY)); - } - -void CTEventTest::AddExpectedPointerDownUpScr(TPoint aPos) - { - AddExpectedPointerDownUp(TPoint(aPos.iX-EWinPositionX,aPos.iY-EWinPositionY)); - } - -void CTEventTest::AddExpectedModifiersChanged(TInt aChangedModifiers, TInt aModifiers) - { - TWsQTEvent event; - event.iType=EEventModifiersChanged; - event.iHandle=(TInt)iQueueClient->iGroup; - event.ModifiersChanged()->iChangedModifiers=aChangedModifiers; - event.ModifiersChanged()->iModifiers=aModifiers; - iQueueClient->AddExpectedEvent(event); - } - -void CTEventTest::AddExpectedEnterExit(TInt aEventCode, TPoint aPos) - { - AddExpectedEvent(aEventCode,iQueueClient->GetHandle(aPos)); - } - -void CTEventTest::AddExpectedKeyAnim(TRawEvent::TType aEventCode, TInt aScanCode, TBool aEat) - { - TAnimRawEvent event; - event.iRawEvent.Set(aEventCode,aScanCode); - event.iEat=aEat; - TInt retVal = iAnim->AddEvent(event); - TEST(retVal==KErrNone); - if (retVal!=KErrNone) - INFO_PRINTF3(_L("iAnim->AddEvent(event) return value - Expected: %d, Actual: %d"), KErrNone, retVal); - - if (!aEat) - AddExpectedKey((aEventCode==TRawEvent::EKeyDown ? EEventKeyDown:EEventKeyUp),aScanCode); - } - -void CTEventTest::AddExpectedPointerAnim(TRawEvent::TType aEventCode, TPoint aPoint, TBool aEat/*=ETrue*/) - { - TAnimRawEvent event; - event.iRawEvent.Set(aEventCode,aPoint.iX,aPoint.iY); - event.iEat=aEat; - - TInt retVal = iAnim->AddEvent(event); - TEST(retVal==KErrNone); - if (retVal!=KErrNone) - INFO_PRINTF3(_L("iAnim->AddEvent(event) return value - Expected: %d, Actual: %d"), KErrNone, retVal); - - if (!aEat) - AddExpectedPointer((aEventCode==TRawEvent::EButton1Down ? TPointerEvent::EButton1Down:TPointerEvent::EButton1Up) - ,aPoint-TPoint(EWinPositionX,EWinPositionY)); - } - -void CTEventTest::AddExpectedVisibilityChange(TUint aFlags) - { - TWsQTEvent event; - event.iType=EEventWindowVisibilityChanged; - event.iHandle=(TInt)iVisWins1; - event.VisibilityChanged()->iFlags=aFlags; - iQueueClient->AddExpectedEvent(event); - } - -void CTEventTest::AddExpectedVisibilityChange(TUint aFlags, CTBlankWindow* aWindow) - { - TWsQTEvent event; - event.iType=EEventWindowVisibilityChanged; - event.iHandle=(TInt)aWindow; - event.VisibilityChanged()->iFlags=aFlags; - iQueueClient->AddExpectedEvent(event); - } - -void CTEventTest::SimulatePointerWin(TRawEvent::TType aType, TInt aX, TInt aY) - { - SimulatePointer(aType,EWinPositionX+aX,EWinPositionY+aY+iYOffset); - } - -void CTEventTest::SimulatePointerDownUpWin(TInt aX, TInt aY) - { - iTest->SimulatePointerDownUp(EWinPositionX+aX,EWinPositionY+aY+iYOffset); - } - -void CTEventTest::SimulatePointer(TRawEvent::TType aType, TInt aX, TInt aY) - { - iTest->SimulatePointer(aType,aX,aY+iYOffset); - } - -#if !defined(TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA) -void CTEventTest::SimulateButton1DownWithSimulatedMove(TInt aX, TInt aY) - { - if(iIs3DPointer) - { - // With advanced pointer events we can have an XYInputType of Pointer coupled with 3DPointer - // which now makes MovesAvailable return ETrue rahter than EFalse, which in turn stops the simulated - // Emove from being generated. - // So... - // If MovesAvailable() returns ETrue, then this move will be used, and the WServ simulated move wont be generated - // If MovesAvailable() returns EFalse, then this move will be filtered out, and the WServ simulated move will be generated - SimulatePointer(TRawEvent::EPointerMove,aX,aY); - } - // then the original button down event - SimulatePointer(TRawEvent::EButton1Down,aX,aY); - } -#endif - -void CTEventTest::NextSetOfEventsL() - { - iQueueClient->ResetCount(iEventSet); - switch (iTest->iState) - { - case 1: - QueuePurge_NextSetOfEventsL(); - break; - case 2: - SendEventTest_NextSetOfEvents(); - break; - case 4: - InvisibleWindow_NextSetOfEvents(); - break; - case 5: - JavaAdditions_NextSetOfEvents(); - break; - case 6: - WinCap_NextSetOfEvents(); - break; - case 7: - XyInputType_NextSetOfEvents(); - break; - case 8: - MovingPointerCursor_NextSetOfEventsL(); - break; - case 9: - RotatedMode_NextSetOfEventsL(); - break; - case 10: - AnimEvent_NextSetOfEventsL(); - break; - case 11: - FocusChanged_NextSetOfEventsL(); - break; - case 12: - StopEvents_NextSetOfEventsL(); - break; - case 13: - VirtualKeyboard_NextSetOfEventsL(); - break; - case 14: - KeyClicks_NextSetOfEvents(); - break; - case 15: - CaptureLong_NextSetOfEventsL(); - break; - case 16: - Password_NextSetOfEvents(); - break; - case 17: - GroupListChanged_NextSetOfEventsL(); - break; - case 18: - RepeatableKeysL(); - break; - case 19: - ScreenScaling_NextSetOfEventsL(); - break; - case 20: - VisibilityChanged_NextSetOfEventsL(); - break; - case 21: - CheckTimeStamp_NextSetOfEventsL(); - break; - case 22: - PointerCapture_NextSetOfEventsL(); - break; - case 23: - EventHandlerRemoval_NextSetOfEventsL(); - break; - // Note that case 24 (which is KTest24) does not use NextSetOfEventsL() - case 25: - MismatchedCapture_NextSetOfEventsL(); - break; - case 26: - PointerBufferPurge_NextSetOfEventsL(); - break; - case 27: - RawEventRepeatTest_NextSetOfEventsL(); - break; - -#ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS -#ifndef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - case 28: - SurfaceVisibilityChanged1_NextSetOfEventsL(); - break; - case 29: - SurfaceVisibilityChanged2_NextSetOfEventsL(); - break; - case 30: - SurfaceVisibilityChanged3_NextSetOfEventsL(); - break; -#endif // TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA -#endif // SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS - - default: - AutoPanic(EAutoPanicWrongTest); - } - } - -void CTEventTest::TriggerOomMessage(TTimeIntervalMinutes aPeriod) - { - TTime time; - if (aPeriod.Int()!=0) // adjust time to affect Oom message triggering - { - time.HomeTime(); - User::SetHomeTime(time+aPeriod); - } - RBlankWindow win(TheClient->iWs); - win.Construct(*(TheClient->iGroup->WinTreeNode()),1); - win.SetColor(TRgb::Gray4(1)); - win.SetExtent(TPoint(10,10),TheClient->iGroup->Size()-TSize(20,20)); - TheClient->iWs.HeapSetFail(RHeap::EDeterministic,1); - win.Activate(); - TheClient->iWs.Flush(); - TheClient->iWs.HeapSetFail(RHeap::ENone,0); - if (aPeriod.Int()!=0) - { - time.HomeTime(); - User::SetHomeTime(time-aPeriod); - } - win.Close(); - } - -TBool CTEventTest::SetClickType(TClickOutputModes aType) - { - TPckgBuf intPkg; - intPkg()=aType; - TInt err=iClick.CommandReply(EClickCommandSetOutput,intPkg); - if (err!=KErrNone) - Failed(); - return err; - } - -void CTEventTest::CreateEventTestGroup() - { - iEventTestGroup=RWindowGroup(TheClient->iWs); - iEventTestGroup.Construct(123, EFalse); - iEventTestGroup.SetName(_L("Fred")); - } - -void CTQueueClient::CreateEventTestGroupOnSecondScreenL() - { - const TInt KSndScreenNo=1; - iSndScreen=new(ELeave) CWsScreenDevice(iWs); - User::LeaveIfError(iSndScreen->Construct(KSndScreenNo)); - iWinGp1 = new(ELeave) RWindowGroup(iWs); - User::LeaveIfError(iWinGp1->Construct((TUint32)iWinGp1,ETrue,iSndScreen)); - iWinGp2 = new (ELeave) RWindowGroup(iWs); - User::LeaveIfError(iWinGp2->Construct((TUint32)iWinGp2,ETrue,iSndScreen)); - } - -void CTQueueClient::CloseEventTestGroupOnSecondScreen() - { - if(iWinGp1) - { - iWinGp1->Close(); - delete iWinGp1; - iWinGp1=NULL; - } - if(iWinGp2) - { - iWinGp2->Close(); - delete iWinGp2; - iWinGp2=NULL; - } - if(iSndScreen) - { - delete iSndScreen; - iSndScreen = NULL; - } - } - -void CTEventTest::CloseEventTestGroup() - { - iEventTestGroup.Close(); - } - -void CTEventTest::CreateAndCloseEventTestGroup() -// -// Create and close a window group to test sending of group changed messages -// - { - CreateEventTestGroup(); - CloseEventTestGroup(); - } - -void CTEventTest::QueuePurge_NextSetOfEventsL() - { -#if defined(LOGGING) - TLogMessageText logMessageText; - _LIT(KSet,"QueuePurge SetOfEvents: %d of 11"); - logMessageText.Format(KSet,iEventSet); - TheClient->LogMessage(logMessageText); -#endif - iTheClientFlush=TheClient->iWs.SetAutoFlush(ETrue); - iQuequeClientFlush=iQueueClient->iWs.SetAutoFlush(ETrue); - switch(iEventSet++) - { - case 0: - iTest->SimulateKey(TRawEvent::EKeyDown,32); - iTest->SimulateKey(TRawEvent::EKeyUp,32); - CreateAndCloseEventTestGroup(); - SimulatePointer(TRawEvent::EButton1Down,10,20); - SimulatePointer(TRawEvent::EButton1Up,20,30); - iTest->SimulateEvent(TRawEvent::ESwitchOn); - CreateAndCloseEventTestGroup(); - // - AddExpectedEvent(EEventFocusGained); - AddExpectedKey(EEventKeyDown,32); - AddExpectedKey(EEventKeyUp,32); - AddExpectedEvent(EEventWindowGroupsChanged); - AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(10-EWinPositionX,20-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(20-EWinPositionX,30-EWinPositionY)); - AddExpectedEvent(EEventSwitchOn); - break; - case 1: - { - for(TInt count=0;count<100;count++) - { - iTest->SimulateKey(TRawEvent::EKeyDown,'A'+(count%26)); - iTest->SimulateKey(TRawEvent::EKeyUp,'A'+(count%26)); - } - for(TInt count2=0;count2iGroup->GroupWin()->EnableModifierChangedEvents(0xFFFFFFFF, EEventControlOnlyWhenVisible)); - for(TInt count=0;count<20;count++) - { - iTest->SimulateEvent(TRawEvent::ESwitchOn); - iTest->SimulateEvent(TRawEvent::ESwitchOn); - iTest->SimulateKey(TRawEvent::EKeyDown,EStdKeyLeftShift); - iTest->SimulateKey(TRawEvent::EKeyDown,EStdKeyRightShift); - iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeyRightShift); - iTest->SimulateEvent(TRawEvent::ESwitchOn); - iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeyLeftShift); - } - for(TInt count2=0;count2<60;count2++) - iTest->SimulateKey(TRawEvent::EKeyDown,'A'); - AddExpectedEvent(EEventSwitchOn); - AddExpectedModifiersChanged(EModifierLeftShift|EModifierRightShift|EModifierShift,0); - for(TInt count3=0;count3iGroup->GroupWin()->DisableModifierChangedEvents(); - } - break; - case 3: - { - SimulatePointer(TRawEvent::EButton1Up,10,20); - SimulatePointer(TRawEvent::EButton2Up,11,22); - SimulatePointer(TRawEvent::EButton1Down,12,23); - SimulatePointer(TRawEvent::EPointerMove,13,24); - SimulatePointer(TRawEvent::EButton3Down,15,25); - SimulatePointer(TRawEvent::EButton1Up,14,24); - for(TInt count2=0;count2<60;count2++) - iTest->SimulateKey(TRawEvent::EKeyDown,'A'); - SimulatePointer(TRawEvent::EButton3Up,15,25); // Should get stripped by unmatched purged down handling code - iTest->SimulateKey(TRawEvent::EKeyUp,'A'); // To stop repeats - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(10-EWinPositionX,20-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton2Up, TPoint(11-EWinPositionX,22-EWinPositionY)); - for(TInt count3=0;count3SimulateKey(TRawEvent::EKeyDown,'B'); - SimulatePointer(TRawEvent::EButton1Down,12,23); - SimulatePointer(TRawEvent::EPointerMove,13,24); - iTest->SimulateKey(TRawEvent::EKeyUp,'B'); - SimulatePointer(TRawEvent::EButton3Down,15,25); - SimulatePointer(TRawEvent::EButton1Up,14,24); - iQueueClient->iWs.PurgePointerEvents(); - iTest->SimulateEvent(TRawEvent::ESwitchOn); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(10-EWinPositionX,20-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton2Up, TPoint(11-EWinPositionX,22-EWinPositionY)); - AddExpectedKey(EEventKeyDown,'B'); - AddExpectedKey(EEventKey,'B','b'); - AddExpectedKey(EEventKeyUp,'B'); -// AddExpectedPointer(TPointerEvent::EButton3Down, TPoint(15-EWinPositionX,25-EWinPositionY)); - AddExpectedEvent(EEventSwitchOn); // To check pointer events purged okay - } - break; - case 5: - CreateEventTestGroup(); - AddExpectedEvent(EEventWindowGroupsChanged); - break; - case 6: - CloseEventTestGroup(); - AddExpectedEvent(EEventWindowGroupsChanged); - break; - case 7: - iQueueClient->iGroup->GroupWin()->DisableGroupChangeEvents(); - CreateAndCloseEventTestGroup(); - iTest->SimulateEvent(TRawEvent::ESwitchOn); - AddExpectedEvent(EEventSwitchOn); - break; - case 8: - SimulatePointer(TRawEvent::EButton1Down,12,23); - iQueueClient->iWs.PurgePointerEvents(); - SimulatePointer(TRawEvent::EButton1Up,13,24); - SimulatePointer(TRawEvent::EButton2Down,12,23); - iQueueClient->iWs.PurgePointerEvents(); - SimulatePointer(TRawEvent::EButton2Up,13,24); - SimulatePointer(TRawEvent::EButton3Down,12,23); - iQueueClient->iWs.PurgePointerEvents(); - SimulatePointer(TRawEvent::EButton3Up,13,24); -// - SendEvent(EEventUser); - AddExpectedEvent(EEventUser); - break; - case 9: - { - for(TInt count5=0;count5<500;count5++) - { - RWindowGroup group(TheClient->iWs); - group.Construct(ENullWsHandle); - group.EnableReceiptOfFocus(EFalse); - group.Close(); - SimulatePointer(TRawEvent::EButton1Up,10,20); - } - for(TInt count4=0;count4iGroup->GroupWin(); - User::LeaveIfError(group->EnableOnEvents(EEventControlOnlyWithKeyboardFocus)); - iTest->SimulateEvent(TRawEvent::ESwitchOn); - SimulatePointer(TRawEvent::EButton3Down,EWinPositionX,EWinPositionY); - AddExpectedEvent(EEventSwitchOn); - AddExpectedPointer(TPointerEvent::EButton3Down, TPoint(0,0)); -// - group->SetOrdinalPosition(-1); - TheClient->iWs.Finish(); - iTest->SimulateEvent(TRawEvent::ESwitchOn); // Shouldn't get it as in background this time - AddExpectedEvent(EEventFocusLost); - group->SetOrdinalPosition(0); - TheClient->iWs.Finish(); - AddExpectedEvent(EEventFocusGained); -// - User::LeaveIfError(group->EnableOnEvents(EEventControlOnlyWhenVisible)); - User::LeaveIfError(group->EnableModifierChangedEvents(EModifierShift, EEventControlOnlyWhenVisible)); - iTest->SimulateEvent(TRawEvent::ESwitchOn); // Should get this as window still visible - AddExpectedEvent(EEventSwitchOn); - iTest->SimulateKey(TRawEvent::EKeyDown,EStdKeyLeftShift); // Should get modifier changed event as window still visible - AddExpectedModifiersChanged(EModifierShift,EModifierShift); - AddExpectedKey(EEventKeyDown,EStdKeyLeftShift); - SimulatePointer(TRawEvent::EButton1Down,EWinPositionX,EWinPositionY); - SimulatePointer(TRawEvent::EButton1Up,EWinPositionX,EWinPositionY); - AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(0,0)); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(0,0)); - iQueueClient->iWin->SetPos(TPoint(-EWinWidth,-EWinHeight)); - TheClient->iWs.Finish(); -// The following two events shouldn't cause an on or mod changed event as the window is now hidden - iTest->SimulateEvent(TRawEvent::ESwitchOn); - iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeyLeftShift); - AddExpectedKey(EEventKeyUp,EStdKeyLeftShift); -// - iQueueClient->iWin->SetPos(TPoint(EWinPositionX,EWinPositionY)); - TheClient->iWs.Finish(); - } - break; - case 11: - { - RWindowGroup *group=iQueueClient->iGroup->GroupWin(); - SendEvent(EEventUser); - AddExpectedEvent(EEventUser); - - if(iTest->IsFullRomL()) - break; -// -// Test focus only messages when with and without focus -// - User::LeaveIfError(group->EnableErrorMessages(EEventControlOnlyWithKeyboardFocus)); - TriggerOomMessage(TTimeIntervalMinutes(3)); - AddExpectedErrorMessage(TWsErrorMessage::EDrawingRegion,KErrNoMemory); - SendEvent(EEventUser); - AddExpectedEvent(EEventUser); - group->SetOrdinalPosition(1); - TriggerOomMessage(TTimeIntervalMinutes(3)); - AddExpectedEvent(EEventFocusLost); - group->SetOrdinalPosition(0); - AddExpectedEvent(EEventFocusGained); - SendEvent(EEventUser+1); - AddExpectedEvent(EEventUser+1); -// -// Test focus only messages when with visible and invisible -// - User::LeaveIfError(group->EnableErrorMessages(EEventControlOnlyWhenVisible)); - TriggerOomMessage(TTimeIntervalMinutes(3)); - AddExpectedErrorMessage(TWsErrorMessage::EDrawingRegion,KErrNoMemory); - iQueueClient->iWin->SetPos(TPoint(-EWinWidth,-EWinHeight)); - TriggerOomMessage(TTimeIntervalMinutes(3)); - SendEvent(EEventUser+2); - AddExpectedEvent(EEventUser+2); - iQueueClient->iWin->SetPos(TPoint(EWinPositionX,EWinPositionY)); -// -// Check always mode sends an event -// - User::LeaveIfError(group->EnableErrorMessages(EEventControlAlways)); - TriggerOomMessage(TTimeIntervalMinutes(3)); - AddExpectedErrorMessage(TWsErrorMessage::EDrawingRegion,KErrNoMemory); -// - iQueueClient->iWin->SetPos(TPoint(-EWinWidth,-EWinHeight)); - TriggerOomMessage(TTimeIntervalMinutes(3)); - AddExpectedErrorMessage(TWsErrorMessage::EDrawingRegion,KErrNoMemory); - iQueueClient->iWin->SetPos(TPoint(EWinPositionX,EWinPositionY)); -// - group->SetOrdinalPosition(1); - AddExpectedEvent(EEventFocusLost); - TriggerOomMessage(TTimeIntervalMinutes(3)); - AddExpectedErrorMessage(TWsErrorMessage::EDrawingRegion,KErrNoMemory); - group->SetOrdinalPosition(0); - AddExpectedEvent(EEventFocusGained); -// -// Check timing of OOM messages -// - TriggerOomMessage(TTimeIntervalMinutes(3)); - AddExpectedErrorMessage(TWsErrorMessage::EDrawingRegion,KErrNoMemory); - TriggerOomMessage(TTimeIntervalMinutes(0)); - User::After(TTimeIntervalMicroSeconds32(1100000)); // 1.1 second - TriggerOomMessage(TTimeIntervalMinutes(0)); - SendEvent(EEventUser+3); - AddExpectedEvent(EEventUser+3); - TriggerOomMessage(TTimeIntervalMinutes(3)); // Forward by a 2 minutes plus the 1.1 from previous test should trigger an OOM event - AddExpectedErrorMessage(TWsErrorMessage::EDrawingRegion,KErrNoMemory); - SendEvent(EEventUser+4); - AddExpectedEvent(EEventUser+4); - TriggerOomMessage(TTimeIntervalMinutes(-1)); // Clock going backwards should trigger an event - AddExpectedErrorMessage(TWsErrorMessage::EDrawingRegion,KErrNoMemory); - User::After(TTimeIntervalMicroSeconds32(800000)); // 8/10ths of a second - TriggerOomMessage(TTimeIntervalMinutes(0)); // Shouldn't trigger an event - SendEvent(EEventUser+5); - AddExpectedEvent(EEventUser+5); - } - break; - default: - TheClient->iWs.DebugInfo(EWsDebugSetEventQueueTest,ETrue); - TRAPD(err, EventQueueExpansionTestL()); - if (err!=KErrNone) - { - iFailed=ETrue; - } - TheClient->iWs.DebugInfo(EWsDebugSetEventQueueTest,EFalse); - CActiveScheduler::Stop(); - break; - } - TheClient->iWs.SetAutoFlush(iTheClientFlush); - iQueueClient->iWs.SetAutoFlush(iQuequeClientFlush); - } - -// Used for testing PDEF112243. -// Create RWsSession/RWindowGroup/RBlankWindow in a loop. In case of odd loop, -// close the session which causes the previous window to gain focus. Also go -// on adding events to the previous session. Along with some change in product -// code and this test code we get some space/memory before globaleventqueue, -// which is the problem faced by licensee for this defect. -void CTEventTest::EventQueueExpansionTestL() - { - const TInt numClients = 5; - TInt cliHanGrpWin = 777; - TInt cliHanBlkWin = 888; - TInt pushed=0; - RWsSession wsSession[numClients]; - RWindowGroup groupWin[numClients]; - RBlankWindow blankWin[numClients]; - - for (TInt i = 0; i < numClients; i++) - { - User::LeaveIfError(wsSession[i].Connect()); - CleanupClosePushL(wsSession[i]); - - groupWin[i] = RWindowGroup(wsSession[i]); - User::LeaveIfError(groupWin[i].Construct(cliHanGrpWin++)); - CleanupClosePushL(groupWin[i]); - groupWin[i].DefaultOwningWindow(); - - blankWin[i] = RBlankWindow(wsSession[i]); - User::LeaveIfError(blankWin[i].Construct(groupWin[i], cliHanBlkWin++)); - if (i%2 == 0) - { - CleanupClosePushL(blankWin[i]); - pushed++; - } - blankWin[i].Activate(); - - if (i%2 == 1) - { - CleanupStack::Pop(2, &wsSession[i]); - wsSession[i].Close(); - - TRawEvent rawEvent; - for (TInt count=0; count < 40; count++) - { - rawEvent.Set(TRawEvent::EKeyDown,'A'+(i%26)); - wsSession[i-1].SimulateRawEvent(rawEvent); - - rawEvent.Set(TRawEvent::EKeyUp,'A'+(i%26)); - wsSession[i-1].SimulateRawEvent(rawEvent); - } - } - } - CleanupStack::PopAndDestroy(pushed*3, &wsSession[0]); - } - -void CTEventTest::doSendEvent(TWsEvent &aEvent) - { - iQueueClient->iWs.SendEventToWindowGroup(iQueueClient->WindowGroupIdentifier(),aEvent); - } - -void CTEventTest::SendKey(TInt aEventCode, TInt aScanCode, TInt aCode/*=0*/, TInt iRepeats/*=0*/) - { - TWsEvent event; - if (aEventCode==EEventKey && aCode==0) - aCode=aScanCode; - event.SetType(aEventCode); - event.Key()->iCode=aCode; - event.Key()->iScanCode=aScanCode; - event.Key()->iModifiers=0; - event.Key()->iRepeats=iRepeats; - doSendEvent(event); - } - -void CTEventTest::SendEvent(TInt aEventCode) - { - TWsQTEvent event; - event.SetType(aEventCode); - doSendEvent(event); - } - -void CTEventTest::SimulateAndCheck(TPoint aOrigin,TSize aScale,TInt aXOffset,TInt aYOffset,TPointerEvent::TType aEventType,TRect aPointerCursorArea) - { - TPoint ptCheck=PhysicalToLogical(TPoint(aOrigin.iX+aXOffset,aOrigin.iY+aYOffset)-aOrigin,aScale); - if (ptCheck.iX < aPointerCursorArea.iTl.iX) - { - ptCheck.iX=aPointerCursorArea.iTl.iX; - } - else if (ptCheck.iX > aPointerCursorArea.iBr.iX) - { - ptCheck.iX=aPointerCursorArea.iBr.iX; - } - if (ptCheck.iY < aPointerCursorArea.iTl.iY) - { - ptCheck.iY=aPointerCursorArea.iTl.iY; - } - else if (ptCheck.iY > aPointerCursorArea.iBr.iY) - { - ptCheck.iY=aPointerCursorArea.iBr.iY; - } - AddExpectedPointer(aEventType,TPoint(ptCheck.iX-EWinPositionX,ptCheck.iY-EWinPositionY)); - } - -void CTEventTest::CheckPointerCursorInDifferentScreenMode(TSizeMode aMode,TPoint aOrigin) - { - aMode.iOrigin=aOrigin; - iQueueClient->iScreen->SetCurrentScreenModeAttributes(aMode); - iQueueClient->iScreen->SetAppScreenMode(iCurrentMode); //This makes the App pick up the new mode parameters - TheClient->iScreen->SetAppScreenMode(iCurrentMode); //Ditto - iQueueClient->iScreen->SetScreenMode(iCurrentMode); //This causes all the windows to be updated - - //.. Tests the general pointer cursor area setting and getting - RWsSession& ws=iQueueClient->iWs; - TRect rect=ws.PointerCursorArea(iCurrentMode); //ws.PointerCursorArea() by default gets first screen mode's pointer cursor area so use other overloaded function - TPoint origin=iQueueClient->iScreen->GetScreenModeOrigin(iCurrentMode); - TSize scale=iQueueClient->iScreen->GetScreenModeScale(iCurrentMode); - TSize fullScreenModeSize=iQueueClient->iScreen->SizeInPixels(); - TRect rect1(PhysicalToLogical(TPoint(),scale),PhysicalToLogical(fullScreenModeSize.AsPoint()-origin,scale)); - TRect rect2=rect1; - rect2.Shrink(20,20); - ws.SetPointerCursorArea(iCurrentMode,rect1); - TEST(ws.PointerCursorArea(iCurrentMode)==rect1); - ws.SetPointerCursorArea(iCurrentMode,rect2); - TEST(ws.PointerCursorArea(iCurrentMode)==rect2); - ws.SetPointerCursorArea(iCurrentMode,rect); - TEST(ws.PointerCursorArea(iCurrentMode)==rect); - - //.. Test events are restricted to correct pointer cursor area - TRect rectPointerCursorArea(10,10,51,51); - iQueueClient->iWs.SetPointerCursorArea(iCurrentMode,rectPointerCursorArea); - TPoint screenModeOrigin=iQueueClient->iScreen->GetDefaultScreenModeOrigin(); - - SimulatePointer(TRawEvent::EButton1Down,screenModeOrigin.iX+5,screenModeOrigin.iY+5); - SimulatePointer(TRawEvent::EButton1Up,screenModeOrigin.iX+25,screenModeOrigin.iY+25); - SimulatePointer(TRawEvent::EButton1Down,screenModeOrigin.iX+50,screenModeOrigin.iY+50); - SimulatePointer(TRawEvent::EButton1Up,screenModeOrigin.iX+75,screenModeOrigin.iY+75); - - SimulatePointer(TRawEvent::EButton1Down,screenModeOrigin.iX+10,screenModeOrigin.iY+15); - SimulatePointer(TRawEvent::EButton1Up,screenModeOrigin.iX+20,screenModeOrigin.iY+5); - SimulatePointer(TRawEvent::EButton1Down,screenModeOrigin.iX+35,screenModeOrigin.iY+40); - SimulatePointer(TRawEvent::EButton1Up,screenModeOrigin.iX+45,screenModeOrigin.iY+70); - - SimulateAndCheck(screenModeOrigin,aMode.iScreenScale,5,5,TPointerEvent::EButton1Down,rectPointerCursorArea); - SimulateAndCheck(screenModeOrigin,aMode.iScreenScale,25,25,TPointerEvent::EButton1Up,rectPointerCursorArea); - SimulateAndCheck(screenModeOrigin,aMode.iScreenScale,50,50,TPointerEvent::EButton1Down,rectPointerCursorArea); - SimulateAndCheck(screenModeOrigin,aMode.iScreenScale,75,75,TPointerEvent::EButton1Up,rectPointerCursorArea); - - SimulateAndCheck(screenModeOrigin,aMode.iScreenScale,10,15,TPointerEvent::EButton1Down,rectPointerCursorArea); - SimulateAndCheck(screenModeOrigin,aMode.iScreenScale,20,5,TPointerEvent::EButton1Up,rectPointerCursorArea); - SimulateAndCheck(screenModeOrigin,aMode.iScreenScale,35,40,TPointerEvent::EButton1Down,rectPointerCursorArea); - SimulateAndCheck(screenModeOrigin,aMode.iScreenScale,45,70,TPointerEvent::EButton1Up,rectPointerCursorArea); - } - -void CTEventTest::SendEventTest_NextSetOfEvents() - { - TTimeIntervalMicroSeconds32 initialTime,time; - TheClient->iWs.GetKeyboardRepeatRate(initialTime,time); - switch(iEventSet++) - { - case 0: - SendKey(EEventKeyDown,1); - SendKey(EEventKeyDown,2); - SendEvent(EEventUser); - SendKey(EEventKeyUp,1); - SendKey(EEventKeyUp,2); - SendEvent(EEventUser+1); - SendEvent(EEventUser+2); -// - AddExpectedEvent(EEventFocusGained); - AddExpectedKey(EEventKeyDown,1); - AddExpectedKey(EEventKeyDown,2); - AddExpectedEvent(EEventUser); - AddExpectedKey(EEventKeyUp,1); - AddExpectedKey(EEventKeyUp,2); - AddExpectedEvent(EEventUser+1); - AddExpectedEvent(EEventUser+2); - break; - case 1: - #if defined(SCREEN_MODE_TESTING) - if (iNumScrModes>1) - { - iQueueClient->iGroup->GroupWin()->EnableScreenChangeEvents(); - - if (SetClickType(EClickCheck)) - return; - iAddToClick=ETrue; - - iQueueClient->iScreen->SetScreenMode(1); - - iAddToClick=EFalse; - SetClickType(EClickNone); - - AddExpectedEvent(EEventScreenDeviceChanged); - SendEvent(EEventUser); - AddExpectedEvent(EEventUser); - iQueueClient->iGroup->GroupWin()->DisableScreenChangeEvents(); - if (iQueueClient->iScreen->ScreenModeEnforcement()==ESizeEnforcementPixelsAndRotation) - AddExpectedEvent(EEventFocusLost); - } - #endif - SendEvent(EEventUser+1); - AddExpectedEvent(EEventUser+1); - break; - case 2: - #if defined(SCREEN_MODE_TESTING) - if (iNumScrModes>1) - { - iQueueClient->iGroup->GroupWin()->EnableScreenChangeEvents(); - - if (SetClickType(EClickCheck)) - return; - iAddToClick=ETrue; - - iQueueClient->iScreen->SetScreenMode(0); - iQueueClient->iScreen->SetScreenMode(1); - iQueueClient->iScreen->SetScreenMode(0); - - iAddToClick=EFalse; - SetClickType(EClickNone); - - AddExpectedEvent(EEventScreenDeviceChanged); // Only one event should get queued - if (iQueueClient->iScreen->ScreenModeEnforcement()==ESizeEnforcementPixelsAndRotation) - AddExpectedEvent(EEventFocusGained); - SendEvent(EEventUser+2); - AddExpectedEvent(EEventUser+2); - iQueueClient->iGroup->GroupWin()->DisableScreenChangeEvents(); - } - #endif - SendEvent(EEventUser+3); - AddExpectedEvent(EEventUser+3); - break; - case 3: - #if defined(SCREEN_MODE_TESTING) - if (iNumScrModes>1) - { - iQueueClient->iGroup->GroupWin()->EnableScreenChangeEvents(); - iQueueClient->iGroup->GroupWin()->DisableScreenChangeEvents(); - - if (SetClickType(EClickCheck)) - return; - iAddToClick=ETrue; - - iQueueClient->iScreen->SetScreenMode(0); - - iAddToClick=EFalse; - SetClickType(EClickNone); - - SendEvent(EEventUser+1); - AddExpectedEvent(EEventUser+1); - } - #endif - SendEvent(EEventUser+4); - AddExpectedEvent(EEventUser+4); - break; - case 4: - iTest->SimulateKey(TRawEvent::EKeyDown,EStdKeySpace); - TheClient->iWs.Flush(); - User::After(initialTime.Int()+time.Int()/3); - iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeySpace); - AddExpectedKey(EEventKeyDown,EStdKeySpace); - AddExpectedKey(EEventKey,EStdKeySpace,' '); - AddExpectedKey(EEventKey,EStdKeySpace,' ',1); - AddExpectedKey(EEventKeyUp,EStdKeySpace); - break; - case 5: //To test sending a key event with iRepeats!=0 - iTest->SimulateKey(TRawEvent::EKeyDown,EStdKeySpace); - TheClient->iWs.Flush(); - User::After(initialTime.Int()+time.Int()/3); - SendKey(EEventKey,EStdKeyHome,EKeyHome,0); - User::After(initialTime.Int()+time.Int()/3); - SendKey(EEventKey,EStdKeyEnd,EKeyEnd,12345); - User::After(initialTime.Int()+time.Int()/3); - iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeySpace); - AddExpectedKey(EEventKeyDown,EStdKeySpace); - AddExpectedKey(EEventKey,EStdKeySpace,' '); - AddExpectedKey(EEventKey,EStdKeySpace,' ',1); - AddExpectedKey(EEventKey,EStdKeyHome,EKeyHome); - AddExpectedKey(EEventKey,EStdKeySpace,' ',1); - AddExpectedKey(EEventKey,EStdKeyEnd,EKeyEnd,1); - AddExpectedKey(EEventKeyUp,EStdKeySpace); - break; - default: - CActiveScheduler::Stop(); - break; - } - TheClient->iWs.Flush(); - } - -void CTEventTest::InvisibleWindow_NextSetOfEvents() - { - switch(iEventSet++) - { - case 0: - SimulatePointer(TRawEvent::EButton1Down,45,30); - SimulatePointer(TRawEvent::EButton1Up,45,30); - SimulatePointer(TRawEvent::EButton1Down,20,10); - SimulatePointer(TRawEvent::EButton1Up,20,10); - TheClient->iWs.Flush(); - iQueueClient->iChildWin->BaseWin()->SetVisible(EFalse); - iQueueClient->iChildWin->BaseWin()->SetVisible(ETrue); - iQueueClient->iWs.Flush(); - SimulatePointer(TRawEvent::EButton1Down,46,31); - SimulatePointer(TRawEvent::EButton1Up,46,31); - AddExpectedEvent(EEventFocusGained); - AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(20-EWinPositionX,10-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(20-EWinPositionX,10-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(46-EWinPositionX,31-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(46-EWinPositionX,31-EWinPositionY)); - break; - case 1: - SimulatePointer(TRawEvent::EButton1Down,21,11); - SimulatePointer(TRawEvent::EButton1Up,21,11); - SimulatePointer(TRawEvent::EButton1Down,44,30); - SimulatePointer(TRawEvent::EButton1Up,44,30); - TheClient->iWs.Flush(); - iQueueClient->iWin->BaseWin()->SetVisible(EFalse); - iQueueClient->iWin->BaseWin()->SetVisible(ETrue); - iQueueClient->iWs.Flush(); - SimulatePointer(TRawEvent::EButton1Down,19,12); - SimulatePointer(TRawEvent::EButton1Up,19,12); - SimulatePointer(TRawEvent::EButton1Down,47,32); - SimulatePointer(TRawEvent::EButton1Up,47,32); - /*AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(44-EWinPositionX,30-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(44-EWinPositionX,30-EWinPositionY));*/ - AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(19-EWinPositionX,12-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(19-EWinPositionX,12-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(47-EWinPositionX,32-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(47-EWinPositionX,32-EWinPositionY)); - break; - default: - CActiveScheduler::Stop(); - break; - } - TheClient->iWs.Flush(); - } - -#define TOP16A 0xAAAA0000 -#define TOP16B 0x55550000 -void CTEventTest::JavaAdditions_NextSetOfEvents() - { - switch(iEventSet++) - { - case 0: - SimulatePointer(TRawEvent::EButton1Down,45,30); - SimulatePointer(TRawEvent::EButton1Up,45,30); - TheClient->iWs.Flush(); - iQueueClient->iWin->BaseWin()->PointerFilter(EPointerMoveEvents,EPointerGenerateSimulatedMove); - iQueueClient->iWs.Flush(); -#if !defined(TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA) - SimulateButton1DownWithSimulatedMove(46,31); -#else - SimulatePointer(TRawEvent::EButton1Down,46,31); -#endif - SimulatePointer(TRawEvent::EButton1Up,46,31); - TheClient->iWs.Flush(); - iQueueClient->iWin->BaseWin()->PointerFilter(EPointerMoveEvents,0); - iQueueClient->iWs.Flush(); - SimulatePointer(TRawEvent::EButton1Down,20,10); - SimulatePointer(TRawEvent::EButton1Up,20,10); - TheClient->iWs.Flush(); - iQueueClient->iWin->BaseWin()->PointerFilter(EPointerMoveEvents,EPointerGenerateSimulatedMove); - iQueueClient->iWs.Flush(); -#if !defined(TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA) - SimulateButton1DownWithSimulatedMove(21,11); -#else - SimulatePointer(TRawEvent::EButton1Down,21,11); -#endif - SimulatePointer(TRawEvent::EButton1Up,21,11); - TheClient->iWs.Flush(); - iQueueClient->iWin->BaseWin()->PointerFilter(EPointerMoveEvents,EPointerMoveEvents); - iQueueClient->iWs.Flush(); - SimulatePointer(TRawEvent::EButton1Down,22,12); - SimulatePointer(TRawEvent::EButton1Up,22,12); - TheClient->iWs.Flush(); - iQueueClient->iWin->BaseWin()->PointerFilter(EPointerMoveEvents,EPointerGenerateSimulatedMove); - iQueueClient->iWs.Flush(); -#if !defined(TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA) - SimulateButton1DownWithSimulatedMove(23,13); -#else - SimulatePointer(TRawEvent::EButton1Down,23,13); -#endif - SimulatePointer(TRawEvent::EButton1Up,23,13); - TheClient->iWs.Flush(); - iQueueClient->iWin->BaseWin()->PointerFilter(EPointerMoveEvents,EPointerFilterMove); - iQueueClient->iWs.Flush(); - SimulatePointer(TRawEvent::EButton1Down,24,14); - SimulatePointer(TRawEvent::EButton1Up,24,14); - AddExpectedEvent(EEventFocusGained); - AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(45-EWinPositionX,30-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(45-EWinPositionX,30-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EMove, TPoint(46-EWinPositionX,31-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(46-EWinPositionX,31-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(46-EWinPositionX,31-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(20-EWinPositionX,10-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(20-EWinPositionX,10-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EMove, TPoint(21-EWinPositionX,11-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(21-EWinPositionX,11-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(21-EWinPositionX,11-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(22-EWinPositionX,12-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(22-EWinPositionX,12-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EMove, TPoint(23-EWinPositionX,13-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(23-EWinPositionX,13-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(23-EWinPositionX,13-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(24-EWinPositionX,14-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(24-EWinPositionX,14-EWinPositionY)); - break; - #if defined(__WINS__) - case 1: - { - RWindowGroup *group=iQueueClient->iGroup->GroupWin(); - group->SetOrdinalPosition(0); - iTest->SimulateKey(TRawEvent::EKeyDown,'2'|TOP16A); - iTest->SimulateKey(TRawEvent::EKeyUp,'2'); - TheClient->iWs.Flush(); - iQueueClient->iWs.SetRemoveKeyCode(EFalse); - iQueueClient->iWs.Flush(); - iTest->SimulateKey(TRawEvent::EKeyDown,'3'|TOP16B); - iTest->SimulateKey(TRawEvent::EKeyUp,'3'); - TheClient->iWs.Flush(); - iQueueClient->iWs.SetRemoveKeyCode(ETrue); - iQueueClient->iWs.Flush(); - iTest->SimulateKey(TRawEvent::EKeyDown,'4'|TOP16B); - iTest->SimulateKey(TRawEvent::EKeyUp,'4'); - AddExpectedKey(EEventKeyDown,'2'); - AddExpectedKey(EEventKey,'2',TOP16A>>16); - AddExpectedKey(EEventKeyUp,'2'); - AddExpectedKey(EEventKeyDown,'3'|TOP16B); - AddExpectedKey(EEventKey,'3',TOP16B>>16); - AddExpectedKey(EEventKeyUp,'3'); - AddExpectedKey(EEventKeyDown,'4'); - AddExpectedKey(EEventKey,'4',TOP16B>>16); - AddExpectedKey(EEventKeyUp,'4'); - break; - } - #endif - default: - CActiveScheduler::Stop(); - break; - } - TheClient->iWs.Flush(); - } - -void CTEventTest::WinCap_NextSetOfEvents() - { - switch(iEventSet++) - { - case 0: - //iQueueClient->SetChildCapture(RWindowBase::TCaptureEnabled); - SimulatePointer(TRawEvent::EButton1Down,35,27); - SimulatePointer(TRawEvent::EButton1Up,25,12); - - - AddExpectedEvent(EEventFocusGained); - AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(35-EWinPositionX,27-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(25-EWinPositionX,12-EWinPositionY)); - break; - - - default: - CActiveScheduler::Stop(); - break; - } - TheClient->iWs.Flush(); - } - -void CTEventTest::XyInputType_NextSetOfEvents() - { - switch(iEventSet++) - { - case 0: - iQueueClient->iWin->BaseWin()->PointerFilter(EPointerMoveEvents|EPointerFilterDrag,EPointerGenerateSimulatedMove); - iQueueClient->iWs.Flush(); -#if !defined(TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA) - SimulateButton1DownWithSimulatedMove(46,31); -#else - SimulatePointer(TRawEvent::EButton1Down,46,31); -#endif - SimulatePointer(TRawEvent::EButton1Up,46,31); - AddExpectedEvent(EEventFocusGained); - AddExpectedPointer(TPointerEvent::EMove, TPoint(46-EWinPositionX,31-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(46-EWinPositionX,31-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(46-EWinPositionX,31-EWinPositionY)); - break; //Must do something - case 1: - { - // check if RWindowGroup::SimulatePointerEvent is working (DEF131563) - RWindowGroup& group = *iQueueClient->iGroup->GroupWin(); - TRawEvent event; - event.Set(TRawEvent::EButton1Down, 10, 10); - group.SimulatePointerEvent(event); - event.Set(TRawEvent::EButton1Up, 10, 10); - group.SimulatePointerEvent(event); - if(!iIs3DPointer) - { - // simulated move will be generated - AddExpectedPointer(TPointerEvent::EMove, TPoint(10 - EWinPositionX, 10 - EWinPositionY)); - } - AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(10 - EWinPositionX, 10 - EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(10 - EWinPositionX, 10 - EWinPositionY)); - } - break; - #if defined(__WINS__) - case 2: -#if !defined(TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA) - SimulateButton1DownWithSimulatedMove(45,32); -#else - SimulatePointer(TRawEvent::EButton1Down,45,32); -#endif - SimulatePointer(TRawEvent::EButton1Up,45,32); - TheClient->iWs.SimulateXyInputType(EXYInputNone); - SimulatePointer(TRawEvent::EButton1Down,44,32); - SimulatePointer(TRawEvent::EPointerMove,43,32); - SimulatePointer(TRawEvent::EButton1Up,43,31); - SimulatePointer(TRawEvent::EButton2Down,44,33); - SimulatePointer(TRawEvent::EButton2Up,44,33); - SimulatePointer(TRawEvent::EButton3Down,43,32); - SimulatePointer(TRawEvent::EButton3Up,43,32); - SimulatePointer(TRawEvent::EPointerSwitchOn,48,32); - TheClient->iWs.SimulateXyInputType(EXYInputPointer); -#if !defined(TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA) - SimulateButton1DownWithSimulatedMove(47,32); -#else - SimulatePointer(TRawEvent::EButton1Down,47,32); -#endif - SimulatePointer(TRawEvent::EButton1Up,47,32); - AddExpectedPointer(TPointerEvent::EMove, TPoint(45-EWinPositionX,32-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(45-EWinPositionX,32-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(45-EWinPositionX,32-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EMove, TPoint(47-EWinPositionX,32-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(47-EWinPositionX,32-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(47-EWinPositionX,32-EWinPositionY)); - break; - case 3: - iQueueClient->iWin->BaseWin()->PointerFilter(EPointerGenerateSimulatedMove,0); - iQueueClient->iWs.Flush(); - TheClient->iWs.SimulateXyInputType(EXYInputPointer); - SimulatePointer(TRawEvent::EButton1Down,49,32); - SimulatePointer(TRawEvent::EPointerMove,50,30); - SimulatePointer(TRawEvent::EButton1Up,50,30); - SimulatePointer(TRawEvent::EButton1Down,51,32); - SimulatePointer(TRawEvent::EPointerMove,52,30); - SimulatePointer(TRawEvent::EButton1Up,52,30); - TheClient->iWs.SimulateXyInputType(EXYInputPointer); - AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(49-EWinPositionX,32-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EDrag, TPoint(50-EWinPositionX,30-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(50-EWinPositionX,30-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(51-EWinPositionX,32-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EDrag, TPoint(52-EWinPositionX,30-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(52-EWinPositionX,30-EWinPositionY)); - break; - case 4: - SimulatePointer(TRawEvent::EButton1Down,49,31); - SimulatePointer(TRawEvent::EButton1Up,49,31); - TheClient->iWs.SimulateXyInputType(EXYInputMouse); - SimulatePointer(TRawEvent::EPointerMove,50,31); - SimulatePointer(TRawEvent::EButton1Down,50,31); - SimulatePointer(TRawEvent::EPointerMove,50,30); - SimulatePointer(TRawEvent::EButton1Up,50,30); - SimulatePointer(TRawEvent::EPointerMove,51,31); - SimulatePointer(TRawEvent::EButton1Down,51,31); - SimulatePointer(TRawEvent::EPointerMove,51,30); - SimulatePointer(TRawEvent::EButton1Up,51,30); - TheClient->iWs.SimulateXyInputType(EXYInputPointer); - SimulatePointer(TRawEvent::EButton1Down,52,31); - SimulatePointer(TRawEvent::EButton1Up,52,31); - AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(49-EWinPositionX,31-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(49-EWinPositionX,31-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EMove, TPoint(50-EWinPositionX,31-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(50-EWinPositionX,31-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EDrag, TPoint(50-EWinPositionX,30-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(50-EWinPositionX,30-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EMove, TPoint(51-EWinPositionX,31-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(51-EWinPositionX,31-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EDrag, TPoint(51-EWinPositionX,30-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(51-EWinPositionX,30-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(52-EWinPositionX,31-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(52-EWinPositionX,31-EWinPositionY)); - break; - case 5: - SimulatePointer(TRawEvent::EButton1Down,69,31); - SimulatePointer(TRawEvent::EButton1Up,69,31); - TheClient->iWs.SimulateXyInputType(EXYInputDeltaMouse); - SimulatePointer(TRawEvent::EPointerMove,-5,-5); - SimulatePointer(TRawEvent::EButton1Down,7,8); - SimulatePointer(TRawEvent::EPointerMove,10,-3); - SimulatePointer(TRawEvent::EButton1Up,-7,-8); - SimulatePointer(TRawEvent::EPointerMove,-4,9); - SimulatePointer(TRawEvent::EButton1Down,123,456); - SimulatePointer(TRawEvent::EPointerMove,15,13); - SimulatePointer(TRawEvent::EButton1Up,-2345,-6789); - TheClient->iWs.SimulateXyInputType(EXYInputPointer); - SimulatePointer(TRawEvent::EButton1Down,62,31); - SimulatePointer(TRawEvent::EButton1Up,62,31); - AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(69-EWinPositionX,31-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(69-EWinPositionX,31-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EMove, TPoint(64-EWinPositionX,26-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(64-EWinPositionX,26-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EDrag, TPoint(74-EWinPositionX,23-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(74-EWinPositionX,23-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EMove, TPoint(70-EWinPositionX,32-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(70-EWinPositionX,32-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EDrag, TPoint(85-EWinPositionX,45-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(85-EWinPositionX,45-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(62-EWinPositionX,31-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(62-EWinPositionX,31-EWinPositionY)); - break; - #endif - default: - CActiveScheduler::Stop(); - break; - } - TheClient->iWs.Flush(); - } - -void CTEventTest::MovingPointerCursor_NextSetOfEventsL() - { - switch(iEventSet++) - { - case 0: - iQueueClient->iWin->BaseWin()->PointerFilter(EPointerFilterMove|EPointerFilterDrag,0); - iQueueClient->iWin->BaseWin()->SetPointerGrab(EFalse); - iQueueClient->iChildWin->BaseWin()->PointerFilter(EPointerFilterMove|EPointerFilterDrag,0); - iQueueClient->iChildWin->BaseWin()->SetPointerGrab(EFalse); - iQueueClient->iWs.Flush(); - //AddExpectedEvent(EEventFocusGained); - break; - #if defined(__WINS__) - case 1: - TheClient->iWs.SimulateXyInputType(EXYInputMouse); - iQueueClient->iChildWin->BaseWin()->PointerFilter(EPointerFilterMove|EPointerFilterDrag,0); - iQueueClient->iWin->BaseWin()->PointerFilter(EPointerFilterMove|EPointerFilterDrag,0); - iQueueClient->iWin->BaseWin()->SetPointerGrab(EFalse); - iQueueClient->iChildWin->BaseWin()->SetPointerGrab(EFalse); - iQueueClient->iWs.Flush(); - SimulatePointer(TRawEvent::EPointerMove,46,31); - SimulatePointer(TRawEvent::EButton1Down,46,31); - SimulatePointer(TRawEvent::EPointerMove,47,32); - SimulatePointer(TRawEvent::EButton1Up,47,32); - AddExpectedPointer(TPointerEvent::EMove, TPoint(46-EWinPositionX,31-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(46-EWinPositionX,31-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EDrag, TPoint(47-EWinPositionX,32-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(47-EWinPositionX,32-EWinPositionY)); - break; - case 2: - TheClient->iWs.SimulateXyInputType(EXYInputDeltaMouse); - TheClient->iWs.SetPointerCursorPosition(TPoint(62,24)); - SimulatePointer(TRawEvent::EPointerMove,-5,-5); - TheClient->iWs.SetPointerCursorPosition(TPoint(60,20)); - SimulatePointer(TRawEvent::EPointerMove,6,7); - SimulatePointer(TRawEvent::EButton1Down,27,38); - SimulatePointer(TRawEvent::EPointerMove,0,0); - TheClient->iWs.SetPointerCursorPosition(TPoint(55,25)); - SimulatePointer(TRawEvent::EPointerMove,4,-13); - TheClient->iWs.SetPointerCursorPosition(TPoint(58,20)); - SimulatePointer(TRawEvent::EButton1Up,45,-678); - TheClient->iWs.Flush(); - iQueueClient->iWin->BaseWin()->PointerFilter(EPointerFilterEnterExit,0); - iQueueClient->iChildWin->BaseWin()->PointerFilter(EPointerFilterEnterExit,0); - iQueueClient->iWs.Flush(); - TheClient->iWs.SetPointerCursorPosition(TPoint(80,45)); - TheClient->iWs.SimulateXyInputType(EXYInputPointer); - AddExpectedPointer(TPointerEvent::EMove, TPoint(57-EWinPositionX,19-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EMove, TPoint(66-EWinPositionX,27-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(66-EWinPositionX,27-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EDrag, TPoint(66-EWinPositionX,27-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EDrag, TPoint(59-EWinPositionX,12-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(58-EWinPositionX,20-EWinPositionY)); - AddExpectedEnterExit(EEventPointerEnter, TPoint(58-EWinPositionX,20-EWinPositionY)); - AddExpectedEnterExit(EEventPointerExit, TPoint(58-EWinPositionX,20-EWinPositionY)); - AddExpectedEnterExit(EEventPointerEnter, TPoint(80-EWinPositionX,45-EWinPositionY)); - break; - case 3: - iQueueClient->iWin->BaseWin()->PointerFilter(EPointerFilterEnterExit,EPointerFilterEnterExit); - iQueueClient->iChildWin->BaseWin()->PointerFilter(EPointerFilterEnterExit,EPointerFilterEnterExit); - iQueueClient->iWs.Flush(); - TheClient->iWs.SetPointerCursorArea(TRect(0,0,70,240)); - TheClient->iWs.SimulateXyInputType(EXYInputDeltaMouse); - TheClient->iWs.SetPointerCursorPosition(TPoint(65,30)); - SimulatePointer(TRawEvent::EPointerMove,20,0); - TheClient->iWs.SetPointerCursorPosition(TPoint(75,32)); - SimulatePointer(TRawEvent::EPointerMove,-1,20); - SimulatePointer(TRawEvent::EButton1Down,29,37); - SimulatePointer(TRawEvent::EPointerMove,25,-13); - SimulatePointer(TRawEvent::EButton1Up,47,-648); - TheClient->iWs.SimulateXyInputType(EXYInputPointer); - AddExpectedPointer(TPointerEvent::EMove, TPoint(69-EWinPositionX,30-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EMove, TPoint(68-EWinPositionX,52-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(68-EWinPositionX,52-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EDrag, TPoint(69-EWinPositionX,39-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(69-EWinPositionX,39-EWinPositionY)); - break; - case 4: - TheClient->iWs.SetPointerCursorArea(TRect(EWinPositionX+2,EWinPositionY+2,EWinPositionX+99,EWinPositionY+49)); - TheClient->iWs.SimulateXyInputType(EXYInputDeltaMouse); - TheClient->iWs.SetPointerCursorPosition(TPoint(56,30)); - SimulatePointer(TRawEvent::EPointerMove,0,-34); - TheClient->iWs.SetPointerCursorPosition(TPoint(56,30)); - SimulatePointer(TRawEvent::EPointerMove,0,0); - SimulatePointer(TRawEvent::EPointerMove,-77,-35); - TheClient->iWs.SetPointerCursorPosition(TPoint(56,30)); - SimulatePointer(TRawEvent::EPointerMove,0,0); - SimulatePointer(TRawEvent::EPointerMove,-78,0); - TheClient->iWs.SetPointerCursorPosition(TPoint(56,30)); - SimulatePointer(TRawEvent::EPointerMove,0,0); - SimulatePointer(TRawEvent::EPointerMove,-79,36); - TheClient->iWs.SetPointerCursorPosition(TPoint(56,30)); - SimulatePointer(TRawEvent::EPointerMove,0,0); - SimulatePointer(TRawEvent::EPointerMove,0,37); - TheClient->iWs.SetPointerCursorPosition(TPoint(56,30)); - SimulatePointer(TRawEvent::EPointerMove,0,0); - SimulatePointer(TRawEvent::EPointerMove,80,38); - TheClient->iWs.SetPointerCursorPosition(TPoint(56,30)); - SimulatePointer(TRawEvent::EPointerMove,0,0); - SimulatePointer(TRawEvent::EPointerMove,81,0); - TheClient->iWs.SetPointerCursorPosition(TPoint(56,30)); - SimulatePointer(TRawEvent::EPointerMove,0,0); - SimulatePointer(TRawEvent::EPointerMove,82,-39); - TheClient->iWs.SetPointerCursorPosition(TPoint(2,2)); - SimulatePointer(TRawEvent::EPointerMove,30,30); - TheClient->iWs.SetPointerCursorPosition(TPoint(1,30)); - SimulatePointer(TRawEvent::EPointerMove,1,0); - TheClient->iWs.SetPointerCursorPosition(TPoint(2,88)); - SimulatePointer(TRawEvent::EPointerMove,30,-30); - TheClient->iWs.SetPointerCursorPosition(TPoint(56,88)); - SimulatePointer(TRawEvent::EPointerMove,0,-1); - TheClient->iWs.SetPointerCursorPosition(TPoint(123,88)); - SimulatePointer(TRawEvent::EPointerMove,-30,-30); - TheClient->iWs.SetPointerCursorPosition(TPoint(123,30)); - SimulatePointer(TRawEvent::EPointerMove,-1,0); - TheClient->iWs.SetPointerCursorPosition(TPoint(123,2)); - SimulatePointer(TRawEvent::EPointerMove,-30,30); - TheClient->iWs.SetPointerCursorPosition(TPoint(56,1)); - SimulatePointer(TRawEvent::EPointerMove,0,1); - TheClient->iWs.SimulateXyInputType(EXYInputPointer); - AddExpectedPointer(TPointerEvent::EMove, TPoint(56-EWinPositionX,2)); - AddExpectedPointer(TPointerEvent::EMove, TPoint(56-EWinPositionX,30-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EMove, TPoint(2,2)); - AddExpectedPointer(TPointerEvent::EMove, TPoint(56-EWinPositionX,30-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EMove, TPoint(2,30-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EMove, TPoint(56-EWinPositionX,30-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EMove, TPoint(2,48)); - AddExpectedPointer(TPointerEvent::EMove, TPoint(56-EWinPositionX,30-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EMove, TPoint(56-EWinPositionX,48)); - AddExpectedPointer(TPointerEvent::EMove, TPoint(56-EWinPositionX,30-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EMove, TPoint(98,48)); - AddExpectedPointer(TPointerEvent::EMove, TPoint(56-EWinPositionX,30-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EMove, TPoint(98,30-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EMove, TPoint(56-EWinPositionX,30-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EMove, TPoint(98,2)); - AddExpectedPointer(TPointerEvent::EMove, TPoint(32,32)); - AddExpectedPointer(TPointerEvent::EMove, TPoint(3,30-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EMove, TPoint(32,18)); - AddExpectedPointer(TPointerEvent::EMove, TPoint(56-EWinPositionX,47)); - AddExpectedPointer(TPointerEvent::EMove, TPoint(68,18)); - AddExpectedPointer(TPointerEvent::EMove, TPoint(97,30-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EMove, TPoint(68,32)); - AddExpectedPointer(TPointerEvent::EMove, TPoint(56-EWinPositionX,3)); - break; - case 5: - TheClient->iWs.SetPointerCursorArea(TRect(0,0,EWinPositionX+100,EWinPositionY+50)); - TheClient->iWs.SimulateXyInputType(EXYInputDeltaMouse); - TheClient->iWs.SetPointerCursorPosition(TPoint(57,31)); - TheClient->iWs.SetPointerCursorArea(TRect(0,35,EWinPositionX+100,EWinPositionY+50)); - SimulatePointer(TRawEvent::EPointerMove,1,0); - TheClient->iWs.SetPointerCursorPosition(TPoint(10,55)); - TheClient->iWs.SetPointerCursorArea(TRect(15,0,EWinPositionX+100,50)); - SimulatePointer(TRawEvent::EPointerMove,1,1); - TheClient->iWs.SetPointerCursorPosition(TPoint(57,31)); - TheClient->iWs.SetPointerCursorArea(TRect(0,0,50,EWinPositionY+50)); - SimulatePointer(TRawEvent::EPointerMove,0,1); - TheClient->iWs.SetPointerCursorPosition(TPoint(10,10)); - TheClient->iWs.SetPointerCursorArea(TRect(15,15,EWinPositionX+100,EWinPositionY+50)); - SimulatePointer(TRawEvent::EPointerMove,1,-1); - TheClient->iWs.SetPointerCursorPosition(TPoint(57,31)); - TheClient->iWs.SetPointerCursorArea(TRect(0,0,EWinPositionX+100,30)); - SimulatePointer(TRawEvent::EPointerMove,-1,0); - TheClient->iWs.SetPointerCursorPosition(TPoint(100,10)); - TheClient->iWs.SetPointerCursorArea(TRect(0,15,95,EWinPositionY+50)); - SimulatePointer(TRawEvent::EPointerMove,-1,-1); - TheClient->iWs.SetPointerCursorPosition(TPoint(57,31)); - TheClient->iWs.SetPointerCursorArea(TRect(60,0,EWinPositionX+100,EWinPositionY+50)); - SimulatePointer(TRawEvent::EPointerMove,0,-1); - TheClient->iWs.SetPointerCursorPosition(TPoint(100,55)); - TheClient->iWs.SetPointerCursorArea(TRect(0,0,95,50)); - SimulatePointer(TRawEvent::EPointerMove,1,-1); - TheClient->iWs.SimulateXyInputType(EXYInputPointer); - AddExpectedPointer(TPointerEvent::EMove, TPoint(58-EWinPositionX,35-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EMove, TPoint(16-EWinPositionX,49-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EMove, TPoint(49-EWinPositionX,32-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EMove, TPoint(16-EWinPositionX,15-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EMove, TPoint(56-EWinPositionX,29-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EMove, TPoint(93-EWinPositionX,15-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EMove, TPoint(60-EWinPositionX,30-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EMove, TPoint(94-EWinPositionX,48-EWinPositionY)); - break; - #endif - default: - TheClient->iWs.SetPointerCursorArea(TRect(0,0,95,50)); - CActiveScheduler::Stop(); - break; - } - TheClient->iWs.Flush(); - } - -void CTEventTest::RotatedMode_NextSetOfEventsL() - { -#if defined(LOGGING) - TLogMessageText logMessageText; - _LIT(KSet,"RotatedMode SetOfEvents: %d Max=4"); - logMessageText.Format(KSet,iEventSet); - INFO_PRINTF1(logMessageText); -#endif - switch(iEventSet++) - { - case 0: - { - iQueueClient->iWin->BaseWin()->PointerFilter(EPointerFilterMove|EPointerFilterDrag,0); - iQueueClient->iWin->BaseWin()->SetPointerGrab(EFalse); - iQueueClient->iWs.Flush(); - TheClient->iWs.SetPointerCursorArea(TRect(10,10,51,51)); - SimulatePointer(TRawEvent::EButton1Down,5,5); - SimulatePointer(TRawEvent::EButton1Up,25,5); - SimulatePointer(TRawEvent::EButton1Down,55,5); - SimulatePointer(TRawEvent::EButton1Up,55,35); - SimulatePointer(TRawEvent::EButton1Down,55,55); - SimulatePointer(TRawEvent::EButton1Up,25,55); - SimulatePointer(TRawEvent::EButton1Down,5,55); - SimulatePointer(TRawEvent::EButton1Up,5,35); - AddExpectedEvent(EEventFocusGained); - AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(10-EWinPositionX,10-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(25-EWinPositionX,10-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(50-EWinPositionX,10-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(50-EWinPositionX,35-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(50-EWinPositionX,50-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(25-EWinPositionX,50-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(10-EWinPositionX,50-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(10-EWinPositionX,35-EWinPositionY)); - } - break; - case 1: - { - TInt enforc=TheClient->iScreen->ScreenModeEnforcement(); - iBlankWin->SetVisible(ETrue); - #if defined(LOGGING) - _LIT(KSet1,"AUTO Rotating Events :1st "); - INFO_PRINTF1(KSet1); - #endif - INFO_PRINTF1(_L(" Set of Events")); - if (iScreenModeTests&EDoRot90) - { - TheClient->iScreen->SetScreenMode(1); - TheClient->iWs.Flush(); - iTest->DelayIfFullRomL(); - INFO_PRINTF1(_L(" Screen mode 1.")); - TPoint screenModeOrigin=TheClient->iScreen->GetDefaultScreenModeOrigin(); - #if defined(__WINS__) - iTest->SimulatePointer(TRawEvent::EButton1Down,20+screenModeOrigin.iX,20+screenModeOrigin.iY); - iTest->SimulatePointer(TRawEvent::EButton1Up,20+screenModeOrigin.iX,20+screenModeOrigin.iY); - #else - // simulate pointer at (20,20) on rotated screen by providing physical coordinates - iTest->SimulatePointer(TRawEvent::EButton1Down,iPhysicalScreenSize.iWidth-1-20+screenModeOrigin.iX,20+screenModeOrigin.iY); - iTest->SimulatePointer(TRawEvent::EButton1Up,iPhysicalScreenSize.iWidth-1-20+screenModeOrigin.iX,20+screenModeOrigin.iY); - #endif - INFO_PRINTF1(_L(" Sent Up and Down 90")); - } - if (iScreenModeTests&EDoRot180) - { - TheClient->iScreen->SetCurrentRotations(0,CFbsBitGc::EGraphicsOrientationRotated180); - TheClient->iScreen->SetScreenMode(0); - INFO_PRINTF1(_L(" Screen mode 0")); - TheClient->iWs.Flush(); - iTest->DelayIfFullRomL(); - INFO_PRINTF1(_L(" Upside Down")); - #if defined(__WINS__) - iTest->SimulatePointer(TRawEvent::EButton1Down,22,22); - iTest->SimulatePointer(TRawEvent::EButton1Up,22,22); - #else - // simulate pointer at (22,22) on rotated screen by providing physical coordinates - iTest->SimulatePointer(TRawEvent::EButton1Down,iPhysicalScreenSize.iWidth-1-22,iPhysicalScreenSize.iHeight-1-22); - iTest->SimulatePointer(TRawEvent::EButton1Up,iPhysicalScreenSize.iWidth-1-22,iPhysicalScreenSize.iHeight-1-22); - #endif - INFO_PRINTF1(_L(" Sent Up and Down 180")); - } - TheClient->iScreen->SetCurrentRotations(0,CFbsBitGc::EGraphicsOrientationNormal); - TheClient->iScreen->SetScreenMode(0); - TheClient->iWs.Flush(); - iTest->DelayIfFullRomL(); - INFO_PRINTF1(_L(" Normal Screen mode")); - if (iScreenModeTests&EDoRot0) - { - SimulatePointer(TRawEvent::EButton1Down,24,24); - SimulatePointer(TRawEvent::EButton1Up,24,24); - } - if (iScreenModeTests&EDoRot90) - { - if (enforc>ESizeEnforcementNone) - { - AddExpectedEvent(EEventFocusLost); - AddExpectedEvent(EEventFocusGained); - } - else - { - AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(20-EWinPositionX,20-EWinPositionY-iYOffset)); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(20-EWinPositionX,20-EWinPositionY-iYOffset)); - } - } - if (iScreenModeTests&EDoRot180) - { - AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(22-EWinPositionX,22-EWinPositionY-iYOffset)); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(22-EWinPositionX,22-EWinPositionY-iYOffset)); - } - if (iScreenModeTests&EDoRot0) - { - AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(24-EWinPositionX,24-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(24-EWinPositionX,24-EWinPositionY)); - } - INFO_PRINTF1(_L(" Added Expected")); - User::After(EPointerCursorUpdateGap); - iBlankWin->SetVisible(EFalse); - } - break; - #if defined(__WINS__) - case 2: - { - TInt enforc=TheClient->iScreen->ScreenModeEnforcement(); - //INFO_PRINTF1("AUTO Rotating Events "); - //INFO_PRINTF1(" :2nd Set of Events"); - TheClient->iWs.SimulateXyInputType(EXYInputDeltaMouse); - TheClient->iWs.SetPointerCursorPosition(TPoint(24+EWinPositionX,24+EWinPositionY)); - if (iScreenModeTests&EDoRot90) - { - TheClient->iScreen->SetScreenMode(1); - TheClient->iWs.Flush(); - iTest->DelayIfFullRomL(); - SimulatePointer(TRawEvent::EPointerMove,1,2); - SimulatePointer(TRawEvent::EButton1Down,56,89); - SimulatePointer(TRawEvent::EPointerMove,2,-1); - SimulatePointer(TRawEvent::EButton1Up,234,456); - } - else - TheClient->iWs.SetPointerCursorPosition(TPoint(27+EWinPositionX,25+EWinPositionY)); - if (iScreenModeTests&EDoRot180) - { - TheClient->iScreen->SetCurrentRotations(0,CFbsBitGc::EGraphicsOrientationRotated180); - TheClient->iScreen->SetScreenMode(0); - TheClient->iWs.Flush(); - iTest->DelayIfFullRomL(); - SimulatePointer(TRawEvent::EPointerMove,-3,4); - SimulatePointer(TRawEvent::EButton1Down,156,289); - SimulatePointer(TRawEvent::EPointerMove,-4,-3); - SimulatePointer(TRawEvent::EButton1Up,2234,3456); - } - else - TheClient->iWs.SetPointerCursorPosition(TPoint(20+EWinPositionX,26+EWinPositionY)); - TheClient->iScreen->SetCurrentRotations(0,CFbsBitGc::EGraphicsOrientationNormal); - TheClient->iScreen->SetScreenMode(0); - TheClient->iWs.Flush(); - iTest->DelayIfFullRomL(); - if (iScreenModeTests&EDoRot0) - { - SimulatePointer(TRawEvent::EButton1Down,24,24); - SimulatePointer(TRawEvent::EButton1Up,24,24); - } - TheClient->iWs.SimulateXyInputType(EXYInputPointer); - TheClient->iWs.Flush(); - if (iScreenModeTests&EDoRot90) - { - if (enforc>ESizeEnforcementNone) - { - AddExpectedEvent(EEventFocusLost); - AddExpectedEvent(EEventFocusGained); - } - else - { - AddExpectedPointer(TPointerEvent::EMove, TPoint(25,26)); - AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(25,26)); - AddExpectedPointer(TPointerEvent::EDrag, TPoint(27,25)); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(27,25)); - } - } - if (iScreenModeTests&EDoRot180) - { - AddExpectedPointer(TPointerEvent::EMove, TPoint(24,29)); - AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(24,29)); - AddExpectedPointer(TPointerEvent::EDrag, TPoint(20,26)); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(20,26)); - } - if (iScreenModeTests&EDoRot0) - { - AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(20,26)); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(20,26)); - } - } - break; - case 3: - { - #if defined(LOGGING) - _LIT(KSet2,"AUTO Rotating Events "); - INFO_PRINTF1(KSet2); - #endif - INFO_PRINTF1(_L(" :3rd Set of Events")); - if (iScreenModeTests&EDoScale) - { - INFO_PRINTF1(_L(" :Screen Scalling Supported")); - iBlankWin->SetVisible(ETrue); - iCurrentMode=iNumScrModes; - --iCurrentMode; - iTheClientFlush=TheClient->iWs.SetAutoFlush(ETrue); - iQuequeClientFlush=iQueueClient->iWs.SetAutoFlush(ETrue); - iQueueClient->iScreen->SetScreenMode(iCurrentMode); - TheClient->iScreen->SetAppScreenMode(iCurrentMode); - iQueueClient->iScreen->SetAppScreenMode(iCurrentMode); - iSizeMode=iQueueClient->iScreen->GetCurrentScreenModeAttributes(); - TSizeMode testMode=iSizeMode; - for (TInt xScale=2;xScale<4;xScale++) - { - INFO_PRINTF1(_L(" :New X-Scale Value")); - for (TInt yScale=2;yScale<4;yScale++) - { - INFO_PRINTF1(_L(" :New Y-Scale Value")); - testMode.iScreenScale.SetSize(xScale,yScale); - CheckPointerCursorInDifferentScreenMode(testMode,TPoint(20,30)); - } - } - User::After(EPointerCursorUpdateGap); - iBlankWin->SetVisible(EFalse); - break; - } - } - case 4: - { - if (iScreenModeTests&EDoScale) - { - TSizeMode testMode=iSizeMode; - iBlankWin->SetVisible(ETrue); - for (TInt xScale=2;xScale<4;xScale++) - { - for (TInt yScale=2;yScale<4;yScale++) - { - testMode.iScreenScale.SetSize(xScale,yScale); - CheckPointerCursorInDifferentScreenMode(testMode,TPoint(30,20)); - } - } - User::After(EPointerCursorUpdateGap); - iBlankWin->SetVisible(EFalse); - break; - } - } - #endif - default: - #if defined(__WINS__) - if (iScreenModeTests&EDoScale) - { - iQueueClient->iScreen->SetScreenMode(iCurrentMode); - iQueueClient->iScreen->SetCurrentScreenModeAttributes(iSizeMode); - iQueueClient->iScreen->SetAppScreenMode(0); - TheClient->iScreen->SetAppScreenMode(0); - iQueueClient->iScreen->SetScreenMode(0); - iBlankWin->SetVisible(EFalse); - TheClient->iWs.SetAutoFlush(iTheClientFlush); - iQueueClient->iWs.SetAutoFlush(iQuequeClientFlush); - } - #endif - User::After(500000); //0.5secs, to allow other screen devices to respond to the flip events - CActiveScheduler::Stop(); - break; - } - TheClient->iWs.Flush(); - } - - -void CTEventTest::ScreenScaling_NextSetOfEventsL() - { -#if defined(LOGGING) - TLogMessageText logMessageText; - _LIT(KSet,"ScreenScaling SetOfEvents: %d (Last=3)"); - logMessageText.Format(KSet,iEventSet); - INFO_PRINTF1(logMessageText); -#endif - if(! (iScreenModeTests & EDoScale)) - { - User::After(500000); - CActiveScheduler::Stop(); - return; - } - switch(iEventSet++) - { - case 0: - { - iTheClientFlush=TheClient->iWs.SetAutoFlush(ETrue); - iQuequeClientFlush=iQueueClient->iWs.SetAutoFlush(ETrue); - iBlankWin->SetVisible(ETrue); - - TInt mode = TheClient->iScreen->CurrentScreenMode(); - - iSizeMode = iQueueClient->iScreen->GetCurrentScreenModeAttributes(); - - iQueueClient->iWin->BaseWin()->PointerFilter(EPointerFilterMove|EPointerFilterDrag,0); - iQueueClient->iWin->BaseWin()->SetPointerGrab(EFalse); - - TSizeMode szMode2 = iSizeMode; - - szMode2.iScreenScale.SetSize(2,2); - - iQueueClient->iScreen->SetCurrentScreenModeAttributes(szMode2); - TheClient->iScreen->SetAppScreenMode(mode); - iQueueClient->iScreen->SetAppScreenMode(mode); - iQueueClient->iScreen->SetScreenMode(mode); - - TPoint theScreenOrigin(iQueueClient->iScreen->GetScreenModeOrigin(mode)); - - SimulatePointer(TRawEvent::EButton1Down, - 20+theScreenOrigin.iX, 20+theScreenOrigin.iY); - SimulatePointer(TRawEvent::EButton1Up, - 20+theScreenOrigin.iX, 20+theScreenOrigin.iY); - iQueueClient->iScreen->SetCurrentScreenModeAttributes(iSizeMode); - TheClient->iScreen->SetAppScreenMode(mode); - iQueueClient->iScreen->SetAppScreenMode(mode); - iQueueClient->iScreen->SetScreenMode(mode); - - AddExpectedEvent(EEventFocusGained); - AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(10-EWinPositionX,10-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(10-EWinPositionX,10-EWinPositionY)); - - break; - } - case 1: - { - TSizeMode szMode2 = iSizeMode; - TInt mode = TheClient->iScreen->CurrentScreenMode(); - - szMode2.iScreenScale.SetSize(2,2); - szMode2.iOrigin.SetXY(20,20); - - iQueueClient->iScreen->SetCurrentScreenModeAttributes(szMode2); - TheClient->iScreen->SetAppScreenMode(mode); - iQueueClient->iScreen->SetAppScreenMode(mode); - iQueueClient->iScreen->SetScreenMode(mode); - - TPoint theScreenOrigin(iQueueClient->iScreen->GetDefaultScreenModeOrigin()); - - SimulatePointer(TRawEvent::EButton1Down, - 30+theScreenOrigin.iX, 30+theScreenOrigin.iY); - SimulatePointer(TRawEvent::EButton1Up, - 26+theScreenOrigin.iX, 20+theScreenOrigin.iY); - SimulatePointer(TRawEvent::EButton1Down, - 40+theScreenOrigin.iX, 60+theScreenOrigin.iY); - SimulatePointer(TRawEvent::EButton1Up, - 26+theScreenOrigin.iX, 20+theScreenOrigin.iY); - - AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(15-EWinPositionX,15-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(13-EWinPositionX,10-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(20-EWinPositionX,30-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(13-EWinPositionX,10-EWinPositionY)); - - iQueueClient->iScreen->SetCurrentScreenModeAttributes(iSizeMode); - TheClient->iScreen->SetAppScreenMode(mode); - iQueueClient->iScreen->SetAppScreenMode(mode); - iQueueClient->iScreen->SetScreenMode(mode); - - theScreenOrigin = TPoint(iQueueClient->iScreen->GetDefaultScreenModeOrigin()); - - SimulatePointer(TRawEvent::EButton1Down, - 30+theScreenOrigin.iX, 30+theScreenOrigin.iY); - SimulatePointer(TRawEvent::EButton1Up, - 26+theScreenOrigin.iX, 20+theScreenOrigin.iY); - SimulatePointer(TRawEvent::EButton1Down, - 40+theScreenOrigin.iX, 50+theScreenOrigin.iY); - SimulatePointer(TRawEvent::EButton1Up, - 26+theScreenOrigin.iX, 20+theScreenOrigin.iY); - - AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(30-EWinPositionX,30-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(26-EWinPositionX,20-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(40-EWinPositionX,50-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(26-EWinPositionX,20-EWinPositionY)); - break; - } - case 2: - { - TInt mode = TheClient->iScreen->CurrentScreenMode(); - TRect theRect = TheClient->iWs.PointerCursorArea(); - - TSizeMode szMode2 = iSizeMode; - - //----------- scaling 2X2 - szMode2.iScreenScale.SetSize(2,2); - - iQueueClient->iScreen->SetCurrentScreenModeAttributes(szMode2); - iQueueClient->iWs.SetPointerCursorArea(mode, TRect(24,10,52,52)); - TheClient->iScreen->SetAppScreenMode(mode); - iQueueClient->iScreen->SetAppScreenMode(mode); - iQueueClient->iScreen->SetScreenMode(mode); - - - TPoint theScreenOrigin(iQueueClient->iScreen->GetDefaultScreenModeOrigin()); - - SimulatePointer(TRawEvent::EButton1Down, - 20+theScreenOrigin.iX, 20+theScreenOrigin.iY); - SimulatePointer(TRawEvent::EButton1Up, - 26+theScreenOrigin.iX, 20+theScreenOrigin.iY); - SimulatePointer(TRawEvent::EButton1Down, - 50+theScreenOrigin.iX, 30+theScreenOrigin.iY); - SimulatePointer(TRawEvent::EButton1Up, - 26+theScreenOrigin.iX, 20+theScreenOrigin.iY); - - AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(24-EWinPositionX,10-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(24-EWinPositionX,10-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(25-EWinPositionX,15-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(24-EWinPositionX,10-EWinPositionY)); - //------------------------ scaling 1X2 - szMode2.iScreenScale.SetSize(1,2); - - iQueueClient->iScreen->SetCurrentScreenModeAttributes(szMode2); - iQueueClient->iWs.SetPointerCursorArea(mode, TRect(24,10,52,52)); - TheClient->iScreen->SetAppScreenMode(mode); - iQueueClient->iScreen->SetAppScreenMode(mode); - iQueueClient->iScreen->SetScreenMode(mode); - - theScreenOrigin = TPoint(iQueueClient->iScreen->GetDefaultScreenModeOrigin()); - - SimulatePointer(TRawEvent::EButton1Down, - 20+theScreenOrigin.iX, 20+theScreenOrigin.iY); - SimulatePointer(TRawEvent::EButton1Up, - 26+theScreenOrigin.iX, 20+theScreenOrigin.iY); - SimulatePointer(TRawEvent::EButton1Down, - 50+theScreenOrigin.iX, 30+theScreenOrigin.iY); - SimulatePointer(TRawEvent::EButton1Up, - 26+theScreenOrigin.iX, 20+theScreenOrigin.iY); - - AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(24-EWinPositionX,10-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(26-EWinPositionX,10-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(50-EWinPositionX,15-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(26-EWinPositionX,10-EWinPositionY)); - //------------------------ scaling 2X1 - szMode2.iScreenScale.SetSize(2,1); - - iQueueClient->iScreen->SetCurrentScreenModeAttributes(szMode2); - iQueueClient->iWs.SetPointerCursorArea(mode, TRect(24,10,52,52)); - TheClient->iScreen->SetAppScreenMode(mode); - iQueueClient->iScreen->SetAppScreenMode(mode); - iQueueClient->iScreen->SetScreenMode(mode); - - theScreenOrigin = TPoint(iQueueClient->iScreen->GetDefaultScreenModeOrigin()); - - SimulatePointer(TRawEvent::EButton1Down, - 20+theScreenOrigin.iX, 20+theScreenOrigin.iY); - SimulatePointer(TRawEvent::EButton1Up, - 26+theScreenOrigin.iX, 20+theScreenOrigin.iY); - SimulatePointer(TRawEvent::EButton1Down, - 50+theScreenOrigin.iX, 30+theScreenOrigin.iY); - SimulatePointer(TRawEvent::EButton1Up, - 26+theScreenOrigin.iX, 20+theScreenOrigin.iY); - - AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(24-EWinPositionX,20-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(24-EWinPositionX,20-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(25-EWinPositionX,30-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(24-EWinPositionX,20-EWinPositionY)); - //------------------------ scaling 3X1 - - szMode2.iScreenScale.SetSize(3,1); - - iQueueClient->iScreen->SetCurrentScreenModeAttributes(szMode2); - iQueueClient->iWs.SetPointerCursorArea(mode, TRect(24,10,52,52)); - TheClient->iScreen->SetAppScreenMode(mode); - iQueueClient->iScreen->SetAppScreenMode(mode); - iQueueClient->iScreen->SetScreenMode(mode); - - theScreenOrigin = TPoint(iQueueClient->iScreen->GetDefaultScreenModeOrigin()); - - SimulatePointer(TRawEvent::EButton1Down, - 21+theScreenOrigin.iX, 20+theScreenOrigin.iY); - SimulatePointer(TRawEvent::EButton1Up, - 30+theScreenOrigin.iX, 20+theScreenOrigin.iY); - SimulatePointer(TRawEvent::EButton1Down, - 75+theScreenOrigin.iX, 30+theScreenOrigin.iY); - SimulatePointer(TRawEvent::EButton1Up, - 30+theScreenOrigin.iX, 20+theScreenOrigin.iY); - - AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(24-EWinPositionX,20-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(24-EWinPositionX,20-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(25-EWinPositionX,30-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(24-EWinPositionX,20-EWinPositionY)); - //------------------------ scaling 3X2 - - szMode2.iScreenScale.SetSize(3,2); - - iQueueClient->iScreen->SetCurrentScreenModeAttributes(szMode2); - iQueueClient->iWs.SetPointerCursorArea(mode, TRect(24,10,52,52)); - TheClient->iScreen->SetAppScreenMode(mode); - iQueueClient->iScreen->SetAppScreenMode(mode); - iQueueClient->iScreen->SetScreenMode(mode); - - theScreenOrigin = TPoint(iQueueClient->iScreen->GetDefaultScreenModeOrigin()); - - SimulatePointer(TRawEvent::EButton1Down, - 21+theScreenOrigin.iX, 20+theScreenOrigin.iY); - SimulatePointer(TRawEvent::EButton1Up, - 30+theScreenOrigin.iX, 20+theScreenOrigin.iY); - SimulatePointer(TRawEvent::EButton1Down, - 75+theScreenOrigin.iX, 30+theScreenOrigin.iY); - SimulatePointer(TRawEvent::EButton1Up, - 30+theScreenOrigin.iX, 20+theScreenOrigin.iY); - - AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(24-EWinPositionX,10-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(24-EWinPositionX,10-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(25-EWinPositionX,15-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(24-EWinPositionX,10-EWinPositionY)); - //------------------------ scaling 3X3 - szMode2.iScreenScale.SetSize(3,3); - - iQueueClient->iScreen->SetCurrentScreenModeAttributes(szMode2); - iQueueClient->iWs.SetPointerCursorArea(mode, TRect(24,10,52,52)); - TheClient->iScreen->SetAppScreenMode(mode); - iQueueClient->iScreen->SetAppScreenMode(mode); - iQueueClient->iScreen->SetScreenMode(mode); - - theScreenOrigin = TPoint(iQueueClient->iScreen->GetDefaultScreenModeOrigin()); - - SimulatePointer(TRawEvent::EButton1Down, - 21+theScreenOrigin.iX, 20+theScreenOrigin.iY); - SimulatePointer(TRawEvent::EButton1Up, - 30+theScreenOrigin.iX, 20+theScreenOrigin.iY); - SimulatePointer(TRawEvent::EButton1Down, - 75+theScreenOrigin.iX, 33+theScreenOrigin.iY); - SimulatePointer(TRawEvent::EButton1Up, - 30+theScreenOrigin.iX, 20+theScreenOrigin.iY); - - AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(24-EWinPositionX,10-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(24-EWinPositionX,10-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(25-EWinPositionX,11-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(24-EWinPositionX,10-EWinPositionY)); - //------------------------ - iQueueClient->iWs.SetPointerCursorArea(mode, theRect); - iQueueClient->iScreen->SetCurrentScreenModeAttributes(iSizeMode); - TheClient->iScreen->SetAppScreenMode(mode); - iQueueClient->iScreen->SetAppScreenMode(mode); - iQueueClient->iScreen->SetScreenMode(mode); - break; - } - case 3: - { - iQueueClient->iWs.SetAutoFlush(ETrue); - TInt theCurMode = iQueueClient->iScreen->CurrentScreenMode(); - TPoint theScreenOrigin; - if (iNumScrModes>2) - { - TheClient->iScreen->SetAppScreenMode(2); - iQueueClient->iScreen->SetAppScreenMode(2); - TheClient->iScreen->SetScreenMode(2); - - theScreenOrigin=iQueueClient->iScreen->GetDefaultScreenModeOrigin(); - SimulatePointer(TRawEvent::EButton1Down, - 30+theScreenOrigin.iX,30+theScreenOrigin.iY); - SimulatePointer(TRawEvent::EButton1Up, - 26+theScreenOrigin.iX,20+theScreenOrigin.iY); - SimulatePointer(TRawEvent::EButton1Down, - 40+theScreenOrigin.iX,60+theScreenOrigin.iY); - SimulatePointer(TRawEvent::EButton1Up, - 26+theScreenOrigin.iX,20+theScreenOrigin.iY); - - AddExpectedPointer(TPointerEvent::EButton1Down, - TPoint(15-EWinPositionX,15-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Up, - TPoint(13-EWinPositionX,10-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Down, - TPoint(20-EWinPositionX,30-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Up, - TPoint(13-EWinPositionX,10-EWinPositionY)); - } - - TheClient->iScreen->SetAppScreenMode(0); - iQueueClient->iScreen->SetAppScreenMode(0); - iQueueClient->iScreen->SetScreenMode(0); - iTest->DelayIfFullRomL(); - - theScreenOrigin = TPoint(iQueueClient->iScreen->GetDefaultScreenModeOrigin()); - - SimulatePointer(TRawEvent::EButton1Down, - 30+theScreenOrigin.iX, 30+theScreenOrigin.iY); - SimulatePointer(TRawEvent::EButton1Up, - 26+theScreenOrigin.iX, 20+theScreenOrigin.iY); - SimulatePointer(TRawEvent::EButton1Down, - 40+theScreenOrigin.iX, 50+theScreenOrigin.iY); - SimulatePointer(TRawEvent::EButton1Up, - 26+theScreenOrigin.iX, 20+theScreenOrigin.iY); - - #if defined(__WINS__) - iQueueClient->iWs.SimulateXyInputType(EXYInputDeltaMouse); - iQueueClient->iWs.SetPointerCursorPosition(TPoint(24+theScreenOrigin.iX,24+theScreenOrigin.iY)); - SimulatePointer(TRawEvent::EPointerMove,1,2); - iQueueClient->iWs.SimulateXyInputType(EXYInputPointer); - #endif - AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(30-EWinPositionX,30-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(26-EWinPositionX,20-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(40-EWinPositionX,50-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(26-EWinPositionX,20-EWinPositionY)); - - #if defined(__WINS__) - AddExpectedPointer(TPointerEvent::EMove, TPoint(25-EWinPositionX,26-EWinPositionY)); - #endif - - iQueueClient->iScreen->SetAppScreenMode(theCurMode); - TheClient->iScreen->SetScreenMode(theCurMode); - break; - } - default: - User::After(EPointerCursorUpdateGap); - iBlankWin->SetVisible(EFalse); - TheClient->iWs.SetAutoFlush(iTheClientFlush); - iQueueClient->iWs.SetAutoFlush(iQuequeClientFlush); - iQueueClient->iScreen->SetCurrentScreenModeAttributes(iSizeMode); - User::After(500000); //0.5secs, to allow other screen devices to respond to the flip events - CActiveScheduler::Stop(); - break; - } - } - -void CTEventTest::AnimEvent_NextSetOfEventsL() - { -#if defined(LOGGING) - TLogMessageText logMessageText; - _LIT(KSet,"AnimEvent SetOfEvents: %d (Max=4)"); - logMessageText.Format(KSet,iEventSet); - INFO_PRINTF1(logMessageText); -#endif - switch(iEventSet++) - { - case 0: - iAnim=REventAnim::NewL(iQueueClient->iWin->BaseWin(), iAnimDll); - AddExpectedEvent(EEventFocusGained); - AddExpectedKeyAnim(TRawEvent::EKeyDown,32,ETrue); - AddExpectedKeyAnim(TRawEvent::EKeyUp,32,ETrue); - AddExpectedKeyAnim(TRawEvent::EKeyDown,33,EFalse); - AddExpectedKeyAnim(TRawEvent::EKeyUp,33,EFalse); - iTest->SimulateKey(TRawEvent::EKeyDown,32); - iTest->SimulateKey(TRawEvent::EKeyUp,32); - iTest->SimulateKey(TRawEvent::EKeyDown,33); - iTest->SimulateKey(TRawEvent::EKeyUp,33); - TheClient->iWs.Flush(); - if (iAnim->TestFail(4)) - Failed(); - break; - case 1: - iQueueClient->iWin->BaseWin()->PointerFilter(EPointerFilterMove|EPointerFilterDrag,0); - iQueueClient->iWin->BaseWin()->SetPointerGrab(EFalse); - iQueueClient->iWs.Flush(); - TheClient->iWs.SetPointerCursorArea(TRect(10,10,51,51)); - AddExpectedPointerAnim(TRawEvent::EButton1Down, TPoint(10,10)); - AddExpectedPointerAnim(TRawEvent::EButton1Up, TPoint(25,10)); - AddExpectedPointerAnim(TRawEvent::EButton1Down, TPoint(50,10)); - AddExpectedPointerAnim(TRawEvent::EButton1Up, TPoint(50,35)); - AddExpectedPointerAnim(TRawEvent::EButton1Down, TPoint(50,50)); - AddExpectedPointerAnim(TRawEvent::EButton1Up, TPoint(25,50)); - AddExpectedPointerAnim(TRawEvent::EButton1Down, TPoint(10,50)); - AddExpectedPointerAnim(TRawEvent::EButton1Up, TPoint(10,35)); - AddExpectedPointerAnim(TRawEvent::EButton1Down, TPoint(30,30),EFalse); - AddExpectedPointerAnim(TRawEvent::EButton1Up, TPoint(30,30),EFalse); - SimulatePointer(TRawEvent::EButton1Down,5,5); - SimulatePointer(TRawEvent::EButton1Up,25,5); - SimulatePointer(TRawEvent::EButton1Down,55,5); - SimulatePointer(TRawEvent::EButton1Up,55,35); - SimulatePointer(TRawEvent::EButton1Down,55,55); - SimulatePointer(TRawEvent::EButton1Up,25,55); - SimulatePointer(TRawEvent::EButton1Down,5,55); - SimulatePointer(TRawEvent::EButton1Up,5,35); - SimulatePointer(TRawEvent::EButton1Down,30,30); - SimulatePointer(TRawEvent::EButton1Up,30,30); - TheClient->iWs.Flush(); - if (iAnim->TestFail(10)) - Failed(); - break; - case 2: - { - #if defined(LOGGING) - _LIT(KLog," :2nd Set of Events Modes=0x%x"); - logMessageText.Format(KLog,iScreenModeTests); - INFO_PRINTF1(logMessageText); - #endif - TInt enforc=TheClient->iScreen->ScreenModeEnforcement(); - iBlankWin->SetVisible(ETrue); - TInt expectedEvents=0; - if (iScreenModeTests&EDoRot90 && enforc==ESizeEnforcementNone) - { - INFO_PRINTF1(_L(" :Rotation 90")); - TheClient->iScreen->SetScreenMode(1); - TheClient->iWs.Flush(); - iTest->DelayIfFullRomL(); - AddExpectedPointerAnim(TRawEvent::EButton1Down, TPoint(20,20-iYOffset)); - AddExpectedPointerAnim(TRawEvent::EButton1Up, TPoint(20,20-iYOffset)); - expectedEvents+=2; - TPoint screenModeOrigin=TheClient->iScreen->GetDefaultScreenModeOrigin(); - #if defined(__WINS__) - iTest->SimulatePointer(TRawEvent::EButton1Down,20+screenModeOrigin.iX,20+screenModeOrigin.iY); - iTest->SimulatePointer(TRawEvent::EButton1Up,20+screenModeOrigin.iX,20+screenModeOrigin.iY); - #else - // simulate pointer at (20,20) on rotated screen by providing physical coordinates - iTest->SimulatePointer(TRawEvent::EButton1Down,iPhysicalScreenSize.iWidth-1-20+screenModeOrigin.iX,20+screenModeOrigin.iY); - iTest->SimulatePointer(TRawEvent::EButton1Up,iPhysicalScreenSize.iWidth-1-20+screenModeOrigin.iX,20+screenModeOrigin.iY); - #endif - } - if (iScreenModeTests&EDoRot180) - { - INFO_PRINTF1(_L(" :Rotation 180")); - TheClient->iScreen->SetCurrentRotations(0,CFbsBitGc::EGraphicsOrientationRotated180); - TheClient->iScreen->SetScreenMode(0); - TheClient->iWs.Flush(); - iTest->DelayIfFullRomL(); - AddExpectedPointerAnim(TRawEvent::EButton1Down, TPoint(22,22-iYOffset)); - AddExpectedPointerAnim(TRawEvent::EButton1Up, TPoint(22,22-iYOffset)); - - expectedEvents+=2; - #if defined(__WINS__) - iTest->SimulatePointer(TRawEvent::EButton1Down,22,22); - iTest->SimulatePointer(TRawEvent::EButton1Up,22,22); - #else - // simulate pointer at (22,22) on rotated screen by providing physical coordinates - iTest->SimulatePointer(TRawEvent::EButton1Down,iPhysicalScreenSize.iWidth-1-22,iPhysicalScreenSize.iHeight-1-22); - iTest->SimulatePointer(TRawEvent::EButton1Up,iPhysicalScreenSize.iWidth-1-22,iPhysicalScreenSize.iHeight-1-22); - #endif - } - TheClient->iScreen->SetCurrentRotations(0,CFbsBitGc::EGraphicsOrientationNormal); - TheClient->iScreen->SetScreenMode(0); - TheClient->iWs.Flush(); - iTest->DelayIfFullRomL(); - if (iScreenModeTests&EDoRot0) - { - INFO_PRINTF1(_L(" :Rotation 0")); - AddExpectedPointerAnim(TRawEvent::EButton1Down, TPoint(24,24),EFalse); - AddExpectedPointerAnim(TRawEvent::EButton1Up, TPoint(24,24),EFalse); - expectedEvents+=2; - SimulatePointer(TRawEvent::EButton1Down,24,24); - SimulatePointer(TRawEvent::EButton1Up,24,24); - } - #if defined(LOGGING) - _LIT(KNumEvents," :Expected Number of Events=%d Actual=%d"); - logMessageText.Format(KNumEvents,expectedEvents,iAnim->GetNumEvents()); - INFO_PRINTF1(logMessageText); - _LIT(KError," :Error Value %d ('0'=OK)"); - logMessageText.Format(KError,iAnim->GetError()); - INFO_PRINTF1(logMessageText); - #endif - if (iAnim->TestFail(expectedEvents)) - Failed(); - User::After(EPointerCursorUpdateGap); - iBlankWin->SetVisible(EFalse); - INFO_PRINTF1(_L(" :Finished 2nd Set")); - } - break; - case 3: - iAnim->Destroy(); iAnim=NULL; - // Create an EventPostingAnim, key down & key up events are simulated. - // The event posting anim sees the key events in turn, and creates duplicates. - // Test checks that each simulated event is received twice. - TRAPD(err, iAnim=REventAnim::NewL(iQueueClient->iWin->BaseWin(), iAnimDll, REventAnimBase::EEventPostingAnim)); - if (err!=KErrNone) - { - Failed(); - return; - } - AddExpectedKeyAnim(TRawEvent::EKeyDown,32,ETrue); - AddExpectedKeyAnim(TRawEvent::EKeyDown,32,EFalse); - AddExpectedKeyAnim(TRawEvent::EKeyUp,32,ETrue); - AddExpectedKeyAnim(TRawEvent::EKeyUp,32,EFalse); - - iTest->SimulateKey(TRawEvent::EKeyDown,32); - iTest->SimulateKey(TRawEvent::EKeyUp,32); - break; - case 4: - // Simulate a key down event, which calls anim's offer raw event - // which inturn calls post key event with old and new API - // Test checks the repeat count for old and new API are as expected. - AddExpectedKeyAnim(TRawEvent::EKeyDown,45,ETrue); - - TKeyEvent event; - event.iCode='J'; - event.iScanCode=0; - event.iModifiers=0; - event.iRepeats=0; - AddExpectedKey(1, event.iScanCode, event.iCode, event.iRepeats, event.iModifiers); - event.iRepeats=2; - AddExpectedKey(1, event.iScanCode, event.iCode, event.iRepeats, event.iModifiers); - - iTest->SimulateKey(TRawEvent::EKeyDown,45); - break; - default: - iAnim->Destroy(); - iAnim=NULL; - CActiveScheduler::Stop(); - break; - } - TheClient->iWs.Flush(); - } - -void CTEventTest::FocusChanged_NextSetOfEventsL() - { -#if defined(LOGGING) - TLogMessageText logMessageText; - _LIT(KSet,"FocusChanged SetOfEvents: %d "); - logMessageText.Format(KSet,iEventSet); - INFO_PRINTF1(logMessageText); -#endif - switch(iEventSet++) - { - case 0: - { - _LIT(AutoFocusTest,"FocusEvents"); - iQueueClient->EnableFocusChangeEvents(); - iEventTestGroup2=new(ELeave) CTWindowGroup(TheClient); - iEventTestGroup2->ConstructL(); - iEventTestGroup2->GroupWin()->SetName(AutoFocusTest); - AddExpectedEvent(EEventFocusGained); - AddExpectedEvent(EEventFocusLost); - AddExpectedEvent(EEventFocusGroupChanged); - AddExpectedEvent(EEventWindowGroupsChanged); - } - break; - case 1: - iEventTestGroup2->GroupWin()->EnableReceiptOfFocus(EFalse); - AddExpectedEvent(EEventFocusGained); - AddExpectedEvent(EEventFocusGroupChanged); - break; - case 2: - iEventTestGroup2->GroupWin()->EnableReceiptOfFocus(ETrue); - AddExpectedEvent(EEventFocusLost); - AddExpectedEvent(EEventFocusGroupChanged); - break; - case 3: - iEventTestGroup2->GroupWin()->SetOrdinalPosition(999); - AddExpectedEvent(EEventFocusGained); - AddExpectedEvent(EEventFocusGroupChanged); - break; - case 4: - iEventTestGroup2->GroupWin()->SetOrdinalPosition(0); - AddExpectedEvent(EEventFocusLost); - AddExpectedEvent(EEventFocusGroupChanged); - break; - case 5: - delete iEventTestGroup2; - iEventTestGroup2=NULL; - AddExpectedEvent(EEventWindowGroupsChanged); - AddExpectedEvent(EEventFocusGroupChanged); - break; - default: - CActiveScheduler::Stop(); - break; - } - TheClient->iWs.Flush(); - } - - -void CTEventTest::StopEvents_NextSetOfEventsL() - { - // we are not running tests 0,1,2 as they currently fail - if(iEventSet==0) - { - iEventSet=3; - AddExpectedEvent(EEventFocusGained); - } - TInt retVal = KErrNone; - - switch(iEventSet++) - { - case 0: // doesn't work if shell gets the off events - will fail on User::LeaveIfError(.... - iQueueClient->iWs.Flush(); - User::LeaveIfError(iQueueClient->iWs.RequestOffEvents(ETrue,iQueueClient->iGroup->WinTreeNode())); - iTest->SimulateEvent(TRawEvent::ESwitchOff); - TheClient->iWs.Flush(); - retVal = iQueueClient->iWs.RequestOffEvents(ETrue,iQueueClient->iWin->WinTreeNode()); - TEST(retVal==KErrAlreadyExists); - if (retVal!=KErrAlreadyExists) - INFO_PRINTF3(_L("iQueueClient->iWs.RequestOffEvents(ETrue,iQueueClient->iWin->WinTreeNode()) return value - Expected: %d, Actual: %d"), KErrAlreadyExists, retVal); - User::LeaveIfError(iQueueClient->iWs.RequestOffEvents(EFalse,iQueueClient->iGroup->WinTreeNode())); - User::LeaveIfError(iQueueClient->iWs.RequestOffEvents(ETrue,iQueueClient->iGroup->WinTreeNode())); - iTest->SimulateEvent(TRawEvent::ESwitchOff); - TheClient->iWs.Flush(); - retVal = iQueueClient->iWs.RequestOffEvents(ETrue,iQueueClient->iGroup->WinTreeNode()); - TEST(retVal==KErrAlreadyExists); - if (retVal!=KErrAlreadyExists) - INFO_PRINTF3(_L("iQueueClient->iWs.RequestOffEvents(ETrue,iQueueClient->iGroup->WinTreeNode()) return value - Expected: %d, Actual: %d"), KErrAlreadyExists, retVal); - User::LeaveIfError(iQueueClient->iWs.RequestOffEvents(EFalse)); - AddExpectedEvent(EEventFocusGained); - AddExpectedEvent(EEventSwitchOff); - AddExpectedEvent(EEventSwitchOff); - break; - - case 1: // doesn't work if shell gets the off events - will fail on User::LeaveIfError(.... - { - TKeyEvent event; - iQueueClient->iWs.Flush(); - User::LeaveIfError(iQueueClient->iWs.RequestOffEvents(ETrue,iQueueClient->iGroup->WinTreeNode())); - event.iCode=EKeyOff; - event.iScanCode=EKeyOff; - event.iModifiers=0; - event.iRepeats=0; - TheClient->iWs.SimulateKeyEvent(event); - TheClient->iWs.Flush(); - User::LeaveIfError(iQueueClient->iWs.RequestOffEvents(EFalse)); - AddExpectedEvent(EEventKeySwitchOff); - } - break; - - case 2: // doesn't work if shell gets the off events - will fail on User::LeaveIfError(.... - { - TKeyEvent event; - event.iCode=EKeyOff; - event.iScanCode=EKeyOff; - event.iModifiers=0; - event.iRepeats=0; - iQueueClient->iWs.Flush(); - User::LeaveIfError(iQueueClient->iWs.RequestOffEvents(ETrue,iQueueClient->iGroup->WinTreeNode())); - iTest->SimulateEvent(TRawEvent::ESwitchOff); - TheClient->iWs.SimulateKeyEvent(event); - iTest->SimulateEvent(TRawEvent::ECaseClose); - TheClient->iWs.Flush(); - retVal = iQueueClient->iWs.RequestOffEvents(ETrue,iQueueClient->iWin->WinTreeNode()); - TEST(retVal==KErrAlreadyExists); - if (retVal!=KErrAlreadyExists) - INFO_PRINTF3(_L("iQueueClient->iWs.RequestOffEvents(ETrue,iQueueClient->iWin->WinTreeNode()) return value - Expected: %d, Actual: %d"), KErrAlreadyExists, retVal); - iTest->SimulateEvent(TRawEvent::ESwitchOff); - iTest->SimulateEvent(TRawEvent::ECaseClose); - TheClient->iWs.SimulateKeyEvent(event); - TheClient->iWs.Flush(); - User::LeaveIfError(iQueueClient->iWs.RequestOffEvents(EFalse,iQueueClient->iGroup->WinTreeNode())); - User::LeaveIfError(iQueueClient->iWs.RequestOffEvents(ETrue,iQueueClient->iWin->WinTreeNode())); - iTest->SimulateEvent(TRawEvent::ECaseClose); - iTest->SimulateEvent(TRawEvent::ESwitchOff); - TheClient->iWs.SimulateKeyEvent(event); - TheClient->iWs.Flush(); - User::LeaveIfError(iQueueClient->iWs.RequestOffEvents(EFalse)); - User::LeaveIfError(iQueueClient->iWs.RequestOffEvents(ETrue,iQueueClient->iChildWin->WinTreeNode())); - iTest->SimulateEvent(TRawEvent::ESwitchOff); - TheClient->iWs.SimulateKeyEvent(event); - iTest->SimulateEvent(TRawEvent::ECaseClose); - TheClient->iWs.Flush(); - User::LeaveIfError(iQueueClient->iWs.RequestOffEvents(EFalse)); - AddExpectedEvent(EEventSwitchOff); - AddExpectedEvent(EEventKeySwitchOff); - AddExpectedEvent(EEventCaseClosed); - AddExpectedEvent(EEventSwitchOff); - AddExpectedEvent(EEventCaseClosed); - AddExpectedEvent(EEventKeySwitchOff); - AddExpectedEvent(EEventCaseClosed,iQueueClient->iWin); - AddExpectedEvent(EEventSwitchOff,iQueueClient->iWin); - AddExpectedEvent(EEventKeySwitchOff,iQueueClient->iWin); - AddExpectedEvent(EEventSwitchOff,iQueueClient->iChildWin); - AddExpectedEvent(EEventKeySwitchOff,iQueueClient->iChildWin); - AddExpectedEvent(EEventCaseClosed,iQueueClient->iChildWin); - } - break; - - case 3: - iQueueClient->iWs.Flush(); - //User::LeaveIfError(iQueueClient->iGroup->WinTreeNode()->EnableOnEvents(EEventControlAlways)); - iTest->SimulateEvent(TRawEvent::ESwitchOn); - iTest->SimulateEvent(TRawEvent::ECaseOpen); - TheClient->iWs.Flush(); - User::LeaveIfError(iQueueClient->iWin->WinTreeNode()->EnableOnEvents(EEventControlAlways)); - iTest->SimulateEvent(TRawEvent::ECaseOpen); - iTest->SimulateEvent(TRawEvent::ESwitchOn); - TheClient->iWs.Flush(); - iQueueClient->iWin->WinTreeNode()->DisableOnEvents(); - AddExpectedEvent(EEventSwitchOn); - //AddExpectedEvent(EEventSwitchOn); - AddExpectedEvent(EEventCaseOpened); - AddExpectedEvent(EEventCaseOpened,iQueueClient->iWin); - AddExpectedEvent(EEventCaseOpened); - AddExpectedEvent(EEventSwitchOn,iQueueClient->iWin); - AddExpectedEvent(EEventSwitchOn); - break; - - case 4: - iQueueClient->iWs.Flush(); - // switch off the device - iTest->SimulateEvent(TRawEvent::ESwitchOff); - // switch it back on. - iTest->SimulateEvent(TRawEvent::ESwitchOn); - TheClient->iWs.Flush(); - // TRawEvent::ESwitchOff never actually comes back. The tests will hang if we look for one - AddExpectedEvent(EEventSwitchOn); - break; - - case 5: - { - TKeyEvent event; - iQueueClient->iWs.Flush(); - event.iCode=EKeyOff; - event.iScanCode=EKeyOff; - event.iModifiers=0; - event.iRepeats=0; - // switch off the device - this one seems to send it to standby rather than off - TheClient->iWs.SimulateKeyEvent(event); - // switch it back on or no further tests will complete - iTest->SimulateEvent(TRawEvent::ESwitchOn); - TheClient->iWs.Flush(); - // again we would expect EEventKeySwitchOff but it doesn't come back. The tests will hang if we look for one - AddExpectedEvent(EEventSwitchOn); - } - break; - - case 6: - iQueueClient->iWs.Flush(); - iTest->SimulateEvent(TRawEvent::ESwitchOn); - iTest->SimulateEvent(TRawEvent::ECaseOpen); - TheClient->iWs.Flush(); - User::LeaveIfError(iQueueClient->iWin->WinTreeNode()->EnableOnEvents(EEventControlAlways)); - iTest->SimulateEvent(TRawEvent::ECaseOpen); - iTest->SimulateEvent(TRawEvent::ESwitchOn); - TheClient->iWs.Flush(); - iQueueClient->iWin->WinTreeNode()->DisableOnEvents(); - AddExpectedEvent(EEventSwitchOn); - AddExpectedEvent(EEventCaseOpened); - AddExpectedEvent(EEventCaseOpened,iQueueClient->iWin); - AddExpectedEvent(EEventCaseOpened); - AddExpectedEvent(EEventSwitchOn,iQueueClient->iWin); - AddExpectedEvent(EEventSwitchOn); - break; - - default: - CActiveScheduler::Stop(); - break; - } - TheClient->iWs.Flush(); - } - -void CTEventTest::VirtualKeyboard_NextSetOfEventsL() - { - const TInt noVirtualKeys=10; - const TInt keyWidth=2*EWinWidth/noVirtualKeys/3; - const TInt keyHeight=EWinHeight/2; - const TInt keySpacing=EWinWidth/noVirtualKeys; - const TInt baseChar='1'; - TInt startX=1; - TInt ii; - switch(iEventSet++) - { - case 0: - iQueueClient->iWin->BaseWin()->SetPointerGrab(EFalse); - for (ii=0;iiiWin->BaseWin()->AddKeyRect(TRect(startX,1,startX+keyWidth,keyHeight),baseChar+ii,EFalse); - startX+=keySpacing; - } - iQueueClient->iWs.Flush(); - iTest->SimulatePointerDownUp(EWinPositionX+1,EWinPositionY+1+iYOffset); - //TheClient->iWs.Flush(); - AddExpectedEvent(EEventFocusGained); - AddExpectedKeyDownUp(baseChar); - break; - case 1: - startX=3; - for (ii=0;iiSimulatePointerDownUp(startX+EWinPositionX+1,EWinPositionY+keyHeight-1+iYOffset); - AddExpectedKeyDownUp(baseChar+ii); - startX+=keySpacing; - } - break; - case 2: - SimulatePointerDownUpWin(keySpacing+1,1); - //SimulatePointerDownUp(EWinPositionX+keySpacing+1,EWinPositionY+1); - iTest->SimulatePointerDownUp(EWinPositionX+keyWidth,EWinPositionY+1+iYOffset); - iTest->SimulatePointerDownUp(EWinPositionX+1,EWinPositionY+keyHeight-1+iYOffset); - iTest->SimulatePointerDownUp(EWinPositionX+keyWidth,EWinPositionY+keyHeight-1+iYOffset); - AddExpectedKeyDownUp(baseChar+1); - AddExpectedKeyDownUp(baseChar); - AddExpectedKeyDownUp(baseChar); - AddExpectedKeyDownUp(baseChar); - break; - case 3: - SimulatePointerDownUpWin(keySpacing+3,4); - SimulatePointerDownUpWin(0,0); //No Pointer event get through even if there are gaps - SimulatePointerDownUpWin(1,0); - SimulatePointerDownUpWin(0,1); - SimulatePointerDownUpWin(keyWidth+1,0); - SimulatePointerDownUpWin(keyWidth,0); - SimulatePointerDownUpWin(keyWidth+1,1); - SimulatePointerDownUpWin(0,keyHeight); - SimulatePointerDownUpWin(1,keyHeight); - SimulatePointerDownUpWin(0,keyHeight-1); - SimulatePointerDownUpWin(keyWidth+1,keyHeight); - SimulatePointerDownUpWin(keyWidth,keyHeight); - SimulatePointerDownUpWin(keyWidth+1,keyHeight-1); - SimulatePointerDownUpWin(2*keySpacing+3,4); - AddExpectedKeyDownUp(baseChar+1); - AddExpectedPointerDownUpScr(TPoint(EWinPositionX+0,EWinPositionY+0)); //No Pointer event get through even if there are gaps - AddExpectedPointerDownUpScr(TPoint(EWinPositionX+1,EWinPositionY+0)); - AddExpectedPointerDownUpScr(TPoint(EWinPositionX+0,EWinPositionY+1)); - AddExpectedPointerDownUpScr(TPoint(EWinPositionX+keyWidth+1,EWinPositionY+0)); - AddExpectedPointerDownUpScr(TPoint(EWinPositionX+keyWidth,EWinPositionY+0)); - AddExpectedPointerDownUpScr(TPoint(EWinPositionX+keyWidth+1,EWinPositionY+1)); - AddExpectedPointerDownUpScr(TPoint(EWinPositionX+0,EWinPositionY+keyHeight)); - AddExpectedPointerDownUpScr(TPoint(EWinPositionX+1,EWinPositionY+keyHeight)); - AddExpectedPointerDownUpScr(TPoint(EWinPositionX+0,EWinPositionY+keyHeight-1)); - AddExpectedPointerDownUpScr(TPoint(EWinPositionX+keyWidth+1,EWinPositionY+keyHeight)); - AddExpectedPointerDownUpScr(TPoint(EWinPositionX+keyWidth,EWinPositionY+keyHeight)); - AddExpectedPointerDownUpScr(TPoint(EWinPositionX+keyWidth+1,EWinPositionY+keyHeight-1)); - AddExpectedKeyDownUp(baseChar+2); - break; - case 4: - SimulatePointerWin(TRawEvent::EButton1Down,keySpacing+2,6); - SimulatePointerWin(TRawEvent::EButton1Up,2*keySpacing+1,5); - SimulatePointerWin(TRawEvent::EButton1Down,2*keySpacing+2,7); - SimulatePointer(TRawEvent::EButton1Up,0,0); - AddExpectedKeyDownUp(baseChar+1); - AddExpectedKeyDownUp(baseChar+2); - break; - default: - CActiveScheduler::Stop(); - break; - } - TheClient->iWs.Flush(); - } - -TInt CTEventTest::ClickCommandReply(TInt aCommand,TInt aData) - { - TPckgBuf intPkg; - intPkg()=aData; - return iClick.CommandReply(aCommand,intPkg); - } - -TInt CTEventTest::CreateGroupWindow(RWindowGroup& aWinGp,TClients aClient,TInt& aWinGpId) - { - ClickCommandReply(EClickCreateGroupWin,aClient); - TInt err=aWinGp.Construct(ENullWsHandle,EFalse); - if (!err) - { - aWinGpId=aWinGp.Identifier(); - ClickCommandReply(EClickCheckGpWinId,aWinGpId); - } - return err; - } - -void CTEventTest::CloseGroupWindow(RWindowGroup& aWinGp,TInt aWinGpId) - { - ClickCommandReply(EClickCloseGroupWin,aWinGpId); - aWinGp.Close(); - } - -void CTEventTest::CloseWindow(RWindowBase& aWin,TInt aHandle,TInt aWinGpId) - { - TPckgBuf winClose; - winClose().iClientHandle=aHandle; - winClose().iWindowGroupId=aWinGpId; - iClick.CommandReply(EClickCloseWin,winClose); - aWin.Close(); - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-0447 - -@SYMCR CR1164 - -@SYMTestCaseDesc Tests that Key Click Plug-in gets new event Information - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Do things that cause the new events to be sent into plug-in. -Creating destroying windows, pointer events. Provide test plug-in with information it needs to check events. - -@SYMTestExpectedResults When Test Plug-in is querried to see if events match what was expected it says that they were. -*/ -void CTEventTest::KeyClicks_NextSetOfEvents() - { -#if defined(LOGGING) - TLogMessageText logMessageText; - _LIT(KSet,"KeyClicks SetOfEvents: %d (last=13)"); - logMessageText.Format(KSet,iEventSet); - INFO_PRINTF1(logMessageText); -#endif - TInt events=-1; - switch(iEventSet++) - { - case 0: - if (SetClickType(EClickCheck)) - return; - iAddToClick=ETrue; - iQueueClient->iWin->BaseWin()->SetPointerGrab(EFalse); - iQueueClient->iChildWin->BaseWin()->SetPointerGrab(EFalse); - AddExpectedEvent(EEventFocusGained); - AddExpectedKeyDownUp(EStdKeySpace,EKeySpace); - iQueueClient->iWs.Flush(); - iTest->SimulateKeyDownUp(EStdKeySpace); //3 events - events=3; - break; - case 1: - AddExpectedKeyDownUp(EStdKeyEnter,EKeyEnter); - AddExpectedKeyDownUp('0'); - AddExpectedKeyDownUp('A','a'); - AddExpectedKeyDownUp('X','x'); - AddExpectedKey(EEventKeyDown,EStdKeyLeftShift,0,0,EModifierLeftShift|EModifierShift); - AddExpectedKey(EEventKeyUp,EStdKeyLeftShift); - iQueueClient->iWs.Flush(); - iTest->SimulateKeyDownUp(EStdKeyEnter); //3 events - iTest->SimulateKeyDownUp('0'); //3 events - iTest->SimulateKeyDownUp('A'); //3 events - iTest->SimulateKeyDownUp('X'); //3 events - iTest->SimulateKeyDownUp(EStdKeyLeftShift); //2 events - events=14; - break; - case 2: - AddExpectedKey(EEventKeyDown,EStdKeyRightShift,0,0,EModifierRightShift|EModifierShift); - AddExpectedKeyDownUp('B','B',0,EModifierRightShift|EModifierShift); - AddExpectedKeyDownUp('W','W',0,EModifierRightShift|EModifierShift); - AddExpectedKey(EEventKeyUp,EStdKeyRightShift); - iQueueClient->iWs.Flush(); - iTest->SimulateKey(TRawEvent::EKeyDown,EStdKeyRightShift); //1 event - iTest->SimulateKeyDownUp('B'); //3 events - iTest->SimulateKeyDownUp('W'); //3 events - iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeyRightShift); //1 event - events=8; - break; - case 3: - AddExpectedKey(EEventKeyDown,'C'); - AddExpectedKey(EEventKey,'C','c'); - AddExpectedKey(EEventKeyDown,'V'); - AddExpectedKey(EEventKey,'V','v'); - AddExpectedKey(EEventKeyUp,'C'); - AddExpectedKey(EEventKeyUp,'V'); - iQueueClient->iWs.Flush(); - iTest->SimulateKey(TRawEvent::EKeyDown,'C'); //2 events - iTest->SimulateKey(TRawEvent::EKeyDown,'V'); //2 events - iTest->SimulateKey(TRawEvent::EKeyUp,'C'); //1 event - iTest->SimulateKey(TRawEvent::EKeyUp,'V'); //1 event - events=6; - break; - case 4: - { - AddExpectedKey(EEventKeyDown,'D'); - AddExpectedKey(EEventKey,'D','d'); - AddExpectedKey(EEventKey,'D','d',1); - AddExpectedKey(EEventKeyUp,'D'); - iQueueClient->iWs.Flush(); - iTest->SimulateKey(TRawEvent::EKeyDown,'D'); //2 events - TTimeIntervalMicroSeconds32 initialTime,time; - TheClient->iWs.GetKeyboardRepeatRate(initialTime,time); - User::After(initialTime.Int()+time.Int()/4); //1 event - iTest->SimulateKey(TRawEvent::EKeyUp,'D'); //1 event - events=4; - } - break; - case 5: - AddExpectedPointerDownUpScr(TPoint(40,25)); - AddExpectedPointerDownUpScr(TPoint(95,30)); - AddExpectedPointer(TPointerEvent::EButton1Down,TPoint(20-EWinPositionX,50-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EDrag,TPoint(45-EWinPositionX,42-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Up,TPoint(45-EWinPositionX,42-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Down,TPoint(98-EWinPositionX,15-EWinPositionY)); - AddExpectedPointerClick(TPointerEvent::EDrag,TPoint(68-EWinPositionX,39-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EDrag,TPoint(41-EWinPositionX,42-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Up,TPoint(50-EWinPositionX,58-EWinPositionY)); - iQueueClient->iWs.Flush(); - iTest->SimulatePointerDownUp(40,25+iYOffset); //2 events - iTest->SimulatePointerDownUp(95,30+iYOffset); //2 events - SimulatePointer(TRawEvent::EButton1Down,20,50); //1 event - SimulatePointer(TRawEvent::EPointerMove,45,42); //1 event - SimulatePointer(TRawEvent::EButton1Up,45,42); //1 event - SimulatePointer(TRawEvent::EButton1Down,98,15); //1 event - SimulatePointer(TRawEvent::EPointerMove,68,39); //1 event - SimulatePointer(TRawEvent::EPointerMove,41,42); //1 event - SimulatePointer(TRawEvent::EButton1Up,50,58); //1 event - events=11; - break; - case 6: - AddExpectedKey(EEventKeyDown,'E'); - AddExpectedKey(EEventKey,'E','e'); - AddExpectedPointerDownUpScr(TPoint(41,24)); - AddExpectedKey(EEventKeyUp,'E'); - AddExpectedPointer(TPointerEvent::EButton1Down,TPoint(23-EWinPositionX,52-EWinPositionY)); - AddExpectedKeyDownUp('1'); - AddExpectedPointer(TPointerEvent::EButton1Up,TPoint(44-EWinPositionX,45-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Down,TPoint(33-EWinPositionX,53-EWinPositionY)); - AddExpectedKey(EEventKeyDown,'F'); - AddExpectedKey(EEventKey,'F','f'); - AddExpectedPointer(TPointerEvent::EButton1Up,TPoint(34-EWinPositionX,47-EWinPositionY)); - AddExpectedKey(EEventKeyUp,'F'); - iQueueClient->iWs.Flush(); - iTest->SimulateKey(TRawEvent::EKeyDown,'E'); //2 events - iTest->SimulatePointerDownUp(41,24+iYOffset); //2 events - iTest->SimulateKey(TRawEvent::EKeyUp,'E'); //1 event - SimulatePointer(TRawEvent::EButton1Down,23,52); //1 event - iTest->SimulateKeyDownUp('1'); //3 events - SimulatePointer(TRawEvent::EButton1Up,44,45); //1 event - SimulatePointer(TRawEvent::EButton1Down,33,53); //1 event - iTest->SimulateKey(TRawEvent::EKeyDown,'F'); //2 events - SimulatePointer(TRawEvent::EButton1Up,34,47); //1 event - iTest->SimulateKey(TRawEvent::EKeyUp,'F'); //1 event - events=15; - break; - case 7: - AddExpectedKeyDownUp('2'); - iAddToClick=EFalse; - AddExpectedKeyDownUp('G','g'); - iAddToClick=ETrue; - AddExpectedPointerDownUpScr(TPoint(42,26)); - AddExpectedKeyDownUp('U','u'); - iQueueClient->iWs.Flush(); - iTest->SimulateKeyDownUp('2'); //3 events - TheClient->iWs.Flush(); - iQueueClient->iGroup->GroupWin()->DisableKeyClick(ETrue); - iQueueClient->iWs.Flush(); - iTest->SimulateKeyDownUp('G'); - iTest->SimulatePointerDownUp(42,26+iYOffset); //2 events - TheClient->iWs.Flush(); - iQueueClient->iGroup->GroupWin()->DisableKeyClick(EFalse); - iQueueClient->iWs.Flush(); - iTest->SimulateKeyDownUp('U'); //3 events - events=8; - break; - case 8: - { - TPckgBuf pointerEventInfo; - pointerEventInfo().iClientHandle=reinterpret_cast(iQueueClient->iChildWin); - pointerEventInfo().iWinGpId=iQueueClient->iGroup->GroupWin()->Identifier(); - pointerEventInfo().iWinOrigin=iQueueClient->ChildTopLeft(); - pointerEventInfo().iParentOrigin.SetXY(EWinPositionX,EWinPositionY); - iClick.CommandReply(EClickPointerEvent,pointerEventInfo); - AddExpectedKeyDownUp('3'); - AddExpectedPointerDownUpScr(TPoint(43,26)); - AddExpectedKeyDownUp('H','h'); - iAddToClick=EFalse; - AddExpectedPointerDownUpScr(TPoint(43,27)); - AddExpectedKeyDownUp('4'); - AddExpectedPointerDownUpScr(TPoint(42,27)); - AddExpectedKeyDownUp('I','i'); - iAddToClick=ETrue; - AddExpectedPointerDownUpScr(TPoint(44,27)); - AddExpectedKeyDownUp('5'); - AddExpectedPointerDownUpScr(TPoint(44,26)); - iQueueClient->iWs.Flush(); - iTest->SimulateKeyDownUp('3'); //3 events - iTest->SimulatePointerDownUp(43,26+iYOffset); //2 events - iClick.SetPenClick(EFalse); - iTest->SimulateKeyDownUp('H'); //3 events - iTest->SimulatePointerDownUp(43,27+iYOffset); - iClick.SetKeyClick(EFalse); - iTest->SimulateKeyDownUp('4'); - iTest->SimulatePointerDownUp(42,27+iYOffset); - iClick.SetPenClick(ETrue); - iTest->SimulateKeyDownUp('I'); - iTest->SimulatePointerDownUp(44,27+iYOffset); //2 events - iClick.SetKeyClick(ETrue); - iTest->SimulateKeyDownUp('5'); //3 events - iTest->SimulatePointerDownUp(44,26+iYOffset); //2 events - pointerEventInfo().iClientHandle=0; - pointerEventInfo().iWinGpId=0; - iClick.CommandReply(EClickPointerEvent,pointerEventInfo); - events=15; - } - break; - case 9: - { - RWindowGroup winGp(iQueueClient->iWs); - TInt winGpId; - TInt ii; - AddExpectedEvent(EEventWindowGroupsChanged); - for (ii=0;ii<2;++ii) //events x2 - { - if (CreateGroupWindow(winGp,EQueueClient,winGpId)) //1 event - Failed(); - CloseGroupWindow(winGp,winGpId); //1 event - iQueueClient->iWs.Flush(); - } - events=4; - } - break; - case 10: - { - RWindowGroup winGp(TheClient->iWs); - RWindowGroup winGp1(iQueueClient->iWs); - RWindowGroup winGp2(iQueueClient->iWs); - TInt winGpId; - TInt winGpId1; - TInt winGpId2; - AddExpectedEvent(EEventWindowGroupsChanged); - if (CreateGroupWindow(winGp,ETheClient,winGpId)) //1 event - Failed(); - CloseGroupWindow(winGp,winGpId); //1 event - TheClient->iWs.Flush(); - if (CreateGroupWindow(winGp1,EQueueClient,winGpId1)) //1 event - Failed(); - if (CreateGroupWindow(winGp2,EQueueClient,winGpId2)) //1 event - Failed(); - if (CreateGroupWindow(winGp,ETheClient,winGpId)) //1 event - Failed(); - CloseGroupWindow(winGp2,winGpId2); //1 event - iQueueClient->iWs.Flush(); - CloseGroupWindow(winGp,winGpId); //1 event - TheClient->iWs.Flush(); - CloseGroupWindow(winGp1,winGpId1); //1 event - iQueueClient->iWs.Flush(); - events=8; - } - break; - case 11: - { - RWindowGroup winGp(iQueueClient->iWs); - TInt winGpId; - AddExpectedEvent(EEventWindowGroupsChanged); - if (CreateGroupWindow(winGp,EQueueClient,winGpId)) //1 event - Failed(); - RWindow win(iQueueClient->iWs); - const TInt handle=79; - if (win.Construct(winGp,handle)) - Failed(); - win.Activate(); - CloseWindow(win,handle,winGpId); //1 event - iQueueClient->iWs.Flush(); - CloseGroupWindow(winGp,winGpId); //1 event - iQueueClient->iWs.Flush(); - events=3; - } - break; - case 12: - { - RWindowGroup winGp1(iQueueClient->iWs); - RWindowGroup winGp2(TheClient->iWs); - TInt winGpId1; - TInt winGpId2; - AddExpectedEvent(EEventWindowGroupsChanged); - if (CreateGroupWindow(winGp2,ETheClient,winGpId2)) //1 event - Failed(); - if (CreateGroupWindow(winGp1,EQueueClient,winGpId1)) //1 event - Failed(); - RWindow win1(iQueueClient->iWs); - RWindow win2(iQueueClient->iWs); - RWindow win(TheClient->iWs); - const TInt handle1a=80; - const TInt handle1b=81; - const TInt handle2a=82; - const TInt handle2b=83; - const TInt handle=84; - if (win1.Construct(winGp1,handle1a)) - Failed(); - win1.Activate(); - if (win2.Construct(win1,handle2a)) - Failed(); - win2.Activate(); - if (win.Construct(winGp2,handle)) - Failed(); - win.Activate(); - CloseWindow(win2,handle2a,winGpId1); //1 event - iQueueClient->iWs.Flush(); - if (win2.Construct(winGp1,handle2b)) - Failed(); - win2.Activate(); - CloseWindow(win1,handle1a,winGpId1); //1 event - iQueueClient->iWs.Flush(); - CloseWindow(win,handle,winGpId2); //1 event - TheClient->iWs.Flush(); - if (win1.Construct(win2,handle1b)) - Failed(); - win1.Activate(); - CloseWindow(win1,handle1b,winGpId1); //1 event - iQueueClient->iWs.Flush(); - CloseGroupWindow(winGp2,winGpId2); //1 event - TheClient->iWs.Flush(); - CloseWindow(win2,handle2b,winGpId1); //1 event - iQueueClient->iWs.Flush(); - CloseGroupWindow(winGp1,winGpId1); //1 event - iQueueClient->iWs.Flush(); - events=9; - } - break; - case 13: - { - TPckgBuf pointerEventInfo; - pointerEventInfo().iClientHandle=reinterpret_cast(iQueueClient->iWin); - pointerEventInfo().iWinGpId=iQueueClient->iGroup->GroupWin()->Identifier(); - pointerEventInfo().iWinOrigin.SetXY(EWinPositionX,EWinPositionY); - pointerEventInfo().iParentOrigin.SetXY(0,0); - iClick.CommandReply(EClickPointerEvent,pointerEventInfo); - AddExpectedPointerDownUpScr(TPoint(43,18)); - AddExpectedPointerDownUpScr(TPoint(43,17)); - AddExpectedPointerDownUpScr(TPoint(42,52)); - AddExpectedPointerDownUpScr(TPoint(24,27)); - AddExpectedPointerDownUpScr(TPoint(94,26)); - iQueueClient->iWs.Flush(); - iTest->SimulatePointerDownUp(43,18+iYOffset); //2 events - iTest->SimulatePointerDownUp(43,17+iYOffset); //2 events - iTest->SimulatePointerDownUp(42,52+iYOffset); //2 events - iTest->SimulatePointerDownUp(24,27+iYOffset); //2 events - iTest->SimulatePointerDownUp(94,26+iYOffset); //2 events - pointerEventInfo().iClientHandle=0; - pointerEventInfo().iWinGpId=0; - iClick.CommandReply(EClickPointerEvent,pointerEventInfo); - events=10; - } - break; - default: - iAddToClick=EFalse; - if (!SetClickType(EClickNone)) - CActiveScheduler::Stop(); - return; - } - TInt failedAt=iClick.CommandReply(EClickFailed,TPtrC8(NULL,0)); - TInt eventsDone=iClick.CommandReply(EClickEvents,TPtrC8(NULL,0)); - if (failedAt!=0 || eventsDone!=events) //iEventSet (already incremented) - { - #if defined(LOGGING) - _LIT(KeyClickFailed,"KeyClick Failed EventSet=%d FailedAt=%d TotalEvents=%d EventsDone=%d"); - logMessageText.Format(KeyClickFailed,iEventSet-1,failedAt,events,eventsDone); - INFO_PRINTF1(logMessageText); - #endif - Failed(); - } - iClick.CommandReply(EClickReset,TPtrC8(NULL,0)); - } - -void CTEventTest::CaptureLong_NextSetOfEventsL() - { - TTimeIntervalMicroSeconds32 initialTime,time; - TheClient->iWs.GetKeyboardRepeatRate(initialTime,time); - #if defined(LOGGING) - TLogMessageText logMessageText; - _LIT(KSet,"CaptureLong SetOfEvents: %d of 14"); - logMessageText.Format(KSet,iEventSet); - INFO_PRINTF1(logMessageText); - #endif - - switch(iEventSet++) - { - case 0: - iQueueClient->iWs.Flush(); - iTest->SimulateKeyDownUp('A'); - AddExpectedEvent(EEventFocusGained); - AddExpectedKeyDownUp('A','a'); - break; - case 1: - iCaptureKey=iQueueClient->iGroup->GroupWin()->CaptureLongKey(' ','a',0,0,2,ELongCaptureNormal); - iQueueClient->iWs.Flush(); - iTest->SimulateKey(TRawEvent::EKeyDown,EStdKeySpace); - TheClient->iWs.Flush(); - User::After(initialTime.Int()+time.Int()/3); - iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeySpace); - AddExpectedKey(EEventKeyDown,EStdKeySpace); - AddExpectedKey(EEventKey,EStdKeySpace,' '); - AddExpectedKey(EEventKey,EStdKeySpace,'a',1); - AddExpectedKey(EEventKeyUp,EStdKeySpace); - iQueueClient->iGroup->GroupWin()->CancelCaptureLongKey(iCaptureKey); - break; - case 2: - iCaptureKey=iQueueClient->iGroup->GroupWin()->CaptureLongKey(' ','a',0,0,2,ELongCaptureWaitShort); - iQueueClient->iWs.Flush(); - iTest->SimulateKey(TRawEvent::EKeyDown,EStdKeySpace); - TheClient->iWs.Flush(); - User::After(initialTime.Int()+time.Int()/3); - iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeySpace); - iTest->SimulateKeyDownUp(EStdKeySpace); - AddExpectedKey(EEventKeyDown,EStdKeySpace); - AddExpectedKey(EEventKey,EStdKeySpace,'a',1); - AddExpectedKey(EEventKeyUp,EStdKeySpace); - AddExpectedKeyDownUp(EStdKeySpace,' '); - iQueueClient->iGroup->GroupWin()->CancelCaptureLongKey(iCaptureKey); - break; - case 3: - iCaptureKey=iQueueClient->iGroup->GroupWin()->CaptureLongKey(' ','a',0,0,2,ELongCaptureNormal|ELongCaptureRepeatEvents); - iQueueClient->iWs.Flush(); - iTest->SimulateKey(TRawEvent::EKeyDown,EStdKeySpace); - TheClient->iWs.Flush(); - User::After(initialTime.Int()+5*time.Int()); - iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeySpace); - AddExpectedKey(EEventKeyDown,EStdKeySpace); - AddExpectedKey(EEventKey,EStdKeySpace,' '); - AddExpectedKey(EEventKey,EStdKeySpace,'a',2); - AddExpectedKey(EEventKeyUp,EStdKeySpace); - iQueueClient->iGroup->GroupWin()->CancelCaptureLongKey(iCaptureKey); - break; - case 4: - iQueueClient->iWs.Flush(); - iTest->SimulateKey(TRawEvent::EKeyDown,'Z'); - TheClient->iWs.Flush(); - User::After(initialTime.Int()+3*time.Int()); - iTest->SimulateKey(TRawEvent::EKeyDown,'Y'); - TheClient->iWs.Flush(); - User::After(initialTime.Int()+2*time.Int()); - iTest->SimulateKey(TRawEvent::EKeyUp,'Z'); - iTest->SimulateKey(TRawEvent::EKeyUp,'Y'); - AddExpectedKey(EEventKeyDown,'Z'); - AddExpectedKey(EEventKey,'Z','z'); - AddExpectedKey(EEventKey,'Z','z',1); - AddExpectedKey(EEventKeyDown,'Y'); - AddExpectedKey(EEventKey,'Y','y'); - AddExpectedKey(EEventKey,'Y','y',1); - AddExpectedKey(EEventKeyUp,'Z'); - AddExpectedKey(EEventKeyUp,'Y'); - break; - case 5: - iQueueClient->iWs.Flush(); - iTest->SimulateKey(TRawEvent::EKeyDown,'Z'); - TheClient->iWs.Flush(); - User::After(initialTime.Int()+3*time.Int()); - iTest->SimulateKey(TRawEvent::EKeyDown,'Y'); - TheClient->iWs.Flush(); - User::After(initialTime.Int()+5*time.Int()/2); - iTest->SimulateKey(TRawEvent::EKeyUp,'Y'); - TheClient->iWs.Flush(); - User::After(initialTime.Int()+2*time.Int()); - iTest->SimulateKey(TRawEvent::EKeyUp,'Z'); - AddExpectedKey(EEventKeyDown,'Z'); - AddExpectedKey(EEventKey,'Z','z'); - AddExpectedKey(EEventKey,'Z','z',1); - AddExpectedKey(EEventKeyDown,'Y'); - AddExpectedKey(EEventKey,'Y','y'); - AddExpectedKey(EEventKey,'Y','y',1); - AddExpectedKey(EEventKeyUp,'Y'); - AddExpectedKey(EEventKey,'Z','z',1); - AddExpectedKey(EEventKeyUp,'Z'); - break; - case 6: - iCaptureKey=iQueueClient->iGroup->GroupWin()->CaptureLongKey(' ','b',0,0,2,ELongCaptureNormal); - iQueueClient->iWs.Flush(); - iTest->SimulateKey(TRawEvent::EKeyDown,'X'); - TheClient->iWs.Flush(); - User::After(initialTime.Int()+3*time.Int()); - iTest->SimulateKeyDownUp(EStdKeySpace); - TheClient->iWs.Flush(); - if(!iTest->IsFullRomL()) - { - User::After(initialTime.Int()+2*time.Int()); - } - iTest->SimulateKey(TRawEvent::EKeyUp,'X'); - AddExpectedKey(EEventKeyDown,'X'); - AddExpectedKey(EEventKey,'X','x'); - AddExpectedKey(EEventKey,'X','x',1); - AddExpectedKey(EEventKeyDown,EStdKeySpace); - AddExpectedKey(EEventKey,EStdKeySpace,' '); - AddExpectedKey(EEventKeyUp,EStdKeySpace); - if(!iTest->IsFullRomL()) - { - AddExpectedKey(EEventKey,'X','x',1); - } - AddExpectedKey(EEventKeyUp,'X'); - iQueueClient->iGroup->GroupWin()->CancelCaptureLongKey(iCaptureKey); - break; - case 7: - iCaptureKey=iQueueClient->iGroup->GroupWin()->CaptureLongKey(' ','b',0,0,2,ELongCaptureNormal|ELongCaptureRepeatEvents); - iQueueClient->iWs.Flush(); - iTest->SimulateKey(TRawEvent::EKeyDown,'X'); - TheClient->iWs.Flush(); - User::After(initialTime.Int()+5*time.Int()); - iTest->SimulateKey(TRawEvent::EKeyDown,EStdKeySpace); - TheClient->iWs.Flush(); - User::After(initialTime.Int()+time.Int()/3); - iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeySpace); - TheClient->iWs.Flush(); - User::ResetInactivityTime(); - User::After(initialTime.Int()+4*time.Int()); - iTest->SimulateKey(TRawEvent::EKeyUp,'X'); - AddExpectedKey(EEventKeyDown,'X'); - AddExpectedKey(EEventKey,'X','x'); - AddExpectedKey(EEventKey,'X','x',1); - AddExpectedKey(EEventKeyDown,EStdKeySpace); - AddExpectedKey(EEventKey,EStdKeySpace,' '); - AddExpectedKey(EEventKey,EStdKeySpace,'b',1); - AddExpectedKey(EEventKeyUp,EStdKeySpace); - AddExpectedKey(EEventKey,'X','x',1); - AddExpectedKey(EEventKeyUp,'X'); - iQueueClient->iGroup->GroupWin()->CancelCaptureLongKey(iCaptureKey); - break; - case 8: - iCaptureKey=iQueueClient->iGroup->GroupWin()->CaptureLongKey(' ','c',0,0,2,ELongCaptureRepeatEvents); - iQueueClient->iWs.Flush(); - iTest->SimulateKey(TRawEvent::EKeyDown,EStdKeySpace); - TheClient->iWs.Flush(); - User::After(initialTime.Int()+5*time.Int()); - iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeySpace); - AddExpectedKey(EEventKeyDown,EStdKeySpace); - AddExpectedKey(EEventKey,EStdKeySpace,'c',1); - AddExpectedKey(EEventKeyUp,EStdKeySpace); - iQueueClient->iGroup->GroupWin()->CancelCaptureLongKey(iCaptureKey); - break; - case 9: - { - TInt captureKey=iQueueClient->iGroup->GroupWin()->CaptureLongKey(EKeyEscape,'e',0,0,2,ELongCaptureNormal|ELongCaptureRepeatEvents); - iCaptureKey=iQueueClient->iGroup->GroupWin()->CaptureLongKey(' ','d',0,0,2,ELongCaptureNormal|ELongCaptureRepeatEvents); - iQueueClient->iWs.Flush(); - iTest->SimulateKey(TRawEvent::EKeyDown,EStdKeySpace); - TheClient->iWs.Flush(); - User::After(initialTime.Int()+5*time.Int()/2); - iTest->SimulateKeyDownUp(EStdKeyEscape); - TheClient->iWs.Flush(); - User::After(initialTime.Int()+3*time.Int()); - iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeySpace); - AddExpectedKey(EEventKeyDown,EStdKeySpace); - AddExpectedKey(EEventKey,EStdKeySpace,' '); - AddExpectedKey(EEventKey,EStdKeySpace,'d',1); - AddExpectedKey(EEventKeyDown,EStdKeyEscape); - AddExpectedKey(EEventKey,EStdKeyEscape,EKeyEscape); - AddExpectedKey(EEventKeyUp,EStdKeyEscape); - AddExpectedKey(EEventKeyUp,EStdKeySpace); - iQueueClient->iGroup->GroupWin()->CancelCaptureLongKey(iCaptureKey); - iQueueClient->iGroup->GroupWin()->CancelCaptureLongKey(captureKey); - } - break; - case 10: - //Cancel a long capture key event whilst a repeat is underway - iCaptureKey=iQueueClient->iGroup->GroupWin()->CaptureLongKey(' ','a',0,0,2,ELongCaptureNormal|ELongCaptureRepeatEvents); - iQueueClient->iWs.Flush(); - iTest->SimulateKey(TRawEvent::EKeyDown,EStdKeySpace); - TheClient->iWs.Flush(); - iQueueClient->iGroup->GroupWin()->CancelCaptureLongKey(iCaptureKey); - User::After(initialTime.Int()+5*time.Int()); - iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeySpace); - AddExpectedKey(EEventKeyDown,EStdKeySpace); - AddExpectedKey(EEventKey,EStdKeySpace,' '); - AddExpectedKey(EEventKeyUp,EStdKeySpace); - break; - case 11: - //Cancel a capture key up and down event whilst a repeat is underway - iCaptureKey=iQueueClient->iGroup->GroupWin()->CaptureKeyUpAndDowns(EStdKeySpace,0,0); - iQueueClient->iWs.Flush(); - iTest->SimulateKey(TRawEvent::EKeyDown,'X'); - TheClient->iWs.Flush(); - iQueueClient->iGroup->GroupWin()->CancelCaptureKeyUpAndDowns(iCaptureKey); - User::After(initialTime.Int()+5*time.Int()); - iTest->SimulateKey(TRawEvent::EKeyUp,'X'); - AddExpectedKey(EEventKeyDown,'X'); - AddExpectedKey(EEventKey,'X','x'); - AddExpectedKey(EEventKeyUp,'X'); - break; - case 12: - //Cancel a capture key event whilst a repeat is underway - iCaptureKey=iQueueClient->iGroup->GroupWin()->CaptureKey(EStdKeySpace,0,0); - iQueueClient->iWs.Flush(); - iTest->SimulateKey(TRawEvent::EKeyDown,'Y'); - TheClient->iWs.Flush(); - iQueueClient->iGroup->GroupWin()->CancelCaptureKey(iCaptureKey); - User::After(initialTime.Int()+5*time.Int()); - iTest->SimulateKey(TRawEvent::EKeyUp,'Y'); - AddExpectedKey(EEventKeyDown,'Y'); - AddExpectedKey(EEventKey,'Y','y'); - AddExpectedKey(EEventKeyUp,'Y'); - break; - case 13: - //Variation on case 12 i.e. change in the timing of the CancelCaptureKey call - iCaptureKey=iQueueClient->iGroup->GroupWin()->CaptureKey(EStdKeySpace,0,0); - iQueueClient->iWs.Flush(); - iTest->SimulateKey(TRawEvent::EKeyDown,'Z'); - TheClient->iWs.Flush(); - User::After(initialTime.Int()+5*time.Int()/2); - iQueueClient->iGroup->GroupWin()->CancelCaptureKey(iCaptureKey); - User::After(initialTime.Int()+5*time.Int()/2); - iTest->SimulateKey(TRawEvent::EKeyUp,'Z'); - AddExpectedKey(EEventKeyDown,'Z'); - AddExpectedKey(EEventKey,'Z','z'); - AddExpectedKey(EEventKey,'Z','z',2); - AddExpectedKey(EEventKeyUp,'Z'); - break; - case 14: - { - // Cancel long capture key event when normal capture key is scheduled for different - // window group. - iCaptureKey=iQueueClient->iGroup->GroupWin()->CaptureLongKey(' ','a',0,0,2,ELongCaptureNormal); - TInt shortCaptKey = TheClient->iGroup->GroupWin()->CaptureKey(' ',0,0); - - iTest->SimulateKey(TRawEvent::EKeyDown,EStdKeySpace); - TheClient->iWs.Flush(); - iQueueClient->iGroup->GroupWin()->CancelCaptureLongKey(iCaptureKey); - User::After(initialTime.Int()+time.Int()/3); - - TheClient->iGroup->GroupWin()->CancelCaptureKey(shortCaptKey); - iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeySpace); - AddExpectedKey(EEventKeyDown,EStdKeySpace); - AddExpectedKey(EEventKeyUp,EStdKeySpace); - } - break; - default: - CActiveScheduler::Stop(); - break; - } - TheClient->iWs.Flush(); - } - -#define PASSWORD_START_OF_DAY 4 -void CTEventTest::Password_NextSetOfEvents() - { - switch(iEventSet++) - { - case 0: - iQueueClient->iWin->BaseWin()->PasswordWindow(EPasswordAlwaysTriggerNow); - iQueueClient->iWs.PasswordEntered(); - iTest->SimulateKeyDownUp('2'); - iQueueClient->iWs.Flush(); - AddExpectedEvent(EEventFocusGained); - AddExpectedEvent(EEventPassword); - AddExpectedKeyDownUp('2'); - break; - case 1: - iQueueClient->iWin->BaseWin()->PasswordWindow(EPasswordOnceADayTriggerNow); - iQueueClient->iWs.PasswordEntered(); - iTest->SimulateKeyDownUp('3'); - iQueueClient->iWs.Flush(); - AddExpectedEvent(EEventPassword); - AddExpectedKeyDownUp('3'); - break; - case 2: - { - TTime time; - time.HomeTime(); - TInt day=time.DayNoInMonth(); - if (day==0) - day=5; - time-=TTimeIntervalDays(day); - time+=TTimeIntervalHours(PASSWORD_START_OF_DAY); - User::SetHomeTime(time); - iQueueClient->iWin->BaseWin()->PasswordWindow(EPasswordOnceADayTriggerNow); - iQueueClient->iWs.PasswordEntered(); - iTest->SimulateKeyDownUp('3'); - iQueueClient->iWs.Flush(); - AddExpectedEvent(EEventPassword); - AddExpectedKeyDownUp('3'); - time+=TTimeIntervalDays(day); - time-=TTimeIntervalHours(PASSWORD_START_OF_DAY); - User::SetHomeTime(time); - } - break; - case 3: - { - TTime time; - time.HomeTime(); - TInt day=time.DayNoInMonth(); - time-=TTimeIntervalDays(day); - time+=TTimeIntervalHours(PASSWORD_START_OF_DAY); - User::SetHomeTime(time); - iQueueClient->iWin->BaseWin()->PasswordWindow(EPasswordOnceADay); - iQueueClient->iWs.PasswordEntered(); - iTest->SimulateEvent(TRawEvent::ESwitchOn); - iTest->SimulateKeyDownUp('3'); - iQueueClient->iWs.Flush(); - AddExpectedEvent(EEventPassword); - AddExpectedEvent(EEventSwitchOn); - AddExpectedKeyDownUp('3'); - time+=TTimeIntervalDays(day); - time-=TTimeIntervalHours(PASSWORD_START_OF_DAY); - User::SetHomeTime(time); - } - break; - default: - CActiveScheduler::Stop(); - break; - } - TheClient->iWs.Flush(); - } - -void CTEventTest::GroupListChanged_NextSetOfEventsL() - { - _LIT(WindowGroup1,"WindowGroupName1"); - _LIT(WindowGroup2,"WindowGroupName2"); - switch(iEventSet++) - { - case 0: - { - _LIT(TestGroup3,"GroupListEvents3"); - iQueueClient->EnableGroupListChangeEvents(); - iEventTestGroup3=new(ELeave) CTWindowGroup(TheClient); - iEventTestGroup3->ConstructL(); - iEventTestGroup3->GroupWin()->SetName(TestGroup3); - AddExpectedEvent(EEventFocusGained); - AddExpectedEvent(EEventFocusLost); - AddExpectedEvent(EEventWindowGroupListChanged); - AddExpectedEvent(EEventWindowGroupsChanged); - } - break; - case 1: - { - _LIT(TestGroup4,"GroupListEvents4"); - iEventTestGroup4=new(ELeave) CTWindowGroup(TheClient); - iEventTestGroup4->ConstructL(); - iEventTestGroup4->GroupWin()->SetName(TestGroup4); - AddExpectedEvent(EEventWindowGroupListChanged); - AddExpectedEvent(EEventWindowGroupsChanged); - } - break; - case 2: - iEventTestGroup3->GroupWin()->SetOrdinalPosition(0); - AddExpectedEvent(EEventWindowGroupListChanged); - break; - case 3: - iEventTestGroup3->GroupWin()->SetOrdinalPosition(999); - AddExpectedEvent(EEventWindowGroupListChanged); - break; - case 4: - iEventTestGroup4->GroupWin()->SetOrdinalPosition(999); - AddExpectedEvent(EEventFocusGained); - AddExpectedEvent(EEventWindowGroupListChanged); - // Testcase for defect INC135635 - // Since iWin has OrdinalPosition Zero (the front) clicking on it won't generate an - // EEventWindowGroupListChanged event as there is no change in the order of the windows - AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(20-EWinPositionX,11-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(20-EWinPositionX,11-EWinPositionY)); - SimulatePointer(TRawEvent::EButton1Down,20,11); - SimulatePointer(TRawEvent::EButton1Up,20,11); - break; - case 5: - iEventTestGroup3->GroupWin()->SetOrdinalPosition(999); - AddExpectedEvent(EEventWindowGroupListChanged); - break; - case 6: - iEventTestGroup3->GroupWin()->SetOrdinalPosition(99); - SimulatePointer(TRawEvent::EButton1Down,20,11); - iEventTestGroup3->GroupWin()->SetName(WindowGroup1); - AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(20-EWinPositionX,11-EWinPositionY)); - AddExpectedEvent(EEventWindowGroupsChanged); - break; - case 7: - iEventTestGroup3->GroupWin()->SetName(WindowGroup2); - SimulatePointer(TRawEvent::EButton1Up,10,20); - AddExpectedEvent(EEventWindowGroupsChanged); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(10-EWinPositionX,20-EWinPositionY)); - break; - case 8: - iEventTestGroup3->GroupWin()->SetName(WindowGroup1); - SimulatePointer(TRawEvent::EButton2Down,20,30); - AddExpectedEvent(EEventWindowGroupsChanged); - AddExpectedPointer(TPointerEvent::EButton2Down, TPoint(20-EWinPositionX,30-EWinPositionY)); - break; - case 9: - SimulatePointer(TRawEvent::EButton1Up,15,15); - iEventTestGroup3->GroupWin()->SetName(WindowGroup2); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(15-EWinPositionX,15-EWinPositionY)); - AddExpectedEvent(EEventWindowGroupsChanged); - break; - case 10: - SimulatePointer(TRawEvent::EButton2Down,25,20); - iEventTestGroup3->GroupWin()->SetName(WindowGroup2); - SimulatePointer(TRawEvent::EButton1Up,15,20); - iEventTestGroup3->GroupWin()->SetName(WindowGroup1); - AddExpectedPointer(TPointerEvent::EButton2Down, TPoint(25-EWinPositionX,20-EWinPositionY)); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(15-EWinPositionX,20-EWinPositionY)); - AddExpectedEvent(EEventWindowGroupsChanged); - break; - case 11: - iEventTestGroup3->GroupWin()->SetName(WindowGroup1); - SimulatePointer(TRawEvent::EButton2Down,12,12); - iEventTestGroup3->GroupWin()->SetName(WindowGroup2); - SimulatePointer(TRawEvent::EButton1Up,12,12); - AddExpectedPointer(TPointerEvent::EButton2Down, TPoint(12-EWinPositionX,12-EWinPositionY)); - AddExpectedEvent(EEventWindowGroupsChanged); - AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(12-EWinPositionX,12-EWinPositionY)); - break; - case 12: - delete iEventTestGroup3; - iEventTestGroup3=NULL; - AddExpectedEvent(EEventWindowGroupsChanged); - AddExpectedEvent(EEventWindowGroupListChanged); - break; - case 13: - delete iEventTestGroup4; - iEventTestGroup4=NULL; - AddExpectedEvent(EEventWindowGroupsChanged); - AddExpectedEvent(EEventWindowGroupListChanged); - break; - default: - CActiveScheduler::Stop(); - break; - } - TheClient->iWs.Flush(); - } - -TInt CTEventTest::KeyRepeatTime() const - { - TTimeIntervalMicroSeconds32 initialTime; - TTimeIntervalMicroSeconds32 time; - TheClient->iWs.GetKeyboardRepeatRate(initialTime,time); - return(initialTime.Int()); - } - -void CTEventTest::RepeatableKeysL() - { - // repeatable key event - TKeyEvent repKeyEvent; - repKeyEvent.iCode='J'; - repKeyEvent.iScanCode=0; - repKeyEvent.iModifiers=EModifierAutorepeatable; - repKeyEvent.iRepeats=0; - - // non-repeatable key event - TKeyEvent keyEvent; - keyEvent.iCode='J'; - keyEvent.iScanCode=0; - keyEvent.iModifiers=0; - keyEvent.iRepeats=0; - - switch(iEventSet++) - { - case 0: - { - TheClient->iWs.SimulateKeyEvent(repKeyEvent); // Create a repeatable key event - TheClient->iWs.SimulateKeyEvent(repKeyEvent); // Create a repeatable key event - TheClient->iWs.SimulateKeyEvent(keyEvent); // Create a non-repeatable key event - TheClient->iWs.Flush(); // Send events - AddExpectedEvent(EEventFocusGained); // Always get a focus gain at start - AddExpectedKey(1, repKeyEvent.iScanCode, repKeyEvent.iCode, repKeyEvent.iRepeats, repKeyEvent.iModifiers);// Expect the event that was created above - AddExpectedKey(1, repKeyEvent.iScanCode, repKeyEvent.iCode, repKeyEvent.iRepeats, repKeyEvent.iModifiers);// Expect the event that was created above - AddExpectedKey(1, keyEvent.iScanCode, keyEvent.iCode, keyEvent.iRepeats, keyEvent.iModifiers);// Expect the event that was created above - break; - } - case 1: - { - TheClient->iWs.SimulateKeyEvent(repKeyEvent); // Create a repeatable key event - TheClient->iWs.SimulateKeyEvent(keyEvent); // Create a non-repeatable key event - TheClient->iWs.Flush(); - iTest->SimulateKey(TRawEvent::EKeyDown, 'A'); // Create a raw event - TheClient->iWs.Flush(); - User::After(KeyRepeatTime()*3/2); - iTest->SimulateKey(TRawEvent::EKeyUp, 'A'); // Create a raw event - TheClient->iWs.Flush(); - AddExpectedKey(1, repKeyEvent.iScanCode, repKeyEvent.iCode, repKeyEvent.iRepeats, repKeyEvent.iModifiers);// Expect the event that was created above - AddExpectedKey(1, keyEvent.iScanCode, keyEvent.iCode, keyEvent.iRepeats, keyEvent.iModifiers);// Expect the event that was created above - AddExpectedKey(EEventKeyDown, 'A'); - AddExpectedKey(EEventKey,'A','a'); - AddExpectedKey(EEventKey,'A','a',1); - AddExpectedKey(EEventKeyUp, 'A'); - break; - } - case 2: - { - iTest->SimulateKey(TRawEvent::EKeyDown, 'A'); // Create a raw event - TheClient->iWs.Flush(); - User::After(KeyRepeatTime()*3/2); - TheClient->iWs.SimulateKeyEvent(repKeyEvent); // Create a repeatable key event - TheClient->iWs.SimulateKeyEvent(keyEvent); // Create a non-repeatable key event - TheClient->iWs.Flush(); // Send event - iTest->SimulateKey(TRawEvent::EKeyUp, 'A'); // Create a raw event - TheClient->iWs.Flush(); - AddExpectedKey(EEventKeyDown, 'A'); - AddExpectedKey(EEventKey,'A','a'); - AddExpectedKey(EEventKey,'A','a',1); - AddExpectedKey(1, repKeyEvent.iScanCode, repKeyEvent.iCode, repKeyEvent.iRepeats, repKeyEvent.iModifiers);// Expect the event that was created above - AddExpectedKey(1, keyEvent.iScanCode, keyEvent.iCode, keyEvent.iRepeats, keyEvent.iModifiers);// Expect the event that was created above - AddExpectedKey(EEventKeyUp, 'A'); - break; - } - default: - CActiveScheduler::Stop(); - break; - } - TheClient->iWs.Flush(); - } - -CTBlankWindow* CTEventTest::NewBlueForgroundWindowL() - { - CTBlankWindow* window; - window=new (ELeave) CTBlankWindow; - CleanupStack::PushL(window); - window->ConstructL(*iQueueClient->iGroup); - User::LeaveIfError(window->BaseWin()->SetRequiredDisplayMode(EColor256)); - CleanupStack::Pop(window); - - window->SetColor(KRgbBlue); - window->SetExt(TPoint(40, 40), TSize(40,40)); - window->BaseWin()->SetOrdinalPosition(0); - return window; - } - -CTBlankWindow* CTEventTest::NewBlueForgroundWindow() - { - CTBlankWindow* window = NULL; - TRAPD(err, window=NewBlueForgroundWindowL()); - if (err != KErrNone) - Failed(); - return window; - } - -#ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS -#ifndef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA -static void CreateSurfaceAttributes(RSurfaceManager::TSurfaceCreationAttributesBuf& aBuffer , const TSize& aSize) - { - RSurfaceManager::TSurfaceCreationAttributes& b = aBuffer(); - - b.iSize.iWidth = aSize.iWidth; - b.iSize.iHeight = aSize.iHeight; - b.iBuffers = 1; // number of buffers in the surface - b.iPixelFormat = EUidPixelFormatARGB_8888; - b.iStride = aSize.iWidth * 4; // Number of bytes between start of one line and start of next - b.iOffsetToFirstBuffer = 0; // way of reserving space before the surface pixel data - b.iAlignment = 4; // alignment, 1,2,4,8 byte aligned - b.iContiguous = EFalse; - b.iMappable = ETrue; - } - -static const TInt KFullyVisible = TWsVisibilityChangedEvent::EPartiallyVisible | TWsVisibilityChangedEvent::EFullyVisible; - -void CTEventTest::SurfaceVisibilityChanged1_NextSetOfEventsL() - { - switch(iEventSet++) - { - case 0: - { - //Setup - LOG_MESSAGE(_L("case 0")); - TInt err = iSurfaceManager.Open(); - if (err != KErrNone) - { - RDebug::Printf("RSurfaceManager::Open() failed", err); - User::Leave(err); - } - - iVisWins1=NewBlueForgroundWindowL(); - iVisWins1->Activate(); - iVisWins1->BaseWin()->EnableVisibilityChangeEvents(); - - AddExpectedEvent(EEventFocusGained); - AddExpectedVisibilityChange(KFullyVisible, iVisWins1); - break; - } - case 1: - { - LOG_MESSAGE(_L("case 1")); - iVisWins2=NewBlueForgroundWindowL(); // will cover iVisWins1 - iVisWins2->BlankWin()->SetColor(); //remove colour to ensure window does not draw to UI layer - iVisWins2->Activate(); - - AddExpectedVisibilityChange(TWsVisibilityChangedEvent::ENotVisible, iVisWins1); - break; - } - case 2: - { - // This case contains the actual test GRAPHICS-WSERV-2669-0015 - LOG_MESSAGE(_L("case 2")); - RSurfaceManager::TSurfaceCreationAttributesBuf surfaceBuf; - CreateSurfaceAttributes(surfaceBuf, iVisWins2->BaseWin()->Size()); - - iSurfaceId = TSurfaceId::CreateNullId(); - TInt err = iSurfaceManager.CreateSurface(surfaceBuf, iSurfaceId); - if (err != KErrNone) - { - RDebug::Printf("RSurfaceManager::CreateSurface() error: %d", err); - TEST(EFalse); - } - - err = iVisWins2->BaseWin()->SetBackgroundSurface(iSurfaceId); - if (err != KErrNone) - { - RDebug::Printf("RWindow::SetBackgroundSurface() error: %d", err); - TEST(EFalse); - } - - iVisWins2->BaseWin()->SetSurfaceTransparency(ETrue); //iVisWins1 will become visible - - AddExpectedVisibilityChange(KFullyVisible, iVisWins1); - break; - } - default: - LOG_MESSAGE(_L("default")); - if (!iSurfaceId.IsNull()) - { - iSurfaceManager.CloseSurface(iSurfaceId); - iSurfaceId = TSurfaceId::CreateNullId(); - } - iSurfaceManager.Close(); - delete iVisWins1; - iVisWins1 = NULL; - delete iVisWins2; - iVisWins2 = NULL; - CActiveScheduler::Stop(); - break; - } - TheClient->iWs.Flush(); - } - -void CTEventTest::SurfaceVisibilityChanged2_NextSetOfEventsL() - { - switch (iEventSet++) - { - case 0: - { - //Win1 - bottom window - //Win2 - middle window with semi-transparent background surface, which totally obscures win1 - LOG_MESSAGE(_L("case 0")); - TInt err = iSurfaceManager.Open(); - if (err != KErrNone) - { - RDebug::Printf("RSurfaceManager::Open() failed", err); - User::Leave(err); - } - - iVisWins1 = NewBlueForgroundWindowL(); - iVisWins1->BaseWin()->EnableVisibilityChangeEvents(); - - iVisWins2 = NewBlueForgroundWindowL(); - iVisWins2->BlankWin()->SetColor(); //remove colour to ensure window does not draw to UI layer - iVisWins2->BaseWin()->EnableVisibilityChangeEvents(); - - iVisWins1->Activate(); //obscured - iVisWins2->Activate(); //visible - - // Create surface for background window - RSurfaceManager::TSurfaceCreationAttributesBuf surfaceBuf; - CreateSurfaceAttributes(surfaceBuf, iVisWins2->BaseWin()->Size()); - - iSurfaceId = TSurfaceId::CreateNullId(); - err = iSurfaceManager.CreateSurface(surfaceBuf, iSurfaceId); - if (err != KErrNone) - { - RDebug::Printf("RSurfaceManager::CreateSurface() error: %d", err); - TEST(EFalse); - } - - err = iVisWins2->BaseWin()->SetBackgroundSurface(iSurfaceId); - if (err != KErrNone) - { - RDebug::Printf("RWindow::SetBackgroundSurface() error: %d", err); - TEST(EFalse); - } - - iVisWins2->BaseWin()->SetSurfaceTransparency(ETrue); //win1 and win2 both visible - - AddExpectedEvent(EEventFocusGained); - AddExpectedVisibilityChange(KFullyVisible, iVisWins2); - AddExpectedVisibilityChange(KFullyVisible, iVisWins1); - break; - } - case 1: - { - //Win3 - opaque top window which obscures win2 and win1 - LOG_MESSAGE(_L("case 1")); - iVisWins3 = NewBlueForgroundWindowL(); - iVisWins3->SetColor(KRgbRed); - iVisWins3->Activate(); - - AddExpectedVisibilityChange(TWsVisibilityChangedEvent::ENotVisible, iVisWins2); - AddExpectedVisibilityChange(TWsVisibilityChangedEvent::ENotVisible, iVisWins1); - break; - } - case 2: - { - //This case contains the actual test GRAPHICS-WSERV-2669-0016 - LOG_MESSAGE(_L("case 2")); - delete iVisWins3; - iVisWins3 = NULL; - - AddExpectedVisibilityChange(KFullyVisible, iVisWins2); - AddExpectedVisibilityChange(KFullyVisible, iVisWins1); - break; - } - default: - LOG_MESSAGE(_L("default")); - if (!iSurfaceId.IsNull()) - { - iSurfaceManager.CloseSurface(iSurfaceId); - iSurfaceId = TSurfaceId::CreateNullId(); - } - iSurfaceManager.Close(); - delete iVisWins1; - iVisWins1 = NULL; - delete iVisWins2; - iVisWins2 = NULL; - delete iVisWins3; - iVisWins3 = NULL; - CActiveScheduler::Stop(); - return; - } - TheClient->iWs.Flush(); - } - -TInt CTEventTest::GenerateAnEvent(TAny* aEventTest) - { - CTEventTest* self = static_cast(aEventTest); - self->LogMessage(((TText8*)__FILE__), __LINE__,_L("Negative test passed OK - no event was generated.")); - //Now we must generate an event to get CTQueueTestEvent out of its wait loop - self->SimulateRepeatEvent(32); - self->AddExpectedKey(EEventKey, 32); - return KErrNone; - } - -void CTEventTest::SurfaceVisibilityChanged3_NextSetOfEventsL() - { - switch (iEventSet++) - { - case 0: - { - //Win1 - Bottom window - //Win2 - Top window with semi-transparent background surface. Does not overlap win1. - LOG_MESSAGE(_L("case 0")); - TInt err = iSurfaceManager.Open(); - if (err != KErrNone) - { - RDebug::Printf("RSurfaceManager::Open() failed", err); - User::Leave(err); - } - iTimeOutCallback = CPeriodic::NewL(CActive::EPriorityIdle); - - iVisWins1 = NewBlueForgroundWindowL(); - iVisWins1->BaseWin()->EnableVisibilityChangeEvents(); - - iVisWins2 = NewBlueForgroundWindowL(); - iVisWins2->BlankWin()->SetColor(); //remove colour to ensure window does not draw to UI layer - TPoint newPos(iVisWins1->Position() + iVisWins1->Size()); - iVisWins2->SetPos(newPos); //to not overlap win1 - - iVisWins1->Activate(); //upper left - iVisWins2->Activate(); //lower right - - // Create surface for background window - RSurfaceManager::TSurfaceCreationAttributesBuf surfaceBuf; - CreateSurfaceAttributes(surfaceBuf, iVisWins2->BaseWin()->Size()); - - iSurfaceId = TSurfaceId::CreateNullId(); - err = iSurfaceManager.CreateSurface(surfaceBuf, iSurfaceId); - if (err != KErrNone) - { - RDebug::Printf("RSurfaceManager::CreateSurface() error: %d", err); - TEST(EFalse); - } - - err = iVisWins2->BaseWin()->SetBackgroundSurface(iSurfaceId); - if (err != KErrNone) - { - RDebug::Printf("RWindow::SetBackgroundSurface() error: %d", err); - TEST(EFalse); - } - - iVisWins2->BaseWin()->SetSurfaceTransparency(ETrue); - - AddExpectedEvent(EEventFocusGained); - AddExpectedVisibilityChange(KFullyVisible, iVisWins1); - break; - } - case 1: - { - //This case contains the actual test GRAPHICS-WSERV-2669-0017 - LOG_MESSAGE(_L("case 1")); - iVisWins2->SetPos(iVisWins1->Position()); //Win2 now overlaps Win1, but because Win2 has - //a transparent surface Win1 is still fully visible - - //Because we don't expect any events we need to generate one to avoid waiting forever. - TCallBack timeout(GenerateAnEvent, this); - iTimeOutCallback->Start(1000000, 10000000, timeout); - break; - } - default: - LOG_MESSAGE(_L("default")); - iTimeOutCallback->Cancel(); - delete iTimeOutCallback; - iTimeOutCallback = NULL; - if (!iSurfaceId.IsNull()) - { - iSurfaceManager.CloseSurface(iSurfaceId); - iSurfaceId = TSurfaceId::CreateNullId(); - } - iSurfaceManager.Close(); - delete iVisWins1; - iVisWins1 = NULL; - delete iVisWins2; - iVisWins2 = NULL; - CActiveScheduler::Stop(); - return; - } - TheClient->iWs.Flush(); - } -#endif //TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA -#endif //SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS - -void CTEventTest::VisibilityChanged_NextSetOfEventsL() - { - const TInt fullyVisible = TWsVisibilityChangedEvent::EPartiallyVisible | TWsVisibilityChangedEvent::EFullyVisible; - - switch(iEventSet++) - { - case 0: //only this case can leave - { - iQueueClient->iWin->BackedUpWin()->MaintainBackup(); - iVisWins1=NewBlueForgroundWindowL(); - iVisWins2=NewBlueForgroundWindowL(); - - iVisWins1->BaseWin()->EnableVisibilityChangeEvents(); - iVisWins1->Activate(); - iVisWins2->SetColor(KRgbGreen); - iVisWins2->SetExt(TPoint(80, 80), TSize(120,120)); - iVisWins2->Activate(); - - AddExpectedEvent(EEventFocusGained); - AddExpectedVisibilityChange(fullyVisible); - } - break; - case 1: - iVisWins1->BaseWin()->SetVisible(EFalse); - AddExpectedVisibilityChange(TWsVisibilityChangedEvent::ENotVisible); - break; - case 2: - iVisWins1->BaseWin()->SetVisible(ETrue); - AddExpectedVisibilityChange(fullyVisible); - break; - case 3: - iVisWins2->SetExt(TPoint(0,0), TSize(120,120)); - AddExpectedVisibilityChange(TWsVisibilityChangedEvent::ENotVisible); - break; - case 4: - iVisWins2->BaseWin()->SetVisible(EFalse); - AddExpectedVisibilityChange(fullyVisible); - break; - case 5: - iVisWins2->BaseWin()->SetVisible(ETrue); - AddExpectedVisibilityChange(TWsVisibilityChangedEvent::ENotVisible); - break; - case 6: - iVisWins2->SetExt(TPoint(60,60), TSize(120,120)); - AddExpectedVisibilityChange(TWsVisibilityChangedEvent::EPartiallyVisible); - break; - case 7: - iVisWins1->SetExt(TPoint(80,80), TSize(40,40)); - AddExpectedVisibilityChange(TWsVisibilityChangedEvent::ENotVisible); - break; - case 8: - iVisWins1->BaseWin()->SetOrdinalPosition(0); - AddExpectedVisibilityChange(fullyVisible); - - if(TransparencySupportedL() != KErrNone) - { - iEventSet += 2; //we shall skip set 9,10 as they work with transparency - } - break; - case 9: - { - TDisplayMode mode = EColor256; - iTransWin=CTransWindow::NewL(iQueueClient->iGroup, TRgb(255, 0, 0, 128), TRect(0,0,200,200), &mode); - iTransWin->CTWin::DrawNow(); - // it gets put at ordinal position 0 - iVisWins2->BaseWin()->SetOrdinalPosition(1); - AddExpectedVisibilityChange(TWsVisibilityChangedEvent::ENotVisible); - } - break; - case 10: - iVisWins1->BaseWin()->SetOrdinalPosition(1); - AddExpectedVisibilityChange(fullyVisible); - break; - case 11: - { - delete iVisWins1; - iVisWins1=NULL; - iVisWins1=NewBlueForgroundWindow(); - - iVisWins1->Activate(); - iVisWins1->BaseWin()->EnableVisibilityChangeEvents(); - - AddExpectedVisibilityChange(fullyVisible); - } - break; - case 12: - { - delete iVisWins1; - iVisWins1=NULL; - iVisWins1=NewBlueForgroundWindow(); - - iVisWins1->Activate(); - iVisWins1->BaseWin()->EnableVisibilityChangeEvents(); - iVisWins1->BaseWin()->SetVisible(EFalse); - - AddExpectedVisibilityChange(TWsVisibilityChangedEvent::ENotVisible); - } - break; - case 13: - { - delete iVisWins1; - iVisWins1=NULL; - iVisWins1=NewBlueForgroundWindow(); - - iVisWins1->BaseWin()->EnableVisibilityChangeEvents(); - iVisWins1->Activate(); - - AddExpectedVisibilityChange(fullyVisible); - } - break; - case 14: - { - delete iVisWins1; - iVisWins1=NULL; - iVisWins1=NewBlueForgroundWindow(); - - iVisWins1->Activate(); - iVisWins1->BaseWin()->SetVisible(EFalse); - iVisWins1->BaseWin()->EnableVisibilityChangeEvents(); - - AddExpectedVisibilityChange(TWsVisibilityChangedEvent::ENotVisible); - } - break; - default: - delete iVisWins1; - delete iVisWins2; - iVisWins1 = NULL; - iVisWins2 = NULL; - delete iTransWin; - iTransWin = NULL; - CActiveScheduler::Stop(); - break; - } - TheClient->iWs.Flush(); - } - -void CTEventTest::CheckTimeStamp_NextSetOfEventsL() - { - iQueueClient->EventQueue()->SetCheckTimeStamp(ETrue); - switch(iEventSet++) - { - case 0: - iTest->SimulateKey(TRawEvent::EKeyDown, 'A'); // Create a raw event - iTest->SimulateKey(TRawEvent::EKeyUp, 'A'); // Create a raw event - AddExpectedEvent(EEventFocusGained); - AddExpectedKey(EEventKeyDown,'A'); - AddExpectedKey(EEventKey,'A','a'); - AddExpectedKey(EEventKeyUp,'A','a'); - break; - case 1: - { - _LIT8(KMsgParam,"CheckTimeStamp"); - TBuf8<0x20> params(KMsgParam); - TInt err = TheClient->iWs.SendMessageToWindowGroup(iQueueClient->WindowGroupIdentifier(),TUid::Uid(123),params); - AddExpectedEvent(EEventMessageReady); - } - break; - default: - CActiveScheduler::Stop(); - break; - } - TheClient->iWs.Flush(); - } - -/** - * @SYMTestCaseID GRAPHICS-WSERV-0001 - * - * @SYMPREQ PREQ525 - * - * @SYMTestCaseDesc Test Capture priority of different top most windows in a Group. - * - * @SYMTestPriority Critical - * - * @SYMTestStatus Implemented - * - * @SYMTestActions Create two different top client windows under one parent window - * in a same window group. Add pointer event by clicking various position on the - * window and Simulate the pointer event. Change the pointer capture flag, capture - * priority and simulate the pointer event. - * - * @SYMTestExpectedResults In general the expected event and the window server event should - * match same event handle, type and pointer position for following cases. - * When pointer capture is disabled and capture priorities are 0, the pointer position on window1 - * window2 or parent window are same as expected. - * When pointer capture is enabled and capture priorities are 0, the pointer position on window2(which is top most now) - * is same as expected. - * When pointer capture is enabled and capture priorities of win1 is greater than win2 - * the pointer position on win1 and win2 are same as expected. - * The combination of above cases should match the general expexted result. - * - */ -void CTEventTest::PointerCapture_NextSetOfEventsL() - { -#if defined(LOGGING) - TLogMessageText logMessageText; - _LIT(KSet,"Pointer Capture SetOfEvents: %d (last=9)"); - logMessageText.Format(KSet,iEventSet); - INFO_PRINTF1(logMessageText); -#endif - switch(iEventSet++) - { - case 0: //Create two top client windows of same group - iVisWins1=new (ELeave) CTBlankWindow; - iVisWins2=new (ELeave) CTBlankWindow; - iVisWins1->ConstructL(*iQueueClient->iGroup); - iVisWins2->ConstructL(*iQueueClient->iGroup); - iVisWins1->SetColor(KRgbBlue); - iVisWins1->SetExt(iQueueClient->ChildTopLeft(),iQueueClient->ChildSize()); - iVisWins1->Activate(); - iVisWins2->SetColor(KRgbGreen); - iVisWins2->SetExt(iQueueClient->ChildTopLeft()+TPoint(15,15),iQueueClient->ChildSize()); - iVisWins2->Activate(); - iQueueClient->iWs.Flush(); - AddExpectedEvent(EEventFocusGained); - break; - case 1: //Pointer capture are disabled and priorities are 0 - iVisWins1->BaseWin()->SetPointerCapture(RWindowBase::TCaptureDisabled); - iVisWins1->BaseWin()->SetPointerCapturePriority(0); - iVisWins2->BaseWin()->SetPointerCapture(RWindowBase::TCaptureDisabled); - iVisWins2->BaseWin()->SetPointerCapturePriority(0); - AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(35,25)); //Pointer on the first window - AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(35,25)); - AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(50,30)); //Pointer on the second window(overlaping on first window) - AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(50,30)); - AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(60,50)); //Pointer on the second window - AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(60,50)); - AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(75,25)); //Pointer on the parent window - AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(75,25)); - iQueueClient->iWs.Flush(); - SimulatePointer(TRawEvent::EButton1Down,35,25); - SimulatePointer(TRawEvent::EButton1Up,35,25); - SimulatePointer(TRawEvent::EButton1Down,50,30); - SimulatePointer(TRawEvent::EButton1Up,50,30); - SimulatePointer(TRawEvent::EButton1Down,60,50); - SimulatePointer(TRawEvent::EButton1Up,60,50); - SimulatePointer(TRawEvent::EButton1Down,75,25); - SimulatePointer(TRawEvent::EButton1Up,75,25); - break; - case 2: //Pointer capture are enabled and priorities are 0 - iVisWins1->BaseWin()->SetPointerCapture(RWindowBase::TCaptureEnabled); - iVisWins2->BaseWin()->SetPointerCapture(RWindowBase::TCaptureEnabled); - iVisWins1->BaseWin()->SetPointerCapturePriority(0); - iVisWins2->BaseWin()->SetPointerCapturePriority(0); - AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(35,25),(TInt)iVisWins2); //Pointer on the first window - AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(35,25),(TInt)iVisWins2); - AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(50,30)); //Pointer on the second window(overlaping on first window) - AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(50,30)); - AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(60,50)); //Pointer on the second window - AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(60,50)); - AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(75,25),(TInt)iVisWins2); //Pointer on the parent window - AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(75,25),(TInt)iVisWins2); - iQueueClient->iWs.Flush(); - SimulatePointer(TRawEvent::EButton1Down,35,25); - SimulatePointer(TRawEvent::EButton1Up,35,25); - SimulatePointer(TRawEvent::EButton1Down,50,30); - SimulatePointer(TRawEvent::EButton1Up,50,30); - SimulatePointer(TRawEvent::EButton1Down,60,50); - SimulatePointer(TRawEvent::EButton1Up,60,50); - SimulatePointer(TRawEvent::EButton1Down,75,25); - SimulatePointer(TRawEvent::EButton1Up,75,25); - break; - case 3: //Pointer capture are enabled and priorities of win1 is higher than win2 - iVisWins1->BaseWin()->SetPointerCapture(RWindowBase::TCaptureEnabled); - iVisWins2->BaseWin()->SetPointerCapture(RWindowBase::TCaptureEnabled); - iVisWins1->BaseWin()->SetPointerCapturePriority(1); - iVisWins2->BaseWin()->SetPointerCapturePriority(0); - AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(35,25)); - AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(35,25)); - AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(50,30)); - AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(50,30)); - AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(60,50)); - AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(60,50)); - AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(75,25),(TInt)iVisWins2); - AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(75,25),(TInt)iVisWins2); - iQueueClient->iWs.Flush(); - SimulatePointer(TRawEvent::EButton1Down,35,25); - SimulatePointer(TRawEvent::EButton1Up,35,25); - SimulatePointer(TRawEvent::EButton1Down,50,30); - SimulatePointer(TRawEvent::EButton1Up,50,30); - SimulatePointer(TRawEvent::EButton1Down,60,50); - SimulatePointer(TRawEvent::EButton1Up,60,50); - SimulatePointer(TRawEvent::EButton1Down,75,25); - SimulatePointer(TRawEvent::EButton1Up,75,25); - break; - case 4: //Pointer capture are enabled and priorities of win1 is equal to win2 - iVisWins1->BaseWin()->SetPointerCapture(RWindowBase::TCaptureEnabled); - iVisWins2->BaseWin()->SetPointerCapture(RWindowBase::TCaptureEnabled); - iVisWins1->BaseWin()->SetPointerCapturePriority(1); - iVisWins2->BaseWin()->SetPointerCapturePriority(1); - AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(35,25),(TInt)iVisWins2); - AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(35,25),(TInt)iVisWins2); - AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(50,30)); - AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(50,30)); - AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(60,50)); - AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(60,50)); - AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(75,25),(TInt)iVisWins2); - AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(75,25),(TInt)iVisWins2); - iQueueClient->iWs.Flush(); - SimulatePointer(TRawEvent::EButton1Down,35,25); - SimulatePointer(TRawEvent::EButton1Up,35,25); - SimulatePointer(TRawEvent::EButton1Down,50,30); - SimulatePointer(TRawEvent::EButton1Up,50,30); - SimulatePointer(TRawEvent::EButton1Down,60,50); - SimulatePointer(TRawEvent::EButton1Up,60,50); - SimulatePointer(TRawEvent::EButton1Down,75,25); - SimulatePointer(TRawEvent::EButton1Up,75,25); - break; - case 5: //Pointer capture are enabled and priorities of win2 is higher than win1 - iVisWins1->BaseWin()->SetPointerCapture(RWindowBase::TCaptureEnabled); - iVisWins2->BaseWin()->SetPointerCapture(RWindowBase::TCaptureEnabled); - iVisWins1->BaseWin()->SetPointerCapturePriority(0); - iVisWins2->BaseWin()->SetPointerCapturePriority(1); - AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(35,25),(TInt)iVisWins2); - AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(35,25),(TInt)iVisWins2); - AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(50,30)); - AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(50,30)); - AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(60,50)); - AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(60,50)); - AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(75,25),(TInt)iVisWins2); - AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(75,25),(TInt)iVisWins2); - iQueueClient->iWs.Flush(); - SimulatePointer(TRawEvent::EButton1Down,35,25); - SimulatePointer(TRawEvent::EButton1Up,35,25); - SimulatePointer(TRawEvent::EButton1Down,50,30); - SimulatePointer(TRawEvent::EButton1Up,50,30); - SimulatePointer(TRawEvent::EButton1Down,60,50); - SimulatePointer(TRawEvent::EButton1Up,60,50); - SimulatePointer(TRawEvent::EButton1Down,75,25); - SimulatePointer(TRawEvent::EButton1Up,75,25); - break; - case 6: //Pointer capture are enabled for all groups and priorities of win1 is higher than win2 - iVisWins1->BaseWin()->SetPointerCapture(RWindowBase::TCaptureEnabled|RWindowBase::TCaptureFlagAllGroups); - iVisWins2->BaseWin()->SetPointerCapture(RWindowBase::TCaptureEnabled|RWindowBase::TCaptureFlagAllGroups); - iVisWins1->BaseWin()->SetPointerCapturePriority(1); - iVisWins2->BaseWin()->SetPointerCapturePriority(0); - AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(35,25)); - AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(35,25)); - AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(50,30)); - AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(50,30)); - AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(60,50)); - AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(60,50)); - AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(75,25),(TInt)iVisWins2); - AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(75,25),(TInt)iVisWins2); - iQueueClient->iWs.Flush(); - SimulatePointer(TRawEvent::EButton1Down,35,25); - SimulatePointer(TRawEvent::EButton1Up,35,25); - SimulatePointer(TRawEvent::EButton1Down,50,30); - SimulatePointer(TRawEvent::EButton1Up,50,30); - SimulatePointer(TRawEvent::EButton1Down,60,50); - SimulatePointer(TRawEvent::EButton1Up,60,50); - SimulatePointer(TRawEvent::EButton1Down,75,25); - SimulatePointer(TRawEvent::EButton1Up,75,25); - break; - case 7: //Pointer capture are enabled and priorities of iWin is higher than the other windows - iVisWins1->BaseWin()->SetPointerCapture(RWindowBase::TCaptureEnabled); - iVisWins2->BaseWin()->SetPointerCapture(RWindowBase::TCaptureEnabled); - iVisWins1->BaseWin()->SetPointerCapturePriority(0); - iVisWins2->BaseWin()->SetPointerCapturePriority(0); - iQueueClient->iWin->BaseWin()->SetPointerCapture(RWindowBase::TCaptureEnabled); - iQueueClient->iWin->BaseWin()->SetPointerCapturePriority(1); - AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(80,20)); //Pointer on the parent window - AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(80,20)); - AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(35,25),(TInt)iVisWins2); - AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(35,25),(TInt)iVisWins2); - AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(60,50)); - AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(60,50)); - AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(50,30)); - AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(50,30)); - AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(75,25)); - AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(75,25)); - iQueueClient->iWs.Flush(); - SimulatePointer(TRawEvent::EButton1Down,80,20); - SimulatePointer(TRawEvent::EButton1Up,80,20); - SimulatePointer(TRawEvent::EButton1Down,35,25); - SimulatePointer(TRawEvent::EButton1Up,35,25); - SimulatePointer(TRawEvent::EButton1Down,60,50); - SimulatePointer(TRawEvent::EButton1Up,60,50); - SimulatePointer(TRawEvent::EButton1Down,50,30); - SimulatePointer(TRawEvent::EButton1Up,50,30); - SimulatePointer(TRawEvent::EButton1Down,75,25); - SimulatePointer(TRawEvent::EButton1Up,75,25); - break; - case 8: //Pointer capture are enabled and priorities of iWin is 0 - iVisWins1->BaseWin()->SetPointerCapture(RWindowBase::TCaptureEnabled); - iVisWins2->BaseWin()->SetPointerCapture(RWindowBase::TCaptureEnabled); - iVisWins1->BaseWin()->SetPointerCapturePriority(1); - iVisWins2->BaseWin()->SetPointerCapturePriority(0); - iQueueClient->iWin->BaseWin()->SetPointerCapture(RWindowBase::TCaptureEnabled); - iQueueClient->iWin->BaseWin()->SetPointerCapturePriority(0); - AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(80,20),(TInt)iVisWins2); //Pointer on the parent window - AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(80,20),(TInt)iVisWins2); - AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(35,25)); - AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(35,25)); - AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(60,50)); - AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(60,50)); - AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(50,30)); - AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(50,30)); - AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(75,25),(TInt)iVisWins2); - AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(75,25),(TInt)iVisWins2); - iQueueClient->iWs.Flush(); - SimulatePointer(TRawEvent::EButton1Down,80,20); - SimulatePointer(TRawEvent::EButton1Up,80,20); - SimulatePointer(TRawEvent::EButton1Down,35,25); - SimulatePointer(TRawEvent::EButton1Up,35,25); - SimulatePointer(TRawEvent::EButton1Down,60,50); - SimulatePointer(TRawEvent::EButton1Up,60,50); - SimulatePointer(TRawEvent::EButton1Down,50,30); - SimulatePointer(TRawEvent::EButton1Up,50,30); - SimulatePointer(TRawEvent::EButton1Down,75,25); - SimulatePointer(TRawEvent::EButton1Up,75,25); - break; - case 9: //Pointer capture are enabled and with different groups - iVisWins1->BaseWin()->SetPointerCapture(RWindowBase::TCaptureEnabled|RWindowBase::TCaptureFlagAllGroups); - iVisWins2->BaseWin()->SetPointerCapture(RWindowBase::TCaptureEnabled|RWindowBase::TCaptureFlagAllGroups); - iVisWins1->BaseWin()->SetPointerCapturePriority(0); - iVisWins2->BaseWin()->SetPointerCapturePriority(0); - iQueueClient->iWin->BaseWin()->SetPointerCapture(RWindowBase::TCaptureEnabled|RWindowBase::TCaptureFlagAllGroups); - iQueueClient->iWin->BaseWin()->SetPointerCapturePriority(1); - AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(25,150),(TInt)iVisWins2); - AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(25,150),(TInt)iVisWins2); - AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(150,25),(TInt)iVisWins2); - AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(150,25),(TInt)iVisWins2); - AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(80,20)); //Pointer on the parent window - AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(80,20)); - AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(35,25),(TInt)iVisWins2); - AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(35,25),(TInt)iVisWins2); - AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(60,50)); - AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(60,50)); - AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(50,30)); - AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(50,30)); - AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(75,25)); - AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(75,25)); - iQueueClient->iWs.Flush(); - SimulatePointer(TRawEvent::EButton1Down,25,150); - SimulatePointer(TRawEvent::EButton1Up,25,150); - SimulatePointer(TRawEvent::EButton1Down,150,25); - SimulatePointer(TRawEvent::EButton1Up,150,25); - SimulatePointer(TRawEvent::EButton1Down,80,20); - SimulatePointer(TRawEvent::EButton1Up,80,20); - SimulatePointer(TRawEvent::EButton1Down,35,25); - SimulatePointer(TRawEvent::EButton1Up,35,25); - SimulatePointer(TRawEvent::EButton1Down,60,50); - SimulatePointer(TRawEvent::EButton1Up,60,50); - SimulatePointer(TRawEvent::EButton1Down,50,30); - SimulatePointer(TRawEvent::EButton1Up,50,30); - SimulatePointer(TRawEvent::EButton1Down,75,25); - SimulatePointer(TRawEvent::EButton1Up,75,25); - break; - default: - delete iVisWins1; - delete iVisWins2; - iVisWins1=NULL; - iVisWins2=NULL; - CActiveScheduler::Stop(); - break; - } - TheClient->iWs.Flush(); - } - -/** -PDEF110849 -Allocate a pointer buffer, send it some events and then disconnect. -Now fill the event queue, causing a purge. -The purge will call void CWsPointerBuffer::DiscardPointerMoveBuffer(TUint aHandle) -in which an access violation occurred because iCurrentBuffer had not been set to NULL. -*/ -void CTEventTest::PointerBufferPurge_NextSetOfEventsL() - { -#if defined(LOGGING) - TLogMessageText logMessageText; - _LIT(KSet,"PointerBufferPurge SetOfEvents: %d of 1"); - logMessageText.Format(KSet,iEventSet); - TheClient->LogMessage(logMessageText); -#endif - iTheClientFlush=TheClient->iWs.SetAutoFlush(ETrue); - iQuequeClientFlush=iQueueClient->iWs.SetAutoFlush(ETrue); - switch(iEventSet++) - { - case 0: - { - RWindowBase& win = *iQueueClient->iWin->BaseWin(); - - // Cause a connect to happen - RDebug::Print(_L("PointerBufferPurge - AllocPointerMoveBuffer()")); - win.AllocPointerMoveBuffer(10, 0); - - // Allow pen events to be received - RDebug::Print(_L("PointerBufferPurge - EnablePointerMoveBuffer()")); - win.EnablePointerMoveBuffer(); - - // Simulate some pen events - RDebug::Print(_L("PointerBufferPurge - Events")); - SimulatePointer(TRawEvent::EPointerMove,10,20); - SimulatePointer(TRawEvent::EButton1Down,10,20); - SimulatePointer(TRawEvent::EPointerMove,11,21); - SimulatePointer(TRawEvent::EButton1Up,11,21); - - // Disconnect - RDebug::Print(_L("PointerBufferPurge - FreePointerMoveBuffer()")); - win.FreePointerMoveBuffer(); - - // Send sufficient events to cause a purge to happen - for (TInt i=0; iiWs.SetAutoFlush(iTheClientFlush); - iQueueClient->iWs.SetAutoFlush(iQuequeClientFlush); - } - -/** - * @SYMTestCaseID GRAPHICS-WSERV-0025 - * - * @SYMDEF DEF085009 - * - * @SYMTestCaseDesc Test removal of event handlers mid-way through processing an event. - * - * @SYMTestPriority Critical - * - * @SYMTestStatus Implemented - * - * @SYMTestActions The following tests use RRemovable anim to replicate the removal of - * event handlers mid-way through processing an event (where an event is offered to each of the - * listed event handlers). - * - * RRemovableAnim is an anim which removes itself from the event handler list - * after receiving n events, where n is the 'lifetime' of the anim measured in events received. - * By setting the lifetimes of a number of these anims, we replicate the removal of event handlers - * mid-way through processing an event. - * - * Event set 0: - * Sends 2 events e1,e2 and expects them be received by wserv event processing. - * - * Event set 1: (Simple scenario) - * Adds 3 removable anims to event handler list - * Sets lifetimes as {1000,2,5} - * Sends 6 events - * Expected events to be received by anims: {6,2,5} - * - * Event set 2: (Manual removal and reset state) - * Manually remove all anims from event handler list - * Sends 2 events - * No events expected to be received by anims - * Resets all anims ready for next test - * - * Event set 3: (Removal of multiple anims on receipt of same event) - * Adds 10 removable anims in event handler list - * Set lifetimes: {1,5,9,3,8,8,8,10,5,2} - * Sends 12 events: - * Expected number of received events for anims: {1,5,9,3,8,8,8,10,5,2} - * - * Event set 4: (Manual removal and reset state) - * Manually remove all anims from event handler list - * Sends 2 events - * No events expected to be received by anims - * Resets all anims ready for next test - * - * Event set 5: (Addition of anims to non-empty event handler list, part 1) - * Adds 6 removable anims in the event handler list - * Set lifetimes: {1,1,1,5,5,5} - * Sends 2 events: - * Expected number of received events for anims: {1,1,1,2,2,2} - * - * Event set 6: (Addition of anims to non-empty event handler list, part 2) - * Readds first 3 anims to event handler list - * Sets lifetimes of these three anims {13,24,6} - * Sends 5 events: - * Expected number of received events for anims: {5,5,5,3,3,3} - * - * Event set 7: (Addition of anims to non-empty event handler list, part 3) - * Sends 16 events: - * Expected number of received events for anims: {8,16,1,0,0,0} - * - * Event set 8: (Manual Removal and reset state) - * Manually remove all anims from event handler list - * Sends 2 events - * No events expected to be received by anims - * Resets all anims ready for next test - * - * Event set 9: (Creating anims which again generate events.) - * Create 3 anims. One anims generates events in its OfferrawEvent function. - * Check the funtionality of ProcessRawEvent in Wserv when it is called - * recursively. Also check the fix for defect INC095892. - * - * @SYMTestExpectedResults - * All events should be received by wserv event processing - * Each anim should only receive events when (number of events received by anim) <= (lifetime of anim) - */ -void CTEventTest::EventHandlerRemoval_NextSetOfEventsL() - { -#if defined(LOGGING) - INFO_PRINTF1(_L("EventHandlerRemoval SetOfEvents: (Max=8)")); -#endif - switch(iEventSet++) - { - case 0: - #if defined(LOGGING) - INFO_PRINTF1(_L("AUTO Event Handler Removal Anim Events")); - #endif - #if defined(DETAILED) - INFO_PRINTF1(_L("No anims in event handler list")); - INFO_PRINTF1(_L(" Send 2 events")); - INFO_PRINTF1(_L(" - Expected to be received by wserv event processing")); - #endif - // Always get a focus gain at start - AddExpectedEvent(EEventFocusGained); - // All expected to be received by wserv event processing - AddExpectedKey(EEventKeyDown,32,ETrue); - AddExpectedKey(EEventKeyUp,32,ETrue); - // Send 2 events - none expected to be received by anims, - iTest->SimulateKey(TRawEvent::EKeyDown,32); - iTest->SimulateKey(TRawEvent::EKeyUp,32); - // Flush events to wserv - TheClient->iWs.Flush(); - // Create all anims for all tests in first event set because - // first event set is only place where leaving functions can be called - EventHandlerRemoval_CreateAnimsL(10); - break; - case 1: - { - #if defined(DETAILED) - INFO_PRINTF1(_L(" Add 3 removable anims to event handler list")); - INFO_PRINTF1(_L(" Set lifetimes for anims: {1000,2,5}")); - INFO_PRINTF1(_L(" Send 6 events")); - INFO_PRINTF1(_L(" - Expected number of received events for anims: {6,2,5}")); - INFO_PRINTF1(_L(" All events expected to be received by wserv event processing")); - #endif - const TInt KLifetimes [] = {1000,2,5}; - EventHandlerRemoval_PrepareAnims(KLifetimes, 3); - EventHandlerRemoval_CreateExpectedEvents(6,3); - // Flush events to wserv - TheClient->iWs.Flush(); - // Check each anim has received the expected events - EventHandlerRemoval_CheckExpectedEventsReceivedByAnims(); - } - break; - case 2: - { - // Remove all anims, check removal was successful - // and reset all anims ready for next test - EventHandlerRemoval_RemoveAndResetAllAnims(); - } - break; - case 3: - { - #if defined(DETAILED) - INFO_PRINTF1(_L(" Add 10 removable anims in event handler list")); - INFO_PRINTF1(_L(" Set lifetimes: {1,5,9,3,8,8,8,10,5,2}")); - INFO_PRINTF1(_L(" Send 12 events")); - INFO_PRINTF1(_L(" - Expected number of received events for anims:{1,5,9,3,8,8,8,10,5,2}")); - INFO_PRINTF1(_L(" All expected to be received by wserv event processing")); - #endif - const TInt KLifetimes [] = {1,5,9,3,8,8,8,10,5,2}; - - // Create anims, set lifetimes, add to event handlers and add to iRemovableAnims array - EventHandlerRemoval_PrepareAnims(KLifetimes, 10); - EventHandlerRemoval_CreateExpectedEvents(12,10); - // Flush events to wserv - TheClient->iWs.Flush(); - // Check each anim has received the expected events - EventHandlerRemoval_CheckExpectedEventsReceivedByAnims(); - } - break; - case 4: - { - // Remove all anims, check removal was successful - // and reset all anims ready for next test - EventHandlerRemoval_RemoveAndResetAllAnims(); - } - break; - case 5: - { - #if defined(DETAILED) - INFO_PRINTF1(_L(" Add 6 removable anims in event handler list")); - INFO_PRINTF1(_L(" Set lifetimes: {1,1,1,5,5,5}")); - INFO_PRINTF1(_L(" Send 2 events")); - INFO_PRINTF1(_L(" - Expected number of received events for anims:{1,1,1,2,2,2}")); - INFO_PRINTF1(_L(" All expected to be received by wserv event processing")); - #endif - const TInt KLifetimes [] = {1,1,1,5,5,5}; - - // Create anims, set lifetimes, add to event handlers and add to iRemovableAnims array - EventHandlerRemoval_PrepareAnims(KLifetimes, 6); - EventHandlerRemoval_CreateExpectedEvents(2, 6); - // Flush events to wserv - TheClient->iWs.Flush(); - // Check each anim has received the expected events - EventHandlerRemoval_CheckExpectedEventsReceivedByAnims(); - } - break; - case 6: - { - #if defined(DETAILED) - INFO_PRINTF1(_L(" Readds first 3 removable anims to event handler list")); - INFO_PRINTF1(_L(" Set lifetimes of these three anims {13,24,6}")); - INFO_PRINTF1(_L(" Send 5 events")); - INFO_PRINTF1(_L(" - Expected number of received events for anims: {5,5,5,3,3,3}")); - INFO_PRINTF1(_L(" All expected to be received by wserv event processing")); - #endif - const TInt KLifetimes [] = {13,24,6}; - - // Create anims, set lifetimes, add to event handlers and add to iRemovableAnims array - EventHandlerRemoval_PrepareAnims(KLifetimes, 3); - EventHandlerRemoval_CreateExpectedEvents(5, 6); - // Flush events to wserv - TheClient->iWs.Flush(); - // Check each anim has received the expected events - EventHandlerRemoval_CheckExpectedEventsReceivedByAnims(); - } - break; - case 7: - { - #if defined(DETAILED) - INFO_PRINTF1(_L(" Send 16 events")); - INFO_PRINTF1(_L(" - Expected number of received events for anims:{8,16,1,0,0,0}")); - INFO_PRINTF1(_L(" All expected to be received by wserv event processing")); - #endif - EventHandlerRemoval_CreateExpectedEvents(16, 3); - // Flush events to wserv - TheClient->iWs.Flush(); - // Check each anim has received the expected events - EventHandlerRemoval_CheckExpectedEventsReceivedByAnims(); - } - break; - case 8: - { - // Remove all anims, check removal was successful - // and reset all anims ready for next test - EventHandlerRemoval_RemoveAndResetAllAnims(); - } - break; - case 9: - EventHandlerRemoval_CheckRecursionOfProcessRawEvent(); - break; - case 10: - EventHandlerRemoval_AddEventHandlerMultipleTimes(); - break; - default: - #if defined(DETAILED) - INFO_PRINTF1(_L(" Test postamble")); - INFO_PRINTF1(_L(" Destroy anims")); - #endif - // Destroy anims - EventHandlerRemoval_DestroyAllAnims(); - iRemovableAnims->Close(); - delete iRemovableAnims; - iRemovableAnims = NULL; - CActiveScheduler::Stop(); - break; - } - TheClient->iWs.Flush(); - } - -/** - * Creates an array of aAnimCount anims on heap - * Assigns array to iRemovableAnims for use in rest of tests - */ -void CTEventTest::EventHandlerRemoval_CreateAnimsL(TInt aAnimCount) - { - RPointerArray* removableAnims = new (ELeave) RPointerArray(); - CleanupStack::PushL(removableAnims); - for (TInt animIndex = 0; animIndex < aAnimCount; animIndex++) - { - RRemovableAnim* anim = RRemovableAnim::NewLC(iQueueClient->iWin->BaseWin(), iAnimDll); - removableAnims->AppendL(anim); - } - CleanupStack::Pop(aAnimCount, (*removableAnims)[0]); - CleanupStack::Pop(removableAnims); - iRemovableAnims = removableAnims; - } - -/** - * Sets lifetimes of anims as specified in aLifeTimes - * Adds anims to event handler list - */ -void CTEventTest::EventHandlerRemoval_PrepareAnims(const TInt* aLifetimes, TInt aAnimCount) - { - for (TInt animIndex = 0; animIndex < aAnimCount; animIndex++) - { - RRemovableAnim* anim = (*iRemovableAnims)[animIndex]; - anim->SetEventHandlerLifetime(aLifetimes[animIndex]); - anim->AddToEventHandlers(); - } - } - -/** - * Creates aEventCount key events to be used in test - * Adds the expected event aEvent to the first aLiveAnimCount anims - * Adds expected events observed by the rest of wserv - * Simulates events on wserv - */ -void CTEventTest::EventHandlerRemoval_CreateExpectedEvents(TInt aEventCount, TInt aLiveAnimCount) - { - RArray events; - - // Add expected events to anims - for (TInt eventCount = 0; eventCount < aEventCount; eventCount++) - { - TRawEvent rawEvent; - TInt scanCode = 33 + eventCount; - // Alternate key down, key up events. - if (eventCount%2 == 0) - { - rawEvent.Set(TRawEvent::EKeyDown, scanCode); - } - else - { - rawEvent.Set(TRawEvent::EKeyUp, scanCode); - } - EventHandlerRemoval_AddExpectedEvent(rawEvent, aLiveAnimCount); - events.Append(rawEvent); - } - - // Simulates expected events - for (TInt eventCount = 0; eventCount < aEventCount; eventCount++) - { - TRawEvent event = events[eventCount]; - iTest->SimulateKey(event.Type(), event.ScanCode()); - } - - events.Close(); - } - -/** - * Adds the expected event aEvent to the first aLiveAnimCount anims - * Adds expected event observed by the rest of wserv - */ -void CTEventTest::EventHandlerRemoval_AddExpectedEvent(TRawEvent aEvent, TInt aLiveAnimCount) - { - // Add event to each of the anims - for (TInt animIndex = 0; animIndex < aLiveAnimCount; animIndex++) - { - TInt err = (*iRemovableAnims)[animIndex]->AddExpectedEvent(aEvent); - } - TInt eventType = (aEvent.Type() == TRawEvent::EKeyDown ? EEventKeyDown : EEventKeyUp); - AddExpectedKey(eventType, aEvent.ScanCode(), ETrue); - } - -/** - * Checks each anim has received the expected events - */ -void CTEventTest::EventHandlerRemoval_CheckExpectedEventsReceivedByAnims() - { - for (TInt animIndex = iRemovableAnims->Count() - 1; animIndex >= 0; animIndex--) - { - if (!(*iRemovableAnims)[animIndex]->TestPassed()) - { - Failed(); - break; - } - } - } - - -/** - * Create three anims. In the first anim's Offer raw event generate two more events - * which will call recursively the process raw event at the server side. - * The second and third anims are just removable anims. To simulate the scenario - * for the defect INC095892. If teh fix for this is defect is not supplied then - * wserv would panic for this test case. - */ -void CTEventTest::EventHandlerRemoval_CheckRecursionOfProcessRawEvent() - { - iTheClientFlush=TheClient->iWs.SetAutoFlush(ETrue); - iQuequeClientFlush=iQueueClient->iWs.SetAutoFlush(ETrue); - - // Create 3 anims - RRemovableAnim* eventRecurAnim = RRemovableAnim::NewLC(iQueueClient->iWin->BaseWin(), iAnimDll); - RRemovableAnim* removableAnim = RRemovableAnim::NewLC(iQueueClient->iWin->BaseWin(), iAnimDll); - RRemovableAnim* eventAnim = RRemovableAnim::NewLC(iQueueClient->iWin->BaseWin(), iAnimDll); - - // Add these anim as event handlers and set thier respective life time - eventRecurAnim->AddToEventHandlers(); - eventRecurAnim->SetEventHandlerLifetime(4); - - removableAnim->AddToEventHandlers(); - removableAnim->SetEventHandlerLifetime(1); - - eventAnim->AddToEventHandlers(); - eventAnim->SetEventHandlerLifetime(2); - - TRawEvent rawEvent1; - TRawEvent rawEvent2; - TRawEvent rawEvent3; - rawEvent1.Set(TRawEvent::EKeyDown, 60); - rawEvent2.Set(TRawEvent::EKeyUp, 34); - rawEvent3.Set(TRawEvent::EKeyUp, 35); - - eventRecurAnim->AddExpectedEvent(rawEvent2); - eventRecurAnim->AddExpectedEvent(rawEvent3); - - removableAnim->AddExpectedEvent(rawEvent2); - - eventAnim->AddExpectedEvent(rawEvent2); - eventAnim->AddExpectedEvent(rawEvent3); - - // Add these events to iQueueClient for testing - AddExpectedKey(EEventKeyUp, 34, ETrue); - AddExpectedKey(EEventKeyUp, 35, ETrue); - - iTest->SimulateKey(rawEvent1.Type(), rawEvent1.ScanCode()); - - CleanupStack::PopAndDestroy(3, eventRecurAnim); - - TheClient->iWs.SetAutoFlush(iTheClientFlush); - iQueueClient->iWs.SetAutoFlush(iQuequeClientFlush); - } - -/** - * Manually removes all anims from event handlers array - */ -void CTEventTest::EventHandlerRemoval_ManuallyRemoveAllAnims() - { - // Manually remove all anims from event handler list - for (TInt animIndex = iRemovableAnims->Count() - 1; animIndex >= 0; animIndex--) - { - (*iRemovableAnims)[animIndex]->RemoveFromEventHandlers(); - } - } - -/** - * Manually removes all anims from event handlers array - */ -void CTEventTest::EventHandlerRemoval_ResetAllAnims() - { - // Manually remove all anims from event handler list - for (TInt animIndex = iRemovableAnims->Count() - 1; animIndex >= 0; animIndex--) - { - (*iRemovableAnims)[animIndex]->Reset(); - (*iRemovableAnims)[animIndex]->SetEventHandlerLifetime(0); - } - } - -/** - * Manually removes all anims from event handler list - * Sends 2 events - * Checks that no events have been received by anims - * Resets all anims ready for next test - */ -void CTEventTest::EventHandlerRemoval_RemoveAndResetAllAnims() - { -#if defined(DETAILED) - INFO_PRINTF1(_L(" Manually remove all anims from event handler list")); - INFO_PRINTF1(_L(" Send 2 events: none expected to be received by anims")); - INFO_PRINTF1(_L(" All expected to be received by wserv event processing")); -#endif - // Manually remove all anims from event handler list - EventHandlerRemoval_ManuallyRemoveAllAnims(); - // All expected to be received by wserv event processing - AddExpectedKey(EEventKeyDown,32,ETrue); - AddExpectedKey(EEventKeyUp,32,ETrue); - // Send 2 events - none expected to be received by anims, - iTest->SimulateKey(TRawEvent::EKeyDown,32); - iTest->SimulateKey(TRawEvent::EKeyUp,32); - // Flush events to wserv - TheClient->iWs.Flush(); - // Check the anims have not received any events - EventHandlerRemoval_CheckExpectedEventsReceivedByAnims(); -#if defined(DETAILED) - INFO_PRINTF1(_L(" Cleanup before next step")); -#endif - // Reset anims - EventHandlerRemoval_ResetAllAnims(); - } - -/** - * Destroys all anims in iRemovableAnims - * Resets iRemovableAnims - */ -void CTEventTest::EventHandlerRemoval_DestroyAllAnims() - { - if (iRemovableAnims) - { - // Destroy anims - for (TInt animIndex = iRemovableAnims->Count() - 1; animIndex >= 0; animIndex--) - { - RRemovableAnim* anim = (*iRemovableAnims)[animIndex]; - if (anim) - { - anim->Destroy(); - } - } - iRemovableAnims->Reset(); - } - } - -/** -SYMTestCaseID GRAPHICS-WSERV-0496 - -@SYMDEF DEF133776 - -@SYMTestCaseDesc Cancels key captures using all combinations of - RWindowGroup::Capture...() and RWindowGroup::Cancel...() APIs. - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Call each of the RWindowGroup::Capture***() APIs followed by - each of the RWindowGroup::CancelCapture***() APIs. - RWindowGroup::Capture***() APIs: - CaptureKey(TUint, TUint, TUint) - CaptureKey(TUint, TUint, TUint, TInt) - CaptureKeyUpAndDowns(TUint, TUint, TUint) - CaptureKeyUpAndDowns(TUint, TUint, TUint, TInt) - CaptureLongKey(TUint, TUint, TUint, TUint, TInt, TUint) - CaptureLongKey(TTimeIntervalMicroSeconds32, TUint, TUint, TUint, TUint, TInt, TUint) - RWindowGroup::CancelCapture***() APIs: - CancelCaptureKey() - CancelCaptureKeyUpAndDowns() - CancelCaptureLongKey() - -@SYMTestExpectedResults WServ should handle matched and mismatched Cancel - and Capture calls without panicking. - */ -void CTEventTest::MismatchedCapture_NextSetOfEventsL() - { - if (iEventSet == 0) - AddExpectedEvent(EEventFocusGained); - - if (iEventSet < (EMaxCaptureKeyApis*EMaxCancelCaptureKeyApis)) - { - TestCaptureAndCancelCapturePair(static_cast(iEventSet%EMaxCaptureKeyApis), static_cast(iEventSet/EMaxCaptureKeyApis)); - iEventSet++; - } - else - { - CActiveScheduler::Stop(); - } - } - -/** Helper function that applies a key capture and then cancels it using the -passed capture and cancel RWindowGroup APIs. - -@param aCaptureApi Enum value specifying the capture API to use -@param aCancelCaptureApi Enum value specifying the cancel capture API to use - */ -void CTEventTest::TestCaptureAndCancelCapturePair(TCaptureKeyApis aCaptureApi, TCancelCaptureKeyApis aCancelCaptureApi) - { -#if defined(LOGGING) - _LIT(KCaptureKey, "CaptureKey"); - _LIT(KCaptureKeyKeyUpAndDowns, "CaptureKeyKeyUpAndDowns"); - _LIT(KCaptureLongKey, "CaptureLongKey"); - _LIT(KCancelCaptureKey, "CancelCaptureKey"); - _LIT(KCancelCaptureKeyKeyUpAndDowns, "CancelCaptureKeyKeyUpAndDowns"); - _LIT(KCancelCaptureLongKey, "CancelCaptureLongKey"); - _LIT(KLog,"TestCaptureAndCancelCapturePair: %S, %S"); - TPtrC captures[EMaxCaptureKeyApis] = {KCaptureKey(), KCaptureKey(), KCaptureKeyKeyUpAndDowns(), KCaptureKeyKeyUpAndDowns(), KCaptureLongKey(), KCaptureLongKey()}; - TPtrC cancelCaptures[EMaxCancelCaptureKeyApis] = {KCancelCaptureKey(), KCancelCaptureKeyKeyUpAndDowns(), KCancelCaptureLongKey()}; - TLogMessageText logMessageText; - logMessageText.Format(KLog, &captures[aCaptureApi], &cancelCaptures[aCancelCaptureApi]); - INFO_PRINTF1(logMessageText); -#endif // LOGGING - - // Start a key capture using one of the six RWindowGroup Capture***() APIs - switch (aCaptureApi) - { - case ECaptureKey1: - case ECaptureKey2: - // Test RWindowGroup::CaptureKey() - if (aCaptureApi == ECaptureKey1) - iCaptureKey = iQueueClient->iGroup->GroupWin()->CaptureKey('A',0,0); - else - iCaptureKey = iQueueClient->iGroup->GroupWin()->CaptureKey('A',0,0,1); // priority 1 (default priority is 0) - iTest->SimulateKey(TRawEvent::EKeyDown, 'A'); - TheClient->iWs.Flush(); - User::After(KeyRepeatTime()*3/2); - iTest->SimulateKey(TRawEvent::EKeyUp, 'A'); - TheClient->iWs.Flush(); - AddExpectedKey(EEventKeyDown, 'A'); - AddExpectedKey(EEventKey,'A','a'); - AddExpectedKey(EEventKey,'A','a',1); - AddExpectedKey(EEventKeyUp, 'A'); - break; - - case ECaptureKeyUpAndDowns1: - case ECaptureKeyUpAndDowns2: - // Test RWindowGroup::CaptureKeyUpAndDowns() - if (aCaptureApi == ECaptureKeyUpAndDowns1) - iCaptureKey=iQueueClient->iGroup->GroupWin()->CaptureKeyUpAndDowns(EStdKeySpace,0,0); - else - iCaptureKey=iQueueClient->iGroup->GroupWin()->CaptureKeyUpAndDowns(EStdKeySpace,0,0,1); // priority 1 (default priority is 0) - iTest->SimulateKey(TRawEvent::EKeyDown,EStdKeySpace); - TheClient->iWs.Flush(); - User::After(KeyRepeatTime()*3/2); - iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeySpace); - TheClient->iWs.Flush(); - AddExpectedKey(EEventKeyDown,EStdKeySpace); - AddExpectedKey(EEventKey,EStdKeySpace,' '); - AddExpectedKey(EEventKey,EStdKeySpace,' ',1); - AddExpectedKey(EEventKeyUp,EStdKeySpace); - break; - - case ECaptureLongKey1: - case ECaptureLongKey2: - { - // Test RWindowGroup::CaptureLongKey() - TTimeIntervalMicroSeconds32 repeat = KeyRepeatTime(); - if (aCaptureApi == ECaptureLongKey1) - { - iCaptureKey = iQueueClient->iGroup->GroupWin()->CaptureLongKey(' ', 'a', 0, 0, 2, ELongCaptureNormal); - } - else - { - repeat = KeyRepeatTime()/2; - iCaptureKey = iQueueClient->iGroup->GroupWin()->CaptureLongKey(repeat, ' ', 'a', 0, 0, 2, ELongCaptureNormal); - } - iQueueClient->iWs.Flush(); - iTest->SimulateKey(TRawEvent::EKeyDown,EStdKeySpace); - TheClient->iWs.Flush(); - User::After(KeyRepeatTime()*3/2); - iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeySpace); - TheClient->iWs.Flush(); - AddExpectedKey(EEventKeyDown,EStdKeySpace); - AddExpectedKey(EEventKey,EStdKeySpace,' '); - AddExpectedKey(EEventKey,EStdKeySpace,'a',1); - AddExpectedKey(EEventKeyUp,EStdKeySpace); - } - break; - - default: - INFO_PRINTF1(_L("Unexpected TCaptureKeyApis value passed to CTEventTest::TestCaptureAndCancelCapturePair()")); - TEST(EFalse); - break; - } - - if (iCaptureKey) - { - // End a capture using one of the three RWindowGroup CancelCapture***() APIs, - // for each Capture***() API each one of these will be called, therefore there will - // be one correct CancelCapture***() APIs called and two incorrect CancelCapture***() - // APIs called for each Capture***() API. - switch (aCancelCaptureApi) - { - case ECancelCaptureKey: - iQueueClient->iGroup->GroupWin()->CancelCaptureKey(iCaptureKey); - break; - case ECancelCaptureKeyUpAndDowns: - iQueueClient->iGroup->GroupWin()->CancelCaptureKeyUpAndDowns(iCaptureKey); - break; - case ECancelCaptureLongKey: - iQueueClient->iGroup->GroupWin()->CancelCaptureLongKey(iCaptureKey); - break; - default: - INFO_PRINTF1(_L("Unexpected TCancelCaptureKeyApis value passed to CTEventTest::TestCaptureAndCancelCapturePair()")); - TEST(EFalse); - break; - } - - // If an mistmatched CancelCapture***() API was called, call the correct one now - // to make sure the Capture/CancelCapture state is clean before the next test starts - if ((aCaptureApi/2) != aCancelCaptureApi) - { - switch (aCaptureApi) - { - case ECaptureKey1: - case ECaptureKey2: - iQueueClient->iGroup->GroupWin()->CancelCaptureKey(iCaptureKey); - break; - case ECaptureKeyUpAndDowns1: - case ECaptureKeyUpAndDowns2: - iQueueClient->iGroup->GroupWin()->CancelCaptureKeyUpAndDowns(iCaptureKey); - break; - case ECaptureLongKey1: - case ECaptureLongKey2: - iQueueClient->iGroup->GroupWin()->CancelCaptureLongKey(iCaptureKey); - break; - } - } - } - - TheClient->iWs.Flush(); - } - -/*void CTEventTest::_NextSetOfEvents() //Template for these functions - { - switch(iEventSet++) - { - case 0: - iQueueClient->iWin->WinTreeNode()->; //Set up window - iQueueClient->iWin->BaseWin()->; - iQueueClient->iGroup->GroupWin()->; - iQueueClient->iWs.Flush(); //Make take effect - SimulateEvent(TRawEvent::); //Create an event - TheClient->iWs.Flush(); //Send event - AddExpectedEvent(EEventFocusGained); //Always get a focus gain at start - AddExpectedEvent(); //Expect the event that was created above - break; - case 1: - iQueueClient->iWs.Flush(); - SimulateEvent(TRawEvent::); - TheClient->iWs.Flush(); - AddExpectedEvent(); - break; - default: - CActiveScheduler::Stop(); - break; - } - TheClient->iWs.Flush(); - }*/ - -/** - @SYMTestCaseID GRAPHICS-WSERV-CODEBASE-WSERV-0051 - - @SYMPREQ PGM027 - - @SYMTestCaseDesc Tests SetKeyboardRepeatRate API. - - @SYMTestPriority 1 - - @SYMTestStatus Implemented - - @SYMTestActions This test tryes to call SetKeyboardRepeatRate with invalid time values\n - - @SYMTestExpectedResults KeyRepeatRateNegTest should tests the API SetKeyboardRepeatRate return value\n - The test should pass and API should return KErrArgument. - - */ -void CTEventTest::KeyRepeatRateNegTest(TInt aInitialRepeat, TInt aRepeat) - { - ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-CODEBASE-WSERV-0051")); - TInt ret=TheClient->iWs.SetKeyboardRepeatRate(TTimeIntervalMicroSeconds32(aInitialRepeat), TTimeIntervalMicroSeconds32(aRepeat)); - TEST(ret==KErrArgument); - TRAPD(err,((CTEventTestStep*)iStep)->RecordTestResultL()); - if (err!=KErrNone) - INFO_PRINTF1(_L("Failed to record test result")); - } - -void CTEventTest::RunTestsL(TBool aNeedChildWindows/*=EFalse*/) - { - iQueueClient=new(ELeave) CTQueueClient(this); - iQueueClient->SetScreenNumber(iTest->iScreenNumber); - iQueueClient->ConstructL(aNeedChildWindows); - iEventSet=0; - TRAPD(err,NextSetOfEventsL()); - if (err!=KErrNone) - { - iFailed=ETrue; - return; - } -// - CActiveScheduler::Start(); -// - TInt eventsLeft=iQueueClient->EventQueue()->EventsLeft(); - if (eventsLeft>0) - iFailed=ETrue; - delete iVisWins1; - iVisWins1 = NULL; - delete iVisWins2; - iVisWins2 = NULL; - delete iQueueClient; - iQueueClient=NULL; - } - -void CTEventTest::RunTestsRestoreAreaL(TBool aNeedChildWindows) - { - TRect area(TheClient->iWs.PointerCursorArea()); - RunTestsL(aNeedChildWindows); - TheClient->iWs.SetPointerCursorArea(area); - } - -/*void CTEventTest::QueuePurgingL() - { - RunTestsL(EFalse); - } - -void CTEventTest::SendEventL() - { - RunTestsL(EFalse); - } - -void CTEventTest::InvisibleWindowL() - { - RunTestsL(ETrue); - } - -void CTEventTest::JavaAdditionsL() - { - RunTestsL(EFalse); - }*/ - -void CTEventTest::WindowCapBugL() - { - RunTestsL(ETrue); - } - -/*void CTEventTest::XyInputTypeL() - { - RunTestsL(EFalse); - } - -void CTEventTest::MovingPointerCursorL() - { - RunTestsRestoreAreaL(ETrue); - } - -void CTEventTest::RotatedModeL() - { - RunTestsRestoreAreaL(EFalse); - }*/ - -/** -* This test creates one anim and calls AddToEventHandlers() twenty times. -* it shouldn't add the same anim to event handler if anim is already in handler. -*/ -void CTEventTest::EventHandlerRemoval_AddEventHandlerMultipleTimes() - { - iTheClientFlush=TheClient->iWs.SetAutoFlush(ETrue); - iQuequeClientFlush=iQueueClient->iWs.SetAutoFlush(ETrue); - - RRemovableAnim* eventTestAnim = RRemovableAnim::NewLC(iQueueClient->iWin->BaseWin(), iAnimDll); - - // Call AddToEventHandlers() on same anim 20 times, it should add this anim in event handler only once - for (TInt count = 0; count < 20; count++) - eventTestAnim->AddToEventHandlers(); - eventTestAnim->SetEventHandlerLifetime(1); - - TRawEvent rawEvent1; - rawEvent1.Set(TRawEvent::EKeyUp, 34); - - eventTestAnim->AddExpectedEvent(rawEvent1); - - // Add these events to iQueueClient for testing - AddExpectedKey(EEventKeyUp, 34, ETrue); - - iTest->SimulateKey(TRawEvent::EKeyUp, 34); - - CleanupStack::PopAndDestroy(eventTestAnim); - TheClient->iWs.SetAutoFlush(iTheClientFlush); - iQueueClient->iWs.SetAutoFlush(iQuequeClientFlush); - } - -void CTEventTest::EventQueuePtrCrashTest() -// Code designed to hit the defect reported in INC109199 & INC105430, needs a very specific sequence of -// events and client disconnections to hit the exact problem state. - { - const TInt KNumTestEvents=6; - const TInt KMaxNumTestEvents=16; - // Number of iterations needs to be as high as the queue granularity to make sure at least - // once around we actually hit the code to change the queue size - const TInt KNumEvTestIterations=4; - const TInt KNumBaseTestSessions=KNumEvTestIterations+1; - const TInt KNumMainTestSessions=13; - const TInt KMaxNumSessions=KNumBaseTestSessions+KNumMainTestSessions+KNumEvTestIterations; - RWsSession wsSessions[KMaxNumSessions]; - RWindowGroup wGroups[KMaxNumSessions]; - for(TInt iterationLoop=0;iterationLoop=KNumBaseTestSessions) - { - TWsEvent event; - for(TInt evLoop=0;evLoopiWs.SendEventToWindowGroup(groupWin[0].Identifier(),event); - TheClient->iWs.SendEventToWindowGroup(groupWin[1].Identifier(),event); - } - - //To create a new client, although the queue is full, wserv will guarantee to initialize - //the queue size of the new queue to at least EMinQueueSize. So that it can response to - //the event. - RWsSession testWsSession; - RWindowGroup testGroupWin; - TRequestStatus testStatus; - if (aEventReadyCancel) - { - //Simulate the heap allocation failure to test expanding spaces by purge - //events from inactive clients when initialize queue size. - TInt failAt = 1; - TInt err; - do { - TheClient->iWs.HeapSetFail(RHeap::EFailNext, failAt++); - TheClient->iWs.Flush(); - err = testWsSession.Connect(); - TheClient->iWs.HeapSetFail(RHeap::ENone, 1); - } while (err == KErrNoMemory); - User::LeaveIfError(err); - } - else - { - User::LeaveIfError(testWsSession.Connect()); - } - CleanupClosePushL(testWsSession); - testGroupWin = RWindowGroup(testWsSession); - User::LeaveIfError(testGroupWin.Construct(cliHanGrpWin++)); - CleanupClosePushL(testGroupWin); - - //Send events to the newly created client. - // The Debug version of WServ puts a EEventFocusGained into the event - // before this test's custom event, so leave one slot in the queue - // for it. -#if (defined _DEBUG) - TInt testEventCount = EMinQueueSize - 1; -#else - TInt testEventCount = EMinQueueSize; -#endif - for(TInt evLoop = 0; evLoop < testEventCount; evLoop++) - { - event.SetType(3001 + evLoop); - TheClient->iWs.SendEventToWindowGroup(testGroupWin.Identifier(),event); - } - - //Check the event queue. - //Having a timer here to avoid infinitely wait for event. - TInt expectedEvent = 3001; - for(TInt evLoop = 0; evLoop < EMinQueueSize; evLoop++) - { - testWsSession.EventReady(&testStatus); - TRequestStatus timerStatus; - timer.After(timerStatus, oneSecond); - User::WaitForRequest(testStatus, timerStatus); - TEST(testStatus == 0); - if (testStatus == 0) - { - // Tests the event - testWsSession.GetEvent(event); - // WServ sometimes puts a EEventFocusGained event into the queue - // before the test's custom event, so ignore it. - if (event.Type() != EEventFocusGained) - { - TEST(event.Type() == expectedEvent); - expectedEvent++; - } - // testStatus has been completed. Cancel the timer. - timer.Cancel(); - User::WaitForRequest(timerStatus); - } - else - { - // Times out, cancel the event notification - testWsSession.EventReadyCancel(); - User::WaitForRequest(testStatus); - } - } - CleanupStack::PopAndDestroy(2*numClients + 2, &wsSession[0]); - } - CleanupStack::PopAndDestroy(&timer); - } - -void CTEventTest::SimulateRepeatEvent(TInt aScanCode, TInt aRepeats/*=0*/) - { - TRawEvent rawEvent; - if (aRepeats) - rawEvent.Set(TRawEvent::EKeyRepeat, aScanCode, aRepeats); - else - rawEvent.Set(TRawEvent::EKeyRepeat, aScanCode); - UserSvr::AddEvent(rawEvent); - } - -void CTEventTest::RawEventRepeatTest_NextSetOfEventsL() - { - switch(iEventSet++) - { - case 0: - // Tests EKeyRepeat without repeat value set. - SimulateRepeatEvent(32); - - // Tests EKeyRepeat with repeat value set to 2. - SimulateRepeatEvent(33,2); - - AddExpectedEvent(EEventFocusGained); - AddExpectedKey(EEventKey, 32); - AddExpectedKey(EEventKey, 33, 0, 2); - break; - default: - CActiveScheduler::Stop(); - break; - } - TheClient->iWs.Flush(); - } - -void CTEventTest::RunTestCaseL(TInt /*aCurTestCase*/) - { - _LIT(KTest0,"General 1"); - _LIT(KTest1,"Event queue purging"); - _LIT(KTest2,"SendEvent"); - _LIT(KTest3,"SendEventToAll"); - _LIT(KTest4,"InvisibleWindow"); - _LIT(KTest5,"JavaAdditions"); - _LIT(KTest6,"WindowCaptureBug"); - _LIT(KTest7,"XYInput Types"); - _LIT(KTest8,"MovingPointerCursor"); - _LIT(KTest9,"Rotated Modes"); - _LIT(KTest10,"Anim Event"); - _LIT(KTest11,"Focus Changed"); - _LIT(KTest12,"On/Off Events"); - _LIT(KTest13,"Virtual Keyboard"); - _LIT(KTest14,"Key Clicks"); - _LIT(KTest15,"Capture Long"); - _LIT(KTest16,"Password Window"); - _LIT(KTest17,"Group List Changed"); - _LIT(KTest18,"Repeatable Key Events"); - _LIT(KTest19,"Screen Scaling"); - _LIT(KTest20,"Visibility Changed Events"); - _LIT(KTest21,"Check Time Stamp Of Events"); - _LIT(KTest22,"Pointer Capture Priority Events"); - _LIT(KTest23,"Event Handler Removal"); - _LIT(KTest24,"Event Queue ptr crash test"); - _LIT(KTest25,"Mismatched Pointer Events"); - _LIT(KTest26,"Pointer Buffer Purge"); - _LIT(KTest27,"TRawEvent test for Repeats"); -#ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS -#ifndef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - _LIT(KTest28,"Transparent Surface Visibility Changed Events 1"); - _LIT(KTest29,"Transparent Surface Visibility Changed Events 2"); - _LIT(KTest30,"Transparent Surface Visibility Changed Events 3"); -#endif // TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA -#endif // SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS - _LIT(KTest31A,"Initialize Queue Size without inactive queue"); - _LIT(KTest31B,"Initialize Queue Size with inactive queue"); - - if (!TestBase()->ConfigurationSupportsPointerEventTesting()) - { - INFO_PRINTF1(_L("Test skipped because config does not support pointer event testing")); - TestComplete(); - return; - } - - //if (iTest->iState==1) iTest->iState=14; //Use this line to skip to a particular test - ((CTEventTestStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); - switch(iTest->iState) - { -/** -@SYMTestCaseID GRAPHICS-WSERV-0053 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Carry out general event tests on WServ - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions General events are sent via WServ - -@SYMTestExpectedResults The events are sent without error -*/ - case 0: - iTest->LogSubTest(KTest0); - General(); - ((CTEventTestStep*)iStep)->SetOverallTestStepID(_L("GRAPHICS-WSERV-0053")); - //iState=8; - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0054 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Carry out event queue purging - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Purge the event queue - -@SYMTestExpectedResults The events queue is purged without error -*/ - case 1: - ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0054")); - iTest->LogSubTest(KTest1); - RunTestsL(); //QueuePurgingL(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0055 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test that events can be sent - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Send events in WServ - -@SYMTestExpectedResults The events are sent without error -*/ - case 2: - ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0055")); - iTest->LogSubTest(KTest2); - RunTestsL(); //SendEventL(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0056 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Send an event to all window groups - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Send an event to all window groups - -@SYMTestExpectedResults The events are sent to all window groups - without error -*/ - case 3: - ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0056")); - iTest->LogSubTest(KTest3); - General2(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0057 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Send events to an invisible window - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Send events to an invisible window - -@SYMTestExpectedResults The events are sent to the window without - error -*/ - case 4: - ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0057")); - iTest->LogSubTest(KTest4); - RunTestsL(ETrue); //InvisibleWindowL(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0058 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Send events for java additions - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Send events for java additions - -@SYMTestExpectedResults The events are sent to the window without - error -*/ - case 5: - ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0058")); - iTest->LogSubTest(KTest5); - RunTestsL(); //JavaAdditionsL(); - break; - - case 6: - ((CTEventTestStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - iTest->LogSubTest(KTest6); - //WindowCapBugL(); //Not finished - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0059 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Send events for x and y inputs - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Send events for x and y inputs - -@SYMTestExpectedResults The events are sent to the window without - error -*/ - case 7: - ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0059")); - iTest->LogSubTest(KTest7); - RunTestsL(); //XyInputTypeL(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0060 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Send events for moving pointer cursor - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Send events for moving pointer cursor - -@SYMTestExpectedResults The events are sent to the window without - error -*/ - case 8: - ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0060")); - iTest->LogSubTest(KTest8); - RunTestsRestoreAreaL(ETrue); //MovingPointerCursorL(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0061 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Send events for rotate mode - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Send events for rotate mode - -@SYMTestExpectedResults The events are sent to the window without - error -*/ - case 9: - ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0061")); - iTest->LogSubTest(KTest9); - RunTestsRestoreAreaL(EFalse); //RotatedModeL(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0062 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Send events for an anim event - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Send events for an anim event - -@SYMTestExpectedResults The events are sent to the window without - error -*/ - case 10: - ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0062")); - iTest->LogSubTest(KTest10); - RunTestsRestoreAreaL(EFalse); //AnimEvent(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0063 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Send events for focus changed - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Send events for focus changed - -@SYMTestExpectedResults The events are sent to the window without - error -*/ - case 11: - ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0063")); - iTest->LogSubTest(KTest11); - RunTestsL(); //FocusChanged(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0064 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Send stop events - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Send stop events - -@SYMTestExpectedResults The events are sent to the window without - error -*/ - case 12: - ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0064")); - iTest->LogSubTest(KTest12); - RunTestsL(ETrue); //StopEvents(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0065 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Send events for the virtual keyboard - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Send events for the virtual keyboard - -@SYMTestExpectedResults The events are sent to the window without - error -*/ - case 13: - ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0065")); - iTest->LogSubTest(KTest13); - RunTestsL(); //VirtualKeyboard(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0066 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Send events for key clicks - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Send stop events - -@SYMTestExpectedResults The events are sent to the window without - error -*/ - case 14: - ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0066")); - iTest->LogSubTest(KTest14); - { - TBool changeable; - if (iClick.IsLoaded(changeable) && !iTest->IsFullRomL()) - RunTestsL(ETrue); //KeyClicks(); - } - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0067 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Send events for capturing large areas of text - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Send events for capturing large areas of text - -@SYMTestExpectedResults The events are sent to the window without - error -*/ - case 15: - ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0067")); - iTest->LogSubTest(KTest15); - RunTestsL(ETrue); //CaptureLong(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0068 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Send events for activating password - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Send events for activating password - -@SYMTestExpectedResults The events are sent to the window without - error -*/ - case 16: - ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0068")); - iTest->LogSubTest(KTest16); - if (!iTest->IsFullRomL()) - RunTestsL(); //Password(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0069 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Send events for activating password - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Send events for activating password - -@SYMTestExpectedResults The events are sent to the window without - error -*/ - case 17: - ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0069")); - iTest->LogSubTest(KTest17); - RunTestsL(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0070 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Send repeatable key events - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Send repeatable key events - -@SYMTestExpectedResults The events are sent to the window without - error -*/ - case 18: - ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0070")); - iTest->LogSubTest(KTest18); - RunTestsL(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0071 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Send Screen Scaling events - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Send Screen Scaling events - -@SYMTestExpectedResults The events are sent to the window without - error -*/ - case 19: - ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0071")); - iTest->LogSubTest(KTest19); - if (iScreenModeTests&EDoScale) - { - RunTestsL(); - } - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0072 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Send Visibility Changed events - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Send Visibility Changed events - -@SYMTestExpectedResults The events are sent to the window without - error -*/ - case 20: - ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0072")); - iTest->LogSubTest(KTest20); - RunTestsL(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0073 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Check Time Stamp Of Sent Events - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Check Time Stamp Of Sent Events - -@SYMTestExpectedResults The time stamps for the events are correct -*/ - case 21: - ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0073")); - iTest->LogSubTest(KTest21); - RunTestsL(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0074 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Send Pointer Capture Priority Events - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Send Pointer Capture Priority Events - -@SYMTestExpectedResults The events are sent to the window without - error -*/ - case 22: - ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0074")); - iTest->LogSubTest(KTest22); - RunTestsL(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0343 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Send Event Handler Removal Events - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Send Event Handler Removal Events - -@SYMTestExpectedResults The events are sent to the window without - error -*/ - case 23: - ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0343")); - iTest->LogSubTest(KTest23); - RunTestsL(); //EventHandlerRemoval(); - break; - case 24: -/** -@SYMTestCaseID GRAPHICS-WSERV-0565 -*/ - ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0565")); - iTest->LogSubTest(KTest24); - EventQueuePtrCrashTest(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0496 - -@SYMDEF DEF133776 - -@SYMTestCaseDesc Cancels key captures using all combinations of - RWindowGroup::Capture...() and RWindowGroup::Cancel...() APIs. - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Call each of the RWindowGroup::Capture***() APIs followed by - each of the RWindowGroup::CancelCapture***() APIs. - RWindowGroup::Capture***() APIs: - CaptureKey(TUint, TUint, TUint) - CaptureKey(TUint, TUint, TUint, TInt) - CaptureKeyUpAndDowns(TUint, TUint, TUint) - CaptureKeyUpAndDowns(TUint, TUint, TUint, TInt) - CaptureLongKey(TUint, TUint, TUint, TUint, TInt, TUint) - CaptureLongKey(TTimeIntervalMicroSeconds32, TUint, TUint, TUint, TUint, TInt, TUint) - RWindowGroup::CancelCapture***() APIs: - CancelCaptureKey() - CancelCaptureKeyUpAndDowns() - CancelCaptureLongKey() - -@SYMTestExpectedResults WServ should handle matched and mismatched Cancel - and Capture calls without panicking. -*/ - case 25: -// Skip this test in debug on the emulator, run it always on hardware as debug ROMs include -// a release version of the production code that doesn't panic - ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0496")); -#if defined(_DEBUG) && !defined (__MARM__) - INFO_PRINTF1(_L("Skipping this test in _DEBUG on emulator to avoid debug only panics, see GRAPHICS-WSERV-0497 for the matching panic test")); -#else - iTest->LogSubTest(KTest25); - RunTestsL(); -#endif - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0444 - -@SYMDEF PDEF110849 - -@SYMTestCaseDesc Pointer Buffer Exception After Event Queue Purge - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Connect to pointer buffer, send it some pointer events and disconnect. - Now send enough events to cause an event queue purge. The purge will - attempt to empty the pointer buffer, but will fail because we have disconnected. - -@SYMTestExpectedResults The purge will realise it does not need to empty the pointer buffer and - so there will not be an access violation - exception. - -*/ - case 26: - ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0444")); - iTest->LogSubTest(KTest26); - RunTestsL(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0484 -@SYMDEF PDEF120721 -@SYMTestCaseDesc Window server guarantees to initialize the queue size of the new queue to - at least EMinQueueSize. -@SYMTestPriority High -@SYMTestStatus Implemented -@SYMTestActions Create multiple clients to connect to window server. - Send enough events to make the event queue full. - Create a new client to connect to window server. - Send events to the new client and test that the new client - can get the events. -@SYMTestExpectedResults Window server guarantees to initialize the size of the new event - queue to EMinQueueSize, so that window server will not lock up - due to the full of global event queue. - -*/ - case 27: - iTest->LogSubTest(KTest27); - RunTestsL(); - break; - -#ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS -#ifndef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA -/** -@SYMTestCaseID GRAPHICS-WSERV-2669-0015 -@SYMREQ REQ13202: Possibility for external layers to appear above UI layer -@SYMTestCaseDesc Window obscured by transparent surface window receives - (EPartiallyVisible | EFullyVisible) when surface is made semi-transparent. -@SYMTestPriority 2 -@SYMPrerequisites Win1 – bottom window - Win2 – middle window with background surface, which totally obscures win1 -@SYMTestActions Call SetSurfaceTransparency(ETrue) on win2 -@SYMTestExpectedResults Win1 receives visibility event -*/ - case 28: - ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-2669-0015")); - iTest->LogSubTest(KTest28); - RunTestsL(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-2669-0016 -@SYMREQ REQ13202: Possibility for external layers to appear above UI layer -@SYMTestCaseDesc Window obscured by semi-transparent surface window receives - (EPartiallyVisible | EFullyVisible) when obscuring window is deleted -@SYMTestPriority 2 -@SYMPrerequisites Win1 – bottom window - Win2 – middle window with semi-transparent background surface, which totally obscures win1 - Win3 – top window which totally obscures win2, and is opaque -@SYMTestActions Delete win3 -@SYMTestExpectedResults Both win1 and win2 receive visibility events -*/ - case 29: - ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-2669-0016")); - iTest->LogSubTest(KTest29); - RunTestsL(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-2669-0017 -@SYMREQ REQ13202: Possibility for external layers to appear above UI layer -@SYMTestCaseDesc Window does not receive any visibiliy event when a semi-transparent - surface is moved onto/above it. -@SYMTestPriority 2 -@SYMPrerequisites Win1 – bottom window - Win2 – top window which does not overlap win1 -@SYMTestActions Move win2 to overlap win1 -@SYMTestExpectedResults No visibility event is received (win1 is still fully visible) -*/ - case 30: - ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-2669-0017")); - iTest->LogSubTest(KTest30); - RunTestsL(); - break; -#endif // TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA -#endif // SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS - -/** -@SYMTestCaseID GRAPHICS-WSERV-0559 -@SYMDEF INC140850 -@SYMTestCaseDesc To check Wserv passes correct repeat value for TRawEvent of type EKeyRepeat. -@SYMTestPriority High -@SYMTestStatus Implemented -@SYMTestActions Simulate TRawEvent of type EKeyRepeat without Repeat value set. - Simulate the above with repeat value set to 2. -@SYMTestExpectedResults Simulated events should match expected events added to the array. -*/ - -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - case 28: -#else -#ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS - case 31: -#else - case 28: -#endif -#endif - // This test was moved to be the last test in the test suite, because it sometimes leaves events in the event queue, - //it can affect the results of other tests. This test case should be the last test in the test suite. - ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0484")); - iTest->LogSubTest(KTest31A); - InitializeQueueSizeTestL(EFalse); - iTest->LogSubTest(KTest31B); - InitializeQueueSizeTestL(ETrue); - break; - - default: - ((CTEventTestStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - ((CTEventTestStep*)iStep)->CloseTMSGraphicsStep(); - TestComplete(); - break; - } - ((CTEventTestStep*)iStep)->RecordTestResultL(); - if (iFailed) - { - TEST(EFalse); - iFailed=EFalse; - } - ++iTest->iState; - } - -__WS_CONSTRUCT_STEP__(EventTest) - diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TFADE.CPP --- a/windowing/windowserver/tauto/TFADE.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2126 +0,0 @@ -// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Test Fading and UnFading of windows -// -// - -#include "TFADE.H" -#define __DISPLAY_MODE_64K_COLOR - -//CRedrawWin - -CRedrawWin::CRedrawWin(CTFade *aTest) : CTWin(), iTest(aTest) - {} - -CRedrawWin::~CRedrawWin() - { - } - -void CRedrawWin::ConstructL(TRect aArea) - { - - ConstructExtLD(*TheClient->iGroup,aArea.iTl,aArea.Size()); - AssignGC(*TheClient->iGc); - Activate(); - iWin.BeginRedraw(); - iWin.EndRedraw(); - } - -void CRedrawWin::Draw() - { - iTest->Drawing(iTest->Content(),iGc); - } - - -//CFadeTest - -CTFade::CTFade(CTestStep* aStep) : CTWsGraphicsBase(aStep) - { -#if defined (__MARM_THUMB__) - CanFade = false; - CanFadeSet = false; -#endif - } - -void CTFade::ConstructL() - { - iDeviceDisplayMode=TheClient->iScreen->DisplayMode(); - iTestWinSize=StdTestWindowSize(); - iFadeDrawMode = iDeviceDisplayMode; - iTestWinCopy = new (ELeave) CFbsBitmap(); - iTestWinCopy->Create(iTestWinSize,TheClient->iScreen->DisplayMode()); - iCheckWinCopy = new (ELeave) CFbsBitmap(); - iCheckWinCopy->Create(iTestWinSize,TheClient->iScreen->DisplayMode()); - } - -CTFade::~CTFade() - { - __ASSERT_ALWAYS(!iBlankWin,AutoPanic(EAutoFadeWindow)); - delete iTestWinCopy; - delete iCheckWinCopy; - } - -TInt CTFade::Content() - { - return iContent; - } - -void CTFade::CreateBlankWindowL() - { - __ASSERT_ALWAYS(!iBlankWin,AutoPanic(EAutoFadeWindow)); - TSize scrSize(TheClient->iScreen->SizeInPixels()); - iTestWinSize.SetSize(2*scrSize.iWidth/3-6,scrSize.iHeight-6); - iBlankWin=new(ELeave) CTBlankWindow(); - iWindowRect.SetRect(TPoint(3+scrSize.iWidth/3,3),iTestWinSize); - iBlankWin->SetUpL(iWindowRect.iTl,iTestWinSize,TheClient->iGroup,*TheClient->iGc); - iBlankWin->BaseWin()->SetRequiredDisplayMode(EGray16); - } - -void CTFade::DestroyBlankWindow() - { - __ASSERT_ALWAYS(iBlankWin,AutoPanic(EAutoFadeWindow)); - delete iBlankWin; - iBlankWin=NULL; - } - -void CTFade::CreateBackupWindowL(TBool aMaintainBackup) - { - __ASSERT_ALWAYS(!iWin,AutoPanic(EAutoFadeWindow)); - CTBackedUpWin* backUpWin=new(ELeave) CTBackedUpWin(MODE_LT_64K(iDeviceDisplayMode)?iFadeDrawMode:iDeviceDisplayMode); - iWin=backUpWin; - iOwnWindow=ETrue; - iWindowRect.SetRect(TPoint(2*iTestWinSize.iWidth+35,7),iTestWinSize); - backUpWin->ConstructExtLD(*TheClient->iGroup,iWindowRect.iTl,iTestWinSize); - if (aMaintainBackup) - backUpWin->BackedUpWin()->MaintainBackup(); - backUpWin->Activate(); - TheClient->WaitForRedrawsToFinish(); //Without this bitmaps won't draw into the window - } - -void CTFade::CreateRedrawWindowL() - { - __ASSERT_ALWAYS(!iWin,AutoPanic(EAutoFadeWindow)); - iWindowRect.SetRect(TPoint(2*iTestWinSize.iWidth+35,7),iTestWinSize); - CRedrawWin* redrawWin=new(ELeave) CRedrawWin(this); - redrawWin->ConstructL(iWindowRect); - redrawWin->Win()->EnableRedrawStore(EFalse); - iWin=redrawWin; - iOwnWindow=ETrue; - iWin->BaseWin()->SetRequiredDisplayMode(iFadeDrawMode); - } - -void CTFade::DestroyDrawableWindow() - { - __ASSERT_ALWAYS(iWin,AutoPanic(EAutoFadeWindow)); - if (iOwnWindow) - delete iWin; - iWin=NULL; - } - -void CTFade::CreateBitmapsL() - { - iTestWinSize=BaseWin->Size(); - iBaseRect.SetRect(BaseWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),iTestWinSize); - iNormalBitmap.Create(iTestWinSize,MODE_LT_64K(iDeviceDisplayMode)?iFadeDrawMode:iDeviceDisplayMode); - iFadedBitmap.Create(iTestWinSize,MODE_LT_64K(iDeviceDisplayMode)?iFadeDrawMode:iDeviceDisplayMode); - iNormalBitmapDevice=CFbsBitmapDevice::NewL(&iNormalBitmap); - iFadedBitmapDevice=CFbsBitmapDevice::NewL(&iFadedBitmap); - User::LeaveIfError(iNormalBitmapDevice->CreateContext(iNormalBitGc)); - User::LeaveIfError(iFadedBitmapDevice->CreateContext(iFadedBitGc)); - iFadedBitGc->SetFadeMode(ETrue); - iBaseWinMode=BaseWin->BaseWin()->DisplayMode(); - BaseWin->BaseWin()->SetRequiredDisplayMode(iFadeDrawMode); - } - -void CTFade::DestroyBitmaps() - { - delete iNormalBitGc; - delete iFadedBitGc; - delete iNormalBitmapDevice; - delete iFadedBitmapDevice; - BaseWin->BaseWin()->SetRequiredDisplayMode(iBaseWinMode); - } - -void CTFade::Drawing(TInt aDrawFunc, CBitmapContext *gc) - { - TRgb grey=TRgb::Gray4(2); - TInt ii; - gc->Reset(); - switch (aDrawFunc) - { - case 1: - case 2: - Draw(0,&grey,gc); - gc->Reset(); - Draw(1,NULL,gc); - if (aDrawFunc==1) - break; - gc->Reset(); - Draw(3,NULL,gc); - break; - case 3: - Draw(0,&grey,gc); - gc->Reset(); - Draw(3,NULL,gc); - break; - case 4: - grey=TRgb::Gray4(1); - gc->Reset(); - Draw(0,&grey,gc); - gc->Reset(); - for (ii=1;ii<37;ii+=7) - Draw(2,&ii,gc); - break; - case 5: - Draw(0,&grey,gc); - gc->Reset(); - Draw(1,NULL,gc); - gc->Reset(); - for (ii=2;ii<60;ii+=11) - Draw(2,&ii,gc); - break; - case 6: - case 7: - Draw(0,&grey,gc); - gc->Reset(); - Draw(3,NULL,gc); - gc->Reset(); - for (ii=3;ii<70;ii+=13) - Draw(2,&ii,gc); - if (aDrawFunc==6) - break; - gc->Reset(); - Draw(1,NULL,gc); - break; - default:; - } - } - -void CTFade::Draw(TInt aDrawFunc, TAny *aParam, TBool aAlternativeFade/*=EFalse*/, TBool aFade/*=EFalse*/) - { - CWindowGc *gc=TheClient->iGc; - gc->Activate(*iWin->DrawableWin()); - gc->Reset(); - if (aFade) - gc->SetFaded(ETrue); - iNormalBitGc->Reset(); - iFadedBitGc->Reset(); - iFadedBitGc->SetFadeMode(ETrue); - if (aAlternativeFade) - iFadedBitGc->SetFadingParameters(BLACK_ALTERNATE,WHITE_ALTERNATE); - Draw(aDrawFunc,aParam,gc); - Draw(aDrawFunc,aParam,iNormalBitGc); - Draw(aDrawFunc,aParam,iFadedBitGc); - gc->Deactivate(); - if (aAlternativeFade) - iFadedBitGc->SetFadingParameters(BLACK_NORMAL,WHITE_NORMAL); - } - -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA // CWindowGc fading is deprecated in NGA -void CTFade::GCDraw(TInt aDrawFunc, TAny *aParam, TBool aAlternativeFade) - { - CWindowGc *gc=TheClient->iGc; - gc->Activate(*iWin->DrawableWin()); - gc->Reset(); - Draw(aDrawFunc,aParam,gc); - gc->Deactivate(); - gc->Activate(*BaseWin->DrawableWin()); - gc->Reset(); - gc->SetFaded(ETrue); - if (aAlternativeFade) - gc->SetFadingParameters(BLACK_ALTERNATE,WHITE_ALTERNATE); - Draw(aDrawFunc,aParam,gc); - gc->Deactivate(); - } -#endif // TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - -void CTFade::Draw(TInt aDrawFunc, TAny *aParam, CBitmapContext *aGc) - { - switch(aDrawFunc) - { - case 0: - aGc->SetBrushColor(*((TRgb *)aParam)); - aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - aGc->SetPenStyle(CGraphicsContext::ENullPen); - aGc->DrawRect(TRect(iTestWinSize)); - break; - case 1: - { - TSize half(iTestWinSize.iWidth/2,iTestWinSize.iHeight/2); - TRect rect(half); - aGc->DrawEllipse(rect); - aGc->DrawEllipse(TRect(TPoint(0,half.iHeight),half)); - aGc->SetOrigin(TPoint(half.iWidth,0)); - aGc->SetClippingRect(rect); - aGc->DrawEllipse(rect); - aGc->SetOrigin(TPoint(half.iWidth,half.iHeight)); - aGc->SetClippingRect(rect); - aGc->DrawEllipse(rect); - aGc->SetOrigin(TPoint()); - aGc->CancelClippingRect(); - } - break; - case 2: - { - TInt param= *((TInt *)aParam); - if (param&0x1) - aGc->DrawLine(TPoint(param+(param*27)%iTestWinSize.iWidth,0), - TPoint(iTestWinSize.iWidth-((param<<1)+(param*19)%iTestWinSize.iWidth),iTestWinSize.iHeight)); - else - aGc->DrawLine(TPoint(0, (param<<1)+(param*7)%iTestWinSize.iHeight), - TPoint(iTestWinSize.iWidth,param+(param*13)%iTestWinSize.iHeight)); - } - break; - case 3: - { - TPoint pos; - for(;pos.iXDrawLine(pos,pos+TSize(0,iTestWinSize.iHeight)); - for(pos.iX=0;pos.iYDrawLine(pos,pos+TSize(iTestWinSize.iWidth,0)); - } - break; - } - } - -void CTFade::CompareWithBitmap(TBool aFade) - { - TBool match; - CWindowGc& gc=*TheClient->iGc; - CFbsBitmap* bitmap; - TheClient->iWs.Flush(); - if (aFade) - bitmap=&iFadedBitmap; - else - bitmap=&iNormalBitmap; - gc.Activate(*BaseWin->DrawableWin()); - gc.Reset(); - gc.BitBlt(TPoint(),bitmap); - gc.Deactivate(); - TheClient->iWs.Flush(); -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - match=TheClient->iScreen->RectCompare(iBaseRect,iWindowRect); -#else // In NGA comparison has to be lossy because fading can be implemented on hardware - match=LossyCompareWindow(*TheClient->iScreen, *iTestWinCopy, *iCheckWinCopy, iWindowRect); -#endif - TEST(match); - if (!match) - { - _LIT(KLog,"Windows content don't match when they should"); - LOG_MESSAGE(KLog); - } - } - -void CTFade::CompareWindows(TBool aAlternativeFade/*=EFalse*/) - { - if (aAlternativeFade) - iWin->WinTreeNode()->SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly,BLACK_ALTERNATE,WHITE_ALTERNATE); - else - iWin->WinTreeNode()->SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly); - TheClient->iWs.Flush(); - TBool retVal = TheClient->iScreen->RectCompare(iBaseRect,iWindowRect); - TEST(retVal); - if (!retVal) - INFO_PRINTF3(_L("TheClient->iScreen->RectCompare(iBaseRect,iWindowRect) return value - Expected: %d, Actual: %d"), ETrue, retVal); - - iWin->WinTreeNode()->SetFaded(EFalse,RWindowTreeNode::EFadeWindowOnly); - TheClient->iWs.Flush(); - TheClient->WaitForRedrawsToFinish(); - } - -#define FADE(n,col) n/2+col/2 -TInt CTFade::Fade4(TInt aGray4) - { -#if defined(__WINS__) - return FADE(4,aGray4); -#elif defined (__MARM_THUMB__) - return (CanFade ? FADE(4,aGray4):aGray4); -#elif defined (__MARM__) - return FADE(4,aGray4); -#else - return aGray4; -#endif - } - -TInt CTFade::Fade16(TInt aGray16) - { -#if defined(__WINS__) - return FADE(16,aGray16); -#elif defined (__MARM_THUMB__) - return (CanFade ? FADE(16,aGray16):aGray16); -#elif defined (__MARM__) - return FADE(16,aGray16); -#else - return aGray16; -#endif - } - -TRgb CTFade::FadeRgb(TRgb aColor) - { - switch (iFadeDrawMode) - { - case EColor16M: - case EColor16MU: - case EColor16MA: - case EColor16MAP: - break; - default: - aColor=TRgb::Color64K(aColor.Color64K()); - break; - } -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA // Color fading calculation differs in NGA - TInt fadeMapFactor=WHITE_NORMAL-BLACK_NORMAL+1; -#else - TInt fadeMapFactor=WHITE_NORMAL-BLACK_NORMAL; -#endif - TInt fadeMapOffset=BLACK_NORMAL; - TInt value = aColor.Internal(); - - TInt b = (((value & 0x000000ff) * fadeMapFactor) >> 8) + fadeMapOffset; - TInt g = (((value & 0x0000ff00) * fadeMapFactor) >> 16) + fadeMapOffset; - TInt r = (((value & 0x00ff0000) * fadeMapFactor) >> 24) + fadeMapOffset; - return TRgb(r,g,b); - } - -TRgb CTFade::FadeRgb(TRgb aColor, TInt aFadeMapFactor, TInt aFadeMapOffset) - { - switch (iFadeDrawMode) - { - case EColor16M: - case EColor16MU: - case EColor16MA: - case EColor16MAP: - break; - default: - aColor=TRgb::Color64K(aColor.Color64K()); - break; - } - TInt value = aColor.Internal(); - - TInt b = (((value & 0x000000ff) * aFadeMapFactor) >> 8) + aFadeMapOffset; - TInt g = (((value & 0x0000ff00) * aFadeMapFactor) >> 16) + aFadeMapOffset; - TInt r = (((value & 0x00ff0000) * aFadeMapFactor) >> 24) + aFadeMapOffset; - return TRgb(r,g,b); - } - -inline void CTFade::ViewDelay() - // - //This routine can provide a delay which will allow the user to see the colors changing - // - { - TheClient->iWs.Finish(); - /*TheClient->iWs.Flush(); - User::After(1000000);*/ // 1 sec - } - -void CTFade::ColorTest() - { - __ASSERT_ALWAYS(iBlankWin,AutoPanic(EAutoFadeWindow)); - TBool retVal; - TSize size(iTestWinSize); -#if defined(SMALL_RECTS) - size.iWidth=Min(SIZE_X,size.iWidth); - size.iHeight=Min(SIZE_Y,size.iHeight); -#endif - TRect windowRect(iBlankWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),size); - TInt ii; - iBlankWin->BaseWin()->SetRequiredDisplayMode(EGray4); - TheClient->WaitForRedrawsToFinish(); //Force the screen into 4 gray mode - TRgb fadedColor; - for (ii=1;ii<4;ii+=2) //0 and 3 now give dithered colors when fading so causing this test to fail - { - iBlankWin->SetColor(TRgb::Gray4(ii)); - ViewDelay(); - INFO_PRINTF1(_L(" Testing Normal Color")); -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - retVal = CheckBlankWindow(windowRect,TRgb::Gray4(ii),TheClient->iScreen); -#else - TheClient->iScreen->CopyScreenToBitmap(iTestWinCopy, windowRect); - retVal = LossyCheckBlankWindow(*TheClient->iScreen, *iTestWinCopy, windowRect, TRgb::Gray4(ii)); -#endif - TEST(retVal); - if (!retVal) - INFO_PRINTF3(_L("CheckBlankWindow(windowRect,TRgb::Gray4(ii),TheClient->iScreen) return value - Expected: %d, Actual: %d"), ETrue, retVal); - iBlankWin->BaseWin()->SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly); - ViewDelay(); - fadedColor=MODE_LT_64K(iDeviceDisplayMode)?TRgb::Gray4(Fade4(ii)):FadeRgb(TRgb::Gray4(ii)); -#if defined (__MARM_THUMB__) - if (ii==1) - { - CanFade=!CheckBlankWindow(windowRect,fadedColor,TheClient->iScreen); - CanFadeSet=ETrue; - fadedColor=MODE_LT_64K(iDeviceDisplayMode)?TRgb::Gray4(Fade4(ii)):FadeRgb(TRgb::Gray4(ii)); - } -#endif -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - retVal = CheckBlankWindow(windowRect,fadedColor,TheClient->iScreen); -#else - retVal = LossyCheckBlankWindow(*TheClient->iScreen, *iTestWinCopy, windowRect, fadedColor); -#endif - TEST(retVal); - if (!retVal) - INFO_PRINTF3(_L("CheckBlankWindow(windowRect,fadedColor,TheClient->iScreen) return value - Expected: %d, Actual: %d"), ETrue, retVal); - - iBlankWin->BaseWin()->SetFaded(EFalse,RWindowTreeNode::EFadeWindowOnly); - ViewDelay(); - INFO_PRINTF1(_L(" Testing Unfaded Color")); -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - retVal = CheckBlankWindow(windowRect,TRgb::Gray4(ii),TheClient->iScreen); -#else - retVal = LossyCheckBlankWindow(*TheClient->iScreen, *iTestWinCopy, windowRect, TRgb::Gray4(ii)); -#endif - TEST(retVal); - if (!retVal) - INFO_PRINTF3(_L("CheckBlankWindow(windowRect,TRgb::Gray4(ii),TheClient->iScreen) return value - Expected: %d, Actual: %d"), ETrue, retVal); - } - iBlankWin->BaseWin()->SetRequiredDisplayMode(EGray16); - - if (MaxGrays()==0 && MaxColors()<256) - return; - - INFO_PRINTF1(_L(" Doing 16 Gray Colors")); - for (ii=0;ii<16;++ii) - { - iBlankWin->SetColor(TRgb::Gray16(ii)); - ViewDelay(); -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - retVal = CheckBlankWindow(windowRect,TRgb::Gray16(ii),TheClient->iScreen); -#else - retVal = LossyCheckBlankWindow(*TheClient->iScreen, *iTestWinCopy, windowRect, TRgb::Gray16(ii)); -#endif - TEST(retVal); - if (!retVal) - INFO_PRINTF3(_L("CheckBlankWindow(windowRect,TRgb::Gray16(ii),TheClient->iScreen) return value - Expected: %d, Actual: %d"), ETrue, retVal); - - iBlankWin->BaseWin()->SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly); - ViewDelay(); - fadedColor=MODE_LT_64K(iDeviceDisplayMode)?TRgb::Gray16(Fade16(ii)):FadeRgb(TRgb::Gray16(ii)); -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - retVal = CheckBlankWindow(windowRect,fadedColor,TheClient->iScreen); -#else - retVal = LossyCheckBlankWindow(*TheClient->iScreen, *iTestWinCopy, windowRect, fadedColor); -#endif - TEST(retVal); - if (!retVal) - INFO_PRINTF3(_L("CheckBlankWindow(windowRect,fadedColor,TheClient->iScreen) return value - Expected: %d, Actual: %d"), ETrue, retVal); - - iBlankWin->BaseWin()->SetFaded(EFalse,RWindowTreeNode::EFadeWindowOnly); - ViewDelay(); - -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - retVal = CheckBlankWindow(windowRect,TRgb::Gray16(ii),TheClient->iScreen); -#else - retVal = LossyCheckBlankWindow(*TheClient->iScreen, *iTestWinCopy, windowRect, TRgb::Gray16(ii)); -#endif - TEST(retVal); - if (!retVal) - INFO_PRINTF3(_L("CheckBlankWindow(windowRect,TRgb::Gray16(ii),TheClient->iScreen) return value - Expected: %d, Actual: %d"), ETrue, retVal); - } - } - -void CTFade::BlankWindowL() - { - TBool retVal; - if (MaxGrays()==0 && MaxColors()<256) - return; - - __ASSERT_ALWAYS(iBlankWin,AutoPanic(EAutoFadeWindow)); - CTBlankWindow* blankWin=new(ELeave) CTBlankWindow(); - TRect testArea(iWindowRect); - TRect windowRect(testArea); -#if defined(SMALL_RECTS) - TSize size(testArea.Size()); - size.iWidth=Min(2*SIZE_X,size.iWidth); - size.iHeight=Min(2*SIZE_Y,size.iHeight); - testArea.SetHeight(size.iHeight); - testArea.iTl.iX=testArea.iBr.iX-size.iWidth; - windowRect=testArea; - windowRect.Shrink(size.iWidth/4,size.iHeight/4); -#else - windowRect.Shrink(30,30); -#endif - blankWin->SetUpL(windowRect.iTl,windowRect.Size(),TheClient->iGroup,*TheClient->iGc); - for (TInt col=2;col<16;col+=6) - { - iBlankWin->SetColor(TRgb::Gray16(col)); - TheClient->iScreen->CopyScreenToBitmap(iTestWinCopy, windowRect); - iBlankWin->BaseWin()->SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly); - blankWin->SetVisible(EFalse); - TheClient->iWs.Finish(); - TRgb fadedColor=MODE_LT_64K(iDeviceDisplayMode)?TRgb::Gray16(Fade16(col)):FadeRgb(TRgb::Gray16(col)); -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - retVal = CheckBlankWindow(testArea,fadedColor,TheClient->iScreen); -#else - retVal = LossyCheckBlankWindow(*TheClient->iScreen, *iTestWinCopy, windowRect, fadedColor); -#endif - TEST(retVal); - if (!retVal) - INFO_PRINTF3(_L("LossyCheckBlankWindow(*TheClient->iScreen, *iTestWinCopy, windowRect, fadedColor) return value - Expected: %d, Actual: %d"), ETrue, retVal); - - blankWin->SetVisible(ETrue); - iBlankWin->BaseWin()->SetFaded(EFalse,RWindowTreeNode::EFadeWindowOnly); - blankWin->SetVisible(EFalse); - TheClient->iWs.Finish(); - retVal = CheckBlankWindow(testArea,TRgb::Gray16(col),TheClient->iScreen); - TEST(retVal); - if (!retVal) - INFO_PRINTF3(_L("CheckBlankWindow(testArea,TRgb::Gray16(col),TheClient->iScreen) return value - Expected: %d, Actual: %d"), ETrue, retVal); - - blankWin->SetVisible(ETrue); - iBlankWin->SetPos(iWindowRect.iTl+TPoint(15,-15)); - iBlankWin->BaseWin()->SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly); - blankWin->SetVisible(EFalse); - iBlankWin->SetPos(iWindowRect.iTl); - fadedColor=MODE_LT_64K(iDeviceDisplayMode)?TRgb::Gray16(Fade16(col)):FadeRgb(TRgb::Gray16(col)); - TheClient->iWs.Finish(); -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - retVal = CheckBlankWindow(testArea,fadedColor,TheClient->iScreen); -#else - retVal = LossyCheckBlankWindow(*TheClient->iScreen, *iTestWinCopy, windowRect, fadedColor); -#endif - TEST(retVal); - if (!retVal) - INFO_PRINTF3(_L("LossyCheckBlankWindow(*TheClient->iScreen, *iTestWinCopy, windowRect, fadedColor) return value - Expected: %d, Actual: %d"), ETrue, retVal); - - blankWin->SetVisible(ETrue); - iBlankWin->SetPos(iWindowRect.iTl+TPoint(15,-15)); - iBlankWin->BaseWin()->SetFaded(EFalse,RWindowTreeNode::EFadeWindowOnly); - blankWin->SetVisible(EFalse); - iBlankWin->SetPos(iWindowRect.iTl); - TheClient->iWs.Finish(); - retVal = CheckBlankWindow(testArea,TRgb::Gray16(col),TheClient->iScreen); - TEST(retVal); - if (!retVal) - INFO_PRINTF3(_L("CheckBlankWindow(testArea,TRgb::Gray16(col),TheClient->iScreen) return value - Expected: %d, Actual: %d"), ETrue, retVal); - - blankWin->SetVisible(ETrue); - } - delete blankWin; - } - -void CTFade::TestStrips(TRect aRect,TInt aHeight,TInt aNumNotFaded,TBool aInvert/*=EFalse*/) - { - TBool isFaded; - TInt ii; - TRgb col; - for (ii=0;ii<16;++ii) - { - isFaded=((!aInvert)==(!(iiiScreen); -#else - TBool retVal = LossyCheckBlankWindow(*TheClient->iScreen, *iTestWinCopy, aRect, col); -#endif - TEST(retVal); - if (!retVal) - INFO_PRINTF3(_L("CheckBlankWindow(aRect,col,TheClient->iScreen) return value - Expected: %d, Actual: %d"), ETrue, retVal); - - aRect.Move(0,aHeight); - } - } - -void CTFade::FadeChildrenL() - { - if (MaxGrays()==0 && MaxColors()<256) - return; - - TInt retVal; - TBool retBool; - - __ASSERT_ALWAYS(iBlankWin,AutoPanic(EAutoFadeWindow)); - iBlankWin->BaseWin()->SetRequiredDisplayMode(EGray16); - iBlankWin->SetColor(TRgb::Gray16(0)); - CTBlankWindow* win[16]; - win[0]=iBlankWin; - TRect rect(iTestWinSize); - TInt height=iTestWinSize.iHeight/16; - rect.iTl.iY=height; - TInt ii; - for (ii=1;ii<16;++ii) //Causes memory leakage under OOM - { - win[ii]=new(ELeave) CTBlankWindow(); - win[ii]->SetUpL(rect.iTl,rect.Size(),win[ii-1],*TheClient->iGc); - win[ii]->BaseWin()->SetRequiredDisplayMode(EGray16); - win[ii]->SetColor(TRgb::Gray16(ii)); - rect.iBr.iY-=height; - } - rect=iWindowRect; - rect.SetHeight(height); -#if defined(SMALL_RECTS) - TSize size(rect.Size()); - size.iWidth=Min(SIZE_X,size.iWidth); - size.iHeight=Min(SIZE_Y,size.iHeight); - rect.SetSize(size); -#endif - for (ii=0;ii<15;++ii) - { - win[ii]->WinTreeNode()->SetFaded(ETrue,RWindowTreeNode::EFadeIncludeChildren); - retVal = win[ii]->BaseWin()->IsFaded(); - TEST(retVal==1); - if (retVal!=1) - INFO_PRINTF3(_L("win[ii]->BaseWin()->IsFaded() return value - Expected: %d, Actual: %d"), 1, retVal); - - TestStrips(rect,height,ii); - win[ii]->WinTreeNode()->SetFaded(EFalse,RWindowTreeNode::EFadeIncludeChildren); - retBool = !win[ii]->BaseWin()->IsFaded(); - TEST(retBool); - if (!retBool) - INFO_PRINTF3(_L("!win[ii]->BaseWin()->IsFaded() return value - Expected: %d, Actual: %d"), ETrue, retBool); - - TestStrips(rect,height,16); - } - TheClient->iGroup->WinTreeNode()->SetFaded(ETrue,RWindowTreeNode::EFadeIncludeChildren); - TestStrips(rect,height,0); - TheClient->iGroup->WinTreeNode()->SetFaded(EFalse,RWindowTreeNode::EFadeIncludeChildren); - TestStrips(rect,height,16); - for (ii=0;ii<16;++ii) - { - win[ii]->BaseWin()->FadeBehind(ETrue); - retBool = !win[ii]->BaseWin()->IsFaded(); - TEST(retBool); - if (!retBool) - INFO_PRINTF3(_L("!win[ii]->BaseWin()->IsFaded() return value - Expected: %d, Actual: %d"), ETrue, retBool); - - retVal = win[0]->BaseWin()->IsFaded(); - TEST(retVal==(ii>0)); - if (retVal!=(ii>0)) - INFO_PRINTF3(_L("win[0]->BaseWin()->IsFaded() return value - Expected: %d, Actual: %d"), (ii>0), retVal); - - TestStrips(rect,height,ii,ETrue); - win[ii]->BaseWin()->FadeBehind(EFalse); - TestStrips(rect,height,16); - } - iBlankWin->WinTreeNode()->SetFaded(ETrue,RWindowTreeNode::EFadeIncludeChildren); - TestStrips(rect,height,0); - iBlankWin->WinTreeNode()->SetNonFading(ETrue); - TestStrips(rect,height,16); - win[8]->WinTreeNode()->SetNonFading(EFalse); - TestStrips(rect,height,8); - iBlankWin->WinTreeNode()->SetNonFading(EFalse); - TestStrips(rect,height,0); - iBlankWin->WinTreeNode()->SetFaded(EFalse,RWindowTreeNode::EFadeIncludeChildren); - TestStrips(rect,height,16); - win[8]->WinTreeNode()->SetNonFading(ETrue); - TestStrips(rect,height,16); - iBlankWin->WinTreeNode()->SetFaded(ETrue,RWindowTreeNode::EFadeIncludeChildren); - TestStrips(rect,height,8,ETrue); - win[8]->WinTreeNode()->SetNonFading(EFalse); - TestStrips(rect,height,0); - iBlankWin->WinTreeNode()->SetFaded(EFalse,RWindowTreeNode::EFadeIncludeChildren); - TestStrips(rect,height,16); - for (ii=15;ii>0;--ii) - delete win[ii]; - } - -static void ResetAndDestroyWindows(TAny* aPtr) - { - RPointerArray& win = *(static_cast*>(aPtr)); - win.Remove(0); - win.ResetAndDestroy(); - win.Close(); - } - -void CTFade::FadeChildrenAfterNewChildIsCreatedL() - { - if (MaxGrays()==0 && MaxColors()<256) - return; - - TBool retBool; - TInt retVal; - - __ASSERT_ALWAYS(iBlankWin,AutoPanic(EAutoFadeWindow)); - iBlankWin->BaseWin()->SetRequiredDisplayMode(iFadeDrawMode); - iBlankWin->SetColor(TRgb::Gray16(0)); - RPointerArray win; - CleanupStack::PushL(TCleanupItem(ResetAndDestroyWindows, &win)); - TInt height=iTestWinSize.iHeight/NUMBER_OF_WINDOWS; - CTBlankWindow* window=NULL; - TInt ii; - for (TInt firstLoop=0;firstLoopiGroup->WinTreeNode()->SetFaded(ETrue,RWindowTreeNode::EFadeIncludeChildren); - TRect rect(iTestWinSize); - rect.iTl.iY=height; - CTBlankWindow* parent=iBlankWin; - for (TInt secondLoop=0;secondLoop<=firstLoop;) - { - window=new(ELeave) CTBlankWindow(); - CleanupStack::PushL(window); - User::LeaveIfError(win.Append(window)); - CleanupStack::Pop(window); - window->SetUpL(rect.iTl,rect.Size(),parent,*TheClient->iGc); - window->BaseWin()->SetRequiredDisplayMode(iFadeDrawMode); - window->SetColor(TRgb::Gray16(++secondLoop)); - rect.iBr.iY-=height; - parent=window; - retBool = window->BaseWin()->IsFaded(); - TEST(retBool); - if (!retBool) - INFO_PRINTF3(_L("window->BaseWin()->IsFaded() return value - Expected: %d, Actual: %d"), ETrue, retBool); - - } - ++firstLoop; - TheClient->iGroup->WinTreeNode()->SetFaded(EFalse,RWindowTreeNode::EFadeIncludeChildren); - const TInt count=win.Count(); - for(TInt index=0;indexBaseWin()->IsFaded(); - TEST(!retBool); - if (retBool) - INFO_PRINTF3(_L("win[index]->BaseWin()->IsFaded return value - Expected: %d, Actual: %d"), EFalse, retBool); - - } - } - User::LeaveIfError(win.Insert(iBlankWin,0)); - TRect testRect=iWindowRect; - testRect.SetHeight(height); -#if defined(SMALL_RECTS) - TSize size(testRect.Size()); - size.iWidth=Min(SIZE_X,size.iWidth); - size.iHeight=Min(SIZE_Y,size.iHeight); - testRect.SetSize(size); -#endif - for (ii=0;iiWinTreeNode()->SetFaded(ETrue,RWindowTreeNode::EFadeIncludeChildren); - retVal = win[ii]->BaseWin()->IsFaded(); - TEST(retVal==1); - if (retVal!=1) - INFO_PRINTF3(_L("win[index]->BaseWin()->IsFaded return value - Expected: %d, Actual: %d"), 1, retVal); - - TestStrips(testRect,height,ii); - win[ii]->WinTreeNode()->SetFaded(EFalse,RWindowTreeNode::EFadeIncludeChildren); - retBool = !win[ii]->BaseWin()->IsFaded(); - TEST(retBool); - if (!retBool) - INFO_PRINTF3(_L("!win[ii]->BaseWin()->IsFaded() return value - Expected: %d, Actual: %d"), EFalse, retBool); - - TestStrips(testRect,height,NUMBER_OF_WINDOWS); - } - TheClient->iGroup->WinTreeNode()->SetFaded(ETrue,RWindowTreeNode::EFadeIncludeChildren); - TestStrips(testRect,height,0); - TheClient->iGroup->WinTreeNode()->SetFaded(EFalse,RWindowTreeNode::EFadeIncludeChildren); - TestStrips(testRect,height,16); - for (ii=0;iiBaseWin()->FadeBehind(ETrue); - retBool = !win[ii]->BaseWin()->IsFaded(); - TEST(retBool); - if (!retBool) - INFO_PRINTF3(_L("!win[ii]->BaseWin()->IsFaded() return value - Expected: %d, Actual: %d"), EFalse, retBool); - - retVal = win[0]->BaseWin()->IsFaded(); - TEST(retVal==(ii>0)); - if (retVal!=(ii>0)) - INFO_PRINTF3(_L("win[index]->BaseWin()->IsFaded return value - Expected: %d, Actual: %d"), (ii>0), retVal); - - TestStrips(testRect,height,ii,ETrue); - win[ii]->BaseWin()->FadeBehind(EFalse); - TestStrips(testRect,height,NUMBER_OF_WINDOWS); - } - iBlankWin->WinTreeNode()->SetFaded(ETrue,RWindowTreeNode::EFadeIncludeChildren); - TestStrips(testRect,height,0); - iBlankWin->WinTreeNode()->SetNonFading(ETrue); - TestStrips(testRect,height,NUMBER_OF_WINDOWS); - win[8]->WinTreeNode()->SetNonFading(EFalse); - TestStrips(testRect,height,NUMBER_OF_WINDOWS/2); - iBlankWin->WinTreeNode()->SetNonFading(EFalse); - TestStrips(testRect,height,0); - iBlankWin->WinTreeNode()->SetFaded(EFalse,RWindowTreeNode::EFadeIncludeChildren); - TestStrips(testRect,height,NUMBER_OF_WINDOWS); - win[8]->WinTreeNode()->SetNonFading(ETrue); - TestStrips(testRect,height,NUMBER_OF_WINDOWS); - iBlankWin->WinTreeNode()->SetFaded(ETrue,RWindowTreeNode::EFadeIncludeChildren); - TestStrips(testRect,height,NUMBER_OF_WINDOWS/2,ETrue); - win[8]->WinTreeNode()->SetNonFading(EFalse); - TestStrips(testRect,height,0); - iBlankWin->WinTreeNode()->SetFaded(EFalse,RWindowTreeNode::EFadeIncludeChildren); - TestStrips(testRect,height,NUMBER_OF_WINDOWS); - - CleanupStack::PopAndDestroy(&win); - } - -void CTFade::TestBlocks(TRect aRect,TSize aSize,TInt aNumNotFaded,TBool aInvert/*=EFalse*/) - { - TInt count=0; - TInt ii,jj; - TRgb col; - for (ii=0;ii<4;++ii) - { - for (jj=0;jj<4;++jj) - { - if ((!aInvert)!=(!(countiScreen); -#else - TBool retBool = LossyCheckBlankWindow(*TheClient->iScreen, *iTestWinCopy, aRect, col); -#endif - TEST(retBool); - if (!retBool) - INFO_PRINTF3(_L("CheckBlankWindow(aRect,col,TheClient->iScreen) return value - Expected: %d, Actual: %d"), EFalse, retBool); - - aRect.Move(0,aSize.iHeight); - count++; - } - aRect.Move(aSize.iWidth,-jj*aSize.iHeight); - } - } - -void CTFade::FadeBehindL() - { - if (MaxGrays()==0 && MaxColors()<256) - return; - - TBool retBool; - TInt retVal; - - __ASSERT_ALWAYS(iBlankWin,AutoPanic(EAutoFadeWindow)); - iBlankWin->BaseWin()->SetRequiredDisplayMode(EGray16); - iBlankWin->SetColor(TRgb::Gray16(0)); - CTBlankWindow* win[4][4]; - win[0][0]=iBlankWin; - TSize size=iTestWinSize; - TInt height=iTestWinSize.iHeight/4; - TInt width=iTestWinSize.iWidth/4; - TRect rect(iWindowRect.iTl,TSize(width,height)); - TSize rectSize(rect.Size()); - TPoint offset(0,height); - TPoint topLeft; - TInt ii,jj; - CTWinBase* parent; -#if defined(SMALL_RECTS) - TSize rSize(rectSize); - rSize.iWidth=Min(SIZE_X,rSize.iWidth); - rSize.iHeight=Min(SIZE_Y,rSize.iHeight); - rect.SetSize(rSize); -#endif - for (ii=0;ii<4;++ii) //Causes memory leakage under OOM - { - parent=TheClient->iGroup; - topLeft=iWindowRect.iTl+TPoint(ii*width,0); - size.iHeight=iTestWinSize.iHeight; - for (jj=0;jj<4;++jj) - { - if (ii+jj>0) - { - win[ii][jj]=new(ELeave) CTBlankWindow(); - win[ii][jj]->SetUpL(topLeft,size,parent,*TheClient->iGc); - win[ii][jj]->BaseWin()->SetRequiredDisplayMode(EGray16); - win[ii][jj]->SetColor(TRgb::Gray16(4*ii+jj)); - } - size.iHeight-=height; - topLeft=offset; - parent=win[ii][jj]; - } - size.iWidth-=width; - } - for (ii=0;ii<4;++ii) - { - for (jj=0;jj<4;++jj) - { - win[ii][jj]->BaseWin()->FadeBehind(ETrue); - retVal = win[0][0]->BaseWin()->IsFaded(); - TEST(retVal==(ii>0||jj>0)); - if (retVal!=(ii>0||jj>0)) - INFO_PRINTF3(_L("win[0][0]->BaseWin()->IsFaded() return value - Expected: %d, Actual: %d"), (ii>0||jj>0), retVal); - - retBool = !win[ii][jj]->BaseWin()->IsFaded(); - TEST(retBool); - if (!retBool) - INFO_PRINTF3(_L("!win[ii][jj]->BaseWin()->IsFaded() return value - Expected: %d, Actual: %d"), ETrue, retBool); - - TestBlocks(rect,rectSize,4*ii+jj,ETrue); - win[ii][jj]->BaseWin()->FadeBehind(EFalse); - TestBlocks(rect,rectSize,16); - } - } - for (ii=0;ii<4;++ii) - { - for (jj=0;jj<4;++jj) - { - win[ii][jj]->BaseWin()->FadeBehind(ETrue); - TestBlocks(rect,rectSize,4*ii+jj,ETrue); - } - retVal = win[ii][0]->BaseWin()->IsFaded(); - TEST(retVal==3); - if (retVal!=3) - INFO_PRINTF3(_L("win[ii][0]->BaseWin()->IsFaded() return value - Expected: %d, Actual: %d"), 3, retVal); - } - for (ii=3;ii>=0;--ii) - { - retVal = win[ii][0]->BaseWin()->IsFaded(); - TEST(retVal==3); - if (retVal!=3) - INFO_PRINTF3(_L("win[ii][0]->BaseWin()->IsFaded() return value - Expected: %d, Actual: %d"), 3, retVal); - - for (jj=3;jj>=0;--jj) - { - TestBlocks(rect,rectSize,4*ii+jj,ETrue); - win[ii][jj]->BaseWin()->FadeBehind(EFalse); - } - } - TestBlocks(rect,rectSize,0,ETrue); - for (ii=0;ii<4;++ii) - { - for (jj=0;jj<4;++jj) - { - win[ii][jj]->BaseWin()->FadeBehind(ETrue); - } - } - TInt fadeCount; - for (ii=0;ii<4;++ii) - { - for (jj=0;jj<4;++jj) - { - fadeCount=15-(4*ii+jj); - retVal = win[0][0]->BaseWin()->IsFaded(); - TEST(retVal==Min(15,fadeCount+1)); - if (retVal!=Min(15,fadeCount+1)) - INFO_PRINTF3(_L("win[0][0]->BaseWin()->IsFaded() return value - Expected: %d, Actual: %d"), Min(15,fadeCount+1), retVal); - - retVal = win[ii][jj]->BaseWin()->IsFaded(); - TEST(retVal==Max(0,fadeCount)); - if (retVal!=Max(0,fadeCount)) - INFO_PRINTF3(_L("win[ii][jj]->BaseWin()->IsFaded() return value - Expected: %d, Actual: %d"), Max(0,fadeCount), retVal); - - TestBlocks(rect,rectSize,15,ETrue); - win[ii][jj]->BaseWin()->FadeBehind(EFalse); - retVal = win[ii][jj]->BaseWin()->IsFaded(); - TEST(retVal==Max(0,fadeCount)); - if (retVal!=Max(0,fadeCount)) - INFO_PRINTF3(_L("win[ii][jj]->BaseWin()->IsFaded() return value - Expected: %d, Actual: %d"), Max(0,fadeCount), retVal); - - } - } - TestBlocks(rect,rectSize,0,ETrue); - if (Fade16(15)==15) - { - win[3][3]->BaseWin()->FadeBehind(ETrue); //All faded as the only unfaded one is white - for (ii=3;ii>=0;--ii) - { - retVal = win[ii][0]->BaseWin()->IsFaded(); - TEST(retVal==1); - if (retVal!=1) - INFO_PRINTF3(_L("win[ii][0]->BaseWin()->IsFaded() return value - Expected: %d, Actual: %d"), 1, retVal); - - retBool = !win[ii][1]->BaseWin()->IsNonFading(); - TEST(retBool); - if (!retBool) - INFO_PRINTF3(_L("!win[ii][1]->BaseWin()->IsNonFading() return value - Expected: %d, Actual: %d"), ETrue, retBool); - - win[ii][0]->WinTreeNode()->SetNonFading(ETrue); - retBool = win[ii][1]->BaseWin()->IsNonFading(); - TEST(retBool); - if (!retBool) - INFO_PRINTF3(_L("win[ii][1]->BaseWin()->IsNonFading() return value - Expected: %d, Actual: %d"), ETrue, retBool); - - TestBlocks(rect,rectSize,4*ii,ETrue); - } - for (ii=3;ii>=0;--ii) - { - retVal = win[ii][0]->BaseWin()->IsFaded(); - TEST(retVal==1); - if (retVal!=1) - INFO_PRINTF3(_L("win[ii][0]->BaseWin()->IsFaded() return value - Expected: %d, Actual: %d"), 1, retVal); - - retBool = win[ii][1]->BaseWin()->IsNonFading(); - TEST(retBool); - if (!retBool) - INFO_PRINTF3(_L("win[ii][1]->BaseWin()->IsNonFading() return value - Expected: %d, Actual: %d"), ETrue, retBool); - - win[ii][0]->WinTreeNode()->SetNonFading(EFalse); - retBool = !win[ii][1]->BaseWin()->IsNonFading(); - TEST(retBool); - if (!retBool) - INFO_PRINTF3(_L("win[ii][1]->BaseWin()->IsNonFading() return value - Expected: %d, Actual: %d"), ETrue, retBool); - - TestBlocks(rect,rectSize,4*ii); - } - win[3][3]->BaseWin()->FadeBehind(EFalse); - } - for (ii=3;ii>=0;--ii) - { - for (jj=3;jj>=0;--jj) - { - if (ii+jj>0) - delete win[ii][jj]; - } - } - } - -void CTFade::ColorTest2() - { -#if defined(__MARM__) - return; -#else - __ASSERT_ALWAYS(iBlankWin,AutoPanic(EAutoFadeWindow)); - TSize size=iTestWinSize; -#if defined(SMALL_RECTS) - size.iWidth=Min(SIZE_X,size.iWidth); - size.iHeight=Min(SIZE_Y,size.iHeight); -#endif - if (MaxGrays()==0 && MaxColors()<256) - return; - TRect windowRect(iBlankWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),size); - TUint8 bm; - TUint8 wm; - TInt test=0; - TInt ii; - FOREVER - { - TInt fadeMapFactor = 0; - TInt fadeMapOffset = 0; - - switch (test) - { - case 0: //Nothing - bm=0; - wm=15; - break; - case 1: //Shadowing or Quartz fading - bm=0; - wm=7; -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - TheClient->iWs.SetDefaultFadingParameters(0,127); - fadeMapFactor = 128; -#else - TheClient->iWs.SetDefaultFadingParameters(STATIC_CAST(TUint8,bm*17),127); - fadeMapFactor = 127-STATIC_CAST(TUint8,bm*17); -#endif - break; - default: - TheClient->iWs.SetDefaultFadingParameters(BLACK_NORMAL,WHITE_NORMAL); - return; - } - if (wm!=7) - { - fadeMapOffset = STATIC_CAST(TUint8,bm*17); - fadeMapFactor = STATIC_CAST(TUint8,wm*17) - fadeMapOffset; - TheClient->iWs.SetDefaultFadingParameters(STATIC_CAST(TUint8,bm*17),STATIC_CAST(TUint8,wm*17)); - } - - for (ii=0;ii<16;ii+=5) - { - iBlankWin->SetColor(TRgb::Gray16(ii)); - ViewDelay(); -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - TBool retBool=CheckBlankWindow(windowRect,TRgb::Gray16(ii),TheClient->iScreen); -#else - TBool retBool = LossyCheckBlankWindow(*TheClient->iScreen, *iTestWinCopy, windowRect, TRgb::Gray16(ii)); -#endif - TEST(retBool); - if (!retBool) - { - _LIT(KLog,"Setting color on blank window failed mappings=%d color=%d"); - LOG_MESSAGE3(KLog,test,ii); - } - iBlankWin->BaseWin()->SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly); - ViewDelay(); - - TRgb col1 = FadeRgb(TRgb::Gray16(ii), fadeMapFactor, fadeMapOffset); -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - retBool=CheckBlankWindow(windowRect,col1,TheClient->iScreen); -#else - retBool = LossyCheckBlankWindow(*TheClient->iScreen, *iTestWinCopy, windowRect, col1); -#endif - TEST(retBool); - if (!retBool) - { - _LIT(KLog,"Fading the window gave wrong color mappings=%d color=%d"); - LOG_MESSAGE3(KLog,test,ii); - } - iBlankWin->BaseWin()->SetFaded(EFalse,RWindowTreeNode::EFadeWindowOnly); - ViewDelay(); -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - retBool=CheckBlankWindow(windowRect,TRgb::Gray16(ii),TheClient->iScreen); -#else - retBool = LossyCheckBlankWindow(*TheClient->iScreen, *iTestWinCopy, windowRect, TRgb::Gray16(ii)); -#endif - TEST(retBool); - if (!retBool) - { - _LIT(KLog,"Unfading the window gave wrong color mappings=%d color=%d"); - LOG_MESSAGE3(KLog,test,ii); - } - } - ++test; - } -#endif //__MARM__ - } - -void CTFade::FadeTest() - { -#if defined(__MARM__) - return; -#else - __ASSERT_ALWAYS(iBlankWin,AutoPanic(EAutoFadeWindow)); - TSize size=iTestWinSize; -#if defined(SMALL_RECTS) - size.iWidth=Min(SIZE_X,size.iWidth); - size.iHeight=Min(SIZE_Y,size.iHeight); -#endif - if (MaxGrays()==0 && MaxColors()<256) - return; - TRect windowRect(iBlankWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),size); - TUint8 bm; - TUint8 wm; - TUint8 fb; - TUint8 fw; - TInt test=0; - TInt ii; - FOREVER - { - TInt fadeMapFactor = 0; - TInt fadeMapOffset = 0; - fw=0; - switch (test) - { - case 0: //Nothing - bm=0; - wm=15; - break; - case 1: //Shadowing or Quartz fading - - bm=0; - wm=7; - fw=127; - break; - default: - return; - } - fb=STATIC_CAST(TUint8,17*bm); - if (!fw) - fw=STATIC_CAST(TUint8,17*wm); - fadeMapFactor = fw - fb; - fadeMapOffset = fb; - for (ii=0;ii<16;ii+=5) - { - iBlankWin->SetColor(TRgb::Gray16(ii)); - ViewDelay(); -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - TBool retBool = CheckBlankWindow(windowRect,TRgb::Gray16(ii),TheClient->iScreen); -#else - TBool retBool = LossyCheckBlankWindow(*TheClient->iScreen, *iTestWinCopy, windowRect, TRgb::Gray16(ii)); -#endif - TEST(retBool); - if (!retBool) - INFO_PRINTF3(_L("CheckBlankWindow(windowRect,TRgb::Gray16(ii),TheClient->iScreen) return value - Expected: %d, Actual: %d"), ETrue, retBool); - - TRgb col3 = TRgb::Gray16(ii).Internal(); - TRgb col1 = FadeRgb(col3, fadeMapFactor, fadeMapOffset); - iBlankWin->BaseWin()->SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly,fb,fw); - ViewDelay(); -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - retBool = CheckBlankWindow(windowRect,col1,TheClient->iScreen); -#else - retBool = LossyCheckBlankWindow(*TheClient->iScreen, *iTestWinCopy, windowRect, col1); -#endif - TEST(retBool); - if (!retBool) - INFO_PRINTF3(_L("CheckBlankWindow(windowRect,TRgb::Gray16((ii*wb+add)/15),TheClient->iScreen) return value - Expected: %d, Actual: %d"), ETrue, retBool); - - iBlankWin->BaseWin()->SetFaded(EFalse,RWindowTreeNode::EFadeWindowOnly); - ViewDelay(); -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - retBool = CheckBlankWindow(windowRect,TRgb::Gray16(ii),TheClient->iScreen); -#else - retBool = LossyCheckBlankWindow(*TheClient->iScreen, *iTestWinCopy, windowRect, TRgb::Gray16(ii)); -#endif - TEST(retBool); - if (!retBool) - INFO_PRINTF3(_L("CheckBlankWindow(windowRect,TRgb::Gray16(ii),TheClient->iScreen) return value - Expected: %d, Actual: %d"), ETrue, retBool); - - } - ++test; - } -#endif //__MARM__ - } - -void CTFade::Draw(TBool aAlternativeFade/*=EFalse*/) - { - __ASSERT_ALWAYS(iWin,AutoPanic(EAutoFadeWindow)); - TRgb grey=TRgb::Gray4(2); - Draw(0,&grey,aAlternativeFade); - Draw(1,NULL,aAlternativeFade); - iContent=1; - CompareWithBitmap(EFalse); - if (aAlternativeFade) - iWin->WinTreeNode()->SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly,BLACK_ALTERNATE,WHITE_ALTERNATE); - else - iWin->WinTreeNode()->SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly); - CompareWithBitmap(ETrue); - Draw(3,NULL,aAlternativeFade); - iContent=2; - CompareWithBitmap(ETrue); - iWin->WinTreeNode()->SetFaded(EFalse,RWindowTreeNode::EFadeWindowOnly); - CompareWithBitmap(EFalse); - } - -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA -void CTFade::GCDraw() - { - __ASSERT_ALWAYS(iWin,AutoPanic(EAutoFadeWindow)); - TRgb grey=TRgb::Gray4(2); - TInt ii; - GCDraw(0,&grey); - GCDraw(3,NULL); - for (ii=3;ii<70;ii+=13) - GCDraw(2,&ii); - iContent=6; - CompareWindows(); - GCDraw(0,&grey,ETrue); - GCDraw(3,NULL,ETrue); - for (ii=3;ii<70;ii+=13) - GCDraw(2,&ii,ETrue); - GCDraw(1,NULL,ETrue); - iContent=7; - CompareWindows(ETrue); - } -#endif // TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - -void CTFade::ObscuredL() - { - CTBlankWindow* blankWin=new(ELeave) CTBlankWindow(); - TRect windowRect(iWindowRect); - windowRect.Shrink(30,30); - blankWin->SetUpL(windowRect.iTl,windowRect.Size(),TheClient->iGroup,*TheClient->iGc); - - __ASSERT_ALWAYS(iWin,AutoPanic(EAutoFadeWindow)); - TRgb grey=TRgb::Gray4(2); - Draw(0,&grey); - Draw(3,NULL); - iContent=3; - iWin->WinTreeNode()->SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly); - blankWin->SetVisible(EFalse); - CompareWithBitmap(ETrue); - blankWin->SetVisible(ETrue); - grey=TRgb::Gray4(1); - Draw(0,&grey); - for (TInt ii=1;ii<37;ii+=7) - Draw(2,&ii); - iContent=4; - blankWin->SetVisible(EFalse); - CompareWithBitmap(ETrue); - blankWin->SetVisible(ETrue); - iWin->WinTreeNode()->SetFaded(EFalse,RWindowTreeNode::EFadeWindowOnly); - blankWin->SetVisible(EFalse); - CompareWithBitmap(EFalse); - - delete blankWin; - } - -void CTFade::MovingL() - { - CTBlankWindow* blankWin=new(ELeave) CTBlankWindow(); - TRect windowRect(iWindowRect); - windowRect.Shrink(40,40); - blankWin->SetUpL(windowRect.iTl,windowRect.Size(),TheClient->iGroup,*TheClient->iGc); - - __ASSERT_ALWAYS(iWin,AutoPanic(EAutoFadeWindow)); - TRgb grey=TRgb::Gray4(2); - Draw(0,&grey); - Draw(1,NULL); - for (TInt ii=2;ii<60;ii+=11) - Draw(2,&ii); - iContent=5; - blankWin->SetPos(windowRect.iTl+TPoint(25,-25)); - iWin->WinTreeNode()->SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly); - blankWin->SetPos(windowRect.iTl+TPoint(10,25)); - blankWin->SetVisible(EFalse); - CompareWithBitmap(ETrue); - blankWin->SetVisible(ETrue); - blankWin->SetPos(windowRect.iTl+TPoint(25,-25)); - iWin->WinTreeNode()->SetFaded(EFalse,RWindowTreeNode::EFadeWindowOnly); - blankWin->SetPos(windowRect.iTl+TPoint(-5,10)); - blankWin->SetVisible(EFalse); - CompareWithBitmap(EFalse); - - delete blankWin; - } - -void CTFade::SystemFadeL() - { - if (MaxGrays()==0 && MaxColors()<256) - return; - - CTBlankWindow* win[16]; - TInt height=iTestWinSize.iHeight/16; - TRect rect(iWindowRect); - rect.SetHeight(height); - TInt ii; - for (ii=0;ii<16;++ii) //Causes memory leakage under OOM - { - win[ii]=new(ELeave) CTBlankWindow(); - win[ii]->SetUpL(rect.iTl,rect.Size(),TheClient->iGroup,*TheClient->iGc); - win[ii]->BaseWin()->SetRequiredDisplayMode(EGray16); - win[ii]->SetColor(TRgb::Gray16(ii)); - rect.Move(0,height); - } - rect=iWindowRect; - rect.SetHeight(height); -#if defined(SMALL_RECTS) - TSize size(rect.Size()); - size.iWidth=Min(SIZE_X,size.iWidth); - size.iHeight=Min(SIZE_Y,size.iHeight); - rect.SetSize(size); -#endif - - TBool retBool; - - // system fade on - TheClient->iWs.SetSystemFaded(ETrue); - for (ii=0;ii<16;++ii) - { - retBool = win[ii]->BaseWin()->IsFaded(); - TEST(retBool); - if (!retBool) - INFO_PRINTF3(_L("win[ii]->BaseWin()->IsFaded() return value - Expected: %d, Actual: %d"), ETrue, retBool); - } - TestStrips(rect,height,0); - - // system fade off - TheClient->iWs.SetSystemFaded(EFalse); - for (ii=0;ii<16;++ii) - { - retBool = !win[ii]->BaseWin()->IsFaded(); - TEST(retBool); - if (!retBool) - INFO_PRINTF3(_L("!win[ii]->BaseWin()->IsFaded() return value - Expected: %d, Actual: %d"), ETrue, retBool); - } - TestStrips(rect,height,16); - - // Now with half non fading - for (ii=8;ii<16;++ii) - win[ii]->WinTreeNode()->SetNonFading(ETrue); - - // system fade on - TheClient->iWs.SetSystemFaded(ETrue); - TestStrips(rect,height,8,ETrue); - - // system fade off - TheClient->iWs.SetSystemFaded(EFalse); - TestStrips(rect,height,16); - - for (ii=0;ii<16;++ii) - delete win[ii]; - } - -void CTFade::SystemAlternateFadeL() - { -#if defined(__MARM__) - return; -#else - __ASSERT_ALWAYS(iBlankWin,AutoPanic(EAutoFadeWindow)); - TSize size=iTestWinSize; -#if defined(SMALL_RECTS) - size.iWidth=Min(SIZE_X,size.iWidth); - size.iHeight=Min(SIZE_Y,size.iHeight); -#endif - if (MaxGrays()==0 && MaxColors()<256) - return; - TRect windowRect(iBlankWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),size); - TUint8 bm; - TUint8 wm; - TUint8 fb; - TUint8 fw; - TInt wb; - TInt add; - TInt test=0; - TInt ii; - TBool retBool; - FOREVER - { - TInt fadeMapFactor = 0; - TInt fadeMapOffset = 0; - fw=0; - switch (test) - { - case 0: //Nothing - bm=0; - wm=15; - break; - case 1: //Shadowing or Quartz fading - bm=0; - wm=7; - fw=127; - break; - default: - return; - } - wb=wm-bm; - add=15*bm+7; - fb=STATIC_CAST(TUint8,17*bm); - if (!fw) - fw=STATIC_CAST(TUint8,17*wm); - fadeMapFactor = fw - fb; - fadeMapOffset = fb; - for (ii=0;ii<16;ii+=5) - { - iBlankWin->SetColor(TRgb::Gray16(ii)); - ViewDelay(); - TheClient->iWs.Finish(); -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - retBool = CheckBlankWindow(windowRect,TRgb::Gray16(ii),TheClient->iScreen); -#else - retBool = LossyCheckBlankWindow(*TheClient->iScreen, *iTestWinCopy, windowRect, TRgb::Gray16(ii)); -#endif - TEST(retBool); - if (!retBool) - INFO_PRINTF3(_L("CheckBlankWindow(windowRect,TRgb::Gray16(ii),TheClient->iScreen) return value - Expected: %d, Actual: %d"), ETrue, retBool); - - TheClient->iWs.SetSystemFaded(ETrue,fb,fw); - ViewDelay(); - - TRgb col3 = TRgb::Gray16(ii).Internal(); - TRgb col1 = FadeRgb(col3, fadeMapFactor, fadeMapOffset); -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - retBool = CheckBlankWindow(windowRect,col1,TheClient->iScreen); -#else - retBool = LossyCheckBlankWindow(*TheClient->iScreen, *iTestWinCopy, windowRect, col1); -#endif - TEST(retBool); - if (!retBool) - INFO_PRINTF3(_L("CheckBlankWindow(windowRect,TRgb::Gray16((ii*wb+add)/15),TheClient->iScreen) return value - Expected: %d, Actual: %d"), ETrue, retBool); - - TheClient->iWs.SetSystemFaded(EFalse); - ViewDelay(); -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - retBool = CheckBlankWindow(windowRect,TRgb::Gray16(ii),TheClient->iScreen); -#else - retBool = LossyCheckBlankWindow(*TheClient->iScreen, *iTestWinCopy, windowRect, TRgb::Gray16(ii)); -#endif - TEST(retBool); - if (!retBool) - INFO_PRINTF3(_L("CheckBlankWindow(windowRect,TRgb::Gray16(ii),TheClient->iScreen) return value - Expected: %d, Actual: %d"), ETrue, retBool); - } - ++test; - } -#endif //__MARM__ - } - -void CTFade::FadeBehindWhenMovedL() - { - __ASSERT_ALWAYS(iBlankWin,AutoPanic(EAutoFadeWindow)); - TDisplayMode displayMode=iBlankWin->BaseWin()->DisplayMode(); - iBlankWin->BaseWin()->SetRequiredDisplayMode(EGray16); - iBlankWin->SetColor(TRgb::Gray16(1)); - TSize size(iTestWinSize.iHeight/4,iTestWinSize.iWidth/4); - CTBlankWindow* blankWinTemp=new(ELeave) CTBlankWindow(); - CleanupStack::PushL(blankWinTemp); - blankWinTemp->SetUpL(TPoint(5,5),size,iBlankWin,*TheClient->iGc); - blankWinTemp->BaseWin()->SetRequiredDisplayMode(EGray16); - blankWinTemp->SetColor(TRgb::Gray16(15)); - blankWinTemp->BaseWin()->FadeBehind(ETrue); - TheClient->Flush(); - blankWinTemp->SetPos(TPoint(5,120)); - //Check whether the back window is faded or not - TBool retBool = iBlankWin->BaseWin()->IsFaded(); - TEST(retBool); - if (!retBool) - INFO_PRINTF3(_L("iBlankWin->BaseWin()->IsFaded() return value - Expected: %d, Actual: %d"), ETrue, retBool); - -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - CheckRect(iWindowRect.iTl+TPoint(5,5),iWindowRect.iTl+TPoint(75,5),size,_L("CTFade::FadeBehindWhenMovedL()")); -#else - TInt res = LossyCompareWindow(*TheClient->iScreen, *iTestWinCopy, *iCheckWinCopy, TRect(iWindowRect.iTl+TPoint(75,5),size)); - TEST(res); -#endif - - //Check whether the area behind the moved window and any other area on same window are identical - blankWinTemp->BaseWin()->FadeBehind(EFalse); - iBlankWin->BaseWin()->SetRequiredDisplayMode(displayMode); - CleanupStack::PopAndDestroy(blankWinTemp); - } - -void CTFade::FadeBehindTransparentWindowL() - { - const TInt KNumberOfWindows = 3; - CRedrawWin* win[KNumberOfWindows]; - TRect rect(iWindowRect); - rect.Resize(-iWindowRect.Width()/3,-iWindowRect.Height()/3); - rect.Move(iWindowRect.Width()/10,iWindowRect.Height()/5); - TRect rectWin[KNumberOfWindows]; - - for (TInt ii=0; iiConstructExtLD(*TheClient->iGroup,rectWin[ii].iTl,rectWin[ii].Size()); - win[ii]->AssignGC(*TheClient->iGc); - win[ii]->Win()->EnableRedrawStore(EFalse); - win[ii]->BaseWin()->SetRequiredDisplayMode(EColor16MA); - if (ii==0) - { - win[ii]->Win()->SetBackgroundColor(TRgb(200,0,0,255)); - } - else - { - TEST(KErrNone == win[ii]->Win()->SetTransparencyAlphaChannel()); - if (iStep->TestStepResult() != EPass) - { - INFO_PRINTF1(_L("Transparency Alpha channel failed to be enabled")); - } - win[ii]->Win()->SetBackgroundColor(TRgb(40,100,0,0)); //RGB colour is of minor importance, as the window is fully transparent (Alpha=0) - } - win[ii]->Activate(); - - //Make sure each window is drawn to the screen now when the new background - //colour have been set but before the call to SetFaded - win[ii]->Win()->BeginRedraw(); - win[ii]->Win()->EndRedraw(); - - rect.Resize(0,-iWindowRect.Height()/10); - rect.Move(iWindowRect.Width()/10,iWindowRect.Height()/20); - } - TheClient->iWs.Flush(); - TheClient->iWs.Finish(); - - win[0]->Win()->SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly); - win[1]->Win()->SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly); - win[2]->Win()->SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly); - - TheClient->iWs.Flush(); - TheClient->iWs.Finish(); - - // As the windows ovelap on their left side, compare the top left corners of the faded windows in order to verify that - // for the opaque window the directly on top faded area and the faded area under the transparent window (the area that - // overlaps with the transparent windows) have the same colour. - TRgb rgbWin[KNumberOfWindows]; - TheClient->iScreen->GetPixel(rgbWin[0], rectWin[0].iTl); - TheClient->iScreen->GetPixel(rgbWin[1], rectWin[1].iTl); - TheClient->iScreen->GetPixel(rgbWin[2], rectWin[2].iTl); - - TEST( ETrue == (rgbWin[0].Red()==rgbWin[1].Red())&&(rgbWin[0].Green()==rgbWin[1].Green())&&(rgbWin[0].Blue()==rgbWin[1].Blue()) ); - TEST( ETrue == (rgbWin[0].Red()==rgbWin[2].Red())&&(rgbWin[0].Green()==rgbWin[2].Green())&&(rgbWin[0].Blue()==rgbWin[2].Blue()) ); - - for (TInt ii=0; iiSetTestStepID(KUnknownSYMTestCaseIDName); - switch(++iTest->iState) - { -/** -@SYMTestCaseID GRAPHICS-WSERV-0218 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test fading colours in windows - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Fade the colours in windows and check they fade correctly - -@SYMTestExpectedResults Colour fade correctly -*/ - case 1: - ((CTFadeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0218")); - iTest->LogSubTest(_L("Color Check")); - CreateBlankWindowL(); - ColorTest(); - //iTest->iState=5; - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0219 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test fading in a blank window - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Fade in a blank window and check the fading occurs correctly - -@SYMTestExpectedResults Fading in a blank window occurs correctly -*/ - case 2: - ((CTFadeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0219")); - iTest->LogSubTest(_L("Blank Window")); - BlankWindowL(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0220 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test fading in child windows - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Fade in child windows and check the fading occurs correctly - -@SYMTestExpectedResults Fading in the child windows occurs correctly -*/ - case 3: - ((CTFadeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0220")); - iTest->LogSubTest(_L("Fade Children")); - FadeChildrenL(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0221 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test fading in newly created child windows - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Fade in newly created child windows and check the fading occurs correctly - -@SYMTestExpectedResults Fading in the newly created child windows occurs correctly -*/ - case 4: - ((CTFadeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0221")); - iTest->LogSubTest(_L("Fade Children newly created")); - FadeChildrenAfterNewChildIsCreatedL(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0222 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test fading in window behind another window - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Fade in window behind another window and check the fading occurs correctly - -@SYMTestExpectedResults Fading in window occurs correctly -*/ - case 5: - ((CTFadeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0222")); - iTest->LogSubTest(_L("Fade Behind")); - FadeBehindL(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0223 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test differnt fading techniques in a window - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Fade using different fading techniques in a window - and check the fading occurs correctly - -@SYMTestExpectedResults Fading in window occurs correctly -*/ - case 6: - ((CTFadeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0223")); -#if(defined(__DISPLAY_MODE_64K_COLOR)) //The test case Alternative Fadings1&2 & System Fade are not executed for EColor64k - iTest->LogSubTest(_L("Alternative Fadings1")); - ColorTest2(); -#else - LOG_MESSAGE(_L("Alternative Fadings1 test not run")); -#endif - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0224 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test differnt fading techniques in a window - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Fade using different fading techniques in a window - and check the fading occurs correctly - -@SYMTestExpectedResults Fading in window occurs correctly -*/ - case 7: - ((CTFadeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0224")); -#if(defined(__DISPLAY_MODE_64K_COLOR)) //The test case Alternative Fadings1&2 & System Fade are not executed for EColor64k - iTest->LogSubTest(_L("Alternative Fadings2")); - FadeTest(); -#else - LOG_MESSAGE(_L("Alternative Fadings2 test not run")); -#endif - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0225 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test differnt system wide fading techniques in a window - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Fade using different system wide fading techniques in a window - and check the fading occurs correctly - -@SYMTestExpectedResults Fading in system occurs correctly -*/ - case 8: - ((CTFadeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0225")); - iTest->LogSubTest(_L("System Fade")); - SystemFadeL(); - SystemAlternateFadeL(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0226 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test fading in window behind another window when the window has been moved - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Fade in window behind another window and check the fading occurs correctly - -@SYMTestExpectedResults Fading in window occurs correctly -*/ - case 9: - ((CTFadeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0226")); - iTest->LogSubTest(_L("Fade behind moved")); - FadeBehindWhenMovedL(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0227 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Destroy the blnk window used for fading - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Destroy the blnk window used for fading and check it was deleted correctly - -@SYMTestExpectedResults The window is destroyed -*/ - case 10: - ((CTFadeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0227")); - DestroyBlankWindow(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0228 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test backup window creation and drawing - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Create a backup window and draw in it - -@SYMTestExpectedResults The drawing is correct in the window -*/ - case BACKUPWIN: - ((CTFadeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0228")); - iTest->LogSubTest(_L("BackupWin Draw")); - CreateBitmapsL(); - CreateBackupWindowL(EFalse); - Draw(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0229 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test fading with backup window obscured - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Test fading with the backup window obscured - -@SYMTestExpectedResults Fading occurs correctly with window obscured -*/ - case BACKUPWIN+1: - ((CTFadeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0229")); - iTest->LogSubTest(_L("BackupWin Obscured")); - ObscuredL(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0230 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test fading with backup window being moved - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Test fading with the backup window being moved - -@SYMTestExpectedResults Fading occurs correctly with window moved -*/ - case BACKUPWIN+2: - ((CTFadeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0230")); - iTest->LogSubTest(_L("BackupWin Moving")); - MovingL(); - DestroyDrawableWindow(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0231 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test backup window creation and drawing - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Create a backup window and draw in it - -@SYMTestExpectedResults The drawing is correct in the window -*/ - case BACKUPWIN+3: - ((CTFadeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0231")); - iTest->LogSubTest(_L("BackupWin Draw")); - CreateBackupWindowL(ETrue); - Draw(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0232 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test fading with backup window obscured - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Test fading with the backup window obscured - -@SYMTestExpectedResults Fading occurs correctly with window obscured -*/ - case BACKUPWIN+4: - ((CTFadeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0232")); - iTest->LogSubTest(_L("BackupWin Obscured")); - ObscuredL(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0233 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test fading with backup window being moved - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Test fading with the backup window being moved - -@SYMTestExpectedResults Fading occurs correctly with window moved -*/ - case BACKUPWIN+5: - ((CTFadeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0233")); - iTest->LogSubTest(_L("BackupWin Moving")); - MovingL(); - DestroyDrawableWindow(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0234 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test redraw window creation and drawing - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Create a redraw window and draw in it - -@SYMTestExpectedResults The drawing is correct in the window -*/ - case REDRAWWIN: - ((CTFadeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0234")); - iTest->LogSubTest(_L("RedrawWin Draw")); - CreateRedrawWindowL(); - Draw(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0235 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test fading with redraw window obscured - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Test fading with the redraw window obscured - -@SYMTestExpectedResults Fading occurs correctly with window obscured -*/ - case REDRAWWIN+1: - ((CTFadeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0235")); - iTest->LogSubTest(_L("RedrawWin Obscured")); - ObscuredL(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0236 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test fading with redraw window being moved - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Test fading with the redraw window being moved - -@SYMTestExpectedResults Fading occurs correctly with window moved -*/ - case REDRAWWIN+2: - ((CTFadeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0236")); - iTest->LogSubTest(_L("RedrawWin Moving")); - MovingL(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0237 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test different fading techniques within a redraw window - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Test different fading techniques within a redraw window - -@SYMTestExpectedResults Fading occurs correctly for the different techniques -*/ - case REDRAWWIN+3: - ((CTFadeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0237")); - iTest->LogSubTest(_L("AlternativeFadeDraw")); - Draw(ETrue); - break; - -/** -@SYMTestCaseID GRAPHICS-WSERV-0238 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test fading within a redraw window using the graphic context - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Test fading within a redraw window using the graphic context - -@SYMTestExpectedResults Fading occurs correctly in the window -*/ - case REDRAWWIN+4: - ((CTFadeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0238")); -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - iTest->LogSubTest(_L("GC Test")); - GCDraw(); - DestroyDrawableWindow(); - DestroyBitmaps(); -#endif - break; - -/** -@SYMTestCaseID GRAPHICS-WSERV-0538 - -@SYMDEF DEF120965 - -@SYMTestCaseDesc Test fading under transparent window - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Construct opaque window lying under two transparent windows. Fade the opaque and the transparent windows. - -@SYMTestExpectedResults Each of the overlapping areas should be faded only once. -*/ - case REDRAWWIN+5: - { - ((CTFadeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0538")); - iTest->LogSubTest(_L("Fade behind transparent window")); - CRedrawWin* win = new(ELeave) CRedrawWin(this); - win->ConstructL(TRect(0,0,0,0)); - TInt transparency = win->Win()->SetTransparencyAlphaChannel(); - if (transparency!=KErrNotSupported) - { - FadeBehindTransparentWindowL(); - } - else - { - WARN_PRINTF1(_L("Transparency not supported. Skipping test.")); - } - delete win; - break; - } - case REDRAWWIN+6: - ((CTFadeStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - iTest->LogSubTest(_L("Test complete\n")); -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA - DestroyDrawableWindow(); - DestroyBitmaps(); -#endif - ((CTFadeStep*)iStep)->CloseTMSGraphicsStep(); - TestComplete(); - break; - default: - ((CTFadeStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - break; - } - ((CTFadeStep*)iStep)->RecordTestResultL(); - } - -__WS_CONSTRUCT_STEP__(Fade) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TFADE.H --- a/windowing/windowserver/tauto/TFADE.H Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,145 +0,0 @@ - -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef __TFADE_H__ -#define __TFADE_H__ - -#include "AUTO.H" - -#if defined(__MARM__) - #define SMALL_RECTS -#endif -#define SIZE_X 10 -#define SIZE_Y 5 -#define DRAW_MODE EColor64K //Mode used for testing fadded drawing -#define BLACK_NORMAL 128 -#define WHITE_NORMAL 255 -#define BLACK_ALTERNATE 0 -#define WHITE_ALTERNATE 127 -#define NUMBER_OF_WINDOWS 16 - -#define MODE_LT_64K(mode) (TDisplayModeUtils::NumDisplayModeColors(mode)<65536) - -#define ETrue 1 -#define EFalse 0 - -class CTFade : public CTWsGraphicsBase - { -public: - CTFade(CTestStep* aStep); - ~CTFade(); - void ConstructL(); - TInt Content(); - void Drawing(TInt aDrawFunc, CBitmapContext *gc); - //Different Tests - void ColorTest(); - void BlankWindowL(); - void FadeChildrenL(); - void FadeChildrenAfterNewChildIsCreatedL(); - void FadeBehindL(); - void ColorTest2(); - void FadeTest(); - void Draw(TBool aAlternativeFade=EFalse); - void ObscuredL(); - void MovingL(); -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - void GCDraw(); -#endif - void SystemFadeL(); - void SystemAlternateFadeL(); - void FadeBehindWhenMovedL(); - void FadeBehindTransparentWindowL(); -protected: -//from CTGraphicsStep - virtual void RunTestCaseL(TInt aCurTestCase); -private: - void CreateBlankWindowL(); - void DestroyBlankWindow(); - void CreateBackupWindowL(TBool aMaintainBackup); - void CreateRedrawWindowL(); - void DestroyDrawableWindow(); - void CreateBitmapsL(); - void DestroyBitmaps(); - void Draw(TInt aDrawFunc, TAny *aParam, TBool aAlternativeFade=EFalse, TBool aFade=EFalse); -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - void GCDraw(TInt aDrawFunc, TAny *aParam, TBool aAlternativeFade=EFalse); -#endif - void Draw(TInt aDrawFunc, TAny *aParam, CBitmapContext *gc); - void CompareWithBitmap(TBool aFade); - void CompareWindows(TBool aAlternativeFade=EFalse); - void TestStrips(TRect aRect,TInt aHeight,TInt aNumNotFaded,TBool aInvert=EFalse); - void TestBlocks(TRect aRect,TSize aSize,TInt aNumNotFaded,TBool aInvert=EFalse); - TInt Fade4(TInt aGray4); - TInt Fade16(TInt aGray16); - TRgb FadeRgb(TRgb aColor); - TRgb FadeRgb(TRgb aColor, TInt aFadeMapFactor, TInt aFadeMapOffset); - inline void ViewDelay(); -private: - CTBlankWindow* iBlankWin; - CTDrawableWin* iWin; - TBool iOwnWindow; - TRect iWindowRect; - TRect iBaseRect; - CFbsBitmap iNormalBitmap; - CFbsBitmap iFadedBitmap; - CFbsBitGc *iNormalBitGc; - CFbsBitGc *iFadedBitGc; - CFbsDevice *iNormalBitmapDevice; - CFbsDevice *iFadedBitmapDevice; - TInt iContent; - TDisplayMode iBaseWinMode; - TDisplayMode iDeviceDisplayMode; - TSize iTestWinSize; - TDisplayMode iFadeDrawMode; - CFbsBitmap *iTestWinCopy; - CFbsBitmap *iCheckWinCopy; -#if defined (__MARM_THUMB__) -GLDEF_D TBool CanFade; -GLDEF_D TBool CanFadeSet; -#endif - }; - -class CRedrawWin : public CTWin - { -public: - CRedrawWin(CTFade *aTest); - void ConstructL(TRect aArea); - ~CRedrawWin(); - void Draw(); - -protected: - CTFade* iTest; - }; - -class CTFadeStep : public CTGraphicsStep - { -public: - CTFadeStep(); -protected: - //from CTGraphicsStep - virtual CTGraphicsBase* CreateTestL(); - }; - -_LIT(KTFadeStep,"TFade"); - - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TFADINGBITMAP.CPP --- a/windowing/windowserver/tauto/TFADINGBITMAP.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,250 +0,0 @@ -// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// The fix enables the fading effect with alpha-blending, which was not applied bofore. -// The test will load a bitmap and two different masks: on/off and alpha-blend. -// The bitmap will be masked with these masks and displayed before and after -// setting the fading effect. -// All different colour modes are being tested for both mask types. -// The test will check the colour of a specific pixel in the scene before and after the -// fading. The higher values in the After circle means that it has been highlighted. -// The result will be printed in wstest log file. -// -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include "TFADINGBITMAP.H" - -//=================================================== -// CBaseWin Declaration -//=================================================== - -CBaseWin::CBaseWin(): CTWin() - { - } - -CBaseWin::~CBaseWin() - { - delete iTempBitmap; - delete iMaskGray256; - delete iMaskGray2; - delete iTempMask; - delete iBitmap; - } - -void CBaseWin::ConstructWinL(TPoint aPos, TSize aSize, TBool aVisible) - { - /*** Setting up the window ***/ - iSize = aSize; - SetUpL(aPos, aSize, TheClient->iGroup, *TheClient->iGc, aVisible); - Win()->SetBackgroundColor(TRgb(20, 80, 20)); // dark green background - BaseWin()->SetRequiredDisplayMode(EColor64K); - - /*** 24 bit bitmap ***/ - // the original 24b bitmap to mask - iTempBitmap = new (ELeave) CFbsBitmap(); - User::LeaveIfError(iTempBitmap->Load(_L("Z:\\WSTEST\\WSAUTOTEST.MBM"), EMbmWsautotestCircles24b)); - iBitmap = new (ELeave) CFbsBitmap(); - - /*** on/off mask ***/ - iMaskGray2 = new (ELeave) CFbsBitmap(); - User::LeaveIfError(iMaskGray2->Load(_L("Z:\\WSTEST\\WSAUTOTEST.MBM"), EMbmWsautotestCircles_mask2b)); - - /*** alpha-blend mask ***/ - // holds the 24bit copy of the alpha blend mask which will be - // copied into the proper Gray256 mask, iMaskGray256. - iTempMask = new (ELeave) CFbsBitmap(); - User::LeaveIfError(iTempMask->Load(_L("Z:\\WSTEST\\WSAUTOTEST.MBM"), EMbmWsautotestCircles_mask256)); - // alpha blend mask; copying its data from iTempMask - iMaskGray256 = new (ELeave) CFbsBitmap(); - User::LeaveIfError(iMaskGray256->Create(iTempBitmap->SizeInPixels(),EGray256)); - CFbsBitmapDevice *dev = CFbsBitmapDevice::NewL(iMaskGray256); - CleanupStack::PushL(dev); - CFbsBitGc *gc; - User::LeaveIfError(dev->CreateContext(gc)); - // performing the copying here - gc->BitBlt(TPoint(0,0), iTempMask); - // cleaning up - CleanupStack::Pop(); - delete gc; - gc = NULL; - delete dev; - dev = NULL; - } - -void CBaseWin::Draw() - { - iGc->Clear(); - - // Font intialization - CFont* myFont; - _LIT(KMyFontName,"Swiss"); - TFontSpec myFontSpec = TFontSpec(KMyFontName,16); // to get smallest Swiss font - TFontStyle style = TFontStyle (EPostureUpright, EStrokeWeightBold, EPrintPosNormal); - myFontSpec.iFontStyle = style; - User::LeaveIfError(TheClient->iScreen->GetNearestFontInPixels(myFont, myFontSpec)); - iGc->UseFont(myFont); - iGc->SetPenStyle(CGraphicsContext::ESolidPen); - iGc->SetPenColor(TRgb(255, 255, 255)); - - // drawing text - iGc->DrawText(_L("Fading = OFF"), TPoint(130,15)); - iGc->DrawText(_L("Fading = ON"), TPoint(275,15)); - iGc->DrawText(_L("Alpha blend"), TPoint(15,90)); - iGc->DrawText(_L("on/off mask"), TPoint(15,190)); - TBuf <30> displayMode(_L("Display Mode = ")); - displayMode.Append(iMode); - iGc->DrawText(displayMode, TPoint(385,100)); - - /*** drawing bitmap with its on/off mask and alpha-blending - before and after fading ***/ - iGc->BitBltMasked(TPoint(140,25), iBitmap, - TRect(0,0,100,100), iMaskGray256, EFalse); - // Save the pixel colour of a pixel on the outer ring of the circle - // before fading enabled. - TheClient->iScreen->GetPixel(iNonFadedPixel, TPoint(190,30)); - - iGc->SetFaded(ETrue); - iGc->BitBltMasked(TPoint(270,25), iBitmap, - TRect(0,0,100,100), iMaskGray256, EFalse); - // Save the pixel colour of a pixel on the outer ring of the circle - // after fading enabled. - TheClient->iScreen->GetPixel(iFadedPixel, TPoint(320,30)); - - iGc->SetFaded(EFalse); - - iGc->BitBltMasked(TPoint(140,125), iBitmap, - TRect(0,0,100,100), iMaskGray2, EFalse); - iGc->SetFaded(ETrue); - iGc->BitBltMasked(TPoint(270,125), iBitmap, - TRect(0,0,100,100), iMaskGray2, EFalse); - iGc->SetFaded(EFalse); - - iGc->DiscardFont(); - TheClient->iScreen->ReleaseFont(myFont); - } - - -//=================================================== -// CTFadingBitmap Definition -//=================================================== - -CTFadingBitmap::CTFadingBitmap(CTestStep* aStep): - CTWsGraphicsBase(aStep), iTestResult(ETrue) - { - } - -CTFadingBitmap::~CTFadingBitmap() - { - delete iBgWin; - } - -void CTFadingBitmap::TestFadingL() - { - // Modes to test - TDisplayMode modes[] = - { - EGray2, EGray4, EGray16, EGray256, - EColor16, EColor256, EColor4K, EColor64K, - EColor16M, EColor16MU, EColor16MA, EColor16MAP - }; - - TBuf <12> modesTxt []= - { - _L("EGray2"), _L("EGray4"), _L("EGray16"), _L("EGray256"), - _L("EColor16"), _L("EColor256"), _L("EColor4K"), _L("EColor64K"), - _L("EColor16M"), _L("EColor16MU"), _L("EColor16MA"), _L("EColor16MAP") - }; - - TBuf <100> testTxt; - for( int i = 0; i < 12; i++) - { - testTxt.Format(modesTxt[i]); - INFO_PRINTF1(testTxt); - // Here we copy the content of the temp bitmap, which holds the test bitmap, - // into the bitmap created with alternating color depths. - User::LeaveIfError(iBgWin->iBitmap->Create(iBgWin->iTempBitmap->SizeInPixels(), modes[i])); - CFbsBitmapDevice *dev = CFbsBitmapDevice::NewL(iBgWin->iBitmap); - CleanupStack::PushL(dev); - CFbsBitGc *gc; - User::LeaveIfError(dev->CreateContext(gc)); - // performing the copying here - gc->BitBlt(TPoint(0,0), iBgWin->iTempBitmap); - // setting the mode text to display it - iBgWin->iMode = modesTxt[i]; - // draws the bitmap on screen - iBgWin->DrawNow(); - TheClient->Flush(); - User::After(5000); - // cleaning up - CleanupStack::Pop(); - delete gc; - gc = NULL; - delete dev; - dev = NULL; - - // Here the colours of pixels before and after fading are printed in wstest log - testTxt.Format(_L("Nonfaded circle - color of the outside ring: R=%d G=%d B=%d"), iBgWin->iNonFadedPixel.Red(), iBgWin->iNonFadedPixel.Green(), iBgWin->iNonFadedPixel.Blue()); - INFO_PRINTF1(testTxt); - testTxt.Format(_L("Faded circle - color of the outside ring: R=%d G=%d B=%d"), iBgWin->iFadedPixel.Red(), iBgWin->iFadedPixel.Green(), iBgWin->iFadedPixel.Blue()); - INFO_PRINTF1(testTxt); - - // Checks if the colors are the same before and after the fading. - // The color will be the same only in EGray2 and EGray4 as there are no enough - // color variations to represent the fading and nonfading effects. - if(iTestResult && - iBgWin->iNonFadedPixel.Red() == iBgWin->iFadedPixel.Red() && - iBgWin->iNonFadedPixel.Green() == iBgWin->iFadedPixel.Green() && - iBgWin->iNonFadedPixel.Blue() == iBgWin->iFadedPixel.Blue() && - modes[i] != EGray2 && modes[i] != EGray4) - iTestResult = EFalse; - } - } - -void CTFadingBitmap::ConstructL() - { - // construct the base window of the test in the background - TSize scrSize = TSize(TheClient->iScreen->SizeInPixels()); - iBgWin = new (ELeave) CBaseWin(); - iBgWin->ConstructWinL(TPoint(0,0), scrSize, ETrue); - } - -void CTFadingBitmap::RunTestCaseL(TInt aCurTestCase) - { - ((CTFadingBitmapStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); - switch(aCurTestCase) - { - case 1: -/** -@SYMTestCaseID GRAPHICS-WSERV-0566 -*/ - ((CTFadingBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0566")); - TestFadingL(); - // Fails or passes the test - if(!iTestResult) - TEST(EFalse); - break; - default: - ((CTFadingBitmapStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - ((CTFadingBitmapStep*)iStep)->CloseTMSGraphicsStep(); - TestComplete(); - } - ((CTFadingBitmapStep*)iStep)->RecordTestResultL(); - } - -__WS_CONSTRUCT_STEP__(FadingBitmap) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TFADINGBITMAP.H --- a/windowing/windowserver/tauto/TFADINGBITMAP.H Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,94 +0,0 @@ -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef __TFADINGBITMAP_H__ -#define __TFADINGBITMAP_H__ - -#include -#include -#include "../tlib/testbase.h" -#include "AUTO.H" -#include "TGraphicsHarness.h" - - -//=================================================== -// CBaseWin Definition -// The plain green background window -//=================================================== - -class CBaseWin : public CTWin - { -public: - CBaseWin(); - ~CBaseWin(); - void Draw(); - void ConstructWinL(TPoint, TSize, TBool); - -public: - CFbsBitmap *iTempBitmap; - CFbsBitmap *iMaskGray256; - CFbsBitmap *iMaskGray2; - CFbsBitmap *iTempMask; - CFbsBitmap *iBitmap; - - TRgb iFadedPixel; - TRgb iNonFadedPixel; - - TBuf <11> iMode; - }; - - -//=================================================== -// CTFadingBitmap Definition -// Bitmaps to be tested -//=================================================== - -class CTFadingBitmap : public CTWsGraphicsBase - { -public: - CTFadingBitmap(CTestStep* aStep); - ~CTFadingBitmap(); - /*Sets the windowing environment,*/ - void ConstructL(); - -protected: - //from CTGraphicsStep - Calls the fading bitmap test. - virtual void RunTestCaseL(TInt aCurTestCase); -private: - void TestFadingL (); - -private: - CBaseWin *iBgWin; - TBool iTestResult; - }; - -class CTFadingBitmapStep : public CTGraphicsStep - { -public: - CTFadingBitmapStep(); -protected: - //from CTGraphicsStep - virtual CTGraphicsBase* CreateTestL(); - }; - -_LIT(KTFadingBitmapStep,"TFadingBitmap"); - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TFLICKERFREE.CPP --- a/windowing/windowserver/tauto/TFLICKERFREE.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,139 +0,0 @@ -// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// TMULSCREENS.CPP -// Tests the newly API function added to RWindow which enables/disables -// the usage of Off-Screen Bitmap (OSB). -// The test will draw squares with random colours on screen filling the -// whole drawable area. The drawing will start first with flickering screen -// and will switch to flicker free in 4 seconds. -// -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include "TFLICKERFREE.H" - -//=================================================== -// CBGWin Declaration -//=================================================== - -CBGWin::CBGWin(): CTWin() - { - } - -CBGWin::~CBGWin() - { - } - -void CBGWin::ConstructWin(TPoint aPos, TSize aSize, TBool aVisible) - { - iSize = aSize; - SetUpL(aPos,iSize,TheClient->iGroup,*TheClient->iGc, aVisible); - BaseWin()->SetRequiredDisplayMode(EColor256); - } - -void CBGWin::Draw() - { - iGc->Clear(); - iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - - TUint propW = iSize.iWidth/32; - TUint propH = iSize.iHeight/12; - - for(TInt i = 0; i < iSize.iWidth ; i+=propW) - { - for(TInt j = 0; j < iSize.iHeight; j+=propH) - { - iGc->SetBrushColor(TRgb( (TInt)(Math::Random()%255), (TInt)(Math::Random()%255), (TInt)(Math::Random()%255) )); - iGc->DrawRect(TRect(i, j, i+propW-1, j+propH-1)); - } - } - } - -void CBGWin::EnableOSBd(TBool aState) - { - iWin.EnableOSB(aState); - } - -//=================================================== -// CFlickerTest Declaration -//=================================================== - -/* This function will be called periodically to draw the rects - on screen.*/ -void CTFlickerFree::TestFlickering() - { - for( int i = 0; i < 40; ++i) - { - // for the first 3 seconds draw with flicker - if(i < 20 ) - iBgWin->EnableOSBd(EFalse); - // for the next 3 seconds draw with flicker free - else if(i >=20 ) - iBgWin->EnableOSBd(ETrue); - - iBgWin->DrawNow(); - - // this draws 20 frames per second for 4 seconds - User::After(50000); - } - } - -CTFlickerFree::CTFlickerFree(CTestStep* aStep): - CTWsGraphicsBase(aStep) - { - } - -CTFlickerFree::~CTFlickerFree() - { - delete iBgWin; - } - -void CTFlickerFree::ConstructL() - { - // get the size of the current client to assign it to the background window - TSize scrSize = TSize(TheClient->iScreen->SizeInPixels()); - - // construct the window in the background - iBgWin = new (ELeave) CBGWin(); - iBgWin->ConstructWin(TPoint(0,0), scrSize, ETrue); - } - -/* Sets the windowing environment, constructs the CPeriod object and - starts the CPeriod object.*/ -void CTFlickerFree::RunTestCaseL(TInt aCurTestCase) - { - ((CTFlickerFreeStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); - switch(aCurTestCase) - { - case 1: -/** -@SYMTestCaseID GRAPHICS-WSERV-0567 -*/ - ((CTFlickerFreeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0567")); - TestFlickering(); - break; - default: - ((CTFlickerFreeStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - ((CTFlickerFreeStep*)iStep)->CloseTMSGraphicsStep(); - TestComplete(); - } - ((CTFlickerFreeStep*)iStep)->RecordTestResultL(); - } - -__WS_CONSTRUCT_STEP__(FlickerFree) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TFLICKERFREE.H --- a/windowing/windowserver/tauto/TFLICKERFREE.H Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,84 +0,0 @@ -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Tests the usage of Off-Screen Bitmap -// -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef __TFLICKERFREE_H__ -#define __TFLICKERFREE_H__ - -#include -#include -#include "../tlib/testbase.h" -#include "AUTO.H" -#include //to include math finction rand() -#include "TGraphicsHarness.h" - -//=================================================== -// CBGWin Definition -//=================================================== - -class CBGWin : public CTWin - { -public: - CBGWin(); - ~CBGWin(); - /*Draws and colors the rectagles that are to fill the screen.*/ - void Draw(); - void ConstructWin(TPoint, TSize, TBool); - void EnableOSBd(TBool); - }; - - -//=================================================== -// CFlickerTest Definition -//=================================================== -class CTFlickerFree : public CTWsGraphicsBase - { -public: - CTFlickerFree(CTestStep* aStep); - ~CTFlickerFree(); - /*Sets the windowing environment,*/ - void ConstructL(); - -protected: -//from CTGraphicsStep - Calls the flicker-drawing test. - virtual void RunTestCaseL(TInt aCurTestCase); -private: - /*Starts first with flickering screen and after 4 senconds it - switches to flicker free drawing.*/ - void TestFlickering(); - -private: - CBGWin *iBgWin; - }; - -class CTFlickerFreeStep : public CTGraphicsStep - { -public: - CTFlickerFreeStep(); -protected: - //from CTGraphicsStep - virtual CTGraphicsBase* CreateTestL(); - }; - -_LIT(KTFlickerFreeStep,"TFlickerFree"); - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TGDI.CPP --- a/windowing/windowserver/tauto/TGDI.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1289 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// GDI.CPP -// Test GDI functions -// -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include "TGDI.H" - -#define TAUTO_BITMAP_NAME _L("Z:\\WSTEST\\TAUTO.MBM") - -//#define LOGGING on //Uncomment this line to get extra test logging - useful if debugging a failure of one of the tests - -typedef CGdiTestLowLevel *(*GdiTestFunc)(); - -_LIT(KMonospaceTestFontTypefaceName,"Arial"); -const TInt KMaxFontSize = 200; - -static inline TBool IsLengthEqual(TInt aLLen, TInt aRLen, TInt aBbLen) - { -// The bounding box of a 'w' is one pixel wider than it should be. W overlaps in to the bounding box of 'x' as the two -// are stuck together. So add a tolerance of -1. - return (((aLLen+aRLen)==aBbLen) || ((aLLen+aRLen-1)==aBbLen)); - } - -struct GdiTest - { - GdiTestFunc func; - const TText *txt; - }; - -GdiTest GdiTestFuncs[]={ - {BoxTextTest,_S("BoxText")}, - {VertTextTest,_S("VertText")}, - /*{JustifiedTextTest,_S("JustifiedText")},*/ // DEF107985 The test for JustifiedText has been removed as it was a bad/useless test - {VertBoxTextTest,_S("VertBoxText")}, - {SetOriginTest,_S("SetOrigin")}, - {PolyLineTest,_S("PolyLine")}, - {PolygonTest,_S("Polygon")}, - {DrawArcTest,_S("DrawArc")}, - {DrawPieTest,_S("DrawPie")}, - {DrawRoundRectTest,_S("DrawRoundRect")}, - {WideLineTest,_S("WideLine")}, - {DrawTextTest,_S("DrawText")}, - {DrawRectTest,_S("DrawRect")}, - }; - -CTestWindow::CTestWindow(TRgb aCol) : CBlankWindow(aCol) - { - } - -CTestWindow::~CTestWindow() - { - } - -void CTestWindow::ConstructL(TPoint aPos,TSize aSize,CTWinBase* aParent, CWindowGc& aGc) - { - iWin=RWindow(TheClient->iWs); - User::LeaveIfError(iWin.Construct(*(aParent->WinTreeNode()),ENullWsHandle)); - SetExt(aPos,aSize); - Activate(); - AssignGC(aGc); - } - -void CGdiTestLowLevel::SetGdiTest(CTGdi *aGdiTest) - { - iGdiTest=aGdiTest; - } - -void CGdiTestLowLevel::AssignGdi(CWindowGc *aGc) - { - iGdi=aGc; - } - -void CGdiTestLowLevel::ConstructL(TInt) - { - } - -void CGdiTestLowLevel::PreTestSetupL(const TRect &,TInt) - { - } - -//=======================================// -// Individual GDI low level test classes // -//=======================================// - - -void CGdiRect::ConstructL(TInt) - { - } - -void CGdiRect::PreTestSetupL(const TRect &, TInt aCount) - { - iBrushCol=TRgb::Gray256(aCount&0x1 ? 0xFF : 0x60); - iPenCol=TRgb::Gray256(aCount&0x1 ? 0xA0 : 0x0); - } - -TInt CGdiRect::Count(TBool ) - { - return(1); - } - -void CGdiDrawRect::BaseTest(const TRect &aRect, TInt aCount) - { - TheTest(aRect,aCount); - } - -void CGdiDrawRect::TheTest(const TRect &aRect, TInt) - { - iGdi->SetBrushColor(iBrushCol); - iGdi->SetPenColor(iPenCol); - iGdi->DrawRect(aRect); - } - -TInt CGdiDrawRect::Count(TBool aMode) - { - return(aMode ? 4:1); - } - -TInt CGdiDrawRoundRect::Count(TBool aMode) - { - return(aMode ? 4:1); - } - -void CGdiDrawRoundRect::BaseTest(const TRect &aRect, TInt aCount) - { - TheTest(aRect,aCount); - } - -void CGdiDrawRoundRect::TheTest(const TRect &aRect, TInt aCount) - { - iGdi->SetBrushColor(iBrushCol); - iGdi->SetPenColor(iPenCol); - TSize size((aRect.iBr.iX-aRect.iTl.iX)/4,(aRect.iBr.iY-aRect.iTl.iY)/4); - switch(aCount) - { - case 0: - size.SetSize((aRect.iBr.iX-aRect.iTl.iX)/4,(aRect.iBr.iY-aRect.iTl.iY)/4); - break; - case 1: - size.SetSize(0,0); - break; - case 2: - size.SetSize((aRect.iBr.iX-aRect.iTl.iX)/2,(aRect.iBr.iY-aRect.iTl.iY)/2); - break; - case 3: - size.SetSize((aRect.iBr.iX-aRect.iTl.iX),(aRect.iBr.iY-aRect.iTl.iY)); - break; - } - iGdi->DrawRoundRect(aRect,size); - } - -TInt CGdiDrawACP::Count(TBool ) - { - return(1); - } - -void CGdiDrawACP::ConstructL(TInt) - { - } - -void CGdiDrawACP::PreTestSetupL(const TRect &, TInt ) - { - iBrushCol=TRgb::Gray256(0xff); - iPenCol=TRgb(0,0,0); - } - -void CGdiDrawArc::BaseTest(const TRect &aRect, TInt aCount) - { - TheTest(aRect,aCount); - } - -void CGdiDrawArc::TheTest(const TRect &aRect, TInt) - { - iGdi->SetBrushColor(iBrushCol); - iGdi->SetPenColor(iPenCol); - TPoint start(aRect.iTl.iX/2+aRect.iBr.iX,aRect.iTl.iY/2+aRect.iBr.iY); - iGdi->DrawArc(aRect,start,TPoint(0,0)); - } - -void CGdiDrawPie::BaseTest(const TRect &aRect, TInt aCount) - { - TheTest(aRect,aCount); - } - -void CGdiDrawPie::TheTest(const TRect &aRect, TInt) - { - iGdi->SetBrushColor(iBrushCol); - iGdi->SetPenColor(iPenCol); - TPoint start(aRect.iTl.iX/2+aRect.iBr.iX,aRect.iTl.iY/2+aRect.iBr.iY); - iGdi->DrawPie(aRect,start,TPoint(0,0)); - } - -// -// Polyline tests -// - -CGdiPolyLine::CGdiPolyLine() : iPnts(5) - {} - -void CGdiPolyLine::PreTestSetupL(const TRect &aRect, TInt aCount) - { - iPnts.Reset(); - TInt wid=aRect.Width(); - TInt hgt=aRect.Height(); - if (aCount==0) - { - TInt pos; - for(pos=0;pos0) - iGdi->DrawLine(prev,iPnts[index]); - prev=iPnts[index]; - } - if (index>0) - iGdi->Plot(iPnts[index-1]); - } - -void CGdiPolyLine::TheTest(const TRect &, TInt ) - { - iGdi->DrawPolyLine(&iPnts); - } - -// -// Polygon tests // -// - -CGdiPolygon::CGdiPolygon() : iPnts(5) - {} - -void CGdiPolygon::PreTestSetupL(const TRect &aRect, TInt ) - { - iPnts.Reset(); - TPoint pnt; - TInt maxPoints=Min((TInt)KMaxPolygonPoints,Min(aRect.Width(),aRect.Height())/KPolygonStep); - TInt numPoints=0; - if (maxPoints>0) - { - iPnts.AppendL(aRect.iTl); - while(numPoints0) - { - numPoints--; - if (numPoints&1) - pnt.SetXY(aRect.iTl.iX+numPoints*KPolygonStep,aRect.iTl.iY+(numPoints+1)*KPolygonStep); - else - pnt.SetXY(aRect.iTl.iX+(numPoints+1)*KPolygonStep,aRect.iTl.iY+numPoints*KPolygonStep); - iPnts.AppendL(pnt); - } - } - } - -void CGdiPolygon::ConstructL(TInt ) - { - } - -TInt CGdiPolygon::Count(TBool aMainTests) - { - return(aMainTests ? 2 : 1); - } - -void CGdiPolygon::BaseTest(const TRect &aRect, TInt ) - { - iGdi->SetPenColor(TRgb::Gray4(2)); - iGdi->SetBrushColor(TRgb::Gray4(1)); - iGdi->SetBrushStyle(CGraphicsContext::ESolidBrush); - TInt maxPoints=Min((TInt)KMaxPolygonPoints,Min(aRect.Width(),aRect.Height())/KPolygonStep); - for(TInt numPoints=0;numPointsDrawRect(TRect(aRect.iTl.iX+numPoints*KPolygonStep + 1,aRect.iTl.iY+numPoints*KPolygonStep + 1, - aRect.iTl.iX+(numPoints+1)*KPolygonStep ,aRect.iTl.iY+(numPoints+1)*KPolygonStep)); - } - -void CGdiPolygon::TheTest(const TRect &, TInt ) -//This is the only one that can leave so it's not worth adding an 'L' - { - iGdi->SetPenColor(TRgb::Gray4(2)); - iGdi->SetBrushColor(TRgb::Gray4(1)); - iGdi->SetBrushStyle(CGraphicsContext::ESolidBrush); - User::LeaveIfError(iGdi->DrawPolygon(&iPnts,CGraphicsContext::EAlternate)); - } - -// - -TInt CGdiWideLine::Count(TBool aMainTests) - { - return(aMainTests ? EMainNumWidths : EMinorNumWidths); - } - -void CGdiWideLine::ConstructL(TInt) - { - } - -void CGdiWideLine::PreTestSetupL(const TRect &, TInt aCount) - { - TInt widths[]={1,4,50,-2, - 48,12345,0,3, - 48,123,0,3, - 4,111,555,1000, - 10,-1,-10,-100}; - iWidth=widths[aCount]; - } - -void CGdiWideLine::BaseTest(const TRect &aRect, TInt) - { - iGdi->SetPenSize(TSize(iWidth,iWidth)); - iGdi->DrawLine(aRect.iTl,aRect.iBr); - iGdi->MoveTo(aRect.iTl+TPoint(0,10)); - iGdi->DrawLineBy(aRect.iBr-aRect.iTl); - iGdi->MoveBy(aRect.iTl-aRect.iBr+TPoint(0,10)); - iGdi->DrawLineTo(aRect.iBr+TPoint(0,20)); - } - -void CGdiWideLine::TheTest(const TRect &aRect, TInt) - { - iGdi->SetPenSize(TSize(iWidth,iWidth)); - iGdi->MoveTo(aRect.iTl); - iGdi->DrawLineBy(aRect.iBr-aRect.iTl); - iGdi->MoveBy(aRect.iTl-aRect.iBr+TPoint(0,10)); - iGdi->DrawLineTo(aRect.iBr+TPoint(0,10)); - iGdi->DrawLine(aRect.iTl+TPoint(0,20),aRect.iBr+TPoint(0,20)); - } - -// -// Set Origin // -// - -CGdiSetOrigin::~CGdiSetOrigin() - { - delete iPolylineArray; - delete iPolygonArray; - TheClient->iScreen->ReleaseFont(iFont); - } - -TInt CGdiSetOrigin::Count(TBool ) - { - return(1); - } - -void CGdiSetOrigin::ConstructL(TInt) - { - iPolylineArray=new(ELeave) CArrayFixFlat(3); - iPolylineArray->AppendL(TPoint(40,1)); - iPolylineArray->AppendL(TPoint(50,11)); - iPolylineArray->AppendL(TPoint(40,21)); - iPolygonArray=new(ELeave) CArrayFixFlat(3); - iPolygonArray->AppendL(TPoint(40,30)); - iPolygonArray->AppendL(TPoint(50,40)); - iPolygonArray->AppendL(TPoint(40,45)); - TFontSpec fspec(KMonospaceTestFontTypefaceName,KMaxFontSize); - User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)iFont,fspec)); - } - -void CGdiSetOrigin::PreTestSetupL(const TRect &, TInt ) - { - } - -void CGdiSetOrigin::DrawIt(const TPoint &aOffset) - { - iGdi->DrawLine(TPoint(10,10)+aOffset,TPoint(20,30)+aOffset); - iGdi->DrawLineBy(TPoint(-10,5)); - iGdi->DrawLineTo(TPoint(20,5)+aOffset); - iGdi->MoveTo(TPoint(20,10)+aOffset); - iGdi->DrawLineTo(TPoint(30,15)+aOffset); - iGdi->MoveBy(TPoint(-10,2)); - iGdi->DrawLineBy(TPoint(10,0)); - iGdi->UseFont(iFont); - iGdi->DrawText(_L("Set Origin Test"),TPoint(40,20)+aOffset); - iGdi->DiscardFont(); - iGdi->DrawRect(TRect(TPoint(10,45)+aOffset,TPoint(20,55)+aOffset)); - iGdi->DrawRoundRect(TRect(TPoint(21,45)+aOffset,TPoint(30,55)+aOffset),TSize(3,2)); - iGdi->DrawEllipse(TRect(TPoint(31,45)+aOffset,TPoint(40,55)+aOffset)); - TInt index; - for(index=0;indexCount();index++) - (*iPolylineArray)[index]+=aOffset; - iGdi->DrawPolyLine(iPolylineArray); - for(index=0;indexCount();index++) - (*iPolylineArray)[index]-=aOffset; - for(index=0;indexCount();index++) - (*iPolygonArray)[index]+=aOffset; - iGdi->SetBrushStyle(CGraphicsContext::ESolidBrush); - User::LeaveIfError(iGdi->DrawPolygon(iPolygonArray,CGraphicsContext::EAlternate)); //Doesn't cause any harm if it leaves - for(index=0;indexCount();index++) - (*iPolygonArray)[index]-=aOffset; - } - -void CGdiSetOrigin::BaseTest(const TRect &aRect, TInt) - { - DrawIt(aRect.iTl); - } - -void CGdiSetOrigin::TheTest(const TRect &aRect, TInt) - { - iGdi->SetOrigin(aRect.iTl); - DrawIt(TPoint(0,0)); - } - -// -// Draw text // -// - -CGdiDrawText::~CGdiDrawText() - { - TheClient->iScreen->ReleaseFont(iFont); - } - -TInt CGdiDrawText::Count(TBool ) - { - return(1); - } - -void CGdiDrawText::ConstructL(TInt) - { - TFontSpec fspec(KMonospaceTestFontTypefaceName,KMaxFontSize); - User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)iFont,fspec)); - TInt index; - for(index=0;indexTextWidthInPixels(iBigBuffer); - for(index=0;indexTextWidthInPixels(iBigBuffer.Left(index)); - TInt rLen=iFont->TextWidthInPixels(iBigBuffer.Right(characters-index)); - TBool result = IsLengthEqual(lLen,rLen,bbLen); - iGdiTest->TEST(result); - if (!result) - { - _LIT(KLog,"Font width metrics error, Width(%dchars)=%d, Width(%dchars)=%d, Width(%dchars)=%d"); - iGdiTest->LOG_MESSAGE7(KLog,index,lLen,characters-index,rLen,characters,bbLen); - } - } - } - -void CGdiDrawText::PreTestSetupL(const TRect&,TInt) - {} - -void CGdiDrawText::BaseTest(const TRect& aRect,TInt) - { - TInt bbLen=iFont->TextWidthInPixels(iBigBuffer); - TInt fAscent=iFont->AscentInPixels(); - TInt fHeight=iFont->HeightInPixels(); - iGdi->UseFont(iFont); -// - iGdi->DrawText(_L("Hello"), TPoint(aRect.iTl.iX, aRect.iTl.iY+fAscent)); - TInt missingChars=iFont->TextCount(iBigBuffer,bbLen-aRect.iBr.iX)-1; // -1 so one off screen char is drawn to handle overhang - if (missingChars>=0) - { - TPtrC bbb=iBigBuffer.Right(iBigBuffer.Length()-missingChars); - TInt lLen=iFont->TextWidthInPixels(iBigBuffer.Left(missingChars)); - TInt rLen=iFont->TextWidthInPixels(bbb); - TBool result = IsLengthEqual(lLen,rLen,bbLen); - iGdiTest->TEST(result); - if (!result) - { - _LIT(KLog,"Font width metrics error, missingChars=%d %d+%d=%d"); - iGdiTest->LOG_MESSAGE5(KLog,missingChars,lLen,rLen,bbLen); - } - iGdi->DrawText(bbb,TPoint(aRect.iBr.iX-rLen,aRect.iTl.iY+fAscent+fHeight)); - } - iGdi->DiscardFont(); - } - -void CGdiDrawText::TheTest(const TRect& aRect,TInt) - { - TInt bbLen=iFont->TextWidthInPixels(iBigBuffer); - TInt fAscent=iFont->AscentInPixels(); - TInt fHeight=iFont->HeightInPixels(); - iGdi->UseFont(iFont); -// - iGdi->DrawText(_L("Hello"), TPoint(aRect.iTl.iX, aRect.iTl.iY+fAscent)); - iGdi->DrawText(iBigBuffer,TPoint(aRect.iBr.iX-bbLen,aRect.iTl.iY+fAscent+fHeight)); - iGdi->DiscardFont(); - } - -// -// Draw vertical text // -// - -CGdiDrawVertText::~CGdiDrawVertText() - { - TheClient->iScreen->ReleaseFont(iFont); - } - -TInt CGdiDrawVertText::Count(TBool ) - { - return(1); - } - -void CGdiDrawVertText::ConstructL(TInt) - { - TFontSpec fspec(KMonospaceTestFontTypefaceName,KMaxFontSize); - User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)iFont,fspec)); - TInt index; - for(index=0;indexTextWidthInPixels(iBigBuffer); - for(index=0;indexTextWidthInPixels(iBigBuffer.Left(index)); - TInt rLen=iFont->TextWidthInPixels(iBigBuffer.Right(iBigBuffer.Length()-index)); - TBool result = IsLengthEqual(lLen,rLen,bbLen); - iGdiTest->TEST(result); - if (!result) - iGdiTest->INFO_PRINTF3(_L("iFont->TextWidthInPixels(iBigBuffer) return value - Expected: %d, Actual: %d"), lLen+rLen, bbLen); - } - } - -void CGdiDrawVertText::PreTestSetupL(const TRect &, TInt ) - { - } - -void CGdiDrawVertText::BaseTest(const TRect &aRect, TInt) - { - TInt bbLen=iFont->TextWidthInPixels(iBigBuffer); - TInt fAscent=iFont->AscentInPixels(); - TInt fHeight=iFont->HeightInPixels(); - iGdi->UseFont(iFont); -// - TInt tlen=iFont->TextWidthInPixels(_L("Hello")); - iGdi->DrawTextVertical(_L("Hello"), TPoint(aRect.iTl.iX+fAscent, aRect.iTl.iY+tlen), ETrue); - iGdi->DrawTextVertical(_L("Hello"), TPoint(aRect.iBr.iX-fAscent, aRect.iTl.iY), EFalse); - TInt missingChars=iFont->TextCount(iBigBuffer,bbLen-aRect.iBr.iY)-1; // -1 so one off screen char is drawn to handle overhang - if (missingChars>=0) - { - TPtrC bbb=iBigBuffer.Right(iBigBuffer.Length()-missingChars); - TInt lLen=iFont->TextWidthInPixels(iBigBuffer.Left(missingChars)); - TInt rLen=iFont->TextWidthInPixels(bbb); - TBool result = IsLengthEqual(lLen,rLen,bbLen); - iGdiTest->TEST(result); - if (!result) - iGdiTest->INFO_PRINTF3(_L("iFont->TextWidthInPixels(iBigBuffer) return value - Expected: %d, Actual: %d"), lLen+rLen, bbLen); - - iGdi->DrawTextVertical(bbb,TPoint(aRect.iTl.iX+fHeight-fAscent+fHeight,aRect.iBr.iY-rLen),EFalse); - } - iGdi->DiscardFont(); - } - -void CGdiDrawVertText::TheTest(const TRect &aRect, TInt) - { - TInt bbLen=iFont->TextWidthInPixels(iBigBuffer); - TInt fAscent=iFont->AscentInPixels(); - TInt fHeight=iFont->HeightInPixels(); - iGdi->UseFont(iFont); -// - TInt tlen=iFont->TextWidthInPixels(_L("Hello")); - iGdi->DrawTextVertical(_L("Hello"), TPoint(aRect.iTl.iX+fAscent, aRect.iTl.iY+tlen), ETrue); - iGdi->DrawTextVertical(_L("Hello"), TPoint(aRect.iBr.iX-fAscent, aRect.iTl.iY), EFalse); - iGdi->DrawTextVertical(iBigBuffer,TPoint(aRect.iTl.iX+fHeight-fAscent+fHeight,aRect.iBr.iY-bbLen),EFalse); - iGdi->DiscardFont(); - } - -// -// Draw Justified text // -// - -// DEF107985 The test for JustifiedText has been removed as it was a bad/useless test. The original test was -// broken after it was migrated to TEF TGdi test. It was not worth fixing as the purpose of test was not clear, -// and fixing it basically required rewriting the whole test. -// - - -// -// Box text // -// - -CGdiBoxText::~CGdiBoxText() - { - TheClient->iScreen->ReleaseFont(iFont); - } - -TInt CGdiBoxText::Count(TBool ) - { - return(1); - } - -void CGdiBoxText::ConstructL(TInt) - { - TFontSpec fspec(KMonospaceTestFontTypefaceName,KMaxFontSize); - User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)iFont,fspec)); - for(TInt index=0;indexTextWidthInPixels(iBigBuffer); - } - -void CGdiBoxText::PreTestSetupL(const TRect &, TInt ) - { - } - -void CGdiBoxText::BaseTest(const TRect &aRect, TInt) - { - TInt rWid=aRect.iBr.iX-aRect.iTl.iX; - TInt fAscent=iFont->AscentInPixels(); - TInt fHeight=iFont->HeightInPixels(); - iGdi->UseFont(iFont); - iGdi->SetBrushStyle(CGraphicsContext::ESolidBrush); -// - TRect rect(aRect); - rect.iBr.iY=rect.iTl.iY+fHeight; -// - TInt missingChars=iFont->TextCount(iBigBuffer,iBbLen-rWid); - TPtrC bbb=iBigBuffer.Right(iBigBuffer.Length()-missingChars); - TInt lLen=iFont->TextWidthInPixels(iBigBuffer.Left(missingChars)); - TInt rLen=iFont->TextWidthInPixels(bbb); - TBool result = IsLengthEqual(lLen,rLen,iBbLen); - iGdiTest->TEST(result); - if (!result) - iGdiTest->INFO_PRINTF3(_L("(lLen+rLen)==iBbLen return value - Expected: %d, Actual: %d"), lLen+rLen, iBbLen); - - iGdi->DrawText(bbb, rect, fAscent,CGraphicsContext::ELeft, rWid-rLen); -// - rect.Move(TPoint(0,fHeight)); - iGdi->DrawText(iBigBuffer, rect, fAscent,CGraphicsContext::ELeft, 0); -// - TBuf<10> buf2(_L("1234567890")); - rect.Move(TPoint(0,fHeight)); - iGdi->DrawText(buf2,rect,fAscent,CGraphicsContext::ERight,rect.Width()-iFont->TextWidthInPixels(buf2)); - } - -void CGdiBoxText::TheTest(const TRect &aRect, TInt) - { - TInt rWid=aRect.iBr.iX-aRect.iTl.iX; - TInt fAscent=iFont->AscentInPixels(); - TInt fHeight=iFont->HeightInPixels(); - iGdi->UseFont(iFont); - iGdi->SetBrushStyle(CGraphicsContext::ESolidBrush); - TRect rect(aRect); - rect.iBr.iY=rect.iTl.iY+fHeight; -// - iGdi->DrawText(iBigBuffer, rect, fAscent, CGraphicsContext::ELeft, rWid-iBbLen); -// - rect.Move(TPoint(0,fHeight)); - iGdi->Clear(rect); - iGdi->SetClippingRegion(TRegionFix<1>(rect)); - iGdi->DrawText(iBigBuffer, rect.iTl+TPoint(0,fAscent)); - TBuf<10> buf2(_L("1234567890")); - rect.Move(TPoint(0,fHeight)); - iGdi->CancelClippingRegion(); - iGdi->DrawText(buf2,rect,fAscent); - } - -// -// Vert Box text // -// - -CGdiVertBoxText::~CGdiVertBoxText() - { - TheClient->iScreen->ReleaseFont(iFont); - } - -TInt CGdiVertBoxText::Count(TBool ) - { - return(1); - } - -void CGdiVertBoxText::ConstructL(TInt) - { - TFontSpec fspec(KMonospaceTestFontTypefaceName,KMaxFontSize); - User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)iFont,fspec)); - for(TInt index=0;indexTextWidthInPixels(iBigBuffer); - } - -void CGdiVertBoxText::PreTestSetupL(const TRect &, TInt ) - { - } - -void CGdiVertBoxText::BaseTest(const TRect &aRect, TInt) - { - TInt rWid=aRect.iBr.iY-aRect.iTl.iY; - TInt fAscent=iFont->AscentInPixels(); - TInt fHeight=iFont->HeightInPixels(); - iGdi->UseFont(iFont); - iGdi->SetBrushStyle(CGraphicsContext::ESolidBrush); -// - TRect rect(aRect); - rect.iBr.iX=rect.iTl.iX+fHeight; -// - TInt missingChars=iFont->TextCount(iBigBuffer,iBbLen-rWid); - TPtrC bbb=iBigBuffer.Right(iBigBuffer.Length()-missingChars+1); - TInt lLen=iFont->TextWidthInPixels(iBigBuffer.Left(missingChars-1)); - TInt rLen=iFont->TextWidthInPixels(bbb); - TBool result = IsLengthEqual(lLen,rLen,iBbLen); - iGdiTest->TEST(result); - if (!result) - iGdiTest->INFO_PRINTF3(_L("(lLen+rLen)==iBbLen return value - Expected: %d, Actual: %d"), lLen+rLen, iBbLen); - - iGdi->DrawTextVertical(bbb, rect, fAscent, ETrue,CGraphicsContext::ELeft, rWid-rLen); -// - rect.iTl.iX=rect.iBr.iX; - rect.iBr.iX=rect.iTl.iX+fHeight; - iGdi->DrawTextVertical(iBigBuffer, rect, fAscent, ETrue,CGraphicsContext::ELeft, 0); - } - -void CGdiVertBoxText::TheTest(const TRect &aRect, TInt) - { - TInt rWid=aRect.iBr.iY-aRect.iTl.iY; - TInt fAscent=iFont->AscentInPixels(); - TInt fHeight=iFont->HeightInPixels(); - iGdi->UseFont(iFont); - iGdi->SetBrushStyle(CGraphicsContext::ESolidBrush); - TRect rect(aRect); - rect.iBr.iX=rect.iTl.iX+fHeight; -// - iGdi->DrawTextVertical(iBigBuffer, rect, fAscent, ETrue, CGraphicsContext::ELeft, rWid-iBbLen); -// - rect.iTl.iX=rect.iBr.iX; - rect.iBr.iX=rect.iTl.iX+fHeight; - iGdi->Clear(rect); - iGdi->SetClippingRegion(TRegionFix<1>(rect)); - iGdi->DrawTextVertical(iBigBuffer, TPoint(rect.iTl.iX+fAscent,rect.iBr.iY), ETrue); - } - - -// -// -CGdiBlitMasked::~CGdiBlitMasked() - { - for(TInt index=0;indexCreateContext(aGc)); -// - aGc->SetBrushColor(TRgb(128,128,128)); - aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - aGc->SetPenStyle(CGraphicsContext::ENullPen); - aGc->DrawRect(TRect(aBitmap->SizeInPixels())); - aGc->SetPenStyle(CGraphicsContext::ESolidPen); - for(TInt index=(-aSize.iHeight);indexDrawLine(TPoint(index,0),TPoint(index+aSize.iHeight,aSize.iHeight)); - aGc->DrawLine(TPoint(index,aSize.iHeight),TPoint(index+aSize.iHeight,0)); - } - } - -void CGdiBlitMasked::createTestBitmapL(CFbsBitmap *&aBitmap, const TSize &aSize) - { - CFbsBitGc *gc=NULL; - CFbsBitmapDevice *device=NULL; - aBitmap=new(ELeave) CFbsBitmap(); - User::LeaveIfError(aBitmap->Create(aSize,EGray16)); - TRAPD(err,doCreateTestBitmapL(aBitmap, gc, device, aSize)); - delete gc; - delete device; - User::LeaveIfError(err); - } - -void CGdiBlitMasked::ConstructL(TInt) - { - TSize max(0,0); - for(TInt index=0;indexLoad(TAUTO_BITMAP_NAME,2+index)); - TSize size=iMask[index]->SizeInPixels(); - if (max.iWidthCreate(max,EGray16)); - iScratchDevice=CFbsBitmapDevice::NewL(iScratch); - User::LeaveIfError(iScratchDevice->CreateContext(iScratchGc)); - - iScratchMask=new(ELeave) CFbsBitmap(); - User::LeaveIfError(iScratchMask->Create(max,EGray16)); - iScratchMaskDevice=CFbsBitmapDevice::NewL(iScratchMask); - User::LeaveIfError(iScratchMaskDevice->CreateContext(iScratchMaskGc)); -// - createTestBitmapL(iBitmap, max); - } - -void CGdiBlitMasked::PreTestSetupL(const TRect &, TInt aCount) - { - iInvertMask=aCount&0x1; - aCount>>=1; - iCurrMask= iMask[aCount%ENumMasks]; - iDrawMode=CGraphicsContext::EDrawModePEN; - } - -void CGdiBlitMasked::BaseTest(const TRect &aRect, TInt) - { -// needs re-writing to emulate tiling of the source rect - if (!aRect.Intersects(TRect(BaseWin->Size()))) - return; - TSize size(aRect.Size()); - TSize bitSize=iBitmap->SizeInPixels(); - if (size.iWidth>bitSize.iWidth) - size.iWidth=bitSize.iWidth; - if (size.iHeight>bitSize.iHeight) - size.iHeight=bitSize.iHeight; -// -// Set up the scratch mask as a black and white bitmap containing the mask to blit -// The mask pattern is replicated all over the scratchmask bitmap -// - iScratchMaskGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - iScratchMaskGc->SetPenStyle(CGraphicsContext::ENullPen); - iScratchMaskGc->SetBrushColor(TRgb(0,0,0)); - iScratchMaskGc->DrawRect(TRect(iScratchMask->SizeInPixels())); - iScratchMaskGc->SetPenColor(TRgb(255,255,255)); - iScratchMaskGc->SetPenStyle(CGraphicsContext::ESolidPen); - TSize maskSize(iCurrMask->SizeInPixels()); - TPoint pos; - TRgb *rgbBuf=(TRgb *)User::AllocL(maskSize.iWidth*sizeof(TRgb)); //Doesn't do any harm if it leaves - for(pos.iY=0;pos.iYGetScanLine(ptr, pos, maskSize.iWidth, ERgb); - for(TInt index=0;indexSetPenColor(rgbBuf[index]); -// if ((isLow && !iLowCutOff) || (!isLow && iLowCutOff)) - iScratchMaskGc->Plot(TPoint(index,pos.iY)); - } - } - User::Free(rgbBuf); - - for(pos.iY=0;pos.iYCopyRect(pos, TRect(maskSize)); -// -// Blit this to the screen in ANDNOT mode to clear all the pixels we want the mask blit to draw to -// - iGdi->SetDrawMode(CGraphicsContext::EDrawModeANDNOT); - iGdi->BitBlt(aRect.iTl, iScratchMask, TRect(size)); -// -// Copy the test bitmap to the scratch bitmap then use the scratch mask to clear all the bits -// that should masked out of the draw to the screen -// - iScratchGc->SetDrawMode(CGraphicsContext::EDrawModePEN); - iScratchGc->BitBlt(TPoint(0,0), iBitmap); - iScratchGc->SetDrawMode(CGraphicsContext::EDrawModeAND); - iScratchGc->BitBlt(TPoint(0,0), iScratchMask); -// -// Now copy the scratch bitmap to the screen in OR mode to get the final result -// - iGdi->SetDrawMode(CGraphicsContext::EDrawModeOR); - iGdi->BitBlt(aRect.iTl, iScratch, TRect(size)); - } - -void CGdiBlitMasked::TheTest(const TRect &aRect, TInt) - { - iGdi->BitBltMasked(aRect.iTl,iBitmap,TRect((aRect.iBr-aRect.iTl).AsSize()), - iCurrMask,iInvertMask); - } -// -// - -CTGdi::CTGdi(CTestStep* aStep) : CTWsGraphicsBase(aStep), iGdiTest (NULL), iTextOffsetX(10),iTextOffsetY(10) - { - } - -void CTGdi::ConstructL() - { - iWinSize=TestWin->Size(); - } - -TSize CTGdi::WinSize() - { - return(iWinSize); - } - -void CTGdi::DoGdiTestL(const TRect &aRect, TInt aNum) - { -// - iGdiTest->PreTestSetupL(aRect,aNum); -// - BaseWin->Win()->Invalidate(); - BaseWin->Win()->BeginRedraw(); - TheGc->Activate(*BaseWin->Win()); - iTest->DrawTestBackground(EFalse,BaseWin->Size()); - iGdiTest->BaseTest(aRect,aNum); - TheGc->Deactivate(); - BaseWin->Win()->EndRedraw(); -// - TestWin->Win()->Invalidate(); - TestWin->Win()->BeginRedraw(); - TheGc->Activate(*TestWin->Win()); - iTest->DrawTestBackground(EFalse,TestWin->Size()); - iGdiTest->TheTest(aRect,aNum); - TheGc->Deactivate(); - TestWin->Win()->EndRedraw(); -// - TheClient->iWs.Flush(); - TheClient->WaitForRedrawsToFinish(); - TheClient->iWs.Finish(); -// - _LIT(KLog,"GDI Substate=%d test=%d rect=(%d,%d,%d,%d) "); - TBuf<64> buf; - buf.Format(KLog,iSubState,aNum,aRect.iTl.iX,aRect.iTl.iY,aRect.iBr.iX,aRect.iBr.iY); - iTestPassing=CompareWindows(buf); - } - -void CTGdi::GdiTestL(CGdiTestLowLevel *aTest) - { - TTestRects::ResetSeed(); - iTestPassing=ETrue; - iGdiTest=aTest; - iGdiTest->SetGdiTest(this); - iGdiTest->AssignGdi(TheGc); - iGdiTest->ConstructL(iTest->iTestRects.Count1()); - TInt index; - TInt index2; - for(index=0; iTestPassing && indexiTestRects.Count2(); ++index) - { - TInt max=iGdiTest->Count(indexiTestRects.Count1()); - TRect rect=iTest->iTestRects[index]; - #if defined(LOGGING) - _LIT(KLog1,"Testing rectangle %d (%d,%d,%d,%d) 1st pass"); - LOG_MESSAGE6(KLog1,index,rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY); - #endif - for(index2=0; iTestPassing && index2iTestRects.Count3(); index++) - { - TRect rect=iTest->iTestRects[index]; - #if defined(LOGGING) - _LIT(KLog2,"Testing rectangle %d (%d,%d,%d,%d) 2nd pass"); - LOG_MESSAGE6(KLog2,index,rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY); - #endif - DoGdiTestL(rect,0); - } - delete iGdiTest; - iGdiTest=NULL; - } - -void CTGdi::NonDrawing() -// -// Test all non-drawing GDI functions -// - { - TDisplayMode mode=TheClient->iScreen->DisplayMode(); - TEST((mode!=ERgb) && (mode!=ENone)); - - RWsSession session; - TInt res = session.Connect(); - TEST(res == KErrNone); - - CArrayFixFlat* modeList= new CArrayFixFlat (15); - if(!modeList) - return; - -#if defined(SYMBIAN_GRAPHICS_GCE) - res = session.GetColorModeList(iTest->iScreenNumber, modeList); -#else - res = session.GetColorModeList(modeList); -#endif //SYMBIAN_GRAPHICS_GCE - session.Close(); - TEST(res == KErrNone); - if(res != KErrNone) - { - modeList->Reset(); - delete modeList; - return; - } - - TBool found = EFalse; - for(TInt ii = 0; ii < modeList->Count() && !found; ii++) - { - TDisplayMode mode1 = (TDisplayMode) ((*modeList)[ii]); - if(mode == mode1) - { - found = ETrue; - } - } - modeList->Reset(); - delete modeList; - - TEST(found); - } - -// -// Auxiliary Fn for Test Case ID CTGdi_TestDefetct_DEF045746 -// This method draws the text represented by aText parameter on the window -// passed to it. -// -void CTGdi::DrawTextOnWindow(const TDesC& aText,CTWin* aWin) - { - aWin->Win()->BeginRedraw(); - TheGc->Activate(*aWin->Win()); - TheGc->Device()->GetNearestFontToDesignHeightInTwips(iFont,TFontSpec(_L("Arial"),250)); - TheGc->UseFont(iFont); - TheGc->Clear(); - TheGc->DrawRect(TRect(aWin->Win()->Size())); - TheGc->DrawText(aText,TPoint(iTextOffsetX,iTextOffsetY)); - TheGc->Device()->ReleaseFont(iFont); - TheGc->Deactivate(); - aWin->Win()->EndRedraw(); - } - - -void CTGdi::TestDefetct_DEF045746L() - { - _LIT(KString,"This is a test window for the defect fix DEF045746 \ - propagated from Opera browser. Most window graphics context drawing\ - functions map to equivalent CFbsBitGc functions they are implemented\ - on the screen with any co-ordinates being relative to the top left\ - corner of the window. However extra clipping is applied. The drawing\ - will always be clipped to the visible part of the window, in addition\ - it will be clipped to the non-invalid part if you are not doing a\ - redraw and to the region being validated if you are doing a redraw."); - - TPtrC TestText(KString().Ptr(),100); - TPtrC LargeText(KString().Ptr()); - TPtrC ShortText(KString().Ptr(),200); - - TSize scrSize=TheClient->iScreen->SizeInPixels(); - TSize winSize; - const TInt windowGap=5; - winSize.SetSize(scrSize.iWidth -2* windowGap,scrSize.iHeight/2 - windowGap); - - iWin=new(ELeave) CTestWindow(TRgb(0,0,0)); - iWin->ConstructL(TPoint(5,5),TSize(winSize),TheClient->iGroup,*TheClient->iGc); - CTestWindow* expectWin= new(ELeave) CTestWindow(TRgb(0,0,0)); - expectWin->ConstructL(TPoint(5,scrSize.iHeight/2 + windowGap),TSize(winSize),TheClient->iGroup,*TheClient->iGc); - DrawTextOnWindow(ShortText,iWin); - DrawTextOnWindow(TestText,expectWin); - TInt fHeight=iFont->HeightInPixels();//Used to compare only pixels where text is drawn - TRect iRect=winSize; - iRect.iTl.iX=iTextOffsetX; - iRect.iTl.iY=iTextOffsetY; - iRect.iBr.iY=iTextOffsetY+fHeight; - CheckRect(iWin,expectWin,iRect,_L("TestDefetct_DEF045746L A")); - iWin->Invalidate(); - DrawTextOnWindow(LargeText,iWin); - CheckRect(iWin,expectWin,iRect,_L("TestDefetct_DEF045746L B")); - delete iWin; - iWin=NULL; - delete expectWin; - expectWin=NULL; - } - -void CTGdi::RunTestCaseL(TInt /*aCurTestCase*/) - { - //_LIT(KTest1,"NonDrawing"); this test is not running - _LIT(KTest2,"DEF045746"); - _LIT(KTest3,"Drawing Tests"); - ((CTGdiStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); - static TTime startTime; - switch(++iTest->iState) - { -/** -@SYMTestCaseID GRAPHICS-WSERV-0262 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test all non-drawing GDI functions - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Check all non-drawing GDI functions operate correctly - -@SYMTestExpectedResults Non-drawing GDI functions operate correctly -*/ - case 1: - // start time log - startTime.HomeTime(); - ((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0262")); - //iTest->LogSubTest(KTest1); - //PeterI this tests whether the display mode is EGray4 or EGray16. - //The actual display mode is EColor16MU so this test will always fail - //NonDrawingL(); - break; -/** - * @SYMTestCaseID GRAPHICS-WSERV-0263 - * - * @SYMPREQ DEF045746 - * - * @SYMTestCaseDesc Test defect fix for DEF045746 - * - * @SYMTestPriority High - * - * @SYMTestStatus Implemented - * - * @SYMTestActions The method tests CWindowGc::DrawText().The test is carried - * out by writing small & very large strings to the window graphic context. - * - * @SYMTestExpectedResults The window with large / small strings written is - * compared with an expected result window. In both the cases strings should - * be displayed. - * - */ - case 2: - ((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0263")); - iTest->LogSubTest(KTest2); - TestDefetct_DEF045746L(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0264 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test all drawing GDI functions - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Check all drawing GDI functions operate correctly - -@SYMTestExpectedResults Drawing GDI functions operate correctly -*/ - case 3: - { - ((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0264")); - iTest->LogSubTest(KTest3); - iSubState = 0; - TheClient->WaitForRedrawsToFinish(); //Just in case the two test windows have any invalid areas - TInt numTests = sizeof(GdiTestFuncs) / sizeof(GdiTestFuncs[0]); - while (iSubState < numTests) - { - LOG_MESSAGE(TPtrC(GdiTestFuncs[iSubState].txt)); - GdiTestL((*GdiTestFuncs[iSubState].func)()); - iSubState++; - } - } - break; - default: - ((CTGdiStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - ((CTGdiStep*)iStep)->CloseTMSGraphicsStep(); - TestComplete(); - // log time and print duration - TTime endTime; - endTime.HomeTime(); - TInt64 duration = endTime.MicroSecondsFrom(startTime).Int64(); - float time = (float) I64LOW(duration) / 1000.0f; - _LIT(KDuration,"Total test duration is %f millisec"); - RDebug::Print(KDuration, time); - break; - } - ((CTGdiStep*)iStep)->RecordTestResultL(); - } - -CGdiTestLowLevel *SetOriginTest() - { - return(new(ELeave) CGdiSetOrigin()); - } - -CGdiTestLowLevel *PolyLineTest() - { - return(new(ELeave) CGdiPolyLine()); - } - -CGdiTestLowLevel *PolygonTest() - { - return(new(ELeave) CGdiPolygon()); - } - -CGdiTestLowLevel *BlitMaskedTest() - { - return(new(ELeave) CGdiBlitMasked()); - } - -CGdiTestLowLevel *DrawArcTest() - { - return(new(ELeave) CGdiDrawArc()); - } - -CGdiTestLowLevel *DrawPieTest() - { - return(new(ELeave) CGdiDrawPie()); - } - -CGdiTestLowLevel *DrawRoundRectTest() - { - return(new(ELeave) CGdiDrawRoundRect()); - } - -CGdiTestLowLevel *BoxTextTest() - { - return(new(ELeave) CGdiBoxText()); - } - -CGdiTestLowLevel *VertTextTest() - { - return(new(ELeave) CGdiDrawVertText()); - } - -CGdiTestLowLevel *VertBoxTextTest() - { - return(new(ELeave) CGdiVertBoxText()); - } - -CGdiTestLowLevel *WideLineTest() - { - return(new(ELeave) CGdiWideLine()); - } - -CGdiTestLowLevel *DrawTextTest() - { - return(new(ELeave) CGdiDrawText()); - } - -CGdiTestLowLevel *DrawRectTest() - { - return(new(ELeave) CGdiDrawRect()); - } - -__WS_CONSTRUCT_STEP__(Gdi) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TGDI.H --- a/windowing/windowserver/tauto/TGDI.H Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,355 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef __TGDI_H__ -#define __TGDI_H__ - -#include -#include -#include "../tlib/testbase.h" -#include -#include "AUTO.H" -#include "TGraphicsHarness.h" - -class CGdiTestLowLevel; - -CGdiTestLowLevel *SetOriginTest(); -CGdiTestLowLevel *PolyLineTest(); -CGdiTestLowLevel *PolygonTest(); -CGdiTestLowLevel *BlitMaskedTest(); -CGdiTestLowLevel *DrawArcTest(); -CGdiTestLowLevel *DrawPieTest(); -CGdiTestLowLevel *DrawRoundRectTest(); -CGdiTestLowLevel *BoxTextTest(); -CGdiTestLowLevel *VertTextTest(); -CGdiTestLowLevel *JustifiedTextTest(); -CGdiTestLowLevel *VertBoxTextTest(); -CGdiTestLowLevel *WideLineTest(); -CGdiTestLowLevel *DrawTextTest(); -CGdiTestLowLevel *DrawRectTest(); - -class CTGdi; -class CGdiTestLowLevel : public CBase -// -// BaseTest uses code that is assumed to be good to draw to one window -// TheTest uses the code beng tested to draw a matching pattern -// - { -public: - void AssignGdi(CWindowGc *aGc); - void SetGdiTest(CTGdi *aGdiTest); - virtual void PreTestSetupL(const TRect &aRect, TInt aCount); - virtual void BaseTest(const TRect &aRect, TInt aCount)=0; - virtual void TheTest(const TRect &aRect, TInt aCount)=0; - virtual void ConstructL(TInt aNumOfRects); - virtual TInt Count(TBool aMainTests)=0; -protected: - CWindowGc *iGdi; - CTGdi *iGdiTest; - }; - -class CGdiRect : public CGdiTestLowLevel - { -public: - void PreTestSetupL(const TRect &aRect, TInt aCount); - void ConstructL(TInt aNumOfRects); - TInt Count(TBool aMainTests); -protected: - TRgb iBrushCol; - TRgb iPenCol; - }; - - -class CGdiDrawRect : public CGdiRect - { -public: - TInt Count(TBool aMainTests); - void BaseTest(const TRect &aRect, TInt aCount); - void TheTest(const TRect &aRect, TInt aCount); - }; - -class CGdiDrawRoundRect : public CGdiRect - { -public: - TInt Count(TBool aMainTests); - void BaseTest(const TRect &aRect, TInt aCount); - void TheTest(const TRect &aRect, TInt aCount); - }; - -class CGdiDrawACP : public CGdiTestLowLevel - { -public: - void PreTestSetupL(const TRect &aRect, TInt aCount); - void ConstructL(TInt aNumOfRects); - TInt Count(TBool aMainTests); -protected: - TRgb iBrushCol; - TRgb iPenCol; - }; - -class CGdiDrawArc : public CGdiDrawACP - { -public: - void BaseTest(const TRect &aRect, TInt aCount); - void TheTest(const TRect &aRect, TInt aCount); - }; - -class CGdiDrawPie : public CGdiDrawACP - { -public: - void BaseTest(const TRect &aRect, TInt aCount); - void TheTest(const TRect &aRect, TInt aCount); - }; - -class CGdiPolyLine : public CGdiTestLowLevel - { -public: - CGdiPolyLine(); - void PreTestSetupL(const TRect &aRect, TInt aCount); - void ConstructL(TInt aNumOfRects); - TInt Count(TBool aMainTests); - void BaseTest(const TRect &aRect, TInt aCount); - void TheTest(const TRect &aRect, TInt aCount); -private: - CArrayFixSeg iPnts; - }; - -class CGdiPolygon : public CGdiTestLowLevel - { -private: - enum {KMaxPolygonPoints=100}; - enum {KPolygonStep=4}; -public: - CGdiPolygon(); - void PreTestSetupL(const TRect &aRect, TInt aCount); - void ConstructL(TInt aNumOfRects); - TInt Count(TBool aMainTests); - void BaseTest(const TRect &aRect, TInt aCount); - void TheTest(const TRect &aRect, TInt aCount); -private: - CArrayFixSeg iPnts; - }; - -class CGdiWideLine : public CGdiTestLowLevel - { -private: - enum TMaxWidths { - EMainNumWidths=16, - EMinorNumWidths=4}; -public: - void PreTestSetupL(const TRect &aRect, TInt aCount); - void BaseTest(const TRect &aRect, TInt aCount); - void TheTest(const TRect &aRect, TInt aCount); - void ConstructL(TInt aNumOfRects); - TInt Count(TBool aMainTests); -private: - TInt iWidth; - }; - -class CGdiSetOrigin : public CGdiTestLowLevel - { -public: - ~CGdiSetOrigin(); - void PreTestSetupL(const TRect &aRect, TInt aCount); - void DrawIt(const TPoint &aOffset); - void BaseTest(const TRect &aRect, TInt aCount); - void TheTest(const TRect &aRect, TInt aCount); - void ConstructL(TInt aNumOfRects); - TInt Count(TBool aMainTests); -private: - CFbsFont *iFont; - CArrayFixFlat *iPolylineArray; - CArrayFixFlat *iPolygonArray; - }; - -class CGdiDrawText : public CGdiTestLowLevel - { -public: - ~CGdiDrawText(); - void PreTestSetupL(const TRect &aRect, TInt aCount); - void BaseTest(const TRect &aRect, TInt aCount); - void TheTest(const TRect &aRect, TInt aCount); - void ConstructL(TInt aNumOfRects); - TInt Count(TBool aMainTests); -private: - TInt iWidth; - CFbsFont *iFont; - TBuf<0x400> iBigBuffer; - }; - -class CGdiDrawVertText : public CGdiTestLowLevel - { -public: - ~CGdiDrawVertText(); - void PreTestSetupL(const TRect &aRect, TInt aCount); - void BaseTest(const TRect &aRect, TInt aCount); - void TheTest(const TRect &aRect, TInt aCount); - void ConstructL(TInt aNumOfRects); - TInt Count(TBool aMainTests); -private: - TInt iWidth; - CFbsFont *iFont; - TBuf<0x400> iBigBuffer; - }; - -//class CGdiDrawJustifiedText : public CGdiTestLowLevel -//DEF107985 The test for JustifiedText has been removed as it was a bad/useless test - -class CGdiBoxText : public CGdiTestLowLevel - { -public: - ~CGdiBoxText(); - void PreTestSetupL(const TRect &aRect, TInt aCount); - void BaseTest(const TRect &aRect, TInt aCount); - void TheTest(const TRect &aRect, TInt aCount); - void ConstructL(TInt aNumOfRects); - TInt Count(TBool aMainTests); -private: - TInt iWidth; - TInt iBbLen; - CFbsFont *iFont; - TBuf<0x400> iBigBuffer; - }; - -class CGdiVertBoxText : public CGdiTestLowLevel - { -public: - ~CGdiVertBoxText(); - void PreTestSetupL(const TRect &aRect, TInt aCount); - void BaseTest(const TRect &aRect, TInt aCount); - void TheTest(const TRect &aRect, TInt aCount); - void ConstructL(TInt aNumOfRects); - TInt Count(TBool aMainTests); -private: - TInt iWidth; - TInt iBbLen; - CFbsFont *iFont; - TBuf<0x400> iBigBuffer; - }; -/* -class CGdiDottedLine : public CGdiTestLowLevel - { - enum TMaxPatterns { - EMainMaxPatterns=5, - EMinorMaxPatterns=3}; -public: - void SetGridRegion(TRegion &grid,const TRect &aRect); - void PreTestSetupL(const TRect &aRect, TInt aCount); - void BaseTest(const TRect &aRect, TInt aCount); - void TheTest(const TRect &aRect, TInt aCount); - void ConstructL(TInt aNumOfRects); - TInt Count(TBool aMainTests); -private: - TUint iPattern; - TInt iPattLen; - static TUint iPatterns[EMainMaxPatterns]; - static TInt iPattLens[EMainMaxPatterns]; - }; -TUint CGdiDottedLine::iPatterns[]={ - 0x55FF0033, - 0xFF00, - 0x1, - 0xFFFF, - 0xF0F0F0}; -TInt CGdiDottedLine::iPattLens[]={ - 32, - 16, - 2, - 32, - 24}; -*/ -class CTestWindow : public CBlankWindow - { -public: - CTestWindow(TRgb aCol); - ~CTestWindow(); - void ConstructL(TPoint aPos,TSize aSize,CTWinBase* aParent, CWindowGc& aGc ); - }; - -class CGdiBlitMasked: public CGdiTestLowLevel - { - enum TNumMasks {ENumMasks=2}; -public: - ~CGdiBlitMasked(); - void PreTestSetupL(const TRect &aRect, TInt aCount); - void BaseTest(const TRect &aRect, TInt aCount); - void TheTest(const TRect &aRect, TInt aCount); - void ConstructL(TInt aNumOfRects); - TInt Count(TBool aMainTests); -private: - void doCreateTestBitmapL(CFbsBitmap *aBitmap, CFbsBitGc *&aGc, CFbsBitmapDevice *&aDevice, const TSize &aSize); - void createTestBitmapL(CFbsBitmap *&aBitmap, const TSize &aSize); -private: - CFbsBitmap *iMask[ENumMasks]; - CFbsBitmap *iBitmap; -// - CFbsBitmap *iScratch; - CFbsBitmapDevice *iScratchDevice; - CFbsBitGc *iScratchGc; -// - CFbsBitmap *iScratchMask; - CFbsBitmapDevice *iScratchMaskDevice; - CFbsBitGc *iScratchMaskGc; -// - TBool iInvertMask; - CFbsBitmap *iCurrMask; - CGraphicsContext::TDrawMode iDrawMode; - }; - -class CTGdi : public CTWsGraphicsBase - { -public: - CTGdi(CTestStep* aStep); - void ConstructL(); - TSize WinSize(); - void GdiTestL(CGdiTestLowLevel *aTest); - void TestDefetct_DEF045746L(); - void DrawTextOnWindow(const TDesC& aText,CTWin* aWin); -protected: -//from CTGraphicsStep - virtual void RunTestCaseL(TInt aCurTestCase); -private: - void DoGdiTestL(const TRect &aRect, TInt aNum); - void NonDrawing(); -private: - TSize iWinSize; - TInt iSubState; - CGdiTestLowLevel *iGdiTest; - CTestWindow* iWin; - CFont* iFont; - TInt iTextOffsetX; - TInt iTextOffsetY; - TBool iTestPassing; - }; - -class CTGdiStep : public CTGraphicsStep - { -public: - CTGdiStep(); -protected: - //from CTGraphicsStep - virtual CTGraphicsBase* CreateTestL(); - }; - -_LIT(KTGdiStep,"TGdi"); - - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TGETPIXEL.CPP --- a/windowing/windowserver/tauto/TGETPIXEL.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,395 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// GETPIXEL.CPP -// Automatically test GetPixel -// -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include "TGETPIXEL.H" - -CTGetPixel::CTGetPixel(CTestStep* aStep): - CTWsGraphicsBase(aStep) - { - } - -CTGetPixel::~CTGetPixel() - { - iWindow.Close(); - User::Free(iRgbBuf); - } - -LOCAL_C TInt DoPanicTest(TInt aFunc, TAny *aScreenNumber) - { - RWsSession ws; - if (ws.Connect()==KErrNone) - switch(aFunc) - { - case 1: // Get pixels into a TPtr 1 pixel too small - { - CWsScreenDevice *screen = new(ELeave) CWsScreenDevice(ws); - User::LeaveIfError(screen->Construct((TInt)aScreenNumber)); - CFbsBitmap *bitmap=new(ELeave) CFbsBitmap(); - TInt bitWid=80; - TRgb *buf=NULL; - if (bitmap->Create(TSize(1,bitWid), EGray16)==KErrNone && (buf=(TRgb *)User::Alloc((bitWid-1)*sizeof(TRgb)))!=NULL) - { - TPtr8 desc((TUint8 *)buf,(bitWid-1)*sizeof(TRgb)); - screen->GetScanLine(desc,TPoint(0,0),bitWid, ERgb); - } - } - break; - } - return(EWsExitReasonBad); - } - -void CTGetPixel::ClearOutRedraws() -// This has been added because partial redraw store can be triggered to request a -// low priority redraw from the window even though in normal circumstances the window -// would not expect to receive any sort of redraw event. - { - iWindow.BeginRedraw(); - iWindow.EndRedraw(); - } - -void CTGetPixel::TestPanicsL() - { - if (!iTest->IsFullRomL()) - { - TEST(iTest->TestWsPanicL(DoPanicTest,EWservPanicInvalidParameter,1,(TAny*)iTest->iScreenNumber)); - } - } - -void CTGetPixel::DrawAndCheckLine(const TPoint &aPos,TInt aLen,TRgb aColor) - { - TheGc->Activate(iWindow); - TheGc->SetPenColor(aColor); - iWindow.BeginRedraw(TRect(aPos,TSize(aLen, 1))); - TheGc->DrawLine(aPos,aPos+TSize(aLen,0)); - iWindow.EndRedraw(); - TheGc->Deactivate(); - iRgbBuf=(TRgb *)User::ReAlloc(iRgbBuf,aLen*sizeof(TRgb)); - TPtr8 ptr((TUint8 *)iRgbBuf,aLen*sizeof(TRgb)); - TheClient->iScreen->GetScanLine(ptr, aPos+iWindow.InquireOffset(*TheClient->iGroup->WinTreeNode()), aLen, EColor16MA); - TRgb result(TRgb::Gray16(aColor.Gray16())); - if (TheClient->iScreen->DisplayMode()==EColor64K) - result=TRgb::Color64K(result.Color64K()); - for(TInt index=0;indexiWs; - TheGc->Activate(*BaseWin->Win()); - TheGc->Clear(); - TheGc->SetBrushColor(TRgb::Gray16(0)); - TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - TheGc->SetPenStyle(CGraphicsContext::ENullPen); - TheGc->DrawRect(TRect(iWinSize)); - TheGc->Deactivate(); - - iWindow.Construct(*TheClient->iGroup->GroupWin(),ENullWsHandle); - iWinSize=TSize(TheClient->iScreen->SizeInPixels()); - iWinSize.iWidth/=3; - iWinSize.iHeight/=3; - iWindow.SetRequiredDisplayMode(EGray16); - TheClient->iWs.Flush(); - iTest->DelayIfFullRomL(); // Need to wait for view server to mess around when display mode changed - TheClient->WaitForRedrawsToFinish();// otherwise it will stomp on top of our window invalidating it. - iWindow.SetExtent(TPoint(iWinSize.iWidth,iWinSize.iHeight),iWinSize); - iWindow.EnableRedrawStore(EFalse); // Otherwise drawing might trigger a redraw when purging redraw store - - iWindow.Activate(); - iWindow.BeginRedraw(); - iWindow.EndRedraw(); - - } - -void CTGetPixel::TestCheckRect() - { - TSize size(TheClient->iScreen->SizeInPixels()); - TEST(TheClient->iScreen->RectCompare(TRect(size),TRect(TPoint(iTest->StdTestWindowSize().iWidth>>1,0),iTest->StdTestWindowSize()))==EFalse); - } - -void CTGetPixel::DrawColorsL() - { - TPoint point(0,0); - TInt color=-1; - iWindow.BeginRedraw(); - FOREVER - { - TheGc->SetPenColor(TRgb::Color256(++color)); - TheGc->Plot(point); - if (color==255) - break; - if (++point.iX==iWinSize.iWidth) - { - point.iX=0; - if (++point.iY==iWinSize.iHeight) - break; - } - } - iWindow.EndRedraw(); - } - -void CTGetPixel::TestColors(CPalette* aPalette) - { - TInt numColors=iWinSize.iWidth; - TPtr8 ptr(REINTERPRET_CAST(TUint8*,iRgbBuf),numColors*sizeof(TRgb)); - TPtr8 paletteData(NULL,0); - TInt color=0; - TPoint point(iWinSize.AsPoint()); - do { - if (color+numColors>256) - numColors=256-color; - TheClient->iScreen->GetScanLine(ptr,point,numColors,EColor16MA); - aPalette->GetDataPtr(color,numColors,paletteData); - TEST(ptr==paletteData); - color+=numColors; - } while (color<256 && ++point.iY<2*iWinSize.iHeight); - } - -void CTGetPixel::CheckPaletteL(CPalette*& aPalette) - { - User::LeaveIfError(TheClient->iScreen->SetCustomPalette(aPalette)); - TestColors(aPalette); - delete aPalette; - User::LeaveIfError(TheClient->iScreen->GetPalette(aPalette)); - TestColors(aPalette); - } - -inline TInt Inc(TInt& aValue) - { - if (aValue>255-83) - aValue-=256-83; - else - aValue+=83; - return aValue; - } - -inline TInt Inc2(TInt& aValue) - { - if (aValue>255-41) - aValue-=256-41; - else - aValue+=41; - return aValue; - } - -void CTGetPixel::PaletteTestL() - { - //INFO_PRINTF1(_L("AUTO PaletteTest ")); - TInt numEntries; - TBool modifiable; - TheClient->iScreen->PaletteAttributes(modifiable,numEntries); - INFO_PRINTF2(_L("Number of entries in the palette %d"), numEntries); - if(numEntries > 65536) - { - INFO_PRINTF1(_L("These test cases has been skipped, as the screen is set up in true colour display mode, where palette is not applicable")); - return; - } - CPalette* palette=NULL; - if (!modifiable) - { - if (numEntries==4) - palette=CPalette::NewDefaultL(EGray4); - else if (numEntries==16) - palette=CPalette::NewDefaultL(EGray16); - else - palette=CPalette::NewL(numEntries); - //INFO_PRINTF1(_L(" Creating Empty Palette, setting it as palette")); - TInt err=TheClient->iScreen->SetCustomPalette(palette); - TEST(err==KErrNoMemory || err==KErrNotSupported || (err==KErrNone && numEntries<=16)); //Series5MX palettes are changeable even though they say they aren't - //INFO_PRINTF1(_L(" Palette setting test passed OK")); - delete palette; - } - TInt err=iWindow.SetRequiredDisplayMode(EColor256); - TheGc->Activate(iWindow); - DrawColorsL(); - //INFO_PRINTF1(_L(" Drawn Colors")); - TheClient->iScreen->PaletteAttributes(modifiable,numEntries); - iRgbBuf=STATIC_CAST(TRgb*,User::ReAllocL(iRgbBuf,Max(256,iWinSize.iWidth)*sizeof(TRgb))); - if (erriScreen->GetPalette(palette); - if (err==KErrNotSupported) - return; - User::LeaveIfError(err); - TestColors(palette); - delete palette; - //INFO_PRINTF1(_L(" Tested Palette OK")); - return; - } - //INFO_PRINTF1(_L(" Palette Changeable")); - TEST(numEntries==256); - CPalette* defPalette=CPalette::NewDefaultL(EColor256); - CleanupStack::PushL(defPalette); - TestColors(defPalette); - User::LeaveIfError(TheClient->iScreen->GetPalette(palette)); - TestColors(palette); - TInt color; - TInt index=0; - for (color=0;color<256;++color) - palette->SetEntry(color,TRgb::Gray256(color)); - CheckPaletteL(palette); - for (color=0;color<256;++color) - palette->SetEntry(color,TRgb(Inc(index),Inc(index),Inc(index))); - CheckPaletteL(palette); - for (color=0;color<256;++color) - palette->SetEntry(color,TRgb(Inc2(index),Inc2(index),Inc2(index))); - CheckPaletteL(palette); - delete palette; - User::LeaveIfError(TheClient->iScreen->SetCustomPalette(defPalette)); - TestColors(defPalette); - CleanupStack::PopAndDestroy(defPalette); - ClearOutRedraws(); - } - -void CTGetPixel::RunTestCaseL(TInt /*aCurTestCase*/) - { - ((CTGetPixelStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); - switch(++iTest->iState) - { -/** -@SYMTestCaseID GRAPHICS-WSERV-0212 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Draw lines and check them by scanning the lines - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Draw lines and then scan them to check that they have - been drawn correctly - -@SYMTestExpectedResults Scanning the lines reveals they have been drawn correctly -*/ - case 1: - ((CTGetPixelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0212")); - TheClient->iWs.SetAutoFlush(ETrue); - iTest->LogSubTest(_L("Basic")); - DrawAndCheckLine(TPoint(0,2),iWinSize.iWidth-2,TRgb::Gray4(0)); - DrawAndCheckLine(TPoint(0,iWinSize.iHeight-2),iWinSize.iWidth,TRgb::Gray4(1)); - DrawAndCheckLine(TPoint(iWinSize.iWidth-1,iWinSize.iHeight-1),1,TRgb::Gray4(2)); - ClearOutRedraws(); - TheClient->iWs.SetAutoFlush(EFalse); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0213 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Draw line on every line of a window and - check them by scanning the lines - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Draw lines on every line of a window and - check them by scanning the lines - -@SYMTestExpectedResults Scanning the lines reveals they have been drawn correctly -*/ - - case 2: - { - ((CTGetPixelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0213")); - iTest->LogSubTest(_L("Full window")); - for(TInt ypos=0;yposSetTestStepID(_L("GRAPHICS-WSERV-0214")); - iTest->LogSubTest(_L("Check Rect")); - TestCheckRect(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0215 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test that the GetScanLine method panics correctly - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Cause the GetScanLine method to panic and chekc the response - -@SYMTestExpectedResults The panic for the GetScanLine method is correct -*/ - case 4: - ((CTGetPixelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0215")); - iTest->LogSubTest(_L("Panic")); - TestPanicsL(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0216 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test that CPalette class functions correctly - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Create a CPalette object and exercise all its methods - -@SYMTestExpectedResults The palette functions as exepcted -*/ - case 5: - ((CTGetPixelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0216")); - iTest->LogSubTest(_L("Palette Test")); - PaletteTestL(); - break; - case 6: - ((CTGetPixelStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - ((CTGetPixelStep*)iStep)->CloseTMSGraphicsStep(); - TestComplete(); - break; - } - ((CTGetPixelStep*)iStep)->RecordTestResultL(); - } - -__WS_CONSTRUCT_STEP__(GetPixel) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TGETPIXEL.H --- a/windowing/windowserver/tauto/TGETPIXEL.H Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,69 +0,0 @@ - -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef __TGETPIXEL_H__ -#define __TGETPIXEL_H__ - -#include -#include -#include "../tlib/testbase.h" -#include "AUTO.H" -#include "TGraphicsHarness.h" - -class CTGetPixel : public CTWsGraphicsBase - { -public: - CTGetPixel(CTestStep* aStep); - ~CTGetPixel(); - void DrawAndCheckLine(const TPoint &aPos,TInt aLen,TRgb aColor); - void TestCheckRect(); - void GetPixelTest(); - void ConstructL(); - void TestPanicsL(); - void PaletteTestL(); -protected: -//from CTGraphicsStep - virtual void RunTestCaseL(TInt aCurTestCase); -private: - void DrawColorsL(); - void TestColors(CPalette* aPalette); - void CheckPaletteL(CPalette*& aPalette); - void ClearOutRedraws(); -private: - TSize iWinSize; - TRgb *iRgbBuf; - RWindow iWindow; - }; - -class CTGetPixelStep : public CTGraphicsStep - { -public: - CTGetPixelStep(); -protected: - //from CTGraphicsStep - virtual CTGraphicsBase* CreateTestL(); - }; - -_LIT(KTGetPixelStep,"TGetPixel"); - - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TGRAPHICSDRAWER.CPP --- a/windowing/windowserver/tauto/TGRAPHICSDRAWER.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,112 +0,0 @@ -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Tests for the TWsGraphicMsgBufParser -// -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include "TGRAPHICSDRAWER.H" -#include "Graphics/WSGRAPHICMSGBUF.H" - -CTGraphicsDrawer::CTGraphicsDrawer(CTestStep* aStep): - CTGraphicsBase(aStep) - { - INFO_PRINTF1(_L("Testing TWsGraphicMsgBufParser")); - } - -void CTGraphicsDrawer::RunTestCaseL(TInt aCurTestCase) - { - ((CTGraphicsDrawerStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); - switch(aCurTestCase) - { - case 1: - ((CTGraphicsDrawerStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0449")); - INFO_PRINTF1(_L("TWsGraphicMsgBufParser Indefinite Loop Test")); - IndefiniteLoopL(); - break; - - case 2: - ((CTGraphicsDrawerStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - ((CTGraphicsDrawerStep*)iStep)->CloseTMSGraphicsStep(); - INFO_PRINTF1(_L("Test complete\n")); - TestComplete(); - break; - } - ((CTGraphicsDrawerStep*)iStep)->RecordTestResultL(); - } - - -void CTGraphicsDrawer::ConstructL() - { - } - -CTGraphicsDrawer::~CTGraphicsDrawer() - { - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-0449 - -@SYMDEF DEF110513, PDEF112710 - -@SYMTestCaseDesc Tests that a zero length buffer does not cause an indefinate loop during verify - -@SYMTestPriority Normal - -@SYMTestStatus Implemented - -@SYMTestActions Creates a buffer, puts it into a TWsGraphicMsgBufParser and calls verify on it - then removes the message from the buffer and re-tests verify. - -@SYMTestExpectedResults Test should pass and not timeout -*/ - -void CTGraphicsDrawer::IndefiniteLoopL() - { - RWsGraphicMsgBuf msgBuffer; - msgBuffer.CleanupClosePushL(); - msgBuffer.Append(TUid::Uid(0x12345670),KNullDesC8); - TWsGraphicMsgBufParser msgParser(msgBuffer.Pckg()); - - // test the verify method with a single message in the buffer - if(msgParser.Verify() != KErrNone) - { - INFO_PRINTF1(_L("TWsGraphicMsgBufParser::Verify() failed for buffer length 1")); - TEST(EFalse); - } - - // remove the (only) message so the message buffer now has a length of zero - msgBuffer.Remove(0); - TEST(msgBuffer.Count()==0); - - // test the verify method with an zero length buffer - if(msgParser.Verify() != KErrNone) - { - INFO_PRINTF1(_L("TWsGraphicMsgBufParser::Verify() failed for zero length buffer")); - TEST(EFalse); - } - - CleanupStack::PopAndDestroy(&msgBuffer); - } - -//-------------- -__CONSTRUCT_STEP__(GraphicsDrawer) - - - diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TGRAPHICSDRAWER.H --- a/windowing/windowserver/tauto/TGRAPHICSDRAWER.H Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,59 +0,0 @@ -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef __TGRAPHICSDRAWER_H__ -#define __TGRAPHICSDRAWER_H__ - -#include -#include -#include "../tlib/testbase.h" -#include "AUTO.H" -#include "TGraphicsHarness.h" - -class CTGraphicsDrawer : public CTGraphicsBase - { -public: - CTGraphicsDrawer(CTestStep* aStep); - ~CTGraphicsDrawer(); - -protected: -//from CTGraphicsStep - virtual void RunTestCaseL(TInt aCurTestCase); -public: - void ConstructL(); - void IndefiniteLoopL(); - -private: - CTestBase *iTest; - }; - -class CTGraphicsDrawerStep : public CTGraphicsStep - { -public: - CTGraphicsDrawerStep(); -protected: - virtual CTGraphicsBase* CreateTestL(); - }; - -_LIT(KTGraphicsDrawerStep,"TGraphicsDrawer"); - - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TGWHANDLE.CPP --- a/windowing/windowserver/tauto/TGWHANDLE.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1870 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// GWHANDLE.CPP -// Test group window handle functions -// -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include "TGWHANDLE.H" - - -CTGwHandle::CTGwHandle(CTestStep* aStep): - CTWsGraphicsBase(aStep) - { - } - -void CTGwHandle::ConstructL() - { - } - -CTGwHandle::~CTGwHandle() - { - } - -TInt CTGwHandle::NumberOfWndGroupsWithZeroPriority(TInt aScreenNumber) - { - __ASSERT_ALWAYS(aScreenNumber <= 1, User::Invariant()); - return TheClient->iWs.NumWindowGroups(aScreenNumber,0); - } - -void CTGwHandle::GetGwListL(CArrayFixFlat *aWindowHandles) - { - User::LeaveIfError(TheClient->iWs.WindowGroupList(aWindowHandles)); - } - -void CTGwHandle::GetGwListL(CArrayFixFlat *aWindowHandles, TInt aScreenNumber) - { - User::LeaveIfError(TheClient->iWs.WindowGroupList(aWindowHandles, aScreenNumber)); - } - -void CTGwHandle::GetGwListL(TInt aPriority, CArrayFixFlat *aWindowHandles) - { - User::LeaveIfError(TheClient->iWs.WindowGroupList(aPriority,aWindowHandles)); - } - -void CTGwHandle::GetGwListL(RArray* aWindowHandles) - { - User::LeaveIfError(TheClient->iWs.WindowGroupList(aWindowHandles)); - } - -void CTGwHandle::GetGwListL(TInt aPriority, RArray* aWindowHandles) - { - User::LeaveIfError(TheClient->iWs.WindowGroupList(aPriority, aWindowHandles)); - } - -void CTGwHandle::GwNamesL() - { - enum {EConnectHandle1=123456}; - enum {EWindowGroupHandle1=234567}; - enum {EWindowGroupHandle2=666666}; -// - TInt foreground; - User::LeaveIfError(foreground=TheClient->iWs.GetFocusWindowGroup()); - RWsSession ws1; - User::LeaveIfError(ws1.Connect()); - - // assign to the correct screen - CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws1); - CleanupStack::PushL(screen); - User::LeaveIfError(screen->Construct(iTest->iScreenNumber)); - - RWindowGroup gw1(ws1); - User::LeaveIfError(gw1.Construct(EWindowGroupHandle1)); - gw1.SetOwningWindowGroup(foreground); - RWindowGroup gw2(ws1); - User::LeaveIfError(gw2.Construct(EWindowGroupHandle2)); - gw2.SetOwningWindowGroup(foreground); -// - TBuf<8> getName; -// -// Check default name is simply a null string -// - TInt retVal = gw1.Name(getName); - TEST(retVal==KErrNone); - if (retVal!=KErrNone) - INFO_PRINTF3(_L("gw1.Name(getName) return value - Expected: %d, Actual: %d"), KErrNone, retVal); - - TEST(getName==_L("")); - if (getName!=_L("")) - INFO_PRINTF3(_L("getName==_L() - Expected: %d, Actual: %d"), ETrue, EFalse); -// - TBuf<8> name1(_L("A_Name1")); - TBuf<8> name2(_L("A_Name2")); -// - retVal = gw1.SetName(name1); - TEST(retVal==KErrNone); - if (retVal!=KErrNone) - INFO_PRINTF3(_L("gw1.SetName(name1) return value - Expected: %d, Actual: %d"), KErrNone, retVal); - - retVal = gw2.SetName(name2); - TEST(retVal==KErrNone); - if (retVal!=KErrNone) - INFO_PRINTF3(_L("(gw2.SetName(name2) return value - Expected: %d, Actual: %d"), KErrNone, retVal); - - retVal = gw1.Name(getName); - TEST(retVal==KErrNone); - if (retVal!=KErrNone) - INFO_PRINTF3(_L("(gw1.Name(getName) return value - Expected: %d, Actual: %d"), KErrNone, retVal); - - TEST(getName==name1); - if (getName!=name1) - INFO_PRINTF3(_L("getName==name1 - Expected: %d, Actual: %d"), ETrue, EFalse); -// - retVal = gw2.Name(getName); - TEST(retVal==KErrNone); - if (retVal!=KErrNone) - INFO_PRINTF3(_L("(gw2.Name(getName) return value - Expected: %d, Actual: %d"), KErrNone, retVal); - - TEST(getName==name2); - if (getName!=name2) - INFO_PRINTF3(_L("getName==name2 - Expected: %d, Actual: %d"), ETrue, EFalse); - -// -// A few weird characters in the name should work fine -// - retVal = gw2.SetName(_L("xx*")); - TEST(retVal==KErrNone); - if (retVal!=KErrNone) - INFO_PRINTF3(_L("(gw2.SetName(_L(xx*)) return value - Expected: %d, Actual: %d"), KErrNone, retVal); - - retVal = gw2.Name(getName); - TEST(retVal==KErrNone); - if (retVal!=KErrNone) - INFO_PRINTF3(_L("(gw2.Name(getName) return value - Expected: %d, Actual: %d"), KErrNone, retVal); - - TEST(getName==_L("xx*")); - if (getName!=_L("xx*")) - INFO_PRINTF3(_L("getName==_L(xx*) - Expected: %d, Actual: %d"), ETrue, EFalse); - -// - retVal = gw2.SetName(_L(":")); - TEST(retVal==KErrNone); - if (retVal!=KErrNone) - INFO_PRINTF3(_L("(gw2.SetName(_L(:)) return value - Expected: %d, Actual: %d"), KErrNone, retVal); - - retVal = gw2.Name(getName); - TEST(retVal==KErrNone); - if (retVal!=KErrNone) - INFO_PRINTF3(_L("(gw2.Name(getName) return value - Expected: %d, Actual: %d"), KErrNone, retVal); - - TEST(getName==_L(":")); - if (getName!=_L(":")) - INFO_PRINTF3(_L("getName==_L(:) - Expected: %d, Actual: %d"), ETrue, EFalse); - -// -// Setting the name back to a null name -// - retVal = gw2.SetName(_L("")); - TEST(retVal==KErrNone); - if (retVal!=KErrNone) - INFO_PRINTF3(_L("gw2.SetName(_L()) return value - Expected: %d, Actual: %d"), KErrNone, retVal); - - retVal = gw2.Name(getName); - TEST(retVal==KErrNone); - if (retVal!=KErrNone) - INFO_PRINTF3(_L("gw2.Name(getName) return value - Expected: %d, Actual: %d"), KErrNone, retVal); - - TEST(getName==_L("")); - if (getName!=_L("")) - INFO_PRINTF3(_L("getName==_L() - Expected: %d, Actual: %d"), ETrue, EFalse); - -// -// Getting a name into a too short buffer should fill thew whole buffer from the left hand part -// of the window name and return KErrOverflow -// - gw2.SetName(name2); - TBuf<4> shortBuf; - retVal = gw2.Name(shortBuf); - TEST(retVal==KErrOverflow); - if (retVal!=KErrOverflow) - INFO_PRINTF3(_L("gw2.Name(shortBuf) return value - Expected: %d, Actual: %d"), KErrOverflow, retVal); - - TEST(shortBuf==name2.Left(4)); - if (shortBuf!=name2.Left(4)) - INFO_PRINTF3(_L("shortBuf==name2.Left(4) - Expected: %d, Actual: %d"), ETrue, EFalse); - -// -// passing a 0 length TPtr pointing to NULL should be safe, simply returning KErrOverflow -// - TPtr nullPtr(NULL,0); - retVal = gw2.Name(nullPtr); - TEST(retVal==KErrOverflow); - if (retVal!=KErrOverflow) - INFO_PRINTF3(_L("gw2.Name(nullPtr) return value - Expected: %d, Actual: %d"), KErrOverflow, retVal); - - TEST(nullPtr==_L("")); - if (nullPtr!=_L("")) - INFO_PRINTF3(_L("nullPtr==_L() - Expected: %d, Actual: %d"), ETrue, EFalse); - -// -// Getting a null name into a null descriptor -// - gw2.SetName(_L("")); - TPtr nullPtr2(NULL,0); - retVal = gw2.Name(nullPtr); - TEST(retVal==KErrNone); - if (retVal!=KErrNone) - INFO_PRINTF3(_L("gw2.Name(nullPtr) return value - Expected: %d, Actual: %d"), KErrNone, retVal); - - TEST(nullPtr2==_L("")); - if (nullPtr2!=_L("")) - INFO_PRINTF3(_L("nullPtr2==_L() - Expected: %d, Actual: %d"), ETrue, EFalse); -// - gw1.Close(); - gw2.Close(); - CleanupStack::PopAndDestroy(screen); - ws1.Close(); - } - -void CTGwHandle::GwIdentifierTestL() - { - enum {EWindowGroupHandle1=234567}; - enum {EWindowGroupHandle2=666666}; - enum {EWindowGroupHandle3=999}; -// - CArrayFixFlat* windowHandles=new(ELeave) CArrayFixFlat(5); - CleanupStack::PushL(windowHandles); - GetGwListL(0, windowHandles); - TInt retVal = TheClient->iWs.GetFocusWindowGroup(); - TEST(retVal==(*windowHandles)[0]); - if (retVal!=(*windowHandles)[0]) - INFO_PRINTF3(_L("TheClient->iWs.GetFocusWindowGroup() return value - Expected: %d, Actual: %d"), (*windowHandles)[0], retVal); - -// - RWsSession ws1; - User::LeaveIfError(ws1.Connect()); - CleanupClosePushL(ws1); - - // assign to the correct screen - CWsScreenDevice* screen1 = new (ELeave) CWsScreenDevice(ws1); - CleanupStack::PushL(screen1); - User::LeaveIfError(screen1->Construct(iTest->iScreenNumber)); - - RWindowGroup gw1(ws1); - User::LeaveIfError(gw1.Construct(EWindowGroupHandle1)); - gw1.SetOwningWindowGroup((*windowHandles)[0]); - RWsSession ws2; - User::LeaveIfError(ws2.Connect()); - CleanupClosePushL(ws2); - - // assign to the correct screen - CWsScreenDevice* screen2 = new (ELeave) CWsScreenDevice(ws2); - CleanupStack::PushL(screen2); - User::LeaveIfError(screen2->Construct(iTest->iScreenNumber)); - - RWindowGroup gw2(ws2); - User::LeaveIfError(gw2.Construct(EWindowGroupHandle2)); -// - GetGwListL(0, windowHandles); -// - - retVal = gw2.Identifier(); - TEST(retVal==(*windowHandles)[0]); - if (retVal!=(*windowHandles)[0]) - INFO_PRINTF3(_L("gw2.Identifier() return value - Expected: %d, Actual: %d"), (*windowHandles)[0], retVal); - - retVal = gw1.Identifier(); - TEST(retVal==(*windowHandles)[1]); - if (retVal!=(*windowHandles)[1]) - INFO_PRINTF3(_L("gw1.Identifier() return value - Expected: %d, Actual: %d"), (*windowHandles)[1], retVal); - - retVal = TheClient->iWs.GetWindowGroupHandle((*windowHandles)[0]); - TEST(retVal==EWindowGroupHandle2); - if (retVal!=EWindowGroupHandle2) - INFO_PRINTF3(_L("TheClient->iWs.GetWindowGroupHandle((*windowHandles)[0]) return value - Expected: %d, Actual: %d"), EWindowGroupHandle2, retVal); - - retVal = TheClient->iWs.GetWindowGroupHandle((*windowHandles)[1]); - TEST(retVal==EWindowGroupHandle1); - if (retVal!=EWindowGroupHandle1) - INFO_PRINTF3(_L("TheClient->iWs.GetWindowGroupHandle((*windowHandles)[1]) return value - Expected: %d, Actual: %d"), EWindowGroupHandle1, retVal); -// - retVal = TheClient->iWs.GetWindowGroupOrdinalPriority((*windowHandles)[1]); - TEST(retVal==0); - if (retVal!=0) - INFO_PRINTF3(_L("TheClient->iWs.GetWindowGroupOrdinalPriority((*windowHandles)[1]) return value - Expected: %d, Actual: %d"), 0, retVal); - - retVal = TheClient->iWs.GetWindowGroupOrdinalPriority((*windowHandles)[0]); - TEST(retVal==0); - if (retVal!=0) - INFO_PRINTF3(_L("TheClient->iWs.GetWindowGroupOrdinalPriority((*windowHandles)[0]) return value - Expected: %d, Actual: %d"), 0, retVal); - -// - TThreadId threadId; - TheClient->iWs.GetWindowGroupClientThreadId((*windowHandles)[0],threadId); - - TUint64 ret = RThread().Id(); - TEST(ret==threadId); - if (ret!=threadId) - INFO_PRINTF3(_L("RThread().Id() return value - Expected: %d, Actual: %d"), (TInt)threadId, (TInt)ret); - - TheClient->iWs.GetWindowGroupClientThreadId((*windowHandles)[1],threadId); - - TUint64 retVal2 = RThread().Id(); - TEST(retVal2==threadId); - if (retVal2!=threadId) - INFO_PRINTF3(_L("RThread().Id() return value - Expected: %d, Actual: %d"), (TInt)threadId, (TInt)retVal2); -// - retVal = gw1.OrdinalPosition(); - TEST(retVal==1); - if (retVal!=1) - INFO_PRINTF3(_L("gw1.OrdinalPosition() return value - Expected: %d, Actual: %d"), 1, retVal); - - retVal = gw2.OrdinalPosition(); - TEST(retVal==0); - if (retVal!=0) - INFO_PRINTF3(_L("gw2.OrdinalPosition() return value - Expected: %d, Actual: %d"), 0, retVal); - - retVal = TheClient->iWs.SetWindowGroupOrdinalPosition((*windowHandles)[1],0); - TEST(retVal==KErrNone); - if (retVal!=KErrNone) - INFO_PRINTF3(_L("TheClient->iWs.SetWindowGroupOrdinalPosition((*windowHandles)[1],0) return value - Expected: %d, Actual: %d"), KErrNone, retVal); - - retVal = gw1.OrdinalPosition(); - TEST(retVal==0); - if (retVal!=0) - INFO_PRINTF3(_L("gw1.OrdinalPosition() return value - Expected: %d, Actual: %d"), 0, retVal); - - retVal = gw2.OrdinalPosition(); - TEST(retVal==1); - if (retVal!=1) - INFO_PRINTF3(_L("gw2.OrdinalPosition() return value - Expected: %d, Actual: %d"), 1, retVal); -// - retVal = TheClient->iWs.SetWindowGroupOrdinalPosition((*windowHandles)[1],1); - TEST(retVal==KErrNone); - if (retVal!=KErrNone) - INFO_PRINTF3(_L("TheClient->iWs.SetWindowGroupOrdinalPosition((*windowHandles)[1],1) return value - Expected: %d, Actual: %d"), KErrNone, retVal); - - retVal = gw1.OrdinalPosition(); - TEST(retVal==1); - if (retVal!=1) - INFO_PRINTF3(_L("gw1.OrdinalPosition() return value - Expected: %d, Actual: %d"), 1, retVal); - - retVal = gw2.OrdinalPosition(); - TEST(retVal==0); - if (retVal!=0) - INFO_PRINTF3(_L("gw2.OrdinalPosition() return value - Expected: %d, Actual: %d"), 0, retVal); - - retVal = TheClient->iWs.SetWindowGroupOrdinalPosition((*windowHandles)[0],1); - TEST(retVal==KErrNone); - if (retVal!=KErrNone) - INFO_PRINTF3(_L("TheClient->iWs.SetWindowGroupOrdinalPosition((*windowHandles)[0],1) return value - Expected: %d, Actual: %d"), KErrNone, retVal); - - GetGwListL(0, windowHandles); - retVal = TheClient->iWs.GetWindowGroupHandle((*windowHandles)[0]); - TEST(retVal==EWindowGroupHandle1); - if (retVal!=EWindowGroupHandle1) - INFO_PRINTF3(_L("TheClient->iWs.GetWindowGroupHandle((*windowHandles)[0]) return value - Expected: %d, Actual: %d"), EWindowGroupHandle1, retVal); - - retVal = TheClient->iWs.GetWindowGroupHandle((*windowHandles)[1]); - TEST(retVal==EWindowGroupHandle2); - if (retVal!=EWindowGroupHandle2) - INFO_PRINTF3(_L("TheClient->iWs.GetWindowGroupHandle((*windowHandles)[1]) return value - Expected: %d, Actual: %d"), EWindowGroupHandle2, retVal); -// - RWindowGroup gw3(ws2); - User::LeaveIfError(gw3.Construct(EWindowGroupHandle3)); - gw1.SetOrdinalPosition(0,100000); // Assume nothing else in the system is higher, else test will fail - gw3.SetOrdinalPosition(0,100000); - ws1.Flush(); - ws2.Flush(); -// - GetGwListL(100000, windowHandles); - retVal = windowHandles->Count(); - TEST(retVal==2); - if (retVal!=2) - INFO_PRINTF3(_L("windowHandles->Count() return value - Expected: %d, Actual: %d"), 2, retVal); - - retVal = TheClient->iWs.GetWindowGroupHandle((*windowHandles)[0]); - TEST(retVal==EWindowGroupHandle3); - if (retVal!=EWindowGroupHandle3) - INFO_PRINTF3(_L("TheClient->iWs.GetWindowGroupHandle((*windowHandles)[0]) return value - Expected: %d, Actual: %d"), EWindowGroupHandle3, retVal); - - retVal = TheClient->iWs.GetWindowGroupHandle((*windowHandles)[1]); - TEST(retVal==EWindowGroupHandle1); - if (retVal!=EWindowGroupHandle1) - INFO_PRINTF3(_L("TheClient->iWs.GetWindowGroupHandle((*windowHandles)[1]) return value - Expected: %d, Actual: %d"), EWindowGroupHandle1, retVal); - -// - retVal = TheClient->iWs.GetWindowGroupOrdinalPriority((*windowHandles)[0]); - TEST(retVal==100000); - if (retVal!=100000) - INFO_PRINTF3(_L("TheClient->iWs.GetWindowGroupOrdinalPriority((*windowHandles)[0]) return value - Expected: %d, Actual: %d"), 100000, retVal); - - retVal = TheClient->iWs.GetWindowGroupOrdinalPriority((*windowHandles)[1]); - TEST(retVal==100000); - if (retVal!=100000) - INFO_PRINTF3(_L("TheClient->iWs.GetWindowGroupOrdinalPriority((*windowHandles)[1]) return value - Expected: %d, Actual: %d"), 100000, retVal); -// - GetGwListL(-12453, windowHandles); // Test 0 count, Assumes no window with priority - retVal = windowHandles->Count(); - TEST(retVal==0); - if (retVal!=0) - INFO_PRINTF3(_L("windowHandles->Count() return value - Expected: %d, Actual: %d"), 0, retVal); - -// - GetGwListL(windowHandles, iTest->iScreenNumber); - retVal = TheClient->iWs.GetWindowGroupHandle((*windowHandles)[0]); - TEST(retVal==EWindowGroupHandle3); - if (retVal!=EWindowGroupHandle3) - INFO_PRINTF3(_L("TheClient->iWs.GetWindowGroupHandle((*windowHandles)[0]) return value - Expected: %d, Actual: %d"), EWindowGroupHandle3, retVal); - - retVal = TheClient->iWs.GetWindowGroupHandle((*windowHandles)[1]); - TEST(retVal==EWindowGroupHandle1); - if (retVal!=EWindowGroupHandle1) - INFO_PRINTF3(_L("TheClient->iWs.GetWindowGroupHandle((*windowHandles)[1]) return value - Expected: %d, Actual: %d"), EWindowGroupHandle1, retVal); -// -// Check passing bad identifiers -// - retVal = TheClient->iWs.SetWindowGroupOrdinalPosition(-1,0); - TEST(retVal==KErrNotFound); - if (retVal!=KErrNotFound) - INFO_PRINTF3(_L("TheClient->iWs.SetWindowGroupOrdinalPosition(-1,0) return value - Expected: %d, Actual: %d"), KErrNotFound, retVal); - - retVal = TheClient->iWs.GetWindowGroupHandle(-3); - TEST(retVal==KErrNotFound); - if (retVal!=KErrNotFound) - INFO_PRINTF3(_L("TTheClient->iWs.GetWindowGroupHandle(-3) return value - Expected: %d, Actual: %d"), KErrNotFound, retVal); - -// - gw1.Close(); - gw2.Close(); - gw3.Close(); - - CleanupStack::PopAndDestroy(5, windowHandles); - } - -void CTGwHandle::OwnerToForegroundL() - { - enum {EWindowGroupHandle1=234567}; - enum {EWindowGroupHandle2a=666666}; - enum {EWindowGroupHandle2b=666667}; -// - CArrayFixFlat *windowHandles=new(ELeave) CArrayFixFlat(5); - CleanupStack::PushL(windowHandles); - GetGwListL(0, windowHandles); - TInt oldForeground=(*windowHandles)[0]; -// - RWsSession ws1; - User::LeaveIfError(ws1.Connect()); - CleanupClosePushL(ws1); - - // assign to the correct screen - CWsScreenDevice* screen1 = new (ELeave) CWsScreenDevice(ws1); - CleanupStack::PushL(screen1); - User::LeaveIfError(screen1->Construct(iTest->iScreenNumber)); - - RWindowGroup gw1(ws1); - User::LeaveIfError(gw1.Construct(EWindowGroupHandle1)); - CleanupClosePushL(gw1); - RWsSession ws2; - User::LeaveIfError(ws2.Connect()); - CleanupClosePushL(ws2); - - // assign to the correct screen - CWsScreenDevice* screen2 = new (ELeave) CWsScreenDevice(ws2); - CleanupStack::PushL(screen2); - User::LeaveIfError(screen2->Construct(iTest->iScreenNumber)); - - RWindowGroup gw2a(ws2); - User::LeaveIfError(gw2a.Construct(EWindowGroupHandle2a)); - CleanupClosePushL(gw2a); - RWindowGroup gw2b(ws2); - User::LeaveIfError(gw2b.Construct(EWindowGroupHandle2b)); - CleanupClosePushL(gw2b); - gw1.SetOrdinalPosition(1); -// -// Turn auto flushing on as we're using multiple connections and it would be easy to forget to flush one -// - ws1.SetAutoFlush(ETrue); - ws2.SetAutoFlush(ETrue); - TheClient->iWs.SetAutoFlush(ETrue); -// - GetGwListL(0, windowHandles); -// - TInt retVal = gw2b.Identifier(); - TEST(retVal==(*windowHandles)[0]); - if (retVal!=(*windowHandles)[0]) - INFO_PRINTF3(_L("gw2b.Identifier() return value - Expected: %d, Actual: %d"), (*windowHandles)[0], retVal); - - retVal = gw1.Identifier(); - TEST(retVal==(*windowHandles)[1]); - if (retVal!=(*windowHandles)[1]) - INFO_PRINTF3(_L("gw1.Identifier() return value - Expected: %d, Actual: %d"), (*windowHandles)[1], retVal); - - retVal = gw2a.Identifier(); - TEST(retVal==(*windowHandles)[2]); - if (retVal!=(*windowHandles)[2]) - INFO_PRINTF3(_L("gw2a.Identifier() return value - Expected: %d, Actual: %d"), (*windowHandles)[2], retVal); - - retVal = oldForeground; - TEST(retVal==(*windowHandles)[3]); - if (retVal!=(*windowHandles)[3]) - INFO_PRINTF3(_L("oldForeground - Expected: %d, Actual: %d"), (*windowHandles)[3], oldForeground); -// - CleanupStack::PopAndDestroy(&gw2b); - GetGwListL(0, windowHandles); - - retVal = gw2a.Identifier(); - TEST(retVal==(*windowHandles)[0]); - if (retVal!=(*windowHandles)[0]) - INFO_PRINTF3(_L("gw2a.Identifier() return value - Expected: %d, Actual: %d"), (*windowHandles)[0], retVal); - // Check 2a jumped over 1 in the ordinal list - - retVal = gw1.Identifier(); - TEST(retVal==(*windowHandles)[1]); - if (retVal!=(*windowHandles)[1]) - INFO_PRINTF3(_L("gw1.Identifier() return value - Expected: %d, Actual: %d"), (*windowHandles)[1], retVal); - - retVal = oldForeground; - TEST(retVal==(*windowHandles)[2]); - if (retVal!=(*windowHandles)[2]) - INFO_PRINTF3(_L("oldForeground - Expected: %d, Actual: %d"), (*windowHandles)[2], oldForeground); - -// - User::LeaveIfError(gw2b.Construct(EWindowGroupHandle2b)); - CleanupClosePushL(gw2b); - gw2b.SetOwningWindowGroup(oldForeground); - CleanupStack::PopAndDestroy(&gw2b); - GetGwListL(0, windowHandles); - retVal = oldForeground; - TEST(retVal==(*windowHandles)[0]); - if (retVal!=(*windowHandles)[0]) - INFO_PRINTF3(_L("oldForeground - Expected: %d, Actual: %d"), (*windowHandles)[0], oldForeground); - // Check old foreground bought to foreground - - retVal = gw2a.Identifier(); - TEST(retVal==(*windowHandles)[1]); - if (retVal!=(*windowHandles)[1]) - INFO_PRINTF3(_L("gw2a.Identifier() return value - Expected: %d, Actual: %d"), (*windowHandles)[1], retVal); - - retVal = gw1.Identifier(); - TEST(retVal==(*windowHandles)[2]); - if (retVal!=(*windowHandles)[2]) - INFO_PRINTF3(_L("gw1.Identifier() return value - Expected: %d, Actual: %d"), (*windowHandles)[2], retVal); - - TheClient->iWs.SetWindowGroupOrdinalPosition((*windowHandles)[0],2); -// - User::LeaveIfError(gw2b.Construct(EWindowGroupHandle2b)); - CleanupClosePushL(gw2b); - gw2b.SetOwningWindowGroup((*windowHandles)[1]); - gw2b.SetOrdinalPosition(KOrdinalPositionSwitchToOwningWindow); // Should bring 2a to foreground - GetGwListL(0, windowHandles); - - retVal = gw2a.Identifier(); - TEST(retVal==(*windowHandles)[0]); - if (retVal!=(*windowHandles)[0]) - INFO_PRINTF3(_L("gw2a.Identifier() return value - Expected: %d, Actual: %d"), (*windowHandles)[0], retVal); - - retVal = gw2b.Identifier(); - TEST(retVal==(*windowHandles)[1]); - if (retVal!=(*windowHandles)[1]) - INFO_PRINTF3(_L("gw2b.Identifier() return value - Expected: %d, Actual: %d"), (*windowHandles)[1], retVal); - - retVal = gw1.Identifier(); - TEST(retVal==(*windowHandles)[2]); - if (retVal!=(*windowHandles)[2]) - INFO_PRINTF3(_L("gw1.Identifier() return value - Expected: %d, Actual: %d"), (*windowHandles)[2], retVal); -// - CleanupStack::PopAndDestroy(&gw2b); - GetGwListL(0, windowHandles); - retVal = gw2a.Identifier(); - TEST(retVal==(*windowHandles)[0]); - if (retVal!=(*windowHandles)[0]) - INFO_PRINTF3(_L("gw2a.Identifier() return value - Expected: %d, Actual: %d"), (*windowHandles)[0], retVal); - - retVal = gw1.Identifier(); - TEST(retVal==(*windowHandles)[1]); - if (retVal!=(*windowHandles)[1]) - INFO_PRINTF3(_L("gw1.Identifier() return value - Expected: %d, Actual: %d"), (*windowHandles)[1], retVal); -// - CleanupStack::PopAndDestroy(&gw2a); // Should bring shell to foreground - GetGwListL(0, windowHandles); - -// check whether the shell is on - TThreadId threadId; - ws2.GetWindowGroupClientThreadId((*windowHandles)[0],threadId); - TBool shellRunning=ETrue; - - TFullName shellName; - // apply to primary screen only where SHELL is running - TFindThread findThread(iTest->iScreenNumber==KDefaultScreen?_L("WSHELL*::*"):_L("WxSHELL*::*")); - if(findThread.Next(shellName)==KErrNone) - { - RThread shell; - User::LeaveIfError(shell.Open(shellName)); - TEST(shell.Id()==threadId); - if (retVal!=(*windowHandles)[1]) - INFO_PRINTF3(_L("gw1.Identifier() return value - Expected: %d, Actual: %d"), (*windowHandles)[1], retVal); - - shell.Close(); - } - else - { - shellRunning=EFalse; - } - - - // Check gw1 second - retVal = gw1.Identifier(); - TEST(retVal==(*windowHandles)[shellRunning ? 1 : 0]); - if (retVal!=(*windowHandles)[shellRunning ? 1 : 0]) - INFO_PRINTF3(_L("gw1.Identifier() return value - Expected: %d, Actual: %d"), (*windowHandles)[shellRunning ? 1 : 0], retVal); - - retVal = oldForeground; - TEST(retVal==(*windowHandles)[shellRunning ? 2 : 1]); - if (retVal!=(*windowHandles)[shellRunning ? 2 : 1]) - INFO_PRINTF3(_L("gw1.Identifier() return value - Expected: %d, Actual: %d"), (*windowHandles)[shellRunning ? 2 : 1], retVal); - // and oldforeground second - -// - CleanupStack::PopAndDestroy(5, &ws1); -// -// Kick shell back into background, 'cause that's where it belongs -// - TheClient->iWs.SetWindowGroupOrdinalPosition((*windowHandles)[0],-1); - TheClient->iWs.SetAutoFlush(EFalse); -// - CleanupStack::PopAndDestroy(windowHandles); - } - -void CTGwHandle::FindWindowGroupIdentifierTestL() - { - enum {EWindowGroupHandle1=234567}; - enum {EWindowGroupHandle2=666666}; - enum {EWindowGroupHandle3=123}; - TInt foreground=TheClient->iWs.GetFocusWindowGroup(); - RWsSession ws1; - User::LeaveIfError(ws1.Connect()); - - // assign to the correct screen - CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws1); - CleanupStack::PushL(screen); - User::LeaveIfError(screen->Construct(iTest->iScreenNumber)); - CleanupStack::Pop(screen); - - CleanupClosePushL(ws1); -// - RWindowGroup gw1(ws1); - User::LeaveIfError(gw1.Construct(EWindowGroupHandle1)); - CleanupClosePushL(gw1); - gw1.SetOwningWindowGroup(foreground); - RWindowGroup gw2(ws1); - User::LeaveIfError(gw2.Construct(EWindowGroupHandle2)); - CleanupClosePushL(gw2); - gw1.SetOwningWindowGroup(foreground); - RWindowGroup gw3(ws1); - User::LeaveIfError(gw3.Construct(EWindowGroupHandle3)); - CleanupClosePushL(gw3); - gw3.SetOwningWindowGroup(foreground); -// - TInt id1=gw1.Identifier(); - TInt id2=gw2.Identifier(); - TInt id3=gw3.Identifier(); -// - gw1.SetName(_L("qwerty123abcd")); - gw2.SetName(_L("123")); - gw3.SetName(_L("qqqabcdxxx123")); -// - TInt retVal = ws1.FindWindowGroupIdentifier(0,_L("123"),0); - TEST(retVal==id2); - if (retVal!=id2) - INFO_PRINTF3(_L("ws1.FindWindowGroupIdentifier(0,_L(123),0) return value - Expected: %d, Actual: %d"), id2, retVal); - -// - retVal = ws1.FindWindowGroupIdentifier(0,_L("*123*"),0); - TEST(retVal==id3); - if (retVal!=id3) - INFO_PRINTF3(_L("ws1.FindWindowGroupIdentifier(0,_L(*123*),0) return value - Expected: %d, Actual: %d"), id3, retVal); - - retVal = ws1.FindWindowGroupIdentifier(id3,_L("*123*"),0); - TEST(retVal==id2); - if (retVal!=id2) - INFO_PRINTF3(_L("ws1.FindWindowGroupIdentifier(id3,_L(*123*),0) return value - Expected: %d, Actual: %d"), id2, retVal); - - retVal = ws1.FindWindowGroupIdentifier(id2,_L("*123*"),0); - TEST(retVal==id1); - if (retVal!=id1) - INFO_PRINTF3(_L("ws1.FindWindowGroupIdentifier(id2,_L(*123*),0) return value - Expected: %d, Actual: %d"), id1, retVal); - -// - retVal = ws1.FindWindowGroupIdentifier(0,_L("*abcd*"),0); - TEST(retVal==id3); - if (retVal!=id3) - INFO_PRINTF3(_L("ws1.FindWindowGroupIdentifier(0,_L(*abcd*),0) return value - Expected: %d, Actual: %d"), id3, retVal); - - retVal = ws1.FindWindowGroupIdentifier(id3,_L("*abcd*"),0); - TEST(retVal==id1); - if (retVal!=id1) - INFO_PRINTF3(_L("ws1.FindWindowGroupIdentifier(id3,_L(*abcd*),0)return value - Expected: %d, Actual: %d"), id1, retVal); -// - retVal = ws1.FindWindowGroupIdentifier(0,_L("*123*"),7); - TEST(retVal==id3); - if (retVal!=id3) - INFO_PRINTF3(_L("ws1.FindWindowGroupIdentifier(0,_L(*123*),7)return value - Expected: %d, Actual: %d"), id3, retVal); - - retVal = ws1.FindWindowGroupIdentifier(id3,_L("*123*"),7); - TEST(retVal==KErrNotFound); - if (retVal!=KErrNotFound) - INFO_PRINTF3(_L("ws1.FindWindowGroupIdentifier(id3,_L(*123*),7) return value - Expected: %d, Actual: %d"), KErrNotFound, retVal); - - retVal = ws1.FindWindowGroupIdentifier(0,_L("*abc*"),4); - TEST(retVal==id1); - if (retVal!=id1) - INFO_PRINTF3(_L("ws1.FindWindowGroupIdentifier(0,_L(*abc*),4) return value - Expected: %d, Actual: %d"), id1, retVal); - - retVal = ws1.FindWindowGroupIdentifier(id1,_L("*abc*"),4); - TEST(retVal==KErrNotFound); - if (retVal!=KErrNotFound) - INFO_PRINTF3(_L("ws1.FindWindowGroupIdentifier(id1,_L(*abc*),4) return value - Expected: %d, Actual: %d"), KErrNotFound, retVal); - - retVal = ws1.FindWindowGroupIdentifier(0,_L("xxx*"),7); - TEST(retVal==id3); - if (retVal!=id3) - INFO_PRINTF3(_L("ws1.FindWindowGroupIdentifier(0,_L(xxx*),7) return value - Expected: %d, Actual: %d"), id3, retVal); - - retVal = ws1.FindWindowGroupIdentifier(0,_L("xxx*"),8); - TEST(retVal==KErrNotFound); - if (retVal!=KErrNotFound) - INFO_PRINTF3(_L("ws1.FindWindowGroupIdentifier(0,_L(xxx*),8) return value - Expected: %d, Actual: %d"), KErrNotFound, retVal); -// - retVal = ws1.FindWindowGroupIdentifier(id1,_L("12"),0); - TEST(retVal==KErrNotFound); - if (retVal!=KErrNotFound) - INFO_PRINTF3(_L("ws1.FindWindowGroupIdentifier(id1,_L(12),0) return value - Expected: %d, Actual: %d"), KErrNotFound, retVal); - - retVal = ws1.FindWindowGroupIdentifier(id1,_L("qqq"),0); - TEST(retVal==KErrNotFound); - if (retVal!=KErrNotFound) - INFO_PRINTF3(_L("ws1.FindWindowGroupIdentifier(id1,_L(qqq),0) return value - Expected: %d, Actual: %d"), KErrNotFound, retVal); - - retVal = ws1.FindWindowGroupIdentifier(id1,_L("abcd"),3); - TEST(retVal==KErrNotFound); - if (retVal!=KErrNotFound) - INFO_PRINTF3(_L("ws1.FindWindowGroupIdentifier(id1,_L(abcd),3) return value - Expected: %d, Actual: %d"), KErrNotFound, retVal); -// - delete screen; - CleanupStack::PopAndDestroy(4, &ws1); - } - -void CTGwHandle::DefaultOwningWindowL() - { - TInt foreground=TheClient->iWs.GetFocusWindowGroup(); - RWsSession ws1; - User::LeaveIfError(ws1.Connect()); - - // assign to the correct screen - CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws1); - CleanupStack::PushL(screen); - User::LeaveIfError(screen->Construct(iTest->iScreenNumber)); - -// - INFO_PRINTF1(_L("DefaultOwningWindow1")); - RWindowGroup gw1(ws1); - User::LeaveIfError(gw1.Construct(1)); - gw1.SetOwningWindowGroup(foreground); - RWindowGroup gw2(ws1); - User::LeaveIfError(gw2.Construct(2)); - gw2.SetOwningWindowGroup(foreground); - RWindowGroup gw3(ws1); - User::LeaveIfError(gw3.Construct(3)); - gw3.SetOwningWindowGroup(foreground); - RWindowGroup gw4(ws1); - User::LeaveIfError(gw4.Construct(4)); - gw4.SetOwningWindowGroup(foreground); - INFO_PRINTF1(_L(" Created Group Window")); -// - TInt prevOwningGroup=ws1.GetDefaultOwningWindow(); - gw1.DefaultOwningWindow(); - TEST(gw1.Identifier()==ws1.GetDefaultOwningWindow()); - if (gw1.Identifier()!=ws1.GetDefaultOwningWindow()) - INFO_PRINTF3(_L("gw1.Identifier()==ws1.GetDefaultOwningWindow() - Expected: %d, Actual: %d"), ws1.GetDefaultOwningWindow(), gw1.Identifier()); - - gw2.DefaultOwningWindow(); - TEST(gw2.Identifier()==ws1.GetDefaultOwningWindow()); - if (gw2.Identifier()!=ws1.GetDefaultOwningWindow()) - INFO_PRINTF3(_L("gw2.Identifier()==ws1.GetDefaultOwningWindow() - Expected: %d, Actual: %d"), ws1.GetDefaultOwningWindow(), gw2.Identifier()); - - gw2.Close(); - TEST(gw1.Identifier()==ws1.GetDefaultOwningWindow()); - if (gw1.Identifier()!=ws1.GetDefaultOwningWindow()) - INFO_PRINTF3(_L("gw1.Identifier()==ws1.GetDefaultOwningWindow() - Expected: %d, Actual: %d"), ws1.GetDefaultOwningWindow(), gw1.Identifier()); - - gw3.DefaultOwningWindow(); - gw4.DefaultOwningWindow(); - gw3.Close(); - TEST(gw4.Identifier()==ws1.GetDefaultOwningWindow()); - if (gw4.Identifier()!=ws1.GetDefaultOwningWindow()) - INFO_PRINTF3(_L("gw4.Identifier()==ws1.GetDefaultOwningWindow() - Expected: %d, Actual: %d"), ws1.GetDefaultOwningWindow(), gw4.Identifier()); - - gw4.Close(); - TEST(gw1.Identifier()==ws1.GetDefaultOwningWindow()); - if (gw1.Identifier()!=ws1.GetDefaultOwningWindow()) - INFO_PRINTF3(_L("gw1.Identifier()==ws1.GetDefaultOwningWindow() - Expected: %d, Actual: %d"), ws1.GetDefaultOwningWindow(), gw1.Identifier()); - - gw1.Close(); - TEST(prevOwningGroup==ws1.GetDefaultOwningWindow()); - if (prevOwningGroup!=ws1.GetDefaultOwningWindow()) - INFO_PRINTF3(_L("prevOwningGroup==ws1.GetDefaultOwningWindow() - Expected: %d, Actual: %d"), ws1.GetDefaultOwningWindow(), prevOwningGroup); - - INFO_PRINTF1(_L(" Closed Group Window")); - - User::LeaveIfError(gw1.Construct(1)); - gw1.SetOwningWindowGroup(foreground); - User::LeaveIfError(gw2.Construct(2)); - gw2.SetOwningWindowGroup(foreground); - User::LeaveIfError(gw3.Construct(3)); - gw3.SetOwningWindowGroup(foreground); - INFO_PRINTF1(_L(" ReCreated Group Window")); - gw1.DefaultOwningWindow(); - gw1.DefaultOwningWindow(); - gw1.Close(); - gw2.DefaultOwningWindow(); - gw2.DefaultOwningWindow(); - gw3.Close(); - gw2.Close(); - INFO_PRINTF1(_L(" Re-Closed Group Window")); - - User::LeaveIfError(gw1.Construct(1)); - gw1.SetOwningWindowGroup(foreground); - User::LeaveIfError(gw2.Construct(2)); - gw2.SetOwningWindowGroup(foreground); - User::LeaveIfError(gw3.Construct(3)); - gw3.SetOwningWindowGroup(foreground); - User::LeaveIfError(gw4.Construct(4)); - gw4.SetOwningWindowGroup(foreground); - INFO_PRINTF1(_L(" ReCreated Group Window Again")); - gw1.DefaultOwningWindow(); - gw2.DefaultOwningWindow(); - gw1.DefaultOwningWindow(); - gw1.Close(); - gw2.Close(); - gw3.DefaultOwningWindow(); - gw4.DefaultOwningWindow(); - gw3.DefaultOwningWindow(); - gw4.Close(); - gw3.Close(); - INFO_PRINTF1(_L(" Re-Closed Group Window Again")); - - User::LeaveIfError(gw1.Construct(1)); - gw1.DefaultOwningWindow(); - TEST(gw1.Identifier()==ws1.GetDefaultOwningWindow()); - if (gw1.Identifier()!=ws1.GetDefaultOwningWindow()) - INFO_PRINTF3(_L("gw1.Identifier()==ws1.GetDefaultOwningWindow() - Expected: %d, Actual: %d"), ws1.GetDefaultOwningWindow(), gw1.Identifier()); - - gw1.DefaultOwningWindow(); - TEST(gw1.Identifier()==ws1.GetDefaultOwningWindow()); - if (gw1.Identifier()!=ws1.GetDefaultOwningWindow()) - INFO_PRINTF3(_L("gw1.Identifier()==ws1.GetDefaultOwningWindow() - Expected: %d, Actual: %d"), ws1.GetDefaultOwningWindow(), gw1.Identifier()); - - User::LeaveIfError(gw2.Construct(2)); - TEST(gw1.Identifier()==ws1.GetDefaultOwningWindow()); - if (gw1.Identifier()!=ws1.GetDefaultOwningWindow()) - INFO_PRINTF3(_L("gw1.Identifier()==ws1.GetDefaultOwningWindow() - Expected: %d, Actual: %d"), ws1.GetDefaultOwningWindow(), gw1.Identifier()); - - gw2.Close(); - gw1.Close(); - - CleanupStack::PopAndDestroy(screen); - ws1.Close(); - } - -void CTGwHandle::DefaultOwningWindow2L() -//This test originally resulted in a crash, while the above test originally resulted in lockups. - { - RWsSession ws1; - User::LeaveIfError(ws1.Connect()); - - // assign to the correct screen - CWsScreenDevice* screen1 = new (ELeave) CWsScreenDevice(ws1); - CleanupStack::PushL(screen1); - User::LeaveIfError(screen1->Construct(iTest->iScreenNumber)); - - RWsSession ws2; - User::LeaveIfError(ws2.Connect()); - - // assign to the correct screen - CWsScreenDevice* screen2 = new (ELeave) CWsScreenDevice(ws2); - CleanupStack::PushL(screen2); - User::LeaveIfError(screen2->Construct(iTest->iScreenNumber)); - -// - RWindowGroup gw1(ws1); - User::LeaveIfError(gw1.Construct(1)); - RWindowGroup gw2(ws2); - User::LeaveIfError(gw2.Construct(2)); - RWindowGroup gw3(ws1); - User::LeaveIfError(gw3.Construct(3)); -// - const TInt gw1Id=gw1.Identifier(); - gw1.DefaultOwningWindow(); - gw2.DefaultOwningWindow(); - /*const TInt gw2Id=*/gw2.Identifier(); - gw1.DefaultOwningWindow(); - TEST(gw1Id==ws1.GetDefaultOwningWindow()); - if (gw1Id!=ws1.GetDefaultOwningWindow()) - INFO_PRINTF3(_L("gw1Id==ws1.GetDefaultOwningWindow() - Expected: %d, Actual: %d"), ws1.GetDefaultOwningWindow(), gw1Id); - - gw3.DefaultOwningWindow(); - gw3.Close(); - TEST(gw1Id==ws1.GetDefaultOwningWindow()); - if (gw1Id!=ws1.GetDefaultOwningWindow()) - INFO_PRINTF3(_L("gw1Id==ws1.GetDefaultOwningWindow() - Expected: %d, Actual: %d"), ws1.GetDefaultOwningWindow(), gw1Id); - - gw1.Close(); - TInt gw2Id=gw2.Identifier(); - TEST(gw2Id==ws1.GetDefaultOwningWindow()); - if (gw2Id!=ws1.GetDefaultOwningWindow()) - INFO_PRINTF3(_L("gw2Id==ws1.GetDefaultOwningWindow() - Expected: %d, Actual: %d"), ws1.GetDefaultOwningWindow(), gw2Id); - - gw2.SetOrdinalPosition(0); - gw2.Close(); - ws2.Flush(); - TRawEvent rawEvent; - rawEvent.Set(TRawEvent::EKeyDown,32); - TheClient->iWs.SimulateRawEvent(rawEvent); - TheClient->iWs.Flush(); -// - CleanupStack::PopAndDestroy(2,screen1); - ws1.Close(); - ws2.Close(); - } - -#define FREQ 500 -void CTGwHandle::IdentifierWrapAroundTestL() - { - TInt report=-1; - RWsSession ws1; - User::LeaveIfError(ws1.Connect()); - - // assign to the correct screen - CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws1); - CleanupStack::PushL(screen); - User::LeaveIfError(screen->Construct(iTest->iScreenNumber)); - - RWindowGroup gw1(ws1); - User::LeaveIfError(gw1.Construct(1)); - gw1.EnableReceiptOfFocus(EFalse); - TInt id1=gw1.Identifier(); - RWindowGroup gw2(ws1); - User::LeaveIfError(gw2.Construct(2)); - gw2.EnableReceiptOfFocus(EFalse); - TInt id2=gw2.Identifier(); - gw2.Close(); // Allow gw2 id to be re-used - TInt id3; - - do - { - RWindowGroup gw3(ws1); - User::LeaveIfError(gw3.Construct(2)); - gw3.EnableReceiptOfFocus(EFalse); - id3=gw3.Identifier(); - if ((id3/FREQ)!=(report/FREQ)) // || id3<=10) - { - report=id3; - iTest->LogMessage(id3); - } - TEST(id3!=id1); // Check id1 is not re-used as the window hasn't been freed yet - if (id3==id1) - { - _LIT(KErr,"Window Group Id Reused!"); - LOG_MESSAGE(KErr); - } - gw3.Close(); - } while(id3!=id2); - - CleanupStack::PopAndDestroy(screen); - ws1.Close(); - } - -void GwHandleDestroyWindow(TAny* aWindow) - { - static_cast(aWindow)->Destroy(); - } - -RWindowGroup* CTGwHandle::CreateWindowGroupLC(RWsSession& aWs,TUint32 aClientHandle,TInt aParentId/*=0*/) - { - RWindowGroup* gw=new(ELeave) RWindowGroup(aWs); - CleanupStack::PushL(TCleanupItem(&GwHandleDestroyWindow,gw)); - if (aParentId>0) - { - User::LeaveIfError(gw->ConstructChildApp(aParentId,aClientHandle,EFalse)); - } - else - { - User::LeaveIfError(gw->Construct(aClientHandle,EFalse)); - } - return gw; - } - -void CTGwHandle::CreateGroupWindowsLC(RWsSession& aWs) - { - for(TInt ii=ENumGroups-1;ii>=0;--ii) - iGroups[ii]=CreateWindowGroupLC(aWs,ii); - } - -void CTGwHandle::CreateChainedGroupWindowsLC(RWsSession& aWs,TBool aSecondChain) - { - TInt parentId=0; - for(TInt ii=ENumChained-1;ii>=0;--ii) - { - iChained[ii]=CreateWindowGroupLC(aWs,ENumGroups+ii,parentId); - parentId=iChained[ii]->Identifier(); - } - if(aSecondChain) - { - parentId =0; - for(TInt ii=ENumChained-1;ii>=0;--ii) - { - iChained2[ii]=CreateWindowGroupLC(aWs,ENumGroups+ENumGroups+ii,parentId); - parentId=iChained2[ii]->Identifier(); - } - } - } - -void CTGwHandle::MoveGroups(RWindowGroup** aGroups,TInt aGp,TInt aNum,TInt aPos,TInt aInc/*=2*/) - { - TInt ii; - for(ii=aNum;ii>0;--ii) - { - aGroups[aGp]->SetOrdinalPosition(aPos); - aGp+=(aInc>0?1:-1); - aPos+=aInc; - } - } - -void CTGwHandle::TestGroups(TInt aPos) - { - TInt retVal; - TInt ii = 0; - for(ii=0;iiOrdinalPosition(); - TEST(retVal==aPos+ii); - if (retVal!=aPos+ii) - INFO_PRINTF3(_L("iChained[ii]->OrdinalPosition() return value - Expected: %d, Actual: %d"), aPos+ii, retVal); - } - - for(ii=0;iiOrdinalPosition(); - TInt ret = (iiOrdinalPosition() return value - Expected: %d, Actual: %d"), ret, retVal); - } - } - -void CTGwHandle::TestGroupsBefore(TInt aPos) - { - TInt ii; - TInt retVal; - if (aPos>0) - { - for (ii=0;iiOrdinalPosition(); - TEST(retVal==ii); - if (retVal!=ii) - INFO_PRINTF3(_L("iGroups[ii]->OrdinalPosition() return value - Expected: %d, Actual: %d"), ii, retVal); - } - } - for (ii=0;iiOrdinalPosition(); - TEST(retVal==aPos+2*ii); - if (retVal!=aPos+2*ii) - INFO_PRINTF3(_L("iChained[ii]->OrdinalPosition() return value - Expected: %d, Actual: %d"), aPos+2*ii, retVal); - } - for (ii=0;iiOrdinalPosition(); - TEST(retVal==aPos+1+2*ii); - if (retVal!=aPos+1+2*ii) - INFO_PRINTF3(_L("iGroups[aPos+ii]->OrdinalPosition() return value - Expected: %d, Actual: %d"), aPos+1+2*ii, retVal); - } - for (ii=aPos+ENumChained-1;iiOrdinalPosition(); - TEST(retVal==ii+ENumChained); - if (retVal!=ii+ENumChained) - INFO_PRINTF3(_L("iGroups[ii]->OrdinalPosition() return value - Expected: %d, Actual: %d"), ii+ENumChained, retVal); - } - } - -void CTGwHandle::WindowGroupChaining() - { - RWsSession& ws=TheClient->iWs; - CreateGroupWindowsLC(ws); - CreateChainedGroupWindowsLC(ws); - TestGroups(0); - TInt start,target,moveGp; - for(moveGp=0;moveGpstart+1) - MoveGroups(iGroups,target-1,target-start-1,ENumChained+target-1,-1); - if (target0) - MoveGroups(iGroups,0,start,0,1); - MoveGroups(iGroups,start,ENumChained-1,start+1); - TestGroupsBefore(start); - iChained[moveGp]->SetOrdinalPosition(target+moveGp); - TestGroups(target); - } - } - iChained[0]->SetOrdinalPosition(0); - TestGroups(0); - } - CleanupStack::PopAndDestroy(ENumGroups+ENumChained,iGroups[ENumGroups-1]); - } - -void CTGwHandle::WindowGroupChaining2() - { - RWsSession& ws=TheClient->iWs; - RWindowGroup* chain1=CreateWindowGroupLC(ws,1); - chain1->SetOrdinalPosition(0,1); - RWindowGroup* chain2=CreateWindowGroupLC(ws,2,chain1->Identifier()); - TInt retVal = chain2->OrdinalPriority(); - TEST(retVal==1); - if (retVal!=1) - INFO_PRINTF3(_L("chain2->OrdinalPriority() return value - Expected: %d, Actual: %d"), 1, retVal); - - chain1->SetOrdinalPosition(0,2); - retVal = chain2->OrdinalPriority(); - TEST(retVal==2); - if (retVal!=2) - INFO_PRINTF3(_L("chain2->OrdinalPriority() return value - Expected: %d, Actual: %d"), 2, retVal); - - chain2->SetOrdinalPosition(0,3); - retVal = chain1->OrdinalPriority(); - TEST(retVal==3); - if (retVal!=3) - INFO_PRINTF3(_L("chain1->OrdinalPriority() return value - Expected: %d, Actual: %d"), 3, retVal); - - CleanupStack::PopAndDestroy(2,chain1); - - //Test that two different sessions can't chain window-groups without permisson. - //Both sessions must use the same screen. - RWsSession ws2; - User::LeaveIfError(ws2.Connect()); - CleanupClosePushL(ws2); - chain1=CreateWindowGroupLC(ws2,1); - TInt id1=chain1->Identifier(); - - RWsSession ws3; - User::LeaveIfError(ws3.Connect()); - CleanupClosePushL(ws3); - RWindowGroup chain(ws3); - - RDebug::Print(KPlatsecBegin); - retVal = chain.ConstructChildApp(id1,2); - TEST(retVal==KErrPermissionDenied); - if (retVal!=KErrPermissionDenied) - INFO_PRINTF3(_L("chain.ConstructChildApp(id1,2) return value - Expected: %d, Actual: %d"), KErrPermissionDenied, retVal); - - RDebug::Print(KPlatsecEnd); - chain1->AllowProcessToCreateChildWindowGroups(TUid::Uid(0x10205152)); //Secure ID - retVal = chain.ConstructChildApp(id1,2); - TEST(retVal==KErrNone); - if (retVal!=KErrNone) - INFO_PRINTF3(_L("chain.ConstructChildApp(id1,2) return value - Expected: %d, Actual: %d"), KErrNone, retVal); - - chain.Close(); - CleanupStack::PopAndDestroy(3,&ws2); - } - -void CTGwHandle::UnchainWindowGroupsL() - { - RArray* windowHandles=new(ELeave) RArray; - CleanupStack::PushL(windowHandles); - GetGwListL(0,windowHandles); - TInt shellWindow=windowHandles->Count(); - //Creating chained window groups. - CreateChainedGroupWindowsLC(TheClient->iWs); - GetGwListL(0,windowHandles); - //Test total window groups in the list - TInt retVal = windowHandles->Count(); - TEST(retVal==ENumChained+shellWindow); - if (retVal!=ENumChained+shellWindow) - INFO_PRINTF3(_L("windowHandles->Count() return value - Expected: %d, Actual: %d"), ENumChained+shellWindow, retVal); - //Two unchained group windows - - //Test Parent Id - TInt parentId=0; - for(TInt ii=ENumChained-1;ii>=0;ii--) - { - RWsSession::TWindowGroupChainInfo window; - window.iId=iChained[ii]->Identifier(); - TInt loc=windowHandles->Find(window); - TEST(loc!=KErrNotFound); - if (loc==KErrNotFound) - INFO_PRINTF3(_L("windowHandles->Find(window) return value - Expected: %d, Actual: %d"), KErrNotFound, loc); - - if(loc!=KErrNotFound) - { - TEST((*windowHandles)[loc].iParentId==parentId); - if ((*windowHandles)[loc].iParentId!=parentId) - INFO_PRINTF3(_L("(*windowHandles)[loc].iParentId==parentId - Expected: %d, Actual: %d"), parentId, (*windowHandles)[loc].iParentId); - - parentId=window.iId; - } - } - //Test unchaining of chained window groups - for(TInt count=ENumChained-1;count>=0;count--) - { - iChained[count]->Close(); - GetGwListL(0,windowHandles); - TEST(windowHandles->Count()== count+shellWindow); - if (windowHandles->Count()!= count+shellWindow) - INFO_PRINTF3(_L("windowHandles->Count()==count+shellWindow - Expected: %d, Actual: %d"), count+shellWindow, windowHandles->Count()); - - } - CleanupStack::PopAndDestroy(ENumChained,iChained[ENumChained-1]); - - //delete middle windowgroup of chain which should kill all the child windows - CreateChainedGroupWindowsLC(TheClient->iWs); - TInt windowPos=2; - CleanupStack::Pop(2,iChained[1]); //Pop first 2 items iChained[0] and iChained[1] - iChained[windowPos]->Close();//Close the 3rd WindowGroup in the chain.should unchain 4 and 5 window group. - CleanupStack::PopAndDestroy(iChained[windowPos]); - CleanupStack::PushL(TCleanupItem(&GwHandleDestroyWindow,iChained[1])); - CleanupStack::PushL(TCleanupItem(&GwHandleDestroyWindow,iChained[0])); - GetGwListL(0,windowHandles); - retVal = ChainedWindowCount(windowHandles); - TEST(retVal==ENumChained-windowPos-1); - if (retVal!=ENumChained-windowPos-1) - INFO_PRINTF3(_L("ChainedWindowCount(windowHandles) return value - Expected: %d, Actual: %d"), ENumChained-windowPos-1, retVal); - -// CleanupStack::PopAndDestroy(ENumChained-1,iChained[ENumChained-1]); - - windowPos=3; - CleanupStack::Pop(2,iChained[1]); - iChained[windowPos]->Close();//Close the 2nd WindowGroup in the chain. - //should unchain all . - CleanupStack::PopAndDestroy(iChained[windowPos]); - CleanupStack::PushL(TCleanupItem(&GwHandleDestroyWindow,iChained[1])); - CleanupStack::PushL(TCleanupItem(&GwHandleDestroyWindow,iChained[0])); - GetGwListL(0,windowHandles); - retVal = ChainedWindowCount(windowHandles); - TEST(retVal==ENumChained-windowPos-2); - if (retVal!=ENumChained-windowPos-2) - INFO_PRINTF3(_L("ChainedWindowCount(windowHandles) return value - Expected: %d, Actual: %d"), ENumChained-windowPos-2, retVal); - - windowPos=4; - CleanupStack::Pop(2,iChained[1]); - iChained[windowPos]->Close();//Closing parent window group in chain. There should be no chain - CleanupStack::PopAndDestroy(iChained[windowPos]); - CleanupStack::PushL(TCleanupItem(&GwHandleDestroyWindow,iChained[1])); - CleanupStack::PushL(TCleanupItem(&GwHandleDestroyWindow,iChained[0])); - GetGwListL(0,windowHandles); - retVal = ChainedWindowCount(windowHandles); - TEST(retVal==ENumChained-windowPos-1); - if (retVal!=ENumChained-windowPos-1) - INFO_PRINTF3(_L("ChainedWindowCount(windowHandles) return value - Expected: %d, Actual: %d"), ENumChained-windowPos-1, retVal); - - CleanupStack::PopAndDestroy(ENumChained-3,iChained[ENumChained-4]); - windowHandles->Close(); - CleanupStack::PopAndDestroy(windowHandles); - } - -TInt CTGwHandle::ChainedWindowCount(RArray* aWindowHandles) - { - TInt wndGrpCount=0; - for(TInt ii=0;iiCount();ii++) - { - if((*aWindowHandles)[ii].iParentId!=-1) - wndGrpCount++; - } - return wndGrpCount; - } - -void CTGwHandle::TestOrdinalPositionL() - { - TInt noOfGroupWnds = NumberOfWndGroupsWithZeroPriority(iTest->iScreenNumber); - //Creating the chained window groups - CreateChainedGroupWindowsLC(TheClient->iWs); - TestOrdinalPos(0); - //Test the ordinal position of all chained windows by setting the WndPos window - //to chainPos position - for(TInt wndPos=0;wndPosSetOrdinalPosition(chainPos); - TInt dung = chainPos-wndPos; - if(dung > noOfGroupWnds) - { - dung = noOfGroupWnds; - } - dung = Max(dung, 0); - TestOrdinalPos(chainPos - wndPos > noOfGroupWnds ? noOfGroupWnds : Max(chainPos - wndPos, 0)); - } - } - //Test for negative ordinal number - iChained[0]->SetOrdinalPosition(-2); - TestOrdinalPos(noOfGroupWnds); - CleanupStack::PopAndDestroy(ENumChained,iChained[ENumChained-1]); - } - -void CTGwHandle::TestOrdinalPositionNoDebugL() - { - TInt noOfGroupWnds = NumberOfWndGroupsWithZeroPriority(iTest->iScreenNumber); - //Creating the chained window groups - CreateChainedGroupWindowsLC(TheClient->iWs); - //Test the ordinal position of all chained windows - TestOrdinalPosNoDebug(0); - //Test the ordinal position of all chained windows by setting the WndPos window - //to chainPos position - for(TInt wndPos=0;wndPosSetOrdinalPosition(chainPos); - TestOrdinalPosNoDebug(chainPos - wndPos > noOfGroupWnds ? noOfGroupWnds : Max(chainPos - wndPos, 0)); - } - } - //Test for negative ordinal number - iChained[0]->SetOrdinalPosition(-2); - TestOrdinalPosNoDebug(noOfGroupWnds); - CleanupStack::PopAndDestroy(ENumChained,iChained[ENumChained-1]); - } - -void CTGwHandle::TestOrdinalPos(TInt aPos) - { - for(TInt ii=0;iiOrdinalPosition(); - TEST(iCha==aPos++); - if (iCha!=aPos-1) - { - INFO_PRINTF3(_L("iChained[ii]->OrdinalPosition() return value - Expected: %d, Actual: %d"), aPos-1, iCha); - } - } - } - -void CTGwHandle::TestOrdinalPosNoDebug(TInt aPos) - { - for(TInt ii=0;iiOrdinalPosition(); - TEST(iCha==aPos++); - if (iCha!=aPos-1) - INFO_PRINTF3(_L("iChained[ii]->OrdinalPosition() return value - Expected: %d, Actual: %d"), aPos-1, iCha); - - } - } - -void CTGwHandle:: TestclosingclientL() - { - RWsSession ws1; - User::LeaveIfError(ws1.Connect()); - CleanupClosePushL(ws1); - - // assign to the correct screen - CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws1); - CleanupStack::PushL(screen); - User::LeaveIfError(screen->Construct(iTest->iScreenNumber)); - - // Creating first Window Group - RWindowGroup gw1(ws1); - User::LeaveIfError(gw1.Construct(ENullWsHandle)); - ws1.SetWindowGroupOrdinalPosition(gw1.Identifier(),0); - - // Creating second Window Group - RWindowGroup gw2(ws1); - User::LeaveIfError(gw2.Construct(ENullWsHandle)); - gw2.SetOwningWindowGroup(gw1.Identifier()); - gw2.SetOrdinalPosition(1); - CleanupStack::PopAndDestroy(screen); - CleanupStack::PopAndDestroy(&ws1); - } - -void CTGwHandle::TestClearingAndSettingChildGroupsL() - { - RArray windowHandles; - CleanupClosePushL(windowHandles); - //Creating a chain of 5 window groups. - CreateChainedGroupWindowsLC(TheClient->iWs); - TInt ret=KErrNone; - // Want to test clearing and setting of window groups for chain lengths of 5 down to 2 - for(TInt jj=ENumChained-1;jj>0;jj--) - { - // For each window group in the chain, test clearing and setting a child group - for(TInt ii=jj;ii>0;ii--) - { - RWsSession::TWindowGroupChainInfo window1; - window1.iId=iChained[ii]->Identifier(); - GetGwListL(0,&windowHandles); - TInt loc=windowHandles.Find(window1); - TEST(loc!=KErrNotFound); - if(loc!=KErrNotFound) - { - RWsSession::TWindowGroupChainInfo window2; - window2.iId=iChained[ii-1]->Identifier(); - loc = windowHandles.Find(window2); - TEST(loc!=KErrNotFound); - // First test that the parent of the next window in the chain is the previous in the chain - if(loc!=KErrNotFound) - { - TEST(windowHandles[loc].iParentId==window1.iId); - } - // Then clear and test that the parent of the next window in the chain - // is no longer the previous window in the chain - ret=iChained[ii]->ClearChildGroup(); - TEST(ret==KErrNone); - // Try to clear a child group when it's already cleared - should return KErrArgument - ret=iChained[ii]->ClearChildGroup(); - TEST(ret==KErrArgument); - GetGwListL(0,&windowHandles); - loc = windowHandles.Find(window2); - TEST(loc!=KErrNotFound); - // Test that it has no parent (0) or is unchained (-1) - if(loc!=KErrNotFound) - { - if(ii==1) // last in chain therefore unchained, should return -1 - TEST(windowHandles[loc].iParentId==-1); - else // otherwise should return 0 signifying in a chain but with no parent - TEST(windowHandles[loc].iParentId==0); - } - // Reset the former child group as a child to the current group - ret=iChained[ii]->SetChildGroup(window2.iId); - TEST(ret==KErrNone); - // Test that it has now got it's parent back - GetGwListL(0,&windowHandles); - loc = windowHandles.Find(window2); - TEST(loc!=KErrNotFound); - if(loc!=KErrNotFound) - { - TEST(windowHandles[loc].iParentId==window1.iId); - } - } - } - // Reduce chain length by 1 - ret=iChained[jj]->ClearChildGroup(); - TEST(ret==KErrNone); - } - // Try to clear the child group of a window that's not in a queue - returns KErrArgument - ret=iChained[0]->ClearChildGroup(); - TEST(ret==KErrArgument); - // Test calling set on a non-existent window group - fictional id, larger than what exists - ret=iChained[0]->SetChildGroup(9999); - TEST(ret==KErrArgument); - // Cleanup - CleanupStack::PopAndDestroy(ENumChained,iChained[ENumChained-1]); - CleanupStack::PopAndDestroy(&windowHandles); - } - -void CTGwHandle::TestAgainstLoopsWhenAddingChildGroupsL() - { - //Creating two chains of 5 window groups. - CreateChainedGroupWindowsLC(TheClient->iWs,ETrue); - TInt ret=KErrNone; - - //Try to append any of element of this chain to the lastone (itself included) - //All these attempts should fail (otherwise a infinite loop will be set up) - for(TInt ii=ENumChained-1;ii>=0;ii--) - { - TInt windowId = iChained[ii]->Identifier(); - // Try to append it to the last one - ret=iChained[0]->SetChildGroup(windowId); - TEST(ret==KErrArgument); - if(ret!=KErrArgument) - { - _LIT(KLog,"Error: SetChildGroup with a GpWin belonging to the same queue succeeded, return value :%d"); - LOG_MESSAGE2(KLog,ret); - } - } - //Try to append any elements belonging to another chain to the last one of this chain - //All these trials should fail (otherwise a infinite loop will be set up) - //Except for the parent of the second chain. - for(TInt ii=0;iiIdentifier(); - // Try to append it to the last one - ret=iChained[0]->SetChildGroup(windowId); - if(ii != ENumChained-1) - { - TEST(ret==KErrArgument); - if(ret!=KErrArgument) - { - _LIT(KLog,"Error: SetChildGroup with a GpWin which already has a parent succeeded, return value :%d"); - LOG_MESSAGE2(KLog,ret); - } - iChained[0]->ClearChildGroup(); - } - else - { - TEST(ret==KErrNone); - if(ret!=KErrNone) - { - _LIT(KLog,"Error: SetChildGroup with a GpWin with no parent failed, return value :%d"); - LOG_MESSAGE2(KLog,ret); - } - } - } - TInt windowId = iChained2[ENumChained-1]->Identifier(); - ret=iChained[ENumChained-1]->SetChildGroup(windowId); - TEST(ret==KErrArgument); - if(ret!=KErrArgument) - { - _LIT(KLog,"Error: SetChildGroup successful on a GpWin which already has a child, return value :%d"); - LOG_MESSAGE2(KLog,ret); - } - //Now take a window group not belonging to any queue - //just take the parent's chain and pop it - //and try to append it to itself - ret=iChained[ENumChained-1]->ClearChildGroup(); - TEST(ret==KErrNone); - ret=iChained[ENumChained-1]->SetChildGroup(iChained[ENumChained-1]->Identifier()); - TEST(ret==KErrArgument); - if(ret!=KErrArgument) - { - _LIT(KLog,"Error: Setting GpWin as a child of itself succeeded, return value :%d"); - LOG_MESSAGE2(KLog,ret); - } - CleanupStack::PopAndDestroy(ENumChained+ENumChained,iChained[ENumChained-1]); - } -void CTGwHandle::RunTestCaseL(TInt /*aCurTestCase*/) - { - _LIT(KTest0,"Window group names"); - _LIT(KTest1,"Window group identifiers"); - _LIT(KTest2,"Owner to foreground"); - _LIT(KTest3,"FindWindowGroupIdentifier test"); - _LIT(KTest4,"IdentifierWrapAround test"); - _LIT(KTest5,"DefaultOwningWindow test"); - _LIT(KTest6,"DefaultOwningWindow2 test"); - _LIT(KTest7,"Window Group Chaining"); - _LIT(KTest8,"Window Group Chaining2"); - _LIT(KTest9,"Unchaining window group"); - _LIT(KTest10,"Ordinal Postion Test"); - _LIT(KTest11,"CrashTest on closing client"); - _LIT(KTest12,"Setting and Clearing Child Groups"); - _LIT(KTest13,"No Infinite Loops in Setting Child Groups"); - ((CTGwHandleStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); - switch(++iTest->iState) - { -/** - - @SYMTestCaseID GRAPHICS-WSERV-0316 - - @SYMDEF DEF081259 - - @SYMTestCaseDesc Test setting window group names - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions Set the name of a window group to different values and check the - value is set correctly - - @SYMTestExpectedResults The window group name is set correctly - -*/ - case 1: - ((CTGwHandleStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0316")); - //iState=9; break; - iTest->LogSubTest(KTest0); - GwNamesL(); - break; -/** - - @SYMTestCaseID GRAPHICS-WSERV-0317 - - @SYMDEF DEF081259 - - @SYMTestCaseDesc Test setting window group identifiers - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions Set the identifiers of a window groups. manipulate the window groups and - check the identifiers remain correct - - @SYMTestExpectedResults The identifiers are correct for each window group after - manipulation - -*/ - case 2: - ((CTGwHandleStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0317")); - iTest->LogSubTest(KTest1); - GwIdentifierTestL(); - break; -/** - - @SYMTestCaseID GRAPHICS-WSERV-0318 - - @SYMDEF DEF081259 - - @SYMTestCaseDesc Test moving different window groups to the foreground and bringing - back the backgorund - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions Create some window groups and move them in turn to the foreground before - restoring the background - - @SYMTestExpectedResults Window groups move to and from the foreground with error - -*/ - case 3: - ((CTGwHandleStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0318")); - iTest->LogSubTest(KTest2); - OwnerToForegroundL(); - break; -/** - - @SYMTestCaseID GRAPHICS-WSERV-0319 - - @SYMDEF DEF081259 - - @SYMTestCaseDesc Test returning different window groups identifiers by searching - on the name - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions Create some window groups and return their identifiers by searching on - their names - - @SYMTestExpectedResults The correct identifiers are returned for each name - -*/ - case 4: - ((CTGwHandleStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0319")); - iTest->LogSubTest(KTest3); - FindWindowGroupIdentifierTestL(); - break; -/** - - @SYMTestCaseID GRAPHICS-WSERV-0320 - - @SYMDEF DEF081259 - - @SYMTestCaseDesc Test that a windows group identifier is not used twice - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions Assign a window group identifier to one window group and check - the same identifier can not be used for a second group - - @SYMTestExpectedResults Window group identifier can not be reused - -*/ - case 5: - ((CTGwHandleStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0320")); - iTest->LogSubTest(KTest4); - IdentifierWrapAroundTestL(); - break; -/** - - @SYMTestCaseID GRAPHICS-WSERV-0321 - - @SYMDEF DEF081259 - - @SYMTestCaseDesc Test that the default owning window for window groups is set - correctly - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions Set different default owning windows for different window groups. - Check the windows have been set correctly. - - @SYMTestExpectedResults The default owning windows for the groups are set correctly - -*/ - case 6: - ((CTGwHandleStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0321")); - iTest->LogSubTest(KTest5); - DefaultOwningWindowL(); - break; -/** - - @SYMTestCaseID GRAPHICS-WSERV-0322 - - @SYMDEF DEF081259 - - @SYMTestCaseDesc Test that the default owning window for window groups is set - correctly - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions Set different default owning windows for different window groups. - Check the windows have been set correctly. - - @SYMTestExpectedResults The default owning windows for the groups are set correctly - -*/ - case 7: - ((CTGwHandleStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0322")); - iTest->LogSubTest(KTest6); - DefaultOwningWindow2L(); - TheClient->iGroup->WinTreeNode()->SetOrdinalPosition(0); - break; -/** - - @SYMTestCaseID GRAPHICS-WSERV-0323 - - @SYMDEF DEF081259 - - @SYMTestCaseDesc Test that window groups can be chained correctly - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions Create a chain of window groups and check that the chain of groups - can be manipluated correctly - - @SYMTestExpectedResults The chain can be manipulated correctly - -*/ - case 8: - ((CTGwHandleStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0323")); - iTest->LogSubTest(KTest7); - WindowGroupChaining(); - break; -/** - - @SYMTestCaseID GRAPHICS-WSERV-0324 - - @SYMDEF DEF081259 - - @SYMTestCaseDesc Test that window groups can be chained correctly - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions Create a chain of window groups and check that the chain of groups - can be manipluated correctly - - @SYMTestExpectedResults The chain can be manipulated correctly - -*/ - case 9: - ((CTGwHandleStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0324")); - iTest->LogSubTest(KTest8); - WindowGroupChaining2(); - break; -/** - - @SYMTestCaseID GRAPHICS-WSERV-0325 - - @SYMDEF DEF081259 - - @SYMTestCaseDesc Test that window groups can be unchained correctly - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions Create chains of window groups and check that the window groups can be - unchained correctly - - @SYMTestExpectedResults The chain can be unchained correctly - -*/ - case 10: - ((CTGwHandleStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0325")); - iTest->LogSubTest(KTest9); - UnchainWindowGroupsL(); - break; -/** - - @SYMTestCaseID GRAPHICS-WSERV-0326 - - @SYMDEF DEF081259 - - @SYMTestCaseDesc Test the ordinal position of chained window groups - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions Create chains of window groups and check their ordinal position is correct - for different scenarios - - @SYMTestExpectedResults Ordinal position of chained window group is correct - -*/ - case 11: - ((CTGwHandleStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0326")); - iTest->LogSubTest(KTest10); - TestOrdinalPositionL(); - break; - case 12: - ((CTGwHandleStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0326")); - iTest->LogSubTest(KTest10); - TestOrdinalPositionNoDebugL(); - break; -/** - - @SYMTestCaseID GRAPHICS-WSERV-0327 - - @SYMDEF DEF081259 - - @SYMTestCaseDesc Test that window groups are dealt with correctly if their client is closed - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions Create window groups and then close there client. - - @SYMTestExpectedResults The window groups of the closed client are handled without error - -*/ - case 13: - ((CTGwHandleStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0327")); - iTest->LogSubTest(KTest11); - TestclosingclientL(); - break; - case 14: - ((CTGwHandleStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0327")); - iTest->LogSubTest(KTest12); - TestClearingAndSettingChildGroupsL(); - break; - case 15: - ((CTGwHandleStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0327")); - iTest->LogSubTest(KTest13); - TestAgainstLoopsWhenAddingChildGroupsL(); - break; - default: - ((CTGwHandleStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - ((CTGwHandleStep*)iStep)->CloseTMSGraphicsStep(); - TestComplete(); - break; - } - ((CTGwHandleStep*)iStep)->RecordTestResultL(); - } - -__WS_CONSTRUCT_STEP__(GwHandle) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TGWHANDLE.H --- a/windowing/windowserver/tauto/TGWHANDLE.H Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,94 +0,0 @@ - -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef __TGWHANDLE_H__ -#define __TGWHANDLE_H__ - -#include -#include -#include "../tlib/testbase.h" -#include "AUTO.H" -#include "TGraphicsHarness.h" - -class CTGwHandle : public CTWsGraphicsBase - { -public: - CTGwHandle(CTestStep* aStep); - ~CTGwHandle(); - void ConstructL(); - TInt NumberOfWndGroupsWithZeroPriority(TInt aScreenNumber); - void GetGwListL(CArrayFixFlat *aWindowHandles); - void GetGwListL(CArrayFixFlat *aWindowHandles, TInt aScreenNumber); - void GetGwListL(TInt aPriority, CArrayFixFlat *aWindowHandles); - void GetGwListL(RArray* aWindowHandles); - void GetGwListL(TInt aPriority, RArray* aWindowHandles); - void GwNamesL(); - void GwIdentifierTestL(); - void OwnerToForegroundL(); - void FindWindowGroupIdentifierTestL(); - void IdentifierWrapAroundTestL(); - void DefaultOwningWindowL(); - void DefaultOwningWindow2L(); - void WindowGroupChaining(); - void WindowGroupChaining2(); - void UnchainWindowGroupsL(); - void TestclosingclientL(); - void TestClearingAndSettingChildGroupsL(); -protected: -//from CTGraphicsStep - virtual void RunTestCaseL(TInt aCurTestCase); -private: - enum {ENumGroups=10,ENumChained=5}; -private: - RWindowGroup* CreateWindowGroupLC(RWsSession& aWs,TUint32 aClientHandle,TInt aParentId=0); - void CreateGroupWindowsLC(RWsSession& aWs); - void CreateChainedGroupWindowsLC(RWsSession& aWs,TBool aSecondChain = EFalse); - void TestAgainstLoopsWhenAddingChildGroupsL(); - void MoveGroups(RWindowGroup** aGroups,TInt aGp,TInt aNum,TInt aPos,TInt aInc=2); - void TestGroups(TInt aPos); - void TestGroupsBefore(TInt aPos); - void TestOrdinalPositionL(); - void TestOrdinalPositionNoDebugL(); - void TestOrdinalPos(TInt awndPos); - void TestOrdinalPosNoDebug(TInt awndPos); - TInt ChainedWindowCount(RArray*); -private: - TFullName iFullName; - TSize iWinSize; - RWindowGroup* iGroups[ENumGroups]; - RWindowGroup* iChained[ENumChained]; - RWindowGroup* iChained2[ENumChained]; - }; - -class CTGwHandleStep : public CTGraphicsStep - { -public: - CTGwHandleStep(); -protected: - //from CTGraphicsStep - virtual CTGraphicsBase* CreateTestL(); - }; - -_LIT(KTGwHandleStep,"TGwHandle"); - - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/THeartBeat.CPP --- a/windowing/windowserver/tauto/THeartBeat.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,659 +0,0 @@ -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Test the Wserv heart beat switch on and off -// -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include "THeartBeat.h" -#include - -CTHeartBeatTest::CTHeartBeatTest(CTestStep* aStep) : - CTWsGraphicsBase(aStep) - { - } - -CTHeartBeatTest::~CTHeartBeatTest() - { - iAnimDll.Close(); - delete iHbTestWin; - } - -void CTHeartBeatTest::ConstructL() - { - TSize screenSize=TheClient->iGroup->Size(); - TInt winWidth=(screenSize.iWidth/3)-10; - TInt winHeight=screenSize.iHeight-10; - iHbTestWin=new(ELeave) CAnimWindow(EFalse, CAnimWindow::ERedraw); - iHbTestWin->ConstructL(TPoint(screenSize.iWidth/3*2+5,5),TSize(winWidth,winHeight)); - iAnimDll=RAnimDll(TheClient->iWs); - User::LeaveIfError(iAnimDll.Load(KAnimDLLName)); - } - -void CTHeartBeatTest::SetCursor(const TPoint& aPos,const TSize& aSize, TUint aFlags/*=0*/) - { // Default aFlags=0 gives a flashing cursor - TTextCursor tc; - tc.iType=TTextCursor::ETypeRectangle; - tc.iHeight=aSize.iHeight; - tc.iAscent=aSize.iHeight*4/5; - tc.iWidth=aSize.iWidth; - tc.iFlags=aFlags; - tc.iColor=KRgbGreen; - TheClient->iGroup->GroupWin()->SetTextCursor(*iHbTestWin->BaseWin(),TPoint(aPos.iX,aPos.iY+tc.iAscent),tc); - } - -TBool CTHeartBeatTest::SetAutoHeartBeatPauseState(TBool aState) const - { - return(TheClient->iWs.DebugInfo(EWsDebugSetAutoHeartBeatPauseState,aState)); - } - -TBool CTHeartBeatTest::GetHeartBeatTimerState() const - { - return(TheClient->iWs.DebugInfo(EWsDebugHeartBeatState)); - } - -void CTHeartBeatTest::CancelTextCursor() - { - TheClient->iGroup->GroupWin()->CancelTextCursor(); - } - -void CTHeartBeatTest::TestTextCursorTimerL() - { - TEST(!GetHeartBeatTimerState()); - SetCursor(TPoint(0,0),TSize(10,10)); - TEST(GetHeartBeatTimerState()); - CancelTextCursor(); - TEST(!GetHeartBeatTimerState()); -// - TPoint testCursorPos; - TSize testCursorSize(10,10); - SetCursor(testCursorPos,testCursorSize); - TEST(GetHeartBeatTimerState()); - iHbTestWin->BaseWin()->SetVisible(EFalse); - TEST(!GetHeartBeatTimerState()); - iHbTestWin->BaseWin()->SetVisible(ETrue); - TEST(GetHeartBeatTimerState()); -// -// Cover the cursor and check heartbeat disabled - RWindow coverCursor(TheClient->iWs); - CleanupClosePushL(coverCursor); - User::LeaveIfError(coverCursor.Construct(*iHbTestWin->BaseWin(), 0xBADBAD)); - coverCursor.SetExtent(testCursorPos,testCursorSize); - coverCursor.Activate(); - TEST(!GetHeartBeatTimerState()); -// Now fractionally expose the cursor and check heartbeat re-enabled - coverCursor.SetExtent(testCursorPos+TPoint(1,1),testCursorSize); - TEST(GetHeartBeatTimerState()); -// Re-cover it - coverCursor.SetExtent(testCursorPos,testCursorSize); - TEST(!GetHeartBeatTimerState()); -// Enlarge cursor to expose itself then check heartbeat - SetCursor(testCursorPos,TSize(testCursorSize.iWidth+1,testCursorSize.iHeight)); - TEST(GetHeartBeatTimerState()); -// Shrink cursor then check heartbeat - SetCursor(testCursorPos,testCursorSize); - TEST(!GetHeartBeatTimerState()); -// Turn off auto heart beat pausing, should turn timer back on - SetAutoHeartBeatPauseState(EFalse); - TEST(GetHeartBeatTimerState()); -// With auto pausing enabled covering/uncovering the cursor should have no effect, -// timer will always be on - coverCursor.SetVisible(EFalse); - TEST(GetHeartBeatTimerState()); - coverCursor.SetVisible(ETrue); - TEST(GetHeartBeatTimerState()); -// Re-enable auto-pause should turn timer back off - SetAutoHeartBeatPauseState(ETrue); - TEST(!GetHeartBeatTimerState()); -// Destroy covering window and check heartbeat re-enabled - CleanupStack::PopAndDestroy(&coverCursor); - TEST(GetHeartBeatTimerState()); -// Check using no flash flag turns timer off - SetCursor(testCursorPos,testCursorSize,TTextCursor::EFlagNoFlash); - TEST(!GetHeartBeatTimerState()); -// and turning no flash flag off turns timer back on - SetCursor(testCursorPos,testCursorSize); - TEST(GetHeartBeatTimerState()); -// Preparing for switch off should disable the heartbeat until another event is received - TheClient->iWs.PrepareForSwitchOff(); - TEST(!GetHeartBeatTimerState()); -// Any event should wake the hearbeat back up again - TRawEvent rawEvent; - rawEvent.Set(TRawEvent::EPointerMove,0,0); - TheClient->iWs.SimulateRawEvent(rawEvent); - TEST(GetHeartBeatTimerState()); -// - CancelTextCursor(); - TEST(!GetHeartBeatTimerState()); -// Check heartbeat still off as expected - TheClient->iWs.PrepareForSwitchOff(); - TEST(!GetHeartBeatTimerState()); -// Check when hearbeat not required that it's not turned back when coming out of PrepareForSwitchOff() mode. - TheClient->iWs.SimulateRawEvent(rawEvent); - TheClient->Flush(); - TEST(!GetHeartBeatTimerState()); - } - -void CTHeartBeatTest::doTestActiveInactiveEvents(TBool aCursorOn, TBool aAutoPauseOn) - { - SetAutoHeartBeatPauseState(aAutoPauseOn); - if (aCursorOn) - SetCursor(TPoint(0,0),TSize(10,10)); -// Should disable timer, regardless of other states - TRawEvent event; - event.Set(TRawEvent::EInactive); - UserSvr::AddEvent(event); - TEST(!GetHeartBeatTimerState()); -// ...and switch it back on - event.Set(TRawEvent::EActive); - UserSvr::AddEvent(event); - TBool testResult1=EFalse; - if (aAutoPauseOn) - testResult1=aCursorOn; // Only on if cursor is on without auto pause enabled - else - testResult1=ETrue; // Always on if auto pause disabled - TBool hbState=GetHeartBeatTimerState(); - if ((!hbState)!=(!testResult1)) - { - _LIT(KLog,"Fail in TestActiveInactiveEvents(%d.%d) HBState=%d result=%d"); - LOG_MESSAGE5(KLog,aCursorOn,aAutoPauseOn,hbState,testResult1); - } - TEST((!GetHeartBeatTimerState())==(!testResult1)); //Works with any positive value for True -// - if (aCursorOn) - CancelTextCursor(); - } - -void CTHeartBeatTest::TestActiveInactiveEvents() - { - doTestActiveInactiveEvents(EFalse,EFalse); - doTestActiveInactiveEvents(ETrue,EFalse); - doTestActiveInactiveEvents(EFalse,ETrue); - doTestActiveInactiveEvents(ETrue,ETrue); - } - -void CTHeartBeatTest::FailCursorHbTest(const TDesC& aErrorBase, const TDesC* aExtraText, TBool aHbState, TBool aHbCheckState) - { - TBuf<256> error(aErrorBase); - if (aExtraText) - { - error.Append(*aExtraText); - } - _LIT(KHbErrorAppendFmt," HB=%d (Testing for %d)"); - error.AppendFormat(KHbErrorAppendFmt,aHbState,aHbCheckState); - LOG_MESSAGE(error); - TEST(EFalse); - } - -TBool CTHeartBeatTest::ChangeTransAndCheckHeartBeat(TInt aTestMode, RWindow& aTransWin, const TRect& aGraphicRect, TInt aExtraWinTestMode, const TDesC* aErrorMsg, TBool aSetVisibleAfterTransUpdate) - { - TRect cursorRect(aGraphicRect); - cursorRect.Move(iHbTestWin->BaseWin()->InquireOffset(aTransWin)); - TRect winRect(aTransWin.Size()); - __ASSERT_ALWAYS(winRect.Contains(cursorRect.iTl) && winRect.Contains(cursorRect.iBr),AutoPanic(EAutoPanicHeartBeatCursorRect)); -// - TRegionFix<8> transRegion; - TBool heartBeatCheck=EFalse; - switch(aTestMode) - { - case ECursorTransWinTestModeFullTrans: - transRegion.AddRect(winRect); - heartBeatCheck=ETrue; - break; - case ECursorTransWinTestNoTrans: - break; - case ECursorTransWinTestPartialTransCoveringCursor: - transRegion.AddRect(winRect); - transRegion.SubRect(cursorRect); - break; - case ECursorTransWinTestPartialTransExposingCursor: - transRegion.AddRect(cursorRect); - heartBeatCheck=ETrue; - break; - default: - ASSERT(EFalse); - } - TBool invisHeartBeatCheck=ETrue; - switch(aExtraWinTestMode) - { - case ECursorTransWinTestNoTrans: - case ECursorTransWinTestPartialTransCoveringCursor: - heartBeatCheck=EFalse; - invisHeartBeatCheck=EFalse; - break; - default: - break; - } -// - ASSERT(!transRegion.CheckError()); - if (aSetVisibleAfterTransUpdate) - aTransWin.SetVisible(EFalse); - aTransWin.SetTransparentRegion(transRegion); - if (aSetVisibleAfterTransUpdate) - aTransWin.SetVisible(ETrue); -// - TBool testSuccess=ETrue; - TBool heartBeatState=GetHeartBeatTimerState(); - TBool failed1stTest=EFalse; - if ((!heartBeatState)!=(!heartBeatCheck)) //Works with any positive value for True - { - failed1stTest=ETrue; - _LIT(KFailedHbTest,"Failed "); - FailCursorHbTest(KFailedHbTest,aErrorMsg,heartBeatState,heartBeatCheck); - testSuccess=EFalse; - } -// - aTransWin.SetVisible(EFalse); - heartBeatState=GetHeartBeatTimerState(); - _LIT(KGoingInvisAfterTestAppend," after %S"); - TBuf<256> errorExtra; - if (aErrorMsg) - { - errorExtra.Format(KGoingInvisAfterTestAppend,aErrorMsg); - } - if ((!heartBeatState)!=(!invisHeartBeatCheck)) //Works with any positive value for True - { - _LIT(KFailedGoingInvis,"Failed setting trans win invisible"); - FailCursorHbTest(KFailedGoingInvis,&errorExtra,heartBeatState,invisHeartBeatCheck); - testSuccess=EFalse; - } -// - aTransWin.SetVisible(ETrue); - heartBeatState=GetHeartBeatTimerState(); - if (!failed1stTest && (!heartBeatState)!=(!heartBeatCheck)) //Works with any positive value for True - { - _LIT(KFailedResettingVis,"Failed re-setting trans win visible"); - FailCursorHbTest(KFailedResettingVis,&errorExtra,heartBeatState,heartBeatCheck); - testSuccess=EFalse; - } - return(testSuccess); - } - -void CTHeartBeatTest::LoopThroughTransWinTestModes(RWindow& aTransWin, const TRect& aGraphicRect, TInt aExtraWinTestMode) - { - TBuf<256> error; - for(TInt setVisMode=0;setVisMode<2;setVisMode++) - { - if (setVisMode==0) - continue; // zzz setinvis/makevis needed to flush out changes it seems - const TBool setVisibleAfterTransUpdate=setVisMode>0; - for(TInt startTestMode=0;startTestModeiWs); - User::LeaveIfError(transWin1.Construct(*TheClient->iGroup->GroupWin(),0xDEADBAD1)); - CleanupClosePushL(transWin1); - if (transWin1.SetTransparencyFactor(TRgb::Gray256(128))!=KErrNone) - { // Transparency not enabled, skip tests - CleanupStack::PopAndDestroy(&transWin1); - return; - } - transWin1.Activate(); - TEST(GetHeartBeatTimerState()); -// First simply check activating default full screen transparent window doesn't disable the heartbeat - _LIT(KBasicTransCursorTests,"Running basic transparent window cursor heartbeat tests"); - LOG_MESSAGE(KBasicTransCursorTests); - LoopThroughTransWinTestModes(transWin1, aGraphicRect, ECursorTransWinTestNA); -// -// Lots of test code disabled due to bugs in handling of transparent window regions -// See DEF110677, hopefully when the issues in there are addressed the rest of the -// test code here can be enabled -// See sections marked with zzz for places where certain tests are disabled, once DEF110677 -// is marked as fixed these sections should be re-enabled and if problems still occur they -// need to be investigated. -// -// -// Now check more complex modes with two transparent windows over the test window - RWindow transWin2(TheClient->iWs); - User::LeaveIfError(transWin2.Construct(*TheClient->iGroup->GroupWin(),0xDEADBAD2)); - CleanupClosePushL(transWin2); - User::LeaveIfError(transWin2.SetTransparencyFactor(TRgb::Gray256(128))); - TSize screenSize=TheClient->iGroup->Size(); - screenSize.iWidth-=10; - transWin1.SetExtent(TPoint(0,0),screenSize); - transWin2.SetExtent(TPoint(10,0),screenSize); - transWin2.Activate(); - for(TInt win1OrdPos=0;win1OrdPos<2;win1OrdPos++) - { - transWin1.SetOrdinalPosition(win1OrdPos); - _LIT(KOrdinalTransCursorTests,"Running tests with transwin1 ordinal pos=%d"); - LOG_MESSAGE2(KOrdinalTransCursorTests,win1OrdPos); - for(TInt topWinTestMode=0;topWinTestMode msg; - msg.Format(KTopTransWinCursorTest,topWinTestMode); - LOG_MESSAGE(msg); - ChangeTransAndCheckHeartBeat(0, transWin2, aGraphicRect, topWinTestMode, NULL, ETrue); - LoopThroughTransWinTestModes(transWin1, aGraphicRect, topWinTestMode); - } - } - ChangeTransAndCheckHeartBeat(0, transWin2, aGraphicRect, 0, NULL, ETrue); - CleanupStack::PopAndDestroy(&transWin2); - TEST(GetHeartBeatTimerState()); -// - CleanupStack::PopAndDestroy(&transWin1); - TEST(GetHeartBeatTimerState()); - } - -void CTHeartBeatTest::TestTextCursorTimerTransL() - { - TSize testWinSize(iHbTestWin->BaseWin()->Size()); - TRect cursorRect(testWinSize.iWidth/4,testWinSize.iHeight/3,testWinSize.iWidth*3/4,testWinSize.iHeight*2/3); - TEST(!GetHeartBeatTimerState()); - SetCursor(cursorRect.iTl,cursorRect.Size()); - TEST(GetHeartBeatTimerState()); - RunTransWinTestsL(cursorRect); - CancelTextCursor(); - TEST(!GetHeartBeatTimerState()); - } - -void CTHeartBeatTest::TestHeartBeatStopStart(TBool aHeartbeatStateOff,TBool aHeartbeatStateOn,const TDesC& aOffText,const TDesC& aOnText) - { - TEST(!aHeartbeatStateOff); - if (aHeartbeatStateOff) - LOG_MESSAGE2(_L("%S failed to disable heartbeat timer"),&aOffText); - TEST(aHeartbeatStateOn); - if (!aHeartbeatStateOn) - LOG_MESSAGE2(_L("%S failed to re-enable heartbeat timer"),&aOnText); - } - -void CTHeartBeatTest::TestAnimDllL(TBool aSpriteMode, TUint aSpriteFlags) - { - RTestAnim anim(iAnimDll); - TEST(!GetHeartBeatTimerState()); - TSize testWinSize(iHbTestWin->BaseWin()->Size()); - TRect animRect(1,1,testWinSize.iWidth/3,testWinSize.iWidth/5); - TPckgC rectPckg(animRect); - RWsSprite sprite(TheClient->iWs); - CleanupClosePushL(sprite); - if (aSpriteMode) - { - sprite.Construct(*iHbTestWin->BaseWin(),TPoint(),aSpriteFlags); - CFbsBitmap* bitmap1=new(ELeave) CFbsBitmap(); - CleanupStack::PushL(bitmap1); - CFbsBitmap* bitmap2=new(ELeave) CFbsBitmap(); - CleanupStack::PushL(bitmap2); - CFbsBitmap* bitmap3=new(ELeave) CFbsBitmap(); - CleanupStack::PushL(bitmap3); - TSize animSize(animRect.Size()); - User::LeaveIfError(bitmap1->Create(TSize(animSize.iWidth/2,animSize.iHeight/2),EGray4)); - User::LeaveIfError(bitmap2->Create(TSize(animSize.iWidth,animSize.iHeight/3),EGray4)); - User::LeaveIfError(bitmap3->Create(TSize(animSize.iWidth/3,animSize.iHeight),EGray4)); -// - TSpriteMember member1; - member1.iMaskBitmap=NULL; - member1.iInvertMask=EFalse; - member1.iDrawMode=CGraphicsContext::EDrawModePEN; - member1.iOffset=TPoint(); - member1.iInterval=TTimeIntervalMicroSeconds32(1); - member1.iBitmap=bitmap1; - member1.iMaskBitmap=bitmap1; - sprite.AppendMember(member1); -// - TSpriteMember member2; - member2.iInvertMask=EFalse; - member2.iDrawMode=CGraphicsContext::EDrawModeXOR; - member2.iOffset=TPoint(1,2); - member2.iInterval=TTimeIntervalMicroSeconds32(2); - member2.iBitmap=bitmap2; - member2.iMaskBitmap=bitmap2; - sprite.AppendMember(member2); -// - TSpriteMember member3; - member3.iInvertMask=ETrue; - member3.iDrawMode=CGraphicsContext::EDrawModeOR; - member3.iOffset=TPoint(3,4); - member3.iInterval=TTimeIntervalMicroSeconds32(3); - member3.iBitmap=bitmap3; - member3.iMaskBitmap=bitmap3; - sprite.AppendMember(member3); -// - User::LeaveIfError(anim.Construct(sprite,EAnimTypeSprite,rectPckg)); - CleanupStack::PopAndDestroy(3,bitmap1); - } - else - { - User::LeaveIfError(anim.Construct(*iHbTestWin->BaseWin(),EAnimTypeTest3,rectPckg)); - } - CleanupClosePushL(anim); - TEST(GetHeartBeatTimerState()); - - // Cover up the window with the animation and check this disables the heartbeat timer. - RBlankWindow blankwin1(TheClient->iWs); - User::LeaveIfError(blankwin1.Construct(*TheClient->iGroup->GroupWin(),123)); - TPoint winOffset(iHbTestWin->BaseWin()->InquireOffset(*TheClient->iGroup->GroupWin())); - if (aSpriteMode) - blankwin1.SetExtent(winOffset,testWinSize); - else - blankwin1.SetExtent(winOffset+animRect.iTl,animRect.Size()); - blankwin1.Activate(); - TBool heartbeatStateOff=GetHeartBeatTimerState(); - TEST(!heartbeatStateOff); - if (heartbeatStateOff) - { - LOG_MESSAGE(_L("Covering window failed to disable heartbeat timer")); - } - TBool heartbeatStateOn; - if (!aSpriteMode) - { - // Resize the anim so it becomes visible, then shrink back down again - animRect.iBr.iX++; - anim.Command(EADllSetRect,rectPckg); - heartbeatStateOn=GetHeartBeatTimerState(); - animRect.iBr.iX--; - anim.Command(EADllSetRect,rectPckg); - heartbeatStateOff=GetHeartBeatTimerState(); - TestHeartBeatStopStart(heartbeatStateOff,heartbeatStateOn,_L("Shrinking anim"),_L("Growing anim")); - } -// - blankwin1.Close(); - heartbeatStateOn=GetHeartBeatTimerState(); - TEST(heartbeatStateOn); - if (!heartbeatStateOn) - { - LOG_MESSAGE(_L("Un-covering window failed to disable heartbeat timer")); - } - - // Put a transparent window over the animation and check the heartbeat timer is not disabled - RWindow transWin(TheClient->iWs); - User::LeaveIfError(transWin.Construct(*TheClient->iGroup->GroupWin(),123)); - if (transWin.SetTransparencyFactor(TRgb::Gray256(128))==KErrNone) - { - transWin.Activate(); - heartbeatStateOn=GetHeartBeatTimerState(); - TEST(heartbeatStateOn); - if (!heartbeatStateOn) - LOG_MESSAGE(_L("Transparent window caused heartbeat timer to be disabled")); - TRegionFix<1> emptyRegion; - transWin.SetTransparentRegion(emptyRegion); - heartbeatStateOff=GetHeartBeatTimerState(); - TRegionFix<1> fullRegion(transWin.Size()); - transWin.SetTransparentRegion(fullRegion); - heartbeatStateOn=GetHeartBeatTimerState(); - TestHeartBeatStopStart(heartbeatStateOff,heartbeatStateOn,_L("Making covering window opaque"),_L("Making covering window transparent")); - if (aSpriteMode) - { - RBlankWindow blankwin2(TheClient->iWs); - User::LeaveIfError(blankwin2.Construct(*iHbTestWin->BaseWin(),1234)); - blankwin2.Activate(); - heartbeatStateOn=GetHeartBeatTimerState(); - // With ESpriteNoChildClip the heartbeat should still be on as the sprite will still be visible - // Without it blankwin2 will cover up the sprite and cancel the heartbeat - TBool heartBeatCheck=aSpriteFlags&ESpriteNoChildClip; - TEST((!heartbeatStateOn)==(!heartBeatCheck)); //Works with any positive value for True - blankwin2.Close(); - } - transWin.SetTransparentRegion(emptyRegion); - heartbeatStateOff=GetHeartBeatTimerState(); - transWin.Close(); - heartbeatStateOn=GetHeartBeatTimerState(); - TestHeartBeatStopStart(heartbeatStateOff,heartbeatStateOn,_L("Making covering window opaque"),_L("Un-covering window")); - } - else - transWin.Close(); - - // Make the window with the animation invisible and check this disables the heartbeat timer. - iHbTestWin->BaseWin()->SetVisible(EFalse); - heartbeatStateOff=GetHeartBeatTimerState(); - iHbTestWin->BaseWin()->SetVisible(ETrue); - heartbeatStateOn=GetHeartBeatTimerState(); - TestHeartBeatStopStart(heartbeatStateOff,heartbeatStateOn,_L("Making window invisible"),_L("Making window visible")); - - // Move the window with the animation off screen and check this disables the heartbeat timer. - TSize screenSize=TheClient->iGroup->Size(); - TPoint oldPos(iHbTestWin->BaseWin()->Position()); - iHbTestWin->BaseWin()->SetPosition(screenSize.AsPoint()); - heartbeatStateOff=GetHeartBeatTimerState(); - iHbTestWin->BaseWin()->SetPosition(oldPos); - heartbeatStateOn=GetHeartBeatTimerState(); - TestHeartBeatStopStart(heartbeatStateOff,heartbeatStateOn,_L("Moving window offscreen"),_L("Moving window back onscreen")); - TEST(GetHeartBeatTimerState()); - CleanupStack::PopAndDestroy(&anim); - TEST(!GetHeartBeatTimerState()); - CleanupStack::PopAndDestroy(&sprite); - } - -void CTHeartBeatTest::TestAnimDllTransL() - { - RTestAnim anim(iAnimDll); - TSize testWinSize(iHbTestWin->BaseWin()->Size()); - TRect animRect(testWinSize.iWidth/4,testWinSize.iHeight/3,testWinSize.iWidth*3/4,testWinSize.iHeight*2/3); - TPckgBuf rectPckg; - rectPckg()=animRect; - TEST(!GetHeartBeatTimerState()); - User::LeaveIfError(anim.Construct(*iHbTestWin->BaseWin(),EAnimTypeTest3,rectPckg)); - CleanupClosePushL(anim); - TEST(GetHeartBeatTimerState()); -// - RunTransWinTestsL(animRect); -// - CleanupStack::PopAndDestroy(&anim); - TEST(!GetHeartBeatTimerState()); - } - -void CTHeartBeatTest::RunTestCaseL(TInt /*aCurTestCase*/) - { - - switch(++iTest->iState) - { - case 1: -/** -@SYMTestCaseID GRAPHICS-WSERV-0568 -*/ - ((CTHeartBeatTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0568")); - _LIT(KTestTextCursorTimer,"Basic heartbeat timer test"); - iTest->LogSubTest(KTestTextCursorTimer); - TestTextCursorTimerL(); - break; - case 2: -/** -@SYMTestCaseID GRAPHICS-WSERV-0569 -*/ - ((CTHeartBeatTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0569")); - _LIT(KTestTextCursorTimerTrans,"Heartbeat timer test with transparent windows"); - iTest->LogSubTest(KTestTextCursorTimerTrans); - TestTextCursorTimerTransL(); - break; - case 3: -/** -@SYMTestCaseID GRAPHICS-WSERV-0570 -*/ - ((CTHeartBeatTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0570")); - _LIT(KTestAnimDll1,"Anim DLL Heartbeat check (Win)"); - iTest->LogSubTest(KTestAnimDll1); - TestAnimDllL(EFalse,0); - break; - case 4: -/** -@SYMTestCaseID GRAPHICS-WSERV-0571 -*/ - ((CTHeartBeatTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0571")); - _LIT(KTestAnimDll2,"Anim DLL Heartbeat check (Sprite)"); - iTest->LogSubTest(KTestAnimDll2); - TestAnimDllL(ETrue,0); - TestAnimDllL(ETrue,ESpriteNoChildClip); - break; - case 5: -/** -@SYMTestCaseID GRAPHICS-WSERV-0572 -*/ - ((CTHeartBeatTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0572")); - _LIT(KTestAnimDllTrans,"Anim DLL Heartbeat check with transparent windows"); - iTest->LogSubTest(KTestAnimDllTrans); - TestAnimDllTransL(); - break; - case 6: -/** -@SYMTestCaseID GRAPHICS-WSERV-0573 -*/ - ((CTHeartBeatTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0573")); - _LIT(KTestActiveInactiveEvents,"Handling of TRawEvent::EInactive and EActive"); - iTest->LogSubTest(KTestActiveInactiveEvents); - TestActiveInactiveEvents(); - break; - default: - ((CTHeartBeatTestStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - ((CTHeartBeatTestStep*)iStep)->CloseTMSGraphicsStep(); - TestComplete(); - break; - } - ((CTHeartBeatTestStep*)iStep)->RecordTestResultL(); - } - -__WS_CONSTRUCT_STEP__(HeartBeatTest) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/THeartBeat.h --- a/windowing/windowserver/tauto/THeartBeat.h Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,82 +0,0 @@ -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef __THEARTBEAT_H__ -#define __THEARTBEAT_H__ - -#include -#include -#include "AUTO.H" -#include "TAUTODLL.H" - -class CTHeartBeatTest : public CTWsGraphicsBase - { -public: - CTHeartBeatTest(CTestStep* aStep); - ~CTHeartBeatTest(); -protected: -//from MTestCases - void RunTestCaseL(TInt aCurTestCase); -private: - enum TCursorTransWinTestMode - { - ECursorTransWinTestNA=-1, - ECursorTransWinTestModeFullTrans, - ECursorTransWinTestNoTrans, - ECursorTransWinTestPartialTransExposingCursor, - ECursorTransWinTestPartialTransCoveringCursor, - ENumCursorTransWinTestModes, - }; -private: - void SetCursor(const TPoint& aPos,const TSize& aSize, TUint aFlags=0); - void CancelTextCursor(); - void ConstructL(); - void TestTextCursorTimerL(); - void TestTextCursorTimerTransL(); - void RunTransWinTestsL(const TRect& aGraphicRect); - void LoopThroughTransWinTestModes(RWindow& aTransWin, const TRect& aGraphicRect, TInt aExtraWinTestMode); - TBool ChangeTransAndCheckHeartBeat(TInt aTestMode, RWindow& aTransWin, const TRect& aGraphicRect, TInt aExtraWinTestMode, const TDesC* aErrorMsg, TBool aSetVisibleAfterTransUpdate); - void FailCursorHbTest(const TDesC& aErrorBase, const TDesC* aExtraText, TBool aHbState, TBool aHbCheckState); - void TestHeartBeatStopStart(TBool aHeartbeatStateOff,TBool aHeartbeatStateOn,const TDesC& aOffText,const TDesC& aOnText); - TBool GetHeartBeatTimerState() const; - TBool SetAutoHeartBeatPauseState(TBool aState) const; - void TestActiveInactiveEvents(); - void TestAnimDllL(TBool aSpriteMode, TUint aSpriteFlags); - void TestAnimDllTransL(); - void doTestActiveInactiveEvents(TBool aCursorOn, TBool aAutoPauseOn); - static TInt DoPanicTest(TInt aInt, TAny* aScreenNumber); -private: - RAnimDll iAnimDll; - CAnimWindow* iHbTestWin; - }; - -class CTHeartBeatTestStep : public CTGraphicsStep - { -public: - CTHeartBeatTestStep(); -protected: - //from CTGraphicsStep - CTGraphicsBase* CreateTestL(); - }; - -_LIT(KTHeartBeatTestStep,"THeartBeatTest"); - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TKEY.CPP --- a/windowing/windowserver/tauto/TKEY.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1119 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Testing key event, capturing keys and hot keys -// -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - - -#include "TKEY.H" - -#define LOGGING 1 //Uncomment this when there is a fail so that you get more logging - -GLDEF_D ClientToKill *SecondClient=NULL; - -GLDEF_C CTClient *CreateClientToKillL() - { - return(SecondClient=new(ELeave) ClientToKill()); - } - -GLDEF_C TInt ProcToKill(TAny *aScreenNumber) - { - TInt ret=KErrNone; - ret=TestLibStartUp(CreateClientToKillL,(TInt)aScreenNumber); - return(ret); - } - -CVisibleGroup::CVisibleGroup(TInt aScreenNo): iScreenNo(aScreenNo) - {} - -void CVisibleGroup::ConstructL() - { - User::LeaveIfError(iWs.Connect()); - iScr=new(ELeave) CWsScreenDevice(iWs); - User::LeaveIfError(iScr->Construct(iScreenNo)); - iScr->SetAppScreenMode(iMode); - iGroup=RWindowGroup(iWs); - User::LeaveIfError(iGroup.Construct(NULL,ETrue)); - TInt id=TheClient->iGroup->GroupWin()->Identifier(); - iGroup.SetOwningWindowGroup(id); -#if defined(LOGGING) - TLogMessageText buf; - _LIT(KIds,"Window Group Id: Main=%d, 2nd Client=%d"); - buf.Format(KIds,id,iGroup.Identifier()); - iWs.LogMessage(buf); -#endif - iWs.Flush(); - } - -CVisibleGroup::~CVisibleGroup() - { - iGroup.Close(); - delete iScr; - iWs.Close(); - } - -void CVisibleGroup::SetMode(TInt aMode) - { - iMode=aMode; - iScr->SetAppScreenMode(iMode); - iWs.Flush(); - } - -ClientToKill::ClientToKill() - {} - -void ClientToKill::ConstructL() - { - CTClient::ConstructL(); - RSemaphore sem; - sem.OpenGlobal(KSemaphoreName); - - iGroup=new(ELeave) TestWindowGroup(this); - iGroup->ConstructL(); - - iScreen->SetScreenMode(0); - TSize screenSize=iScreen->SizeInPixels(); - - TInt winWidth=3*screenSize.iWidth/4; - TInt winHeight=3*screenSize.iHeight/4; - iTestWin=new(ELeave) TestWindow(); - iTestWin->SetUpL(TPoint((screenSize.iWidth+4)/8,(screenSize.iHeight+4)/8),TSize(winWidth,winHeight),iGroup,*iGc); - -#if defined(LOGGING) - TLogMessageText buf; - _LIT(KId,"Window Group Id in 2nd Process=%d"); - buf.Format(KId,iGroup->GroupWin()->Identifier()); - LogMessage(buf); -#endif - sem.Signal(); // Signal thread fully initialised - sem.Close(); - } - -ClientToKill::~ClientToKill() - { - delete iTestWin; - } - - -// CTKey - -CTKey::CTKey(CTestStep* aStep) : CTWsGraphicsBase(aStep) - { - } - - - -void CTKey::ConstructL() - { - iSem.CreateGlobal(KSemaphoreName,0,KOwnerType); - iVisibleGroup=new(ELeave) CVisibleGroup(iTest->iScreenNumber); - iVisibleGroup->ConstructL(); - } - -CTKey::~CTKey() - { - delete iVisibleGroup; - iSem.Close(); - // Set focus back to this screen as it went to primary screen when iVisibleGroup was destroyed - // Wserv focus handling made focus screen switch to another screen if there is no - // focusable window group on that particular screen. - TheClient->iWs.SetFocusScreen(iTest->iScreenNumber); - } - -void CTKey::SendKey(TInt aScanCode) - { - TKeyEvent keyEvent; - keyEvent.iCode=aScanCode; - keyEvent.iScanCode=aScanCode; - keyEvent.iModifiers=0; - keyEvent.iRepeats=0; - TheClient->iWs.SimulateKeyEvent(keyEvent); - TheClient->iWs.Flush(); - } - -void CTKey::SendUpDown(TInt aScanCode) - { - TRawEvent rawEvent; - rawEvent.Set(TRawEvent::EKeyDown,aScanCode); - TheClient->iWs.SimulateRawEvent(rawEvent); - rawEvent.Set(TRawEvent::EKeyUp,aScanCode); - TheClient->iWs.SimulateRawEvent(rawEvent); - } - -void CTKey::SendCtrlAltShift(TRawEvent::TType aType) - { - TRawEvent rawEvent; - rawEvent.Set(aType,EStdKeyLeftFunc); - TheClient->iWs.SimulateRawEvent(rawEvent); - rawEvent.Set(aType,EStdKeyLeftCtrl); - TheClient->iWs.SimulateRawEvent(rawEvent); - rawEvent.Set(aType,EStdKeyLeftShift); - TheClient->iWs.SimulateRawEvent(rawEvent); - } - -void CTKey::SendCtrlAltShift(TInt aScanCode) - { - SendCtrlAltShift(TRawEvent::EKeyDown); - SendUpDown(aScanCode); - SendCtrlAltShift(TRawEvent::EKeyUp); - TheClient->iWs.Flush(); - } - -void CTKey::LogWindowGroupIds() - { - CArrayFixFlat* idList=new(ELeave) CArrayFixFlat(5); - if (!idList) - return; - TheClient->iWs.WindowGroupList(0,idList); - TLogMessageText buf; - _LIT(KWinGp,"Window Group Id's: %d"); - _LIT(KId,", %d"); - TInt ii=0; - buf.Format(KWinGp,(*idList)[ii]); - while (++iiCount()) - buf.AppendFormat(KId,(*idList)[ii]); - LOG_MESSAGE(buf); - delete idList; - } - -void CTKey::SetHotKey(THotKey aType, TUint aKeyCode) - { - TheClient->iWs.SetHotKey(aType,aKeyCode-'A'+1,EFuncCtrlShift,EFuncCtrlShift); - } - -void CTKey::KeyOfOrientation() - { - TInt numScreenModes = TheClient->iScreen->NumScreenModes(); - TInt originalScreenMode = TheClient->iScreen->CurrentScreenMode(); - if(numScreenModes >= 2) - { - //1 possible rotation of 180deg found in wsini.ini screenmode 8 - iVisibleGroup->SetMode(numScreenModes-1); - TheClient->iScreen->SetScreenMode(numScreenModes-1); - SendCtrlAltShift('O'); - TheClient->iWs.Flush(); - //1 possible rotation of 90deg found in wsini.ini screenmode 7 - iVisibleGroup->SetMode(numScreenModes-2); - TheClient->iScreen->SetScreenMode(numScreenModes-2); - SendCtrlAltShift('O'); - TheClient->iWs.Flush(); - //reset to original screenmode - iVisibleGroup->SetMode(originalScreenMode); - TheClient->iScreen->SetScreenMode(originalScreenMode); - } - else - { - TEST(numScreenModes>2); - INFO_PRINTF2(_L("numScreenModes - Expected: >2, Actual: %d"), numScreenModes); - } - TPixelsAndRotation originalSizeAndRotation; - TheClient->iScreen->GetScreenModeSizeAndRotation(TheClient->iScreen->CurrentScreenMode(),originalSizeAndRotation); - SendCtrlAltShift('O'); - TheClient->iWs.Flush(); - TPixelsAndRotation sizeAndRotation; - TheClient->iScreen->GetScreenModeSizeAndRotation(TheClient->iScreen->CurrentScreenMode(),sizeAndRotation); - TEST(sizeAndRotation.iRotation!=originalSizeAndRotation.iRotation); - if (sizeAndRotation.iRotation==originalSizeAndRotation.iRotation) - INFO_PRINTF3(_L("iRotation - Not Expected: %d, Actual: %d"), originalSizeAndRotation.iRotation, sizeAndRotation.iRotation); - SendCtrlAltShift('O'); - TheClient->iWs.Flush(); - } - -void CTKey::CycleDisplaySize() - { - // The test does nothing if there is only one possible screen mode -> return - TInt numScreenModes = TheClient->iScreen->NumScreenModes(); - if (numScreenModes<2) - { - TEST(numScreenModes>2); - INFO_PRINTF2(_L("numScreenModes - Expected: >2, Actual: %d"), numScreenModes); - return; - } - //Get original screen mode and size values - TInt originalScreenMode = TheClient->iScreen->CurrentScreenMode(); - TPixelsAndRotation sizeAndRotation; - TheClient->iScreen->GetScreenModeSizeAndRotation(TheClient->iScreen->CurrentScreenMode(),sizeAndRotation); - TSize originalScreenSize = sizeAndRotation.iPixelSize; - - SendCtrlAltShift('U'); - TheClient->iWs.Flush(); - TheClient->iScreen->GetScreenModeSizeAndRotation(TheClient->iScreen->CurrentScreenMode(),sizeAndRotation); - TEST(sizeAndRotation.iPixelSize.iHeight!=originalScreenSize.iHeight && sizeAndRotation.iPixelSize.iWidth!=originalScreenSize.iWidth); - if (sizeAndRotation.iPixelSize.iHeight==originalScreenSize.iHeight || sizeAndRotation.iPixelSize.iWidth==originalScreenSize.iWidth) - INFO_PRINTF5(_L("iPixelSize - Expected: !%d !%d, Actual: %d %d"), originalScreenSize.iHeight, originalScreenSize.iWidth, sizeAndRotation.iPixelSize.iHeight, sizeAndRotation.iPixelSize.iWidth); - TheClient->iScreen->SetScreenMode(originalScreenMode); - TheClient->iWs.Flush(); - } - -void CTKey::KeyOfDeathL() - { - //Key of Death -#if defined(LOGGING) - TLogMessageText buf; - _LIT(KNum1,"Priority Zero Window Groups=%d Total=%d (Before Process Creation)"); - buf.Format(KNum1,TheClient->iWs.NumWindowGroups(0),TheClient->iWs.NumWindowGroups()); - LOG_MESSAGE(buf); - LogWindowGroupIds(); -#endif - CProcess* process = CProcess::NewL(CProcess::eProcessKeyTest,iTest->iScreenNumber); - RWindowGroup group(TheClient->iWs); - group.Construct(1234); - TheClient->Flush(); //Make sure the window group above is created before the one in the other process - TInt id=TheClient->iGroup->GroupWin()->Identifier(); - group.SetOwningWindowGroup(id); - group.DefaultOwningWindow(); - - iSem.Wait(); - User::After(TTimeIntervalMicroSeconds32(100000)); //0.1 secs - TInt numGroups=TheClient->iWs.NumWindowGroups(); - TInt numGroups0=TheClient->iWs.NumWindowGroups(0); - -#if defined(LOGGING) - _LIT(KNum2,"NewWinGpId=%d Priority Zero Window Groups=%d Total=%d (After Process Creation)"); - buf.Format(KNum2,id,numGroups0,numGroups); - LOG_MESSAGE(buf); - _LIT(KLog1,"Sending Key Of Death"); - buf.Copy(KLog1); - LOG_MESSAGE(buf); - LogWindowGroupIds(); -#endif - group.SetOrdinalPosition(1); //Make sure that the window group we have just created is behind the one created by the other process (belt and braces) - SendCtrlAltShift('K'); - TheClient->iWs.Flush(); -#if defined(LOGGING) - _LIT(KLog2,"Sent Key Of Death"); - buf.Copy(KLog2); - LOG_MESSAGE(buf); -#endif - TInt numGroups2; - TInt numGroups0b; - TInt tries=3; - FOREVER //On multi-core platforms need to wait for the Key of Death procedure to complete - { - numGroups2=TheClient->iWs.NumWindowGroups(); - numGroups0b=TheClient->iWs.NumWindowGroups(0); - if (--tries==0) - break; - if (numGroups!=numGroups2 || numGroups0!=numGroups0b) - { - tries=1; - continue; - } - User::After(100000); //0.1secs - } - TEST(numGroups==numGroups2+1); - _LIT(KLog,"KeyOfDeath Num WinGps Before=%d After=%d (should be one less)"); - if (numGroups!=numGroups2+1) - LOG_MESSAGE3(KLog,numGroups,numGroups2); - TEST(numGroups0==numGroups0b+1); - if (numGroups0!=numGroups0b+1) - LOG_MESSAGE3(KLog,numGroups0,numGroups0b); - group.Close(); - - TBool processDead=!process->StillAlive(); - TEST(processDead); - if (!processDead) - { - _LIT(KLog,"Other Thread Still Alive"); - LOG_MESSAGE(KLog); - } - delete process; - -#if defined(LOGGING) - _LIT(KLog3,"Finished KeyOfDeath Test"); - buf.Copy(KLog3); - LOG_MESSAGE(buf); - LogWindowGroupIds(); -#endif - } - -#define CONTRAST_UP 'A' //'a'-'a'+1 -#define CONTRAST_DOWN 'B' //'b'-'a'+1 - -void CTKey::TestContrastL(TBool aChange) - { - TInt contrast=0; - TInt newContrast=0; - TInt maxContrast=0; - User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayContrastMax,maxContrast)); - TInt diff=aChange ? 1:0; - User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayContrast,contrast)); - - SendCtrlAltShift(CONTRAST_UP); - User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayContrast,newContrast)); - if ((contrast==maxContrast) && aChange) - { - TEST(newContrast==0); - if (newContrast!=0) - INFO_PRINTF3(_L("newContrast==0 - Expected: %d, Actual: %d"), 0, newContrast); - } - else - { - TEST(contrast+diff==newContrast); - if (contrast+diff!=newContrast) - INFO_PRINTF3(_L("contrast+diff==newContrast - Expected: %d, Actual: %d"), contrast+diff, newContrast); - } - - SendCtrlAltShift(CONTRAST_DOWN); - User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayContrast,newContrast)); - TEST(contrast==newContrast); - if (contrast!=newContrast) - INFO_PRINTF3(_L("contrast==newContrast - Expected: %d, Actual: %d"), contrast, newContrast); - - SendCtrlAltShift(CONTRAST_DOWN); - User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayContrast,newContrast)); - if (contrast==0) - { - TEST(maxContrast==newContrast); - if (maxContrast!=newContrast) - INFO_PRINTF3(_L("maxContrast==newContrast - Expected: %d, Actual: %d"), maxContrast, newContrast); - - } - else - { - TEST(contrast-diff==newContrast); - if (contrast-diff!=newContrast) - INFO_PRINTF3(_L("contrast-diff==newContrast - Expected: %d, Actual: %d"), contrast-diff, newContrast); - - } - - SendCtrlAltShift(CONTRAST_UP); - User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayContrast,newContrast)); - TEST(contrast==newContrast); - if (contrast!=newContrast) - INFO_PRINTF3(_L("contrast==newContrast - Expected: %d, Actual: %d"), contrast, newContrast); - - } - -void CTKey::TestDefaultContrastL(TBool aChange) - { - TInt contrast=0; - TInt newContrast=0; - TInt maxContrast=0; - User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayContrastMax,maxContrast)); - TInt diff=aChange ? 1:0; - User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayContrast,contrast)); - - SendKey(EKeyIncContrast); - User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayContrast,newContrast)); - if ((contrast==maxContrast) && aChange) - { - TEST(newContrast==0); - if (0!=newContrast) - INFO_PRINTF3(_L("newContrast==0 - Expected: %d, Actual: %d"), 0, newContrast); - } - else - { - TEST(contrast+diff==newContrast); - if (contrast+diff!=newContrast) - INFO_PRINTF3(_L("newContrast==contrast+diff - Expected: %d, Actual: %d"), contrast+diff, newContrast); - } - - SendKey(EKeyDecContrast); - User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayContrast,newContrast)); - TEST(contrast==newContrast); - if (contrast!=newContrast) - INFO_PRINTF3(_L("contrast==newContrast - Expected: %d, Actual: %d"), contrast, newContrast); - - SendKey(EKeyDecContrast); - User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayContrast,newContrast)); - if (contrast==0) - { - TEST(maxContrast==newContrast); - if (maxContrast!=newContrast) - INFO_PRINTF3(_L("maxContrast==newContrast - Expected: %d, Actual: %d"), maxContrast, newContrast); - } - else - { - TEST(contrast-diff==newContrast); - if (contrast-diff!=newContrast) - INFO_PRINTF3(_L("contrast-diff==newContrast - Expected: %d, Actual: %d"), contrast-diff, newContrast); - } - - SendKey(EKeyIncContrast); - User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayContrast,newContrast)); - TEST(contrast==newContrast); - if (contrast!=newContrast) - INFO_PRINTF3(_L("contrast==newContrast - Expected: %d, Actual: %d"), contrast, newContrast); - - } - -void CTKey::ContrastKeysL() - { - TInt maxContrast=0; - TInt contrast=0; - TInt err=HAL::Get(iTest->iScreenNumber,HALData::EDisplayContrastMax,maxContrast); - if (err==KErrNotSupported) - return; - else if (err==KErrNone) - err=HAL::Get(iTest->iScreenNumber,HALData::EDisplayContrast,contrast); - if (err==KErrNotSupported) - return; - TEST(err==KErrNone); - if (err!=KErrNone) - INFO_PRINTF3(_L("HAL::Get(iTest->iScreenNumber,HALData::EDisplayContrast,contrast)=KErrNone - Expected: %d, Actual: %d"), KErrNone, err); - - if (contrast==0) - err=HAL::Set(iTest->iScreenNumber,HALData::EDisplayContrast,++contrast); - else if (contrast==maxContrast) - err=HAL::Set(iTest->iScreenNumber,HALData::EDisplayContrast,--contrast); - if (err==KErrNotSupported) - return; - TEST(err==KErrNone); - if (err!=KErrNone) - INFO_PRINTF3(_L("HAL::Get(iTest->iScreenNumber,HALData::EDisplayContrast,contrast)=KErrNone - Expected: %d, Actual: %d"), KErrNone, err); - TestDefaultContrastL(ETrue); - - SetHotKey(EHotKeyIncContrast,CONTRAST_UP); - SetHotKey(EHotKeyDecContrast,CONTRAST_DOWN); - TestContrastL(ETrue); - TestDefaultContrastL(ETrue); - - TheClient->iWs.ClearHotKeys(EHotKeyIncContrast); - TheClient->iWs.ClearHotKeys(EHotKeyDecContrast); - TestContrastL(EFalse); - TestDefaultContrastL(EFalse); - - TheClient->iWs.RestoreDefaultHotKey(EHotKeyIncContrast); - TheClient->iWs.RestoreDefaultHotKey(EHotKeyDecContrast); - TestContrastL(EFalse); - TestDefaultContrastL(ETrue); - - SetHotKey(EHotKeyIncContrast,CONTRAST_UP); - SetHotKey(EHotKeyDecContrast,CONTRAST_DOWN); - TestContrastL(ETrue); - TestDefaultContrastL(ETrue); - - TheClient->iWs.RestoreDefaultHotKey(EHotKeyIncContrast); - TheClient->iWs.RestoreDefaultHotKey(EHotKeyDecContrast); - TestContrastL(EFalse); - TestDefaultContrastL(ETrue); - } - -#define BACKLIGHT_ON 'A' //'o'-'a'+1 -#define BACKLIGHT_OFF 'B' //'p'-'a'+1 -#define BACKLIGHT_TOGGLE 'C' //'q'-'a'+1 -/** Test for reaction against backlight ON/OFF/TOGGLE buttons defined above. - If aChange is false button presses must not affect the state of backlight. -*/ -void CTKey::TestBackLightL(TBool aChange) - { - TBool state; - SendCtrlAltShift(BACKLIGHT_ON); - User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EBacklightState,state)); - TEST(state==aChange); - if (state!=aChange) - INFO_PRINTF3(_L("state==aChange - Expected: %d, Actual: %d"), aChange, state); - - SendCtrlAltShift(BACKLIGHT_TOGGLE); - User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EBacklightState,state)); - TEST(state==EFalse); - if (state!=EFalse) - INFO_PRINTF3(_L("state==EFalse - Expected: %d, Actual: %d"), EFalse, state); - - SendCtrlAltShift(BACKLIGHT_TOGGLE); - User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EBacklightState,state)); - TEST(state==aChange); - if (state!=aChange) - INFO_PRINTF3(_L("state==aChange - Expected: %d, Actual: %d"), aChange, state); - - SendCtrlAltShift(BACKLIGHT_OFF); - User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EBacklightState,state)); - TEST(state==EFalse); - if (state!=EFalse) - INFO_PRINTF3(_L("state==EFalse - Expected: %d, Actual: %d"), EFalse, state); - - SendCtrlAltShift(BACKLIGHT_TOGGLE); - User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EBacklightState,state)); - TEST(state==aChange); - if (state!=aChange) - INFO_PRINTF3(_L("state==aChange - Expected: %d, Actual: %d"), aChange, state); - - SendCtrlAltShift(BACKLIGHT_TOGGLE); - User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EBacklightState,state)); - TEST(state==EFalse); - if (state!=EFalse) - INFO_PRINTF3(_L("state==EFalse - Expected: %d, Actual: %d"), EFalse, state); - - } - -/** Test for reaction against default backlight ON/OFF/TOGGLE buttons. - If aChange is false button presses must not affect the state of backlight. -*/ -void CTKey::TestDefaultBackLightL(TBool aChange) - { - TBool state; - SendKey(EKeyBacklightOn); - User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EBacklightState,state)); - TEST(state==aChange); - if (state!=aChange) - INFO_PRINTF3(_L("state==aChange - Expected: %d, Actual: %d"), aChange, state); - - SendKey(EKeyBacklightToggle); - User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EBacklightState,state)); - TEST(state==EFalse); - if (state!=EFalse) - INFO_PRINTF3(_L("state==EFalse - Expected: %d, Actual: %d"), EFalse, state); - - SendKey(EKeyBacklightToggle); - User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EBacklightState,state)); - TEST(state==aChange); - if (state!=aChange) - INFO_PRINTF3(_L("state==aChange - Expected: %d, Actual: %d"), aChange, state); - - SendKey(EKeyBacklightOff); - User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EBacklightState,state)); - TEST(state==EFalse); - if (state!=EFalse) - INFO_PRINTF3(_L("state==EFalse - Expected: %d, Actual: %d"), EFalse, state); - - SendKey(EKeyBacklightToggle); - User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EBacklightState,state)); - TEST(state==aChange); - if (state!=aChange) - INFO_PRINTF3(_L("state==aChange - Expected: %d, Actual: %d"), aChange, state); - - SendKey(EKeyBacklightToggle); - User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EBacklightState,state)); - TEST(state==EFalse); - if (state!=EFalse) - INFO_PRINTF3(_L("state==EFalse - Expected: %d, Actual: %d"), EFalse, state); - - } - -void CTKey::BackLightKeysL() - { - // Turns backlight off - TBool prevState; - TInt err=HAL::Get(iTest->iScreenNumber,HALData::EBacklightState,prevState); - if (err==KErrNotSupported) - { - _LIT(KLog,"Cannot test BackLight Key presses as cannot read its state on screen %d"); - LOG_MESSAGE2(KLog,iTest->iScreenNumber); - return; - } - else if (err==KErrNone) - err=HAL::Set(iTest->iScreenNumber,HALData::EBacklightState,EFalse); - if (err==KErrNotSupported) - { - _LIT(KLog,"Cannot test BackLight Key presses as cannot set its state on screen %d"); - LOG_MESSAGE2(KLog,iTest->iScreenNumber); - return; - } - TEST(err==KErrNone); - if (err!=KErrNone) - { - _LIT(KLog,"Reading or Setting BackLight state gave error %d on screen %d"); - LOG_MESSAGE3(KLog,err,iTest->iScreenNumber); - } - - // Tests that default backlight ON/OFF/TOGGLE buttons work - TestDefaultBackLightL(ETrue); - - // Sets user defined backlight buttons and tests that both default and user defined buttons work - SetHotKey(EHotKeyBacklightOn,BACKLIGHT_ON); - SetHotKey(EHotKeyBacklightOff,BACKLIGHT_OFF); - SetHotKey(EHotKeyBacklightToggle,BACKLIGHT_TOGGLE); - TestBackLightL(ETrue); - TestDefaultBackLightL(ETrue); - - // Calls RWsSession::ClearHotKeys and tests that both default and user defined buttons don't work - TheClient->iWs.ClearHotKeys(EHotKeyBacklightOn); - TheClient->iWs.ClearHotKeys(EHotKeyBacklightOff); - TheClient->iWs.ClearHotKeys(EHotKeyBacklightToggle); - TestBackLightL(EFalse); - TestDefaultBackLightL(EFalse); - - // Calls RWsSession::RestoreDefaultHotKey and tests that only default buttons work - TheClient->iWs.RestoreDefaultHotKey(EHotKeyBacklightOn); - TheClient->iWs.RestoreDefaultHotKey(EHotKeyBacklightOff); - TheClient->iWs.RestoreDefaultHotKey(EHotKeyBacklightToggle); - TestBackLightL(EFalse); - TestDefaultBackLightL(ETrue); - - // Sets user defined backlight buttons and tests that both default and user defined buttons work - SetHotKey(EHotKeyBacklightOn,BACKLIGHT_ON); - SetHotKey(EHotKeyBacklightOff,BACKLIGHT_OFF); - SetHotKey(EHotKeyBacklightToggle,BACKLIGHT_TOGGLE); - TestBackLightL(ETrue); - TestDefaultBackLightL(ETrue); - - // Calls RWsSession::RestoreDefaultHotKey and tests that only default buttons work - TheClient->iWs.RestoreDefaultHotKey(EHotKeyBacklightOn); - TheClient->iWs.RestoreDefaultHotKey(EHotKeyBacklightOff); - TheClient->iWs.RestoreDefaultHotKey(EHotKeyBacklightToggle); - TestBackLightL(EFalse); - TestDefaultBackLightL(ETrue); - - //Restores previous backlight state - //err=UserHal::SetBacklightOn(prevState); - err=HAL::Set(iTest->iScreenNumber,HALData::EBacklightState,prevState); - TEST(err==KErrNone); - if (err!=KErrNone) - { - _LIT(KLog,"Failed to set BackLight state back to previous state: %d on screen %d, error code: %d"); - LOG_MESSAGE4(KLog,prevState,iTest->iScreenNumber,err); - } - } - -#define BRIGHTNESS_UP 'N' -#define BRIGHTNESS_DOWN 'J' -/** If aChange is true, checks that programmicaly defined brightness buttons increase and decrease brightness properly. - If aChange is false, checks that programmicaly defined brightness buttons don't affect brightness. -*/ -void CTKey::TestBrightnessL(TBool aChange) - { - TInt brightness; - TInt newBrightness; - TInt diff=aChange ? 1:0; - User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayBrightness,brightness)); - - SendCtrlAltShift(BRIGHTNESS_UP); - User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayBrightness,newBrightness)); - TEST(brightness+diff==newBrightness); - if (brightness+diff!=newBrightness) - INFO_PRINTF3(_L("brightness+diff==newBrightness - Expected: %d, Actual: %d"), newBrightness, brightness+diff); - - SendCtrlAltShift(BRIGHTNESS_DOWN); - User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayBrightness,newBrightness)); - TEST(brightness==newBrightness); - if (brightness!=newBrightness) - INFO_PRINTF3(_L("brightness==newBrightness - Expected: %d, Actual: %d"), newBrightness, brightness); - - SendCtrlAltShift(BRIGHTNESS_DOWN); - User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayBrightness,newBrightness)); - TEST(brightness-diff==newBrightness); - if (brightness-diff!=newBrightness) - INFO_PRINTF3(_L("brightness-diff==newBrightness - Expected: %d, Actual: %d"), newBrightness, brightness-diff); - - SendCtrlAltShift(BRIGHTNESS_UP); - User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayBrightness,newBrightness)); - TEST(brightness==newBrightness); - if (brightness!=newBrightness) - INFO_PRINTF3(_L("brightness==newBrightness - Expected: %d, Actual: %d"), newBrightness, brightness); - } - -/** If aChange is true, checks that default brightness buttons increase and decrease brightness properly (increase/decrease by 1). - If aChange is false, checks that default brightness buttons don't affect brightness. -*/ -void CTKey::TestDefaultBrightnessL(TBool aChange) - { - TInt brightness; - TInt newBrightness; - TInt diff=aChange ? 1:0; - User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayBrightness,brightness)); - - SendKey(EKeyIncBrightness); - User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayBrightness,newBrightness)); - TEST(brightness+diff==newBrightness); - if (brightness+diff!=newBrightness) - INFO_PRINTF3(_L("brightness+diff==newBrightness - Expected: %d, Actual: %d"), newBrightness, brightness+diff); - - SendKey(EKeyDecBrightness); - User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayBrightness,newBrightness)); - TEST(brightness==newBrightness); - if (brightness!=newBrightness) - INFO_PRINTF3(_L("brightness==newBrightness - Expected: %d, Actual: %d"), newBrightness, brightness); - - SendKey(EKeyDecBrightness); - User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayBrightness,newBrightness)); - TEST(brightness-diff==newBrightness); - if (brightness-diff!=newBrightness) - INFO_PRINTF3(_L("brightness-diff==newBrightness - Expected: %d, Actual: %d"), newBrightness, brightness-diff); - - SendKey(EKeyIncBrightness); - User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayBrightness,newBrightness)); - TEST(brightness==newBrightness); - if (brightness!=newBrightness) - INFO_PRINTF3(_L("brightness==newBrightness - Expected: %d, Actual: %d"), newBrightness, brightness); - } - -void CTKey::BrightnessKeysL() - { - INFO_PRINTF1(_L("AUTO Brightness Key Test ")); - TInt maxBrightness; - TInt brightness=0; //To stop warning - // get maximum brightness and current - TInt err=HAL::Get(iTest->iScreenNumber,HALData::EDisplayBrightnessMax,maxBrightness); - if (err==KErrNotSupported) - return; - else if (err==KErrNone) - err=HAL::Get(iTest->iScreenNumber,HALData::EDisplayBrightness,brightness); - if (err==KErrNotSupported) - return; - INFO_PRINTF1(_L(" Supported")); - TEST(err==KErrNone); - if (err!=KErrNone) - INFO_PRINTF3(_L("HAL::Get(iTest->iScreenNumber,HALData::EDisplayBrightness,brightness) return value - Expected: %d, Actual: %d"), KErrNone, err); - - // sets brightness to be neither maximal nor minimal - if (brightness==0) - err=HAL::Set(iTest->iScreenNumber,HALData::EDisplayBrightness,++brightness); - else if (brightness==maxBrightness) - err=HAL::Set(iTest->iScreenNumber,HALData::EDisplayBrightness,--brightness); - if (err==KErrNotSupported) - return; - INFO_PRINTF1(_L(" Changeable")); - TEST(err==KErrNone); - if (err!=KErrNone) - INFO_PRINTF3(_L("HAL::Get(iTest->iScreenNumber,HALData::EDisplayBrightness,brightness) return value - Expected: %d, Actual: %d"), KErrNone, err); - - // Test default brightness buttons increase/decrease brightness by 1 - TestDefaultBrightnessL(ETrue); - - // Add new inc/dec buttons, test that default and program defined brightness buttons increase/decrease brightness by 1 - INFO_PRINTF1(_L(" First Test")); - SetHotKey(EHotKeyIncBrightness,BRIGHTNESS_UP); - SetHotKey(EHotKeyDecBrightness,BRIGHTNESS_DOWN); - TestBrightnessL(ETrue); - TestDefaultBrightnessL(ETrue); - - // Clear brightness buttons, test that default and program defined brightness buttons doesn't affect brightness - INFO_PRINTF1(_L(" Second Test")); - TheClient->iWs.ClearHotKeys(EHotKeyIncBrightness); - TheClient->iWs.ClearHotKeys(EHotKeyDecBrightness); - TestBrightnessL(EFalse); - TestDefaultBrightnessL(EFalse); - - // Restore default brightness buttons, test that only default brightness buttons increase/decrease brightness by 1 - INFO_PRINTF1(_L(" Third Test")); - TheClient->iWs.RestoreDefaultHotKey(EHotKeyIncBrightness); - TheClient->iWs.RestoreDefaultHotKey(EHotKeyDecBrightness); - TestBrightnessL(EFalse); - TestDefaultBrightnessL(ETrue); - - // Add new inc/dec buttons, test that default and program defined brightness buttons increase/decrease brightness by 1 - INFO_PRINTF1(_L(" Fourth Test")); - SetHotKey(EHotKeyIncBrightness,BRIGHTNESS_UP); - SetHotKey(EHotKeyDecBrightness,BRIGHTNESS_DOWN); - TestBrightnessL(ETrue); - TestDefaultBrightnessL(ETrue); - - // Restore default brightness buttons, test that only default brightness buttons increase/decrease brightness by 1 - INFO_PRINTF1(_L(" Fifth Test")); - TheClient->iWs.RestoreDefaultHotKey(EHotKeyIncBrightness); - TheClient->iWs.RestoreDefaultHotKey(EHotKeyDecBrightness); - TestBrightnessL(EFalse); - TestDefaultBrightnessL(ETrue); - } - -void CTKey::TestDefaultScreenSizeModeL(TInt aKeys,TBool aChange) - { - TInt screenMode=TheClient->iScreen->CurrentScreenMode(); - TInt key; - TInt retVal; - for (key=0;keySetMode(key); - SendKey(EKeyScreenDimension0+key); - if (aChange) - { - retVal = TheClient->iScreen->CurrentScreenMode(); - TEST(retVal==key); - if (retVal!=key) - INFO_PRINTF3(_L("TheClient->iScreen->CurrentScreenMode() return value - Expected: %d, Actual: %d"), key, retVal); - } - else - { - retVal = TheClient->iScreen->CurrentScreenMode(); - TEST(retVal==screenMode); - if (retVal!=screenMode) - INFO_PRINTF3(_L("TheClient->iScreen->CurrentScreenMode() return value - Expected: %d, Actual: %d"), screenMode, retVal); - } - } - } - -#define DIMENSION0 'P' -#define DIMENSION1 'Q' -#define DIMENSION2 'R' -#define DIMENSION3 'N' -void CTKey::TestScreenSizeModeL(TInt aKeys,TBool aChange) - { - TInt screenMode=TheClient->iScreen->CurrentScreenMode(); - TInt key; - TInt retVal; - for (key=0;keySetMode(key); - switch (key) - { - case 0: - SendCtrlAltShift(DIMENSION0); - break; - case 1: - SendCtrlAltShift(DIMENSION1); - break; - case 2: - SendCtrlAltShift(DIMENSION2); - break; - case 3: - SendCtrlAltShift(DIMENSION3); - break; - default: - INFO_PRINTF2(_L("Error Invalid Key: %d"),key); - TEST(EFalse); - break; - } - - - if (aChange) - { - retVal = TheClient->iScreen->CurrentScreenMode(); - TEST(retVal==key); - if (retVal!=key) - INFO_PRINTF3(_L("TheClient->iScreen->CurrentScreenMode() return value - Expected: %d, Actual: %d"), key, retVal); - - } - else - { - retVal = TheClient->iScreen->CurrentScreenMode(); - TEST(retVal==screenMode); - if (retVal!=screenMode) - INFO_PRINTF3(_L("TheClient->iScreen->CurrentScreenMode() return value - Expected: %d, Actual: %d"), screenMode, retVal); - - } - } - } - -void CTKey::ScreenSizeModeKeysL() - { - // The test does nothing if there is only one possible screen mode -> return - TInt numScreenModes=TheClient->iScreen->NumScreenModes(); - if (numScreenModes<2) - return; - - // Use at most 4 different modes for the test - if (numScreenModes>4) {numScreenModes=4;} - - // Set screen mode 3 - TInt screenMode=TheClient->iScreen->CurrentScreenMode(); - iVisibleGroup->SetMode(numScreenModes-1); - TheClient->iScreen->SetScreenMode(numScreenModes-1); - - // Test default screen mode switch buttons - TestDefaultScreenSizeModeL(numScreenModes,ETrue); - - // Add new screen mode switch buttons. Test that default and program defined screen mode switch buttons switch modes. - SetHotKey(EHotKeyScreenDimension0,DIMENSION0); - SetHotKey(EHotKeyScreenDimension1,DIMENSION1); - SetHotKey(EHotKeyScreenDimension2,DIMENSION2); - SetHotKey(EHotKeyScreenDimension3,DIMENSION3); - TestDefaultScreenSizeModeL(numScreenModes,ETrue); - TestScreenSizeModeL(numScreenModes,ETrue); - - // Clear all screen mode switch buttons. Test that default and program defined screen mode switch buttons don't affect screen modes - TheClient->iWs.ClearHotKeys(EHotKeyScreenDimension0); - TheClient->iWs.ClearHotKeys(EHotKeyScreenDimension1); - TheClient->iWs.ClearHotKeys(EHotKeyScreenDimension2); - TheClient->iWs.ClearHotKeys(EHotKeyScreenDimension3); - TestDefaultScreenSizeModeL(numScreenModes,EFalse); - TestScreenSizeModeL(numScreenModes,EFalse); - - // Restore default screen mode switch buttons. Test that only default screen mode switch buttons switch screen modes - TheClient->iWs.RestoreDefaultHotKey(EHotKeyScreenDimension0); - TheClient->iWs.RestoreDefaultHotKey(EHotKeyScreenDimension1); - TheClient->iWs.RestoreDefaultHotKey(EHotKeyScreenDimension2); - TheClient->iWs.RestoreDefaultHotKey(EHotKeyScreenDimension3); - TestDefaultScreenSizeModeL(numScreenModes,ETrue); - TestScreenSizeModeL(numScreenModes,EFalse); - - // Add new screen mode switch buttons. Test that default and program defined screen mode switch buttons switch modes. - SetHotKey(EHotKeyScreenDimension0,DIMENSION0); - SetHotKey(EHotKeyScreenDimension1,DIMENSION1); - SetHotKey(EHotKeyScreenDimension2,DIMENSION2); - SetHotKey(EHotKeyScreenDimension3,DIMENSION3); - TestDefaultScreenSizeModeL(numScreenModes,ETrue); - TestScreenSizeModeL(numScreenModes,ETrue); - - // Restore default screen mode switch buttons. Test that only default screen mode switch buttons switch screen modes - TheClient->iWs.RestoreDefaultHotKey(EHotKeyScreenDimension0); - TheClient->iWs.RestoreDefaultHotKey(EHotKeyScreenDimension1); - TheClient->iWs.RestoreDefaultHotKey(EHotKeyScreenDimension2); - TheClient->iWs.RestoreDefaultHotKey(EHotKeyScreenDimension3); - TestDefaultScreenSizeModeL(numScreenModes,ETrue); - TestScreenSizeModeL(numScreenModes,EFalse); - - // Restore initial screen mode - iVisibleGroup->SetMode(screenMode); - TheClient->iScreen->SetScreenMode(screenMode); - } - -void CTKey::RunTestCaseL(TInt /*aCurTestCase*/) - { - _LIT(KTest0,"KeyOfDeath"); - _LIT(KTest1,"Contrast"); - _LIT(KTest2,"BackLight"); - _LIT(KTest3,"Brightness"); - _LIT(KTest4,"Screen Size Mode"); - ((CTKeyStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); -#ifdef _DEBUG - _LIT(KTest5,"Orientation"); - _LIT(KTest6,"CycleDisplaySize"); -#endif - switch(++iTest->iState) - { -/** -@SYMTestCaseID GRAPHICS-WSERV-0106 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Key of Death test - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Creates a new client process and runs it. - Waits until the process is started and simulates Ctrl-Alt-Shift-K press. - When starts the process assumes that TAutoServer.exe exists in z:\sys\bin directory. - Otherwise the test will not exit a wait-state and will be aborted. - -@SYMTestExpectedResults Checks that the process is dead after the Ctrl-Alt-Shift-K press. - Check also that the difference between amounts of window groups efore - death-key press and after death-key press is 1. -*/ - case 1: - ((CTKeyStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0106")); - iTest->LogSubTest(KTest0); - KeyOfDeathL(); - break; - case 2: -/** -@SYMTestCaseID GRAPHICS-WSERV-0539 -*/ - ((CTKeyStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0539")); - iTest->LogSubTest(KTest1); - ContrastKeysL(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0107 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test backlight - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Does nothing if hardware attributes are not supported. - 1. Turns backlight off. - 2. Tests that default backlight ON/OFF/TOGGLE buttons work. - 3. Sets user defined backlight buttons and tests that both default and user defined buttons work. - 4. Calls RWsSession::ClearHotKeys and tests that both default and user defined buttons don't work. - 5. Calls RWsSession::RestoreDefaultHotKey and tests that only default buttons work. - 6. Sets user defined backlight buttons and tests that both default and user defined buttons work. - 7. Calls RWsSession::RestoreDefaultHotKey and tests that only default buttons work. - 8. Restores previous backlight state. - -@SYMTestExpectedResults Expects that actions described above give positive result. - The test also checks that programmatic turn off/on doesn't fail. -*/ - case 3: - ((CTKeyStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0107")); - iTest->LogSubTest(KTest2); - BackLightKeysL(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0108 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test brightness - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Does nothing if hardware attributes are not supported. - 1. Get maximum brightness and current, test that those operations don't fail - 2. Sets brightness to be neither maximal nor minimal, test that those operations don't fail - 3. Test default brightness buttons increase/decrease brightness by 1 - 4. Add new inc/dec buttons, test that default and program defined brightness buttons increase/decrease brightness by 1 - 5. Clear brightness buttons, test that default and program defined brightness buttons doesn't affect brightness - 6. Restore default brightness buttons, test that only default brightness buttons increase/decrease brightness by 1 - 7. Add new inc/dec buttons, test that default and program defined brightness buttons increase/decrease brightness by 1 - 8. Restore default brightness buttons, test that only default brightness buttons increase/decrease brightness by 1 - -@SYMTestExpectedResults Expects that actions described above give positive result. - The test also checks that programmatic brightness increase and decrease doesn't fail. -*/ - case 4: - ((CTKeyStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0108")); - iTest->LogSubTest(KTest3); - BrightnessKeysL(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0109 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test screen mode switching - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions The test does nothing if there is only one possible screen mode. It uses at most 4 different modes for the test. - 1. Test default screen mode switch buttons - 2. Add new screen mode switch buttons. Test that default and program defined screen mode switch buttons switch modes. - 3. Clear all screen mode switch buttons. Test that default and program defined screen mode switch buttons don't affect screen modes - 4. Restore default screen mode switch buttons. Test that only default screen mode switch buttons switch screen modes - 5. Add new screen mode switch buttons. Test that default and program defined screen mode switch buttons switch modes. - 6. Restore default screen mode switch buttons. Test that only default screen mode switch buttons switch screen modes - 7. Restore initial screen mode - - - -@SYMTestExpectedResults Expects that actions described above give positive result. -*/ - case 5: - ((CTKeyStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0109")); - iTest->LogSubTest(KTest4); - ScreenSizeModeKeysL(); - break; -#ifdef _DEBUG - case 6: -/** -@SYMTestCaseID GRAPHICS-WSERV-0540 -*/ - ((CTKeyStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0540")); - iTest->LogSubTest(KTest5); - KeyOfOrientation(); - break; - case 7: -/** -@SYMTestCaseID GRAPHICS-WSERV-0541 -*/ - ((CTKeyStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0541")); - iTest->LogSubTest(KTest6); - CycleDisplaySize(); - break; -#endif - default: - ((CTKeyStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - ((CTKeyStep*)iStep)->CloseTMSGraphicsStep(); - TestComplete(); - } - ((CTKeyStep*)iStep)->RecordTestResultL(); - } - - -__WS_CONSTRUCT_STEP__(Key) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TKEY.H --- a/windowing/windowserver/tauto/TKEY.H Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,115 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef __TKEY_H__ -#define __TKEY_H__ - -#include -#include -#include "../tlib/testbase.h" -#include "AUTO.H" -#include -#include "TGraphicsHarness.h" - -_LIT(KSemaphoreName,"KeyProcSem"); - - -class CVisibleGroup: public CBase - { -public: - CVisibleGroup(TInt aScreenNo); - ~CVisibleGroup(); - void ConstructL(); - void SetMode(TInt aMode); -private: - RWsSession iWs; - RWindowGroup iGroup; - CWsScreenDevice* iScr; - TInt iScreenNo; - TInt iMode; - }; - - -class ClientToKill : public CTClient - { -public: - ClientToKill(); - ~ClientToKill(); - void ConstructL(); -private: - TestWindow *iTestWin; - }; - - - -class CTKey : public CTWsGraphicsBase - { -public: - enum {EFuncCtrlShift=EModifierFunc|EModifierCtrl|EModifierShift}; -public: - CTKey(CTestStep* aStep); - ~CTKey(); - void ConstructL(); - - void KeyOfDeathL(); - void KeyOfOrientation(); - void CycleDisplaySize(); - void ContrastKeysL(); - void BackLightKeysL(); - void BrightnessKeysL(); - void ScreenSizeModeKeysL(); -protected: - virtual void RunTestCaseL(TInt aCurTestCase); -private: - void SendKey(TInt aScanCode); - void SendUpDown(TInt aScanCode); - void SendCtrlAltShift(TInt aScanCode); - void SendCtrlAltShift(TRawEvent::TType aType); - void SetHotKey(THotKey aType, TUint aKeyCode); - void LogWindowGroupIds(); - void TestContrastL(TBool aChange); - void TestDefaultContrastL(TBool aChange); - void TestBackLightL(TBool aChange); - void TestDefaultBackLightL(TBool aChange); - void TestBrightnessL(TBool aChange); - void TestDefaultBrightnessL(TBool aChange); - void TestScreenSizeModeL(TInt aKeys,TBool aChange); - void TestDefaultScreenSizeModeL(TInt aKeys,TBool aChange); - -private: - RSemaphore iSem; - TSize iWinSize; - CVisibleGroup* iVisibleGroup; - }; - -class CTKeyStep : public CTGraphicsStep - { -public: - CTKeyStep(); -protected: - //from CTGraphicsStep - virtual CTGraphicsBase* CreateTestL(); - }; - -_LIT(KTKeyStep,"TKey"); - - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TKRepeat.CPP --- a/windowing/windowserver/tauto/TKRepeat.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,464 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Converted from TMan test code May 2001 -// Keyboard repeat test -// -// - -#include "TKRepeat.H" - -#define LOGGING 1 - -// -// CRKWindow, class // -// - -CRKWindow::CRKWindow(CTKRepeat *aTest) : CTWin(), iTest(aTest) - { - } - -void CRKWindow::SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc) - { - ConstructExtLD(*parent,pos,size); - iWin.SetBackgroundColor(TRgb::Gray256(230)); - Activate(); - AssignGC(aGc); - } - -void CRKWindow::Draw() - { - iGc->Clear(); - switch(iState) - { - case EStateWaitingForKeyDown: - iGc->DrawText(_L("Press and hold the space bar"), TPoint(10,20)); - break; - case EStateWaitingForFirstRepeat: - case EStateWaitingForNthRepeat: - { - TBuf<0x40> buf; - buf.Format(TRefByValue(_L("Keep space bar down (%d repeats so far)")),iRepCount); - iGc->DrawText(buf, TPoint(10,20)); - } - break; - case EStateWaitingForKeyUp: - iGc->DrawText(_L("Release space bar"), TPoint(10,20)); - default: - break; - } - } - -void CRKWindow::SetState(TRKStates aState) - { -#if defined(LOGGING) - TLogMessageText logMessageText; - _LIT(KStateChange,"State Change Old=%d New=%d"); - logMessageText.Format(KStateChange,iState,aState); - iTest->LOG_MESSAGE(logMessageText); -#endif - iState=aState; - DrawNow(); - TheClient->WaitForRedrawsToFinish(); - SendEvent(); - } - -void CRKWindow::SendEvent() - { - switch (iState) - { - case EStateWaitingForKeyDown: - case EStateWaitingForKeyUp: - #if defined(LOGGING) - _LIT(KKeyUp,"Send key up event substate 0"); - _LIT(KKeyDown,"Send key down event substate 4"); - iTest->LOG_MESSAGE(iState==EStateWaitingForKeyDown ? KKeyDown() : KKeyUp()); - #endif - iTest->TestBase()->SimulateKey((iState==EStateWaitingForKeyDown ? TRawEvent::EKeyDown : TRawEvent::EKeyUp),EStdKeySpace); - break; - case EStateWaitingForKeyCode: - case EStateWaitingForFirstRepeat: - case EStateWaitingForNthRepeat: - case EStateInactive: - case EStateError: - #if defined(LOGGING) - _LIT(KLog,"SendEvent: substate %d so no event to send"); - iTest->LOG_MESSAGE2(KLog,iState); - #endif - break; - } - } - -TBool CRKWindow::CheckResults() - { -// -// Checks repeat results, first convert everything to 10th's as that what is actually used -// for the timer in the window server. -// -// Return ETrue if the inacuracy in the average time is greater than 1/10th either way -// Allow initial 2/10ths either -// Allow min 2/10ths below -// Allow max 2/10ths above -// - if (iState!=EStateInactive) - return(ETrue); - TInt initial=iInitialGap.Int()/100000; - TInt initialX=iInitialRepeatSet.Int()/100000; - if (initialX==0) - initialX=1; - TInt average=(iTotalGap.Int()/100000)/(iRepCount-1); - TInt repeatX=iRepeatSet.Int()/100000; - if (repeatX==0) - repeatX=1; - TInt min=iMinGap.Int()/100000; - TInt max=iMaxGap.Int()/100000; - if (average>(repeatX+1) || average<(repeatX-1)) - return(ETrue); - if (initial>(initialX+2) || initial<(initialX-2)) - return(ETrue); -#if defined(__MARM_ARM4__) - if (min>(repeatX+1) || min<(repeatX-2) || max>(repeatX+3) || max2*(repeatX+2)) - return(ETrue); - } -#else - if (min>(repeatX+1) || min<(repeatX-2)) - return(ETrue); - if (max>(repeatX+3) || max(_L("Initial=%d [%d], Av=%d [%d], Min=%d, Max=%d")),initial,initialX,average,repeatX,min,max); - } - return(iReport); - } - -void CRKWindow::KeyDownL(const TKeyEvent &aKey,const TTime &) - { -#if defined(LOGGING) - TLogMessageText logMessageText; - _LIT(KKeyDown,"CRKWindow::KeyDownL Code=%d '%c' State=%d (0)"); - logMessageText.Format(KKeyDown,aKey.iScanCode,aKey.iScanCode,iState); - iTest->LOG_MESSAGE(logMessageText); -#endif - switch(iState) - { - case EStateWaitingForKeyDown: - SetState(EStateWaitingForKeyCode); - iDownCode=aKey.iScanCode; - break; - default:; - } - } - -void CRKWindow::KeyUpL(const TKeyEvent &aKey,const TTime &) - { -#if defined(LOGGING) - TLogMessageText logMessageText; - _LIT(KKeyUp,"CRKWindow::KeyUpL Code=%d (%c) State=%d Down=%d"); - logMessageText.Format(KKeyUp,aKey.iScanCode,aKey.iScanCode,iState,iDownCode); - iTest->LOG_MESSAGE(logMessageText); -#endif - if (aKey.iScanCode==iDownCode) - { - switch(iState) - { - case EStateWaitingForKeyUp: - SetState(EStateInactive); - break; - default: - SetState(EStateError); - break; - } - CActiveScheduler::Stop(); - } - } - -void CRKWindow::WinKeyL(const TKeyEvent &aKey,const TTime &aTime) - { - if (aKey.iCode==EKeyEscape) - { - CActiveScheduler::Stop(); - iTest->iAbort=ETrue; - } -#if defined(LOGGING) - TLogMessageText logMessageText; - _LIT(KKey,"CRKWindow::WinKeyL Code=%d (%c) State=%d RepeatCount=%d"); - logMessageText.Format(KKey,aKey.iScanCode,aKey.iScanCode,iState,iRepCount); - iTest->LOG_MESSAGE(logMessageText); -#endif - if (aKey.iCode==32) - { - switch(iState) - { - case EStateWaitingForKeyCode: - SetState(EStateWaitingForFirstRepeat); - iPrevTime=aTime; - break; - case EStateWaitingForFirstRepeat: - iRepCount=1; - iInitialGap = I64LOW(aTime.MicroSecondsFrom(iPrevTime).Int64()); - SetState(EStateWaitingForNthRepeat); - break; - case EStateWaitingForNthRepeat: - if (iRepCount==5) - SetState(EStateWaitingForKeyUp); - else - { - TTimeIntervalMicroSeconds32 gap(I64LOW(aTime.MicroSecondsFrom(iPrevTime).Int64())); - #if defined(LOGGING) - TLogMessageText logMessageText; - _LIT(KRepeatGap,"Repeat after %d"); - logMessageText.AppendFormat(KRepeatGap,gap.Int()); - iTest->LOG_MESSAGE(logMessageText); - TheClient->Flush(); - #endif - if (gapiMaxGap) - iMaxGap=gap; - iTotalGap=iTotalGap.Int()+gap.Int(); // Horrible way to do a += - iRepCount++; - SetState(EStateWaitingForNthRepeat); - } - case EStateWaitingForKeyUp: // Do nothing here - break; - default: - //iTest->Test(EFalse); - iTest->TestBase()->SimulateKey(TRawEvent::EKeyUp,EStdKeySpace); - CActiveScheduler::Stop(); - } - iPrevTime=aTime; - } - } - -void CRKWindow::SetKeyboardRepeatRate(const TTimeIntervalMicroSeconds32 &aInitialTime, const TTimeIntervalMicroSeconds32 &aTime) - { - iInitialRepeatSet=aInitialTime; - iRepeatSet=aTime; - iMinGap=TTimeIntervalMicroSeconds32(100000000); // Any very big number will do - iMaxGap=TTimeIntervalMicroSeconds32(0); - iTotalGap=TTimeIntervalMicroSeconds32(0); - SetState(EStateWaitingForKeyDown); - Client()->iWs.Flush(); - } - -// - -CTKRepeat::CTKRepeat(CTestStep* aStep) : CTWsGraphicsBase(aStep) - { - } - -CTKRepeat::~CTKRepeat() - { - CTWin::Delete(iWin); - Client()->iWs.SetKeyboardRepeatRate(iOldInitialTime, iOldTime); - } - -void CTKRepeat::ConstructL() - { - TheClient->iWs.SetFocusScreen(iTest->iScreenNumber); - iWin=new(ELeave) CRKWindow(this); - TSize screenSize=Client()->iGroup->Size(); - iWin->SetUpL(TPoint(5,5),TSize(Min(Max(screenSize.iWidth/2,250),screenSize.iWidth-10),screenSize.iHeight-10),Client()->iGroup,*Client()->iGc); - Client()->iGroup->WinTreeNode()->SetOrdinalPosition(0); - Client()->iGroup->SetCurrentWindow(iWin); - Client()->iWs.GetKeyboardRepeatRate(iOldInitialTime, iOldTime); - iTest->SimulateKeyDownUp(EStdKeyLeftCtrl); - iTest->SimulateKeyDownUp(EStdKeyRightCtrl); - TInt mods=Client()->iWs.GetModifierState(); - TheClient->WaitForRedrawsToFinish(); //Let all pending events be processed before test begins - _LIT(KLog,"Initial Modifiers state 0x%x (ideally should be zero)"); - LOG_MESSAGE2(KLog,mods); - } - -TInt CTKRepeat::CheckReportL() - { - if (iWin->CheckResults()) - { - /*CTDialog *dialog=new(ELeave) CTDialog(); - dialog->SetTitle(_L("Keyboard repeat innacuracies")); - dialog->SetLine1(iWin->Report()); - dialog->SetNumButtons(3); - dialog->SetButtonText(0,_L("Okay")); - dialog->SetButtonText(1,_L("Retest")); - dialog->SetButtonText(2,_L("Fail")); - dialog->ConstructLD(*Client()->iGroup,*Client()->iGc); - switch(dialog->Display()) - { - case 0: - break; - case 1: - return(ETrue); // Redo test - case 2: - Client()->iGroup->ClearCurrentWindow(); - Test(EFalse); - break; - } - */} - return(EFalse); - } - -void CTKRepeat::TestKeyboardRepeatRateL(const TTimeIntervalMicroSeconds32 &aInitialTime, const TTimeIntervalMicroSeconds32 &aTime) - { - do - { - #if defined(LOGGING) - const TInt KOneSec=1000000; - const TInt KOneHundrethSec=KOneSec/100; - TLogMessageText logMessageText; - _LIT(KRepeatRate,"Repeat Rate Initial=%d.%02dsecs, Subsequent=%d.%02dsecs"); - logMessageText.Format(KRepeatRate,aInitialTime.Int()/KOneSec,(aInitialTime.Int()%KOneSec)/KOneHundrethSec - ,aTime.Int()/KOneSec,(aTime.Int()%KOneSec)/KOneHundrethSec); - LOG_MESSAGE(logMessageText); - #endif - TheClient->iWs.SetKeyboardRepeatRate(aInitialTime, aTime); - iWin->SetKeyboardRepeatRate(aInitialTime, aTime); - CActiveScheduler::Start(); - if (iAbort) - { - iTest->AbortL(); - } - } while(CheckReportL()); - } - -void CTKRepeat::RunTestCaseL(TInt /*aCurTestCase*/) - { - _LIT(KTestName1,"Keyboard Repeat 1"); - _LIT(KTestName2,"Keyboard Repeat 2"); - _LIT(KTestName3,"Keyboard Repeat 3"); - _LIT(KTestName4,"Keyboard Repeat 4"); - ((CTKRepeatStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); - switch(++iTest->iState) - { -/** - - @SYMTestCaseID GRAPHICS-WSERV-0311 - - @SYMDEF DEF081259 - - @SYMTestCaseDesc Test that a key can be repeatedly struck after a second, then every half second - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions Simulate a key being struck first after a second and then repeatedly every - half second and check the response time to the key strike is correct - - @SYMTestExpectedResults Response time each time the key is struck is correct - -*/ - case 1: - ((CTKRepeatStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0311")); - iTest->LogSubTest(KTestName1); - TestKeyboardRepeatRateL(TTimeIntervalMicroSeconds32(1000000), TTimeIntervalMicroSeconds32(500000)); - break; -/** - - @SYMTestCaseID GRAPHICS-WSERV-0312 - - @SYMDEF DEF081259 - - @SYMTestCaseDesc Test that a key can be repeatedly struck after a 5th of a second, then every 10th of a second - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions Simulate a key being struck first after a 5th of a second and then repeatedly every - 10th of a second and check the response time to the key strike is correct - - @SYMTestExpectedResults Response time each time the key is struck is correct - -*/ - case 2: - ((CTKRepeatStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0312")); - iTest->LogSubTest(KTestName2); - TestKeyboardRepeatRateL(TTimeIntervalMicroSeconds32(200000), TTimeIntervalMicroSeconds32(100000)); - break; -/** - - @SYMTestCaseID GRAPHICS-WSERV-0313 - - @SYMDEF DEF081259 - - @SYMTestCaseDesc Test that a key can be repeatedly struck immediately, then every 10th of a second - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions Simulate a key being struck first immediately and then repeatedly every - 10th of a second and check the response time to the key strike is correct - - @SYMTestExpectedResults Response time each time the key is struck is correct - -*/ - case 3: - ((CTKRepeatStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0313")); - iTest->LogSubTest(KTestName3); - TestKeyboardRepeatRateL(TTimeIntervalMicroSeconds32(0), TTimeIntervalMicroSeconds32(100000)); - break; -/** - - @SYMTestCaseID GRAPHICS-WSERV-0314 - - @SYMDEF DEF081259 - - @SYMTestCaseDesc Test that a key can be repeatedly struck after a 10 of a second, then every 10th of a second - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions Simulate a key being struck first after a 10th of a second and then repeatedly every - 10th of a second and check the response time to the key strike is correct - - @SYMTestExpectedResults Response time each time the key is struck is correct - -*/ - - case 4: - ((CTKRepeatStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0314")); - iTest->LogSubTest(KTestName4); - TestKeyboardRepeatRateL(TTimeIntervalMicroSeconds32(100000), TTimeIntervalMicroSeconds32(100000)); - break; - case 5: - ((CTKRepeatStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - ((CTKRepeatStep*)iStep)->CloseTMSGraphicsStep(); - TestComplete(); - break; - } - ((CTKRepeatStep*)iStep)->RecordTestResultL(); - } - -__WS_CONSTRUCT_STEP__(KRepeat) - diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TKRepeat.H --- a/windowing/windowserver/tauto/TKRepeat.H Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,110 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef __TKREPEAT_H__ -#define __TKREPEAT_H__ - -#include -#include -#include -#include "../tlib/testbase.h" -#include "AUTO.H" -#include "TGraphicsHarness.h" - -class CRKWindow; - -class CTKRepeat : public CTWsGraphicsBase - { - friend class CRKWindow; -public: - CTKRepeat(CTestStep* aStep); - ~CTKRepeat(); - void ConstructL(); - void TestKeyboardRepeatRateL(const TTimeIntervalMicroSeconds32 &aInitialTime, const TTimeIntervalMicroSeconds32 &aTime); - TBool CheckReportL(); -public: - TBool iAbort; -protected: -//from CTGraphicsStep - virtual void RunTestCaseL(TInt aCurTestCase); -private: - inline TestClient *Client() {return TheClient;} -private: - TTimeIntervalMicroSeconds32 iOldInitialTime; - TTimeIntervalMicroSeconds32 iOldTime; - CRKWindow *iWin; - TSize iWinSize; - TInt iState; - }; - -class CRKWindow : public CTWin - { - enum TRKStates { - EStateWaitingForKeyDown, - EStateWaitingForKeyCode, - EStateWaitingForFirstRepeat, - EStateWaitingForNthRepeat, - EStateWaitingForKeyUp, - EStateInactive, - EStateError, - }; -public: - CRKWindow(CTKRepeat *aTest); - void SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc); - void SetState(TRKStates aState); - void SetKeyboardRepeatRate(const TTimeIntervalMicroSeconds32 &aInitialTime, const TTimeIntervalMicroSeconds32 &aTime); - void WinKeyL(const TKeyEvent &,const TTime &); - void KeyUpL(const TKeyEvent &aKey,const TTime &aTime); - void KeyDownL(const TKeyEvent &aKey,const TTime &aTime); - void Draw(); - TDesC& Report(); - TBool CheckResults(); - void SendEvent(); -protected: - TInt iConnIndex; - CTKRepeat *iTest; - TRgb iBack; - TRKStates iState; - TInt iDownCode; - TInt iRepCount; - TTimeIntervalMicroSeconds32 iInitialRepeatSet; - TTimeIntervalMicroSeconds32 iRepeatSet; - TTime iPrevTime; - TTimeIntervalMicroSeconds32 iInitialGap; - TTimeIntervalMicroSeconds32 iTotalGap; - TTimeIntervalMicroSeconds32 iMinGap; - TTimeIntervalMicroSeconds32 iMaxGap; - TBuf<0x40> iReport; - }; - -class CTKRepeatStep : public CTGraphicsStep - { -public: - CTKRepeatStep(); -protected: - //from CTGraphicsStep - virtual CTGraphicsBase* CreateTestL(); - }; - -_LIT(KTKRepeatStep,"TKRepeat"); - - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TMDISPLAY.CPP --- a/windowing/windowserver/tauto/TMDISPLAY.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,232 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Multiple display test -// -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - - - -#include "TMDISPLAY.H" -#include -// -// -CTClient* CreateClientL() - { - return (TheClient=new(ELeave) TestClient()); - } - -TInt ProcMultiDisplay(TAny* aScreenNo) - { - return TestLibStartUp(CreateClientL,(TInt)aScreenNo); - } - - -// -// - -CTMultiDisplay::CTMultiDisplay(CTestStep* aStep) : CTWsGraphicsBase(aStep) - { - INFO_PRINTF1(_L("Testing Mutli display functions")); - } - -void CTMultiDisplay::ConstructL() - { - } - -CTMultiDisplay::~CTMultiDisplay() - { - } - -TInt DoSetFocusScreenL(TInt aFocusScreen,TAny* /*aArg*/) - { - RWsSession ws; - User::LeaveIfError(ws.Connect()); - ws.SetFocusScreen(aFocusScreen); - ws.Close(); - return EWsExitReasonBad; - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-0051 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test focusing on the two different screens - available - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Test the response to different calls to focus - on the two screens available - -@SYMTestExpectedResults Foucisng on the different screens is correct -*/ -void CTMultiDisplay::DoFocusScreenTestL() - { - _LIT(KSubTitle,"FocusScreen API"); - INFO_PRINTF1(KSubTitle); - - TInt numberOfScreens; - HAL::Get(HALData::EDisplayNumberOfScreens, numberOfScreens); - TInt oldFocus=TheClient->iWs.GetFocusScreen(); - - // test case #1: out of bounds screen number - // expected result: client panic and focus stays on current screen - TEST(iTest->TestWsPanicL(&DoSetFocusScreenL,EWservPanicScreenNumber,-1,NULL)); - TEST(TheClient->iWs.GetFocusScreen()==oldFocus); - if (TheClient->iWs.GetFocusScreen()!=oldFocus) - INFO_PRINTF3(_L("TheClient->iWs.GetFocusScreen() return value - Expected: %d, Actual: %d"), oldFocus, TheClient->iWs.GetFocusScreen()); - - TEST(iTest->TestWsPanicL(&DoSetFocusScreenL,EWservPanicScreenNumber,numberOfScreens,NULL)); - TEST(TheClient->iWs.GetFocusScreen()==oldFocus); - if (TheClient->iWs.GetFocusScreen()!=oldFocus) - INFO_PRINTF3(_L("TheClient->iWs.GetFocusScreen() return value - Expected: %d, Actual: %d"), oldFocus, TheClient->iWs.GetFocusScreen()); - - - // test case #2: new focus equals to current focus - // expected result: KErrNone and focus stays on current screen - TInt ret = TheClient->iWs.SetFocusScreen(oldFocus); - TEST(ret==KErrNone && TheClient->iWs.GetFocusScreen()==oldFocus); - if (ret!=KErrNone || TheClient->iWs.GetFocusScreen()!=oldFocus) - INFO_PRINTF5(_L("TheClient->iWs.SetFocusScreen(oldFocus)==KErrNone && TheClient->iWs.GetFocusScreen()==oldFocus - Expected: %d and %d, Actual: %d and %d"),KErrNone, oldFocus, ret, TheClient->iWs.GetFocusScreen()); - - - // test case #3: set focus to screen N where screen N is empty (doesn't have any windows) - // expected result: KErrNotFound and focus stays on current screen - TInt i; - for(i=1;iiWs.SetFocusScreen(i); - TEST(ret==KErrNotReady && TheClient->iWs.GetFocusScreen()==oldFocus); - if (ret!=KErrNotReady || TheClient->iWs.GetFocusScreen()!=oldFocus) - INFO_PRINTF5(_L("TheClient->iWs.SetFocusScreen(i)==KErrNotReady && TheClient->iWs.GetFocusScreen()==oldFocus - Expected: %d and %d, Actual: %d and %d"),KErrNotReady, oldFocus, ret, TheClient->iWs.GetFocusScreen()); - } - - // test case #4: set focus to screen N where screen N has focus-able window - // expected result: KErrNone and focus is set to screen N - CArrayPtrFlat* wins; - wins=new(ELeave) CArrayPtrFlat(numberOfScreens); - CleanupStack::PushL(wins); - for(i=0;iConstructL(); - wins->AppendL(win); - } - - for(i=1;iiWs.SetFocusScreen(i); - TEST(ret==KErrNone && TheClient->iWs.GetFocusScreen()==i); - if (ret!=KErrNone || TheClient->iWs.GetFocusScreen()!=i) - INFO_PRINTF5(_L("TheClient->iWs.SetFocusScreen(i)==KErrNone && TheClient->iWs.GetFocusScreen()==i - Expected: %d and %d, Actual: %d and %d"),KErrNone, i, ret, TheClient->iWs.GetFocusScreen()); - - } - - // test case #5: set focus back from screen N to main screen (screen 0) - // expected result: KErrNone and focus is set to screen 0 - ret = TheClient->iWs.SetFocusScreen(0); - TEST(ret==KErrNone && TheClient->iWs.GetFocusScreen()==0); - if (ret!=KErrNone || TheClient->iWs.GetFocusScreen()!=0) - INFO_PRINTF5(_L("TheClient->iWs.SetFocusScreen(0)==KErrNone && TheClient->iWs.GetFocusScreen()==0 - Expected: %d and %d, Actual: %d and %d"),KErrNone, 0, ret, TheClient->iWs.GetFocusScreen()); - - CleanupStack::PopAndDestroy(numberOfScreens+1,wins); - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-0052 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Launch a test from a new process and check - that it passes indepenedent of screen focus - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Focus on a screen, launch a test process, - switch to focus on the other screen, then - then check the test process passed - -@SYMTestExpectedResults The test in the process passed -*/ -void CTMultiDisplay::DoScreenTestL(TInt aScreenNo) - { - _LIT(KSubTest,"Screen %d"); - TBuf<16> subMsg; - - const TInt numScreens=TheClient->iWs.NumberOfScreens(); - if (numScreens<=aScreenNo) - { - _LIT(KLog,"WARNING!! Cannot run test for screen %d as the device only has %d screens."); - LOG_MESSAGE3(KLog,aScreenNo,numScreens); - aScreenNo=numScreens-1; - } - - subMsg.AppendFormat(KSubTest,aScreenNo); - LOG_MESSAGE(subMsg); - - // Must switch focus screen to relevant screen manually - CMinWin* win=new(ELeave) CMinWin(aScreenNo); - CleanupStack::PushL(win); - win->ConstructL(); - TheClient->iWs.SetFocusScreen(aScreenNo); - - CleanupStack::PopAndDestroy(win); - TheClient->iWs.SetFocusScreen(0); - CTestBase::iScreenNo=aScreenNo; - - //Set CTestBase::iNumberOfGrpWndsOnPrimaryScreenWithZeroPriority with the number of window groups - //in default screen with priority zero. This will be used in TGwHandle test case. - CTestBase::iNumberOfGrpWndsOnPrimaryScreenWithZeroPriority = TheClient->iWs.NumWindowGroups(0) - 1; - } - -void CTMultiDisplay::RunTestCaseL(TInt /*aCurTestCase*/) - { - _LIT(KTest1,"Focus Screen"); - _LIT(KTest2,"Screen"); - ((CTMultiDisplayStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); - - switch (++iTest->iState) - { - case 1: - ((CTMultiDisplayStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0051")); - iTest->LogSubTest(KTest1); - DoFocusScreenTestL(); - break; - case 2: - ((CTMultiDisplayStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0052")); - iTest->LogSubTest(KTest2); - DoScreenTestL(1); - break; - default: - ((CTMultiDisplayStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - ((CTMultiDisplayStep*)iStep)->CloseTMSGraphicsStep(); - TestComplete(); - break; - } - ((CTMultiDisplayStep*)iStep)->RecordTestResultL(); - } - -__WS_CONSTRUCT_STEP__(MultiDisplay) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TMDISPLAY.H --- a/windowing/windowserver/tauto/TMDISPLAY.H Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,61 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// TBLANK.H -// -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef __TMDISPLAY_H__ -#define __TMDISPLAY_H__ - -#include "AUTO.H" -#include "TGraphicsHarness.h" -#include "../tlib/testbase.h" - -class CTMultiDisplay : public CTWsGraphicsBase - { -public: - CTMultiDisplay(CTestStep* aStep); - CTMultiDisplay(); - void ConstructL(); - TestState DoTestL(); - ~CTMultiDisplay(); - -protected: -//from CTGraphicsStep - virtual void RunTestCaseL(TInt aCurTestCase); - -private: - void DoFocusScreenTestL(); - void DoScreenTestL(TInt aScreenNo); - }; - -class CTMultiDisplayStep : public CTGraphicsStep - { -public: - CTMultiDisplayStep(); -protected: - //from CTGraphicsStep - virtual CTGraphicsBase* CreateTestL(); - }; - -_LIT(KTMultiDisplayStep,"TMultiDisplay"); - - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TMESSAGE.CPP --- a/windowing/windowserver/tauto/TMESSAGE.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,471 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - - -#include "TMESSAGE.H" - -const TInt KTotalNumberOfTestMessages=5; -const TInt KMaxNumOfMessagesInActiveQueue=21; -const TInt KMaxNumOfSyncMessages=25; -const TInt KNumOfTestCases=7; -TInt MsgCountCheck=0; -TInt SyncSendReceiveCount=0; -TUid UidAtFirstLocation; -TUid UidAtLastLocation; -TBool TestNeedsExtraCheck=EFalse; - -CTMessage::CTMessage(CTestStep* aStep) : CTWsGraphicsBase(aStep), iSyncSendReceiveFlag(EFalse), iCounter(-1), iState(0) - { - } - -TInt CTMessage::CreateAndSendMessages(TInt aCount,TInt aNoOfMessages) - { - CMessageReceiver* msgReceiver=(*iMessageReceiver)[iState]; - TInt identifer=msgReceiver->GroupWin()->Identifier(); - TInt length=aCount*2; - TUint8 modificationFactor=(TUint8 )(aCount*3+1); - TUint8 msgValue=0; - if(!iSyncSendReceiveFlag && TestNeedsExtraCheck) - { - if(aCount==0) - { - UidAtFirstLocation=TUid::Uid(length+(modificationFactor<<24)); - } - else if(aCount==(aNoOfMessages-1)) - { - UidAtLastLocation=TUid::Uid(length+(modificationFactor<<24)); - } - } - iMsg->Des().Zero(); - for(TInt index=0;indexDes().Append(msgValue); - } - return TheClient->iWs.SendMessageToWindowGroup(identifer, TUid::Uid(length+(modificationFactor<<24)), *iMsg); - } - -TInt CTMessage::CallbackLowPriority(TAny* aMessageTest) - { - return static_cast(aMessageTest)->SendSyncMessages(); - } - -TInt CTMessage::SendSyncMessages() - { - if(iSyncSendReceiveFlag && iCounter++iWs.NumWindowGroups(); //Make sure all asyncronus calls have been processed - CTEventBase& eventHandler=*TheClient->EventHandler(); - if (eventHandler.iStatus.Int()==KRequestPending) - CActiveScheduler::Stop(); - else - return ETrue; - return EFalse; - } - -CTMessage::~CTMessage() - { - iMessageReceiver->ResetAndDestroy(); - iMessageReceiver->Close(); - delete iMessageReceiver; - iLowPriorityObject->Cancel(); - delete iLowPriorityObject; - iLowPriorityObject=NULL; - delete iMsg; - } - -void CTMessage::ConstructL() - { - iLowPriorityObject= new(ELeave) CLowPriorityIdle(); - iMessageReceiver=new(ELeave) RPointerArray(KNumOfTestCases); - iMsg=HBufC8::NewL(KMaxNumOfSyncMessages*2); - for(TInt index=0;indexConstructL(); - iMessageReceiver->AppendL(messageReceiver); - } - } - - -CLowPriorityIdle::CLowPriorityIdle() : CIdle(EPriorityIdle) - { - CActiveScheduler::Add(this); - } - -TInt CLowPriorityIdle::RunError(TInt /*aError*/) - { - CActiveScheduler::Stop(); - return KErrNone; - } - -LOCAL_C TInt DoPanicTest(TInt aInt, TAny *) - { - switch(aInt) - { - case 1: - User::Panic(KWSERV,EWservPanicGcActive); - break; - } - return(EWsExitReasonBad); - } - -CMessageReceiver::CMessageReceiver(CTClient *aClient, CTMessage *aTMessage) : CTWindowGroup(aClient), iMsgCount(0) - { - iTMessage = aTMessage; - } - -#define MESSAGES_READ 1 //Change to 2 to test the 16-bit functions too. -void CMessageReceiver::MessageReady(const TWsEvent& aEvent) - { - iTMessage->OnMessageReceived(aEvent, iMsgCount); - } - -void CTMessage::OnMessageReceived(const TWsEvent& aEvent, TInt& aMsgCount) - { - aMsgCount++; - if(aMsgCount>MsgCountCheck) - { - return; - } - if (MESSAGES_READ*(aMsgCount/MESSAGES_READ)iWs.FetchMessage(uid, msgPtr, aEvent); - TEST(retValue==KErrNone); - //GroupWin()->FetchMessage(uid, msgPtr2); - if(TestNeedsExtraCheck) - { - TEST(uid==(aMsgCount==1?UidAtFirstLocation:UidAtLastLocation)); - } - TInt msgLength=(uid.iUid)&0xFFFFFF; - TUint8 uidFactor=(TUint8)((uid.iUid&0xFF000000)>>24); - TBool retVal = msgPtr.Length()==msgLength; - TEST(retVal); - if (!retVal) - INFO_PRINTF3(_L("msgPtr.Length()==msgLength - Expected: %d, Actual: %d"), msgLength, msgPtr.Length()); - - TUint8 check=0; - for(TInt index=0;indexTestWsPanicL(&DoPanicTest,EWservPanicGcActive,1)); - iTest->CloseAllPanicWindows(); - } - -void CTMessage::MessageTests(TInt aNoOfMessages,TInt aMsgCountCheck,TBool aSyncSendReceiveFlag,TBool aTestNeedsExtraCheck) - { - iSyncSendReceiveFlag=aSyncSendReceiveFlag; - TestNeedsExtraCheck=aTestNeedsExtraCheck; - MsgCountCheck=aMsgCountCheck; - iLowPriorityObject->Start(TCallBack(CallbackLowPriority,this)); - - if(iSyncSendReceiveFlag) - { - //Messages will be sent and received one by one using the function SendSyncMessages(). - CActiveScheduler::Start(); - } - else - { - for(TInt count=0;countMessageCount(); - TEST(msgCount==MsgCountCheck); - if (msgCount!=MsgCountCheck) - { - _LIT(KLog,"Number of messages recieved=%d expected=%d"); - LOG_MESSAGE3(KLog,msgCount,MsgCountCheck); - } - } - } - -/** - Test delivery group messages in case when event queue is overflow - */ -void CTMessage::TestMessageQueueOverflowL() - { - const TInt numMaxMessages = 60; - TInt numWasteMessages = 0; - TInt numWgMessages = 5; - - TInt gotRealWasteMessages = 0; - TInt gotRealWgMessages = 0; - - const TInt oneSecond = 1000000; - const TInt allPossibleMessages = 500; - - RWsSession senderWsSession; - RWindowGroup senderGroupWin; - TInt sndrHanGrpWin = 7777; - - RWsSession receiverWsSession; - RWindowGroup receiverGroupWin; - TInt rcvrHanGrpWin = 8888; - - TRequestStatus testStatus; - TRequestStatus timerStatus; - TWsEvent wasteEvent; - TWsEvent event; - - RTimer timer; - timer.CreateLocal(); - CleanupClosePushL(timer); - - // Create sender WsSession and the window group - User::LeaveIfError(senderWsSession.Connect()); - CleanupClosePushL(senderWsSession); - - senderGroupWin = RWindowGroup(senderWsSession); - User::LeaveIfError(senderGroupWin.Construct(sndrHanGrpWin)); - CleanupClosePushL(senderGroupWin); - - // Create reciever WsSession and the window group - User::LeaveIfError(receiverWsSession.Connect()); - CleanupClosePushL(receiverWsSession); - - receiverGroupWin = RWindowGroup(receiverWsSession); - User::LeaveIfError(receiverGroupWin.Construct(rcvrHanGrpWin)); - CleanupClosePushL(receiverGroupWin); - - TInt err = KErrNone; - - // Send waste events to the receiver and overflow the event queue - for (TInt ind = 0; ind < numMaxMessages; ind++) - { - wasteEvent.SetType(sndrHanGrpWin); - err = senderWsSession.SendEventToWindowGroup(receiverGroupWin.Identifier(), wasteEvent); - if (err != KErrNone) - { - numWasteMessages = ind; // Real number waste messages that was sent - break; - } - } - - // Send messages to the receiver - for (TInt ind = 0; ind < numWgMessages; ind++) - { - TInt uidData = ind + sndrHanGrpWin; - TPtr8 msg((unsigned char*) &uidData, sizeof(uidData)); - err = senderWsSession.SendMessageToWindowGroup(receiverGroupWin.Identifier(), TUid::Uid(uidData), msg); - if (err != KErrNone) - { - LOG_MESSAGE2(_L("UnExpected Error Code = %d"),err); - numWgMessages = ind; // Real number window group messages that was sent - } - } - - // Check and count sent messages - for (TInt ind = 0; ind < allPossibleMessages; ind++) - { - receiverWsSession.EventReady(&testStatus); - timer.After(timerStatus, oneSecond); - User::WaitForRequest(testStatus, timerStatus); - if (testStatus == 0) - { - // Test incoming events - receiverWsSession.GetEvent(event); - if (event.Type() == sndrHanGrpWin) - { - ++gotRealWasteMessages; - } - else if (event.Type() == EEventMessageReady) - { - if (gotRealWgMessages == 0) - { - for (TInt ind = 0; ind < numMaxMessages; ind++) - { - wasteEvent.SetType(sndrHanGrpWin); - err = senderWsSession.SendEventToWindowGroup(receiverGroupWin.Identifier(), wasteEvent); - if (err == KErrNone) - { - ++numWasteMessages; - } - else - { - break; - } - } - } - ++gotRealWgMessages; - TUid uid; - TPtr8 msgPtr(NULL,0); - err = receiverWsSession.FetchMessage(uid, msgPtr, event); - User::Free((TAny *) msgPtr.Ptr()); - } - // testStatus has been completed. Hence, Cancel the timer. - timer.Cancel(); - User::WaitForRequest(timerStatus); - } - else - { - // Times out, cancel the event notification - receiverWsSession.EventReadyCancel(); - User::WaitForRequest(testStatus); - // All events were recieved - break; - } - } - - LOG_MESSAGE3(_L("Got Waste message = %d expected =%d"),gotRealWasteMessages,numWasteMessages); - LOG_MESSAGE3(_L("Got Group message = %d expected =%d"),gotRealWgMessages,numWgMessages); - TEST(gotRealWasteMessages == numWasteMessages); - TEST(gotRealWgMessages == numWgMessages); - - CleanupStack::PopAndDestroy(&receiverGroupWin); - CleanupStack::PopAndDestroy(&receiverWsSession); - CleanupStack::PopAndDestroy(&senderGroupWin); - CleanupStack::PopAndDestroy(&senderWsSession); - CleanupStack::PopAndDestroy(&timer); - - TheClient->iWs.Flush(); - - } - -void CTMessage::RunTestCaseL(TInt /*aCurTestCase*/) - { - _LIT(KMsgTest0,"Message test 1"); - _LIT(KMsgTest1,"Message test 2"); - _LIT(KMsgTest2,"Message test 3"); - _LIT(KMsgTest3,"Message test 4"); - _LIT(KMsgTest4,"Message test 5"); - _LIT(KMsgTest5,"Message test 6"); - _LIT(KMsgTest6,"Message test 7"); - _LIT(KMsgTest7,"Message test 8 - when event queue is overflow"); - - iState=iTest->iState; // used by iMessageReceiver array - ((CTMessageStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); - switch(++iTest->iState) - { -/** -@SYMTestCaseID GRAPHICS-WSERV-0084 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test message sending and receiving - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Generates 5 short messages and sends them to window group, window group receives them - -@SYMTestExpectedResults Expects that received messages have the same length and the same content as those sent -*/ - case 1: - ((CTMessageStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0084")); - iTest->LogSubTest(KMsgTest0); - MessageTests(KTotalNumberOfTestMessages,KTotalNumberOfTestMessages,EFalse,EFalse); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0406 - -@SYMDEF DEF102201,DEF141447 - -@SYMTestCaseDesc Test message sending and receiving - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Generates some diffrent size of messages and sends them to window group, window group receives them - -@SYMTestExpectedResults Expects that received messages have the same length and the same content as those sent -*/ - case 2: - ((CTMessageStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0406")); - iTest->LogSubTest(KMsgTest1); - MessageTests(KMaxNumOfMessagesInActiveQueue-1,KMaxNumOfMessagesInActiveQueue-1,EFalse,EFalse); - break; - case 3: - ((CTMessageStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0406")); - iTest->LogSubTest(KMsgTest2); - MessageTests(KMaxNumOfMessagesInActiveQueue,2,EFalse,ETrue); - break; - case 4: - ((CTMessageStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0406")); - iTest->LogSubTest(KMsgTest3); - MessageTests(KMaxNumOfMessagesInActiveQueue+1,2,EFalse,ETrue); - break; - case 5: - ((CTMessageStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0406")); - iTest->LogSubTest(KMsgTest4); - MessageTests(KMaxNumOfMessagesInActiveQueue+2,2,EFalse,ETrue); - break; - case 6: - ((CTMessageStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0406")); - iTest->LogSubTest(KMsgTest5); - SyncSendReceiveCount=KMaxNumOfSyncMessages; - MessageTests(KMaxNumOfSyncMessages,KMaxNumOfSyncMessages,ETrue,EFalse); - break; - case 7: - ((CTMessageStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0406")); - iTest->LogSubTest(KMsgTest6); - MessageTests(KMaxNumOfMessagesInActiveQueue+1,2,EFalse,ETrue); - ((*iMessageReceiver)[iState])->ResetMessageCount(); - SyncSendReceiveCount=KTotalNumberOfTestMessages; - MessageTests(KTotalNumberOfTestMessages,KTotalNumberOfTestMessages,ETrue,EFalse); - break; - case 8: - ((CTMessageStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0406")); - iTest->LogSubTest(KMsgTest7); - TestMessageQueueOverflowL(); - ((CTMessageStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - ((CTMessageStep*)iStep)->CloseTMSGraphicsStep(); - TestComplete(); - return; - } - ((*iMessageReceiver)[iState])->ResetMessageCount(); - ((CTMessageStep*)iStep)->RecordTestResultL(); - } - - -__WS_CONSTRUCT_STEP__(Message) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TMESSAGE.H --- a/windowing/windowserver/tauto/TMESSAGE.H Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,95 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef __TMESSAGE_H__ -#define __TMESSAGE_H__ - -#include -#include -#include "../tlib/testbase.h" -#include "AUTO.H" -#include "TGraphicsHarness.h" - -class CMessageReceiver; - -class CLowPriorityIdle : public CIdle - { -public: - CLowPriorityIdle(); - virtual TInt RunError(TInt aError); - }; - -class CTMessage : public CTWsGraphicsBase - { -public: - CTMessage(CTestStep* aStep); - ~CTMessage(); - void ConstructL(); - void TestPanicsL(); - void MessageTests(TInt aNoOfMessages,TInt aMsgCountCheck,TBool aSyncSendReceiveFlag,TBool aTestNeedsExtraCheck); - void OnMessageReceived(const TWsEvent &aEvent, TInt& aMsgCount); - TInt SendSyncMessages(); - static TInt CallbackLowPriority(TAny *aMessageTest); - TInt CreateAndSendMessages(TInt aCount,TInt aNoOfMessages); - void TestMessageQueueOverflowL(); - -protected: - virtual void RunTestCaseL(TInt aCurTestCase); - -private: - TBool iSyncSendReceiveFlag; - TInt iCounter; - HBufC8* iMsg; - RPointerArray* iMessageReceiver; - CLowPriorityIdle* iLowPriorityObject; - TInt iState; - }; - - -class CMessageReceiver : public CTWindowGroup - { -public: - CMessageReceiver(CTClient *aClient, CTMessage *aTMessage); - void MessageReady(const TWsEvent &aTime); - inline TInt MessageCount() - {return iMsgCount;} - inline void ResetMessageCount() - {iMsgCount=0;} -private: - CTMessage *iTMessage; // CTMessage, to call it's OnMessageReceived when message is received - TInt iMsgCount; - }; - - - -class CTMessageStep : public CTGraphicsStep - { -public: - CTMessageStep(); -protected: - //from CTGraphicsStep - virtual CTGraphicsBase* CreateTestL(); - }; - -_LIT(KTMessageStep,"TMessage"); - - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TMODCHG.CPP --- a/windowing/windowserver/tauto/TMODCHG.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,511 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Coverted from TMan test code (TMMODCHG.CPP) August 2000 -// Test modifier changed message -// -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include "TMODCHG.H" - -#define LOGGING on //Uncoment this line to get extra logging - -struct TModifierChangedTestsParams - { - TText *txt; // Text message telling user what to do - TUint changed; - TUint state; - TUint stateMask; - }; - -LOCAL_D TModifierChangedTestsParams ModifierChangedTests[]={ - {(TText *)_S("Press Caps"),EModifierCapsLock,EModifierCapsLock,EModifierCapsLock}, - {(TText *)_S("Press Caps (again)"),EModifierCapsLock,0,EModifierCapsLock}, - {(TText *)_S("Press left shift"),EModifierShift|EModifierLeftShift,EModifierShift|EModifierLeftShift,EModifierShift|EModifierLeftShift}, - {(TText *)_S("Release left shift"),EModifierShift|EModifierLeftShift,0,EModifierShift|EModifierLeftShift}, - {(TText *)_S("Press right shift"),EModifierShift|EModifierRightShift,EModifierShift|EModifierRightShift,EModifierShift|EModifierRightShift}, - {(TText *)_S("Release right shift"),EModifierShift|EModifierRightShift,0,EModifierShift|EModifierRightShift}, - {(TText *)_S("Press (left) func"),EModifierFunc|EModifierLeftFunc,EModifierFunc|EModifierLeftFunc,EModifierFunc|EModifierLeftFunc}, - {(TText *)_S("Release (left) func"),EModifierFunc|EModifierLeftFunc,0,EModifierFunc|EModifierLeftFunc}, - {(TText *)_S("Press (left) control"),EModifierCtrl|EModifierLeftCtrl,EModifierCtrl|EModifierLeftCtrl,EModifierCtrl|EModifierLeftCtrl}, - {(TText *)_S("Release (left) control"),EModifierCtrl|EModifierLeftCtrl,0,EModifierCtrl|EModifierLeftCtrl}, - }; - -// list of ModifierEvents that should be monitored -LOCAL_D TInt ModifierChangedEvents=EModifierShift|EModifierLeftShift|EModifierRightShift| - EModifierCapsLock|EModifierFunc|EModifierLeftFunc|EModifierCtrl|EModifierLeftCtrl; - -const TInt numTests=sizeof(ModifierChangedTests)/sizeof(ModifierChangedTests[0]); - - -// -// CTEventWindowGroup class // -// - -CTEventWindowGroup::CTEventWindowGroup(CTClient *aClient, CTModifiersChanged *aTest) : CTWindowGroup(aClient), iTest(aTest) - {} - -void CTEventWindowGroup::ConstructL() - { - CTWindowGroup::ConstructL(); - iGroupWin.EnableModifierChangedEvents(ModifierChangedEvents,EEventControlAlways); - } - -void CTEventWindowGroup::ModifiersChanged(const TModifiersChangedEvent &aModifiersChanged, const TTime &) - { - iTest->TestModifiersState(aModifiersChanged); // tests if event is correct - } - -void CTEventWindowGroup::KeyL(const TKeyEvent &aKey,const TTime &) - { - if (aKey.iCode==EKeyEscape || (aKey.iCode==' ' && iTest->iModSetTest)) - iTest->EndTest(); // not really needed, because timer cancels long running tests - } - -// -// CMCWindow, class // -// - -CMCWindow::CMCWindow(CTModifiersChanged *aTest) : CTWin(), iTest(aTest) - { - iBack=TRgb::Gray256(230); - } - -void CMCWindow::SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc) - { - ConstructExtLD(*parent,pos,size); - iWin.SetBackgroundColor(iBack); - Activate(); - AssignGC(aGc); - iLineHeight=iFont->HeightInPixels()*5/4; - iFontAscent=iFont->AscentInPixels(); - iXpos1=4; - iXpos2=iXpos1+12*iFont->TextWidthInPixels(_L("M")); - } - -void CMCWindow::DrawModSetLine(const TDesC &aDes,TInt aModifier,TInt iSettableModifiers) - { - iYpos+=iLineHeight; - iGc->DrawText(aDes, TPoint(iXpos1,iYpos)); - iGc->DrawText(aModifier&iSettableModifiers ? _L("Yes"):_L("No"), TPoint(iXpos2,iYpos)); - } - -void CMCWindow::Draw() - { - iGc->Clear(); - if (iTest->iModSetTest) - { - iYpos=iFontAscent+3; - TBuf<32> buf; - buf.Format(TRefByValue(_L("Settable? [0x%4x]")), iTest->iSettable); - iGc->DrawText(_L("Modifier"), TPoint(iXpos1,iYpos)); - iGc->DrawText(buf, TPoint(iXpos2,iYpos)); - DrawModSetLine(_L("Shift"),EModifierShift,iTest->iSettable); - DrawModSetLine(_L("Left Shift"),EModifierLeftShift,iTest->iSettable); - DrawModSetLine(_L("Func"),EModifierFunc,iTest->iSettable); - DrawModSetLine(_L("Caps"),EModifierCapsLock,iTest->iSettable); - DrawModSetLine(_L("NumLock"),EModifierNumLock,iTest->iSettable); - DrawModSetLine(_L("Double Click"),EModifierDoubleClick,iTest->iSettable); - } - else - iGc->DrawText(TPtrC(ModifierChangedTests[iTest->SubState()].txt), TPoint(10,20)); - } - -// - -CTModifiersChanged::CTModifiersChanged(CTestStep* aStep): CTWsGraphicsBase(aStep), - iSkipFirstModifierEvents(EFalse), iSubSchedulerRunning(EFalse) - { - } - -CTModifiersChanged::~CTModifiersChanged() - { - delete iTimeOut; - delete iWin; - delete iEventGroup; - } - -void CTModifiersChanged::ConstructL() - { - iTimeOut=new(ELeave) CTimeOut(); - iTimeOut->ConstructL(); - iWin=new(ELeave) CMCWindow(this); - iWin->SetUpL(TPoint(10,10),TSize(240,200),Client()->iGroup, *Client()->iGc); - } - -TInt CTModifiersChanged::TimeOut(TAny* aTest) // static - { - static_cast(aTest)->TimeOut(); - return(KErrNone); - } - -void CTModifiersChanged::TimeOut() - { - #if defined(LOGGING) - _LIT(KLogTimeOut,"Test timed out after %d secs."); - LOG_MESSAGE2(KLogTimeOut,KTimeOutAfter/1000000); - #endif - EndTest(); - } - -void CTModifiersChanged::EndTest() - { - TEST(EFalse); // test failed (timeout or manually cancelled) - if (iModSetTest) - { - iModSetTest=EFalse; - iWin->Invalidate(); - } - _LIT(KLogEndTest,"EndTest - State %d - SubState %d"); - LOG_MESSAGE3(KLogEndTest,iTest->iState,iSubState); - if (iSubSchedulerRunning) - { - iSubSchedulerRunning = EFalse; - CActiveScheduler::Stop(); // stop the sub-scheduler, so test-framework can execute the next test - } - } - -TInt CTModifiersChanged::SubState() const - { - return(iSubState); - } - -void CTModifiersChanged::IncSubState() - { - if (iSubStateInvalidate(); - TheClient->WaitForRedrawsToFinish(); - SendEvents(); - } - else if (iSubState>=numTests-1) // test finished successfully - { - if (iSubSchedulerRunning) - { - iSubSchedulerRunning = EFalse; - CActiveScheduler::Stop(); // stop the sub-scheduler, so test-framework can execute the next test - } - } - } - -void CTModifiersChanged::TestModifiersState(const TModifiersChangedEvent &aModifiersChanged) - { - if (iTest->iState==1) // only if currently in test 1 (add another if for further tests) - { - TInt getMods=Client()->iWs.GetModifierState(); // double check the modifiers - #if defined(LOGGING) - if (iSkipFirstModifierEvents) - { - _LIT(KLogIgnored,"### This Event is part of the initial setup and is ignored for the test. ###"); - LOG_MESSAGE(KLogIgnored); - } - TLogMessageText buf; - _LIT(KLog1,"##MC1 SS=%x Test-Modifiers=0x%x Test-Changed=0x%x Test-Mask=0x%x"); - buf.Format(KLog1,iSubState,ModifierChangedTests[iSubState].state,ModifierChangedTests[iSubState].changed,ModifierChangedTests[iSubState].stateMask); - LOG_MESSAGE(buf); - _LIT(KLog2,"##MC2 Event-Modifiers=0x%x Event-Changed=0x%x Get-Modifiers=0x%x"); - buf.Format(KLog2,aModifiersChanged.iModifiers,aModifiersChanged.iChangedModifiers,getMods); - LOG_MESSAGE(buf); - _LIT(KLog3,"##MC3 Changed: (Event) 0x%x==0x%x (Test)"); - buf.Format(KLog3,aModifiersChanged.iChangedModifiers,ModifierChangedTests[iSubState].changed); - LOG_MESSAGE(buf); - _LIT(KLog4,"##MC4 Modifier (with mask): (Event) 0x%x==0x%x (Test)"); - buf.Format(KLog4,aModifiersChanged.iModifiers&ModifierChangedTests[iSubState].stateMask,ModifierChangedTests[iSubState].state); - LOG_MESSAGE(buf); - _LIT(KLog5,"##MC5 Modifier (with mask): (Get) 0x%x==0x%x (Test)"); - buf.Format(KLog5,getMods&ModifierChangedTests[iSubState].stateMask,ModifierChangedTests[iSubState].state); - LOG_MESSAGE(buf); - #endif - if (iSkipFirstModifierEvents) // skip the events caused by the initialization - { - if(--iSkipCounter<=0) - { - iSkipFirstModifierEvents = EFalse; - } - } - else - { - if (aModifiersChanged.iChangedModifiers==ModifierChangedTests[iSubState].changed && - (aModifiersChanged.iModifiers&ModifierChangedTests[iSubState].stateMask)==ModifierChangedTests[iSubState].state && - (getMods&ModifierChangedTests[iSubState].stateMask)==ModifierChangedTests[iSubState].state) - { - IncSubState(); // subtest is successfull - } - else - { - TEST(EFalse); // subtest failed - _LIT(KLogTestFailed,"Modifier Change test failed."); - LOG_MESSAGE(KLogTestFailed); - } - } - } // if test 1 - } - -void CTModifiersChanged::BadParams() - { - } - -/** - * Resets all the modifiers after the test is finished. Make sure that all keys used in the - * test are in the up-state. - */ -void CTModifiersChanged::ResetModifiers() - { - _LIT(KLogResetModifiersError,"Error %d occured while turning off modifier 0x%x"); - TInt err; - if ((err = Client()->iWs.SetModifierState(EModifierCapsLock,ETurnOffModifier)) != KErrNone) - LOG_MESSAGE3(KLogResetModifiersError,err, EModifierCapsLock); - if ((err = Client()->iWs.SetModifierState(EModifierShift,ETurnOffModifier)) != KErrNone) - LOG_MESSAGE3(KLogResetModifiersError,err, EModifierShift); - if ((err = Client()->iWs.SetModifierState(EModifierLeftShift,ETurnOffModifier)) != KErrNone) - LOG_MESSAGE3(KLogResetModifiersError,err, EModifierLeftShift); - if ((err = Client()->iWs.SetModifierState(EModifierRightShift,ETurnOffModifier)) != KErrNone) - LOG_MESSAGE3(KLogResetModifiersError,err, EModifierRightShift); - if ((err = Client()->iWs.SetModifierState(EModifierFunc,ETurnOffModifier)) != KErrNone) - LOG_MESSAGE3(KLogResetModifiersError,err, EModifierFunc); - if ((err = Client()->iWs.SetModifierState(EModifierLeftFunc,ETurnOffModifier)) != KErrNone) - LOG_MESSAGE3(KLogResetModifiersError,err, EModifierLeftFunc); - if ((err = Client()->iWs.SetModifierState(EModifierCtrl,ETurnOffModifier)) != KErrNone) - LOG_MESSAGE3(KLogResetModifiersError,err, EModifierCtrl); - if ((err = Client()->iWs.SetModifierState(EModifierLeftCtrl,ETurnOffModifier)) != KErrNone) - LOG_MESSAGE3(KLogResetModifiersError,err, EModifierLeftCtrl); - } - -/** - * Initialises the Modifier state. All tested modifiers must be in the up-state before the - * test starts. The number of sent key simulations needed for initialization is recorded. - * Each key simulation during initialization causes a ModifierChanged event which should be - * ignored because it's not part of the actual test. - */ -void CTModifiersChanged::ModifierChangedEventsL() - { - iEventGroup=new(ELeave) CTEventWindowGroup(Client(), this); - iEventGroup->ConstructL(); - TInt modifiers=Client()->iWs.GetModifierState(); - - if ((ModifierChangedEvents&modifiers)>0) // reset modifiers if they are in the down-state - { - iSkipFirstModifierEvents = ETrue; - if ((modifiers&EModifierCapsLock)>0) - { - iTest->SimulateKeyDownUp(EStdKeyCapsLock); - ++iSkipCounter; - modifiers=Client()->iWs.GetModifierState(); - } - if ((modifiers&EModifierLeftShift)>0) - { - iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeyLeftShift); - ++iSkipCounter; - modifiers=Client()->iWs.GetModifierState(); - } - if ((modifiers&EModifierRightShift)>0) - { - iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeyRightShift); - ++iSkipCounter; - modifiers=Client()->iWs.GetModifierState(); - } - if ((modifiers&EModifierLeftFunc)>0) - { - iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeyLeftFunc); - ++iSkipCounter; - modifiers=Client()->iWs.GetModifierState(); - } - if ((modifiers&EModifierLeftCtrl)>0) - { - iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeyLeftCtrl); - ++iSkipCounter; - } - } - modifiers=Client()->iWs.GetModifierState(); - _LIT(KLog,"Initial Modifiers state 0x%x (ideally should be zero)"); - LOG_MESSAGE2(KLog,modifiers); - } - -void CTModifiersChanged::CheckModifier(TEventModifier aModifier) - { - TBool retVal; - TInt oldMods=Client()->iWs.GetModifierState(); - Client()->iWs.SetModifierState(aModifier,EToggleModifier); - TInt getMods=Client()->iWs.GetModifierState(); - if (oldMods!=getMods) - { - _LIT(KLogOff,"Attempted to turn off modifiers 0x%x, 0x%x still on"); - _LIT(KLogOn,"Attempted to turn on modifiers 0x%x, 0x%x still off"); - iSettable|=aModifier; - Client()->iWs.SetModifierState(aModifier,ETurnOffModifier); - getMods=Client()->iWs.GetModifierState(); - retVal=!(getMods&aModifier); - TEST(retVal); - if (!retVal) - LOG_MESSAGE3(KLogOff,aModifier,getMods&aModifier); - Client()->iWs.SetModifierState(aModifier,ETurnOnModifier); - getMods=Client()->iWs.GetModifierState(); - retVal=getMods&aModifier; - TEST(retVal); - if (!retVal) - LOG_MESSAGE3(KLogOn,aModifier,getMods&aModifier); - Client()->iWs.SetModifierState(aModifier,ETurnOffModifier); - getMods=Client()->iWs.GetModifierState(); - retVal=!(getMods&aModifier); - TEST(retVal); - if (!retVal) - LOG_MESSAGE3(KLogOff,aModifier,getMods&aModifier); - if (oldMods&aModifier) - Client()->iWs.SetModifierState(aModifier,ETurnOnModifier); - } - else - { - Client()->iWs.SetModifierState(aModifier,ETurnOffModifier); - retVal=oldMods==Client()->iWs.GetModifierState(); - TEST(retVal); - if (!retVal) - { - _LIT(KLog,"Attempted to turn off modifiers 0x%x, suceeded when it should have failed"); - LOG_MESSAGE2(KLog,aModifier); - } - Client()->iWs.SetModifierState(aModifier,ETurnOnModifier); - retVal=oldMods==Client()->iWs.GetModifierState(); - TEST(retVal); - if (!retVal) - { - _LIT(KLog,"Attempted to turn on modifiers 0x%x, suceeded when it should have failed"); - LOG_MESSAGE2(KLog,aModifier); - } - } - } - -void CTModifiersChanged::SetModifiers() - { - iModSetTest=ETrue; - for(TInt mod=1;mod!=0;mod<<=1) - CheckModifier((TEventModifier)mod); - iWin->Invalidate(); - Client()->iWs.Flush(); - } - -void CTModifiersChanged::SendEvents() - { - iTest->LogSubState(iSubState); - switch (iSubState) - { - case 0: - iTest->SimulateKeyDownUp(EStdKeyCapsLock); - break; - case 1: - iTest->SimulateKeyDownUp(EStdKeyCapsLock); - break; - case 2: - iTest->SimulateKey(TRawEvent::EKeyDown,EStdKeyLeftShift); - break; - case 3: - iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeyLeftShift); - break; - case 4: - iTest->SimulateKey(TRawEvent::EKeyDown,EStdKeyRightShift); - break; - case 5: - iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeyRightShift); - break; - case 6: - iTest->SimulateKey(TRawEvent::EKeyDown,EStdKeyLeftFunc); - break; - case 7: - iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeyLeftFunc); - break; - case 8: - iTest->SimulateKey(TRawEvent::EKeyDown,EStdKeyLeftCtrl); - break; - case 9: - iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeyLeftCtrl); - break; - default: - TEST(EFalse); - return; - } - TheClient->iWs.Flush(); - } - -void CTModifiersChanged::RunTestCaseL(TInt /*aCurTestCase*/) - { - _LIT(KModChange,"Modifier Change"); - _LIT(KTestErrors,"Bad Parameter"); - ((CTModifiersChangedStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); - switch(++iTest->iState) - { -/** -@SYMTestCaseID GRAPHICS-WSERV-0239 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test modifier changed message - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Test that modifier changed message functions correctly - -@SYMTestExpectedResults The message functions correctly -*/ - case 1: - ((CTModifiersChangedStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0239")); - iTest->LogSubTest(KModChange); - ModifierChangedEventsL(); - // start a timer to cancel the sub-scheduler - iTimeOut->Start(KTimeOutAfter,TCallBack(CTModifiersChanged::TimeOut,this)); - SendEvents(); - iSubSchedulerRunning = ETrue; - CActiveScheduler::Start(); // sub-scheduler blocks this AO (test-framework) until completion - iTimeOut->Cancel(); - ((CTModifiersChangedStep*)iStep)->RecordTestResultL(); - ((CTModifiersChangedStep*)iStep)->CloseTMSGraphicsStep(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0240 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test bad parameters for modifier changed message - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Test using bad parameters for a modifier changed message - -@SYMTestExpectedResults Responds correctly when bad parameters are used -*/ - case 2: - ((CTModifiersChangedStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0240")); - iTest->LogSubTest(KTestErrors); - BadParams(); - ((CTModifiersChangedStep*)iStep)->RecordTestResultL(); - break; - default: - ResetModifiers(); // reset modifiers, so further tests are not influenced - ((CTModifiersChangedStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - ((CTModifiersChangedStep*)iStep)->CloseTMSGraphicsStep(); - TestComplete(); - } - - - } - -__WS_CONSTRUCT_STEP__(ModifiersChanged) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TMODCHG.H --- a/windowing/windowserver/tauto/TMODCHG.H Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,116 +0,0 @@ - -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef __TMODCHG_H__ -#define __TMODCHG_H__ - -#include -#include -#include -#include "../tlib/testbase.h" -#include "AUTO.H" -#include "TGraphicsHarness.h" - - -class CTModifiersChanged; - -class CMCWindow : public CTWin - { -public: - CMCWindow(CTModifiersChanged *aTest); - void SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc); - void Draw(); - void DrawModSetLine(const TDesC &aDes,TInt aModifier,TInt iSettableModifiers); -protected: - CTModifiersChanged *iTest; - TRgb iBack; - TInt iLineHeight; - TInt iFontAscent; - TInt iYpos; - TInt iXpos1; - TInt iXpos2; - }; - -class CTEventWindowGroup : public CTWindowGroup - { -public: - CTEventWindowGroup(CTClient *aClient, CTModifiersChanged *iTest); - void ConstructL(); - void ModifiersChanged(const TModifiersChangedEvent &aModifiersChanged ,const TTime &aTime); - void KeyL(const TKeyEvent &aKey,const TTime &aTime); -private: - CTModifiersChanged *iTest; - }; - -class CTModifiersChanged : public CTWsGraphicsBase - { -public: - CTModifiersChanged(CTestStep* aStep); - ~CTModifiersChanged(); - TestState DoTestL(); - void ConstructL(); - void EndTest(); - TInt SubState() const; - void IncSubState(); - void BadParams(); - void ModifierChangedEventsL(); - void SetModifiers(); - void CheckModifier(TEventModifier aModifier); - void TestModifiersState(const TModifiersChangedEvent &aModifiersChanged); -protected: -//from CTGraphicsStep - virtual void RunTestCaseL(TInt aCurTestCase); -private: - inline TestClient* Client() {return TheClient;} - void SendEvents(); - void ResetModifiers(); - static TInt TimeOut(TAny* aTest); - void TimeOut(); -public: - TBool iModSetTest; - TInt iSettable; -private: - enum {KTimeOutAfter=30000000}; // 30 seconds (test takes 8 sec on h4) -private: - TSize iWinSize; - TInt iSubState; - CTEventWindowGroup *iEventGroup; - CMCWindow *iWin; - TBool iSkipFirstModifierEvents; - TInt iSkipCounter; - CTimeOut* iTimeOut; - TBool iSubSchedulerRunning; - }; - -class CTModifiersChangedStep : public CTGraphicsStep - { -public: - CTModifiersChangedStep(); -protected: - //from CTGraphicsStep - virtual CTGraphicsBase* CreateTestL(); - }; - -_LIT(KTModifiersChangedStep,"TModifiersChanged"); - - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TMULSCREENS.CPP --- a/windowing/windowserver/tauto/TMULSCREENS.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,666 +0,0 @@ -// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Enable Multiple Displays -// -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include "TMULSCREENS.h" - -const TInt KFstScreenNo = 0; -const TInt KSndScreenNo = 1; - -CTMulScreens::CTMulScreens(CTestStep* aStep): - CTWsGraphicsBase(aStep) - { - } - -void CTMulScreens::ConstructL() - { - User::LeaveIfError(iRws.Connect()); - iFstScreenDevice =new(ELeave) CWsScreenDevice(iRws); - TInt err = iFstScreenDevice->Construct(KFstScreenNo); - iTest->LogLeave(err); - User::LeaveIfError(err); - iNumScreens = iRws.NumberOfScreens(); - if(KSndScreenNoConstruct(KSndScreenNo); - iTest->LogLeave(err); - User::LeaveIfError(err); - } - INFO_PRINTF2(_L("The number of screens supported on this device is %d"),iNumScreens); - } - -CTMulScreens::~CTMulScreens() - { - iFstWinGp.Close(); - if(KSndScreenNo* aWindowList,TInt aScreenNumber,TInt aPriority) - TInt RWindowGroup::Construct(TUint32 aClientHandle,CWsScreenDevice* aScreenDevice) - TInt RWsSession::GetFocusWindowGroup(TInt aScreenNumber) - - @SYMTestExpectedResults Provided that a second screen is configured in the epoc.ini and the wsini.ini, this test case will create one window group on the first screen - and two window groups on the second screen. - If only one screen is configured, then it will create one group on the primary screen. - Otherwise this function leaves with a system-wide error. -*/ - -void CTMulScreens::TestCreateGroupWindowsL() - { - const TInt fstNumWinGps = iRws.NumWindowGroups(KFstScreenNo,EAllPriorities); - CArrayFixFlat* fstList = new(ELeave) CArrayFixFlat(1); - CleanupStack::PushL(fstList); - TInt err = iRws.WindowGroupList(fstList,KFstScreenNo,EAllPriorities); - TEST(err==KErrNone); - TEST(fstList->Count()==fstNumWinGps); - err = iRws.WindowGroupList(fstList); //test existing api - TEST(err==KErrNone); - TEST(fstList->Count()==(iRws.NumWindowGroups())); - iFstWinGp = RWindowGroup(iRws); - TRAP(err,iFstWinGp.Construct(ENullWsHandle,iFstScreenDevice)); - TEST(err==KErrNone); - if(err==KErrNone) - { - TEST(iRws.NumWindowGroups(KFstScreenNo,EAllPriorities) == (fstNumWinGps+1)); - } - CleanupStack::PopAndDestroy(fstList); - - //Second screen has been configured. - if(KSndScreenNo* sndList =new(ELeave) CArrayFixFlat(1); - CleanupStack::PushL(sndList); - TInt sndNumWinGps = iRws.NumWindowGroups(KSndScreenNo,iSndWinGp.OrdinalPriority()); - err = iRws.WindowGroupList(sndList,KSndScreenNo,iSndWinGp.OrdinalPriority()); - TEST(err==KErrNone); - TEST(sndList->Count()==sndNumWinGps); - - iSndWinGp.SetOrdinalPosition(iSndWinGp.OrdinalPosition(),EAllPriorities); - TInt allPriNumWinGps= iRws.NumWindowGroups(EAllPriorities); - CArrayFixFlat* allPriList =new(ELeave) CArrayFixFlat(1); - CleanupStack::PushL(allPriList); - err = iRws.WindowGroupList(EAllPriorities,allPriList); - TEST(err==KErrNone); - TEST(allPriList->Count()==allPriNumWinGps); - - CleanupStack::PopAndDestroy(2,sndList); - } - RWindowGroup trdWinGp = RWindowGroup(iRws); - TRAP(err,trdWinGp.Construct(ENullWsHandle,ETrue,iSndScreenDevice)); - TEST(err==KErrNone); - if(err==KErrNone) - { - winId = iRws.GetFocusWindowGroup(KSndScreenNo); - TEST(winId==trdWinGp.Identifier()); - trdWinGp.Close(); - } - } - } - -/** - @SYMTestCaseID GRAPHICS-WSERV-0384 - - @SYMPREQ PREQ1227 - - @SYMREQ REQ5541 - - @SYMTestCaseDependencies SYMTestCaseID GRAPHICS-WSERV-0383 - - @SYMTestCaseDesc Create a blank window on each screen. - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions Test that each blank window is created on a different screen. - API Calls:\n - TInt RBlankWindow::Construct(const RWindowTreeNode &parent, TUint32 aClientHandle) where parent is - a Window Group created on each screen. - - @SYMTestExpectedResults The background colour of the first screen changes to blue and that of the second one changes to green. - Otherwise this function leaves with a system-wide error. -*/ -void CTMulScreens::TestCreateBlankWindowsL() - { - RBlankWindow fstBlankWin(iRws); - CleanupClosePushL(fstBlankWin); - TRAPD(err,fstBlankWin.Construct(iFstWinGp,ENullWsHandle)); - TEST(err==KErrNone); - if(err==KErrNone) - { - fstBlankWin.SetRequiredDisplayMode(EColor256); - fstBlankWin.SetColor(TRgb(0,0,255)); // paint the screen blue - fstBlankWin.Activate(); - iRws.Flush(); - TheClient->WaitForRedrawsToFinish(); - User::After(6000000); - } - CleanupStack::PopAndDestroy();//fstBlankWin - - // Second screen - if(KSndScreenNoWaitForRedrawsToFinish(); - User::After(6000000); - } - CleanupStack::PopAndDestroy(); //sndBlankWin - } - } - - -/** - @SYMTestCaseID GRAPHICS-WSERV-0385 - - @SYMPREQ PREQ1227 - - @SYMREQ REQ5541 - - @SYMTestCaseDependencies SYMTestCaseID GRAPHICS-WSERV-0383 - - @SYMTestCaseDesc Test the Window Group that has the keyboard focus for each screen. - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions Call RWsSession::GetFocusWindowGroup on each screen. - API Calls:\n - TInt RWsSession::GetFocusWindowGroup(TInt aScreenNumber) - - @SYMTestExpectedResults The identifier returned by the API for each screen is tested to see if it is the expected Window Group ID; ie the - ID of the window group created in the first test case. -*/ -void CTMulScreens::TestGetFocusWindow() - { - TInt winId = iRws.GetFocusWindowGroup(KFstScreenNo); - TEST(winId==iFstWinGp.Identifier()); - if(KSndScreenNo* aWindowList,TInt aScreenNumber,TInt aPriority) - TInt RWsSession::GetFocusWindowGroup(TInt aScreenNumber) - TInt GetDefaultOwningWindow(TInt aScreenNumber) - TDisplayMode GetDefModeMaxNumColors(TInt aScreenNumber,TInt& aColor,TInt& aGray) const - TInt GetColorModeList(TInt aScreenNumber,CArrayFixFlat* aModeList) const - - @SYMTestExpectedResults The thread panics and exits with reason EWservPanicScreenNumber. -*/ -void CTMulScreens::TestPanicsL() - { - TInt firstTest = 1; - TInt lastTest = 6; - const TInt KInvalidScreenNumber = 2; - for (TInt option=firstTest;option<=lastTest;option++) - { - TEST(iTest->TestWsPanicL(&TestInvalidScreenNumberL,EWservPanicScreenNumber,option,(TAny*)KInvalidScreenNumber)); - } - } - -TInt CTMulScreens::TestInvalidScreenNumberL(TInt aOption, TAny *aScreenNumber) - { - RWsSession wsSession; - wsSession.Connect(); - switch((TInt)aOption) - { - case 1: - wsSession.NumWindowGroups((TInt)aScreenNumber,EAllPriorities); - break; - case 2: - { - CArrayFixFlat* list = new(ELeave) CArrayFixFlat(1); - wsSession.WindowGroupList(list,(TInt)aScreenNumber,EAllPriorities); - } - break; - case 3: - wsSession.GetFocusWindowGroup((TInt)aScreenNumber); - break; - case 4: - wsSession.GetDefaultOwningWindow((TInt)aScreenNumber); - break; - case 5: - { - CArrayFixFlat* list = new(ELeave) CArrayFixFlat(1); - wsSession.GetColorModeList((TInt)aScreenNumber,list); - } - break; - case 6: - { - TInt color,gray; - wsSession.GetDefModeMaxNumColors((TInt)aScreenNumber,color,gray); - } - break; - default: - User::Panic(_L("Default panic"),KErrGeneral); - break; - } - return KErrNone; - } - - -/** - @SYMTestCaseID GRAPHICS-WSERV-0390 - - @SYMPREQ PREQ1227 - - @SYMREQ REQ5541 - - @SYMTestCaseDependencies SYMTestCaseID GRAPHICS-WSERV-0383 - - @SYMTestCaseDesc Test that CWindowGc updates its screendevice each time it is activated on a window. - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions Activate the gc on both RWindows.CWindowGc::Device() is called after each activation has taken place. - API Calls:\n - void CWindowGc::Activate(RDrawableWindow &aDevice); - void CWindowGc::Deactivate(); - CGraphicsDevice* CWindowGc::Device() const - TInt RWindow::Construct(const RWindowTreeNode &parent,TUint32 aHandle); - - @SYMTestExpectedResults CWindowGc::Device() returns the screendevice on which the gc was last activated. -*/ -void CTMulScreens::TestDeviceL() - { - RWindow fstWin(iRws); - User::LeaveIfError(fstWin.Construct(iFstWinGp,ENullWsHandle)); - CleanupClosePushL(fstWin); - fstWin.Activate(); - - CWindowGc* gc=new (ELeave) CWindowGc(iFstScreenDevice); - User::LeaveIfError(gc->Construct()); - CleanupStack::PushL(gc); - gc->Activate(fstWin); - - TEST((CWsScreenDevice*)gc->Device()==iFstScreenDevice); - gc->Deactivate(); - - if(KSndScreenNoActivate(sndWin); - TEST((CWsScreenDevice*)gc->Device()==iSndScreenDevice); - gc->Deactivate(); - CleanupStack::PopAndDestroy(); - } - - CleanupStack::PopAndDestroy(2,&fstWin); - } - -/** - @SYMTestCaseID GRAPHICS-WSERV-0034 - - @SYMPREQ PREQ1227 - - @SYMREQ REQ5541 - - @SYMTestCaseDesc Test that the order of creating a screen device and window group does not matter. - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions Create a window group before creating the screen device. Create a graphics context and call activate on it. - API Calls:\n - TInt RWindowGroup::Construct(TUint32 aClientHandle) - TInt CWsScreenDevice::Construct() - void CWindowGc::Activate(RDrawableWindow &aDevice); - void CWindowGc::Deactivate(); - TInt RWindow::Construct(const RWindowTreeNode &parent,TUint32 aHandle); - - @SYMTestExpectedResults The test code does not panic with EWservPanicGroupWinScreenDeviceDeleted -*/ -void CTMulScreens::TestInitaliseScreenDeviceL() - { - RWsSession rws1; - User::LeaveIfError(rws1.Connect()); - CleanupClosePushL(rws1); - - RWindowGroup gw1(rws1); - User::LeaveIfError(gw1.Construct(ENullWsHandle)); - CleanupClosePushL(gw1); - - CWsScreenDevice* screen1 = new (ELeave) CWsScreenDevice(rws1); - User::LeaveIfError(screen1->Construct()); - CleanupStack::PushL(screen1); - - RWindow win1(rws1); - User::LeaveIfError(win1.Construct(gw1,ETrue)); - CleanupClosePushL(win1); - win1.Activate(); - - CWindowGc* gc=new (ELeave) CWindowGc(screen1); - User::LeaveIfError(gc->Construct()); - CleanupStack::PushL(gc); - gc->Activate(win1); - - CleanupStack::PopAndDestroy(5,&rws1); - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-0492 - -@SYMDEF PDEF126432 - -@SYMTestCaseDesc Test the screen number that a window is located on - -@SYMTestPriority Medium - -@SYMTestStatus Implemented - -@SYMTestActions Create two windows on two screens respectively - and check the screen number that each window is located on - -@SYMTestExpectedResults The screen numbers should match the expected ones -*/ -void CTMulScreens::TestScreenNumbersOfWindowsL() - { - // First screen - RWindow fstWin(iRws); - CleanupClosePushL(fstWin); - TRAPD(err,fstWin.Construct(iFstWinGp,ENullWsHandle)); - TEST(err==KErrNone); - if(err==KErrNone) - { - fstWin.Activate(); - iRws.Flush(); - } - TEST(fstWin.ScreenNumber()==KFstScreenNo); - CleanupStack::PopAndDestroy();//fstWin - - // Second screen - if(KSndScreenNoSetTestStepID(KUnknownSYMTestCaseIDName); - - switch(aCurTestCase) - { - case 1: - ((CTMulScreensStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0383")); - INFO_PRINTF1(KTest0); - TestCreateGroupWindowsL(); - break; - case 2: - ((CTMulScreensStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0384")); - INFO_PRINTF1(KTest1); - TestCreateBlankWindowsL(); - break; - case 3: - ((CTMulScreensStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0385")); - INFO_PRINTF1(KTest2); - TestGetFocusWindow(); - case 4: - ((CTMulScreensStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0386")); - INFO_PRINTF1(KTest3); - TestGetDefaultOwningWindow(); - break; - case 5: - ((CTMulScreensStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0387")); - INFO_PRINTF1(KTest4); - TestSetBackgroundColour(); - break; - case 6: - ((CTMulScreensStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0388")); - INFO_PRINTF1(KTest5); - TestSetShadowVector(); - break; - case 7: - ((CTMulScreensStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0389")); - INFO_PRINTF1(KTest6); - TestPanicsL(); - break; - case 8: - ((CTMulScreensStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0390")); - INFO_PRINTF1(KTest7); - TestDeviceL(); - break; - case 9: - ((CTMulScreensStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0034")); - INFO_PRINTF1(KTest8); - TestInitaliseScreenDeviceL(); - break; - case 10: - ((CTMulScreensStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0492")); - INFO_PRINTF1(KTest9); - TestScreenNumbersOfWindowsL(); - case 11: - ((CTMulScreensStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - ((CTMulScreensStep*)iStep)->CloseTMSGraphicsStep(); - INFO_PRINTF1(_L("All tests completed.\n")); - TestComplete(); - break; - default: - ((CTMulScreensStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - ((CTMulScreensStep*)iStep)->CloseTMSGraphicsStep(); - INFO_PRINTF1(_L("CTMulScreens::RunTestCaseL default case\n")); - break; - } - ((CTMulScreensStep*)iStep)->RecordTestResultL(); - } - -__WS_CONSTRUCT_STEP__(MulScreens) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TMULSCREENS.h --- a/windowing/windowserver/tauto/TMULSCREENS.h Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,73 +0,0 @@ -// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Enable Multiple Displays -// -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef __TMULSCREENS_H__ -#define __TMULSCREENS_H__ - -#include -#include -#include "AUTO.H" -#include "TGraphicsHarness.h" - -class CTMulScreens : public CTWsGraphicsBase - { -public: - CTMulScreens(CTestStep* aStep); - ~CTMulScreens(); -protected: -//from CTGraphicsStep - virtual void RunTestCaseL(TInt aCurTestCase); -private: - void ConstructL(); - void TestCreateGroupWindowsL(); - void TestCreateBlankWindowsL(); - void TestGetFocusWindow(); - void TestGetDefaultOwningWindow(); - void TestSetBackgroundColour(); - void TestSetShadowVector(); - void TestPanicsL(); - static TInt TestInvalidScreenNumberL(TInt aOption,TAny* aScreenNumber); - void TestInitaliseScreenDeviceL(); - void TestScreenNumbersOfWindowsL(); - void TestDeviceL(); -private: - RWsSession iRws; - CWsScreenDevice* iFstScreenDevice; - CWsScreenDevice* iSndScreenDevice; - RWindowGroup iFstWinGp; - RWindowGroup iSndWinGp; - TInt iNumScreens; - }; - -class CTMulScreensStep : public CTGraphicsStep - { -public: - CTMulScreensStep(); -protected: - //from CTGraphicsStep - virtual CTGraphicsBase* CreateTestL(); - }; - -_LIT(KTMulScreensStep,"TMulScreens"); - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TMULTCON.CPP --- a/windowing/windowserver/tauto/TMULTCON.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,478 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Test multiple connections to the window server -// -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include "TMULTCON.H" - -const TInt EMaxSubState=3; - -//#define LOGGING on //Uncomment this line to get extra logging - -_LIT(ClickOnMe,"Click on me"); -_LIT(KError,"ERROR"); - - -CTMultiCon::CTMultiCon(CTestStep* aStep) : CTWsGraphicsBase(aStep) - { - } - -CTMultiCon::~CTMultiCon() - { - delete iConn1; - delete iConn2; - delete iConn3; - delete iTimeOut; - } - -void CTMultiCon::EndAutoForegroundTest() - { -#if defined(LOGGING) - _LIT(KLog,"EndAutoForegroundTest SubState %d"); - LOG_MESSAGE2(KLog,iSubState); -#endif - iConn1->iGroup->GroupWin()->EnableReceiptOfFocus(EFalse); - iConn2->iGroup->GroupWin()->EnableReceiptOfFocus(EFalse); - iConn3->iGroup->GroupWin()->EnableReceiptOfFocus(EFalse); - CActiveScheduler::Stop(); - } - -void CTMultiCon::ConstructL() - { - iTimeOut=new(ELeave) CTimeOut(); - iTimeOut->ConstructL(); - TheClient->iWs.SetPointerCursorArea(iTest->iNormalPointerCursorArea); - iScreenSize=TSize(TheClient->iScreen->SizeInPixels()); - iConn3=new(ELeave) CMcConnectionDef(this); - iConn3->ConstructL(); - iConn2=new(ELeave) CMcConnection(this); - iConn2->ConstructL(); - iConn1=new(ELeave) CMcConnectionAf(this); - iConn1->ConstructL(); - iTest->SimulateKeyDownUp(EStdKeyLeftCtrl); - iTest->SimulateKeyDownUp(EStdKeyRightCtrl); - TInt mods=TheClient->iWs.GetModifierState(); - _LIT(KLog,"Initial Modifiers state 0x%x (ideally should be zero)"); - LOG_MESSAGE2(KLog,mods); - } - -TInt CTMultiCon::TimeOut(TAny* aTest) //static - { - static_cast(aTest)->TimeOut(); - return(KErrNone); - } - -void CTMultiCon::TimeOut() - { - TLogMessageText buf; - _LIT(KMultiConTimeOut,"TIMEOUT: Multiple Conection Test, %d, %S"); - buf.AppendFormat(KMultiConTimeOut,iTest->iState,&iTest->iSubTitle); - TheClient->LogMessage(buf); - ++iTimeOutCount; - EndAutoForegroundTest(); - } - - -// -// CMcConnection // -// - -CMcConnectionBase::CMcConnectionBase(CTMultiCon *aTest) : iTest(aTest) - { - } - -CMcConnectionBase::~CMcConnectionBase() - { - CTWin::Delete(iWin); - delete iGc; - } - -void CMcConnectionBase::SubStateChanged() - { - iWin->Invalidate(); - iWs.Flush(); - } - -void CMcConnectionBase::ConstructL() - { - CTClient::SetScreenNumber(iTest->ScreenNumber()); - CTClient::ConstructL(); - User::LeaveIfError(iScreen->CreateContext(iGc)); - } - -CMcConnection::CMcConnection(CTMultiCon *aTest) : CMcConnectionBase(aTest) - { - } - -void CMcConnection::ConstructL() - { - CMcConnectionBase::ConstructL(); - iGroup=new(ELeave) CTWindowGroup(this); - iGroup->ConstructL(); - TSize screenSize=iGroup->Size(); - TInt winWidth=screenSize.iWidth/3; - TInt winHeight=screenSize.iHeight/2-10; - iGroup->GroupWin()->AutoForeground(EFalse); - CMcWindow *win=new(ELeave) CMcWindow(iTest); - win->SetUpL(TPoint(5,5),TSize(winWidth,winHeight),iGroup,*iGc); - iWin=win; - iWs.Flush(); - } - -CMcConnectionAf::CMcConnectionAf(CTMultiCon *aTest) : CMcConnectionBase(aTest) - { - } - -void CMcConnectionAf::ConstructL() - { - CMcConnectionBase::ConstructL(); - iGroup=new(ELeave) CMcWindowGroupAf(this); - iGroup->ConstructL(); - TSize screenSize=iGroup->Size(); - TInt winWidth=screenSize.iWidth/3; - TInt winHeight=screenSize.iHeight/2-10; - iGroup->GroupWin()->AutoForeground(ETrue); - CMcWindowAf *win=new(ELeave) CMcWindowAf(iTest); - win->SetUpL(TPoint(winWidth,5),TSize(winWidth,winHeight),iGroup,*iGc); - iWin=win; - iWs.Flush(); - } - -void CMcConnectionAf::KeyL(const TKeyEvent &aKey) - { -#if defined(LOGGING) - _LIT(KLog1,"KeyL SS=%d (0) GpWinOrdPos=%d (0) Code=%d (32)"); - _LIT(KLog2," '%c'"); - TLogMessageText buf; - buf.Format(KLog1,iTest->SubState(),iGroup->GroupWin()->OrdinalPosition(),aKey.iCode); - if (aKey.iCode>0) - buf.AppendFormat(KLog2,aKey.iCode); - iTest->LOG_MESSAGE(buf); -#endif - switch(aKey.iCode) - { - case ' ': - if (iTest->SubState()==0) - { - iTest->TEST(iGroup->GroupWin()->OrdinalPosition()==0); - iTest->IncSubState(); - } - break; - case EKeyEscape: - iTest->EndAutoForegroundTest(); - break; - } - } - -CMcConnectionDef::CMcConnectionDef(CTMultiCon *aTest) : CMcConnectionBase(aTest) - { - } - -void CMcConnectionDef::ConstructL() - { - CMcConnectionBase::ConstructL(); - iGroup=new(ELeave) CTWindowGroup(this); - iGroup->ConstructL(); - iGroup->GroupWin()->EnableReceiptOfFocus(EFalse); - TSize screenSize=iGroup->Size(); - TInt winWidth=screenSize.iWidth/3-10; - TInt winHeight=(screenSize.iHeight/2)-10; - CMcWindowDef *win=new(ELeave) CMcWindowDef(iTest); - win->SetUpL(TPoint(5+winWidth/2,screenSize.iHeight/2),TSize(winWidth,winHeight),iGroup,*iGc); - iWin=win; - iWs.Flush(); - } - -// -// CMcWindow, base class // -// - -CMcWindowBase::CMcWindowBase(CTMultiCon *aTest) : CTWin(), iTest(aTest) - { - } - -void CMcWindowBase::SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc) - { - ConstructExtLD(*parent,pos,size); - iWin.SetBackgroundColor(iBack); - Activate(); - AssignGC(aGc); - } - -// -// CMcWindow, window used to test multiple connections // -// - -CMcWindow::CMcWindow(CTMultiCon *aTest) : CMcWindowBase(aTest) - { - iBack=TRgb::Gray256(221); - } - -void CMcWindow::PointerL(const TPointerEvent &pointer,const TTime &) - { -#if defined(LOGGING) - _LIT(KLog,"Pointer SS=%d (1) Type=%d (%d) GpWinOrdPos=%d (1)"); - iTest->LOG_MESSAGE5(KLog,iTest->SubState(),pointer.iType,TPointerEvent::EButton1Down,Client()->iGroup->GroupWin()->OrdinalPosition()); -#endif - if (pointer.iType==TPointerEvent::EButton1Down) - { - switch(iTest->SubState()) - { - case 1: - iTest->TEST(Client()->iGroup->GroupWin()->OrdinalPosition()==1); - iTest->IncSubState(); - break; - } - } - } - -void CMcWindow::Draw() - { - iGc->Clear(); - TBuf<0x40> buf; - switch(iTest->SubState()) - { - case 1: - buf.Copy(ClickOnMe); - break; - case 0: - case 2: - case 3: - buf.Copy(KNullDesC); - break; - default: - buf.Copy(KError); - } - iGc->DrawText(buf, TPoint(10,20)); - } - -// -// CMcWindowAf, Auto foreground version of CMcWindow // -// - -CMcWindowAf::CMcWindowAf(CTMultiCon *aTest) : CMcWindowBase(aTest) - { - iBack=TRgb::Gray256(150); - } - -void CMcWindowAf::PointerL(const TPointerEvent &pointer,const TTime &) - { -#if defined(LOGGING) - _LIT(KLog,"PointerL SS=%d (2) Type=%d (%d) GpWinOrdPos=%d (0)"); - iTest->LOG_MESSAGE5(KLog,iTest->SubState(),pointer.iType,TPointerEvent::EButton1Down,Client()->iGroup->GroupWin()->OrdinalPosition()); -#endif - if (pointer.iType==TPointerEvent::EButton1Down) - { - switch(iTest->SubState()) - { - case 2: - iTest->TEST(Client()->iGroup->GroupWin()->OrdinalPosition()==0); - iTest->IncSubState(); - break; - } - } - } - -void CMcWindowAf::Draw() - { - _LIT(PressSpace,"Press "); - iGc->Clear(); - TBuf<0x40> buf; - switch(iTest->SubState()) - { - case 1: - case 3: - break; - case 0: - buf.Copy(PressSpace); - break; - case 2: - buf.Copy(ClickOnMe); - break; - default: - buf.Copy(KError); - } - iGc->DrawText(buf, TPoint(10,20)); - } - -// - -CMcWindowGroupAf::CMcWindowGroupAf(CTClient *aClient) : CTWindowGroup(aClient) - {} - -void CMcWindowGroupAf::KeyL(const TKeyEvent &aKey, const TTime &) - { - ((CMcConnectionAf *)iClient)->KeyL(aKey); - } - -// -// CMcWindowDef, Default auto foreground version of CMcWindow // -// - -CMcWindowDef::CMcWindowDef(CTMultiCon *aTest) : CMcWindowBase(aTest) - { - iBack=TRgb::Gray256(236); - } - -void CMcWindowDef::PointerL(const TPointerEvent &pointer,const TTime &) - { -#if defined(LOGGING) - _LIT(KLog,"PointerL SS=%d (3) Type=%d (%d) GpWinOrdPos=%d (0)"); - iTest->LOG_MESSAGE5(KLog,iTest->SubState(),pointer.iType,TPointerEvent::EButton1Down,Client()->iGroup->GroupWin()->OrdinalPosition()); -#endif - if (pointer.iType==TPointerEvent::EButton1Down) - { - switch(iTest->SubState()) - { - case 3: - iTest->TEST(Client()->iGroup->GroupWin()->OrdinalPosition()==0); - iTest->IncSubState(); - break; - } - } - } - -void CMcWindowDef::Draw() - { - iGc->Clear(); - TBuf<0x40> buf; - switch(iTest->SubState()) - { - case 0: - case 1: - case 2: - break; - case 3: - buf.Copy(ClickOnMe); - break; - default: - buf.Copy(KError); - } - iGc->DrawText(buf, TPoint(10,20)); - } - -// - -TInt CTMultiCon::SubState() const - { - return(iSubState); - } - -void CTMultiCon::IncSubState() - { - if (iSubState==EMaxSubState) - EndAutoForegroundTest(); - else - { - iSubState++; - #if defined(LOGGING) - _LIT(KLog,"New SubState %d"); - LOG_MESSAGE2(KLog,iSubState); - #endif - iConn1->SubStateChanged(); - iConn2->SubStateChanged(); - iConn3->SubStateChanged(); - TheClient->WaitForRedrawsToFinish(); - SendEvents(); - } - } - -void CTMultiCon::SendEvents() - { -#if defined(LOGGING) - _LIT(KLog,"Sending event for substate %d"); - LOG_MESSAGE2(KLog,iSubState); -#endif - - switch (iSubState) - { - case 0: - iTest->SimulateKeyDownUp(EStdKeySpace); - break; - case 1: - iTest->SimulatePointerDownUp(iScreenSize.iWidth/6+5,iScreenSize.iHeight/4); - break; - case 2: - iTest->SimulatePointerDownUp(iScreenSize.iWidth/2,iScreenSize.iHeight/4); - break; - case 3: - iTest->SimulatePointerDownUp(iScreenSize.iWidth/3,3*iScreenSize.iHeight/4-5); - break; - default: - TEST(EFalse); - } - TheClient->iWs.Flush(); - } - -void CTMultiCon::RunTestCaseL(TInt /*aCurTestCase*/) - { - _LIT(KTestMultiCon1,"MultiCon 1"); - _LIT(KTimeOut,"Test Timed Out after %dsecs. SubState=%d"); - ((CTMultiConStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); - - if (!TestBase()->ConfigurationSupportsPointerEventTesting()) - { - INFO_PRINTF1(_L("Test skipped because config does not support pointer event testing")); - TestComplete(); - return; - } - - switch(++iTest->iState) - { -/** - - @SYMTestCaseID GRAPHICS-WSERV-0289 - - @SYMDEF DEF081259 - - @SYMTestCaseDesc Test multiple connections to the window server - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions Make mutiple connections to the window server and check - that the connections are made corectly - - @SYMTestExpectedResults The connections are made correctly - -*/ - case 1: - ((CTMultiConStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0289")); - iTest->LogSubTest(KTestMultiCon1); - iTimeOut->Start(KTimeOutAfter,TCallBack(CTMultiCon::TimeOut,this)); - SendEvents(); - CActiveScheduler::Start(); - iTimeOut->Cancel(); - TEST(iTimeOutCount==0); - if (iTimeOutCount!=0) - LOG_MESSAGE3(KTimeOut,KTimeOutAfter/1000000,iSubState); - break; - default: - ((CTMultiConStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - ((CTMultiConStep*)iStep)->CloseTMSGraphicsStep(); - TestComplete(); - break; - } - ((CTMultiConStep*)iStep)->RecordTestResultL(); - } - -__WS_CONSTRUCT_STEP__(MultiCon) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TMULTCON.H --- a/windowing/windowserver/tauto/TMULTCON.H Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,157 +0,0 @@ - -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef __TMULTCON_H__ -#define __TMULTCON_H__ - -#include -#include -#include -#include "../tlib/testbase.h" -#include "AUTO.H" -#include "TGraphicsHarness.h" - -class CTMultiCon; -class CMcWindowBase; - -class CMcConnectionBase : public CTClient - { -public: - CMcConnectionBase(CTMultiCon *aTest); - ~CMcConnectionBase(); - virtual void ConstructL(); - void SubStateChanged(); -protected: - CTMultiCon *iTest; - CMcWindowBase *iWin; - CWindowGc *iGc; - }; - -class CMcConnection : public CMcConnectionBase // Sets AutoForeground off - { -public: - CMcConnection(CTMultiCon *aTest); - void ConstructL(); - }; - -class CMcWindowGroupAf : public CTWindowGroup - { -public: - CMcWindowGroupAf(CTClient *aClient); - void KeyL(const TKeyEvent &aKey, const TTime &aTime); - }; - -class CMcConnectionAf : public CMcConnectionBase // Sets AutoForeground on - { -public: - CMcConnectionAf(CTMultiCon *aTest); - void ConstructL(); - void KeyL(const TKeyEvent &aKey); - }; - -class CMcConnectionDef : public CMcConnectionBase // Leaves AutoForeground as the default value - { -public: - CMcConnectionDef(CTMultiCon *aTest); - void ConstructL(); - }; - -class CMcWindowBase : public CTWin - { -public: - CMcWindowBase(CTMultiCon *aTest); - void SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc); - virtual void Draw()=0; - virtual void PointerL(const TPointerEvent &pointer,const TTime &)=0; -protected: - CTMultiCon *iTest; - TRgb iBack; - }; - -class CMcWindow : public CMcWindowBase - { -public: - CMcWindow(CTMultiCon *aTest); - virtual void Draw(); - virtual void PointerL(const TPointerEvent &pointer,const TTime &); - }; - -class CMcWindowAf : public CMcWindowBase - { -public: - CMcWindowAf(CTMultiCon *aTest); - virtual void Draw(); - virtual void PointerL(const TPointerEvent &pointer,const TTime &); - void ConstructL(); - }; - -class CMcWindowDef : public CMcWindowBase - { -public: - CMcWindowDef(CTMultiCon *aTest); - virtual void Draw(); - virtual void PointerL(const TPointerEvent &pointer,const TTime &); - }; - -class CTMultiCon : public CTWsGraphicsBase - { -public: - enum {KTimeOutAfter=10000000}; //10secs -public: - CTMultiCon(CTestStep* aStep); - ~CTMultiCon(); - void ConstructL(); - void EndAutoForegroundTest(); - TInt SubState() const; - void IncSubState(); - static TInt TimeOut(TAny* aTest); - void TimeOut(); - inline TInt ScreenNumber() const {return(iTest->ScreenNumber());} -protected: -//from CTGraphicsStep - virtual void RunTestCaseL(TInt aCurTestCase); -private: - void SendEvents(); -private: - CTimeOut* iTimeOut; - TInt iTimeOutCount; - CMcConnectionAf *iConn1; - CMcConnection *iConn2; - CMcConnectionDef *iConn3; - TSize iScreenSize; - //TInt iState; - TInt iSubState; - }; - -class CTMultiConStep : public CTGraphicsStep - { -public: - CTMultiConStep(); -protected: - //from CTGraphicsStep - virtual CTGraphicsBase* CreateTestL(); - }; - -_LIT(KTMultiConStep,"TMultiCon"); - - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TMemLeakMode.cpp --- a/windowing/windowserver/tauto/TMemLeakMode.cpp Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,88 +0,0 @@ -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Enable Wserv memory leak checks -// -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include "TMemLeakMode.h" -#include - -// -// -CTMemLeakCheckEnable::CTMemLeakCheckEnable(CTestStep* aStep) : CTWsGraphicsBase(aStep) - { - INFO_PRINTF1(_L("Enabling memory leak checks")); - } - -void CTMemLeakCheckEnable::ConstructL() - { - iIsWsTestMode = !iTest->IsFullRomL(); - if (iIsWsTestMode) - { - TheClient->iWs.DebugInfo(EWsDebugSetCheckHeapOnDisconnectMode,EWsCheckHeapOnDisconnectModeAlways); - } - } - -void CTMemLeakCheckEnable::RunTestCaseL(TInt ) - { - if (!iIsWsTestMode) - { -#if defined(__WINS__) - WARN_PRINTF1(_L("Test skipped as TechView appears to be running\n")); -#else - INFO_PRINTF1(_L("Test skipped as TechView appears to be running\n")); -#endif - } - TestComplete(); - } - -__WS_CONSTRUCT_STEP__(MemLeakCheckEnable) - -// -// - -CTMemLeakCheckOneShot::CTMemLeakCheckOneShot(CTestStep* aStep) : CTWsGraphicsBase(aStep) - { - INFO_PRINTF1(_L("Triggering one shot memory leak check")); - } - -void CTMemLeakCheckOneShot::ConstructL() - { - iIsWsTestMode = !iTest->IsFullRomL(); - if (iIsWsTestMode) - { - TheClient->iWs.DebugInfo(EWsDebugSetCheckHeapOnDisconnectMode,EWsCheckHeapOnDisconnectModeOnce); - } - } - -void CTMemLeakCheckOneShot::RunTestCaseL(TInt ) - { - if (!iIsWsTestMode) - { -#if defined(__WINS__) - WARN_PRINTF1(_L("Test skipped as TechView appears to be running\n")); -#else - INFO_PRINTF1(_L("Test skipped as TechView appears to be running\n")); -#endif - } - TestComplete(); - } - -__WS_CONSTRUCT_STEP__(MemLeakCheckOneShot) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TMemLeakMode.h --- a/windowing/windowserver/tauto/TMemLeakMode.h Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,74 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include -#include -#include "../tlib/testbase.h" -#include "AUTO.H" -#include "TGraphicsHarness.h" - -// CTMemLeakCheckEnable - -class CTMemLeakCheckEnable : public CTWsGraphicsBase - { -public: - CTMemLeakCheckEnable(CTestStep* aStep); - void ConstructL(); -protected: - virtual void RunTestCaseL(TInt aCurTestCase); -private: - TBool iIsWsTestMode; - }; - -class CTMemLeakCheckEnableStep : public CTGraphicsStep - { -public: - CTMemLeakCheckEnableStep(); - TestState DoTestL(); -protected: - virtual CTGraphicsBase* CreateTestL(); - }; - -_LIT(KTMemLeakCheckEnableStep,"TMemLeakCheckEnable"); - -// CTMemLeakCheckOneShot - -class CTMemLeakCheckOneShot : public CTWsGraphicsBase - { -public: - CTMemLeakCheckOneShot(CTestStep* aStep); - void ConstructL(); -protected: - virtual void RunTestCaseL(TInt aCurTestCase); -private: - TBool iIsWsTestMode; - }; - -class CTMemLeakCheckOneShotStep : public CTGraphicsStep - { -public: - CTMemLeakCheckOneShotStep(); - TestState DoTestL(); -protected: - virtual CTGraphicsBase* CreateTestL(); - }; - -_LIT(KTMemLeakCheckOneShotStep,"TMemLeakCheckOneShot"); diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TMulTran.CPP --- a/windowing/windowserver/tauto/TMulTran.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1111 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Test multiple level transparent window -// -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include "TMulTran.H" - - -LOCAL_D TDisplayMode DisplayMode=EColor64K; -LOCAL_D TSize WinSize; - -static const TRgb KRed=TRgb(255, 0, 0, 128); -static const TRgb KGreen=TRgb(0, 255, 0, 128); -static const TRgb KYellow=TRgb(255, 255, 0, 128); -static const TRgb KBlue=TRgb(0, 0, 255, 128); -static const TRgb KCyan=TRgb(0, 255, 255, 128); - -/*CTransWindow*/ - -CTransWindow* CTransWindow::NewL(RPointerArray& aWindows,TRgb aColor,TRect aPos) - { - CTransWindow* self=NewL(TheClient->iGroup,aColor,aPos,&DisplayMode); - aWindows.Insert(self,0); - return self; - } - -CTransWindow* CTransWindow::NewL(CTWinBase* aParent,TRgb aColor,TRect aPos, TDisplayMode* aDisplayMode) - { - CTransWindow* self=new(ELeave) CTransWindow(aColor); - CleanupStack::PushL(self); - self->SetUpL(aPos.iTl,aPos.Size(),aParent,*TheClient->iGc,aDisplayMode); - User::LeaveIfError(self->iError); - CleanupStack::Pop(self); - return self; - } - -//the following function doesn't activate a window -CTransWindow* CTransWindow::NewL(CTWinBase* aParent,TRgb aColor,TDisplayMode* aDisplayMode) - { - CTransWindow* self=new(ELeave) CTransWindow(aColor); - CleanupStack::PushL(self); - self->ConstructL(*aParent); - if (aDisplayMode) - { - self->BaseWin()->SetRequiredDisplayMode(*aDisplayMode); - } - User::LeaveIfError((self->iError) && (self->iError != KErrNotSupported)); - CleanupStack::Pop(self); - return self; - } - -void CTransWindow::InitWin() - { - AdjustShadow(-1); - iShadowHight=0; - iWin.SetShadowDisabled(ETrue); - iShadowing=EFalse; - iError = iWin.SetTransparencyAlphaChannel(); - iWin.SetBackgroundColor(iCol); - iDrawOpaque=EFalse; - } - -void CTransWindow::ToggleVisibility() - { - iVisible=!iVisible; - SetVisible(iVisible); - } - -void CTransWindow::SetOrdinal(RPointerArray& aWindows,TInt aOldPos,TInt aNewPos) - { - CTransWindow* win=aWindows[aOldPos]; - aWindows.Remove(aOldPos); - aWindows.Insert(win,aNewPos); - win->iWin.SetOrdinalPosition(aNewPos); - } - -void CTransWindow::SetShadowDisabled(TBool aState) - { - iWin.SetShadowDisabled(aState); - iShadowing=!aState; - } - -void CTransWindow::AdjustShadow(TInt aAdjust) - { - CBlankWindow::AdjustShadow(aAdjust); - iShadowHight+=aAdjust; - } - -TPoint CTransWindow::Position() const - { - return CBlankWindow::Position()+iPosOffset; - } - -void CTransWindow::Draw() - { - //don't call CBlankWindow::Draw() since the background is already drawn - - if(iDrawOpaque) - { - iGc->SetPenStyle(CGraphicsContext::ESolidPen); - iGc->SetPenSize(TSize(4,4)); - iGc->SetBrushStyle(CGraphicsContext::ENullBrush); - iGc->SetPenColor(~iCol); - iGc->SetOpaque(ETrue); - iGc->DrawLine(TPoint(0,0),TPoint(1000,1000)); - iGc->SetOpaque(EFalse); - } - } - -/*CTMultipleTrans*/ - -CTMultipleTrans::CTMultipleTrans(CTestStep* aStep) : CTWsGraphicsBase(aStep), iWindows(5), iShadows(EFalse) - { - } - -CTMultipleTrans::~CTMultipleTrans() - { - ((CTMultipleTransStep*)iStep)->CloseTMSGraphicsStep(); - delete iBackgroundWin; - delete iCheckWin; - delete iCheckBitmap; - iWindows.ResetAndDestroy(); - iBlankWin.Close(); - } - -void CTMultipleTrans::ConstructL() - { - if(TransparencySupportedL() == KErrNotSupported) - return; - iMajorTest=0; - const TSize scrSize(TheClient->iScreen->SizeInPixels()); - WinSize.SetSize(scrSize.iWidth/2,scrSize.iHeight); - iBackgroundWin=new(ELeave) CTBlankWindow(); - iBackgroundWin->SetUpL(TPoint(),WinSize,TheClient->iGroup,*TheClient->iGc); - TheClient->WaitForRedrawsToFinish(); - CTBackedUpWin* checkWin=new(ELeave) CTBackedUpWin(DisplayMode); - checkWin->ConstructExtLD(*TheClient->iGroup,TPoint(WinSize.iWidth,0),WinSize); - iCheckWin=checkWin; - RBackedUpWindow& backWin=*iCheckWin->BackedUpWin(); - backWin.SetShadowHeight(0); - iCheckWin->Activate(); - backWin.MaintainBackup(); - iCheckBitmap=CBitmap::NewL(backWin.BitmapHandle()); - iCheckBitmap->Gc().SetPenStyle(CGraphicsContext::ENullPen); - iCheckBitmap->Gc().SetBrushStyle(CGraphicsContext::ESolidBrush); - TheClient->Flush(); - TheClient->WaitForRedrawsToFinish(); - RecreateWindowsL(); - iBlankWin=RBlankWindow(TheClient->iWs); - User::LeaveIfError(iBlankWin.Construct(*TheClient->iGroup->WinTreeNode(),ENullWsHandle)); - iBlankWinVis=EFalse; - iBlankWin.SetVisible(iBlankWinVis); - User::LeaveIfError(iBlankWin.SetRequiredDisplayMode(EColor256)); - iBlankWinCol=TRgb(170,170,170); //Grey - iBlankWin.SetColor(iBlankWinCol); - iBlankWin.SetOrdinalPosition(0,1); //Set the priority to 1 so that the 4 main windows are the first 4 with priory 0 - iBlankWin.Activate(); - iOpacitySupported=EFalse; - } - -void CTMultipleTrans::ShadowRegion(TRegion& aRegion,TInt aWin) - { - TRect rect; - TInt height; - TInt window; - aRegion.Clear(); - RRegion single; - RRegion noShadow1; - RRegion noShadow2; - RRegion temp; - RRegion temp2; - for (window=0;windowGc(); - gc.SetBrushColor(KRgbWhite); - gc.DrawRect(TRect(WinSize)); - TInt windows=iWindows.Count(); - if (iShadows) - { - ShadowRegion(shadowRegion,windows); - gc.ShadowArea(&shadowRegion); - } - TInt window; - for (window=windows;window>0;) - { - CTransWindow& win=*iWindows[--window]; - if (win.IsVisible()) - { - gc.SetBrushColor(win.Color()); - const TPoint& winTopLeft=win.Position(); - gc.DrawRect(TRect(winTopLeft, win.Size())); - - if(win.DrawOpaque()) - { - gc.SetPenColor(~(win.Color())); - gc.SetPenSize(TSize(4,4)); - gc.SetPenStyle(CGraphicsContext::ESolidPen); - gc.SetClippingRect(TRect(TPoint(winTopLeft.iX,winTopLeft.iY),TPoint(winTopLeft.iX + win.Size().iWidth, winTopLeft.iY + win.Size().iHeight))); - gc.DrawLine(TPoint(winTopLeft.iX,winTopLeft.iY),TPoint(winTopLeft.iX+1000, winTopLeft.iY+1000)); - gc.SetPenStyle(CGraphicsContext::ENullPen); - gc.SetClippingRect(TRect(WinSize)); - } - - if (iShadows) - { - ShadowRegion(shadowRegion,window); - gc.ShadowArea(&shadowRegion); - } - } - } - iCheckWin->BackedUpWin()->UpdateScreen(); - TheClient->Flush(); - if (windows>=4) - { - AdvancedCheckRect(); - } - _LIT(KTest,"Multiple Transparent Test, SubTest %d, OpacityOn=%d"); - TBuf<128> buf; - buf.Format(KTest,iTest->iState,iMajorTest); - CheckRect(iBackgroundWin,iCheckWin,TRect(WinSize),buf); - shadowRegion.Close(); - } - -#define OFFSET 2 -void CTMultipleTrans::AdvancedCheckRect() - { - const TSize compareSize(5,5); - const TInt OFFSET2=OFFSET+compareSize.iWidth; - TPoint comparePos=iCheckWin->Position(); - TPoint checkPos; - //Check Single Level for Top Left Win - checkPos=iTopLeft->Position()+TPoint(OFFSET,OFFSET); - CheckRect(checkPos,checkPos+comparePos,compareSize); - //Check Single Level for Top Right Win - checkPos=iTopRight->Position()+TPoint(iTopRight->Size().iWidth-OFFSET2,OFFSET); - CheckRect(checkPos,checkPos+comparePos,compareSize); - //Check Single Level for Bottom Left Win - checkPos=iBotLeft->Position()+TPoint(OFFSET,iBotLeft->Size().iHeight-OFFSET2); - CheckRect(checkPos,checkPos+comparePos,compareSize); - //Check Single Level for Bottom Right Win - checkPos=iBotRight->Position()+TPoint(iBotRight->Size().iWidth-OFFSET2,iBotRight->Size().iHeight-OFFSET2); - CheckRect(checkPos,checkPos+comparePos,compareSize); - //Double level top 2 windows - checkPos=iTopRight->Position()+TPoint(OFFSET,OFFSET); - CheckRect(checkPos,checkPos+comparePos,compareSize); - //Double level left 2 windows - checkPos=iBotLeft->Position()+TPoint(OFFSET,OFFSET); - CheckRect(checkPos,checkPos+comparePos,compareSize); - //Double level bot 2 windows - checkPos=iBotRight->Position()+TPoint(OFFSET,iBotRight->Size().iHeight-OFFSET2); - CheckRect(checkPos,checkPos+comparePos,compareSize); - //Double level right 2 windows - checkPos=iBotRight->Position()+TPoint(iBotRight->Size().iWidth-OFFSET2,OFFSET); - CheckRect(checkPos,checkPos+comparePos,compareSize); - //Triple level all but bot right - checkPos=iTopRight->Position()+TPoint(OFFSET,iTopRight->Size().iHeight-OFFSET2); - CheckRect(checkPos,checkPos+comparePos,compareSize); - //Triple level all but bot left - checkPos=iBotRight->Position()+TPoint(OFFSET,OFFSET); - CheckRect(checkPos,checkPos+comparePos,compareSize); - //Triple level all but top right - checkPos=iTopLeft->Position()+TPoint(iTopLeft->Size().iWidth-OFFSET2,iTopLeft->Size().iHeight-OFFSET2); - CheckRect(checkPos,checkPos+comparePos,compareSize); - //Triple level all but top left - checkPos=iBotLeft->Position()+TPoint(iBotLeft->Size().iWidth-OFFSET2,OFFSET); - CheckRect(checkPos,checkPos+comparePos,compareSize); - //Quad level - checkPos=TPoint(iBotRight->Position().iX,iBotLeft->Position().iY)+TPoint(OFFSET,OFFSET); - CheckRect(checkPos,checkPos+comparePos,compareSize); - } - -void CTMultipleTrans::SimpleTest() - { - CheckDisplay(); - } - -void CTMultipleTrans::ChangeVisibility() - { - TUint toggle; - TUint toggle2; - TInt win; - TInt ii=0; - for (ii=2;ii>0;--ii) - { - for (toggle=1;toggle<16;++toggle) - { - win=0; - toggle2=toggle; - while ((toggle2&0x1)==0) - { - ++win; - toggle2/=2; - } - iWindows[win]->ToggleVisibility(); - CheckDisplay(); - } - } - } - -void CTMultipleTrans::ChangeVisibility2() - { - iBlankWin.SetOrdinalPosition(0,0); - iBlankWin.SetVisible(ETrue); - iBlankWin.SetVisible(EFalse); - CheckDisplay(); - const TInt xSteps=4; - const TInt ySteps=3; - iBlankWinSize.SetSize(WinSize.iWidth/xSteps,WinSize.iHeight/ySteps); - iBlankWin.SetSize(iBlankWinSize); - TInt ordPos,xx,yy; - for (ordPos=0;ordPos<=4;++ordPos) - { - iBlankWin.SetOrdinalPosition(ordPos); - for (xx=0;xx=0;--kk) - { - for (jj=3;jj>kk;--jj) - { - for (ii=jj;ii>=kk;--ii) - { - CTransWindow::SetOrdinal(iWindows,jj,kk); - CheckDisplay(); - } - } - } - for (kk=2;kk>=0;--kk) - { - for (jj=3;jj>kk;--jj) - { - for (ii=jj;ii>=kk;--ii) - { - CTransWindow::SetOrdinal(iWindows,kk,jj); - CheckDisplay(); - } - } - } - } - -TSize CTMultipleTrans::GetSize(TInt aPos) - { //Comments show values for 640x240 screen - const TInt halfSize=40; - const TPoint topLeft=iTopLeft->Position(); //10,10 - const TInt xLeft=WinSize.iWidth/2-topLeft.iX-halfSize; //110 - const TInt xRight=xLeft+2*halfSize; //190 - const TInt yTop=WinSize.iHeight/2-topLeft.iY-halfSize; //70 - const TInt yBot=yTop+2*halfSize; //150 - if (aPos<6) - return TSize(xLeft+16*aPos-8,yTop); //1->118, 5->182 - if (aPos<11) - return TSize(xRight,yTop+16*aPos-88); //6->78, 10->142 - if (aPos<16) - return TSize(xRight-16*aPos+168,yBot); //11->182, 15->118 - return TSize(xLeft,yBot-16*aPos+248); //16->142, 20->78 - } - -void CTMultipleTrans::SizeChange(TInt aJump) - { - TInt ii=aJump; - TSize size; - while (ii<20) - { - size=GetSize(ii); - iTopLeft->SetSize(size); - if(iTopLeft->DrawOpaque()) - { - iTopLeft->CTWin::DrawNow(); - TheClient->Flush(); - } - CheckDisplay(); - ii+=aJump; - if (ii>20) - ii-=20; - } - } - -void CTMultipleTrans::SizeChange() - { - CTransWindow::SetOrdinal(iWindows,2,1); - TSize size=iBotLeft->Size(); - TInt change; - for (change=70;change>=0;change-=14) - { - iBotLeft->SetSize(TSize(size.iWidth-change,size.iHeight)); - if(iBotLeft->DrawOpaque()) - { - iBotLeft->CTWin::DrawNow(); - TheClient->Flush(); - } - CheckDisplay(); - } - size=iTopRight->Size(); - for (change=25;change>-50;change-=14) - { - iTopRight->SetSize(TSize(size.iWidth,size.iHeight+change)); - if(iTopRight->DrawOpaque()) - { - iTopRight->CTWin::DrawNow(); - TheClient->Flush(); - } - CheckDisplay(); - } - iTopRight->SetSize(size); - if(iTopRight->DrawOpaque()) - { - iTopRight->CTWin::DrawNow(); - TheClient->Flush(); - } - CTransWindow::SetOrdinal(iWindows,1,0); - CheckDisplay(); - size=iTopLeft->Size(); - SizeChange(3); - iTopLeft->SetSize(size); - if(iTopLeft->DrawOpaque()) - { - iTopLeft->CTWin::DrawNow(); - TheClient->Flush(); - } - CheckDisplay(); - CTransWindow::SetOrdinal(iWindows,0,2); - CheckDisplay(); - SizeChange(7); - iTopLeft->SetSize(size); - if(iTopLeft->DrawOpaque()) - { - iTopLeft->CTWin::DrawNow(); - TheClient->Flush(); - } - CheckDisplay(); - } - -void CTMultipleTrans::MoveWin() - { - const TPoint topLeftPos=iTopLeft->Position(); - const TPoint topRightPos=iTopRight->Position(); - const TPoint botLeftPos=iBotLeft->Position(); - const TPoint botRightPos=iBotRight->Position(); - const TInt maxMove=Min(topRightPos.iX,botRightPos.iY)-10; - TInt steps,move; - for (steps=2;steps>=0;--steps) - { - move=maxMove*(3-steps)/3; - iTopLeft->SetPos(TPoint(topLeftPos.iX+move,topLeftPos.iY+move)); - CheckDisplay(); - iTopRight->SetPos(TPoint(topRightPos.iX-move,topRightPos.iY+move)); - CheckDisplay(); - iBotRight->SetPos(TPoint(botRightPos.iX-move,botRightPos.iY-move)); - CheckDisplay(); - iBotLeft->SetPos(TPoint(botLeftPos.iX+move,botLeftPos.iY-move)); - CheckDisplay(); - } - for (steps=4;steps>=0;--steps) - { - move=maxMove*steps/5; - iBotLeft->SetPos(TPoint(botLeftPos.iX+move,botLeftPos.iY-move)); - CheckDisplay(); - iTopLeft->SetPos(TPoint(topLeftPos.iX+move,topLeftPos.iY+move)); - CheckDisplay(); - iBotRight->SetPos(TPoint(botRightPos.iX-move,botRightPos.iY-move)); - CheckDisplay(); - iTopRight->SetPos(TPoint(topRightPos.iX-move,topRightPos.iY+move)); - CheckDisplay(); - } - } - -void CTMultipleTrans::GroupWinL() - { - CTWindowGroup* group=new(ELeave) CTWindowGroup(TheClient); - CleanupStack::PushL(group); - group->ConstructL(); - CTransWindow* win=CTransWindow::NewL(group,KCyan,TRect(40,40,WinSize.iWidth-40,WinSize.iHeight-40),&DisplayMode); - win->CTWin::DrawNow(); - if(iMajorTest==1) - { - win->SetDrawOpaque(ETrue); - win->Invalidate(); - TheClient->WaitForRedrawsToFinish(); - } - iWindows.Insert(win,0); - CheckDisplay(); - group->GroupWin()->SetOrdinalPosition(1); - iWindows.Remove(0); - CheckDisplay(); - group->GroupWin()->SetOrdinalPosition(0); - iWindows.Insert(win,0); - CheckDisplay(); - iWindows.Remove(0); - delete win; //Would be better to delete this after the group window but the test window don't support this behaviour currently. - CleanupStack::PopAndDestroy(group); - CheckDisplay(); - } - -void CTMultipleTrans::FadeTranWin() - { - // system fade on - TheClient->iWs.SetSystemFaded(ETrue); - // system fade off - TheClient->iWs.SetSystemFaded(EFalse); - CheckDisplay(); - } - -void CTMultipleTrans::StartShadows() - { - iShadows=ETrue; - iTopLeft->SetShadowDisabled(EFalse); - iTopLeft->AdjustShadow(1); - iTopRight->SetShadowDisabled(EFalse); - iTopRight->AdjustShadow(1); - iBotLeft->SetShadowDisabled(EFalse); - iBotLeft->AdjustShadow(1); - iBotRight->SetShadowDisabled(EFalse); - iBotRight->AdjustShadow(1); - if(!iOpacitySupported) - { - iTopRight->ToggleVisibility(); // In 8.1 this isn't needed. - iTopRight->ToggleVisibility(); - } - CheckDisplay(); - } - -void CTMultipleTrans::ShadowsOnOff() - { - if(!iOpacitySupported) - return; // In 8.1 this isn't needed. - iBotRight->SetShadowDisabled(EFalse); - iBotRight->AdjustShadow(1); - CheckDisplay(); - iBotRight->SetShadowDisabled(ETrue); - CheckDisplay(); - iTopLeft->SetShadowDisabled(EFalse); - iTopLeft->AdjustShadow(1); - CheckDisplay(); - iTopLeft->SetShadowDisabled(ETrue); - CheckDisplay(); - iTopRight->SetShadowDisabled(ETrue); - CheckDisplay(); - iBotLeft->SetShadowDisabled(EFalse); - iBotLeft->AdjustShadow(1); - CheckDisplay(); - iBotLeft->SetShadowDisabled(ETrue); - CheckDisplay(); - iTopLeft->SetShadowDisabled(EFalse); - iTopRight->SetShadowDisabled(EFalse); - iBotLeft->SetShadowDisabled(EFalse); - iBotRight->SetShadowDisabled(EFalse); - iTopLeft->ToggleVisibility(); - CheckDisplay(); - iTopLeft->ToggleVisibility(); - CheckDisplay(); - iTopRight->ToggleVisibility(); - CheckDisplay(); - iTopRight->ToggleVisibility(); - CheckDisplay(); - iBotLeft->ToggleVisibility(); - CheckDisplay(); - iBotLeft->ToggleVisibility(); - CheckDisplay(); - iBotRight->ToggleVisibility(); - CheckDisplay(); - iBotRight->ToggleVisibility(); - CheckDisplay(); - } - -void CTMultipleTrans::StartChildL() - { - CTransWindow* win; - TInt windows=iWindows.Count(); - TInt window; - //Delete the first 4 windows from the array, could use ResetAndDestroy but would be broken by other uses of the array - for (window=windows;window>0;--window) - { - win=iWindows[0]; - iWindows.Remove(0); - delete win; - } - RecreateWindowsL(iBackgroundWin); - CheckDisplay(); - } - -void CTMultipleTrans::StartChild2L() - { - CTransWindow* win; - TInt windows=iWindows.Count(); - TInt window; - //Delete the first 4 windows from the array, could use ResetAndDestroy but would be broken by other uses of the array - for (window=windows;window>0;--window) - { - win=iWindows[0]; - iWindows.Remove(0); - delete win; - } - iShadows=EFalse; - TRect rect=WinSize; - rect.Shrink(10,10); - iBotRight=CTransWindow::NewL(iBackgroundWin,KBlue,rect,&DisplayMode); - iBotRight->CTWin::DrawNow(); - iWindows.Insert(iBotRight,0); - CheckDisplay(); - rect.Resize(-20,-20); - iTopLeft=CTransWindow::NewL(iBotRight,KRed,rect,&DisplayMode); - iTopLeft->CTWin::DrawNow(); - iTopLeft->SetPosOffset(TPoint(10,10)); - iWindows.Insert(iTopLeft,0); - CheckDisplay(); - rect.Resize(-20,-20); - iTopRight=CTransWindow::NewL(iTopLeft,KGreen,rect,&DisplayMode); - iTopRight->CTWin::DrawNow(); - iTopRight->SetPosOffset(TPoint(20,20)); - iWindows.Insert(iTopRight,0); - CheckDisplay(); - rect.Resize(-20,-20); - iBotLeft=CTransWindow::NewL(iTopRight,KYellow,rect,&DisplayMode); - iBotLeft->CTWin::DrawNow(); - iBotLeft->SetPosOffset(TPoint(30,30)); - iWindows.Insert(iBotLeft,0); - if(iMajorTest==1) - { - for (TInt window = 0; window < iWindows.Count(); ++window) - { - iWindows[window]->SetDrawOpaque(ETrue); - iWindows[window]->Invalidate(); - } - TheClient->WaitForRedrawsToFinish(); - } - CheckDisplay(); - } - -void CTMultipleTrans::RecreateWindowsL(CTWinBase *aParent) - { - CTransWindow* win; - TInt windows=iWindows.Count(); - TInt window; - //Delete existing windows: - for (window=windows;window>0;--window) - { - win=iWindows[0]; - iWindows.Remove(0); - delete win; - } - - if(!aParent) - aParent = TheClient->iGroup; - - iBotRight=CTransWindow::NewL(aParent,KBlue,TRect(WinSize.iWidth/2-10,WinSize.iHeight/2-30,WinSize.iWidth-20,WinSize.iHeight-20),&DisplayMode); - iBotRight->CTWin::DrawNow(); - iWindows.Insert(iBotRight,0); - iTopLeft=CTransWindow::NewL(aParent,KRed,TRect(10,10,WinSize.iWidth/2+10,WinSize.iHeight/2+30),&DisplayMode); - iTopLeft->CTWin::DrawNow(); - iWindows.Insert(iTopLeft,0); - iTopRight=CTransWindow::NewL(aParent,KGreen,TRect(WinSize.iWidth/2-30,20,WinSize.iWidth-10,WinSize.iHeight/2+10),&DisplayMode); - iTopRight->CTWin::DrawNow(); - iWindows.Insert(iTopRight,0); - iBotLeft=CTransWindow::NewL(aParent,KYellow,TRect(20,WinSize.iHeight/2-10,WinSize.iWidth/2+30,WinSize.iHeight-10),&DisplayMode); - iBotLeft->CTWin::DrawNow(); - iWindows.Insert(iBotLeft,0); - iShadows=EFalse; - - if(iMajorTest==1) - { - for (TInt window=0;windowSetDrawOpaque(ETrue); - iWindows[window]->Invalidate(); - } - TheClient->WaitForRedrawsToFinish(); - } - } - -void CTMultipleTrans::RunTestCaseL(TInt /*aCurTestCase*/) - { - _LIT(KCheck,"Check"); - _LIT(KSimple,"Simple Test"); - _LIT(KVisibility,"Change Visibility"); - _LIT(KVisibility2,"Change Visibility 2"); - _LIT(KOrdinal,"Ordinal Position"); - _LIT(KSizeChange,"Size Change"); - _LIT(KMoveWin,"Move Window"); - _LIT(KGroupWin,"Group Window Ordinal"); - _LIT(KBackground,"Background Color Changes"); - _LIT(KShadowsOnOff,"Shadows On Off"); - _LIT(KChild1,"Child 1"); - _LIT(KChild2,"Child 2"); - _LIT(KOpacity,"Opaque Drawing"); - _LIT(KTranWinFade,"Fading Transparent Windows"); - ((CTMultipleTransStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); - - switch(iTest->iState) - { - case 0: -/** -@SYMTestCaseID GRAPHICS-WSERV-0500 -*/ - ((CTMultipleTransStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0500")); - // Check to see if Transparency is enabled before running tests - iTest->LogSubTest(KCheck); - if (TransparencySupportedL()==KErrNotSupported) - { - LOG_MESSAGE(_L("Transparency is not supported\n")); - TestComplete(); - return; - } - ++iTest->iState; //Fall Through -/** -@SYMTestCaseID GRAPHICS-WSERV-0111 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Simple transparent windows test. - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Four overlapping transparent windows (RWindow) are created before the test on the screen's left side. - The test draws the windows on the screen's right side using FBS bitmaps direcly. - The test does nothing if transparency is not enabled on the screen. - -@SYMTestExpectedResults Expects that left and rightside bitmaps are identical -*/ - case 1: - ((CTMultipleTransStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0111")); - iTest->LogSubTest(KSimple); - SimpleTest(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0112 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc On/off switching of visibility of transparent windows - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Four overlapping transparent windows (RWindow) are created before the test on the screen's left side. - The test toggles visibility of those four windows going through all - combinations. For each combination it draws visible windows on the screen's right side using FBS bitmaps direcly. - The test does nothing if transparency is not enabled on the screen. - -@SYMTestExpectedResults Expects that left and rightside bitmaps are identical -*/ - case 2: - case 23: - case 42: - ((CTMultipleTransStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0112")); - iTest->LogSubTest(KVisibility); - ChangeVisibility(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0113 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc On/off switching of visibility of a small transparent window on top of existing transparent windows - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Four overlapping transparent windows (RWindow) are created before the test on the screen's left side. - Toggles visibility of 5th blank little window making this appear in different places - with different ordinal position. Draws visible windows on the screen's right side using FBS bitmaps direcly - each time when the 5th window becomes invisible. - The test does nothing if transparency is not enabled on the screen. - -@SYMTestExpectedResults Expects that left and rightside bitmaps are identical -*/ - case 3: - ((CTMultipleTransStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0113")); - iTest->LogSubTest(KVisibility2); - ChangeVisibility2(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0114 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Ordinal positions' switches of intersecting transparent windows - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Four overlapping transparent windows (RWindow) are created before the test on the screen's left side. - Switches ordinal positions of the four windows trying all combinations. Draws visible windows on the screen's right side - using FBS bitmaps direcly each time when a new combination is applied. - The test does nothing if transparency is not enabled on the screen. - - -@SYMTestExpectedResults Expects that left and rightside bitmaps are identical -*/ - case 4: - case 43: - ((CTMultipleTransStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0114")); - iTest->LogSubTest(KOrdinal); - OrdinalPos(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0115 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Changing sizes of intersecting transparent windows - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Four overlapping transparent windows (RWindow) are created before the test on the screen's left side. - Plays with sizes of each of the four windows to affect overlapping. - Draws visible windows on the screen's right side using FBS bitmaps direcly - each time when a new size for a particular window is applied. - The test does nothing if transparency is not enabled on the screen. - - -@SYMTestExpectedResults Expects that left and rightside bitmaps are identical -*/ - case 5: - case 24: - ((CTMultipleTransStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0115")); - iTest->LogSubTest(KSizeChange); - SizeChange(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0116 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Moving intersecting transparent windows - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Four overlapping transparent windows (RWindow) are created before the test on the screen's left side. - Performs moves of those windows one by one making little steps in direction of the center of intersection and backwards. - Draws visible windows on the screen's right side using FBS bitmaps direcly - each time when a position of a particular window changes. - The test does nothing if transparency is not enabled on the screen. - -@SYMTestExpectedResults Expects that left and rightside bitmaps are identical -*/ - case 6: - ((CTMultipleTransStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0116")); - iTest->LogSubTest(KMoveWin); - MoveWin(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0117 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test with a second window group - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Four overlapping transparent windows (RWindow, within the same group) are created before the test on the screen's left side. - Creates a 5th transparent window in a separate window group - on top of existing windows which covers the intersection area of initial 4 windows. - Changes the ordinal position of the group to 1, changes ordinal position - back to 0, removes the new group. - Redraws visible windows on the screen's right side using FBS bitmaps direcly - each time when any change on the screen's left side is performed. - The test does nothing if transparency is not enabled on the screen. - -@SYMTestExpectedResults Expects that left and rightside bitmaps are identical -*/ - case 7: - ((CTMultipleTransStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0117")); - iTest->LogSubTest(KGroupWin); - GroupWinL(); - break; - case 8: - ((CTMultipleTransStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - iTest->LogSubTest(KBackground); - //Change the background color of the 4 test windows and the window behind them - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0118 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc On/off switching of fading - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Four overlapping transparent windows (RWindow) are created before the test on the screen's left side. - Switches system fading on and right after that back to off. - Draws visible windows on the screen's right side using FBS bitmaps direcly - after that. - The test does nothing if transparency is not enabled on the screen. - -@SYMTestExpectedResults Expects that left and rightside bitmaps are identical -*/ - case 9: - ((CTMultipleTransStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0118")); - iTest->LogSubTest(KTranWinFade); - FadeTranWin(); - break; - case 10: - ((CTMultipleTransStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - iTest->iState=21-1; - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0120 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Shadows' on/off test. - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Four overlapping transparent windows (RWindow) with shadowing enabled are created before the test on the screen's left side. - The test plays with on/off-switching of shadowing and visibility for the windows. - The test redraws visible windows on the screen's right side using FBS bitmaps direcly - each time when state of ony window changes. - The test does nothing if transparency is not enabled on the screen. - The test also repeats GRAPHICS-WSERV-0111 - GRAPHICS-WSERV-015 foor the shadowed windows. - -@SYMTestExpectedResults Expects that left and rightside bitmaps are identical -*/ - case 22: - ((CTMultipleTransStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0120")); - iTest->LogSubTest(KShadowsOnOff); - ShadowsOnOff(); - break; - case 25: - ((CTMultipleTransStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - iTest->iState=41-1; - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0121 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Transparent child-windows of a bacground window - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Four overlapping transparent windows (RWindow) with shadowing enabled are created before the test on the screen's left side. - The test removes those windows and creates new four overlapping transparent windows - but as children of existing background window. After that the test redraws visible windows on the screen's right side using FBS bitmaps direcly. - The test does nothing if transparency is not enabled on the screen. - The test also repeats GRAPHICS-WSERV-0111 - GRAPHICS-WSERV-014 foor the shadowed windows. - -@SYMTestExpectedResults Expects that left and rightside bitmaps are identical -*/ - case 41: - ((CTMultipleTransStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0121")); - iTest->LogSubTest(KChild1); - StartChildL(); - break; - case 44: - ((CTMultipleTransStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - iTest->iState=61-1; - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0122 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Four overlapping transparent windows (RWindow) with shadowing enabled are created before the test on the screen's left side. - The test removes those windows and creates new four transparent windows - so that each one (except first) is a child of prevoiusly created window. - The test redraws visible windows on the screen's right side using FBS bitmaps direcly - after each window's creation. - The test does nothing if transparency is not enabled on the screen. - -@SYMTestExpectedResults Expects that left and rightside bitmaps are identical -*/ - case 61: - ((CTMultipleTransStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0122")); - iTest->LogSubTest(KChild2); - StartChild2L(); - break; - default: - ((CTMultipleTransStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0123")); -/** -@SYMTestCaseID GRAPHICS-WSERV-0123 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions The test draws four overlapping transparent windows (RWindow) on the screen's left side. - Each window has an opaque diagonal line (\) which goes from the top-left corner of each window. - The test repeats all tests from GRAPHICS-WSERV-0111 to GRAPHICS-WSERV-0122 - with those four windows and diagonaly lines on them. - -@SYMTestExpectedResults Expects that all tests will obtain results they expected. -*/ - if (iMajorTest==1 || !iOpacitySupported) - { - if (!iOpacitySupported) - { - _LIT(KNoOpacity,"Opacity is not supported"); - LOG_MESSAGE(KNoOpacity); - } - ((CTMultipleTransStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - TestComplete(); - return; - } - LOG_MESSAGE(KOpacity); - iTest->iState=0; - iMajorTest=1; - RecreateWindowsL(); - break; - } - ((CTMultipleTransStep*)iStep)->RecordTestResultL(); - ++iTest->iState; - } - - -__WS_CONSTRUCT_STEP__(MultipleTrans) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TMulTran.H --- a/windowing/windowserver/tauto/TMulTran.H Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,91 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef __TMULTRAN_H__ -#define __TMULTRAN_H__ - -#include -#include -#include "../tlib/testbase.h" -#include "AUTO.H" -#include "TGraphicsHarness.h" - - -class CTMultipleTrans : public CTWsGraphicsBase - { -public: - CTMultipleTrans(CTestStep* aStep); - ~CTMultipleTrans(); - void ConstructL(); - void CheckDisplay(); - void SimpleTest(); - void ChangeVisibility(); - void ChangeVisibility2(); - void OrdinalPos(); - void SizeChange(); - void MoveWin(); - void GroupWinL(); - void StartShadows(); - void ShadowsOnOff(); - void StartChildL(); - void StartChild2L(); - void FadeTranWin(); -protected: //Pure virtual function from MTestCase - void RunTestCaseL(TInt aCurTestCase); -private: - void RecreateWindowsL(CTWinBase *aParent=0); - void ShadowRegion(TRegion& aRegion,TInt aWin); - void AdvancedCheckRect(); - void SizeChange(TInt aJump); - TSize GetSize(TInt aPos); - - -private: - CTBlankWindow* iBackgroundWin; - CTBackedUpWin* iCheckWin; - CBitmap* iCheckBitmap; - RPointerArray iWindows; - CTransWindow* iTopLeft; - CTransWindow* iTopRight; - CTransWindow* iBotLeft; - CTransWindow* iBotRight; - RBlankWindow iBlankWin; - TRgb iBlankWinCol; - TPoint iBlankWinPos; - TSize iBlankWinSize; - TBool iBlankWinVis; - TBool iShadows; - TInt iMajorTest; - TBool iOpacitySupported; - }; - -class CTMultipleTransStep : public CTGraphicsStep - { -public: - CTMultipleTransStep(); -protected: - //from CTGraphicsStep - virtual CTGraphicsBase* CreateTestL(); - }; - -_LIT(KTMultipleTransStep,"TMultipleTrans"); - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TOOM.CPP --- a/windowing/windowserver/tauto/TOOM.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1583 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Out of memory tests -// -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - - -#include "TOOM.H" - - -typedef COomFailBase *(*COmmCreate)(CTOom *aTest); - -COomFailBase *CreateOomConnect(CTOom *aTest) - {return(new(ELeave) COomConnect(aTest));} - -COomFailBase *CreateOomWindow(CTOom *aTest) - {return(new(ELeave) COomWindow(aTest));} - -COomFailBase *CreateOomWindowGroup(CTOom *aTest) - {return(new(ELeave) COomWindowGroup(aTest));} - -COomFailBase *CreateOomBackedUpWindow(CTOom *aTest) - {return(new(ELeave) COomBackedUpWindow(aTest));} - -COomFailBase *CreateOomBackupResize(CTOom *aTest) - {return(new(ELeave) COomBackupResize(aTest));} - -COomFailBase *CreateOomBlankWindow(CTOom *aTest) - {return(new(ELeave) COomBlankWindow(aTest));} - -COomFailBase *CreateOomGc(CTOom *aTest) - {return(new(ELeave) COomGc(aTest));} - -COomFailBase *CreateOomScreenDevice(CTOom *aTest) - {return(new(ELeave) COomScreenDevice(aTest));} - -COomFailBase *CreateOomPointerBuffer(CTOom *aTest) - {return(new(ELeave) COomPointerBuffer(aTest));} - -COomFailBase *CreateOomPolygon(CTOom *aTest) - {return(new(ELeave) COomPolygon(aTest));} - -COomFailBase *CreateOomPriorityKey(CTOom *aTest) - {return(new(ELeave) COomPriorityKey(aTest));} - -COomFailBase *CreateOomCaptureKey(CTOom *aTest) - {return(new(ELeave) COomCaptureKey(aTest));} - -COomFailBase *CreateOomCaptureKeyUpDown(CTOom *aTest) - {return(new(ELeave) COomCaptureKeyUpDown(aTest));} - -COomFailBase *CreateOomHotKey(CTOom *aTest) - {return(new(ELeave) COomHotKey(aTest));} - -COomFailBase *CreateOomGroupName(CTOom *aTest) - {return(new(ELeave) COomGroupName(aTest));} - -COomFailBase *CreateOomMessageSend(CTOom *aTest) - {return(new(ELeave) COomMessageSend(aTest));} - -COomFailBase *CreateOomMessageFetch(CTOom *aTest) - {return(new(ELeave) COomMessageFetch(aTest));} - -COomFailBase *CreateOomSprite(CTOom *aTest) - {return(new(ELeave) COomSprite(aTest));} - -COomFailBase *CreateOomPointerCursor(CTOom *aTest) - {return(new(ELeave) COomPointerCursor(aTest));} - -COomFailBase *CreateOomCopyScreen(CTOom *aTest) - {return(new(ELeave) COomCopyScreen(aTest));} - -COomFailBase *CreateOomRequestEvents(CTOom *aTest) - {return(new(ELeave) COomRequestEvents(aTest));} - -COomFailBase *CreateOomCustomTextCursor(CTOom *aTest) - {return(new(ELeave) COomCustomTextCursor(aTest));} - -COomFailBase *CreateOomTranspWindow(CTOom *aTest) - {return(new(ELeave) COomTranspWindow(aTest));} - -COomFailBase *CreateOomObscuredWindow(CTOom *aTest) - {return(new(ELeave) COomObscuredWindow(aTest));} - -COmmCreate CreateOomFailTest[]={ - CreateOomConnect, - CreateOomWindow, - CreateOomWindowGroup, - CreateOomBackedUpWindow, - CreateOomBackupResize, - CreateOomBlankWindow, - CreateOomGc, - CreateOomScreenDevice, - CreateOomPointerBuffer, - CreateOomPolygon, - CreateOomPriorityKey, - CreateOomCaptureKey, - CreateOomCaptureKeyUpDown, - CreateOomHotKey, - CreateOomGroupName, - CreateOomSprite, - CreateOomPointerCursor, - CreateOomCopyScreen, - CreateOomRequestEvents, - CreateOomMessageSend, - CreateOomMessageFetch, - CreateOomCustomTextCursor, - CreateOomTranspWindow, - CreateOomObscuredWindow, - }; - -// -// Individual out of memory test classes // -// - -COomFailBase::COomFailBase(CTOom *aTest) : iTest(aTest) - {} - -void COomFailBase::ConstructL() - { - iTest->INFO_PRINTF1(TestName()); - } - -void COomFailBase::PreFail() - {} - -void COomFailBase::ClearUpL() - {} - -void COomFailBase::Flush() - { - iWs.Flush(); - } - -COomConnect::COomConnect(CTOom *aTest) : COomFailBase(aTest) - {} - -TOomTestName COomConnect::TestName() - { - return(_L("Connect")); - } - -/** Creates a wserv session, connects and creates CWsScreenDevice object -*/ -TInt COomConnect::Fail() - { - TInt err = iWs.Connect(); - if (err!=KErrNone) - return err; - - TRAP(err, iDummyScreen = new (ELeave) CWsScreenDevice(iWs)); - if (err!=KErrNone) - { - iWs.Close(); - return err; - } - - if ((err=iDummyScreen->Construct(iTest->ScreenNumber()))!=KErrNone) - { - delete iDummyScreen; - iDummyScreen = NULL; - iWs.Close(); - return err; - } - - return err; - } - -void COomConnect::ClearUpL() - { - if (iDummyScreen) - { - delete iDummyScreen; - iDummyScreen = NULL; - } - iWs.Close(); - } - -// - -COomSetup::COomSetup(CTOom *aTest) : COomFailBase(aTest) - {} - -void COomSetup::ConstructL() - { - COomFailBase::ConstructL(); - User::LeaveIfError(iWs.Connect()); - iDummyScreen = new (ELeave) CWsScreenDevice(iWs); - User::LeaveIfError(iDummyScreen->Construct(iTest->ScreenNumber())); - - iWinGroup=RWindowGroup(iWs); - iWinGroup.Construct(556); - iWinGroup.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close - } - -COomSetup::~COomSetup() - { - iWinGroup.Close(); - delete iDummyScreen; - iDummyScreen = NULL; - - iTest->TEST(iWs.ResourceCount()==0); - if (iWs.ResourceCount()!=0) - iTest->INFO_PRINTF3(_L("iWs.ResourceCount() return value - Expected: %d, Actual: %d"), 0, iWs.ResourceCount()); - - iWs.Close(); - } - -// - -COomWindowGroup::COomWindowGroup(CTOom *aTest) : COomSetup(aTest) - {} - -TOomTestName COomWindowGroup::TestName() - { - return(_L("Window Group")); - } - -/** Creates a RWindowGroup object -*/ -TInt COomWindowGroup::Fail() - { - iFailWinGroup=RWindowGroup(iWs); - return(iFailWinGroup.Construct(987)); - } - -void COomWindowGroup::ClearUpL() - { - iFailWinGroup.Close(); - } - -// - -COomWindow::COomWindow(CTOom *aTest) : COomSetup(aTest) - {} - -TOomTestName COomWindow::TestName() - { - return(_L("Window")); - } - -/** Creates a RWindow object -*/ -TInt COomWindow::Fail() - { - iFailWin=RWindow(iWs); - return(iFailWin.Construct(iWinGroup,11)); - } - -void COomWindow::ClearUpL() - { - iFailWin.Close(); - } - -// - -COomBackedUpWindow::COomBackedUpWindow(CTOom *aTest) : COomSetup(aTest) - {} - -TOomTestName COomBackedUpWindow::TestName() - { - return(_L("Backed up window")); - } - -/** Creates a RBackedUpWindow object -*/ -TInt COomBackedUpWindow::Fail() - { - iFailWin=RBackedUpWindow(iWs); - return(iFailWin.Construct(iWinGroup,EGray16,22)); - } - -void COomBackedUpWindow::ClearUpL() - { - iFailWin.Close(); - } - -// - -COomBackupResize::COomBackupResize(CTOom *aTest) : COomSetup(aTest) - {} - -COomBackupResize::~COomBackupResize() - { - iFailWin.Close(); - } - -TOomTestName COomBackupResize::TestName() - { - return(_L("Resize backed up window")); - } - -void COomBackupResize::ConstructL() - { - COomSetup::ConstructL(); - iFailWin=RBackedUpWindow(iWs); - User::LeaveIfError(iFailWin.Construct(iWinGroup,EGray16,33)); - User::LeaveIfError(iFailWin.SetSizeErr(TSize(10,10))); - iFailWin.Activate(); - } - -/** Sets the size of previously created backed-up window -*/ -TInt COomBackupResize::Fail() - { - return(iFailWin.SetSizeErr(TSize(100,100))); - } - -void COomBackupResize::ClearUpL() -//Virtual fn declared in CoomFailBase. This is the only one that can leave, I think, but one is enough - { - User::LeaveIfError(iFailWin.SetSizeErr(TSize(10,10))); - } - -// - -COomBlankWindow::COomBlankWindow(CTOom *aTest) : COomSetup(aTest) - {} - -TOomTestName COomBlankWindow::TestName() - { - return(_L("Blank window")); - } - -/** Creates a RBlankWindow object -*/ -TInt COomBlankWindow::Fail() - { - iFailWin=RBlankWindow(iWs); - return(iFailWin.Construct(iWinGroup,44)); - } - -void COomBlankWindow::ClearUpL() - { - iFailWin.Close(); - } - -// - -COomPointerBuffer::COomPointerBuffer(CTOom *aTest) : COomSetup(aTest) - {} - -COomPointerBuffer::~COomPointerBuffer() - { - iFailWin.Close(); - } - -TOomTestName COomPointerBuffer::TestName() - { - return(_L("Pointer buffer")); - } - -void COomPointerBuffer::ConstructL() - { - COomSetup::ConstructL(); - iFailWin=RBackedUpWindow(iWs); - User::LeaveIfError(iFailWin.Construct(iWinGroup,EGray16,55)); - User::LeaveIfError(iFailWin.SetSizeErr(TSize(10,10))); - iFailWin.Activate(); - } - -/** Allocates a buffer for storing pointer movements for previously created backed-up window -*/ -TInt COomPointerBuffer::Fail() - { - return(iFailWin.AllocPointerMoveBuffer(10,0)); - } - -void COomPointerBuffer::ClearUpL() - { - iFailWin.FreePointerMoveBuffer(); - } - -// - -COomPriorityKey::COomPriorityKey(CTOom *aTest) : COomSetup(aTest) - {} - -COomPriorityKey::~COomPriorityKey() - { - } - -TOomTestName COomPriorityKey::TestName() - { - return(_L("Priority key")); - } - -void COomPriorityKey::ConstructL() - { - COomSetup::ConstructL(); - } - -/** Adds a priority key for a previously created window group -*/ -TInt COomPriorityKey::Fail() - { - return(iWinGroup.AddPriorityKey(1,0,0)); - } - -void COomPriorityKey::ClearUpL() - { - iWinGroup.RemovePriorityKey(1,0,0); - } - -// - -COomCaptureKey::COomCaptureKey(CTOom *aTest) : COomSetup(aTest) - {} - -COomCaptureKey::~COomCaptureKey() - { - } - -TOomTestName COomCaptureKey::TestName() - { - return(_L("Capture key")); - } - -void COomCaptureKey::ConstructL() - { - COomSetup::ConstructL(); - } - -/** Requests a capture keys for a previously created window group -*/ -TInt COomCaptureKey::Fail() - { - for (iIndex=0;iIndex<(TInt)(sizeof(iCapKey)/sizeof(iCapKey[0]));iIndex++) - { - TInt ret=iWinGroup.CaptureKey('a',0,0); - if (ret<0) - return(ret); - iCapKey[iIndex]=ret; - } - return(KErrNone); - } - -void COomCaptureKey::ClearUpL() - { - for (TInt index=0;index params(_L8("SomeParams")); - return(iWs.SendMessageToWindowGroup(iWinGroup2.Identifier(),TUid::Uid(123),params)); - } - -void COomMessageSend::ClearUpL() - { - iWinGroup2.Close(); - } - -// - -COomMessageFetch::COomMessageFetch(CTOom *aTest) : COomSetup(aTest) - {} - -COomMessageFetch::~COomMessageFetch() - { - } - -TOomTestName COomMessageFetch::TestName() - { - return(_L("MessageFetch")); - } - -void COomMessageFetch::ConstructL() - { - COomSetup::ConstructL(); - } - -#define CLIENT_HANDLE 555 -#define UID_VALUE 123 -#define MESSAGE_LEN 0x20 -void COomMessageFetch::PreFail() - { - iWinGroup2=RWindowGroup(iWs); - iWinGroup2.Construct(CLIENT_HANDLE); - iWinGroup2.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close - TBuf8 params(_L8("SomeParams")); - TBool retVal = iWs.SendMessageToWindowGroup(iWinGroup2.Identifier(),TUid::Uid(UID_VALUE),params); - iTest->TEST(retVal==KErrNone); - if (retVal!=KErrNone) - iTest->INFO_PRINTF3(_L("iWs.SendMessageToWindowGroup() return value - Expected: %d, Actual: %d"), KErrNone, retVal); - } - -/** Fetches a message -*/ -TInt COomMessageFetch::Fail() - { - TWsEvent event; - TPtr8 ptr(NULL,0); - TUid uid; - event.SetType(EEventMessageReady); - event.SetHandle(CLIENT_HANDLE); - event.SetTimeNow(); - SEventMessageReady& eventMessageReady=*(SEventMessageReady*)event.EventData(); - eventMessageReady.iWindowGroupIdentifier=iWinGroup2.Identifier(); - eventMessageReady.iMessageUid=TUid::Uid(UID_VALUE); - eventMessageReady.iMessageParametersSize=MESSAGE_LEN; - TInt ret=TheClient->iWs.FetchMessage(uid,ptr,event); - if (ret==KErrNone) - User::Free((TAny *)ptr.Ptr()); - return(ret); - } - -void COomMessageFetch::ClearUpL() - { - iWinGroup2.Close(); - } - -// - -COomRequestEvents::COomRequestEvents(CTOom *aTest) : COomSetup(aTest) - {} - -COomRequestEvents::~COomRequestEvents() - { - } - -TOomTestName COomRequestEvents::TestName() - { - return(_L("Request events")); - } - -void COomRequestEvents::ConstructL() - { - COomSetup::ConstructL(); - } - -/** Enables window group change events and modifier change events -*/ -TInt COomRequestEvents::Fail() - { - TInt err; - if ((err=iWinGroup.EnableOnEvents())==KErrNone) - if ((err=iWinGroup.EnableGroupChangeEvents())==KErrNone) - err=iWinGroup.EnableModifierChangedEvents(EModifierCapsLock,EEventControlAlways); - return(err); - } - -void COomRequestEvents::ClearUpL() - { - iWinGroup.DisableOnEvents(); - iWinGroup.DisableGroupChangeEvents(); - iWinGroup.DisableModifierChangedEvents(); - } - -// - -COomCopyScreen::COomCopyScreen(CTOom *aTest) : COomSetup(aTest) - {} - -TOomTestName COomCopyScreen::TestName() - { - return(_L("Copy screen")); - } - -COomCopyScreen::~COomCopyScreen() - { - delete iScrDev; - delete iBitmap; - } - -void COomCopyScreen::ConstructL() - { - COomSetup::ConstructL(); - iScrDev=new(ELeave) CWsScreenDevice(iWs); - User::LeaveIfError(iScrDev->Construct(iTest->ScreenNumber())); - iBitmap=new(ELeave) CFbsBitmap(); - User::LeaveIfError(iBitmap->Create(TSize(100,100),EGray4)); - } - -/** Copies screen to bitmap -*/ -TInt COomCopyScreen::Fail() - { - TInt ret=iScrDev->CopyScreenToBitmap(iBitmap); - if (ret==KErrNone) - ret=iScrDev->CopyScreenToBitmap(iBitmap,TRect(10,10,50,50)); - return(ret); - } - -void COomCopyScreen::ClearUpL() - { - } - -// - -COomSpriteBase::COomSpriteBase(CTOom *aTest) : COomSetup(aTest) - {} - -COomSpriteBase::~COomSpriteBase() - { - iWin.Close(); - delete iBitmap; - delete iMask; - delete iBitmap2; - delete iMask2; - } - -void COomSpriteBase::ConstructL() - { - COomSetup::ConstructL(); - iWin=RWindow(iWs); - User::LeaveIfError(iWin.Construct(iWinGroup,33)); - User::LeaveIfError(iWin.SetSizeErr(TSize(100,100))); - iWin.Activate(); - iBitmap=new(ELeave) CFbsBitmap(); - User::LeaveIfError(iBitmap->Create(TSize(10,10),EGray4)); - iBitmap2=new(ELeave) CFbsBitmap(); - User::LeaveIfError(iBitmap2->Create(TSize(40,40),EGray4)); - iMask=new(ELeave) CFbsBitmap(); - User::LeaveIfError(iMask->Create(TSize(10,10),EGray4)); - iMask2=new(ELeave) CFbsBitmap(); - User::LeaveIfError(iMask2->Create(TSize(40,40),EGray4)); - } - -// - -COomSprite::COomSprite(CTOom *aTest) : COomSpriteBase(aTest) - {} - -TOomTestName COomSprite::TestName() - { - return(_L("Sprites")); - } - -/** Creates a sprite. -*/ -TInt COomSprite::Fail() - { - iSprite=RWsSprite(iWs); - TInt err=iSprite.Construct(iWin,TPoint(10,10),0); - if (err==KErrNone) - { - TSpriteMember sprite; - sprite.iBitmap=iBitmap; - sprite.iMaskBitmap=iMask; - sprite.iInvertMask=EFalse; - sprite.iDrawMode=CGraphicsContext::EDrawModePEN; - sprite.iOffset=TPoint(0,0); - sprite.iInterval=TTimeIntervalMicroSeconds32(100000); - if ((err=iSprite.AppendMember(sprite))==KErrNone) - if ((err=iSprite.Activate())==KErrNone) - { - sprite.iBitmap=iBitmap2; // Bigger bitmap to force resize of bitmap - sprite.iMaskBitmap=iMask2; - if ((err=iSprite.AppendMember(sprite))==KErrNone) - err=iSprite.UpdateMember(1,sprite); - } - } - return(err); - } - -void COomSprite::ClearUpL() - { - iSprite.Close(); - } - -// - -COomPointerCursor::COomPointerCursor(CTOom *aTest) : COomSpriteBase(aTest) - {} - -TOomTestName COomPointerCursor::TestName() - { - return(_L("Pointer cursor")); - } - -/** Creates a pointer cursor. -*/ -TInt COomPointerCursor::Fail() - { - iPointerCursor=RWsPointerCursor(iWs); - TInt err=iPointerCursor.Construct(0); - if (err==KErrNone) - { - TSpriteMember sprite; - sprite.iBitmap=iBitmap; - sprite.iMaskBitmap=iMask; - sprite.iInvertMask=EFalse; - sprite.iDrawMode=CGraphicsContext::EDrawModePEN; - sprite.iOffset=TPoint(0,0); - sprite.iInterval=TTimeIntervalMicroSeconds32(100000); - if ((err=iPointerCursor.AppendMember(sprite))==KErrNone) - if ((err=iPointerCursor.Activate())==KErrNone) - { - sprite.iBitmap=iBitmap2; // Bigger bitmap to force resize of bitmap - sprite.iMaskBitmap=iMask2; - if ((err=iPointerCursor.AppendMember(sprite))==KErrNone) - err=iPointerCursor.UpdateMember(1,sprite); - } - } - return(err); - } - -void COomPointerCursor::ClearUpL() - { - iPointerCursor.Close(); - } - -// - -COomGc::COomGc(CTOom *aTest) : COomSetup(aTest) - {} - -COomGc::~COomGc() - { - delete iScrDev; - } - -TOomTestName COomGc::TestName() - { - return(_L("Graphic Context")); - } - -void COomGc::ConstructL() - { - COomSetup::ConstructL(); - iScrDev=new(ELeave) CWsScreenDevice(iWs); - User::LeaveIfError(iScrDev->Construct(iTest->ScreenNumber())); - } - -/** Creates a graphical context for a previously created screen device. -*/ -TInt COomGc::Fail() - { - TRAPD(err,iFailGc=new(ELeave) CWindowGc(iScrDev)); - if (err!=KErrNone) - return(err); - return(iFailGc->Construct()); - } - -void COomGc::ClearUpL() - { - delete iFailGc; - iFailGc=NULL; - } - -// - -COomPolygon::COomPolygon(CTOom *aTest) : COomSetup(aTest), iPnts(5) - {} - -COomPolygon::~COomPolygon() - { - delete iGc; - delete iScrDev; - iWin.Close(); - } - -TOomTestName COomPolygon::TestName() - { - return(_L("Polygon")); - } - -void COomPolygon::ConstructL() - { - COomSetup::ConstructL(); - iScrDev=new(ELeave) CWsScreenDevice(iWs); - User::LeaveIfError(iScrDev->Construct(iTest->ScreenNumber())); - User::LeaveIfError(iScrDev->CreateContext(iGc)); - iWin=RBackedUpWindow(iWs); - User::LeaveIfError(iWin.Construct(iWinGroup,EGray16,33)); - User::LeaveIfError(iWin.SetSizeErr(TSize(40,40))); - iWin.Activate(); - TInt index; - for(index=0;index<20;index+=2) - iPnts.AppendL(TPoint(20+index,index)); - for(index=0;index<20;index+=2) - iPnts.AppendL(TPoint(40-index,20+index)); - for(index=0;index<20;index+=2) - iPnts.AppendL(TPoint(20-index,40-index)); - for(index=0;index<20;index+=2) - iPnts.AppendL(TPoint(index,20-index)); - } - -/** Draws a polygon. -*/ -TInt COomPolygon::Fail() - { - iGc->Activate(iWin); - iGc->Clear(); - iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - iGc->SetBrushColor(TRgb::Gray4(2)); - iGc->SetPenColor(TRgb::Gray4(0)); - TInt err=iGc->DrawPolygon(&iPnts,CGraphicsContext::EAlternate); - if (err!=KErrNone) - return(err); - err=iGc->DrawPolygon(&iPnts,CGraphicsContext::EWinding); - if (err!=KErrNone) - return(err); - return(KErrNone); - } - -void COomPolygon::ClearUpL() - { - iGc->Deactivate(); - } - -// - -COomScreenDevice::COomScreenDevice(CTOom *aTest) : COomSetup(aTest) - {} - -TOomTestName COomScreenDevice::TestName() - { - return(_L("Screen device")); - } - -/** Creates a screen device handle. -*/ -TInt COomScreenDevice::Fail() - { - TRAPD(err,iScrDev=new(ELeave) CWsScreenDevice(iWs)); - if (err!=KErrNone) - return(err); - return(iScrDev->Construct(iTest->ScreenNumber())); - } - -void COomScreenDevice::ClearUpL() - { - delete iScrDev; - iScrDev=NULL; - } - -// - -COomCustomTextCursor::COomCustomTextCursor(CTOom *aTest) : COomSetup(aTest) - {} - -COomCustomTextCursor::~COomCustomTextCursor() - { - delete iMemberArray; - delete iBitmap; - } - -TOomTestName COomCustomTextCursor::TestName() - { - return(_L("Custom Text Cursor")); - } - -void COomCustomTextCursor::ConstructL() - { - COomSetup::ConstructL(); - - iBitmap = new(ELeave) CFbsBitmap; - User::LeaveIfError(iBitmap->Load(TEST_BITMAP_NAME, EMbmWsautotestBmp1)); - - TSpriteMember member; - member.iMaskBitmap=NULL; - member.iInvertMask=EFalse; - member.iDrawMode=CGraphicsContext::EDrawModePEN; - member.iOffset=TPoint(); - member.iInterval=TTimeIntervalMicroSeconds32(0); - member.iBitmap = iBitmap; - - iMemberArray = new(ELeave) CArrayFixFlat(1); - iMemberArray->AppendL(member); - } - -/** Adds a custom text cursor to the server's list of cursors. -*/ -TInt COomCustomTextCursor::Fail() - { - TInt err = TheClient->iWs.SetCustomTextCursor(0x98765432, iMemberArray->Array(), 0, RWsSession::ECustomTextCursorAlignTop); - if (err == KErrAlreadyExists) - return KErrNone; - else - return err; - } - -void COomCustomTextCursor::ClearUpL() - { - } - -COomTranspWindow::COomTranspWindow(CTOom *aTest) : COomSetup(aTest) - {} - -COomTranspWindow::~COomTranspWindow() - { - delete iBackgroundWin; - delete iFirst; - delete iSecond; - - delete iFbsBitmap; - delete iWsBitmap; - delete iFbsBitmapDevice; - delete iFbsBitmapGc; - delete iWsBitmapDevice; - delete iWsBitmapGc; - } - -TOomTestName COomTranspWindow::TestName() - { - return(_L("Transparent Window")); - } - -void COomTranspWindow::ConstructL() - { - COomSetup::ConstructL(); - - iTransparencyEnabled = (TransparencySupportedL() == KErrNone); - if(!iTransparencyEnabled) - return; - - iFbsBitmap = new (ELeave) CFbsBitmap; - - // Do the creation - const TSize KSizeForBitmap(10,10); - iFbsBitmap->Create(KSizeForBitmap,EGray256); - - // Fill the bitmap with a colour - iFbsBitmapDevice=CFbsBitmapDevice::NewL(iFbsBitmap); - - iFbsBitmapDevice->CreateContext(iFbsBitmapGc); - - iFbsBitmapGc->SetPenStyle(CGraphicsContext::ENullPen); - iFbsBitmapGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - iFbsBitmapGc->SetBrushColor(128); - iFbsBitmapGc->DrawRect(TRect(KSizeForBitmap)); - - // Create a CWsBitmap, and fill it with a colour - iWsBitmap = new (ELeave) CWsBitmap(TheClient->iWs); - - // Do the creation - iWsBitmap->Create(KSizeForBitmap,EGray256); - - // Fill the bitmap with a colour - iWsBitmapDevice=CFbsBitmapDevice::NewL(iWsBitmap); - - iWsBitmapDevice->CreateContext(iWsBitmapGc); - iWsBitmapGc->SetPenStyle(CGraphicsContext::ENullPen); - iWsBitmapGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - iWsBitmapGc->SetBrushColor(128); - iWsBitmapGc->DrawRect(TRect(KSizeForBitmap)); - } - - -/** Does nothing if transparency is not enabled. Creates a blank window with -* two transparent child-windows. Tests setting the transparency via a factor, CFbsBitmap -* or a CWsBitmap, and changing from one to the other. -* Changes child-windows' sizes and toggles their visibility. -*/ -TInt COomTranspWindow::Fail() - { - if(!iTransparencyEnabled) - return KErrNone; - TSize scrSize(TheClient->iScreen->SizeInPixels()); - TRAPD(res, iBackgroundWin = new (ELeave) CBlankWindow(TRgb(0,0,238))); - if(res != KErrNone) - { - return res; - } - - TDisplayMode mode=EColor256; - TRAP(res, iBackgroundWin->SetUpL(TPoint(50,50),scrSize-TSize(100,100),TheClient->iGroup,*TheClient->iGc,&mode)); - if(res != KErrNone) - { - return res; - } - - TheClient->Flush(); - TheClient->WaitForRedrawsToFinish(); - - iBackgroundWin->Win()->SetBackgroundColor(TRgb(51,204,51)); - iBackgroundWin->Invalidate(); - - TheClient->Flush(); - TheClient->WaitForRedrawsToFinish(); - - TRect thePos1(20, 20, 60, 60); - TRect thePos2(100, 40, 160, 80); - TRAP(res, iFirst = CTransWindow::NewL(iBackgroundWin, TRgb(255,0,0,128),&mode)); - if(res != KErrNone) - { - return res; - } - - TRAP(res, iSecond = CTransWindow::NewL(iBackgroundWin, TRgb(255,0,0,128),&mode)); - if(res != KErrNone) - { - return res; - } - - TRAP(res, iFirst->SetExtL(thePos1.iTl,thePos1.Size())); - if(res != KErrNone) - { - return res; - } - - TRAP(res, iSecond->SetExtL(thePos2.iTl,thePos2.Size())); - if(res != KErrNone) - { - return res; - } - - res=SetTransparencyTesting(); - if(res != KErrNone) - { - return res; - } - - TheClient->Flush(); - //TheClient->WaitForRedrawsToFinish(); - - iFirst->Activate(); - iFirst->AssignGC(*TheClient->iGc); - - iSecond->Activate(); - iSecond->AssignGC(*TheClient->iGc); - - iFirst->Win()->SetBackgroundColor(TRgb(0, 0, 255)); - iSecond->Win()->SetBackgroundColor(TRgb(0, 0, 255)); - iFirst->Invalidate(); - iSecond->Invalidate(); - - iFirst->AdjustSize(150,10, 0); - iSecond->AdjustSize(150,10, 0); - - TheClient->Flush(); - TheClient->WaitForRedrawsToFinish(); - - iFirst->ToggleVisibility(); - iSecond->ToggleVisibility(); - - TheClient->Flush(); - TheClient->WaitForRedrawsToFinish(); - - iFirst->AdjustSize(200,10, 0); - iSecond->AdjustSize(200,10, 0); - - iFirst->ToggleVisibility(); - iSecond->ToggleVisibility(); - - TheClient->Flush(); - TheClient->WaitForRedrawsToFinish(); - - return KErrNone; - } - - -// This function tests setting the transparency via a factor, CFbsBitmap -// or a CWsBitmap, and changing from one to the other. -TInt COomTranspWindow::SetTransparencyTesting() - { - TInt res; - TLogMessageText buf; - - // Need all nine transitions, from the 3 ways to the same 3 ways. - // The ways are Factor, CWsBitmap, CFbsBitmap - const TRgb KTransparencyFactor(128,128,128); - res=iFirst->Win()->SetTransparencyFactor(KTransparencyFactor); - if (res!=KErrNone) - { - buf=_L("test failure!! with SetTransparencyFactor -1"); - TheClient->LogMessage(buf); - return res; - } - - res=iFirst->Win()->SetTransparencyBitmap(*iFbsBitmap); - if (res!=KErrNone) - { - buf=_L("test failure!! with SetTransparencyBitmap - fbs -2"); - TheClient->LogMessage(buf); - return res; - } - - res=iFirst->Win()->SetTransparencyWsBitmap(*iWsBitmap); - if (res!=KErrNone) - { - buf=_L("test failure!! with SetTransparencyBitmap - Ws -3"); - TheClient->LogMessage(buf); - return res; - } - - res=iFirst->Win()->SetTransparencyFactor(KTransparencyFactor); - if (res!=KErrNone) - { - buf=_L("test failure!! with SetTransparencyBitmap - fbs -4"); - TheClient->LogMessage(buf); - return res; - } - res=iFirst->Win()->SetTransparencyWsBitmap(*iWsBitmap); - if (res!=KErrNone) - { - buf=_L("test failure!! with SetTransparencyBitmap - Ws -5"); - TheClient->LogMessage(buf); - return res; - } - res=iFirst->Win()->SetTransparencyWsBitmap(*iWsBitmap); - if (res!=KErrNone) - { - buf=_L("test failure!! with SetTransparencyBitmap - Ws -6"); - TheClient->LogMessage(buf); - return res; - } - - res=iFirst->Win()->SetTransparencyBitmap(*iFbsBitmap); - if (res!=KErrNone) - { - buf=_L("test failure!! with SetTransparencyBitmap - fbs -7"); - TheClient->LogMessage(buf); - return res; - } - - res=iFirst->Win()->SetTransparencyBitmap(*iFbsBitmap); - if (res!=KErrNone) - { - buf=_L("test failure!! with SetTransparencyBitmap - fbs -8"); - TheClient->LogMessage(buf); - return res; - } - - res=iFirst->Win()->SetTransparencyFactor(KTransparencyFactor); - if (res!=KErrNone) - { - buf=_L("test failure!! with SetTransparencyFactor -9"); - TheClient->LogMessage(buf); - return res; - } - - res=iFirst->Win()->SetTransparencyFactor(KTransparencyFactor); - if (res!=KErrNone) - { - buf=_L("test failure!! with SetTransparencyFactor -10"); - TheClient->LogMessage(buf); - return res; - } - - return res; - } - -void COomTranspWindow::ClearUpL() - { - delete iFirst; - iFirst = NULL; - delete iSecond; - iSecond = NULL; - delete iBackgroundWin; - iBackgroundWin = NULL; - } - -// - -CWindowWithOneLine* CWindowWithOneLine::NewL(CTWinBase& aParent, const TRect& aExtent) - { - CWindowWithOneLine* self = new(ELeave) CWindowWithOneLine; - CleanupStack::PushL(self); - self->ConstructL(aParent); - const TSize screenSize(TheClient->iScreen->SizeInPixels()); - self->SetExtL(aExtent.iTl, aExtent.Size()); - self->AssignGC(*TheClient->iGc); - self->Activate(); - self->DrawNow(); - CleanupStack::Pop(self); - return self; - } - -void CWindowWithOneLine::Draw() - { - iGc->DrawLine(TPoint(0,0), TPoint(Size().iWidth, Size().iHeight)); - } - -// - -COomObscuredWindow::COomObscuredWindow(CTOom *aTest) : COomSetup(aTest) - {} - -TOomTestName COomObscuredWindow::TestName() - { - return(_L("Obscured window")); - } - -TInt COomObscuredWindow::Fail() - { - TRAPD(err, DoFailL()); - return err; - } - - -void COomObscuredWindow::DoFailL() - { -#ifdef __WINS__ - RDebug::Print(_L("COomObscuredWindow::DoFailL - enter")); -#endif - const TRect extent(20, 20, 100, 100); - CBlankWindow* backgroundWindow = new(ELeave) CBlankWindow(TRgb(12, 23, 34)); - CleanupStack::PushL(backgroundWindow); - TDisplayMode mode = EColor16MAP; - backgroundWindow->SetUpL(extent.iTl, extent.Size(), TheClient->iGroup, *TheClient->iGc, &mode); - - CWindowWithOneLine* window = CWindowWithOneLine::NewL(*backgroundWindow, extent); - CleanupStack::PushL(window); -#ifdef __WINS__ - RDebug::Print(_L("COomObscuredWindow - WaitForRedrawsToFinish - 1")); -#endif - TheClient->WaitForRedrawsToFinish(); - - CBlankWindow* obscuringWindow = new(ELeave) CBlankWindow(TRgb(255, 0, 0)); - CleanupStack::PushL(obscuringWindow); - obscuringWindow->SetUpL(extent.iTl, extent.Size(), backgroundWindow, *TheClient->iGc, &mode); - - TheClient->Flush(); -#ifdef __WINS__ - RDebug::Print(_L("COomObscuredWindow - WaitForRedrawsToFinish - 2")); -#endif - TheClient->WaitForRedrawsToFinish(); - - window->Invalidate(); - - for(TInt i = 0; i < 50; i++) - { - RWindow anotherWin(iWs); - User::LeaveIfError(anotherWin.Construct(iWinGroup, 11)); - anotherWin.Close(); - - if(i % 4) - window->Invalidate(); - - TheClient->Flush(); -#ifdef __WINS__ - RDebug::Print(_L("COomObscuredWindow - WaitForRedrawsToFinish - 3 - %d"), i); -#endif - TheClient->WaitForRedrawsToFinish(); - } - - TheClient->Flush(); -#ifdef __WINS__ - RDebug::Print(_L("COomObscuredWindow - WaitForRedrawsToFinish - 4")); -#endif - TheClient->WaitForRedrawsToFinish(); - - CleanupStack::PopAndDestroy(obscuringWindow); - CleanupStack::PopAndDestroy(window); - CleanupStack::PopAndDestroy(backgroundWindow); -#ifdef __WINS__ - RDebug::Print(_L("COomObscuredWindow::DoFailL - exit")); -#endif - } - -void COomObscuredWindow::ClearUpL() - { - } - -// - -CTOom::CTOom(CTestStep* aStep) : CTWsGraphicsBase(aStep) - { - iState = 0; - } - -const TDesC& CTOom::TestName() const - { - _LIT(KTestName,"CTOom"); - return(KTestName()); - } - -void CTOom::DoOomTestL(COomFailBase *aOomTest) - { - //TLogMessageText buf; - TEST(aOomTest!=NULL); - if (aOomTest==NULL) - INFO_PRINTF1(_L("aOomTest - Expected: Not Null, Actual: NULL")); - - TRAPD(ret1,aOomTest->ConstructL()); - TEST(ret1==KErrNone); - if (ret1!=KErrNone) - INFO_PRINTF3(_L("aOomTest->ConstructL() return value - Expected: %d, Actual: %d"), KErrNone, ret1); - - aOomTest->Flush(); - __UHEAP_MARK; -// TInt oldCount=TheClient->iWs.HeapCount(); - for(TInt mode=0;mode<3;mode++) - { - /*buf.Format(_L("OOMTest[%d] Mode=%d"),iState,mode), - TheClient->LogMessage(buf);*/ - TInt successCount=0; - for(TInt count=1;;count++) - { - TInt ret; - aOomTest->PreFail(); - if (mode==0) - TheClient->iWs.HeapSetFail(RHeap::EDeterministic,count); - else if (mode==1) - TheClient->iWs.HeapSetBurstFail(RHeap::EBurstFailNext, count, KMaxTUint16); - else if (mode==3) - { - __UHEAP_SETFAIL(RHeap::EDeterministic,count); //Leavescan will complain about EFailNext, although it isn't a leaving function - } - ret=aOomTest->Fail(); - if (mode==0) - TheClient->iWs.HeapSetFail(RHeap::ENone,0); - else if (mode==1) - TheClient->iWs.HeapSetBurstFail(RHeap::ENone, 0, 0); - else if (mode==2) - { - __UHEAP_RESET; - } - aOomTest->ClearUpL(); //In just 1 case this could leave... - aOomTest->Flush(); - if (ret==KErrNone) - { - if (successCount==10) - break; - successCount++; - } - else - { - /*if (successCount>0) - { - buf.Format(_L("[%d,%d] Count=%d, MaxSuccess=%d"),iState,mode,count,successCount); - TheClient->LogMessage(buf); - }*/ - successCount=0; - /*if (ret!=KErrNoMemory) - { - buf.Format(_L("[%d,%d] Fail, Count=%d, Error=%d"),iState,mode,count,ret); - TheClient->LogMessage(buf); - }*/ - TEST(ret==KErrNoMemory); - if (ret!=KErrNoMemory) - INFO_PRINTF3(_L("aOomTest->Fail() return value - Expected: %d, Actual: %d"), KErrNoMemory, ret); - - } - } - /*buf.Format(_L("[%d,%d] LastCount=%d"),iState,mode,count), - TheClient->LogMessage(buf);*/ - } -// TEST(oldCount>=TheClient->iWs.HeapCount()); - __UHEAP_MARKEND; - delete aOomTest; - /*buf.Format(_L("OOMTest[%d] Finished"),iState); - TheClient->LogMessage(buf);*/ - } - -void CTOom::ConstructL() - { - iShieldWin=RBlankWindow(TheClient->iWs); - User::LeaveIfError(iShieldWin.Construct(*(TheClient->iGroup->GroupWin()),1)); -// iShieldWin.SetOrdinalPosition(0,-1); - iShieldWin.Activate(); - } - -CTOom::~CTOom() - { - iShieldWin.Close(); - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-0124 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Out of memory tests - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Uses deterministic heap failure mode to test WSERV classes against out-of-memory errors. - Sets and unsets deterministic mode using both RWsSession.HeapSetFail() methods and - __UHEAP_SETFAIL/__UHEAP_RESET macros (doing this both client and WSERV threads are tested). - On each step the test creates a failure object and repeatedly asks it to do some work (calling Fail() method). - A failure object is an object which encapsulates some allocation functionality inside it's Fail() method. - The test is performed for 23 different failure objects that do the following: - 1. Creates a wserv session, connects and creates CWsScreenDevice object. - 2. Creates a RWindowGroup object. - 3. Creates a RWindow object. - 4. Creates a RBackedUpWindow object. - 5. Sets the size of previously created backed-up window. - 6. Creates a RBlankWindow object. - 7. Allocates a buffer for storing pointer movements for a previously created backed-up window. - 8. Adds a priority key for a previously created window group. - 9. Requests a capture keys for a previously created window group. - 10. Requests the capture of key-up and key-down events for a previously created window group. - 11. Sets hot key for the session. - 12. Sets the window group's name. - 13. Sends a message to another window group. - 14. Fetches a message. - 15. Enables window group change events and modifier change events. - 16. Copies screen to bitmap. - 17. Creates a sprite. - 18. Creates a pointer cursor. - 19. Creates a graphical context for a previously created screen device. - 20. Draws a polygon. - 21. Creates a screen device handle. - 22. Adds a custom text cursor to the server's list of cursors. - 23. Does nothing if transparency is not enabled. Creates a blank window with - two transparent child-windows. Tests setting the transparency via a factor, CFbsBitmap - or a CWsBitmap, and changing from one to the other. - Changes child-windows' sizes and toggles their visibility. - - -@SYMTestExpectedResults The test checks that the creation failure objects doesn't fail and their's work either causes no errors or causes KErrNoMemory error. -*/ -void CTOom::RunTestCaseL(TInt /*aCurTestCase*/) - { - ((CTOomStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0124")); - if (iState==0) - { - // commented by Anton Golovko, 01.03.2006 while converting to TEF - // the code below prevented the test to do anything. -// if (iTest->IsFullRomL()) -// { -// TestComplete(); -// return; -// } - iOldCount=TheClient->iWs.HeapCount(); - } - else if (iState==sizeof(CreateOomFailTest)/sizeof(CreateOomFailTest[0])) - { - iTest->CloseAllPanicWindows(); - TInt heapCount=TheClient->iWs.HeapCount(); - if (heapCount>iOldCount) - { - TEST(iOldCount>=heapCount-184); //For some uninvestigated reason 184 object get allocated on the server side, partly because of INFO_PRINTF1 - if (iOldCount=heapCount-174 - Expected: %d, Actual: %d"), heapCount-184, iOldCount); - - } - ((CTOomStep*)iStep)->CloseTMSGraphicsStep(); - TestComplete(); - return; - } - DoOomTestL(CreateOomFailTest[iState++](this)); - ((CTOomStep*)iStep)->RecordTestResultL(); - } - - - - -__WS_CONSTRUCT_STEP__(Oom) - diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TOOM.H --- a/windowing/windowserver/tauto/TOOM.H Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,425 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef __TOOM_H__ -#define __TOOM_H__ - -#include -#include -#include "../tlib/testbase.h" -#include "AUTO.H" -#include "TGraphicsHarness.h" - - -typedef TBuf<0x40> TOomTestName; - -class CTOom; - - -class COomFailBase : public CBase - { -public: - COomFailBase(CTOom *aTest); - virtual void ConstructL(); - virtual void PreFail(); - virtual void ClearUpL(); - virtual void Flush(); - virtual TInt Fail()=0; - virtual TOomTestName TestName()=0; -protected: - RWsSession iWs; - CWsScreenDevice* iDummyScreen; - CTOom *iTest; - }; - - -class COomConnect : public COomFailBase - { -public: - COomConnect(CTOom *aTest); - TInt Fail(); - void ClearUpL(); - TOomTestName TestName(); - }; - -class COomSetup : public COomFailBase - { -public: - COomSetup(CTOom *aTest); - ~COomSetup(); - void ConstructL(); -protected: - RWindowGroup iWinGroup; - }; - -class COomWindowGroup : public COomSetup - { -public: - COomWindowGroup(CTOom *aTest); - void ClearUpL(); - TInt Fail(); - TOomTestName TestName(); -private: - RWindowGroup iFailWinGroup; - }; - -class COomWindow : public COomSetup - { -public: - COomWindow(CTOom *aTest); - void ClearUpL(); - TInt Fail(); - TOomTestName TestName(); -private: - RWindow iFailWin; - }; - -class COomBackedUpWindow : public COomSetup - { -public: - COomBackedUpWindow(CTOom *aTest); - void ClearUpL(); - TInt Fail(); - TOomTestName TestName(); -private: - RBackedUpWindow iFailWin; - }; - -class COomBlankWindow : public COomSetup - { -public: - COomBlankWindow(CTOom *aTest); - void ClearUpL(); - TInt Fail(); - TOomTestName TestName(); -private: - RBlankWindow iFailWin; - }; - -class COomGc : public COomSetup - { -public: - COomGc(CTOom *aTest); - ~COomGc(); - void ConstructL(); - void ClearUpL(); - TInt Fail(); - TOomTestName TestName(); -private: - CWsScreenDevice *iScrDev; - CWindowGc *iFailGc; - }; - -class COomPolygon : public COomSetup - { -public: - COomPolygon(CTOom *aTest); - ~COomPolygon(); - void ConstructL(); - void ClearUpL(); - TInt Fail(); - TOomTestName TestName(); -private: - CWsScreenDevice *iScrDev; - RBackedUpWindow iWin; - CWindowGc *iGc; - CArrayFixSeg iPnts; - }; - -class COomScreenDevice : public COomSetup - { -public: - COomScreenDevice(CTOom *aTest); - void ClearUpL(); - TInt Fail(); - TOomTestName TestName(); -private: - CWsScreenDevice *iScrDev; - }; - -class COomBackupResize : public COomSetup - { -public: - COomBackupResize(CTOom *aTest); - ~COomBackupResize(); - void ConstructL(); - void ClearUpL(); - TInt Fail(); - TOomTestName TestName(); -private: - RBackedUpWindow iFailWin; - }; - -class COomPointerBuffer : public COomSetup - { -public: - COomPointerBuffer(CTOom *aTest); - ~COomPointerBuffer(); - void ConstructL(); - void ClearUpL(); - TInt Fail(); - TOomTestName TestName(); -private: - RBackedUpWindow iFailWin; - }; - -class COomPriorityKey : public COomSetup - { -public: - COomPriorityKey(CTOom *aTest); - ~COomPriorityKey(); - void ConstructL(); - void ClearUpL(); - TInt Fail(); - TOomTestName TestName(); - }; - -class COomCaptureKey : public COomSetup - { -public: - COomCaptureKey(CTOom *aTest); - ~COomCaptureKey(); - void ConstructL(); - void ClearUpL(); - TInt Fail(); - TOomTestName TestName(); -private: - TInt32 iCapKey[20]; - TInt iIndex; - }; - -class COomCaptureKeyUpDown : public COomSetup - { -public: - COomCaptureKeyUpDown(CTOom *aTest); - ~COomCaptureKeyUpDown(); - void ConstructL(); - void ClearUpL(); - TInt Fail(); - TOomTestName TestName(); -private: - TInt32 iCapKey[20]; - TInt iIndex; - }; - -class COomHotKey : public COomSetup - { -public: - COomHotKey(CTOom *aTest); - ~COomHotKey(); - void ConstructL(); - void ClearUpL(); - TInt Fail(); - TOomTestName TestName(); - }; - -class COomGroupName : public COomSetup - { -public: - COomGroupName(CTOom *aTest); - ~COomGroupName(); - void ConstructL(); - void ClearUpL(); - TInt Fail(); - TOomTestName TestName(); - }; - -class COomMessageSend: public COomSetup - { -public: - COomMessageSend(CTOom *aTest); - ~COomMessageSend(); - void ConstructL(); - void PreFail(); - void ClearUpL(); - TInt Fail(); - TOomTestName TestName(); -private: - RWindowGroup iWinGroup2; - }; - -class COomMessageFetch: public COomSetup - { -public: - COomMessageFetch(CTOom *aTest); - ~COomMessageFetch(); - void PreFail(); - void ConstructL(); - void ClearUpL(); - TInt Fail(); - TOomTestName TestName(); -private: - RWindowGroup iWinGroup2; - }; - -class COomCopyScreen : public COomSetup - { -public: - COomCopyScreen(CTOom *aTest); - ~COomCopyScreen(); - void ConstructL(); - void ClearUpL(); - TInt Fail(); - TOomTestName TestName(); -private: - CWsScreenDevice *iScrDev; - CFbsBitmap *iBitmap; - }; - -class COomRequestEvents : public COomSetup - { -public: - COomRequestEvents(CTOom *aTest); - ~COomRequestEvents(); - void ConstructL(); - void ClearUpL(); - TInt Fail(); - TOomTestName TestName(); - }; - -class COomSpriteBase : public COomSetup - { -public: - COomSpriteBase(CTOom *aTest); - ~COomSpriteBase(); - void ConstructL(); -protected: - RWindow iWin; - CFbsBitmap *iBitmap; - CFbsBitmap *iMask; - CFbsBitmap *iBitmap2; - CFbsBitmap *iMask2; - }; - -class COomSprite : public COomSpriteBase - { -public: - COomSprite(CTOom *aTest); - void ClearUpL(); - TInt Fail(); - TOomTestName TestName(); -private: - RWsSprite iSprite; - }; - -class COomPointerCursor : public COomSpriteBase - { -public: - COomPointerCursor(CTOom *aTest); - void ClearUpL(); - TInt Fail(); - TOomTestName TestName(); -private: - RWsPointerCursor iPointerCursor; - }; - -class COomCustomTextCursor : public COomSetup - { -public: - COomCustomTextCursor(CTOom *aTest); - ~COomCustomTextCursor(); - void ConstructL(); - void ClearUpL(); - TInt Fail(); - TOomTestName TestName(); -private: - CArrayFixFlat* iMemberArray; - CFbsBitmap* iBitmap; - }; - -class COomTranspWindow : public COomSetup - { -public: - COomTranspWindow(CTOom *aTest); - ~COomTranspWindow(); - void ConstructL(); - void ClearUpL(); - TInt Fail(); - TOomTestName TestName(); - CTransWindow* CreateTransWinL(CTWinBase* aParent,TRgb aColor,TRect aPos, TDisplayMode* aDisplayMode); -private: - TInt SetTransparencyTesting(); - - CBlankWindow* iBackgroundWin; - CTransWindow* iFirst; - CTransWindow* iSecond; - - CFbsBitmap* iFbsBitmap; - CWsBitmap* iWsBitmap; - CFbsBitmapDevice* iFbsBitmapDevice; - CFbsBitGc* iFbsBitmapGc; - CFbsBitmapDevice* iWsBitmapDevice; - CFbsBitGc* iWsBitmapGc; - TBool iTransparencyEnabled; - }; - - -class CWindowWithOneLine : public CTWin - { -public: - static CWindowWithOneLine* NewL(CTWinBase& aParent, const TRect& aExtent); - void Draw(); - }; - -class COomObscuredWindow : public COomSetup - { -public: - COomObscuredWindow(CTOom *aTest); - void ClearUpL(); - TInt Fail(); - TOomTestName TestName(); -private: - void DoFailL(); - }; - -class CTOom : public CTWsGraphicsBase - { -public: - CTOom(CTestStep* aStep); - ~CTOom(); - const TDesC& TestName() const; - void ConstructL(); - void DoOomTestL(COomFailBase *aOomTest); - inline TInt ScreenNumber(){ return iTest->ScreenNumber();} - -protected: - virtual void RunTestCaseL(TInt aCurTestCase); - -private: - TInt iOldCount; - RBlankWindow iShieldWin; - TSize iWinSize; - TInt iState; - }; - -class CTOomStep : public CTGraphicsStep - { -public: - CTOomStep(); -protected: - //from CTGraphicsStep - virtual CTGraphicsBase* CreateTestL(); - }; - -_LIT(KTOomStep,"TOom"); - - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TOOMDRAW.CPP --- a/windowing/windowserver/tauto/TOOMDRAW.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,244 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Test out of memory redraws -// -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include "TOOMDRAW.H" - -void DrawTestScreen(CWindowGc *aGc, const TSize &aSize) - { - aGc->SetPenSize(TSize(10,10)); - aGc->SetBrushStyle(CGraphicsContext::EVerticalHatchBrush); - aGc->DrawRect(TRect(aSize)); - } - -CTestWin::CTestWin() - { - } - -void CTestWin::Draw() - { -#if defined(FULLLOGGING) - _LIT(KLog,"Drawing Test Win:%d %d,%d"); - TLogMessageText buf; - buf.Format(KLog,Size().iWidth>320?1:0,Size().iWidth,Size().iHeight); - TheClient->LogMessage(buf); -#endif - DrawTestScreen(iGc,Size()); - } - -CBaseTestWin::CBaseTestWin() : CTBackedUpWin(EGray4) - {} - -void CBaseTestWin::Resized(const TSize &aNewSize) - { - TheGc->Activate(*DrawableWin()); - DrawTestScreen(TheGc,aNewSize); - TheGc->Deactivate(); - } - -CToomDraw::CToomDraw(CTestStep* aStep): - CTWsGraphicsBase(aStep) - { - } - -CToomDraw::~CToomDraw() - { - TheClient->iWs.HeapSetFail(RHeap::ENone,0); //In case the test crashes and it hasn't been reset - DeleteWindows(); - } - -void CToomDraw::DeleteWindows() - { - delete iTestWin; - iTestWin=NULL; - delete iBaseWin; - iBaseWin=NULL; - delete iBackWin; - iBackWin=NULL; - delete iBlankWin; - iBlankWin=NULL; - } - -void CToomDraw::ConstructL() - { - iScrSize=TheClient->iScreen->SizeInPixels(); - iBlankWin=new(ELeave) CTBlankWindow; - iBlankWin->ConstructL(*TheClient->iGroup); - iBlankWin->SetColor(TRgb::Gray4(2)); //Grey - iBlankWin->Activate(); - iBackWin=new(ELeave) CTestWin(); - iBackWin->SetUpL(TPoint(0,iScrSize.iHeight/4), TSize(iScrSize.iWidth,iScrSize.iHeight/2), TheClient->iGroup, *TheClient->iGc); - iBaseWin=new(ELeave) CBaseTestWin(); - iBaseWin->SetUpL(TPoint(iScrSize.iWidth*2/3,0), TSize(iScrSize.iWidth/3,iScrSize.iHeight), TheClient->iGroup, *TheClient->iGc); - } - -void CToomDraw::CreateTestWinL() - { - iTestWin=new(ELeave) CTestWin(); - iTestWin->ConstructL(*TheClient->iGroup); - iTestWin->SetExtL(TPoint(0,0), TSize(iScrSize.iWidth/3,iScrSize.iHeight)); - iTestWin->AssignGC(*TheClient->iGc); - iTestWin->BaseWin()->SetShadowHeight(2); - } - -void CToomDraw::TriggerOomDrawsL(TInt aCount) - { - if(iTestWin) - { - iTestWin->SetExtL(TPoint(),iScrSize); - } - delete iTestWin; - iTestWin=NULL; - CreateTestWinL(); - TheClient->iWs.HeapSetFail(RHeap::EDeterministic,aCount); - iTestWin->Activate(); - TheClient->iWs.Finish(); - } - -TBool CToomDraw::CheckWindowsL() - { - TLogMessageText buf; - TBool pass = DoCheckRect(iTestWin,iBaseWin); - if (pass) - { - TEST(ETrue); //Adds one to test count - #if defined(FULLLOGGING) - _LIT(KLog,"OOM Draw Test Pass, State=%d"); - buf.Format(KLog,iState); - #endif - iRetryCount=0; - } - else - { - if (iRetryCount==4) - { - if ((iTest->RedrawStoreTypeL()==EPartialRedraw_PreserveStoredCmds || - iTest->RedrawStoreTypeL()==EPartialRedraw_FullRedrawSupport) && (iState==19 || iState==30) || - ((iState>=2 && iState<=6) && (iTest->RedrawStoreTypeL()==EPartialRedraw_None || iTest->RedrawStoreTypeL()==EPartialRedraw_FullRedrawSupport))) - { - #if defined(FULLLOGGING) - _LIT(KLog,"OOM Draw Test Known F a i l, State=%d"); - buf.Format(KLog,iState); - #endif - pass=ETrue; - } - else - { - if (iFailAt==0) - iFailAt=iState; - ++iFails; //mark this test as failed - #if defined(LOGGING) - _LIT(KLog,"OOM Draw Test FAIL, State=%d <------- FAIL"); - buf.Format(KLog,iState); - #endif - ++iState; //and advance to next test - } - iRetryCount=0; - } - else - { - #if defined(FULLLOGGING) - _LIT(KLog,"OOM Draw Test F a i l, State=%d retrying"); - buf.Format(KLog,iState); - #endif - if (++iRetryCount%2==0) - iBackWin->DrawNow(); - } - } - if (buf.Length()>0) - TheClient->LogMessage(buf); - return pass; - } - -void CToomDraw::RunTestCaseL(TInt aCurTestCase) - { - TBool testFinished = false; - ((CToomDrawStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); - switch(aCurTestCase) - { -/** -@SYMTestCaseID GRAPHICS-WSERV-0110 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test trying to draw when out of memory - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Set out of memory and try drawing - -@SYMTestExpectedResults Out of memory drawing is handle correctly -*/ - case 1: - ((CToomDrawStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0110")); - while (!testFinished) - { - if (iDoCheck) - { - TheClient->iWs.HeapSetFail(RHeap::ENone,0); - TheClient->WaitForRedrawsToFinish(); - if (CheckWindowsL()) - { - ++iState; - if (iState==EMaxOOMState) - DeleteWindows(); - } - iDoCheck=EFalse; - TheClient->iWs.Finish(); - } - else - { - if (iState==EMaxOOMState) - { - if (iFails>0) - { - #if defined(LOGING) - _LIT(KLog,"OOM Draw Test Failed, First Fail At %d, Number of Fails %d"); - TLogMessageText buf; - buf.Format(KLog,iFailAt,iFails); - TheClient->LogMessage(buf); - #endif - TEST(iFails==0); - } - User::After(500000); // Let the rest of the world catch up after OOM death - testFinished = true; - } - else if (iState < 3 && iTest->IsFullRomL()) - testFinished = true; - else - TriggerOomDrawsL(iState); - iDoCheck=ETrue; - } - } - break; - case 2: - ((CToomDrawStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - ((CToomDrawStep*)iStep)->CloseTMSGraphicsStep(); - TestComplete(); - break; - } - ((CToomDrawStep*)iStep)->RecordTestResultL(); - } - -__WS_CONSTRUCT_STEP__(oomDraw) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TOOMDRAW.H --- a/windowing/windowserver/tauto/TOOMDRAW.H Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,90 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef __TOOMDRAW_H__ -#define __TOOMDRAW_H__ - -#include -#include -#include "../tlib/testbase.h" -#include "AUTO.H" -#include "TGraphicsHarness.h" - -#define LOGGING yes //Log only failures -#if defined(LOGGING) - #define FULLLOGGING yes -#endif - -class CTestWin : public CTWin - { -public: - CTestWin(); - void Draw(); - }; - -class CBaseTestWin : public CTBackedUpWin - { -public: - CBaseTestWin(); - void Resized(const TSize &aNewSize); - }; - -class CToomDraw : public CTWsGraphicsBase - { -private: - enum {EMaxOOMState=150}; -public: - CToomDraw(CTestStep* aStep); - ~CToomDraw(); - void ConstructL(); - void CreateTestWinL(); - void TriggerOomDrawsL(TInt aCount); - TBool CheckWindowsL(); - void DeleteWindows(); -protected: -//from CTGraphicsStep - virtual void RunTestCaseL(TInt aCurTestCase); -private: - TBool iDoCheck; - TSize iScrSize; - CTBlankWindow* iBlankWin; - CTestWin *iTestWin; - CBaseTestWin *iBaseWin; - CTestWin *iBackWin; - TInt iFails; - TInt iFailAt; - TInt iRetryCount; - TInt iState; - }; - -class CToomDrawStep : public CTGraphicsStep - { -public: - CToomDrawStep(); -protected: - //from CTGraphicsStep - virtual CTGraphicsBase* CreateTestL(); - }; - -_LIT(KToomDrawStep,"TOOMDRAW"); - - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TORDINAL.CPP --- a/windowing/windowserver/tauto/TORDINAL.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,579 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// ORDINAL.CPP -// Test ordinal position and priority changes on windows -// -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include "TORDINAL.H" - -_LIT(KLogNextSibling,"NextSibling of iChild%d is not iChild%d"); -_LIT(KLogNoNextSibling,"iChild%d has a NextSibling when it shouldn't"); -_LIT(KLogPrevSibling,"PrevSibling of iChild%d is not iChild%d"); -_LIT(KLogNoPrevSibling,"iChild%d has a PrevSibling when it shouldn't"); - -CTOrdinal::CTOrdinal(CTestStep* aStep): - CTWsGraphicsBase(aStep) - { - } - -COrdinalWindowBase::COrdinalWindowBase(CTClient *aClient, CTestBase* aTest, CTestStep* aTestStep) : iClient(aClient), iTest(aTest), iTestStep(aTestStep) - { - } - -COrdinalWindow::COrdinalWindow(CTClient *aClient, CTestBase* aTest, CTestStep* aTestStep) : COrdinalWindowBase(aClient, aTest, aTestStep), iClientWin(aClient->iWs) - { - __DECLARE_NAME(_S("COrdinalWindow")); - } - -COrdinalWindowGroup::COrdinalWindowGroup(CTClient *aClient, CTestBase* aTest, CTestStep* aTestStep) : COrdinalWindowBase(aClient, aTest, aTestStep), iGroupWin(aClient->iWs) - { - __DECLARE_NAME(_S("COrdinalWindowGroup")); - } - -COrdinalWindowBase::~COrdinalWindowBase() - { - if (iWin) - iWin->Close(); - } - -void COrdinalWindowBase::Draw() - {} - -inline RWindowTreeNode* COrdinalWindowBase::WinTreeNode() - { - return(iWin); - } - -inline TUint32 COrdinalWindowBase::Handle() - { - return reinterpret_cast(this); - } - -COrdinalWindowBase *COrdinalWindowGroup::NewL(CTClient *aClient, CTestBase* aTest, CTestStep* aTestStep) - { - COrdinalWindowGroup *oWin=new(ELeave) COrdinalWindowGroup(aClient, aTest, aTestStep); - TInt err=oWin->iGroupWin.Construct((TUint32)oWin); - if (err<0) - { - delete oWin; - User::Leave(err); - } - oWin->iWin= &oWin->iGroupWin; - return(oWin); - } - -COrdinalWindowBase *COrdinalWindow::NewL(CTClient* aClient, RWindowTreeNode* aParent, CTestBase* aTest, CTestStep* aTestStep) - { - COrdinalWindow *oWin=new(ELeave) COrdinalWindow(aClient, aTest, aTestStep); - TInt err=oWin->iClientWin.Construct(*aParent,(TUint32)oWin); - if (err!=KErrNone) - { - delete oWin; - User::Leave(err); - } - oWin->iClientWin.Activate(); - oWin->iWin= &oWin->iClientWin; - return(oWin); - } - -TInt COrdinalWindowBase::OrdinalPosition() - { - return(iWin->OrdinalPosition()); - } - -void COrdinalWindowBase::SetOrdinalPosition(TInt aPos) - { - iWin->SetOrdinalPosition(aPos); - } - -void COrdinalWindowBase::SetOrdinalPosition(TInt aPos,TInt aPri) - { - iWin->SetOrdinalPosition(aPos,aPri); - } - -CTOrdinal::~CTOrdinal() - { - delete iClient; - } - -void DZ(COrdinalWindowBase * &aX) - { - delete aX; - aX=NULL; - } - -void CTOrdinal::DestroyWindows() - { - DZ(iParent); - DZ(iParent2); - DZ(iParent3); - for(TInt child=0;childTEST(iWin->OrdinalPosition()==aTestPos); - } - -void COrdinalWindowBase::SetAndTestOP(TInt aPos,TInt aTestPos) - { - iWin->SetOrdinalPosition(aPos); - iTestStep->TEST(iWin->OrdinalPosition()==aTestPos); - } - -void COrdinalWindowBase::SetAndTestOP(TInt aPos) - { - SetAndTestOP(aPos, aPos); - } - -TInt COrdinalWindowBase::SetToLastAndGetOP() - { - iWin->SetOrdinalPosition(-1); - return(iWin->OrdinalPosition()); - } - -TInt COrdinalWindowBase::SetToLastAndGetOPPri(TInt aPri) - { - iWin->SetOrdinalPosition(-1, aPri); - return(iWin->OrdinalPosition()); - } - -void COrdinalWindowBase::SetAndTestOPPri(TInt aPos,TInt aPri,TInt aTestPos) - { - iWin->SetOrdinalPosition(aPos,aPri); - iTestStep->TEST(iWin->OrdinalPosition()==aTestPos); - iTestStep->TEST(iWin->OrdinalPriority()==aPri); - } - -void COrdinalWindowBase::SetAndTestOPPri(TInt aPos,TInt aPri) - { - SetAndTestOPPri(aPos,aPri,aPos); - } - -inline COrdinalWindowBase* COrdinalWindowBase::NextSibling() const - { - return reinterpret_cast(iWin->NextSibling()); - } - -inline COrdinalWindowBase* COrdinalWindowBase::PrevSibling() const - { - return reinterpret_cast(iWin->PrevSibling()); - } - -void CTOrdinal::TestWindowOrderNext(TInt aBefore,TInt aAfter) - { - TInt retVal=(iChild[aBefore]->NextSibling()==iChild[aAfter]); - TEST(retVal); - if (!retVal) - LOG_MESSAGE3(KLogNextSibling,aBefore,aAfter); - } - -void CTOrdinal::TestWindowOrderNext(TInt aLast) - { - TInt retVal=(iChild[aLast]->NextSibling()==0); - TEST(retVal); - if (!retVal) - LOG_MESSAGE2(KLogNoNextSibling,aLast); - } - -void CTOrdinal::TestWindowOrderPrev(TInt aAfter,TInt aBefore) - { - TInt retVal=(iChild[aAfter]->PrevSibling()==iChild[aBefore]); - TEST(retVal); - if (!retVal) - LOG_MESSAGE3(KLogPrevSibling,aAfter,aBefore); - } - -void CTOrdinal::TestWindowOrderPrev(TInt aFirst) - { - TInt retVal=(iChild[aFirst]->PrevSibling()==0); - TEST(retVal); - if (!retVal) - LOG_MESSAGE2(KLogNoPrevSibling,aFirst); - } - -void CTOrdinal::OrdinalPos() - { - TInt last=iChild[0]->SetToLastAndGetOP(); - iChild[0]->SetAndTestOP(0); - iChild[5]->TestOP(5); - iChild[1]->SetAndTestOP(3); - iChild[0]->SetAndTestOP(0); - iChild[0]->SetAndTestOP(-1,last); - iChild[0]->SetAndTestOP(-1000,last); - iChild[0]->SetAndTestOP(2); - iChild[0]->SetAndTestOP(-1000,last); - iChild[0]->SetAndTestOP(0); - for(TInt index=0;index<=5;index++) - iChild[4]->SetAndTestOP(index,index); - iChild[0]->SetAndTestOP(-1,last); - iChild[1]->SetAndTestOP(-1,last); - iChild[2]->SetAndTestOP(-1,last); - iChild[3]->SetAndTestOP(-1,last); - iChild[4]->SetAndTestOP(-1,last); - iChild[5]->SetAndTestOP(-1,last); - TInt child; - for (child=0;childSetToLastAndGetOPPri(12); - iChild[2]->TestOP(last12); - TInt lastKMax=iChild[2]->SetToLastAndGetOPPri(KMaxTInt32); - iChild[2]->TestOP(lastKMax); - TInt last=iChild[2]->SetToLastAndGetOPPri(0); - iChild[2]->TestOP(last); - iChild[2]->SetAndTestOPPri(-1,12,last12); // One and only pri 12 window - iChild[3]->SetAndTestOPPri(-1,KMaxTInt32,lastKMax); // One and only pri KMaxTInt32 window - iChild[1]->SetAndTestOPPri(0,KMaxTInt32); - iChild[5]->SetAndTestOP(-1,last-3); - iChild[1]->TestOP(0); - iChild[0]->SetAndTestOPPri(0,50); - iChild[1]->SetAndTestOPPri(0,50); - iChild[2]->SetAndTestOPPri(0,50); - iChild[3]->SetAndTestOPPri(0,50); - iChild[1]->TestOP(2); - if (iGroupTest) - { - retVal=(reinterpret_cast(iChild[0]->NextSibling())==iClient->iGroup); - TEST(retVal); - if (!retVal) - { - _LIT(KLog,"iChild0 NextSibling is not the main group window"); - LOG_MESSAGE(KLog); - } - retVal=(reinterpret_cast(iClient->iGroup->NextSibling())==iChild[4]); - TEST(retVal); - if (!retVal) - { - _LIT(KLog,"NextSibling of main group window is not iChild4"); - LOG_MESSAGE(KLog); - } - } - else - TestWindowOrderNext(0,4); - TestWindowOrderNext(4,5); - TestWindowOrderNext(5); - iChild[2]->SetAndTestOPPri(5,-1,0); - iChild[3]->SetAndTestOPPri(5,-1,1); - TestWindowOrderNext(5,2); - iChild[0]->SetAndTestOPPri(100000,KMinTInt32,0); - iChild[1]->SetAndTestOPPri(200000,KMinTInt32,1); - iChild[2]->SetAndTestOPPri(300000,KMinTInt32,2); - iChild[5]->SetAndTestOPPri(0,0,0); - iChild[3]->TestOP(0); - iChild[0]->SetAndTestOPPri(0,-1); - iChild[1]->SetAndTestOPPri(0,-1); - iChild[2]->SetAndTestOPPri(0,-1); - iChild[3]->SetAndTestOPPri(0,1); - iChild[4]->SetAndTestOPPri(0,1); - iChild[5]->SetAndTestOPPri(0,1); - TestWindowOrderPrev(0,1); - TestWindowOrderPrev(1,2); - if (iGroupTest) - { - retVal=(reinterpret_cast(iChild[2]->PrevSibling())==iClient->iGroup); - TEST(retVal); - if (!retVal) - { - _LIT(KLog,"iChild2 PrevSibling is not the main group window"); - LOG_MESSAGE(KLog); - } - retVal=(reinterpret_cast(iClient->iGroup->PrevSibling())==iChild[3]); - TEST(retVal); - if (!retVal) - { - _LIT(KLog,"PrevSibling of main group window is not iChild3"); - LOG_MESSAGE(KLog); - } - } - else - TestWindowOrderPrev(2,3); - TestWindowOrderPrev(3,4); - TestWindowOrderPrev(4,5); - TestWindowOrderPrev(5); - } - -void CTOrdinal::ConstructL() - { - iClient=new(ELeave) COrdinalClient(); - iClient->SetScreenNumber(iTest->iScreenNumber); - iClient->ConstructL(); - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-0446 - -@SYMCR CR1164 - -@SYMTestCaseDesc Test ClientHandle function returns right value - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Call this function on windows at various times - -@SYMTestExpectedResults The value set when window was created is returned -*/ -void CTOrdinal::CreateWindowsL(TInt aMode) - { - RWindowTreeNode* parent=NULL; - RWindowTreeNode* base=iClient->iGroup->WinTreeNode(); - TInt errors=0; - - if (base->Child()!=0) - { - _LIT(KErrText,"Main Group Window has children at start of test"); - LOG_MESSAGE(KErrText); - AutoPanic(EAutoPanicGroupWinHasChild); - } - if (base->ClientHandle()!=reinterpret_cast(iClient->iGroup)) - ++errors; - if (base->Parent()!=0) - ++errors; - TEST(errors==0); - if (errors>0) - { - _LIT(KErrText,"Handles of Main Group Window are not as expected"); - LOG_MESSAGE2(KErrText,errors); - } - iGroupTest=EFalse; - switch(aMode) - { - case 3: - iParent=COrdinalWindow::NewL(iClient,base,iTest,iStep); - parent=iParent->WinTreeNode(); - CheckHandlesOnNewWindow(iClient->iGroup,iParent); - break; - case 1: - parent=iClient->iGroup->WinTreeNode(); - break; - case 2: - iParent=COrdinalWindow::NewL(iClient,base,iTest,iStep); - CheckHandlesOnNewWindow(iClient->iGroup,iParent); - iParent2=COrdinalWindow::NewL(iClient,iParent->WinTreeNode(),iTest,iStep); - CheckHandlesOnNewWindow(iParent,iParent2); - iParent3=COrdinalWindow::NewL(iClient,iParent2->WinTreeNode(),iTest,iStep); - parent=iParent3->WinTreeNode(); - CheckHandlesOnNewWindow(iParent2,iParent3); - break; - case 0: - iGroupTest=ETrue; - for (TInt child=ENumChildren-1;child>=0;--child) - iChild[child]=COrdinalWindowGroup::NewL(iClient,iTest,iStep); - CheckHandles(0); - return; - } - for (TInt child=ENumChildren-1;child>=0;--child) - { - iChild[child]=COrdinalWindow::NewL(iClient,parent,iTest,iStep); - if (iChild[child]->Handle()!=parent->Child()) - ++errors; - } - TEST(errors==0); - if (errors>0) - { - _LIT(KErrText,"%d windows were not the first child"); - LOG_MESSAGE2(KErrText,errors); - } - CheckHandles(parent->ClientHandle()); - } - -void CTOrdinal::CheckHandlesOnNewWindow(CTWindowGroup* aParent,COrdinalWindowBase* aWin) - { - TInt errors=0; - if (aParent->WinTreeNode()->Child()!=aWin->Handle()) - ++errors; - if (aWin->WinTreeNode()->Parent()!=reinterpret_cast(aParent)) - ++errors; - CheckHandlesOnNewWindow(errors,aWin); - } - -void CTOrdinal::CheckHandlesOnNewWindow(COrdinalWindowBase* aParent,COrdinalWindowBase* aWin) - { - TInt errors=0; - if (aParent->WinTreeNode()->Child()!=aWin->Handle()) - ++errors; - if (aWin->WinTreeNode()->Parent()!=aParent->Handle()) - ++errors; - CheckHandlesOnNewWindow(errors,aWin); - } - -void CTOrdinal::CheckHandlesOnNewWindow(TInt aErrors,COrdinalWindowBase* aWin) - { - RWindowTreeNode* win=aWin->WinTreeNode(); - if (win->ClientHandle()!=aWin->Handle()) - ++aErrors; - if (win->PrevSibling()!=0) - ++aErrors; - if (win->NextSibling()!=0) - ++aErrors; - if (win->Child()!=0) - ++aErrors; - TEST(aErrors==0); - if (aErrors>0) - { - _LIT(KErrText,"%d errors in handles of newly created window"); - LOG_MESSAGE2(KErrText,aErrors); - } - } - -void CTOrdinal::CheckHandles(TUint aParent) - { - TInt errors=0; - TInt child; - for (child=0;childWinTreeNode()->ClientHandle()!=iChild[child]->Handle()) - ++errors; - } - TEST(errors==0); - if (errors>0) - { - _LIT(KErrText,"%d windows gave wrong client handle"); - LOG_MESSAGE2(KErrText,errors); - errors=0; - } - for (child=0;childWinTreeNode()->Parent()!=aParent) - ++errors; - } - TEST(errors==0); - if (errors>0) - { - _LIT(KErrText,"%d children gave wrong parent handle"); - LOG_MESSAGE2(KErrText,errors); - errors=0; - } - for (child=1;childWinTreeNode()->NextSibling()!=iChild[child]->Handle()) - ++errors; - } - if (iChild[5]->WinTreeNode()->NextSibling()!=0 && !iGroupTest) - ++errors; - TEST(errors==0); - if (errors>0) - { - _LIT(KErrText,"%d windows gave wrong next sibling handle"); - LOG_MESSAGE2(KErrText,errors); - errors=0; - } - if (iChild[0]->WinTreeNode()->PrevSibling()!=0 && !iGroupTest) - ++errors; - for (child=1;childWinTreeNode()->PrevSibling()!=iChild[child-1]->Handle()) - ++errors; - } - TEST(errors==0); - if (errors>0) - { - _LIT(KErrText,"%d windows gave wrong prev sibling handle"); - LOG_MESSAGE2(KErrText,errors); - } - } - -COrdinalClient::COrdinalClient() - { - } - -void COrdinalClient::ConstructL() - { - User::LeaveIfError(iWs.Connect()); - // change to correct screen - // - iScreen = new (ELeave) CWsScreenDevice(iWs); - User::LeaveIfError(iScreen->Construct(iScreenNumber)); - - TheClient->iGroup->WinTreeNode()->SetOrdinalPosition(0,-2000000000); - TheClient->iWs.Flush(); - iGroup=new(ELeave) CTWindowGroup(this); - iGroup->ConstructL(); - } - -COrdinalClient::~COrdinalClient() - { - TheClient->iGroup->WinTreeNode()->SetOrdinalPosition(0,0); - } - -void COrdinalClient::KeyL(const TKeyEvent &,const TTime &) - { - } - -void CTOrdinal::RunTestCaseL(TInt /*aCurTestCase*/) - { - _LIT(KTest1,"Ordinal 1"); - ((CTOrdinalStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); - switch(++iTest->iState) - { -/** -@SYMTestCaseID GRAPHICS-WSERV-0217 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test ordinal position and priority changes on windows - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Set different ordinal positions and priorities on a - number of windows and check they have been set - correctly - -@SYMTestExpectedResults The positions and priorities are set correctly -*/ - case 1: - ((CTOrdinalStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0217")); - iTest->LogSubTest(KTest1); - { - for(TInt index=0;index<4;index++) - { - ((CTOrdinalStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0446")); - CreateWindowsL(index); - ((CTOrdinalStep*)iStep)->RecordTestResultL(); - OrdinalPos(); - OrdinalPriority(); - DestroyWindows(); - } - } - ((CTOrdinalStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0217")); - if (!iStep->TestStepResult() == EPass) - TEST(EFalse); - break; - default: - ((CTOrdinalStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - ((CTOrdinalStep*)iStep)->CloseTMSGraphicsStep(); - TestComplete(); - break; - }; - ((CTOrdinalStep*)iStep)->RecordTestResultL(); - } - -__WS_CONSTRUCT_STEP__(Ordinal) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TORDINAL.H --- a/windowing/windowserver/tauto/TORDINAL.H Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,134 +0,0 @@ - -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef __TORDINAL_H__ -#define __TORDINAL_H__ - -#include -#include -#include "../tlib/testbase.h" -#include "AUTO.H" -#include "TGraphicsHarness.h" - -class CTOrdinal; - -class COrdinalClient : public CTClient - { -public: - COrdinalClient(); - virtual void KeyL(const TKeyEvent &aKey,const TTime &aTime); - virtual void ConstructL(); - ~COrdinalClient(); - }; - -class COrdinalWindowBase : public CBase - { -public: - COrdinalWindowBase(CTClient *aClient, CTestBase* aTest, CTestStep* aTestStep); - ~COrdinalWindowBase(); - TInt OrdinalPosition(); - void SetOrdinalPosition(TInt aPos); - void SetOrdinalPosition(TInt aPos,TInt aPri); - virtual void Draw(); - void TestOP(TInt aTestPos); - TInt SetToLastAndGetOP(); - TInt SetToLastAndGetOPPri(TInt aPri); - void SetAndTestOP(TInt aPos); - void SetAndTestOP(TInt aPos,TInt aTestPos); - void SetAndTestOPPri(TInt aPos,TInt aPri,TInt aTestPos); - void SetAndTestOPPri(TInt aPos,TInt aPri); - inline COrdinalWindowBase* NextSibling() const; - inline COrdinalWindowBase* PrevSibling() const; - inline RWindowTreeNode* WinTreeNode(); - inline TUint32 Handle(); -protected: - RWindowTreeNode* iWin; -private: - CTClient* iClient; - CTestBase* iTest; - CTestStep* iTestStep; - }; - -class COrdinalWindow : public COrdinalWindowBase - { -public: - COrdinalWindow(CTClient *aClient, CTestBase* aTest, CTestStep* aTestStep); - static COrdinalWindowBase *NewL(CTClient *aClient, RWindowTreeNode *parent, CTestBase* aTest, CTestStep* aTestStep); -private: - RWindow iClientWin; - }; - -class COrdinalWindowGroup : public COrdinalWindowBase - { -public: - COrdinalWindowGroup(CTClient *aClient, CTestBase* aTest, CTestStep* aTestStep); - static COrdinalWindowBase *NewL(CTClient *aClient, CTestBase* aTest, CTestStep* aTestStep); -private: - RWindowGroup iGroupWin; - }; - -class CTOrdinal : public CTWsGraphicsBase - { -public: - CTOrdinal(CTestStep* aStep); - ~CTOrdinal(); - void DestroyWindows(); - void OrdinalPos(); - void OrdinalPriority(); - void ConstructL(); - void CreateWindowsL(TInt aMode); -protected: //virtual function from CTGraphicsStep - void RunTestCaseL(TInt aCurTestCase); -private: - void TestWindowOrderNext(TInt aBefore,TInt aAfter); - void TestWindowOrderNext(TInt aLast); - void TestWindowOrderPrev(TInt aAfter,TInt aBefore); - void TestWindowOrderPrev(TInt aFirst); - void CheckHandlesOnNewWindow(CTWindowGroup* aParent,COrdinalWindowBase* aWin); - void CheckHandlesOnNewWindow(COrdinalWindowBase* aParent,COrdinalWindowBase* aWin); - void CheckHandlesOnNewWindow(TInt aErrors,COrdinalWindowBase* aWin); - void CheckHandles(TUint aParent); -private: - enum {ENumChildren=6}; -private: - COrdinalClient* iClient; - TSize iWinSize; - TBool iGroupTest; - COrdinalWindowBase* iParent; - COrdinalWindowBase* iParent2; - COrdinalWindowBase* iParent3; - COrdinalWindowBase* iChild[ENumChildren]; - }; - -class CTOrdinalStep : public CTGraphicsStep - { -public: - CTOrdinalStep(); -protected: - //from CTGraphicsStep - virtual CTGraphicsBase* CreateTestL(); - }; - -_LIT(KTOrdinalStep,"TOrdinal"); - - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TPANIC.CPP --- a/windowing/windowserver/tauto/TPANIC.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2014 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Test various cases of Wserv panicing client apps -// -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include "TPANIC.H" -#include "../tlib/testbase.h" -#include -#define TEST_BITMAP _L("Z:\\WSTEST\\WSAUTOTEST.MBM") - -class RWsSessionHacker : public RWsSession - { -public: - inline RWsBuffer *WsBuffer() const {return(iBuffer);}; - inline TInt PanicItSendReceive(TInt aFunction,const TIpcArgs& aArgs) const {return SendReceive(aFunction,aArgs);}; - inline TInt PanicItSend(TInt aFunction,const TIpcArgs& aArgs) const {return Send(aFunction,aArgs);}; - inline TInt PanicItSendReceive(TInt aFunction) const {return SendReceive(aFunction);}; - inline TInt PanicItSend(TInt aFunction) const {return Send(aFunction);}; - }; - -class RWsBufferHacker // copy of original data structure to access buffer data - { -public: - RWsSession* iSession; - CWsGraphic::CManager* iManager; - TBool iAutoFlush; - TPtr8 iBuf; - RWsBuffer* iNext; - TInt iPreviousHandle; - TInt iBufSize; - TInt iMaxBufSize; - TInt iDirectAcessCount; - RArray iBitmapArray; - TBool iInvalidBitmapArray; - }; - -CTPanic::CTPanic(CTestStep* aStep): - CTWsGraphicsBase(aStep) - { - } - -CTPanic::~CTPanic() - { - } - -LOCAL_C TInt DoDeletedParentTest(TInt aInt, TAny *aScreenNumber) - { - RWsSession ws; - User::LeaveIfError(ws.Connect()); - // point to correct screen - CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws); - User::LeaveIfError(screen->Construct((TInt)aScreenNumber)); - - RWindowGroup group(ws); - User::LeaveIfError(group.Construct(888)); - group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close - switch(aInt) - { - case 1: - RWindow win1(ws); - User::LeaveIfError(win1.Construct(group,1)); - RWindow win2(ws); - User::LeaveIfError(win2.Construct(win1,2)); - win1.Close(); - win2.SetExtent(TPoint(1,2),TSize(3,4)); - break; - } - ws.Flush(); - return(EWsExitReasonBad); - } - -LOCAL_C void ReuseWindow(RWsSession& aWs,RWindowGroup& aGroup,RWindow aCopyWin,RWindow* aPtrWin) - { - aPtrWin->Close(); - RWindow win(aWs); - User::LeaveIfError(win.Construct(aGroup,17)); - aCopyWin.SetExtent(TPoint(1,2),TSize(3,4)); - } - -LOCAL_C void ReuseGroupWindow(RWsSession& aWs,RWindowGroup aCopyWin,RWindowGroup* aPtrWin) - { - aPtrWin->Close(); - RWindowGroup group(aWs); - User::LeaveIfError(group.Construct(889)); - group.EnableReceiptOfFocus(EFalse); - aCopyWin.EnableReceiptOfFocus(EFalse); - } - -LOCAL_C void ReuseSprite(RWsSession& aWs,RWindow& aWin,RWsSprite aCopySprite,RWsSprite* aPtrSprite) - { - aPtrSprite->Close(); - RWsSprite sprite(aWs); - sprite.Construct(aWin,TPoint(0,0),0); - aCopySprite.SetPosition(TPoint(22,22)); - } - -LOCAL_C void ReusePointerCursor(RWsSession& aWs,RWsPointerCursor aCopyCursor,RWsPointerCursor* aPtrCursor) - { - aPtrCursor->Close(); - RWsPointerCursor cursor(aWs); - cursor.Construct(0); - aCopyCursor.Activate(); - } - -LOCAL_C TInt DoHandleReUse(TInt aInt, TAny *aScreenNumber) - { - RWsSession ws; - User::LeaveIfError(ws.Connect()); - CWsScreenDevice *scrdev=new(ELeave) CWsScreenDevice(ws); - scrdev->Construct((TInt)aScreenNumber); - RWindowGroup group(ws); - User::LeaveIfError(group.Construct(888)); - group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close - RWindow win(ws); - User::LeaveIfError(win.Construct(group,1)); - switch(aInt) - { - case 2: //WS_HANDLE_WINDOW - ReuseWindow(ws,group,win,&win); - break; - case 3: //WS_HANDLE_GROUP_WINDOW - ReuseGroupWindow(ws,group,&group); - break; - case 4: //WS_HANDLE_SPRITE - { - RWsSprite sprite(ws); - sprite.Construct(win,TPoint(0,0),0); - ReuseSprite(ws,win,sprite,&sprite); - } - break; - case 5: //WS_HANDLE_POINTER_CURSOR - { - RWsPointerCursor cursor(ws); - cursor.Construct(0); - ReusePointerCursor(ws,cursor,&cursor); - } - break; - } - ws.Flush(); - return(EWsExitReasonBad); - } - -LOCAL_C TInt DoScreenDevicePanicTest(TInt aInt, TAny *aScreenNumber) - { - RWsSession ws; - User::LeaveIfError(ws.Connect()); - - CWsScreenDevice *scrdev=new(ELeave) CWsScreenDevice(ws); - User::LeaveIfError(scrdev->Construct((TInt)aScreenNumber)); - - RWindowGroup group(ws); - User::LeaveIfError(group.Construct(888)); - group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close - RWindow win(ws); - User::LeaveIfError(win.Construct(group, 1)); - win.Activate(); - CFbsBitmap *bitmap=new(ELeave) CFbsBitmap; - switch(aInt) - { - case 1: - scrdev->CopyScreenToBitmap(bitmap); - break; - case 2: - scrdev->CopyScreenToBitmap(bitmap,TRect(0,0,10,10)); - break; - default: - return(EWsExitReasonFinished); - } - ws.Flush(); - return(EWsExitReasonBad); - } - -LOCAL_C TInt DoOpcodeTests(TInt aInt, TAny *aScreenNumber) - { - RWsSession ws; - User::LeaveIfError(ws.Connect()); - - CWsScreenDevice *scrdev=new(ELeave) CWsScreenDevice(ws); - User::LeaveIfError(scrdev->Construct((TInt)aScreenNumber)); - - RWindowGroup group(ws); - User::LeaveIfError(group.Construct(888)); - group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close - RWindow win(ws); - User::LeaveIfError(win.Construct(group, 1)); - win.Activate(); - CWindowGc *gc; - scrdev->CreateContext(gc); - switch(aInt) - { - case 1: - ws.TestWrite(ws.WsHandle(),9999,NULL,0); - break; - case 2: - gc->Activate(win); - win.BeginRedraw(); - ws.TestWrite(gc->WsHandle(),9999,NULL,0); - /* This only panics if the command is processed immediately. If it goes into the redraw - store then it will be unable to panic the client untill an additional buffer has been received, - hence the double flush. - */ - win.EndRedraw(); - ws.Finish(); - win.BeginRedraw(); - win.EndRedraw(); - break; - case 3: - ws.TestWrite(scrdev->WsHandle(),9999,NULL,0); - break; - case 4: - { - CWsBitmap *bitmap=new(ELeave) CWsBitmap(ws); - bitmap->Create(TSize(10,10),EGray4); - ws.TestWrite(bitmap->WsHandle(),9999,NULL,0); - } - break; - case 5: - ws.TestWrite(win.WsHandle(),9999,NULL,0); - break; - case 6: - ws.TestWrite(group.WsHandle(),9999,NULL,0); - break; - case 7: - { - RWsSprite sprite(ws); - sprite.Construct(win,TPoint(0,0),0); - ws.TestWrite(sprite.WsHandle(),9999,NULL,0); - } - break; - default: - return(EWsExitReasonFinished); - } - ws.Flush(); - return(EWsExitReasonBad); - } - -TInt DoGraphicsPanicTest(RWsSession& aWs, RWindow& aRWin, RDrawableWindow* aDrawWin, CWindowGc* aGc, CFbsFont* aFont, TInt aTest, TInt aSubTest, TBool aInRedraw, TBool aNeedsValidating) - { - if (aInRedraw || aNeedsValidating) - { - aRWin.BeginRedraw(); - if (!aInRedraw) - { // TransWin without redraw active needs the begin/end to make the redraw store active - aRWin.EndRedraw(); // or else all graphics will simply be ignored and no panics will occur - } - } - aWs.Flush(); - TRect rect01(0,0,1,1); - TPoint point00; - switch(aTest) - { - case 1: - aGc->UseFont(aFont); - switch(aSubTest) - { - case 0: - { - TWsGcCmdBoxText boxText(rect01,0,CGraphicsContext::ELeft,0,0x800000,1); - aWs.TestWrite(aGc->WsHandle(),EWsGcOpDrawBoxText,&boxText,sizeof(boxText)); - } - break; - case 1: - { - TWsGcCmdDrawText dt(point00,600); - aWs.TestWrite(aGc->WsHandle(),EWsGcOpDrawText,&dt,sizeof(dt)); - } - break; - case 2: - { - TWsGcCmdBoxTextOptimised1 dt(rect01,0,600); - aWs.TestWrite(aGc->WsHandle(),EWsGcOpDrawBoxTextOptimised1,&dt,sizeof(dt)); - } - break; - case 3: - { - TWsGcCmdDrawTextVertical dt(point00,600,EFalse); - aWs.TestWrite(aGc->WsHandle(),EWsGcOpDrawTextVertical,&dt,sizeof(dt)); - } - break; - case 4: - { - TWsGcCmdBoxTextVertical dt(rect01); - dt.length=600; - aWs.TestWrite(aGc->WsHandle(),EWsGcOpDrawBoxTextVertical,&dt,sizeof(dt)); - } - break; - case 5: - return(EWsExitReasonFinished); - } - break; - case 2: - { - TInt opcode=0; - switch(aSubTest) - { - case 0: - opcode=EWsGcOpGdiBlt2; - break; - case 1: - opcode=EWsGcOpGdiWsBlt2; - break; - case 2: - return(EWsExitReasonFinished); - } - TWsGcCmdGdiBlt2 gdiBlit(point00,0xBADBAD); - aWs.TestWrite(aGc->WsHandle(),opcode,&gdiBlit,sizeof(gdiBlit)); - if (aInRedraw) - { // Adding two bad bitmaps to redraw store fbs store causes leave as NULL handles of failed bitmaps clash - gdiBlit.handle=0xBADBAD2; - aWs.TestWrite(aGc->WsHandle(),opcode,&gdiBlit,sizeof(gdiBlit)); - } - } - break; - case 3: - { - const TInt KNumBadBmpModes=3; - const TInt KNumTestsPerOpcode=KNumBadBmpModes*2; - enum {KPanicIndexMasked,KPanicIndexDraw,KPanicIndexAlphaBlend,KPanicIndexMax}; - TInt opcodeMode=aSubTest/KNumTestsPerOpcode; - TInt bmpMode=aSubTest%KNumTestsPerOpcode; - TInt bmp1=0xBADBAD; - TInt bmp2=0xBADBAD; - TInt goodBmp; - TInt opcodeBlt; - TInt opcodeDraw; - if (bmpModeCreate(TSize(10,10),EGray4); - goodBmp=goodBitmap->Handle(); - opcodeBlt=EWsGcOpGdiBltMasked; - opcodeDraw=EWsGcOpDrawBitmapMasked; - } - else - { // These two use a CWsBitmap - CWsBitmap* goodBitmap=new(ELeave) CWsBitmap(aWs); - goodBitmap->Create(TSize(10,10),EGray4); - goodBmp=goodBitmap->WsHandle(); - opcodeBlt=EWsGcOpGdiWsBltMasked; - opcodeDraw=EWsGcOpWsDrawBitmapMasked; - } - switch(bmpMode%KNumBadBmpModes) - { - case 0: - bmp2=goodBmp; - break; - case 1: - bmp1=goodBmp; - break; - case 2: // Leave them both bad - break; - } - switch(opcodeMode) - { - case KPanicIndexMasked: - { - TWsGcCmdBltMasked gdiBlitMasked(point00,bmp1,rect01,bmp2,EFalse); - aWs.TestWrite(aGc->WsHandle(),opcodeBlt,&gdiBlitMasked,sizeof(gdiBlitMasked)); - } - break; - case KPanicIndexDraw: - { - TWsGcCmdDrawBitmapMasked maskedBitmap(rect01,bmp1,rect01,bmp2,EFalse); - aWs.TestWrite(aGc->WsHandle(),opcodeDraw,&maskedBitmap,sizeof(maskedBitmap)); - } - break; - case KPanicIndexAlphaBlend: - { - TWsGcCmdAlphaBlendBitmaps alphaBlend(point00,bmp1,rect01,bmp2,point00); - aWs.TestWrite(aGc->WsHandle(),EWsGcOpGdiAlphaBlendBitmaps,&alphaBlend,sizeof(alphaBlend)); - } - break; - case KPanicIndexMax: - return(EWsExitReasonFinished); - } - } - break; - case 4: - switch(aSubTest) - { - case 0: - { - TWsClCmdCreateBitmap createBitmap; - createBitmap.handle=0xB0D; - aWs.TestWrite(aWs.WsHandle(),EWsClOpCreateBitmap,&createBitmap,sizeof(createBitmap)); - } - break; - case 1: - { - TInt badBrush=0xBADB3054; - aWs.TestWrite(aGc->WsHandle(),EWsGcOpUseBrushPattern,&badBrush,sizeof(badBrush)); - } - break; - case 2: - { - TWsGcCmdDrawBitmap drawBitmap(point00,0xBADBAD); - aWs.TestWrite(aGc->WsHandle(),EWsGcOpDrawBitmap,&drawBitmap,sizeof(drawBitmap)); - } - break; - case 3: - return(EWsExitReasonFinished); - } - break; - case 5: - // test bad opcodes - { - TInt opcode=0; - switch(aSubTest) - { - case 0: - opcode=9999; - break; - case 1: - return(EWsExitReasonFinished); - } - aWs.TestWrite(aGc->WsHandle(),opcode,NULL,0); - } - break; - case 6: - {// Test EWsGcOpDrawPolygon with invalid parameters - // First two times has slightly more points specified than exist in the data - // Third time time has a massive number of points in the header - const TInt KNumTestsPerPolyMode=3; - enum TPanicPolyMode {EPanicPolyModePolygon,EPanicPolyModePolyLine,EPanicPolyModeEnd}; - TInt polyMode=aSubTest/KNumTestsPerPolyMode; - if (polyMode==EPanicPolyModeEnd) - return(EWsExitReasonFinished); - TInt subMode=aSubTest%KNumTestsPerPolyMode; - TInt bufPoints=0; - TInt headerPoints=1; - switch(subMode) - { - case 0: - break; - case 1: - bufPoints=2; - headerPoints=8; - break; - case 2: - bufPoints=2; - headerPoints=999999; - break; - } - TInt bufDataLen=bufPoints*sizeof(TPoint); - if (polyMode==EPanicPolyModePolyLine) - bufDataLen+=sizeof(TWsGcCmdDrawPolyLine); - else - bufDataLen+=sizeof(TWsGcCmdDrawPolygon); - TAny* bufData=User::AllocL(bufDataLen); - TPoint* pointPtr; - TInt opcode; - if (polyMode==EPanicPolyModePolyLine) - { - TWsGcCmdDrawPolyLine* drawPolyline=static_cast(bufData); - drawPolyline->numPoints=headerPoints; - drawPolyline->more=EFalse; - drawPolyline->last=point00; - pointPtr=reinterpret_cast(drawPolyline+1); - opcode=EWsGcOpDrawPolyLine; - } - else - { - TWsGcCmdDrawPolygon* drawPolygon=static_cast(bufData); - drawPolygon->numPoints=headerPoints; - drawPolygon->fillRule=CGraphicsContext::EAlternate; - pointPtr=reinterpret_cast(drawPolygon+1); - opcode=EWsGcOpDrawPolygon; - } - const TPoint* endPtr=pointPtr+bufPoints; - TInt pointPos=0; - while(pointPtrWsHandle(),opcode,bufData,bufDataLen); - aWs.Flush(); // Needs flush to make sure EndRedraw() doesn't make buffer bigger and catch out buf len check - } - break; - case 7: - { - // first sets the index to match the total count - // second sets the index negative - // fourth sends too much data - TWsGcCmdStartSegmentedDrawPolygon startPoly; - startPoly.totalNumPoints=8; - aWs.TestWrite(aGc->WsHandle(),EWsGcOpStartSegmentedDrawPolygon,&startPoly,sizeof(startPoly)); - TInt bufDataLen=sizeof(TWsGcCmdSegmentedDrawPolygonData)+startPoly.totalNumPoints*sizeof(TPoint); - TAny* bufData=User::AllocL(bufDataLen); - TWsGcCmdSegmentedDrawPolygonData* polyData=static_cast(bufData); - polyData->numPoints=1; - polyData->index=0; - switch(aSubTest) - { - case 0: - polyData->index=startPoly.totalNumPoints; - break; - case 1: - polyData->index=-123; - break; - case 2: - polyData->numPoints=startPoly.totalNumPoints+1; - break; - case 3: - return(EWsExitReasonFinished); - } - aWs.TestWrite(aGc->WsHandle(),EWsGcOpSegmentedDrawPolygonData,polyData,bufDataLen); - TWsGcCmdDrawSegmentedPolygon drawit; - drawit.fillRule=CGraphicsContext::EAlternate; - aWs.TestWrite(aGc->WsHandle(),EWsGcOpDrawSegmentedPolygon,&drawit,sizeof(drawit)); - } - break; - case 8: - { - if (aSubTest==1) - return(EWsExitReasonFinished); - // This is a test designed to specificially test polylines still work after the previous - // polyline/polygon tests. One potential defect is they leave the common redraw store gc - // in a bad state still holding part of the poly data and causing a EWservPanicBadPolyData - // panic. - // This test is designed to make sure the drawpolyline call works ok and we reach the bad - // opcode panic instead. - TWsGcCmdStartSegmentedDrawPolygon startPoly; - startPoly.totalNumPoints=2; - aWs.TestWrite(aGc->WsHandle(),EWsGcOpStartSegmentedDrawPolygon,&startPoly,sizeof(startPoly)); - struct - { - TWsGcCmdSegmentedDrawPolygonData iPolyData; - TPoint iPoints[2]; - } polyParams; - polyParams.iPoints[0].iX=1; - polyParams.iPoints[0].iY=1; - polyParams.iPoints[1].iX=2; - polyParams.iPoints[1].iY=2; - - polyParams.iPolyData.numPoints=2; - polyParams.iPolyData.index=0; - aWs.TestWrite(aGc->WsHandle(),EWsGcOpSegmentedDrawPolygonData,&polyParams.iPolyData,sizeof(polyParams)); - TWsGcCmdDrawSegmentedPolygon drawit; - drawit.fillRule=CGraphicsContext::EAlternate; - aWs.TestWrite(aGc->WsHandle(),EWsGcOpDrawSegmentedPolygon,&drawit,sizeof(drawit)); - aWs.TestWrite(aGc->WsHandle(),9999,NULL,0); - } - break; - case 9: - if (aSubTest==1) - return(EWsExitReasonFinished); - aGc->Activate(*aDrawWin); // Double activate - break; - case 10: - if (aSubTest==1) - return(EWsExitReasonFinished); - aGc->DrawText(_L("No font"),point00); - break; - case 11: - if (aSubTest==1) - return(EWsExitReasonFinished); - aGc->SetBrushStyle(CGraphicsContext::EPatternedBrush); - aGc->DrawRect(rect01); - break; - case 12: - { - if (aSubTest==1) - return(EWsExitReasonFinished); - aGc->UseFont(aFont); - TPtrC bigAndbad(NULL,5000); // Will go through remote descriptor fetching code - aGc->DrawText(bigAndbad,point00); - } - break; - case 13: - { - if (aSubTest==1) - return(EWsExitReasonFinished); - TInt badHandle=0xDEADBAD; - aWs.TestWrite(aGc->WsHandle(),EWsGcOpUseFont,&badHandle,sizeof(badHandle)); - aGc->DrawText(_L("BOO!"),point00); - } - break; - } - if (aInRedraw) - aRWin.EndRedraw(); - aWs.Finish(); - return(EWsExitReasonBad); - } - -LOCAL_C TInt GraphicsPanicTest(TInt aInt, TAny* aPanicParams) - { - CTPanic::TPanicParams* panicParams=static_cast(aPanicParams); - /* - * Drawing to a transparent window goes via the redraw store. In this - * situation parameters do not get checked during the original processing - * of the incoming graphics commands. They are only caught later when - * playing back from the redraw store. - */ - const TBool useTransWin = panicParams->iRedrawMode==EPanicRedrawModeTransRedraw; - /* - * We always do redraw drawing unless we are using a BackedUpWindow. - * Redraws can affect the way graphics commands are pre-processed, - * as with transparent windows they can also cause commands to get - * buffered in the redraw store and played back later. - */ - const TBool inRedraw = - panicParams->iRedrawMode==EPanicRedrawModeNormalRedraw || - panicParams->iRedrawMode==EPanicRedrawModeTransRedraw || - panicParams->iRedrawMode==EPanicRedrawModeInvisRedraw; - /* - * Drawing to an invisible window skips some of the code where errors - * are caught. Particularly text drawing commands that skip the actual - * drawing, but still process the update of the justification, this - * has the potential of missing parameter checks made during the actual - * drawing, but being caught out when processing the justification update. - */ - const TBool invisWin = panicParams->iRedrawMode==EPanicRedrawModeInvisRedraw; - - RWsSession ws; - User::LeaveIfError(ws.Connect()); - - CWsScreenDevice* scrdev=new(ELeave) CWsScreenDevice(ws); - User::LeaveIfError(scrdev->Construct(panicParams->iScreen)); - - RWindowGroup group(ws); - User::LeaveIfError(group.Construct(888)); - group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close - RDrawableWindow* drawWin; - RWindow rwin(ws); - RBackedUpWindow bwin(ws); - TBool needsValidating=EFalse; - if (useTransWin || inRedraw || invisWin) - { - drawWin=&rwin; - needsValidating=ETrue; - User::LeaveIfError(rwin.Construct(group,1)); - if (useTransWin) - { - rwin.SetTransparencyAlphaChannel(); - } - } - else - { - // EPanicRedrawModeBackedUpWindow case - drawWin=&bwin; - User::LeaveIfError(bwin.Construct(group, EGray4, 1)); - } - const TSize testWinSize(100,100); - User::LeaveIfError(drawWin->SetSizeErr(testWinSize)); - if (invisWin) - drawWin->SetPosition(TPoint(-testWinSize.iWidth,-testWinSize.iHeight)); - drawWin->Activate(); - CWindowGc* gc; - scrdev->CreateContext(gc); - gc->Activate(*drawWin); - CFbsFont* font; - User::LeaveIfError(scrdev->GetNearestFontToDesignHeightInTwips((CFont*&)font,TFontSpec())); - TInt ret=DoGraphicsPanicTest(ws,rwin,drawWin,gc,font,aInt,panicParams->iSubTest,inRedraw,needsValidating); - if (ret!=EWsExitReasonFinished && invisWin) - { - /* - * Some functions are totally skipped on invisible windows, parameter - * errors will be harmlessly ignored in these case. To make the test - * pass we re-do the tests with the window now visible. The purpose - * of the invisible draw tests was not to check the client is always - * panicked doing illegal draws to invisible windows, but to make sure - * they had no harmful side effects. - */ - drawWin->SetPosition(TPoint(0,0)); - gc->Reset(); - ret=DoGraphicsPanicTest(ws,rwin,drawWin,gc,font,aInt,panicParams->iSubTest,inRedraw,needsValidating); - } - return(ret); - } -LOCAL_C TInt DoMiscPanicTest(TInt aSubTest, TAny* ) - { - const TInt KNumPanicFuncsPerMode=EWsClOpLastEnumValue; - const TInt KNumPanicFuncModes=6; - const TInt KNumPanicSendTests=KNumPanicFuncsPerMode*KNumPanicFuncModes; - const TInt KNumRandGarbageTests=500; - if (aSubTest==(KNumPanicSendTests+KNumRandGarbageTests)) - return(EWsExitReasonFinished); - RWsSessionHacker wshacker; - User::LeaveIfError(wshacker.Connect()); - if (aSubTest(0xDEAD),100); - TIpcArgs ipcArgs; - ipcArgs.Set(0,&badDesc); - if (msgFunc&EPanicWservMessAsynchronousService) - { - sendItErr=wshacker.PanicItSend(msgFunc,ipcArgs); - msgFunc&=~EPanicWservMessAsynchronousService; - } - sendItErr=wshacker.PanicItSendReceive(msgFunc,ipcArgs); - } - if (sendItErr==KErrNotSupported) - wshacker.PanicItSendReceive(EWservMessCommandBuffer); // Should always panic - } - else - { - // Fill Wserv buffer with random garbage - RWsBufferHacker* hacker=reinterpret_cast(wshacker.WsBuffer()); - TInt64 seed=aSubTest; - TInt retries=0; - const TInt KMaxRandPanicRetrys=1000; - do - { - const TInt maxLen=hacker->iBuf.MaxLength()-1; - TInt writeLen=1+Math::Rand(seed)%maxLen; - while(writeLen--) - { - TUint8 randData=static_cast(Math::Rand(seed)); - hacker->iBuf.Append(randData); - } - wshacker.Flush(); - retries++; - } while(retriesConstruct((TInt)aScreenNumber)); - - switch(aInt) - { - case 1: - ws.ComputeMode((RWsSession::TComputeMode)543); - break; - } - ws.Flush(); - return(EWsExitReasonBad); - } - -#if defined(_DEBUG) && defined(__WINS__) -LOCAL_C TInt DoCKPanicTest(TInt aInt, TAny *aScreenNumber) - { - RWsSession ws; - User::LeaveIfError(ws.Connect()); - // use correct screen - // - CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws); - User::LeaveIfError(screen->Construct((TInt)aScreenNumber)); - - RWindowGroup group(ws); - group.Construct(888); - group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close - switch(aInt) - { - case 1: - group.CancelCaptureKey(345); - break; - } - ws.Flush(); - return(EWsExitReasonBad); - } -#endif - -LOCAL_C TInt DoEventPanicTest(TInt aInt, TAny *aScreenNumber) - { - RWsSession ws; - User::LeaveIfError(ws.Connect()); - // use correct screen - // - CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws); - User::LeaveIfError(screen->Construct((TInt)aScreenNumber)); - - - switch(aInt) - { - case 1: - TRequestStatus stat; - ws.EventReady(&stat); - ws.EventReady(&stat); - User::After(15000000); //15secs - break; - } - ws.Flush(); - return(EWsExitReasonBad); - } - -LOCAL_C TInt DoTBufPtrTests(TInt aInt, TAny *aScreenNumber) - { - RWsSession ws; - User::LeaveIfError(ws.Connect()); - // use correct screen - // - CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws); - User::LeaveIfError(screen->Construct((TInt)aScreenNumber)); - - switch(aInt) - { - case 1: - { - TWsClCmdLoadAnimDll dt; - dt.length=600; - ws.TestWrite(ws.WsHandle(),EWsClOpCreateAnimDll,&dt,sizeof(dt)); - } - break; - case 2: - { - TInt len=600; - ws.TestWrite(ws.WsHandle(),EWsClOpLogMessage,&len,sizeof(len)); - } - break; - case 3: - { - RWindowGroup group(ws); - group.Construct(888); - group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close - TWsWinCmdSetName dt; - dt.length=600; - dt.ptr=NULL; - ws.TestWrite(group.WsHandle(),EWsWinOpSetName,&dt,sizeof(dt)); - } - break; - case 4: - { - RWindowGroup group(ws); - group.Construct(888); - group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close - TWsWinCmdSetName dt; - dt.length=600; - dt.ptr=(TDesC *)0x1234; - ws.TestWrite(group.WsHandle(),EWsWinOpSetName,&dt,sizeof(dt)); - } - break; - } - ws.Flush(); - return(EWsExitReasonBad); - } - -#if defined(_DEBUG) && defined(__WINS__) -LOCAL_C TInt DoMismatchedCancelCaptureTest(TInt aInt, TAny *aScreenNumber) - { - RWsSession ws; - User::LeaveIfError(ws.Connect()); - // use correct screen - CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws); - User::LeaveIfError(screen->Construct((TInt)aScreenNumber)); - RWindowGroup group(ws); - User::LeaveIfError(group.Construct(888)); - group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close - RWindow win(ws); - User::LeaveIfError(win.Construct(group, 1)); - win.Activate(); - TInt capture; - - switch (aInt) - { - case CTPanic::ECancelCaptureKey: - // Create a capture that is not matched to CancelCaptureKey() - capture = group.CaptureLongKey(' ','a',0,0,2,ELongCaptureNormal); - ws.Flush(); - group.CancelCaptureKey(capture); - break; - case CTPanic::ECancelCaptureKeyUpAndDowns: - // Create a capture that is not matched to CancelCaptureKeyUpAndDowns() - capture = group.CaptureKey('A',0,0); - ws.Flush(); - group.CancelCaptureKeyUpAndDowns(capture); - break; - case CTPanic::ECancelCaptureLongKey: - // Create a capture that is not matched to CancelCaptureLongKey() - capture = group.CaptureKeyUpAndDowns(EStdKeySpace,0,0); - ws.Flush(); - group.CancelCaptureLongKey(capture); - break; - } - - ws.Flush(); - return(EWsExitReasonBad); - } -#endif // _DEBUG - -class ROverrideProtectionInRSessionBase : public RWsSession - { -public: - inline TInt SendReceive(TInt aFunction,TAny *aPtr) const {return(RSessionBase::SendReceive(aFunction,TIpcArgs(aPtr)));}; - }; - -LOCAL_C TInt DoMultiInitPanicTest(TInt , TAny *aScreenNumber) - { - ROverrideProtectionInRSessionBase ws; - User::LeaveIfError(ws.Connect()); - - // use correct screen - // - CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws); - User::LeaveIfError(screen->Construct((TInt)aScreenNumber)); - - RWindowGroup group(ws); - group.Construct(888); - group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close - ws.Flush(); - ws.SendReceive(EWservMessInit,NULL); - - return(EWsExitReasonBad); - } - -LOCAL_C TInt DoSpritePanicTestL(TInt aTest, TAny *aScreenNumber) - { - RWsSession ws; - User::LeaveIfError(ws.Connect()); - // use correct screen - // - CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws); - User::LeaveIfError(screen->Construct((TInt)aScreenNumber)); - - RWindowGroup group(ws); - User::LeaveIfError(group.Construct(889)); - group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close - RBlankWindow win(ws); - User::LeaveIfError(win.Construct(group,898)); - RWsPointerCursor* cursor=(RWsPointerCursor*)&win; - switch (aTest) - { - case 1: - win.SetCustomPointerCursor(*cursor); - break; - case 2: - ws.SetSystemPointerCursor(*cursor,0); - break; - case 3: - { - RAnimDll animDll=RAnimDll(ws); - User::LeaveIfError(animDll.Load(KAnimDLLName)); - RTestAnim anim=RTestAnim(animDll); - RWsSprite* sprite=(RWsSprite*)&win; - User::LeaveIfError(anim.Construct(*sprite,EAnimTypeSprite,TPtrC8())); - } - break; - case 4: - { - CFbsBitmap* bitmap=new(ELeave) CFbsBitmap; - CleanupStack::PushL(bitmap); - User::LeaveIfError(bitmap->Load(TEST_BITMAP_NAME,0)); - win.SetExtent(TPoint(),TSize(150,250)); - win.SetVisible(ETrue); - win.Activate(); - RWsSprite sprite(ws); - User::LeaveIfError(sprite.Construct(win,TPoint(),0)); - TSpriteMember member; - member.iMaskBitmap=NULL; - member.iInvertMask=EFalse; - member.iDrawMode=CGraphicsContext::EDrawModePEN; - member.iOffset=TPoint(); - member.iInterval=TTimeIntervalMicroSeconds32(0); - member.iBitmap=bitmap; - User::LeaveIfError(sprite.AppendMember(member)); - User::LeaveIfError(sprite.Activate()); - User::After(1000000); //1 sec - User::LeaveIfError(bitmap->Resize(bitmap->SizeInPixels() + TSize(200,200))); - User::After(1000000); //1 sec - CleanupStack::Pop(bitmap); - break; - } - } - ws.Flush(); - return(EWsExitReasonBad); - } - -#ifdef __WINS__ -LOCAL_C TInt DoDoubleConstructionTestL(TInt aTest, TAny *aScreenNumber) - { - RWsSession ws; - User::LeaveIfError(ws.Connect()); - - // use correct screen - // - CWsScreenDevice* screen = new(ELeave) CWsScreenDevice(ws); - User::LeaveIfError(screen->Construct((TInt)aScreenNumber)); - - RWindowGroup group(ws); - User::LeaveIfError(group.Construct(890, EFalse)); - RBlankWindow bwin(ws); - User::LeaveIfError(bwin.Construct(group,900)); - - switch (aTest) - { - case 1: - { - RWsSprite sprite = RWsSprite(ws); - User::LeaveIfError(sprite.Construct(bwin,TPoint(),0)); - sprite.Construct(bwin,TPoint(),0); //should panic - sprite.Close(); - } - break; - case 2: - { - RWsPointerCursor cursor(ws); - User::LeaveIfError(cursor.Construct(0)); - cursor.Construct(0); //should panic - cursor.Close(); - } - break; - case 3: - { - RSoundPlugIn click(ws); - User::LeaveIfError(click.Construct()); - click.Construct(); //should panic - click.Close(); - } - break; - case 4: - { - RWindowGroup windowgroup(ws); - User::LeaveIfError(windowgroup.Construct(901)); - windowgroup.Construct(902); //should panic - windowgroup.Close(); - } - break; - case 5: - { - RWindow win(ws); - User::LeaveIfError(win.Construct(group,902)); - win.Construct(group,903); //should panic - win.Close(); - } - break; - case 6: - { - RBlankWindow win(ws); - User::LeaveIfError(win.Construct(group,902)); - win.Construct(group,903); //should panic - win.Close(); - } - break; - case 7: - { - RBackedUpWindow win(ws); - User::LeaveIfError(win.Construct(group,EGray4,902)); - win.Construct(group,EGray4,903); //should panic - win.Close(); - } - break; - case 8: - { - RAnimDll animDll=RAnimDll(ws); - User::LeaveIfError(animDll.Load(KAnimDLLName)); - animDll.Load(KAnimDLLName); //should panic - animDll.Close(); - } - break; - case 9: - { - CWindowGc *gc = new(ELeave) CWindowGc(screen); - User::LeaveIfError(gc->Construct()); - gc->Construct(); //should panic - delete gc; - } - break; - case 10: - { - CWsScreenDevice* screendevice = new (ELeave) CWsScreenDevice(ws); - User::LeaveIfError(screendevice->Construct()); - screendevice->Construct(); //should panic - delete screendevice; - } - break; - default: - break; - } - ws.Flush(); - return(EWsExitReasonBad); - } -#endif - -/** Checks that activating a sprite without members will panic. -*/ -LOCAL_C TInt DoTestSpriteActivatePanicL(TInt aTest, TAny *aScreenNumber) - { - RWsSession ws; - User::LeaveIfError(ws.Connect()); - CWsScreenDevice* screen = new(ELeave) CWsScreenDevice(ws); - User::LeaveIfError(screen->Construct((TInt)aScreenNumber)); - RWindowGroup group(ws); - User::LeaveIfError(group.Construct(891, EFalse, screen)); - RBlankWindow bwin(ws); - User::LeaveIfError(bwin.Construct(group,892)); - - switch(aTest) - { - case 1: - { - RWsSprite sprite = RWsSprite(ws); - User::LeaveIfError(sprite.Construct(group,TPoint(),0)); - sprite.Activate(); //should panic here - sprite.Close(); - } - break; - case 2: - { - RWsSprite sprite = RWsSprite(ws); - User::LeaveIfError(sprite.Construct(bwin,TPoint(),0)); - sprite.Activate(); //should panic here - sprite.Close(); - } - break; - } - return(EWsExitReasonBad); - } - -LOCAL_C TInt DoMoveToGroupPanicTestL(TInt aTest, TAny *aScreenNumber) - { - RWsSession ws; - User::LeaveIfError(ws.Connect()); - // use correct screen - // - CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws); - User::LeaveIfError(screen->Construct((TInt)aScreenNumber)); - - RWindowGroup group(ws); - User::LeaveIfError(group.Construct(887)); - group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close - TInt id=group.Identifier(); - switch (aTest) - { - case 1: - { - RWindowTreeNode* win=&group; - ((RWindowBase*)win)->MoveToGroup(id); - } - break; - case 2: - { - RBlankWindow win1(ws); - User::LeaveIfError(win1.Construct(group,878)); - RBlankWindow win2(ws); - User::LeaveIfError(win2.Construct(win1,788)); - win2.MoveToGroup(id); - } - break; - } - ws.Flush(); - return(EWsExitReasonBad); - } - -LOCAL_C TInt DoGetEventPanicTestL(TInt aTest, TAny *aScreenNumber) - { - RWsSession ws; - User::LeaveIfError(ws.Connect()); - switch(aTest) - { - case 1: - { - TPckgBuf event; - ws.TestWrite(ws.WsHandle(),EWsClOpGetEvent,&event,0); - } - break; - case 2: - { - CWsScreenDevice* screen=new(ELeave) CWsScreenDevice(ws); - User::LeaveIfError(screen->Construct((TInt)aScreenNumber)); - RWindowGroup group(ws); - User::LeaveIfError(group.Construct(555)); // trigger a focus changed event - TRequestStatus stat; - ws.EventReady(&stat); - User::WaitForRequest(stat); - TPtrC8 badDesc(reinterpret_cast(0xDEAD),100); - ws.TestWrite(ws.WsHandle(),EWsClOpGetEvent,&badDesc,0); - } - break; - } - ws.Flush(); - return(EWsExitReasonBad); - } - -LOCAL_C TInt DoWinHandlePanicTestL(TInt aTest, TAny *) - { - RWsSession ws; - User::LeaveIfError(ws.Connect()); - RWindowGroup group1(ws); - RWindowGroup group2(ws); - RWindow win1(ws); - RWindow win2(ws); - switch(aTest) - { - case 1: - User::LeaveIfError(group1.Construct(888)); - User::LeaveIfError(group2.Construct(888)); - break; - case 2: - User::LeaveIfError(group1.Construct(777)); - User::LeaveIfError(win1.Construct(group1,888)); - User::LeaveIfError(win2.Construct(group1,888)); - break; - case 3: - User::LeaveIfError(group1.Construct(777)); - User::LeaveIfError(win1.Construct(group1,777)); - break; - case 4: - User::LeaveIfError(group1.Construct(777)); - User::LeaveIfError(win1.Construct(group1,0)); - break; - } - ws.Flush(); - return(EWsExitReasonBad); - } - -#ifdef __WINS__ -LOCAL_C TInt DoDeleteScreenPanicTestL(TInt aTest, TAny *aScreenNumber) -/** - * Test examples of use of the 'screen device deleted' panic for group windows. - * This is issued to panic the client, if they make API calls to RWindowGroup after having deleted - * the CWsScreenDevice with which that window group is associated. - */ - { - RWsSession ws; - User::LeaveIfError(ws.Connect()); - // point to correct screen - CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws); - User::LeaveIfError(screen->Construct((TInt)aScreenNumber)); - - RWindowGroup group(ws); - User::LeaveIfError(group.Construct(888)); - group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close - switch(aTest) - { - // Test 1: deleting screen then modifying screen change events is illegal - case 1: - { - delete screen, screen=NULL; - group.EnableScreenChangeEvents(); - break; - } - // Test 2: deleting screen then setting window group name is illegal - case 2: - { - delete screen, screen=NULL; - _LIT(KPanicTest, "PanicTest"); - group.SetName(KPanicTest); - break; - } - } - ws.Flush(); - return(EWsExitReasonBad); - } -#endif - -LOCAL_C TInt DoUnInitPanicTest(TInt , TAny *) - { - // Creating a client session outside the test harness for panicking - // before initialisation as the test harness initialises the one it creates. - TVersion version(0,0,0); - _LIT(KServerName, "!Windowserver"); - - RUnInitalisedConnect myUnInit; - - User::LeaveIfError(myUnInit.Connect(KServerName(), version)); - myUnInit.Send(EWservMessCommandBuffer); - - return(EWsExitReasonBad); - } - -void CTPanic::TestScreenDevicePanicsL() - { - TEST(iTest->TestWsPanicL(&DoScreenDevicePanicTest,EWservPanicBitmap,1,(TAny*)iTest->iScreenNumber)); - - TEST(iTest->TestWsPanicL(&DoScreenDevicePanicTest,EWservPanicBitmap,2,(TAny*)iTest->iScreenNumber)); - } - -void CTPanic::TestMiscPanicsL() - { - TBool finished=EFalse; - TInt index=0; - while(!finished) - { - const TBool result = iTest->TestWsPanicL(&DoMiscPanicTest, EWservNoPanic, index, NULL, &finished); - if(!result) - { - INFO_PRINTF2(_L("TestMiscPanicsL %d failed"), index); - TEST(result); - } - index++; - } - } - -void CTPanic::LogHeapInfo() - { - _LIT(KInfoHeapSummary," WsHeap - Count=%d,Total=%d,Free=%d,Max free=%d"); - TPckgBuf heapInfo; - TheClient->iWs.DebugInfo(EWsDebugInfoHeap,heapInfo); - TBuf<256> infoBuf; - infoBuf.Format(KInfoHeapSummary,heapInfo().iCount,heapInfo().iTotal,heapInfo().iAvailable,heapInfo().iLargestAvailable); - INFO_PRINTF1(infoBuf); - } - -void CTPanic::TestGraphicsPanicsL(TClientPanic aExitReason, TInt aIndex, CTPanic::TPanicParams* aPanicParams) - { - TBool finished=EFalse; - aPanicParams->iSubTest=0; - - // uncomment to show which test is being run - INFO_PRINTF3(_L("GraphicsPanicTest %d, mode=%d"),aIndex,aPanicParams->iRedrawMode); - RDebug::Print(_L("GraphicsPanicTest %d, mode=%d"),aIndex,aPanicParams->iRedrawMode); - do - { - // uncomment for detailed view of which sub-test failed - LogHeapInfo(); - INFO_PRINTF4(_L("GraphicsPanicTest %d/%d, mode=%d"),aIndex,aPanicParams->iSubTest,aPanicParams->iRedrawMode); - RDebug::Print(_L("GraphicsPanicTest %d/%d, mode=%d"),aIndex,aPanicParams->iSubTest,aPanicParams->iRedrawMode); - TEST(iTest->TestWsPanicL(&GraphicsPanicTest,aExitReason,aIndex,aPanicParams,&finished)); - aPanicParams->iSubTest++; - } while(!finished); - iTest->CloseAllPanicWindows(); - } - -void CTPanic::TestGraphicsPanicsL(TPanicRedrawMode aRedrawMode) - { - CTPanic::TPanicParams pp; - pp.iScreen=iTest->iScreenNumber; - pp.iRedrawMode=aRedrawMode; - static TClientPanic expectedPanics[]= - { - EWservPanicBufferPtr, - EWservPanicBitmap, - EWservPanicBitmap, - EWservPanicBitmap, - EWservPanicOpcode, - EWservPanicBadPolyData, - EWservPanicBadPolyData, - EWservPanicOpcode, - EWservPanicGcActive, - EWservPanicNoFont, - EWservPanicNoBrush, - EWservPanicDescriptor, - EWservPanicFont, - EWservNoPanic, // Marks the end of the list - }; - TInt panicIndex=0; - TClientPanic expectedPanic; - while((expectedPanic=expectedPanics[panicIndex++])!=EWservNoPanic) - { - TestGraphicsPanicsL(expectedPanic,panicIndex,&pp); - } - } - -void CTPanic::TestGraphicsPanicsL() - { - TestGraphicsPanicsL(EPanicRedrawModeBackedUpWindow); - TestGraphicsPanicsL(EPanicRedrawModeNormalRedraw); - if (TransparencySupportedL()==KErrNone) - { - TestGraphicsPanicsL(EPanicRedrawModeTransRedraw); - } - TestGraphicsPanicsL(EPanicRedrawModeInvisRedraw); - } - -void CTPanic::TestDeletedParentPanicsL() - { - TEST(iTest->TestWsPanicL(&DoDeletedParentTest,EWservPanicParentDeleted,1,(TAny*)iTest->iScreenNumber)); - } - -void CTPanic::TestHandleReUseL() - { - for (TInt ii=2;ii<6;++ii) - { - TEST(iTest->TestWsPanicL(&DoHandleReUse,EWservPanicHandle,ii,(TAny*)iTest->iScreenNumber)); - } - } - -void CTPanic::TestComputeModePanicsL() - { - TEST(iTest->TestWsPanicL(&DoCMPanicTest,EWservPanicSetComputeMode,1,(TAny*)iTest->iScreenNumber)); - } - -void CTPanic::TestCaptureKeyPanicsL() - { -// Run this test in debug on emulator only. -// On a debug ROM the release version of the wserv.exe is included so the test can't be run as no panic happens. -#if defined(_DEBUG) && defined(__WINS__) - TEST(iTest->TestWsPanicL(&DoCKPanicTest,EWservPanicDestroy,1,(TAny*)iTest->iScreenNumber)); -#endif - } - -void CTPanic::TestEventPanicsL() - { - TEST(iTest->TestWsPanicL(&DoEventPanicTest,EWservPanicReadOutstanding,1,(TAny*)iTest->iScreenNumber)); - } - -void CTPanic::TestTPtrPanicsL() - { - TEST(iTest->TestWsPanicL(&DoTBufPtrTests,EWservPanicBufferPtr,1,(TAny*)iTest->iScreenNumber)); - } - -void CTPanic::TestOpcodePanicsL() - { - TInt param=1; - TBool finishTest = EFalse; - while(!finishTest) - { - TEST(iTest->TestWsPanicL(&DoOpcodeTests,EWservPanicOpcode,param,(TAny*)iTest->iScreenNumber,&finishTest)); - param++; - } - } - -void CTPanic::TestMultiInitPanicL() - { - TEST(iTest->TestWsPanicL(&DoMultiInitPanicTest,EWservPanicReInitialise,0,(TAny*)iTest->iScreenNumber)); - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-0472 - -@SYMDEF DEF118618 - -@SYMTestCaseDesc Test defect fixes to system panics - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Check that various defect fixes to system panics are correct. - Also verify that reconstructing a closed object will succeed. - -@SYMTestExpectedResults Panics respond correctly -*/ -void CTPanic::TestDoubleConstructionL() - { -#ifdef __WINS__ - for(TInt test=1;test<11;test++) - { - TEST(iTest->TestW32PanicL(&DoDoubleConstructionTestL,EW32PanicGraphicDoubleConstruction,test,NULL)); - } - TestDoubleConstructionNoPanic(); -#endif - } - -/** Verifies the following scenario is valid: - 1. Create some wserv client-side objects. - 2. Call Close on them. - 3. Reconstruct them and they shouldn't panic this time. */ -void CTPanic::TestDoubleConstructionNoPanic() - { - RWsSession ws; - User::LeaveIfError(ws.Connect()); - - RWindowGroup group(ws); - User::LeaveIfError(group.Construct(890, EFalse)); - RBlankWindow bwin(ws); - User::LeaveIfError(bwin.Construct(group,900)); - - //RWsSprite - RWsSprite sprite(ws); - TEST(KErrNone == sprite.Construct(bwin,TPoint(0,0),0)); - sprite.Close(); - TEST(KErrNone == sprite.Construct(bwin,TPoint(0,0),0)); - sprite.Close(); - - //RWsPointerCursor - RWsPointerCursor cursor(ws); - TEST(KErrNone == cursor.Construct(0)); - cursor.Close(); - TEST(KErrNone == cursor.Construct(0)); - cursor.Close(); - - //RSoundPlugIn - RSoundPlugIn click(ws); - TEST(KErrNone == click.Construct()); - click.Close(); - TEST(KErrNone == click.Construct()); - click.Close(); - - //RWindowGroup - RWindowGroup windowgroup(ws); - TEST(KErrNone ==windowgroup.Construct(901)); - windowgroup.Close(); - TEST(KErrNone ==windowgroup.Construct(901)); - windowgroup.Close(); - - //RWindow - RWindow win1(ws); - TEST(KErrNone == win1.Construct(group,902)); - win1.Close(); - TEST(KErrNone == win1.Construct(group,902)); - win1.Close(); - - //RBlankWindow - RBlankWindow win2(ws); - TEST(KErrNone == win2.Construct(group,902)); - win2.Close(); - TEST(KErrNone == win2.Construct(group,902)); - win2.Close(); - - //RBackedUpWindow - RBackedUpWindow win3(ws); - TEST(KErrNone == win3.Construct(group,EGray4,902)); - win3.Close(); - TEST(KErrNone == win3.Construct(group,EGray4,902)); - win3.Close(); - - //RAnimDll - RAnimDll animDll=RAnimDll(ws); - TEST(KErrNone == animDll.Load(KAnimDLLName)); - animDll.Close(); - TEST(KErrNone == animDll.Load(KAnimDLLName)); - animDll.Close(); - - group.Close(); - bwin.Close(); - ws.Close(); - } - -void CTPanic::TestSpritePanicsL() - { - for(TInt test=1;test<4;test++) - { - TEST(iTest->TestWsPanicL(&DoSpritePanicTestL,EWservPanicSprite,test,(TAny*)iTest->iScreenNumber)); - } - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-0475 - -@SYMDEF DEF118616 - -@SYMTestCaseDesc Test defect fixes to system panics - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Check that various defect fixes to system panics are correct. - -@SYMTestExpectedResults Panics respond correctly -*/ -void CTPanic::TestSpriteActivatePanicL() - { - for(TInt test=1;test<3;test++) - { - TEST(iTest->TestWsPanicL(&DoTestSpriteActivatePanicL,EWservPanicNoSpriteMember,test,NULL)); - } - } - -void CTPanic::TestMoveToGroupPanicsL() - { - TEST(iTest->TestWsPanicL(&DoMoveToGroupPanicTestL,EWservPanicOpcode,1,(TAny*)iTest->iScreenNumber)); - TEST(iTest->TestWsPanicL(&DoMoveToGroupPanicTestL,EWservPanicNotTopClient,2,(TAny*)iTest->iScreenNumber)); - } - -void CTPanic::TestDeleteScreenPanicL() - { -#ifdef __WINS__ - TEST(iTest->TestWsPanicL(&DoDeleteScreenPanicTestL,EWservPanicGroupWinScreenDeviceDeleted,1,(TAny*)iTest->iScreenNumber)); - TEST(iTest->TestWsPanicL(&DoDeleteScreenPanicTestL,EWservPanicGroupWinScreenDeviceDeleted,2,(TAny*)iTest->iScreenNumber)); -#endif - } - -void CTPanic::TestWinHandleErrors() - { -#ifdef __WINS__ - TEST(iTest->TestWsPanicL(&DoWinHandlePanicTestL,EWservPanicDuplicateHandle,1)); - TEST(iTest->TestWsPanicL(&DoWinHandlePanicTestL,EWservPanicDuplicateHandle,2)); - TEST(iTest->TestWsPanicL(&DoWinHandlePanicTestL,EWservPanicDuplicateHandle,3)); -#endif - TEST(iTest->TestWsPanicL(&DoWinHandlePanicTestL,EWservPanicNullHandle,4)); - } - -void CTPanic::TestGetEventErrors() - { - TEST(iTest->TestWsPanicL(&DoGetEventPanicTestL,EWservPanicUnsignalledEventData,1,(TAny*)iTest->iScreenNumber)); - TEST(iTest->TestWsPanicL(&DoGetEventPanicTestL,EWservPanicDescriptor,2,(TAny*)iTest->iScreenNumber)); - } - -void CTPanic::TestUnInitPanicL() - { - TEST(iTest->TestWsPanicL(&DoUnInitPanicTest,EWservPanicUninitialisedClient,0,(TAny*)iTest->iScreenNumber)); - } - -void CTPanic::ConstructL() - { - TheGc->Activate(*BaseWin->Win()); - TheGc->Clear(); - TheGc->SetBrushColor(TRgb::Gray16(12)); - TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - TheGc->SetPenStyle(CGraphicsContext::ENullPen); - TheGc->DrawRect(TRect(BaseWin->Win()->Size())); - TheGc->Deactivate(); - TheGc->Activate(*TestWin->Win()); - TheGc->Clear(); - TheGc->SetBrushColor(TRgb::Gray16(4)); - TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - TheGc->SetPenStyle(CGraphicsContext::ENullPen); - TheGc->DrawRect(TRect(TestWin->Win()->Size())); - TheGc->Deactivate(); -// - _LIT(KReportFullRom,"Warning full ROM, EikSrv present, panic dialogs may interfere with tests"); - _LIT(KReportGoodRom,"ROM OK, No EikSrv present"); - if (iTest->IsFullRomL()) - { - INFO_PRINTF1(KReportFullRom); - } - else - { - INFO_PRINTF1(KReportGoodRom); - } - } - -void CTPanic::TestAlphaBlendingPanicL() - { - INFO_PRINTF1(_L("Masked transparency support has been removed.")); - } - -void CTPanic::TestMismatchedCaptureCancelPanicL() - { -// Run this test in debug on emulator only. -// On a debug ROM the release version of the wserv.exe is included so the test can't be run as no panic happens. -#if defined(_DEBUG) && defined(__WINS__) - TEST(iTest->TestWsPanicL(DoMismatchedCancelCaptureTest,EWservPanicDestroy,ECancelCaptureKey,(TAny*)iTest->iScreenNumber)); - TEST(iTest->TestWsPanicL(DoMismatchedCancelCaptureTest,EWservPanicDestroy,ECancelCaptureKeyUpAndDowns,(TAny*)iTest->iScreenNumber)); - TEST(iTest->TestWsPanicL(DoMismatchedCancelCaptureTest,EWservPanicDestroy,ECancelCaptureLongKey,(TAny*)iTest->iScreenNumber)); -#endif - } - -void CTPanic::RunTestCaseL(TInt /*aCurTestCase*/) - { - ((CTPanicStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); - switch(++iTest->iState) - { -/** -@SYMTestCaseID GRAPHICS-WSERV-0259 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test various system panics - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Check that various system panics respond correctly - -@SYMTestExpectedResults Panics respond correctly -*/ - case 1: - { - ((CTPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0259")); - iTest->LogSubTest(_L("TestCaptureKeyPanicsL")); - TestCaptureKeyPanicsL(); - } - break; - case 2: - { - iTest->LogSubTest(_L("TestEventPanicsL")); - TestEventPanicsL(); - } - break; - case 3: - { - iTest->LogSubTest(_L("TestComputeModePanicsL")); - TestComputeModePanicsL(); - } - break; - case 4: - { -#ifdef __WINS__ -// Only running this under WINS as the tests are a bit excessive, firing off all sorts of illegal -// opcode/flag combinations, as well as buffers of random data. -// Currently on ARM builds they're failing with KErrOutOfMemory, probably running out of handles -// somewhere in the OS. - iTest->LogSubTest(_L("TestMiscPanicsL")); - TestMiscPanicsL(); -#endif - } - break; - case 5: - { - iTest->LogSubTest(_L("TestGraphicsPanicsL")); - TestGraphicsPanicsL(); - } - break; - case 6: - { - iTest->LogSubTest(_L("TestTPtrPanicsL")); - TestTPtrPanicsL(); - } - break; - case 7: - { - iTest->LogSubTest(_L("TestOpcodePanicsL")); - TestOpcodePanicsL(); - } - break; - case 8: - { - iTest->LogSubTest(_L("TestScreenDevicePanicsL")); - TestScreenDevicePanicsL(); - } - break; - case 9: - { - iTest->LogSubTest(_L("TestMultiInitPanicL")); - TestMultiInitPanicL(); - } - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0260 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test various system panics - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Check that various system panics respond correctly - -@SYMTestExpectedResults Panics respond correctly -*/ - case 10: - { - ((CTPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0260")); - iTest->LogSubTest(_L("Panic 2")); - TestSpritePanicsL(); - TestMoveToGroupPanicsL(); - } - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0261 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test defect fixes to system panics - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Check that various defect fixes to system panics are correct - -@SYMTestExpectedResults Panics respond correctly -*/ - case 11: - { - ((CTPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0261")); - _LIT(KPanicTest,"Defect Fixes (Pan.3)"); - iTest->LogSubTest(KPanicTest); - TestDeletedParentPanicsL(); - TestHandleReUseL(); - TestDeleteScreenPanicL(); // DEF069809 - } - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-097969-0001 - -@SYMDEF DEF097969 - -@SYMTestCaseDesc Test defect fixes to system panics - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Check that various defect fixes to system panics are correct - -@SYMTestExpectedResults Panics respond correctly -*/ - case 12: - { - ((CTPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-097969-0001")); - _LIT(KPanicTest,"Server panic defect Fix (Pan.4)"); - iTest->LogSubTest(KPanicTest); - TestUnInitPanicL(); // DEF097969 - } - break; - - case 13: - { -/** -@SYMTestCaseID GRAPHICS-WSERV-0501 -*/ - ((CTPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0501")); - _LIT(KPanicTest,"AlphaBlending Bitmap panic defect Fix (Pan.5)"); - iTest->LogSubTest(KPanicTest); - TestAlphaBlendingPanicL(); // DEF112916 - } - break; - case 14: - { - ((CTPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0472")); - _LIT(KPanicTest,"Double construction panic test"); - iTest->LogSubTest(KPanicTest); - TestDoubleConstructionL(); // DEF118618 - } - break; - case 15: - { - ((CTPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0475")); - _LIT(KPanicTest, "RWsSprite Activate() without members panic test"); - iTest->LogSubTest(KPanicTest); - TestSpriteActivatePanicL(); //DEF118616 - } - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0497 - -@SYMDEF DEF133776 - -@SYMTestCaseDesc Test that a debug only panic occurs when an attempt - is made to cancel a key capture using the wrong cancel capture API. - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Check that calling the each RWindowGroup::CancelCapture***() API - using the handle returned from a mismatched RWindowGroup::Capture***() call causes - a debug only panic. Tests each of the three RWindowGroup::CancelCapture***() APIs. - -@SYMTestExpectedResults Panics respond correctly in debug only. -*/ - case 16: - { - ((CTPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0497")); - _LIT(KPanicTest,"TestMismatchedCaptureCancelPanicL"); - iTest->LogSubTest(KPanicTest); - TestMismatchedCaptureCancelPanicL(); - } - break; -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA - case 17: - { - _LIT(KPanicTest, "Non-Redraw Drawing inside Redrawer Panic Test"); - iTest->LogSubTest(KPanicTest); - TestNonRedrawRedrawerL(); - } -#endif - default: - ((CTPanicStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - ((CTPanicStep*)iStep)->CloseTMSGraphicsStep(); - TestComplete(); - break; - } - ((CTPanicStep*)iStep)->RecordTestResultL(); - } - -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA -LOCAL_C TInt DoTestNonRedrawRedrawerL(TInt /* aInt */, TAny * /* aPtr */) - { - CActiveScheduler* scheduler = new (ELeave) CActiveScheduler(); - CleanupStack::PushL(scheduler); - CActiveScheduler::Install(scheduler); - - RWsSession session; - User::LeaveIfError(session.Connect()); - - CWsScreenDevice *screenDevice = new (ELeave)CWsScreenDevice(session); - User::LeaveIfError(screenDevice->Construct ()); - CWindowGc *gc; - User::LeaveIfError(screenDevice->CreateContext(gc)); - - CNonRedrawWin *nonRedrawWin=CNonRedrawWin::NewL(session, gc); - nonRedrawWin->Invalidate(); - CActiveScheduler::Start(); - User::After(2000000); // so the Redrawer has a chance to run - CActiveScheduler::Stop(); - delete gc; - delete screenDevice; - session.Close(); - CleanupStack::PopAndDestroy(scheduler); - return(EWsExitReasonBad); - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-0121808 -@SYMDEF DEF121808: No more Non-Redraw drawing for NGA (test added during DEF134308) -@SYMTestCaseDesc Test defect fixes to system panics -@SYMTestPriority High -@SYMTestStatus Implemented -@SYMTestActions Check that WServ panics a client which uses Non-Redraw drawing in the Redrawer. -@SYMTestExpectedResults Panics respond correctly -*/ -void CTPanic::TestNonRedrawRedrawerL() - { - TEST(iTest->TestWsPanicL(&DoTestNonRedrawRedrawerL,EWservPanicWindowBeginRedrawNotCalled,NULL,NULL)); - } - -CNonRedrawWin::CRedrawer::CRedrawer(CNonRedrawWin* aWd) : - CActive(CActive::EPriorityStandard), iWd(aWd){ - CActiveScheduler::Add(this); - HandleRedrawEvent(); -} - -CNonRedrawWin::CRedrawer::~CRedrawer(){ - Cancel(); -} - -void CNonRedrawWin::CRedrawer::HandleRedrawEvent(){ - iWd->GetSession().RedrawReady(&iStatus); - SetActive(); -} - -void CNonRedrawWin::CRedrawer::RunL(){ - TWsRedrawEvent redrawEvent; - iWd->GetSession().GetRedraw(redrawEvent); - iWd->Redraw(); - HandleRedrawEvent(); -} - -void CNonRedrawWin::CRedrawer::DoCancel(){ - iWd->GetSession().RedrawReadyCancel(); -} - -CNonRedrawWin* CNonRedrawWin::NewL(RWsSession &aSession, CWindowGc *aGc){ - CNonRedrawWin* self=new(ELeave)CNonRedrawWin(aSession, aGc); - CleanupStack::PushL(self); - self->ConstrucL(); - CleanupStack::Pop(self); - return self; -} - -CNonRedrawWin::CNonRedrawWin(RWsSession &aSession, CWindowGc *aGc): - iSession(aSession), iGc(aGc){} - -CNonRedrawWin::~CNonRedrawWin(){ - delete iRedrawer; - iWd.Close(); - iWdGrp.Close(); -} - -void CNonRedrawWin::Redraw(){ - // This is a Non-Redraw Drawing Redrawer; BeginRedraw()/EndRedraw() - // have been intentionally omitted. - iGc->Activate(iWd); - iGc->SetBrushColor(TRgb(255,0,0)); - iGc->SetPenColor(KRgbBlue); - iGc->SetPenSize(TSize(10,20)); - iGc->DrawRect(TRect(TPoint(10,10),TPoint(50,50))); - iGc->Deactivate(); - iSession.Finish(); -} - -RWsSession &CNonRedrawWin::GetSession(){return iSession;} - -void CNonRedrawWin::Invalidate(){iWd.Invalidate();} - -void CNonRedrawWin::ConstrucL(){ - iWdGrp=RWindowGroup(iSession); - iWdGrp.Construct((TUint32)this,ETrue); - _LIT(KWndGrpName,"NonRedrawWndGrp"); - iWdGrp.SetName(KWndGrpName); - iWd=RWindow(iSession); - iWd.Construct(iWdGrp, 0x101); - User::LeaveIfError(iWd.SetExtentErr(TPoint(0,0),TSize(150,150))); - iWd.SetBackgroundColor(KRgbWhite); - iWd.SetOrdinalPosition(0); - iWd.Activate(); - iRedrawer=new(ELeave) CRedrawer(this); -} -#endif - -TInt RUnInitalisedConnect::Connect(const TDesC &aName, const TVersion &aVersion) - { - return CreateSession(aName, aVersion, 255); - } - -TInt RUnInitalisedConnect::Send(const TInt aMsg) - { - return SendReceive(aMsg); - } - -__WS_CONSTRUCT_STEP__(Panic) -#pragma warning( disable : 4505 ) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TPANIC.H --- a/windowing/windowserver/tauto/TPANIC.H Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,154 +0,0 @@ - -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef __TPANIC_H__ -#define __TPANIC_H__ - -#include -#include -#include "../tlib/testbase.h" -#include "AUTO.H" -#include "AUTODLL.H" -#include "TGraphicsHarness.h" - -enum TPanicRedrawMode - { - EPanicRedrawModeBackedUpWindow, // Draw to a RBackedUpWindow; no BeginRedraw()/EndRedraw() needed - EPanicRedrawModeNormalRedraw, // Draw in a redraw - EPanicRedrawModeTransRedraw, // Draw to a window under a transparent window in a redraw - EPanicRedrawModeInvisRedraw, // Draw to an invisible window in a redraw - }; - -class CTPanic : public CTWsGraphicsBase - { -public: - struct TPanicParams - { - public: - TInt iScreen; - TPanicRedrawMode iRedrawMode; - TInt iSubTest; - }; - - enum TCancelCaptureType - { - ECancelCaptureKey, - ECancelCaptureKeyUpAndDowns, - ECancelCaptureLongKey - }; -public: - CTPanic(CTestStep* aStep); - ~CTPanic(); - void ConstructL(); -private: - void TestDeletedParentPanicsL(); - void TestScreenDevicePanicsL(); - void TestGraphicsPanicsL(TClientPanic aExitReason, TInt aIndex, CTPanic::TPanicParams* aPanicParams); - void TestGraphicsPanicsL(); - void TestGraphicsPanicsL(TPanicRedrawMode aRedrawMode); - void TestMiscPanicsL(); - void TestComputeModePanicsL(); - void TestCaptureKeyPanicsL(); - void TestEventPanicsL(); - void TestTPtrPanicsL(); - void TestOpcodePanicsL(); - void TestMultiInitPanicL(); - void TestSpritePanicsL(); - void TestMoveToGroupPanicsL(); - void TestHandleReUseL(); - void TestDeleteScreenPanicL(); - void TestWinHandleErrors(); - void TestGetEventErrors(); - void TestUnInitPanicL(); - void TestAlphaBlendingPanicL(); - void TestDoubleConstructionL(); - void TestDoubleConstructionNoPanic(); - void TestSpriteActivatePanicL(); -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA - void TestNonRedrawRedrawerL(); -#endif - void TestMismatchedCaptureCancelPanicL(); - void LogHeapInfo(); -protected: -//from CTGraphicsStep - virtual void RunTestCaseL(TInt aCurTestCase); -private: - TSize iWinSize; - }; - -class CTPanicStep : public CTGraphicsStep - { -public: - CTPanicStep(); -protected: - //from CTGraphicsStep - virtual CTGraphicsBase* CreateTestL(); - }; - -_LIT(KTPanicStep,"TPanic"); - -class RUnInitalisedConnect : public RSessionBase - { - public: - TInt Connect(const TDesC &aName, const TVersion &aVersion); - TInt Send(const TInt aMsg); - }; - -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA -class CNonRedrawWin : public CBase{ - public: - ~CNonRedrawWin(); - static CNonRedrawWin* NewL(RWsSession &aSession, CWindowGc *aGc); - virtual void Redraw(); - RWsSession &GetSession(); - void Invalidate(); - - protected: - CNonRedrawWin(RWsSession &aSession, CWindowGc *aGc); - void ConstrucL(); - - class CRedrawer : public CActive{ - public: - CRedrawer(CNonRedrawWin* aWd); - ~CRedrawer(); - private: - void HandleReDrawEvent(); - void RunL(); - void DoCancel(); - void HandleRedrawEvent(); - - private: - CNonRedrawWin* iWd; - }; - - private: - RWsSession &iSession; - RWindowGroup iWdGrp; - RWindow iWd; - CWindowGc *iGc; - - CRedrawer *iRedrawer; - -}; -#endif - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TPNTCAP.CPP --- a/windowing/windowserver/tauto/TPNTCAP.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1014 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Test pointer capture -// -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include "TPNTCAP.H" - -#define LOGGING on - -_LIT(ClickOnMe,"Click on me"); - -// -// CMcConnection - -CPcConnection::CPcConnection(CTPointerCapture *aTest) : iTest(aTest) - { - } - -CPcConnection::~CPcConnection() - { - } - -void CPcConnection::ConstructL() - { - CTClient::SetScreenNumber(iTest->TestBase()->ScreenNumber()); - CTClient::ConstructL(); - iGroup=new(ELeave) CTWindowGroup(this); - iGroup->ConstructL(); - iGroup->GroupWin()->SetOrdinalPosition(0,1); - iGroup->GroupWin()->EnableReceiptOfFocus(EFalse); - iWs.Flush(); - } - -// -// CPcWindow, base class // -// - -CPcWindowBase::CPcWindowBase(CTPointerCapture *aTest) : CTWin(), iTest(aTest) - { - } - -void CPcWindowBase::SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc) - { - ConstructExtLD(*parent,pos,size); - iWin.SetBackgroundColor(iBack); - Activate(); - AssignGC(aGc); - } - -void CPcWindowBase::SetUpL(TPoint pos,TSize size,CTWinBase *parent) - { - SetUpL(pos,size,parent,*iTest->Client()->iGc); - } - -void CPcWindowBase::SubStateChanged() - { - iWin.Invalidate(); - Client()->iWs.Flush(); - } - -void CPcWindowBase::Draw(TDesC &aBuf) - { - iGc->Clear(); - iGc->SetPenColor(iBack.Gray4()>1 ? TRgb(0,0,0) : TRgb(255,255,255)); - iGc->DrawText(aBuf, TPoint(10,20)); - } - -void CPcWindowBase::PointerL(const TPointerEvent &pointer,const TTime &) - { -#if defined(LOGGING) - _LIT(KLog1,"Pointer Event Recieved Type=%S State=%d SubState=%d"); - _LIT(KDown,"Down"); - _LIT(KUp,"Up"); - iTest->LOG_MESSAGE4(KLog1,&(pointer.iType?KUp():KDown()),iTest->State(),iTest->SubState()); -#endif - if (pointer.iType==TPointerEvent::EButton1Down && !iTest->iFailed) - { - if (iTest->SubState()==ERootWindow) // Root window click, must not be inside this window - { - if (TRect(Size()).Contains(pointer.iPosition)) - { - iTest->TestFailed(); - return; - } - } - TInt ret; - if ((ret=PointerDown())==EFailed) - iTest->TestFailed(); - else - iTest->IncSubStateL(ret==ENeedsDDEvent); - } -#if defined(LOGGING) - _LIT(KLog2,"End of processing Pointer Event"); - iTest->LOG_MESSAGE(KLog2); -#endif - } - -void CPcWindowBase::DragDropL(const TPointerEvent &pointer,const TTime &) - { -#if defined(LOGGING) - _LIT(KLog,"CPcWindowBase::DragDropL Type=%d State=%d SubState=%d"); - iTest->LOG_MESSAGE4(KLog,pointer.iType,iTest->State(),iTest->SubState()); -#endif - switch(iTest->State()) - { - case ENormalCaptureWithoutFocus: - if (iTest->SubState()==0) - break; - case ECaptureDisabled: - case ENormalCapture: - case ECaptureAllGroups: - iTest->TestFailed(); - break; - } - if (pointer.iType==TPointerEvent::EButton1Down && !iTest->iFailed) - { - if (DragDrop()==EFailed) - iTest->TestFailed(); - else - iTest->GotDDL(); - } - } -// - -CPcWindowMain::CPcWindowMain(CTPointerCapture *aTest) : CPcWindowBase(aTest) - { - iBack=TRgb::Gray256(236); - } - -TPointerCheckRet CPcWindowMain::PointerDown() - { -#if defined(LOGGING) - _LIT(KLog1,"CPcWindowMain::PointerDown State=%d SubState=%d"); - iTest->LOG_MESSAGE3(KLog1,iTest->State(),iTest->SubState()); -#endif - switch(iTest->State()) - { - case ECaptureDisabled: - if (iTest->SubState()==EMainWindow) - return(EOkay); - break; - case ENormalCapture: - switch(iTest->SubState()) - { - case EMainWindow: - case ERootWindow: - return(EOkay); - default: - break; - } - break; - case ECaptureAllGroups: - switch(iTest->SubState()) - { - case EMainWindow: - case EOtherGroup: - case EOtherSession: - case ERootWindow: - return(EOkay); - default: - break; - } - break; - case EDragDropCapture: - switch(iTest->SubState()) - { - case EMainWindow: - return(ENeedsDDEvent); - case ERootWindow: - return(EOkay); - default: - break; - } - break; - case EDragDropCaptureAllGroups: - switch(iTest->SubState()) - { - case EMainWindow: - case EOtherGroup: - case EOtherSession: - return(ENeedsDDEvent); - case ERootWindow: - return(EOkay); - default: - break; - } - break; - case ENormalCaptureWithoutFocus: - switch(iTest->SubState()) - { - case EMainWindow: - return(EOkay); - default: - break; - } - break; - default: - break; - } -#if defined(LOGGING) - _LIT(KLog2,"CPcWindowMain::PointerDown FAILED State=%d SubState=%d"); - iTest->LOG_MESSAGE3(KLog2,iTest->State(),iTest->SubState()); -#endif - return(EFailed); - } - -TPointerCheckRet CPcWindowMain::DragDrop() - { -#if defined(LOGGING) - _LIT(KLog1,"CPcWindowMain::DragDrop State=%d SubState=%d"); - iTest->LOG_MESSAGE3(KLog1,iTest->State(),iTest->SubState()); -#endif - switch(iTest->State()) - { - case EDragDropCapture: - case EDragDropCaptureAllGroups: - switch(iTest->SubState()) - { - case EMainWindow: - return(EOkay); - default: - break; - } - break; - default: - break; - } -#if defined(LOGGING) - _LIT(KLog2,"CPcWindowMain::DragDrop FAILED State=%d SubState=%d"); - iTest->LOG_MESSAGE3(KLog2,iTest->State(),iTest->SubState()); -#endif - return(EFailed); - } - -void CPcWindowMain::Draw() - { - TBuf<0x40> buf; - if (iTest->State()==ECaptureDisabled) - { - switch(iTest->SubState()) - { - case EMainWindow: - buf.Copy(ClickOnMe); - break; - } - } - else - { - switch(iTest->SubState()) - { - case EMainWindow: - buf.Copy(ClickOnMe); - break; - case EChildWindow: - case EOtherGroup: - case EOtherSession: - break; - case ERootWindow: - { - _LIT(ClickOnRoot,"Click on the root window"); - if (iTest->State()"); - buf.Copy(ClickOnRoot); - buf.Append(AndEscape); - } - } - break; - } - } - CPcWindowBase::Draw(buf); - } - -void CPcWindowMain::WinKeyL(const TKeyEvent &aKey,const TTime &) - { - switch(aKey.iCode) - { - case EKeyEscape: - iTest->AbortTests(); - break; - case EKeyEnter: - if (iTest->SubState()==ERootWindow) - iTest->IncSubStateL(EFalse); - break; - } - } - -// - -CPcWindowChild::CPcWindowChild(CTPointerCapture *aTest) : CPcWindowBase(aTest) - { - iBack=TRgb::Gray256(85); - } - -TPointerCheckRet CPcWindowChild::PointerDown() - { -#if defined(LOGGING) - _LIT(KLog1,"CPcWindowChild::PointerDown State=%d SubState=%d"); - iTest->LOG_MESSAGE3(KLog1,iTest->State(),iTest->SubState()); -#endif - switch(iTest->State()) - { - case ECaptureDisabled: - break; - default: - switch(iTest->SubState()) - { - case EChildWindow: - return(EOkay); - default: - break; - } - break; - } -#if defined(LOGGING) - _LIT(KLog2,"CPcWindowChild::PointerDown FAILED State=%d SubState=%d"); - iTest->LOG_MESSAGE3(KLog2,iTest->State(),iTest->SubState()); -#endif - return(EFailed); - } - -TPointerCheckRet CPcWindowChild::DragDrop() - { -#if defined(LOGGING) - _LIT(KLog1,"CPcWindowChild::PointerDown State=%d SubState=%d"); - iTest->LOG_MESSAGE3(KLog1,iTest->State(),iTest->SubState()); -#endif - switch(iTest->State()) - { - case EDragDropCapture: - case EDragDropCaptureAllGroups: - switch(iTest->SubState()) - { - case EChildWindow: - return(EOkay); - default: - break; - } - break; - default: - break; - } -#if defined(LOGGING) - _LIT(KLog2,"CPcWindowChild::PointerDown FAILED State=%d SubState=%d"); - iTest->LOG_MESSAGE3(KLog2,iTest->State(),iTest->SubState()); -#endif - return(EFailed); - } - -void CPcWindowChild::Draw() - { - TBuf<0x40> buf; - if (iTest->State()!=ECaptureDisabled) - { - switch(iTest->SubState()) - { - case EChildWindow: - buf.Copy(ClickOnMe); - break; - default: - break; - } - } - CPcWindowBase::Draw(buf); - } - -// - -CPcWindowNickFocusGroup::CPcWindowNickFocusGroup(CTPointerCapture *aTest, CTClient *aClient) : CTWindowGroup(aClient), iTest(aTest) - { - } - -void CPcWindowNickFocusGroup::KeyL(const TKeyEvent &aKey,const TTime &) - { - if (aKey.iCode==EKeyEscape) - iTest->IncSubStateL(EFalse); - } - -// - -CPcWindowAltGroup::CPcWindowAltGroup(CTPointerCapture *aTest) : CPcWindowBase(aTest) - { - iBack=TRgb::Gray256(236); - } - -TPointerCheckRet CPcWindowAltGroup::PointerDown() - { -#if defined(LOGGING) - _LIT(KLog1,"CPcWindowAltGroup::PointerDown State=%d SubState=%d"); - iTest->LOG_MESSAGE3(KLog1,iTest->State(),iTest->SubState()); -#endif - switch(iTest->State()) - { - case ECaptureDisabled: - if (iTest->SubState()==EChildWindow) - return(EOkay); - break; - case ENormalCapture: - case EDragDropCapture: - case ENormalCaptureWithoutFocus: - switch(iTest->SubState()) - { - case EOtherGroup: - return(EOkay); - default: - break; - } - break; - default: - break; - } -#if defined(LOGGING) - _LIT(KLog2,"CPcWindowAltGroup::PointerDown FAILED State=%d SubState=%d"); - iTest->LOG_MESSAGE3(KLog2,iTest->State(),iTest->SubState()); -#endif - return(EFailed); - } - -TPointerCheckRet CPcWindowAltGroup::DragDrop() - { -#if defined(LOGGING) - _LIT(KLog1,"CPcWindowAltGroup::DragDrop State=%d SubState=%d"); - iTest->LOG_MESSAGE3(KLog1,iTest->State(),iTest->SubState()); -#endif - switch(iTest->State()) - { - case EDragDropCapture: - case EDragDropCaptureAllGroups: - switch(iTest->SubState()) - { - case EOtherGroup: - return(EOkay); - default: - break; - } - break; - default: - break; - } -#if defined(LOGGING) - _LIT(KLog2,"CPcWindowAltGroup::DragDrop FAILED State=%d SubState=%d"); - iTest->LOG_MESSAGE3(KLog2,iTest->State(),iTest->SubState()); -#endif - return(EFailed); - } - -void CPcWindowAltGroup::Draw() - { - TBuf<0x40> buf; - if (iTest->State()==ECaptureDisabled) - { - switch(iTest->SubState()) - { - case EMainWindow: - break; - case EChildWindow: - buf.Copy(ClickOnMe); - break; - } - } - else - { - switch(iTest->SubState()) - { - case EOtherGroup: - buf.Copy(ClickOnMe); - break; - default: - break; - } - } - CPcWindowBase::Draw(buf); - } - -// - -CPcWindowAltConnection::CPcWindowAltConnection(CTPointerCapture *aTest) : CPcWindowBase(aTest) - { - iBack=TRgb::Gray256(236); - } - -TPointerCheckRet CPcWindowAltConnection::PointerDown() - { -#if defined(LOGGING) - _LIT(KLog1,"CPcWindowAltConnection::PointerDown State=%d SubState=%d"); - iTest->LOG_MESSAGE3(KLog1,iTest->State(),iTest->SubState()); -#endif - switch(iTest->State()) - { - case ECaptureDisabled: - if (iTest->SubState()==EChildWindow) - return(EOkay); - break; - case ENormalCapture: - case EDragDropCapture: - case ENormalCaptureWithoutFocus: - switch(iTest->SubState()) - { - case EOtherSession: - return(EOkay); - default: - break; - } - break; - default: - break; - } -#if defined(LOGGING) - _LIT(KLog2,"CPcWindowAltConnection::PointerDown FAILED State=%d SubState=%d"); - iTest->LOG_MESSAGE3(KLog2,iTest->State(),iTest->SubState()); -#endif - return(EFailed); - } - -TPointerCheckRet CPcWindowAltConnection::DragDrop() - { -#if defined(LOGGING) - _LIT(KLog1,"CPcWindowAltConnection::DragDrop State=%d SubState=%d"); - iTest->LOG_MESSAGE3(KLog1,iTest->State(),iTest->SubState()); -#endif - switch(iTest->State()) - { - case EDragDropCapture: - case EDragDropCaptureAllGroups: - switch(iTest->SubState()) - { - case EOtherSession: - return(EOkay); - default: - break; - } - break; - default: - break; - } -#if defined(LOGGING) - _LIT(KLog2,"CPcWindowAltConnection::DragDrop FAILED State=%d SubState=%d"); - iTest->LOG_MESSAGE3(KLog2,iTest->State(),iTest->SubState()); -#endif - return(EFailed); - } - -void CPcWindowAltConnection::Draw() - { - TBuf<0x40> buf; - if (iTest->State()!=ECaptureDisabled) - { - switch(iTest->SubState()) - { - case EOtherSession: - buf.Copy(ClickOnMe); - break; - default: - break; - } - } - CPcWindowBase::Draw(buf); - } - -// - -CTPointerCapture::CTPointerCapture(CTestStep* aStep) : CTWsGraphicsBase(aStep) - { - iSubState=0; - iFailed=EFalse; - } - -CTPointerCapture::~CTPointerCapture() - { - delete iNickFocusBlankWin; - delete iNickFocusGroup; - delete iAltConnectionWin; - delete iAltConnection; - delete iChildWin; - delete iMainWin; - delete iMainGroup; - delete iAltGroupWin; - delete iAltGroup; - } - -void CTPointerCapture::TestFailed() - { - if (iFailed) - { - _LIT(KLog,"Test Failed State=%d SubState=%d"); - LOG_MESSAGE3(KLog,iTest->iState,iSubState); - } - __ASSERT_DEBUG(iFailed==EFalse,AutoPanic(ETManPanicPcFailed)); - TInt dRet=1; -#if !defined(DISABLE_FAIL_DIALOG) - Client()->iGroup->GroupWin()->SetOrdinalPosition(0,10); // Put error dialog on top of test windows - TRAPD(err,dRet=doTestFailedL()); - Client()->iGroup->GroupWin()->SetOrdinalPosition(0,0); -#endif - switch(dRet) - { - case 0: - break; - case 1: - iFailed=ETrue; - NextTest(); - break; - } - } - -TInt CTPointerCapture::doTestFailedL() - { - CTDialog *dialog=new(ELeave) CTDialog(); - dialog->SetTitle(_L("Pointer capture test failed")); - dialog->SetNumButtons(2); - dialog->SetButtonText(0,_L("Retest")); - dialog->SetButtonText(1,_L("Fail")); - dialog->ConstructLD(*Client()->iGroup,*Client()->iGc); - return dialog->Display(); - } - -TInt CTPointerCapture::State() const - { - return(iTest->iState); - } - -TInt CTPointerCapture::SubState() const - { - return(iSubState); - } - -void CTPointerCapture::doIncSubStateL() - { - iSubState++; - TInt max=0; - switch(iTest->iState) - { - case ECaptureDisabled: - max=ESubStates1; - break; - case ENormalCapture: - max=ESubStates2; - break; - case ECaptureAllGroups: - max=ESubStates3; - break; - case EDragDropCapture: - max=ESubStates4; - break; - case EDragDropCaptureAllGroups: - max=ESubStates5; - break; - case ENormalCaptureWithoutFocus: - max=ESubStates6; - break; - } - //SubState 4 has been broken by something in the framework - if (iSubState==max || iSubState==4) - { - #if defined(LOGGING) - _LIT(KLog,"IncState OldState=%d SubState=%d"); - LOG_MESSAGE3(KLog,iTest->iState,iSubState); - #endif - NextTest(); - } - StateChanged(); - TheClient->WaitForRedrawsToFinish(); - if (iSubState>0) - SendEventsL(); - } - -void CTPointerCapture::GotDDL() - { - if (iDDState==DDStateWaiting) - doIncSubStateL(); - else - iDDState=DDStateGot; - } - -void CTPointerCapture::IncSubStateL(TBool aNeedsDD) - { - if (!aNeedsDD) - { - if (iDDState!=DDStateNull) - TestFailed(); - else - doIncSubStateL(); - } - else if (iDDState==DDStateGot) - doIncSubStateL(); - else - iDDState=DDStateWaiting; - } - -void CTPointerCapture::StateChanged() - { - iDDState=DDStateNull; - iChildWin->SubStateChanged(); - iMainWin->SubStateChanged(); - iAltGroupWin->SubStateChanged(); - iAltConnectionWin->SubStateChanged(); - } - -void CTPointerCapture::AbortTests() - { - iTest->iState=99; - } - -void CTPointerCapture::NextTest() - { - TEST(!iFailed); - if (iFailed) - { - _LIT(KLog,"SubTest %d failed"); - LOG_MESSAGE2(KLog,iTest->iState); - } - ++iTest->iState; - iSubState=0; - iFailed=EFalse; - CaseComplete(); - _LIT(KLog,"Done NextTest NewSubTest %d"); - LOG_MESSAGE2(KLog,iTest->iState); - } - -void CTPointerCapture::ConstructL() - { - TheClient->iWs.SetPointerCursorArea(iTest->iNormalPointerCursorArea); - iScreenSize=TSize(TheClient->iScreen->SizeInPixels()); - TInt winWidth2=iScreenSize.iWidth/2-EWinBorderSize*2; - TInt winWidth4=iScreenSize.iWidth/4-EWinBorderSize*2; - TInt winHeight=iScreenSize.iHeight/2-EWinBorderSize*2; -// - iMainGroup=new(ELeave) CTWindowGroup(Client()); - iMainGroup->ConstructL(); - iMainGroup->GroupWin()->SetOrdinalPosition(0,1); - iMainWin=new(ELeave) CPcWindowMain(this); - iMainWin->SetUpL(TPoint(EWinBorderSize,EWinBorderSize) ,TSize(winWidth2,winHeight) ,iMainGroup); - iMainGroup->SetCurrentWindow(iMainWin); - iChildWin=new(ELeave) CPcWindowChild(this); - iChildWin->SetUpL(TPoint(0,winHeight/2) ,TSize(winWidth2,winHeight/2) ,iMainWin); -// - iAltGroup=new(ELeave) CTWindowGroup(Client()); - iAltGroup->ConstructL(); - iAltGroup->GroupWin()->SetOrdinalPosition(0,1); - iAltGroup->GroupWin()->EnableReceiptOfFocus(EFalse); - iAltGroupWin=new(ELeave) CPcWindowAltGroup(this); - iAltGroupWin->SetUpL(TPoint(iScreenSize.iWidth/2+EWinBorderSize,EWinBorderSize) ,TSize(winWidth4,winHeight) ,iAltGroup); -// - iAltConnection=new(ELeave) CPcConnection(this); - iAltConnection->ConstructL(); - iAltConnectionWin=new(ELeave) CPcWindowAltConnection(this); - iAltConnectionWin->SetUpL(TPoint(iScreenSize.iWidth/4*3+EWinBorderSize,EWinBorderSize) ,TSize(winWidth4,winHeight),iAltConnection->iGroup,*iAltConnection->iGc); - iTest->DelayIfFullRomL(); - SetSelfDrive(ETrue); - } - -void CTPointerCapture::NickFocusL() - { - iNickFocusGroup=new(ELeave) CPcWindowNickFocusGroup(this,Client()); - iNickFocusGroup->ConstructL(); - iNickFocusGroup->GroupWin()->SetOrdinalPosition(0,2); - iNickFocusBlankWin=new(ELeave) CTBlankWindow(); - iNickFocusBlankWin->ConstructL(*iNickFocusGroup); - iNickFocusBlankWin->SetSize(TSize(1,1)); - iNickFocusBlankWin->Activate(); - } - -void CTPointerCapture::SetCapture(TInt aCaptureFlags) - { -#if defined(LOGGING) - _LIT(KLog,"Change Capture State=%d CaptureFlags=0x%x"); - LOG_MESSAGE3(KLog,iTest->iState,aCaptureFlags); -#endif - iMainWin->Win()->SetPointerCapture(aCaptureFlags); - } - -void CTPointerCapture::SendEventsL() - { -#if defined(LOGGING) - _LIT(KLog,"SendEvent State=%d SubState=%d"); - LOG_MESSAGE3(KLog,iTest->iState,iSubState); -#endif - switch (iSubState) - { - case 0: - iTest->SimulatePointerDownUp(iScreenSize.iWidth/4,iScreenSize.iHeight/8+EWinBorderSize/2); - break; - case 1: - if (iTest->iState>ECaptureDisabled) - { - iTest->SimulatePointerDownUp(iScreenSize.iWidth/4,3*iScreenSize.iHeight/8-EWinBorderSize/2); - break; - } - case 2: - iTest->SimulatePointerDownUp(5*iScreenSize.iWidth/8,iScreenSize.iHeight/4); - break; - case 3: - iTest->SimulatePointerDownUp(7*iScreenSize.iWidth/8,iScreenSize.iHeight/4); - break; - case 4: - if (iTest->IsFullRomL()) - iTest->SimulateKeyDownUp(EStdKeyEnter); - else - iTest->SimulatePointerDownUp(0,0); - if (iTest->iState==ENormalCaptureWithoutFocus) - { - iTest->SimulateKeyDownUp(EStdKeyEscape); - break; - } - break; - default: - TEST(EFalse); - } - TheClient->iWs.Flush(); - } - -void CTPointerCapture::RunTestCaseL(TInt /*aCurTestCase*/) - { - _LIT(TestNoCapture,"No capture"); - _LIT(TestNormalCapture,"Normal capture"); - _LIT(TestAllGroups,"All groups"); - _LIT(TestDragDrop,"Drag & Drop"); - _LIT(TestDragDropAllGroups,"Drag & Drop All groups"); - _LIT(TestWithoutFocus,"Without focus"); - StateChanged(); - - if (!TestBase()->ConfigurationSupportsPointerEventTesting()) - { - INFO_PRINTF1(_L("Test skipped because config does not support pointer event testing")); - TestComplete(); - return; - } - - ((CTPointerCaptureStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); - switch(iTest->iState) - { -/** - - @SYMTestCaseID GRAPHICS-WSERV-0290 - - @SYMDEF DEF081259 - - @SYMTestCaseDesc Test pointer capture can be disabled - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions Disable the pointer capture to the screen and simulate - capture with the pointer - - @SYMTestExpectedResults The pointer capture has been disabled - -*/ - case ECaptureDisabled: - ((CTPointerCaptureStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0290")); - if (TheClient->iScreen->GetScreenNumber()>0) - { - _LIT(KLog,"Cannot run this test on the 2nd screen - all pointer events goto the 1st screen"); - LOG_MESSAGE(KLog); - TestComplete(); - } - iTest->LogSubTest(TestNoCapture); - SetCapture(RWindowBase::TCaptureDisabled); - break; -/** - - @SYMTestCaseID GRAPHICS-WSERV-0291 - - @SYMDEF DEF081259 - - @SYMTestCaseDesc Test pointer capture can be enabled - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions Enable the pointer capture to the screen and simulate - capture with the pointer - - @SYMTestExpectedResults The pointer capture has been enabled and works - correctly - -*/ - case ENormalCapture: - ((CTPointerCaptureStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0291")); - iTest->LogSubTest(TestNormalCapture); - SetCapture(RWindowBase::TCaptureEnabled); - break; -/** - - @SYMTestCaseID GRAPHICS-WSERV-0292 - - @SYMDEF DEF081259 - - @SYMTestCaseDesc Test pointer capture can be enabled for - windows belonging to any group - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions Enable the pointer capture to all windows and simulate - capture with the pointer - - @SYMTestExpectedResults The pointer capture has been enabled and works - correctly - -*/ - case ECaptureAllGroups: - ((CTPointerCaptureStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0292")); - iTest->LogSubTest(TestAllGroups); - SetCapture(RWindowBase::TCaptureEnabled|RWindowBase::TCaptureFlagAllGroups); - break; -/** - - @SYMTestCaseID GRAPHICS-WSERV-0293 - - @SYMDEF DEF081259 - - @SYMTestCaseDesc Test drag and drop pointer capture can be enabled for - windows belonging to any group - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions Enable drag and drop pointer capture to all windows and simulate - capture with the pointer - - @SYMTestExpectedResults The pointer capture has been enabled and works - correctly - -*/ - case EDragDropCapture: - ((CTPointerCaptureStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0293")); - iTest->LogSubTest(TestDragDrop); - SetCapture(RWindowBase::TCaptureDragDrop&~RWindowBase::TCaptureFlagAllGroups); - break; -/** - - @SYMTestCaseID GRAPHICS-WSERV-0294 - - @SYMDEF DEF081259 - - @SYMTestCaseDesc Test drag and drop pointer capture can be enabled - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions Enable drag and drop pointer capture and simulate - capture with the pointer - - @SYMTestExpectedResults The pointer capture has been enabled and works - correctly - -*/ - case EDragDropCaptureAllGroups: - ((CTPointerCaptureStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0294")); - iTest->LogSubTest(TestDragDropAllGroups); - SetCapture(RWindowBase::TCaptureDragDrop); - break; -/** - - @SYMTestCaseID GRAPHICS-WSERV-0295 - - @SYMDEF DEF081259 - - @SYMTestCaseDesc Test pointer capture can be enabled - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions Enable the pointer capture to the screen and simulate capture - with the pointer when the screen does not have the focus - - @SYMTestExpectedResults The pointer capture has been enabled and works - correctly - -*/ - case ENormalCaptureWithoutFocus: - ((CTPointerCaptureStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0295")); - iTest->LogSubTest(TestWithoutFocus); - NickFocusL(); - SetCapture(RWindowBase::TCaptureEnabled); - break; - default: - ((CTPointerCaptureStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - ((CTPointerCaptureStep*)iStep)->CloseTMSGraphicsStep(); - TestComplete(); - return; - } - ((CTPointerCaptureStep*)iStep)->RecordTestResultL(); - SendEventsL(); - } - -__WS_CONSTRUCT_STEP__(PointerCapture) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TPNTCAP.H --- a/windowing/windowserver/tauto/TPNTCAP.H Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,200 +0,0 @@ - -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef __TPNTCAP_H__ -#define __TPNTCAP_H__ - -#include -#include -#include -#include "../tlib/testbase.h" -#include "AUTO.H" -#include "TGraphicsHarness.h" - -enum TTestState - { - ECaptureDisabled=0, - ENormalCapture, - ECaptureAllGroups, - EDragDropCapture, - EDragDropCaptureAllGroups, - ENormalCaptureWithoutFocus, - }; - -enum TTestSubState - { - EMainWindow, - EChildWindow, - EOtherGroup, - EOtherSession, - ERootWindow, - }; - -enum TPointerCheckRet - { - EFailed, - EOkay, - ENeedsDDEvent, - }; - -const TInt ESubStates1=2; -const TInt ESubStates2=5; -const TInt ESubStates3=5; -const TInt ESubStates4=5; -const TInt ESubStates5=5; -const TInt ESubStates6=5; - -const TInt EWinBorderSize=10; - -class CPcWindowBase; -class CTPointerCapture; - -class CPcConnection : public CTClient - { -public: - CPcConnection(CTPointerCapture *aTest); - ~CPcConnection(); - virtual void ConstructL(); -protected: - CTPointerCapture *iTest; - }; - -class CPcWindowBase : public CTWin - { -public: - CPcWindowBase(CTPointerCapture *aTest); - void SetUpL(TPoint pos,TSize size,CTWinBase *parent); - void SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc); - void Draw(TDesC &aBuf); - void PointerL(const TPointerEvent &pointer,const TTime &); - void DragDropL(const TPointerEvent &pointer,const TTime &); - virtual TPointerCheckRet PointerDown()=0; - virtual TPointerCheckRet DragDrop()=0; - virtual void SubStateChanged(); -protected: - CTPointerCapture *iTest; - TRgb iBack; - }; - -class CPcWindowChild : public CPcWindowBase - { -public: - CPcWindowChild(CTPointerCapture *aTest); - void Draw(); - TPointerCheckRet PointerDown(); - TPointerCheckRet DragDrop(); - }; - -class CPcWindowMain : public CPcWindowBase - { -public: - CPcWindowMain(CTPointerCapture *aTest); - void Draw(); - TPointerCheckRet PointerDown(); - TPointerCheckRet DragDrop(); - void WinKeyL(const TKeyEvent &aKey,const TTime &aTime); - }; - -class CPcWindowAltGroup : public CPcWindowBase - { -public: - CPcWindowAltGroup(CTPointerCapture *aTest); - void Draw(); - TPointerCheckRet PointerDown(); - TPointerCheckRet DragDrop(); - }; - -class CPcWindowNickFocusGroup : public CTWindowGroup - { -public: - CPcWindowNickFocusGroup(CTPointerCapture *aTest, CTClient *aClient); - void KeyL(const TKeyEvent &aKey,const TTime &aTime); -private: - CTPointerCapture *iTest; - }; - -class CPcWindowAltConnection : public CPcWindowBase - { -public: - CPcWindowAltConnection(CTPointerCapture *aTest); - void Draw(); - TPointerCheckRet PointerDown(); - TPointerCheckRet DragDrop(); - }; - -class CTPointerCapture : public CTWsGraphicsBase - { -private: - enum TDState {DDStateNull, DDStateGot, DDStateWaiting}; -public: - CTPointerCapture(CTestStep* aStep); - ~CTPointerCapture(); - void ConstructL(); - void NextTest(); - void AbortTests(); - TInt State() const; - TInt SubState() const; - void doIncSubStateL(); - void IncSubStateL(TBool aNeedsDD=EFalse); - void GotDDL(); - void StateChanged(); - void TestFailed(); - void NickFocusL(); - void SetCapture(TInt aCaptureFlags); - inline TestClient* Client() {return TheClient;} -protected: -//from CTGraphicsStep - virtual void RunTestCaseL(TInt aCurTestCase); -private: - TInt doTestFailedL(); - void SendEventsL(); -private: - CPcConnection *iAltConnection; - CTWindowGroup *iMainGroup; - CTWindowGroup *iAltGroup; - CPcWindowChild *iChildWin; - CPcWindowMain *iMainWin; - CPcWindowAltGroup *iAltGroupWin; - CPcWindowAltConnection *iAltConnectionWin; - CPcWindowNickFocusGroup *iNickFocusGroup; - CTBlankWindow *iNickFocusBlankWin; - //TInt iState; - TInt iSubState; - TDState iDDState; - TSize iScreenSize; -public: - TBool iFailed; - }; - -class CTPointerCaptureStep : public CTGraphicsStep - { -public: - CTPointerCaptureStep(); -protected: - //from CTGraphicsStep - virtual CTGraphicsBase* CreateTestL(); - }; - -_LIT(KTPointerCaptureStep,"TPointerCapture"); - - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TPNTKEY.H --- a/windowing/windowserver/tauto/TPNTKEY.H Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,112 +0,0 @@ - -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef __TPNTKEY_H__ -#define __TPNTKEY_H__ - -#include -#include -#include -#include "../tlib/testbase.h" -#include "AUTO.H" -#include "TGraphicsHarness.h" - -const TInt ENumPntKeyTests=6; -const TUint EModifierMask=EModifierCtrl|EModifierShift|EModifierFunc; - -class CTPntKey; - -class CTPntKeyWindow : public CTWin - { -private: - enum {KPointerMoveBufferSize=32}; -public: - CTPntKeyWindow(CTPntKey *aTest); - ~CTPntKeyWindow(); - void SetUpLD(TPoint pos,TSize size,CTWinBase *parent); - void PointerL(const TPointerEvent &pointer,const TTime &aTime); - void KeyUpL(const TKeyEvent &aKey,const TTime &); - void KeyDownL(const TKeyEvent &aKey,const TTime &); - void WinKeyL(const TKeyEvent &aKey,const TTime &); - void SwitchOn(const TTime &aTime); - void NextKey(); - void Test(TInt aCheck); - void Error(TInt aWhere); - void DrawButton(const TRect &aRect, const TDesC &aText); - void Draw(); - void SendEvent(); - void SimulatePointerDownUp(const TRect& aRect); - inline TInt KeyCount() {return iKeyCount;} -private: - TInt iKeyCount; - TRect iKey1; - TRect iKey2; - TRect iKey3; - static TInt iTestScanCodes[ENumPntKeyTests]; - static TUint iTestCodes[ENumPntKeyTests]; - static TUint iTestModifiers[ENumPntKeyTests]; - CTPntKey *iTest; - }; - -class CTPntKey : public CTWsGraphicsBase -{ -private: - enum {KTimeOutAfter=60000000}; //60secs - -public: - CTPntKey(CTestStep* aStep); - ~CTPntKey(); - void ConstructL(); - static TInt TimeOut(TAny* aTest); - void TimeOut(); - void Failed(TInt aWhere); - inline TBool NoDigitiser() const {return iNoDigitiser;} - -protected: //from CTGraphicsStep - virtual void RunTestCaseL(TInt aCurTestCase); - -private: - inline TestClient *Client() {return TheClient;} - -private: - CTimeOut* iTimeOut; - CTPntKeyWindow *iWin; - TSize iWinSize; - TInt iState; - TBool iFailed; - TBool iOldPointerState; - TBool iNoDigitiser; - }; - -class CTPntKeyStep : public CTGraphicsStep - { -public: - CTPntKeyStep(); -protected: - //from CTGraphicsStep - virtual CTGraphicsBase* CreateTestL(); - }; - -_LIT(KTPntKeyStep,"TPntKey"); - - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TPROCPRI.CPP --- a/windowing/windowserver/tauto/TPROCPRI.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,194 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Test process priority control -// -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - - -#include "TPROCPRI.H" - -TName OtherGroupName; - -TInt ProcPriTestOtherProcess(TAny *aScreenNumber) - { - CTrapCleanup* CleanUpStack=CTrapCleanup::New(); - RWsSession ws; - User::LeaveIfError(ws.Connect()); - // use correct screen - // - CWsScreenDevice* screen = NULL; - TInt err; - TRAP(err, screen = new (ELeave) CWsScreenDevice(ws)); - if (err!=KErrNone) - return err; - if ((err=screen->Construct((TInt)aScreenNumber))!=KErrNone) - { - delete screen; - return err; - } - - RWindowGroup group(ws); - group.Construct(888); - group.SetName(OTHER_PROC_GROUP_NAME); - RSemaphore sem1; - RSemaphore sem2; - sem1.OpenGlobal(PROC_PRI_SEMAPHORE_NAME1); - sem2.OpenGlobal(PROC_PRI_SEMAPHORE_NAME2); - sem1.Signal(); // Signal thread fully initialised - sem2.Wait(); // Wait for command to disable focus -// - group.EnableReceiptOfFocus(EFalse); - ws.Flush(); - sem1.Signal(); // Signal focus disabled - sem2.Wait(); // Wait for command to enable focus - - group.EnableReceiptOfFocus(ETrue); - ws.Flush(); - sem1.Signal(); // Signal focus enabled - sem2.Wait(); // Wait until signalled to exit -// - group.EnableReceiptOfFocus(EFalse); // To stop shell being tasked into foreground - delete screen; - ws.Close(); - sem1.Close(); - sem2.Close(); - delete CleanUpStack; - return(KErrNone); - } - -CTProcPri::CTProcPri(CTestStep* aStep) : CTWsGraphicsBase(aStep) - { - } - -CTProcPri::~CTProcPri() - { - if (iFlags&ECreatedSem1) - iSem1.Close(); - if (iFlags&ECreatedSem2) - iSem2.Close(); - delete iProcess; - } - -void CTProcPri::TestPriChangeL() - { - #define BACK_PRI EPriorityForeground - #define FORE_PRI EPriorityForeground - RProcess proc; - TEST(proc.Priority()==BACK_PRI); - if (proc.Priority()!=BACK_PRI) - INFO_PRINTF3(_L("proc.Priority() return value - Expected: %d, Actual: %d"), BACK_PRI, proc.Priority()); - - iSem2.Signal(); - iSem1.Wait(); - - TEST(proc.Priority()==FORE_PRI); - if (proc.Priority()!=FORE_PRI) - INFO_PRINTF3(_L("proc.Priority() return value - Expected: %d, Actual: %d"), FORE_PRI, proc.Priority()); - - iSem2.Signal(); - iSem1.Wait(); - - TEST(proc.Priority()==BACK_PRI); - if (proc.Priority()!=BACK_PRI) - INFO_PRINTF3(_L("proc.Priority() return value - Expected: %d, Actual: %d"), BACK_PRI, proc.Priority()); - - TInt ident; - User::LeaveIfError(ident=TheClient->iWs.FindWindowGroupIdentifier(0,OTHER_PROC_GROUP_NAME,0)); - TInt retVal = TheClient->iWs.SetWindowGroupOrdinalPosition(ident,1); - TEST(retVal==KErrNone); - if (retVal!=KErrNone) - INFO_PRINTF3(_L("TheClient->iWs.SetWindowGroupOrdinalPosition(ident,1) return value - Expected: %d, Actual: %d"), KErrNone, retVal); - - TEST(proc.Priority()==FORE_PRI); - if (proc.Priority()!=FORE_PRI) - INFO_PRINTF3(_L("proc.Priority() return value - Expected: %d, Actual: %d"), FORE_PRI, proc.Priority()); - - retVal = TheClient->iWs.SetWindowGroupOrdinalPosition(ident,0); - TEST(retVal==KErrNone); - if (retVal!=KErrNone) - INFO_PRINTF3(_L("TheClient->iWs.SetWindowGroupOrdinalPosition(ident,0) return value - Expected: %d, Actual: %d"), KErrNone, retVal); - - TEST(proc.Priority()==BACK_PRI); - if (proc.Priority()!=BACK_PRI) - INFO_PRINTF3(_L("proc.Priority() return value - Expected: %d, Actual: %d"), BACK_PRI, proc.Priority()); - - TRequestStatus stat; - iProcess->Logon(stat); //Must Logon before the last Signal so we can be sure that it is still alive to get round a base issue - iSem2.Signal(); - User::WaitForRequest(stat); - - TEST(proc.Priority()==FORE_PRI); - if (proc.Priority()!=FORE_PRI) - INFO_PRINTF3(_L("proc.Priority() return value - Expected: %d, Actual: %d"), FORE_PRI, proc.Priority()); - - } - -void CTProcPri::ConstructL() - { - User::LeaveIfError(iSem1.CreateGlobal(PROC_PRI_SEMAPHORE_NAME1,0,KOwnerType)); - iFlags|=ECreatedSem1; - User::LeaveIfError(iSem2.CreateGlobal(PROC_PRI_SEMAPHORE_NAME2,0,KOwnerType)); - iFlags|=ECreatedSem2; - iProcess=CProcess::NewL(CProcess::eProcessPriortyTest,iTest->iScreenNumber); - iSem1.Wait(); - } - -void CTProcPri::RunTestCaseL(TInt /*aCurTestCase*/) - { - _LIT(KTest1,"Priority Change"); - ((CTProcPriStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); - - switch(++iTest->iState) - { -/** - - @SYMTestCaseID GRAPHICS-WSERV-0315 - - @SYMDEF DEF081259 - - @SYMTestCaseDesc Test that the priority of a process or thread changes depending - on how the the process or thread is being used - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions Create a process or thread and use it. Check the priority of the - process or thread changes depending on how it is being used - - @SYMTestExpectedResults Prioirty of the process of thread changes depending on - how it is being used - -*/ - case 1: - ((CTProcPriStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0315")); - iTest->LogSubTest(KTest1); - TestPriChangeL(); - break; - case 2: - ((CTProcPriStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - ((CTProcPriStep*)iStep)->CloseTMSGraphicsStep(); - TestComplete(); - break; - } - ((CTProcPriStep*)iStep)->RecordTestResultL(); - } - -__WS_CONSTRUCT_STEP__(ProcPri) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TPROCPRI.H --- a/windowing/windowserver/tauto/TPROCPRI.H Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,72 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef __TPROCPRI_H__ -#define __TPROCPRI_H__ - -#include "AUTO.H" -#include "TGraphicsHarness.h" -#include "../tlib/testbase.h" -#include -#include - -#define OTHER_PROC_GROUP_NAME _L("OtherProcGroupWindow") -#define PROC_PRI_SEMAPHORE_NAME1 _L("abcerProcSem1") -#define PROC_PRI_SEMAPHORE_NAME2 _L("OtherProcSem2") - -class CTProcPri : public CTWsGraphicsBase - { -private: - enum - { - ECreatedSem1=0x0001, - ECreatedSem2=0x0002, - }; -public: - CTProcPri(CTestStep* aStep); - ~CTProcPri(); - void ConstructL(); - void TestPriChangeL(); -protected: -//from CTGraphicsStep - virtual void RunTestCaseL(TInt aCurTestCase); -private: - TSize iWinSize; - RSemaphore iSem1; - RSemaphore iSem2; - TUint iFlags; - CProcess* iProcess; - }; - - -class CTProcPriStep : public CTGraphicsStep - { -public: - CTProcPriStep(); -protected: - //from CTGraphicsStep - virtual CTGraphicsBase* CreateTestL(); - }; - -_LIT(KTProcPriStep,"TProcPri"); - - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TPntKey.CPP --- a/windowing/windowserver/tauto/TPntKey.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,385 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Converted from TMan test code (TMPNTKEY.CPP) May 2001 -// Test Pointer move/drag buffer -// -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include "TPNTKEY.H" - -#define LOGGING on //Uncomment this line to get more logging - -TInt CTPntKeyWindow::iTestScanCodes[ENumPntKeyTests]={'A','B',0,'C',EStdKeyEnter,'Y'}; -TUint CTPntKeyWindow::iTestCodes[ENumPntKeyTests]={'a','B',0,'c',EKeyEnter,'y'}; -TUint CTPntKeyWindow::iTestModifiers[ENumPntKeyTests]={0,EModifierShift,0,0,0,0}; - -CTPntKeyWindow::CTPntKeyWindow(CTPntKey *aTest) : iTest(aTest) - {} - -CTPntKeyWindow::~CTPntKeyWindow() - { - } - -void CTPntKeyWindow::SetUpLD(TPoint pos,TSize size,CTWinBase *parent) - { - ConstructExtLD(*parent,pos,size); - iWin.SetPointerGrab(ETrue); - iKey1=TRect(size.iWidth*1/16,size.iHeight/2,size.iWidth*5/16,size.iHeight); - iKey2=TRect(size.iWidth*6/16,size.iHeight/2,size.iWidth*10/16,size.iHeight); - iKey3=TRect(size.iWidth*11/16,size.iHeight/2,size.iWidth*15/16,size.iHeight); - iWin.AddKeyRect(iKey1,'A',EFalse); - iWin.AddKeyRect(iKey2,'B',EFalse); - AssignGC(*Client()->iGc); - BaseWin()->EnableOnEvents(); - Activate(); - } - -void CTPntKeyWindow::Error(TInt aWhere) - { - iTest->Failed(aWhere); - } - -void CTPntKeyWindow::NextKey() - { - if (++iKeyCount!=ENumPntKeyTests) - { - #if defined(LOGGING) - _LIT(KLog,"Next Key KeyCount=%d"); - iTest->LOG_MESSAGE2(KLog,iKeyCount); - #endif - if (iKeyCount==2) - iWin.RemoveAllKeyRects(); - else if (iKeyCount==3) - iWin.AddKeyRect(iKey3,'C',EFalse); - else if (iKeyCount==4) - { - #if !defined(__WINS__) - if (iTest->NoDigitiser()) - { - return; - } - #endif - iWin.RemoveAllKeyRects(); - iWin.AddKeyRect(TRect(Client()->iScreen->SizeInPixels()),'Z',EFalse); - } - else if (iKeyCount==5) - { - iWin.RemoveAllKeyRects(); - Client()->iWs.Flush(); - User::After(500000); // Wait half a second - iWin.AddKeyRect(TRect(Client()->iScreen->SizeInPixels()),'Y',ETrue); - } - Invalidate(); - } - SendEvent(); - } - -void CTPntKeyWindow::SendEvent() - { - TheClient->WaitForRedrawsToFinish(); -#if defined(LOGGING) - _LIT(KLog,"SendEvent KeyCount=%d"); - iTest->LOG_MESSAGE2(KLog,iKeyCount); -#endif - switch(iKeyCount) - { - case 0: - SimulatePointerDownUp(iKey1); - break; - case 1: - iTest->TestBase()->SimulateKey(TRawEvent::EKeyDown,EStdKeyLeftShift); - SimulatePointerDownUp(iKey2); - iTest->TestBase()->SimulateKey(TRawEvent::EKeyUp,EStdKeyLeftShift); - break; - case 2: - case 5: - { - TPoint pos=Position(); - TSize size=Size(); - iTest->TestBase()->SimulatePointerDownUp(pos.iX+size.iWidth/2,pos.iY+size.iHeight/4); - } - break; - case 3: - SimulatePointerDownUp(iKey3); - break; - case 4: - iTest->TestBase()->SimulateKeyDownUp(EStdKeyEnter); - break; - } - } - -void CTPntKeyWindow::SimulatePointerDownUp(const TRect& aRect) - { - iTest->TestBase()->SimulatePointerDownUp((aRect.iTl.iX+aRect.iBr.iX)/2,(aRect.iTl.iY+aRect.iBr.iY)/2); - } - -void CTPntKeyWindow::Test(TInt aCheck) - { - if (!aCheck) - Error(3); - } - -void CTPntKeyWindow::KeyUpL(const TKeyEvent &aKey,const TTime&) - { - if (aKey.iScanCode==iTestScanCodes[iKeyCount]) - NextKey(); - } - -void CTPntKeyWindow::KeyDownL(const TKeyEvent &aKey,const TTime &) - { -#if defined(LOGGING) - _LIT(KLog,"KeyDownL ScanCode=%d '%c' (%d) KeyCount=%d"); - iTest->LOG_MESSAGE5(KLog,aKey.iScanCode,aKey.iScanCode,iTestScanCodes[iKeyCount],iKeyCount); -#endif - if (aKey.iScanCode!=EStdKeyLeftFunc && aKey.iScanCode!=EStdKeyRightFunc && - aKey.iScanCode!=EStdKeyLeftAlt && aKey.iScanCode!=EStdKeyRightAlt && - aKey.iScanCode!=EStdKeyLeftCtrl && aKey.iScanCode!=EStdKeyRightCtrl && - aKey.iScanCode!=EStdKeyLeftShift && aKey.iScanCode!=EStdKeyRightShift && - aKey.iScanCode!=EStdKeyOff && - aKey.iScanCode!=EStdKeyEscape) - Test(aKey.iScanCode==iTestScanCodes[iKeyCount]); - } - -void CTPntKeyWindow::WinKeyL(const TKeyEvent &aKey,const TTime &) - { - if (aKey.iCode!=EKeyEscape) - { -#if defined(LOGGING) - _LIT(KLog1,"WinKeyL1 ScanCode=%d (%d) Code=%d '%c' (%d)"); - _LIT(KLog2,"WinKeyL2 ScanCode=%d Modifiers=0x%x (0x%x) KeyCount=%d"); - iTest->LOG_MESSAGE6(KLog1,aKey.iScanCode,iTestScanCodes[iKeyCount],aKey.iCode,aKey.iCode,iTestCodes[iKeyCount]); - iTest->LOG_MESSAGE5(KLog2,aKey.iScanCode,aKey.iModifiers&EModifierMask,iTestModifiers[iKeyCount]&EModifierMask,iKeyCount); -#endif - Test(aKey.iScanCode==iTestScanCodes[iKeyCount]); - Test(aKey.iCode==iTestCodes[iKeyCount]); - Test((aKey.iModifiers&EModifierMask)==(iTestModifiers[iKeyCount]&EModifierMask)); - } - } - -void CTPntKeyWindow::SwitchOn(const TTime &) - { -#if defined(LOGGING) - _LIT(KLog,"SwitchOn KeyCount=%d"); - iTest->LOG_MESSAGE2(KLog,iKeyCount); -#endif - if (iKeyCount==4) - NextKey(); - else if (iKeyCount!=5) - Error(2); - } - -void CTPntKeyWindow::PointerL(const TPointerEvent &aPointer,const TTime &) - { -#if defined(LOGGING) - _LIT(KLog,"Pointer Event Type=%d Pos=(%d,%d) PPos=(%d,%d) KeyCount=%d"); - iTest->LOG_MESSAGE7(KLog,aPointer.iType,aPointer.iPosition.iX,aPointer.iPosition.iY - ,aPointer.iParentPosition.iX,aPointer.iParentPosition.iY,iKeyCount); -#endif - if (aPointer.iType==TPointerEvent::EButton1Down) - { - if (iKeyCount!=2) - Error(1); - else - NextKey(); - } - } - -void CTPntKeyWindow::DrawButton(const TRect &aRect, const TDesC &aText) - { - iGc->DrawRect(aRect); - iGc->DrawText(aText, TPoint((aRect.iBr.iX+aRect.iTl.iX)/2,(aRect.iBr.iY+aRect.iTl.iY)/2)); - } - -void CTPntKeyWindow::Draw() - { - iGc->SetBrushColor(TRgb::Gray4(0)); - iGc->SetPenColor(TRgb::Gray4(3)); - iGc->Clear(); - DrawButton(iKey1,_L("A")); - DrawButton(iKey2,_L("B")); - DrawButton(iKey3,_L("C")); - switch(iKeyCount) - { - case 0: - iGc->DrawText(_L("Click on 'A'"), TPoint(10,20)); - break; - case 1: - iGc->DrawText(_L("Shift-Click on 'B'"), TPoint(10,20)); - break; - case 2: - iGc->DrawText(_L("Click anywhere in this window"), TPoint(10,20)); - break; - case 3: - iGc->DrawText(_L("Click on 'C'"), TPoint(10,20)); - break; - case 4: -#if defined(__WINS__) // Can't emulate touching dig when switched off under WINS - iGc->DrawText(_L("Switch off and on (or press Enter)"), TPoint(10,20)); -#else - iGc->DrawText(_L("Switch off, then touch the screen to switch on"), TPoint(10,20)); -#endif - break; - case 5: -#if defined(__WINS__) // Can't emulate touching dig when switched off under WINS - iGc->DrawText(_L("Touch anywhere in the window"), TPoint(10,20)); -#else - iGc->DrawText(_L("Switch off and touch the screen to switch on again"), TPoint(10,20)); -#endif - break; - } - } - -CTPntKey::CTPntKey(CTestStep* aStep): - CTWsGraphicsBase(aStep) - { - } - -CTPntKey::~CTPntKey() - { - HAL::Set(HALData::EPenDisplayOn,iOldPointerState); - CTWin::Delete(iWin); - Client()->ResetFocus(); - delete iTimeOut; - } - -TInt CTPntKey::TimeOut(TAny* aTest) //static - { - static_cast(aTest)->TimeOut(); - return(KErrNone); - } - -void CTPntKey::TimeOut() - { - TLogMessageText buf; - _LIT(KPntKeyTimeOut,"TIMEOUT: Pointer Key, %d, %S"); - buf.AppendFormat(KPntKeyTimeOut,iState,&TestBase()->iSubTitle); - TheClient->LogMessage(buf); - Failed(4); - } - -void CTPntKey::Failed(TInt aWhere) - { - _LIT(KLog,"Failed at %d"); - LOG_MESSAGE2(KLog,aWhere); - if (!iFailed) - { - iFailed=ETrue; - Client()->iGroup->ClearCurrentWindow(); - } - } - -void CTPntKey::ConstructL() - { - TInt mods=TheClient->iWs.GetModifierState(); - if (mods&EModifierCapsLock) - iTest->SimulateKeyDownUp(EStdKeyCapsLock); - //Make sure all the keys we test are in the up state - iTest->SimulateKeyDownUp(EStdKeyLeftShift); - iTest->SimulateKeyDownUp(EStdKeyRightShift); - iTest->SimulateKeyDownUp(EStdKeyLeftFunc); - iTest->SimulateKeyDownUp(EStdKeyLeftCtrl); - iTest->SimulateKeyDownUp(EStdKeyRightCtrl); - mods=TheClient->iWs.GetModifierState(); - _LIT(KLog,"Initial Modifiers state 0x%x (ideally should be zero)"); - LOG_MESSAGE2(KLog,mods); - TheClient->iScreen->SetScreenMode(0); //May sure we are in the right screen size mode - TheClient->iScreen->SetAppScreenMode(0); - TheClient->iWs.SetPointerCursorArea(TestBase()->iNormalPointerCursorArea); - CTPntKeyWindow *win=new(ELeave) CTPntKeyWindow(this); - win->SetUpLD(TPoint(20,20),Client()->iScreen->SizeInPixels()-TSize(40,40),Client()->iGroup); - iWin=win; - Client()->iGroup->SetCurrentWindow(iWin); - iNoDigitiser=EFalse; - TInt err=HAL::Get(HALData::EPenDisplayOn,iOldPointerState); - if (err==KErrNotSupported) - { - iNoDigitiser=ETrue; - } - else if (err==KErrNone) - { - err=HAL::Set(HALData::EPenDisplayOn,ETrue); - if (err==KErrNotSupported) - iNoDigitiser=(!iOldPointerState); - } - else - { - TEST(EFalse); - } - TheClient->WaitForRedrawsToFinish(); //Make sure all pending events have been delt with (redraw events are lowest priority) - iTimeOut=new(ELeave) CTimeOut(); - iTimeOut->ConstructL(); - iTimeOut->Start(KTimeOutAfter,TCallBack(CTPntKey::TimeOut,this)); - } - -void CTPntKey::RunTestCaseL(TInt /*aCurTestCase*/) - { - _LIT(KTestName,"Key set 1"); - TEST(!iFailed); - if (iFailed) - { - _LIT(KLog,"Test Failed Substate=%d KeyCount=%d"); - LOG_MESSAGE3(KLog,iTest->iState,iWin->KeyCount()); - } - ((CTPntKeyStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); - switch(++iTest->iState) - { -/** -@SYMTestCaseID GRAPHICS-WSERV-0200 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test Pointer move/drag buffer - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Exercise the pointer move/drag buffer and check - that it functions correctly - -@SYMTestExpectedResults The buffer functions correctly -*/ - case 1: - ((CTPntKeyStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0200")); - iTest->LogSubTest(KTestName); - if (TestBase()->ConfigurationSupportsPointerEventTesting()) - { - iWin->SendEvent(); - TheClient->Flush(); - } - else - { - INFO_PRINTF1(_L("Test skipped because config does not support pointer event testing")); - } - break; - case 2: - ((CTPntKeyStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - ((CTPntKeyStep*)iStep)->CloseTMSGraphicsStep(); - if (TestBase()->ConfigurationSupportsPointerEventTesting()) - { - iTimeOut->Cancel(); - } - TestComplete(); - break; - } - ((CTPntKeyStep*)iStep)->RecordTestResultL(); - } - -__WS_CONSTRUCT_STEP__(PntKey) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TPointer.CPP --- a/windowing/windowserver/tauto/TPointer.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1087 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Test pointer event handling -// Coverted from TMan test code (TMPOINTR.CPP) October 2000 -// -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include "TPointer.H" - - -//#define LOGGING - -#if defined(LOGGING) - LOCAL_D TLogMessageText LogMessageText; -#endif - - -CPointerWindow::CPointerWindow(CTPointer *aTest) : CTWin(), iTest(aTest) - {} - -void CPointerWindow::SetState(TInt aState) - { -#if defined(LOGGING) - _LIT(KState,"CPointerWindow::SetState(%d) OldState=%d"); - LogMessageText.Format(KState,aState,iState); - TheClient->LogMessage(LogMessageText); -#endif - iState=aState; - iWin.Invalidate(); - switch(aState) - { - case KStateWaitingForTest1: - case KStateWaitingForTest2: - case KStateWaitingForTest3: - case KStateWaitingForTest4: - case KStateWaitingForTest5: - case KStateWaitingForTest6: - case KStateWaitingForTest8: - case KStateWaitingForTest7: - iRepeatRect=TRect(); - break; - case KStateTesting8: - iWin.Close(); - Client()->iWs.Flush(); - User::After(500000); - FinishedTests(); - break; - } - TheClient->WaitForRedrawsToFinish(); - SendEvent(); - } - -void CPointerWindow::ResetTest(TInt aState) - { - TInt newState=KStateFinished; - switch(aState) - { - case KStateTesting1: - newState=KStateWaitingForTest1; - break; - case KStateTesting2: - newState=KStateWaitingForTest2; - break; - case KStateTesting3: - newState=KStateWaitingForTest3; - break; - case KStateTesting4: - newState=KStateWaitingForTest4; - break; - case KStateTesting5: - newState=KStateWaitingForTest5; - break; - case KStateTesting6: - newState=KStateWaitingForTest6; - break; - case KStateTesting8: - newState=KStateWaitingForTest8; - break; - case KStateTesting7: - newState=KStateWaitingForTest7; - break; - } - TheClient->iWs.PurgePointerEvents(); - SetState(newState); - } - -void CPointerWindow::SetUpLD(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc) - { - ConstructExtLD(*parent,pos,size); - iTl=pos; - iSize=size; - Activate(); - AssignGC(aGc); - SetState(KStateWaitingForTest1); - BaseWin()->EnableOnEvents(); - } - -void CPointerWindow::Draw() - { - iGc->Clear(); - iGc->DrawRect(Size()); - iGc->DrawRect(iRepeatRect); - TBuf<0x80> buf; - TBuf<0x80> buf2; - switch(iState) - { - case KStateWaitingForTest1: - { - _LIT(Draw1,"Click anywhere in the window and hold the pointer steady"); - buf.Format(Draw1); - } - break; - case KStateTesting1: - { - _LIT(Draw2,"Hold pointer inside the box"); - buf.Format(Draw2); - } - break; - case KStateWaitingForTest2: - { - _LIT(Draw3,"Release the pointer then click in the window and hold the pointer steady"); - buf.Format(Draw3); - } - break; - case KStateTesting2: - { - _LIT(Draw4,"Drag the pointer outside the box"); - buf.Format(Draw4); - } - break; - case KStateWaitingForTest3: - { - _LIT(Draw5,"Release the pointer then click in the window and hold the pointer steady"); - buf.Format(Draw5); - } - break; - case KStateTesting3: - { - _LIT(Draw6,"Release the pointer"); - buf.Format(Draw6); - } - break; - case KStateWaitingForTest4: - { - _LIT(Draw7,"Click anywhere in the window and move the pointer slightly"); - buf.Format(Draw7); - } - break; - case KStateTesting4: - { - _LIT(Draw8,"Release the pointer"); - buf.Format(Draw8); - } - break; - case KStateWaitingForTest5: - { - _LIT(Draw9,"Click anywhere in the window and move the pointer slightly"); - buf.Format(Draw9); - } - break; - case KStateTesting5: - { - _LIT(Draw10,"Release the pointer"); - buf.Format(Draw10); - break; - } - case KStateWaitingForTest6: - { - _LIT(Draw11,"Click anywhere in the window"); - buf.Format(Draw11); - } - break; - case KStateTesting6: - { - _LIT(Draw12,"Move the pointer"); - buf.Format(Draw12); - } - break; - case KStateWaitingForTest8: - { - _LIT(Draw13,"Click anywhere in the window, and keep the pointer pressed"); - buf.Format(Draw13); - } - break; - case KStateTesting8: - buf.Format(KNullDesC); - break; - case KStateWaitingForTest7: - { - _LIT(Draw14,"Switch off and touch the center of the screen"); - buf.Format(Draw14); - } - break; - case KStateTesting7: - buf.Format(KNullDesC); - break; - } - switch(iState) - { - case KStateTesting1: - { - _LIT(Repeat2,"Repeat (%d/%d), interval=%d.%d"); - buf2.Format(Repeat2,iRepeatCount,KRepeatCount,iInterval.Int()/1000000,(iInterval.Int()%1000000)/100000); - } - break; - case KStateTesting2: - case KStateTesting3: - { - _LIT(Repeat1,"Repeat (%d), interval=%d.%d"); - buf2.Format(Repeat1,iRepeatCount,iInterval.Int()/1000000,(iInterval.Int()%1000000)/100000); - } - break; - } - iGc->DrawText(buf,TPoint(10,20)); - iGc->DrawText(buf2,TPoint(10,40)); - } - -void CPointerWindow::FinishedTests() - { - iState=KStateFinished; - } - -void CPointerWindow::StartNextRepeatTest() - { - iInterval=0; - iRepeatCount=0; - if (iState==KStateWaitingForTest4) - User::After(TTimeIntervalMicroSeconds32(1000000)); - else if (iState==KStateWaitingForTest5) - User::After(TTimeIntervalMicroSeconds32(1000000)); - QueueNextRepeat(); - switch(iState) - { - case KStateWaitingForTest1: - SetState(KStateTesting1); - break; - case KStateWaitingForTest2: - SetState(KStateTesting2); - break; - case KStateWaitingForTest3: - SetState(KStateTesting3); - break; - case KStateWaitingForTest4: - SetState(KStateTesting4); - break; - case KStateWaitingForTest5: - SetState(KStateTesting5); - break; - case KStateWaitingForTest6: - SetState(KStateTesting6); - break; - case KStateWaitingForTest8: - SetState(KStateTesting8); - break; - case KStateWaitingForTest7: - SetState(KStateTesting7); - break; - } - } - -void CPointerWindow::QueueNextRepeat() - { - iInterval=iInterval.Int()+KRepeatIntervalIncrements; -#if defined(LOGGING) - /*_LIT(KRequestRepeat,"Request Repeat, State=%d, Interval=%d"); - TLogMessageText buf; - buf.Format(KRequestRepeat,iState,iInterval.Int()); - TheClient->LogMessage(buf);*/ -#endif - iWin.RequestPointerRepeatEvent(TTimeIntervalMicroSeconds32(iInterval),TRect(iRepeatRect)); - iPrevTime.HomeTime(); - iWin.Invalidate(); - } - -void CPointerWindow::PointerL(const TPointerEvent &aPointer,const TTime &aTime) - { -#if defined(LOGGING) - _LIT(KPointer,"CPointerWindow::PointerL(Type=%d, Pos=(%d,%d), ParPos=(%d,%d), Mod=0x%x) State=%d"); - LogMessageText.Format(KPointer,aPointer.iType,aPointer.iPosition.iX,aPointer.iPosition.iY,aPointer.iParentPosition.iX,aPointer.iParentPosition.iY,aPointer.iModifiers,iState); - TheClient->LogMessage(LogMessageText); -#endif - if (aPointer.iType==TPointerEvent::EButtonRepeat) - { - if (iState!=KStateTesting1 && iState!=KStateTesting2 && iState!=KStateTesting3 && iState!=KStateTesting4) - TestFailed(); - else - { - TTimeIntervalMicroSeconds32 interval(I64LOW(aTime.MicroSecondsFrom(iPrevTime).Int64())); - TBool fail1=(interval.Int()<(iInterval.Int()-KRepeatMargin) || interval.Int()>(iInterval.Int()+KRepeatMargin)); - if (fail1) - { - _LIT(KPointerRepeat1,"Pointer Repeat Interval, Exp=%d, Act=%d, F1=%d, F2=%d"); - TLogMessageText buf; - TBool fail2=(interval.Int()<(iInterval.Int()-2*KRepeatMargin) || interval.Int()>(iInterval.Int()+3*KRepeatMargin)); - buf.Format(KPointerRepeat1,iInterval.Int(),interval.Int(),fail1,fail2); - TheClient->LogMessage(buf); - } - if (interval.Int()<(iInterval.Int()- - #if defined(__MARM_ARM4__) - 2* - #endif - KRepeatMargin) || interval.Int()>(iInterval.Int()+ - #if defined(__MARM_ARM4__) - 3* - #endif - KRepeatMargin)) - TestFailed(); - else - { - if (!iRepeatRect.Contains(aPointer.iPosition) || - aPointer.iParentPosition!=(aPointer.iPosition+iWin.InquireOffset(*Parent()->WinTreeNode()))) - TestFailed(); - else - { - iRepeatCount++; - if (iState==KStateTesting1 && iRepeatCount==KRepeatCount) - { - QueueNextRepeat(); - Client()->iWs.Flush(); - User::After(TTimeIntervalMicroSeconds32(iRepeatCount*KRepeatIntervalIncrements)); - iWin.CancelPointerRepeatEventRequest(); - SetState(KStateWaitingForTest2); - } - else - QueueNextRepeat(); - } - } - } - } - else switch(iState) - { - case KStateWaitingForTest1: - case KStateWaitingForTest2: - case KStateWaitingForTest3: - case KStateWaitingForTest4: - case KStateWaitingForTest8: - if (aPointer.iType==TPointerEvent::EButton1Down) - { - iRepeatRect.iTl=aPointer.iPosition-TPoint(KRepeatRectXExtra,KRepeatRectYExtra); - iRepeatRect.iBr=aPointer.iPosition+TPoint(KRepeatRectXExtra,KRepeatRectYExtra); - StartNextRepeatTest(); - } - break; - case KStateWaitingForTest5: - if (aPointer.iType==TPointerEvent::EButton1Down) - { - iRepeatRect.iTl=aPointer.iPosition; - iRepeatRect.iBr=aPointer.iPosition+TPoint(1,1); - StartNextRepeatTest(); - } - break; - case KStateWaitingForTest6: - if (aPointer.iType==TPointerEvent::EButton1Down) - { - iRepeatRect.iTl=aPointer.iPosition+TPoint(KRepeatRectXExtra,KRepeatRectYExtra); - iRepeatRect.iBr=aPointer.iPosition+TPoint(2*KRepeatRectXExtra,2*KRepeatRectYExtra); - StartNextRepeatTest(); - } - break; - case KStateTesting1: - { - TBool isDrag=(aPointer.iType==TPointerEvent::EDrag); - TestFailed(isDrag); - if (isDrag) - { - iTest->SimulatePointer(TRawEvent::EButton1Down,aPointer.iPosition.iX,aPointer.iPosition.iY); - iTest->SimulatePointer(TRawEvent::EButton1Up,aPointer.iPosition.iX,aPointer.iPosition.iY); - } - } - break; - case KStateTesting2: - if (aPointer.iType==TPointerEvent::EDrag) - SetState(KStateWaitingForTest3); - else - TestFailed(); - break; - case KStateTesting3: - if (aPointer.iType==TPointerEvent::EButton1Up) - SetState(KStateWaitingForTest4); - else - TestFailed(); - break; - case KStateTesting4: - if (aPointer.iType==TPointerEvent::EButton1Up) - SetState(KStateWaitingForTest5); - else - TestFailed(); - break; - case KStateTesting5: - if (aPointer.iType==TPointerEvent::EButton1Up) - SetState(KStateWaitingForTest6); - else if (aPointer.iType!=TPointerEvent::EDrag) - TestFailed(); - break; - case KStateTesting6: - if (aPointer.iType==TPointerEvent::EDrag) - { - //#if !defined(__WINS__) // Can't emulate touching dig when switched off under WINS - // if (iTest->Digitiser()) - SetState(KStateWaitingForTest7); - /* else - #endif - SetState(KStateWaitingForTest8);*/ - } - else - TestFailed(); - break; - case KStateWaitingForTest7: - if (aPointer.iType==TPointerEvent::EButton1Down || aPointer.iType==TPointerEvent::ESwitchOn) - TestFailed(); - break; - case KStateTesting7: - if (aPointer.iType!=TPointerEvent::ESwitchOn) - TestFailed(); - else - SetState(KStateWaitingForTest8); - break; - case KStateTesting8: - break; - } - } - -void CPointerWindow::TestFailed(TBool aRetest/*=EFalse*/) - { - if (iState!=KStateFailed) - { - TInt oldState=iState; - iState=KStateFailed; - if (iTest->TestFailed(oldState,aRetest) || aRetest) - ResetTest(oldState); - } - } - -void CPointerWindow::WinKeyL(const TKeyEvent &aKey,const TTime &) - { -#if defined(LOGGING) - _LIT(KKey,"CPointerWindow::WinKeyL(Code=%d, ScanCode=%d) State=%d"); - LogMessageText.Format(KKey,aKey.iCode,aKey.iScanCode,iState); - TheClient->LogMessage(LogMessageText); -#endif - if (aKey.iCode==EKeyEscape) - FinishedTests(); // Simply skip this test if the Escape key is pressed - } - -void CPointerWindow::SwitchOn(const TTime &) - { -#if defined(LOGGING) - _LIT(KOn,"CPointerWindow::SwitchOn() State=%d"); - LogMessageText.Format(KOn,iState); - TheClient->LogMessage(LogMessageText); -#endif - if (iState==KStateWaitingForTest7) - SetState(KStateTesting7); - else - TestFailed(); - } - -void CPointerWindow::SendEvent() - { -#if defined(LOGGING) - _LIT(KSend,"CPointerWindow::SendEvent() State=%d"); - LogMessageText.Format(KSend,iState); - TheClient->LogMessage(LogMessageText); -#endif - switch (iState) - { - case KStateWaitingForTest1: - iTest->SimulatePointer(TRawEvent::EButton1Down,iTl.iX+iSize.iWidth/4,iTl.iY+iSize.iHeight/4); - break; - //case KStateTesting1: //Do Nothing - // break; - case KStateWaitingForTest2: - iTest->SimulatePointer(TRawEvent::EButton1Up,iTl.iX+iSize.iWidth/4,iTl.iY+iSize.iHeight/4); - iTest->SimulatePointer(TRawEvent::EButton1Down,iTl.iX+iSize.iWidth/2,iTl.iY+iSize.iHeight/4); - break; - case KStateTesting2: - iTest->SimulatePointer(TRawEvent::EPointerMove,iTl.iX+5*iSize.iWidth/8,iTl.iY+iSize.iHeight/4+2); - iTest->SimulatePointer(TRawEvent::EPointerMove,iTl.iX+3*iSize.iWidth/4,iTl.iY+iSize.iHeight/4+4); - break; - case KStateWaitingForTest3: - iTest->SimulatePointer(TRawEvent::EButton1Up,iTl.iX+3*iSize.iWidth/4,iTl.iY+iSize.iHeight/4+4); - iTest->SimulatePointer(TRawEvent::EButton1Down,iTl.iX+iSize.iWidth/4,iTl.iY+iSize.iHeight/2); - break; - case KStateTesting3: - iTest->SimulatePointer(TRawEvent::EButton1Up,iTl.iX+iSize.iWidth/4,iTl.iY+iSize.iHeight/2); - break; - case KStateWaitingForTest4: - iTest->SimulatePointer(TRawEvent::EButton1Down,iTl.iX+iSize.iWidth/2,iTl.iY+iSize.iHeight/2); - iTest->SimulatePointer(TRawEvent::EPointerMove,iTl.iX+iSize.iWidth/2+3,iTl.iY+iSize.iHeight/2+1); - iTest->SimulatePointer(TRawEvent::EPointerMove,iTl.iX+iSize.iWidth/2+6,iTl.iY+iSize.iHeight/2+2); - iTest->SimulatePointer(TRawEvent::EPointerMove,iTl.iX+iSize.iWidth/2+9,iTl.iY+iSize.iHeight/2+3); - iTest->SimulatePointer(TRawEvent::EPointerMove,iTl.iX+iSize.iWidth/2+12,iTl.iY+iSize.iHeight/2+4); - break; - case KStateTesting4: - iTest->SimulatePointer(TRawEvent::EButton1Up,iTl.iX+iSize.iWidth/2+12,iTl.iY+iSize.iHeight/2+4); - break; - case KStateWaitingForTest5: - iTest->SimulatePointer(TRawEvent::EButton1Down,iTl.iX+iSize.iWidth/2,iTl.iY+3*iSize.iHeight/4); - iTest->SimulatePointer(TRawEvent::EPointerMove,iTl.iX+iSize.iWidth/2+3,iTl.iY+3*iSize.iHeight/4+1); - iTest->SimulatePointer(TRawEvent::EPointerMove,iTl.iX+iSize.iWidth/2+6,iTl.iY+3*iSize.iHeight/4+2); - iTest->SimulatePointer(TRawEvent::EPointerMove,iTl.iX+iSize.iWidth/2+9,iTl.iY+3*iSize.iHeight/4+3); - iTest->SimulatePointer(TRawEvent::EPointerMove,iTl.iX+iSize.iWidth/2+12,iTl.iY+3*iSize.iHeight/4+4); - break; - case KStateTesting5: - iTest->SimulatePointer(TRawEvent::EButton1Up,iTl.iX+iSize.iWidth/2+12,iTl.iY+3*iSize.iHeight/4+4); - break; - case KStateWaitingForTest6: - iTest->SimulatePointer(TRawEvent::EButton1Down,iTl.iX+3*iSize.iWidth/4,iTl.iY+3*iSize.iHeight/4); - break; - case KStateTesting6: - iTest->SimulatePointer(TRawEvent::EPointerMove,iTl.iX+3*iSize.iWidth/4+4,iTl.iY+3*iSize.iHeight/4+2); - iTest->SimulatePointer(TRawEvent::EPointerMove,iTl.iX+3*iSize.iWidth/4+8,iTl.iY+3*iSize.iHeight/4+4); - iTest->SimulatePointer(TRawEvent::EPointerMove,iTl.iX+3*iSize.iWidth/4+12,iTl.iY+3*iSize.iHeight/4+6); - iTest->SimulatePointer(TRawEvent::EPointerMove,iTl.iX+3*iSize.iWidth/4+16,iTl.iY+3*iSize.iHeight/4+8); - break; - case KStateWaitingForTest8: - iTest->SimulatePointer(TRawEvent::EButton1Down,iTl.iX+iSize.iWidth/2,iTl.iY+3*iSize.iHeight/4); - break; - case KStateTesting8: - break; - case KStateWaitingForTest7: - iTest->SimulatePointer(TRawEvent::EButton1Up,iTl.iX+3*iSize.iWidth/4+16,iTl.iY+3*iSize.iHeight/4+8); - iTest->SimulateEvent(TRawEvent::ESwitchOn); - iTest->SimulatePointer(TRawEvent::EPointerSwitchOn,iTl.iX+iSize.iWidth/2-1,iTl.iY+iSize.iHeight/2-1); - break; - //case KStateTesting7: //Do Nothing - // break; - /*case KStateFailed: - break; - case KStateFinished: - break;*/ - } - } - -// -// CGrabWindow // -// - -CGrabWindow::CGrabWindow(CTPointer *aTest) : iTest(aTest) - { - } - -void CGrabWindow::SetUpLD(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc) - { - ConstructExtLD(*parent,pos,size); - iTl=pos; - iSize=size; - Activate(); - AssignGC(aGc); - SetState(KGrabStateWaitingForDown); - } - -void CGrabWindow::Draw() - { - iGc->Clear(); - iGc->DrawRect(Size()); - TBuf<0x80> buf; - switch(iState) - { - case KGrabStateWaitingForDown: - case KGrabStateWaitingForDown2: - case KGrabStateWaitingForDown5: - { - _LIT(Draw1,"Press the pointer inside the window"); - buf.Copy(Draw1); - } - break; - case KGrabStateWaitingForDown3: - case KGrabStateWaitingForUp3a: - { - _LIT(Draw2,"Press and release the pointer inside the window"); - buf.Copy(Draw2); - } - break; - case KGrabStateWaitingForDragOut: - { - _LIT(Draw3,"Drag the pointer outside into the outside window"); - buf.Copy(Draw3); - } - break; - case KGrabStateWaitingForUp: - case KGrabStateWaitingForUp2b: - case KGrabStateWaitingForUp5: - { - _LIT(Draw4,"Release the pointer"); - buf.Copy(Draw4); - } - break; - case KGrabStateWaitingForDown4: - { - _LIT(Draw5,"Press then release the pointer"); - buf.Copy(Draw5); - } - break; - default:; - } - iGc->DrawText(buf,TPoint(10,20)); - } - -void CGrabWindow::PointerL(const TPointerEvent &aPointer,const TTime&) - { -#if defined(LOGGING) - _LIT(KPointer,"CGrabWindow::PointerL(Type=%d, Pos=(%d,%d), ParPos=(%d,%d), Mod=0x%x) State=%d"); - LogMessageText.Format(KPointer,aPointer.iType,aPointer.iPosition.iX,aPointer.iPosition.iY,aPointer.iParentPosition.iX,aPointer.iParentPosition.iY,aPointer.iModifiers,iState); - TheClient->LogMessage(LogMessageText); -#endif - switch(iState) - { - case KGrabStateWaitingForDown: - if (aPointer.iType==TPointerEvent::EButton1Down) - SetState(KGrabStateWaitingForDragOut); - break; - case KGrabStateWaitingForDragOut: - if (aPointer.iType!=TPointerEvent::EDrag) - TestFailed(); - else - { - if (!TRect(Size()).Contains(aPointer.iPosition)) - SetState(KGrabStateWaitingForUp); - } - break; - case KGrabStateWaitingForUp: - if (aPointer.iType==TPointerEvent::EDrag) - break; - if (aPointer.iType==TPointerEvent::EButton1Up) - SetState(KGrabStateWaitingForDown2); - else - TestFailed(); - break; - case KGrabStateWaitingForDown2: - if (aPointer.iType!=TPointerEvent::EButton1Down) - TestFailed(); - else - { - iTest->GrabWin2()->BaseWin()->ClaimPointerGrab(); - iTest->GrabWin2()->BaseWin()->ClaimPointerGrab(); // Call twice to check it's harmless - SetState(KGrabStateWaitingForUp2a); - } - break; - case KGrabStateWaitingForUp2a: - SetState(KGrabStateWaitingForDrag2); - break; - case KGrabStateWaitingForDrag2: - break; - case KGrabStateWaitingForUp2b: - TestFailed(); - break; - case KGrabStateWaitingForDown3: - if (aPointer.iType!=TPointerEvent::EButton1Down) - TestFailed(); - else - SetState(KGrabStateWaitingForUp3a); - break; - case KGrabStateWaitingForUp3a: - if (aPointer.iType==TPointerEvent::EButton1Up) - { - iTest->GrabWin2()->BaseWin()->ClaimPointerGrab(); - SetState(KGrabStateWaitingForUp3b); - } - break; - case KGrabStateWaitingForUp3b: - TestFailed(); - break; - case KGrabStateWaitingForDown5: - if (aPointer.iType!=TPointerEvent::EButton1Down) - TestFailed(); - else - { - iTest->GrabWin2()->BaseWin()->ClaimPointerGrab(EFalse); - SetState(KGrabStateWaitingForDrag5); - } - break; - case KGrabStateWaitingForDrag5: - if (aPointer.iType==TPointerEvent::EButton1Up) - TestFailed(); - break; - case KGrabStateWaitingForUp5: - TestFailed(); - break; - case KGrabStateWaitingForDown4: - iWin.Close(); // Close the window with the grab captured in it - SetState(KGrabStateWaitingForUp4); - break; - case KGrabStateFinished: - break; - } - } - -void CGrabWindow::ResetTest() - { - TheClient->iWs.PurgePointerEvents(); - SetState(KGrabStateWaitingForDown); - } - -void CGrabWindow::Pointer2(const TPointerEvent &aPointer) - { - switch(iState) - { - case KGrabStateWaitingForDrag2: - { - if (aPointer.iType==TPointerEvent::EDrag) - { - SetState(KGrabStateWaitingForUp2b); - } - else - { - if (iTest->TestFailed(iState)) - ResetTest(); - } - break; - } - case KGrabStateWaitingForUp2b: - if (aPointer.iType==TPointerEvent::EDrag) // Harmless - break; - if (aPointer.iType==TPointerEvent::EButton1Up) - SetState(KGrabStateWaitingForDown3); - else - TestFailed(); - break; - case KGrabStateWaitingForUp3b: - if (aPointer.iType==TPointerEvent::EButton1Up) - SetState(KGrabStateWaitingForDown5); - else - TestFailed(); - break; - case KGrabStateWaitingForUp4: - FinishedTests(); - break; - case KGrabStateWaitingForDrag5: - { - if (aPointer.iType==TPointerEvent::EDrag) - SetState(KGrabStateWaitingForUp5); - else if (iTest->TestFailed(iState)) - ResetTest(); - break; - } - case KGrabStateWaitingForUp5: - if (aPointer.iType==TPointerEvent::EDrag) // Harmless - break; - if (aPointer.iType==TPointerEvent::EButton1Up) - SetState(KGrabStateWaitingForDown4); - else - TestFailed(); - break; - default:; - } - } - -void CGrabWindow::SetState(TInt aState) - { - iState=aState; - if (aState!=KGrabStateWaitingForUp4) - iWin.Invalidate(); - TheClient->WaitForRedrawsToFinish(); - SendEvent(); - } - -void CGrabWindow::TestFailed() - { -#if defined(LOGGING) - _LIT(KFail,"CGrabWindow::TestFailed() State=%d"); - LogMessageText.Format(KFail,iState); - TheClient->LogMessage(LogMessageText); -#endif - if (iState!=KStateFailed) - { - TInt oldState=iState; - iState=KStateFailed; - if (iTest->TestFailed(oldState)) - ResetTest(); - } - } - -void CGrabWindow::FinishedTests() - { - iState=KGrabStateFinished; - } - -void CGrabWindow::WinKeyL(const TKeyEvent &aKey,const TTime &) - { -#if defined(LOGGING) - _LIT(KKey,"CGrabWindow::WinKeyL(Code=%d, ScanCode=%d) State=%d"); - LogMessageText.Format(KKey,aKey.iCode,aKey.iScanCode,iState); - TheClient->LogMessage(LogMessageText); -#endif - if (aKey.iCode==EKeyEscape) - FinishedTests(); // Simply skip this test if the Escape key is pressed - } - -void CGrabWindow::SendEvent() - { - switch (iState) - { - case KGrabStateWaitingForDown: - iTest->SimulatePointer(TRawEvent::EButton1Down,iTl.iX+iSize.iWidth/3,iTl.iY+iSize.iHeight/3); - break; - case KGrabStateWaitingForDragOut: - iTest->SimulatePointer(TRawEvent::EPointerMove,iTl.iX+iSize.iWidth/6,iTl.iY+iSize.iHeight/6); - iTest->SimulatePointer(TRawEvent::EPointerMove,iTl.iX+1,iTl.iY+1); - iTest->SimulatePointer(TRawEvent::EPointerMove,iTl.iX-10,iTl.iY-10); - break; - case KGrabStateWaitingForUp: - iTest->SimulatePointer(TRawEvent::EPointerMove,iTl.iX-8,iTl.iY-8); - iTest->SimulatePointer(TRawEvent::EButton1Up,iTl.iX-5,iTl.iY-5); - break; - case KGrabStateWaitingForDown2: - iTest->SimulatePointer(TRawEvent::EButton1Down,iTl.iX+2*iSize.iWidth/3,iTl.iY+iSize.iHeight/3); - break; - /*case KGrabStateWaitingForUp2a: //Don't need to do anything for these cases - break; - case KGrabStateWaitingForDrag2: - break;*/ - case KGrabStateWaitingForUp2b: - iTest->SimulatePointer(TRawEvent::EPointerMove,iTl.iX+2*iSize.iWidth/3-3,iTl.iY+iSize.iHeight/3+3); - iTest->SimulatePointer(TRawEvent::EButton1Up,iTl.iX+2*iSize.iWidth/3,iTl.iY+iSize.iHeight/3); - break; - case KGrabStateWaitingForDown3: - iTest->SimulatePointer(TRawEvent::EButton1Down,iTl.iX+2*iSize.iWidth/3,2*iTl.iY+iSize.iHeight/3); - break; - case KGrabStateWaitingForUp3a: - iTest->SimulatePointer(TRawEvent::EButton1Up,iTl.iX+2*iSize.iWidth/3,2*iTl.iY+iSize.iHeight/3); - break; - case KGrabStateWaitingForUp3b: - break; - case KGrabStateWaitingForDown4: - iTest->SimulatePointer(TRawEvent::EButton1Down,iTl.iX+2*iSize.iWidth/5,iTl.iY+iSize.iHeight/3); - break; - case KGrabStateWaitingForUp4: - iTest->SimulatePointer(TRawEvent::EButton1Up,iTl.iX+2*iSize.iWidth/5,iTl.iY+iSize.iHeight/3); - break; - case KGrabStateWaitingForDown5: - iTest->SimulatePointer(TRawEvent::EButton1Down,iTl.iX+iSize.iWidth/3,2*iTl.iY+iSize.iHeight/3); - break; - case KGrabStateWaitingForUp5: - iTest->SimulatePointer(TRawEvent::EButton1Up,iTl.iX+iSize.iWidth/3,2*iTl.iY+iSize.iHeight/3); - break; - //case KGrabStateWaitingForDrag5: //Don't need to do anything for these cases - // break; - /*case KStateFailed: - break; - case KGrabStateFinished: - break;*/ - default:; - } - TheClient->iWs.Flush(); - } - - -// -// CGrabWindow2, used as part of grab tests // -// - -CGrabWindow2::CGrabWindow2(CGrabWindow *aWindow) : iGrabWindow(aWindow) - { - } - -void CGrabWindow2::Draw() - { - iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - iGc->SetBrushColor(TRgb::Gray4(2)); - iGc->DrawRect(Size()); - } - -void CGrabWindow2::PointerL(const TPointerEvent &aPointer,const TTime&) - { -#if defined(LOGGING) - _LIT(KPointer,"CGrabWindow2::PointerL(Type=%d, Pos=(%d,%d), ParPos=(%d,%d), Mod=0x%x)"); - LogMessageText.Format(KPointer,aPointer.iType,aPointer.iPosition.iX,aPointer.iPosition.iY,aPointer.iParentPosition.iX,aPointer.iParentPosition.iY,aPointer.iModifiers); - TheClient->LogMessage(LogMessageText); -#endif - iGrabWindow->Pointer2(aPointer); - } - -// -// CTPointTest // -// - -CTPointer::CTPointer(CTestStep* aStep) : CTWsGraphicsBase(aStep) - { - iState = 0; - } - - -CTPointer::~CTPointer() - { - HAL::Set(HALData::EPenDisplayOn,iOldPointerState); - delete iRepeatWin; - delete iGrabWin; - delete iGrabWin2; - Client()->ResetFocus(); - delete iTimeOut; - } - -void CTPointer::ConstructL() - { - iTimeOut=new(ELeave) CTimeOut(); - iTimeOut->ConstructL(); - iTimeOut->Start(KTimeOutAfter,TCallBack(CTPointer::TimeOut,this)); - - TheClient->iWs.SetPointerCursorArea(iTest->iNormalPointerCursorArea); - iRepeatWin=new(ELeave) CPointerWindow(this); - TSize screenSize(Client()->iScreen->SizeInPixels()); - if (TestBase()->ConfigurationSupportsPointerEventTesting()) - { - iRepeatWin->SetUpLD(TPoint(screenSize.iWidth/8,screenSize.iHeight/8),TSize(screenSize.iWidth*3/4,screenSize.iHeight*3/4),Client()->iGroup,*Client()->iGc); - } - Client()->iGroup->SetCurrentWindow(iRepeatWin); - iNoDigitiser=EFalse; - TInt err=HAL::Get(HALData::EPenDisplayOn,iOldPointerState); - if (err==KErrNotSupported) - iNoDigitiser=ETrue; - else if (err==KErrNone) - err=HAL::Set(HALData::EPenDisplayOn,ETrue); - if (err==KErrNotSupported) - iNoDigitiser=(!iOldPointerState); - else - { - TEST(err==KErrNone); - if (err!=KErrNone) - INFO_PRINTF3(_L("HAL::Set(HALData::EPenDisplayOn,ETrue) return value - Expected: %d, Actual: %d"), KErrNone, err); - } - - } - -TInt CTPointer::TimeOut(TAny* aTest) //static - { - static_cast(aTest)->TimeOut(); - return(KErrNone); - } - -void CTPointer::TimeOut() - { - TLogMessageText buf; - _LIT(KPointerTimeOut,"TIMEOUT: Pointer Test, %d, %S"); - buf.AppendFormat(KPointerTimeOut,iState,&(iTest->iSubTitle)); - TheClient->LogMessage(buf); - ++iTimeOutCount; - if (!TestFailed(-1) && iState<2) - { - iTimeOut->Start(KTimeOutAfter,TCallBack(CTPointer::TimeOut,this)); - } - } - -TBool CTPointer::TestFailed(TInt aCase,TBool aRetry/*=EFalse*/) - { - _LIT(KPointerTest,": Pointer Test, %d, %S, Case %d"); - _LIT(KRetry,"Retry"); - _LIT(KFail,"FAIL"); - TLogMessageText buf; - TInt ret=0; - if (aRetry) - buf.Append(KRetry); - else - { - ret=1; - buf.Append(KFail); - } - buf.AppendFormat(KPointerTest,iState,&(iTest->iSubTitle),aCase); - TheClient->LogMessage(buf); -#if !defined(DISABLE_FAIL_DIALOG) - if (!aRetry) - { - __DEBUGGER(); - TRAPD(err,ret=doTestFailedL()); - } -#endif - switch(ret) - { - case 0: - return(ETrue); // Re-try test - case 1: - break; - } - return(EFalse); - } - -TInt CTPointer::doTestFailedL() - { - //_LIT(Failed,"Pointer repeat test failed"); - _LIT(Retest,"Retest"); - _LIT(Fail,"Fail"); - CTDialog *dialog=new(ELeave) CTDialog(); - dialog->SetNumButtons(2); - dialog->SetButtonText(0,Retest); - dialog->SetButtonText(1,Fail); - dialog->ConstructLD(*Client()->iGroup,*Client()->iGc); - dialog->SetTitle(_L("Pointer repeat test failed")); - dialog->SetFlags(CTDialog::EDialogWaitForButtonUp); - return dialog->Display(); - } - -CGrabWindow2 *CTPointer::GrabWin2() const - { - return(iGrabWin2); - } - -void CTPointer::StartGrabTestL() - { - iGrabWin=new(ELeave) CGrabWindow(this); - iGrabWin2=new(ELeave) CGrabWindow2(iGrabWin); -// - TSize screenSize(Client()->iScreen->SizeInPixels()); - iGrabWin2->SetUpL(TPoint(screenSize.iWidth/8,screenSize.iHeight/8),TSize(screenSize.iWidth*3/4,screenSize.iHeight*3/4),Client()->iGroup,*Client()->iGc); - Client()->iGroup->SetCurrentWindow(iGrabWin2); -// - iGrabWin->SetUpLD(TPoint(screenSize.iWidth/4,screenSize.iHeight/4),TSize(screenSize.iWidth/2,screenSize.iHeight/2),Client()->iGroup,*Client()->iGc); - Client()->iGroup->SetCurrentWindow(iGrabWin); -// - } - - -void CTPointer::RunTestCaseL(TInt /*aCurTestCase*/) - { - _LIT(Repeat,"Repeat tests"); - _LIT(Grab,"Grab tests"); - - iTest->iState=iState; - - if (!TestBase()->ConfigurationSupportsPointerEventTesting()) - { - INFO_PRINTF1(_L("Test skipped because config does not support pointer event testing")); - TestComplete(); - return; - } - - ((CTPointerStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); - switch(iState) - { - case 0: - ((CTPointerStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - iTest->LogSubTest(Repeat); - iState++; - break; -/** - - @SYMTestCaseID GRAPHICS-WSERV-0310 - - @SYMDEF DEF081259 - - @SYMTestCaseDesc Test pointer event handling - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions Simulate pointer events and check the events are then handled correctly - - @SYMTestExpectedResults Pointer events are handled correctly - -*/ - case 1: - ((CTPointerStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0310")); - iTest->LogSubTest(Grab); - - StartGrabTestL(); - iState++; - break; - default: - ((CTPointerStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - ((CTPointerStep*)iStep)->CloseTMSGraphicsStep(); - iTimeOut->Cancel(); - if (iTimeOutCount>0) TEST(EFalse); - if (iTest->IsFullRomL()) User::After(5000000); - TestComplete(); - } - ((CTPointerStep*)iStep)->RecordTestResultL(); - } - - -__WS_CONSTRUCT_STEP__(Pointer) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TPointer.H --- a/windowing/windowserver/tauto/TPointer.H Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,167 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef __TPOINTER_H__ -#define __TPOINTER_H__ - -#include -#include -#include -#include "../tlib/testbase.h" -#include "AUTO.H" -#include "TGraphicsHarness.h" - -class CTPointer; -class CGrabWindow; - -class CPointerWindow : public CTWin - { - enum {KRepeatMargin=200000}; // 0.2 Seconds - enum {KRepeatCount=4}; - enum {KRepeatIntervalIncrements=100000}; - enum {KRepeatRectXExtra=50}; - enum {KRepeatRectYExtra=50}; - enum {KStateWaitingForTest1,KStateFailed,KStateTesting1, - KStateWaitingForTest2,KStateTesting2, - KStateWaitingForTest3,KStateTesting3, - KStateWaitingForTest4,KStateTesting4, - KStateWaitingForTest5,KStateTesting5, - KStateWaitingForTest6,KStateTesting6, - KStateWaitingForTest8,KStateTesting8, - KStateWaitingForTest7,KStateTesting7, - KStateFinished}; -public: - CPointerWindow(CTPointer *aTest); - void SetUpLD(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc); - void Draw(); - void StartNextRepeatTest(); - void QueueNextRepeat(); - void PointerL(const TPointerEvent &aPointer,const TTime&); - void WinKeyL(const TKeyEvent &aKey,const TTime &aTime); -private: - void SwitchOn(const TTime &); - void ResetTest(TInt aState); - void SetState(TInt aState); - void FinishedTests(); - void TestFailed(TBool aRetest=EFalse); - void SendEvent(); -private: - CTPointer *iTest; - TInt iRepeatCount; - TInt iState; - TTimeIntervalMicroSeconds32 iInterval; - TTime iPrevTime; - TRect iRepeatRect; - TPoint iTl; - TSize iSize; - }; - -class CGrabWindow2 : public CTWin - { -public: - CGrabWindow2(CGrabWindow *aWindow); - void SetUpLD(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc); -private: - void Draw(); - void PointerL(const TPointerEvent &aPointer,const TTime&); -private: - CGrabWindow *iGrabWindow; - }; - -class CGrabWindow : public CTWin - { - enum {KGrabStateWaitingForDown,KGrabStateWaitingForDragOut,KGrabStateWaitingForUp,KGrabStateFinished, - KGrabStateWaitingForDown2,KGrabStateWaitingForUp2a,KGrabStateWaitingForDrag2,KGrabStateWaitingForUp2b, - KGrabStateWaitingForDown3,KGrabStateWaitingForUp3a,KGrabStateWaitingForUp3b, - KGrabStateWaitingForDown4,KGrabStateWaitingForUp4, - KGrabStateWaitingForDown5,KGrabStateWaitingForUp5,KGrabStateWaitingForDrag5, - KStateFailed}; -public: - CGrabWindow(CTPointer *aTest); - void Pointer2(const TPointerEvent &aPointer); - void SetUpLD(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc); - void WinKeyL(const TKeyEvent &aKey,const TTime &aTime); -private: - void Draw(); - void SetState(TInt aState); - void ResetTest(); - void PointerL(const TPointerEvent &aPointer,const TTime&); - void TestFailed(); - void FinishedTests(); - void SendEvent(); -private: - TInt iState; - CTPointer *iTest; - TPoint iTl; - TSize iSize; - }; - - -class CTPointer : public CTWsGraphicsBase - { -public: - enum {KTimeOutAfter=20000000}; //20secs -public: - CTPointer(CTestStep* aStep); - ~CTPointer(); - void ConstructL(); - - TBool TestFailed(TInt aCase,TBool aRetry=EFalse); - void StartGrabTestL(); - static TInt TimeOut(TAny* aTest); - void TimeOut(); - CGrabWindow2 *GrabWin2() const; - inline TBool Digitiser() const {return !iNoDigitiser;} - inline void SimulatePointer(TRawEvent::TType aType, TInt aX, TInt aY){iTest->SimulatePointer(aType, aX, aY);} - inline void SimulateEvent(TRawEvent::TType aType){iTest->SimulateEvent(aType);} -protected: - virtual void RunTestCaseL(TInt aCurTestCase); -private: - TInt doTestFailedL(); - inline TestClient* Client() {return TheClient;} - TInt iState; - -private: - CTimeOut* iTimeOut; - TInt iTimeOutCount; - CPointerWindow *iRepeatWin; - CGrabWindow *iGrabWin; - CGrabWindow2 *iGrabWin2; - TSize iWinSize; - //TInt iState; - TBool iOldPointerState; - TBool iNoDigitiser; - }; - - -class CTPointerStep : public CTGraphicsStep - { -public: - CTPointerStep(); -protected: - //from CTGraphicsStep - virtual CTGraphicsBase* CreateTestL(); - }; - -_LIT(KTPointerStep,"TPointer"); - - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TRECTLIST.CPP --- a/windowing/windowserver/tauto/TRECTLIST.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,136 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Generate a list of rectangles to be used as parameters for graphics tests -// -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - - -#include "TRECTLIST.H" - -CTRectList::CTRectList(CTestStep* aStep) : CTWsGraphicsBase(aStep) - { - } - -CTRectList::~CTRectList() - { - } - -void CTRectList::ConstructL() - { - TheGc->Activate(*BaseWin->Win()); - TheGc->SetBrushColor(TRgb::Gray16(14)); - TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - TheGc->SetPenStyle(CGraphicsContext::ENullPen); - TheGc->DrawRect(TRect(BaseWin->Win()->Size())); - TInt scale=16; - TSize size(TestWin->Size()); - TSize scaleSize(size.iWidth/scale,size.iHeight/scale); - iOffset1=TPoint((size.iWidth-scaleSize.iWidth)/2,(size.iWidth-scaleSize.iHeight)/2); - TheGc->DrawRect(TRect(iOffset1,scaleSize)); - TheGc->Deactivate(); -// - TheGc->Activate(*TestWin->Win()); - TheGc->SetBrushColor(TRgb::Gray16(15)); - TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - TheGc->SetPenStyle(CGraphicsContext::ENullPen); - TheGc->DrawRect(TRect(TestWin->Win()->Size())); - { - TInt scale=1; - TSize size(TestWin->Size()); - TSize scaleSize(size.iWidth/scale,size.iHeight/scale); - iOffset2=TPoint((size.iWidth-scaleSize.iWidth)/2,(size.iWidth-scaleSize.iHeight)/2); - TheGc->DrawRect(TRect(iOffset2,scaleSize)); - TheGc->Deactivate(); - } - } - -void CTRectList::RunTestCaseL(TInt /*aCurTestCase*/) - { - ((CTRectListStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); - switch(++iTest->iState) - { - /** -@SYMTestCaseID GRAPHICS-WSERV-0028 - -@@SYMDEF DEF081259 - -@SYMTestCaseDesc Draw rectangles from a list in two different positions - on the screen - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Draw a list of rectangles to the screen - -@SYMTestExpectedResults Rectangles are drawn without error -*/ - case 1: - ((CTRectListStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0028")); - iTest->LogSubTest(_L("RectListCheck")); - { - TheGc->Activate(*BaseWin->Win()); - TheGc->SetPenColor(TRgb::Gray16(7)); - TInt scale=16; - for(TInt index=0;indexiTestRects.Count3();index++) - { - TRect rect=iTest->iTestRects[index]; - rect.iTl.iX/=scale; - rect.iTl.iY/=scale; - rect.iBr.iX/=scale; - rect.iBr.iY/=scale; - rect.Move(iOffset1); - TheGc->DrawRect(rect); - } - TheGc->Deactivate(); - } - { - TheGc->Activate(*TestWin->Win()); - TheGc->SetPenColor(TRgb::Gray16(7)); - TInt scale=1; - for(TInt index=0;indexiTestRects.Count3();index++) - { - TRect rect=iTest->iTestRects[index]; - rect.iTl.iX/=scale; - rect.iTl.iY/=scale; - rect.iBr.iX/=scale; - rect.iBr.iY/=scale; - rect.Move(iOffset2); - TheGc->DrawRect(rect); - } - TheClient->iWs.Flush(); - TheGc->Deactivate(); - } - TEST(ETrue); - break; - case 2: - ((CTRectListStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - iTest->LogSubTest(_L("Panic")); - break; - case 3: - ((CTRectListStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - ((CTRectListStep*)iStep)->CloseTMSGraphicsStep(); - TestComplete(); - break; - } - ((CTRectListStep*)iStep)->RecordTestResultL(); - } - -__WS_CONSTRUCT_STEP__(RectList) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TRECTLIST.H --- a/windowing/windowserver/tauto/TRECTLIST.H Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,60 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Generate a list of rectangles to be used as parameters for graphics tests -// -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef __TRECTLIST_H__ -#define __TRECTLIST_H__ - -#include -#include -#include "../tlib/testbase.h" -#include "AUTO.H" -#include "TGraphicsHarness.h" - -class CTRectList : public CTWsGraphicsBase - { -public: - CTRectList(CTestStep* aStep); - ~CTRectList(); - void ConstructL(); -protected: -//from CTGraphicsStep - virtual void RunTestCaseL(TInt aCurTestCase); -private: - TPoint iOffset1; - TPoint iOffset2; - TSize iWinSize; - }; - -class CTRectListStep : public CTGraphicsStep - { -public: - CTRectListStep(); -protected: - //from CTGraphicsStep - virtual CTGraphicsBase* CreateTestL(); - }; - -_LIT(KTRectListStep,"TRectList"); - - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TREDRAW.CPP --- a/windowing/windowserver/tauto/TREDRAW.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1586 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Window redraw/validate/invalidate tests -// -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include "TREDRAW.H" - -LOCAL_D TSize FullScreenModeSize; - -const TRgb KRed = TRgb(255,0,0); -const TRgb KBlack = TRgb(0,0,0); -const TRgb KWhite = TRgb(255,255,255); -const TRgb KTransBisque = TRgb(255,228,196,128); -const TRgb KTransLightSalmon = TRgb(255,160,122,128); -const TRgb KLightSteelBlue = TRgb(176,196,222); -const TRgb KCadetBlue = TRgb(95,158,160); - -TInt CTRedrawOrderWindow::iRedrawNumber=0; - -#define InvalidRegionLogging -#if defined(InvalidRegionLogging) -#define BLOG_MESSAGE(p) (const_cast(&iGraphicsTest))->LogMessage(((TText8*)__FILE__), __LINE__,(p)) -#endif - -// -// // -// - -CTCheckDefectWin* CTCheckDefectWin::NewL(TPoint aPos,TSize aWinSize) - { - CTCheckDefectWin* win=new(ELeave) CTCheckDefectWin; - win->ConstructExtLD(*TheClient->iGroup,aPos,aWinSize); - win->BaseWin()->SetRequiredDisplayMode(EColor256); - win->AssignGC(*TheClient->iGc); - win->BaseWin()->SetShadowDisabled(ETrue); - win->BaseWin()->SetShadowHeight(0); - TheClient->Flush(); - return win; - } - -CRedrawWindow::CRedrawWindow(CTRedrawTest *aTest) : CTWin(), iTest(aTest) - { - } - -CRedrawWindow::~CRedrawWindow() - { - iInvalid.Close(); - } - -void CRedrawWindow::Draw() - { - ReceivedDrawRequest(); - DrawPattern(iTest->WinContent()); - } - -void CRedrawWindow::ReceivedDrawRequest() - { - iDrawRequests++; - } - -TInt CRedrawWindow::DrawRequests() const - { - return iDrawRequests; - } - -void CRedrawWindow::DrawPattern(TInt aPattern) - { - iGc->Clear(); - TPoint drawBase(-10,-20); - TSize drawSize(iSize.iWidth-2*drawBase.iX,iSize.iHeight-2*drawBase.iY); - TPoint offset=drawBase+iOffset; - switch(aPattern) - { - case EDrawGraphPaperlHatched: - { - iGc->DrawRect(TRect(drawBase,drawBase+drawSize)); - iGc->SetPenColor(TRgb(85,85,85)); - iGc->SetDrawMode(CGraphicsContext::EDrawModeXOR); - TInt xpos; - for(xpos=0;xposDrawLine(TPoint(xpos,0)+offset,TPoint(xpos,drawSize.iHeight)+offset); - TInt ypos; - for(ypos=0;yposDrawLine(TPoint(0,ypos)+offset,TPoint(drawSize.iWidth,ypos)+offset); - break; - } - case EDrawSlantingHatched: - { - iGc->SetPenColor(TRgb(255,255,255)); - iGc->SetDrawMode(CGraphicsContext::EDrawModeXOR); - for(TInt xpos=0;xposDrawLine(TPoint(xpos,0)+offset,TPoint(drawSize.iWidth,xpos*drawSize.iHeight/drawSize.iWidth)+offset); - iGc->DrawLine(TPoint(xpos,0)+offset,TPoint(0,drawSize.iHeight-xpos*drawSize.iHeight/drawSize.iWidth)+offset); - iGc->DrawLine(TPoint(xpos,drawSize.iHeight)+offset,TPoint(drawSize.iWidth,drawSize.iHeight-xpos*drawSize.iHeight/drawSize.iWidth)+offset); - iGc->DrawLine(TPoint(xpos,drawSize.iHeight)+offset,TPoint(0,xpos*drawSize.iHeight/drawSize.iWidth)+offset); - } - } - break; - case EDrawCenteredRectangle: - { - TRect rect(5,iSize.iHeight/4,iSize.iWidth-5,iSize.iHeight/2); - iGc->SetDrawMode(CGraphicsContext::EDrawModeXOR); - iGc->SetPenColor(TRgb(255,255,255)); - iGc->DrawRect(rect); - } - break; - default: - // Other pattern values requested are ignored - break; - } - } - -void CRedrawWindow::Reset() - { - iOffset=TPoint(0,0); - iWin.Invalidate(); - iInvalid.Clear(); - } - -/** - * Calculate the window region minus the region covered by the child - * window; this is the "visible region" - */ -void CRedrawWindow::VisibleRegion(RRegion &aRegion) - { - aRegion.Clear(); - aRegion.AddRect(TRect(Size())); - TRect child; - child.iTl=Child()->BaseWin()->InquireOffset(iWin); - child.iBr=child.iTl+Child()->Size(); - aRegion.SubRect(child); - } - - -void CRedrawWindow::ValidateAndClear() - { - Win()->Invalidate(); - Win()->BeginRedraw(); - iGc->Activate(*Win()); - iGc->Clear(); - iGc->Deactivate(); - Win()->EndRedraw(); - } - -void CRedrawWindow::ActivateAndDraw(TInt aPattern, TRegion *aRegion) - { - iGc->Activate(*Win()); - if (aRegion) - iGc->SetClippingRegion(*aRegion); - DrawPattern(aPattern); - iGc->Deactivate(); - } - -CReferenceComparisonRedrawWindow::CReferenceComparisonRedrawWindow(CTRedrawTest *aTest) : CRedrawWindow(aTest) - {} - -/** - * Prepare the invalid region. - * - * Update the invalid region with a rectangle where such a rectangle is minus - * any area covered by a child window. - * - * @param aRect Rectangle to be added to the invalid region - */ -void CReferenceComparisonRedrawWindow::PrepareInvalidation(const TRect &aRect) - { - RRegion clipped_visible; - VisibleRegion(clipped_visible); - clipped_visible.ClipRect(aRect); - iInvalid.Union(clipped_visible); - clipped_visible.Close(); - iInvalid.Tidy(); - } - -/** - * Mop up all pending invalid regions and simulate a Draw(). - * - * Normally, we would rely on WServ to call this window's Draw() method - * to obtain drawing operations to cover the currently invalid regions - * of the window. - * - * This method does that task by marking all invalid regions as clean and - * then performs the drawing required in the invalid portions of the screen. - * - * The purpose of this is to then allow a comparison to be made against a - * different window which does rely on the WServ framework calling back - * to do a Draw(). - * - * @post the window has no outstanding invalid regions - */ -void CReferenceComparisonRedrawWindow::PerformInvalidation() - { - for(TInt index=0;indexActivate(iWin); - iGc->SetClippingRegion(iInvalid); - DrawPattern(iTest->WinContent()); - iGc->Deactivate(); - iWin.EndRedraw(); - } - -CRedrawWindow2::CRedrawWindow2(CTRedrawTest *aTest) : CRedrawWindow(aTest) - { - } - -void CRedrawWindow2::Draw() - { - ReceivedDrawRequest(); - if (iClipped) - iGc->SetClippingRegion(iInvalid); - DrawPattern(iTest->WinContent()); - if (iClipped) - iGc->CancelClippingRegion(); - } - -/** - * Prepare the invalid region. - * @param aRect rectangle to be added to the invalid region - */ -void CRedrawWindow2::PrepareInvalidation(const TRect &aRect) - { - iInvalid.Clear(); - iInvalid.AddRect(aRect); - } - -/** - * Perform invalidation by setting the window's invalid region. - * - * The purpose of this method is to stimulate a call from WServ to the - * Draw() method of this class. - */ -void CRedrawWindow2::PerformInvalidation() - { - iWin.Invalidate(iInvalid.BoundingRect()); - } - -void CRedrawWindow2::Reset() - { - CRedrawWindow::Reset(); - iClipped=EFalse; - } - -CRedrawWindow3::CRedrawWindow3(CTRedrawTest *aTest) : CRedrawWindow(aTest) - { - } - -void CRedrawWindow3::Draw() - { - ReceivedDrawRequest(); - iGc->Clear(); - iGc->SetPenStyle(CGraphicsContext::ENullPen); - iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - iGc->SetBrushColor(TRgb(0,255,255)); - iGc->DrawRect(TRect(TPoint(0,0),TSize(50,50))); - } - -void CRedrawWindow3::PrepareInvalidation(const TRect &aRect) - { - iInvalid.Clear(); - iInvalid.AddRect(aRect); - } - -void CRedrawWindow3::PerformInvalidation() - { - iWin.Invalidate(iInvalid.BoundingRect()); - } - -void CRedrawWindow3::SetUp1L(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc) - { - ConstructL(*parent); - SetExtL(pos,size); - AssignGC(aGc); - } - -void CRedrawWindow3::Redraw(const TRect &aRect) - { - if(!isActive) - {//make an empty redraw - iWin.BeginRedraw(aRect); - iWin.EndRedraw(); - } - else - { - CTWin::Redraw(aRect); - } - } - -void CRedrawWindow3::Activate() - { - isActive = ETrue; - Win()->Activate(); - } - -// - -CTRedrawOrderWindow::CTRedrawOrderWindow(TInt aOrder, CTRedrawTest *aTest) : iTest(aTest), iOrder(aOrder) - {} - -CTRedrawOrderWindow* CTRedrawOrderWindow::NewLC(TInt aOrder,CTWinBase* aParent,const TPoint& aPos,const TSize& aSize,CTRedrawTest* aTest) - { - CTRedrawOrderWindow* self=new(ELeave) CTRedrawOrderWindow(aOrder,aTest); - CleanupStack::PushL(self); - self->SetUpL(aPos,aSize,aParent,*TheGc); - return self; - } - -void CTRedrawOrderWindow::Draw() - { - iGc->SetBrushColor(TRgb::Gray16(iOrder*2)); - iGc->Clear(); - } - -void CTRedrawOrderWindow::ResetRedrawNumber() - { - iRedrawNumber=0; - } - -void CTRedrawOrderWindow::Redraw(const TRect &aRect) - { - if (++iRedrawNumber!=iOrder) - iTest->Failed(iOrder); - CTWin::Redraw(aRect); - } - -// - -TInt DestructCallback(TAny *aParam) - { - ((CTRedrawTest *)aParam)->doDestruct(); - return(0); - } - -CTRedrawTest::CTRedrawTest(CTestStep* aStep): - CTWsGraphicsBase(aStep)//, iInvalidRegionChecker(*this) - {} - -void CTRedrawTest::doDestruct() - { - BaseWin->SetVisible(ETrue); - TestWin->SetVisible(ETrue); - delete iBaseRedrawWin; - delete iTestRedrawWin; - delete iBaseChildWin; - delete iTestChildWin; - } - -CTRedrawTest::~CTRedrawTest() - { - TCallBack callBack(DestructCallback,this); - TheClient->SetRedrawCancelFunction(callBack); - delete iInvalidRegionChecker; - } - -void CTRedrawTest::ConstructL() - { -#if defined(InvalidRegionLogging) - LOG_MESSAGE(_L(" CTRedrawTest::ConstructL()")); - LOG_MESSAGE4(_L(" Ex Wins 0x%08x, 0x%08x, 0x%08x"), BaseWin, TestWin, &(TheClient->StdLogWindow())); -#endif - - iInvalidRegionChecker = new(ELeave)CInvalidRegionChecker(*this); - User::LeaveIfError(iInvalidRegionChecker->AddExcludedWindow(BaseWin)); - User::LeaveIfError(iInvalidRegionChecker->AddExcludedWindow(TestWin)); - User::LeaveIfError(iInvalidRegionChecker->AddExcludedWindow(&(TheClient->StdLogWindow()))); - WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions); - - iWinContent=0; - BaseWin->SetVisible(EFalse); - TestWin->SetVisible(EFalse); - FullScreenModeSize=TheClient->iGroup->Size(); - TInt winWidth=(FullScreenModeSize.iWidth/3)-10; - TInt winHeight=FullScreenModeSize.iHeight-10; - iBaseRedrawWin=new(ELeave) CReferenceComparisonRedrawWindow(this); - iBaseRedrawWin->SetUpL(TPoint(FullScreenModeSize.iWidth/3+5,5),TSize(winWidth,winHeight),TheClient->iGroup,*TheClient->iGc); - iTestRedrawWin=new(ELeave) CRedrawWindow2(this); - iTestRedrawWin->SetUpL(TPoint(FullScreenModeSize.iWidth/3*2+5,5),TSize(winWidth,winHeight),TheClient->iGroup,*TheClient->iGc); - iBaseChildWin=new(ELeave) CBlankWindow(); - iBaseChildWin->SetUpL(TPoint(winWidth>>2,winHeight>>2),TSize(winWidth>>1,winHeight>>1),iBaseRedrawWin,*TheClient->iGc); - iTestChildWin=new(ELeave) CBlankWindow(); - iTestChildWin->SetUpL(TPoint(winWidth>>2,winHeight>>2),TSize(winWidth>>1,winHeight>>1),iTestRedrawWin,*TheClient->iGc); - -#if defined(InvalidRegionLogging) - LOG_MESSAGE5(_L(" In Wins %08x, %08x, %08x, %08x"), iBaseRedrawWin, iBaseChildWin, iTestRedrawWin, iTestChildWin); -#endif - - WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions); - -#if defined(InvalidRegionLogging) - LOG_MESSAGE(_L(" Done")); -#endif - } - -void CTRedrawTest::CheckRedrawWindows() - { - _LIT(KTest,"Redraw Test, SubTest %d "); - TBuf<64> buf; - buf.Format(KTest,iTest->iState); - CheckRect(iBaseRedrawWin,iTestRedrawWin,TRect(iBaseRedrawWin->Size()),buf); - } - -void CTRedrawTest::InvalidateTestWins(const TRect &aRect) - { - iBaseRedrawWin->PrepareInvalidation(aRect); - iTestRedrawWin->PrepareInvalidation(aRect); - iBaseRedrawWin->PerformInvalidation(); - iTestRedrawWin->PerformInvalidation(); - } - -inline TInt CTRedrawTest::WinContent() - { - return iWinContent; - } - -void CTRedrawTest::SetBackground(const TRgb &aRgb) - { - iBaseRedrawWin->iWin.SetBackgroundColor(aRgb); - iTestRedrawWin->iWin.SetBackgroundColor(aRgb); - } - -void CTRedrawTest::DumpRegion(const TRegion &aRegion) - { - _LIT(KLog,"RegionRect %d: (%d,%d,%d,%d)"); - for (TInt ii=0;iiiWin.Position(); - TSize screenSize=TheClient->iGroup->Size(); - iBaseRedrawWin->iWin.Invalidate(); - iTestRedrawWin->iWin.Invalidate(); - iTestRedrawWin->iWin.SetPosition(TPoint(10,10)); - iTestRedrawWin->iWin.SetPosition(TPoint(0,0)); - iTestRedrawWin->iWin.SetPosition(TPoint(-10,-10)); - iTestRedrawWin->iWin.SetPosition(TPoint(screenSize.iWidth-10,screenSize.iHeight-10)); - iTestRedrawWin->iWin.SetPosition(TPoint(screenSize.iWidth,screenSize.iHeight)); - iTestRedrawWin->iWin.SetPosition(TPoint(screenSize.iWidth+10,screenSize.iHeight+10)); - iTestRedrawWin->iWin.SetPosition(old); - RRegion baseInvalidRegion; - RRegion testInvalidRegion; - iBaseRedrawWin->iWin.GetInvalidRegion(baseInvalidRegion); - iTestRedrawWin->iWin.GetInvalidRegion(testInvalidRegion); - CompareRegionsL(baseInvalidRegion,testInvalidRegion); - baseInvalidRegion.Close(); - testInvalidRegion.Close(); - } - -void CTRedrawTest::GetInvalidRegionTestsL() - { - TSize stdWinSize(iTest->StdTestWindowSize()); - CArrayFixFlat* rectList=new(ELeave) CArrayFixFlat(3); - rectList->AppendL(TRect(1,1,5,2)); - rectList->AppendL(TRect(stdWinSize.iWidth>>1,stdWinSize.iHeight>>1,stdWinSize.iWidth,stdWinSize.iHeight)); - rectList->AppendL(TRect(2,0,4,5)); - TestGetInvalidRegionL(rectList); - rectList->Reset(); - rectList->AppendL(TRect(-1000,-1,10000,5)); - rectList->AppendL(TRect(0,0,stdWinSize.iWidth>>1,stdWinSize.iHeight>>1)); - rectList->AppendL(TRect(2,100,2*stdWinSize.iWidth,105)); - TestGetInvalidRegionL(rectList); - delete rectList; - } - -void CTRedrawTest::TestGetInvalidRegionL(const CArrayFixFlat *aRectList) - { - RRegion invalidRegion; - RRegion region; - iTestRedrawWin->iWin.BeginRedraw(); - iTestRedrawWin->iWin.EndRedraw(); - for (TInt index=0;indexCount();index++) - { - iTestRedrawWin->iWin.Invalidate((*aRectList)[index]); - region.AddRect((*aRectList)[index]); - } - //Currently WSERV includes areas under a child or other window in the invalid region - //This is arguable the incorrect thing to do - /*TRect subRect; - subRect.iTl=iTestChildWin->BaseWin()->InquireOffset(iTestRedrawWin->iWin); - subRect.SetSize(iTestChildWin->Size()); - region.SubRect(subRect);*/ - region.ClipRect(TRect(iTestRedrawWin->Size())); - iTestRedrawWin->iWin.GetInvalidRegion(invalidRegion); - CompareRegionsL(region,invalidRegion); - region.Close(); - invalidRegion.Close(); - } - -void CTRedrawTest::Failed(TInt aOrder) - { - _LIT(KLog,"Redraw Order Error, Window Drawn at Position %d should be drawn at Position %d"); - LOG_MESSAGE3(KLog,CTRedrawOrderWindow::RedrawNumber(),aOrder); - if (iRedrawNo==0) - iRedrawNo=CTRedrawOrderWindow::RedrawNumber(); - } - -void CTRedrawTest::CheckOrderL() - { - _LIT(KLog,"Fail in redraw order test, first position of error is %d"); - iRedrawNo=0; - CTRedrawOrderWindow* order1; - CTRedrawOrderWindow* order2; - CTRedrawOrderWindow* order3; - CTRedrawOrderWindow* order4; - CTRedrawOrderWindow* order5; - CTRedrawOrderWindow* order6; - CTRedrawOrderWindow* order7; - order6=CTRedrawOrderWindow::NewLC(6,TheClient->iGroup,TPoint(100,10),TSize(40,40),this); - order7=CTRedrawOrderWindow::NewLC(7,order6,TPoint(0,0),TSize(20,20),this); - order1=CTRedrawOrderWindow::NewLC(1,TheClient->iGroup,TPoint(10,10),TSize(60,40),this); - order4=CTRedrawOrderWindow::NewLC(4,order1,TPoint(20,0),TSize(20,40),this); - order5=CTRedrawOrderWindow::NewLC(5,order4,TPoint(0,0),TSize(20,20),this); - order2=CTRedrawOrderWindow::NewLC(2,order1,TPoint(0,0),TSize(20,40),this); - order3=CTRedrawOrderWindow::NewLC(3,order2,TPoint(0,0),TSize(20,20),this); - TheClient->iWs.Finish(); // Fix for DEF133199 - Intermittant failure with windows out of order - WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions); // Check order is correct after initial creation - TEST(order1!=NULL && order2!=NULL && order3!=NULL && order4!=NULL && order5!=NULL && order6!=NULL && order7!=NULL); // redundant check to shut up the compiler - TEST(iRedrawNo==0); - if (iRedrawNo>0) - LOG_MESSAGE2(KLog,iRedrawNo); - - CTRedrawOrderWindow::ResetRedrawNumber(); - iRedrawNo=0; - CTUser::Splat(TheClient,TRect(0,0,200,60),TRgb(0,0,0)); - TheClient->iWs.Flush(); - WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions); // Check it's still correct on subsequent redraws - TEST(iRedrawNo==0); - if (iRedrawNo>0) - LOG_MESSAGE2(KLog,iRedrawNo); - CTRedrawOrderWindow::ResetRedrawNumber(); - CleanupStack::PopAndDestroy(7,order6); - } - -// For reproducing INC049554 -void CTRedrawTest::CheckDefectINC049554L() - { - if(TransparencySupportedL() == KErrNotSupported) //the defect only happens when transparency enabled - return; - TSize screenSize=TheClient->iScreen->SizeInPixels(); - TPoint winPos(screenSize.iWidth/3,0); - TSize winSize(screenSize.iWidth/3,screenSize.iHeight); - CTCheckDefectWin* lowerWin=CTCheckDefectWin::NewL(winPos,winSize); - CleanupStack::PushL(lowerWin); - lowerWin->Activate(); - TheClient->Flush(); - WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions); - - winPos.iX+=screenSize.iWidth/12; - - CTCheckDefectWin* upperWin=CTCheckDefectWin::NewL(winPos,winSize); - CleanupStack::PushL(upperWin); - upperWin->Activate(); - TheClient->Flush(); - WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions); - - // Invalidate the lower win and while drawing its content, move top window - lowerWin->Invalidate(); - lowerWin->Win()->BeginRedraw(); - TheClient->iGc->Activate(*lowerWin->DrawableWin()); - TheClient->iGc->SetPenStyle(CGraphicsContext::ENullPen); - TheClient->iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - TheClient->iGc->SetBrushColor(TRgb(0,255,0)); - TheClient->iGc->DrawRect(TRect(TPoint(0,0),TSize(50,50))); - - winPos.iX+=screenSize.iWidth/12; - upperWin->SetExt(winPos,winSize); - - TheClient->iGc->SetBrushColor(TRgb(255,0,0)); - TheClient->iGc->DrawRect(TRect(TPoint(0,0),TSize(50,50))); - TheClient->iGc->Deactivate(); - lowerWin->Win()->EndRedraw(); - - TheClient->Flush(); - WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions); - - CleanupStack::PopAndDestroy(upperWin); - - // Create 2 transaprent windows, slightly over lapping the background window - winPos.iX=screenSize.iWidth/3; - TPoint winPosTop(winPos.iX-screenSize.iWidth/6,0); - TSize winSizeTop(screenSize.iWidth/3+screenSize.iWidth/6,screenSize.iHeight/2); - - CTCheckDefectWin* leftWin=CTCheckDefectWin::NewL(winPosTop,winSizeTop); - CleanupStack::PushL(leftWin); - leftWin->Win()->SetTransparencyAlphaChannel(); - leftWin->Win()->SetBackgroundColor(TRgb(0,0,0, 128)); - leftWin->Activate(); - TheClient->iWs.Finish(); - WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions); - - CTCheckDefectWin* rightWin=CTCheckDefectWin::NewL(winPos,winSizeTop); - CleanupStack::PushL(rightWin); - rightWin->Win()->SetTransparencyAlphaChannel(); - rightWin->Win()->SetBackgroundColor(TRgb(0,0,0, 128)); - rightWin->Activate(); - TheClient->iWs.Finish(); - WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions); - - lowerWin->Invalidate(); - lowerWin->Win()->BeginRedraw(); - TheClient->iGc->Activate(*lowerWin->DrawableWin()); - TheClient->iGc->SetPenStyle(CGraphicsContext::ENullPen); - TheClient->iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - TheClient->iGc->SetBrushColor(TRgb(0,255,0)); - TheClient->iGc->DrawRect(TRect(TPoint(0,0),TSize(50,50))); - - TheClient->iGc->SetBrushColor(TRgb(255,0,0)); - TheClient->iGc->DrawRect(TRect(TPoint(0,0),TSize(50,50))); - TheClient->iGc->Deactivate(); - lowerWin->Win()->EndRedraw(); - - TheClient->iWs.Finish(); - WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions); - - CleanupStack::PopAndDestroy(3,lowerWin); - } - - -TInt myKK=1; -_LIT(KSnap,"c:\\TestRect%2i.mbm"); -_LIT(KSnapE,"c:\\TestRect%2iErr.mbm"); -void CTRedrawTest::TestRect() - { - - TBuf<50> snapshotFileName; - snapshotFileName.Zero(); - CFbsBitmap *snapshot=new(ELeave) CFbsBitmap(); - CleanupStack::PushL(snapshot); - User::LeaveIfError(snapshot->Create(TheClient->iScreen->SizeInPixels(),TheClient->iScreen->DisplayMode())); - - User::LeaveIfError(TheClient->iScreen->CopyScreenToBitmap(snapshot)); - - TRect rect1=TRect(TPoint(),TSize(FullScreenModeSize.iWidth/2,FullScreenModeSize.iHeight)); - TRect rect2=TRect(TPoint(FullScreenModeSize.iWidth/2,0),TSize(FullScreenModeSize.iWidth/2,FullScreenModeSize.iHeight)); - TBool retVal = TheClient->iScreen->RectCompare(rect1,rect2); - - RDebug::Printf("Picture %i !!!: Rect1: (%i,%i)->(%i,%i) - Rect2: (%i,%i)->(%i,%i)",myKK, - rect1.iTl.iX,rect1.iTl.iY,rect1.iBr.iX,rect1.iBr.iY, - rect2.iTl.iX,rect2.iTl.iY,rect2.iBr.iX,rect2.iBr.iY); - - - if (retVal) - { - snapshotFileName.Format(KSnap,myKK); - } - else - { - snapshotFileName.Format(KSnapE,myKK); - } - snapshot->Save(snapshotFileName); - CleanupStack::PopAndDestroy(snapshot); - myKK++; - - - - TEST(retVal); - if(!retVal) - INFO_PRINTF3(_L("TheClient->iScreen->RectCompare() return value - Expected: %d, Actual: %d"), ETrue, retVal); - } - -void CTRedrawTest::ConstructAndSetBlankWinLC(RBlankWindow& aWindow, TSize aSize, TPoint aPoint/*=TPoint()*/, - TRgb aBackgroundColor/*=TRgb(0,0,0)*/) - { - User::LeaveIfError(aWindow.Construct(*TheClient->iGroup->GroupWin(), ENullWsHandle)); - CleanupClosePushL(aWindow); - aWindow.SetExtent(aPoint, aSize); - aWindow.SetColor(aBackgroundColor); - aWindow.Activate(); - } - -void CTRedrawTest::ConstructWindowLC(RWindow& aWindow, TSize aSize, TPoint aPoint/*=TPoint()*/, - TRgb aBackgroundColor/*=TRgb(255,255,255)*/, TBool aTransparencyByAlpha/*=EFalse*/, - TDisplayMode aDisplayMode/*=EColor64K*/) - { - User::LeaveIfError(aWindow.Construct(*TheClient->iGroup->GroupWin(), ENullWsHandle)); - CleanupClosePushL(aWindow); - aWindow.SetExtent(aPoint,aSize); - aWindow.SetBackgroundColor(aBackgroundColor); - aWindow.SetRequiredDisplayMode(aDisplayMode); - if (aTransparencyByAlpha) - { - aWindow.SetTransparencyAlphaChannel(); - } - aWindow.Activate(); - } - -void CTRedrawTest::ActivateAndSetGc(CWindowGc& aGc, RWindow& aWindow, CGraphicsContext::TBrushStyle aBrushStyle/*=CGraphicsContext::ESolidBrush*/, TRgb aBrushColor/*=TRgb(0,0,0)*/, - CGraphicsContext::TPenStyle aPenStyle/*=CGraphicsContext::ENullPen*/, TRgb aPenColor/*=TRgb(0,0,0)*/) - { - aGc.Activate(aWindow); - aGc.Reset(); - aGc.SetBrushStyle(aBrushStyle); - aGc.SetBrushColor(aBrushColor); - aGc.SetPenStyle(aPenStyle); - aGc.SetPenColor(aPenColor); - } - -void CTRedrawTest::DrawWin(CWindowGc& aGc, RWindow& aWin, TSize aWinSize, TRgb aRectColor1, TRgb aRectColor2, TInt aNewOrdinalPos/*=0*/, RWindow* aWinToMove/*=NULL*/, TBool aDrawAllPixels/*=EFalse*/) - { - const TUint startX = 10; - const TUint endX = aWinSize.iWidth - startX; - const TUint startY = 10; - const TUint sHeight = (aWinSize.iHeight >> 1) - startY; - ActivateAndSetGc(aGc,aWin); - aWin.BeginRedraw(); - if(aDrawAllPixels) - { - aGc.SetBrushColor(KWhite); - aGc.DrawRect(TRect(aWinSize)); - } - aGc.SetBrushColor(aRectColor1); - aGc.DrawRect(TRect(startX, startY, endX, sHeight)); - if (aWinToMove) - { - aWinToMove->SetOrdinalPosition(aNewOrdinalPos); - TheClient->iWs.Finish(); - } - aGc.SetBrushColor(aRectColor2); - aGc.DrawRect(TRect(startX, sHeight + startY, endX, aWinSize.iHeight - startY)); - aWin.EndRedraw(); - aGc.Deactivate(); - } - -void CTRedrawTest::CheckOrdinalPositionDefectL() - { - if(TransparencySupportedL() == KErrNotSupported) //the defect only happens when transparency enabled - { - return; - } - - const TRgb KTransWinColor = TRgb(0,0,255,128); - const TUint hWidth = FullScreenModeSize.iWidth >> 1; - const TSize windowSize = TSize(hWidth,FullScreenModeSize.iHeight); - const TPoint rightWinStartPt = TPoint(hWidth,0); - - // A Blank Window to clear the screen. - // It is required to clear all the pixels on the screen. - RBlankWindow clrWin(TheClient->iWs); - ConstructAndSetBlankWinLC(clrWin, FullScreenModeSize); - - // Transparent window - RWindow winLeftT(TheClient->iWs); - ConstructWindowLC(winLeftT, windowSize, TPoint(), KTransWinColor,ETrue); - - CWindowGc& gc = *(TheClient->iGc); - // Draw the Transparent Window (winLeftT) on the Left side - DrawWin(gc, winLeftT, windowSize, KTransBisque, KTransLightSalmon); - - // Invisible window - RWindow winRightI(TheClient->iWs); - User::LeaveIfError(winRightI.Construct(*TheClient->iGroup->GroupWin(), ENullWsHandle)); - CleanupClosePushL(winRightI); - winRightI.SetExtent(rightWinStartPt, windowSize); - winRightI.SetVisible(EFalse); - winRightI.Activate(); - - // Transparent window - RWindow winRightT(TheClient->iWs); - ConstructWindowLC(winRightT, windowSize, rightWinStartPt, KTransWinColor,ETrue); - - // Draw the Transparent Window (winRightT) on the Right side and change the - // Ordinal Position for Invisible Window (winRightI) to move it front - // to the Transparent Window. - // Invisible window is behind the Transparent Window - - DrawWin(gc, winRightT, windowSize, KTransBisque, KTransLightSalmon, 0, &winRightI); // Move winRightI to Front of winRightT - TestRect(); - - CleanupStack::PopAndDestroy(4, &clrWin); - } - -// For reproducing PDEF099892 -void CTRedrawTest::CheckDefectPDEF099892L() - { - if(TransparencySupportedL() == KErrNotSupported) //the defect only happens when transparency enabled - { - return; - } - - const TRgb KTransWinColor = TRgb(0,0,255,128); - const TUint hWidth = FullScreenModeSize.iWidth >> 1; - const TUint hHeight = FullScreenModeSize.iHeight >> 1; - const TSize windowSize = TSize(hWidth,FullScreenModeSize.iHeight); - const TSize transWinSize = TSize(hWidth,hHeight + 10); - const TPoint rightWinStartPt = TPoint(hWidth,0); - - // A Blank Window to clear the screen. - // It is required to clear all the pixels on the screen. - RBlankWindow clrWin(TheClient->iWs); - ConstructAndSetBlankWinLC(clrWin, FullScreenModeSize); - - // Create an Opaque and a Transparent Window and Draw them on the - // Left Side of the Screen. Opaque Window is Behind the Transparent Window. - - // Opaque Window - RWindow winLeftOpq(TheClient->iWs); - ConstructWindowLC(winLeftOpq, windowSize, TPoint(), KRed); - - // Transparent window - RWindow winLeftT(TheClient->iWs); - ConstructWindowLC(winLeftT, transWinSize, TPoint(), KTransWinColor, ETrue); - - CWindowGc& gc = *(TheClient->iGc); - // Draw the transparent Window (winLeftT) on the Left side - DrawWin(gc, winLeftT, transWinSize, KTransBisque, KTransLightSalmon); - - // Draw the Opaque Window (winLeftOpq) on the Left side - DrawWin(gc, winLeftOpq, windowSize, KLightSteelBlue, KCadetBlue, 0, NULL, ETrue); - - // Create an Invisible, an Opaque and a Transparent Window and Draw them on the - // Right Side of the Screen. Invisible Window is Behind the Opaque Window and - // Opaque Window is Behind the Transparent Window. - // While drawing the Transparent Window, move the Invisible Window to the Front of Opaque Window. - // And while Drawing the Opaque Window move the Invisible Window again Behind the Opaque Window. - - // Invisible window - RWindow winRightI(TheClient->iWs); - User::LeaveIfError(winRightI.Construct(*TheClient->iGroup->GroupWin(), ENullWsHandle)); - CleanupClosePushL(winRightI); - winRightI.SetExtent(rightWinStartPt, windowSize); - winRightI.SetVisible(EFalse); - winRightI.Activate(); - - // Opaque Window - RWindow winRightOpq(TheClient->iWs); - ConstructWindowLC(winRightOpq, windowSize, rightWinStartPt, KRed); - - // Transparent window - RWindow winRightT(TheClient->iWs); - ConstructWindowLC(winRightT, transWinSize, rightWinStartPt, KTransWinColor, ETrue); - - // Draw the transparent Window (winRightT) on the Right side - DrawWin(gc, winRightT, transWinSize, KTransBisque, KTransLightSalmon, 1, &winRightI ); - - // Draw the Opaque Window (winRightOpq) on the Right side - DrawWin(gc, winRightOpq, windowSize, KLightSteelBlue, KCadetBlue, 2, &winRightI, ETrue); - - // Compare the Left and Right side Rectangles - TestRect(); - - CleanupStack::PopAndDestroy(6, &clrWin); - } - -void CTRedrawTest::CheckMMSDefectL(TBool aMoveBlankWindow) - { - if(TransparencySupportedL() == KErrNotSupported) //the defect only happens when transparency enabled - { - return; - } - - const TRgb KTransWinColor = TRgb(0,0,255,128); - const TUint hWidth = FullScreenModeSize.iWidth >> 1; - const TUint hHeight = FullScreenModeSize.iHeight >> 1; - const TSize windowSize = TSize(hWidth,FullScreenModeSize.iHeight); - const TSize transWinSize = TSize(hWidth - 20,hHeight + 10); - const TPoint rightWinStartPt = TPoint(hWidth,0); - - // A Blank Window to clear the screen. - // It is required to clear all the pixels on the screen. - RBlankWindow clrWin(TheClient->iWs); - ConstructAndSetBlankWinLC(clrWin, FullScreenModeSize); - - // Create an Opaque and a Transparent Window and Draw them on the - // Left Side of the Screen. Opaque Window is Behind the Transparent Window. - - // Opaque Window - RWindow winLeftOpq(TheClient->iWs); - ConstructWindowLC(winLeftOpq, windowSize, TPoint(), KRed); - CWindowGc& gc = *(TheClient->iGc); - // Draw the Opaque Window (winLeftOpq) on the Left side - DrawWin(gc, winLeftOpq, windowSize, KLightSteelBlue, KCadetBlue, 0, NULL, ETrue); - - // Another Window - A Blank Window - RBlankWindow winLeftBlank(TheClient->iWs); - ConstructAndSetBlankWinLC(winLeftBlank, TSize(100,100), TPoint(20,20), TRgb(128,128,128)); - - // Transparent window - RWindow winLeftT(TheClient->iWs); - ConstructWindowLC(winLeftT, transWinSize, TPoint(10, 10), KTransWinColor, ETrue); - // Draw the Transparent Window (winLeftT) on the Left side - DrawWin(gc, winLeftT, transWinSize, KTransBisque, KTransLightSalmon); - - // Invisible window - RWindow winRightI(TheClient->iWs); - User::LeaveIfError(winRightI.Construct(*TheClient->iGroup->GroupWin(), ENullWsHandle)); - CleanupClosePushL(winRightI); - winRightI.SetExtent(rightWinStartPt, windowSize); - winRightI.SetVisible(EFalse); - winRightI.Activate(); - - // Opaque Window - RWindow winRightOpq(TheClient->iWs); - ConstructWindowLC(winRightOpq, windowSize, rightWinStartPt, KRed); - - // Draw the Opaque Window (winRightOpq) on the Right side - DrawWin(gc, winRightOpq, windowSize, KLightSteelBlue, KCadetBlue, 0, NULL, ETrue); - - // Another Window - A Blank Window - RBlankWindow winRightBlank(TheClient->iWs); - ConstructAndSetBlankWinLC(winRightBlank, TSize(100,100), rightWinStartPt + TPoint(20,20), TRgb(128,128,128)); - - // Transparent window - RWindow winRightT(TheClient->iWs); - ConstructWindowLC(winRightT, transWinSize, rightWinStartPt + TPoint(10,10), KTransWinColor, ETrue); - - if (aMoveBlankWindow) - { - winRightBlank.SetOrdinalPosition(0); // Move the Blank Window to the front of the Transparent Window - TheClient->iWs.Finish(); - } - // Draw the transparent Window (winRightT) on the Right side - DrawWin(gc, winRightT, transWinSize, KTransBisque, KTransLightSalmon, 2, &winRightI); - if (aMoveBlankWindow) - { - winRightBlank.SetOrdinalPosition(1); // Move the Blank Window back to behind the Transparent Window - TheClient->iWs.Finish(); - } - TestRect(); - - DrawWin(gc, winRightT, transWinSize, KTransBisque, KTransLightSalmon, 0, &winRightI); - TestRect(); // if aMoveBlankWindow is ETrue then this will test the Defect PDEF099892 - - // Rest of the lines are just to check other possibilities. - // But,currently, they are not affecting the result. - // i.e. the DrawWin() functions called after this line will draw the same thing - // as it was drawn for the DrawWin() called just before this line. - DrawWin(gc, winRightT, transWinSize, KTransBisque, KTransLightSalmon, 1, &winRightI); - TestRect(); - - DrawWin(gc, winRightT, transWinSize, KTransBisque, KTransLightSalmon, 0, &winRightI); - TestRect(); - - DrawWin(gc, winRightT, transWinSize, KTransBisque, KTransLightSalmon, 2, &winRightI); - TestRect(); - - DrawWin(gc, winRightT, transWinSize, KTransBisque, KTransLightSalmon, 1, &winRightI); - TestRect(); - - DrawWin(gc, winRightT, transWinSize, KTransBisque, KTransLightSalmon, 3, &winRightI); - TestRect(); - - CleanupStack::PopAndDestroy(8, &clrWin); - } - -/** - -The test window is receiving a draw request before it activates, -doing an empty redraw, then activating itself, and drawing itself properly in -response to the next redraw request. - -Without the fix the next redraw request will not be received and it will be drawn blank. -*/ -void CTRedrawTest::CheckDefectPDEF117784L() - { - TSize winSize = BaseWin->Size(); - - TInt winWidth=(FullScreenModeSize.iWidth/3)-10; - TInt winHeight=FullScreenModeSize.iHeight-10; - - CRedrawWindow3* baseRedrawWin = new(ELeave) CRedrawWindow3(this); - CleanupStack::PushL(baseRedrawWin); - TPoint ptBase = TPoint(FullScreenModeSize.iWidth/3*2+5,5); - baseRedrawWin->SetUp1L(ptBase,TSize(winWidth,winHeight),TheClient->iGroup,*TheClient->iGc); - baseRedrawWin->SetVisible(ETrue); - baseRedrawWin->Activate(); - - CRedrawWindow3* testRedrawWin = new(ELeave) CRedrawWindow3(this); - CleanupStack::PushL(testRedrawWin); - TPoint ptTest = TPoint(FullScreenModeSize.iWidth/3+5,5); - testRedrawWin->SetUp1L(ptTest,TSize(winWidth,winHeight),TheClient->iGroup,*TheClient->iGc); - testRedrawWin->SetVisible(ETrue); - testRedrawWin->Activate(); - - TheClient->iWs.Finish(); - User::LeaveIfError(iInvalidRegionChecker->AddExcludedWindow(testRedrawWin)); - TBool retVal = WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions); - TEST(retVal == KErrNone); - if(retVal != KErrNone) - { - ERR_PRINTF2(_L("CTRedrawTest::WaitForRedrawsToFinish failed with error: %d"), retVal); - } - iInvalidRegionChecker->RemoveExcludedWindow(testRedrawWin); - - TheClient->iWs.Finish(); - retVal = WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions); - TEST(retVal == KErrNone); - if(retVal != KErrNone) - { - ERR_PRINTF2(_L("CTRedrawTest::WaitForRedrawsToFinish failed with error: %d"), retVal); - } - - retVal = TheClient->iScreen->RectCompare(TRect(TPoint(ptBase),TSize(winWidth,winHeight)),TRect(TPoint(ptTest),TSize(winWidth,winHeight))); - TEST(retVal); - if(!retVal) - { - ERR_PRINTF1(_L("New activated window has lost redraw request")); - } - - CleanupStack::PopAndDestroy(2, baseRedrawWin); - } - -CInvalidRegionChecker::CInvalidRegionChecker(const CTRedrawTest& aGraphicsTest) - : iGraphicsTest(aGraphicsTest) - {} - -CInvalidRegionChecker::~CInvalidRegionChecker() - { - iExcludedWindowArray.Close(); - } - -TInt CInvalidRegionChecker::AddExcludedWindow(const CTWinBase* aExcludedWindow) - { - TInt error = KErrNone; - const CTWinBase** emptySlot = NULL; - for(TInt win=iExcludedWindowArray.Count()-1; win>=0; win--) - { - if(iExcludedWindowArray[win]==aExcludedWindow) - { - // window is already excluded, we don't want to add it twice - return error; - } - if(!emptySlot && iExcludedWindowArray[win]==NULL) - { - emptySlot = &iExcludedWindowArray[win]; - } - } - - if(emptySlot) - { - // re-use the emptyslot - *emptySlot=aExcludedWindow; // re-use the element - } - else - { - // no empty elements re-used, so add a new one - error = iExcludedWindowArray.Append(aExcludedWindow); - } - return error; - }; - -void CInvalidRegionChecker::RemoveExcludedWindow(const CTWinBase* aExcludedWindow) - { - if(iExcludedWindowArray.Count()) - { - for(TInt win=iExcludedWindowArray.Count()-1; win>=0; win--) - { - if(iExcludedWindowArray[win]==aExcludedWindow) - { - iExcludedWindowArray[win]=NULL; // Not worth deleting the array element, just mark it as NULL - return; - } - } - } - }; - -TBool CInvalidRegionChecker::ExcludedWindow(const CTWinBase* aWin) const - { - for(TInt win=iExcludedWindowArray.Count()-1; win>=0; win--) - { - if(aWin == iExcludedWindowArray[win]) - { -#if defined(InvalidRegionLogging) - { - _LIT(KText, " Excluded Window %08x"); - TLogMessageText buf; - buf.Format(KText, aWin); - BLOG_MESSAGE(buf); - } -#endif - return ETrue; - } - } - return EFalse; - } - -void CInvalidRegionChecker::ProcessWindow(const CTWinBase* aTWinBase) - { -#if defined(InvalidRegionLogging) - { - _LIT(KText, " ProcessWindow %08x %d - Child(%08x), Next(%08x), Prev(%08x)"); - TLogMessageText buf; - buf.Format(KText, aTWinBase, iInvalidRegionCount, aTWinBase->Child(), aTWinBase->NextSibling(), aTWinBase->PrevSibling()); - BLOG_MESSAGE(buf); - } -#endif - - if(aTWinBase && !ExcludedWindow(aTWinBase)) - { - RRegion invalidRegion; - static_cast(aTWinBase)->Win()->GetInvalidRegion(invalidRegion); - iInvalidRegionCount += invalidRegion.Count(); - -#if defined(InvalidRegionLogging) - if(invalidRegion.Count()) - { - _LIT(KText, " IR Found for %08x %d"); - TLogMessageText buf; - buf.Format(KText, aTWinBase, invalidRegion.Count()); - BLOG_MESSAGE(buf); - } -#endif - - invalidRegion.Close(); - - if(0==iInvalidRegionCount) - { - ProcessChildWindow(aTWinBase->Child()); - } - } - } - -void CInvalidRegionChecker::ProcessChildWindow(const CTWinBase* aTWinBase) - { - if(aTWinBase) - { - // get the first sibling window - const CTWinBase *sibling=aTWinBase; - const CTWinBase *prevSibling=sibling->PrevSibling(); - while(prevSibling) - { - sibling=prevSibling; - prevSibling=sibling->PrevSibling(); - } - // process all siblings inc. self - while(sibling && (0==iInvalidRegionCount)) - { - ProcessWindow(sibling); - sibling=sibling->NextSibling(); - } - } - } - - -void CInvalidRegionChecker::ProcessWindowGroup(const CTWinBase* aTWinBase) - { - if(aTWinBase && !ExcludedWindow(aTWinBase)) - { - ProcessChildWindow(aTWinBase->Child()); - } - } - -TInt CInvalidRegionChecker::CheckInvalidRegions(const CTWindowGroup* aGroup) - { - iInvalidRegionCount=0; - ProcessWindowGroup(aGroup); -#if defined(InvalidRegionLogging) - { - _LIT(KText, " CheckInvalidRegions %d"); - TLogMessageText buf; - buf.Format(KText, iInvalidRegionCount); - BLOG_MESSAGE(buf); - } -#endif - return iInvalidRegionCount; - } - -TInt CTRedrawTest::WaitForRedrawsToFinish(TRedrawCheckType aRedrawCheckType) - { - TInt error=KErrNone; -#define EnableCheckInvalidRegions -#if defined(EnableCheckInvalidRegions) - if(aRedrawCheckType == ECheckRedrawActiveObjectAndInvalidRegions) - { - TInt regions = 0; - TInt count = 0; - //We do not want to cycle round forever or too long, a limit of 10 has - //been added but this is arbitrary. If CTClient::WaitForRedrawsToFinish - //fails too many times then possibly something else us wrong. - do - { - count++; - error = TheClient->WaitForRedrawsToFinish(); - if(error != KErrNone) - { - RDebug::Printf("CTRedrawTest::WaitForRedrawsToFinish, error %d", error); - } - regions = iInvalidRegionChecker->CheckInvalidRegions(TheClient->iGroup); - if(regions) - { - // Give the server a chance to do the redraws because - // the Animation Scheduler is an idle priority AO - const TUint KOneSecond = 1000000; // us - User::After(KOneSecond>>2); // 0.25s - } - } while (0 < regions && 10 < count); - } - else // ECheckRedrawActiveObjectOnly -#endif // CheckInvalidRegions - { - error = TheClient->WaitForRedrawsToFinish(); - } - return error; - } - -void CTRedrawTest::RunTestCaseL(TInt /*aCurTestCase*/) - { - _LIT(Redraw0,"Redraw1"); - _LIT(Redraw1,"Redraw2"); - _LIT(Redraw2,"GetInvalid"); - _LIT(Redraw3,"MoveInvalid"); - _LIT(Redraw4,"CheckOrder"); - _LIT(Redraw5,"Defect 49554"); - _LIT(Redraw6,"Check Ordinal Position"); - _LIT(Redraw7,"Defect 99892"); - _LIT(Redraw8,"Check MMS Defect 1"); - _LIT(Redraw9,"Check MMS Defect 2"); - _LIT(Redraw10,"Redraw inactive window"); - ((CTRedrawTestStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); - - TInt testWindowDraws = -1; // to prevent RVCT 546-D warning - _LIT(KLog,"RunTestCase %d"); - if (++iTest->iState<6) - LOG_MESSAGE2(KLog,iTest->iState); - switch(iTest->iState) - { -/** -@SYMTestCaseID GRAPHICS-WSERV-0265 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test invalidation a test window and check it - redraws correctly - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Invalidate a test window causing it to redraw - -@SYMTestExpectedResults The test window redraws correctly -*/ - case 1: - ((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0265")); - iTest->LogSubTest(Redraw0); - SetBackground(TRgb::Gray256(128)); - iDrawRequestsFromTestWindow=iTestRedrawWin->DrawRequests(); - InvalidateTestWins(TRect(10,10,50,50)); - break; - case 2: - ((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0265")); - TheClient->iWs.Finish(); - WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions); - testWindowDraws=iTestRedrawWin->DrawRequests(); - if (iDrawRequestsFromTestWindow+1!=testWindowDraws) - { - LOG_MESSAGE3(_L("wrong number of test window draw requests %d %d"), - iDrawRequestsFromTestWindow, - testWindowDraws); - TEST(EFalse); - } - CheckRedrawWindows(); - ++iWinContent; - iTestRedrawWin->Reset(); - iBaseRedrawWin->Reset(); - TheClient->Flush(); - WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0266 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test invalidation a test window and check it - redraws correctly - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Invalidate a test window causing it to redraw - -@SYMTestExpectedResults The test window redraws correctly -*/ - case 3: - ((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0266")); - iTest->LogSubTest(Redraw1); - InvalidateTestWins(TRect(1,1,150,20)); - TheClient->iWs.Finish(); - WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions); - break; - case 4: - ((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0266")); - CheckRedrawWindows(); - ++iWinContent; - iTestRedrawWin->Reset(); - iBaseRedrawWin->Reset(); - TheClient->iWs.Flush(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0267 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test invalidation a region of a test window and check it - redraws correctly - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Invalidate a region of a test window causing it to redraw - -@SYMTestExpectedResults The test window redraws correctly -*/ - case 5: - ((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0267")); - iTest->LogSubTest(Redraw2); - GetInvalidRegionTestsL(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0268 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test moving an invalid region of a test window and check it - redraws correctly - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Move an invalid region of a test window causing it to redraw - -@SYMTestExpectedResults The test window redraws correctly -*/ - case 6: - ((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0268")); - iTest->LogSubTest(Redraw3); - MoveInvalidAreaL(); - break; - -/** -@SYMTestCaseID GRAPHICS-WSERV-0270 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test the order redraws occur in a test window - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Set up a number of redraws for a test window and - invalidate it - -@SYMTestExpectedResults The order the test window redraws occur is correct -*/ - - case 7: - ((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0270")); - iTest->LogSubTest(Redraw4); - CheckOrderL(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0271 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test defect INC049554L does not occur - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Check that defect INC049554L does not occur when a test - window is redrawn - -@SYMTestExpectedResults Defect INC049554L does not occur -*/ - case 8: - ((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0271")); - iTest->LogSubTest(Redraw5); - CheckDefectINC049554L(); - break; -/** - @SYMTestCaseID GRAPHICS-WSERV-0359 - - @SYMDEF PDEF099892 - - @SYMTestCaseDesc Ensure that changing the Ordinal postion of an Invisible Window - does not affect the Transparent Window or Opaque Window redrawing. - - @SYMTestPriority Medium - - @SYMTestStatus Implemented - - @SYMTestActions Create an Invisible Window - Create a Transparent Window - Inside the Begin and End Redraw for the Transparent Window, - change the Ordinal Position for Invisible Window to move it - front to the Transparent Window. - - @SYMTestExpectedResults Changing the Ordinal postion for Invisible Window should not - affect the Transparent Window redrawing. -*/ - case 9: - ((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0359")); - iTest->LogSubTest(Redraw6); - CheckOrdinalPositionDefectL(); - break; -/** - @SYMTestCaseID GRAPHICS-WSERV-0360 - - @SYMDEF PDEF099892 - - @SYMTestCaseDesc Ensure that changing the Ordinal postion of an Invisible window - does not affect the Transparent Window or Opaque Window redrawing. - - @SYMTestPriority Medium - - @SYMTestStatus Implemented - - @SYMTestActions Create an Invisible Window - Create an Opaque Window - Create a Transparent Window - Invisible Window is Behind the Opaque Window - and Opaque Window is Behind the Transparent Window. - While drawing the Transparent Window, move the Invisible Window - to the Front of Opaque Window. And while Drawing the Opaque Window - move the Invisible Window again Behind the Opaque Window. - - @SYMTestExpectedResults Changing the Ordinal postion for Invisible window should not - affect the Transparent Window or Opaque Window redrawing. -*/ - case 10: - ((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0360")); - iTest->LogSubTest(Redraw7); - CheckDefectPDEF099892L(); - break; -/** - @SYMTestCaseID GRAPHICS-WSERV-0361 - - @SYMDEF DEF101548 - - @SYMTestCaseDesc Ensure that changing the Ordinal postion of an Invisible window - does not affect the Transparent Window redrawing. - - @SYMTestPriority Low - - @SYMTestStatus Implemented - - @SYMTestActions Create an Invisible Window - Create an Opaque Window - Create a Blank Window - Create a Transparent Window - Invisible Window is Behind the Opaque Window - Opaque Window is Behind the Blank Window - and Blank Window is Behind the Transparent Window. - While drawing the Transparent Window, move the Invisible Window - to the Front/Back to one or all the Other Windows. - Also move the Blank Window Front/Back to the Transparent Window for other scenario. - - @SYMTestExpectedResults Changing the Ordinal postion for Invisible window should not - affect the Transparent Window redrawing. -*/ - case 11: - ((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0361")); - iTest->LogSubTest(Redraw8); - CheckMMSDefectL(EFalse); - case 12: - ((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0361")); - iTest->LogSubTest(Redraw9); - CheckMMSDefectL(ETrue);// In this case we will move Blank Window Front/Back to the Transparent Window to Test Defect PDEF099892 - break; - case 13: - iTest->LogSubTest(Redraw10); -/** - @SYMTestCaseID GRAPHICS-WSERV-0362 - - @SYMDEF PDEF117784 - - @SYMTestCaseDesc Ensure that drawing request for non active window will not - impact following redrawings - - @SYMTestPriority High - - @SYMTestStatus Implemented - - - @SYMTestActions Create test window as in active - Create base window in active mode. - - The test window is receiving a draw request before it activates, - doing an empty redraw, - Activate test window - Draw test window properly in response to the next redraw request. - - @SYMTestExpectedResults The next redraw request will be received and it will be drawn correctly. -*/ - ((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0362")); - CheckDefectPDEF117784L(); - break; - case 14: - ((CTRedrawTestStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - ((CTRedrawTestStep*)iStep)->CloseTMSGraphicsStep(); - TestComplete(); - break; - default: - TEST(EFalse); - } - ((CTRedrawTestStep*)iStep)->RecordTestResultL(); - } - -__WS_CONSTRUCT_STEP__(RedrawTest) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TREDRAW.H --- a/windowing/windowserver/tauto/TREDRAW.H Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,239 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef __TREDRAW_H__ -#define __TREDRAW_H__ - -#include -#include -#include "../tlib/testbase.h" -#include "AUTO.H" -#include "TScreenModeScaling.h" -#include "TGraphicsHarness.h" - -class CTRedrawTest; - -/** - * Abstract base class to draw a pattern into a window. - * - * This provides a default Draw() implementation which - * DOES NOT set the clipping region before drawing. - */ -class CRedrawWindow : public CTWin - { - friend class CTRedrawTest; -public: - enum TDrawPattern - { - EDrawGraphPaperlHatched = 0, - EDrawSlantingHatched, - EDrawCenteredRectangle - }; -public: - CRedrawWindow(CTRedrawTest* aTest); - ~CRedrawWindow(); -public: - /* - * Draw the window, counting the number of calls. - * @post DrawRequests() returns a value increased by 1. - */ - virtual void Reset(); - virtual void PrepareInvalidation(const TRect& aRect) = 0; - virtual void PerformInvalidation() = 0; - //Virtual function from CTBaseWin - void Draw(); -public: - void ActivateAndDraw(TInt aPattern); - void DrawPattern(TInt aPattern); - void VisibleRegion(RRegion& aRegion); - void ValidateAndClear(); - void ActivateAndDraw(TInt aPattern,TRegion* aRegion); - TInt DrawRequests() const; -protected: - void ReceivedDrawRequest(); - TPoint iOffset; - RRegion iInvalid; - CTRedrawTest *iTest; -private: - TInt iDrawRequests; - }; - -/** - * Concrete class to draw a pattern into a window. - * - */ -class CReferenceComparisonRedrawWindow : public CRedrawWindow - { -public: - CReferenceComparisonRedrawWindow(CTRedrawTest* aTest); -public: - // from CRedrawWindow - void PrepareInvalidation(const TRect& aRect); - void PerformInvalidation(); - }; - -class CRedrawWindow2 : public CRedrawWindow - { -public: - CRedrawWindow2(CTRedrawTest* aTest); -public: - //Virtual function from CTBaseWin overridden in CRedrawWindow - void Draw(); - //Virtual function from CRedrawWindow - void Reset(); - // from CRedrawWindow - void PrepareInvalidation(const TRect& aRect); - void PerformInvalidation(); -private: - TBool iClipped; - }; - -class CRedrawWindow3 : public CRedrawWindow - { -public: - CRedrawWindow3(CTRedrawTest* aTest); -public: - //Virtual function from CTBaseWin overridden in CRedrawWindow - void Draw(); - // from CRedrawWindow - void PrepareInvalidation(const TRect& aRect); - void PerformInvalidation(); -public: - void SetUp1L(TPoint pos,TSize size,CTWinBase* parent,CWindowGc& aGc); - void Activate(); - void Redraw(const TRect& aRect); -protected: - TBool isActive; - }; - -class CTRedrawOrderWindow : public CTWin - { -public: - CTRedrawOrderWindow(TInt aOrder, CTRedrawTest *aTest); - static CTRedrawOrderWindow* NewLC(TInt aOrder,CTWinBase* aParent,const TPoint& aPos,const TSize& aSize,CTRedrawTest* aTest); - inline static TInt RedrawNumber() {return iRedrawNumber;} - static void ResetRedrawNumber(); - void Redraw(const TRect& aRect); - void Draw(); -private: - CTRedrawTest* iTest; - TInt iOrder; - static TInt iRedrawNumber; - }; - -class CTCheckDefectWin : public CBasicWin - { -public: - static CTCheckDefectWin *NewL(TPoint aPos,TSize aWinSize); -private: - CTCheckDefectWin(){} - }; - -class CInvalidRegionChecker : public CBase - { -public: - CInvalidRegionChecker(const CTRedrawTest& aGraphicsTest); - ~CInvalidRegionChecker(); - - TInt CheckInvalidRegions(const CTWindowGroup* aGroup); - TBool ExcludedWindow(const CTWinBase* aTWinBase) const; - TInt AddExcludedWindow(const CTWinBase* aExcludedWindow); - void RemoveExcludedWindow(const CTWinBase* aExcludedWindow); -private: - void ProcessWindowGroup(const CTWinBase* aTWinBase); - void ProcessChildWindow(const CTWinBase* aTWinBase); - void ProcessWindow(const CTWinBase* aTWinBase); -private: - TInt iInvalidRegionCount; - RPointerArray iExcludedWindowArray; - const CTRedrawTest& iGraphicsTest; - }; - -class CTRedrawTest : public CTWsGraphicsBase - { -public: - CTRedrawTest(CTestStep* aStep); - ~CTRedrawTest(); - void doDestruct(); - void ConstructL(); - void CheckRedrawWindows(); - void ProcessBaseInvalidate(); - void SetBackground(const TRgb& aRgb); - void DumpRegion(const TRegion& aRegion); - inline TInt WinContent(); - void InvalidateTestWins(const TRect& aRect); - void MoveInvalidAreaL(); - void TestGetInvalidRegionL(const CArrayFixFlat* aRectList); - void GetInvalidRegionTestsL(); - void CompareRegionsL(const TRegion& aRegion1,const TRegion& aRegion2); - void Failed(TInt aOrder); - void CheckOrderL(); - void TestRect(); - void CheckDefectINC049554L(); - void CheckDefectPDEF099892L(); - void CheckOrdinalPositionDefectL(); - void CheckDefectPDEF117784L(); - void CheckMMSDefectL(TBool aMoveBlankWindow); - void ConstructAndSetBlankWinLC(RBlankWindow& aWindow, TSize aSize, TPoint aPoint=TPoint(), - TRgb aBackgroundColor=TRgb(0,0,0)); - void ConstructWindowLC(RWindow& aWindow, TSize aSize, TPoint aPoint=TPoint(), - TRgb aBackgroundColor=TRgb(255,255,255), TBool aTransparencyByAlpha=EFalse, - TDisplayMode aDisplayMode=EColor64K); - void ActivateAndSetGc(CWindowGc& aGc, RWindow& aWindow, CGraphicsContext::TBrushStyle aBrushStyle=CGraphicsContext::ESolidBrush, TRgb aBrushColor=TRgb(0,0,0), - CGraphicsContext::TPenStyle aPenStyle=CGraphicsContext::ENullPen, TRgb aPenColor=TRgb(0,0,0)); - void DrawWin(CWindowGc& aGc, RWindow& aWin, TSize winSize, TRgb aRectColor1, TRgb aRectColor2, TInt aNewOrdinalPos=0, RWindow* aWinToMove=NULL, TBool aDrawAllPixels=EFalse); - enum TRedrawCheckType - { - ECheckRedrawActiveObjectOnly, - ECheckRedrawActiveObjectAndInvalidRegions - }; - TInt WaitForRedrawsToFinish(TRedrawCheckType aRedrawCheckType); -protected: -//from CTGraphicsStep - virtual void RunTestCaseL(TInt aCurTestCase); -private: - void ValidateAndClear(TestWindow *aWin); -private: - TSize iWinSize; - TBool iDoCheck; - TInt iRedrawNo; - CReferenceComparisonRedrawWindow *iBaseRedrawWin; - CRedrawWindow2 *iTestRedrawWin; - CBlankWindow *iBaseChildWin; - CBlankWindow *iTestChildWin; - TInt iDrawRequestsFromTestWindow; - TInt iWinContent; - CInvalidRegionChecker *iInvalidRegionChecker; - }; - -class CTRedrawTestStep : public CTGraphicsStep - { -public: - CTRedrawTestStep(); -protected: - //from CTGraphicsStep - virtual CTGraphicsBase* CreateTestL(); - }; - -_LIT(KTRedrawTestStep,"TRedrawTest"); - - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TREDRSTR.CPP --- a/windowing/windowserver/tauto/TREDRSTR.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,3947 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Test redraw storing -// Tests Storing the Redraw command mechanism in the window server. -// The first time a window is redrawn its commands are stored. When -// the window needs to be redrawn, the stored commands will be used -// rather than issue a redraw request to the client. -// The principle behind this test is to do lots of different types of drawing to a window, -// invalidate the window and test that no redrawing occurred, instead the stored commands -// should be used to generate the content of the window. -// -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include "TREDRSTR.H" -#include "colorblender.h" - -//#define LOGGING on - -_LIT(KColorUnmatchedFormat, "Check failed, expected color value: 0x%08x, got: 0x%08x"); -#define TEST_COLOR_MATCH(aExpected, aActual) \ - TEST(aExpected == aActual); \ - if(aExpected != aActual) \ - LOG_MESSAGE3(KColorUnmatchedFormat, aExpected.Value(), aActual.Value()) - -/*CPartialRedrawWin*/ -void CPartialRedrawWin::Init() - { - iClientDrawn = EFalse; - iClientCanDraw = ETrue; - Win()->SetRequiredDisplayMode(EColor16MA); - Win()->SetTransparencyAlphaChannel(); - Win()->SetBackgroundColor(TRgb(127,127,127,0)); - } - -void CPartialRedrawWin::Draw() - { - DoDraw(*iGc); - } - -void CPartialRedrawWin::DrawToBmp(CGraphicsContext& aGc) - { - DoDraw(aGc); - } - -void CPartialRedrawWin::DoDraw(CGraphicsContext& aGc) - { - if(!iClientCanDraw) return; - iClientDrawn = ETrue; - CPartialRedrawWin::DrawRects(aGc, iSize, TPoint(0,0), ETrue, EPartialRedraw_Unknown); - } - -/*static*/ -void CPartialRedrawWin::DrawRects(CGraphicsContext& aGc, TSize aSize, TPoint aPosition, - TBool aIsFullRedraw, TPartialRedrawType aPartialRedrawType) - { - aGc.SetPenStyle(CGraphicsContext::ESolidPen); - aGc.SetPenColor(TRgb::Gray256(0)); - aGc.SetBrushStyle(CGraphicsContext::ESolidBrush); - if(aIsFullRedraw) - { - aGc.SetBrushColor(TRgb(200,200,200,127)); - aGc.DrawRect(TRect(aPosition, aSize)); - } - else if (aPartialRedrawType!=EPartialRedraw_PreserveStoredCmds) - { - aGc.SetBrushColor(TRgb(200,200,200,127)); // same color as original background. - aGc.SetPenStyle(CGraphicsContext::ENullPen); - aGc.DrawRect(TRect(TPoint(10,10) + aPosition, aSize - TSize(20,20))); - aGc.SetPenStyle(CGraphicsContext::ESolidPen); - aGc.SetPenColor(TRgb::Gray256(0)); - } - TSize r1 = TSize(aSize.iWidth/3, aSize.iHeight/5); - TSize r2 = TSize(aSize.iWidth/9, 2*aSize.iHeight/3); - aGc.SetBrushColor(TRgb(255, 0, 0, 127)); - aGc.DrawEllipse(TRect(TPoint(aSize.iWidth/3, aSize.iHeight/5)+aPosition, r1)); - aGc.SetBrushColor(TRgb(0, 255, 0, 127)); - aGc.DrawEllipse(TRect(TPoint(aSize.iWidth/3, 3*aSize.iHeight/5)+aPosition, r1)); - aGc.SetBrushColor(TRgb(0, 0, 255, 127)); - aGc.DrawEllipse(TRect(TPoint(4*aSize.iWidth/9, aSize.iHeight/6)+aPosition, r2)); - } - -void CPartialRedrawWin::DrawPartial(TPartialRedrawType aPartialRedrawType) - { - TRect rect = TRect(TPoint(10,10), iSize - TSize(20,20)); - Invalidate(rect); - Win()->BeginRedraw(rect); - iGc->Activate(*Win()); - CPartialRedrawWin::DrawRects(*iGc, iSize, TPoint(0,0), EFalse, aPartialRedrawType); - iGc->Deactivate(); - Win()->EndRedraw(); - } -void CPartialRedrawWin::RedrawSubRectWithBitmapL(TRgb aBitmapColour) - { - TInt bitmapWidth = Win()->Size().iWidth - 20; - TInt bitmapHeight = Win()->Size().iHeight - 20; - TSize bitmapSize(bitmapWidth, bitmapHeight); - - CFbsBitmap* fbsBitmap = new(ELeave) CFbsBitmap(); - CleanupStack::PushL(fbsBitmap); - User::LeaveIfError(fbsBitmap->Create(bitmapSize, EColor16MU)); - - // ensure colour is opaque - aBitmapColour.SetAlpha(255); - - // draw on the bitmap - TBitmapUtil bmpUtil(fbsBitmap); - bmpUtil.Begin(TPoint(0, 0)); - TInt row, col; - for(row = 0; row < bitmapWidth; ++row) - { - bmpUtil.SetPos(TPoint(row, 0)); - for(col = 0; col < bitmapHeight; ++col) - { // diagonal stripes - if ( ((col + row) % 8) < 4 ) - { // colour - bmpUtil.SetPixel(aBitmapColour.Color16M()); - } - else - { // semi-transparent white - TRgb white(255, 255, 255, 128); - bmpUtil.SetPixel(white.Color16M()); - } - bmpUtil.IncYPos(); - } - } - bmpUtil.End(); - - // send bitmap to screen - TRect rect = TRect(TPoint(10,10), bitmapSize); - Invalidate(rect); - Win()->BeginRedraw(rect); - iGc->Activate(*Win()); - iGc->DrawBitmap(rect, fbsBitmap); - iGc->Deactivate(); - Win()->EndRedraw(); - CleanupStack::PopAndDestroy(fbsBitmap); - } - -/* CResetRedrawStoreWin */ - -const TInt KResetRedrawMaxAnimState=4; - -void CResetRedrawStoreWin::PreSetSize(const TSize &aSize) -// Sets the size variable so draw code using it will use the new size -// before the window has actually been resized - { - iSize=aSize; - } - -void CResetRedrawStoreWin::Draw() - { - DoDraw(*iGc); - } - -void CResetRedrawStoreWin::DoDraw(CGraphicsContext& aGc) const - { - aGc.SetPenStyle(CGraphicsContext::ESolidPen); - aGc.SetPenColor(KRgbBlack); - aGc.SetBrushStyle(CGraphicsContext::ESolidBrush); - aGc.SetBrushColor(TRgb(200,200,200,127)); - aGc.DrawRect(TRect(iSize)); - TSize r1(iSize.iWidth/3, iSize.iHeight/5); - TSize r2(iSize.iWidth/9, 2*iSize.iHeight/3); - aGc.SetBrushColor(TRgb(255, 0, 0, 127)); - aGc.DrawEllipse(TRect(TPoint(iSize.iWidth/3, iSize.iHeight/5), r1)); - aGc.SetBrushColor(TRgb(0, 255, 0, 127)); - aGc.DrawEllipse(TRect(TPoint(iSize.iWidth/3, 3*iSize.iHeight/5), r1)); - aGc.SetBrushColor(TRgb(0, 0, 255, 127)); - aGc.DrawEllipse(TRect(TPoint(4*iSize.iWidth/9, iSize.iHeight/6), r2)); - DoDrawAnim(aGc); - } - -TRect CResetRedrawStoreWin::AnimRect() const - { - if (iUpdateInRedraw) - { - TInt row=iAnimState/iSize.iWidth; - TInt col=iAnimState-row*iSize.iWidth; - return(TRect(col,row,col+4,row+4)); - } - return(TRect(iSize.iWidth/6,iSize.iHeight/4,iSize.iWidth*5/6,iSize.iHeight*3/4)); - } - -void CResetRedrawStoreWin::DoDrawAnim(CGraphicsContext& aGc) const - { - if (iAnimState>0) - { - aGc.SetBrushColor(KRgbBlue); - aGc.SetPenStyle(CGraphicsContext::ENullPen); - aGc.SetBrushStyle(CGraphicsContext::ESolidBrush); - TInt animColState=iAnimState%KResetRedrawMaxAnimState; - TRgb animCol(255*animColState/KResetRedrawMaxAnimState,0,255*(KResetRedrawMaxAnimState-animColState)/KResetRedrawMaxAnimState); - aGc.SetBrushColor(animCol); - aGc.DrawRect(AnimRect()); - } - } - -CResetRedrawStoreWin::~CResetRedrawStoreWin() - { - delete iExtraGc; - } - -void CResetRedrawStoreWin::SetUpdateInRedraw(TBool aUpdateInRedraw) - { - iUpdateInRedraw=aUpdateInRedraw; - } - -void CResetRedrawStoreWin::SetKeepGcActive(TBool aState) - { - if (iKeepGcActive!=aState) - { - iKeepGcActive=aState; - if (iKeepGcActive) - { - iExtraGc=new(ELeave) CWindowGc(TheClient->iScreen); - iExtraGc->Construct(); - iExtraGc->Activate(*Win()); - } - else - { - iExtraGc->Deactivate(); - delete iExtraGc; - iExtraGc=NULL; - } - } - } - -TBool CResetRedrawStoreWin::Failed() const - { - return iFailed; - } - -void CResetRedrawStoreWin::UpdateAnim(TInt aSteps) - { - TRect oldAnimRect(AnimRect()); - iAnimState+=aSteps; - if (iUpdateInRedraw) - { - if (iAnimState>=(iSize.iWidth*iSize.iHeight)) - { - iFailed=ETrue; - } - } - else if (iAnimState>KResetRedrawMaxAnimState) - { - iAnimState-=KResetRedrawMaxAnimState; - } - CWindowGc *gc=Gc(); - if (iUpdateInRedraw) - { - Win()->Invalidate(oldAnimRect); - Win()->BeginRedraw(oldAnimRect); - if (iKeepGcActive) - { - DoDraw(*iExtraGc); - } - else - { - gc->Activate(*Win()); - DoDraw(*gc); - gc->Deactivate(); - } - Win()->EndRedraw(); - TRect animRect=AnimRect(); - Win()->Invalidate(animRect); - Win()->BeginRedraw(animRect); - } - if (iKeepGcActive) - DoDrawAnim(*iExtraGc); - else - { - gc->Activate(*Win()); - DoDrawAnim(*gc); - gc->Deactivate(); - } - if (iUpdateInRedraw) - Win()->EndRedraw(); - } - -void CTRedrawStoring::GetTestWinSizeAndPos(TInt aWinIndex, TPoint& aPos, TSize& aSize) const - { - switch(aWinIndex) - { - case 0: - // Centered window half the width of the parent window - aSize.iWidth=iWinSize.iWidth/2; - aSize.iHeight=iWinSize.iHeight/2; - aPos.iX=iWinSize.iWidth/4; - aPos.iY=iWinSize.iHeight/4; - break; - case 1: - // 1/3rd parent window size window positioned 1/3rd spare size in from the bottom right - aSize.iWidth=iWinSize.iWidth/3; - aSize.iHeight=iWinSize.iHeight/3; - aPos.iX=(iWinSize.iWidth-aSize.iWidth)*2/3; - aPos.iY=(iWinSize.iHeight-aSize.iHeight)*2/3; - break; - } - } - -/*CRedrawStoreWin*/ - -void CRedrawStoreWin::Draw() - { - if (iTest->iQueueTest) - iDrawOrder=iTest->iDrawOrder++; - iTest->DoDrawingL(iGc); - } - - -/*CNoDrawWin*/ - -void CNoDrawWin::Draw() - { - //Deliberately have no drawing - } - -/*CBitmapMaskedWin*/ -CBitmapMaskedWin* CBitmapMaskedWin::NewL(CFbsBitmap* aFbsBitmap,CFbsBitmap* aFbsMaskBitmap, - CWsBitmap* aWsBitmap,CWsBitmap* aWsMaskBitmap, - TRgb aBackground,TRect aRect,TBool aInvertMask,TBool aWsFbs) - { - CBitmapMaskedWin* self=new(ELeave) CBitmapMaskedWin(aFbsBitmap,aFbsMaskBitmap,aWsBitmap, - aWsMaskBitmap,aRect,aInvertMask,aWsFbs); - CleanupStack::PushL(self); - self->ConstructL(*TheClient->iGroup); - self->AssignGC(*TheClient->iGc); - self->BaseWin()->SetRequiredDisplayMode(EColor16MU); - self->Win()->SetBackgroundColor(aBackground); - CleanupStack::Pop(self); - return self; - } - -CBitmapMaskedWin::~CBitmapMaskedWin() - { - delete iFbsBitmap; - delete iFbsMaskBitmap; - delete iWsBitmap; - if (!iWsFbs) - { - delete iWsMaskBitmap; - } - } - -void CBitmapMaskedWin::SetDestRectSize(const TSize aSize) - { - iRect.SetSize(aSize); - } - -void CBitmapMaskedWin::Draw() - { - if (iWsFbs) - { - TheClient->iGc->DrawBitmapMasked(iRect,iWsBitmap,TRect(iWsBitmap->SizeInPixels()),iWsMaskBitmap,iInvertMask); - } - else - { - TheClient->iGc->DrawBitmapMasked(iRect,iFbsBitmap,TRect(iFbsBitmap->SizeInPixels()),iFbsMaskBitmap,iInvertMask); - } - } - - -/* TESTCASE: DEF095130 - * TITLE: Redraw store for Alpha Channel Transparency. - * IMPORTANCE: 1 - * - * ACTION: a. Creates a window disable the redrawstore. Set the Alpha channel - * Transparency. - * - * RESULT: Redraw store should be enabled and should redraw correctly. - */ -void CTRedrawStoring::DoRedrawStoreAlphaChannelTransTest() - { - // Create testwin and disable the redraw store - // Set alpha transparency and check if redraw store is enabled - RWindow win(TheClient->iWs); - CleanupClosePushL(win); - User::LeaveIfError(win.Construct(*TheClient->iGroup->GroupWin(), ENullWsHandle)); - win.SetExtent(iWinPos, iWinSize); - win.SetRequiredDisplayMode(EColor256); - win.EnableRedrawStore(EFalse); - win.SetTransparencyAlphaChannel(); - TEST(win.IsRedrawStoreEnabled()); - CleanupStack::PopAndDestroy(&win); - - // Create a window and disable the redraw store - // Set alpha transparency and check if redraw store is enabled - // and check if redraw storing is done correctly - RWindow wint(TheClient->iWs); - CleanupClosePushL(wint); - User::LeaveIfError(wint.Construct(*TheClient->iGroup->GroupWin(), ENullWsHandle)); - wint.SetExtent(iWinPos, iWinSize); - wint.SetRequiredDisplayMode(iTestDisplayMode); - wint.SetBackgroundColor(TRgb(255,255,255)); - wint.SetShadowDisabled(ETrue); - wint.EnableRedrawStore(EFalse); - wint.SetTransparencyAlphaChannel(); - wint.Activate(); - wint.BeginRedraw(); - TheClient->iGc->Activate(wint); - DoDrawingL(23,TheClient->iGc,ETrue); - TheClient->iGc->Deactivate(); - wint.EndRedraw(); - - DoDrawingL(23,iCheckGc,EFalse); - iCheckWin->BackedUpWin()->UpdateScreen(); - - iBlankWin.SetOrdinalPosition(0); - iBlankWin.SetVisible(ETrue); - iBlankWin.SetVisible(EFalse); - - TheClient->Flush(); - TheClient->WaitForRedrawsToFinish(); - TInt gap = 5; - const TSize scrSize(TheClient->iScreen->SizeInPixels()); - TEST(TheClient->iScreen->RectCompare(TRect(TPoint(scrSize.iWidth-2*iWinSize.iWidth-gap,0),iWinSize),TRect(TPoint(scrSize.iWidth-iWinSize.iWidth,0),iWinSize))); - CleanupStack::PopAndDestroy(&wint); - } - -/* TESTCASE: PDEF091091 - * TITLE: Redraw in between begin and end redraw. - * IMPORTANCE: 1 - * - * ACTION: Draws some content to test window in its redraw. Then starts drawing - * to test window by using BeginRedraw and EndRedraw methods. A blank window in - * front of test wndow is made visible and invisible in between BeginRedraw and - * EndRedraw. - * - * - * RESULT: When the window is made visible again redraw should ot happen. - */ -void CTRedrawStoring::DoBeginEndRedraw() - { - // Check whether redrawstoring is working - RedrawWindows(); - iBlankWin.SetVisible(ETrue); - iBlankWin.SetVisible(EFalse); - iClientDidDraw = EFalse; - CheckWindowsMatch(); - TEST(!iClientDidDraw); - if(iClientDidDraw != 0) - INFO_PRINTF3(_L("iClientDidDraw Expected value %d Actual value %d"), 0, iClientDidDraw); - - // Change the size and make the blank window visible - // Then start drawing by BeginRedraw and Activating its gc - // Now make the blank window visible - iTestWin->Win()->Invalidate(); - iBlankWin.SetSize(TSize(40,40)); - iBlankWin.SetVisible(ETrue); - - CWindowGc* gc = iTestWin->Gc(); - RWindow* win = iTestWin->Win(); - win->BeginRedraw(); - gc->Activate(*win); - gc->SetPenStyle(CGraphicsContext::ESolidPen); - gc->SetPenColor(TRgb(0,0,0)); - gc->SetPenSize(TSize(1,1)); - gc->DrawLine(TPoint(iWinSize.iWidth,0), TPoint(0, iWinSize.iHeight)); - iBlankWin.SetVisible(EFalse); - gc->DrawLine(TPoint(0,0), TPoint(iWinSize.iWidth, iWinSize.iHeight)); - iBlankWin.SetVisible(ETrue); - gc->DrawLine(TPoint(iWinSize.iWidth/2,0), TPoint(iWinSize.iWidth/2, iWinSize.iHeight)); - gc->DrawLine(TPoint(0,iWinSize.iHeight/2), TPoint(iWinSize.iWidth, iWinSize.iHeight/2)); - - iCheckGc->Clear(); - iCheckGc->SetPenStyle(CGraphicsContext::ESolidPen); - iCheckGc->SetPenColor(TRgb(0,0,0)); - iCheckGc->SetPenSize(TSize(1,1)); - iCheckGc->DrawLine(TPoint(iWinSize.iWidth/2,0), TPoint(iWinSize.iWidth/2, iWinSize.iHeight)); - iCheckGc->DrawLine(TPoint(0,iWinSize.iHeight/2), TPoint(iWinSize.iWidth, iWinSize.iHeight/2)); - iCheckGc->DrawLine(TPoint(0,0), TPoint(iWinSize.iWidth, iWinSize.iHeight)); - iCheckGc->DrawLine(TPoint(iWinSize.iWidth,0), TPoint(0, iWinSize.iHeight)); - iCheckWin->BackedUpWin()->UpdateScreen(); - - iBlankWin.SetVisible(EFalse); - - // This is to check if any redraw happened in between Begin and EndRedraw - /* Andy commented this out. I'm not entirely sure what it's doing. We just redrew a window - while part of it was hidden, and then revealed the hidden part before calling EndRedraw, and - this is testing that the new draw commands for the region revealed are not processed, or are not - processed correctly. In the new window server they are processed and the region checked matches - the test bitmap. */ -// TInt gap = 5; -// const TSize scrSize(TheClient->iScreen->SizeInPixels()); -// TBool failed=DoCheckRect(TPoint(scrSize.iWidth-2*iWinSize.iWidth-gap,0),TPoint(scrSize.iWidth-iWinSize.iWidth,0),TSize(40,40)); - gc->Deactivate(); - win->EndRedraw(); -/* if (failed) - { - TEST(EFalse); - return; - } */ - - // This is to check redraw is done after EndRedraw has called. - iBlankWin.SetVisible(ETrue); - iBlankWin.SetVisible(EFalse); - CheckRect(iTestWin,iCheckWin,TRect(TSize(40,40)),_L("CTRedrawStoring::DoBeginEndRedraw")); - // Finally bring every thing to normal - RedrawWindows(); - CheckWindowsMatch(); - iBlankWin.SetSize(iWinSize); - } -/** -@SYMTestCaseID GRAPHICS-WSERV-00XX-0006 - -@SYMDEF INC087721 - -@SYMTestCaseDesc Invisible Redraw Storing Test - Tests the non-redraw storing commands are stored/executed properly, - in presence of partial redraw commands. - When a semi-transparent window ST0 sits on top of an opaque window OW1, - you want the screen to be drawn as OW1, then alpha-blend ST0 once. - When ST0 is set to invisible, you want the screen to be drawn as OW1, - i.e. window server to not issue redraw requests for ST0. - When an opaque window OW2 sites on top of an opaque window OW1, - you want the screen to be drawn as OW1, then over-print OW2 once. - When OW2 is set invisible, you want the screen to be drawn as OW1, - i.e. window server to not issue redraw requests for OW2. - The reference document specifies that invisible windows do not receive - any window server events, i.e. no redraw requests. - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Makes invisible a window with an invalid area - -@SYMTestExpectedResults When the window is made visible again it should display correctly - */ -void CTRedrawStoring::DoInvisibleRedrawStoreTestL( TBool aUseTransparency ) - { - /* - * Obtain the color of a particular reference pixel which will be used for - * comparison later on when the blue test window is added covering it. - */ - const TPoint referencePixel(iWinPos+TPoint(50,50)); - TRgb backgroundReferenceColor; - TheClient->Flush(); - TheClient->WaitForRedrawsToFinish(); - TheClient->iWs.Finish(); - TheClient->iScreen->GetPixel(backgroundReferenceColor, referencePixel); - /* - * Add a blue test window: transparent or opaque given parameter aUseTransparency - */ - CInvisibleRedrawWin* testWin=new(ELeave) CInvisibleRedrawWin; - CleanupStack::PushL(testWin); - testWin->ConstructL(*TheClient->iGroup); - testWin->AssignGC(*TheClient->iGc); - testWin->SetExt(iWinPos+TPoint(25,25),TSize(300,200)); - testWin->Win()->SetRequiredDisplayMode(iTestDisplayMode); - testWin->Win()->SetShadowDisabled(ETrue); - if (aUseTransparency) - { - const TInt err = testWin->MakeTransparent(); - if (err) - { - TEST(EFalse); - _LIT(KLog,"Failed to make the window transparent!"); - LOG_MESSAGE(KLog); - } - } - /* - * Make the blue testWin window appear on top of the window at iWinPos - */ - testWin->Win()->Activate(); - testWin->Win()->Invalidate(); - TheClient->iWs.Finish(); - TheClient->WaitForRedrawsToFinish(); - /* - * By making the blue window invisible and then visible we can check to see if - * the window gets re-drawn correctly. Redraws should not come in during the - * invisible phase, because "invisible windows do not receive any window server events" - * but should come in during the visible phase. The background should have been - * drawn first and then the blue window alpha blended exactly once. - */ - testWin->MakeVisible(EFalse); - testWin->Win()->Invalidate(); - testWin->MakeVisible(ETrue); - testWin->Win()->Invalidate(); - /* - * Now check the screen has the desired color at the reference pixel. - */ - TRgb actualColor; - TheClient->Flush(); - TheClient->WaitForRedrawsToFinish(); - TheClient->iWs.Finish(); - TheClient->iScreen->GetPixel(actualColor, referencePixel); - if (aUseTransparency) - { - CColorBlender* blender = CColorBlender::NewLC(iTestDisplayMode); - blender->SetInitialColor(backgroundReferenceColor); - blender->Blend(TRgb(0, 0, 255, 127)); //the blue background of the window - const TRgb expectedColor(blender->Color()); - TEST_COLOR_MATCH(expectedColor, actualColor); - CleanupStack::PopAndDestroy(blender); - } - else - { - TEST_COLOR_MATCH(KRgbBlue, actualColor); - } - CleanupStack::PopAndDestroy(testWin); - } - -/*CInvisibleRedrawWin*/ -CInvisibleRedrawWin::CInvisibleRedrawWin() - : iVisible( ETrue ) - {} - -TInt CInvisibleRedrawWin::MakeTransparent() - { - const TInt err = Win()->SetTransparencyAlphaChannel(); - if(!err) - { - Win()->SetBackgroundColor(TRgb(0, 0, 0, 0)); - iTransparent = ETrue; - } - return err; - } - -void CInvisibleRedrawWin::MakeVisible( TBool aVisible ) - { - iVisible = aVisible; - SetVisible( aVisible ); - } - -void CInvisibleRedrawWin::Redraw() - { - iWin.BeginRedraw(); - DrawIfVisible(); - iWin.EndRedraw(); - } - -void CInvisibleRedrawWin::Redraw( const TRect &aRect ) - { - iWin.BeginRedraw( aRect ); - DrawIfVisible(); - iWin.EndRedraw(); - } - -void CInvisibleRedrawWin::DrawIfVisible() - { - if (iVisible) - { - iGc->Activate( iWin ); - iGc->SetBrushStyle( CGraphicsContext::ESolidBrush ); - if(iTransparent) - iGc->SetBrushColor( TRgb(0, 0, 255, 127) ); - else - iGc->SetBrushColor( KRgbBlue ); - iGc->Clear(); - iGc->Deactivate(); - } - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-0498 - -@SYMDEF INC135845 - -@SYMTestCaseDesc UseBrushPattern test - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Create a bitmap and use as brush. bitmap deleted immediately to - prove that wserv retains the handle - -@SYMTestExpectedResults No Panic BITGDI 13 - */ - -void CTRedrawStoring::DoBrushDrawTestL() - { - CBrushDrawWin* testWin=new(ELeave) CBrushDrawWin; - CleanupStack::PushL(testWin); - testWin->ConstructL(*TheClient->iGroup); - testWin->AssignGC(*TheClient->iGc); - testWin->SetExt(iWinPos+TPoint(25,25),TSize(300,200)); - testWin->Win()->SetRequiredDisplayMode(iTestDisplayMode); - testWin->Win()->SetShadowDisabled(ETrue); - testWin->Activate(); - testWin->SetVisible(ETrue); - - testWin->DrawNow(); - - TheClient->Flush(); - TheClient->WaitForRedrawsToFinish(); - - CleanupStack::PopAndDestroy(testWin); - } - -/*CBrushDrawWin*/ -CBrushDrawWin::CBrushDrawWin() - {} - -void CBrushDrawWin::Draw() - { - Redraw(); - } - -void CBrushDrawWin::Redraw() - { - CFbsBitmap *bitmap=new(ELeave) CFbsBitmap(); - User::LeaveIfError(bitmap->Load(TEST_BITMAP_NAME,0)); - TSize bitSize(bitmap->SizeInPixels()); - iGc->UseBrushPattern(bitmap); - iGc->SetBrushStyle(CGraphicsContext::EPatternedBrush); - iGc->DrawRect(TRect(TPoint(0, 0), bitSize)); - iGc->DiscardBrushPattern(); - delete bitmap; - } - -/*CTRedrawStoring*/ -CTRedrawStoring::CTRedrawStoring(CTestStep* aStep) : CTWsGraphicsBase(aStep) - { - } - -CTRedrawStoring::~CTRedrawStoring() - { - delete iCheckWin; - delete iCheckGc; - delete iCheckDevice; - delete iCheckBitmap; - delete iTestWin; - for(TInt bmp = 0; bmp < 3; ++bmp) - delete iAlphaBitmap[bmp]; - iBlankWin.Close(); - iRegion.Close(); - iWinTestGc.Close(); - delete iNoDrawWin; - delete iTestWinCopy; - delete iCheckWinCopy; - } - -void CTRedrawStoring::ConstructL() - { - iState = 0; - const TInt gap=5; - iTestDisplayMode = TheClient->iScreen->DisplayMode(); - const TSize scrSize(TheClient->iScreen->SizeInPixels()); - iWinSize=TheClient->iScreen->SizeInPixels(); - iWinSize.iWidth=(scrSize.iWidth-gap)/3; - CTBackedUpWin* checkWin=new(ELeave) CTBackedUpWin(iTestDisplayMode); - checkWin->ConstructExtLD(*TheClient->iGroup,TPoint(scrSize.iWidth-iWinSize.iWidth,0),iWinSize); - iCheckWin=checkWin; - iCheckWin->Activate(); - RBackedUpWindow& win=*iCheckWin->BackedUpWin(); - win.MaintainBackup(); - iCheckBitmap=new(ELeave) CFbsBitmap(); - iCheckBitmap->Duplicate(win.BitmapHandle()); - iCheckDevice=CFbsBitmapDevice::NewL(iCheckBitmap); - User::LeaveIfError(iCheckDevice->CreateContext(iCheckGc)); - iCheckGc->SetUserDisplayMode(iTestDisplayMode); - CRedrawStoreWin* testWin=new(ELeave) CRedrawStoreWin(this); - iWinPos.SetXY(scrSize.iWidth-2*iWinSize.iWidth-gap,0); - testWin->ConstructExtLD(*TheClient->iGroup,iWinPos,iWinSize); - iTestWin=testWin; - iTestWin->AssignGC(*TheClient->iGc); - RWindowBase& baseWin=*iTestWin->BaseWin(); - User::LeaveIfError(baseWin.SetRequiredDisplayMode(iTestDisplayMode)); - baseWin.SetShadowHeight(0); - iTestWin->Activate(); - - CNoDrawWin* noDrawWin=new(ELeave) CNoDrawWin(); - iWinPos.SetXY(scrSize.iWidth-2*iWinSize.iWidth-gap,0); - noDrawWin->ConstructExtLD(*TheClient->iGroup,iWinPos,iWinSize); - iNoDrawWin=noDrawWin; - iNoDrawWin->AssignGC(*TheClient->iGc); - RWindowBase& bWin=*iNoDrawWin->BaseWin(); - User::LeaveIfError(bWin.SetRequiredDisplayMode(EColor256)); - bWin.SetShadowHeight(0); - - iBlankWin=RBlankWindow(TheClient->iWs); - User::LeaveIfError(iBlankWin.Construct(*TheClient->iGroup->WinTreeNode(),ENullWsHandle)); - iBlankWin.SetVisible(EFalse); - User::LeaveIfError(iBlankWin.SetRequiredDisplayMode(EColor256)); - iBlankWin.SetColor(TRgb(48,240,32)); - iBlankWin.Activate(); - iWinTestGc=RWindow(TheClient->iWs); - User::LeaveIfError(iWinTestGc.Construct(*TheClient->iGroup->WinTreeNode(),ENullWsHandle)); - iWinTestGc.SetVisible(EFalse); - User::LeaveIfError(iWinTestGc.SetRequiredDisplayMode(EColor256)); - - iDrawMode=EClientRedrawsNormal; - iDoScrollTest=EFalse; - iDrawOrder=0; - //PeterI Alpha is supported but opacity is not -// iAlphaSupported=OpacityAndAlphaSupportedL(); - iAlphaSupported =TransparencySupportedL(); - iXPlus = ETrue; - iYPlus = EFalse; - - // Used for fading test - iTestWinCopy = new (ELeave) CFbsBitmap(); - iTestWinCopy->Create(iTestWin->Size(),TheClient->iScreen->DisplayMode()); - iCheckWinCopy = new (ELeave) CFbsBitmap(); - iCheckWinCopy->Create(iCheckWin->Size(),TheClient->iScreen->DisplayMode()); - } - -void CTRedrawStoring::CheckWindowsMatch() - { - TheClient->Flush(); - if (iDrawMode==EClientRedrawsNormal || iDrawMode==EClientRedrawsScrolled) - TheClient->WaitForRedrawsToFinish(); - TheClient->iWs.Finish(); - if(!iWindowsFaded) - { - _LIT(KLog,"RedrawStoring SubTest %d"); - TBuf<32> buf; - buf.AppendFormat(KLog,iTest->iState); - CheckRect(iTestWin,iCheckWin,TRect(iWinSize),buf); - } - else - { - TInt res = LossyCompareWindow(*TheClient->iScreen, *iTestWinCopy, *iCheckWinCopy, TRect(iCheckWin->Position(), iCheckWin->Size())); - TEST(res); - } - } - -void CTRedrawStoring::CheckWindowsNotMatch() - { - TheClient->Flush(); - TheClient->WaitForRedrawsToFinish(); - TheClient->iWs.Finish(); - CheckRectNoMatch(iTestWin,iCheckWin,TRect(iWinSize),_L("CTRedrawStoring::CheckWindowsNotMatch()")); - } - -void CTRedrawStoring::HideRevealTest() - { - iBlankWin.SetVisible(ETrue); - iBlankWin.SetVisible(EFalse); - CheckWindowsMatch(); - } - -void CTRedrawStoring::MultipleHideReveal(TInt aX,TInt aY) - { - TInt xInc=(iWinSize.iWidth+aX-1)/aX; - TInt yInc=(iWinSize.iHeight+aY-1)/aY; - TInt xEnd=iWinPos.iX+iWinSize.iWidth; - TInt yEnd=iWinPos.iY+iWinSize.iHeight; - TInt xx,yy; - for(xx=iWinPos.iX;xxInvalidate(); - CheckWindowsMatch(); - iDrawMode=EServerRedraw; - } - -void CTRedrawStoring::DoDrawingL(CWindowGc* aWinGc) - { - iClientDidDraw = ETrue; - switch (iDrawMode) - { - case EServerRedraw: - TEST(EFalse); - break; - case EClientRedrawsNormal: - if (iState>0) - { - DoDrawingL(0,aWinGc,ETrue); - DoDrawingL(0,iCheckGc,EFalse); - aWinGc->Deactivate(); - aWinGc->Activate(*iTestWin->DrawableWin()); - } - DoDrawingL(iState,aWinGc,ETrue); - DoDrawingL(iState,iCheckGc,EFalse); - iCheckWin->BackedUpWin()->UpdateScreen(); - break; - case EClientRedrawsScrolled: - { - DoDrawingL(0,aWinGc,ETrue); - TRegionFix<8> region; - region.AddRect(TRect(iWinSize)); - region.SubRect(iScrollTarget); - aWinGc->SetClippingRegion(region); - DoDrawingL(iState,aWinGc,ETrue); - aWinGc->CancelClippingRegion(); - aWinGc->SetClippingRect(iScrollTarget); - aWinGc->SetOrigin(iScrollTarget.iTl-iScrollSource); - DoDrawingL(iState,aWinGc,ETrue); - aWinGc->CancelClippingRect(); - break; - } - } - TheClient->Flush(); - } - -#define KLastDrawingCase 24 //This should always be the same as the value of last case number in the switch statement of the next function -void CTRedrawStoring::DoDrawingL(TInt aDraw,CBitmapContext* aGc,TBool aWinGc) - { - switch (aDraw) - { - case 0: - case 1: - aGc->SetBrushColor(TRgb(255,(aDraw==0?255:0),255)); - aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - aGc->SetPenStyle(CGraphicsContext::ENullPen); - aGc->DrawRect(iWinSize); - iDoScrollTest=EFalse; - break; - case 2: - aGc->SetPenStyle(CGraphicsContext::ESolidPen); - aGc->SetPenSize(TSize(1,1)); - aGc->SetPenColor(TRgb(0,0,0)); - aGc->DrawLine(TPoint(0,10),TPoint(iWinSize.iWidth,10)); - aGc->SetPenColor(TRgb(128,0,0)); - aGc->DrawLine(TPoint(0,iWinSize.iHeight-10),TPoint(iWinSize.iWidth,iWinSize.iHeight-10)); - aGc->SetPenColor(TRgb(0,128,0)); - aGc->DrawLine(TPoint(10,0),TPoint(10,iWinSize.iHeight)); - aGc->SetPenColor(TRgb(0,0,128)); - aGc->DrawLine(TPoint(iWinSize.iWidth-10,0),TPoint(iWinSize.iWidth-10,iWinSize.iHeight)); - iDoScrollTest=EFalse; - break; - case 3: - //Do various drawing using: MoveTo, MoveBy, Plot, DrawLineTo, DrawLineBy - aGc->SetPenStyle(CGraphicsContext::ESolidPen); - aGc->SetPenColor(TRgb(0,0,0)); - aGc->MoveTo(TPoint(iWinSize.iWidth, iWinSize.iHeight)); - aGc->DrawLineTo(TPoint(0, 0)); - aGc->MoveBy(TPoint(iWinSize.iWidth, 0)); - aGc->DrawLineTo(TPoint(0, iWinSize.iHeight)); - aGc->MoveTo(TPoint(0, iWinSize.iHeight/2)); - aGc->DrawLineBy(TPoint(iWinSize.iWidth, 0)); - aGc->SetPenSize(TSize(5,5)); - aGc->Plot(TPoint(iWinSize.iWidth/2, 20)); - aGc->Plot(TPoint(iWinSize.iWidth/2, iWinSize.iHeight/2)); - aGc->Plot(TPoint(iWinSize.iWidth/2, iWinSize.iHeight-20)); - aGc->SetPenSize(TSize(1,1)); - iDoScrollTest=EFalse; - break; - case 4: - //Do various drawing with lines of different widths - { - TInt inc=iWinSize.iHeight/8; - TInt penSize=2; - TInt yy; - aGc->SetPenStyle(CGraphicsContext::ESolidPen); - aGc->SetPenColor(TRgb(0,0,0)); - for (yy=0;yySetPenSize(TSize(penSize,penSize)); - else if (yy%3==1) - aGc->SetPenSize(TSize(penSize,7*penSize/5)); - else - aGc->SetPenSize(TSize(7*penSize/5,penSize)); -#else - aGc->SetPenSize(TSize(penSize,penSize)); -#endif - aGc->DrawLine(TPoint(2,yy),TPoint(iWinSize.iWidth-3,yy)); - penSize+=2; - } - aGc->SetPenSize(TSize(1,1)); - } - iDoScrollTest=ETrue; - break; - case 5: - //Some drawing using fading on the gc - aGc->SetPenStyle(CGraphicsContext::ESolidPen); - aGc->SetPenColor(TRgb(0,0,255)); -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - aGc->SetFaded(ETrue); -#endif - aGc->SetPenSize(TSize(10,10)); - aGc->DrawLine(TPoint(0,iWinSize.iHeight/2-5),TPoint(iWinSize.iWidth,iWinSize.iHeight/2-5)); -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - aGc->SetFaded(EFalse); -#endif - aGc->DrawLine(TPoint(0,iWinSize.iHeight/2+5),TPoint(iWinSize.iWidth, iWinSize.iHeight/2+5)); - aGc->SetPenStyle(CGraphicsContext::ESolidPen); - aGc->SetPenColor(TRgb(0,0,255)); -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - aGc->SetFaded(ETrue); - aGc->SetFadingParameters(0,127); -#endif - aGc->SetPenSize(TSize(10,10)); - aGc->DrawLine(TPoint(iWinSize.iWidth/2-5,0),TPoint(iWinSize.iWidth/2-5,iWinSize.iHeight)); -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - aGc->SetFaded(EFalse); - // default params - aGc->SetFadingParameters(128,255); -#endif - aGc->DrawLine(TPoint(iWinSize.iWidth/2+5,0),TPoint(iWinSize.iWidth/2+5,iWinSize.iHeight)); -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - aGc->SetFaded(EFalse); -#endif - iDoScrollTest=ETrue; - break; - case 6: - // Fading on window - aGc->SetPenStyle(CGraphicsContext::ESolidPen); - aGc->SetPenColor(TRgb(0,255,0)); - aGc->SetPenSize(TSize(10,10)); - aGc->DrawLine(TPoint(0,iWinSize.iHeight/2),TPoint(iWinSize.iWidth,iWinSize.iHeight/2)); - aGc->DrawLine(TPoint(iWinSize.iWidth/2,0),TPoint(iWinSize.iWidth/2,iWinSize.iHeight)); - iDoScrollTest=EFalse; - break; - case 7: - //Some drawing with text - create and destroy the font as soon as used - { - CFbsFont *font; - TFontSpec fspec(_L("Swiss"),190); - User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)font,fspec)); - aGc->SetPenColor(TRgb(0,0,0)); - aGc->UseFont(font); - aGc->DrawText(_L("Hello"), TPoint(20,20)); - aGc->DiscardFont(); - TheClient->iScreen->ReleaseFont(font); - - CFbsFont *font2; - TInt fontSize = 100; - TInt inc = 10; - for (TInt i=0; i<20; i++) - { - TFontSpec fspec2(_L("Ariel"), fontSize); - User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)font2,fspec2)); - aGc->SetPenColor(TRgb(0,0,0)); - aGc->UseFont(font2); - aGc->DrawText(_L("Hello"), TPoint(20,100)); - aGc->DiscardFont(); - TheClient->iScreen->ReleaseFont(font2); - fontSize+=inc; - } - iDoScrollTest=ETrue; - } - break; - case 8: - //Some drawing with bitmaps - create and destroy the bitmap as soon as used - { - CFbsBitmap* testBitmap; - testBitmap=new(ELeave) CFbsBitmap(); - User::LeaveIfError(testBitmap->Load(TEST_BITMAP_NAME,0)); - aGc->DrawBitmap(TRect(TPoint(10,10), TPoint(150,150)), testBitmap); - delete testBitmap; - iDoScrollTest=ETrue; - } - break; - case 9: - //Some drawing with clipping regions and rects - - //clipping rect - - aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - aGc->SetPenStyle(CGraphicsContext::ENullPen); - aGc->SetClippingRect(TRect(TPoint(50,0), TSize(iWinSize.iWidth/2,100))); - aGc->SetBrushColor(TRgb(255,255,0)); - aGc->DrawRect(TRect(TPoint(0,0), TPoint(100,100))); - aGc->SetBrushColor(TRgb(0,128,128)); - aGc->DrawRect(TRect(TPoint(iWinSize.iWidth/2,0), TSize(iWinSize.iWidth/2,100))); - aGc->CancelClippingRect(); - - - //regions - - iRegion.AddRect(TRect(TPoint(0,30), TSize(3*iWinSize.iWidth/4,150))); - iRegion.AddRect(TRect(TPoint(iWinSize.iWidth/2-20, 0), TSize(70,70))); - - aGc->SetClippingRegion(iRegion); - - aGc->SetBrushColor(TRgb(0,200,0)); - aGc->DrawRect(TRect(TPoint(5,5), TPoint(iWinSize.iWidth-50,200))); - aGc->SetBrushColor(TRgb(200,0,0)); - aGc->DrawRect(TRect(TPoint(50,50), TPoint(iWinSize.iWidth/2,150))); - aGc->SetBrushColor(TRgb(0,0,200)); - aGc->DrawRect(TRect(TPoint(20,10), TPoint(100,100))); - - aGc->CancelClippingRegion(); - - iDoScrollTest=EFalse; - break; - case 10: - //Some drawing with deactivating and reactivating the gc on the window (if it is indeed it is window gc) - - aGc->SetBrushColor(TRgb(0,0,255)); - aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - aGc->SetPenStyle(CGraphicsContext::ENullPen); - aGc->DrawRect(TRect(TPoint(20,20), TSize(50,50))); - - if (aWinGc) - { - static_cast(aGc)->Deactivate(); - - // Associate gc with another window and change attributes - static_cast(aGc)->Activate(iWinTestGc); - aGc->SetPenStyle(CGraphicsContext::ESolidPen); - aGc->SetPenColor(TRgb(0,0,255)); - static_cast(aGc)->Deactivate(); - static_cast(aGc)->Activate(*iTestWin->DrawableWin()); - } - - aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - aGc->SetPenStyle(CGraphicsContext::ENullPen); - aGc->SetBrushColor(TRgb(200,0,0)); - aGc->DrawRect(TRect(TPoint(70,70), TSize(50,50))); - iDoScrollTest=EFalse; - break; - case 11: - // Some drawing with polygons - { - aGc->SetBrushColor(TRgb(0,221,0)); - aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - aGc->SetPenStyle(CGraphicsContext::ENullPen); - - TPoint point1(iWinSize.iWidth/3,iWinSize.iHeight/4*3); - TPoint point2(iWinSize.iWidth/2,iWinSize.iHeight/5*4); - TPoint point3(iWinSize.iWidth/3,iWinSize.iHeight-20); - TPoint point4(iWinSize.iWidth/4,iWinSize.iHeight-20); - TPoint point5(iWinSize.iWidth/6,iWinSize.iHeight-60); - - CArrayFix* points; - points = new CArrayFixFlat(5); - points->AppendL(point1); - points->AppendL(point2); - points->AppendL(point3); - points->AppendL(point4); - points->AppendL(point5); - aGc->DrawPolygon(points); - delete points; - - TPoint points2[5]; - points2[0].SetXY(iWinSize.iWidth/2,50); - points2[1].SetXY(iWinSize.iWidth-50,iWinSize.iHeight/2); - points2[2].SetXY(iWinSize.iWidth-70,iWinSize.iHeight/2+30); - points2[3].SetXY(iWinSize.iWidth/3,iWinSize.iHeight/3); - points2[4].SetXY(iWinSize.iWidth/4,iWinSize.iHeight/4); - aGc->SetBrushColor(TRgb(221,0,0)); - aGc->DrawPolygon(points2,5); - iDoScrollTest=ETrue; - } - break; - case 12: - { - // Another Fading on Window Test - aGc->SetPenStyle(CGraphicsContext::ENullPen); - aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - aGc->SetBrushColor(TRgb(51,204,204)); -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - if (!iWindowsFaded || aWinGc) - { - aGc->SetFaded(ETrue); - } -#endif - aGc->DrawRect(TRect(iWinSize.iWidth/4-1,iWinSize.iHeight/4-1,3*iWinSize.iWidth/4+1,3*iWinSize.iHeight/4+1)); -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - aGc->SetFaded(EFalse); -#endif - aGc->SetBrushStyle(CGraphicsContext::ENullBrush); - aGc->SetPenStyle(CGraphicsContext::ESolidPen); - aGc->SetPenColor(TRgb(34,204,34)); - aGc->SetPenSize(TSize(8,8)); - aGc->DrawLine(TPoint(2,iWinSize.iHeight/2+5),TPoint(iWinSize.iWidth-2,iWinSize.iHeight/2-5)); - aGc->DrawLine(TPoint(iWinSize.iWidth/2+5,2),TPoint(iWinSize.iWidth/2-5,iWinSize.iHeight-2)); -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - if (!iWindowsFaded || aWinGc) - { - aGc->SetFaded(ETrue); - } -#endif - aGc->SetPenColor(TRgb(51,221,51)); - aGc->SetPenSize(TSize(3,3)); - aGc->SetBrushColor(TRgb(238,34,238)); - aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - aGc->DrawRect(TRect(3*iWinSize.iWidth/8-1,3*iWinSize.iHeight/8-1,5*iWinSize.iWidth/8+1,5*iWinSize.iHeight/8+1)); -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - aGc->SetFaded(EFalse); -#endif - aGc->SetBrushStyle(CGraphicsContext::ENullBrush); - aGc->SetPenColor(TRgb(238,34,238)); -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - aGc->SetPenSize(TSize(8,9)); -#else - aGc->SetPenSize(TSize(8,8)); -#endif - aGc->DrawRect(TRect(iWinSize.iWidth/8-1,iWinSize.iHeight/8-1,7*iWinSize.iWidth/8+1,7*iWinSize.iHeight/8+1)); - iDoScrollTest=ETrue; - } - break; - case 15: - //Some masked drawing with FBS bitmaps - create and destroy the bitmaps as soon as used - { - CFbsBitmap* testBitmap; - CFbsBitmap* maskBitmap; - testBitmap=new(ELeave) CFbsBitmap(); - CleanupStack::PushL(testBitmap); - maskBitmap=new(ELeave) CFbsBitmap(); - CleanupStack::PushL(maskBitmap); - User::LeaveIfError(testBitmap->Load(TEST_BITMAP_NAME,2)); - User::LeaveIfError(maskBitmap->Load(TEST_BITMAP_NAME,4)); - aGc->BitBltMasked(TPoint(10,10), testBitmap, TRect(TPoint(0, 0), testBitmap->SizeInPixels()), maskBitmap, EFalse); - CleanupStack::PopAndDestroy(2, testBitmap); - iDoScrollTest=ETrue; - } - break; - case 16: - //As above, except using Ws bitmaps - { - CWsBitmap* testBitmap; - CWsBitmap* maskBitmap; - testBitmap=new(ELeave) CWsBitmap(TheClient->iWs); - CleanupStack::PushL(testBitmap); - maskBitmap=new(ELeave) CWsBitmap(TheClient->iWs); - CleanupStack::PushL(maskBitmap); - User::LeaveIfError(testBitmap->Load(TEST_BITMAP_NAME,3)); - User::LeaveIfError(maskBitmap->Load(TEST_BITMAP_NAME,4)); - // If we don't cast to the window gc we don't see the WS version of the BitBltMasked function: - if(aWinGc) - ((CWindowGc*)aGc)->BitBltMasked(TPoint(20,20), testBitmap, TRect(TPoint(0, 0), testBitmap->SizeInPixels()), maskBitmap, EFalse); - else - aGc->BitBltMasked(TPoint(20,20), testBitmap, TRect(TPoint(0, 0), testBitmap->SizeInPixels()), maskBitmap, EFalse); - CleanupStack::PopAndDestroy(2, testBitmap); - iDoScrollTest=ETrue; - } - break; - case 19: - //Some drawing with WS bitmaps - { - if(!iAlphaBitmap[0]) - { - for(TInt bmp = 0; bmp < 3; ++bmp) - { - iAlphaBitmap[bmp] = new(ELeave) CWsBitmap(TheClient->iWs); - User::LeaveIfError(iAlphaBitmap[bmp]->Load(TEST_BITMAP_NAME,2 + bmp)); - } - } - if(aWinGc) - ((CWindowGc*)aGc)->BitBlt(TPoint(20,20), iAlphaBitmap[0]); - else - aGc->BitBlt(TPoint(20,20), iAlphaBitmap[0]); - iDoScrollTest=ETrue; - } - break; - case 20: - //Some drawing with alpha blended bitmaps - if (iAlphaSupported) - { - aGc->SetFaded(EFalse); - TPoint start(0,0); - TSize size = iAlphaBitmap[0]->SizeInPixels(); - TPoint alphastart((start.iX + size.iWidth / 4), (start.iY + size.iHeight / 4)); - - aGc->BitBlt(start, iAlphaBitmap[0], TRect(start, size)); - aGc->AlphaBlendBitmaps(start, iAlphaBitmap[1], TRect(start, size), iAlphaBitmap[2], alphastart); - iDoScrollTest=ETrue; - } - break; - case 21: - // As in previous case, except using FBS bitmaps. - if (iAlphaSupported) - { - aGc->SetFaded(EFalse); - CFbsBitmap* baseBitmap; - CFbsBitmap* testBitmap; - CFbsBitmap* alphaBitmap; - baseBitmap=new(ELeave) CFbsBitmap(); - CleanupStack::PushL(baseBitmap); - testBitmap=new(ELeave) CFbsBitmap(); - CleanupStack::PushL(testBitmap); - alphaBitmap=new(ELeave) CFbsBitmap(); - CleanupStack::PushL(alphaBitmap); - User::LeaveIfError(baseBitmap->Load(TEST_BITMAP_NAME,2)); - User::LeaveIfError(testBitmap->Load(TEST_BITMAP_NAME,3)); - User::LeaveIfError(alphaBitmap->Load(TEST_BITMAP_NAME,4)); - TPoint start(0,0); - TSize size = baseBitmap->SizeInPixels(); - TPoint alphastart((start.iX + size.iWidth / 4), (start.iY + size.iHeight / 4)); - - aGc->BitBlt(start, baseBitmap, TRect(start, size)); - aGc->AlphaBlendBitmaps(start, testBitmap, TRect(start, size), alphaBitmap, alphastart); - - CleanupStack::PopAndDestroy(3, baseBitmap); - iDoScrollTest=ETrue; - } - break; - case 22: - // Some default drawing for Begin EndRedraw test - aGc->SetPenStyle(CGraphicsContext::ESolidPen); - aGc->SetPenSize(TSize(2,2)); - aGc->SetPenColor(TRgb(128,0,0)); - aGc->DrawLine(TPoint(10,10),TPoint(20,10)); - aGc->DrawLine(TPoint(20,10),TPoint(20,20)); - aGc->DrawLine(TPoint(20,20),TPoint(10,20)); - aGc->DrawLine(TPoint(10,20),TPoint(10,10)); - - aGc->SetPenSize(TSize(4,4)); - aGc->SetPenColor(TRgb(0,0,128)); - aGc->DrawLine(TPoint(50,50),TPoint(150,50)); - aGc->DrawLine(TPoint(150,50),TPoint(150,150)); - aGc->DrawLine(TPoint(150,150),TPoint(50,150)); - aGc->DrawLine(TPoint(50,150),TPoint(50,50)); - iDoScrollTest=EFalse; - break; - case 23: - aGc->SetBrushColor(TRgb(244,196,48)); - aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - aGc->SetPenStyle(CGraphicsContext::ENullPen); - aGc->DrawRect(TRect(0,0,iWinSize.iWidth,iWinSize.iHeight/3)); - aGc->SetBrushColor(TRgb(255,255,255)); - aGc->DrawRect(TRect(0,iWinSize.iHeight/3,iWinSize.iWidth,iWinSize.iHeight*2/3)); - aGc->SetBrushColor(TRgb(3,192,60)); - aGc->DrawRect(TRect(0,iWinSize.iHeight*2/3,iWinSize.iWidth,iWinSize.iHeight)); - iDoScrollTest=EFalse; - break; - case 24: - iClientDidDraw=ETrue; - //Draw some rects to screen - aGc->Reset(); - aGc->Clear(); - aGc->SetPenStyle(CGraphicsContext::ESolidPen); - aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - aGc->SetBrushColor(TRgb(98,72,172)); - aGc->DrawRect(TRect(20,iYPoz,250,280+iYPoz)); - aGc->SetBrushColor(TRgb(255,0,0)); - aGc->DrawRect(TRect(0,iYPoz,200,200+iYPoz)); - aGc->SetBrushColor(TRgb(0,255,255)); - aGc->DrawRect(TRect(10,15+iYPoz,250,115+iYPoz)); - aGc->SetBrushColor(TRgb(0,255,0)); - aGc->DrawRect(TRect(0,50+iYPoz,100,250+iYPoz)); - aGc->SetBrushColor(TRgb(255,255,0)); - aGc->DrawRect(TRect(50,50+iYPoz,150,150+iYPoz)); - aGc->SetBrushColor(TRgb(5,25,20)); - aGc->DrawRect(TRect(120,170+iYPoz,220,250+iYPoz)); - break; - } - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-0085 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Do Draw Test - REQUIREMENT: REQ2123 - GT0164/Delta/ 1450, 1460, 1470, 1490, 1500, 1510, 1520, 1530 - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Lots of different type of drawing is done to the test window. - (Including: normal drawing, fonts, bitmaps, fading on the GC, - clipping regions and rects). - A blank window is made visible then invisible above the test window - The blank window's size and position is also changed many times. - -@SYMTestExpectedResults After the initial drawing of the test window, all the draw commands - should be stored by the window server. When the blank window is made - visible/invisible above the test window a redraw message will be sent - to the test window. The window will be redrawn using the draw commands - stored in the server. Once all the redrawing is complete, the test window - will be compared with a bitmap that has had the same draw commands applied - to it. - The test will fail if the bitmaps don't match or if the test window was - redrawn not using the stored server side draw commands. - */ - -void CTRedrawStoring::DoDrawTest() - { - RedrawWindows(); - HideRevealTest(); - iTestWin->SetVisible(EFalse); - iTestWin->SetVisible(ETrue); - CheckWindowsMatch(); - MultipleHideReveal(2,3); - MultipleHideReveal(5,4); - iBlankWin.SetExtent(iWinPos,iWinSize); - HideRevealTest(); - CheckWindowsMatch(); - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-0086 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Fade Window Test - REQUIREMENT: REQ2123 - GT0164/Delta/ 1480 - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions The test window is faded and the GC associated with the bitmap used - to check the test window is faded. The Draw Test in TestCase 1 is then - applied. - -@SYMTestExpectedResults The test window and the check bitmap should both be faded and contain - the same drawing. The test will fail if the bitmaps don't match or if the - test window was redrawn not using the stored server side draw commands. - - */ -void CTRedrawStoring::FadeWindowTest() - { - iWindowsFaded = ETrue; - iTestWin->Win()->SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly); - iCheckGc->SetFaded(ETrue); - DoDrawTest(); - iDrawMode=EClientRedrawsNormal; - iTestWin->Win()->SetFaded(EFalse,RWindowTreeNode::EFadeWindowOnly); - iCheckGc->SetFaded(EFalse); - TheClient->Flush(); - TheClient->WaitForRedrawsToFinish(); - iWindowsFaded = EFalse; - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-0087 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Fade Window Test 2 - REQUIREMENT: REQ2123 - GT0164/Delta/ 1480 - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions The test window is faded and the check window that uses the check bitmap - is faded. A blank window is made visbible/invisible above the test window. - Fading is switched off on both windows, they are redrawn and then compared. - -@SYMTestExpectedResults The test window and the check bitmap should both be faded. After showing - the blank window the test window will contain a couple of rectangles faded due to - Gc fade apart from the overall window fade (will look similar to double fading), whereas - check window will have simply the overall window fade. Once both windows have been - redrawn with the fading switched off, they should not look the same for the same - reason explained above. - - */ -void CTRedrawStoring::FadeWindowTest2L() - { - DoDrawTest(); - iWindowsFaded=ETrue; - iTestWin->BaseWin()->SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly); - iCheckWin->BaseWin()->SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly); - CheckWindowsMatch(); - -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - //perform RedrawWindows() with CheckWindowsNotMatch() - iDrawMode=EClientRedrawsNormal; - iTestWin->Invalidate(); - CheckWindowsNotMatch(); - iDrawMode=EServerRedraw; - - //perform HideRevealTest() with CheckWindowsNotMatch() - iBlankWin.SetVisible(ETrue); - iBlankWin.SetVisible(EFalse); - CheckWindowsNotMatch(); -#endif - - iWindowsFaded=EFalse; - iTestWin->BaseWin()->SetFaded(EFalse,RWindowTreeNode::EFadeWindowOnly); - iCheckWin->BaseWin()->SetFaded(EFalse,RWindowTreeNode::EFadeWindowOnly); - iDrawMode=EClientRedrawsNormal; - DoDrawingL(0,iCheckGc,EFalse); - DoDrawingL(iState,iCheckGc,EFalse); - iCheckWin->BackedUpWin()->UpdateScreen(); - iDrawMode=EServerRedraw; - CheckWindowsMatch(); - HideRevealTest(); - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-0088 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Scroll Test - REQUIREMENT: REQ2123 - GT0164/Delta/ 1540 - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Different areas of the test window are scrolled, the check bitmap - window is also adjusted to reflect this scrolling. The blank window is - then made visible/invisible above the test window - -@SYMTestExpectedResults The test will fail if the bitmaps don't match or if the test window was - redrawn not using the stored server side draw commands. - - */ -void CTRedrawStoring::ScrollTest() - { - CheckWindowsMatch(); - TInt x=iWinSize.iWidth/3; - TInt w=iWinSize.iWidth/4; - SetScrolling(TPoint(10,20),TRect(x,100,x+w,160)); - DoScrollTest(); - x=iWinSize.iWidth/2; - w=iWinSize.iWidth/3; - SetScrolling(TPoint(48,100),TRect(x,10,x+w,80)); - DoScrollTest(); - x=iWinSize.iWidth/10; - w=iWinSize.iWidth/5; - SetScrolling(TPoint(iWinSize.iWidth/2,20),TRect(x,100,x+w,150)); - DoScrollTest(); - } - -void CTRedrawStoring::DoScrollTest() - { - TheClient->Flush(); - iDrawMode=EClientRedrawsScrolled; - CheckWindowsMatch(); - iDrawMode=EServerRedraw; - HideRevealTest(); - RedrawWindows(); - CheckWindowsMatch(); - } - -void CTRedrawStoring::SetScrolling(TPoint aScrollSource, TRect aScrollTarget) - { - iScrollSource=aScrollSource; - iScrollTarget=aScrollTarget; - iTestWin->DrawableWin()->Scroll(iScrollTarget.iTl-iScrollSource,TRect(iScrollSource,iScrollTarget.Size())); - iCheckWin->DrawableWin()->Scroll(iScrollTarget.iTl-iScrollSource,TRect(iScrollSource,iScrollTarget.Size())); - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-0090 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Do Nothing in Redraw Test - REQUIREMENT: REQ2123 - GT0164/Delta/ 1570 - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions A window is created that contains no drawing code. A blank window is - made visible/invisible above this window. - -@SYMTestExpectedResults No buffer will be created server side because there are no draw commands - to store. The server should be able to cope with an empty buffer when the - redraw is issued, caused by the blank win. - - */ -void CTRedrawStoring::DoNothingInRedrawTest() - { - // iNoDrawWin contains no drawing code, therefore no server side - // redraw store buffer will be created in a redraw. - // When a redraw occurs because the blank win is made visible/invisible, - // the server will try and access the non existant buffer, all being well - // nothing should happen because the server can cope with an empty redraw - // buffer. - - iTestWin->SetVisible(EFalse); - iNoDrawWin->Activate(); - TheClient->Flush(); - TheClient->WaitForRedrawsToFinish(); - iDrawMode=EServerRedraw; - iBlankWin.SetOrdinalPosition(0); - iBlankWin.SetVisible(ETrue); - iBlankWin.SetVisible(EFalse); - TheClient->Flush(); - - //return to normal testing state - iNoDrawWin->SetVisible(EFalse); - iTestWin->SetVisible(ETrue); - RedrawWindows(); - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-0091 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Disable Redraw Store Test - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions A windows redraw store is disabled and enabled, and the window is exposed. - -@SYMTestExpectedResults When the redraw store is disabled, a client redraw should occur when the window - is exposed. When it is enabled, no client redraw should occur. However, the - first time it is exposed after enabling the store it will need a client redraw - in order to fill the store. - - */ -void CTRedrawStoring::DoDisableRedrawStoreTest() - { - _LIT(KLog1,"Redraw storing not enabled when expected to be"); - _LIT(KLog2,"No client redraw was done when it was expected"); - RedrawWindows(); - CheckWindowsMatch(); - - iDrawMode=EServerRedraw; - HideRevealTest(); - - iClientDidDraw=EFalse; - TBool isEnabled=iTestWin->Win()->IsRedrawStoreEnabled(); - TEST(isEnabled); - if (!isEnabled) - LOG_MESSAGE(KLog1); - - /*iTestWin->Win()->EnableRedrawStore(EFalse); - isEnabled=iTestWin->Win()->IsRedrawStoreEnabled(); - TEST(!isEnabled); - if (isEnabled) - { - _LIT(KLog,"Redraw storing enabled when expected not to be"); - LOG_MESSAGE(KLog); - } - - iDrawMode=EClientRedrawsNormal; - HideRevealTest(); - TEST(iClientDidDraw); - if (!iClientDidDraw) - { - LOG_MESSAGE(KLog2); - TheClient->WaitForRedrawsToFinish(); - if (iClientDidDraw) - { - _LIT(KLog,"After Waiting Redraws had taken place"); - LOG_MESSAGE(KLog); - } - }*/ - - iTestWin->Win()->EnableRedrawStore(ETrue); - isEnabled=iTestWin->Win()->IsRedrawStoreEnabled(); - TEST(isEnabled); - if (!isEnabled) - LOG_MESSAGE(KLog1); - - HideRevealTest(); - iDrawMode=EServerRedraw; - HideRevealTest(); - - iClientDidDraw=EFalse; - TheClient->iWs.ClearAllRedrawStores(); - iDrawMode=EClientRedrawsNormal; - HideRevealTest(); - TEST(iClientDidDraw); - if (!iClientDidDraw) - { - LOG_MESSAGE(KLog2); - TheClient->WaitForRedrawsToFinish(); - if (iClientDidDraw) - { - _LIT(KLog,"After Waiting Redraws had taken place"); - LOG_MESSAGE(KLog); - } - } - - HideRevealTest(); - iDrawMode=EServerRedraw; - HideRevealTest(); - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-0092 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Resize Redraws - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions A window is resized. - -@SYMTestExpectedResults When the window decreases in size, the server should be able to - redraw it from the store. When it increases in size, a client redraw - should occur. - - */ -void CTRedrawStoring::DoResizeTest() - { - RedrawWindows(); - - TSize oldsize = iTestWin->Win()->Size(); - - iDrawMode=EServerRedraw; - iTestWin->Win()->SetSize(TSize(8, 8)); - TheClient->Flush(); - TheClient->WaitForRedrawsToFinish(); - - iClientDidDraw=EFalse; - iDrawMode=EClientRedrawsNormal; - iTestWin->Win()->SetSize(oldsize); - TheClient->Flush(); - TheClient->WaitForRedrawsToFinish(); - TEST(iClientDidDraw); - if (!iClientDidDraw) - INFO_PRINTF3(_L("iClientDidDraw - Expected: %d, Actual: %d"), ETrue, iClientDidDraw); - - } - -/* TESTCASE: 9 - * TITLE: Font Cache Overflow - * IMPORTANCE: 1 - * REQUIREMENT: DEF065463 - * - * - * API: - * # - * - * ACTION: - * The Font Cache is overflowed - * - * RESULT: - * If the font cache overflows or under out of memory conditions, - * there should be no leaves, panics or incorrect behaviour of the - * local array of font handles. - */ - - void CTRedrawStoring::DoFontCacheOverflowTestL() - { - RWindow window(TheClient->iWs); - User::LeaveIfError(window.Construct(*TheClient->iGroup->WinTreeNode(), ENullWsHandle)); - CleanupClosePushL(window); - window.Activate(); - // Display mode is set after window.Activate() purposely to check that drawing - // is done in the right mode, in order to test fix for DEF083327 - User::LeaveIfError(window.SetRequiredDisplayMode(EColor256)); - - // run test using a single gc - FontCacheOverflowDrawingTestL(EFalse, window); - // reset for next test - window.Invalidate(); - iXPlus = ETrue; - iYPlus = EFalse; - // run test using multiple gcs - FontCacheOverflowDrawingTestL(ETrue, window); - - CleanupStack::PopAndDestroy(&window); - } - -/* TESTCASE: 22 -* TITLE: Scroll Window -* IMPORTANCE: -* REQUIREMENT: -* -* -* API: -* # -* -* ACTION: -* A window is scrolled then a blank window is popped up, made visible and then -* invisible in order to test that partial redraw storing is drawing window -* contents properly after hiding the blank window. -* -* Before the fix, the contents used to disappear as partial redraw storing was -* not storing the commands to draw areas outside the defined clipping rect, in -* this case the area covered by the popped window. Now, the fix makes sure that -* full redraw to the window is applied when there are atored commands but the -* changes are performed only in the covered area. -* -* RESULT: -* When the blank window is hidden, the covered area will be redrawn and will -* contain the original contents before poping the blank window. -* -*/ -void CTRedrawStoring::ScrollWinTest() - { - iDrawMode=EClientRedrawsNormal; - - // Drawing the contents first before scrolling - iTestWin->DrawNow(); - - // Scrolling the test window and updating its y position - iTestWin->DrawableWin()->Scroll(TPoint(0, 25)); - iYPoz += 25; - - // Invalidating and redrawing the area that should be updated - TRect invalidRect(0,25, iWinSize.iWidth, 25*2); - iTestWin->Invalidate(invalidRect); - iTestWin->Redraw(invalidRect); // Redraw is used instead of DrawNow becuase the later calls Invalidate on the whole window - - // Displaying and then hiding the popup blank window - iBlankWin.SetExtent(TPoint(iWinSize.iWidth+40,30), TSize(120, 100)); - iBlankWin.SetVisible(ETrue); - iBlankWin.SetVisible(EFalse); - TheClient->Flush(); - TheClient->WaitForRedrawsToFinish(); - - // Resetting iBlankWin to its original size and position for future use - // by other test cases - iBlankWin.SetExtent(iWinPos, iWinSize); - CheckWindowsMatch(); - iYPoz=0; - } - - -TPoint CTRedrawStoring::ComputeTextPosition(TPoint aPoint) - { - // Bounces text around the screen - const TInt KSpacing = 30; - - if(iXPlus) - { - aPoint.iX += KSpacing; - } - else - { - aPoint.iX -= KSpacing; - } - if(aPoint.iX > iWinSize.iWidth) - { - aPoint.iX = iWinSize.iWidth - (aPoint.iX - iWinSize.iWidth); - iXPlus = EFalse; - } - else if(aPoint.iX < 0) - { - aPoint.iX = -1*aPoint.iX; - iXPlus = ETrue; - } - - if(iYPlus) - { - aPoint.iY += KSpacing; - } - else - { - aPoint.iY -= KSpacing; - } - if(aPoint.iY > iWinSize.iHeight) - { - aPoint.iY = iWinSize.iHeight - (aPoint.iY - iWinSize.iHeight); - iYPlus = EFalse; - } - else if(aPoint.iY < 0) - { - aPoint.iY = -1*aPoint.iY; - iYPlus = ETrue; - } - return aPoint; - } - -void CTRedrawStoring::FontCacheOverflowDrawingTestL(TBool aDiffGc, RWindow& aWindow) - { - const TInt KNumFonts = 250; - const TInt KNumFontTypes = TheClient->iScreen->NumTypefaces(); - const TInt KMaxFontSize = 21; // font sizes to be tested in range 1 to 21 - const TInt KNumTestStyles = 4; - const TInt KNumSizes = KNumFonts/(KNumFontTypes * KNumTestStyles) + 1; // chooses a number of font sizes to overflow cache, rounded up - TInt textStyle = 0; //determines whether text is not changed (0), bold (1), bold and italic (2) or italic (3) - TInt fontType = 0; //increment for different font types - TInt currentSize = 1; // start with a font size of 1 - TInt fontSizeIncrement = KMaxFontSize - currentSize; //defaults to 20 - if(KNumSizes>2) - { - fontSizeIncrement = KMaxFontSize/(KNumSizes-1); - } - TInt numGcs = 1; - if(aDiffGc) - { - numGcs = KNumFonts; - } - _LIT(KTestText,"b8-/+.,*:"); - const TSize KScrSize(TheClient->iScreen->SizeInPixels()); - TSize fontCacheWinSize(KScrSize.iWidth/2,KScrSize.iHeight); - iTestWinPoint.SetXY(fontCacheWinSize.iWidth/2, fontCacheWinSize.iHeight/2); //draw initially near the middle of the screen - - CWindowGc* winGc = NULL; - RArray winGcList; - CleanupClosePushL(winGcList); - - aWindow.BeginRedraw(); - - // fill an array with fonts of different styles (see textStyle comment), types, and sizes - RArray fontArray; - CleanupClosePushL(fontArray); - for(TInt ii = 0; ii < KNumFonts; ii++) - { - if(ii && !(ii % (KNumTestStyles * KNumSizes))) - { - fontType++; - textStyle = 0; - currentSize = 1; - } - else if(ii && !(ii % KNumTestStyles)) - { - currentSize += fontSizeIncrement; - textStyle = 0; - } - TTypefaceSupport support; - TheClient->iScreen->TypefaceSupport(support, fontType); - TFontSpec fspec(support.iTypeface.iName.Des(), currentSize); - switch(textStyle++) - { - case 0: - fspec.iFontStyle.SetPosture(EPostureUpright); - break; - case 1: - fspec.iFontStyle.SetStrokeWeight(EStrokeWeightBold); - break; - case 2: - fspec.iFontStyle.SetPosture(EPostureItalic); - break; - case 3: - fspec.iFontStyle.SetStrokeWeight(EStrokeWeightNormal); - break; - } - CFont* font = NULL; - User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInPixels(font, fspec)); - User::LeaveIfError(fontArray.Append(font)); - font = NULL; - - // Draw to left half of screen using either one gc for all fonts, or using a font per gc, dependent on value of aDiffGc - if(iiiScreen); - CleanupStack::PushL(winGc); - User::LeaveIfError(winGc->Construct()); - winGc->Activate(aWindow); - User::LeaveIfError(winGcList.Append(winGc)); - } - winGc->UseFont(fontArray[ii]); - winGc->SetPenColor(TRgb::Color256(ii)); - winGc->DrawText(KTestText, iTestWinPoint = ComputeTextPosition(iTestWinPoint)); - } - - aWindow.EndRedraw(); - TheClient->Flush(); - - // Copy the drawing to a bitmap and redraw to the right half of the screen - CFbsBitmap* bitmap = new (ELeave) CFbsBitmap; - CleanupStack::PushL(bitmap); - bitmap->Create(TSize(fontCacheWinSize.iWidth, fontCacheWinSize.iHeight), EColor256); - User::LeaveIfError(TheClient->iScreen->CopyScreenToBitmap(bitmap, TRect(fontCacheWinSize))); - TPoint copiedBitmapOrigin(fontCacheWinSize.iWidth, 0); - TRect bitmapArea(copiedBitmapOrigin, bitmap->SizeInPixels()); - aWindow.Invalidate(bitmapArea); - aWindow.BeginRedraw(bitmapArea); - winGc->BitBlt(copiedBitmapOrigin, bitmap); - aWindow.EndRedraw(); - CleanupStack::PopAndDestroy(bitmap); - - // Trigger a redraw (left half of screen) - RBlankWindow blankWindow(TheClient->iWs); - CleanupClosePushL(blankWindow); - User::LeaveIfError(blankWindow.Construct(*TheClient->iGroup->WinTreeNode(), ENullWsHandle)); - blankWindow.SetSize(TSize(fontCacheWinSize.iWidth, fontCacheWinSize.iHeight)); - blankWindow.Activate(); - TheClient->Flush(); - blankWindow.SetVisible(EFalse); - TheClient->Flush(); - CleanupStack::PopAndDestroy(&blankWindow); - TheClient->WaitForRedrawsToFinish(); - // Compare what is redrawn with copy of original drawing - TEST(TheClient->iScreen->RectCompare(TRect(fontCacheWinSize),TRect(copiedBitmapOrigin,fontCacheWinSize))); - // Clean up all memory - for(TInt kk = 0; kk < KNumFonts; kk++) - { - if(kk < numGcs) - { - winGcList[kk]->Deactivate(); - } - TheClient->iScreen->ReleaseFont(fontArray[kk]); - } - CleanupStack::PopAndDestroy(2+numGcs, &winGcList); - } - -// As a full fledged test code is written for this implementation. -// so this test code checks whether this defect is fixed. -void CTRedrawStoring::DoTestDrawBitmapMaskedL(TInt aWsBitmap/*=EFalse*/) - { - // Create a source bitmap with display mode EColor16MU and Fill RGB lines successively - TInt bitmapWidth=iWinSize.iWidth-40; - TInt bitmapHeight=80; - TSize bitmapSize(bitmapWidth,bitmapHeight); - CFbsBitmap* fbsBitmap=NULL; - CWsBitmap* wsBitmap=NULL; - if (aWsBitmap) - { - wsBitmap=new(ELeave) CWsBitmap(TheClient->iWs); - CleanupStack::PushL(wsBitmap); - User::LeaveIfError(wsBitmap->Create(bitmapSize,EColor16MU)); - } - else - { - fbsBitmap=new(ELeave) CFbsBitmap(); - CleanupStack::PushL(fbsBitmap); - User::LeaveIfError(fbsBitmap->Create(bitmapSize,EColor16MU)); - } - - TBitmapUtil bmpUtil(aWsBitmap ? wsBitmap : fbsBitmap); - bmpUtil.Begin(TPoint(0,0)); - TInt row,col; - for(row=0;rowiWs); - CleanupStack::PushL(wsBitmapMask); - User::LeaveIfError(wsBitmapMask->Create(bitmapSize,EGray256)); - } - else - { - fbsBitmapMask=new(ELeave) CFbsBitmap(); - CleanupStack::PushL(fbsBitmapMask); - User::LeaveIfError(fbsBitmapMask->Create(bitmapSize,EGray256)); - } - - TBitmapUtil bmpUtilMask(aWsBitmap ? wsBitmapMask : fbsBitmapMask); - bmpUtilMask.Begin(TPoint(0,0)); - for(row=0;rowiScreen->SizeInPixels(); - iWinRect.SetRect(screenSize.iWidth/3,0,2*screenSize.iWidth/3,screenSize.iHeight); - iBitmapMaskedWin=CBitmapMaskedWin::NewL(fbsBitmap,fbsBitmapMask,wsBitmap,wsBitmapMask,KRgbRed,bitmapSize,EFalse,aWsBitmap); - CleanupStack::PushL(iBitmapMaskedWin); - iBitmapMaskedWin->SetExt(TPoint(screenSize.iWidth/3,0),iWinRect.Size()); - iBitmapMaskedWin->Activate(); - TheClient->Flush(); - TheClient->WaitForRedrawsToFinish(); - - // Create a bitmap window which in its draw function it just bitblts its content - // First fill that bitmap with red color - iTestWinPoint.SetXY(2*screenSize.iWidth/3,0); - iTestBitmap=CBitmap::NewL(iWinRect.Size(),EColor16MU); - CleanupStack::PushL(iTestBitmap); - iTestBitmap->Gc().SetBrushColor(TRgb(255,0,0)); - iTestBitmap->Gc().SetBrushStyle(CGraphicsContext::ESolidBrush); - iTestBitmap->Gc().SetPenStyle(CGraphicsContext::ENullPen); - iTestBitmap->Gc().DrawRect(iWinRect.Size()); - iTestBitmap->Gc().Reset(); - iTestBitmapWin=new(ELeave) CBitMapWin(iTestBitmap); - CleanupStack::PushL(iTestBitmapWin); - iTestBitmapWin->ConstructExtLD(*TheClient->iGroup,iTestWinPoint,iWinRect.Size()); - iTestBitmapWin->BaseWin()->SetRequiredDisplayMode(EColor16MU); - iTestBitmapWin->BaseWin()->SetShadowDisabled(ETrue); - iTestBitmapWin->BaseWin()->SetShadowHeight(0); - iTestBitmapWin->AssignGC(*TheClient->iGc); - iTestBitmapWin->Activate(); - - // This if for testing with Invertmask as EFalse - TSize tempSize=bitmapSize; - DrawBitmapAndCheckL(tempSize,EColor16MU,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),EFalse); - - tempSize.SetSize(bitmapSize.iWidth*11/10,bitmapSize.iHeight*11/10); - iBitmapMaskedWin->SetDestRectSize(tempSize); - iBitmapMaskedWin->DrawNow(); - TheClient->WaitForRedrawsToFinish(); - DrawBitmapAndCheckL(tempSize,EColor16MU,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),EFalse); - - tempSize.SetSize(bitmapSize.iWidth*2/3,bitmapSize.iHeight*2/3); - iBitmapMaskedWin->SetDestRectSize(tempSize); - iBitmapMaskedWin->DrawNow(); - TheClient->WaitForRedrawsToFinish(); - DrawBitmapAndCheckL(tempSize,EColor16MU,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),EFalse); - - // This if for testing with Invertmask as ETrue - tempSize=bitmapSize; - iBitmapMaskedWin->SetInvertMask(ETrue); - iBitmapMaskedWin->SetDestRectSize(tempSize); - iBitmapMaskedWin->DrawNow(); - TheClient->WaitForRedrawsToFinish(); - DrawBitmapAndCheckL(tempSize,EColor16MU,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),ETrue); - - tempSize.SetSize(bitmapSize.iWidth*11/10,bitmapSize.iHeight*11/10); - iBitmapMaskedWin->SetDestRectSize(tempSize); - iBitmapMaskedWin->DrawNow(); - TheClient->WaitForRedrawsToFinish(); - DrawBitmapAndCheckL(tempSize,EColor16MU,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),ETrue); - - tempSize.SetSize(bitmapSize.iWidth*2/3,bitmapSize.iHeight*2/3); - iBitmapMaskedWin->SetDestRectSize(tempSize); - iBitmapMaskedWin->DrawNow(); - TheClient->WaitForRedrawsToFinish(); - DrawBitmapAndCheckL(tempSize,EColor16MU,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),ETrue); - - // With bitmap's display mode as EColor256 and invertmask EFalse - if (aWsBitmap) - { - wsBitmap->SetDisplayMode(EColor256); - } - else - { - fbsBitmap->SetDisplayMode(EColor256); - } - iBitmapMaskedWin->BaseWin()->SetRequiredDisplayMode(EColor256); - TheClient->Flush(); - TheClient->WaitForRedrawsToFinish(); - - // Delete the tempbitmap and tempbitmapwin and recreate once again. - CleanupStack::PopAndDestroy(2); // iTestBitmap, iTestBitmapWin - iTestBitmap=NULL; - iTestBitmapWin=NULL; - iTestBitmap=CBitmap::NewL(iWinRect.Size(),EColor256); - CleanupStack::PushL(iTestBitmap); - iTestBitmap->Gc().SetBrushColor(TRgb(255,0,0)); - iTestBitmap->Gc().SetBrushStyle(CGraphicsContext::ESolidBrush); - iTestBitmap->Gc().SetPenStyle(CGraphicsContext::ENullPen); - iTestBitmap->Gc().DrawRect(iWinRect.Size()); - iTestBitmap->Gc().Reset(); - iTestBitmapWin=new(ELeave) CBitMapWin(iTestBitmap); - CleanupStack::PushL(iTestBitmapWin); - iTestBitmapWin->ConstructExtLD(*TheClient->iGroup,iTestWinPoint,iWinRect.Size()); - iTestBitmapWin->BaseWin()->SetRequiredDisplayMode(EColor256); - iTestBitmapWin->BaseWin()->SetShadowDisabled(ETrue); - iTestBitmapWin->BaseWin()->SetShadowHeight(0); - iTestBitmapWin->AssignGC(*TheClient->iGc); - iTestBitmapWin->Activate(); - TheClient->Flush(); - TheClient->WaitForRedrawsToFinish(); - - tempSize=bitmapSize; - iBitmapMaskedWin->SetInvertMask(EFalse); - iBitmapMaskedWin->SetDestRectSize(tempSize); - iBitmapMaskedWin->DrawNow(); - TheClient->WaitForRedrawsToFinish(); - DrawBitmapAndCheckL(tempSize,EColor256,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),EFalse); - - tempSize.SetSize(bitmapSize.iWidth*11/10,bitmapSize.iHeight*11/10); - iBitmapMaskedWin->SetDestRectSize(tempSize); - iBitmapMaskedWin->DrawNow(); - TheClient->WaitForRedrawsToFinish(); - DrawBitmapAndCheckL(tempSize,EColor256,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),EFalse); - - tempSize.SetSize(bitmapSize.iWidth*2/3,bitmapSize.iHeight*2/3); - iBitmapMaskedWin->SetDestRectSize(tempSize); - iBitmapMaskedWin->DrawNow(); - TheClient->WaitForRedrawsToFinish(); - DrawBitmapAndCheckL(tempSize,EColor256,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),EFalse); - - // With bitmap's display mode as EColor256 and invertmask ETrue - tempSize=bitmapSize; - iBitmapMaskedWin->SetInvertMask(ETrue); - iBitmapMaskedWin->SetDestRectSize(tempSize); - iBitmapMaskedWin->DrawNow(); - TheClient->WaitForRedrawsToFinish(); - DrawBitmapAndCheckL(tempSize,EColor256,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),ETrue); - - tempSize.SetSize(bitmapSize.iWidth*11/10,bitmapSize.iHeight*11/10); - iBitmapMaskedWin->SetDestRectSize(tempSize); - iBitmapMaskedWin->DrawNow(); - TheClient->WaitForRedrawsToFinish(); - DrawBitmapAndCheckL(tempSize,EColor256,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),ETrue); - - tempSize.SetSize(bitmapSize.iWidth*2/3,bitmapSize.iHeight*2/3); - iBitmapMaskedWin->SetDestRectSize(tempSize); - iBitmapMaskedWin->DrawNow(); - TheClient->WaitForRedrawsToFinish(); - DrawBitmapAndCheckL(tempSize,EColor256,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),ETrue); - - //To test if DrawBitmapMask uses stored commands when called to redraw the bitmap. - if (aWsBitmap) - { - delete wsBitmapMask; //deleting the bitmap - wsBitmapMask=NULL; - DrawBitmapAndCheckL(tempSize,EColor256,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),ETrue); - } - CleanupStack::PopAndDestroy(3,iBitmapMaskedWin); // iBitmapMaskedWin,iTestBitmap,iTestBitmapWin - } - -void CTRedrawStoring::DrawBitmapAndCheckL(const TSize aSize,TDisplayMode aDisplayMode,CFbsBitmap* aSrceBitmap,CFbsBitmap* aMaskBitmap,TBool aInvertMask) - { - TBool retVal; - if (aMaskBitmap) - { - TRect srceRect(aSrceBitmap->SizeInPixels()); - TRect destRect(aSize); - CBitmap* srcTempBitmap=CBitmap::NewL(aSize,aDisplayMode); - CleanupStack::PushL(srcTempBitmap); - srcTempBitmap->Gc().DrawBitmap(destRect,aSrceBitmap,srceRect); - CBitmap* maskTempBitmap=CBitmap::NewL(aSize,EGray256); - CleanupStack::PushL(maskTempBitmap); - maskTempBitmap->Gc().DrawBitmap(destRect,aMaskBitmap,srceRect); - iTestBitmap->Gc().SetPenStyle(CGraphicsContext::ENullPen); - iTestBitmap->Gc().SetBrushColor(TRgb(255,0,0)); - iTestBitmap->Gc().SetBrushStyle(CGraphicsContext::ESolidBrush); - iTestBitmap->Gc().DrawRect(iWinRect.Size()); - iTestBitmap->Gc().BitBltMasked(TPoint(),&srcTempBitmap->Bitmap(),destRect,&maskTempBitmap->Bitmap(),aInvertMask); - iTestBitmap->Gc().Reset(); - iTestBitmapWin->DrawNow(); - TheClient->iWs.Finish(); - TheClient->WaitForRedrawsToFinish(); - retVal = TheClient->iScreen->RectCompare(TRect(iWinRect.iTl,aSize),TRect(iTestWinPoint,aSize)); - TEST(retVal); - if (!retVal) - INFO_PRINTF3(_L("TheClient->iScreen->RectCompare() return value - Expected: %d, Actual: %d"), ETrue, retVal); - CleanupStack::PopAndDestroy(2,srcTempBitmap); - } - else - //To test if DrawBitmapMask uses stored commands, when called to redraw the bitmap. - //After the bitmap "wsBitmapMask" is being deleted, the window "iBitmapMaskWin" is first made invisible - //and then visible on the screen. This operation invokes draw function which redraws the bitmap by using the stored commands. - { - iBitmapMaskedWin->SetVisible(EFalse); - iBitmapMaskedWin->SetVisible(ETrue); - retVal = TheClient->iScreen->RectCompare(TRect(iWinRect.iTl,aSize),TRect(iTestWinPoint,aSize)); - TEST(retVal); - if (!retVal) - INFO_PRINTF3(_L("TheClient->iScreen->RectCompare() return value - Expected: %d, Actual: %d"), ETrue, retVal); - } - } - - -/** - @SYMTestCaseID GRAPHICS-CODEBASE-WSERV-0052-0001 - @SYMPREQ PGM027 - - @SYMTestCaseDesc Tests CWsBitmap::BitBltMasked and CFbsBitmap::BitBltMasked API's with \n - By passing Null and unexpected values. - - @SYMTestPriority 1 - - @SYMTestStatus Implemented - - @SYMTestActions Call BitBltMasked with different ways - Source Bitpmap as NULL and MaskBitmap - Source Bitmap and MaskBitmap as NULL (For both CFbsBitmap, CWsBitmap) - - @SYMTestExpectedResults Should not panic even if the passed bitmaps are NULL. - - */ -void CTRedrawStoring::DoBitBltAndMaskedNegTestsL() - { - CWsBitmap* testBitmap=NULL; - CWsBitmap* maskBitmap=NULL; - // Passing null Masked bitmap - (TheClient->iGc)->BitBltMasked(TPoint(20,20), testBitmap, TRect(TPoint(0, 0), TSize(20,20)), maskBitmap, EFalse); - testBitmap=new(ELeave) CWsBitmap(TheClient->iWs); - CleanupStack::PushL(testBitmap); - User::LeaveIfError(testBitmap->Load(TEST_BITMAP_NAME,3)); - (TheClient->iGc)->BitBltMasked(TPoint(20,20), testBitmap, TRect(TPoint(0, 0), TSize(20,20)), maskBitmap, EFalse); - CleanupStack::PopAndDestroy(testBitmap); - testBitmap=NULL; - maskBitmap=new(ELeave) CWsBitmap(TheClient->iWs); - CleanupStack::PushL(maskBitmap); - User::LeaveIfError(maskBitmap->Load(TEST_BITMAP_NAME,4)); - // Passing null source bitmap - (TheClient->iGc)->BitBltMasked(TPoint(20,20), testBitmap, TRect(TPoint(0, 0), TSize(20,20)), maskBitmap, EFalse); - CleanupStack::PopAndDestroy(maskBitmap); - CFbsBitmap* samBitmap=NULL; - CFbsBitmap* mskBitmap=NULL; - // Passing null Masked bitmap - (TheClient->iGc)->BitBltMasked(TPoint(20,20), samBitmap, TRect(TPoint(0, 0), TSize(20,20)), mskBitmap, EFalse); - samBitmap=new(ELeave) CWsBitmap(TheClient->iWs); - CleanupStack::PushL(samBitmap); - User::LeaveIfError(samBitmap->Load(TEST_BITMAP_NAME,3)); - (TheClient->iGc)->BitBltMasked(TPoint(20,20), samBitmap, TRect(TPoint(0, 0), TSize(20,20)), mskBitmap, EFalse); - CleanupStack::PopAndDestroy(samBitmap); - samBitmap=NULL; - mskBitmap=new(ELeave) CWsBitmap(TheClient->iWs); - CleanupStack::PushL(mskBitmap); - User::LeaveIfError(mskBitmap->Load(TEST_BITMAP_NAME,4)); - // Passing null source bitmap - (TheClient->iGc)->BitBltMasked(TPoint(20,20), testBitmap, TRect(TPoint(0, 0), TSize(20,20)), mskBitmap, EFalse); - CleanupStack::PopAndDestroy(mskBitmap); - CWsBitmap* cwBitmap=NULL; - TPoint pos(0,0); - // Passing null CWsBitmap - TheClient->iGc->BitBlt(pos,cwBitmap); - TheClient->iGc->BitBlt(pos,cwBitmap,TRect(0,0,10,10)); - // Passing null CFbsBitmap - CFbsBitmap* fbsBitmap=NULL; - TheClient->iGc->BitBlt(pos,fbsBitmap); - TheClient->iGc->BitBlt(pos,fbsBitmap,TRect(0,0,10,10)); - } - -/* TESTCASE: INC095798 - * TITLE: Partial Draw Now Test - * IMPORTANCE: 1 - * - * ACTION: Changes the color of a rectangle inside a window to simulate CCoeControl::DrawNow() - * for an embedded control that does not own a window. - * - * RESULT: The rectangle should change color immediately, without waiting for a redraw event - * from the Window Server, and this should work with or without partial redraw storing and - * with or without transparency. - */ -void CTRedrawStoring::DoPartialDrawNowTestL( TBool aUseTransparency ) - { - /* - * Obtain the color of a particular reference pixel which will be used for - * comparison later on when the test window is added covering it. - */ - const TPoint referencePixel(iWinPos+TPoint(50,50)); - TRgb backgroundReferenceColor; - TheClient->Flush(); - TheClient->WaitForRedrawsToFinish(); - TheClient->iWs.Finish(); - TheClient->iScreen->GetPixel(backgroundReferenceColor, referencePixel); - /* - * Add a test window which emulates a CONE control with a lodger. - * The window is transparent according to parameter aUseTransparency - */ - CPartialDrawNowWin* testWin=new(ELeave) CPartialDrawNowWin; - CleanupStack::PushL(testWin); - testWin->ConstructL(*TheClient->iGroup); - testWin->AssignGC(*TheClient->iGc); - testWin->SetExt(iWinPos+TPoint(25,25),TSize(300,200)); - testWin->Win()->SetRequiredDisplayMode(iTestDisplayMode); - testWin->Win()->SetShadowDisabled(ETrue); - if (aUseTransparency) - TEST(testWin->MakeTransparent() == KErrNone); - testWin->Win()->Activate(); - testWin->Redraw(); - testWin->SetLodger(TRect(20,20,30,30)); - TheClient->Flush(); - TheClient->WaitForRedrawsToFinish(); - TheClient->iWs.Finish(); - TRgb actualColor; - TheClient->iScreen->GetPixel(actualColor,iWinPos+TPoint(50,50)); - if (aUseTransparency) - { - CColorBlender* blender = CColorBlender::NewLC(iTestDisplayMode); - blender->SetInitialColor(backgroundReferenceColor); - blender->Blend(TRgb(0, 0, 255, 127)); //the blue background of the window - blender->Blend(TRgb(0, 255, 0, 127)); //the green color of the lodger - const TRgb expectedColor = blender->Color(); - TEST_COLOR_MATCH(expectedColor, actualColor); - CleanupStack::PopAndDestroy(blender); - } - else - { - TEST_COLOR_MATCH(KRgbGreen, actualColor); - } - CleanupStack::PopAndDestroy(testWin); - } - -/*CPartialDrawNowWin*/ -CPartialDrawNowWin::CPartialDrawNowWin() - : iLodger( 0, 0, 0, 0 ) - {} - -TInt CPartialDrawNowWin::MakeTransparent() - { - const TInt err = iWin.SetTransparencyAlphaChannel(); - if(!err) - { - iWin.SetBackgroundColor(TRgb(0, 0, 0, 0)); - iTransparent = ETrue; - } - return err; - } - -void CPartialDrawNowWin::SetLodger( const TRect &aLodger ) - { - iLodger = aLodger; - iWin.Invalidate( aLodger ); - Redraw( aLodger ); - } - -void CPartialDrawNowWin::Redraw() - { - iWin.BeginRedraw(); - DrawWindowAndLodger(); - iWin.EndRedraw(); - } - -void CPartialDrawNowWin::Redraw( const TRect &aRect ) - { - iWin.BeginRedraw( aRect ); - DrawWindowAndLodger(); - iWin.EndRedraw(); - } - -void CPartialDrawNowWin::DrawWindowAndLodger() - { - iGc->Activate( iWin ); - iGc->SetPenStyle( CGraphicsContext::ENullPen ); - iGc->SetBrushStyle( CGraphicsContext::ESolidBrush ); - iGc->SetBrushColor( iTransparent ? TRgb(0, 0, 255, 127) : KRgbBlue ); - iGc->Clear(); - if (!iLodger.IsEmpty()) - { - iGc->SetBrushColor( iTransparent ? TRgb(0, 255, 0, 127) : KRgbGreen ); - iGc->DrawRect( iLodger ); - } - iGc->Deactivate(); - } - - - -/* TESTCASE: PDEF101789 - TITLE: Expose Window Test for PDEF101789: WServ does not perform well in 9.2 release. - - ACTION: Draws a base window followed by a top window that completly covers the base window. - The base window has an area invalidated and the top window is then moved out of the - way to expose the bottom window. The invalid are is then drawn to within a begin/end redraw - - RESULT: The invalid area on the base window should be redrawn correctly betweeen the begin/end - redraw pair after the base window has been exposed. The invalid area is drawn in a different - colour to the base window. - */ -void CTRedrawStoring::DoExposeTestL(TInt aIteration) - { - _LIT(KErrorMessage,"Expected colour value does not match actual value : Windows not drawn correctly"); - - TPartialRedrawType type = iTest->RedrawStoreTypeL(); - if(type==EPartialRedraw_FullRedrawSupport) - { - //draw a green coloured base window - CPartialRedrawBottomWin* bottomWin = new (ELeave) CPartialRedrawBottomWin(); - CleanupStack::PushL(bottomWin); - bottomWin->ConstructL(*TheClient->iGroup); - bottomWin->Init(); - bottomWin->AssignGC(*TheClient->iGc); - bottomWin->BaseWin()->SetShadowDisabled(ETrue); - bottomWin->BaseWin()->SetShadowHeight(0); - bottomWin->SetExt(iWinPos+TPoint(10,10), iTest->StdTestWindowSize()); - bottomWin->Win()->Activate(); - bottomWin->DrawPartial(TRect(TPoint(0,0), iTest->StdTestWindowSize())); - TheClient->Flush(); - - //draw a red coloured top window that completely covers the base window - CPartialRedrawTopWin* topWin = new (ELeave) CPartialRedrawTopWin(); - CleanupStack::PushL(topWin); - topWin->ConstructL(*TheClient->iGroup); - topWin->Init(); - topWin->AssignGC(*TheClient->iGc); - topWin->BaseWin()->SetShadowDisabled(ETrue); - topWin->BaseWin()->SetShadowHeight(0); - topWin->SetExt(iWinPos+TPoint(10,10),iTest->StdTestWindowSize()); - topWin->Win()->Activate(); - topWin->DrawPartial(TRect(TPoint(0,0), iTest->StdTestWindowSize())); - TheClient->Flush(); - - //Invalidate the an area on the bottom window. - TRect rect(TPoint(10,10), TSize(iTest->StdTestWindowSize().iWidth/4, iTest->StdTestWindowSize().iHeight/4)); - bottomWin->Win()->Invalidate(rect); - - //Now expose the bottom window by moving the top window out of the way - //using one of the methods below - switch(aIteration) - { - case 0: - topWin->Win()->SetOrdinalPosition(-10); - break; - case 1: - topWin->SetPos(iWinPos + TPoint(150,150)); - break; - case 2: - topWin->SetVisible(EFalse); - break; - } - - //now do a begin/end redraw to draw a blue rect to the invalid area on the bottom window - bottomWin->Win()->BeginRedraw(rect); - bottomWin->Gc()->Activate(*bottomWin->Win()); - bottomWin->Gc()->SetBrushStyle(CGraphicsContext::ESolidBrush); - bottomWin->Gc()->SetBrushColor(TRgb(0,0,255,255)); - bottomWin->Gc()->SetPenStyle(CGraphicsContext::ESolidPen); - bottomWin->Gc()->SetPenColor(0); - bottomWin->Gc()->DrawRect(rect); - bottomWin->Gc()->Deactivate(); - bottomWin->Win()->EndRedraw(); - TheClient->Flush(); - - //get the color of a pixel within the invalid area that should be coloured - //blue if the window is redrawn correctly. In the defect this blue area is NOT drawn - TPoint point =iWinPos + TPoint(30,30); - TRgb colour; - TheClient->iScreen->GetPixel(colour,point); - TRgb expectedColour=TRgb(0,0,255,255); - TEST(colour == expectedColour); - if (colour!=expectedColour) - INFO_PRINTF1(KErrorMessage); - - CleanupStack::PopAndDestroy(2, bottomWin); - } - } -/*CPartialRedrawTopWin*/ -void CPartialRedrawTopWin::Init() - { - Win()->SetRequiredDisplayMode(EColor16MA); - Win()->SetTransparencyAlphaChannel(); - Win()->SetBackgroundColor(TRgb(255,255,255,255)); - } - -void CPartialRedrawTopWin::Draw() - { - DoDraw(); - } - -void CPartialRedrawTopWin::DoDraw() - { - DrawFullWindowRect(); - } - -void CPartialRedrawTopWin::DrawFullWindowRect() - { - TRect rect = TRect(TPoint(0,0),iSize); - iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - iGc->SetBrushColor(TRgb(255,0,0,255)); - iGc->DrawRect(rect); - } - -void CPartialRedrawTopWin::DrawPartial(TRect aRect) - { - Invalidate(aRect); - Win()->BeginRedraw(aRect); - iGc->Activate(*Win()); - DrawFullWindowRect(); - iGc->Deactivate(); - Win()->EndRedraw(); - } - -/*CPartialRedrawBottomWin*/ -void CPartialRedrawBottomWin::Init() - { - Win()->SetRequiredDisplayMode(EColor16MA); - Win()->SetTransparencyAlphaChannel(); - Win()->SetBackgroundColor(TRgb(255,255,255,255)); - } - -void CPartialRedrawBottomWin::Draw() - { - DoDraw(); - } - -void CPartialRedrawBottomWin::DoDraw() - { - DrawFullWindowRect(); - } - -void CPartialRedrawBottomWin::DrawFullWindowRect() - { - TRect rect = TRect(TPoint(0,0),iSize); - iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - iGc->SetBrushColor(TRgb(0,255,0,255)); - iGc->DrawRect(rect); - } - -void CPartialRedrawBottomWin::DrawPartial(TRect aRect) - { - Invalidate(aRect); - Win()->BeginRedraw(aRect); - iGc->Activate(*Win()); - DrawFullWindowRect(); - iGc->Deactivate(); - Win()->EndRedraw(); - } - -//CPartialRedrawTiledWin - -void CPartialRedrawTiledWin::Init(TRgb aColour,TBool aTransparent) - { - iColour=aColour; - Win()->SetRequiredDisplayMode(EColor16MA); - if(aTransparent) - { - Win()->SetTransparencyAlphaChannel(); - } - Win()->SetBackgroundColor(iColour); - } - -void CPartialRedrawTiledWin::Draw() - { - DoDraw(); - } - -void CPartialRedrawTiledWin::DoDraw() - { - DrawFullWindowRect(); - } - -void CPartialRedrawTiledWin::DrawFullWindowRect() - { - TRect rect = TRect(TPoint(0,0),iSize); - iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - iGc->SetBrushColor(iColour); - iGc->DrawRect(rect); - } - -void CPartialRedrawTiledWin::DrawPartial(TRect aRect) - { - Invalidate(aRect); - Win()->BeginRedraw(aRect); - iGc->Activate(*Win()); - DrawFullWindowRect(); - iGc->Deactivate(); - Win()->EndRedraw(); - } - -/* TESTCASE: DEF101889 - TITLE: Expose Window Test for DEF101889 Windows tiled by opaque children do not redraw correctly - under certain use cases - - ACTION: Draws a base window then a further window over it that is tiled by opaque children. - This window is then, either completely or partially, covered by a transparent window. - The tiled window is then set invisible. Drawing is then performed to the base window. - - RESULT: The windows should be correctly drawn. More specifically the transparent top window should draw - the correct window underneath it. i.e. after the setinvisible command the base window should be - drawn - */ -void CTRedrawStoring::DoExposeTest2L(TInt aIteration) - { - //This test reproduces problems found during the fixing of DEF096874: WServ does not perform well in 9.2 release. - //The issues (described later) only exhbit themselves when there are no shadows present in the system. - //Unfortunatly there is no direct way of disabling shadows from the test code so under normal running the - //following tests will never hit the defect and always pass. - //To disable shadows the WSERV source code has to be manually altered by editing the CWsClientWindow::CommandL - //method in clwin.cpp. In the EWsWinOpSetShadowHeight case alter the SetHeightDiff(*pData.Int); function call - //to read SetHeightDiff(0); - //The use cases are related to DEF096874 in that the problem occurs when we have 2 windows overlaying each other - //where the top window is completely tiled by child windows. DEF096874 occurs when the window that is tiled is made - //invisible, with the result that the windows are not redrawn correctly. - //The use cases reproduced by this test are when the two windows are either fully or partially obscured by a - //further transparent window laid over the both of them. When the tiled window is made invisible then - //the windows are not updated properly resulting in either transparency problems or the windows not being drawn - //correctly. - //There are further use cases not addressed here i.e. tiled windows becoming visible underneath a transparent window - //that relate to the same fundamental problem but are correctlly addressed by the defect fix. - - TPartialRedrawType type=iTest->RedrawStoreTypeL(); - if(type!=EPartialRedraw_FullRedrawSupport) - return; - - _LIT(KErrorMessage,"Pixel expected to have colour 0x%x has color 0x%x"); - const TSize winSize=iTest->StdTestWindowSize(); - const TInt offset=winSize.iWidth/2; - - //draw a green coloured base window - CPartialRedrawBottomWin* underWin = new(ELeave) CPartialRedrawBottomWin(); - CleanupStack::PushL(underWin); - underWin->ConstructL(*TheClient->iGroup); - underWin->Init(); - underWin->AssignGC(*TheClient->iGc); - underWin->BaseWin()->SetShadowDisabled(ETrue); - underWin->SetExt(iWinPos+TPoint(10,10),winSize); - underWin->Win()->Activate(); - underWin->DrawPartial(TRect(winSize)); - if (TDisplayModeUtils::NumDisplayModeColors(underWin->BaseWin()->DisplayMode())<=4096) - { - CleanupStack::PopAndDestroy(underWin); - _LIT(KLog,"Cannot run test without more than 4K colors"); - LOG_MESSAGE(KLog); - return; - } - - //draw a red coloured top window that completly covers the base window - CPartialRedrawTopWin* overWin = new (ELeave) CPartialRedrawTopWin(); - CleanupStack::PushL(overWin); - overWin->ConstructL(*TheClient->iGroup); - overWin->Init(); - overWin->AssignGC(*TheClient->iGc); - overWin->BaseWin()->SetShadowDisabled(ETrue); - overWin->SetExt(iWinPos+TPoint(10,10),winSize); - overWin->Win()->Activate(); - overWin->DrawPartial(TRect(winSize)); - - //create the two tiles to attach to the top window - CPartialRedrawTiledWin* tile = new (ELeave) CPartialRedrawTiledWin(); - CleanupStack::PushL(tile); - tile->ConstructL(*overWin); - tile->Init(TRgb(255,255,0,255),EFalse); - tile->AssignGC(*TheClient->iGc); - tile->BaseWin()->SetShadowDisabled(ETrue); - tile->SetSize(winSize); - tile->Win()->Activate(); - tile->DrawPartial(TRect(winSize)); - - //create a transparent window overlaying the whole arrangement - CPartialRedrawTiledWin* transparentWin = new (ELeave) CPartialRedrawTiledWin(); - CleanupStack::PushL(transparentWin); - transparentWin->ConstructL(*TheClient->iGroup); - transparentWin->Init(TRgb(255,255,255,0),ETrue); - transparentWin->AssignGC(*TheClient->iGc); - transparentWin->BaseWin()->SetShadowDisabled(ETrue); - //for the first iteration have the transparent window fully covering the other windows - //for the second iteration have the tansparent window partially covering the other windows. - transparentWin->SetExt(iWinPos+TPoint(10+(aIteration==0?0:offset),10),winSize); - transparentWin->Win()->Activate(); - transparentWin->DrawPartial(TRect(winSize)); - - //Now expose the bottom window (underWin) by setting the top window (overWin) invisible - //the opaque child window (tile) should also go invisible - overWin->SetVisible(EFalse); - TheClient->Flush(); - TheClient->WaitForRedrawsToFinish(); - //get the color of a pixel within the window. If everything has been drawn correctly the - //pixel should be green ( the colour of the base window, underWin) - TPoint point =iWinPos + TPoint(30,30); - TRgb colour; - TheClient->iScreen->GetPixel(colour,point); - TRgb expectedColour=TRgb(0,255,0,255); - TEST(colour == expectedColour); - if (colour!=expectedColour) - LOG_MESSAGE3(KErrorMessage,expectedColour.Value(),colour.Value()); - //for partially covered windows the above code tests the uncovered region so an additional test - //is needed on a pixel in the covered region. - if (aIteration!=0) - { - point+=TPoint(offset,0); - TheClient->iScreen->GetPixel(colour,point); - TEST(colour==expectedColour); - if (colour!=expectedColour) - LOG_MESSAGE3(KErrorMessage,expectedColour.Value(),colour.Value()); - } - CleanupStack::PopAndDestroy(4, underWin); //tile,topWin,transparentWin - } - -/* Test automatically purging the redraw store */ - -CResetRedrawStoreWin* CTRedrawStoring::CreatePartialRedrawWinLC(const TPoint &aPos, const TSize &aSize, CTWin *aParent) - { - CResetRedrawStoreWin* testWin = new (ELeave) CResetRedrawStoreWin(); - CleanupStack::PushL(testWin); - if (aParent) - testWin->ConstructL(*aParent); - else - testWin->ConstructL(*TheClient->iGroup); - testWin->Init(); - testWin->AssignGC(*TheClient->iGc); - testWin->BaseWin()->SetShadowDisabled(ETrue); - testWin->BaseWin()->SetShadowHeight(0); - testWin->Win()->SetVisible(EFalse); - testWin->Win()->Activate(); - testWin->SetExt(aPos,aSize); - testWin->SetVisible(ETrue); - return(testWin); - } - -CNoDrawWin* CTRedrawStoring::CreateNoDrawWinLC(const TPoint &aPos, const TSize &aSize) - { - CNoDrawWin* noDrawWin=new (ELeave) CNoDrawWin(); - CleanupStack::PushL(noDrawWin); - noDrawWin->ConstructExtLD(*TheClient->iGroup, aPos, aSize); - noDrawWin->AssignGC(*TheClient->iGc); - noDrawWin->Win()->SetRequiredDisplayMode(iTestDisplayMode); - noDrawWin->Win()->SetTransparencyAlphaChannel(); - noDrawWin->Win()->SetBackgroundColor(TRgb(127,127,127,127)); - noDrawWin->BaseWin()->SetShadowDisabled(ETrue); - noDrawWin->BaseWin()->SetShadowHeight(0); - noDrawWin->Win()->SetVisible(ETrue); - noDrawWin->Activate(); - noDrawWin->Win()->BeginRedraw(); - noDrawWin->Gc()->Activate(*noDrawWin->Win()); - CPartialRedrawWin::DrawRects(*noDrawWin->Gc(), aSize, - TPoint(0,0), ETrue, EPartialRedraw_Unknown); - noDrawWin->Gc()->Deactivate(); - noDrawWin->Win()->EndRedraw(); - return(noDrawWin); - } - -void CTRedrawStoring::AutoResetRedrawStoreTestsL() - { - //PeterI This tests redraw store resetting by monitoring the wserv heap. - //It currently fails as it performs too many iterations of the test i.e. it doesn't reset as frequently - //as the orignal werv. Needs investigation to determine what the expected number of resets should be for - //the Mk3 wserv. - /* - if (iPartialRedrawType==EPartialRedraw_FullRedrawSupport) - { - const TInt startWsHeapCount=TheClient->iWs.HeapCount(); - const TInt KNumFlagsToTest=4; - const TInt KNumFlagStatesToTest=1<iWs.HeapCount(); - TEST((startWsHeapCount+KHeapTotalSafetyMargin)>=endHeapCount); - } - */ - } - -void CTRedrawStoring::DoAutoResetRedrawStoreTestL(TBool aTwoWins, TBool aAnimateBothWins, TBool aKeepGcActive, TBool aUpdateInRedraw) - { - TRect testRect1(iTestWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),iWinSize); - TRect testRect2(iCheckWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),iWinSize); -// - TSize testWinSize1(iWinSize.iWidth/3,iWinSize.iHeight/3); - TSize testWinSize2(iWinSize.iWidth/2,iWinSize.iHeight/2); - TPoint topLeft=iWinPos+TPoint(100,100); - TInt tooBig=topLeft.iX+testWinSize1.iWidth-testRect1.iBr.iX; - if (tooBig>0) - topLeft.iX-=tooBig; - - CResetRedrawStoreWin* testWin1=CreatePartialRedrawWinLC(topLeft,testWinSize1); - CResetRedrawStoreWin* testWin2=CreatePartialRedrawWinLC(topLeft-TPoint(50,50),testWinSize2); - testWin1->SetUpdateInRedraw(aUpdateInRedraw); - testWin2->SetUpdateInRedraw(aUpdateInRedraw); -// - topLeft+=iCheckWin->Position()-iWinPos; - CResetRedrawStoreWin* tW1=CreatePartialRedrawWinLC(topLeft,testWinSize1); - CResetRedrawStoreWin* tW2=CreatePartialRedrawWinLC(topLeft-TPoint(50,50),testWinSize2); - tW1->SetUpdateInRedraw(aUpdateInRedraw); - tW2->SetUpdateInRedraw(aUpdateInRedraw); -// - TheClient->Flush(); - TheClient->WaitForRedrawsToFinish(); -// - const TInt KNumTestResets1=5; - const TInt KNumTestResets2=15; - const TInt KMaxIterationsPerReset=20; - const TInt numTestResets=aTwoWins?KNumTestResets2:KNumTestResets1; - const TInt maxTotalIterations=numTestResets*KMaxIterationsPerReset; - TInt resets=0; -// - const TInt startWsHeapCount=TheClient->iWs.HeapCount(); - TInt baseWsHeapCount=startWsHeapCount; - TInt prevWsHeapCount=0; - TInt totalIterations=0; - testWin1->SetKeepGcActive(aKeepGcActive); - if (aAnimateBothWins) - testWin2->SetKeepGcActive(aKeepGcActive); - do - { - testWin1->UpdateAnim(1); - testWin1->UpdateAnim(1); - testWin1->UpdateAnim(1); - if (aAnimateBothWins) - testWin2->UpdateAnim(3); - if (aTwoWins) - { - tW1->UpdateAnim(1); - tW1->UpdateAnim(2); - if (aAnimateBothWins) - { - tW2->UpdateAnim(1); - tW2->UpdateAnim(1); - tW2->UpdateAnim(1); - } - } - TBool failed=testWin1->Failed(); - TEST(!failed); - if (failed) - { - _LIT(KLog,"Window had fail flag set"); - LOG_MESSAGE(KLog); - } -// - TheClient->Flush(); - TheClient->WaitForRedrawsToFinish(); - if (aTwoWins && !aUpdateInRedraw) - { - TBool match=TheClient->iScreen->RectCompare(testRect1,testRect2); - TEST(match); - if (!match) - { - _LIT(KLog,"Rectangle Area doesn't match, resets=%d (TwoWins=%d,AnimateBoth=%d,KeepActive=%d,InRedraw=%d)"); - LOG_MESSAGE6(KLog,resets,aTwoWins,aAnimateBothWins,aKeepGcActive,aUpdateInRedraw); - } - } - const TInt wsHeapCount=TheClient->iWs.HeapCount(); - TInt lowGap=wsHeapCount-baseWsHeapCount; - TInt highGap=prevWsHeapCount-wsHeapCount; - if (prevWsHeapCount>0 && ((aAnimateBothWins || aTwoWins)?highGap>0:lowGap=maxTotalIterations) - { - TEST(EFalse); - _LIT(KLog,"Too many iterations, number %d, max expect %d"); - LOG_MESSAGE3(KLog,totalIterations,maxTotalIterations); - break; - } - prevWsHeapCount=wsHeapCount; - } while(resetsiWs.HeapCount(); - const TInt KHeapSafetyMargin=4; // Granularity of buffers can leave odd extra cells, hard to specify an exact amount - TBool heapUsageError=(startWsHeapCount+KHeapSafetyMargin>=endHeapCount); - TEST(heapUsageError); - if (!heapUsageError) - { - _LIT(KLog,"Memory Allocation Error, Before=%d, After=%d (Allowable Margin=%d)"); - LOG_MESSAGE4(KLog,startWsHeapCount,endHeapCount,KHeapSafetyMargin); - } - } - } -// - CleanupStack::PopAndDestroy(4, testWin1); - } - -void CTRedrawStoring::RedrawStoreWithSetExtentL() -/* Test how the redraw store deals with windows changing their extent -*/ - { - TSize testSize(4*iWinSize.iWidth/7, iWinSize.iHeight); - TRect testRect1(iTestWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),testSize); - TRect testRect2(iCheckWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),testSize); - TSize testWinSize1a; - TSize testWinSize2; - TPoint winOffset1; - TPoint winOffset2; - GetTestWinSizeAndPos(1,winOffset1,testWinSize1a); - GetTestWinSizeAndPos(0,winOffset2,testWinSize2); - TPoint winPos1(iWinPos + winOffset1); - enum TSetExtentTestMode {ESetExtentTestModeExpandXY,ESetExtentTestModeExpandY,ESetExtentTestModeShrinkXY,ESetExtentTestModeShrinkY,ESetExtentTestModeShrinkXExpandY,ESetExtentTestModeCount}; - for(TInt extMode=ESetExtentTestModeExpandXY;extModePosition() + winOffset1, testWinSize1a); - CResetRedrawStoreWin* tW2=CreatePartialRedrawWinLC(iCheckWin->Position() + winOffset2, testWinSize2); - TheClient->Flush(); - TheClient->WaitForRedrawsToFinish(); -// - if (invalidateMode==ESetExtentInvalidateTestModeBeforeWithRedraw) - { - testWin1->PreSetSize(testWinSize1a); - testWin1->DrawNow(); - } - if (invalidateMode==ESetExtentInvalidateTestModeBefore) - testWin1->Invalidate(); - testWin1->SetExt(winPos1,testWinSize1a); - if (invalidateMode==ESetExtentInvalidateTestModeAfter) - testWin1->Invalidate(); - TheClient->Flush(); - TBool redrawWaiting=TheClient->WaitUntilRedrawPending(); - TheClient->WaitForRedrawsToFinish(); - TInt testRet=TheClient->iScreen->RectCompare(testRect1,testRect2); - if (!testRet) - { - TEST(EFalse); - _LIT(KRedrawStoreSetExtentFail,"Fade Regions fail: extMode=%d, invalidateMode=%d"); - LOG_MESSAGE3(KRedrawStoreSetExtentFail,extMode,invalidateMode); - } -// - CleanupStack::PopAndDestroy(4, testWin1); - } - } - } - -void CTRedrawStoring::PartialRedrawWithEmptyRedrawStoreL() - { - for(TInt numWins=1;numWins<4;numWins++) - { - const TInt KNumTestFlags=3; - for(TUint flags=0;flags<(1<Position() + winOffset1, testWinSize1); - CResetRedrawStoreWin* testWin2=NULL; - CResetRedrawStoreWin* testWin3=NULL; - if (aChildWindows) - { - TPoint winOffset2(TPoint(testWinSize1.iWidth/4,testWinSize1.iHeight/3)); - testWin2=CreatePartialRedrawWinLC(winOffset2, testWinSize2, aChildWindows?testWin1:NULL); - CreatePartialRedrawWinLC(winOffset2, testWinSize2, aChildWindows?tW1:NULL); - if (aNumWins>2) - { - TPoint winOffset3(TPoint(testWinSize1.iWidth/2,testWinSize1.iHeight*2/3)); - testWin3=CreatePartialRedrawWinLC(winOffset3, testWinSize3, aChildWindows?testWin1:NULL); - CreatePartialRedrawWinLC(winOffset3, testWinSize3, aChildWindows?tW1:NULL); - } - } - else - { - if (aNumWins>1) - { - TPoint winOffset2(TPoint(50,50)); - testWin2=CreatePartialRedrawWinLC(iWinPos + winOffset2, testWinSize2, aChildWindows?testWin1:NULL); - CreatePartialRedrawWinLC(iCheckWin->Position() + winOffset2, testWinSize2, aChildWindows?tW1:NULL); - if (aNumWins>2) - { - TPoint winOffset3(TPoint(iWinSize.iWidth/6,iWinSize.iHeight/3)); - testWin3=CreatePartialRedrawWinLC(iWinPos + winOffset3, testWinSize3, aChildWindows?testWin1:NULL); - CreatePartialRedrawWinLC(iCheckWin->Position() + winOffset3, testWinSize3, aChildWindows?tW1:NULL); - } - } - } - TheClient->Flush(); - TheClient->WaitForRedrawsToFinish(); - iDrawMode=EClientRedrawsNormal; -// - TSize testSize(4*iWinSize.iWidth/7, iWinSize.iHeight); - TRect testRect1(iTestWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),testSize); - TRect testRect2(iCheckWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),testSize); - TRect partialRedrawRect1(0,testWinSize1.iHeight/4,testWinSize1.iWidth,testWinSize1.iHeight*3/4); - TRect partialRedrawRect2(0,testWinSize2.iHeight/4,testWinSize1.iWidth,testWinSize2.iHeight*3/4); - TRect partialRedrawRect3(testWinSize3.iWidth/4,0,testWinSize3.iWidth*3/4,testWinSize3.iHeight); - iBlankWin.SetExtent(iWinPos+winOffset1+partialRedrawRect1.iTl, partialRedrawRect1.Size()); - const TInt KDoWindow1=0x01; - const TInt KDoWindow2=0x02; - const TInt KDoWindow3=0x04; - TInt numWinModes=1<iWs.ClearAllRedrawStores(); - if (invalidateWindowFlags&KDoWindow1) - testWin1->Invalidate(partialRedrawRect1); - if (invalidateWindowFlags&KDoWindow2) - testWin2->Invalidate(partialRedrawRect2); - if (invalidateWindowFlags&KDoWindow3) - testWin3->Invalidate(partialRedrawRect3); - if (aRedrawWindow) - { - if (invalidateWindowFlags&KDoWindow1) - testWin1->Redraw(partialRedrawRect1); - if (invalidateWindowFlags&KDoWindow2) - testWin1->Redraw(partialRedrawRect2); - if (invalidateWindowFlags&KDoWindow3) - testWin1->Redraw(partialRedrawRect3); - } - if (aDoWinOnTop) - { - iBlankWin.SetOrdinalPosition(0); - iBlankWin.SetVisible(ETrue); - iBlankWin.SetVisible(EFalse); - } - TheClient->Flush(); - TheClient->WaitForRedrawsToFinish(); - // - TBool match=TheClient->iScreen->RectCompare(testRect1,testRect2); - TEST(match); - if (!match) - { - _LIT(KLog,"Rectangle area doesn't match, windows=%d, flags=%d,%d,%d"); - LOG_MESSAGE5(KLog,aNumWins,aDoWinOnTop,aRedrawWindow,aChildWindows); - } - } - // Resetting iBlankWin to its original size and position for future use - // by other test cases - iBlankWin.SetExtent(iWinPos,iWinSize); - // window handles which are pushed onto cleanup stack, shall be deleted here - CleanupStack::PopAndDestroy(aNumWins*2,testWin1); - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-103713-0001 - -@SYMDEF PDEF106998 - -@SYMTestCaseDesc Empty Draw Test - -@SYMTestPriority - -@SYMTestStatus Implemented - -@SYMTestActions Draws an empty base window followed by an empty top window. - The top window is drawn in one of two cases: - completely covering the bottom window or - only covering the area that will be drawn to - - A red rectangle is drawn to the bottom window and the top window is made invisible. - -@SYMTestExpectedResults The tested pixel colour should be red. Test will fail if the red rectangle - is not drawn or if an infinite loop is detected. - -*/ -void CTRedrawStoring::DoEmptyDrawTestL(TInt aTestMode) - { - _LIT(KErrorMessage,"Infinite Loop"); - - TPartialRedrawType type = iTest->RedrawStoreTypeL(); - if(type==EPartialRedraw_FullRedrawSupport) - { - TBool testStatus = EFalse; - - //draw an empty, green base window - CPartialRedrawEmptyWin* bottomWin = new (ELeave) CPartialRedrawEmptyWin(); - CleanupStack::PushL(bottomWin); - bottomWin->ConstructL(*TheClient->iGroup); - bottomWin->Init(KRgbGreen); - bottomWin->AssignGC(*TheClient->iGc); - bottomWin->BaseWin()->SetShadowDisabled(ETrue); - bottomWin->BaseWin()->SetShadowHeight(0); - bottomWin->SetExt(iWinPos+TPoint(10,10), iWinSize); - bottomWin->Win()->Activate(); - bottomWin->DrawPartial(TRect(TPoint(0,0), iWinSize)); - TheClient->Flush(); - - //draw an empty, blue top window - CPartialRedrawEmptyWin* topWin = new (ELeave) CPartialRedrawEmptyWin(); - CleanupStack::PushL(topWin); - topWin->ConstructL(*TheClient->iGroup); - topWin->Init(KRgbBlue); - topWin->AssignGC(*TheClient->iGc); - topWin->BaseWin()->SetShadowDisabled(ETrue); - topWin->BaseWin()->SetShadowHeight(0); - - switch(aTestMode) - { - case 0: - // top window is completely covering the base window - topWin->SetExt(iWinPos+TPoint(10,10), iWinSize); - break; - case 1: - // top window only covers the upper left hand corner, - // over where the red rectangle will be drawn - topWin->SetExt(iWinPos+TPoint(-5,-5), iWinSize); - break; - } - - topWin->Win()->Activate(); - topWin->DrawPartial(TRect(TPoint(0,0), iWinSize)); - TheClient->Flush(); - - //Invalidate the an area on the top window. - TRect smallrect(TPoint(10,10), TSize(iWinSize.iWidth/4, iWinSize.iHeight/4)); - topWin->Win()->Invalidate(smallrect); - - //draw a small red rectangle on the bottom window - bottomWin->Win()->BeginRedraw(smallrect); - bottomWin->Gc()->Activate(*bottomWin->Win()); - bottomWin->Gc()->SetBrushStyle(CGraphicsContext::ESolidBrush); - bottomWin->Gc()->SetBrushColor(KRgbRed); - bottomWin->Gc()->SetPenStyle(CGraphicsContext::ESolidPen); - bottomWin->Gc()->SetPenColor(0); - bottomWin->Gc()->DrawRect(smallrect); - bottomWin->Gc()->Deactivate(); - bottomWin->Win()->EndRedraw(); - TheClient->Flush(); - TheClient->WaitForRedrawsToFinish(); - - // hide the top window, so that the bottom window will be redrawn - topWin->SetVisible(EFalse); - TheClient->Flush(); - TheClient->WaitForRedrawsToFinish(); - - // check to see if an 'infinite' loop occured - if ((topWin->ReturnCount() > KEmptyLoopThreshold) || (bottomWin->ReturnCount() > KEmptyLoopThreshold)) - INFO_PRINTF1(KErrorMessage); - - //get the color of a pixel within the invalid area that should be coloured - //red if the window is redrawn correctly. - TPoint point =iWinPos + TPoint(30,30); - TRgb colour; - TheClient->iScreen->GetPixel(colour,point); - TRgb expectedColour = KRgbRed; - - if ((colour == expectedColour) && (topWin->ReturnCount() < KEmptyLoopThreshold) && (bottomWin->ReturnCount() < KEmptyLoopThreshold)) - testStatus = ETrue; - - TEST(testStatus); - - CleanupStack::PopAndDestroy(2, bottomWin); - } - } - -void CTRedrawStoring::DoPolygonRedrawTestSetL() - { - _LIT(KRedrawStoringPolygon0,"Test polygon redraw in opaque window"); - _LIT(KRedrawStoringPolygon1,"Test polygon low priority redraw in opaque window"); - _LIT(KRedrawStoringPolygon2,"Test polygon redraw in transparent window"); - _LIT(KRedrawStoringPolygon3,"Test polygon low priority redraw in transparent window"); - INFO_PRINTF1(KRedrawStoringPolygon0); - DoPolygonRedrawTestL(0,0); // Polygon redraw in opaque window - INFO_PRINTF1(KRedrawStoringPolygon1); - DoPolygonRedrawTestL(0,1); // Polygon low priority redraw in opaque window - INFO_PRINTF1(KRedrawStoringPolygon2); - DoPolygonRedrawTestL(1,0); // Polygon redraw in transparent window - INFO_PRINTF1(KRedrawStoringPolygon3); - DoPolygonRedrawTestL(1,1); // Polygon low priority redraw in transparent window - } - -void CTRedrawStoring::DoPolygonRedrawTestL(TInt aWindowMode, TInt aTestMode) - { - //Used to place windows. - TInt gap = 5; - const TSize scrSize(TheClient->iScreen->SizeInPixels()); - TheClient->iWs.SetBufferSizeL(640); - - CPartialRedrawPolygonWin* polyTestWin = NULL; - if (aTestMode == 0) //If polygon redraw test. - { - //Draw a green test window with a polygon in it. - polyTestWin = new (ELeave) CPartialRedrawPolygonWin(); - CleanupStack::PushL(polyTestWin); - polyTestWin->ConstructL(*TheClient->iGroup); - polyTestWin->Init(aWindowMode, KRgbGreen); //aWindowMode 0=opaque 1=transparent - polyTestWin->AssignGC(*TheClient->iGc); - polyTestWin->BaseWin()->SetShadowDisabled(ETrue); - polyTestWin->BaseWin()->SetShadowHeight(0); - polyTestWin->SetExt(TPoint(scrSize.iWidth-iWinSize.iWidth,0), iWinSize); - polyTestWin->Win()->Activate(); - polyTestWin->DrawPartial(); - TheClient->Flush(); - } - - //Draw a green base window with a polygon in it. - CPartialRedrawPolygonWin* bottomWin = new (ELeave) CPartialRedrawPolygonWin(); - CleanupStack::PushL(bottomWin); - bottomWin->ConstructL(*TheClient->iGroup); - bottomWin->Init(aWindowMode, KRgbGreen); //aWindowMode 0=opaque 1=transparent - bottomWin->AssignGC(*TheClient->iGc); - bottomWin->BaseWin()->SetShadowDisabled(ETrue); - bottomWin->BaseWin()->SetShadowHeight(0); - bottomWin->SetExt(TPoint(scrSize.iWidth-(2*iWinSize.iWidth)-gap,0), iWinSize); - bottomWin->Win()->Activate(); - bottomWin->DrawPartial(); - TheClient->Flush(); - - //Draw an empty, blue transparent top window. - CPartialRedrawEmptyWin* topWin = new (ELeave) CPartialRedrawEmptyWin(); - CleanupStack::PushL(topWin); - topWin->ConstructL(*TheClient->iGroup); - topWin->Init(KRgbBlue); - topWin->AssignGC(*TheClient->iGc); - topWin->BaseWin()->SetShadowDisabled(ETrue); - topWin->BaseWin()->SetShadowHeight(0); - topWin->SetExt(TPoint(scrSize.iWidth-(2*iWinSize.iWidth)-gap,0), iWinSize); - topWin->Win()->Activate(); - topWin->DrawPartial(TRect(TPoint(0,0), iWinSize)); - TheClient->Flush(); - - if (aTestMode == 1) //If polygon low priority redraw test. - { - //Clear all redraw stores. - TheClient->iWs.ClearAllRedrawStores(); - TheClient->Flush(); - TheClient->WaitForRedrawsToFinish(); - } - - //Hide the top window, so the bottom window will be redrawn. - topWin->SetVisible(EFalse); - TheClient->Flush(); - TheClient->WaitForRedrawsToFinish(); - - if (aTestMode==0) //If polygon redraw test. - { - //Compare bottomWin against polyTestWin. - TEST(TheClient->iScreen->RectCompare(TRect(TPoint(scrSize.iWidth-2*iWinSize.iWidth-gap,0),iWinSize),TRect(TPoint(scrSize.iWidth-iWinSize.iWidth,0),iWinSize))); - CleanupStack::PopAndDestroy(3,polyTestWin); - } - else //If polygon low priority redraw test. - { - //Test bottomWin has only called DoDraw once. - TEST(bottomWin->ReturnCount()==1); - if (bottomWin->ReturnCount()!=1) - { - _LIT(KLog,"Number of redraws of bottom window %d, 1 expected (windowMode %d)"); - LOG_MESSAGE3(KLog,bottomWin->ReturnCount(),aWindowMode); - } - CleanupStack::PopAndDestroy(2,bottomWin); - } - } - -void CTRedrawStoring::DoRedrawOOMTestL() - { - _LIT(KFailedTestInfo,"Failure information: redrawCount=%d failRate=%d"); - _LIT(KCompletedTest,"OOM test started succeeding at failRate = %d"); - const TInt KConsecutiveSuccessfulRedraws = 20; - - //draw a white test window - CRedrawRectWin* testWin = new (ELeave) CRedrawRectWin(); - CleanupStack::PushL(testWin); - testWin->ConstructL(*TheClient->iGroup); - testWin->Init(); - testWin->AssignGC(*TheClient->iGc); - testWin->BaseWin()->SetShadowDisabled(ETrue); - testWin->BaseWin()->SetShadowHeight(0); - testWin->SetExt(iWinPos+TPoint(0,0), iWinSize); - testWin->Win()->Activate(); - testWin->DrawNow(); - TheClient->Flush(); - TheClient->WaitForRedrawsToFinish(); - - TPoint pointTest = iWinPos + TPoint(30,30); - TRgb colourTest; - TRgb expectedColour = KRgbGreen; - TInt numberOfSuccessfulRedraws = 0; - TInt failRate = 1; - do - { - expectedColour=((expectedColour==KRgbGreen)?KRgbRed:KRgbGreen); - testWin->ResetWindow(expectedColour); - testWin->SetLogging(failRate<3?this:NULL); - testWin->Win()->Invalidate(); - TheClient->iWs.HeapSetFail(RHeap::EDeterministic,failRate); - TheClient->WaitForRedrawsToFinish(); - TheClient->iWs.HeapSetFail(RHeap::ENone,0); - TheClient->iScreen->GetPixel(colourTest,pointTest); - const TInt redrawCount = testWin->RedrawCount(); - - if (redrawCount>2) //If DoDraw called too often: - { - TBool passed=(failRate<3 && redrawCount<9); //For a failrate of 2 allow upto 8 redraws - TEST(passed); //Fail. - LOG_MESSAGE3(KFailedTestInfo,redrawCount,failRate); - if (!passed) - { - CleanupStack::PopAndDestroy(testWin); - return; - } - } - else if (colourTest==expectedColour && redrawCount==1) //If drawn correctly. - { - #if defined(LOGGING) - _LIT(KLog,"FailRate %d Drawing Corect RedrawCount %d"); - LOG_MESSAGE3(KLog,failRate,redrawCount); - #endif - numberOfSuccessfulRedraws++; - } - else //If not drawn. - { - #if defined(LOGGING) - _LIT(KLog,"FailRate %d Drawing Wrong RedrawCount %d"); - LOG_MESSAGE3(KLog,failRate,redrawCount); - #endif - numberOfSuccessfulRedraws=0; - } - failRate++; - } while (numberOfSuccessfulRedrawsiWs); - CleanupClosePushL(win); - User::LeaveIfError(win.Construct(*TheClient->iGroup->GroupWin(),ENullWsHandle)); - win.SetRequiredDisplayMode(EColor64K); - TPoint winPos(270,70); - win.SetExtent(winPos, TSize(100,100)); - win.SetBackgroundColor( KRgbRed ); - win.Activate(); - - TheGc->Activate(win); - win.BeginRedraw(); - TheGc->SetBrushColor(KRgbGreen); - TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - TheGc->DrawRect(TRect(0,0,100,40)); - win.EndRedraw(); - - win.BeginRedraw(TRect(10,20,20,0)); - TheGc->SetBrushColor(KRgbBlue); - TheGc->DrawRect(TRect(0,0,40,100)); - win.EndRedraw(); - - win.SetVisible(EFalse); - win.SetVisible(ETrue); - TheGc->Deactivate(); - TheClient->Flush(); - - TRgb color; - TheClient->iScreen->GetPixel(color,winPos+TPoint(20,20)); - TBool passed=(color==KRgbGreen); - TEST(passed); - - CleanupStack::Pop(&win); - win.Close(); - } - - -/*CPartialRedrawEmptyWin*/ - -void CPartialRedrawEmptyWin::Init(TRgb aColor) - { - Win()->SetRequiredDisplayMode(EColor16MA); - Win()->SetTransparencyAlphaChannel(); - Win()->SetBackgroundColor(aColor); - iCount = 0; - } - -void CPartialRedrawEmptyWin::Draw() - { - DoDraw(); - iCount++; - } - -void CPartialRedrawEmptyWin::DoDraw() - { - DrawFullWindowRect(); - } - -void CPartialRedrawEmptyWin::DrawFullWindowRect() - { - // Only draw when we've looped too many times - if (ReturnCount() > KEmptyLoopThreshold) - { - TRect rect = TRect(TPoint(0,0),iSize); - iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - iGc->SetBrushColor(KRgbBlack); - iGc->DrawRect(rect); - } - } - -void CPartialRedrawEmptyWin::DrawPartial(TRect aRect) - { - Invalidate(aRect); - Win()->BeginRedraw(aRect); - iGc->Activate(*Win()); - DrawFullWindowRect(); - iGc->Deactivate(); - Win()->EndRedraw(); - } - -inline TInt CPartialRedrawEmptyWin::ReturnCount() - { - return iCount; - } - - -/*CPartialRedrawPolygonWin*/ - -void CPartialRedrawPolygonWin::Init(TInt aWindowMode, TRgb aColor) - { - Win()->SetRequiredDisplayMode(EColor16MA); - if (aWindowMode == 1) - { - Win()->SetTransparencyAlphaChannel(); - } - Win()->SetBackgroundColor(aColor); - iCount = 0; - } - -void CPartialRedrawPolygonWin::Draw() - { - DoDraw(); - iCount++; - } - -void CPartialRedrawPolygonWin::DoDraw() - { - DrawFullWindowPolygonL(); - } - -void CPartialRedrawPolygonWin::DrawFullWindowPolygonL() - { - iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - iGc->SetBrushColor(KRgbBlack); - CArrayFixFlat* longPolygon = new CArrayFixFlat(84); - CleanupStack::PushL(longPolygon); - TInt forLoop = 0, loopValue = 0; - TInt tempX=18, tempY=49; - TPoint polygonPoint(tempX, tempY); - - //Create jagged line for the polygon - for (forLoop=0; forLoop<81; forLoop++) - { - tempX += 2; - if (loopValue==0) - { - tempY +=2; - loopValue = 1; - } - else - { - tempY -=2; - loopValue = 0; - } - polygonPoint.SetXY(tempX, tempY); - longPolygon->AppendL(polygonPoint); - } - polygonPoint.SetXY(tempX,70); - longPolygon->AppendL(polygonPoint); - polygonPoint.SetXY(20,70); - longPolygon->AppendL(polygonPoint); - iGc->DrawPolygon(longPolygon); - CleanupStack::PopAndDestroy(longPolygon); - } - -void CPartialRedrawPolygonWin::DrawPartial() - { - Invalidate(); - Win()->BeginRedraw(); - iGc->Activate(*Win()); - DrawFullWindowPolygonL(); - iGc->Deactivate(); - Win()->EndRedraw(); - } - -inline TInt CPartialRedrawPolygonWin::ReturnCount() - { - return iCount; - } - - -/*CRedrawRectWin*/ - -void CRedrawRectWin::Init() - { - Win()->SetRequiredDisplayMode(EColor16MA); - Win()->SetTransparencyAlphaChannel(); - Win()->SetBackgroundColor(KRgbWhite); - iRedrawCount = 0; - iRectColour = KRgbGreen; - } - -void CRedrawRectWin::Draw() - { - DoDraw(); - iRedrawCount++; - } - -void CRedrawRectWin::DoDraw() - { - DrawFullWindowRect(); - } - -void CRedrawRectWin::DrawFullWindowRect() - { - TRect Rect(TPoint(10,10), TSize(30, 30)); - Gc()->SetBrushStyle(CGraphicsContext::ESolidBrush); - Gc()->SetBrushColor(iRectColour); - Gc()->SetPenStyle(CGraphicsContext::ESolidPen); - Gc()->SetPenColor(0); - Gc()->DrawRect(Rect); - } - -void CRedrawRectWin::DrawNow() - { - Win()->Invalidate(); - Win()->BeginRedraw(); - Gc()->Activate(*Win()); - DrawFullWindowRect(); - Gc()->Deactivate(); - Win()->EndRedraw(); - } - -inline TInt CRedrawRectWin::RedrawCount() - { - return iRedrawCount; - } - -void CRedrawRectWin::ResetWindow(TRgb aColour) - { - iRectColour = aColour; - iRedrawCount = 0; - } - -inline void CRedrawRectWin::SetLogging(CTWsGraphicsBase* aTest) - { - iLog=aTest; - } - -void CRedrawRectWin::Redraw(const TRect& aRect) - { - if (iLog) - { - _LIT(KLog,"Redraw Count %d Rect=(%d,%d,%d,%d)"); - iLog->LOG_MESSAGE6(KLog,RedrawCount(),aRect.iTl.iX,aRect.iTl.iY,aRect.iBr.iX,aRect.iBr.iY); - } - CTWin::Redraw(aRect); - } - - -// - -void CTRedrawStoring::RunTestCaseL(TInt /*aCurTestCase*/) - { - _LIT(KNormalDrawing,"Normal Draw Test"); - _LIT(KFadeWindow1,"Fade Window1"); - _LIT(KFadeWindow2,"Fade Window2"); - _LIT(KRedrawQueue2,"Empty Redraw Queue"); - _LIT(KDisableRedrawStore,"Disable redraw store"); - _LIT(KResizeRedraws,"Redraw on Resize event"); - _LIT(KFontCacheOverflow,"Font Cache Overflow test"); - _LIT(KDrawBitmapMask,"Test DrawBitmapMasked"); - _LIT(KInvisibleRedrawStore,"Test invisible window redraw storing"); - _LIT(KBrushDraw,"Test UseBrushPattern storing"); - _LIT(KInvisibleRedrawStoreTransparent,"Test invisible transparent window redraw storing"); - _LIT(KPartialDrawNow,"Test partial DrawNow"); - _LIT(KPartialDrawNowTransparent,"Test partial transparent DrawNow"); - _LIT(KBeginEndRedraw,"Redraw in between Begin and EndRedraw"); - _LIT(KRedrawStoreAlphaChannelTransparency,"Redraw store for Alpha Channel Transparency"); - _LIT(KDrawBitBltAndMaskedNegTestsL,"Test BitBltMasked by passing Neg,UnExpected Values"); - _LIT(KRedrawStoringExposeWindow,"Redraw Storing Window Exposed"); - _LIT(KRedrawStoringExposeWindow2,"Redraw Storing Window behind Transparent Exposed"); - _LIT(KAutoResetRedrawStore,"Test automatic redraw store reset"); - _LIT(KRedrawStoreWithSetExtent,"Redraw store with set extent"); - _LIT(KPartialRedrawWithEmptyRedrawStore,"Partial redraw with empty redraw store"); - _LIT(KScrollingWin,"Test scrolling when partial redraw is enabled"); - _LIT(KRedrawStoringEmptyDrawWindow0,"Empty window under redraw storing - full case"); - _LIT(KRedrawStoringEmptyDrawWindow1,"Empty window under redraw storing - corner case"); - _LIT(KRedrawOOMTest,"Testing OOM redraw"); - _LIT(KRedrawWithBadRect, "Redraw storing when BeginRedraw with bad rect"); - if (iState==0) - { - // Check to see if Transparency is enabled before running tests - if (TransparencySupportedL()==KErrNotSupported) - { - _LIT(KLog,"Transparency is not enabled"); - LOG_MESSAGE(KLog); - TestComplete(); - return; - } - } - TInt err=KErrNone; - //if (iTest->iState==1) iTest->iState=KLastDrawingCase+2; //Set one less that the test you want to run - iState=++iTest->iState; - ((CTRedrawStoringStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); - switch(iTest->iState) - { - case 6: - ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0086")); - // Special case handled seperately because unfading the - // window requires a redraw - iTest->LogSubTest(KFadeWindow1); - FadeWindowTest(); - break; - case 12: - ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0087")); - iTest->LogSubTest(KFadeWindow2); - FadeWindowTest2L(); - break; - case 14: - ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0090")); - iTest->LogSubTest(KRedrawQueue2); - DoNothingInRedrawTest(); - break; - case 17: - ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0091")); - iTest->LogSubTest(KDisableRedrawStore); - DoDisableRedrawStoreTest(); - break; - case 18: - ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0092")); - iTest->LogSubTest(KResizeRedraws); - DoResizeTest(); - break; - case 22: -/** - @SYMTestCaseID GRAPHICS-WSERV-0508 -*/ - ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0508")); - iTest->LogSubTest(KBeginEndRedraw); - DoBeginEndRedraw(); - break; - case 23: -/** - @SYMTestCaseID GRAPHICS-WSERV-0509 -*/ - ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0509")); - iTest->LogSubTest(KRedrawStoreAlphaChannelTransparency); - DoRedrawStoreAlphaChannelTransTest(); - break; - case 24: -/** - @SYMTestCaseID GRAPHICS-WSERV-0510 -*/ - ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0510")); - iTest->LogSubTest(KScrollingWin); - ScrollWinTest(); - break; - case KLastDrawingCase + 1: -/** - @SYMTestCaseID GRAPHICS-WSERV-0511 -*/ - ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0511")); - iTest->LogSubTest(KDrawBitmapMask); - TRAP(err,DoTestDrawBitmapMaskedL()); - break; - case KLastDrawingCase + 2: - - ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0511")); - iTest->LogSubTest(KDrawBitmapMask); - TRAP(err,DoTestDrawBitmapMaskedL(ETrue)); - break; - case KLastDrawingCase + 3: -/** - @SYMTestCaseID GRAPHICS-WSERV-0512 -*/ - ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0512")); - iTest->LogSubTest(KFontCacheOverflow); - DoFontCacheOverflowTestL(); - break; - case KLastDrawingCase + 4: - ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-00XX-0006")); - iTest->LogSubTest(KInvisibleRedrawStore); - TRAP(err,DoInvisibleRedrawStoreTestL( EFalse )); - break; - case KLastDrawingCase + 5: - ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-00XX-0006")); - iTest->LogSubTest(KInvisibleRedrawStoreTransparent); - TRAP(err,DoInvisibleRedrawStoreTestL( ETrue )); - break; - case KLastDrawingCase + 6: - ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-CODEBASE-WSERV-0052-0001")); - iTest->LogSubTest(KDrawBitBltAndMaskedNegTestsL); - TRAP(err,DoBitBltAndMaskedNegTestsL()); - break; - case KLastDrawingCase + 7: -/** - @SYMTestCaseID GRAPHICS-WSERV-0513 -*/ - ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0513")); - iTest->LogSubTest(KPartialDrawNow); - TRAP(err,DoPartialDrawNowTestL(EFalse)); - break; - case KLastDrawingCase + 8: -/** - @SYMTestCaseID GRAPHICS-WSERV-0514 -*/ - ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0514")); - iTest->LogSubTest(KPartialDrawNowTransparent); - TRAP(err,DoPartialDrawNowTestL(ETrue)); - break; - case KLastDrawingCase + 9: -/** - @SYMTestCaseID GRAPHICS-WSERV-0515 -*/ - ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0515")); - TInt iteration; - for(iteration=0;iteration<3 && err==KErrNone;iteration++) - { - iTest->LogSubTest(KRedrawStoringExposeWindow); - TRAP(err,DoExposeTestL(iteration)); - } - break; - case KLastDrawingCase + 10: - { -/** - @SYMTestCaseID GRAPHICS-WSERV-0516 -*/ - ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0516")); - TInt iteration; - for(iteration=0;iteration<2 && err==KErrNone;iteration++) - { - iTest->LogSubTest(KRedrawStoringExposeWindow2); - TRAP(err,DoExposeTest2L(iteration)); - } - break; - } - case KLastDrawingCase + 11: - ((CTRedrawStoringStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - iTest->LogSubTest(KAutoResetRedrawStore); - AutoResetRedrawStoreTestsL(); - break; - case KLastDrawingCase + 12: -/** - @SYMTestCaseID GRAPHICS-WSERV-0517 -*/ - ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0517")); - iTest->LogSubTest(KRedrawStoreWithSetExtent); - RedrawStoreWithSetExtentL(); - break; - case KLastDrawingCase + 13: -/** - @SYMTestCaseID GRAPHICS-WSERV-0518 -*/ - ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0518")); - iTest->LogSubTest(KPartialRedrawWithEmptyRedrawStore); - PartialRedrawWithEmptyRedrawStoreL(); - break; - case KLastDrawingCase + 14: - ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-103713-0001")); - iTest->LogSubTest(KRedrawStoringEmptyDrawWindow0); - TRAP(err,DoEmptyDrawTestL(0)); // Completely covered case - if (err!=KErrNone) - break; - iTest->LogSubTest(KRedrawStoringEmptyDrawWindow1); - TRAP(err,DoEmptyDrawTestL(1)); // Quarter covered case - break; - -/** -@SYMTestCaseID GRAPHICS-WSERV-0439 - -@SYMDEF DEF107817 - -@SYMTestCaseDesc Drawing polygons with many points panics WServ (redraw store enabled) - -@SYMTestPriority Normal - -@SYMTestStatus Implemented - -@SYMTestActions Draw a polygon in opaque and transparent windows testing redraw and low priority redraw - -@SYMTestExpectedResults Redraw tests display correctly, low priority redraw tests call DoDraw only once -*/ - case KLastDrawingCase + 15: - ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L(" GRAPHICS-WSERV-0439")); - TRAP(err,DoPolygonRedrawTestSetL()); - break; - -/** -@SYMTestCaseID GRAPHICS-WSERV-0442 - -@SYMDEF DEF107984 - -@SYMTestCaseDesc OOM causing infinite redraw loop - -@SYMTestPriority Normal - -@SYMTestStatus Implemented - -@SYMTestActions Redraw rectangles in OOM situations - -@SYMTestExpectedResults There are no extended redraw loops -*/ - case KLastDrawingCase + 16: - ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0442")); - iTest->LogSubTest(KRedrawOOMTest); - TRAP(err,DoRedrawOOMTestL()); - break; - case KLastDrawingCase + 17: -/** - @SYMTestCaseID GRAPHICS-WSERV-0519 -*/ - ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0519")); - iTest->LogSubTest(KRedrawWithBadRect); - TRAP(err,RedrawStoreWithBadRectL()); - break; - case KLastDrawingCase + 18: - ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0498")); - iTest->LogSubTest(KBrushDraw); - TRAP(err,DoBrushDrawTestL()); - break; - case KLastDrawingCase + 19: - ((CTRedrawStoringStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - ((CTRedrawStoringStep*)iStep)->CloseTMSGraphicsStep(); - TestComplete(); - break; - default: - iTest->LogSubTest(KNormalDrawing); - ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0085")); - DoDrawTest(); - if (iDoScrollTest) - ScrollTest(); - } - ((CTRedrawStoringStep*)iStep)->RecordTestResultL(); - if (err!=KErrNone) - { - TEST(EFalse); - _LIT(KLog,"Sub-Test[%d] left with error code %d"); - LOG_MESSAGE3(KLog,iState,err); - } - } - - -__WS_CONSTRUCT_STEP__(RedrawStoring) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TREDRSTR.H --- a/windowing/windowserver/tauto/TREDRSTR.H Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,363 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef __TREDRSTR_H__ -#define __TREDRSTR_H__ - -#include -#include -#include "../../tlib/testbase.h" -#include "AUTO.H" -#include "TGraphicsHarness.h" -#include "TScreenModeScaling.h" - - -class CRedrawStoreWin; -class CNoDrawWin; -class CBitmapMaskedWin; -class CResetRedrawStoreWin; - - -class CTRedrawStoring : public CTWsGraphicsBase - { -public: - CTRedrawStoring(CTestStep* aStep); - ~CTRedrawStoring(); - void ConstructL(); - - void CheckWindowsMatch(); - void CheckWindowsMatchLossy(); - void CheckWindowsNotMatch(); - void HideRevealTest(); - void MultipleHideReveal(TInt aX,TInt aY); - void RedrawWindows(); - void DoDrawingL(CWindowGc* aWinGc); - void DoDrawingL(TInt aDraw,CBitmapContext* aGc,TBool aWinGc); - void ScrollTest(); - void FadeWindowTest(); - void FadeWindowTest2L(); - void DoDrawTest(); - void DoScrollTest(); - void SetScrolling(TPoint aScrollSource, TRect aScrollTarget); - //Pure Virtual Function from CTestBase - void DoNothingInRedrawTest(); - void DoDisableRedrawStoreTest(); - void DoBitBltAndMaskedNegTestsL(); - void DoResizeTest(); - void DoTestDrawBitmapMaskedL(TBool aWsBitmap=EFalse); - void DrawBitmapAndCheckL(const TSize aSize,TDisplayMode aDisplayMode,CFbsBitmap* aSrceBitmap,CFbsBitmap* aMaskBitmap,TBool aInvertMask); - void DoFontCacheOverflowTestL(); - void FontCacheOverflowDrawingTestL(TBool aDiffGc, RWindow& aWindow); - void DoInvisibleRedrawStoreTestL( TBool aUseTransparency ); - void DoBrushDrawTestL(); - void DoPartialDrawNowTestL( TBool aUseTransparency ); - void DoBeginEndRedraw(); - void DoRedrawStoreAlphaChannelTransTest(); - - void DoExposeTestL(TInt aIteration); - void DoExposeTest2L(TInt aIteration); - void DoEmptyDrawTestL(TInt aTestMode); - void DoPolygonRedrawTestSetL(); - void DoPolygonRedrawTestL(TInt aWindowMode, TInt aTestMode); - void DoRedrawOOMTestL(); - void RedrawStoreWithBadRectL(); -protected: - virtual void RunTestCaseL(TInt aCurTestCase); - void DoAutoResetRedrawStoreTestL(TBool aTwoWins, TBool aAnimateBothWins, TBool aKeepGcActive, TBool aUpdateInRedraw); - void AutoResetRedrawStoreTestsL(); - void RedrawStoreWithSetExtentL(); - void PartialRedrawWithEmptyRedrawStoreL(); - void DoPartialRedrawWithEmptyRedrawStoreL(TInt aNumWins, TBool aDoWinOnTop, TBool aRedrawWindow, TBool aChildWindows); - CResetRedrawStoreWin* CreatePartialRedrawWinLC(const TPoint& aPos, const TSize& aSize, CTWin* aParent=NULL); - CNoDrawWin* CreateNoDrawWinLC(const TPoint &aPos, const TSize &aSize); - void GetTestWinSizeAndPos(TInt aWinIndex, TPoint &aPos, TSize &aSize) const; - void ScrollWinTest(); -public: - TInt iDrawOrder; - TBool iQueueTest; - -private: - enum TDrawingMode - { - EServerRedraw, - EClientRedrawsNormal, - EClientRedrawsScrolled, - }; - TPoint ComputeTextPosition(TPoint aPoint); - CTBackedUpWin* iCheckWin; - CFbsBitmap* iCheckBitmap; - CFbsBitmapDevice* iCheckDevice; - CFbsBitGc* iCheckGc; - CRedrawStoreWin* iTestWin; - TSize iWinSize; - TPoint iWinPos; - TDrawingMode iDrawMode; - RBlankWindow iBlankWin; - RRegion iRegion; - RWindow iWinTestGc; - TBool iWindowsFaded; - TRect iScrollTarget; - TPoint iScrollSource; - TBool iDoScrollTest; - CNoDrawWin* iNoDrawWin; - TBool iClientDidDraw; - CWsBitmap* iAlphaBitmap[3]; - TBool iAlphaSupported; - CBitmapMaskedWin* iBitmapMaskedWin; - CBitmap* iTestBitmap; - CBitMapWin* iTestBitmapWin; - TRect iWinRect; - TPoint iTestWinPoint; - TBool iXPlus; - TBool iYPlus; - TInt iState; - TInt iYPoz; - TDisplayMode iTestDisplayMode; - CFbsBitmap *iTestWinCopy; - CFbsBitmap *iCheckWinCopy; - }; - -class CRedrawStoreWin : public CTWin - { -public: - inline CRedrawStoreWin(CTRedrawStoring* aTest) : iDrawOrder(0), iTest(aTest){} - //Virtual Function from CTBaseWin - void Draw(); -public: - TInt iDrawOrder; -private: - CTRedrawStoring *iTest; - }; - -class CNoDrawWin : public CTWin - { -public: - void Draw(); - }; - -class CBrushDrawWin : public CTWin - { -public: - CBrushDrawWin(); - void Draw(); - void Redraw(); - -private: - }; - -class CBitmapMaskedWin : public CTWin - { -public: - static CBitmapMaskedWin* NewL(CFbsBitmap* aFbsBitmap,CFbsBitmap* aFbsMaskBitmap, - CWsBitmap* aWsBitmap,CWsBitmap* aWsMaskBitmap, - TRgb aBackground,TRect aRect,TBool aInvertMask,TBool aWsFbs); - ~CBitmapMaskedWin(); - //Virtual Function from CTBaseWin - void Draw(); - void SetDestRectSize(const TSize aSize); - inline void SetInvertMask(TBool aInvertMask){iInvertMask=aInvertMask;} -private: - inline CBitmapMaskedWin(CFbsBitmap* aFbsBitmap,CFbsBitmap* aFbsMaskBitmap,CWsBitmap* aWsBitmap,CWsBitmap* aWsMaskBitmap, - TRect aRect,TBool aInvertMask,TBool aWsFbs): - iFbsBitmap(aFbsBitmap),iFbsMaskBitmap(aFbsMaskBitmap), - iWsBitmap(aWsBitmap),iWsMaskBitmap(aWsMaskBitmap), - iRect(aRect),iInvertMask(aInvertMask),iWsFbs(aWsFbs) {} -private: - CFbsBitmap* iFbsBitmap; - CFbsBitmap* iFbsMaskBitmap; - CWsBitmap* iWsBitmap; - CWsBitmap* iWsMaskBitmap; - TRect iRect; - TBool iInvertMask; - TBool iWsFbs; - }; - -class CPartialRedrawWin : public CTWin - { -public: - void Init(); - virtual void Draw(); - void DrawToBmp(CGraphicsContext& aGc); - void DrawPartial(TPartialRedrawType aPartialRedrawType); - static void DrawRects(CGraphicsContext& aGc, TSize aSize, TPoint aPosition, - TBool aIsFullRedraw, TPartialRedrawType aPartialRedrawType); - void RedrawSubRectWithBitmapL(TRgb aBitmapColour); -public: - TBool iClientDrawn; - TBool iClientCanDraw; -private: - void DoDraw(CGraphicsContext& aGc); -private: - }; - -class CPartialRedrawBottomWin : public CTWin - { -public: - void Init(); - virtual void Draw(); - void DrawPartial(TRect aRect); - void DrawFullWindowRect(); -private: - void DoDraw(); - }; - -class CPartialRedrawTopWin : public CTWin - { -public: - void Init(); - virtual void Draw(); - void DrawPartial(TRect aRect); - void DrawFullWindowRect(); -private: - void DoDraw(); - }; - -class CPartialRedrawTiledWin : public CTWin - { -public: - void Init(TRgb aColour,TBool aTransparent); - virtual void Draw(); - void DrawPartial(TRect aRect); - void DrawFullWindowRect(); -private: - void DoDraw(); -private: - TRgb iColour; - }; - -class CInvisibleRedrawWin: public CTWin - { -public: - CInvisibleRedrawWin(); - TInt MakeTransparent(); - void MakeVisible( TBool aVisible ); - virtual void Redraw(); - virtual void Redraw( const TRect &aRect ); - -private: - void DrawIfVisible(); - -private: - TBool iVisible; - TBool iTransparent; - }; - -class CPartialDrawNowWin: public CTWin - { -public: - CPartialDrawNowWin(); - TInt MakeTransparent(); - void SetLodger( const TRect &aLodger ); - virtual void Redraw(); - virtual void Redraw( const TRect &aRect ); - -private: - void DrawWindowAndLodger(); - -private: - TRect iLodger; - TBool iTransparent; - }; - -class CPartialRedrawEmptyWin : public CTWin - { -public: - void Init(TRgb aColor); - virtual void Draw(); - void DrawPartial(TRect aRect); - void DrawFullWindowRect(); - inline TInt ReturnCount(); -private: - void DoDraw(); - TInt iCount; - }; - -class CPartialRedrawPolygonWin : public CTWin - { -public: - void Init(TInt aWindowMode, TRgb aColor); - virtual void Draw(); - void DrawPartial(); - void DrawFullWindowPolygonL(); - inline TInt ReturnCount(); -private: - void DoDraw(); - TInt iCount; - }; - -class CRedrawRectWin : public CTWin - { -public: - void Init(); - void DrawNow(); - void DrawFullWindowRect(); - inline TInt RedrawCount(); - void ResetWindow(TRgb aColour); - inline void SetLogging(CTWsGraphicsBase* aTest); - //Virtual function from CTBaseWin - void Draw(); - //Virtual function from CTWin - void Redraw(const TRect& aRect); -private: - void DoDraw(); -private: - TInt iRedrawCount; - TRgb iRectColour; - CTWsGraphicsBase* iLog; - }; - -class CTRedrawStoringStep : public CTGraphicsStep - { -public: - CTRedrawStoringStep(); -protected: - //from CTGraphicsStep - virtual CTGraphicsBase* CreateTestL(); - }; - -class CResetRedrawStoreWin : public CPartialRedrawWin - { -public: - ~CResetRedrawStoreWin(); - void SetUpdateInRedraw(TBool aUpdateInRedraw); - void SetKeepGcActive(TBool aState); - void UpdateAnim(TInt aSteps); - void PreSetSize(const TSize &aSize); - TBool Failed() const; -private: - virtual void Draw(); - void DoDraw(CGraphicsContext& aGc) const; - void DoDrawAnim(CGraphicsContext& aGc) const; - TRect AnimRect() const; -private: - TInt iAnimState; - TBool iKeepGcActive; - TBool iUpdateInRedraw; - TBool iFailed; - CWindowGc* iExtraGc; - }; - -const TInt KEmptyLoopThreshold = 3; - -_LIT(KTRedrawStoringStep,"TRedrawStoring"); - - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TRegion.H --- a/windowing/windowserver/tauto/TRegion.H Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,90 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef __TREGION_H__ -#define __TREGION_H__ - -#include -#include -#include "../tlib/testbase.h" -#include "AUTO.H" -#include -#include "TGraphicsHarness.h" - -class CTRegion : public CTWsGraphicsBase - { -public: - CTRegion(CTestStep* aStep); - ~CTRegion(); - void ConstructL(); - -protected: - virtual void RunTestCaseL(TInt aCurTestCase); - -private: - void DrawNonClippedSample1(CTWin *aDrawable, const TPoint &aOrigin); - void DrawNonClippedSample1(CTWin *aDrawable, const TRegion &aRegion, const TPoint &aOrigin); - void DrawClippedSample1(TestWindow *aDrawable, const TRegion &aRegion, const TRect &aClippingRect, const TPoint &aOrigin); - void DrawNonClippedSample2(CTWin *aDrawable, const TPoint &aOrigin); - void DrawNonClippedSample2(CTWin *aDrawable, const TRegion &aRegion, const TPoint &aOrigin); - void DrawClippedSample2(TestWindow *aDrawable, const TRegion &aRegion, const TRect &aClippingRect, const TPoint &aOrigin); - void DrawClippedSample3(CBitmapContext &aGc); - void DrawNonClippedSample1(CBitmapContext &aGc); - void DrawClippedSample1(CBitmapContext &aGc); - void DrawNonClippedSample2(CBitmapContext &aGc, CFont *aFont); - void DrawClippedSample2(CBitmapContext &aGc, CFont *aFont); - void TestRegionL(const TRegion &aClippingRegion, const TRect &aClippingRect, const TPoint &aOrigin); - void ScrollBugL(); - void ExposeTestL(); - void ExposeTest2L(); - void CoverTestL(); - void OffsetTestL(); - void ClipTestL(); - void CreateChildWindowsL(); - void DeleteChildWindows(); - void ClearBitmapAndWindows(); - void CompareRectsL(TPoint aTl1,TPoint aTl2,TSize aSize); - -private: - CFbsFont *iFont; - CFbsFont *iBitFont; - CFbsBitmap iPicture; - CFbsBitmapDevice *iBitmapDevice; - CWsBitmap *iBitmap; - CFbsBitGc *iBitGc; - TSize iDrawableSize; - CBlankWindow *iBaseChildWin; - CBlankWindow *iTestChildWin; - }; - -class CTRegionStep : public CTGraphicsStep - { -public: - CTRegionStep(); -protected: - //from CTGraphicsStep - virtual CTGraphicsBase* CreateTestL(); - }; - -_LIT(KTRegionStep,"TRegion"); - - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TRegion.cpp --- a/windowing/windowserver/tauto/TRegion.cpp Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,854 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Code for testing CWindowGc::SetCurrentRegion -// -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include "TRegion.H" - -TBool RegionCanFade; -TBool RegionCanFadeSet; - -LOCAL_D TBuf<0x10> text=_L("SOME TEXT"); -LOCAL_D TPoint textRefPos(210, 80); - -LOCAL_D TRect regionRectList[]={ - TRect(0,0,0,0), TRect(30,10,70,40),TRect(60,30,80,70),TRect(10,110,70,170), - TRect(190,0,240,60),TRect(62,63,67,115),TRect(0,180,240,200),TRect(40,50,210,130), - TRect(160,130,190,160),TRect(100,140,140,170),TRect(140,170,100,140),TRect(90,120,230,200)}; -LOCAL_D TRect clippingRectList[]={ - TRect(0,0,200,400), TRect(30,10,500,600),TRect(-60,0,80,70),TRect(20,0,170,500), - TRect(0,0,2000,6000),TRect(-1000,-2000,123,195),TRect(10,10,230,190),TRect(0,0,510,730), - TRect(110,30,190,150),TRect(1,1,500,11170),TRect(0,0,800,940),TRect(-10,-20,240,210)}; -LOCAL_D TPoint originList[]={ - TPoint(0,0),TPoint(10,0),TPoint(0,10),TPoint(-5,-20), - TPoint(1,1),TPoint(0,0),TPoint(0,0),TPoint(100,0), - TPoint(0,111),TPoint(90,40),TPoint(0,0),TPoint(-1,0)}; - -CTRegion::CTRegion(CTestStep* aStep) : CTWsGraphicsBase(aStep) - { - } - -void CTRegion::ConstructL() - { - iDrawableSize=TestWin->Size(); -// - User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)iFont,TFontSpec(_L("Arial"),200))); - User::LeaveIfError(iPicture.Load(TEST_BITMAP_NAME,0)); - - iBitmap = new (ELeave) CWsBitmap(TheClient->iWs); - User::LeaveIfError(iBitmap->Create(TSize(iDrawableSize.iWidth+1,iDrawableSize.iHeight),EGray16)); - iBitmap->SetSizeInTwips(TheClient->iScreen); - iBitmapDevice=CFbsBitmapDevice::NewL(iBitmap); - User::LeaveIfError(iBitmapDevice->CreateContext(iBitGc)); - User::LeaveIfError(iBitmapDevice->GetNearestFontToDesignHeightInTwips((CFont *&)iBitFont,TFontSpec(_L("Arial"),200))); - } - -CTRegion::~CTRegion() - { - delete iBitGc; - TheClient->iScreen->ReleaseFont(iFont); - if (iBitmapDevice) - iBitmapDevice->ReleaseFont(iBitFont); - delete iBitmapDevice; - DeleteChildWindows(); - delete iBitmap; - } - -void CTRegion::CreateChildWindowsL() - { - TSize screenSize=TheClient->iGroup->Size(); - TInt winWidth=(screenSize.iWidth/3)-10; - TInt winHeight=screenSize.iHeight-10; - iBaseChildWin=new(ELeave) CBlankWindow(); - iBaseChildWin->SetUpL(BaseWin->Win()->InquireOffset(*TheClient->iGroup->GroupWin())+TPoint(winWidth>>2,winHeight>>2),TSize(winWidth>>2,winHeight>>1),TheClient->iGroup,*TheClient->iGc); - iBaseChildWin->Win()->SetShadowHeight(2); - iTestChildWin=new(ELeave) CBlankWindow(); - iTestChildWin->SetUpL(TestWin->Win()->InquireOffset(*TheClient->iGroup->GroupWin())+TPoint(winWidth>>2,winHeight>>2),TSize(winWidth>>2,winHeight>>1),TheClient->iGroup,*TheClient->iGc); - } - -void CTRegion::DeleteChildWindows() - { - delete iBaseChildWin; - iBaseChildWin=NULL; - delete iTestChildWin; - iTestChildWin=NULL; - } - -void CTRegion::DrawNonClippedSample1(CBitmapContext &aGc) - { - aGc.SetPenColor(TRgb::Gray4(0)); - aGc.SetBrushColor(TRgb::Gray4(2)); - aGc.SetBrushStyle(CGraphicsContext::ESolidBrush); - aGc.DrawRect(TRect(TPoint(30,100), TPoint(120,200))); - TheClient->iWs.Flush(); - } - -void CTRegion::DrawClippedSample1(CBitmapContext &aGc) - { - aGc.SetPenColor(TRgb::Gray4(0)); - aGc.SetBrushColor(TRgb::Gray4(1)); - aGc.SetBrushStyle(CGraphicsContext::ESolidBrush); - aGc.DrawRect(TRect(TSize(100,200))); - -// aGc.BitBlt(TPoint(55,65), iPicture); - - aGc.SetPenStyle(CGraphicsContext::ENullPen); - aGc.SetBrushStyle(CGraphicsContext::ESolidBrush); - aGc.SetBrushColor(TRgb::Gray4(2)); - aGc.DrawEllipse(TRect(TPoint(20,35), TPoint(90,79))); - - aGc.SetBrushColor(TRgb::Gray4(0)); - aGc.DrawEllipse(TRect(TPoint(110,110), TPoint(175,200))); - - aGc.SetBrushColor(TRgb::Gray4(1)); - aGc.DrawEllipse(TRect(TPoint(170,30), TPoint(220,150))); - - aGc.SetBrushColor(TRgb::Gray4(3)); - aGc.DrawEllipse(TRect(TPoint(0,150), TPoint(240,190))); - - aGc.SetPenStyle(CGraphicsContext::ESolidPen); - aGc.SetBrushStyle(CGraphicsContext::ENullBrush); - - TheClient->iWs.Flush(); - } - -void CTRegion::DrawNonClippedSample2(CBitmapContext &aGc, CFont *aFont) - { - aGc.SetPenColor(TRgb::Gray4(0)); - aGc.SetPenColor(TRgb::Gray4(0)); - aGc.UseFont(aFont); - TPoint textPos=textRefPos-TPoint(iFont->TextWidthInPixels(text)*3/4, 0); - aGc.DrawText(text, textPos); - aGc.DiscardFont(); - - TheClient->iWs.Flush(); - } - -void CTRegion::DrawClippedSample2(CBitmapContext &aGc, CFont *aFont) - { - aGc.SetPenColor(TRgb::Gray4(0)); - aGc.SetPenColor(TRgb::Gray4(2)); - aGc.UseFont(aFont); - TPoint textPos=textRefPos-TPoint(iFont->TextWidthInPixels(text)*3/4, -20); - aGc.DrawText(text, textPos); - aGc.DiscardFont(); - aGc.SetBrushColor(TRgb::Gray4(3)); - aGc.SetBrushStyle(CGraphicsContext::ESolidBrush); - aGc.DrawRect(TRect(TPoint(10,100), TPoint(210,120))); - TheClient->iWs.Flush(); - } - -void CTRegion::DrawClippedSample3(CBitmapContext &aGc) - { - aGc.SetPenColor(TRgb::Gray4(0)); - aGc.SetPenColor(TRgb::Gray4(2)); - aGc.DrawRect(TRect(TPoint(10,200), TPoint(20,210))); - } - -void CTRegion::DrawNonClippedSample1(CTWin *aWindow, const TPoint &aOrigin) - { - TheGc->Activate(*aWindow->Win()); - TheGc->SetOrigin(aOrigin); - DrawNonClippedSample1(*TheGc); - TheGc->Deactivate(); - } - -void CTRegion::DrawNonClippedSample1(CTWin *aWindow, const TRegion &aRegion, const TPoint &aOrigin) - { - TheGc->Activate(*aWindow->Win()); - TheGc->SetOrigin(aOrigin); - TheGc->SetClippingRegion(aRegion); - DrawNonClippedSample1(*TheGc); - TheGc->Deactivate(); - } - -void CTRegion::DrawClippedSample1(TestWindow *aWindow, const TRegion &aRegion, const TRect &aClippingRect, const TPoint &aOrigin) - { - TheGc->Activate(*aWindow->Win()); - TheGc->SetOrigin(aOrigin); - TheGc->SetClippingRegion(aRegion); - TheGc->SetClippingRect(aClippingRect); - DrawClippedSample1(*TheGc); - TheGc->Deactivate(); - } - -void CTRegion::DrawNonClippedSample2(CTWin *aWindow, const TPoint &aOrigin) - { - TheGc->Activate(*aWindow->Win()); - TheGc->SetOrigin(aOrigin); - DrawNonClippedSample2(*TheGc,iFont); - TheGc->Deactivate(); - } - -void CTRegion::DrawNonClippedSample2(CTWin *aWindow, const TRegion &aRegion, const TPoint &aOrigin) - { - TheGc->Activate(*aWindow->Win()); - TheGc->SetOrigin(aOrigin); - TheGc->SetClippingRegion(aRegion); - DrawNonClippedSample2(*TheGc,iFont); - TheGc->Deactivate(); - } - -void CTRegion::DrawClippedSample2(TestWindow *aWindow, const TRegion &aRegion, const TRect &aClippingRect, const TPoint &aOrigin) - { - TheGc->Activate(*aWindow->Win()); - TheGc->SetClippingRegion(TRegionFix<1>()); - DrawClippedSample3(*TheGc); // needed to trigger region update in wserv - TheGc->SetOrigin(aOrigin); - TheGc->SetClippingRect(aClippingRect); - TheGc->SetClippingRegion(aRegion); - DrawClippedSample2(*TheGc,iFont); - TheGc->CancelClippingRegion(); - TheGc->Deactivate(); - } - -void CTRegion::ClearBitmapAndWindows() - { - TestWin->Win()->Invalidate(); - TestWin->Win()->BeginRedraw(); - TheGc->Activate(*TestWin->Win()); - TheGc->SetBrushColor(TRgb::Gray4(3)); - TheGc->Clear(); - TheGc->Deactivate(); - TestWin->Win()->EndRedraw(); -// - BaseWin->Win()->Invalidate(); - BaseWin->Win()->BeginRedraw(); - TheGc->Activate(*BaseWin->Win()); - TheGc->SetBrushColor(TRgb::Gray4(3)); - TheGc->Clear(); - TheGc->Deactivate(); - BaseWin->Win()->EndRedraw(); -// - iBitGc->SetBrushColor(TRgb::Gray4(3)); - iBitGc->Clear(); - TheClient->iWs.Flush(); - } - -void CTRegion::TestRegionL(const TRegion &aClippingRegion, const TRect &aClippingRect, const TPoint &aOrigin) - { - if (aClippingRegion.CheckError()) - User::Leave(KErrGeneral); - ClearBitmapAndWindows(); - - // draw to iWindow1 (clipping intermittently) and iBitmap (not clipping) - DrawNonClippedSample1(TestWin,aOrigin); - DrawNonClippedSample1(*iBitGc); - - DrawNonClippedSample2(TestWin,aOrigin); - DrawNonClippedSample2(*iBitGc, iBitFont); - - DrawClippedSample1(TestWin,aClippingRegion,aClippingRect,aOrigin); - DrawClippedSample1(*iBitGc); - - DrawClippedSample2(TestWin,aClippingRegion,aClippingRect,aOrigin); - DrawClippedSample2(*iBitGc, iBitFont); - - // copy each rectangle of the clipping region from iBitmap to iWindow2 - TheGc->Activate(*BaseWin->Win()); - for (TUint i=0; i<(TUint)aClippingRegion.Count(); i++) - { - TRect rect=aClippingRegion.RectangleList()[i]; - rect.Intersection(aClippingRect); - TheGc->SetOrigin(aOrigin); - TheGc->BitBlt(rect.iTl, iBitmap, rect); - TheClient->Flush(); - } - TheGc->Deactivate(); - - // draw the non-clipped samples to everywhere in iWindow2 *except* the clipping region - RRegion inverseClippingRegion(TRect(-aOrigin,iDrawableSize)); - RRegion clip; - clip.Copy(aClippingRegion); - clip.ClipRect(aClippingRect); - inverseClippingRegion.SubRegion(clip); - clip.Close(); - DrawNonClippedSample1(BaseWin,inverseClippingRegion,aOrigin); - DrawNonClippedSample2(BaseWin,inverseClippingRegion,aOrigin); - inverseClippingRegion.Close(); - CompareWindows(_L("CTRegion::TestRegionL")); - } - -void CTRegion::CompareRectsL(TPoint aTl1,TPoint aTl2,TSize aSize) - { - _LIT(KError,"Pixels Differ: (%d,%d),(%d,%d)"); - CFbsScreenDevice* device; - device=CFbsScreenDevice::NewL(KNullDesC,iBaseChildWin->BaseWin()->DisplayMode()); - TPoint br=aTl1+aSize; - TInt startX1=aTl1.iX; - TInt startX2=aTl2.iX; - TSize pixelSize(1,1); - TPoint zero; - while(aTl1.iYRectCompare(TRect(aTl1,pixelSize),*device,TRect(aTl2,pixelSize))) - { - RDebug::Print(KError,aTl1.iX,aTl1.iY,aTl2.iX,aTl2.iY); - iTest->LogColors(*device,zero,aTl1,aTl1); - iTest->LogColors(*device,zero,aTl2,aTl2); - } - ++aTl1.iX; - ++aTl2.iX; - } - aTl1.iX=startX1; - aTl2.iX=startX2; - ++aTl1.iY; - ++aTl2.iY; - } - } - -void CTRegion::ScrollBugL() - { - CBlankWindow* testWin; - RBlankWindow win(TheClient->iWs); - CleanupClosePushL(win); - TSize screenSize=TheClient->iGroup->Size(); - testWin=new(ELeave) CBlankWindow(TRgb::Gray4(0)); - CleanupStack::PushL(testWin); - //testWin->ConstructL(*TheClient->iGroup); - testWin->SetUpL(TPoint(screenSize.iWidth/3,0),TSize(screenSize.iWidth/3,screenSize.iHeight),TheClient->iGroup,*TheGc); - //testWin->Win()->SetBackgroundColor(TRgb::Gray2(1)); - testWin->Win()->EnableRedrawStore(EFalse); - testWin->SetColor(TRgb::Gray4(1)); - testWin->RealDraw(ETrue); - win.Construct(*TheClient->iGroup->WinTreeNode(),3456); - win.SetColor(TRgb::Gray4(2)); - win.SetExtent(TPoint(screenSize.iWidth/3+30,20),TSize(screenSize.iWidth/3-62,25)); - win.Activate(); - TheClient->iWs.Flush(); - TheClient->WaitForRedrawsToFinish(); - win.SetVisible(EFalse); - TheClient->iWs.Flush(); - testWin->Win()->BeginRedraw(); - testWin->DrawNow(); - testWin->SetColor(TRgb::Gray4(2)); - testWin->Win()->Scroll(TPoint(0,-50)); - testWin->DrawNow(); - testWin->Win()->EndRedraw(); - TheClient->iWs.Flush(); - TBool retVal = TheClient->iScreen->RectCompare(TRect(TPoint(screenSize.iWidth/3,0),TSize(screenSize.iWidth/3,screenSize.iHeight/2-30)) - ,TRect(TPoint(screenSize.iWidth/3,screenSize.iHeight/2-30),TSize(screenSize.iWidth/3,screenSize.iHeight/2-30))); - TEST(retVal); - if (!retVal) - INFO_PRINTF3(_L("TheClient->iScreen->RectCompare() return value - Expected: %d, Actual: %d"), ETrue, retVal); - - retVal = !TheClient->iScreen->RectCompare(TRect(TPoint(screenSize.iWidth/3,screenSize.iHeight-60),TSize(10,10)) - ,TRect(TPoint(screenSize.iWidth/3,screenSize.iHeight-50),TSize(10,10))); - TEST(retVal); - if (!retVal) - INFO_PRINTF3(_L("!TheClient->iScreen->RectCompare() return value - Expected: %d, Actual: %d"), ETrue, retVal); - - TheClient->WaitForRedrawsToFinish(); - win.SetVisible(ETrue); - win.SetVisible(EFalse); - testWin->Win()->BeginRedraw(); - testWin->Win()->Scroll(TPoint(0,-50)); - testWin->SetColor(TRgb::Gray4(1)); - testWin->DrawNow(); - testWin->Win()->EndRedraw(); - TheClient->iWs.Flush(); - retVal = TheClient->iScreen->RectCompare(TRect(TPoint(screenSize.iWidth/3+35,0),TSize(screenSize.iWidth/6-35,100)) - ,TRect(TPoint(screenSize.iWidth/2,0),TSize(screenSize.iWidth/6-35,100))); - TEST(retVal); - if (!retVal) - INFO_PRINTF3(_L("TheClient->iScreen->RectCompare() return value - Expected: %d, Actual: %d"), ETrue, retVal); - - retVal = !TheClient->iScreen->RectCompare(TRect(TPoint(screenSize.iWidth/3+30,20),TSize(10,10)) - ,TRect(TPoint(screenSize.iWidth/3+30,50),TSize(10,10))); - TEST(retVal); - if (!retVal) - INFO_PRINTF3(_L("!TheClient->iScreen->RectCompare() return value - Expected: %d, Actual: %d"), ETrue, retVal); - - TheClient->WaitForRedrawsToFinish(); - testWin->Win()->BeginRedraw(); - testWin->DrawNow(); - testWin->Win()->EndRedraw(); - CleanupStack::PopAndDestroy(2,&win); - } - -void CTRegion::ExposeTestL() - { - CBlankWindow* testWin; - TSize screenSize=TheClient->iGroup->Size(); - TRect topHalf(0,0,screenSize.iWidth/3,screenSize.iHeight/2); - TRect leftHalf(0,0,screenSize.iWidth/6,screenSize.iHeight); - testWin=new(ELeave) CBlankWindow(TRgb::Gray4(0)); - CleanupStack::PushL(testWin); - testWin->SetUpL(TPoint(screenSize.iWidth/3,0),TSize(screenSize.iWidth/3,screenSize.iHeight),TheClient->iGroup,*TheGc); - testWin->Win()->EnableRedrawStore(EFalse); - testWin->SetColor(TRgb::Gray4(2)); - testWin->RealDraw(ETrue); - TheClient->iWs.Flush(); - TheClient->WaitForRedrawsToFinish(); - testWin->Win()->BeginRedraw(); - testWin->DrawNow(); - testWin->Win()->Invalidate(topHalf); - testWin->SetColor(TRgb::Gray4(1)); - testWin->DrawNow(); - testWin->Win()->EndRedraw(); - TheClient->iWs.Flush(); - CheckRectNoMatch(TPoint(screenSize.iWidth/3,0),TPoint(screenSize.iWidth/3,screenSize.iHeight/2),TSize(10,10),_L("CTRegion::ExposeTestL() A")); - - TheClient->WaitForRedrawsToFinish(); - CheckRect(TPoint(screenSize.iWidth/3,0),TPoint(screenSize.iWidth/3,screenSize.iHeight/2),TSize(screenSize.iWidth/3,screenSize.iHeight/2),_L("CTRegion::ExposeTestL() B")); - - testWin->Win()->Invalidate(topHalf); - testWin->SetColor(TRgb::Gray4(2)); - testWin->Win()->BeginRedraw(); - testWin->Win()->Invalidate(leftHalf); - testWin->DrawNow(); - testWin->Win()->EndRedraw(); - TheClient->iWs.Flush(); - CheckRect(TPoint(screenSize.iWidth/3,0),TPoint(screenSize.iWidth/3,screenSize.iHeight/2),TSize(screenSize.iWidth/6-10,screenSize.iHeight/2),_L("CTRegion::ExposeTestL() C")); - CheckRectNoMatch(TPoint(screenSize.iWidth/2,0),TPoint(screenSize.iWidth/2,screenSize.iHeight/2),TSize(10,10),_L("CTRegion::ExposeTestL() D")); - CheckRectNoMatch(TPoint(screenSize.iWidth/3,0),TPoint(screenSize.iWidth/2,0),TSize(10,10),_L("CTRegion::ExposeTestL() E")); - CheckRect(TPoint(screenSize.iWidth/3,screenSize.iHeight/2),TPoint(screenSize.iWidth/2,screenSize.iHeight/2),TSize(((screenSize.iWidth/6-5)/4*4),screenSize.iHeight/2),_L("CTRegion::ExposeTestL() F")); - testWin->Win()->BeginRedraw(); - testWin->DrawNow(); - testWin->Win()->EndRedraw(); - TheClient->iWs.Flush(); - - CheckRect(TPoint(screenSize.iWidth/3,0),TPoint(screenSize.iWidth/3,screenSize.iHeight/2),TSize(screenSize.iWidth/6-10,screenSize.iHeight/2),_L("CTRegion::ExposeTestL() G")); - CheckRectNoMatch(TPoint(screenSize.iWidth/2,0),TPoint(screenSize.iWidth/2,screenSize.iHeight/2),TSize(10,10),_L("CTRegion::ExposeTestL() H")); - CheckRect(TPoint(screenSize.iWidth/3,0),TPoint(screenSize.iWidth/2,0),TSize(((screenSize.iWidth/6-5)/4*4),screenSize.iHeight/2),_L("CTRegion::ExposeTestL() I")); - CheckRectNoMatch(TPoint(screenSize.iWidth/3,screenSize.iHeight/2),TPoint(screenSize.iWidth/2,screenSize.iHeight/2),TSize(10,10),_L("CTRegion::ExposeTestL() J")); - - CleanupStack::PopAndDestroy(testWin); - } - -#if defined(__MARM_ARM4__) - #define FADING ETrue -#elif defined(__MARM__) - #define FADING EFalse -#else - #define FADING ETrue -#endif -void CTRegion::ExposeTest2L() - { - TBool canFade=FADING; -#if defined(__MARM_THUMB__) - if (!RegionCanFadeSet) - return; - canFade=RegionCanFade; -#endif - INFO_PRINTF1(_L("AUTO REGN ExpostTest2 ")); - CBlankWindow* testWin; - RBlankWindow win(TheClient->iWs); - CleanupClosePushL(win); - TSize screenSize=TheClient->iGroup->Size(); - TRect topHalf(0,0,screenSize.iWidth/3,screenSize.iHeight/2); - testWin=new(ELeave) CBlankWindow(TRgb::Gray4(0)); - CleanupStack::PushL(testWin); - testWin->SetUpL(TPoint(screenSize.iWidth/3,0),TSize(screenSize.iWidth/3,screenSize.iHeight),TheClient->iGroup,*TheGc); - testWin->Win()->EnableRedrawStore(EFalse); - testWin->Win()->SetRequiredDisplayMode(EGray16); - testWin->SetColor(TRgb::Gray16(12)); - testWin->RealDraw(ETrue); - win.Construct(*TheClient->iGroup->WinTreeNode(),3456); - win.SetColor(TRgb::Gray4(2)); - win.SetExtent(TPoint(0,-screenSize.iHeight),TSize(screenSize.iWidth/3-2,2*screenSize.iHeight)); - win.SetShadowHeight(screenSize.iWidth/9); - win.Activate(); - TheClient->iWs.Flush(); - TheClient->WaitForRedrawsToFinish(); - INFO_PRINTF1(_L(" Constructed Windows")); - testWin->DrawNow(); - testWin->Win()->SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly); - testWin->DrawNow(topHalf); - TheClient->iWs.Flush(); - INFO_PRINTF1(_L(" Drawn TopHalf Faded")); - TBool retVal = TheClient->iScreen->RectCompare(TRect(TPoint(screenSize.iWidth/3,0),TSize(screenSize.iWidth/3,screenSize.iHeight/2)) - ,TRect(TPoint(screenSize.iWidth/3,screenSize.iHeight/2),TSize(screenSize.iWidth/3,screenSize.iHeight/2))); - TEST(retVal); - if (!retVal) - INFO_PRINTF3(_L("TheClient->iScreen->RectCompare() return value - Expected: %d, Actual: %d"), ETrue, retVal); - - testWin->DrawNow(topHalf); - TheClient->iWs.Flush(); - canFade!=TheClient->iScreen->RectCompare(TRect(TPoint(screenSize.iWidth/3,0),TSize(10,10)) - ,TRect(TPoint(screenSize.iWidth/3,screenSize.iHeight/2),TSize(10,10))); - TEST(canFade); - if (!canFade) - INFO_PRINTF3(_L("TheClient->iScreen->RectCompare() return value - Expected: %d, Actual: %d"), ETrue, canFade); - - testWin->DrawNow(); - TheClient->iWs.Flush(); - INFO_PRINTF1(_L(" All Faded (Flush)")); - - retVal = TheClient->iScreen->RectCompare(TRect(TPoint(screenSize.iWidth/3,0),TSize(screenSize.iWidth/3,screenSize.iHeight/2)) - ,TRect(TPoint(screenSize.iWidth/3,screenSize.iHeight/2),TSize(screenSize.iWidth/3,screenSize.iHeight/2))); - TEST(retVal); - if (!retVal) - INFO_PRINTF3(_L("TheClient->iScreen->RectCompare() return value - Expected: %d, Actual: %d"), ETrue, retVal); - - testWin->Win()->SetFaded(EFalse,RWindowTreeNode::EFadeWindowOnly); - TheClient->iWs.Flush(); - TheClient->WaitForRedrawsToFinish(); - INFO_PRINTF1(_L(" Redrawn Screen Unfaded")); - testWin->Win()->Invalidate(topHalf); - testWin->Win()->SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly); - testWin->DrawNow(); - TheClient->iWs.Flush(); - INFO_PRINTF1(_L(" Re Drawn Top Half Faded Again")); - retVal = TheClient->iScreen->RectCompare(TRect(TPoint(screenSize.iWidth/3,0),TSize(screenSize.iWidth/3,screenSize.iHeight/2)) - ,TRect(TPoint(screenSize.iWidth/3,screenSize.iHeight/2),TSize(screenSize.iWidth/3,screenSize.iHeight/2))); - TEST(retVal); - if (!retVal) - INFO_PRINTF3(_L("TheClient->iScreen->RectCompare() return value - Expected: %d, Actual: %d"), ETrue, retVal); - - testWin->DrawNow(); - TheClient->iWs.Flush(); - INFO_PRINTF1(_L(" Re Drawn Top Half Faded Yet Again")); - canFade!=TheClient->iScreen->RectCompare(TRect(TPoint(screenSize.iWidth/3,0),TSize(10,10)) - ,TRect(TPoint(screenSize.iWidth/3,screenSize.iHeight/2),TSize(10,10))); - TEST(canFade); - if (!canFade) - INFO_PRINTF3(_L("TheClient->iScreen->RectCompare() return value - Expected: %d, Actual: %d"), ETrue, canFade); - - testWin->DrawNow(); - TheClient->iWs.Flush(); - INFO_PRINTF1(_L(" All Faded Again")); - retVal = TheClient->iScreen->RectCompare(TRect(TPoint(screenSize.iWidth/3,0),TSize(screenSize.iWidth/3,screenSize.iHeight/2)) - ,TRect(TPoint(screenSize.iWidth/3,screenSize.iHeight/2),TSize(screenSize.iWidth/3,screenSize.iHeight/2))); - TEST(retVal); - if (!retVal) - INFO_PRINTF3(_L("TheClient->iScreen->RectCompare() return value - Expected: %d, Actual: %d"), ETrue, retVal); - - CleanupStack::PopAndDestroy(2,&win); - INFO_PRINTF1(_L(" Killed Windows")); - } - -void CTRegion::CoverTestL() - { - CBlankWindow* testWin; - RBlankWindow win(TheClient->iWs); - CleanupClosePushL(win); - TSize screenSize=TheClient->iGroup->Size(); - testWin=new(ELeave) CBlankWindow(TRgb::Gray4(0)); - CleanupStack::PushL(testWin); - testWin->SetUpL(TPoint(screenSize.iWidth/3,0),TSize(screenSize.iWidth/3,screenSize.iHeight),TheClient->iGroup,*TheGc); - testWin->SetColor(TRgb::Gray4(1)); - testWin->RealDraw(ETrue); - win.Construct(*TheClient->iGroup->WinTreeNode(),3456); - win.SetColor(TRgb::Gray4(0)); - win.SetExtent(TPoint(screenSize.iWidth/3+30,20),TSize(screenSize.iWidth/3-62,25)); - win.SetVisible(EFalse); - win.Activate(); - TheClient->iWs.Flush(); - TheClient->WaitForRedrawsToFinish(); - testWin->DrawNow(); - testWin->SetColor(TRgb::Gray4(2)); - win.SetVisible(ETrue); - testWin->DrawNow(); - TheClient->iWs.Flush(); - CheckRectNoMatch(TPoint(screenSize.iWidth/3,0),TPoint(screenSize.iWidth/3+30,20),TSize(10,10),_L("TRegion::CoverTestL() A")); - - TheClient->WaitForRedrawsToFinish(); - CheckRectNoMatch(TPoint(screenSize.iWidth/3,0),TPoint(screenSize.iWidth/3+30,20),TSize(10,10),_L("TRegion::CoverTestL() B")); - - win.SetVisible(EFalse); - TheClient->iWs.Flush(); - TheClient->WaitForRedrawsToFinish(); - testWin->SetColor(TRgb::Gray4(1)); - testWin->Win()->Invalidate(); - win.SetVisible(ETrue); - testWin->DrawNow(); - TheClient->iWs.Flush(); - CheckRectNoMatch(TPoint(screenSize.iWidth/3,0),TPoint(screenSize.iWidth/3+30,20),TSize(10,10),_L("TRegion::CoverTestL() C")); - - CleanupStack::PopAndDestroy(2,&win); - } - -void CTRegion::OffsetTestL() - { - CBlankWindow* testWin; - RBlankWindow win(TheClient->iWs); - CleanupClosePushL(win); - TSize screenSize=TheClient->iGroup->Size(); - testWin=new(ELeave) CBlankWindow(TRgb::Gray4(0)); - CleanupStack::PushL(testWin); - testWin->SetUpL(TPoint(screenSize.iWidth/3,0),TSize(screenSize.iWidth/3,screenSize.iHeight-40),TheClient->iGroup,*TheGc); - testWin->Win()->EnableRedrawStore(EFalse); - testWin->SetColor(TRgb::Gray4(1)); - testWin->RealDraw(ETrue); - win.Construct(*testWin->WinTreeNode(),3456); - win.SetColor(TRgb::Gray4(2)); - win.SetExtent(TPoint(30,20),TSize(screenSize.iWidth/3-62,25)); - win.Activate(); - TheClient->iWs.Flush(); - TheClient->WaitForRedrawsToFinish(); - win.SetVisible(EFalse); - TheClient->iWs.Flush(); - testWin->DrawNow(); - testWin->SetColor(TRgb::Gray4(2)); - testWin->Win()->SetPosition(TPoint(screenSize.iWidth/3+30,35)); - testWin->DrawNow(); - TheClient->iWs.Flush(); - /* Andy - this is verifying that the complete redraw of the window in the second DrawNow only affects part - of the window. I don't understand it atall. - CheckRectNoMatch(TPoint(screenSize.iWidth/3+60,55),TPoint(screenSize.iWidth/3+70,85),TSize(10,10),_L("CTRegion::OffsetTestL() A")); - */ - TheClient->WaitForRedrawsToFinish(); - CheckRect(TPoint(screenSize.iWidth/3+60,55),TPoint(screenSize.iWidth/3+70,85),TSize(screenSize.iWidth/3-62,25),_L("CTRegion::OffsetTestL() A")); - - win.SetVisible(ETrue); - win.SetVisible(EFalse); - testWin->Win()->SetPosition(TPoint(screenSize.iWidth/3+5,5)); - testWin->SetColor(TRgb::Gray4(1)); - testWin->DrawNow(); - TheClient->iWs.Flush(); - CheckRect(TPoint(screenSize.iWidth/3+60,55),TPoint(screenSize.iWidth/3+55,90),TSize(screenSize.iWidth/3-62,25),_L("CTRegion::OffsetTestL() B")); - /* Andy - this is verifying that the complete redraw of the window during DrawNow only affects part - of the window. I don't understand it atall. - CheckRectNoMatch(TPoint(screenSize.iWidth/3+30,20),TPoint(screenSize.iWidth/3+50,90),TSize(10,10),_L("CTRegion::OffsetTestL() B")); - */ - CleanupStack::PopAndDestroy(2,&win); - } - -void CTRegion::ClipTestL() - { - CBlankWindow* testWin; - RBlankWindow win(TheClient->iWs); - CleanupClosePushL(win); - TSize screenSize=TheClient->iGroup->Size(); - testWin=new(ELeave) CBlankWindow(TRgb::Gray4(0)); - CleanupStack::PushL(testWin); - testWin->SetUpL(TPoint(screenSize.iWidth/3,0),TSize(screenSize.iWidth/3,screenSize.iHeight),TheClient->iGroup,*TheGc); - testWin->Win()->EnableRedrawStore(EFalse); - testWin->SetColor(TRgb::Gray4(1)); - testWin->RealDraw(ETrue); - win.Construct(*testWin->WinTreeNode(),3456); - win.SetColor(TRgb::Gray4(2)); - win.SetExtent(TPoint(30,20),TSize(screenSize.iWidth/3-62,25)); - win.Activate(); - TheClient->iWs.Flush(); - TheClient->WaitForRedrawsToFinish(); - win.SetVisible(EFalse); - TheClient->iWs.Flush(); - testWin->DrawNow(); - testWin->SetColor(TRgb::Gray4(2)); - User::LeaveIfError(testWin->Win()->SetSizeErr(TSize(screenSize.iWidth/6,screenSize.iHeight-2))); - RRegion invalid; - testWin->Win()->GetInvalidRegion(invalid); - testWin->DrawNow(); - TheClient->iWs.Flush(); - TBool retVal = !invalid.CheckError(); - TEST(retVal); - if (!retVal) - INFO_PRINTF3(_L("!invalid.CheckError() return value - Expected: %d, Actual: %d"), ETrue, retVal); - - TEST(invalid.BoundingRect().iBr.iX<=screenSize.iWidth/6); - if (invalid.BoundingRect().iBr.iX>screenSize.iWidth/6) - INFO_PRINTF3(_L("invalid.BoundingRect().iBr.iX<=screenSize.iWidth/6 - Expected: %d, Actual: %d"), screenSize.iWidth/6, invalid.BoundingRect().iBr.iX); - TheClient->iWs.Finish(); - TheClient->WaitForRedrawsToFinish(); - testWin->Win()->GetInvalidRegion(invalid); - - retVal = invalid.IsEmpty(); - TEST(retVal); - if (!retVal) - { - INFO_PRINTF3(_L("!invalid.CheckError() return value - Expected: %d, Actual: %d"), ETrue, retVal); - } - - User::LeaveIfError(testWin->Win()->SetSizeErr(TSize(screenSize.iWidth/3,screenSize.iHeight-4))); - win.SetVisible(ETrue); - win.SetVisible(EFalse); - User::LeaveIfError(testWin->Win()->SetSizeErr(TSize(screenSize.iWidth/6,screenSize.iHeight-6))); - testWin->SetColor(TRgb::Gray4(1)); - testWin->DrawNow(); - TheClient->iWs.Flush(); - //PeterI This is testing an intermediate state i.e. "flicker" and will never pass on mk3 -/* CheckRectNoMatch(TPoint(screenSize.iWidth/3+30,20),TPoint(screenSize.iWidth/3+50,90),TSize(10,10),_L("CTRegion::ClipTestL()")); - TEST(retVal); - if (!retVal) - { - INFO_PRINTF3(_L("!CheckRect() return value - Expected: %d, Actual: %d"), ETrue, retVal); - } - */ - CleanupStack::PopAndDestroy(2,&win); - } - -void CTRegion::RunTestCaseL(TInt /*aCurTestCase*/) - { - ((CTRegionStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); - switch(++iTest->iState) - { -/** -@SYMTestCaseID GRAPHICS-WSERV-0272 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test drawing to a region including clipping - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Draw to a region that has clipping enabled and the check the - drawing occurs correctly - -@SYMTestExpectedResults Drawing to the region occurs correctly -*/ - case 1: - { - ((CTRegionStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0272")); - iTest->LogSubTest(_L("Main")); - RRegion clippingRegion; - CreateChildWindowsL(); - TheClient->iWs.Finish(); - TheClient->WaitForRedrawsToFinish(); - TSize scrSize(TheClient->iScreen->SizeInPixels()); - for(TUint index=0;index<(sizeof(regionRectList)/sizeof(regionRectList[0]));index++) - { - regionRectList[index].SetWidth((regionRectList[index].Width()*scrSize.iWidth)/640); - regionRectList[index].SetHeight((regionRectList[index].Height()*scrSize.iHeight)/240); - clippingRectList[index].SetWidth((clippingRectList[index].Width()*scrSize.iWidth)/640); - clippingRectList[index].SetHeight((clippingRectList[index].Height()*scrSize.iHeight)/240); - originList[index].iX = (originList[index].iX*scrSize.iWidth)/640; - originList[index].iY = (originList[index].iY*scrSize.iHeight)/240; - - clippingRegion.AddRect(regionRectList[index]); - TestRegionL(clippingRegion,clippingRectList[index],originList[index]); - } - clippingRegion.Close(); - DeleteChildWindows(); - } - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0273 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test drawing to a region including clipping as it is exposed - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Draw to a region that has clipping enabled as it is exposed - and the check the drawing occurs correctly - -@SYMTestExpectedResults Drawing to the region occurs correctly -*/ - case 2: - ((CTRegionStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0273")); - //PeterI This appears to be testing "flicker" of a window after an expose - //Mk3 doesn't exhibit this behaviour. Is the flicker expected behaviour? -// iTest->LogSubTest(_L("Expose Test")); -// ExposeTestL(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0274 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test drawing to a region including clipping as it is exposed - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Draw to a region that has clipping enabled as it is exposed - and the check the drawing occurs correctly - -@SYMTestExpectedResults Drawing to the region occurs correctly -*/ - case 3: - ((CTRegionStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0274")); - iTest->LogSubTest(_L("Expose Test2")); - ExposeTest2L(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0275 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test drawing to a region including clipping as it is covered - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Draw to a region that has clipping enabled as it is covered - and the check the drawing occurs correctly - -@SYMTestExpectedResults Drawing to the region occurs correctly -*/ - case 4: - ((CTRegionStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0275")); - iTest->LogSubTest(_L("Cover Test")); - CoverTestL(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0276 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test drawing to a region including clipping and with an offset - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Draw to a region that has clipping enabled and with an offset - and the check the drawing occurs correctly - -@SYMTestExpectedResults Drawing to the region occurs correctly -*/ - case 5: - ((CTRegionStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0276")); - iTest->LogSubTest(_L("Offset Test")); - OffsetTestL(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0277 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test drawing to a region including clipping - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Draw to a region that has clipping enabled - and the check the drawing occurs correctly - -@SYMTestExpectedResults Drawing to the region occurs correctly -*/ - case 6: - ((CTRegionStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0277")); - iTest->LogSubTest(_L("Clip Test")); - ClipTestL(); - break; - default: - ((CTRegionStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - ((CTRegionStep*)iStep)->CloseTMSGraphicsStep(); - TestComplete(); - } - ((CTRegionStep*)iStep)->RecordTestResultL(); - } - - -__WS_CONSTRUCT_STEP__(Region) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TSCRDEV.CPP --- a/windowing/windowserver/tauto/TSCRDEV.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,642 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Screen device test code -// -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include "TSCRDEV.H" - -//Define this to get visible pauses (in test 6: DeviceResSwitchL) -//#define VISIBLE_PAUSES - -//Define this to get extra logging which may be useful in tracking down a fail -//#define EXTRA_LOGGING - -CTScreenDevice::CTScreenDevice(CTestStep* aStep) : CTWsGraphicsBase(aStep) - {} - -CTScreenDevice::~CTScreenDevice() - {} - -void CTScreenDevice::ConstructL() - { - //The following is just another test... it doesn't leave any resources for use by the test class AFAICT... - RWsSession aSession; - CWsScreenDevice *device1; - CWsScreenDevice *device2; - CWsScreenDevice *device3; - - aSession.Connect(); - device1=new(ELeave) CWsScreenDevice(aSession); - device1->Construct(iTest->iScreenNumber); - delete device1; - device1=new(ELeave) CWsScreenDevice(aSession); - device1->Construct(iTest->iScreenNumber); - device2=new(ELeave) CWsScreenDevice(aSession); - device2->Construct(iTest->iScreenNumber); - device3=new(ELeave) CWsScreenDevice(aSession); - device3->Construct(iTest->iScreenNumber); - delete device3; - CFbsFont *font; - User::LeaveIfError(device1->GetNearestFontToDesignHeightInTwips((CFont *&)font,TFontSpec())); - RWindowGroup group(aSession); - group.Construct(777); - group.SetOwningWindowGroup(TheClient->iGroup->GroupWin()->Identifier()); - RWindow win(aSession); - win.Construct(group,77); - CWindowGc *gc=new(ELeave) CWindowGc(device1); - gc->Construct(); - gc->Activate(win); - gc->UseFont(font); - device1->ReleaseFont(font); - aSession.Flush(); - delete gc; - win.Close(); - group.Close(); - delete device1; - delete device2; - aSession.Close(); - } - - -void CTScreenDevice::TestTwipPixelConversions() - { - TInt result=TheClient->iScreen->HorizontalTwipsToPixels(TheClient->iScreen->HorizontalPixelsToTwips(1234)); - TEST(result==1234); - if (result!=1234) - INFO_PRINTF3(_L("TheClient->iScreen->HorizontalTwipsToPixels(TheClient->iScreen->HorizontalPixelsToTwips(1234) return value - Expected: %d, Actual: %d"), 1234, result); - - result=TheClient->iScreen->VerticalTwipsToPixels(TheClient->iScreen->VerticalPixelsToTwips(1234)); - TEST(result==1234); - if (result!=1234) - INFO_PRINTF3(_L("TheClient->iScreen->VerticalTwipsToPixels(TheClient->iScreen->VerticalPixelsToTwips(1234) return value - Expected: %d, Actual: %d"), 1234, result); - - TSize pixels=TheClient->iScreen->SizeInPixels(); - TSize twips=TheClient->iScreen->SizeInTwips(); - TInt conv=TheClient->iScreen->HorizontalPixelsToTwips(pixels.iWidth); - TEST(conv==twips.iWidth); - if (conv!=twips.iWidth) - INFO_PRINTF3(_L("TheClient->iScreen->HorizontalPixelsToTwips(pixels.iWidth) return value - Expected: %d, Actual: %d"), twips.iWidth, conv); - - conv=TheClient->iScreen->VerticalPixelsToTwips(pixels.iHeight); - TEST(conv==twips.iHeight); - if (conv!=twips.iHeight) - INFO_PRINTF3(_L("TheClient->iScreen->VerticalPixelsToTwips(pixels.iHeight) return value - Expected: %d, Actual: %d"), twips.iHeight, conv); - } - -#define TEST_VALUE 100000000 -void CTScreenDevice::TestTwipPixelOverflow() - { - TInt result=TheClient->iScreen->HorizontalTwipsToPixels(TheClient->iScreen->HorizontalPixelsToTwips(TEST_VALUE)); - TEST(result==TEST_VALUE); - if (result!=TEST_VALUE) - INFO_PRINTF3(_L("TheClient->iScreen->HorizontalTwipsToPixels(TheClient->iScreen->HorizontalPixelsToTwips(TEST_VALUE)) return value - Expected: %d, Actual: %d"), TEST_VALUE, result); - - result=TheClient->iScreen->VerticalTwipsToPixels(TheClient->iScreen->VerticalPixelsToTwips(TEST_VALUE)); - TEST(result==TEST_VALUE); - if (result!=TEST_VALUE) - INFO_PRINTF3(_L("TheClient->iScreen->VerticalTwipsToPixels(TheClient->iScreen->VerticalPixelsToTwips(TEST_VALUE)) return value - Expected: %d, Actual: %d"), TEST_VALUE, result); - - result = TheClient->iScreen->HorizontalPixelsToTwips(TEST_VALUE); - TEST(result>0); - if (!result>0) - INFO_PRINTF3(_L("TheClient->iScreen->HorizontalPixelsToTwips(TEST_VALUE) return value - Expected: %d less than, Actual: %d"), 0, result); - - result = TheClient->iScreen->VerticalPixelsToTwips(TEST_VALUE); - TEST(result>0); - if (!result>0) - INFO_PRINTF3(_L("TheClient->iScreen->VerticalPixelsToTwips(TEST_VALUE) return value - Expected: %d less than, Actual: %d"), 0, result); - - result = TheClient->iScreen->HorizontalTwipsToPixels(TEST_VALUE); - TEST(result>0); - if (!result>0) - INFO_PRINTF3(_L("TheClient->iScreen->HorizontalTwipsToPixels(TEST_VALUE) return value - Expected: %d less than, Actual: %d"), 0, result); - - result = TheClient->iScreen->VerticalTwipsToPixels(TEST_VALUE); - TEST(result>0); - if (!result>0) - INFO_PRINTF3(_L("TheClient->iScreen->VerticalTwipsToPixels(TEST_VALUE) return value - Expected: %d less than, Actual: %d"), 0, result); - } - -void CTScreenDevice::TwipsCacheFlushL() - { - RWsSession session; - CWsScreenDevice* device; - CFont* font; - CFont* font2; - const TFontSpec fontspec(KTestFontTypefaceName,250); - TPixelsTwipsAndRotation sizeAndRotation; - - // create a CWsScreenDevice instance - User::LeaveIfError(session.Connect()); - device=new(ELeave) CWsScreenDevice(session); - device->Construct(iTest->iScreenNumber); - - // Record a font height for use by latter tests - User::LeaveIfError(device->GetNearestFontToDesignHeightInTwips(font,fontspec)); - const TInt height0=font->HeightInPixels(); - device->ReleaseFont(font); - - // 1. find font with best-matching height in twips, - // 2. change twips size of the screen (leaving pixel-size same), - // 3. find font with best-matching height in twips, - // 4. make sure that the newly found font is not the same as previous and has the different height in pixels - device->GetDefaultScreenSizeAndRotation(sizeAndRotation); -#if defined(EXTRA_LOGGING) - _LIT(KLog1,"Font height: %d for unchanged device. pixels=%d,%d twips=%d,%d"); - LOG_MESSAGE6(KLog1,height0,sizeAndRotation.iPixelSize.iWidth,sizeAndRotation.iPixelSize.iHeight - ,sizeAndRotation.iTwipsSize.iWidth,sizeAndRotation.iTwipsSize.iHeight); -#endif - sizeAndRotation.iTwipsSize.iHeight=2000; - sizeAndRotation.iTwipsSize.iWidth =3000; - device->SetScreenSizeAndRotation(sizeAndRotation); - - User::LeaveIfError(device->GetNearestFontToDesignHeightInTwips(font,fontspec)); - TInt height=font->HeightInPixels(); -#if defined(EXTRA_LOGGING) - _LIT(KLog2,"Font height: %d for device with twips set to 2000x3000"); - LOG_MESSAGE2(KLog2,height); -#endif - TFontSpec returnedSpec=font->FontSpecInTwips(); - - sizeAndRotation.iTwipsSize.iHeight=4000; - sizeAndRotation.iTwipsSize.iWidth =6000; - device->SetScreenSizeAndRotation(sizeAndRotation); - - User::LeaveIfError(device->GetNearestFontToDesignHeightInTwips(font2,fontspec)); - TInt height2=font2->HeightInPixels(); - TFontSpec returnedSpec2 = font2->FontSpecInTwips(); -#if defined(EXTRA_LOGGING) - _LIT(KLog3,"Font height: %d for device with twips set to 4000x6000"); - LOG_MESSAGE2(KLog3,height2); -#endif - - TEST(font!=font2); - TEST(height!=height2); - _LIT(KLogErrM,"Font Heights in pixels match unexpectantly, height=%d"); - if (height==height2) - INFO_PRINTF2(KLogErrM,height); - - device->ReleaseFont(font2); - device->ReleaseFont(font); - - // 1. find font with best-matching height in twips, - // 2. change pixel size of the screen (leaving twip-size same), - // 3. find font with best-matching height in twips, - // 4. make sure that the newly found font is not the same as previous and has the different height in pixels - device->GetDefaultScreenSizeAndRotation(sizeAndRotation); - sizeAndRotation.iPixelSize.iHeight=240; - sizeAndRotation.iPixelSize.iWidth =640; - device->SetScreenSizeAndRotation(sizeAndRotation); - - User::LeaveIfError(device->GetNearestFontToDesignHeightInTwips(font,fontspec)); - height=font->HeightInPixels(); - returnedSpec=font->FontSpecInTwips(); -#if defined(EXTRA_LOGGING) - _LIT(KLog4,"Font height: %d for device with pixels set to 240x640 twips=%d,%d"); - LOG_MESSAGE4(KLog4,height,sizeAndRotation.iTwipsSize.iWidth,sizeAndRotation.iTwipsSize.iHeight); -#endif - - sizeAndRotation.iPixelSize.iHeight=480; - sizeAndRotation.iPixelSize.iWidth =1280; - device->SetScreenSizeAndRotation(sizeAndRotation); - - User::LeaveIfError(device->GetNearestFontToDesignHeightInTwips(font2,fontspec)); - height2=font2->HeightInPixels(); - returnedSpec2=font2->FontSpecInTwips(); -#if defined(EXTRA_LOGGING) - _LIT(KLog5,"Font height: %d for device with pixels set to 480x1280"); - LOG_MESSAGE2(KLog5,height2); -#endif - - TEST(font!=font2); - TEST(height!=height2); - if (height==height2) - INFO_PRINTF2(KLogErrM,height); - - device->ReleaseFont(font2); - device->ReleaseFont(font); - - // 1. double the width and height of screen in both pixels and twips - // 2. find font with best-matching height in twips, - // 3. make sure that the newly found font is the same as previous and has the same height in pixels - device->GetDefaultScreenSizeAndRotation(sizeAndRotation); - device->SetScreenSizeAndRotation(sizeAndRotation); - User::LeaveIfError(device->GetNearestFontToDesignHeightInTwips(font,fontspec)); - sizeAndRotation.iPixelSize.iHeight*=2; - sizeAndRotation.iPixelSize.iWidth *=2; - sizeAndRotation.iTwipsSize.iHeight*=2; - sizeAndRotation.iTwipsSize.iWidth *=2; - device->SetScreenSizeAndRotation(sizeAndRotation); - - User::LeaveIfError(device->GetNearestFontToDesignHeightInTwips(font2,fontspec)); - height2=font2->HeightInPixels(); -#if defined(EXTRA_LOGGING) - _LIT(KLog6,"Font height: %d for device doubled size. pixels=%d,%d twips=%d,%d"); - LOG_MESSAGE6(KLog6,height2,sizeAndRotation.iPixelSize.iWidth,sizeAndRotation.iPixelSize.iHeight - ,sizeAndRotation.iTwipsSize.iWidth,sizeAndRotation.iTwipsSize.iHeight); -#endif - - TEST(font==font2); - TEST(height0==height2); - _LIT(KLogErrD,"Font Heights in pixels don't match, expected=%d, actual=%d"); - if (height0!=height2) - INFO_PRINTF3(KLogErrD,height0,height2); - - device->ReleaseFont(font2); - device->ReleaseFont(font); - - // 1. swap width and height sizes of screen for both pixels and twips - // 2. find font with best-matching height in twips, - // 3. make sure that the newly found font is the same as previous and has the same height in pixels - device->GetDefaultScreenSizeAndRotation(sizeAndRotation); - device->SetScreenSizeAndRotation(sizeAndRotation); - User::LeaveIfError(device->GetNearestFontToDesignHeightInTwips(font,fontspec)); - TInt swap=sizeAndRotation.iPixelSize.iHeight; - sizeAndRotation.iPixelSize.iHeight=sizeAndRotation.iPixelSize.iWidth; - sizeAndRotation.iPixelSize.iWidth =swap; - swap=sizeAndRotation.iTwipsSize.iHeight; - sizeAndRotation.iTwipsSize.iHeight=sizeAndRotation.iTwipsSize.iWidth; - sizeAndRotation.iTwipsSize.iWidth =swap; - device->SetScreenSizeAndRotation(sizeAndRotation); - User::LeaveIfError(device->GetNearestFontToDesignHeightInTwips(font2,fontspec)); - height2 = font2->HeightInPixels(); -#if defined(EXTRA_LOGGING) - _LIT(KLog7,"Font height: %d for device rotated size. pixels=%d,%d twips=%d,%d"); - LOG_MESSAGE6(KLog7,height2,sizeAndRotation.iPixelSize.iWidth,sizeAndRotation.iPixelSize.iHeight - ,sizeAndRotation.iTwipsSize.iWidth,sizeAndRotation.iTwipsSize.iHeight); -#endif - - TEST(font==font2); - TEST(height0==height2); - if (height0!=height2) - INFO_PRINTF3(KLogErrD,height0,height2); - - device->ReleaseFont(font2); - device->ReleaseFont(font); - - delete device; - session.Close(); - } - -void CTScreenDevice::CheckBitmapL(CFbsBitmap *aBitmap, const TRect &aRect) - { - CFbsBitmapDevice *device=CFbsBitmapDevice::NewL(aBitmap); - CleanupStack::PushL(device); - TInt height=Min(aRect.Size().iHeight,aBitmap->SizeInPixels().iHeight); - TInt width=Min(aRect.Size().iWidth,aBitmap->SizeInPixels().iWidth); - TPoint pos(0,0); - TInt bufLen=CFbsBitmap::ScanLineLength(width,EGray4); - TAny *buf1=User::AllocLC(bufLen); - TAny *buf2=User::AllocLC(bufLen); - TPtr8 scanBuf1((TUint8 *)buf1,bufLen); - TPtr8 scanBuf2((TUint8 *)buf2,bufLen); - TInt oddPixels=width%4; - TInt byte1,byte2; - for(;pos.iYiScreen->GetScanLine(scanBuf1,pos+aRect.iTl,width,EGray4); - device->GetScanLine(scanBuf2,pos,width,EGray4); - if (oddPixels>0) - { - byte1=(scanBuf1[bufLen-1]<<(2*(4-oddPixels)))%256; - byte2=(scanBuf2[bufLen-1]<<(2*(4-oddPixels)))%256; - TEST(byte1==byte2); - if (byte1!=byte2) - INFO_PRINTF3(_L("byte1==byte2 - byte1: %d, byte2 Height: %d"), byte1, byte2); - - scanBuf1=scanBuf1.Left(bufLen-1); - scanBuf2=scanBuf2.Left(bufLen-1); - } - TBool retVal = !scanBuf1.Compare(scanBuf2); - TEST(retVal); - if (!retVal) - INFO_PRINTF3(_L("!scanBuf1.Compare(scanBuf2) return value - Expected: %d, Actual: %d"), ETrue, retVal); - } - CleanupStack::PopAndDestroy(3); - } - -void CTScreenDevice::doTestScreenToBitmapL() - { - RBlankWindow shieldWin(TheClient->iWs); - shieldWin.Construct(*TheClient->iGroup->GroupWin(),1); - shieldWin.SetOrdinalPosition(0,-1); - shieldWin.SetColor(TRgb::Gray4(1)); - shieldWin.Activate(); - CleanupStack::PushL(TCleanupItem(CleanUpWindow,&shieldWin)); - TSize scrSize(TheClient->iScreen->SizeInPixels()); - CWsBitmap *wsBitmap=new(ELeave) CWsBitmap(TheClient->iWs); - CleanupStack::PushL(wsBitmap); - User::LeaveIfError(wsBitmap->Create(scrSize,EGray4)); - CFbsBitmap *bitmap=new(ELeave) CFbsBitmap; - CleanupStack::PushL(bitmap); - - TheClient->iWs.Finish(); - TheClient->WaitForRedrawsToFinish(); - - User::LeaveIfError(bitmap->Create(TSize(30,10),EGray4)); -// - User::LeaveIfError(TheClient->iScreen->CopyScreenToBitmap(wsBitmap)); - CheckBitmapL(wsBitmap,TRect(scrSize)); -// - User::LeaveIfError(TheClient->iScreen->CopyScreenToBitmap(bitmap)); - CheckBitmapL(bitmap,TRect(scrSize)); -// - TRect rect1(111,10,222,20); - User::LeaveIfError(TheClient->iScreen->CopyScreenToBitmap(wsBitmap,rect1)); - CheckBitmapL(wsBitmap,rect1); -// - TRect rect2(10,20,100,200); - User::LeaveIfError(TheClient->iScreen->CopyScreenToBitmap(bitmap,rect2)); - CheckBitmapL(bitmap,rect2); -// -// Now some mad values -// -// Right edge left of left edge - User::LeaveIfError(TheClient->iScreen->CopyScreenToBitmap(bitmap,TRect(100,20,90,200))); -// Off the edge of the screen - User::LeaveIfError(TheClient->iScreen->CopyScreenToBitmap(bitmap,TRect(-10,20,-5,200))); -// Off the edge of the screen again - User::LeaveIfError(TheClient->iScreen->CopyScreenToBitmap(bitmap,TRect(scrSize.AsPoint()+TPoint(5,5),TSize(10,10)))); -// - CleanupStack::PopAndDestroy(3); - } - - - -void CTScreenDevice::TestScreenToBitmap() - { - TRAPD(ret,doTestScreenToBitmapL()); - TEST(ret==KErrNone); - if (ret!=KErrNone) - INFO_PRINTF3(_L("doTestScreenToBitmapL() return value - Expected: %d, Actual: %d"), KErrNone, ret); - } - - -CCachePanic::~CCachePanic() - { - delete iWsScrDev; - iWs.Close(); - } - -void CCachePanic::ConstructL(TInt aScreenNumber, TInt aInt) - { - iScreenNumber = aScreenNumber; - iInt = aInt; - - User::LeaveIfError(iWs.Connect()); - iWsScrDev=new(ELeave) CWsScreenDevice(iWs); - User::LeaveIfError(iWsScrDev->Construct(iScreenNumber)); - } - -TInt CCachePanic::DoTest(CCachePanic* aTestClass) - { - CActiveScheduler* activeScheduler=new(ELeave) CActiveScheduler; - CActiveScheduler::Install(activeScheduler); - CleanupStack::PushL(activeScheduler); - TRAP_IGNORE(aTestClass->TestL()); - CleanupStack::PopAndDestroy(activeScheduler); - return EWsExitReasonFinished; - } - -void CCachePanic::TestL() - { - AutoPanic(EAutoPanicTestFailed); - } - -TInt CTwipsPanic::RunTest(TInt aInt, TAny* aPtr) - { - TInt error = KErrNone; - - CTwipsPanic* self=new(ELeave) CTwipsPanic(); - CleanupStack::PushL(self); - - TRAP(error, self->ConstructL((TInt)aPtr, aInt)); - if (!error) - { - error = CCachePanic::DoTest(self); - } - CleanupStack::PopAndDestroy(self); - return error; - } - -void CTwipsPanic::TestL() - { - TPixelsTwipsAndRotation sizeAndRotation; - TFontSpec fontspec(KTestFontTypefaceName,250); - - CFbsFont *font; - CFbsFont *font2; - - iWsScrDev->GetDefaultScreenSizeAndRotation(sizeAndRotation); - sizeAndRotation.iTwipsSize.iHeight = 2000; - sizeAndRotation.iTwipsSize.iWidth = 3000; - iWsScrDev->SetScreenSizeAndRotation(sizeAndRotation); - iWsScrDev->GetNearestFontToDesignHeightInTwips((CFont *&)font,fontspec); - iWsScrDev->GetNearestFontToDesignHeightInTwips((CFont *&)font2,fontspec); - sizeAndRotation.iTwipsSize.iHeight = 4000; - sizeAndRotation.iTwipsSize.iWidth = 6000; - iWsScrDev->SetScreenSizeAndRotation(sizeAndRotation); - iWsScrDev->ReleaseFont(font); - } - -TInt CScanLinePanic::RunTest(TInt aInt, TAny* aPtr) - { - TInt error = KErrNone; - - CScanLinePanic* self=new(ELeave) CScanLinePanic(); - CleanupStack::PushL(self); - - TRAP(error, self->ConstructL((TInt)aPtr, aInt)); - if (!error) - { - error = CCachePanic::DoTest(self); - } - CleanupStack::PopAndDestroy(self); - return error; - } - -void CScanLinePanic::TestL() - { - switch (iInt) - { - case TESTCASE_GRAPHICS_WSERV_0473: - TestLengthInvariant(); - break; - case TESTCASE_GRAPHICS_WSERV_0474: - TestBufferInvariant(); - break; - } - } - -void CScanLinePanic::TestLengthInvariant() - { - TInt buffLength=50; - TInt length=-1; - TUint8* buffer=new(ELeave) TUint8[buffLength]; - TPtr8 scanline(buffer, buffLength, buffLength); - iWsScrDev->GetScanLine(scanline, TPoint(), length, EColor64K); - delete buffer; - } - -void CScanLinePanic::TestBufferInvariant() - { - TInt buffLength=19; - TInt length=10; - TUint8* buffer=new(ELeave) TUint8[buffLength]; - TPtr8 scanline(buffer, buffLength, buffLength); - iWsScrDev->GetScanLine(scanline, TPoint(), length, EColor64K); - delete buffer; - } - -void CTScreenDevice::RunTestCaseL(TInt /*aCurTestCase*/) - { - ((CTScreenDeviceStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); - switch(++iTest->iState) - { -/** -@SYMTestCaseID GRAPHICS-WSERV-0080 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test twips to pixels conversions - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Converts pixels to twips and then back the result back to pixels. Checks screen size request methods both in pixels and twips - -@SYMTestExpectedResults Expects that back and forth conversions preserve an original value. -*/ - case 1: - ((CTScreenDeviceStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0080")); - iTest->LogSubTest(_L("Screen Device 1")); - TestTwipPixelConversions(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0081 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Tests CWsScreenDevice::CopyScreenToBitmap method - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Creates a blank window on the screen and uses CWsScreenDevice::CopyScreenToBitmap to copy parts of the screen image to either CWsBitmap or CFbsBitmap - -@SYMTestExpectedResults Expects that the method will not fail and that the image is copied correctly making pixel-to-pixel comparisons -*/ - case 2: - ((CTScreenDeviceStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0081")); - iTest->LogSubTest(_L("Copy Screen To Bitmap")); - TestScreenToBitmap(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0082 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test for integrity of twips to pixels conversions providing big values - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Calls twips to pixels (and backward) conversions for 100000000 value - -@SYMTestExpectedResults Expects that back and forth conversions preserve an original value. Make sure that the result is always greater that 0. -*/ - case 3: - ((CTScreenDeviceStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0082")); - iTest->LogSubTest(_L("Twip To Pixels Overflow")); - TestTwipPixelOverflow(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0083 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test that twips-in-pixel ratio change for screen size affects twips-in-pixel ratio of font - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Changes number of twips on screen (leaving number of pixels same), changes number of pixels on screen (leaving number of twips same), makes proportional changes of screen size for both twips and pixels - -@SYMTestExpectedResults Expects that twips-in-pixel ratio of font leaves the same only when screen size was changed through multipying of width by a coefficient (same for both twips and pixels) and multipying of height by a coefficient (same for both twips and pixels) -*/ - case 4: - ((CTScreenDeviceStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0083")); - iTest->LogSubTest(_L("Twips cache flush after device size change")); - TwipsCacheFlushL(); - break; - case 5: - ((CTScreenDeviceStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0083")); - iTest->LogSubTest(_L("Twips cache reset")); - // not expecting any panic - TEST(iTest->TestPanicL(CTwipsPanic::RunTest, 0, 0, (TAny*)iTest->iScreenNumber, _L(""))); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0473 - -@SYMDEF DEF116127 - -@SYMTestCaseDesc Invariant testing length parameter of less then 0 values in CWsScreenDevice::GetScanLine() - method - -@SYMTestActions Calls CWsScreenDevice::GetScanLine with aLength of -1. - -**/ - case 6: - ((CTScreenDeviceStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0473")); - iTest->LogSubTest(_L("Testing ScanLine length invariant")); - TEST(iTest->TestPanicL(CScanLinePanic::RunTest, EWservPanicInvalidParameter, - CScanLinePanic::TESTCASE_GRAPHICS_WSERV_0473, - (TAny*)iTest->iScreenNumber, _L("WSERV"))); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0474 - -@SYMDEF DEF116127 - -@SYMTestCaseDesc Invariant testing buffer parameter for required size. - -@SYMTestActions Calls CWsScreenDevice::GetScanLine with buffer too small to contain requested data. -**/ - case 7: - ((CTScreenDeviceStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0474")); - iTest->LogSubTest(_L("Testing ScanLine buffer invariant")); - TEST(iTest->TestPanicL(CScanLinePanic::RunTest, EWservPanicInvalidParameter, - CScanLinePanic::TESTCASE_GRAPHICS_WSERV_0474, - (TAny*)iTest->iScreenNumber, _L("WSERV"))); - break; - default: - ((CTScreenDeviceStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - ((CTScreenDeviceStep*)iStep)->CloseTMSGraphicsStep(); - TestComplete(); - } - ((CTScreenDeviceStep*)iStep)->RecordTestResultL(); - } - -__WS_CONSTRUCT_STEP__(ScreenDevice) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TSCRDEV.H --- a/windowing/windowserver/tauto/TSCRDEV.H Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,107 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef __TSCRDEV_H__ -#define __TSCRDEV_H__ - -#include -#include "w32std.h" -#include "../tlib/testbase.h" -#include "AUTO.H" -#include "TGraphicsHarness.h" - -class CTScreenDevice : public CTWsGraphicsBase - { -public: - CTScreenDevice(CTestStep* aStep); - ~CTScreenDevice(); - void ConstructL(); - void TestTwipPixelConversions(); - void TestTwipPixelOverflow(); - void TwipsCacheFlushL(); - void CheckBitmapL(CFbsBitmap *aBitmap, const TRect &aRect); - void TestScreenToBitmap(); -protected: - virtual void RunTestCaseL(TInt aCurTestCase); -private: - void doTestScreenToBitmapL(); - }; - -class CTScreenDeviceStep : public CTGraphicsStep - { -public: - CTScreenDeviceStep(); -protected: - //from CTGraphicsStep - virtual CTGraphicsBase* CreateTestL(); - }; - -class CCachePanic : public CBase - { -protected: - CCachePanic() - { - }; - ~CCachePanic(); - virtual void TestL(); - void ConstructL(TInt aScreenNumber, TInt aInt); - static TInt DoTest(CCachePanic* aTestClass); - -protected: - RWsSession iWs; - CWsScreenDevice* iWsScrDev; - TInt iScreenNumber; - TInt iInt; - }; - -class CTwipsPanic : public CCachePanic - { -public: - static TInt RunTest(TInt aInt, TAny* aPtr); - -private: - virtual void TestL(); - }; - -class CScanLinePanic : public CCachePanic - { -public: - enum ScanLineTestCases - { - TESTCASE_GRAPHICS_WSERV_0473 = 0, - TESTCASE_GRAPHICS_WSERV_0474 - }; -public: - static TInt RunTest(TInt aInt, TAny* aPtr); - -private: - virtual void TestL(); - - // Methods for test cases go here -private: - void TestLengthInvariant(); - void TestBufferInvariant(); - - }; - -_LIT(KTScreenDeviceStep,"TScreenDevice"); - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TSCRDEVRESSWITCH.CPP --- a/windowing/windowserver/tauto/TSCRDEVRESSWITCH.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,581 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Screen device test code -// -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include "TSCRDEVRESSWITCH.H" - -//Define this to get visible pauses (in test 6: DeviceResSwitchL) -//#define VISIBLE_PAUSES - -//Define this to get extra logging which may be useful in tracking down a fail -//#define EXTRA_LOGGING - -CTScreenDeviceResSwitch::CTScreenDeviceResSwitch(CTestStep* aStep) : CTWsGraphicsBase(aStep) - {} - -CTScreenDeviceResSwitch::~CTScreenDeviceResSwitch() - {} - -void CTScreenDeviceResSwitch::ConstructL() - { - //The following is just another test... it doesn't leave any resources for use by the test class AFAICT... - RWsSession aSession; - CWsScreenDevice *device1; - CWsScreenDevice *device2; - CWsScreenDevice *device3; - - aSession.Connect(); - device1=new(ELeave) CWsScreenDevice(aSession); - device1->Construct(iTest->iScreenNumber); - delete device1; - device1=new(ELeave) CWsScreenDevice(aSession); - device1->Construct(iTest->iScreenNumber); - device2=new(ELeave) CWsScreenDevice(aSession); - device2->Construct(iTest->iScreenNumber); - device3=new(ELeave) CWsScreenDevice(aSession); - device3->Construct(iTest->iScreenNumber); - delete device3; - CFbsFont *font; - User::LeaveIfError(device1->GetNearestFontToDesignHeightInTwips((CFont *&)font,TFontSpec())); - RWindowGroup group(aSession); - group.Construct(777); - group.SetOwningWindowGroup(TheClient->iGroup->GroupWin()->Identifier()); - RWindow win(aSession); - win.Construct(group,77); - CWindowGc *gc=new(ELeave) CWindowGc(device1); - gc->Construct(); - gc->Activate(win); - gc->UseFont(font); - device1->ReleaseFont(font); - aSession.Flush(); - delete gc; - win.Close(); - group.Close(); - delete device1; - delete device2; - aSession.Close(); - } - - -class CPrimaryColoursWin : public CTWin - { -public: - enum //various size factors - { - kShrinkFactor=5, - kPlotSize=16, - kPlotMargin=4, - kPlotWithMargin=kPlotSize+kPlotMargin, - kPlotsAccross=3, - kPlotsDown=1, - kMinWidth=kPlotWithMargin*kPlotsAccross+kPlotMargin, - kMinHeight=kPlotWithMargin*kPlotsDown+kPlotMargin, - KNumChannels=3, - KNumColours=256 - }; - - CPrimaryColoursWin(); - ~CPrimaryColoursWin(); - //Virtual Function from CTBaseWin - void Draw(); - TInt CountUniquePlottedColours(); - TInt iDrawn; - TInt iNumColours; - TBool iBadPixels[KNumChannels][KNumColours]; - TBuf<0x40> iDisplayText; - }; - -CPrimaryColoursWin::CPrimaryColoursWin() - { - for (TInt channelnum=0;channelnumSetBrushStyle(CGraphicsContext::ESolidBrush); - iGc->SetPenStyle(CGraphicsContext::ESolidPen); - iGc->SetPenColor(TRgb(255, 255, 255)); - iGc->SetBrushColor(TRgb(0, 0, 0)); - TSize winSize = Size(); - iGc->DrawRect(TRect(winSize)); - - CFont* font; - TFontSpec fontSpec(_L(""), 300); - TheClient->iScreen->GetNearestFontInTwips(font, fontSpec); - - if (font) - { - iGc->UseFont(font); - TRect r(TPoint(0, 0), Size()); - r.Shrink(kMinHeight, kMinHeight); - iGc->DrawText(iDisplayText, r, font->AscentInPixels(), iGc->ECenter, 0); - iGc->DiscardFont(); - TheClient->iScreen->ReleaseFont(font); - } - - iNumColours = 0; - TPoint lhsAbs = Win()->AbsPosition(); - - for(TInt channelnum = 0, channelmul = 1, xoordinate = kPlotMargin; channelnum < KNumChannels; channelnum++, channelmul <<= 8, xoordinate += kPlotWithMargin) - { - TRgb lastPixel(255, 255, 255, 255); - - for(TInt colour = 0; colour < KNumColours; colour++) - { - if(!iBadPixels[channelnum][colour]) - { - iGc->SetPenColor(TRgb(colour * channelmul)); - } - else - { - iGc->SetPenColor(TRgb(255, 255, 255)); - } - - TPoint point = TPoint(xoordinate + (colour & 0x0f), kPlotMargin + (colour >> 4)); - iGc->Plot(point); - } - } - - iDrawn=ETrue; - } - -TInt CPrimaryColoursWin::CountUniquePlottedColours() - { - iNumColours = 0; - TPoint lhsAbs = Win()->AbsPosition(); - - for(TInt channelnum = 0, channelmul = 1, xoordinate = kPlotMargin; channelnum < 3; channelnum++, channelmul <<=8 , xoordinate += kPlotWithMargin) - { - TRgb lastPixel(255, 255, 255, 255); - - for(TInt colour = 0; colour < 256; colour++) - { - TRgb readPixel; - TPoint point = TPoint(xoordinate + (colour & 0x0f), kPlotMargin + (colour >> 4)); - TheClient->iScreen->GetPixel(readPixel, lhsAbs + point); - - if(readPixel != lastPixel) - { - lastPixel = readPixel; - iNumColours++; - iBadPixels[channelnum][colour] = EFalse; - } - else - { - iBadPixels[channelnum][colour] = ETrue; - } - } // for loop - } // for loop - - return iNumColours; - } - -/** - Intended primarily as a visual check that the mode is displayed correctly, - for each rotated mode. -**/ -void CTScreenDeviceResSwitch::DeviceResSwitchWithRotationsL() - { - CWsScreenDevice *screen=TheClient->iScreen; - TInt originalScreenMode = screen->CurrentScreenMode(); - TPixelsTwipsAndRotation originalModeSettings; - screen->GetScreenModeSizeAndRotation(originalScreenMode,originalModeSettings); - CArrayFixFlat *rotations=new(ELeave) CArrayFixFlat(1); - CleanupStack::PushL(rotations); - INFO_PRINTF2(_L("ScreenMode and rotation with colour depth. ScreenModes=%i"),TheClient->iScreenModes.Count()); - - for (TInt rr=0,maxrr=3;rriScreenModes.Count();iiiScreenModes[ii]; - if ( screen->GetScreenModeOrigin(ii)!=TPoint(0,0) || screen->GetScreenModeScale(ii)!=TSize(1,1) ) - { - INFO_PRINTF2(_L("ScreenMode %i skipped: has scalind and/ or rotation"),ii); - INFO_PRINTF1(_L("This scaling code is known to be broken if all modes do not support scaling")); - INFO_PRINTF1(_L("See defect DEF111847 and break request 2226")); - INFO_PRINTF5(_L("Origin: %i %i Scale %i %i"), - screen->GetScreenModeOrigin(ii).iX,screen->GetScreenModeOrigin(ii).iY, - screen->GetScreenModeScale(ii).iWidth,screen->GetScreenModeScale(ii).iHeight - ); - continue; - } - - screen->SetAppScreenMode(newMode); - screen->SetScreenMode(newMode); - TInt currentScreenMode = screen->CurrentScreenMode(); - TEST(currentScreenMode == newMode); - - User::LeaveIfError(screen->GetRotationsList(newMode,rotations)); - INFO_PRINTF4(_L("ScreenMode and rotation with colour depth. Mode#%i=%i. Rotations=%i"),ii,newMode,rotations->Count()); - TPixelsTwipsAndRotation currentModeSettings; - screen->GetDefaultScreenSizeAndRotation(currentModeSettings); - screen->SetScreenSizeAndRotation(currentModeSettings); - for (TInt jj=0,maxjj=rotations->Count();jjSetCurrentRotations(newMode,newOrientation); - TheClient->iWs.Flush(); - - TPixelsAndRotation modeSettings; - TheClient->iScreen->GetDefaultScreenSizeAndRotation(modeSettings); - TRect screenRect(TPoint(0,0),modeSettings.iPixelSize); - - //move the debug windows to inside the area - //actually don't bother yet! - if (screenRect.Width()>screenRect.Height()) - { - } - else - { - } - DeviceResSwitchL(); - } - screen->SetCurrentRotations(newMode,currentModeSettings.iRotation); - screen->SetScreenSizeAndRotation(currentModeSettings); - } - - CleanupStack::PopAndDestroy(); - screen->SetScreenMode(originalScreenMode); - screen->SetCurrentRotations(originalScreenMode,originalModeSettings.iRotation); - screen->SetScreenSizeAndRotation(originalModeSettings); - } - -/** - Intended primarily as a visual check that the mode is displayed correctly, - this code also verifies that the number of physical colours matches the reported mode. - Note that although written to test GCE, this test is general and applies to all display versions. -**/ -void CTScreenDeviceResSwitch::DeviceResSwitchL() - { - INFO_PRINTF1(_L("DeviceResSwitchL: Entering function")); - TInt error = KErrNone; - TInt isTransparencySupportedResult = KErrNone; - - TRAP(error, isTransparencySupportedResult = IsTransparencySupportedL()); - - if(error != KErrNone) - { - INFO_PRINTF1(_L("DeviceResSwitchL: Transparency is not supported. Exits.")); - return; - } - - TRAP(error, CalculateDisplayPropertiesL()); - - if(error != KErrNone) - { - INFO_PRINTF1(_L("DeviceResSwitchL: Could not calculate display properties. Test not supported. Exits.")); - return; - } - - TDisplayMode startDisplayMode = TheClient->iScreen->DisplayMode(); - TInt startColoursPixel = TDisplayModeUtils::NumDisplayModeColors(startDisplayMode); - - TPixelsAndRotation modeSettings; - TheClient->iScreen->GetDefaultScreenSizeAndRotation(modeSettings); - TRect r(TPoint(0, 0), modeSettings.iPixelSize); - - // Starts off full-screen. Only shrink it if it will still be large enough to run the test - // It should be... the test only needs 60x20 pixels - - if(r.Width() > r.Height()) - { - if(r.Width() > (CPrimaryColoursWin::kMinWidth) * (CPrimaryColoursWin::kShrinkFactor-2) * 3 / (CPrimaryColoursWin::kShrinkFactor * 2)) - { - r.iTl.iX = r.iBr.iX / 3; - } - } - else - { - if (r.Height() > (CPrimaryColoursWin::kMinHeight) * (CPrimaryColoursWin::kShrinkFactor - 2) * 3/ (CPrimaryColoursWin::kShrinkFactor * 2)) - { - r.iTl.iY = r.iBr.iY / 3; - } - } - if(r.Width() > (CPrimaryColoursWin::kMinWidth) * (CPrimaryColoursWin::kShrinkFactor - 2) / CPrimaryColoursWin::kShrinkFactor) - { - if(r.Height() > (CPrimaryColoursWin::kMinHeight) * (CPrimaryColoursWin::kShrinkFactor - 2) / CPrimaryColoursWin::kShrinkFactor) - { - r.Shrink(r.Width() / CPrimaryColoursWin::kShrinkFactor, r.Height() / CPrimaryColoursWin::kShrinkFactor); - } - } - - for(TInt i = 0; i < EColorLast; i++) - { - TDisplayMode tryMode = TDisplayMode(i); - TInt tryColoursPixel = NumDisplayModeColors(tryMode); - - INFO_PRINTF3(_L("DeviceResSwitchL: tryColoursPixel = %d, tryMode = %d"), tryColoursPixel, tryMode); - - if(TDisplayModeUtils::IsDisplayModeColor(tryMode) && startColoursPixel <= tryColoursPixel) - { - //Create a test window at this mode, and see if it changes the screen mode - { // The braces define the lifetime of testWin. It must be destroyed before we check if mode changed back successfully. - - CPrimaryColoursWin* testWin1 = new (ELeave) CPrimaryColoursWin; - CleanupStack::PushL(testWin1); - - TInt expectedColoursPerChannel = 1; - TInt tt; - - testWin1->SetUpL(r.iTl, r.Size(), TheClient->iGroup, *TheClient->iGc, &tryMode); - TheClient->iWs.Flush(); - TDisplayMode newDisplayMode = TheClient->iScreen->DisplayMode(); - - TEST(TDisplayModeUtils::NumDisplayModeColors(newDisplayMode) >= tryColoursPixel); - - if(!(TDisplayModeUtils::NumDisplayModeColors(newDisplayMode) >= tryColoursPixel)) - { - ERR_PRINTF3(_L("testWin1: newDisplayMode = %d, tryColoursPixel = %d"), newDisplayMode, tryColoursPixel); - } - - // Estimate the minimum number of shades of primary colours given the bits per pixel. - // The maximum is twice this. Very appoximate but seems to work OK for 256 colours. Probably not good for grey modes. - for(tt = tryColoursPixel; tt >= 8; tt >>= 3) - { - expectedColoursPerChannel <<= 1; - } - - // Draw some test data on the test window. - testWin1->DrawNow(); - TheClient->iWs.Flush(); - -#ifdef VISIBLE_PAUSES - TheClient->StdLogWindow().LogMessage(EFalse, _L("Mode: "), tryMode); - User::After(1000000); -#endif - TInt numUniqueColours = testWin1->CountUniquePlottedColours(); - INFO_PRINTF2(_L("testWin1: numUniqueColours = %d"), numUniqueColours); - testWin1->DrawNow(); - TheClient->StdLogWindow().LogMessage(EFalse, _L("Channel Colours: "), numUniqueColours); - TheClient->iWs.Flush(); - -#ifdef VISIBLE_PAUSES - User::After(1000000); -#endif - // Read it back and see if it has the expected quality - TEST(numUniqueColours >= (expectedColoursPerChannel * 3)); - - if(!(numUniqueColours >= (expectedColoursPerChannel * 3))) - { - ERR_PRINTF3(_L("testWin1: numUniqueColours = %d, (expectedColoursPerChannel * 3) = %d"), numUniqueColours, (expectedColoursPerChannel * 3)); - } - - /* - * Defect 107176 was rejected. This test for transparency is therefore removed. - * - */ - if (false) //newDisplayMode != startDisplayMode) // Hide the window under a startmode window and see if we switch back? - if (isTransparencySupportedResult==KErrNone && newDisplayMode != startDisplayMode) // Hide the window under a startmode window and see if we switch back? - /* - * Defect 107176 was rejected. This test for transparency is therefore removed. - * The crash demonstrated by this code is related to the inconsistant support for origin and scale - * See defect DEF111847 and break request 2226 - */ - if (false) //newDisplayMode != startDisplayMode) // Hide the window under a startmode window and see if we switch back? - { - // Demonstration of defect 107176 - // Create a translucent window which obscures the high-colour window - // The existing code reduces the display colour depth because it thinks the obscured window is not visible any more - // However, the obscured window is actually visible trough the transparency - CPrimaryColoursWin* testWin2 = new (ELeave) CPrimaryColoursWin; - CleanupStack::PushL(testWin2); - - testWin2->SetUpL(r.iTl - TPoint(20,20), r.Size() + TSize(40,40), TheClient->iGroup, *TheClient->iGc, &startDisplayMode, ETrue, 0x80); - TheClient->iWs.Flush(); - testWin2->DrawNow(); - TheClient->iWs.Flush(); - - TDisplayMode newnewDisplayMode = TheClient->iScreen->DisplayMode(); - TInt newNumUniqueColours = testWin2->CountUniquePlottedColours(); - INFO_PRINTF2(_L("testWin2: newNumUniqueColours = %d"), newNumUniqueColours); - - TEST(newnewDisplayMode == newDisplayMode); - - if(!(newnewDisplayMode == newDisplayMode)) - { - ERR_PRINTF3(_L("testWin2: newnewDisplayMode = %d, newDisplayMode = %d"), newnewDisplayMode, newDisplayMode); - } - - testWin2->DrawNow(); - TheClient->iWs.Flush(); - -#ifdef VISIBLE_PAUSES - User::After(1000000); -#endif - TheClient->iWs.Flush(); - - CleanupStack::PopAndDestroy(testWin2); - testWin2 = NULL; - } - - CleanupStack::PopAndDestroy(testWin1); - testWin1 = NULL; - } - - TDisplayMode afterDisplayMode = TheClient->iScreen->DisplayMode(); - TEST(afterDisplayMode == startDisplayMode); - - if(afterDisplayMode != startDisplayMode) - { - ERR_PRINTF3(_L("DeviceResSwitchL: Original colour depth not restored. Was %i, now %i (TDisplayMode)"), startDisplayMode, afterDisplayMode); - } - -#ifdef VISIBLE_PAUSES - User::After(1000000); -#endif - } // context - } // for loop ends - - INFO_PRINTF1(_L("DeviceResSwitchL: Returning from function")); - } - -void CTScreenDeviceResSwitch::CalculateDisplayPropertiesL() - { - INFO_PRINTF1(_L("CalculateDisplayPropertiesL: Entering function")); - - TDisplayMode tryMode = (TDisplayMode) (EColorLast - 1); - TPixelsAndRotation modeSettings; - TheClient->iScreen->GetDefaultScreenSizeAndRotation(modeSettings); - TRect r(TPoint(0, 0), modeSettings.iPixelSize); - - CPrimaryColoursWin* tempWin = new (ELeave) CPrimaryColoursWin; - CleanupStack::PushL(tempWin); - - tempWin->SetUpL(r.iTl, r.Size(), TheClient->iGroup, *TheClient->iGc, &tryMode); - TheClient->iWs.Flush(); - - iMaxDisplayMode = TheClient->iScreen->DisplayMode(); - INFO_PRINTF2(_L("CalculateDisplayPropertiesL: iMaxDisplayMode %d"), iMaxDisplayMode); - iMaxDisplayModeColors = TDisplayModeUtils::NumDisplayModeColors(iMaxDisplayMode); - INFO_PRINTF2(_L("CalculateDisplayPropertiesL: iMaxDisplayModeColors %d"), iMaxDisplayModeColors); - - CleanupStack::PopAndDestroy(tempWin); - INFO_PRINTF1(_L("CalculateDisplayPropertiesL: Returning from function")); - } - -TInt CTScreenDeviceResSwitch::NumDisplayModeColors(TDisplayMode aDispMode) - { - TInt dispModeColors = TDisplayModeUtils::NumDisplayModeColors(aDispMode); - - if(dispModeColors > iMaxDisplayModeColors) - { - return iMaxDisplayModeColors; - } - - return dispModeColors; - } - -TInt CTScreenDeviceResSwitch::IsTransparencySupportedL() - { - INFO_PRINTF1(_L("IsTransparencySupportedL: Entering function")); - // Creates a window and sets the transparency, if this feature - // is not enabled, KErrNotSupported will be returned - const TRgb KTransparencyColor(85,85,85); - RWindow win(TheClient->iWs); - win.Construct(*TheClient->iGroup->GroupWin(), ENullWsHandle); - win.SetExtent(TPoint(0,0), TSize(50,50)); - win.SetRequiredDisplayMode(EColor256); - TInt ret = win.SetTransparencyFactor(KTransparencyColor); - win.Close(); - - if(!ret) - { - INFO_PRINTF1(_L("IsTransparencySupportedL: Transparency is supported")); - } - else - { - INFO_PRINTF1(_L("IsTransparencySupportedL: Transparency is not supported")); - } - - INFO_PRINTF1(_L("IsTransparencySupportedL: Returning from function")); - return ret; - } - -void CTScreenDeviceResSwitch::RunTestCaseL(TInt /*aCurTestCase*/) - { - ((CTScreenDeviceResSwitchStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); - switch(++iTest->iState) - { -/** -@SYMTestCaseID GRAPHICS-WSERV-0440 - -@SYMDEF DEF107176 - -@SYMTestCaseDesc Intended primarily as a visual check that the mode is displayed correctly. Checks correct display mode is set. - The test also verifies that the number of physical colours matches the reported mode. - Note that although written to test GCE, this test is general and applies to all display versions. - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Creates a windows with a higher display mode. Then creates a transparent - window with lower display mode that completely covers the first window. - Checks the display mode is not changed to the lower diplay mode when - the higher display mode window is visible through transparency. - -@SYMTestExpectedResults The higher display mode should still be set after the second window is drawn. -*/ - case 1: - ((CTScreenDeviceResSwitchStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0440")); - iTest->LogSubTest(_L("Device resolution switching")); - DeviceResSwitchL(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0520 - -@SYMTestCaseDesc Test for device switching when mode increased. - -@SYMTestActions Windows are created in increasing modes and pixel colours written and read back. - This code verifies that the mode change actually takes place. - I am using this visually to verify that the new GCE is actually changing the mode. - -**/ - case 2: - ((CTScreenDeviceResSwitchStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0520")); - iTest->LogSubTest(_L("More device resolution switching")); - DeviceResSwitchWithRotationsL(); - break; - default: - ((CTScreenDeviceResSwitchStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - ((CTScreenDeviceResSwitchStep*)iStep)->CloseTMSGraphicsStep(); - TestComplete(); - } - ((CTScreenDeviceResSwitchStep*)iStep)->RecordTestResultL(); - } - -__WS_CONSTRUCT_STEP__(ScreenDeviceResSwitch) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TSCRDEVRESSWITCH.H --- a/windowing/windowserver/tauto/TSCRDEVRESSWITCH.H Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,61 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef __TSCRDEVRESSWITCH_H__ -#define __TSCRDEVRESSWITCH_H__ - -#include -#include "w32std.h" -#include "../tlib/testbase.h" -#include "AUTO.H" -#include "TGraphicsHarness.h" - -class CTScreenDeviceResSwitch : public CTWsGraphicsBase - { -public: - CTScreenDeviceResSwitch(CTestStep* aStep); - ~CTScreenDeviceResSwitch(); - void ConstructL(); - void DeviceResSwitchL(); - void DeviceResSwitchWithRotationsL(); -protected: - virtual void RunTestCaseL(TInt aCurTestCase); -private: - TInt NumDisplayModeColors(TDisplayMode aDispMode); - void CalculateDisplayPropertiesL(); - TInt IsTransparencySupportedL(); -private: - TDisplayMode iMaxDisplayMode; - TInt iMaxDisplayModeColors; - }; - -class CTScreenDeviceResSwitchStep : public CTGraphicsStep - { -public: - CTScreenDeviceResSwitchStep(); -protected: - //from CTGraphicsStep - virtual CTGraphicsBase* CreateTestL(); - }; - -_LIT(KTScreenDeviceResSwitchStep,"TScreenDeviceResSwitch"); - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TSCREENMODEPOSITIONING.CPP --- a/windowing/windowserver/tauto/TSCREENMODEPOSITIONING.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1164 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Test code for screen mode positioning CR -// GT 0164 Uikon: A3.26. IM 9. -// Test code for the positioning part of Change Request PHAR-5SJGAM -// ("Enable screen mode positioning and scaling"). -// Note this feature is also in GT0199 as PREQ673"Screen Positioning". -// Tests screen position being configurable for a screen mode - -// eg it is now possible to set in wsini.ini the position on the -// physical screen where the origin of the screen mode's screen will appear. -// -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include "TSCREENMODEPOSITIONING.H" -#include - -//#define LOGGING on //Uncomment this line to get extra logging useful when there is a tests that fails - -LOCAL_D TSize FullScreenModeSize; -LOCAL_D TDisplayMode ScreenDisplayMode; -LOCAL_D TInt Copy2ndHalfOfScreen; - - -void CBasicWin::Draw() - { - iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - iGc->SetPenStyle(CGraphicsContext::ENullPen); - iGc->SetBrushColor(TRgb(255,0,0)); - TSize winSize=Size(); - iGc->DrawRect(TRect(winSize)); - iGc->SetBrushColor(TRgb(0,221,221)); - iGc->DrawEllipse(TRect(TPoint(winSize.iWidth/2,winSize.iHeight/2),winSize)); - iGc->DrawEllipse(TRect(TPoint(-winSize.iWidth/2,-winSize.iHeight/2),winSize)); - iDrawn=ETrue; - } - -void CSpriteWin::UpdateState(TInt aState) - { - SetState(aState); - DrawNow(); - } - -TPoint CheckSpritePos(233,60); -TPoint CheckSpritePos2(18,60); - -void CSpriteWin::Draw() - { - switch(iState) - { - case 0: - iGc->BitBlt(CheckSpritePos,&iSpriteBitmap); - break; - case 1: - iGc->BitBlt(CheckSpritePos+TPoint(30,30),&iSpriteBitmap); - iGc->BitBlt(CheckSpritePos,&iSpriteBitmap); - break; - case 2: - iGc->BitBlt(CheckSpritePos2+TPoint(-10,40),&iSpriteBitmap); - iGc->BitBlt(CheckSpritePos2+TPoint(-10,20),&iSpriteBitmap); - break; - case 3: - iGc->BitBlt(TPoint(),&iSpriteBitmap); - break; - default: - break; - } - } - -CSpriteWin::~CSpriteWin() - { - } - -void CBmpWin::Draw() - { - iGc->BitBlt(TPoint(),&iScreenBmp); - } - -CConnection2::~CConnection2() - { - delete iScreenBitmap; - delete iBitmapWin; - delete iSpriteWin; - iGroup->GroupWin()->EnableReceiptOfFocus(EFalse); - delete iGroup; - delete iClient; - } - -void CConnection2::ConstructL(CTestBase *aTest,CFbsBitmap& aBitmap) - { - iClient=new(ELeave) CTClient; - iClient->SetScreenNumber(aTest->ScreenNumber()); - iClient->ConstructL(); - iGroup=new(ELeave) CConnection2Group(iClient,this,aTest); - iGroup->ConstructL(); - iGroup->GroupWin()->EnableScreenChangeEvents(); - iClient->Flush(); - iSpriteWin=new(ELeave) CSpriteWin(aBitmap); - iSpriteWin->ConstructExtLD(*iGroup,TPoint(),TSize(433,240)); - User::LeaveIfError(iSpriteWin->BaseWin()->SetRequiredDisplayMode(EColor256)); - iSpriteWin->AssignGC(*iClient->iGc); - iSpriteWin->Activate(); - iSpriteWin->SetVisible(EFalse); - iSpriteWin->BaseWin()->SetShadowDisabled(ETrue); - iSpriteWin->BaseWin()->SetShadowHeight(0); - iScreenBitmap=new(ELeave) CFbsBitmap(); - User::LeaveIfError(iScreenBitmap->Create(TSize(FullScreenModeSize.iWidth/2,FullScreenModeSize.iHeight), ScreenDisplayMode)); - iBitmapWin=new(ELeave) CBmpWin(*iScreenBitmap); - iBitmapWin->ConstructExtLD(*iGroup,TPoint(FullScreenModeSize.iWidth/2,0),iScreenBitmap->SizeInPixels()); - User::LeaveIfError(iBitmapWin->BaseWin()->SetRequiredDisplayMode(EColor256)); - iBitmapWin->AssignGC(*iClient->iGc); - iBitmapWin->Activate(); - iBitmapWin->SetVisible(EFalse); - iBitmapWin->BaseWin()->SetShadowDisabled(ETrue); - iBitmapWin->BaseWin()->SetShadowHeight(0); - } - -void CConnection2::DrawBitmapWin() - { - TPoint pos=(Copy2ndHalfOfScreen? TPoint() : TPoint(FullScreenModeSize.iWidth/2,0)); - iBitmapWin->SetPos(pos); - iBitmapWin->SetVisible(ETrue); - iBitmapWin->DrawNow(); - iClient->Flush(); - } - -CConnection2Group::CConnection2Group(CTClient *aClient, CConnection2 *aSecondConnection, CTestBase *aTest) : CTWindowGroup(aClient), iTest(aTest), iConnection2(aSecondConnection) - {} - - - - -//CTScreenModePositioning -CTScreenModePositioning::CTScreenModePositioning(CTestStep* aStep) : CTWsGraphicsBase(aStep) - { - } - - -CTScreenModePositioning::~CTScreenModePositioning() - { - delete iTestWin; - delete iConnection2; - delete iBlankWin; - delete iBackedUpWin; - delete iTestChildWin; - } - -void CTScreenModePositioning::ConstructL() - { - User::LeaveIfError(iSpriteBitmap.Load(TEST_BITMAP_NAME,0)); - iScalingSupported=CheckScalingSupportedOrNot(); - TheClient->iScreen->SetScreenMode(TheClient->iScreenModes[0]); - FullScreenModeSize=TheClient->iScreen->SizeInPixels(); - ScreenDisplayMode=TheClient->iScreen->DisplayMode(); - iConnection2=new(ELeave) CConnection2; - iConnection2->ConstructL(iTest,iSpriteBitmap); - iBlankWin=new(ELeave) CTBlankWindow(); - iBlankWin->ConstructL(*TheClient->iGroup); - User::LeaveIfError(iBlankWin->BaseWin()->SetRequiredDisplayMode(EColor256)); - iBlankWin->SetExt(TPoint(),FullScreenModeSize); - iBlankWin->SetVisible(EFalse); - iBlankWin->Activate(); - iTestWin=new(ELeave) CBasicWin; - iTestWin->ConstructExtLD(*TheClient->iGroup,TPoint(),FullScreenModeSize); - User::LeaveIfError(iTestWin->BaseWin()->SetRequiredDisplayMode(EColor256)); - iTestWin->AssignGC(*TheClient->iGc); - iTestWin->BaseWin()->SetShadowDisabled(ETrue); - iTestWin->BaseWin()->SetShadowHeight(0); - iTestWin->SetVisible(EFalse); - iTestWin->Activate(); - iBackedUpWin=new(ELeave) CTBackedUpWin(EColor256); - iBackedUpWin->ConstructExtLD(*iTestWin,TPoint(),FullScreenModeSize); - iBackedUpWin->SetVisible(EFalse); - iBackedUpWin->Activate(); - iTestChildWin=new(ELeave) CTBlankWindow(); - iTestChildWin->ConstructL(*iTestWin); - User::LeaveIfError(iTestChildWin->BaseWin()->SetRequiredDisplayMode(EColor256)); - iTestChildWin->BaseWin()->SetShadowDisabled(ETrue); - iTestChildWin->SetColor(KRgbGreen); - iTestChildWin->BaseWin()->SetVisible(EFalse); - iTestChildWin->Activate(); - //The Cursor appearing on screen will affect the result of RectCompare function. - //Set it to the position out of the screen - TheClient->iWs.SetPointerCursorPosition(TPoint(-1,-1)); - } - -void CTScreenModePositioning::ChangeScreenMode(CTClient* aClient,TPixelsAndRotation aPixelsAndRotation,TInt aMode) - { - ChangeScreenMode(aClient,aPixelsAndRotation,ESizeEnforcementNone,aMode); - } - -void CTScreenModePositioning::ChangeScreenMode(CTClient* aClient,TPixelsAndRotation aPixelsAndRotation,TScreenModeEnforcement aScreenModeEnforcement,TInt aMode) - { - aClient->iScreen->SetScreenSizeAndRotation(aPixelsAndRotation); - aClient->iScreen->SetScreenModeEnforcement(aScreenModeEnforcement); - aClient->iScreen->SetScreenMode(aMode); - } - -void CTScreenModePositioning::SetScreenMode(CTClient* aClient,TInt aMode,TScreenModeEnforcement aScreenModeEnforcement) - { - TPixelsAndRotation pixelsAndRotation; - aClient->iScreen->SetScreenModeEnforcement(aScreenModeEnforcement); - aClient->iScreen->SetScreenMode(aMode); - aClient->iScreen->GetDefaultScreenSizeAndRotation(pixelsAndRotation); - aClient->iScreen->SetScreenSizeAndRotation(pixelsAndRotation); - aClient->Flush(); - } - -void CTScreenModePositioning::SetUpSpriteLC(RWsSprite &aSprite, RWsSession &aSession, RWindowTreeNode &aWindow,TInt aFlags) - { - aSprite=RWsSprite(aSession); - User::LeaveIfError(aSprite.Construct(aWindow,TPoint(),aFlags)); - CleanupClosePushL(aSprite); - TSpriteMember member; - iTest->SetUpMember(member); - member.iBitmap=&iSpriteBitmap; - User::LeaveIfError(aSprite.AppendMember(member)); - User::LeaveIfError(aSprite.Activate()); - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-0098 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Window Tests. Please see test cases GRAPHICS-WSERV-(0099-0103) which are a subset of this test case. - REQUIREMENT: CR PHAR-5SJGAM, PREQ673 - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Tests on windows in different screen modes each with differing screen mode origin's defined in the - wsini file. This test case only tests screen modes with 0 orientation. - Goes through each screen mode defined in the wsini file and exercises test cases GRAPHICS-WSERV-(0099-0103) for each mode. - For more details see test cases GRAPHICS-WSERV-(0099-0103) which are a subset of this test case. - -@SYMTestExpectedResults - -*/ -void CTScreenModePositioning::WindowTestsL() - { - TheClient->iGroup->GroupWin()->EnableScreenChangeEvents(); - TInt numOfModes=TheClient->iScreenModes.Count(); - TInt ii; - for (ii=0; iiiScreenModes[ii]; - TPixelsAndRotation pixelsAndRotation; - iCurrentScreenModeOrigin=TheClient->iScreen->GetScreenModeScaledOrigin(iCurrentMode); - iCurrentScreenModeScale=TheClient->iScreen->GetScreenModeScale(iCurrentMode); - TheClient->iScreen->GetScreenModeSizeAndRotation(iCurrentMode,pixelsAndRotation); - iCurrentScreenModeSize=pixelsAndRotation.iPixelSize; - if (iCurrentScreenModeOrigin.iX<=FullScreenModeSize.iWidth/2-10 /*&& iCurrentScreenModeOrigin!=TPoint() */&& pixelsAndRotation.iRotation==CFbsBitGc::EGraphicsOrientationNormal) - { - #if defined(LOGGING) - _LIT(KLog,"Test mode %d"); - LOG_MESSAGE2(KLog,ii); - #endif - TRAPD(ret,DoWindowTestsL()); - if (ret==KErrNone) - continue; - RestoreScreenMode(); - if (retSetVisible(ETrue); - Copy2ndHalfOfScreen=(iCurrentScreenModeOrigin.iX>FullScreenModeSize.iWidth/2? 1 : 0); - TInt testWinWidth=Max(FullScreenModeSize.iWidth/2-iCurrentScreenModeOrigin.iX,iCurrentScreenModeOrigin.iX-FullScreenModeSize.iWidth/2); - iTestWinSize=TSize(testWinWidth,FullScreenModeSize.iHeight-iCurrentScreenModeOrigin.iY-60); - iTestWinSize.iWidth/=(iCurrentScreenModeScale.iWidth > 1 ? iCurrentScreenModeScale.iWidth*2 : iCurrentScreenModeScale.iWidth); - iTestWinSize.iHeight/=(iCurrentScreenModeScale.iHeight > 1 ? iCurrentScreenModeScale.iHeight*2 : iCurrentScreenModeScale.iHeight); -#if defined(LOGGING) - _LIT(KLog1," PosTest1"); - LOG_MESSAGE(KLog1); -#endif - PositionTest1L(TPoint()); -#if defined(LOGGING) - _LIT(KLog2," PosTest2"); - LOG_MESSAGE(KLog2); -#endif - PositionTest1L(TPoint(25,35)); -#if defined(LOGGING) - _LIT(KLog3," PosTest3"); - LOG_MESSAGE(KLog3); -#endif - PositionTest2L(TPoint(10,10)); -#if defined(LOGGING) - _LIT(KLog4," GetInvalidRegion"); - LOG_MESSAGE(KLog4); -#endif - GetInvalidRegionTestL(TPoint(10,10)); -#if defined(LOGGING) - _LIT(KLog5," CreateWin1"); - LOG_MESSAGE(KLog5); -#endif - CreateWindowsTestL(TPoint()); -#if defined(LOGGING) - _LIT(KLog6," CreateWin2"); - LOG_MESSAGE(KLog6); -#endif - CreateWindowsTestL(TPoint(33,15)); -#if defined(LOGGING) - _LIT(KLog7," NextMode"); - LOG_MESSAGE(KLog7); -#endif - NextScreenModeTestL(TPoint(12,6)); - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-0099 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Position Test 1 - REQUIREMENT: CR PHAR-5SJGAM, PREQ673 - API: RWindowBase::InquireOffset(), RWindowBase::AbsPosition(),RWindowBase::Position() - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Sets the new screen mode on the main client's screen device. Checks that an window whose group window - has this screen device is in the correct position and for the origin of the new screen mode. - (Does this by copying the window to a bitmap, switching back to screen mode 0 and then setting the position - of the window to be the expected position. Then the bitmap is blitted to the other half of the screen and the - 2 halves of the screen compared) - -@SYMTestExpectedResults Checks the window is positioned correctly for the origin of the new screen mode. - -*/ -void CTScreenModePositioning::PositionTest1L(TPoint aPos) - { - ((CTScreenModePositioningStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0099")); - SetScreenMode(TheClient,iCurrentMode,ESizeEnforcementPixelsAndRotation); - iTestWin->SetExt(aPos,iTestWinSize); - iTestWin->SetVisible(ETrue); - iTestWin->Invalidate(); - TheClient->Flush(); - TestTopClientWindowPositionAPIs(aPos,iTestWin->BaseWin()); - TheClient->WaitForRedrawsToFinish(); - CopyAndCompareL(aPos); - ((CTScreenModePositioningStep*)iStep)->RecordTestResultL(); - } - -template -class TCleanupSetVisible:public TCleanupItem - { - static void Cleanup(void*v) - { - ((CTWinBase*)v)[0].SetVisible(newstate); - } - public: - TCleanupSetVisible(CTWinBase* v): - TCleanupItem(Cleanup,v) - {} - }; - - -/** -@SYMTestCaseID GRAPHICS-WSERV-0100 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Position Test 2 - REQUIREMENT: CR PHAR-5SJGAM, PREQ673 - API: RWindowBase::SetPosition(),RWindowBase::InquireOffset(), RWindowBase::AbsPosition(),RWindowBase::Position() - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions As in test case GRAPHICS-WSERV-0099 but also tests moving and resizing the window and also does these tests on a backed up child window. - -@SYMTestExpectedResults Checks both the windows are positioned correctly for the origin of the new screen mode. - -*/ -void CTScreenModePositioning::PositionTest2L(TPoint aPos) - { - ((CTScreenModePositioningStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0100")); - SetScreenMode(TheClient,iCurrentMode,ESizeEnforcementPixelsAndRotation); - iTestWin->SetPos(aPos); - - CleanupStack::PushL(TCleanupSetVisible(iBackedUpWin)); - iTestWin->SetVisible(ETrue); - TestTopClientWindowPositionAPIs(aPos,iTestWin->BaseWin()); - TPoint backedUpWinPt=TPoint(iTestWinSize.iWidth/3,iTestWinSize.iHeight/4); - iBackedUpWin->SetExtL(backedUpWinPt,TSize(iTestWinSize.iWidth/6,iTestWinSize.iHeight/6)); - iBackedUpWin->SetVisible(ETrue); - TestChildWindowPositionAPIs(backedUpWinPt,aPos,iBackedUpWin->BaseWin(),iTestWin->BaseWin()); - aPos+=TPoint(20,20); - iTestWin->SetPos(aPos); - TestTopClientWindowPositionAPIs(aPos,iTestWin->BaseWin()); - TestChildWindowPositionAPIs(backedUpWinPt,aPos,iBackedUpWin->BaseWin(),iTestWin->BaseWin()); - iTestWin->Invalidate(); - TheClient->Flush(); - TheClient->WaitForRedrawsToFinish(); - TestTopClientWindowPositionAPIs(aPos,iTestWin->BaseWin()); - TestChildWindowPositionAPIs(backedUpWinPt,aPos,iBackedUpWin->BaseWin(),iTestWin->BaseWin()); - CopyAndCompareL(aPos); - CleanupStack::PopAndDestroy(iBackedUpWin); //TCleanupSetVisible - ((CTScreenModePositioningStep*)iStep)->RecordTestResultL(); - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-0101 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Invalid Region Test - REQUIREMENT: CR PHAR-5SJGAM, PREQ673 - API: RWindow::GetInvalidRegion() - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Sets the new screen mode, then invalidates different parts of the test window. Checks that the above API gets - the correct invalid area from the server. Also tests moving the invalid area. - -@SYMTestExpectedResults Checks the invalid region is correct for the origin of the new screen mode. - -*/ -void CTScreenModePositioning::GetInvalidRegionTestL(TPoint aPos) - { - ((CTScreenModePositioningStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0101")); - SetScreenMode(TheClient,iCurrentMode,ESizeEnforcementPixelsAndRotation); - iTestWin->SetExt(aPos,iTestWinSize); - iTestWin->SetVisible(ETrue); - iTestChildWin->SetExt(TPoint(iTestWinSize.iWidth>>2,iTestWinSize.iHeight>>2),TSize(iTestWinSize.iWidth>>1,iTestWinSize.iHeight>>1)); - iTestChildWin->SetVisible(ETrue); - iTestWin->Win()->BeginRedraw(); - iTestWin->Win()->EndRedraw(); - const TInt KNumRects=3; - TRect rects[KNumRects]; - rects[0]=TRect(1,1,5,2); - rects[1]=TRect(TPoint(iTest->StdTestWindowSize().iWidth>>1,iTest->StdTestWindowSize().iHeight>>1),iTest->StdTestWindowSize()); - rects[2]=TRect(2,0,4,5); - RRegion region; - CleanupClosePushL(region); - for (TInt index=0;indexInvalidate(rects[index]); - region.AddRect(rects[index]); - } - //PeterI original wserv assumes a region hidden beneath a child is not invalid - //Mk3 doesn't make this assumption - //TRect subRect; - //subRect.iTl=iTestChildWin->BaseWin()->InquireOffset(*iTestWin->BaseWin()); - //subRect.SetSize(iTestChildWin->Size()); - //region.Tidy(); - //region.SubRect(subRect); - //region.ClipRect(TRect(iTestWin->Size())); - RRegion invalidRegion; - CleanupClosePushL(invalidRegion); - iTestWin->Win()->GetInvalidRegion(invalidRegion); - CompareRegionsL(region,invalidRegion); - CleanupStack::PopAndDestroy(2,®ion); - TheClient->Flush(); - TheClient->WaitForRedrawsToFinish(); - iTestChildWin->SetVisible(EFalse); - TRect rect1(TPoint(0,0),iTestWinSize); - TestGetInvalidRegionL(rect1); - TInt width=iTestWinSize.iWidth; - TInt height=iTestWinSize.iHeight; - TRect rect2(TPoint(width/6,height/6),TSize(width/3,height/3)); - TestGetInvalidRegionL(rect2); - iTestWin->Invalidate(); - iTestWin->SetPos(TPoint(15,15)); - iTestWin->SetPos(TPoint()); - iTestWin->SetPos(TPoint(-15,-15)); - iTestWin->SetPos(aPos); - RRegion invalid; - RRegion testRegion(rect1); - CleanupClosePushL(invalid); - CleanupClosePushL(testRegion); - iTestWin->Win()->GetInvalidRegion(invalid); - TBool err=invalid.CheckError(); - TEST(!err); - if (err) - { - _LIT(KLog,"Returned Invalid Region has an error"); - LOG_MESSAGE(KLog); - } - - TEST(invalid.BoundingRect().iBr.iX<=iTestWinSize.iWidth); - if (invalid.BoundingRect().iBr.iX>iTestWinSize.iWidth) - { - _LIT(KLog,"Invalid Region extends beyond right edge of window"); - LOG_MESSAGE(KLog); - } - - CompareRegionsL(testRegion,invalid); - CleanupStack::PopAndDestroy(2,&invalid); - iTestWin->DrawNow(); - TheClient->Flush(); - CopyAndCompareL(aPos); - ((CTScreenModePositioningStep*)iStep)->RecordTestResultL(); - } - -void CTScreenModePositioning::CopyAndCompareL(TPoint aPos) - { - CopyScreenAndChangeBackToDefScrModeL(); - iTestWin->SetPos(iCurrentScreenModeOrigin+aPos); - iConnection2->DrawBitmapWin(); - TheClient->WaitForRedrawsToFinish(); - TestRect(); - iConnection2->BitmapWin()->SetVisible(EFalse); - iTestWin->SetVisible(EFalse); - } - -void CTScreenModePositioning::TestGetInvalidRegionL(TRect& aRect) - { - RRegion testRegion; - RRegion invalid; - iTestWin->Invalidate(aRect); - testRegion.AddRect(aRect); - iTestWin->Win()->GetInvalidRegion(invalid); - CompareRegionsL(testRegion,invalid); - invalid.Close(); - testRegion.Close(); - TheClient->Flush(); - TheClient->WaitForRedrawsToFinish(); - } - -void CTScreenModePositioning::CompareRegionsL(const TRegion &aRegion1,const TRegion &aRegion2) - { - _LIT(KLog,"Regions do not contain same area."); - RRegion tmp; - tmp.Copy(aRegion1); - tmp.SubRegion(aRegion2); - if (tmp.CheckError()) - User::Leave(KErrNoMemory); - TBool retVal1=tmp.IsEmpty(); - TEST(retVal1); - if (!retVal1) - LOG_MESSAGE(KLog); - - tmp.Copy(aRegion2); - tmp.SubRegion(aRegion1); - if (tmp.CheckError()) - User::Leave(KErrNoMemory); - TBool retVal2=tmp.IsEmpty(); - TEST(retVal2); - if (!retVal2 && retVal1) - LOG_MESSAGE(KLog); - - tmp.Close(); - } - -void CTScreenModePositioning::TestTopClientWindowPositionAPIs(TPoint aPos,RWindowBase* aWin) - { - TEST(aWin->AbsPosition()==aPos); - TEST(aWin->Position()==aPos); - TEST(aWin->InquireOffset(*TheClient->iGroup->GroupWin())==aPos); - } - -void CTScreenModePositioning::TestChildWindowPositionAPIs(TPoint aPos,TPoint aParentPos,RWindowBase* aWin,RWindowBase* aParentWin) - { - TEST(aWin->AbsPosition()==aParentPos+aPos); - TEST(aWin->Position()==aPos); - TEST(aWin->InquireOffset(*TheClient->iGroup->GroupWin())==aParentPos+aPos); - TEST(aWin->InquireOffset(*aParentWin)==aPos); - } - -void CTScreenModePositioning::RestoreScreenMode() - { - TPixelsAndRotation pixelsAndRotation; - pixelsAndRotation.iPixelSize=FullScreenModeSize; - TheClient->iScreen->GetDefaultScreenSizeAndRotation(pixelsAndRotation); - ChangeScreenMode(TheClient,pixelsAndRotation,ESizeEnforcementNone,TheClient->iScreenModes[0]); - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-0102 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Create Windows Test - REQUIREMENT: CR PHAR-5SJGAM, PREQ673 - API: RWindowBase::SetPosition(),RWindowBase::InquireOffset(), RWindowBase::AbsPosition(),RWindowBase::Position() - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions As in test case GRAPHICS-WSERV-0100 but tests windows that are created in the new screen mode. Also tests moving and resizing these windows - -@SYMTestExpectedResults Checks both the windows are positioned correctly for the origin of the new screen mode. - -*/ -void CTScreenModePositioning::CreateWindowsTestL(TPoint aPos) - { - ((CTScreenModePositioningStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0102")); - SetScreenMode(TheClient,iCurrentMode,ESizeEnforcementPixelsAndRotation); - CBasicWin* basicWin=new(ELeave) CBasicWin; - basicWin->ConstructExtLD(*TheClient->iGroup,aPos,iTestWinSize); - CleanupStack::PushL(basicWin); - TInt mode=basicWin->BaseWin()->SetRequiredDisplayMode(EColor256); - basicWin->AssignGC(*TheClient->iGc); - basicWin->BaseWin()->SetShadowDisabled(ETrue); - basicWin->BaseWin()->SetShadowHeight(0); - basicWin->Activate(); - TheClient->Flush(); - TheClient->WaitForRedrawsToFinish(); - TestTopClientWindowPositionAPIs(aPos,basicWin->BaseWin()); - CTBlankWindow* blankChildWin=new(ELeave) CTBlankWindow ; - CleanupStack::PushL(blankChildWin); - blankChildWin->ConstructL(*basicWin); - blankChildWin->BaseWin()->SetRequiredDisplayMode(EColor256); - blankChildWin->BaseWin()->SetShadowDisabled(ETrue); - blankChildWin->SetColor(KRgbYellow); - TPoint childPos(iTestWinSize.iWidth/4,iTestWinSize.iHeight/4); - blankChildWin->SetExtL(childPos,TSize(iTestWinSize.iWidth/2,iTestWinSize.iHeight/2)); - blankChildWin->Activate(); - TheClient->Flush(); - TheClient->WaitForRedrawsToFinish(); - TestChildWindowPositionAPIs(childPos,aPos,blankChildWin->BaseWin(),basicWin->BaseWin()); - blankChildWin->SetPos(TPoint(-15,-20)); - TheClient->Flush(); - basicWin->DrawNow(); - TestChildWindowPositionAPIs(TPoint(-15,-20),aPos,blankChildWin->BaseWin(),basicWin->BaseWin()); - CopyScreenAndChangeBackToDefScrModeL(); - basicWin->SetPos(iCurrentScreenModeOrigin+aPos); - iConnection2->DrawBitmapWin(); - TheClient->WaitForRedrawsToFinish(); - TestRect(); - iConnection2->BitmapWin()->SetVisible(EFalse); - iTestWin->SetVisible(EFalse); - CleanupStack::PopAndDestroy(blankChildWin); - CleanupStack::PopAndDestroy(basicWin); - ((CTScreenModePositioningStep*)iStep)->RecordTestResultL(); - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-0103 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Changing to next screen mode - REQUIREMENT: CR PHAR-5SJGAM, PREQ673 - API: RWindowBase::SetPosition(),RWindowBase::InquireOffset(), RWindowBase::AbsPosition(),RWindowBase::Position() - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Sets the new screen mode, creates a new child window and then changes to the next screen mode with non-zero origin, - checks windows are in the expected position for the origin of the new screen mode. - -@SYMTestExpectedResults Checks both the windows are positioned correctly for the origin of the new screen mode. - -*/ -void CTScreenModePositioning::NextScreenModeTestL(TPoint aPos) - { - ((CTScreenModePositioningStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0103")); - if (iCurrentScreenModeOrigin==TPoint()) - { - return; - } - TInt numOfModes=TheClient->iScreenModes.Count(); - TInt defaultMode=TheClient->iScreenModes[0]; - TInt lastMode=TheClient->iScreenModes[numOfModes-1]; - TInt mode=(iCurrentModeiScreenModes[ii]) - { - modeIdx=ii; - break; - } - } - TPoint screenModeOrigin(0,0); - TPixelsAndRotation pixelsAndRotation; - while (screenModeOrigin==TPoint()||(pixelsAndRotation.iRotation!=CFbsBitGc::EGraphicsOrientationNormal)) - { - mode=(mode==lastMode? defaultMode : TheClient->iScreenModes[++modeIdx]); - if (mode==iCurrentMode) - { - return; - } - else if (mode==lastMode) - { - modeIdx=0; - } - screenModeOrigin=TheClient->iScreen->GetScreenModeOrigin(mode); - TheClient->iScreen->GetScreenModeSizeAndRotation(mode,pixelsAndRotation); - } - SetScreenMode(TheClient,iCurrentMode,ESizeEnforcementPixelsAndRotation); - iTestWin->SetExt(aPos,iTestWinSize); - iTestWin->SetVisible(ETrue); - TheClient->Flush(); - CBasicWin* basicWin=new(ELeave) CBasicWin; - CleanupStack::PushL(basicWin); - basicWin->ConstructExtLD(*iTestWin,TPoint(),TSize(iTestWinSize.iWidth/5,iTestWinSize.iHeight/5)); - User::LeaveIfError(basicWin->BaseWin()->SetRequiredDisplayMode(EColor256)); - basicWin->AssignGC(*TheClient->iGc); - basicWin->BaseWin()->SetShadowDisabled(ETrue); - basicWin->BaseWin()->SetShadowHeight(0); - basicWin->Activate(); - TPoint pos(iTestWinSize.iWidth/3,iTestWinSize.iWidth/4); - basicWin->SetPos(pos); - TheClient->Flush(); - TheClient->WaitForRedrawsToFinish(); - TestChildWindowPositionAPIs(pos,aPos,basicWin->BaseWin(),iTestWin->BaseWin()); - iCurrentScreenModeScale=TheClient->iScreen->GetScreenModeScale(mode); - iCurrentScreenModeOrigin=TheClient->iScreen->GetScreenModeOrigin(mode); - iTestWinSize.iWidth/=(iCurrentScreenModeScale.iWidth > 1 ? iCurrentScreenModeScale.iWidth*2 : iCurrentScreenModeScale.iWidth); - iTestWinSize.iHeight/=(iCurrentScreenModeScale.iHeight > 1 ? iCurrentScreenModeScale.iHeight*2 : iCurrentScreenModeScale.iHeight); - iTestWin->SetExt(aPos,iTestWinSize); - SetScreenMode(TheClient,mode,ESizeEnforcementPixelsAndRotation); - CopyScreenAndChangeBackToDefScrModeL(); - iTestWin->SetPos(aPos+iCurrentScreenModeOrigin); - basicWin->SetPos(pos); - iConnection2->DrawBitmapWin(); - TestRect(); - iConnection2->BitmapWin()->SetVisible(EFalse); - iTestWin->SetVisible(EFalse); - CleanupStack::PopAndDestroy(basicWin); - iCurrentScreenModeOrigin=TheClient->iScreen->GetScreenModeOrigin(iCurrentMode); - ((CTScreenModePositioningStep*)iStep)->RecordTestResultL(); - } - -void CTScreenModePositioning::CopyScreenAndChangeBackToDefScrModeL() - { - // clear the content of bitmap before it is used for copying - ClearBitmap(iConnection2->iScreenBitmap); - - // Copy the current content of the screen before moving to screen sizemode 0. - if (!iScalingSupported) - { - TPoint pt=(Copy2ndHalfOfScreen? TPoint(FullScreenModeSize.iWidth/2,0) : TPoint()); - User::LeaveIfError(iConnection2->iClient->iScreen->CopyScreenToBitmap(iConnection2->iScreenBitmap,TRect(pt,TSize(FullScreenModeSize.iWidth/2,FullScreenModeSize.iHeight)))); - } - else - { - TPoint pt=(Copy2ndHalfOfScreen? TPoint((iCurrentScreenModeSize.iWidth+iCurrentScreenModeOrigin.iX)/2,0) : -iCurrentScreenModeOrigin); - TPoint ptBottom(FullScreenModeSize.iWidth/2,FullScreenModeSize.iHeight); - ptBottom-=iCurrentScreenModeOrigin; - ptBottom.iX=(ptBottom.iX>=0 ? ptBottom.iX/iCurrentScreenModeScale.iWidth : ((-ptBottom.iX)*iCurrentScreenModeScale.iWidth+ptBottom.iX)/iCurrentScreenModeScale.iWidth+ptBottom.iX); - ptBottom.iY=(ptBottom.iY>=0 ? ptBottom.iY/iCurrentScreenModeScale.iHeight : ((-ptBottom.iY)*iCurrentScreenModeScale.iHeight+ptBottom.iY)/iCurrentScreenModeScale.iHeight+ptBottom.iY); - User::LeaveIfError(iConnection2->iClient->iScreen->CopyScreenToBitmap(iConnection2->iScreenBitmap,TRect(pt,ptBottom))); - } - TheClient->Flush(); - SetScreenMode(TheClient,TheClient->iScreenModes[0],ESizeEnforcementPixelsAndRotation); - TPixelsAndRotation dummySize; - dummySize.iPixelSize=TSize(0,0); - iConnection2->iClient->iScreen->SetScreenSizeAndRotation(dummySize); //to force an update in the server when we do the next line - TPixelsAndRotation pixelsAndRotation; - TheClient->iScreen->GetDefaultScreenSizeAndRotation(pixelsAndRotation); - iConnection2->iClient->iScreen->SetScreenSizeAndRotation(pixelsAndRotation); - iConnection2->iClient->iScreen->SetScreenModeEnforcement(ESizeEnforcementPixelsAndRotation); - iConnection2->iClient->iScreen->SetScreenMode(TheClient->iScreenModes[0]); - } - -TBool CTScreenModePositioning::TestRect() - { - TSize size(FullScreenModeSize.iWidth/2,FullScreenModeSize.iHeight); - TRect right(TPoint(FullScreenModeSize.iWidth/2,0),size); - TBool retVal=TheClient->iScreen->RectCompare(TRect(size),right); -// User::After(2000000); - //Let the pixels cool down for a bit - User::After(10); - TEST(retVal); - if(!retVal) - { - _LIT(KLog,"Left and Right halves of display don't match. RightHalf=(%d,%d,%d,%d)"); - LOG_MESSAGE5(KLog,right.iTl.iX,right.iTl.iY,right.iBr.iX,right.iBr.iY); - } - return retVal; - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-0104 - -@SYMDEF DEF081259, DEF111847 - -@SYMTestCaseDesc Sprite Tests - REQUIREMENT: CR PHAR-5SJGAM, PREQ673 - API: RWsSprite::SetPosition() - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Test sprites associated with group windows in screen modes with non-zero origin: - Sets such a new screen mode and creates 2 sprites. - compares these sprites with some blitted onto the screen in the expected position. - Sets the rotation of screen mode to be 180 deg, sets the position of the sprites - and does the same as above to compare expected position. - Then changes back to screen mode 0 and sets a new positions of the sprites,changes to the new - screen mode and checks the sprites have been moved to the correct position. - Additionally, as part of defect fix DEF111847, this also loops through all display modes above and including Color256, - and if possible tests each with the above described method. Previously, it use to only test Color256. - Display modes lower than EColor256 are not tested as they are not supported for origin change. - -@SYMTestExpectedResults Checks the sprites are positioned correctly according to the origin - of the new screen mode. - -*/ -void CTScreenModePositioning::SpriteTestL() - { - -#if defined(__WINS__) - TBool retVal; - if (iScalingSupported) - { - TDisplayMode curDispMode; // Holds the current display mode being tested - - for(curDispMode = EColor256; curDispMode < EColorLast; curDispMode = TDisplayMode(curDispMode+1)) - { - if (curDispMode == ERgb) - { - continue; - } - // Set screen mode to 3 - iCurrentMode=3; - SetScreenMode(TheClient,iCurrentMode,ESizeEnforcementPixelsAndRotation); - TPoint topLeft(-TheClient->iScreen->GetScreenModeOrigin(iCurrentMode)); - TPoint botRight(TheClient->iScreen->SizeInPixels().AsPoint()); - - // Create a sprite at position (0,0) from current origin - RWsSprite sprite; - TSize spriteSize=iSpriteBitmap.SizeInPixels(); - SetUpSpriteLC(sprite,TheClient->iWs,*iBlankWin->BaseWin()); - TPoint winPos; - if (botRight.iXBaseWin()->SetPosition(winPos); - } - - // Now create a spritewin at top left of the visible screen - CSpriteWin* spriteWin=new(ELeave) CSpriteWin(iSpriteBitmap); - CleanupStack::PushL(spriteWin); - spriteWin->ConstructExtLD(*TheClient->iGroup,topLeft,spriteSize); - - // Set the display mode of the base window - TInt setBlankWinDispMode = iBlankWin->BaseWin()->SetRequiredDisplayMode(curDispMode); - // Set the display mode of the sprite window - TInt setSpriteWinDispMode = spriteWin->BaseWin()->SetRequiredDisplayMode(curDispMode); - - //Only do the tests if the requested mode was actually set on both windows - if(curDispMode == setBlankWinDispMode && curDispMode == setSpriteWinDispMode) - { - //Create and show DisplayMode details message - _LIT(KModeDetails, "Display Mode: "); - TBuf<30> modeDetailsMessage(KModeDetails); - modeDetailsMessage.Append(DisplayModeAsString(curDispMode)); - LOG_MESSAGE(modeDetailsMessage); - - spriteWin->AssignGC(*TheClient->iGc); - spriteWin->SetState(3); - spriteWin->Activate(); - spriteWin->DrawNow(); - TheClient->WaitForRedrawsToFinish(); - retVal=TheClient->iScreen->RectCompare(TRect(topLeft,spriteSize),TRect(winPos,spriteSize),CWsScreenDevice::EIncludeSprite); - TEST(retVal); - if(!retVal) - { - _LIT(KLog,"Initial Drawing of sprite fails - does not compare to same bitmap drawn in window."); - LOG_MESSAGE(KLog); - } - - // Move position of the window and sprite and then test - TPoint spritePos(Min(20,botRight.iX-spriteSize.iWidth-winPos.iX),20); - spriteWin->SetExt(topLeft+spritePos,spriteSize); - sprite.SetPosition(spritePos); - spriteWin->DrawNow(); - TheClient->WaitForRedrawsToFinish(); - retVal=TheClient->iScreen->RectCompare(TRect(topLeft+spritePos,spriteSize),TRect(winPos+spritePos,spriteSize),CWsScreenDevice::EIncludeSprite); - TEST(retVal); - if(!retVal) - { - _LIT(KLog,"Second position of sprite fails - does not compare to same bitmap drawn in window."); - LOG_MESSAGE(KLog); - } - iBlankWin->BaseWin()->SetPosition(TPoint()); - - // Now test the same by moving into other screen mode - iCurrentMode=4; - SetScreenMode(TheClient,iCurrentMode,ESizeEnforcementNone); - spritePos.SetXY(0,160); - sprite.SetPosition(spritePos); - spriteWin->SetExt(TPoint(),spriteSize); - spriteWin->DrawNow(); - TheClient->WaitForRedrawsToFinish(); - retVal=TheClient->iScreen->RectCompare(TRect(TPoint(),spriteSize),TRect(spritePos,spriteSize),CWsScreenDevice::EIncludeSprite); - TEST(retVal); - if(!retVal) - { - _LIT(KLog,"Third position of sprite fails - does not compare to same bitmap drawn in window."); - LOG_MESSAGE(KLog); - } - } - - CleanupStack::PopAndDestroy(spriteWin); - CleanupStack::PopAndDestroy(&sprite); - RestoreScreenMode(); - } - } - else - { - const TInt KScreenModeWithOffset = 2; - TheClient->iGroup->GroupWin()->EnableScreenChangeEvents(); - iTestWin->SetVisible(EFalse); - TheClient->Flush(); - iConnection2->iClient->Flush(); - TheClient->WaitForRedrawsToFinish(); - TPixelsAndRotation pixelsAndRotation1; - TheClient->iScreen->GetScreenModeSizeAndRotation(KScreenModeWithOffset,pixelsAndRotation1); - ChangeScreenMode(TheClient,pixelsAndRotation1,KScreenModeWithOffset); - RWsSprite sprite[2]; - for (TInt ii=0;ii<2;ii++) - { - SetUpSpriteLC(sprite[ii],TheClient->iWs,*TheClient->iGroup->WinTreeNode()); - } - TheClient->Flush(); - TheClient->WaitForRedrawsToFinish(); - TPixelsAndRotation pixelsAndRotation2; - TheClient->iScreen->GetScreenModeSizeAndRotation(0,pixelsAndRotation2); - iConnection2->iSpriteWin->UpdateState(0); - iConnection2->iSpriteWin->SetVisible(ETrue); - iConnection2->iClient->Flush(); - TSize spriteSize=iSpriteBitmap.SizeInPixels(); - TPoint screenMode2Origin; - screenMode2Origin=TheClient->iScreen->GetScreenModeOrigin(KScreenModeWithOffset); - //Check all reference bitmaps can be drawn inside the screen - MDisplayControl* interface = static_cast - (TheClient->iScreen->GetInterface(MDisplayControl::ETypeId)); - if(interface) - { - TDisplayConfiguration config; - interface->GetConfiguration(config); - TSize screenSize; - config.GetResolution(screenSize); - TEST(screenSize.iWidth > screenMode2Origin.iX+CheckSpritePos.iX+spriteSize.iWidth+30 - && screenSize.iHeight > screenMode2Origin.iY+CheckSpritePos.iY + spriteSize.iHeight+30); - } - - retVal = iConnection2->iClient->iScreen->RectCompare(TRect(screenMode2Origin+CheckSpritePos,spriteSize),TRect(screenMode2Origin,spriteSize),CWsScreenDevice::EIncludeSprite); - TEST(retVal); - if(!retVal) - INFO_PRINTF3(_L("iConnection2->iClient->iScreen->RectCompare() return value - Expected: %d, Actual: %d"), ETrue, retVal); - - TheClient->iScreen->SetCurrentRotations(KScreenModeWithOffset,CFbsBitGc::EGraphicsOrientationRotated180); - ChangeScreenMode(TheClient,pixelsAndRotation1,KScreenModeWithOffset); - TheClient->Flush(); - sprite[0].SetPosition(TPoint(0,0)); - sprite[1].SetPosition(TPoint(30,30)); - TheClient->Flush(); - TheClient->WaitForRedrawsToFinish(); - iConnection2->iSpriteWin->UpdateState(1); - iConnection2->iClient->Flush(); - retVal = iConnection2->iClient->iScreen->RectCompare(TRect(screenMode2Origin+CheckSpritePos,spriteSize+TPoint(30,30)),TRect(screenMode2Origin,spriteSize+TPoint(30,30)),CWsScreenDevice::EIncludeSprite); - TEST(retVal); - if(!retVal) - INFO_PRINTF3(_L("iConnection2->iClient->iScreen->RectCompare() return value - Expected: %d, Actual: %d"), ETrue, retVal); - - TheClient->iScreen->SetCurrentRotations(KScreenModeWithOffset,CFbsBitGc::EGraphicsOrientationNormal); - ChangeScreenMode(TheClient,pixelsAndRotation2,0); - iConnection2->iSpriteWin->SetExt(TPoint(215,0),TSize(218,240)); - TheClient->Flush(); - TheClient->WaitForRedrawsToFinish(); - sprite[0].SetPosition(TPoint(-10,20)); - sprite[1].SetPosition(TPoint(-10,40)); - TheClient->Flush(); - TheClient->WaitForRedrawsToFinish(); - ChangeScreenMode(TheClient,pixelsAndRotation1,ESizeEnforcementPixelsAndRotation,KScreenModeWithOffset); - TheClient->Flush(); - TheClient->WaitForRedrawsToFinish(); - iConnection2->iSpriteWin->UpdateState(2); - iConnection2->iClient->Flush(); - retVal = iConnection2->iClient->iScreen->RectCompare(TRect(screenMode2Origin+CheckSpritePos+TPoint(0,20),spriteSize+TPoint(-10,20)),TRect(screenMode2Origin+TPoint(0,20),spriteSize+TPoint(-10,20)),CWsScreenDevice::EIncludeSprite); - TEST(retVal); - if(!retVal) - INFO_PRINTF3(_L("iConnection2->iClient->iScreen->RectCompare() return value - Expected: %d, Actual: %d"), ETrue, retVal); - - CleanupStack::PopAndDestroy(2,&sprite[0]); - iConnection2->iSpriteWin->SetVisible(EFalse); - ChangeScreenMode(TheClient,pixelsAndRotation2,ESizeEnforcementPixelsAndRotation,0); - TheClient->Flush(); - TheClient->WaitForRedrawsToFinish(); - } -#endif - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-0105 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Rotation Tests - REQUIREMENT: CR PHAR-5SJGAM, PREQ673 - API: RWindowBase::InquireOffset(), RWindowBase::AbsPosition(),RWindowBase::Position() - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Goes through all the screen modes defined in the wsini file and all the rotations in - each screen mode. For each case sets the new screen mode and the the rotation on the current - client's screen device. Then sets a suitable size and position of 2 windows (an RWindow - and a child RBackedUpWindow) whose group window has the above screen device. - -@SYMTestExpectedResults Checks the windows are positioned correctly according to the origin and rotation - of the new screen mode. - -*/ -void CTScreenModePositioning::RotationTestsL() - { - RBlankWindow color256(TheClient->iWs); - User::LeaveIfError(color256.Construct(*TheClient->iGroup->GroupWin(),ENullWsHandle)); - CleanupClosePushL(color256); - color256.SetRequiredDisplayMode(EColor256); - color256.SetOrdinalPosition(2); - color256.Activate(); - TInt ii; - for (ii=0;iiiScreenModes.Count();) - { - iCurrentMode=TheClient->iScreenModes[ii]; - SetScreenMode(TheClient,iCurrentMode,ESizeEnforcementPixelsAndRotation); - TPixelsAndRotation pixelsAndRotation; - TheClient->iScreen->GetDefaultScreenSizeAndRotation(pixelsAndRotation); - TInt oldCurrentMode=iCurrentMode; - CArrayFixFlat* rotations=new(ELeave) CArrayFixFlat(1); - CleanupStack::PushL(rotations); - User::LeaveIfError(TheClient->iScreen->GetRotationsList(iCurrentMode,rotations)); - TInt count=rotations->Count(); - TInt jj=0; - if (count>1) - { - for (jj=0;jjiScreen->SetCurrentRotations(oldCurrentMode,REINTERPRET_CAST(CFbsBitGc::TGraphicsOrientation&,currentRotation)); - CleanupStack::PopAndDestroy(rotations); - iCurrentScreenModeOrigin=TheClient->iScreen->GetScreenModeOrigin(oldCurrentMode); - iCurrentScreenModeOrigin=TheClient->iScreen->GetScreenModeScaledOrigin(oldCurrentMode); - TPoint point1(iCurrentScreenModeOrigin.iX,iCurrentScreenModeOrigin.iY+(iCurrentScreenModeOrigin.iY+pixelsAndRotation.iPixelSize.iHeight)/2); - TPoint point2(iCurrentScreenModeOrigin.iX+(iCurrentScreenModeOrigin.iX+pixelsAndRotation.iPixelSize.iWidth)/2,pixelsAndRotation.iPixelSize.iHeight+iCurrentScreenModeOrigin.iY); - TRect rect0(point1,point2); - iTestWin->SetExtL(TPoint(),rect0.Size()); - iTestWin->Invalidate(); - - iTestWin->SetVisible(ETrue); - TheClient->Flush(); - TheClient->WaitForRedrawsToFinish(); - TestTopClientWindowPositionAPIs(TPoint(),iTestWin->BaseWin()); - TPoint backedUpWinPt=TPoint(rect0.Width()/3,rect0.Height()/4); - iBackedUpWin->SetVisible(ETrue); - - CleanupStack::PushL(TCleanupSetVisible(iBackedUpWin)); - CleanupStack::PushL(TCleanupSetVisible(iTestWin)); - - - iBackedUpWin->SetExtL(backedUpWinPt,TSize(rect0.Width()/6,rect0.Height()/6)); - TestChildWindowPositionAPIs(backedUpWinPt,TPoint(),iBackedUpWin->BaseWin(),iTestWin->BaseWin()); - - CleanupStack::PopAndDestroy(2,iBackedUpWin); //TCleanupSetVisible - } - CleanupStack::PopAndDestroy(&color256); - } - -TBool CTScreenModePositioning::ScalingSupportedByDisplayMode() - { - //PeterI Standard ScreenDriver only supports scaling in EColor256 and EColor64k - //see CDrawBitmap::CanBeScaled(), as mk3 is always in 16mu the tests will not pass. - TBool ret=EFalse; - TDisplayMode mode=TheClient->iScreen->DisplayMode(); - if (mode==EColor64K || mode==EColor256) - { - ret=ETrue; - } - return ret; - } -void CTScreenModePositioning::RunTestCaseL(TInt /*aCurTestCase*/) - { - _LIT(KWindowTests,"Window Tests"); - _LIT(KSpriteTest,"Sprite Test"); - _LIT(KRotationTests,"Rotation Tests"); - ((CTScreenModePositioningStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); - switch(iTest->iState) - { - case 0: - ((CTScreenModePositioningStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - if (!CheckNonZeroOriginsSupportedOrNot()) - { - _LIT(KLog,"Non Zero Origins not supported"); - LOG_MESSAGE(KLog); - TestComplete(); - return; - } - break; - case 1: - iTest->LogSubTest(KWindowTests); - if(ScalingSupportedByDisplayMode()) - WindowTestsL(); - ((CTScreenModePositioningStep*)iStep)->SetOverallTestStepID(_L("GRAPHICS-WSERV-0098")); - break; - case 2: - ((CTScreenModePositioningStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0104")); - iTest->LogSubTest(KSpriteTest); - if(ScalingSupportedByDisplayMode()) - SpriteTestL(); - break; - case 3: - ((CTScreenModePositioningStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0105")); - iTest->LogSubTest(KRotationTests); - RotationTestsL(); - break; - default: - ((CTScreenModePositioningStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - ((CTScreenModePositioningStep*)iStep)->CloseTMSGraphicsStep(); - RestoreScreenMode(); - TestComplete(); - return; - } - ((CTScreenModePositioningStep*)iStep)->RecordTestResultL(); - ++iTest->iState; // still used in the remaining code - } - -__WS_CONSTRUCT_STEP__(ScreenModePositioning) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TSCREENMODEPOSITIONING.H --- a/windowing/windowserver/tauto/TSCREENMODEPOSITIONING.H Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,123 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - - -#ifndef __TSCREENMODEPOSITIONING_H__ -#define __TSCREENMODEPOSITIONING_H__ - -#include -#include -#include "../tlib/testbase.h" -#include "AUTO.H" -#include "TScreenModeScaling.h" -#include "TGraphicsHarness.h" - -class CConnection2; - -class CConnection2Group : public CTWindowGroup - { -public: - CConnection2Group(CTClient *aClient, CConnection2 *aSecondConnection, CTestBase *aTest); -private: - CTestBase* iTest; -public: - CConnection2* iConnection2; - }; - -class CConnection2 : public CBase - { -public: - ~CConnection2(); - void ConstructL(CTestBase *aTest,CFbsBitmap& aBitmap); - void DrawBitmapWin(); - CBmpWin* BitmapWin() {return iBitmapWin;} -public: - CTClient* iClient; - CFbsBitmap* iScreenBitmap; - CSpriteWin* iSpriteWin; -private: - CConnection2Group *iGroup; - CBmpWin* iBitmapWin; - }; - - - -class CTScreenModePositioning : public CTWsGraphicsBase - { -public: - CTScreenModePositioning(CTestStep* aStep); - ~CTScreenModePositioning(); - void ConstructL(); - - void WindowTestsL(); - void SpriteTestL(); - void RotationTestsL(); - TBool ScalingSupportedByDisplayMode(); - -protected: - virtual void RunTestCaseL(TInt aCurTestCase); -private: - TBool TestRect(); - void CopyScreenAndChangeBackToDefScrModeL(); - void PositionTest1L(TPoint aPosTSize); - void PositionTest2L(TPoint aPos); - void GetInvalidRegionTestL(TPoint aPos); - void DoWindowTestsL(); - void CreateWindowsTestL(TPoint aPos); - void NextScreenModeTestL(TPoint aPos); - void ChangeScreenMode(CTClient* aClient,TPixelsAndRotation aPixelsAndRotation,TInt aMode); - void ChangeScreenMode(CTClient* aClient,TPixelsAndRotation aPixelsAndRotation,TScreenModeEnforcement aScreenModeEnforcement,TInt aMode); - void SetScreenMode(CTClient* aClient,TInt aMode,TScreenModeEnforcement aScreenModeEnforcement); - void SetUpSpriteLC(RWsSprite &aSprite, RWsSession &aSession, RWindowTreeNode &aWindow,TInt aFlags=ESpriteNoShadows); - void CompareRegionsL(const TRegion &aRegion1,const TRegion &aRegion2); - void TestGetInvalidRegionL(TRect& aRect); - void TestTopClientWindowPositionAPIs(TPoint aPos,RWindowBase* aWin); - void TestChildWindowPositionAPIs(TPoint aPos,TPoint aParentPos,RWindowBase* aWin,RWindowBase* aParentWin); - void CopyAndCompareL(TPoint aPos); - void RestoreScreenMode(); -private: - CFbsBitmap iSpriteBitmap; - CConnection2* iConnection2; - CBasicWin *iTestWin; - CTBackedUpWin* iBackedUpWin; - CTBlankWindow* iBlankWin; - CTBlankWindow* iTestChildWin; - TInt iCurrentMode; - TSize iTestWinSize; - TPoint iCurrentScreenModeOrigin; - TSize iCurrentScreenModeScale; - TSize iCurrentScreenModeSize; - TInt iScalingSupported; - }; - -class CTScreenModePositioningStep : public CTGraphicsStep - { -public: - CTScreenModePositioningStep(); -protected: - //from CTGraphicsStep - virtual CTGraphicsBase* CreateTestL(); - }; - -_LIT(KTScreenModePositioningStep,"TScreenModePositioning"); - - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TSCRMODE.CPP --- a/windowing/windowserver/tauto/TSCRMODE.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1701 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Test screen mode switching -// -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include "TSCRMODE.H" - -const TInt KBlankWinPosX=10; -const TInt KBlankWinPosY=20; -const TInt KBlankWinSizeX=30; -const TInt KBlankWinSizeY=25; - -const TInt KScreenMode0=0; -const TInt KScreenMode1=1; -_LIT(KScreenModeDisplayMode,"GetScreenModeDisplayMode"); - - -CTScrMode::CTScrMode(CTestStep* aStep) : CTWsGraphicsBase(aStep) - { - } - -// -// Static func to check windows -// - -LOCAL_C TInt DoPanicTest(TInt aInt, TAny *aScreenNumber) - { - RWsSession ws; - CWsScreenDevice *screen=NULL; - if (ws.Connect()==KErrNone) - { - screen = new (ELeave) CWsScreenDevice(ws); - if (screen && screen->Construct((TInt)aScreenNumber)==KErrNone) - { - TPixelsTwipsAndRotation sar; - CFbsBitGc::TGraphicsOrientation rot=CFbsBitGc::EGraphicsOrientationNormal; - TInt mode=0; - switch(aInt) - { - case 0: - case 1: - screen->SetScreenMode(aInt==0?1000:-1); - break; - case 2: - case 3: - screen->GetScreenModeSizeAndRotation(aInt==2?screen->NumScreenModes():-100000, sar); - break; - case 4: - case 5: - screen->GetScreenModeSizeAndRotation(aInt==4?screen->NumScreenModes()+100:-10, sar); - break; - case 6: - mode=screen->NumScreenModes(); - goto SetRot; - case 7: - mode=-55; - goto SetRot; - case 8: - mode=234; - goto SetRot; - case 9: - mode=screen->NumScreenModes()+2; - rot=CFbsBitGc::EGraphicsOrientationRotated270; - SetRot: - screen->SetCurrentRotations(mode,rot); - break; - case 10: - case 11: - ws.SetPointerCursorArea(aInt==10?1000:-1,TRect()); - break; - case 12: - case 13: - ws.PointerCursorArea(aInt==12?1003:-2); - break; - case 14: - case 15: - { - CArrayFixFlat *rotations=new(ELeave) CArrayFixFlat(1); - screen->GetRotationsList(aInt==12?1003:-2,rotations); - } - break; - case 100: - rot=CFbsBitGc::EGraphicsOrientationRotated90; - goto SetRot; - case 101: - rot=CFbsBitGc::EGraphicsOrientationRotated270; - goto SetRot; - case 102: - mode=1; - rot=CFbsBitGc::EGraphicsOrientationRotated270; - goto SetRot; - case 103: - mode=1; - #if defined(__EPOC32__) - rot=CFbsBitGc::EGraphicsOrientationRotated180; - #else - rot=CFbsBitGc::EGraphicsOrientationNormal; - #endif - goto SetRot; - } - ws.Flush(); - } - } - - return(EWsExitReasonBad); - } - -void SetupTestRWindowLC(RWindow& aWindow, const TPoint& aPos, const TSize& aSize, TDisplayMode aDisplayMode) - { - CleanupClosePushL(aWindow); - User::LeaveIfError(aWindow.Construct(*TheClient->iGroup->GroupWin(), (TUint)&aWindow)); - aWindow.SetExtent(aPos, aSize); - User::LeaveIfError(aWindow.SetRequiredDisplayMode(aDisplayMode)); - aWindow.Activate(); - } - -void CTScrMode::TestPanicsL() - { - TInt ii; - for (ii=0;ii<16;++ii) - TEST(iTest->TestWsPanicL(DoPanicTest,EWservPanicScreenModeNumber,ii,(TAny*)iTest->iScreenNumber)); - for (ii=100;ii<104;++ii) - TEST(iTest->TestWsPanicL(DoPanicTest,EWservPanicRotation,ii,(TAny*)iTest->iScreenNumber)); - iTest->CloseAllPanicWindows(); - } - -CTScrMode::~CTScrMode() - { - ((CTScrModeStep*)iStep)->CloseTMSGraphicsStep(); - delete iSecondConnection; - TheClient->iGroup->GroupWin()->DisableScreenChangeEvents(); - SetScreenModeEnforcement(iOldEnfMode); - } - -void CTScrMode::ConstructL() - { - //Remove next line when bitmaps are stored correctly - TestWin->Win()->EnableRedrawStore(EFalse); - BaseWin->Win()->EnableRedrawStore(EFalse); -// - TheClient->iGroup->GroupWin()->EnableScreenChangeEvents(); -// - //TheClient->iWs.SetAutoFlush(ETrue); - ValidateWin(BaseWin,TRgb::Gray256(204)); - ValidateWin(TestWin,TRgb::Gray256(204)); -// - iWinState=0; - iWinPos=TPoint(2*TheClient->iGroup->Size().iWidth/3,0); -// - iSecondConnection=new(ELeave) CSecondConnection; - iSecondConnection->ConstructL(iTest->iScreenNumber, TRect(KBlankWinPosX,KBlankWinPosY,KBlankWinPosX+KBlankWinSizeX,KBlankWinPosY+KBlankWinSizeY),iTest,iStep); -// - iOldEnfMode=TheClient->iScreen->ScreenModeEnforcement(); - if (TheClient->iScreenModes.Count()<2) - { - iTest->iState=1000; // Miss all tests - _LIT(KLog,"Skipping all tests as less that 2 screen size modes"); - LOG_MESSAGE(KLog); - } - else - { - SetScreenModeEnforcement(ESizeEnforcementNone); - TheClient->iScreen->SetScreenMode(TheClient->iScreenModes[0]); - } - } - -void CTScrMode::SetScreenModeEnforcement(TScreenModeEnforcement aMode) - { - iCurEnforcement=aMode; - TheClient->iScreen->SetScreenModeEnforcement(iCurEnforcement); - } - -void CTScrMode::ScaledDrawingL() - { - const TInt KLineXPos=10; - const TInt KLineYPos=30; - const TInt KLineLength=10; - const TInt KXScaleFactor=4; - const TInt KYScaleFactor=3; -// - // Draw rectangle onto TestWin - CWindowGc *gc=TheClient->iGc; - gc->Activate(*(TestWin->Win())); - gc->SetBrushColor(KRgbBlack); - gc->SetBrushStyle(CGraphicsContext::ESolidBrush); - gc->DrawRect(TRect(TPoint(KLineXPos,KLineYPos),TSize(KLineLength*KXScaleFactor,KYScaleFactor))); - gc->Deactivate(); -// - // Draw scaled bitmap onto BaseWin - TSize bitSize(KLineLength,1); - TSize bitTwipSize(TheClient->iScreen->HorizontalPixelsToTwips(bitSize.iWidth*KXScaleFactor), - TheClient->iScreen->VerticalPixelsToTwips(bitSize.iHeight*KYScaleFactor)); - CFbsBitGc *bitGc=NULL; - CFbsBitmapDevice *device=NULL; - CFbsBitmap *bitmap=NULL; - bitmap=new(ELeave) CFbsBitmap(); - CleanupStack::PushL(bitmap); - User::LeaveIfError(bitmap->Create(bitSize,EGray16)); - bitmap->SetSizeInTwips(bitTwipSize); - device=CFbsBitmapDevice::NewL(bitmap); - CleanupStack::PushL(device); - User::LeaveIfError(device->CreateContext(bitGc)); - bitGc->SetBrushColor(KRgbBlack); - bitGc->Clear(); - delete bitGc; -// - gc->Activate(*(BaseWin->Win())); - gc->DrawBitmap(TPoint(KLineXPos,KLineYPos),bitmap); - gc->Deactivate(); -// - TheClient->iWs.Flush(); - - CleanupStack::PopAndDestroy(2); // bitmap,device - - CompareWindows(_L("CTScrMode::ScaledDrawingL() CompareWindows() failed")); - } - -void CTScrMode::ValidateWin(TestWindow *aWin, TRgb aColor) - { - aWin->Win()->Invalidate(); - RedrawWin(*aWin->Win(),aColor); - } - -void CTScrMode::RedrawWin(RWindow &aWin, TRgb aColor) - { - aWin.BeginRedraw(); - TheClient->iGc->Activate(aWin); - TheClient->iGc->SetBrushColor(aColor); - TheClient->iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - TheClient->iGc->SetPenStyle(CGraphicsContext::ENullPen); - TheClient->iGc->Clear(); - TheClient->iGc->Deactivate(); - aWin.EndRedraw(); - } - -void CTScrMode::CheckWindows(TBool aWinIsVis) - { - iSecondConnection->SetWindow2Visibility(aWinIsVis); - TheClient->WaitForRedrawsToFinish(); - TheClient->iWs.Finish(); - CompareWindows(_L("CTScrMode::CheckWindows() CompareWindows() failed")); - } - -void CTScrMode::ScreenRotationsL() - { - CWsScreenDevice *screen=TheClient->iScreen; - CArrayFixFlat *rotations=new(ELeave) CArrayFixFlat(1); - CFbsBitGc::TGraphicsOrientation currentRotation; - TPixelsAndRotation sizeAndRotation; - TPixelsTwipsAndRotation sizeAndRotation2; - TBool found; - TInt numModes=TheClient->iScreenModes.Count(); - TInt count; - TInt ii,jj; - CleanupStack::PushL(rotations); - for (ii=0;iiiScreenModes[ii]; - User::LeaveIfError(screen->GetRotationsList(mode,rotations)); - screen->GetScreenModeSizeAndRotation(mode,sizeAndRotation); - screen->GetScreenModeSizeAndRotation(mode,sizeAndRotation2); - TEST(sizeAndRotation.iPixelSize.iWidth==sizeAndRotation2.iPixelSize.iWidth); - if (sizeAndRotation.iPixelSize.iWidth!=sizeAndRotation2.iPixelSize.iWidth) - INFO_PRINTF3(_L("sizeAndRotation.iPixelSize.iWidth==sizeAndRotation2.iPixelSize.iWidth - Expected: %d, Actual: %d"), sizeAndRotation.iPixelSize.iWidth, sizeAndRotation2.iPixelSize.iWidth); - - TEST(sizeAndRotation.iPixelSize.iHeight==sizeAndRotation2.iPixelSize.iHeight); - if (sizeAndRotation.iPixelSize.iHeight!=sizeAndRotation2.iPixelSize.iHeight) - INFO_PRINTF3(_L("sizeAndRotation.iPixelSize.iHeight==sizeAndRotation2.iPixelSize.iHeight - Expected: %d, Actual: %d"), sizeAndRotation.iPixelSize.iHeight, sizeAndRotation2.iPixelSize.iHeight); - - count=rotations->Count(); - TEST(count>=1); - if (count<1) - INFO_PRINTF3(_L("rotations->Count() return value - Expected: %d or more, Actual: %d"), 1, count); - - TBool retVal; - - if (sizeAndRotation.iPixelSize.iWidth!=sizeAndRotation.iPixelSize.iHeight) - { - TEST(count<=2); - if (count>2) - INFO_PRINTF3(_L("rotations->Count() return value - Expected: %d or less, Actual: %d"), 2, count); - - if (count==2) - { - retVal = (*rotations)[0]+2==(*rotations)[1]; - TEST(retVal); //Must only have rotations 180 degrees apart - if (!retVal) - INFO_PRINTF3(_L("(*rotations)[0]+2==(*rotations)[1] - Expected: %d, Actual: %d"), ETrue, retVal); - } - } - found=EFalse; - for (jj=0;jj1) - { - currentRotation=sizeAndRotation.iRotation; - for (jj=0;jjSetCurrentRotations(mode,REINTERPRET_CAST(CFbsBitGc::TGraphicsOrientation&,(*rotations)[jj])); - screen->GetScreenModeSizeAndRotation(mode,sizeAndRotation); - screen->GetScreenModeSizeAndRotation(mode,sizeAndRotation2); - retVal = (*rotations)[jj]==sizeAndRotation.iRotation; - TEST(retVal); - if (!retVal) - INFO_PRINTF3(_L("(*rotations)[jj]==sizeAndRotation.iRotation - Expected: %d, Actual: %d"), ETrue, retVal); - - retVal = (*rotations)[jj]==sizeAndRotation2.iRotation; - TEST(retVal); - if (!retVal) - INFO_PRINTF3(_L("(*rotations)[jj]==sizeAndRotation2.iRotation - Expected: %d, Actual: %d"), ETrue, retVal); - - } - screen->SetCurrentRotations(mode,REINTERPRET_CAST(CFbsBitGc::TGraphicsOrientation&,currentRotation)); - screen->GetScreenModeSizeAndRotation(mode,sizeAndRotation); - screen->GetScreenModeSizeAndRotation(mode,sizeAndRotation2); - - retVal = currentRotation==sizeAndRotation.iRotation; - TEST(retVal); - if (!retVal) - INFO_PRINTF3(_L("currentRotation==sizeAndRotation.iRotation - Expected: %d, Actual: %d"), ETrue, retVal); - - retVal = currentRotation==sizeAndRotation2.iRotation; - TEST(retVal); - if (!retVal) - INFO_PRINTF3(_L("currentRotation==sizeAndRotation2.iRotation - Expected: %d, Actual: %d"), ETrue, retVal); - } - } - CleanupStack::PopAndDestroy(); - } - -void CTScrMode::MoreScreenRotationsL() - { - RWindow shield4Gray(TheClient->iWs); - // The default display mode needs to be updated to EColor64K for Oghma integ - SetupTestRWindowLC(shield4Gray,TPoint(),TSize(100000,100000),EColor64K); -// - CWsScreenDevice *screen=TheClient->iScreen; - //CFbsBitGc::TGraphicsOrientation currentRotation; - TPixelsAndRotation sizeAndRotation; - TInt currentRotation; - TInt currentMode=FindCurrentMode(); - TInt numModes=TheClient->iScreenModes.Count(); - TInt currentScreenMode; - TInt count; - TInt ii,jj; - CArrayFixFlat *currentRotations=new(ELeave) CArrayFixFlat(1); - CleanupStack::PushL(currentRotations); - currentRotations->ResizeL(numModes); - CArrayFixFlat *originalRotation=new(ELeave) CArrayFixFlat(1); - CleanupStack::PushL(originalRotation); - originalRotation->ResizeL(numModes); - CArrayFixFlat *rotations=new(ELeave) CArrayFixFlat(1); - CleanupStack::PushL(rotations); - for (ii=0;iiiScreenModes[ii]; - screen->GetScreenModeSizeAndRotation(mode,sizeAndRotation); - (*currentRotations)[ii]=sizeAndRotation.iRotation; - (*originalRotation)[ii]=sizeAndRotation.iRotation; - } - for (ii=0;iiiScreenModes[ii]; - screen->SetScreenMode(mode); - currentScreenMode = screen->CurrentScreenMode(); - TEST(currentScreenMode == mode); - if (currentScreenMode != mode) - INFO_PRINTF3(_L("screen->CurrentScreenMode() return value - Expected: %d, Actual: %d"), mode, currentScreenMode); - - screen->GetDefaultScreenSizeAndRotation(sizeAndRotation); - currentRotation=(*currentRotations)[ii]; - TEST(sizeAndRotation.iRotation==currentRotation); - - screen->GetScreenModeSizeAndRotation(mode,sizeAndRotation); - TEST(sizeAndRotation.iRotation==currentRotation); - - User::LeaveIfError(screen->GetRotationsList(mode,rotations)); - count=rotations->Count(); - if (count>1) - { - for (jj=0;jjSetCurrentRotations(mode,REINTERPRET_CAST(CFbsBitGc::TGraphicsOrientation&,currentRotation)); - (*currentRotations)[ii]=currentRotation; - } - } - for (ii=0;iiiScreenModes[ii]; - screen->SetScreenMode(mode); - currentScreenMode = screen->CurrentScreenMode(); - TEST(currentScreenMode == mode); - if (currentScreenMode != mode) - INFO_PRINTF3(_L("(screen->CurrentScreenMode() return value - Expected: %d, Actual: %d"), mode, currentScreenMode); - - screen->GetDefaultScreenSizeAndRotation(sizeAndRotation); - currentRotation=(*currentRotations)[ii]; - TEST(sizeAndRotation.iRotation==currentRotation); - if (sizeAndRotation.iRotation != currentRotation) - INFO_PRINTF3(_L("(screen->GetDefaultScreenSizeAndRotation() return value - Expected: %d, Actual: %d"), currentRotation, sizeAndRotation.iRotation); - - screen->GetScreenModeSizeAndRotation(mode,sizeAndRotation); - TEST(sizeAndRotation.iRotation==currentRotation); - if (sizeAndRotation.iRotation != currentRotation) - INFO_PRINTF3(_L("(screen->GetDefaultScreenSizeAndRotation() return value - Expected: %d, Actual: %d"), currentRotation, sizeAndRotation.iRotation); - - if (currentRotation!=(*originalRotation)[ii]) - screen->SetCurrentRotations(mode,REINTERPRET_CAST(CFbsBitGc::TGraphicsOrientation&,(*originalRotation)[ii])); - } - screen->SetScreenMode(currentMode); - currentScreenMode = screen->CurrentScreenMode(); - TEST(currentScreenMode == currentMode); - if (currentScreenMode != currentMode) - INFO_PRINTF3(_L("(screen->CurrentScreenMode() return value - Expected: %d, Actual: %d"), currentMode, currentScreenMode); - - CleanupStack::PopAndDestroy(4,&shield4Gray); - } - -TInt CTScrMode::FindCurrentMode() - { - CWsScreenDevice *screen=TheClient->iScreen; - TPixelsTwipsAndRotation sizeAndRotation; - TPixelsTwipsAndRotation sizeAndRotation2; - TInt numModes=TheClient->iScreenModes.Count(); - TInt ii; - screen->GetDefaultScreenSizeAndRotation(sizeAndRotation); - for (ii=0;iiiScreenModes[ii]; - screen->GetScreenModeSizeAndRotation(mode,sizeAndRotation2); - if (Equal(sizeAndRotation,sizeAndRotation2)) - return mode; - } - TEST(EFalse); - return -1; - } - -TBool CTScrMode::Equal(const TPixelsTwipsAndRotation& aLeft,const TPixelsTwipsAndRotation& aRight) - { - if (aLeft.iPixelSize!=aRight.iPixelSize) - return EFalse; - if (aLeft.iRotation!=aRight.iRotation) - return EFalse; - if (aLeft.iTwipsSize!=aRight.iTwipsSize) - return EFalse; - return ETrue; - } - -TBool CTScrMode::RectClearBugL() - { - CWsScreenDevice *screen=TheClient->iScreen; - TPixelsTwipsAndRotation sizeAndRotation1; - TPixelsTwipsAndRotation sizeAndRotation2; - TInt screenMode=FindCurrentMode(); - TInt largeMode=0; - TInt smallMode=1; - INFO_PRINTF1(_L("Rotation 1")); - screen->GetScreenModeSizeAndRotation(0,sizeAndRotation1); - INFO_PRINTF1(_L("Rotation 2")); - screen->GetScreenModeSizeAndRotation(1,sizeAndRotation2); - TSize winSize=TSize(Max(sizeAndRotation1.iPixelSize.iWidth,sizeAndRotation2.iPixelSize.iWidth) - ,Max(sizeAndRotation1.iPixelSize.iHeight,sizeAndRotation2.iPixelSize.iHeight)); - if (sizeAndRotation1.iPixelSize.iWidth<=sizeAndRotation2.iPixelSize.iWidth - && sizeAndRotation1.iPixelSize.iHeight<=sizeAndRotation2.iPixelSize.iHeight) - { - largeMode=1; - smallMode=0; - } - if (screenMode!=largeMode) - { - INFO_PRINTF2(_L("Large Mode %d\r\n"),largeMode); - screen->SetScreenMode(largeMode); - } - CBlankWindow *blankWin=new(ELeave) CBlankWindow(TRgb::Gray256(204)); - CleanupStack::PushL(blankWin); - blankWin->SetUpL(TPoint(),winSize,TheClient->iGroup,*TheClient->iGc); - TheClient->iGc->Activate(*blankWin->Win()); //blankWin->Win()->Invalidate(); - blankWin->Draw(); - TheClient->iWs.Flush(); - blankWin->Win()->SetRequiredDisplayMode(EGray4); - INFO_PRINTF2(_L("Small Mode %d\r\n"),smallMode); - screen->SetScreenMode(smallMode); - TheClient->iWs.Flush(); - TheClient->iGc->Deactivate(); - CleanupStack::PopAndDestroy(); - if (screenMode!=smallMode) - { - INFO_PRINTF2(_L("Screen Mode %d\r\n"),screenMode); - screen->SetScreenMode(screenMode); - } - - return ETrue; - } - -void CTScrMode::ScreenModeChange1L() - { - CTWin* color64win; - color64win=new(ELeave) CTWin(); - CleanupStack::PushL(color64win); - color64win->ConstructL(*TheClient->iGroup); - color64win->BaseWin()->SetRequiredDisplayMode(EColor64K); - //color64win->SetBackgroundColor(TRgb(0,0,255)); - color64win->Win()->SetBackgroundColor(); - color64win->Activate(); - TheClient->Flush(); - CTWin* color4win; - color4win=new(ELeave) CTWin(); - CleanupStack::PushL(color4win); - color4win->ConstructL(*TheClient->iGroup); - color4win->BaseWin()->SetRequiredDisplayMode(EColor4K); - //color4win->SetBackgroundColor(TRgb(255,0,0)); - color4win->Win()->SetBackgroundColor(); - color4win->SetSize(TSize(600,200)); - color4win->Activate(); - TheClient->Flush(); - color4win->SetSize(TSize(640,240)); - TheClient->Flush(); - color64win->SetSize(TSize(20,20)); - color64win->WinTreeNode()->SetOrdinalPosition(0); - TheClient->Flush(); - CleanupStack::Pop(2,color64win); - delete color64win; - TheClient->Flush(); - delete color4win; - //CleanupStack::PopAndDestroy(2,color64win); - } - -void CTScrMode::ScreenModeChange2L() - { - CTBlankWindow* color64win; - color64win=new(ELeave) CTBlankWindow(); - CleanupStack::PushL(color64win); - color64win->ConstructL(*TheClient->iGroup); - color64win->BaseWin()->SetRequiredDisplayMode(EColor64K); - color64win->SetColor(TRgb(0,0,255)); - //color64win->SetColor(); - color64win->Activate(); - TheClient->Flush(); - CTBlankWindow* color4win; - color4win=new(ELeave) CTBlankWindow(); - CleanupStack::PushL(color4win); - color4win->ConstructL(*TheClient->iGroup); - color4win->BaseWin()->SetRequiredDisplayMode(EColor4K); - color4win->SetColor(TRgb(255,0,0)); - //color4win->SetColor(); - color4win->SetSize(TSize(600,200)); - color4win->Activate(); - TheClient->Flush(); - color4win->SetSize(TSize(640,240)); - TheClient->Flush(); - color64win->SetSize(TSize(20,20)); - color64win->WinTreeNode()->SetOrdinalPosition(0); - TheClient->Flush(); - CleanupStack::Pop(2,color64win); - delete color64win; - TheClient->Flush(); - delete color4win; - //CleanupStack::PopAndDestroy(2,color64win); - } - -LOCAL_C void ResetAndDestroyWindows(TAny* aPointerArray) - { - static_cast*>(aPointerArray)->ResetAndDestroy(); - } - -LOCAL_C TBool WalkThroughTree(RPointerArray aListOfWindows) - { - TBool ret=ETrue; - TInt count = aListOfWindows.Count(); - while (--count>=0 && ret) - { - RRegion region; - ((aListOfWindows)[count])->Win()->GetInvalidRegion(region); - ret=region.IsEmpty(); - } - return ret; - } - -void CTScrMode::InvisibleWndAndInfiniteRedrawBugL() - { - // Current Test client state - CTClient* clientA=TheClient; - CWsScreenDevice* screenClientA=clientA->iScreen; - const TScreenModeEnforcement screenModeEnforcement = screenClientA->ScreenModeEnforcement(); - const TInt currentScreenMode=FindCurrentMode(); - TPixelsTwipsAndRotation sizeAndRotation; - screenClientA->GetScreenModeSizeAndRotation(currentScreenMode,sizeAndRotation); - - - SecondClientConnection* clientB = new(ELeave) SecondClientConnection(); - CleanupStack::PushL(clientB); - clientB->SetScreenNumber(iTest->iScreenNumber); - clientB->ConstructL(currentScreenMode, sizeAndRotation); - -// Start test - CWindowGc& gc=*clientB->iGc; - RWsSession ws=clientB->iWs; - CTWindowGroup* group=clientB->iGroup; - - const TInt shrinkFactor = 5; - TRect parentRect(0,0, sizeAndRotation.iPixelSize.iWidth, sizeAndRotation.iPixelSize.iHeight); - RPointerArray windows; - CleanupStack::PushL(TCleanupItem(ResetAndDestroyWindows, &windows)); - // create several children - const TInt count = (iTest->iTestLevel==iTest->ELevelQuick ? 5 : 7); - CBlankWindow* blankWin=NULL; - CTWinBase* parent=group; - for (TInt childNum=0; childNumSetUpL(parentRect.iTl, parentRect.Size(), parent, gc); - // make it visible and draw it - blankWin->Win()->Invalidate(); - gc.Activate(*blankWin->Win()); - blankWin->Draw(); - ws.Flush(); - gc.Deactivate(); - // prepare for next window - parent=blankWin; - parentRect.Shrink(shrinkFactor, shrinkFactor); - } - - // change screen mode and check visibility of all windows - - const TInt newScreenMode = (currentScreenMode==KScreenMode0?KScreenMode1:KScreenMode0); - TPixelsTwipsAndRotation sizeAndRotationForDifferentScreenMode; - screenClientA->GetScreenModeSizeAndRotation(newScreenMode, sizeAndRotationForDifferentScreenMode); - screenClientA->SetScreenSizeAndRotation(sizeAndRotationForDifferentScreenMode); - screenClientA->SetScreenMode(newScreenMode); - - TheClient->WaitForRedrawsToFinish(); - TBool retVal = WalkThroughTree(windows); - TEST(retVal); - if (!retVal) - INFO_PRINTF3(_L("WalkThroughTree(windows) return value - Expected: %d, Actual: %d"), ETrue, retVal); - - - screenClientA->SetScreenModeEnforcement(screenModeEnforcement); - screenClientA->SetScreenMode(currentScreenMode); - screenClientA->SetScreenSizeAndRotation(sizeAndRotation); - - // destroy all windows - CleanupStack::PopAndDestroy(2, clientB); // ResetAndDestroyWindows and client - // Needed to get system back into a good state as this test can leave the shell in front of the test app - TheClient->iGroup->GroupWin()->SetOrdinalPosition(0); - } - -//To test the APIs GetScreenModeDisplayMode() & GetDefModeMaxNumColors() -void CTScrMode::GetScreenDisplayMode() - { - TInt color,gray; - CWsScreenDevice *screen=TheClient->iScreen; - TInt currentScreenMode=screen->CurrentScreenMode(); //finding the current screen mode - screen->SetScreenMode(KScreenMode1); //changing the current screen mode to 1 - - //testing the display mode of Screen Mode using the API GetScreenModeDisplayMode() - TDisplayMode displayMode=screen->GetScreenModeDisplayMode(KScreenMode1); - - TEST(displayMode!=ENone); - TEST(displayMode!=ERgb); - //testing the default mode of Screen Mode using the API GetDefModeMaxNumColors() - TDisplayMode defaultMode=TheClient->iWs.GetDefModeMaxNumColors(color,gray); - TDisplayMode defaultModeForScreen=TheClient->iWs.GetDefModeMaxNumColors(screen->GetScreenNumber(),color,gray); - TEST(defaultMode==defaultModeForScreen); - TEST(defaultMode!=ENone); - TEST(defaultMode!=ERgb); - TEST(color == 16777216 || color == 0 || color == 16 || color == 256 || color == 4096 || color == 65536); - TEST(gray == 0 || gray == 2 || gray == 4 || gray == 16 || gray == 256); - screen->SetScreenMode(currentScreenMode); - - CArrayFixFlat* modeList=new CArrayFixFlat(15); - TEST(modeList != NULL); - if(!modeList) - { - return; - } - TInt res = TheClient->iWs.GetColorModeList(modeList); - TEST(res == KErrNone); - TDisplayMode modeMax = ENone; - for(TInt index = 0; index < modeList->Count(); index++) - { - TDisplayMode mode = (TDisplayMode) ((*modeList)[index]); - if(mode > modeMax) - { - modeMax = mode; - } - } - modeList->Reset(); - delete modeList; - TInt realColor = 0; - TInt realGray = 0; - switch(modeMax) - { - case EGray2: - realColor = 2; - realGray = 2; - break; - case EGray4: - realColor = 4; - realGray = 4; - break; - case EGray16: - realColor = 16; - realGray = 16; - break; - case EGray256: - realColor = 256; - realGray = 256; - break; - case EColor16: - realColor = 16; - break; - case EColor256: - realColor = 256; - break; - case EColor4K: - realColor = 4096; - break; - case EColor64K: - realColor = 65536; - break; - case EColor16M: - case EColor16MU: - case EColor16MA: - case EColor16MAP: - realColor = 16777216; - break; - default: - break; - } - - if (realColor > 0) - TEST(realColor == color); - if (realGray > 0) - TEST(gray == realGray); - } - -void CTScrMode::SetScreenModeAfterScreenDeviceDeletedL() - { - // A separate session is needed, because this test will delete the primary screen device - RWsSession ws; - User::LeaveIfError(ws.Connect()); - - // Push the secondary screen device first onto the cleanup stack - // so that we can pop and destroy the primary screen device first - CWsScreenDevice* secondaryScreenDevice = new (ELeave) CWsScreenDevice(ws); - CleanupStack::PushL(secondaryScreenDevice); - - CWsScreenDevice* primaryScreenDevice = new (ELeave) CWsScreenDevice(ws); - CleanupStack::PushL(primaryScreenDevice); - - // Construct the primary screen device first to ensure that it is - // used by the group window - User::LeaveIfError(primaryScreenDevice->Construct(iTest->iScreenNumber)); - User::LeaveIfError(secondaryScreenDevice->Construct(iTest->iScreenNumber)); - - RWindowGroup group(ws); - User::LeaveIfError(group.Construct(888)); - group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close - - RArray screenModes; - primaryScreenDevice->GetScreenSizeModeList(&screenModes); - primaryScreenDevice->SetScreenMode(screenModes[0]); - - // Prematurely destroy the primary screen device used by the group window - CleanupStack::PopAndDestroy(primaryScreenDevice); - - // Simulate screen rotation - call SetScreenMode() - // This would trigger the defective behaviour and wserv would panic if broken - secondaryScreenDevice->SetScreenMode(screenModes[0]); - - // Tidy up - screenModes.Close(); - group.Close(); - CleanupStack::PopAndDestroy(secondaryScreenDevice); - ws.Flush(); - ws.Close(); - } - -void CTScrMode::DrawTestBmpL(CFbsBitmap* aTestBitmap) - { - CFbsBitmapDevice* device=CFbsBitmapDevice::NewL(aTestBitmap); - CleanupStack::PushL(device); - CGraphicsContext* bmpgc; - User::LeaveIfError(device->CreateContext(bmpgc)); - CleanupStack::PushL(bmpgc); - bmpgc->SetPenColor(KRgbDarkRed); - bmpgc->SetBrushColor(KRgbYellow); - bmpgc->SetBrushStyle(CGraphicsContext::ESolidBrush); - bmpgc->SetPenStyle(CGraphicsContext::ESolidPen); - bmpgc->DrawRect(TRect(aTestBitmap->SizeInPixels())); - CleanupStack::PopAndDestroy(2,device); - } - -void CTScrMode::TestDrawingToWindows(CWindowGc* aWinGc1, CWindowGc* aWinGc2, RWindow& aWindow1,RWindow& aWindow2,CFbsBitmap* aBitmap64K,CFbsBitmap* aBitmap16M,CFbsFont* aFont, TBool aAllInRedraw, TBool aUseSystemGc, TBool aUseBmp16M) - { - CFbsBitmap* bitmap=aUseBmp16M?aBitmap16M:aBitmap64K; - TInt ascent=aFont->AscentInPixels(); - for(TInt win=0;win<2;win++) - { - RWindow* winPtr=(win==0)?&aWindow1:&aWindow2; - winPtr->Invalidate(); - winPtr->BeginRedraw(); - CWindowGc* winGc; - if (aUseSystemGc) - { - winGc=TheClient->iGc; - winGc->Activate(*winPtr); - } - else - { - winGc=(win==0)?aWinGc1:aWinGc2; - winGc->Reset(); - } - winGc->SetBrushColor(KRgbBlue); - winGc->Clear(); - if (!aAllInRedraw) - winPtr->EndRedraw(); -// - winGc->BitBlt(TPoint(0,0),bitmap); - winGc->UseFont(aFont); - _LIT(KTestText123,"Test text 123"); - winGc->DrawText(KTestText123,TPoint(0,ascent)); - if (aAllInRedraw) - winPtr->EndRedraw(); - if (aUseSystemGc) - winGc->Deactivate(); - } - TBool winCheck=DoCheckRectRWin(aWindow1,aWindow2,TRect(aWindow1.Size())); - if (!winCheck) - { - TBuf<256> errBuf(_L("Rot-mode test failed")); - if (aAllInRedraw) - errBuf.Append(_L(", All in Redraw")); - if (aUseSystemGc) - errBuf.Append(_L(", System Gc")); - if (aUseBmp16M) - errBuf.Append(_L(", 16M bmp")); - else - errBuf.Append(_L(", 64K bmp")); - INFO_PRINTF1(errBuf); - } - TEST(winCheck); - } - -void SetWsAndAppScreenModes(TInt aMode) - { - TheClient->iScreen->SetScreenMode(aMode); - TheClient->iScreen->SetAppScreenMode(aMode); - } - -TDisplayMode HighestMatch(CArrayFixFlat* aModeList,TInt &aMaxBpp) - { - TDisplayMode highMode=ENone; - TInt highBpp=0; - for(TInt loop=aModeList->Count()-1;loop>=0;loop--) - { - TDisplayMode mode=(TDisplayMode)(*aModeList)[loop]; - TInt bpp; - switch(mode) - { - case EGray2: - bpp=1; - break; - case EGray4: - bpp=2; - break; - case EGray16: - case EColor16: - bpp=4; - break; - case EColor256: - case EGray256: - bpp=8; - break; - case EColor64K: - bpp=16; - break; - case EColor4K: - bpp=12; - break; - case EColor16M: - case EColor16MU: - case EColor16MA: - case EColor16MAP: - bpp=32; - break; - default: - bpp=0; - break; - } - if (bpp>highBpp && bppiGroup->GroupWin()->SetOrdinalPosition(0); -// When switching colour modes Wserv takes into account the full device size, not the clipped size -// associated with any specific screen mode. Therefore any windows designed to influence the screen -// mode must use the appropriately rotated device base screen size, not any cutdown screen mode sizes. - TSize baseScreenSize=TheClient->iScreen->SizeInPixels(); - TSize rotatedBaseSize(baseScreenSize.iHeight,baseScreenSize.iWidth); - TInt maxScreenDimension=Max(baseScreenSize.iHeight,baseScreenSize.iWidth); -// - CArrayFixFlat* modeList=new(ELeave) CArrayFixFlat(15); - CleanupStack::PushL(modeList); - User::LeaveIfError(TheClient->iWs.GetColorModeList(modeList)); - TInt maxBpp=KMaxTInt; - TDisplayMode testDispModeHigh=HighestMatch(modeList,maxBpp); - TDisplayMode testDispModeLow=HighestMatch(modeList,maxBpp); - CleanupStack::PopAndDestroy(modeList); -// If only one available display mode skip tests - if (testDispModeLow==ENone) - return; -// - CFbsFont* font; - TFontSpec fspec; - fspec.iHeight=240; - User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont*&)font,fspec)); -// Create a massive 16M window to make sure 16M is the fallback mode when any area of the screen is exposed - RWindow shield16M(TheClient->iWs); - SetupTestRWindowLC(shield16M,TPoint(),TSize(100000,100000),testDispModeHigh); - RedrawWin(shield16M,KRgbBlack); -// - TInt numModes=TheClient->iScreenModes.Count(); - for(TInt modeIndex=0;modeIndexiScreenModes[modeIndex]; - TPoint origin=TheClient->iScreen->GetScreenModeScaledOrigin(screenMode); - if (origin.iX!=0 || origin.iY!=0) - continue; - TPixelsTwipsAndRotation sar; - TheClient->iScreen->GetScreenModeSizeAndRotation(screenMode,sar); - TSize screenSize=sar.iPixelSize; - if (screenSize.iWidth>baseScreenSize.iWidth || screenSize.iHeight>baseScreenSize.iHeight) - continue; - TSize rotatedScreenDeviceSize(sar.iRotation==CFbsBitGc::EGraphicsOrientationRotated90 || sar.iRotation==CFbsBitGc::EGraphicsOrientationRotated270? - rotatedBaseSize:baseScreenSize); -// - TheClient->iScreen->SetScreenMode(screenMode); -// - TSize screenSize1 = screenSize; - screenSize1.iWidth = Min(screenSize1.iWidth, rotatedScreenDeviceSize.iWidth); //this is to guarantee we won't compare beyond screen size - TSize testSize(screenSize1.iWidth/2,screenSize1.iHeight); - TSize testBmpSize(testSize.iWidth,testSize.iHeight/4); -// - CFbsBitmap* testBitmap64=new(ELeave) CFbsBitmap; - CleanupStack::PushL(testBitmap64); - User::LeaveIfError(testBitmap64->Create(testBmpSize,testDispModeLow)); - DrawTestBmpL(testBitmap64); -// - CFbsBitmap* testBitmap16M=new(ELeave) CFbsBitmap; - CleanupStack::PushL(testBitmap16M); - User::LeaveIfError(testBitmap16M->Create(testBmpSize,testDispModeHigh)); - DrawTestBmpL(testBitmap16M); -// - RWindow window(TheClient->iWs); - SetupTestRWindowLC(window,TPoint(0,0), testSize,testDispModeHigh); - RWindow window2(TheClient->iWs); - SetupTestRWindowLC(window2,TPoint(testSize.iWidth,0),testSize,testDispModeHigh); -// - CWindowGc* winGc1=new(ELeave) CWindowGc(TheClient->iScreen); - CleanupStack::PushL(winGc1); - User::LeaveIfError(winGc1->Construct()); - winGc1->Activate(window); - CWindowGc* winGc2=new(ELeave) CWindowGc(TheClient->iScreen); - CleanupStack::PushL(winGc2); - User::LeaveIfError(winGc2->Construct()); - winGc2->Activate(window2); -// - for(TInt modeIndex2=0;modeIndex2iScreenModes[modeIndex2]; - TPoint origin2=TheClient->iScreen->GetScreenModeScaledOrigin(screenMode2); - if (origin2.iX!=0 || origin2.iY!=0) - continue; - TDisplayMode baseDisplayMode=TheClient->iScreen->DisplayMode(); - INFO_PRINTF5(_L("Testing with screen modes %d/%d, display modes %d/%d"),modeIndex,modeIndex2,testDispModeLow,testDispModeHigh); - SetWsAndAppScreenModes(screenMode2); - TDisplayMode dispMode11 = TheClient->iScreen->DisplayMode(); - TPixelsTwipsAndRotation sar1; - TheClient->iScreen->GetScreenModeSizeAndRotation(screenMode2, sar1); - if(sar1.iRotation == sar.iRotation) - { - continue; - } -// - RWindow window64K(TheClient->iWs); - SetupTestRWindowLC(window64K,TPoint(),TSize(maxScreenDimension,maxScreenDimension),testDispModeLow); - RedrawWin(window64K,KRgbGreen); - // Should now have switched Wserv to 64K mode - TEST(TheClient->iScreen->DisplayMode()==testDispModeLow); -// - RWindow window16M(TheClient->iWs); - SetupTestRWindowLC(window16M,TPoint(),TSize(maxScreenDimension/2,maxScreenDimension/2),testDispModeHigh); - RedrawWin(window16M,KRgbCyan); - // Should switch Wserv back to 16M mode - TEST(TheClient->iScreen->DisplayMode()==testDispModeHigh); -// - window64K.SetOrdinalPosition(-1); - window16M.SetOrdinalPosition(-1); - SetWsAndAppScreenModes(screenMode); - TEST(TheClient->iScreen->DisplayMode()==baseDisplayMode); -// - const TInt KNumTestFlags=3; - const TInt KMaxTestFlags=1<iScreen->DisplayMode()==testDispModeLow); - window64K.SetVisible(EFalse); - TEST(TheClient->iScreen->DisplayMode()==baseDisplayMode); - window64K.SetVisible(ETrue); - TEST(TheClient->iScreen->DisplayMode()==testDispModeLow); - window64K.SetSize(rotatedScreenDeviceSize); - TEST(TheClient->iScreen->DisplayMode()==testDispModeLow); - // Changing screen mode now should expose the 16M window - SetWsAndAppScreenModes(screenMode2); - TEST(TheClient->iScreen->DisplayMode()==testDispModeHigh); - SetWsAndAppScreenModes(screenMode); - // And back to the 64K win covering the screen - TEST(TheClient->iScreen->DisplayMode()==testDispModeLow); -// Create a new group with a 16M window and switching ordinal pos to back and back to front - RWindowGroup testGroup(TheClient->iWs); - CleanupClosePushL(testGroup); - User::LeaveIfError(testGroup.Construct(111,EFalse)); - RWindow testGroupWin(TheClient->iWs); - CleanupClosePushL(testGroupWin); - User::LeaveIfError(testGroupWin.Construct(testGroup, 112)); - testGroupWin.SetExtent(TPoint(), TSize(1,1)); // Just enough to change mode - testGroupWin.SetRequiredDisplayMode(testDispModeHigh); - testGroupWin.Activate(); - TEST(TheClient->iScreen->DisplayMode()==testDispModeHigh); - TInt oldPos=testGroup.OrdinalPosition(); - testGroup.SetOrdinalPosition(oldPos+1); - TEST(TheClient->iScreen->DisplayMode()==testDispModeLow); - testGroup.SetOrdinalPosition(oldPos); - TEST(TheClient->iScreen->DisplayMode()==testDispModeHigh); - CleanupStack::PopAndDestroy(2,&testGroup); - TEST(TheClient->iScreen->DisplayMode()==testDispModeLow); -// - CleanupStack::PopAndDestroy(2,&window64K); - } - CleanupStack::PopAndDestroy(2,winGc1); - CleanupStack::PopAndDestroy(2,&window); - CleanupStack::PopAndDestroy(2,testBitmap64); - } - CleanupStack::PopAndDestroy(&shield16M); - TheClient->iScreen->ReleaseFont(font); - SetWsAndAppScreenModes(TheClient->iScreenModes[0]); - } - -void CTScrMode::RunTestCaseL(TInt /*aCurTestCase*/) - { - TBuf<32> buf; - TBool checkWindowParam=EFalse; - TInt count=0; - TInt mode=0; - TBool enable=EFalse; - TBool disable=EFalse; - TInt retVal; - - ((CTScrModeStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); - switch(++iTest->iState) - { -/** - - @SYMTestCaseID GRAPHICS-WSERV-0296 - - @SYMDEF DEF081259 - - @SYMTestCaseDesc Test screen modes can be set while the screen is rotated - through 180 degrees. - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions Rotate the screen through 180 degrees while setting each - of the screen modes available - - @SYMTestExpectedResults The screen is rotated and screen modes set correctly - -*/ - case 1: - ((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0296")); - iTest->LogSubTest(_L("Orientation1")); - ScreenRotationsL(); - break; -/** - - @SYMTestCaseID GRAPHICS-WSERV-0297 - - @SYMDEF DEF081259 - - @SYMTestCaseDesc Change the screen orientation then test screen modes can - be set while the screen is rotated through 180 degrees. - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions Rotate the screen through 180 degrees while setting each - of the screen modes available - - @SYMTestExpectedResults The screen is rotated and screen modes set correctly - -*/ - case 2: - ((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0297")); - iTest->LogSubTest(_L("Orientation2")); - MoreScreenRotationsL(); - iSubState=0; - break; -/** - - @SYMTestCaseID GRAPHICS-WSERV-0298 - - @SYMDEF DEF081259 - - @SYMTestCaseDesc Test for the rect clear defect while setting screen mode - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions Change the screen mode and check the rect clear defect is - not present - - @SYMTestExpectedResults The defect is not present - -*/ - case 3: - ((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0298")); - iTest->LogSubTest(_L("Rect Clear Defect")); - RectClearBugL(); - break; - case 4: -/** - - @SYMTestCaseID GRAPHICS-WSERV-0299 - - @SYMDEF DEF081259 - - @SYMTestCaseDesc Test display mode can be set for test windows and - that the windows then function correctly - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions Set the display mode in two test windows and then call - methods on the windows - - @SYMTestExpectedResults The windows function correctly - -*/ - ((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0299")); - - iTest->LogSubTest(_L("ScreenModeChange")); - ScreenModeChange1L(); - ScreenModeChange2L(); - break; -/** - - @SYMTestCaseID GRAPHICS-WSERV-0300 - - @SYMDEF DEF081259 - - @SYMTestCaseDesc Test display mode can be set and retrieved - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions Set the display mode in a window and the retrieve it - - @SYMTestExpectedResults The display mode retrieved is the same as the - one set. - -*/ - case 5: - ((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0300")); - iTest->LogSubTest(KScreenModeDisplayMode); - GetScreenDisplayMode(); - break; - - -#if defined(SCREEN_MODE_TESTING) -/** - - @SYMTestCaseID GRAPHICS-WSERV-0301 - - @SYMDEF DEF081259 - - @SYMTestCaseDesc Case 101 to 105 tests that the screen is drawn correctly - as different screen modes and screen orientation are - set for the screen - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions Set different screen modes and orientations for the screen and - redraw the screen - - @SYMTestExpectedResults The screen is drawn correctly for each setting - -*/ - case 101: - ((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0301")); - iSubState = 0; - buf.Format(TRefByValue(_L("Screen mode %d:%d")),101,iSubState); - INFO_PRINTF1(buf); - checkWindowParam=ETrue; - mode=1; - if (iCurEnforcement==ESizeEnforcementPixelsAndRotation) - count+=3; - else if (iCurEnforcement==ESizeEnforcementPixelsTwipsAndRotation) - count+=6; - if (iSecondConnection->DeviceMessageCount()!=count) - { - TLogMessageText buf; - _LIT(KFailCount,"Event Mismatch, Exp=%d, Act=%d"); - buf.Format(KFailCount,count,iSecondConnection->DeviceMessageCount()); - TheClient->iWs.LogMessage(buf); - TheClient->iWs.Flush(); - } - retVal = iSecondConnection->DeviceMessageCount(); - TEST(retVal==count); - if (retVal!=count) - INFO_PRINTF3(_L("(iSecondConnection->DeviceMessageCount() return value - Expected: %d, Actual: %d"),count ,retVal); - - CheckWindows(iCurEnforcement==ESizeEnforcementNone?ETrue:checkWindowParam); - if (enable) - iSecondConnection->EnableMessages(); - if (disable) - iSecondConnection->DisableMessages(); - TheClient->iScreen->SetScreenMode(mode); - TheClient->iWs.Flush(); - iSubState++; - break; - case 102: -/** - @SYMTestCaseID GRAPHICS-WSERV-0521 -*/ - ((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0521")); - buf.Format(TRefByValue(_L("Screen mode %d:%d")),101,iSubState); - INFO_PRINTF1(buf); - checkWindowParam=EFalse; - enable=ETrue; - if (iCurEnforcement==ESizeEnforcementPixelsAndRotation) - count+=3; - else if (iCurEnforcement==ESizeEnforcementPixelsTwipsAndRotation) - count+=6; - if (iSecondConnection->DeviceMessageCount()!=count) - { - TLogMessageText buf; - _LIT(KFailCount,"Event Mismatch, Exp=%d, Act=%d"); - buf.Format(KFailCount,count,iSecondConnection->DeviceMessageCount()); - TheClient->iWs.LogMessage(buf); - TheClient->iWs.Flush(); - } - retVal = iSecondConnection->DeviceMessageCount(); - TEST(retVal==count); - if (retVal!=count) - INFO_PRINTF3(_L("(iSecondConnection->DeviceMessageCount() return value - Expected: %d, Actual: %d"),count ,retVal); - - if (enable) - iSecondConnection->EnableMessages(); - if (disable) - iSecondConnection->DisableMessages(); - TheClient->iScreen->SetScreenMode(mode); - TheClient->iWs.Flush(); - iSubState++; - break; - case 103: -/** - @SYMTestCaseID GRAPHICS-WSERV-0522 -*/ - ((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0522")); - buf.Format(TRefByValue(_L("Screen mode %d:%d")),101,iSubState); - INFO_PRINTF1(buf); - count=1; - mode=1; - checkWindowParam=ETrue; - if (iCurEnforcement==ESizeEnforcementPixelsAndRotation) - count+=3; - else if (iCurEnforcement==ESizeEnforcementPixelsTwipsAndRotation) - count+=6; - if (iSecondConnection->DeviceMessageCount()!=count) - { - TLogMessageText buf; - _LIT(KFailCount,"Event Mismatch, Exp=%d, Act=%d"); - buf.Format(KFailCount,count,iSecondConnection->DeviceMessageCount()); - TheClient->iWs.LogMessage(buf); - TheClient->iWs.Flush(); - } - retVal = iSecondConnection->DeviceMessageCount(); - TEST(retVal==count); - if (retVal!=count) - INFO_PRINTF3(_L("(iSecondConnection->DeviceMessageCount() return value - Expected: %d, Actual: %d"),count ,retVal); - - CheckWindows(iCurEnforcement==ESizeEnforcementNone?ETrue:checkWindowParam); - if (enable) - iSecondConnection->EnableMessages(); - if (disable) - iSecondConnection->DisableMessages(); - TheClient->iScreen->SetScreenMode(mode); - TheClient->iWs.Flush(); - iSubState++; - break; - case 104: -/** - @SYMTestCaseID GRAPHICS-WSERV-0523 -*/ - ((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0523")); - buf.Format(TRefByValue(_L("Screen mode %d:%d")),101,iSubState); - INFO_PRINTF1(buf); - checkWindowParam=ETrue; - count=2; - disable=ETrue; - if (iCurEnforcement==ESizeEnforcementPixelsAndRotation) - count+=3; - else if (iCurEnforcement==ESizeEnforcementPixelsTwipsAndRotation) - count+=6; - if (iSecondConnection->DeviceMessageCount()!=count) - { - TLogMessageText buf; - _LIT(KFailCount,"Event Mismatch, Exp=%d, Act=%d"); - buf.Format(KFailCount,count,iSecondConnection->DeviceMessageCount()); - TheClient->iWs.LogMessage(buf); - TheClient->iWs.Flush(); - } - retVal = iSecondConnection->DeviceMessageCount(); - TEST(retVal==count); - if (retVal!=count) - INFO_PRINTF3(_L("(iSecondConnection->DeviceMessageCount() return value - Expected: %d, Actual: %d"),count ,retVal); - - if (enable) - iSecondConnection->EnableMessages(); - if (disable) - iSecondConnection->DisableMessages(); - TheClient->iScreen->SetScreenMode(mode); - TheClient->iWs.Flush(); - iSubState++; - break; - case 105: -/** - @SYMTestCaseID GRAPHICS-WSERV-0524 -*/ - ((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0524")); - buf.Format(TRefByValue(_L("Screen mode %d:%d")),101,iSubState); - INFO_PRINTF1(buf); - checkWindowParam=EFalse; - count=2; - enable=ETrue; - if (iCurEnforcement==ESizeEnforcementPixelsAndRotation) - count+=3; - else if (iCurEnforcement==ESizeEnforcementPixelsTwipsAndRotation) - count+=6; - if (iSecondConnection->DeviceMessageCount()!=count) - { - TLogMessageText buf; - _LIT(KFailCount,"Event Mismatch, Exp=%d, Act=%d"); - buf.Format(KFailCount,count,iSecondConnection->DeviceMessageCount()); - TheClient->iWs.LogMessage(buf); - TheClient->iWs.Flush(); - } - retVal = iSecondConnection->DeviceMessageCount(); - TEST(retVal==count); - if (retVal!=count) - INFO_PRINTF3(_L("(iSecondConnection->DeviceMessageCount() return value - Expected: %d, Actual: %d"),count ,retVal); - - CheckWindows(iCurEnforcement==ESizeEnforcementNone?ETrue:checkWindowParam); - if (enable) - iSecondConnection->EnableMessages(); - if (disable) - iSecondConnection->DisableMessages(); - TheClient->iScreen->SetScreenMode(mode); - TheClient->iWs.Flush(); - - - iSecondConnection->DisableMessages(); - if (iCurEnforcement==ESizeEnforcementNone) - { // Do it again with different enforcement mode - SetScreenModeEnforcement(ESizeEnforcementPixelsAndRotation); - ResetCounter(100); - } - else if (iCurEnforcement==ESizeEnforcementPixelsAndRotation) - { // Do it again with different enforcement mode - SetScreenModeEnforcement(ESizeEnforcementPixelsTwipsAndRotation); - ResetCounter(100); - } - else - { - SetScreenModeEnforcement(ESizeEnforcementNone); - delete iSecondConnection; - iSecondConnection=NULL; - } - TheClient->iWs.Flush(); - break; -/** - - @SYMTestCaseID GRAPHICS-WSERV-0302 - - @SYMDEF DEF099638 - - @SYMTestCaseDesc Test that a drawing can be scaled while different screen - modes are set - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions Set different screen modes and scale a drawing - - @SYMTestExpectedResults The drawing is redrawn to scale - -*/ - case 110: - { - ((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0302")); - // Ensure that the TestWin and BaseWin will be drawn properly in all screen modes - SetScreenModeEnforcement(ESizeEnforcementPixelsAndRotation); - TheClient->SetTestClientScreenMode(0); - INFO_PRINTF1(_L("Scaled drawing - screen mode 0")); - ScaledDrawingL(); - TheClient->SetTestClientScreenMode(1); - INFO_PRINTF1(_L("Scaled drawing - screen mode 1")); - ScaledDrawingL(); - // Restore screen mode and enforcement mode - TheClient->SetTestClientScreenMode(0); - SetScreenModeEnforcement(iOldEnfMode); - break; - } - -/** - - @SYMTestCaseID GRAPHICS-WSERV-0303 - - @SYMDEF DEF081259 - - @SYMTestCaseDesc Test screen mode and rotation panic messages - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions Test the panics fro screen mode and rotation respond as - expected - - @SYMTestExpectedResults Panics respond as expected - -*/ - case 111: - ((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0303")); - INFO_PRINTF1(_L("Panic")); - TestPanicsL(); - break; -#endif -/** - - @SYMTestCaseID GRAPHICS-WSERV-0304 - - @SYMDEF DEF081259 - - @SYMTestCaseDesc Test that if there are invisible windows and then the - screen mode is changed, the windows are redrawn correctly - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions Create some windows, make some invisible, change the screen - mode and redraw the windows - - @SYMTestExpectedResults The windows are redrawn without error - -*/ - case 112: - ((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0304")); - INFO_PRINTF1(_L("Invisible Wnds And Infinite Redraw Bugs")); // two defects one problem - InvisibleWndAndInfiniteRedrawBugL(); - break; -/** - - @SYMTestCaseID GRAPHICS-WSERV-0358 - - @SYMDEF PDEF096151 - - @SYMTestCaseDesc Ensure that wserv does not panic when calling CWsScreenDevice::SetScreenMode() - after a client has deleted a screen device used by an active group window - - @SYMTestPriority Critical - - @SYMTestStatus Implemented - - @SYMTestActions Creates a RWsSession - Creates a primary screen device - Creates another screen device - Creates a group window - Gets all the valid screen modes - Deletes the primary screen device - Calls SetScreenMode on the second screen device - (this step triggered the defect - panicking wserv) - Cleans up the above - - @SYMTestExpectedResults The call to SetScreenMode should not cause wserv to panic - -*/ - case 113: - ((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0358")); - INFO_PRINTF1(_L("Set screen mode after a client has deleted the screen device")); - SetScreenModeAfterScreenDeviceDeletedL(); - break; - case 114: - INFO_PRINTF1(_L("Rotate/screen mode test")); -/** - @SYMTestCaseID GRAPHICS-WSERV-0525 -*/ - ((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0525")); - TestRotateAndScreenModeL(); - break; - default: - ((CTScrModeStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - if (iTest->iState==115 || iTest->iState>1000) - TestComplete(); - break; - } - ((CTScrModeStep*)iStep)->RecordTestResultL(); - } - -// -// CSecondConnection -// - -CSecondConnection::~CSecondConnection() - { - delete iWindow; - delete iWindow2; - iGroup->GroupWin()->EnableReceiptOfFocus(EFalse); // Stop auto group switching on close - delete iGroup; - delete iClient; - } - -void CSecondConnection::ConstructL(TInt aScreenNumber,const TRect &aWinRect, CTestBase *aTest, CTestStep* aTestStep) - { - iClient=new(ELeave) CTClient; - iClient->SetScreenNumber(aScreenNumber); - iClient->ConstructL(); - iGroup=new(ELeave) CSecondConnectionGroup(iClient,this,aTest,aTestStep); - iGroup->ConstructL(); -// - iWindow=new(ELeave) CTBlankWindow; - iWindow->ConstructL(*iGroup); - iWindow->BaseWin()->SetShadowDisabled(ETrue); - iWindow->SetColor(TRgb::Gray4(1)); - TPoint offset=BaseWin->BaseWin()->InquireOffset((*iGroup->GroupWin())); - iWindow->SetExtL(offset+aWinRect.iTl,aWinRect.Size()); - iWindow->Activate(); -// - iWindow2=new(ELeave) CTBlankWindow; - iWindow2->ConstructL(*iGroup); - iWindow2->BaseWin()->SetShadowDisabled(ETrue); - iWindow2->SetColor(TRgb::Gray4(1)); - TPoint offset2=TestWin->BaseWin()->InquireOffset((*iGroup->GroupWin())); - iWindow2->SetExtL(offset2+aWinRect.iTl,aWinRect.Size()); - iWindow2->BaseWin()->SetVisible(EFalse); - iWindow2->Activate(); - } - -void CSecondConnection::SetWindow2Visibility(TBool aVisible) - { - iWindow2->BaseWin()->SetVisible(aVisible); - iClient->iWs.Flush(); - iClient->iWs.Finish(); - } - -void CSecondConnection::EnableMessages() - { - iGroup->GroupWin()->EnableScreenChangeEvents(); - iClient->iWs.Flush(); - } - -void CSecondConnection::DisableMessages() - { - iGroup->GroupWin()->DisableScreenChangeEvents(); - iClient->iWs.Flush(); - } - -TInt CSecondConnection::DeviceMessageCount() const - { - return(iMessageCount); - } - -void CSecondConnection::ScreenDeviceChanged() - { - iMessageCount++; - } - -// -// CSecondConnectionGroup -// - -CSecondConnectionGroup::CSecondConnectionGroup(CTClient *aClient, CSecondConnection *aSecondConnection, CTestBase *aTest, CTestStep* aTestStep) : CTWindowGroup(aClient), iTest(aTest), iSecondConnection(aSecondConnection), iTestStep(aTestStep) - {} - -void CSecondConnectionGroup::ScreenDeviceChanged() - { - iSecondConnection->ScreenDeviceChanged(); - TPixelsTwipsAndRotation sar; - Client()->iScreen->GetDefaultScreenSizeAndRotation(sar); - Client()->iScreen->SetScreenSizeAndRotation(sar); -// - iTestStep->TEST(Client()->iScreen->SizeInPixels()==sar.iPixelSize); - iTestStep->TEST(Client()->iScreen->SizeInTwips()==sar.iTwipsSize); - TSize pixelConv; - pixelConv.iWidth=Client()->iScreen->HorizontalTwipsToPixels(sar.iTwipsSize.iWidth); - pixelConv.iHeight=Client()->iScreen->VerticalTwipsToPixels(sar.iTwipsSize.iHeight); - iTestStep->TEST(pixelConv==sar.iPixelSize); - } - - -// -// SecondClientConnection -// - -SecondClientConnection::SecondClientConnection() - { - } - -SecondClientConnection::~SecondClientConnection() - { - } - -void SecondClientConnection::ConstructL(TInt aScreenMode, const TPixelsTwipsAndRotation& aSizeAndRotation) - { - CTClient::ConstructL(); - iGroup=new(ELeave) TestWindowGroup(this); - iGroup->ConstructL(); - iScreen->SetScreenModeEnforcement(ESizeEnforcementPixelsAndRotation); - iScreen->SetScreenSizeAndRotation(aSizeAndRotation); - iScreen->SetScreenMode(aScreenMode); - } - -__WS_CONSTRUCT_STEP__(ScrMode) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TSCRMODE.H --- a/windowing/windowserver/tauto/TSCRMODE.H Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,128 +0,0 @@ - -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef __TSCRMODE_H__ -#define __TSCRMODE_H__ - -#include -#include -#include "../tlib/testbase.h" -#include "AUTO.H" -#include "TGraphicsHarness.h" - -class CSecondConnection; - -class CSecondConnectionGroup : public CTWindowGroup - { -public: - CSecondConnectionGroup(CTClient *aClient, CSecondConnection *aSecondConnection, CTestBase *aTest, CTestStep* aTestStep); - void ScreenDeviceChanged(); -private: - CTestBase *iTest; - CSecondConnection *iSecondConnection; - CTestStep* iTestStep; - }; - -class CSecondConnection : public CBase - { -public: - ~CSecondConnection(); - void ConstructL(TInt aScreenNumber,const TRect &aWinRect, CTestBase *aTest, CTestStep* aTestStep); - void EnableMessages(); - void DisableMessages(); - TInt DeviceMessageCount() const; - void ScreenDeviceChanged(); - void SetWindow2Visibility(TBool aVisible); -public: - CSecondConnectionGroup *iGroup; -private: - CTClient *iClient; - CTBlankWindow *iWindow; - CTBlankWindow *iWindow2; - TInt iMessageCount; - }; - -class SecondClientConnection : public CTClient - { -public: - SecondClientConnection(); - ~SecondClientConnection(); - void ConstructL(TInt aScreenMode, const TPixelsTwipsAndRotation &aSizeAndRotation); - }; - -class CTScrMode : public CTWsGraphicsBase - { -public: - CTScrMode(CTestStep* aStep); - ~CTScrMode(); -protected: -//from CTGraphicsStep - virtual void RunTestCaseL(TInt aCurTestCase); -private: - void ConstructL(); - void doMoveWindowTest(); - TBool MoveWindow(); - void TestPanicsL(); - void ScaledDrawingL(); - void SetScreenModeEnforcement(TScreenModeEnforcement aMode); - void CheckWindows(TBool aWinIsVis); - void ValidateWin(TestWindow *aWin, TRgb aColor); - void RedrawWin(RWindow &aWin, TRgb aColor); - void ScreenRotationsL(); - void MoreScreenRotationsL(); - TBool RectClearBugL(); - void ScreenModeChange1L(); - void ScreenModeChange2L(); - TInt FindCurrentMode(); - TBool Equal(const TPixelsTwipsAndRotation& aLeft,const TPixelsTwipsAndRotation& aRight); - void InvisibleWndAndInfiniteRedrawBugL(); - void GetScreenDisplayMode(); - void SetScreenModeAfterScreenDeviceDeletedL(); - void TestRotateAndScreenModeL(); -private: - void DrawTestBmpL(CFbsBitmap* aTestBitmap); - void TestDrawingToWindows(CWindowGc* aWinGc1, CWindowGc* aWinGc2, RWindow& aWindow1,RWindow& aWindow2,CFbsBitmap* aBitmap64K,CFbsBitmap* aBitmap16M,CFbsFont* aFont,TBool aAllInRedraw, TBool aUseSystemGc, TBool aUseBmp16M); -private: - TInt iSubState; - CSecondConnection *iSecondConnection; - TSize iWinSize; - TPoint iWinPos; - TInt iWinState; - TScreenModeEnforcement iOldEnfMode; - TScreenModeEnforcement iCurEnforcement; - }; - - - -class CTScrModeStep : public CTGraphicsStep - { -public: - CTScrModeStep(); -protected: - //from CTGraphicsStep - virtual CTGraphicsBase* CreateTestL(); - }; - -_LIT(KTScrModeStep,"TScrMode"); - - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TSCROLL.CPP --- a/windowing/windowserver/tauto/TSCROLL.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,850 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Window scroll tests -// -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include "TSCROLL.H" - -#pragma warning(disable : 4710) - -// -// Scroll window, used to test the Scroll() command -// - -void DrawScrollWin(CBitmapContext *aGc, const TPoint &aOffset, const TSize &aSize) - { - aGc->Clear(); - TPoint drawBase(-10,-20); - TSize drawSize(aSize.iWidth-2*drawBase.iX,aSize.iHeight-2*drawBase.iY); - aGc->DrawRect(TRect(drawBase,drawBase+drawSize)); - TPoint offset=drawBase+aOffset; - aGc->SetPenColor(TRgb::Gray4(2)); -// aGc->SetDrawMode(CGraphicsContext::EDrawModeXOR); - aGc->DrawRect(TRect(offset+TPoint(13,23),offset+TPoint(22,32))); - TInt xpos,xplus; - for(xpos=0,xplus=2;xposDrawLine(TPoint(xpos,0)+offset,TPoint(xpos,drawSize.iHeight)+offset); - for(TInt ypos=0,yplus=2;yposDrawLine(TPoint(0,ypos)+offset,TPoint(drawSize.iWidth,ypos)+offset); -// - aGc->SetPenColor(TRgb(0,0,0)); - aGc->SetDrawMode(CGraphicsContext::EDrawModePEN); - TheClient->iWs.Flush(); - for(xpos=0;xposDrawLine(TPoint(xpos,0)+offset,TPoint(drawSize.iWidth,xpos*drawSize.iHeight/drawSize.iWidth)+offset); - aGc->DrawLine(TPoint(xpos,0)+offset,TPoint(0,drawSize.iHeight-xpos*drawSize.iHeight/drawSize.iWidth)+offset); - aGc->DrawLine(TPoint(xpos,drawSize.iHeight)+offset,TPoint(drawSize.iWidth,drawSize.iHeight-xpos*drawSize.iHeight/drawSize.iWidth)+offset); - aGc->DrawLine(TPoint(xpos,drawSize.iHeight)+offset,TPoint(0,xpos*drawSize.iHeight/drawSize.iWidth)+offset); - } - - } - -CScrollWindowNorm::CScrollWindowNorm() : CTWin() - { - } - -void DrawScrollWin(const TPoint &aOffset, const TSize &aSize) - { - ::DrawScrollWin(TheClient->iGc, aOffset, aSize); - } - -void CScrollWindowNorm::Draw() - { - DrawScrollWin(iScrollTest->Offset(), Size()); - } - -void CScrollWindowNorm::SetScrollTest(CScrollTestBase *aScrollTest) - { - iScrollTest=aScrollTest; - } - -// -// CScrollWindowBackedUp -// - -CScrollWindowBackedUp::CScrollWindowBackedUp(TDisplayMode aDisplayMode) : CTBackedUpWin(aDisplayMode) - { - } - -void CScrollWindowBackedUp::Draw() - { - DrawScrollWin(iScrollTest->Offset(), Size()); - } - -void CScrollWindowBackedUp::SetScrollTest(CScrollTestBase *aScrollTest) - { - iScrollTest=aScrollTest; - } - -// -// CScrollTestBase -// - -void CScrollTestBase::Reset() - { - iOffset=TPoint(0,0); - iInvalid.Clear(); - } - -void CScrollTestBase::DoInvalidate() - { - } - -TPoint CScrollTestBase::Offset() const - { - return(iOffset); - } - -CScrollTestBase::~CScrollTestBase() - { - delete iBlankWin; - iInvalid.Close(); - } - -void CScrollTestBaseNorm::ConstructL(const TPoint &aPos, const TSize &aSize) - { - iScrollWin=new(ELeave) CScrollWindowNorm(); - iScrollWin->SetUpL(aPos, aSize, TheClient->iGroup, *TheClient->iGc); - iScrollWin->SetScrollTest(this); - iSize=iScrollWin->Size(); - } - -CScrollTestBaseNorm::~CScrollTestBaseNorm() - { - delete iScrollWin; - } - -void CScrollTestBaseNorm::Redraw() - { - iScrollWin->Redraw(); - } - -void CScrollTestBaseNorm::Reset() - { - iScrollWin->Win()->Invalidate(); - iScrollWin->Redraw(); - CScrollTestBase::Reset(); - } - -CTDrawableWin *CScrollTestBaseNorm::ScrollWin() const - { - return(iScrollWin); - } - -void CScrollTestBaseNorm::AdjustTestScrollRegion(const TRect &aClipRect, const TPoint &aOffset, const TRect &aRect) - { - RRegion clipped_visible; - VisibleRegion(clipped_visible); - clipped_visible.ClipRect(aClipRect); -// -// - RRegion invalidate(aRect); - invalidate.SubRegion(clipped_visible); - invalidate.Offset(aOffset); - invalidate.ClipRect(aClipRect); -// - RRegion invalidate2(aRect); - invalidate2.ClipRect(aClipRect); - invalidate2.Intersect(iInvalid); - invalidate2.Offset(aOffset); - invalidate2.ClipRect(aClipRect); -// - RRegion validate(aRect); - validate.Intersect(clipped_visible); - validate.SubRegion(iInvalid); - validate.Offset(aOffset); - validate.ClipRect(aClipRect); -// - iInvalid.SubRegion(validate); - iInvalid.Union(invalidate); - iInvalid.Union(invalidate2); - RRegion visible; - VisibleRegion(visible); - iInvalid.Intersect(visible); - iInvalid.Tidy(); -// - invalidate2.Close(); - invalidate.Close(); - validate.Close(); - visible.Close(); - clipped_visible.Close(); - - iOffset+=aOffset; - } - -void CScrollTestBaseNorm::VisibleRegion(RRegion &aRegion) - { - aRegion.Clear(); - aRegion.AddRect(TRect(iSize)); - TRect child; - child.iTl=iBlankWin->BaseWin()->InquireOffset(*ScrollWin()->BaseWin()); - child.iBr=child.iTl+iBlankWin->BaseWin()->Size(); - aRegion.SubRect(child); - } - -void CScrollWindow1::DoTestScroll(const TRect &aClipRect, const TPoint &aOffset, const TRect &aRect) - { - TheGc->Activate(*iScrollWin->DrawableWin()); - RRegion region(aRect); - RRegion visible; - VisibleRegion(visible); - visible.ClipRect(aClipRect); - region.Intersect(visible); - visible.Close(); - region.SubRegion(iInvalid); - region.Offset(aOffset); - region.ClipRect(aClipRect); - TheGc->SetClippingRegion(region); - TheGc->CopyRect(aOffset,aRect); - TheGc->Deactivate(); - AdjustTestScrollRegion(aClipRect, aOffset,aRect); - iInvalid.Union(TRegionFix<1>(TRect(aClipRect))); - region.Close(); - } - -void CScrollWindow1::DoTestScroll(const TPoint &aOffset) - { - DoTestScroll(TRect(TPoint(0,0),iSize), aOffset,TRect(-aOffset,iSize)); - } - -void CScrollWindow1::DoTestScroll(const TPoint &aOffset, const TRect &aRect) - { - DoTestScroll(TRect(TPoint(0,0),iSize), aOffset, aRect); - } - -void CScrollWindow1::DoTestScroll(const TRect &aClipRect, const TPoint &aOffset) - { - DoTestScroll(aClipRect, aOffset, TRect(-aOffset.iX,-aOffset.iY,iSize.iWidth-aOffset.iX, iSize.iHeight-aOffset.iY)); - } - -void CScrollWindow1::DoInvalidate() - { - for(TInt index=0;indexInvalidate(iInvalid[index]); - } - -void CScrollWindow2::Reset() - { - CScrollTestBaseNorm::Reset(); - iClipped=EFalse; - } - -CScrollWindow2::CScrollWindow2(CTScroll *aTest) : iTest(aTest) - { - } - -void CScrollWindow2::Draw() - { - if (iClipped) - TheClient->iGc->SetClippingRegion(iInvalid); - iScrollWin->Draw(); - if (iClipped) - TheClient->iGc->CancelClippingRegion(); - } - -void CScrollWindow2::DoTestScroll(const TPoint &aOffset) - { - AdjustTestScrollRegion(TRect(iSize), aOffset, TRect(-aOffset.iX,-aOffset.iY,iSize.iWidth-aOffset.iX, iSize.iHeight-aOffset.iY)); - iClipped=ETrue; - iScrollWin->DrawableWin()->Scroll(aOffset); - } - -void CScrollWindow2::DoTestScroll(const TRect &aClipRect, const TPoint &aOffset) - { - AdjustTestScrollRegion(aClipRect, aOffset, TRect(-aOffset.iX,-aOffset.iY,iSize.iWidth-aOffset.iX, iSize.iHeight-aOffset.iY)); - iClipped=ETrue; - iScrollWin->DrawableWin()->Scroll(aClipRect, aOffset); - } - -void CScrollWindow2::DoTestScroll(const TPoint &aOffset, const TRect &aRect) - { - AdjustTestScrollRegion(TRect(iSize), aOffset, aRect); - iClipped=ETrue; - iScrollWin->DrawableWin()->Scroll(aOffset, aRect); - } - -void CScrollWindow2::DoTestScroll(const TRect &aClipRect, const TPoint &aOffset, const TRect &aRect) - { - AdjustTestScrollRegion(aClipRect, aOffset, aRect); - iClipped=ETrue; - iScrollWin->DrawableWin()->Scroll(aClipRect, aOffset, aRect); - } - -void CScrollWindow3::DrawScrollBit() - { - ::DrawScrollWin(iBitmapGc, iOffset, iSize); - } - -void CScrollWindow3::Reset() - { - CScrollTestBase::Reset(); - iBitmapGc->Clear(TRect(iSize)); - DrawScrollBit(); - DoInvalidate(); - } - -CScrollWindow3::~CScrollWindow3() - { - delete iBitmapGc; - delete iBitmapDevice; - delete iBitmap; - } - -void CScrollWindow3::ConstructL(const TPoint &aPos, const TSize &aSize) - { - CScrollTestBaseNorm::ConstructL(aPos,aSize); - iBitmap=new(ELeave) CFbsBitmap(); - User::LeaveIfError(iBitmap->Create(iSize,EGray4)); - iBitmapDevice=CFbsBitmapDevice::NewL(iBitmap); - User::LeaveIfError(iBitmapDevice->CreateContext(iBitmapGc)); - DrawScrollBit(); - } - -void CScrollWindow3::DoTestScroll(const TRect &aClipRect, const TPoint &aOffset, const TRect &aRect) - { - iOffset+=aOffset; - RRegion blank(aRect); - TRect clipRect(aClipRect); - clipRect.Intersection(TRect(iSize)); - blank.SubRect(clipRect); - blank.Offset(aOffset); - blank.ClipRect(clipRect); - TRect rect(aRect); - rect.Intersection(clipRect); - TRect rect2(clipRect); - rect2.Move(-aOffset); - rect.Intersection(rect2); - iBitmapGc->CopyRect(aOffset,rect); - iBitmapGc->SetClippingRegion(&blank); - iBitmapGc->Clear(TRect(iSize)); - iBitmapGc->SetClippingRegion(NULL); - blank.Close(); - } - -void CScrollWindow3::DoTestScroll(const TPoint &aOffset) - { - DoTestScroll(TRect(iSize), aOffset,TRect(-aOffset.iX,-aOffset.iY,iSize.iWidth-aOffset.iX, iSize.iHeight-aOffset.iY)); - } - -void CScrollWindow3::DoTestScroll(const TPoint &aOffset, const TRect &aRect) - { - DoTestScroll(TRect(iSize), aOffset, aRect); - } - -void CScrollWindow3::DoTestScroll(const TRect &aClipRect, const TPoint &aOffset) - { - DoTestScroll(aClipRect, aOffset, TRect(-aOffset.iX,-aOffset.iY,iSize.iWidth-aOffset.iX, iSize.iHeight-aOffset.iY)); - } - -void CScrollWindow3::Draw() - { - TheGc->BitBlt(TPoint(),iBitmap); - } - -void CScrollWindow3::DoInvalidate() - { - RWindow win=*iScrollWin->Win(); - win.Invalidate(); - win.BeginRedraw(); - TheGc->Activate(win); - Draw(); - TheGc->Deactivate(); - win.EndRedraw(); - } - -void CScrollWindow4::ConstructL(const TPoint &aPos, const TSize &aSize) - { - iScrollWin=new(ELeave) CScrollWindowBackedUp(EGray4); - iScrollWin->SetUpL(aPos, aSize, TheClient->iGroup, *TheClient->iGc); - iScrollWin->SetScrollTest(this); - iSize=iScrollWin->Size(); - TheClient->iGc->Activate(*iScrollWin->DrawableWin()); - TheClient->iGc->Clear(); - DrawScrollWin(TPoint(), iSize); - TheClient->iGc->Deactivate(); - } - -CScrollWindow4::~CScrollWindow4() - { - delete iScrollWin; - } - -void CScrollWindow4::Redraw() - { - } - -void CScrollWindow4::Reset() - { - TheClient->iGc->Activate(*iScrollWin->DrawableWin()); - TheClient->iGc->Clear(); - DrawScrollWin(TPoint(), iSize); - TheClient->iGc->Deactivate(); - CScrollTestBase::Reset(); - } - -void CScrollWindow4::DoTestScroll(const TPoint &aOffset) - { - iScrollWin->DrawableWin()->Scroll(aOffset); - iOffset+=aOffset; - } - -void CScrollWindow4::DoTestScroll(const TPoint &aOffset, const TRect &aRect) - { - iScrollWin->DrawableWin()->Scroll(aOffset, aRect); - iOffset+=aOffset; - } - -void CScrollWindow4::DoTestScroll(const TRect &aClipRect, const TPoint &aOffset) - { - iScrollWin->DrawableWin()->Scroll(aClipRect, aOffset); - iOffset+=aOffset; - } - -void CScrollWindow4::DoTestScroll(const TRect &aClipRect, const TPoint &aOffset, const TRect &aRect) - { - iScrollWin->DrawableWin()->Scroll(aClipRect, aOffset, aRect); - iOffset+=aOffset; - } - -CTDrawableWin *CScrollWindow4::ScrollWin() const - { - return(iScrollWin); - } - -// - -CTScroll::CTScroll(CTestStep* aStep): - CTWsGraphicsBase(aStep) - { - } - -CTScroll::~CTScroll() - { - BaseWin->SetVisible(ETrue); - TestWin->SetVisible(ETrue); - delete iBaseScrollWin; - delete iTestScrollWin; - } - -void CTScroll::ConstructL() - { - BaseWin->SetVisible(EFalse); - TestWin->SetVisible(EFalse); -// - iTest->iState=1; - TSize screenSize=TheClient->iGroup->Size(); - TInt winWidth=(screenSize.iWidth/3)-10; - TInt winHeight=screenSize.iHeight-10; - TInt winBaseX=(screenSize.iWidth/3); - if (iMode==0) - { - iBaseScrollWin=new(ELeave) CScrollWindow1(); - iTestScrollWin=new(ELeave) CScrollWindow2(this); - } - else - { - iBaseScrollWin=new(ELeave) CScrollWindow3(); - iTestScrollWin=new(ELeave) CScrollWindow4(); - } - iWinSize=TSize(winWidth,winHeight); - iBaseScrollWin->ConstructL(TPoint(winBaseX+5,5),iWinSize); - iTestScrollWin->ConstructL(TPoint(winBaseX+winWidth+15,5),iWinSize); - - iBaseScrollWin->iBlankWin=new(ELeave) CTBlankWindow(); - iBaseScrollWin->iBlankWin->SetUpL(iBaseScrollWin->ScrollWin()->BaseWin()->InquireOffset(*TheClient->iGroup->GroupWin())+TPoint(winWidth>>2,winHeight>>2),TSize(winWidth>>2,winHeight>>1),TheClient->iGroup,*TheClient->iGc); - iBaseScrollWin->iBlankWin->BlankWin()->SetShadowHeight(2); - - iTestScrollWin->iBlankWin=new(ELeave) CTBlankWindow(); - iTestScrollWin->iBlankWin->SetUpL(iTestScrollWin->ScrollWin()->BaseWin()->InquireOffset(*TheClient->iGroup->GroupWin())+TPoint(winWidth>>2,winHeight>>2),TSize(winWidth>>2,winHeight>>1),TheClient->iGroup,*TheClient->iGc); - } - -void CTScroll::CheckScrollWindows() - { - CheckRect(iBaseScrollWin->ScrollWin(),iTestScrollWin->ScrollWin(),TRect(iBaseScrollWin->ScrollWin()->Size()),_L("CTScroll::CheckScrollWindows()")); - } - -void CTScroll::DoTestScroll(const TPoint &aOffset) - { - iTestScrollWin->DoTestScroll(aOffset); - iBaseScrollWin->DoTestScroll(aOffset); - } - -void CTScroll::DoTestScroll(const TRect &aClipRect, const TPoint &aOffset) - { - iTestScrollWin->DoTestScroll(aClipRect,aOffset); - iBaseScrollWin->DoTestScroll(aClipRect,aOffset); - } - -void CTScroll::DoTestScroll(const TPoint &aOffset, const TRect &aRect) - { - iTestScrollWin->DoTestScroll(aOffset,aRect); - iBaseScrollWin->DoTestScroll(aOffset,aRect); - } - -void CTScroll::DoTestScroll(const TRect &aClipRect, const TPoint &aOffset, const TRect &aRect) - { - iTestScrollWin->DoTestScroll(aClipRect,aOffset,aRect); - iBaseScrollWin->DoTestScroll(aClipRect,aOffset,aRect); - } - -void CTScroll::FinishedRectScrolls() - { - iBaseScrollWin->DoInvalidate(); - } - -void CTScroll::CheckOomScroll() - { - TheClient->iWs.HeapSetFail(RHeap::ENone,0); - FinishedRectScrolls(); - iTestScrollWin->Redraw(); - iBaseScrollWin->Redraw(); -// if (iMode!=1) // Out of memory scrolling of backed up windows can not work 100% when out of memory -// CheckScrollWindows(); // Redraw window code can't check these cases properly yet - } - -void CTScroll::OomScrolling() - { - iTestScrollWin->iBlankWin->BaseWin()->SetShadowHeight(0); - iBaseScrollWin->iBlankWin->BaseWin()->SetShadowHeight(0); - iTestScrollWin->ScrollWin()->BaseWin()->SetShadowHeight(0); - iTestScrollWin->Redraw(); - iBaseScrollWin->Redraw(); - for(TInt count=1;count<20;count++) - { - TheClient->iWs.HeapSetFail(RHeap::EDeterministic,count); - DoTestScroll(TPoint(50,0)); - CheckOomScroll(); - // - TheClient->iWs.HeapSetFail(RHeap::EDeterministic,count); - iTestScrollWin->Reset(); - iBaseScrollWin->Reset(); - DoTestScroll(TPoint(-6,-14),TRect(20,20,100,50)); - CheckOomScroll(); - // - TheClient->iWs.HeapSetFail(RHeap::EDeterministic,count); - iTestScrollWin->Reset(); - iBaseScrollWin->Reset(); - DoTestScroll(TRect(TPoint(1,1),iWinSize-TSize(1,1)),TPoint(50,0),TRect(10,10,50,50)); - CheckOomScroll(); - } - } - -void CTScroll::RunTestCaseL(TInt /*aCurTestCase*/) - { - _LIT(KScroll,"Scroll"); - //if (iTest->iState==0) iTest->iState=22; - if (iDoCheck) - { - if (iMode==1) // The test code does not mimic scrolling to a non-backed up window properly - { - TheClient->iWs.Flush(); - TheClient->iWs.Finish(); - CheckScrollWindows(); - } - iTestScrollWin->Reset(); - iBaseScrollWin->Reset(); - TheClient->iWs.Flush(); - ++iTest->iState; - iDoCheck=EFalse; - return; - } - ((CTScrollStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); - switch(iTest->iState) - { -/** -@SYMTestCaseID GRAPHICS-WSERV-0249 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test window scrolling by different offsets - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Pass different offsets for scrolling a window by and - check the window is scrolled correctly - -@SYMTestExpectedResults Window scrolls correctly to offsets -*/ - case 1: - ((CTScrollStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0249")); - //DemoWindowScroll(); - iTest->LogSubTest(KScroll); - DoTestScroll(TPoint(6,0)); - DoTestScroll(TPoint(-6,-14)); - DoTestScroll(TPoint(-6,-14)); - DoTestScroll(TPoint(0,10)); - DoTestScroll(TPoint(0,0)); - DoTestScroll(TPoint(10,23)); - break; - case 2: - ((CTScrollStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0249")); - iTest->LogSubTest(KScroll); - DoTestScroll(TPoint(50,0)); - break; - case 3: - ((CTScrollStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0249")); - iTest->LogSubTest(KScroll); - DoTestScroll(TPoint(0,33)); - break; - case 4: - ((CTScrollStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0249")); - iTest->LogSubTest(KScroll); - DoTestScroll(TPoint(-10,0)); - break; - case 5: - ((CTScrollStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0249")); - iTest->LogSubTest(KScroll); - DoTestScroll(TPoint(0,-13)); - break; - case 6: - ((CTScrollStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0249")); - iTest->LogSubTest(KScroll); - DoTestScroll(TPoint(0,0)); - break; - case 7: - ((CTScrollStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0249")); - iTest->LogSubTest(KScroll); - DoTestScroll(TPoint(-234,-1400)); - break; - case 8: - ((CTScrollStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0249")); - iTest->LogSubTest(KScroll); - DoTestScroll(TPoint(-69,15)); - break; - case 9: - ((CTScrollStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0249")); - iTest->LogSubTest(KScroll); - DoTestScroll(TPoint(-234,-1400)); - DoTestScroll(TPoint(233,1401)); - break; - case 10: - ((CTScrollStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0249")); - iTest->LogSubTest(KScroll); - DoTestScroll(TPoint(10,-1)); - DoTestScroll(TPoint(11,-10)); - DoTestScroll(TPoint(-5,-40)); - DoTestScroll(TPoint(0,50)); - break; - -/** -@SYMTestCaseID GRAPHICS-WSERV-0250 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test window scrolling by different offsets and - source rectangles - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Pass different offsets for scroll a window by and - different source rectangles. - Check the window is scrolled correctly - -@SYMTestExpectedResults Window scrolls correctly to offsets and source - rectangles -*/ - case 11: - ((CTScrollStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0250")); - iTest->LogSubTest(KScroll); - DoTestScroll(TPoint(-6,-14),TRect(20,20,100,50)); - DoTestScroll(TPoint(-6,-14),TRect(20,20,100,50)); - DoTestScroll(TPoint(-6,-14),TRect(40,10,130,130)); - break; - case 12: - ((CTScrollStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0250")); - iTest->LogSubTest(KScroll); - DoTestScroll(TPoint(10,-1),TRect(20,20,21,21)); - break; - case 13: - ((CTScrollStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0250")); - iTest->LogSubTest(KScroll); - DoTestScroll(TPoint(-20,-14),TRect(10,10,10,10)); - break; - case 14: - ((CTScrollStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0250")); - iTest->LogSubTest(KScroll); - DoTestScroll(TPoint(-6,-14),TRect(20,20,200,300)); - DoTestScroll(TPoint(10,-24),TRect(20,20,200,300)); - DoTestScroll(TPoint(3,12),TRect(20,20,200,300)); - DoTestScroll(TPoint(-20,19),TRect(20,20,200,300)); - break; - case 15: - ((CTScrollStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0250")); - iTest->LogSubTest(KScroll); - DoTestScroll(TPoint(-6,-14),TRect(20000,200000,30000,300000)); - DoTestScroll(TPoint(10,-24),TRect(20,20,-200,-300)); - DoTestScroll(TPoint(10,-24),TRect(20,20,-200,300)); - DoTestScroll(TPoint(10,-24),TRect(20,20,200,-300)); - DoTestScroll(TPoint(3,12),TRect(-100,-200,1000,2000)); - DoTestScroll(TPoint(-20,19),TRect(0,0,0,0)); - break; - -/** -@SYMTestCaseID GRAPHICS-WSERV-0251 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test window scrolling by different offsets and - clipping rectangles - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Pass different offsets for scroll a window by and - different clipping rectangles. - Check the window is scrolled correctly - -@SYMTestExpectedResults Window scrolls correctly to offsets and clipping - rectangles -*/ - case 16: - ((CTScrollStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0251")); - iTest->LogSubTest(KScroll); - DoTestScroll(TRect(10,10,200,200),TPoint(-6,-14)); - break; - case 17: - ((CTScrollStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0251")); - iTest->LogSubTest(KScroll); - DoTestScroll(TRect(10,50,210,200),TPoint(10,20)); - DoTestScroll(TRect(0,0,100,100),TPoint(-22,4)); - DoTestScroll(TRect(50,50,300,500),TPoint(-5,-2)); - break; - case 18: - ((CTScrollStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0251")); - iTest->LogSubTest(KScroll); - DoTestScroll(TRect(-1000,-10000,23456,1111),TPoint(-6,-14)); - break; - case 19: - ((CTScrollStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0251")); - iTest->LogSubTest(KScroll); - DoTestScroll(TRect(20,5,198,202),TPoint(-100,1)); - DoTestScroll(TRect(1,1,200,123),TPoint(2,1)); - DoTestScroll(TRect(23,23,200,400),TPoint(5,-1)); - break; - case 20: - ((CTScrollStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0251")); - iTest->LogSubTest(KScroll); - DoTestScroll(TRect(0,0,0,0),TPoint(-10,1)); - DoTestScroll(TRect(-1000,1,2000,123),TPoint(2,1)); - DoTestScroll(TRect(23,-23,200,40000),TPoint(5,-1)); - DoTestScroll(TRect(-1000,-10000,23456,1111),TPoint(-6,-14)); - break; - -/** -@SYMTestCaseID GRAPHICS-WSERV-0252 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test window scrolling by different offsets and - clipping ans source rectangles - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Pass different offsets for scroll a window by and - different clipping and source rectangles. - Check the window is scrolled correctly - -@SYMTestExpectedResults Window scrolls correctly to offsets and source - and clipping rectangles -*/ - case 21: - ((CTScrollStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0252")); - iTest->LogSubTest(KScroll); - DoTestScroll(TRect(TPoint(1,1),iWinSize-TSize(1,1)),TPoint(-6,-14),TRect(10,10,50,50)); - DoTestScroll(TRect(TPoint(1,1),iWinSize-TSize(1,1)),TPoint(16,4),TRect(10,10,50,50)); - break; - case 22: - ((CTScrollStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0252")); - iTest->LogSubTest(KScroll); - DoTestScroll(TRect(TPoint(10,100),iWinSize-TSize(0,10)),TPoint(26,22),TRect(iWinSize)); - DoTestScroll(TRect(iWinSize),TPoint(2,-1),TRect(-10,-10,50,50)); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0253 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Out of memory window scrolling test - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Out of memory window scrolling test - -@SYMTestExpectedResults Out of memory scrolling is handled correctly -*/ - case 23: - ((CTScrollStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0253")); - iTest->LogSubTest(KScroll); - OomScrolling(); - iTest->CloseAllPanicWindows(); - ++iTest->iState; - return; - case 24: - ((CTScrollStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0253")); - ++iTest->iState; - ++iMode; - if (iMode==1) - { - delete iBaseScrollWin; - delete iTestScrollWin; - ConstructL(); - } - return; - default: - ((CTScrollStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - ((CTScrollStep*)iStep)->CloseTMSGraphicsStep(); - TestComplete(); - break; - } - ((CTScrollStep*)iStep)->RecordTestResultL(); - FinishedRectScrolls(); - iDoCheck=ETrue; - } - -void CTScroll::DemoWindowScrollL() - //Function to see what scrolling does. - { - CBlankWindow* iWin; - iWin=new(ELeave) CBlankWindow(TRgb(64,64,224)); - iWin->SetUpL(TPoint(20,10),TSize(120,100),TheClient->iGroup,*TheClient->iGc); - iWin->BaseWin()->SetRequiredDisplayMode(EColor256); - iWin->Win()->SetBackgroundColor(TRgb(64,224,64)); - iWin->RealDraw(ETrue); - TheClient->WaitForRedrawsToFinish(); - iWin->DrawableWin()->Scroll(TPoint(8,5),TRect(20,20,100,80)); - TheClient->Flush(); - TheClient->WaitForRedrawsToFinish(); - TheClient->Flush(); - } - - -__WS_CONSTRUCT_STEP__(Scroll) -#pragma warning(default : 4710) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TSCROLL.H --- a/windowing/windowserver/tauto/TSCROLL.H Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,203 +0,0 @@ - -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef __TSCROLL_H__ -#define __TSCROLL_H__ - -#include -#include -#include "../tlib/testbase.h" -#include -#include "AUTO.H" -#include "TGraphicsHarness.h" - -class CTScroll; -class CScrollTestBase; - -class CScrollWindowNorm : public CTWin - { -public: - CScrollWindowNorm(); - void Draw(); - void SetScrollTest(CScrollTestBase *aScrollTest); -private: - CScrollTestBase *iScrollTest; - }; - -class CScrollWindowBackedUp : public CTBackedUpWin - { -public: - CScrollWindowBackedUp(TDisplayMode aDisplayMode); - void Draw(); - void SetScrollTest(CScrollTestBase *aScrollTest); -private: - CScrollTestBase *iScrollTest; - }; - -class CScrollTestBase : public CBase - { -public: - ~CScrollTestBase(); - virtual void ConstructL(const TPoint &aPos, const TSize &aSize)=0; - virtual void DoTestScroll(const TPoint &aOffset)=0; - virtual void DoTestScroll(const TRect &aClipRect, const TPoint &aOffset)=0; - virtual void DoTestScroll(const TPoint &aOffset, const TRect &aRect)=0; - virtual void DoTestScroll(const TRect &aClipRect, const TPoint &aOffset, const TRect &aRect)=0; - virtual void Reset(); - TPoint Offset() const; - virtual CTDrawableWin *ScrollWin() const=0; - virtual void DoInvalidate(); - virtual void Redraw()=0; -protected: - TSize iSize; - TPoint iOffset; - friend class CTScroll; - RRegion iInvalid; - CTBlankWindow *iBlankWin; - }; - -class CScrollTestBaseNorm : public CScrollTestBase - { -public: - void ConstructL(const TPoint &aPos, const TSize &aSize); - ~CScrollTestBaseNorm(); - virtual CTDrawableWin *ScrollWin() const; - virtual void Reset(); - void VisibleRegion(RRegion &aRegion); - void AdjustTestScrollRegion(const TRect &aClipRect, const TPoint &aOffset, const TRect &aRect); - void DrawScrollWin(const TPoint &aOffset, const TSize &aSize); - void Redraw(); -protected: - CScrollWindowNorm *iScrollWin; - }; - -class CScrollWindow1 : public CScrollTestBaseNorm -// -// Used as control window for a normal redraw window -// - { -public: - void DoTestScroll(const TPoint &aOffset); - void DoTestScroll(const TRect &aClipRect, const TPoint &aOffset); - void DoTestScroll(const TPoint &aOffset, const TRect &aRect); - void DoTestScroll(const TRect &aClipRect, const TPoint &aOffset, const TRect &aRect); - void DoInvalidate(); - }; - -class CScrollWindow2 : public CScrollTestBaseNorm -// -// Used to test a normal redraw window -// - { -public: - CScrollWindow2(CTScroll *aTest); - virtual void Draw(); - virtual void Reset(); - void DoTestScroll(const TPoint &aOffset); - void DoTestScroll(const TRect &aClipRect, const TPoint &aOffset); - void DoTestScroll(const TPoint &aOffset, const TRect &aRect); - void DoTestScroll(const TRect &aClipRect, const TPoint &aOffset, const TRect &aRect); -private: - TBool iClipped; - CTScroll *iTest; - }; - -class CScrollWindow3 : public CScrollTestBaseNorm -// -// Used as control window for testing backed up windows -// - { -public: - void ConstructL(const TPoint &aPos, const TSize &aSize); - ~CScrollWindow3(); - virtual void Reset(); - void Draw(); - void DoTestScroll(const TPoint &aOffset); - void DoTestScroll(const TRect &aClipRect, const TPoint &aOffset); - void DoTestScroll(const TPoint &aOffset, const TRect &aRect); - void DoTestScroll(const TRect &aClipRect, const TPoint &aOffset, const TRect &aRect); - void DoInvalidate(); - void DrawScrollBit(); -private: - CFbsBitmap *iBitmap; - CFbsDevice *iBitmapDevice; - CFbsBitGc *iBitmapGc; - }; - -class CScrollWindow4 : public CScrollTestBase -// -// Tests a backed up window -// - { -public: - ~CScrollWindow4(); - void ConstructL(const TPoint &aPos, const TSize &aSize); - void DoTestScroll(const TPoint &aOffset); - void DoTestScroll(const TRect &aClipRect, const TPoint &aOffset); - void DoTestScroll(const TPoint &aOffset, const TRect &aRect); - void DoTestScroll(const TRect &aClipRect, const TPoint &aOffset, const TRect &aRect); - virtual CTDrawableWin *ScrollWin() const; - virtual void Reset(); - void Redraw(); -protected: - CScrollWindowBackedUp *iScrollWin; - }; - -class CTScroll : public CTWsGraphicsBase - { -public: - CTScroll(CTestStep* aStep); - ~CTScroll(); - void ConstructL(); - void CheckScrollWindows(); - void DoTestScroll(const TPoint &aOffset); - void DoTestScroll(const TRect &aClipRect, const TPoint &aOffset); - void DoTestScroll(const TPoint &aOffset, const TRect &aRect); - void DoTestScroll(const TRect &aClipRect, const TPoint &aOffset, const TRect &aRect); - void FinishedRectScrolls(); - void CheckOomScroll(); - void OomScrolling(); - void DemoWindowScrollL(); -protected: -//from CTGraphicsStep - virtual void RunTestCaseL(TInt aCurTestCase); -private: - TSize iWinSize; - TInt iMode; - TBool iDoCheck; - CScrollTestBase *iBaseScrollWin; - CScrollTestBase *iTestScrollWin; - }; - -class CTScrollStep : public CTGraphicsStep - { -public: - CTScrollStep(); -protected: - //from CTGraphicsStep - virtual CTGraphicsBase* CreateTestL(); - }; - -_LIT(KTScrollStep,"TScroll"); - - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TSPRITE.CPP --- a/windowing/windowserver/tauto/TSPRITE.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,996 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include "TSPRITE.H" - -CTTSprite::CTTSprite(CTestStep* aStep): - CTWsGraphicsBase(aStep) - { - INFO_PRINTF1(_L("Testing TSprite functions")); - } - -void CTTSprite::SetUpMember(TSpriteMember &aMember) - { - aMember.iMaskBitmap=NULL; - aMember.iInvertMask=EFalse; - aMember.iDrawMode=CGraphicsContext::EDrawModePEN; - aMember.iOffset=TPoint(); - aMember.iInterval=TTimeIntervalMicroSeconds32(0); - aMember.iBitmap=&iBitmap; - } - -void CTTSprite::SetUpPointerCursorL(RWsPointerCursor &aCursor, RWsSession &aSession) - { - aCursor=RWsPointerCursor(aSession); - TSpriteMember member; - SetUpMember(member); - User::LeaveIfError(aCursor.Construct(0)); - User::LeaveIfError(aCursor.AppendMember(member)); - User::LeaveIfError(aCursor.Activate()); - } - -void CTTSprite::SetUpSpriteL(RWsSprite &aSprite, RWsSession &aSession, RWindowTreeNode &aWindow,TInt aFlags/*=0*/) - { - aSprite=RWsSprite(aSession); - User::LeaveIfError(aSprite.Construct(aWindow,TPoint(),aFlags)); - TSpriteMember member; - SetUpMember(member); - User::LeaveIfError(aSprite.AppendMember(member)); - User::LeaveIfError(aSprite.Activate()); - } - -void CTTSprite::ConstructL() - { - User::LeaveIfError(iBitmap.Load(TEST_BITMAP_NAME,0)); - } - -CTTSprite::~CTTSprite() - { - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-0018 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc General cursor tests involving a sprite - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Carries out cursor and window tests before updating - a cursor's member with a sprite - -@SYMTestExpectedResults When the cursor member is update returns KErrArgument -*/ - -void CTTSprite::GeneralTestsL() - { -// -// Close cursor while still active on a window -// - - RWindow win(TheClient->iWs); - win.Construct(*TheClient->iGroup->GroupWin(),1); - win.Activate(); - SetUpPointerCursorL(iCursor1,TheClient->iWs); - win.SetCustomPointerCursor(iCursor1); - iCursor1.Close(); -// -// Close window while cursor active on it -// - SetUpPointerCursorL(iCursor1,TheClient->iWs); - win.SetCustomPointerCursor(iCursor1); - win.Close(); - iCursor1.Close(); - -// -// Close session with: -// An open cursor active on a window & A closed cursor active on another window -// - RWsSession ws; - User::LeaveIfError(ws.Connect()); - // use correct screen - // - ws.SetFocusScreen(iTest->iScreenNumber); - CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws); - CleanupStack::PushL(screen); - User::LeaveIfError(screen->Construct(0)); - - RWindowGroup group(ws); - User::LeaveIfError(group.Construct(123)); - group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close - RWindow win2(ws); - User::LeaveIfError(win2.Construct(group, 1)); - win2.Activate(); - RWindow win3(ws); - User::LeaveIfError(win3.Construct(group, 2)); - win3.Activate(); -// - SetUpPointerCursorL(iCursor1,ws); - SetUpPointerCursorL(iCursor2,ws); - win2.SetCustomPointerCursor(iCursor1); - win3.SetCustomPointerCursor(iCursor2); -// - TSpriteMember member; - member.iBitmap=member.iMaskBitmap=NULL; - TInt err = iCursor1.UpdateMember(9999,member); - TEST(err==KErrArgument); - if (err!=KErrArgument) - INFO_PRINTF3(_L("iCursor1.UpdateMember(9999,member) return value - Expected: %d, Actual: %d"), KErrArgument, err); - - iCursor1.Close(); - - CleanupStack::PopAndDestroy(screen); - ws.Close(); - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-0019 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Construct a sprite in a group window - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Creates a sprite in a group window - -@SYMTestExpectedResults The sprite is created without error -*/ -void CTTSprite::GroupWindowSpritesL() - { - RWsSprite sprite1; - RWsSprite sprite2; - SetUpSpriteL(sprite1,TheClient->iWs,*TheClient->iGroup->GroupWin()); - SetUpSpriteL(sprite2,TheClient->iWs,*TheClient->iGroup->GroupWin()); - TheClient->iWs.Flush(); - sprite2.Close(); - sprite1.Close(); - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-0020 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Constructs a number of different sprites in different windows - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Creates many sprites in three different windows and the checks - the sprites can be manipulated - -@SYMTestExpectedResults The sprite are created and manipulated without error -*/ -#define NUM_SPRITES 8 -void CTTSprite::LotsSpritesL() - { - CTBlankWindow* win=new(ELeave) CTBlankWindow(); - CTBlankWindow* win2=new(ELeave) CTBlankWindow(); - TSize size(100,120); - win->ConstructL(*TheClient->iGroup); - win2->ConstructL(*win); - win2->SetExt(TPoint(100,100),size); - win2->SetColor(TRgb::Gray4(2)); - RWindowBase window=*win->BaseWin(); - RWindowBase window2=*win2->BaseWin(); - window.Activate(); - window2.Activate(); - RWsSprite sprite[NUM_SPRITES]; - TInt ii; - //TheClient->iWs.SetAutoFlush(ETrue); - for (ii=0;iiiWs,window); - sprite[4].Close(); - sprite[2].SetPosition(TPoint(20,20)); - sprite[0].Close(); - win2->SetExt(TPoint(80,100),size); - sprite[6].SetPosition(TPoint(60,120)); - sprite[7].Close(); - sprite[5].SetPosition(TPoint(100,120)); - sprite[3].Close(); - SetUpSpriteL(sprite[7],TheClient->iWs,window); - sprite[7].SetPosition(TPoint(80,150)); - sprite[1].Close(); - win2->SetExt(TPoint(60,110),size); - sprite[5].SetPosition(TPoint(50,40)); - sprite[7].Close(); - SetUpSpriteL(sprite[0],TheClient->iWs,window); - sprite[0].SetPosition(TPoint(55,65)); - sprite[6].Close(); - win2->SetExt(TPoint(40,90),size); - sprite[2].SetPosition(TPoint(80,45)); - sprite[5].Close(); - sprite[0].SetPosition(TPoint(90,60)); - sprite[2].Close(); - SetUpSpriteL(sprite[2],TheClient->iWs,window); - sprite[2].SetPosition(TPoint(70,80)); - sprite[0].Close(); - win2->SetExt(TPoint(20,80),size); - sprite[2].SetPosition(TPoint(600,200)); - sprite[2].Close(); - SetUpSpriteL(sprite[0],TheClient->iWs,window2,ESpriteFlash); - sprite[0].SetPosition(TPoint(0,25)); - SetUpSpriteL(sprite[1],TheClient->iWs,window2,ESpriteFlash); - SetUpSpriteL(sprite[2],TheClient->iWs,window2,ESpriteFlash); - sprite[2].SetPosition(TPoint(25,0)); - win2->SetExt(TPoint(40,70),size); - CTBlankWindow* win3=new(ELeave) CTBlankWindow(); - win3->ConstructL(*TheClient->iGroup); - win3->SetExt(TPoint(30,60),TSize(30,30)); - win3->SetColor(TRgb::Gray4(1)); - win3->BaseWin()->SetShadowHeight(10); - win3->BaseWin()->Activate(); - User::After(1000000); //1 sec so sprites has time to flash - delete win2; - delete win; - delete win3; - sprite[0].Close(); - sprite[1].Close(); - sprite[2].Close(); - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-0021 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc General PointerCursor Tests - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Exercise the different pointercursor methods of a Window Server Session - -@SYMTestExpectedResults The methods are called without error -*/ -void CTTSprite::GeneralPointerCursor() - { - if (!TestBase()->ConfigurationSupportsPointerEventTesting()) - { - INFO_PRINTF1(_L("Test skipped because config does not support pointer event testing")); - return; - } - TInt currentSMode=TheClient->iScreen->CurrentScreenMode(); - TInt altSMode=-1; - if (TheClient->iScreen->NumScreenModes()>1) - altSMode=(currentSMode==1?0:1); - RWsSession &ws=TheClient->iWs; - TRect rect=ws.PointerCursorArea(); - TRect testRect1(TPoint(rect.iBr.iX/4,rect.iBr.iY/4),TSize(rect.Width()/2,rect.Height()/2)); - TRect testRect2(TPoint(rect.iBr.iX/3,rect.iBr.iY/3),TSize(2*rect.Width()/3,2*rect.Height()/3)); - ws.SetPointerCursorArea(testRect1); - TEST(ws.PointerCursorArea()==testRect1); - TEST(ws.PointerCursorArea(currentSMode)==testRect1); - ws.SetPointerCursorArea(currentSMode,testRect2); - TEST(ws.PointerCursorArea()==testRect2); - TEST(ws.PointerCursorArea(currentSMode)==testRect2); - ws.SetPointerCursorArea(rect); - TEST(ws.PointerCursorArea()==rect); - - if (altSMode>=0) - { - rect=ws.PointerCursorArea(altSMode); - testRect1.iTl.iX=rect.iBr.iX/4; - testRect1.iTl.iY=rect.iBr.iY/4; - testRect1.SetWidth(rect.Width()/2); - testRect1.SetHeight(rect.Height()/2); - ws.SetPointerCursorArea(altSMode,testRect1); - TEST(ws.PointerCursorArea(altSMode)==testRect1); - ws.SetPointerCursorArea(altSMode,rect); - TEST(ws.PointerCursorArea(altSMode)==rect); - } - TPointerCursorMode currentMode=ws.PointerCursorMode(); - TInt ii; - TInt err1; - for(ii=EPointerCursorFirstMode;ii<=EPointerCursorLastMode;ii++) - { - ws.SetPointerCursorMode(STATIC_CAST(TPointerCursorMode,ii)); - err1 = ws.PointerCursorMode(); - TEST(ii==err1); - if (ii!=err1) - INFO_PRINTF3(_L("ws.PointerCursorMode() return value - Expected: %d, Actual: %d"), ii, err1); - } - ws.SetPointerCursorMode(currentMode); - TEST(currentMode==ws.PointerCursorMode()); - TPoint point1(10,12); - TPoint point2(24,20); - ws.PointerCursorPosition(); - ws.SetPointerCursorPosition(point1); - TEST(ws.PointerCursorPosition()==point1); - ws.SetPointerCursorPosition(point2); - TEST(ws.PointerCursorPosition()==point2); - } - - -/** -@SYMTestCaseID GRAPHICS-WSERV-0498 - -@SYMDEF PDEF137614 - Propagation to TB92 - -@SYMTestCaseDesc Test activating a pointer cursor - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Construct and activate a pointer cursor. - Check it is visible. - Deactivate it - Check it is removed - - -@SYMTestExpectedResults - The pointer cursor bitmp should be visible when activated and removed when deactivated. -*/ - -void CTTSprite::PointerCursorVisibleL() - { - if (!TestBase()->ConfigurationSupportsPointerEventTesting()) - { - INFO_PRINTF1(_L("Test skipped because config does not support pointer event testing")); - return; - } - - // The pointer events need time to have an affect on the wserv - static const TInt eventPropagationDelay = 100 * 1000; // 100 ms - - TInt screenNumber = TheClient->iScreen->GetScreenNumber(); - - if(screenNumber != 0) // pointer events only supported on emulator screen 0 - { - LOG_MESSAGE(_L("Pointer Cursor Visible only runs on screen 0")); - return; - } - - // set up objects used in test - // 50x50 red rectangle colour 24 - CFbsBitmap bitmap; - User::LeaveIfError(bitmap.Load(TEST_BITMAP_NAME, 8)); - - TSize bmSize = bitmap.SizeInPixels(); - TPoint bmSample = TPoint(bmSize.iWidth / 2, bmSize.iHeight / 2); - TRgb bmColour; - bitmap.GetPixel(bmColour, bmSample); - TEST(bmColour == KRgbRed); - - // single window, size of screen - RWindow win(TheClient->iWs); - User::LeaveIfError(win.Construct(*TheClient->iGroup->GroupWin(),1)); - win.Activate(); - - // setup cursor mode - TheClient->iWs.SetPointerCursorMode(EPointerCursorWindow); - - // setup cursor to contain single 50x50 red bitmap - RWsPointerCursor iCursor1 = RWsPointerCursor(TheClient->iWs); - TSpriteMember member; - SetUpMember(member); - member.iBitmap=&bitmap; - User::LeaveIfError(iCursor1.Construct(0)); - User::LeaveIfError(iCursor1.AppendMember(member)); - User::LeaveIfError(iCursor1.Activate()); - win.SetCustomPointerCursor(iCursor1); - iCursor1.UpdateMember(0); - - // draw a green rect, size of screen as defined background and wait till it is rendered - win.BeginRedraw(); - TheGc->Activate(win); - TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - TheGc->SetBrushColor(KRgbGreen); - TSize wSize = win.Size(); - TheGc->DrawRect(TRect(TPoint(0,0), wSize)); - TheGc->Deactivate(); - win.EndRedraw(); - TheClient->iWs.Finish(); - - // #### do test #### - // define locations of simulated pointer events and sample positions of where we expect to see the cursor - // The cursor will be moved and a check will be made to see if this has actually happened - - TPoint pos1(wSize.iWidth / 2, wSize.iHeight / 2); // top left of cursor at centre screen - TPoint sample1(pos1 + bmSample); // centre of sprite at pos1 - TPoint pos2 = pos1 - bmSize; // bottom right of cursor at centre screen - TPoint sample2 = pos2 + bmSample; // centre of sprite at pos2 - - TRgb pixel; - - // check initial state of screen at both sample positions - TheClient->iScreen->GetPixel(pixel, sample1); - TEST(pixel == KRgbGreen); - - TheClient->iScreen->GetPixel(pixel, sample2); - TEST(pixel == KRgbGreen); - - TRawEvent e; // to simulate pointer events - - // simulate button 1 down event at pos1 - e.Set(TRawEvent::EButton1Down, pos1.iX, pos1.iY); - e.SetDeviceNumber(screenNumber); - UserSvr::AddEvent(e); - - User::After(eventPropagationDelay); - - // check red cursor visible on top of background - TheClient->iScreen->GetPixel(pixel, sample1); - TEST(pixel == KRgbRed); - - // simulate button 1 up event - e.Set(TRawEvent::EButton1Up, pos1.iX, pos1.iY); - UserSvr::AddEvent(e); - User::After(eventPropagationDelay); - - // Move cursor away to pos2 - e.Set(TRawEvent::EButton1Down, pos2.iX, pos2.iY); - e.SetDeviceNumber(screenNumber); - UserSvr::AddEvent(e); - - User::After(eventPropagationDelay); - - // check cursor has left this position ... - TheClient->iScreen->GetPixel(pixel, sample1); - TEST(pixel == KRgbGreen); - // and arrived at the correct place - TheClient->iScreen->GetPixel(pixel, sample2); - TEST(pixel == KRgbRed); - - // simulate button 1 up event - e.Set(TRawEvent::EButton1Up, pos2.iX, pos2.iY); - UserSvr::AddEvent(e); - User::After(eventPropagationDelay); - - // remove the cursor - win.ClearPointerCursor(); - User::After(eventPropagationDelay); - - // check it has gone - TheClient->iScreen->GetPixel(pixel, sample2); - TEST(pixel == KRgbGreen); - - // #### clean up #### - iCursor1.Close(); - win.Close(); - } - - -/** - @SYMTestCaseID GRAPHICS-CODEBASE-WSERV-0053-0001 - - @SYMPREQ PGM027 - - @SYMTestCaseDesc Tests RWsPointerCursor::UpdateMember APIs. - - @SYMTestPriority 1 - - @SYMTestStatus Implemented - - @SYMTestActions This test calls RWsPointerCursor::UpdateMember - - @SYMTestExpectedResults Should run properly with out any Panics. - - */ -void CTTSprite::SpriteUpdateMemberTestsL() - { - RWsPointerCursor iCursor1; - - CFbsBitmap bitmap; - bitmap.Load(TEST_BITMAP_NAME,0); - - RWindow win(TheClient->iWs); - win.Construct(*TheClient->iGroup->GroupWin(),1); - win.Activate(); - - iCursor1=RWsPointerCursor(TheClient->iWs); - TSpriteMember member; - SetUpMember(member); - member.iBitmap=&bitmap; - User::LeaveIfError(iCursor1.Construct(0)); - User::LeaveIfError(iCursor1.AppendMember(member)); - User::LeaveIfError(iCursor1.Activate()); - win.SetCustomPointerCursor(iCursor1); - iCursor1.UpdateMember(0); - - RWsPointerCursor iCursor2; - bitmap.Load(TEST_NEW_BITMAP_NAME,0); - iCursor2=RWsPointerCursor(TheClient->iWs); - User::LeaveIfError(iCursor2.Construct(0)); - User::LeaveIfError(iCursor2.AppendMember(member)); - User::LeaveIfError(iCursor2.Activate()); - win.SetCustomPointerCursor(iCursor2); - iCursor2.UpdateMember(1); - - iCursor1.Close(); - iCursor2.Close(); - win.Close(); - } - -/** - @SYMTestCaseID GRAPHICS-CODEBASE-WSERV-0054-0001 - - @SYMPREQ PGM027 - - @SYMTestCaseDesc Negative Tests RWsSpriteBase::UpdateMember API. - - @SYMTestPriority 1 - - @SYMTestStatus Implemented - - @SYMTestActions This test calls RWsPointerCursor::UpdateMember - - @SYMTestExpectedResults Should run properly with out any Panics. - - */ -void CTTSprite::SpriteUpdateMemberNegTestsL() - { - RWsPointerCursor iCursor1; - - CFbsBitmap bitmap; - bitmap.Load(TEST_BITMAP_NAME,0); - - RWindow win(TheClient->iWs); - win.Construct(*TheClient->iGroup->GroupWin(),1); - win.Activate(); - - iCursor1=RWsPointerCursor(TheClient->iWs); - TSpriteMember member; - SetUpMember(member); - member.iBitmap=&bitmap; - User::LeaveIfError(iCursor1.Construct(0)); - User::LeaveIfError(iCursor1.AppendMember(member)); - User::LeaveIfError(iCursor1.Activate()); - win.SetCustomPointerCursor(iCursor1); - iCursor1.UpdateMember(-100); - - RWsPointerCursor iCursor2; - bitmap.Load(TEST_NEW_BITMAP_NAME,0); - iCursor2=RWsPointerCursor(TheClient->iWs); - User::LeaveIfError(iCursor2.Construct(0)); - User::LeaveIfError(iCursor2.AppendMember(member)); - User::LeaveIfError(iCursor2.Activate()); - win.SetCustomPointerCursor(iCursor2); - iCursor2.UpdateMember(10000); - - iCursor1.Close(); - iCursor2.Close(); - win.Close(); - } - -/** - @SYMTestCaseID GRAPHICS-CODEBASE-WSERV-0055-0001 - - @SYMPREQ PGM027 - - @SYMTestCaseDesc Tests FindWindowGroupIdentifier API. - - @SYMTestPriority 1 - - @SYMTestStatus Implemented - - @SYMTestActions Create windows session and call FindWindowGroupIdentifier \n - with different thread Id's both with valid thread ids and in valid thread id's. - - @SYMTestExpectedResults Should run properly. - - */ -void CTTSprite::FindWindowGroupThreadTestsL() - { - RThread proc; - TInt ident; - TUint64 id=proc.Id(); - RWsSession ws1; - User::LeaveIfError(ws1.Connect()); - CleanupClosePushL(ws1); - //Positive test for FindWindowGroupIdentifier - ident=ws1.FindWindowGroupIdentifier(0,id); - TEST(ws1.SetWindowGroupOrdinalPosition(ident,0)==KErrNone); - TEST(ws1.SetWindowGroupOrdinalPosition(ident,1)==KErrNone); - //Negative test for FindWindowGroupIdentifier - TInt ret=ws1.FindWindowGroupIdentifier(0,id+200); - TEST(ret==KErrNotFound); - #if defined __WINS__ || defined __WINSCW__ - ret=ws1.FindWindowGroupIdentifier(0,-200); - TEST(ret==KErrNotFound); - #endif//defined __WINS__ || defined __WINSCW__ - CleanupStack::PopAndDestroy(1, &ws1); - ws1.Close(); - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-0462 - -@SYMDEF PDEF114190 - -@SYMTestCaseDesc Test sprite list cleanup when a window is deleted in low memory conditions - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Have a loop which increases the number of allocations in the server thread before failure; - Within the loop: - 1) Create a parent window and a child window of the parent; - 2) Create a sprite on the child window; - 3) Delete the parent window only, but not the child window; - 4) Create a testWindow and do redraw on this window; - 5) Do redraw on the testWindow. This testWindow's redraw will force checking the sprite list. - This would panic the client thread due to this defect because the sprite on the orphaned - window (which is the previous child window) is still in the sprite list; - 6) Delete all the windows involved. - -@SYMTestExpectedResults The sprite should be disabled when a window is deleted; - The client thread should not be panic'd. - The test should pass. -*/ -void CTTSprite::SpriteOnWindowOrphanedTestsL() - { - TInt handles = 344; - TInt loop = 0; - TInt allocFailRate = 0; - TInt err = KErrNone; - - CFbsBitmap* bitmap = new(ELeave) CFbsBitmap; - CleanupStack::PushL(bitmap); - User::LeaveIfError(bitmap->Create(TSize(500, 500), EColor16MU)); - TSpriteMember spritemember; - spritemember.iBitmap = bitmap; - spritemember.iMaskBitmap = NULL; - - RWindowGroup group(TheClient->iWs); - RWindow parent1(TheClient->iWs); - RWindow child1(TheClient->iWs); - RWindow testWindow(TheClient->iWs); - RWsSprite sprite(TheClient->iWs); - - while (loop < 5) - { - TRect mainRect(TPoint(0,0), TSize(500,500)); - err = group.Construct(++handles, EFalse); - if (err == KErrNone) - { - TheClient->iWs.HeapSetFail(RHeap::EDeterministic, allocFailRate); - - //Create parent 1 - err = parent1.Construct(group,++handles); - if (err == KErrNone) - { - parent1.SetExtent(mainRect.iTl, mainRect.Size()); - parent1.EnableRedrawStore(ETrue); - parent1.Activate(); - } - } - - //Create child 1 - if (err == KErrNone) - { - TRect childRect(TPoint (10, 10), TSize (200, 150)); - err = child1.Construct(parent1,++handles); - if (err == KErrNone) - { - child1.SetExtent(childRect.iTl, childRect.Size()); - child1.SetBackgroundColor(TRgb(128,100,255,20)); - child1.Activate(); - } - } - - //Add sprite to child 1 - if (err == KErrNone) - { - err = sprite.Construct(child1,TPoint(10,10), 0); - if (err == KErrNone) - { - err = sprite.AppendMember(spritemember); - if (err == KErrNone) - err = sprite.Activate(); - } - } - - //Only delete parent 1, but not child 1 - parent1.Close(); - - if (err == KErrNone) - { - TRect testRect(TPoint(10, 30), TSize(200, 150)); - //Create testWindow - err = testWindow.Construct(group,++handles); - if (err == KErrNone) - { - testWindow.SetExtent(testRect.iTl, testRect.Size()); - testWindow.SetBackgroundColor(TRgb(128,100,255,20)); - testWindow.EnableRedrawStore(ETrue); - testWindow.Activate(); - testWindow.BeginRedraw(); - testWindow.EndRedraw(); - TheClient->Flush(); - } - } - TheClient->iWs.HeapSetFail(RAllocator::ENone, 0); - - sprite.Close(); - child1.Close(); - testWindow.Close(); - group.Close(); - ++allocFailRate; - loop = (err == KErrNone) ? loop + 1 : 0; - } - CleanupStack::PopAndDestroy(bitmap); - } -void CTTSprite::ResizeMemberL() - { -#ifndef __WINS__ - CTBlankWindow* win=new(ELeave) CTBlankWindow(); - CleanupStack::PushL(win); - win->ConstructL(*TheClient->iGroup); - win->SetExt(TPoint(),TSize(640,240)); - RWindowBase& window=*win->BaseWin(); - window.Activate(); - RWsSprite sprite(TheClient->iWs); - CleanupClosePushL(sprite); - User::LeaveIfError(sprite.Construct(window,TPoint(),0)); - TSpriteMember member; - member.iMaskBitmap=NULL; - member.iInvertMask=EFalse; - member.iDrawMode=CGraphicsContext::EDrawModePEN; - member.iOffset=TPoint(); - member.iInterval=TTimeIntervalMicroSeconds32(250000); - member.iBitmap=&iBitmap; - User::LeaveIfError(sprite.AppendMember(member)); - User::LeaveIfError(sprite.AppendMember(member)); - User::LeaveIfError(sprite.Activate()); - User::After(1000000); // // Interval is 1 sec. - User::LeaveIfError(iBitmap.Resize(iBitmap.SizeInPixels() + TSize(100,100))); - User::After(1000000); // Interval is 1 sec. - CleanupStack::PopAndDestroy(&sprite); - CleanupStack::PopAndDestroy(win); -#endif // __WINS__ - } - - -void CTTSprite::SetUpSpriteL(RWsSprite &aSprite, RWindowTreeNode &aWindow,TPoint aPoint, TSpriteMember aMember, TInt aFlags/*=0*/) - { - User::LeaveIfError(aSprite.Construct(aWindow,aPoint,aFlags)); - User::LeaveIfError(aSprite.AppendMember(aMember)); - User::LeaveIfError(aSprite.Activate()); - } -/** -@SYMTestCaseID GRAPHICS-WSERV-00-0001 - -@SYMDEF PDEF117721 - -@SYMTestCaseDesc Test Screenrotation does not cause panic by sprite with NULL bitmap and NULL maskbitmap - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Defines two sprites and one with Null iBitmap and Null iMaskBitmap, then rotate the screen to 90 degrees - -@SYMTestExpectedResults the screen rotation will not cause wserv a panic -*/ -void CTTSprite::RotateNullSpriteL() - { - if (TheClient->iScreen->NumScreenModes() < 2) - { - LOG_MESSAGE(_L("WARNING: Unable to rotate screen")); - return; - } -// Sprite Members - TSpriteMember spriteMember1,spriteMember2; - SetUpMember(spriteMember1); - SetUpMember(spriteMember2); - spriteMember2.iBitmap = NULL; - -// Create windows - RWindowGroup group(TheClient->iWs); - User::LeaveIfError(group.Construct(ENullWsHandle,EFalse)); //Creates a Group Window - CleanupClosePushL(group); - RBlankWindow win(TheClient->iWs); - User::LeaveIfError(win.Construct(group,ENullWsHandle)); //Creates a Blank Window - CleanupClosePushL(win); - win.SetVisible(ETrue); - win.SetColor(TRgb::Gray4(2)); - win.Activate(); - TheClient->Flush(); - -// Create Sprites - RWsSprite sprite1(TheClient->iWs); - CleanupClosePushL(sprite1); - SetUpSpriteL(sprite1, win,TPoint(20,70),spriteMember1,0); - RWsSprite sprite2(TheClient->iWs); - CleanupClosePushL(sprite2); - SetUpSpriteL(sprite2, win,TPoint(80,130),spriteMember2,0); - RWsSprite sprite3(TheClient->iWs); - CleanupClosePushL(sprite3); - SetUpSpriteL(sprite3, win,TPoint(2800,2130),spriteMember1,0); - TheClient->Flush(); - -// Get the original screen mode - CWsScreenDevice* device = TheClient->iScreen; - TInt originalScreenMode = device->CurrentScreenMode(); - TPixelsTwipsAndRotation originalModeSettings; - device->GetScreenModeSizeAndRotation(originalScreenMode,originalModeSettings); - -// Rotate screens - TPixelsAndRotation pixelsAndRotation; - device->SetScreenMode( 1 ); - device->GetDefaultScreenSizeAndRotation(pixelsAndRotation); - device->SetCurrentRotations(1,pixelsAndRotation.iRotation); - device->SetScreenSizeAndRotation(pixelsAndRotation); - User::After(1000000); - - CleanupStack::PopAndDestroy(5,&group); -// Restore the original screen mode - device->SetScreenMode(originalScreenMode); - device->SetCurrentRotations(originalScreenMode,originalModeSettings.iRotation); - device->SetScreenSizeAndRotation(originalModeSettings); - TheClient->Flush(); - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-GCE-0700 - -@SYMDEF DEF123129 - -@SYMTestCaseDesc Test activating a sprite twice does not cause the system to hang - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Construct a sprite and add a member to it. Activate twice. - -@SYMTestExpectedResults The test should terminate smoothly and it should not hang the system. -*/ -void CTTSprite::DoubleActivateL() - { - RWsSession ws; - User::LeaveIfError(ws.Connect()); - CleanupClosePushL(ws); - - RWindowGroup group(ws); - User::LeaveIfError(group.Construct(890, EFalse)); - CleanupClosePushL(group); - - RWsSprite sprite = RWsSprite(ws); - User::LeaveIfError(sprite.Construct(group,TPoint(),0)); - CleanupClosePushL(sprite); - CFbsBitmap* bitmap=new(ELeave) CFbsBitmap; - CleanupStack::PushL(bitmap); - User::LeaveIfError(bitmap->Create(TSize(10,12),EColor256)); - TSpriteMember member; - member.iMaskBitmap=NULL; - member.iInvertMask=EFalse; - member.iDrawMode=CGraphicsContext::EDrawModePEN; - member.iOffset=TPoint(); - member.iInterval=TTimeIntervalMicroSeconds32(0); - member.iBitmap=bitmap; - User::LeaveIfError(sprite.AppendMember(member)); - User::LeaveIfError(sprite.Activate()); - User::LeaveIfError(sprite.Activate()); - - sprite.Close(); - CleanupStack::PopAndDestroy(4, &ws); - - group.Close(); - ws.Close(); - } - -void CTTSprite::RunTestCaseL(TInt /*aCurTestCase*/) - { - _LIT(KTest1, "General Tests"); - _LIT(KTest2, "Group Window Sprites Tests"); - _LIT(KTest3, "Lots Sprites Tests"); - _LIT(KTest4, "General Pointer Cursor Tests"); - _LIT(KTest5, "Pointer Cursor Visible Tests"); - _LIT(KTest6, "Update member tests"); - _LIT(KTest7, "Negative tests for Update member"); - _LIT(KTest8, "Window Group with Thread"); - _LIT(KTest9, "Resize Sprite Member Tests"); - _LIT(KTest10, "Rotate a NULL sprite"); - _LIT(KTest11, "Sprite On Window Orphaned Tests"); - _LIT(KTest12, "Sprite Double Activation Test"); - - ((CTTSpriteStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); - switch(++iTest->iState) - { - case 1: - ((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0018")); - TheClient->iWs.SetFocusScreen(0); - iTest->LogSubTest(KTest1); - GeneralTestsL(); - break; - case 2: - ((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0019")); - iTest->LogSubTest(KTest2); - GroupWindowSpritesL(); - break; - case 3: - ((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0020")); - iTest->LogSubTest(KTest3); - LotsSpritesL(); - break; - case 4: - ((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0021")); - iTest->LogSubTest(KTest4); - GeneralPointerCursor(); - break; - case 5: - ((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0498")); - iTest->LogSubTest(KTest5); - TRAPD(err, PointerCursorVisibleL()); - TEST(err == KErrNone); - break; - case 6: - ((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-CODEBASE-WSERV-0053-0001")); - iTest->LogSubTest(KTest6); - TRAP(err, SpriteUpdateMemberTestsL()); - TEST(err == KErrNone); - break; - case 7: - ((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-CODEBASE-WSERV-0054-0001")); - iTest->LogSubTest(KTest7); - TRAP(err, SpriteUpdateMemberNegTestsL()); - TEST(err == KErrNone); - break; - case 8: - ((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-CODEBASE-WSERV-0055-0001")); - iTest->LogSubTest(KTest8); - TRAP(err, FindWindowGroupThreadTestsL()); - TEST(err == KErrNone); - break; - case 9: - ((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0526")); - iTest->LogSubTest(KTest9); - ResizeMemberL(); - break; - case 10: - ((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-00-0001")); - iTest->LogSubTest(KTest10); - RotateNullSpriteL(); - break; - case 11: - ((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0462")); - iTest->LogSubTest(KTest11); - SpriteOnWindowOrphanedTestsL(); - break; - case 12: - ((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-GCE-0700")); - iTest->LogSubTest(KTest12); - DoubleActivateL(); - break; - default: - ((CTTSpriteStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - ((CTTSpriteStep*)iStep)->CloseTMSGraphicsStep(); - TestComplete(); - break; - } - ((CTTSpriteStep*)iStep)->RecordTestResultL(); - } - -//-------------- -__WS_CONSTRUCT_STEP__(TSprite) - diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TSPRITE.H --- a/windowing/windowserver/tauto/TSPRITE.H Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,79 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef __TSPRITE_H__ -#define __TSPRITE_H__ - -#include -#include -#include "../tlib/testbase.h" -#include "AUTO.H" -#include "TGraphicsHarness.h" - -#define TEST_NEW_BITMAP_NAME _L("Z:\\WSTEST\\mytest.mbm") - -class CTTSprite : public CTWsGraphicsBase - { -public: - CTTSprite(CTestStep* aStep); - ~CTTSprite(); -protected: -//from CTGraphicsStep - virtual void RunTestCaseL(TInt aCurTestCase); -public: - void ConstructL(); - void GeneralTestsL(); - void GroupWindowSpritesL(); - void LotsSpritesL(); - void GeneralPointerCursor(); - void PointerCursorVisibleL(); - void SpriteUpdateMemberTestsL(); - void SpriteUpdateMemberNegTestsL(); - void FindWindowGroupThreadTestsL(); - void SpriteOnWindowOrphanedTestsL(); - void ResizeMemberL(); - void RotateNullSpriteL(); - void DoubleActivateL(); -private: - void SetUpMember(TSpriteMember &aMember); - void SetUpPointerCursorL(RWsPointerCursor &aCursor, RWsSession &aSession); - void SetUpSpriteL(RWsSprite &aSprite, RWsSession &aSession, RWindowTreeNode &aWindow,TInt aFlags=0); - void SetUpSpriteL(RWsSprite &aSprite, RWindowTreeNode &aWindow,TPoint aPoint, TSpriteMember aMember, TInt aFlags=0); - -private: - RWsPointerCursor iCursor1; - RWsPointerCursor iCursor2; - CFbsBitmap iBitmap; - }; - -class CTTSpriteStep : public CTGraphicsStep - { -public: - CTTSpriteStep(); -protected: - //from CTGraphicsStep - virtual CTGraphicsBase* CreateTestL(); - }; - -_LIT(KTTSpriteStep,"TSprite"); - - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TScreenModeScaling.cpp --- a/windowing/windowserver/tauto/TScreenModeScaling.cpp Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1104 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Test code for screen mode scaling CR -// Test code for the Scaling part of Change Request PHAR-5SJGAM -// ("Enable screen mode positioning and scaling"). -// Tests screen scale being configurable for a screen mode - -// eg it is now possible to set in wsini.ini amount by which a screen -// mode's screen will be scaled when drawn on the physical screen. -// -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include "TScreenModeScaling.h" - -#define MY_TEST_BITMAP _L("Z:\\WSTEST\\MYTEST.MBM") - -LOCAL_D TSize FullScreenModeSize; -LOCAL_D TInt Copy2ndHalfOfScreen; - -void ClearBitmap(CFbsBitmap* aBitMap) - { - // clear the content of bitmap before it is used for copying - CFbsBitmapDevice *device=CFbsBitmapDevice::NewL(aBitMap); - CleanupStack::PushL(device); - CFbsBitGc *gc=NULL; - User::LeaveIfError(device->CreateContext(gc)); - CleanupStack::PushL(gc); - gc->Clear(); - CleanupStack::PopAndDestroy(2,device); - } - -/*CBitMapWin*/ - -void CBitMapWin::Draw() - { - iGc->BitBlt(TPoint(),&iBackup->Bitmap()); - } - -/*CTestSpriteWin*/ - -CTestSpriteWin::~CTestSpriteWin() - { - } - -void CTestSpriteWin::UpdateWin(TPoint aOrigin) - { - SetOrigin(aOrigin); - DrawNow(); - } - -void CTestSpriteWin::Draw() - { - iGc->BitBlt(iOrigin,&iSpriteBitmap); - } - -/*CTScreenModeScaling*/ - -CTScreenModeScaling::CTScreenModeScaling(CTestStep* aStep) : CTWsGraphicsBase(aStep) - { - } - -CTScreenModeScaling::~CTScreenModeScaling() - { - delete iTestWin; - delete iBlankWin; - delete iBackedUpWin; - delete iTestChildWin; - delete iScreenBitmap; - delete iBitmapWin; - delete iCheckWin; - delete iTransWin; - delete iBackgroundWin; - delete iCheckBitmap; - delete iTransparencyBitmap; - delete iBackgroundBitmap; - delete iForegroundBitmap; - } - -void CTScreenModeScaling::ConstructL() - { - iDisplayMode=TheClient->iScreen->DisplayMode(); - if (iDisplayModeiScreen->SetAppScreenMode(TheClient->iScreenModes[0]); - FullScreenModeSize=TheClient->iScreen->SizeInPixels(); - iBlankWin=new(ELeave) CTBlankWindow(); - iBlankWin->ConstructL(*TheClient->iGroup); - User::LeaveIfError(iBlankWin->BaseWin()->SetRequiredDisplayMode(EColor256)); - iBlankWin->SetExt(TPoint(),FullScreenModeSize); - iBlankWin->Activate(); - - iTestWin=new(ELeave) CBasicWin; - iTestWin->ConstructExtLD(*TheClient->iGroup,TPoint(),FullScreenModeSize); - User::LeaveIfError(iTestWin->BaseWin()->SetRequiredDisplayMode(EColor256)); - iTestWin->AssignGC(*TheClient->iGc); - iTestWin->SetVisible(EFalse); - iTestWin->Activate(); - iTestWin->BaseWin()->SetShadowDisabled(ETrue); - iTestWin->BaseWin()->SetShadowHeight(0); - - iBackedUpWin=new(ELeave) CTBackedUpWin(iDisplayMode); - iBackedUpWin->ConstructExtLD(*iTestWin,TPoint(),FullScreenModeSize); - iBackedUpWin->SetVisible(EFalse); - iBackedUpWin->Activate(); - - iTestChildWin=new(ELeave) CTBlankWindow(); - iTestChildWin->ConstructL(*iTestWin); - User::LeaveIfError(iTestChildWin->BaseWin()->SetRequiredDisplayMode(EColor256)); - iTestChildWin->BaseWin()->SetShadowDisabled(ETrue); - iTestChildWin->SetColor(KRgbGreen); - iTestChildWin->BaseWin()->SetVisible(EFalse); - iTestChildWin->Activate(); - - iScreenBitmap=new(ELeave) CFbsBitmap(); - User::LeaveIfError(iScreenBitmap->Create(TSize(FullScreenModeSize.iWidth/2,FullScreenModeSize.iHeight),iDisplayMode)); - - iBitmapWin=new(ELeave) CBmpWin(*iScreenBitmap); - iBitmapWin->ConstructExtLD(*TheClient->iGroup,TPoint(),iScreenBitmap->SizeInPixels()); - User::LeaveIfError(iBitmapWin->BaseWin()->SetRequiredDisplayMode(EColor256)); - iBitmapWin->AssignGC(*TheClient->iGc); - iBitmapWin->Activate(); - iBitmapWin->SetVisible(EFalse); - iBitmapWin->BaseWin()->SetShadowDisabled(ETrue); - iBitmapWin->BaseWin()->SetShadowHeight(0); - - //.. Create all the bitmaps and transparent windows - iWinSize.SetSize(20,20); - iTransparencyBitmap=CBitmap::NewL(iWinSize,EGray256); - iBackgroundBitmap=CBitmap::NewL(iWinSize,iDisplayMode); - iForegroundBitmap=CBitmap::NewL(iWinSize,iDisplayMode); - - CBitMapWin* backgroundWin=new(ELeave) CBitMapWin(iBackgroundBitmap); - backgroundWin->ConstructExtLD(*TheClient->iGroup,TPoint(),iWinSize); - iBackgroundWin=backgroundWin; - User::LeaveIfError(iBackgroundWin->BaseWin()->SetRequiredDisplayMode(EColor256)); - iBackgroundWin->SetVisible(EFalse); - iBackgroundWin->BaseWin()->SetShadowDisabled(ETrue); - iBackgroundWin->BaseWin()->SetShadowHeight(0); - iBackgroundWin->AssignGC(*TheClient->iGc); - iBackgroundWin->Activate(); - - CBitMapWin* transWin=new(ELeave) CBitMapWin(iForegroundBitmap); - transWin->ConstructExtLD(*TheClient->iGroup,TPoint(),iWinSize); - iTransWin=transWin; - RWindowBase& transWinB=*iTransWin->BaseWin(); - User::LeaveIfError(transWinB.SetRequiredDisplayMode(EColor256)); - transWinB.SetShadowDisabled(ETrue); - transWinB.SetShadowHeight(0); - iTransWin->SetVisible(EFalse); - iTransWin->AssignGC(*TheClient->iGc); - iTransWin->Win()->SetTransparencyBitmap(iTransparencyBitmap->Bitmap()); - iTransWin->Activate(); - - CTBackedUpWin* checkWin=new(ELeave) CTBackedUpWin(iDisplayMode); - checkWin->ConstructExtLD(*TheClient->iGroup,TPoint(iWinSize.iWidth+1,0),iWinSize); - iCheckWin=checkWin; - RBackedUpWindow& win=*iCheckWin->BackedUpWin(); - win.SetShadowHeight(0); - iCheckWin->Activate(); - win.MaintainBackup(); - iCheckBitmap=CBitmap::NewL(win.BitmapHandle()); - iCheckWin->BaseWin()->SetShadowDisabled(ETrue); - iCheckWin->BaseWin()->SetShadowHeight(0); - iCheckWin->BaseWin()->SetVisible(EFalse); - TheClient->Flush(); - TheClient->WaitForRedrawsToFinish(); - } - -void CTScreenModeScaling::TestTopClientWindowPositionAPIs(TPoint aPos,RWindowBase* aWin) - { - TEST(aWin->AbsPosition()==aPos); - TEST(aWin->Position()==aPos); - TEST(aWin->InquireOffset(*TheClient->iGroup->GroupWin())==aPos); - } - -void CTScreenModeScaling::TestChildWindowPositionAPIs(TPoint aPos,TPoint aParentPos,RWindowBase* aWin,RWindowBase* aParentWin) - { - TEST(aWin->AbsPosition()==aParentPos+aPos); - TEST(aWin->Position()==aPos); - TEST(aWin->InquireOffset(*TheClient->iGroup->GroupWin())==aParentPos+aPos); - TEST(aWin->InquireOffset(*aParentWin)==aPos); - } - -void CTScreenModeScaling::TestRect() - { - // Here if the width or height of the screen cannot be divided by 2 - // then make both the rect size same by reducing the first or second which ever is smaller - // and make sure that top left corner is not disturbed. - TRect rect1=TRect(PhysicalToLogical(TPoint()-iCurrentScreenModeOrigin,iCurrentScreenModeScale), - PhysicalToLogical(TPoint(FullScreenModeSize.iWidth/2,FullScreenModeSize.iHeight)-iCurrentScreenModeOrigin, - iCurrentScreenModeScale) - ); - TRect rect2=TRect(PhysicalToLogical(TPoint(FullScreenModeSize.iWidth/2,0)-iCurrentScreenModeOrigin, - iCurrentScreenModeScale), - PhysicalToLogical(FullScreenModeSize.AsPoint()-iCurrentScreenModeOrigin, - iCurrentScreenModeScale) - ); - if ((Abs(rect1.iBr.iX-rect1.iTl.iX)>Abs(rect2.iBr.iX-rect2.iTl.iX)) || (Abs(rect1.iBr.iY-rect1.iTl.iY)>Abs(rect2.iBr.iY-rect2.iTl.iY))) - { - rect1.SetRect(rect1.iTl,rect2.Size()); - } - if ((Abs(rect1.iBr.iX-rect1.iTl.iX)iScreen->RectCompare(rect1,rect2); - TEST(retVal); - if (!retVal) - INFO_PRINTF3(_L("TheClient->iScreen->RectCompare(rect1,rect2) return value - Expected: %d, Actual: %d"), ETrue, retVal); - } - -void CTScreenModeScaling::CompareRegionsL(const TRegion &aRegion1,const TRegion &aRegion2) - { - RRegion tmp; - tmp.Copy(aRegion1); - tmp.SubRegion(aRegion2); - if (tmp.CheckError()) - User::Leave(KErrNoMemory); - TBool retVal = tmp.IsEmpty(); - TEST(retVal); - if (!retVal) - INFO_PRINTF3(_L("RRegion1.IsEmpty() return value - Expected: %d, Actual: %d"), ETrue, retVal); - tmp.Copy(aRegion2); - tmp.SubRegion(aRegion1); - if (tmp.CheckError()) - User::Leave(KErrNoMemory); - retVal = tmp.IsEmpty(); - TEST(retVal); - if (!retVal) - INFO_PRINTF3(_L("RRegion2.IsEmpty() return value - Expected: %d, Actual: %d"), ETrue, retVal); - - tmp.Close(); - } - -void CTScreenModeScaling::SetUpSpriteLC(RWsSprite &aSprite, RWsSession &aSession, RWindowTreeNode &aWindow,TInt aFlags) - { - aSprite=RWsSprite(aSession); - User::LeaveIfError(aSprite.Construct(aWindow,TPoint(),aFlags)); - CleanupClosePushL(aSprite); - TSpriteMember member; - iTest->SetUpMember(member); - member.iBitmap=&iSpriteBitmap; - User::LeaveIfError(aSprite.AppendMember(member)); - User::LeaveIfError(aSprite.Activate()); - } - -void CTScreenModeScaling::TestGetInvalidRegionL(TRect& aRect) - { - RRegion testRegion; - RRegion invalid; - iTestWin->Invalidate(aRect); - testRegion.AddRect(aRect); - iTestWin->Win()->GetInvalidRegion(invalid); - CleanupClosePushL(testRegion); - CleanupClosePushL(invalid); - CompareRegionsL(testRegion, invalid); - CleanupStack::PopAndDestroy(2, &testRegion); - TheClient->WaitForRedrawsToFinish(); - } - -void CTScreenModeScaling::CopyAndCompareL() - { - TInt oldOrdinalPriority = TheClient->iGroup->GroupWin()->OrdinalPriority(); - TInt oldOrdinalPosition = TheClient->iGroup->GroupWin()->OrdinalPosition(); - // the following line makes sure that a console object hidden outside of - // screens range doesn't affect test results ocerlapping the bitmap window - TheClient->iGroup->GroupWin()->SetOrdinalPosition(0, 65535); - - // clear the content of bitmap before it is used for copying - ClearBitmap(iScreenBitmap); - - // Copy first half or second half of the screen to a bitmap then paste it to second or first half of the screen - TRect testWinRect(PhysicalToLogical(TPoint((Copy2ndHalfOfScreen ? FullScreenModeSize.iWidth/2 : 0),0)-iCurrentScreenModeOrigin,iCurrentScreenModeScale), - PhysicalToLogical(TPoint((Copy2ndHalfOfScreen ? FullScreenModeSize.iWidth : FullScreenModeSize.iWidth/2),FullScreenModeSize.iHeight)-iCurrentScreenModeOrigin,iCurrentScreenModeScale) - ); - TheClient->iScreen->CopyScreenToBitmap(iScreenBitmap,testWinRect); - iBitmapWin->SetExt(PhysicalToLogical(TPoint((Copy2ndHalfOfScreen ? 0 : FullScreenModeSize.iWidth/2),0)-iCurrentScreenModeOrigin,iCurrentScreenModeScale),testWinRect.Size()); - iBitmapWin->SetVisible(ETrue); - iBitmapWin->DrawNow(); - TheClient->Flush(); - TestRect(); - iBitmapWin->SetVisible(EFalse); - iTestWin->SetVisible(EFalse); - TheClient->Flush(); - - TheClient->iGroup->GroupWin()->SetOrdinalPosition(oldOrdinalPosition, oldOrdinalPriority); - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-0093 - -@SYMDEF DEF081259, DEF111847 - -@SYMTestCaseDesc Window tests - REQUIREMENT: PREQ673 (Screen Scaling) - API: RWindowBase::InquireOffset(), RWindowBase::AbsPosition(),RWindowBase::Position() - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Loops through all the screen modes present in the wsini file, and then moves to the test screen - mode where it goes on changing the screen scale and origin. In each of the wsini screen modes and test - screen modes, it checks the test window's API's RWindowBase::InquireOffset(), RWindowBase::AbsPosition() - RWindowBase::Position(). Then it copies the content from either first or second half to second or first - half and compares both the regions so that its content are same. - Additionally, as part of defect fix DEF111847, this also loops through all the display modes, and if possible - tests each with the above described method. Previously, it use to only test Color256. - -@SYMTestExpectedResults The content of both halves of the screen should match. -*/ -void CTScreenModeScaling::WindowTestsL() - { - INFO_PRINTF1(_L("AUTO WindowTests : ")); - - TDisplayMode curDispMode; // Holds the current display mode being tested - - for(curDispMode = EGray2; curDispMode < EColorLast; curDispMode = TDisplayMode(curDispMode+1)) - { - if (curDispMode == ERgb) - { - continue; - } - CTClient* client=new(ELeave) CTClient(); - CleanupStack::PushL(client); - client->SetScreenNumber(iTest->iScreenNumber); - client->ConstructL(); - client->iGroup=new(ELeave) TestWindowGroup(client); - client->iGroup->ConstructL(); - client->iGroup->WinTreeNode()->SetOrdinalPosition(1); - RBlankWindow testWindow(client->iWs); - User::LeaveIfError(testWindow.Construct(*TheClient->iGroup->GroupWin(),ENullWsHandle)); - CleanupClosePushL(testWindow); - - TInt setDispMode; // Holds the actual display mode that was set - setDispMode = testWindow.SetRequiredDisplayMode(curDispMode); - - //Only do the tests if the requested mode was actually set - if(curDispMode == setDispMode) - { - //Create and show DisplayMode details message - _LIT(KModeDetails, "Display Mode: "); - TBuf<30> modeDetailsMessage(KModeDetails); - modeDetailsMessage.Append(DisplayModeAsString(curDispMode)); - LOG_MESSAGE(modeDetailsMessage); - - testWindow.Activate(); - TheClient->iGroup->GroupWin()->EnableScreenChangeEvents(); - TInt numOfModes=TheClient->iScreenModes.Count(); - TInt ii; - for (ii=0; iiiScreenModes[ii]; - TPixelsAndRotation pixelsAndRotation; - iCurrentScreenModeOrigin=TheClient->iScreen->GetScreenModeOrigin(iCurrentMode); - iCurrentScreenModeScale=TheClient->iScreen->GetScreenModeScale(iCurrentMode); - TheClient->iScreen->GetScreenModeSizeAndRotation(iCurrentMode,pixelsAndRotation); - if (pixelsAndRotation.iRotation==CFbsBitGc::EGraphicsOrientationNormal) - { - INFO_PRINTF1(_L(" Do Tests")); - TRAPD(ret,DoWindowTestsL()); - TEST(ret==KErrNone); - if (ret!=KErrNone) - { - INFO_PRINTF3(_L("DoWindowTestsL() return value - Expected: %d, Actual: %d"), KErrNone, ret); - } - - INFO_PRINTF1(_L(" Window Trees")); - client->iScreen->SetAppScreenMode(iCurrentMode); - client->Flush(); - } - } - TestDifferentScales(numOfModes-1); - } - CleanupStack::PopAndDestroy(2,client); - } - } - -void CTScreenModeScaling::TestDifferentScales(TInt aLastModeIdx) - { - if (aLastModeIdx<0) return; - TPixelsAndRotation pixelsAndRotation; - for (TInt modeCount=aLastModeIdx;modeCount>=0;--modeCount) - { - TheClient->iScreen->GetScreenModeSizeAndRotation(TheClient->iScreenModes[modeCount],pixelsAndRotation); - if (pixelsAndRotation.iRotation==CFbsBitGc::EGraphicsOrientationNormal) - break; - } - iCurrentMode=TheClient->iScreenModes[aLastModeIdx]; - TheClient->iScreen->SetAppScreenMode(iCurrentMode); - TheClient->iScreen->SetScreenMode(iCurrentMode); - TSizeMode storeModeData=TheClient->iScreen->GetCurrentScreenModeAttributes(); - TSizeMode testMode=storeModeData; - for (TInt xScale=1;xScale<4;++xScale) - { - for (TInt yScale=1;yScale<4;++yScale) - { - testMode.iScreenScale=TSize(xScale,yScale); - TestDifferentOrigin(testMode,TPoint(20,20)); - TestDifferentOrigin(testMode,TPoint(20,30)); - TestDifferentOrigin(testMode,TPoint(30,20)); - TestDifferentOrigin(testMode,TPoint(FullScreenModeSize.iWidth/2+640/FullScreenModeSize.iWidth*10,60)); - } - } - TheClient->iScreen->SetScreenMode(iCurrentMode); - TheClient->iScreen->SetCurrentScreenModeAttributes(storeModeData); - TInt defaultMode=TheClient->iScreenModes[0]; - TheClient->iScreen->SetAppScreenMode(defaultMode); - TheClient->iScreen->SetScreenMode(defaultMode); - } - -void CTScreenModeScaling::TestDifferentOrigin(TSizeMode &aMode,TPoint aOrigin) - { - TheClient->iScreen->SetScreenMode(iCurrentMode);//.. this is required because at the end of next screenmode test it will be set to zero screen mode - aMode.iOrigin=aOrigin; - TheClient->iScreen->SetCurrentScreenModeAttributes(aMode); - TheClient->iScreen->SetAppScreenMode(iCurrentMode); - TheClient->iScreen->SetScreenMode(iCurrentMode); - iCurrentScreenModeOrigin=TheClient->iScreen->GetScreenModeOrigin(iCurrentMode); - iCurrentScreenModeScale=TheClient->iScreen->GetScreenModeScale(iCurrentMode); - TRAPD(ret,DoWindowTestsL()); - TEST(ret==KErrNone); - if (ret!=KErrNone) - INFO_PRINTF3(_L("DoWindowTestsL() return value - Expected: %d, Actual: %d"), KErrNone, ret); - } - -void CTScreenModeScaling::DoWindowTestsL() - { - TheClient->iScreen->SetAppScreenMode(iCurrentMode); - TheClient->iScreen->SetScreenMode(iCurrentMode); - Copy2ndHalfOfScreen=(iCurrentScreenModeOrigin.iX>FullScreenModeSize.iWidth/2? 1 : 0); - TRect testWinRect(PhysicalToLogical(TPoint(),iCurrentScreenModeScale), - PhysicalToLogical(TPoint((Copy2ndHalfOfScreen ? FullScreenModeSize.iWidth - : FullScreenModeSize.iWidth/2), - FullScreenModeSize.iHeight)-iCurrentScreenModeOrigin,iCurrentScreenModeScale) - ); - testWinRect.Shrink(10,10); - iTestWinSize=testWinRect.Size(); - PositionTestL(testWinRect.iTl); - testWinRect.Shrink(10,10); - iTestWinSize=testWinRect.Size(); - PositionTestL(testWinRect.iTl); - BackedUpChildWindowTestL(testWinRect.iTl); - GetInvalidRegionTestL(testWinRect.iTl); - //NextScreenModeTestL(testWinRect.iTl); //This test needs a lot more work ### - } - -void CTScreenModeScaling::PositionTestL(TPoint aPostion) - { - iTestWin->SetExt(aPostion,iTestWinSize); - iTestWin->SetVisible(ETrue); - iTestWin->Invalidate(); - TheClient->Flush(); - TheClient->WaitForRedrawsToFinish(); - TestTopClientWindowPositionAPIs(aPostion,iTestWin->BaseWin()); - CopyAndCompareL(); - } - -void CTScreenModeScaling::BackedUpChildWindowTestL(TPoint aPostion) - { - iTestWin->SetVisible(ETrue); - TPoint backedUpWinPt=TPoint(iTestWinSize.iWidth/3,iTestWinSize.iHeight/4); - iBackedUpWin->SetExtL(backedUpWinPt,TSize(iTestWinSize.iWidth/6,iTestWinSize.iHeight/6)); - iBackedUpWin->SetVisible(ETrue); - TestChildWindowPositionAPIs(backedUpWinPt,aPostion,iBackedUpWin->BaseWin(),iTestWin->BaseWin()); - aPostion+=TPoint(10,10); - iTestWin->SetPos(aPostion); - TestTopClientWindowPositionAPIs(aPostion,iTestWin->BaseWin()); - TestChildWindowPositionAPIs(backedUpWinPt,aPostion,iBackedUpWin->BaseWin(),iTestWin->BaseWin()); - iTestWin->Invalidate(); - TheClient->Flush(); - TheClient->WaitForRedrawsToFinish(); - TestTopClientWindowPositionAPIs(aPostion,iTestWin->BaseWin()); - TestChildWindowPositionAPIs(backedUpWinPt,aPostion,iBackedUpWin->BaseWin(),iTestWin->BaseWin()); - CopyAndCompareL(); - iBackedUpWin->SetVisible(EFalse); - } - -void CTScreenModeScaling::NextScreenModeTestL(TPoint aPos) - { - TInt numOfModes=TheClient->iScreenModes.Count(); - TInt defaultMode=TheClient->iScreenModes[0]; - TInt lastMode=TheClient->iScreenModes[numOfModes-1]; - TInt mode=(iCurrentModeiScreenModes[ii]) - { - modeIdx=ii; - break; - } - } - TPoint screenModeOrigin(0,0); - TPixelsAndRotation pixelsAndRotation; - while (screenModeOrigin==TPoint()||(pixelsAndRotation.iRotation!=CFbsBitGc::EGraphicsOrientationNormal)) - { - mode=(mode==lastMode? defaultMode : TheClient->iScreenModes[++modeIdx]); - if (mode==iCurrentMode) - { - return; - } - screenModeOrigin=TheClient->iScreen->GetScreenModeOrigin(mode); - TheClient->iScreen->GetScreenModeSizeAndRotation(mode,pixelsAndRotation); - } - iTestWin->SetExt(aPos,iTestWinSize); - iTestWin->SetVisible(ETrue); - TheClient->Flush(); - CBasicWin* basicWin=new(ELeave) CBasicWin; - CleanupStack::PushL(basicWin); - basicWin->ConstructExtLD(*iTestWin,TPoint(),TSize(iTestWinSize.iWidth/5,iTestWinSize.iHeight/5)); - User::LeaveIfError(basicWin->BaseWin()->SetRequiredDisplayMode(EColor256)); - basicWin->AssignGC(*TheClient->iGc); - basicWin->BaseWin()->SetShadowDisabled(ETrue); - basicWin->BaseWin()->SetShadowHeight(0); - basicWin->Activate(); - TPoint pos(iTestWinSize.iWidth/3,iTestWinSize.iWidth/4); - basicWin->SetPos(pos); - TheClient->Flush(); - TheClient->WaitForRedrawsToFinish(); - TestChildWindowPositionAPIs(pos,aPos,basicWin->BaseWin(),iTestWin->BaseWin()); - iCurrentScreenModeScale=TheClient->iScreen->GetScreenModeScale(mode); - iCurrentScreenModeOrigin=TheClient->iScreen->GetScreenModeOrigin(mode); - Copy2ndHalfOfScreen=(iCurrentScreenModeOrigin.iX>FullScreenModeSize.iWidth/2? 1 : 0); - TheClient->iScreen->SetAppScreenMode(mode); - TheClient->iScreen->SetScreenMode(mode); - iTestWin->SetVisible(ETrue); - CopyAndCompareL(); - TheClient->iScreen->SetAppScreenMode(defaultMode); - TheClient->iScreen->SetScreenMode(defaultMode); - CleanupStack::PopAndDestroy(basicWin); - } - -void CTScreenModeScaling::GetInvalidRegionTestL(TPoint aPos) - { - iTestWin->SetExt(aPos,iTestWinSize); - iTestWin->SetVisible(ETrue); - iTestChildWin->SetExt(TPoint(iTestWinSize.iWidth>>2,iTestWinSize.iHeight>>2),TSize(iTestWinSize.iWidth>>1,iTestWinSize.iHeight>>1)); - iTestChildWin->SetVisible(ETrue); - TheClient->Flush(); // ensure testchildwin is on-screen - - CArrayFixFlat *rectList=new(ELeave) CArrayFixFlat(3); - CleanupStack::PushL(rectList); - rectList->AppendL(TRect(1,1,5,2)); - rectList->AppendL(TRect(iTest->StdTestWindowSize().iWidth>>1,iTest->StdTestWindowSize().iHeight>>1,iTest->StdTestWindowSize().iWidth,iTest->StdTestWindowSize().iHeight)); - rectList->AppendL(TRect(2,0,4,5)); - - // set iTestWin to a 'clean state' before invalidating rects in the window - iTestWin->DrawNow(); - TheClient->Flush(); - - // invalidate the various rectangles in iTestWin & then initiate a redraw of the window - RRegion invalidRegion; - RRegion region; - for (TInt index=0;indexCount();index++) - { - const TRect& myRect = (*rectList)[index]; - iTestWin->Invalidate(myRect); - region.AddRect(myRect); - } - CleanupStack::PopAndDestroy(rectList); - CleanupClosePushL(invalidRegion); - CleanupClosePushL(region); - iTestWin->Win()->GetInvalidRegion(invalidRegion); - CompareRegionsL(region, invalidRegion); - CleanupStack::PopAndDestroy(2,&invalidRegion); - iTestChildWin->SetVisible(EFalse); - - // ensure the test child win is removed - TheClient->Flush(); - TheClient->WaitForRedrawsToFinish(); - - TRect rect1(iTestWinSize); - TestGetInvalidRegionL(rect1); - TInt width=iTestWinSize.iWidth; - TInt height=iTestWinSize.iHeight; - TRect rect2(TPoint(width/6,height/6),TSize(width/3,height/3)); - TestGetInvalidRegionL(rect2); - - // invalidate the entire test window - iTestWin->Invalidate(); - TheClient->Flush(); - - iTestWin->SetPos(TPoint(15,15)); - iTestWin->SetPos(TPoint()); - iTestWin->SetPos(TPoint(-15,-15)); - iTestWin->SetPos(aPos); - RRegion invalid; - RRegion testRegion(rect1); - CleanupClosePushL(invalid); - CleanupClosePushL(testRegion); - iTestWin->Win()->GetInvalidRegion(invalid); - TBool retVal = !invalid.CheckError(); - TEST(retVal); - if (!retVal) - INFO_PRINTF3(_L("RRegion.CheckError() return value - Expected: %d, Actual: %d"), ETrue, retVal); - TEST(invalid.BoundingRect().iBr.iX<=iTestWinSize.iWidth); - if (invalid.BoundingRect().iBr.iX>iTestWinSize.iWidth) - INFO_PRINTF3(_L("invalid.BoundingRect().iBr.iX<=iTestWinSize.iWidth - Expected: %d, Actual: %d"), invalid.BoundingRect().iBr.iX, iTestWinSize.iWidth); - CompareRegionsL(testRegion,invalid); - CleanupStack::PopAndDestroy(2,&invalid); - - // redraw the test window & confirm - iTestWin->DrawNow(); - TheClient->Flush(); - CopyAndCompareL(); - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-0094 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc SpriteTestL - REQUIREMENT: PREQ673 (Screen Scaling) - API: RWsSprite::SetPosition() - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions In the same way as in window tests it shifts the screen modes. - In each screen modes it creates a sprite window and then it moves slightly - either side or bottom of the sprite, then it compares both the regions - to check whether content are same. - -@SYMTestExpectedResults The content of both halves of the screen should match. -*/ -void CTScreenModeScaling::SpriteTestL() - { - CTClient* client=new(ELeave) CTClient(); - CleanupStack::PushL(client); - client->SetScreenNumber(iTest->iScreenNumber); - client->ConstructL(); - client->iGroup=new(ELeave) TestWindowGroup(client); - client->iGroup->ConstructL(); - client->iGroup->WinTreeNode()->SetOrdinalPosition(1); - RBlankWindow color256(client->iWs); - User::LeaveIfError(color256.Construct(*TheClient->iGroup->GroupWin(),ENullWsHandle)); - CleanupClosePushL(color256); - color256.SetRequiredDisplayMode(EColor256); - color256.Activate(); - TInt numOfModes=TheClient->iScreenModes.Count(); - TInt flushState=TheClient->iWs.SetAutoFlush(ETrue); - TInt ii; - for (ii=0; iiiScreenModes[ii]; - TPixelsAndRotation pixelsAndRotation; - iCurrentScreenModeOrigin=TheClient->iScreen->GetScreenModeOrigin(iCurrentMode); - iCurrentScreenModeScale=TheClient->iScreen->GetScreenModeScale(iCurrentMode); - TheClient->iScreen->GetScreenModeSizeAndRotation(iCurrentMode,pixelsAndRotation); - DoSpriteTestsL(); - client->iScreen->SetAppScreenMode(iCurrentMode); - client->Flush(); - } - iCurrentMode=TheClient->iScreenModes[numOfModes-1]; - TheClient->iScreen->SetAppScreenMode(iCurrentMode); - TheClient->iScreen->SetScreenMode(iCurrentMode); - TSizeMode storeModeData=TheClient->iScreen->GetCurrentScreenModeAttributes(); - TSizeMode testMode=storeModeData; - for (TInt xScale=1;xScale<4;xScale++) - { - for (TInt yScale=1;yScale<4;yScale++) - { - testMode.iScreenScale=TSize(xScale,yScale); - TestDifferentOriginAndScaleForSpritesL(testMode,TPoint(20,20)); - TestDifferentOriginAndScaleForSpritesL(testMode,TPoint(20,30)); - TestDifferentOriginAndScaleForSpritesL(testMode,TPoint(30,20)); - TestDifferentOriginAndScaleForSpritesL(testMode,TPoint(FullScreenModeSize.iWidth/2+10,60)); - } - } - TheClient->iScreen->SetScreenMode(iCurrentMode); - TheClient->iScreen->SetCurrentScreenModeAttributes(storeModeData); - TInt defaultMode=TheClient->iScreenModes[0]; - TheClient->iScreen->SetAppScreenMode(defaultMode); - TheClient->iScreen->SetScreenMode(defaultMode); - CleanupStack::PopAndDestroy(2,client); - TheClient->iWs.SetAutoFlush(flushState); - } - -void CTScreenModeScaling::TestDifferentOriginAndScaleForSpritesL(TSizeMode &aMode, TPoint aOrigin) - { - TheClient->iScreen->SetScreenMode(iCurrentMode); - aMode.iOrigin=aOrigin; - TheClient->iScreen->SetCurrentScreenModeAttributes(aMode); - iCurrentScreenModeOrigin=TheClient->iScreen->GetScreenModeOrigin(iCurrentMode); - iCurrentScreenModeScale=TheClient->iScreen->GetScreenModeScale(iCurrentMode); - DoSpriteTestsL(); - } - -void CTScreenModeScaling::DoSpriteTestsL() - { - TheClient->iScreen->SetAppScreenMode(iCurrentMode); - TheClient->iScreen->SetScreenMode(iCurrentMode); - TPixelsAndRotation pixelsAndRotation; - TheClient->iScreen->GetScreenModeSizeAndRotation(iCurrentMode,pixelsAndRotation); - RWsSprite sprite; - TSize spriteSize=iSpriteBitmap.SizeInPixels(); - if (spriteSize.iWidth*iCurrentScreenModeScale.iWidth>FullScreenModeSize.iWidth/2) - spriteSize.iWidth=(FullScreenModeSize.iWidth/2-20)/iCurrentScreenModeScale.iWidth; - SetUpSpriteLC(sprite,TheClient->iWs,*iBlankWin->BaseWin()); - sprite.SetPosition(TPoint()); - CTestSpriteWin* spriteWin=new(ELeave) CTestSpriteWin(iSpriteBitmap); - CleanupStack::PushL(spriteWin); - spriteWin->ConstructExtLD(*TheClient->iGroup,PhysicalToLogical(TPoint()-iCurrentScreenModeOrigin,iCurrentScreenModeScale),spriteSize); - User::LeaveIfError(spriteWin->BaseWin()->SetRequiredDisplayMode(EColor256)); - spriteWin->AssignGC(*TheClient->iGc); - spriteWin->SetVisible(ETrue); - spriteWin->Activate(); - spriteWin->UpdateWin(TPoint()); - spriteWin->BaseWin()->SetShadowDisabled(ETrue); - spriteWin->BaseWin()->SetShadowHeight(0); - TheClient->Flush(); - TheClient->WaitForRedrawsToFinish(); - TPoint spritePosition; - if (iCurrentScreenModeOrigin.iX<=spriteSize.iWidth || iCurrentScreenModeOrigin.iY<=spriteSize.iHeight) - { - if (pixelsAndRotation.iRotation==CFbsBitGc::EGraphicsOrientationNormal || pixelsAndRotation.iRotation==CFbsBitGc::EGraphicsOrientationRotated180) - spritePosition=TPoint(spriteSize.iWidth+1,0); - else - spritePosition=TPoint(0,spriteSize.iHeight+1); - } - sprite.SetPosition(spritePosition); - const TInt KAnimationGrace = 35000; //defined in server.cpp, but can be changed in wsini.ini - User::After(KAnimationGrace); - TBool retVal = TheClient->iScreen->RectCompare(TRect(PhysicalToLogical(TPoint()-iCurrentScreenModeOrigin,iCurrentScreenModeScale),spriteSize),TRect(spritePosition,spriteSize),CWsScreenDevice::EIncludeSprite); - TEST(retVal); - if (!retVal) - INFO_PRINTF3(_L("TheClient->iScreen->RectCompare(rect1,rect2) return value - Expected: %d, Actual: %d"), ETrue, retVal); - - sprite.SetPosition(TPoint()); - CleanupStack::PopAndDestroy(spriteWin); - CleanupStack::PopAndDestroy(&sprite); - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-0095 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Rotation Tests - REQUIREMENT: PREQ673 (Screen Scaling) - API: RWindowBase::InquireOffset(), RWindowBase::AbsPosition(),RWindowBase::Position() - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions For each of the screen mode with all its rotation it checks whether the window - is correctly placed in particular screen mode. Then it creates a child window - and checks whether it s correctly placed. - -@SYMTestExpectedResults Checks the windows are positioned correctly according to the origin,scale and rotation - of the new screen mode. -*/ -void CTScreenModeScaling::RotationTestsL() - { - CTClient* client=new(ELeave) CTClient(); - CleanupStack::PushL(client); - client->SetScreenNumber(iTest->iScreenNumber); - client->ConstructL(); - client->iGroup=new(ELeave) TestWindowGroup(client); - client->iGroup->ConstructL(); - client->iGroup->WinTreeNode()->SetOrdinalPosition(1); - RBlankWindow color256(client->iWs); - User::LeaveIfError(color256.Construct(*TheClient->iGroup->GroupWin(),ENullWsHandle)); - CleanupClosePushL(color256); - color256.SetRequiredDisplayMode(EColor256); - color256.Activate(); - TInt oldCurrentMode=0; - TInt ii; - //TInt screenMode=TheClient->iScreen->CurrentScreenMode(); - for (ii=0;iiiScreenModes.Count();) - { - iCurrentMode=TheClient->iScreenModes[ii]; - if (iCurrentMode!=oldCurrentMode) - { - client->iScreen->SetAppScreenMode(iCurrentMode); - TheClient->iScreen->SetScreenMode(iCurrentMode); - TheClient->iScreen->SetAppScreenMode(iCurrentMode); - } - TPixelsAndRotation pixelsAndRotation; - TheClient->iScreen->GetDefaultScreenSizeAndRotation(pixelsAndRotation); - oldCurrentMode=iCurrentMode; - CArrayFixFlat* rotations=new(ELeave) CArrayFixFlat(1); - CleanupStack::PushL(rotations); - User::LeaveIfError(TheClient->iScreen->GetRotationsList(iCurrentMode,rotations)); - TInt count=rotations->Count(); - TInt jj=0; - if (count>1) - { - for (jj=0;jjiScreen->SetCurrentRotations(oldCurrentMode,REINTERPRET_CAST(CFbsBitGc::TGraphicsOrientation&,currentRotation)); - CleanupStack::PopAndDestroy(rotations); - iCurrentScreenModeOrigin=TheClient->iScreen->GetScreenModeOrigin(oldCurrentMode); - iCurrentScreenModeScale=TheClient->iScreen->GetScreenModeScale(oldCurrentMode); - TRect testWinRect(PhysicalToLogical(TPoint(),iCurrentScreenModeScale), - PhysicalToLogical(TPoint((Copy2ndHalfOfScreen ? FullScreenModeSize.iWidth : FullScreenModeSize.iWidth/2),FullScreenModeSize.iHeight)-iCurrentScreenModeOrigin,iCurrentScreenModeScale) - ); - testWinRect.Shrink(10,10); - iTestWin->SetExtL(testWinRect.iTl,testWinRect.Size()); - iTestWin->Invalidate(); - iTestWin->SetVisible(ETrue); - TheClient->Flush(); - TheClient->WaitForRedrawsToFinish(); - TestTopClientWindowPositionAPIs(testWinRect.iTl,iTestWin->BaseWin()); - TPoint backedUpWinPt=TPoint(testWinRect.Width()/3,testWinRect.Height()/4); - iBackedUpWin->SetVisible(ETrue); - iBackedUpWin->SetExtL(backedUpWinPt,TSize(testWinRect.Width()/6,testWinRect.Height()/6)); - TestChildWindowPositionAPIs(backedUpWinPt,testWinRect.iTl,iBackedUpWin->BaseWin(),iTestWin->BaseWin()); - iTestWin->SetVisible(EFalse); - iBackedUpWin->SetVisible(EFalse); - } - CleanupStack::PopAndDestroy(2,client); - } - -void CTScreenModeScaling::DrawTransparentWindows() - { - //.. First Draw on Backgroundbitmap - iBackgroundBitmap->Gc().SetBrushColor(TRgb(255,0,255)); - iBackgroundBitmap->Gc().SetBrushStyle(CGraphicsContext::ESolidBrush); - iBackgroundBitmap->Gc().SetPenStyle(CGraphicsContext::ENullPen); - iBackgroundBitmap->Gc().DrawRect(iWinSize); - - //.. Invalidate the background bitmap and do bitBlt to iCheckBitmap also - iBackgroundWin->BaseWin()->SetVisible(ETrue); - iBackgroundWin->DrawNow(); - - //.. Copy to checkbitmap - iCheckBitmap->Gc().SetFaded(EFalse); - iCheckBitmap->Gc().BitBlt(TPoint(),&iBackgroundBitmap->Bitmap()); - - //.. Set the grade of transperency - iTransparencyBitmap->Gc().SetBrushColor(TRgb::Gray256(128)); - iTransparencyBitmap->Gc().SetBrushStyle(CGraphicsContext::ESolidBrush); - iTransparencyBitmap->Gc().SetPenStyle(CGraphicsContext::ENullPen); - iTransparencyBitmap->Gc().DrawRect(iWinSize); - - //.. Then draw to the fore ground bitmap and invalidate the second window - iForegroundBitmap->Gc().Reset(); - iForegroundBitmap->Gc().SetPenStyle(CGraphicsContext::ESolidPen); - iForegroundBitmap->Gc().SetPenSize(TSize(1,1)); - iForegroundBitmap->Gc().SetPenColor(TRgb(0,0,0)); - iForegroundBitmap->Gc().DrawLine(TPoint(0,0),TPoint(iWinSize.iWidth,iWinSize.iHeight)); - iForegroundBitmap->Gc().DrawLine(TPoint(iWinSize.iWidth,0),TPoint(0,iWinSize.iHeight)); - iTransWin->BaseWin()->SetVisible(ETrue); - iTransWin->Invalidate(); - iTransWin->DrawNow(); - - iCheckBitmap->Gc().AlphaBlendBitmaps(TPoint(0,0),&iForegroundBitmap->Bitmap(),&iCheckBitmap->Bitmap() - ,TRect(iWinSize),TPoint(0,0),&iTransparencyBitmap->Bitmap(),TPoint(0,0)); - iCheckWin->BaseWin()->SetVisible(ETrue); - iCheckWin->BackedUpWin()->UpdateScreen(); - TheClient->Flush(); - TheClient->WaitForRedrawsToFinish(); - CheckRect(iTransWin,iCheckWin,TRect(iWinSize),_L("DrawTransparentWindows() CheckRect failed")); - } - -// !!! THE COMMENT BELOW IS DISABLED BECAUSE TransparentTests() METHOD IS NOT USED !!! -//** -//@SYMTestCaseID GRAPHICS-WSERV-0096 -// -//@SYMDEF DEF081259 -// -//@SYMTestCaseDesc TransparentTests -// REQUIREMENT: PREQ673 (Screen Scaling) -// API: CWindowGc::AlphaBlendBitmaps() -// -//@SYMTestPriority High -// -//@SYMTestStatus Implemented -// -//@SYMTestActions The main logic behind this test is to copy the content of the background window -// bitmap to checkwindow bitmap and then use the foreground window bitmap and transparency bitmap -// with the function AlphaBlendBitmaps() to get the content present on the combination of -// foreground(transparent) window and background window. Then compare both the regions of the -// window to check whether the content is same. -// -//@SYMTestExpectedResults The content of both halves of the screen should match. -//*/ -void CTScreenModeScaling::TransparentTestsL() - { - TInt flushState=TheClient->iWs.SetAutoFlush(ETrue); - TInt defaultMode=TheClient->iScreenModes[0]; - TheClient->iScreen->SetAppScreenMode(defaultMode); - TheClient->iScreen->SetScreenMode(defaultMode); - CTClient* client=new(ELeave) CTClient(); - CleanupStack::PushL(client); - client->SetScreenNumber(iTest->iScreenNumber); - client->ConstructL(); - client->iGroup=new(ELeave) TestWindowGroup(client); - client->iGroup->ConstructL(); - client->iGroup->WinTreeNode()->SetOrdinalPosition(1); - RBlankWindow color256(client->iWs); - User::LeaveIfError(color256.Construct(*TheClient->iGroup->GroupWin(),ENullWsHandle)); - CleanupClosePushL(color256); - color256.SetRequiredDisplayMode(EColor256); - color256.Activate(); - client->Flush(); - DrawTransparentWindows(); - iCurrentMode=TheClient->iScreenModes[TheClient->iScreenModes.Count()-1]; - TheClient->iScreen->SetAppScreenMode(iCurrentMode); - TheClient->iScreen->SetScreenMode(iCurrentMode); - TSizeMode storeModeData=TheClient->iScreen->GetCurrentScreenModeAttributes(); - TSizeMode testMode=storeModeData; - for (TInt xScale=1;xScale<4;xScale++) - { - for (TInt yScale=1;yScale<4;yScale++) - { - testMode.iScreenScale=TSize(xScale,yScale); - TestDifferentOriginAndScaleForTranspWin(testMode,TPoint(20,20)); - TestDifferentOriginAndScaleForTranspWin(testMode,TPoint(20,30)); - TestDifferentOriginAndScaleForTranspWin(testMode,TPoint(30,20)); - TestDifferentOriginAndScaleForTranspWin(testMode,TPoint(FullScreenModeSize.iWidth/2+1,60)); - } - } - TheClient->iScreen->SetScreenMode(iCurrentMode); - TheClient->iScreen->SetCurrentScreenModeAttributes(storeModeData); - client->iScreen->SetAppScreenMode(iCurrentMode); - client->Flush(); - TheClient->iScreen->SetAppScreenMode(defaultMode); - TheClient->iScreen->SetScreenMode(defaultMode); - TheClient->iWs.SetAutoFlush(flushState); - CleanupStack::PopAndDestroy(2,client); - } - -void CTScreenModeScaling::TestDifferentOriginAndScaleForTranspWin(TSizeMode &aMode,TPoint aOrigin) - { - TheClient->iScreen->SetScreenMode(iCurrentMode); - aMode.iOrigin=aOrigin; - TheClient->iScreen->SetCurrentScreenModeAttributes(aMode); - TheClient->iScreen->SetAppScreenMode(iCurrentMode); - TheClient->iScreen->SetScreenMode(iCurrentMode); - TRAPD(ret,DrawTransparentWindows()); - TEST(ret==KErrNone); - if (ret!=KErrNone) - INFO_PRINTF3(_L("DrawTransparentWindows() return value - Expected: %d, Actual: %d"), KErrNone, ret); - - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-0097 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc AppScreenModeTest - REQUIREMENT: PREQ673 (Screen Scaling) - API: CWsScreenDevice::SetAppScreenMode() - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Enable the visibility of Test window, Call SetAppScreenMode() API with different - screen mode. Check the variable which is set in its draw function. - -@SYMTestExpectedResults The variable should not be set when the application screen mode is different - then current screen mode. -*/ -void CTScreenModeScaling::AppScreenModeTestL() - { - TheClient->iScreen->SetAppScreenMode(0); - TheClient->iScreen->SetScreenMode(0); - iTestWin->iDrawn=EFalse; - iTestWin->SetExtL(TPoint(),TSize(FullScreenModeSize.iWidth/2,FullScreenModeSize.iHeight)); - iTestWin->SetVisible(ETrue); - TheClient->Flush(); - TheClient->WaitForRedrawsToFinish(); - TEST(iTestWin->iDrawn); - if (!iTestWin->iDrawn) - INFO_PRINTF3(_L("iTestWin->iDrawn - Expected: %d, Actual: %d"), ETrue, iTestWin->iDrawn); - - iTestWin->iDrawn=EFalse; - TheClient->iScreen->SetAppScreenMode(2); - TheClient->iScreen->SetScreenMode(0); - iTestWin->Invalidate(); - TheClient->Flush(); - TEST(!iTestWin->iDrawn); - if (iTestWin->iDrawn) - INFO_PRINTF3(_L("iTestWin->iDrawn - Expected: %d, Actual: %d"), EFalse, iTestWin->iDrawn); - - TheClient->iScreen->SetAppScreenMode(0); - TheClient->Flush(); - TheClient->WaitForRedrawsToFinish(); - TEST(iTestWin->iDrawn); - if (!iTestWin->iDrawn) - INFO_PRINTF3(_L("iTestWin->iDrawn - Expected: %d, Actual: %d"), ETrue, iTestWin->iDrawn); - - iTestWin->iDrawn=EFalse; - TheClient->iScreen->SetScreenMode(1); - iTestWin->Invalidate(); - TheClient->Flush(); - TEST(!iTestWin->iDrawn); - if (iTestWin->iDrawn) - INFO_PRINTF3(_L("iTestWin->iDrawn - Expected: %d, Actual: %d"), EFalse, iTestWin->iDrawn); - - iTestWin->SetVisible(EFalse); - TheClient->iScreen->SetAppScreenMode(0); - TheClient->iScreen->SetScreenMode(0); - } - -void CTScreenModeScaling::RunTestCaseL(TInt /*aCurTestCase*/) - { - _LIT(KWindowTests,"Window Tests"); - _LIT(KSpriteTest,"Sprite Test"); - _LIT(KRotationTests,"Rotation Tests"); - _LIT(KTransparentTests,"Transparent Tests"); - _LIT(KAppScreenModeTest,"AppScreenMode Test"); - _LIT(KScalling,"Scaling not Supported"); - _LIT(KModes,"Only one Screen Size Mode"); - - ((CTScreenModeScalingStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); - switch(++iTest->iState) - { - case 1: - { - ((CTScreenModeScalingStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0097")); - TInt numScrModes=TheClient->iScreen->NumScreenModes(); - if (numScrModes<2 || !CheckScalingSupportedOrNot()) - { - if (numScrModes<2) - LOG_MESSAGE(KModes); - else - LOG_MESSAGE(KScalling); - TestComplete(); - return; - } - iTest->LogSubTest(KAppScreenModeTest); - AppScreenModeTestL(); - } - break; - case 2: - ((CTScreenModeScalingStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0093")); - iTest->LogSubTest(KWindowTests); - WindowTestsL(); - break; - case 3: - ((CTScreenModeScalingStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0094")); - iTest->LogSubTest(KSpriteTest); - SpriteTestL(); - break; - case 4: - ((CTScreenModeScalingStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0095")); - iTest->LogSubTest(KRotationTests); - RotationTestsL(); - break; - case 5: - ((CTScreenModeScalingStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - iTest->LogSubTest(KTransparentTests); - //TransparentTestsL(); //This tests currently fails sometimes for reasons not understood #### - break; - default: - { - TInt defaultMode=TheClient->iScreenModes[0]; - TheClient->iScreen->SetAppScreenMode(defaultMode); - TheClient->iScreen->SetScreenMode(defaultMode); - } - ((CTScreenModeScalingStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - ((CTScreenModeScalingStep*)iStep)->CloseTMSGraphicsStep(); - TestComplete(); - return; - } - ((CTScreenModeScalingStep*)iStep)->RecordTestResultL(); - } - -__WS_CONSTRUCT_STEP__(ScreenModeScaling) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TScreenModeScaling.h --- a/windowing/windowserver/tauto/TScreenModeScaling.h Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,164 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Definitions common for both scren mode positioning and scaling -// -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef __TSCREENMODESCALING_H__ -#define __TSCREENMODESCALING_H__ - - -#include -#include -#include "../tlib/testbase.h" -#include "AUTO.H" -#include "TGraphicsHarness.h" - -_LIT(ScalingTestName,"Screen Mode Scaling"); - -GLREF_C void ClearBitmap(CFbsBitmap* aBitMap); - -class CBasicWin : public CTWin - { -public: - //Virtual Function from CTBaseWin - void Draw(); - TInt iDrawn; - }; - -class CBmpWin : public CTWin - { -public: - inline CBmpWin(CFbsBitmap& aScreenBmp) :iScreenBmp(aScreenBmp) {} - //Virtual Function from CTBaseWin - void Draw(); -private: - CFbsBitmap& iScreenBmp; - }; - -class CSpriteWin : public CTWin - { -public: - inline CSpriteWin(CFbsBitmap& aSpriteBitmap) :iSpriteBitmap(aSpriteBitmap) {} - ~CSpriteWin(); - inline void SetState(TInt aState) {iState=aState;} - void UpdateState(TInt aState); - //Virtual Function from CTBaseWin - void Draw(); -private: - CFbsBitmap& iSpriteBitmap; - TInt iState; - }; - -class CTestSpriteWin : public CTWin - { -public: - inline CTestSpriteWin(CFbsBitmap& aSpriteBitmap) :iSpriteBitmap(aSpriteBitmap) {} - ~CTestSpriteWin(); - inline void SetOrigin(TPoint aOrigin) {iOrigin=aOrigin;} - void UpdateWin(TPoint aOrigin); - //Virtual Function from CTBaseWin - void Draw(); -private: - CFbsBitmap& iSpriteBitmap; - TPoint iOrigin; - }; - -class CBitMapWin : public CTWin - { -public: - inline CBitMapWin(CBitmap* aBackupBitmap) :iBackup(aBackupBitmap) {} - //Virtual Function from CTBaseWin - void Draw(); -private: - CBitmap* iBackup; - }; - - - -class CTScreenModeScaling : public CTWsGraphicsBase - { -public: - CTScreenModeScaling(CTestStep* aStep); - ~CTScreenModeScaling(); - void ConstructL(); - void WindowTestsL(); - void SpriteTestL(); - void RotationTestsL(); - void TransparentTestsL(); - void AppScreenModeTestL(); - -protected: - virtual void RunTestCaseL(TInt aCurTestCase); - -private: - void DoWindowTestsL(); - void TestTopClientWindowPositionAPIs(TPoint aPos,RWindowBase* aWin); - void TestChildWindowPositionAPIs(TPoint aPos,TPoint aParentPos,RWindowBase* aWin,RWindowBase* aParentWin); - void TestRect(); - void CompareRegionsL(const TRegion &aRegion1,const TRegion &aRegion2); - void TestGetInvalidRegionL(TRect& aRect); - void CopyAndCompareL(); - void PositionTestL(TPoint aPostion); - void BackedUpChildWindowTestL(TPoint aPostion); - void NextScreenModeTestL(TPoint aPos); - void GetInvalidRegionTestL(TPoint aPos); - void TestDifferentScales(TInt aLastMode); - void TestDifferentOrigin(TSizeMode &aMode,TPoint aOrigin); - void DoSpriteTestsL(); - void TestDifferentOriginAndScaleForSpritesL(TSizeMode &aMode,TPoint aOrigin); - void SetUpSpriteLC(RWsSprite &aSprite,RWsSession &aSession,RWindowTreeNode &aWindow,TInt aFlags=ESpriteNoShadows); - void DrawTransparentWindows(); - void TestDifferentOriginAndScaleForTranspWin(TSizeMode &aMode,TPoint aOrigin); -private: - CFbsBitmap iSpriteBitmap; - CBmpWin* iBitmapWin; - CFbsBitmap* iScreenBitmap; - CBasicWin *iTestWin; - CTBackedUpWin* iBackedUpWin; - CTBlankWindow* iBlankWin; - CTBlankWindow* iTestChildWin; - TInt iCurrentMode; - TSize iTestWinSize; - TPoint iCurrentScreenModeOrigin; - TSize iCurrentScreenModeScale; - CTBackedUpWin* iCheckWin; - CBitmap* iCheckBitmap; - CBitmap* iTransparencyBitmap; - CBitmap* iBackgroundBitmap; - CBitmap* iForegroundBitmap; - CBitMapWin* iTransWin; - CBitMapWin* iBackgroundWin; - TSize iWinSize; - TDisplayMode iDisplayMode; - }; - -class CTScreenModeScalingStep : public CTGraphicsStep - { -public: - CTScreenModeScalingStep(); -protected: - //from CTGraphicsStep - virtual CTGraphicsBase* CreateTestL(); - }; - -_LIT(KTScreenModeScalingStep,"TScreenModeScaling"); - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TTEXTCURS.CPP --- a/windowing/windowserver/tauto/TTEXTCURS.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2040 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Test the text cursor. -// -// This suite of tests checks to see if the TextCursors are operating -// correctly for a number of use case scenarios; see doxygen comments -// for each sub-test. This test suite is applicable on both winscw -// emulator and armv5 target hardware. However, it must be noted that -// text cursors are special due to their timeliness. The text cursor -// must flash every second: half a second ON, half a second OFF. One -// consequence of this is that when the test suite is run on emulator, -// the PC must be otherwise quiescent. No other IO or CPU intensive -// activities may occur on the system, because these will cause delays -// to the flashing of the text cursor giving unreliable results. -// Where timeliness is a consideration, we use TEST_SOFTFAIL_WINSCW so -// that if the test fails and we are running on the PC emulator, we only -// record the fact, but don't mark the test as failing. - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include "TTEXTCURS.H" -#include "graphics/windowserverconstants.h" - -const TInt KNumberOfCustoTextCursors = 3; -const TInt KTextCursorInitialIdValue = 1001; -const TInt KTextCursorPanicUid1 = 200; -const TInt KTextCursorPanicUid2 = 2000; -const TInt KTextCursorPanicUid3 = 3000; -const TInt KTextCursorPanicUid4 = 4000; -const TInt KTextCursorPanicUid5 = 5000; - -CTestBase* CTCursorTest::iStaticTest = NULL; -const TInt kWinWidth=400; -const TInt kWinHeight=100; -const TSize kWinSize(kWinWidth,kWinHeight); -const TInt kWinXPos=150; -const TInt kCursorWidth = 10; -const TInt kCursorHeight = 20; -const TSize kCursorSize(kCursorWidth,kCursorHeight); -const TPoint kWin1TopLeft(kWinXPos,0); -const TPoint kWin2TopLeft(kWinXPos,kWinHeight+10); - -LOCAL_D void DeleteSpriteMember(TAny* aSpriteMember) - { - TSpriteMember* member=reinterpret_cast(aSpriteMember); - delete member->iBitmap; - member->iBitmap=NULL; - delete member->iMaskBitmap; - member->iMaskBitmap=NULL; - } - -CCustomTextCursor::~CCustomTextCursor() - { - const TInt count = iSpriteMemberArray.Count(); - for (TInt index=0; indexLoad(TEST_BITMAP_NAME, EMbmWsautotestBmp1)); - spriteMember.iMaskBitmap = new (ELeave) CFbsBitmap; - User::LeaveIfError(spriteMember.iMaskBitmap->Load(TEST_BITMAP_NAME, EMbmWsautotestBmp1mask)); - - User::LeaveIfError(iSpriteMemberArray.Append(spriteMember)); - CleanupStack::Pop(&spriteMember); - - // create unique-id accross screens - // - iIdentifier = KTextCursorInitialIdValue + aScreenNumber*KNumberOfCustoTextCursors + aBmpIndex; - iAlignment = (RWsSession::TCustomTextCursorAlignment)(aBmpIndex); - } - -CCustomTextCursor* CCustomTextCursor::CreateCustomTextCursorL(TInt aScreenNumber,TInt aBmpIndex,CTestBase* aTest) - { - CCustomTextCursor* customTextCursor = new (ELeave) CCustomTextCursor(aTest); - CleanupStack::PushL(customTextCursor); - customTextCursor->ConstructL(aScreenNumber,aBmpIndex); - CleanupStack::Pop(customTextCursor); - return customTextCursor; - } - -/* - * Wrapper class for a list of custom text cursor. - */ -class CCustomTextCursorsWrapper : public CBase - { -public: - static CCustomTextCursorsWrapper* NewLC(TInt aScreenNumber,CTestBase* aTest); - ~CCustomTextCursorsWrapper(); - inline RPointerArray& CustomTextCursorsArray(); - inline CCustomTextCursor& CustomTextCursor(TInt aIndex); -private: - void ConstructL(TInt aScreenNumber,CTestBase* aTest); -private: - RPointerArray iCustomTextCursors; - }; - -inline RPointerArray& CCustomTextCursorsWrapper::CustomTextCursorsArray() - { - return iCustomTextCursors; - } - -inline CCustomTextCursor& CCustomTextCursorsWrapper::CustomTextCursor(TInt aIndex) - { - return *(iCustomTextCursors[aIndex]); - } - -CCustomTextCursorsWrapper* CCustomTextCursorsWrapper::NewLC(TInt aScreenNumber,CTestBase* aTest) - { - CCustomTextCursorsWrapper* self = new(ELeave) CCustomTextCursorsWrapper(); - CleanupStack::PushL(self); - self->ConstructL(aScreenNumber,aTest); - return self; - } - -CCustomTextCursorsWrapper::~CCustomTextCursorsWrapper() - { - iCustomTextCursors.ResetAndDestroy(); - iCustomTextCursors.Close(); - } - -void CCustomTextCursorsWrapper::ConstructL(TInt aScreenNumber, CTestBase* aTest) - { - for (TInt index=0; indexConstruct((TInt)aScreenNumber)); - RWindowGroup group(ws); - if (group.Construct(444)==KErrNone) - { - group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close - RWindow wnd(ws); - if (wnd.Construct(group, TInt32(&ws))==KErrNone) - { - TTextCursor tc; - tc.iHeight=10; - tc.iAscent=5; - tc.iWidth=10; - tc.iFlags=0; - tc.iColor=TRgb(0,0,0); - switch(aInt) - { - case 0: - { - /* TESTCASE: 6.1 - * TITLE: Invalid use of a custom text cursor ID (basic text cursor). - * IMPORTANCE: 1 - * REQUIREMENT: Unknown. - * - * ACTION: This test tries to set a text cursor using an ID which is invalid. - * - * CHECK: The thread should panic with the exit reason EWservPanicInvalidTextCursor - */ - tc.iType=(TTextCursor::EType)KTextCursorPanicUid1; - group.SetTextCursor(wnd,TPoint(10,10),tc); - } - break; - case 1: - { - /* TESTCASE: 6.2 - * TITLE: Invalid use of a window for a text cursor. - * IMPORTANCE: 1 - * REQUIREMENT: REQ 1079, CR RDEF-5F7Q24 (10/04/2003). - * - * ACTION: This test tries to set a text cursor using a window which is not part - * of the window group calling the setting API. - * - * CHECK: The thread should panic with the exit reason EWservPanicWindow - */ - tc.iType=(TTextCursor::EType)KTextCursorPanicUid2; - group.SetTextCursor(*TestWin->Win(),TPoint(10,10),tc); - } - break; - case 2: - { - /* TESTCASE: 6.3 - * TITLE: Invalid use of a custom text cursor ID. - * IMPORTANCE: 1 - * REQUIREMENT: REQ 1079, CR RDEF-5F7Q24 (10/04/2003). - * - * ACTION: This test tries to set a text cursor using an ID which is associated to - * an non-existing custom text cursor. - * - * CHECK: The thread should panic with the exit reason EWservPanicNoCustomTextCursor - */ - tc.iType=(TTextCursor::EType)KTextCursorPanicUid3; - group.SetTextCursor(wnd,TPoint(10,10),tc); - } - break; - case 3: - { - /* TESTCASE: 6.4 - * TITLE: Invalid use of a custom text cursor ID. - * IMPORTANCE: 1 - * REQUIREMENT: REQ 1079, CR RDEF-5F7Q24 (10/04/2003). - * - * ACTION: This test tries to set a custom text cursor which has been set to use - * an invalid alignment. - * - * CHECK: The thread should panic with the exit reason EWservPanicCustomTextCursorAlign - */ - CCustomTextCursor* customTextCursor=NULL; - TRAPD(error, customTextCursor=CCustomTextCursor::CreateCustomTextCursorL((TInt)aScreenNumber,0,iStaticTest)); - if (error==KErrNone) - { - error = ws.SetCustomTextCursor(KTextCursorPanicUid4, customTextCursor->iSpriteMemberArray.Array(), 0, (RWsSession::TCustomTextCursorAlignment)(RWsSession::ECustomTextCursorAlignBottom+1)); - if (error==KErrNone || error==KErrAlreadyExists) - { - tc.iType=(TTextCursor::EType)KTextCursorPanicUid4; - group.SetTextCursor(wnd,TPoint(10,10),tc); - } - } - delete customTextCursor; - } - break; - case 4: - { - /* TESTCASE: 6.5 - * TITLE: Use of an invalid custom text cursor - * IMPORTANCE: 1 - * REQUIREMENT: REQ 1079, CR RDEF-5F7Q24 (10/04/2003). - * - * ACTION: This test tries to set a custom text cursor which does not have - * any sprite member set. - * - * CHECK: The thread should panic with the exit reason EWservPanicNoSpriteMember - */ - RArray spriteMemberArray; - const TInt error = ws.SetCustomTextCursor(KTextCursorPanicUid5, spriteMemberArray.Array(), 0, (RWsSession::TCustomTextCursorAlignment)(RWsSession::ECustomTextCursorAlignBottom)); - if (error==KErrNone || error==KErrAlreadyExists) - { - tc.iType=(TTextCursor::EType)KTextCursorPanicUid5; - group.SetTextCursor(wnd,TPoint(10,10),tc); - } - } - break; - case 5: - { - // Uncover set.cursor.iType < TTextCursor::ETypeFirst code path - tc.iType=(TTextCursor::EType)TTextCursor::ETypeFirst - 1; - group.SetTextCursor(wnd,TPoint(10,10),tc); - } - break; - case 6: - { - // Uncover (set.cursor.iFlags&static_cast(TTextCursor::EPrivateFlags) code path - tc.iFlags=ETextCursorPrivateFlags; - group.SetTextCursor(wnd,TPoint(10,10),tc); - } - break; - case 7: - { - // Uncover (iGroupWin != searchWin) i.e. bogus group window - tc.iType=(TTextCursor::EType)TTextCursor::ETypeRectangle; - RWindow windowNotAssociatedWithAGroup(ws); - group.SetTextCursor(windowNotAssociatedWithAGroup, TPoint(10,10),tc); - } - break; - } - } - ws.Flush(); - } - } - return(EWsExitReasonBad); - } - -void CTCursorTest::TestPanicsL() - { - TEST(iTest->TestWsPanicL(DoPanicTest, EWservPanicInvalidTextCursor, 0, (TAny*)iTest->iScreenNumber)); - TEST(iTest->TestWsPanicL(DoPanicTest, EWservPanicWindow, 1, (TAny*)iTest->iScreenNumber)); - TEST(iTest->TestWsPanicL(DoPanicTest, EWservPanicNoCustomTextCursor, 2, (TAny*)iTest->iScreenNumber)); - TEST(iTest->TestWsPanicL(DoPanicTest, EWservPanicCustomTextCursorAlign, 3, (TAny*)iTest->iScreenNumber)); - TEST(iTest->TestWsPanicL(DoPanicTest, EWservPanicNoSpriteMember, 4, (TAny*)iTest->iScreenNumber)); - TEST(iTest->TestWsPanicL(DoPanicTest, EWservPanicInvalidTextCursor, 5, (TAny*)iTest->iScreenNumber)); - TEST(iTest->TestWsPanicL(DoPanicTest, EWservPanicInvalidTextCursor, 6, (TAny*)iTest->iScreenNumber)); - TEST(iTest->TestWsPanicL(DoPanicTest, EWservPanicWindow, 7, (TAny*)iTest->iScreenNumber)); - iTest->CloseAllPanicWindows(); - } - -void CTCursorTest::TextCursorSetLCoverageTests() - { - ValidateWin(BaseWin,TRgb::Gray256(255)); - ValidateWin(TestWin,TRgb::Gray256(255)); - TTextCursor textCursor; - textCursor.iHeight = 10; - textCursor.iAscent = 0; - textCursor.iWidth = 10; - textCursor.iFlags = 0; - textCursor.iColor = KRgbBlack; - textCursor.iType = (TTextCursor::EType)TTextCursor::ETypeRectangle; - TPoint position(10, 10); - TRect clipRect0(10, 10, 10, 10); - TRect clipRect1(10, 10, 5, 5); - RWindowGroup *group = TheClient->iGroup->GroupWin(); - group->SetTextCursor(*TestWin->Win(), position, textCursor); - /* - * Duplicate the previous SetTextCursor command to uncover the code which checks for any delta in SetL - * compared to the current settings. - */ - group->SetTextCursor(*TestWin->Win(), position, textCursor); - /* - * Change the type only to pick up that difference in SetL. - */ - textCursor.iType++; - group->SetTextCursor(*TestWin->Win(), position, textCursor); - textCursor.iType--; - /* - * Vary the clipping rectangle. - */ - group->SetTextCursor(*TestWin->Win(), position, textCursor, clipRect0); - group->SetTextCursor(*TestWin->Win(), position, textCursor, clipRect1); - /* - * Vary the color. - */ - textCursor.iColor = KRgbGreen; - group->SetTextCursor(*TestWin->Win(), position, textCursor); - textCursor.iColor = KRgbBlack; - group->SetTextCursor(*TestWin->Win(), position, textCursor); - /* - * Vary the target Window. - */ - group->SetTextCursor(*BaseWin->Win(), position, textCursor); - group->SetTextCursor(*TestWin->Win(), position, textCursor); - /* - * Vary the size of the cursor. - */ - textCursor.iWidth++; - group->SetTextCursor(*TestWin->Win(), position, textCursor); - textCursor.iWidth--; - /* - * Set different custom cursors. - */ - CCustomTextCursorsWrapper* customTextCursorsWrapper = CCustomTextCursorsWrapper::NewLC(iTest->iScreenNumber, iTest); - const TInt count = customTextCursorsWrapper->CustomTextCursorsArray().Count(); - for (TInt index=0; indexCustomTextCursor(index); - textCursor.iType = customTextCursor.iIdentifier; - group->SetTextCursor(*TestWin->Win(), position, textCursor); - } - CleanupStack::PopAndDestroy(customTextCursorsWrapper); - /* - * Set the last custom cursor from the above loop again so the - * product code sees the same Custom Text Cursor settings come - * in a second time. - */ - group->SetTextCursor(*TestWin->Win(), position, textCursor); - textCursor.iType = (TTextCursor::EType)TTextCursor::ETypeRectangle; - /* - * Vary the horizontal clipping. - */ - textCursor.iFlags = TTextCursor::EFlagClipHorizontal; - group->SetTextCursor(*TestWin->Win(), position, textCursor); - /* - * Vary the horizontal clipping. - */ - textCursor.iFlags = TTextCursor::EFlagClipVertical; - group->SetTextCursor(*TestWin->Win(), position, textCursor); - /* - * Try both horizontal and vertical clipping. - */ - textCursor.iFlags = TTextCursor::EFlagClipVertical|TTextCursor::EFlagClipHorizontal; - group->SetTextCursor(*TestWin->Win(), position, textCursor); - textCursor.iFlags = 0; - - TheClient->iWs.Flush(); - CancelTextCursor(); - } - -void CTCursorTest::SetCursor(const TPoint &aPos,const TSize &aSize,TRgb aColor, const TRect &aRect, TUint aFlags) - { - TTextCursor tc; - tc.iType=iCursorType; - tc.iHeight=aSize.iHeight; - tc.iAscent=aSize.iHeight*4/5; - tc.iWidth=aSize.iWidth; - tc.iFlags=aFlags; - tc.iColor=aColor; - TheClient->iGroup->GroupWin()->SetTextCursor(*TestWin->Win(),TPoint(aPos.iX,aPos.iY+tc.iAscent),tc,aRect); - } - -void CTCursorTest::SetCursor(const TPoint &aPos,const TSize &aSize,TRgb aColor, TUint aFlags) - { - TTextCursor tc; - tc.iType=iCursorType; - tc.iHeight=aSize.iHeight; - tc.iAscent=aSize.iHeight*4/5; - tc.iWidth=aSize.iWidth; - tc.iFlags=aFlags; - tc.iColor=aColor; - TheClient->iGroup->GroupWin()->SetTextCursor(*TestWin->Win(),TPoint(aPos.iX,aPos.iY+tc.iAscent),tc); - } - -void CTCursorTest::SetCursorPlusBox(const TPoint &aPos,const TSize &aSize,TRgb aColor, const TRect *aClipRect, TUint aFlags) - { - if (aClipRect) - SetCursor(aPos,aSize,aColor,*aClipRect,aFlags); - else - SetCursor(aPos,aSize,aColor,aFlags); - TRect rect(aPos,aSize); - if (aClipRect) - rect.Intersection(*aClipRect); - rect.Grow(2,2); - - TheClient->iGc->Activate(*(TestWin->Win())); - TestWin->Invalidate(rect); - TestWin->Win()->BeginRedraw(rect); - TheClient->iGc->SetPenColor(aColor); - TheClient->iGc->SetDrawMode(CGraphicsContext::EDrawModeXOR); - - TheClient->iGc->DrawRect(rect); - TheClient->iGc->Deactivate(); - TestWin->Win()->EndRedraw(); - - } - -void CTCursorTest::CancelTextCursor() - { - TheClient->iGroup->GroupWin()->CancelTextCursor(); - } - -void CTCursorTest::ConstructL() - { - // for allocating some cached memory - CFbsBitmap* bitmap = new (ELeave) CFbsBitmap; - CleanupStack::PushL(bitmap); - User::LeaveIfError(bitmap->Load(TEST_BITMAP_NAME, 0)); - CleanupStack::PopAndDestroy(bitmap); - - CCustomTextCursorsWrapper* customTextCursorsWrapper = CCustomTextCursorsWrapper::NewLC(iTest->iScreenNumber, iTest); - const TInt count = customTextCursorsWrapper->CustomTextCursorsArray().Count(); - for (TInt index=0; indexCustomTextCursor(index); - TInt err = TheClient->iWs.SetCustomTextCursor(customTextCursor.iIdentifier, customTextCursor.iSpriteMemberArray.Array(), customTextCursor.iSpriteFlags, customTextCursor.iAlignment); - TEST(err == KErrNone || err == KErrAlreadyExists); - if (err!=KErrNone && err != KErrAlreadyExists) - INFO_PRINTF4(_L("TheClient->iWs.SetCustomTextCursor return value - Expected: %d or %d, Actual: %d"), KErrNone, KErrAlreadyExists, err); - - __UHEAP_MARK; - err = TheClient->iWs.SetCustomTextCursor(customTextCursor.iIdentifier, customTextCursor.iSpriteMemberArray.Array(), customTextCursor.iSpriteFlags, customTextCursor.iAlignment); - __UHEAP_MARKEND; - TEST(err == KErrAlreadyExists); - if (err != KErrAlreadyExists) - INFO_PRINTF3(_L("TheClient->iWs.SetCustomTextCursor return value - Expected: %d, Actual: %d"), KErrAlreadyExists, err); - - } - _LIT(KLog,"Text Cursor: Loaded %d Custom Cursors"); - TLogMessageText buf; - buf.Format(KLog,count); - TheClient->LogMessage(buf); - CleanupStack::PopAndDestroy(customTextCursorsWrapper); -// - ValidateWin(BaseWin,TRgb::Gray256(204)); - ValidateWin(TestWin,TRgb::Gray256(204)); -// - SetCursor(TPoint(10,90),TSize(80,100),TRgb(255,255,255)); -// - iWinState=0; - iWinPos=TPoint(2*TheClient->iGroup->Size().iWidth/3,0); -// - iMoveWin=new(ELeave) CBlankWindow(TRgb::Gray256(220)); - TDisplayMode mode=EGray16; - TInt testWinWidth = TestWin->Size().iWidth; - TInt halfTestWinWidth = testWinWidth/2; - TInt halfTestWinHeight = TestWin->Size().iHeight/2; - - iMoveWin->SetUpL(iWinPos,TSize(halfTestWinHeight,halfTestWinHeight), - TheClient->iGroup,*TheClient->iGc,&mode); - - iCheckWin=new(ELeave) CBlankWindow(TRgb::Gray256(220)); - iCheckWin->SetUpL(TPoint(testWinWidth+halfTestWinWidth,halfTestWinHeight), - TSize(halfTestWinWidth,halfTestWinHeight), - TheClient->iGroup,*TheClient->iGc,&mode); - } - -void CTCursorTest::DeleteMoveWindows() - { - delete iMoveWin; - delete iCheckWin; - CancelTextCursor(); - } - -void CTCursorTest::ResetMoveWindowsL() - { - SetCursor(TPoint(10,90),TSize(80,100),TRgb(255,255,255)); - iWinState=0; - iWinPos=TPoint(2*TheClient->iGroup->Size().iWidth/3,0); - iMoveWin->SetExtL(iWinPos,TSize(TestWin->Size().iWidth/2,TestWin->Size().iHeight/2)); - iCheckWin->SetExtL(TPoint(TestWin->Size().iWidth+(TestWin->Size().iWidth>>1),TestWin->Size().iHeight>>1), - TSize(TestWin->Size().iWidth/2,TestWin->Size().iHeight/2)); - } - -TBool CTCursorTest::MoveWindow() - { - TSize scrSize(TheClient->iScreen->SizeInPixels()); - iWinState++; - if (iWinState<20) - iWinPos+=TPoint((4*scrSize.iWidth)/640,(4*scrSize.iHeight)/240); - else if (iWinState<40) - iWinPos+=TPoint((1*scrSize.iWidth)/640,(-3*scrSize.iHeight)/240); - else if (iWinState<60) - iWinPos+=TPoint((-6*scrSize.iWidth)/640,(3*scrSize.iHeight)/240); - else - iWinPos+=TPoint((1*scrSize.iWidth)/640,(-2*scrSize.iHeight)/240); - iMoveWin->SetPos(iWinPos); - return (iWinState==80); - } - -void CTCursorTest::ValidateWin(TestWindow *aWin, TRgb aColor) - { - aWin->Win()->Invalidate(); - RedrawWin(*aWin->Win(),aColor); - } - -void CTCursorTest::RedrawWin(RWindow &aWin, TRgb aColor) - { - aWin.BeginRedraw(); - TheClient->iGc->Activate(aWin); - TheClient->iGc->SetBrushColor(aColor); - TheClient->iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - TheClient->iGc->SetPenStyle(CGraphicsContext::ENullPen); - TheClient->iGc->Clear(); - TheClient->iGc->Deactivate(); - aWin.EndRedraw(); - } - -void CTCursorTest::ScrollTest() - { - const TSize size(20,40); - ValidateWin(TestWin,TRgb::Gray256(255)); - - SetCursor(TPoint(10,20),size,TRgb::Gray256(255),TTextCursor::EFlagNoFlash); - TheClient->iWs.Flush(); - TheClient->WaitForRedrawsToFinish(); - TheClient->iWs.Finish(); - - for(TInt ii=0;ii<20;ii++) - { - TInt dist=(ii&3)*2; - TInt nx=ii&0x1?1:-1; - TInt ny=ii&0x2?1:-1; - TestWin->Win()->Scroll(TPoint(dist*nx,dist*ny),TRect(10,20,30,40)); - TheClient->iWs.Flush(); - } - TheClient->WaitForRedrawsToFinish(); - TheClient->iWs.Finish(); - - BaseWin->Win()->Invalidate(); - BaseWin->Win()->BeginRedraw(); - TheClient->iGc->Activate(*(BaseWin->Win())); - TheClient->iGc->Clear(); - TheClient->iGc->SetBrushColor(TRgb::Gray256(255)); - TheClient->iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - TheClient->iGc->SetPenStyle(CGraphicsContext::ENullPen); - TheClient->iGc->Clear(TRect(TPoint(10,20),size)); - TheClient->iGc->Deactivate(); - BaseWin->Win()->EndRedraw(); - - TheClient->iWs.Flush(); - TheClient->WaitForRedrawsToFinish(); - TheClient->iWs.Finish(); - - /* - * NOTE: Reason for removal of COMPARE_WINDOWS_SOFTFAIL_WINSCW - * Due to the new implementation of sprites in wserv2, the sprites no longer keep a - * backup bitmap of what the screen looks like beneath them. As it is not possible to - * move the sprites associated with the custom text cursors that were created in second - * phase construction of the CTCursorTest object, the COMPARE_WINDOWS_SOFTFAIL_WINSCW; - * macro function has been removed. Otherwise the test case is going to subject to the - * timing of the flashing sprite. An alternative solution would be to assign NULL values - * to the sprite bitmaps in second phase construction, but this is avoided as it would - * trigger failures in some test cases later on (that are depended on these "embedded" - * sprite images). - */ - CancelTextCursor(); - } - -void DrawTestSprite(CBitmapContext *aGc,TInt , const TSize &aSize, TBool aDoMask, TAny *) - { - aGc->SetBrushColor(TRgb::Gray4(aDoMask ? 0 : 2)); - aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - aGc->SetPenStyle(CGraphicsContext::ENullPen); - aGc->DrawRect(TRect(aSize)); - aGc->SetPenStyle(CGraphicsContext::ESolidPen); - aGc->SetPenColor(TRgb::Gray4(aDoMask ? 3 : 0)); - aGc->SetBrushColor(TRgb::Gray4(aDoMask ? 3 : 1)); - aGc->DrawEllipse(TRect(aSize)); - } - -CTSprite *CTCursorTest::CreateTestSpriteLC(RWindowTreeNode &aWindow, const TPoint &aPos, TInt aCount) -// -// At the moment aCount must be 1 or 2 -// - { - TSpriteCreateParams params(TSize(30,70),TPoint(0,0),DrawTestSprite); - TSpriteCreateParams paramarray[2]; - params.iInterval=TTimeIntervalMicroSeconds32(200000); - - paramarray[0]=params; - paramarray[1]=params; - paramarray[1].iSize=TSize(100,10); - CTSprite *sprite=new(ELeave) CTSprite(TheClient->iWs); - CleanupStack::PushL(sprite); - sprite->ConstructL(aWindow,aPos,aCount,¶marray[0],0); - return(sprite); - } - -void CTCursorTest::doMoveWindowTestL() - { - RBlankWindow blankwin(TheClient->iWs); - User::LeaveIfError(blankwin.Construct(*TestWin->Win(),1)); - CleanupStack::PushL(TCleanupItem(CleanUpWindow,&blankwin)); -// - blankwin.SetExtent(TPoint(35,165),TSize(40,40)); - blankwin.SetColor(TRgb::Gray256(220)); - blankwin.Activate(); - TheClient->iWs.SetAutoFlush(ETrue); - User::After(500000); - blankwin.SetPosition(TPoint(25,55)); - User::After(500000); - blankwin.SetPosition(TPoint(30,160)); - User::After(500000); - blankwin.SetPosition(TPoint(12,22)); // Almost totally covering sprite - User::After(500000); - blankwin.SetPosition(TPoint(-100,-100)); // Totally off the sprite - User::After(500000); - blankwin.SetPosition(TPoint(10,20)); // Write on top of sprite - User::After(500000); - blankwin.SetPosition(TPoint(24,24)); // moving off... - User::After(500000); - blankwin.SetPosition(TPoint(38,28)); // ... - User::After(500000); - blankwin.SetPosition(TPoint(58,48)); // ... - User::After(500000); - blankwin.SetPosition(TPoint(92,62)); // ... off - User::After(500000); - CleanupStack::PopAndDestroy(); // blank window - TheClient->iWs.Flush(); - TheClient->WaitForRedrawsToFinish(); - TheClient->iWs.Finish(); - - TheClient->iWs.SetAutoFlush(EFalse); - } - -void CTCursorTest::MoveWindowTest1L() - { - ValidateWin(TestWin,TRgb::Gray256(255)); -// Check it with a static sprite - CTSprite * sprite_static = CreateTestSpriteLC(*TestWin->Win(), TPoint(10,20), 1); - doMoveWindowTestL(); - (sprite_static->Sprite()).SetPosition(TPoint(500,500)); //move the sprite out of the viewing area before the window comparison - CleanupStack::PopAndDestroy(1); // sprite -// Check it an animated sprite - CTSprite * sprite_anim = CreateTestSpriteLC(*TestWin->Win(), TPoint(10,20), 2); - doMoveWindowTestL(); - (sprite_anim->Sprite()).SetPosition(TPoint(500,500)); //move the sprite out of the viewing area before the window comparison - CleanupStack::PopAndDestroy(1); // sprite - } - -void CTCursorTest::MoveWindowTest2L() - { - const TSize size(20,40); -// Check it with a text cursor - ValidateWin(TestWin,TRgb::Gray256(255)); - SetCursor(TPoint(10,25),size,TRgb::Gray256(255),TTextCursor::EFlagNoFlash); - doMoveWindowTestL(); - CancelTextCursor(); -// Check it with an anaimated sprite and a text cursor - ValidateWin(TestWin,TRgb::Gray256(255)); - CTSprite * sprite_anim = CreateTestSpriteLC(*TestWin->Win(), TPoint(10,20), 2); - SetCursor(TPoint(10,45),size,TRgb::Gray256(255),TTextCursor::EFlagNoFlash); - doMoveWindowTestL(); - (sprite_anim->Sprite()).SetPosition(TPoint(500,500)); - CancelTextCursor(); - CleanupStack::PopAndDestroy(1); // sprite - } - -TBool CTCursorTest::IncrementCursorType() - { - // each screen has it own set of cursor - // - // the values would be ETypeLast=2 ETypeLastBasic=1009 - // - if (iCursorType == TTextCursor::ETypeFirst) - { - iCursorType = (TTextCursor::EType)(TTextCursor::ETypeLastBasic + 1 + iTest->iScreenNumber*KNumberOfCustoTextCursors); - return ETrue; - } - else if (iCursorType >= TTextCursor::ETypeLastBasic + (iTest->iScreenNumber+1)*KNumberOfCustoTextCursors) - { - iCursorType = TTextCursor::ETypeFirst; - return EFalse; - } - else - { - iCursorType = (TTextCursor::EType)(iCursorType + 1); - return ETrue; - } - } - -void CTCursorTest::GeneralTestsL() - { - const TInt winColor=255; //Best to use Light Grey that is 170, but this code is bugged and doing so shows them up. - ValidateWin(BaseWin,TRgb::Gray256(255)); - ValidateWin(TestWin,TRgb::Gray256(255)); - SetCursor(TPoint(-1000,10),TSize(10,30),TRgb::Gray256(255)); - TheClient->iWs.Flush(); - SetCursor(TPoint(10,10),TSize(10,30),TRgb::Gray256(255)); - TheClient->iWs.Flush(); - TRect rect(15,15,18,25); - SetCursorPlusBox(TPoint(10,10),TSize(10,30),TRgb::Gray256(255), &rect); - CancelTextCursor(); -// - ValidateWin(BaseWin,TRgb::Gray256(255)); - ValidateWin(TestWin,TRgb::Gray256(255)); - TheClient->iWs.Flush(); - for(TInt winType=0;winType<3;winType++) - { - RWindowBase *cursorwin=NULL; - RBackedUpWindow backcursorwin(TheClient->iWs); - RWindow backwindow(TheClient->iWs); - RBlankWindow backblankwin(TheClient->iWs); - switch(winType) - { - case 0: - cursorwin=&backcursorwin; - User::LeaveIfError(backcursorwin.Construct(*TestWin->BaseWin(),EGray4,1)); - break; - case 1: - cursorwin=&backwindow; - User::LeaveIfError(backwindow.Construct(*TestWin->BaseWin(),1)); - break; - case 2: - cursorwin=&backblankwin; - User::LeaveIfError(backblankwin.Construct(*TestWin->BaseWin(),1)); - break; - } - CleanupStack::PushL(TCleanupItem(CleanUpWindow,cursorwin)); - User::LeaveIfError(cursorwin->SetSizeErr(TestWin->BaseWin()->Size())); - cursorwin->Activate(); -// - TTextCursor tc; - tc.iType=iCursorType; - tc.iHeight=30; - tc.iAscent=0; - tc.iWidth=50; - tc.iFlags=0; - tc.iColor=TRgb::Gray256(255); - TheClient->iGroup->GroupWin()->SetTextCursor(*cursorwin,TPoint(10,10),tc); -// - CreateTestSpriteLC(*cursorwin, TPoint(10,20), 2); -// - if (cursorwin==&backwindow) - RedrawWin(backwindow,TRgb::Gray256(255)); - for(TInt count=0;count<9;count++) - { - RWindowBase *pwin=NULL; - RBackedUpWindow backedup(TheClient->iWs); - RWindow window(TheClient->iWs); - RBlankWindow blankwin(TheClient->iWs); - switch(count%3) - { - case 0: - pwin=&window; - window.Construct(*cursorwin,2); - window.SetBackgroundColor(TRgb(winColor,winColor,winColor)); - break; - case 1: - pwin=&backedup; - backedup.Construct(*cursorwin,EGray4,2); - break; - case 2: - pwin=&blankwin; - blankwin.Construct(*cursorwin,2); - blankwin.SetColor(TRgb(winColor,winColor,winColor)); - break; - } - CleanupStack::PushL(TCleanupItem(CleanUpWindow,pwin)); - pwin->SetExtentErr(TPoint(30,30),TSize(50,80)); - pwin->Activate(); - TheClient->iWs.Flush(); - CleanupStack::PopAndDestroy(); // window - if (cursorwin==&backwindow) - RedrawWin(backwindow,TRgb::Gray256(255)); - TheClient->iWs.Flush(); - TheClient->WaitForRedrawsToFinish(); - COMPARE_WINDOWS_SOFTFAIL_WINSCW; - User::After(200000); // Wait a fifth of a second to make sure the test is run during different states of flashing - } - for(TInt count2=0;count2<4;count2++) - { - cursorwin->SetPosition(TPoint(10,5)); - TheClient->iWs.Flush(); - User::After(100000); - cursorwin->SetPosition(TPoint(5,10)); - TheClient->iWs.Flush(); - User::After(100000); - cursorwin->SetPosition(TPoint(0,0)); - TheClient->iWs.Flush(); - User::After(100000); - TheClient->WaitForRedrawsToFinish(); - COMPARE_WINDOWS_SOFTFAIL_WINSCW; - } - CleanupStack::PopAndDestroy(2); // sprite & window containing sprite and cursor - } - CancelTextCursor(); - } - -void CTCursorTest::INC040489L() - { - INFO_PRINTF1(_L("AUTO_TCur INC040489 ")); - RWindowGroup group1(TheClient->iWs); - PushWindowL(&group1); - User::LeaveIfError(group1.Construct(ENullWsHandle)); - RBlankWindow blank1(TheClient->iWs); - PushWindowL(&blank1); - User::LeaveIfError(blank1.Construct(group1,ENullWsHandle)); - blank1.SetRequiredDisplayMode(EColor4K); - blank1.SetColor(TRgb(250,150,0)); - blank1.Activate(); - RWindowGroup group2(TheClient->iWs); - PushWindowL(&group2); - User::LeaveIfError(group2.Construct(ENullWsHandle)); - RBlankWindow blank2(TheClient->iWs); - PushWindowL(&blank2); - User::LeaveIfError(blank2.Construct(group2,ENullWsHandle)); - blank2.SetRequiredDisplayMode(EColor4K); - blank2.SetColor(TRgb(75,200,125)); - blank2.Activate(); - TheClient->Flush(); - INFO_PRINTF1(_L(" Created Windows ")); - TTextCursor tc; - tc.iType=KTextCursorInitialIdValue + iTest->iScreenNumber*KNumberOfCustoTextCursors; - tc.iHeight=80; - tc.iAscent=10; - tc.iWidth=30; - tc.iFlags=0; - tc.iColor=TRgb::Gray256(255); - INFO_PRINTF1(_L(" About to Set Text Cursor 1 ")); - group2.SetTextCursor(blank2,TPoint(20,20),tc); - TheClient->Flush(); - INFO_PRINTF1(_L(" Set Text Cursor 1 ")); - User::After(2000000); //2sec - TheClient->iWs.PrepareForSwitchOff(); - TheClient->Flush(); - User::After(2000000); //2sec - group1.SetOrdinalPosition(0); - group2.CancelTextCursor(); - TheClient->Flush(); - INFO_PRINTF1(_L(" Canceled Text Cursor ")); - User::After(2000000); //2sec - // - // Before applying the fix, the following operations makes the Custom Text - // Cursor Sprite invisible (happens even without wserv heartbeat suppression) - INFO_PRINTF1(_L(" About to Set Text Cursor 2 ")); - group1.SetOrdinalPosition(2); - group2.SetTextCursor(blank2,TPoint(20,20),tc); - TheClient->Flush(); - INFO_PRINTF1(_L(" Set Text Cursor 2 ")); - User::After(2000000); //2sec - TRawEvent event; - event.Set(TRawEvent::EActive); - TheClient->iWs.SimulateRawEvent(event); - TheClient->Flush(); - INFO_PRINTF1(_L(" Simulated Active Event ")); - User::After(2000000); //2sec - CleanupStack::PopAndDestroy(4, &group1); - INFO_PRINTF1(_L(" End of test ")); - } - -void CTCursorTest::CursorUpdatedBeforeWindowRenderedL() - { - INFO_PRINTF1(_L("CursorUpdatedBeforeWindowRenderedL")); - TheClient->iGroup->WinTreeNode()->SetOrdinalPosition(0); - // We use some unique looking colors otherwise its harder - // to spot which test is which - TRgb kAqua(134, 242, 251); - - iWorkInProgress = new(ELeave) CBlankWindow(kAqua); - iComparisonWindow = new(ELeave) CBlankWindow(kAqua); - CancelTextCursor(); - - const TSize screenSize=TheClient->iGroup->Size(); - const TInt kPad = 5; - const TInt kThirdOfScreenWidth = screenSize.iWidth/3; - const TInt kWinWidth = kThirdOfScreenWidth - 2*kPad; - const TInt kWinHeight = screenSize.iHeight - 2*kPad; - const TSize kWinSize(kWinWidth, kWinHeight); - const TPoint kCursorPos(30, 30); - iComparisonWindow->SetUpL(TPoint(2*kThirdOfScreenWidth + kPad, kPad), kWinSize, TheClient->iGroup, *TheClient->iGc); - iWorkInProgress->SetUpL( TPoint( kThirdOfScreenWidth + kPad, kPad), kWinSize, TheClient->iGroup, *TheClient->iGc); - - TTextCursor nonFlashingCursor; - nonFlashingCursor.iType = TTextCursor::ETypeRectangle; - nonFlashingCursor.iHeight=kCursorHeight; - nonFlashingCursor.iAscent=0; - nonFlashingCursor.iWidth=kCursorWidth; - nonFlashingCursor.iFlags=TTextCursor::EFlagNoFlash; - nonFlashingCursor.iColor = KRgbBlack; - TheClient->iGroup->GroupWin()->SetTextCursor(*iWorkInProgress->BaseWin(), kCursorPos, nonFlashingCursor); - - // Up till this point, there has not been a CWsWindow::Render() for iWorkInProgress - // because the window has not been invalid - - /* - * Here is the crux of the test. We want to create the following condition in a window group: - * 1) None of its windows have yet been Rendered using CWsWindow::Render() - * 2) A text cursor is present - * 3) Focus is lost then received - * - * It used to be the case that Wserv picked up the handle to the Render Stage Text Cursor - * drawer upon a Refresh caused by Rendering the window. But drawing the Text Cursor could - * come either from a Window Render or a change to the state of the Text Cursor, such as - * receiving focus in the window. A bug was experienced when the Text Cursor was drawn in - * a window which never had been rendered. This meant that the handle was not set up causing - * an assert. - * - * The code has been modified since then, to setup the handle to the Render Stage Text - * Cursor during Wserv initialisation. However, to guard against future changes, its - * worthwhile to have this corner case test to ensure it is possible to receive focus - * in a window which has never been rendered. That is because the text cursor state - * is updated in such circumstances, and that might trigger a draw of the cursor in a - * future version of the text cursor code. - */ - TheClient->iGroup->WinTreeNode()->SetOrdinalPosition(1); // lose focus - TheClient->iWs.Finish(); - TheClient->iGroup->WinTreeNode()->SetOrdinalPosition(0); // gain focus - TheClient->iWs.Finish(); - - // If we get this far without a panic or assert, we have passed this test. - - // Now allow CWsWindow::Render() to occur in iWorkInProgress - // The reason for doing this is so that when you watch the test - // progress you can see visual confirmation via the progress message and - // the coloured windows appear on the screen. Otherwise you would think - // that the test had either been skipped or had broken. - iWorkInProgress->Invalidate(); - iWorkInProgress->Redraw(); - iComparisonWindow->Invalidate(); - iComparisonWindow->Redraw(); - TheClient->iWs.Finish(); - delete iWorkInProgress; - iWorkInProgress = NULL; - delete iComparisonWindow; - iComparisonWindow = NULL; - INFO_PRINTF1(_L("End of test")); - } - -void CTCursorTest::INC097774() - { - TTimeIntervalMicroSeconds32 initialRepeatRate; - TTimeIntervalMicroSeconds32 repeatRate; - TheClient->iWs.GetKeyboardRepeatRate(initialRepeatRate,repeatRate); - - //simulates a text cursor moving across the screen as if a user was holding down - //a key to scroll the cursor through a section of text. - //before applying the fix the cursor only shows up intermittently instead of smoothly - //scrolling across the screen. - const TSize cursorSize(3,20); - const TInt moveInterval=10; - SetCursor(TPoint(0,20),cursorSize,TRgb::Gray256(255),TTextCursor::EFlagNoFlash); - TheClient->Flush(); - User::After(initialRepeatRate); - for(TInt offset=10;offset<=100;offset+=moveInterval) - { - SetCursor(TPoint(offset,20),cursorSize,TRgb::Gray256(255),TTextCursor::EFlagNoFlash); - TheClient->Flush(); - User::After(repeatRate); - } - - //simulate clipped text cursor moving accross the screen - TRect rect(0,20,3,40); - SetCursor(TPoint(0,20),cursorSize,TRgb::Gray256(255),rect,TTextCursor::EFlagNoFlash); - TheClient->Flush(); - User::After(initialRepeatRate); - for(TInt offset=10;offset<=100;offset+=moveInterval) - { - rect.Move(moveInterval,0); - SetCursor(TPoint(offset,20),cursorSize,TRgb::Gray256(255),rect,TTextCursor::EFlagNoFlash); - TheClient->Flush(); - User::After(repeatRate); - } - } -/** What happens when a cursor becomes off-screen when the screen is resized/rotated? - * - * - **/ -void CTCursorTest::INC117232() - { - const TInt initialRepeatRate=300000; // 3/10 seconds should be long enough to update everything! - TInt currMode=TheClient->iScreen->CurrentScreenMode(); - TInt testMode=currMode; - TPixelsTwipsAndRotation currModeSize; - TheClient->iScreen->GetScreenModeSizeAndRotation(currMode, currModeSize); - //find a (rotated) mode where the dimensions of the screen shrank - for (TInt mode=0;modeiScreenModes.Count();mode++) - { - TPixelsTwipsAndRotation testModeSize; - TheClient->iScreen->GetScreenModeSizeAndRotation(mode,testModeSize); - if ( testModeSize.iPixelSize.iWidthSetTestStepResult(EInconclusive); //With this line the whole test fails which is too drastic - return; - } - //enable a cursor on the bottom right corner of the screen - TestWin->SetFullScreenExtL(); - TheClient->Flush(); - iCursorType=TTextCursor::ETypeRectangle; - SetCursor(TPoint(-20,-20)+TestWin->Size(),TSize(40,40),KRgbDarkMagenta,TTextCursor::EFlagNoFlash); - TheClient->Flush(); - User::After(initialRepeatRate); - //shrink the screen - TheClient->iScreen->SetScreenMode(testMode); - TheClient->iScreen->SetAppScreenMode(testMode); - //The defect was that WServ would now crash! - TheClient->Flush(); - User::After(initialRepeatRate); - //Set everything back - TheClient->iScreen->SetScreenMode(currMode); - TheClient->iScreen->SetAppScreenMode(currMode); - TheClient->Flush(); - User::After(initialRepeatRate); - } - -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA -/** - * Sets up a text cursor whose attributes indicate it should not be flashing - * and then checks to ensure this is the actual behaviour. - */ -void CTCursorTest::TextCursorNoFlashTestL() - { - TheClient->iGroup->WinTreeNode()->SetOrdinalPosition(0); - // We use some unique looking colors otherwise its harder - // to spot which test is which - TRgb kGentleYellow(251, 249, 198); - TRgb kGentlePink(253, 196, 221); - - iWorkInProgress = new(ELeave) CBlankWindow(kGentleYellow); - iComparisonWindow = new(ELeave) CBlankWindow(kGentleYellow); - CancelTextCursor(); - TheClient->Flush(); - - const TSize screenSize=TheClient->iGroup->Size(); - const TInt kPad = 5; - const TInt kThirdOfScreenWidth = screenSize.iWidth/3; - const TInt kWinWidth = kThirdOfScreenWidth - 2*kPad; - const TInt kWinHeight = screenSize.iHeight - 2*kPad; - const TSize kWinSize(kWinWidth, kWinHeight); - const TPoint kCursorPos(30, 30); - iWorkInProgress->SetUpL( TPoint( kThirdOfScreenWidth + kPad, kPad), kWinSize, TheClient->iGroup, *TheClient->iGc); - iComparisonWindow->SetUpL(TPoint(2*kThirdOfScreenWidth + kPad, kPad), kWinSize, TheClient->iGroup, *TheClient->iGc); - - TTextCursor nonFlashingCursor; - - nonFlashingCursor.iType = TTextCursor::ETypeRectangle; - nonFlashingCursor.iHeight=kCursorHeight; - nonFlashingCursor.iAscent=0; - nonFlashingCursor.iWidth=kCursorWidth; - nonFlashingCursor.iFlags=TTextCursor::EFlagNoFlash; - nonFlashingCursor.iColor = kGentlePink; // We expect a Flicker Buffer Render Stage to ignore this color - - iWorkInProgress->Invalidate(); - iWorkInProgress->Redraw(); - iComparisonWindow->Invalidate(); - iComparisonWindow->Redraw(); - - DrawTextCursorSimilarToRenderStage(*TheClient->iGc, *iComparisonWindow->Win(), kCursorPos, nonFlashingCursor); - TheClient->iGroup->GroupWin()->SetTextCursor(*iWorkInProgress->BaseWin(), kCursorPos, nonFlashingCursor); - TheClient->Flush(); - - CheckCursorDoesNotFlash(iWorkInProgress->BaseWin()->Size()); - - delete iWorkInProgress; - iWorkInProgress = NULL; - delete iComparisonWindow; - iComparisonWindow = NULL; - } - -void CTCursorTest::TextCursorFlashTestL() - { - TheClient->iGroup->WinTreeNode()->SetOrdinalPosition(0); - // We use some unique looking colors otherwise its harder - // to spot which test is which - TRgb kMildPurple(218, 155, 244); - TRgb kPaleGreen(146, 190, 12); - - iWorkInProgress = new(ELeave) CBlankWindow(kMildPurple); - iComparisonWindow = new(ELeave) CBlankWindow(kMildPurple); - CancelTextCursor(); - TheClient->Flush(); - - const TSize screenSize=TheClient->iGroup->Size(); - const TInt kPad = 5; - const TInt kThirdOfScreenWidth = screenSize.iWidth/3; - const TInt kWinWidth = kThirdOfScreenWidth - 2*kPad; - const TInt kWinHeight = screenSize.iHeight - 2*kPad; - const TSize kWinSize(kWinWidth, kWinHeight); - const TPoint kCursorPos(30, 30); - iWorkInProgress->SetUpL( TPoint( kThirdOfScreenWidth + kPad, kPad), kWinSize, TheClient->iGroup, *TheClient->iGc); - iComparisonWindow->SetUpL(TPoint(2*kThirdOfScreenWidth + kPad, kPad), kWinSize, TheClient->iGroup, *TheClient->iGc); - - TTextCursor flashingCursor; - - flashingCursor.iType = TTextCursor::ETypeRectangle; - flashingCursor.iHeight=kCursorHeight; - flashingCursor.iAscent=0; - flashingCursor.iWidth=kCursorWidth; - flashingCursor.iFlags=0; // implies that cursor SHOULD flash - flashingCursor.iColor = kPaleGreen; // We expect a Flicker Buffer Render Stage to ignore this color - - iWorkInProgress->Invalidate(); - iWorkInProgress->Redraw(); - iComparisonWindow->Invalidate(); - iComparisonWindow->Redraw(); - - DrawTextCursorSimilarToRenderStage(*TheClient->iGc, *iComparisonWindow->Win(), kCursorPos, flashingCursor); - TheClient->iGroup->GroupWin()->SetTextCursor(*iWorkInProgress->BaseWin(), kCursorPos, flashingCursor); - TheClient->Flush(); - - CheckCursorDoesFlash(kCursorPos, flashingCursor, kMildPurple); - CancelTextCursor(); - TheClient->Flush(); - - delete iWorkInProgress; - iWorkInProgress = NULL; - delete iComparisonWindow; - iComparisonWindow = NULL; - } - -void CTCursorTest::DrawTextCursorSimilarToRenderStage(CWindowGc& aGc, RWindow& aWin, const TPoint& aPos, const TTextCursor& aTextCursor) - { - // This method duplicates the way in which the default FlickerBuffer Render - // Stage draws a Text Cursor of ETypeRectangle. @see CFbRenderStage::DrawTextCursor - // This code must be kept in sync with the FlickerBuffer Render Stage - - ASSERT(aTextCursor.iType == TTextCursor::ETypeRectangle); - const TRect updatedRegion(aPos,TSize(aTextCursor.iWidth,aTextCursor.iHeight)); - aWin.Invalidate(); - aWin.BeginRedraw(); - aGc.Activate(aWin); - aGc.Clear(); - aGc.SetBrushStyle(CGraphicsContext::ESolidBrush); - aGc.SetBrushColor(KRgbBlack); - aGc.SetPenStyle(CGraphicsContext::ENullPen); - aGc.Clear(updatedRegion); - aGc.Deactivate(); - aWin.EndRedraw(); - } - -void CTCursorTest::CheckCursorDoesNotFlash(const TSize& aSize) - { - const TInt kSampleTime = 100000; // one tenth of a second - const TInt kSampleLimit = 100; - TInt sampleIteration = 0; - TBool comparisonOkay = EFalse; - - while (sampleIteration < kSampleLimit) - { - comparisonOkay = DoCheckRect(iWorkInProgress, iComparisonWindow, TRect(TPoint(), aSize), CWsScreenDevice::EIncludeTextCursor); - if (!comparisonOkay) - { - INFO_PRINTF2(_L("CheckCursorDoesNotFlash difference found after %d milliseconds"), sampleIteration*100); - break; - } - sampleIteration++; - User::After(kSampleTime); - } - TEST(comparisonOkay); - } - -void CTCursorTest::UpdateCountersOnCursorTransition( - const TBool aTransitionedToOn, - TTime& aNow, - TInt64& aDeltaTime, - TTime& aLastDeltaTime, - TInt& aWarmUpIterations, - const TInt& aFlashChangeTime, - const TInt& aToleranceMargin, - TInt& aSampleNumber, - TInt& aToleranceViolations - ) - { - _LIT(KTxtOn, " On"); - _LIT(KTxtOff, "Off"); - TBufC<3> transitionType; - transitionType = aTransitionedToOn ? KTxtOn : KTxtOff; - - aNow.UniversalTime(); - aDeltaTime = aNow.MicroSecondsFrom(aLastDeltaTime).Int64(); - aLastDeltaTime = aNow; - - if (aWarmUpIterations > 0) - { - aWarmUpIterations--; - } - else - { - if (aDeltaTime > aFlashChangeTime + aToleranceMargin || - aDeltaTime < aFlashChangeTime - aToleranceMargin) - { - INFO_PRINTF5(_L(" Iteration %d, Cursor %S after %d, errorDelta %d microseconds"), - aSampleNumber, &transitionType, I64INT(aDeltaTime), I64INT(aDeltaTime - aFlashChangeTime)); - aToleranceViolations++; - } - } - } -void CTCursorTest::CheckCursorDoesFlash(const TPoint& aPos, const TTextCursor& aTextCursor, TRgb /* aBackgroundColor */) - { - - /** - * Quality of Service based thresholding - * - * The idea behind this test is to identify tolerances which would either - * cause the test to fail when the user would perceive the text cursor as - * not flashing uniformly, or would point to an unexpected delay outside - * the way the flashing (and scheduling of animations) is supposed to work. - * - * Potentially the cursor can be late if we miss a V-SYNC from hardware. In - * such cases we expect to see the cursor on the next frame. Since the V-SYNC - * is typically 1/50 second, a tolerance of two frames, or 1/25 second is reasonable. - * - * If the cursor is delayed longer than this, say a long time of 1 second, but this - * does not happen too often, then the user is likely to still be happy. So we - * set the period of testing to 60 seconds, and set the violations limit to 2. - */ - const TInt kOneSecond = 1000000; - const TInt kFlashPeriod = kOneSecond; // comprises one "ON" and one "OFF" - const TInt kToleranceFactor = 25; // meaning 1/25 of a Flash Period - const TInt kNumberTestFlashPeriods = 60; // meaning 60 Flash Periods worth of testing - const TInt kMaximumToleranceViolations = 2; // number of times an occassional flash may be late or early - - const TInt kToleranceMargin = kFlashPeriod / kToleranceFactor; - const TInt kNumberSamples = kNumberTestFlashPeriods * kToleranceFactor; - const TInt kFlashChangeTime = kFlashPeriod / 2; - - // The first couple of changes to the cursor should be ignored because - // when the test is started, the cursor may have been on for a while. - // Then when the cursor goes off, it appears to have switched to the - // off state too early. We therefore ignore the first two changes - // so we start cleanly. - TInt warmUpIterations = 2; - - // Empirically we see that cursors mostly flash with good timeliness apart from - // occasional events causing them to be either early or late. In order to keep - // a tight tolerance (1/50 second is around the screen refresh time) but still - // allow for the occasional variance (seen to be 1/23 second) we use a counter - // toleranceViolations < kMaximumToleranceViolations - TInt toleranceViolations = 0; - TBool cursorShownLastTime = EFalse; - TBool cursorShown = EFalse; - TTime lastDeltaTime; - TTime now; - TInt64 deltaTime = 0; - lastDeltaTime.UniversalTime(); - now.UniversalTime(); - - TRect textCursorRect(TRect(aPos, TSize(aTextCursor.iWidth, aTextCursor.iHeight))); - - for (TInt sampleNumber = 0; sampleNumber < kNumberSamples; sampleNumber++) - { - cursorShown = DoCheckRect(iWorkInProgress, iComparisonWindow, textCursorRect, CWsScreenDevice::EIncludeTextCursor); - - if (cursorShown && !cursorShownLastTime) - { - cursorShownLastTime = ETrue; - UpdateCountersOnCursorTransition( - cursorShownLastTime, now, deltaTime, lastDeltaTime, warmUpIterations, kFlashChangeTime, - kToleranceMargin, sampleNumber, toleranceViolations); - } - else if (!cursorShown && cursorShownLastTime) - { - cursorShownLastTime = EFalse; - UpdateCountersOnCursorTransition( - cursorShownLastTime, now, deltaTime, lastDeltaTime, warmUpIterations, kFlashChangeTime, - kToleranceMargin, sampleNumber, toleranceViolations); - } - - if (toleranceViolations > kMaximumToleranceViolations) - break; - - User::After(kToleranceMargin); - } - // Check was some flashing - TEST_SOFTFAIL_WINSCW(warmUpIterations == 0); - // Check cursor flashed on and off, regularly and on-time - TEST_SOFTFAIL_WINSCW(toleranceViolations <= kMaximumToleranceViolations); - } -#endif // TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA - -void CTCursorTest::MakeCursors(TTextCursor& aTextCursor, TTextCursor& aCustomCursor) - { - aCustomCursor.iType = KTextCursorInitialIdValue + iTest->iScreenNumber*KNumberOfCustoTextCursors; // custom text cursor - aCustomCursor.iAscent=0; - aCustomCursor.iHeight=kCursorHeight; - aCustomCursor.iWidth=kCursorWidth; - aCustomCursor.iFlags=TTextCursor::EFlagNoFlash; - aCustomCursor.iColor=TRgb::Color256(217); - - // Create a standard cursor for the tests - aTextCursor.iType = TTextCursor::ETypeRectangle; // Normal rectangular text cursor - aTextCursor.iHeight=kCursorHeight; - aTextCursor.iAscent=0; - aTextCursor.iWidth=kCursorWidth; - aTextCursor.iFlags=TTextCursor::EFlagNoFlash; - } - -void CTCursorTest::StartDoubleCursorTestL(TInt aTestNumber) - { - // general setup - CBlankWindow* win1=new(ELeave) CBlankWindow(KRgbWhite); - CleanupStack::PushL(win1); - - win1->SetUpL(kWin1TopLeft,kWinSize,TheClient->iGroup,*TheClient->iGc,EColor64K); - - win1->Redraw(); - - // Create the second window - CBlankWindow* win2=new(ELeave) CBlankWindow(KRgbWhite); - CleanupStack::PushL(win2); - - win2->SetUpL(kWin2TopLeft,kWinSize,TheClient->iGroup,*TheClient->iGc,EColor64K); - win2->Redraw(); - - // Create normal and custom cursor for the tests - TTextCursor textCursor; - TTextCursor customCursor; - MakeCursors(textCursor, customCursor); - - TheClient->Flush(); - CWindowGc* winGc = TheClient->iGc; - - switch(aTestNumber) - { - case 1: - CheckNoDoubleCursorTest1L(win1, win2, textCursor, customCursor, winGc); - break; - - case 2: - CheckNoDoubleCursorTest2L(win1, win2, textCursor, customCursor, winGc); - break; - - case 3: - CheckNoDoubleCursorTest3L(win1, win2, textCursor, customCursor, winGc); - break; - - default: - TEST(EFalse); - break; - } - CleanupStack::PopAndDestroy(2); - } - -// DEF098704 -void CTCursorTest::CheckNoDoubleCursorTest1L(CBlankWindow* aWin1, CBlankWindow* aWin2, TTextCursor& /*aTextCursor*/, TTextCursor& aCustomCursor, CWindowGc* aWinGc) - { - // Test that changing the focus of a custom text cursor does not leave that cursor drawn where it was (INC093898) - - TheClient->iGroup->GroupWin()->SetTextCursor(*aWin1->BaseWin(),TPoint(),aCustomCursor); - - // Bit blit the TEST_BITMAP_NAME image to the second window to use as a comparison - // this is the same image that the custom cursor is using - CFbsBitmap* bitmap = new(ELeave) CFbsBitmap; - CleanupStack::PushL(bitmap); - TEST(KErrNone == bitmap->Load(TEST_BITMAP_NAME,0,ETrue)); - - aWinGc->Activate(*aWin2->Win()); - TRect updateArea(TPoint(0,0), bitmap->SizeInPixels()); - aWin2->Win()->Invalidate(updateArea); - aWin2->Win()->BeginRedraw(updateArea); - aWinGc->BitBlt(TPoint(0,0),bitmap); - aWinGc->Deactivate(); - aWin2->Win()->EndRedraw(); - TheClient->Flush(); - doCheckNoDoubleCursor(aWin1,aWin2,kWin1TopLeft,kWin2TopLeft,aCustomCursor,bitmap->SizeInPixels(),CWsScreenDevice::EIncludeSprite); - CleanupStack::PopAndDestroy(1); // bitmap - } - -// DEF098704 -void CTCursorTest::CheckNoDoubleCursorTest2L(CBlankWindow* aWin1, CBlankWindow* aWin2, TTextCursor& /*aTextCursor*/, TTextCursor& aCustomCursor, CWindowGc* aWinGc) - { - //TEST 2: Checks that no artifacts are left behind when a text cursor is moved from under a transparent sprite - - // Construct the window win1 with a transparent sprite - - // Clear the top and bottom windows - ResetWindows(aWinGc,aWin1,aWin2); - - // Create a bitmap and a corresponding bitmap mask - CFbsBitmap* bitmap = new(ELeave) CFbsBitmap; - CleanupStack::PushL(bitmap); - TEST(KErrNone == bitmap->Load(TEST_BITMAP_NAME,0,ETrue)); - CBitmap* spriteBitmap=CBitmap::NewL(kWinSize,EColor256); - CleanupStack::PushL(spriteBitmap); - spriteBitmap->Gc().SetBrushColor(KRgbBlack); - spriteBitmap->Gc().SetBrushStyle(CGraphicsContext::ESolidBrush); - spriteBitmap->Gc().SetPenStyle(CGraphicsContext::ESolidPen); - spriteBitmap->Gc().DrawRect(TRect(kWinSize)); - CBitmap* mask=CBitmap::NewL(kWinSize,EColor256); - CleanupStack::PushL(mask); - mask->Gc().SetBrushStyle(CGraphicsContext::ESolidBrush); - mask->Gc().SetBrushColor(KRgbBlack); - mask->Gc().DrawRect(TRect(kWinSize)); - - // Create a sprite - RWsSprite sprite = RWsSprite(TheClient->iWs); - CleanupClosePushL(sprite); - TEST(KErrNone == sprite.Construct(*aWin1->BaseWin(),TPoint(),0)); - - // Add the bitmap to the sprite - TSpriteMember member; - member.iInvertMask=EFalse; - member.iDrawMode=CGraphicsContext::EDrawModePEN; - member.iOffset=TPoint(); - member.iInterval=TTimeIntervalMicroSeconds32(0); - member.iBitmap = &spriteBitmap->Bitmap(); - member.iMaskBitmap = &mask->Bitmap(); - TEST(KErrNone == sprite.AppendMember(member)); - - // Activate the sprite in win1 - TEST(KErrNone == sprite.Activate()); - - // Put a cursor in win1 - TheClient->iGroup->GroupWin()->SetTextCursor(*aWin1->BaseWin(),TPoint(),aCustomCursor); - - // Bit blit the matching bitmap to the bottom window - TRect bitmapArea(TPoint(0,0), bitmap->SizeInPixels()); - aWin2->Win()->Invalidate(bitmapArea); - aWin2->Win()->BeginRedraw(bitmapArea); - aWinGc->Activate(*aWin2->Win()); - aWinGc->BitBlt(TPoint(),bitmap); - aWinGc->Deactivate(); - aWin2->Win()->EndRedraw(); - - TheClient->Flush(); - doCheckNoDoubleCursor(aWin1,aWin2,kWin1TopLeft,kWin2TopLeft,aCustomCursor,bitmap->SizeInPixels(),CWsScreenDevice::EIncludeSprite); - CleanupStack::PopAndDestroy(4); // sprite, mask, spriteBitmap, bitmap - } - -// DEF098704 -void CTCursorTest::CheckNoDoubleCursorTest3L(CBlankWindow* aWin1, CBlankWindow* aWin2, TTextCursor& aTextCursor,TTextCursor& aCustomCursor, CWindowGc* aWinGc) - { - // - // TEST 3: Test a flashing text cursor does not leave artifacts when a redraw + change position happens during - // the time the cursor flashing 'off' - // - // This test moves a flashing cursor a number of times over a two second period to a seconds position. - // it does it a number of times so some of the redraws will occur during the 'flash off' period - // We then compare the 'after' position to what we expect - // - // There are four possible outcomes when we look at the bitmap after the redraw + move - // Position 1 is the original position, position 2 is the new position after the redraw - // - // cursor artifact @ pos1 and flashed on cursor @ pos2 - // cursor artifact at pos1 and flashed off cursor @ pos2 - // no artifact at pos1 and flashed off cursor @ pos2 - // no artifact at pos1 and flashed on cursor @ pos2 - // - // any artifacts left over will cause the complete test to fail. - // - - // - // PART A: - aTextCursor.iFlags=0; // flashing - - ResetWindows(aWinGc,aWin1,aWin2); - TestForArtifacts(aWin1, aTextCursor); - - // - // PART B - For a non-custom text cursor - aCustomCursor.iFlags=0; // flashing - - ResetWindows(aWinGc,aWin1,aWin2); - TestForArtifacts(aWin1, aCustomCursor); - } - -// moves the cursor between two positions while flashing and tests no artifacts are left at the position it moved from -// The moves take place in a loop so it is tested happening when the cursor is flashed on and also off -void CTCursorTest::TestForArtifacts(CBlankWindow* aWin1, TTextCursor& aCursor) - { - const TInt KIterations = 30; - const TPoint kStartPos(0,0); - const TPoint kMoveToPos(200,0); - TRect r1(kWin1TopLeft,kCursorSize); - TRect r2(kWin2TopLeft,kCursorSize); - const TPoint kWin1TopLeft; - const TPoint kWin2TopLeft; - const TSize aCursorSize; - - TheClient->iGroup->GroupWin()->SetTextCursor(*aWin1->BaseWin(),kStartPos,aCursor); - TheClient->Flush(); - - TInt initialRepeatRate = 1000000; - const TInt KIncrement = 30000; - TInt i=0; - - for(i=0; iiGroup->GroupWin()->SetTextCursor(*aWin1->BaseWin(),kMoveToPos,aCursor); - TheClient->Flush(); - - User::After(initialRepeatRate); - - // check no artifact was left in position 1 by comparing against (blank) win2 - if(!TheClient->iScreen->RectCompare( r1,r2, CWsScreenDevice::EIncludeTextCursor)) - { - break; // detected an artifact remaining, test failed - } - - // move the cursor back to its start position, this resets the flash timer which is why we increment initialRepeatRate - TheClient->iGroup->GroupWin()->SetTextCursor(*aWin1->BaseWin(),kStartPos,aCursor); - TheClient->Flush(); - initialRepeatRate += KIncrement; - } - - // if all went well i should equal KIterations, if it doesnt its because we detected - // an artifact and quit the test early - TEST_SOFTFAIL_WINSCW(i==KIterations); - } - - -// Tests the two windows match, moves the cursor off win 1 then tests they no longer match -void CTCursorTest::doCheckNoDoubleCursor(CBlankWindow* aWin1, - CBlankWindow* aWin2, - const TPoint& aWin1Tl, - const TPoint& aWin2Tl, - const TTextCursor& aCursor, - const TSize& aCursorSize, - CWsScreenDevice::TSpriteInCompare aFlags) - { - TRect r1(aWin1Tl,aCursorSize); - TRect r2(aWin2Tl,aCursorSize); - - TInt compareTries = 0; - const TInt compareLimit = 5; - - TBool correctComparison = EFalse; - while (!correctComparison && compareTries < compareLimit) - { - compareTries++; - User::After(500000); - correctComparison = TheClient->iScreen->RectCompare(r1,r2, aFlags); - } - - INFO_PRINTF3(_L("Result Before %d (attempts %d)"), correctComparison, compareTries); - TEST_SOFTFAIL_WINSCW(correctComparison); - - - // Change the focus off win1, by drawing the text cursor on the second window - TheClient->iGroup->GroupWin()->SetTextCursor(*aWin2->BaseWin(),aWin2Tl,aCursor); - TheClient->Flush(); - - // Cause a redraw - aWin1->CTWin::DrawNow(); - TheClient->WaitForRedrawsToFinish(); - - // make sure any cursor has actually moved - User::After(1000000); // 1 sec - - TBool resultAfter; - resultAfter = !TheClient->iScreen->RectCompare(r1,r2, aFlags); - INFO_PRINTF2(_L("Result After %d"), resultAfter); - TEST_SOFTFAIL_WINSCW(resultAfter); - } - -// resets the windows to their initial state -void CTCursorTest::ResetWindows(CWindowGc* aWinGc,CBlankWindow* aWin1,CBlankWindow* aWin2) - { - TheClient->iGroup->GroupWin()->CancelTextCursor(); - aWinGc->Activate(*aWin1->Win()); - aWinGc->Reset(); - aWinGc->Clear(); - aWinGc->Deactivate(); - - aWin1->Invalidate(); - aWin1->Redraw(); - aWin2->Invalidate(); - aWin2->Redraw(); - TheClient->Flush(); - } - -void CTCursorTest::RunTestCaseL(TInt /*aCurTestCase*/) - { - TBool deleteMove=EFalse; - ((CTCursorTestStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); - - switch(++iTest->iState) - { -/** -@SYMTestCaseID GRAPHICS-WSERV-0241 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test the text cursor functions properly as a window is moved - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Move a window about the screen and meanwhile check the text - cursor functions correctly - -@SYMTestExpectedResults The text cursor functions correctly as the window is moved -*/ - case 1: - ((CTCursorTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0241")); - while (!deleteMove) - { - if (iCursorType==TTextCursor::ETypeFirst) - iTest->LogSubTest(_L("Cursor 1")); - if (MoveWindow()) - { - if (IncrementCursorType()) - { - ResetMoveWindowsL(); - } - else - { - DeleteMoveWindows(); - deleteMove =true; - } - } - } - break; - -/** -@SYMTestCaseID GRAPHICS-WSERV-0242 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test the text cursor functions properly as the window is scrolled - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Scroll the window and meanwhile check the text cursor functions correctly - -@SYMTestExpectedResults The text cursor functions correctly as the window is scrolled -*/ - case 2: - ((CTCursorTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0242")); - iTest->LogSubTest(_L("Cursor 2")); - iCursorType=TTextCursor::ETypeRectangle; - ScrollTest(); - iCursorType=TTextCursor::ETypeFirst; - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0244 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test the text cursor functions properly as a blank window is moved - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Move a blank window about the screen and meanwhile check the text - cursor functions correctly - -@SYMTestExpectedResults The text cursor functions correctly as the blank window is moved -*/ - case 3: - ((CTCursorTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0244")); - iTest->LogSubTest(_L("Move window1")); - MoveWindowTest1L(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0245 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test that a non flashing text cursor functions properly as a - blank window is moved - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Move a blank window about the screen and meanwhile check that a non - flashing text cursor functions correctly - -@SYMTestExpectedResults The text cursor functions correctly as the blank window is moved -*/ - case 4: - ((CTCursorTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0245")); - while (IncrementCursorType()) - { - iTest->LogSubTest(_L("Move window2")); - MoveWindowTest2L(); - } - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0247 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Tests a Custom Text Cursor Sprite visibility after wserv hearbeat suppression - REQUIREMENT: INC040489. - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Create a window group with an associated window for it, then activate it. - Create another window group with an associated window along with a custom cursor, - then active it. Make a call to suppress the wserv hearbeat, which will stop - the custom cursor from flashing with flash ON state. Bring the first window - group to the foreground and cancel the custom test cursor in the second window group. - After that, put the first window group to the background and set the custom test - cursor in the second window group. Simulate a raw key event to start - the wserv heartbeat, which will make the custom cursor flashing. - -@SYMTestExpectedResults The Custom text cursor in the second window group should be visible and flashing, - when it comes to the foreground after the first window group sent to the background. -*/ - case 5: - ((CTCursorTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0247")); - iTest->LogSubTest(_L("Custom Text Cursor Sprite visibility")); - INC040489L(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-2095-0015 - -@SYMTestCaseDesc Text Cursor allows Update before Rendering the owning window - -@SYMTestPriority Normal - -@SYMTestStatus Implemented - -@SYMTestActions Create a window group and two windows, one with a Text Cursor. - Stimulate a state change in the Text Cursor by receiving - window focus, but before the Window has ever been Rendered. - This shakes out logic in RWsTextCursor which depends on - side effects arising from having executed CWsWindow::Render() - -@SYMTestExpectedResults - There should be no panic or assertion. -*/ - case 6: - ((CTCursorTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-2095-0015")); - iTest->LogSubTest(_L("Update before Render")); - CursorUpdatedBeforeWindowRenderedL(); - break; - -/** -@SYMTestCaseID GRAPHICS-WSERV-0248 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Tests a bad use of text cursor functionality from a client. - REQ 1079, CR RDEF-5F7Q24 (10/04/2003). - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions This test case checks whether the window server is able to detect a bad - use of the text cursor functionality (including the custom text cursor) - by a client. - This test case launches several threads and each of them will try - to use the text cursor functionality in a non-proper way. - -@SYMTestExpectedResults Each new thread has panic code associated to it. This is the expected panic when - the thread dies. - The thread once launched is expected to panic and the returning panic code should - match the expected one. -*/ - case 7: - ((CTCursorTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0248")); - iTest->LogSubTest(_L("Panic")); - TestPanicsL(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0400 - -@SYMDEF PDEF099013 - -@SYMTestCaseDesc Cursor moves slowly in text editors. - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions This test case is a VISUAL TEST only on whether a scrolling text cursor is drawn to the - screen correctly. 2 types of cursor are checked both clipped and non clipped cursors. - In each case the test simulates a text cursor moving across the screen as if a user were - holding down a key to scroll the cursor through a section of text. - -@SYMTestExpectedResults The text cursor in both cases should scroll smoothly to the centre of the screen. - In versions prior to this fix the cursor was not correctly drawn and appeared to move - slowly. -*/ - case 8: - ((CTCursorTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0400")); - iTest->LogSubTest(_L("Text Cursor Update Tests")); - INC097774(); - break; - -/** -@SYMTestCaseID GRAPHICS-WSERV-0401 - -@SYMDEF DEF098704 - -@SYMTestCaseDesc Test code for implemented fix to remove double cursors - -@SYMTestPriority Normal - -@SYMTestStatus Implemented - -@SYMTestActions This test case tests for artifacts left over when normal/custon flashing/non-flashing cursors are drawn. - Test that changing the focus of a custom text cursor does not leave that cursor drawn where it was (INC093898) - -@SYMTestExpectedResults -*/ - case 9: - ((CTCursorTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0401")); - iTest->LogSubTest(_L("Double cursors test 1")); - StartDoubleCursorTestL(1); - break; - - /** - @SYMTestCaseID GRAPHICS-WSERV-0402 - - @SYMDEF DEF098704 - - @SYMTestCaseDesc Test code for implemented fix to remove double cursors - - @SYMTestPriority Normal - - @SYMTestStatus Implemented - - @SYMTestActions Checks that no artifacts are left behind when a text cursor is moved from under a transparent sprite - - @SYMTestExpectedResults - */ - case 10: - ((CTCursorTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0402")); - iTest->LogSubTest(_L("Double cursors test 2")); - StartDoubleCursorTestL(2); - break; - - /** - @SYMTestCaseID GRAPHICS-WSERV-0403 - - @SYMDEF DEF098704 - - @SYMTestCaseDesc Test code for implemented fix to remove double cursors - - @SYMTestPriority Normal - - @SYMTestStatus Implemented - - @SYMTestActions This test moves a flashing cursor a number of times over a two second period to a seconds position. - it does it a number of times so some of the redraws will occur during the 'flash off' period - We then compare the 'after' position to what we expect - - @SYMTestExpectedResults - */ - case 11: - ((CTCursorTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0403")); - iTest->LogSubTest(_L("Double cursors test 3")); - StartDoubleCursorTestL(3); - break; - - /** - @SYMTestCaseID GRAPHICS-WSERV-0483 - - @SYMDEF INC117232 - - @SYMTestCaseDesc Test code: Refreshing cursors becoming offscreen due to screen size change should not panic - - @SYMTestPriority Normal - - @SYMTestStatus Implemented - - @SYMTestActions Create a cursor on bottom right of screen, change to a screen mode that excludes that coordinate - - @SYMTestExpectedResults - The server should not panic. - */ - case 12: - ((CTCursorTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0483")); - iTest->LogSubTest(_L("Screen resize invalidate cursor off-screen")); - INC117232(); - break; - - /** - @SYMTestCaseID GRAPHICS-WSERV-2095-0016 - - @SYMTestCaseDesc Text Cursor flag TTextCursor::EFlagNoFlash honored - - @SYMTestPriority Normal - - @SYMTestStatus Implemented - - @SYMTestActions Create a text cursor with the TTextCursor::EFlagNoFlash setting. Observe the screen over - a short period of time to verify that it remains continuously in the Flash ON state. - - @SYMTestExpectedResults - The text cursor should be always shown. - */ - case 13: - #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA - ((CTCursorTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-2095-0016")); - iTest->LogSubTest(_L("Text cursor EFlagNoFlash test")); - TextCursorNoFlashTestL(); - #endif - break; - - /** - @SYMTestCaseID GRAPHICS-WSERV-2095-0009 - - @SYMTestCaseDesc Text Cursor flashes when flag value is 0 - - @SYMTestPriority Normal - - @SYMTestStatus Implemented - - @SYMTestActions Create a text cursor with the 0 flag setting. Observe the screen over - a short period of time to verify that the cursor flashes ON and OFF at - the correct period of one second. - - @SYMTestExpectedResults - The text cursor should flash. - */ - case 14: - #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA - ((CTCursorTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-2095-0009")); - iTest->LogSubTest(_L("Text cursor will Flash test")); - TextCursorFlashTestL(); - #endif - break; - - /** - @SYMTestCaseID GRAPHICS-WSERV-2095-0017 - - @SYMTestCaseDesc Text Cursor handles different valid Cursor Setttings - - @SYMTestPriority Normal - - @SYMTestStatus Implemented - - @SYMTestActions Create a text cursor and then issue a SetTextCursor. Then repeatedly - call SetTextCursor, varying the arguments relating to the Text Cursor - as well as keeping the arguments the same on one occassion. - - @SYMTestExpectedResults - The system should not panic as the arguments supplied are never invalid. - */ - case 15: - ((CTCursorTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-2095-0017")); - iTest->LogSubTest(_L("SetTextCursor test")); - TextCursorSetLCoverageTests(); - break; - - default: - ((CTCursorTestStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - ((CTCursorTestStep*)iStep)->CloseTMSGraphicsStep(); - TestComplete(); - break; - } - ((CTCursorTestStep*)iStep)->RecordTestResultL(); - } - -__WS_CONSTRUCT_STEP__(CursorTest) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TTEXTCURS.H --- a/windowing/windowserver/tauto/TTEXTCURS.H Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,146 +0,0 @@ - -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef __TTEXTCURS_H__ -#define __TTEXTCURS_H__ - -#include -#include -#include "../tlib/testbase.h" -#include "AUTO.H" -#include "TGraphicsHarness.h" - -/* - * Wrapper class for a custom text cursor. - */ -class CCustomTextCursor : public CBase - { -public: - static CCustomTextCursor* CreateCustomTextCursorL(TInt aScreenNumber,TInt aBmpIndex,CTestBase* aTest); - ~CCustomTextCursor(); - -private: - CCustomTextCursor(CTestBase* aTest); - void ConstructL(TInt aScreenNumber,TInt aBmpIndex); - -public: - TInt iIdentifier; - RArray iSpriteMemberArray; - TUint iSpriteFlags; - RWsSession::TCustomTextCursorAlignment iAlignment; - CTestBase* iTest; - }; - -class CTCursorTest : public CTWsGraphicsBase - { -public: - CTCursorTest(CTestStep* aStep); - ~CTCursorTest(); -protected: -//from CTGraphicsStep - virtual void RunTestCaseL(TInt aCurTestCase); -private: - void SetCursor(const TPoint &aPos,const TSize &aSize,TRgb aColor, TUint aFlags=0); - void SetCursor(const TPoint &aPos,const TSize &aSize,TRgb aColor, const TRect &aRect, TUint aFlags=0); - void SetCursorPlusBox(const TPoint &aPos,const TSize &aSize,TRgb aColor, const TRect *aRect, TUint aFlags=0); - void CancelTextCursor(); - void ConstructL(); - void doMoveWindowTestL(); - TBool MoveWindow(); - void TestPanicsL(); - void ScrollTest(); - void GeneralTestsL(); - void MoveWindowTest1L(); - void MoveWindowTest2L(); - void INC041278L(); - void INC040489L(); - void CursorUpdatedBeforeWindowRenderedL(); - void INC097774(); - void INC117232(); -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA - void TextCursorNoFlashTestL(); - void TextCursorFlashTestL(); - void CheckCursorDoesNotFlash(const TSize& aSize); - void UpdateCountersOnCursorTransition( - const TBool aTransitionedToOn, - TTime& aNow, - TInt64& aDeltaTime, - TTime& aLastDeltaTime, - TInt& aWarmUpIterations, - const TInt& aFlashChangeTime, - const TInt& aToleranceMargin, - TInt& aSampleNumber, - TInt& aToleranceViolations - ); - void CheckCursorDoesFlash(const TPoint& aPos, const TTextCursor& aTextCursor, TRgb aBackgroundColor); - void DrawTextCursorSimilarToRenderStage(CWindowGc& aGc, RWindow& aWin, const TPoint& aPos, const TTextCursor& aTextCursor); -#endif - TBool IncrementCursorType(); - CTSprite* CreateTestSpriteLC(RWindowTreeNode &aWindow, const TPoint &aPos, TInt aCount); - void TestForArtifacts(CBlankWindow* aWin1, TTextCursor& aCursor); - void CheckNoDoubleCursorTest1L(CBlankWindow* aWin1, CBlankWindow* win2, TTextCursor& aTextCursor,TTextCursor& aCustomCursor, CWindowGc* winGc); - void CheckNoDoubleCursorTest2L(CBlankWindow* aWin1, CBlankWindow* win2, TTextCursor& aTextCursor,TTextCursor& aCustomCursor, CWindowGc* winGc); - void CheckNoDoubleCursorTest3L(CBlankWindow* aWin1, CBlankWindow* win2, TTextCursor& aTextCursor,TTextCursor& aCustomCursor, CWindowGc* winGc); - void MakeCursors(TTextCursor& aTextCursor, TTextCursor& aCustomCursor); - void StartDoubleCursorTestL(TInt aTestNumber); - void doCheckNoDoubleCursor(CBlankWindow* aWin1, - CBlankWindow* aWin2, - const TPoint& aWin1Tl, - const TPoint& aWin1T2, - const TTextCursor& aCursor, - const TSize& aCursorSize, - CWsScreenDevice::TSpriteInCompare aFlags); - - void ResetWindows(CWindowGc* aWinGc,CBlankWindow* aWin1,CBlankWindow* aWin2); - void ValidateWin(TestWindow *aWin, TRgb aColor); - void RedrawWin(RWindow &aWin, TRgb aColor); - void DeleteMoveWindows(); - void ResetMoveWindowsL(); - static TInt DoPanicTest(TInt aInt, TAny *aScreenNumber); - void TextCursorSetLCoverageTests(); - -private: - TSize iWinSize; - TPoint iWinPos; - TInt iWinState; - CBlankWindow *iMoveWin; - CBlankWindow *iCheckWin; - CBlankWindow *iWorkInProgress; - CBlankWindow *iComparisonWindow; - TTextCursor::EType iCursorType; - static CTestBase* iStaticTest; // static because it is used by DoPanicTest - }; - - -class CTCursorTestStep : public CTGraphicsStep - { -public: - CTCursorTestStep(); -protected: - //from CTGraphicsStep - virtual CTGraphicsBase* CreateTestL(); - }; - -_LIT(KTCursorTestStep,"TCursorTest"); - - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TTransptAnim.cpp --- a/windowing/windowserver/tauto/TTransptAnim.cpp Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,367 +0,0 @@ -// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ -#include "TTransptAnim.h" - -struct FrameSet - { - TRgb* iFrames; - const TInt iFrameCount; - FrameSet(TRgb* aFrames, const TInt aFrameCount) - : iFrames(aFrames), - iFrameCount(aFrameCount) - { - } - }; - -TRgb FrameSequenceAlpha[]= -{ TRgb(255, 0, 0, 50), TRgb(0, 255, 0, 70), TRgb(0, 0, 255, 100), TRgb(255, 255, 0, 150), TRgb(0, 255, 255, 200) }; -TRgb FrameSequenceNoAlpha[] = -{ TRgb(255, 0, 0), TRgb(0, 255, 0), TRgb(0, 0, 255), TRgb(255, 255, 0), TRgb(0, 255, 255) }; - -FrameSet frameSetAlpha(FrameSequenceAlpha, sizeof(FrameSequenceAlpha)/sizeof(TRgb)); -FrameSet frameSetNoAlpha(FrameSequenceNoAlpha, sizeof(FrameSequenceNoAlpha)/sizeof(TRgb)); -FrameSet TestFrameSets[] = - { - frameSetAlpha, frameSetNoAlpha - }; - -static const TInt FRAME_DELAY = 2000000; -static const TInt DRAW_LINE_ANIMATION = 36; -static const TBool ALPHATRANSPARENCY_ON = ETrue; -static const TInt ALPHA_FRAMESET = 0; - -//***************************************************************************** -CTTestCase* CTTransparentAnim::CreateTestCaseL(CTTransparentAnim* aTransAnim, TInt aTestCaseId) - { - CTTestCase* testCase = aTransAnim->GetCurrent(); - - if (!testCase) - { - switch (aTestCaseId) - { - case GraphicsWServ0483 : - testCase = CTGraphicsWServ0483::NewL(); - break; - } - } - - return testCase; - } - -//***************************************************************************** -CTTransparentAnim::CTTransparentAnim(CTestStep* aStep) -: CTWsGraphicsBase(aStep), iCurrentTestCase(NULL) - {} - -CTTransparentAnim::~CTTransparentAnim() - { - TheClient->iWs.SetAutoFlush(EFalse); - } - -void CTTransparentAnim::ConstructL() - { - TheClient->iWs.SetAutoFlush(ETrue); - } - -void CTTransparentAnim::RunTestCaseL(TInt) - { - ((CTTransparentAnimStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0483")); - CTTestCase* testCase = CTTransparentAnim::CreateTestCaseL(this, iTest->iState); - - if (!testCase) - { - TestComplete(); - return ; - } - - TInt err = KErrNone; - - if (!testCase->IsAlreadyRunning()) - { - SetCurrent(testCase); - iTest->LogSubTest(testCase->TestCaseName()); - TRAP(err, testCase->StartL()); - testCase->SetError(err); - } - - if (testCase->IsComplete() || err != KErrNone) - { - ((CTTransparentAnimStep*)iStep)->RecordTestResultL(); - ((CTTransparentAnimStep*)iStep)->CloseTMSGraphicsStep(); - if (testCase->HasFailed()) - { - INFO_PRINTF3(_L("ErrorStatus - Expected: %d, Actual: %d"), ETrue, EFalse); - } - ++iTest->iState; - SetCurrent(NULL); - delete testCase; - } - else - { - // Prevent test harness from repeatedly running the test case too quickly. - User::After(TTimeIntervalMicroSeconds32(FRAME_DELAY)); - } - } - -void CTTransparentAnim::SetCurrent(CTTestCase* aTestCase) - { - iCurrentTestCase = aTestCase; - } - -CTTestCase* CTTransparentAnim::GetCurrent() - { - return iCurrentTestCase; - } - -//***************************************************************************** -CTTAnimation::CTTAnimation(CTWin* aWin, TInt aDrawArg) -: iWin(aWin), iFrameCount(0), iCurrentFrameSet(0), iIsComplete(EFalse), iDrawArg(aDrawArg) - { - iAnimDll = RAnimDll(TheClient->iWs); - iAnimDll.Load(KAnimDLLName); - iDrawAnim = RTestAnim(iAnimDll); - iDrawAnim.Construct(*iWin->BaseWin(), EAnimTypeTrans, TPckgBuf(aWin->Size())); - } - -CTTAnimation::~CTTAnimation() - { - iDrawAnim.Close(); - iAnimDll.Close(); - delete iWin; - } - -void CTTAnimation::StartL() - { - iAnimTimer.ConstructL(); - iAnimTimer.Start(FRAME_DELAY, TCallBack(CTTAnimation::NextFrame,this)); - } - -TBool CTTAnimation::IsComplete() - { - return iIsComplete; - } - -void CTTAnimation::SetCurrentFrameSet(TInt aFrameSet) - { - iCurrentFrameSet = aFrameSet; - } - -CTWin* CTTAnimation::GetWindow() - { - return iWin; - } - -void CTTAnimation::Attach(MAnimationObserver* aObserver) - { - iObserver = aObserver; - } - -TInt CTTAnimation::NextFrame(TAny* aAnim) - { - STATIC_CAST(CTTAnimation*,aAnim)->NextFrame(); - - return KErrNone; - } - -void CTTAnimation::NextFrame() - { - TRgb Color; - TPckgBuf paramsPckg; - - if (iFrameCount == TestFrameSets[iCurrentFrameSet].iFrameCount) - { - iIsComplete = ETrue; - iObserver->Update(this); - return ; - } - - Color = TestFrameSets[iCurrentFrameSet].iFrames[iFrameCount++]; - - paramsPckg().draw = iDrawArg; - paramsPckg().color = Color; - - iDrawAnim.Command(EADllNextFrame, paramsPckg); - - iAnimTimer.Start(FRAME_DELAY, TCallBack(CTTAnimation::NextFrame,this)); - } - -//***************************************************************************** -CTransAnimTimer::CTransAnimTimer() -: CTimer(EPriorityStandard) - {} - -CTransAnimTimer::~CTransAnimTimer() - {} - -void CTransAnimTimer::ConstructL() - { - CTimer::ConstructL(); - CActiveScheduler::Add(this); - } - -void CTransAnimTimer::RunL() - { - iCallBack.CallBack(); - } - -void CTransAnimTimer::Start(TTimeIntervalMicroSeconds32 aInterval,TCallBack aCallBack) - { - iCallBack = aCallBack; - After(aInterval); - } - -//***************************************************************************** -CTTestCase::CTTestCase() -: iError(KErrNone), iIsComplete(EFalse), iIsRunning(EFalse) - {} - -TBool CTTestCase::IsAlreadyRunning() - { - return iIsRunning; - } - -void CTTestCase::Update(CTTAnimation* aAnim) - { - iIsComplete = aAnim->IsComplete(); - } - -TBool CTTestCase::IsComplete() - { - return iIsComplete; - } - -void CTTestCase::StartL() - { - if (!iIsRunning) - { - RunTestCaseL(); - iIsRunning = ETrue; - } - } - -TBool CTTestCase::HasFailed() - { - TBool ret = EFalse; - if (iError != KErrNone) - { - ret = ETrue; - } - return ret; - } - -void CTTestCase::SetIsCompleted(TBool aIsComplete) - { - iIsComplete = aIsComplete; - } - -void CTTestCase::SetError(TInt aError) - { - iError = aError; - } - -//*********************** New Test Case Classes go here************************ - -/** - * @SYMTestCaseID GRAPHICS-WSERV-0483 - * - * @SYMTestCaseDesc There are two animations running, one attached to a transparent - * window using SetTransparencyAlphaChannel and a second animation with a non-transparent - * window. The animations draw a line and then change the color of the line in subsequent - * frames. After the last frame the alpha channel for the first animation is set to - * opaque and then compared with the second animation to make certain that no artifacts - * are present. - * - * @SYMTestPriority High - * - * @SYMTestStatus Implemented - * - * @SYMTestActions An anim is attached with a Transparent window. - * The anim draws several frames using WSERV's Anim animation functionality. - * - * @SYMTestExpectedResults Both animations draw a line and then change it's color, the first - * animation doing it in a tranparent window and the second doing it in a non-transparent window. - **/ -CTGraphicsWServ0483* CTGraphicsWServ0483::NewL() - { - CTGraphicsWServ0483* testCase = new(ELeave) CTGraphicsWServ0483(); - - CleanupStack::PushL(testCase); - testCase->ConstructL(); - CleanupStack::Pop(); - - return testCase; - } - -CTGraphicsWServ0483::~CTGraphicsWServ0483() - { - delete iAnim; - delete iCheckAnim; - } - -void CTGraphicsWServ0483::ConstructL() - { - iAnim = new(ELeave) CTTAnimation(CTAnimWin::NewL( - BaseWin->GetBorderWin()->Position(), - BaseWin->GetBorderWin()->Size()), DRAW_LINE_ANIMATION); - - iCheckAnim = new(ELeave) CTTAnimation(CTAnimWin<>::NewL( - TestWin->GetBorderWin()->Position(), - TestWin->GetBorderWin()->Size()), DRAW_LINE_ANIMATION); - TheClient->WaitForRedrawsToFinish(); - } - -void CTGraphicsWServ0483::RunTestCaseL() - { - iAnim->Attach(this); - iCheckAnim->Attach(this); - - iAnim->SetCurrentFrameSet(ALPHA_FRAMESET); - iAnim->StartL(); - - iCheckAnim->SetCurrentFrameSet(ALPHA_FRAMESET); - iCheckAnim->StartL(); - } - -void CTGraphicsWServ0483::Update(CTTAnimation*) - { - if (iAnim->IsComplete() && iCheckAnim->IsComplete()) - { - TRgb bgColor(150, 150, 150, 255); - iAnim->GetWindow()->Win()->SetBackgroundColor(bgColor); - iAnim->GetWindow()->Win()->Invalidate(); - TheClient->iWs.Finish(); - TheClient->WaitForRedrawsToFinish(); - if (!DoCheckRect(iAnim->GetWindow(), iCheckAnim->GetWindow())) - { - SetError(KErrGeneral); - } - SetIsCompleted(ETrue); - } - } - -TPtrC CTGraphicsWServ0483::TestCaseName() - { - _LIT(KTransparentAlphaChannelAnimationTest, "Transparent Anim Test"); - - return TPtrC(KTransparentAlphaChannelAnimationTest); - } - -__WS_CONSTRUCT_STEP__(TransparentAnim) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TTransptAnim.h --- a/windowing/windowserver/tauto/TTransptAnim.h Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,203 +0,0 @@ - -// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ -#ifndef __TTRANSPTANIM__ -#define __TTRANSPTANIM__ - -#include -#include -#include -#include "../tlib/testbase.h" -#include "AUTO.H" -#include "AUTODLL.H" - -enum - { - GraphicsWServ0483 = 0 - }; - -class CTTestCase; -class CTransAnimTimer; -class CTTransparentAnim; -class CTTAnimation; -class MAnimationObserver; - -class CTTransparentAnim : public CTWsGraphicsBase - { -public: - static CTTestCase* CreateTestCaseL(CTTransparentAnim*, TInt); -public: - CTTransparentAnim(CTestStep*); - virtual ~CTTransparentAnim(); - void ConstructL(); - - void SetCurrent(CTTestCase*); - CTTestCase* GetCurrent(); -protected: - virtual void RunTestCaseL(TInt); - -private: - CTTestCase* iCurrentTestCase; - }; - -class CTTransparentAnimStep : public CTGraphicsStep - { -public: - CTTransparentAnimStep(); - -protected: - virtual CTGraphicsBase* CreateTestL(); - }; - -class CTransAnimTimer : public CTimer - { -public: - CTransAnimTimer(); - ~CTransAnimTimer(); - void ConstructL(); - void Start(TTimeIntervalMicroSeconds32 aInterval,TCallBack aCallBack); -private: - void RunL(); - TCallBack iCallBack; - }; - -class CTTAnimation - { -public: - CTTAnimation(CTWin*, TInt); - ~CTTAnimation(); - - void StartL(); - TBool IsComplete(); - void SetCurrentFrameSet(TInt); - CTWin* GetWindow(); - void Attach(MAnimationObserver*); -private: - static TInt NextFrame(TAny*); - void NextFrame(); - -private: - CTWin* iWin; - MAnimationObserver* iObserver; - RAnimDll iAnimDll; - RTestAnim iDrawAnim; - CTransAnimTimer iAnimTimer; - TInt iFrameCount; - TInt iCurrentFrameSet; - TBool iIsComplete; - TInt iDrawArg; - }; - -template -class CTAnimWin : public CTWin - { -public: - static CTWin* NewL(TPoint aPosition, TSize aSize) - { - CTAnimWin* w = new(ELeave) CTAnimWin(); - - CleanupStack::PushL(w); - w->ConstructL(aPosition, aSize); - CleanupStack::Pop(); - - return w; - } -public: - virtual ~CTAnimWin(){} - - void Draw(){} -private: - CTAnimWin(){} - - void ConstructL(TPoint aPoint, TSize aSize) - { - TRgb bgColor(150, 150, 150); - ConstructExtLD(*TheClient->iGroup, aPoint, aSize); - AssignGC(*TheClient->iGc); - Win()->SetRequiredDisplayMode(EColor16MA); - if (AlphaTransparency) - { - Win()->SetTransparencyAlphaChannel(); - bgColor.SetAlpha(150); - } - Win()->SetBackgroundColor(bgColor); - Win()->Activate(); - } - }; - -//***************************************************************************** -class MAnimationObserver - { -public: - virtual void Update(CTTAnimation*) = 0; - }; - -class CTTestCase : public MAnimationObserver - { -public: - CTTestCase(); - virtual ~CTTestCase() {} - - TBool IsAlreadyRunning(); - TBool IsComplete(); - void StartL(); - TBool HasFailed(); - void SetError(TInt); - - // Implemented for MAnimationObserver - virtual void Update(CTTAnimation*); - virtual void ConstructL() = 0; - virtual TPtrC TestCaseName() = 0; - -protected: - virtual void RunTestCaseL() = 0; - void SetIsCompleted(TBool); - -private: - TInt iError; - TBool iIsComplete; - TBool iIsRunning; - }; - -class CTGraphicsWServ0483 : public CTTestCase - { -public: - static CTGraphicsWServ0483* NewL(); - -public: - virtual ~CTGraphicsWServ0483(); - virtual void RunTestCaseL(); - - void Update(CTTAnimation*); - -protected: - CTGraphicsWServ0483(){} - virtual void ConstructL(); - virtual TPtrC TestCaseName(); - -private: - CTTAnimation* iAnim; - CTTAnimation* iCheckAnim; - }; - -_LIT(KTTransparentAnimStep,"TTransparentAnim"); - -#endif // __TTRANSPTANIM__ diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TWINDOW.CPP --- a/windowing/windowserver/tauto/TWINDOW.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2943 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// General window tests -// -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include "TWINDOW.H" - -const TInt ENumCornerInsets=6; -const TInt corner0[ENumCornerInsets]={0,0,0,0,0,0}; -const TInt corner1[ENumCornerInsets]={1,0,0,0,0,0}; -const TInt corner2[ENumCornerInsets]={2,1,0,0,0,0}; -const TInt corner3[ENumCornerInsets]={3,1,1,0,0,0}; -const TInt corner5[ENumCornerInsets]={5,3,2,1,1,0}; -const TInt KBaseUserEvent=61750; //0xF136 - a random number that is unlikely to be used by other applicaions for user event sending - -// - -CWinTestWindow::CWinTestWindow(TRgb aCol) : CBlankWindow(aCol) - { - } - -CWinTestWindow::~CWinTestWindow() - { - delete iChild; - } - -void CWinTestWindow::ConstructL(TPoint pos,TSize size,CTWinBase *aParent, CWindowGc &aGc, TInt aDepth) - { - iWin=RWindow(TheClient->iWs); - User::LeaveIfError(iWin.Construct(*(aParent->WinTreeNode()),ENullWsHandle)); - SetExt(pos,size); - if (aDepth<3) - { - iChild=new(ELeave) CWinTestWindow(TRgb::Gray256(iCol.Gray256()+34)); - size.iWidth-=8; - size.iHeight-=8; - iChild->ConstructL(TPoint(4,4),size,this,aGc,aDepth+1); - } - Activate(); - AssignGC(aGc); - } - -// - -CEvWindowGroup* CEvWindowGroup::NewLC(CTClient* aClient,CTWsGraphicsBase* aTest) - { - CEvWindowGroup* self=new(ELeave) CEvWindowGroup(aClient,aTest); - CleanupStack::PushL(self); - self->ConstructL(); - return self; - } - -CEvWindowGroup::CEvWindowGroup(CTClient* aClient,CTWsGraphicsBase* aTest) : CTWindowGroup(aClient), iTest(aTest) - {} - -void CEvWindowGroup::ConstructL() - { - CTWindowGroup::ConstructL(); - iGroupWin.EnableReceiptOfFocus(EFalse); - } - -void CEvWindowGroup::SetExpectedEvent(TInt aType) - { - iTest->TEST(!iExpectingEvent); - if (iExpectingEvent) - { - _LIT(KLog,"Setting expected event of type %d, when previouse event of type %d has not arrived (GpWinId=%d)."); - iTest->LOG_MESSAGE4(KLog,aType,iExpectedEvent,iGroupWin.Identifier()); - } - iExpectedEvent=aType; - iExpectingEvent=ETrue; - } - -void CEvWindowGroup::SendEvent(TInt aType) - { - TWsEvent event; - event.SetType(aType); - iClient->iWs.SendEventToWindowGroup(iGroupWin.Identifier(),event); - SetExpectedEvent(aType); - iClient->Flush(); - } - -void CEvWindowGroup::UserEvent(TInt aEventType) - { - iTest->TEST(iExpectingEvent && iExpectedEvent==aEventType); - if (!iExpectingEvent || iExpectedEvent!=aEventType) - { - TInt id=iGroupWin.Identifier(); - if (!iExpectingEvent) - { - _LIT(KLog,"Event of type %d recieved when not expecting an event (GpWinId=%d)."); - iTest->LOG_MESSAGE3(KLog,aEventType,id); - } - else - { - _LIT(KLog,"Event of type %d when expecting an event of type %d (GpWinId=%d)."); - iTest->LOG_MESSAGE4(KLog,aEventType,iExpectingEvent,id); - } - } - iExpectingEvent=EFalse; - } - -// - -CTWindowTest::CTWindowTest(CTestStep* aStep) : CTWsGraphicsBase(aStep) - {} - -CTWindowTest::~CTWindowTest() - { - delete iWin; - } - -void CTWindowTest::ConstructL() - {} - -TInt CTWindowTest::MoveGroup(TAny* aParam) - { - RWsSession ws; - TInt err=ws.Connect(); - if (err==KErrNone) - { - TInt command=static_cast(aParam)->iCommand; - err=ws.SetWindowGroupOrdinalPosition(command&EIdMask,(command&EPosMask)>>EPosShift); - ws.Finish(); - ws.Close(); - } - return err; - } - -void CTWindowTest::CreateTestWindowL() - { - iWin=new(ELeave) CWinTestWindow(TRgb(0,0,0)); - iWin->ConstructL(TPoint(1,1),TSize(TestWin->Size().iWidth/2,TestWin->Size().iHeight/2),TheClient->iGroup,*TheClient->iGc,0); - } - -void CTWindowTest::DrawWindows(CWinTestWindow *aWin) - { - if (aWin->iChild) - DrawWindows(aWin->iChild); - aWin->Win()->BeginRedraw(); - TheGc->Activate(*aWin->Win()); - TheGc->DrawRect(TRect(aWin->Win()->Size())); - TheGc->Deactivate(); - aWin->Win()->EndRedraw(); - TheClient->iWs.Flush(); - } - -void CTWindowTest::CheckAndDestroyWindows() - { - DrawWindows(iWin); - delete iWin; - iWin=NULL; - } - -void CTWindowTest::DestroyWindowWithActiveGc() - { - iWin->Win()->BeginRedraw(); - TheGc->Activate(*iWin->Win()); - delete iWin; - TheGc->Deactivate(); - iWin=NULL; - } - -void CTWindowTest::DestroyWindowWithActiveGc2L() - { - iWin->Win()->BeginRedraw(); - TheGc->Activate(*iWin->Win()); - CWindowGc *gc1=new(ELeave) CWindowGc(TheClient->iScreen); - CWindowGc *gc2=new(ELeave) CWindowGc(TheClient->iScreen); - CWindowGc *gc3=new(ELeave) CWindowGc(TheClient->iScreen); - gc1->Construct(); - gc2->Construct(); - gc3->Construct(); - gc1->Activate(*iWin->Win()); - gc2->Activate(*iWin->Win()); - gc3->Activate(*iWin->Win()); - delete iWin; - TheGc->Deactivate(); - delete gc1; - delete gc2; - delete gc3; - iWin=NULL; - } - -LOCAL_C TInt DoPanicTest(TInt aInt, TAny *aScreenNumber) - { - RWsSession ws; - User::LeaveIfError(ws.Connect()); - // use correct screen - // - CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws); - User::LeaveIfError(screen->Construct((TInt)aScreenNumber)); - - RWindowGroup group(ws); - group.Construct(888); - group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close - - RWindow redraw(ws); - redraw.Construct(group,88); - - RBackedUpWindow backedUp(ws); - backedUp.Construct(group,EGray16,99); - - RBlankWindow blank(ws); - blank.Construct(group,111); - - RWindowBase *base=NULL; - TInt source=aInt/10000; - TInt target=(aInt%10000)/100; - TInt panic=aInt%100; - switch(source) - { - case 0: - base= &redraw; - break; - case 1: - base= &backedUp; - break; - case 2: - base= ␣ - break; - } - switch(target) - { - case 0: - { - RWindow *win=(RWindow *)base; - switch(panic) - { - case 0: - win->BeginRedraw(); - break; - case 1: - ws.SetAutoFlush(ETrue); - win->BeginRedraw(TRect(0,0,1,1)); - ws.SetAutoFlush(EFalse); - break; - case 2: - ws.SetAutoFlush(ETrue); - win->EndRedraw(); - ws.SetAutoFlush(EFalse); - break; - case 3: - win->Invalidate(); - break; - case 4: - win->Invalidate(TRect(0,0,1,1)); - break; - case 5: - { - RRegion region; - win->GetInvalidRegion(region); - } - break; - case 6: - win->SetBackgroundColor(TRgb(0,0,0)); - break; - case 7: - return(EWsExitReasonFinished); - } - break; - } - case 1: - { - RBackedUpWindow *win=(RBackedUpWindow *)base; - switch(panic) - { - case 0: - win->BitmapHandle(); - break; - case 1: - win->UpdateScreen(); - break; - case 2: - win->UpdateScreen(TRegionFix<1>(TRect(10,10,20,20))); - break; - case 3: - win->UpdateBackupBitmap(); - break; - case 4: - win->MaintainBackup(); - break; - case 5: - return(EWsExitReasonFinished); - } - break; - } - case 2: - { - RBlankWindow *win=(RBlankWindow *)base; - switch(panic) - { - case 0: - win->SetColor(TRgb(0)); - break; - case 1: - return(EWsExitReasonFinished); - } - break; - } - } - ws.Flush(); - return(EWsExitReasonBad); // Should never get here, but it's baaddd if it does - } - -struct TWsLocalStructure - { - TInt xPos; - TInt yPos; - TInt Length; - TAny *ptr; - }; - -LOCAL_C TInt DoPanicTest2(TInt aInt, TAny *aScreenNumber) - { - RWsSession ws; - User::LeaveIfError(ws.Connect()); -// - CWsScreenDevice *screen=new(ELeave) CWsScreenDevice(ws); - screen->Construct((TInt)aScreenNumber); -// - RWindowGroup group(ws); - group.Construct(999); - group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close - - RWindow win(ws); - win.Construct(group,122); - win.Activate(); - - switch(aInt) - { - case 0: - { - win.BeginRedraw(); - CWindowGc *gc; - screen->CreateContext(gc); - gc->Activate(win); - CFbsFont *font; - screen->GetNearestFontToDesignHeightInTwips((CFont *&)font,TFontSpec()); - gc->UseFont(font); - TWsLocalStructure params; - params.xPos=0; - params.yPos=0; - params.Length=1; - TPckgC pkg(params); - TPtr8 ptr(NULL,10,10); - ws.TestWriteReplyByProvidingRemoteReadAccess(gc->WsHandle(),EWsGcOpDrawTextPtr,pkg,ptr); // Bad source descriptor - } - break; - case 1: - { - TPtr8 bad(NULL,0); // Bad descriptor - ws.TestWriteReplyP(win.WsHandle(),EWsWinOpSize,NULL,0,&bad); // Bad descriptor - } - break; - case 2: - { - TSize size; - TPtr8 bad((TUint8 *)&size,4,4); // Short descriptor - ws.TestWriteReplyP(win.WsHandle(),EWsWinOpSize,NULL,0,&bad); // Short descriptor - } - break; - case 3: - win.EnablePointerMoveBuffer(); - break; - case 4: - { - RBackedUpWindow backup(ws); - backup.Construct(group,EGray16,123); - backup.Activate(); - backup.SetRequiredDisplayMode(EGray16); - } - break; - default: - return(EWsExitReasonFinished); - } - ws.Flush(); - return(EWsExitReasonBad); // Should never get here, but it's baaddd if it does - } - -LOCAL_C TInt CallWindowFuction(RWindowTreeNode* aWin,TInt aWinType,TInt aFunc,RWsSession aWs) - { - switch(aWinType) - { - case 0: //Call functions from RWindowTreeNode - { - RWindowTreeNode* win=aWin; - switch(aFunc) - { - case 0: - win->OrdinalPosition(); - break; - case 1: - win->SetOrdinalPosition(1); - break; - case 2: - win->SetOrdinalPosition(1,2); - break; - case 3: - win->FullOrdinalPosition(); - break; - case 4: - win->Parent(); - break; - case 5: - win->PrevSibling(); - break; - case 6: - win->SetFaded(0,RWindowTreeNode::EFadeIncludeChildren); - break; - case 7: - win->WindowGroupId(); - break; - //The following can be called on a window with no parent without panicking - case 8: - win->ClearPointerCursor(); - break; - case 9: - win->ClientHandle(); - break; - case 10: - win->DisableErrorMessages(); - break; - case 11: - win->DisableFocusChangeEvents(); - break; - case 12: - win->DisableGroupChangeEvents(); - break; - case 13: - win->DisableGroupListChangeEvents(); - break; - case 14: - win->DisableModifierChangedEvents(); - break; - case 15: - win->DisableOnEvents(); - break; - case 16: - win->DisableVisibilityChangeEvents(); - break; - case 17: - win->EnableErrorMessages(EEventControlAlways); - break; - case 18: - win->EnableFocusChangeEvents(); - break; - case 19: - win->EnableGroupChangeEvents(); - break; - case 20: - win->EnableGroupListChangeEvents(); - break; - case 21: - win->EnableModifierChangedEvents(0,EEventControlAlways); - break; - case 22: - win->EnableVisibilityChangeEvents(); - break; - case 23: - win->NextSibling(); - break; - case 24: - win->OrdinalPriority(); - break; - case 25: - win->SetNonFading(0); - break; - case 26: - win->SetPointerCursor(0); - break; - case 27: - win->Child(); - break; - case 28: - return(EWsExitReasonFinished); - default:; - } - } - break; - case 1: //Call functions from RWindowGroup - { - RWindowGroup* win=(RWindowGroup*)aWin; - switch(aFunc) - { - case 0: - win->EnableReceiptOfFocus(ETrue); - break; - case 1: - win->AutoForeground(ETrue); - break; - case 2: - win->SetOrdinalPriorityAdjust(5); - break; - case 3: - win->CaptureKey(20,0,0); - break; - case 4: - win->CaptureKeyUpAndDowns(20,0,0); - break; - case 5: - case 6: - { - RWindowGroup group(aWs); - group.Construct(876); - group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close - if (aFunc==5) - win->CancelCaptureKey(group.CaptureKey(20,0,0)); - else - win->CancelCaptureKeyUpAndDowns(group.CaptureKeyUpAndDowns(20,0,0)); - } - break; - case 7: - win->AddPriorityKey(20,0,0); - break; - case 8: - win->RemovePriorityKey(20,0,0); - break; - case 9: - case 10: - { - RWindowGroup group(aWs); - group.Construct(765); - group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close - RWindow window(aWs); - window.Construct(group,79); - if (aFunc==9) - win->SetTextCursor(window,TPoint(45,46),TTextCursor()); - else - win->SetTextCursor(window,TPoint(55,66),TTextCursor(),TRect(TSize(5,8))); - } - break; - case 11: - win->CancelTextCursor(); - break; - case 12: - win->SetOwningWindowGroup(456); - break; - case 13: - win->DefaultOwningWindow(); - break; - case 14: - { - TBufC<8> text(_L("abcdef")); - win->SetName(text); - } - break; - case 15: - { - TBuf<16> text; - User::LeaveIfError(win->Name(text)); - } - break; - case 16: - win->Identifier(); - break; - case 17: - win->DisableKeyClick(ETrue); - break; - case 18: - /*{ - TPtr8 text(NULL,0); - TUid uid; - User::LeaveIfError(win->FetchMessage(uid,text)); - }*/ - win->Identifier(); - break; - case 19: - User::LeaveIfError(win->EnableScreenChangeEvents()); - break; - case 20: - win->EnableScreenChangeEvents(); - break; - case 21: - win->DisableScreenChangeEvents(); - break; - case 22: - win->SimulatePointerEvent(TRawEvent()); - break; -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA - case 23: - win->SimulateAdvancedPointerEvent(TRawEvent()); - break; - case 24: - return(EWsExitReasonFinished); -#else - case 23: - return(EWsExitReasonFinished); -#endif - default:; - } - } - break; - case 2: //Call functions from RWindowBase - { - RWindowBase* win=(RWindowBase*)aWin; - switch(aFunc) - { - case 0: - win->SetPosition(TPoint(7,8)); - break; - case 1: - User::LeaveIfError(win->SetSizeErr(TSize(21,22))); - break; - case 2: - User::LeaveIfError(win->SetExtentErr(TPoint(8,9),TSize(21,22))); - break; - case 3: - win->ClaimPointerGrab(); - break; - case 4: - win->SetVisible(ETrue); - break; - case 5: - win->EnableBackup(); - break; - case 6: - win->RequestPointerRepeatEvent(TTimeIntervalMicroSeconds32(100000),TRect()); - break; - case 7: - win->PasswordWindow(EPasswordCancel); - break; - case 8: - win->FadeBehind(ETrue); - break; - //These can all be called on a window with no parent without panicking - case 9: - win->SetVisible(EFalse); - break; - case 10: - { - RWindowGroup group(aWs); - group.Construct(567); - group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close - RWindow window(aWs); - window.Construct(group,97); - win->InquireOffset(window); - } - break; - case 11: - win->PointerFilter(0,0); - break; - case 12: - win->SetPointerGrab(ETrue); - break; - case 13: - win->SetPointerCapture(0); - break; - case 14: - win->Size(); - break; - case 15: - win->Position(); - break; - case 16: - User::LeaveIfError(win->SetCornerType(EWindowCorner5,0)); - break; - case 17: - { - TRegionFix<3> region; - User::LeaveIfError(win->SetShape(region)); - } - break; - case 18: - User::LeaveIfError(win->SetRequiredDisplayMode(EColor16)); - break; - case 19: - win->DisplayMode(); - break; - case 20: - win->CancelPointerRepeatEventRequest(); - break; - case 21: - win->AllocPointerMoveBuffer(10,0); - break; - case 22: - win->FreePointerMoveBuffer(); - break; - case 23: - win->DisablePointerMoveBuffer(); - break; - case 24: - { - TBuf8<16> buf; - win->RetrievePointerMoveBuffer(buf); - } - break; - case 25: - win->DiscardPointerMoveBuffer(); - break; - case 26: - User::LeaveIfError(win->AddKeyRect(TRect(TSize(10,10)),20,ETrue)); - break; - case 27: - win->RemoveAllKeyRects(); - break; - case 28: - win->EnablePointerMoveBuffer(); - break; - case 29: - return(EWsExitReasonFinished); - default:; - } - } - break; - case 3: //Call functions from RDrawableWindow - { - RDrawableWindow* win=(RDrawableWindow*)aWin; - switch(aFunc) - { - //The following can be called on a window with no parent without panicking - case 0: - win->Scroll(TPoint(7,8)); - break; - case 1: - win->Scroll(TRect(9,10,11,12),TPoint(13,14)); - break; - case 2: - win->Scroll(TPoint(15,16),TRect(17,18,19,20)); - break; - case 3: - win->Scroll(TRect(21,22,23,24),TPoint(25,26),TRect(27,28,29,30)); - break; - case 4: - return(EWsExitReasonFinished); - default:; - } - } - break; - case 4: //Call functions from RBlankWindow - { - RBlankWindow* win=(RBlankWindow*)aWin; - switch(aFunc) - { - case 0: - win->SetSize(TSize(7,8)); - break; - case 1: - win->SetExtent(TPoint(27,28),TSize(17,18)); - break; - //The following function can be called on a window with no parent without panicking - case 2: - win->SetColor(TRgb::Gray4(2)); - break; - case 3: - return(EWsExitReasonFinished); - default:; - } - } - break; - case 5: //Call functions from RWindow - { - RWindow* win=(RWindow*)aWin; - switch(aFunc) - { - case 0: - win->BeginRedraw(); - break; - case 1: - aWs.SetAutoFlush(ETrue); - win->BeginRedraw(TRect(31,32,43,44)); - aWs.SetAutoFlush(EFalse); - break; - case 2: - win->SetSize(TSize(5,6)); - break; - case 3: - win->SetExtent(TPoint(25,26),TSize(15,16)); - break; - //The following can be called on a window with no parent without panicking - case 4: - win->Invalidate(); - break; - case 5: - win->Invalidate(TRect(51,52,63,64)); - break; - case 6: //These ones don't panic - aWs.SetAutoFlush(ETrue); - win->EndRedraw(); - aWs.SetAutoFlush(EFalse); - break; - case 7: - { - RRegion region; - win->GetInvalidRegion(region); - } - break; - case 8: - win->SetBackgroundColor(TRgb::Gray4(1)); - break; - case 9: - win->SetBackgroundColor(); - break; - case 10: - return(EWsExitReasonFinished); - default:; - } - } - break; - case 6: //Call functions from RBackedUpWindow - { - RBackedUpWindow* win=(RBackedUpWindow*)aWin; - switch(aFunc) //None of these functions panic - { - //The following can be called on a window with no parent without panicking - case 0: - win->BitmapHandle(); - break; - case 1: - win->UpdateBackupBitmap(); - break; - case 2: - win->MaintainBackup(); - break; - case 3: - win->UpdateScreen(); - break; - case 4: - win->UpdateScreen(TRegionFix<1>(TRect(1,1,22,22))); - break; - case 5: - return(EWsExitReasonFinished); - default:; - } - } - break; - } - aWs.Flush(); - return(EWsExitReasonBad); // Should never get here, but it's baaddd if it does - } - -LOCAL_C TInt DoPanicTest3(TInt aInt, TAny *aScreenNumber) - { - TInt winType=aInt/CTWindowTest::EWinTypeFactor; - TInt func=aInt%CTWindowTest::EWinTypeFactor; - RWsSession ws; - User::LeaveIfError(ws.Connect()); - // use correct screen - // - CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws); - User::LeaveIfError(screen->Construct((TInt)aScreenNumber)); - - RWindowGroup group(ws); - group.Construct(888); - group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close - RWindow window(ws); - window.Construct(group,789); - RWindowTreeNode* win; - if (winType==1) - win=&window; - else - win=&group; - - return CallWindowFuction(win,winType,func,ws); - } - -//PanicTestNoPanic -//This function is called from DoPanicTest4 for window functions that should run without -//panicking the user thread if its parent has been deleted. -TInt PanicTestNoPanic(RWindowTreeNode* aWin,TInt aWinType,TInt aFunc,RWsSession aWs,const TInt* const aFuncToSkip) - { - TInt funcReturn; - for(;;) - { - if (aFuncToSkip && *aFuncToSkip == aFunc) - { - aFunc++; - } - funcReturn = CallWindowFuction(aWin,aWinType,aFunc,aWs); - if (funcReturn==EWsExitReasonBad) - { - aFunc++; - } - else if (funcReturn==EWsExitReasonFinished) - { - return EWsExitReasonFinished; - } - else - { - return EWsExitReasonBad; - } - } - } - -LOCAL_C TInt DoPanicTest4(TInt aInt, TAny *aScreenNumber) - { - TInt winType=aInt/CTWindowTest::EWinTypeFactor; - TInt func=aInt%CTWindowTest::EWinTypeFactor; - RWsSession ws; - User::LeaveIfError(ws.Connect()); - // use correct screen - // - CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws); - User::LeaveIfError(screen->Construct((TInt)aScreenNumber)); - - RWindowGroup group(ws); - group.Construct(234); - group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close - RWindow window(ws); - window.Construct(group,897); - RBackedUpWindow backedUp(ws); - backedUp.Construct(group,EGray16,98); - RBlankWindow blank(ws); - blank.Construct(group,169); - RWindowTreeNode* win=&window; - switch (winType) - { - case 0: - { - if (func > 8) //if a func 8+ had panicked, fail the test - { - return EWsExitReasonBad; - } - else if (func==8) - { - group.Close(); - return PanicTestNoPanic(win,winType,func,ws,NULL); - } - } - break; - case 2: - { - if (func>9) //if a func 9+ had panicked, fail the test - { - return EWsExitReasonBad; - } - else if (func==9) //set window visible so that SetVisible(EFalse) (func 9) would crash before fix - { - window.SetVisible(ETrue); - ws.Flush(); - group.Close(); - TInt funcToSkip = 28; //this call needs to have already successfully allocated a pointer cursor - return PanicTestNoPanic(win,winType,func,ws,&funcToSkip); - } - } - break; - case 4: - { - win=␣ - if (func>2) //if a func 2+ had panicked, fail the test - { - return EWsExitReasonBad; - } - else if (func==2) - { - group.Close(); - return PanicTestNoPanic(win,winType,func,ws,NULL); - } - } - break; - case 5: - { - if (func>6) //if a func 4+ had panicked, fail the test - { - return EWsExitReasonBad; - } - else if (func==4 || func==5) - { - if (CallWindowFuction(win,winType,func,ws)==EWsExitReasonBad) - { - func = 1; - } - else - { - return EWsExitReasonBad; - } - } - else if (func==6) - { - group.Close(); - TInt funcToSkip = 6; //Skip the call to EndRedraw in CallWindowFunction, it is not safe to call it on Window casts. - return PanicTestNoPanic(win,winType,func,ws,&funcToSkip); - } - } - break; - case 6: - { - win=&backedUp; - if (func>0) - return EWsExitReasonBad; - else //if (func==0) - { - TInt end=2; - while (func==0) - { - group.Close(); - while (CallWindowFuction(win,winType,func,ws)==EWsExitReasonBad && ++funcConstruct((TInt)aScreenNumber); - - RWindowGroup group(ws); - group.Construct(235); - group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close - RWindow window(ws); - window.Construct(group,896); - CWindowGc *gc=new(ELeave) CWindowGc(scrDev); - gc->Construct(); - gc->Activate(window); - group.Close(); - switch (aTest) - { - case 0: - gc->Deactivate(); - gc->Activate(window); - break; - case 1: - gc->DrawLine(TPoint(0,0),TPoint(10,10)); - break; - default: - return(EWsExitReasonFinished); - } - ws.Flush(); - return(EWsExitReasonBad); // Should never get here, but it's baaddd if it does - } - -#if defined(_DEBUG) -LOCAL_C TInt DoPanicTest6(TInt /*aInt*/, TAny *aScreenNumber) - { - RWsSession ws; - User::LeaveIfError(ws.Connect()); - RWindowGroup group1(ws); - CWsScreenDevice* screen=new(ELeave) CWsScreenDevice(ws); - User::LeaveIfError(screen->Construct((TInt)aScreenNumber)); - group1.Construct(123456,ETrue,screen); - RWindowGroup group2(ws); - group2.Construct(123456,ETrue,screen); // Should panic client here - return(EWsExitReasonBad); // Should never get here - } -#endif - -void CTWindowTest::TestInvalidFunctionsL() -// -// This code casts windows to be different types and then sends messages for the 'cast' that -// should not be sent to the original type of window. These should all result in panics -// - { - static TClientPanic PanicCode[]={EWservPanicDescriptor,EWservPanicDescriptor,EWservPanicDescriptor, - EWservPanicNoPointerBuffer,EWservPanicBackupDisplayMode, - EWservPanicNoFont}; // Dummy end value to catch out overflowing the array - INFO_PRINTF1(_L("AUTO Test Invalid Functions ")); - INFO_PRINTF1(_L(" Opcode Panics")); - - for (TInt source=0;source<3;source++) - for (TInt target=0;target<3;target++) - if (source!=target) - for (TInt panic=0;;panic++) - { - TBool testFinished=EFalse; - TEST(iTest->TestWsPanicL(DoPanicTest,EWservPanicOpcode,source*10000+target*100+panic,(TAny*)iTest->iScreenNumber,&testFinished)); - if (testFinished) - break; - } - _LIT(KSet,"Various Different Panics"); - INFO_PRINTF1(KSet); - RDebug::Print(KPlatsecBegin); - for(TInt index=0;;index++) - { - TBool testFinished=EFalse; - TEST(iTest->TestWsPanicL(DoPanicTest2,PanicCode[index],index,(TAny*)iTest->iScreenNumber,&testFinished)); - if (testFinished) - break; - } - RDebug::Print(KPlatsecEnd); - iTest->CloseAllPanicWindows(); - } - -void CTWindowTest::ShadowAutoClearTest() - { - RWindowGroup group(TheClient->iWs); - group.Construct(1111); - group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close - - RWindow background(TheClient->iWs); - background.Construct(group,133); - background.SetBackgroundColor(); - background.Activate(); - - background.BeginRedraw(); - TheClient->iGc->Activate(background); - TheClient->iGc->SetBrushColor(TRgb::Gray4(1)); - TheClient->iGc->Clear(); - background.EndRedraw(); -// - RBlankWindow tab2(TheClient->iWs); - tab2.Construct(group,144); - tab2.SetExtent(TPoint(10,00),TSize(200,10)); - tab2.SetColor(TRgb::Gray256(170)); - tab2.SetShadowHeight(1); - tab2.Activate(); - RBlankWindow tab1(TheClient->iWs); - tab1.Construct(group,155); - tab1.SetExtent(TPoint(70,00),TSize(10,10)); - tab1.SetColor(TRgb::Gray256(170)); - tab1.SetShadowHeight(1); - tab1.Activate(); - RBlankWindow blank(TheClient->iWs); - blank.Construct(group,156); - blank.SetExtent(TPoint(50,10),TSize(100,100)); - blank.SetColor(TRgb::Gray256(170)); - blank.SetShadowHeight(0); - blank.Activate(); -// - tab1.Close(); - tab1.Construct(group,166); - tab1.SetExtent(TPoint(50,00),TSize(10,10)); - tab1.SetColor(TRgb::Gray256(170)); - tab1.SetShadowHeight(1); - tab1.Activate(); - blank.Close(); - RBlankWindow blank2(TheClient->iWs); - blank2.Construct(group,177); - blank2.SetColor(TRgb::Gray256(255)); - blank2.SetExtent(TPoint(10,10),TSize(100,120)); - blank2.SetShadowHeight(2); - blank2.Activate(); - TheClient->iWs.Flush(); -// - background.BeginRedraw(); - TheClient->iGc->SetBrushColor(TRgb::Gray4(1)); - TheClient->iGc->Clear(); - background.EndRedraw(); -// - tab1.Close(); - tab2.Close(); - blank2.Close(); - background.BeginRedraw(); - TheClient->iGc->Clear(); - TheClient->iGc->Deactivate(); - background.EndRedraw(); - TheClient->iWs.Finish(); - TSize size=TheClient->iScreen->SizeInPixels(); - TBool rectCompare = TheClient->iScreen->RectCompare(TRect(0,0,size.iWidth>>1,size.iHeight),TRect(size.iWidth>>1,0,(size.iWidth>>1)<<1,size.iHeight)); - TEST(rectCompare); - if(!rectCompare) - INFO_PRINTF3(_L("TheClient->iScreen->RectCompare return value - Expected: %d, Actual: %d"), ETrue, rectCompare); - background.Close(); - group.Close(); - } - -void CTWindowTest::ClearRedraw(RWindow &aWindow, TRgb aRgb) - { - aWindow.BeginRedraw(); - TheClient->iGc->Activate(aWindow); - TheClient->iGc->SetBrushColor(aRgb); - TheClient->iGc->Clear(); - TheClient->iGc->Deactivate(); - aWindow.EndRedraw(); - } - -void CTWindowTest::CheckCorner(TCorner aCorner, const TInt *aInsetList) - { - TRect rect(TPoint(1,1),iBlankWin2->Size()); - TPoint pos; - TInt direction; - if (aCorner==ECornerTL || aCorner==ECornerTR) - { - pos.iY=rect.iTl.iY; - direction=1; - } - else - { - pos.iY=rect.iBr.iY-1; - direction= -1; - } - if (aCorner==ECornerTL || aCorner==ECornerBL) - pos.iX=rect.iTl.iX; - else - pos.iX=rect.iBr.iX-8; - TRgb rgbBuf[8]; - TPtr8 desc((TUint8 *)rgbBuf,sizeof(rgbBuf)); - for(TInt count=0;countGetScanLine(desc,pos,8,EColor16MA); - if (aCorner==ECornerTR || aCorner==ECornerBR) - { - for(TInt loop=0;loop<4;loop++) - { - TRgb tmp=rgbBuf[loop]; - rgbBuf[loop]=rgbBuf[8-1-loop]; - rgbBuf[8-1-loop]=tmp; - } - } - // We can't compare rgb value from original source against screen value in EColor64K mode as - // the color component might be truncated (EColor64K is 16-bit using format RGB565), - // ie R or B components might be reduced from 8-bit to 5-bit and G from 8-bit to 6-bit - // - // For example: RGB value of Gray4(1) is 0x555555, it is drawn to screen in RGB565 as 0x52AA, - // when it's converted back to RGB for comparison, the value becomes 0x525552 - TRgb col1=TRgb::Gray4(1); - TRgb col2=TRgb::Gray4(3); - if (iScreenDev->DisplayMode()==EColor64K) - { - col1=TRgb::Color64K(col1.Color64K()); - col2=TRgb::Color64K(col2.Color64K()); - } - TInt loop2=0; - for(;loop2BaseWin()->SetCornerType(aCornerType,aFlags); - if (!(aFlags&EWindowCornerNotTL)) - CheckCorner(ECornerTL, corners); - if (!(aFlags&EWindowCornerNotTR)) - CheckCorner(ECornerTR, corners); - if (!(aFlags&EWindowCornerNotBL)) - CheckCorner(ECornerBL, corners); - if (!(aFlags&EWindowCornerNotBR)) - CheckCorner(ECornerBR, corners); -// - if (aFlags&EWindowCornerNotTL) - CheckCorner(ECornerTL, corner0); - if (aFlags&EWindowCornerNotTR) - CheckCorner(ECornerTR, corner0); - if (aFlags&EWindowCornerNotBL) - CheckCorner(ECornerBL, corner0); - if (aFlags&EWindowCornerNotBR) - CheckCorner(ECornerBR, corner0); - } - -void CTWindowTest::doCornerTestsL() - { - iScreenDev=new(ELeave) CWsScreenDevice(TheClient->iWs); - User::LeaveIfError(iScreenDev->Construct(iTest->iScreenNumber)); - iBlankWin1=new(ELeave) CTBlankWindow(); - iBlankWin1->SetUpL(TPoint(1,1),TSize(100,50),TheClient->iGroup,*TheClient->iGc); - iBlankWin1->SetColor(TRgb::Gray4(1)); - iBlankWin2=new(ELeave) CTBlankWindow(); - iBlankWin2->SetUpL(TPoint(1,1),iBlankWin1->Size(),TheClient->iGroup,*TheClient->iGc); - iBlankWin2->SetColor(TRgb::Gray4(3)); - iBlankWin2->BaseWin()->SetShadowHeight(0); - doCornerTest(EWindowCornerSquare,0); - doCornerTest(EWindowCornerSquare,EWindowCornerNotBL); - doCornerTest(EWindowCorner1,0); // 0 + all corners missing - doCornerTest(EWindowCorner1,EWindowCornerNotTL|EWindowCornerNotTR|EWindowCornerNotBL|EWindowCornerNotBR); - doCornerTest(EWindowCorner2,0); // 0 + all sets of 3 corners missing - doCornerTest(EWindowCorner2,EWindowCornerNotTR|EWindowCornerNotBL|EWindowCornerNotBR); - doCornerTest(EWindowCorner2,EWindowCornerNotTL|EWindowCornerNotBL|EWindowCornerNotBR); - doCornerTest(EWindowCorner2,EWindowCornerNotTL|EWindowCornerNotTR|EWindowCornerNotBR); - doCornerTest(EWindowCorner2,EWindowCornerNotTL|EWindowCornerNotTR|EWindowCornerNotBL); - doCornerTest(EWindowCorner3,0); // 0 + all 4 individual corners missing - doCornerTest(EWindowCorner3,EWindowCornerNotTL); - doCornerTest(EWindowCorner3,EWindowCornerNotTR); - doCornerTest(EWindowCorner3,EWindowCornerNotBL); - doCornerTest(EWindowCorner3,EWindowCornerNotBR); - doCornerTest(EWindowCorner5,0); // 0 + all pairs of corners missing - doCornerTest(EWindowCorner5,EWindowCornerNotTL|EWindowCornerNotTR); - doCornerTest(EWindowCorner5,EWindowCornerNotTL|EWindowCornerNotBL); - doCornerTest(EWindowCorner5,EWindowCornerNotTL|EWindowCornerNotBR); - doCornerTest(EWindowCorner5,EWindowCornerNotTR|EWindowCornerNotBL); - doCornerTest(EWindowCorner5,EWindowCornerNotTR|EWindowCornerNotBR); - doCornerTest(EWindowCorner5,EWindowCornerNotBL|EWindowCornerNotBR); - } - -void CTWindowTest::CornerTests() - { - TRAP_IGNORE(doCornerTestsL()); - delete iBlankWin2; - delete iBlankWin1; - delete iScreenDev; - } - -LOCAL_C void doMegaTreeThread(TInt aScreenNumber) - { - CTrapCleanup::New(); - RWsSession ws; - ws.Connect(); - CWsScreenDevice *scrDev=new(ELeave) CWsScreenDevice(ws); - scrDev->Construct(aScreenNumber); - RWindowGroup group(ws); - group.Construct(1); - group.EnableReceiptOfFocus(EFalse); - RWindow parent(ws); - parent.Construct(group,123); - parent.Activate(); - CWindowGc *gc=new(ELeave) CWindowGc(scrDev); - gc->Construct(); - TSize max(parent.Size()); - RWindow prev=parent; - TBool horiz=EFalse; - TInt color=0; - for(TInt count=0;count<100;count++) - { - RWindow win(ws); - if (win.Construct(prev,ENullWsHandle)!=KErrNone) - break; - win.SetExtent(horiz?TPoint(1,0):TPoint(0,1),max); - win.SetBackgroundColor(TRgb::Gray4(color)); - color=(color+1)%4; - win.Activate(); - win.BeginRedraw(); - gc->Activate(win); - gc->Clear(); - gc->Deactivate(); - win.EndRedraw(); - prev=win; - horiz=!horiz; - } - parent.SetVisible(EFalse); - parent.SetVisible(ETrue); - parent.SetPosition(TPoint(-1,-1)); - parent.SetPosition(TPoint(0,0)); - parent.Close(); - ws.Close(); - } - -LOCAL_C TInt MegaTreeThread(TAny *aScreenNumber) - { - TRAPD(err,doMegaTreeThread((TInt)aScreenNumber)); - return(err); - } - -void CTWindowTest::CreateMegaTree() - { - const TUint KThreadHeapSize=0x2000; - RThread thread; - if (thread.Create(_L("MegaTree"),MegaTreeThread,KDefaultStackSize,KThreadHeapSize,KThreadHeapSize,(TAny*)iTest->iScreenNumber,EOwnerThread)==KErrNone) - { - TRequestStatus stat; - thread.Logon(stat); - thread.Resume(); - User::WaitForRequest(stat); - TEST(stat==KErrNone); - } - thread.Close(); - } - -void CTWindowTest::TiledWindowTestL() - { - RWindow parent(TheClient->iWs); - User::LeaveIfError(parent.Construct(*TheClient->iGroup->GroupWin(),ENullWsHandle)); - CleanupStack::PushL(TCleanupItem(CleanUpWindow,&parent)); - parent.SetExtent(TPoint(10,10),TSize(50,50)); - parent.Activate(); -// - RWindow child1(TheClient->iWs); - User::LeaveIfError(child1.Construct(parent,ENullWsHandle)); - CleanupStack::PushL(TCleanupItem(CleanUpWindow,&child1)); - child1.SetExtent(TPoint(0,0),TSize(50,20)); - child1.Activate(); -// - RWindow child2(TheClient->iWs); - User::LeaveIfError(child2.Construct(parent,ENullWsHandle)); - CleanupStack::PushL(TCleanupItem(CleanUpWindow,&child2)); - child2.SetExtent(TPoint(0,20),TSize(50,30)); - child2.Activate(); -// - child1.BeginRedraw(); - TSize rect1Size(25,20); - TheGc->Activate(child1); - TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - TheGc->DrawRect(TRect(rect1Size)); - TheGc->DrawRect(TRect(TPoint(rect1Size.iWidth,0),rect1Size)); - TheGc->Deactivate(); - child1.EndRedraw(); -// - child2.BeginRedraw(); - TSize rect2Size(25,30); - TheGc->Activate(child2); - TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - TheGc->DrawRect(TRect(rect2Size)); - TheGc->DrawRect(TRect(TPoint(rect2Size.iWidth,0),rect2Size)); - TheGc->Deactivate(); - child2.EndRedraw(); -// -// Left and right halves should be identical -// - TBool rectCompare = !TheClient->iScreen->RectCompare(TRect(10,10,35,60),TRect(35,10,70,60)); - TEST(rectCompare); - if(!rectCompare) - INFO_PRINTF3(_L("TheClient->iScreen->RectCompare return value - Expected: %d, Actual: %d"), ETrue, rectCompare); -// - CleanupStack::PopAndDestroy(3); - } - -void CTWindowTest::TiledWindowTest2L() - { - TSize size(200,240); //Parent Windows - TSize childSize(TSize(size.iWidth/2,size.iHeight/2)); //Child Windows - TSize dialogueSize(50,50); - - TheClient->iWs.SetAutoFlush(ETrue); - RBlankWindow parent1(TheClient->iWs); - User::LeaveIfError(parent1.Construct(*TheClient->iGroup->GroupWin(),ENullWsHandle)); - CleanupStack::PushL(TCleanupItem(CleanUpWindow,&parent1)); - parent1.SetExtent(TPoint(240,0),size); - parent1.SetColor(TRgb::Gray4(2)); - parent1.Activate(); - - TheClient->iWs.SetAutoFlush(ETrue); - RBlankWindow parent2(TheClient->iWs); - User::LeaveIfError(parent2.Construct(*TheClient->iGroup->GroupWin(),ENullWsHandle)); - CleanupStack::PushL(TCleanupItem(CleanUpWindow,&parent2)); - parent2.SetExtent(TPoint(440,0),size); - parent2.SetColor(TRgb::Gray4(2)); - parent2.Activate(); - - TheClient->iWs.SetAutoFlush(ETrue); - RBlankWindow child1(TheClient->iWs); - User::LeaveIfError(child1.Construct(parent1,ENullWsHandle)); - CleanupStack::PushL(TCleanupItem(CleanUpWindow,&child1)); - child1.SetExtent(TPoint(0,0),childSize); - child1.SetColor(TRgb::Gray4(2)); - child1.Activate(); - - TheClient->iWs.SetAutoFlush(ETrue); - RBlankWindow child2(TheClient->iWs); - User::LeaveIfError(child2.Construct(parent1,ENullWsHandle)); - CleanupStack::PushL(TCleanupItem(CleanUpWindow,&child2)); - child2.SetExtent(TPoint(0,childSize.iHeight),childSize); - child2.SetColor(TRgb::Gray4(2)); - child2.Activate(); - - TheClient->iWs.SetAutoFlush(ETrue); - RBlankWindow child3(TheClient->iWs); - User::LeaveIfError(child3.Construct(parent1,ENullWsHandle)); - CleanupStack::PushL(TCleanupItem(CleanUpWindow,&child3)); - child3.SetExtent(TPoint(childSize.iWidth,0),TSize(childSize.iWidth,size.iHeight)); - child3.SetColor(TRgb::Gray4(2)); - child3.Activate(); - - TPoint dialoguePos(375,93); - TheClient->iWs.SetAutoFlush(ETrue); - RBlankWindow dialog1(TheClient->iWs); - User::LeaveIfError(dialog1.Construct(*TheClient->iGroup->GroupWin(),ENullWsHandle)); - CleanupStack::PushL(TCleanupItem(CleanUpWindow,&dialog1)); - dialog1.SetExtent(dialoguePos,dialogueSize); - dialog1.SetColor(TRgb::Gray4(3)); - dialog1.SetShadowHeight(4); - dialog1.Activate(); - - TheClient->iWs.SetAutoFlush(ETrue); - RBlankWindow dialog2(TheClient->iWs); - User::LeaveIfError(dialog2.Construct(*TheClient->iGroup->GroupWin(),ENullWsHandle)); - CleanupStack::PushL(TCleanupItem(CleanUpWindow,&dialog2)); - dialog2.SetExtent(TPoint(dialoguePos.iX+size.iWidth,dialoguePos.iY),dialogueSize); - dialog2.SetColor(TRgb::Gray4(3)); - dialog2.SetShadowHeight(0); - dialog2.Activate(); - - TInt ii; - for (ii=400;ii>374;ii-=25) - dialog1.SetPosition(TPoint(ii,93)); - TheClient->iWs.SetAutoFlush(EFalse); - CleanupStack::PopAndDestroy(7); - } - -void CTWindowTest::ColorTestL() - { - if (iTest->MaxGrays() == 0) - return; - - _LIT(KSet,"AUTO Color Test "); - INFO_PRINTF1(KSet); - RWindow window(TheClient->iWs); - User::LeaveIfError(window.Construct(*TheClient->iGroup->GroupWin(),ENullWsHandle)); - PushWindowL(&window); - window.SetExtent(TPoint(10,10),TSize(50,50)); - window.Activate(); - TInt colorMode,mode; - TInt currentMode=TheClient->iScreen->DisplayMode(); - TEST(currentMode==EGray4 || currentMode==EColor16 || currentMode==EColor256 || currentMode == EColor64K); - if(currentMode!=EGray4 && currentMode!=EColor16 && currentMode!=EColor256 && currentMode != EColor64K) - INFO_PRINTF5(_L("TheClient->iScreen->DisplayMode() return value - Expected: %d or %d or %d, Actual: %d"), EGray4, EColor16, EColor256, currentMode); - INFO_PRINTF1(_L(" Done Setup")); - for(colorMode=EGray4;colorMode log; - log.Format(KModes,colorMode,mode,currentMode); - INFO_PRINTF1(log); - } - if (mode>ERgb && colorMode==EColor64K) - break; - TEST(mode==currentMode || mode==colorMode ); - if (mode!=currentMode && mode!=colorMode) - INFO_PRINTF4(_L("window.DisplayMode() return value - Expected: %d or %d, Actual: %d"), currentMode, colorMode, mode); - INFO_PRINTF1(_L(" Loop 2")); - if (mode>currentMode) - currentMode=mode; - if (colorMode==EColor16) - window.SetSize(TSize(40,60)); - else if (colorMode==EColor4K) - window.SetSize(TSize(60,40)); - mode=TheClient->iScreen->DisplayMode(); - if(TDisplayModeUtils::NumDisplayModeColors(STATIC_CAST(TDisplayMode,currentMode))==16777216) - { - TEST(mode==CFbsDevice::DisplayMode16M()); - if (mode!=CFbsDevice::DisplayMode16M()) - INFO_PRINTF3(_L("window.DisplayMode() return value - Expected: %d, Actual: %d"), CFbsDevice::DisplayMode16M(), mode); - } - else - { - TEST(currentMode==mode || currentMode==colorMode); - if (currentMode!=mode && currentMode!=colorMode) - INFO_PRINTF3(_L("TheClient->iScreen->DisplayMode() return value return value - Expected: %d , Actual: %d"), currentMode, mode); - } - } - INFO_PRINTF1(_L(" Done First Loop")); - TInt color,gray; - TDisplayMode defMode=TheClient->iWs.GetDefModeMaxNumColors(color,gray); - TInt screenNo =TheClient->iScreen->GetScreenNumber(); - TDisplayMode defModeForScreen=TheClient->iWs.GetDefModeMaxNumColors(screenNo,color,gray); - TEST(defMode==defModeForScreen); - if (defMode!=defModeForScreen) - INFO_PRINTF3(_L("TheClient->iScreen->DisplayMode() return value return value - Expected: %d , Actual: %d"), defMode, defModeForScreen); - if (color==16777216 && gray==256) - { - TEST(defMode==EGray4 || defMode==EColor256 || defMode==EColor64K); //WINS - if (defMode!=EGray4 && defMode!=EColor256 && defMode != EColor64K) - INFO_PRINTF4(_L("TheClient->iWs.GetDefModeMaxNumColors(color,gray) return value return value - Expected: %d or %d, Actual: %d"), EGray4, EColor256, defMode); - } - else - { - if (color==0 && gray==16) - { - TEST(defMode==EGray4); //S5 family - if (defMode!=EGray4) - INFO_PRINTF3(_L("TheClient->iScreen->DisplayMode() return value return value - Expected: %d , Actual: %d"), EGray4, defMode); - } - else - { - TLogMessageText buf; - _LIT(KColorSettings,"##Data Most Colors=%d, Most Greys=%d, DefMode=%d"); - buf.Format(KColorSettings,color,gray,defMode); - TheClient->iWs.LogMessage(buf); - TheClient->iWs.Flush(); - TEST(defMode==EGray4 || defMode==EColor256); - if (defMode!=EGray4 && defMode!=EColor256) - INFO_PRINTF4(_L("TheClient->iWs.GetDefModeMaxNumColors(color,gray) return value return value - Expected: %d or %d, Actual: %d"), EGray4, EColor256, defMode); - } - } - CArrayFixFlat *colorModes=new(ELeave) CArrayFixFlat(1); - CleanupStack::PushL(colorModes); - User::LeaveIfError(TheClient->iWs.GetColorModeList(screenNo,colorModes)); - TDisplayMode mostColor=ENone; - TDisplayMode lastGray=ENone; - TDisplayMode dispMode; - TInt ii; - TInt colorModes16M = 0; - INFO_PRINTF1(_L(" Done Setup 2")); - for (ii=0;iiCount();ii++) - { - dispMode=(TDisplayMode)(*colorModes)[ii]; - TEST(dispMode!=ERgb); - if (dispMode==ERgb) - INFO_PRINTF3(_L("(TDisplayMode)(*colorModes)[i] return value - Not Expected: %d , Actual: %d"), ERgb, dispMode); - TEST(dispMode!=ENone); - if (dispMode==ENone) - INFO_PRINTF3(_L("(TDisplayMode)(*colorModes)[i] return value - Not Expected: %d , Actual: %d"), ENone, dispMode); - if (dispMode<=EGray256) - lastGray=dispMode; - else - mostColor=dispMode; - if(dispMode == EColor16M || dispMode == EColor16MU || dispMode == EColor16MA) - colorModes16M++; - } - TEST(mostColor!=ERgb); - if (mostColor==ERgb) - INFO_PRINTF3(_L("mostColor - Not Expected: %d , Actual: %d"), ERgb, mostColor); - TEST(colorModes16M <= 1); - if (colorModes16M > 1) - INFO_PRINTF3(_L("Number of times color Modes 16M - less than or equal to: %d , Actual: %d"), 1, colorModes16M); -#if defined(__WINS__) - TEST(colorModes16M == 1); - if (colorModes16M != 1) - INFO_PRINTF3(_L("Number of times color Modes 16M on wins - equal to: %d , Actual: %d"), 1, colorModes16M); -#endif - TInt retVal; - if (color==0) - { - TEST(mostColor==ENone); - if (mostColor!=ENone) - INFO_PRINTF3(_L("Most color - equal to: %d , Actual: %d"), ENone ,mostColor); - } - else - { - retVal = TDisplayModeUtils::NumDisplayModeColors(mostColor); - TEST(color==retVal); - if (color!=retVal) - INFO_PRINTF3(_L("TDisplayModeUtils::NumDisplayModeColors(mostColor) return value - equal to: %d , Actual: %d"), TDisplayModeUtils::NumDisplayModeColors(mostColor), retVal); - } - if (gray==0) - { - TEST(lastGray==ENone); - if (lastGray!=ENone) - INFO_PRINTF3(_L("LastGray - equal to: %d , Actual: %d"), ENone, lastGray); - } - else - { - retVal = TDisplayModeUtils::NumDisplayModeColors(lastGray); - TEST(gray==retVal); - if(gray!=retVal) - INFO_PRINTF3(_L("Gray - equal to: %d , Actual: %d"), retVal, gray); - } - retVal = TDisplayModeUtils::NumDisplayModeColors(ENone); - TEST(retVal==0); - if (retVal!=0) - INFO_PRINTF3(_L("TDisplayModeUtils::NumDisplayModeColors(ENone) return value - equal to: %d , Actual: %d"), 0, retVal); - CleanupStack::PopAndDestroy(2); //window and mode-array - } - -void CTWindowTest::TestInvalidFunctions2L() -// -// This code casts windows to group windows and vice-versa and then sends messages for the 'cast' that -// should not be sent to the original type of window. These should all result in panics -// - { - for (TInt winType=1;winType<7;++winType) //Skip type 0 (RWindowTreeNode) - for (TInt panic=0;;panic++) - { - TBool testFinished=EFalse; - TEST(iTest->TestWsPanicL(DoPanicTest3,EWservPanicOpcode,EWinTypeFactor*winType+panic,(TAny*)iTest->iScreenNumber,&testFinished)); - if (testFinished) - break; - } - iTest->CloseAllPanicWindows(); - } - -void CTWindowTest::TestDeletedParentPanics1L() - { - for (TInt winType=0;winType<7;++winType) - { - if (winType==1) //Skip type 1 (RWindowGroup) - ++winType; - for (TInt panic=0;;panic++) - { - TBool testFinished=EFalse; - TEST(iTest->TestWsPanicL(DoPanicTest4,EWservPanicParentDeleted,EWinTypeFactor*winType+panic,(TAny*)iTest->iScreenNumber,&testFinished)); - if (testFinished) - break; - } - } - iTest->CloseAllPanicWindows(); - } - -void CTWindowTest::TestDeletedParentPanics2L() - { - for (TInt panic=0;;panic++) - { - TBool testFinished=EFalse; - TEST(iTest->TestWsPanicL(DoPanicTest5,EWservPanicParentDeleted,panic,(TAny*)iTest->iScreenNumber,&testFinished)); - if (testFinished) - break; - } - iTest->CloseAllPanicWindows(); - } - -void CTWindowTest::Bug1L() -// -// Test a defect found with WSERV 099 that caused a full Eikon ROM to crash before even the splach screen appeared -// - { - RWsSession ws; - User::LeaveIfError(ws.Connect()); - // use correct screen - CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws); - CleanupStack::PushL(screen); - User::LeaveIfError(screen->Construct(iTest->iScreenNumber)); - - RWindowGroup group(ws); - group.Construct(344); - group.EnableReceiptOfFocus(EFalse); //Not done by Eikon, but needed to stop shell window comming to front. - RBlankWindow blank(ws); - blank.Construct(group,345); - blank.SetOrdinalPosition(0,1000); - blank.Activate(); - RWindow window(ws); - window.Construct(group,346); - - //Must delete this window to tidy up - window.Close(); - blank.Close(); - group.Close(); - - CleanupStack::PopAndDestroy(screen); - ws.Close(); - } - -void CTWindowTest::TestWindowDelete() - { - TInt handles = 344; - TInt err = KErrNone; - TInt loop = 0; - TInt allocFailRate = 0; - - RWindowGroup group(TheClient->iWs); - RWindow parent1(TheClient->iWs); - RWindow child1(TheClient->iWs); - RWindow testWindow(TheClient->iWs); - - while (loop < 5) - { - err = group.Construct(++handles, EFalse); - if (err == KErrNone) - { - TheClient->iWs.HeapSetFail(RHeap::EDeterministic, allocFailRate); - - //Create parent 1 - err = parent1.Construct(group,++handles); - if (err == KErrNone) - { - parent1.SetExtent(TPoint(10,10),TSize(50,50)); - parent1.Activate(); - } - } - //Create child 1 - if (err == KErrNone) - { - err = child1.Construct(parent1,++handles); - if (err == KErrNone) - { - child1.SetExtent(TPoint(),TSize(50,20)); - child1.Activate(); - } - //Only delete the parent 1, but not the child 1 - parent1.Close(); - } - - if (err == KErrNone) - { - //Create testWindow - err = testWindow.Construct(group,++handles); - if (err == KErrNone) - { - testWindow.SetExtent(TPoint(0,20),TSize(50,30)); - testWindow.Activate(); - } - } - TheClient->iWs.HeapSetFail(RAllocator::ENone, 0); - - child1.Close(); - testWindow.Close(); - group.Close(); - ++allocFailRate; - loop = (err == KErrNone) ? loop + 1 : 0; - } - } -void CTWindowTest::Bug2L() -// -// Test a defect ... -// - { - TSize offset(20,20); - TRect screen(TheClient->iScreen->SizeInPixels()-offset); - TRgb color; - RWsSession ws1; - User::LeaveIfError(ws1.Connect()); - ws1.SetAutoFlush(ETrue); - - // use correct screen - // - CWsScreenDevice* scr1 = new (ELeave) CWsScreenDevice(ws1); - CleanupStack::PushL(scr1); - User::LeaveIfError(scr1->Construct(iTest->iScreenNumber)); - - RWsSession ws2; - User::LeaveIfError(ws2.Connect()); - ws2.SetAutoFlush(ETrue); - - // use correct screen - // - CWsScreenDevice* scr2 = new (ELeave) CWsScreenDevice(ws2); - CleanupStack::PushL(scr2); - User::LeaveIfError(scr2->Construct(iTest->iScreenNumber)); - - RWindowGroup group1a(ws1); - group1a.Construct(344); - group1a.EnableReceiptOfFocus(EFalse); - group1a.SetOrdinalPosition(0,5); - RBlankWindow blank1a(ws1); - blank1a.Construct(group1a,345); - color=TRgb::Gray4(0); - blank1a.SetColor(color); - blank1a.SetExtent(screen.iTl,screen.Size()); - blank1a.EnableBackup(); - blank1a.Activate(); - - RWindowGroup group2(ws2); - group2.Construct(342); - group2.EnableReceiptOfFocus(EFalse); - group2.SetOrdinalPosition(0,5); - RBlankWindow blank2(ws2); - blank2.Construct(group2,347); - color=TRgb::Gray4(1); - blank2.SetColor(color); - blank2.SetExtent(screen.iTl+TSize(20,0),screen.Size()); - blank2.EnableBackup(); - blank2.Activate(); - - RWindowGroup group1b(ws1); - group1b.Construct(343); - //group1b.EnableReceiptOfFocus(EFalse); - group1b.SetOrdinalPosition(0,5); - RBlankWindow blank1b(ws1); - blank1b.Construct(group1b,346); - color=TRgb::Gray4(2); - blank1b.SetColor(color); - blank1b.SetExtent(screen.iTl+offset,screen.Size()); - blank1b.EnableBackup(); - blank1b.Activate(); - - group1b.Close(); - blank1a.Close(); - blank1b.Close(); - blank2.Close(); - group1a.Close(); - group2.Close(); - - CleanupStack::PopAndDestroy(2,scr1); - ws1.Close(); - ws2.Close(); - } - -void CTWindowTest::Bug3L() -// -// Actiate then make visible and backup behind window caused panic. -// - { - TSize offset(20,20); - TRect screen(TheClient->iScreen->SizeInPixels()-offset); - TRgb color; - RWsSession ws; - User::LeaveIfError(ws.Connect()); - ws.SetAutoFlush(ETrue); - - // use correct screen - // - CWsScreenDevice* scr = new (ELeave) CWsScreenDevice(ws); - CleanupStack::PushL(scr); - User::LeaveIfError(scr->Construct(iTest->iScreenNumber)); - - RWindowGroup group(ws); - group.Construct(348); - group.EnableReceiptOfFocus(EFalse); - RBlankWindow blank1(ws); - blank1.Construct(group,341); - color=TRgb::Gray4(1); - blank1.SetColor(color); - blank1.SetExtent(screen.iTl,screen.Size()); - blank1.EnableBackup(); - blank1.SetVisible(EFalse); - blank1.Activate(); - blank1.SetVisible(ETrue); - RBlankWindow blank2(ws); - blank2.Construct(group,342); - color=TRgb::Gray4(2); - blank2.SetColor(color); - blank2.SetExtent(screen.iTl,screen.Size()); - blank2.EnableBackup(); - blank2.SetVisible(EFalse); - blank2.SetVisible(ETrue); - blank2.Activate(); - group.Close(); - blank1.Close(); - blank2.Close(); - - CleanupStack::PopAndDestroy(scr); - ws.Close(); - } - -void CTWindowTest::ErrorCodesL() - { - RWsSession ws; - User::LeaveIfError(ws.Connect()); - // use correct screen - // - CWsScreenDevice* scr = new (ELeave) CWsScreenDevice(ws); - CleanupStack::PushL(scr); - User::LeaveIfError(scr->Construct(iTest->iScreenNumber)); - - - RWindowGroup group(ws); - group.Construct(349); - group.EnableReceiptOfFocus(EFalse); - RWindow window(TheClient->iWs); - User::LeaveIfError(window.Construct(*TheClient->iGroup->GroupWin(),ENullWsHandle)); - TInt retVal = window.MoveToGroup(22222); - TEST(retVal==KErrNotFound); - if (retVal!=KErrNotFound) - INFO_PRINTF3(_L("window.MoveToGroup(22222) return value - equal to: %d , Actual: %d"), KErrNotFound, retVal); - retVal = window.MoveToGroup(group.Identifier()); - TEST(retVal==KErrNotFound); - if (retVal!=KErrNotFound) - INFO_PRINTF3(_L("window.MoveToGroup(group.Identifier()) return value - equal to: %d , Actual: %d"), KErrNotFound, retVal); - window.Close(); - group.Close(); - - CleanupStack::PopAndDestroy(scr); - ws.Close(); - } - -void CTWindowTest::BackColorBugL() -// -// Test a defect with window being drawn with the wrong background color when they are moved on the screen -// - { - TSize scrSize(TheClient->iScreen->SizeInPixels()); - TSize checkSize(12,10); //X-Size needs to be multiple of 4 due to BITGDI change/defect - CBlankWindow* win; - win=new(ELeave) CBlankWindow(TRgb(16,16,240)); - CleanupStack::PushL(win); - win->SetUpL(TPoint(5,5),scrSize-TSize(10,10),TheClient->iGroup,*TheClient->iGc); - TInt mode=win->BaseWin()->SetRequiredDisplayMode(EColor256); - const TDisplayMode actualMode=reinterpret_cast(mode); - if (!TDisplayModeUtils::IsDisplayModeColor(actualMode) || TDisplayModeUtils::NumDisplayModeColors(actualMode)<256) - { - CleanupStack::PopAndDestroy(win); - return; - } - win->RealDraw(ETrue); - win->Win()->SetBackgroundColor(TRgb(64,224,64)); - CBlankWindow* win3; - win3=new(ELeave) CBlankWindow(TRgb::Gray16(8)); - CleanupStack::PushL(win3); - win3->SetUpL(TPoint(12,12),checkSize,TheClient->iGroup,*TheClient->iGc); - win3->BaseWin()->SetRequiredDisplayMode(EColor256); - CBlankWindow* win2; - win2=new(ELeave) CBlankWindow(TRgb(240,16,16)); - CleanupStack::PushL(win2); - win2->SetUpL(TPoint(10,scrSize.iHeight/2),TSize(scrSize.iWidth/3,scrSize.iHeight/2-10),TheClient->iGroup,*TheClient->iGc); - win2->BaseWin()->SetRequiredDisplayMode(EColor256); - win2->RealDraw(EFalse); - - win2->Win()->SetBackgroundColor(TRgb::Gray16(8)); - win2->SetExt(TPoint(scrSize.iWidth/4,30),TSize(scrSize.iWidth/2,2*scrSize.iHeight/3)); - TheClient->iWs.Finish(); - TheClient->WaitForRedrawsToFinish(); - if (!CheckRect(win2,win3,TRect(checkSize))) - { - _LIT(KLog,"After window is moved and resizes it doesn't matches the other window"); - LOG_MESSAGE(KLog); - //Code to save a screen shot useful if this test fails - /*_LIT(KTest,"E:\\logs\\testexecute\\Window%d"); - TBuf<64> buf; - buf.Format(KTest,iTest->iState); - TInt err=iTest->SaveScreen(buf); - _LIT(KLogSave,"Saved screenshot to file %S, (err=%d)"); - LOG_MESSAGE3(KLogSave,&buf,err);*/ - } - TheClient->WaitForRedrawsToFinish(); - CleanupStack::PopAndDestroy(3,win); - } - -void CTWindowTest::FocusChangedL() -// -// Test that the focus change is available when the redraw is -// it should be available before, but it isn't always possible to test that -// - { - _LIT(KThreadName,"MoveGroup"); - _LIT(KEventWaiting,"Event Waiting when none expected."); - TInt command; - iThreadParam.iScreenNumber=iTest->iScreenNumber; - iFirstFunction=TThreadStartUp(CTWindowTest::MoveGroup,&iThreadParam); - TRequestStatus status; - TSize scrSize(TheClient->iScreen->SizeInPixels()); - CTWindowGroup* group1=new(ELeave) CTWindowGroup(TheClient); - group1->ConstructL(); - CleanupStack::PushL(group1); - TInt winId1=group1->GroupWin()->Identifier(); - CBlankWindow* win1=new(ELeave) CBlankWindow(TRgb::Gray4(1)); - CleanupStack::PushL(win1); - win1->SetUpL(TPoint(1,1),TSize(2*scrSize.iWidth/3,2*scrSize.iHeight/3),group1,*TheClient->iGc); - win1->RealDraw(ETrue); - win1->Win()->SetBackgroundColor(TRgb::Gray4(3)); - CTWindowGroup* group2=new(ELeave) CTWindowGroup(TheClient); - group2->ConstructL(); - CleanupStack::PushL(group2); - TInt winId2=group2->GroupWin()->Identifier(); - CBlankWindow* win2=new(ELeave) CBlankWindow(TRgb::Gray4(2)); - CleanupStack::PushL(win2); - win2->SetUpL(TPoint(scrSize.iWidth/3-5,scrSize.iHeight/3-5),TSize(2*scrSize.iWidth/3,2*scrSize.iHeight/3),group2,*TheClient->iGc); - win2->RealDraw(ETrue); - win2->Win()->SetBackgroundColor(TRgb::Gray4(0)); - - TheClient->WaitForRedrawsToFinish(); - TheClient->WaitForAllEventProcessingToFinish(); - command=winId1; - iThreadParam.iCommand=command; - TBool noEventWaiting=!TheClient->IsEventWaiting(); - TEST(noEventWaiting); - if (!noEventWaiting) - LOG_MESSAGE(KEventWaiting); - _LIT(KTest1,"FocusChangedL: 1st test completed"); - LOG_MESSAGE(KTest1); - CProcess* iMoveGroup=CProcess::NewSimpleThreadL(KThreadName,&iFirstFunction,&status); - User::WaitForRequest(status); - delete iMoveGroup; - TEST(TheClient->WaitForEvent()); - TheClient->WaitForAllEventProcessingToFinish(); - - command=winId2; - iThreadParam.iCommand=command; - TheClient->WaitForRedrawsToFinish(); - noEventWaiting=!TheClient->IsEventWaiting(); - TEST(noEventWaiting); - if (!noEventWaiting) - LOG_MESSAGE(KEventWaiting); - _LIT(KTest2,"FocusChangedL: 2nd test completed"); - LOG_MESSAGE(KTest2); - iMoveGroup=CProcess::NewSimpleThreadL(KThreadName,&iFirstFunction,&status); - User::WaitForRequest(status); - delete iMoveGroup; - TEST(TheClient->WaitForEvent()); - TheClient->WaitForAllEventProcessingToFinish(); - - command=winId2|(1<WaitForRedrawsToFinish(); - noEventWaiting=!TheClient->IsEventWaiting(); - TEST(noEventWaiting); - if (!noEventWaiting) - LOG_MESSAGE(KEventWaiting); - _LIT(KTest3,"FocusChangedL: 3rd test completed"); - LOG_MESSAGE(KTest3); - iMoveGroup=CProcess::NewSimpleThreadL(KThreadName,&iFirstFunction,&status); - User::WaitForRequest(status); - delete iMoveGroup; - TEST(TheClient->WaitForEvent()); - TheClient->WaitForAllEventProcessingToFinish(); - - command=winId1|(1<WaitForRedrawsToFinish(); - noEventWaiting=!TheClient->IsEventWaiting(); - TEST(noEventWaiting); - if (!noEventWaiting) - LOG_MESSAGE(KEventWaiting); - _LIT(KTest4,"FocusChangedL: 4th test completed"); - LOG_MESSAGE(KTest4); - iMoveGroup=CProcess::NewSimpleThreadL(KThreadName,&iFirstFunction,&status); - User::WaitForRequest(status); - delete iMoveGroup; - TEST(TheClient->WaitForEvent()); - TheClient->WaitForAllEventProcessingToFinish(); - - TheClient->WaitForRedrawsToFinish(); - noEventWaiting=!TheClient->IsEventWaiting(); - TEST(noEventWaiting); - if (!noEventWaiting) - LOG_MESSAGE(KEventWaiting); - _LIT(KTest5,"FocusChangedL: 5th and last test completed"); - LOG_MESSAGE(KTest5); - CleanupStack::PopAndDestroy(2,group2); - TheClient->Flush(); - TEST(TheClient->WaitForEvent()); - TheClient->WaitForAllEventProcessingToFinish(); - CleanupStack::PopAndDestroy(2,group1); - } - -#define ALT_PRI 78 -void CTWindowTest::EventsToAllL() - { - CTClient* client1=new(ELeave) CTClient; - CleanupStack::PushL(client1); - client1->SetScreenNumber(iTest->iScreenNumber); - client1->ConstructL(); - CTClient* client2=new(ELeave) CTClient; - CleanupStack::PushL(client2); - client2->SetScreenNumber(iTest->iScreenNumber); - client2->ConstructL(); - CEvWindowGroup* group1a=CEvWindowGroup::NewLC(client1,this); - CEvWindowGroup* group1b=CEvWindowGroup::NewLC(client1,this); - CEvWindowGroup* group2a=CEvWindowGroup::NewLC(client2,this); - CEvWindowGroup* group2b=CEvWindowGroup::NewLC(client2,this); - /*_LIT(KLog,"Window Group Id's: %d,%d,%d,%d"); - LOG_MESSAGE5(KLog,group1a->GroupWin()->Identifier(),group1b->GroupWin()->Identifier(),group2a->GroupWin()->Identifier(),group2b->GroupWin()->Identifier());*/ - group1a->SendEvent(KBaseUserEvent+1); - group2b->SendEvent(KBaseUserEvent+2); - client1->WaitForAllEventProcessingToFinish(); - client2->WaitForAllEventProcessingToFinish(); - TWsEvent event; - // Assigned random value because before PREQ1226, TWsevent's data wasn't zero initialised. - // In techview, following function - // void CEikServAppUi::HandleSystemEventL(const TWsEvent& aEvent) - // was relaying on TWsevent's data not be zero - *(event.Int()) = 0XCCCCCCCC; - event.SetType(KBaseUserEvent+3); - group1a->SetExpectedEvent(KBaseUserEvent+3); - group1b->SetExpectedEvent(KBaseUserEvent+3); - group2a->SetExpectedEvent(KBaseUserEvent+3); - group2b->SetExpectedEvent(KBaseUserEvent+3); - TheClient->iWs.SendEventToAllWindowGroups(event); - client1->WaitForAllEventProcessingToFinish(); - client2->WaitForAllEventProcessingToFinish(); - event.SetType(KBaseUserEvent+4); - group1a->SetExpectedEvent(KBaseUserEvent+4); - group1b->SetExpectedEvent(KBaseUserEvent+4); - group2a->SetExpectedEvent(KBaseUserEvent+4); - group2b->SetExpectedEvent(KBaseUserEvent+4); - TheClient->iWs.SendEventToAllWindowGroups(event); - client1->WaitForAllEventProcessingToFinish(); - client2->WaitForAllEventProcessingToFinish(); - event.SetType(KBaseUserEvent+5); - //group1a->SetExpectedEvent(KBaseUserEvent+5); - group1b->SetExpectedEvent(KBaseUserEvent+5); - //group2a->SetExpectedEvent(KBaseUserEvent+5); - group2b->SetExpectedEvent(KBaseUserEvent+5); - TheClient->iWs.SendEventToOneWindowGroupsPerClient(event); - client1->WaitForAllEventProcessingToFinish(); - client2->WaitForAllEventProcessingToFinish(); - group1a->WinTreeNode()->SetOrdinalPosition(0); - client1->Flush(); - event.SetType(KBaseUserEvent+6); - group1a->SetExpectedEvent(KBaseUserEvent+6); - group2b->SetExpectedEvent(KBaseUserEvent+6); - TheClient->iWs.SendEventToOneWindowGroupsPerClient(event); - client1->WaitForAllEventProcessingToFinish(); - client2->WaitForAllEventProcessingToFinish(); - group2b->WinTreeNode()->SetOrdinalPosition(6); - client2->Flush(); - event.SetType(KBaseUserEvent+7); - group1a->SetExpectedEvent(KBaseUserEvent+7); - group2a->SetExpectedEvent(KBaseUserEvent+7); - TheClient->iWs.SendEventToOneWindowGroupsPerClient(event); - client1->WaitForAllEventProcessingToFinish(); - client2->WaitForAllEventProcessingToFinish(); - event.SetType(KBaseUserEvent+8); - group1a->SetExpectedEvent(KBaseUserEvent+8); - group1b->SetExpectedEvent(KBaseUserEvent+8); - group2a->SetExpectedEvent(KBaseUserEvent+8); - group2b->SetExpectedEvent(KBaseUserEvent+8); - TheClient->iWs.SendEventToAllWindowGroups(0,event); - group1a->WinTreeNode()->SetOrdinalPosition(0,ALT_PRI); - client1->Flush(); - client1->WaitForAllEventProcessingToFinish(); - client2->WaitForAllEventProcessingToFinish(); - event.SetType(KBaseUserEvent+9); - group1a->SetExpectedEvent(KBaseUserEvent+9); - TheClient->iWs.SendEventToAllWindowGroups(ALT_PRI,event); - client1->WaitForAllEventProcessingToFinish(); - client2->WaitForAllEventProcessingToFinish(); - group2b->WinTreeNode()->SetOrdinalPosition(0,ALT_PRI); - client2->Flush(); - client1->WaitForAllEventProcessingToFinish(); - client2->WaitForAllEventProcessingToFinish(); - event.SetType(KBaseUserEvent+10); - group1a->SetExpectedEvent(KBaseUserEvent+10); - group2b->SetExpectedEvent(KBaseUserEvent+10); - TheClient->iWs.SendEventToAllWindowGroups(ALT_PRI,event); - client1->WaitForAllEventProcessingToFinish(); - client2->WaitForAllEventProcessingToFinish(); - event.SetType(KBaseUserEvent+11); - group1b->SetExpectedEvent(KBaseUserEvent+11); - group2a->SetExpectedEvent(KBaseUserEvent+11); - TheClient->iWs.SendEventToAllWindowGroups(0,event); - client1->WaitForAllEventProcessingToFinish(); - client2->WaitForAllEventProcessingToFinish(); - event.SetType(KBaseUserEvent); - group1a->SetExpectedEvent(KBaseUserEvent); - group1b->SetExpectedEvent(KBaseUserEvent); - group2a->SetExpectedEvent(KBaseUserEvent); - group2b->SetExpectedEvent(KBaseUserEvent); - TheClient->iWs.SendEventToAllWindowGroups(event); - client1->WaitForAllEventProcessingToFinish(); - client2->WaitForAllEventProcessingToFinish(); - CleanupStack::PopAndDestroy(6,client1); - } - -void DestroyWindow(TAny* aWindow) - { - static_cast(aWindow)->Destroy(); - } - -void CTWindowTest::GroupIdL() - { - const TInt numWindows=10; - RWindowGroup group(TheClient->iWs); - CleanupClosePushL(group); - User::LeaveIfError(group.Construct(ENullWsHandle)); - TInt id=group.Identifier(); - RWindowTreeNode* prevWindow=&group; - TInt ii; - for (ii=0;iiiWs); - CleanupStack::PushL(TCleanupItem(&DestroyWindow,window)); - User::LeaveIfError(window->Construct(*prevWindow,ENullWsHandle)); - TInt retVal = window->WindowGroupId(); - TEST(retVal==id); - if (retVal!=id) - INFO_PRINTF3(_L("window->WindowGroupId() return value - equal to: %d , Actual: %d"), id, retVal); - prevWindow=window; - } - CleanupStack::PopAndDestroy(numWindows+1); - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-0495 - -@SYMDEF PDEF131541 - -@SYMTestCaseDesc Sending Events using one of the functions SendEventToWindowGroup, SendEventToAllWindowGroups (x2) - and SendEventToOneWindowGroupsPerClient when an event queue is full returns an error - -@SYMTestPriority Low - -@SYMTestStatus Implemented - -@SYMTestActions Call the functions repeatly many times and check that an error gets returned eventually - -@SYMTestExpectedResults Functions return the error KErrNoMemory -*/ -const TInt numTest=75; //Must be at least 33 -void CTWindowTest::SaturateSendEvent() - { - const TInt id=TheClient->iGroup->GroupWin()->Identifier(); - TWsEvent event; - event.SetType(KBaseUserEvent); - TInt ii; - - TInt err=KErrNone; - for (ii=0; ii<=numTest && err==KErrNone;) - { - ++ii; - err=TheClient->iWs.SendEventToWindowGroup(id,event); - } - TEST(err==KErrNoMemory); - if (err!=KErrNoMemory) - { - _LIT(KLog,"After %d/%d iterations SendEventToWindowGroup returned the error %d"); - LOG_MESSAGE4(KLog,ii,numTest,err); - } - TheClient->WaitForAllEventProcessingToFinish(); - - err=KErrNone; - for (ii=0; ii<=numTest && err==KErrNone;) - { - ++ii; - err=TheClient->iWs.SendEventToAllWindowGroups(event); - } - TEST(err==KErrNoMemory); - if (err!=KErrNoMemory) - { - _LIT(KLog,"After %d/%d iterations SendEventToAllWindowGroups returned the error %d"); - LOG_MESSAGE4(KLog,ii,numTest,err); - } - TheClient->WaitForAllEventProcessingToFinish(); - User::After(1000000); //1sec, give other sessions a chance to respond to the events - - err=KErrNone; - for (ii=0; ii<=numTest && err==KErrNone;) - { - ++ii; - err=TheClient->iWs.SendEventToAllWindowGroups(0,event); - } - TEST(err==KErrNoMemory); - if (err!=KErrNoMemory) - { - _LIT(KLog,"After %d/%d iterations SendEventToAllWindowGroups_Priority0 returned the error %d"); - LOG_MESSAGE4(KLog,ii,numTest,err); - } - TheClient->WaitForAllEventProcessingToFinish(); - User::After(1000000); //1sec, give other sessions a chance to respond to the events - - err=KErrNone; - for (ii=0; ii<=numTest && err==KErrNone;) - { - ++ii; - err=TheClient->iWs.SendEventToOneWindowGroupsPerClient(event); - } - TEST(err==KErrNoMemory); - if (err!=KErrNoMemory) - { - _LIT(KLog,"After %d/%d iterations SendEventToOneWindowGroupsPerClient returned the error %d"); - LOG_MESSAGE4(KLog,ii,numTest,err); - } - TheClient->WaitForAllEventProcessingToFinish(); - User::After(1000000); //1sec, give other sessions a chance to respond to the events - } - -void CTWindowTest::TestNotSupportedFunctionality() - { - TInt err = KErrNone; - TSize windowSize = TSize(10,10); - TSize testSize = TSize(); - - RWindowGroup group(TheClient->iWs); - RWindow window(TheClient->iWs); - - err = group.Construct((TUint32)&group, EFalse); - TEST(err==KErrNone); - err = window.Construct(group,(TUint32)&window); - TEST(err==KErrNone); - - window.SetExtent(TPoint(0,0),windowSize); - window.Activate(); - - testSize = window.Size(); - TEST((testSize.iWidth==windowSize.iWidth) && (testSize.iHeight==windowSize.iHeight)); - - testSize = window.SizeForEgl(); - TEST((testSize.iWidth==windowSize.iWidth) && (testSize.iHeight==windowSize.iHeight)); - - err = window.FixNativeOrientation(); - TEST(err==KErrNotSupported); - - testSize = window.Size(); - TEST((testSize.iWidth==windowSize.iWidth) && (testSize.iHeight==windowSize.iHeight)); - - testSize = window.SizeForEgl(); - TEST((testSize.iWidth==windowSize.iWidth) && (testSize.iHeight==windowSize.iHeight)); - - window.Close(); - group.Close(); - } - -void CTWindowTest::RunTestCaseL(TInt /*aCurTestCase*/) - { - _LIT(KTest1,"Window"); - _LIT(KTest2,"DestroyWindowWithActiveGc"); - _LIT(KTest3,"Shadow/NoAutoClear"); - _LIT(KTest4,"Corner Tests"); - _LIT(KTest5,"Invalid Window Functions"); - _LIT(KTest7,"Mega-Tree"); - _LIT(KTest8,"Tiled Window One"); - _LIT(KTest9,"Tiled Window Two"); - _LIT(KTest10,"Color Test"); - _LIT(KTest11,"Invalid Window Functions2"); - _LIT(KTest12,"Defect 1"); - _LIT(KTest13,"Defect 2"); - _LIT(KTest14,"Parent Deleted 1"); - _LIT(KTest15,"Parent Deleted 2"); - _LIT(KTest16,"Defect 3"); - _LIT(KTest17,"Background Color"); - _LIT(KTest18,"Focus Changed"); - _LIT(KTest21,"Events To All"); - _LIT(KTest22,"Error Codes"); - _LIT(KTest23,"Group Id"); - _LIT(KTest24,"DeleteParentWindowOnly"); -#if defined(_DEBUG) - _LIT(KTest25,"DuplicateWindowHandles"); -#else - _LIT(KTest25skipped,"DuplicateWindowHandles skipped"); -#endif - - ((CTWindowTestStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - - _LIT(KTest26,"Saturate SendEvent"); - _LIT(KTest27,"Not Supported Functionality"); - - switch(++iTest->iState) - { -/** -@SYMTestCaseID GRAPHICS-WSERV-0029 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test window can be created and destroyed correctly - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Creates and destroys a window - -@SYMTestExpectedResults Window is created and destroyed without error -*/ - case 1: - ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0029")); - iTest->LogSubTest(KTest1); - CreateTestWindowL(); - CheckAndDestroyWindows(); - //iState=17; - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0030 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Creates and destroys window with an active gc - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Create and destroy a window with an active gc - -@SYMTestExpectedResults Window is created and destroyed without error -*/ - case 2: - ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0030")); - iTest->LogSubTest(KTest2); - CreateTestWindowL(); - DestroyWindowWithActiveGc(); - CreateTestWindowL(); - DestroyWindowWithActiveGc2L(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0031 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test that shadow is not automatically cleared when - drawing a window - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Draw windows and check that the shadow is not automatically - cleared - -@SYMTestExpectedResults Screen comparison returns that the shadow was not cleared -*/ - case 3: - ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0031")); - //window shadowing is no longer supported. keep the test to make sure clients can still call the methods - iTest->LogSubTest(KTest3); - ShadowAutoClearTest(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0032 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test the drawing of different types of corner of - a window - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Draw a window with different types of corner - -@SYMTestExpectedResults The window is drawn correctly for each corner type -*/ - case 4: - ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0032")); - iTest->LogSubTest(KTest4); - CornerTests(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0033 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test for panics when window is sent wrong requests - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Send wrong requests to windows and deal with panic - -@SYMTestExpectedResults The windows panic as expected -*/ - case 5: - ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0033")); - iTest->LogSubTest(KTest5); - TestInvalidFunctionsL(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0035 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Draw 100 windows from a thread - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Draw 100 windows from the same thread - -@SYMTestExpectedResults The windows are all drawn without error -*/ - case 6: - ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0035")); - iTest->LogSubTest(KTest7); - CreateMegaTree(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0036 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Check that windows can be drawn in a tiled format - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Draw two windows in a tiled format and check they - are identical - -@SYMTestExpectedResults The tiled windows are identical -*/ - case 7: - ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0036")); - - iTest->LogSubTest(KTest8); - TiledWindowTestL(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0037 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Check that windows and dialogs can be drawn in a - tiled format - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Draw windows and dialogs in a tiled format - -@SYMTestExpectedResults The windows and dialogs are drawn correctly -*/ - case 8: - ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0037")); - iTest->LogSubTest(KTest9); - TiledWindowTest2L(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0038 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Check drawing into a window with different - colour set ups - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Draw in a window using different colour - configurations - -@SYMTestExpectedResults The different colours are drawn correctly -*/ - case 9: - ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0038")); - iTest->LogSubTest(KTest10); - ColorTestL(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0039 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test for panics when window is sent wrong requests - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Send wrong requests to windows and deal with panic - -@SYMTestExpectedResults The windows panic as expected -*/ - case 10: - ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0039")); - iTest->LogSubTest(KTest11); - TestInvalidFunctions2L(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0040 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test for a defect that causes ROM to crash - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Test a defect is not present which causes the ROM - to crash - -@SYMTestExpectedResults The defect is not present -*/ - case 11: - ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0040")); - iTest->LogSubTest(KTest12); - Bug1L(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0041 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test a previous defect has not returned - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Exercise the code the defect was discovered in - -@SYMTestExpectedResults The defect is not present -*/ - case 12: - ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0041")); - iTest->LogSubTest(KTest13); - Bug2L(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0042 - -@SYMDEF DEF081259 - DEF115543 - -@SYMTestCaseDesc Test that when a parent window is deleted a panic - occurs - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Delete a parent window and check for a panic - NOTE: DEF115543 has corrected GRAPHICS-WSERV-0042, and added a lot - more window functions. - -@SYMTestExpectedResults All functions either: - Panic the owner thread with EWservPanicParentDeleted or - Get performed without accessing any NULL iParent pointers in the WSERV thread -*/ - case 13: - ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0042")); - iTest->LogSubTest(KTest14); - TestDeletedParentPanics1L(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0043 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test that when a parent window is deleted a panic - occurs - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Delete a parent window and check for a panic - -@SYMTestExpectedResults The panic occurs as expected -*/ - case 14: - ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0043")); - iTest->LogSubTest(KTest15); - TestDeletedParentPanics2L(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0044 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Check that activate then make visible and backup - behind a window does not panic. - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Activate then make visible and backup - behind a window - -@SYMTestExpectedResults No panic occurs -*/ - case 15: - ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0044")); - iTest->LogSubTest(KTest16); - Bug3L(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0045 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test window being drawn with the correct background - color when they are moved on the screen - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Move window on the screen and check it is drawn with - the correct background colour - -@SYMTestExpectedResults The background coloour is correct -*/ - case 16: - ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0045")); - iTest->LogSubTest(KTest17); - BackColorBugL(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0046 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test that the focus change is available after redraw - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Redraw and check the focus change is available - -@SYMTestExpectedResults The focus change is available -*/ - case 17: - ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0046")); - iTest->LogSubTest(KTest18); - FocusChangedL(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0048 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test that events can be sent to a number of window - groups simultaneously - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Send events to a number of window groups and check - that they all receive them - -@SYMTestExpectedResults The events and sent to the window groups correctly -*/ - case 18: - ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0048")); - iTest->LogSubTest(KTest21); - EventsToAllL(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0049 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Test error code when incorrectly moving a window to - a group. - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Try to move a window to a group and check the error - codes - -@SYMTestExpectedResults The correct error codes are returned -*/ - case 19: - ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0049")); - iTest->LogSubTest(KTest22); - ErrorCodesL(); -/** -@SYMTestCaseID GRAPHICS-WSERV-0050 - -@SYMDEF DEF081259 - -@SYMTestCaseDesc Check that the correct group id is assigned to a - chain of windows - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Create a chain of windows in the same group and check - the all have the same group id - -@SYMTestExpectedResults The windows all have the same group id -*/ - case 20: - ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0050")); - iTest->LogSubTest(KTest23); - GroupIdL(); - break; - -/** -@SYMTestCaseID GRAPHICS-WSERV-0461 - -@SYMDEF PDEF114190 - -@SYMTestCaseDesc Test window redraw queue cleanup when window is deleted in low memory conditions - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Have a loop which increases the number of allocations in the server thread before failure; - Within the loop: - 1) Create a parent window and a child window of the parent; - 2) Delete the parent window only, but not the child window; - 3) Create a testWindow. This new window gets added to the redraw queue which will force it - reordering. This would crash WSERV due to this defect because the orphaned window (which is - the previous child window) is still in the redraw queue - 4) Delete all the windows involved; - -@SYMTestExpectedResults The window redraw queue should be cleaned up when the first window is deleted; - WSERV should not crash. The test should pass. -*/ - case 21: - ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0461")); - iTest->LogSubTest(KTest24); - TestWindowDelete(); - break; - -/** -@SYMTestCaseID GRAPHICS-WSERV-0463 - -@SYMDEF DEF115601 - -@SYMTestCaseDesc Two RWindowGroup objects using same window client handle cause Emulator crash - -@SYMTestPriority Medium - -@SYMTestStatus Implemented - -@SYMTestActions Create two window groups with the same handle. - -@SYMTestExpectedResults WSERV should panic the client thread with the code EWservPanicDuplicateHandle - and then destroy the window groups without crashing WSERV -*/ - case 22: -#if defined(_DEBUG) - ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0463")); - iTest->LogSubTest(KTest25); - TEST(iTest->TestWsPanicL(DoPanicTest6,EWservPanicDuplicateHandle,0,(TAny*)iTest->iScreenNumber,NULL)); - iTest->CloseAllPanicWindows(); -#else - iTest->LogSubTest(KTest25skipped); //Client side panic will only occur in debug builds of WServ -#endif - break; - case 23: - ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0495")); - iTest->LogSubTest(KTest26); - SaturateSendEvent(); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0655 - -@SYMDEF ou1cimx1#329309 - -@SYMTestCaseDesc Fix native orientation functionality not supported - -@SYMTestPriority Medium - -@SYMTestStatus Implemented - -@SYMTestActions Call fucntions related to fix native orientation on a window - -@SYMTestExpectedResults Fix native orientation functionality not supported - */ - case 24: - ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0655")); - iTest->LogSubTest(KTest27); - TestNotSupportedFunctionality(); - break; - default: - ((CTWindowTestStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - ((CTWindowTestStep*)iStep)->CloseTMSGraphicsStep(); - TestComplete(); - break; - } - ((CTWindowTestStep*)iStep)->RecordTestResultL(); - } - -__WS_CONSTRUCT_STEP__(WindowTest) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TWINDOW.H --- a/windowing/windowserver/tauto/TWINDOW.H Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,149 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef __TWINDOW_H__ -#define __TWINDOW_H__ - -#include -#include -#include "AUTO.H" - -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA -#include "../nonnga/CLIENT/w32comm.h" -#endif - -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA -#include "../nga/CLIENT/w32comm.h" -#endif - -#include "../tlib/testbase.h" -#include "TGraphicsHarness.h" - -struct TWindowThreadParam - { - TInt iCommand; - TInt iScreenNumber; - }; - -class CWinTestWindow : public CBlankWindow - { -public: - CWinTestWindow(TRgb aCol); - ~CWinTestWindow(); - void ConstructL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc, TInt aDepth); -public: - CWinTestWindow *iChild; - }; - -class CEvWindowGroup : public CTWindowGroup - { -public: - static CEvWindowGroup* NewLC(CTClient* aClient,CTWsGraphicsBase* aTest); - CEvWindowGroup(CTClient* aClient,CTWsGraphicsBase* aTest); - void SetExpectedEvent(TInt aType); - void SendEvent(TInt aType); - //Virtual functions from CTWindowGroup - void ConstructL(); - void UserEvent(TInt aEventType); -private: - CTWsGraphicsBase* iTest; - TInt iExpectedEvent; - TBool iExpectingEvent; - }; - -class CTWindowTest : public CTWsGraphicsBase - { -public: - enum {EWinTypeFactor=1000}; - enum - { - EIdMask=0x0000FFFF, - EPosMask=0xFFFF0000, - EPosShift=16 - }; -private: - enum TCorner {ECornerTL,ECornerTR,ECornerBL,ECornerBR}; -public: - CTWindowTest(CTestStep* aStep); - ~CTWindowTest(); - TestState DoTestL(); - void ConstructL(); - void CreateTestWindowL(); - void CheckAndDestroyWindows(); - void DestroyWindowWithActiveGc(); - void DestroyWindowWithActiveGc2L(); - void DrawWindows(CWinTestWindow *aWin); - void ClearRedraw(RWindow &aWindow, TRgb aRgb); - void TestInvalidFunctionsL(); - void ShadowAutoClearTest(); - void CreateMegaTree(); - void TiledWindowTestL(); - void TiledWindowTest2L(); - void CornerTests(); - void ColorTestL(); - void TestInvalidFunctions2L(); - void Bug1L(); - void Bug2L(); - void Bug3L(); - void TestDeletedParentPanics1L(); - void TestDeletedParentPanics2L(); - void BackColorBugL(); - void FocusChangedL(); - void FadeRegionsL(); - void FadeRegionsWithRedrawStoringL(); - void EventsToAllL(); - void ErrorCodesL(); - void GroupIdL(); - void doCornerTestsL(); - void doCornerTest(TCornerType aCornerType, TInt aFlags); - void CheckCorner(TCorner aCorner, const TInt *aInsetList); - void ShadowTestL(); - void TestWindowDelete(); - void SaturateSendEvent(); - void TestNotSupportedFunctionality(); -protected: -//from CTGraphicsStep - virtual void RunTestCaseL(TInt aCurTestCase); -private: - static TInt MoveGroup(TAny* aParam); - void DoFadeRegionsL(TBool aRedrawStoring); -private: - CWinTestWindow *iWin; - CTBlankWindow *iBlankWin1; - CTBlankWindow *iBlankWin2; - CWsScreenDevice *iScreenDev; - TThreadStartUp iFirstFunction; - TWindowThreadParam iThreadParam; - }; - -class CTWindowTestStep : public CTGraphicsStep - { -public: - CTWindowTestStep(); -protected: - //from CTGraphicsStep - virtual CTGraphicsBase* CreateTestL(); - }; - -_LIT(KTWindowTestStep,"TWindowTest"); - - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TWSGRAPHS.CPP --- a/windowing/windowserver/tauto/TWSGRAPHS.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2593 +0,0 @@ -// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// This test step contains a series of tests cases to validate the correct behaviour of PREQ1246 implementation. -// In order to create these test cases, basic implementations of the objects involved in this PREQ will be created, -// .i.e. CWsGraphic-derived objects (generically named CWsGraphicTest) and CWsGraphicDrawer-derived objects -// (generically named CWsGraphicDrawerTest). -// Actual construction is performed by a UI-specific entity such as a theme manager. The test code shall replace -// that theme manager functionality, in terms of being the test code who owns a collection of CWsGraphicTest -// objects. -// -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include "TWSGRAPHS.H" -#include "../inc/WSGRAPHICDRAWERARRAY.H" -#include "../../nga/graphicdrawer/panics.h" -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA -#include "wsbufferdrawer.h" -#endif - -_LIT(KTestExe, "TWSGRAPHICTEST.exe"); -_LIT(KSpace, " "); - -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA -const TInt KCustomTextCursorId = TTextCursor::ETypeLastBasic + 57; // 57 is arbitrary -#endif - -CCrWin* CCrWin::NewL(TInt aScreenId, TBool aDraw) - { - CCrWin* win = new(ELeave) CCrWin; - CleanupStack::PushL(win); - win->ConstructL(aScreenId, aDraw); - CleanupStack::Pop(win); - return win; - } - -CCrWin::~CCrWin() - { - iWin.Close(); - iGroup.Close(); - delete iGc; - delete iScr; - iWs.Close(); - } - -void CCrWin::ConstructL(TInt aScreenId, TBool aDraw) - { - User::LeaveIfError(iWs.Connect()); - iScr = new(ELeave) CWsScreenDevice(iWs); - User::LeaveIfError(iScr->Construct(aScreenId)); - User::LeaveIfError(iScr->CreateContext(iGc)); - iGroup = RWindowGroup(iWs); - User::LeaveIfError(iGroup.Construct(0xbadbabe,ETrue)); - iGroup.SetOrdinalPosition(0,100); - iWin = RWindow(iWs); - User::LeaveIfError(iWin.Construct(iGroup,0xbadcafe)); - iWin.SetRequiredDisplayMode(EColor64K); - iWin.Activate(); - iWs.Flush(); - if (aDraw) - Draw(); - } - -void CCrWin::Draw() - { - iWin.BeginRedraw(); - iGc->Activate(iWin); - iGc->SetBrushColor(KRgbRed); - iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - TRect rect(iScr->SizeInPixels()); - iGc->DrawRect(rect); - iGc->SetBrushColor(KRgbBlue); - iGc->DrawEllipse(TRect(rect.iTl.iX,rect.iTl.iY,rect.iBr.iX/2,rect.iBr.iY)); - iGc->DrawEllipse(TRect(rect.iBr.iX/2,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY)); - iGc->Deactivate(); - iWin.EndRedraw(); - iWs.Flush(); - } - - -void CCrWin::DrawFirstHalf() - { - iWin.BeginRedraw(); - iGc->Activate(iWin); - iGc->SetBrushColor(KRgbRed); - iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - TRect rect(TPoint(0,0),TSize(iScr->SizeInPixels().iWidth/2,iScr->SizeInPixels().iHeight)); - iGc->DrawRect(rect); - iWs.Flush(); - } - -void CCrWin::DrawSecondHalf() - { - TRect rect(TPoint(iScr->SizeInPixels().iWidth/2,0),TSize(iScr->SizeInPixels().iWidth/2,iScr->SizeInPixels().iHeight)); - iGc->DrawRect(rect); - iGc->Deactivate(); - iWin.EndRedraw(); - iWs.Flush(); - } - -/** -The objective of this function is, two animations should run independently -with respective frame rate in the given time interval. -The time delay allows to draw animations freely and the plug-in -calculates number of times DoDraw() function called during this interval. - -@param TInt Wsgrphic test plug-in id. -*/ -void CCrWin::DrawGraphic(TInt aWsId) - { - // draw the animation in two positions - const TSize screenSize = iScr->SizeInPixels(); - const TRect position(0,0,screenSize.iWidth/2,screenSize.iHeight); - const TRect position2((screenSize.iWidth/2)+1,0,screenSize.iWidth,screenSize.iHeight); - //PeterI if CWsGraphic animation areas overlap then when one redraws the other will as well. - //2 separate positions are needed otherwise the framerates will be identical. - - iWin.BeginRedraw(); - iGc->Activate(iWin); - const TUint8 animid1=0; - const TUint8 fps1=20; - TBuf8<2> animData1; - animData1.Append(animid1); //animId1 - animData1.Append(fps1); //20fps - iGc->DrawWsGraphic(aWsId,position,animData1); - iWs.Flush(); - User::After(200000); - const TUint8 animid2=1; - const TUint8 fps2=60; - TBuf8<2> animData2; - animData2.Append(animid2); //animId2 - animData2.Append(fps2); //60fps - iGc->DrawWsGraphic(aWsId,position2,animData2); - iWs.Flush(); - User::After(200000); - iGc->Deactivate(); - iWin.EndRedraw(); - iWs.Flush(); - } - -/** - * Set a standard text cursor on this window. - * @see RWindowGroup::SetTextCursor() - */ -void CCrWin::SetTextCursor(const TPoint &aPos, const TTextCursor &aCursor) - { - iGroup.SetTextCursor(iWin, aPos, aCursor); - } - -/** - * Cancel a text cursor from this window. - * @see RWindowGroup::CancelTextCursor() - */ -void CCrWin::CancelTextCursor() - { - iGroup.CancelTextCursor(); - } - -CCrAlphaWin* CCrAlphaWin::NewL(TInt aScreenId) - { - CCrAlphaWin* win = new(ELeave) CCrAlphaWin; - CleanupStack::PushL(win); - win->ConstructL(aScreenId); - CleanupStack::Pop(win); - return win; - } - -CCrAlphaWin::~CCrAlphaWin() - { - iWin.Close(); - iGroup.Close(); - delete iScr; - iWs.Close(); - } - -void CCrAlphaWin::ConstructL(TInt aScreenId) - { - User::LeaveIfError(iWs.Connect()); - iScr = new(ELeave) CWsScreenDevice(iWs); - User::LeaveIfError(iScr->Construct(aScreenId)); - iGroup = RWindowGroup(iWs); - User::LeaveIfError(iGroup.Construct(0xbadc0de,ETrue)); - iGroup.SetOrdinalPosition(0,100); - iWin = RWindow(iWs); - User::LeaveIfError(iWin.Construct(iGroup,0xbadbeef)); - iWin.SetRequiredDisplayMode(EColor64K); - iWin.SetTransparencyAlphaChannel(); - iWin.SetBackgroundColor(TRgb(0xff,0xff,0,0x80)); - iWin.Activate(); - iWs.Flush(); - } - - -// -// CTWsGraphs -// - -CTWsGraphs::CTWsGraphs(CTestStep* aStep): - CTWsGraphicsBase(aStep) - { - } - -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA -LOCAL_D void DeleteSpriteMember(TAny* aSpriteMember) - { - TSpriteMember* member=reinterpret_cast(aSpriteMember); - delete member->iBitmap; - member->iBitmap=NULL; - delete member->iMaskBitmap; - member->iMaskBitmap=NULL; - } -#endif - -CTWsGraphs::~CTWsGraphs() - { -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - DeleteSpriteMember(&iSpriteMemberArray[0]); - iSpriteMemberArray.Close(); -#endif - delete iGdCoverage; -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - delete iAfter; - delete iBefore; - delete iBackCopy; - delete iFrontCopy; -#endif - delete iListen; - delete iNotify2; - delete iNotify1; -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - delete iRedir; -#endif - } - -void CTWsGraphs::ConstructL() - { -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - iRedir = CWsRedir::NewL(iTest->iScreenNumber,ETrue); - iRedir->SetCallBack(TCallBack(CTWsGraphs::PluginCallBack,this)); -#endif - iNotify1 = CWsNotify::NewL(EFalse); - iNotify2 = CWsNotify::NewL(ETrue); - iListen = CWsListen::NewL(ETrue); - iListen->SetCallBack(TCallBack(CTWsGraphs::PluginCallBack,this)); -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - iFrontCopy = new(ELeave) CFbsBitmap; - iBackCopy = new(ELeave) CFbsBitmap; - iBefore = new(ELeave) CFbsBitmap; - User::LeaveIfError(iBefore->Create(TheClient->iScreen->SizeInPixels(), EColor64K)); - iAfter = new(ELeave) CFbsBitmap; - User::LeaveIfError(iAfter->Create(TheClient->iScreen->SizeInPixels(), EColor64K)); -#endif - iGdCoverage = CWsGdCoverage::NewL(); - iGdCoverage->SetCallBack(TCallBack(CTWsGraphs::PluginCallBack,this)); -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - TSpriteMember spriteMember; - spriteMember.iBitmap = NULL; - spriteMember.iMaskBitmap = NULL; - spriteMember.iInvertMask =EFalse; - spriteMember.iDrawMode = CGraphicsContext::EDrawModePEN; - spriteMember.iOffset = TPoint(); - spriteMember.iInterval = TTimeIntervalMicroSeconds32(0); - CleanupStack::PushL(TCleanupItem(DeleteSpriteMember, &spriteMember)); - spriteMember.iBitmap = new (ELeave) CFbsBitmap; - User::LeaveIfError(spriteMember.iBitmap->Load(TEST_BITMAP_NAME, EMbmWsautotestBmp1)); - spriteMember.iMaskBitmap = new (ELeave) CFbsBitmap; - User::LeaveIfError(spriteMember.iMaskBitmap->Load(TEST_BITMAP_NAME, EMbmWsautotestBmp1mask)); - User::LeaveIfError(iSpriteMemberArray.Append(spriteMember)); - CleanupStack::Pop(&spriteMember); -#endif - } - -void CTWsGraphs::LaunchNewProcess(const TDesC& aExecutable) - { - TBuf<128> args; - args.Append(KSpace); - args.AppendNum(iTest->iScreenNumber); - RProcess pr; - TInt err = pr.Create(aExecutable,args); - if (err == KErrNone) - { - TRequestStatus status; - pr.Logon(status); - pr.Resume(); - User::WaitForRequest(status); - err = pr.ExitReason(); - pr.Close(); - if (err != KErrNone) - { - _LIT(KLog,"%S returned error: %d. Check RDebug output."); - LOG_MESSAGE3(KLog, &aExecutable, err); - } - } - else - { - _LIT(KLog,"Can't create the process (%S), err=%d"); - LOG_MESSAGE3(KLog, &aExecutable, err); - } - TEST(err == KErrNone); - // Restore main test group to foreground. - TheClient->iGroup->GroupWin()->SetOrdinalPosition(0); - } - -TInt CTWsGraphs::PluginCallBack(TAny* /*aArg*/) - { - return (TInt)EWait; - } - -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - -/** - @SYMTestCaseID GRAPHICS-WSERV-0371 - @SYMREQ GT247-CR0714 - @SYMTestCaseDesc Test interface extension - @SYMTestPriority High - @SYMTestStatus Implemented - @SYMTestActions Retrieves object interfaces from Content Rendering Plugin (plugin). - Actions step: - -Create plugin - -Query interfaces obtained from plugin side - @SYMTestExpectedResults Supported interfaces should return non null -*/ -TestState CTWsGraphs::TestInterfaceExtensionL() - { - if (iSubState==0) - { - _LIT(KTestInterfaceExtension, "TestInterfaceExtension"); - INFO_PRINTF1(KTestInterfaceExtension); - - ++iSubState; - Mem::FillZ(&iRedirInfo, sizeof(TRedirectorInfo)); - iRedir->QueryPlugin(iRedirInfo); - return EWait; - } - TEST(iRedirInfo.iScreenConfigInterface!=NULL); - TEST(iRedirInfo.iFrontBufferInterface!=NULL); - TEST(iRedirInfo.iScreenBitmapHandle!=0); - iFrontCopy->Duplicate(iRedirInfo.iScreenBitmapHandle); - - if (TransparencySupportedL()!=KErrNotSupported) - { - TEST(iRedirInfo.iBackBufferInterface!=NULL); - TEST(iRedirInfo.iFlickerBitmapHandle!=0); - iBackCopy->Duplicate(iRedirInfo.iFlickerBitmapHandle); - } - - ++(iTest->iState); - iSubState = 0; - return ENext; - } - -#endif // TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - -void CTWsGraphs::CreateWindowL(TBool aDraw) - { - iWin = CCrWin::NewL(iTest->iScreenNumber, aDraw); - } - -void CTWsGraphs::DestroyWindowL() - { - delete iWin; - iWin = NULL; - } - -void CTWsGraphs::CreateAlphaWindowL() - { - iAlpha = CCrAlphaWin::NewL(iTest->iScreenNumber); - } - -void CTWsGraphs::DestroyAlphaWindowL() - { - delete iAlpha; - iAlpha = NULL; - } - -TBool CTWsGraphs::CompareBitmapArea16Bpp(CFbsBitmap* aBmp1, const TPoint& aPos1, CFbsBitmap* aBmp2, const TPoint& aPos2, const TSize& aSize) - { - const TDisplayMode dispmode = aBmp1->DisplayMode(); - if (dispmode!=aBmp2->DisplayMode()) - return EFalse; - const TInt stride1 = aBmp1->DataStride(); - const TInt stride2 = aBmp2->DataStride(); - const TInt linebytes = aSize.iWidth * 2; - const TInt pixelbytes = 2; - aBmp1->LockHeap(); - const TUint8* p1 = ((const TUint8*)aBmp1->DataAddress())+aPos1.iY*stride1+aPos1.iX*pixelbytes; - const TUint8* p2 = ((const TUint8*)aBmp2->DataAddress())+aPos2.iY*stride2+aPos2.iX*pixelbytes; - for (TInt y=0; yUnlockHeap(); - return EFalse; - } - } - aBmp1->UnlockHeap(); - return ETrue; - } - -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA -TestState CTWsGraphs::TestScreenRedirectionL() - { - if (iSubState==0) - { - _LIT(KTestScreenRedirection, "TestScreenRedirection"); - INFO_PRINTF1(KTestScreenRedirection); - - ++iSubState; - /** - @SYMTestCaseID GRAPHICS-WSERV-0372 - @SYMREQ GT247-CR0714 - @SYMTestCaseDesc Redirect wserv screen drawing to custom graphics context - @SYMTestPriority High - @SYMTestStatus Implemented - @SYMTestActions Redirects wserv screen drawing to bitmap context owned by plugin. - Actions step: - -Draw opaque window. - -Save screen content to a bitmap - -Instruct plugin to redirect wserv screen drawing to a bitmap device - -Draw the same window again - -Retrieve plugin bitmap and compare against the saved bitmap - @SYMTestExpectedResults Bitmap content match - */ - CreateWindowL(); - TheClient->iScreen->CopyScreenToBitmap(iBefore); - DestroyWindowL(); - iRedir->Redirect(CWsRedir::EFrontBuffer, ETrue); - return EWait; - } - - if (iSubState==1) - { - ++iSubState; - CreateWindowL(); - TSize sz = iBefore->SizeInPixels(); - TInt bytes = sz.iWidth*sz.iHeight*2; // EColor64K - iBefore->LockHeap(); - TEST(Mem::Compare((const TUint8*)iFrontCopy->DataAddress(),bytes,(const TUint8*)iBefore->DataAddress(),bytes)==0); - iBefore->UnlockHeap(); - - Mem::FillZ(&iRedirInfo, sizeof(TRedirectorInfo)); - iRedir->QueryPlugin(iRedirInfo); - return EWait; - } - - if (iSubState==2) - { - ++iSubState; - /** - @SYMTestCaseID GRAPHICS-WSERV-0047 - @SYMTestCaseDesc Screen update event - @SYMTestPriority Medium - @SYMTestStatus Implemented - @SYMTestActions Check plugin receive screen update event during redirection - @SYMTestExpectedResults Counter is non-zero - */ - TEST(iRedirInfo.iUpdateCounter>0); - - DestroyWindowL(); - /** - @SYMTestCaseID GRAPHICS-WSERV-0373 - @SYMREQ GT247-CR0714 - @SYMTestCaseDesc Stop wserv screen drawing redirection - @SYMTestPriority High - @SYMTestStatus Implemented - @SYMTestActions Stop wserv screen drawing redirection. - Actions step: - -Instruct plugin to stop wserv screen drawing redirection - -Draw the same window again - -Save screen content to another bitmap - -Compare the saved bitmap against newly saved bitmap - @SYMTestExpectedResults Bitmap content match - */ - iRedir->Redirect(CWsRedir::EFrontBuffer, EFalse); - return EWait; - } - - if (iSubState==3) - { - ++iSubState; - CreateWindowL(); - TheClient->iScreen->CopyScreenToBitmap(iAfter); - TSize sz = iBefore->SizeInPixels(); - TInt bytes = sz.iWidth*sz.iHeight*2; // EColor64K - iAfter->LockHeap(); - TEST(Mem::Compare((const TUint8*)iAfter->DataAddress(),bytes,(const TUint8*)iBefore->DataAddress(),bytes)==0); - iAfter->UnlockHeap(); - DestroyWindowL(); - - Mem::FillZ(&iRedirInfo, sizeof(TRedirectorInfo)); - iRedir->QueryPlugin(iRedirInfo); - return EWait; - } - - /** - @SYMTestCaseID GRAPHICS-WSERV-0374 - @SYMTestCaseDesc Screen update event - @SYMTestPriority Medium - @SYMTestStatus Implemented - @SYMTestActions Check plugin receive no screen update event when redirection is terminated - @SYMTestExpectedResults Counter is zero - */ - TEST(iRedirInfo.iUpdateCounter==0); - - ++(iTest->iState); - iSubState = 0; - - return ENext; - } - -TestState CTWsGraphs::TestTextCursorUnderRedirectionL(TTestCursorType aCursorType) - { - /** - @SYMTestCaseID GRAPHICS-WSERV-0363 - @SYMTestCaseDesc Text Cursor when drawing redirected - @SYMTestPriority Medium - @SYMTestStatus Implemented - @SYMTestActions Action steps: - - Draw the text cursor in the left side of the screen - - Re-direct the Front Buffer - - Move the text cursor to the right side of the screen - - Pause 0.5 seconds because this amount of time is needed - to change from the flash ON phase to the flash OFF phase - - Stop re-directing - - See if when we exit re-direction in a different place in - the phase of the text cursor flashing, whether we get - non-text cursor drawing artefacts in the old location - where the text cursor used to be - @SYMTestExpectedResults Left side of the screen does not show a Text Cursor - */ - - ASSERT(aCursorType == ETestStandardTextCursor || aCursorType == ETestCustomTextCursor); - - // Cursor Flash Period is 1 second (comprising two phases; ON and OFF) - const TInt KCursorFlashPeriod = 1000000; - const TInt KWaitForNextFlashPhase = KCursorFlashPeriod / 2; - - // Size of the cursor; it may be either a standard or custom text cursor - TSize cursorSize = (aCursorType == ETestStandardTextCursor) ? TSize(15, 20) : TSize(80, 80); - - // Original Text Cursor position in the left part of the screen - const TPoint originalCursorPos(45, 40); - - // New Text Cursor position in the right half of the screen - const TPoint newCursorPos((TheClient->iScreen->SizeInPixels().iWidth/2) + 45, 40); - - // Clean area of the screen which never had a text cursor - const TPoint cleanReferencePos(45, 40 + 80); - - /* Initial setup to get a window with a standard flashing text cursor */ - if (iSubState == 0) - { - ++iSubState; - CreateWindowL(ETrue); - - if (aCursorType == ETestStandardTextCursor) - { - _LIT(KTestTextCursorUnderRedirection, "TestTextCursorUnderRedirection(Standard Cursor)"); - INFO_PRINTF1(KTestTextCursorUnderRedirection); - iTextCursor.iType=TTextCursor::ETypeRectangle; - iTextCursor.iHeight=cursorSize.iHeight; - iTextCursor.iAscent=0; - iTextCursor.iWidth=cursorSize.iWidth; - iTextCursor.iFlags=0; // means flash the cursor - iTextCursor.iColor=KRgbGreen; - iWin->SetTextCursor(originalCursorPos, iTextCursor); - } - else if (aCursorType == ETestCustomTextCursor) - { - _LIT(KTestTextCursorUnderRedirection, "TestTextCursorUnderRedirection(Custom Cursor)"); - INFO_PRINTF1(KTestTextCursorUnderRedirection); - - TInt err = TheClient->iWs.SetCustomTextCursor( - KCustomTextCursorId, - iSpriteMemberArray.Array(), - ESpriteFlash, - RWsSession::ECustomTextCursorAlignTop - ); - iTextCursor.iType=KCustomTextCursorId; - iTextCursor.iHeight=cursorSize.iHeight; - iTextCursor.iAscent=0; - iTextCursor.iWidth=cursorSize.iWidth; - iTextCursor.iFlags=TTextCursor::EFlagClipHorizontal; // means flash the cursor and clip the sprite - iTextCursor.iColor=KRgbCyan; - iWin->SetTextCursor(originalCursorPos, iTextCursor); - } - else - { - // unknown type of test being requested - ASSERT(0); - } - iWin->DrawFirstHalf(); - return EWait; - } - /* - * Re-direct drawing to another Front Buffer. Whilst re-directed, change the - * position of the text cursor. Then pause 0.5 seconds because this is how - * long it will take to enter the next phase in the flashing cycle. Finally - * stop re-directing. We exit the re-direction in a different point in the - * phase of the text cursor from when we entered it. - * This is key to testing for faulty behaviour. - */ - if (iSubState==1) - { - ++iSubState; - User::After(KCursorFlashPeriod * 2); // so its easy to visually review progress - iRedir->Redirect(CWsRedir::EFrontBuffer, ETrue); - iWin->SetTextCursor(newCursorPos, iTextCursor); - User::After(KWaitForNextFlashPhase); - iRedir->Redirect(CWsRedir::EFrontBuffer, EFalse); - return EWait; - } - /* - * Paint the right hand side of the screen which should now have a text cursor. - */ - if (iSubState==2) - { - ++iSubState; - iWin->DrawSecondHalf(); - return EWait; - } - /* - * Let the cursor flash a few times, as it assists manual viewing of the progress - * of the test. - */ - if (iSubState==3) - { - ++iSubState; - User::After(KCursorFlashPeriod * 3); - return EWait; - } - /* - * Check to see if the text cursor did move to the right of the screen. - */ - if (iSubState==4) - { - ++iSubState; - - /* When we do a screen comparison, we supply flag 0, which means - * don't include the text cursor. We do this because we are interested - * in screen artefacts. - */ - TEST(TheClient->iScreen->RectCompare( - TRect(originalCursorPos, cursorSize), - TRect(cleanReferencePos, cursorSize), - 0)); // must not supply CWsScreenDevice::EIncludeTextCursor - - return EWait; - } - /* Clean up */ - if (iSubState==5) - { - ++iSubState; - iWin->CancelTextCursor(); - DestroyWindowL(); - } - - iSubState = 0; - - return ENext; - } - -/** - @SYMTestCaseID GRAPHICS-WSERV-0375 - @SYMREQ GT247-CR0714 - @SYMTestCaseDesc Redirect wserv flickerfree drawing to custom graphics context - @SYMTestPriority Medium - @SYMTestStatus Implemented - @SYMTestActions Redirect wserv flickerfree buffer drawing. - Action step: - -Draw opaque window (as background) and transparent window - -Save screen content to a bitmap - -Instruct plugin to redirect wserv flickerfree buffer drawing - -Draw the same opaque window and transparent window again - -Retrieve plugin bitmap and compare against the saved bitmap - @SYMTestExpectedResults Bitmap content match -*/ -/** - @SYMTestCaseID GRAPHICS-WSERV-0376 - @SYMREQ GT247-CR0714 - @SYMTestCaseDesc Stop wserv flickerfree drawing redirection - @SYMTestPriority Medium - @SYMTestStatus Implemented - @SYMTestActions Stop wserv flickerfree buffer drawing redirection. - Action step: - -Instruct plugin to stop wserv filckerfree drawing redirection - -Draw the same opaque and transparent window - -Save screen content to another bitmap - -Compare saved bitmap against newly saved bitmap - @SYMTestExpectedResults Bitmap content match -*/ - -TestState CTWsGraphs::TestFlickerRedirectionL() - { - if (TransparencySupportedL()==KErrNotSupported) - { - ++(iTest->iState); - return ENext; - } - - // flush transparent window destruction created in TransparencySupportedL before - // proceeding with the test - - TheClient->iWs.Flush(); - - if (iSubState==0) - { - _LIT(KTestFlickerRedirection, "TestFlickerRedirection"); - INFO_PRINTF1(KTestFlickerRedirection); - - ++iSubState; - - CreateWindowL(); - CreateAlphaWindowL(); - TheClient->iScreen->CopyScreenToBitmap(iBefore); - DestroyAlphaWindowL(); - DestroyWindowL(); - iRedir->Redirect(CWsRedir::EBackBuffer, ETrue); - return EWait; - } - - if (iSubState==1) - { - ++iSubState; - CreateWindowL(); - CreateAlphaWindowL(); - TSize sz = iBefore->SizeInPixels(); - TInt bytes = sz.iWidth*sz.iHeight*2; // EColor64K - iBefore->LockHeap(); - TInt ret=Mem::Compare((const TUint8*)iBackCopy->DataAddress(),bytes,(const TUint8*)iBefore->DataAddress(),bytes); - TEST(ret==0); - if (ret!=0) - { - _LIT(KLog,"The memory of two bitmaps doesn't match"); - LOG_MESSAGE(KLog); - } - iBefore->UnlockHeap(); - DestroyAlphaWindowL(); - DestroyWindowL(); - iRedir->Redirect(CWsRedir::EBackBuffer, EFalse); - return EWait; - } - - CreateWindowL(); - CreateAlphaWindowL(); - TheClient->iScreen->CopyScreenToBitmap(iAfter); - TSize sz = iBefore->SizeInPixels(); - TInt bytes = sz.iWidth*sz.iHeight*2; // EColor64K - iAfter->LockHeap(); - TEST(Mem::Compare((const TUint8*)iAfter->DataAddress(),bytes,(const TUint8*)iBefore->DataAddress(),bytes)==0); - iAfter->UnlockHeap(); - DestroyAlphaWindowL(); - DestroyWindowL(); - - ++(iTest->iState); - iSubState = 0; - return ENext; - } - -#endif // TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - -/** - @SYMTestCaseID GRAPHICS-WSERV-0377 - @SYMREQ GT247-CR0714 - @SYMTestCaseDesc Enable event notification - @SYMTestPriority Medium - @SYMTestStatus Implemented - @SYMTestActions Enable plugin to register to event notification. - Action step: - -Instruct plugin to register event handler - -Draw fullscreen window (plugin will receive window visibility changed event) - -Query visibility region from plugin side - -Compare window visible region against value obtained by plugin - @SYMTestExpectedResults Visible region match -*/ -/** - @SYMTestCaseID GRAPHICS-WSERV-0378 - @SYMREQ GT247-CR0714 - @SYMTestCaseDesc Disable event notification - @SYMTestPriority Medium - @SYMTestStatus Implemented - @SYMTestActions Disable plugin to register to event notification. - Action step: - -Instruct plugin to unregister event handler - -Destroy fullscreen window (plugin will not receive window visibility changed event) - -Query visibility region from plugin side - - @SYMTestExpectedResults Plugin does not receive events notification -*/ -TestState CTWsGraphs::TestEventNotificationL() - { - if (iSubState==0) - { - _LIT(KTestEventNotification, "TestEventNotification"); - INFO_PRINTF1(KTestEventNotification); - - ++iSubState; - iListen->Enable(ETrue); - CreateWindowL(); - Mem::FillZ(&iListenInfo, sizeof(TListenerInfo)); - TheClient->iWs.Finish(); - TheClient->WaitForRedrawsToFinish(); - iListen->QueryPlugin(iListenInfo); - return EWait; - } - - if (iSubState==1) - { - ++iSubState; - iListen->Enable(EFalse); - TEST(iListenInfo.iNumRect==1); - TEST(iListenInfo.iRect==TRect(TPoint(0,0),TheClient->iScreen->SizeInPixels())); - DestroyWindowL(); - Mem::FillZ(&iListenInfo, sizeof(TListenerInfo)); - iListen->QueryPlugin(iListenInfo); - iListen->Enable(EFalse); - DestroyWindowL(); - return EWait; - } - - TEST(iListenInfo.iNumRect==0); - - ++(iTest->iState); - iSubState = 0; - return ENext; - } - -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - -TestState CTWsGraphs::TestRedirectionUsingWsBackBufferL() - { - if (TransparencySupportedL()==KErrNotSupported) - { - ++(iTest->iState); - return ENext; - } - - // flush transparent window destruction created in TransparencySupportedL before - // proceeding with the test - - TheClient->iWs.Flush(); - - if (iSubState==0) - { - _LIT(KTestRedirectionWsBack, "TestRedirectionUsingWsBackBuffer"); - INFO_PRINTF1(KTestRedirectionWsBack); - - ++iSubState; - - /** - @SYMTestCaseID GRAPHICS-WSERV-0379 - @SYMTestCaseDesc Redirect wserv flickerfree to MWsBackBuffer object - @SYMTestPriority Medium - @SYMTestStatus Implemented - @SYMTestActions -Draw opaque window (as background) and transparent window - -Save screen content to a bitmap - -Instruct plugin to redirect flickerfree buffer to MWsBackBuffer object - -Draw the same opaque window and transparent window again - -Retrieve plugin bitmap and compare against the saved bitmap - @SYMTestExpectedResults Bitmap content match - */ - ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0379")); - CreateWindowL(); - CreateAlphaWindowL(); - TheClient->iScreen->CopyScreenToBitmap(iBefore); - DestroyAlphaWindowL(); - DestroyWindowL(); - iRedir->RedirectUsingWsBackBuffer(ETrue); - return EWait; - } - - if (iSubState==1) - { - ++iSubState; - CreateWindowL(); - CreateAlphaWindowL(); - TSize sz = iBefore->SizeInPixels(); - TInt bytes = sz.iWidth*sz.iHeight*2; // EColor64K - iBefore->LockHeap(); - TInt ret=Mem::Compare((const TUint8*)iBackCopy->DataAddress(),bytes,(const TUint8*)iBefore->DataAddress(),bytes); - TEST(ret==0); - if (ret!=0) - { - _LIT(KLog,"The memory of two bitmaps doesn't match"); - LOG_MESSAGE(KLog); - } - iBefore->UnlockHeap(); - DestroyAlphaWindowL(); - DestroyWindowL(); - - /** - @SYMTestCaseID GRAPHICS-WSERV-0380 - @SYMTestCaseDesc Restore wserv flickerfree redirection from MWsBackBuffer object - @SYMTestPriority Medium - @SYMTestStatus Implemented - @SYMTestActions -Instruct plugin to stop wserv filckerfree drawing redirection - -Draw the same opaque and transparent window - -Save screen content to another bitmap - -Compare saved bitmap against newly saved bitmap - @SYMTestExpectedResults Bitmap content match - */ - ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0380")); - iRedir->RedirectUsingWsBackBuffer(EFalse); - return EWait; - } - - CreateWindowL(); - CreateAlphaWindowL(); - TheClient->iScreen->CopyScreenToBitmap(iAfter); - TSize sz = iBefore->SizeInPixels(); - TInt bytes = sz.iWidth*sz.iHeight*2; // EColor64K - iAfter->LockHeap(); - TEST(Mem::Compare((const TUint8*)iAfter->DataAddress(),bytes,(const TUint8*)iBefore->DataAddress(),bytes)==0); - iAfter->UnlockHeap(); - DestroyAlphaWindowL(); - DestroyWindowL(); -/** - @SYMTestCaseID GRAPHICS-WSERV-0527 -*/ - ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0527")); - ++(iTest->iState); - iSubState = 0; - return ENext; - } - -#endif // TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - -//A call to do coverage through a plugin. -//This can serve as a basis for future coverage to objects exposed by the -//plugin. For now a single simple test is implmeneted. -TestState CTWsGraphs::TestGraphicDrawerCoverage() - { - __ASSERT_ALWAYS(iGdCoverage->RunTest(1)==KErrNone||KErrNotReady, User::Invariant()); - return ENext; - } - -//Simplified non-functional class to create a few dummy CWsGraphicDrawer instances. -//This code is intended to test the Array class, not the Drawer. -//Note that this object is not at all functional! The only guaranteed method is Id(). -//WsGraphicDrawer is declared as a friend and is actually intended to be the factory class for CWsGraphicDrawer -class WsGraphicDrawer:public CWsGraphicDrawer - { -public: - WsGraphicDrawer() - { - } - //stub for virtual construction. Most members are ignored - virtual void ConstructL(MWsGraphicDrawerEnvironment& ,const TGraphicDrawerId& id,MWsClient& ,const TDesC8& ) - { - ConstructL(id); - } - //simplified custom construction - void ConstructL(const TGraphicDrawerId& id) - { - MWsGraphicDrawerEnvironment* nullEnv=NULL; - MWsGraphicDrawerEnvironment& aEnv=*nullEnv; - MWsClient* nullClient=NULL; - MWsClient& aOwner=*nullClient; - this->BaseConstructL(aEnv,id,aOwner); - this->iDtor_ID_Key=TUid::Null(); - - } - //stubs for pure virtual methods - virtual void HandleMessage(const TDesC8& ) - {} - virtual void DoDraw(MWsGc& ,const TRect& ,const TDesC8& ) const - {} - - }; -//Class to allow me to pre-allocate the CWsGraphicDrawerArray so it doesn't pop up a false-positive memory allocation! -class DummyCleanup:public TCleanupItem - { -public: - static void CleanUp(TAny*) {} - DummyCleanup(): TCleanupItem(CleanUp,this) {} - operator DummyCleanup*() { return this; } - - }; - -//Helper function to explain test fails. Most other tests are against KErrNone -void CTWsGraphs::ReportNegativeResultfail(TInt aLine,TInt aResult,TInt aExpectedResult) - { - testBooleanTrue((aResult==aExpectedResult), (TText8*)__FILE__, aLine); - if (aResult!=aExpectedResult) - { - INFO_PRINTF3(_L("Expected return code %i, got %i"),aExpectedResult,aResult); - } - - } - -//This is an attempt to use wserv test's pre-existing Panic handler to perform some negative tests. -//At present this handler appears to be broken: -// 1) It doesn't write to the correct html log file -// 2) It no longer writes to the WSERV.LOG file it was writing to a few versions ago -// 3) It doesn't close the panic window so subsequent tests that check the display output fail. -//That was a waste of effort. -struct CTWsGraphs::WrapTestCall - { - CTWsGraphs* thisThis; - TUint testCount; - TBool continueTests; - TUint testFailedLine; - //This field was intended to allow threaded panicing tests to report other errors - //As I can't get threaded panicing tests to operate correctly, I have not implemented support for the field. - //TBuf<1024> errorMessages; - - WrapTestCall ( CTWsGraphs* thisThis, TUint testCount): - thisThis(thisThis), testCount(testCount) - { continueTests=false;testFailedLine=0; } - }; - -TInt CTWsGraphs::DoNegTestCall(TInt /*aInt*/, TAny *aPtr) - { - CTWsGraphs::WrapTestCall* aWrap=static_cast(aPtr); - aWrap->continueTests=aWrap->thisThis->NegTestAddSwapGDArrayL(aWrap->testCount,aWrap); - return 0; - } - -TBool CTWsGraphs::LaunchNegTestCall(TUint aTestCount,TUint PanicCode,const TDesC &aPanicCategory) - { - WrapTestCall wt(this,aTestCount); - (void)PanicCode; - (void)aPanicCategory; -//I have disabled the panicing tests because they don't output diagnostics -//and the open panic window causes subsequent screen bitmap comparrisson tests to fail. -// iTest->TestPanicL(DoNegTestCall,aPanicCode,3,&wt,aPanicCategory); - return wt.continueTests; - } - -/** - Loops through all the positive and negative tests associated with the GraphicDrawerArray. - The aim is to perform isolated testing of these classes as some are not currently being used. - -**/ -void CTWsGraphs::TestAddSwapGDArrayL() - { - - - INFO_PRINTF1(_L("Positive tests for GraphicDrawerArray")); - for (TInt i=0;PosTestAddSwapGDArrayL(i);i++) - {} - - - - INFO_PRINTF1(_L("Verifying that negative tests for GraphicDrawerArray don't actually panic")); - for (TInt i=1;NegTestAddSwapGDArrayL(i);i++) - {} - } -/** - Resets and deallocates the GDA withoud deleting the objects. - @param testArray the array to reset - @return true if the array was already empty. -**/ -static bool ResetArray(CWsGraphicDrawerArray& testArray) -{ - bool rv=(testArray.IsEmpty()); - MWsClient* nullClient=NULL; - testArray.RemoveAll(*nullClient); - testArray.ResetAndDestroy(); - return rv; -} -/** - @SYMTestCaseID GRAPHICS-WSERV-AddSwapGDArray-0001 - @SYMDEF DEF093926 - - @SYMTestCaseDesc DEF093926: Check for stability of Add and Swap unwind methods in isolation. - Note that this code is testing the functionality of a class internal to CWindowServer. - At present CWindowServer presents just a simple shim on this class, - but if that implementation of CWindowServer changes than this test will be redudant. - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions - The sequence for each of these positive test sections is pretty much the same: - Add one record with id 1234(test for errors) - Add one record with id Badf00d - Swap with another record with id Badf00d - Remove 2 records - result=no leaks - - Add/Swap: no Cleanup item - no leaks after Remove the added items - AddTLC/SwapTLC: Cleanup item requires Commit - check for no leaks after Remove. - AddTLC/SwapTLC: Cleanup item gets executed by forced Leave - check for no leaks after. - AddTLC, SwapTLC in allocation failure scenarios. Add/Swap don't allocate anything! - obsoleted AddLC/SwapLC to ensure correct function when forced Leave - check for no leaks after - obsoleted AddLC/SwapLC to ensure correct function. These will always leak in good case. - @SYMTestExpectedResults - no exceptions or panics within this fn. - only the old AddLC and SwapLC should leak as indicated. - */ -TBool CTWsGraphs::PosTestAddSwapGDArrayL(TInt testcase) - { - ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-AddSwapGDArray-0001")); - CWsGraphicDrawerArray testArray; - //Represents the memory cached in the array once it has been used even when it is then resized to zero -#if defined(_DEBUG) - const TInt KArrayMemUseBaseline=1; -#endif - //Use testArray.IsEmpty() to prove the array is clear when it should be! - TGraphicDrawerId id1234= { 1234, EFalse }; - TGraphicDrawerId idBADF00D= { 0xBADF00D, EFalse }; - WsGraphicDrawer dg1234; - dg1234.ConstructL(id1234); - WsGraphicDrawer dgBADF00D; - dgBADF00D.ConstructL(idBADF00D); - WsGraphicDrawer dgBADF00D_2; - dgBADF00D_2.ConstructL(idBADF00D); - CWsGraphicDrawerArray::XRollBackBase* rollBack1; - TInt errCode=KErrAbort; - TInt leaveCode=KErrNone; - DummyCleanup markerCleanup; - CleanupStack::PushL(markerCleanup); //This allows me to check the stack is clear! - //expected result of this fn: no exceptions or panics. - //Put as much as you like in here, so long as it shouldn't fail. - - __UHEAP_MARK; - __UHEAP_CHECK(0); - TUint expectedLeakCount=0; - TBool returnCode=ETrue; - switch (testcase) - { - case 0: - - INFO_PRINTF1(_L("Sub test P0: AddL/Swap: no Cleanup item")); - TEST(testArray.IsEmpty()); - TRAP(leaveCode,errCode=testArray.Add(&dg1234)); - TEST(errCode==KErrNone); - TEST(leaveCode==KErrNone); - TEST(!testArray.IsEmpty()); - TRAP(leaveCode,errCode=testArray.Add(&dgBADF00D)); - TEST(errCode==KErrNone); - TEST(leaveCode==KErrNone); - TRAP(leaveCode,errCode=testArray.Swap(&dgBADF00D_2)); - TEST(errCode==KErrNone); - TEST(leaveCode==KErrNone); - TRAP(leaveCode,errCode=testArray.Remove(dg1234.Id())); - TEST(errCode==KErrNone); - TEST(leaveCode==KErrNone); - //Note that it is the ID that matters here... dgBADF00D & dgBADF00D_2 have same id. - TRAP(leaveCode,errCode=testArray.Remove(dgBADF00D_2.Id())); - TEST(errCode==KErrNone); - TEST(leaveCode==KErrNone); - TEST(testArray.IsEmpty()); - break; - // - case 1: - INFO_PRINTF1(_L("Sub test P1: AddTLC/SwapTLC: Cleanup item requires Commit.")); - - rollBack1=NULL; - TEST(testArray.IsEmpty()); - TRAP(leaveCode, - rollBack1=testArray.AddTLC(&dg1234); - CleanupStack::Check(rollBack1); - testArray.CommitP(rollBack1); - ) - TEST(rollBack1!=NULL); - TEST(leaveCode==KErrNone); - TEST(!testArray.IsEmpty()); - rollBack1=NULL; - TRAP(leaveCode, - rollBack1=testArray.AddTLC(&dgBADF00D); - CleanupStack::Check(rollBack1); - testArray.CommitP(rollBack1); - ) - TEST(rollBack1!=NULL); - TEST(leaveCode==KErrNone); - rollBack1=NULL; - TRAP(leaveCode, - rollBack1=testArray.SwapTLC(&dgBADF00D_2); - CleanupStack::Check(rollBack1); - testArray.CommitP(rollBack1); - ) - TEST(rollBack1!=NULL); - TEST(leaveCode==KErrNone); - rollBack1=NULL; - TRAP(leaveCode, - rollBack1=testArray.RemoveTLC(dg1234.Id()); - CleanupStack::Check(rollBack1); - testArray.CommitP(rollBack1); - ) - TEST(rollBack1!=NULL); - TEST(leaveCode==KErrNone); - rollBack1=NULL; - TRAP(leaveCode, - rollBack1=testArray.RemoveTLC(dgBADF00D_2.Id()); - CleanupStack::Check(rollBack1); - testArray.CommitP(rollBack1); - ) - TEST(rollBack1!=NULL); - TEST(leaveCode==KErrNone); - rollBack1=NULL; - TEST(testArray.IsEmpty()); - break; - // - case 2: - INFO_PRINTF1(_L("Sub test P2: AddTLC/SwapTLC: Cleanup item gets executed.")); - - rollBack1=NULL; - TEST(testArray.IsEmpty()); - TRAP(leaveCode, - rollBack1=testArray.AddTLC(&dg1234); - User::Leave(1234); - ); - TEST(rollBack1!=NULL); - TEST(leaveCode==1234); - TEST(testArray.IsEmpty()); - rollBack1=NULL; - CleanupStack::Check(markerCleanup); - __UHEAP_CHECK(KArrayMemUseBaseline); - - TRAP(leaveCode, errCode=testArray.Add(&dgBADF00D)); - TEST(errCode==KErrNone); - TEST(leaveCode==KErrNone); - rollBack1=NULL; - TRAP(leaveCode, - rollBack1=testArray.SwapTLC(&dgBADF00D_2); - User::Leave(1234); - ); - TEST(rollBack1!=NULL); - TEST(leaveCode==1234); - TEST(!testArray.IsEmpty()); - rollBack1=NULL; - TRAP(leaveCode, - rollBack1=testArray.RemoveTLC(dgBADF00D_2.Id()); - TEST(testArray.IsEmpty()); - User::Leave(1234); - ); - TEST(rollBack1!=NULL); - TEST(leaveCode==1234); - TEST(!testArray.IsEmpty()); - - - TRAP(leaveCode,errCode=testArray.Remove(dgBADF00D_2.Id())); - TEST(errCode==KErrNone); - TEST(leaveCode==KErrNone); - TEST(testArray.IsEmpty()); - rollBack1=NULL; - break; - // - case 3: - INFO_PRINTF1(_L("Sub test P3: AddLC/SwapLC: Cleanup item gets executed - doesn't leak")); - TEST(testArray.IsEmpty()); - TRAP(leaveCode, - testArray.AddLC(&dg1234); - User::Leave(1234); - ); - TEST(leaveCode==1234); - TEST(testArray.IsEmpty()); - rollBack1=NULL; - __UHEAP_CHECK(KArrayMemUseBaseline); //because it threw it didn't leak - - //use my new method to add the object to be swapped out so no leak - TRAP(leaveCode,errCode=testArray.Add(&dgBADF00D)); - TEST(errCode==KErrNone); - TEST(leaveCode==KErrNone); - __UHEAP_CHECK(KArrayMemUseBaseline); //new method doesn't leak. - rollBack1=NULL; - TRAP(leaveCode, - errCode=testArray.SwapLC(&dgBADF00D_2); - User::Leave(1234); - ); - TEST(errCode==KErrNone); - TEST(leaveCode==1234); - TEST(!testArray.IsEmpty()); - - TRAP(leaveCode,errCode=testArray.Remove(dgBADF00D_2.Id())); - TEST(errCode==KErrNone); - TEST(leaveCode==KErrNone); - TEST(testArray.IsEmpty()); - rollBack1=NULL; - break; - // - case 4: - - //I don't really care whether the individual calls succeed or fail, - //just whether it leaks overall, and that the error codes correspond to no-action - for (TInt faultRate=1;faultRate<5;faultRate++) - { - INFO_PRINTF2(_L("Sub test P4: Add/Swap: memory faulting %i"),faultRate); - __UHEAP_SETFAIL(RAllocator::EDeterministic,faultRate); - TInt err1=KErrNone; - rollBack1=NULL; - TRAP(leaveCode, - errCode=testArray.Add(&dg1234); - ) - err1=errCode; - __UHEAP_SETFAIL(RAllocator::ENone,0); - TRAP(leaveCode,errCode=testArray.Add(&dgBADF00D)); - __UHEAP_SETFAIL(RAllocator::EDeterministic,faultRate); - rollBack1=NULL; - TRAP(leaveCode, - errCode=testArray.Swap(&dgBADF00D_2); - ) - __UHEAP_SETFAIL(RAllocator::ENone,0); - //If the first Add fails then the object should not be removed - if (!err1) - { - TRAP(leaveCode,errCode=testArray.Remove(dg1234.Id())); - TEST(errCode==KErrNone); - TEST(leaveCode==KErrNone); - } - //If the swap fails, then the add still needs to be removed - //Note that it is the ID that matters here... dgBADF00D & dgBADF00D_2 have same id. - TRAP(leaveCode,errCode=testArray.Remove(dgBADF00D_2.Id())); - TEST(errCode==KErrNone); - TEST(leaveCode==KErrNone); - TEST(testArray.IsEmpty()); - ResetArray(testArray); - CleanupStack::Check(markerCleanup); - __UHEAP_CHECK(0); - } - break; - // - case 5: - - //I don't really care whether the individual calls succeed or fail, - //just whether it leaks overall, and that the error codes correspond to no-action - for (TInt faultRate=1;faultRate<5;faultRate++) - { - INFO_PRINTF2(_L("Sub test P5: AddTLC/SwapTLC: memory faulting %i"),faultRate); - __UHEAP_SETFAIL(RAllocator::EDeterministic,faultRate); - TInt err1=KErrNone,err2=KErrNone,err3=KErrNone; - rollBack1=NULL; - TRAP(leaveCode, - rollBack1=testArray.AddTLC(&dg1234); - CleanupStack::Check(rollBack1); - testArray.CommitP(rollBack1); - ) - err1=leaveCode; - __UHEAP_SETFAIL(RAllocator::ENone,0); - TRAP(leaveCode,errCode=testArray.Add(&dgBADF00D)); - __UHEAP_SETFAIL(RAllocator::EDeterministic,faultRate); - rollBack1=NULL; - TRAP(leaveCode, - rollBack1=testArray.SwapTLC(&dgBADF00D_2); - CleanupStack::Check(rollBack1); - testArray.CommitP(rollBack1); - ) - //If the first Add fails then the object should not be removed - if (!err1) - { - TRAP(leaveCode, - rollBack1=testArray.RemoveTLC(dg1234.Id()); - CleanupStack::Check(rollBack1); - testArray.CommitP(rollBack1); - ) - err2=leaveCode; - } - //If the swap fails, then the add still needs to be removed - //Note that it is the ID that matters here... dgBADF00D & dgBADF00D_2 have same id. - TRAP(leaveCode, - rollBack1=testArray.RemoveTLC(dgBADF00D_2.Id()); - CleanupStack::Check(rollBack1); - testArray.CommitP(rollBack1); - ) - err3=leaveCode; - - - __UHEAP_SETFAIL(RAllocator::ENone,0); - //If the Removes failed then the object should be removed again - if (err2) - { - TRAP(leaveCode,errCode=testArray.Remove(dg1234.Id())); - TEST(errCode==KErrNone); - TEST(leaveCode==KErrNone); - } - if (err3) - { - TRAP(leaveCode,errCode=testArray.Remove(dgBADF00D_2.Id())); - TEST(errCode==KErrNone); - TEST(leaveCode==KErrNone); - } - TEST(testArray.IsEmpty()); - ResetArray(testArray); - CleanupStack::Check(markerCleanup); - __UHEAP_CHECK(0); - } - - break; - // - case 6: - //this set does leak: - - INFO_PRINTF1(_L("Sub test P6: AddLC/SwapLC: Cleanup item gets popped - unfixable leaks")); - TEST(testArray.IsEmpty()); - TRAP(leaveCode, - testArray.AddLC(&dg1234); - CleanupStack::Pop(); - ); - TEST(leaveCode==KErrNone); - TEST(!testArray.IsEmpty()); - - CleanupStack::Check(markerCleanup); - __UHEAP_CHECK(KArrayMemUseBaseline+1); - - TRAP(leaveCode, - testArray.AddLC(&dgBADF00D); - CleanupStack::Pop(); - ) - TEST(leaveCode==KErrNone); - CleanupStack::Check(markerCleanup); - __UHEAP_CHECK(KArrayMemUseBaseline+2); - rollBack1=NULL; - TRAP(leaveCode, - errCode=testArray.SwapLC(&dgBADF00D_2); - CleanupStack::Pop(); - ); - TEST(errCode==KErrNone); - TEST(leaveCode==KErrNone); - TEST(!testArray.IsEmpty()); - TRAP(leaveCode,errCode=testArray.Remove(dg1234.Id())); - TEST(errCode==KErrNone); - TEST(leaveCode==KErrNone); - TRAP(leaveCode,errCode=testArray.Remove(dgBADF00D_2.Id())); - TEST(errCode==KErrNone); - TEST(leaveCode==KErrNone); - TEST(testArray.IsEmpty()); - rollBack1=NULL; - expectedLeakCount=3; - break; - // - case 7: - returnCode=EFalse; - break; - } - ResetArray(testArray); - CleanupStack::Check(markerCleanup); - __UHEAP_CHECK(expectedLeakCount); - __UHEAP_MARKENDC(expectedLeakCount); - if (expectedLeakCount!=0) - { //Ensure that the leaked items are no longer associated with this debug level. - //Note that __DbgSetAllocFail(FALSE,RAllocator::EReset,1) resets the debug level to 0, - //so levels can't be nested when using this call. - __UHEAP_MARK; - __UHEAP_TOTAL_RESET; - INFO_PRINTF2(_L("Anticipated %i leaks declassified"),expectedLeakCount); //can't get here if wrong - } - - CleanupStack::PopAndDestroy(markerCleanup); - ((CTWsGraphsStep*)iStep)->RecordTestResultL(); - return returnCode; - } - -/** - @param failcase index to test to perform - @param aWrappedParams represents inter-thread information when test is run on a private thread - if aWrappedParams is NULL then the test is running on the main thread. - @return true if there are higher-numbered fail cases. - - @SYMTestCaseID GRAPHICS-WSERV-NegAddSwapGDArray-0001 - @SYMDEF DEF093926 - - @SYMTestCaseDesc DEF093926: Check for stability of Add and Swap unwind methods in isolation, - specifically checking that bad inputs are rejected gracefully. - Note that this code is testing the functionality of a class internal to CWindowServer. - At present CWindowServer presents just a simple shim on this class, - but if that implementation of CWindowServer changes than this test will be redudant. - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions - - Add/Swap: no Cleanup item - no leaks after Remove the added items - AddTLC/SwapTLC: Cleanup item requires Commit - check for no leaks after Remove. - AddTLC/SwapTLC: Cleanup item gets executed by forced Leave - check for no leaks after. - AddTLC, SwapTLC in allocation failure scenarios. Add/Swap don't allocate anything! - obsoleted AddLC/SwapLC to ensure correct function when forced Leave - check for no leaks after - obsoleted AddLC/SwapLC to ensure correct function. These will always leak in good case. - Calls NegTestAddSwapGDArrayL. - case 1/2/3: Tests AddL, AddLC, AddTLC that a NULL input is rejected - case 4/5/6: Tests SwapL, SwapLC, SwapTLC that a NULL input is rejected - case 7/8/9: Tests AddL, AddLC, AddTLC that a repeat input is rejected - case 10/11/12: Tests SwapL, SwapLC, SwapTLC that a non-repeat input is rejected - @SYMTestExpectedResults - */ -TBool CTWsGraphs::NegTestAddSwapGDArrayL(TInt failcase,WrapTestCall*aWrappedParams) - { - ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-NegAddSwapGDArray-0001")); - _LIT(KCategory,"WsGraphicDrawer"); - if (!aWrappedParams) - { - INFO_PRINTF2(_L("NegTestAddSwapGDArrayL Negative sub test %i"),failcase); - }; - CWsGraphicDrawerArray testArray; - TGraphicDrawerId id1234= { 1234, EFalse }; - TGraphicDrawerId idBADF00D= { 0xBADF00D, EFalse }; - WsGraphicDrawer dg1234; - dg1234.ConstructL(id1234); - WsGraphicDrawer dgBADF00D; - dgBADF00D.ConstructL(idBADF00D); - WsGraphicDrawer dgBADF00D_2; - dgBADF00D_2.ConstructL(idBADF00D); - CWsGraphicDrawerArray::XRollBackBase* rollBack1=NULL; - TInt errCode=KErrAbort; - TInt leaveCode=KErrNone; - TBool returnMoreTests=ETrue; - DummyCleanup markerCleanup; - TBool mayPanic=EFalse; -#ifdef __WINS__ - mayPanic=ETrue; -#endif - - CleanupStack::PushL(markerCleanup); //This allows me to check the stack is clear! - __UHEAP_MARK; - - switch (failcase) - { - case 1: //NULL arg: expected result: returns KErrArgument - TRAP(leaveCode, - errCode=testArray.Add(NULL); - ) - TEST(leaveCode==KErrNone); - ReportNegativeResultfail(__LINE__,errCode,KErrArgument); - break; - case 2: //NULL arg: expected result: throws KErrArgument - TRAP(leaveCode, - rollBack1=testArray.AddTLC(NULL); - TEST(EFalse); //Should never get here! - ) - TEST(rollBack1==NULL); - ReportNegativeResultfail(__LINE__,leaveCode,KErrArgument); - break; - case 3: //NULL arg: expected result: debug: panic. In release doesn't return any information! - if (!aWrappedParams && mayPanic) - { - LaunchNegTestCall(failcase,EWsGraphicDrawerPanicBadArgument,KCategory); - } - else - { - TRAP(leaveCode, - testArray.AddLC(NULL); - User::Leave(1234); //Panics before here in debug. No leak if cleanup is taken. - ); - TEST(leaveCode==1234); //Panics before here in debug - } - break; - // - case 4: //NULL arg: expected result: returns KErrArgument - TRAP(leaveCode, - errCode=testArray.Swap(NULL) - ) - TEST(leaveCode==KErrNone); - ReportNegativeResultfail(__LINE__,errCode,KErrArgument); - break; - case 5: //expected result: throws KErrArgument - TRAP(leaveCode, - rollBack1=testArray.SwapTLC(NULL); - testArray.CommitP(rollBack1); - ) - TEST(rollBack1==NULL); - ReportNegativeResultfail(__LINE__,leaveCode,KErrArgument); - break; - case 6: //NULL arg: expected result: debug: panic. In release doesn't return any information! - if (!aWrappedParams && mayPanic) - { - LaunchNegTestCall(failcase,EWsGraphicDrawerPanicBadArgument,KCategory); - } - else - { - TRAP(leaveCode, - errCode=testArray.SwapLC(NULL); - User::Leave(1234); //Panics before here in debug. No leak if cleanup is taken. - ); - TEST(leaveCode==1234); //Panics before here in debug - TEST(errCode==KErrNotFound); - } - break; - // - case 7: //Add overwrites: expected result: returns KErrAlreadyExists - TRAP(leaveCode, - errCode=testArray.Add(&dg1234); - ) - TEST(errCode==KErrNone); - TEST(leaveCode==KErrNone); - TRAP(leaveCode, - errCode=testArray.Add(&dg1234); //oops! Already added! - ) - TEST(leaveCode==KErrNone); - ReportNegativeResultfail(__LINE__,errCode,KErrAlreadyExists); - break; - case 8: //Add overwrites: expected result: throws KErrAlreadyExists - TRAP(leaveCode, - errCode=testArray.Add(&dg1234); - ) - TEST(errCode==KErrNone); - TEST(leaveCode==KErrNone); - TRAP(leaveCode, - rollBack1=testArray.AddTLC(&dg1234); //oops! Already added! - testArray.CommitP(rollBack1); - ) - TEST(rollBack1==NULL); - ReportNegativeResultfail(__LINE__,leaveCode,KErrAlreadyExists); - break; - case 9: //Add overwrites: expected result: debug: does not panic, but throws KErrAlreadyExists. - TRAP(leaveCode, - errCode=testArray.Add(&dg1234); - ) - TEST(errCode==KErrNone); - TEST(leaveCode==KErrNone); - TRAP(leaveCode, - testArray.AddLC(&dg1234); //oops! Already added! Should leave. - User::Leave(1234); //Should leave before here! No leak if cleanup is taken. - ); - ReportNegativeResultfail(__LINE__,leaveCode,KErrAlreadyExists); - break; - // - case 10: //Swap empty slot: expected result: returns KErrNotFound - TRAP(leaveCode, - errCode=testArray.Swap(&dg1234) //oops! Nothing to swap with! - ) - TEST(leaveCode==KErrNone); - ReportNegativeResultfail(__LINE__,errCode,KErrNotFound); - break; - case 11: //Swap empty slot: expected result: throws KErrNotFound - TRAP(leaveCode, - rollBack1=testArray.SwapTLC(&dg1234); //oops! Nothing to swap with! - testArray.CommitP(rollBack1); - ) - TEST(rollBack1==NULL); - ReportNegativeResultfail(__LINE__,leaveCode,KErrNotFound); - break; - case 12: //Swap empty slot: expected result: debug: panic. In release doesn't return any information! - if (!aWrappedParams && mayPanic) - { - LaunchNegTestCall(failcase,EWsGraphicDrawerPanicBadArgument,KCategory); - } - else - { - TRAP(leaveCode, - errCode=testArray.SwapLC(&dg1234); //oops! Nothing to swap with! - User::Leave(1234); //Panics before here in debug. No leak if cleanup is taken. - ); - TEST(leaveCode==1234); //Panics before here in debug - TEST(errCode==KErrNotFound); //Panics before here in debug - } - break; - - // - default: - returnMoreTests=EFalse; - } - ResetArray(testArray); - CleanupStack::Check(markerCleanup); - __UHEAP_CHECK(0); - __UHEAP_MARKENDC(0); - testArray.Close(); -// CWsGraphicDrawerArray::testArrayValidator::ResetArray(&testArray); - CleanupStack::PopAndDestroy(markerCleanup); - return returnMoreTests; - } - -/** - @SYMTestCaseID GRAPHICS-WSERV-LeakInService-0001 - @SYMDEF DEF093926 - @SYMTestCaseDesc Check for leaks over repeated re-assignments. - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions - Repeatedly create the same bitmap instance - After a few initial wobbles in the server-side HeapCount it should not increase - 5 calls are made without checking the level, then 5 more check the level. - Note that as we are testing the main server heap, - other threads may interrupt and perform operations that change the memory figures. - - @SYMTestExpectedResults The CWsGraphicBitmap objects are created and no leaks are reported. - */ -void CTWsGraphs::DoTestLeakInServiceL() - { - INFO_PRINTF1(_L("DoTestLeakInServiceL")); - const TInt prepCount=5; - const TInt testCount=5; - - - TUid uid1 = {0x10000001}; - TUid uid2 = {0x10000002}; - - TWsGraphicId twsGraphicId1(uid1); - TEST(twsGraphicId1.Uid()==uid1); - - TWsGraphicId twsGraphicId2(uid2); - TEST(twsGraphicId2.Uid()==uid2); - - TWsGraphicId twsGraphicId3(twsGraphicId2); - TEST(twsGraphicId3.Uid()==uid2); - - TWsGraphicId twsGraphicId4(1); - twsGraphicId4.Set(uid1); - TEST(twsGraphicId4.Uid()==uid1); - - TSize screenSize = TheClient->iScreen->SizeInPixels(); - - __UHEAP_RESET; - __UHEAP_MARK; - // Create local shared CWsGraphicBitmap - // Repeat operation for any sign of memory leak... - CFbsBitmap bitmap2; - CFbsBitmap mask2; - - bitmap2.Create(screenSize,TheClient->iScreen->DisplayMode()); - mask2.Create(bitmap2.SizeInPixels(),TheClient->iScreen->DisplayMode()); - - TInt c0=TheClient->iWs.HeapCount(); - CWsGraphicBitmap* bTestX = CWsGraphicBitmap::NewL(twsGraphicId2.Uid(), &bitmap2,&mask2); - for (TInt i=0;iiWs.HeapCount(); - delete bTestX; - //TInt c3=TheClient->iWs.HeapCount(); - bTestX = CWsGraphicBitmap::NewL(twsGraphicId2.Uid(), &bitmap2,&mask2); - //TInt c4=TheClient->iWs.HeapCount(); - } - // Give WSERV a chance to settle. - TheClient->iWs.Finish(); - User::After (1000000); //1s - - TInt c1=TheClient->iWs.HeapCount(); - TInt failures=0; - for (TInt i=0;iiWs.HeapCount(); - delete bTestX; - //TInt c3=TheClient->iWs.HeapCount(); - //The heap count doesn't go down after delete operation - //because the delete message is buffered by the server, because it does not have a return value. - //Aparrently, although CWsGraphicBitmap and TheClient terminate at the same server, - //and use the same general heap (I have tested this under debug), - //they do not share the same session, so flushing TheClient does not effect CWsGraphicBitmap - bTestX = CWsGraphicBitmap::NewL(twsGraphicId2.Uid(), &bitmap2,&mask2); - - // Give WSERV a chance to settle. - TheClient->iWs.Finish(); - User::After (1000000); //1s - - TInt c4=TheClient->iWs.HeapCount(); - //Can compare immediately after allocation as the server doesn't buffer the create command. - if (!(c2==c4)) - { - if (c4 > c2) // only fail the test if the count has increased - { - failures++; - } - INFO_PRINTF2(_L("Server Heap count change accross delete/new = %i"),c4-c2); - } - } - // Outside of main loop to avoid client/wserv interaction during test. - TEST(failures==0); - TInt c5=TheClient->iWs.HeapCount(); - TEST((c1-c5)/testCount==0); //If every call leaked. - if ((c1-c5)/testCount) - { - INFO_PRINTF3(_L("Server Heap count change accross %i delete/new cycles = %i"),testCount,c5-c1); - INFO_PRINTF3(_L("Before %i / After %i"),c1,c5); - } - - delete bTestX; - - __UHEAP_CHECK(0); - __UHEAP_MARKEND; - - } -/** - @SYMTestCaseID GRAPHICS-WSERV-0381 - @SYMDEF DEF095063 - @SYMTestCaseDesc Test case for INC098114 CWsGraphicDrawer::SendMessage panics window server - @SYMTestPriority Medium - @SYMTestStatus Implemented - @SYMTestActions Enable the test flag and reproduce the defect - Action step: - -Instruct plugin to register event handler - -Draw fullscreen window (plugin will receive window visibility changed event) - -Set the test flag - -Query visibility region from plugin side - -Instruct plugin to unregister event handler - -Destroy fullscreen window (plugin will not receive window visibility changed event) - - @SYMTestExpectedResults wserv should not panic with the fix -*/ - -TestState CTWsGraphs::TestSuccessiveMessageL() - { - if (iSubState==0) - { - _LIT(KTestSuccessiveMessage, "TestSuccessiveMessage"); - INFO_PRINTF1(KTestSuccessiveMessage); - - ++iSubState; - iListen->Enable(ETrue); - CreateWindowL(); - Mem::FillZ(&iListenInfo, sizeof(TListenerInfo)); - //Set the test flag to enable the reproduction of defect - iListen->SetTestFlag(); - iListen->QueryPlugin(iListenInfo); - iListen->Enable(EFalse); - DestroyWindowL(); - return EWait; - } - - ++(iTest->iState); - iSubState = 0; - return ENext; - } - -TestState CTWsGraphs::TestWindowGroupChangeL() - { - if (iSubState==0) - { - _LIT(KTestWindowGroupChange, "TestWindowGroupChange"); - INFO_PRINTF1(KTestWindowGroupChange); - - ++iSubState; - iListen->Enable(ETrue); - CreateWindowL(); - Mem::FillZ(&iListenInfo, sizeof(TListenerInfo)); - iListen->QueryPlugin(iListenInfo); - return EWait; - } - - if (iSubState==1) - { - ++iSubState; - iOriginalWindowGroupId = iListenInfo.iWindowGroupId; - iNewWin = CCrWin::NewL(iTest->iScreenNumber, ETrue); - iListen->QueryPlugin(iListenInfo); - return EWait; - } - - TEST(iListenInfo.iWindowGroupId != iOriginalWindowGroupId); - - delete iNewWin; - iNewWin = NULL; - iListen->Enable(EFalse); - DestroyWindowL(); - ++(iTest->iState); - iSubState = 0; - return ENext; - } - -/** - @SYMTestCaseID GRAPHICS-WSERV-0382 - @SYMDEF INC085451 - @SYMTestCaseDesc Test Animation frame rate - @SYMTestPriority Medium - @SYMTestStatus Implemented - @SYMTestActions Simulate an Animation artwork by calling DrawWsGraphic and DoDraw. - Action step: - -Calls DrawWsGraphic for two different animations with different frame rates - -Retrieve the frame count for two differnt frames per seconds - -Test the two frame rate shouldn't be same. - - @SYMTestExpectedResults Animation Frame rate should be different for different frames per second -*/ -TestState CTWsGraphs::TestFrameRateL() - { - //Check for Transparency enabled in wsini.ini - if (TransparencySupportedL()==KErrNotSupported) - { - ++(iTest->iState); - return ENext; - } - - // flush transparent window destruction created in TransparencySupportedL before - // proceeding with the test - TheClient->iWs.Flush(); - - //Here iSubState is 0, when this functions executes first time - // iSubState is 1 means the call is from a callback function. - if(iSubState == 0) - { - _LIT(KTestFrameRate, "TestFrameRate"); - INFO_PRINTF1(KTestFrameRate); - - ++iSubState; - iTestframerate = CGraphicTestFrameRate::NewL(iTest->iScreenNumber); - - //Set the callback function - iTestframerate->SetCallBack(TCallBack(CTWsGraphs::PluginCallBack,this)); - - //Create the window and call the graphic animation - CreateWindowL(EFalse); - iWin->DrawGraphic(iTestframerate->Id().Id()); - return EWait; - } - - //PeterI wait a while for animations to redraw then query the plugin - User::After(2000000); - TheClient->iWs.Flush(); - TheClient->WaitForRedrawsToFinish(); - TheClient->iWs.Finish(); - - //Invoke the plug-in and get the counter value - Mem::FillZ(&iAnimCount, sizeof(TAnimRate)); - - iTestframerate->QueryPlugin(iAnimCount); - TheClient->iWs.Flush(); - TheClient->WaitForRedrawsToFinish(); - TheClient->iWs.Finish(); - - //Compare and test the total frame rate for two different frame counts.... - TEST((iAnimCount.iAnim1>0 && iAnimCount.iAnim2>0) && iAnimCount.iAnim1 !=iAnimCount.iAnim2); - if(iSubState == 1) - { - DestroyWindowL(); - delete iTestframerate; - } - ++(iTest->iState); - iSubState = 0; - return ENext; - } - -/** - @SYMTestCaseID GRAPHICS-WSERV-0438 - @SYMDEF INC103472 - @SYMTestCaseDesc CRedrawRegion::ContainsDrawers does not look for all drawers - @SYMTestPriority Medium - @SYMTestStatus Implemented - @SYMTestActions Create ECom-plugins to enable the scenario, in which there is one simple and one container drawer. - In the container drawer, two other simple drawers are enabled. Each drawer draws a coloured ellipse. - In this case, when the contained drawer is requested to change the colour of the ellipse, the screen will not be updated - without the fix. - Action step: - -Create four CRP graphics. - -Call the simple drawer and container drawer to draw ellipses. The container drawer - also enables two other simple drawers to draw ellipses in different colors. - -Update the color of each ellipse in turn. - -Check that the screen display is as required. - @SYMTestExpectedResults The colour of each ellipse residing in the drawers is successfully updated. Those for the contained drawers wont be updated without the fix. -*/ -void CTWsGraphs::TestNestedDrawerCRP() - { - _LIT(KTestContainDrawer, "Test INC103472: A Contained Drawer"); - INFO_PRINTF1(KTestContainDrawer); - - RWindow window1(TheClient->iWs); - CleanupClosePushL(window1); - User::LeaveIfError(window1.Construct(*TheClient->iGroup->GroupWin(), ENullWsHandle)); - - window1.EnableRedrawStore(ETrue); // Force to enable the redraw storing - window1.SetRequiredDisplayMode(EColor256); // Do not set window size here to avoid hardware test failure - window1.SetBackgroundColor(KRgbDarkGreen); - window1.Activate(); - - // A simple graphic - CWsSimpleGraphicBitmap* wsGraphic1 = CWsSimpleGraphicBitmap::NewL(KSimpleDrawerInterfaceId); - CleanupStack::PushL(wsGraphic1); - // A container graphic - CWsContainGraphicBitmap* wsGraphic2 = CWsContainGraphicBitmap::NewL(KContainDrawerInterfaceId); - CleanupStack::PushL(wsGraphic2); - // A contained graphic residing in the container graphic wsGraphic2 - CWsSimpleGraphicBitmap* wsGraphic3 = CWsInvisibleGraphicBitmap1::NewL(KInvisibleDrawerInterfaceId1); - CleanupStack::PushL(wsGraphic3); - // A contained graphic residing in the container graphic wsGraphic2 - CWsSimpleGraphicBitmap* wsGraphic4 = CWsInvisibleGraphicBitmap2::NewL(KInvisibleDrawerInterfaceId2); - CleanupStack::PushL(wsGraphic4); - - window1.Invalidate(); - window1.BeginRedraw(); - TheClient->iGc->Activate(window1); - TheClient->iGc->Clear(); - // Call CRP drawer to draw the coloured ellipses - TheClient->iGc->DrawWsGraphic(wsGraphic1->Id(),TRect(TPoint(20,20),TSize(300,100))); - TheClient->iGc->DrawWsGraphic(wsGraphic2->Id(),TRect(TPoint(20,100),TSize(300,100))); - - TheClient->iGc->Deactivate(); - window1.EndRedraw(); - TheClient->Flush(); - - // Update the colour of four ellipses residing in four CRP drawers. - TInt err = wsGraphic1->UpdateColor(KRgbRed); - TEST(KErrNone == err); - err = wsGraphic2->UpdateColor(KRgbDarkBlue); - TEST(KErrNone == err); - // If the fix is not inserted, the colour of the third and fourth ellipses residing in the contained drawers wont be updated - err = wsGraphic3->UpdateColor(KRgbDarkMagenta); - TEST(KErrNone == err); - err = wsGraphic4->UpdateColor(KRgbDarkCyan); //won't change the displayed color if there is a right place for flush() - TEST(KErrNone == err); - - TheClient->Flush(); - // Force some delays to wait until the color change - User::After(2000000); - // Test whether the screen content is changed as required - CheckResult(); - CleanupStack::PopAndDestroy(5,&window1); - } - -// Check the screen display with the reference bitmap to ensure the color to be updated correctly -void CTWsGraphs::CheckResult() - { - TSize size = TSize(320,200);//The maximum size of the screen content we are looking at - - // Create a reference bitmap - CFbsBitmap* bitmapRef = new(ELeave) CFbsBitmap; - CleanupStack::PushL(bitmapRef); - User::LeaveIfError(bitmapRef->Create(size, EColor256)); - CFbsBitGc* gc; - CFbsBitmapDevice* bitmapDev = CFbsBitmapDevice::NewL(bitmapRef); - TEST(bitmapDev!=NULL); - CleanupStack::PushL(bitmapDev); - User::LeaveIfError(bitmapDev->CreateContext(gc)); - CleanupStack::PushL(gc); - gc->SetBrushStyle(CGraphicsContext::ESolidBrush); - gc->SetBrushColor(KRgbDarkGreen); - gc->Clear(TRect(TPoint(0,0), size));//background dark green - gc->SetBrushStyle(CGraphicsContext::ESolidBrush); - gc->SetBrushColor(KRgbRed); - gc->DrawEllipse(TRect(TPoint(20,20),TSize(300,100))); //map to the simple drawer - gc->SetBrushStyle(CGraphicsContext::ESolidBrush); - gc->SetBrushColor(KRgbDarkBlue); - gc->DrawEllipse(TRect(TPoint(20,100),TSize(300,100))); //map to the container drawer - gc->SetBrushStyle(CGraphicsContext::ESolidBrush); - gc->SetBrushColor(KRgbDarkMagenta); - gc->DrawEllipse(TRect(TPoint(100,150),TSize(50,50))); //map to the contained drawer - gc->SetBrushStyle(CGraphicsContext::ESolidBrush); - gc->SetBrushColor(KRgbDarkCyan); - gc->DrawEllipse(TRect(TPoint(200,150),TSize(50,50))); //map to the contained drawer - TInt bitmapHeight = bitmapRef->SizeInPixels().iHeight; - TInt bitmapWidth = bitmapRef->SizeInPixels().iWidth; - - // Copy the screen content to bitmap - INFO_PRINTF1(_L("Capture screen content.")); - CFbsBitmap* screenBitmap = new(ELeave) CFbsBitmap(); - CleanupStack::PushL(screenBitmap); - User::LeaveIfError(screenBitmap->Create(size, TheClient->iScreen->DisplayMode())); - TRect rct = TRect(TPoint(0,0), size); - User::LeaveIfError(TheClient->iScreen->CopyScreenToBitmap(screenBitmap,rct)); - - // Compare the displayed bitmap against the reference one - INFO_PRINTF1(_L("Compare the displayed bitmap against the expected one.")); - TInt lineLength=bitmapRef->ScanLineLength(bitmapWidth, EColor256); - HBufC8* compareLineBuf=HBufC8::NewLC(lineLength); - TPtr8 compareLinePtr(compareLineBuf->Des()); - HBufC8* screenLineBuf=HBufC8::NewLC(lineLength); - TPtr8 screenLinePtr(screenLineBuf->Des()); - for (TInt index=0; indexGetScanLine(compareLinePtr, TPoint(0,index), bitmapWidth, EColor256); - screenBitmap->GetScanLine(screenLinePtr, TPoint(0,index),bitmapWidth, EColor256); - TInt compareResult=compareLinePtr.Compare(screenLinePtr); - if (compareResult!=0) - { - INFO_PRINTF2(_L("Scanline compare failed: %d"),index); - TEST(EFalse); - break; - } - } - CleanupStack::PopAndDestroy(6,bitmapRef); - - } - -void ResetScreenMode(TAny* aAny) - { - CWsScreenDevice* screen=static_cast(aAny); - screen->SetScreenMode(0); - screen->SetAppScreenMode(0); - } - -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - -void CTWsGraphs::TestScreenModeChangeL() - { - _LIT(KLog,"Screen Doesn't match bitmap. Size=(%d,%d) winSizeMode=%d redrawMode=%d modeIndex=%d"); -// A simple CRP graphic to draw in the test - CWsSimpleGraphicBitmap* wsGraphic1=CWsSimpleGraphicBitmap::NewL(KSimpleDrawerInterfaceId); - CleanupStack::PushL(wsGraphic1); - RWindow testWin(TheClient->iWs); - CleanupClosePushL(testWin); - User::LeaveIfError(testWin.Construct(*TheClient->iGroup->GroupWin(),0xbadbad)); - testWin.SetRequiredDisplayMode(EColor64K); - testWin.Activate(); -// Cleanup display mode by setting back to 0 if we leave in the tests - CleanupStack::PushL(TCleanupItem(ResetScreenMode,TheClient->iScreen)); - TInt numScreenModes=TheClient->iScreenModes.Count(); - TBool match; - - for(TInt winSizeMode=0;winSizeMode<2;winSizeMode++) - { // Two size modes, fullScreen and non-full screen - for(TInt redrawMode=0;redrawMode<2;redrawMode++) - { // Two redraw modes to test drawing inside and outside of a redraw. - const TBool drawInsideRedraw=(redrawMode==0); - for(TInt modeIndex=0;modeIndexiScreenModes[modeIndex]; - const TPoint origin=TheClient->iScreen->GetScreenModeScaledOrigin(screenMode); - if (origin.iX!=0 || origin.iY!=0) - continue; - // Enable redirection before changing screen mode as this is what we are testing - iRedir->Redirect(CWsRedir::EFrontBuffer, ETrue); - TheClient->iScreen->SetAppScreenMode(screenMode); - TheClient->iScreen->SetScreenMode(screenMode); - - TPixelsAndRotation sizeAndRotation; - TheClient->iScreen->GetDefaultScreenSizeAndRotation(sizeAndRotation); -// - TSize screenSize(TheClient->iScreen->SizeInPixels()); - if(sizeAndRotation.iRotation == CFbsBitGc::EGraphicsOrientationRotated90 || - sizeAndRotation.iRotation == CFbsBitGc::EGraphicsOrientationRotated270) - { - screenSize.iWidth = Min(screenSize.iWidth, 240);//to make sure we won't exceed physical screen size - } - TSize winSize(screenSize); - TPoint winPos; - if (winSizeMode==1) - { - winSize.iWidth=winSize.iWidth*2/3; - winSize.iHeight=winSize.iHeight*3/4; - winPos.iX=(screenSize.iWidth-winSize.iWidth)/4; - winPos.iY=(screenSize.iHeight-winSize.iHeight)*3/4; - } - testWin.SetExtent(winPos,winSize); - TSize halfSize(winSize.iWidth/2,winSize.iHeight); - TRect leftHalf(halfSize); - TRect rightHalf(TPoint(halfSize.iWidth,0),halfSize); - TRect leftEllipse(leftHalf); - leftEllipse.Shrink(4,4); - TRect rightEllipse(rightHalf); - rightEllipse.Shrink(4,4); - // Draw half the screen with redirection on, should only go to redirection test bitmap - // Then draw again with redirection off, this time should go to the screen - // The two steps are drawn with the color of the left/right rectangles swapped. - for(TInt drawStep=0;drawStep<2;drawStep++) - { - TRgb leftColor; - TRgb rightColor; - if (drawStep==0) - { - leftColor=KRgbGreen; - rightColor=KRgbRed; - } - else - { // Turn re-direction off for second time around loop - iRedir->Redirect(CWsRedir::EFrontBuffer, EFalse); - leftColor=KRgbRed; - rightColor=KRgbGreen; - } - testWin.Invalidate(); - testWin.BeginRedraw(); - if (!drawInsideRedraw) - testWin.EndRedraw(); - CWindowGc* testWinGc=TheClient->iGc; - testWinGc->Activate(testWin); - testWinGc->SetBrushColor(leftColor); - testWinGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - testWinGc->DrawRect(leftHalf); - // Call CRP drawer to draw the coloured ellipses - TheClient->iGc->DrawWsGraphic(wsGraphic1->Id(),leftEllipse); - testWinGc->SetBrushColor(rightColor); - testWinGc->DrawRect(rightHalf); - TheClient->iGc->DrawWsGraphic(wsGraphic1->Id(),rightEllipse); - testWinGc->Deactivate(); - if (drawInsideRedraw) - testWin.EndRedraw(); - TheClient->iWs.Flush(); - } - // We now check that the left rect of the re-directed drawing matches the right half - // of the on-screen drawing - CFbsBitmap* screenCopy=new(ELeave) CFbsBitmap; - CleanupStack::PushL(screenCopy); - User::LeaveIfError(screenCopy->Create(screenSize, EColor64K)); - TheClient->iScreen->CopyScreenToBitmap(screenCopy); - match=CompareBitmapArea16Bpp(iFrontCopy,winPos,screenCopy,TPoint(winPos.iX+rightHalf.iTl.iX,winPos.iY),halfSize); - TEST(match); - if (!match) - LOG_MESSAGE6(KLog,screenSize.iWidth,screenSize.iHeight,winSizeMode,redrawMode,modeIndex); - // As a double check also check the right half of the off-screen drawing matches the - // on-screen left half. - match=CompareBitmapArea16Bpp(iFrontCopy,TPoint(winPos.iX+rightHalf.iTl.iX,winPos.iY),screenCopy,winPos,halfSize); - TEST(match); - if (!match) - LOG_MESSAGE6(KLog,screenSize.iWidth,screenSize.iHeight,winSizeMode,redrawMode,modeIndex); - CleanupStack::PopAndDestroy(screenCopy); - } - } - } - CleanupStack::PopAndDestroy(3,wsGraphic1); - - TEST(iNotify1->iResult); - if(iNotify1->iResult==EFalse) - { - INFO_PRINTF1(iNotify1->iError); - } - TEST(iNotify2->iResult); - if(iNotify1->iResult==EFalse) - { - INFO_PRINTF1(iNotify2->iError); - } - } - -#endif // TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - -/** -@SYMTestCaseID GRAPHICS-WSERV-0443 - -@SYMDEF INC109263 - -@SYMTestCaseDesc TWindowServerEvent::NotifyDrawer can refer to a deleted array index causing a crash - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Cause an event that will generate the following behaviour through TWindowServerEvent::NotifyDrawer() - - The for loop performs the following: - 0) Drawer handler 1: Remove handle 1 ; Drawer handler 2: Do nothing - 1) Drawer handler 1: Remove handle 1,Add handle 1 ; Drawer handler 2: Do nothing - 2) Drawer handler 1: Add handle 1 ; Drawer handler 2: Do nothing - 3) Drawer handler 1: Remove handle 2 ; Drawer handler 2: Do nothing - 4) Drawer handler 1: Remove handle 2,Add handle 2 ; Drawer handler 2: Do nothing - 5) Drawer handler 1: Add handle 2 ; Drawer handler 2: Do nothing - 6) Drawer handler 1: Remove handle 1,Remove handle 2 ; Drawer handler 2: Do nothing - - Repeat with handlers 1 and 2 swapped - -@SYMTestExpectedResults Loops through TWindowServerEvent::NotifyDrawer() should complete without crashing wserv -*/ - -void CTWsGraphs::TestNotifyRemoval() - { - _LIT(KTestEventNotification, "TestDrawerEventHandler"); - INFO_PRINTF1(KTestEventNotification); - ++iSubState; - - for (TInt ii = 0; iiSetBehaviour(ii); //Enable this plugin and set it to an event handling method - iNotify2->SetBehaviour(KNotifyDoNothing); //Add a second drawer handler which is enabled but does nothing - CreateWindowL(); //Change visibility activating the event handlers - Fails if wserv crashes! - iNotify1->SetBehaviour(KNotifyDisable); //Disable plugin if still enabled - iNotify2->SetBehaviour(KNotifyDisable); //Disable plugin if still enabled - DestroyWindowL(); - } - INFO_PRINTF1(_L("Swap handlers")); - for (TInt ii = 0; iiSetBehaviour(KNotifyDoNothing); //Add a first drawer handler which is enabled but does nothing - iNotify1->SetBehaviour(ii); //Enable this plugin and set it to an event handling method - CreateWindowL(); //Change visibility activating the event handlers - Fails if wserv crashes! - iNotify2->SetBehaviour(KNotifyDisable); //Disable plugin if still enabled - iNotify1->SetBehaviour(KNotifyDisable); //Disable plugin if still enabled - DestroyWindowL(); - } - - TEST(ETrue); // If the test has failed WServ will have paniced. - } - -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA -/** -@SYMTestCaseID GRAPHICS-WSERV-0491 -@SYMPREQ PREQ39 -@SYMTestPriority High -@SYMTestCaseDesc Draw using a ECom-plugin which has direct access to the screen/OSB buffer -@SYMTestActions Create the plugin - Draw using the plugin - Update the position of the white line to line 70 and test - Update the position of the white line to line 80 and test -@SYMTestExpectedResults White lines are drawn on the correct positions. -*/ -void CTWsGraphs::TestMWsUiBufferL() - { - const TInt KWhiteLinePos = 70; - const TRect KBlueRect(TPoint(50,50),TSize(100,100)); - - // Construct and setup window to be drawn to - RWindow window1 = RWindow(TheClient->iWs); - CleanupClosePushL(window1); - User::LeaveIfError(window1.Construct(*TheClient->iGroup->GroupWin(),ENullWsHandle)); - TSize winSize=TSize(TheClient->iScreen->SizeInPixels()); - window1.SetExtent(TPoint(0,0),winSize); - window1.Activate(); - - CWsBufferGraphic* graphic = CWsBufferGraphic::NewL(); - CleanupStack::PushL(graphic); - - // Draw inital drawing with a Crp which is blue rect and a white line at line 0 - TheGc->Activate(window1); - TheGc->Clear(); - window1.BeginRedraw(); - TheGc->DrawWsGraphic(graphic->Id(),KBlueRect); - window1.EndRedraw(); - TheGc->Deactivate(); - - TheClient->iWs.Finish(); - User::After(2000000); - - // Update the position of the white line to line 70 - INFO_PRINTF1(_L("Update position of white line to line 70")); - graphic->UpdateWhiteLinePos(KWhiteLinePos); - TheClient->iWs.Finish(); - // Force some delays to wait until the line position changes - User::After(2000000); - //Test white line has been drawn and is in the correct postion - TBool res1 = IsWhiteLine(KWhiteLinePos); - TEST(res1); - - // Update the position of the white line to line 80 - INFO_PRINTF1(_L("Update position of white line to line 80")); - graphic->UpdateWhiteLinePos(KWhiteLinePos+10); - TheClient->iWs.Finish(); - // Force some delays to wait until the line position changes - User::After(2000000); - // Test white line has been drawn and is in the correct postion - TBool res2 = IsWhiteLine(KWhiteLinePos+10); - TEST(res2); - - graphic->Destroy(); - CleanupStack::PopAndDestroy(2, &window1); - } - -// Test whether a line is completely white -TBool CTWsGraphs::IsWhiteLine(TInt aWhiteLinePos) - { - TRgb color; - TPoint pixel; - - for(TInt xPos = 0; xPos < TheClient->iScreen->SizeInPixels().iWidth; xPos++) - { - pixel = TPoint(xPos,aWhiteLinePos); - TheClient->iScreen->GetPixel(color,pixel); - if(color.Red() != 255 && color.Blue() != 255 && color.Green() != 255) - { - return EFalse; - } - } - return ETrue; - } -#endif //TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA - -/** - DoTestL() method, called by the WSERV Test Framework. -*/ -void CTWsGraphs::RunTestCaseL(TInt /*aCurTestCase*/) - { - _LIT(KTest1,"DoTestWsGraphics"); - _LIT(KTest2,"DoTestOOMWsGraphics"); - _LIT(KTest3,"Interface Extension"); - _LIT(KTest4,"Screen Redirection"); - _LIT(KTest5,"TextCursor1"); - _LIT(KTest6,"TextCursor2"); - _LIT(KTest7,"Flicker Redirection"); - _LIT(KTest8,"Event Notification"); - _LIT(KTest9,"Successive Message"); - _LIT(KTest10,"Redirection Using WsBackBuffer"); - _LIT(KTest11,"Group Change"); - _LIT(KTest12,"Frame Rate"); - _LIT(KTest13,"Leak In Service"); - _LIT(KTest14,"Add/Swap GDArray"); - _LIT(KTest15,"Nested Drawer CRP"); - _LIT(KTest16,"Notify Removal"); - _LIT(KTest17,"Screen Mode Change"); - _LIT(KTest18,"UI Buffer"); - _LIT(KTest19,"Graphics Drawer Coverage"); - CFbsBitmap bitmap1; - CFbsBitmap mask1; - CWsGraphicBitmap* bTest=NULL; - TSize screenSize=TheClient->iScreen->SizeInPixels(); - - bitmap1.Create(screenSize,TheClient->iScreen->DisplayMode()); - mask1.Create(screenSize,TheClient->iScreen->DisplayMode()); - ((CTWsGraphsStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); - - switch(++iTest->iState) - { - case 1: -/** - @SYMTestCaseID GRAPHICS-WSERV-0528 -*/ - ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0528")); - // Launch new process with PROTSERV capability to run CWSGraphics tests in - iTest->LogSubTest(KTest1); - // This process only launches succesfully when _DEBUG is defined for the build, because it depends - // on the existance of debug macros such as _UHEAP_MARK, _UHEAP_MARKEND, _UHEAP_FAILNEXT, ... etc - LaunchNewProcess(KTestExe); - break; - case 2: - { - /** - @SYMTestCaseID GRAPHICS-WSERV-0017 - - @SYMPREQ PREQ1246 - - @SYMDEF DEF081259 - - @SYMTestCaseDesc Out of memery test when creating a CWsGraphic. - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions Out of memory test when creating a CWsGraphic. - - @SYMTestExpectedResults Whenever an API call fails, it should leave the number - of allocated heap cells unchanged. - */ - ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0017")); - - iTest->LogSubTest(KTest2); - TInt failRate; - for(failRate=1;;failRate++) - { - __UHEAP_RESET; - __UHEAP_SETFAIL(RHeap::EDeterministic,failRate); - __UHEAP_MARK; - - TRAPD(ret,bTest=CWsGraphicBitmap::NewL(&bitmap1,&mask1)); - TEST((ret==KErrNone || ret==KErrNoMemory)); - if (ret!=KErrNone && ret!=KErrNoMemory) - { - _LIT(KLog,"Failed to create CWsGraphicBitmap error=%d"); - LOG_MESSAGE2(KLog,ret); - } - if (ret!=KErrNone) - { - __UHEAP_MARKEND; - } - else - { - TEST(bTest!=NULL); - if (bTest==NULL) - { - _LIT(KLog,"Object creation didn't leave but returned NULL"); - LOG_MESSAGE(KLog); - } - delete bTest; - bTest=NULL; - __UHEAP_MARKEND; - TLogMessageText logMessageText; - _LIT(KSet,"OOM test succeds after %d allocations."); - logMessageText.Format(KSet,failRate); - LOG_MESSAGE(logMessageText); - break; - } - } - __UHEAP_RESET; - } - break; - case 3: - iTest->LogSubTest(KTest3); - ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0371")); -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - - if (TestInterfaceExtensionL()==EWait) - --iTest->iState; -#endif - break; - case 4: - iTest->LogSubTest(KTest4); - ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0372")); -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - if (TestScreenRedirectionL()==EWait) - --iTest->iState; -#endif - break; - case 5: - iTest->LogSubTest(KTest5); - ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0363")); -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - if (TestTextCursorUnderRedirectionL(ETestStandardTextCursor) == EWait) - --iTest->iState; -#endif - break; - case 6: - iTest->LogSubTest(KTest6); - ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0363")); -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - if (TestTextCursorUnderRedirectionL(ETestCustomTextCursor) == EWait) - --iTest->iState; -#endif - break; - case 7: - iTest->LogSubTest(KTest7); - ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0376")); -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - if (TestFlickerRedirectionL()==EWait) - --iTest->iState; -#endif - break; - case 8: - ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0378")); - iTest->LogSubTest(KTest8); - if (TestEventNotificationL()==EWait) - --iTest->iState; - break; - case 9: - ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0381")); - iTest->LogSubTest(KTest9); - if (TestSuccessiveMessageL()==EWait) - --iTest->iState; - break; - case 10: - iTest->LogSubTest(KTest10); - ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0527")); -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - if(TestRedirectionUsingWsBackBufferL()==EWait) - --iTest->iState; -#endif - break; - case 11: -/** - @SYMTestCaseID GRAPHICS-WSERV-0529 -*/ - ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0529")); - iTest->LogSubTest(KTest11); - if(TestWindowGroupChangeL()==EWait) - --iTest->iState; - break; - case 12: - ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0382")); - iTest->LogSubTest(KTest12); - if(TestFrameRateL()==EWait) - --iTest->iState; - break; - case 13: - ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-LeakInService-0001")); - iTest->LogSubTest(KTest13); - DoTestLeakInServiceL(); - break; - case 14: - ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-NegAddSwapGDArray-0001")); - iTest->LogSubTest(KTest14); - TestAddSwapGDArrayL(); - break; - case 15: - ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0438")); - iTest->LogSubTest(KTest15); - TestNestedDrawerCRP(); - break; - case 16: - ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0443")); - iTest->LogSubTest(KTest16); - TestNotifyRemoval(); - break; - case 17: - iTest->LogSubTest(KTest17); - ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0530")); -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA -/** - @SYMTestCaseID GRAPHICS-WSERV-0530 -*/ - - TestScreenModeChangeL(); -#endif - break; - case 18: - iTest->LogSubTest(KTest18); - ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0491")); -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA - - TestMWsUiBufferL(); -#endif - break; - case 19: - iTest->LogSubTest(KTest19); -/** - @SYMTestCaseID GRAPHICS-WSERV-0531 -*/ - ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0531")); - TestGraphicDrawerCoverage(); - break; - default: - ((CTWsGraphsStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - ((CTWsGraphsStep*)iStep)->CloseTMSGraphicsStep(); - TestComplete(); - break; - } - ((CTWsGraphsStep*)iStep)->RecordTestResultL(); - } - -__WS_CONSTRUCT_STEP__(WsGraphs) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/TWSGRAPHS.H --- a/windowing/windowserver/tauto/TWSGRAPHS.H Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,172 +0,0 @@ - -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef __TWSGRAPHS_H__ -#define __TWSGRAPHS_H__ - -#include -#include -#include "../tlib/testbase.h" -#include "AUTO.H" -#include "W32STDGRAPHIC.H" -#include "wsredir.h" -#include "wslisten.h" -#include "TGraphicsHarness.h" -#include "wsframerate.h" -#include "wscontaindrawer.h" -#include "wssimpledrawer.h" -#include "listener.h" -#include "wsgdcov.h" - -// -class CCrWin: public CBase - { -public: - static CCrWin* NewL(TInt aScreenId,TBool aDraw=ETrue); - ~CCrWin(); - void DrawFirstHalf(); - void DrawSecondHalf(); - void DrawGraphic(TInt aWsId=0); - void SetTextCursor(const TPoint &aPos, const TTextCursor &aCursor); - void CancelTextCursor(); -private: - void ConstructL(TInt aScreenId,TBool aDraw); - void Draw(); -private: - RWsSession iWs; - CWsScreenDevice* iScr; - RWindowGroup iGroup; - RWindow iWin; - CWindowGc* iGc; - }; - -class CCrAlphaWin: public CBase - { -public: - static CCrAlphaWin* NewL(TInt aScreenId); - ~CCrAlphaWin(); -private: - void ConstructL(TInt aScreenId); -private: - RWsSession iWs; - CWsScreenDevice* iScr; - RWindowGroup iGroup; - RWindow iWin; - }; - -class CTWsGraphs : public CTWsGraphicsBase - { -public: - enum TTestCursorType - { - ETestStandardTextCursor, - ETestCustomTextCursor - }; -public: - CTWsGraphs(CTestStep* aStep); - ~CTWsGraphs(); - void ConstructL(); -public: // list of test cases - void LaunchNewProcess(const TDesC& aExecutable); -protected: -//from CTGraphicsStep - virtual void RunTestCaseL(TInt aCurTestCase); - -private: -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - TestState TestInterfaceExtensionL(); - TestState TestScreenRedirectionL(); - TestState TestTextCursorUnderRedirectionL(TTestCursorType aCursorType); - TestState TestFlickerRedirectionL(); - TestState TestRedirectionUsingWsBackBufferL(); - void TestScreenModeChangeL(); -#endif - TestState TestEventNotificationL(); - void TestAddSwapGDArrayL(); - TestState TestSuccessiveMessageL(); - void ReportNegativeResultfail(TInt aLine,TInt aResult,TInt aExpectedResult); - void DoTestLeakInServiceL(); - void TestNestedDrawerCRP(); - void CheckResult(); - void TestNotifyRemoval(); - TestState TestWindowGroupChangeL(); - TestState TestFrameRateL(); - static TInt PluginCallBack(TAny* aArg); - void CreateWindowL(TBool aDraw=ETrue); - void DestroyWindowL(); - void CreateAlphaWindowL(); - void DestroyAlphaWindowL(); - TBool CompareBitmapArea16Bpp(CFbsBitmap* aBmp1, const TPoint& aPos1, CFbsBitmap* aBmp2, const TPoint& aPos2, const TSize& aSize); - - TBool PosTestAddSwapGDArrayL(TInt testcase); - struct WrapTestCall; - TBool NegTestAddSwapGDArrayL(TInt failcase,WrapTestCall*aWrappedParams=NULL); - static TInt DoNegTestCall(TInt /*aInt*/, TAny *aPtr); - TBool LaunchNegTestCall(TUint aTestCount,TUint aPanicCode,const TDesC &aPanicCategory); - TestState TestGraphicDrawerCoverage(); - // For WsBuffer CRP tests -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA - void TestMWsUiBufferL(); - TBool IsWhiteLine(TInt aWhiteLinePos); -#endif - -private: -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - CWsRedir* iRedir; - CFbsBitmap* iFrontCopy; - CFbsBitmap* iBackCopy; - TRedirectorInfo iRedirInfo; - CFbsBitmap* iBefore; - CFbsBitmap* iAfter; - TTextCursor iTextCursor; - RArray iSpriteMemberArray; -#endif - CWsListen* iListen; - CWsNotify* iNotify1; - CWsNotify* iNotify2; - TListenerInfo iListenInfo; - TInt iSubState; - CCrWin* iWin; - CCrAlphaWin* iAlpha; - TInt iOriginalWindowGroupId; - CCrWin* iNewWin; - CGraphicTestFrameRate* iTestframerate; - TAnimRate iAnimCount; - CWsGdCoverage* iGdCoverage; - }; - -class CTWsGraphsStep : public CTGraphicsStep - { -public: - CTWsGraphsStep(); - -protected: - //from CTGraphicsStep - virtual CTGraphicsBase* CreateTestL(); - }; - - - -_LIT(KTWsGraphsStep,"TWsGraphs"); - - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/colorblender.cpp --- a/windowing/windowserver/tauto/colorblender.cpp Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,60 +0,0 @@ -// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -#include "colorblender.h" -#include -#include -#include - -CColorBlender* CColorBlender::NewLC(TDisplayMode aDisplayMode) - { - CColorBlender* self = new(ELeave) CColorBlender; - CleanupStack::PushL(self); - self->iBitmap = new(ELeave) CFbsBitmap; - User::LeaveIfError(self->iBitmap->Create(TSize(1, 1), aDisplayMode)); - self->iDevice = CFbsBitmapDevice::NewL(self->iBitmap); - self->iGc = CFbsBitGc::NewL(); - self->iGc->Activate(self->iDevice); - return self; - } - -CColorBlender::~CColorBlender() - { - delete iBitmap; - delete iDevice; - delete iGc; - } - -void CColorBlender::SetInitialColor(TRgb aColor) - { - iGc->SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); - iGc->SetBrushColor(aColor); - iGc->Clear(); - iGc->SetDrawMode(CGraphicsContext::EDrawModePEN); - } - -void CColorBlender::Blend(TRgb aColor) - { - iGc->SetBrushColor(aColor); - iGc->Clear(); - } - -TRgb CColorBlender::Color() const - { - TRgb color; - iBitmap->GetPixel(color, TPoint(0, 0)); - return color; - } - diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/colorblender.h --- a/windowing/windowserver/tauto/colorblender.h Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,39 +0,0 @@ -// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -#ifndef __COLORBLENDER_H__ -#define __COLORBLENDER_H__ - -#include - -class CFbsBitGc; -class CFbsBitmap; -class CFbsBitmapDevice; - -class CColorBlender : public CBase - { -public: - static CColorBlender* NewLC(TDisplayMode aDisplayMode); - ~CColorBlender(); - void SetInitialColor(TRgb aColor); - void Blend(TRgb aColor); - TRgb Color() const; -private: - CFbsBitmap* iBitmap; - CFbsBitmapDevice* iDevice; - CFbsBitGc* iGc; - }; - -#endif //__COLORBLENDER_H__ diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/config/graphics-wserv-autotest.ini --- a/windowing/windowserver/tauto/config/graphics-wserv-autotest.ini Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,4 +0,0 @@ -//This ini file is used to set the screen number for the wserv autotests using a function called GetScreenFromIni(). - -[useScreen] -screen=1 \ No newline at end of file diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/directgdigcwrapper.cpp --- a/windowing/windowserver/tauto/directgdigcwrapper.cpp Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,521 +0,0 @@ -// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -#include "directgdigcwrapper.h" -#include "mwsgraphicscontexttodirectgdimappings.h" -#include -#include "stdpanic.h" -#include -#include -#include - -void Panic(TStdPluginPanic aPanic) - { - _LIT(KStdPanicCategory, "WSERV-TEST-PLUGIN"); - User::Panic(KStdPanicCategory, aPanic); - } - -CDirectGdiGcWrapper* CDirectGdiGcWrapper::NewL(RDirectGdiImageTarget& aTarget) - { - CDirectGdiGcWrapper* self = new(ELeave) CDirectGdiGcWrapper; - CleanupStack::PushL(self); - CDirectGdiDriver* driver = CDirectGdiDriver::Static(); - User::LeaveIfNull(driver); - self->iContext = CDirectGdiContext::NewL(*driver); - TInt err = self->iContext->Activate(aTarget); - User::LeaveIfError(err); - self->iErrorCode = KErrNone; - self->iGcBuf = CBufSeg::NewL(512); - //MWsFader - //Default in BitGdi was 128 for the blackMap and 255 for the whiteMap - //SetFadingParameters shows how the fade color is computed - self->iFadeColor.SetInternal(0x80FFFFFF); - - self->iLut = PtrTo16BitNormalisationTable(); - CleanupStack::Pop(self); - return self; - } - -CDirectGdiGcWrapper::~CDirectGdiGcWrapper() - { - delete iContext; - delete iGcBuf; - iClippingRegion.Close(); - } - -void CDirectGdiGcWrapper::BitBlt(const TPoint& aDestPos, const CFbsBitmap& aSourceBitmap) - { - iContext->BitBlt(aDestPos, aSourceBitmap); - } - -void CDirectGdiGcWrapper::BitBlt(const TPoint& aDestPos, const CFbsBitmap& aSourceBitmap, const TRect& aSourceRect) - { - iContext->BitBlt(aDestPos, aSourceBitmap, aSourceRect); - } - -void CDirectGdiGcWrapper::BitBltMasked(const TPoint& aDestPos, const CFbsBitmap& aSourceBitmap, const TRect& aSourceRect, const CFbsBitmap& aMaskBitmap, TBool aInvertMask) - { - iContext->BitBltMasked(aDestPos, aSourceBitmap, aSourceRect, aMaskBitmap, aInvertMask); - } - -void CDirectGdiGcWrapper::BitBltMasked(const TPoint& aDestPos, const CFbsBitmap& aSourceBitmap, const TRect& aSourceRect, const CFbsBitmap& aMaskBitmap, const TPoint& aMaskPos) - { - iContext->BitBltMasked(aDestPos, aSourceBitmap, aSourceRect, aMaskBitmap, aMaskPos); - } - -void CDirectGdiGcWrapper::ResetClippingRegion() - { - iContext->ResetClippingRegion(); - } - -void CDirectGdiGcWrapper::Clear() - { - iContext->Clear(); - } - -void CDirectGdiGcWrapper::Clear(const TRect& aRect) - { - iContext->Clear(aRect); - } - -void CDirectGdiGcWrapper::ResetBrushPattern() - { - iContext->ResetBrushPattern(); - } - -void CDirectGdiGcWrapper::ResetFont() - { - iContext->ResetFont(); - } - -void CDirectGdiGcWrapper::DrawArc(const TRect& aRect, const TPoint& aStart, const TPoint& aEnd) - { - iContext->DrawArc(aRect, aStart, aEnd); - } - -void CDirectGdiGcWrapper::DrawPie(const TRect& aRect, const TPoint& aStart, const TPoint& aEnd) - { - iContext->DrawPie(aRect, aStart, aEnd); - } - -void CDirectGdiGcWrapper::DrawBitmap(const TRect& aDestRect, const CFbsBitmap& aSourceBitmap) - { - iContext->DrawBitmap(aDestRect, aSourceBitmap); - } - -void CDirectGdiGcWrapper::DrawBitmap(const TRect& aDestRect, const CFbsBitmap& aSourceBitmap, const TRect& aSourceRect) - { - iContext->DrawBitmap(aDestRect, aSourceBitmap, aSourceRect); - } - -void CDirectGdiGcWrapper::DrawBitmapMasked(const TRect& aDestRect, const CFbsBitmap& aSourceBitmap, const TRect& aSourceRect, const CFbsBitmap& aMaskBitmap, TBool aInvertMask) - { - iContext->DrawBitmapMasked(aDestRect, aSourceBitmap, aSourceRect, aMaskBitmap, aInvertMask); - } - -void CDirectGdiGcWrapper::DrawRoundRect(const TRect& aRect, const TSize& aEllipse) - { - iContext->DrawRoundRect(aRect, aEllipse); - } - -void CDirectGdiGcWrapper::DrawPolyLine(const TArray& aPointList) - { - iContext->DrawPolyLine(aPointList); - } - -void CDirectGdiGcWrapper::DrawPolyLineNoEndPoint(const TArray& aPointList) - { - iContext->DrawPolyLineNoEndPoint(aPointList); - } - -void CDirectGdiGcWrapper::DrawPolygon(const TArray& aPointList, TFillRule aFillRule) - { - iContext->DrawPolygon(aPointList, MWsGraphicsContextToDirectGdiMappings::Convert(aFillRule)); - } - -void CDirectGdiGcWrapper::DrawEllipse(const TRect& aRect) - { - iContext->DrawEllipse(aRect); - } - -void CDirectGdiGcWrapper::DrawLine(const TPoint& aStart, const TPoint& aEnd) - { - iContext->DrawLine(aStart, aEnd); - } - -void CDirectGdiGcWrapper::DrawLineTo(const TPoint& aPoint) - { - iContext->DrawLineTo(aPoint); - } - -void CDirectGdiGcWrapper::DrawLineBy(const TPoint& aVector) - { - iContext->DrawLineBy(aVector); - } - -void CDirectGdiGcWrapper::DrawRect(const TRect& aRect) - { - iContext->DrawRect(aRect); - } - -void CDirectGdiGcWrapper::DrawText(const TDesC& aText,const TTextParameters* aParam) - { - iContext->DrawText(aText, MWsGraphicsContextToDirectGdiMappings::Convert(aParam)); - } - -void CDirectGdiGcWrapper::DrawText(const TDesC& aText,const TTextParameters* aParam,const TPoint& aPosition) - { - iContext->DrawText(aText, MWsGraphicsContextToDirectGdiMappings::Convert(aParam), aPosition); - } - -void CDirectGdiGcWrapper::DrawText(const TDesC& aText,const TTextParameters* aParam,const TRect& aClipRect) - { - iContext->DrawText(aText, MWsGraphicsContextToDirectGdiMappings::Convert(aParam), aClipRect); - } - -void CDirectGdiGcWrapper::DrawText(const TDesC& aText,const TTextParameters* aParam,const TRect& aClipFillRect,TInt aBaselineOffset, TTextAlign aHrz,TInt aMargin) - { - iContext->DrawText(aText, MWsGraphicsContextToDirectGdiMappings::Convert(aParam), aClipFillRect, aBaselineOffset, MWsGraphicsContextToDirectGdiMappings::Convert(aHrz), aMargin); - } - -void CDirectGdiGcWrapper::DrawTextVertical(const TDesC& aText,const TTextParameters* aParam,TBool aUp) - { - iContext->DrawTextVertical(aText, MWsGraphicsContextToDirectGdiMappings::Convert(aParam), aUp); - } - -void CDirectGdiGcWrapper::DrawTextVertical(const TDesC& aText,const TTextParameters* aParam,const TPoint& aPosition,TBool aUp) - { - iContext->DrawTextVertical(aText, MWsGraphicsContextToDirectGdiMappings::Convert(aParam), aPosition, aUp); - } - -void CDirectGdiGcWrapper::DrawTextVertical(const TDesC& aText,const TTextParameters* aParam,const TRect& aClipRect,TBool aUp) - { - iContext->DrawTextVertical(aText, MWsGraphicsContextToDirectGdiMappings::Convert(aParam), aClipRect, aUp); - } - -void CDirectGdiGcWrapper::DrawTextVertical(const TDesC& aText,const TTextParameters* aParam,const TRect& aClipRect,TInt aBaselineOffset,TBool aUp,TTextAlign aVert,TInt aMargin) - { - iContext->DrawTextVertical(aText, MWsGraphicsContextToDirectGdiMappings::Convert(aParam), aClipRect, aBaselineOffset, aUp, MWsGraphicsContextToDirectGdiMappings::Convert(aVert), aMargin); - } - -void CDirectGdiGcWrapper::DrawTextVertical(const TDesC& aText,const TTextParameters* aParam,const TRect& aClipRect,TInt aBaselineOffset,TInt aTextWidth,TBool aUp,TTextAlign aVert,TInt aMargin) - { - iContext->DrawTextVertical(aText, MWsGraphicsContextToDirectGdiMappings::Convert(aParam), aClipRect, aBaselineOffset, aTextWidth, aUp, MWsGraphicsContextToDirectGdiMappings::Convert(aVert), aMargin); - } - -void CDirectGdiGcWrapper::MoveTo(const TPoint& aPoint) - { - iContext->MoveTo(aPoint); - } - -void CDirectGdiGcWrapper::MoveBy(const TPoint& aVector) - { - iContext->MoveBy(aVector); - } - -void CDirectGdiGcWrapper::Plot(const TPoint& aPoint) - { - iContext->Plot(aPoint); - } - -void CDirectGdiGcWrapper::Reset() - { - iContext->Reset(); - } - -void CDirectGdiGcWrapper::SetBrushColor(const TRgb& aColor) - { - iContext->SetBrushColor(aColor); - } - -void CDirectGdiGcWrapper::SetBrushOrigin(const TPoint& aOrigin) - { - iContext->SetBrushOrigin(aOrigin); - } - -void CDirectGdiGcWrapper::SetBrushStyle(TBrushStyle aBrushStyle) - { - iContext->SetBrushStyle(MWsGraphicsContextToDirectGdiMappings::Convert(aBrushStyle)); - } - -void CDirectGdiGcWrapper::SetClippingRegion(const TRegion& aRegion) - { - CDirectGdiDriver* driver = CDirectGdiDriver::Static(); - driver->GetError(); //make sure that an error has been received - iContext->SetClippingRegion(aRegion); - TInt err = driver->GetError(); - SetError(err); - if(err == KErrNone) - { - iClippingRegion.Copy(aRegion); - } - } - -void CDirectGdiGcWrapper::SetDrawMode(TDrawMode aDrawMode) - { - iContext->SetDrawMode(MWsGraphicsContextToDirectGdiMappings::LossyConvert(aDrawMode)); - } - -void CDirectGdiGcWrapper::SetOrigin(const TPoint& aPoint) - { - iContext->SetOrigin(aPoint); - iOrigin = aPoint; - } - -void CDirectGdiGcWrapper::SetPenColor(const TRgb& aColor) - { - iContext->SetPenColor(aColor); - } - -void CDirectGdiGcWrapper::SetPenStyle(TPenStyle aPenStyle) - { - iContext->SetPenStyle(MWsGraphicsContextToDirectGdiMappings::Convert(aPenStyle)); - } - -void CDirectGdiGcWrapper::SetPenSize(const TSize& aSize) - { - iContext->SetPenSize(aSize); - } - -void CDirectGdiGcWrapper::SetTextShadowColor(const TRgb& aColor) - { - iContext->SetTextShadowColor(aColor); - } - -void CDirectGdiGcWrapper::SetCharJustification(TInt aExcessWidth, TInt aNumChars) - { - iContext->SetCharJustification(aExcessWidth, aNumChars); - } - -void CDirectGdiGcWrapper::SetWordJustification(TInt aExcessWidth, TInt aNumGaps) - { - iContext->SetWordJustification(aExcessWidth, aNumGaps); - } - -void CDirectGdiGcWrapper::SetUnderlineStyle(TFontUnderline aUnderlineStyle) - { - iContext->SetUnderlineStyle(MWsGraphicsContextToDirectGdiMappings::Convert(aUnderlineStyle)); - } - -void CDirectGdiGcWrapper::SetStrikethroughStyle(TFontStrikethrough aStrikethroughStyle) - { - iContext->SetStrikethroughStyle(MWsGraphicsContextToDirectGdiMappings::Convert(aStrikethroughStyle)); - } - -void CDirectGdiGcWrapper::SetBrushPattern(const CFbsBitmap& aBitmap) - { - iContext->SetBrushPattern(aBitmap); - } - -void CDirectGdiGcWrapper::SetBrushPattern(TInt aFbsBitmapHandle) - { - iContext->SetBrushPattern(aFbsBitmapHandle); - } - -void CDirectGdiGcWrapper::SetFont(const CFont* aFont) - { - iContext->SetFont(aFont); - } - -void CDirectGdiGcWrapper::CopyRect(const TPoint& aOffset, const TRect& aRect) - { - iContext->CopyRect(aOffset, aRect); - } - -void CDirectGdiGcWrapper::UpdateJustification(const TDesC& aText,const TTextParameters* aParam) - { - iContext->UpdateJustification(aText, MWsGraphicsContextToDirectGdiMappings::Convert(aParam)); - } - -void CDirectGdiGcWrapper::UpdateJustificationVertical(const TDesC& aText,const TTextParameters* aParam,TBool aUp) - { - iContext->UpdateJustificationVertical(aText, MWsGraphicsContextToDirectGdiMappings::Convert(aParam), aUp); - } - -void CDirectGdiGcWrapper::SetFontNoDuplicate(const CFont* aFont) - { - iContext->SetFontNoDuplicate(static_cast(aFont)); - } - -TBool CDirectGdiGcWrapper::HasBrushPattern() const - { - return iContext->HasBrushPattern(); - } - -TBool CDirectGdiGcWrapper::HasFont() const - { - return iContext->HasFont(); - } - -TRgb CDirectGdiGcWrapper::BrushColor() const - { - return iContext->BrushColor(); - } - -TRgb CDirectGdiGcWrapper::PenColor() const - { - return iContext->PenColor(); - } - -TRgb CDirectGdiGcWrapper::TextShadowColor() const - { - return iContext->TextShadowColor(); - } - -TAny* CDirectGdiGcWrapper::ResolveObjectInterface(TUint /*aTypeId*/) - { - return NULL; - } - -/** -Sets the error code. If the error code is already set to a value other -than KErrNone, the error code will not be modified. - -@param aErr The error code to set. - -@post The error code has been set. -*/ -void CDirectGdiGcWrapper::SetError(TInt aError) - { - if (aError != KErrNone && iErrorCode == KErrNone) - { - iErrorCode = aError; - } - } - -/** -Returns the first error code (set as the result of calling some CDirectGdiGcWrapper API), if any, -since the last call to this function or, if it has not previously been called, since -the CDirectGdiGcWrapper was constructed. Calling this function clears the error code. - -@post The error code has been reset after being read. - -@return The first error code, if any, since the last call to this function or, - if it has not previously been called, since the CDirectGdiGcWrapper was constructed. - KErrNone will indicate that no such error has occurred. -*/ -TInt CDirectGdiGcWrapper::GetError() - { - TInt err = iErrorCode; - iErrorCode = KErrNone; - return err; - } - -TPoint CDirectGdiGcWrapper::Origin() const - { - return iOrigin; - } - -const TRegion& CDirectGdiGcWrapper::ClippingRegion() - { - return iClippingRegion; - } - -TInt CDirectGdiGcWrapper::Push() - { - // the buf format is len+data where data is written by the GC's ExternalizeL() - iGcBuf->Reset(); - CBufBase& buf = *iGcBuf; - const TInt start = buf.Size(); - RBufWriteStream out(buf,start); - TRAPD(err,out.WriteInt32L(0)); - if(!err) - { - TRAP(err,iContext->ExternalizeL(out)); - } - if(err) //rollback addition - { - buf.Delete(start,buf.Size()-start); - } - else //fixup len - { - TRAP_IGNORE(out.CommitL();) // can't see this failing - TPckgBuf pckg(buf.Size()-sizeof(TInt32)-start); - buf.Write(start,pckg); - } - return err; - } - -void CDirectGdiGcWrapper::Pop() - { - CBufBase& buf = *iGcBuf; - TInt ofs = 0; - FOREVER - { - TInt chunk = 0; - RBufReadStream in(buf,ofs); - TRAPD(err,chunk = in.ReadInt32L()); - if(err) - { - STD_ASSERT_DEBUG(err != 0, EStdPanicPopGcSettings); - return; - } - if(ofs+sizeof(TInt32)+chunk >= buf.Size()) // the last chunk? - { - TRAP_IGNORE(iContext->InternalizeL(in)); - buf.Delete(ofs,buf.Size()-ofs); - return; - } - ofs += chunk + sizeof(TInt32); - } - } - -//Default method of fading simply uses bitgdi to perform fading -void CDirectGdiGcWrapper::FadeArea(const TRegion& aRegion) - { - if (!&aRegion || aRegion.CheckError()) - return; - - iContext->Reset(); - iContext->SetClippingRegion(aRegion); - iContext->SetPenStyle(DirectGdi::ENullPen); - iContext->SetBrushStyle(DirectGdi::ESolidBrush); - iContext->SetBrushColor(iFadeColor); - iContext->DrawRect(aRegion.BoundingRect()); - } - -//Default method of fading expects two TUint8's describing the black/white map -//as possible fading parameters -void CDirectGdiGcWrapper::SetFadingParameters(const TDesC8& aData) - { - TPckgBuf buf; - buf.Copy(aData); - TFadingParams parameters = buf(); - - //Situations where blackMap > whiteMap are NOT supported - if (parameters.blackMap > parameters.whiteMap) - { - TUint8 oldMap = parameters.blackMap; - parameters.blackMap = parameters.whiteMap; - parameters.whiteMap = oldMap; - } - - //CFbsBitGc::FadeArea() does the following per color component: - // dst = dst * (whiteMap - blackMap) + blackMap; - - //To achieve the same effect using MWsGraphicsContext we draw a rectangle - //with specific intensity and alpha values: - // dst = dst * (1 - alpha) + intensity * alpha; - //Thus: - // alpha = 1 - whiteMap + blackMap; - // intensity = blackMap / alpha; - - // alpha = 1 - whiteMap + blackMap; - TInt alpha = 255 - parameters.whiteMap + parameters.blackMap; - // intensity = blackMap / alpha; - TInt i = (parameters.blackMap * iLut[alpha]) >> 8; - - iFadeColor.SetInternal(i << 16 | i << 8 | i | alpha << 24); - } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/directgdigcwrapper.h --- a/windowing/windowserver/tauto/directgdigcwrapper.h Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,169 +0,0 @@ -// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -#ifndef __DIRECTGDIGCWRAPPER_H__ -#define __DIRECTGDIGCWRAPPER_H__ - -#include -#include -#include -#include -#include - - -/* - * Required by MWsFader implementation - */ -struct TFadingParams - { - TUint8 blackMap; - TUint8 whiteMap; - }; - -/** -The purpose of this class is to wrap a @c CDirectGdiContext whenever an -@c MWsGraphicsContext is needed. - -The methods doesn't do anything other than calling the corresponding method -in @c MWsGraphicsContext. - -@see MWsGraphicsContext -@see MWsDrawableSourceProvider -@see CDirectGdiContext; - -@internalComponent -@prototype -*/ -class CDirectGdiGcWrapper : public CBase, public MWsGraphicsContext, public MWsFader - { -public: - static CDirectGdiGcWrapper* NewL(RDirectGdiImageTarget& aTarget); - ~CDirectGdiGcWrapper(); - inline CDirectGdiContext& DirectGdiGc(); - TInt SetDrawDeviceOffset(TPoint& aOrigin); - -public: //from MWsGraphicsContext - void BitBlt(const TPoint& aDestPos, const CFbsBitmap& aSourceBitmap); - void BitBlt(const TPoint& aDestPos, const CFbsBitmap& aSourceBitmap, const TRect& aSourceRect); - void BitBltMasked(const TPoint& aDestPos, const CFbsBitmap& aSourceBitmap, const TRect& aSourceRect, const CFbsBitmap& aMaskBitmap, TBool aInvertMask); - void BitBltMasked(const TPoint& aDestPos, const CFbsBitmap& aSourceBitmap, const TRect& aSourceRect, const CFbsBitmap& aMaskBitmap, const TPoint& aMaskPos); - void ResetClippingRegion(); - void Clear(); - void Clear(const TRect& aRect); - void ResetBrushPattern(); - void ResetFont(); - void DrawArc(const TRect& aRect, const TPoint& aStart, const TPoint& aEnd); - void DrawPie(const TRect& aRect, const TPoint& aStart, const TPoint& aEnd); - void DrawBitmap(const TRect& aDestRect, const CFbsBitmap& aSourceBitmap); - void DrawBitmap(const TRect& aDestRect, const CFbsBitmap& aSourceBitmap, const TRect& aSourceRect); - void DrawBitmapMasked(const TRect& aDestRect, const CFbsBitmap& aSourceBitmap, const TRect& aSourceRect, const CFbsBitmap& aMaskBitmap, TBool aInvertMask); - void DrawRoundRect(const TRect& aRect, const TSize& aEllipse); - void DrawPolyLine(const TArray& aPointList); - void DrawPolyLineNoEndPoint(const TArray& aPointList); - void DrawPolygon(const TArray& aPointList, TFillRule aFillRule=EAlternate); - void DrawEllipse(const TRect& aRect); - void DrawLine(const TPoint& aStart, const TPoint& aEnd); - void DrawLineTo(const TPoint& aPoint); - void DrawLineBy(const TPoint& aVector); - void DrawRect(const TRect& aRect); - void DrawText(const TDesC& aText,const TTextParameters* aParam); - void DrawText(const TDesC& aText,const TTextParameters* aParam,const TPoint& aPosition); - void DrawText(const TDesC& aText,const TTextParameters* aParam,const TRect& aClipRect); - void DrawText(const TDesC& aText,const TTextParameters* aParam,const TRect& aClipFillRect,TInt aBaselineOffset,TTextAlign aHrz=ELeft,TInt aMargin=0); - void DrawTextVertical(const TDesC& aText,const TTextParameters* aParam,TBool aUp); - void DrawTextVertical(const TDesC& aText,const TTextParameters* aParam,const TPoint& aPosition,TBool aUp); - void DrawTextVertical(const TDesC& aText,const TTextParameters* aParam,const TRect& aClipRect,TBool aUp); - void DrawTextVertical(const TDesC& aText,const TTextParameters* aParam,const TRect& aClipRect,TInt aBaselineOffset,TBool aUp,TTextAlign aVert=ELeft,TInt aMargin=0); - void DrawTextVertical(const TDesC& aText,const TTextParameters* aParam,const TRect& aClipRect,TInt aBaselineOffset,TInt aTextWidth,TBool aUp,TTextAlign aVert=ELeft,TInt aMargin=0); - void MoveTo(const TPoint& aPoint); - void MoveBy(const TPoint& aVector); - void Plot(const TPoint& aPoint); - void Reset(); - void SetBrushColor(const TRgb& aColor); - void SetBrushOrigin(const TPoint& aOrigin); - void SetBrushStyle(TBrushStyle aBrushStyle); - void SetClippingRegion(const TRegion& aRegion); - void SetDrawMode(TDrawMode aDrawMode); - void SetOrigin(const TPoint& aPoint = TPoint(0, 0)); - void SetPenColor(const TRgb& aColor); - void SetPenStyle(TPenStyle aPenStyle); - void SetPenSize(const TSize& aSize); - void SetTextShadowColor(const TRgb& aColor); - void SetCharJustification(TInt aExcessWidth, TInt aNumChars); - void SetWordJustification(TInt aExcessWidth, TInt aNumGaps); - void SetUnderlineStyle(TFontUnderline aUnderlineStyle); - void SetStrikethroughStyle(TFontStrikethrough aStrikethroughStyle); - void SetBrushPattern(const CFbsBitmap& aBitmap); - void SetBrushPattern(TInt aFbsBitmapHandle); - void SetFont(const CFont* aFont); - void CopyRect(const TPoint& aOffset, const TRect& aRect); - void UpdateJustification(const TDesC& aText,const TTextParameters* aParam); - void UpdateJustificationVertical(const TDesC& aText,const TTextParameters* aParam,TBool aUp); - void SetFontNoDuplicate(const CFont* aFont); - TBool HasBrushPattern() const; - TBool HasFont() const; - TRgb BrushColor() const; - TRgb PenColor() const; - TRgb TextShadowColor() const; - - // Return current error status of MWsGraphicsContext - TInt GetError(); - // Getters - TPoint Origin() const; - const TRegion& ClippingRegion(); - // Save and retrieve gc settings - TInt Push(); - void Pop(); - -public: // MWsFader - void SetFadingParameters(const TDesC8& aData); - void FadeArea(const TRegion& aRegion); - - //from MWsObjectProvider - TAny* ResolveObjectInterface(TUint aTypeId); - -private: - const CArrayFix* DoCreateCArrayL(const TArray& aPointList); - const CArrayFix* CreateCArray(const TArray& aPointList); - void SetError(TInt aError); - -private: - CDirectGdiContext* iContext; - TInt iErrorCode; - CBufBase* iGcBuf; // used for keeping state when drawing CWsGraphicDrawers - RRegionBuf<20> iClippingRegion; // Clipping region while doing drawing - TPoint iOrigin; // Window Origin + User defined gc origin - - //Required by MWsFader implmentation - TRgb iFadeColor; - const TUint16* iLut; - }; - -struct RDirectGdiImageEntry - { - RDirectGdiDrawableSource* iDrawableSource; - RSgImage iImage; - }; - -// -// CDirectGdiGcWrapper -// - -inline CDirectGdiContext& CDirectGdiGcWrapper::DirectGdiGc() - {return(*iContext);} - - - -#endif //__DIRECTGDIGCWRAPPER_H__ diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/eventdd.cpp --- a/windowing/windowserver/tauto/eventdd.cpp Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,111 +0,0 @@ -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -#include -#include "eventdd.h" - -/** - Logical Device (factory class) for 'EventDD' -*/ -class DEventFactory : public DLogicalDevice - { -public: - DEventFactory(); - //Pure virtual funcitons from DLogicalDevice - TInt Install(); - void GetCaps(TDes8& aDes) const; - TInt Create(DLogicalChannelBase*& aChannel); - }; - -class DEventDD : public DLogicalChannelBase - { -public: - //Pure virtual function from DLogicalChannelBase - TInt Request(TInt aReqNo,TAny* a1,TAny* a2); -private: - TInt DoControl(TInt aFunction, TAny* a1, TAny* a2); - TInt SendEvent(TRawEvent* aEvent); - }; - - -/* DLL Factory Function */ - -DECLARE_STANDARD_LDD() - { - return new DEventFactory; - } - - -/* DEventFactory */ - -DEventFactory::DEventFactory() :DLogicalDevice() - { - iVersion=REventDD::VersionRequired(); //Set version number for this device - } - -TInt DEventFactory::Install() - { - return SetName(&REventDD::DriverName()); - } - -void DEventFactory::GetCaps(TDes8& aDes) const - { - Kern::InfoCopy(aDes,KNullDesC8); - } - -TInt DEventFactory::Create(DLogicalChannelBase*& aChannel) - { - aChannel=new DEventDD; - return aChannel?KErrNone:KErrNoMemory; - } - - -/* DEventDD */ // Logical Channel - -TInt DEventDD::Request(TInt aReqNo,TAny* a1,TAny* a2) - { - // Decode the message type and dispatch it to the relevent handler function... - // only using synchronous control messages - if (static_cast(aReqNo)(KMaxTInt)) - return DoControl(aReqNo,a1,a2); - return KErrNotSupported; - } - -/** - Process synchronous 'control' requests -*/ -TInt DEventDD::DoControl(TInt aFunction,TAny* a1,TAny* /*a2*/) - { - TInt ret=KErrNotSupported; - - switch (aFunction) - { - case REventDD::ESendEvent: - ret=SendEvent(static_cast(a1)); - break; - default:; - } - return ret; - } - -TInt DEventDD::SendEvent(TRawEvent* aEvent) - { - TRawEvent event; - kumemget(&event,aEvent,sizeof(TRawEvent)); //fetch event from user memory - NKern::ThreadEnterCS(); - TInt err=Kern::AddEvent(event); - NKern::ThreadLeaveCS(); - return err; - } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/eventdd.h --- a/windowing/windowserver/tauto/eventdd.h Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,75 +0,0 @@ -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -#ifndef __EVENTDD_H__ -#define __EVENTDD_H__ - -#ifndef __E32cmn_H__ -#include -#endif - -_LIT(KName,"EventDD"); - - -class REventDD : public RBusLogicalChannel - { - friend class DEventDD; -public: - /** - Structure for holding driver capabilities information - (Just a version number in this example.) - */ - class TCaps - { - public: - TVersion iVersion; - }; - -public: - inline static const TDesC& BinaryName(); - inline static const TDesC& DriverName(); - inline static TVersion VersionRequired(); - inline TInt Open(); - inline TInt SendEvent(TRawEvent& aEvent); -private: - enum TControl - { - ESendEvent - }; - }; - - -inline const TDesC& REventDD::BinaryName() - { - return KName; - } -inline const TDesC& REventDD::DriverName() - { - return KName; - } -inline TVersion REventDD::VersionRequired() - { - return TVersion(1,0,0); - } -inline TInt REventDD::Open() - { - return DoCreate(DriverName(),VersionRequired(),KNullUnit,NULL,NULL,EOwnerThread); - } -inline TInt REventDD::SendEvent(TRawEvent& aEvent) - { - return DoControl(ESendEvent,static_cast(&aEvent)); - } - -#endif //__EVENTDD_H__ diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/mwsgraphicscontexttodirectgdimappings.h --- a/windowing/windowserver/tauto/mwsgraphicscontexttodirectgdimappings.h Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,81 +0,0 @@ -// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -#ifndef __MWSGRAPHICSCONTEXTTODIRECTGDIMAPPINGS_H__ -#define __MWSGRAPHICSCONTEXTTODIRECTGDIMAPPINGS_H__ - -#include -#include -#include - -class MWsGraphicsContextToDirectGdiMappings - { -public: - static DirectGdi::TFillRule Convert(MWsGraphicsContext::TFillRule aFillRule) { return (DirectGdi::TFillRule)aFillRule; } - static DirectGdi::TPenStyle Convert(MWsGraphicsContext::TPenStyle aPenStyle) { return (DirectGdi::TPenStyle)aPenStyle; } - static DirectGdi::TBrushStyle Convert(MWsGraphicsContext::TBrushStyle aBrushStyle) { return (DirectGdi::TBrushStyle)aBrushStyle; } - static DirectGdi::TTextAlign Convert(MWsGraphicsContext::TTextAlign aTextAlign) { return (DirectGdi::TTextAlign)aTextAlign; } - static DirectGdi::TFontUnderline Convert(MWsGraphicsContext::TFontUnderline aFontUnderline) { return (DirectGdi::TFontUnderline)aFontUnderline; } - static DirectGdi::TFontStrikethrough Convert(MWsGraphicsContext::TFontStrikethrough aFontStrikethrough) { return (DirectGdi::TFontStrikethrough)aFontStrikethrough; } - static const DirectGdi::TTextParameters* Convert(const MWsGraphicsContext::TTextParameters* aParam) { return reinterpret_cast(aParam); } - static DirectGdi::TDrawMode LossyConvert(MWsGraphicsContext::TDrawMode aDrawMode) - {return (aDrawMode==MWsGraphicsContext::EDrawModeWriteAlpha ? DirectGdi::EDrawModeWriteAlpha : DirectGdi::EDrawModePEN);} - }; - - -template -class TArrayWrapper : public TArray - { -public: - TArrayWrapper(const T* aArray, TInt aCount); -private: - static TInt Count(const CBase* aPtr); - static const TAny* At(const CBase* aPtr, TInt aIndex); -private: - const T* iArray; - const TInt iCount; - }; - -template -TArrayWrapper::TArrayWrapper(const T* aArray, TInt aCount) - : TArray(TArrayWrapper::Count, TArrayWrapper::At, reinterpret_cast(this)), iArray(aArray), iCount(aCount) - { - //reinterpret_cast above since this class doesn't derive from CBase but TArray is - //only silly requiring CBase as opposed to TAny, so this is safe - ASSERT(iArray); - } - -template -TInt TArrayWrapper::Count(const CBase* aPtr) - { - //reinterpret_cast since this class doesn't derive from CBase but TArray is - //only silly requiring CBase as opposed to TAny, so this is safe - const TArrayWrapper* self = reinterpret_cast(aPtr); - return self->iCount; - } - -template -const TAny* TArrayWrapper::At(const CBase* aPtr, TInt aIndex) - { - //reinterpret_cast since this class doesn't derive from CBase but TArray is - //only silly requiring CBase as opposed to TAny, so this is safe - const TArrayWrapper* self = reinterpret_cast(aPtr); - if(!Rng(0, aIndex, self->iCount - 1)) - User::Panic(_L("USER"), 130); //out of bounds (RArray/RPointerArray) - return self->iArray + aIndex; - } - - -#endif //__MWSGRAPHICSCONTEXTTODIRECTGDIMAPPINGS_H__ diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/mytest.mbm Binary file windowing/windowserver/tauto/mytest.mbm has changed diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/openwfc/AUTO.H --- a/windowing/windowserver/tauto/openwfc/AUTO.H Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,669 +0,0 @@ -// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Header for window server auto test code -// -// - - -#ifndef __AUTO_H__ -#define __AUTO_H__ - -#include -#include -#include "../../SERVER/w32cmd.h" -#include -#include "../tlib/testbase.h" -#include -#include "TGraphicsHarness.h" -#include "../../SERVER/openwfc/panics.h" - -#define DISABLE_FAIL_DIALOG - -#define TEST_BITMAP_NAME _L("Z:\\WSTEST\\WSAUTOTEST.MBM") - -#define SCREEN_MODE_TESTING - -#define LOG_MESSAGE(p) LogMessage(((TText8*)__FILE__), __LINE__,(p)) -#define LOG_MESSAGE2(p1,p2) LogMessage(((TText8*)__FILE__), __LINE__,(p1),(p2)) -#define LOG_MESSAGE3(p1,p2,p3) LogMessage(((TText8*)__FILE__), __LINE__,(p1),(p2),(p3)) -#define LOG_MESSAGE4(p1,p2,p3,p4) LogMessage(((TText8*)__FILE__), __LINE__,(p1),(p2),(p3),(p4)) -#define LOG_MESSAGE5(p1,p2,p3,p4,p5) LogMessage(((TText8*)__FILE__), __LINE__,(p1),(p2),(p3),(p4),(p5)) -#define LOG_MESSAGE6(p1,p2,p3,p4,p5,p6) LogMessage(((TText8*)__FILE__), __LINE__,(p1),(p2),(p3),(p4),(p5),(p6)) -#define LOG_MESSAGE7(p1,p2,p3,p4,p5,p6,p7) LogMessage(((TText8*)__FILE__), __LINE__,(p1),(p2),(p3),(p4),(p5),(p6),(p7)) - -// MB 23\11\04 The heap size was only 4k which was causing DSA step 7 to fail on HW. -// Increased heap size to 8k -// 23/02/2009 Again failing with no memory due to COLOR16MAP used. -// Increased heap size to 16k -LOCAL_D const TUint KOtherProcHeapSize=0x4000; -LOCAL_D const TInt KAutoTestPriority=-20; - -TBool DoCheckRect(CTBaseWin *aWin1,CTBaseWin *aWin2,const TRect &aRect); -TBool DoCheckRect(CTBaseWin *aWin1,CTBaseWin *aWin2,const TRect &aRect, TUint aFlags); -TBool DoCheckRectRWin(RWindowBase &aWin1,RWindowBase &aWin2,const TRect &aRect); -TBool DoCheckRectRWin(RWindowBase &aWin1,RWindowBase &aWin2,const TRect &aRect, TUint aFlags); -TBool DoCheckRect(CTBaseWin *aWin1,CTBaseWin *aWin2); -TBool DoCheckRect(TPoint aPos1,TPoint aPos2,TSize aSize); - -_LIT(KWSERV,"WSERV"); -_LIT(KW32,"W32"); -_LIT(KPlatsecBegin,"*PlatSec* ERROR - BEGIN NEGATIVE PLATSEC TESTING"); -_LIT(KPlatsecEnd,"*PlatSec* ERROR - END NEGATIVE PLATSEC TESTING"); -_LIT(KTestFontTypefaceName,"DejaVu Sans Condensed"); - -class TestClient; -class CMinWin; -class CTWsGraphicsBase; - -enum TestState - { - EInvalid, - ENext, - EWait, - EFinished - }; - -enum TAutoPanics - { - EAutoPanicTestFailed, - EAutoPanicPanicFailed, - EAutoPanicTestRectsIndex, - EAutoPanicTestRectsSection, - EAutoPanicUnexpectedLeave, - EAutoPanicTestBrushesIndex, - EAutoPanicWindowType, - EAutoPanicTooManyDownKeys, - EAutoPanicInvalidEvent, - EAutoFadeWindow, - EAutoPanicWrongTest, - EAutoPanicAnimError, - ETManPanicPcFailed, //Panic use in a test copied from TMan - EAutoPanicTestError, //Test returned bad return type - EAutoPanicDirect, //Direct Screen Access logic state error - EAutoPanicScanCapital, //Scan codes must not be lower case letters - EAutoPanicRedrawStoring, //Inconsistent Redraw Storing Behaviour - EAutoPanicRecalledCreateTestBaseL, //Called CreateTestBaseL twice - EAutoPanicHeartBeatCursorRect, //Invalid size of rectangle in ChangeTransAndCheckHeartBeat - EAutoPanicGroupWinHasChild, //Main test group window has child at start of test - EAutoPanicPanicSetTrans, //Error setting transparency during panic tests - EAutoPanicNoDigitiser, //Pointer event when the configuration has no digitiser - }; - -enum TPanicExitReasons - { - EWsExitReasonBad, - EWsExitReasonFinished, - }; - -enum TAutoLeaves - { - ETestPassed=0, - ETestFailed=1, - }; - -typedef TInt (*TPanicFunction)(TInt aInt, TAny *aPtr); - -struct SPanicParams - { - TInt num; - TPanicFunction func; - TAny *ptr; - }; - -class LogWindow : public CTWin - { - enum - { - EDummyValue=-9999 - }; -public: - LogWindow(); - void ConstructL(CTWinBase& aParent); - void Draw(); - void DrawSubTitle(); - void DrawMessage(); - void LogTest(const TDesC &aTitle,TInt aNum); - const TDesC& LogSubTest(const TDesC &aTitle,TInt aNum); - const TDesC& LogMessage(TBool aLog,const TDesC& aText,TInt aNum=EDummyValue); -private: - TBuf<0x40> iTestTitle; - TBuf<0x40> iSubTitle; - TBuf<0x40> iMessage; - TInt iTitleHeight; - }; - -class CTestBase; - -/** -This class is a window that is used to fake a border around the TestWindow defined below. -It simply draws an opaque black window on top of which the TestWindow will be drawn giving the illusion -there is a border. - -@see TestWindow -@internalComponent -@released -*/ -class CBorderWindow : public CTWin - { -public: - CBorderWindow(); - void ConstructL(CTWinBase& aParent); - void Draw(); - }; - -class TestWindow : public CTWin - { -public: - TestWindow(); - ~TestWindow(); - void Draw(); - void SetUpL(TPoint aPos, TSize aSize, CTWinBase* aParent, CWindowGc& aGc); - void ClearWin(); - void SetBorderExt(TPoint aPos, TSize aSize); - CBorderWindow* GetBorderWin(); -private: - CBorderWindow* iBorderWin; - }; - -/** -This class used to run each individual test before the migration to TEF. -Now it doesn't do much and should probably be refactored. - -@internalComponent -@released -*/ -class CTestDriver : public CBase - { -public: - /** Factory function that returns a class derived from CTestDriver */ - static CTestDriver* CreateL(TInt aScreenNumber); - virtual ~CTestDriver(); - -protected: - CTestDriver(TInt aScreenNumber); - -public: - virtual void DoDisplayDialog(TDesC& timeBuf,TDesC& testReport) = 0; - - void TestComplete2(); - void DestroyTest(); - - inline TInt ScreenNumber() {return iScreenNumber;} - inline TInt NumberOfScreens() {return iNumberOfScreens;} - -public: - CTestBase *iTest; - TInt iSubTestNum; - static TInt iTestNum; -protected: - TTime iStartTime; - TInt iScreenNumber; - TInt iTestSize; - TInt iNumberOfScreens; - }; - -/** Variant of CTestDriver used when the tests are run on the primary screen. - -@internalComponent -@released -*/ -class CTestDriverPrimary: public CTestDriver - { -public: - CTestDriverPrimary(TInt aScreenNumber); - void DoDisplayDialog(TDesC& timeBuf,TDesC& testReport); - }; - -/** Variant of CTestDriver used when the tests are run on a secondary screen. - -@internalComponent -@released -*/ -class CTestDriverSecondary : public CTestDriver - { -public: - CTestDriverSecondary(TInt aScreenNumber); - void DoDisplayDialog(TDesC& timeBuf,TDesC& testReport); - }; - -/** List of rectangles use by TGDI.CPP and TRECTLIST.CPP. - -Since only 2 tests make use of this shouldn't it be moved outside of the framework? - -@internalComponent -@released -*/ -class TTestRects - { -private: - enum TRectListLimits - { - EMaxRectFromList=64, - EMaxRectZeroSize=73, - EMaxRectWide=83, - EMaxRectHigh=93 - }; - -public: - void Construct(const RWindow &aWindow); - TInt Count1() const; - TInt Count2() const; - TInt Count3() const; - TRect operator[](TInt aIndex); - static void ResetSeed(); -private: - TInt Rnd(TInt aSize); - TInt RndMax(TInt aSize); - TInt RectCoord(TInt aSection,TInt aSize); - void RectCoordPair(TInt &aTl, TInt &aBr, TInt aSection, TInt aSize); - -private: - TSize iSize; - static TRect iList[64]; - static TInt64 iSeed; - }; - -/** -@internalComponent -@released -*/ -class CBitmap : public CBase - { -public: - static CBitmap* NewLC(const TSize& aSizeInPixels,TDisplayMode aDispMode); - static CBitmap* NewL(const TSize& aSizeInPixels,TDisplayMode aDispMode); - static CBitmap* NewL(TInt aHandle); - static CBitmap* NewL(TDesC& aFileName); - ~CBitmap(); - inline CFbsBitmap& Bitmap() const {return *iBitmap;} - inline CFbsBitmapDevice& Device() const {return *iDevice;} - inline CFbsBitGc& Gc() const {return *iGc;} -private: - static CBitmap* NewLC(TInt aHandle,const TSize& aSizeInPixels,TDisplayMode aDispMode); - void ConstructL(TInt aHandle,const TSize& aSizeInPixels,TDisplayMode aDispMode); -private: - CFbsBitmap* iBitmap; - CFbsBitmapDevice* iDevice; - CFbsBitGc* iGc; - }; - -/*TPartialRedrawType*/ -enum TPartialRedrawType - { - //redraw store type is not yet determined. - EPartialRedraw_Unknown, - //redraw store is discarded on invalidation and begin-redraw on a smaller rect. - EPartialRedraw_None, - // redraw store is preserved on invalidation and begin-redraw on a smaller rect. - EPartialRedraw_PreserveStoredCmds, - // redraw store is appended with partial redraw commands, and old redraw store is suitably modified. - EPartialRedraw_FullRedrawSupport - }; - -class CTestBase : public CBase - { -public: - enum TPriorites - { - EAutoTestPriority=KAutoTestPriority - }; - enum TTestLevel - { - ELevelQuick, // Quick check on main cases for each function - ELevelNormal, // Suitable test level for internal release - ELevelRelease, // Thorough test suitable for official releases - ELevelMega, // Really OTT, takes forever to run, leave it going over the weekend sort of tests - }; -public: - CTestBase(const TDesC &aTitle,CTWsGraphicsBase* aTestBase); - ~CTestBase(); - void StartTestL(TInt aNum, CTestDriver* aDriver, TTestLevel aLevel); - void LogSubTest(const TDesC &aTitle); - void LogMessage(TInt aValue); - void LogSubState(TInt aSubState); - TInt LaunchPanicThread(RThread &aThread, SPanicParams *aPtr); - TInt TestPanicL(SPanicParams *aPtr, TInt aExitReason, const TDesC &aCategory, TBool* aTestFinished=NULL); - TInt TestPanicL(TPanicFunction aFunction, TInt aExitReason, TInt aInt, TAny *aPtr, const TDesC &aCategory, TBool* aTestFinished=NULL); - TInt TestWsPanicL(TPanicFunction aFunction, TClientPanic aExitReason, TInt aInt, TAny *aPtr=NULL, TBool* aTestFinished=NULL); - TInt TestW32PanicL(TPanicFunction aFunction, TW32Panic aExitReason, TInt aInt, TAny *aPtr, TBool* aTestFinished=NULL); - TInt TestWservPanicL(TPanicFunction aFunction, TWservPanic aExitReason, TInt aInt, TAny *aPtr); - void TriggerFail(); - static void DrawTestBackground(TBool aInvertColours, const TSize &aSize, TInt aGrays=16); - inline CTestDriver* Driver(); - void SimulatePointer(TRawEvent::TType aType, TInt aX, TInt aY); - TBool ConfigurationSupportsPointerEventTesting() const; - void SimulateEvent(TRawEvent::TType aType); - void LogColors(const CBitmapDevice& aDevice,TPoint aBasePoint, TPoint aStartPoint, TPoint aEndPoint); - void LogColors4(const CBitmapDevice& aDevice,TPoint aStartPoint,TInt aLen); - inline TInt ScreenNumber() {return iScreenNumber;} - TPartialRedrawType RedrawStoreTypeL(); - TBool IsFullRomL(); - void SimulateKeyDownUpWithModifiers(TInt aScanCode,TUint aModifiers); - void SimulatePointerDownUp(TInt aX, TInt aY); - void SimulateKeyDownUp(TInt aScanCode); - void SimulateKey(TRawEvent::TType aType, TInt aScanCode); - void DelayIfFullRomL(); - void SetUpMember(TSpriteMember &aMember); - void AbortL(); - void LogLeave(TInt aErr); - void CloseAllPanicWindows(); - const TSize& StdTestWindowSize(); - TInt MaxGrays() const; - TInt MaxColors() const; - TInt SaveScreen(const TDesC& aFileName); - TInt SaveScreen(const TDesC& aFileName,const TSize& aScreenSize,TDisplayMode aColorDepth); -protected: - void UpdateTestResults(TInt aNoOfTest, TInt aNoOfTestPass); - void SaveScreenL(const TDesC& aFileName,const TSize& aScreenSize,TDisplayMode aColorDepth); -public: - static TInt iNumberTestsPass; - static TInt iNumberTests; - TInt iState; - TInt iScreenNumber; - static TInt iScreenNo; - TTestRects iTestRects; - static TRect iNormalPointerCursorArea; - TBuf<0x40> iSubTitle; - TTestLevel iTestLevel; - static TInt iNumberOfGrpWndsOnPrimaryScreenWithZeroPriority; // Will be used in TGWHANDLE test. -protected: - CTestDriver* iDriver; -private: - TBuf<0x40> iTitle; - CTWsGraphicsBase* iTestBase; - /** - Several tests use 3 windows : one is a log window, one is a reference window - and one is the actual output of the test. All these windows have the same width which is roughly - 1/3 of the screen. They also have the same height which is roughly equal to the screen height. - */ - TSize iStdTestWindowSize; - CMinWin* iMinWin; - TInt iTestNum; - TBool iFail; // Used to trigger failures to test test code. - TInt iThreadNumber; - /** - The type of redraw store in use. Static members so that RedrawStoreTypeL computes - this value only once and then returns the cached result as this remains the same for - the entire test run. - */ - static TPartialRedrawType iRedrawType; - /** The number of greys available in the richest grey mode. */ - static TInt iMaxGrays; - /** The number of colours available in the richest supported colour mode. */ - static TInt iMaxColors; - }; - -class CTWsGraphicsBase : public CTGraphicsBase - { -public: - CTWsGraphicsBase(CTestStep* aStep); - ~CTWsGraphicsBase(); - void CreateTestBaseL(CTTMSGraphicsStep* aTmsStep); - inline CTestBase *TestBase() const {return(iTest);}; - void TestComplete(); - void LogMessage(const TText8* aFile,TInt aLine,TRefByValue aFmt,...); - TInt GetScreenFromIni() const; -protected: - void CheckRect(TPoint aPos1,TPoint aPos2,TSize aSize, const TDesC *aErrorMsg=NULL); - void CheckRect(TPoint aPos1,TPoint aPos2,TSize aSize, const TDesC &aErrorMsg); - void CheckRectNoMatch(TPoint aPos1,TPoint aPos2,TSize aSize, const TDesC *aErrorMsg=NULL); - void CheckRectNoMatch(TPoint aPos1,TPoint aPos2,TSize aSize, const TDesC &aErrorMsg); - void CheckRect(CTBaseWin *aWin1,CTBaseWin *aWin2, const TDesC *aErrorMsg=NULL); - void CheckRect(CTBaseWin *aWin1,CTBaseWin *aWin2, const TDesC &aErrorMsg); - void CheckRectNoMatch(CTBaseWin *aWin1,CTBaseWin *aWin2, const TDesC *aErrorMsg=NULL); - void CheckRectNoMatch(CTBaseWin *aWin1,CTBaseWin *aWin2, const TDesC &aErrorMsg); - TBool CheckRect(CTBaseWin *aWin1,CTBaseWin *aWin2,const TRect &aRect, const TDesC *aErrorMsg=NULL); - TBool CheckRect(CTBaseWin *aWin1,CTBaseWin *aWin2,const TRect &aRect, const TDesC &aErrorMsg); - void CheckRectNoMatch(CTBaseWin *aWin1,CTBaseWin *aWin2,const TRect &aRect, const TDesC *aErrorMsg=NULL); - void CheckRectNoMatch(CTBaseWin *aWin1,CTBaseWin *aWin2,const TRect &aRect, const TDesC &aErrorMsg); - TBool CompareWindows(const TDesC *aErrorMsg=NULL); - TBool CompareWindows(const TDesC &aErrorMsg); - void CompareWindows(const TRect &aRect, const TDesC *aErrorMsg=NULL); - void CompareWindows(const TRect &aRect, const TDesC &aErrorMsg); - void CompareWindowsSoftFailWinscw(const TText8* aFile, TInt aLine); - const TSize& StdTestWindowSize(); - TInt MaxGrays() const; - TInt MaxColors() const; -private: - TBool CheckRetValue(TBool aPass,const TDesC* aErrorMsg,const TDesC& aErrorFunction); -protected: - CTestBase* iTest; - CTTMSGraphicsStep* iTmsStep; - }; - -class TestWindowGroup : public CTWindowGroup - { -public: - TestWindowGroup(CTClient *aClient); - void BecomeOwning(); - void KeyL(const TKeyEvent &aKey,const TTime &aTime); - void KeyDownL(const TKeyEvent &aKey,const TTime &aTime); - void KeyUpL(const TKeyEvent &aKey,const TTime &aTime); - }; - -class TestClient : public CTClient - { -public: - TestClient(); - ~TestClient(); - void ConstructL(); // virtual from CTClient - void KeyL(const TKeyEvent &aKey,const TTime &aTime); - void Shutdown(); - inline CTestDriver* Driver(); - TBool WaitForEvent(); - TBool IsEventWaiting(); - void LogAvailableScreenModeL(); - void TestWsSetBufferSizeL(); - void TestWsSetMaxBufferSizeL(); - inline LogWindow& StdLogWindow() {return *iStdLogWindow;} - void SetTestClientScreenMode(TInt aMode); - void UpdateTestClientScreenMode(); -public: - RArray iScreenModes; - -private: - /** - Several tests use 3 windows : one is a log window, one is a reference window - and one is the actual output of the test. This member is the log window. - */ - LogWindow* iStdLogWindow; - CTestDriver* iDriver; - }; - -class TThreadStartUp - { -public: - TThreadStartUp() :iInitFunction(0), iParam(0) {} - TThreadStartUp(TThreadFunction aInitFunction,TAny* aParam) :iInitFunction(aInitFunction), iParam(aParam) {} -public: - TThreadFunction iInitFunction; //The call to this fn will prepare a cleanup stack, but this function should not leave. - TAny* iParam; - }; - -#if defined(__WINS__) - const TOwnerType KOwnerType=EOwnerThread; -#else - const TOwnerType KOwnerType=EOwnerProcess; -#endif - -typedef TBuf<32> TBufArg; - -class CProcess : public CBase - { -public: - enum - { - eProcessPriortyTest, - eProcessKeyTest, - eProcessDirectTest, - eProcessMultiDisplayTest, - eNumProcessCalls //Must be last one - }; - struct TInitialFunction - { - inline TInitialFunction(const TDesC& aParam,TThreadFunction aFunction) :iParam(aParam), iFunction(aFunction) {} - TBuf<16> iParam; - TThreadFunction iFunction; - }; -public: - static TInt Start(const TWinCommand& aParam); - static CProcess* NewL(TInt aFunctionNo,TInt aScreenNumber=KDefaultScreen); - static CProcess* NewTL(TInt aFunctionNo,TInt aScreenNumber=KDefaultScreen,TRequestStatus* aClientRequestStatus = NULL); - static CProcess* NewThreadL(const TDesC& aName,TThreadFunction aFunction,TThreadStartUp* aPtr - ,TRequestStatus* aStatus); - static CProcess* NewThreadL(const TDesC& aName,TThreadStartUp* aPtr); - static CProcess* NewThreadRendezvousL(const TDesC& aName,TThreadFunction aFunction,TThreadStartUp* aPtr,TRequestStatus* aLogonStatus,TRequestStatus& aRendezvousStatus); - static CProcess* NewThreadRendezvousL(const TDesC& aName,TThreadStartUp* aPtr,TRequestStatus& aRendezvousStatus); - - static CProcess* NewSimpleThreadL(const TDesC& aName,TThreadStartUp* aPtr,TRequestStatus* aStatus=NULL); - void ConstructL(TInt aFunctionNo,TInt aScreenNumber=KDefaultScreen); - void ConstructTL(TInt aFunctionNo,TInt aScreenNumber=KDefaultScreen,TRequestStatus* aStatus=NULL); - void ConstructL(const TDesC& aName,TThreadFunction aFunction,TThreadStartUp* aPtr,TRequestStatus* aStatus); - void ConstructRendezvousL(const TDesC& aName,TThreadFunction aFunction,TThreadStartUp* aPtr,TRequestStatus* aLogonStatus,TRequestStatus& aRendezvousStatus); - - ~CProcess(); - void Logon(TRequestStatus& aStatus) const; - void Terminate(TInt aReason); - TBool StillAlive(); - void LeaveIfDied(); - static TBool ProcessDied(TInt aScreenNo=KDefaultScreen); -private: - enum - { - eOtherCreated=0x0001, - eThreadCreated=0x0002, - }; -private: - static TInt ThreadInit(TAny *aPtr); - static void InitialiseL(TThreadStartUp* aPtr); - static TInt SimpleThreadInit(TAny *aPtr); - void Close(); - static void GetProcArg(const TWinCommand& aParam,TBufArg& aProcArg); - static void GetScreenArg(const TWinCommand& aParam, TInt& aScreenArg); - -private: - TUint iCreated; - RProcess iOther; - RThread iThread; - static TInitialFunction iFunctions[eNumProcessCalls]; - }; - -GLREF_D TestWindow* BaseWin; -GLREF_D TestWindow* TestWin; -GLREF_D TestClient* TheClient; -GLREF_D CWindowGc* TheGc; - -GLREF_C void AutoPanic(TInt aPanic); -GLREF_C void CleanUpWindow(TAny *aWindow); -GLREF_C void PushWindowL(RWindowTreeNode *aWindow); -GLREF_C TBool OpacityAndAlphaSupportedL(); -GLREF_C TInt TransparencySupportedL(); -GLREF_C TInt CheckScalingSupportedOrNot(); -GLREF_C TBool CheckNonZeroOriginsSupportedOrNot(); -GLREF_C TPoint PhysicalToLogical(TPoint aPhysicalPtMinusOrigin,TSize aScale); -GLREF_C TPtrC DisplayModeAsString(TDisplayMode aMode); -GLREF_C TBool LossyCheckBlankBitmap(const CFbsBitmap& aBitmap, const TRect aArea, const TRgb aCheckColor, TBool aLossyCompare=ETrue); -GLREF_C TBool LossyCompareBitmap(const CFbsBitmap& aBitmap1, const CFbsBitmap& aBitmap2, const TRect aCompareRect, TBool aLossyCompare=ETrue); -GLDEF_C TBool LossyCompareBitmapRecord(CFbsBitmap& aBitmap1, CFbsBitmap& aBitmap2, const TRect aCompareRect, TBool aLossyCompare, TInt& aPixelsDifferent, CTestExecuteLogger& aLogger); -GLREF_C TBool LossyCheckBlankWindow(const CWsScreenDevice& aScreen, CFbsBitmap& aBitmap, const TRect aArea, const TRgb aCheckColor); -GLREF_C TBool LossyCompareWindow(const CWsScreenDevice& aScreen, CFbsBitmap& aBitmap1, CFbsBitmap& aBitmap2, const TRect aCompareRect); - -#define LogText(S) {_LIT(String__LINE__,S); Logger.Log(String__LINE__);} -#define LogFormat(S) {Logger.Log(S);} - -inline CTestDriver* CTestBase::Driver() - { - return iDriver; - } - -class CTransWindow : public CBlankWindow - { -public: - static CTransWindow* NewL(RPointerArray& aWindows,TRgb aColor,TRect aPos); - static CTransWindow* NewL(CTWinBase* aParent,TRgb aColor,TRect aPos,TDisplayMode* aDisplayMode); - static CTransWindow* NewL(CTWinBase* aParent,TRgb aColor,TDisplayMode* aDisplayMode); - void ToggleVisibility(); - static void SetOrdinal(RPointerArray& aWindows,TInt aOldPos,TInt aNewPos); - inline TRgb Color() {return iCol;} - inline TBool IsVisible() {return iVisible;} - void SetShadowDisabled(TBool aState); - inline TBool IsShadowing() {return iShadowing;} - inline TBool ShadowHeight() {return iShadowHight;} - inline void SetPosOffset(TPoint aOffset) {iPosOffset=aOffset;} - virtual void Draw(); - void SetDrawOpaque(TBool aDrawOpaque) { iDrawOpaque = aDrawOpaque; } - TBool DrawOpaque() const { return iDrawOpaque; } - //Virtual functions from CTWinBase overridden in CTBaseWin - void AdjustShadow(TInt aAdjust); - TPoint Position() const; - inline TInt TransparentError() {return iError;} -private: - CTransWindow(TRgb aColor) :CBlankWindow(aColor), iVisible(ETrue) {} - //Virtual function from CTBaseWin - void InitWin(); -private: - TBool iVisible; - TBool iShadowing; - TBool iDrawOpaque; - TInt iShadowHight; - TPoint iPosOffset; - TInt iError; - }; - -class CMinWin : public CBase - { -public: - CMinWin(TInt aScreenNo); - ~CMinWin(); - void ConstructL(); - void Draw(const TRect& aRect); -private: - RWsSession iWs; - RWindow iWin; - RWindowGroup iGroup; - CWsScreenDevice* iScr; - TInt iScreenNo; - TRect iRect; - CWindowGc* iGc; - }; - -class CTimeOut : public CTimer - { -public: - inline CTimeOut(): CTimer((EPriorityLow+EPriorityIdle)/2) {} - void ConstructL(); - void Start(TTimeIntervalMicroSeconds32 aInterval,TCallBack aCallBack); - //Pure virtual from CActive - void RunL(); -private: - TCallBack iCallBack; - }; - -#define COMPARE_WINDOWS_SOFTFAIL_WINSCW CompareWindowsSoftFailWinscw((TText8*)__FILE__, __LINE__) - -#define __WS_CONSTRUCT_STEP__(a) \ - CT##a##Step::CT##a##Step() \ - { \ - SetTestStepName(KT##a##Step); \ - SetLogHeapInfo(ETrue); \ - } \ - \ -CTGraphicsBase* CT##a##Step::CreateTestL() \ - { \ - CTWsGraphicsBase* test=new (ELeave) CT##a (this); \ - test->CreateTestBaseL(this);\ - return test;\ - } - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/stdpanic.h --- a/windowing/windowserver/tauto/stdpanic.h Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,64 +0,0 @@ -// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -#ifndef __STDPANIC_H__ -#define __STDPANIC_H__ - -enum TStdPluginPanic -{ - EStdPanicTemp = 0, - EStdPanicNoDisplayModeFound = 1, - EStdPanicCreatedOffScreenBitmapInWrongDimensions = 2, - EStdPanicStdRenderStageMustBeFinal = 3, - EStdPanicFlickerBufferRenderStageMustNotBeFinal = 4, - EStdPanicIniFileMissing = 5, // can't find an MWsIniFile instance - EStdPanicPreviousUiSurfaceUnregisterable = 6, - EStdPanicDuplicateUiLayer = 7, // occurs when trying to add a UI layer when another UI layer is already part of the scene - EStdPanicNonMatchingRemovalOfUiLayer = 8, // occurs when removing a UI layer, when it's not the current UI layer - EStdPanicUiSurfaceIsNull = 9, // occurs when the UI surface is NULL - EStdPanicScreenDeviceMissing = 10, // can't get MWsScreenDevice from the next render stage - EStdPanicCompositionContextMissing = 11, // can't get MWsCompositionContext from the next render stage - EStdPanicPopGcSettings = 12, // problem when popping gc settings, previously saved - EStdPanicDrawCommandsInvalidState = 13, //The draw commands state doesn't match with the action that is occuring - EStdPanicInvalidCursorType = 14, // invalid cursor - EStdPanicRegionError = 15, //Region is not NULL and TRegion::CheckError() has returned ETrue, or validation of region state has failed - EStdPanicBadBeginEndSequence = 16, // End() has been called without corresponding Begin(), or Begin() has been called twice. - EStdPanicRedrawNotCompleted = 17, // A redraw has been requested before the previous redraw has completed. - EStdPanicNoContext = 18, // Graphics context from the next rendering stage is not available -}; - -void Panic(TStdPluginPanic aPanic); - -#ifdef _DEBUG -#define STD_ASSERT_DEBUG(c, p) \ - do { \ - if(!(c)) \ - { \ - Panic(p); \ - } \ - } while (EFalse) -#else -#define STD_ASSERT_DEBUG(c, p) -#endif //_DEBUG - -#define STD_ASSERT_ALWAYS(c, p) \ - do { \ - if(!(c)) \ - { \ - Panic(p); \ - } \ - } while (EFalse) - -#endif //__STDPANIC_H__ diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/symball.gif Binary file windowing/windowserver/tauto/symball.gif has changed diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/tadvancedpointerevent.cpp --- a/windowing/windowserver/tauto/tadvancedpointerevent.cpp Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,411 +0,0 @@ -// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Advanced pointer event unit tests -// -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include "tadvancedpointerevent.h" - -CTAdvancedPointerEvent::CTAdvancedPointerEvent(CTestStep* aStep) - : CTWsGraphicsBase(aStep) - {} - -CTAdvancedPointerEvent::~CTAdvancedPointerEvent() - {} - -void CTAdvancedPointerEvent::TestPointerEventInit() - { - // Test size of class with hard coded values to prevent regression failure - TEST(sizeof(TPointerEvent) == 24); - - TPointerEvent ptrEvent1 = TPointerEvent(); - ptrEvent1.iType = TPointerEvent::EButton1Down; - TPoint initCoords(10,10); - ptrEvent1.iPosition = initCoords; - ptrEvent1.iParentPosition = initCoords; - ptrEvent1.iModifiers = 0; - - // Construct two TPointerEvent objects. The first using default constructor, the second using the copy constructor. T - { - TPointerEvent ptrEvent2 = TPointerEvent(ptrEvent1); - TEST(0==Mem::Compare(reinterpret_cast(&ptrEvent1),sizeof(TPointerEvent),reinterpret_cast(&ptrEvent2),sizeof(TPointerEvent))); - } - - { - TPointerEvent ptrEvent2(TPointerEvent::EButton1Down, 0, initCoords, initCoords); - TEST(0==Mem::Compare(reinterpret_cast(&ptrEvent1),sizeof(TPointerEvent),reinterpret_cast(&ptrEvent2),sizeof(TPointerEvent))); - } - } - -void AdvancedPointerInit(TWsEvent& aEvent1, TWsEvent& aEvent2, const TPointerEvent::TType aType, const TPoint3D& aPoint3D, const TUint8 aPointerNumber) - { - // init first event - TAdvancedPointerEvent& ptrEvent = *aEvent1.Pointer(); - ptrEvent.iType = aType; - ptrEvent.iModifiers = EModifierAdvancedPointerEvent; // done implicitly by TAdvancedPointerEvent::Init method - ptrEvent.iPosition.iX = aPoint3D.iX; - ptrEvent.iPosition.iY = aPoint3D.iY; - aEvent1.SetPointerNumber(aPointerNumber); - aEvent1.SetPointerZ(aPoint3D.iZ); - - // init 2nd event - aEvent2.InitAdvancedPointerEvent(aType,0,aPoint3D,aPointerNumber); - } - -void CTAdvancedPointerEvent::TestAdvancedPointerInit() - { - // Test size of class with hard coded values to prevent regression failure - TEST(sizeof(TAdvancedPointerEvent) == 32); - - TWsEvent event1; - TWsEvent event2; - - // low value coords, lowest value event type - { - TPoint3D point3D(1,2,3); - AdvancedPointerInit(event1, event2, TPointerEvent::EButton1Down, point3D, 1); - } - TEST(0==Mem::Compare(reinterpret_cast(&event1),sizeof(TWsEvent),reinterpret_cast(&event2),sizeof(TWsEvent))); - - // high value coords, highest value event type and pointer number - { - TPoint3D point3D(KMaxTInt, KMaxTInt-1, KMaxTInt-3); - AdvancedPointerInit(event1, event2, TPointerEvent::EOutOfRange, point3D, KMaxTUint8); - } - TEST(0==Mem::Compare(reinterpret_cast(&event1),sizeof(TWsEvent),reinterpret_cast(&event2),sizeof(TWsEvent))); - - // high negative value coords, highest value event type and pointer number - { - TPoint3D point3D(KMinTInt, KMinTInt+1, KMinTInt+3); - AdvancedPointerInit(event1, event2, TPointerEvent::EOutOfRange, point3D, KMaxTUint8); - } - TEST(0==Mem::Compare(reinterpret_cast(&event1),sizeof(TWsEvent),reinterpret_cast(&event2),sizeof(TWsEvent))); - } - -void CTAdvancedPointerEvent::TestAdvancedPointerGetPointerId() - { - TWsEvent event; - TAdvancedPointerEvent& ptrEvent = *event.Pointer(); - const TPoint3D point3D(1,2,3); - const TUint8 MaxLikelyCommonPointerNumber = 10; - - // Likely Common Values - TUint8 pointerNumber = 0; - for(;pointerNumber<=MaxLikelyCommonPointerNumber;pointerNumber++) - { - event.InitAdvancedPointerEvent(TPointerEvent::EMove,0,point3D,pointerNumber); - TEST(ptrEvent.PointerNumber()==pointerNumber); - } - - // mid-range value - pointerNumber = 127; - event.InitAdvancedPointerEvent(TPointerEvent::EMove,0,point3D,pointerNumber); - TEST(ptrEvent.PointerNumber()==pointerNumber); - - // highest value - pointerNumber = 255; // KMaxTUint8 is there was one defined. - event.InitAdvancedPointerEvent(TPointerEvent::EMove,0,point3D,pointerNumber); - TEST(ptrEvent.PointerNumber()==pointerNumber); - } - -/** helper method for TestAdvancedPointerGetPressureAndProximity() */ -void CTAdvancedPointerEvent::TestAdvancedPointerGetPressureAndProximity(const TPoint3D aPoint3D) - { - TWsEvent event; - event.InitAdvancedPointerEvent(TPointerEvent::EMove, 0, aPoint3D, 0); - TAdvancedPointerEvent ptrEvent = *event.Pointer(); - const TPoint3D positionAndPressure3D = ptrEvent.PositionAndPressure3D(); - TEST(0==Mem::Compare(reinterpret_cast(&aPoint3D),sizeof(TPoint3D),reinterpret_cast(&positionAndPressure3D),sizeof(TPoint3D))); - TInt proximityAndPressure = ptrEvent.ProximityAndPressure(); - TEST(aPoint3D.iZ==proximityAndPressure); - } - -void CTAdvancedPointerEvent::TestAdvancedPointerGetPressureAndProximity() - { - { - // middle value - TPoint3D point3D(0,0,0); - TestAdvancedPointerGetPressureAndProximity(point3D); - } - { - // Typical value - TPoint3D point3D(10,9,8); - TestAdvancedPointerGetPressureAndProximity(point3D); - } - { - // Typical value - TPoint3D point3D(10,9,-8); - TestAdvancedPointerGetPressureAndProximity(point3D); - } - { - // max values - TPoint3D point3D(KMaxTInt-2,KMaxTInt-1,KMaxTInt); - TestAdvancedPointerGetPressureAndProximity(point3D); - } - { - // min values - TPoint3D point3D(KMinTInt+2,KMinTInt+1,KMinTInt); - TestAdvancedPointerGetPressureAndProximity(point3D); - } - } - -void CTAdvancedPointerEvent::TestAdvancedPointerGetPressure() - { - { - // middle value - const TPoint3D point3D(0,0,0); - TWsEvent event; - event.InitAdvancedPointerEvent(TPointerEvent::EMove, 0, point3D, 0); - TAdvancedPointerEvent ptrEvent = *event.Pointer(); - const TPoint3D pressure3D = ptrEvent.Pressure3D(); - TEST(0==Mem::Compare(reinterpret_cast(&point3D),sizeof(TPoint3D),reinterpret_cast(&pressure3D),sizeof(TPoint3D))); - TInt pressure = ptrEvent.Pressure(); - TEST(point3D.iZ==pressure); - } - { - // Typical value - const TPoint3D point3D(10,9,8); - TWsEvent event; - event.InitAdvancedPointerEvent(TPointerEvent::EMove, 0, point3D, 0); - TAdvancedPointerEvent ptrEvent = *event.Pointer(); - const TPoint3D pressure3D = ptrEvent.Pressure3D(); - TEST(0==Mem::Compare(reinterpret_cast(&point3D),sizeof(TPoint3D),reinterpret_cast(&pressure3D),sizeof(TPoint3D))); - TInt pressure = ptrEvent.Pressure(); - TEST(point3D.iZ==pressure); - } - { - // max value - const TPoint3D point3D(KMaxTInt-2,KMaxTInt-1,KMaxTInt); - TWsEvent event; - event.InitAdvancedPointerEvent(TPointerEvent::EMove, 0, point3D, 0); - TAdvancedPointerEvent ptrEvent = *event.Pointer(); - const TPoint3D pressure3D = ptrEvent.Pressure3D(); - TEST(0==Mem::Compare(reinterpret_cast(&point3D),sizeof(TPoint3D),reinterpret_cast(&pressure3D),sizeof(TPoint3D))); - TInt pressure = ptrEvent.Pressure(); - TEST(point3D.iZ==pressure); - } - { - // min value - TPoint3D point3D(KMinTInt+2,KMinTInt+1,KMinTInt); - TWsEvent event; - event.InitAdvancedPointerEvent(TPointerEvent::EMove, 0, point3D, 0); - TAdvancedPointerEvent ptrEvent = *event.Pointer(); - const TPoint3D pressure3D = ptrEvent.Pressure3D(); - point3D.iZ=0; // pressure can't be negative - TEST(0==Mem::Compare(reinterpret_cast(&point3D),sizeof(TPoint3D),reinterpret_cast(&pressure3D),sizeof(TPoint3D))); - TInt pressure = ptrEvent.Pressure(); - TEST(0==pressure); - } - } - -void CTAdvancedPointerEvent::TestAdvancedPointerGetPosition() - { - { - // middle value - const TPoint3D point3D(0,0,0); - TWsEvent event; - event.InitAdvancedPointerEvent(TPointerEvent::EMove, 0, point3D, 0); - TAdvancedPointerEvent ptrEvent = *event.Pointer(); - const TPoint3D position3D = ptrEvent.Position3D(); - TEST(0==Mem::Compare(reinterpret_cast(&point3D),sizeof(TPoint3D),reinterpret_cast(&position3D),sizeof(TPoint3D))); - TInt proximity = ptrEvent.Proximity(); - TEST(point3D.iZ==proximity); - } - { - // typical value - const TPoint3D point3D(10,9,-8); - TWsEvent event; - event.InitAdvancedPointerEvent(TPointerEvent::EMove, 0, point3D, 0); - TAdvancedPointerEvent ptrEvent = *event.Pointer(); - const TPoint3D position3D = ptrEvent.Position3D(); - TEST(0==Mem::Compare(reinterpret_cast(&point3D),sizeof(TPoint3D),reinterpret_cast(&position3D),sizeof(TPoint3D))); - TInt proximity = ptrEvent.Proximity(); - TEST(point3D.iZ==proximity); - } - { - // highest value - TPoint3D point3D(KMaxTInt-2,KMaxTInt-1,KMaxTInt); - TWsEvent event; - event.InitAdvancedPointerEvent(TPointerEvent::EMove, 0, point3D, 0); - TAdvancedPointerEvent ptrEvent = *event.Pointer(); - const TPoint3D position3D = ptrEvent.Position3D(); - point3D.iZ=0; // proximity can't be positive - TEST(0==Mem::Compare(reinterpret_cast(&point3D),sizeof(TPoint3D),reinterpret_cast(&position3D),sizeof(TPoint3D))); - TInt proximity = ptrEvent.Proximity(); - TEST(0==proximity); - } - { - // lowest value - const TPoint3D point3D(KMinTInt+2,KMinTInt+1,KMinTInt); - TWsEvent event; - event.InitAdvancedPointerEvent(TPointerEvent::EMove, 0, point3D, 0); - TAdvancedPointerEvent ptrEvent = *event.Pointer(); - const TPoint3D position3D = ptrEvent.Position3D(); - TEST(0==Mem::Compare(reinterpret_cast(&point3D),sizeof(TPoint3D),reinterpret_cast(&position3D),sizeof(TPoint3D))); - TInt proximity = ptrEvent.Proximity(); - TEST(point3D.iZ==proximity); - } - } - -void CTAdvancedPointerEvent::TestPointerEventCopying() - { - TWsEvent event; - event.InitAdvancedPointerEvent(TPointerEvent::EMove, 0, TPoint3D(2,3,4),1); - TPointerEvent testPointerEvent; - testPointerEvent.iModifiers =0; - testPointerEvent.iParentPosition=TPoint(0,0); - testPointerEvent.iPosition = TPoint(2,3); - testPointerEvent.iType=TPointerEvent::EMove; - - // TPointerEvent to TPointerEvent - // Copy Constructor - { - TPointerEvent* pointerEventPtr = event.Pointer(); - TPointerEvent pointerEvent = *pointerEventPtr; - TEST(0==Mem::Compare(reinterpret_cast(&pointerEvent),sizeof(TPointerEvent),reinterpret_cast(&testPointerEvent),sizeof(TPointerEvent))); - } - // Assignment operator - { - TPointerEvent* pointerEventPtr = event.Pointer(); - TPointerEvent pointerEvent; - pointerEvent = *pointerEventPtr; - TEST(0==Mem::Compare(reinterpret_cast(&pointerEvent),sizeof(TPointerEvent),reinterpret_cast(&testPointerEvent),sizeof(TPointerEvent))); - } - // TAdvancedPointerEvent to TPointerEvent - // Copy Constructor - { - TAdvancedPointerEvent* advancedPointerEventPtr = event.Pointer(); - TPointerEvent pointerEvent = *advancedPointerEventPtr; - TEST(0==Mem::Compare(reinterpret_cast(&pointerEvent),sizeof(TPointerEvent),reinterpret_cast(&testPointerEvent),sizeof(TPointerEvent))); - } - // Assignment operator - { - TAdvancedPointerEvent* advancedPointerEventPtr = event.Pointer(); - TPointerEvent pointerEvent; - pointerEvent = *advancedPointerEventPtr; - TEST(0==Mem::Compare(reinterpret_cast(&pointerEvent),sizeof(TPointerEvent),reinterpret_cast(&testPointerEvent),sizeof(TPointerEvent))); - } - - // TPointerEvent to TPointerEvent - // Copy Method - { - TPointerEvent* pointerEventPtr = event.Pointer(); - TPointerEvent pointerEvent; - pointerEvent.Copy(*pointerEventPtr); - TEST(0==Mem::Compare(reinterpret_cast(&pointerEvent),sizeof(TPointerEvent),reinterpret_cast(&testPointerEvent),sizeof(TPointerEvent))); - } - - // TAdvancedPointerEvent to TPointerEvent - // Copy Constructor - { - TAdvancedPointerEvent* advancedPointerEventPtr = event.Pointer(); - TPointerEvent pointerEvent; - pointerEvent.Copy(*advancedPointerEventPtr); - TEST(0==Mem::Compare(reinterpret_cast(&pointerEvent),sizeof(TPointerEvent),reinterpret_cast(&testPointerEvent),sizeof(TPointerEvent))); - } - - // Assignment operator - { - TAdvancedPointerEvent* advancedPointerEventPtr = event.Pointer(); - TAdvancedPointerEvent advancedPointerEventPtr2; - advancedPointerEventPtr2 = *advancedPointerEventPtr; - TEST(0==Mem::Compare(reinterpret_cast(&advancedPointerEventPtr2),sizeof(TAdvancedPointerEvent),reinterpret_cast(event.Pointer()),sizeof(TAdvancedPointerEvent))); - } - } - -void CTAdvancedPointerEvent::RunTestCaseL(TInt /*aCurTestCase*/) - { - _LIT(KTest1,"PointerEventInit"); - _LIT(KTest2,"AdvancedPointerEventInit"); - _LIT(KTest3,"PointerEventCopying"); - _LIT(KTest4,"AdvancedPointerEventGetPointerId"); - _LIT(KTest5,"AdvancedPointerEventGetPressureAndProximity"); - _LIT(KTest6,"AdvancedPointerEventGetPressure"); - _LIT(KTest7,"AdvancedPointerEventGetPosition"); - - ((CTAdvancedPointerEventStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); - switch(++iTest->iState) - { - case 1: -/** -@SYMTestCaseID GRAPHICS-WSERV-0542 -*/ - ((CTAdvancedPointerEventStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0542")); - iTest->LogSubTest(KTest1); - TestPointerEventInit(); - break; - case 2: -/** -@SYMTestCaseID GRAPHICS-WSERV-0543 -*/ - ((CTAdvancedPointerEventStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0543")); - iTest->LogSubTest(KTest2); - TestAdvancedPointerInit(); - break; - case 3: -/** -@SYMTestCaseID GRAPHICS-WSERV-0544 -*/ - ((CTAdvancedPointerEventStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0544")); - iTest->LogSubTest(KTest3); - TestPointerEventCopying(); - break; - case 4: -/** -@SYMTestCaseID GRAPHICS-WSERV-0545 -*/ - ((CTAdvancedPointerEventStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0545")); - iTest->LogSubTest(KTest4); - TestAdvancedPointerGetPointerId(); - break; - case 5: -/** -@SYMTestCaseID GRAPHICS-WSERV-0546 -*/ - ((CTAdvancedPointerEventStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0546")); - iTest->LogSubTest(KTest5); - TestAdvancedPointerGetPressureAndProximity(); - break; - case 6: -/** -@SYMTestCaseID GRAPHICS-WSERV-0547 -*/ - ((CTAdvancedPointerEventStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0547")); - iTest->LogSubTest(KTest6); - TestAdvancedPointerGetPressure(); - break; - case 7: -/** -@SYMTestCaseID GRAPHICS-WSERV-0548 -*/ - ((CTAdvancedPointerEventStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0548")); - iTest->LogSubTest(KTest7); - TestAdvancedPointerGetPosition(); - break; - default: - ((CTAdvancedPointerEventStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - ((CTAdvancedPointerEventStep*)iStep)->CloseTMSGraphicsStep(); - TestComplete(); - break; - } - ((CTAdvancedPointerEventStep*)iStep)->RecordTestResultL(); - } - -__WS_CONSTRUCT_STEP__(AdvancedPointerEvent) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/tadvancedpointerevent.h --- a/windowing/windowserver/tauto/tadvancedpointerevent.h Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,63 +0,0 @@ - -// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// tadvancedpionter.h -// -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef tadvancedpointerevent_h -#define tadvancedpointerevent_h - -#include "w32std.h" -#include "AUTO.H" -#include "../tlib/testbase.h" -#include "TGraphicsHarness.h" - -class CTAdvancedPointerEvent : public CTWsGraphicsBase - { -public: - CTAdvancedPointerEvent(CTestStep* aStep); - virtual ~CTAdvancedPointerEvent(); -protected: - //from CTGraphicsStep - virtual void RunTestCaseL(TInt aCurTestCase); -private: - void TestPointerEventInit(); - void TestAdvancedPointerInit(); - void TestAdvancedPointerGetPointerId(); - void TestAdvancedPointerGetPressureAndProximity(); - void TestAdvancedPointerGetPressureAndProximity(const TPoint3D aPoint3D); - void TestAdvancedPointerGetPressure(); - void TestAdvancedPointerGetPosition(); - void TestPointerEventCopying(); - }; - -class CTAdvancedPointerEventStep : public CTGraphicsStep - { -public: - CTAdvancedPointerEventStep(); -protected: - //from CTGraphicsStep - virtual CTGraphicsBase* CreateTestL(); - }; - -_LIT(KTAdvancedPointerEventStep,"TAdvancedPointerEvent"); - -#endif // tadvancedpointerevent_h diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/talphawin.cpp --- a/windowing/windowserver/tauto/talphawin.cpp Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1272 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Test alpha channel transparent windows -// Test that draw operations with non-opaque colours do alpha blending in EColor64K and EColor16MA display modes -// Test that alpha channel transparent windows are drawn correctly when windows move, redraw, change visibility, etc. -// In the draw operation tests, the left window draws opaque pink on white background, the right window blends semi-transparent red on white background, -// and the results are compared. -// In the transparent window tests, the right window contains several transparent windows, which are moved, redrawn, visibility changed, etc, -// the left window contains a single window in which we draw what we expect the right window to look like. The results are compared. -// In each case, the left and right windows should be identical -// -// - - -#include "TALPHAWIN.H" - -enum - { - EOpDrawRect, - EOpDrawLine, - EOpDrawEllipse, - EOpDrawText, - EOpDrawTextVertical, - EOpDrawTextAntiAliased, - EOpBitBlt, - EOpBitBltMasked, - ENumDrawOps - }; - - -enum - { - ERed = 0x1, - EGreen = 0x2, - EBlue = 0x4, - - EAlphaTransparency = 0x8, - ETransparencyFactor = 0x10, - // defaults to non-transparent - - EOpaque = 0x20, - ETransparent = 0x40, - // defaults to semi-transparent - - EModeColor64K = 0x80, - EModeColor16MA = 0x100, - // defaults to 64k - - EInvisible = 0x200, - - EActive = 0xf000000 - }; - - -TRgb ColourFromDrawState(TInt aDrawState) - { - TInt red = (aDrawState & ERed) ? 255 : 0; - TInt green = (aDrawState & EGreen) ? 255 : 0; - TInt blue = (aDrawState & EBlue) ? 255 : 0; - TInt alpha = 128; - if (aDrawState & EOpaque) - alpha = 255; - if (aDrawState & ETransparent) - alpha = 0; - return TRgb(red, green, blue, alpha); - } - - - -// -// CTAlphaWinTest -// - -CTAlphaWin::CTAlphaWin(CTestStep* aStep): - CTWsGraphicsBase(aStep) - { - } - -CTAlphaWin::~CTAlphaWin() - { - iTestWin.DeleteAll(); - delete iRefWin; - } - -void CTAlphaWin::ConstructL() - { - if(TransparencySupportedL() == KErrNotSupported) - return; - - TSize winSize = BaseWin->Size(); - - iTestWin[0] = CTAlphaWindow::NewL(this, TestWin, TPoint(0,0), winSize, ERed | EGreen | EBlue | EOpaque); - iTestWin[1] = CTAlphaWindow::NewL(this, TestWin, TPoint(0,0), TSize(winSize.iWidth/2, winSize.iHeight/2), ERed | EAlphaTransparency); - iTestWin[2] = CTAlphaWindow::NewL(this, TestWin, TPoint(winSize.iWidth/3,0), TSize(winSize.iWidth/2, winSize.iHeight/2), EGreen | EAlphaTransparency); - iTestWin[3] = CTAlphaWindow::NewL(this, TestWin, TPoint(winSize.iWidth/6, winSize.iHeight/3), TSize(winSize.iWidth/2, winSize.iHeight/2), EBlue | EAlphaTransparency); - iTestWin[4] = CTAlphaWindow::NewL(this, TestWin, TPoint(winSize.iWidth/4,winSize.iHeight/6), TSize(winSize.iWidth/3,winSize.iHeight/3), ERed | EGreen | EBlue | EAlphaTransparency | ETransparent); - - iRefWin = CTAlphaRefWin::NewL(BaseWin, TPoint(0,0), winSize, iTestWin); - //Clearing the windows - BaseWin->ClearWin(); - TestWin->ClearWin(); - } - -void CTAlphaWin::ConfigureDisplayModes(TDisplayMode aRequiredMode = EColor16M) - { - TInt i; - for (i=0; i<5; i++) - { - iTestWin[i]->BaseWin()->SetRequiredDisplayMode(aRequiredMode); - } - iRefWin->BaseWin()->SetRequiredDisplayMode(aRequiredMode); - } - - -void CTAlphaWin::TestSemiTransparentDrawingL() - { - TSize winSize = BaseWin->Size(); - - // In this window, we draw opaque pink - CTDrawOpWin* drawWin = CTDrawOpWin::NewL(this, BaseWin, TPoint(0,0), winSize, TRgb(255,127,127,255)); - - // In this window, we blend semi-transparent red - CTDrawOpWin* blendWin = CTDrawOpWin::NewL(this, TestWin, TPoint(0,0), winSize, TRgb(255,0,0,128)); - - const TInt tolerance = 9;//8 - wouldn't be enough!! The defect DEF112334 was raised - for (TInt i=EOpDrawRect; iSetDrawOp(i); - blendWin->SetDrawOp(i); - drawWin->DrawNow(); - blendWin->DrawNow(); - TheClient->Flush(); - TheClient->WaitForRedrawsToFinish(); - - if((i == EOpDrawTextAntiAliased) && (TheClient->iScreen->DisplayMode() == EColor16MA) || (TheClient->iScreen->DisplayMode() == EColor16MAP)) - { - TSize winSize=BaseWin->Size(); - TRect rect1(BaseWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),winSize); - TRect rect2(TestWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),winSize); - - CheckRectL(rect1, rect2, winSize, TheClient->iScreen->DisplayMode(), tolerance, _L("CTAlphaWin::TestSemiTransparentDrawingL()")); - } - else - { - CheckRect(BaseWin,TestWin,_L("CTAlphaWin::TestSemiTransparentDrawingL()")); - } - } - delete drawWin; - delete blendWin; - } - -void CTAlphaWin::TestTransparentDrawingL() - { - TSize winSize = BaseWin->Size(); - - // In this window, we draw opaque white - CTDrawOpWin* drawWin = CTDrawOpWin::NewL(this, BaseWin, TPoint(0,0), winSize, TRgb(255,255,255,255)); - - // In this window, we blend transparent red - CTDrawOpWin* blendWin = CTDrawOpWin::NewL(this, TestWin, TPoint(0,0), winSize, TRgb(255,0,0,0)); - - for (TInt i=EOpDrawRect; iSetDrawOp(i); - blendWin->SetDrawOp(i); - drawWin->DrawNow(); - blendWin->DrawNow(); - TheClient->Flush(); - TheClient->WaitForRedrawsToFinish(); - CheckRect(BaseWin,TestWin,_L("CTAlphaWin::TestTransparentDrawingL()")); - } - delete drawWin; - delete blendWin; - } - -void CTAlphaWin::CheckRectL(const TRect& aRect1, const TRect& aRect2, TSize aSize, TDisplayMode aRequiredMode, TInt aTolerance, const TDesC& aErrorMsg) - { - CFbsBitmap *bmp1 = new (ELeave) CFbsBitmap; - CleanupStack::PushL(bmp1); - User::LeaveIfError(bmp1->Create(aSize, aRequiredMode)); - - CFbsBitmap *bmp2 = new (ELeave) CFbsBitmap; - CleanupStack::PushL(bmp2); - User::LeaveIfError(bmp2->Create(aSize, aRequiredMode)); - - User::LeaveIfError(TheClient->iScreen->CopyScreenToBitmap(bmp1, aRect1)); - User::LeaveIfError(TheClient->iScreen->CopyScreenToBitmap(bmp2, aRect2)); - - TRgb *rgbBuf1=(TRgb *)User::AllocL(aSize.iWidth*sizeof(TRgb)); - TRgb *rgbBuf2=(TRgb *)User::Alloc(aSize.iWidth*sizeof(TRgb)); - if(!rgbBuf2) - { - User::Free(rgbBuf1); - User::Leave(KErrNoMemory); - } - TBool equal = ETrue; - TInt maxDeviation = 0; - for(TInt yy = 0; yy < aSize.iHeight && equal; yy++) - { - TPtr8 ptr1((TUint8 *)rgbBuf1,aSize.iWidth*sizeof(TRgb)); - bmp1->GetScanLine(ptr1, TPoint(0, yy), aSize.iWidth, ERgb); - TPtr8 ptr2((TUint8 *)rgbBuf2,aSize.iWidth*sizeof(TRgb)); - bmp2->GetScanLine(ptr2, TPoint(0, yy), aSize.iWidth, ERgb); - - TRgb *rgbBufCur1 = rgbBuf1; - TRgb *rgbBufCur2 = rgbBuf2; - for(TInt ii = 0; ii < aSize.iWidth; ii++) - { - TInt delta = Abs(rgbBufCur1->Red()-rgbBufCur2->Red()); - TInt delta1 = Abs(rgbBufCur1->Green()-rgbBufCur2->Green()); - TInt delta2 = Abs(rgbBufCur1->Blue()-rgbBufCur2->Blue()); - - if((delta > aTolerance) || (delta1 > aTolerance) || (delta2 > aTolerance)) - { - equal = EFalse; - } - TInt maxItermedia = Max(delta1, delta2); - maxItermedia = Max(maxItermedia, delta); - maxDeviation = Max(maxItermedia, maxDeviation); - - rgbBufCur1++; - rgbBufCur2++; - } - } - - User::Free(rgbBuf1); - User::Free(rgbBuf2); - - CleanupStack::PopAndDestroy(2,bmp1); - - if (!equal) - { - INFO_PRINTF3(_L("%S CheckRectA failed, max deviation %d"), &aErrorMsg, maxDeviation); - } - else if(maxDeviation) - { - INFO_PRINTF4(_L("%S CheckRectA passed with tolerance %d, max deviation %d"), &aErrorMsg, aTolerance, maxDeviation); - } - - iStep->TEST(equal); - } - -void CTAlphaWin::TestCondition() - { - // User::After(1000000);// helpful when debugging - iRefWin->DrawNow(); - TheClient->Flush(); - TheClient->WaitForRedrawsToFinish(); - CheckRect(BaseWin,TestWin,_L("CTAlphaWin::TestCondition()")); - } - -void CTAlphaWin::TestConditionL() - { - iRefWin->DrawNow(); - TheClient->Flush(); - TheClient->WaitForRedrawsToFinish(); - - const TInt tolerance = 9; - TSize winSize=BaseWin->Size(); - TRect rect1(BaseWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),winSize); - TRect rect2(TestWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),winSize); - CheckRectL(rect1, rect2, winSize, TheClient->iScreen->DisplayMode(), tolerance, _L("CTAlphaWin::TestCondition()")); - } - -void CTAlphaWin::TestInitialConfiguration() - { - if(TheClient->iScreen->DisplayMode() == EColor64K) - { - TestConditionL(); - } - else - { - TestCondition(); - } - } - -void CTAlphaWin::TestMove() - { - // Test moving windows, both in front and behind - for (TInt i = 0; i<5; i++) - { - TPoint pos = iTestWin[i]->Position(); - pos += TPoint(10,10); - iTestWin[i]->SetPos(pos); - TestCondition(); - } - for (TInt j = 0; j<5; j++) - { - TPoint pos = iTestWin[j]->Position(); - pos -= TPoint(10,10); - iTestWin[j]->SetPos(pos); - TestCondition(); - } - } - - -void CTAlphaWin::TestRedraw() - { - // Test redrawing windows, both in front and behind - for (TInt i=0; i<5; i++) - { - iTestWin[i]->DrawNow(); - TestCondition(); - } - } - - -void CTAlphaWin::TestInvisible() - { - // Test making windows visible and invisible, both in front and behind - for (TInt i=0; i<5; i++) - { - iTestWin[i]->SetVisible(EFalse); - TestCondition(); - iTestWin[i]->SetVisible(ETrue); - TestCondition(); - } - } - -void CTAlphaWin::TestChildrenL() - { - struct CTAlphaWinChildren: public TCleanupItem - { - static void Destroy(TAny* trg) - { - static_cast(trg)->DestroyChildren(); - } - CTAlphaWinChildren(CTAlphaWindow*trg): TCleanupItem(Destroy,trg) - {} - - }; - CleanupStack::PushL(CTAlphaWinChildren(iTestWin[2])); - iTestWin[2]->CreateChildrenL(3); - TestCondition(); - TestMove(); - CleanupStack::PopAndDestroy(iTestWin[2]); - } - - -void CTAlphaWin::TestAntiAliasedTextTransparentL() - { - - //Clear the screen - for (TInt i=0; i<5; i++) - { - iTestWin[i]->SetVisible(EFalse); - } - iRefWin->SetVisible(EFalse); - TheClient->iWs.Flush(); - - //Create a new test window on the left - //Create a transparent window: - TSize winSize = BaseWin->Size(); - - RWindow theWin(TestWin->Client()->iWs); - User::LeaveIfError(theWin.Construct(*(TestWin->WinTreeNode()),(TUint32)&theWin)); - - theWin.SetExtent(TPoint(0,0), winSize); - theWin.SetBackgroundColor(TRgb(127,0,255,127)); - TInt mode=theWin.SetRequiredDisplayMode(EColor16MA); - theWin.SetVisible(ETrue); - theWin.SetTransparencyAlphaChannel(); - theWin.Activate(); - TheClient->iWs.Flush(); - CleanupClosePushL(theWin); - - //get windows screen device. - CWsScreenDevice *device; - device = new (ELeave)CWsScreenDevice(TestWin->Client()->iWs);//(TheClient->iWs); - User::LeaveIfError(device->Construct(iTest->ScreenNumber())); - CleanupStack::PushL(device); - - TFontSpec fs1; - CFont *font1; - CFont *font2; - fs1.iTypeface.iName = KTestFontTypefaceName; - fs1.iHeight = 16; - fs1.iFontStyle.SetBitmapType(EDefaultGlyphBitmap); - int error = TheClient->iScreen->GetNearestFontToDesignHeightInPixels((CFont*&)font1,fs1); - if (error) - { - TheClient->iScreen->ReleaseFont(font1); - User::Panic(_L("font not created"),error); - } - fs1.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap); - error = TheClient->iScreen->GetNearestFontToDesignHeightInPixels((CFont*&)font2,fs1); - if (error) - { - TheClient->iScreen->ReleaseFont(font1); - TheClient->iScreen->ReleaseFont(font2); - User::Panic(_L("font not created"),error); - } - - CWindowGc *gc; - device->CreateContext(gc); - CleanupStack::PushL(gc); - - theWin.Invalidate(); - theWin.BeginRedraw(); - gc->Activate(theWin); - - gc->SetPenStyle( CGraphicsContext::ESolidPen ); - gc->SetPenColor( TRgb( 0, 0, 0, 127 ) ); - - //draw text for anti-aliasing needs an open font (scalable). - int typefaces = TheClient->iScreen->NumTypefaces(); - - gc->UseFont(font1); - gc->SetBrushStyle( CGraphicsContext::ENullBrush ); - gc->DrawText(_L("Test"),TPoint(10,20)); - gc->DiscardFont(); - gc->UseFont(font2); - gc->DrawText(_L("Test"),TPoint(10,60)); - gc->DiscardFont(); - - //destruction and tidying up - gc->Deactivate(); - theWin.EndRedraw(); - TheClient->iWs.Flush(); - - TheClient->iScreen->ReleaseFont(font1); - TheClient->iScreen->ReleaseFont(font2); - CleanupStack::PopAndDestroy(gc);//gc - CleanupStack::PopAndDestroy(device);//device - - //do not close the test window yet since there is a comparison - //required - - //now do the same on an off screen bitmap. Then create a window - //and put the bitmap onto it. - //create a colour bitmap - // - CFbsBitmap *bitmapOne; - bitmapOne = new (ELeave)CFbsBitmap(); - CleanupStack::PushL(bitmapOne); - User::LeaveIfError(bitmapOne->Create(winSize,static_cast(mode))); - - CFbsBitmapDevice *deviceOne=CFbsBitmapDevice::NewL(bitmapOne); - CleanupStack::PushL(deviceOne); - - CFont *font3; - CFont *font4; - fs1.iFontStyle.SetBitmapType(EDefaultGlyphBitmap); - error = TheClient->iScreen->GetNearestFontToDesignHeightInPixels((CFont*&)font3,fs1); - if (error) - { - TheClient->iScreen->ReleaseFont(font3); - User::Panic(_L("font not created"),error); - } - fs1.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap); - error = TheClient->iScreen->GetNearestFontToDesignHeightInPixels((CFont*&)font4,fs1); - if (error) - { - TheClient->iScreen->ReleaseFont(font3); - TheClient->iScreen->ReleaseFont(font4); - User::Panic(_L("font not created"),error); - } - CFbsBitGc *bGcOne = CFbsBitGc::NewL(); - CleanupStack::PushL(bGcOne); - - bGcOne->Activate(deviceOne); - - bGcOne->SetBrushStyle(CGraphicsContext::ESolidBrush); - bGcOne->SetBrushColor(TRgb(127,0,255,127)); - bGcOne->DrawRect(TRect(0,0,winSize.iWidth,winSize.iHeight)); - - bGcOne->SetPenStyle(CGraphicsContext::ESolidPen); - bGcOne->SetPenColor(TRgb(0,0,0,127)); - - bGcOne->UseFont(font3); - bGcOne->SetBrushStyle( CGraphicsContext::ENullBrush ); - bGcOne->DrawText(_L("Test"),TPoint(10,20)); - bGcOne->DiscardFont(); - bGcOne->UseFont(font4); - bGcOne->DrawText(_L("Test"),TPoint(10,60)); - bGcOne->DiscardFont(); - //destruction and tidying up - //measure the text - CFont::TMeasureTextOutput textSize; - font4->MeasureText(_L("Test"),NULL,&textSize); - - TheClient->iScreen->ReleaseFont(font3); - TheClient->iScreen->ReleaseFont(font4); - - //display at the left - RWindow refWin(BaseWin->Client()->iWs); - CleanupClosePushL(refWin); - User::LeaveIfError(refWin.Construct(*(BaseWin->WinTreeNode()),(TUint32)&refWin)); - - refWin.SetExtent(TPoint(0,0), winSize); - refWin.SetRequiredDisplayMode(static_cast(mode)); - refWin.SetVisible(ETrue); - refWin.SetTransparencyAlphaChannel(); - refWin.Activate(); - TheClient->iWs.Flush(); - - //a gc for the ref win - CWsScreenDevice *refDevice; - refDevice = new (ELeave)CWsScreenDevice(BaseWin->Client()->iWs); - User::LeaveIfError(refDevice->Construct(iTest->ScreenNumber())); - CleanupStack::PushL(refDevice); - CWindowGc *gcRef; - refDevice->CreateContext(gcRef); - CleanupStack::PushL(gcRef); - - refWin.Invalidate(); - refWin.BeginRedraw(); - gcRef->Activate(refWin); - gcRef->BitBlt(TPoint(0,0), bitmapOne); - gcRef->Deactivate(); - refWin.EndRedraw(); - TheClient->iWs.Flush(); - - TPoint refPos = refWin.AbsPosition(); - TPoint winPos = theWin.AbsPosition(); - - //Compare the anti-aliased text areas - TInt textLength=textSize.iBounds.iBr.iX; - TInt textHeight=Abs(textSize.iBounds.iTl.iY); - - TRect rect1(refPos.iX+10,refPos.iY+60-textHeight, - refPos.iX+10+textLength,refPos.iY+60); - TRect rect2(winPos.iX+10,winPos.iY+60-textHeight, - winPos.iX+10+textLength,winPos.iY+60); - - TBool match = refDevice->RectCompare(rect1,rect2); - TEST(match); - - CleanupStack::PopAndDestroy(gcRef); - CleanupStack::PopAndDestroy(refDevice); - CleanupStack::PopAndDestroy(&refWin); - - CleanupStack::PopAndDestroy(bGcOne); - CleanupStack::PopAndDestroy(deviceOne); - CleanupStack::PopAndDestroy(bitmapOne); - CleanupStack::PopAndDestroy(&theWin);//theWin - - } -// -// CTDrawOpWin -// - -CTDrawOpWin* CTDrawOpWin::NewL(CTAlphaWin* aTest, CTWinBase* aParent, TPoint aPos, TSize aSize, TRgb aDrawColour) - { - CTDrawOpWin* theWin = new(ELeave) CTDrawOpWin(aTest,aDrawColour); - - theWin->ConstructL(*aParent); - theWin->SetExtL(aPos, aSize); - theWin->AssignGC(*TheClient->iGc); - if (TheClient->iScreen->DisplayMode() == EColor16MA) - { - theWin->BaseWin()->SetRequiredDisplayMode(EColor16MA); - } - else - { - theWin->BaseWin()->SetRequiredDisplayMode(EColor64K); - } - - theWin->Activate(); - theWin->DrawNow(); - - return theWin; - } - -CTDrawOpWin::CTDrawOpWin(CTAlphaWin* aTest, TRgb aDrawColour) -: iTest(aTest), iDrawColour(aDrawColour) - {} - - -void CTDrawOpWin::SetDrawOp(TInt aDrawOp) - { - iDrawOp = aDrawOp; - } - - -void CTDrawOpWin::Draw() - { - _LIT(KText,"Text test"); - - iGc->SetPenColor(iDrawColour); - iGc->SetBrushColor(iDrawColour); - TSize size = Size(); - TInt top = 5; - TInt left = 5; - TInt bottom = size.iHeight - 5; - TInt right = size.iWidth - 5; - TInt square = Min(bottom-top,right-left); - - switch (iDrawOp) - { - case EOpDrawRect: - iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - iGc->SetPenStyle(CGraphicsContext::ENullPen); - iGc->DrawRect(TRect(left,top,right,bottom)); - break; - case EOpDrawLine: - //!! FAILS - //!! The endpoint of the line is drawn twice, with the result that it is darker when we do blending - //!! Not intending to fix at the moment - /* - iGc->SetPenStyle(CGraphicsContext::ESolidPen); - iGc->SetPenSize(TSize(4,4)); - // The lines must not overlap, otherwise the blended lines will be darker at the overlap - iGc->DrawLine(TPoint(left+5,top), TPoint(left+square,top)); - iGc->DrawLine(TPoint(left+5,top+5), TPoint(left+square,top+square)); - iGc->DrawLine(TPoint(left,top+5), TPoint(left,top+square)); - */ - break; - case EOpDrawEllipse: - iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - iGc->SetPenStyle(CGraphicsContext::ENullPen); - iGc->DrawEllipse(TRect(left,top,right,bottom)); - break; - case EOpDrawText: - case EOpDrawTextVertical: - { - iGc->SetBrushStyle(CGraphicsContext::ENullBrush); - iGc->SetPenStyle(CGraphicsContext::ESolidPen); - CFont* font; - TFontSpec fontSpec(KTestFontTypefaceName,200); - User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips(font, fontSpec)); - iGc->UseFont(font); - if (iDrawOp==EOpDrawText) - iGc->DrawText(KText(), TPoint(5,30)); - else - iGc->DrawTextVertical(KText(), TPoint(5,30), EFalse); - iGc->DiscardFont(); - TheClient->iScreen->ReleaseFont(font); - } - break; - case EOpDrawTextAntiAliased: - { - iGc->SetBrushStyle(CGraphicsContext::ENullBrush); - iGc->SetPenStyle(CGraphicsContext::ESolidPen); - CFont* font; - TFontSpec fontSpec(KTestFontTypefaceName,600); - fontSpec.iFontStyle.SetStrokeWeight(EStrokeWeightBold); - fontSpec.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap); - - User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips(font, fontSpec)); - iGc->UseFont(font); - iGc->DrawText(KText(), TPoint(5,30)); - iGc->DiscardFont(); - TheClient->iScreen->ReleaseFont(font); - } - break; - case EOpBitBlt: - break; - case EOpBitBltMasked: - break; - default: - break; - }; - } - - - -// -// CTAlphaWindow -// - -CTAlphaWindow::~CTAlphaWindow() - { - DestroyChildren(); - } - -CTAlphaWindow* CTAlphaWindow::NewL(CTAlphaWin* aTest, CTWinBase* aParent, TPoint aPos, TSize aSize, TInt aDrawState) - { - CTAlphaWindow* theWin = new (ELeave) CTAlphaWindow(aTest); - - theWin->ConstructL(*aParent); - theWin->SetExtL(aPos, aSize); - theWin->SetDrawState(aDrawState); - - theWin->AssignGC(*TheClient->iGc); - - theWin->Activate(); - theWin->iDrawState |= EActive; - theWin->DrawNow(); - - return theWin; - } - -void CTAlphaWindow::SetDrawState(TInt aDrawState) - { - TBool active = iDrawState & EActive; - iDrawState = aDrawState & 0x7fffffff; - - TRgb colour = ColourFromDrawState(iDrawState); - ((RWindow*) DrawableWin())->SetBackgroundColor(colour); - - if (iDrawState & EModeColor16MA) - BaseWin()->SetRequiredDisplayMode(EColor16MA); - else - BaseWin()->SetRequiredDisplayMode(EColor64K); - - BaseWin()->SetVisible(! (iDrawState & EInvisible)); - - if (!active) - { - if (iDrawState & EAlphaTransparency) - ((RWindow*) DrawableWin())->SetTransparencyAlphaChannel(); - else if (iDrawState & ETransparencyFactor) - ((RWindow*) DrawableWin())->SetTransparencyFactor(TRgb(128,128,128)); - } - - if (active) - iDrawState |= EActive; - } - -void CTAlphaWindow::SetVisible(TBool aVisible) - { - if (aVisible) - iDrawState &= ~EInvisible; - else - iDrawState |= EInvisible; - BaseWin()->SetVisible(aVisible); - } - -void CTAlphaWindow::CreateChildrenL(TInt aDepth) - { - DestroyChildren(); - if (aDepth>0) - { - TSize size = Size(); - iChild1 = CTAlphaWindow::NewL(iTest, this, TPoint(size.iWidth/3,0), TSize(2*size.iWidth/3, 2*size.iHeight/3), ERed | EGreen | EBlue | EOpaque); - iChild2 = CTAlphaWindow::NewL(iTest, this, TPoint(0,size.iHeight/3), TSize(2*size.iWidth/3, 2*size.iHeight/3), ERed | EGreen | EBlue | EAlphaTransparency); - iChild2->CreateChildrenL(aDepth-1); - } - } - -void CTAlphaWindow::DestroyChildren() - { - if (iChild1) - { - iChild1->DestroyChildren(); - delete iChild1; - iChild1 = NULL; - } - if (iChild2) - { - iChild2->DestroyChildren(); - delete iChild2; - iChild2 = NULL; - } - } - -TInt CTAlphaWindow::DrawState() - { - return iDrawState; - } - -void CTAlphaWindow::Draw() - { - // we draw a diagonal line from top left to bottom right - // we use the complementary colour to the window background colour - TInt red = (iDrawState & ERed) ? 0 : 255; - TInt green = (iDrawState & EGreen) ? 0 : 255; - TInt blue = (iDrawState & EBlue) ? 0 : 255; - TRgb color(red,green,blue); - - TSize size = Size(); - iGc->SetPenColor(color); - iGc->SetPenSize(TSize(4,4)); - iGc->DrawLine(TPoint(0,0), TPoint(size.iWidth, size.iHeight)); - } - - -// -// CTAlphaRefWin -// - -CTAlphaRefWin::CTAlphaRefWin(TFixedArray& aAlphaWin) -: iAlphaWin(aAlphaWin) - {} - -CTAlphaRefWin* CTAlphaRefWin::NewL(CTWinBase* aParent, TPoint aPos, TSize aSize, TFixedArray& aAlphaWin) - { - CTAlphaRefWin* theWin = new(ELeave) CTAlphaRefWin(aAlphaWin); - - theWin->ConstructL(*aParent); - theWin->SetExtL(aPos, aSize); - theWin->AssignGC(*TheClient->iGc); - theWin->BaseWin()->SetRequiredDisplayMode(EColor64K); - - theWin->Activate(); - theWin->DrawNow(); - - return theWin; - } - -void CTAlphaRefWin::Draw() - { - iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - iGc->SetBrushColor(KRgbWhite); - iGc->Clear(); - - // Note, the order of the windows in the array must correspond to their z-order - for (TInt i=0; i<5; i++) - DrawWindow(iAlphaWin[i], iAlphaWin[i]->Position()); - } - -void CTAlphaRefWin::DrawWindow(CTAlphaWindow* aWindow, TPoint aPos) - { - TInt drawState = aWindow->DrawState(); - if ( (drawState & EInvisible) || ! (drawState & EActive) ) - return; - - TRgb colour = ColourFromDrawState(drawState); - if (drawState & EOpaque) - colour.SetAlpha(255); - if (drawState & ETransparent) - colour.SetAlpha(0); - iGc->SetBrushColor(colour); - - TPoint tl = aPos; - TPoint br = tl + aWindow->Size(); - TRect rect(tl,br); - iGc->Clear(rect); - - TInt red = (drawState & ERed) ? 0 : 255; - TInt green = (drawState & EGreen) ? 0 : 255; - TInt blue = (drawState & EBlue) ? 0 : 255; - colour = TRgb(red,green,blue); - - iGc->SetClippingRect(rect); - - TSize size = Size(); - iGc->SetPenColor(colour); - iGc->SetPenSize(TSize(4,4)); - iGc->DrawLine(tl, br); - - iGc->CancelClippingRect(); - - if (aWindow->iChild1) - DrawWindow(aWindow->iChild1, aPos + aWindow->iChild1->Position() ); - if (aWindow->iChild2) - DrawWindow(aWindow->iChild2, aPos + aWindow->iChild2->Position() ); - } - - -// -// Main test loop -// -void CTAlphaWin::RunTestCaseL(TInt /*aCurTestCase*/) - { - //User::After(TTimeIntervalMicroSeconds32(1000 * 1000)); - ((CTAlphaWinStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); - switch (++iTest->iState) - { -/** - - @SYMTestCaseID GRAPHICS-WSERV-0278 - - @SYMDEF DEF081259 - - @SYMPREQ 915 - - @SYMTestCaseDesc Semi-transparent drawing - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions Use draw operations with semi-transparent pen or brush colours - - @SYMTestExpectedResults Draw operations must do alpha blending - -*/ - case 1: - { - ((CTAlphaWinStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0278")); - if(TransparencySupportedL() == KErrNotSupported) - { - LOG_MESSAGE(_L("Test(1) complete - Transparency not supported\n")); - TestComplete(); - break; - } - TDisplayMode mode = TheClient->iScreen->DisplayMode(); - if (mode < EColor64K) - { - LOG_MESSAGE(_L("Test(1) complete - Display mode < EColor64K\n")); - TestComplete(); - break; - } - _LIT(KSemiTrans64K,"(1) Semi transparent drawing Color64K"); - iTest->LogSubTest(KSemiTrans64K); - TestSemiTransparentDrawingL(); - break; - } - -/** - - @SYMTestCaseID GRAPHICS-WSERV-0287 - - @SYMDEF DEF081259 - - @SYMPREQ 915 - - @SYMTestCaseDesc Invisible. All windows are in EColor16MA display mode. - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions Transparent alpha channel windows are made invisible and visible both in front and behind one another - - @SYMTestExpectedResults The windows are redrawn correctly, as compared to a reference drawing - -*/ - case 2: - ((CTAlphaWinStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0287")); - ConfigureDisplayModes(EColor16MA); - if(TransparencySupportedL()==KErrNone) - { - _LIT(KInvisible16MA,"(2) Invisible Color16MA"); - iTest->LogSubTest(KInvisible16MA); - TestInvisible(); - } - break; - -/** - - @SYMTestCaseID GRAPHICS-WSERV-0280 - - @SYMDEF DEF081259 - - @SYMPREQ 915 - - @SYMTestCaseDesc Initial Configuration. All windows are in EColor64K display mode. - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions Several windows are set to be transparent alpha channel, and given semi-transparent or transparent background colours - - @SYMTestExpectedResults The transparent window configuration matches a reference drawing created using only alpha blending - -*/ - //Test 3 to 6 can't be run without transparency support - case 3: - ((CTAlphaWinStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0280")); - ConfigureDisplayModes(EColor64K); - if(TransparencySupportedL()==KErrNone) - { - _LIT(KInitialConfiguration64K,"(3) Initial configuration Color64K"); - iTest->LogSubTest(KInitialConfiguration64K); - TestInitialConfiguration(); - } - break; -/** - - @SYMTestCaseID GRAPHICS-WSERV-0281 - - @SYMDEF DEF081259 - - @SYMPREQ 915 - - @SYMTestCaseDesc Move. All windows are in EColor64K display mode. - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions Transparent alpha channel windows are moved both in front and behind one another - - @SYMTestExpectedResults The windows are redrawn correctly, as compared to a reference drawing - -*/ - case 4: - ((CTAlphaWinStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0281")); - if(TransparencySupportedL()==KErrNone) - { - _LIT(KMove64K,"(4) Move Color64K"); - iTest->LogSubTest(KMove64K); - TestMove(); - } - break; -/** - - @SYMTestCaseID GRAPHICS-WSERV-0282 - - @SYMDEF DEF081259 - - @SYMPREQ 915 - - @SYMTestCaseDesc Redraw. All windows are in EColor64K display mode. - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions Transparent alpha channel windows are redrawn both in front and behind one another - - @SYMTestExpectedResults The windows are redrawn correctly, as compared to a reference drawing - -*/ - case 5: - ((CTAlphaWinStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0282")); - if(TransparencySupportedL()==KErrNone) - { - _LIT(KRedraw64K,"(5) Redraw Color64K"); - iTest->LogSubTest(KRedraw64K); - TestRedraw(); - } - break; -/** - - @SYMTestCaseID GRAPHICS-WSERV-0283-0001 - - @SYMDEF DEF081259 - - @SYMPREQ 915 - - @SYMTestCaseDesc Invisible. All windows are in EColor64K display mode. - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions Transparent alpha channel windows are made invisible and visible both in front and behind one another - - @SYMTestExpectedResults The windows are redrawn correctly, as compared to a reference drawing - -*/ - case 6: - ((CTAlphaWinStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0283-0001")); - if(TransparencySupportedL()==KErrNone) - { - _LIT(KInvisible64K,"(6) Invisible Color64K"); - iTest->LogSubTest(KInvisible64K); - TestInvisible(); - } - break; -/** - - @SYMTestCaseID GRAPHICS-WSERV-0283-0002 - - @SYMDEF DEF081259 - - @SYMPREQ 915 - - @SYMTestCaseDesc Children. All windows are in EColor64K display mode. - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions Transparent alpha channel windows are given child windows, both transparent and non-transparent, - and are then moved, redrawn, set visible or invisible both in front and behind one another - - @SYMTestExpectedResults The windows are redrawn correctly, as compared to a reference drawing - -*/ - case 7: - ((CTAlphaWinStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0283-0002")); - _LIT(KChildren64K,"(7)Children Color64K"); - iTest->LogSubTest(KChildren64K); - TestChildrenL(); - break; -/** - - @SYMTestCaseID GRAPHICS-WSERV-0356 - - @SYMDEF DEF081259 - - @SYMPREQ 915 - - @SYMTestCaseDesc Initial Configuration. All windows are in EColor64k Dispaly Mode - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions Tests Anti-aliasing of text - - @SYMTestExpectedResults Anti-alisaing should behave correctly - -*/ - case 8: - ((CTAlphaWinStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0356")); - _LIT(KAntiAliasedText64K,"(8) AntiAliasedText DEF082251 Color64K"); - iTest->LogSubTest(KAntiAliasedText64K); - TestAntiAliasedTextTransparentL(); - break; - -/** - - @SYMTestCaseID GRAPHICS-WSERV-0284 - - @SYMDEF DEF081259 - - @SYMPREQ 915 - - @SYMTestCaseDesc Initial Configuration. All windows are in EColor16MA display mode. - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions Several windows are set to be transparent alpha channel, and given semi-transparent or transparent background colours - - @SYMTestExpectedResults The transparent window configuration matches a reference drawing created using only alpha blending - -*/ - case 9: - { - ((CTAlphaWinStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0284")); - ConfigureDisplayModes(EColor16MA); - TDisplayMode mode1 = TheClient->iScreen->DisplayMode(); - _LIT(KInitialConfiguration16MA,"(9)Initial configuration Color16MA"); - iTest->LogSubTest(KInitialConfiguration16MA); - TestInitialConfiguration(); - break; - } -/** - - @SYMTestCaseID GRAPHICS-WSERV-0285 - - @SYMDEF DEF081259 - - @SYMPREQ 915 - - @SYMTestCaseDesc Move. All windows are in EColor16MA display mode. - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions Transparent alpha channel windows are moved both in front and behind one another - - @SYMTestExpectedResults The windows are redrawn correctly, as compared to a reference drawing - -*/ - case 10: - ((CTAlphaWinStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0285")); - _LIT(KMove16MA,"(10)Move Color16MA"); - iTest->LogSubTest(KMove16MA); - TestMove(); - break; -/** - - @SYMTestCaseID GRAPHICS-WSERV-0286 - - @SYMDEF DEF081259 - - @SYMPREQ 915 - - @SYMTestCaseDesc Redraw. All windows are in EColor16MA display mode. - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions Transparent alpha channel windows are redrawn both in front and behind one another - - @SYMTestExpectedResults The windows are redrawn correctly, as compared to a reference drawing - -*/ - case 11: - ((CTAlphaWinStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0286")); - _LIT(KRedraw16MA,"(11)Redraw Color16MA"); - iTest->LogSubTest(KRedraw16MA); - TestRedraw(); - break; - -/** - - @SYMTestCaseID GRAPHICS-WSERV-0279 - - @SYMDEF DEF081259 - - @SYMPREQ 915 - - @SYMTestCaseDesc Transparent drawing - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions Use draw operations with transparent pen or brush colours - - @SYMTestExpectedResults Draw operations with transparent pen or brush colours should leave the destination unchanged - -*/ - - case 12: - ((CTAlphaWinStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0279")); - ConfigureDisplayModes(EColor64K); - _LIT(KTrans64K,"(12) Transparent drawing Color64K"); - iTest->LogSubTest(KTrans64K); - TestTransparentDrawingL(); - break; - - -/** - - @SYMTestCaseID GRAPHICS-WSERV-0288 - - @SYMDEF DEF081259 - - @SYMPREQ 915 - - @SYMTestCaseDesc Children. All windows are in EColor16MA display mode. - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions Transparent alpha channel windows are given child windows, both transparent and non-transparent, - and are then moved, redrawn, set visible or invisible both in front and behind one another - - @SYMTestExpectedResults The windows are redrawn correctly, as compared to a reference drawing - -*/ - case 13: - ((CTAlphaWinStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0288")); - _LIT(KChildren16MA,"(13) Children Color16MA"); - iTest->LogSubTest(KChildren16MA); - TestChildrenL(); - break; -/** - - @SYMTestCaseID GRAPHICS-WSERV-0357 - - @SYMDEF DEF081259 - - @SYMPREQ 915 - - @SYMTestCaseDesc Initial Configuration. All windows are in EColor16MA Dispaly Mode - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions Tests Anti-aliasing of text - - @SYMTestExpectedResults Anti-alisaing should behave correctly - -*/ - case 14: - ((CTAlphaWinStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0357")); - _LIT(KAntiAliasedText16MA,"(14) AntiAliasedText DEF082251 Color16MA"); - iTest->LogSubTest(KAntiAliasedText16MA); - TestAntiAliasedTextTransparentL(); - break; - default: - ((CTAlphaWinStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - ((CTAlphaWinStep*)iStep)->CloseTMSGraphicsStep(); - TestComplete(); - break; - } - ((CTAlphaWinStep*)iStep)->RecordTestResultL(); - } - -__WS_CONSTRUCT_STEP__(AlphaWin) - diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/tauto.mbm Binary file windowing/windowserver/tauto/tauto.mbm has changed diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/tclosepanicwindowprocess.cpp --- a/windowing/windowserver/tauto/tclosepanicwindowprocess.cpp Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,88 +0,0 @@ -// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// The process to close all the panic window. -// -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include -#include -#include -#include -#include -#include -#include - -// Simulate 50 escape-keys down to close all the panic window -static TInt CloseAllPanicWindows(RWsSession& aWs) - { - TInt idFocus = aWs.GetFocusWindowGroup(); - TWsEvent event; - event.SetType(EEventKey); - TKeyEvent* keyEvent = event.Key(); - keyEvent->iCode = EKeyEscape; - keyEvent->iScanCode = EStdKeyEscape; - keyEvent->iModifiers = 0; - TInt theLimit = 50; - TInt err = KErrNone; - while(idFocus != NULL && (theLimit-- > 0)) - { - err = aWs.SendEventToAllWindowGroups(event); - if (err != KErrNone && err != KErrNoMemory) - { - return err; - } - User::After(1000); //give it time to process - idFocus = aWs.GetFocusWindowGroup(); - } - return KErrNone; - } - - -// Real main function -void MainL() - { - // Open wserv session - RWsSession ws; - TInt err = ws.Connect(); - if (err != KErrNone) - { - User::Leave(err); - } - - CleanupClosePushL(ws); - - User::LeaveIfError(CloseAllPanicWindows(ws)); - - CleanupStack::PopAndDestroy(&ws); - } - -// Cleanup stack harness -GLDEF_C TInt E32Main() - { - __UHEAP_MARK; - CTrapCleanup* cleanupStack = CTrapCleanup::New(); - TRAPD(error, MainL()); - _LIT(KTCloseAllPanicWindowPanic,"tcloseallpanicwindow"); - // Panic the current process - __ASSERT_ALWAYS(!error, User::Panic(KTCloseAllPanicWindowPanic, error)); - delete cleanupStack; - __UHEAP_MARKEND; - return KErrNone; - } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/tcrpanim.cpp --- a/windowing/windowserver/tauto/tcrpanim.cpp Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1464 +0,0 @@ -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Implements CTCrpAnim -// Test CRP animations & their interaction with overlapping transparent/non-transparent windows -// & wserv's underlying redraw-store strategies -// -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include -#include "tcrpanim.h" - -// RUN_SAMPLE_ON_LEFT allows the demo animation to run in the left-hand window during testing. -// Used for demonstration purposes only -#define RUN_SAMPLE_ON_LEFT - -namespace //anonymous local scope - { - const TInt KAnimationFrameDelayTime = 50000; // delay in microseconds between frames - const TInt KShortDelayLoop = 2*KAnimationFrameDelayTime; // delay time in microseconds used in test cases - const TInt KAnimationTotalFrames = 40; // total number of frames in a CWsGraphicBitmapAnimation - const TInt KAnimDimension = 40; // animation width/height. We're enforcing a square animation here - const TInt KFrameMissedAnimationsThreshold = 10; // maximum number of missed frame steps allowed - const TInt KAnimationTearWidthThreshold = 4; // maximum columns permitted between a tear - const TInt KMinGoodFrameThreshold = 30; // percentage threshold for number of good frames detected in a test - const TInt KMaxXY = 200; // arbitrary maximum size of square used to invalidate a window - const TInt KMaxRepeatDraw = 2; // arbitrary value for DrawLine calls during a Draw - TUid KUidTestAnimation2 = {0xBAADF00D}; // unique id. for CWsGraphicBitmapAnimation object - const TUint32 KWhitePixels = 0xFFFFFFFF; // 32-bit mask value for rgb white - const TUint32 KBlackPixels = 0x00000000; // 32-bit value for rgb black - const TPoint KPointZero(0,0); // initial point used for animation creation & manipulation (currently 0,0) - const TPoint KPointOffsite(1000,1000); // point used to draw off-screen - const TDisplayMode KTestDisplayMode = EColor16MU; // display mode used for testing - const TInt KFrameStepCalculation = Max(1, KAnimDimension/Max(1, KAnimationTotalFrames)); // determine framestep size in columns - - enum TColorDetected - { - ECantTell=0, - EDetRed=1, - EDetGreen=2, - EDetBlue=4, - EDetBlack=0x10, - EDetGrey=0x20, - EDetWhite=0x40 - }; - - class CCrpAnim; - class CAnimRedrawWindow : public CTWin - { - public: - CAnimRedrawWindow(CCrpAnim *aAnimWindow, TBool aIsBase); - ~CAnimRedrawWindow(); - void Draw(); - private: - CCrpAnim *iAnimWindow; - TBool iIsBase; - }; - - class CCrpAnim : public CBase - { - friend class CAnimRedrawWindow; - public: - enum TWinType - { - ERedraw, - EBlank, // note: not currently used in tcrpanim tests - EBackedUp // note: not currently used in tcrpanim tests - }; - public: - CCrpAnim(TBool aIsBase, TWinType aWinType); - ~CCrpAnim(); - enum - { - ENoTransparency=0x100 - }; - void ConstructL(const TPoint &aPos, const TSize &aSize,const TInt aAlphaValue=ENoTransparency); - void DoDraw(TBool aBlankIt); - inline void DoDraw(); - void DoDrawEllipse(); - inline TSize Size() {return iCtWin->Size();}; - inline RWindowBase* BaseWin() const {return iCtWin->BaseWin();}; - inline RWindow* Window() const {return STATIC_CAST(RWindow*, iCtWin->BaseWin());}; - inline CTBaseWin* CtBaseWin() {return iCtWin;}; - inline void Invalidate() {CTUser::Splat(TheClient, TRect(iCtWin->Position(), iCtWin->Size()), KRgbGray);}; - void Invalidate(const TRect &aRect); - static void SetEllipseDrawMode(CGraphicsContext::TDrawMode aEllipseDrawMode); - void InvalidateAndRedraw(TBool aUseBlankItMember,TBool aBlankIt,TBool aUseRWindowInvalidate,TRect* aRect=NULL); - - //A bit of an animation interface... - //I have written this interface to be amenable to playing multiple animations, - //which I think needs testing, - //but the underlying implementation assumes one animation at present. - //Your mission, should you choose to accept it, .... - - void SetPosAnimation(const TUid& aUid, const TRect& aRect); - TRect* GetPosAnimation(const TUid& aUid); - TWsGraphicAnimation* SetAnimation(TUid); - TWsGraphicAnimation* GetAnimation(TUid); - TBool RemoveAnimation(TUid); - inline void SetBlankIt(TBool aNewVal) {iBlankIt = aNewVal;}; - inline void SetRepeatDrawMax(TInt aVal) {iRepeatDrawMax = aVal;}; - protected: - static void Draw(CBitmapContext *aGc, const TSize &aSize, TBool aIsBase,const TRect &aRect, TBool aBlankIt,TInt aRepeat, TInt aAlphaValue); - static void DrawEllipse(CBitmapContext *aGc, const TRect &aRect, TInt aAlphaValue); - CTBaseWin *iCtWin; - TWinType iWinType; - TBool iIsBase; - TBool iBlankIt; - TRect iRect; - TInt iRepeatDrawMax; - static CGraphicsContext::TDrawMode iEllipseDrawMode; - TUid iAnimUid; - TWsGraphicAnimation iAnimData; - TRect iAnimPos; - TInt iAlphaValue; - }; - -/* Using this time delay class in order to allow animations to play in our draw. - User::Wait does not allow the draw to occur (aparrently) - Note when using this time-delay class: because other active objects can perform part of their - processing whilst we wait, wrapping calls to this in __UHEAP_MARK / __UHEAP_MARKEND - is likely to fail. The data providers and animators are a major cause of this. -*/ - class CActiveWait : public CActive - { - public: - static CActiveWait* NewL(); - ~CActiveWait(); - void Wait(TInt aDelay); - // From CActive: - void RunL(); - void DoCancel(); - TInt RunError(TInt aError); - protected: - CActiveWait(); - void ConstructL(); - protected: - RTimer iTimer; - TTime iFromTime; - }; - - CActiveWait* CActiveWait::NewL() - { - CActiveWait* self = new (ELeave) CActiveWait; - CleanupStack::PushL(self); - self->ConstructL(); - CleanupStack::Pop(self); - return self; - } - - void CActiveWait::ConstructL() - { - User::LeaveIfError(iTimer.CreateLocal()); - CActiveScheduler::Add(this); - } - - CActiveWait::CActiveWait() : CActive(EPriorityNormal) - { - iFromTime.HomeTime(); - } - - CActiveWait::~CActiveWait() - { - Cancel(); - iTimer.Close(); - } - - void CActiveWait::DoCancel() - { - iTimer.Cancel(); - CActiveScheduler::Stop(); - } - - void CActiveWait::RunL() - { - CActiveScheduler::Stop(); - } - - TInt CActiveWait::RunError(TInt aError) - { - return aError; // exists so a break point can be placed on it. - } - -/* Note when using this : because other active objects can perform part of their - processing whilst we wait, wrapping calls to this in __UHEAP_MARK / __UHEAP_MARKEND - is likely to fail. The data providers and animators are a major cause of this. -*/ - void CActiveWait::Wait(TInt aDelay) - { - iTimer.After(iStatus, aDelay); - SetActive(); - CActiveScheduler::Start(); - } - CGraphicsContext::TDrawMode CCrpAnim::iEllipseDrawMode; - -// - } //end anonymous local scope -// - -/** This fn allocates an animation frame of the specified dimensions. - Not tested outside the current limited parameter set (16/2/2007). - Note the use of 32-bit integers for pixel/colour values. Using display mode lower than 24bpp may not produce correct results - My attempt to write animation generating code that avoids CIclLoader and Decoder class. - @param aDelayUs the display time for the frame - @param aImageType Colour format for colour plane. 24MA currently not flagged correctly I expect. - @param aMaskType Format for mask. ENone for no mask. - @param aImageSize Width/height of bitmap area - @param aImageOffset Optional offset for bitmap area - @param aTotalSize Optional width/height of whole animation (I think) - @return CFrame filled in with allocated bitmaps. The get methods for the bitmaps return const type. -**/ -static CWsGraphicBitmapAnimation::CFrame* NewFrameLC(TInt aDelayUs,TDisplayMode aImageType,TDisplayMode aMaskType,const TSize& aImageSize,const TPoint& aImageOffset=KPointZero,const TSize& aTotalSize=TSize(0,0)) - { - TFrameInfo info; - info.iFrameCoordsInPixels = TRect(aImageOffset,aImageSize); - info.iFrameSizeInTwips = aImageSize; //this is zero in the gif loader - info.iDelay = TTimeIntervalMicroSeconds(aDelayUs); - info.iFlags = TFrameInfo::EColor|TFrameInfo::ELeaveInPlace|TFrameInfo::EUsesFrameSizeInPixels; - if (aMaskType != ENone) - { - info.iFlags|=TFrameInfo::ETransparencyPossible; - } - if ((aTotalSize.iHeight > 0) && (aTotalSize.iWidth > 0)) - { - // restrict the size of the frame to specified size of the animation - info.iOverallSizeInPixels = aTotalSize; - } - else - { - // assign the size of the frame to the size of the entire bitmap area - info.iOverallSizeInPixels = info.iFrameCoordsInPixels.iBr.AsSize(); - } - info.iFrameDisplayMode = aImageType; - info.iBackgroundColor = KRgbGreen; - - CWsGraphicBitmapAnimation::CFrame* frame = CWsGraphicBitmapAnimation::CFrame::NewL(); - CleanupStack::PushL(frame); - frame->SetFrameInfo(info); - CFbsBitmap* bitmap = new(ELeave) CFbsBitmap; - frame->SetBitmap(bitmap); //takes ownership - TSize frameInfoSize = info.iFrameCoordsInPixels.Size(); - User::LeaveIfError(bitmap->Create(frameInfoSize, aImageType)); - if((TFrameInfo::EAlphaChannel|TFrameInfo::ETransparencyPossible) & info.iFlags) - { - CFbsBitmap* mask = new(ELeave) CFbsBitmap; - frame->SetMask(mask); //takes ownership - User::LeaveIfError(mask->Create(frameInfoSize, aMaskType)); - } - return frame; - } - -// -// function called back by TCleanupItem frameListCleanup from within CreateAnimFramesL(..) method -// -void CleanupFrameList(TAny* aPtr) - { - RPointerArray* ptrArray = STATIC_CAST(RPointerArray*, aPtr); - ptrArray->ResetAndDestroy(); - ptrArray->Close(); - } - -/** Helper function for making animation frames. - //Called from CreateAnimL(...) - @param aDelayUs the delay between frames - @param aNumFrames number of frames (approx - image width is a factor) - @param aImageType colour format of colour data. This may not work properly for non-32-bit, but I haven't fully understood TBitmapUtil documentation. - @param aMaskType format for mask - ENone for no mask. - @param aImageSize width/height of animation - @param aBgCol background colour for image non-masked areas. Masked areas are black. - @param aFgCol foreground colour of animating area - @param aFrames frames that the animation is constructed from -**/ -static void CreateAnimFramesL(TInt aDelayUs,TInt aNumFrames,TDisplayMode aImageType,TDisplayMode aMaskType,TSize aImageSize,TRgb aBgCol,TRgb aFgCol, RPointerArray& aFrames) - { - const TInt animWH = aImageSize.iWidth; - const TInt animStep = Max(1,animWH/Max(1,aNumFrames)); //note this intentionally rounds down to avoid overflows - for (TInt ii = 0 ; ii < animWH ; ii += animStep) - { - CWsGraphicBitmapAnimation::CFrame* frame = NewFrameLC(aDelayUs,aImageType,aMaskType,aImageSize,KPointZero,aImageSize); - aFrames.AppendL(frame); - CleanupStack::Pop(frame); - TBitmapUtil utilMask(CONST_CAST(CFbsBitmap*, frame->Mask())); - TBitmapUtil utilCol(CONST_CAST(CFbsBitmap*, frame->Bitmap())); - utilCol.Begin(KPointZero); - - // cycle through the frame's actual bitmap & assign each pixel a value identical to the specified colours - TUint32 colback=aBgCol.Internal(); - TUint32 colfront=aFgCol.Internal(); - TInt row = KErrNone; - TInt col = KErrNone; - for (row = 0 ; row < aImageSize.iHeight ; row++) - { - utilCol.SetPos(TPoint(0, row)); - for (col = 0 ; col < aImageSize.iWidth ; col++) - { - utilCol.SetPixel(colback); - utilCol.IncXPos(); - } - utilCol.SetPos(TPoint(ii, row)); - for (col = 0 ; col < animStep ; col++) //Note I rely on intentional rounding down here! - { - utilCol.SetPixel(colfront); - utilCol.IncXPos(); - } - } - - if (aMaskType) - { - // cycle through each pixel of the frame's mask & assign a default pixel a colour value - utilMask.Begin(KPointZero); - for (row = 0 ; row < aImageSize.iHeight ; row++) - { - utilMask.SetPos(TPoint(0,row)); - for (col = 0 ; col < aImageSize.iWidth ; col++) - { - utilMask.SetPixel(KWhitePixels); - utilMask.IncXPos(); - } - } - - const TInt maxmaskWidth = Min(8,Max(animWH/3,2)); - - //cut the corners off the mask - for (row = 0 ; row < maxmaskWidth ; row++) - { - TInt currentX = maxmaskWidth - row; - TInt xPos = KErrNone; - - utilCol.SetPos(TPoint(0,row)); - utilMask.SetPos(TPoint(0,row)); - for(xPos = currentX ; xPos >= 0 ; xPos--) - { - utilCol.SetPixel(KBlackPixels); - utilCol.IncXPos(); - utilMask.SetPixel(KBlackPixels); - utilMask.IncXPos(); - } - - utilCol.SetPos(TPoint(animWH - 1, row)); - utilMask.SetPos(TPoint(animWH - 1, row)); - for(xPos = currentX ; xPos >= 0 ; xPos--) - { - utilCol.SetPixel(KBlackPixels); - utilCol.DecXPos(); - utilMask.SetPixel(KBlackPixels); - utilMask.DecXPos(); - } - - utilCol.SetPos(TPoint(0, animWH - 1 - row)); - utilMask.SetPos(TPoint(0, animWH - 1 - row)); - for(xPos = currentX ; xPos >= 0 ; xPos--) - { - utilCol.SetPixel(KBlackPixels); - utilCol.IncXPos(); - utilMask.SetPixel(KBlackPixels); - utilMask.IncXPos(); - } - - utilCol.SetPos(TPoint(animWH - 1, animWH - 1 - row)); - utilMask.SetPos(TPoint(animWH - 1, animWH - 1 - row)); - for(xPos = currentX ; xPos >= 0 ; xPos--) - { - utilCol.SetPixel(KBlackPixels); - utilCol.DecXPos(); - utilMask.SetPixel(KBlackPixels); - utilMask.DecXPos(); - } - } - utilMask.End(); - } - utilCol.End(); - } - } - -/** My attempt to write animation generating code that avoids CIclLoader and Decoder class. - //It is better if this test class used it's own generated animation - //rather than relying on the GIF loader in order to reduce the cross-dependencies. - //The animation generated is a simple vertical line moving from left to right. - //To prove the masking, I cut the corners off. - @param aDelayUs the delay between frames - @param aNumFrames number of frames (approx - image width is a factor) - @param aImageType colour format of colour data. This may not work properly for non-32-bit, but I haven't fully understood TBitmapUtil documentation. - @param aMaskType format for mask - ENone for no mask. - @param aImageSize width/height of animation - @param aBgCol background colour for image non-masked areas. Masked areas are black. - @param aFgCol foreground colour of animating area - @param aTUid TUid assigned to animation - @return CWsGraphicBitmapAnimation allocated to represent the final animation -**/ -static CWsGraphicBitmapAnimation* CreateAnimL(TInt aDelayUs,TInt aNumFrames,TDisplayMode aImageType,TDisplayMode aMaskType,TSize aImageSize,TRgb aBgCol,TRgb aFgCol,TUid& aTUid) - { - RPointerArray frames; - TCleanupItem frameListCleanup(CleanupFrameList, &frames); - CleanupStack::PushL(frameListCleanup); - - CreateAnimFramesL(aDelayUs, aNumFrames, aImageType, aMaskType, aImageSize,aBgCol, aFgCol, frames); - - CWsGraphicBitmapAnimation* anim = CWsGraphicBitmapAnimation::NewL(aTUid,frames.Array()); - CleanupStack::PopAndDestroy(&frames); - return anim; - } - -// -// Describes the pure colour of the RGB value. yellow/magenta/cyan set 2 bits. White/grey is seperately flagged. -// This method attempts to determine the strongest primary colour present in any given pixel. -// Note: The algorithm used is known to work for the current test cases only but requires careful review -// for anyone making additional changes to tcrpanim. Given time, improved algorithm should be developed -// to replace the current one -// -TUint PredominantColour(TUint aCol) - { //I don't like all these ifs, but I don't see an easy alternative - //Possibly a bit look-up of the deltas from average would work - //(ignoring the bottom 5 bits =32, not 0x30=48. Ignore bottom 4 bits and accept 3-same answers, or divide by delta?) - // - const TInt Kdelta=0x30; - TInt red=(aCol&0x00ff0000)>>16; - TInt green=(aCol&0x0000ff00)>>8; - TInt blue=(aCol&0x000000ff); - TInt ave=((red+green+blue)*(65536/3))>>16; - TBool rOverA=(red>ave); - TBool gOverA=(green>ave); - TBool bOverA=(blue>ave); - TInt numOverAve=(rOverA?1:0)+(gOverA?1:0)+(bOverA?1:0); - - if (numOverAve==1) - { - if (rOverA) - { - if (red>ave+Kdelta) - { - if ((green-blue)>-Kdelta && (green-blue)ave-Kdelta && blue>ave-Kdelta) - { - if (ave>256-Kdelta) - return EDetWhite; - else - return EDetGrey; - } - } - } - } - - if (gOverA) - { - if (green>ave+Kdelta) - { - if ((blue-red)>-Kdelta && (blue-red)ave-Kdelta && blue>ave-Kdelta) - if (ave>256-Kdelta) - return EDetWhite; - else - return EDetGrey; - } - } - } - - if (bOverA) - { - if (blue>ave+Kdelta) - { - if ((green-red)>-Kdelta && (green-red)ave-Kdelta && green>ave-Kdelta) - if (ave>256-Kdelta) - return EDetWhite; - else - return EDetGrey; - } - } - } - } - else - { - if (!rOverA) - if (red-Kdelta && (green-blue)256-Kdelta) - return EDetWhite; - else - { - if (blue-Kdelta && (blue-red)256-Kdelta) - return EDetWhite; - else - { - if (blue-Kdelta && (green-red)256-Kdelta) - return EDetWhite; - else - { - if (rediGroup->WinTreeNode()->SetOrdinalPosition(0); - iRedrawWin=new(ELeave) CCrpAnim(EFalse, CCrpAnim::ERedraw); - iBaseWin=new(ELeave) CCrpAnim(EFalse, CCrpAnim::ERedraw); - iOverWin=new(ELeave) CCrpAnim(EFalse, CCrpAnim::ERedraw); - - TSize screenSize=TheClient->iGroup->Size(); - TInt winWidth=(screenSize.iWidth/3)-10; - TInt winHeight=screenSize.iHeight-10; - TSize windowSize(winWidth,winHeight); - - iRedrawWin->ConstructL(TPoint(screenSize.iWidth/3*2+5,5), windowSize); - iBaseWin->ConstructL(TPoint(screenSize.iWidth/3+5,5), windowSize); - - //Create a transparent window that exactly overlaps the test window - //If transparency is not supported the leave causes the window to be destroyed and set to NULL. - //There is a test for transparency supported, but that simply creates a temp window to test anyway... - - //Note that when I originally wrote this test to fix PDEF101991, it generated white areas that I detected. - //However, if this transparent window used for extended tests is created over the test window, - //that somehow stops the white fill from occurring. - //The fault still occurs, but the previous screen contents are left behind. - //So now this window is created at an off-screen location. - TRAPD(err, iOverWin->ConstructL(KPointOffsite, windowSize, 0x80); iOverWin->SetBlankIt(ETrue); iOverWin->SetRepeatDrawMax(KMaxRepeatDraw);); - if (err) - { - delete iOverWin; - iOverWin = NULL; - } - - iTestWin = iRedrawWin; - iTestWin->SetRepeatDrawMax(KMaxRepeatDraw); - iBaseWin->SetRepeatDrawMax(KMaxRepeatDraw); - - // create animation object & share it with everyone - iAnim = CreateAnimL(KAnimationFrameDelayTime,KAnimationTotalFrames,KTestDisplayMode,EGray256,TSize(KAnimDimension, KAnimDimension),KRgbBlue,KRgbRed,KUidTestAnimation2); - if (!iAnim) - { - User::Leave(KErrNoMemory); - } - iAnim->ShareGlobally(); - - // calculate minimum length of the red line - const TInt maxmaskHeight = Min(8, Max(KAnimDimension/3,2)); // note this calculation mimics that for the size of the corners cut from the mask in CreateAnimL above - iMinimumCalcRedLine = KAnimDimension - maxmaskHeight*2; // the height of the image minus the two cut corners - - // create the timer object - iWaiter = CActiveWait::NewL(); - - // create screen bitmap object & scanline buffer - iScreenBitmap = new (ELeave) CFbsBitmap; - User::LeaveIfError(iScreenBitmap->Create(TSize(KAnimDimension, KAnimDimension), KTestDisplayMode)); - TInt bufLength = iScreenBitmap->ScanLineLength(windowSize.iHeight, KTestDisplayMode); - iScanlineBuf = HBufC8::NewL(bufLength); - - #ifdef RUN_SAMPLE_ON_LEFT - { - // play animation on iBaseWin window - iBaseWin->SetAnimation(KUidTestAnimation2)->Play(ETrue); - TSize subsize1 = iTestWin->BaseWin()->Size(); - TRect subposition1(subsize1); - CalcCentredAnimPosition(subposition1, subsize1); - iBaseWin->SetPosAnimation(KUidTestAnimation2, subposition1); - iBaseWin->InvalidateAndRedraw(ETrue,EFalse,ETrue); - } - #endif - } - -CTCrpAnim::~CTCrpAnim() - { - delete iRedrawWin; - delete iBaseWin; - delete iOverWin; - if (iAnim) - { - // destroy the animation object - iAnim->UnShareGlobally(); - iAnim->Destroy(); - delete iAnim; - iAnim = NULL; - } - if (iWaiter) - { - // destroy the timer object - delete iWaiter; - iWaiter = NULL; - } - if (iScreenBitmap) - { - // destroy the screen capture of the animation - delete iScreenBitmap; - iScreenBitmap = NULL; - } - if (iScanlineBuf) - { - // destroy the scanline buffer - delete iScanlineBuf; - iScanlineBuf = NULL; - } - User::After(200000); - } - -// -// This method checks the animation contained in the aAnimWin window has progressed. That is -// that it's drawn a sufficient number of concurrent frames to screen & the animation is -// drawn properly to screen -// returns a Bool identifying whether the animation is considered 'good' or not -// -void CTCrpAnim::CheckAnimProgressedL(CAnonAnimWindow* aAnimWin, TInt aAdditionalFrameCount, TBool aCaptureFrameResult) - { - TBool goodAnimation = ETrue; - - // retrieve the rect from the screen's bitmap that contains the animation - CWsScreenDevice* screen = TheClient->iScreen; - TRect animPos = *aAnimWin->GetPosAnimation(KUidTestAnimation2); - CTBaseWin* bWin = aAnimWin->CtBaseWin(); - animPos.Move(bWin->Position()); - User::LeaveIfError(screen->CopyScreenToBitmap(iScreenBitmap, animPos)); - - TInt frameNum = DetermineApproxFrameNum(iScreenBitmap, aCaptureFrameResult); // determines the frame Number & checks quality of animation (no tearing, etc) - TBool frameIdentified=(frameNum>=0); - - if (aCaptureFrameResult) - { - if (frameIdentified) - { - if (iPreviousFrameNum != KErrNotFound) - { - if (iPreviousFrameNum < frameNum) - { - TInt frameStep = KFrameStepCalculation * aAdditionalFrameCount; - iPreviousFrameNum += frameStep; // move to our *expected* framenumber - if (frameNum > iPreviousFrameNum) - { - // the frame number is ahead of it's expected position - // This suggests we've possibly missed animating a frame in wserv - // or test code isn't getting a chance to execute as crp animations taking all cpu cycles - // If its significantly outside norms, we log the fact (as a performance metric) - TInt performance = ((frameNum - iPreviousFrameNum) / frameStep); - if (performance > KFrameMissedAnimationsThreshold) - { - iFrameStatus.iFrameSkipped++; - goodAnimation = EFalse; - } - } - // else we're animating above an acceptable threshold - } - else if (iPreviousFrameNum == frameNum) // potentially not animating anymore - { - iFrameStatus.iFrameIdentical++; - goodAnimation = EFalse; - } - // else animation is progressing fine - } - // ignore iPreviousFrameNum == KErrNotFound - } - else - { - goodAnimation = EFalse; // couldn't id the red line - } - - if (goodAnimation) - { - iFrameStatus.iFrameOK++; - } - } - // else we were only interested in calculating the frameNum - iPreviousFrameNum = frameNum; - } - -// -// method to estimate the framenumber based on the location of the thin, red line. -// Also checks whether tearing of the animation has occured or the animation -// is only partially drawn. -// These are known issues with wserv animation performance & so we give some allowance for error -// -TInt CTCrpAnim::DetermineApproxFrameNum(CFbsBitmap* aBitmap, TBool aCaptureFrameResult) - { - TInt colFirstTear = KErrNotFound; // column id'ing the first tear in the vertical line - TPtr8 des = iScanlineBuf->Des(); // ptr to the scanline buffer - - // locate the thin, red line in the bitmap - for (TInt xPos = 0 ; xPos < aBitmap->SizeInPixels().iWidth ; xPos++) - { - aBitmap->GetVerticalScanLine(des, xPos, EColor16MA); - TUint32* pixel = (TUint32*) des.Ptr(); - TInt colour = KErrNone; - - for (TInt ii = 0 ; ii < aBitmap->SizeInPixels().iHeight ; ii++) - { - colour = PredominantColour(*pixel); - if (colour & EDetRed) - { - if (colFirstTear < 0) - { - // check the length of the red line is a good length - pixel += (iMinimumCalcRedLine - 1); // minus the one pixel to position on last pixel in red line - colour = PredominantColour(*pixel); - if (colour & EDetRed) - { - // good line - return xPos; - } - else // we've detected first part of a torn line - { - colFirstTear = xPos; - } - } - else - { - // located second part of torn line - if ((xPos - colFirstTear) > KAnimationTearWidthThreshold) - { - if (aCaptureFrameResult) - { - iFrameStatus.iFrameTearing++; - } - xPos = KErrNotFound; - } - return xPos; - } - break; - } - pixel++; - } - } - if (aCaptureFrameResult) - { - if (colFirstTear < 0) - { - iFrameStatus.iFrameEmpty++; // we never located any red line at all - } - else - { - iFrameStatus.iFramePartial++; // we only located a single, small part of the red line - } - } - return KErrNotFound; - } - -/** This internal loop tests that the animation and the foreground interact correctly - The primary test is that the outline of the animation - intersects the lines drawn on the foreground correctly, compared to a reference version. - The iBaseWin is already showing this reference anim. - If the animation is not drawn, or the foreground is wiped, then this test will fail. -**/ -void CTCrpAnim::TestSpriteLoopL(TBool aAnimForeground,TBool aDrawForeground) - { - _LIT(KForegroundInfo,"TestSpriteLoop animForeground [%d] drawForeground [%d]"); - INFO_PRINTF3(KForegroundInfo, aAnimForeground, aDrawForeground); - - if (!iOverWin && (aAnimForeground || aDrawForeground)) - { - User::Leave(KErrGeneral); // unable to run this test without iOverWin - } - - ResetFrameCounters(); - iTestWin->RemoveAnimation(KUidTestAnimation2); - iTestWin->SetBlankIt(ETrue); - if (iOverWin) - { - iOverWin->RemoveAnimation(KUidTestAnimation2); - iOverWin->SetBlankIt(ETrue); - } - - // determine which window holds the animation, & which will be invalidated with progressively larger rects - CCrpAnim* animWin=aAnimForeground?iOverWin:iTestWin; - CCrpAnim* paintWin=aDrawForeground?iOverWin:iTestWin; - paintWin->SetBlankIt(EFalse); - - // set & play the animation on the specified window (animWin) - animWin->SetAnimation(KUidTestAnimation2)->Play(ETrue); - TSize subsize1 = paintWin->BaseWin()->Size(); - TRect subposition1(subsize1); - CalcCentredAnimPosition(subposition1, subsize1); - animWin->SetPosAnimation(KUidTestAnimation2, subposition1); - - #ifdef RUN_SAMPLE_ON_LEFT - // play the demo animation in the left-hand window also - iBaseWin->InvalidateAndRedraw(ETrue, EFalse, ETrue); - #endif - - iTestWin->InvalidateAndRedraw(ETrue,EFalse,ETrue); - if (iOverWin) - { - iOverWin->InvalidateAndRedraw(ETrue,EFalse,ETrue); - } - - // invalidate increasingly larger squares on paintWin - // note, some fully overlap the animation, some partially overlap, and some don't overlap at all - TInt invalidateWaitTime=KAnimationFrameDelayTime*3/4; // microseconds - TInt temp = KErrNotFound; - for (TInt step=30;stepInvalidateAndRedraw(ETrue,EFalse,ETrue,&invalidRect); - - // calculate any additional frames that may be drawn by above. Note intentionally ignore frame result - temp = iPreviousFrameNum; - CheckAnimProgressedL(animWin, 1, EFalse); - - //new defect DEF101896: Test runs faster with this line removed, but there is evident tearing - iWaiter->Wait(invalidateWaitTime); //DEF101896 search string: //interrupt_foreground_draw - - if (temp == iPreviousFrameNum) - { - // give wserv more time to animate the frame - iWaiter->Wait(invalidateWaitTime); - } - CheckAnimProgressedL(animWin, 1); // calculate the frame drawn. Capture frame result - } - } - } - - // determine whether the animation was successful (ie: enough Good frames were detected) or not - // Note KMinGoodFrameThreshold is essentially an arbitrary number. This can be adjusted to accommodate - // performance requirements as needed - temp = LogResults(); - TInt quality = 100*iFrameStatus.iFrameOK/temp; - TEST(quality > KMinGoodFrameThreshold); - - ResetFrameCounters(); - iWaiter->Cancel(); - iTestWin->RemoveAnimation(KUidTestAnimation2); - iTestWin->SetBlankIt(ETrue); - if (iOverWin) - { - iOverWin->RemoveAnimation(KUidTestAnimation2); - iOverWin->SetBlankIt(ETrue); - } - } - -// -// resets the frame trackers to intial values -// -void CTCrpAnim::ResetFrameCounters() - { - iPreviousFrameNum = KErrNotFound; - iFrameStatus.iFrameOK = 0; - iFrameStatus.iFramePartial = 0; - iFrameStatus.iFrameIdentical = 0; - iFrameStatus.iFrameEmpty = 0; - iFrameStatus.iFrameTearing = 0; - iFrameStatus.iFrameSkipped = 0; - } - -// -// Log the current frame results & return the total number of frame calculations -// -// Calculated : the total number of frame-checks run -// Good: the frame was successfully drawn to screen & within specified tolerances for tearing, expected position & colour -// Partial: the frame was only partially drawn to screen. Specifcally the animated red line was only partially drawn -// Identical: the frame was in the same position as the last frame -// Empty: no redline was detected at all in the frame -// Skipped: the position of the frame was beyond the expected position -// -// There is a dependency on the timing as to when the frame is animated hence tolerances are used to allow -// for this. -// -TInt CTCrpAnim::LogResults() - { - TInt result = iFrameStatus.iFrameOK + iFrameStatus.iFramePartial + iFrameStatus.iFrameIdentical + - iFrameStatus.iFrameEmpty + iFrameStatus.iFrameTearing + iFrameStatus.iFrameSkipped; - INFO_PRINTF4(_L("\tAnimation results: Calculated[%d], Good[%d], Partial[%d]"), result, iFrameStatus.iFrameOK, iFrameStatus.iFramePartial); - INFO_PRINTF5(_L("\tAnimation results: Identical[%d], Empty[%d], Tearing[%d], Skipped[%d]"), iFrameStatus.iFrameIdentical, iFrameStatus.iFrameEmpty, iFrameStatus.iFrameTearing, iFrameStatus.iFrameSkipped); - return result; - } - -/** This test tests the result of drawing an animation and main draw to two windows that overlap. - The two windows are placed in exactly the same location, so the result of splitting the drawing across them should be "identical". - Note that when the anim and the draw are on different screens the lines are seen merged over the anim. -**/ -void CTCrpAnim::TestOverlappingWindowsL() - { - if (!iOverWin) - { - INFO_PRINTF1(_L("- Test skipped - transparency not supported")); - return; - } - - // setup necessary params - // Note we place the overlapping transparent window (iOverWin) directly on top of the test window (iTestWin) - iOverWin->BaseWin()->SetPosition(iTestWin->BaseWin()->Position()); - - enum - { - EAllBackground=0, - EForegroundDraw=1, - EForegroundAnim=2, - EAllForeGround=3, - ECountModes, - EFirstMode=EAllBackground, - }; - - // test the various permutations of overlapping vs animated windows - for (TInt mode = EFirstMode ; mode < ECountModes ; mode++) - { - INFO_PRINTF2(_L("TestOverlappingWindowsL [%d]"), mode); - TestSpriteLoopL((mode&EForegroundAnim)!=0,(mode&EForegroundDraw)!=0); - } - } - -/** - This method demonstrates clipping of an animation running behind a transparent window. - No main window redraw takes place here. -**/ -void CTCrpAnim::DemoClippingWindowsL() - { - if (!iOverWin) - { - INFO_PRINTF1(_L("- Test skipped - transparency not supported")); - return; - } - - // setup test case params. Note we calculate three different positions for the overlapping window - RWindow* win = iTestWin->Window(); - - TPoint screenPos= win->Position(); - TSize screenSize = win->Size(); - TRect subposition1(screenSize); - CalcCentredAnimPosition(subposition1, screenSize); - - TPoint testPositions[]= - { - //first test: window clips corner of anim - TPoint(screenPos.iX+screenSize.iWidth/2-10,screenPos.iY+screenSize.iHeight/2-10), - //test: window clips all of anim - TPoint(screenPos.iX+screenSize.iWidth/3,screenPos.iY+screenSize.iHeight/3), - //test: window clips none of anim - TPoint(screenPos.iX+screenSize.iWidth*2/3,screenPos.iY+screenSize.iHeight*2/3), - }; - - // calculate roughly number of frames we expect to have drawn - TInt loopWaitTime = KShortDelayLoop; // time given to allow animation to progress (arbitrary number) - float expectedFrameCount = 1; - if (loopWaitTime > KAnimationFrameDelayTime) - { - expectedFrameCount = loopWaitTime/KAnimationFrameDelayTime; - } - - for (TInt ii = 0; ii < ((sizeof testPositions)/(sizeof testPositions[0])) ; ii++) - { - // initialise test windows to known state with no active animations - ResetFrameCounters(); - iTestWin->RemoveAnimation(KUidTestAnimation2); - iTestWin->SetBlankIt(EFalse); - iOverWin->SetBlankIt(ETrue); - iOverWin->RemoveAnimation(KUidTestAnimation2); - - // position animation windows - iTestWin->SetAnimation(KUidTestAnimation2)->Play(ETrue); - iTestWin->SetPosAnimation(KUidTestAnimation2, subposition1); - iOverWin->BaseWin()->SetPosition(testPositions[ii]); // positions the transparent overlapping window - - // redraw both test windows - iTestWin->InvalidateAndRedraw(ETrue,EFalse,ETrue); - iOverWin->InvalidateAndRedraw(ETrue,EFalse,ETrue); - - // run the animation for an arbitrary period - for (TInt loopit = 0 ; loopit < 20 ; loopit++) - { - iWaiter->Wait(loopWaitTime); - CheckAnimProgressedL(iTestWin,static_cast(expectedFrameCount)); // log the frame result - } - - // calculate & log frame results. Test an acceptable number of frames were successfully animated - TInt total = LogResults(); - TInt qA = 100*iFrameStatus.iFrameOK/total; - TEST(qA > KMinGoodFrameThreshold); - } - } - -/** In this version, the background window is updated in patches. - If the animation intersects the transparent window then the whole transparent window is redrawn. -**/ -void CTCrpAnim::TestClippingWindowsL() - { - if (!iOverWin) - { - INFO_PRINTF1(_L("- Test skipped - transparency not supported")); - return; - } - // setup test case params. Note we calculate three different positions for the overlapping window - RWindow* win = iTestWin->Window(); - TPoint screenPos= win->Position(); - TSize screenSize = win->Size(); - - TPoint testPositions[]= - { - //first test: window clips corner of anim - TPoint(screenPos.iX+screenSize.iWidth/2-10,screenPos.iY+screenSize.iHeight/2-10), - //test: window clips all of anim - TPoint(screenPos.iX+screenSize.iWidth/3,screenPos.iY+screenSize.iHeight/3), - //test: window clips none of anim - TPoint(screenPos.iX+screenSize.iWidth*2/3,screenPos.iY+screenSize.iHeight*2/3), - }; - - for (TInt loopIt = 0; loopIt < ((sizeof testPositions)/(sizeof testPositions[0])) ; loopIt++) - { - iOverWin->BaseWin()->SetPosition(testPositions[loopIt]); // position the overlapping window - TestSpriteLoopL(EFalse,EFalse); - } - } - -/** This just demonstrates that an animation plays - for about 1 second. -**/ -void CTCrpAnim::BasicCRPDemo() - { - // draw the animation in two positions - TSize subsize1 = iTestWin->BaseWin()->Size(); - TRect subposition1(subsize1); - CalcCentredAnimPosition(subposition1, subsize1); - - if (iOverWin) - { - iOverWin->BaseWin()->SetPosition(KPointOffsite); //way away! - iOverWin->InvalidateAndRedraw(EFalse,EFalse,ETrue); - } - - CCrpAnim *animWin= iTestWin; - animWin->SetAnimation(KUidTestAnimation2)->Play(ETrue); - animWin->SetPosAnimation(KUidTestAnimation2, subposition1); - iTestWin->InvalidateAndRedraw(ETrue,EFalse,ETrue); - iBaseWin->InvalidateAndRedraw(ETrue,EFalse,ETrue); - - // allow the animation to play for ~1 second. Purpose is to demonstrate animation to an observer - iWaiter->Wait(KShortDelayLoop); - - ResetFrameCounters(); - iWaiter->Cancel(); - iTestWin->RemoveAnimation(KUidTestAnimation2); - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-CRP01-0001 - -@SYMDEF DEF100356 - -@SYMTestCaseDesc CRP animation test for redraw storing interrupting main draw - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Creates a CRP animation and runs it on the server scheduler - while also running redraws of the window. - - With Redraw storing this has been known to cause problems - sharing and resetting the window iDisplayRegion. - This is evidenced by white areas. - - -@SYMTestExpectedResults - The LHS window shows what the animation should look like just animating, - while the RHS window demonstrates the simultanious animation and redraw. - No White patches should be in evidence, and no missing fragments of animation. - The TEST should detect white patches. -*/ -void CTCrpAnim::TestSpriteInterruptsForegroundL() - { - // setup test params - TSize subsize1(iTestWin->BaseWin()->Size()); - TRect subposition1(subsize1); - CalcCentredAnimPosition(subposition1, subsize1); - if (iOverWin) - { - iOverWin->BaseWin()->SetPosition(KPointOffsite); // ensure overlapping transparent window DOESN'T overlap the test window - } - - // execute test loop - TestSpriteLoopL(EFalse,EFalse); - } - -void CTCrpAnim::RunTestCaseL(TInt /*aCurTestCase*/) - { - _LIT(KTest1,"1: Basic CRP demo"); - _LIT(KTest2,"2: sprite anim interrupts foreground"); - _LIT(KTest3,"3: translucent windows"); - _LIT(KTest4,"4: CRP clipping windows"); - _LIT(KTest5,"5: CRP & redraw clipping windows"); - _LIT(KTest6,"6: CRP Invalidation"); - - ((CTCrpAnimStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); - switch(++iTest->iState) - { - case 1: -/** -@SYMTestCaseID GRAPHICS-WSERV-CRP01-0002 -*/ - ((CTCrpAnimStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-CRP01-0002")); - iTest->LogSubTest(KTest1); - BasicCRPDemo(); - break; - case 2: - ((CTCrpAnimStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-CRP01-0001")); - iTest->LogSubTest(KTest2); - TestSpriteInterruptsForegroundL(); - break; - case 3: -/** -@SYMTestCaseID GRAPHICS-WSERV-CRP01-0003 -*/ - ((CTCrpAnimStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-CRP01-0003")); - iTest->LogSubTest(KTest3); - TestOverlappingWindowsL(); - break; - case 4: -/** -@SYMTestCaseID GRAPHICS-WSERV-CRP01-0004 -*/ - ((CTCrpAnimStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-CRP01-0004")); - iTest->LogSubTest(KTest4); - DemoClippingWindowsL(); - break; - case 5: -/** -@SYMTestCaseID GRAPHICS-WSERV-CRP01-0005 -*/ - ((CTCrpAnimStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-CRP01-0005")); - iTest->LogSubTest(KTest5); - TestClippingWindowsL(); - break; - case 6: -/** -@SYMTestCaseID GRAPHICS-WSERV-CRP01-0006 -*/ - ((CTCrpAnimStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-CRP01-0006")); - iTest->LogSubTest(KTest6); - //this testcase is removed, because invalidation is removed from CWsGraphicDrawer destructor (due to flickering) - break; - default: - ((CTCrpAnimStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - ((CTCrpAnimStep*)iStep)->CloseTMSGraphicsStep(); - TestComplete(); - } - ((CTCrpAnimStep*)iStep)->RecordTestResultL(); - } - -// -namespace //anonymous namespace - { -// - CAnimRedrawWindow::CAnimRedrawWindow(CCrpAnim *aAnimWindow, TBool aIsBase) : CTWin(), - iAnimWindow(aAnimWindow), - iIsBase(aIsBase) - { - } - - CAnimRedrawWindow::~CAnimRedrawWindow() - { - } - - void CAnimRedrawWindow::Draw() - { - CCrpAnim::Draw(Gc(),Size(),iIsBase,iAnimWindow->iRect,iAnimWindow->iBlankIt,iAnimWindow->iRepeatDrawMax,iAnimWindow->iAlphaValue); - if (iAnimWindow->iAnimUid!=TUid::Null()) - { - TheClient->Flush(); - Gc()->DrawWsGraphic(iAnimWindow->iAnimUid,iAnimWindow->iAnimPos,iAnimWindow->iAnimData.Pckg()); - TheClient->Flush(); - } - } - - // - - CCrpAnim::CCrpAnim(TBool aIsBase, TWinType aWinType) - : iWinType(aWinType), - iIsBase(aIsBase), - iBlankIt(EFalse), - iRepeatDrawMax(1), - iAnimUid(TUid::Null()), - iAlphaValue(ENoTransparency) - { - } - - CCrpAnim::~CCrpAnim() - { - delete iCtWin; - } - - void CCrpAnim::ConstructL(const TPoint &aPos, const TSize &aSize, TInt aAlphaValue) - { - TDisplayMode reqMode = EColor16MA; //for transparency we need 16ma or 16map mode - TDisplayMode *pReqMode=&reqMode; - switch(iWinType) - { - case ERedraw: - iCtWin = new(ELeave) CAnimRedrawWindow(this, iIsBase); - break; - case EBlank: - iCtWin = new(ELeave) CTBlankWindow(); - break; - case EBackedUp: - iCtWin = new(ELeave) CTBackedUpWin(EColor64K); - pReqMode = NULL; - break; - } - iCtWin->SetUpL(aPos, aSize, TheClient->iGroup, *TheClient->iGc, pReqMode, ETrue); - if (aAlphaValue != ENoTransparency) - { - User::LeaveIfError(Window()->SetTransparencyAlphaChannel()); - //the window itself should be completely transparent, the draw commands will use the alpha value - Window()->SetBackgroundColor(TRgb(0, 0, 0, 0)); - iAlphaValue = aAlphaValue; - } - } - - void CCrpAnim::SetEllipseDrawMode(CGraphicsContext::TDrawMode aEllipseDrawMode) - { - iEllipseDrawMode = aEllipseDrawMode; - } - - void CCrpAnim::DrawEllipse(CBitmapContext *aGc, const TRect &aRect, TInt aAlphaValue) - { - if(aAlphaValue != ENoTransparency) - { - aGc->SetBrushColor(TRgb(85,85,85, aAlphaValue)); - aGc->SetPenColor(TRgb(170,170,170, aAlphaValue)); - } - else - { - aGc->SetBrushColor(TRgb(85,85,85)); - aGc->SetPenColor(TRgb(170,170,170)); - } - aGc->SetDrawMode(iEllipseDrawMode); - aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - aGc->DrawEllipse(aRect); - } - - void CCrpAnim::Draw(CBitmapContext *aGc, const TSize &aSize, TBool aIsBase, const TRect &aRect, TBool aBlankIt,TInt aRepeat, TInt aAlphaValue) - { - static TInt sGrey=0; - sGrey+=3; - if (sGrey>0x40) - sGrey-=0x40; - sGrey=sGrey^0x20; - if(aAlphaValue != ENoTransparency) - { - aGc->SetBrushColor(TRgb(sGrey, sGrey, sGrey, aAlphaValue)); - aGc->SetPenColor(TRgb(KRgbGreen.Value(), aAlphaValue)); - } - else - { - aGc->SetBrushColor(TRgb::Gray256(sGrey)); - aGc->SetPenColor(KRgbGreen); - } - aGc->Clear(); - TInt xPos=aSize.iHeight,yPos=aSize.iWidth; - - // The test windows are created relative to screen size. The - // number of green lines generated needs to be tied into the - // window size to prevent green becoming the dominant colour - // when blended with the second animation, which would - // prevent the PredominantColour() algorithm from discovering - // the red line. - TInt yStep = aSize.iHeight/14; - TInt xStep = aSize.iWidth/6; - - //This paint is intentionally complex and slow so that the animation timer is likely to interrupt it. - if (!aBlankIt) - for (TInt nn = 0 ; nn < aRepeat ; nn++) - for(yPos=0 ; yPos < aSize.iHeight ; yPos += yStep) - for(xPos=0 ; xPos < aSize.iWidth ; xPos += xStep) - aGc->DrawLine(aRect.Center(),TPoint(xPos,yPos)); - if (aIsBase) - DrawEllipse(aGc, aRect, aAlphaValue); - } - - //This simple API may need replacing by a list and search if multiple anims are played together - TWsGraphicAnimation* CCrpAnim::SetAnimation(TUid aUid) - { //currently only have 1 animation - it gets replaced. It could get refiused - iAnimUid=aUid; - return &iAnimData; - } - - TWsGraphicAnimation* CCrpAnim::GetAnimation(TUid aUid) - { //currently only have 1 animation - if (iAnimUid==aUid) - return &iAnimData; - else - return NULL; - } - - void CCrpAnim::SetPosAnimation(const TUid& aUid, const TRect& aRect) - { //currently only have 1 animation - if (iAnimUid==aUid) - iAnimPos = aRect; - } - - TRect* CCrpAnim::GetPosAnimation(const TUid& aUid) - { //currently only have 1 animation - if (iAnimUid==aUid) - return &iAnimPos; - else - return NULL; - } - - TBool CCrpAnim::RemoveAnimation(TUid) - { - iAnimUid=TUid::Null(); - iAnimData.Stop(EFalse); - return ETrue; - } - - void CCrpAnim::DoDraw() - { - DoDraw(iBlankIt); - } - - inline void CCrpAnim::DoDraw(TBool aBlankIt) - { - __ASSERT_ALWAYS(iWinType!=EBlank,AutoPanic(EAutoPanicWindowType)); - iCtWin->Gc()->Activate(*Window()); - Draw(iCtWin->Gc(),Size(),iIsBase,iRect,aBlankIt,iRepeatDrawMax,iAlphaValue); - if (iAnimUid!=TUid::Null()) - iCtWin->Gc()->DrawWsGraphic(iAnimUid,iAnimPos,iAnimData.Pckg()); - iCtWin->Gc()->Deactivate(); - } - - void CCrpAnim::DoDrawEllipse() - { - __ASSERT_ALWAYS(iWinType!=EBlank,AutoPanic(EAutoPanicWindowType)); - iCtWin->Gc()->Activate(*Window()); - DrawEllipse(iCtWin->Gc(),iRect,iAlphaValue); - iCtWin->Gc()->Deactivate(); - } - - void CCrpAnim::InvalidateAndRedraw(TBool /*aUseBlankItMember*/,TBool /*aBlankIt*/,TBool aUseRWindowInvalidate,TRect* aRect) - { - RWindow& win = *Window(); - if (aRect) - { - if (aUseRWindowInvalidate) - win.Invalidate(*aRect); - else - Invalidate(*aRect); - } - else - { - if (aUseRWindowInvalidate) - win.Invalidate(); - else - Invalidate(); - } - if (aRect) - win.BeginRedraw(*aRect); - else - win.BeginRedraw(); - DoDraw(); - win.EndRedraw(); - TheClient->Flush(); - } - - void CCrpAnim::Invalidate(const TRect &aRect) - { - TRect rect(aRect); - rect.Move(iCtWin->Position()); - CTUser::Splat(TheClient,rect,TRgb::Gray256(0)); - } - -// - } //end anonymous namespace -// -__WS_CONSTRUCT_STEP__(CrpAnim) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/tcrpanim.h --- a/windowing/windowserver/tauto/tcrpanim.h Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,98 +0,0 @@ -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// TCrpAnim.H Defines class CTCrpAnim -// -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef __TCRPANIM_H__ -#define __TCRPANIM_H__ - -#include "AUTO.H" - -_LIT(KTCrpAnimStep,"TCrpAnim"); - -namespace //anonymous local scope - { - class CCrpAnim; - typedef CCrpAnim CAnonAnimWindow; - class CActiveWait; - typedef CActiveWait CAnonActiveWait; - } - -class CTCrpAnim : public CTWsGraphicsBase - { -public: - CTCrpAnim(CTestStep* aStep); - ~CTCrpAnim(); - void ConstructL(); -protected: - virtual void RunTestCaseL(TInt aCurTestCase); -private: - // TAnimFrameResult is a struct designed to track the various frame results - // as the animation progresses. Once the animation is complete, TAnimFrameResult - // provides an easy to read indication as to the animation's performance - struct TAnimFrameResult - { - TInt iFrameOK; - TInt iFramePartial; - TInt iFrameIdentical; - TInt iFrameEmpty; - TInt iFrameTearing; - TInt iFrameSkipped; - }; - void InvalidatePauseAndRedraw(const TRect &aRect,TTimeIntervalMicroSeconds32 aInterval); - void RedrawAndCheckWindows(TBool aBlankIt=EFalse); - void TestSpriteLoopL(TBool aAnimForeground,TBool aDrawForeground); - void CheckAnimProgressedL(CAnonAnimWindow* aAnimWin, TInt aAdditionalFrameCount, TBool aCaptureFrameResult = ETrue); - TInt DetermineApproxFrameNum(CFbsBitmap* aBitmap, TBool aCaptureFrameResult); - void ResetFrameCounters(); - TInt LogResults(); -// The tests - void TestSpriteInterruptsForegroundL(); - void TestSpriteRestartInterruptsForegroundL(); - void BasicCRPDemo(); - void TestOverlappingWindowsL(); - void TestClippingWindowsL(); - void DemoClippingWindowsL(); - void TestInvalidateL(); -private: - CAnonAnimWindow *iTestWin; - CAnonAnimWindow *iOverWin; - CAnonAnimWindow *iRedrawWin; - CAnonAnimWindow *iBaseWin; - TInt iPreviousFrameNum; // identifies the last successfully drawn frame number calculated - TInt iMinimumCalcRedLine; // the calculated minimum length of the red line in the animation - TAnimFrameResult iFrameStatus; // tracker for the performance of each animated frame - CActiveWait* iWaiter; // active object with configurable timer - CWsGraphicBitmapAnimation* iAnim; // ptr to server-side animation object - CFbsBitmap* iScreenBitmap; // bitmap holding screen snap-shot - HBufC8* iScanlineBuf; // buffer holding pixel data on a single vertical scan line - }; - -class CTCrpAnimStep : public CTGraphicsStep - { -public: - CTCrpAnimStep(); -protected: - //from CTGraphicsStep - virtual CTGraphicsBase* CreateTestL(); - }; - -#endif //__TCRPANIM_H__ diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/tdirecta.h --- a/windowing/windowserver/tauto/tdirecta.h Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,522 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef __TDIRECTA_H__ -#define __TDIRECTA_H__ - -#include "AUTO.H" -#include -#include -#include "TGraphicsHarness.h" - -//#define LOGGING - -class CColorAnimation; -class CScrollText; -class CScrollingTextDrawer; -class CDirectScreenAccessOld; - - -struct TDirectThreadParam - { - TRect iRect; - TInt iScreenNumber; - TBool iIsInFront; - }; - -class MAnimCallBacks - { -public: - virtual void LogLeave(TInt aErr)=0; - virtual void Fail()=0; - virtual void Finished(TInt aId)=0; - virtual TDisplayMode DisplayMode(TInt aId)=0; - virtual TRgb BrushColorL(TInt aId,TInt& aColor,TBool& aFinished)=0; - virtual TInt TimerInterval(TInt aId)=0; - virtual void FailedReStart(TInt aId,TInt aReason)=0; - virtual TInt SlowStopping(TInt aId,TInt aCount)=0; - virtual void Log(const TText8* aFile, TInt aLine, TInt aSeverity,const TDesC& aString)=0; -public: - CTBlankWindow* iCallBackWin; - }; - -class CTDirect : public CTWsGraphicsBase, public MAbortDirectScreenAccess, public MAnimCallBacks - { -public: - enum - { - eDirectNumFrames=10 - }; - enum - { - eDirectControlSem=0x01, - eDirectWindowSem=0x02, - eFontSet=0x04, - eMultiAnim=0x08, - }; -public: - CTDirect(CTestStep* aStep); - ~CTDirect(); - void ConstructL(); - TBool DrawFrame(); - TBool Restart(); - void ChangeToNextScreenModeL(); - void ChangeScreenScale(); - //The Tests - TestState AnimateWindowL(); - TestState AnimationDiesL(); - TestState PackagingClassL(); - TestState MultipleL(); - TestState FailCodesL(); - TestState ScrolingText1L(); - TestState RClassL(); - TestState ScrolingText2L(); - TestState ScrolingText3L(); - TestState ScrolingText4L(); - TestState DefectFix_KAA_5J3BLW_L(); - TestState KillAnimationL(); - TestState DSAWithScreenModeOffset1L(); - TestState DSAWithScreenModeOffset2L(); - TestState WindowPoistionRelativeToScreenL(); - TestState ScreenModeScalingTestL(); - TestState ScreenModeTestForScalingL(); - TestState MultipleDSAsOnSameWindowL(); - TestState TemporaryDeadlockL(); - TestState RegionTrackingOnlyNotificationsL(TUint aId); - TestState MixDsaAndRegionTrackingOnlyL(TBool aWhoExitsLast); - TestState TryDifferentSupportedModesL(); -protected: -//from CTGraphicsStep - virtual void RunTestCaseL(TInt aCurTestCase); -private: - void ConstrucBlankWindowL(); - void ScanTypeFacesL(); - void InitialiseAnimationL(); - void DestroyAnimation(); - void ResetScreenSizeMode(); - void StartDirect(); - void SignalWindow(); - void ModeSwitch(); - void ScrolingTextL(TInt aId,TRect aWinRect,TBool aStartThread,TInt aScreenMode=0); - void AnimTestL(TInt aId,TRect aWinRect,CTWinBase& aParent); - //Pure virtual function from MAbortDirectScreenAccess - void AbortNow(RDirectScreenAccess::TTerminationReasons aReason); - //Pure virtual functions from MAnimCallBacks - void LogLeave(TInt aErr); - void Fail(); - void Finished(TInt aId); - void DeleteMoveWindow(); - void DeleteScroll(); - TDisplayMode DisplayMode(TInt aId); - TRgb BrushColorL(TInt aId,TInt& aColor,TBool& aFinished); - TInt TimerInterval(TInt aId); - void FailedReStart(TInt aId,TInt aReason); - TInt SlowStopping(TInt aId,TInt aCount); - void Log(const TText8* aFile, TInt aLine, TInt aSeverity,const TDesC& aString); - void SetScreenMode(TInt aMode,TPixelsAndRotation& aPixelsAndRotation); - void CreateAnimForScreenModeL(TInt aAnimIndex,CTWinBase& aParent,TRect aRect,TInt aId); - void BlankTopClientWindowL(CTBlankWindow& aBlankWindow,TRect aRect); - void TestDifferentOriginAndScaleL(TSizeMode &aMode,TPoint aOrigin); - void CheckForTemporaryDeadlock(); -private: - CProcess* iProcess; - CProcess* iMoveWin; - RSemaphore iControlSem; - RMsgQueueBase iControlQueue; - RSemaphore iWinSem; - TRequestStatus iThreadStatus; - TUint iFlags; - CTBlankWindow* iWin; - CTBlankWindow* iWin2; - CFbsScreenDevice* iScrDev; - CFbsBitGc* iGc; - CFont* iFont; - CPeriodic* iTimer; - CIdle* iRestart; - CDirectScreenAccessOld* iDirect; - RRegion* iDrawingRegion; - TSize iScrSize; - TRect iDrawRect; - TInt iDrawHeight; - TInt iFrameNo; - TInt iLastTextWidth; - TInt iLastMaxTextWidth; - TInt iFrameToSignalAfter; - TBool iDelay; - TBool iCancelNext; - TBool iWindowDead; - CColorAnimation* iAnim; - CColorAnimation* iAnims[13]; - TInt iCount; - CScrollText* iScroll; - TInt iCycles; - TScreenModeEnforcement iModeBackup; - TThreadStartUp iFirstFunction; - TInt iNumThreadHandles; - CTBlankWindow* iBlankTopClientWin1; - CTBlankWindow* iBlankTopClientWin2; - CPeriodic* iChangeScreenModeTimer; - TInt iCurrentMode; - TInt iNumOfModes; - TPoint iCurrentScreenModeOrigin; - TSize iCurrentScreenModeScale; - TInt iNumAnimation; - TSizeMode iModeData; - CPeriodic* iScreenModeTimer; - TInt iIsScalingSupported; - TInt iNumOfCallBack; - TBool iTestJustFailed; - TBool iTestJustCompleted; - TInt iState; - TBool iNextFrameFinished; - TBool iPackagingFinished; - TBool iTimerRunning; - }; - -class CDirectScreenAccessOld : public CActive - { -public: - static CDirectScreenAccessOld* NewL(RWsSession& aWs,MAbortDirectScreenAccess& aAborter); - ~CDirectScreenAccessOld(); - TInt Request(RRegion*& aRegion, RWindowBase& aWindow); -private: - inline CDirectScreenAccessOld(RWsSession& aWs,MAbortDirectScreenAccess& aAborter) - : CActive(RDirectScreenAccess::EPriorityVeryHigh), iDirectAccess(aWs), iAborter(aAborter) {} - void ConstructL(); - //Pure virtual functions from CActive - void DoCancel(); - void RunL(); -private: - RDirectScreenAccess iDirectAccess; - MAbortDirectScreenAccess& iAborter; - TBool iAborting; - }; - -class CColorAnimation : public CBase, public MDirectScreenAccess - { -public: - enum - { - eStopNow=EFalse, - eStopDelayed=ETrue, - eAbort=2, - eAbortAll, - }; -public: - static TInt DrawColorL(TAny* aAnimation); - static TInt IdlingL(TAny* aAnimation); - static CColorAnimation* NewL(TInt aScreenNumber,TInt aId,MAnimCallBacks& aCallBack,CTWinBase& aParent,TRect aExtent,TBool aStart,TBool aRegionTrackingOnly = EFalse); - inline CColorAnimation(TInt aScreenNumber,TInt aId,MAnimCallBacks& aCallBack) :iId(aId), iCallBack(aCallBack), iScreenNumber(aScreenNumber) {} - ~CColorAnimation(); - void ConstructL(CTWinBase& aParent,TRect aExtent,TBool aRegionTrackingOnly,TInt aTypeWindow=0,TInt aSingleWinForMultipleDSA=0); - void StartL(TBool aChildWindow=EFalse); - void StartOrPanic(); - void Stop(); - void BringWindowToFront(); - void ChangeModeL(TDisplayMode aMode); - TBool inline IsTimerActive() {return iTimer->IsActive();} - inline MAnimCallBacks& CallBack() { return iCallBack; } - TPoint AbsoluteWindowPosition(TInt aWindowId=0); - inline CDirectScreenAccess* GetDrawer(); - void FinishTest(); - TBool TestGcAndScreenDeviceValues(); - //inline TBool IsReadyToAbort(){return (iDrawer->iStatus!=KRequestPending);} -protected: - void DrawColorL(); - void IdlingL(); - /*pure virtual function from MAbortDirectScreenAccess*/ - void AbortNow(RDirectScreenAccess::TTerminationReasons aReason); - /*pure virtual function from MDirectScreenAccess*/ - void Restart(RDirectScreenAccess::TTerminationReasons aReason); -private: - TInt iId; - CTBlankWindow* iWindow; - CTBlankWindow* iWindow2; - TSize iWinSize; - CDirectScreenAccess* iDrawer; - CPeriodic* iTimer; - MAnimCallBacks& iCallBack; - TInt iColor; - TInt iCount; - TUint iIdling; - TInt iScreenNumber; - TInt iSingleWinForMultipleDSA; - TBool iRegionTrackingOnly; - }; - -class CScrollingTextDrawer : public CBase - { -public: - static CScrollingTextDrawer* NewL(TInt aScreenNumber,CFbsScreenDevice*& aDevice,CFbsBitGc& aGc); - ~CScrollingTextDrawer(); - inline void SetScrollJump(TInt aJump) {iJump=aJump;} - void SetBottomOfTest(TInt aBottom); - void Scroll(); -private: - inline CScrollingTextDrawer(CFbsScreenDevice*& aDevice,CFbsBitGc& aGc) : iDevice(aDevice), iGc(&aGc) {} - void ConstructL(TInt aScreenNumber); - void CreateFontL(); -private: - CFbsScreenDevice*& iDevice; - CFbsScreenDevice* iFontDevice; - CFbsBitGc* iGc; - CFont* iFont; - TBuf<32> iText; - TRect iDrawRect; - TInt iDrawHeight; - TInt iCharWidth; - TInt iFirstChar; - TInt iJump; -#if defined(LOGGING) - RWsSession iWs; -#endif - }; - -class CScrollText : public CBase, public MDirectScreenAccess - { -public: - static TInt DrawText(TAny* aAnimation); - static CScrollText* NewL(TInt aScreenNumber,TInt aId,CTWindowGroup& aParent,TInt aScrollJump,TBool aStart=EFalse); - inline CScrollText(TInt aId,TInt aScrollJump,TInt aScreenNumber) :iId(aId), iScrollJump(aScrollJump), iScreenNumber(aScreenNumber) {} - ~CScrollText(); - void ConstructL(CTWindowGroup& aParent); - void StartL(); - void Stop(); - void ContinueL(); - inline TBool IsRunning() {return iTimer->IsActive();} - inline void SetCountDown(TInt aCountDown) {iAbortCountDown=aCountDown; iCounting=ETrue;} - inline void SetBottomOfTest(TInt aBottom) {iTextDraw->SetBottomOfTest(aBottom);} -private: - void ScrollText(); - void DoContinueL(); - /*pure virtual function from MAbortDirectScreenAccess*/ - void AbortNow(RDirectScreenAccess::TTerminationReasons aReason); - /*pure virtual function from MDirectScreenAccess*/ - void Restart(RDirectScreenAccess::TTerminationReasons aReason); -private: - TInt iId; - CTBlankWindow* iWindow; - TSize iWinSize; - CDirectScreenAccess* iDrawer; - CScrollingTextDrawer* iTextDraw; - CPeriodic* iTimer; - TInt iScrollJump; - TBool iCounting; - TInt iAbortCountDown; - TInt iScreenNumber; - }; - - -/** - A simple class based on CScrollText constructs a blank window that has - a blank window child, used for functional coverage testing of CWsClientWindow - */ -class CWindowWithChild : public CBase, public MDirectScreenAccess - { -public: - static CWindowWithChild* NewL(TInt aScreenNumber, CTWindowGroup& aParent,TBool aStart=EFalse); - inline CWindowWithChild(TInt aScreenNumber) : iScreenNumber(aScreenNumber) {} - ~CWindowWithChild(); - void ConstructL(CTWindowGroup& aParent); - void StartL(); - void Stop(); - void ContinueL(); - inline TBool IsRunning() {return iRunning;} - void PerformCoverageCalls(); - RWindow *ChildWindow() {return iChildWindow->Win();} -private: - void DoContinueL(); - /*pure virtual function from MAbortDirectScreenAccess*/ - void AbortNow(RDirectScreenAccess::TTerminationReasons aReason); - /*pure virtual function from MDirectScreenAccess*/ - void Restart(RDirectScreenAccess::TTerminationReasons aReason); -private: - CTBlankWindow* iWindow; - CTWin * iChildWindow; - TSize iWinSize; - CDirectScreenAccess* iDrawer; - TInt iScreenNumber; - TBool iRunning; - }; - - -class CWsBase : public CBase - { -public: -protected: - ~CWsBase(); - void ConstructL(TInt aScreenNumber,TInt aHandle); - void CreateBlankWindowL(RBlankWindow& iWin,TInt aHandle); -protected: - RWsSession iWs; - CWsScreenDevice *iScrDev; - RWindowGroup iGroup; - }; - -class CAnimating : public CWsBase, public MAbortDirectScreenAccess - { -public: - static TInt StartLC(TAny* aScreenNumber); - //static CAnimating* NewLC(); - void DrawFrame(); - /*pure virtual function from MAbortDirectScreenAccess*/ - void AbortNow(RDirectScreenAccess::TTerminationReasons aReason); -private: - void ConstructL(TInt aScreenNumber); - ~CAnimating(); - void StartAnimatingL(); -private: - RSemaphore iControlSem; - RMsgQueueBase iControlQueue; - TBool iSemCreated; - RBlankWindow iWindow; - CFbsScreenDevice* iScrDev; - CFbsBitGc* iGc; - TSize iScrSize; - CDirectScreenAccessOld* iDirect; - RRegion* iDrawingRegion; - CPeriodic* iTimer; - TInt iColor; - }; - -class CMoveWindow : public CWsBase - { -public: - static TInt StartLC(TAny* aScreenNumber); - static TInt StateChange(TAny* aMoveWin); - static TInt FlipChange(TAny*); - //Call Backs - void MoveWindow(); -private: - inline static CMoveWindow* Cast(TAny* aMoveWin) {return STATIC_CAST(CMoveWindow*,aMoveWin);} - ~CMoveWindow(); - void ConstructL(TInt aScreenNumber); - void CreateTimerL(); - void StateChange(); - void ToggleDisplayMode(); - void FlipChange(); -private: - CPeriodic* iFlipTimer; - CPeriodic* iStateTimer; - CPeriodic* iTimer; - CWsScreenDevice* iDevice; - RBlankWindow iWindow; - TDisplayMode iDisplayMode; - RBackedUpWindow iBackUpWin; - CWindowGc* iGc; - TRect iBounceArea; - TSize iScrSize; - TPoint iTl; - TSize iSize; - TSize iDelta; - TInt iStateCountDown; - TInt iNumOfModes; - TInt iCurrentMode; - }; - -class CBugFixColorAnimation : public CColorAnimation - { -public: - static CBugFixColorAnimation* NewL(TInt aScreenNumber,TInt aId,MAnimCallBacks& aCallBack,CTWindowGroup& aParent,TRect aExtent,TBool aStart=EFalse); - ~CBugFixColorAnimation(); - inline void Started() { iSem.Signal(); } -private: - CBugFixColorAnimation(TInt aScreenNumber,TInt aId,MAnimCallBacks& aCallBack); - void ConstructL(CTWindowGroup& aParent,TRect aExtent); -private: - /*pure virtual function from MAbortDirectScreenAccess*/ - void AbortNow(RDirectScreenAccess::TTerminationReasons aReason); - /*pure virtual function from MDirectScreenAccess*/ - void Restart(RDirectScreenAccess::TTerminationReasons aReason); -private: - CProcess* iThread; - CIdle* iTestFailed; - TRect iAnimRect; - TDirectThreadParam iThreadParam; - RSemaphore iSem; - }; - -class CRegionTrackingOnly : public CColorAnimation - { -public: - static CRegionTrackingOnly* NewL(TInt aScreenNumber,TInt aId,MAnimCallBacks& aCallBack,CTWindowGroup& aParent,TRect aExtent,TBool aStart,TBool aOpenWindowInFrontDsa); - void ConstructL(CTWindowGroup& aParent,TRect aExtent,TBool aOpenWindowInFrontDsa); - ~CRegionTrackingOnly(); - inline void Started() { iSem.Signal(); } -private: - CRegionTrackingOnly(TInt aScreenNumber,TInt aId,MAnimCallBacks& aCallBack); - /*Overriding of bases class virtual functions*/ - void AbortNow(RDirectScreenAccess::TTerminationReasons aReason); - void Restart(RDirectScreenAccess::TTerminationReasons aReason); -private: - CProcess* iThread; - TRect iAnimRect; - TBool iExpectedToAbort; - TDirectThreadParam iThreadParam; - RSemaphore iSem; - }; - -/*CPanicDirect*/ - class CPanicDirect : public CBase - { - public: - static TInt DoTestOnNewScheduler(TInt aInt, TAny* aPtr); - static TInt DoTestOnNewSchedulerL(TInt aInt, TAny* aPtr); - private: - inline CPanicDirect() {} - ~CPanicDirect(); - void ConstructL(TInt aScreenNumber, TInt aInt); - static void DoTestNowL(TInt aInt, TAny* aPtr); - void TestL(); - void DoDrawingL(); -private: - TInt iTestNo; - RWsSession iWs; - CWsScreenDevice* iWsScrDev; - RWindowGroup iGroup; - RBlankWindow iBlankWin; - RDirectScreenAccess iDirect; - TRequestStatus iDirectStatus; - RRegion* iRegion; - RTimer iTimer; - TRequestStatus iTimerStatus; - TBool iDrawingAllowed; - CFbsScreenDevice* iScreenDevice; - CFbsBitGc* iGc; - TDisplayMode iDisplayMode; - CScrollingTextDrawer* iTextDraw; - TInt iCount; - TInt iScreenNumber; - }; - -class CTDirectStep : public CTGraphicsStep - { -public: - CTDirectStep(); -protected: - //from CTGraphicsStep - virtual CTGraphicsBase* CreateTestL(); - }; - -_LIT(KTDirectStep,"TDirect"); - - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/tdirecta2.cpp --- a/windowing/windowserver/tauto/tdirecta2.cpp Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,185 +0,0 @@ -// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Test Direct Screen Access on a screen that supports transparency -// -// - -#include "tdirecta2.h" - -const TInt KMainTestOrdinalPriority=65535; -const TInt KOntopOfAllOthersTestOrdinalPriority=65537; - -CTDirect2::CTDirect2(CTestStep* aStep): - CTWsGraphicsBase(aStep) - { - } - -CTDirect2::~CTDirect2() - { - delete iDsa; - delete iUnderWindow; - delete iOverWindow; - delete iScreenDevice; - delete iWindowGroup; - delete iTimer; - - // put focus back to current screen as this test changed the focus screen to primary screen - TheClient->iWs.SetFocusScreen(iTest->iScreenNumber); - } - -void CTDirect2::ConstructL() - { - // the following line makes sure that a console object hidden outside of - // screens range doesn't affect test results being on top of tested objects - TheClient->iGroup->GroupWin()->SetOrdinalPosition(0, KMainTestOrdinalPriority); - } - -TInt CTDirect2::Timeout(TAny* aDirect2) - { - static_cast(aDirect2)->HandleTimeout(); - return KErrNone; - } - -void CTDirect2::HandleTimeout() - { - // Send window group to back to avoid possibility of it - // interfering with other parts of this test - iWindowGroup->GroupWin()->SetOrdinalPosition(0, -1); - - iTimer->Cancel(); // Don't call back again - TEST(EFalse); // Fail the test, as we didn't get a DSA abort within timeout period - iTestCaseComplete = ETrue; // Move to next test case - } - -void CTDirect2::AbortNow(RDirectScreenAccess::TTerminationReasons /*aReason*/) - { - iTimer->Cancel(); // As soon as abort is received, we don't need the timer anymore - } - -void CTDirect2::Restart(RDirectScreenAccess::TTerminationReasons /*aReason*/) - { - // Send window group to back to avoid possibility of it - // interfering with other tests - iWindowGroup->GroupWin()->SetOrdinalPosition(0, -1); - - iTestCaseComplete = ETrue; // Move to next test case - - // Don't bother restarting DSA, we were only interested in making sure the abort was sent by wserv - } - -// Starts DSA on a topmost window, then puts a translucent window ontop of it -// to make sure wserv sends a DSA Abort even though the translucent window -// hasn't changed the visible area of the DSA window -void CTDirect2::StartTranslucentWindowOverDsaL() - { - // Use a new window group so we can put windows ontop of all others - iWindowGroup = new(ELeave) CTWindowGroup(TheClient); - iWindowGroup->ConstructL(); - - // Create new blank window - iUnderWindow = new(ELeave) CTBlankWindow(); - iUnderWindow->SetUpL(TPoint(10,10), TSize(100,100), iWindowGroup, *TheClient->iGc); - iUnderWindow->SetColor(TRgb(0,192,0)); - - // Make window group visible ontop of all others - User::LeaveIfError(iWindowGroup->GroupWin()->SetOrdinalPositionErr(0, KOntopOfAllOthersTestOrdinalPriority)); - TheClient->Flush(); - - // Call Finish() to wait until under window has been rendered. - // Once window has been rendered, we can be sure window server has - // calculated the "top visible" region of the window. - TheClient->iWs.Finish(); - - // Start DSA on under window - iScreenDevice = new(ELeave) CWsScreenDevice(TheClient->iWs); - User::LeaveIfError(iScreenDevice->Construct(iTest->iScreenNumber)); - iDsa = CDirectScreenAccess::NewL(TheClient->iWs, *iScreenDevice, *iUnderWindow->BaseWin(), *this); - iDsa->StartL(); - - // Put translucent window ontop so as to reduce the top visible area, but leave the - // visible area unchanged (as the translucent window doesn't change the visible area - // of the window underneath it). - iOverWindow = new(ELeave) CTTitledWindow(); - _LIT(KTranslucentWindowTitle, "Translucent window"); - iOverWindow->SetUpL(TPoint(60,60), TSize(150,100), iWindowGroup, *TheClient->iGc, NULL, ETrue); - TWindowTitle windowTitle(KTranslucentWindowTitle); - iOverWindow->SetTitle(windowTitle); - iOverWindow->SetColor(TRgb(192, 0, 0, 128)); - TheClient->Flush(); - - // Start a timer, if the timeout triggers, fail the test, as we should get - // an abort DSA from wserv within the timeout - iTimer = CPeriodic::NewL(CActive::EPriorityStandard); - const TInt KTimeoutPeriod = 5000000; // 5 seconds should give the client plenty of time to respond to the abort - iTimer->Start(KTimeoutPeriod, 0, TCallBack(CTDirect2::Timeout, this)); - - // Do nothing more here, once over win is rendered, wserv should cause CAbortTest::AbortNow - // to be called - } - -void CTDirect2::RunTestCaseL(TInt aCurTestCase) - { - ((CTDirect2Step*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); - switch(aCurTestCase) - { -/** -@SYMTestCaseID GRAPHICS-WSERV-0176 - -@SYMDEF PDEF116863 - -@SYMTestCaseDesc Overlapping a translucent window ontop of a DSA window should abort DSA - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Start DSA on a blank window. - Then place a translucent window so that it partially overlaps the DSA window. - -@SYMTestExpectedResults Wserv should send a DSA abort when the translucent window is placed ontop of the DSA window. -*/ - case 1: - ((CTDirect2Step*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0176")); - if (!iOnceOnly) - { - _LIT(DSA1,"Translucent window overlaping DSA window"); - INFO_PRINTF1(DSA1); - StartTranslucentWindowOverDsaL(); // call this only once - iOnceOnly = ETrue; - } - if (!iTestCaseComplete) - { - // Keep calling this test case until iTestCaseComplete is true - ResetCounter(aCurTestCase-1); - } - else - { - iOnceOnly = EFalse; - // Move to next test case in sequence - iTestCaseComplete = EFalse; - } - break; - - default: - INFO_PRINTF1(_L("Test complete\n")); - ((CTDirect2Step*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - ((CTDirect2Step*)iStep)->CloseTMSGraphicsStep(); - TestComplete(); - break; - } - ((CTDirect2Step*)iStep)->RecordTestResultL(); - } - -__WS_CONSTRUCT_STEP__(Direct2) - diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/tdirecta2.h --- a/windowing/windowserver/tauto/tdirecta2.h Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,73 +0,0 @@ -// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef __TDIRECTA2_H__ -#define __TDIRECTA2_H__ - -#include "AUTO.H" -#include "TGraphicsHarness.h" - -// This DSA test code only works when run using a screen that supports transparency. -class CTDirect2 : public CTWsGraphicsBase, public MDirectScreenAccess - { -public: - CTDirect2(CTestStep* aStep); - ~CTDirect2(); - void ConstructL(); - - static TInt Timeout(TAny* aAbortTest); - - // from MAbortDirectScreenAccess - void AbortNow(RDirectScreenAccess::TTerminationReasons aReason); - // from MDirectScreenAccess - void Restart(RDirectScreenAccess::TTerminationReasons aReason); - -protected: - //from CTGraphicsStep - void RunTestCaseL(TInt aCurTestCase); - -private: - void StartTranslucentWindowOverDsaL(); - void HandleTimeout(); - -private: - CWsScreenDevice* iScreenDevice; - CTWindowGroup* iWindowGroup; - CTBlankWindow* iUnderWindow; // window to perform DSA on - CTTitledWindow* iOverWindow; // translucent window to overlap DSA window - CDirectScreenAccess* iDsa; - CPeriodic* iTimer; - TBool iTestCaseComplete; - TBool iOnceOnly; - }; - -class CTDirect2Step : public CTGraphicsStep - { -public: - CTDirect2Step(); -protected: - //from CTGraphicsStep - virtual CTGraphicsBase* CreateTestL(); - }; - -_LIT(KTDirect2Step,"TDirect2"); - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/tdrawresource.cpp --- a/windowing/windowserver/tauto/tdrawresource.cpp Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1144 +0,0 @@ -// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include "tdrawresource.h" -#include -#include -#include -#include -#include - - -__WS_CONSTRUCT_STEP__(DrawResource); - - -#if defined(__X86GCC__) -extern "C" TInt atexit(void (*function)(void)) - { - return KErrNone; - } -#endif - -// -// class CTestWsGraphicsContext -// -CTestWsGraphicsContext* CTestWsGraphicsContext::NewL(RDirectGdiImageTarget& aTarget) - { - CTestWsGraphicsContext* self = new(ELeave) CTestWsGraphicsContext; - CleanupStack::PushL(self); - self->ConstructL(aTarget); - CleanupStack::Pop(self); - return self; - } - -void CTestWsGraphicsContext::ConstructL(RDirectGdiImageTarget& aTarget) - { - CDirectGdiDriver* driver = CDirectGdiDriver::Static(); - User::LeaveIfNull(driver); - iContext = CDirectGdiContext::NewL(*driver); - TInt err = iContext->Activate(aTarget); - User::LeaveIfError(err); - } - -CTestWsGraphicsContext::~CTestWsGraphicsContext() - { - delete iContext; - } - -TAny* CTestWsGraphicsContext::ResolveObjectInterface(TUint aTypeId) - { - switch(aTypeId) - { - case MWsDrawableSourceProvider::EWsObjectInterfaceId: - return static_cast(this); - } - return NULL; - - } - -TInt CTestWsGraphicsContext::CreateDrawableSource(const TSgDrawableId& aDrawableId, TAny*& aSource) - { - TRAPD(err, DoCreateDrawableSourceL(aDrawableId, aSource)); - return err; - } - -void CTestWsGraphicsContext::DoCreateDrawableSourceL(const TSgDrawableId& aDrawableId, TAny*& aSource) - { - CDirectGdiDriver* driver = CDirectGdiDriver::Static(); - if (!driver) - { - User::Leave(KErrNotReady); - } - RDirectGdiDrawableSource* drawableSource = new(ELeave) RDirectGdiDrawableSource(*driver); - CleanupStack::PushL(drawableSource); - RSgDrawable drawable; - User::LeaveIfError(drawable.Open(aDrawableId, ESgDoNotRestrictUsage)); - CleanupClosePushL(drawable); - User::LeaveIfError(drawableSource->Create(drawable)); - CleanupStack::PopAndDestroy(); - CleanupStack::Pop(drawableSource); - aSource = drawableSource; - } - -void CTestWsGraphicsContext::CloseDrawableSource(TAny* aSource) - { - RDirectGdiDrawableSource* drawableSource = static_cast(aSource); - drawableSource->Close(); - delete drawableSource; - } - -void CTestWsGraphicsContext::DrawResource(const TAny* aSource, const TPoint& aPos, CWindowGc::TGraphicsRotation aRotation) - { - const RDirectGdiDrawableSource* drawableSource = static_cast(aSource); - iContext->DrawResource(aPos, *drawableSource, (DirectGdi::TGraphicsRotation)aRotation); - iPos = aPos; - iRotation = (DirectGdi::TGraphicsRotation)aRotation; - } - -void CTestWsGraphicsContext::DrawResource(const TAny* aSource, const TRect& aRect, CWindowGc::TGraphicsRotation aRotation) - { - const RDirectGdiDrawableSource* drawableSource = static_cast(aSource); - iContext->DrawResource(aRect, *drawableSource, (DirectGdi::TGraphicsRotation)aRotation); - iDestRect = aRect; - iRotation = (DirectGdi::TGraphicsRotation)aRotation; - } - -void CTestWsGraphicsContext::DrawResource(const TAny* aSource, const TRect& aRectDest, const TRect& aRectSrc, CWindowGc::TGraphicsRotation aRotation) - { - const RDirectGdiDrawableSource* drawableSource = static_cast(aSource); - iContext->DrawResource(aRectDest, *drawableSource, aRectSrc, (DirectGdi::TGraphicsRotation)aRotation); - iDestRect = aRectDest; - iSrcRect = aRectSrc; - iRotation = (DirectGdi::TGraphicsRotation)aRotation; - } - -void CTestWsGraphicsContext::DrawResource(const TAny* aSource, const TRect& aRect, const TDesC8& aParam) - { - const RDirectGdiDrawableSource* drawableSource = static_cast(aSource); - iContext->DrawResource(aRect, *drawableSource, aParam); - iDestRect = aRect; - } - - -void CTestWsGraphicsContext::Clear() - { - iContext->Clear(); - } - -// -// class CTDrawResource -// - -CTDrawResource::CTDrawResource(CTestStep* aStep) - : CTWsGraphicsBase(aStep) - { - } - -CTDrawResource::~CTDrawResource() - { - iWindow.Close(); - delete iRefBitmap; - delete iRotatedRefBitmap; - delete iScaledBitmap; - delete iScaledCroppedBitmap; - delete iCopyBitmap; - delete iBitmapWrongScreenNumber; - - delete iWsGrapicResolver; - delete iGraphicsCon; - - iWsDrawableSource.Close(); - iImage.Close(); - iImageTarget.Close(); - iImageCollection.Close(); - - CDirectGdiDriver* dGdiDriver = CDirectGdiDriver::Static(); - if(dGdiDriver) - { - dGdiDriver->Close(); - } - SgDriver::Close(); - } - -void CTDrawResource::ConstructL() - { - //Constrcut and setup window to be drawn to - iWindow = RWindow(TheClient->iWs); - User::LeaveIfError(iWindow.Construct(*TheClient->iGroup->GroupWin(),ENullWsHandle)); - TSize iWinSize=TSize(TheClient->iScreen->SizeInPixels()); - iWindow.SetExtent(TPoint(0,0),iWinSize); - iWindow.Activate(); - iWindow.BeginRedraw(); - iWindow.EndRedraw(); - - //Creates all reference and copy bitmaps required for all tests - CreateReferenceAndCopyBitmapsL(); - - TInt err = CDirectGdiDriver::Open(); - User::LeaveIfError(err); - err = SgDriver::Open(); - User::LeaveIfError(err); - - //create image target - CDirectGdiDriver* theDGdiDriver = CDirectGdiDriver::Static(); - if(!theDGdiDriver) - { - User::Leave(KErrNotReady); - } - TSgImageInfo info; - info.iUsage = ESgUsageDirectGdiTarget | ESgUsageDirectGdiSource | ESgUsageCompositionSource; - info.iPixelFormat = EUidPixelFormatRGB_565; - info.iSizeInPixels = TSize(200, 200); - info.iShareable = ETrue; - const TInt KImageCount = 1; - err = iImageCollection.Create(info, KImageCount); - User::LeaveIfError(err); - - err = iImageCollection.OpenImage(0, iImage); - User::LeaveIfError(err); - iImageTarget = RDirectGdiImageTarget(*theDGdiDriver); - err = iImageTarget.Create(iImage); - User::LeaveIfError(err); - - // construction of image source - RSgImage sgImage; - CreateSgImageFromBitmapL(sgImage); - CleanupClosePushL(sgImage); - iWsDrawableSource = RWsDrawableSource(TheClient->iWs); - User::LeaveIfError(iWsDrawableSource.Create(sgImage, TheClient->iScreen->GetScreenNumber())); - - //Create dummy MWsGraphicResolver - required RemoteGc testing - iWsGrapicResolver = new (ELeave) CWSGraphicsRes(); - - //Create dummy MWsGraphicsContext - required RemoteGc testing - iGraphicsCon = CTestWsGraphicsContext::NewL(iImageTarget); - - CleanupStack::PopAndDestroy(&sgImage); - } - -void CTDrawResource::RunTestCaseL(TInt aCurTestCase) - { - ((CTDrawResourceStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); - switch(aCurTestCase) - { - case 1: - ((CTDrawResourceStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-DRAWRESOURCE-0001")); - INFO_PRINTF1(_L("DrawResourcePos Test")); - TestDrawResourcePos(); - break; - case 2: - ((CTDrawResourceStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-DRAWRESOURCE-0002")); - INFO_PRINTF1(_L("DrawResourceRect Test")); - TestDrawResourceRect(); - break; - case 3: - ((CTDrawResourceStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-DRAWRESOURCE-0003")); - INFO_PRINTF1(_L("DrawResourceScale Test")); - TestDrawResourceScale(); - break; - case 4: - ((CTDrawResourceStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-DRAWRESOURCE-0004")); - INFO_PRINTF1(_L("RWsDrawableSource Reference Counting Test")); - TestRWsDrawableSourceReferenceCountingL(); - break; - case 5: - ((CTDrawResourceStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-DRAWRESOURCE-0005")); - INFO_PRINTF1(_L("RemoteGcDrawResourcePos Test")); - TestRemoteGcDrawResourcePosL(); - break; - case 6: - ((CTDrawResourceStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-DRAWRESOURCE-0006")); - INFO_PRINTF1(_L("RemoteGcDrawResourceRect Test")); - TestRemoteGcDrawResourceRectL(); - break; - case 7: - ((CTDrawResourceStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-DRAWRESOURCE-0007")); - INFO_PRINTF1(_L("RemoteGcDrawResourceScale Test")); - TestRemoteGcDrawResourceScaleL(); - break; - case 8: - ((CTDrawResourceStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-DRAWRESOURCE-0008")); - INFO_PRINTF1(_L("DrawResourceScreens Test")); - TestDrawResourceScreensL(); - break; - case 9: - ((CTDrawResourceStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-TestCopyScreenToBitmapWithDifferentDisplayModes-0001")); - INFO_PRINTF1(_L("CopyScreenToBitmapWithDifferentDisplayModes Test\n")); - TestCopyScreenToBitmapWithDifferentDisplayModesL(); - break; - case 10: - ((CTDrawResourceStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - ((CTDrawResourceStep*)iStep)->CloseTMSGraphicsStep(); - INFO_PRINTF1(_L("Test complete\n")); - TestComplete(); - break; - } - ((CTDrawResourceStep*)iStep)->RecordTestResultL(); - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-DRAWRESOURCE-0001 -@SYMPREQ PREQ2095 -@SYMTestPriority High -@SYMTestCaseDesc Draw RSgImage using DrawResource(const TPoint&, const RWsDrawableSource&, TGraphicsRotation) -@SYMTestActions Draw to position (0,0) with default rotation (none) - Draw to position (10,10) with 90 degrees rotation -@SYMTestExpectedResults Drawn images should match reference CFbsBitmap -*/ -void CTDrawResource::TestDrawResourcePos() - { - // Draw to TPoint(0,0) with EGraphicsRotationNone - iWindow.BeginRedraw(); - TheGc->Activate(iWindow); - TheGc->Clear(); - MWsDrawResource* dr = static_cast(TheGc->Interface(KMWsDrawResourceInterfaceUid)); - TEST(dr != NULL); - dr->DrawResource(KDestPoint, iWsDrawableSource, CWindowGc::EGraphicsRotationNone); - TheGc->Deactivate(); - iWindow.EndRedraw(); - TheClient->iWs.Finish(); - TheClient->WaitForRedrawsToFinish(); - - //Copy the screen to the copy bitmap - TheClient->iScreen->CopyScreenToBitmap(iCopyBitmap, KCopyTestRect); - - //Compare the bitmaps - INFO_PRINTF1(_L("Draw to TPoint(0,0) with EGraphicsRotationNone")); - TBool compRes = CompareBitmapsByPixel(iCopyBitmap, iRefBitmap); - TEST(compRes); - - /*** Draw to position (10,10) with 90 degrees rotation ***/ - TPoint const KDestPoint2(10,10); - iWindow.BeginRedraw(); - TheGc->Activate(iWindow); - TheGc->Clear(); - dr->DrawResource(KDestPoint2, iWsDrawableSource, KTestRotation); - TheGc->Deactivate(); - iWindow.EndRedraw(); - TheClient->iWs.Finish(); - TheClient->WaitForRedrawsToFinish(); - - //Copy the screen to the copy bitmap - TheClient->iScreen->CopyScreenToBitmap(iCopyBitmap, TRect(KDestPoint2, KSourceSize)); - - //Compare the bitmaps - INFO_PRINTF1(_L("Draw to position (10,10) with 90 degrees rotation")); - compRes = CompareBitmapsByPixel(iCopyBitmap, iRotatedRefBitmap); - TEST(compRes); - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-DRAWRESOURCE-0002 -@SYMPREQ PREQ2095 -@SYMTestPriority High -@SYMTestCaseDesc Draw RSgImage using DrawResource(const TRect& , const RWsDrawableSource&, TGraphicsRotation aRotation) -@SYMTestActions Draw to rect pos (10,10), rect size (60,60) with 90 degrees rotation -@SYMTestExpectedResults Drawn images should match the reference CFbsBitmap -*/ -void CTDrawResource::TestDrawResourceRect() - { - //Use DrawResource - iWindow.BeginRedraw(); - TheGc->Activate(iWindow); - TheGc->Clear(); - MWsDrawResource* dr = static_cast(TheGc->Interface(KMWsDrawResourceInterfaceUid)); - TEST(dr != NULL); - dr->DrawResource(KDestRect, iWsDrawableSource, KTestRotation); - TheGc->Deactivate(); - iWindow.EndRedraw(); - TheClient->iWs.Finish(); - TheClient->WaitForRedrawsToFinish(); - - //Copy the screen to the copy bitmap - TheClient->iScreen->CopyScreenToBitmap(iCopyBitmap, KCopyTestRect); - - //Compare the bitmaps - INFO_PRINTF1(_L("Draw to rect pos (10,10), rect size (60,60) with 90 degrees rotation")); - TInt compRes = CompareBitmapsByPixel(iCopyBitmap, iScaledBitmap); - TEST(compRes); - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-DRAWRESOURCE-0003 -@SYMPREQ PREQ2095 -@SYMTestPriority High -@SYMTestCaseDesc Draw RSgImage using DrawResource(const TRect& , const RWsDrawableSource&, const TRect&, TGraphicsRotation aRotation) -@SYMTestActions Draw the part of the source image (rect Pos (0,0), rect size(50,50)) - to rect pos(10,10), rect size(60,60) and and 90 degrees rotation -@SYMTestExpectedResults Drawn images should match the reference CFbsBitmap -*/ -void CTDrawResource::TestDrawResourceScale() - { - //Use DrawResource - iWindow.BeginRedraw(); - TheGc->Activate(iWindow); - TheGc->Clear(); - MWsDrawResource* dr = static_cast(TheGc->Interface(KMWsDrawResourceInterfaceUid)); - TEST(dr != NULL); - dr->DrawResource(KDestRect, iWsDrawableSource, KSourceRect, KTestRotation); - TheGc->Deactivate(); - iWindow.EndRedraw(); - TheClient->iWs.Finish(); - TheClient->WaitForRedrawsToFinish(); - - //Copy the screen to the copy bitmap - TheClient->iScreen->CopyScreenToBitmap(iCopyBitmap, KCopyTestRect); - - //Compare the bitmaps - INFO_PRINTF1(_L("Draw the part of the source image to rect pos(10,10), rect size(60,60) and and 90 degrees rotation")); - TInt compRes = CompareBitmapsByPixel(iCopyBitmap, iScaledCroppedBitmap); - TEST(compRes); - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-DRAWRESOURCE-0004 -@SYMPREQ PREQ2095 -@SYMTestPriority High -@SYMTestCaseDesc Draw RSgImage using DrawResource(const TPoint&, const RWsDrawableSource&, TGraphicsRotation) after closing the image source -@SYMTestActions Draw to position (0,0) with default rotation (none) after closing the image source -@SYMTestExpectedResults Drawn image should match reference CFbsBitmap -*/ -void CTDrawResource::TestRWsDrawableSourceReferenceCountingL() - { - // construction of image source - RSgImage sgImage; - CreateSgImageFromBitmapL(sgImage); - CleanupClosePushL(sgImage); - RWsDrawableSource drawableSource(TheClient->iWs); - CleanupClosePushL(drawableSource); - User::LeaveIfError(drawableSource.Create(sgImage, TheClient->iScreen->GetScreenNumber())); - - //Draw using DrawResource - iWindow.BeginRedraw(); - TheGc->Activate(iWindow); - TheGc->Clear(); - MWsDrawResource* dr = static_cast(TheGc->Interface(KMWsDrawResourceInterfaceUid)); - TEST(dr != NULL); - dr->DrawResource(KDestPoint, drawableSource, CWindowGc::EGraphicsRotationNone); - TheGc->Deactivate(); - iWindow.EndRedraw(); - - //Close the image source but this should not stop the source from being drawn - drawableSource.Close(); - TheClient->iWs.Finish(); - TheClient->WaitForRedrawsToFinish(); - - //Copy the screen to the copy bitmap - TheClient->iScreen->CopyScreenToBitmap(iCopyBitmap, KCopyTestRect); - - //Compare the bitmaps - INFO_PRINTF1(_L("Draw to TPoint(0,0) with EGraphicsRotationNone")); - TBool compRes = CompareBitmapsByPixel(iCopyBitmap, iRefBitmap); - TEST(compRes); - - CleanupStack::PopAndDestroy(2, &sgImage); - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-DRAWRESOURCE-0005 -@SYMPREQ PREQ2095 -@SYMTestPriority High -@SYMTestCaseDesc Draw RSgImage using RemotGc->DrawResource(const TPoint&, const RWsDrawableSource&, TGraphicsRotation) -@SYMTestActions Record the draw resource commands using CRemoteGc and play the recorded commands on a window using - Play(const TPoint&, const TRect&, RWsSession&, CWindowGc&) and then play the recorded commands using . - Play(const TPoint&, const TRect&, const MWsGraphicResolver&, MWsGraphicsContext&). -@SYMTestExpectedResults Drawn images should match reference CFbsBitmap and also values received by MWsGraphicsContext should - match what was originally sent to DrawResource. -*/ -void CTDrawResource::TestRemoteGcDrawResourcePosL() - { - const TRect KRemotGcSourceRect(0, 0, iWindow.Size().iWidth, iWindow.Size().iHeight); - const TRegionFix<1> KClippingRegion(KRemotGcSourceRect); - CWindowGc::TGraphicsRotation testRotation= CWindowGc::EGraphicsRotationNone; - - //Create remote gc - required RemoteGc testing - CRemoteGc* remoteGc = CRemoteGc::NewL(TheClient->iScreen); - CleanupStack::PushL(remoteGc); - - //Record draw messages - remoteGc->ResetCommandBuffer(); - remoteGc->BeginDraw(KRemotGcSourceRect); - MWsDrawResource* dr = static_cast(remoteGc->Interface(KMWsDrawResourceInterfaceUid)); - TEST(dr != NULL); - dr->DrawResource(KDestPoint, iWsDrawableSource, CWindowGc::EGraphicsRotationNone); - remoteGc->EndDraw(); - - RWsGraphicMsgBuf msgBuf; - CleanupClosePushL(msgBuf); - //Externalize the captured commands from remote gc in to a buffer - remoteGc->ExternalizeL(msgBuf, ETrue); - //Create command buffer - required RemoteGc testing - CCommandBuffer* cmdBuffer = CCommandBuffer::NewL(); - CleanupStack::PushL(cmdBuffer); - //Internalize the buffer with captured commands (from CRemoteGC) in to CCommandBuffer - cmdBuffer->InternalizeL(msgBuf.Pckg()); - - // Play stored commands using Play(const TPoint&, const TRect&, RWsSession&, CWindowGc&) - remoteGc->ResetCommandBuffer(); - iWindow.Invalidate(); - iWindow.BeginRedraw(); - TheGc->Activate(iWindow); - TheGc->Clear(); - cmdBuffer->Play(KPlayOffset, &KClippingRegion, KRemotGcSourceRect, TheClient->iWs, *TheGc); - TheGc->Deactivate(); - iWindow.EndRedraw(); - TheClient->iWs.Finish(); - TheClient->WaitForRedrawsToFinish(); - - //Copy the screen to the copy bitmap - TheClient->iScreen->CopyScreenToBitmap(iCopyBitmap, KCopyTestRect); - - //Compare the bitmaps - INFO_PRINTF1(_L("Using Play(const TPoint&, const TRect&, RWsSession&, CWindowGc&)")); - TBool compRes = CompareBitmapsByPixel(iCopyBitmap, iRefBitmap); - TEST(compRes); - - // Play stored commands using Play(const TPoint&, const TRect&, const MWsGraphicResolver&, MWsGraphicsContext&) - remoteGc->ResetCommandBuffer(); - iWindow.Invalidate(); - iWindow.BeginRedraw(); - TheGc->Activate(iWindow); - TheGc->Clear(); - cmdBuffer->Play(KPlayOffset,&KClippingRegion,KRemotGcSourceRect,*iWsGrapicResolver,*iGraphicsCon); - TheGc->Deactivate(); - iWindow.EndRedraw(); - TheClient->iWs.Finish(); - - //Compare the values received by CTestWsGraphicsContext and the values sent to it - INFO_PRINTF1(_L("Using Play(const TPoint&, const TRect&, const MWsGraphicResolver&, MWsGraphicsContext&)")); - TBool valuesSame = EFalse; - CFbsBitmap* bmp; - BitmapLC(bmp); - compRes = CompareBitmapsByPixel(bmp, iRefBitmap); - CleanupStack::PopAndDestroy(bmp); - - if((iGraphicsCon->iPos == KDestPoint) && (compRes) - && (reinterpret_cast(iGraphicsCon->iRotation)==reinterpret_cast(testRotation))) - valuesSame = ETrue; - TEST(valuesSame); - CleanupStack::PopAndDestroy(3, remoteGc); - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-DRAWRESOURCE-0006 -@SYMPREQ PREQ2095 -@SYMTestPriority High -@SYMTestCaseDesc Draw RSgImage using RemotGc->DrawResource(const TRect&, const RWsDrawableSource&, TGraphicsRotation) -@SYMTestActions Record the draw resource commands using CRemoteGc and play the recorded commands on a window using - Play(const TPoint&, const TRect&, RWsSession&, CWindowGc&) and then play the recorded commands using . - Play(const TPoint&, const TRect&, const MWsGraphicResolver&, MWsGraphicsContext&). -@SYMTestExpectedResults Drawn images should match reference CFbsBitmap and also values received by MWsGraphicsContext should - match what was originally sent to DrawResource. -*/ -void CTDrawResource::TestRemoteGcDrawResourceRectL() - { - const TRect KRemotGcSourceRect(0, 0, iWindow.Size().iWidth, iWindow.Size().iHeight); - const TRegionFix<1> KClippingRegion(KRemotGcSourceRect); - - //Create remote gc - required RemoteGc testing - CRemoteGc* remoteGc = CRemoteGc::NewL(TheClient->iScreen); - CleanupStack::PushL(remoteGc); - - //Record draw messages - remoteGc->BeginDraw(KRemotGcSourceRect); - MWsDrawResource* dr = static_cast(remoteGc->Interface(KMWsDrawResourceInterfaceUid)); - TEST(dr != NULL); - dr->DrawResource(KDestRect, iWsDrawableSource, KTestRotation); - remoteGc->EndDraw(); - - RWsGraphicMsgBuf msgBuf; - CleanupClosePushL(msgBuf); - //Externalize the captured commands from remote gc in to a buffer - remoteGc->ExternalizeL(msgBuf, ETrue); - - //Create command buffer - required RemoteGc testing - CCommandBuffer* cmdBuffer = CCommandBuffer::NewL(); - CleanupStack::PushL(cmdBuffer); - //Internalize the buffer with captured commands (from CRemoteGC) in to CCommandBuffer - cmdBuffer->InternalizeL(msgBuf.Pckg()); - - // Play stored commands using Play(const TRect&, const TRect&, RWsSession&, CWindowGc&) - iWindow.Invalidate(); - iWindow.BeginRedraw(); - TheGc->Activate(iWindow); - TheGc->Clear(); - cmdBuffer->Play(KPlayOffset, &KClippingRegion, KRemotGcSourceRect, TheClient->iWs, *TheGc); - TheGc->Deactivate(); - iWindow.EndRedraw(); - TheClient->iWs.Finish(); - TheClient->WaitForRedrawsToFinish(); - - //Copy the screen to the copy bitmap - TheClient->iScreen->CopyScreenToBitmap(iCopyBitmap, KCopyTestRect); - - //Compare the bitmaps - INFO_PRINTF1(_L("Using Play(const TPoint&, const TRect&, RWsSession&, CWindowGc&)")); - TBool compRes = CompareBitmapsByPixel(iCopyBitmap, iScaledBitmap); - TEST(compRes); - - // Play stored commands using Play(const TPoint&, const TRect&, const MWsGraphicResolver&, MWsGraphicsContext&) - iWindow.Invalidate(); - iWindow.BeginRedraw(); - TheGc->Activate(iWindow); - TheGc->Clear(); - iGraphicsCon->Clear(); - cmdBuffer->Play(KPlayOffset,&KClippingRegion,KRemotGcSourceRect,*iWsGrapicResolver,*iGraphicsCon); - TheGc->Deactivate(); - iWindow.EndRedraw(); - TheClient->iWs.Finish(); - TheClient->WaitForRedrawsToFinish(); - - //Compare the values received by CTestWsGraphicsContext and the values sent to it - INFO_PRINTF1(_L("Using Play(const TPoint&, const TRect&, const MWsGraphicResolver&, MWsGraphicsContext&)")); - TBool valuesSame = EFalse; - - CFbsBitmap* bmp; - BitmapLC(bmp); - compRes = CompareBitmapsByPixel(bmp, iScaledBitmap); - CleanupStack::PopAndDestroy(bmp); - - if((iGraphicsCon->iDestRect == KDestRect) && (compRes) - && (reinterpret_cast(iGraphicsCon->iRotation)==reinterpret_cast(KTestRotation))) - valuesSame = ETrue; - TEST(valuesSame); - CleanupStack::PopAndDestroy(3, remoteGc); - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-DRAWRESOURCE-0007 -@SYMPREQ PREQ2095 -@SYMTestPriority High -@SYMTestCaseDesc Draw RSgImage using RemotGc->DrawResource(const TRect&, const RWsDrawableSource&, const TRect&, TGraphicsRotation) -@SYMTestActions Record the draw resource commands using CRemoteGc and play the recorded commands on a window using - Play(const TPoint&, const TRect&, RWsSession&, CWindowGc&) and then play the recorded commands using . - Play(const TPoint&, const TRect&, const MWsGraphicResolver&, MWsGraphicsContext&). -@SYMTestExpectedResults Drawn images should match reference CFbsBitmap and also values received by MWsGraphicsContext should - match what was originally sent to DrawResource. -*/ -void CTDrawResource::TestRemoteGcDrawResourceScaleL() - { - const TRect KRemotGcSourceRect(0, 0, iWindow.Size().iWidth, iWindow.Size().iHeight); - const TRegionFix<1> KClippingRegion(KRemotGcSourceRect); - - //Create remote gc - required RemoteGc testing - CRemoteGc* remoteGc = CRemoteGc::NewL(TheClient->iScreen); - CleanupStack::PushL(remoteGc); - - //Record draw messages - remoteGc->BeginDraw(KRemotGcSourceRect); - MWsDrawResource* dr = static_cast(remoteGc->Interface(KMWsDrawResourceInterfaceUid)); - TEST(dr != NULL); - dr->DrawResource(KDestRect, iWsDrawableSource, KSourceRect, KTestRotation); - remoteGc->EndDraw(); - - RWsGraphicMsgBuf msgBuf; - CleanupClosePushL(msgBuf); - //Externalize the captured commands from remote gc in to a buffer - remoteGc->ExternalizeL(msgBuf, ETrue); - - //Create command buffer - required RemoteGc testing - CCommandBuffer* cmdBuffer = CCommandBuffer::NewL(); - CleanupStack::PushL(cmdBuffer); - //Internalize the buffer with captured commands (from CRemoteGC) in to CCommandBuffer - cmdBuffer->InternalizeL(msgBuf.Pckg()); - - // Play the stored commands using Play(const TRect&, const TRect&, RWsSession&, CWindowGc&) - remoteGc->ResetCommandBuffer(); - iWindow.Invalidate(); - iWindow.BeginRedraw(); - TheGc->Activate(iWindow); - TheGc->Clear(); - cmdBuffer->Play(KPlayOffset, &KClippingRegion, KRemotGcSourceRect, TheClient->iWs, *TheGc); - TheGc->Deactivate(); - iWindow.EndRedraw(); - TheClient->iWs.Finish(); - TheClient->WaitForRedrawsToFinish(); - //Copy the screen to the copy bitmap - TheClient->iScreen->CopyScreenToBitmap(iCopyBitmap, KCopyTestRect); - - //Compare the bitmaps - INFO_PRINTF1(_L("Using Play(const TPoint&, const TRect&, RWsSession&, CWindowGc&)")); - TBool compRes = CompareBitmapsByPixel(iCopyBitmap, iScaledCroppedBitmap); - TEST(compRes); - - // Play the stored commands using Play(const TPoint&, const TRect&, const MWsGraphicResolver&, MWsGraphicsContext&) - iWindow.Invalidate(); - iWindow.BeginRedraw(); - TheGc->Activate(iWindow); - TheGc->Clear(); - iGraphicsCon->Clear(); - cmdBuffer->Play(KPlayOffset,&KClippingRegion,KRemotGcSourceRect,*iWsGrapicResolver,*iGraphicsCon); - TheGc->Deactivate(); - iWindow.EndRedraw(); - TheClient->iWs.Finish(); - TheClient->WaitForRedrawsToFinish(); - - //Compare the values received by CTestWsGraphicsContext and the values sent to it - INFO_PRINTF1(_L("Using Play(const TPoint&, const TRect&, const MWsGraphicResolver&, MWsGraphicsContext&)")); - TBool valuesSame = EFalse; - - CFbsBitmap* bmp; - BitmapLC(bmp); - compRes = CompareBitmapsByPixel(bmp, iScaledCroppedBitmap); - CleanupStack::PopAndDestroy(bmp); - - if((iGraphicsCon->iDestRect == KDestRect) && (compRes) && (iGraphicsCon->iSrcRect == KSourceRect) - && (reinterpret_cast(iGraphicsCon->iRotation)==reinterpret_cast(KTestRotation))) - valuesSame = ETrue; - TEST(valuesSame); - CleanupStack::PopAndDestroy(3, remoteGc); - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-DRAWRESOURCE-0008 -@SYMPREQ PREQ2095 -@SYMTestPriority High -@SYMTestCaseDesc Negative testing. Draw graphics recourses which associated with different screens. -@SYMTestActions Open RWsDrawableSource associated with the screen which doesn’ exist. - Open RWsDrawableSource associated with the screen which exists but differes from drawing target. - Draw Rectangle and Resource to the screen via CWindowGc - Draw Rectangle and Resource to the screen via CRemoteGc -@SYMTestExpectedResults Opening drawable resource on the screen which doesn’t exist must fail with error code KErrArgument - Drawing primitives will result only rectangles be drawn as drawable recourses get associated with different screen -*/ -void CTDrawResource::TestDrawResourceScreensL() - { - TInt numOfScreens = TheClient->iWs.NumberOfScreens(); - if(numOfScreens < 2) - { - INFO_PRINTF2(_L("This test case will be running if the number of available screens more than 1, current number is %d"), numOfScreens); - return; - } - TInt screenNumber = TheClient->iScreen->GetScreenNumber(); - TInt differentScreen = (screenNumber == 0) ? 1 : 0; - - RSgImage sgImage; - CreateSgImageFromBitmapL(sgImage); - CleanupClosePushL(sgImage); - - RWsDrawableSource drawableSource(TheClient->iWs); - TInt res = drawableSource.Create(sgImage, differentScreen + 200); //wrong screen number - TEST(res == KErrArgument); - - res = drawableSource.Create(iImage, differentScreen); - TEST(res == KErrNotSupported); //in order to succeed the image must be created with flag usage ESgUsageWindowGcSource - - TSgImageInfo info; - User::LeaveIfError(sgImage.GetInfo(info)); - - res = drawableSource.Create(sgImage, differentScreen); - if(res == KErrNotSupported) - { - INFO_PRINTF1(_L("The second screen is not supports drawable source. This test case terminates now.")); - CleanupStack::PopAndDestroy(&sgImage); - return; - } - TEST(res == KErrNone); - User::LeaveIfError(res); - CleanupClosePushL(drawableSource); - - iWindow.BeginRedraw(); - TheGc->Activate(iWindow); - TheGc->Clear(); - TheGc->SetBrushStyle(CFbsBitGc::ESolidBrush); - TheGc->SetPenStyle(CFbsBitGc::ENullPen); - TheGc->SetBrushColor(KRgbGreen); - TheGc->DrawRect(TRect(KDestPoint, info.iSizeInPixels)); - // Draw to TPoint(0,0) with EGraphicsRotationNone but to the different screen - MWsDrawResource* winDr = static_cast(TheGc->Interface(KMWsDrawResourceInterfaceUid)); - TEST(winDr != NULL); - winDr->DrawResource(KDestPoint, drawableSource, CWindowGc::EGraphicsRotationNone); - TheGc->Deactivate(); - iWindow.EndRedraw(); - TheClient->iWs.Finish(); - TheClient->WaitForRedrawsToFinish(); - - //Copy the screen to the copy bitmap - TheClient->iScreen->CopyScreenToBitmap(iCopyBitmap, KCopyTestRect); - - //Compare the bitmaps - INFO_PRINTF1(_L("Draw to TPoint(0,0) with EGraphicsRotationNone but to different screen")); - TBool compRes = CompareBitmapsByPixel(iCopyBitmap, iBitmapWrongScreenNumber); - TEST(compRes); - - //--------------------------- remoteGc - const TRect KRemotGcSourceRect(0, 0, iWindow.Size().iWidth, iWindow.Size().iHeight); - const TRegionFix<1> KClippingRegion(KRemotGcSourceRect); - - //Create remote gc - required RemoteGc testing - CRemoteGc* remoteGc = CRemoteGc::NewL(TheClient->iScreen); - CleanupStack::PushL(remoteGc); - - //Record draw messages - remoteGc->BeginDraw(KRemotGcSourceRect); - remoteGc->SetBrushStyle(CFbsBitGc::ESolidBrush); - remoteGc->SetPenStyle(CFbsBitGc::ENullPen); - remoteGc->SetBrushColor(KRgbGreen); - remoteGc->DrawRect(TRect(KDestPoint, info.iSizeInPixels)); - MWsDrawResource* remDr = static_cast(remoteGc->Interface(KMWsDrawResourceInterfaceUid)); - TEST(remDr != NULL); - remDr->DrawResource(KDestRect, drawableSource, CWindowGc::EGraphicsRotationNone); - remoteGc->EndDraw(); - - RWsGraphicMsgBuf msgBuf; - CleanupClosePushL(msgBuf); - //Externalize the captured commands from remote gc in to a buffer - remoteGc->ExternalizeL(msgBuf, ETrue); - - //Create command buffer - required RemoteGc testing - CCommandBuffer* cmdBuffer = CCommandBuffer::NewL(); - CleanupStack::PushL(cmdBuffer); - //Internalize the buffer with captured commands (from CRemoteGC) in to CCommandBuffer - cmdBuffer->InternalizeL(msgBuf.Pckg()); - - // Play stored commands using Play(const TRect&, const TRect&, RWsSession&, CWindowGc&) - iWindow.Invalidate(); - iWindow.BeginRedraw(); - TheGc->Activate(iWindow); - TheGc->Clear(); - cmdBuffer->Play(KPlayOffset, &KClippingRegion, KRemotGcSourceRect, TheClient->iWs, *TheGc); - TheGc->Deactivate(); - iWindow.EndRedraw(); - TheClient->iWs.Finish(); - TheClient->WaitForRedrawsToFinish(); - - //Copy the screen to the copy bitmap - TheClient->iScreen->CopyScreenToBitmap(iCopyBitmap, KCopyTestRect); - - INFO_PRINTF1(_L("Draw to TPoint(0,0) with EGraphicsRotationNone but to different screen")); - TBool compRes1 = CompareBitmapsByPixel(iCopyBitmap, iBitmapWrongScreenNumber); - TEST(compRes1); - - CleanupStack::PopAndDestroy(5, &sgImage); - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-TestCopyScreenToBitmapWithDifferentDisplayModes-0001 -@SYMPREQ PREQ2095 -@SYMTestPriority High -@SYMTestCaseDesc Get bitmap and scanline from the screen. -@SYMTestActions Draw bitmap in various display modes to the screen. - Retrieve scan line and bitmap from the screen using standard WSERV API. - -@SYMTestExpectedResults Checks that obtained bitmap matches with the reference bitmap. -*/ -void CTDrawResource::TestCopyScreenToBitmapWithDifferentDisplayModesL() - { - TDisplayMode mode = TheClient->iScreen->DisplayMode(); - INFO_PRINTF2(_L("Screen display mode %d"), mode); - CFbsBitmap* bitmap = NULL; - - TSize bitmapSize(163, 120); - CreateBitmapLC(bitmap, bitmapSize, mode); - - iWindow.BeginRedraw(); - TheGc->Activate(iWindow); - TheGc->SetBrushStyle(CWindowGc::ESolidBrush); - TheGc->SetBrushColor(KRgbYellow); - TheGc->Clear(); - const TPoint ptOffset(10, 15); - TheGc->BitBlt(KDestPoint + ptOffset, bitmap); - - TheGc->Deactivate(); - iWindow.EndRedraw(); - TheClient->iWs.Finish(); - TheClient->WaitForRedrawsToFinish(); - - const TInt length = bitmapSize.iWidth; - const TInt height = bitmapSize.iHeight; - const TInt buffersSize = length * 4; - TUint8 *screenData = (TUint8*) User::AllocL(buffersSize); - CleanupStack::PushL(screenData); - TUint8 *bitmapData = (TUint8*) User::AllocL(buffersSize); - CleanupStack::PushL(bitmapData); - TPtr8 ptrScreen (screenData, buffersSize, buffersSize); - TPtr8 ptrBitmap (bitmapData, buffersSize, buffersSize); - - //EGray mode uses dithering in BitGdi, wserv doesnt support this, thus skipping the first mode - for(TInt ii =2; ; ii++) - { - TDisplayMode dispMode = (TDisplayMode)ii; - if(dispMode >= EColorLast) - break; - if(dispMode == ERgb) - continue; - - INFO_PRINTF2(_L("Copy Screen to bitmap, destination mode %d"), dispMode); - - CFbsBitmap *bmp = new (ELeave) CFbsBitmap; - CleanupStack::PushL(bmp); - User::LeaveIfError(bmp->Create(bitmapSize, dispMode)); - TUidPixelFormat pixelFormat = SgUtils::DisplayModeToPixelFormat(dispMode); - const TInt minStride = SgUtils::MinDataStride(length, pixelFormat); - const TInt bitmapStride = bmp->DataStride(); - TEST(minStride <= bitmapStride); - - //Copy the screen to the copy bitmap - TRect rc = bitmapSize; - rc.Move(ptOffset); - TheClient->iScreen->CopyScreenToBitmap(bmp, rc); - CFbsBitmap *bmpRef = NULL; - CreateReferenceBitmapLC(bmpRef, bitmap, dispMode); - TEST(bmpRef->DisplayMode() == dispMode); - - //Compare the bitmaps - TBool compRes = CompareBitmapsByPixel(bmp, bmpRef); - TEST(compRes); - - for(TInt jj = 0; jj < height; jj++) - { - TPoint pt(0, jj); - TPoint ptScreen = pt + ptOffset; - - Mem::Fill(screenData, bitmapStride, 0xff); - Mem::Fill(bitmapData, bitmapStride, 0xff); - - TheClient->iScreen->GetScanLine(ptrScreen, ptScreen, length, dispMode); - bitmap->GetScanLine(ptrBitmap, pt, length, dispMode); - TInt length1 = ptrScreen.Length(); - - TInt res = Mem::Compare(screenData, length1, bitmapData, length1); - TEST(res == 0); - } - CleanupStack::PopAndDestroy(2, bmp); - }//screen modes; - - CleanupStack::PopAndDestroy(3, bitmap); - } - -//Helper function: Creates reference bitmap with specified display mode -void CTDrawResource::CreateReferenceBitmapLC(CFbsBitmap*& aBmpTarget, CFbsBitmap* aBmpSrc, TDisplayMode aDestMode) - { - TSize size = aBmpSrc->SizeInPixels(); - aBmpTarget = new (ELeave) CFbsBitmap; - CleanupStack::PushL(aBmpTarget); - User::LeaveIfError(aBmpTarget->Create(size, aDestMode)); - CFbsBitmapDevice *refBitmapDev = CFbsBitmapDevice::NewL(aBmpTarget); - CleanupStack::PushL(refBitmapDev); - CFbsBitGc *originalBitGc; - User::LeaveIfError(refBitmapDev->CreateContext(originalBitGc)); - CleanupStack::PushL(originalBitGc); - originalBitGc->BitBlt(TPoint(0,0), aBmpSrc); - CleanupStack::PopAndDestroy(2, refBitmapDev); - } - -//Helper function: Creates reference bitmap with specified display mode -void CTDrawResource::CreateBitmapLC(CFbsBitmap*& aBmpTarget, const TSize& aSize, TDisplayMode aDispMode) const - { - aBmpTarget = new (ELeave) CFbsBitmap; - CleanupStack::PushL(aBmpTarget); - User::LeaveIfError(aBmpTarget->Create(aSize, aDispMode)); - CFbsBitmapDevice *refBitmapDev = CFbsBitmapDevice::NewL(aBmpTarget); - CleanupStack::PushL(refBitmapDev); - CFbsBitGc *originalBitGc; - User::LeaveIfError(refBitmapDev->CreateContext(originalBitGc)); - CleanupStack::PushL(originalBitGc); - - TRect rect = TRect(aSize); - rect.Shrink(21, 15); - - originalBitGc->SetBrushStyle(CFbsBitGc::ESolidBrush); - originalBitGc->SetBrushColor(TRgb(0,150,150)); - originalBitGc->DrawRect(TRect(TPoint(0,0), TSize(aSize.iWidth, aSize.iHeight / 2))); - originalBitGc->SetBrushColor(TRgb(150,100,150)); - originalBitGc->DrawRect(TRect(TPoint(0,aSize.iHeight / 2), TSize(aSize.iWidth, aSize.iHeight))); - - originalBitGc->SetBrushColor(TRgb(0,0,128)); - originalBitGc->DrawRect(rect); - - - CleanupStack::PopAndDestroy(2, refBitmapDev); - } - -//Helper function: Creates a RSgImage from a bitmap -void CTDrawResource::CreateSgImageFromBitmapL(RSgImage& aSgImage) - { - TUint32* data = iRefBitmap->DataAddress(); - TInt stride = iRefBitmap->DataStride(); - TSize size = iRefBitmap->SizeInPixels(); - - TSgImageInfo info; - info.iSizeInPixels = size; - info.iScreenId = TheClient->iScreen->CurrentScreenMode(); - info.iShareable = ETrue; //must be shareable since wserv is in other process - info.iUsage = ESgUsageWindowGcSource; - info.iPixelFormat = SgUtils::DisplayModeToPixelFormat(iRefBitmap->DisplayMode()); - - User::LeaveIfError(aSgImage.Create(info, data, stride)); - } - -//Helper function: Creates all reference bitmaps required for all tests -void CTDrawResource::CreateReferenceAndCopyBitmapsL() - { - //Create reference bitmap - iRefBitmap = new (ELeave) CFbsBitmap(); - User::LeaveIfError(iRefBitmap->Create(TSize(160,120),EColor64K)); - - //Setup to draw to original reference bitmap - CFbsBitmapDevice *refBitmapDev = CFbsBitmapDevice::NewL(iRefBitmap); - CleanupStack::PushL(refBitmapDev); - CFbsBitGc *originalBitGc; - User::LeaveIfError(refBitmapDev->CreateContext(originalBitGc)); - CleanupStack::PushL(originalBitGc); - - //Draw to reference bitmap - originalBitGc->SetBrushStyle(CFbsBitGc::ESolidBrush); - originalBitGc->SetBrushColor(TRgb(0,150,150)); - originalBitGc->DrawRect(TRect(TPoint(0,0), TSize(160,60))); - originalBitGc->SetBrushColor(TRgb(150,100,150)); - originalBitGc->DrawRect(TRect(TPoint(0,60), TSize(160,60))); - - //create a rotated version of the reference bitmap - iRotatedRefBitmap = new (ELeave) CFbsBitmap(); - User::LeaveIfError(iRotatedRefBitmap->Create(TSize(120,160),EColor64K)); - - //Setup to draw to rotated reference bitmap - CFbsBitmapDevice *rotRefBitmapDev = CFbsBitmapDevice::NewL(iRotatedRefBitmap); - CleanupStack::PushL(rotRefBitmapDev); - CFbsBitGc *rotatedBitGc; - User::LeaveIfError(rotRefBitmapDev->CreateContext(rotatedBitGc)); - CleanupStack::PushL(rotatedBitGc); - - //Draw to rotated reference bitmap - rotatedBitGc->SetBrushStyle(CFbsBitGc::ESolidBrush); - rotatedBitGc->SetBrushColor(TRgb(0,150,150)); - rotatedBitGc->DrawRect(TRect(TPoint(60,0), TSize(60,160))); - rotatedBitGc->SetBrushColor(TRgb(150,100,150)); - rotatedBitGc->DrawRect(TRect(TPoint(0,0), TSize(60,160))); - - //Prepare a scaled version of the rotated reference bitmap to later compare against - iScaledBitmap = new (ELeave) CFbsBitmap(); - User::LeaveIfError(iScaledBitmap->Create(TSize(160,120),EColor64K)); - //Setup to draw to bitmap - CFbsBitmapDevice *scaledBitDev = CFbsBitmapDevice::NewL(iScaledBitmap); - CleanupStack::PushL(scaledBitDev); - CFbsBitGc *scaledBitGc; - User::LeaveIfError(scaledBitDev->CreateContext(scaledBitGc)); - CleanupStack::PushL(scaledBitGc); - //Draw the rotated reference bitmap scaled - scaledBitGc->DrawBitmap(KDestRect, iRotatedRefBitmap); - - //Prepare a scaled version of the rotated reference bitmap to later compare against - iScaledCroppedBitmap = new (ELeave) CFbsBitmap(); - User::LeaveIfError(iScaledCroppedBitmap->Create(TSize(160,120),EColor64K)); - - //Setup to draw to bitmap - CFbsBitmapDevice *scaledCroppedBitDev = CFbsBitmapDevice::NewL(iScaledCroppedBitmap); - CleanupStack::PushL(scaledCroppedBitDev); - CFbsBitGc *scaledCroppedBitGc; - User::LeaveIfError(scaledCroppedBitDev->CreateContext(scaledCroppedBitGc)); - CleanupStack::PushL(scaledCroppedBitGc); - - //Draw the rotated reference bitmap scaled - TInt width = iRotatedRefBitmap->SizeInPixels().iWidth; - TInt height = iRotatedRefBitmap->SizeInPixels().iHeight; - - TRect rectSrc; - rectSrc.iTl.iX= width - KSourceRect.Height(); - rectSrc.iTl.iY= 0; - rectSrc.iBr.iX= width; - rectSrc.iBr.iY= KSourceRect.Width(); - - scaledCroppedBitGc->DrawBitmap(KDestRect, iRotatedRefBitmap, rectSrc); - - //Prepare bitmap for testing drawable which opened with different screen number - iBitmapWrongScreenNumber = new (ELeave) CFbsBitmap(); - User::LeaveIfError(iBitmapWrongScreenNumber->Create(TSize(160,120),EColor64K)); - //Setup to draw to bitmap - CFbsBitmapDevice *wrongScreenNumberBitDev = CFbsBitmapDevice::NewL(iBitmapWrongScreenNumber); - CleanupStack::PushL(wrongScreenNumberBitDev); - CFbsBitGc *wrongScreenNumberBitGc; - User::LeaveIfError(wrongScreenNumberBitDev->CreateContext(wrongScreenNumberBitGc)); - CleanupStack::PushL(wrongScreenNumberBitGc); - //Draw the rotated reference bitmap scaled - wrongScreenNumberBitGc->SetBrushColor(KRgbGreen); - wrongScreenNumberBitGc->SetBrushStyle(CFbsBitGc::ESolidBrush); - wrongScreenNumberBitGc->SetPenStyle(CFbsBitGc::ENullPen); - wrongScreenNumberBitGc->DrawRect(TRect(0, 0, 160, 120)); // - - //Create a bitmap to copy to with the same display mode as the reference bitmap - iCopyBitmap = new (ELeave) CFbsBitmap(); - User::LeaveIfError(iCopyBitmap->Create(TSize(640,240),EColor64K)); - - CleanupStack::PopAndDestroy(10, refBitmapDev); - } - -//Helper function: This function compares two bitmaps on a pixel by pixel basis */ -TBool CTDrawResource::CompareBitmapsByPixel(CFbsBitmap* aCandidateBitmap, CFbsBitmap* aReferenceBitmap) - { - TBool result = ETrue; - - TSize candidateSize = aCandidateBitmap->SizeInPixels(); - TSize referenceSize = aReferenceBitmap->SizeInPixels(); - - TInt mismatchedPixels = 0; - - TRgb nativePixel; - TRgb referencePixel; - for (TInt x = 0; x < referenceSize.iWidth; x++) - { - for (TInt y = 0; y < referenceSize.iHeight; y++) - { - TPoint point(x,y); - nativePixel = TRgb(0,0,0,0); - referencePixel = TRgb(0,0,0,0); - aCandidateBitmap->GetPixel(nativePixel, point); - aReferenceBitmap->GetPixel(referencePixel, point); - - if (nativePixel != referencePixel) - { - mismatchedPixels++; - result = EFalse; - } - } - } - - INFO_PRINTF2(_L("Number of different pixels: %i"), mismatchedPixels); - return result; - } -//Helper function: This function extracts content of the image associated with the image target and copies it into bitmap -void CTDrawResource::BitmapLC(CFbsBitmap*& aBmp) - { - aBmp = new(ELeave) CFbsBitmap; - CleanupStack::PushL(aBmp); - - TSgImageInfo info; - TInt res = iImage.GetInfo(info); - User::LeaveIfError(res); - - res = aBmp ->Create(info.iSizeInPixels, SgUtils::PixelFormatToDisplayMode(info.iPixelFormat)); - User::LeaveIfError(res); - TUint32* dataAddressDest = aBmp->DataAddress(); - - RSgImage image; - info.iUsage = ESgUsageNone; - info.iCpuAccess = ESgCpuAccessReadOnly; - res = image.Create(info, iImage); - User::LeaveIfError(res); - CleanupClosePushL(image); - const TAny* dataAddress = NULL; - TInt dataStride; - res = image.MapReadOnly(dataAddress, dataStride); - User::LeaveIfError(res); - Mem::Copy(dataAddressDest, dataAddress, dataStride * info.iSizeInPixels.iHeight); - image.Unmap(); - CleanupStack::PopAndDestroy(&image); - } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/tdrawresource.h --- a/windowing/windowserver/tauto/tdrawresource.h Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,221 +0,0 @@ -// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef TDRAWRESOURCE_H_ -#define TDRAWRESOURCE_H_ - -#include "AUTO.H" -#include -#include -#include -#include -#include -#include -#include -#include "RemoteGc.h" -#include "CommandBuffer.h" - -class TSgImageInfo; - -_LIT(KTDrawResourceStep, "TDrawResource"); - -const TSize KSourceSize(200,200); //The size of the rect to copy from the screen -const TPoint KDestPoint(0,0); -const TRect KCopyTestRect(TPoint(0,0), TSize(200,200)); //The test rect to copy from the screen -const TRect KSourceRect(TPoint(0,0), TSize(50,50));//Rect of the source image to be drawn -const TRect KDestRect(TPoint(10,10), TSize(60,60));//Rect of the destination to draw to -const CWindowGc::TGraphicsRotation KTestRotation= CWindowGc::EGraphicsRotation90; -const TPoint KPlayOffset(0,0); - - -/** - * Dummy class used to check the values received by MWsGraphicsContext. - * The only funtions overridden with some functionality are the DrawResource functions. - * These simply receive the values and then store them in public member variables. - */ -class CTestWsGraphicsContext : public CBase, public MWsGraphicsContext, public MWsDrawableSourceProvider - { -public: - static CTestWsGraphicsContext* NewL(RDirectGdiImageTarget& aTarget); - ~CTestWsGraphicsContext(); - -public: //from MWsGraphicsContext - void BitBlt(const TPoint&, const CFbsBitmap&){} - void BitBlt(const TPoint&, const CFbsBitmap&, const TRect&){} - void BitBltMasked(const TPoint&, const CFbsBitmap&, const TRect&, const CFbsBitmap&, TBool){} - void BitBltMasked(const TPoint&, const CFbsBitmap&, const TRect&, const CFbsBitmap&, const TPoint&){} - void ResetClippingRegion(){} - void Clear(); - void Clear(const TRect&){} - void ResetBrushPattern(){} - void ResetFont(){} - void DrawArc(const TRect&, const TPoint&, const TPoint&){} - void DrawPie(const TRect&, const TPoint&, const TPoint&){} - void DrawBitmap(const TRect&, const CFbsBitmap&){} - void DrawBitmap(const TRect&, const CFbsBitmap&, const TRect&){} - void DrawBitmapMasked(const TRect&, const CFbsBitmap&,const TRect&, const CFbsBitmap&, TBool){} - void DrawRoundRect(const TRect&, const TSize&){} - void DrawPolyLine(const TArray&){} - void DrawPolyLineNoEndPoint(const TArray&){} - void DrawPolygon(const TArray& , TFillRule ){} - void DrawEllipse(const TRect&){} - void DrawLine(const TPoint&, const TPoint&){} - void DrawLineTo(const TPoint&){} - void DrawLineBy(const TPoint&){} - void DrawRect(const TRect&){} - void DrawText(const TDesC& ,const TTextParameters* ){} - void DrawText(const TDesC& ,const TTextParameters* ,const TPoint& ){} - void DrawText(const TDesC& ,const TTextParameters* ,const TRect& ){} - void DrawText(const TDesC& ,const TTextParameters* ,const TRect& ,TInt ,TTextAlign ,TInt ){} - void DrawTextVertical(const TDesC& ,const TTextParameters* ,TBool ) {} - void DrawTextVertical(const TDesC& ,const TTextParameters* ,const TPoint& ,TBool ){} - void DrawTextVertical(const TDesC& ,const TTextParameters* ,const TRect& ,TBool ){} - void DrawTextVertical(const TDesC& ,const TTextParameters* ,const TRect& ,TInt ,TBool ,TTextAlign ,TInt ){} - void DrawTextVertical(const TDesC& ,const TTextParameters* ,const TRect& ,TInt ,TInt ,TBool ,TTextAlign ,TInt ){} - void MoveTo(const TPoint&){} - void MoveBy(const TPoint&){} - TPoint Origin() const {return TPoint(0,0);} - void Plot(const TPoint&){} - void Reset(){} - void SetBrushColor(const TRgb&){} - void SetBrushOrigin(const TPoint&){} - void SetBrushStyle(TBrushStyle ){} - void SetClippingRegion(const TRegion&){} - void SetDrawMode(TDrawMode){} - void SetOrigin(const TPoint&){} - void SetPenColor(const TRgb&){} - void SetPenStyle(TPenStyle){} - void SetPenSize(const TSize& ){} - void SetTextShadowColor(const TRgb&){} - void SetCharJustification(TInt, TInt){} - void SetWordJustification(TInt, TInt){} - void SetUnderlineStyle(TFontUnderline){} - void SetStrikethroughStyle(TFontStrikethrough){} - void SetBrushPattern(const CFbsBitmap&){} - void SetBrushPattern(TInt){} - void SetFont(const CFont*){} - void CopyRect(const TPoint&, const TRect&){} - void RectDrawnTo(TRect&){} - void UpdateJustification(const TDesC& ,const TTextParameters* ){} - void UpdateJustificationVertical(const TDesC& ,const TTextParameters* ,TBool ){} - void SetFontNoDuplicate(const CFont* ){} - TBool HasBrushPattern() const{return EFalse;} - TBool HasFont() const{return EFalse;} - void InternalizeL(RReadStream&){} - void ExternalizeL(RWriteStream&){} - TRgb BrushColor() const {return iContext->BrushColor();} - TRgb PenColor() const {return iContext->PenColor();} - TRgb TextShadowColor() const {return iContext->TextShadowColor ();} - - const TRegion& ClippingRegion(){return iRegion;} - TInt GetError(){return KErrNone;} - TInt Push(){return KErrNone;} - void Pop(){} - //from MWsObjectProvider - TAny* ResolveObjectInterface(TUint aTypeId); - - //from MWsDrawableSourceProvider - TInt CreateDrawableSource(const TSgDrawableId& aDrawableId, TAny*& aSource); - void CloseDrawableSource(TAny* aSource); - void DrawResource(const TAny* aSource, const TPoint& aPos, CWindowGc::TGraphicsRotation aRotation = CWindowGc::EGraphicsRotationNone); - void DrawResource(const TAny* aSource, const TRect& aRect, CWindowGc::TGraphicsRotation aRotation = CWindowGc::EGraphicsRotationNone); - void DrawResource(const TAny* aSource, const TRect& aRectDest, const TRect& aRectSrc, CWindowGc::TGraphicsRotation aRotation = CWindowGc::EGraphicsRotationNone); - void DrawResource(const TAny* aSource, const TRect& aRect, const TDesC8& aParam); - -private: - void ConstructL(RDirectGdiImageTarget& aTarget); - void DoCreateDrawableSourceL(const TSgDrawableId& aDrawableId, TAny*& aSource); -public: - TPoint iPos; - TRect iDestRect; - TRect iSrcRect; - DirectGdi::TGraphicsRotation iRotation; - RRegion iRegion; -private: - CDirectGdiContext* iContext; - }; - -/** - * Class derived from MWsGraphicResolver. This a dummy implmentation which has no functionality. - * An instance of it is passed to CCommandBuffer::Play to make it a valid call. - */ -class CWSGraphicsRes: public CBase, public MWsGraphicResolver - { -public: - void DrawWsGraphic(TInt, TBool, const TRect&, const TDesC8&) const{} - }; - -class CTDrawResource : public CTWsGraphicsBase - { -public: - CTDrawResource(CTestStep* aStep); - ~CTDrawResource(); - void ConstructL(); -protected: - //from CTGraphicsStep - void RunTestCaseL(TInt aCurTestCase); -private: - void TestDrawResourcePos(); - void TestDrawResourceRect(); - void TestDrawResourceScale(); - void TestRWsDrawableSourceReferenceCountingL(); - void TestRemoteGcDrawResourcePosL(); - void TestRemoteGcDrawResourceRectL(); - void TestRemoteGcDrawResourceScaleL(); - void TestDrawResourceScreensL(); - void TestCopyScreenToBitmapWithDifferentDisplayModesL(); - //Helper functions - TBool CompareBitmapsByPixel(CFbsBitmap* aCandidateBitmap, CFbsBitmap* aReferenceBitmap); - void CreateReferenceAndCopyBitmapsL(); - void CreateSgImageFromBitmapL(RSgImage& aImage); - void BitmapLC(CFbsBitmap*& aBmp); //helper function to extract bitmap from the image - void CreateReferenceBitmapLC(CFbsBitmap*& aBmpTarget, CFbsBitmap* aBmpSrc, TDisplayMode aDestMode); - void CreateBitmapLC(CFbsBitmap*& aBmpTarget, const TSize& aSize, TDisplayMode aDispMode) const; -private: - RWindow iWindow; - CFbsBitmap* iRefBitmap; - CFbsBitmap* iRotatedRefBitmap; - CFbsBitmap* iScaledBitmap; - CFbsBitmap *iScaledCroppedBitmap; - CFbsBitmap* iCopyBitmap; - CFbsBitmap* iBitmapWrongScreenNumber; - CDirectGdiDriver* iDGdiDriver; - - //Required for RemoteGc testing - RSgImageCollection iImageCollection; - RSgImage iImage; - RDirectGdiImageTarget iImageTarget; - RWsDrawableSource iWsDrawableSource; - CTestWsGraphicsContext* iGraphicsCon; - CWSGraphicsRes* iWsGrapicResolver; - }; - -class CTDrawResourceStep : public CTGraphicsStep - { -public: - CTDrawResourceStep(); -protected: - //from CTGraphicsStep - CTGraphicsBase* CreateTestL(); - }; - - -#endif /*TDRAWRESOURCE_H_*/ diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/tgc.cpp --- a/windowing/windowserver/tauto/tgc.cpp Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1864 +0,0 @@ -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ -#include "tgc.h" -#include "RemoteGc.h" -#include "CommandBuffer.h" -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA -#include "directgdigcwrapper.h" -#include -#include -#include -#endif - -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA -GLDEF_C void CopyImageToBitmapL(CFbsBitmap* aBitmap, const RSgImage& aImage, const TRect& aRect); -GLDEF_C void CopyImageToDestination(TAny* aDataAddressDest, TInt aDataStrideDest, TDisplayMode aDisplayModeDest, - TAny* aDataAddressSrc, TInt aDataStrideSrc, TDisplayMode aDisplayModeSrc, const TRect& aRect); -GLDEF_C void CopyImageToDestination64K(TAny* aDataAddressDest, TInt aDataStrideDest, TDisplayMode aDisplayModeDest, - TUint16* aDataAddressSrc, TInt aDataStrideSrc, const TRect& aRect); - -GLDEF_C void CopyImageToBitmapL(CFbsBitmap* aBitmap, const RSgImage& aImage, const TRect& aRect) - { - TSgImageInfo info; - TInt res = aImage.GetInfo(info); - if(res == KErrNone) - { - info.iUsage = ESgUsageNone; - info.iCpuAccess = ESgCpuAccessReadOnly; - RSgImage image; - res = image.Create(info, aImage); - if(res == KErrNone) - { - const TAny* dataAddressSrc = NULL; - TInt dataStrideSrc = 0; - res = image.MapReadOnly(dataAddressSrc, dataStrideSrc); - if(res == KErrNone) - { - const TDisplayMode displayModeDest = aBitmap->DisplayMode(); - const TDisplayMode displayModeSrc = SgUtils::PixelFormatToDisplayMode(info.iPixelFormat); - TUint32* dataAddressDest = aBitmap->DataAddress(); - const TInt dataStrideDest = aBitmap -> DataStride(); - TSize bitmapSize = aBitmap->SizeInPixels(); - TRect rect = aRect; - TRect rectDest = info.iSizeInPixels; - rect.Intersection(rectDest); - if(rect.Height() > bitmapSize.iHeight) - { - rect.SetHeight(bitmapSize.iHeight); - } - if(rect.Width() > bitmapSize.iWidth) - { - rect.SetWidth(bitmapSize.iWidth); - } - CopyImageToDestination((TAny*)dataAddressDest, dataStrideDest, displayModeDest, (TAny*)dataAddressSrc, - dataStrideSrc, displayModeSrc, rect); - - image.Unmap(); - } - image.Close(); - } - } - } - -GLDEF_C void CopyImageToDestination(TAny* aDataAddressDest, TInt aDataStrideDest, TDisplayMode aDisplayModeDest, - TAny* aDataAddressSrc, TInt aDataStrideSrc, TDisplayMode aDisplayModeSrc, const TRect& aRect) - { - if(aRect.IsEmpty()) - return; - - if((aDisplayModeDest == aDisplayModeSrc) && (aDataStrideSrc == aDataStrideDest)) - { - Mem::Copy(aDataAddressDest, aDataAddressSrc, aDataStrideDest * aRect.Height()); - return; - } - - switch(aDisplayModeSrc) - { - case EColor64K: - { - CopyImageToDestination64K(aDataAddressDest, aDataStrideDest, aDisplayModeDest, - (TUint16*)aDataAddressSrc, aDataStrideSrc, aRect); - break; - } - default: - break; - } - } - -GLDEF_C void CopyImageToDestination64K(TAny* aDataAddressDest, TInt aDataStrideDest, TDisplayMode aDisplayModeDest, - TUint16* aDataAddressSrc, TInt aDataStrideSrc, const TRect& aRect) - { - const TInt bppSrc = 2; - const TInt width = aRect.Width(); - const TInt height = aRect.Height(); - const TInt dataStrideLengthSrc = aDataStrideSrc / bppSrc; - TUint16* dataAddressSrc = aDataAddressSrc + aRect.iTl.iY * dataStrideLengthSrc + aRect.iTl.iX; - const TUint16* dataAddressSrcEnd = dataAddressSrc + dataStrideLengthSrc * height; - - switch(aDisplayModeDest) - { - case EColor64K: - { - TUint16* dataAddressDest = static_cast (aDataAddressDest); - const TInt dataStrideLengthDest = aDataStrideDest / bppSrc; - while(dataAddressSrcEnd > dataAddressSrc) - { - Mem::Copy(dataAddressDest, dataAddressSrc, width * bppSrc); - dataAddressSrc += dataStrideLengthSrc; - dataAddressDest += dataStrideLengthDest; - } - break; - } - case EColor16MU: - { - const TInt bppDest = 4; - TUint32* dataAddressDest = static_cast (aDataAddressDest); - const TInt dataStrideLengthDest = aDataStrideDest / bppDest; - - while(dataAddressSrcEnd > dataAddressSrc) - { - const TUint16* dataAddressSrcLineEnd = dataAddressSrc + width; - TUint32* dataAddressDestCur = dataAddressDest; - TUint16* dataAddressSrcCur = dataAddressSrc; - - while(dataAddressSrcLineEnd > dataAddressSrcCur) - { - *dataAddressDestCur = TRgb::Color64K(*dataAddressSrcCur).Color16MU(); - dataAddressDestCur++; - dataAddressSrcCur++; - } - dataAddressSrc += dataStrideLengthSrc; - dataAddressDest += dataStrideLengthDest; - } - break; - } - case EGray4: - { - TUint8* dataAddressDest = static_cast (aDataAddressDest); - const TInt dataStrideLengthDest = aDataStrideDest; - - while(dataAddressSrcEnd > dataAddressSrc) - { - const TUint8* dataAddressDstLineEnd = dataAddressDest + aDataStrideDest; - TUint8* dataAddressDestCur = dataAddressDest; - TUint16* dataAddressSrcCur = dataAddressSrc; - - while(dataAddressDstLineEnd > dataAddressDestCur) - { - *dataAddressDestCur = 0; - for(TInt index = 0; index < 8; index +=2) - { - TInt col = TRgb::Color64K(*dataAddressSrcCur).Gray4(); - col <<= index; - *dataAddressDestCur |= col; - dataAddressSrcCur++; - } - dataAddressDestCur++; - } - dataAddressSrc += dataStrideLengthSrc; - dataAddressDest += dataStrideLengthDest; - } - break; - } - case EColor256: - { - TUint8* dataAddressDest = static_cast (aDataAddressDest); - const TInt dataStrideLengthDest = aDataStrideDest; - - while(dataAddressSrcEnd > dataAddressSrc) - { - const TUint8* dataAddressDstLineEnd = dataAddressDest + aDataStrideDest; - TUint8* dataAddressDestCur = dataAddressDest; - TUint16* dataAddressSrcCur = dataAddressSrc; - - while(dataAddressDstLineEnd > dataAddressDestCur) - { - *dataAddressDestCur = TRgb::Color64K(*dataAddressSrcCur).Color256(); - dataAddressSrcCur++; - dataAddressDestCur++; - } - dataAddressSrc += dataStrideLengthSrc; - dataAddressDest += dataStrideLengthDest; - } - break; - } - default: - break; - } - } - -TDisplayMode DisplayModeFromPixelFormat(TUidPixelFormat aPixelFormat) - { - switch(aPixelFormat) - { - case EUidPixelFormatARGB_8888_PRE: - return EColor16MAP; - case EUidPixelFormatARGB_8888: - return EColor16MA; - case EUidPixelFormatRGB_565: - return EColor64K; - default: - break; - } - return ENone; - } - -TUidPixelFormat PixelFormatFromDisplayMode(TDisplayMode aDisplayMode) - { - switch (aDisplayMode) - { - case EGray2: - case EGray4: - case EGray16: - case EGray256: - case EColor16: - case EColor256: - case EColor16M: - case EColor16MU: - { - return EUidPixelFormatXRGB_8888; - } - case EColor4K: - { - return EUidPixelFormatXRGB_4444; - } - case EColor64K: - { - return EUidPixelFormatRGB_565; - } - case EColor16MA: - { - return EUidPixelFormatARGB_8888; - } - case EColor16MAP: - { - return EUidPixelFormatARGB_8888_PRE; - } - default: - { - return EUidPixelFormatUnknown; - } - } - } -#endif - -CTGc::CTGc(CTestStep* aStep) : CTWsGraphicsBase(aStep) - { - } - -CTGc::~CTGc() - { - delete iTest; -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA - SgDriver::Close(); - CDirectGdiDriver *directGdiDriver = CDirectGdiDriver::Static(); - if(directGdiDriver) - { - directGdiDriver->Close(); - } -#endif - } - -void CTGc::ConstructL() - { - _LIT(KTestName,"GC Test"); - iTest=new(ELeave) CTestBase(KTestName,this); - -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA - TInt err = CDirectGdiDriver::Open(); - User::LeaveIfError(err); - err = SgDriver::Open(); - if(err != KErrNone) - { - CDirectGdiDriver *directGdiDriver = CDirectGdiDriver::Static(); - if(directGdiDriver) - { - directGdiDriver->Close(); - } - User::Leave(err); - } -#endif - } - -//Class derived from MWsGraphicResolver. Used for playing the commands from command buffer -class CWSGraphicsRes: public CBase, public MWsGraphicResolver - { -public: - void DrawWsGraphic(TInt /*aId*/, TBool /*aIsUid*/, const TRect& /*aRect*/, const TDesC8& /*aData*/) const - { - //Orveriding by giving empty implemention - } - }; - -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA -// -//Class CDrawTextInContextTest -// - -CDrawTextInContextTest::CDrawTextInContextTest(){} - -CDrawTextInContextTest::~CDrawTextInContextTest() - { - delete iRefBitmap; - delete iRefDevice; - delete iRefBitGc; - delete iRemoteGc; - iMsgBuf.Close(); - delete iCommandBuffer; - delete iWsGraphicRes; - - TheClient->iScreen->ReleaseFont(iFont); - - delete iDirectGdiGcWrapper; - if(iWrapperImageTarget) - { - iWrapperImageTarget->Close(); - } - delete iWrapperImageTarget; - iWrapperImage.Close(); - iWrapperImageCollection.Close(); - } - -void CDrawTextInContextTest::BaseConstructL() - { - //Initialise font settings - TFontSpec fsp; - fsp.iTypeface.iName=_L("Series 60 Sans"); - fsp.iHeight=430; - User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont*&)iFont,fsp)); - - //Initialise TTextParameter - iParam.iStart = 27; - iParam.iEnd = 60; - - //Text to draw - iText.Set(_L("This text will not be drawnK.,!\"\x00A3$%^&*()_+-=;'#:@~/<>? Latin This text will not be drawn")); - - //For reference bitmap - iRefBitmap = new(ELeave) CFbsBitmap(); - User::LeaveIfError(iRefBitmap->Create(KBitmapSize, EColor64K)); - iRefDevice = CFbsBitmapDevice::NewL(iRefBitmap); - User::LeaveIfError(iRefDevice->CreateContext(iRefBitGc)); - - CDirectGdiDriver* theDGdiDriver = CDirectGdiDriver::Static(); - User::LeaveIfNull(theDGdiDriver); - - TSgImageInfo info; - info.iUsage = ESgUsageDirectGdiTarget | ESgUsageDirectGdiSource | ESgUsageCompositionSource; - info.iSizeInPixels = KBitmapSize; - info.iPixelFormat = EUidPixelFormatRGB_565; - - TInt res = iWrapperImageCollection.Create(info, 1); - User::LeaveIfError(res); - res = iWrapperImageCollection.OpenImage(0, iWrapperImage); - User::LeaveIfError(res); - iWrapperImageTarget = new (ELeave) RDirectGdiImageTarget(*theDGdiDriver); - res = iWrapperImageTarget->Create(iWrapperImage); - User::LeaveIfError(res); - iDirectGdiGcWrapper = CDirectGdiGcWrapper::NewL(*iWrapperImageTarget); - - //clean image----------------- - CDirectGdiGcWrapper* directGdiGcWrapper = CDirectGdiGcWrapper::NewL(*iWrapperImageTarget); - CleanupStack::PushL(directGdiGcWrapper); - - directGdiGcWrapper->SetDrawMode(MWsGraphicsContext::EDrawModeWriteAlpha); - directGdiGcWrapper->SetBrushColor(KRgbWhite); - directGdiGcWrapper->Clear(); - - CleanupStack::PopAndDestroy(1, directGdiGcWrapper); - //------------------ - - //Used to record draw commands - iRemoteGc = CRemoteGc::NewL(TheClient->iScreen); - - //Used to play recorded draw commands - iCommandBuffer = CCommandBuffer::NewL(); - - //Dummy class created required for CCommandBuffer::Play - iWsGraphicRes = new (ELeave) CWSGraphicsRes(); - - //Offset for CCommandBuffer::Play - iOffset = TPoint(0,0); - - //Result of doing the test - iHasPassedTest = EFalse; - } - -void CDrawTextInContextTest::Test() - { - /* Create reference bitmap by drawing using bitgc */ - iRefBitGc->UseFont(iFont); - DoDrawTextBitGc(); - iRefBitGc->DiscardFont(); - - /* Drawing using CBitGcWrapper via CRemotGc*/ - - //Capturing the commands in remote gc - iRemoteGc->BeginDraw(KBitmapRect); - iRemoteGc->UseFont(iFont); - DoDrawTextRemoteGc(); - iRemoteGc->DiscardFont(); - iRemoteGc->EndDraw(); - - //Externalize the captured commands from remote gc in to a buffer - iRemoteGc->ExternalizeL(iMsgBuf, ETrue); - - //Internalize the buffer with captured commands (from CRemoteGC) in to CCommandBuffer - iCommandBuffer->InternalizeL(iMsgBuf.Pckg()); - - //Play the commands on test window using command buffer - iCommandBuffer->Play(iOffset,&KBitmapRegion,KBitmapRect,*iWsGraphicRes,*iDirectGdiGcWrapper); - - //Test to see if the bitmap drawn to using CRemoteGc is the same as the reference bitmap - CFbsBitmap* bitmap = new (ELeave) CFbsBitmap; - CleanupStack::PushL(bitmap); - - TSgImageInfo info; - iWrapperImage.GetInfo(info); - TDisplayMode displayMode = DisplayModeFromPixelFormat(info.iPixelFormat); - bitmap->Create(info.iSizeInPixels, displayMode); - TRect rect(info.iSizeInPixels); - CopyImageToBitmapL(bitmap, iWrapperImage, rect); - - iHasPassedTest = LossyCompareBitmap(*iRefBitmap, *bitmap, KBitmapRect, EFalse); - - CleanupStack::PopAndDestroy(bitmap); - } - -TBool CDrawTextInContextTest::HasPassedTest() - { - return iHasPassedTest; - } - -// -// Class DrawTextInContextTestPoint -// - -CDrawTextInContextTestPoint::CDrawTextInContextTestPoint(){} - -CDrawTextInContextTestPoint::~CDrawTextInContextTestPoint(){} - -CDrawTextInContextTestPoint* CDrawTextInContextTestPoint::NewL() - { - CDrawTextInContextTestPoint* self = new(ELeave) CDrawTextInContextTestPoint; - CleanupStack::PushL(self); - self->ConstructL(); - CleanupStack::Pop(self); - return self; - } - -void CDrawTextInContextTestPoint::ConstructL() - { - BaseConstructL(); - iPosition = TPoint(0,0); - } - -void CDrawTextInContextTestPoint::DoDrawTextBitGc() - { - iRefBitGc->DrawText(iText,&iParam,iPosition); - } - -void CDrawTextInContextTestPoint::DoDrawTextRemoteGc() - { - iRemoteGc->DrawText(iText,&iParam,iPosition); - } - -// -// Class DrawTextInContextTestBox -// - -CDrawTextInContextTestBox::CDrawTextInContextTestBox(){} - -CDrawTextInContextTestBox::~CDrawTextInContextTestBox(){} - -CDrawTextInContextTestBox* CDrawTextInContextTestBox::NewL() - { - CDrawTextInContextTestBox* self = new(ELeave) CDrawTextInContextTestBox; - CleanupStack::PushL(self); - self->ConstructL(); - CleanupStack::Pop(self); - return self; - } - -void CDrawTextInContextTestBox::ConstructL() - { - BaseConstructL(); - iClipFillRect = TRect(10,50,640,120); - iBaselineOffset = 40; - iTTextAlign = CGraphicsContext::ELeft; - } - -void CDrawTextInContextTestBox::DoDrawTextBitGc() - { - iRefBitGc->DrawText(iText,&iParam,iClipFillRect,iBaselineOffset,iTTextAlign); - } - -void CDrawTextInContextTestBox::DoDrawTextRemoteGc() - { - iRemoteGc->DrawText(iText,&iParam,iClipFillRect,iBaselineOffset,iTTextAlign); - } - -// -// Class CDrawTextInContextTestPointVertical -// - -CDrawTextInContextTestPointVertical::CDrawTextInContextTestPointVertical(){} - -CDrawTextInContextTestPointVertical::~CDrawTextInContextTestPointVertical(){} - -CDrawTextInContextTestPointVertical* CDrawTextInContextTestPointVertical::NewL() - { - CDrawTextInContextTestPointVertical* self = new(ELeave) CDrawTextInContextTestPointVertical; - CleanupStack::PushL(self); - self->ConstructL(); - CleanupStack::Pop(self); - return self; - } - -void CDrawTextInContextTestPointVertical::ConstructL() - { - BaseConstructL(); - iPosition = TPoint(0,0); - iUp = EFalse; - } - -void CDrawTextInContextTestPointVertical::DoDrawTextBitGc() - { - iRefBitGc->DrawTextVertical(iText,&iParam,iPosition,iUp); - } - -void CDrawTextInContextTestPointVertical::DoDrawTextRemoteGc() - { - iRemoteGc->DrawTextVertical(iText,&iParam,iPosition,iUp); - } - -// -// Class CDrawTextInContextTestBoxVertical -// - -CDrawTextInContextTestBoxVertical::CDrawTextInContextTestBoxVertical(){} - -CDrawTextInContextTestBoxVertical::~CDrawTextInContextTestBoxVertical(){} - -CDrawTextInContextTestBoxVertical* CDrawTextInContextTestBoxVertical::NewL() - { - CDrawTextInContextTestBoxVertical* self = new(ELeave) CDrawTextInContextTestBoxVertical; - CleanupStack::PushL(self); - self->ConstructL(); - CleanupStack::Pop(self); - return self; - } - -void CDrawTextInContextTestBoxVertical::ConstructL() - { - BaseConstructL(); - iClipFillRect = TRect(10,50,640,120); - iBaselineOffset = 40; - iUp = EFalse; - iTTextAlign = CGraphicsContext::ELeft; - } - -void CDrawTextInContextTestBoxVertical::DoDrawTextBitGc() - { - iRefBitGc->DrawTextVertical(iText,&iParam,iClipFillRect,iBaselineOffset,iUp,iTTextAlign); - } - -void CDrawTextInContextTestBoxVertical::DoDrawTextRemoteGc() - { - iRemoteGc->DrawTextVertical(iText,&iParam,iClipFillRect,iBaselineOffset,iUp,iTTextAlign); - } -#endif //TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA - -void CleanUpFont(TAny* aFont) - { - //Will be called in case of a leave to release the font - CFont* font= static_cast(aFont); - TheClient->iScreen->ReleaseFont(font); - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-0437 -@SYMPREQ PREQ1543 -@SYMTestCaseDesc Draw text using CWindowGc and CRemoteGc with both outline and shadow -effect on. -@SYMTestPriority High -@SYMTestStatus Implemented -@SYMTestActions Create a font with both outline and shadow effects. Record the commands -(like setting colours,drawing text etc) using CRemoteGc and play the recorded commands on a window. Use the same -commands in CWindowGc and draw text on a different window -@SYMTestExpectedResults Text drawn using CWindowGc and CRemoteGc should be same -*/ -void CTGc::TestOutlineAndShadowL() - { - TRect sourceRect(0, 0, TestWin->Size().iWidth, TestWin->Size().iHeight); - TRegionFix<1> clippingRegion(sourceRect); - - CWsScreenDevice* device = TheClient->iScreen; - - _LIT(KText,"Outline and shadow"); - TFontSpec fSpec(KTestFontTypefaceName,23); - fSpec.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap); - fSpec.iFontStyle.SetEffects(FontEffect::EDropShadow, ETrue); - fSpec.iFontStyle.SetEffects(FontEffect::EOutline, ETrue); - - CFont *font; - User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInPixels((CFont *&)font, fSpec)); - CleanupStack::PushL(TCleanupItem(CleanUpFont, font)); - - CRemoteGc* remoteGc = CRemoteGc::NewL(device); - CleanupStack::PushL(remoteGc); - remoteGc->BeginDraw(sourceRect); - //Capturing the commands in remote gc - remoteGc->SetBrushColor(KRgbGreen); - remoteGc->SetShadowColor(KRgbDarkRed); - remoteGc->SetPenColor(KRgbBlack); - remoteGc->UseFont(font); - remoteGc->DrawText(KText, TPoint(2,40)); - remoteGc->DiscardFont(); - remoteGc->EndDraw(); - - RWsGraphicMsgBuf msgBuf; - CleanupClosePushL(msgBuf); - //Externalize the captured commands from remote gc in to a buffer - remoteGc->ExternalizeL(msgBuf, ETrue); - - CWSGraphicsRes* wsGrap = new (ELeave) CWSGraphicsRes(); - CleanupStack::PushL(wsGrap); - - CCommandBuffer* cmdBuf = CCommandBuffer::NewL(); - CleanupStack::PushL(cmdBuf); - //Internalize the buffer with captured commands (from CRemoteGC) - //in to CCommandBuffer - cmdBuf->InternalizeL(msgBuf.Pckg()); - - TestWin->Win()->Invalidate(); - TestWin->Win()->BeginRedraw(); - TheGc->Activate(*TestWin->Win()); - TheGc->Clear(); - //Play the commands on test window using command buffer -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA - cmdBuf->Play(TPoint(0, 0), &clippingRegion, sourceRect, TheClient->iWs, *TheGc); -#else - cmdBuf->Play(TPoint(),TRect(TestWin->Size()),*wsGrap,*TheGc); -#endif - TheGc->Deactivate(); - TestWin->Win()->EndRedraw(); - - BaseWin->Win()->Invalidate(); - BaseWin->Win()->BeginRedraw(); - TheGc->Activate(*BaseWin->Win()); - TheGc->Clear(); - TheGc->SetBrushColor(KRgbGreen); - TheGc->SetShadowColor(KRgbDarkRed); - TheGc->SetPenColor(KRgbBlack); - TheGc->UseFont(font); - //Draw the text on base window using CWindowGC - TheGc->DrawText(KText, TPoint(2, 40)); - TheGc->DiscardFont(); - TheGc->Deactivate(); - BaseWin->Win()->EndRedraw(); - TheClient->iWs.Finish(); - TheClient->WaitForRedrawsToFinish(); - - //Check the text drawn on base and test windows. - CheckRect(BaseWin, TestWin, TRect(0, 0, BaseWin->Size().iWidth, BaseWin->Size().iHeight), _L("CTGc::TestOutlineAndShadowL()")); - - CleanupStack::PopAndDestroy(4, remoteGc); //cmdBuf, wsGrap, msgBuf and remoteGc - CleanupStack::Pop();//font - TheClient->iScreen->ReleaseFont(font); - } - -void CTGc::TestGcClipRectOrigin_DrawContent(TestWindow& aWindow, TBool bActivateBeforeRedraw /*= ETrue*/) - { - TSize winSize = aWindow.Size(); - TPoint gcOrigin(winSize.iWidth >> 3, winSize.iWidth >> 3); - TRect gcClipRect(0, 0, (winSize.iWidth * 3) >> 2, (winSize.iHeight * 3) >> 2); - TRect ellipseRect(gcClipRect); - // Shrink the ellipse for better visibility and to fit well within the clip area. - ellipseRect.Shrink(3, 3); - TSize penSize(1, 1); - - aWindow.Win()->SetBackgroundColor(KRgbGreen); - aWindow.ClearWin(); - aWindow.Win()->Invalidate(); - - if(!bActivateBeforeRedraw) - { - aWindow.Win()->BeginRedraw(); - } - - TheGc->Activate(*(aWindow.Win())); - TheGc->SetOrigin(gcOrigin); - TheGc->SetClippingRect(gcClipRect); - - if(bActivateBeforeRedraw) - { - aWindow.Win()->BeginRedraw(); - } - - TheGc->SetBrushColor(KRgbDarkRed); - TheGc->SetPenColor(KRgbDarkRed); - TheGc->SetPenSize(penSize); - TheGc->SetPenStyle(CGraphicsContext::ESolidPen); - TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - TheGc->DrawEllipse(ellipseRect); - TheGc->SetBrushStyle(CGraphicsContext::ENullBrush); - TheGc->SetPenColor(KRgbYellow); - TheGc->SetPenStyle(CGraphicsContext::EDashedPen); - TheGc->DrawRect(gcClipRect); - - aWindow.Win()->EndRedraw(); - TheGc->Deactivate(); - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-0471 -@SYMTestCaseDesc This test is to verify that the GC correctly applies the clip rect and - origin attributes irrespective of whether the GC is activated on the - window before or after the BeginRedraw. -@SYMDEF PDEF120091 -@SYMTestPriority High -@SYMTestStatus Implemented -@SYMTestActions The test has following steps: - 1. For the Test window follow the steps: - A. Activate the GC on Test window. - B. Set the Origin of the GC to centre of the window. - C. Set the Clipping rectangle of the GC to half the size of the window. - D. In the BeginDraw and EndDraw call bracket perform the following: - a. Draw an ellipse with the rectangle smaller by 5 pixels than the clip rectangle. - b. Draw a rectangle that is size of the clip rectangle. - E. Deactivate the GC. - 2. For the Base window follow the steps: - A. In the BeginDraw and EndDraw call bracket perform the following: - a. Activate the GC on Base window. - b. Set the Origin of the GC to centre of the window. - c. Set the Clipping rectangle of the GC to half the size of the window. - d. Draw an ellipse with the rectangle smaller by 5 pixels than the clip rectangle. - e. Draw a rectangle that is size of the clip rectangle. - f. Deactivate the GC. - 3. Compare Test and Base window. -@SYMTestExpectedResults Both the Test and Base window should have the complete - non-clipped ellipse completely encapsulated within the rectangle. -*/ -void CTGc::TestGcClipRectOrigin() - { - TestGcClipRectOrigin_DrawContent(*BaseWin, EFalse); - TestGcClipRectOrigin_DrawContent(*TestWin, ETrue); - - TheClient->Flush(); - - CheckRect(BaseWin, TestWin, TRect(0, 0, BaseWin->Size().iWidth, BaseWin->Size().iHeight), _L("CTGc::TestGcClipRectOriginL()")); - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-0469 -@SYMDEF INC116406 -@SYMTestCaseDesc Try playback on MWsGraphicsContext and CWindowGc to check that the background colour is -set correctly. -@SYMTestPriority High -@SYMTestStatus Implemented -@SYMTestActions -@SYMTestExpectedResults Text drawn using CWindowGc should use the background colour of -the window, and MWsGraphicsContext should use transparent white. -*/ -void CTGc::TestResetWithBackgroundColorL() - { - const TRect KSourceRect(0, 0, TestWin->Size().iWidth, TestWin->Size().iHeight); - const TRegionFix<1> KClippingRegion(KSourceRect); - - CWsScreenDevice* device = TheClient->iScreen; - - CRemoteGc* remoteGc = CRemoteGc::NewL(device); - CleanupStack::PushL(remoteGc); - - //note this remote GC has not been activated on any window - remoteGc->BeginDraw(KSourceRect); - - //Draw the commands in remote gc - remoteGc->SetBrushColor(KRgbGreen); //nothing green is seen in this test - - remoteGc->Reset(); //This resets the brush colour to the background colour of the window - //where playback is, in the case of playing back to a window - //however with a CFbsBitGc the color is transparent white, as there is no window. - remoteGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - remoteGc->SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); - remoteGc->DrawRect(KSourceRect); - remoteGc->EndDraw(); - -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA - CDirectGdiDriver* theDGdiDriver = CDirectGdiDriver::Static(); - User::LeaveIfNull(theDGdiDriver); - - TSgImageInfo info; - info.iUsage = ESgUsageDirectGdiTarget | ESgUsageCompositionSource; - info.iSizeInPixels = TSize(TestWin->Size().iWidth, TestWin->Size().iHeight); - info.iPixelFormat = EUidPixelFormatXRGB_8888;//among display modes with alpha channel only pre-multiply alpha is supported in directGDI currently - - RSgImageCollection imageCollection; - CleanupClosePushL(imageCollection); - TInt res = imageCollection.Create(info, 1); - User::LeaveIfError(res); - RSgImage image; - CleanupClosePushL(image); - res = imageCollection.OpenImage(0, image); - User::LeaveIfError(res); - RDirectGdiImageTarget imageTarget(*theDGdiDriver); - CleanupClosePushL(imageTarget); - res = imageTarget.Create(image); - User::LeaveIfError(res); -#endif -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - //create a bitmap - CFbsBitmap *bitmap = new (ELeave) CFbsBitmap(); - User::LeaveIfError(bitmap->Create(TSize(TestWin->Size().iWidth, TestWin->Size().iHeight), EColor16MA)); - CleanupStack::PushL(bitmap); - - CFbsBitmapDevice *fbsDevice = CFbsBitmapDevice::NewL(bitmap); - CleanupStack::PushL(fbsDevice); -#endif - - //prepare the command buffer for playback - RWsGraphicMsgBuf msgBuf; - CleanupClosePushL(msgBuf); - - //Externalize the captured commands from remote gc in to a buffer - remoteGc->ExternalizeL(msgBuf, ETrue); - - CWSGraphicsRes* wsGrap = new (ELeave) CWSGraphicsRes(); - CleanupStack::PushL(wsGrap); - - CCommandBuffer* cmdBuf = CCommandBuffer::NewL(); - CleanupStack::PushL(cmdBuf); - cmdBuf->InternalizeL(msgBuf.Pckg()); - - TRgb color; - TRgb testColor(KRgbWhite); -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA - CDirectGdiGcWrapper* directGdiGcWrapper=CDirectGdiGcWrapper::NewL(imageTarget); - CleanupStack::PushL(directGdiGcWrapper); - cmdBuf->Play(TPoint(),&KClippingRegion,KSourceRect,*wsGrap,*directGdiGcWrapper); - - //check that the background has been cleared to transparent white. - image.GetInfo(info); - info.iUsage = ESgUsageNone; - info.iCpuAccess = ESgCpuAccessReadOnly; - RSgImage image1; - CleanupClosePushL(image1); - res = image1.Create(info, image); - const TAny* data; - TInt stride = 0; - res = image1.MapReadOnly(data, stride); - User::LeaveIfError(res); - TPoint pixel(10,10); - TInt offset = pixel.iY * stride + pixel.iX * 4; - TAny* non_const_data = const_cast (data); - TUint8* pointData = static_cast (non_const_data) + offset; - color = *(reinterpret_cast (pointData)); - image1.Unmap(); -#endif -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - CFbsBitGc* fbsBitGc=NULL; - User::LeaveIfError(fbsDevice->CreateContext(fbsBitGc)); - CleanupStack::PushL(fbsBitGc); - fbsBitGc->Activate(fbsDevice); - cmdBuf->Play(TPoint(0, 0), KSourceRect, *wsGrap, *fbsBitGc); - bitmap->GetPixel(color, TPoint(10,10)); - testColor.SetAlpha(0); -#endif - iStep->TEST(color==testColor); - - //now test drawing to a window to ensure that the brush colour is - //the window background colour - - //display a blue window - BaseWin->Win()->SetBackgroundColor(KRgbBlue); - BaseWin->Win()->Invalidate(); - BaseWin->Win()->BeginRedraw(); - TheGc->Activate(*BaseWin->Win()); - TheGc->Clear(); - TheGc->Deactivate(); - BaseWin->Win()->EndRedraw(); - TheClient->iWs.Finish(); - TheClient->WaitForRedrawsToFinish(); - - //start drawing the display commands with a green background - - BaseWin->Win()->SetBackgroundColor(KRgbYellow); - BaseWin->Win()->Invalidate(); - BaseWin->Win()->BeginRedraw(); - TheGc->Activate(*BaseWin->Win()); - - //Play the commands on test window using command buffer -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA - cmdBuf->Play(TPoint(0, 0), &KClippingRegion, KSourceRect, TheClient->iWs, *TheGc); -#else - cmdBuf->Play(TPoint(0, 0), KSourceRect, *wsGrap, *TheGc); -#endif - - TheGc->Deactivate(); - BaseWin->Win()->EndRedraw(); - TheClient->iWs.Finish(); - TheClient->WaitForRedrawsToFinish(); - - //check that the background has been cleared to yellow, using brush colour - TPoint position = BaseWin->Win()->InquireOffset(*TheClient->iGroup->WinTreeNode()); - position.iX+=10; - position.iY+=10; - TheClient->iScreen->GetPixel(color, position); - iStep->TEST(color==KRgbYellow); - - BaseWin->Win()->SetBackgroundColor(KRgbGreen); //set back to original backgroundcolor - -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA - CleanupStack::PopAndDestroy(9, remoteGc); -#else - CleanupStack::PopAndDestroy(7, remoteGc); -#endif - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-0481 -@SYMPREQ 1841 -@SYMTestCaseDesc Create font and graphics with various effect effects. Record the commands -(like setting colours,drawing text etc) using CRemoteGc and play the recorded commands on a window. Use the same -commands in CWindowGc and draw text on a different window -@SYMTestPriority Medium -@SYMTestStatus Implemented -@SYMTestActions -@SYMTestExpectedResults Text/graphics drawn using CWindowGc and CRemoteGc should be same -*/ -void CTGc::TestCommandBufferL() - { - CWsScreenDevice* device = TheClient->iScreen; - - _LIT(KBuffText,"Command Buffer"); - TFontSpec fSpec(KTestFontTypefaceName,23); - fSpec.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap); - fSpec.iFontStyle.SetEffects(FontEffect::EDropShadow, ETrue); - fSpec.iFontStyle.SetEffects(FontEffect::EOutline, ETrue); - - CFont *font; - User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInPixels((CFont *&)font, fSpec)); - CleanupStack::PushL(TCleanupItem(CleanUpFont, font)); - - CRemoteGc* remoteGc = CRemoteGc::NewL(device); - CleanupStack::PushL(remoteGc); - -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA - //-------create image--------- - CDirectGdiDriver* theDGdiDriver = CDirectGdiDriver::Static(); - User::LeaveIfNull(theDGdiDriver); - const TSize KImageSize = TSize(2, 2); - TSgImageInfo info; - info.iUsage = ESgUsageWindowGcSource; - info.iSizeInPixels = KImageSize; - info.iPixelFormat = EUidPixelFormatRGB_565; - info.iShareable = ETrue; - const TInt stride = KImageSize.iWidth * 2; - TUint8* buf = (TUint8*) (User::AllocL(KImageSize.iHeight * stride)); - CleanupStack::PushL(buf); - TUint16* bufCur = ((TUint16*)buf); - *bufCur = KRgbRed.Color64K(); - *(bufCur + 1) = KRgbRed.Color64K(); - *(bufCur + 2) = KRgbRed.Color64K(); - *(bufCur + 3) = KRgbRed.Color64K(); - - RSgImage image; - TInt res = image.Create(info, buf, stride); - User::LeaveIfError(res); - CleanupClosePushL(image); - RWsDrawableSource drawableSource(TheClient->iWs); - res = drawableSource.Create(image, TheClient->iScreen->GetScreenNumber()); - if(res == KErrNotSupported) - { - INFO_PRINTF1(_L("The current screen is not supports drawable source. This test case terminates now.")); - CleanupStack::PopAndDestroy(3, remoteGc); - CleanupStack::Pop();//font - TheClient->iScreen->ReleaseFont(font); - return; - } - User::LeaveIfError(res); - CleanupClosePushL(drawableSource); - //-------end create image--------- -#endif - remoteGc->ResetCommandBuffer(); - remoteGc->BeginDraw(TRect(0, 0, TestWin->Size().iWidth, TestWin->Size().iHeight)); - //Capturing the commands in remote gc - remoteGc->Clear(); - remoteGc->DrawRect(TRect(10,10,30,30)); - remoteGc->Clear(TRect(10,10,11,11)); - remoteGc->CopyRect(TPoint(5,5), TRect(25,25,30,30)); - CFbsBitmap* bitmap = new (ELeave) CFbsBitmap; - CFbsBitmap* bitmapMask = new (ELeave) CFbsBitmap; - User::LeaveIfError(bitmap->Load(_L("Z:\\WSTEST\\WSAUTOTEST.MBM"), EMbmWsautotestCircles24b)); - User::LeaveIfError(bitmapMask->Load(_L("Z:\\WSTEST\\WSAUTOTEST.MBM"), EMbmWsautotestCircles_mask2b)); - remoteGc->BitBlt(TPoint(100,100), bitmap); - remoteGc->BitBlt(TPoint(0,0), bitmap, TRect(0,0,1,1)); - remoteGc->BitBltMasked(TPoint(0,5), bitmap, TRect(0,0,1,1), bitmapMask, EFalse); - CWsBitmap* bitmapWs = new (ELeave) CWsBitmap(TheClient->iWs); - CWsBitmap* bitmapWsMask = new (ELeave) CWsBitmap(TheClient->iWs); - User::LeaveIfError(bitmapWs->Load(_L("Z:\\WSTEST\\TEST.MBM"), 0)); - remoteGc->BitBlt(TPoint(110,110), bitmapWs); - remoteGc->BitBlt(TPoint(5,0), bitmapWs, TRect(0,0,1,1)); - remoteGc->BitBltMasked(TPoint(10,0), bitmap, TRect(0,0,1,1), bitmapWsMask, EFalse); - remoteGc->SetFadingParameters(128,128); - remoteGc->SetFaded(EFalse); - remoteGc->AlphaBlendBitmaps(TPoint(2,2), bitmap, TRect(0,0,1,1), bitmapMask, TPoint(2,2)); - remoteGc->AlphaBlendBitmaps(TPoint(3,3), bitmapWs, TRect(0,0,1,1), bitmapWsMask, TPoint(2,2)); - remoteGc->SetOrigin(TPoint(0,30)); - remoteGc->SetDrawMode(CGraphicsContext::EDrawModePEN); - remoteGc->SetClippingRect(TRect(0,0,10,10)); - remoteGc->SetPenStyle(CGraphicsContext::ESolidPen); - remoteGc->SetPenSize(TSize(1,2)); - remoteGc->UseBrushPattern(bitmap); - remoteGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - remoteGc->SetBrushOrigin(TPoint(0,0)); - remoteGc->DrawPie(TRect(0,0,15,15),TPoint(0,8),TPoint(15,8)); - remoteGc->CancelClippingRect(); - remoteGc->DiscardBrushPattern(); - remoteGc->CancelClippingRegion(); - remoteGc->Reset(); - remoteGc->SetOrigin(TPoint(0,0)); - remoteGc->SetUnderlineStyle(EUnderlineOff); - remoteGc->SetStrikethroughStyle(EStrikethroughOff); - remoteGc->SetWordJustification(1,2); - remoteGc->SetCharJustification(1,2); - remoteGc->UseFont(font); - remoteGc->DrawText(KBuffText,TRect(50,0,100,50),10,CGraphicsContext::ELeft,0); - remoteGc->DrawTextVertical(KBuffText,TPoint(170,20),EFalse); - remoteGc->DrawTextVertical(KBuffText,TRect(120,20,150,100),5,EFalse,CGraphicsContext::ELeft,0); - remoteGc->MoveTo(TPoint(25,150)); - remoteGc->MoveBy(TPoint(5,5)); - remoteGc->DrawLineTo(TPoint(35,160)); - remoteGc->DrawLine(TPoint(35,160),TPoint(25,150)); - remoteGc->DrawLineBy(TPoint(15,6)); - remoteGc->Plot(TPoint(5,5)); - remoteGc->DrawArc(TRect(0,80,10,90),TPoint(0,85),TPoint(10,85)); - remoteGc->DrawEllipse(TRect(0,90,10,100)); - remoteGc->DrawRoundRect(TRect(30,80,50,100),TSize(5,5)); - remoteGc->DrawBitmap(TPoint(150,150),bitmap); - remoteGc->DrawBitmap(TRect(160,160,170,170), bitmap); - remoteGc->DrawBitmap(TRect(175,175,180,180), bitmap, TRect(0,5,5,10)); - remoteGc->DrawBitmapMasked(TRect(185,185,190,190), bitmap, TRect(0,50,5,55),bitmapMask,EFalse); - remoteGc->DrawBitmapMasked(TRect(195,195,200,200), bitmapWs, TRect(0,50,5,55),bitmapWsMask,EFalse); - CArrayFixFlat* polyPoints = new(ELeave) CArrayFixFlat(3); //CArrayFixFlat - CleanupStack::PushL(polyPoints); - TRect rect (200,0,200,100); - polyPoints->AppendL(rect.iTl); - polyPoints->AppendL(rect.Center()); - polyPoints->AppendL(TPoint(rect.iBr.iX, rect.iTl.iY)); - remoteGc->DrawPolyLine(polyPoints); - remoteGc->DrawPolyLine(&polyPoints->At(0), 3); - remoteGc->DrawPolygon(polyPoints, CGraphicsContext::EWinding); - remoteGc->DrawPolygon(&polyPoints->At(0), 3, CGraphicsContext::EAlternate); -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA - MWsDrawResource* dr = static_cast(remoteGc->Interface(KMWsDrawResourceInterfaceUid)); - if(dr) - dr->DrawResource(TPoint(30, 40), drawableSource); -#endif - RRegion region; - remoteGc->SetClippingRegion(region); - remoteGc->DiscardFont(); - remoteGc->EndDraw(); - - RWsGraphicMsgBuf msgBuf; - CleanupClosePushL(msgBuf); - //Externalize the captured commands from remote gc in to a buffer - remoteGc->ExternalizeL(msgBuf, EFalse); - - CCommandBuffer* cmdBuf = CCommandBuffer::NewL(); - CleanupStack::PushL(cmdBuf); - const CCommandBuffer* testCmdBuf = CCommandBuffer::NewL(); - if(cmdBuf->IsIdentical(*testCmdBuf)==EFalse) - { - User::Panic(_L("TestCommandBufferL"), KErrGeneral); - } - delete testCmdBuf; - //Internalize the buffer with captured commands (from CRemoteGC) - //in to CCommandBuffer - cmdBuf->InternalizeL(msgBuf.Pckg()); - - TheGc->Activate(*TestWin->Win()); - TestWin->Win()->Invalidate(); - -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - /* - * Make sure anything that can leave is done outside the - * BeginRedraw/EndRedraw bracket. - */ - CWSGraphicsRes* wsGrap=new(ELeave) CWSGraphicsRes(); - CleanupStack::PushL(wsGrap); -#endif - /* - * Note we need to still do BeginRedraw/EndRedraw for the TestWin Window - * even though the CRemoteGc we are going to Play into TestWin already has - * BeginRedraw/EndRedraw commands issued into it. Those commands just allow - * for replacement of draw ops already in the CRemoteGc to be replaced by - * new draw ops covering the same area. The BeginRedraw/EndRedraws never - * get Play()'ed into TestWin. - */ - TestWin->Win()->BeginRedraw(); - TheGc->Clear(); - //Play the commands on test window using command buffer -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA - cmdBuf->Play(TPoint(), NULL, TRect(TestWin->Size()), TheClient->iWs, *TheGc); -#endif -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - cmdBuf->Play(TPoint(),TRect(TestWin->Size()),*wsGrap,*TheGc); - CleanupStack::PopAndDestroy(wsGrap); -#endif - TheGc->Deactivate(); - TestWin->Win()->EndRedraw(); - remoteGc->ResetCommandBuffer(); - BaseWin->Win()->Invalidate(); - BaseWin->Win()->BeginRedraw(); - TheGc->Activate(*BaseWin->Win()); - TheGc->Clear(); - TheGc->DrawRect(TRect(10,10,30,30)); - TheGc->Clear(TRect(10,10,11,11)); - TheGc->CopyRect(TPoint(5,5), TRect(25,25,30,30)); - TheGc->BitBlt(TPoint(100,100), bitmap); - TheGc->BitBlt(TPoint(0,0), bitmap, TRect(0,0,1,1)); - TheGc->BitBltMasked(TPoint(0,5), bitmap, TRect(0,0,1,1), bitmapMask, EFalse); - TheGc->BitBlt(TPoint(110,110), bitmapWs); - TheGc->BitBlt(TPoint(5,0), bitmapWs, TRect(0,0,1,1)); - TheGc->BitBltMasked(TPoint(10,0), bitmap, TRect(0,0,1,1), bitmapWsMask, EFalse); - TheGc->SetFadingParameters(128,128); - TheGc->SetFaded(EFalse); - TheGc->AlphaBlendBitmaps(TPoint(2,2), bitmap, TRect(0,0,1,1), bitmapMask, TPoint(2,2)); - TheGc->AlphaBlendBitmaps(TPoint(3,3), bitmapWs, TRect(0,0,1,1), bitmapWsMask, TPoint(2,2)); - TheGc->SetOrigin(TPoint(0,30)); - TheGc->SetDrawMode(CGraphicsContext::EDrawModePEN); - TheGc->SetClippingRect(TRect(0,0,10,10)); - TheGc->SetPenStyle(CGraphicsContext::ESolidPen); - TheGc->SetPenSize(TSize(1,2)); - TheGc->UseBrushPattern(bitmap); - TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - TheGc->SetBrushOrigin(TPoint(0,0)); - TheGc->DrawPie(TRect(0,0,15,15),TPoint(0,8),TPoint(15,8)); - TheGc->CancelClippingRect(); - TheGc->DiscardBrushPattern(); - TheGc->CancelClippingRegion(); - TheGc->Reset(); - TheGc->SetOrigin(TPoint(0,0)); - TheGc->SetUnderlineStyle(EUnderlineOff); - TheGc->SetStrikethroughStyle(EStrikethroughOff); - TheGc->SetWordJustification(1,2); - TheGc->SetCharJustification(1,2); - TheGc->UseFont(font); - TheGc->DrawText(KBuffText,TRect(50,0,100,50),10,CGraphicsContext::ELeft,0); - TheGc->DrawTextVertical(KBuffText,TPoint(170,20),EFalse); - TheGc->DrawTextVertical(KBuffText,TRect(120,20,150,100),5,EFalse,CGraphicsContext::ELeft,0); - TheGc->MoveTo(TPoint(25,150)); - TheGc->MoveBy(TPoint(5,5)); - TheGc->DrawLineTo(TPoint(35,160)); - TheGc->DrawLine(TPoint(35,160),TPoint(25,150)); - TheGc->DrawLineBy(TPoint(15,6)); - TheGc->Plot(TPoint(5,5)); - TheGc->DrawArc(TRect(0,80,10,90),TPoint(0,85),TPoint(10,85)); - TheGc->DrawEllipse(TRect(0,90,10,100)); - TheGc->DrawRoundRect(TRect(30,80,50,100),TSize(5,5)); - TheGc->DrawBitmap(TPoint(150,150),bitmap); - TheGc->DrawBitmap(TRect(160,160,170,170), bitmap); - TheGc->DrawBitmap(TRect(175,175,180,180), bitmap, TRect(0,5,5,10)); - TheGc->DrawBitmapMasked(TRect(185,185,190,190), bitmap, TRect(0,50,5,55),bitmapMask,EFalse); - TheGc->DrawBitmapMasked(TRect(195,195,200,200), bitmapWs, TRect(0,50,5,55),bitmapWsMask,EFalse); - TheGc->DrawPolyLine(polyPoints); - TheGc->DrawPolyLine(&polyPoints->At(0), 3); - TheGc->DrawPolygon(polyPoints, CGraphicsContext::EWinding); - TheGc->DrawPolygon(&polyPoints->At(0), 3, CGraphicsContext::EAlternate); -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA - TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - TheGc->SetBrushColor(KRgbRed); - TheGc->SetPenColor(KRgbRed); - TheGc->DrawRect(TRect(30, 40, 32, 42)); -#endif - TheGc->DiscardFont(); - TheGc->Deactivate(); - BaseWin->Win()->EndRedraw(); - TheClient->Flush(); - TheClient->WaitForRedrawsToFinish(); - - //Check the text drawn on base and test windows. - TBool err = CheckRect(BaseWin, TestWin, TRect(0, 0, BaseWin->Size().iWidth, BaseWin->Size().iHeight), _L("CTGc::TestCommandBufferL()")); - if (err) - { - INFO_PRINTF1(_L("The CheckRect function returned error.")); - } - delete bitmap; - INFO_PRINTF1(_L("bitmap deleted.")); - delete bitmapMask; - INFO_PRINTF1(_L("bitmapMask deleted.")); - delete bitmapWs; - INFO_PRINTF1(_L("bitmapWs deleted.")); - delete bitmapWsMask; - INFO_PRINTF1(_L("bitmapWsMask deleted.")); - -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA - CleanupStack::PopAndDestroy(7, remoteGc); -#else - CleanupStack::PopAndDestroy(4, remoteGc); -#endif - CleanupStack::Pop();//font - INFO_PRINTF1(_L("CleanupStack popped.")); - TheClient->iScreen->ReleaseFont(font); - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-0482 -@SYMPREQ 1841 -@SYMTestCaseDesc Play empty command buffer. -@SYMTestPriority Medium -@SYMTestStatus Implemented -@SYMTestActions -@SYMTestExpectedResults return KErrEof error -*/ -void CTGc::TestEmptyCommandBufferL() - { -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - CWSGraphicsRes* wsGrap = new (ELeave) CWSGraphicsRes(); - CleanupStack::PushL(wsGrap); -#endif - - CCommandBuffer* cmdBuf = CCommandBuffer::NewL(); - CleanupStack::PushL(cmdBuf); - - TheGc->Activate(*TestWin->Win()); - TheGc->Clear(); - //Play the commands on test window using command buffer -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - TInt err = cmdBuf->Play(TPoint(),TRect(TestWin->Size()),*wsGrap,*TheGc); -#else - TInt err = cmdBuf->Play(TPoint(),NULL,TRect(TestWin->Size()),TheClient->iWs,*TheGc); -#endif - if(err!=KErrEof) - { - User::Panic(_L("TestEmptyCommandBufferL"), KErrGeneral); - } - TheGc->Deactivate(); -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA - CleanupStack::PopAndDestroy(2, wsGrap); //cmdBuf, wsGrap, msgBuf and remoteGc -#else - CleanupStack::PopAndDestroy(cmdBuf); -#endif - } - -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA -/** -@SYMTestCaseID GRAPHICS-WSERV-0486 -@SYMPREQ PREQ2095 -@SYMTestCaseDesc Draw text using CWindowGc and CRemoteGc with both outline and shadow -effect on. -@SYMTestPriority High -@SYMTestStatus Implemented -@SYMTestActions Create a font with both outline and shadow effects, also use ClippingRect -and ClippingRegion. Record the commands using CRemoteGc and play the recorded commands on a -bitmap using MWsGraphicsContext. Use the same commands in CWindowGc and draw text on a -different window -@SYMTestExpectedResults Text drawn using CWindowGc and CRemoteGc(MWsGraphicsContext) should be same -*/ -void CTGc::TestCRemoteGcAndMWsGraphicsContextClippingRectL() - { - const TRect KTestRect(0, 0, TestWin->Size().iWidth, TestWin->Size().iHeight); - const TRegionFix<1> KTestRegion(KTestRect); - const TRect KClippingRect1(5, 5, TestWin->Size().iWidth-10, 90); - const TRegionFix<1> KClippingRegion(KClippingRect1); - const TRect KClippingRect2(15, 15, TestWin->Size().iWidth-10, TestWin->Size().iHeight-10); - - CWsScreenDevice* device = TheClient->iScreen; - /* - * On hardware, the first screen runs in 64K colors, but the second screen (TV OUT) - * cannot run in this mode, it instead falls back to 16M colors. We need to ensure - * that we use matching color depths for our off-screen bitmaps so that accuracy is - * not lost since we compare bitmaps from the screen versus off-screen. - */ - const TDisplayMode displayMode = device->DisplayMode(); - - _LIT(KText,"RemoteGc & MWsGraphicsContext"); - TFontSpec fSpec(KTestFontTypefaceName,23); - fSpec.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap); - fSpec.iFontStyle.SetEffects(FontEffect::EDropShadow, ETrue); - fSpec.iFontStyle.SetEffects(FontEffect::EOutline, ETrue); - - CFont *font; - User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInPixels((CFont *&)font, fSpec)); - CleanupStack::PushL(TCleanupItem(CleanUpFont, font)); - - //Record the commands using CRemoteGc - CRemoteGc* remoteGc = CRemoteGc::NewL(device); - CleanupStack::PushL(remoteGc); - remoteGc->BeginDraw(KTestRect); - //fill background with white - remoteGc->SetPenStyle(CFbsBitGc::ENullPen); - remoteGc->SetBrushStyle(CFbsBitGc::ESolidBrush); - remoteGc->SetBrushColor(KRgbWhite); - remoteGc->DrawRect(TRect(TPoint(0,0), TestWin->Size())); - remoteGc->SetPenStyle(CFbsBitGc::ESolidPen); - //Capturing the commands in remote gc - remoteGc->SetClippingRect(KClippingRect2); - remoteGc->SetClippingRegion(KClippingRegion); - remoteGc->SetBrushStyle(CFbsBitGc::ESolidBrush); - remoteGc->SetBrushColor(TRgb(0,150,150)); - remoteGc->DrawRect(TRect(TPoint(0,0), TSize(160,60))); - remoteGc->SetBrushColor(TRgb(150,100,150)); - remoteGc->DrawRect(TRect(TPoint(0,60), TSize(160,60))); - remoteGc->SetBrushColor(KRgbGreen); - remoteGc->SetShadowColor(KRgbDarkRed); - remoteGc->SetPenColor(KRgbBlack); - remoteGc->UseFont(font); - remoteGc->DrawText(KText, TPoint(2,40)); - remoteGc->DiscardFont(); - remoteGc->EndDraw(); - - RWsGraphicMsgBuf msgBuf; - CleanupClosePushL(msgBuf); - //Externalize the captured commands from remote gc in to a buffer - remoteGc->ExternalizeL(msgBuf, ETrue); - - CCommandBuffer* cmdBuf = CCommandBuffer::NewL(); - CleanupStack::PushL(cmdBuf); - //Internalize the buffer with captured commands (from CRemoteGC) - //in to CCommandBuffer - cmdBuf->InternalizeL(msgBuf.Pckg()); - - CDirectGdiDriver* theDGdiDriver = CDirectGdiDriver::Static(); - User::LeaveIfNull(theDGdiDriver); - - TSgImageInfo info; - info.iUsage = ESgUsageDirectGdiTarget | ESgUsageDirectGdiSource | ESgUsageCompositionSource; - info.iSizeInPixels = TestWin->Size(); - info.iPixelFormat = PixelFormatFromDisplayMode(displayMode); - - RSgImageCollection imageCollection; - CleanupClosePushL(imageCollection); - TInt res = imageCollection.Create(info, 1); - User::LeaveIfError(res); - RSgImage image; - CleanupClosePushL(image); - res = imageCollection.OpenImage(0, image); - User::LeaveIfError(res); - RDirectGdiImageTarget imageTarget(*theDGdiDriver); - CleanupClosePushL(imageTarget); - - res = imageTarget.Create(image); - User::LeaveIfError(res); - - CDirectGdiGcWrapper* directGdiGcWrapper = CDirectGdiGcWrapper::NewL(imageTarget); - CleanupStack::PushL(directGdiGcWrapper); - - //Dummy class created - CWSGraphicsRes* wsGrap = new (ELeave) CWSGraphicsRes(); - CleanupStack::PushL(wsGrap); - - //Play the commands on test window using command buffer - cmdBuf->Play(TPoint(),&KTestRegion,KTestRect,*wsGrap,*directGdiGcWrapper); - - //Set window back to same as test bitmap background - BaseWin->Win()->SetBackgroundColor(KRgbWhite); - - BaseWin->Win()->Invalidate(); - BaseWin->Win()->BeginRedraw(); - TheGc->Activate(*BaseWin->Win()); - TheGc->Clear(); - TheGc->SetClippingRect(KClippingRect2); - TheGc->SetClippingRegion(KClippingRegion); - TheGc->SetBrushStyle(CFbsBitGc::ESolidBrush); - TheGc->SetBrushColor(TRgb(0,150,150)); - TheGc->DrawRect(TRect(TPoint(0,0), TSize(160,60))); - TheGc->SetBrushColor(TRgb(150,100,150)); - TheGc->DrawRect(TRect(TPoint(0,60), TSize(160,60))); - TheGc->SetBrushColor(KRgbGreen); - TheGc->SetShadowColor(KRgbDarkRed); - TheGc->SetPenColor(KRgbBlack); - TheGc->UseFont(font); - //Draw the text on base window using CWindowGC - TheGc->DrawText(KText, TPoint(2, 40)); - TheGc->DiscardFont(); - TheGc->Deactivate(); - BaseWin->Win()->EndRedraw(); - TheClient->iWs.Finish(); - TheClient->WaitForRedrawsToFinish(); - - //Create a bitmap and then copy the screen to it - TRect rc(TRect(BaseWin->Win()->AbsPosition(), BaseWin->Win()->Size())); - CFbsBitmap *screenBitmap = new (ELeave) CFbsBitmap(); - User::LeaveIfError(screenBitmap->Create(rc.Size(), displayMode)); - CleanupStack::PushL(screenBitmap); - TheClient->iScreen->CopyScreenToBitmap(screenBitmap, rc); - - CFbsBitmap* bitmap = new (ELeave) CFbsBitmap; - CleanupStack::PushL(bitmap); - - image.GetInfo(info); - bitmap->Create(info.iSizeInPixels, displayMode); - TRect rect(info.iSizeInPixels); - CopyImageToBitmapL(bitmap, image, rect); - - //Test to see if the bitmap drawn to using CRemoteGc is the same as the screen copy bitmap - TInt differentPixels = 0; - res = LossyCompareBitmapRecord(*bitmap, *screenBitmap, KTestRect, EFalse, differentPixels, Logger()); - if (differentPixels != 0) - { - INFO_PRINTF2(_L(" Pixels different %d"), differentPixels); - } - TEST(res); - CleanupStack::PopAndDestroy(10, remoteGc); //screenBitmap, imageCollection, image, imageTarget, directGdiGcWrapper, cmdBuf, wsGrap, msgBuf, remoteGc, bitmap - CleanupStack::Pop();//font - TheClient->iScreen->ReleaseFont(font); - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-0487 -@SYMPREQ PREQ2095 -@SYMTestCaseDesc Draw text using CRemoteGc and DrawText(const TDesC&,const TTextParameters*,const TPoint&) -@SYMTestPriority High -@SYMTestStatus Implemented -@SYMTestActions Create a font. Draw text to a bitmap with the font using CFbsBitGc::DrawText. Draw text with the font using CFbsBitGc::DrawText. -Record the same DrawText commands using CRemoteGc and play the recorded commands on a -bitmap using MWsGraphicsContext. Compare the two bitmaps. -@SYMTestExpectedResults Text drawn using CFbsBitGc and CRemoteGc(MWsGraphicsContext) should be the same -*/ -void CTGc::TestCRemoteGcDrawTextInContextPointL() - { - CDrawTextInContextTestPoint* test = CDrawTextInContextTestPoint::NewL(); - CleanupStack::PushL(test); - test->Test(); - TEST(test->HasPassedTest()); - CleanupStack::PopAndDestroy(); //test - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-0488 -@SYMPREQ PREQ2095 -@SYMTestCaseDesc Draw text using CRemoteGc and DrawText(const TDesC&,const TTextParameters*,const TRect&,TInt,TTextAlign,TInt) -@SYMTestPriority High -@SYMTestStatus Implemented -@SYMTestActions Create a font. Draw text to a bitmap with the font using CFbsBitGc::DrawText. Draw text with the font using CFbsBitGc::DrawText. -Record the same DrawText commands using CRemoteGc and play the recorded commands on a -bitmap using MWsGraphicsContext. Compare the two bitmaps. -@SYMTestExpectedResults Text drawn using CFbsBitGc and CRemoteGc(MWsGraphicsContext) should be the same -*/ -void CTGc::TestCRemoteGcDrawTextInContextBoxL() - { - CDrawTextInContextTestBox* test = CDrawTextInContextTestBox::NewL(); - CleanupStack::PushL(test); - test->Test(); - TEST(test->HasPassedTest()); - CleanupStack::PopAndDestroy(); //test - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-0489 -@SYMPREQ PREQ2095 -@SYMTestCaseDesc Draw text using CRemoteGc and DrawTextVertical(const TDesC&,const TTextParameters*,const TPoint&) -@SYMTestPriority High -@SYMTestStatus Implemented -@SYMTestActions Create a font. Draw text to a bitmap with the font using CFbsBitGc::DrawTextVertical. Draw text with the font using CFbsBitGc::DrawText. -Record the same DrawText commands using CRemoteGc and play the recorded commands on a -bitmap using MWsGraphicsContext. Compare the two bitmaps. -@SYMTestExpectedResults Text drawn using CFbsBitGc and CRemoteGc(MWsGraphicsContext) should be the same -*/ -void CTGc::TestCRemoteGcDrawTextInContextPointVerticalL() - { - CDrawTextInContextTestPointVertical* test = CDrawTextInContextTestPointVertical::NewL(); - CleanupStack::PushL(test); - test->Test(); - TEST(test->HasPassedTest()); - CleanupStack::PopAndDestroy(); //test - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-0490 -@SYMPREQ PREQ2095 -@SYMTestCaseDesc Draw text using CRemoteGc and DrawTextVertical(const TDesC&,const TTextParameters*,const TRect&,TInt,TTextAlign,TInt) -@SYMTestPriority High -@SYMTestStatus Implemented -@SYMTestActions Create a font. Draw text to a bitmap with the font using CFbsBitGc::DrawTextVertical. Draw text with the font using CFbsBitGc::DrawText. -Record the same DrawText commands using CRemoteGc and play the recorded commands on a -bitmap using MWsGraphicsContext. Compare the two bitmaps. -@SYMTestExpectedResults Text drawn using CFbsBitGc and CRemoteGc(MWsGraphicsContext) should be the same -*/ -void CTGc::TestCRemoteGcDrawTextInContextBoxVerticalL() - { - CDrawTextInContextTestBoxVertical* test = CDrawTextInContextTestBoxVertical::NewL(); - CleanupStack::PushL(test); - test->Test(); - TEST(test->HasPassedTest()); - CleanupStack::PopAndDestroy(); //test - } -#endif //TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA - -/** -@SYMTestCaseID GRAPHICS-WSERV-0494 -@SYMDEF DEF131255 -@SYMTestCaseDesc Negative test to show that using SetBrushStyle() will not panic WServ with different - brush bitmaps. -@SYMTestPriority High -@SYMTestStatus Implemented -@SYMTestActions Four seperate panic situations are tested: - 1) - Create a regular CFbsBitmap, set as brush pattern, and set brush style to EPatternedBrush. - Draw a line to force the playback to occur. - Call Finish on the GC. - Destroy the brush bitmap. - 2) - Create a regular CFbsBitmap, set as brush pattern, and set brush style to EPatternedBrush. - Draw a line to force the playback to occur. - Destroy the brush bitmap. - Call Finish on the GC. - 3+4) - Create an extended bitmap, set as the brush pattern, and set the brush style to EPatternedBrush. - Draw a line to force the playback to occur. - Set the brush bitmap and style again. - Call Finish on the GC. - Destroy the brush bitmap. -@SYMTestExpectedResults The calls to SetBrushStyle() should not cause WServ to panic when Finish() is called. -*/ -void CTGc::TestGcSetBrushPatternL() - { - // Extended bitmap test data. - const TUint8 KTestData[] = "TEST DATA"; - const TInt KTestDataSize = sizeof(KTestData); - const TUid KTestExtendedBitmapUid = TUid::Uid(0xFFFFFFFF); - - // First try using a regular bitmap as the brush pattern. - BaseWin->Win()->Invalidate(); - BaseWin->Win()->BeginRedraw(); - TheGc->Activate(*BaseWin->Win()); - CFbsBitmap* bitmapRegular = new (ELeave) CFbsBitmap; - CleanupStack::PushL(bitmapRegular); - TInt res = bitmapRegular->Create(TSize(10,10), EColor64K); - TEST(res == KErrNone); - //Record the commands using CWindowGc. - TheGc->UseBrushPattern(bitmapRegular); - TheGc->SetBrushStyle(CGraphicsContext::EPatternedBrush); - // DrawLine() is only used here to force playback of the commands. - TheGc->DrawLine(TPoint(0,0), TPoint(1,1)); - TheGc->Deactivate(); - BaseWin->Win()->EndRedraw(); - TheClient->iWs.Finish(); - CleanupStack::PopAndDestroy(1, bitmapRegular); - - // Secondly, try using a regular bitmap as the brush pattern, but deleting the bitmap - // before calling Finish(). - BaseWin->Win()->Invalidate(); - BaseWin->Win()->BeginRedraw(); - TheGc->Activate(*BaseWin->Win()); - bitmapRegular = new (ELeave) CFbsBitmap; - CleanupStack::PushL(bitmapRegular); - res = bitmapRegular->Create(TSize(10,10), EColor64K); - TEST(res == KErrNone); - //Record the commands using CWindowGc. - TheGc->UseBrushPattern(bitmapRegular); - TheGc->SetBrushStyle(CGraphicsContext::EPatternedBrush); - TheGc->DrawLine(TPoint(0,0), TPoint(1,1)); - CleanupStack::PopAndDestroy(1, bitmapRegular); - TheGc->Deactivate(); - BaseWin->Win()->EndRedraw(); - TheClient->iWs.Finish(); - - // Thirdly, try using an extended bitmap (which is unsupported by DirectGDI) as - // the brush pattern. - BaseWin->Win()->Invalidate(); - BaseWin->Win()->BeginRedraw(); - TheGc->Activate(*BaseWin->Win()); - // Create a dummy extended bitmap to use as a brush bitmap. - // This is unsupported by the default implementation of DirectGDI. - CFbsBitmap* bitmapExtended = new (ELeave) CFbsBitmap; - CleanupStack::PushL(bitmapExtended); - res = bitmapExtended->CreateExtendedBitmap(TSize(10,10), EColor64K, KTestExtendedBitmapUid, KTestData, KTestDataSize); - TEST(res == KErrNone); - //Record the commands using CWindowGc. - TheGc->UseBrushPattern(bitmapExtended); - TheGc->SetBrushStyle(CGraphicsContext::EPatternedBrush); - TheGc->DrawLine(TPoint(0,0), TPoint(100,100)); - TheGc->UseBrushPattern(bitmapExtended); - // Forth, do it twice so that we test the state commands and the drawops commands. - TheGc->SetBrushStyle(CGraphicsContext::EPatternedBrush); - TheGc->DrawLine(TPoint(0,0), TPoint(100,100)); - TheGc->Deactivate(); - BaseWin->Win()->EndRedraw(); - TheClient->iWs.Finish(); - CleanupStack::PopAndDestroy(1, bitmapExtended); - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-0576 -@SYMDEF -@SYMTestCaseDesc Checks window server is still able to draw a bitmap, even after the client has released its handle to the bitmap. -@SYMTestPriority High -@SYMTestStatus Implemented -@SYMTestActions - Draw the bitmap to TestWin (keeping the window hidden) - - Delete the bitmap - - Show TestWin to cause it to be drawn on screen (after the bitmap has been deleted) - - Draw the same bitmap (same image, different bitmap object instance) to BaseWin - - Compare contents of TestWin with BaseWin -@SYMTestExpectedResults TestWin and BaseWin should both show the bitmap. -*/ -void CTGc::TestGcDeleteBitmap1L() - { - CFbsBitmap* bitmap = new (ELeave) CFbsBitmap; - CleanupStack::PushL(bitmap); - TInt ret = bitmap->Load(TEST_BITMAP_NAME,0); - TEST(ret == KErrNone); - - // send drawing to hidden window - TestWin->SetVisible(EFalse); - TestWin->Win()->Invalidate(); - TestWin->Win()->BeginRedraw(); - TheGc->Activate(*TestWin->Win()); - TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - TheGc->SetDrawMode(CGraphicsContext::EDrawModePEN); - TheGc->SetBrushColor(TRgb(255, 0, 0)); - TheGc->Clear(); - TheGc->BitBlt(TPoint(0,0), bitmap); - CleanupStack::PopAndDestroy(bitmap); // before the bitmap is actually deleted, WsFbsDestroyCallBack flushes the command buffer to ensure the bitmap is duplicated in the window server thread - bitmap = NULL; - TheGc->Deactivate(); - TestWin->Win()->EndRedraw(); - TheClient->iWs.Flush(); // calling Flush rather than Finish, as we don't need to wait for any drawing to happen (as the window is currently hidden) - - // make window visible (forcing it to draw) - TestWin->SetVisible(ETrue); - TheClient->iWs.Finish(); // ensure the bitmap has been drawn on test win - - // window server should have duplicated the bitmap when the BitBlt was added to the redraw store, so drawing - // the window now (by making it visible above) should display the bitmap on screen, even - // though we've deleted it in this thread - - // now create the bitmap again, and draw it to the base win (for comparison with test win) - bitmap = new (ELeave) CFbsBitmap; - CleanupStack::PushL(bitmap); - ret = bitmap->Load(TEST_BITMAP_NAME,0); - TEST(ret == KErrNone); - BaseWin->SetVisible(ETrue); - BaseWin->Win()->Invalidate(); - BaseWin->Win()->BeginRedraw(); - TheGc->Activate(*BaseWin->Win()); - TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - TheGc->SetDrawMode(CGraphicsContext::EDrawModePEN); - TheGc->SetBrushColor(TRgb(255, 0, 0)); - TheGc->Clear(); - TheGc->BitBlt(TPoint(0,0), bitmap); - TheGc->Deactivate(); - BaseWin->Win()->EndRedraw(); - TheClient->iWs.Finish(); // ensure the bitmap has been drawn on base win - - CleanupStack::PopAndDestroy(bitmap); - - // the test bitmap should be shown in both base win and test win, so we now check that the - // contents of base win and test win are the same - CheckRect(BaseWin, TestWin, TRect(0, 0, BaseWin->Size().iWidth, BaseWin->Size().iHeight), _L("CTGc::TestGcDeleteBitmap1L()")); - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-0577 -@SYMDEF -@SYMTestCaseDesc Check window server is still able to use a bitmap required by window drawing, even - after the client has released its handle to the bitmap. Also check window server - releases the bitmap, when it's no longer used by window drawing. -@SYMTestPriority High -@SYMTestStatus Implemented -@SYMTestActions - Clean BaseWin and TestWin from content that has been left over from previous test - - Draw test bitmap to TestWin - - Delete the bitmap - - Using a different bitmap object instance, duplicate bitmap (the bitmap is still used by window drawing) - - Delete the bitmap - - Draw new content to TestWin, so that previously drawn bitmap is covered - - Duplicate bitmap (the bitmap is no longer used by window drawing) -@SYMTestExpectedResults Bitmap duplication succeeds, when the bitmap used by window drawing, whereas - bitmap duplication fails, when the bitmap is no longer used by window drawing. -*/ -void CTGc::TestGcDeleteBitmap2L() - { - //send new drawing to test and base windows, in order to cover - //any content has been left on them (through previous test) - BaseWin->SetVisible(ETrue); - BaseWin->Win()->Invalidate(); - BaseWin->Win()->BeginRedraw(); - TheGc->Activate(*BaseWin->Win()); - TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - TheGc->SetDrawMode(CGraphicsContext::EDrawModePEN); - TheGc->SetBrushColor(TRgb(0, 0, 255)); - TheGc->Clear(); - TheGc->Deactivate(); - BaseWin->Win()->EndRedraw(); - - TestWin->SetVisible(ETrue); - TestWin->Win()->Invalidate(); - TestWin->Win()->BeginRedraw(); - TheGc->Activate(*TestWin->Win()); - TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - TheGc->SetDrawMode(CGraphicsContext::EDrawModePEN); - TheGc->SetBrushColor(TRgb(0, 0, 255)); - TheGc->Clear(); - TheGc->Deactivate(); - TestWin->Win()->EndRedraw(); - - TheClient->iWs.Flush(); - TheClient->iWs.Finish(); - - //load test bitmap - CFbsBitmap* bitmap = new (ELeave) CFbsBitmap; - CleanupStack::PushL(bitmap); - TInt ret = bitmap->Load(_L("Z:\\WSTEST\\TESTCIRCLES.MBM"),0); - TEST(ret == KErrNone); - TInt bitmapHandle = bitmap->Handle(); - - //send bitmap drawing to test window - TestWin->Win()->Invalidate(); - TestWin->Win()->BeginRedraw(); - TheGc->Activate(*TestWin->Win()); - TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - TheGc->SetDrawMode(CGraphicsContext::EDrawModePEN); - TheGc->SetBrushColor(TRgb(0, 255, 0)); - TheGc->Clear(); - TheGc->BitBlt(TPoint(0,0), bitmap); - TheGc->Deactivate(); - TestWin->Win()->EndRedraw(); - - CleanupStack::PopAndDestroy(bitmap); - - TheClient->iWs.Flush(); - TheClient->iWs.Finish(); - - //using a new bitmap object instance check that wserv can still duplicate test bitmap (even though - //the initial bitmap object is deleted) , since there is a window segment using it - bitmap = new (ELeave) CFbsBitmap; - CleanupStack::PushL(bitmap); - ret = bitmap->Duplicate(bitmapHandle); - TEST(ret == KErrNone); - CleanupStack::PopAndDestroy(bitmap); - - //send new drawing to test window, in order to cover the bitmap that was previously drawn - TestWin->Win()->Invalidate(); - TestWin->Win()->BeginRedraw(); - TheGc->Activate(*TestWin->Win()); - TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - TheGc->SetDrawMode(CGraphicsContext::EDrawModePEN); - TheGc->SetBrushColor(TRgb(0, 0, 255)); - TheGc->Clear(); - TheGc->Deactivate(); - TestWin->Win()->EndRedraw(); - - TheClient->iWs.Flush(); - TheClient->iWs.Finish(); - - //check that wserv can't duplicate test bitmap, since no window segment uses it any more - bitmap = new (ELeave) CFbsBitmap; - CleanupStack::PushL(bitmap); - ret = bitmap->Duplicate(bitmapHandle); - TEST(ret != KErrNone); - CleanupStack::PopAndDestroy(bitmap); - } - -void CTGc::RunTestCaseL(TInt /*aCurTestCase*/) - { - ((CTGcStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); - switch(++iTest->iState) - { - case 1: - ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0437")); - iTest->LogSubTest(_L("CRemoteGc&CWindowGc, outline and shadow text")); - TestOutlineAndShadowL(); - break; - case 2: - ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0471")); - iTest->LogSubTest(_L("Test GC clip rect and origin attributes.")); - TestGcClipRectOrigin(); - break; - case 3: - ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0469")); - iTest->LogSubTest(_L("CRemoteGc&CWindowGc, reset with background colour")); - TestResetWithBackgroundColorL(); - break; - case 4: - ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0481")); - iTest->LogSubTest(_L("CRemoteGc&CCommandBuffer, coverage tests")); - TestCommandBufferL(); - break; - case 5: - ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0482")); - iTest->LogSubTest(_L("CCommandBuffer, coverage tests")); - TestEmptyCommandBufferL(); - break; - case 6: - ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0494")); - iTest->LogSubTest(_L("CWindowGc, Brush Pattern test")); - TestGcSetBrushPatternL(); - break; - case 7: - ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0576")); - iTest->LogSubTest(_L("CWindowGc, delete bitmap 1")); - TestGcDeleteBitmap1L(); - break; - case 8: - ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0577")); - iTest->LogSubTest(_L("CWindowGc, delete bitmap 2")); - TestGcDeleteBitmap2L(); - break; -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA - case 9: - ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0471")); - iTest->LogSubTest(_L("Test GC clip rect and origin attributes.")); - TestGcClipRectOrigin(); - break; - case 10: - ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0469")); - iTest->LogSubTest(_L("CRemoteGc&CWindowGc, reset with background colour")); - TestResetWithBackgroundColorL(); - break; - case 11: - ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0486")); - iTest->LogSubTest(_L("CRemoteGc&MWsGraphicsContext, clipping rect test")); - TestCRemoteGcAndMWsGraphicsContextClippingRectL(); - break; - case 12: - ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0487")); - iTest->LogSubTest(_L("CRemoteGc, DrawTextInContext Position test")); - TestCRemoteGcDrawTextInContextPointL(); - break; - case 13: - ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0488")); - iTest->LogSubTest(_L("CRemoteGc, DrawTextInContext ClipRect test")); - TestCRemoteGcDrawTextInContextBoxL(); - break; - case 14: - ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0489")); - iTest->LogSubTest(_L("CRemoteGc, DrawTextInContext Pos Vertical test")); - TestCRemoteGcDrawTextInContextPointVerticalL(); - break; - case 15: - ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0490")); - iTest->LogSubTest(_L("CRemoteGc, DrawTextInContext ClipRect Vert test")); - TestCRemoteGcDrawTextInContextBoxVerticalL(); - break; -#endif //TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA - default: - ((CTGcStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - ((CTGcStep*)iStep)->CloseTMSGraphicsStep(); - TestComplete(); - break; - } - ((CTGcStep*)iStep)->RecordTestResultL(); - } - -__CONSTRUCT_STEP__(Gc) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/tgc.h --- a/windowing/windowserver/tauto/tgc.h Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,199 +0,0 @@ -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef __TGC_H__ -#define __TGC_H__ - -#include "AUTO.H" -#include "TGraphicsHarness.h" -#include -#include - -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA -/* - * The following classes are only required for the RemoteGc DrawText tests: . - * CDrawTextInContextTest : is the Abstract base class - * CDrawTextInContextTestPoint : Test DrawText(const TDesC&,const TTextParameters*,const TPoint&) - * CDrawTextInContextTestBox : Test DrawText(const TDesC&,const TTextParameters*,const TRect&,TInt,TTextAlign,TInt) - * CDrawTextInContextTestPointVertical : Test DrawTextVertical(const TDesC&,const TTextParameters*,const TPoint&) - * CDrawTextInContextTestBoxVertical : Test DrawTextVertical(const TDesC&,const TTextParameters*,const TRect&,TInt,TTextAlign,TInt) - */ -class CDirectGdiGcWrapper; -class CRemoteGc; -class CCommandBuffer; -class CWSGraphicsRes; -class RDirectGdiImageTarget; - -const TSize KBitmapSize(620, 240); -const TRect KBitmapRect(TPoint(0,0),TSize(620, 240)); -const TRegionFix<1> KBitmapRegion(KBitmapRect); - -//CDrawTextInContextTest -class CDrawTextInContextTest : public CBase - { -public: - void Test(); - TBool HasPassedTest(); -protected: - CDrawTextInContextTest(); - ~CDrawTextInContextTest(); - void BaseConstructL(); - virtual void DoDrawTextBitGc() = 0; - virtual void DoDrawTextRemoteGc() = 0; -protected: - CFont *iFont; - CGraphicsContext::TTextParameters iParam; - TPtrC iText; - - //For reference bitmap - CFbsBitmap* iRefBitmap; - CFbsBitmapDevice* iRefDevice; - CFbsBitGc* iRefBitGc; - - //For CDirectGdiGcWrapper - RSgImage iWrapperImage; - RDirectGdiImageTarget* iWrapperImageTarget; - RSgImageCollection iWrapperImageCollection; - CDirectGdiGcWrapper* iDirectGdiGcWrapper; - - - //For CRemoteGc - CRemoteGc* iRemoteGc; - RWsGraphicMsgBuf iMsgBuf; - CCommandBuffer* iCommandBuffer; - CWSGraphicsRes* iWsGraphicRes; - TPoint iOffset; - - //Test result - TBool iHasPassedTest; - }; - -//CDrawTextInContextTestPoint -class CDrawTextInContextTestPoint : public CDrawTextInContextTest - { -public: - static CDrawTextInContextTestPoint* NewL(); - ~CDrawTextInContextTestPoint(); - void DoDrawTextBitGc(); - void DoDrawTextRemoteGc(); -private: - CDrawTextInContextTestPoint(); - void ConstructL(); -private: - TPoint iPosition; - }; - -//CDrawTextInContextTestBox -class CDrawTextInContextTestBox : public CDrawTextInContextTest - { -public: - static CDrawTextInContextTestBox* NewL(); - ~CDrawTextInContextTestBox(); - void DoDrawTextBitGc(); - void DoDrawTextRemoteGc(); -private: - CDrawTextInContextTestBox(); - void ConstructL(); -private: - TRect iClipFillRect; - TInt iBaselineOffset; - CGraphicsContext::TTextAlign iTTextAlign; - }; - -//CDrawTextInContextTestPointVertical -class CDrawTextInContextTestPointVertical : public CDrawTextInContextTest - { -public: - static CDrawTextInContextTestPointVertical* NewL(); - ~CDrawTextInContextTestPointVertical(); - void DoDrawTextBitGc(); - void DoDrawTextRemoteGc(); -private: - CDrawTextInContextTestPointVertical(); - void ConstructL(); -private: - TPoint iPosition; - TBool iUp; - }; - -//CDrawTextInContextTestBoxVertical -class CDrawTextInContextTestBoxVertical : public CDrawTextInContextTest - { -public: - static CDrawTextInContextTestBoxVertical* NewL(); - ~CDrawTextInContextTestBoxVertical(); - void DoDrawTextBitGc(); - void DoDrawTextRemoteGc(); -private: - CDrawTextInContextTestBoxVertical(); - void ConstructL(); -private: - TRect iClipFillRect; - TInt iBaselineOffset; - TBool iUp; - CGraphicsContext::TTextAlign iTTextAlign; - }; - -#endif // TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA - -class CTGc : public CTWsGraphicsBase - { -public: - CTGc(CTestStep* aStep); - ~CTGc(); - void ConstructL(); - void TestOutlineAndShadowL(); - void TestGcClipRectOrigin(); - void TestResetWithBackgroundColorL(); - void TestCommandBufferL(); - void TestEmptyCommandBufferL(); - void TestGcSetBrushPatternL(); - void TestGcDeleteBitmap1L(); - void TestGcDeleteBitmap2L(); -#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA - void TestCRemoteGcAndMWsGraphicsContextClippingRectL(); - void TestCRemoteGcDrawTextInContextPointL(); - void TestCRemoteGcDrawTextInContextBoxL(); - void TestCRemoteGcDrawTextInContextPointVerticalL(); - void TestCRemoteGcDrawTextInContextBoxVerticalL(); -#endif - -protected: - void TestGcClipRectOrigin_DrawContent(TestWindow& aWindow, TBool bActivateBeforeRedraw = ETrue); - -//from CTWsGraphicsBase - virtual void RunTestCaseL(TInt aCurTestCase); -private: - CTestBase *iTest; - }; - -class CTGcStep : public CTGraphicsStep - { -public: - CTGcStep(); -protected: - //from CTGraphicsStep - virtual CTGraphicsBase* CreateTestL(); - }; - -_LIT(KTGcStep,"TGc"); - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/tmultiptrevent.cpp --- a/windowing/windowserver/tauto/tmultiptrevent.cpp Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,4842 +0,0 @@ -// Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Multi pointer and Z-coordinate test code -// -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef __INIPARSER_H__ -#define __INIPARSER_H__ -#endif // __INIPARSER_H__ - -#include "PARSEINIDATA.H" -#include "tmultiptrevent.h" -#include -#include - -//#define FAILLOG 1 // Uncomment this code to get detailed log -#define TESTMULTIPOINTER 1 // Comment this line to get detailed log without testing - -_LIT(KMultiPtrPluginDll, "multiptrclick.dll"); - -const TInt KErrDescSize = 128; -const TInt KMaxQueueSize = 32; // Queue size of wserv. In any test we cannot test more than MaxQueueSize events. - -LOCAL_C void DestroyAnim(TAny* aAnim) - { - (static_cast(aAnim))->Destroy(); - } - - -//CTMultiPtrEventBuffer -CTMultiPtrEventBuffer::CTMultiPtrEventBuffer(RWsSession *aWs, CTMultiPtrEventTest *aTest, CTMultiPtrEventClient* aClient) - : CTEvent(aWs), iTest(aTest), iClient(aClient) - { - } - -void CTMultiPtrEventBuffer::ConstructL() - { - CTEventBase::Construct(); - iEventBuffer.SetLengthL(EEventBufferSize); - iMovePtsBuffer.SetLengthL(EMovePtsBuffer); - } - -void CTMultiPtrEventBuffer::AddExpectedEvent(TWsEvent &aEvent) - { - iEventBuffer.Add(&aEvent); - } - -void CTMultiPtrEventBuffer::AddExpectedMovePtEvent(TPoint &aMovePt) - { - iMovePtsBuffer.Add(&aMovePt); - } - -TInt CTMultiPtrEventBuffer::EventsRemaining() - { - return iEventBuffer.Count(); - } - -void CTMultiPtrEventBuffer::GetMoveBufferAndCompareL() - { - TBuf8 buf; - iClient->ParentWin()->BaseWin()->RetrievePointerMoveBuffer(buf); - - TUint bufferSize = buf.Length(); - TUint numLoop = bufferSize/sizeof(TPoint); - - if (iMovePtsBuffer.Count() != numLoop) - { -#if defined(FAILLOG) - TLogMessageText logText; - _LIT(KPointerNumber, "Actual number of move/drag buffer points from Wserv = %d Expected number of move/drag buffer points = %d "); - logText.Format(KPointerNumber, numLoop, iMovePtsBuffer.Count()); - iTest->LOG_MESSAGE(logText); -#endif - TestL(EFalse); - } - - TPoint wsPoint; - TPoint expPoint; - TUint8* BasePtr = const_cast(buf.Ptr()); - for (TUint count = 0; count < numLoop; count++) - { - wsPoint = *(reinterpret_cast(BasePtr)); - iMovePtsBuffer.Remove(&expPoint); - if (wsPoint != expPoint) - { -#if defined(FAILLOG) - TLogMessageText logText; - _LIT(KMoveBufferPoint, "Actual move/drag buffer point from Wserv = ([%d], [%d]) Expected move/drag buffer point = ([%d], [%d])"); - logText.Format(KMoveBufferPoint, wsPoint.iX, wsPoint.iY, expPoint.iX, expPoint.iY); - iTest->LOG_MESSAGE(logText); -#endif - TestL(EFalse); - } - BasePtr = BasePtr + sizeof(TPoint); - } - } - - -#define TESTXL(expr1, oper, expr2, event, expected) \ - TestL(expr1 oper expr2, expr1, expr2, #oper, #expr1 ## #oper ## #expr2, \ - event, expected, __FILE__, __LINE__); - -// Main function which gets the event, checks with the event in buffer -// Then calls function NextSetOfEventsL for running other tests of a particualar test case -void CTMultiPtrEventBuffer::doRunL() - { - // Get the event from wserv - TWsEvent wsEvent; - iWs->GetEvent(wsEvent); - - TWsEvent expectedEvent; - TInt wsType=wsEvent.Type(); - if (wsEvent.Type()==EEventNull) - { - TESTXL(wsEvent.Handle(), ==, 0, &wsEvent, NULL); - goto End; - } - // This code is for running successive anim test code - if (wsEvent.Type()==EEventPointer && wsEvent.Pointer()->iType==TPointerEvent::ESwitchOn) - goto End; - // if this is called accidentally - if (iEventBuffer.Count()==0 && wsType==EEventFocusGained) - goto End; - - iEventBuffer.Remove(&expectedEvent); - iEventCount++; - - if (wsEvent.Type() == EEventPointerBufferReady) - { - GetMoveBufferAndCompareL(); -#if defined(FAILLOG) - TLogMessageText logText; - _LIT(KEventHandle, "Actual Window Handle from Wserv = %d Expected Window Handle = %d "); - logText.Format(KEventHandle, wsEvent.Handle(), expectedEvent.Handle()); - iTest->LOG_MESSAGE(logText); -#endif -#if defined(TESTMULTIPOINTER) - TESTXL(wsEvent.Handle(), ==, expectedEvent.Handle(), &wsEvent, &expectedEvent); -#endif - goto End; - } - - // Test wsEvent and expected event have same handle, position and type. -#if defined(FAILLOG) - { - TLogMessageText logText; - _LIT(KEventCountCheck, "Checking event number = %d"); - logText.Format(KEventCountCheck, iEventCount); - iTest->LOG_MESSAGE(logText); - _LIT(KEventType, "Actual Event type from Wserv = %d Expected Event Type = %d "); - logText.Format(KEventType, wsEvent.Type(), expectedEvent.Type()); - iTest->LOG_MESSAGE(logText); - } -#endif - -#if defined(TESTMULTIPOINTER) - TESTXL(wsEvent.Type(), ==, expectedEvent.Type(), &wsEvent, &expectedEvent); -#endif - // Test pointer number for Enter/Exit events - if (wsType == EEventPointerEnter || wsType == EEventPointerExit) - { -#if defined(FAILLOG) - TLogMessageText logText; - _LIT(KPointerNumber, "Actual PointerNumber for Enter/Exit event from Wserv = %d Expected PointerNumber for Enter/Exit event = %d "); - logText.Format(KPointerNumber, *wsEvent.Int(), *expectedEvent.Int()); - iTest->LOG_MESSAGE(logText); -#endif -#if defined(TESTMULTIPOINTER) - TESTXL(*wsEvent.Int(), ==, *expectedEvent.Int(), &wsEvent, &expectedEvent); -#endif - } - - // Test only if it is a Pointer event - if (wsType==EEventPointer) - { - TAdvancedPointerEvent* expectedPointerEvent=expectedEvent.Pointer(); - TAdvancedPointerEvent* actualPointerEvent=wsEvent.Pointer(); -#if defined(FAILLOG) - TLogMessageText logText; - _LIT(KEventHandle, "Actual Window Handle from Wserv = %d Expected Window Handle = %d "); - logText.Format(KEventHandle, wsEvent.Handle(), expectedEvent.Handle()); - iTest->LOG_MESSAGE(logText); -#endif -#if defined(TESTMULTIPOINTER) - TESTXL(wsEvent.Handle(), ==, expectedEvent.Handle(), &wsEvent, &expectedEvent); -#endif -#if defined(FAILLOG) - _LIT(KPointerType, "Actual PointerType from Wserv = %d Expected PointerType = %d "); - logText.Format(KPointerType, actualPointerEvent->iType, expectedPointerEvent->iType); - iTest->LOG_MESSAGE(logText); -#endif -#if defined(TESTMULTIPOINTER) - TESTXL(actualPointerEvent->iType, ==, expectedPointerEvent->iType, &wsEvent, &expectedEvent); -#endif -#if defined(FAILLOG) - _LIT(KPointerPosition, "Actual PointerPosition from Wserv = (%d, %d) Expected PointerPosition = (%d, %d) "); - logText.Format(KPointerPosition, actualPointerEvent->iPosition.iX, actualPointerEvent->iPosition.iY, expectedPointerEvent->iPosition.iX, expectedPointerEvent->iPosition.iY); - iTest->LOG_MESSAGE(logText); -#endif -#if defined(TESTMULTIPOINTER) - TESTXL(actualPointerEvent->iPosition, ==, expectedPointerEvent->iPosition, &wsEvent, &expectedEvent); -#endif -#if defined(FAILLOG) - _LIT(KPointerNumber, "Actual PointerNumber from Wserv = %d Expected PointerNumber = %d "); - logText.Format(KPointerNumber, actualPointerEvent->PointerNumber(), expectedPointerEvent->PointerNumber()); - iTest->LOG_MESSAGE(logText); -#endif -#if defined(TESTMULTIPOINTER) - TESTXL(actualPointerEvent->PointerNumber(), ==, expectedPointerEvent->PointerNumber(), &wsEvent, &expectedEvent); -#endif -#if defined(FAILLOG) - _LIT(KPointerProximity, "Actual PointerProximity from Wserv = %d Expected PointerProximity = %d "); - logText.Format(KPointerProximity, actualPointerEvent->Proximity(), expectedPointerEvent->Proximity()); - iTest->LOG_MESSAGE(logText); -#endif -#if defined(TESTMULTIPOINTER) - TESTXL(actualPointerEvent->Proximity(), ==, expectedPointerEvent->Proximity(), &wsEvent, &expectedEvent); -#endif -#if defined(FAILLOG) - _LIT(KPointerPressure, "Actual PointerPressure from Wserv = %d Expected PointerPressure = %d "); - logText.Format(KPointerPressure, actualPointerEvent->Pressure(), expectedPointerEvent->Pressure()); - iTest->LOG_MESSAGE(logText); -#endif -#if defined(TESTMULTIPOINTER) - TESTXL(actualPointerEvent->Pressure(), ==, expectedPointerEvent->Pressure(), &wsEvent, &expectedEvent); -#endif -#if defined(FAILLOG) - _LIT(KPointerModifier, "Actual Modifier value from Wserv = 0x%08x Expected Modfier value = 0x%08x "); - logText.Format(KPointerModifier, actualPointerEvent->iModifiers, expectedPointerEvent->iModifiers); - iTest->LOG_MESSAGE(logText); -#endif -#if defined(TESTMULTIPOINTER) - TESTXL((actualPointerEvent->iModifiers&expectedPointerEvent->iModifiers), ==, expectedPointerEvent->iModifiers, &wsEvent, &expectedEvent); -#endif - } -End: - // Call NextSetOfEvents() only for primary client - if (iEventBuffer.Count()==0 && !iClient->IsSecondaryClient()) - { - iTest->NextSetOfEventsL(); // Cannot Leave - } - - // If this is for secondary client and active scheduler(nested loop) has started, this code stops that scheduler - if (iEventBuffer.Count()==0 && iClient->IsSecondaryClient() && iNestedLoopStarted) - { - iNestedLoopStarted = EFalse; - CActiveScheduler::Stop(); - } - } - -void CTMultiPtrEventBuffer::TestL(TInt aTest) - { - if (!aTest) - { - iTest->Failed(); - User::Leave(ETestFailed); - } - } - -static void DumpEvent(const char *aName, const TWsEvent *aEvent) - { - // aEvent may be NULL - if it isn't NULL, we print it's data. - if (aEvent) - { - RDebug::Printf("%s:", aName); - RDebug::Printf("handle = %u", aEvent->Handle()); - RDebug::Printf("type() = %d", aEvent->Type()); - if (aEvent->Type() == EEventPointer) - { - TAdvancedPointerEvent *pointer = aEvent->Pointer(); - RDebug::Printf("pointer type = %d, position = (%d, %d)", - pointer->iType, pointer->iPosition.iX, pointer->iPosition.iY); - RDebug::Printf("PointerNumber() = %d, proximity=%d, pressure=%d", - pointer->PointerNumber(), pointer->Proximity(), pointer->Pressure()); - RDebug::Printf("modifiers = 0x%08x", pointer->iModifiers); - } - else - { - RDebug::Printf("Not a pointer event, event type"); - } - } - else - { - // aEvent is NULL, just let us know it is. - RDebug::Printf("%s: is NULL which means not applicapable"); - } - } - -void CTMultiPtrEventBuffer::TestL(TInt aTest, TInt aVal1, TInt aVal2, const char *aOper, const char *aTestStr, - const TWsEvent *aEvent, const TWsEvent *aExpected, const char *aFile, TUint aLine) - { - if (!aTest) - { - RDebug::Printf("Expression %d %s %d [%s] (=%d) failed [call from %s:%d]", aVal1, aOper, aVal2, aTestStr, aTest, aFile, aLine); - DumpEvent("actual", aEvent); - DumpEvent("expected", aExpected); - iTest->Failed(); - User::Leave(ETestFailed); - } - } - - -void CTMultiPtrEventBuffer::TestL(TInt aTest, TPoint aVal1, TPoint aVal2, const char *oper, const char *aTestStr, - const TWsEvent *aEvent, const TWsEvent *aExpected, const char *aFile, TUint aLine) - { - if (!aTest) - { - RDebug::Printf("Expression (%d, %d) %s (%d, %d) [%s] (=%d) failed [call from %s:%d]", - aVal1.iX, aVal1.iY, oper, aVal2.iX, aVal2.iY, aTestStr, aTest, aFile, aLine); - DumpEvent("actual", aEvent); - DumpEvent("expected", aExpected); - iTest->Failed(); - User::Leave(ETestFailed); - } - } - -//CTMultiPtrEventClient -CTMultiPtrEventClient::CTMultiPtrEventClient(CTMultiPtrEventTest *aTest, TBool aSecondaryClient) - : iTest(aTest), iSecondaryClient(aSecondaryClient) - { - } - -CTMultiPtrEventClient::~CTMultiPtrEventClient() - { - if (iWinAutoFocus1 || iWinAutoFocus2 || iGroupWinAutoFocus2 || iGroupWinAutoFocus1) - { - DeleteGroupBlankWin(); - } - delete iChildWin; - delete iParentWin; - } - -void CTMultiPtrEventClient::ConstructL() - { - CTClient::ConstructL(); - - // Create a group window and assign it iGroup - iGroup = new(ELeave) CTWindowGroup(this); - iGroup->ConstructL(); - - iParentWinSize = iScreen->SizeInPixels(); - iParentWinPos = TPoint(); - - // Change the parent window size and position for secondary client - if (iSecondaryClient) - { - iParentWinSize.iWidth /= 2; - iParentWinPos.iX = iParentWinSize.iWidth; - } - - // Create window/s for this client so that events can come to this client - iParentWin=new(ELeave) CTBlankWindow(); - iParentWin->ConstructL(*iGroup); - iParentWin->SetExt(iParentWinPos, iParentWinSize); - iParentWin->SetColor(KRgbRed); - if (iTest->TestBase()->iState != 12) - { - iParentWin->BaseWin()->EnableAdvancedPointers(); - } - iParentWin->Activate(); - - // Don't create child window for secodary client - if (!iSecondaryClient) - { - iChildWinSize = TSize(iParentWinSize.iWidth/2, iParentWinSize.iHeight); - iChildWinPos = TPoint(iParentWinSize.iWidth/2,0); - - iChildWin=new(ELeave) CTBlankWindow(); - iChildWin->ConstructL(*iGroup); - iChildWin->SetExt(iChildWinPos, iChildWinSize); - iChildWin->SetColor(KRgbRed); - iChildWin->BaseWin()->EnableAdvancedPointers(); - iChildWin->Activate(); - } - } - -void CTMultiPtrEventClient::CalculatePtrPosAndSet3Ddata(TWsEvent& aEvent, TPointerEvent::TType aType, TPoint aPos, TUint aModifiers, TInt aZ, TUint8 aPointerNumber, TUint aHandle) - { - // If in future you need to change parent position then put this in corresponding if statements - aEvent.Pointer()->iParentPosition = aPos; - - // This is for Auto foreground test - if (iTest->TestBase()->iState == 11) - { - if (TRect(iWinPosAutoFocus1, iWinSizeAutoFocus1).Contains(aPos)) - { - aPos -= iWinPosAutoFocus1; - aEvent.SetHandle((TUint)iWinAutoFocus1); - } - else if (TRect(iWinPosAutoFocus2, iWinSizeAutoFocus2).Contains(aPos)) - { - aPos -= iWinPosAutoFocus2; - aEvent.SetHandle((TUint)iWinAutoFocus2); - } - goto SETOTHERDATA; - } - - // Here simulated pointer position is w.r.t to 0,0 - // Actual pointer position is w.r.t windowPosition - if (iSecondaryClient) - { - if (TRect(iParentWinPos, TSize(iParentWinSize.iWidth, iParentWinSize.iHeight)).Contains(aPos)) - { - // Since for secondary client parent window is at half of screensize - aPos -= iParentWinPos; - aEvent.SetHandle((aHandle == 0) ? (TUint)iParentWin : aHandle); - } - } - else - { - // If sent position is on blankWindow then - if (TRect(iParentWinPos, TSize(iParentWinSize.iWidth/2, iParentWinSize.iHeight)).Contains(aPos)) - { - aEvent.SetHandle((aHandle == 0) ? (TUint)iParentWin : aHandle); - } - else // else the pointer event occured on child window - { - // if aPos < 0 then position has been generated in test code and should not be adjusted - if (aPos.iX >= 0) - { - aPos -= iChildWinPos; - } - aEvent.SetHandle((aHandle == 0) ? (TUint)iChildWin : aHandle); - } - } - -SETOTHERDATA: - aEvent.Pointer()->iType = aType; - aEvent.Pointer()->iPosition = aPos; - if(iExpectNonAdvancedPointerEvents) - { - aEvent.Pointer()->iModifiers = aModifiers; - } - else - { - aEvent.Pointer()->iModifiers = aModifiers|EModifierAdvancedPointerEvent; - aEvent.SetPointerNumber(aPointerNumber); - aEvent.SetPointerZ(aZ); - } - } - -void CTMultiPtrEventClient::AddExpectedPointerEvent(TPointerEvent::TType aType, TPoint aPos, TUint8 aPointerNumber, TUint aHandle) - { - AddExpectedPointerEvent(aType, aPos, 0, 0, aPointerNumber, aHandle); - } - -void CTMultiPtrEventClient::AddExpectedPointerEvent(TPointerEvent::TType aType, TPoint aPos, TInt aZ, TUint aModifier, TUint8 aPointerNumber, TUint aHandle) - { - TWsEvent ptrEvent; - ptrEvent.SetType(EEventPointer); - if (aType != TPointerEvent::ESwitchOn) - { - CalculatePtrPosAndSet3Ddata(ptrEvent, aType, aPos, aModifier, aZ, aPointerNumber, aHandle); - } - static_cast(iEventHandler)->AddExpectedEvent(ptrEvent); - } - -void CTMultiPtrEventClient::AddExpectedWsEvent(TEventCode aType, TInt aPointerNumber, TUint aHandle) - { - TWsEvent ptrEvent; - ptrEvent.SetType(aType); - if (aType == EEventPointerEnter || aType == EEventPointerExit) - { - *ptrEvent.Int() = aPointerNumber; - } - if (aType == EEventPointerBufferReady) - { - ptrEvent.SetHandle(aHandle); - } - static_cast(iEventHandler)->AddExpectedEvent(ptrEvent); - } - -void CTMultiPtrEventClient::AddExpectedMovePoint(TPoint aPos) - { - static_cast(iEventHandler)->AddExpectedMovePtEvent(aPos); - } - -// Create and store CTMultiPtrEventBuffer in iEventHandler -void CTMultiPtrEventClient::ConstructEventHandlerL() - { - CTMultiPtrEventBuffer* eventBufferAndHandler = new(ELeave) CTMultiPtrEventBuffer(&iWs, iTest, this); - eventBufferAndHandler->ConstructL(); - iEventHandler = eventBufferAndHandler; - } - -// Create groupwindow and blank window for AutoFocus tests -void CTMultiPtrEventClient::ConstructGroupBlankWinL() - { - iWinPosAutoFocus1 = TPoint(10,10); - iWinSizeAutoFocus1 = TSize(40,40); - - iWinPosAutoFocus2 = TPoint(50,50); - iWinSizeAutoFocus2 = TSize(80,80); - - iGroupWinAutoFocus1 = new(ELeave) CTWindowGroup(this); - iGroupWinAutoFocus1->ConstructL(); - iGroupWinAutoFocus1->GroupWin()->AutoForeground(ETrue); - iGroupWinAutoFocus1->GroupWin()->EnableFocusChangeEvents(); - - iGroupWinAutoFocus2 = new(ELeave) CTWindowGroup(this); - iGroupWinAutoFocus2->ConstructL(); - iGroupWinAutoFocus2->GroupWin()->AutoForeground(ETrue); - iGroupWinAutoFocus2->GroupWin()->EnableFocusChangeEvents(); - - iWinAutoFocus1=new(ELeave) CTBlankWindow(); - iWinAutoFocus1->ConstructL(*iGroupWinAutoFocus1); - iWinAutoFocus1->SetExt(iWinPosAutoFocus1, iWinSizeAutoFocus1); - iWinAutoFocus1->SetColor(KRgbDarkYellow); - iWinAutoFocus1->BaseWin()->EnableAdvancedPointers(); - iWinAutoFocus1->Activate(); - - iWinAutoFocus2=new(ELeave) CTBlankWindow(); - iWinAutoFocus2->ConstructL(*iGroupWinAutoFocus2); - iWinAutoFocus2->SetExt(iWinPosAutoFocus2, iWinSizeAutoFocus2); - iWinAutoFocus2->SetColor(KRgbDarkCyan); - iWinAutoFocus2->BaseWin()->EnableAdvancedPointers(); - iWinAutoFocus2->Activate(); - } - -void CTMultiPtrEventClient::DeleteGroupBlankWin() - { - delete iWinAutoFocus2; - iWinAutoFocus2 = NULL; - delete iGroupWinAutoFocus2; - iGroupWinAutoFocus2 = NULL; - delete iWinAutoFocus1; - iWinAutoFocus1 = NULL; - delete iGroupWinAutoFocus1; - iGroupWinAutoFocus1 = NULL; - } - -TBool CTMultiPtrEventClient::CheckOrdinalPosition(TInt aAutoFocusWin) - { - if (aAutoFocusWin == 1) - { - return iWinAutoFocus1->BaseWin()->OrdinalPosition() == 0; - } - else - { - return iWinAutoFocus2->BaseWin()->OrdinalPosition() == 0; - } - } - -//CTMultiPtrEventTest -CTMultiPtrEventTest::CTMultiPtrEventTest(CTestStep* aStep) - : CTWsGraphicsBase(aStep) - { - } - -CTMultiPtrEventTest::~CTMultiPtrEventTest() - { - ((CTMultiPtrEventTestStep*)iStep)->CloseTMSGraphicsStep(); - delete iMultiPtrEventClient; - DestroyAnimDllAndAnim(); - if (iPtrPluginLoaded) - { - iClick.Unload(); - } - iClick.Close(); - if (iHeap) - { - iHeap->Close(); - iChunk.Close(); - } - DeleteGroupWin(); - } - -void CTMultiPtrEventTest::ConstructL() - { - // Here check if the HAL configuration are correct if not then finish the test case - TInt ret = HAL::Get(HALData::EPointerMaxPointers, iMaxDevPointers); - if (ret != KErrNone || iMaxDevPointers < 2 || iMaxDevPointers > 8) - { - TLogMessageText logText1; - _LIT(KWrongHALConfig, "HAL configuration are incorrect. \n"); - logText1.Append(KWrongHALConfig); - LOG_MESSAGE(logText1); - TEST(EFalse); - User::Leave(ret); - } - - // Get the data by using HAL api - User::LeaveIfError(HAL::Get(HALData::EPointerMaxPointers,iMaxDevPointers)); - User::LeaveIfError(HAL::Get(HALData::EPointerNumberOfPointers,iMaxUiPointers)); - User::LeaveIfError(HAL::Get(HALData::EPointer3DMaxPressure, iMaxPressure)); - User::LeaveIfError(HAL::Get(HALData::EPointer3DPressureStep, iPressureStep)); - User::LeaveIfError(HAL::Get(HALData::EPointer3DMaxProximity, iMaxProximity)); - User::LeaveIfError(HAL::Get(HALData::EPointer3DProximityStep, iProximityStep)); - - _LIT(KWsIniFile, "z:\\system\\data\\wsini.ini"); - CIniData* iniData = CIniData::NewL(KWsIniFile, ' '); - _LIT( KWsiniYShifting, "YSHIFTING"); - iniData->FindVar(KWsiniYShifting, iYOffset); - delete iniData; - TheClient->iScreen->SetAppScreenMode(0); - TheClient->iScreen->SetScreenMode(0); - iPhysicalScreenSize = TheClient->iScreen->SizeInPixels(); - - TheGc->Activate(*BaseWin->Win()); - TheGc->SetBrushColor(TRgb::Gray16(12)); - TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - TheGc->SetPenStyle(CGraphicsContext::ENullPen); - TheGc->DrawRect(TRect(BaseWin->Win()->Size())); - TheGc->Deactivate(); - - TheGc->Activate(*TestWin->Win()); - TheGc->SetBrushColor(TRgb::Gray16(4)); - TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - TheGc->SetPenStyle(CGraphicsContext::ENullPen); - TheGc->DrawRect(TRect(TestWin->Win()->Size())); - TheGc->Deactivate(); - - TheClient->iWs.Flush(); - } - -// Create raw event setting type, X, Y, Z and pointernumber for rawevent -// use UserSvr for simulating the event -void CTMultiPtrEventTest::SimulatePointerEvent(TRawEvent::TType aType, TInt aX, TInt aY, TUint8 aPointerNumber) - { - TRawEvent rawEvent; - rawEvent.Set(aType, aX, aY+iYOffset, aPointerNumber); - UserSvr::AddEvent(rawEvent); - } - -void CTMultiPtrEventTest::SimulatePointerEvent(TRawEvent::TType aType, TInt aX, TInt aY, TInt aZ, TUint8 aPointerNumber) - { - TRawEvent rawEvent; - rawEvent.Set(aType, aX, aY+iYOffset, aZ, aPointerNumber); - UserSvr::AddEvent(rawEvent); - } - -// Simulate multipointer down and up event -void CTMultiPtrEventTest::SimulatePointerDownUp(TInt aX, TInt aY, TInt aZ, TUint8 aPointerNumber) - { - SimulatePointerEvent(TRawEvent::EButton1Down, aX, aY, aZ, aPointerNumber); - SimulatePointerEvent(TRawEvent::EButton1Up, aX, aY, aZ, aPointerNumber); - } - -void CTMultiPtrEventTest::AddExpectedKey(TInt aEventCode, TInt aScanCode, TInt aCode/*=0*/, TInt aRepeats/*=0*/, TUint aModifiers/*=0*/) - { - TPckgBuf evtPkg; - TWsEvent& event=evtPkg(); - if (aEventCode==EEventKey && aCode==0) - aCode=aScanCode; - event.SetType(aEventCode); - event.SetHandle((TUint)iMultiPtrEventClient->iGroup); - event.Key()->iCode=aCode; - event.Key()->iScanCode=aScanCode; - event.Key()->iModifiers=aModifiers; - event.Key()->iRepeats=aRepeats; - iMultiPtrEventClient->EventBuffer()->AddExpectedEvent(event); - } - -void CTMultiPtrEventTest::AddExpectedKeyDownUp(TInt aScanCode, TInt aCode/*=0*/, TInt aRepeats/*=0*/, TUint aModifiers/*=0*/) - { - __ASSERT_DEBUG(aScanCode<'a' || aScanCode>'z',AutoPanic(EAutoPanicScanCapital)); - AddExpectedKey(EEventKeyDown,aScanCode,0,aRepeats,aModifiers); - AddExpectedKey(EEventKey,aScanCode,aCode,aRepeats,aModifiers); - AddExpectedKey(EEventKeyUp,aScanCode,0,aRepeats,aModifiers); - } - -void CTMultiPtrEventTest::AddExpectedPointerEvent(TPointerEvent::TType aType, TPoint aPos, TUint8 aPointerNumber, TUint aHandle) - { - AddExpectedPointerEvent(aType, aPos, 0, 0, aPointerNumber, aHandle); - } - -void CTMultiPtrEventTest::AddExpectedPointerEvent(TPointerEvent::TType aType, TPoint aPos, TInt aZ, TUint aModifier, TUint8 aPointerNumber, TUint aHandle, TBool aSecondaryClient) - { - if (aSecondaryClient) - { - iSecMultiPtrEventClient->AddExpectedPointerEvent(aType, aPos, aZ, aModifier, aPointerNumber, aHandle); - } - else - { - iMultiPtrEventClient->AddExpectedPointerEvent(aType, aPos, aZ, aModifier, aPointerNumber, aHandle); - } - } - -void CTMultiPtrEventTest::SetExpectNonAdvancedPointerEvents(TBool aSecondaryClient) - { - if (aSecondaryClient) - { - iSecMultiPtrEventClient->SetExpectNonAdvancedPointerEvents(); - } - else - { - iMultiPtrEventClient->SetExpectNonAdvancedPointerEvents(); - } - } - -void CTMultiPtrEventTest::ClearExpectNonAdvancedPointerEvents(TBool aSecondaryClient) - { - if (aSecondaryClient) - { - iSecMultiPtrEventClient->ClearExpectNonAdvancedPointerEvents(); - } - else - { - iMultiPtrEventClient->ClearExpectNonAdvancedPointerEvents(); - } - } - -void CTMultiPtrEventTest::AddExpectedPointerDownUp(TPoint aPos, TInt aZ, TUint8 aPointerNumber) - { - AddExpectedPointerEvent(TPointerEvent::EButton1Down, aPos, aZ, 0, aPointerNumber); - AddExpectedPointerEvent(TPointerEvent::EButton1Up, aPos, aZ, 0, aPointerNumber); - } - -void CTMultiPtrEventTest::AddExpectedWsEvent(TEventCode aType, TBool aSecondaryClient, TInt aPointerNumber, TUint aHandle) - { - if (aSecondaryClient) - { - iSecMultiPtrEventClient->AddExpectedWsEvent(aType); - } - else - { - iMultiPtrEventClient->AddExpectedWsEvent(aType, aPointerNumber, aHandle); - } - } - -void CTMultiPtrEventTest::TestDragForMultiPointer(TPoint aPtrPos, TInt aPrValue, TUint8 aPointerNumber) - { - SimulatePointerEvent(TRawEvent::EButton1Down, aPtrPos.iX, aPtrPos.iY, aPrValue, aPointerNumber); - SimulatePointerEvent(TRawEvent::EPointerMove, aPtrPos.iX+2, aPtrPos.iY+1, aPrValue, aPointerNumber); - SimulatePointerEvent(TRawEvent::EButton1Up, aPtrPos.iX+2, aPtrPos.iY+1, 0, aPointerNumber); - AddExpectedPointerEvent(TPointerEvent::EButton1Down, aPtrPos, aPrValue, 0, aPointerNumber); - aPtrPos.iX += 2; aPtrPos.iY += 1; - AddExpectedPointerEvent(TPointerEvent::EDrag, aPtrPos, aPrValue, 0, aPointerNumber); - AddExpectedPointerEvent(TPointerEvent::EButton1Up, aPtrPos, 0, 0, aPointerNumber); - } - -void CTMultiPtrEventTest::SimulateAndAddLoneUpEvents(TInt aNumSimulation, TInt aNumAddition, TPoint aPos) - { - for (TInt count = 0; count < aNumSimulation; count++) - { - SimulatePointerEvent(TRawEvent::EButton1Up, aPos.iX, aPos.iY, 0, 0); - } - for (TInt count = 0; count < aNumAddition; count++) - { - AddExpectedPointerEvent(TPointerEvent::EButton1Up, aPos, 0, 0, 0); - } - } - -void CTMultiPtrEventTest::TestFilteringForMultiPointer(TBool aFiltering) - { - TPoint ptrPos; - TInt ptrNum; - TInt xInc = iPhysicalScreenSize.iWidth/iMaxDevPointers; - TInt yInc = iPhysicalScreenSize.iHeight/iMaxDevPointers; - - for (ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) - { - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, 0, ptrNum); - SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum); - if(!aFiltering) - { - AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, ptrNum); - } - AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, ptrNum); - ptrPos.iX += xInc/2; - ptrPos.iY += yInc/2; - } - - ptrPos.SetXY(0,0); - TPoint interPt = ptrPos; - for (ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) - { - SimulatePointerEvent(TRawEvent::EPointerMove, interPt.iX+2, interPt.iY+1, 0, ptrNum); - SimulatePointerEvent(TRawEvent::EPointerMove, interPt.iX+4, interPt.iY+2, 0, ptrNum); - SimulatePointerEvent(TRawEvent::EPointerMove, interPt.iX+6, interPt.iY+3, 0, ptrNum); - if(!aFiltering) - { - interPt.iX += 6; interPt.iY += 3; - AddExpectedPointerEvent(TPointerEvent::EDrag, interPt, ptrNum); - } - ptrPos.iX += xInc/2; - ptrPos.iY += yInc/2; - interPt = ptrPos; - } - - ptrPos.SetXY(0,0); - interPt = ptrPos; - for (ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) - { - interPt.iX += 6; - interPt.iY += 3; - SimulatePointerEvent(TRawEvent::EButton1Up, interPt.iX, interPt.iY, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EButton1Up, interPt, ptrNum); - ptrPos.iX += xInc/2; - ptrPos.iY += yInc/2; - interPt = ptrPos; - } - } - -void CTMultiPtrEventTest::TestGrabbingForMultiPointer(TBool aGrabbing) - { - TPoint ptrPos; - TInt ptrNum; - TInt xInc = iPhysicalScreenSize.iWidth/iMaxDevPointers; - TInt yInc = iPhysicalScreenSize.iHeight/iMaxDevPointers; - - for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) - { - SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, ptrNum); - ptrPos.iX += xInc/3; // Ensure all Button1Down events are on iParentWin - ptrPos.iY += yInc/3; - } - - ptrPos.SetXY(0,0); - ptrPos.iX += iPhysicalScreenSize.iWidth/2; // Ensure all Drag and Button1Up events are on iChildWin - ptrPos.iY += iPhysicalScreenSize.iHeight/2; - for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) - { - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, 0, ptrNum); - if(aGrabbing) - { - // CalculatePtrPosAndSet3Ddata will subtract iChildWinPos from ptrPos if pointer event occured on child window. Thus we add iChildWinPos here. - AddExpectedPointerEvent(TPointerEvent::EDrag, ptrPos+iMultiPtrEventClient->ChildWin()->Position(), ptrNum, (TUint)iMultiPtrEventClient->ParentWin()); - } - else - { - AddExpectedPointerEvent(TPointerEvent::EDrag, ptrPos, ptrNum); - } - ptrPos.iX += xInc/3; - ptrPos.iY += yInc/3; - } - - ptrPos.SetXY(0,0); - ptrPos.iX += iPhysicalScreenSize.iWidth/2; - ptrPos.iY += iPhysicalScreenSize.iHeight/2; - for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) - { - SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, ptrNum); - if(aGrabbing) - { - AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos+iMultiPtrEventClient->ChildWin()->Position(), ptrNum, (TUint)iMultiPtrEventClient->ParentWin()); - } - else - { - AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, ptrNum); - } - ptrPos.iX += xInc/3; - ptrPos.iY += yInc/3; - } - } - -void CTMultiPtrEventTest::TestCapturingForMultiPointer(TBool aAllWinGroups) - { - TPoint ptrPos; - TInt ptrNum = 0; - TInt xInc = iPhysicalScreenSize.iWidth/iMaxDevPointers; - TInt yInc = iPhysicalScreenSize.iHeight/iMaxDevPointers; - - // These are some typical values which are used only for testing purposes. - // 20mm to screen - // 50mm to screen - // 4N of pressure - // 2N of pressure - SetThresholdValues(-20,-50,4000,2000); - - iMultiPtrEventClient->ChildWin()->BaseWin()->PointerFilter(EPointerMoveEvents, 0); - - if(!aAllWinGroups) - { - for (ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) - { - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, -30, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos-iMultiPtrEventClient->ChildWin()->Position(), -30, 0, ptrNum, (TInt)iMultiPtrEventClient->ChildWin()); - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, -10, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EEnterCloseProximity, ptrPos-iMultiPtrEventClient->ChildWin()->Position(), -10, 0, ptrNum, (TInt)iMultiPtrEventClient->ChildWin()); - SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos-iMultiPtrEventClient->ChildWin()->Position(), 0, 0, ptrNum, (TInt)iMultiPtrEventClient->ChildWin()); - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX+=2, ptrPos.iY+=2, 5000, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EEnterHighPressure, ptrPos-iMultiPtrEventClient->ChildWin()->Position(), 5000, 0, ptrNum, (TInt)iMultiPtrEventClient->ChildWin()); - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX-=2, ptrPos.iY-=2, 1000, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EExitHighPressure, ptrPos-iMultiPtrEventClient->ChildWin()->Position(), 1000, 0, ptrNum, (TInt)iMultiPtrEventClient->ChildWin()); - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX+=2, ptrPos.iY+=2, 1000, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EDrag, ptrPos-iMultiPtrEventClient->ChildWin()->Position(), 1000, 0, ptrNum, (TInt)iMultiPtrEventClient->ChildWin()); - SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos-iMultiPtrEventClient->ChildWin()->Position(), 0, 0, ptrNum, (TInt)iMultiPtrEventClient->ChildWin()); - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX-=2, ptrPos.iY-=2, -60, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EExitCloseProximity, ptrPos-iMultiPtrEventClient->ChildWin()->Position(), -60, 0, ptrNum, (TInt)iMultiPtrEventClient->ChildWin()); - ptrPos.iX += xInc/3; // Ensure all Pointer events are on iParentWin - ptrPos.iY += yInc/3; - } - } - else - { - ptrPos.iX = iPhysicalScreenSize.iWidth/2 + xInc/3; - ptrPos.iY = 0; - - for (ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) - { - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, -10, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EEnterCloseProximity, TPoint(ptrPos.iX+iPhysicalScreenSize.iWidth/2, ptrPos.iY), -10, 0, ptrNum, (TInt)iWinForCapturing); - SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EButton1Down, TPoint(ptrPos.iX+iPhysicalScreenSize.iWidth/2, ptrPos.iY), 0, 0, ptrNum, (TInt)iWinForCapturing); - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX+=2, ptrPos.iY+=2, 5000, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EEnterHighPressure, TPoint(ptrPos.iX+iPhysicalScreenSize.iWidth/2, ptrPos.iY), 5000, 0, ptrNum, (TInt)iWinForCapturing); - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX-=2, ptrPos.iY-=2, 1000, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EExitHighPressure, TPoint(ptrPos.iX+iPhysicalScreenSize.iWidth/2, ptrPos.iY), 1000, 0, ptrNum, (TInt)iWinForCapturing); - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX+=2, ptrPos.iY+=2, 1000, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EDrag, TPoint(ptrPos.iX+iPhysicalScreenSize.iWidth/2, ptrPos.iY), 1000, 0, ptrNum, (TInt)iWinForCapturing); - SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EButton1Up, TPoint(ptrPos.iX+iPhysicalScreenSize.iWidth/2, ptrPos.iY), 0, 0, ptrNum, (TInt)iWinForCapturing); - SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EOutOfRange, TPoint(ptrPos.iX+iPhysicalScreenSize.iWidth/2, ptrPos.iY), 0, 0, ptrNum, (TInt)iWinForCapturing); - ptrPos.iX += xInc/3; - ptrPos.iY += yInc/3; - } - } - } - -void CTMultiPtrEventTest::SetAutoFlush() - { - iTheClientFlush = TheClient->iWs.SetAutoFlush(ETrue); - iClientFlush = iMultiPtrEventClient->iWs.SetAutoFlush(ETrue); - } - -void CTMultiPtrEventTest::ResetFlushStopAS() - { - if (iActiveSchedulerStarted) - { - iActiveSchedulerStarted = EFalse; - CActiveScheduler::Stop(); - } - TheClient->iWs.SetAutoFlush(iTheClientFlush); - iMultiPtrEventClient->iWs.SetAutoFlush(iClientFlush); - } - -// Common function for all test cases -void CTMultiPtrEventTest::RunTestsL() - { - // Create CTMultiPtrEventClient for each test case and call NextSetOfEventsL() - iMultiPtrEventClient = new(ELeave) CTMultiPtrEventClient(this); - iMultiPtrEventClient->SetScreenNumber(iTest->iScreenNumber); - iMultiPtrEventClient->ConstructL(); - - iEventSet=0; - - // Create secondary client for test case number 3 - if (iTest->iState == 3) - { - iSecMultiPtrEventClient = new(ELeave) CTMultiPtrEventClient(this, 1); - iSecMultiPtrEventClient->SetScreenNumber(iTest->iScreenNumber); - iSecMultiPtrEventClient->ConstructL(); - } - - TRAPD(err, NextSetOfEventsL()); - if (err != KErrNone) - { - iFailed = ETrue; - } - - // Start nested activescheduler if it is not failed for the first attempt - if (!iFailed) - { - iActiveSchedulerStarted = ETrue; - CActiveScheduler::Start(); - } - - // - TInt eventsRem = iMultiPtrEventClient->EventBuffer()->EventsRemaining(); - if (eventsRem > 0) - { - iFailed=ETrue; - } - - // Delete secondary client for test case number 3 - if (iTest->iState == 3) - { - delete iSecMultiPtrEventClient; - iSecMultiPtrEventClient = NULL; - } - - delete iMultiPtrEventClient; - iMultiPtrEventClient = NULL; - } - -// Common function for all tests -// Important point to remember is that this function should not leave when running tests -void CTMultiPtrEventTest::NextSetOfEventsL() - { - // For each test case calls its respective tests - - ((CTMultiPtrEventTestStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); - switch (iTest->iState) - { - case 0: -/** -@SYMTestCaseID GRAPHICS-WSERV-ADVANCEDPOINTER-0036 -*/ - ((CTMultiPtrEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-ADVANCEDPOINTER-0036")); - MultiPointerEvents(); - break; - case 1: - ((CTMultiPtrEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-ADVANCEDPOINTER-0014")); - PurgingMultiPointerEvents(); - break; - case 2: - ((CTMultiPtrEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-ADVANCEDPOINTER-0013")); - MultiPointerEventsForAnimsL(); - break; - case 3: - ((CTMultiPtrEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-ADVANCEDPOINTER-0011")); - GetRemainingEventsFromSecondaryClient(); // Does nothing for first time - MultiClientMultiPointerEvents(); - break; - case 4: - ((CTMultiPtrEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-ADVANCEDPOINTER-0027")); - MultiPointerEventsForPointerClickL(); - break; - case 5: - ((CTMultiPtrEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-ADVANCEDPOINTER-0028")); - MultiPointerEventsInDiffScreenModes(); - break; - case 6: - ((CTMultiPtrEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-ADVANCEDPOINTER-0025")); - FilteringMultiPointerEvents(); - break; - case 7: - ((CTMultiPtrEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-ADVANCEDPOINTER-0021")); - GrabbingMultiPointerEvents(); - break; - case 8: - ((CTMultiPtrEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-ADVANCEDPOINTER-0031")); - VirtualKeyBoardForMultiplePointers(); - break; - case 9: - ((CTMultiPtrEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-ADVANCEDPOINTER-0032")); - DoubleClickForMultiplePointers(); - break; - case 10: - ((CTMultiPtrEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-ADVANCEDPOINTER-0015")); - MultiPointerOutOfRangeEvents(); - break; - case 11: - ((CTMultiPtrEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-ADVANCEDPOINTER-0026")); - AutoForeGroundForMultiplePointersL(); - break; - case 12: - ((CTMultiPtrEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-ADVANCEDPOINTER-0029")); - EmulationRulesForMultiplePointers(); - break; - case 13: - ((CTMultiPtrEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-ADVANCEDPOINTER-0034")); - CloseProximityAndHighPressureEventsL(); - break; - case 14: - ((CTMultiPtrEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-ADVANCEDPOINTER-0017")); - OutOfBoundValueTesting(); - break; - case 15: - ((CTMultiPtrEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-ADVANCEDPOINTER-0019")); - CapturingMultiPointerEvents(); - break; - case 16: - ((CTMultiPtrEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-ADVANCEDPOINTER-0035")); - NegativeTestsForProximityPressureEventsL(); - break; - case 17: - ((CTMultiPtrEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-ADVANCEDPOINTER-0034")); - PointerRepeatEventForMultiplePointers(); - break; - // Any new test case should be added here. - // because some of the above tests use testcase number for certain checks - default: - ((CTMultiPtrEventTestStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - AutoPanic(EAutoPanicWrongTest); - } - ((CTMultiPtrEventTestStep*)iStep)->RecordTestResultL(); - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-ADVANCEDPOINTER-0033 -@SYMPREQ PREQ1226 -@SYMREQ REQ9677 -@SYMTestPriority High -@SYMTestCaseDesc To check Wserv sends Pointer Repeat Events for all pointers. -@SYMTestStatus Implemented - -@SYMTestActions Simulate events being passed to the client by implementing each discrete test - over 4 seperate test cases. - In the first test case simulate EButton1Down and add event to a TWsEvent buffer. - In the second test case call RequestPointerRepeatEvent on the base window passing - in a time interval, a rectangle (the 'hitbox') and pointer number. - Add EButtonRepeat to TWsEvent buffer. - In the third test case simulate EPointerMove event within the hitbox, then simulate - an elapsed period of time longer that specified interval. Add only a EButtonRepeat - to TWsEvent buffer. - In the final test case simulate EButton1Up and add event to TWsEvent buffer. - - Repeat steps for the second discrete test, however, in the third test case simulate - EPointerMove event outside the hitbox. In addition add EDrag to TWsEvent buffer - instead of EButtonRepeat. - - A third discrete test will be executed over two test cases and will test - CancelPointerRepeatEventRequest API. - -@SYMTestExpectedResults The received events must match the events added to the buffer except where EPointerMove - events should be filtered out. In addition, EButtonRepeat will be generated by wserv - after calling RequestPointerRepeatEvent and time interval specified has elapsed. - -*/ -void CTMultiPtrEventTest::PointerRepeatEventForMultiplePointers() - { - // Test PointerRepeatEvent for Multiple Pointers - TLogMessageText logText; - _LIT(KSet, "PointerRepeatEventForMultiplePointers SetOfEvents: %d of 10"); - logText.AppendFormat(KSet, iEventSet); - LOG_MESSAGE(logText); - - if (!iEventSet) - { - SetAutoFlush(); - AddExpectedWsEvent(EEventFocusGained); - } - iMultiPtrEventClient->EventBuffer()->SetEventCount(0); - - TPoint ptrPos; - TInt ptrNum; - // Ensure all pointers are on iParentWin - TInt xInc = iPhysicalScreenSize.iWidth/iMaxDevPointers/3; - TInt yInc = iPhysicalScreenSize.iHeight/iMaxDevPointers/3; - - switch(iEventSet++) - { - // Test cases 0 - 3 represent first discrete test for PointerRepeatEvents - case 0: - // Simulate EButton1Down events only. This is in order to simulate the event being passed to the client. - // If the event remained in the window queue the PointerRepeatEvent request would be cancelled when PointerRepeatPurgeCheck is performed. - INFO_PRINTF1(_L("Simulate EButton1Down event for all pointers.")); - for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) - { - SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, ptrNum); - ptrPos.iX+=xInc; - ptrPos.iY+=yInc; - } - break; - case 1: - // Simulate client calling RequestPointerRepeatEvent in response to EButton1Down event being within a 'hitbox'. - INFO_PRINTF1(_L("Simulate PointerRepeatEvent request for all pointers.")); - ptrPos.SetXY(0,0); - for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) - { - iMultiPtrEventClient->ParentWin()->BaseWin()->RequestPointerRepeatEvent(TTimeIntervalMicroSeconds32(100000),TRect(TPoint(0,0), TSize(iPhysicalScreenSize.iWidth/2,iPhysicalScreenSize.iHeight)),ptrNum); - User::After(200000); - AddExpectedPointerEvent(TPointerEvent::EButtonRepeat, ptrPos, ptrNum); - ptrPos.iX+=xInc; - ptrPos.iY+=yInc; - } - break; - case 2: - // Simulate client calling RequestPointerRepeatEvent in response to EButtonRepeat and pointer remaining within the 'hitbox'. - INFO_PRINTF1(_L("Simulate additional PointerRepeatEvent request for all pointers.")); - // New coordinates will be used for a simulated EPointerMove. This event will be filtered out, however, EButtonRepeat will occur at new coordinates - ptrPos.iX = xInc; - ptrPos.iY = yInc; - for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) - { - iMultiPtrEventClient->ParentWin()->BaseWin()->RequestPointerRepeatEvent(TTimeIntervalMicroSeconds32(100000),TRect(TPoint(0,0), TSize(iPhysicalScreenSize.iWidth/2,iPhysicalScreenSize.iHeight)),ptrNum); - // EPointerMove event is filtered out by TWsPointer::PointerRepeatPurgeCheck - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, 0, ptrNum); - User::After(200000); - AddExpectedPointerEvent(TPointerEvent::EButtonRepeat, ptrPos, ptrNum); - ptrPos.iX+=xInc; - ptrPos.iY+=yInc; - } - break; - case 3: - INFO_PRINTF1(_L("Simulate EButton1Up for all pointers.")); - ptrPos.iX = xInc; - ptrPos.iY = yInc; - for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) - { - SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, ptrNum); - ptrPos.iX+=xInc; - ptrPos.iY+=yInc; - } - break; - // Test cases 4 - 7 represent second second discrete test for PointerRepeatEvents - case 4: - // Simulate EButton1Down events only. This is in order to simulate the event being passed to the client. - // If the event remained in the window queue the PointerRepeatEvent request would be cancelled when PointerRepeatPurgeCheck is performed. - INFO_PRINTF1(_L("Simulate EButton1Down event for all pointers.")); - ptrPos.SetXY(0,0); - for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) - { - SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, ptrNum); - ptrPos.iX+=xInc; - ptrPos.iY+=yInc; - } - break; - case 5: - // Simulate client calling RequestPointerRepeatEvent in response to EButton1Down event being within a 'hitbox'. - INFO_PRINTF1(_L("Call RequestPointerRepeatEvent for all pointers.")); - ptrPos.SetXY(0,0); - for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) - { - iMultiPtrEventClient->ParentWin()->BaseWin()->RequestPointerRepeatEvent(TTimeIntervalMicroSeconds32(100000),TRect(TPoint(0,0), TSize(iPhysicalScreenSize.iWidth/3,iPhysicalScreenSize.iHeight)),ptrNum); // hitbox size reduced - User::After(200000); - AddExpectedPointerEvent(TPointerEvent::EButtonRepeat, ptrPos, ptrNum); - ptrPos.iX+=xInc; - ptrPos.iY+=yInc; - } - break; - case 6: - // Simulate client calling RequestPointerRepeatEvent in response to EButtonRepeat and event remaining within the 'hitbox' rect. - // EPointerMove will take pointer out of the hitbox so should not be filtered. PointerRepeatEvent should be cancelled. - INFO_PRINTF1(_L("Simulate a PointerMove event for all pointers to a coordinate outside the hitbox.")); - // New coordinates will be used for a simulated EPointerMove outisde the hitbox. - ptrPos.iX = iPhysicalScreenSize.iWidth/3 + xInc; - ptrPos.iY = 0; - for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) - { - iMultiPtrEventClient->ParentWin()->BaseWin()->RequestPointerRepeatEvent(TTimeIntervalMicroSeconds32(100000),TRect(TPoint(0,0), TSize(iPhysicalScreenSize.iWidth/3,iPhysicalScreenSize.iHeight)),ptrNum); - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, 0, ptrNum); - User::After(200000); - AddExpectedPointerEvent(TPointerEvent::EDrag, ptrPos, ptrNum); - } - break; - case 7: - INFO_PRINTF1(_L("Simulate EButton1Up for all pointers.")); - ptrNum = 0; - ptrPos.iX = iPhysicalScreenSize.iWidth/3 + xInc; - ptrPos.iY = 0; - for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) - { - SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, ptrNum); - } - break; - // Test cases 8 and 9 represent third discrete test for PointerRepeatEvents - case 8: - // Simulate EButton1Down events only. This is in order to simulate the event being passed to the client. - // If the event remained in the window queue the PointerRepeatEvent request would be cancelled when PointerRepeatPurgeCheck is performed. - INFO_PRINTF1(_L("Simulate EButton1Down event for all pointers.")); - ptrPos.SetXY(0,0); - for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) - { - SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, ptrNum); - ptrPos.iX+=xInc; - ptrPos.iY+=yInc; - } - break; - case 9: - // No simulated events. This test case is to explicity call RWindowBase::CancelPointerRepeatEventRequest(const TUint8 aPointerNumber) - INFO_PRINTF1(_L("Call RequestPointerRepeatEvent and CancelPointerRepeatEventRequest for all pointers.")); - ptrPos.SetXY(0,0); - for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) - { - iMultiPtrEventClient->ParentWin()->BaseWin()->RequestPointerRepeatEvent(TTimeIntervalMicroSeconds32(100000),TRect(TPoint(0,0), TSize(iPhysicalScreenSize.iWidth/3,iPhysicalScreenSize.iHeight)),ptrNum); - iMultiPtrEventClient->ParentWin()->BaseWin()->CancelPointerRepeatEventRequest(ptrNum); - ptrPos.iX+=xInc; - ptrPos.iY+=yInc; - } - INFO_PRINTF1(_L("Simulate EButton1Up for all pointers.")); - ptrPos.iX = xInc; - ptrPos.iY = yInc; - for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) - { - SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, ptrNum); - ptrPos.iX+=xInc; - ptrPos.iY+=yInc; - } - break; - default: - ResetFlushStopAS(); - break; - } - LogEventsAdded(); - } - -void CTMultiPtrEventTest::TestErrorCodeL(TInt aExpErrCode, TInt aActualErrCode) - { - if (aExpErrCode != aActualErrCode) - { - TLogMessageText logText; - _LIT(KError, "Expected Error code = %d Actual Actual Error code %d"); - logText.AppendFormat(KError, aExpErrCode, aActualErrCode); - LOG_MESSAGE(logText); - User::Leave(ETestFailed); - } - } - -void CTMultiPtrEventTest::NegativeTestingOfProximityPressureAPIsL() - { - // First send -10 for EnterCloseProximity and -5 for ExitCLoseProximity, it should return KErrArgument - // Then send 20 and 10 which should return KErrNone - // Then sent 10 and 20 which should return KErrArgument - TInt retVal; - retVal = iMultiPtrEventClient->iWs.SetCloseProximityThresholds(-10, -5); - TestErrorCodeL(KErrArgument, retVal); - - retVal = iMultiPtrEventClient->iWs.SetCloseProximityThresholds(20, 10); - TestErrorCodeL(KErrNone, retVal); - - retVal = iMultiPtrEventClient->iWs.SetCloseProximityThresholds(10, 20); - TestErrorCodeL(KErrArgument, retVal); - - // Repeat the above for EnterHighPressure and ExitHighPressure with these values - // -10 and -5 it should return KErrArgument - // -5 and -10 it should return KErrNone - retVal = iMultiPtrEventClient->iWs.SetHighPressureThresholds(-10, -5); - TestErrorCodeL(KErrArgument, retVal); - - retVal = iMultiPtrEventClient->iWs.SetHighPressureThresholds(-5, -10); - TestErrorCodeL(KErrNone, retVal); - } - -void CTMultiPtrEventTest::SimulateProximityAndPressureEvents(TInt aCloseProxEnterValue, TInt aCloseProxExitValue, TInt aHighPresEnterValue, TInt aHighPresExitValue) - { - TPoint ptrPos(10,10); - // Simulate EPointerMove with proximity value > EnterCloseProximity threshold - for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) - { - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, aCloseProxEnterValue, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EEnterCloseProximity, ptrPos, aCloseProxEnterValue, 0, ptrNum); - } - - // Simulate EPointerMove with proximity value < ExitCloseProximity threshold - for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) - { - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, aCloseProxExitValue, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EExitCloseProximity, ptrPos, aCloseProxExitValue, 0, ptrNum); - } - - // Simulate EBUtton1Down with presure value > EnterHighPressure threshold - for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) - { - SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, aHighPresEnterValue, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, aHighPresEnterValue, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EEnterHighPressure, ptrPos, aHighPresEnterValue, 0, ptrNum); - } - - // Simulate EPointerMove with presure value < ExitHighPressure threshold - for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) - { - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, aHighPresExitValue, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EExitHighPressure, ptrPos, aHighPresExitValue, 0, ptrNum); - } - - // Finally simulate Ebutton1Up with proximity value < ExitCloseProximity - for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) - { - SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, aCloseProxExitValue, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, aCloseProxExitValue, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EExitCloseProximity, ptrPos, aCloseProxExitValue, 0, ptrNum); - } - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-ADVANCEDPOINTER-0035 -@SYMPREQ PREQ1226 -@SYMREQ REQ10887, REQ10886 -@SYMTestPriority High -@SYMTestCaseDesc Negative tests for close Proximity and high Pressure events. -@SYMTestStatus Implemented - -@SYMTestActions Set CloseProximity and HighPressure thresholds with positive and negative values. - Simulate Enter/ExitCloseProximity and Enter/ExitHighPressure events. -@SYMTestExpectedResults The received events must match the simulated pointer events -*/ -void CTMultiPtrEventTest::NegativeTestsForProximityPressureEventsL() - { - TLogMessageText logText; - _LIT(KSet, "Negative tests for pressure and proximity events: %d of 3"); - logText.AppendFormat(KSet, iEventSet); - LOG_MESSAGE(logText); - - if (!iEventSet) - { - SetAutoFlush(); - NegativeTestingOfProximityPressureAPIsL(); - AddExpectedWsEvent(EEventFocusGained); - } - iMultiPtrEventClient->EventBuffer()->SetEventCount(0); - switch(iEventSet++) - { - case 0: - // This is to check close proximity threshold API can be given +ve values - // and high pressure threshold API can begiven -ve values - iMultiPtrEventClient->iWs.SetCloseProximityThresholds(50, 20); - iMultiPtrEventClient->iWs.SetHighPressureThresholds(-20, -50); - SimulateProximityAndPressureEvents(60, 10, -10, -60); - break; - case 1: - // Repeat the above with +ve values - iMultiPtrEventClient->iWs.SetCloseProximityThresholds(50, 20); - iMultiPtrEventClient->iWs.SetHighPressureThresholds(50, 20); - SimulateProximityAndPressureEvents(60, 10, 60, 10); - break; - case 2: - // Repeat the above -ve values - iMultiPtrEventClient->iWs.SetCloseProximityThresholds(-20, -50); - iMultiPtrEventClient->iWs.SetHighPressureThresholds(-20, -50); - SimulateProximityAndPressureEvents(-10, -60, -10, -60); - break; - default: - SetThresholdValues(KMaxTInt, KMinTInt, KMaxTInt, KMinTInt); - ResetFlushStopAS(); - break; - } - - LogEventsAdded(); - } - - -void CTMultiPtrEventTest::CreateGroupWinForCapturingL() - { - iGroupWinForCapturing = new(ELeave) CTWindowGroup(iMultiPtrEventClient); - iGroupWinForCapturing->ConstructL(); - iGroupWinForCapturing->GroupWin()->AutoForeground(ETrue); - iGroupWinForCapturing->GroupWin()->EnableFocusChangeEvents(); - - iWinForCapturing = new(ELeave) CTBlankWindow(); - iWinForCapturing->ConstructL(*iGroupWinForCapturing); - iWinForCapturing->SetExt(TPoint(), TSize(iPhysicalScreenSize.iWidth/2, iPhysicalScreenSize.iHeight)); - iWinForCapturing->SetColor(KRgbBlue); - iWinForCapturing->BaseWin()->EnableAdvancedPointers(); - iWinForCapturing->Activate(); - } - -void CTMultiPtrEventTest::DeleteGroupWinForCapturing() - { - if (iWinForCapturing) - { - delete iWinForCapturing; - iWinForCapturing = NULL; - } - if (iGroupWinForCapturing) - { - delete iGroupWinForCapturing; - iGroupWinForCapturing = NULL; - } - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-ADVANCEDPOINTER-0019 -@SYMPREQ PREQ1226 -@SYMREQ REQ9677,REQ9683, -@SYMTestPriority High -@SYMTestCaseDesc Checks Wserv supports Capturing in case of multi pointer events. -@SYMTestStatus Implemented - -@SYMTestActions Create a window with group window as its parent. - Create another window with same parent and partially overlapping the first one. - SetPointerCapture for second window with TCaptureEnabled flag. - Simulate TRawEvent::EButton1Down from each pointer the device supports - - Repeat the above with TCaptureFlagAllGroups flag for SetPointerCapture - and creating windows from different window group - -@SYMTestExpectedResults Even if events were simulated on first window events are delivered to - second window as it is capturing. - With TCaptureFlagAllGroups flag set events are delivered to window which is - capturing even if events were simulated on a window from different group - -*/ -void CTMultiPtrEventTest::CapturingMultiPointerEvents() - { - // Test Capturing of multi pointer events - // 1. Test Wserv supports Capturing in case of multi-pointer events - // 2. Test pointer events are delivered correctly when Capturing is disabled. - TLogMessageText logText; - _LIT(KSet, "CapturingMultiPtrEvents SetOfEvents: %d of 3"); - logText.AppendFormat(KSet, iEventSet); - LOG_MESSAGE(logText); - - if (!iEventSet) - { - SetAutoFlush(); - } - iMultiPtrEventClient->EventBuffer()->SetEventCount(0); - - TPoint ptrPos; - TInt ptrNum; - - switch(iEventSet++) - { - case 0: - INFO_PRINTF1(_L("Ensure pointer state is Out of Range")); - AddExpectedWsEvent(EEventFocusGained); - for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) - { - SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, ptrNum); - SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, ptrNum); - } - break; - case 1: - INFO_PRINTF1(_L("Check Wserv supports Capturing in case of multi-pointer events, within window group")); - iMultiPtrEventClient->ChildWin()->BaseWin()->SetPointerCapture(RWindowBase::TCaptureEnabled); - TestCapturingForMultiPointer(EFalse); - break; - case 2: - INFO_PRINTF1(_L("Check Wserv supports Capturing in case of multi-pointer events, from different window groups")); - TRAPD(err, CreateGroupWinForCapturingL()); // it cannot leave so trap and fail - if (err != KErrNone) - { - Failed(); - } - AddExpectedWsEvent(EEventFocusLost); // First group window losing focus because of second group creation - AddExpectedWsEvent(EEventFocusGained); // Second group window creation - - iWinForCapturing->BaseWin()->SetPointerCapture(RWindowBase::TCaptureEnabled|RWindowBase::TCaptureFlagAllGroups); - TestCapturingForMultiPointer(ETrue); - break; - default: - DeleteGroupWinForCapturing(); - ResetFlushStopAS(); - break; - } - LogEventsAdded(); - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-ADVANCEDPOINTER-0017 -@SYMPREQ PREQ1226 -@SYMREQ Negative Testing -@SYMTestPriority High -@SYMTestCaseDesc Out of bound value testing -@SYMTestStatus Implemented - -@SYMTestActions Simulate raw events of TRawEvent with pointer number greater than EPointerMaxPointers - -@SYMTestExpectedResults The received events must match the events added to the buffer and check that out of bound events are ignored. - -*/ -void CTMultiPtrEventTest::OutOfBoundValueTesting() - { - // Test Wserv ignores pointer events which have a pointer number greater than EPointerMaxPointers. - TLogMessageText logText; - _LIT(KSet, "OutOfBoundValueTesting SetOfEvents: %d of 1"); - logText.AppendFormat(KSet, iEventSet); - LOG_MESSAGE(logText); - - if (!iEventSet) - { - SetAutoFlush(); - AddExpectedWsEvent(EEventFocusGained); - } - iMultiPtrEventClient->EventBuffer()->SetEventCount(0); - - TPoint ptrPos; - TInt ptrNum; - TInt ptrNumOutOfBounds; - - switch(iEventSet++) - { - case 0: - INFO_PRINTF1(_L("Checks Wserv ignores pointer events which have a pointer number greater than EPointerMaxPointers.")); - ptrPos.SetXY(0,0); - ptrNum = iMaxDevPointers-1; // Max value for ptrNum - ptrNumOutOfBounds = iMaxDevPointers; // Invalid ptrNum as pointer numbers are zero indexed - - SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum); - SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNumOutOfBounds); - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX+10, ptrPos.iY+10, 0, ptrNum); - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX+10, ptrPos.iY+10, 0, ptrNumOutOfBounds); - SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX+10, ptrPos.iY+10, 0, ptrNum); - SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX+10, ptrPos.iY+10, 0, ptrNumOutOfBounds); - AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, ptrNum); - ptrPos.iX += 10; ptrPos.iY += 10; - AddExpectedPointerEvent(TPointerEvent::EDrag, ptrPos, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, ptrNum); - break; - default: - ResetFlushStopAS(); - break; - } - LogEventsAdded(); - } - -void CTMultiPtrEventTest::SetThresholdValues(TInt aEnterCloseProx, TInt aExitCloseProx, TInt aEnterHighPres, TInt aExitHighPres) - { - iEnterCloseProximityThreshold = aEnterCloseProx; - iExitCloseProximityThreshold = aExitCloseProx; - iEnterHighPressureThreshold = aEnterHighPres; - iExitHighPressureThreshold = aExitHighPres; - - iMultiPtrEventClient->iWs.SetCloseProximityThresholds(iEnterCloseProximityThreshold,iExitCloseProximityThreshold); - iMultiPtrEventClient->iWs.SetHighPressureThresholds(iEnterHighPressureThreshold,iExitHighPressureThreshold); - } - -void CTMultiPtrEventTest::TestCloseProximityHighPressureAPIsL() - { - // These are some typical values which are used only for testing purposes. - // 20mm to screen - // 50mm to screen - // 4N of pressure - // 2N of pressure - SetThresholdValues(-20,-50,4000,2000); - - if (iMultiPtrEventClient->iWs.GetEnterCloseProximityThreshold() != iEnterCloseProximityThreshold) - { - TLogMessageText logText; - _LIT(KError, "Expected EnterCloseProximityThreshold = %d Actual EnterCloseProximityThreshold %d"); - logText.AppendFormat(KError, iEnterCloseProximityThreshold, iMultiPtrEventClient->iWs.GetEnterCloseProximityThreshold()); - LOG_MESSAGE(logText); - User::Leave(ETestFailed); - } - - if (iMultiPtrEventClient->iWs.GetExitCloseProximityThreshold() != iExitCloseProximityThreshold) - { - TLogMessageText logText; - _LIT(KError, "Expected ExitCloseProximityThreshold = %d Actual ExitCloseProximityThreshold %d"); - logText.AppendFormat(KError, iExitCloseProximityThreshold, iMultiPtrEventClient->iWs.GetExitCloseProximityThreshold()); - LOG_MESSAGE(logText); - User::Leave(ETestFailed); - } - - if (iMultiPtrEventClient->iWs.GetEnterHighPressureThreshold() != iEnterHighPressureThreshold) - { - TLogMessageText logText; - _LIT(KError, "Expected EnterHighPressureThreshold = %d Actual EnterHighPressureThreshold %d"); - logText.AppendFormat(KError, iEnterHighPressureThreshold, iMultiPtrEventClient->iWs.GetEnterHighPressureThreshold()); - LOG_MESSAGE(logText); - User::Leave(ETestFailed); - } - - if (iMultiPtrEventClient->iWs.GetExitHighPressureThreshold() != iExitHighPressureThreshold) - { - TLogMessageText logText; - _LIT(KError, "Expected ExitHighPressureThreshold = %d Actual ExitHighPressureThreshold %d"); - logText.AppendFormat(KError, iExitHighPressureThreshold, iMultiPtrEventClient->iWs.GetExitHighPressureThreshold()); - LOG_MESSAGE(logText); - User::Leave(ETestFailed); - } - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-ADVANCEDPOINTER-0034 -@SYMPREQ PREQ1226 -@SYMREQ REQ10887,REQ10886 -@SYMTestPriority High -@SYMTestCaseDesc Tests close Proximity and high Pressure event types. -@SYMTestStatus Implemented - -@SYMTestActions Set CloseProximity and HighPressure thresholds and simulate events with different Z values -@SYMTestExpectedResults The received events must match the simulated pointer events -*/ -void CTMultiPtrEventTest::CloseProximityAndHighPressureEventsL() - { - TLogMessageText logText; - _LIT(KSet, "Close Proximity and High Pressure events: %d of 11"); - logText.AppendFormat(KSet, iEventSet); - LOG_MESSAGE(logText); - - if (!iEventSet) - { - SetAutoFlush(); - TestCloseProximityHighPressureAPIsL(); - AddExpectedWsEvent(EEventFocusGained); - } - iMultiPtrEventClient->EventBuffer()->SetEventCount(0); - - TPoint ptrPos(10,10); - TInt proxValue; - TInt prValue; - TInt tempCount; - switch(iEventSet++) - { - case 0: - iMultiPtrEventClient->ParentWin()->BaseWin()->PointerFilter(EPointerFilterMove, 0); - // One whole cycle of events - // Simulate out-of-range from all pointers and don't expect out-of-range events - // since all the pointers are already in same state - for (TInt ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) - { - SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum); - } - - // Simulate moves with proximity value < EEnterCloseProximity - proxValue = -30; - for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) - { - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, proxValue, 0, ptrNum); - } - - // Simulate moves with proximity value > EEnterCloseProximity - proxValue = -10; - for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) - { - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EEnterCloseProximity, ptrPos, proxValue, 0, ptrNum); - } - - // Simulate EButton1Down with pressure value < EEnterHighPressure - prValue = 1000; - for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) - { - SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, prValue, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, prValue, 0, ptrNum); - } - - // Simulate moves with pressure value > EEnterHighPressure - prValue = 5000; - for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) - { - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, prValue, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EEnterHighPressure, ptrPos, prValue, 0, ptrNum); - } - - // Simulate moves with pressure value < EExitHighPressure - prValue = 1000; - for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) - { - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, prValue, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EExitHighPressure, ptrPos, prValue, 0, ptrNum); - } - - // Simulate EButton1Up with proximity value > EEnterCloseProximity - proxValue = -10; - for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) - { - SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, proxValue, 0, ptrNum); - } - - // Simulate moves with proximity value < EExitCloseProximity - proxValue = -60; - for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) - { - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EExitCloseProximity, ptrPos, proxValue, 0, ptrNum); - } - break; - case 1: - // Simulate events to meet all scenarios - // Simulate EButton1Down with pressure value < EEnterHighPressure - prValue = 1000; - for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) - { - SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, prValue, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, prValue, 0, ptrNum); - } - - // Simulate EButton1Up with proximity value < EExitCloseProximity - proxValue = -60; - for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) - { - SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, proxValue, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EExitCloseProximity, ptrPos, proxValue, 0, ptrNum); - } - - // Simulate EButton1Down with pressure value > EEnterHighPressure - prValue = 5000; - for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) - { - SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, prValue, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, prValue, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EEnterHighPressure, ptrPos, prValue, 0, ptrNum); - } - - // Simulate EButton1Up with proximity value < EExitCloseProximity - proxValue = -60; - for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) - { - SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, proxValue, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EExitCloseProximity, ptrPos, proxValue, 0, ptrNum); - } - break; - case 2: - // Simulate moves with proximity value > EEnterCloseProximity - proxValue = -10; - for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) - { - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EEnterCloseProximity, ptrPos, proxValue, 0, ptrNum); - } - - // Simulate EButton1Down with pressure value > EEnterHighPressure - prValue = 5000; - for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) - { - SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, prValue, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, prValue, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EEnterHighPressure, ptrPos, prValue, 0, ptrNum); - } - - // Simulate EButton1Up with proximity value > EExitCloseProximity - proxValue = -40; // When you coming up, EEnterCloseProximity is of no use - for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) - { - SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, proxValue, 0, ptrNum); - } - - // Simulate out-of-range events - for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) - { - SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, proxValue, 0, ptrNum); - } - break; - case 3: - // From out-of-range state to EButton1Down - // Simulate EButton1Down with pressure value < EEnterHighPressure - prValue = 1000; - for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) - { - SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, prValue, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, prValue, 0, ptrNum); - } - - // Simulate EButton1Up with proximity value > EExitCloseProximity - proxValue = -40; - for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) - { - SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, proxValue, 0, ptrNum); - } - - // Simulate out-of-range events - for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) - { - SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, proxValue, 0, ptrNum); - } - - // Simulate EButton1Down with pressure value > EEnterHighPressure - prValue = 5000; - for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) - { - SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, prValue, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, prValue, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EEnterHighPressure, ptrPos, prValue, 0, ptrNum); - } - - // Simulate EButton1Up with proximity value > EExitCloseProximity - proxValue = -40; - for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) - { - SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, proxValue, 0, ptrNum); - } - - // Simulate out-of-range events - for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) - { - SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, proxValue, 0, ptrNum); - } - break; - case 4: - // Simulate EButton1Dowm with pressure value < EEnterHighPressure - prValue = 1000; - for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) - { - SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, prValue, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, prValue, 0, ptrNum); - } - - // Simulate EButton1Up with proximity value < EExitCloseProximity - proxValue = -60; - for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) - { - SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, proxValue, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EExitCloseProximity, ptrPos, proxValue, 0, ptrNum); - } - - // Simulate out-of-range from Up/OutOfCloseProximity - for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) - { - SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, proxValue, 0, ptrNum); - } - break; - case 5: - // Purging of proximity and pressure events - // Simulate EnterCloseProximity and ExitCloseProximity events which will be purged - // when you send Button1Up events for KMaxQueueSize - proxValue = -10; - for (TInt ptrNum = 0; (ptrNum < iMaxDevPointers && ptrNum < 4); ptrNum++) - { - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); - } - proxValue = -60; - for (TInt ptrNum = 0; (ptrNum < iMaxDevPointers && ptrNum < 4); ptrNum++) - { - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); - } - for (TInt count = 0; count < KMaxQueueSize; count++) - { - SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, proxValue, 0); - AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, proxValue, 0, 0); - } - break; - case 6: - // Simulate EnterCloseProximity for 4 pointers. - // As we cannot create lone ExitCloseProximity events, so create just moves from next 4 pointers - // Simulate out-of-range for these events on thier respective pointers - // Then simulate EButton1Up events which will purge EnterCloseProximity and move events - // which checks that lone EnterCloseProximity and lone move events will be purged - proxValue = -10; - for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) - { - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); - SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, proxValue, 0, ptrNum); - } - proxValue = -60; - for (TInt ptrNum = iMaxDevPointers/2; ptrNum < iMaxDevPointers; ptrNum++) - { - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); - SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, proxValue, 0, ptrNum); - } - for (TInt count = 0; count < KMaxQueueSize-iMaxDevPointers; count++) - { - SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, proxValue, 0); - AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, proxValue, 0, 0); - } - break; - case 7: - // Bring all other pointers to Up state, becasue of previous test - // Then simulate out-of-range twice for all the pointers - // Then simulate Button1Up which will cause purging of successive out-of-range events - proxValue = -60; - tempCount = 0; - for (TInt ptrNum = 1; ptrNum < iMaxDevPointers; ptrNum++) - { - tempCount++; - SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, proxValue, 0, ptrNum); - } - for (TInt ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) - { - tempCount++; - // Wserv does nothing if current state is outofrange and if receives again EOutOfRange event which is practically not possible - SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum); - SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, proxValue, 0, ptrNum); - } - for (TInt count = 0; count < KMaxQueueSize-tempCount; count++) - { - SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, proxValue, 0); - AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, proxValue, 0, 0); - } - break; - case 8: - // Simulate EButton1Down with pressure value > EnterHIghPressure threshold - // which will cause EButton1Down and EnterHighPressure to be filled in queue - // Simulate ExitHighPressure and EButton1Up events for 2 pointers - // Then simulate EButton1Up events from pointer0 so that all of the above events are purged - prValue = 5000; - for (TInt ptrNum = 0; (ptrNum < iMaxDevPointers && ptrNum < 2); ptrNum++) - { - SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, prValue, ptrNum); - } - prValue = 1000; - for (TInt ptrNum = 0; (ptrNum < iMaxDevPointers && ptrNum < 2); ptrNum++) - { - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, prValue, ptrNum); - // Here these events are purged becasue their correpsonding down event would have been purged - SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, ptrNum); - } - // All the above events get purged by this - for (TInt count = 0; count < KMaxQueueSize; count++) - { - SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 0); - AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, 0); - } - break; - case 9: - // Simulate EButton1Down for 2 pointers, which will generate Button1Down and EnterHighPressure - // Simulate Ebutton1Up events for MaxQueueSize from last pointer so that all the above events are purged - prValue = 5000; - for (TInt ptrNum = 0; (ptrNum < iMaxDevPointers/2 && ptrNum < 2); ptrNum++) - { - SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, prValue, ptrNum); - } - - // This will cause above down and enterhighpressure events to be purged - // When pointer is in outofrange state and when EButton1Up event is sent Wserv sends EnterCloseProximity - // EnterCloseProximity cannot be purged unless the next event is EExitCloseProximity or EOutOfRange - for (TInt count = 0; count < KMaxQueueSize; count++) - { - SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, iMaxDevPointers-1); - AddExpectedPointerEvent((count ? TPointerEvent::EButton1Up : TPointerEvent::EEnterCloseProximity), ptrPos, 0, 0, iMaxDevPointers-1); - } - - // As the first 2 pointers are in down state, and if we send the move events with prValue = 1000 - // This will generate the exithigh pressure events, which will be ignored - // This will also generate the Ebutton1Up event which will also be ignored - prValue = 1000; - for (TInt ptrNum = 0; (ptrNum < iMaxDevPointers/2 && ptrNum < 2); ptrNum++) - { - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, prValue, ptrNum); - SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, ptrNum); - } - break; - case 10: - // This is to just bring all the pointers to out-of-range state - // to make all pointers in valid state for other test to run - // Wserv processes EOutOfRange events only when its current state is not in outofrange. - for (TInt ptrNum = 0; ptrNum < iMaxDevPointers && ptrNum < 2; ptrNum++) - { - SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, 0, 0, ptrNum); - } - SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, iMaxDevPointers-1); - AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, 0, 0, iMaxDevPointers-1); - break; - default: - SetThresholdValues(KMaxTInt, KMinTInt, KMaxTInt, KMinTInt); - ResetFlushStopAS(); - break; - } - - LogEventsAdded(); - } - -void CTMultiPtrEventTest::CreateAnimDllAndAnimL() - { - iAnimDll = new(ELeave) RAnimDll(iMultiPtrEventClient->iWs); - User::LeaveIfError(iAnimDll->Load(KAnimDLLName)); - iAnim = RMultiPointerAnim::NewL(iMultiPtrEventClient->ParentWin()->BaseWin(), iAnimDll); - } - -void CTMultiPtrEventTest::DestroyAnimDllAndAnim() - { - if (iAnim) - { - iAnim->Destroy(); - iAnim = NULL; - } - if (iAnimDll) - { - iAnimDll->Destroy(); - iAnimDll = NULL; - } - } - -void CTMultiPtrEventTest::CreateGroupWinL() - { - iGroupWinForEmul = new(ELeave) CTWindowGroup(iMultiPtrEventClient); - iGroupWinForEmul->ConstructL(); - iGroupWinForEmul->GroupWin()->AutoForeground(ETrue); - iGroupWinForEmul->GroupWin()->EnableFocusChangeEvents(); - - iWinForEmul = new(ELeave) CTBlankWindow(); - iWinForEmul->ConstructL(*iGroupWinForEmul); - iWinForEmul->SetExt(TPoint(50,50), TSize(80,80)); - iWinForEmul->SetColor(KRgbDarkYellow); - iWinForEmul->Activate(); - } - -void CTMultiPtrEventTest::DeleteGroupWin() - { - if (iWinForEmul) - { - delete iWinForEmul; - iWinForEmul = NULL; - } - if (iGroupWinForEmul) - { - delete iGroupWinForEmul; - iGroupWinForEmul = NULL; - } - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-ADVANCEDPOINTER-0029 -@SYMPREQ PREQ1226 -@SYMREQ REQ9688 -@SYMTestPriority High -@SYMTestCaseDesc Tests the emulation rules for Apps, Anims, Autofocus and Buffered delivery -@SYMTestStatus Implemented - -@SYMTestActions Simulate event to make a pointer primary. EnableAdvancedPointers API is not called. And then simulate events from other pointers -@SYMTestExpectedResults The events from other pointer are not received -*/ -void CTMultiPtrEventTest::EmulationRulesForMultiplePointers() - { - TLogMessageText logText; - _LIT(KSet, "Emulation rules set of events: %d of 15"); - logText.AppendFormat(KSet, iEventSet); - LOG_MESSAGE(logText); - - if (!iEventSet) - { - SetExpectNonAdvancedPointerEvents(); - SetAutoFlush(); - AddExpectedWsEvent(EEventFocusGained); - } - iMultiPtrEventClient->EventBuffer()->SetEventCount(0); - - TPoint ptrPos(10,10); - TInt proxValue = -iProximityStep; - TInt prValue = iPressureStep; - TInt ptrNum = 0; - switch(iEventSet++) - { - case 0: - // This event is for simulated/primary pointer - iMultiPtrEventClient->ParentWin()->BaseWin()->PointerFilter(EPointerFilterMove, 0); - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, 0); - AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, proxValue, 0, TAdvancedPointerEvent::EDefaultPointerNumber); - - // Parent window has not called EnableAdvancedPointers API - // So even if we simulate moves and out-of-range these are not delivered to client - for (ptrNum = 1; ptrNum < iMaxDevPointers; ptrNum++) - { - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); - SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum); - } - break; - case 1: - // Since the primary pointer is 0, simulate EButton1Down for making pointer 1 as primary - SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 1); - AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); - - // Simulate move or Ebutton1Down from pointer0 they are NOT sent back to client - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, 0); - SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 0); - SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 0); - - SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 1); - AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); - SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 1); - AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); - break; - case 2: - // Simulate EButton1Down from pointer0 to make it primary - SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 0); - AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, 0); - - // Move from pointer1 - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, 1); - - // Take the zero pointer out-of-range, this will not result in Pointer 1 becoming primary - // and out-of-range event is sent to client - SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 0); - AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, 0); - SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 0); - AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, 0, 0, 0); - - // Send moves from pointer1, but these are not sent to the Client. - ptrPos.iX += 10; - ptrPos.iY += 10; - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, 1); - SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 1); - - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, 1); - AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, proxValue, 0, TAdvancedPointerEvent::EDefaultPointerNumber); - - SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 1); - AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, proxValue, 0, TAdvancedPointerEvent::EDefaultPointerNumber); - break; - case 3: - // Simulate EButton1Down from pointer0 to make it primary - SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 0); - AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); - - // Simulate EButton1Down from pointer1, which is not sent to client - SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 1); - - SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 0); - AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); - - SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 0); - AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); - - // Drag events are not sent becasue pointer1 has NOT become primary - ptrPos.iX += 10; - ptrPos.iY += 10; - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, 0, 1); - - // Simulate up from pointer1, still not primary, so event is not sent - SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 1); - - // Simulate out-of-range from pointer1, still not primary, so event is not sent - SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 1); - - // Now moves from out-of-range to move state - ptrPos.iX += 10; - ptrPos.iY += 10; - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, 0, 1); - AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); - - SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 1); - AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); - break; - case 4: - // pointer0 sends move (becomes primary) - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, 0, 0); - AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); - - // pointer0 sends down - SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 0); - AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); - - // pointer1 sends down, doesn't become primary - SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 1); - - // pointer0 sends up, stays primary - SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 0); - AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); - - // pointer2, pointer3 and pointer4 sends move with proximity -5, -10, -15 - for (ptrNum = 2; ptrNum < iMaxDevPointers; ptrNum++, proxValue -= iProximityStep) - { - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); - } - - // pointer0 sends out-of-range, loses primary pointer, But NO events are sent - SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 0); - AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); - - // Send moves for pointer2, pointer3 and pointer4. - // None of the evnst are sent - ptrPos.SetXY(0,0); - for (ptrNum = 2; ptrNum < iMaxDevPointers; ptrNum++) - { - ptrPos.iX += 10; - ptrPos.iY += 5; - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); - } - - // Drag from pointer1, NOT sent, since it is not primary - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, prValue, 1); - - // Send out-of-range from all pointers - for (ptrNum = 2; ptrNum < iMaxDevPointers; ptrNum++) - { - SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum); - } - - // As the pointer1 is down, this will not become primary even if EButton1Up is called - SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 1); - - // And now sending out-of-range will also not send the event to client as it is not primary - SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 1); - break; - case 5: - // Test cases 5 - 7 represent one discrete test for PointerRepeatEvents - // Case 5 simulates EButton1Down events only. This is to ensure the event is delivered to the client. - // If the event remained in the window queue the PointerRepeatEvent request would be cancelled when PointerRepeatPurgeCheck is performed. - ptrPos.SetXY(0,0); - - // pointer0 sends down (become primary) - SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 0); - AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); - - // pointer1 sends down, doesn't become primary - SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 1); - - // pointer4 sends down - if (4 < iMaxDevPointers) - { - SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 4); - } - break; - case 6: - ptrPos.SetXY(0,0); - // Simulate client calling RequestPointerRepeatEvent in response to EButton1Down event being within a 'hitbox'. - // Legacy API called which does not specify a pointer number. EButtonRepeat should be generated for primary pointer only. - iMultiPtrEventClient->ParentWin()->BaseWin()->RequestPointerRepeatEvent(TTimeIntervalMicroSeconds32(100000),TRect(TPoint(0,0), TSize(20,20))); - User::After(200000); - AddExpectedPointerEvent(TPointerEvent::EButtonRepeat, ptrPos, TAdvancedPointerEvent::EDefaultPointerNumber); - break; - case 7: - // pointer0 sends up - SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 0); - AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, TAdvancedPointerEvent::EDefaultPointerNumber); - - // pointer2 sends out-of-range - SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, ptrPos.iX, ptrPos.iY, 0, 0); - AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, TAdvancedPointerEvent::EDefaultPointerNumber); - - // Send up and out-of-range for pointer1 and 4 - SimulatePointerEvent(TRawEvent::EButton1Up, 0, 0, 0, 1); - SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 1); - - if (4 < iMaxDevPointers) - { - SimulatePointerEvent(TRawEvent::EButton1Up, 0, 0, 0, 4); - SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 4); - } - break; - case 8: - // Autofocus does not work for other than primary pointers - // Create group window which will send focus lost and gained - TRAPD(err, CreateGroupWinL()); // it cannot leave so trap and fail - if (err != KErrNone) - { - Failed(); - } - AddExpectedWsEvent(EEventFocusLost); - AddExpectedWsEvent(EEventFocusGained); - - // Simulate Epointer down which will send focuslost, focusgained and focusgroupchanged events - SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 0); - AddExpectedWsEvent(EEventFocusLost); - AddExpectedWsEvent(EEventFocusGained); - AddExpectedWsEvent(EEventFocusGroupChanged); - AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); - - // Now simulate EButton1Down from first or second pointer on second group - // This should not reflect the autofocus - ptrPos.iX = 60; - ptrPos.iY = 60; - SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 1); - if (2 < iMaxDevPointers) - { - SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 2); - } - SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 1); - if (2 < iMaxDevPointers) - { - SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 2); - } - SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 0); - AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); - SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 0); - AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); - break; - case 9: - // First thing to do in this case is to delete the group window created - DeleteGroupWin(); - - TRAP(err, CreateAnimDllAndAnimL()); // it cannot leave so trap and fail - if (err != KErrNone) - { - Failed(); - } - - // This is the first event which makes first pointer as primary - // When the last argument is EFalse, it means that the event is not consumed by Anim - iAnim->AddExpectedAnimPointerEvent(TRawEvent::EPointerMove, ptrPos, 0, 0, 0, EFalse); - AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, 0, 0); - - // Now simulate moves from other pointers and these events are not sent to anim - for (ptrNum = 1; ptrNum < iMaxDevPointers; ptrNum++) - { - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); - SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum); - } - - // This is to reset the primary pointer - iAnim->AddExpectedAnimPointerEvent(TRawEvent::EPointer3DOutOfRange, ptrPos, 0, 0, 0, EFalse); - AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); - SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 0); - - // Now simulate EButton1Down, which will make it as primary - iAnim->AddExpectedAnimPointerEvent(TRawEvent::EButton1Down, ptrPos, 0, 0, 1, EFalse); - AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); - SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 1); - - // Simulate move or Ebutton1Down from any other prointer they are not sent back to client - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, 0); - SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 0); - SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 0); - - iAnim->AddExpectedAnimPointerEvent(TRawEvent::EButton1Up, ptrPos, 0, 0, 1, EFalse); - AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); - SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 1); - - iAnim->AddExpectedAnimPointerEvent(TRawEvent::EPointer3DOutOfRange, ptrPos, 0, 0, 1, EFalse); - AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); - SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 1); - - // Set the primary pointer to Zero - iAnim->AddExpectedAnimPointerEvent(TRawEvent::EButton1Down, ptrPos, 0, 0, 0, EFalse); - AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); - SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 0); - - // Move from second pointer - // As EnableMultiPointer is not called and this is not a primary pointer so this event - // will cause the pointer 1 into move state - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, 1); - - // Take the zero pointer out-of-range - iAnim->AddExpectedAnimPointerEvent(TRawEvent::EButton1Up, ptrPos, 0, 0, 0, EFalse); - AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); - SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 0); - - iAnim->AddExpectedAnimPointerEvent(TRawEvent::EPointer3DOutOfRange, ptrPos, 0, 0, 0, EFalse); - AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); - SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 0); - - // These moves will not be sent - ptrPos.iX += 10; - ptrPos.iY += 10; - - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, 1); - SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 1); - SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 1); - - TestAndDisplayAnimError(); - - _LIT(KEventsChecked, "Events checked at server side = %d"); - logText.Format(KEventsChecked, 10); - LOG_MESSAGE(logText); - break; - case 10: - DestroyAnimDllAndAnim(); - - // Test for PointerMove buffers - // AllocPointerMoveBuffer, EnablePointerMoveBuffer and then simulate few moves - // Add these moves to another points buffer for testing - // Simulate moves from other pointers, these should not be delivered to clients. - iMultiPtrEventClient->ParentWin()->BaseWin()->AllocPointerMoveBuffer(10, 0); - iMultiPtrEventClient->ParentWin()->BaseWin()->EnablePointerMoveBuffer(); - - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, 0, 0); - AddExpectedWsEvent(EEventPointerBufferReady, EFalse, TAdvancedPointerEvent::EDefaultPointerNumber, (TUint)iMultiPtrEventClient->ParentWin()); - iMultiPtrEventClient->AddExpectedMovePoint(ptrPos); // If this position is above some other window then we need to consider its window postion also - ptrPos.iX += 10; - ptrPos.iY += 10; - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, 0, 0); - iMultiPtrEventClient->AddExpectedMovePoint(ptrPos); - ptrPos.iX += 10; - ptrPos.iY += 10; - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, 0, 0); - iMultiPtrEventClient->AddExpectedMovePoint(ptrPos); - - // These events should not be added to buffer - for (ptrNum = 1; ptrNum < iMaxDevPointers; ptrNum++) - { - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, 0, ptrNum); - ptrPos.iX += 10; - ptrPos.iY += 10; - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, 0, ptrNum); - SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum); - } - break; - case 11: - // Repeat the above for drag events - SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 0); - AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); - - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, 0, 0); - AddExpectedWsEvent(EEventPointerBufferReady, EFalse, TAdvancedPointerEvent::EDefaultPointerNumber, (TUint)iMultiPtrEventClient->ParentWin()); - iMultiPtrEventClient->AddExpectedMovePoint(ptrPos); - ptrPos.iX += 10; - ptrPos.iY += 10; - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, 0, 0); - iMultiPtrEventClient->AddExpectedMovePoint(ptrPos); - ptrPos.iX += 10; - ptrPos.iY += 10; - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, 0, 0); - iMultiPtrEventClient->AddExpectedMovePoint(ptrPos); - - // These events should not be added to buffer - for (ptrNum = 1; ptrNum < iMaxDevPointers; ptrNum++) - { - SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum); - ptrPos.iX += 10; - ptrPos.iY += 10; - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, 0, ptrNum); - SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, ptrNum); - SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum); - } - - SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 0); - AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); - SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 0); - AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); - break; - case 12: - iMultiPtrEventClient->ParentWin()->BaseWin()->FreePointerMoveBuffer(); - iMultiPtrEventClient->ParentWin()->BaseWin()->DisablePointerMoveBuffer(); - - // Pointer Cursor Position test - // This event is for simulating primary pointer - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, 0); - // Here I am not adding the event because this event is deleted by another move of same pointer - if (ptrPos != iMultiPtrEventClient->iWs.PointerCursorPosition()) - { - TEST(EFalse); - Failed(); - } - - iMultiPtrEventClient->iWs.SetPointerCursorPosition(TPoint(20,20)); - if (TPoint(20,20) != iMultiPtrEventClient->iWs.PointerCursorPosition()) - { - TEST(EFalse); - Failed(); - } - - // Now simulate moves from other pointer, this should not have any effect on pointer cursor position - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, 1); - - // Now move the primary pointer, and check the pointer cursor position which should be same as position used for move - ptrPos.iX = 30; - ptrPos.iY = 30; - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, 0); - AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, proxValue, 0, TAdvancedPointerEvent::EDefaultPointerNumber); - if (ptrPos != iMultiPtrEventClient->iWs.PointerCursorPosition()) - { - TEST(EFalse); - Failed(); - } - - // Send out-of-range event which will not lead to pointer 1 becoming primary - SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 0); - AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, proxValue, 0, TAdvancedPointerEvent::EDefaultPointerNumber); - - // Now check the pointer cursor position, which should be same - // as primary even if there is other pointer in up state, but that is not primary - if (ptrPos != iMultiPtrEventClient->iWs.PointerCursorPosition()) - { - TEST(EFalse); - Failed(); - } - - // This is to bring the pointer1 to out-of-range state - SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 1); - - // then send move event and then again check the pointer cursor position - ptrPos.iX = 20; - ptrPos.iY = 20; - SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 1); - AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); - if (ptrPos != iMultiPtrEventClient->iWs.PointerCursorPosition()) - { - TEST(EFalse); - Failed(); - } - - SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 1); - AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); - - SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 1); - AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); - break; - case 13: - { - // Pointer Cursor Area test-1 - iOrigPtrCursorArea = iMultiPtrEventClient->iWs.PointerCursorArea(); - TRect ptrCurArea(0,0,40,40); - iMultiPtrEventClient->iWs.SetPointerCursorArea(ptrCurArea); - - // Simulate move from pointer0 in PointerCursorArea - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, 0); - AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, proxValue, 0, TAdvancedPointerEvent::EDefaultPointerNumber); - - // Simulate move from other pointer, This should have no effect - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, 1); - SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 1); - - SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 0); - AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, proxValue, 0, TAdvancedPointerEvent::EDefaultPointerNumber); - - // Repeat the above with moves outside pointer cursor area - ptrPos.iX = 50; - ptrPos.iY = 50; - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, 0); - TPoint pointInCurArea(39, 39); - AddExpectedPointerEvent(TPointerEvent::EMove, pointInCurArea, proxValue, 0, TAdvancedPointerEvent::EDefaultPointerNumber); - - // Simulate move from other pointer, This should have no effect - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, 1); - SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 1); - - SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 0); - AddExpectedPointerEvent(TPointerEvent::EOutOfRange, pointInCurArea, proxValue, 0, TAdvancedPointerEvent::EDefaultPointerNumber); - } - break; - case 14: - { - // Pointer Cursor Area test-2 - // repeat the above test with button1 down - SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 0); - AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); - - // Simulate move from other pointer, This should have no effect - SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 1); - SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 1); - SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 1); - - SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 0); - AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); - - SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 0); - AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); - - // Repeat the above with moves outside pointer cursor area - ptrPos.iX = 50; - ptrPos.iY = 50; - TPoint pointInCurArea(39, 39); - SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 0); - AddExpectedPointerEvent(TPointerEvent::EButton1Down, pointInCurArea, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); - - // Simulate move from other pointer, This should have no effect - SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 1); - SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 1); - SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 1); - - SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 0); - AddExpectedPointerEvent(TPointerEvent::EButton1Up, pointInCurArea, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); - - SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 0); - AddExpectedPointerEvent(TPointerEvent::EOutOfRange, pointInCurArea, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); - } - break; - default: - ClearExpectNonAdvancedPointerEvents(); - iMultiPtrEventClient->iWs.SetPointerCursorArea(iOrigPtrCursorArea); - ResetFlushStopAS(); - break; - } - LogEventsAdded(); - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-ADVANCEDPOINTER-0026 -@SYMPREQ PREQ1226 -@SYMREQ REQ9677, REQ9683 -@SYMTestPriority High -@SYMTestCaseDesc Checks Wserv supports Autofocus for multiple pointers -@SYMTestStatus Implemented - -@SYMTestActions Create 2 group window and respective client windows for it. And simulate EButton1Down on each window consecutively -@SYMTestExpectedResults The received events must match the simulated pointer events -*/ -void CTMultiPtrEventTest::AutoForeGroundForMultiplePointersL() - { - TLogMessageText logText; - _LIT(KSet, "Multiple pointer Auto foreground events: %d of 2"); - logText.AppendFormat(KSet, iEventSet); - LOG_MESSAGE(logText); - - if (!iEventSet) - { - SetAutoFlush(); - AddExpectedWsEvent(EEventFocusGained); // This if for the main groupwindow - iMultiPtrEventClient->ConstructGroupBlankWinL(); - - // These are for child group window creation - AddExpectedWsEvent(EEventFocusLost); // This if for the main groupwindow losing focus - AddExpectedWsEvent(EEventFocusGained); // First group window of this test creation - - AddExpectedWsEvent(EEventFocusLost); // First group window losing focus because of second group creation - AddExpectedWsEvent(EEventFocusGained); // Second group window creation - AddExpectedWsEvent(EEventFocusGroupChanged); // First group window's Enable Focus changed flag is set - } - iMultiPtrEventClient->EventBuffer()->SetEventCount(0); - - TPoint win1PtrPos(20,20); - TPoint win2PtrPos(60,60); - TPoint ptrPos; - TInt autoFocusWin; - switch(iEventSet++) - { - case 0: - for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) - { - if ((ptrNum & 1) == 0) - { - ptrPos = win1PtrPos; - autoFocusWin = 1; - } - else - { - ptrPos = win2PtrPos; - autoFocusWin = 0; - } - SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum); - AddExpectedWsEvent(EEventFocusLost); // Second group window losing focus - AddExpectedWsEvent(EEventFocusGained); // First group window gaining focus - if (ptrNum == 0) - { // First group window has already received EEventFocusGroupChanged - AddExpectedWsEvent(EEventFocusGroupChanged); // Second group window's Enable Focus changed flag is set - } - // In the queue only once EEventFocusGroupChanged is sent - AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, ptrNum); - - SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, ptrNum); - - // These events are to clear out the pointer state - SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, 0, 0, ptrNum); - - if (!iMultiPtrEventClient->CheckOrdinalPosition(autoFocusWin)) - { - TEST(EFalse); - Failed(); - } - } - break; - case 1: - for (TInt ptrNum = iMaxDevPointers/2; ptrNum < iMaxDevPointers; ptrNum++) - { - if ((ptrNum & 1) == 0) - { - ptrPos = win1PtrPos; - autoFocusWin = 1; - } - else - { - ptrPos = win2PtrPos; - autoFocusWin = 0; - } - SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum); - AddExpectedWsEvent(EEventFocusLost); // Second group window losing focus - AddExpectedWsEvent(EEventFocusGained); // First group window gaining focus - if (ptrNum == iMaxDevPointers/2) // first loop - { - // When ever a group window changes focus, For all the group/client windows which have - // registered for receiving group window changes recive EEventFocusGroupChanged - // EEventFocusGroupChanged is sent only once in one queue - AddExpectedWsEvent(EEventFocusGroupChanged); - AddExpectedWsEvent(EEventFocusGroupChanged); - } - AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, ptrNum); - - SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, ptrNum); - - // These events are to clear out the pointer state - SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, 0, 0, ptrNum); - if (!iMultiPtrEventClient->CheckOrdinalPosition(autoFocusWin)) - { - TEST(EFalse); - Failed(); - } - } - break; - default: - iMultiPtrEventClient->DeleteGroupBlankWin(); - ResetFlushStopAS(); - break; - } - - LogEventsAdded(); - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-ADVANCEDPOINTER-0015 -@SYMPREQ PREQ1226 -@SYMREQ REQ9684 -@SYMTestPriority High -@SYMTestCaseDesc Checks Wserv supports out-of-range and pointer Enter/Exit events. -@SYMTestStatus Implemented - -@SYMTestActions Simulate moves and EPointer3DOutOfRange from different pointers -@SYMTestExpectedResults The received events must match the simulated pointer events -*/ -void CTMultiPtrEventTest::MultiPointerOutOfRangeEvents() - { - TLogMessageText logText; - _LIT(KSet, "OutOfRange & Enter/Exit events: %d of 4"); - logText.AppendFormat(KSet, iEventSet); - LOG_MESSAGE(logText); - - if (!iEventSet) - { - SetAutoFlush(); - AddExpectedWsEvent(EEventFocusGained); - } - iMultiPtrEventClient->EventBuffer()->SetEventCount(0); - - TPoint ptrPos(10,10); - TInt proxValue = -iProximityStep; - switch(iEventSet++) - { - case 0: - // Simulate moves and EPointer3DOutOfRange from all pointers - iMultiPtrEventClient->ParentWin()->BaseWin()->PointerFilter(EPointerFilterMove, 0); - for (TInt ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) - { - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, proxValue, 0, ptrNum); - - SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, proxValue, 0, ptrNum); - // Here I am not enabling the enter/exit events filter so not getting those - } - break; - case 1: - // Repeat the above by enabling the enter/exit events - iMultiPtrEventClient->ParentWin()->BaseWin()->PointerFilter(EPointerFilterEnterExit, 0); - for (TInt ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum = ptrNum+2) - { - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); - AddExpectedWsEvent(EEventPointerEnter, EFalse, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, proxValue, 0, ptrNum); - - SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum); - AddExpectedWsEvent(EEventPointerExit, EFalse, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, proxValue, 0, ptrNum); - } - break; - case 2: - // Check the moves from one window to other - for (TInt ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum = ptrNum+2) - { - ptrPos.iX = 10; - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); - AddExpectedWsEvent(EEventPointerEnter, EFalse, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, proxValue, 0, ptrNum); - - ptrPos.iX = (iMultiPtrEventClient->ParentWin()->Size().iWidth)/2 + 10; - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); - AddExpectedWsEvent(EEventPointerExit, EFalse, ptrNum); // move and enter of child window is filtered out - } - break; - case 3: - // Since all the pointers are now on child and when we change the pointer filter - // wserv sends enter event to all pointers - iMultiPtrEventClient->ChildWin()->BaseWin()->PointerFilter(EPointerFilterEnterExit, 0); - for (TInt ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum = ptrNum+2) - { - AddExpectedWsEvent(EEventPointerEnter, EFalse, ptrNum); - } - for (TInt ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum = ptrNum+2) - { - ptrPos.iX = ptrPos.iY =10; - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); - AddExpectedWsEvent(EEventPointerExit, EFalse, ptrNum); - AddExpectedWsEvent(EEventPointerEnter, EFalse, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, proxValue, 0, ptrNum); - - SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum); - AddExpectedWsEvent(EEventPointerExit, EFalse, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, proxValue, 0, ptrNum); - } - break; - default: - ResetFlushStopAS(); - break; - } - - LogEventsAdded(); - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-ADVANCEDPOINTER-0032 -@SYMPREQ PREQ1226 -@SYMREQ REQ9677 -@SYMTestPriority High -@SYMTestCaseDesc Checks Wserv supports Double click events for multi pointer events. -@SYMTestStatus Implemented - -@SYMTestActions Simulate double click events from different pointers -@SYMTestExpectedResults The received events must match the simulated pointer events -*/ -void CTMultiPtrEventTest::DoubleClickForMultiplePointers() - { - // Logic involved, double click settings are global no need to test them - // Check that double click events are sent by wserv for all pointers - TLogMessageText logText; - _LIT(KSet, "Double click settings and events: %d of 1"); - logText.AppendFormat(KSet, iEventSet); - LOG_MESSAGE(logText); - - if (!iEventSet) - { - SetAutoFlush(); - AddExpectedWsEvent(EEventFocusGained); - } - iMultiPtrEventClient->EventBuffer()->SetEventCount(0); - - TPoint ptrPos(10,10); - switch(iEventSet++) - { - case 0: - for (TInt ptrNum = 0; ptrNum < Min(iMaxDevPointers, 7); ptrNum++) - { - SimulatePointerDownUp(ptrPos.iX, ptrPos.iY, 0, ptrNum); - SimulatePointerDownUp(ptrPos.iX, ptrPos.iY, 0, ptrNum); - AddExpectedPointerDownUp(ptrPos, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, EModifierDoubleClick, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, ptrNum); - } - break; - default: - ResetFlushStopAS(); - break; - } - - LogEventsAdded(); - } - - -/** -@SYMTestCaseID GRAPHICS-WSERV-ADVANCEDPOINTER-0031 -@SYMPREQ PREQ1226 -@SYMREQ REQ9677 -@SYMTestPriority High -@SYMTestCaseDesc Checks Wserv supports Virtual keyboard for multi pointer events. -@SYMTestStatus Implemented - -@SYMTestActions Create virtual keyboard by AddKeyRect() to a window and simulate pointer events from all pointers -@SYMTestExpectedResults The received events must match the simulated Key events -*/ -void CTMultiPtrEventTest::VirtualKeyBoardForMultiplePointers() - { - TLogMessageText logText; - _LIT(KSet, "VirtualKeyboard SetOfEvents: %d of 8"); - logText.AppendFormat(KSet, iEventSet); - LOG_MESSAGE(logText); - - // Create virtual keyboard for 8 keys on parent window - // give a 5 pixel spacing at start/end and in between keys - const TInt noVirtualKeys = iMaxDevPointers; - const TInt keySpacing = 5; - const TInt keyWidth = ((iPhysicalScreenSize.iWidth/2) - ((noVirtualKeys+1)*keySpacing))/noVirtualKeys; - const TInt keyHeight = keyWidth/2; - TInt startX = keySpacing; - const TInt baseChar ='A'; - - if (!iEventSet) - { - SetAutoFlush(); - for (TInt count=0; count < noVirtualKeys; count++) - { - iMultiPtrEventClient->ParentWin()->BaseWin()->AddKeyRect(TRect(startX, keySpacing, startX+keyWidth, keySpacing+keyHeight), baseChar+count,EFalse); - startX+=(keyWidth+keySpacing); - } - AddExpectedWsEvent(EEventFocusGained); - } - - iMultiPtrEventClient->EventBuffer()->SetEventCount(0); - TPoint ptrPos(keySpacing+(keyWidth/2), keySpacing+(keyHeight/2)); - - TInt count = 0; - if (iEventSet < iMaxDevPointers) - { - for (; ptrPos.iX < (iPhysicalScreenSize.iWidth/2)-5; ptrPos.iX += (keySpacing+keyWidth), count++) - { - SimulatePointerDownUp(ptrPos.iX, ptrPos.iY, 0, iEventSet); - AddExpectedKeyDownUp(baseChar+count); - } - } - else - { - ResetFlushStopAS(); - } - iEventSet++; - - LogEventsAdded(); - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-ADVANCEDPOINTER-0021 -@SYMPREQ PREQ1226 -@SYMREQ REQ9677,REQ9683, -@SYMTestPriority High -@SYMTestCaseDesc Checks Wserv supports Grabbing in case of multi pointer events. -@SYMTestStatus Implemented - -@SYMTestActions Simulate EButton1Down events on iParentWin. Simulate Drag and Button1Up events on iChildWin. - SetPointerGrab is called on iParentWin for first test and disabled for the second. -@SYMTestExpectedResults The Drag and Button1Up events contain a handle to iParentWin when Grabbing active. - The Drag and Button1Up events contain a handle to iChildWin when Grabbing disabled. -*/ -void CTMultiPtrEventTest::GrabbingMultiPointerEvents() - { - // Test Grabbing of multi pointer events - // 1. Test Wserv supports Grabbing in case of multi-pointer events - // 2. Test pointer events are delivered correctly when Grabbing is disabled. - TLogMessageText logText; - _LIT(KSet, "GrabbingMultiPtrEvents SetOfEvents: %d of 2"); - logText.AppendFormat(KSet, iEventSet); - LOG_MESSAGE(logText); - - if (!iEventSet) - { - SetAutoFlush(); - } - - iMultiPtrEventClient->EventBuffer()->SetEventCount(0); - - TPoint ptrPos; - - switch(iEventSet++) - { - case 0: - INFO_PRINTF1(_L("Check Wserv supports Grabbing in case of multi-pointer events")); - // Check pointer events are delivered to the window where the EButton1Down event occured, - // even if subsequent events are simulated outside this window. - AddExpectedWsEvent(EEventFocusGained); - iMultiPtrEventClient->ParentWin()->BaseWin()->PointerFilter(EPointerFilterDrag, 0); - iMultiPtrEventClient->ParentWin()->BaseWin()->SetPointerGrab(ETrue); - TestGrabbingForMultiPointer(ETrue); - break; - case 1: - INFO_PRINTF1(_L("Check pointer events are delivered correctly when Grabbing is disabled.")); - // Check pointer events are delivered to the window on which they occured. - iMultiPtrEventClient->ParentWin()->BaseWin()->SetPointerGrab(EFalse); - TestGrabbingForMultiPointer(EFalse); - break; - default: - ResetFlushStopAS(); - break; - } - LogEventsAdded(); - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-ADVANCEDPOINTER-0025 -@SYMPREQ PREQ1226 -@SYMREQ REQ9677,REQ9683, -@SYMTestPriority High -@SYMTestCaseDesc Checks Wserv supports Filtering in case of multi pointer events. -@SYMTestStatus Implemented - -@SYMTestActions Simulate Move and Drag events. Add only Button1Up and Button1Down to TWsEvent buffer. - Disable Filtering and repeat test with the addition of Move and Drag events to TWsEvent buffer. -@SYMTestExpectedResults The received events must match the expected simulated raw events - The received events must match the simulated raw events -*/ -void CTMultiPtrEventTest::FilteringMultiPointerEvents() - { - // Test Filtering of multi pointer events - // 1. Test pointer move and drag events are filtered correctly by Wserv - // 2. Test pointer events are delivered correctly when Filtered is disabled. - TLogMessageText logText; - _LIT(KSet, "FilteringMultiPtrEvents SetOfEvents: %d of 2"); - logText.AppendFormat(KSet, iEventSet); - LOG_MESSAGE(logText); - - if (!iEventSet) - { - SetAutoFlush(); - } - - iMultiPtrEventClient->EventBuffer()->SetEventCount(0); - - TPoint ptrPos; - - switch(iEventSet++) - { - case 0: - INFO_PRINTF1(_L("Check pointer move and drag events are filtered with multi-pointer events")); - // Check pointer move and drag events are filtered by Wserv - AddExpectedWsEvent(EEventFocusGained); - - // Ensure default values are set i.e. Drag and Move events are filtered out and not delivered to the client. - iMultiPtrEventClient->ParentWin()->BaseWin()->PointerFilter(EPointerFilterDrag|EPointerFilterMove, - EPointerFilterDrag|EPointerFilterMove); - TestFilteringForMultiPointer(ETrue); - break; - case 1: - INFO_PRINTF1(_L("Check pointer move and drag events are not filtered, with multi-pointer events, when filtering is disabled")); - // Check move and drag events are not filtered by Wserv when filtering is disabled - - // Enable Drag and Move events - iMultiPtrEventClient->ParentWin()->BaseWin()->PointerFilter(EPointerFilterDrag|EPointerFilterMove, 0); - TestFilteringForMultiPointer(EFalse); - break; - default: - ResetFlushStopAS(); - break; - } - LogEventsAdded(); - } - -void CTMultiPtrEventTest::SetDefaultScreenMode() - { - iMultiPtrEventClient->iScreen->SetAppScreenMode(0); - TheClient->iScreen->SetAppScreenMode(0); - iMultiPtrEventClient->iScreen->SetScreenMode(0); - iMultiPtrEventClient->iScreen->SetCurrentRotations(0, CFbsBitGc::EGraphicsOrientationNormal); - } - -TPoint PhysicalToLogical(TPoint aPhysicalPt, TPoint aOrigin, TSize aSize) - { - return PhysicalToLogical(aPhysicalPt-aOrigin, aSize); - } - -TPoint CTMultiPtrEventTest::GetPointerPostionOnRotatedMode(TPoint aPointerPos, CFbsBitGc::TGraphicsOrientation aRotation) - { - if (aRotation == CFbsBitGc::EGraphicsOrientationNormal) - { - return aPointerPos; - } - else if (aRotation == CFbsBitGc::EGraphicsOrientationRotated90) - { - // here width is actually height in rotated mode - return TPoint(iPhysicalScreenSize.iWidth - aPointerPos.iY - 1, aPointerPos.iX); - } - else if (aRotation == CFbsBitGc::EGraphicsOrientationRotated180) - { - return TPoint(iPhysicalScreenSize.iWidth - aPointerPos.iX - 1, iPhysicalScreenSize.iHeight - aPointerPos.iY - 1); - } - else if (aRotation == CFbsBitGc::EGraphicsOrientationRotated270) - { - // here width is actually height in rotated mode - return TPoint(aPointerPos.iY, iPhysicalScreenSize.iHeight - aPointerPos.iX -1); - } - return TPoint(0,0); - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-ADVANCEDPOINTER-0028 -@SYMPREQ PREQ1226 -@SYMREQ REQ9677, REQ9683 -@SYMTestPriority High -@SYMTestCaseDesc To check Wserv sends multi pointer events in Different screen modes -@SYMTestStatus Implemented - -@SYMTestActions Simulate multi pointer events in Different screenmodes -@SYMTestExpectedResults The received events must match the simulated raw events -*/ -void CTMultiPtrEventTest::MultiPointerEventsInDiffScreenModes() - { - // Logic inloved, For a particular screen mode check pointer down/up, moves and drags - // for different pointers and for different co-ordinates. - // For each screen mode check these events on diffferent rotation that screen mode supports - // During the last switch case increment the screenmode - TLogMessageText logText; - _LIT(KSet, "Multi pointer events in screenmode(%d): %d of 2"); - logText.AppendFormat(KSet, iCurrentScreenMode+1, iEventSet); - LOG_MESSAGE(logText); - - TInt numScrMode = iMultiPtrEventClient->iScreen->NumScreenModes(); - iMultiPtrEventClient->EventBuffer()->SetEventCount(0); - - if (!iEventSet && !iChangeScreenMode) - { - SetAutoFlush(); - iChangeScreenMode = ETrue; - AddExpectedWsEvent(EEventFocusGained); - } - else - { - if (iChangeScreenMode) - { - if (iCurrentScreenMode >= numScrMode) - { -EndFun: - SetDefaultScreenMode(); - ResetFlushStopAS(); - return; - } - } - } - - if (iChangeScreenMode) - { - iMultiPtrEventClient->iScreen->SetAppScreenMode(iCurrentScreenMode); - TheClient->iScreen->SetAppScreenMode(iCurrentScreenMode); - iMultiPtrEventClient->iScreen->SetScreenMode(iCurrentScreenMode); - iChangeScreenMode = EFalse; - } - - CArrayFixFlat* rotations = NULL; - TRAPD(err, - rotations = new(ELeave) CArrayFixFlat(1); - iMultiPtrEventClient->iScreen->GetRotationsList(iCurrentScreenMode, rotations)); - if (err != KErrNone) - { - if (iEventSet) - { - goto EndFun; - } - else - { - return; - } - } - -#if !defined(__WINS__) - TPoint ptrRotatedPos; - TPoint ptrNormalPos; -#else - TPoint ptrPhyPos; -#endif - TPoint ptrLogPos; - - TInt ptrNum = 0; - TInt proxValue = 0; - // Since screenmode positioning and screenmode scaling is not supported in NGA wserv2 - // but it is supported in Non NGA. But for NGA it will return (0,0) as origin and (1,1) as scale. - TPoint screenOrigin(iMultiPtrEventClient->iScreen->GetDefaultScreenModeOrigin()); - TPoint scaledScreenOrigin(iMultiPtrEventClient->iScreen->GetCurrentScreenModeScaledOrigin()); - TSize scale(iMultiPtrEventClient->iScreen->GetCurrentScreenModeScale()); - - switch(iEventSet++) - { - case 0: - // Simulate Pointer down/up for different rotations of a screenmode - for (TInt rotCou = 0; rotCou < rotations->Count(); rotCou++) - { - CFbsBitGc::TGraphicsOrientation newOrientation = static_cast(rotations[0][rotCou]); - iMultiPtrEventClient->iScreen->SetCurrentRotations(iCurrentScreenMode, newOrientation); - -#if !defined(__WINS__) - ptrNormalPos = screenOrigin; - ptrRotatedPos = GetPointerPostionOnRotatedMode(ptrNormalPos, newOrientation); - SimulatePointerDownUp(ptrRotatedPos.iX, ptrRotatedPos.iY, 0, ptrNum); - ptrLogPos = PhysicalToLogical(ptrNormalPos, screenOrigin, scale); - AddExpectedPointerDownUp(ptrLogPos, 0, ptrNum); - - ptrNormalPos.iX += 10; - ptrNormalPos.iY += 5; - ptrNum = iMaxDevPointers/2; - ptrRotatedPos = GetPointerPostionOnRotatedMode(ptrNormalPos, newOrientation); - SimulatePointerDownUp(ptrRotatedPos.iX, ptrRotatedPos.iY, 0, ptrNum); - ptrLogPos = PhysicalToLogical(ptrNormalPos, screenOrigin, scale); - AddExpectedPointerDownUp(ptrLogPos, 0, ptrNum); - - ptrNormalPos.iX += 5; - ptrNormalPos.iY += 10; - ptrNum = iMaxDevPointers-1; - ptrRotatedPos = GetPointerPostionOnRotatedMode(ptrNormalPos, newOrientation); - SimulatePointerDownUp(ptrRotatedPos.iX, ptrRotatedPos.iY, 0, ptrNum); - ptrLogPos = PhysicalToLogical(ptrNormalPos, screenOrigin, scale); - AddExpectedPointerDownUp(ptrLogPos, 0, ptrNum); - ptrNum = 0; -#else - // This is not needed for NGA, becasue NGA wserv does not support positioning and scaling - // but for early access we are deliverying for NonNGA so we need it. - ptrPhyPos = screenOrigin; - ptrLogPos = PhysicalToLogical(ptrPhyPos, screenOrigin, scale); - SimulatePointerDownUp(ptrPhyPos.iX, ptrPhyPos.iY, 0, ptrNum); - AddExpectedPointerDownUp(ptrLogPos, 0, ptrNum); - ptrPhyPos.iX += 10; - ptrPhyPos.iY += 5; - ptrNum = iMaxDevPointers/2; - ptrLogPos = PhysicalToLogical(ptrPhyPos, screenOrigin, scale); - SimulatePointerDownUp(ptrPhyPos.iX, ptrPhyPos.iY, 0, ptrNum); - AddExpectedPointerDownUp(ptrLogPos, 0, ptrNum); - ptrPhyPos.iX += 5; - ptrPhyPos.iY += 10; - ptrNum = iMaxDevPointers-1; - ptrLogPos = PhysicalToLogical(ptrPhyPos, screenOrigin, scale); - SimulatePointerDownUp(ptrPhyPos.iX, ptrPhyPos.iY, 0, ptrNum); - AddExpectedPointerDownUp(ptrLogPos, 0, ptrNum); - ptrNum = 0; -#endif - } - break; - case 1: - // Simulate moves for different rotations of a screenmode with different Proximity - iMultiPtrEventClient->ParentWin()->BaseWin()->PointerFilter(EPointerFilterMove,0); - for (TInt rotCou = 0; rotCou < rotations->Count(); rotCou++) - { - CFbsBitGc::TGraphicsOrientation newOrientation = static_cast(rotations[0][rotCou]); - iMultiPtrEventClient->iScreen->SetCurrentRotations(iCurrentScreenMode, newOrientation); - -#if !defined(__WINS__) - ptrNormalPos = screenOrigin; - ptrRotatedPos = GetPointerPostionOnRotatedMode(ptrNormalPos, newOrientation); - proxValue = -iProximityStep; - SimulatePointerEvent(TRawEvent::EPointerMove, ptrRotatedPos.iX, ptrRotatedPos.iY, proxValue, ptrNum); - ptrLogPos = PhysicalToLogical(ptrNormalPos, screenOrigin, scale); - AddExpectedPointerEvent(TPointerEvent::EMove, ptrLogPos, proxValue, 0, ptrNum); - SimulatePointerDownUp(ptrRotatedPos.iX, ptrRotatedPos.iY, 0, ptrNum); - AddExpectedPointerDownUp(ptrLogPos, 0, ptrNum); - - ptrNormalPos.iX += 10; - ptrNormalPos.iY += 5; - ptrNum = iMaxDevPointers/2; - if (proxValue-iProximityStep > iMaxProximity) - { - proxValue -= iProximityStep; - } - ptrRotatedPos = GetPointerPostionOnRotatedMode(ptrNormalPos, newOrientation); - SimulatePointerEvent(TRawEvent::EPointerMove, ptrRotatedPos.iX, ptrRotatedPos.iY, proxValue, ptrNum); - ptrLogPos = PhysicalToLogical(ptrNormalPos, screenOrigin, scale); - AddExpectedPointerEvent(TPointerEvent::EMove, ptrLogPos, proxValue, 0, ptrNum); - SimulatePointerDownUp(ptrRotatedPos.iX, ptrRotatedPos.iY, 0, ptrNum); - AddExpectedPointerDownUp(ptrLogPos, 0, ptrNum); - ptrNum = 0; -#else - ptrPhyPos = screenOrigin; - proxValue = -iProximityStep; - ptrLogPos = PhysicalToLogical(ptrPhyPos, screenOrigin, scale); - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPhyPos.iX, ptrPhyPos.iY, proxValue, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EMove, ptrLogPos, proxValue, 0, ptrNum); - SimulatePointerDownUp(ptrPhyPos.iX, ptrPhyPos.iY, 0, ptrNum); - AddExpectedPointerDownUp(ptrLogPos, 0, ptrNum); - - ptrPhyPos.iX += 10; - ptrPhyPos.iY += 5; - ptrNum = iMaxDevPointers/2; - if (proxValue-iProximityStep > iMaxProximity) - { - proxValue -= iProximityStep; - } - ptrLogPos = PhysicalToLogical(ptrPhyPos, screenOrigin, scale); - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPhyPos.iX, ptrPhyPos.iY, proxValue, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EMove, ptrLogPos, proxValue, 0, ptrNum); - SimulatePointerDownUp(ptrPhyPos.iX, ptrPhyPos.iY, 0, ptrNum); - AddExpectedPointerDownUp(ptrLogPos, 0, ptrNum); - ptrNum = 0; -#endif - } - break; - case 2: - { - // Simulate drags for different rotations of a screenmode -#if !defined(__WINS__) - TPoint intNormalPt; - TPoint intRotatedPt; -#else - TPoint interPhyPt; - TPoint interLogPt; -#endif - iMultiPtrEventClient->ParentWin()->BaseWin()->PointerFilter(EPointerFilterDrag,0); - for (TInt rotCou = 0; rotCou < rotations->Count(); rotCou++) - { - CFbsBitGc::TGraphicsOrientation newOrientation = static_cast(rotations[0][rotCou]); - iMultiPtrEventClient->iScreen->SetCurrentRotations(iCurrentScreenMode, newOrientation); -#if !defined(__WINS__) - ptrNormalPos = screenOrigin; - intNormalPt.iX = ptrNormalPos.iX+4; - intNormalPt.iY = ptrNormalPos.iY+5; - ptrRotatedPos = GetPointerPostionOnRotatedMode(ptrNormalPos, newOrientation); - intRotatedPt = GetPointerPostionOnRotatedMode(intNormalPt, newOrientation); - SimulatePointerEvent(TRawEvent::EButton1Down, ptrRotatedPos.iX, ptrRotatedPos.iY, 0, ptrNum); - SimulatePointerEvent(TRawEvent::EPointerMove, intRotatedPt.iX, intRotatedPt.iY, 0, ptrNum); - SimulatePointerEvent(TRawEvent::EButton1Up, intRotatedPt.iX, intRotatedPt.iY, 0, ptrNum); - ptrLogPos = PhysicalToLogical(ptrNormalPos, screenOrigin, scale); - AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrLogPos, 0, 0, ptrNum); - TPoint intLogPt = PhysicalToLogical(intNormalPt, screenOrigin, scale); - AddExpectedPointerEvent(TPointerEvent::EDrag, intLogPt, 0, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EButton1Up, intLogPt, 0, 0, ptrNum); - - ptrNormalPos.iX += 10; - ptrNormalPos.iY += 5; - ptrNum = iMaxDevPointers-1; - intNormalPt.iX = ptrNormalPos.iX+5; - intNormalPt.iY = ptrNormalPos.iY+4; - ptrRotatedPos = GetPointerPostionOnRotatedMode(ptrNormalPos, newOrientation); - intRotatedPt = GetPointerPostionOnRotatedMode(intNormalPt, newOrientation); - SimulatePointerEvent(TRawEvent::EButton1Down, ptrRotatedPos.iX, ptrRotatedPos.iY, 0, ptrNum); - SimulatePointerEvent(TRawEvent::EPointerMove, intRotatedPt.iX, intRotatedPt.iY, 0, ptrNum); - SimulatePointerEvent(TRawEvent::EButton1Up, intRotatedPt.iX, intRotatedPt.iY, 0, ptrNum); - ptrLogPos = PhysicalToLogical(ptrNormalPos, screenOrigin, scale); - AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrLogPos, 0, 0, ptrNum); - intLogPt = PhysicalToLogical(intNormalPt, screenOrigin, scale); - AddExpectedPointerEvent(TPointerEvent::EDrag, intLogPt, 0, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EButton1Up, intLogPt, 0, 0, ptrNum); - - ptrNum = 0; -#else - ptrPhyPos = screenOrigin; - interPhyPt.iX = ptrPhyPos.iX+4; - interPhyPt.iY = ptrPhyPos.iY+5; - ptrLogPos = PhysicalToLogical(ptrPhyPos, screenOrigin, scale); - interLogPt = PhysicalToLogical(interPhyPt, screenOrigin, scale); - SimulatePointerEvent(TRawEvent::EButton1Down, ptrPhyPos.iX, ptrPhyPos.iY, 0, ptrNum); - SimulatePointerEvent(TRawEvent::EPointerMove, interPhyPt.iX, interPhyPt.iY, 0, ptrNum); - SimulatePointerEvent(TRawEvent::EButton1Up, interPhyPt.iX, interPhyPt.iY, 0, ptrNum); - interLogPt = PhysicalToLogical(interPhyPt, screenOrigin, scale); - AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrLogPos, 0, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EDrag, interLogPt, 0, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EButton1Up, interLogPt, 0, 0, ptrNum); - - ptrPhyPos.iX += 10; - ptrPhyPos.iY += 5; - ptrNum = iMaxDevPointers-1; - interPhyPt.iX = ptrPhyPos.iX+5; - interPhyPt.iY = ptrPhyPos.iY+4; - - SimulatePointerEvent(TRawEvent::EButton1Down, ptrPhyPos.iX, ptrPhyPos.iY, 0, ptrNum); - SimulatePointerEvent(TRawEvent::EPointerMove, interPhyPt.iX, interPhyPt.iY, 0, ptrNum); - SimulatePointerEvent(TRawEvent::EButton1Up, interPhyPt.iX, interPhyPt.iY, 0, ptrNum); - - ptrLogPos = PhysicalToLogical(ptrPhyPos, screenOrigin, scale); - interLogPt = PhysicalToLogical(interPhyPt, screenOrigin, scale); - AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrLogPos, 0, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EDrag, interLogPt, 0, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EButton1Up, interLogPt, 0, 0, ptrNum); - ptrNum = 0; -#endif - } - } - iChangeScreenMode = ETrue; - iEventSet = 0; - iCurrentScreenMode++; - break; - default: - break; - } - - delete rotations; - - LogEventsAdded(); - } - -/* - Checks if pointer click plugin has an error when testing its events - If so then it gets the error deescription and displays the same - */ -void CTMultiPtrEventTest::TestAndDisplayPtrClickError() - { - TPckgBuf intPkg; - TInt retErr = iClick.CommandReply(EMultiPtrClickEventError, intPkg); - if (retErr != KErrNone) - { - _LIT(KError, "Failed in Pointer click plugin"); - LOG_MESSAGE(KError); - // Error is ignored here, becasue this function should not leave - TRAPD(errMem, iErrDesc = iHeap->AllocL(KErrDescSize)); - if (errMem == KErrNone) - { - intPkg() = reinterpret_cast(iErrDesc) - iChunk.Base() ; - - // get the error desccription, print it out and stop the tests - TInt retVal = iClick.CommandReply(EADllMultiPtrEventErrorDesc, intPkg); - if (retVal > KErrNone) - { - TPtr8 memPtr2(reinterpret_cast(iErrDesc), retVal, retVal); - HBufC16* buf16 = NULL; - TRAPD(err, buf16 = HBufC16::NewL(retVal)); // Error is ignored here - if (err == KErrNone) - { - buf16->Des().Copy(memPtr2); - LOG_MESSAGE(buf16->Des()); - delete buf16; - } - } - iHeap->Free(iErrDesc); - } - Failed(); - } - iClick.CommandReply(EMultiPtrClickEventReset, intPkg); - } - -void CTMultiPtrEventTest::AddExpectedMultiPtrClickEvent(TPointerEvent::TType aType, TPoint aPos, TInt aZ, TUint aModifier, TUint8 aPointerNumber, TUint aHandle) - { - TPckgBuf evtPkg; - TWsEvent& event=evtPkg(); - event.SetType(EEventPointer); - iMultiPtrEventClient->CalculatePtrPosAndSet3Ddata(event, aType, aPos, aModifier, aZ, aPointerNumber, aHandle); - - // change the parent position here as they r with respect to screen corodinates. - event.Pointer()->iParentPosition = aPos; - - iClick.CommandReply(EMultiPtrClickEventAdd, evtPkg); - AddExpectedMultiPtrClickOtherEvent(aType, aPos, aZ, aModifier, aPointerNumber, aHandle); - } - -void CTMultiPtrEventTest::AddExpectedMultiPtrClickOtherEvent(TPointerEvent::TType aType, TPoint aPos, TInt aZ, TUint aModifier, TUint8 aPointerNumber, TUint aHandle) - { - TWsEvent event; - event.SetType(EEventPointer); - iMultiPtrEventClient->CalculatePtrPosAndSet3Ddata(event, aType, aPos, aModifier, aZ, aPointerNumber, aHandle); - - TPointerEventData otherEvent; - otherEvent.iClientHandle = event.Handle(); - otherEvent.iCurrentPos = aPos; - otherEvent.iPointerEvent = *event.Pointer(); - - TPckgBuf evtPkg(otherEvent); - iClick.CommandReply(EMultiPtrOtherEventAdd, evtPkg); - } - -/* - Function of creating - 1. Pointer click plugin - 2. RChunk for transfering error description from pointer click plugin to current test - 3. RHeap for allocating memory in RChunk -*/ -void CTMultiPtrEventTest::CreatePointerClickPluginL() - { - // tranfer this to another function - iClick=RSoundPlugIn(TheClient->iWs); - User::LeaveIfError(iClick.Construct(TUid::Uid(MULTIPTR_CLICK_THIRD_UID))); - TBool ptrPluginLoadable = EFalse; - iClick.IsLoaded(ptrPluginLoadable); - if (ptrPluginLoadable) - { - User::LeaveIfError(iClick.Load(KMultiPtrPluginDll)); - iPtrPluginLoaded = ETrue; - } - iClick.SetPenClick(ETrue); - iHeap = UserHeap::ChunkHeap(&KMultiPtrClickChunk, 128, 256, 10); - if (iHeap == NULL) - { - User::LeaveNoMemory(); - } - User::LeaveIfError(iChunk.OpenGlobal(KMultiPtrClickChunk, ETrue)); - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-ADVANCEDPOINTER-0027 -@SYMPREQ PREQ1226 -@SYMREQ REQ9677, REQ9683 -@SYMTestPriority High -@SYMTestCaseDesc To check Wserv sends multi pointer events to PointerClickPlugin -@SYMTestStatus Implemented - -@SYMTestActions Simulate multi pointer events for PointerClickPlugin -@SYMTestExpectedResults The received events must match the simulated raw events -*/ -void CTMultiPtrEventTest::MultiPointerEventsForPointerClickL() - { - TLogMessageText logText; - _LIT(KSet, "Multi pointer events for PointerClickPlugin: %d of 4"); - logText.AppendFormat(KSet, iEventSet); - LOG_MESSAGE(logText); - - iMultiPtrEventClient->EventBuffer()->SetEventCount(0); - if (!iEventSet) - { - SetAutoFlush(); - } - - TPoint ptrPos; - TInt ptrNum = 0; - TInt prValue = 0; - TInt proxValue = 0; - TInt xInc = iPhysicalScreenSize.iWidth/iMaxDevPointers; - TInt yInc = iPhysicalScreenSize.iHeight/iMaxDevPointers; - - switch(iEventSet++) - { - case 0: - // Creates RSoundPlugin, loads the plugin DLL, create RChunk and RHeap - CreatePointerClickPluginL(); - AddExpectedWsEvent(EEventFocusGained); - for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) - { - AddExpectedMultiPtrClickEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, ptrNum); - AddExpectedMultiPtrClickEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, ptrNum); - AddExpectedPointerDownUp(ptrPos, 0, ptrNum); - SimulatePointerDownUp(ptrPos.iX, ptrPos.iY, 0, ptrNum); - ptrPos.iX += xInc; - ptrPos.iY += yInc; - } - TestAndDisplayPtrClickError(); - break; - case 1: - // Simulate moves from different pointer with different pressure - iMultiPtrEventClient->ParentWin()->BaseWin()->PointerFilter(EPointerFilterMove,0); - iMultiPtrEventClient->ChildWin()->BaseWin()->PointerFilter(EPointerFilterMove,0); - ptrPos.SetXY(0,0); - prValue = iPressureStep; - for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) - { - AddExpectedMultiPtrClickEvent(TPointerEvent::EMove, ptrPos, prValue, 0, ptrNum); - AddExpectedMultiPtrClickEvent(TPointerEvent::EButton1Down,ptrPos,0,0,ptrNum); - AddExpectedMultiPtrClickEvent(TPointerEvent::EButton1Up,ptrPos,0,0,ptrNum); - AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, prValue, 0, ptrNum); - AddExpectedPointerDownUp(ptrPos, 0, ptrNum); - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, prValue, ptrNum); - SimulatePointerDownUp(ptrPos.iX, ptrPos.iY, 0, ptrNum); - ptrPos.iX += xInc; - ptrPos.iY += yInc; - } - TestAndDisplayPtrClickError(); - break; - case 2: - // Simulate moves from different pointer with different proximity - ptrPos.SetXY(0,0); - proxValue = -iProximityStep; - for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) - { - AddExpectedMultiPtrClickEvent(TPointerEvent::EMove, ptrPos, proxValue, 0, ptrNum); - AddExpectedMultiPtrClickEvent(TPointerEvent::EButton1Down,ptrPos,0,0,ptrNum); - AddExpectedMultiPtrClickEvent(TPointerEvent::EButton1Up,ptrPos,0,0,ptrNum); - AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, proxValue, 0, ptrNum); - AddExpectedPointerDownUp(ptrPos, 0, ptrNum); - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); - SimulatePointerDownUp(ptrPos.iX, ptrPos.iY, 0, ptrNum); - ptrPos.iX += xInc; - ptrPos.iY += yInc; - } - TestAndDisplayPtrClickError(); - break; - case 3: - { - // Simulate drags from all pointers - iMultiPtrEventClient->ParentWin()->BaseWin()->PointerFilter(EPointerFilterDrag,0); - iMultiPtrEventClient->ChildWin()->BaseWin()->PointerFilter(EPointerFilterDrag,0); - ptrPos.SetXY(0,0); - TPoint interPt; - for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) - { - AddExpectedMultiPtrClickEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, ptrNum); - interPt.iX = ptrPos.iX+1; - interPt.iY = ptrPos.iY+2; - AddExpectedMultiPtrClickEvent(TPointerEvent::EDrag, interPt, 0, 0, ptrNum); - AddExpectedMultiPtrClickEvent(TPointerEvent::EButton1Up, interPt, 0, 0, ptrNum); - - AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EDrag, interPt, 0, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EButton1Up, interPt, 0, 0, ptrNum); - - SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum); - SimulatePointerEvent(TRawEvent::EPointerMove, interPt.iX, interPt.iY, 0, ptrNum); - SimulatePointerEvent(TRawEvent::EButton1Up, interPt.iX, interPt.iY, 0, ptrNum); - - ptrPos.iX += xInc; - ptrPos.iY += yInc; - } - TestAndDisplayPtrClickError(); - } - break; - default: - iClick.Unload(); - iClick.Close(); - iPtrPluginLoaded = EFalse; - iHeap->Close(); - iHeap = NULL; - iChunk.Close(); - ResetFlushStopAS(); - break; - } - - LogEventsAdded(); - } - -void CTMultiPtrEventTest::GetRemainingEventsFromSecondaryClient() - { - if (iSecMultiPtrEventClient->EventBuffer()->EventsRemaining() != 0) - { - iSecMultiPtrEventClient->EventBuffer()->SetNestedLoopState(ETrue); - CActiveScheduler::Start(); - } - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-ADVANCEDPOINTER-0011 -@SYMPREQ PREQ1226 -@SYMREQ REQ9677,REQ9674, -@SYMTestPriority High -@SYMTestCaseDesc To check Wserv sends Multi Pointer events to correct clients -@SYMTestStatus Implemented - -@SYMTestActions Simulate multi pointer events on windows from different client. -@SYMTestExpectedResults The received events must match the simulated raw events -*/ -void CTMultiPtrEventTest::MultiClientMultiPointerEvents() - { - // Logic for this test code - // Create a secondary client when running this test - // Simulate events for both main client and secondary simulataneously - // Get events from DoRunL() of event buffer class - // Before running next set of events, get all the events from secondary client - // If test fails on any client make sure both active scheduler are stopped - TLogMessageText logText; - _LIT(KSet, "Multi pointer events for Multi client: %d of 5"); - logText.AppendFormat(KSet, iEventSet); - LOG_MESSAGE(logText); - - iMultiPtrEventClient->EventBuffer()->SetEventCount(0); - iSecMultiPtrEventClient->EventBuffer()->SetEventCount(0); - if (!iEventSet) - { - SetAutoFlush(); - iSecClientFlush = iSecMultiPtrEventClient->iWs.SetAutoFlush(ETrue); - } - - TPoint ptrPos; - TInt ptrNum = 0; - TInt prValue = 0; - TInt proxValue = 0; - TInt xInc = (iPhysicalScreenSize.iWidth/2)/iMaxDevPointers; - TInt yInc = iPhysicalScreenSize.iHeight/iMaxDevPointers; - TPoint secPt(iPhysicalScreenSize.iWidth/2,0); - TInt ptrSecNum = iMaxDevPointers-1; - - switch(iEventSet++) - { - case 0: - ptrPos.SetXY(0,0); - - // These events are generated when primary client is created and its group - // window constructed and then when button down for primary client is called - AddExpectedWsEvent(EEventFocusGained); - AddExpectedWsEvent(EEventFocusLost); - AddExpectedWsEvent(EEventFocusGained); - - // Simulate pointer down/up events for primary client from 0,1,3... pointers and 6,5,4... pointers for secondary client - for (ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) - { - SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, ptrNum); - - SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, ptrNum); - - ptrPos.iX += xInc; - ptrPos.iY += yInc; - } - - ptrPos.iX = iPhysicalScreenSize.iWidth/2; - ptrPos.iY = 0; - - // These events are generated when secondary cleint is created and then when - // button down for primary client is called, then when SetOrdinalPosition is - // called on secondary cleint's group window - AddExpectedWsEvent(EEventFocusGained, ETrue); - AddExpectedWsEvent(EEventFocusLost, ETrue); - iSecMultiPtrEventClient->iGroup->GroupWin()->SetOrdinalPosition(0, 1); - AddExpectedWsEvent(EEventFocusGained, ETrue); - - AddExpectedWsEvent(EEventFocusLost); - - for (ptrNum = iMaxDevPointers/2; ptrNum < iMaxDevPointers; ptrNum++) - { - SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, ptrNum, (TUint)iSecMultiPtrEventClient->ParentWin(), ETrue); - - SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, ptrNum, (TUint)iSecMultiPtrEventClient->ParentWin(), ETrue); - - ptrPos.iX += xInc; - ptrPos.iY += yInc; - } - break; - case 1: - // Simulate move events from primary and secondary client simultaneously with pressure - iMultiPtrEventClient->ParentWin()->BaseWin()->PointerFilter(EPointerFilterMove, 0); - iSecMultiPtrEventClient->ParentWin()->BaseWin()->PointerFilter(EPointerFilterMove, 0); - - ptrPos.SetXY(0,0); - prValue = iPressureStep; - - for (ptrNum = 0; (ptrNum < iMaxDevPointers/2 && ptrSecNum >= iMaxDevPointers/2); ptrNum++, ptrSecNum--) - { - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, prValue, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, prValue, 0, ptrNum); - ptrPos.iX += xInc; - ptrPos.iY += yInc; - - SimulatePointerEvent(TRawEvent::EPointerMove, secPt.iX, secPt.iY, prValue, ptrSecNum); - AddExpectedPointerEvent(TPointerEvent::EMove, secPt, prValue, 0, ptrSecNum, (TUint)iSecMultiPtrEventClient->ParentWin(), ETrue); - secPt.iX += xInc; - secPt.iY += yInc; - } - break; - case 2: - // Simulate move events from primary and secondary client simultaneously with proximity - ptrPos.SetXY(0,0); - proxValue = -iProximityStep; - - for (ptrNum = 0; (ptrNum < iMaxDevPointers/2 && ptrSecNum >= iMaxDevPointers/2); ptrNum++, ptrSecNum--) - { - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, proxValue, 0, ptrNum); - ptrPos.iX += xInc; - ptrPos.iY += yInc; - - SimulatePointerEvent(TRawEvent::EPointerMove, secPt.iX, secPt.iY, proxValue, ptrSecNum); - AddExpectedPointerEvent(TPointerEvent::EMove, secPt, proxValue, 0, ptrSecNum, (TUint)iSecMultiPtrEventClient->ParentWin(), ETrue); - secPt.iX += xInc; - secPt.iY += yInc; - } - break; - case 3: - { - // Simulate drag events on different clients window one after the other - iMultiPtrEventClient->ParentWin()->BaseWin()->PointerFilter(EPointerFilterDrag, 0); - iSecMultiPtrEventClient->ParentWin()->BaseWin()->PointerFilter(EPointerFilterDrag, 0); - - ptrPos.SetXY(0,0); - secPt.iX = iPhysicalScreenSize.iWidth/2; - secPt.iY = 0; - ptrSecNum = iMaxDevPointers-1; - TPoint interPt; - for (ptrNum = 0; (ptrNum < iMaxDevPointers/2 && ptrSecNum >= iMaxDevPointers/2); ptrNum++, ptrSecNum--) - { - SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, ptrNum); - interPt.iX = ptrPos.iX+2; - interPt.iY = ptrPos.iY+1; - SimulatePointerEvent(TRawEvent::EPointerMove, interPt.iX, interPt.iY, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EDrag, interPt, 0, 0, ptrNum); - SimulatePointerEvent(TRawEvent::EButton1Up, interPt.iX, interPt.iY, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EButton1Up, interPt, 0, 0, ptrNum); - ptrPos.iX += xInc; - ptrPos.iY += yInc; - - SimulatePointerEvent(TRawEvent::EButton1Down, secPt.iX, secPt.iY, 0, ptrSecNum); - AddExpectedPointerEvent(TPointerEvent::EButton1Down, secPt, 0, 0, ptrSecNum, (TUint)iSecMultiPtrEventClient->ParentWin(), ETrue); - interPt.iX = secPt.iX+2; - interPt.iY = secPt.iY+1; - SimulatePointerEvent(TRawEvent::EPointerMove, interPt.iX, interPt.iY, 0, ptrSecNum); - AddExpectedPointerEvent(TPointerEvent::EDrag, interPt, 0, 0, ptrSecNum, (TUint)iSecMultiPtrEventClient->ParentWin(), ETrue); - SimulatePointerEvent(TRawEvent::EButton1Up, interPt.iX, interPt.iY, 0, ptrSecNum); - AddExpectedPointerEvent(TPointerEvent::EButton1Up, interPt, 0, 0, ptrSecNum, (TUint)iSecMultiPtrEventClient->ParentWin(), ETrue); - secPt.iX += xInc; - secPt.iY += yInc; - } - } - break; - case 4: - { - // Simulate drag events on different clients, but interleaved each other - ptrPos.SetXY(0,0); - secPt.iX = iPhysicalScreenSize.iWidth/2; - secPt.iY = 0; - ptrSecNum = iMaxDevPointers-1; - TPoint interPt; - - for (ptrNum = 0; (ptrNum < iMaxDevPointers/2 && ptrSecNum >= iMaxDevPointers/2); ptrNum++, ptrSecNum--) - { - SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, ptrNum); - ptrPos.iX += xInc; - ptrPos.iY += yInc; - - SimulatePointerEvent(TRawEvent::EButton1Down, secPt.iX, secPt.iY, 0, ptrSecNum); - AddExpectedPointerEvent(TPointerEvent::EButton1Down, secPt, 0, 0, ptrSecNum, (TUint)iSecMultiPtrEventClient->ParentWin(), ETrue); - secPt.iX += xInc; - secPt.iY += yInc; - } - - ptrPos.SetXY(0,0); - secPt.iX = iPhysicalScreenSize.iWidth/2; - secPt.iY = 0; - ptrSecNum = iMaxDevPointers-1; - for (ptrNum = 0; (ptrNum < iMaxDevPointers/2 && ptrSecNum >= iMaxDevPointers/2); ptrNum++, ptrSecNum--) - { - interPt.iX = ptrPos.iX+2; - interPt.iY = ptrPos.iY+1; - SimulatePointerEvent(TRawEvent::EPointerMove, interPt.iX, interPt.iY, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EDrag, interPt, 0, 0, ptrNum); - ptrPos.iX += xInc; - ptrPos.iY += yInc; - - - interPt.iX = secPt.iX+2; - interPt.iY = secPt.iY+1; - SimulatePointerEvent(TRawEvent::EPointerMove, interPt.iX, interPt.iY, 0, ptrSecNum); - AddExpectedPointerEvent(TPointerEvent::EDrag, interPt, 0, 0, ptrSecNum, (TUint)iSecMultiPtrEventClient->ParentWin(), ETrue); - secPt.iX += xInc; - secPt.iY += yInc; - } - - ptrPos.SetXY(0,0); - secPt.iX = iPhysicalScreenSize.iWidth/2; - secPt.iY = 0; - ptrSecNum = iMaxDevPointers-1; - for (ptrNum = 0; (ptrNum < iMaxDevPointers/2 && ptrSecNum >= iMaxDevPointers/2); ptrNum++, ptrSecNum--) - { - interPt.iX = ptrPos.iX+2; - interPt.iY = ptrPos.iY+1; - SimulatePointerEvent(TRawEvent::EButton1Up, interPt.iX, interPt.iY, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EButton1Up, interPt, 0, 0, ptrNum); - ptrPos.iX += xInc; - ptrPos.iY += yInc; - - interPt.iX = secPt.iX+2; - interPt.iY = secPt.iY+1; - SimulatePointerEvent(TRawEvent::EButton1Up, interPt.iX, interPt.iY, 0, ptrSecNum); - AddExpectedPointerEvent(TPointerEvent::EButton1Up, interPt, 0, 0, ptrSecNum, (TUint)iSecMultiPtrEventClient->ParentWin(), ETrue); - secPt.iX += xInc; - secPt.iY += yInc; - } - } - break; - default: - ResetFlushStopAS(); - iSecMultiPtrEventClient->iWs.SetAutoFlush(iSecClientFlush); - break; - } - - _LIT(KEventsAdded, "Events added to Primary client's buffer = %d"); - logText.Format(KEventsAdded, iMultiPtrEventClient->EventBuffer()->EventsRemaining()); - LOG_MESSAGE(logText); - _LIT(KEventsAdded1, "Events added to Secondary client's buffer = %d"); - logText.Format(KEventsAdded1, iSecMultiPtrEventClient->EventBuffer()->EventsRemaining()); - LOG_MESSAGE(logText); - } - - -// RMultiPointerAnim -RMultiPointerAnim* RMultiPointerAnim::NewL(RWindowBase* aWin, RAnimDll* aDll) - { - RMultiPointerAnim* self=new(ELeave) RMultiPointerAnim(aDll); - CleanupStack::PushL(TCleanupItem(DestroyAnim,self)); - User::LeaveIfError(self->Construct(*aWin, EAnimTypeMultiPointer, TPtrC8())); - CleanupStack::Pop(self); - return self; - } - -TInt RMultiPointerAnim::AddExpectedAnimPointerEvent(TRawEvent::TType aType, TPoint aPos, TInt aZ, TUint /*aModifier*/, TUint8 aPointerNumber, TBool aEat /*= ETrue*/) - { - TRawEvent rawEvent; - rawEvent.Set(aType, aPos.iX, aPos.iY, aZ, aPointerNumber); - TAnimRawEvent animEvent; - animEvent.iRawEvent = rawEvent; - animEvent.iEat = aEat; - TPckgBuf param; - param()=animEvent; - return CommandReply(EADllAddExpectedMultiPtrEvent, param); - } - -void CTMultiPtrEventTest::TestAndDisplayAnimError() - { - TInt err = iAnim->CommandReply(EADllMultiPtrEventError); - if (err != KErrNone) - { - _LIT(KError, "Failed in Anim dll"); - LOG_MESSAGE(KError); - TBuf<255> errDesc; - errDesc.SetMax(); - TIpcArgs ipcArgs; - ipcArgs.Set(KIpcSlot,&errDesc); - // get the error desccription, print it out and stop the tests - TInt retVal = iAnim->CommandReply(EADllMultiPtrEventErrorDesc, KNullDesC8, ipcArgs); - if (retVal == KErrNone) - { - LOG_MESSAGE(errDesc); - } - Failed(); - } - iAnim->CommandReply(EADllMultiPtrEventReset); - } - -/** -@SYMTestCaseID GRAPHICS-WSERV-ADVANCEDPOINTER-0013 -@SYMPREQ PREQ1226 -@SYMREQ REQ9677,REQ9683, -@SYMTestPriority High -@SYMTestCaseDesc To check Wserv sends Multi Pointer events to Anims -@SYMTestStatus Implemented - -@SYMTestActions Simulate multi pointer events for anims -@SYMTestExpectedResults The received events must match the simulated raw events -*/ -void CTMultiPtrEventTest::MultiPointerEventsForAnimsL() - { - // The logic behind these tests is - // Create an anim, which creates animation at server side(which swicthes raw event handling on) - // Add the required events to the animtaion at server side buffer - // Simulate those events and check simulated events are same as required at server side - // If any test fail, error description is got from server and displayed in the log file - TLogMessageText logText; - _LIT(KSet, "Multi pointer events for Anims: %d of 3"); - logText.AppendFormat(KSet, iEventSet); - LOG_MESSAGE(logText); - _LIT(KEventsChecked, "Events checked at server side = %d"); - - iMultiPtrEventClient->EventBuffer()->SetEventCount(0); - if (!iEventSet) - { - SetAutoFlush(); - iAnimDll = new(ELeave) RAnimDll(iMultiPtrEventClient->iWs); - User::LeaveIfError(iAnimDll->Load(KAnimDLLName)); - } - - TPoint ptrPos; - TInt ptrNum = 0; - TInt prValue = 0; - TInt proxValue = 0; - TInt xInc = iPhysicalScreenSize.iWidth/iMaxDevPointers; - TInt yInc = iPhysicalScreenSize.iHeight/iMaxDevPointers; - - switch(iEventSet++) - { - case 0: - // Simulate downup events for all pointers - iAnim = RMultiPointerAnim::NewL(iMultiPtrEventClient->ParentWin()->BaseWin(), iAnimDll); - AddExpectedWsEvent(EEventFocusGained); - for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) - { - iAnim->AddExpectedAnimPointerEvent(TRawEvent::EButton1Down,ptrPos,0,0,ptrNum); - iAnim->AddExpectedAnimPointerEvent(TRawEvent::EButton1Up,ptrPos,0,0,ptrNum); - SimulatePointerDownUp(ptrPos.iX, ptrPos.iY, 0, ptrNum); - ptrPos.iX += xInc; - ptrPos.iY += yInc; - } - TestAndDisplayAnimError(); - logText.Format(KEventsChecked, iMaxDevPointers*2); - LOG_MESSAGE(logText); - break; - case 1: - // Simulate moves from different pointer with different pressure - // Here there is no need for events to be exaclty on the anim window. - // becasue when the animtaions ask for events it will be delivered all the events - // irrespective of where they occured. - ptrPos.SetXY(0,0); - prValue = iPressureStep; - for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) - { - iAnim->AddExpectedAnimPointerEvent(TRawEvent::EPointerMove, ptrPos, prValue, 0, ptrNum); - iAnim->AddExpectedAnimPointerEvent(TRawEvent::EButton1Down,ptrPos,0,0,ptrNum); - iAnim->AddExpectedAnimPointerEvent(TRawEvent::EButton1Up,ptrPos,0,0,ptrNum); - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, prValue, ptrNum); - SimulatePointerDownUp(ptrPos.iX, ptrPos.iY, 0, ptrNum); - ptrPos.iX += xInc; - ptrPos.iY += yInc; - } - TestAndDisplayAnimError(); - - // This is for just to add run the next test - SimulatePointerEvent(TRawEvent::EPointerSwitchOn, 0, 0, 0, 0); - - logText.Format(KEventsChecked, iMaxDevPointers*3); - LOG_MESSAGE(logText); - break; - case 2: - // Simulate moves from different pointer with different proximity - ptrPos.SetXY(0,0); - proxValue = -iProximityStep; - for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) - { - iAnim->AddExpectedAnimPointerEvent(TRawEvent::EPointerMove, ptrPos, proxValue, 0, ptrNum); - iAnim->AddExpectedAnimPointerEvent(TRawEvent::EButton1Down,ptrPos,0,0,ptrNum); - iAnim->AddExpectedAnimPointerEvent(TRawEvent::EButton1Up,ptrPos,0,0,ptrNum); - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); - SimulatePointerDownUp(ptrPos.iX, ptrPos.iY, 0, ptrNum); - ptrPos.iX += xInc; - ptrPos.iY += yInc; - } - TestAndDisplayAnimError(); - - // This is for just to add run the next test - SimulatePointerEvent(TRawEvent::EPointerSwitchOn, 0, 0, 0, 0); - - logText.Format(KEventsChecked, iMaxDevPointers*3); - LOG_MESSAGE(logText); - break; - default: - DestroyAnimDllAndAnim(); - ResetFlushStopAS(); - break; - } - - LogEventsAdded(); - } - - -/** -@SYMTestCaseID GRAPHICS-WSERV-ADVANCEDPOINTER-0014 -@SYMPREQ PREQ1226 -@SYMREQ REQ9677,REQ9683, -@SYMTestPriority High -@SYMTestCaseDesc To check Wserv purges multi pointer events with standard rules -@SYMTestStatus Implemented - -@SYMTestActions Simulate raw events to be purged -@SYMTestExpectedResults The purged events should not be delivered to client -*/ -void CTMultiPtrEventTest::PurgingMultiPointerEvents() - { - // Test purging of multi pointer events - // 1. Test down/up pairs are purged - // 2. Test moves events are purged - // 3. Test drag events are purged - // 4. Test lone down events are purged - // 5. And finally test lone up events are also purged - TLogMessageText logText; - _LIT(KSet, "Purging of multi pointer events: %d of 6"); - logText.AppendFormat(KSet, iEventSet); - LOG_MESSAGE(logText); - - iMultiPtrEventClient->EventBuffer()->SetEventCount(0); - TInt xInc = iPhysicalScreenSize.iWidth/KMaxQueueSize; - TInt yInc = iPhysicalScreenSize.iHeight/KMaxQueueSize; - TPoint ptrPos(xInc,yInc); - TInt ptrNum = 0; - TInt prValue = 0; - TInt proxValue = 0; - - if (!iEventSet) - { - SetAutoFlush(); - } - - // Point to note is that Kernel has an event queue size of 40 - // So make sure that you don't send more than 40 events - switch(iEventSet++) - { - case 0: - // Simulate pointer down/up events for all pointers - // Simulate many up events from any pointer which will purge down/up events - AddExpectedWsEvent(EEventFocusGained); - for (ptrNum = 0; (ptrNum < iMaxDevPointers && ptrNum < 4); ptrNum++) - { - SimulatePointerDownUp(ptrPos.iX, ptrPos.iY, 0, ptrNum); - } - SimulateAndAddLoneUpEvents(KMaxQueueSize, KMaxQueueSize-1, ptrPos); - break; - case 1: - // Repeat the same for Move events - // Simulate moves for all pointers with different pressure and proximity value - iMultiPtrEventClient->ParentWin()->BaseWin()->PointerFilter(EPointerFilterMove, 0); - iMultiPtrEventClient->ChildWin()->BaseWin()->PointerFilter(EPointerFilterMove, 0); - prValue = iPressureStep; - for (ptrNum = 0; (ptrNum < iMaxDevPointers && prValue < iMaxPressure && ptrNum < 4); ptrNum++,prValue+=iPressureStep) - { - ptrPos.iX += xInc/2; - ptrPos.iY += yInc/2; - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, prValue, ptrNum); - } - ptrPos.iX = xInc; - ptrPos.iY = yInc; - proxValue = -iProximityStep; - for (ptrNum = 0; (ptrNum < iMaxDevPointers && proxValue > iMaxProximity && ptrNum < 4); ptrNum++,proxValue-=iProximityStep) - { - ptrPos.iX += xInc/2; - ptrPos.iY += yInc/2; - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); - } - SimulateAndAddLoneUpEvents(KMaxQueueSize, KMaxQueueSize, ptrPos); - break; - case 2: - { - // Repeat the same for drag events - iMultiPtrEventClient->ParentWin()->BaseWin()->PointerFilter(EPointerFilterDrag, 0); - iMultiPtrEventClient->ChildWin()->BaseWin()->PointerFilter(EPointerFilterDrag, 0); - ptrPos.iX = xInc; - ptrPos.iY = yInc; - for (ptrNum = 0; (ptrNum < iMaxDevPointers && ptrNum < 2); ptrNum++) - { - SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum); - ptrPos.iX += xInc/2; - ptrPos.iY += yInc/2; - } - ptrPos.iX = xInc; - ptrPos.iY = yInc; - TPoint interPt = ptrPos; - for (ptrNum = 0; (ptrNum < iMaxDevPointers && ptrNum < 2); ptrNum++) - { - interPt.iX += 2; - interPt.iY += 1; - SimulatePointerEvent(TRawEvent::EPointerMove, interPt.iX, interPt.iY, 0, ptrNum); - ptrPos.iX += xInc/2; - ptrPos.iY += yInc/2; - interPt = ptrPos; - } - ptrPos.iX = xInc; - ptrPos.iY = yInc; - interPt = ptrPos; - for (ptrNum = 0; (ptrNum < iMaxDevPointers && ptrNum < 2); ptrNum++) - { - interPt.iX += 2; - interPt.iY += 1; - SimulatePointerEvent(TRawEvent::EButton1Up, interPt.iX, interPt.iY, 0, ptrNum); - ptrPos.iX += xInc/2; - ptrPos.iY += yInc/2; - interPt = ptrPos; - } - SimulateAndAddLoneUpEvents(KMaxQueueSize, KMaxQueueSize, ptrPos); - } - break; - case 3: - // Repeat the same for lone down events - ptrPos.iX = xInc; - ptrPos.iY = yInc; - for (ptrNum = 0; (ptrNum < iMaxDevPointers && ptrNum < 3); ptrNum++) - { - SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum); - ptrPos.iX += xInc/2; - ptrPos.iY += yInc/2; - } - SimulateAndAddLoneUpEvents(KMaxQueueSize+1, KMaxQueueSize, ptrPos); - - // Before this we had to send dummy 7 EButton1Up events from 1 to 7 pointers so that iLastUnmatchedDown1 - // variable to be reset and that consecutive events was not sent to client. But now EPointer3DOutOfRange - // resets all the variables. - for (ptrNum = 1; (ptrNum < iMaxDevPointers && ptrNum < 3); ptrNum++) - { - SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, ptrPos.iX, ptrPos.iY, 0, ptrNum); - } - break; - case 4: - // Finally for even lone up events, check that when you send events more then the queuesize - // the events are not sent back and they are ignored in wserv - ptrPos.iX = xInc; - ptrPos.iY = yInc; - for (ptrNum = 0; (ptrNum < iMaxDevPointers && ptrNum < 4); ptrNum++) - { - SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, ptrNum); - ptrPos.iX += xInc/2; - ptrPos.iY += yInc/2; - } - ptrPos.iX = xInc; - ptrPos.iY = yInc; - for (TInt count = 0; count < KMaxQueueSize; count++) - { - SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 0); - // For all up events more then KMaxQueueSize, wserv igoners then as the queue if full - if (count < (KMaxQueueSize - iMaxDevPointers)) - { - AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, 0); - } - } - break; - case 5: - // Check PurgePointerEvents works with multi pointer events - ptrPos.iX = xInc; - ptrPos.iY = yInc; - for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) - { - SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, ptrNum); - ptrPos.iX += xInc/2; - ptrPos.iY += yInc/2; - } - ptrPos.iX = xInc; - ptrPos.iY = yInc; - iMultiPtrEventClient->iWs.PurgePointerEvents(); - SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 0); - AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, 0); - break; - default: - ResetFlushStopAS(); - break; - } - LogEventsAdded(); - } - -void CTMultiPtrEventTest::MultiPointerEvents() - { - TLogMessageText logText; - _LIT(KSet, "MultiPtrEvents SetOfEvents: %d of 9"); - logText.AppendFormat(KSet, iEventSet); - LOG_MESSAGE(logText); - - if (!iEventSet) - { - SetAutoFlush(); - } - iMultiPtrEventClient->EventBuffer()->SetEventCount(0); - - TPoint ptrPos; - TInt ptrNum = 0; - TInt prValue = 0; - TInt proxValue = 0; - TInt xInc = iPhysicalScreenSize.iWidth/iMaxDevPointers; - TInt yInc = iPhysicalScreenSize.iHeight/iMaxDevPointers; - - switch(iEventSet++) - { - case 0: - /** - @SYMTestCaseID GRAPHICS-WSERV-ADVANCEDPOINTER-0001 - @SYMPREQ PREQ1226 - @SYMREQ REQ9674,REQ9687, - @SYMTestPriority High - @SYMTestCaseDesc Checks Wserv sends multi touch pointer events received by it - @SYMTestStatus Implemented - - @SYMTestActions Simulate raw events from different pointers - @SYMTestExpectedResults The received events must match the simulated raw events - */ - INFO_PRINTF1(_L("Simulate pointer events from all pointers")); - INFO_PRINTF1(_L("Test pattern is PointerDown0/PointerUp0, PointerDown1/PointerUp1, PointerDown2/PointerUp2...")); - // Test pattern is down0/up0, down1/up1, down2/up2, down3/up3.... - AddExpectedWsEvent(EEventFocusGained); - for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) - { - SimulatePointerDownUp(ptrPos.iX, ptrPos.iY, 0, ptrNum); - AddExpectedPointerDownUp(ptrPos, 0, ptrNum); - ptrPos.iX += xInc; - ptrPos.iY += yInc; - } - break; - case 1: - /** - @SYMTestCaseID GRAPHICS-WSERV-ADVANCEDPOINTER-0003 - @SYMPREQ PREQ1226 - @SYMREQ REQ9674,REQ9687, - @SYMTestPriority High - @SYMTestCaseDesc To check Wserv sends simultaneous multi touch pointer events - @SYMTestStatus Implemented - - @SYMTestActions Simulate simultaneous raw events from different pointers - @SYMTestExpectedResults The received events must match the simulated raw events - */ - INFO_PRINTF1(_L("Test pattern PointerDown0/PointerDown1/PointerDown2/... PointerUp0/PointerUp1/PointerUp2...")); - // Test pattern is pointer0Down/pointer1Down/pointer2Down/pointer3Down.... pointer0Up/pointer1Up/pointer2Up/pointer3Up.... - ptrPos.SetXY(0,0); - for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) - { - SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, ptrNum); - ptrPos.iX += xInc; - ptrPos.iY += yInc; - } - - ptrPos.SetXY(0,0); - for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) - { - SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, ptrNum); - ptrPos.iX += xInc; - ptrPos.iY += yInc; - } - break; - case 2: - /** - @SYMTestCaseID GRAPHICS-WSERV-ADVANCEDPOINTER-0005 - @SYMPREQ PREQ1226 - @SYMREQ REQ9676 - @SYMTestPriority High - @SYMTestCaseDesc To check Wserv sends the multi touch pointer events received - by it along with the Pressure or Proximity - @SYMTestStatus Implemented - - @SYMTestActions Simulate raw events with pressure and proximity from different pointers - @SYMTestExpectedResults The received events must match the simulated raw events - */ - // Simulate Button1Down with differet pressure - // Simulate Button1Up with zero pressure - INFO_PRINTF1(_L("Simulate pointer events with different pressure values")); - ptrPos.SetXY(0,0); - prValue = iPressureStep; - for (; (prValue <= iMaxPressure && ptrPos.iX < iPhysicalScreenSize.iWidth && ptrPos.iY < iPhysicalScreenSize.iHeight); prValue+=iPressureStep) - { - SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, prValue, 0); - SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 0); - AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, prValue, 0, 0); - AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, 0); - ptrPos.iX += xInc; - ptrPos.iY += yInc; - } - - // Test with max pressure it might be that the width may cross the physical screen size - ptrPos.SetXY(0,0); - prValue = iMaxPressure; - SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, prValue, 0); - SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 0); - AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, prValue, 0, 0); - AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, 0); - break; - case 3: - // Simulate EPointerMove with different pressure values and for differernt pointers - INFO_PRINTF1(_L("Simulate pointer events with different pressure values and from different pointers")); - ptrPos.SetXY(0,0); - prValue = iPressureStep; - - // Enable move events - iMultiPtrEventClient->ParentWin()->BaseWin()->PointerFilter(EPointerFilterMove, 0); - iMultiPtrEventClient->ChildWin()->BaseWin()->PointerFilter(EPointerFilterMove, 0); - - // Right now when 2 or more moves occur, wserv deletes all the moves except the last one. - // So test only one move per Pointer and then one set of button down and button up - // Then repeat the same for different pressure values - for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) - { - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, prValue, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, prValue, 0, ptrNum); - ptrPos.iX += xInc; - ptrPos.iY += yInc; - } - - ptrPos.SetXY(0,0); - for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) - { - SimulatePointerDownUp(ptrPos.iX, ptrPos.iY, 0, ptrNum); - AddExpectedPointerDownUp(ptrPos, 0, ptrNum); - ptrPos.iX += xInc; - ptrPos.iY += yInc; - } - - // Test moves with different pressure - ptrPos.SetXY(0,0); - if ((prValue+iPressureStep) <= iMaxPressure) - { - prValue += iPressureStep; - } - ptrNum = 0; - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, prValue, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, prValue, 0, ptrNum); - break; - case 4: - INFO_PRINTF1(_L("Simulate pointer events with different proximity values")); - // Repeat the same test of case 3 for different proximity values - ptrPos.SetXY(0,0); - - proxValue = -iProximityStep; - for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) - { - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, proxValue, 0, ptrNum); - ptrPos.iX += xInc; - ptrPos.iY += yInc; - } - - ptrPos.SetXY(0,0); - for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) - { - SimulatePointerDownUp(ptrPos.iX, ptrPos.iY, 0, ptrNum); - AddExpectedPointerDownUp(ptrPos, 0, ptrNum); - ptrPos.iX += xInc; - ptrPos.iY += yInc; - } - - ptrPos.SetXY(0,0); - if ((proxValue-iProximityStep) > iMaxProximity) - { - proxValue -= iProximityStep; - } - ptrNum = 0; - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, proxValue, 0, ptrNum); - break; - case 5: - /** - @SYMTestCaseID GRAPHICS-WSERV-ADVANCEDPOINTER-0007 - @SYMPREQ PREQ1226 - @SYMREQ REQ9677 - @SYMTestPriority High - @SYMTestCaseDesc To check Wserv sends move/drags of different pointers - @SYMTestStatus Implemented - - @SYMTestActions Simulate raw move and drag events from different pointers - @SYMTestExpectedResults The received events must match the simulated raw events - */ - INFO_PRINTF1(_L("Simulate pointer drag events")); - ptrPos.SetXY(0,0); - iMultiPtrEventClient->ParentWin()->BaseWin()->PointerFilter(EPointerFilterDrag, 0); - - // Simulate EButton1Down and then one move and then EButton1Up event - // which will lead to corresponding drag, do it for all the pointers - for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) - { - TestDragForMultiPointer(ptrPos, 0, ptrNum); - ptrPos.iX += xInc/2; - ptrPos.iY += yInc/2; - } - - // Check the drag with different pressure value with different pointer - prValue = iPressureStep; - ptrPos.iX = xInc; - ptrPos.iY = yInc; - if ((prValue+iPressureStep) <= iMaxPressure) - { - prValue += iPressureStep; - } - ptrNum = 0; - TestDragForMultiPointer(ptrPos, prValue, ptrNum); - break; - case 6: - { - /** - @SYMTestCaseID GRAPHICS-WSERV-ADVANCEDPOINTER-0009 - @SYMPREQ PREQ1226 - @SYMREQ REQ9677, REQ9674 - @SYMTestPriority High - @SYMTestCaseDesc To check Wserv sends simultaneous move/drags of different pointers - @SYMTestStatus Implemented - - @SYMTestActions Simulate simulatneous raw move and drag events from different pointers - @SYMTestExpectedResults The received events must match the simulated raw events - */ - INFO_PRINTF1(_L("Simulate pointer drag events in different pattern")); - // Dragging done in this pattern - // pointer0Down/pointer1Down/pointer2Down/pointer3Down... pointer0Up/pointer1Up/pointer2Up/pointer3Up.... - - ptrPos.SetXY(0,0); - for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) - { - SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, ptrNum); - ptrPos.iX += xInc/2; - ptrPos.iY += yInc/2; - } - - ptrPos.SetXY(0,0); - TPoint interPt = ptrPos; - for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) - { - interPt.iX += 2; - interPt.iY += 1; - SimulatePointerEvent(TRawEvent::EPointerMove, interPt.iX, interPt.iY, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EDrag, interPt, 0, 0, ptrNum); - ptrPos.iX += xInc/2; - ptrPos.iY += yInc/2; - interPt = ptrPos; - } - - ptrPos.SetXY(0,0); - interPt = ptrPos; - for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) - { - interPt.iX += 2; - interPt.iY += 1; - SimulatePointerEvent(TRawEvent::EButton1Up, interPt.iX, interPt.iY, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EButton1Up, interPt, 0, 0, ptrNum); - ptrPos.iX += xInc/2; - ptrPos.iY += yInc/2; - interPt = ptrPos; - } - break; - } - case 7: - { - // Mixing of drag and moves of different pointers - ptrPos.SetXY(0,0); - for (ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) - { - SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, ptrNum); - ptrPos.iX += xInc/2; - ptrPos.iY += yInc/2; - } - ptrPos.SetXY(0,0); - TPoint interPt = ptrPos; - for (ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) - { - interPt.iX += 2; - interPt.iY += 1; - SimulatePointerEvent(TRawEvent::EPointerMove, interPt.iX, interPt.iY, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EDrag, interPt, 0, 0, ptrNum); - ptrPos.iX += xInc/2; - ptrPos.iY += yInc/2; - interPt = ptrPos; - } - - ptrPos.SetXY(0,0); - interPt = ptrPos; - for (ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) - { - interPt.iX += 2; - interPt.iY += 1; - SimulatePointerEvent(TRawEvent::EButton1Up, interPt.iX, interPt.iY, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EButton1Up, interPt, 0, 0, ptrNum); - ptrPos.iX += xInc/2; - ptrPos.iY += yInc/2; - interPt = ptrPos; - } - - ptrPos.SetXY(0,0); - prValue = iPressureStep; - for (ptrNum = 0; ptrNum < iMaxDevPointers/2 && prValue < iMaxPressure; ptrNum++, prValue+=iPressureStep) - { - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, prValue, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, prValue, 0, ptrNum); - ptrPos.iX += xInc; - ptrPos.iY += yInc; - } - } - break; - case 8: - { - INFO_PRINTF1(_L("Check intermediate Moves and Drags are deleted except last event")); - // Check if intermediate move and drag events are deleted - // The deletion is done with respect to same pointer and same window - xInc = iPhysicalScreenSize.iWidth/KMaxQueueSize; - yInc = iPhysicalScreenSize.iHeight/KMaxQueueSize; - ptrPos.iX = xInc; - ptrPos.iY = yInc; - TInt count = 0; - - for (ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) - { - // Make sure that ptrPos does not go out of screen area, i,e the loop count should not exceed 4 - for (count = proxValue = 0; proxValue > iMaxProximity && count < 4; proxValue=proxValue-(4*iProximityStep), count++) - { - ptrPos.iX += xInc/2; - ptrPos.iY += yInc/2; - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); - } - // Since the for loop increments the variables at the end - proxValue = proxValue + (4*iProximityStep); - AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, proxValue, 0, ptrNum); - } - - ptrPos.iX = xInc; - ptrPos.iY = yInc; - for (ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) - { - ptrPos.iX += xInc/2; - ptrPos.iY += yInc/2; - SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, ptrNum); - } - - ptrPos.iX = xInc; - ptrPos.iY = yInc; - for (ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) - { - // Make sure that ptrPos does not go out of screen area, i,e the loop count shuld not exceed 4 - for (count = prValue = 0; prValue < iMaxPressure && count < 4; prValue=prValue+(4*iPressureStep), count++) - { - ptrPos.iX += xInc/2; - ptrPos.iY += yInc/2; - SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, prValue, ptrNum); - } - prValue = prValue-(4*iPressureStep); - AddExpectedPointerEvent(TPointerEvent::EDrag, ptrPos, prValue, 0, ptrNum); - } - - ptrPos.iX = xInc; - ptrPos.iY = yInc; - for (ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) - { - ptrPos.iX += xInc/2; - ptrPos.iY += yInc/2; - SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, ptrNum); - AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, ptrNum); - } - } - break; - default: - ResetFlushStopAS(); - break; - } - - LogEventsAdded(); - } - -// Logs number of events added to test buffer for comaparison -void CTMultiPtrEventTest::LogEventsAdded() - { - TLogMessageText logText1; - _LIT(KEventsAdded, "Events added to buffer = %d"); - logText1.AppendFormat(KEventsAdded, iMultiPtrEventClient->EventBuffer()->EventsRemaining()); - LOG_MESSAGE(logText1); - } - -// If any of the Tests fails, bring the wserv in a consistent state for other test to run, -// stop ActiveScheduler and display some logs where the fail occured. -void CTMultiPtrEventTest::Failed() - { - switch (iTest->iState) - { - case 2: // Anim tests - DestroyAnimDllAndAnim(); - break; - case 3: // MultiClient tests - if (iMultiPtrEventClient->EventBuffer()->NestedLoopState()) - { - iSecMultiPtrEventClient->EventBuffer()->SetNestedLoopState(EFalse); - CActiveScheduler::Stop(); - } - break; - case 4: //PtrClick tests - if (iPtrPluginLoaded) - { - iPtrPluginLoaded = EFalse; - iClick.Unload(); - iClick.Close(); - } - if (iHeap) - { - iHeap->Close(); - iHeap = NULL; - iChunk.Close(); - } - break; - case 5: //Screen mode tests - SetDefaultScreenMode(); - break; - case 11: - iMultiPtrEventClient->DeleteGroupBlankWin(); - break; - case 12: //Emulation tests, iEventSet is incremented in main switch case. - switch (iEventSet) - { - case 9: - DeleteGroupWin(); - break; - case 10: - DestroyAnimDllAndAnim(); - break; - case 11: - case 12: - iMultiPtrEventClient->ParentWin()->BaseWin()->FreePointerMoveBuffer(); - iMultiPtrEventClient->ParentWin()->BaseWin()->DisablePointerMoveBuffer(); - break; - case 14: - case 15: - iMultiPtrEventClient->iWs.SetPointerCursorArea(iOrigPtrCursorArea); - break; - default: - break; - } - break; - case 15: - if (iEventSet > 1) - { - DeleteGroupWinForCapturing(); - } - break; - case 13: - case 16: - SetThresholdValues(KMaxTInt, KMinTInt, KMaxTInt, KMinTInt); - break; - default: - break; - } - - if (iActiveSchedulerStarted) - { - iActiveSchedulerStarted = EFalse; - CActiveScheduler::Stop(); - } - - // Display the test case number, subtest case number and number of events left in the buffer which can be used to - // find out which event actually caused the failure when any test fails - TLogMessageText logText1; - _LIT(KEventsAdded, "Test case number %d Sub test case number %d Events remaining in the buffer %d \n"); - logText1.AppendFormat(KEventsAdded, iTest->iState, iEventSet, iMultiPtrEventClient->EventBuffer()->EventsRemaining()); - LOG_MESSAGE(logText1); - RDebug::Printf("Test case number %d Sub test case number %d Events remaining in the buffer %d \n", iTest->iState, iEventSet, iMultiPtrEventClient->EventBuffer()->EventsRemaining()); - - iFailed=ETrue; - } - -// This function is called by TestExecute Framework, through which all the testcases are run -void CTMultiPtrEventTest::RunTestCaseL(TInt /*aCurTestCase*/) - { - _LIT(KTest0, "MultiPointerEvents with Pressure and Proximity"); - _LIT(KTest1, "Purging Of MultiPointerEvents"); - _LIT(KTest2, "MultiPointerEvents for Anims"); - _LIT(KTest3, "MultiPointerEvents from multi client"); - _LIT(KTest4, "MultiPointerEvents for pointer click plugin"); - _LIT(KTest5, "MultiPointerEvents In Different ScreenModes"); - _LIT(KTest6, "Filtering Of MultiPointerEvents"); - _LIT(KTest7, "Grabbing Of MultiPointerEvents"); - _LIT(KTest8, "VirtualKeyboard for Multiple Pointers"); - _LIT(KTest9, "DoubleClick events for Multiple Pointer"); - _LIT(KTest10, "OutOfRange & EnterExit for Multiple Pointer"); - _LIT(KTest11, "Auto foreground for Multiple Pointer"); - _LIT(KTest12, "Emulation rules for Mulitple Pointers"); - _LIT(KTest13, "Close proximity and High Pressure events"); - _LIT(KTest14, "Out of bound value testing"); - _LIT(KTest15, "Capturing Of MultiPointerEvents"); - _LIT(KTest16, "Negative testing for Proximity and Pressure events"); - _LIT(KTest17, "PointerRepeatEvent for Multiple Pointers"); - - if (!TestBase()->ConfigurationSupportsPointerEventTesting()) - { - INFO_PRINTF1(_L("Test skipped because config does not support pointer event testing")); - TestComplete(); - return; - } - - switch(iTest->iState) - { - case 0: - iTest->LogSubTest(KTest0); - RunTestsL(); - break; - case 1: - iTest->LogSubTest(KTest1); - RunTestsL(); - break; - case 2: - iTest->LogSubTest(KTest2); - RunTestsL(); - break; - case 3: - iTest->LogSubTest(KTest3); - RunTestsL(); - break; - case 4: - iTest->LogSubTest(KTest4); - RunTestsL(); - break; - case 5: - iTest->LogSubTest(KTest5); - RunTestsL(); - break; - case 6: - iTest->LogSubTest(KTest6); - RunTestsL(); - break; - case 7: - iTest->LogSubTest(KTest7); - RunTestsL(); - break; - case 8: - iTest->LogSubTest(KTest8); - RunTestsL(); - break; - case 9: - iTest->LogSubTest(KTest9); - RunTestsL(); - break; - case 10: - iTest->LogSubTest(KTest10); - RunTestsL(); - break; - case 11: - iTest->LogSubTest(KTest11); - RunTestsL(); - break; - case 12: - iTest->LogSubTest(KTest12); - RunTestsL(); - break; - case 13: - iTest->LogSubTest(KTest13); - RunTestsL(); - break; - case 14: - iTest->LogSubTest(KTest14); - RunTestsL(); - break; - case 15: - iTest->LogSubTest(KTest15); - RunTestsL(); - break; - case 16: - iTest->LogSubTest(KTest16); - RunTestsL(); - break; - case 17: - iTest->LogSubTest(KTest17); - RunTestsL(); - break; - case 18: - // Keep this code in last case statement for main test completion - TestComplete(); - break; - default: - AutoPanic(EAutoPanicWrongTest); - } - - // - if (iFailed) - { - TEST(EFalse); - iFailed=EFalse; - } - ++iTest->iState; - } - -// Macro which is used for construction of CTMultiPtrEventTestStep object -// and also used to call CreateTestL() which creates CTMultiPtrEventTest and CTestBase objects -__WS_CONSTRUCT_STEP__(MultiPtrEventTest) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/tmultiptrevent.h --- a/windowing/windowserver/tauto/tmultiptrevent.h Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,283 +0,0 @@ -// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef TMULTIPTREVENT_H_ -#define TMULTIPTREVENT_H_ - -#include -#include -#include "w32std.h" -#include "../tlib/testbase.h" -#include "AUTO.H" -#include "AUTODLL.H" -#include "../TClick/multiptrclick.h" -#include "TGraphicsHarness.h" - -class CTMultiPtrEventTest; -class CTMultiPtrEventClient; - -/* - * CTEvent derived class which acts as eventhandler and eventbuffer - * Stores the events in buffer, which is used for comparing events received from wserv. - */ -class CTMultiPtrEventBuffer : public CTEvent - { - enum {EEventBufferSize=40, EMovePtsBuffer=10}; -public: - CTMultiPtrEventBuffer(RWsSession *aWs, CTMultiPtrEventTest *aTest, CTMultiPtrEventClient* aClient); - void ConstructL(); - void AddExpectedEvent(TWsEvent &aEvent); - void AddExpectedMovePtEvent(TPoint &aMovePt); - TInt EventsRemaining(); - void SetEventCount(TInt aCount) {iEventCount = aCount;} - void SetNestedLoopState(TBool aLoopStart) {iNestedLoopStarted = aLoopStart;} - TBool NestedLoopState() {return iNestedLoopStarted;} - void GetMoveBufferAndCompareL(); -protected: - // Pure virtual from CTEventBase - void doRunL(); -private: - void TestL(TInt aTest); - void TestL(TInt aTest, TInt aVal1, TInt aVal2,const char *oper, const char *aTestStr, - const TWsEvent *aEvent, const TWsEvent *aExpected, const char *aFile, TUint aLine); - void TestL(TInt aTest, TPoint aVal1, TPoint aVal2,const char *oper, const char *aTestStr, - const TWsEvent *aEvent, const TWsEvent *aExpected, const char *aFile, TUint aLine); -private: - CCirBuf iEventBuffer; - CCirBuf iMovePtsBuffer; - CTMultiPtrEventTest* iTest; - TInt iEventCount; - CTMultiPtrEventClient* iClient; - TBool iNestedLoopStarted; - }; - - -/* - * CTClient derived class which gives Wserv client environment - * i,e iWs, iScreen, iGc, iGroup, iEventHandler etc... - * Owns CTMultiPtrEventBuffer and stores in iEventhandler of its base class - * Accepts the event from test class and passes them on to buffer class - */ -class CTMultiPtrEventClient : public CTClient - { -public: - CTMultiPtrEventClient(CTMultiPtrEventTest *aTest, TBool aSecondaryClient = EFalse); - ~CTMultiPtrEventClient(); - void ConstructL(); - - inline CTBlankWindow* ParentWin() { return iParentWin; } - inline CTBlankWindow* ChildWin() { return iChildWin; } - inline CTMultiPtrEventBuffer* EventBuffer() {return static_cast(iEventHandler);} - inline void SetExpectNonAdvancedPointerEvents() {iExpectNonAdvancedPointerEvents=ETrue;}; - inline void ClearExpectNonAdvancedPointerEvents() {iExpectNonAdvancedPointerEvents=EFalse;}; - - TBool IsSecondaryClient() {return iSecondaryClient;} - - void AddExpectedPointerEvent(TPointerEvent::TType aType, TPoint aPos, TUint8 aPointerNumber, TUint aHandle = 0); - void AddExpectedPointerEvent(TPointerEvent::TType aType, TPoint aPos, TInt aZ, TUint aModifier, TUint8 aPointerNumber, TUint aHandle = 0); - void AddExpectedWsEvent(TEventCode aType, TInt aPointerNumber = 0, TUint aHandle = 0); - void AddExpectedMovePoint(TPoint aPos); - void CalculatePtrPosAndSet3Ddata(TWsEvent& aEvent, TPointerEvent::TType aType, TPoint aPos, TUint aModifiers, TInt aZ, TUint8 aPointerNumber, TUint aHandle); - void ConstructGroupBlankWinL(); - void DeleteGroupBlankWin(); - TBool CheckOrdinalPosition(TInt aWinAutoFocus1); - - // Virtual from CTClient - void ConstructEventHandlerL(); - -private: - CTMultiPtrEventTest* iTest; - TSize iParentWinSize; - TPoint iParentWinPos; - TSize iChildWinSize; - TPoint iChildWinPos; - CTBlankWindow* iParentWin; - CTBlankWindow* iChildWin; - - TBool iSecondaryClient; - - // For AutoFocus test - CTWindowGroup* iGroupWinAutoFocus1; - CTWindowGroup* iGroupWinAutoFocus2; - CTBlankWindow* iWinAutoFocus1; - CTBlankWindow* iWinAutoFocus2; - - TSize iWinSizeAutoFocus1; - TPoint iWinPosAutoFocus1; - TSize iWinSizeAutoFocus2; - TPoint iWinPosAutoFocus2; - TBool iExpectNonAdvancedPointerEvents; - }; - -class RMultiPointerAnim : public RTestAnim - { -public: - static RMultiPointerAnim* NewL(RWindowBase* aWin, RAnimDll* aDll); - RMultiPointerAnim(RAnimDll* aDll) :RTestAnim(*aDll) {} - TInt AddExpectedAnimPointerEvent(TRawEvent::TType aType, TPoint aPos, TInt aZ, TUint aModifier, TUint8 aPointerNumber, TBool aEat = ETrue); - }; - -/* - * CTWsGraphicsBase derived class which implements RunTestCaseL pure virtual. - * Runs all the testcases for multi poniter events. - * For each test case it creates CTMultiPtrEventClient object and creates a nested activescheduler - * Calls NextSetOfEventsL() which in turn calls respective tests depending upong the testcase number - * For each test simulates the events and adds the same event to CTMultiPtrEventBuffer - * When all the tests for a particular testcase completes stops activescheduler - * Repeats the same for all testcases - */ -class CTMultiPtrEventTest : public CTWsGraphicsBase - { -public: - CTMultiPtrEventTest(CTestStep* aStep); - ~CTMultiPtrEventTest(); - void ConstructL(); - void NextSetOfEventsL(); - void Failed(); - - // Functions for simulating events, which use UserSvr::AddEvent - void SimulatePointerEvent(TRawEvent::TType aType, TInt aX, TInt aY, TUint8 aPointerNumber); - void SimulatePointerEvent(TRawEvent::TType aType, TInt aX, TInt aY, TInt aZ, TUint8 aPointerNumber); - void SimulatePointerDownUp(TInt aX, TInt aY, TInt aZ, TUint8 aPointerNumber); - - // Functions for adding event, calls the client's AddExpectedPointer - void AddExpectedPointerEvent(TPointerEvent::TType aType, TPoint aPos, TUint8 aPointerNumber, TUint aHandle = 0); - void AddExpectedPointerEvent(TPointerEvent::TType aType, TPoint aPos, TInt aZ, TUint aModifier, TUint8 aPointerNumber, TUint aHandle = 0, TBool aSecondaryClient = EFalse); - void AddExpectedPointerDownUp(TPoint aPos, TInt aZ, TUint8 aPointerNumber); - void AddExpectedWsEvent(TEventCode aType, TBool aSecondaryClient = EFalse, TInt aPointerNumber = 0, TUint aHandle = 0); - void AddExpectedMultiPtrClickEvent(TPointerEvent::TType aType, TPoint aPos, TInt aZ, TUint aModifier, TUint8 aPointerNumber, TUint aHandle = 0); - void AddExpectedMultiPtrClickOtherEvent(TPointerEvent::TType aType, TPoint aPos, TInt aZ, TUint aModifier, TUint8 aPointerNumber, TUint aHandle); - - void AddExpectedKey(TInt aEventCode, TInt aScanCode, TInt aCode/*=0*/, TInt aRepeats/*=0*/, TUint aModifiers/*=0*/); - void AddExpectedKeyDownUp(TInt aScanCode, TInt aCode=0, TInt aRepeats=0, TUint aModifiers=0); - - // Supplementary function for tests - void TestDragForMultiPointer(TPoint aPtrPos, TInt aPrValue, TUint8 aPointerNumber); - void SimulateAndAddLoneUpEvents(TInt aNumSimulation, TInt aNumAddition, TPoint aPos); - void TestAndDisplayAnimError(); - void GetRemainingEventsFromSecondaryClient(); - void TestAndDisplayPtrClickError(); - void CreatePointerClickPluginL(); - void SetAutoFlush(); - void ResetFlushStopAS(); - void TestFilteringForMultiPointer(TBool aFiltering); - void TestGrabbingForMultiPointer(TBool aGrabbing); - void CreateGroupWinL(); - void DeleteGroupWin(); - void CreateGroupWinForCapturingL(); - void DeleteGroupWinForCapturing(); - void CreateAnimDllAndAnimL(); - void DestroyAnimDllAndAnim(); - void TestCloseProximityHighPressureAPIsL(); - void TestCapturingForMultiPointer(TBool aAllGroups); - void SetThresholdValues(TInt aEnterCloseProx, TInt aExitCloseProx, TInt aEnterHighPres, TInt aExitHighPres); - void NegativeTestingOfProximityPressureAPIsL(); - void TestErrorCodeL(TInt aExpErrCode, TInt aActualErrCode); - void SimulateProximityAndPressureEvents(TInt aCloseProxEnterValue, TInt aCloseProxExitValue, TInt aHighPresEnterValue, TInt aHighPresExitValue); - void SetDefaultScreenMode(); - TPoint GetPointerPostionOnRotatedMode(TPoint aPointerPos, CFbsBitGc::TGraphicsOrientation aRotation); - void LogEventsAdded(); - - // All tests - void MultiPointerEvents(); - void PurgingMultiPointerEvents(); - void MultiPointerEventsForAnimsL(); - void MultiClientMultiPointerEvents(); - void MultiPointerEventsForPointerClickL(); - void MultiPointerEventsInDiffScreenModes(); - void FilteringMultiPointerEvents(); - void GrabbingMultiPointerEvents(); - void VirtualKeyBoardForMultiplePointers(); - void DoubleClickForMultiplePointers(); - void MultiPointerOutOfRangeEvents(); - void AutoForeGroundForMultiplePointersL(); - void EmulationRulesForMultiplePointers(); - void CloseProximityAndHighPressureEventsL(); - void OutOfBoundValueTesting(); - void CapturingMultiPointerEvents(); - void NegativeTestsForProximityPressureEventsL(); - void PointerRepeatEventForMultiplePointers(); - void SetExpectNonAdvancedPointerEvents(TBool aSecondaryClient=EFalse); - void ClearExpectNonAdvancedPointerEvents(TBool aSecondaryClient=EFalse); - -protected: - void RunTestCaseL(TInt aCurTestCase); -private: - void RunTestsL(); -private: - TInt iEventSet; // Set of events for one particular test case - TBool iFailed; - TBool iActiveSchedulerStarted; - TBool iTheClientFlush; - TBool iClientFlush; - TBool iSecClientFlush; - TSize iPhysicalScreenSize; - TRect iOrigPtrCursorArea; - - TUint iPointerNumber; - TInt iMaxDevPointers; - TInt iMaxUiPointers; - TInt iMaxPressure; - TInt iPressureStep; - TInt iMaxProximity; - TInt iProximityStep; - - TInt iEnterCloseProximityThreshold; - TInt iExitCloseProximityThreshold; - TInt iEnterHighPressureThreshold; - TInt iExitHighPressureThreshold; - - CTMultiPtrEventClient *iMultiPtrEventClient; - CTMultiPtrEventClient *iSecMultiPtrEventClient; - - RAnimDll* iAnimDll; - RMultiPointerAnim* iAnim; - - RSoundPlugIn iClick; - TBool iPtrPluginLoaded; - RChunk iChunk; - RHeap* iHeap; - TAny* iErrDesc; - - TInt iCurrentScreenMode; - TBool iChangeScreenMode; - - CTWindowGroup* iGroupWinForEmul; - CTBlankWindow* iWinForEmul; - - CTWindowGroup* iGroupWinForCapturing; - CTBlankWindow* iWinForCapturing; - - TInt iYOffset; - }; - -class CTMultiPtrEventTestStep : public CTGraphicsStep - { -public: - CTMultiPtrEventTestStep(); -protected: - //from CTGraphicsStep - virtual CTGraphicsBase* CreateTestL(); - }; - -_LIT(KTMultiPtrEventTestStep, "TMultiPtrEventTest"); - -#endif /*TMULTIPTREVENT_H_*/ diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/topaquechild.cpp --- a/windowing/windowserver/tauto/topaquechild.cpp Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,167 +0,0 @@ -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// This file is part of manual test (group\inc113743.mmp) to check Wserv behaviour when -// exposing a transparent window that is obscured by some opaque child window above it. -// Without the fix, that transparent window will be drawn as opaque window -// because its transparent regions is null (not re-created due to its update flag is not -// set as it is not traceable via transparent regions linked list of windows above it. -// Some illustration when the situation will trigger the defect (side view), -// ---- Child (opaque) -// ---------- Parent (transparent) -// ---- Other transparent window obscured by opaque child -// This defect is only reproducable when window shadowing is not used, so it cannot be -// tested from standard Wserv test framework. -// @SYMTestCaseID GRAPHICS-WSERV-0450 -// @SYMDEF INC113743 -// @SYMTestCaseDesc Perform test on Wserv behaviour in exposing transparent windows which is obscured indirectly by opaque child window -// @SYMTestPriority High -// @SYMTestStatus Implemented -// @SYMTestActions Create opaque and transparent windows in the following dimension and z-order -// ---- opaque child -// ---------- transparent parent -// ---- other transparent underneath obscured and non traceable via transparent parent iTransparentRegions -// and then make transparent parent window invisible -// @SYMTestExpectedResults The expected result are: other transparent window underneath is exposed and redrawn properly not becoming opaque -// -// - -#include -#include -#include - -#define ENullWsHandle 0xffffffff - -void MainL() - { - const TSize KTestSize(320,240); - const TSize KHalfSize(160,240); - const TInt KScreenNo = 1; - - RRegion shape; - shape.AddRect(TRect(0,0,160,120)); - shape.AddRect(TRect(160,120,320,240)); - CleanupClosePushL(shape); - - RWsSession ws; - User::LeaveIfError(ws.Connect()); - CleanupClosePushL(ws); - - CWsScreenDevice* scr = new(ELeave) CWsScreenDevice(ws); - CleanupStack::PushL(scr); - User::LeaveIfError(scr->Construct(KScreenNo)); - TDisplayMode displayMode = scr->DisplayMode(); - - CWindowGc* gc = NULL; - User::LeaveIfError(scr->CreateContext(gc)); - CleanupStack::PushL(gc); - - RWindowGroup group(ws); - User::LeaveIfError(group.Construct(0x0badface, ETrue)); - CleanupClosePushL(group); - - // create transparent window underneath that will be obscured by some opaque child window above it - RWindow transWinUnderneath(ws); - User::LeaveIfError(transWinUnderneath.Construct(group, ENullWsHandle)); - CleanupClosePushL(transWinUnderneath); - transWinUnderneath.SetShadowDisabled(ETrue); - transWinUnderneath.SetExtent(TPoint(0,0),KTestSize/*KHalfSize*/); - transWinUnderneath.SetTransparencyAlphaChannel(); - transWinUnderneath.SetRequiredDisplayMode(EColor64K); - transWinUnderneath.SetBackgroundColor(TRgb(255,0,0,128)); - transWinUnderneath.SetShape(shape); - transWinUnderneath.Activate(); - transWinUnderneath.Invalidate(); - transWinUnderneath.BeginRedraw(); - transWinUnderneath.EndRedraw(); - ws.Flush(); - - User::After(1*1000*1000); - - // save the reference image (semi-transparent red window) - CFbsBitmap* refImage = new(ELeave) CFbsBitmap; - CleanupStack::PushL(refImage); - User::LeaveIfError(refImage->Create(KTestSize, displayMode)); - scr->CopyScreenToBitmap(refImage); - - // create transparent window parent which will have opaque child - RWindow transWinParent(ws); - User::LeaveIfError(transWinParent.Construct(group, ENullWsHandle)); - CleanupClosePushL(transWinParent); - transWinParent.SetShadowDisabled(ETrue); - transWinParent.SetExtent(TPoint(0,0),KTestSize); - transWinParent.SetTransparencyAlphaChannel(); - transWinParent.SetRequiredDisplayMode(EColor64K); - transWinParent.SetBackgroundColor(TRgb(255,255,255,0)); - transWinParent.Activate(); - - transWinParent.Invalidate(); - transWinParent.BeginRedraw(); - transWinParent.EndRedraw(); - ws.Flush(); - - // create opaque child window that obscure transparent window underneath (not its parent) - RWindow opaqueWinChild(ws); - User::LeaveIfError(opaqueWinChild.Construct(transWinParent, ENullWsHandle)); - CleanupClosePushL(opaqueWinChild); - opaqueWinChild.SetExtent(TPoint(0,0),KTestSize/*KHalfSize*/); - opaqueWinChild.SetRequiredDisplayMode(EColor64K); - opaqueWinChild.SetShape(shape); - opaqueWinChild.Activate(); - - opaqueWinChild.Invalidate(); - opaqueWinChild.BeginRedraw(); - gc->Activate(opaqueWinChild); - gc->SetBrushStyle(CGraphicsContext::ESolidBrush); - gc->SetPenStyle(CGraphicsContext::ENullPen); - gc->SetBrushColor(KRgbGreen); - gc->Clear(); - gc->SetBrushColor(KRgbBlue); - gc->DrawEllipse(KTestSize/*KHalfSize*/); - gc->Deactivate(); - opaqueWinChild.EndRedraw(); - ws.Flush(); - - User::After(1*1000*1000); - - // preform the test by making transparent window parent invisible - transWinParent.SetVisible(EFalse); - ws.Flush(); - - User::After(2*1000*1000); - - // save the test image (without the fix this would be an opaque red window) - CFbsBitmap* testImage = new(ELeave) CFbsBitmap; - CleanupStack::PushL(testImage); - User::LeaveIfError(testImage->Create(KTestSize, displayMode)); - scr->CopyScreenToBitmap(testImage); - - _LIT(KPanicMsg, "Test Failed"); - TInt nbytes = CFbsBitmap::ScanLineLength(KTestSize.iWidth, displayMode)*KTestSize.iHeight; - if (Mem::Compare((TUint8*)testImage->DataAddress(), nbytes, (TUint8*)refImage->DataAddress(), nbytes)!=0) - User::Panic(KPanicMsg, 0); - - CleanupStack::PopAndDestroy(10, &shape); - } - -GLDEF_C TInt E32Main() - { - CTrapCleanup* cs = CTrapCleanup::New(); - if (!cs) - return KErrNoMemory; - - TRAPD(err,MainL()); - - delete cs; - return err; - } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/tw32cmdbuf.cpp --- a/windowing/windowserver/tauto/tw32cmdbuf.cpp Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,283 +0,0 @@ -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// The fix solves the problem of bitmap drawing command being added to the window server -// command buffer without the bitmap handle(s) being added to the command buffer bitmap array. -// -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include "tw32cmdbuf.h" - -const TInt KMaxTestIterations = 300; -const TInt KMinTestIterations = 100; - -CTW32CmdBuf::CTW32CmdBuf(CTestStep* aStep): - CTGraphicsBase(aStep) - { - } - -CTW32CmdBuf::~CTW32CmdBuf() - { - } - -void CTW32CmdBuf::ConstructL() - { - } - -void CTW32CmdBuf::RunTestCaseL(TInt aCurTestCase) - { - ((CTW32CmdBufStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); - switch(aCurTestCase) - { - case 1: - ((CTW32CmdBufStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0452")); - INFO_PRINTF1(_L("Test all the drawing commands involving a CFbsBitmap\n")); - DoCmdBufTestsL(); - break; - default: - ((CTW32CmdBufStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - ((CTW32CmdBufStep*)iStep)->CloseTMSGraphicsStep(); - INFO_PRINTF1(_L("Test complete\n")); - TestComplete(); - } - ((CTW32CmdBufStep*)iStep)->RecordTestResultL(); - } - -/** -* TTestFunctionPtr pointer-to-function type definition -*/ -typedef void (*TTestFunctionPtr)(CWindowGc* aGc, CFbsBitmap* aBitmap, CFbsBitmap* aMask); - - -/** -* Calls CWindowGc::DrawBitmap(const TPoint &aTopLeft, const CFbsBitmap *aDevice) -*/ -void CallDrawBitmap1(CWindowGc* aGc, CFbsBitmap* aBitmap, CFbsBitmap* /*aMask*/) - { - aGc->DrawBitmap(TPoint(0, 0), aBitmap); - } - -/** -* Calls CWindowGc::DrawBitmap(const TRect &aDestRect, const CFbsBitmap *aDevice) -*/ -void CallDrawBitmap2(CWindowGc* aGc, CFbsBitmap* aBitmap, CFbsBitmap* /*aMask*/) - { - aGc->DrawBitmap(TRect(0, 0, 100, 100), aBitmap); - } - -/** -* Calls CWindowGc::DrawBitmap(const TRect &aDestRect, const CFbsBitmap *aDevice, const TRect &aSourceRect) -*/ -void CallDrawBitmap3(CWindowGc* aGc, CFbsBitmap* aBitmap, CFbsBitmap* /*aMask*/) - { - aGc->DrawBitmap(TRect(0, 0, 100, 100), aBitmap, TRect(0, 0, 100, 100)); - } - -/** -* Calls CWindowGc::DrawBitmapMasked(const TRect& aDestRect, const CFbsBitmap* aBitmap, const TRect& aSourceRect, const CFbsBitmap* aMaskBitmap, TBool aInvertMask) -*/ -void CallDrawBitmapMasked(CWindowGc* aGc, CFbsBitmap* aBitmap, CFbsBitmap* aMask) - { - aGc->DrawBitmapMasked(TRect(0, 0, 100, 100), aBitmap, TRect(0, 0, 100, 100), aMask, EFalse); - } - -/** -* Calls CWindowGc::UseBrushPattern(const CFbsBitmap *aDevice) -*/ -void CallUseBrushPattern(CWindowGc* aGc, CFbsBitmap* aBitmap, CFbsBitmap* /*aMask*/) - { - aGc->UseBrushPattern(aBitmap); - } - -/** -* Calls CWindowGc::BitBlt(const TPoint &aPos, const CFbsBitmap *aBitmap) -*/ -void CallBitBlt1(CWindowGc* aGc, CFbsBitmap* aBitmap, CFbsBitmap* /*aMask*/) - { - aGc->BitBlt(TPoint(0, 0), aBitmap); - } - -/** -* Calls CWindowGc::BitBlt(const TPoint &aDestination, const CFbsBitmap *aBitmap, const TRect &aSource) -*/ -void CallBitBlt2(CWindowGc* aGc, CFbsBitmap* aBitmap, CFbsBitmap* /*aMask*/) - { - aGc->BitBlt(TPoint(0, 0), aBitmap, TRect(0, 0, 100, 100)); - } - -/** -* Calls CWindowGc::BitBltMasked(const TPoint& aPoint,const CFbsBitmap* aBitmap,const TRect& aSourceRect,const CFbsBitmap* aMaskBitmap,TBool aInvertMask) -*/ -void CallBitBltMasked(CWindowGc* aGc, CFbsBitmap* aBitmap, CFbsBitmap* aMask) - { - aGc->BitBltMasked(TPoint(0, 0), aBitmap, TRect(0, 0, 100, 100), aMask, EFalse); - } - -/** -* Calls CWindowGc::AlphaBlendBitmaps(const TPoint& aDestPt, const CFbsBitmap* aSrcBmp, const TRect& aSrcRect, const CFbsBitmap* aAlphaBmp, const TPoint& aAlphaPt) -*/ -void CallAlphaBlendBitmaps(CWindowGc* aGc, CFbsBitmap* aBitmap, CFbsBitmap* aMask) - { - aGc->AlphaBlendBitmaps(TPoint(0, 0), aBitmap, TRect(0, 0, 100, 100), aMask, TPoint(0, 0)); - } - -/** -* Drawing command function array. -*/ -const TTestFunctionPtr KTestFunctions[] = - { - CallDrawBitmap1, - CallDrawBitmap2, - CallDrawBitmap3, - CallDrawBitmapMasked, - CallUseBrushPattern, - CallBitBlt1, - CallBitBlt2, - CallBitBltMasked, - CallAlphaBlendBitmaps, - }; - -/** - * @SYMTestCaseID GRAPHICS-WSERV-0452 - * @SYMTestCaseDesc Tests drawing commands with bitmap handles. - * @SYMDEF INC111655 - * @SYMFssID CWindowGc::DrawBitmap() \n - * CWindowGc::DrawBitmapMasked()\n - * CWindowGc::UseBrushPattern()\n - * CWindowGc::BitBlt()\n - * CWindowGc::AlphaBlendBitmaps() - * @SYMTestPriority Critical - * @SYMTestType Unit Test - * @SYMTestPurpose To ensure drawing commands with bitmap handles are added to the - command buffer successfully when the buffer is full. - * @SYMTestActions Fill the command buffer with CWindowGc::Clear() commands in a loop until - the buffer is full, create bitmap(s), then call the draw command and then - delete the bitmap handle(s). All tests are done in a second thread. - * @SYMTestExpectedResults The function should not panic. Without the fix the functions will panic - with WSERV 7. - * @SYMTestStatus Implemented - */ -void CTW32CmdBuf::DoCmdBufTestsL() - { - CreateSecondThreadAndDoTestL(ECallDrawBitmap1); - CreateSecondThreadAndDoTestL(ECallDrawBitmap2); - CreateSecondThreadAndDoTestL(ECallDrawBitmap3); - CreateSecondThreadAndDoTestL(ECallDrawBitmapMasked); - CreateSecondThreadAndDoTestL(ECallUseBrushPattern); - CreateSecondThreadAndDoTestL(ECallBitBlt1); - CreateSecondThreadAndDoTestL(ECallBitBlt2); - CreateSecondThreadAndDoTestL(ECallBitBltMasked); - CreateSecondThreadAndDoTestL(ECallAlphaBlendBitmaps); - } - -/** -* Creates a second thread to run the test. -* -* @param aFunctionIndex The drawing function command to be executed. All commands are defined in TestFunctionIndex. -*/ -void CTW32CmdBuf::CreateSecondThreadAndDoTestL(TTestFunctionIndex aFunctionIndex) - { - RThread thread; - TBuf<30> threadName(KTW32CmdBufSecondThread); - static TInt threadSerialNumber = 0; - threadName.AppendNum(++threadSerialNumber); - User::LeaveIfError(thread.Create(threadName, TestCmdBufFunction, KDefaultStackSize, KMinHeapSize, 0x4000, &aFunctionIndex)); - TRequestStatus status; - thread.Logon(status); - thread.Resume(); - User::WaitForRequest(status); - TEST(thread.ExitType()==EExitKill); - TEST(thread.ExitReason() == KErrNone); - thread.Close(); - } - -/** -* Runs the test in a second thread. -* -* @param aFunctionIndex The drawing function command to be executed. All commands are defined in TestFunctionIndex. -*/ -TInt CTW32CmdBuf::DoTestCmdBufFunctionL(TTestFunctionIndex aFunctionIndex) - { - RWsSession session; - User::LeaveIfError(session.Connect()); - CleanupClosePushL(session); - CWsScreenDevice *device = new(ELeave) CWsScreenDevice(session); - CleanupStack::PushL(device); - User::LeaveIfError(device->Construct(CTestBase::iScreenNo)); - CWindowGc* gc; - User::LeaveIfError(device->CreateContext(gc)); - CleanupStack::PushL(gc); - RWindowGroup group(session); - User::LeaveIfError(group.Construct(1, EFalse)); - CleanupClosePushL(group); - RWindow window(session); - User::LeaveIfError(window.Construct(group, 2)); - CleanupClosePushL(window); - window.SetExtent(TPoint(0,0), TSize(200, 200)); - User::LeaveIfError(window.SetRequiredDisplayMode(EColor64K)); - window.Activate(); - gc->Activate(window); - session.SetAutoFlush(EFalse); - window.Invalidate(); - window.BeginRedraw(); - for(TInt i=KMinTestIterations; iClear(); - } - - CFbsBitmap* bitmap = new(ELeave) CFbsBitmap; - CleanupStack::PushL(bitmap); - User::LeaveIfError(bitmap->Create(TSize(100, 100), EColor64K)); - CFbsBitmap* mask = new(ELeave) CFbsBitmap; - CleanupStack::PushL(mask); - User::LeaveIfError(mask->Create(TSize(100, 100), EColor64K)); - KTestFunctions[aFunctionIndex](gc, bitmap, mask); - CleanupStack::PopAndDestroy(2); - session.Flush(); - } - window.EndRedraw(); - gc->Deactivate(); - CleanupStack::PopAndDestroy(5); - return KErrNone; - } - -/** -* Second thread entry function. -* -* @param aInfo The parameter(s) passed to the second thread in this case the function index. -*/ -TInt CTW32CmdBuf::TestCmdBufFunction(TAny* aInfo) - { - if(!aInfo) - { - return KErrArgument; - } - TTestFunctionIndex functionIndex = *(TTestFunctionIndex*)aInfo; - CTrapCleanup *trap = CTrapCleanup::New(); - __ASSERT_ALWAYS(trap, User::Invariant()); - - TRAPD(err, DoTestCmdBufFunctionL(functionIndex)); - - delete trap; - return err; - } - -__CONSTRUCT_STEP__(W32CmdBuf) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/tw32cmdbuf.h --- a/windowing/windowserver/tauto/tw32cmdbuf.h Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,73 +0,0 @@ -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef TW32CMDBUF_H -#define TW32CMDBUF_H - -#include -#include -#include "../tlib/testbase.h" -#include "AUTO.H" -#include "TGraphicsHarness.h" - -_LIT(KTW32CmdBufSecondThread, "TW32CmdBufSecondThread"); - -enum TTestFunctionIndex - { - ECallDrawBitmap1, - ECallDrawBitmap2, - ECallDrawBitmap3, - ECallDrawBitmapMasked, - ECallUseBrushPattern, - ECallBitBlt1, - ECallBitBlt2, - ECallBitBltMasked, - ECallAlphaBlendBitmaps, - }; - -class CTW32CmdBuf : public CTGraphicsBase - { -public: - CTW32CmdBuf(CTestStep* aStep); - ~CTW32CmdBuf(); - void ConstructL(); - -protected: - virtual void RunTestCaseL(TInt aCurTestCase); -private: - void DoCmdBufTestsL(); - void CreateSecondThreadAndDoTestL(TTestFunctionIndex aFunctionIndex); - static TInt TestCmdBufFunction(TAny* aInfo); - static TInt DoTestCmdBufFunctionL(TTestFunctionIndex aFunctionIndex); - }; - -class CTW32CmdBufStep : public CTGraphicsStep - { -public: - CTW32CmdBufStep(); -protected: - //from CTGraphicsStep - virtual CTGraphicsBase* CreateTestL(); - }; - -_LIT(KTW32CmdBufStep,"TW32CmdBuf"); - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/twindowsizecache.cpp --- a/windowing/windowserver/tauto/twindowsizecache.cpp Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2940 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// General window tests -// -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include "twindowsizecache.h" - -CTWindowSizeCacheTest::CTWindowSizeCacheTest(CTestStep* aStep) : CTWsGraphicsBase(aStep) - {} - -CTWindowSizeCacheTest::~CTWindowSizeCacheTest() - { - } - -void CTWindowSizeCacheTest::ConstructL() - {} - - -void CTWindowSizeCacheTest::TestCreateRWindowL(TSizeCacheStatus aEnableWindowSizeCache) - { - __UHEAP_MARK; - // w* State Initial - RWsSession rws; - TInt err = rws.Connect(); - CleanupClosePushL(rws); - TEST(KErrNone == err); - - if (ETestSizeCacheEnabled == aEnableWindowSizeCache) - { - rws.EnableWindowSizeCacheL(); - } - - RWindowGroup wg(rws); - err = wg.Construct(0); - CleanupClosePushL(wg); - TEST(KErrNone == err); - - // w1 State 0 - RWindow w1(rws); - err = w1.Construct(wg,1); - CleanupClosePushL(w1); - TEST(KErrNone == err); - - // w2 State 0 - RWindow w2(rws); - err = w2.Construct(wg,2); - CleanupClosePushL(w2); - TEST(KErrNone == err); - - CleanupStack::Pop(2); - - // w1 State Final - w1.Close(); - // w2 State Final - w2.Close(); - - RWindow w3(rws); - // w3 State 0 - err = w3.Construct(wg,1); - CleanupClosePushL(w3); - TEST(KErrNone == err); - - CleanupStack::Pop(2); - - // w3 State Final - w3.Close(); - - wg.Close(); - - RWindowGroup wg2(rws); - err = wg2.Construct(0); - CleanupClosePushL(wg2); - TEST(KErrNone == err); - - RWindowGroup wg3(rws); - err = wg3.Construct(1); - CleanupClosePushL(wg3); - TEST(KErrNone == err); - - // w4 State 0 - RWindow w4(rws); - err = w4.Construct(wg2,2); - CleanupClosePushL(w4); - TEST(KErrNone == err); - - // w5 State 0 - RWindow w5(rws); - err = w5.Construct(wg3,3); - CleanupClosePushL(w5); - TEST(KErrNone == err); - - CleanupStack::Pop(5); - - // w4 State Final - w4.Close(); - - // w5 State Final - // Check nothing bad happens when calling Close more than once on RWindow - w5.Close(); - w5.Close(); - - // Check nothing bad happens when calling Close more than once on RWindowGroup - wg2.Close(); - wg2.Close(); - - wg3.Close(); - - // Check nothing bad happens when calling Close more than once on RWsSession - rws.Close(); - rws.Close(); - __UHEAP_MARKEND; - } - -void CTWindowSizeCacheTest::TestCreateRBlankWindowL(TSizeCacheStatus aEnableWindowSizeCache) - { - __UHEAP_MARK; - // w* State Initial - RWsSession rws; - TInt err = rws.Connect(); - CleanupClosePushL(rws); - TEST(KErrNone == err); - - if (ETestSizeCacheEnabled == aEnableWindowSizeCache) - { - rws.EnableWindowSizeCacheL(); - } - - RWindowGroup wg(rws); - err = wg.Construct(0); - CleanupClosePushL(wg); - TEST(KErrNone == err); - - // w1 State 0 - RBlankWindow w1(rws); - err = w1.Construct(wg,1); - CleanupClosePushL(w1); - TEST(KErrNone == err); - - // w2 State 0 - RBlankWindow w2(rws); - err = w2.Construct(wg,2); - CleanupClosePushL(w2); - TEST(KErrNone == err); - - CleanupStack::Pop(2); - - // w1 State Final - w1.Close(); - // w2 State Final - w2.Close(); - - RBlankWindow w3(rws); - // w3 State 0 - err = w3.Construct(wg,1); - CleanupClosePushL(w3); - TEST(KErrNone == err); - - CleanupStack::Pop(2); - - // w3 State Final - w3.Close(); - - wg.Close(); - - RWindowGroup wg2(rws); - err = wg2.Construct(0); - CleanupClosePushL(wg2); - TEST(KErrNone == err); - - RWindowGroup wg3(rws); - err = wg3.Construct(1); - CleanupClosePushL(wg3); - TEST(KErrNone == err); - - // w4 State 0 - RBlankWindow w4(rws); - err = w4.Construct(wg2,2); - CleanupClosePushL(w4); - TEST(KErrNone == err); - - // w5 State 0 - RBlankWindow w5(rws); - err = w5.Construct(wg3,3); - CleanupClosePushL(w5); - TEST(KErrNone == err); - - CleanupStack::Pop(5); - - // w4 State Final - w4.Close(); - - // w5 State Final - // Check nothing bad happens when calling Close more than once on RBlankWindow - w5.Close(); - w5.Close(); - - wg2.Close(); - wg3.Close(); - rws.Close(); - __UHEAP_MARKEND; - } - -void CTWindowSizeCacheTest::TestCreateRBackedUpWindowL(TSizeCacheStatus aEnableWindowSizeCache, TDisplayMode aDisplayMode) - { - __UHEAP_MARK; - // w* State Initial - RWsSession rws; - TInt err = rws.Connect(); - CleanupClosePushL(rws); - TEST(KErrNone == err); - - if (ETestSizeCacheEnabled == aEnableWindowSizeCache) - { - rws.EnableWindowSizeCacheL(); - } - - RWindowGroup wg(rws); - err = wg.Construct(0); - CleanupClosePushL(wg); - TEST(KErrNone == err); - - // w1 State 0 - RBackedUpWindow w1(rws); - err = w1.Construct(wg,aDisplayMode,1); - CleanupClosePushL(w1); - TEST(KErrNone == err); - - // w2 State 0 - RBackedUpWindow w2(rws); - err = w2.Construct(wg,aDisplayMode,2); - CleanupClosePushL(w2); - TEST(KErrNone == err); - - CleanupStack::Pop(2); - - // w1 State Final - w1.Close(); - - // w2 State Final - w2.Close(); - - RBackedUpWindow w3(rws); - // w3 State 0 - err = w3.Construct(wg,aDisplayMode,1); - CleanupClosePushL(w3); - TEST(KErrNone == err); - - CleanupStack::Pop(2); - - // w3 State Final - w3.Close(); - - wg.Close(); - - RWindowGroup wg2(rws); - CleanupClosePushL(wg2); - err = wg2.Construct(0); - TEST(KErrNone == err); - - RWindowGroup wg3(rws); - err = wg3.Construct(1); - CleanupClosePushL(wg3); - TEST(KErrNone == err); - - // w4 State 0 - RBackedUpWindow w4(rws); - err = w4.Construct(wg2,aDisplayMode,2); - CleanupClosePushL(w4); - TEST(KErrNone == err); - - // w5 State 0 - RBackedUpWindow w5(rws); - err = w5.Construct(wg3,aDisplayMode,3); - CleanupClosePushL(w5); - TEST(KErrNone == err); - - CleanupStack::Pop(5); - - // w4 State Final - w4.Close(); - - // w5 State Final - // Check nothing bad happens when calling Close more than once on RBackedUpWindow - w5.Close(); - w5.Close(); - - wg2.Close(); - wg3.Close(); - rws.Close(); - __UHEAP_MARKEND; - } - -void CTWindowSizeCacheTest::TestRWindowNoCacheEntryL(TSizeCacheStatus aEnableWindowSizeCache) - { - __UHEAP_MARK; - // w* State Initial - RWsSession rws; - TInt err = rws.Connect(); - CleanupClosePushL(rws); - TEST(err==KErrNone); - - if (aEnableWindowSizeCache) - { - rws.EnableWindowSizeCacheL(); - } - - RWindowGroup wg(rws); - wg.Construct(0); - CleanupClosePushL(rws); - - // w1 State 0 - RWindow w1(rws); - w1.Construct(wg,1); - CleanupClosePushL(w1); - - // w1 State Final - CleanupStack::Pop(); - w1.Close(); - - CleanupStack::Pop(); - wg.Close(); - - CleanupStack::Pop(); - rws.Close(); - - __UHEAP_MARKEND; - } - -void CTWindowSizeCacheTest::TestRWindowNoCacheEntrySetExtentErrL(TSizeCacheStatus aEnableWindowSizeCache) - { - __UHEAP_MARK; - // w* State Initial - RWsSession rws; - TInt err = rws.Connect(); - CleanupClosePushL(rws); - TEST(err==KErrNone); - - if (aEnableWindowSizeCache) - { - rws.EnableWindowSizeCacheL(); - } - - RWindowGroup wg(rws); - wg.Construct(0); - CleanupClosePushL(rws); - - // w1 State 0 - RWindow w1(rws); - w1.Construct(wg,1); - CleanupClosePushL(w1); - - // w1 State 0 - TPoint point1 (10101,897); - TSize size1 (10001,123); - err = w1.SetExtentErr(point1, size1); - TEST(KErrNone == err); - - // w1 State Final - CleanupStack::Pop(); - w1.Close(); - - CleanupStack::Pop(); - wg.Close(); - - CleanupStack::Pop(); - rws.Close(); - - __UHEAP_MARKEND; - } - -void CTWindowSizeCacheTest::TestRWindowNoCacheEntrySetSizeErrL(TSizeCacheStatus aEnableWindowSizeCache) - { - __UHEAP_MARK; - // w* State Initial - RWsSession rws; - TInt err = rws.Connect(); - CleanupClosePushL(rws); - TEST(err==KErrNone); - - if (aEnableWindowSizeCache) - { - rws.EnableWindowSizeCacheL(); - } - - RWindowGroup wg(rws); - wg.Construct(0); - CleanupClosePushL(rws); - - // w1 State 0 - RWindow w1(rws); - w1.Construct(wg,1); - CleanupClosePushL(w1); - - // w1 State 0 - TSize size1 (10001,123); - err = w1.SetSizeErr(size1); - TEST(KErrNone == err); - - // w1 State Final - CleanupStack::Pop(); - w1.Close(); - - CleanupStack::Pop(); - wg.Close(); - - CleanupStack::Pop(); - rws.Close(); - - __UHEAP_MARKEND; - } - -void CTWindowSizeCacheTest::TestRWindowNoCacheEntrySetExtentL(TSizeCacheStatus aEnableWindowSizeCache) - { - __UHEAP_MARK; - // w* State Initial - RWsSession rws; - TInt err = rws.Connect(); - CleanupClosePushL(rws); - TEST(err==KErrNone); - - if (aEnableWindowSizeCache) - { - rws.EnableWindowSizeCacheL(); - } - - RWindowGroup wg(rws); - wg.Construct(0); - CleanupClosePushL(rws); - - // w1 State 0 - RWindow w1(rws); - w1.Construct(wg,1); - CleanupClosePushL(w1); - - // w1 State 0 - TPoint point1 (10101,897); - TSize size1 (10001,123); - w1.SetExtent(point1, size1); - rws.Flush(); - - // w1 State Final - CleanupStack::Pop(); - w1.Close(); - - CleanupStack::Pop(); - wg.Close(); - - CleanupStack::Pop(); - rws.Close(); - - __UHEAP_MARKEND; - } - -void CTWindowSizeCacheTest::TestRWindowNoCacheEntrySetSizeL(TSizeCacheStatus aEnableWindowSizeCache) - { - __UHEAP_MARK; - // w* State Initial - RWsSession rws; - TInt err = rws.Connect(); - CleanupClosePushL(rws); - TEST(err==KErrNone); - - if (aEnableWindowSizeCache) - { - rws.EnableWindowSizeCacheL(); - } - - RWindowGroup wg(rws); - wg.Construct(0); - CleanupClosePushL(rws); - - // w1 State 0 - RWindow w1(rws); - w1.Construct(wg,1); - CleanupClosePushL(w1); - - // w1 State 0 - TSize size1 (10001,123); - w1.SetSize(size1); - rws.Flush(); - - // w1 State Final - CleanupStack::Pop(); - w1.Close(); - - CleanupStack::Pop(); - wg.Close(); - - CleanupStack::Pop(); - rws.Close(); - - __UHEAP_MARKEND; - } - -void CTWindowSizeCacheTest::TestRWindowNoCacheEntryEnableWindowSizeCacheL() - { - __UHEAP_MARK; - // w* State Initial - RWsSession rws; - TInt err = rws.Connect(); - CleanupClosePushL(rws); - TEST(err==KErrNone); - - rws.EnableWindowSizeCacheL(); - - RWindowGroup wg(rws); - wg.Construct(0); - CleanupClosePushL(rws); - - // w1 State 0 - RWindow w1(rws); - w1.Construct(wg,1); - CleanupClosePushL(w1); - - // w1 State 0 - // Only the first call to EnableWindowSizeCacheL() should have an effect - // All subsequent calls to EnableWindowSizeCacheL() should have no effect - rws.EnableWindowSizeCacheL(); - - // w1 State Final - CleanupStack::Pop(); - w1.Close(); - - CleanupStack::Pop(); - wg.Close(); - - CleanupStack::Pop(); - rws.Close(); - - __UHEAP_MARKEND; - } - -void CTWindowSizeCacheTest::TestRWindowCacheEntryExistsCacheCleanL(TSizeCacheStatus aEnableWindowSizeCache) - { - __UHEAP_MARK; - // w* State Initial - RWsSession rws; - TInt err = rws.Connect(); - CleanupClosePushL(rws); - TEST(err==KErrNone); - - if (aEnableWindowSizeCache) - { - rws.EnableWindowSizeCacheL(); - } - - RWindowGroup wg(rws); - wg.Construct(0); - CleanupClosePushL(rws); - - // w1 State 0 - RWindow w1(rws); - w1.Construct(wg,1); - CleanupClosePushL(w1); - - // w1 State 0 - TSize size1 (10001,123); - w1.SetSize(size1); - rws.Flush(); - - // w1 State 1 - TSize retSize1 = w1.Size(); - TEST(retSize1 == size1); - - // w1 State Final - CleanupStack::Pop(); - w1.Close(); - - CleanupStack::Pop(); - wg.Close(); - - CleanupStack::Pop(); - rws.Close(); - - __UHEAP_MARKEND; - } - -void CTWindowSizeCacheTest::TestRWindowCacheEntryExistsCacheCleanSizeL(TSizeCacheStatus aEnableWindowSizeCache) - { - __UHEAP_MARK; - // w* State Initial - RWsSession rws; - TInt err = rws.Connect(); - CleanupClosePushL(rws); - TEST(err==KErrNone); - - if (aEnableWindowSizeCache) - { - rws.EnableWindowSizeCacheL(); - } - - RWindowGroup wg(rws); - wg.Construct(0); - CleanupClosePushL(rws); - - // w1 State 0 - RWindow w1(rws); - w1.Construct(wg,1); - CleanupClosePushL(w1); - - // w1 State 0 - TSize size1 (10001,123); - w1.SetSize(size1); - rws.Flush(); - - // w1 State 1 - TSize retSize1 = w1.Size(); - TEST(retSize1 == size1); - - // w1 State 1 - TSize retSize2 = w1.Size(); - TEST(retSize2 == size1); - - // w1 State Final - CleanupStack::Pop(); - w1.Close(); - - CleanupStack::Pop(); - wg.Close(); - - CleanupStack::Pop(); - rws.Close(); - - __UHEAP_MARKEND; - } - -void CTWindowSizeCacheTest::TestRWindowCacheEntryExistsCacheCleanEnableWindowSizeCacheL() - { - __UHEAP_MARK; - // w* State Initial - RWsSession rws; - TInt err = rws.Connect(); - CleanupClosePushL(rws); - TEST(err==KErrNone); - - rws.EnableWindowSizeCacheL(); - - RWindowGroup wg(rws); - wg.Construct(0); - CleanupClosePushL(rws); - - // w1 State 0 - RWindow w1(rws); - w1.Construct(wg,1); - CleanupClosePushL(w1); - - // w1 State 0 - TSize size1 (10001,123); - w1.SetSize(size1); - rws.Flush(); - - // w1 State 1 - TSize retSize1 = w1.Size(); - TEST(retSize1 == size1); - - // w1 State 1 - // Only the first call to EnableWindowSizeCacheL() should have an effect - // All subsequent calls to EnableWindowSizeCacheL() should have no effect - rws.EnableWindowSizeCacheL(); - - // w1 State Final - CleanupStack::Pop(); - w1.Close(); - - CleanupStack::Pop(); - wg.Close(); - - CleanupStack::Pop(); - rws.Close(); - - __UHEAP_MARKEND; - } - -void CTWindowSizeCacheTest::TestRWindowCacheEntryExistsCacheCleanEnableWindowSizeCacheLSizeL() - { - __UHEAP_MARK; - // w* State Initial - RWsSession rws; - TInt err = rws.Connect(); - CleanupClosePushL(rws); - TEST(err==KErrNone); - - rws.EnableWindowSizeCacheL(); - - RWindowGroup wg(rws); - wg.Construct(0); - CleanupClosePushL(rws); - - // w1 State 0 - RWindow w1(rws); - w1.Construct(wg,1); - CleanupClosePushL(w1); - - // w1 State 0 - TSize size1 (10001,123); - w1.SetSize(size1); - rws.Flush(); - - // w1 State 1 - TSize retSize1 = w1.Size(); - TEST(retSize1 == size1); - - // w1 State 1 - // Only the first call to EnableWindowSizeCacheL() should have an effect - // All subsequent calls to EnableWindowSizeCacheL() should have no effect - rws.EnableWindowSizeCacheL(); - - // w1 State 1 - TSize retSize2 = w1.Size(); - TEST(retSize2 == size1); - - // w1 State Final - CleanupStack::Pop(); - w1.Close(); - - CleanupStack::Pop(); - wg.Close(); - - CleanupStack::Pop(); - rws.Close(); - - __UHEAP_MARKEND; - } - -void CTWindowSizeCacheTest::TestRWindowCacheEntryExistsCacheDirtySetSizeL(TSizeCacheStatus aEnableWindowSizeCache) - { - __UHEAP_MARK; - // w* State Initial - RWsSession rws; - TInt err = rws.Connect(); - CleanupClosePushL(rws); - TEST(err==KErrNone); - - if (aEnableWindowSizeCache) - { - rws.EnableWindowSizeCacheL(); - } - - RWindowGroup wg(rws); - wg.Construct(0); - CleanupClosePushL(rws); - - // w1 State 0 - RWindow w1(rws); - w1.Construct(wg,1); - CleanupClosePushL(w1); - - // w1 State 0 - TSize size1 (10001,123); - w1.SetSize(size1); - rws.Flush(); - - // w1 State 1 - TSize retSize1 = w1.Size(); - TEST(retSize1 == size1); - - // w1 State 2 - TSize size2 (20002,223); - w1.SetSize(size2); - rws.Flush(); - - // w1 State Final - CleanupStack::Pop(); - w1.Close(); - - CleanupStack::Pop(); - wg.Close(); - - CleanupStack::Pop(); - rws.Close(); - - __UHEAP_MARKEND; - } - -void CTWindowSizeCacheTest::TestRWindowCacheEntryExistsCacheDirtySetExtentL(TSizeCacheStatus aEnableWindowSizeCache) - { - __UHEAP_MARK; - // w* State Initial - RWsSession rws; - TInt err = rws.Connect(); - CleanupClosePushL(rws); - TEST(err==KErrNone); - - if (aEnableWindowSizeCache) - { - rws.EnableWindowSizeCacheL(); - } - - RWindowGroup wg(rws); - wg.Construct(0); - CleanupClosePushL(rws); - - // w1 State 0 - RWindow w1(rws); - w1.Construct(wg,1); - CleanupClosePushL(w1); - - // w1 State 0 - TSize size1 (10001,123); - w1.SetSize(size1); - rws.Flush(); - - // w1 State 1 - TSize retSize1 = w1.Size(); - TEST(retSize1 == size1); - - // w1 State 2 - TPoint point2 (20202,223); - TSize size2 (20002,223); - w1.SetExtent(point2, size2); - rws.Flush(); - - // w1 State Final - CleanupStack::Pop(); - w1.Close(); - - CleanupStack::Pop(); - wg.Close(); - - CleanupStack::Pop(); - rws.Close(); - - __UHEAP_MARKEND; - } - -void CTWindowSizeCacheTest::TestRWindowCacheEntryExistsCacheDirtySetSizeErrL(TSizeCacheStatus aEnableWindowSizeCache) - { - __UHEAP_MARK; - // w* State Initial - RWsSession rws; - TInt err = rws.Connect(); - CleanupClosePushL(rws); - TEST(err==KErrNone); - - if (aEnableWindowSizeCache) - { - rws.EnableWindowSizeCacheL(); - } - - RWindowGroup wg(rws); - wg.Construct(0); - CleanupClosePushL(rws); - - // w1 State 0 - RWindow w1(rws); - w1.Construct(wg,1); - CleanupClosePushL(w1); - - // w1 State 0 - TSize size1 (10001,123); - w1.SetSize(size1); - rws.Flush(); - - // w1 State 1 - TSize retSize1 = w1.Size(); - TEST(retSize1 == size1); - - // w1 State 2 - TSize size2 (20002,223); - err = w1.SetSizeErr(size2); - TEST(KErrNone == err); - - // w1 State Final - CleanupStack::Pop(); - w1.Close(); - - CleanupStack::Pop(); - wg.Close(); - - CleanupStack::Pop(); - rws.Close(); - - __UHEAP_MARKEND; - } - -void CTWindowSizeCacheTest::TestRWindowCacheEntryExistsCacheDirtySetExtentErrL(TSizeCacheStatus aEnableWindowSizeCache) - { - __UHEAP_MARK; - // w* State Initial - RWsSession rws; - TInt err = rws.Connect(); - CleanupClosePushL(rws); - TEST(err==KErrNone); - - if (aEnableWindowSizeCache) - { - rws.EnableWindowSizeCacheL(); - } - - RWindowGroup wg(rws); - wg.Construct(0); - CleanupClosePushL(rws); - - // w1 State 0 - RWindow w1(rws); - w1.Construct(wg,1); - CleanupClosePushL(w1); - - // w1 State 0 - TSize size1 (10001,123); - w1.SetSize(size1); - rws.Flush(); - - // w1 State 1 - TSize retSize1 = w1.Size(); - TEST(retSize1 == size1); - - // w1 State 2 - TPoint point2 (20202,223); - TSize size2 (20002,223); - err = w1.SetExtentErr(point2, size2); - TEST(KErrNone == err); - - // w1 State Final - CleanupStack::Pop(); - w1.Close(); - - CleanupStack::Pop(); - wg.Close(); - - CleanupStack::Pop(); - rws.Close(); - - __UHEAP_MARKEND; - } - -void CTWindowSizeCacheTest::TestRWindowCacheEntryExistsCacheDirtySetSizeTwiceL(TSizeCacheStatus aEnableWindowSizeCache) - { - __UHEAP_MARK; - // w* State Initial - RWsSession rws; - TInt err = rws.Connect(); - CleanupClosePushL(rws); - TEST(err==KErrNone); - - if (aEnableWindowSizeCache) - { - rws.EnableWindowSizeCacheL(); - } - - RWindowGroup wg(rws); - wg.Construct(0); - CleanupClosePushL(rws); - - // w1 State 0 - RWindow w1(rws); - w1.Construct(wg,1); - CleanupClosePushL(w1); - - // w1 State 0 - TSize size1 (10001,123); - w1.SetSize(size1); - rws.Flush(); - - // w1 State 1 - TSize retSize1 = w1.Size(); - TEST(retSize1 == size1); - - // w1 State 2 - TSize size2 (20002,223); - w1.SetSize(size2); - - TSize size3 (30003,323); - // w1 State 2 - w1.SetSize(size3); - rws.Flush(); - - // w1 State Final - CleanupStack::Pop(); - w1.Close(); - - CleanupStack::Pop(); - wg.Close(); - - CleanupStack::Pop(); - rws.Close(); - - __UHEAP_MARKEND; - } - -void CTWindowSizeCacheTest::TestRWindowCacheEntryExistsCacheDirtySetSizeSetExtentL(TSizeCacheStatus aEnableWindowSizeCache) - { - __UHEAP_MARK; - // w* State Initial - RWsSession rws; - TInt err = rws.Connect(); - CleanupClosePushL(rws); - TEST(err==KErrNone); - - if (aEnableWindowSizeCache) - { - rws.EnableWindowSizeCacheL(); - } - - RWindowGroup wg(rws); - wg.Construct(0); - CleanupClosePushL(rws); - - // w1 State 0 - RWindow w1(rws); - w1.Construct(wg,1); - CleanupClosePushL(w1); - - // w1 State 0 - TSize size1 (10001,123); - w1.SetSize(size1); - rws.Flush(); - - // w1 State 1 - TSize retSize1 = w1.Size(); - TEST(retSize1 == size1); - - // w1 State 2 - TSize size2 (20002,223); - w1.SetSize(size2); - - // w1 State 2 - TPoint point3 (30303,232); - TSize size3 (30003,323); - w1.SetExtent(point3, size3); - rws.Flush(); - - // w1 State Final - CleanupStack::Pop(); - w1.Close(); - - CleanupStack::Pop(); - wg.Close(); - - CleanupStack::Pop(); - rws.Close(); - - __UHEAP_MARKEND; - } - -void CTWindowSizeCacheTest::TestRWindowCacheEntryExistsCacheDirtySetSizeSetSizeErrL(TSizeCacheStatus aEnableWindowSizeCache) - { - __UHEAP_MARK; - // w* State Initial - RWsSession rws; - TInt err = rws.Connect(); - CleanupClosePushL(rws); - TEST(err==KErrNone); - - if (aEnableWindowSizeCache) - { - rws.EnableWindowSizeCacheL(); - } - - RWindowGroup wg(rws); - wg.Construct(0); - CleanupClosePushL(rws); - - // w1 State 0 - RWindow w1(rws); - w1.Construct(wg,1); - CleanupClosePushL(w1); - - // w1 State 0 - TSize size1 (10001,123); - w1.SetSize(size1); - rws.Flush(); - - // w1 State 1 - TSize retSize1 = w1.Size(); - TEST(retSize1 == size1); - - // w1 State 2 - TSize size2 (20002,223); - w1.SetSize(size2); - - // w1 State 2 - TSize size3 (30003,323); - err = w1.SetSizeErr(size3); - TEST(KErrNone == err); - - // w1 State Final - CleanupStack::Pop(); - w1.Close(); - - CleanupStack::Pop(); - wg.Close(); - - CleanupStack::Pop(); - rws.Close(); - - __UHEAP_MARKEND; - } - -void CTWindowSizeCacheTest::TestRWindowCacheEntryExistsCacheDirtySetSizeSetExtentErrL(TSizeCacheStatus aEnableWindowSizeCache) - { - __UHEAP_MARK; - // w* State Initial - RWsSession rws; - TInt err = rws.Connect(); - CleanupClosePushL(rws); - TEST(err==KErrNone); - - if (aEnableWindowSizeCache) - { - rws.EnableWindowSizeCacheL(); - } - - RWindowGroup wg(rws); - wg.Construct(0); - CleanupClosePushL(rws); - - // w1 State 0 - RWindow w1(rws); - w1.Construct(wg,1); - CleanupClosePushL(w1); - - // w1 State 0 - TSize size1 (10001,123); - w1.SetSize(size1); - rws.Flush(); - - // w1 State 1 - TSize retSize1 = w1.Size(); - TEST(retSize1 == size1); - - // w1 State 2 - TSize size2 (20002,223); - w1.SetSize(size2); - - // w1 State 2 - TPoint point3 (30303,232); - TSize size3 (30003,323); - err = w1.SetExtentErr(point3, size3); - TEST(KErrNone == err); - - // w1 State Final - CleanupStack::Pop(); - w1.Close(); - - CleanupStack::Pop(); - wg.Close(); - - CleanupStack::Pop(); - rws.Close(); - - __UHEAP_MARKEND; - } - -void CTWindowSizeCacheTest::TestRWindowCacheEntryExistsCacheDirtySetSizeEnableWindowSizeCacheL() - { - __UHEAP_MARK; - // w* State Initial - RWsSession rws; - TInt err = rws.Connect(); - CleanupClosePushL(rws); - TEST(err==KErrNone); - - rws.EnableWindowSizeCacheL(); - - RWindowGroup wg(rws); - wg.Construct(0); - CleanupClosePushL(rws); - - // w1 State 0 - RWindow w1(rws); - w1.Construct(wg,1); - CleanupClosePushL(w1); - - // w1 State 0 - TSize size1 (10001,123); - w1.SetSize(size1); - rws.Flush(); - - // w1 State 1 - TSize retSize1 = w1.Size(); - TEST(retSize1 == size1); - - // w1 State 2 - TSize size2 (20002,223); - w1.SetSize(size2); - - // Only the first call to EnableWindowSizeCacheL() should have an effect - // All subsequent calls to EnableWindowSizeCacheL() should have no effect - rws.EnableWindowSizeCacheL(); - - // w1 State Final - CleanupStack::Pop(); - w1.Close(); - - CleanupStack::Pop(); - wg.Close(); - - CleanupStack::Pop(); - rws.Close(); - - __UHEAP_MARKEND; - } - -//------------------------------------------------------------------------------------------- -void CTWindowSizeCacheTest::TestRWindowCacheEntryExistsCacheDirtyToCleanSetSizeL(TSizeCacheStatus aEnableWindowSizeCache) - { - __UHEAP_MARK; - // w* State Initial - RWsSession rws; - TInt err = rws.Connect(); - CleanupClosePushL(rws); - TEST(err==KErrNone); - - if (aEnableWindowSizeCache) - { - rws.EnableWindowSizeCacheL(); - } - - RWindowGroup wg(rws); - wg.Construct(0); - CleanupClosePushL(rws); - - // w1 State 0 - RWindow w1(rws); - w1.Construct(wg,1); - CleanupClosePushL(w1); - - // w1 State 0 - TSize size1 (10001,123); - w1.SetSize(size1); - rws.Flush(); - - // w1 State 1 - TSize retSize1 = w1.Size(); - TEST(retSize1 == size1); - - // w1 State 2 - TSize size2 (20002,223); - w1.SetSize(size2); - rws.Flush(); - - // w1 State 1 - TSize retSize2 = w1.Size(); - TEST(retSize2 == size2); - - // w1 State Final - CleanupStack::Pop(); - w1.Close(); - - CleanupStack::Pop(); - wg.Close(); - - CleanupStack::Pop(); - rws.Close(); - - __UHEAP_MARKEND; - } - -void CTWindowSizeCacheTest::TestRWindowCacheEntryExistsCacheDirtyToCleanSetExtentL(TSizeCacheStatus aEnableWindowSizeCache) - { - __UHEAP_MARK; - // w* State Initial - RWsSession rws; - TInt err = rws.Connect(); - CleanupClosePushL(rws); - TEST(err==KErrNone); - - if (aEnableWindowSizeCache) - { - rws.EnableWindowSizeCacheL(); - } - - RWindowGroup wg(rws); - wg.Construct(0); - CleanupClosePushL(rws); - - // w1 State 0 - RWindow w1(rws); - w1.Construct(wg,1); - CleanupClosePushL(w1); - - // w1 State 0 - TSize size1 (10001,123); - w1.SetSize(size1); - rws.Flush(); - - // w1 State 1 - TSize retSize1 = w1.Size(); - TEST(retSize1 == size1); - - // w1 State 2 - TPoint point2 (20202,223); - TSize size2 (20002,223); - w1.SetExtent(point2, size2); - rws.Flush(); - - // w1 State 1 - TSize retSize2 = w1.Size(); - TEST(retSize2 == size2); - - // w1 State Final - CleanupStack::Pop(); - w1.Close(); - - CleanupStack::Pop(); - wg.Close(); - - CleanupStack::Pop(); - rws.Close(); - - __UHEAP_MARKEND; - } - -void CTWindowSizeCacheTest::TestRWindowCacheEntryExistsCacheDirtyToCleanSetSizeErrL(TSizeCacheStatus aEnableWindowSizeCache) - { - __UHEAP_MARK; - // w* State Initial - RWsSession rws; - TInt err = rws.Connect(); - CleanupClosePushL(rws); - TEST(err==KErrNone); - - if (aEnableWindowSizeCache) - { - rws.EnableWindowSizeCacheL(); - } - - RWindowGroup wg(rws); - wg.Construct(0); - CleanupClosePushL(rws); - - // w1 State 0 - RWindow w1(rws); - w1.Construct(wg,1); - CleanupClosePushL(w1); - - // w1 State 0 - TSize size1 (10001,123); - w1.SetSize(size1); - rws.Flush(); - - // w1 State 1 - TSize retSize1 = w1.Size(); - TEST(retSize1 == size1); - - // w1 State 2 - TSize size2 (20002,223); - err = w1.SetSizeErr(size2); - TEST(KErrNone == err); - - // w1 State 1 - TSize retSize2 = w1.Size(); - TEST(retSize2 == size2); - - // w1 State Final - CleanupStack::Pop(); - w1.Close(); - - CleanupStack::Pop(); - wg.Close(); - - CleanupStack::Pop(); - rws.Close(); - - __UHEAP_MARKEND; - } - -void CTWindowSizeCacheTest::TestRWindowCacheEntryExistsCacheDirtyToCleanSetExtentErrL(TSizeCacheStatus aEnableWindowSizeCache) - { - __UHEAP_MARK; - // w* State Initial - RWsSession rws; - TInt err = rws.Connect(); - CleanupClosePushL(rws); - TEST(err==KErrNone); - - if (aEnableWindowSizeCache) - { - rws.EnableWindowSizeCacheL(); - } - - RWindowGroup wg(rws); - wg.Construct(0); - CleanupClosePushL(rws); - - // w1 State 0 - RWindow w1(rws); - w1.Construct(wg,1); - CleanupClosePushL(w1); - - // w1 State 0 - TSize size1 (10001,123); - w1.SetSize(size1); - rws.Flush(); - - // w1 State 1 - TSize retSize1 = w1.Size(); - TEST(retSize1 == size1); - - // w1 State 2 - TPoint point2 (20202,223); - TSize size2 (20002,223); - err = w1.SetExtentErr(point2, size2); - TEST(KErrNone == err); - - // w1 State 1 - TSize retSize2 = w1.Size(); - TEST(retSize2 == size2); - - // w1 State Final - CleanupStack::Pop(); - w1.Close(); - - CleanupStack::Pop(); - wg.Close(); - - CleanupStack::Pop(); - rws.Close(); - - __UHEAP_MARKEND; - } - -void CTWindowSizeCacheTest::TestRWindowCacheEntryExistsCacheDirtyToCleanSetSizeTwiceL(TSizeCacheStatus aEnableWindowSizeCache) - { - __UHEAP_MARK; - // w* State Initial - RWsSession rws; - TInt err = rws.Connect(); - CleanupClosePushL(rws); - TEST(err==KErrNone); - - if (aEnableWindowSizeCache) - { - rws.EnableWindowSizeCacheL(); - } - - RWindowGroup wg(rws); - wg.Construct(0); - CleanupClosePushL(rws); - - // w1 State 0 - RWindow w1(rws); - w1.Construct(wg,1); - CleanupClosePushL(w1); - - // w1 State 0 - TSize size1 (10001,123); - w1.SetSize(size1); - rws.Flush(); - - // w1 State 1 - TSize retSize1 = w1.Size(); - TEST(retSize1 == size1); - - // w1 State 2 - TSize size2 (20002,223); - w1.SetSize(size2); - - TSize size3 (30003,323); - // w1 State 2 - w1.SetSize(size3); - rws.Flush(); - - // w1 State 1 - TSize retSize2 = w1.Size(); - TEST(retSize2 == size3); - - // w1 State Final - CleanupStack::Pop(); - w1.Close(); - - CleanupStack::Pop(); - wg.Close(); - - CleanupStack::Pop(); - rws.Close(); - - __UHEAP_MARKEND; - } - -void CTWindowSizeCacheTest::TestRWindowCacheEntryExistsCacheDirtyToCleanSetSizeSetExtentL(TSizeCacheStatus aEnableWindowSizeCache) - { - __UHEAP_MARK; - // w* State Initial - RWsSession rws; - TInt err = rws.Connect(); - CleanupClosePushL(rws); - TEST(err==KErrNone); - - if (aEnableWindowSizeCache) - { - rws.EnableWindowSizeCacheL(); - } - - RWindowGroup wg(rws); - wg.Construct(0); - CleanupClosePushL(rws); - - // w1 State 0 - RWindow w1(rws); - w1.Construct(wg,1); - CleanupClosePushL(w1); - - // w1 State 0 - TSize size1 (10001,123); - w1.SetSize(size1); - rws.Flush(); - - // w1 State 1 - TSize retSize1 = w1.Size(); - TEST(retSize1 == size1); - - // w1 State 2 - TSize size2 (20002,223); - w1.SetSize(size2); - - // w1 State 2 - TPoint point3 (30303,232); - TSize size3 (30003,323); - w1.SetExtent(point3, size3); - rws.Flush(); - - // w1 State 1 - TSize retSize2 = w1.Size(); - TEST(retSize2 == size3); - - // w1 State Final - CleanupStack::Pop(); - w1.Close(); - - CleanupStack::Pop(); - wg.Close(); - - CleanupStack::Pop(); - rws.Close(); - - __UHEAP_MARKEND; - } - -void CTWindowSizeCacheTest::TestRWindowCacheEntryExistsCacheDirtyToCleanSetSizeSetSizeErrL(TSizeCacheStatus aEnableWindowSizeCache) - { - __UHEAP_MARK; - // w* State Initial - RWsSession rws; - TInt err = rws.Connect(); - CleanupClosePushL(rws); - TEST(err==KErrNone); - - if (aEnableWindowSizeCache) - { - rws.EnableWindowSizeCacheL(); - } - - RWindowGroup wg(rws); - wg.Construct(0); - CleanupClosePushL(rws); - - // w1 State 0 - RWindow w1(rws); - w1.Construct(wg,1); - CleanupClosePushL(w1); - - // w1 State 0 - TSize size1 (10001,123); - w1.SetSize(size1); - rws.Flush(); - - // w1 State 1 - TSize retSize1 = w1.Size(); - TEST(retSize1 == size1); - - // w1 State 2 - TSize size2 (20002,223); - w1.SetSize(size2); - - // w1 State 2 - TSize size3 (30003,323); - err = w1.SetSizeErr(size3); - TEST(KErrNone == err); - - // w1 State 1 - TSize retSize2 = w1.Size(); - TEST(retSize2 == size3); - - // w1 State Final - CleanupStack::Pop(); - w1.Close(); - - CleanupStack::Pop(); - wg.Close(); - - CleanupStack::Pop(); - rws.Close(); - - __UHEAP_MARKEND; - } - -void CTWindowSizeCacheTest::TestRWindowCacheEntryExistsCacheDirtyToCleanSetSizeSetExtentErrL(TSizeCacheStatus aEnableWindowSizeCache) - { - __UHEAP_MARK; - // w* State Initial - RWsSession rws; - TInt err = rws.Connect(); - CleanupClosePushL(rws); - TEST(err==KErrNone); - - if (aEnableWindowSizeCache) - { - rws.EnableWindowSizeCacheL(); - } - - RWindowGroup wg(rws); - wg.Construct(0); - CleanupClosePushL(rws); - - // w1 State 0 - RWindow w1(rws); - w1.Construct(wg,1); - CleanupClosePushL(w1); - - // w1 State 0 - TSize size1 (10001,123); - w1.SetSize(size1); - rws.Flush(); - - // w1 State 1 - TSize retSize1 = w1.Size(); - TEST(retSize1 == size1); - - // w1 State 2 - TSize size2 (20002,223); - w1.SetSize(size2); - - // w1 State 2 - TPoint point3 (30303,232); - TSize size3 (30003,323); - err = w1.SetExtentErr(point3, size3); - TEST(KErrNone == err); - - // w1 State 1 - TSize retSize2 = w1.Size(); - TEST(retSize2 == size3); - - // w1 State Final - CleanupStack::Pop(); - w1.Close(); - - CleanupStack::Pop(); - wg.Close(); - - CleanupStack::Pop(); - rws.Close(); - - __UHEAP_MARKEND; - } - -void CTWindowSizeCacheTest::TestRWindowCacheEntryExistsCacheDirtyToCleanSetSizeEnableWindowSizeCacheL() - { - __UHEAP_MARK; - // w* State Initial - RWsSession rws; - TInt err = rws.Connect(); - CleanupClosePushL(rws); - TEST(err==KErrNone); - - rws.EnableWindowSizeCacheL(); - - RWindowGroup wg(rws); - wg.Construct(0); - CleanupClosePushL(rws); - - // w1 State 0 - RWindow w1(rws); - w1.Construct(wg,1); - CleanupClosePushL(w1); - - // w1 State 0 - TSize size1 (10001,123); - w1.SetSize(size1); - rws.Flush(); - - // w1 State 1 - TSize retSize1 = w1.Size(); - TEST(retSize1 == size1); - - // w1 State 2 - TSize size2 (20002,223); - w1.SetSize(size2); - - // Only the first call to EnableWindowSizeCacheL() should have an effect - // All subsequent calls to EnableWindowSizeCacheL() should have no effect - rws.EnableWindowSizeCacheL(); - - // w1 State 1 - TSize retSize2 = w1.Size(); - TEST(retSize2 == size2); - - // w1 State Final - CleanupStack::Pop(); - w1.Close(); - - CleanupStack::Pop(); - wg.Close(); - - CleanupStack::Pop(); - rws.Close(); - - __UHEAP_MARKEND; - } - -//------------------------------------------------------------------------------------------ - -void CTWindowSizeCacheTest::TestRBlankWindowSetSizeSetExtentL(TSizeCacheStatus aEnableWindowSizeCache) - { - __UHEAP_MARK; - // w* State Initial - RWsSession rws; - TInt err = rws.Connect(); - CleanupClosePushL(rws); - TEST(err==KErrNone); - - if (aEnableWindowSizeCache) - { - rws.EnableWindowSizeCacheL(); - } - - RWindowGroup wg(rws); - err = wg.Construct(0); - CleanupClosePushL(rws); - TEST(err==KErrNone); - - // w1 State 0 - RBlankWindow w1(rws); - err = w1.Construct(wg,1); - CleanupClosePushL(w1); - TEST(err==KErrNone); - - // w1 State 0 - TSize size1 (10001,123); - w1.SetSize(size1); - rws.Flush(); - - // w1 State 1 - TSize retSize1 = w1.Size(); - TEST(retSize1 == size1); - - // w1 State 2 - TSize size2 (20002,223); - w1.SetSize(size2); - - // w1 State 2 - TPoint point3 (30303,232); - TSize size3 (30003,323); - w1.SetExtent(point3, size3); - rws.Flush(); - - // w1 State 1 - TSize retSize2 = w1.Size(); - TEST(retSize2 == size3); - - // w1 State 2 - TSize size4 (40004,423); - w1.SetSize(size4); - - // w1 State 1 - TSize retSize3 = w1.Size(); - TEST(retSize3 == size4); - - // w1 State Final - CleanupStack::Pop(); - w1.Close(); - - CleanupStack::Pop(); - wg.Close(); - - CleanupStack::Pop(); - rws.Close(); - - __UHEAP_MARKEND; - } - -//------------------------------------------------------------------------------------------ - -void CTWindowSizeCacheTest::TestRBackedUpWindowSetSizeErrSetExtentErrL(TSizeCacheStatus aEnableWindowSizeCache) - { - __UHEAP_MARK; - // w* State Initial - RWsSession rws; - TInt err = rws.Connect(); - CleanupClosePushL(rws); - TEST(err==KErrNone); - - if (aEnableWindowSizeCache) - { - rws.EnableWindowSizeCacheL(); - } - - RWindowGroup wg(rws); - err = wg.Construct(0); - CleanupClosePushL(rws); - TEST(err==KErrNone); - - // w1 State 0 - RBlankWindow w1(rws); - err = w1.Construct(wg,1); - CleanupClosePushL(w1); - TEST(err==KErrNone); - - // w1 State 0 - TSize size1 (10001,123); - err = w1.SetSizeErr(size1); - TEST(err==KErrNone); - - // w1 State 1 - TSize retSize1 = w1.Size(); - TEST(retSize1 == size1); - - // w1 State 2 - TSize size2 (20002,223); - err = w1.SetSizeErr(size2); - TEST(err==KErrNone); - - // w1 State 2 - TPoint point3 (30303,232); - TSize size3 (30003,323); - err = w1.SetExtentErr(point3, size3); - TEST(err==KErrNone); - - // w1 State 1 - TSize retSize2 = w1.Size(); - TEST(retSize2 == size3); - - // w1 State 2 - TSize size4 (40004,423); - err = w1.SetSizeErr(size4); - TEST(err==KErrNone); - - // w1 State 1 - TSize retSize3 = w1.Size(); - TEST(retSize3 == size4); - - // w1 State Final - CleanupStack::Pop(); - w1.Close(); - - CleanupStack::Pop(); - wg.Close(); - - CleanupStack::Pop(); - rws.Close(); - - __UHEAP_MARKEND; - } - -//------------------------------------------------------------------------------------------ - -TUint64 CTWindowSizeCacheTest::TestRWindowSizePerformanceL(TSizeCacheStatus aEnableWindowSizeCache, TUint aIterations) - { - TUint64 timeDeltaMicroSeconds = 0; - - __UHEAP_MARK; - // w* State Initial - RWsSession rws; - TInt err = rws.Connect(); - TEST(KErrNone == err); - CleanupClosePushL(rws); - - if (ETestSizeCacheEnabled == aEnableWindowSizeCache) - { - rws.EnableWindowSizeCacheL(); - } - - RWindowGroup wg(rws); - err = wg.Construct(0); - TEST(KErrNone == err); - CleanupClosePushL(wg); - - // w1 State 0 - RWindow w1(rws); - err = w1.Construct(wg,1); - TEST(KErrNone == err); - CleanupClosePushL(w1); - - TSize size1 (10001,123); - w1.SetSize(size1); - - TTime start; - TTime end; - start.UniversalTime(); - for (TUint iter = 0; iter < aIterations; ++iter) - { - // w1 State 1 - TSize retSize1 = w1.Size(); - TEST(retSize1 == size1); - } - end.UniversalTime(); - - TTimeIntervalMicroSeconds delta = end.MicroSecondsFrom(start); - timeDeltaMicroSeconds = delta.Int64(); - INFO_PRINTF4(_L("TestRWindowSizePerformanceL - WindowSizeCacheEnabled %d, Iterations %d, Microseconds %Ld"), aEnableWindowSizeCache, aIterations, timeDeltaMicroSeconds); - - // w1 State Final - CleanupStack::Pop(); - w1.Close(); - - CleanupStack::Pop(); - wg.Close(); - - CleanupStack::Pop(); - rws.Close(); - - __UHEAP_MARKEND; - return timeDeltaMicroSeconds; - } - - -//------------------------------------------------------------------------------------------ -/* -Sets the random seed used by CTWindowSizeCacheTest::NextRandom. - */ -void CTWindowSizeCacheTest::SetRandomSeed(TInt64 aSeed) - { - INFO_PRINTF2(_L("Random Seed - %d"), aSeed); - iSeed = aSeed; - } - -/* -Performs an action on RWindow or RWsSession as specified by TRWindowAction aAction. -When the size of the window is changed, aExpectedSize is changed to the size we expect the window to be the next time RWindow::Size is called. -When RWindow::Size is called, we check the size returned matches aExpectedSize. -If aAction requests RWsSession::EnableWindowSizeCache, we call this if TSizeCacheStatus allows this. - -This function was designed for use with random stress tests, with a pseudo-random sequence driving TRWindowAction. - */ -void CTWindowSizeCacheTest::RWindowPerformAction(TRWindowAction aAction, TSizeCacheStatus aEnableWindowSizeCache, RWsSession& aWs, RWindow& aWindow, TSize& aExpectedSize) - { - switch (aAction) - { - case ESetExtent : - { - TPoint point(NextRandom(), NextRandom()); - aExpectedSize.iHeight = NextRandom(); - aExpectedSize.iWidth = NextRandom(); - aWindow.SetExtent(point, aExpectedSize); - aExpectedSize.iHeight = (aExpectedSize.iHeight < 0) ? 0 : aExpectedSize.iHeight; - aExpectedSize.iWidth = (aExpectedSize.iWidth < 0) ? 0 : aExpectedSize.iWidth; - } - break; - case ESetExtentErr : - { - TPoint point(NextRandom(), NextRandom()); - aExpectedSize.iHeight = NextRandom(); - aExpectedSize.iWidth = NextRandom(); - TInt err = aWindow.SetExtentErr(point, aExpectedSize); - TEST(KErrNone == err); - aExpectedSize.iHeight = (aExpectedSize.iHeight < 0) ? 0 : aExpectedSize.iHeight; - aExpectedSize.iWidth = (aExpectedSize.iWidth < 0) ? 0 : aExpectedSize.iWidth; - } - break; - case ESetSize : - { - aExpectedSize.iHeight = NextRandom(); - aExpectedSize.iWidth = NextRandom(); - aWindow.SetSize(aExpectedSize); - aExpectedSize.iHeight = (aExpectedSize.iHeight < 0) ? 0 : aExpectedSize.iHeight; - aExpectedSize.iWidth = (aExpectedSize.iWidth < 0) ? 0 : aExpectedSize.iWidth; - } - break; - case ESetSizeErr : - { - aExpectedSize.iHeight = NextRandom(); - aExpectedSize.iWidth = NextRandom(); - TInt err = aWindow.SetSizeErr(aExpectedSize); - TEST(KErrNone == err); - aExpectedSize.iHeight = (aExpectedSize.iHeight < 0) ? 0 : aExpectedSize.iHeight; - aExpectedSize.iWidth = (aExpectedSize.iWidth < 0) ? 0 : aExpectedSize.iWidth; - } - break; - case ECheckSize : - { - TSize retSize1 = aWindow.Size(); - TEST(retSize1 == aExpectedSize); - } - break; - case EFlushSession : - { - aWs.Flush(); - } - break; - case EEnableWindowSizeCache : - { - if (ETestSizeCacheEnabled == aEnableWindowSizeCache) - { - aWs.EnableWindowSizeCacheL(); - } - } - break; - default : - break; - } - } - -void CTWindowSizeCacheTest::TestRandomisedStressL(TSizeCacheStatus aEnableWindowSizeCache, TUint aIterations) - { - __UHEAP_MARK; - // w* State Initial - RWsSession rws; - TInt err = rws.Connect(); - TEST(KErrNone == err); - CleanupClosePushL(rws); - - if (aEnableWindowSizeCache) - { - rws.EnableWindowSizeCacheL(); - } - - RWindowGroup wg(rws); - err = wg.Construct(0); - TEST(KErrNone == err); - CleanupClosePushL(wg); - - // w1 State 0 - RWindow w1(rws); - err = w1.Construct(wg,1); - TEST(KErrNone == err); - CleanupClosePushL(w1); - - TSize size1 (10001,123); - w1.SetSize(size1); - - for (TUint iter = 0; iter < aIterations; ++iter) - { - TRWindowAction action = static_cast(NextRandom(EMaxAction)); - RWindowPerformAction(action, aEnableWindowSizeCache, rws, w1, size1); - } - - // w1 State Final - CleanupStack::Pop(); - w1.Close(); - - CleanupStack::Pop(); - wg.Close(); - - CleanupStack::Pop(); - rws.Close(); - __UHEAP_MARKEND; - } - -/* -TCleanupOperation for a window pool, implemented as RPointerArray. - */ -void CTWindowSizeCacheTest::CleanupWindowPool(TAny* aPtr) - { - RPointerArray windowPool = *(static_cast*>(aPtr)); - const TUint poolSize = windowPool.Count(); - // Note: ResetAndDestroy deletes referenced objects, so no need to delete items in loop - for (TUint iter = 0; iter < poolSize; ++iter) - { - windowPool[iter]->Close(); - } - windowPool.ResetAndDestroy(); - } - -void CTWindowSizeCacheTest::TestRandomisedStressMultiSessionL(TSizeCacheStatus aEnableWindowSizeCache, TUint aIterations) - { - __UHEAP_MARK; - // w* State Initial - RWsSession rws1; - TInt err = rws1.Connect(); - TEST(KErrNone == err); - CleanupClosePushL(rws1); - - // Multiple sessions in one thread - RWsSession rws2; - err = rws2.Connect(); - TEST(KErrNone == err); - CleanupClosePushL(rws2); - - RWindowGroup rws1_wg1(rws1); - err = rws1_wg1.Construct(0); - CleanupClosePushL(rws1_wg1); - TEST(KErrNone == err); - - RWindowGroup rws2_wg1(rws2); - err = rws2_wg1.Construct(0); - CleanupClosePushL(rws2_wg1); - TEST(KErrNone == err); - - // Multiple window groups in one session - RWindowGroup rws2_wg2(rws2); - err = rws2_wg2.Construct(1); - CleanupClosePushL(rws2_wg2); - TEST(KErrNone == err); - - // Window pool for all windows owned by session rws1 - RPointerArray rws1_windowPool; - CleanupStack::PushL(TCleanupItem(CleanupWindowPool,&rws1_windowPool)); - // Each window in window pool has a corresponding expected size at corresponding array index - RArray rws1_expectedSizePool; - CleanupClosePushL(rws1_expectedSizePool); - - // Window pool for all windows owned by session rws2 - RPointerArray rws2_windowPool; - CleanupStack::PushL(TCleanupItem(CleanupWindowPool,&rws2_windowPool)); - // Each window in window pool has a corresponding expected size at corresponding array index - RArray rws2_expectedSizePool; - CleanupClosePushL(rws2_expectedSizePool); - - // Populate window pool - const TUint KWindowCount_rws1_wg1 = 50; - const TUint KWindowCount_rws2_wg1 = 50; - const TUint KWindowCount_rws2_wg2 = 50; - - // Windows for session 1 belonging to rws1_wg1 - // Many windows - siblings - for (TUint iter = 0; iter < KWindowCount_rws1_wg1; ++iter) - { - RWindow* win = new (ELeave) RWindow(rws1); - CleanupStack::PushL(win); - TInt err = win->Construct(rws1_wg1,iter+1); - TEST(KErrNone == err); - rws1_windowPool.AppendL(win); - CleanupStack::Pop(win); - TSize expectedSize (NextRandom(),NextRandom()); - win->SetSize(expectedSize); - // Wserv flattens size to zero - expectedSize.iHeight = (expectedSize.iHeight < 0) ? 0 : expectedSize.iHeight; - expectedSize.iWidth = (expectedSize.iWidth < 0) ? 0 : expectedSize.iWidth; - rws1_expectedSizePool.AppendL(expectedSize); - TSize retSize1 = win->Size(); - TEST(retSize1 == expectedSize); - } - - // Windows for session 2 belonging to rws2_wg1 - // Many windows - siblings - for (TUint iter = 0; iter < KWindowCount_rws2_wg1; ++iter) - { - RWindow* win = new (ELeave) RWindow(rws2); - CleanupStack::PushL(win); - TInt err = win->Construct(rws2_wg1,iter+2); - TEST(KErrNone == err); - rws2_windowPool.AppendL(win); - CleanupStack::Pop(); - TSize expectedSize (NextRandom(),NextRandom()); - win->SetSize(expectedSize); - // Wserv flattens size to zero - expectedSize.iHeight = (expectedSize.iHeight < 0) ? 0 : expectedSize.iHeight; - expectedSize.iWidth = (expectedSize.iWidth < 0) ? 0 : expectedSize.iWidth; - rws2_expectedSizePool.AppendL(expectedSize); - TSize retSize1 = win->Size(); - TEST(retSize1 == expectedSize); - } - - // Windows for session 2 belonging to rws2_wg2 - // Many windows - children - RWindowTreeNode parent = rws2_wg2; - for (TUint iter = 0; iter < KWindowCount_rws2_wg2; ++iter) - { - RWindow* win = new (ELeave) RWindow(rws2); - CleanupStack::PushL(win); - TInt err = win->Construct(parent,KWindowCount_rws2_wg1+iter+2); - TEST(KErrNone == err); - parent = *win; - rws2_windowPool.AppendL(win); - CleanupStack::Pop(); - TSize expectedSize (NextRandom(),NextRandom()); - win->SetSize(expectedSize); - // Wserv flattens size to zero - expectedSize.iHeight = (expectedSize.iHeight < 0) ? 0 : expectedSize.iHeight; - expectedSize.iWidth = (expectedSize.iWidth < 0) ? 0 : expectedSize.iWidth; - rws2_expectedSizePool.AppendL(expectedSize); - TSize retSize1 = win->Size(); - TEST(retSize1 == expectedSize); - } - - // Stress system by performing actions on windows - for (TUint iter = 0; iter < aIterations; ++iter) - { - TRWindowAction action = static_cast(NextRandom(EMaxAction)); - TUint32 windowPool = NextRandom(2); - switch (windowPool) - { - case 0 : - { - TUint32 target = NextRandom(rws1_windowPool.Count()); - RWindowPerformAction(action, aEnableWindowSizeCache, rws1, *(rws1_windowPool[target]) , rws1_expectedSizePool[target]); - } - break; - case 1 : - { - TUint32 target = NextRandom(rws2_windowPool.Count()); - RWindowPerformAction(action, aEnableWindowSizeCache, rws2, *(rws2_windowPool[target]) , rws2_expectedSizePool[target]); - } - break; - default : - User::Invariant(); - } - } - - - // Cleanup afterwards - CleanupStack::Pop(9); - - CleanupWindowPool(&rws1_windowPool); - rws1_expectedSizePool.Close(); - rws1_wg1.Close(); - rws1.Close(); - - CleanupWindowPool(&rws2_windowPool); - rws2_expectedSizePool.Close(); - rws2_wg1.Close(); - rws2_wg2.Close(); - rws2.Close(); - } - -void CTWindowSizeCacheTest::TestRandomisedStressCacheEntryVolumeL(TSizeCacheStatus aEnableWindowSizeCache, TUint aIterations, TUint aWindowPoolSize) - { - __UHEAP_MARK; - // w* State Initial - RWsSession rws1; - TInt err = rws1.Connect(); - TEST(KErrNone == err); - CleanupClosePushL(rws1); - - if (aEnableWindowSizeCache) - { - rws1.EnableWindowSizeCacheL(); - } - - RWindowGroup rws1_wg1(rws1); - err = rws1_wg1.Construct(0); - TEST(KErrNone == err); - CleanupClosePushL(rws1_wg1); - - RPointerArray windowPool; - CleanupStack::PushL(TCleanupItem(CleanupWindowPool,&windowPool)); - // Each window in window pool has a corresponding expected size at corresponding array index - RArray expectedSizePool; - CleanupClosePushL(expectedSizePool); - - // Populate window pool - for (TUint iter = 0; iter < aWindowPoolSize; ++iter) - { - RWindow* win = new (ELeave) RWindow(rws1); - CleanupStack::PushL(win); - TInt err = win->Construct(rws1_wg1,iter+1); - TEST(KErrNone == err); - windowPool.AppendL(win); - CleanupStack::Pop(win); - - TSize expectedSize (NextRandom(),NextRandom()); - win->SetSize(expectedSize); - // Wserv flattens size to zero - expectedSize.iHeight = (expectedSize.iHeight < 0) ? 0 : expectedSize.iHeight; - expectedSize.iWidth = (expectedSize.iWidth < 0) ? 0 : expectedSize.iWidth; - expectedSizePool.AppendL(expectedSize); - TSize retSize1 = win->Size(); - TEST(retSize1 == expectedSize); - } - - // Stress system by performing actions on windows - for (TUint iter = 0; iter < aIterations; ++iter) - { - TRWindowAction action = static_cast(NextRandom(EMaxAction)); - TUint32 target = NextRandom(aWindowPoolSize); - RWindowPerformAction(action, aEnableWindowSizeCache, rws1, *(windowPool[target]), expectedSizePool[target]); - } - - // Cleanup afterwards - CleanupStack::Pop(4); - - CleanupWindowPool(&windowPool); - expectedSizePool.Close(); - rws1_wg1.Close(); - rws1.Close(); - - __UHEAP_MARKEND; - } - -//------------------------------------------------------------------------------------------ - -void CTWindowSizeCacheTest::TestStressEnableWindowSizeCacheL(TUint aIterations) - { - __UHEAP_MARK; - // w* State Initial - RWsSession rws; - TInt err = rws.Connect(); - CleanupClosePushL(rws); - TEST(err==KErrNone); - - // Only the first call to EnableWindowSizeCacheL() should have an effect - // All subsequent calls to EnableWindowSizeCacheL() should have no effect - for (TUint iter = 0; iter < aIterations; iter++) - { - rws.EnableWindowSizeCacheL(); - } - - RWindowGroup wg(rws); - wg.Construct(0); - CleanupClosePushL(rws); - - // w1 State 0 - RWindow w1(rws); - w1.Construct(wg,1); - CleanupClosePushL(w1); - - TSize size1 (10001,123); - w1.SetSize(size1); - - // w1 State 1 - TSize retSize1 = w1.Size(); - TEST(retSize1 == size1); - - // w1 State 2 - TSize size2 (20002,223); - w1.SetSize(size2); - - // w1 State 2 - // Only the first call to EnableWindowSizeCacheL() should have an effect - // All subsequent calls to EnableWindowSizeCacheL() should have no effect - for (TUint iter = 0; iter < aIterations; iter++) - { - rws.EnableWindowSizeCacheL(); - } - - // w1 State 1 - TSize retSize2 = w1.Size(); - TEST(retSize2 == size2); - - // w1 State Final - CleanupStack::Pop(); - w1.Close(); - - CleanupStack::Pop(); - wg.Close(); - - CleanupStack::Pop(); - rws.Close(); - - __UHEAP_MARKEND; - } - -/* -Tests 701-706 focus on window creation operating correctly, alternating use of the window size cache. -Tests 707-710 aim to cover state transitions for cache entries in the window size cache for RWindow. -Tests 711-712 performs basic verification of size related functionality for RBlankWindow and RBackedUpWindow. -Test 713 focusses on ensuring a performance gain is achieved with window size caching enabled. -Tests 714-720 aim to stress the window size cache with pseudo-random sequences of RWindow size related functions. - -The states in the state machine model used for testing the RWindow size cache in tests 707-710 is as follows: - -State: Initial - Window not yet in existence - -State 0: No Cache entry - Window created, window size cache does not contain an entry for this window - -State 1: Cache entry exists, cache clean - Window created, window size cache exists, contains a valid size - -State 2: Cache entry exists, cache dirty - Window created, window size cache exists, does not contain a valid size - -State: Final - Window destroyed - */ -void CTWindowSizeCacheTest::RunTestCaseL(TInt /*aCurTestCase*/) - { - _LIT(KTest1,"Create RWindow, window size cache off"); - _LIT(KTest2,"Create RWindow, window size cache on"); - _LIT(KTest3,"Create RBlankWindow, window size cache off"); - _LIT(KTest4,"Create RBlankWindow, window size cache on"); - _LIT(KTest5,"Create RBackedUpWindow, window size cache off"); - _LIT(KTest6,"Create RBackedUpWindow, window size cache on"); - - _LIT(KTest7,"RWindow - No cache entry"); - _LIT(KTest8,"RWindow - Cache entry exists, cache clean"); - _LIT(KTest9,"RWindow - Cache entry exists, cache dirty"); - _LIT(KTest10,"RWindow - Cache entry exists, cache dirty->clean"); - - _LIT(KTest11,"RBlankWindow size cache"); - _LIT(KTest12,"RBackedUpWindow size cache"); - - _LIT(KTest13,"RWindow Size Performance"); - _LIT(KTest14,"RWindow Randomised Stress window size cache off"); - _LIT(KTest15,"RWindow Randomised Stress window size cache on"); - _LIT(KTest16,"RWindow Randomised Stress MultiSession cache off"); - _LIT(KTest17,"RWindow Randomised Stress MultiSession cache on"); - _LIT(KTest18,"RWindow Randomised Stress Entry Volume cache off"); - _LIT(KTest19,"RWindow Randomised Stress Entry Volume cache on"); - _LIT(KTest20,"RWsSession stress EnableWindowSizeCacheL"); - - const TDisplayMode displayMode = EColor16MAP; - const TUint KPerformanceIterations = 50000; - const TUint KStressTestIterations = 3000; - const TUint KStressWindowPoolSize = 100; - - ((CTWindowSizeCacheTestStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - - switch(++iTest->iState) - { -/** -@SYMTestCaseID GRAPHICS-WSERV-0701 - -@SYMDEF DevCR BBRE-7UWGHL - -@SYMTestCaseDesc Test creation and destruction for instances of RWindow, window size cache off - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Creates an RWsSession, some RWindowGroup and RWindow instances, and closes them. - -@SYMTestExpectedResults Window objects created successfully, no memory leaks. -*/ - case 1: - ((CTWindowSizeCacheTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0701")); - iTest->LogSubTest(KTest1); - TestCreateRWindowL(ETestSizeCacheNotEnabled); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0702 - -@SYMDEF DevCR BBRE-7UWGHL - -@SYMTestCaseDesc Test creation and destruction for instances of RWindow, window size cache on - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Creates an RWsSession, enables window size cache, creates some RWindowGroup and RWindow instances, and closes them. - -@SYMTestExpectedResults Window objects created successfully, no memory leaks. -*/ - case 2: - ((CTWindowSizeCacheTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0702")); - iTest->LogSubTest(KTest2); - TestCreateRWindowL(ETestSizeCacheEnabled); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0703 - -@SYMDEF DevCR BBRE-7UWGHL - -@SYMTestCaseDesc Test creation and destruction for instances of RBlankWindow, window size cache off - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Creates an RWsSession, creates some RWindowGroup and RBlankWindow instances, and closes them. - -@SYMTestExpectedResults Window objects created successfully, no memory leaks. -*/ - case 3: - ((CTWindowSizeCacheTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0703")); - iTest->LogSubTest(KTest3); - TestCreateRBlankWindowL(ETestSizeCacheNotEnabled); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0704 - -@SYMDEF DevCR BBRE-7UWGHL - -@SYMTestCaseDesc Test creation and destruction for instances of RBlankWindow, window size cache on - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Creates an RWsSession, enables window size cache, creates some RWindowGroup and RBlankWindow instances, and closes them. - -@SYMTestExpectedResults Window objects created successfully, no memory leaks. -*/ - case 4: - ((CTWindowSizeCacheTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0704")); - iTest->LogSubTest(KTest4); - TestCreateRBlankWindowL(ETestSizeCacheEnabled); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0705 - -@SYMDEF DevCR BBRE-7UWGHL - -@SYMTestCaseDesc Test creation and destruction for instances of RBackedUpWindow, window size cache off - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Creates an RWsSession, creates some RWindowGroup and RBackedUpWindow instances, and closes them. - -@SYMTestExpectedResults Window objects created successfully, no memory leaks. -*/ - case 5: - ((CTWindowSizeCacheTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0705")); - iTest->LogSubTest(KTest5); - TestCreateRBackedUpWindowL(ETestSizeCacheNotEnabled, displayMode); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0706 - -@SYMDEF DevCR BBRE-7UWGHL - -@SYMTestCaseDesc Test creation and destruction for instances of RBackedUpWindow, window size cache on - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Creates an RWsSession, enables window size cache, creates some RWindowGroup and RBackedUpWindow instances, and closes them. - -@SYMTestExpectedResults Window objects created successfully, no memory leaks. -*/ - case 6: - ((CTWindowSizeCacheTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0706")); - iTest->LogSubTest(KTest6); - TestCreateRBackedUpWindowL(ETestSizeCacheEnabled, displayMode); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0707 - -@SYMDEF DevCR BBRE-7UWGHL - -@SYMTestCaseDesc Test RWindow size cache - State: No Cache Entry - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Perform the following with window size cache on and off: - Create RWsSession, creates RWindowGroup and RWindow. - Perform one of SetExtent/SetSize/SetExtentErr/SetSizeErr/EnableWindowSizeCacheL. - Clean up. - -@SYMTestExpectedResults Window objects created successfully, no memory leaks. -*/ - case 7: - ((CTWindowSizeCacheTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0707")); - iTest->LogSubTest(KTest7); - TestRWindowNoCacheEntryL(ETestSizeCacheNotEnabled); - TestRWindowNoCacheEntryL(ETestSizeCacheEnabled); - TestRWindowNoCacheEntrySetExtentErrL(ETestSizeCacheNotEnabled); - TestRWindowNoCacheEntrySetExtentErrL(ETestSizeCacheEnabled); - TestRWindowNoCacheEntrySetSizeErrL(ETestSizeCacheNotEnabled); - TestRWindowNoCacheEntrySetSizeErrL(ETestSizeCacheEnabled); - TestRWindowNoCacheEntrySetExtentL(ETestSizeCacheNotEnabled); - TestRWindowNoCacheEntrySetExtentL(ETestSizeCacheEnabled); - TestRWindowNoCacheEntrySetSizeL(ETestSizeCacheNotEnabled); - TestRWindowNoCacheEntrySetSizeL(ETestSizeCacheEnabled); - TestRWindowNoCacheEntryEnableWindowSizeCacheL(); - break; - -/** -@SYMTestCaseID GRAPHICS-WSERV-0708 - -@SYMDEF DevCR BBRE-7UWGHL - -@SYMTestCaseDesc Test RWindow size cache State: Cache entry exists, cache clean - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Perform the following with window size cache on and off: - Create RWsSession, creates RWindowGroup and RWindow, calls SetSize. - Perform one of Size/EnableWindowSizeCacheL. - Check that size returned matches expected size. - Clean up. - -@SYMTestExpectedResults Window objects created successfully, no memory leaks. -*/ - case 8: - ((CTWindowSizeCacheTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0708")); - iTest->LogSubTest(KTest8); - TestRWindowCacheEntryExistsCacheCleanL(ETestSizeCacheNotEnabled); - TestRWindowCacheEntryExistsCacheCleanL(ETestSizeCacheEnabled); - TestRWindowCacheEntryExistsCacheCleanSizeL(ETestSizeCacheNotEnabled); - TestRWindowCacheEntryExistsCacheCleanSizeL(ETestSizeCacheEnabled); - TestRWindowCacheEntryExistsCacheCleanEnableWindowSizeCacheL(); - TestRWindowCacheEntryExistsCacheCleanEnableWindowSizeCacheLSizeL(); - break; - -/** -@SYMTestCaseID GRAPHICS-WSERV-0709 - -@SYMDEF DevCR BBRE-7UWGHL - -@SYMTestCaseDesc Test RWindow size cache State: Cache entry exists, cache dirty - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Perform the following with window size cache on and off: - Create RWsSession, creates RWindowGroup and RWindow. - Calls SetSize, Size, then SetSize to enter state with dirty cache entry. - Perform combinations of SetSize/SetExtent/SetSizeErr/SetExtentErr/EnableWindowSizeCacheL. - Check that size returned matches the last size set on the window whenever size is queried. - Clean up. - -@SYMTestExpectedResults Window objects created successfully, no memory leaks. -*/ - case 9: - ((CTWindowSizeCacheTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0709")); - iTest->LogSubTest(KTest9); - TestRWindowCacheEntryExistsCacheDirtySetSizeL(ETestSizeCacheNotEnabled); - TestRWindowCacheEntryExistsCacheDirtySetSizeL(ETestSizeCacheEnabled); - TestRWindowCacheEntryExistsCacheDirtySetExtentL(ETestSizeCacheNotEnabled); - TestRWindowCacheEntryExistsCacheDirtySetExtentL(ETestSizeCacheEnabled); - TestRWindowCacheEntryExistsCacheDirtySetSizeErrL(ETestSizeCacheNotEnabled); - TestRWindowCacheEntryExistsCacheDirtySetSizeErrL(ETestSizeCacheEnabled); - TestRWindowCacheEntryExistsCacheDirtySetExtentErrL(ETestSizeCacheNotEnabled); - TestRWindowCacheEntryExistsCacheDirtySetExtentErrL(ETestSizeCacheEnabled); - TestRWindowCacheEntryExistsCacheDirtySetSizeTwiceL(ETestSizeCacheNotEnabled); - TestRWindowCacheEntryExistsCacheDirtySetSizeTwiceL(ETestSizeCacheEnabled); - TestRWindowCacheEntryExistsCacheDirtySetSizeSetExtentL(ETestSizeCacheNotEnabled); - TestRWindowCacheEntryExistsCacheDirtySetSizeSetExtentL(ETestSizeCacheEnabled); - TestRWindowCacheEntryExistsCacheDirtySetSizeSetSizeErrL(ETestSizeCacheNotEnabled); - TestRWindowCacheEntryExistsCacheDirtySetSizeSetSizeErrL(ETestSizeCacheEnabled); - TestRWindowCacheEntryExistsCacheDirtySetSizeSetExtentErrL(ETestSizeCacheNotEnabled); - TestRWindowCacheEntryExistsCacheDirtySetSizeSetExtentErrL(ETestSizeCacheEnabled); - TestRWindowCacheEntryExistsCacheDirtySetSizeEnableWindowSizeCacheL(); - break; - - -/** -@SYMTestCaseID GRAPHICS-WSERV-0710 - -@SYMDEF DevCR BBRE-7UWGHL - -@SYMTestCaseDesc Test RWindow size cache State: Cache entry exists, cache dirty -> State: Cache entry exists, cache clean - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Perform the following with window size cache on and off: - Create RWsSession, creates RWindowGroup and RWindow. - Calls SetSize, Size, to enter state with clean cache entry. - Perform combinations of SetSize/SetExtent/SetSizeErr/SetExtentErr/EnableWindowSizeCacheL to enter state with dirty cache entry. - Calls RWindow::Size to re-enter state with clean cache entry. - Check that size returned matches the last size set on the window whenever size is queried. - Clean up. - -@SYMTestExpectedResults Window objects created successfully, no memory leaks. -*/ - case 10: - ((CTWindowSizeCacheTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0710")); - iTest->LogSubTest(KTest10); - TestRWindowCacheEntryExistsCacheDirtyToCleanSetSizeL(ETestSizeCacheNotEnabled); - TestRWindowCacheEntryExistsCacheDirtyToCleanSetSizeL(ETestSizeCacheEnabled); - TestRWindowCacheEntryExistsCacheDirtyToCleanSetExtentL(ETestSizeCacheNotEnabled); - TestRWindowCacheEntryExistsCacheDirtyToCleanSetExtentL(ETestSizeCacheEnabled); - TestRWindowCacheEntryExistsCacheDirtyToCleanSetSizeErrL(ETestSizeCacheNotEnabled); - TestRWindowCacheEntryExistsCacheDirtyToCleanSetSizeErrL(ETestSizeCacheEnabled); - TestRWindowCacheEntryExistsCacheDirtyToCleanSetExtentErrL(ETestSizeCacheNotEnabled); - TestRWindowCacheEntryExistsCacheDirtyToCleanSetExtentErrL(ETestSizeCacheEnabled); - TestRWindowCacheEntryExistsCacheDirtyToCleanSetSizeTwiceL(ETestSizeCacheNotEnabled); - TestRWindowCacheEntryExistsCacheDirtyToCleanSetSizeTwiceL(ETestSizeCacheEnabled); - TestRWindowCacheEntryExistsCacheDirtyToCleanSetSizeSetExtentL(ETestSizeCacheNotEnabled); - TestRWindowCacheEntryExistsCacheDirtyToCleanSetSizeSetExtentL(ETestSizeCacheEnabled); - TestRWindowCacheEntryExistsCacheDirtyToCleanSetSizeSetSizeErrL(ETestSizeCacheNotEnabled); - TestRWindowCacheEntryExistsCacheDirtyToCleanSetSizeSetSizeErrL(ETestSizeCacheEnabled); - TestRWindowCacheEntryExistsCacheDirtyToCleanSetSizeSetExtentErrL(ETestSizeCacheNotEnabled); - TestRWindowCacheEntryExistsCacheDirtyToCleanSetSizeSetExtentErrL(ETestSizeCacheEnabled); - TestRWindowCacheEntryExistsCacheDirtyToCleanSetSizeEnableWindowSizeCacheL(); - break; - -/** -@SYMTestCaseID GRAPHICS-WSERV-0711 - -@SYMDEF DevCR BBRE-7UWGHL - -@SYMTestCaseDesc Test RBlankWindow Size cache behaviour - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Utilises RBlankWindow::SetSize, RBlankWindow::SetExtent, RBlankWindow::Size. - Checks size returned by RBlankWindow::Size. - Cleans up. - -@SYMTestExpectedResults Window objects created successfully, no memory leaks, size returned should be last size set on window -*/ - case 11: - ((CTWindowSizeCacheTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0711")); - iTest->LogSubTest(KTest11); - TestRBlankWindowSetSizeSetExtentL(ETestSizeCacheNotEnabled); - TestRBlankWindowSetSizeSetExtentL(ETestSizeCacheEnabled); - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0712 - -@SYMDEF DevCR BBRE-7UWGHL - -@SYMTestCaseDesc Test RBackedUpWindow Size cache behaviour - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Utilises RBackedUpWindow::SetSizeErr, RBackedUpWindow::SetExtentErr, RBackedUpWindow::Size. - Checks size returned by RBackedUpWindow::Size. - Cleans up. - -@SYMTestExpectedResults Window objects created successfully, no memory leaks, size returned should be last size set on window -*/ - case 12: - ((CTWindowSizeCacheTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0712")); - iTest->LogSubTest(KTest12); - TestRBackedUpWindowSetSizeErrSetExtentErrL(ETestSizeCacheNotEnabled); - TestRBackedUpWindowSetSizeErrSetExtentErrL(ETestSizeCacheEnabled); - break; - -/** -@SYMTestCaseID GRAPHICS-WSERV-0713 - -@SYMDEF DevCR BBRE-7UWGHL - -@SYMTestCaseDesc Compare performance of RWindow::Size function with size cache on and off - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Creates an RWsSession, optionally enables window size cache, creates an RWindowGroup and an RWindow - Calls RWindow::Size KPerformanceIterations times. - Measures time taken - with and without size cache enabled - -@SYMTestExpectedResults Window objects created successfully, no memory leaks, time taken for KPerformanceIterations RWindow::Size() calls with cache enabled should be faster. -*/ - case 13: - { - ((CTWindowSizeCacheTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0713")); - iTest->LogSubTest(KTest13); - TUint64 sizeCacheOffDeltaMicroSeconds = TestRWindowSizePerformanceL(ETestSizeCacheNotEnabled, KPerformanceIterations); - TUint64 sizeCacheOnDeltaMicroSeconds = TestRWindowSizePerformanceL(ETestSizeCacheEnabled, KPerformanceIterations); - TEST(sizeCacheOnDeltaMicroSeconds < sizeCacheOffDeltaMicroSeconds); - INFO_PRINTF1(_L("Accessing size using cache is faster")); - } - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0714 - -@SYMDEF DevCR BBRE-7UWGHL - -@SYMTestCaseDesc Randomised stress test - RWindow size related functions - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Creates an RWsSession, creates some RWindowGroup and RWindow instances, performs random size related actions, cleans up. - -@SYMTestExpectedResults Window objects created successfully, no memory leaks, size for each window matches last size set on window -*/ - case 14: - { - ((CTWindowSizeCacheTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0714")); - iTest->LogSubTest(KTest14); - TInt seed = Math::Random(); - // To replicate a test run, take the random seed from the test log and pass into SetRandomSeed - SetRandomSeed(seed); - TestRandomisedStressL(ETestSizeCacheNotEnabled, KStressTestIterations); - } - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0714 - -@SYMDEF DevCR BBRE-7UWGHL - -@SYMTestCaseDesc Randomised stress test - RWindow size related functions, size cache on - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Creates an RWsSession, enables window size cache, creates some RWindowGroup and RWindow instances, performs random size related actions, cleans up. - -@SYMTestExpectedResults Window objects created successfully, no memory leaks, size for each window matches last size set on window -*/ - case 15: - { - ((CTWindowSizeCacheTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0715")); - iTest->LogSubTest(KTest15); - TInt seed = Math::Random(); - // To replicate a test run, take the random seed from the test log and pass into SetRandomSeed - SetRandomSeed(seed); - TestRandomisedStressL(ETestSizeCacheEnabled, KStressTestIterations); - } - break; - - -/** -@SYMTestCaseID GRAPHICS-WSERV-0716 - -@SYMDEF DevCR BBRE-7UWGHL - -@SYMTestCaseDesc Randomised stress test - RWindow size related functions, multiple sessions - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Creates two RWsSession instances, creates some RWindowGroup and RWindow instances, performs random size related actions, cleans up. - -@SYMTestExpectedResults Window objects created successfully, no memory leaks, size for each window matches last size set on window -*/ - case 16: - { - ((CTWindowSizeCacheTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0716")); - iTest->LogSubTest(KTest16); - TInt seed = Math::Random(); - // To replicate a test run, take the random seed from the test log and pass into SetRandomSeed - SetRandomSeed(seed); - TestRandomisedStressMultiSessionL(ETestSizeCacheNotEnabled, KStressTestIterations); - } - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0717 - -@SYMDEF DevCR BBRE-7UWGHL - -@SYMTestCaseDesc Randomised stress test - RWindow size related functions, multiple sessions, size cache on - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Creates two RWsSession instances, enables window size cache, creates some RWindowGroup and RWindow instances, performs random size related actions, cleans up. - -@SYMTestExpectedResults Window objects created successfully, no memory leaks, size for each window matches last size set on window -*/ - case 17: - { - ((CTWindowSizeCacheTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0717")); - iTest->LogSubTest(KTest17); - TInt seed = Math::Random(); - // To replicate a test run, take the random seed from the test log and pass into SetRandomSeed - SetRandomSeed(seed); - TestRandomisedStressMultiSessionL(ETestSizeCacheEnabled, KStressTestIterations); - } - break; - -/** -@SYMTestCaseID GRAPHICS-WSERV-0718 - -@SYMDEF DevCR BBRE-7UWGHL - -@SYMTestCaseDesc Randomised stress test - RWindow size related functions, large number of windows - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Creates an RWsSession, creates some RWindowGroup and RWindow instances, performs random size related actions, cleans up. - -@SYMTestExpectedResults Window objects created successfully, no memory leaks, size for each window matches last size set on window -*/ - case 18: - { - ((CTWindowSizeCacheTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0718")); - iTest->LogSubTest(KTest18); - TInt seed = Math::Random(); - // To replicate a test run, take the random seed from the test log and pass into SetRandomSeed - SetRandomSeed(seed); - TestRandomisedStressCacheEntryVolumeL(ETestSizeCacheNotEnabled, KStressTestIterations, KStressWindowPoolSize); - } - break; -/** -@SYMTestCaseID GRAPHICS-WSERV-0719 - -@SYMDEF DevCR BBRE-7UWGHL - -@SYMTestCaseDesc Randomised stress test - RWindow size related functions, large number of windows - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Creates an RWsSession, enables window size cache, creates some RWindowGroup and RWindow instances, performs random size related actions, cleans up. - -@SYMTestExpectedResults Window objects created successfully, no memory leaks, size for each window matches last size set on window -*/ - case 19: - { - ((CTWindowSizeCacheTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0719")); - iTest->LogSubTest(KTest19); - TInt seed = Math::Random(); - // To replicate a test run, take the random seed from the test log and pass into SetRandomSeed - SetRandomSeed(seed); - TestRandomisedStressCacheEntryVolumeL(ETestSizeCacheEnabled, KStressTestIterations, KStressWindowPoolSize); - } - break; - -/** -@SYMTestCaseID GRAPHICS-WSERV-0720 - -@SYMDEF DevCR BBRE-7UWGHL - -@SYMTestCaseDesc Test RWsSession::EnableWindowSizeCacheL() API - -@SYMTestPriority High - -@SYMTestStatus Implemented - -@SYMTestActions Creates an RWsSession, calls EnableWindowSizeCacheL() multiple times, uses Size related APIs. - -@SYMTestExpectedResults No memory leaks. -*/ - case 20: - { - ((CTWindowSizeCacheTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0720")); - iTest->LogSubTest(KTest20); - TestStressEnableWindowSizeCacheL(KStressTestIterations); - } - break; - default: - ((CTWindowSizeCacheTestStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); - ((CTWindowSizeCacheTestStep*)iStep)->CloseTMSGraphicsStep(); - TestComplete(); - break; - } - ((CTWindowSizeCacheTestStep*)iStep)->RecordTestResultL(); - } - -__WS_CONSTRUCT_STEP__(WindowSizeCacheTest) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/twindowsizecache.h --- a/windowing/windowserver/tauto/twindowsizecache.h Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,143 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef __TWINDOWSIZECACHE_H__ -#define __TWINDOWSIZECACHE_H__ - -#include -#include -#include "AUTO.H" - -#include "../nga/CLIENT/w32comm.h" - -#include "../tlib/testbase.h" -#include "TGraphicsHarness.h" - -//----------------------------------------------------------- -class CTWindowSizeCacheTest : public CTWsGraphicsBase - { -public: - enum TSizeCacheStatus - { - ETestSizeCacheNotEnabled, - ETestSizeCacheEnabled, - }; - enum TRWindowAction - { - ESetExtent, - ESetExtentErr, - ESetSize, - ESetSizeErr, - ECheckSize, - EFlushSession, - EEnableWindowSizeCache, - EMaxAction, - }; -public: - CTWindowSizeCacheTest(CTestStep* aStep); - ~CTWindowSizeCacheTest(); - TestState DoTestL(); - void ConstructL(); -// - void TestCreateRWindowL(TSizeCacheStatus aEnableWindowSizeCache); - void TestCreateRBlankWindowL(TSizeCacheStatus aEnableWindowSizeCache); - void TestCreateRBackedUpWindowL(TSizeCacheStatus aEnableWindowSizeCache, TDisplayMode aDisplayMode); -// - void TestRWindowNoCacheEntryL(TSizeCacheStatus aEnableWindowSizeCache); - void TestRWindowNoCacheEntrySetExtentErrL(TSizeCacheStatus aEnableWindowSizeCache); - void TestRWindowNoCacheEntrySetSizeErrL(TSizeCacheStatus aEnableWindowSizeCache); - void TestRWindowNoCacheEntrySetExtentL(TSizeCacheStatus aEnableWindowSizeCache); - void TestRWindowNoCacheEntrySetSizeL(TSizeCacheStatus aEnableWindowSizeCache); - void TestRWindowNoCacheEntryEnableWindowSizeCacheL(); -// - void TestRWindowCacheEntryExistsCacheCleanL(TSizeCacheStatus aEnableWindowSizeCache); - void TestRWindowCacheEntryExistsCacheCleanSizeL(TSizeCacheStatus aEnableWindowSizeCache); - void TestRWindowCacheEntryExistsCacheCleanEnableWindowSizeCacheL(); - void TestRWindowCacheEntryExistsCacheCleanEnableWindowSizeCacheLSizeL(); -// - void TestRWindowCacheEntryExistsCacheDirtySetSizeL(TSizeCacheStatus aEnableWindowSizeCache); - void TestRWindowCacheEntryExistsCacheDirtySetExtentL(TSizeCacheStatus aEnableWindowSizeCache); - void TestRWindowCacheEntryExistsCacheDirtySetSizeErrL(TSizeCacheStatus aEnableWindowSizeCache); - void TestRWindowCacheEntryExistsCacheDirtySetExtentErrL(TSizeCacheStatus aEnableWindowSizeCache); - void TestRWindowCacheEntryExistsCacheDirtySetSizeTwiceL(TSizeCacheStatus aEnableWindowSizeCache); - void TestRWindowCacheEntryExistsCacheDirtySetSizeSetExtentL(TSizeCacheStatus aEnableWindowSizeCache); - void TestRWindowCacheEntryExistsCacheDirtySetSizeSetSizeErrL(TSizeCacheStatus aEnableWindowSizeCache); - void TestRWindowCacheEntryExistsCacheDirtySetSizeSetExtentErrL(TSizeCacheStatus aEnableWindowSizeCache); - void TestRWindowCacheEntryExistsCacheDirtySetSizeEnableWindowSizeCacheL(); -// - void TestRWindowCacheEntryExistsCacheDirtyToCleanSetSizeL(TSizeCacheStatus aEnableWindowSizeCache); - void TestRWindowCacheEntryExistsCacheDirtyToCleanSetExtentL(TSizeCacheStatus aEnableWindowSizeCache); - void TestRWindowCacheEntryExistsCacheDirtyToCleanSetSizeErrL(TSizeCacheStatus aEnableWindowSizeCache); - void TestRWindowCacheEntryExistsCacheDirtyToCleanSetExtentErrL(TSizeCacheStatus aEnableWindowSizeCache); - void TestRWindowCacheEntryExistsCacheDirtyToCleanSetSizeTwiceL(TSizeCacheStatus aEnableWindowSizeCache); - void TestRWindowCacheEntryExistsCacheDirtyToCleanSetSizeSetExtentL(TSizeCacheStatus aEnableWindowSizeCache); - void TestRWindowCacheEntryExistsCacheDirtyToCleanSetSizeSetSizeErrL(TSizeCacheStatus aEnableWindowSizeCache); - void TestRWindowCacheEntryExistsCacheDirtyToCleanSetSizeSetExtentErrL(TSizeCacheStatus aEnableWindowSizeCache); - void TestRWindowCacheEntryExistsCacheDirtyToCleanSetSizeEnableWindowSizeCacheL(); -// - void TestRBlankWindowSetSizeSetExtentL(TSizeCacheStatus aEnableWindowSizeCache); - void TestRBackedUpWindowSetSizeErrSetExtentErrL(TSizeCacheStatus aEnableWindowSizeCache); -// - void SetRandomSeed(TInt64 aSeed); - inline TInt NextRandom(TUint aMax = 0); -// - TUint64 TestRWindowSizePerformanceL(TSizeCacheStatus aEnableWindowSizeCache, TUint aIterations); -// - static void CleanupWindowPool(TAny* aPtr); - void RWindowPerformAction(TRWindowAction aAction, TSizeCacheStatus aEnableWindowSizeCache, RWsSession& aWs, RWindow& aWindow, TSize& aExpectedSize); - void TestRandomisedStressL(TSizeCacheStatus aEnableWindowSizeCache, TUint aIterations); - void TestRandomisedStressMultiSessionL(TSizeCacheStatus aEnableWindowSizeCache, TUint aIterations); - void TestRandomisedStressCacheEntryVolumeL(TSizeCacheStatus aEnableWindowSizeCache, TUint aIterations, TUint aWindowPoolSize); - void TestStressEnableWindowSizeCacheL(TUint aIterations); - -protected: -//from CTGraphicsStep - virtual void RunTestCaseL(TInt aCurTestCase); - -private: - TInt64 iSeed; - }; - -//----------------------------------------------------------- -inline TInt CTWindowSizeCacheTest::NextRandom(TUint aMax) - { - TInt random = Math::Rand(iSeed); - if (aMax != 0) - { - random = random % aMax; - } - return random; - } - -//----------------------------------------------------------- -class CTWindowSizeCacheTestStep : public CTGraphicsStep - { -public: - CTWindowSizeCacheTestStep(); -protected: - //from CTGraphicsStep - virtual CTGraphicsBase* CreateTestL(); - }; - -_LIT(KTWindowSizeCacheTestStep,"TWindowSizeCacheTest"); - -//----------------------------------------------------------- -#endif // TWINDOWSIZECACHE diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tauto/wscons.cpp --- a/windowing/windowserver/tauto/wscons.cpp Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,113 +0,0 @@ -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -#include -#include - -NONSHARABLE_CLASS(CWsConsole) : public CConsoleBase - { -public: -// Pure virtuals from CConsoleBase - TInt Create(const TDesC& aTitle,TSize aSize); - void Read(TRequestStatus& aStatus); - void ReadCancel(); - void Write(const TDesC& aDes); - TPoint CursorPos() const; - void SetCursorPosAbs(const TPoint& aPoint); - void SetCursorPosRel(const TPoint& aPoint); - void SetCursorHeight(TInt aPercentage); - void SetTitle(const TDesC& aTitle); - void ClearScreen(); - void ClearToEndOfLine(); - TSize ScreenSize() const; - TKeyCode KeyCode() const; - TUint KeyModifiers() const; -private: - TRequestStatus* iStatus; - }; - -// -// CWsConsole -// - -TInt CWsConsole::Create(const TDesC&,TSize ) - { - return(KErrNone); - } - -void CWsConsole::Read(TRequestStatus& aStatus) - { - aStatus=KRequestPending; - iStatus=&aStatus; - User::RequestComplete(iStatus,KErrNone); - } - -void CWsConsole::ReadCancel() - { - User::RequestComplete(iStatus,KErrCancel); - } - -void CWsConsole::Write(const TDesC&) - { - } - -TPoint CWsConsole::CursorPos() const - { - return(TPoint()); - } - -void CWsConsole::SetCursorPosAbs(const TPoint&) - { - } - -void CWsConsole::SetCursorPosRel(const TPoint&) - { - } - -void CWsConsole::SetCursorHeight(TInt ) - { - } - -void CWsConsole::SetTitle(const TDesC&) - { - } - -void CWsConsole::ClearScreen() - { - } - -void CWsConsole::ClearToEndOfLine() - { - } - -TSize CWsConsole::ScreenSize() const - { - return(TSize(32,20)); - } - -TKeyCode CWsConsole::KeyCode() const - { - return(EKeyNull); - } - -TUint CWsConsole::KeyModifiers() const - { - return(0); - } - -EXPORT_C TAny* NewConsole() - { - return new CWsConsole; - } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tbufferdrawer/bufferdrawer.cpp --- a/windowing/windowserver/tbufferdrawer/bufferdrawer.cpp Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,89 +0,0 @@ -// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include "bufferdrawer.h" -#include -#include -#include -#include -#include -#include -#include - - -// CWsGraphicDrawer -CWsBufferGraphicDrawer* CWsBufferGraphicDrawer::NewL() - { - return new(ELeave) CWsBufferGraphicDrawer; - } - -CWsBufferGraphicDrawer::~CWsBufferGraphicDrawer() - { - } - -void CWsBufferGraphicDrawer::ConstructL(MWsGraphicDrawerEnvironment& aEnv, const TGraphicDrawerId& aId, MWsClient& aOwner, const TDesC8& /*aData*/) - { - BaseConstructL(aEnv, aId, aOwner); - // default white line number - iWhiteLinePos = 0; - } - -void CWsBufferGraphicDrawer::HandleMessage(const TDesC8& aData) - { - TInt linePos = aData[0]; - DoUpdateWhiteLinePos(linePos); - } - -void CWsBufferGraphicDrawer::DoUpdateWhiteLinePos(TInt aWhiteLinePos) - { - iWhiteLinePos = aWhiteLinePos; - // Invalidate the redrawing - Invalidate(); - } - -void CWsBufferGraphicDrawer::DoDraw(MWsGc& aGc, const TRect& aRect, const TDesC8& /*aData*/) const - { - MWsGraphicsContext* context = static_cast(aGc.ResolveObjectInterface(KMWsGraphicsContext)); - - //Draw a filled rect with the chosen color - context->Push(); - context->SetBrushStyle(MWsGraphicsContext::ESolidBrush); - context->SetBrushColor(KRgbBlue); - context->DrawRect(aRect); - context->Pop(); - - //Obtain access to the screen/OSB buffer - MWsUiBuffer* buffer = static_cast(aGc.ResolveObjectInterface(KMWsUiBufferInterfaceId)); - TAny* data; - TInt stride; - - TInt err = buffer->MapReadWrite(data, stride); - - if (err == KErrNone) - { - //Fill the chosen line with white - TUint8* scanLine = static_cast(data); - scanLine += stride * iWhiteLinePos; - Mem::Fill(scanLine, stride, 0xFF); - - buffer->Unmap(); - } - } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tbufferdrawer/bufferdrawer.h --- a/windowing/windowserver/tbufferdrawer/bufferdrawer.h Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,54 +0,0 @@ -// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef BUFFERDRAWER_H_ -#define BUFFERDRAWER_H_ - -#include -#include -#include - -// A buffer drawer -NONSHARABLE_CLASS(CWsBufferGraphicDrawer): public CWsGraphicDrawer - { -public: - enum {EImplUid = 0x10285D54}; - -public: - static CWsBufferGraphicDrawer* NewL(); - virtual ~CWsBufferGraphicDrawer(); - // override CWsGraphicDrawer - virtual void ConstructL(MWsGraphicDrawerEnvironment& aEnv,const TGraphicDrawerId& aId, MWsClient& aOwner, const TDesC8& aData); - virtual void HandleMessage(const TDesC8& aData); - -protected: - // override CWsGraphicDrawer - virtual void DoDraw(MWsGc& aGc, const TRect& aRect, const TDesC8& aData) const; - -private: - void DoUpdateWhiteLinePos(TInt aWhiteLinePos); - -private: - TInt iWhiteLinePos; -}; - - -#endif /*BUFFERDRAWER_H_*/ diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tbufferdrawer/bufferdrawer.rss --- a/windowing/windowserver/tbufferdrawer/bufferdrawer.rss Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include - -RESOURCE REGISTRY_INFO registry_info - { - dll_uid = 0x10285D52; - interfaces = - { - INTERFACE_INFO - { - interface_uid = 0x10285D53; - implementations = - { - IMPLEMENTATION_INFO - { - implementation_uid = 0x10285D54; - version_no = 1; - display_name = "CWsBufferGraphicDrawer"; - default_data = ""; - opaque_data = ""; - } - }; - } - }; - } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tbufferdrawer/proxy.cpp --- a/windowing/windowserver/tbufferdrawer/proxy.cpp Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include -#include "bufferdrawer.h" - - -LOCAL_C const TImplementationProxy KImplementationTable[] = - { - IMPLEMENTATION_PROXY_ENTRY(CWsBufferGraphicDrawer::EImplUid, CWsBufferGraphicDrawer::NewL), - }; - -EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) - { - aTableCount = sizeof(KImplementationTable)/sizeof(TImplementationProxy); - return KImplementationTable; - } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tbufferdrawer/wsbufferdrawer.cpp --- a/windowing/windowserver/tbufferdrawer/wsbufferdrawer.cpp Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,97 +0,0 @@ -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include "wsbufferdrawer.h" -#include - -CWsBufferGraphic::CWsBufferGraphic() - { - } - -EXPORT_C CWsBufferGraphic::~CWsBufferGraphic() - { - } - -EXPORT_C CWsBufferGraphic* CWsBufferGraphic::NewL() - { - CWsBufferGraphic* self = new(ELeave) CWsBufferGraphic; - CleanupStack::PushL(self); - self->BaseConstructL(KBufferDrawerImplId,KNullDesC8()); - CleanupStack::Pop(self); - return self; - } - -EXPORT_C CWsBufferGraphic* CWsBufferGraphic::NewL(TUid aUid) - { - CWsBufferGraphic* self = new(ELeave) CWsBufferGraphic; - CleanupStack::PushL(self); - self->BaseConstructL(aUid,KBufferDrawerImplId,KNullDesC8()); - CleanupStack::Pop(self); - return self; - } - -EXPORT_C CWsBufferGraphic* CWsBufferGraphic::NewL(const TWsGraphicId& aReplace) - { - CWsBufferGraphic* self = new(ELeave) CWsBufferGraphic; - CleanupStack::PushL(self); - self->BaseConstructL(aReplace,KBufferDrawerImplId,KNullDesC8()); - CleanupStack::Pop(self); - return self; - } - -EXPORT_C TInt CWsBufferGraphic::UpdateWhiteLinePos(TInt aWhiteLinePos) - { - // Send the message to server side - TBuf8<1> cmd; - cmd.Append(aWhiteLinePos); - - SendMessage(cmd); - return Flush(); - } - -EXPORT_C void CWsBufferGraphic::HandleMessage(const TDesC8& /*aData*/) - { - } - -EXPORT_C void CWsBufferGraphic::OnReplace() - { - } - -EXPORT_C TInt CWsBufferGraphic::ShareGlobally() - { - return CWsGraphic::ShareGlobally(); - } - -EXPORT_C TInt CWsBufferGraphic::UnShareGlobally() - { - return CWsGraphic::UnShareGlobally(); - } - -EXPORT_C TInt CWsBufferGraphic::Share(TSecureId aClientId) - { - return CWsGraphic::Share(aClientId); - } - -EXPORT_C TInt CWsBufferGraphic::UnShare(TSecureId aClientId) - { - return CWsGraphic::UnShare(aClientId); - } - diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tbufferdrawer/wsbufferdrawer.h --- a/windowing/windowserver/tbufferdrawer/wsbufferdrawer.h Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,55 +0,0 @@ -// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef WSBUFFERDRAWER_H_ -#define WSBUFFERDRAWER_H_ - - -#include -const TUid KBufferDrawerInterfaceId = {0x10285D53}; -const TUid KBufferDrawerImplId = {0x10285D54}; - -/** Client representation of a window-server-side drawing owned by this Client -@publishedAll -@released -*/ -NONSHARABLE_CLASS(CWsBufferGraphic): public CWsGraphic - { -public: - IMPORT_C static CWsBufferGraphic* NewL(); - IMPORT_C static CWsBufferGraphic* NewL(TUid aUid); - IMPORT_C static CWsBufferGraphic* NewL(const TWsGraphicId& aReplace); - IMPORT_C ~CWsBufferGraphic(); - IMPORT_C TInt UpdateWhiteLinePos(TInt aWhiteLinePos); - -public: // protected virtuals from CWsGraphic promoted to public - IMPORT_C TInt ShareGlobally(); - IMPORT_C TInt UnShareGlobally(); - IMPORT_C TInt Share(TSecureId aClientId); - IMPORT_C TInt UnShare(TSecureId aClientId); - -public: - CWsBufferGraphic(); - void HandleMessage(const TDesC8& aData); - void OnReplace(); -}; - -#endif /*WSBUFFERDRAWER_H_*/ diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tcapability/TCapTest.CPP --- a/windowing/windowserver/tcapability/TCapTest.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,745 +0,0 @@ -// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Automatically test the window server capabilities. -// -// - -#include -#include "W32STD.H" -#include "../SERVER/w32cmd.h" -#include -#include -#include - -typedef TInt (*TPanicFunction)(TInt aInt,TDes& capability,TInt aExternalGroupId); -LOCAL_D const TUint KPanicThreadHeapSize=0x2000; -#define EWindowGroupHandle 1234 -#define EWindowGroupHandle2 4567 -_LIT(KCAPABILITY_ALL,"CAPABILITY_ALL"); -_LIT(KCAPABILITY_NONE,"CAPABILITY_NONE"); -_LIT(KWRITEDATA_SWEVENT,"WRITEDATA+SWEVENT"); -_LIT(KWRITEDATA_POWERMGMT,"WRITEDATA+POWERMGMT"); -_LIT(KPOWERMGMT_SWEVENT,"POWERMGMT+SWEVENT"); -_LIT(KSetOrdinalPositionPri,"EWsWinOpSetOrdinalPositionPri Capability Check"); -_LIT(KSetOrdinalPositionErr,"EWsWinOpSetOrdinalPositionErr Capability Check"); -TLogMessageText LogMessageText; - -//Enum for indicating which capability is checked. -enum TTestCapability - { - EWriteDeviceData, - ESwEvent, - EPowerMgmt, - EDoNotTest, - ENoCapReq, - EEikSrvSID, - ESwEventPri, - ENoSwEventPri, - ENoSwEventPriSmallOrdinal, - ESwEventErr, - ENoSwEventErr, - ENoSwEventErrSmallOrdinal, - }; - -//Enum for test exit reasons -enum TTestState - { - EWsExitReasonBad, - EWsTestNext, - EWsTestFinished, - }; - - -TTestCapability gTheTestCapability; -TInt gTestState=KErrNone; - - -//Panics if EWsExitReasonBad -enum TAutoPanics - { - EAutoPanicPanicFailed, - }; - -//Thread function structure -struct SPanicParams - { - TInt num; - TPanicFunction func; - TBuf<256> capability; - TInt externalGroupId; - }; - -class CTestBase - { -public: - CTestBase(); - ~CTestBase(); - void ConstructL(const TDes* aCapabilityTest); - TInt TestWsPanicL(TPanicFunction aFunction, TInt aInt, const TDes& aCommandLine); - void UpdateLogsL(); -private : - TInt TestPanicL(SPanicParams* aPtr); - TInt LaunchPanicThread(RThread& aThread, SPanicParams* aPtr); - void Test(TInt aCondition); -private : - TInt iThreadNumber; - RWsSession iWs; - TBuf<256> iCapabilityTest; - TInt iTestCount; - TInt iTestPass; - }; - -//RWsSession derived class to test the EWservMessShutdown message -class RShellWsSession : public RWsSession - { -public: - void ShutDown(); - }; - -void RShellWsSession::ShutDown() - { - SendReceive(EWservMessShutdown,TIpcArgs(EWservShutdownCheck)); - } - -LOCAL_C TInt PanicThreadFunc(TAny* aPtr) - { - CTrapCleanup* CleanUpStack=CTrapCleanup::New(); - SPanicParams* ptr=(SPanicParams*)aPtr; - TInt ret; - TRAP(ret,ret=(*ptr->func)(ptr->num,ptr->capability,ptr->externalGroupId)); - delete CleanUpStack; - if (ret==EWsExitReasonBad) - { - User::Panic(_L("Auto"),EAutoPanicPanicFailed); - } - return(ret); - } - -CTestBase::CTestBase() - { - } - -CTestBase::~CTestBase() - { - iWs.Close(); - } - -void CTestBase::ConstructL(const TDes* aCapabilityTest) - { - iTestCount=iTestPass=0; - iWs.Connect(); - TLex lex(*aCapabilityTest); - TPtrC capability = lex.NextToken(); - iCapabilityTest.Append(capability); - } - -TInt CTestBase::LaunchPanicThread(RThread& aThread, SPanicParams* aPtr) - { - TBuf<32> threadName; - _LIT(KPanicThread, "AutoPanicThread%d"); - threadName.AppendFormat(KPanicThread,iThreadNumber++); - return(aThread.Create(threadName,PanicThreadFunc,KDefaultStackSize,KPanicThreadHeapSize,KPanicThreadHeapSize,aPtr,EOwnerThread)); - } - -TInt CTestBase::TestPanicL(SPanicParams* aPtr) - { - RThread thread; - TRequestStatus stat; - TInt err=LaunchPanicThread(thread, aPtr); - if (err==KErrAlreadyExists) - { - // wait for kernel to clear up old threads - // and have several attempts at starting the thread - // if unsuccessful the first time - for (TInt i=0;i<3;i++) - { - User::After(TTimeIntervalMicroSeconds32(100000)); //0.1 secs - err=LaunchPanicThread(thread, aPtr); - if (err!=KErrAlreadyExists) - { - break; - } - } - } - User::LeaveIfError(err); - thread.Logon(stat); - User::SetJustInTime(EFalse); - thread.Resume(); - User::WaitForRequest(stat); - User::SetJustInTime(ETrue); - TInt threadExit=thread.ExitReason(); - if (threadExit!=EWsTestFinished) - { - if (gTheTestCapability==ENoCapReq) - { - Test(threadExit==KErrNone); - } - else if(gTheTestCapability==EEikSrvSID) - { - Test(threadExit==KErrPermissionDenied); - } - else if(!iCapabilityTest.Compare(KCAPABILITY_ALL)) - { - if(gTheTestCapability!=EDoNotTest) - { - iTestCount++; - if(gTheTestCapability==ESwEventPri) - { - Test(threadExit==KPasswordWindowGroupPriority); - } - else - { - Test(threadExit==KErrNone); - } - } - } - else if(!iCapabilityTest.Compare(KCAPABILITY_NONE)) - { - if(gTheTestCapability!=EDoNotTest) - { - iTestCount++; - if((gTheTestCapability==ENoSwEventPriSmallOrdinal)||(gTheTestCapability==ENoSwEventPri)) - { - Test(threadExit==KPasswordWindowGroupPriority-1); - } - else if(gTheTestCapability==ENoSwEventErrSmallOrdinal) - { - Test(threadExit==KErrNone); - } - else if(gTheTestCapability==ENoSwEventErr) - { - Test(threadExit==KErrPermissionDenied); - } - else - { - Test((threadExit==EWservPanicPermissionDenied)||(threadExit==KErrPermissionDenied)); - } - } - } - else if(!iCapabilityTest.Compare(KWRITEDATA_SWEVENT)) - { - if(gTheTestCapability==EWriteDeviceData || gTheTestCapability==ESwEvent) - { - iTestCount++; - Test(threadExit==KErrNone); - } - if(gTheTestCapability==EPowerMgmt) - { - iTestCount++; - Test((threadExit==EWservPanicPermissionDenied)||(threadExit==KErrPermissionDenied)); - } - } - else if(!iCapabilityTest.Compare(KWRITEDATA_POWERMGMT)) - { - if(gTheTestCapability==EWriteDeviceData || gTheTestCapability==EPowerMgmt) - { - iTestCount++; - Test(threadExit==KErrNone); - } - if(gTheTestCapability==ESwEvent) - { - iTestCount++; - Test((threadExit==EWservPanicPermissionDenied)||(threadExit==KErrPermissionDenied)); - } - } - else if(!iCapabilityTest.Compare(KPOWERMGMT_SWEVENT)) - { - if(gTheTestCapability==EPowerMgmt || gTheTestCapability==ESwEvent) - { - iTestCount++; - Test(threadExit==KErrNone); - } - if(gTheTestCapability==EWriteDeviceData) - { - iTestCount++; - Test((threadExit==EWservPanicPermissionDenied)||(threadExit==KErrPermissionDenied)); - } - } - } - thread.Close(); - return(threadExit); - } - -TInt CTestBase::TestWsPanicL(TPanicFunction aFunction,TInt aTestNo, const TDes& aCommandLine) - { - TLex lex(aCommandLine); - TPtrC capability = lex.NextToken(); - TPtrC idstr = lex.NextToken(); - lex = idstr; - TInt id = 0; - lex.Val(id); - - SPanicParams params; - params.num=aTestNo; - params.func=aFunction; - params.capability.Copy(capability); - params.externalGroupId = id; - return TestPanicL(¶ms); - } - -void CTestBase::Test(TInt aCondition) - { - if(!aCondition) - { - TLogMessageText buf; - _LIT(Fail,"AUTO Failed in Capability Test : "); - buf.Append(Fail); - buf.Append(iCapabilityTest); - iWs.LogMessage(buf); - iWs.Flush(); - } - else - { - iTestPass++; - } - } - -void CTestBase::UpdateLogsL() - { - TBuf<256> testResult; - RFs fileSession; - RFile resultFile; - User::LeaveIfError(fileSession.Connect()); - CleanupClosePushL(fileSession); - resultFile.Replace(fileSession,_L("C:\\DATA\\TestResult.Dat"),EFileWrite); - CleanupClosePushL(resultFile); - TFileText fileText; - fileText.Set(resultFile); - testResult.Num(iTestCount); - fileText.Write(testResult); - testResult.Num(iTestPass); - fileText.Write(testResult); - resultFile.Close(); - fileSession.Close(); - CleanupStack::PopAndDestroy(&resultFile); - CleanupStack::PopAndDestroy(&fileSession); - } - -TInt TestCapability(TInt aTest, TDes& aCapability, TInt aExternalGroupId) - { - _LIT(KDllName,"CLICK"); - RWsSession ws; - ws.Connect(); - CleanupClosePushL(ws); - RWindowGroup gr1(ws); - RWindowGroup gr2(ws); - gr1.Construct(EWindowGroupHandle,EFalse); - gr2.Construct(EWindowGroupHandle2,EFalse); - CleanupClosePushL(gr1); - CleanupClosePushL(gr2); - TWsEvent event; - RSoundPlugIn click1(ws); - CWsScreenDevice *screenDevice; - TRawEvent rawEvent; - CPalette* defPalette=CPalette::NewDefaultL(EColor256); - TInt ret=KErrNone; - switch(aTest) - { - case 0: - // ws.LogMessage(_L("EWsClOpSetKeyboardRepeatRate Capability Check")); - gTheTestCapability=EWriteDeviceData; - ret=ws.SetKeyboardRepeatRate(TTimeIntervalMicroSeconds32(1000000), TTimeIntervalMicroSeconds32(500000)); - ws.Flush(); - break; - case 1: - // ws.LogMessage(_L("EWsClOpSetDoubleClick Capability Check")); - gTheTestCapability=EWriteDeviceData; - ret=ws.SetDoubleClick(TTimeIntervalMicroSeconds32(900000),10); - ws.Flush(); - break; - case 2: - // ws.LogMessage(_L("EWsClOpSendEventToWindowGroup (external group) Capability Check")); - gTheTestCapability=ESwEvent; - event.SetType(EEventModifiersChanged); - ret=ws.SendEventToWindowGroup(aExternalGroupId,event); - break; - case 3: - // ws.LogMessage(_L("EWsClOpSendEventToAllWindowGroup Capability Check")); - gTheTestCapability=ESwEvent; - event.SetType(EEventModifiersChanged); - ret=ws.SendEventToAllWindowGroups(event); - break; - case 4: - // ws.LogMessage(_L("EWsClOpSendEventToAllWindowGroupPriority Capability Check")); - gTheTestCapability=ESwEvent; - event.SetType(EEventModifiersChanged); - gr1.SetOrdinalPosition(0,1); - ret=ws.SendEventToAllWindowGroups(gr1.OrdinalPriority(),event); - break; - case 5: - // ws.LogMessage(_L("EWsClOpSendEventToOneWindowGroupPerClient Capability Check")); - gTheTestCapability=ESwEvent; - event.SetType(EEventModifiersChanged); - ret=ws.SendEventToOneWindowGroupsPerClient(event); - break; - case 6: - // ws.LogMessage(_L("EWsClOpSendMessageToWindowGroup (external group) Capability Check")); - gTheTestCapability=ESwEvent; - ret=ws.SendMessageToWindowGroup(aExternalGroupId,TUid::Uid(123),_L8("SomeParams")); - break; - case 7: - // ws.LogMessage(_L("EWsClOpClaimSystemPointerCursorList Capability Check")); - gTheTestCapability=EWriteDeviceData; - ret=ws.ClaimSystemPointerCursorList(); - //This may return KErrInUse if succeeds. - if(ret==KErrInUse) - { - ret=KErrNone; - } - break; - case 8: - // ws.LogMessage(_L("EWsClOpSetClientCursorMode Capability Check")); - gTheTestCapability=EWriteDeviceData; - ret=ws.SetClientCursorMode(EPointerCursorNone); - ws.Flush(); - break; - case 9: - //Check only if capability is not defined,since the windowgroup is not focused. - if(aCapability.Compare(KCAPABILITY_ALL)&&aCapability.Compare(KWRITEDATA_POWERMGMT)&&aCapability.Compare(KWRITEDATA_SWEVENT)) - { - // ws.LogMessage(_L("EWsClOpSetPointerCursorPosition Capability Check")); - gTheTestCapability=EWriteDeviceData; - ret=ws.SetPointerCursorPosition(TPoint(60,20)); - ws.Flush(); - } - else - { - gTheTestCapability=EDoNotTest; - } - break; - case 10: - // ws.LogMessage(_L("EWsClOpSetModifierState Capability Check")); - gTheTestCapability=EWriteDeviceData; - ret=ws.SetModifierState(EModifierCapsLock,ETurnOnModifier); - ret=ws.SetModifierState(EModifierCapsLock,ETurnOffModifier); - ws.Flush(); - break; - case 11: - { - // ws.LogMessage(_L("EWsClOpRawEvent Capability Check")); - gTheTestCapability=ESwEvent; - rawEvent.Set(TRawEvent::EActive); - ws.SimulateRawEvent(rawEvent); - ws.Flush(); - } - break; - case 12: - { - // ws.LogMessage(_L("EWsClOpKeyEvent Capability Check")); - gTheTestCapability=ESwEvent; - TKeyEvent keyEvent; - keyEvent.iCode='J'; - keyEvent.iScanCode=0; - keyEvent.iModifiers=EModifierAutorepeatable; - keyEvent.iRepeats=0; - ws.SimulateKeyEvent(keyEvent); - ws.Flush(); - } - break; - case 13: - // ws.LogMessage(_L("EWsClOpSendOffEventsToShell Capability Check")); - gTheTestCapability=EPowerMgmt; - ret=ws.RequestOffEvents(EFalse); - break; - case 14: - // ws.LogMessage(_L("EWsClOpSetFaded Capability Check")); - gTheTestCapability=EWriteDeviceData; - ret=ws.SetSystemFaded(EFalse); - break; - case 15: - //Since there is some problem in running the EWsClOpNoFlickerFree - //code this test is not run if WriteDeviceData capability is defined. - // ws.LogMessage(_L("EWsClOpNoFlickerFree Capability Check")); - if(aCapability.Compare(KCAPABILITY_ALL)&&aCapability.Compare(KWRITEDATA_POWERMGMT)&&aCapability.Compare(KWRITEDATA_SWEVENT)) - { - CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws); - gTheTestCapability=EWriteDeviceData; - TInt err; - if ((err=screen->Construct(0))!=KErrNone) - { - delete screen; - User::Leave(err); - } - ws.TestWrite(ws.WsHandle(), EWsClOpNoFlickerFree, NULL, 0); - ws.Flush(); - delete screen; - } - else - { - gTheTestCapability=EDoNotTest; - } - break; - case 16: - // ws.LogMessage(_L("EWsClOpSetFocusScreen Capability Check")); - gTheTestCapability=EWriteDeviceData; - ret=ws.SetFocusScreen(0); - break; - case 17: - { - //Check only if capability is not defined. Otherwise it will shut down the shell. - if(aCapability.Compare(KCAPABILITY_ALL)&&aCapability.Compare(KWRITEDATA_POWERMGMT)&&aCapability.Compare(KPOWERMGMT_SWEVENT)) - { - // ws.LogMessage(_L("EWservMessShutdown Capability Check")); - gTheTestCapability=EPowerMgmt; - RShellWsSession wsShell; - wsShell.Connect(); - wsShell.ShutDown(); - } - else - { - gTheTestCapability=EDoNotTest; - } - break; - } - case 18: - // ws.LogMessage(_L("EWsWinOpCaptureKey Capability Check")); - gTheTestCapability=ESwEvent; - ret=gr2.CaptureKey('a',EModifierFunc,EModifierFunc); - //If the function succeeds capability check,the ret value is handle identifying the capture key. - if(ret>0) - { - ret=KErrNone; - } - break; - case 19: - // ws.LogMessage(_L("EWsWinOpCaptureKeyUpsAndDowns Capability Check")); - gTheTestCapability=ESwEvent; - ret=gr2.CaptureKeyUpAndDowns('a',0,0); - //If the function succeeds capability check,the ret value is handle identifying the capture key. - if(ret>0) - { - ret=KErrNone; - } - break; - case 20: - // ws.LogMessage(_L("EWsWinOpCaptureLongKey Capability Check")); - gTheTestCapability=ESwEvent; - ret=gr2.CaptureLongKey(EKeyEscape,'e',0,0,2,ELongCaptureNormal|ELongCaptureRepeatEvents); - //If the function succeeds capability check,the ret value is handle identifying the capture key. - if(ret>0) - { - ret=KErrNone; - } - break; - case 21: - // ws.LogMessage(_L("EWsClickOpLoad Capability Check")); - gTheTestCapability=EWriteDeviceData; - click1.Construct(); - CleanupClosePushL(click1); - ret=click1.Load(KDllName); - CleanupStack::PopAndDestroy(&click1); - break; - case 22: - // ws.LogMessage(_L("EWsClickOpUnLoad Capability Check")); - gTheTestCapability=EWriteDeviceData; - click1.Construct(); - ret=click1.Unload(); - break; - case 23: - // ws.LogMessage(_L("EWsSdOpSetScreenMode Capability Check")); - gTheTestCapability=EWriteDeviceData; - screenDevice=new(ELeave) CWsScreenDevice(ws); - CleanupStack::PushL(screenDevice); - screenDevice->Construct(0); - screenDevice->SetScreenMode(0); - CleanupStack::PopAndDestroy(screenDevice); - break; - case 24: - // ws.LogMessage(_L("EWsSdOpSetScreenModeEnforcement Capability Check")); - gTheTestCapability=EWriteDeviceData; - screenDevice=new(ELeave) CWsScreenDevice(ws); - CleanupStack::PushL(screenDevice); - screenDevice->Construct(0); - screenDevice->SetScreenModeEnforcement(ESizeEnforcementNone); - ws.Flush(); - CleanupStack::PopAndDestroy(screenDevice); - break; - case 25: - { - // ws.LogMessage(_L("EWsSdOpSetPalette Capability Check")); - gTheTestCapability=EWriteDeviceData; - screenDevice=new(ELeave) CWsScreenDevice(ws); - CleanupStack::PushL(screenDevice); - screenDevice->Construct(0); - ret=screenDevice->SetCustomPalette(defPalette); - //Returns KErrNotSupported if succeeds capability check. - if(ret==KErrNotSupported) - { - ret=KErrNone; - } - CleanupStack::PopAndDestroy(screenDevice); - } - break; - case 26: - { - //Checking the capability for SetHotKeys - // ws.LogMessage(_L("EWsClOpSetHotKey Capability Check")); - gTheTestCapability=ESwEvent; - ret=ws.SetHotKey(EHotKeyEnableLogging,'e',EModifierFunc|EModifierCtrl|EModifierShift,0); - ws.Flush(); - } - break; - case 27: - { - //Checking the capability for ClearHotKeys - // ws.LogMessage(_L("EWsClOpClearHotKeys Capability Check")); - gTheTestCapability=ESwEvent; - ret=ws.ClearHotKeys(EHotKeyEnableLogging); - ws.Flush(); - } - break; - case 28: - // ws.LogMessage(_L("EWsClOpSendEventToWindowGroup (own group) Capability Check")); - gTheTestCapability=ENoCapReq; - event.SetType(EEventModifiersChanged); - ret=ws.SendEventToWindowGroup(gr1.Identifier(),event); - break; - case 29: - // ws.LogMessage(_L("EWsClOpSendMessageToWindowGroup (own group) Capability Check")); - gTheTestCapability=ENoCapReq; - ret=ws.SendMessageToWindowGroup(gr1.Identifier(),TUid::Uid(123),_L8("SomeParams")); - break; - case 30: - // ws.LogMessage(_L("EWsClOpSetBackLight Capability Check")); - gTheTestCapability=EEikSrvSID; - screenDevice=new(ELeave) CWsScreenDevice(ws); - CleanupStack::PushL(screenDevice); - screenDevice->Construct(0); - ret=screenDevice->SetBackLight(ETrue); //Always returns KErrPermissionDenied. - CleanupStack::PopAndDestroy(screenDevice); - break; - case 31: - { - TBool test=EFalse; - if(!aCapability.Compare(KCAPABILITY_ALL)) - { - gTheTestCapability=ESwEventPri; - test=ETrue; - } - else if(!aCapability.Compare(KCAPABILITY_NONE)) - { - gTheTestCapability=ENoSwEventPri; - test=ETrue; - } - else - { - gTheTestCapability=EDoNotTest; - } - if(test) - { - LogMessageText.Format(KSetOrdinalPositionPri); - ws.LogMessage(LogMessageText); - gr1.SetOrdinalPosition(0,KPasswordWindowGroupPriority); - ret=ws.GetWindowGroupOrdinalPriority(gr1.Identifier()); - } - } - break; - case 32: - if(!aCapability.Compare(KCAPABILITY_NONE)) - { - LogMessageText.Format(KSetOrdinalPositionPri); - ws.LogMessage(LogMessageText); - gTheTestCapability=ENoSwEventPriSmallOrdinal; - gr1.SetOrdinalPosition(0,KPasswordWindowGroupPriority-1); - ret=ws.GetWindowGroupOrdinalPriority(gr1.Identifier()); - } - else - { - gTheTestCapability=EDoNotTest; - } - break; - case 33: - { - TBool test=EFalse; - if(!aCapability.Compare(KCAPABILITY_ALL)) - { - gTheTestCapability=ESwEventErr; - test=ETrue; - } - else if(!aCapability.Compare(KCAPABILITY_NONE)) - { - gTheTestCapability=ENoSwEventErr; - test=ETrue; - } - else - { - gTheTestCapability=EDoNotTest; - } - if(test) - { - LogMessageText.Format(KSetOrdinalPositionErr); - ws.LogMessage(LogMessageText); - ret=gr1.SetOrdinalPositionErr(0,KPasswordWindowGroupPriority); - } - } - break; - case 34: - if(!aCapability.Compare(KCAPABILITY_NONE)) - { - LogMessageText.Format(KSetOrdinalPositionErr); - ws.LogMessage(LogMessageText); - gTheTestCapability=ENoSwEventErrSmallOrdinal; - ret=gr1.SetOrdinalPositionErr(0,KPasswordWindowGroupPriority-1); - } - else - { - gTheTestCapability=EDoNotTest; - } - break; - case 35: - // EWsClOpSetCloseProximityThresholds Capability Check - gTheTestCapability=EWriteDeviceData; - ret=ws.SetCloseProximityThresholds(-20, -50); - ws.SetCloseProximityThresholds(KMaxTInt, KMinTInt); - break; - case 36: - // EWsClOpSetHighPressureThresholds Capability Check - gTheTestCapability=EWriteDeviceData; - ret=ws.SetHighPressureThresholds(4000, 2000); - ws.SetHighPressureThresholds(KMaxTInt, KMinTInt); - break; - default: - ret=gTestState=EWsTestFinished; - } - CleanupStack::PopAndDestroy(&gr2); - CleanupStack::PopAndDestroy(&gr1); - CleanupStack::PopAndDestroy(&ws); - return ret; - } - -void MainL() - { - TBuf<256> commandLine; - User::CommandLine(commandLine); - CTestBase testBase; - testBase.ConstructL(&commandLine); - TInt ii=0; - while(gTestState!=EWsTestFinished) - testBase.TestWsPanicL(&TestCapability,ii++,commandLine) ; -// testBase.UpdateLogsL(); - } - -GLDEF_C TInt E32Main() - { - __UHEAP_MARK; - CTrapCleanup* cleanUpStack=CTrapCleanup::New(); - if(cleanUpStack==NULL) - { - return KErrNoMemory; - } - TRAP_IGNORE(MainL()) - delete cleanUpStack; - __UHEAP_MARKEND; - return(KErrNone); - } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tcontaindrawer/containdrawer.cpp --- a/windowing/windowserver/tcontaindrawer/containdrawer.cpp Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,103 +0,0 @@ -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include "containdrawer.h" -#include "wsgraphicdrawercontext.h" -#include -#include - -const TGraphicDrawerId KChildInterfaceId1={0x1028353A, ETrue}; -const TGraphicDrawerId KChildInterfaceId2={0x1028353C, ETrue}; - - -// CWsGraphicDrawer -CWsContainGraphicDrawer* CWsContainGraphicDrawer::NewL() - { - return new(ELeave) CWsContainGraphicDrawer; - } - -CWsContainGraphicDrawer::~CWsContainGraphicDrawer() - { - if (iContext) - { - iContext->Destroy(); - iContext = NULL; - } - } - -void CWsContainGraphicDrawer::ConstructL(MWsGraphicDrawerEnvironment& aEnv, const TGraphicDrawerId& aId, MWsClient& aOwner, const TDesC8& /*aData*/) - { - BaseConstructL(aEnv, aId, aOwner); - iColor = KRgbWhite; - if (!(aEnv.Screen(0)->ResolveObjectInterface(KMWsCompositionContext) || aEnv.Screen(0)->ResolveObjectInterface(KMWsScene))) - { - iContext = CWsGraphicDrawerNonNgaContext::NewL(); - } - else - { - iContext = CWsGraphicDrawerNgaContext::NewL(); - } - } - -void CWsContainGraphicDrawer::HandleMessage(const TDesC8& aData) - { - TInt red = aData[0]; - TInt green = aData[1]; - TInt blue = aData[2]; - TRgb color(red, green, blue); - DoUpdateColor(color); - } - -void CWsContainGraphicDrawer::DoUpdateColor(TRgb aColor) - { - iColor = aColor; - // Invalidate the redrawing - Invalidate(); - } - -void CWsContainGraphicDrawer::DoDraw(MWsGc& aGc, const TRect& aRect, const TDesC8& aData) const - { - iContext->DrawEllipse(aGc, aRect, iColor); - - // invoke another CRPs to draw their artwork - TRect rect1 = TRect(TPoint(100,150),TSize(50,50)); - const CWsGraphicDrawer* child1 = Env().ResolveGraphic(KChildInterfaceId1); - if (child1) - child1->Draw(aGc, rect1, aData); - TRect rect2 = TRect(TPoint(200,150),TSize(50,50)); - const CWsGraphicDrawer* child2 = Env().ResolveGraphic(KChildInterfaceId2); - if (child2) - child2->Draw(aGc, rect2, aData); - } - -// inherited API to indicate there are contained drawers -TBool CWsContainGraphicDrawer::HasAsChild(const TArray& aIds) const - { - // Two child CRPs - const CWsGraphicDrawer* child1 = Env().ResolveGraphic(KChildInterfaceId1); - const CWsGraphicDrawer* child2 = Env().ResolveGraphic(KChildInterfaceId2); - if (child1 && child1->Contains(aIds)) - return ETrue; - else if (child2 && child2->Contains(aIds)) - return ETrue; - else - return EFalse; - } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tcontaindrawer/containdrawer.h --- a/windowing/windowserver/tcontaindrawer/containdrawer.h Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,52 +0,0 @@ -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef __CONTAINDRAWER_H__ -#define __CONTAINDRAWER_H__ - -#include -#include - -class MWsGraphicDrawerContext; - -NONSHARABLE_CLASS(CWsContainGraphicDrawer): public CWsGraphicDrawer - { -public: - enum {EImplUid = 0x10283521}; - -public: - static CWsContainGraphicDrawer* NewL(); - virtual ~CWsContainGraphicDrawer(); - // override CWsGraphicDrawer - virtual void ConstructL(MWsGraphicDrawerEnvironment& aEnv,const TGraphicDrawerId& aId, MWsClient& aOwner, const TDesC8& aData); - virtual void HandleMessage(const TDesC8& aData); -private: - // override CWsGraphicDrawer - virtual void DoDraw(MWsGc& aGc, const TRect& aRect, const TDesC8& aData) const; - virtual TBool HasAsChild(const TArray& aIds) const; - - void DoUpdateColor(TRgb aColor); -private: - MWsGraphicDrawerContext* iContext; - TRgb iColor; -}; - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tcontaindrawer/containdrawer.rss --- a/windowing/windowserver/tcontaindrawer/containdrawer.rss Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,81 +0,0 @@ -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include - -RESOURCE REGISTRY_INFO registry_info - { - dll_uid = 0x10283520; - interfaces = - { - INTERFACE_INFO - { - interface_uid = 0x10283522; - implementations = - { - IMPLEMENTATION_INFO - { - implementation_uid = 0x10283521; - version_no = 1; - display_name = "CWsContainDrawer"; - default_data = ""; - opaque_data = ""; - } - }; - interface_uid = 0x1028351B; - implementations = - { - IMPLEMENTATION_INFO - { - implementation_uid = 0x1028351C; - version_no = 1; - display_name = "CWsSimpleDrawer"; - default_data = ""; - opaque_data = ""; - } - }; - interface_uid = 0x1028353A; - implementations = - { - IMPLEMENTATION_INFO - { - implementation_uid = 0x10283539; - version_no = 1; - display_name = "CWsInvisibleDrawer1"; - default_data = ""; - opaque_data = ""; - } - }; - interface_uid = 0x1028353C; - implementations = - { - IMPLEMENTATION_INFO - { - implementation_uid = 0x1028353B; - version_no = 1; - display_name = "CWsInvisibleDrawer2"; - default_data = ""; - opaque_data = ""; - } - }; - } - }; - } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tcontaindrawer/proxy.cpp --- a/windowing/windowserver/tcontaindrawer/proxy.cpp Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,39 +0,0 @@ -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include -#include "containdrawer.h" -#include "simpledrawer.h" - - -LOCAL_C const TImplementationProxy KImplementationTable[] = - { - IMPLEMENTATION_PROXY_ENTRY(CWsContainGraphicDrawer::EImplUid, CWsContainGraphicDrawer::NewL), - IMPLEMENTATION_PROXY_ENTRY(CWsSimpleGraphicDrawer::EImplUid, CWsSimpleGraphicDrawer::NewL), - IMPLEMENTATION_PROXY_ENTRY(CWsInvisibleGraphicDrawer1::EImplUid, CWsInvisibleGraphicDrawer1::NewL), - IMPLEMENTATION_PROXY_ENTRY(CWsInvisibleGraphicDrawer2::EImplUid, CWsInvisibleGraphicDrawer2::NewL), - }; - -EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) - { - aTableCount = sizeof(KImplementationTable)/sizeof(TImplementationProxy); - return KImplementationTable; - } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tcontaindrawer/simpledrawer.cpp --- a/windowing/windowserver/tcontaindrawer/simpledrawer.cpp Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,115 +0,0 @@ -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include "simpledrawer.h" -#include "wsgraphicdrawercontext.h" -#include -#include - -// CWsGraphicDrawer -CWsSimpleGraphicDrawer* CWsSimpleGraphicDrawer::NewL() - { - return new(ELeave) CWsSimpleGraphicDrawer; - } - -CWsSimpleGraphicDrawer::~CWsSimpleGraphicDrawer() - { - if (iContext) - { - iContext->Destroy(); - iContext = NULL; - } - } - -void CWsSimpleGraphicDrawer::ConstructL(MWsGraphicDrawerEnvironment& aEnv, const TGraphicDrawerId& aId, MWsClient& aOwner, const TDesC8& /*aData*/) - { - BaseConstructL(aEnv, aId, aOwner); - // default color - iColor = KRgbBlue; - } - -void CWsSimpleGraphicDrawer::HandleMessage(const TDesC8& aData) - { - TInt red = aData[0]; - TInt green = aData[1]; - TInt blue = aData[2]; - TRgb color(red, green, blue); - DoUpdateColor(color); - } - -void CWsSimpleGraphicDrawer::BaseConstructL(MWsGraphicDrawerEnvironment& aEnv,const TGraphicDrawerId& aId,MWsClient& aOwner) - { - CWsGraphicDrawer::BaseConstructL(aEnv, aId, aOwner); - if (!(aEnv.Screen(0)->ResolveObjectInterface(KMWsCompositionContext) || aEnv.Screen(0)->ResolveObjectInterface(KMWsScene))) - { - iContext = CWsGraphicDrawerNonNgaContext::NewL(); - } - else - { - iContext = CWsGraphicDrawerNgaContext::NewL(); - } - } - -void CWsSimpleGraphicDrawer::DoUpdateColor(TRgb aColor) - { - iColor = aColor; - // Invalidate the redrawing - Invalidate(); - } - -void CWsSimpleGraphicDrawer::DoDraw(MWsGc& aGc, const TRect& aRect, const TDesC8& /*aData*/) const - { - iContext->DrawEllipse(aGc, aRect, iColor); - } - -// First contained (child) drawer -CWsInvisibleGraphicDrawer1* CWsInvisibleGraphicDrawer1::NewL() - { - return new(ELeave) CWsInvisibleGraphicDrawer1; - } - -CWsInvisibleGraphicDrawer1::~CWsInvisibleGraphicDrawer1() - { - } - -void CWsInvisibleGraphicDrawer1::ConstructL(MWsGraphicDrawerEnvironment& aEnv, const TGraphicDrawerId& aId, MWsClient& aOwner, const TDesC8& /*aData*/) - { - BaseConstructL(aEnv, aId, aOwner); - // default color - iColor = KRgbYellow; - } - -// Second contained (child) drawer -CWsInvisibleGraphicDrawer2* CWsInvisibleGraphicDrawer2::NewL() - { - return new(ELeave) CWsInvisibleGraphicDrawer2; - } - -CWsInvisibleGraphicDrawer2::~CWsInvisibleGraphicDrawer2() - { - } - -void CWsInvisibleGraphicDrawer2::ConstructL(MWsGraphicDrawerEnvironment& aEnv, const TGraphicDrawerId& aId, MWsClient& aOwner, const TDesC8& /*aData*/) - { - BaseConstructL(aEnv, aId, aOwner); - // default color - iColor = KRgbCyan; - } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tcontaindrawer/simpledrawer.h --- a/windowing/windowserver/tcontaindrawer/simpledrawer.h Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,78 +0,0 @@ -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef __SIMPLEDRAWER_H__ -#define __SIMPLEDRAWER_H__ - -#include -#include - -class MWsGraphicDrawerContext; - -// A simple drawer -NONSHARABLE_CLASS(CWsSimpleGraphicDrawer): public CWsGraphicDrawer//, public MWsEventHandler - { -public: - enum {EImplUid = 0x1028351C}; - -public: - static CWsSimpleGraphicDrawer* NewL(); - virtual ~CWsSimpleGraphicDrawer(); - // override CWsGraphicDrawer - virtual void ConstructL(MWsGraphicDrawerEnvironment& aEnv,const TGraphicDrawerId& aId, MWsClient& aOwner, const TDesC8& aData); - virtual void HandleMessage(const TDesC8& aData); -protected: - // override CWsGraphicDrawer - void BaseConstructL(MWsGraphicDrawerEnvironment& aEnv,const TGraphicDrawerId& aId,MWsClient& aOwner); - virtual void DoDraw(MWsGc& aGc, const TRect& aRect, const TDesC8& aData) const; - void DoUpdateColor(TRgb aColor); -protected: - MWsGraphicDrawerContext* iContext; - TRgb iColor; -}; - -// First Contained (Child) drawer -NONSHARABLE_CLASS(CWsInvisibleGraphicDrawer1): public CWsSimpleGraphicDrawer//, public MWsEventHandler - { -public: - enum {EImplUid = 0x10283539}; - -public: - static CWsInvisibleGraphicDrawer1* NewL(); - virtual ~CWsInvisibleGraphicDrawer1(); - // override CWsGraphicDrawer - virtual void ConstructL(MWsGraphicDrawerEnvironment& aEnv,const TGraphicDrawerId& aId, MWsClient& aOwner, const TDesC8& aData); -}; - -// Second contained (child) drawer -NONSHARABLE_CLASS(CWsInvisibleGraphicDrawer2): public CWsSimpleGraphicDrawer//, public MWsEventHandler - { -public: - enum {EImplUid = 0x1028353B}; - -public: - static CWsInvisibleGraphicDrawer2* NewL(); - virtual ~CWsInvisibleGraphicDrawer2(); - // override CWsGraphicDrawer - virtual void ConstructL(MWsGraphicDrawerEnvironment& aEnv,const TGraphicDrawerId& aId, MWsClient& aOwner, const TDesC8& aData); -}; - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tcontaindrawer/wscontaindrawer.cpp --- a/windowing/windowserver/tcontaindrawer/wscontaindrawer.cpp Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,121 +0,0 @@ -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// The plug-in provides the client side CWsGraphic instance CWsListen, which is used in -// GRAPHICS-WSERV-0438. -// This also provides Test Case INC103472: CRedrawRegion::ContainsDrawers does not look for all drawers. -// The customer incident "INC103472" reports CWsRedrawMsgWindow::CRedrawRegion::ContainsDrawers in wnredraw.cpp -// is suppose to return whether some drawers are contained within a specific region. -// But right now it doesn't check for drawers in drawers. -// So if one drawer from the iDrawerArray contains one of the drawers passed along -// in aDrawers it will still return EFalse when it should return ETrue. -// The fix is added in CWsRedrawMsgWindow::CRedrawRegion::ContainsDrawers(const TArray& aDrawers,const RRegion& aRegion). -// The drawer->Contains() call will end up in HasAsChild(const TArray& aIds), -// where the CWsGraphicDrawer has to look for its own nested drawers and return ETrue or EFalse. -// -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ -//CWsGraphic -#include "wscontaindrawer.h" - -CWsContainGraphicBitmap::CWsContainGraphicBitmap() - { - } - -EXPORT_C CWsContainGraphicBitmap::~CWsContainGraphicBitmap() - { - iIsReady = EFalse; - } - -EXPORT_C CWsContainGraphicBitmap* CWsContainGraphicBitmap::NewL() - { - CWsContainGraphicBitmap* self = new(ELeave) CWsContainGraphicBitmap; - CleanupStack::PushL(self); - self->BaseConstructL(KContainDrawerImplId,KNullDesC8()); - self->iIsReady = ETrue; - CleanupStack::Pop(self); - return self; - } - -EXPORT_C CWsContainGraphicBitmap* CWsContainGraphicBitmap::NewL(TUid aUid) - { - CWsContainGraphicBitmap* self = new(ELeave) CWsContainGraphicBitmap; - CleanupStack::PushL(self); - self->BaseConstructL(aUid,KContainDrawerImplId,KNullDesC8()); - self->iIsReady = ETrue; - CleanupStack::Pop(self); - return self; - } - -EXPORT_C CWsContainGraphicBitmap* CWsContainGraphicBitmap::NewL(const TWsGraphicId& aReplace) - { - CWsContainGraphicBitmap* self = new(ELeave) CWsContainGraphicBitmap; - CleanupStack::PushL(self); - self->BaseConstructL(aReplace,KContainDrawerImplId,KNullDesC8()); - self->iIsReady = ETrue; - CleanupStack::Pop(self); - return self; - } - -EXPORT_C TInt CWsContainGraphicBitmap::UpdateColor(TRgb aColor) - { - if (!iIsReady) - return KErrNotReady; - // Send the color the server side - TBuf8<3> cmd; - TInt red = aColor.Red(); - TInt green = aColor.Green(); - TInt blue = aColor.Blue(); - //Append the color - cmd.Append(red); - cmd.Append(green); - cmd.Append(blue); - - SendMessage(cmd); - return Flush(); - } - - -EXPORT_C void CWsContainGraphicBitmap::HandleMessage(const TDesC8& /*aData*/) - { - } - -EXPORT_C void CWsContainGraphicBitmap::OnReplace() - { - } - -EXPORT_C TInt CWsContainGraphicBitmap::ShareGlobally() - { - return CWsGraphic::ShareGlobally(); - } - -EXPORT_C TInt CWsContainGraphicBitmap::UnShareGlobally() - { - return CWsGraphic::UnShareGlobally(); - } - -EXPORT_C TInt CWsContainGraphicBitmap::Share(TSecureId aClientId) - { - return CWsGraphic::Share(aClientId); - } - -EXPORT_C TInt CWsContainGraphicBitmap::UnShare(TSecureId aClientId) - { - return CWsGraphic::UnShare(aClientId); - } - diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tcontaindrawer/wscontaindrawer.h --- a/windowing/windowserver/tcontaindrawer/wscontaindrawer.h Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,55 +0,0 @@ -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef __WSCONTAINDRAWER_H__ -#define __WSCONTAINDRAWER_H__ - -#include - -const TUid KContainDrawerInterfaceId = {0x10283522}; -const TUid KContainDrawerImplId = {0x10283521}; -/** Client representation of a window-server-side drawing owned by this Client -@publishedAll -@released -*/ -NONSHARABLE_CLASS(CWsContainGraphicBitmap): public CWsGraphic - { -public: - IMPORT_C static CWsContainGraphicBitmap* NewL(); - IMPORT_C static CWsContainGraphicBitmap* NewL(TUid aUid); - IMPORT_C static CWsContainGraphicBitmap* NewL(const TWsGraphicId& aReplace); - IMPORT_C ~CWsContainGraphicBitmap(); -public: - IMPORT_C TInt ShareGlobally(); - IMPORT_C TInt UnShareGlobally(); - IMPORT_C TInt Share(TSecureId aClientId); - IMPORT_C TInt UnShare(TSecureId aClientId); - - IMPORT_C TInt UpdateColor(TRgb aColor); -public: - CWsContainGraphicBitmap(); - void HandleMessage(const TDesC8& aData); - void OnReplace(); -private: - TBool iIsReady; -}; - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tcontaindrawer/wsgraphicdrawercontext.h --- a/windowing/windowserver/tcontaindrawer/wsgraphicdrawercontext.h Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,50 +0,0 @@ -// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -#ifndef __WSGRAPHICDRAWERCONTEXT_H__ -#define __WSGRAPHICDRAWERCONTEXT_H__ - -#include -#include - -class MWsGc; -class TRgb; - -class MWsGraphicDrawerContext - { -public: - virtual void Destroy() = 0; - virtual void DrawEllipse(MWsGc& aGc, const TRect& aRect, const TRgb& aColor) const = 0; - }; - -class CWsGraphicDrawerNgaContext : public CBase, public MWsGraphicDrawerContext - { -public: - static MWsGraphicDrawerContext* NewL(); -public: - void Destroy(); - void DrawEllipse(MWsGc& aGc, const TRect& aRect, const TRgb& aColor) const; - }; - -class CWsGraphicDrawerNonNgaContext : public CBase, public MWsGraphicDrawerContext - { -public: - static MWsGraphicDrawerContext* NewL(); -public: - void Destroy(); - void DrawEllipse(MWsGc& aGc, const TRect& aRect, const TRgb& aColor) const; - }; - -#endif // __WSGRAPHICDRAWERCONTEXT_H__ diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tcontaindrawer/wsgraphicdrawerngacontext.cpp --- a/windowing/windowserver/tcontaindrawer/wsgraphicdrawerngacontext.cpp Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,42 +0,0 @@ -// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -#define SYMBIAN_GRAPHICS_GCE - -#include "wsgraphicdrawercontext.h" -#include - -MWsGraphicDrawerContext* CWsGraphicDrawerNgaContext::NewL() - { - return new(ELeave) CWsGraphicDrawerNgaContext(); - } - -void CWsGraphicDrawerNgaContext::Destroy() - { - delete this; - } - -void CWsGraphicDrawerNgaContext::DrawEllipse(MWsGc& aGc, const TRect& aRect, const TRgb& aColor) const - { - MWsGraphicsContext* context = aGc.ObjectInterface(); - if (context) - { - context->Push(); - context->SetBrushStyle(MWsGraphicsContext::ESolidBrush); - context->SetBrushColor(aColor); - context->DrawEllipse(aRect); - context->Pop(); - } - } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tcontaindrawer/wsgraphicdrawernonngacontext.cpp --- a/windowing/windowserver/tcontaindrawer/wsgraphicdrawernonngacontext.cpp Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -#undef SYMBIAN_GRAPHICS_GCE - -#include "wsgraphicdrawercontext.h" -#include -#include - -MWsGraphicDrawerContext* CWsGraphicDrawerNonNgaContext::NewL() - { - return new(ELeave) CWsGraphicDrawerNonNgaContext(); - } - -void CWsGraphicDrawerNonNgaContext::Destroy() - { - delete this; - } - -void CWsGraphicDrawerNonNgaContext::DrawEllipse(MWsGc& aGc, const TRect& aRect, const TRgb& aColor) const - { - aGc.PushBitGcSettings(); - CFbsBitGc& bitGc = aGc.BitGc(); - bitGc.SetBrushStyle(CGraphicsContext::ESolidBrush); - bitGc.SetBrushColor(aColor); - bitGc.DrawEllipse(aRect); - aGc.PopBitGcSettings(); - } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tcontaindrawer/wssimpledrawer.cpp --- a/windowing/windowserver/tcontaindrawer/wssimpledrawer.cpp Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,181 +0,0 @@ -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// The plug-in provides the client side CWsGraphic instance CWsListen, which is used in -// GRAPHICS-WSERV-0438. -// This also provides Test Case INC103472: CRedrawRegion::ContainsDrawers does not look for all drawers. -// The customer incident "INC103472" reports CWsRedrawMsgWindow::CRedrawRegion::ContainsDrawers in wnredraw.cpp -// is suppose to return wheather some drawers are contained within a specific region. -// But it currently fails to check for drawers in drawers. -// So if one drawer from the iDrawerArray contains one of the drawers passed along -// in aDrawers it will still return EFalse when it should return ETrue. -// The fix is added in CWsRedrawMsgWindow::CRedrawRegion::ContainsDrawers(const TArray& aDrawers,const RRegion& aRegion). -// The drawer->Contains() call will end up in HasAsChild(const TArray& aIds), -// where the CWsGraphicDrawer has to look for its own nested drawers and return ETrue or EFalse. -// -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ -//CWsGraphic -#include "wssimpledrawer.h" -#include - -CWsSimpleGraphicBitmap::CWsSimpleGraphicBitmap() - { - } - -EXPORT_C CWsSimpleGraphicBitmap::~CWsSimpleGraphicBitmap() - { - iIsReady = EFalse; - } - -EXPORT_C CWsSimpleGraphicBitmap* CWsSimpleGraphicBitmap::NewL() - { - CWsSimpleGraphicBitmap* self = new(ELeave) CWsSimpleGraphicBitmap; - CleanupStack::PushL(self); - self->BaseConstructL(KSimpleDrawerImplId,KNullDesC8()); - self->iIsReady = ETrue; - CleanupStack::Pop(self); - return self; - } - -EXPORT_C CWsSimpleGraphicBitmap* CWsSimpleGraphicBitmap::NewL(TUid aUid) - { - CWsSimpleGraphicBitmap* self = new(ELeave) CWsSimpleGraphicBitmap; - CleanupStack::PushL(self); - self->BaseConstructL(aUid,KSimpleDrawerImplId,KNullDesC8()); - self->iIsReady = ETrue; - CleanupStack::Pop(self); - return self; - } - -EXPORT_C CWsSimpleGraphicBitmap* CWsSimpleGraphicBitmap::NewL(const TWsGraphicId& aReplace) - { - CWsSimpleGraphicBitmap* self = new(ELeave) CWsSimpleGraphicBitmap; - CleanupStack::PushL(self); - self->BaseConstructL(aReplace,KSimpleDrawerImplId,KNullDesC8()); - self->iIsReady = ETrue; - CleanupStack::Pop(self); - return self; - } - -EXPORT_C TInt CWsSimpleGraphicBitmap::UpdateColor(TRgb aColor) - { - if (!iIsReady) - return KErrNotReady; - // Send the message to server side - TBuf8<3> cmd; - TInt red = aColor.Red(); - TInt green = aColor.Green(); - TInt blue = aColor.Blue(); - //Append the color - cmd.Append(red); - cmd.Append(green); - cmd.Append(blue); - - SendMessage(cmd); - return Flush(); - } - -EXPORT_C void CWsSimpleGraphicBitmap::HandleMessage(const TDesC8& /*aData*/) - { - } - -EXPORT_C void CWsSimpleGraphicBitmap::OnReplace() - { - } - -EXPORT_C TInt CWsSimpleGraphicBitmap::ShareGlobally() - { - return CWsGraphic::ShareGlobally(); - } - -EXPORT_C TInt CWsSimpleGraphicBitmap::UnShareGlobally() - { - return CWsGraphic::UnShareGlobally(); - } - -EXPORT_C TInt CWsSimpleGraphicBitmap::Share(TSecureId aClientId) - { - return CWsGraphic::Share(aClientId); - } - -EXPORT_C TInt CWsSimpleGraphicBitmap::UnShare(TSecureId aClientId) - { - return CWsGraphic::UnShare(aClientId); - } - -EXPORT_C CWsInvisibleGraphicBitmap1* CWsInvisibleGraphicBitmap1::NewL() - { - CWsInvisibleGraphicBitmap1* self = new(ELeave) CWsInvisibleGraphicBitmap1; - CleanupStack::PushL(self); - self->BaseConstructL(KInvisibleDrawerImplId1,KNullDesC8()); - self->iIsReady = ETrue; - CleanupStack::Pop(self); - return self; - } - -EXPORT_C CWsInvisibleGraphicBitmap1* CWsInvisibleGraphicBitmap1::NewL(TUid aUid) - { - CWsInvisibleGraphicBitmap1* self = new(ELeave) CWsInvisibleGraphicBitmap1; - CleanupStack::PushL(self); - self->BaseConstructL(aUid,KInvisibleDrawerImplId1,KNullDesC8()); - self->iIsReady = ETrue; - CleanupStack::Pop(self); - return self; - } - -EXPORT_C CWsInvisibleGraphicBitmap1* CWsInvisibleGraphicBitmap1::NewL(const TWsGraphicId& aReplace) - { - CWsInvisibleGraphicBitmap1* self = new(ELeave) CWsInvisibleGraphicBitmap1; - CleanupStack::PushL(self); - self->BaseConstructL(aReplace,KInvisibleDrawerImplId1,KNullDesC8()); - self->iIsReady = ETrue; - CleanupStack::Pop(self); - return self; - } - -EXPORT_C CWsInvisibleGraphicBitmap2* CWsInvisibleGraphicBitmap2::NewL() - { - CWsInvisibleGraphicBitmap2* self = new(ELeave) CWsInvisibleGraphicBitmap2; - CleanupStack::PushL(self); - self->BaseConstructL(KInvisibleDrawerImplId2,KNullDesC8()); - self->iIsReady = ETrue; - CleanupStack::Pop(self); - return self; - } - -EXPORT_C CWsInvisibleGraphicBitmap2* CWsInvisibleGraphicBitmap2::NewL(TUid aUid) - { - CWsInvisibleGraphicBitmap2* self = new(ELeave) CWsInvisibleGraphicBitmap2; - CleanupStack::PushL(self); - self->BaseConstructL(aUid,KInvisibleDrawerImplId2,KNullDesC8()); - self->iIsReady = ETrue; - CleanupStack::Pop(self); - return self; - } - -EXPORT_C CWsInvisibleGraphicBitmap2* CWsInvisibleGraphicBitmap2::NewL(const TWsGraphicId& aReplace) - { - CWsInvisibleGraphicBitmap2* self = new(ELeave) CWsInvisibleGraphicBitmap2; - CleanupStack::PushL(self); - self->BaseConstructL(aReplace,KInvisibleDrawerImplId2,KNullDesC8()); - self->iIsReady = ETrue; - CleanupStack::Pop(self); - return self; - } - diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tcontaindrawer/wssimpledrawer.h --- a/windowing/windowserver/tcontaindrawer/wssimpledrawer.h Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,92 +0,0 @@ -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef __WSSIMPLEDRAWER_H__ -#define __WSSIMPLEDRAWER_H__ - - -#include -const TUid KSimpleDrawerInterfaceId = {0x1028351B}; -const TUid KSimpleDrawerImplId = {0x1028351C}; - -/** Client representation of a window-server-side drawing owned by this Client -@publishedAll -@released -*/ -NONSHARABLE_CLASS(CWsSimpleGraphicBitmap): public CWsGraphic - { -public: - IMPORT_C static CWsSimpleGraphicBitmap* NewL(); - IMPORT_C static CWsSimpleGraphicBitmap* NewL(TUid aUid); - IMPORT_C static CWsSimpleGraphicBitmap* NewL(const TWsGraphicId& aReplace); - - IMPORT_C ~CWsSimpleGraphicBitmap(); -public: // protected virtuals from CWsGraphic promoted to public - IMPORT_C TInt ShareGlobally(); - IMPORT_C TInt UnShareGlobally(); - IMPORT_C TInt Share(TSecureId aClientId); - IMPORT_C TInt UnShare(TSecureId aClientId); - - IMPORT_C TInt UpdateColor(TRgb aColor); - -public: - CWsSimpleGraphicBitmap(); - void HandleMessage(const TDesC8& aData); - void OnReplace(); -public: - TBool iIsReady; -}; - - -const TUid KInvisibleDrawerInterfaceId1 = {0x1028353A}; -const TUid KInvisibleDrawerImplId1 = {0x10283539}; - -/** Client representation of a window-server-side drawing owned by this Client -@publishedAll -@released -*/ -NONSHARABLE_CLASS(CWsInvisibleGraphicBitmap1): public CWsSimpleGraphicBitmap - { -public: - IMPORT_C static CWsInvisibleGraphicBitmap1* NewL(); - IMPORT_C static CWsInvisibleGraphicBitmap1* NewL(TUid aUid); - IMPORT_C static CWsInvisibleGraphicBitmap1* NewL(const TWsGraphicId& aReplace); -}; - - -const TUid KInvisibleDrawerInterfaceId2 = {0x1028353C}; -const TUid KInvisibleDrawerImplId2 = {0x1028353B}; - -/** Client representation of a window-server-side drawing owned by this Client -@publishedAll -@released -*/ -NONSHARABLE_CLASS(CWsInvisibleGraphicBitmap2): public CWsSimpleGraphicBitmap - { -public: - IMPORT_C static CWsInvisibleGraphicBitmap2* NewL(); - IMPORT_C static CWsInvisibleGraphicBitmap2* NewL(TUid aUid); - IMPORT_C static CWsInvisibleGraphicBitmap2* NewL(const TWsGraphicId& aReplace); -}; - - - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tcrx/tcrx.cpp --- a/windowing/windowserver/tcrx/tcrx.cpp Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,393 +0,0 @@ -// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include -#include "tcrx.h" -#include "wsredir.h" -#include "wslisten.h" - -static TRedirectorInfo TheInfo; - -class CTwoWindow: public CBase - { -public: - static CTwoWindow* NewL(); - ~CTwoWindow(); -private: - void ConstructL(); -private: - RWsSession iWs; - CWsScreenDevice* iScr; - CWindowGc* iGc; - RWindowGroup iGroup; - RWindow iBg; - RWindow iFg; - }; - -CTwoWindow* CTwoWindow::NewL() - { - CTwoWindow* tw = new(ELeave) CTwoWindow; - CleanupStack::PushL(tw); - tw->ConstructL(); - CleanupStack::Pop(tw); - return tw; - } - -CTwoWindow::~CTwoWindow() - { - iFg.Close(); - iBg.Close(); - iGroup.Close(); - delete iGc; - delete iScr; - iWs.Close(); - } - -void CTwoWindow::ConstructL() - { - User::LeaveIfError(iWs.Connect()); - iScr = new(ELeave) CWsScreenDevice(iWs); - User::LeaveIfError(iScr->Construct()); - User::LeaveIfError(iScr->CreateContext(iGc)); - iGroup = RWindowGroup(iWs); - User::LeaveIfError(iGroup.Construct(0xc0de,ETrue)); - - iBg = RWindow(iWs); - User::LeaveIfError(iBg.Construct(iGroup,0xc0debabe)); - iBg.SetRequiredDisplayMode(EColor64K); - iBg.Activate(); - iWs.Flush(); - - iBg.BeginRedraw(); - iGc->Activate(iBg); - iGc->SetBrushColor(KRgbGreen); - iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - TRect rect(iScr->SizeInPixels()); - iGc->DrawRect(rect); - iGc->SetBrushColor(KRgbBlue); - iGc->DrawEllipse(rect); - iGc->Deactivate(); - iBg.EndRedraw(); - iWs.Flush(); - - iFg = RWindow(iWs); - User::LeaveIfError(iFg.Construct(iGroup,0xc0decafe)); - iFg.SetRequiredDisplayMode(EColor64K); - iFg.SetTransparencyAlphaChannel(); - iFg.SetBackgroundColor(TRgb(0xff,0x55,0x55,0x80)); - iFg.Activate(); - iWs.Flush(); - } - -CClient* CClient::NewL() - { - CClient* self = new(ELeave) CClient; - CleanupStack::PushL(self); - self->ConstructL(); - CleanupStack::Pop(self); - - return self; - } - -CClient::CClient(): CActive(CActive::EPriorityStandard) - { - } - -void CClient::ConstructL() - { - CActiveScheduler::Add(this); - User::LeaveIfError(iWs.Connect()); - iScreen = new(ELeave) CWsScreenDevice(iWs); - User::LeaveIfError(iScreen->Construct(0)); - iGroup = RWindowGroup(iWs); - User::LeaveIfError(iGroup.Construct(0xCAFE, ETrue)); - iGc = new(ELeave) CWindowGc(iScreen); - User::LeaveIfError(iGc->Construct()); - iWin = new(ELeave) CWindow(this); - iWin->ConstructL(NULL, EFalse); - iRedraw = CRedrawHandler::NewL(this); - - iRedir = CWsRedir::NewL(); - iListen = CWsListen::NewL(); - - MakeRequest(); - } - -void CClient::HandleCommand(TInt aCmd) - { - switch (aCmd) - { - case 1: - iRedir->Redirect(CWsRedir::EFrontBuffer, ETrue); - break; - - case 2: - iRedir->Redirect(CWsRedir::EBackBuffer, ETrue); - break; - - case 3: - iRedir->Redirect(CWsRedir::EFrontBuffer, EFalse); - break; - - case 4: - iRedir->Redirect(CWsRedir::EBackBuffer, EFalse); - break; - - case 5: - iListen->Enable(ETrue); - break; - - case 6: - iListen->Enable(EFalse); - break; - - case 7: - iRedir->QueryPlugin(TheInfo); - break; - - case 8: - iBlank.Close(); - iBlank = RBlankWindow(iWs); - iBlank.Construct(iGroup, 0xbeef); - iBlank.SetRequiredDisplayMode(EColor64K); - iBlank.SetColor(KRgbRed); - iBlank.SetExtent(TPoint(20,20),TSize(100,100)); - iBlank.Activate(); - break; - - case 9: - ClearTwoWindow(); - DrawTwoWindow(); - break; - - case 10: - CActiveScheduler::Stop(); - break; - } - } - -CClient::~CClient() - { - Deque(); - ClearTwoWindow(); - iBlank.Close(); - - delete iListen; - delete iRedir; - delete iWin; - delete iRedraw; - delete iGc; - delete iScreen; - - iGroup.Close(); - iWs.Close(); - } - -void CClient::DrawTwoWindow() - { - TRAP_IGNORE(iTwo = CTwoWindow::NewL()); - } - -void CClient::ClearTwoWindow() - { - delete iTwo; - iTwo = NULL; - } - -void CClient::RunL() - { - iWs.GetEvent(iEvent); - if (iEvent.Type()==EEventKey) - HandleCommand(iEvent.Key()->iCode-'0'); - MakeRequest(); - } - -void CClient::DoCancel() - { - iWs.EventReadyCancel(); - } - -void CClient::MakeRequest() - { - iWs.EventReady(&iStatus); - SetActive(); - } - -CRedrawHandler* CRedrawHandler::NewL(CClient* aClient) - { - CRedrawHandler* self=new(ELeave) CRedrawHandler(aClient); - CleanupStack::PushL(self); - self->ConstructL(); - CleanupStack::Pop(self); - - return self; - } - -CRedrawHandler::CRedrawHandler(CClient* aClient) : CActive(CActive::EPriorityStandard), iClient(aClient) - { - } - -void CRedrawHandler::ConstructL() - { - CActiveScheduler::Add(this); - MakeRequest(); - } - -CRedrawHandler::~CRedrawHandler() - { - Cancel(); - } - -void CRedrawHandler::RunL() - { - TWsRedrawEvent event; - iClient->Ws().GetRedraw(event); - CWindow* win = (CWindow*)event.Handle(); - if (win) - { - TRect rect=event.Rect(); - iClient->Gc().Activate(win->Window()); - win->Window().BeginRedraw(rect); - win->Draw(rect); - win->Window().EndRedraw(); - iClient->Gc().Deactivate(); - } - - MakeRequest(); - } - -void CRedrawHandler::MakeRequest() - { - iClient->Ws().RedrawReady(&iStatus); - SetActive(); - } - -void CRedrawHandler::DoCancel() - { - iClient->Ws().RedrawReadyCancel(); - } - -CWindow::CWindow(CClient* aClient) : iClient(aClient) - { - } - -CWindow::~CWindow() - { - iWin.Close(); - } - -void CWindow::ConstructL(CWindow* aParent, TBool aTransparentFlag) - { - iParent = aParent; - iWin = RWindow(iClient->Ws()); - RWindowTreeNode* node=iParent? &iParent->Window() : (RWindowTreeNode*)&iClient->Group(); - User::LeaveIfError(iWin.Construct(*node, (TUint32)this)); - iWin.SetRequiredDisplayMode(EColor64K); - if (aTransparentFlag) - { - iWin.SetBackgroundColor(TRgb(0,0,0,0x80)); - iWin.SetTransparencyAlphaChannel(); - } - iWin.SetExtent(TPoint(0,0),TSize(240,240)); - iWin.Activate(); - } - -void CWindow::Draw(const TRect& aRect) const - { - CWindowGc& gc = iClient->Gc(); - gc.SetBrushStyle(CGraphicsContext::ESolidBrush); - gc.SetBrushColor(TRgb(0,0,0xff,0xff)); - gc.DrawRect(TRect(aRect.iTl.iX,aRect.iTl.iY,aRect.iBr.iX,aRect.iBr.iY/2)); - gc.SetBrushColor(TRgb(0,0,0xff,0x80)); - gc.DrawRect(TRect(aRect.iTl.iX,aRect.iBr.iY/2,aRect.iBr.iX,aRect.iBr.iY)); - DrawMenu(); - - gc.DrawWsGraphic(iClient->WsRedir()->Id(),TRect(aRect.iTl.iX,aRect.iBr.iY/2,aRect.iBr.iX,aRect.iBr.iY)); - } - -_LIT(KMenu1, "1. Redirect screen"); -_LIT(KMenu2, "2. Redirect flickerfree"); -_LIT(KMenu3, "3. Restore screen"); -_LIT(KMenu4, "4. Restore flickerfree"); -_LIT(KMenu5, "5. Register event listener"); -_LIT(KMenu6, "6. Unregister listener"); -_LIT(KMenu7, "7. Test send receive msg"); -_LIT(KMenu8, "8. Test blank window"); -_LIT(KMenu9, "9. Test two window"); -_LIT(KMenuA, "A. Exit"); - -const TBufC<32> TheMenu[] = - { - (const TDesC&)KMenu1, - (const TDesC&)KMenu2, - (const TDesC&)KMenu3, - (const TDesC&)KMenu4, - (const TDesC&)KMenu5, - (const TDesC&)KMenu6, - (const TDesC&)KMenu7, - (const TDesC&)KMenu8, - (const TDesC&)KMenu9, - (const TDesC&)KMenuA - }; - -_LIT(KTypeFace, "DejaVu Sans Condensed"); - -void CWindow::DrawMenu() const - { - CWsScreenDevice* scr = iClient->Screen(); - CFont* font = NULL; - TFontSpec fs(KTypeFace, 15); - scr->GetNearestFontInPixels(font, fs); - CWindowGc& gc = iClient->Gc(); - gc.UseFont(font); - TInt h = font->HeightInPixels(); - gc.SetPenColor(KRgbYellow); - TInt nMenu = sizeof(TheMenu)/sizeof(TheMenu[0]); - for (TInt ii=0; iiReleaseFont(font); - } - -void MainL() - { - CClient* client=CClient::NewL(); - CActiveScheduler::Start(); - - delete client; - } - -GLDEF_C TInt E32Main() - { - CTrapCleanup* trap=CTrapCleanup::New(); - if (!trap) - return KErrNoMemory; - CActiveScheduler* scheduler = new(ELeave) CActiveScheduler; - CActiveScheduler::Install(scheduler); - - __UHEAP_MARK; - TRAPD(err, MainL()); - __UHEAP_MARKEND; - - delete scheduler; - delete trap; - return err; - } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tcrx/tcrx.h --- a/windowing/windowserver/tcrx/tcrx.h Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,128 +0,0 @@ -// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef __TCRX_H__ -#define __TCRX_H__ - -#include -#include - -class CRedrawHandler; -class CWindow; -class CWsListen; -class CWsRedir; -class CTwoWindow; - -class CClient: public CActive - { -public: - static CClient* NewL(); - ~CClient(); - void RunL(); - void DoCancel(); - inline RWsSession& Ws(); - inline RWindowGroup& Group(); - inline CWindowGc& Gc(); - inline CWindow* Win(); - inline CWsScreenDevice* Screen(); - inline CWsRedir* WsRedir(); - inline CWsListen* WsListen(); - void HandleCommand(TInt aCmd); -private: - CClient(); - void ConstructL(); - void MakeRequest(); - void DrawTwoWindow(); - void ClearTwoWindow(); - - RWsSession iWs; - RWindowGroup iGroup; - CWsScreenDevice* iScreen; - CWindowGc* iGc; - TWsEvent iEvent; - CWindow* iWin; - CRedrawHandler* iRedraw; - CWsListen* iListen; - CWsRedir* iRedir; - RBlankWindow iBlank; - CTwoWindow* iTwo; - }; - -class CRedrawHandler: public CActive - { -public: - static CRedrawHandler* NewL(CClient* aClient); - ~CRedrawHandler(); - void RunL(); - void DoCancel(); -private: - CRedrawHandler(CClient* aClient); - void ConstructL(); - void MakeRequest(); - - CClient* iClient; - }; - -class CWindow: public CBase - { -public: - CWindow(CClient* aClient); - void ConstructL(CWindow* aParent, TBool aTransparentFlag); - ~CWindow(); - void Draw(const TRect& aRect) const; - void DrawMenu() const; - inline RWindow& Window(); - inline CWindow* Parent(); - inline TSize Size(); - inline CClient* Client(); -private: - CClient* iClient; - RWindow iWin; - CWindow* iParent; - }; - -// CClient -inline RWsSession& CClient::Ws() - {return iWs;} -inline RWindowGroup& CClient::Group() - {return iGroup;} -inline CWindowGc& CClient::Gc() - {return *iGc;} -inline CWindow* CClient::Win() - {return iWin;} -inline CWsScreenDevice* CClient::Screen() - {return iScreen;} -inline CWsListen* CClient::WsListen() - {return iListen;} -inline CWsRedir* CClient::WsRedir() - {return iRedir;} -// CWindow -inline RWindow& CWindow::Window() - {return iWin;} -inline CWindow* CWindow::Parent() - {return iParent;} -inline TSize CWindow::Size() - {return iWin.Size();} -inline CClient* CWindow::Client() - {return iClient;} - -#endif - diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tcsc/cwsgcecsc.cpp --- a/windowing/windowserver/tcsc/cwsgcecsc.cpp Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,656 +0,0 @@ -// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// @file -// -// - -#include -#include -#include "cwsgcecsc.h" -#include "extendtef.h" -#include "teflogextensions.h" -#include "testscreencapture.h" - - -#if defined(__X86GCC__) -extern "C" TInt atexit(void (*function)(void)) - { - return KErrNone; - } -#endif - -void TefUnitFailLeaveL() - { - User::Leave(KErrTEFUnitFail); - } - -CWSGceCsc::CWSGceCsc() - { - } - -CWSGceCsc::~CWSGceCsc() - { - } - -/** -Common set up code for all tests. - -Creates the session and window group for further windows, plus a simple white -background to obscure any unwanted stuff behind the test. Sets up the surface -update session and surface manager, to work with surfaces. Creates a screen -device for use in the tests. -*/ -void CWSGceCsc::SetupL() - { - CWsGceCscBase::SetupL(); - } - -/** -Common tear down code for all tests. - -Windows, group and session created are closed. Screen device is destroyed. -Surfaces, manager and update session are closed. -*/ -void CWSGceCsc::TearDownL() - { - CWsGceCscBase::TearDownL(); - } - -CTestSuite* CWSGceCsc::CreateSuiteL( const TDesC& aName) - { - SUB_SUITE; - ADD_WSGCE_TEST_STEP(CWSGceCsc, GRAPHICS_WSERV_CSC_101L); - ADD_WSGCE_TEST_STEP(CWSGceCsc, GRAPHICS_WSERV_CSC_102L); - ADD_WSGCE_TEST_STEP(CWSGceCsc, GRAPHICS_WSERV_CSC_103L); - ADD_WSGCE_TEST_STEP(CWSGceCsc, GRAPHICS_WSERV_CSC_104L); - ADD_WSGCE_TEST_STEP(CWSGceCsc, GRAPHICS_WSERV_CSC_105L); - END_SUITE; - } - -/** - @SYMTestCaseID GRAPHICS_WSERV_CSC_101L - - @SYMTestCaseDesc Compare the screen composition using the new and legacy API - - @SYMPREQ CSC - - @SYMTestStatus Implemented - - @SYMTestPriority 1 - - @SYMTestPurpose To check that the screen composition retrieved using the new and legacy APIs - - @SYMTestActions Initialization. - Construct a background opaque window. - Create two bitmaps with the size equal with the composition. - Draw something on the screen. - Use legacy API CopyScreenToBitmap() to copy the screen to first bitmap. - Use the the new API to copy the composition of the screen. - Compare the results. - - @SYMTestExpectedResults The bitmap should be identical -*/ -void CWSGceCsc::GRAPHICS_WSERV_CSC_101L() - { - TRect screen(iScreenDevice->SizeInPixels()); - RWindow nonSurfacedWindow(iSession); - iTestName.Format(_L("GRAPHICS_WSERV_CSC_101L")); - - INFO_PRINTF2(_L("%S"),&iTestName); - iDisplayMode = iScreenDevice->DisplayMode(); // Get default display mode - - ConstructOpaqueWindowLC(nonSurfacedWindow, - iCyan, - 0, - TPoint(0, 0), - screen.Size()); - iSession.Flush(); - Pause(1000); - - MTestScreenCapture* csc = static_cast (iScreenDevice->GetInterface(MTestScreenCapture::KUidTestScreenCaptureIf)); - ASSERT_NOT_NULL(csc); - - TSize compositionScreenSize; - - User::LeaveIfError(csc->GetCompositedSize(compositionScreenSize)); - - CFbsBitmap *bmp1 = new (ELeave) CFbsBitmap; - CleanupStack::PushL(bmp1); - User::LeaveIfError(bmp1->Create(compositionScreenSize, EColor16MU)); - - CFbsBitmap *bmp2 = new (ELeave) CFbsBitmap; - CleanupStack::PushL(bmp2); - User::LeaveIfError(bmp2->Create(compositionScreenSize, EColor16MU)); - - iSession.Flush(); - Pause(200); - - iScreenDevice->CopyScreenToBitmap(bmp1); - User::LeaveIfError(csc->ComposeScreen(*bmp2)); - - SetBackgroundColorWindow(nonSurfacedWindow, iRed); - iSession.Flush(); - - Pause(500); - - iGc->Activate(nonSurfacedWindow); - iGc->BitBlt(TPoint(0, 0), bmp1); - iGc->Deactivate(); - iSession.Flush(); - Pause(500); - - SetBackgroundColorWindow(nonSurfacedWindow, iWhite); - iSession.Flush(); - Pause(500); - - iGc->Activate(nonSurfacedWindow); - iGc->BitBlt(TPoint(0, 0), bmp2); - iGc->Deactivate(); - iSession.Flush(); - Pause(500); - - ASSERT_TRUE(Compare(*bmp1, *bmp2)); - - if (GCEIsSupported()) - { - iUtility->DestroyAll(); - } - - CleanupStack::PopAndDestroy(bmp2); - CleanupStack::PopAndDestroy(bmp1); - CleanupStack::PopAndDestroy(&nonSurfacedWindow); - iSession.Flush(); - Pause(1000); - } - -void CWSGceCsc::DrawBasicPattern (RWindow& aWin) - { - TSize rectSize(100, 100); - aWin.Invalidate(); - aWin.BeginRedraw(); - iGc->Activate(aWin); - iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - iGc->SetBrushColor(KRgbDarkRed); - iGc->DrawRect(TRect(TPoint(35, 5), rectSize)); - iGc->SetBrushColor(KRgbBlack); - iGc->DrawRect(TRect(TPoint(55, 15), rectSize)); - iGc->SetBrushColor(KRgbDarkBlue); - iGc->DrawRect(TRect(TPoint(75, 35), rectSize)); - iGc->SetBrushColor(KRgbYellow); - iGc->DrawRect(TRect(TPoint(95, 55), rectSize)); - iGc->Deactivate(); - aWin.EndRedraw(); - iSession.Flush(); - Pause(500); - } - -/** - @SYMTestCaseID GRAPHICS_WSERV_CSC_102L - - @SYMTestCaseDesc Compare the screen composition using the new and legacy API - - @SYMPREQ CSC - - @SYMTestStatus Implemented - - @SYMTestPriority 1 - - @SYMTestPurpose To check that the screen composition retrieved using the new and legacy APIs - - @SYMTestActions Initialization. - Draw a pattern on the screen - Retrieve to a bitmap the UI content using the legacy API - Blank the screen. - Display the retrieved content to a surface - Retrieve the composited content - Compare the UI content with the composited content - NOTE:assumes current screen mode is at 0 offset - - @SYMTestExpectedResults The UI content should be identical with the composited content -*/ -void CWSGceCsc::GRAPHICS_WSERV_CSC_102L() - { - TRect screen(iScreenDevice->SizeInPixels()); - RWindow testWindow(iSession); - RWindow surfacedTestWindow(iSession); - TSurfaceId surfaceID; - - MTestScreenCapture* csc = static_cast (iScreenDevice->GetInterface(MTestScreenCapture::KUidTestScreenCaptureIf)); - ASSERT_NOT_NULL(csc); - - TSize compositionScreenSize; - User::LeaveIfError(csc->GetCompositedSize(compositionScreenSize)); - - iTestName.Format(_L("GRAPHICS_WSERV_CSC_102")); - INFO_PRINTF2(_L("%S"),&iTestName); - - iDisplayMode = iScreenDevice->DisplayMode(); - - TRAPD(err, surfaceID = iUtility->CreateSurfaceL(compositionScreenSize, - KSurfaceFormat, - compositionScreenSize.iWidth * KBytesPerPixel)); - ASSERT_EQUALS(err,KErrNone); - - ConstructOpaqueWindowLC(testWindow, - iWhite, - 0, - TPoint(0, 0), - compositionScreenSize); - - iSession.Flush(); - Pause(100); - - CFbsBitmap *bmp1 = new (ELeave) CFbsBitmap; - CleanupStack::PushL(bmp1); - User::LeaveIfError(bmp1->Create(compositionScreenSize, EColor16MU)); - - CFbsBitmap *bmp2 = new (ELeave) CFbsBitmap; - CleanupStack::PushL(bmp2); - User::LeaveIfError(bmp2->Create(compositionScreenSize, EColor16MU)); - - iSession.Flush(); - Pause(500); - - SetBackgroundColorWindow(testWindow, iWhite); - DrawBasicPattern (testWindow); - - iScreenDevice->CopyScreenToBitmap(bmp1); - iSession.Flush(); - Pause(100); - - ConstructOpaqueSurfacedWindowLC(surfacedTestWindow, - iRed, - 0, - TPoint(0, 0), - compositionScreenSize, - surfaceID); - - TRAP(err,iUtility->FillSurfaceL(surfaceID, iCyan)); - ASSERT_EQUALS(err,KErrNone); - iSession.Flush(); - Pause(500); - - TRAP(err, iUtility->CopyBitmapToSurfaceL(surfaceID, *bmp1)); - ASSERT_EQUALS(err,KErrNone); - iSession.Flush(); - Pause(500); - - User::LeaveIfError(csc->ComposeScreen(*bmp2)); - - ASSERT_TRUE(Compare(*bmp1, *bmp2)); - - iUtility->DestroyAll(); - CleanupStack::PopAndDestroy(&surfacedTestWindow); - CleanupStack::PopAndDestroy(bmp2); - CleanupStack::PopAndDestroy(bmp1); - CleanupStack::PopAndDestroy(&testWindow); - iSession.Flush(); - Pause(1000); - } - -/** - @SYMTestCaseID GRAPHICS_WSERV_CSC_103L - - @SYMTestCaseDesc Test TranslateExtent - - @SYMPREQ CSC - - @SYMTestStatus Implemented - - @SYMTestPriority 1 - - @SYMTestPurpose To check that the correct translated extent is returned to the client - - @SYMTestActions Initialization - Change to app mode with offset and 90 degrees rotation - Translate a rectangle corresponding to the original app mode - Compare the expected rectangle with the translated rectangle - - @SYMTestExpectedResults The translated rectangle should take into account the offset and rotation - and be equal to the expected rectangle -*/ -void CWSGceCsc::GRAPHICS_WSERV_CSC_103L() - { - TRect screen(iScreenDevice->SizeInPixels()); - RWindow testWindow(iSession); - - iTestName.Format(_L("GRAPHICS_WSERV_CSC_103L")); - INFO_PRINTF2(_L("%S"),&iTestName); - - iDisplayMode = iScreenDevice->DisplayMode(); - - ConstructOpaqueWindowLC(testWindow, - iWhite, - 0, - TPoint(0, 0), - screen.Size()); - iSession.Flush(); - Pause(1000); - - // Get the screen modes - RArray modeList; - TInt err = iScreenDevice->GetScreenSizeModeList(&modeList); - ASSERT_TRUE(err > 1); //2 modes expected - ASSERT_TRUE(modeList.Count() > 1); //2 modes expected - - // The initial extent and the expected translated extent - TRect initial(TPoint(10,10), TSize(20,30)); - TRect extent(initial); - TRect expected(TPoint(15,15), TSize(20,30)); - - // Change app mode to 5 pixels offset - iScreenDevice->SetAppScreenMode(modeList[1]); - iScreenDevice->SetScreenMode(modeList[1]); - iSession.Flush(); - Pause(100); - - TPoint origin = iScreenDevice->GetCurrentScreenModeScaledOrigin(); - if(origin != TPoint(0,0)) - { - // Calculate the new extent - MTestScreenCapture* csc = static_cast (iScreenDevice->GetInterface(MTestScreenCapture::KUidTestScreenCaptureIf)); - ASSERT_NOT_NULL(csc); - csc->TranslateExtent(initial, extent); - ASSERT_TRUE(extent == expected); - } - else - { - INFO_PRINTF1(_L("Non zero offset not supported")); - } - // Change app mode - iScreenDevice->SetAppScreenMode(modeList[0]); - iScreenDevice->SetScreenMode(modeList[0]); - iSession.Flush(); - Pause(100); - - modeList.Close(); - CleanupStack::PopAndDestroy(&testWindow); - iSession.Flush(); - Pause(1000); - } - -/** - @SYMTestCaseID GRAPHICS_WSERV_CSC_104L - - @SYMTestCaseDesc Compare the screen composition using bitmaps with different display modes - - @SYMPREQ CSC - - @SYMTestStatus Implemented - - @SYMTestPriority 1 - - @SYMTestPurpose To check that bitmaps with different display modes - - @SYMTestActions Initialization. - Draw a pattern on the screen - Retrieve to a bitmap the UI content using the legacy API - Blank the screen. - Display the retrieved content to a surface - Retrieve the composited content to a 2nd bitmap - Compare the UI content with the composited content - - @SYMTestExpectedResults The bitmaps format should not match and should return KErrArgument -*/ -void CWSGceCsc::GRAPHICS_WSERV_CSC_104L() - { - TRect screen(iScreenDevice->SizeInPixels()); - RWindow testWindow(iSession); - RWindow surfacedTestWindow(iSession); - TSurfaceId surfaceID; - - MTestScreenCapture* csc = static_cast (iScreenDevice->GetInterface(MTestScreenCapture::KUidTestScreenCaptureIf)); - ASSERT_NOT_NULL(csc); - - TSize compositionScreenSize; - User::LeaveIfError(csc->GetCompositedSize(compositionScreenSize)); - - iTestName.Format(_L("GRAPHICS_WSERV_CSC_102")); - INFO_PRINTF2(_L("%S"),&iTestName); - - iDisplayMode = iScreenDevice->DisplayMode(); - - TRAPD(err, surfaceID = iUtility->CreateSurfaceL(compositionScreenSize, - KSurfaceFormat, - compositionScreenSize.iWidth * KBytesPerPixel)); - ASSERT_EQUALS(err,KErrNone); - - ConstructOpaqueWindowLC(testWindow, - iWhite, - 0, - TPoint(0, 0), - compositionScreenSize); - - iSession.Flush(); - Pause(100); - - CFbsBitmap *bmp1 = new (ELeave) CFbsBitmap; - CleanupStack::PushL(bmp1); - User::LeaveIfError(bmp1->Create(compositionScreenSize, EColor16MU)); - - // Invalid bitmap display mode - CFbsBitmap *bmp2 = new (ELeave) CFbsBitmap; - CleanupStack::PushL(bmp2); - User::LeaveIfError(bmp2->Create(compositionScreenSize, EColor256)); - - iSession.Flush(); - Pause(500); - - // Draw a pattern using WServ - SetBackgroundColorWindow(testWindow, iWhite); - - TSize rectSize(100, 100); - testWindow.Invalidate(); - testWindow.BeginRedraw(); - iGc->Activate(testWindow); - iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - iGc->SetBrushColor(KRgbDarkRed); - iGc->DrawRect(TRect(TPoint(35, 5), rectSize)); - iGc->SetBrushColor(KRgbBlack); - iGc->DrawRect(TRect(TPoint(55, 15), rectSize)); - iGc->SetBrushColor(KRgbDarkBlue); - iGc->DrawRect(TRect(TPoint(75, 35), rectSize)); - iGc->SetBrushColor(KRgbYellow); - iGc->DrawRect(TRect(TPoint(95, 55), rectSize)); - iGc->Deactivate(); - testWindow.EndRedraw(); - iSession.Flush(); - Pause(500); - - iScreenDevice->CopyScreenToBitmap(bmp1); - iSession.Flush(); - Pause(100); - - ConstructOpaqueSurfacedWindowLC(surfacedTestWindow, - iRed, - 0, - TPoint(0, 0), - compositionScreenSize, - surfaceID); - - TRAP(err,iUtility->FillSurfaceL(surfaceID, iCyan)); - ASSERT_EQUALS(err,KErrNone); - iSession.Flush(); - Pause(500); - - TRAP(err, iUtility->CopyBitmapToSurfaceL(surfaceID, *bmp1)); - ASSERT_EQUALS(err,KErrNone); - iSession.Flush(); - Pause(500); - - // negative test, it should fail wit KErrArgument - TInt ret = csc->ComposeScreen(*bmp2); - ASSERT_EQUALS(ret, KErrArgument); - - iUtility->DestroyAll(); - CleanupStack::PopAndDestroy(&surfacedTestWindow); - CleanupStack::PopAndDestroy(bmp2); - CleanupStack::PopAndDestroy(bmp1); - CleanupStack::PopAndDestroy(&testWindow); - iSession.Flush(); - Pause(1000); - } - -/** - @SYMTestCaseID GRAPHICS_WSERV_CSC_105L - @SYMTestCaseDesc Correct bitmap size returned when in small screen mode - @SYMDEF DEF139191 - @SYMPREQ CSC - @SYMTestStatus Implemented - @SYMTestPriority 1 - @SYMTestPurpose Checking GetCompositedSize is correct on gce & acceptable behaviour in non gce mode - @SYMTestActions For every available screen mode - Get size from GetCompositedSize - Draw some coloured rectangles on screen - If gce, do a full screen surface, and paste the coloured rectangles into the surface - ComposeScreen - bitmap 1 should be the same as bitmap 2 - Note - non GCE mode - GetCompositedSize returns unrotated appmode size, so only - compares the intersection of that with actual screen size - Note - gce mode - GetCompositedSize returns actual rotated screen size, so - does a complete screen comparison - @SYMTestExpectedResults All asserts should complete. Comparison should succeed! -*/ -void CWSGceCsc::GRAPHICS_WSERV_CSC_105L() - { - iTestName.Format(_L("GRAPHICS_WSERV_CSC_105")); - INFO_PRINTF2(_L("%S"),&iTestName); - TInt err; - //get list of modes - RArray screenModes; - err = iScreenDevice->GetScreenSizeModeList(&screenModes); - ASSERT_TRUE (err > 0); - //get first mode info - TPixelsAndRotation firstModeInfo; - iScreenDevice->GetScreenModeSizeAndRotation(screenModes[0],firstModeInfo); - - //make sure csc is available - MTestScreenCapture* csc = static_cast (iScreenDevice->GetInterface(MTestScreenCapture::KUidTestScreenCaptureIf)); - ASSERT_NOT_NULL(csc); - - TBool differentSizes = EFalse; - TSizeMode currentModeInfo; - TSize compositionScreenSize; - //for every screen mode - for (TInt ii = 0; ii < screenModes.Count(); ++ii && !differentSizes) - { - //set mode - iScreenDevice->SetAppScreenMode(screenModes[ii]); - iScreenDevice->SetScreenMode(screenModes[ii]); - iSession.Flush(); - Pause(100); - //get mode info - currentModeInfo = iScreenDevice->GetCurrentScreenModeAttributes(); - if (currentModeInfo.iScreenSize.iWidth != firstModeInfo.iPixelSize.iWidth || - currentModeInfo.iScreenSize.iHeight != firstModeInfo.iPixelSize.iHeight || - currentModeInfo.iRotation != firstModeInfo.iRotation) - { //note that we have modes of different sizes / rotations - differentSizes = ETrue; - } - - RWindow testWindow(iSession); - RWindow surfacedTestWindow(iSession); - TSurfaceId surfaceID; - - err = csc->GetCompositedSize(compositionScreenSize); - ASSERT_EQUALS (err,KErrNone); - iDisplayMode = iScreenDevice->DisplayMode(); - - if (GCEIsSupported()) - { //create a surface - TRAP(err, surfaceID = iUtility->CreateSurfaceL(compositionScreenSize, - KSurfaceFormat, - compositionScreenSize.iWidth * KBytesPerPixel)); - ASSERT_EQUALS(err,KErrNone); - } - - //create a basic window - ConstructOpaqueWindowLC(testWindow, - iWhite, - 0, - -currentModeInfo.iOrigin, - compositionScreenSize); //negative origin to ensure it fills screen, not app mode area - iSession.Flush(); - Pause(100); - - //bitmap 1 to compare against - CFbsBitmap *bmp1 = new (ELeave) CFbsBitmap; - CleanupStack::PushL(bmp1); - User::LeaveIfError(bmp1->Create(compositionScreenSize, EColor16MU)); - //bitmap 2 to pass into csc - CFbsBitmap *bmp2 = new (ELeave) CFbsBitmap; - CleanupStack::PushL(bmp2); - User::LeaveIfError(bmp2->Create(compositionScreenSize, EColor16MU)); - - //draw coloured rectangles in the test window - SetBackgroundColorWindow(testWindow, iWhite); - DrawBasicPattern (testWindow); - - //copy screen to bitmap 1 - err = iScreenDevice->CopyScreenToBitmap(bmp1); - ASSERT_EQUALS (err,KErrNone); - iSession.Flush(); - Pause(100); - - if (GCEIsSupported()) - { //place a window with a surface into the screen - ConstructOpaqueSurfacedWindowLC(surfacedTestWindow, - iRed, - 0, - -currentModeInfo.iOrigin, - compositionScreenSize, - surfaceID); //negative origin to ensure it fills screen,not app mode area - - //make surface boring cyan - TRAP(err,iUtility->FillSurfaceL(surfaceID, iCyan)); - ASSERT_EQUALS(err,KErrNone); - iSession.Flush(); - Pause(300); - - //paste bitmap 1 contents into the surface - TRAP(err, iUtility->CopyBitmapToSurfaceL(surfaceID, *bmp1)); - ASSERT_EQUALS(err,KErrNone); - iSession.Flush(); - Pause(300); - } - - //use csc to get a copy of the screen - err = csc->ComposeScreen(*bmp2); - ASSERT_EQUALS (err, KErrNone); - - //should match the original bitmap copy of the screen - ASSERT_TRUE(Compare(*bmp1, *bmp2)); - - if (GCEIsSupported()) - { - iUtility->DestroyAll(); - CleanupStack::PopAndDestroy(&surfacedTestWindow); - } - else - { - surfacedTestWindow.Close(); - } - CleanupStack::PopAndDestroy(bmp2); - CleanupStack::PopAndDestroy(bmp1); - CleanupStack::PopAndDestroy(&testWindow); - iSession.Flush(); - Pause(300); - } - if (!differentSizes) - { - INFO_PRINTF1(_L("Didn't find screen modes of different sizes - test inconclusive")); - } - iScreenDevice->SetAppScreenMode(screenModes[0]); - iScreenDevice->SetScreenMode(screenModes[0]); - screenModes.Close(); - } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tcsc/cwsgcecsc.h --- a/windowing/windowserver/tcsc/cwsgcecsc.h Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,51 +0,0 @@ -/* -* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* @file -* -* -*/ - - - -#ifndef CWSGCECSC_H_ -#define CWSGCECSC_H_ - -#include -#include -#include "cwsgcecscbase.h" - -class CWSGceCsc : public CWsGceCscBase -{ -private: - -public: - CWSGceCsc(); - virtual ~CWSGceCsc(); - static CTestSuite* CreateSuiteL(const TDesC &aName); - virtual void SetupL(); - virtual void TearDownL(); - void GRAPHICS_WSERV_CSC_101L(); - void GRAPHICS_WSERV_CSC_102L(); - void GRAPHICS_WSERV_CSC_103L(); - void GRAPHICS_WSERV_CSC_104L(); - void GRAPHICS_WSERV_CSC_105L(); -private: - void DrawBasicPattern (RWindow& aWin); -public: - -private: -}; - -#endif /*CWSGCECSC_H_*/ diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tcsc/cwsgcecscbase.cpp --- a/windowing/windowserver/tcsc/cwsgcecscbase.cpp Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,400 +0,0 @@ -// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// @file -// -// - -#include -#include -#include -#include -#include -#include "teflogextensions.h" -#include "globalsettings.h" -#include "CWsGceCscBase.h" -#include -#include -#include -#include - - -CWsGceCscBase::CWsGceCscBase(): -iDoTearDown(EFalse), -iUtility(this, NULL) -{ -} - -CWsGceCscBase::~CWsGceCscBase() -{ -if (iDoTearDown) - TearDownFromDeleteL(); //This mechanism is not entirely clean to use. -} - -void CWsGceCscBase::SetupL() -{ -iDoTearDown=ETrue; -iRed.SetInternal(0xFFFF0000); -iGreen.SetInternal(0xFF00FF00); -iBlue.SetInternal(0xFF0000FF); -iCyan.SetInternal(0xFF00FFFF); -iMagenta.SetInternal(0xFFFF00FF); -iYellow.SetInternal(0xFFFFFF00); -iWhite.SetInternal(0xFFFFFFFF); - -ASSERT_EQUALS_X(iSession.Connect(), KErrNone); - - {//Stolen from TAuto CloseAllPanicWindows() - TInt idFocus = iSession.GetFocusWindowGroup(); - TWsEvent event; - event.SetType(EEventKey); //EEventKeyDown - TKeyEvent *keyEvent = event.Key(); - keyEvent->iCode = EKeyEscape; - keyEvent->iScanCode = EStdKeyEscape; - keyEvent->iModifiers = 0; - TInt theLimit = 50; - while(idFocus != NULL && (theLimit-- > 0)) - { - iSession.SendEventToAllWindowGroups(event); - TInt idNewFocus = iSession.GetFocusWindowGroup(); - if (idNewFocus!=idFocus) - { - INFO_PRINTF1(_L("A window was closed [probably a panic box from the previous test].")); - } - idFocus=idNewFocus; - } - } -TInt err = KErrNone; - -TRAP(err, iScreenDevice = new (ELeave) CWsScreenDevice(iSession)); -PRINT_ON_ERROR2_L(err, _L("Failed to create screen device: %d"), err); -ASSERT_EQUALS_X(iScreenDevice->Construct(TGlobalSettings::Instance().iScreen), KErrNone); -iDisplayMode = iScreenDevice->DisplayMode(); // Get default display mode - -TRAP(err, iGc = new (ELeave) CWindowGc(iScreenDevice)); -PRINT_ON_ERROR2_L(err, _L("Failed to create graphics context: %d"), err); -ASSERT_EQUALS_X(iGc->Construct(), KErrNone); - -iGroup = RWindowGroup(iSession); -ASSERT_EQUALS_X(iGroup.Construct(++iWindowHandle,iScreenDevice), KErrNone); -iSession.Flush(); - -RWindow testTrans(iSession); -ASSERT_EQUALS_X(testTrans.Construct(iGroup, ++iWindowHandle), KErrNone); -iTransparencyEnabled=(testTrans.SetTransparencyFactor(iWhite)==KErrNone); -testTrans.Close(); - -//clean-up if previous test abended - if (PostTestCleanupInstance().iSharedUtility) - { -//Temp removed - may be causing ONB fails! -// if (PostTestCleanupInstance().iSharedUtility->DestroyAll()) -// { -// INFO_PRINTF1(_L("Destroyed some surfaces from previous test.")); -// -// } - } - if (!PostTestCleanupInstance().iCleanedUpOnExit) - PostTestCleanupInstance().iCleanedUpOnExit=EFalse; - - if (!GCEIsSupported()) - { - INFO_PRINTF1(_L("Some Setup skipped: GCE support is not loaded")); - return; - } - - TRAPD(err_FailedToCreateSurfaceUtility, iUtility = CSurfaceUtility::NewL( PostTestCleanupInstance().iSharedUtility)); - ASSERT_EQUALS(err_FailedToCreateSurfaceUtility,KErrNone); - -} - -void CWsGceCscBase::TearDownL() -{ -iDoTearDown=EFalse; -delete iGc; -delete iScreenDevice; - -iGroup.Close(); -iSession.Flush(); -iSession.Close(); - -delete iUtility(); -PostTestCleanupInstance().iCleanedUpOnExit=ETrue; -Pause(1000); -} - -void CWsGceCscBase::TearDownFromDeleteL() -{ -CWsGceCscBase::TearDownL(); -} - -void CWsGceCscBase::Pause(TInt aMilliseconds) -{ -User::After(TTimeIntervalMicroSeconds32(aMilliseconds * 1000)); -} - -/** Test using an indipendent method that GCE version of WServ is running - * This method can only be called after the testcase is started - * - * @return true if WServ version is GCE technology, false if legacy technology - **/ -TBool CWsGceCscBase::GCEIsSupported() const - { - CFbsDrawDevice* screenDevice=NULL; - TDisplayMode displayMode=iScreenDevice->DisplayMode(); - TRAPD(err, screenDevice = CFbsDrawDevice::NewScreenDeviceL(TGlobalSettings::Instance().iScreen, displayMode)); - TBool rv=EFalse; - if(err == KErrNone) - { - TAny* p=NULL; - rv=(screenDevice->GetInterface(KSurfaceInterfaceID, p)==KErrNone); - delete screenDevice; - } - return rv; - } -/** Test using an indipendent method that GCE version of WServ is running - * This method can be called at any time, even by external code, but creates temporary window session objects - * - * @return true if WServ version is GCE technology, false if legacy technology - **/ -TBool CWsGceCscBase::GCEIsSupportedStatic() - { - CFbsDrawDevice* screenDevice=NULL; - RWsSession session; - if (session.Connect()!=KErrNone) - { - return EFalse; - } - CWsScreenDevice screen(session); - if (screen.Construct(TGlobalSettings::Instance().iScreen)!=KErrNone) - { - return EFalse; - } - - TDisplayMode displayMode=screen.DisplayMode(); - TRAPD(err, screenDevice = CFbsDrawDevice::NewScreenDeviceL(TGlobalSettings::Instance().iScreen, displayMode)); - TBool rv=EFalse; - if(err == KErrNone) - { - TAny* p=NULL; - rv=(screenDevice->GetInterface(KSurfaceInterfaceID, p)==KErrNone); - delete screenDevice; - } - return rv; - } - -//Allocating an instance of surface utility here means all test code instances will share the same instance of the utility class. -// Owns the singleton -CWsGceCscBase::TPostTestCleanup& CWsGceCscBase::PostTestCleanupInstance() - { - static - class RPostTestCleanup:public TPostTestCleanup - { - public: - RPostTestCleanup() - { - iSharedUtility=NULL; - iCleanedUpOnExit=ETrue; - } - ~RPostTestCleanup() - { - // I want to cleanly release the surface utility, but at this point the threads have already been pulled down! - // if (iSharedUtility) - // delete iSharedUtility; - iSharedUtility=NULL; //avoid phoenix behaviour - } - } staticInstance; - return staticInstance; - } - -// This handles any non-member uses of the extended ASSERT_XXX macros -extern void TefUnitFailLeaveL(); -/** - * side-effect: log the state info just before I leave! - * Note that this only logs intentional assertion failures. - * Fails due to panics or throws won't log this info. - **/ -void CWsGceCscBase::TefUnitFailLeaveL() - { - for (TInt line=0;lineaHostBuffer.MaxLength()) - { - return reqSize/aObjectSize; - } - if (reqSize==0) - { - reqSize=aHostBuffer.MaxLength(); - } - if ((reqSize%aObjectSize)!=0) - { - return KErrCorrupt; - } - aReturnedObject=(const void*)aHostBuffer.Ptr(); - reqSize/=aObjectSize; - return reqSize; - } - -void CWsGceCscBase::SetCompositionMode(RWindow& aWindow, TDisplayMode aMode) - { - iDisplayMode = (TDisplayMode)aWindow.SetRequiredDisplayMode(aMode); - aWindow.Invalidate(); - aWindow.BeginRedraw(); - aWindow.EndRedraw(); - } - -TBool CWsGceCscBase::Compare(CFbsBitmap& aBitmap1, CFbsBitmap& aBitmap2) - { - if ((aBitmap1.SizeInPixels() == aBitmap2.SizeInPixels()) && - (aBitmap1.DisplayMode() == aBitmap2.DisplayMode())) - { - TSize size = aBitmap1.SizeInPixels(); - TInt width = size.iWidth; - TInt height = size.iHeight; - TRgb color1, color2; - - for (TInt i = 0; i < width; i++) - { - for (TInt j = 0; j < height; j++) - { - aBitmap1.GetPixel(color1, TPoint(i, j)); - aBitmap2.GetPixel(color2, TPoint(i, j)); - if (color1 != color2) - { - return EFalse; - } - } - } - - return ETrue; - } - return EFalse; - } - -void CWsGceCscBase::ConstructOpaqueWindowL(RWindow& aWindow, - const TRgb& aColor, - TInt aPos, - const TPoint &aPoint, - const TSize &aSize) - { - ASSERT_EQUALS_X(aWindow.Construct(iGroup, ++iWindowHandle), KErrNone); - aWindow.SetRequiredDisplayMode(iDisplayMode); - aWindow.SetExtent(aPoint, aSize); - aWindow.SetBackgroundColor(aColor); - aWindow.SetOrdinalPosition(aPos); - aWindow.Activate(); - aWindow.BeginRedraw(); - iGc->Activate(aWindow); - iGc->Deactivate(); - aWindow.EndRedraw(); - } - -void CWsGceCscBase::ConstructOpaqueWindowLC(RWindow& aWindow, - const TRgb& aColor, - TInt aPos, - const TPoint &aPoint, - const TSize &aSize) - { - ASSERT_EQUALS_X(aWindow.Construct(iGroup, ++iWindowHandle), KErrNone); - CleanupClosePushL(aWindow); - aWindow.SetRequiredDisplayMode(iDisplayMode); - aWindow.SetExtent(aPoint, aSize); - aWindow.SetBackgroundColor(aColor); - aWindow.SetOrdinalPosition(aPos); - aWindow.SetVisible(ETrue); - aWindow.Activate(); - aWindow.BeginRedraw(); - iGc->Activate(aWindow); - iGc->Clear(); - iGc->Deactivate(); - aWindow.EndRedraw(); - } - - -void CWsGceCscBase::SetBackgroundColorWindow(RWindow& aWindow, const TRgb& aColor) - { - aWindow.Invalidate(); - aWindow.SetBackgroundColor(aColor); - aWindow.BeginRedraw(); - iGc->Activate(aWindow); - iGc->Deactivate(); - aWindow.EndRedraw(); - } - -void CWsGceCscBase::ConstructOpaqueSurfacedWindowLC(RWindow& aWindow, - const TRgb& aColor, - TInt aPos, - const TPoint &aPoint, - const TSize &aSize, - TSurfaceId& aSurfaceID) - { - ASSERT_EQUALS_X(aWindow.Construct(iGroup, ++iWindowHandle), KErrNone); - CleanupClosePushL(aWindow); - aWindow.SetRequiredDisplayMode(iDisplayMode); - aWindow.SetExtent(aPoint, aSize); - aWindow.SetBackgroundColor(aColor); - aWindow.SetOrdinalPosition(aPos); - ASSERT_EQUALS_X(aWindow.SetBackgroundSurface(aSurfaceID), KErrNone); - aWindow.Activate(); - aWindow.BeginRedraw(); - iGc->Activate(aWindow); - iGc->Deactivate(); - aWindow.EndRedraw(); - } - -void CWsGceCscBase::ConstructOpaqueSurfacedWindowL(RWindow& aWindow, - const TRgb& aColor, - TInt aPos, - const TPoint& aPoint, - const TSize& aSize, - const TSurfaceId& aSurfaceID) - { - ASSERT_EQUALS_X(aWindow.Construct(iGroup, ++iWindowHandle), KErrNone); - aWindow.SetRequiredDisplayMode(iDisplayMode); - aWindow.SetExtent(aPoint, aSize); - aWindow.SetBackgroundColor(aColor); - aWindow.SetOrdinalPosition(aPos); - ASSERT_EQUALS_X(aWindow.SetBackgroundSurface(aSurfaceID), KErrNone); - aWindow.Activate(); - aWindow.BeginRedraw(); - iGc->Activate(aWindow); - iGc->Deactivate(); - aWindow.EndRedraw(); - } - - diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tcsc/cwsgcecscbase.h --- a/windowing/windowserver/tcsc/cwsgcecscbase.h Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,181 +0,0 @@ -// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -#ifndef TCWGCECSCBASE_H_ -#define TCWGCECSCBASE_H_ - -#include -#include -#include "surfaceutility.h" -#include - -class TPerfProperties -{ -public: - TBool GetValue(TUint aKey); - void PrintAllL(CTestFixture& aLogger); - TBool ResetValue(TUint aKey); - void UpdateAll(); - void ResetAll(); -private: -#ifdef GCE_BACKEND_PROFILING - TInt iValue[EPerfLastKey]; - TInt iPrevValue[EPerfLastKey]; - const static TBuf<100> propertyKeysTxt[EPerfLastKey]; -#endif -}; - -class CWsGceCscBase: public CTestFixture -{ - -public: - template - class SafePointer - { - public: - SafePointer(LoggerOwner* aOwner,Referee* aReferee=NULL): - iOwner(aOwner), iReferee(aReferee) - {} - Referee* operator=(Referee* aReferee) - { - return iReferee=aReferee; - } - Referee*& operator()() - { - return iReferee; - } - Referee* operator->() - { - if (iReferee==NULL) - { - iOwner -> INFO_PRINTF1(_L("Tried to dereference a pointer that is null!")); - User::Panic(_L("null pointer"),__LINE__); - } - return iReferee; - } - private: - LoggerOwner* iOwner; - Referee* iReferee; - }; - -public: - CWsGceCscBase(); - virtual ~CWsGceCscBase(); - virtual void SetupL(); - virtual void TearDownL(); - virtual void TearDownFromDeleteL(); - -protected: - typedef TBuf TTestName; - - class TPostTestCleanup - { - protected: - TPostTestCleanup() {} - public: - CSurfaceUtility* iSharedUtility; - TBool iCleanedUpOnExit; - }; - - - typedef enum TOptimizationLevel - { - EDisable, - EDetectFrontmostFullScreenOpaqueLayer, - EMaximum, - } TOptimizationLevel; - - -protected: - void SetCompositionMode(RWindow& aWindow, TDisplayMode aMode); - - TBool Compare(CFbsBitmap& aBitmap1, CFbsBitmap& aBitmap2); - - void ConstructOpaqueWindowLC(RWindow& aWindow, - const TRgb& aColor, - TInt aPos, - const TPoint& aPoint, - const TSize& aSize); - - void ConstructOpaqueWindowL(RWindow& aWindow, - const TRgb& aColor, - TInt aPos, - const TPoint& aPoint, - const TSize& aSize); - - void SetBackgroundColorWindow(RWindow& aWindow, const TRgb& aColor); - - void ConstructOpaqueSurfacedWindowLC(RWindow& aWindow, - const TRgb& aColor, - TInt aPos, - const TPoint& aPoint, - const TSize& aSize, - TSurfaceId& aSurfaceID); - void ConstructOpaqueSurfacedWindowL(RWindow& aWindow, - const TRgb& aColor, - TInt aPos, - const TPoint& aPoint, - const TSize& aSize, - const TSurfaceId& aSurfaceID); - -protected: - inline TInt ObjIndScr(TInt aScreen,TInt aWin=0,TInt aLayer=0,TInt aExtra=0); - template // DataType may be TSurfaceId, TInt,TRect, TSurfaceConfiguration (not TRegion) - TInt DebugInfo(TWsDebugInfoFunc aFunction, TInt aObjectIndex, TDes8& aHostBuffer,const DataType*&aReturnedObject)const - { - return DebugInfo(aFunction,aObjectIndex,aHostBuffer,(const void*&)aReturnedObject,sizeof(DataType)); - } - TInt DebugInfo(TWsDebugInfoFunc aFunction, - TInt aParam, - TDes8& aHostBuffer, - const void*&aReturnedObject, - TInt aObjectSize)const; - void TefUnitFailLeaveL(); - static void Pause(TInt aMilliseconds=200); - TBool GCEIsSupported() const; - static TBool GCEIsSupportedStatic(); - static TPostTestCleanup& PostTestCleanupInstance(); - -protected: - TBool iDoTearDown; - RWsSession iSession; - RWindowGroup iGroup; - CWsScreenDevice* iScreenDevice; - CWindowGc* iGc; - TInt iWindowHandle; - TBool iTransparencyEnabled; - TRgb iRed, iGreen, iBlue, iCyan, iMagenta, iYellow, iWhite; - TDisplayMode iDisplayMode; - SafePointer iUtility; - static const TInt KMaxInfoLines=5; - TTestName iTestInfo[KMaxInfoLines]; - TTestName iTestName; - static const TUidPixelFormat KSurfaceFormat = EUidPixelFormatXRGB_8888; - static const TInt KBytesPerPixel = 4; // Four bytes per pixel for the format above. - TPerfProperties iProperties; -}; - -inline TInt CWsGceCscBase::ObjIndScr(TInt aScreen, - TInt aWin, - TInt aLayer, - TInt aExtra) - { - return (aScreen< -#include "cwsgcecsc.h" - -_LIT( KServerName, "wsgcecscserver" ); - -GLDEF_C const TTestName ServerName() -/** - * ServerName - * - * @return - The TEF server name - */ - { - TTestName serverName(KServerName); - return serverName; - } - - -GLDEF_C CTestSuite* CreateTestSuiteL() -/** - * Create the overall test suite. - * - * @return - The top level suite - */ - { - START_SUITE; - ADD_TEST_SUITE(CWSGceCsc); - END_SUITE; - } - - -GLDEF_C CTestStep* CreateTEFTestStep(const TDesC& /*aStepName*/, CTEFUnitServer& /* aServer */) -/** - * Create individual test steps, outside the suite. - */ - { - // Initialise test step object to NULL if no TEF step is found - CTestStep* testStep = NULL; - - - - return testStep; - } - diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tcsc/tcsc.iby --- a/windowing/windowserver/tcsc/tcsc.iby Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,28 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ -rem Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). - -#if (!defined __TCSC_IBY__) -#define __TCSC_IBY__ - -#include - -// Display channel test server and test script -file=ABI_DIR\DEBUG_DIR\wsgcecscserver.exe \sys\bin\wsgcecscserver.exe -data=EPOCROOT##epoc32\data\z\wstest\wscsc.script \wstest\wscsc.script - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tcsc/wscsc.script --- a/windowing/windowserver/tcsc/wscsc.script Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,31 +0,0 @@ -// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// WsGcePerformance.script -// - -LOAD_SUITE wsgcecscserver - -// Run the tests as specified by the wrapping script -// RUN_TEST_STEP 100 wsgcecscserver TEFUnit.CGlobalSettings.Report - -//////////////// -// CSC NGA tests -//////////////// -RUN_TEST_STEP 500 wsgcecscserver TEFUnit.CWSGceCsc.GRAPHICS_WSERV_CSC_101L -RUN_TEST_STEP 500 wsgcecscserver TEFUnit.CWSGceCsc.GRAPHICS_WSERV_CSC_102L -RUN_TEST_STEP 500 wsgcecscserver TEFUnit.CWSGceCsc.GRAPHICS_WSERV_CSC_103L -// Negative test cases -RUN_TEST_STEP 500 wsgcecscserver TEFUnit.CWSGceCsc.GRAPHICS_WSERV_CSC_104L -// Defect test cases -RUN_TEST_STEP 500 wsgcecscserver TEFUnit.CWSGceCsc.GRAPHICS_WSERV_CSC_105L diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tcsc/wscscclassic.script --- a/windowing/windowserver/tcsc/wscscclassic.script Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,27 +0,0 @@ -// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// WsGcePerformance.script -// - -LOAD_SUITE wsgcecscserver - -// Run the tests as specified by the wrapping script -// RUN_TEST_STEP 100 wsgcecscserver TEFUnit.CGlobalSettings.Report - -//////////////// -// CSC related tests -//////////////// -RUN_TEST_STEP 500 wsgcecscserver TEFUnit.CWSGceCsc.GRAPHICS_WSERV_CSC_101L -RUN_TEST_STEP 500 wsgcecscserver TEFUnit.CWSGceCsc.GRAPHICS_WSERV_CSC_103L -RUN_TEST_STEP 500 wsgcecscserver TEFUnit.CWSGceCsc.GRAPHICS_WSERV_CSC_105L diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tdynamicres/group/bld.inf --- a/windowing/windowserver/tdynamicres/group/bld.inf Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,41 +0,0 @@ -// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// @file -// @test -// @internalComponent -// -// - - -PRJ_TESTMMPFILES -#ifndef SMP -#ifdef SYMBIAN_BUILD_GCE -tdynamicres.mmp -#endif // SYMBIAN_BUILD_GCE -tdynamicresclassic.mmp -#endif // SMP -PRJ_TESTEXPORTS - -#ifdef SYMBIAN_BUILD_GCE -../scripts/wsdynamicresbasic_no_scaling.script z:/wstest/dynamicres/wsdynamicresbasic_no_scaling.script -../scripts/wsdynamicresbasic_integer_scaling.script z:/wstest/dynamicres/wsdynamicresbasic_integer_scaling.script -../scripts/wsdynamicresbasic_isotropic_scaling.script z:/wstest/dynamicres/wsdynamicresbasic_isotropic_scaling.script -../scripts/wsdynamicresbasic_anisotropic_scaling.script z:/wstest/dynamicres/wsdynamicresbasic_anisotropic_scaling.script -../scripts/wsdynamicresbasic_openvg_isotropic.script z:/wstest/dynamicres/wsdynamicresbasic_openvg_isotropic.script -#endif // SYMBIAN_BUILD_GCE -wstestdynamicres.iby /epoc32/rom/include/wstestdynamicres.iby -../scripts/wsdynamicresclassic.script z:/wstest/dynamicres/wsdynamicresclassic.script - - - diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tdynamicres/group/tdynamicres.mmp --- a/windowing/windowserver/tdynamicres/group/tdynamicres.mmp Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,67 +0,0 @@ -// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file -*/ - -TARGET wsdynamicrestestserver.exe -TARGETTYPE exe -UID 0x1000007A 0x102864B7 - -// For setting the screen mode and registering GUID CRPs -CAPABILITY PowerMgmt WriteDeviceData SwEvent ProtServ -SOURCEPATH ../src - -SOURCE globalsettings.cpp -SOURCE screenselect.cpp -SOURCE surfaceutility.cpp -SOURCE wsgcedebugsession.cpp - -SOURCE t_wsdynamicrestestserver.cpp -SOURCE t_wsdynamicreswinbase.cpp - -SOURCE wsdynamicresbase.cpp -SOURCE wsdynamicresbasic.cpp - -USERINCLUDE ../inc -USERINCLUDE ../../SERVER ../../nga/SERVER ../../SERVER/restricted ../../inc - -MW_LAYER_SYSTEMINCLUDE_SYMBIAN -OS_LAYER_SYSTEMINCLUDE_SYMBIAN -OS_LAYER_LIBC_SYSTEMINCLUDE - -MACRO SYMBIAN_GRAPHICS_GCE - -STATICLIBRARY tefunit.lib -LIBRARY euser.lib -LIBRARY estlib.lib -LIBRARY testexecuteutils.lib -LIBRARY testexecutelogclient.lib -LIBRARY rfileloggerclient.lib -LIBRARY ws32.lib -LIBRARY surfacemanager.lib -LIBRARY surfaceupdateclient.lib -LIBRARY imageconversion.lib -LIBRARY efsrv.lib -LIBRARY fbscli.lib -LIBRARY gdi.lib -LIBRARY bitgdi.lib -LIBRARY hal.lib -LIBRARY scdv.lib -//LIBRARY samplegraphicsurface.lib w32stdgraphic.lib samplegraphictestsurfacemulti.lib - - -SMPSAFE diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tdynamicres/group/tdynamicresclassic.mmp --- a/windowing/windowserver/tdynamicres/group/tdynamicresclassic.mmp Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file -*/ - -TARGET wsdynamicresclassictestserver.exe -TARGETTYPE exe -UID 0x1000007A 0x102864B8 - -// For setting the screen mode and registering GUID CRPs -CAPABILITY PowerMgmt WriteDeviceData SwEvent ProtServ -SOURCEPATH ../src -SOURCE t_wsdynamicresclassictestserver.cpp -SOURCE wsdynamicresclassic.cpp - -USERINCLUDE ../inc - -MW_LAYER_SYSTEMINCLUDE_SYMBIAN -OS_LAYER_SYSTEMINCLUDE_SYMBIAN -OS_LAYER_LIBC_SYSTEMINCLUDE - - -STATICLIBRARY tefunit.lib -LIBRARY euser.lib -LIBRARY estlib.lib -LIBRARY testexecuteutils.lib -LIBRARY testexecutelogclient.lib -LIBRARY rfileloggerclient.lib -LIBRARY ws32.lib - -SMPSAFE diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tdynamicres/group/wstestdynamicres.iby --- a/windowing/windowserver/tdynamicres/group/wstestdynamicres.iby Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,44 +0,0 @@ -// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// WSLog.iby -// -// - -#ifndef __WSTESTDYNAMICRES_IBY__ -#define __WSTESTDYNAMICRES_IBY__ - -REM Window Server Dynamic Resolution Test Scripts [no plugins] - -//All these test scripts are copied to the rom. -//Please execute only the tests appropriate to your hardware capabilities. - -//The following test script asserts that the simplest tests to open the new interfaces will fail. -//The Symbian reference H4 does not implement MDisplayControl, but some vendors may create their own support. -file=ABI_DIR\DEBUG_DIR\wsdynamicresclassictestserver.exe System\Libs\wsdynamicresclassictestserver.exe -data=DATAZ_\wstest\dynamicres\wsdynamicresclassic.script wstest\dynamicres\wsdynamicresclassic.script - -//Note the following scripts expect H4 GCE to support MDisplayControl. -//They also optionally benefit from having screen capture installed (dll and wsini.ini) -//The Symbian reference H4 does not implement MDisplayControl, but some vendors may create their own support. -//These represent tests that apply to different scaling modes as specified in wsini.ini -#ifdef SYMBIAN_GRAPHICS_USE_GCE -file=ABI_DIR\DEBUG_DIR\wsdynamicrestestserver.exe System\Libs\wsdynamicrestestserver.exe -data=DATAZ_\wstest\dynamicres\wsdynamicresbasic_anisotropic_scaling.script wstest\dynamicres\wsdynamicresbasic_anisotropic_scaling.script -data=DATAZ_\wstest\dynamicres\wsdynamicresbasic_integer_scaling.script wstest\dynamicres\wsdynamicresbasic_integer_scaling.script -data=DATAZ_\wstest\dynamicres\wsdynamicresbasic_isotropic_scaling.script wstest\dynamicres\wsdynamicresbasic_isotropic_scaling.script -data=DATAZ_\wstest\dynamicres\wsdynamicresbasic_no_scaling.script wstest\dynamicres\wsdynamicresbasic_no_scaling.script -data=DATAZ_\wstest\dynamicres\wsdynamicresbasic_openvg_isotropic.script wstest\dynamicres\wsdynamicresbasic_openvg_isotropic.script -#endif - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tdynamicres/inc/globalsettings.h --- a/windowing/windowserver/tdynamicres/inc/globalsettings.h Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,52 +0,0 @@ -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Test class that allows a script to set global values -// -// - -#ifndef __GLOBALSETTINGS_H__ -#define __GLOBALSETTINGS_H__ - -#include -#include -#include -class CTestExecuteLogger; - -class TGlobalSettings - { -public: - static const TGlobalSettings& Instance(); - -public: - TInt iScreen; - TBool iDisconnected; //This value might be changed from CWsDynamicResWinBase::SetupL - }; //once the screen has been connected. - -class CGlobalSettings : public CTestFixture - { -public: - static const TGlobalSettings& Instance(); - - // SetUp and TearDown code - - // Create a suite of all the tests - static CTestSuite* CreateSuiteL(const TDesC& aName); - - //these tests are public to allow the old CScreenSelect to get to them! - void SetScreenNoL(TInt aScreenNo); - void ExpectDisconnectedScreenL(TBool aValue); - }; - - -#endif //__GLOBALSETTINGS_H__ diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tdynamicres/inc/screenselect.h --- a/windowing/windowserver/tdynamicres/inc/screenselect.h Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,52 +0,0 @@ -/* -* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* @file -* -* -*/ - - - -#ifndef __SCREEN_SELECT__ -#define __SCREEN_SELECT__ - -#include - -/** -Test step to set a static screen number selection, which can be used to run the -same test code on an alternate screen by simply adding this step and repeating -the test. - -Test steps which support this must use the static CSelectScreen::Number() -function to get the currently selected screen number, and pass this to the -Construct() call for a CWsScreenDevice. -*/ - -class CScreenSelect : public CTestStep - { -public: - CScreenSelect(TInt aScreenNumber, const TDesC& aStepName); - ~CScreenSelect(); - - static TInt Number(); - - virtual TVerdict doTestStepL(); - -private: - TInt iScreenNumber; - }; - -#endif // __SCREEN_SELECT__ - diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tdynamicres/inc/surfaceutility.h --- a/windowing/windowserver/tdynamicres/inc/surfaceutility.h Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,108 +0,0 @@ -/** -* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - -/** - @file -*/ - -#ifndef __SURFACE_UTILITY__ -#define __SURFACE_UTILITY__ - -#include -#include -#include -#include - -#define ENABLE_TEST_LOGGING -#define ALPHA_FIX_24BIT 0xffU //This forces a non-zero value into the X byte of 16MU color values - -#if defined(ENABLE_TEST_LOGGING) -#define LOG(X) RDebug::Printf X -#else -#define LOG(X) -#endif - -class TRgb; -class CFbsBitmap; - -class CSurfaceUtility : public CBase - { -public: - static CSurfaceUtility* NewL(CSurfaceUtility* aClone=NULL); - virtual ~CSurfaceUtility(); - TSize SurfaceSize(const TSurfaceId& aSurface); - void CreateSurfaceFromFileL(const TDesC& aFileName, TSurfaceId& aSurface); - TSurfaceId CreateSurfaceL(const TSize& aSize, TUidPixelFormat aPixelFormat, TInt aStride, TInt aBuffers = 1); - TInt BytesPerPixelL(TUidPixelFormat aPixelFormat); - void FillSurfaceL(TSurfaceId& aSurface, const TRgb& aColor); - void FillChunkL(TSurfaceId& aSurface, RChunk& aChunk, const TRgb& aColor, TInt aBufferNumber); - void FillRectangleL(TSurfaceId& aSurface, const TPoint& aStartPos, const TSize& aSize, const TRgb& aColor); - void FillRectangleNoUpdateL(TSurfaceId& aSurface, const TPoint& aStartPos, const TSize& aSize, const TRgb& aColor); - void GridFillSurfaceL(TSurfaceId& aSurface, const TRgb& aColor, const TRgb& aLines); - void PatternFillSurfaceL(TSurfaceId& aSurface); - void FanFillSurfaceL(TSurfaceId& aSurface, const TRgb& aColor, const TRgb& aLinesTL,const TRgb& aLinesBR); - void LineFillSurfaceL(TSurfaceId& aSurface, const TRgb& aBackColor, const TRgb& aLineColor, TInt aPosition); - CFbsBitmap* EquivalentBitmapL(TSurfaceId& aSurface, CFbsBitmap* aCopyTo=NULL); - void DestroySurface(TSurfaceId& aSurface); - TBool DestroyAll(); - void SubmitUpdate(TInt aScreenNumber, const TSurfaceId& aSurface, const TRegion* aRegion, TInt aBufferNumber = 0); - void MapAndSubmitUpdateL(RChunk& aChunk, TInt aScreenNumber, const TSurfaceId& aSurface, const TRegion* aRegion); - void MapSurfaceL(const TSurfaceId& aSurface, RChunk& aChunk); - void CopyBitmapFromFileToSurfaceL(const TDesC& aFileName, TSurfaceId& aSurface); - void CopyBitmapSurfaceL(const CFbsBitmap* aBitmap, TSurfaceId& aSurface); - void CopyBitmapToSurfaceL(TSurfaceId& aSurface, const CFbsBitmap& aBitmap); -private: - CSurfaceUtility(CSurfaceUtility* aClone); - void ConstructL(); - -private: - RSurfaceManager iManager; - RSurfaceUpdateSession iSurfaceUpdateSession; - //This local object wraps the array operations in a heap switch - //The reason for providing this wrapper is to allow threads to share the surface manager surface ID list. - //In particular, the next test can attempt to release the previous test's surfaces if it paniced. - //Note that the presumption is that the owning thread will be paused, - //so there will be no thread interlock issues with it's heap manager. - class RHeapSurfaceArray - { - public: - typedef RArray Array; - RHeapSurfaceArray(RHeapSurfaceArray* aUseExternalArray=NULL); - - //Emulation of RArray entrypoints. Add more stub methods if required... - TSurfaceId& operator[](TUint aIndex); - void Close(); - TInt Count() const; - inline void Reset(); - void AppendL(const TSurfaceId &anEntry); - TInt Find(const TSurfaceId &anEntry) const; - void Remove(TInt anIndex); - - private: - static void PopHeap(void* mainheap); - static void SwitchHeapLC(RHeap* aNewHeap); - - Array iLocalArray; - Array* iUseArray; - RHeap &iExternalHeapRef; - } iSurfaces; - }; - -#endif // __SURFACE_UTILITY__ - diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tdynamicres/inc/t_wsdynamicreswinbase.h --- a/windowing/windowserver/tdynamicres/inc/t_wsdynamicreswinbase.h Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,169 +0,0 @@ -// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// twsgcetestwinbase.h -// -// - -#ifndef TWSDYNAMICRESWINBASE_H_ -#define TWSDYNAMICRESWINBASE_H_ - -#include -#include -#include -#include -#include "wsgcedebugsession.h" -struct TWsDebugWindowId; - -/** - * Base class sets up the tryptich of test windows. - * - * - **/ -class CWsDynamicResWinBase : public CTestFixture -{ -public: - CWsDynamicResWinBase(); - virtual ~CWsDynamicResWinBase(); - virtual void SetupL(); - virtual void SetupL(TBool aUseOtherScreenForInfo); - - virtual void TearDownL(); - virtual void TearDownFromDeleteL(); - - static TBool ActivateWithWipe(CWindowGc* aGc,RWindow& aWin,TRgb aColor=TRgb(0,0)); - - /* Note that each derived test class needs to declare a static function to register tests. - * This should match the following prototype: - static CTestSuite* CreateSuiteL( const TDesC& aName ); - */ - -protected: - static void Pause(TInt aMilliseconds=200); - - TBool GCEIsSupported() const; - static TBool GCEIsSupportedStatic(); - - TBool DisplayHasAlpha() const; - TBool SelectChromaCompositionMode(); - TBool SelectAlphaCompositionMode(TDisplayMode aMode = EColor16MA); - TRgb GceHoleColor(RWindowBase& aWin)const; - void DrawUIContent(RWindow& aWindow); - void DrawPlainUI(RWindow& aWindow,TBool aInvalidate,TRgb aWipeColor=TRgb(0,0)); - void DrawCross(RWindow& aWindow, TRgb aColor, TInt aThickness=1); - void TestPixelL(TPoint aPt, TRgb aColor, TBool aMatch); - TBool TestRectL(TRect aRect,TRgb aInnerColor,TInt aOtherInnerColors,TRgb aOuterColor,TInt aOtherOuterColors,TInt aCornerSize); - void MakeTitleAndCompareWindowsL(TRefByValue aTitle,TRefByValue aDetail=_L("")); - void LargerCompareWindow(TBool aGoLarger=ETrue); - void UpdateTitleWindowL(TRefByValue aDetail,TInt aIndex=0); - void RepaintTitleWindowL(); - void TefUnitFailLeaveL(); - CWindowGc* GcForWindow(RWindow& aWin); - TBool InvalidateRegion(const TRegion& aRegion,RWindow& aWin); - CWindowGc* BeginActivateWithWipe(TBool aInvalidate,RWindow& aWin,TRgb aColor=TRgb(0,0)); - CWindowGc* BeginActivateWithWipe(TBool aInvalidate,TRect aRect,RWindow& aWin,TRgb aColor=TRgb(0,0)); - CWindowGc* BeginActivateWithWipe(const TRegion& aRegion,RWindow& aWin,TRgb aColor); - /** Helper method to find a named screen region - * start/end letter should be 'a' to 'y' (yes that includes 'i') - **/ - static TRect PentCellRect(const TRect& aFullRect,char aStartLetter,char aEndLetter=0); - void CheckAndConnectScreen(); - -protected: - static const TInt KSurfaceWidth = 50; - static const TInt KSurfaceHeight = 50; - TBool iDoTearDown; - RWsDebugSession iSession; - RWindowGroup iGroup; - RWindowGroup iInfoGroupInstance; - RWindowGroup* iInfoGroup; - CWsScreenDevice* iScreenDevice; - CWsScreenDevice* iInfoScreenDevice; - CWindowGc* iGc; - CWindowGc* iInfoGc; - TInt iWindowHandle; - static TBool iTransparencyEnabled; - TRgb iRed, iGreen, iBlue, iCyan, iMagenta, iYellow, iWhite; - TRgb TITLE_BACKGROUND; - TRgb COMPARE_BACKGROUND; - RBlankWindow iBackground; - RWindow iCompare; - RWindow iTitle; - TRect iTestPos; - TRect iCenteredFrontWinRect; - TPoint iTestPointCentre; - TDisplayMode iDisplayMode; - static const TInt KMaxTestName = 80; - typedef TBuf TTestName; - mutable TRgb iLastGceHoleColor; - TTestName iTestName; - static const TInt KMaxInfoLines=5; - TTestName iTestInfo[KMaxInfoLines]; - static CActiveScheduler iScheduler; -}; - -// This little helper class checks that the given bytes contain the expected pattern. -namespace Pattern - { - void Fill(void* aTrg,TInt aOffset,TInt aLength); - TBool Check(void* aTrg,TInt aOffset,TInt aLength); - TBool CheckVal(void* aTrg,TInt aOffset,TInt aLength,char val=0); - } - -//This wrapper for the configuration class allows stress testing of the configuration object - -template -class TestExtend: public TXxxConfiguration - { -public: - char iExtraData[aExtraSize]; - TestExtend(): - TXxxConfiguration(aFalseSize) - { - TXxxConfiguration::iSize=aFalseSize; - Pattern::Fill(this,aFalseSize,sizeof(*this)-aFalseSize); - } - void* operator new(unsigned int,TestExtend* inplace) - { //Use this inplace operator new to pre-initialise the memory - return inplace; - } - void operator delete(void*,TestExtend*) - { //Stops the warning! - } - TestExtend(const TXxxConfiguration&i): - TXxxConfiguration(i) - { - Pattern::Check(this,sizeof(TXxxConfiguration),aExtraSize); - } - TBool WasExtraOverwritten() - { - return Pattern::Check(this,sizeof(TXxxConfiguration),aExtraSize); - } - TBool WasFalseSizeOverwritten() - { - return Pattern::Check(this,aFalseSize,sizeof(*this)-aFalseSize); - } - TBool WasFalseSizeZero() - { - return Pattern::CheckVal(this,aFalseSize,sizeof(TXxxConfiguration)-aFalseSize); - } - void StompValue(TInt aOffsetInLongs,TInt aNewValue) - { - *((TInt*)this+aOffsetInLongs)=aNewValue; - } - TInt ReadValue(TInt aOffsetInLongs) - { - return *((TInt*)this+aOffsetInLongs); - } - }; -#endif /*TWSDYNAMICRESWINBASE_H_*/ diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tdynamicres/inc/teflogextensions.h --- a/windowing/windowserver/tdynamicres/inc/teflogextensions.h Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,110 +0,0 @@ -/* -* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* @file -* -* -*/ - - - -#ifndef __TEF_LOG_EXTENSIONS__ -#define __TEF_LOG_EXTENSIONS__ - -#include - -/* -This file contains extensions to the TEF macros used for logging, defined in -tefunit.h. -*/ - -/* -Wrapper to check for an error, then print it and leave with it if not KErrNone. -do ... while (0) ensures the macro can be treated like a single statement. A -macro is used to get the line number information. -Note that p1 will be evaluated once and only once. -*/ -#define PRINT_ON_ERROR2_L(test, p1, p2) \ - do \ - { \ - TInt result = (test); \ - if (result != KErrNone) \ - { \ - Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, (p1), (p2)); \ - User::Leave(result); \ - } \ - } \ - while (0) - -#define PRINT_ON_ERROR3_L(test, p1, p2, p3) \ - do \ - { \ - TInt result = (test); \ - if (result != KErrNone) \ - { \ - Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, (p1), (p2), (p3)); \ - User::Leave(result); \ - } \ - } \ - while (0) - -/* -Modified version of ASSERT_EQUALS() that will log the expression tested, the -expected result and the actual one. -*/ -#define ASSERT_CONDITION(c) _LIT(KExpression, c); - -#define ASSERT_EQUALS_X(aExpression, aExpected) \ - do \ - { \ - TInt result = (TInt)(aExpression); \ - TInt expected = (TInt)(aExpected); \ - if (result != expected) \ - { \ - ASSERT_CONDITION(#aExpression); \ - Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, _L("%S == %d, not %d"), &KExpression(), result, expected ); \ - User::Leave(KErrTEFUnitFail); \ - } \ - } \ - while (0) - -#define ASSERT_NOT_EQUALS_X(aExpression, aUnexpected) \ - do \ - { \ - TInt result = (TInt)(aExpression); \ - TInt unexpected = (TInt)(aUnexpected); \ - if (result == unexpected) \ - { \ - ASSERT_CONDITION(#aExpression); \ - Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, _L("%S == %d, unexpectedly"), &KExpression(), result ); \ - User::Leave(KErrTEFUnitFail); \ - } \ - } \ - while (0) - -#define ASSERT_TRUE_X(aExpression) \ - do \ - { \ - TBool result = (TBool)(aExpression); \ - if (!result) \ - { \ - ASSERT_CONDITION(#aExpression); \ - Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, _L("%S false"), &KExpression() ); \ - User::Leave(KErrTEFUnitFail); \ - } \ - } \ - while (0) - -#endif // __TEF_LOG_EXTENSIONS__ - diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tdynamicres/inc/wsdynamicresbase.h --- a/windowing/windowserver/tdynamicres/inc/wsdynamicresbase.h Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,164 +0,0 @@ -// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -#ifndef WSDYNAMICRESBASE_H_ -#define WSDYNAMICRESBASE_H_ - -#include "t_wsdynamicreswinbase.h" -#include -#include "surfaceutility.h" - -//************************************ -// -// Asserting wrapper around dereferencing a pointer that might be NULL. -// I don't want to fill the test code with checks that this pointer is not null before calling surface utility methods.... -// -//************************************ - -template -class SafePointer - { -public: - SafePointer(LoggerOwner* aOwner,Referee* aReferee=NULL): - iOwner(aOwner), iReferee(aReferee) - {} - Referee* operator=(Referee* aReferee) - { - return iReferee=aReferee; - } - Referee*& operator()() - { - return iReferee; - } - Referee* operator->() - { - if (iReferee==NULL) - { - iOwner -> INFO_PRINTF1(_L("Tried to dereference a pointer that is null!")); - User::Panic(_L("null pointer"),__LINE__); - } - return iReferee; - } -private: - LoggerOwner* iOwner; - Referee* iReferee; - }; - -/** - * Base class test harness that provides facilities for windowing and surface testing - * - **/ -class CWsDynamicResBase : public CWsDynamicResWinBase -{ -public: - CWsDynamicResBase(); - virtual ~CWsDynamicResBase(); - - virtual void SetupL(); - virtual void SetupL(TBool aUseOtherScreenForInfo); - virtual void TearDownL(); - virtual void TearDownFromDeleteL(); - /* Note that each derived test class needs to declare a static function to register tests. - * This should match the following prototype: - static CTestSuite* CreateSuiteL( const TDesC& aName ); - */ - - protected: - void UISurfaceL(TSurfaceId& aSurfaceId) const; - void CommonSurfaceWindowSetupL(RWindow& aWindow, TSurfaceId& aSurface, const TRgb& aColor); - void CommonOverlayWindowSetupL(RWindow& aWindow, const TRgb& aColor); - void ResizeTestCommonSetupL(RWindow& aWindow, const TRgb& aColor); - - void MakeTestWindowPairL(TRect aOuterRect,TRgb aOuterColor,TRect aInnerRect,TRgb aInnerColor); - void LargerTestWindow(TInt aPercentOfBack=80); - void DestroyTestWindowPair(TBool aKillTestBack=ETrue,TBool aKillTestFront=ETrue,TBool aKillTestChildren=ETrue); - void MakeTestWindowTripleL(TRect aOuterRect,TRgb aOuterColor,TRect aInnerRect,TRgb aInnerColor,TRect aChildRect,TRgb aChildColor,TRect aSecondChildRect,TRgb aSecondChildColor); - void CreateTestWindowQuadL(TRect aOuterRect,TRgb aOuterColor,TRect aInnerRect,TRgb aInnerColor,TRect aChildRect,TRgb aChildColor,TRect aSecondChildRect,TRgb aSecondChildColor); - void MakeTestWindowTripleL(TRect aOuterRect,TRgb aOuterColor,TRect aInnerRect,TRgb aInnerColor,TRect aChildRect,TRgb aChildColor); - void MakeExtraChildWindowL(const RWindowBase& aFromParent,TRect aChildRect,TRgb aChildColor); - struct LoopingGcPtr; - LoopingGcPtr LoopBeginActivateWithWipe(const TRegion& aRegion,RWindow& aWin,TRgb aColor); - CWindowGc* BeginActivateWithWipe(TBool aInvalidate,RWindow& aWin,TRgb aColor=TRgb(0,0)); - CWindowGc* BeginActivateWithWipe(TBool aInvalidate,TRect aRect,RWindow& aWin,TRgb aColor=TRgb(0,0)); - CWindowGc* BeginActivateWithWipe(const TRegion& aRegion,RWindow& aWin,TRgb aColor); - static CFbsBitmap* RotateBitmapLC(const CFbsBitmap* aSrcBitmap); - - void Pause(TInt aMilliseconds); - TInt RegionDiffForUiLayer(TInt aUiLayer); //returns values from TRegionExtend::TOverlapFlags enumeration - enum FastPathMode - { //Tereat this as bit flags or distinct states as you wish. - EFpExternalOpaque=0, - EFpUiOpaque=1, - EFpUiBlended=2, - EFpUiComplex=3, //If ony this is set then both blended and opaque are full=screen - EFpUiRegions=4, //If this FLAG is set then the regions are less than full-screen. Never occurs on its own - EFpUiRegionsOpaque=5, //If this is set then the regions are less than full-screen - EFpUiRegionsBlended=6, //If this is set then the regions are less than full-screen - EFpUiRegionsComplex=7 //This is the expected setting for windowed cr1108 optimisation. - }; - FastPathMode DeduceUiFastPathMode(); -protected: - SafePointer iUtility; - class TPostTestCleanup - { - protected: - TPostTestCleanup() {} - public: - mutable CSurfaceUtility* iSharedUtility; - mutable TBool iCleanedUpOnExit; - void CreateSharedUtilityL()const ; - }; - static const TPostTestCleanup& PostTestCleanupInstance(); - RWindow iTestBack; - RWindow iTestFront; - RWindow iTestChild; - RWindow iTestSecondChild; - static const TUidPixelFormat KSurfaceFormat = EUidPixelFormatXRGB_8888; - static const TInt KBytesPerPixel = 4; // Four bytes per pixel for the format above. -private: - -}; - -struct CWsDynamicResBase::LoopingGcPtr - { - LoopingGcPtr(const TRegion& aRegion,RWindow& aWin,TRgb aColor,CWindowGc *aGc) - : iRegion(aRegion), iWin(aWin), iColor(aColor), iGc(aGc), iPass(-1) - { operator++(); } - LoopingGcPtr(const LoopingGcPtr& aRhs) - : iRegion(aRhs.iRegion), iWin(aRhs.iWin), - iColor(aRhs.iColor), iGc(aRhs.iGc), - iPass(aRhs.iPass) - {} - void operator ++(); - operator bool() { return iPass>=0?iGc:(CWindowGc *)NULL; } - CWindowGc * operator ->() { return iPass>=0?iGc:(CWindowGc *)NULL; } - const TRegion& iRegion; - RWindow& iWin; - TRgb iColor; - CWindowGc *iGc; - TInt iPass; - }; - -#define LOG_AND_PANIC_IF_NOT_GCE \ - { \ - if (!GCEIsSupported()) \ - { \ - INFO_PRINTF1(_L("Test skipped: GCE support is not loaded")); \ - User::Panic(_L("GCE.Wrong.Mode"),1); \ - return; \ - } \ - } - -#endif /*WSDYNAMICRESBASE_H_*/ diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tdynamicres/inc/wsdynamicresbasic.h --- a/windowing/windowserver/tdynamicres/inc/wsdynamicresbasic.h Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,187 +0,0 @@ -// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file -*/ - -#ifndef __WSDYNAMICRESBASIC_H__ -#define __WSDYNAMICRESBASIC_H__ - -#include "wsdynamicresbase.h" -#include -#include -#include -#include -/** - * - **/ - -static TBool cSCLogged =EFalse; - - -class CWsDynamicResBasic : public CWsDynamicResBase -{ - typedef CWsDynamicResBase MyBase; -private: - struct TBitmapRegionPair - { - CFbsBitmap* bitmap; - RRegion* region; - TRect drawRect; - }; - -public: - CWsDynamicResBasic(); - virtual ~CWsDynamicResBasic(); - virtual void SetupL(); - virtual void TearDownL(); - virtual void TearDownFromDeleteL(); - - static CTestSuite* CreateSuiteL( const TDesC& aName ); - - void ResetScreens(); - -protected: -//tests - - //BASIC - void GRAPHICS_WSERV_DYNAMICRES_0001L(); - void GRAPHICS_WSERV_DYNAMICRES_0002L(); - void GRAPHICS_WSERV_DYNAMICRES_0003L(); - void GRAPHICS_WSERV_DYNAMICRES_0004L(); - void GRAPHICS_WSERV_DYNAMICRES_0005L(); - void GRAPHICS_WSERV_DYNAMICRES_0006L(); - void GRAPHICS_WSERV_DYNAMICRES_0007L(); - void GRAPHICS_WSERV_DYNAMICRES_0008L(); - void GRAPHICS_WSERV_DYNAMICRES_0009L(); - void GRAPHICS_WSERV_DYNAMICRES_0010L(); - void GRAPHICS_WSERV_DYNAMICRES_0011L(); - void GRAPHICS_WSERV_DYNAMICRES_0012L(); - void GRAPHICS_WSERV_DYNAMICRES_0013L(); - void GRAPHICS_WSERV_DYNAMICRES_0014L(); - void GRAPHICS_WSERV_DYNAMICRES_0015L(); - void GRAPHICS_WSERV_DYNAMICRES_0016L(); - void GRAPHICS_WSERV_DYNAMICRES_0017L(); - void GRAPHICS_WSERV_DYNAMICRES_0018L(); - - //NEGATIVE - void GRAPHICS_WSERV_DYNAMICRES_0021L(TBool aScaleMode); - - //OOM - void GRAPHICS_WSERV_DYNAMICRES_0031L(); - void GRAPHICS_WSERV_DYNAMICRES_0032L(); - void GRAPHICS_WSERV_DYNAMICRES_0033L(); - void GRAPHICS_WSERV_DYNAMICRES_0034L(); - - //SCREEN CAPTURE - void GRAPHICS_WSERV_DYNAMICRES_0041L(TBool aIsSurface); - void GRAPHICS_WSERV_DYNAMICRES_0042L(TBool aIsSurface); - - //DYNAMIC SCREEN MODE - void GRAPHICS_WSERV_DYNAMICRES_0051L(); - void GRAPHICS_WSERV_DYNAMICRES_0052L(); - void GRAPHICS_WSERV_DYNAMICRES_0053L(); - - //DEFECT - void GRAPHICS_WSERV_DYNAMICRES_0101L(); - void GRAPHICS_WSERV_DYNAMICRES_0102L(); - - - void SetRotation (TDisplayConfiguration& aConfig, const MDisplayControl::TResolution& aResolution); - TBool Compare(const CFbsBitmap& aBitmap, const TRect& aRect1, - const TRect& aRect2, RArray& aRegionArray, TBool aIsSurface); - TRgb GreatestColor(TRgb& aColor) const; - -//data members: -private: - CActiveScheduler iScheduler; -}; - -class CWsDisplayEvent : public CActive - { - -public: - CWsDisplayEvent(RWsSession *aWs); - ~CWsDisplayEvent(); - void Request(); - TInt ConfigSpinner() {return iConfigSpinner;} - TInt ResListSpinner() {return iResListSpinner;} - TInt ReceivedEventCount() {return iReceivedEventCount;} - TInt ReceivedDeviceEventCount() {return iReceivedDeviceEventCount;} - TInt ReceivedPointerEventCount() {return iReceivedPointerEventCount;} - void SetExpectedPointPos(const TPoint& aPos) {iPointerPos = aPos;} - TBool PointerTestPassed() {return iPointerPosTestPass;} -protected: - void DoCancel(); - void RunL(); - -private: - RWsSession *iWs; - TInt iConfigSpinner; - TInt iResListSpinner; - TInt iReceivedEventCount; - TInt iReceivedDeviceEventCount; - TInt iReceivedPointerEventCount; - TPoint iPointerPos; - TBool iPointerPosTestPass; - }; - -class CEventTimer : public CActive - { -public: - static CEventTimer* NewL(); - ~CEventTimer(); - void Wait(TInt aDelay); - // From CActive: - void RunL(); - void DoCancel(); - -protected: - CEventTimer(); - void ConstructL(); - protected: -RTimer iTimer; -}; - - - -class CDSATestDrawing: public CTimer, public MDirectScreenAccess - { -public: - - void Draw(); - - - - static CDSATestDrawing* NewL(); - void ConstructL(); - //from MDirectScreenAccess - void Restart(RDirectScreenAccess::TTerminationReasons aReason); - void AbortNow(RDirectScreenAccess::TTerminationReasons aReason); - ~CDSATestDrawing(); - void SetDSA(CDirectScreenAccess *aDSA){iDSA = aDSA;} - void SetWindow(RWindow &aWindow){iWin = &aWindow;} - void StartDrawingL(CDirectScreenAccess *aDSA); - void RunL(); - -private: - CDSATestDrawing(); - TRect iRect; - RWindow* iWin; - CDirectScreenAccess *iDSA; - }; - -#endif /*__WSDYNAMICRESBASIC_H__*/ diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tdynamicres/inc/wsdynamicresclassic.h --- a/windowing/windowserver/tdynamicres/inc/wsdynamicresclassic.h Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,39 +0,0 @@ -// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Test class that allows a script to set global values -// -// - -#ifndef __WSDYNAMICRESCLASSIC_H__ -#define __WSDYNAMICRESCLASSIC_H__ - -#include -#include -class CTestExecuteLogger; - -class CWsDynamicResClassic : public CTestFixture - { -public: - static const CWsDynamicResClassic& Instance(); - - // Create a suite of all the tests - static CTestSuite* CreateSuiteL(const TDesC& aName); - -private: - // Private tests - void GRAPHICS_WSERV_DYNAMICRES_0100L(); - }; - - -#endif //__WSDYNAMICRESCLASSIC_H__ diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tdynamicres/inc/wsgcedebugsession.h --- a/windowing/windowserver/tdynamicres/inc/wsgcedebugsession.h Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,98 +0,0 @@ -// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -#ifndef WSGCEDEBUGSESSION_H_ -#define WSGCEDEBUGSESSION_H_ - -#include -#include -struct TWsDebugWindowId; - -class RWsDebugSession:public RWsSession - { -public: - RWsDebugSession(TInt aScreenNo = -1); - ~ RWsDebugSession(); - using RWsSession::DebugInfo; //exposes the following two functions: -// TInt DebugInfo(TInt aFunction, TInt aParam=0) const; -// TInt DebugInfo(TInt aFunction, TDes8& aReturnBuf, TInt aParam=0) const; - - /** Returns an array of debug data about the specified object. - * The data is placed in the aHostBuffer - * If data is returned, aReturnedObject points to the start of the returned data, and the return value is the number of DataType objects. - * If no data is returned, aReturnedObject is NULL. - * If so the return code indicates an error code, or the required number of objects. - * The object index is specified using the masks and shifts in TWsDebugClassArgMask - * Various error codes may be returned from the server, some of which may simply explain why no data is available. - * The client may return - * KErrCancel to indicate that there is zero length of data - * KErrCorrupt if the size of the returned data is not an exact multiple of DataType. - * No other type checking is performed. - **/ - template // DataType may be TSurfaceId, TInt,TRect, TSurfaceConfiguration (not TRegion) - TInt DebugInfo(TWsDebugInfoFunc aFunction, TInt aObjectIndex, TDes8& aHostBuffer,const DataType*&aReturnedObject)const - { - return DebugInfo(aFunction,aObjectIndex,aHostBuffer,(const void*&)aReturnedObject,sizeof(DataType)); - } - /** Fills the region object with the specified debug information. - * If required the region is resized to fit the data, which may fail with KErrNoMemory - * The region will be forced to error state if an error code is returned. - * Other details: see overloads - **/ - TInt DebugInfo(TWsDebugInfoFunc aFunction, TInt aObjectIndex, TRegion& aPreAllocatedReturnedRegion)const; - - /** Indicates the start of a "consistancy-critical-read" section and fetches the window list. - * Any number of debug commands can be fetched in the section, then client can check if the were interrupted by a server recalculation. - **/ - TInt ResetUpdatedAndGetSurfaceWindowList (const TWsDebugWindowId*&); - /** Indicates the start or end of a "consistancy-critical-read" section - * Any number of debug commands can be fetched in the section, then client can check if the were interrupted by a server recalculation. - * If this method returns ETrue then the data fetched since the start may be inconsistant, and should be refetched. - * This method may also be used as a dirty way of waiting for a deferred update to occur. - **/ - TBool ResetUpdated(); - /** Returns the screen number assigned when the stub was created. - **/ - TInt DebugScreenNo() { return iScreenNo; } - /** Helper method to correctly format the aObjectIndex parameter. - **/ - inline TInt ObjInd(TInt aWin=0,TInt aLayer=0,TInt aExtra=0) - { return ObjIndScr(iScreenNo,aWin,aLayer,aExtra); } - /** Helper method to correctly format the aObjectIndex parameter. - **/ - inline TInt ObjIndScr(TInt aScreen,TInt aWin=0,TInt aLayer=0,TInt aExtra=0); - - inline TInt Finish(TBool aAndFlush=ETrue) - { - if (aAndFlush) - Flush(); - return RWsSession::Finish(); - } -protected: - // Resolves the template parameter to a size. See overload docs for more info. - TInt DebugInfo(TWsDebugInfoFunc aFunction, TInt aObjectIndex, TDes8& aHostBuffer,const void*&aReturnedObject,TInt aSize)const; - TInt iScreenNo; - TInt iSurfaceUpdateSerial; - RBuf8 iSurfaceListBuffer; - }; -inline TInt RWsDebugSession::ObjIndScr(TInt aScreen,TInt aWin,TInt aLayer,TInt aExtra) - { - return (aScreen< - -TGlobalSettings settings_instance={0,0}; -const TGlobalSettings& TGlobalSettings::Instance() - { - return settings_instance; - } - -// Create a suite of all the tests -CTestSuite* CGlobalSettings::CreateSuiteL(const TDesC& aName) - { - SUB_SUITE_OPT(CGlobalSettings,NULL); - - ADD_TEST_STEP_PARAM_RANGE(SetScreenNoL,0,9); - ADD_TEST_STEP_PARAM_BOOL(ExpectDisconnectedScreenL); - - END_SUITE; - } - -void CGlobalSettings::SetScreenNoL(TInt aScreenNo) - { - RWsSession session; - ASSERT_EQUALS(session.Connect(), KErrNone); - TInt maxScreens=session.NumberOfScreens(); - - if (maxScreens>aScreenNo) - { - INFO_PRINTF2(_L("New screen number for all output selected: %i"),aScreenNo); - { - CWsScreenDevice screen(session); - screen.Construct(aScreenNo); - screen.SetCurrentRotations(0,CFbsBitGc::TGraphicsOrientation(0)); - screen.SetScreenMode(0); - screen.SetAppScreenMode(0); - } - settings_instance.iScreen=aScreenNo; - session.Flush(); - session.Close(); - } - else - { - INFO_PRINTF1(_L("**************************")); - INFO_PRINTF1(_L("")); - INFO_PRINTF3(_L("Can't set screen output to %i. Only got %i screens"),aScreenNo,maxScreens); - INFO_PRINTF2(_L("Screen number for all output remains at: %i"),settings_instance.iScreen); - - INFO_PRINTF1(_L("")); - INFO_PRINTF1(_L("**************************")); - session.Flush(); - session.Close(); - User::Leave(KErrTEFUnitFail); - } - } - -void CGlobalSettings::ExpectDisconnectedScreenL(TBool aValue) - { - settings_instance.iDisconnected=aValue; - } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tdynamicres/src/screenselect.cpp --- a/windowing/windowserver/tdynamicres/src/screenselect.cpp Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,64 +0,0 @@ -// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file -*/ - -#include -#include -#include "teflogextensions.h" -#include "screenselect.h" -#include "globalsettings.h" - -//Note that this class now just acts as a stub to the CGlobalSettings::SetScreenNoL() method and data, so both are equivalent. - -CScreenSelect::CScreenSelect(TInt aScreenNumber, const TDesC& aStepName) - { - SetTestStepName(aStepName); - iScreenNumber = aScreenNumber; - } - -CScreenSelect::~CScreenSelect() - { - } - - -TInt CScreenSelect::Number() - { - return TGlobalSettings::Instance().iScreen; - } - - -TVerdict CScreenSelect::doTestStepL() - { - SetTestStepError(EFail); - - CGlobalSettings* globalSettings=new (ELeave) CGlobalSettings; - - globalSettings->SetLoggerL(Logger()); - TRAPD(err,globalSettings->SetScreenNoL( iScreenNumber)); - - if (err==KErrNone) - { - SetTestStepError(EPass); - return EPass; - } - else - { - return EFail; - } - } - diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tdynamicres/src/surfaceutility.cpp --- a/windowing/windowserver/tdynamicres/src/surfaceutility.cpp Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1544 +0,0 @@ -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file -*/ - -#include -#include -#include "surfaceutility.h" - -CSurfaceUtility::CSurfaceUtility(CSurfaceUtility* aClone/*=NULL*/) - : iSurfaces(aClone?&(aClone->iSurfaces):NULL) - { - } - -CSurfaceUtility* CSurfaceUtility::NewL(CSurfaceUtility* aClone/*=NULL*/) - { - CSurfaceUtility* utility = new (ELeave)CSurfaceUtility(aClone); - CleanupStack::PushL(utility); - utility->ConstructL(); - CleanupStack::Pop(utility); - return utility; - } - -void CSurfaceUtility::ConstructL() - { - TInt r = iManager.Open(); - if (r != KErrNone) - { - LOG(("Surface manager failed to open: %d", r)); - User::Leave(r); - } - - r = iSurfaceUpdateSession.Connect(); - if (r != KErrNone) - { - LOG(("Failed to connect to update server: %d", r)); - User::Leave(r); - } - } - -CSurfaceUtility::~CSurfaceUtility() - { - DestroyAll(); - - iSurfaces.Close(); - - iManager.Close(); - - iSurfaceUpdateSession.Close(); - } - -TBool CSurfaceUtility::DestroyAll() - { - TInt err = KErrNone; - TInt jj = iSurfaces.Count() - 1; - if (jj<0) - return EFalse; - for (; jj >= 0; jj--) - { - err = iManager.CloseSurface(iSurfaces[jj]); - if (err!=KErrNone) - { - LOG(("Error closing surface: 0x%X\n", err)); - } - } - iSurfaces.Reset(); - return ETrue; - } - -/*************************************** - * The aim of the THeapSurfaceArray is to locally switch in the specified heap for any array operation - ***************************************/ - -CSurfaceUtility::RHeapSurfaceArray::RHeapSurfaceArray(RHeapSurfaceArray* aUseExternalArray) - : iUseArray(aUseExternalArray?aUseExternalArray->iUseArray:&this->iLocalArray), - iExternalHeapRef(aUseExternalArray?aUseExternalArray->iExternalHeapRef:User::Heap()) - { - - } -/************************************ - * The following methods have been used by the surfaceutility... some require the heap wrapping, and some don't - * I actually need three different startegies (count em) for 7 methods... - * Some methods only read the existing objects, so don't need a heap swap at all - * Leaving methods have to use PopAndDestroy strategy to restore the heap on leaving or success - * Non-leaving methods must not call PushL, so directly make SwitchHeap calls! - ************************************/ - -// PopAndDestroy method to restore the heap -/*static*/ void CSurfaceUtility::RHeapSurfaceArray::PopHeap(void* aHeapPtr) - { - RHeap* heapPtr=(RHeap*)aHeapPtr; - User::SwitchHeap(heapPtr); - } - -// Switches and pushes the previous heap so it can be restored with PopAndDestroy -/*static*/ void CSurfaceUtility::RHeapSurfaceArray::SwitchHeapLC(RHeap* aNewHeap) - { - CleanupStack::PushL(TCleanupItem(PopHeap,NULL)); - CleanupStack::PushL(TCleanupItem(PopHeap,NULL)); - CleanupStack::PushL(TCleanupItem(PopHeap,NULL)); - CleanupStack::Pop(3); - RHeap* oldHeap=User::SwitchHeap(aNewHeap); - delete new char; - CleanupStack::PushL(TCleanupItem(PopHeap,oldHeap)); - } - - -TSurfaceId& CSurfaceUtility::RHeapSurfaceArray::operator[](TUint aIndex) - { - return iUseArray->operator[](aIndex); - } -// Close only closes the local array, while Reset resets the active array (may be external) -void CSurfaceUtility::RHeapSurfaceArray::Close() - { - RHeap* oldHeap=User::SwitchHeap(&iExternalHeapRef); - iLocalArray.Close(); - User::SwitchHeap(oldHeap); - } -TInt CSurfaceUtility::RHeapSurfaceArray::Count() const - { - return iUseArray->Count(); - } -// Close only closes the local array, while Reset resets the active array (may be external) -inline void CSurfaceUtility::RHeapSurfaceArray::Reset() - { - RHeap* oldHeap=User::SwitchHeap(&iExternalHeapRef); - iUseArray->Reset(); - User::SwitchHeap(oldHeap); - } -void CSurfaceUtility::RHeapSurfaceArray::AppendL(const TSurfaceId &anEntry) - { - SwitchHeapLC(&iExternalHeapRef); - iUseArray->AppendL(anEntry); - CleanupStack::PopAndDestroy(); - } -TInt CSurfaceUtility::RHeapSurfaceArray::Find(const TSurfaceId &anEntry) const - { - return iUseArray->Find(anEntry); - } -void CSurfaceUtility::RHeapSurfaceArray::Remove(TInt anIndex) - { - RHeap* oldHeap=User::SwitchHeap(&iExternalHeapRef); - iUseArray->Remove(anIndex); - User::SwitchHeap(oldHeap); - } - - - - -/** -Cleanup stack helper object, holding references to both utility and surface, so -that the standard Close() semantics can be used. -*/ -class TSurfaceCleanup - { -public: - TSurfaceCleanup(CSurfaceUtility& aUtility, TSurfaceId& aSurface) - : iUtility(aUtility), iSurface(aSurface) - {} - void Close() - { - // Removes the surface from the list of surfaces to clean up, and closes - // the surface reference. - iUtility.DestroySurface(iSurface); - } -private: - CSurfaceUtility& iUtility; - TSurfaceId& iSurface; - }; - -/** -Read the given image file into a new surface. - -@param aFileName The name of the image file. -@param aSurface Filled with the surface ID for the surface containing the pixels. -*/ -void CSurfaceUtility::CreateSurfaceFromFileL(const TDesC& aFileName, TSurfaceId& aSurface) - { - RFs fs; - - User::LeaveIfError(fs.Connect()); - CleanupClosePushL(fs); - CImageDecoder* decoder = CImageDecoder::FileNewL(fs, aFileName, CImageDecoder::EOptionAlwaysThread); - CleanupStack::PushL(decoder); - - const TFrameInfo& info = decoder->FrameInfo(); - - TSize size = info.iOverallSizeInPixels; - TInt stride = size.iWidth << 2; // Default to four bytes per pixel - TDisplayMode bmpFormat = info.iFrameDisplayMode; - TUidPixelFormat pixelFormat = EUidPixelFormatUnknown; - - switch (bmpFormat) - { - case EGray2: - case EGray4: - case EGray16: - case EGray256: - case EColor16: - case EColor256: - case EColor16M: - case EColor16MU: - { - bmpFormat = EColor16MU; - pixelFormat = EUidPixelFormatXRGB_8888; - break; - } - case EColor4K: - { - stride = size.iWidth << 1; - pixelFormat = EUidPixelFormatXRGB_4444; - break; - } - case EColor64K: - { - stride = size.iWidth << 1; - pixelFormat = EUidPixelFormatRGB_565; - break; - } - case EColor16MA: - { - pixelFormat = EUidPixelFormatARGB_8888; - break; - } - case EColor16MAP: - { - pixelFormat = EUidPixelFormatARGB_8888_PRE; - break; - } - default: - { - LOG(("Unsupported display mode: %d", bmpFormat)); - User::Leave(KErrNotSupported); - break; - } - } - - // Create an intermediary bitmap for decoding into - CFbsBitmap* bitmap = new (ELeave) CFbsBitmap(); - CleanupStack::PushL(bitmap); - User::LeaveIfError(bitmap->Create(size, info.iFrameDisplayMode)); - - // Create the final surface. - aSurface = CreateSurfaceL(size, pixelFormat, stride); - TSurfaceCleanup surfaceCleanup(*this, aSurface); - CleanupClosePushL(surfaceCleanup); - - RChunk chunk; - User::LeaveIfError(iManager.MapSurface(aSurface, chunk)); - CleanupClosePushL(chunk); - - // Convert the image file into a Symbian bitmap - TRequestStatus status; - decoder->Convert(&status, *bitmap); - User::WaitForRequest(status); - User::LeaveIfError(status.Int()); - - TInt offsetToFirstBuffer; - User::LeaveIfError(iManager.GetBufferOffset(aSurface, 0, offsetToFirstBuffer)); - - // Copy the data from the bitmap into the surface. - TPoint start; - TUint8 *pSurfStart = chunk.Base() + offsetToFirstBuffer; - for (start.iY = 0; start.iY < size.iHeight; start.iY++) - { - // Set up a descriptor for the current line in the surface and get pixels. - TPtr8 ptr(pSurfStart + start.iY * stride, stride); - bitmap->GetScanLine(ptr, start, size.iWidth, bmpFormat); - } - - CleanupStack::PopAndDestroy(/* chunk */); - CleanupStack::Pop(/* surfaceCleanup */); - CleanupStack::PopAndDestroy(bitmap); - CleanupStack::PopAndDestroy(decoder); - CleanupStack::PopAndDestroy(/* fs */); - } - -void CSurfaceUtility::CopyBitmapSurfaceL(const CFbsBitmap* aBitmap, TSurfaceId& aSurface) - { - RChunk chunk; - User::LeaveIfError(iManager.MapSurface(aSurface, chunk)); - CleanupClosePushL(chunk); - TSize bitmapSize = aBitmap->SizeInPixels(); - TSize size = SurfaceSize(aSurface); - TInt stride = size.iWidth*4; // Default to four bytes per pixel - - TInt offsetToFirstBuffer; - User::LeaveIfError(iManager.GetBufferOffset(aSurface, 0, offsetToFirstBuffer)); - - // Copy the data from the bitmap into the surface. - TPoint start; - TUint8 *pSurfStart = chunk.Base() + offsetToFirstBuffer; - for (start.iY = 0; start.iY < bitmapSize.iHeight; start.iY++) - { - // Set up a descriptor for the current line in the surface and get pixels. - TPtr8 ptr(pSurfStart + start.iY * stride, stride); - aBitmap->GetScanLine(ptr, start, bitmapSize.iWidth, EColor16MU); - } - CleanupStack::PopAndDestroy(/* chunk */); - - } -/** -Copy the bitmap from a file to a surface. - -@param aFileName The name of the image file. -@param aSurface Filled with the surface ID for the surface containing the pixels. -*/ -void CSurfaceUtility::CopyBitmapFromFileToSurfaceL(const TDesC& aFileName, TSurfaceId& aSurface) - { - RFs fs; - - User::LeaveIfError(fs.Connect()); - CleanupClosePushL(fs); - CImageDecoder* decoder = CImageDecoder::FileNewL(fs, aFileName, CImageDecoder::EOptionAlwaysThread); - CleanupStack::PushL(decoder); - - const TFrameInfo& info = decoder->FrameInfo(); - - RSurfaceManager::TInfoBuf infoBuf; - RSurfaceManager::TSurfaceInfoV01& infoSurf = infoBuf(); - User::LeaveIfError(iManager.SurfaceInfo(aSurface, infoBuf)); - - TSize size = infoSurf.iSize; - TDisplayMode bmpFormat = info.iFrameDisplayMode; - TInt stride = size.iWidth << 2; // Default to four bytes per pixel - - // Create an intermediary bitmap for decoding into - CFbsBitmap* bitmap = new (ELeave) CFbsBitmap(); - CleanupStack::PushL(bitmap); - User::LeaveIfError(bitmap->Create(size, info.iFrameDisplayMode)); - - RChunk chunk; - User::LeaveIfError(iManager.MapSurface(aSurface, chunk)); - CleanupClosePushL(chunk); - - // Convert the image file into a Symbian bitmap - TRequestStatus status; - decoder->Convert(&status, *bitmap); - User::WaitForRequest(status); - User::LeaveIfError(status.Int()); - - TInt offsetToFirstBuffer; - User::LeaveIfError(iManager.GetBufferOffset(aSurface, 0, offsetToFirstBuffer)); - - // Copy the data from the bitmap into the surface. - TPoint start; - TUint8 *pSurfStart = chunk.Base() + offsetToFirstBuffer; - for (start.iY = 0; start.iY < size.iHeight; start.iY++) - { - // Set up a descriptor for the current line in the surface and get pixels. - TPtr8 ptr(pSurfStart + start.iY * stride, stride); - bitmap->GetScanLine(ptr, start, size.iWidth, bmpFormat); - } - - CleanupStack::PopAndDestroy(/* chunk */); - CleanupStack::PopAndDestroy(bitmap); - CleanupStack::PopAndDestroy(decoder); - CleanupStack::PopAndDestroy(/* fs */); - } -/** -Get the size of a surface. - -@param aSurface The surface to get the size for. -@return The size in pixels, or empty on failure. -*/ -TSize CSurfaceUtility::SurfaceSize(const TSurfaceId& aSurface) - { - RSurfaceManager::TInfoBuf infoBuf; - RSurfaceManager::TSurfaceInfoV01& info = infoBuf(); - - if (iManager.SurfaceInfo(aSurface, infoBuf) == KErrNone) - { - return info.iSize; - } - - return TSize(); - } - - -/** -Create a surface using the surface manager. - -Stores the ID for tear down, as well as returning it. - -@param aSize Dimensions of the surface. -@param aPixelFormat UID of the pixel format. -@param aStride Stride value for the surface (usually bytes per pixel * width) -@leave May leave due to lack of memory. -@return New surface's ID. -*/ -TSurfaceId CSurfaceUtility::CreateSurfaceL(const TSize& aSize, TUidPixelFormat aPixelFormat, TInt aStride, TInt aBuffers) - { - RSurfaceManager::TSurfaceCreationAttributesBuf bf; - RSurfaceManager::TSurfaceCreationAttributes& b = bf(); - - b.iSize.iWidth = aSize.iWidth; - b.iSize.iHeight = aSize.iHeight; - b.iBuffers = aBuffers; // number of buffers in the surface - b.iPixelFormat = aPixelFormat; - b.iStride = aStride; // Number of bytes between start of one line and start of next - b.iOffsetToFirstBuffer = 0; // way of reserving space before the surface pixel data - b.iAlignment = 4; // alignment, 1,2,4,8 byte aligned - b.iContiguous = EFalse; - b.iMappable = ETrue; - - TSurfaceId surface = TSurfaceId::CreateNullId(); - - User::LeaveIfError(iManager.CreateSurface(bf, surface)); - iSurfaces.AppendL(surface); - return surface; - } - -/** -A helper function that returns the bytes per pixel for a given pixel format uid - -@param aPixelFormat Pixel format UID to convert -@return The bytes per pixel -*/ -TInt CSurfaceUtility::BytesPerPixelL(TUidPixelFormat aPixelFormat) - { - TInt bytesPerPixel = 0; - switch (aPixelFormat) - { - case EUidPixelFormatXRGB_8888: - case EUidPixelFormatARGB_8888: - case EUidPixelFormatARGB_8888_PRE: - { - bytesPerPixel = 4; - break; - } - case EUidPixelFormatXRGB_4444: - case EUidPixelFormatARGB_4444: - case EUidPixelFormatRGB_565: - { - bytesPerPixel = 2; - break; - } - default: - { - User::Leave(KErrNotSupported); - break; - } - } - return bytesPerPixel; - } - -/** -Fill the given surface with a color. - -@param aSurface The surface to be filled. -@param aColor The color to fill it with. -*/ -void CSurfaceUtility::FillSurfaceL(TSurfaceId& aSurface, const TRgb& aColor) - { - RSurfaceManager::TInfoBuf infoBuf; - RSurfaceManager::TSurfaceInfoV01& info = infoBuf(); - - User::LeaveIfError(iManager.SurfaceInfo(aSurface, infoBuf)); - TUint32 color = 0; - TBool use16 = EFalse; - - if (info.iSize.iHeight<0 || info.iSize.iWidth<0 || info.iStride<0) - { - User::Leave(KErrCorrupt); - } - if (info.iSize.iHeight==0 || info.iSize.iWidth==0 || info.iStride==0) - { - User::Leave(KErrNotReady); - } - - switch (info.iPixelFormat) - { - case EUidPixelFormatXRGB_8888: - { - color = aColor.Color16MU(); -#ifdef ALPHA_FIX_24BIT - color |= ((ALPHA_FIX_24BIT)&0xff)<<24; -#endif - break; - } - case EUidPixelFormatARGB_8888: - { - color = aColor.Color16MA(); - break; - } - case EUidPixelFormatARGB_8888_PRE: - { - color = aColor.Color16MAP(); - break; - } - case EUidPixelFormatXRGB_4444: - case EUidPixelFormatARGB_4444: - { - color = aColor.Color4K(); - use16 = ETrue; - break; - } - case EUidPixelFormatRGB_565: - { - color = aColor.Color64K(); - use16 = ETrue; - break; - } - default: - { - User::Leave(KErrNotSupported); - break; - } - } - - RChunk chunk; - User::LeaveIfError(iManager.MapSurface(aSurface, chunk)); - CleanupClosePushL(chunk); - - TInt offsetToFirstBuffer; - User::LeaveIfError(iManager.GetBufferOffset(aSurface, 0, offsetToFirstBuffer)); - TUint8* surfacePtr = chunk.Base() + offsetToFirstBuffer; - TUint8* linePtr = surfacePtr; - - if (use16) - { - if ( info.iSize.iWidth*2>info.iStride) - { - User::Leave(KErrOverflow); - } - TUint16* ptr = reinterpret_cast(surfacePtr); - - // Fill first line - for (TInt xx = 0; xx < info.iSize.iWidth; xx++) - { - ptr[xx] = (TUint16)color; - } - } - else - { - if ( info.iSize.iWidth*4>info.iStride) - { - User::Leave(KErrOverflow); - } - TUint32* ptr = reinterpret_cast(surfacePtr); - - // Fill first line - for (TInt xx = 0; xx < info.iSize.iWidth; xx++) - { - ptr[xx] = color; - } - } - - // Now copy that to the other lines - for (TInt yy = 1; yy < info.iSize.iHeight; yy++) - { - linePtr += info.iStride; - Mem::Copy(linePtr, surfacePtr, info.iSize.iWidth * BytesPerPixelL(info.iPixelFormat)); - } - - TInt err = iSurfaceUpdateSession.SubmitUpdate(KAllScreens, aSurface, 0, NULL); - if (err!=KErrNone) - LOG(("Error submitting update: 0x%X\n", err)); - - CleanupStack::PopAndDestroy(/* chunk */); - } - -/** -Fill the given memory chunk with a color. - -@param aSurface The surface to be filled. -@param aChunk The surface to be filled. -@param aColor The color to fill it with. -*/ -void CSurfaceUtility::FillChunkL(TSurfaceId& aSurface, RChunk& aChunk, const TRgb& aColor, TInt aBufferNumber) - { - RSurfaceManager::TInfoBuf infoBuf; - RSurfaceManager::TSurfaceInfoV01& info = infoBuf(); - - User::LeaveIfError(iManager.SurfaceInfo(aSurface, infoBuf)); - TUint32 color = 0; - TBool use16 = EFalse; - - if (info.iSize.iHeight<0 || info.iSize.iWidth<0 || info.iStride<0) - { - User::Leave(KErrCorrupt); - } - if (info.iSize.iHeight==0 || info.iSize.iWidth==0 || info.iStride==0) - { - User::Leave(KErrNotReady); - } - - switch (info.iPixelFormat) - { - case EUidPixelFormatXRGB_8888: - { - color = aColor.Color16MU(); -#ifdef ALPHA_FIX_24BIT - color |= ((ALPHA_FIX_24BIT)&0xff)<<24; -#endif - break; - } - case EUidPixelFormatARGB_8888: - { - color = aColor.Color16MA(); - break; - } - case EUidPixelFormatARGB_8888_PRE: - { - color = aColor.Color16MAP(); - break; - } - case EUidPixelFormatXRGB_4444: - case EUidPixelFormatARGB_4444: - { - color = aColor.Color4K(); - use16 = ETrue; - break; - } - case EUidPixelFormatRGB_565: - { - color = aColor.Color64K(); - use16 = ETrue; - break; - } - default: - { - User::Leave(KErrNotSupported); - break; - } - } - - User::LeaveIfError(iManager.MapSurface(aSurface, aChunk)); - - TInt offsetToFirstBuffer; - User::LeaveIfError(iManager.GetBufferOffset(aSurface, 0, offsetToFirstBuffer)); - TInt offsetToBufferNumber; - User::LeaveIfError(iManager.GetBufferOffset(aSurface, aBufferNumber, offsetToBufferNumber)); - - TUint8* chunkPtr = aChunk.Base() + offsetToFirstBuffer; - TUint8* linePtr = aChunk.Base() + offsetToBufferNumber; - TUint8* surfPlanePtr = linePtr; - - if (use16) - { - if ( info.iSize.iWidth*2>info.iStride) - { - aChunk.Close(); - User::Leave(KErrOverflow); - } - TUint16* ptr = reinterpret_cast(surfPlanePtr); - - // Fill first line - for (TInt xx = 0; xx < info.iSize.iWidth; xx++) - { - ptr[xx] = (TUint16)color; - } - } - else - { - if ( info.iSize.iWidth*4>info.iStride) - { - aChunk.Close(); - User::Leave(KErrOverflow); - } - TUint32* ptr = reinterpret_cast(surfPlanePtr); - - // Fill first line - for (TInt xx = 0; xx < info.iSize.iWidth; xx++) - { - ptr[xx] = color; - } - } - - // Now copy that to the other lines - for (TInt yy = 1; yy < info.iSize.iHeight; yy++) - { - linePtr += info.iStride; - Mem::Copy(linePtr, surfPlanePtr, info.iSize.iWidth * BytesPerPixelL(info.iPixelFormat)); - } - - aChunk.Close(); - } - -/** -Fill a rectangle on the given surface. - -@param aSurface The surface to be filled. -@param aStartPos Where to place the rectangle. -@param aSize Size of the rectangle. -@param aColor The colour to fill it with. -*/ -void CSurfaceUtility::FillRectangleL(TSurfaceId& aSurface, const TPoint& aStartPos, const TSize& aSize, const TRgb& aColor) - { - FillRectangleNoUpdateL(aSurface, aStartPos, aSize, aColor); - - TInt err = iSurfaceUpdateSession.SubmitUpdate(KAllScreens, aSurface, 0, NULL); - if (err!=KErrNone) - LOG(("Error submitting update: 0x%X\n", err)); - } - -/** -Fill a rectangle on the given surface - does not submit update. - -@param aSurface The surface to be filled. -@param aStartPos Where to place the rectangle. -@param aSize Size of the rectangle. -@param aColor The colour to fill it with. -*/ -void CSurfaceUtility::FillRectangleNoUpdateL(TSurfaceId& aSurface, const TPoint& aStartPos, const TSize& aSize, const TRgb& aColor) - { - RSurfaceManager::TInfoBuf infoBuf; - RSurfaceManager::TSurfaceInfoV01& info = infoBuf(); - - User::LeaveIfError(iManager.SurfaceInfo(aSurface, infoBuf)); - TUint32 color = 0; - TBool use16 = EFalse; - - if (info.iSize.iHeight<0 || info.iSize.iWidth<0 || info.iStride<0) - { - User::Leave(KErrCorrupt); - } - if (info.iSize.iHeight==0 || info.iSize.iWidth==0 || info.iStride==0) - { - User::Leave(KErrNotReady); - } - - switch (info.iPixelFormat) - { - case EUidPixelFormatXRGB_8888: - { - color = aColor.Color16MU(); -#ifdef ALPHA_FIX_24BIT - color |= ((ALPHA_FIX_24BIT)&0xff)<<24; -#endif - break; - } - case EUidPixelFormatARGB_8888: - { - color = aColor.Color16MA(); - break; - } - case EUidPixelFormatARGB_8888_PRE: - { - color = aColor.Color16MAP(); - break; - } - case EUidPixelFormatXRGB_4444: - case EUidPixelFormatARGB_4444: - { - color = aColor.Color4K(); - use16 = ETrue; - break; - } - case EUidPixelFormatRGB_565: - { - color = aColor.Color64K(); - use16 = ETrue; - break; - } - default: - { - User::Leave(KErrNotSupported); - break; - } - } - - RChunk chunk; - User::LeaveIfError(iManager.MapSurface(aSurface, chunk)); - CleanupClosePushL(chunk); - - TInt offsetToFirstBuffer; - User::LeaveIfError(iManager.GetBufferOffset(aSurface, 0, offsetToFirstBuffer)); - TUint8* surfacePtr = chunk.Base() + offsetToFirstBuffer; - - // Check for out of bounds - TBool validRect = ETrue; - TInt surfaceWidth = info.iSize.iWidth; - TInt surfaceHeight = info.iSize.iHeight; - - // Width and Height - if ((aStartPos.iX + aSize.iWidth) > surfaceWidth) - validRect = EFalse; - - if ((aStartPos.iY + aSize.iHeight) > surfaceHeight) - validRect = EFalse; - - // Starting position - if ((aStartPos.iX < 0) || (aStartPos.iY < 0)) - validRect = EFalse; - - if (!validRect) - User::Leave(KErrOverflow); - - if (use16) - { - if ( info.iSize.iWidth*2>info.iStride) - { - User::Leave(KErrOverflow); - } - - TUint16* ptr = reinterpret_cast(surfacePtr); - - // Fill the rectangle - TInt yPos = aStartPos.iY; - TInt xPos = aStartPos.iX; - for (TInt yy = 0; yy < aSize.iHeight; ++yy) - { - ptr = reinterpret_cast(surfacePtr+(yPos*info.iStride)); - for (TInt xx = 0; xx < aSize.iWidth; ++xx) - { - ptr[xPos] = color; - xPos++; - } - xPos = aStartPos.iX; - yPos++; - } - } - else - { - if ( info.iSize.iWidth*4>info.iStride) - { - User::Leave(KErrOverflow); - } - - TUint32* ptr = reinterpret_cast(surfacePtr); - - // Fill the rectangle - TInt yPos = aStartPos.iY; - TInt xPos = aStartPos.iX; - for (TInt yy = 0; yy < aSize.iHeight; ++yy) - { - ptr = reinterpret_cast(surfacePtr+(yPos*info.iStride)); - for (TInt xx = 0; xx < aSize.iWidth; ++xx) - { - ptr[xPos] = color; - xPos++; - } - xPos = aStartPos.iX; - yPos++; - } - } - - CleanupStack::PopAndDestroy(/* chunk */); - } - -/** -Fill the given surface with a grid over a solid color. - -Similar to FillSurfaceL(), but with a grid overlayed. The pitch of the grid is -eight pixels. - -@param aSurface The surface to be filled. -@param aColor The color to fill it with. -@param aLines The color of the grid lines. -*/ -void CSurfaceUtility::GridFillSurfaceL(TSurfaceId& aSurface, const TRgb& aColor, const TRgb& aLines) - { - RSurfaceManager::TInfoBuf infoBuf; - RSurfaceManager::TSurfaceInfoV01& info = infoBuf(); - - User::LeaveIfError(iManager.SurfaceInfo(aSurface, infoBuf)); - TUint32 color = 0; - TUint32 lines = 0; - TBool use16 = EFalse; - - if (info.iSize.iHeight<0 || info.iSize.iWidth<0 || info.iStride<0) - { - User::Leave(KErrCorrupt); - } - if (info.iSize.iHeight==0 || info.iSize.iWidth==0 || info.iStride==0) - { - User::Leave(KErrNotReady); - } - - switch (info.iPixelFormat) - { - case EUidPixelFormatXRGB_8888: - { - color = aColor.Color16MU(); - lines = aLines.Color16MU(); -#ifdef ALPHA_FIX_24BIT - color |= ((ALPHA_FIX_24BIT)&0xff)<<24; - lines |= ((ALPHA_FIX_24BIT)&0xff)<<24; -#endif - break; - } - case EUidPixelFormatARGB_8888: - { - color = aColor.Color16MA(); - lines = aLines.Color16MA(); - break; - } - case EUidPixelFormatARGB_8888_PRE: - { - color = aColor.Color16MAP(); - lines = aLines.Color16MAP(); - break; - } - case EUidPixelFormatXRGB_4444: - case EUidPixelFormatARGB_4444: - { - color = aColor.Color4K(); - lines = aLines.Color4K(); - use16 = ETrue; - break; - } - case EUidPixelFormatRGB_565: - { - color = aColor.Color64K(); - lines = aLines.Color64K(); - use16 = ETrue; - break; - } - default: - { - User::Leave(KErrNotSupported); - break; - } - } - - RChunk chunk; - User::LeaveIfError(iManager.MapSurface(aSurface, chunk)); - CleanupClosePushL(chunk); - - TInt offsetToFirstBuffer; - User::LeaveIfError(iManager.GetBufferOffset(aSurface, 0, offsetToFirstBuffer)); - TUint8* surfacePtr = chunk.Base() + offsetToFirstBuffer; - TUint8* linePtr = surfacePtr; - - if (use16) - { - if ( info.iSize.iWidth*2>info.iStride) - { - User::Leave(KErrOverflow); - } - TUint16* ptr = reinterpret_cast(surfacePtr); - - // Fill first line - for (TInt xx1 = 0; xx1 < info.iSize.iWidth; xx1++) - { - ptr[xx1] = (TUint16)lines; - } - - // Fill second line - ptr = reinterpret_cast(surfacePtr + info.iStride); - for (TInt xx2 = 0; xx2 < info.iSize.iWidth; xx2++) - { - // Vertical line every 8 pixels across - ptr[xx2] = (TUint16)((xx2 & 7) ? color : lines); - } - } - else - { - if ( info.iSize.iWidth*4>info.iStride) - { - User::Leave(KErrOverflow); - } - TUint32* ptr = reinterpret_cast(surfacePtr); - - // Fill first line - for (TInt xx3 = 0; xx3 < info.iSize.iWidth; xx3++) - { - ptr[xx3] = lines; - } - - // Fill second line - ptr = reinterpret_cast(surfacePtr + info.iStride); - for (TInt xx4 = 0; xx4 < info.iSize.iWidth; xx4++) - { - // Vertical line every 8 pixels across - ptr[xx4] = (xx4 & 7) ? color : lines; - } - } - linePtr += info.iStride; - - // Now copy that to the other lines - for (TInt yy = 2; yy < info.iSize.iHeight; yy++) - { - linePtr += info.iStride; - if (yy & 7) - { - // Copy second line - Mem::Copy(linePtr, surfacePtr + info.iStride, info.iSize.iWidth * BytesPerPixelL(info.iPixelFormat)); - } - else - { - // Copy first line - Mem::Copy(linePtr, surfacePtr, info.iSize.iWidth * BytesPerPixelL(info.iPixelFormat)); - } - } - - TInt err =iSurfaceUpdateSession.SubmitUpdate(KAllScreens, aSurface, 0, NULL); - if (err!=KErrNone) - LOG(("Error submitting update: 0x%X\n", err)); - - CleanupStack::PopAndDestroy(/* chunk */); - } - - -/** -Fill the given surface with a pattern suitable for automated testing. - -@param aSurface The surface to be filled. -*/ -void CSurfaceUtility::PatternFillSurfaceL(TSurfaceId& aSurface) - { - RSurfaceManager::TInfoBuf infoBuf; - RSurfaceManager::TSurfaceInfoV01& info = infoBuf(); - - User::LeaveIfError(iManager.SurfaceInfo(aSurface, infoBuf)); - - // Fill the background - FillSurfaceL(aSurface, TRgb(0x00000000)); - - TInt surfaceWidth = info.iSize.iWidth; - TInt surfaceHeight = info.iSize.iHeight; - - // Create the 4 rectangles in the corners - TPoint startPos(0,0); - TSize size(15,15); - TInt rectWidth = size.iWidth; - TInt rectHeight = size.iHeight; - // Top left - FillRectangleL(aSurface, startPos, size, TRgb(0x0000ff)); - - // Top right - startPos.iX = surfaceWidth - rectWidth; - startPos.iY = 0; - FillRectangleL(aSurface, startPos, size, TRgb(0x00ff00)); - - // Bottom left - startPos.iX = 0; - startPos.iY = surfaceHeight - rectHeight; - FillRectangleL(aSurface, startPos, size, TRgb(0x00ffff)); - - // Bottom right - startPos.iX = surfaceWidth - rectWidth; - startPos.iY = surfaceHeight - rectHeight; - FillRectangleL(aSurface, startPos, size, TRgb(0xffffff)); - - // Create the 4 side bars - startPos.iX = 0; - startPos.iY = 6; - size.iWidth = 5; - size.iHeight = surfaceHeight - 12; - // Left - FillRectangleL(aSurface, startPos, size, TRgb(0x808000)); - - startPos.iX = surfaceWidth - size.iWidth; - startPos.iY = 6; - // Right - FillRectangleL(aSurface, startPos, size, TRgb(0xff00ff)); - - startPos.iX = 6; - startPos.iY = surfaceHeight - size.iWidth; - size.iWidth = surfaceWidth - 12; - size.iHeight = 5; - // Top - FillRectangleL(aSurface, startPos, size, TRgb(0xaaaaaa)); - - startPos.iX = 6; - startPos.iY = 0; - // Bottom - FillRectangleL(aSurface, startPos, size, TRgb(0x000080)); - } - - -template void -DdaLine(TUint aX1, TUint aY1,TUint aX2,TUint aY2, TUint aPixPerScan, TIntType* aBuffer, TIntType aColor) - { - TInt dx=aX2-aX1; - TInt dy=aY2-aY1; - TInt adx=dx,sdx=1; - if (adx<0) - { adx=-adx; sdx=-1; } - TInt ady=dy,sdy=aPixPerScan; - if (ady<0) - { ady=-ady; sdy=-aPixPerScan; } - //This is simplistic integert DDA. - //The vertical cases are handled by this 1/2 accumulator: - // If adx is zero then we step in sdy indefinitely - // If ady is zero then we step in sdx indefinitely - TInt accum=adx/2; - - TIntType* bufferend=aBuffer+aX2+aY2*aPixPerScan; - aBuffer+=aX1+aY1*aPixPerScan; - *aBuffer=aColor; - while (aBuffer!=bufferend) - { - if (accum>0) - { - accum-=ady; - aBuffer+=sdx; - } - else - { - accum+=adx; - aBuffer+=sdy; - } - *aBuffer=aColor; - } - - - } -template void -FanFill(const TPoint& aInnerXY,TUint aPixPerScan, TIntType* aSurfacePtr, TIntType aLinesTL, - TIntType aLinesBR, TIntType aLinesTR, TIntType aLinesBL) - { - - DdaLine(aInnerXY.iX,0,aInnerXY.iX-aInnerXY.iX*180/1024,aInnerXY.iY,aPixPerScan,aSurfacePtr,aLinesTR); - DdaLine(aInnerXY.iX,0,aInnerXY.iX-aInnerXY.iX*372/1024,aInnerXY.iY,aPixPerScan,aSurfacePtr,aLinesTR); - DdaLine(aInnerXY.iX,0,aInnerXY.iX-aInnerXY.iX*591/1024,aInnerXY.iY,aPixPerScan,aSurfacePtr,aLinesTR); - DdaLine(aInnerXY.iX,0,aInnerXY.iX-aInnerXY.iX*859/1024,aInnerXY.iY,aPixPerScan,aSurfacePtr,aLinesTR); - - DdaLine(aInnerXY.iX,0,0,aInnerXY.iY*180/1024,aPixPerScan,aSurfacePtr,aLinesTR); - DdaLine(aInnerXY.iX,0,0,aInnerXY.iY*372/1024,aPixPerScan,aSurfacePtr,aLinesTR); - DdaLine(aInnerXY.iX,0,0,aInnerXY.iY*591/1024,aPixPerScan,aSurfacePtr,aLinesTR); - DdaLine(aInnerXY.iX,0,0,aInnerXY.iY*859/1024,aPixPerScan,aSurfacePtr,aLinesTR); - - DdaLine(0,aInnerXY.iY,aInnerXY.iX*180/1024,0,aPixPerScan,aSurfacePtr,aLinesBL); - DdaLine(0,aInnerXY.iY,aInnerXY.iX*372/1024,0,aPixPerScan,aSurfacePtr,aLinesBL); - DdaLine(0,aInnerXY.iY,aInnerXY.iX*591/1024,0,aPixPerScan,aSurfacePtr,aLinesBL); - DdaLine(0,aInnerXY.iY,aInnerXY.iX*859/1024,0,aPixPerScan,aSurfacePtr,aLinesBL); - - DdaLine(0,aInnerXY.iY,aInnerXY.iX,aInnerXY.iY-aInnerXY.iY*180/1024,aPixPerScan,aSurfacePtr,aLinesBL); - DdaLine(0,aInnerXY.iY,aInnerXY.iX,aInnerXY.iY-aInnerXY.iY*372/1024,aPixPerScan,aSurfacePtr,aLinesBL); - DdaLine(0,aInnerXY.iY,aInnerXY.iX,aInnerXY.iY-aInnerXY.iY*591/1024,aPixPerScan,aSurfacePtr,aLinesBL); - DdaLine(0,aInnerXY.iY,aInnerXY.iX,aInnerXY.iY-aInnerXY.iY*859/1024,aPixPerScan,aSurfacePtr,aLinesBL); - - DdaLine(0,0,aInnerXY.iX*180/1024,aInnerXY.iY,aPixPerScan,aSurfacePtr,aLinesTL); - DdaLine(0,0,aInnerXY.iX*372/1024,aInnerXY.iY,aPixPerScan,aSurfacePtr,aLinesTL); - DdaLine(0,0,aInnerXY.iX*591/1024,aInnerXY.iY,aPixPerScan,aSurfacePtr,aLinesTL); - DdaLine(0,0,aInnerXY.iX*859/1024,aInnerXY.iY,aPixPerScan,aSurfacePtr,aLinesTL); - - DdaLine(0,0,aInnerXY.iX,aInnerXY.iY*180/1024,aPixPerScan,aSurfacePtr,aLinesTL); - DdaLine(0,0,aInnerXY.iX,aInnerXY.iY*372/1024,aPixPerScan,aSurfacePtr,aLinesTL); - DdaLine(0,0,aInnerXY.iX,aInnerXY.iY*591/1024,aPixPerScan,aSurfacePtr,aLinesTL); - DdaLine(0,0,aInnerXY.iX,aInnerXY.iY*859/1024,aPixPerScan,aSurfacePtr,aLinesTL); - - DdaLine(0,aInnerXY.iY-aInnerXY.iY*180/1024,aInnerXY.iX,aInnerXY.iY,aPixPerScan,aSurfacePtr,aLinesBR); - DdaLine(0,aInnerXY.iY-aInnerXY.iY*372/1024,aInnerXY.iX,aInnerXY.iY,aPixPerScan,aSurfacePtr,aLinesBR); - DdaLine(0,aInnerXY.iY-aInnerXY.iY*591/1024,aInnerXY.iX,aInnerXY.iY,aPixPerScan,aSurfacePtr,aLinesBR); - DdaLine(0,aInnerXY.iY-aInnerXY.iY*859/1024,aInnerXY.iX,aInnerXY.iY,aPixPerScan,aSurfacePtr,aLinesBR); - - DdaLine(aInnerXY.iX-aInnerXY.iX*180/1024,0,aInnerXY.iX,aInnerXY.iY,aPixPerScan,aSurfacePtr,aLinesBR); - DdaLine(aInnerXY.iX-aInnerXY.iX*372/1024,0,aInnerXY.iX,aInnerXY.iY,aPixPerScan,aSurfacePtr,aLinesBR); - DdaLine(aInnerXY.iX-aInnerXY.iX*591/1024,0,aInnerXY.iX,aInnerXY.iY,aPixPerScan,aSurfacePtr,aLinesBR); - DdaLine(aInnerXY.iX-aInnerXY.iX*859/1024,0,aInnerXY.iX,aInnerXY.iY,aPixPerScan,aSurfacePtr,aLinesBR); - - } -/** -Fill the given surface with a fan of lines over a solid color. - -Similar to FillSurfaceL(), but with a fan of lines overlayed. -One fan is drawn about the top-left, and second fan at bottom-right. -The fan contains 8 segments. - -@param aSurface The surface to be filled. -@param aColor The color to fill it with. -@param aLines The color of the grid lines. -*/ -void CSurfaceUtility::FanFillSurfaceL(TSurfaceId& aSurface, const TRgb& aColor, const TRgb& aLinesTL, const TRgb& aLinesBR) - { - FillSurfaceL(aSurface,aColor); - RSurfaceManager::TInfoBuf infoBuf; - RSurfaceManager::TSurfaceInfoV01& info = infoBuf(); - - User::LeaveIfError(iManager.SurfaceInfo(aSurface, infoBuf)); - TUint32 linesTL = 0; - TUint32 linesBR = 0; - TUint32 linesTR = 0; - TUint32 linesBL = 0; - TBool use16 = EFalse; - TRgb rgbLinesTR(0,0,0); - TRgb rgbLinesBL(255,255,255); - - switch (info.iPixelFormat) - { - case EUidPixelFormatXRGB_8888: - { - linesBR = aLinesBR.Color16MU(); - linesTL = aLinesTL.Color16MU(); - linesTR = rgbLinesTR.Color16MU(); - linesBL = rgbLinesBL.Color16MU(); -#ifdef ALPHA_FIX_24BIT - linesBR |= ((ALPHA_FIX_24BIT)&0xff)<<24; - linesTL |= ((ALPHA_FIX_24BIT)&0xff)<<24; - linesTR |= ((ALPHA_FIX_24BIT)&0xff)<<24; - linesBL |= ((ALPHA_FIX_24BIT)&0xff)<<24; -#endif - break; - } - case EUidPixelFormatARGB_8888: - { - linesBR = aLinesBR.Color16MA(); - linesTL = aLinesTL.Color16MA(); - linesTR = rgbLinesTR.Color16MA(); - linesBL = rgbLinesBL.Color16MA(); - break; - } - case EUidPixelFormatARGB_8888_PRE: - { - linesBR = aLinesBR.Color16MAP(); - linesTL = aLinesTL.Color16MAP(); - linesTR = rgbLinesTR.Color16MAP(); - linesBL = rgbLinesBL.Color16MAP(); - break; - } - case EUidPixelFormatXRGB_4444: - case EUidPixelFormatARGB_4444: - { - linesBR = aLinesBR.Color4K(); - linesTL = aLinesTL.Color4K(); - linesTR = rgbLinesTR.Color4K(); - linesBL = rgbLinesBL.Color4K(); - use16 = ETrue; - break; - } - case EUidPixelFormatRGB_565: - { - linesBR = aLinesBR.Color64K(); - linesTL = aLinesTL.Color64K(); - linesTR = rgbLinesTR.Color64K(); - linesBL = rgbLinesBL.Color64K(); - use16 = ETrue; - break; - } - default: - { - User::Leave(KErrNotSupported); - break; - } - } - if (info.iSize.iHeight<0 || info.iSize.iWidth<0 || info.iStride<0) - { - User::Leave(KErrCorrupt); - } - if (info.iSize.iHeight==0 || info.iSize.iWidth==0 || info.iStride==0) - { - User::Leave(KErrNotReady); - } - RChunk chunk; - User::LeaveIfError(iManager.MapSurface(aSurface, chunk)); - CleanupClosePushL(chunk); - - TInt offsetToFirstBuffer; - User::LeaveIfError(iManager.GetBufferOffset(aSurface, 0, offsetToFirstBuffer)); - TUint8* surfacePtr = chunk.Base() + offsetToFirstBuffer; - TPoint innerXY(info.iSize.iWidth-1,info.iSize.iHeight-1); - if (use16) - { - if ( info.iSize.iWidth*2>info.iStride) - { - User::Leave(KErrOverflow); - } - FanFill(innerXY,info.iStride/2,(TUint16*)surfacePtr,linesTL,linesBR,linesBL,linesTR); - } - else - { - if ( info.iSize.iWidth*4>info.iStride) - { - User::Leave(KErrOverflow); - } - FanFill(innerXY,info.iStride/4,(TUint*)surfacePtr,linesTL,linesBR,linesBL,linesTR); - } - - iSurfaceUpdateSession.SubmitUpdate(KAllScreens, aSurface, 0, NULL); - - CleanupStack::PopAndDestroy(/* chunk */); - } -/** -Fill the given surface with vertical line at the given position - -Similar to FillSurfaceL(), but with a vertical line overlayed. -The position along the surface is given as a percentage from the left - -@param aSurface The surface to be filled. -@param aColor The color to fill it with. -@param aLine The color of the line. -@param aPosition Position of the vertical line given as a percentage across the surface from the left edge -*/ -void CSurfaceUtility::LineFillSurfaceL(TSurfaceId& aSurface, const TRgb& aBackColor, const TRgb& aLineColor, TInt aPosition) - { - if (aPosition<0 || aPosition>100) - { - aPosition=0; - } - FillSurfaceL(aSurface,aBackColor); - RSurfaceManager::TInfoBuf infoBuf; - RSurfaceManager::TSurfaceInfoV01& info = infoBuf(); - - User::LeaveIfError(iManager.SurfaceInfo(aSurface, infoBuf)); - TUint32 lineColor = 0; - TBool use16 = EFalse; - - switch (info.iPixelFormat) - { - case EUidPixelFormatXRGB_8888: - { - lineColor = aLineColor.Color16MU(); -#ifdef ALPHA_FIX_24BIT - lineColor |= ((ALPHA_FIX_24BIT)&0xff)<<24; -#endif - break; - } - case EUidPixelFormatARGB_8888: - { - lineColor = aLineColor.Color16MA(); - break; - } - case EUidPixelFormatARGB_8888_PRE: - { - lineColor = aLineColor.Color16MAP(); - break; - } - case EUidPixelFormatXRGB_4444: - case EUidPixelFormatARGB_4444: - { - lineColor = aLineColor.Color4K(); - use16 = ETrue; - break; - } - case EUidPixelFormatRGB_565: - { - lineColor = aLineColor.Color64K(); - use16 = ETrue; - break; - } - default: - { - User::Leave(KErrNotSupported); - break; - } - } - RChunk chunk; - User::LeaveIfError(iManager.MapSurface(aSurface, chunk)); - - TInt offsetToFirstBuffer; - User::LeaveIfError(iManager.GetBufferOffset(aSurface, 0, offsetToFirstBuffer)); - TUint8* surfacePtr = chunk.Base() + offsetToFirstBuffer; - if (use16) - { - DdaLine((info.iSize.iWidth*aPosition)/100,0,(info.iSize.iWidth*aPosition)/100, - info.iSize.iHeight-1,info.iStride/2,(TUint16*)surfacePtr,lineColor); - } - else - { - DdaLine((info.iSize.iWidth*aPosition)/100,0,(info.iSize.iWidth*aPosition)/100, - info.iSize.iHeight-1,info.iStride/4,(TUint*)surfacePtr,lineColor); - } - - chunk.Close(); - - iSurfaceUpdateSession.SubmitUpdate(KAllScreens, aSurface, 0, NULL); - } -/** - * Generates a bitmap equivalent to the surface. - * Can reuse an existing bitmap or create a new bitmap. - * The existing bitmap must be an exact match (eg previously generated by this method) - **/ -CFbsBitmap* CSurfaceUtility::EquivalentBitmapL(TSurfaceId& aSurface,CFbsBitmap* aCopyToMayBeNull) - { - RSurfaceManager::TInfoBuf infoBuf; - RSurfaceManager::TSurfaceInfoV01& info = infoBuf(); - - User::LeaveIfError(iManager.SurfaceInfo(aSurface, infoBuf)); - TInt bytesPerPixel=0; - TDisplayMode bitmapMode = ENone; - switch (info.iPixelFormat) - { - case EUidPixelFormatXRGB_8888: - { - bitmapMode = EColor16MU; - bytesPerPixel = 4; - break; - } - case EUidPixelFormatARGB_8888: - { - bitmapMode=EColor16MA; - bytesPerPixel = 4; - break; - } - case EUidPixelFormatARGB_8888_PRE: - { - bitmapMode=EColor16MAP; - bytesPerPixel = 4; - break; - } - case EUidPixelFormatXRGB_4444: - case EUidPixelFormatARGB_4444: - { - bitmapMode=EColor4K; - bytesPerPixel = 2; - break; - } - case EUidPixelFormatRGB_565: - { - bitmapMode=EColor64K; - bytesPerPixel = 2; - break; - } - default: - { - User::Leave(KErrNotSupported); - break; - } - } - CFbsBitmap* retVal=NULL; - if (aCopyToMayBeNull) - { - retVal=aCopyToMayBeNull; - if (retVal->SizeInPixels()!=info.iSize) - User::Leave(KErrCorrupt); - if (retVal->DisplayMode()!=bitmapMode) - User::Leave(KErrCorrupt); - } - else - { - retVal=new CFbsBitmap; - CleanupStack::PushL(retVal); - User::LeaveIfError(retVal->Create(info.iSize,bitmapMode)); - } - RChunk chunk; - CleanupClosePushL(chunk); - User::LeaveIfError(iManager.MapSurface(aSurface, chunk)); - TInt offsetToFirstBuffer; - User::LeaveIfError(iManager.GetBufferOffset(aSurface, 0, offsetToFirstBuffer)); - TUint8* surfacePtr = chunk.Base() + offsetToFirstBuffer; - TUint8* bitmapPtr = (TUint8*)retVal->DataAddress(); - TInt copyBytes=info.iSize.iWidth*bytesPerPixel; - for (TInt y=0;yDataStride(); - } - CleanupStack::PopAndDestroy(&chunk); - if (!aCopyToMayBeNull) - CleanupStack::Pop(retVal); - return retVal; - } - -/** -Destroy a surface. - -As well as destroying the surface, it is removed from the set held for -destruction during tear down. - -@param aSurface The surface to be destroyed. -*/ -void CSurfaceUtility::DestroySurface(TSurfaceId& aSurface) - { - TInt index = iSurfaces.Find(aSurface); - - if (index != KErrNotFound) - { - iSurfaces.Remove(index); - } - - TInt err = iManager.CloseSurface(aSurface); - if (err!=KErrNone) - LOG(("Error closing surfaces: 0x%X\n", err)); - } - - -/** -Submit an update to a surface to the update server. - -@param aScreenNumber The screen to be updated where the surface is shown. -@param aSurface The surface which has been updated. -@param aRegion The area of the surface affected, or NULL for all of it.*/ -void CSurfaceUtility::SubmitUpdate(TInt /* aScreenNumber */, const TSurfaceId& aSurface, const TRegion* aRegion,TInt aBufferNumber) - { - TInt err =iSurfaceUpdateSession.SubmitUpdate(KAllScreens, aSurface, aBufferNumber, aRegion); - if (err!=KErrNone) - LOG(("Error submitting update: 0x%X\n", err)); - } - -/** -Map and submit an update to a surface to the update server. - -@param aChunk The chunk of memory to be mapped -@param aScreenNumber The screen to be updated where the surface is shown. -@param aSurface The surface which has been updated. -@param aRegion The area of the surface affected, or NULL for all of it.*/ -void CSurfaceUtility::MapAndSubmitUpdateL(RChunk& aChunk, - TInt /* aScreenNumber */, - const TSurfaceId& aSurface, - const TRegion* aRegion) - { - User::LeaveIfError(iManager.MapSurface(aSurface, aChunk)); - aChunk.Close(); - TInt err =iSurfaceUpdateSession.SubmitUpdate(KAllScreens, aSurface, 0, aRegion); - if (err!=KErrNone) - LOG(("Error submitting update: 0x%X\n", err)); - } - -void CSurfaceUtility::MapSurfaceL(const TSurfaceId& aSurface, RChunk& aChunk) - { - User::LeaveIfError(iManager.MapSurface(aSurface, aChunk)); - } - -void CSurfaceUtility::CopyBitmapToSurfaceL(TSurfaceId& aSurface, const CFbsBitmap& aBitmap) - { - TSize size = SurfaceSize(aSurface); - - TDisplayMode bmpFormat = aBitmap.DisplayMode(); - TInt stride = size.iWidth * 4; // Default to four bytes per pixel - - RChunk chunk; - User::LeaveIfError(iManager.MapSurface(aSurface, chunk)); - CleanupClosePushL(chunk); - - TInt offsetToFirstBuffer; - User::LeaveIfError(iManager.GetBufferOffset(aSurface, 0, offsetToFirstBuffer)); - - // Copy the data from the bitmap into the surface. - TPoint start; - TUint8 *pSurfStart = chunk.Base() + offsetToFirstBuffer; - for (start.iY = 0; start.iY < size.iHeight; start.iY++) - { - // Set up a descriptor for the current line in the surface and get pixels. - TPtr8 ptr(pSurfStart + start.iY * stride, stride); - aBitmap.GetScanLine(ptr, start, size.iWidth, bmpFormat); - } - - TInt err =iSurfaceUpdateSession.SubmitUpdate(KAllScreens, aSurface, 0, NULL); - if (err!=KErrNone) - { - LOG(("Error submitting update: 0x%X\n", err)); - } - - CleanupStack::PopAndDestroy(/* chunk */); - } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tdynamicres/src/t_wsdynamicresclassictestserver.cpp --- a/windowing/windowserver/tdynamicres/src/t_wsdynamicresclassictestserver.cpp Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,59 +0,0 @@ -// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file -*/ - -#include "wsdynamicresclassic.h" -#include - -_LIT( KServerName, "wsdynamicresclassictestserver" ); - -GLDEF_C const TTestName ServerName() -/** - * ServerName - * - * @return - The TEF server name - */ - { - TTestName serverName(KServerName); - return serverName; - } - -GLDEF_C CTestSuite* CreateTestSuiteL() -/** - * Create the overall test suite. - * - * @return - The top level suite - */ - { - START_SUITE; - - ADD_TEST_SUITE( CWsDynamicResClassic ); - - END_SUITE; - } - -GLDEF_C CTestStep* CreateTEFTestStep(const TDesC& , CTEFUnitServer& /* aServer */) -/** - * Create individual test steps, outside the suite. - */ - { - // Initialise test step object to NULL if no TEF step is found - CTestStep* testStep = NULL; - - return testStep; - } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tdynamicres/src/t_wsdynamicrestestserver.cpp --- a/windowing/windowserver/tdynamicres/src/t_wsdynamicrestestserver.cpp Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,69 +0,0 @@ -// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file -*/ -#include -#include "globalsettings.h" -#include "screenselect.h" -#include "wsdynamicresbase.h" -#include "wsdynamicresbasic.h" - -_LIT( KServerName, "wsdynamicrestestserver" ); - -GLDEF_C const TTestName ServerName() -/** - * ServerName - * - * @return - The TEF server name - */ - { - TTestName serverName(KServerName); - return serverName; - } - -GLDEF_C CTestSuite* CreateTestSuiteL() -/** - * Create the overall test suite. - * - * @return - The top level suite - */ - { - START_SUITE; - ADD_TEST_SUITE( CWsDynamicResBasic ); - ADD_TEST_SUITE( CGlobalSettings ); - END_SUITE; - } - -_LIT(KSelectScreen0, "SelectScreen0"); -_LIT(KSelectScreen1, "SelectScreen1"); - -GLDEF_C CTestStep* CreateTEFTestStep(const TDesC& aStepName, CTEFUnitServer& /* aServer */) -/** - * Create individual test steps, outside the suite. - */ - { - // Initialise test step object to NULL if no TEF step is found - CTestStep* testStep = NULL; - - if (aStepName == KSelectScreen0) - testStep = new CScreenSelect(0, aStepName); - else if (aStepName == KSelectScreen1) - testStep = new CScreenSelect(1, aStepName); - - return testStep; - } - diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tdynamicres/src/t_wsdynamicreswinbase.cpp --- a/windowing/windowserver/tdynamicres/src/t_wsdynamicreswinbase.cpp Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,980 +0,0 @@ -// Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file -*/ - - -#include -#include -#include -#include -#include "teflogextensions.h" -#include "t_wsdynamicreswinbase.h" -#include "globalsettings.h" -#include -#include -#include -#include -#include - -#if (!defined(K_DISPLAY_CH_MAJOR_VERSION_NUMBER) && !defined(K_DISPLAY_CH_MINOR_VERSION_NUMBER)) -#define MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER -#endif - -_LIT(KMonospaceTestFontTypefaceName,"Arial"); -const TInt KMaxFontSize = 150; -TBool CWsDynamicResWinBase::iTransparencyEnabled=EFalse; - -CWsDynamicResWinBase::CWsDynamicResWinBase(): - iDoTearDown(EFalse), - iSession(TGlobalSettings::Instance().iScreen) -{ -} - -void CWsDynamicResWinBase::SetupL() - { - SetupL(EFalse); - } -CActiveScheduler CWsDynamicResWinBase::iScheduler; - -void CWsDynamicResWinBase::SetupL(TBool aUseOtherScreenForInfo) - { - if (CActiveScheduler::Current()!=&iScheduler) - { - new (&iScheduler) CActiveScheduler; - CActiveScheduler::Install(&iScheduler); - } - iDoTearDown=ETrue; - iRed.SetInternal(0xFFFF0000); - iGreen.SetInternal(0xFF00FF00); - iBlue.SetInternal(0xFF0000FF); - iCyan.SetInternal(0xFF00FFFF); - iMagenta.SetInternal(0xFFFF00FF); - iYellow.SetInternal(0xFFFFFF00); - iWhite.SetInternal(0xFFFFFFFF); - iLastGceHoleColor.SetInternal(0); - TITLE_BACKGROUND=iCyan; - COMPARE_BACKGROUND=iBlue; - - ASSERT_EQUALS_X(iSession.Connect(), KErrNone); - - {//Stolen from TAuto CloseAllPanicWindows() - TInt idFocus = iSession.GetFocusWindowGroup(); - TWsEvent event; - event.SetType(EEventKey); //EEventKeyDown - TKeyEvent *keyEvent = event.Key(); - keyEvent->iCode = EKeyEscape; - keyEvent->iScanCode = EStdKeyEscape; - keyEvent->iModifiers = 0; - TInt theLimit = 50; - while(idFocus != NULL && (theLimit-- > 0)) - { - iSession.SendEventToAllWindowGroups(event); - TInt idNewFocus = iSession.GetFocusWindowGroup(); - if (idNewFocus!=idFocus) - { - INFO_PRINTF1(_L("A window was closed [probably a panic box from the previous test].")); - } - idFocus=idNewFocus; - } - } - TInt err = KErrNone; - - TRAP(err, iScreenDevice = new (ELeave) CWsScreenDevice(iSession)); - PRINT_ON_ERROR2_L(err, _L("Failed to create screen device: %d"), err); - ASSERT_EQUALS_X(iScreenDevice->Construct(TGlobalSettings::Instance().iScreen), KErrNone); - iDisplayMode = iScreenDevice->DisplayMode(); // Get default display mode - - CheckAndConnectScreen(); - - TRAP(err, iGc = new (ELeave) CWindowGc(iScreenDevice)); - PRINT_ON_ERROR2_L(err, _L("Failed to create graphics context: %d"), err); - ASSERT_EQUALS_X(iGc->Construct(), KErrNone); - - iGroup = RWindowGroup(iSession); - ASSERT_EQUALS_X(iGroup.Construct(++iWindowHandle,iScreenDevice), KErrNone); - iGroup.SetOrdinalPositionErr(0, KPasswordWindowGroupPriority - 1); // Added code ---- Fastpath - iSession.Flush(); - - if (aUseOtherScreenForInfo) - { - if (iSession.NumberOfScreens()>1) - { //Create server objects for info windows to appear on alternate screen - TInt alternateScreenNum=iSession.NumberOfScreens()-1; - if (TGlobalSettings::Instance().iScreen==alternateScreenNum) - { //Alternate screen is last screen, or first screen if that is being tested. - alternateScreenNum=0; - } - - TRAP(err, iInfoScreenDevice = new (ELeave) CWsScreenDevice(iSession)); - PRINT_ON_ERROR2_L(err, _L("Failed to create second screen device: %d"), err); - ASSERT_EQUALS_X(iInfoScreenDevice->Construct(alternateScreenNum), KErrNone); - - TRAP(err, iInfoGc = new (ELeave) CWindowGc(iInfoScreenDevice)); - PRINT_ON_ERROR2_L(err, _L("Failed to create second graphics context: %d"), err); - ASSERT_EQUALS_X(iInfoGc->Construct(), KErrNone); - - iInfoGroupInstance = RWindowGroup(iSession); - ASSERT_EQUALS_X(iInfoGroupInstance.Construct(++iWindowHandle,iInfoScreenDevice), KErrNone); - iInfoGroup=&iInfoGroupInstance; - } - else - { //If alternate screen is not available then no text or compare windows should be created! - iInfoScreenDevice=iScreenDevice; //it is "convenient" for the device to still be good. - iInfoGc=NULL; - iInfoGroup=NULL; - } - } - else - { // - iInfoScreenDevice=iScreenDevice; - iInfoGc=iGc; - iInfoGroup=&iGroup; - } - - if (iInfoGroup && iInfoGc) - { - // Add a plain background window to obscure anything else that - // happens to be behind the test. Setting this window's display mode is also - // used to set the screen device display mode, and hence the composition - // mode: alpha or chroma key. - iBackground = RBlankWindow(iSession); - ASSERT_EQUALS_X(iBackground.Construct(*iInfoGroup, ++iWindowHandle), KErrNone); - - iBackground.SetOrdinalPosition(100); // Behind anything else in this group. - iBackground.SetColor(TRgb(iWhite)); - //iBackground.SetExtent(TPoint(-1000,-1000),TSize(3000,3000)); - iBackground.Activate(); - iBackground.SetVisible(ETrue); - } - iSession.Flush(); - - RWindow testTrans(iSession); - ASSERT_EQUALS_X(testTrans.Construct(iGroup, ++iWindowHandle), KErrNone); - iTransparencyEnabled=(testTrans.SetTransparencyFactor(iWhite)==KErrNone); - if (iTransparencyEnabled) - { - TTestName testName; - testName.Format(_L("Screen %i, depth %i: Found Trans Man"), - TGlobalSettings::Instance().iScreen - ); - UpdateTitleWindowL(testName,KMaxInfoLines-1); - } - else - { - TTestName testName; - testName.Format(_L("Screen %i, depth %i: No Trans Man"), - TGlobalSettings::Instance().iScreen - ); - UpdateTitleWindowL(testName,KMaxInfoLines-1); - } - testTrans.Close(); - } - - -void CWsDynamicResWinBase::CheckAndConnectScreen() - { - if (TGlobalSettings::Instance().iDisconnected) //set from script file to match wsini keyword SIMULATE_STARTUP_DISCONNECTED - { - //Verify that the display really is disconnected - ASSERT_TRUE_X(iScreenDevice != NULL); - MDisplayControl* interface = static_cast(iScreenDevice->GetInterface(MDisplayControl::ETypeId)); - ASSERT_TRUE_X(interface != NULL); - RArray resolutions; - const TInt err = interface->GetResolutions(resolutions); - ASSERT_EQUALS_X(err, KErrDisconnected); - resolutions.Close(); - } - -#ifndef MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER - //make sure display is attached to screen (only if I/F is available at compile time...) - TInt displayState = ENormalResolution; - UserSvr::HalFunction(EHalGroupDisplay | (TGlobalSettings::Instance().iScreen<<16), EDisplayHalSetDisplayState, &displayState, NULL); - Pause(200); -#endif - - if (TGlobalSettings::Instance().iDisconnected) - { - //Verify that the display now is connected - MDisplayControl* interface = static_cast(iScreenDevice->GetInterface(MDisplayControl::ETypeId)); - RArray resolutions; - const TInt err = interface->GetResolutions(resolutions); - ASSERT_EQUALS_X(err, KErrNone); - const_cast(TGlobalSettings::Instance()).iDisconnected = EFalse; - resolutions.Close(); - } - } - -/** -Common tear down code for all tests. - -Windows, group and session created are closed. Screen device is destroyed. -Surfaces, manager and update session are closed. -*/ -void CWsDynamicResWinBase::TearDownL() - { - iDoTearDown=EFalse; - if (iInfoGc!=iGc) - delete iInfoGc; - delete iGc; - if (iInfoScreenDevice!=iScreenDevice) - delete iInfoScreenDevice; - delete iScreenDevice; - - iGroup.Close(); - if (iInfoGroupInstance.WsHandle()) - iInfoGroupInstance.Close(); - iSession.Flush(); - iSession.Close(); - } -/** - * Note that this is not the ideal mechanism. - * A derived class may thinks its TearDown is safe to do from delete, but in the class it is derived from it may not be safe - **/ -void CWsDynamicResWinBase::TearDownFromDeleteL() - { - CWsDynamicResWinBase::TearDownL(); //Explicitly call the non-derived implementation. - } - -CWsDynamicResWinBase::~CWsDynamicResWinBase() -{ - if (iDoTearDown) - TearDownFromDeleteL(); //This mechanism is not entirely clean to use. -} -/** -Pause for the given number of milliseconds. - -@param aMilliseconds Time to wait in milliseconds. -*/ -void CWsDynamicResWinBase::Pause(TInt aMilliseconds) - { - User::After(TTimeIntervalMicroSeconds32(aMilliseconds * 1000)); - } -// This handles any non-member uses of the extended ASSERT_XXX macros -void TefUnitFailLeaveL() - { - - User::Leave(KErrTEFUnitFail); - } -/** - * side-effect: log the state info just before I leave! - * Note that this only logs intentional assertion failures. - * Fails due to panics or throws won't log this info. - **/ -void CWsDynamicResWinBase::TefUnitFailLeaveL() - { - for (TInt line=0;line aTitle,TRefByValue aDetail) - { - iTestName=aTitle; - iTestInfo[0]=aDetail; - - TRect screenSize(iInfoScreenDevice->SizeInPixels()); - TPoint oneThird(screenSize.iBr.iX/3,screenSize.iBr.iY/3); - TRect winSize(0,0,oneThird.iX,oneThird.iY); - - if (oneThird.iX>oneThird.iY) - { - oneThird.iY=0; - winSize.iBr.iY=screenSize.iBr.iY; - } - else - { - oneThird.iX=0; - winSize.iBr.iX=screenSize.iBr.iX; - } - winSize.Shrink(5,5); - - if (iInfoGc) - { - iTitle=RWindow(iSession); - ASSERT_EQUALS_X(iTitle.Construct(*iInfoGroup, ++iWindowHandle), KErrNone); - iTitle.SetBackgroundColor(iCyan); - iTitle.SetExtent(winSize.iTl,winSize.Size()); - iTitle.Activate(); - - RepaintTitleWindowL(); - iTitle.SetVisible(ETrue); - - winSize.Move(oneThird); - iCompare=RWindow(iSession); - ASSERT_EQUALS_X(iCompare.Construct(*iInfoGroup, ++iWindowHandle), KErrNone); - iCompare.SetBackgroundColor(COMPARE_BACKGROUND); - iCompare.SetExtent(winSize.iTl,winSize.Size()); - iCompare.Activate(); - iCompare.BeginRedraw(); - ActivateWithWipe(iInfoGc,iCompare,COMPARE_BACKGROUND); - - TFontSpec fspec(KMonospaceTestFontTypefaceName,KMaxFontSize); - CFont *font=NULL; - ASSERT_EQUALS(iScreenDevice->GetNearestFontToDesignHeightInTwips(font,fspec),KErrNone); - iInfoGc->UseFont(font); - iInfoGc->DrawText(_L("Simulation"),winSize.Size(),winSize.Size().iHeight-5,iGc->ECenter); - - iInfoGc->Deactivate(); - iCompare.EndRedraw(); - iCompare.SetVisible(ETrue); - if (iScreenDevice!=iInfoScreenDevice) - { - winSize.Move(-oneThird); - } - else - { - winSize.Move(oneThird); - } - } - else - { - winSize=iScreenDevice->SizeInPixels(); - } - - iTestPos=winSize; - iTestPointCentre=winSize.Center(); - iCenteredFrontWinRect=winSize; - iCenteredFrontWinRect.Shrink(winSize.Size().iWidth/3,winSize.Size().iHeight/3); - - } -/** Makes the compare window larger by covering the test window area as well. - * Copes with vertically aligned screens, but will be naughty if called multiple times!!! - * @param aGoLarger If set false, resets the size back. - **/ -void CWsDynamicResWinBase::LargerCompareWindow(TBool aGoLarger) - { - TPoint currPos=iCompare.AbsPosition(); - TSize currSize=iCompare.Size(); - if (currPos.iX>=1; - } - else - { - if (aGoLarger) - currSize.iWidth<<=1; - else - currSize.iWidth>>=1; - } - iCompare.SetSize(currSize); - } - - -/** Puts a line of text on the LHS window. - * Repaints the window. The line of text will also be shown in the log if the test fails. - * @param aDetail The text to display - * @param aIndex The row number to display at - **/ -void CWsDynamicResWinBase::UpdateTitleWindowL(TRefByValue aDetail,TInt aIndex) - { - ASSERT(aIndex>=0 && aIndexActivate(aWin); - aGc->SetBrushColor(aColor); - aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - if (aColor!=TRgb(0,0) && !iTransparencyEnabled) //presume that all redraw-stored windows will draw background - { - aGc->Clear(); - return ETrue; //window was cleared - } - return EFalse; - } - -CWindowGc* CWsDynamicResWinBase::GcForWindow(RWindow& aWin) - { - if (aWin.WsHandle()==NULL) - return NULL; //can't activate uninitialised window. - CWindowGc* gc=iGc; - if (iGc!=iInfoGc) - if (&aWin==&iCompare || &aWin==&iTitle) - gc=iInfoGc; - else if (iInfoGroup && aWin.WindowGroupId()==iInfoGroup->WindowGroupId()) - gc=iInfoGc; - return gc; - } -/** Activates an appropriate predefined GC on the specified window and wipes the background if necessary. - * @param aWin The window to wipe - * @param aColor The colour to wipe with (if necessary) - * @return the GC to use for drawing and deactivate at end. This may be NULL if the window is not "live" - **/ -CWindowGc* CWsDynamicResWinBase::BeginActivateWithWipe(TBool aInvalidate,RWindow& aWin,TRgb aColor) - { - CWindowGc* gc=GcForWindow(aWin); - iSession.Flush(); - if (gc==NULL) - return gc; //can't activate uninitialised window. - if (aInvalidate) - aWin.Invalidate(); - iSession.Flush(); - aWin.BeginRedraw(); - iSession.Flush(); - ActivateWithWipe(gc,aWin,aColor); - return gc; - } - -/** Activates an appropriate predefined GC on the specified window and wipes the background if necessary. - * @param aWin The window to wipe - * @param aColor The colour to wipe with (if necessary) - * @return the GC to use for drawing and deactivate at end. This may be NULL if the window is not "live" - **/ -CWindowGc* CWsDynamicResWinBase::BeginActivateWithWipe(TBool aInvalidate,TRect aRect,RWindow& aWin,TRgb aColor) - { - if (aWin.WsHandle()==NULL) - return NULL; //can't activate uninitialised window. - if (aInvalidate) - aWin.Invalidate(aRect); - aWin.BeginRedraw(aRect); - CWindowGc* gc=iGc; - if (iGc!=iInfoGc) - if (&aWin==&iCompare || &aWin==&iTitle) - gc=iInfoGc; - else if (aWin.WindowGroupId()==iInfoGroup->WindowGroupId()) - gc=iInfoGc; - ActivateWithWipe(gc,aWin,aColor); - return gc; - } - -TBool CWsDynamicResWinBase::InvalidateRegion(const TRegion& aRegion,RWindow& aWin) - { - if (aWin.WsHandle()==NULL) - return false; //can't activate uninitialised window. - for (TInt ii = 0; ii < aRegion.Count(); ii++) - { - aWin.Invalidate(aRegion[ii]); - } - return true; - } - -CWindowGc* CWsDynamicResWinBase::BeginActivateWithWipe(const TRegion& aRegion,RWindow& aWin,TRgb aColor) - { - if (!InvalidateRegion(aRegion,aWin)) - return NULL; //can't activate uninitialised window. - - aWin.BeginRedraw(); - CWindowGc* gc=iGc; - if (iGc!=iInfoGc) - if (&aWin==&iCompare || &aWin==&iTitle) - gc=iInfoGc; - else if (aWin.WindowGroupId()==iInfoGroup->WindowGroupId()) - gc=iInfoGc; - ActivateWithWipe(gc,aWin,aColor); - return gc; - } - - -/** Paints the LHS window with rows of text. - * - **/ -void CWsDynamicResWinBase::RepaintTitleWindowL() - { - if (iTitle.WsHandle()) - { - iTitle.Invalidate(); - - iTitle.BeginRedraw(); - ActivateWithWipe(iInfoGc,iTitle,TITLE_BACKGROUND); - iInfoGc->SetUnderlineStyle(EUnderlineOn); - TSize winSize=iTitle.Size(); - TRect textRect(winSize); - textRect.iBr.iY/=4; - TFontSpec fspec(KMonospaceTestFontTypefaceName,KMaxFontSize); - CFont *font=NULL; - ASSERT_EQUALS(iInfoScreenDevice->GetNearestFontToDesignHeightInTwips(font,fspec),KErrNone); - iInfoGc->UseFont(font); - iInfoGc->DrawText(iTestName,textRect,textRect.iBr.iY/2,iGc->ECenter); - iInfoGc->SetUnderlineStyle(EUnderlineOff); - textRect.iTl.iY=textRect.iBr.iY; - TInt rowHeight=winSize.iHeight*3/(4*(KMaxInfoLines+1)); - textRect.iBr.iY+=rowHeight; - for (TInt index=0;indexDrawText(iTestInfo[index],textRect,textRect.Size().iHeight*3/4,iInfoGc->ECenter); - textRect.Move(0,rowHeight); - } - iInfoGc->DiscardFont(); - iInfoGc->Deactivate(); - iTitle.EndRedraw(); - iInfoScreenDevice->ReleaseFont(font); - - iSession.Flush(); - iSession.Finish(); - } - } - -/** Useful test culled from other GCE test classes. - * - * - * - **/ -TBool CWsDynamicResWinBase::DisplayHasAlpha() const - { - return (iDisplayMode == EColor16MA || iDisplayMode == EColor16MAP); - } -/** Test using an indipendent method that GCE version of WServ is running - * This method can only be called after the testcase is started - * - * @return true if WServ version is GCE technology, false if legacy technology - **/ -TBool CWsDynamicResWinBase::GCEIsSupported() const - { - CFbsDrawDevice* screenDevice=NULL; - TDisplayMode displayMode=iScreenDevice->DisplayMode(); - TRAPD(err, screenDevice = CFbsDrawDevice::NewScreenDeviceL(TGlobalSettings::Instance().iScreen, displayMode)); - TBool rv=EFalse; - if(err == KErrNone) - { - TAny* p=NULL; - rv=(screenDevice->GetInterface(KSurfaceInterfaceID, p)==KErrNone); - delete screenDevice; - } - return rv; - } -/** Test using an indipendent method that GCE version of WServ is running - * This method can be called at any time, even by external code, but creates temporary window session objects - * - * @return true if WServ version is GCE technology, false if legacy technology - **/ -TBool CWsDynamicResWinBase::GCEIsSupportedStatic() - { - CFbsDrawDevice* screenDevice=NULL; - RWsSession session; - if (session.Connect()!=KErrNone) - { - return EFalse; - } - TDisplayMode displayMode=ENone; - {CWsScreenDevice screen(session); - if (screen.Construct(TGlobalSettings::Instance().iScreen)!=KErrNone) - { - return EFalse; - } - displayMode=screen.DisplayMode(); - }//screen destroyed - TRAPD(err, screenDevice = CFbsDrawDevice::NewScreenDeviceL(TGlobalSettings::Instance().iScreen, displayMode)); - TBool rv=EFalse; - if(err == KErrNone) - { - TAny* p=NULL; - rv=(screenDevice->GetInterface(KSurfaceInterfaceID, p)==KErrNone); - delete screenDevice; - } - return rv; - }//session destroyed -/** -Use the full-screen background window to select a display mode that doesn't use -alpha (anything other than EColor16MA or EColor16MAP). Record the mode for use -in setting all other windows. -@return ETrue if an appropriate mode was selected, EFalse otherwise. -*/ -TBool CWsDynamicResWinBase::SelectChromaCompositionMode() - { - // Request EColor64K, but as long as the actual mode doesn't use alpha, it - // doesn't matter too much which one is used. - if (iInfoGc==iGc) - { - iDisplayMode = (TDisplayMode)iBackground.SetRequiredDisplayMode(EColor64K); - iSession.Flush(); // Force switching to the display mode. - } - return !DisplayHasAlpha(); - } -/** Returns the colour used by WServ to paint holes in UI layer to reveal the GCE behind. - * The window should have a surface attached. - * If the method is called after the surface has been detached or the window was removed then - * the previous recorded hole color is returned. - **/ -TRgb CWsDynamicResWinBase::GceHoleColor( RWindowBase& aWin)const - { - if (aWin.WsHandle()==NULL) - { - return iLastGceHoleColor; - } - TRgb retVal=aWin.KeyColor(); - if (retVal==TRgb(0,0)) - { - return iLastGceHoleColor; - } - else - { - iLastGceHoleColor=retVal; - return retVal; - } - } - - -/** -Use the full-screen background window to select a display mode that can use -alpha (either EColor16MA or EColor16MAP). Record the mode for use in setting all -other windows. -@return ETrue if an appropriate mode was selected, EFalse otherwise. -*/ -TBool CWsDynamicResWinBase::SelectAlphaCompositionMode(TDisplayMode aMode) - { - // Request EColor16MA, but as long as the actual mode can use alpha, it - // doesn't matter too much which one is used. - if (iInfoGc==iGc) - { - iDisplayMode = (TDisplayMode)iBackground.SetRequiredDisplayMode(aMode); - iSession.Flush(); // Force switching to the display mode. - } - return DisplayHasAlpha(); - } - -/** - * Interesting UI pattern used by other GCE tests. - * - * - **/ -void CWsDynamicResWinBase::DrawUIContent(RWindow& aWindow) - { - aWindow.BeginRedraw(); - CWindowGc* gc=(&aWindow==&iCompare)?iInfoGc:iGc; - - gc->Activate(aWindow); - - TBool hasAlpha = DisplayHasAlpha(); - - // Draw a red-green graduated box in the central portion of the window, - // with alpha if available. - TPoint start; - TPoint end; - TInt halfW = KSurfaceWidth / 2; - TInt quarterW = halfW / 2; - TInt halfH = KSurfaceHeight / 2; - TInt quarterH = halfH / 2; - - // Set constant ordinals for non-alpha case. - start.iX = quarterW; - end.iX = quarterW + halfW; - - for (TInt yy = 0; yy < halfH; yy++) - { - TInt yval = yy * 255 / (halfH - 1); - start.iY = yy + quarterH; - end.iY = start.iY; - - if (hasAlpha) - { - for (TInt xx = 0; xx < halfW; xx++) - { - TInt xval = xx * 255 / (halfW - 1); - start.iX = xx + quarterW; - end.iX = start.iX + 1; - gc->SetPenColor(TRgb(yval, 255 - yval, 0, xval)); - gc->DrawLine(start, end); - } - } - else - { - gc->SetPenColor(TRgb(yval, 255 - yval, 0)); - gc->DrawLine(start, end); - } - } - - gc->Deactivate(); - aWindow.EndRedraw(); - } - -/** - * Causes the given window to be redrawn. - * Doesn't draw anything except the background wipe, when the transparency manager hasn't - * - **/ -void CWsDynamicResWinBase::DrawPlainUI(RWindow& aWindow,TBool aInvalidate,TRgb aWipeColor) - { - if (CWindowGc* gc=BeginActivateWithWipe(aInvalidate,aWindow,aWipeColor)) - { - //actually does nothing! - gc->Deactivate(); - aWindow.EndRedraw(); - } - } -/** - * Interesting UI pattern used by other GCE tests. - * - * - **/ -void CWsDynamicResWinBase::DrawCross(RWindow& aWindow, TRgb aColor, TInt aThickness) - { - aWindow.BeginRedraw(); - CWindowGc* gc=(&aWindow==&iCompare)?iInfoGc:iGc; - gc->Activate(aWindow); - - // Draw a red diagonal cross in the window. - gc->SetPenColor(aColor); - gc->SetPenSize(TSize(aThickness, aThickness)); - gc->DrawLine(TPoint(0, 0), TPoint(KSurfaceWidth, KSurfaceHeight)); - gc->DrawLine(TPoint(KSurfaceWidth, 0), TPoint(0, KSurfaceHeight)); - - gc->Deactivate(); - aWindow.EndRedraw(); - } - -/** - * Checks the RGB value - * - * - **/ -void CWsDynamicResWinBase::TestPixelL(TPoint aPt, TRgb aColor, TBool aMatch) - { - TRect screenArea(iScreenDevice->SizeInPixels()); - if (aPt.iX < screenArea.iTl.iX) - { - aPt.iX = screenArea.iTl.iX; - } - else if (aPt.iX >= screenArea.iBr.iX) - { - aPt.iX = screenArea.iBr.iX - 1; - } - if (aPt.iY < screenArea.iTl.iY) - { - aPt.iY = screenArea.iTl.iY; - } - else if (aPt.iY >= screenArea.iBr.iY) - { - aPt.iY = screenArea.iBr.iY - 1; - } - - TRgb pixel; - iScreenDevice->GetPixel(pixel, aPt); - if (aMatch) - { - ASSERT_EQUALS_X(pixel.Internal(), aColor.Internal()); - } - else - { - ASSERT_NOT_EQUALS_X(pixel.Internal(), aColor.Internal()); - } - } - -struct CountColour - { - TRgb iColor; - TInt iCount; - TBool operator < (const CountColour& aRhs)const - { return iColor.Value()& aColors) - { - //I am sure one of the find methods would do this, but life is too short! - TInt existingIndex; - for (existingIndex=0;existingIndexDisplayMode(); - switch (displayMode) - { - case EColor4K: - aInnerColor=aInnerColor.Color4K(aInnerColor.Color4K()); - aOuterColor=aOuterColor.Color4K(aOuterColor.Color4K()); - break; - case EColor64K: - aInnerColor=aInnerColor.Color64K(aInnerColor.Color64K()); - aOuterColor=aOuterColor.Color64K(aOuterColor.Color64K()); - break; - case EColor16M: - case EColor16MU: - case EColor16MA: - case EColor16MAP: - break; - default: - ASSERT_EQUALS(EColor16MA,displayMode); //Can't quantise color for this display mode! - } - - RArray innerColors; - innerColors.AppendL(aInnerColor); - RArray outerColors; - outerColors.AppendL(aOuterColor); - TInt cornerSize=aExpectedCornerSize>=0?aExpectedCornerSize:-aExpectedCornerSize; - //Check outside first! - TRgb pixelVal; - for(TPoint pixelPos(aRect.iTl.iX-1,aRect.iTl.iY-1);pixelPos.iXGetPixel(pixelVal, pixelPos); - LogColorL(pixelVal,outerColors); - } - for(TPoint pixelPos(aRect.iTl.iX,aRect.iBr.iY);pixelPos.iX<=aRect.iBr.iX;pixelPos.iX++) - { - iScreenDevice->GetPixel(pixelVal, pixelPos); - LogColorL(pixelVal,outerColors); - } - for(TPoint pixelPos(aRect.iTl.iX-1,aRect.iTl.iY);pixelPos.iY<=aRect.iBr.iY;pixelPos.iY++) - { - iScreenDevice->GetPixel(pixelVal, pixelPos); - LogColorL(pixelVal,outerColors); - } - for(TPoint pixelPos(aRect.iBr.iX,aRect.iTl.iY-1);pixelPos.iYGetPixel(pixelVal, pixelPos); - LogColorL(pixelVal,outerColors); - } - TInt cornerStart=1; - if (cornerSize) - { - cornerStart=cornerSize; - if (aExpectedCornerSize>0) - { - iScreenDevice->GetPixel(pixelVal, aRect.iTl); - LogColorL(pixelVal,outerColors); - iScreenDevice->GetPixel(pixelVal, TPoint(aRect.iTl.iX,aRect.iBr.iY-1)); - LogColorL(pixelVal,outerColors); - iScreenDevice->GetPixel(pixelVal, TPoint(aRect.iBr.iX-1,aRect.iTl.iY)); - LogColorL(pixelVal,outerColors); - iScreenDevice->GetPixel(pixelVal, TPoint(aRect.iBr.iX-1,aRect.iBr.iY-1)); - LogColorL(pixelVal,outerColors); - } - } - - //test inside edges (excluding 4 corner pixels - do them seperately) - for(TPoint pixelPos(aRect.iTl.iX+cornerStart,aRect.iTl.iY);pixelPos.iXGetPixel(pixelVal, pixelPos); - LogColorL(pixelVal,innerColors); - } - for(TPoint pixelPos(aRect.iTl.iX+cornerStart,aRect.iBr.iY-1);pixelPos.iXGetPixel(pixelVal, pixelPos); - LogColorL(pixelVal,innerColors); - } - for(TPoint pixelPos(aRect.iTl.iX,aRect.iTl.iY+cornerStart);pixelPos.iYGetPixel(pixelVal, pixelPos); - LogColorL(pixelVal,innerColors); - } - for(TPoint pixelPos(aRect.iBr.iX-1,aRect.iTl.iY+cornerStart);pixelPos.iYGetPixel(pixelVal, pixelPos); - LogColorL(pixelVal,innerColors); - } - //the 4 corner cells - not checking the whole corner area... - if (aExpectedCornerSize>=0) - { - iScreenDevice->GetPixel(pixelVal, TPoint(aRect.iTl.iX+cornerSize,aRect.iTl.iY+cornerSize)); - LogColorL(pixelVal,innerColors); - iScreenDevice->GetPixel(pixelVal, TPoint(aRect.iTl.iX+cornerSize,aRect.iBr.iY-1-cornerSize)); - LogColorL(pixelVal,innerColors); - iScreenDevice->GetPixel(pixelVal, TPoint(aRect.iBr.iX-1-cornerSize,aRect.iBr.iY-1-cornerSize)); - LogColorL(pixelVal,innerColors); - iScreenDevice->GetPixel(pixelVal, TPoint(aRect.iBr.iX-1-cornerSize,aRect.iTl.iY+cornerSize)); - LogColorL(pixelVal,innerColors); - } - //OK... that has tested all the pixels, now check the result - if (innerColors.Count()>aOtherInnerColors+1) - return EFalse; - if (outerColors.Count()>aOtherOuterColors+1) - return EFalse; - for (TInt index=1;indexendy) - { //swap // s e - starty-=endy; // s-e - endy+=starty; // s - starty=endy-starty; // e - } - if (startx>endx) - { //swap // s e - startx-=endx; // s-e - endx+=startx; // s - startx=endx-startx; // e - } - TSize fullSize=aFullRect.Size(); - return TRect( aFullRect.iTl.iX+fullSize.iWidth*startx/5, - aFullRect.iTl.iY+fullSize.iHeight*starty/5, - aFullRect.iTl.iX+fullSize.iWidth*(endx+1)/5, - aFullRect.iTl.iY+fullSize.iHeight*(endy+1)/5 - ); - } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tdynamicres/src/wsdynamicresbase.cpp --- a/windowing/windowserver/tdynamicres/src/wsdynamicresbase.cpp Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,603 +0,0 @@ -// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -#include -#include "wsdynamicresbase.h" -#include "teflogextensions.h" -#include "globalsettings.h" -#include -#include -#include -#include -#include "regionextend.h" - - -#if defined(__X86GCC__) -extern "C" TInt atexit(void (*function)(void)) - { - return KErrNone; - } -#endif - -CWsDynamicResBase::CWsDynamicResBase(): - iUtility(this) - { - } - -CWsDynamicResBase::~CWsDynamicResBase() - { - } - -/** -Common set up code for all tests. - -Creates the session and window group for further windows, plus a simple white -background to obscure any unwanted stuff behind the test. Sets up the surface -update session and surface manager, to work with surfaces. Creates a screen -device for use in the tests. -*/ -void CWsDynamicResBase::SetupL() - { - SetupL(EFalse); - } -void CWsDynamicResBase::SetupL(TBool aUseOtherScreenForInfo) - { - CWsDynamicResWinBase::SetupL(aUseOtherScreenForInfo); - - -//clean-up if previous test abended - if (PostTestCleanupInstance().iSharedUtility) - { -//Temp removed - may be causing ONB fails! -// if (PostTestCleanupInstance().iSharedUtility->DestroyAll()) -// { -// INFO_PRINTF1(_L("Destroyed some surfaces from previous test.")); -// -// } - } - if (!PostTestCleanupInstance().iCleanedUpOnExit) - PostTestCleanupInstance().iCleanedUpOnExit=EFalse; - - if (!GCEIsSupported()) - { - INFO_PRINTF1(_L("Some Setup skipped: GCE support is not loaded")); - return; - } - - TRAPD(err_FailedToCreateSurfaceUtility, iUtility = CSurfaceUtility::NewL( PostTestCleanupInstance().iSharedUtility)); - ASSERT_EQUALS(err_FailedToCreateSurfaceUtility,KErrNone); - - - } - -/** -Common tear down code for all tests. - -Windows, group and session created are closed. Screen device is destroyed. -Surfaces, manager and update session are closed. -*/ -void CWsDynamicResBase::TearDownL() - { - CWsDynamicResWinBase::TearDownL(); - delete iUtility(); - PostTestCleanupInstance().iCleanedUpOnExit=ETrue; - //Pause(1000); - } -/** - * Note that this is not the ideal mechanism. - * A derived class may thinks its TearDown is safe to do from delete, but in the class it is derived from it may not be safe - **/ -void CWsDynamicResBase::TearDownFromDeleteL() - { - CWsDynamicResBase::TearDownL(); - } - -//Allocating an instance of surface utility here means all test code instances will share the same instance of the utility class. -// Owns the singleton -/*static*/ const CWsDynamicResBase::TPostTestCleanup& CWsDynamicResBase::PostTestCleanupInstance() - { - static - class RPostTestCleanup:public TPostTestCleanup - { - public: - RPostTestCleanup() - { - iSharedUtility=NULL; - iCleanedUpOnExit=ETrue; - } - ~RPostTestCleanup() - { - // I want to cleanly release the surface utility, but at this point the threads have already been pulled down! - // if (iSharedUtility) - // delete iSharedUtility; - iSharedUtility=NULL; //avoid phoenix behaviour - } - } staticInstance; - return staticInstance; - } - -void CWsDynamicResBase::TPostTestCleanup::CreateSharedUtilityL()const - { - if (iSharedUtility==NULL) - iSharedUtility=CSurfaceUtility::NewL(); - } - -/** -Pause for the given number of milliseconds. - -@param aMilliseconds Time to wait in milliseconds. -*/ -void CWsDynamicResBase::Pause(TInt aMilliseconds) - { - User::After(TTimeIntervalMicroSeconds32(aMilliseconds * 1000)); - } - -/** Creates the normal scenario used by these tests. - * With a large window behind and small window in front. - * If the windows already exist then they are just repositioned and redrawn. - * @param aOuterRect Position of back window - * @param aOuterColor Background colour for back window - * @param aInnerRect Position of front window - * @param aInnerColor Background colour for front window - * - **/ -void CWsDynamicResBase::MakeTestWindowPairL(TRect aOuterRect,TRgb aOuterColor,TRect aInnerRect,TRgb aInnerColor) - { - if (!iTestBack.WsHandle()) - { - iTestBack=RWindow(iSession); - ASSERT_EQUALS_X(iTestBack.Construct(iGroup, ++iWindowHandle), KErrNone); -#ifdef FLICKER - iTestBack.Activate(); -#endif - iTestBack.SetRequiredDisplayMode(iDisplayMode); - iTestBack.SetBackgroundColor(aOuterColor); - iTestBack.SetExtent(aOuterRect.iTl,aOuterRect.Size()); -#ifndef FLICKER - iTestBack.Activate(); -#endif - } - else - { - iTestBack.SetRequiredDisplayMode(iDisplayMode); - iTestBack.SetBackgroundColor(aOuterColor); - iTestBack.SetExtent(aOuterRect.iTl,aOuterRect.Size()); - } - iTestBack.BeginRedraw(); - ActivateWithWipe(iGc,iTestBack,aOuterColor); - iGc->Deactivate(); - iTestBack.EndRedraw(); - iTestBack.SetVisible(ETrue); - - if (!iTestFront.WsHandle()) - { - iTestFront=RWindow(iSession); - ASSERT_EQUALS_X(iTestFront.Construct(iGroup, ++iWindowHandle), KErrNone); -#ifdef FLICKER - iTestFront.Activate(); -#endif - iTestFront.SetRequiredDisplayMode(iDisplayMode); - iTestFront.SetBackgroundColor(aInnerColor); - iTestFront.SetExtent(aInnerRect.iTl,aInnerRect.Size()); - -#ifndef FLICKER - iTestFront.Activate(); -#endif - } - else - { - iTestFront.SetRequiredDisplayMode(iDisplayMode); - iTestFront.SetBackgroundColor(aInnerColor); - iTestFront.SetExtent(aInnerRect.iTl,aInnerRect.Size()); - } - - DrawPlainUI(iTestFront,EFalse,aInnerColor); - iTestFront.SetVisible(ETrue); - - } - -void CWsDynamicResBase::LargerTestWindow(TInt aPercentOfBack) - { - TRect newPos=iTestPos; - TSize backSize=iTestPos.Size(); - newPos.Grow((aPercentOfBack-100)*backSize.iWidth/200,(aPercentOfBack-100)*backSize.iHeight/200); - iCenteredFrontWinRect=newPos; - if (iTestFront.WsHandle()) - { - iTestFront.SetExtent(newPos.iTl,newPos.Size()); - } - - } - -/** Destroys some or all of the test windows so the test can loop (or test the state after destruction. - * The windows are destroyed when the test exits normally. - * Child windows are automatically killed when parent window is killed! - * - **/ -void CWsDynamicResBase::DestroyTestWindowPair(TBool aKillTestBack,TBool aKillTestFront,TBool aKillTestChildren) - { - if (aKillTestBack && iTestBack.WsHandle()) - { - iTestBack.Close(); - } - if (aKillTestFront && iTestFront.WsHandle()) - { - iTestFront.Close(); - } - if (aKillTestChildren) - { - if (iTestChild.WsHandle()) - { - iTestChild.Close(); - } - if (iTestSecondChild.WsHandle()) - { - iTestSecondChild.Close(); - } - } - } -/** Creates a child window inside the front window of the usual test scenario -* With a large window behind and small window in front. - * If the windows already exist then they are just repositioned and redrawn. - * @param aOuterRect Position of back window - * @param aOuterColor Background colour for back window - * @param aInnerRect Position of front window - * @param aInnerColor Background colour for front window - * @param aChildRect Position of child window - * @param aChildColor Background colour for child window - * @param aSecondChildRect Position of Second child window - * @param aSecondChildColor Background colour for Second child window - * - **/ -void CWsDynamicResBase::MakeTestWindowTripleL(TRect aOuterRect,TRgb aOuterColor,TRect aInnerRect,TRgb aInnerColor,TRect aChildRect,TRgb aChildColor,TRect aSecondChildRect,TRgb aSecondChildColor) - { - MakeTestWindowTripleL(aOuterRect,aOuterColor,aInnerRect,aInnerColor,aChildRect,aChildColor); - - MakeExtraChildWindowL(iTestChild,aSecondChildRect,aSecondChildColor); - } - -/** Creates a child window inside the front window of the usual test scenario -* With a large window behind and small window in front. - * If the windows already exist then they are just repositioned and redrawn. - * @param aOuterRect Position of back window - * @param aOuterColor Background colour for back window - * @param aInnerRect Position of front window - * @param aInnerColor Background colour for front window - * @param aChildRect Position of child window - * @param aChildColor Background colour for child window - * @param aSecondChildRect Position of second child window - * @param aSecondChildColor Background colour for second child window - * - **/ -void CWsDynamicResBase::CreateTestWindowQuadL(TRect aOuterRect,TRgb aOuterColor,TRect aInnerRect,TRgb aInnerColor,TRect aChildRect,TRgb aChildColor,TRect aSecondChildRect,TRgb aSecondChildColor) - { - MakeTestWindowTripleL(aOuterRect,aOuterColor,aInnerRect,aInnerColor,aChildRect,aChildColor); - - MakeExtraChildWindowL(iTestFront,aSecondChildRect,aSecondChildColor); - } - -void CWsDynamicResBase::MakeExtraChildWindowL(const RWindowBase& aFromParent,TRect aChildRect,TRgb aChildColor) - { - ASSERT(aFromParent.WsHandle()); - if (!iTestSecondChild.WsHandle()) - { - iTestSecondChild=RWindow(iSession); - ASSERT_EQUALS_X(iTestSecondChild.Construct(aFromParent, ++iWindowHandle), KErrNone); - iTestSecondChild.SetRequiredDisplayMode(iDisplayMode); - } - iTestSecondChild.SetBackgroundColor(aChildColor); - iTestSecondChild.SetExtent(aChildRect.iTl,aChildRect.Size()); - iTestSecondChild.Activate(); - iTestSecondChild.BeginRedraw(); - iGc->Activate(iCompare); - iGc->SetBrushColor(iBlue); - iGc->Clear(); - iGc->Deactivate(); - iTestSecondChild.EndRedraw(); - iTestSecondChild.SetVisible(ETrue); - } - -CWsDynamicResBase::LoopingGcPtr CWsDynamicResBase::LoopBeginActivateWithWipe(const TRegion& aRegion,RWindow& aWin,TRgb aColor) - { - InvalidateRegion(aRegion,aWin); - return LoopingGcPtr(aRegion,aWin,aColor,GcForWindow(aWin)); - } - -//This gets called each itteration of the while loop, and is used to step the rectangle count! -void CWsDynamicResBase::LoopingGcPtr::operator ++() - { - iPass++; - if (iPassActivate(iCompare); - iGc->SetBrushColor(iBlue); - iGc->Clear(); - iGc->Deactivate(); - iTestChild.EndRedraw(); - iTestChild.SetVisible(ETrue); - } -/** - * Generates a valid surfaceID for the current display mode. - * This is then used in negative testing. - * - * - **/ -void CWsDynamicResBase::UISurfaceL(TSurfaceId& aSurfaceId) const - { - CFbsDrawDevice* screenDevice=NULL; - TDisplayMode displayMode=iScreenDevice->DisplayMode(); - screenDevice = CFbsDrawDevice::NewScreenDeviceL(TGlobalSettings::Instance().iScreen, displayMode); - CleanupStack::PushL(screenDevice); - TAny* p=NULL; - User::LeaveIfError(screenDevice->GetInterface(KSurfaceInterfaceID, p)); - MSurfaceId* uiSurface = static_cast(p); - uiSurface->GetSurface(aSurfaceId); - CleanupStack::PopAndDestroy(screenDevice); - } - -/** -Common set up code for creating a surface based window. - -Given window and surface objects and a color: creates the window and surface, -sets the window to a default size (the same as the surface), sets the background -to the bitwise inverse of the given color, sets the surface as the background, -fills the surface with the color and completes a redraw to prevent an event. - -@param aWindow The window object, connected to a session. -@param aSurface The surface object, to be initialized. -@param aColor The color to fill the surface with. -*/ -void CWsDynamicResBase::CommonSurfaceWindowSetupL(RWindow& aWindow, TSurfaceId& aSurface, const TRgb& aColor) - { - TInt err = KErrNone; - - TRAP(err, aSurface = iUtility->CreateSurfaceL(TSize(KSurfaceWidth, KSurfaceHeight), - KSurfaceFormat, KSurfaceWidth * KBytesPerPixel)); - PRINT_ON_ERROR2_L(err, _L("Failed to create surface: %d"), err); - ASSERT_EQUALS_X(aWindow.Construct(iGroup, ++iWindowHandle), KErrNone); - - aWindow.SetRequiredDisplayMode(iDisplayMode); - aWindow.SetExtent(TPoint(0, 0), TSize(KSurfaceWidth, KSurfaceHeight)); - aWindow.SetBackgroundColor(TRgb(aColor.Value() ^ 0xFFFFFF)); - - ASSERT_EQUALS_X(aWindow.SetBackgroundSurface(aSurface), KErrNone); - - TRAP(err, iUtility->FillSurfaceL(aSurface, aColor)); - PRINT_ON_ERROR2_L(err, _L("Failed to fill surface: %d"), err); - DrawUIContent(aWindow); - } - -/** -Common set up code for resizing tests. - -Similar to the common surface window code, but filling the surface with a grid -instead of a solid color. The grid lines are always black. Also, the background -color is always blue. -*/ -void CWsDynamicResBase::ResizeTestCommonSetupL(RWindow& aWindow, const TRgb& aColor) - { - // Session and group created in SetUpL() - - TSurfaceId surface; - TInt err = KErrNone; - - TRAP(err, surface = iUtility->CreateSurfaceL(TSize(KSurfaceWidth, KSurfaceHeight), - KSurfaceFormat, KSurfaceWidth * KBytesPerPixel)); - PRINT_ON_ERROR2_L(err, _L("Failed to create surface: %d"), err); - - ASSERT_EQUALS_X(aWindow.Construct(iGroup, ++iWindowHandle), KErrNone); - - aWindow.SetRequiredDisplayMode(iDisplayMode); - aWindow.SetExtent(TPoint(0, 0), TSize(KSurfaceWidth, KSurfaceHeight)); - aWindow.SetBackgroundColor(iBlue); - ASSERT_EQUALS_X(aWindow.SetBackgroundSurface(surface), KErrNone); - - TRAP(err, iUtility->GridFillSurfaceL(surface, aColor, TRgb(0))); - PRINT_ON_ERROR2_L(err, _L("Failed to grid fill surface: %d"), err); - DrawUIContent(aWindow); - } - -CFbsBitmap* CWsDynamicResBase::RotateBitmapLC(const CFbsBitmap* aSrcBitmap) - { - CFbsBitmap* rv=new CFbsBitmap; - CleanupStack::PushL(rv); - TSize srcSize=aSrcBitmap->SizeInPixels(); - rv->Create(TSize(srcSize.iHeight,srcSize.iWidth),EColor16MA); - TRgb* linestore=new TRgb[srcSize.iHeight]; - TPtr8 buff((unsigned char*)linestore,srcSize.iHeight*sizeof(TRgb),srcSize.iHeight*sizeof(TRgb)); - for (TInt col=0;colSizeInPixels().iWidth;col++) - { - for (TInt row=0,brow=srcSize.iHeight-1;rowGetPixel(linestore[row],TPoint(col,brow)); - } - rv->SetScanLine(buff,col); - } - delete[] linestore; - return rv; - } - - -// -// -// -// Pattern checking. Is a given pattern still present? -// To make life interesting, the pattern is stored backwards! -// The pattern is fibonnacci sequence masked to byte: -// 1 2 3 5 8 13 21 34 55 89 144 233 121 -// 98 219 61 24 85 109 194 47 241 32 17 49 66 -// 115 181 40 221 5 226 231 201 176 121 41 162 -// -// -void Pattern::Fill(void* aTrg,TInt aOffset,TInt aLength) - { - unsigned char* ptr=(unsigned char*)aTrg; - TInt a=0; - TInt b=1; - while (--aLength) - { - TInt c=a+b; - *(ptr+aOffset+aLength)=c&0xff; - a=b; - b=c; - } - } -TBool Pattern::Check(void* aTrg,TInt aOffset,TInt aLength) - { - unsigned char* ptr=(unsigned char*)aTrg; - TInt a=0; - TInt b=1; - while (--aLength) - { - TInt c=a+b; - if (*(ptr+aOffset+aLength)!=c&0xff) - return EFalse; - a=b; - b=c; - } - return ETrue; - } -TBool Pattern::CheckVal(void* aTrg,TInt aOffset,TInt aLength,char val) - { - unsigned char* ptr=(unsigned char*)aTrg; - while (--aLength) - { - if (*(ptr+aOffset+aLength)!=val&0xff) - return EFalse; - } - return ETrue; - } - -//I have removed these only because they use TRegionExtend -// -//TInt CWsDynamicResBase::RegionDiffForUiLayer(TInt aUiLayer) -// { -// EWsDebugGetUILayerConfig, //return: TSurfaceConfig //Index UI layer via EWsDebugArgLayerMask -// EWsDebugGetUILayerBase, //return: TRect[] -// -// RRegion layerRegion; -// TInt layerRegionLen=iSession.DebugInfo(EWsDebugGetUILayerBase,iSession.ObjInd(0,aUiLayer),layerRegion); -// if (layerRegionLen==KErrCancel) -// return TRegionExtend::EExact; -// ASSERT_TRUE(layerRegionLen>=0); -// TBuf8 configBuf(sizeof(TSurfaceConfiguration)); -// const TSurfaceConfiguration* config; -// TInt configLen=iSession.DebugInfo(EWsDebugGetUILayerConfig,iSession.ObjInd(0,aUiLayer),configBuf,config); -// ASSERT_TRUE(configLen>=0); -// TRect layerExtent; -// config->GetExtent(layerExtent); -// TInt retVal=TRegionExtend::Cast(layerRegion).TestDifference(layerExtent.Size()); -// layerRegion.Close(); -// return retVal; -// } -//CWsDynamicResBase::FastPathMode CWsDynamicResBase::DeduceUiFastPathMode() -// { -// TInt blendedRegionState=RegionDiffForUiLayer(0); -// TInt opaqueRegionState=RegionDiffForUiLayer(1); -// if (blendedRegionState&TRegionExtend::ENoIntersect) -// { -// if (opaqueRegionState&TRegionExtend::ENoIntersect) -// { -// return EFpExternalOpaque; //fullscreen fast-path external surface -// } -// else -// if (opaqueRegionState&TRegionExtend::EAdd) -// { -// return (FastPathMode)(EFpUiOpaque|EFpUiRegions); //windowed max-opt no blending -// } -// else -// { -// return EFpUiOpaque; //full-screen fastpath -// } -// } -// else -// { -// if (opaqueRegionState&TRegionExtend::ENoIntersect) -// { -// if (blendedRegionState&TRegionExtend::EAdd) -// { -// return (FastPathMode)(EFpUiBlended|EFpUiRegions); //windowed max-opt no opaque -// } -// else -// { -// return (EFpUiBlended); //full-screen blended -// } -// } -// else -// { -// if ((blendedRegionState|opaqueRegionState)&TRegionExtend::EAdd) -// { -// return (FastPathMode)(EFpUiComplex|EFpUiRegions); //moxed blending, opaque and external max optimisation -// } -// else -// { -// return EFpUiComplex; //Error! blend and opaque both enabled and full-screen! -// } -// } -// -// } -// } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tdynamicres/src/wsdynamicresbasic.cpp --- a/windowing/windowserver/tdynamicres/src/wsdynamicresbasic.cpp Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,4540 +0,0 @@ -// Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file -*/ -#include "wsdynamicresbasic.h" -#include -#include "globalsettings.h" -#include -#include -#include "regionextend.h" -#include -#include -#include -#include -#include "surfaceutility.h" -#include - -//verify which base code is available to the test -#include -#if (!defined(K_DISPLAY_CH_MAJOR_VERSION_NUMBER) && !defined(K_DISPLAY_CH_MINOR_VERSION_NUMBER)) -#define MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER -#endif - - -//#define VISIBLE_PAUSES 1000 -#define OVERLAPPING_CELL 0 //'m' //0 indicates cells do not overlap -/* - * CWsGceTestPlaceSurfExtra implementation - * - * - * - * - */ -CWsDynamicResBasic::CWsDynamicResBasic() -{ -} - -CWsDynamicResBasic::~CWsDynamicResBasic() -{ -} - -void CWsDynamicResBasic::SetupL() - { - MyBase::SetupL(); - } -void CWsDynamicResBasic::TearDownL() - { - MyBase::TearDownL(); - - } -void CWsDynamicResBasic::TearDownFromDeleteL() - { - MyBase::TearDownFromDeleteL(); - } - - -CTestSuite* CWsDynamicResBasic::CreateSuiteL( const TDesC& aName ) - { - //Create the surface manager here, before the test suite creates additional threads - if (GCEIsSupportedStatic()) - { - TRAP_IGNORE(PostTestCleanupInstance().CreateSharedUtilityL()); - } - - SUB_SUITE_OPT(CWsDynamicResBasic,NULL); - - //BASIC - ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0001L); - ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0002L); - ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0003L); - ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0004L); - ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0005L); - ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0006L); - ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0007L); - ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0008L); - ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0009L); - ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0010L); //only run on screen 1 - ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0011L); - ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0012L); //only run on screen 0 - ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0013L); - ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0014L); //only run on screen 1 - ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0015L); //only run with no scaling - ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0016L); //only run with anisotropic scaling - ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0017L); //only run with integer scaling - ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0018L); - - ADD_TEST_STEP_PARAM_BOOL(GRAPHICS_WSERV_DYNAMICRES_0021L); //only run on screen 1 - - //OOM - ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0031L); - ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0032L); - ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0033L); - ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0034L); //dont run with no scaling on screen 0 - - //SCREEN CAPTURE - ADD_TEST_STEP_PARAM_BOOL(GRAPHICS_WSERV_DYNAMICRES_0041L); - ADD_TEST_STEP_PARAM_BOOL(GRAPHICS_WSERV_DYNAMICRES_0042L); - - //DYNAMIC SCREEN MODE - only run these with no scaling and isotropic scaling - ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0051L); - ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0052L); //only run on screen 1 (multiple resolutions) - ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0053L); - - //DEFECT - ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0101L); - ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0102L); - - END_SUITE; - } - -#define LOG_AND_PANIC_IF_NOT_GCE \ - { \ - if (!GCEIsSupported()) \ - { \ - INFO_PRINTF1(_L("Test skipped: GCE support is not loaded")); \ - User::Panic(_L("GCE.Wrong.Mode"),1); \ - return; \ - } \ - } - -CWsDisplayEvent::CWsDisplayEvent(RWsSession *aWs): -CActive(EPriorityStandard), iWs(aWs), iConfigSpinner(0), iResListSpinner(0),iReceivedEventCount(0), -iReceivedPointerEventCount(0), iPointerPosTestPass(ETrue) - { - CActiveScheduler::Add(this); - } -CWsDisplayEvent::~CWsDisplayEvent() - { - Cancel(); - } - -void CWsDisplayEvent::DoCancel() - { - iWs->EventReadyCancel(); - } - -void CWsDisplayEvent::Request() - { - iWs->EventReady(&iStatus); - SetActive(); - } - -void CWsDisplayEvent::RunL() - { - TWsEvent event; - iWs->GetEvent(event); - - if(iStatus == KErrNone) - { - switch(event.Type()) - { - case EEventScreenDeviceChanged: - { - iReceivedDeviceEventCount++; - } - case EEventPointer: - { - iReceivedPointerEventCount++; - TPointerEvent* ptEvent = event.Pointer(); - //make 1 pixels distance allowance, as non integer scalling from composition to app may occur - //1 pixels allowance because we never scale greater than 2 times - if(ptEvent->iPosition.iX < iPointerPos.iX - 1 && ptEvent->iPosition.iX > iPointerPos.iX + 1 - && ptEvent->iPosition.iY < iPointerPos.iY - 1 &&ptEvent->iPosition.iY > iPointerPos.iY + 1) - { - iPointerPosTestPass = EFalse; - } - } - case EEventDisplayChanged: - { - iConfigSpinner = event.DisplayChanged()->iConfigurationChangeId; - iResListSpinner = event.DisplayChanged()->iResolutionListChangeId; - iReceivedEventCount++; - } - break; - default: - break; - } - } - else - User::Leave(iStatus.Int()); - - Request(); - } - -CEventTimer* CEventTimer::NewL() - { - CEventTimer* self = new (ELeave) CEventTimer; - CleanupStack::PushL(self); - self->ConstructL(); - CleanupStack::Pop(self); - return self; - } - -void CEventTimer::ConstructL() - { - User::LeaveIfError(iTimer.CreateLocal()); - CActiveScheduler::Add(this); - } - -CEventTimer::CEventTimer() : CActive(EPriorityStandard) - { - - } - -CEventTimer::~CEventTimer() - { - Cancel(); - iTimer.Close(); - } - -void CEventTimer::DoCancel() - { - iTimer.Cancel(); - CActiveScheduler::Stop(); - } - -void CEventTimer::RunL() - { - CActiveScheduler::Stop(); - } - -void CEventTimer::Wait(TInt aDelay) - { - iTimer.After(iStatus, aDelay); - SetActive(); - CActiveScheduler::Start(); - } - -//Set display state to normal and to the first decent resolution -//A failed test could leave it in a bad state -void CWsDynamicResBasic::ResetScreens() - { - Pause(1000); -#ifndef MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER - TInt displayState = ENormalResolution; - UserSvr::HalFunction(EHalGroupDisplay | (iScreenDevice->GetScreenNumber()<<16), EDisplayHalSetDisplayState, &displayState, NULL); -#endif - MDisplayControl* interface = static_cast - (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); - ASSERT_TRUE(interface); - - RArray appModeIndexList; - TInt currMode=iScreenDevice->CurrentScreenMode(); - iScreenDevice->GetScreenSizeModeList(&appModeIndexList); - if (appModeIndexList[0]!=currMode) - { - iScreenDevice->SetAppScreenMode(appModeIndexList[0]); - iScreenDevice->SetScreenMode(appModeIndexList[0]); - } - appModeIndexList.Close(); - - TInt resolutions = interface->NumberOfResolutions(); - ASSERT_TRUE (resolutions > 0); - RArray resolutionList1; - TInt error = interface->GetResolutions(resolutionList1); - ASSERT_EQUALS(error,KErrNone); - ASSERT_EQUALS(resolutionList1.Count(), resolutions); - TDisplayConfiguration config; - TInt goodRes=0; - if (resolutionList1[goodRes].iPixelSize==TSize()) - { - goodRes++; - ASSERT_TRUE(resolutions>goodRes); //First res was blank, and no more to choose! - } - config.SetResolution(resolutionList1[goodRes].iPixelSize); - error=interface->SetConfiguration(config); - ASSERT_EQUALS(error,KErrNone); - resolutionList1.Close(); - } - -/** -@SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0001L -@SYMTestCaseDesc WSERV Screen Device GetInterface returns known interface -@SYMREQ REQ10325 -@SYMPREQ PREQ2102 -@SYMTestType CT -@SYMTestPriority 1 -@SYMTestPurpose Basic classic behaviour -@SYMTestActions - Call GetInterface with a well known GUID -@SYMTestExpectedResults - Returns a pointer -*/ -void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0001L() - { - LOG_AND_PANIC_IF_NOT_GCE; - MakeTitleAndCompareWindowsL(_L("GRAPHICS_WSERV_DYNAMICRES_0001L"),_L("Basic Dynamic Resolution test")); - - MDisplayControlBase* interface1 = static_cast - (iScreenDevice->GetInterface(MDisplayControlBase::ETypeId)); - ASSERT_TRUE(interface1); - - MDisplayControl* interface2 = static_cast - (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); - ASSERT_TRUE(interface2); - - MDisplayMappingBase* interface3 = static_cast - (iScreenDevice->GetInterface(MDisplayMappingBase::ETypeId)); - ASSERT_TRUE(interface3); - - MDisplayMapping* interface4 = static_cast - (iScreenDevice->GetInterface(MDisplayMapping::ETypeId)); - ASSERT_TRUE(interface4); - } - -/** -@SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0002L -@SYMTestCaseDesc Basic test for NumberOfResolutions -@SYMREQ REQ10328 -@SYMPREQ PREQ2102 -@SYMTestType CT -@SYMTestPriority 1 -@SYMTestPurpose NumberOfResolutions returns correctly -@SYMTestActions - GetInterface - then call NumberOfResolutions. -@SYMTestExpectedResults - It shouldn't return KErrNotSupported -*/ -void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0002L() - { - LOG_AND_PANIC_IF_NOT_GCE; - MDisplayControl* interface = static_cast - (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); - ASSERT_TRUE(interface); - TInt resolutions = interface->NumberOfResolutions(); - ASSERT_TRUE (resolutions != KErrNotSupported); - } - -/** -@SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0003L -@SYMTestCaseDesc Basic test for GetResolutions -@SYMREQ REQ10328 -@SYMPREQ PREQ2102 -@SYMTestType CT -@SYMTestPriority -@SYMTestPurpose Check GetResolutions returns a valid TSize RArray -@SYMTestActions - GetInterface - Call NumberOfResolutions - Create an array and garbage fill based on amount of resolutions - Call GetResolutions on this array - Create an array (dont garbage fill) - Call GetResolutions on this empty array - Create an array with smaller size than required - Call GetResolutions on this array - Create an array with larger size than required - Call GetResolutions on this array -@SYMTestExpectedResults - For both GetResolutions calls, it should allocate memory if needed, and fill - with correct sizes -*/ -void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0003L() - { - LOG_AND_PANIC_IF_NOT_GCE; - TInt count; - TInt error; - - MDisplayControl* interface = static_cast - (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); - ASSERT_TRUE(interface); - - TInt resolutions = interface->NumberOfResolutions(); - ASSERT_TRUE (resolutions > 0); - - RArray resolutionList1; - for (count=0;countGetResolutions(resolutionList1); - ASSERT_EQUALS(error,KErrNone); - ASSERT_EQUALS(resolutionList1.Count(), resolutions); - - RArray resolutionList2; - error = interface->GetResolutions(resolutionList2); - ASSERT_EQUALS(error,KErrNone); - ASSERT_EQUALS(resolutionList2.Count(), resolutions); - - RArray resolutionList3; - for (count=0;countGetResolutions(resolutionList3); - ASSERT_EQUALS(error,KErrNone); - ASSERT_EQUALS(resolutionList3.Count(), resolutions); - - RArray resolutionList4; - for (count=0;countGetResolutions(resolutionList4); - ASSERT_EQUALS(error,KErrNone); - ASSERT_EQUALS(resolutionList4.Count(), resolutions); - - for (count=0;count - (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); - ASSERT_TRUE(interface); - - TDisplayConfiguration dispConfig; - interface->GetConfiguration(dispConfig); - ASSERT_TRUE(dispConfig.IsDefined(TDisplayConfigurationBase::EResolution)); - TSize size; - TSize twips; - ASSERT_TRUE(dispConfig.GetResolution(size)); - ASSERT_TRUE(dispConfig.GetResolutionTwips(twips)); - - TDisplayConfiguration dispConfig1(TDisplayConfiguration().Version() + 10); - interface->GetConfiguration(dispConfig1); - ASSERT_TRUE(dispConfig1.IsDefined(TDisplayConfigurationBase::EResolution)); - TSize size1; - TSize twips1; - ASSERT_TRUE(dispConfig1.GetResolution(size1)); - ASSERT_TRUE(dispConfig1.GetResolutionTwips(twips1)); - - TDisplayConfiguration dispConfig2(TDisplayConfiguration1().Version()); - interface->GetConfiguration(dispConfig2); - ASSERT_TRUE(dispConfig2.IsDefined(TDisplayConfigurationBase::EResolution)); - TSize size2; - TSize twips2; - ASSERT_TRUE(dispConfig2.GetResolution(size2)); - ASSERT_TRUE(dispConfig2.GetResolutionTwips(twips2)); - - ASSERT_EQUALS(size, size1); - ASSERT_EQUALS(size, size2); - ASSERT_EQUALS(twips, twips1); - ASSERT_EQUALS(twips, twips2); - } - -/** -@SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0005L -@SYMTestCaseDesc Test getting display change event from event queue -@SYMREQ REQ10329 REQ10330 -@SYMPREQ PREQ2102 -@SYMTestType CT -@SYMTestPriority 1 -@SYMTestPurpose Verify the correct behaviour of display change notification -@SYMTestActions - Run through various ways of changing resolution - For each, check if event has been received -@SYMTestExpectedResults - Based on type of change, check event -*/ -void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0005L() - { - LOG_AND_PANIC_IF_NOT_GCE; - ResetScreens(); -#ifdef MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER - ASSERT_FALSE("Display connection test not compiled because MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER"); -#else - TInt screenNo = iScreenDevice->GetScreenNumber(); - - MDisplayControl* interface = static_cast - (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); - ASSERT_TRUE(interface); - interface->EnableDisplayChangeEvents(ETrue); - ASSERT_TRUE(interface->DisplayChangeEventsEnabled()); - - CWsDisplayEvent* displayEventAO = new(ELeave) CWsDisplayEvent(&iSession); - CleanupStack::PushL(displayEventAO); - displayEventAO->Request(); - CEventTimer *timer = CEventTimer::NewL(); - CleanupStack::PushL(timer); - TInt dispSpinnerValue = displayEventAO->ResListSpinner(); - TInt configSpinnerValue = displayEventAO->ConfigSpinner(); - - iSession.Flush(); - TInt displayState = EDisconnect; - UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL); - - timer->Wait(100000); - ASSERT_TRUE(displayEventAO->ConfigSpinner() >= configSpinnerValue); //this is also a config change - ASSERT_TRUE(displayEventAO->ResListSpinner() > dispSpinnerValue); //1st display change event - dispSpinnerValue = displayEventAO->ResListSpinner(); - configSpinnerValue = displayEventAO->ConfigSpinner(); - - - interface->EnableDisplayChangeEvents(ETrue);//enable again - ASSERT_TRUE(interface->DisplayChangeEventsEnabled()); - interface->EnableDisplayChangeEvents(EFalse);//disable - ASSERT_FALSE(interface->DisplayChangeEventsEnabled()); - interface->EnableDisplayChangeEvents(EFalse);//disable again - interface->EnableDisplayChangeEvents(ETrue);//enable again - iSession.Flush(); - - TDisplayConfiguration disconnectedConfig; - disconnectedConfig.SetResolution(TSize(10,11)); - disconnectedConfig.SetResolutionTwips(TSize(12,13)); - disconnectedConfig.SetRotation(TDisplayConfiguration1::ERotationNormal); - interface->GetConfiguration(disconnectedConfig); - ASSERT_FALSE(disconnectedConfig.IsDefined(disconnectedConfig.EResolution)); - ASSERT_FALSE(disconnectedConfig.IsDefined(disconnectedConfig.EResolutionTwips)); - ASSERT_FALSE(disconnectedConfig.IsDefined(disconnectedConfig.ERotation)); - - displayState = ENormalResolution; - UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL); - - timer->Wait(1000000); - ASSERT_TRUE(displayEventAO->ConfigSpinner() >= configSpinnerValue); //this is a config change if display policy is enabled. not a change otherwise - ASSERT_TRUE(displayEventAO->ResListSpinner() > dispSpinnerValue); //display change event - dispSpinnerValue = displayEventAO->ResListSpinner(); - configSpinnerValue = displayEventAO->ConfigSpinner(); - - TDisplayConfiguration dispConfig, dispConfig2; - TSize resolution,resolution2; - interface->GetConfiguration(dispConfig2); - dispConfig2.GetResolution(resolution2); - RArray resolutions; - TInt err = interface->GetResolutions(resolutions); - ASSERT_EQUALS(err, KErrNone); - dispConfig.SetResolution(resolutions[resolutions.Count()/2].iPixelSize); - err = interface->SetConfiguration(dispConfig); - ASSERT_EQUALS(err, KErrNone); - interface->GetConfiguration(dispConfig); - - timer->Wait(100000); - - if(!(dispConfig2 == dispConfig)) - { - ASSERT_TRUE(displayEventAO->ConfigSpinner() > configSpinnerValue); //a config change, but on screen 0 with DP disabled, as we only have 1 resolution when DP disabled - } - else - { - ASSERT_TRUE(displayEventAO->ConfigSpinner() == configSpinnerValue); - } - ASSERT_EQUALS(displayEventAO->ResListSpinner(), dispSpinnerValue); //this is not a display change event - dispSpinnerValue = displayEventAO->ResListSpinner(); - configSpinnerValue = displayEventAO->ConfigSpinner(); - resolutions.Close(); - - //here we flood the event queue with key events, so the next display change - //can't put event and queue and force the retry AO on server side to kick off - iSession.SetFocusScreen(TGlobalSettings::Instance().iScreen); - for(TInt scanCode = 'a'; scanCode < 't'; scanCode ++) - { - TRawEvent rawEvent; - rawEvent.Set(TRawEvent::EKeyDown,scanCode); - iSession.SimulateRawEvent(rawEvent); - rawEvent.Set(TRawEvent::EKeyUp,scanCode); - iSession.SimulateRawEvent(rawEvent); - } - iSession.Flush(); - - TInt eventCount1 = displayEventAO->ReceivedEventCount(); - //we should still receive this - displayState = EDisconnect; - UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL); - //let retry AO retry more times before we try to get it - User::After(1000000); - - timer->Wait(10000000); - ASSERT_TRUE(displayEventAO->ConfigSpinner()> configSpinnerValue ); //4th config change - ASSERT_TRUE(displayEventAO->ResListSpinner() > dispSpinnerValue); //4th display change event - - //This part is doomed as well. Now the received event count includes all the pointer, device and display change event - /* - TInt eventCount2 = displayEventAO->ReceivedEventCount(); - //make sure retry AO is stopped - we only receive 1 display event - ASSERT_EQUALS(eventCount1 + 1, eventCount2); - */ - displayState = ENormalResolution; - UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL); - - CleanupStack::PopAndDestroy(2, displayEventAO); -#endif - } - -//Adds the first rotation defined in the TResolution to the display configuration -void CWsDynamicResBasic::SetRotation (TDisplayConfiguration& aConfig, const MDisplayControl::TResolution& aResolution) - { - if (aResolution.iFlags.IsSet(MDisplayControlBase::TResolution::ERotationNormalSupported)) - { - aConfig.SetRotation(TDisplayConfiguration1::ERotationNormal); - } - else if (aResolution.iFlags.IsSet(MDisplayControlBase::TResolution::ERotation90Supported)) - { - aConfig.SetRotation(TDisplayConfiguration1::ERotation90CW); - } - else if (aResolution.iFlags.IsSet(MDisplayControlBase::TResolution::ERotation180Supported)) - { - aConfig.SetRotation(TDisplayConfiguration1::ERotation180); - } - else if (aResolution.iFlags.IsSet(MDisplayControlBase::TResolution::ERotation270Supported)) - { - aConfig.SetRotation(TDisplayConfiguration1::ERotation270CW); - } - ASSERT_TRUE(aConfig.IsDefined(aConfig.ERotation)); - } - -/** -@SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0006L -@SYMTestCaseDesc Set Screen display res -@SYMREQ REQ10326 -@SYMPREQ PREQ2102 -@SYMTestType CT -@SYMTestPriority -@SYMTestPurpose Checking window and layer extents continue working -@SYMTestActions - Get resolution list - For every resolution - Set resolution - Draw many rectangles that shrink to demonstrate scaling issues - Draw surface - Move window around -@SYMTestExpectedResults - Every resolution that is supported by current app mode should successfully be set - All rectangles and surface should be visible - As the window moves, the rectangles and surface should move with it, keeping visible -*/ -void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0006L() - { - LOG_AND_PANIC_IF_NOT_GCE; - ResetScreens(); - TInt error; - MakeTitleAndCompareWindowsL(_L("GFX_WSERV_DYNAMICRES_0006L"),_L("Change Resolution")); - - iTestBack=RWindow(iSession); - ASSERT_EQUALS(iTestBack.Construct(iGroup, ++iWindowHandle), KErrNone); - iTestBack.SetRequiredDisplayMode(iDisplayMode); - iTestBack.SetBackgroundColor(TRgb(255,0,0)); - iTestBack.SetExtent(iTestPos.iTl,iTestPos.Size()); - iTestBack.Activate(); - iTestBack.BeginRedraw(); - ActivateWithWipe(iGc,iTestBack,TRgb(255,0,0)); - iGc->Deactivate(); - iTestBack.EndRedraw(); - iTestBack.SetVisible(ETrue); - - struct DrawCompare - { - static void Draw(CWindowGc* aGc) - { - aGc->SetPenStyle(aGc->ESolidPen); - aGc->SetPenColor(TRgb(255,255,255)); - aGc->SetBrushColor(TRgb(0,0,0)); - TRect r(2,2,82,82); - while(r.Width()>0) - { - aGc->DrawRect(r); - r.Shrink(2,2); - } - } - }; - TSurfaceId surfaceID; - TRAPD(err, surfaceID = iUtility->CreateSurfaceL(TSize(200,200), - KSurfaceFormat, 200 * KBytesPerPixel)); - ASSERT_EQUALS(err,KErrNone); - TRAP(err,iUtility->FanFillSurfaceL(surfaceID,iYellow,iRed,iMagenta)); - ASSERT_EQUALS(err,KErrNone); - TSurfaceConfiguration surfConf; - surfConf.SetSurfaceId(surfaceID); - - surfConf.SetExtent(TRect(2,84,82,166)); - iCompare.SetBackgroundSurface(surfConf,EFalse); - - if (CWindowGc* gc=BeginActivateWithWipe(ETrue,iCompare,TRgb(128,128,128))) - { - DrawCompare::Draw(gc); - gc->Deactivate(); - iCompare.EndRedraw(); - - } - iSession.Finish(ETrue); - Pause(1000); - - MDisplayControl* interface = static_cast - (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); - ASSERT_TRUE(interface); - - TInt resolutions = interface->NumberOfResolutions(); - ASSERT_TRUE (resolutions > 0); - - RArray resolutionList1; - error = interface->GetResolutions(resolutionList1); - ASSERT_EQUALS(error,KErrNone); - ASSERT_EQUALS(resolutionList1.Count(), resolutions); - - TDisplayConfiguration dispConfigBefore; - interface->GetConfiguration(dispConfigBefore); - ASSERT_TRUE(dispConfigBefore.IsDefined(dispConfigBefore.EResolution)) - if (resolutions>1) - { - //Got a mode to change to! - TSize resBefore; - TBool ok=dispConfigBefore.GetResolution(resBefore); - ASSERT_TRUE(ok); //we "know" this should be ok, as we just asserted the flag - TBool foundBeforeRes=EFalse; - for (TInt res=0;resSetConfiguration(dispConfigReq); - //ASSERT_EQUALS(errCode,KErrNone); - if (errCode != KErrNone) - { - //Probably current size mode does not support the rotation of the passed in configuration - - ASSERT_EQUALS(errCode,KErrArgument); //failed to find compatible res in the policy - continue; - } - Pause(300); - TRect outerrect(iTestPos.iTl,resolutionList1[res].iPixelSize.AsPoint()); - iTestBack.SetExtent(outerrect.iTl,outerrect.Size()); - iSession.Finish(ETrue); - Pause(300); - if (CWindowGc* gc=BeginActivateWithWipe(ETrue,iCompare,TRgb(128,128,128))) - { - DrawCompare::Draw(gc); - gc->Deactivate(); - iCompare.EndRedraw(); - } - TBuf16<20> s; - s.AppendNum(res); - UpdateTitleWindowL(s,2); - s.Zero(); - s.AppendNum(resolutionList1[res].iPixelSize.iWidth); - s.Append('x'); - s.AppendNum(resolutionList1[res].iPixelSize.iHeight); - UpdateTitleWindowL(s,3); - - iSession.Finish(ETrue); - Pause(300); - outerrect.iBr.iX-=5; - outerrect.iBr.iY-=5; - iTestBack.SetExtent(outerrect.iTl,outerrect.Size()); - iSession.Finish(ETrue); - Pause(300); - TPoint winpos=iCompare.AbsPosition(); - TSize winsize=iCompare.Size(); -// iInfoScreenDevice->ReleaseTwipsCache(); - RepaintTitleWindowL(); - for (TSize z=TSize(1,1);z!=TSize(-1,-1);) - { - for (TInt i=0;i<15;i++) - { - winpos+=z; - iCompare.SetExtent(winpos,winsize); - iSession.Finish(ETrue); - Pause(100); - } - if (z.iHeight && z.iWidth) - z=TSize(0,-1); - else - if (z.iHeight) - z=TSize(-1,0); - else - z=TSize(-1,-1); - } - TDisplayConfiguration dispConfigAfter; - interface->GetConfiguration(dispConfigAfter); - TSize resAfter; - TBool ok=dispConfigAfter.GetResolution(resAfter); - ASSERT_TRUE(ok); - if (resolutionList1[res].iPixelSize!=resAfter) - { - INFO_PRINTF3(_L("Did not receive expected resolution %ix%i"),resolutionList1[res].iPixelSize.iWidth,resolutionList1[res].iPixelSize.iHeight); - INFO_PRINTF3(_L("Instead got %ix%i"),resAfter.iWidth,resAfter.iHeight); - } - } - } - if (resolutionList1[res].iPixelSize==resBefore) - { - foundBeforeRes=ETrue; - } - } - ASSERT_TRUE(foundBeforeRes); - //restore initial res - interface->SetConfiguration(dispConfigBefore); - Pause(1000); - TDisplayConfiguration dispConfigAfter; - interface->GetConfiguration(dispConfigAfter); - TSize resAfter; - ok=dispConfigAfter.GetResolution(resAfter); - ASSERT_TRUE(ok); - ASSERT_EQUALS(resBefore,resAfter); - } - else - { - INFO_PRINTF1(_L("Only 1 resolution configured on this screen - res change test skipped.")); - } - resolutionList1.Close(); - } - -/** -@SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0007L -@SYMTestCaseDesc Coordinates Mapping -@SYMREQ REQ10336 -@SYMPREQ PREQ2102 -@SYMTestType CT -@SYMTestPurpose Basic call to mapcoordinates -@SYMTestActions - Call mapCoordinates -@SYMTestExpectedResults - targetRect should be correctly filled in with same rect as sourceRect -*/ -void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0007L() - { - MDisplayMapping* interface = static_cast - (iScreenDevice->GetInterface(MDisplayMapping::ETypeId)); - ASSERT_TRUE(interface); - TRect sourceRect(10, 10, 30, 50); - TRect targetRect(5,5,10,10); - TInt err = interface->MapCoordinates(EApplicationSpace, sourceRect, EApplicationSpace, targetRect); - ASSERT_EQUALS(err, KErrNone); - ASSERT_EQUALS(sourceRect, targetRect); - } - -/** -@SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0008L -@SYMTestCaseDesc SetModes and mapCoordinates -@SYMREQ REQ10336 -@SYMPREQ PREQ2102 -@SYMTestType CT -@SYMTestPurpose Basic SetSizeMode and complex MapCoordinates function -@SYMTestActions - Set a new size mode - Perform many rect conversions using MapCoordinates -@SYMTestExpectedResults - Ensure that through multiple conversions, accuracy is not lost -*/ -void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0008L() - { - LOG_AND_PANIC_IF_NOT_GCE; - ResetScreens(); - TInt error; - MakeTitleAndCompareWindowsL(_L("GFX_WSERV_DYNAMICRES_0008L"),_L("Change Size Mode")); - - iTestBack=RWindow(iSession); - ASSERT_EQUALS(iTestBack.Construct(iGroup, ++iWindowHandle), KErrNone); - iTestBack.SetRequiredDisplayMode(iDisplayMode); - iTestBack.SetBackgroundColor(TRgb(255,0,0)); - iTestBack.SetExtent(iTestPos.iTl,iTestPos.Size()); - iTestBack.Activate(); - iTestBack.BeginRedraw(); - ActivateWithWipe(iGc,iTestBack,TRgb(255,0,0)); - iGc->Deactivate(); - iTestBack.EndRedraw(); - iTestBack.SetVisible(ETrue); - - - if (CWindowGc* gc=BeginActivateWithWipe(ETrue,iCompare,TRgb(128,128,128))) - { - gc->SetPenStyle(gc->ESolidPen); - gc->SetPenColor(TRgb(255,255,255)); - gc->SetBrushColor(TRgb(0,0,0)); - TRect r(2,2,22,22); - while(r.Width()>0) - { - gc->DrawRect(r); - r.Shrink(2,2); - } - gc->Deactivate(); - iCompare.EndRedraw(); - - } - iSession.Finish(ETrue); - Pause(1000); - - MDisplayControl* interface = static_cast - (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); - ASSERT_TRUE(interface); - - TInt resolutions = interface->NumberOfResolutions(); - ASSERT_TRUE (resolutions > 0); - - RArray resolutionList1; - error = interface->GetResolutions(resolutionList1); - ASSERT_EQUALS(error,KErrNone); - ASSERT_EQUALS(resolutionList1.Count(), resolutions); - - TDisplayConfiguration dispConfigBefore; - interface->GetConfiguration(dispConfigBefore); - ASSERT_TRUE(dispConfigBefore.IsDefined(dispConfigBefore.EResolution)); - - RArray screenModeList; - iInfoScreenDevice->GetScreenSizeModeList(&screenModeList); - ASSERT_TRUE (screenModeList.Count() > 1); - iScreenDevice->SetAppScreenMode(screenModeList[1]); - iScreenDevice->SetScreenMode(screenModeList[1]); - iSession.Finish(ETrue); - Pause(1000); - - MDisplayMapping* interfaceM = static_cast - (iScreenDevice->GetInterface(MDisplayMapping::ETypeId)); - TRect appRect(20, 40, 193, 110); - TRect uiRect(1,2,3,4); - TRect compRect(5,6,7,8); - TRect tempRect(10,11,12,13); - TInt err; - while (ETrue) - { - //quick get for a print - err = interfaceM->MapCoordinates(EApplicationSpace, appRect, EFullScreenSpace, uiRect); - err = interfaceM->MapCoordinates(EApplicationSpace, appRect, ECompositionSpace, compRect); - -// print -// INFO_PRINTF5(_L("appRect : %d , %d - %d , %d"),appRect.iTl.iX,appRect.iTl.iY,appRect.iBr.iX,appRect.iBr.iY); -// INFO_PRINTF5(_L("uiRect : %d , %d - %d , %d"),uiRect.iTl.iX,uiRect.iTl.iY,uiRect.iBr.iX,uiRect.iBr.iY); -// INFO_PRINTF5(_L("compRect : %d , %d - %d , %d"),compRect.iTl.iX,compRect.iTl.iY,compRect.iBr.iX,compRect.iBr.iY); -// INFO_PRINTF1(_L(" ")); - - //longer process to insure conversions both ways dont lose accuracy - err = interfaceM->MapCoordinates(EApplicationSpace, appRect, EFullScreenSpace, uiRect); - err = interfaceM->MapCoordinates(EFullScreenSpace, uiRect, EApplicationSpace, tempRect); - ASSERT_EQUALS(tempRect,appRect); - - err = interfaceM->MapCoordinates(EApplicationSpace, appRect, ECompositionSpace, compRect); - err = interfaceM->MapCoordinates(ECompositionSpace, compRect, EApplicationSpace, tempRect); - ASSERT_EQUALS(tempRect,appRect); - - err = interfaceM->MapCoordinates(EApplicationSpace, appRect, EFullScreenSpace, uiRect); - err = interfaceM->MapCoordinates(EFullScreenSpace, uiRect, ECompositionSpace, compRect); - err = interfaceM->MapCoordinates(ECompositionSpace, compRect, EFullScreenSpace, tempRect); - ASSERT_EQUALS(tempRect,uiRect); - - appRect.iBr.iX--; - appRect.iBr.iY--; - if (appRect.IsEmpty()) - { - break; - } - } - - TRect rect1(5,5,10,10); - TRect rect2(15,15,20,20); - TRect rect3(50,50,50,50); - //1 - err = interfaceM->MapCoordinates(ECompositionSpace, rect1, ECompositionSpace, rect2); - err = interfaceM->MapCoordinates(EFullScreenSpace, rect2, ECompositionSpace, rect3); - ASSERT_EQUALS(rect1,rect2); - - err = interfaceM->MapCoordinates(ECompositionSpace, rect1, EFullScreenSpace, rect2); - err = interfaceM->MapCoordinates(EFullScreenSpace, rect2, ECompositionSpace, rect3); - ASSERT_EQUALS(rect1,rect3); - - err = interfaceM->MapCoordinates(ECompositionSpace, rect1, EApplicationSpace, rect2); - err = interfaceM->MapCoordinates(EApplicationSpace, rect2, ECompositionSpace, rect3); - ASSERT_EQUALS(rect1,rect3); - - err = interfaceM->MapCoordinates(ECompositionSpace, rect1, EDirectScreenAccessSpace, rect2); - err = interfaceM->MapCoordinates(EDirectScreenAccessSpace, rect2, ECompositionSpace, rect3); - ASSERT_EQUALS(rect1,rect3); - - //2 - err = interfaceM->MapCoordinates(EFullScreenSpace, rect1, EFullScreenSpace, rect2); - ASSERT_EQUALS(rect1,rect2); - - err = interfaceM->MapCoordinates(EFullScreenSpace, rect1, EApplicationSpace, rect2); - err = interfaceM->MapCoordinates(EApplicationSpace, rect2, EFullScreenSpace, rect3); - ASSERT_EQUALS(rect1,rect3); - - err = interfaceM->MapCoordinates(EFullScreenSpace, rect1, EDirectScreenAccessSpace, rect2); - err = interfaceM->MapCoordinates(EDirectScreenAccessSpace, rect2, EFullScreenSpace, rect3); - ASSERT_EQUALS(rect1,rect3); - - //3 - err = interfaceM->MapCoordinates(EApplicationSpace, rect1, EApplicationSpace, rect2); - ASSERT_EQUALS(rect1,rect2); - - err = interfaceM->MapCoordinates(EApplicationSpace, rect1, EDirectScreenAccessSpace, rect2); - err = interfaceM->MapCoordinates(EDirectScreenAccessSpace, rect2, EApplicationSpace, rect3); - ASSERT_EQUALS(rect1,rect3); - - //4 - err = interfaceM->MapCoordinates(EDirectScreenAccessSpace, rect1, EDirectScreenAccessSpace, rect2); - ASSERT_EQUALS(rect1,rect2); - - //invalid - err = interfaceM->MapCoordinates(ECompositionSpace, rect1, (TCoordinateSpace)0, rect2); - ASSERT_EQUALS(err,KErrNotSupported); - err = interfaceM->MapCoordinates(EFullScreenSpace, rect1, (TCoordinateSpace)0, rect2); - ASSERT_EQUALS(err,KErrNotSupported); - err = interfaceM->MapCoordinates(EApplicationSpace, rect1, (TCoordinateSpace)0, rect2); - ASSERT_EQUALS(err,KErrNotSupported); - err = interfaceM->MapCoordinates(EDirectScreenAccessSpace, rect1, (TCoordinateSpace)0, rect2); - ASSERT_EQUALS(err,KErrNotSupported); - err = interfaceM->MapCoordinates((TCoordinateSpace)0, rect1, EDirectScreenAccessSpace, rect2); - ASSERT_EQUALS(err,KErrNotSupported); - - TDisplayConfiguration dispConfigAfter; - interface->GetConfiguration(dispConfigAfter); - - screenModeList.Close(); - resolutionList1.Close(); - iScreenDevice->SetAppScreenMode(0); - iScreenDevice->SetScreenMode(0); - } - -/** -@SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0009L -@SYMTestCaseDesc Set Screen display res using app mode -@SYMREQ REQ10336 -@SYMPREQ PREQ2102 -@SYMTestType CT -@SYMTestPurpose SetScreenMode functions correctly -@SYMTestActions - Similar to 0006, but setting every available screen mode instead of resolution -@SYMTestExpectedResults - Every set should work, including modes that involve a rotation! -*/ -void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0009L() - { - LOG_AND_PANIC_IF_NOT_GCE; - ResetScreens(); - TInt error; - iSession.Finish(ETrue); - MakeTitleAndCompareWindowsL(_L("GFX_WSERV_DYNAMICRES_0009L"),_L("Change Size Mode")); - iSession.Finish(ETrue); - - iTestBack=RWindow(iSession); - ASSERT_EQUALS(iTestBack.Construct(iGroup, ++iWindowHandle), KErrNone); - iTestBack.SetRequiredDisplayMode(iDisplayMode); - iTestBack.SetBackgroundColor(TRgb(255,0,0)); - iTestBack.SetExtent(iTestPos.iTl,iTestPos.Size()); - iTestBack.Activate(); - iTestBack.BeginRedraw(); - ActivateWithWipe(iGc,iTestBack,TRgb(255,0,0)); - iGc->Deactivate(); - iTestBack.EndRedraw(); - iTestBack.SetVisible(ETrue); - iSession.Finish(ETrue); - - struct DrawCompare - { - static void Draw(CWindowGc* aGc) - { - aGc->SetPenStyle(aGc->ESolidPen); - aGc->SetPenColor(TRgb(255,255,255)); - aGc->SetBrushColor(TRgb(0,0,0)); - TRect r(2,2,82,82); - while(r.Width()>0) - { - aGc->DrawRect(r); - r.Shrink(2,2); - } - } - }; - TSurfaceId surfaceID; - TRAPD(err, surfaceID = iUtility->CreateSurfaceL(TSize(200,200), - KSurfaceFormat, 200 * KBytesPerPixel)); - ASSERT_EQUALS(err,KErrNone); - TRAP(err,iUtility->FanFillSurfaceL(surfaceID,iYellow,iRed,iMagenta)); - ASSERT_EQUALS(err,KErrNone); - TSurfaceConfiguration surfConf; - surfConf.SetSurfaceId(surfaceID); - - surfConf.SetExtent(TRect(2,84,82,166)); - iCompare.SetBackgroundSurface(surfConf,EFalse); - - if (CWindowGc* gc=BeginActivateWithWipe(ETrue,iCompare,TRgb(128,128,128))) - { - DrawCompare::Draw(gc); - gc->Deactivate(); - iCompare.EndRedraw(); - - } - iSession.Finish(ETrue); - Pause(1000); - RArray screenModeList; - iInfoScreenDevice->GetScreenSizeModeList(&screenModeList); - MDisplayControl* interface = static_cast - (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); - ASSERT_TRUE(interface); - - TInt resolutions = interface->NumberOfResolutions(); - ASSERT_TRUE (resolutions > 0); - - RArray resolutionList1; - error = interface->GetResolutions(resolutionList1); - ASSERT_EQUALS(error,KErrNone); - ASSERT_EQUALS(resolutionList1.Count(), resolutions); - - TDisplayConfiguration dispConfigBefore; - interface->GetConfiguration(dispConfigBefore); - ASSERT_TRUE(dispConfigBefore.IsDefined(dispConfigBefore.EResolution)) - if (screenModeList.Count()>1) - { - //Got a mode to change to! - TSize resBefore; - TBool ok=dispConfigBefore.GetResolution(resBefore); - ASSERT_TRUE(ok); //we "know" this should be ok, as we just asserted the flag - for (TInt res=0;resSetAppScreenMode(screenModeList[res]); - iInfoScreenDevice->SetScreenMode(screenModeList[res]); - iSession.Finish(ETrue); - Pause(300); - - TPixelsAndRotation pr; - iInfoScreenDevice->GetDefaultScreenSizeAndRotation(pr); - TPoint origin=iInfoScreenDevice->GetDefaultScreenModeOrigin(); - Pause(300); - - if (CWindowGc* gc=BeginActivateWithWipe(ETrue,iCompare,TRgb(128,128,128))) - { - DrawCompare::Draw(gc); - gc->Deactivate(); - iCompare.EndRedraw(); - } - if (iTitle.WsHandle()) - { - TPoint infoWinPos; - TSize infoWinSize; - infoWinPos=iTitle.AbsPosition(); - infoWinSize=iTitle.Size(); - infoWinSize.iHeight=pr.iPixelSize.iHeight-2*infoWinPos.iY; - iTitle.SetSize(infoWinSize); - } - TBuf16<20> s; - s.AppendNum(res); - UpdateTitleWindowL(s,1); - s.Zero(); - s.AppendNum(pr.iPixelSize.iWidth); - s.Append('x'); - s.AppendNum(pr.iPixelSize.iHeight); - UpdateTitleWindowL(s,2); - s.Zero(); - s.AppendNum(origin.iX); - s.Append(','); - s.AppendNum(origin.iY); - UpdateTitleWindowL(s,3); - - iSession.Finish(ETrue); - Pause(300); - - TPoint winpos=iCompare.AbsPosition(); - TSize winsize=iCompare.Size(); - - for (TSize z=TSize(1,1);z!=TSize(-1,-1);) - { - for (TInt i=0;i<15;i++) - { - winpos+=z; - iCompare.SetExtent(winpos,winsize); - iSession.Finish(ETrue); - Pause(100); - } - if (z.iHeight && z.iWidth) - z=TSize(0,-1); - else - if (z.iHeight) - z=TSize(-1,0); - else - z=TSize(-1,-1); - } - } - } - } - //restore initial res - if (screenModeList.Count() > 1) - { //set back to basics - iInfoScreenDevice->SetAppScreenMode(screenModeList[0]); - iInfoScreenDevice->SetScreenMode(screenModeList[0]); - Pause(300); - } - - interface->SetConfiguration(dispConfigBefore); - Pause(1000); - TDisplayConfiguration dispConfigAfter; - interface->GetConfiguration(dispConfigAfter); - TSize resAfter; - ok=dispConfigAfter.GetResolution(resAfter); - ASSERT_TRUE(ok); - ASSERT_EQUALS(resBefore,resAfter); - } - else - { - INFO_PRINTF1(_L("Only 1 screen size mode configured on this screen - res change test skipped.")); - } - - screenModeList.Close(); - resolutionList1.Close(); - } - -/** -@SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0010L -@SYMTestCaseDesc Test app mode setting during attach/detach -@SYMREQ REQ10330 -@SYMPREQ PREQ2102 -@SYMTestType CT -@SYMTestPurpose Make sure display resumes last app mode when reattached -@SYMTestActions - Save app mode and display configuration before detach and compare it with those after reattach. - Repeat for a second app mode - If available, repeat with dynamic app mode -@SYMTestExpectedResults - For normal app mode, on reconnect it should re apply the old configuration - For dynamic app mode, on reconnect it should be 0x0 -*/ -void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0010L() - { - LOG_AND_PANIC_IF_NOT_GCE; - ResetScreens(); -#ifdef MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER - ASSERT_FALSE("Test not compiled because MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER"); -#else - TInt error; - iSession.Finish(ETrue); - MakeTitleAndCompareWindowsL(_L("GFX_WSERV_DYNAMICRES_0010L"),_L("detach/attach")); - iSession.Finish(ETrue); - - Pause(1000); - TInt screenNo = iScreenDevice->GetScreenNumber(); - RArray screenModeList; - iInfoScreenDevice->GetScreenSizeModeList(&screenModeList); - - //Find 2 real app modes and 1 dynamic app mode - TInt firstAvailableAppMode = -1; - TInt secondAvailableAppMode = -1; - TInt dynamicAppMode = -1; - for (TInt ii = 0; ii < screenModeList.Count(); ii++) - { - TBool dynamic = iInfoScreenDevice->IsModeDynamic(screenModeList[ii]); - if (dynamic && dynamicAppMode == -1) - { - dynamicAppMode = screenModeList[ii]; - } - if (!dynamic) - { - if (firstAvailableAppMode == -1) - { - firstAvailableAppMode = screenModeList[ii]; - } - else if (secondAvailableAppMode == -1) - { - secondAvailableAppMode = screenModeList[ii]; - } - } - } - ASSERT_TRUE(firstAvailableAppMode!=-1); - ASSERT_TRUE(secondAvailableAppMode!=-1); - - MDisplayControl* interface = static_cast - (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); - ASSERT_TRUE(interface); - - MDisplayMapping* mappingInterface = static_cast - (iScreenDevice->GetInterface(MDisplayMapping::ETypeId)); - ASSERT_TRUE(mappingInterface); - - TInt resolutions = interface->NumberOfResolutions(); - ASSERT_TRUE (resolutions > 0); - - RArray resolutionList1; - error = interface->GetResolutions(resolutionList1); - ASSERT_EQUALS(error,KErrNone); - ASSERT_EQUALS(resolutionList1.Count(), resolutions); - - TDisplayConfiguration configBeforeDetach, configAfterReattach; - TInt appModeBeforeDetach, appModeAfterReattach; - - // - //1st detach - attach sequence - appModeBeforeDetach = firstAvailableAppMode; - iScreenDevice->SetAppScreenMode(appModeBeforeDetach ); - iScreenDevice->SetScreenMode(appModeBeforeDetach ); - Pause(200); - interface->GetConfiguration(configBeforeDetach); - - TInt displayState = EDisconnect; - UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL); - Pause(300); - - //dummy mapping should return KErrNotReady if display is disconnected - TRect dummyRect(1,2,5,8); - error = mappingInterface->MapCoordinates(ECompositionSpace, dummyRect, EFullScreenSpace, dummyRect); - ASSERT_EQUALS(error, KErrNotReady); - - displayState = ENormalResolution; - UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL); - Pause(300); - - interface->GetConfiguration(configAfterReattach); - ASSERT_TRUE(configBeforeDetach==configAfterReattach); - appModeAfterReattach = iScreenDevice->CurrentScreenMode(); - ASSERT_EQUALS(appModeBeforeDetach, appModeAfterReattach); - //1st detach - attach sequence ends here - // - - configBeforeDetach.ClearAll(); - configAfterReattach.ClearAll(); - - // - //2nd detach-attach sequence - non dynamic app mode - iScreenDevice->SetAppScreenMode(secondAvailableAppMode); - iScreenDevice->SetScreenMode(secondAvailableAppMode); - Pause(200); - appModeBeforeDetach = iScreenDevice->CurrentScreenMode(); - interface->GetConfiguration(configBeforeDetach); - displayState = EDisconnect; - UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL); - Pause(300); - //dummy mapping should return KErrNotReady if display is disconnected - error = mappingInterface->MapCoordinates(ECompositionSpace, dummyRect, EFullScreenSpace, dummyRect); - ASSERT_EQUALS(error, KErrNotReady); - - displayState = ENoResolution; - UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL); - Pause(300); - //dummy mapping should return KErrNotReady if display is disconnected - error = mappingInterface->MapCoordinates(ECompositionSpace, dummyRect, EFullScreenSpace, dummyRect); - ASSERT_EQUALS(error, KErrNotReady); - - displayState = ENormalResolution; - UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL); - Pause(300); - - interface->GetConfiguration(configAfterReattach); - ASSERT_TRUE(configBeforeDetach==configAfterReattach); - appModeAfterReattach = iScreenDevice->CurrentScreenMode(); - ASSERT_EQUALS(appModeBeforeDetach, appModeAfterReattach); - //2nd detach-attach sequence ends here - // - - configBeforeDetach.ClearAll(); - configAfterReattach.ClearAll(); - - // - //3rd detach-attach sequence - dynamic app mode - if (dynamicAppMode == -1) - { - screenModeList.Close(); - resolutionList1.Close(); - INFO_PRINTF1(_L("No dynamic app mode, end test")); //not a fail if there isn't a dynamic app mode - return; - } - - iScreenDevice->SetAppScreenMode(dynamicAppMode); - iScreenDevice->SetScreenMode(dynamicAppMode); - Pause(200); - appModeBeforeDetach = iScreenDevice->CurrentScreenMode(); - interface->GetConfiguration(configBeforeDetach); - displayState = EDisconnect; - UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL); - Pause(300); - //dummy mapping should return KErrNotReady if display is disconnected - error = mappingInterface->MapCoordinates(ECompositionSpace, dummyRect, EFullScreenSpace, dummyRect); - ASSERT_EQUALS(error, KErrNotReady); - - displayState = ENoResolution; - UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL); - Pause(300); - //dummy mapping should return KErrNotReady if display is disconnected - error = mappingInterface->MapCoordinates(ECompositionSpace, dummyRect, EFullScreenSpace, dummyRect); - ASSERT_EQUALS(error, KErrNotReady); - - displayState = ENormalResolution; - UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL); - Pause(300); - - interface->GetConfiguration(configAfterReattach); - ASSERT_FALSE(configBeforeDetach==configAfterReattach); - TSize afterReattachSize; - ASSERT_TRUE(configAfterReattach.GetResolution(afterReattachSize)); - ASSERT_EQUALS(afterReattachSize,TSize(0,0)); - ASSERT_TRUE(configAfterReattach.GetResolutionTwips(afterReattachSize)); - ASSERT_EQUALS(afterReattachSize,TSize(0,0)); - - appModeAfterReattach = iScreenDevice->CurrentScreenMode(); - ASSERT_EQUALS(appModeBeforeDetach, appModeAfterReattach); - //3rd detach-attach sequence ends here - // - - screenModeList.Close(); - resolutionList1.Close(); -#endif - } - - -CDSATestDrawing::CDSATestDrawing():CTimer(EPriorityStandard) - {} - -CDSATestDrawing::~CDSATestDrawing() - { - Cancel(); - } -CDSATestDrawing* CDSATestDrawing::NewL() - { - CDSATestDrawing *self = new(ELeave) CDSATestDrawing(); - CleanupStack::PushL(self); - self->ConstructL(); - CleanupStack::Pop(self); - return self; - } - -void CDSATestDrawing::ConstructL() - { - CTimer::ConstructL(); - CActiveScheduler::Add(this); - } - -void CDSATestDrawing::StartDrawingL(CDirectScreenAccess *aDSA) - { - - if(aDSA) - { - iDSA = aDSA; - } - - if(iDSA) - { - iDSA->StartL(); - - iRect = TRect(TPoint(0,0), iDSA->DrawingRegion()->BoundingRect().Size()); - - iWin->Invalidate(); - iWin->BeginRedraw(); - CFbsBitGc* gc = iDSA->Gc(); - gc->SetBrushColor(TRgb(220,220,220)); - gc->SetBrushStyle(CGraphicsContext::ESolidBrush); - gc->Clear(); - iWin->EndRedraw(); - After(500000); - } - - } - -void CDSATestDrawing::RunL() - { - Draw(); - After(500000); - } - -void CDSATestDrawing::Draw() - { - iWin->Invalidate(); - iWin->BeginRedraw(); - CFbsBitGc* gc = iDSA->Gc(); - gc->SetPenStyle(gc->ESolidPen); - gc->SetPenColor(TRgb(255,0,0)); - gc->SetBrushStyle(gc->ENullBrush); - iRect.Shrink(1, 1); - gc->DrawRect(iRect); - iDSA->ScreenDevice()->Update(); - iWin->EndRedraw(); - - } -void CDSATestDrawing::Restart(RDirectScreenAccess::TTerminationReasons /*aReason*/) - { - - StartDrawingL(NULL); - } - -void CDSATestDrawing::AbortNow(RDirectScreenAccess::TTerminationReasons /*aReason*/) - { - Cancel(); - } - -/** -@SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0011L -@SYMTestCaseDesc Test DSA drawing in different App Mode -@SYMREQ REQ10332 REQ10336 -@SYMPREQ PREQ2102 -@SYMTestType CT -@SYMTestPurpose Test DSA can restart and draw at correct place when screen mode changes -@SYMTestActions - A rectangle will be drawn 1 pixel inside the DSA drawing region, and continue to shrink before the drawing - time runs out. when screen mode changes, DSA should restart and the rectangle should be reset to 1 pixel inside - the new drawing region. - - note: DSA drawing region is clipped by DSA buffer, App Size and the visible area of the window which it drawns in -@SYMTestExpectedResults - All tests should pass. - -*/ -void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0011L() - { - LOG_AND_PANIC_IF_NOT_GCE; - ResetScreens(); - - Pause(1000); - MakeTitleAndCompareWindowsL(_L("GFX_WSERV_DYNAMICRES_0011L"),_L("DSA drawing")); - CDSATestDrawing *dsaDraw = CDSATestDrawing::NewL(); - CleanupStack::PushL(dsaDraw); - CDirectScreenAccess *dsa = CDirectScreenAccess::NewL(iSession, *iScreenDevice, iCompare, *dsaDraw); - CleanupStack::PushL(dsa); - dsaDraw->SetWindow(iCompare); - dsaDraw->StartDrawingL(dsa); - - CEventTimer *timer = CEventTimer::NewL(); - CleanupStack::PushL(timer); - - RArray screenModeList; - iInfoScreenDevice->GetScreenSizeModeList(&screenModeList); - MDisplayControl* interface = static_cast - (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); - ASSERT_TRUE(interface); - - MDisplayMapping* mappingInterface = static_cast - (iScreenDevice->GetInterface(MDisplayMapping::ETypeId)); - ASSERT_TRUE(mappingInterface); - - CFbsScreenDevice *pixelReadBackDevice = CFbsScreenDevice::NewL(iScreenDevice->GetScreenNumber(), iScreenDevice->DisplayMode()); - CleanupStack::PushL(pixelReadBackDevice); - - for (TInt res=0;resSetAppScreenMode(screenModeList[res]); - iScreenDevice->SetScreenMode(screenModeList[res]); - dsa->ScreenDevice()->Update(); - Pause(300); - //wait for DSA to restart - timer->Wait(500000); - TRect regionRect(dsa->DrawingRegion()->BoundingRect()); - - TPoint winpos = iCompare.AbsPosition(); - TSize winsize = iCompare.Size(); - - TPixelsAndRotation pr; - iInfoScreenDevice->GetDefaultScreenSizeAndRotation(pr); - TPoint origin=iInfoScreenDevice->GetDefaultScreenModeOrigin(); - Pause(300); - if (iTitle.WsHandle()) - { - TPoint infoWinPos; - TSize infoWinSize; - infoWinPos=iTitle.AbsPosition(); - infoWinSize=iTitle.Size(); - infoWinSize.iHeight=pr.iPixelSize.iHeight-2*infoWinPos.iY; - iTitle.SetSize(infoWinSize); - } - TBuf16<20> s; - s.AppendNum(res); - UpdateTitleWindowL(s,1); - s.Zero(); - s.AppendNum(pr.iPixelSize.iWidth); - s.Append('x'); - s.AppendNum(pr.iPixelSize.iHeight); - UpdateTitleWindowL(s,2); - s.Zero(); - s.AppendNum(origin.iX); - s.Append(','); - s.AppendNum(origin.iY); - UpdateTitleWindowL(s,3); - - INFO_PRINTF2(_L("---------test %i---------"), res); - INFO_PRINTF3(_L("resolution %i x %i"), pr.iPixelSize.iWidth, pr.iPixelSize.iHeight); - INFO_PRINTF3(_L("Origin (%i, %i)"), origin.iX, origin.iY); - //INFO_PRINTF3(_L("Test Window Origin (%i, %i)"), iCompare.AbsPosition().iX, iCompare.AbsPosition().iY); - INFO_PRINTF3(_L("DSA drawing region bounding rect origin (%i, %i)"), dsa->DrawingRegion()->BoundingRect().iTl.iX, - dsa->DrawingRegion()->BoundingRect().iTl.iY); - INFO_PRINTF3(_L("DSA drawing region bounding rect size (%i x %i)"), dsa->DrawingRegion()->BoundingRect().Width(), - dsa->DrawingRegion()->BoundingRect().Height()); - //give time so DSA AO can start drawing - timer->Wait(5000000); - - - TRect readBackRect; - mappingInterface->MapCoordinates(EApplicationSpace, TRect(0,0,1,1), EDirectScreenAccessSpace, readBackRect); - pixelReadBackDevice->SetDrawDeviceOffset(readBackRect.iTl); - pixelReadBackDevice->SetDeviceOrientation((TDeviceOrientation)(1 << pr.iRotation)); - readBackRect.SetRect(dsa->DrawingRegion()->BoundingRect().iTl, dsa->DrawingRegion()->BoundingRect().iBr); - - if(readBackRect.IsEmpty()) - { - INFO_PRINTF1(_L("DSA drawing region is empty, skip checking pixel colour")); - continue; - } - - //if my rectangle's iTl is (0,0) and iBr is (100,100). Why does it gives me the rect width and height - //both 100? 0 - 100 is 101 pixels drawn. Or does this indicates iBr is exclusive and iTl is inclusive? - //Ruo: Oh I almost believe iBr is exclusive now - TDisplayConfiguration dispConfigAfter2; - interface->GetConfiguration(dispConfigAfter2); - TSize theSize; - dispConfigAfter2.GetResolution(theSize); - TDisplayConfiguration1::TRotation orient; - dispConfigAfter2.GetRotation(orient); - if (orient == TDisplayConfiguration1::ERotation90CW || orient == TDisplayConfiguration1::ERotation270CW) - { - TInt temp = theSize.iHeight; - theSize.iHeight = theSize.iWidth; - theSize.iWidth = temp; - } - TRect uiSize(TPoint(0,0), theSize); - MDisplayMapping* mappingInterface = static_cast - (iScreenDevice->GetInterface(MDisplayMapping::ETypeId)); - ASSERT_TRUE(mappingInterface); - TRect finalSize; - mappingInterface->MapCoordinates(EApplicationSpace, uiSize, ECompositionSpace, finalSize); - - CFbsBitmap* bmp2 = new (ELeave) CFbsBitmap; - CleanupStack::PushL(bmp2); - User::LeaveIfError(bmp2->Create(finalSize.Size(), EColor16MU)); - MTestScreenCapture - * csc = - static_cast (iScreenDevice->GetInterface(MTestScreenCapture::KUidTestScreenCaptureIf)); - - if (csc) - { - TInt errr = csc->ComposeScreen(*bmp2); - ASSERT_TRUE(errr == KErrNone); - } - else - { - if (!cSCLogged) - { - cSCLogged = ETrue; - _LIT(KNoCSC, "CSC testing not enabled as CSC render stage not defined"); - Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrAll, KNoCSC); - } - } - - readBackRect.iBr = readBackRect.iBr - TPoint(1,1); - //check 4 outter corners - TRgb pixelRgb; - TRgb cornerRgb(220, 220, 220); - TRgb innerRgb(255, 0, 0); - readBackRect.Grow(1, 1); - TRect compSpaceReadBackRect; - mappingInterface->MapCoordinates(EApplicationSpace, readBackRect, ECompositionSpace, compSpaceReadBackRect); - - - if (csc) - { - if (finalSize.Contains(compSpaceReadBackRect.iTl)) - { - bmp2->GetPixel(pixelRgb, compSpaceReadBackRect.iTl); - if(!(pixelRgb != cornerRgb)) - { - _LIT(KCompareFailed, "Corner check failed on app mode: %d"); - TBuf<256> x; - x.Format(KCompareFailed, res+1); - Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x); - CleanupStack::PopAndDestroy(bmp2); - continue; - } - } - if (finalSize.Contains(TPoint(compSpaceReadBackRect.iBr.iX, compSpaceReadBackRect.iTl.iY))) - { - bmp2->GetPixel(pixelRgb, TPoint(compSpaceReadBackRect.iBr.iX, compSpaceReadBackRect.iTl.iY)); - if(!(pixelRgb != cornerRgb)) - { - _LIT(KCompareFailed, "Corner check failed on app mode: %d"); - TBuf<256> x; - x.Format(KCompareFailed, res+1); - Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x); - CleanupStack::PopAndDestroy(bmp2); - continue; - } - } - if (finalSize.Contains(compSpaceReadBackRect.iBr)) - { - bmp2->GetPixel(pixelRgb, compSpaceReadBackRect.iBr); - if(!(pixelRgb != cornerRgb)) - { - _LIT(KCompareFailed, "Corner check failed on app mode: %d"); - TBuf<256> x; - x.Format(KCompareFailed, res+1); - Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x); - CleanupStack::PopAndDestroy(bmp2); - continue; - } - } - if (finalSize.Contains(TPoint(compSpaceReadBackRect.iTl.iX, compSpaceReadBackRect.iBr.iY))) - { - bmp2->GetPixel(pixelRgb, TPoint(compSpaceReadBackRect.iTl.iX, compSpaceReadBackRect.iBr.iY)); - if(!(pixelRgb != cornerRgb)) - { - _LIT(KCompareFailed, "Corner check failed on app mode: %d"); - TBuf<256> x; - x.Format(KCompareFailed, res+1); - Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x); - CleanupStack::PopAndDestroy(bmp2); - continue; - } - } - } - - pixelReadBackDevice->GetPixel(pixelRgb, readBackRect.iTl); - ASSERT_TRUE(pixelRgb != cornerRgb); - pixelReadBackDevice->GetPixel(pixelRgb, TPoint(readBackRect.iBr.iX, readBackRect.iTl.iY)); - ASSERT_TRUE(pixelRgb != cornerRgb); - pixelReadBackDevice->GetPixel(pixelRgb, readBackRect.iBr); - ASSERT_TRUE(pixelRgb != cornerRgb); - pixelReadBackDevice->GetPixel(pixelRgb, TPoint(readBackRect.iTl.iX, readBackRect.iBr.iY)); - ASSERT_TRUE(pixelRgb != cornerRgb); - - //check 4 inner corners - readBackRect.Shrink(1,1); - mappingInterface->MapCoordinates(EApplicationSpace, readBackRect, ECompositionSpace, compSpaceReadBackRect); - - if (csc) - { - if (finalSize.Contains(compSpaceReadBackRect.iTl)) - { - bmp2->GetPixel(pixelRgb, compSpaceReadBackRect.iTl); - if(!(pixelRgb == cornerRgb)) - { - _LIT(KCompareFailed, "Corner check failed on app mode: %d"); - TBuf<256> x; - x.Format(KCompareFailed, res+1); - Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x); - CleanupStack::PopAndDestroy(bmp2); - continue; - } - } - if (finalSize.Contains(TPoint(compSpaceReadBackRect.iBr.iX, compSpaceReadBackRect.iTl.iY))) - { - bmp2->GetPixel(pixelRgb, TPoint(compSpaceReadBackRect.iBr.iX, compSpaceReadBackRect.iTl.iY)); - if(!(pixelRgb == cornerRgb)) - { - _LIT(KCompareFailed, "Corner check failed on app mode: %d"); - TBuf<256> x; - x.Format(KCompareFailed, res+1); - Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x); - CleanupStack::PopAndDestroy(bmp2); - continue; - } - } - if (finalSize.Contains(compSpaceReadBackRect.iBr)) - { - bmp2->GetPixel(pixelRgb, compSpaceReadBackRect.iBr); - if(!(pixelRgb == cornerRgb)) - { - _LIT(KCompareFailed, "Corner check failed on app mode: %d"); - TBuf<256> x; - x.Format(KCompareFailed, res+1); - Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x); - CleanupStack::PopAndDestroy(bmp2); - continue; - } - } - if (finalSize.Contains(TPoint(compSpaceReadBackRect.iTl.iX, compSpaceReadBackRect.iBr.iY))) - { - bmp2->GetPixel(pixelRgb, TPoint(compSpaceReadBackRect.iTl.iX, compSpaceReadBackRect.iBr.iY)); - if(!(pixelRgb == cornerRgb)) - { - _LIT(KCompareFailed, "Corner check failed on app mode: %d"); - TBuf<256> x; - x.Format(KCompareFailed, res+1); - Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x); - CleanupStack::PopAndDestroy(bmp2); - continue; - } - } - } - - pixelReadBackDevice->GetPixel(pixelRgb, readBackRect.iTl); - ASSERT_TRUE(pixelRgb == cornerRgb); - pixelReadBackDevice->GetPixel(pixelRgb, TPoint(readBackRect.iBr.iX, readBackRect.iTl.iY)); - ASSERT_TRUE(pixelRgb == cornerRgb); - pixelReadBackDevice->GetPixel(pixelRgb, readBackRect.iBr); - ASSERT_TRUE(pixelRgb == cornerRgb); - pixelReadBackDevice->GetPixel(pixelRgb, TPoint(readBackRect.iTl.iX, readBackRect.iBr.iY)); - ASSERT_TRUE(pixelRgb == cornerRgb); - //check inner colour - if(readBackRect.Width() < 3 || readBackRect.Height() < 3) - { - INFO_PRINTF1(_L("DSA drawing region is too small for drawing inner rectangle skip checking inner colour")); - CleanupStack::PopAndDestroy(bmp2); - continue; - } - - readBackRect.Shrink(1,1); - mappingInterface->MapCoordinates(EApplicationSpace, readBackRect, ECompositionSpace, compSpaceReadBackRect); - - if (csc) - { - if (finalSize.Contains(compSpaceReadBackRect.iTl)) - { - bmp2->GetPixel(pixelRgb, compSpaceReadBackRect.iTl); - if(!(pixelRgb == innerRgb)) - { - _LIT(KCompareFailed, "Corner check failed on app mode: %d"); - TBuf<256> x; - x.Format(KCompareFailed, res+1); - Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x); - CleanupStack::PopAndDestroy(bmp2); - continue; - } - } - if (finalSize.Contains(TPoint(compSpaceReadBackRect.iBr.iX, compSpaceReadBackRect.iTl.iY))) - { - bmp2->GetPixel(pixelRgb, TPoint(compSpaceReadBackRect.iBr.iX, compSpaceReadBackRect.iTl.iY)); - if(!(pixelRgb == innerRgb)) - { - _LIT(KCompareFailed, "Corner check failed on app mode: %d"); - TBuf<256> x; - x.Format(KCompareFailed, res+1); - Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x); - CleanupStack::PopAndDestroy(bmp2); - continue; - } - } - if (finalSize.Contains(compSpaceReadBackRect.iBr)) - { - bmp2->GetPixel(pixelRgb, compSpaceReadBackRect.iBr); - if(!(pixelRgb == innerRgb)) - { - _LIT(KCompareFailed, "Corner check failed on app mode: %d"); - TBuf<256> x; - x.Format(KCompareFailed, res+1); - Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x); - CleanupStack::PopAndDestroy(bmp2); - continue; - } - } - if (finalSize.Contains(TPoint(compSpaceReadBackRect.iTl.iX, compSpaceReadBackRect.iBr.iY))) - { - bmp2->GetPixel(pixelRgb, TPoint(compSpaceReadBackRect.iTl.iX, compSpaceReadBackRect.iBr.iY)); - if(!(pixelRgb == innerRgb)) - { - _LIT(KCompareFailed, "Corner check failed on app mode: %d"); - TBuf<256> x; - x.Format(KCompareFailed, res+1); - Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x); - CleanupStack::PopAndDestroy(bmp2); - continue; - } - } - } - - pixelReadBackDevice->GetPixel(pixelRgb, readBackRect.iTl); - ASSERT_TRUE(pixelRgb == innerRgb); - pixelReadBackDevice->GetPixel(pixelRgb, TPoint(readBackRect.iBr.iX, readBackRect.iTl.iY)); - ASSERT_TRUE(pixelRgb == innerRgb); - pixelReadBackDevice->GetPixel(pixelRgb, readBackRect.iBr); - ASSERT_TRUE(pixelRgb == innerRgb); - pixelReadBackDevice->GetPixel(pixelRgb, TPoint(readBackRect.iTl.iX, readBackRect.iBr.iY)); - ASSERT_TRUE(pixelRgb == innerRgb); - - CleanupStack::PopAndDestroy(bmp2); - } - screenModeList.Close(); - CleanupStack::PopAndDestroy(4, dsaDraw); - } - -/** -@SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0012L -@SYMTestCaseDesc Test Pointer event coordinates are correct in different screen modes. -@SYMREQ REQ10336 -@SYMPREQ PREQ2102 -@SYMTestType CT -@SYMTestPriority 1 -@SYMTestPurpose Test Pointer event coordinates are correct in different screen mode -@SYMTestActions - In each screen mode, the simulated pointer event should always at the same relative position - inside iCompare window -@SYMTestExpectedResults - All test should pass - **NOTE Can only be tested in screen 0 ** -*/ -void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0012L() - { - LOG_AND_PANIC_IF_NOT_GCE; - ResetScreens(); - MakeTitleAndCompareWindowsL(_L("GFX_WSERV_DYNAMICRES_0012L"),_L("Pointer coordinates")); - Pause(300); - - CWsDisplayEvent* displayEventAO = new(ELeave) CWsDisplayEvent(&iSession); - CleanupStack::PushL(displayEventAO); - displayEventAO->Request(); - CEventTimer *timer = CEventTimer::NewL(); - CleanupStack::PushL(timer); - - MDisplayMapping* mappingInterface = static_cast - (iScreenDevice->GetInterface(MDisplayMapping::ETypeId)); - ASSERT_TRUE(mappingInterface); - - RArray screenModeList; - iInfoScreenDevice->GetScreenSizeModeList(&screenModeList); - iSession.SetFocusScreen(TGlobalSettings::Instance().iScreen); - - for (TInt res=0;resSetAppScreenMode(screenModeList[res]); - iScreenDevice->SetScreenMode(screenModeList[res]); - Pause(300); - - //win position in app space - TPoint winPos = iCompare.AbsPosition(); - TSize winSize = iCompare.Size(); - - //pointer event at the origin of window - TRect rectNearWinOrigin(winPos+TPoint(1,1), TSize(1,1)); - //the expected pointer position received by client to compare with the actual point received. - //it's (1,1) because it's relative to window - displayEventAO->SetExpectedPointPos(TPoint(1, 1)); - TRect rectInComp, rectBackInApp; - mappingInterface->MapCoordinates(EApplicationSpace, rectNearWinOrigin, ECompositionSpace, rectInComp); - //as we got the physical coordinates at where we simulate pointer event - TRawEvent rawEvent; - rawEvent.Set(TRawEvent::EButton1Down, rectInComp.iTl.iX, rectInComp.iTl.iY); - iSession.SimulateRawEvent(rawEvent); - rawEvent.Set(TRawEvent::EButton1Up, rectInComp.iTl.iX, rectInComp.iTl.iY); - iSession.SimulateRawEvent(rawEvent); - iSession.Flush(); - timer->Wait(1000); - - ASSERT_EQUALS(displayEventAO->ReceivedPointerEventCount(), res*4+2); - ASSERT_TRUE(displayEventAO->PointerTestPassed()); - - //pointer event at 1/2 width and height inside the window - TRect rectAtWinCenter(winPos+TPoint(winSize.iWidth/2, winSize.iHeight/2), TSize(1,1)); - displayEventAO->SetExpectedPointPos(rectAtWinCenter.iTl - winPos); - mappingInterface->MapCoordinates(EApplicationSpace, rectAtWinCenter, ECompositionSpace, rectInComp); - //as we got the physical coordinates at where we simulate pointer event - rawEvent.Set(TRawEvent::EButton1Down, rectInComp.iTl.iX, rectInComp.iTl.iY); - iSession.SimulateRawEvent(rawEvent); - rawEvent.Set(TRawEvent::EButton1Up, rectInComp.iTl.iX, rectInComp.iTl.iY); - iSession.SimulateRawEvent(rawEvent); - iSession.Flush(); - timer->Wait(1000); - - ASSERT_EQUALS(displayEventAO->ReceivedPointerEventCount(), res*4 + 4); - ASSERT_TRUE(displayEventAO->PointerTestPassed()); - } - screenModeList.Close(); - CleanupStack::PopAndDestroy(2, displayEventAO); - } - -/** -@SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0013L -@SYMTestCaseDesc Test the twips size after detach -@SYMREQ REQ10329 -@SYMPREQ PREQ2102 -@SYMTestType CT -@SYMTestPurpose Make sure the twips size is undefined after detach. -@SYMTestActions - Save display configuration before detach and compare it with the display configuration after detach. -@SYMTestExpectedResults - all tests should pass -*/ -void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0013L() - { - LOG_AND_PANIC_IF_NOT_GCE; - ResetScreens(); -#ifdef MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER - ASSERT_FALSE("Test not compiled because MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER"); -#else - TInt error; - iSession.Finish(ETrue); - MakeTitleAndCompareWindowsL(_L("GFX_WSERV_DYNAMICRES_0013L"),_L("detach/attach - twips size")); - iSession.Finish(ETrue); - - Pause(1000); - TInt screenNo = iScreenDevice->GetScreenNumber(); - RArray screenModeList; - iInfoScreenDevice->GetScreenSizeModeList(&screenModeList); - MDisplayControl* interface = static_cast - (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); - ASSERT_TRUE(interface); - - MDisplayMapping* mappingInterface = static_cast - (iScreenDevice->GetInterface(MDisplayMapping::ETypeId)); - ASSERT_TRUE(mappingInterface); - - TInt resolutions = interface->NumberOfResolutions(); - ASSERT_TRUE (resolutions > 0); - - RArray resolutionList1; - error = interface->GetResolutions(resolutionList1); - ASSERT_EQUALS(error,KErrNone); - ASSERT_EQUALS(resolutionList1.Count(), resolutions); - - TDisplayConfiguration configBeforeDetach; - - // detach the display - interface->GetConfiguration(configBeforeDetach); - TInt displayState = EDisconnect; - UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL); - Pause(300); - - // retrieve the display configuration - interface->GetConfiguration(configBeforeDetach); - ASSERT_FALSE(configBeforeDetach.IsDefined(TDisplayConfiguration::EResolutionTwips)); - - error = interface->GetResolutions(resolutionList1); - ASSERT_EQUALS(error,KErrDisconnected); - - configBeforeDetach.ClearAll(); - - screenModeList.Close(); - resolutionList1.Close(); - - displayState = ENormalResolution; - UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL); -#endif - } - -/** -@SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0014L -@SYMTestCaseDesc Test GetConfiguration immediatly after SetConfiguration -@SYMREQ REQ10328 -@SYMPREQ PREQ2102 -@SYMTestType CT -@SYMTestPurpose Make sure the twips size is buffered so immediate GetConfiguration can get correct twip size -@SYMTestActions - successive SetConfiguration/GetConfiguration pair -@SYMTestExpectedResults - all tests should pass -*/ -void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0014L() - { - MDisplayControl* interface = static_cast - (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); - ASSERT_TRUE(interface); - - RArray resolutions; - TInt err = interface->GetResolutions(resolutions); - ASSERT_EQUALS(err, KErrNone); - TDisplayConfiguration configSet, configGet; - TSize twipsGet, resolutionGet; - - TInt screenNo = iScreenDevice->GetScreenNumber(); - iSession.SetFocusScreen(TGlobalSettings::Instance().iScreen); - for(TInt testIndex = 0; testIndex < 2; testIndex++) - {//run twice -#ifdef MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER - INFO_PRINTF1(_L("Test not compiled because MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER")); -#else - TInt displayState; - displayState = ENormalResolution; - UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL); -#endif - for (TInt i=0;iSetConfiguration(configSet); - if(err != KErrNone) - { - //with scaling, KErrArgument means current config is not compatible with appmode. - //In none scaling, it does mean an error, - //but the purpose of this test is to see if twips size is buffered so we can read it back instantly - //let other tests test the functionality of SetConfiguration. - ASSERT_EQUALS(err, KErrArgument); - - INFO_PRINTF1(_L("this configuration is not compatible with current appmode, skip")); - continue; - } - interface->GetConfiguration(configGet); - ASSERT_TRUE(configGet.IsDefined(TDisplayConfigurationBase::EResolutionTwips)); - ASSERT_TRUE(configGet.IsDefined(TDisplayConfigurationBase::EResolution)); - configGet.GetResolutionTwips(twipsGet); - configGet.GetResolution(resolutionGet); - INFO_PRINTF3(_L("resolution readback: %i x %i"), resolutionGet.iWidth, resolutionGet.iHeight); - INFO_PRINTF3(_L("twips readback: %i x %i"), twipsGet.iWidth, twipsGet.iHeight); - ASSERT_EQUALS(twipsGet, resolutions[i].iTwipsSize); - Pause(300); - } -#ifdef MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER - INFO_PRINTF1(_L("Test not compiled because MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER")); -#else - displayState = EDisconnect; - UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL); -#endif - } - resolutions.Close(); - - } - -/** -@SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0015L -@SYMTestCaseDesc No Scaling doesnt return virtual resolutions -@SYMREQ REQ10336 -@SYMPREQ PREQ2102 -@SYMTestType CT -@SYMTestPriority 1 -@SYMTestPurpose no scaling should mean basic resolution selection -@SYMTestActions - Get resolution list - Should not contain virtual resolutions - Set every app mode - Should not change resolution -@SYMTestExpectedResults - All test should pass - **SENSITIVE TO CHANGES IN EPOC.INI and WSINI.INI** -*/ -void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0015L() - { //ONLY RUN WITH 'NO SCALING' WSINI.INI, can be found in resources - MDisplayControl* interface = static_cast - (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); - ASSERT_TRUE(interface); - - TInt resolutions = interface->NumberOfResolutions(); - TInt screenNumber = iScreenDevice->GetScreenNumber(); - if (screenNumber == 0) - { - ASSERT_EQUALS(resolutions,1); - } - else if (screenNumber == 1) - { - ASSERT_EQUALS(resolutions,4); - } - - RArray resolutionList1; - TInt error = interface->GetResolutions(resolutionList1); - ASSERT_EQUALS(error,KErrNone); - ASSERT_EQUALS(resolutionList1.Count(), resolutions); - - RArray screenModeList; - iInfoScreenDevice->GetScreenSizeModeList(&screenModeList); - - TDisplayConfiguration dispConfig1; - interface->GetConfiguration(dispConfig1); - TSize size1; - ASSERT_TRUE(dispConfig1.GetResolution(size1)); - - for (TInt ii = 0; ii < screenModeList.Count(); ii++) - { - iInfoScreenDevice->SetAppScreenMode(screenModeList[ii]); - iInfoScreenDevice->SetScreenMode(screenModeList[ii]); - iSession.Finish(ETrue); - Pause(300); - - TDisplayConfiguration newConfig; - interface->GetConfiguration(newConfig); - TSize newSize; - ASSERT_TRUE(dispConfig1.GetResolution(newSize)); - ASSERT_EQUALS(size1,newSize); - } - iInfoScreenDevice->SetAppScreenMode(screenModeList[0]); - iInfoScreenDevice->SetScreenMode(screenModeList[0]); - iSession.Finish(ETrue); - Pause(300); - - screenModeList.Close(); - resolutionList1.Close(); - } - -/** -@SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0016L -@SYMTestCaseDesc Anisotropic scaling -@SYMREQ REQ10336 -@SYMPREQ PREQ2102 -@SYMTestType CT -@SYMTestPriority 1 -@SYMTestPurpose Check using twips will cause virtual resolutions to possibly be different -@SYMTestActions - Check the virtual resolution for XXX is correctly XXX - Check when setting the appmode, it choses the correct resolution -@SYMTestExpectedResults - Tests should pass - **SENSITIVE TO CHANGES IN EPOC.INI and WSINI.INI** -*/ -void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0016L() - { //ONLY RUN WITH ANISOTROPIC WSINI.INI - - } - -/** -@SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0017L -@SYMTestCaseDesc Integer scales correctly in policy -@SYMREQ REQ10336 -@SYMPREQ PREQ2102 -@SYMTestType CT -@SYMTestPriority 1 -@SYMTestPurpose Integer scaling should not create resolutions of non integer value! -@SYMTestActions - For every virtual resolution - Check its an integer size of a real resolution -@SYMTestExpectedResults - All should be integers (1:1 , 1:2 , 1:3 or 1:4 in current policy) - **NOTE ONLY RUN WITH INTEGER WSINI.INI** -*/ -void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0017L() - { //ONLY RUN WITH INTEGER WSINI.INI - MDisplayControl* interface = static_cast - (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); - ASSERT_TRUE(interface); - - TInt resolutions = interface->NumberOfResolutions(); - ASSERT_TRUE(resolutions>1); - - RArray resolutionList1; - TInt error = interface->GetResolutions(resolutionList1); - ASSERT_EQUALS(error,KErrNone); - ASSERT_EQUALS(resolutionList1.Count(), resolutions); - - TInt index; - for (index=0;index - (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); - ASSERT_TRUE(interface); - - MDisplayMapping* mapInterface = static_cast - (iScreenDevice->GetInterface(MDisplayMapping::ETypeId)); - ASSERT_TRUE(mapInterface); - - RArray screenModeList; - iInfoScreenDevice->GetScreenSizeModeList(&screenModeList); - - TRect maxWinExtent, refMaxWinExtent; - TSize surfaceSize, surfaceTwips, refSurfaceSize, refSurfaceTwips; - TRect displayWinExtent, refDisplayWinExtent; - for (TInt i = 0; i < screenModeList.Count(); i++) - { - iInfoScreenDevice->SetAppScreenMode(screenModeList[i]); - iInfoScreenDevice->SetScreenMode(screenModeList[i]); - iSession.Finish(ETrue); - Pause(300); - - INFO_PRINTF1(_L("---------------")); - INFO_PRINTF2(_L("screen mode : %i"), screenModeList[i]); - - mapInterface->GetMaximumWindowExtent(maxWinExtent); - INFO_PRINTF3(_L("MaximumWindowExtent Origin: (%i, %i)"), maxWinExtent.iTl.iX, maxWinExtent.iTl.iY); - INFO_PRINTF3(_L("MaximumWindowExtent Size: %i x %i"), maxWinExtent.Width(), maxWinExtent.Height()); - - - TDisplayConfiguration config; - interface->GetConfiguration(config); - ASSERT_TRUE(config.IsDefined(TDisplayConfigurationBase::EResolution)); - TSize fullUiSize; - config.GetResolution(fullUiSize); - error = mapInterface->MapCoordinates(EFullScreenSpace, fullUiSize, EApplicationSpace, refMaxWinExtent); - ASSERT_EQUALS(error, KErrNone); - INFO_PRINTF3(_L("ref MaximumWindowExtent Origin: (%i, %i)"), refMaxWinExtent.iTl.iX, refMaxWinExtent.iTl.iY); - INFO_PRINTF3(_L("ref MaximumWindowExtent Size: %i x %i"), refMaxWinExtent.Width(), refMaxWinExtent.Height()); - ASSERT_EQUALS(maxWinExtent, refMaxWinExtent); - INFO_PRINTF1(_L("Match")); - - mapInterface->GetMaximumSurfaceSize(surfaceSize, surfaceTwips); - INFO_PRINTF3(_L("MaxSurfaceSize: %i x %i"), surfaceSize.iWidth, surfaceSize.iHeight); - INFO_PRINTF3(_L("MaxSurfaceTwips: %i x %i"), surfaceTwips.iWidth, surfaceSize.iHeight); - TRect compositionRect; - error = mapInterface->MapCoordinates(EFullScreenSpace, fullUiSize, ECompositionSpace, compositionRect); - ASSERT_EQUALS(error, KErrNone); - refSurfaceSize = compositionRect.Size(); - INFO_PRINTF3(_L("RefSurfaceSize: %i x %i"), refSurfaceSize.iWidth, refSurfaceSize.iHeight); - ASSERT_TRUE(config.IsDefined(TDisplayConfigurationBase::EResolutionTwips)); - config.GetResolutionTwips(refSurfaceTwips); - INFO_PRINTF3(_L("RefSurfaceTwips: %i x %i"), refSurfaceTwips.iWidth, refSurfaceTwips.iHeight); - ASSERT_EQUALS(surfaceSize, refSurfaceSize); - ASSERT_EQUALS(surfaceTwips, refSurfaceTwips); - INFO_PRINTF1(_L("Match")); - - mapInterface->GetDisplayExtentOfWindow(iCompare, displayWinExtent); - INFO_PRINTF3(_L("DisplayWin origin: (%i, %i)"), displayWinExtent.iTl.iX, displayWinExtent.iTl.iY); - INFO_PRINTF3(_L("DisplayWin Size: (%i x %i"), displayWinExtent.Width(), displayWinExtent.Height()); - error = mapInterface->MapCoordinates(EApplicationSpace, TRect(TPoint(iCompare.AbsPosition()),iCompare.Size()), ECompositionSpace, refDisplayWinExtent); - ASSERT_EQUALS(error, KErrNone); - INFO_PRINTF3(_L("RefDisplayWin origin: (%i, %i)"), refDisplayWinExtent.iTl.iX, refDisplayWinExtent.iTl.iY); - INFO_PRINTF3(_L("RefDisplayWin Size: (%i x %i"), refDisplayWinExtent.Width(), refDisplayWinExtent.Height()); - ASSERT_EQUALS(displayWinExtent, refDisplayWinExtent); - INFO_PRINTF1(_L("Match")); - } - iInfoScreenDevice->SetAppScreenMode(screenModeList[0]); - iInfoScreenDevice->SetScreenMode(screenModeList[0]); - screenModeList.Close(); - } - -/* -@SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0021L -@SYMTestCaseDesc SetResolution negative test -@SYMREQ REQ10326 -@SYMPREQ PREQ2102 -@SYMTestType CT -@SYMTestPriority 1 -@SYMTestPurpose Invalid configurations should return error and change nothing! -@SYMTestActions - Set config with rubbish resolution - Set config with rubbish twips - Set config with valid resolution, rubbish twips - Set config with valid twips, rubbish resolution - Set config with nothing defined -@SYMTestExpectedResults - Should all fail safely and not change any settings. - Config with nothing defined in a scaled mode will reset the resolution to current modes - equivilent virtual resolution - **NOTE ONLY RUN IN SCREEN 1 - we need multiple resolutions available** -*/ -void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0021L(TBool aScaleMode) - { //aScaleMode 0 = no scaling, 1 = integer,isotropic or anisotropic - MDisplayControl* interface = static_cast - (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); - ASSERT_TRUE(interface); - - TInt resolutions = interface->NumberOfResolutions(); - ASSERT_TRUE (resolutions > 1); - - RArray resolutionList1; - TInt error = interface->GetResolutions(resolutionList1); - ASSERT_EQUALS(resolutionList1.Count(), resolutions); - - TDisplayConfiguration original; - original.SetResolution(resolutionList1[0].iPixelSize); - error = interface->SetConfiguration(original); - ASSERT_EQUALS(error,KErrNone); - - TDisplayConfiguration beforeConfig; - TDisplayConfiguration afterConfig; - interface->GetConfiguration(beforeConfig); - - TInt differentRes; - for (differentRes = 1; differentRes < resolutions; differentRes++) - { - if (!(resolutionList1[differentRes].iPixelSize == resolutionList1[0].iPixelSize)) - { - break; - } - } - ASSERT_TRUE(differentRes < resolutions); //otherwise it didnt find a resolution different to the one set - - TDisplayConfiguration test1; - test1.SetResolution(TSize(5,6)); //rubbish resolution! - error = interface->SetConfiguration(test1); - - ASSERT_EQUALS(error,KErrArgument); - - ASSERT_EQUALS(error,KErrArgument); - iSession.Flush(); - interface->GetConfiguration(afterConfig); - ASSERT_TRUE(beforeConfig == afterConfig); - - TDisplayConfiguration test2; - test2.SetResolutionTwips(TSize(7,8)); //rubbish twips! - error = interface->SetConfiguration(test2); - ASSERT_EQUALS(error,KErrArgument); - iSession.Flush(); - interface->GetConfiguration(afterConfig); - ASSERT_TRUE(beforeConfig == afterConfig); - - TDisplayConfiguration test3; - test3.SetResolution(resolutionList1[differentRes].iPixelSize); //ok resolution! - test3.SetResolutionTwips(TSize(9,10)); //rubbish twips! - error = interface->SetConfiguration(test3); - //ASSERT_EQUALS(error,KErrArgument); - if (error != KErrArgument) - { - ASSERT_EQUALS (aScaleMode,0); //if no policy, we currently have issue with confing not being validated - INFO_PRINTF1(_L("config was not honoured!")); - error = interface->SetConfiguration(original); - ASSERT_EQUALS(error,KErrNone); - iSession.Flush(); - Pause(200); - } - else - { - iSession.Flush(); - Pause(200); - interface->GetConfiguration(afterConfig); - ASSERT_TRUE(beforeConfig == afterConfig); - } - - TDisplayConfiguration test4; - test4.SetResolution(TSize(11,12)); //rubbish resolution! - test4.SetResolutionTwips(resolutionList1[differentRes].iTwipsSize); //ok twips! - error = interface->SetConfiguration(test4); - if (error != KErrArgument) - { - ASSERT_EQUALS (aScaleMode,0); //if no policy, we currently have issue with config not being validated - INFO_PRINTF1(_L("config was not honoured!")); - error = interface->SetConfiguration(original); - ASSERT_EQUALS(error,KErrNone); - iSession.Flush(); - Pause(200); - } - else - { - iSession.Flush(); - Pause(200); - interface->GetConfiguration(afterConfig); - ASSERT_TRUE(beforeConfig == afterConfig); - } - - if (aScaleMode) - { - RArray screenModeList; - iInfoScreenDevice->GetScreenSizeModeList(&screenModeList); - ASSERT_TRUE(screenModeList.Count()>1); - //set default screen mode, sets resolution to best fit for this mode - iInfoScreenDevice->SetAppScreenMode(screenModeList[0]); - iInfoScreenDevice->SetScreenMode(screenModeList[0]); //also sets its best resolution - iSession.Finish(ETrue); - Pause(200); - - TDisplayConfiguration newModeConfig; - interface->GetConfiguration(newModeConfig); - //get best fit resolution - TSize newModeRes; - ASSERT_TRUE(newModeConfig.GetResolution(newModeRes)); - - //find a different resolution - TInt i; - for (i = 0; i < resolutions; i++) - { - if (!(resolutionList1[i].iPixelSize == newModeRes)) - { - break; - } - } - ASSERT_TRUE(i < resolutions); //otherwise it didnt find a resolution different to the one set - TDisplayConfiguration newSetConfig; - - //set the different resolution - newSetConfig.SetResolution(resolutionList1[i].iPixelSize); - error = interface->SetConfiguration(newSetConfig); - ASSERT_TRUE(error == KErrNone); - iSession.Flush(); - Pause(200); - TDisplayConfiguration checkConfig; - - //check its set this new resolution - interface->GetConfiguration(checkConfig); - TSize checkSize; - checkConfig.GetResolution(checkSize); - ASSERT_TRUE (checkSize == resolutionList1[i].iPixelSize); - - TDisplayConfiguration emptyConfig; - TDisplayConfiguration newModeConfig2(newModeConfig); - newModeConfig2.Clear(newModeConfig2.EResolutionTwips); - //set empty config, which should reset resolution to current modes default - error = interface->SetConfiguration(emptyConfig);//emptyConfig); - ASSERT_TRUE(error == KErrNone); - iSession.Finish(); - Pause(200); - - interface->GetConfiguration(checkConfig); - ASSERT_TRUE (newModeConfig == checkConfig); //empty config reset res to modes default res - - screenModeList.Close(); - } - else - { - TDisplayConfiguration test5; - error = interface->SetConfiguration(test5); - ASSERT_EQUALS(error,KErrArgument); - } - resolutionList1.Close(); - } - -/** -@SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0031L -@SYMTestCaseDesc SetConfiguration in OOM (changing resolution) -@SYMREQ REQ10326 -@SYMPREQ PREQ2102 -@SYMTestType CT -@SYMTestPriority 1 -@SYMTestPurpose Safety check against OOM -@SYMTestActions - Set OOM failure - Set a resolution that will definately cause a change of resolution - Increase length of time to failure, repeat - Finish after 5 successful changes of resolution -@SYMTestExpectedResults - Set resolution should either return a fail and not have cause a change in resolution, - or it should have returned no fail and have set the new resolution -*/ -void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0031L() - { - MDisplayControl* interface = static_cast - (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); - ASSERT_TRUE(interface); - INFO_PRINTF1(_L("Interface obtained sucessfully.")); - - TInt resolutions = interface->NumberOfResolutions(); - ASSERT_TRUE (resolutions > 0); - INFO_PRINTF1(_L("NumberOfResolutions obtained sucessfully.")); - - RArray resolutionList1; - TInt error = interface->GetResolutions(resolutionList1); - ASSERT_EQUALS(error,KErrNone); - ASSERT_EQUALS(resolutionList1.Count(), resolutions); - INFO_PRINTF1(_L("resolutionList1 has correct number of resolutions.")); - - TInt index; - TDisplayConfiguration dispConfigBefore; - TDisplayConfiguration dispConfigAfter; - - dispConfigBefore.SetResolution(resolutionList1[0].iPixelSize); - interface->SetConfiguration(dispConfigBefore); - interface->GetConfiguration(dispConfigBefore); - ASSERT_TRUE(dispConfigBefore.IsDefined(dispConfigBefore.EResolution)); - INFO_PRINTF1(_L("dispConfigBefore is defined.")); - TSize dispResBefore; - TSize dispResAfter; - dispConfigBefore.GetResolution(dispResBefore); - TDisplayConfiguration::TRotation dispRotBefore; - TDisplayConfiguration::TRotation dispRotReq; - dispConfigBefore.GetRotation(dispRotBefore); - - for (index = 0; index < resolutionList1.Count(); index++) - { - INFO_PRINTF2(_L("Starting resolution %d."), index); - if (resolutionList1[index].iPixelSize.iWidth == 0) - { - continue; - } - TInt heapFail = 1; - TBool notComplete = ETrue; - TInt completeCount = 0; - while (notComplete) - { - TDisplayConfiguration dispConfigReq; - dispConfigReq.SetResolution(resolutionList1[index].iPixelSize); - ASSERT_TRUE(dispConfigReq.IsDefined(dispConfigReq.EResolution)); - SetRotation(dispConfigReq,resolutionList1[index]); //set rotation to first defined in res list - dispConfigReq.GetRotation(dispRotReq); - INFO_PRINTF2(_L("Before heap failure, value of heapfail is %d."), heapFail); - - iSession.Finish(ETrue); - iSession.HeapSetFail(RHeap::EDeterministic,heapFail); - TInt errCode=interface->SetConfiguration(dispConfigReq); - iSession.HeapSetFail(RHeap::ENone,0); - INFO_PRINTF1(_L("After Heap Failure.")); - iSession.Finish(ETrue); - Pause (100); - INFO_PRINTF1(_L("After Session Finish.")); - - interface->GetConfiguration(dispConfigAfter); - ASSERT_TRUE(dispConfigAfter.IsDefined(dispConfigAfter.EResolution)); - dispConfigAfter.GetResolution(dispResAfter); - - TBool worked = ETrue; - if (errCode < KErrNone) - { - worked = EFalse; - ASSERT_EQUALS(dispResAfter,dispResBefore); - if (dispRotReq != dispRotBefore) - { //didnt expect it work-KErrGeneral can mean a memory allocation fail - if (errCode == KErrArgument) - { //if it didnt panic, that is a good enough pass in this instance - worked = ETrue; - } - } - } - else - { - ASSERT_EQUALS(dispResAfter,resolutionList1[index].iPixelSize); - } - if (worked) - { - completeCount++; - if (completeCount == 5) - { - notComplete = EFalse; - } - } - else - { - completeCount = 0; - } - interface->SetConfiguration(dispConfigBefore); - INFO_PRINTF1(_L("After Setting Original Configuration.")); - heapFail++; - if (heapFail == 80) - { - ASSERT_TRUE(0); //worrying amount of fails - } - } - } - resolutionList1.Close(); - } - -/** -@SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0032L -@SYMTestCaseDesc SetAppMode in OOM -@SYMREQ REQ10326 REQ10336 -@SYMPREQ PREQ2102 -@SYMTestType CT -@SYMTestPriority 1 -@SYMTestPurpose Safety check against OOM -@SYMTestActions - Set OOM failure - Set new app mode - Increase length of time to failure, repeat - Finish after 5 successful changes of mode -@SYMTestExpectedResults - SetAppMode should either return a fail and not have cause a change in resolution, - or it should have returned no fail and have set the new resolution -*/ -void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0032L() - { - MDisplayControl* interface = static_cast - (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); - ASSERT_TRUE(interface); - - TInt resolutions = interface->NumberOfResolutions(); - ASSERT_TRUE (resolutions > 0); - RArray screenModeList; - iInfoScreenDevice->GetScreenSizeModeList(&screenModeList); - ASSERT_TRUE (screenModeList.Count()>0); - - iInfoScreenDevice->SetAppScreenMode(screenModeList[0]); - iInfoScreenDevice->SetScreenMode(screenModeList[0]); - - for (TInt index = 1; index < screenModeList.Count(); index++) - { //skip index 0, as that wouldn't be changing mode - TInt heapFail = 1; - TBool notComplete = ETrue; - TInt completeCount = 0; - while (notComplete) - { - iInfoScreenDevice->SetAppScreenMode(screenModeList[index]); - iSession.Finish(ETrue); - iSession.HeapSetFail(RHeap::EDeterministic,heapFail); - iInfoScreenDevice->SetScreenMode(screenModeList[index]); - iSession.HeapSetFail(RHeap::ENone,0); - iSession.Finish(ETrue); - Pause(50); - TInt newMode = iInfoScreenDevice->CurrentScreenMode(); - - if (screenModeList[index] == newMode) - { - completeCount++; - if (completeCount == 5) - { - INFO_PRINTF2(_L("Succeeded with heapFail = %d"),heapFail); - notComplete = EFalse; - } - iInfoScreenDevice->SetAppScreenMode(screenModeList[0]); - iInfoScreenDevice->SetScreenMode(screenModeList[0]); - iSession.Finish(ETrue); - Pause(50); - } - else - { - completeCount = 0; - } - heapFail++; - if (heapFail == 80) - { - ASSERT_TRUE(0); //worrying amount of fails - } - } - } - screenModeList.Close(); - } - -/** -@SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0033L -@SYMTestCaseDesc GetConfiguration in OOM -@SYMREQ REQ10328 -@SYMPREQ PREQ2102 -@SYMTestType CT -@SYMTestPriority 1 -@SYMTestPurpose Safety check against OOM -@SYMTestActions - Set OOM failure - GetConfiguration - Check config - Increase time till failure - Success after 5 completed gets -@SYMTestExpectedResults - Should always succeed -*/ -void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0033L() - { - MDisplayControl* interface = static_cast - (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); - ASSERT_TRUE(interface); - - TInt heapFail = 1; - for (TInt i=0;i<5;i++) - { - TDisplayConfiguration config; - iSession.Finish(ETrue); - iSession.HeapSetFail(RHeap::EDeterministic,heapFail); - interface->GetConfiguration(config); - iSession.HeapSetFail(RHeap::ENone,0); - iSession.Finish(ETrue); - ASSERT_TRUE(config.IsDefined(config.ERotation)); - ASSERT_TRUE(config.IsDefined(config.EResolution)); - ASSERT_TRUE(config.IsDefined(config.EResolutionTwips)); - heapFail++; - } - } - -/** -@SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0034L -@SYMTestCaseDesc GetResolutions in OOM -@SYMREQ REQ10328 -@SYMPREQ PREQ2102 -@SYMTestType CT -@SYMTestPriority 1 -@SYMTestPurpose Safety check against OOM -@SYMTestActions - Set OOM failure - GetResolutions - Check resolutions filled in - Success after 5 completed gets -@SYMTestExpectedResults - Should never panic! -*/ -void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0034L() - { - MDisplayControl* interface = static_cast - (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); - ASSERT_TRUE(interface); - - TInt resolutions = interface->NumberOfResolutions(); - ASSERT_TRUE(resolutions>1); - - RArray resolutionList1; - TInt error = interface->GetResolutions(resolutionList1); - ASSERT_EQUALS(error,KErrNone); - ASSERT_TRUE(resolutionList1.Count() > 0); - - TInt heapFail = 1; - TInt completeCount = 0; - TBool notComplete = ETrue; - while (notComplete) - { - RArray resolutionList2; - iSession.Finish(ETrue); - iSession.HeapSetFail(RHeap::EDeterministic,heapFail); - error = interface->GetResolutions(resolutionList2); - iSession.HeapSetFail(RHeap::ENone,0); - iSession.Finish(ETrue); - if (errorSizeInPixels()); - screenSize.Shrink(5,5); - - RBlankWindow testWindow; - if (iInfoGc) - { - testWindow=RBlankWindow(iSession); - ASSERT_EQUALS(testWindow.Construct(*iInfoGroup, ++iWindowHandle), KErrNone); - testWindow.SetColor(iBlue); - testWindow.SetExtent(screenSize.iTl,screenSize.Size()); - testWindow.Activate(); - - if (testWindow.WsHandle()) - { - iSession.Flush(); - iSession.Finish(); - } - testWindow.SetVisible(ETrue); - } - - iSession.Finish(ETrue); - - RArray screenModeList; - iInfoScreenDevice->GetScreenSizeModeList(&screenModeList); - MDisplayControl* interface = static_cast - (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); - ASSERT_TRUE(interface); - - TInt resolutions = interface->NumberOfResolutions(); - ASSERT_TRUE (resolutions > 0); - - RArray resolutionList1; - error = interface->GetResolutions(resolutionList1); - ASSERT_EQUALS(error,KErrNone); - ASSERT_EQUALS(resolutionList1.Count(), resolutions); - - TDisplayConfiguration dispConfigBefore; - interface->GetConfiguration(dispConfigBefore); - ASSERT_TRUE(dispConfigBefore.IsDefined(dispConfigBefore.EResolution)) - if (screenModeList.Count()>1) - { - //Got a mode to change to! - TSize resBefore; - TBool ok=dispConfigBefore.GetResolution(resBefore); - ASSERT_TRUE(ok); //we "know" this should be ok, as we just asserted the flag - for (TInt res=0;resSetAppScreenMode(screenModeList[res]); - iInfoScreenDevice->SetScreenMode(screenModeList[res]); - iSession.Finish(ETrue); - Pause(300); - - - TSize pr = iInfoScreenDevice->SizeInPixels(); - TPoint origin=iInfoScreenDevice->GetDefaultScreenModeOrigin(); - Pause(300); - TSize winpos; - - TSize surfaceSize = pr; - surfaceSize.iWidth /= 2; - surfaceSize.iWidth -= 20; - surfaceSize.iHeight -= 20; - TSurfaceId surfaceID; - TRAPD(err, surfaceID = iUtility->CreateSurfaceL(surfaceSize, - KSurfaceFormat, surfaceSize.iWidth * KBytesPerPixel)); - ASSERT_EQUALS(err,KErrNone); - TRAP(err,iUtility->PatternFillSurfaceL(surfaceID)); - ASSERT_EQUALS(err,KErrNone); - - CFbsBitmap* equivalentBitmap=NULL; - TRAP(err,equivalentBitmap=iUtility->EquivalentBitmapL(surfaceID)); - CleanupStack::PushL(equivalentBitmap); - ASSERT_EQUALS(err,KErrNone); - - screenSize = iInfoScreenDevice->SizeInPixels(); - TSize testSize = iScreenDevice->SizeInPixels(); - screenSize.Shrink(5,5); - - if (iInfoGc) - { - testWindow.SetExtent(screenSize.iTl,screenSize.Size()); - - if (testWindow.WsHandle()) - { - - iSession.Flush(); - iSession.Finish(); - } - testWindow.SetVisible(ETrue); - } - Pause(200); - iSession.Finish(ETrue); - - RWindow surfWindow; - if (iInfoGc) - { - surfWindow=RWindow(iSession); - ASSERT_EQUALS(surfWindow.Construct(*iInfoGroup, ++iWindowHandle), KErrNone); - surfWindow.SetBackgroundSurface(surfaceID); - surfWindow.SetExtent(screenSize.iTl+TPoint( screenSize.Width()/2 +5,5),surfaceSize); - surfWindow.Activate(); - - if (surfWindow.WsHandle()) - { - surfWindow.Invalidate(); - - surfWindow.BeginRedraw(); - ActivateWithWipe(iInfoGc,surfWindow,iRed); - surfWindow.EndRedraw(); - - iSession.Flush(); - iSession.Finish(); - } - surfWindow.SetVisible(ETrue); - iInfoGc->Deactivate(); - } - - iSession.Finish(ETrue); - - TRect bitmapDrawRect; - bitmapDrawRect = surfaceSize; - - RWindow bmpWindow; - if (iInfoGc) - { - bmpWindow=RWindow(iSession); - ASSERT_EQUALS(bmpWindow.Construct(*iInfoGroup, ++iWindowHandle), KErrNone); - bmpWindow.SetBackgroundColor(iRed); - bmpWindow.SetExtent(screenSize.iTl+TPoint(5,5),surfaceSize); - bmpWindow.Activate(); - - if (bmpWindow.WsHandle()) - { - bmpWindow.Invalidate(); - - bmpWindow.BeginRedraw(); - ActivateWithWipe(iInfoGc,bmpWindow,iRed); - // Not drawing, draw twice?? - iInfoGc->DrawBitmap(bitmapDrawRect, equivalentBitmap); - bmpWindow.EndRedraw(); - - iSession.Flush(); - iSession.Finish(); - } - bmpWindow.SetVisible(ETrue); - iInfoGc->Deactivate(); - } - Pause(200); - iSession.Finish(ETrue); - - - if (iInfoGc) - { - - if (bmpWindow.WsHandle()) - { - bmpWindow.Invalidate(); - - bmpWindow.BeginRedraw(); - ActivateWithWipe(iInfoGc,bmpWindow,iRed); - // Not drawing, draw twice?? - iInfoGc->DrawBitmap(bitmapDrawRect, equivalentBitmap); - bmpWindow.EndRedraw(); - - iSession.Flush(); - iSession.Finish(); - } - bmpWindow.SetVisible(ETrue); - iInfoGc->Deactivate(); - } - Pause(200); - iSession.Finish(ETrue); - - if (iInfoGc) - { - - if (bmpWindow.WsHandle()) - { - bmpWindow.Invalidate(); - - bmpWindow.BeginRedraw(); - ActivateWithWipe(iInfoGc,bmpWindow,iRed); - // Not drawing, draw twice?? - iInfoGc->DrawBitmap(bitmapDrawRect, equivalentBitmap); - bmpWindow.EndRedraw(); - iSession.Flush(); - iSession.Finish(); - } - bmpWindow.SetVisible(ETrue); - iInfoGc->Deactivate(); - } - Pause(200); - iSession.Finish(ETrue); - - RArray regionArray; - - RRegion equivRegion; - TBitmapRegionPair bitmap1Region; - bitmap1Region.bitmap = equivalentBitmap; - bitmap1Region.drawRect = TRect(TPoint(0,0),surfaceSize); - equivRegion.AddRect(TRect(TPoint(0,0),surfaceSize)); - bitmap1Region.region = &equivRegion; - - regionArray.Append(bitmap1Region); - - - TDisplayConfiguration dispConfigAfter2; - interface->GetConfiguration(dispConfigAfter2); - TSize theSize; - dispConfigAfter2.GetResolution(theSize); - TDisplayConfiguration1::TRotation orient; - dispConfigAfter2.GetRotation(orient); - if (orient == TDisplayConfiguration1::ERotation90CW || orient == TDisplayConfiguration1::ERotation270CW) - { - TInt temp = theSize.iHeight; - theSize.iHeight = theSize.iWidth; - theSize.iWidth = temp; - } - TRect uiSize(TPoint(0,0), theSize); - MDisplayMapping* mappingInterface = static_cast - (iScreenDevice->GetInterface(MDisplayMapping::ETypeId)); - ASSERT_TRUE(mappingInterface); - TRect finalSize; - mappingInterface->MapCoordinates(EApplicationSpace, uiSize, ECompositionSpace, finalSize); - - - CFbsBitmap* bmp2 = new (ELeave) CFbsBitmap; - CleanupStack::PushL(bmp2); - User::LeaveIfError(bmp2->Create(finalSize.Size(), EColor16MU)); - - MTestScreenCapture - * csc = - static_cast (iScreenDevice->GetInterface(MTestScreenCapture::KUidTestScreenCaptureIf)); - if (csc) - { - TInt errr = csc->ComposeScreen(*bmp2); - ASSERT_TRUE(errr == KErrNone); - } - else - { - if (!cSCLogged) - { - cSCLogged = ETrue; - _LIT(KNoCSC, "CSC testing not enabled as CSC render stage not defined"); - Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrAll, KNoCSC); - } - } - - - TRect compareRect(bmpWindow.AbsPosition(), bmpWindow.Size()); - TRect testRect(surfWindow.AbsPosition(), surfWindow.Size()); - - if (csc) - { - if(!Compare(*bmp2, compareRect, testRect, regionArray, aIsSurface)) - { - _LIT(KCompareFailed, "Compare Failed on app mode: %d"); - TBuf<256> x; - x.Format(KCompareFailed, res+1); - Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x); - } - } - - CleanupStack::PopAndDestroy(bmp2); - - equivRegion.Close(); - regionArray.Close(); - - CleanupStack::PopAndDestroy(equivalentBitmap); - surfWindow.Close(); - bmpWindow.Close(); - } - } - } - //restore initial res - if (screenModeList.Count() > 1) - { //set back to basics - iInfoScreenDevice->SetAppScreenMode(screenModeList[0]); - iInfoScreenDevice->SetScreenMode(screenModeList[0]); - Pause(300); - } - - interface->SetConfiguration(dispConfigBefore); - Pause(1000); - TDisplayConfiguration dispConfigAfter; - interface->GetConfiguration(dispConfigAfter); - TSize resAfter; - ok=dispConfigAfter.GetResolution(resAfter); - ASSERT_TRUE(ok); - ASSERT_EQUALS(resBefore,resAfter); - } - else - { - INFO_PRINTF1(_L("Only 1 screen size mode configured on this screen - res change test skipped.")); - } - testWindow.Close(); - screenModeList.Close(); - resolutionList1.Close(); - } - - -/** -@SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0042L -@SYMTestCaseDesc Test Drawing of bitmaps (case 0) and surfaces (case 1) in all different resolutions -@SYMREQ REQ10332 -@SYMPREQ PREQ2102 -@SYMTestType CT -@SYMTestPurpose Check to see if Bitmaps and Surfaces are drawn correctly in different resolutions -@SYMTestActions - A Simple pattern will be drawn by a bitmap on the left and a surface on the right, about half the window size each. The Composited Screen Capture code will be used to compare the drawing to a unchanged copy of the bitmap to see if they are drawn correctly - - Note, add .0 to test name to test bitmap drawing and .1 to test surface drawing -@SYMTestExpectedResults - All tests should pass. - -*/ -void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0042L(TBool aIsSurface) - { - LOG_AND_PANIC_IF_NOT_GCE; - ResetScreens(); - TInt error; - iSession.Finish(ETrue); - - TRect screenSize(iInfoScreenDevice->SizeInPixels()); - screenSize.Shrink(5,5); - - RBlankWindow testWindow; - if (iInfoGc) - { - testWindow=RBlankWindow(iSession); - ASSERT_EQUALS(testWindow.Construct(*iInfoGroup, ++iWindowHandle), KErrNone); - testWindow.SetColor(iBlue); - testWindow.SetExtent(screenSize.iTl,screenSize.Size()); - testWindow.Activate(); - - if (testWindow.WsHandle()) - { - iSession.Flush(); - iSession.Finish(); - } - testWindow.SetVisible(ETrue); - } - - iSession.Finish(ETrue); - - RArray screenModeList; - iInfoScreenDevice->GetScreenSizeModeList(&screenModeList); - MDisplayControl* interface = static_cast - (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); - ASSERT_TRUE(interface); - - TInt resolutions = interface->NumberOfResolutions(); - ASSERT_TRUE (resolutions > 0); - - RArray resolutionList1; - error = interface->GetResolutions(resolutionList1); - ASSERT_EQUALS(error,KErrNone); - ASSERT_EQUALS(resolutionList1.Count(), resolutions); - - TDisplayConfiguration dispConfigBefore; - interface->GetConfiguration(dispConfigBefore); - - iInfoScreenDevice->SetAppScreenMode(screenModeList[1]); - iInfoScreenDevice->SetScreenMode(screenModeList[1]); - iSession.Finish(); - Pause(50); - - if (resolutions>1) - { - //Got a mode to change to! - TSize resBefore; - TBool ok=dispConfigBefore.GetResolution(resBefore); - ASSERT_TRUE(ok); //we "know" this should be ok, as we just asserted the flag - for (TInt res=0;resSetConfiguration(dispConfigReq); - //ASSERT_EQUALS(errCode,KErrNone); - if (errCode != KErrNone) - { - //Probably current size mode does not support the rotation of the passed in configuration - - ASSERT_EQUALS(errCode,KErrArgument); //failed to find compatible res in the policy - continue; - } - - - TSize pr = iInfoScreenDevice->SizeInPixels(); - TPoint origin=iInfoScreenDevice->GetDefaultScreenModeOrigin(); - Pause(300); - TSize winpos; - - TSize surfaceSize = pr; - surfaceSize.iWidth /= 2; - surfaceSize.iWidth -= 20; - surfaceSize.iHeight -= 20; - TSurfaceId surfaceID; - TRAPD(err, surfaceID = iUtility->CreateSurfaceL(surfaceSize, - KSurfaceFormat, surfaceSize.iWidth * KBytesPerPixel)); - ASSERT_EQUALS(err,KErrNone); - TRAP(err,iUtility->PatternFillSurfaceL(surfaceID)); - ASSERT_EQUALS(err,KErrNone); - - CFbsBitmap* equivalentBitmap=NULL; - TRAP(err,equivalentBitmap=iUtility->EquivalentBitmapL(surfaceID)); - CleanupStack::PushL(equivalentBitmap); - ASSERT_EQUALS(err,KErrNone); - - screenSize = iInfoScreenDevice->SizeInPixels(); - screenSize.Shrink(5,5); - - if (iInfoGc) - { - testWindow.SetExtent(screenSize.iTl,screenSize.Size()); - - if (testWindow.WsHandle()) - { - - iSession.Flush(); - iSession.Finish(); - } - testWindow.SetVisible(ETrue); - } - Pause(200); - iSession.Finish(ETrue); - - RWindow surfWindow; - if (iInfoGc) - { - surfWindow=RWindow(iSession); - ASSERT_EQUALS(surfWindow.Construct(*iInfoGroup, ++iWindowHandle), KErrNone); - surfWindow.SetBackgroundSurface(surfaceID); - surfWindow.SetExtent(screenSize.iTl+TPoint( screenSize.Width()/2 +5,5),surfaceSize); - surfWindow.Activate(); - - if (surfWindow.WsHandle()) - { - surfWindow.Invalidate(); - - surfWindow.BeginRedraw(); - ActivateWithWipe(iInfoGc,surfWindow,iRed); - surfWindow.EndRedraw(); - - iSession.Flush(); - iSession.Finish(); - } - surfWindow.SetVisible(ETrue); - iInfoGc->Deactivate(); - } - - iSession.Finish(ETrue); - - TRect bitmapDrawRect; - bitmapDrawRect = surfaceSize; - - RWindow bmpWindow; - if (iInfoGc) - { - bmpWindow=RWindow(iSession); - ASSERT_EQUALS(bmpWindow.Construct(*iInfoGroup, ++iWindowHandle), KErrNone); - bmpWindow.SetBackgroundColor(iRed); - bmpWindow.SetExtent(screenSize.iTl+TPoint(5,5),surfaceSize); - bmpWindow.Activate(); - - if (bmpWindow.WsHandle()) - { - bmpWindow.Invalidate(); - - bmpWindow.BeginRedraw(); - ActivateWithWipe(iInfoGc,bmpWindow,iRed); - // Not drawing, draw twice?? - iInfoGc->DrawBitmap(bitmapDrawRect, equivalentBitmap); - bmpWindow.EndRedraw(); - - iSession.Flush(); - iSession.Finish(); - } - bmpWindow.SetVisible(ETrue); - iInfoGc->Deactivate(); - } - Pause(200); - iSession.Finish(ETrue); - - - if (iInfoGc) - { - - if (bmpWindow.WsHandle()) - { - bmpWindow.Invalidate(); - - bmpWindow.BeginRedraw(); - ActivateWithWipe(iInfoGc,bmpWindow,iRed); - // Not drawing, draw twice?? - iInfoGc->DrawBitmap(bitmapDrawRect, equivalentBitmap); - bmpWindow.EndRedraw(); - - iSession.Flush(); - iSession.Finish(); - } - bmpWindow.SetVisible(ETrue); - iInfoGc->Deactivate(); - } - Pause(200); - iSession.Finish(ETrue); - - - - - RArray regionArray; - - RRegion equivRegion; - TBitmapRegionPair bitmap1Region; - bitmap1Region.bitmap = equivalentBitmap; - bitmap1Region.drawRect = TRect(TPoint(0,0),surfaceSize); - equivRegion.AddRect(TRect(TPoint(0,0),surfaceSize)); - bitmap1Region.region = &equivRegion; - - regionArray.Append(bitmap1Region); - - - TDisplayConfiguration dispConfigAfter2; - interface->GetConfiguration(dispConfigAfter2); - TSize theSize; - dispConfigAfter2.GetResolution(theSize); - TDisplayConfiguration1::TRotation orient; - dispConfigAfter2.GetRotation(orient); - if (orient & 0x1) - { - TInt temp = theSize.iHeight; - theSize.iHeight = theSize.iWidth; - theSize.iWidth = temp; - } - TRect uiSize(TPoint(0,0), theSize); - MDisplayMapping* mappingInterface = static_cast - (iScreenDevice->GetInterface(MDisplayMapping::ETypeId)); - ASSERT_TRUE(mappingInterface); - TRect finalSize; - mappingInterface->MapCoordinates(EApplicationSpace, uiSize, ECompositionSpace, finalSize); - - - - - CFbsBitmap* bmp2 = new (ELeave) CFbsBitmap; - CleanupStack::PushL(bmp2); - TInt bmpErr = bmp2->Create(finalSize.Size(), EColor16MU); - ASSERT_EQUALS(bmpErr, KErrNone); - - MTestScreenCapture - * csc = - static_cast (iScreenDevice->GetInterface(MTestScreenCapture::KUidTestScreenCaptureIf)); - if (csc) - { - TInt errr = csc->ComposeScreen(*bmp2); - } - else - { - if (!cSCLogged) - { - cSCLogged = ETrue; - _LIT(KNoCSC, "CSC testing not enabled as CSC render stage not defined"); - Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrAll, KNoCSC); - } - } - TRect compareRect(bmpWindow.AbsPosition(), bmpWindow.Size()); - TRect testRect(surfWindow.AbsPosition(), surfWindow.Size()); - - if (csc) - { - if(!Compare(*bmp2, compareRect, testRect, regionArray, aIsSurface)) - { - _LIT(KCompareFailed, "Compare Failed on resolution: %d"); - TBuf<256> x; - x.Format(KCompareFailed, res+1); - Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x); - } - } - CleanupStack::PopAndDestroy(bmp2); - - equivRegion.Close(); - regionArray.Close(); - - CleanupStack::PopAndDestroy(equivalentBitmap); - surfWindow.Close(); - bmpWindow.Close(); - } - } - //restore initial res - iInfoScreenDevice->SetAppScreenMode(0); - iInfoScreenDevice->SetScreenMode(0); - } - else - { - INFO_PRINTF1(_L("Only 1 screen size mode configured on this screen - res change test skipped.")); - } - testWindow.Close(); - screenModeList.Close(); - resolutionList1.Close(); - } - - -/** - Tests to see if the pixels in the bitmap match what should be drawn with regards to the bitmaps and regions in aBitmapRegionPairArray - It does this by in the case of non-scaled bitmaps, performing a pixel by pixel comparison between what has been drawn to the CSC created bitmap and either the pixels of the bitmap if they are contained within the related region or the pixels of the simulation screen. In the case of scalingm only certain pixels are compared from the CSC bitmap to the comparison drawing as the scaling algorithm is hard to replicate. - - - @param aBitmap a bitmap of the entire screen which should be generated using the Composited Screen Capture code - @param aRect1 A rectangle representing the middle window in the comparison triple - @param aRect2 A rectangle represneting the right window in the comparison triple - @param aBitmapRegionPairArray An array of the different regions that are being drawn on the screen. They should be placed in order such that the closest to the foreground is first and the furthest away is last in the queue. Each member of the array is a misleadingly titled TBitmapRegion pair, the bitmap member of this should be the bitmap that is being drawn to the region of the screen, if the region is just a blank color then a blank color bitmap should be drawn. The region should be the region that the bitmap is being drawn to and should be the same as the clipping region which is set jsut before the bitmap is drawn to screen. Finally the draw rect is the basic rectangle the bitmap is being drawn to and is mainly used to test if the bitmap is being scaled - @return True - */ -TBool CWsDynamicResBasic::Compare(const CFbsBitmap& aBitmap, - const TRect& aRect1, const TRect& aRect2, - RArray& aBitmapRegionPairArray, TBool aIsSurface) - { - MDisplayMapping* mappingInterface = static_cast - (iScreenDevice->GetInterface(MDisplayMapping::ETypeId)); - ASSERT_TRUE(mappingInterface); - - - TRgb color1; - TRgb color2; - - TInt errorPixels =0; - TInt diffPixels = 0; - RRegion ignoreDueToResizing; - TInt regionCount = aBitmapRegionPairArray.Count(); - for (TInt i=regionCount-1; i>=0; i--) - { - if (aBitmapRegionPairArray[i].bitmap->SizeInPixels() - != aBitmapRegionPairArray[i].drawRect.Size()) - { - RArray corners; - corners.Append(aBitmapRegionPairArray[i].drawRect.iTl); - corners.Append(TPoint(aBitmapRegionPairArray[i].drawRect.iBr.iX-1, - aBitmapRegionPairArray[i].drawRect.iTl.iY)); - corners.Append(TPoint(aBitmapRegionPairArray[i].drawRect.iTl.iX, - aBitmapRegionPairArray[i].drawRect.iBr.iY-1)); - corners.Append(aBitmapRegionPairArray[i].drawRect.iBr- TPoint(1,1)); - for (TInt j=0; jContains(corners[j])) - { - inOther = ETrue; - } - } - if (inOther) - { - continue; - } - aBitmap.GetPixel(color1, aRect2.iTl + corners[j]); - aBitmap.GetPixel(color2, aRect1.iTl + corners[j]); - TRgb color3 = GreatestColor(color1); - TRgb color4 = GreatestColor(color2); - if (color3 != color4) - { - // Bitmap copy can be off by a pixel on grid filled surface so allow for green and yellow to be treated equally as they are the background colours, this may allow a misfunctioning gce to pass the test though. - if (color4 == TRgb(0, 1, 0) && color3 == TRgb(1, 1, 0)) - { - } - else - if (color4 == TRgb(1, 1, 0) && color3 == TRgb(0, 1, 0)) - { - } - else - { - corners.Close(); - return EFalse; - } - } - - } - // testPoints contains first the pixel within the destRect followed by the pixel in the original position for comparison to - RArray testPoints; - testPoints.Append(aBitmapRegionPairArray[i].drawRect.Center()); - testPoints.Append(TPoint( - aBitmapRegionPairArray[i].bitmap->SizeInPixels().iWidth/2, - aBitmapRegionPairArray[i].bitmap->SizeInPixels().iHeight/2)); - testPoints.Append(TPoint(aBitmapRegionPairArray[i].drawRect.iTl.iX, - aBitmapRegionPairArray[i].drawRect.Center().iY)); - testPoints.Append(TPoint(0, - aBitmapRegionPairArray[i].bitmap->SizeInPixels().iHeight/2)); - testPoints.Append(TPoint(aBitmapRegionPairArray[i].drawRect.iBr.iX - -1, aBitmapRegionPairArray[i].drawRect.Center().iY)); - testPoints.Append(TPoint( - aBitmapRegionPairArray[i].bitmap->SizeInPixels().iWidth-1, - aBitmapRegionPairArray[i].bitmap->SizeInPixels().iHeight/2)); - TSize sizeee = aBitmapRegionPairArray[i].drawRect.Size(); - if (aBitmapRegionPairArray[i].drawRect.Size().iWidth > 11 && aBitmapRegionPairArray[i].drawRect.Size().iHeight > 20) - { - testPoints.Append(TPoint( - aBitmapRegionPairArray[i].drawRect.Center().iX, aBitmapRegionPairArray[i].drawRect.iTl.iY)); - testPoints.Append(TPoint( - aBitmapRegionPairArray[i].bitmap->SizeInPixels().iWidth/2, 0)); - - testPoints.Append(TPoint( - aBitmapRegionPairArray[i].drawRect.Center().iX, aBitmapRegionPairArray[i].drawRect.iBr.iY-1)); - testPoints.Append(TPoint( - aBitmapRegionPairArray[i].bitmap->SizeInPixels().iWidth/2, - aBitmapRegionPairArray[i].bitmap->SizeInPixels().iHeight-1)); - - if (aBitmapRegionPairArray[i].drawRect.Size().iWidth > 34 - && aBitmapRegionPairArray[i].drawRect.Size().iHeight > 43) - { - testPoints.Append(aBitmapRegionPairArray[i].drawRect.iTl - + TPoint(5, 5)); - testPoints.Append(TPoint(5, 5)); - testPoints.Append(TPoint( - aBitmapRegionPairArray[i].drawRect.iBr.iX - 6, - aBitmapRegionPairArray[i].drawRect.iTl.iY + 5)); - testPoints.Append(TPoint( - aBitmapRegionPairArray[i].bitmap->SizeInPixels().iWidth-6, 5)); - testPoints.Append(TPoint( - aBitmapRegionPairArray[i].drawRect.iTl.iX + 5, - aBitmapRegionPairArray[i].drawRect.iBr.iY -6)); - testPoints.Append(TPoint(5, - aBitmapRegionPairArray[i].bitmap->SizeInPixels().iHeight - 6)); - testPoints.Append(aBitmapRegionPairArray[i].drawRect.iBr - - TPoint(6, 6)); - testPoints.Append(TPoint( - aBitmapRegionPairArray[i].bitmap->SizeInPixels().iWidth-6, - aBitmapRegionPairArray[i].bitmap->SizeInPixels().iHeight-6)); - } - else - { - testPoints.Append(aBitmapRegionPairArray[i].drawRect.iTl - + TPoint(2, 3)); - testPoints.Append(TPoint(5, 5)); - testPoints.Append(TPoint( - aBitmapRegionPairArray[i].drawRect.iBr.iX - 3, - aBitmapRegionPairArray[i].drawRect.iTl.iY + 3)); - testPoints.Append(TPoint( - aBitmapRegionPairArray[i].bitmap->SizeInPixels().iWidth-6, 5)); - testPoints.Append(TPoint( - aBitmapRegionPairArray[i].drawRect.iTl.iX + 2, - aBitmapRegionPairArray[i].drawRect.iBr.iY -4)); - testPoints.Append(TPoint(5, - aBitmapRegionPairArray[i].bitmap->SizeInPixels().iHeight - 6)); - testPoints.Append(aBitmapRegionPairArray[i].drawRect.iBr - - TPoint(3, 4)); - testPoints.Append(TPoint( - aBitmapRegionPairArray[i].bitmap->SizeInPixels().iWidth-6, - aBitmapRegionPairArray[i].bitmap->SizeInPixels().iHeight-6)); - } - } - for (int jj=0; jjContains(testPoints[jj])) - { - continue; - } - for (TInt k=0; kContains(testPoints[jj])) - { - inOther = ETrue; - } - } - if (inOther) - { - continue; - } - TPoint currentPoint = testPoints[jj]; - TRect bound = aBitmapRegionPairArray[i].region->BoundingRect(); - TBool - contat = - aBitmapRegionPairArray[i].region->Contains(testPoints[jj]); - aBitmap.GetPixel(color1, aRect2.iTl + testPoints[jj]); - aBitmapRegionPairArray[i].bitmap->GetPixel(color2, - testPoints[jj+1]); - TRgb color5 = GreatestColor(color1); - TRgb color6 = GreatestColor(color2); - if (color5 != color6) - { - // Bitmap copy can be off by a pixel on grid filled surface so allow for green and yellow to be treated equally as they are the background colours, this may allow a misfunctioning gce to pass the test though. - if (color6 == TRgb(0, 1, 0) && color5 == TRgb(1, 1, 0)) - { - } - else - if (color6 == TRgb(1, 1, 0) && color5 == TRgb(0, 1, 0)) - { - } - else - { - testPoints.Close(); - return EFalse; - } - } - } - - testPoints.Close(); - corners.Close(); - ignoreDueToResizing.Union(*aBitmapRegionPairArray[i].region); - aBitmapRegionPairArray.Remove(i); - } - } - - RRegion superRegion; - - regionCount = aBitmapRegionPairArray.Count(); - - for (TInt i=0; i0) - { - for (TInt i=0; iContains(currentPoint)) - { - if (aIsSurface) - { - TPoint checkPoint = currentPoint + aRect2.iTl; - TRect readBackRect; - mappingInterface->MapCoordinates(EApplicationSpace, TRect(checkPoint, TSize(1,1)), ECompositionSpace, readBackRect); - aBitmap.GetPixel(color1, readBackRect.iTl); - } - else - { - TPoint checkPoint = currentPoint + aRect1.iTl; - TRect readBackRect; - mappingInterface->MapCoordinates(EApplicationSpace, TRect(checkPoint, TSize(1,1)), ECompositionSpace, readBackRect); - aBitmap.GetPixel(color1, readBackRect.iTl); - } - - aBitmapRegionPairArray[arrayIndex].bitmap->GetPixel(color2, currentPoint - - aBitmapRegionPairArray[arrayIndex].drawRect.iTl); - - TRgb color7 = GreatestColor(color1); - TRgb color8 = GreatestColor(color2); - - if (color7 != color8) - { - diffPixels++; - //return EFalse; - } - pointInArray = ETrue; - } - arrayIndex++; - } - while (!pointInArray && !(arrayIndex - >= aBitmapRegionPairArray.Count())); - - if (!pointInArray) - { - aBitmap.GetPixel(color1, TPoint(i + aRect2.iTl.iX - + xStart, j +aRect2.iTl.iY +yStart)); - aBitmap.GetPixel(color2, TPoint(i + aRect1.iTl.iX - +xStart, j +aRect1.iTl.iY+yStart)); - // Bitmap copy is duller on first few iterations so just pick the greatest color or two colors and see if they match - TRgb color3 = GreatestColor(color1); - TRgb color4 = GreatestColor(color2); - - if (color3 != color4) - { - // Bitmap copy can be off by a pixel on grid filled surface so allow for green and yellow to be treated equally as they are the background colours, this may allow a misfunctioning gce to pass the test though. - if (GreatestColor(color2) == TRgb(0, 1, 0) - && GreatestColor(color1) == TRgb(1, 1, 0)) - { - continue; - } - else - if (GreatestColor(color2) == TRgb(1, 1, 0) - && GreatestColor(color1) == TRgb(0, 1, - 0)) - { - continue; - } - else - { - errorPixels++; - //return EFalse; - } - } - } - } - } - } - } - ignoreDueToResizing.Close(); - if (errorPixels+diffPixels < 2) - { - return ETrue; - } - else - { - return EFalse; - } - - } - - -/* - Creates a rough apprxoiamtion to the color pass in. This is used because of issues with the bitmap drwaing in the comparison window. If these issues are fixed then this method can be changed to simply return aColor. - - @param aColor the color to be approximated - @return an approximation of aColor. - */ -TRgb CWsDynamicResBasic::GreatestColor(TRgb& aColor) const - { - TInt test = aColor.Difference(TRgb(0, 0, 0)); - // Accounts for a case when Rgb = 20,20,20 due to poor bitmap drawing - if (aColor == TRgb(32, 32, 32)) - { - return TRgb(0, 0, 0); - } - if (aColor == TRgb(0, 0, 0)) - { - return TRgb(0, 0, 0); - } - TRgb test2; - test2.SetInternal(0xFFFEDF01); - if (aColor == test2) - { - return TRgb(1, 1, 0); - } - - if (test < 70) - { - return TRgb(0, 0, 0); - } - if (aColor.Green() > aColor.Blue()) - { - if (aColor.Green() > aColor.Red()) - { - return TRgb(0, 1, 0); - } - else - if (aColor.Green() == aColor.Red()) - { - return TRgb(1, 1, 0); - } - } - if (aColor.Green() > aColor.Red()) - { - if (aColor.Green() > aColor.Blue()) - { - return TRgb(0, 1, 0); - } - else - if (aColor.Green() == aColor.Blue()) - { - return TRgb(0, 1, 1); - } - } - - if (aColor.Red() > aColor.Green()) - { - if (aColor.Red() > aColor.Blue()) - { - return TRgb(1, 0, 0); - } - else - if (aColor.Red() == aColor.Blue()) - { - return TRgb(1, 0, 1); - } - } - if (aColor.Red() > aColor.Blue()) - { - if (aColor.Red() > aColor.Green()) - { - return TRgb(1, 0, 0); - } - else - if (aColor.Red() == aColor.Green()) - { - return TRgb(1, 1, 0); - } - } - - if (aColor.Blue() > aColor.Red()) - { - if (aColor.Blue() > aColor.Green()) - { - return TRgb(0, 0, 1); - } - else - if (aColor.Blue() == aColor.Green()) - { - return TRgb(0, 1, 1); - } - } - if (aColor.Blue() > aColor.Green()) - { - if (aColor.Blue() > aColor.Red()) - { - return TRgb(0, 0, 1); - } - else - if (aColor.Blue() == aColor.Red()) - { - return TRgb(1, 0, 1); - } - } - - // Should never reach here, but the compiler cannot be sure - return TRgb(0, 0, 0); - } - -/* -@SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0051L -@SYMTestCaseDesc Getting if a mode is dynamic -@SYMREQ REQ11554 -@SYMPREQ PREQ2102 -@SYMTestType CT -@SYMTestPriority 1 -@SYMTestPurpose Check functions work correctly -@SYMTestActions - Do IsModeDynamic for a wrong mode number - Do IsModeDynamic for a mode that isnt dynamic - Do IsModeDynamic for a mode that is dynamic - Do IsCurrentModeDynamic when current mode is not dynamic - Do IsCurrentModeDynamic when current mode is dynamic - MODE 10 must be dynamic -@SYMTestExpectedResults - All should return as expected. -*/ -void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0051L() - { - RArray screenModeList; - iInfoScreenDevice->GetScreenSizeModeList(&screenModeList); - iInfoScreenDevice->SetAppScreenMode(0); - iInfoScreenDevice->SetScreenMode(0); - iSession.Flush(); - Pause(50); - ASSERT_FALSE(iInfoScreenDevice->IsModeDynamic(25)); - ASSERT_FALSE(iInfoScreenDevice->IsModeDynamic(1)); - ASSERT_TRUE(iInfoScreenDevice->IsModeDynamic(10)); - ASSERT_FALSE(iInfoScreenDevice->IsCurrentModeDynamic()); - iInfoScreenDevice->SetAppScreenMode(10); - iInfoScreenDevice->SetScreenMode(10); - iSession.Flush(); - Pause(50); - ASSERT_TRUE(iInfoScreenDevice->IsCurrentModeDynamic()); - screenModeList.Close(); - iInfoScreenDevice->SetAppScreenMode(0); - iInfoScreenDevice->SetScreenMode(0); - } - -/* Takes any 0x0 resolutions out of the res list, useful for some tests -*/ -void ResListCleanup(RArray& aResList) - { - for (TInt ii=0; ii - (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); - ASSERT_TRUE(interface); - - TInt resolutions = interface->NumberOfResolutions(); - ASSERT_TRUE (resolutions > 1); - - RArray resolutionList1; - TInt error = interface->GetResolutions(resolutionList1); - ASSERT_EQUALS(resolutionList1.Count(), resolutions); - ResListCleanup(resolutionList1); //remove any 0x0 - ASSERT_TRUE (resolutionList1.Count() > 1); //without multiple proper res this test is pointless - - TDisplayConfiguration newResolution; - newResolution.SetResolution(resolutionList1[0].iPixelSize); - error = interface->SetConfiguration(newResolution); - ASSERT_EQUALS(error,KErrNone); - - TSizeMode info; - RArray screenModes; - error = iInfoScreenDevice->GetScreenSizeModeList(&screenModes); - ASSERT_TRUE(error>KErrNone); - TInt dynamicMode1 = -1; - TInt dynamicMode2 = -1; - TPixelsTwipsAndRotation modeAttributes; - - //for every app mode, check calculations update correctly - for (TInt ii=0;iiIsModeDynamic(screenMode)) - { - CArrayFixFlat* rotations=new(ELeave) CArrayFixFlat(1); - CleanupStack::PushL(rotations); - TInt error = iInfoScreenDevice->GetRotationsList(screenMode,rotations); - ASSERT_EQUALS(error,KErrNone); - ASSERT_TRUE(rotations->Count()>0); - for (TInt jj = 0; jj < rotations->Count(); jj++) - { - if ((*rotations)[jj] == (TInt)CFbsBitGc::EGraphicsOrientationNormal || - (*rotations)[jj] == (TInt)CFbsBitGc::EGraphicsOrientationRotated180) - { - dynamicMode1 = screenMode; - } - else if ((*rotations)[jj] == (TInt)CFbsBitGc::EGraphicsOrientationRotated90 || - (*rotations)[jj] == (TInt)CFbsBitGc::EGraphicsOrientationRotated270) - { - dynamicMode2 = screenMode; - } - } - CleanupStack::PopAndDestroy(rotations); - continue; //dont want to test dynamic modes - } - - INFO_PRINTF2(_L("ScreenMode %d"),screenMode); - newResolution.ClearAll(); - - iInfoScreenDevice->SetAppScreenMode(screenMode); - iInfoScreenDevice->SetScreenMode(screenMode); - iSession.Flush(); - Pause(50); - - info = iInfoScreenDevice->GetCurrentScreenModeAttributes(); - //These 2 asserts relate to DEF136304 - disconnect on startup causes invalid - //twips values. They need to be calculated when the screen is connected - ASSERT_TRUE(info.iScreenTwipsSize.iWidth < 40000); - ASSERT_TRUE(info.iScreenTwipsSize.iHeight < 40000); - - //test that conversions correlate to values reported by config - TInt test = iInfoScreenDevice->HorizontalTwipsToPixels( - info.iScreenTwipsSize.iWidth); - ASSERT_EQUALS (test,info.iScreenSize.iWidth); - - test = iInfoScreenDevice->VerticalTwipsToPixels( - info.iScreenTwipsSize.iHeight); - ASSERT_EQUALS (test,info.iScreenSize.iHeight); - - test = iInfoScreenDevice->HorizontalPixelsToTwips( - info.iScreenSize.iWidth); - ASSERT_EQUALS (test,info.iScreenTwipsSize.iWidth); - - test = iInfoScreenDevice->VerticalPixelsToTwips( - info.iScreenSize.iHeight); - ASSERT_EQUALS (test,info.iScreenTwipsSize.iHeight); - } - - if (dynamicMode1 == -1 && dynamicMode2 == -1) //expected to find at least 1 dynamic mode - { - ASSERT_TRUE(0); - } - - for (TInt jj=0;jj<2;jj++) //for dynamic mode 1 and 2 - { - TInt dynMode = (jj == 0) ? dynamicMode1 : dynamicMode2; - if (dynMode == -1) - continue; - //set dynamic app mode - iInfoScreenDevice->SetAppScreenMode(dynMode); - iInfoScreenDevice->SetScreenMode(dynMode); - iSession.Flush(); - Pause(50); - ASSERT_TRUE(iInfoScreenDevice->IsModeDynamic(dynMode)); - ASSERT_TRUE(iInfoScreenDevice->IsCurrentModeDynamic()); - ASSERT_EQUALS(dynMode,iInfoScreenDevice->CurrentScreenMode()); - for (TInt ii=0;iiSetConfiguration(newResolution); - - if (jj == 0) - { - if (tempSetRot == TDisplayConfiguration1::ERotation90CW || - tempSetRot == TDisplayConfiguration1::ERotation270CW) //mode rotation will not work with config rotation - { - ASSERT_EQUALS(error,KErrArgument); - continue; - } - } - else //jj == 1 - { - if (tempSetRot == TDisplayConfiguration1::ERotationNormal || - tempSetRot == TDisplayConfiguration1::ERotation180) //mode rotation will not work with config rotation - { - ASSERT_EQUALS(error,KErrArgument); - continue; - } - } - ASSERT_EQUALS(error,KErrNone); - interface->GetConfiguration(newResolution); - iSession.Flush(); - Pause(50); - - //test that conversions correlate to values reported by config - TInt test = iInfoScreenDevice->HorizontalTwipsToPixels( - resolutionList1[ii].iTwipsSize.iWidth); - ASSERT_EQUALS (test,resolutionList1[ii].iPixelSize.iWidth); - - test = iInfoScreenDevice->VerticalTwipsToPixels( - resolutionList1[ii].iTwipsSize.iHeight); - ASSERT_EQUALS (test,resolutionList1[ii].iPixelSize.iHeight); - - test = iInfoScreenDevice->HorizontalPixelsToTwips( - resolutionList1[ii].iPixelSize.iWidth); - ASSERT_EQUALS (test,resolutionList1[ii].iTwipsSize.iWidth); - - test = iInfoScreenDevice->VerticalPixelsToTwips( - resolutionList1[ii].iPixelSize.iHeight); - ASSERT_EQUALS (test,resolutionList1[ii].iTwipsSize.iHeight); - } - } - - resolutionList1.Close(); - screenModes.Close(); - } - -/* -@SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0053L -@SYMTestCaseDesc SetScreenSizeAndRotation -@SYMREQ REQ11554 -@SYMPREQ PREQ2102 -@SYMTestType CT -@SYMTestPriority 1 -@SYMTestPurpose Check functions work correctly -@SYMTestActions - Perform calls to SetScreenSizeAndRotation with the various structure types - MODE 10 must be dynamic -@SYMTestExpectedResults - Cannt fail, used for debugging and coverage. -*/ -void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0053L() - { - MDisplayControl* interface = static_cast - (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); - ASSERT_TRUE(interface); - - TInt resolutions = interface->NumberOfResolutions(); - ASSERT_TRUE (resolutions > 1); - - RArray resolutionList1; - TInt error = interface->GetResolutions(resolutionList1); - ASSERT_EQUALS(resolutionList1.Count(), resolutions); - - //set default app mode and default resolution - iInfoScreenDevice->SetAppScreenMode(0); - iInfoScreenDevice->SetScreenMode(0); - iSession.Flush(); - Pause(50); - TDisplayConfiguration original; - original.SetResolution(resolutionList1[0].iPixelSize); - interface->SetConfiguration(original); - iSession.Flush(); - Pause(50); - - TPixelsAndRotation setup0; - setup0.iPixelSize = TSize(30,40); - setup0.iRotation = CFbsBitGc::EGraphicsOrientationNormal; - - TPixelsTwipsAndRotation setup1; - setup1.iPixelSize = TSize(50,60); - setup1.iTwipsSize = TSize(70,80); - setup1.iRotation = CFbsBitGc::EGraphicsOrientationNormal; - - iInfoScreenDevice->SetScreenSizeAndRotation(setup0); - iInfoScreenDevice->SetScreenSizeAndRotation(setup1); - - //set dynamic app mode - iInfoScreenDevice->SetAppScreenMode(10); - iInfoScreenDevice->SetScreenMode(10); - iSession.Flush(); - Pause(50); - - iInfoScreenDevice->SetScreenSizeAndRotation(setup0); - iInfoScreenDevice->SetScreenSizeAndRotation(setup1); - - const CWsScreenDevice* newDevice = iScreenDevice; - const MDisplayControl* interface2 = (MDisplayControl*) - newDevice->GetInterface(MDisplayControl::ETypeId); - TInt version = interface2->PreferredDisplayVersion(); //for coverage! - (void)version; - - //set default app mode and default resolution - iInfoScreenDevice->SetAppScreenMode(1); - iInfoScreenDevice->SetScreenMode(1); - iSession.Flush(); - Pause(50); - interface->SetConfiguration(original); - iSession.Flush(); - Pause(50); - - resolutionList1.Close(); - } - -/** -@SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0101L -@SYMTestCaseDesc Quick demonstration of app modes sizes and positions on screen -@SYMREQ -@SYMPREQ PREQ2102 -@SYMTestType CT (manual visual test) -@SYMTestPurpose To show app modes -@SYMTestActions - For every app mode - Draw a blue box showing the full size and position of the app mode. - Draw thin red lines demonstrating a window can be drawn outside of the app area to fill - the screen. - Green borders at the edge of the appmode, to show we are drawing up to the edges of the - appmode. -@SYMTestExpectedResults - Blue window should represent appmode (with offset and size) - Red windows should be visible across screen - Green border (made of windows) around the appmode (blue window) -*/ -void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0101L() - { - RArray screenModeList; - iInfoScreenDevice->GetScreenSizeModeList(&screenModeList); - - if (screenModeList.Count()>1) - { - //Got modes to change between! - TSize resBefore; - for (TInt res=0;resSetAppScreenMode(screenModeList[res]); - iInfoScreenDevice->SetScreenMode(screenModeList[res]); - iSession.Flush(); - Pause(50); - - TSize appSize = iInfoScreenDevice->SizeInPixels(); - RWindow backWindow(iSession); - ASSERT_EQUALS(backWindow.Construct(iGroup, 123455), KErrNone); - backWindow.SetRequiredDisplayMode(iDisplayMode); - backWindow.SetBackgroundColor(iCyan); - backWindow.SetExtent(TPoint(40,40),appSize-TSize(40,40)); //shows size of the apparea - backWindow.Activate(); - - TSurfaceId surfaceID; - TRAPD(err, surfaceID = iUtility->CreateSurfaceL(TSize(200,200), - KSurfaceFormat, 200 * KBytesPerPixel)); - ASSERT_EQUALS(err,KErrNone); - TRAP(err,iUtility->FanFillSurfaceL(surfaceID,iYellow,iRed,iMagenta)); - ASSERT_EQUALS(err,KErrNone); - TSurfaceConfiguration surfConf; - surfConf.SetSurfaceId(surfaceID); - - backWindow.SetBackgroundSurface(surfaceID); - - DrawPlainUI(backWindow,ETrue,iBlue); - iSession.Flush(); - Pause(200); - - RWindow longWindow1(iSession); - ASSERT_EQUALS(longWindow1.Construct(iGroup, 123456), KErrNone); - longWindow1.SetRequiredDisplayMode(iDisplayMode); - longWindow1.SetBackgroundColor(iRed); - longWindow1.SetExtent(TPoint(-2000,10),TSize(5000,5)); //shows you can draw outside the apparea - longWindow1.Activate(); - DrawPlainUI(longWindow1,ETrue,iRed); - - iBackground.SetColor(TRgb(0x001000*res|0x800000)); - iSession.SetBackgroundColor(TRgb(0x001000*res+0x40)); - iSession.Flush(); - Pause(100); - - RWindow longWindow2(iSession); - ASSERT_EQUALS(longWindow2.Construct(iGroup, 123457), KErrNone); - longWindow2.SetRequiredDisplayMode(iDisplayMode); - longWindow2.SetBackgroundColor(iRed); - longWindow2.SetExtent(TPoint(20,-2000),TSize(5,5000)); //shows you can draw outside the apparea - longWindow2.Activate(); - DrawPlainUI(longWindow2,ETrue,iRed); - - //borders - RWindow borderTop(iSession); - ASSERT_EQUALS(borderTop.Construct(iGroup, 123460), KErrNone); - borderTop.SetRequiredDisplayMode(iDisplayMode); - borderTop.SetBackgroundColor(iGreen); - borderTop.SetExtent(TPoint(0,0),TSize(appSize.iWidth,5)); //border - borderTop.Activate(); - DrawPlainUI(borderTop,ETrue,iGreen); - - RWindow borderLeft(iSession); - ASSERT_EQUALS(borderLeft.Construct(iGroup, 123461), KErrNone); - borderLeft.SetRequiredDisplayMode(iDisplayMode); - borderLeft.SetBackgroundColor(iGreen); - borderLeft.SetExtent(TPoint(0,0),TSize(5,appSize.iHeight)); //border - borderLeft.Activate(); - DrawPlainUI(borderLeft,ETrue,iGreen); - - RWindow borderRight(iSession); - ASSERT_EQUALS(borderRight.Construct(iGroup, 123462), KErrNone); - borderRight.SetRequiredDisplayMode(iDisplayMode); - borderRight.SetBackgroundColor(iGreen); - borderRight.SetExtent(TPoint(appSize.iWidth-5,0),TSize(5,appSize.iHeight)); //border - borderRight.Activate(); - DrawPlainUI(borderRight,ETrue,iGreen); - - RWindow borderBottom(iSession); - ASSERT_EQUALS(borderBottom.Construct(iGroup, 123463), KErrNone); - borderBottom.SetRequiredDisplayMode(iDisplayMode); - borderBottom.SetBackgroundColor(iGreen); - borderBottom.SetExtent(TPoint(0,appSize.iHeight-5),TSize(appSize.iWidth,5)); //border - borderBottom.Activate(); - DrawPlainUI(borderBottom,ETrue,iGreen); - - iSession.Flush(); - Pause(100); - - backWindow.Close(); - longWindow1.Close(); - longWindow2.Close(); - borderTop.Close(); - borderLeft.Close(); - borderRight.Close(); - borderBottom.Close(); - - iSession.Finish(); - Pause(50); - } - } - else - { - INFO_PRINTF1(_L("Only 1 screen size mode configured on this screen - test skipped.")); - } - - screenModeList.Close(); - iInfoScreenDevice->SetAppScreenMode(0); - iInfoScreenDevice->SetScreenMode(0); - iSession.Finish(ETrue); - Pause(100); - INFO_PRINTF1(_L("Drawing to borderBottom completed.")); - } - -/** -@SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0102L -@SYMTestCaseDesc Quick demonstration of square app modes in all 4 rotations -@SYMREQ -@SYMPREQ PREQ2102 -@SYMTestType CT (manual visual test) -@SYMTestPurpose To show square app mode in all 4 rotations -@SYMTestActions - Draw a blue box showing the full size and position of the app mode. - Draw thin red lines demonstrating a window can be drawn outside of the app area to fill - the screen. - Green borders at the edge of the appmode, to show we are drawing up to the edges of the - appmode. -@SYMTestExpectedResults - Blue window should represent appmode (with offset and size) - Red windows should be visible across screen - Green border (made of windows) around the appmode (blue window) -*/ -void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0102L() - { - RArray screenModeList; - iInfoScreenDevice->GetScreenSizeModeList(&screenModeList); - - - TSize resBefore; - TInt res; - for (res=0;resSetAppScreenMode(screenModeList[res]); - iInfoScreenDevice->SetScreenMode(screenModeList[res]); - - iSession.Finish(ETrue); - iSession.Flush(); - Pause(50); - - TPixelsAndRotation pr; - iInfoScreenDevice->GetDefaultScreenSizeAndRotation(pr); - if(pr.iPixelSize.iHeight == pr.iPixelSize.iWidth) - { - //found square appmode - break; - } - } - - for(TInt rotation = CFbsBitGc::EGraphicsOrientationNormal; rotation <= CFbsBitGc::EGraphicsOrientationRotated270; rotation++) - { - iScreenDevice->SetCurrentRotations(screenModeList[res], (CFbsBitGc::TGraphicsOrientation)rotation); - iSession.Flush(); - Pause(50); - TDisplayConfiguration dispConfigReq; - TSize appSize = iInfoScreenDevice->SizeInPixels(); - RWindow backWindow(iSession); - ASSERT_EQUALS(backWindow.Construct(iGroup, 123455), KErrNone); - backWindow.SetRequiredDisplayMode(iDisplayMode); - backWindow.SetBackgroundColor(iBlue); - backWindow.SetExtent(TPoint(0,0),appSize); //shows size of the apparea - backWindow.Activate(); - DrawPlainUI(backWindow,ETrue,iBlue); - iSession.Flush(); - Pause(200); - - RWindow longWindow1(iSession); - ASSERT_EQUALS(longWindow1.Construct(iGroup, 123456), KErrNone); - longWindow1.SetRequiredDisplayMode(iDisplayMode); - longWindow1.SetBackgroundColor(iRed); - longWindow1.SetExtent(TPoint(-2000,10),TSize(5000,5)); //shows you can draw outside the apparea - longWindow1.Activate(); - DrawPlainUI(longWindow1,ETrue,iRed); - - iBackground.SetColor(TRgb(0x001000*res|0x800000)); - iSession.SetBackgroundColor(TRgb(0x001000*res+0x40)); - iSession.Flush(); - Pause(100); - - RWindow longWindow2(iSession); - ASSERT_EQUALS(longWindow2.Construct(iGroup, 123457), KErrNone); - longWindow2.SetRequiredDisplayMode(iDisplayMode); - longWindow2.SetBackgroundColor(iRed); - longWindow2.SetExtent(TPoint(20,-2000),TSize(5,5000)); //shows you can draw outside the apparea - longWindow2.Activate(); - DrawPlainUI(longWindow2,ETrue,iRed); - - //borders - RWindow borderTop(iSession); - ASSERT_EQUALS(borderTop.Construct(iGroup, 123460), KErrNone); - borderTop.SetRequiredDisplayMode(iDisplayMode); - borderTop.SetBackgroundColor(iGreen); - borderTop.SetExtent(TPoint(0,0),TSize(appSize.iWidth,5)); //border - borderTop.Activate(); - DrawPlainUI(borderTop,ETrue,iGreen); - - RWindow borderLeft(iSession); - ASSERT_EQUALS(borderLeft.Construct(iGroup, 123461), KErrNone); - borderLeft.SetRequiredDisplayMode(iDisplayMode); - borderLeft.SetBackgroundColor(iGreen); - borderLeft.SetExtent(TPoint(0,0),TSize(5,appSize.iHeight)); //border - borderLeft.Activate(); - DrawPlainUI(borderLeft,ETrue,iGreen); - - RWindow borderRight(iSession); - ASSERT_EQUALS(borderRight.Construct(iGroup, 123462), KErrNone); - borderRight.SetRequiredDisplayMode(iDisplayMode); - borderRight.SetBackgroundColor(iGreen); - borderRight.SetExtent(TPoint(appSize.iWidth-5,0),TSize(5,appSize.iHeight)); //border - borderRight.Activate(); - DrawPlainUI(borderRight,ETrue,iGreen); - - RWindow borderBottom(iSession); - ASSERT_EQUALS(borderBottom.Construct(iGroup, 123463), KErrNone); - borderBottom.SetRequiredDisplayMode(iDisplayMode); - borderBottom.SetBackgroundColor(iGreen); - borderBottom.SetExtent(TPoint(0,appSize.iHeight-5),TSize(appSize.iWidth,5)); //border - borderBottom.Activate(); - DrawPlainUI(borderBottom,ETrue,iGreen); - - iSession.Flush(); - Pause(100); - - backWindow.Close(); - longWindow1.Close(); - longWindow2.Close(); - borderTop.Close(); - borderLeft.Close(); - borderRight.Close(); - borderBottom.Close(); - - iSession.Finish(); - Pause(50); - - } - - - screenModeList.Close(); - iInfoScreenDevice->SetAppScreenMode(0); - iInfoScreenDevice->SetScreenMode(0); - iSession.Finish(ETrue); - Pause(100); - } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tdynamicres/src/wsdynamicresclassic.cpp --- a/windowing/windowserver/tdynamicres/src/wsdynamicresclassic.cpp Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,90 +0,0 @@ -// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// TDISPLAYCONFIGURATION.CPP -// Test class for TDisplayConfiguration -// -// - -#include "wsdynamicresclassic.h" -#include -#include "teflogextensions.h" - -struct TLoggerStub -{ - TLoggerStub(CTestExecuteLogger& aLogger) - : iLogger(&aLogger) {} - CTestExecuteLogger* iLogger; - CTestExecuteLogger& operator()()const - { - return *iLogger; - } -}; - -// This handles any non-member uses of the extended ASSERT_XXX macros -void TefUnitFailLeaveL() - { - - User::Leave(KErrTEFUnitFail); - } - -// Create a suite of all the tests -CTestSuite* CWsDynamicResClassic::CreateSuiteL(const TDesC& aName) - { - SUB_SUITE_OPT(CWsDynamicResClassic,NULL); - - ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0100L); - - END_SUITE; - } - -// Published Tests - -/** -@SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0100L -@SYMTestCaseDesc GetInterface in classic -@SYMREQ -@SYMPREQ PREQ2102 -@SYMTestType CT -@SYMTestPriority -@SYMTestPurpose GetInterface should always return NULL in classic -@SYMTestActions - Create an RWsSession - Create a CWsScreenDevice - Call GetInterface with various GUIDS. -@SYMTestExpectedResults - Should always return NULL -**/ -void CWsDynamicResClassic::GRAPHICS_WSERV_DYNAMICRES_0100L() - { - RWsSession session; - session.Connect(); - - CWsScreenDevice* screenDevice = NULL; - - TRAPD(err, screenDevice = new (ELeave) CWsScreenDevice(session)); - PRINT_ON_ERROR2_L(err, _L("Failed to create screen device: %d"), err); - if (screenDevice) - { - ASSERT_EQUALS_X(screenDevice->Construct(0), KErrNone); - - void* interface = screenDevice->GetInterface(12344321); - ASSERT_NULL (interface); - interface = screenDevice->GetInterface(0); - ASSERT_NULL (interface); - } - - delete screenDevice; - session.Close(); - } - diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tdynamicres/src/wsgcedebugsession.cpp --- a/windowing/windowserver/tdynamicres/src/wsgcedebugsession.cpp Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,177 +0,0 @@ -// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file -*/ - -#include "wsgcedebugsession.h" - -RWsDebugSession::RWsDebugSession(TInt aScreenNo /*= -1*/): - iScreenNo(aScreenNo), - iSurfaceUpdateSerial(-1) - { - iSurfaceListBuffer.CreateMax(48); - } - -RWsDebugSession::~RWsDebugSession() - { - iSurfaceListBuffer.Close(); - - } - -TBool RWsDebugSession::ResetUpdated() - { - TInt surfaceUpdateSerial=DebugInfo(EWsDebugSerialSurfacesUpdated,iScreenNo); - TBool retVal=(iSurfaceUpdateSerial!=surfaceUpdateSerial); - iSurfaceUpdateSerial=surfaceUpdateSerial; - return retVal; - } - -TInt RWsDebugSession::ResetUpdatedAndGetSurfaceWindowList(const TWsDebugWindowId * & aWinList) - { - iSurfaceUpdateSerial=DebugInfo(EWsDebugSerialSurfacesUpdated,iScreenNo); - TInt reqSize=DebugInfo(EWsDebugSurfaceWindowList,iSurfaceListBuffer,iScreenNo); - while (reqSize>iSurfaceListBuffer.MaxLength()) - { - iSurfaceListBuffer.Close(); - iSurfaceListBuffer.CreateMax(reqSize); - iSurfaceUpdateSerial=DebugInfo(EWsDebugSerialSurfacesUpdated,iScreenNo); - reqSize=DebugInfo(EWsDebugSurfaceWindowList,iSurfaceListBuffer,iScreenNo); - } - if (reqSize==KErrCancel) - { - aWinList=NULL; - return 0; - } - else - { - aWinList=(TWsDebugWindowId*)iSurfaceListBuffer.Ptr(); - return reqSize/sizeof(TWsDebugWindowId); - } - } -/** - * Stream data into the provided buffer and point the return object pointer to it. - * The pointer is left null if the method returns an error code or the buffer is too small. - * The ret5urn code reports - * - **/ -TInt RWsDebugSession::DebugInfo(TWsDebugInfoFunc aFunction, TInt aParam, TDes8& aHostBuffer,const void*&aReturnedObject,TInt aObjectSize)const - { - aHostBuffer.SetMax(); - TInt reqSize=DebugInfo(aFunction,aHostBuffer,aParam); - aReturnedObject=NULL; - if (reqSize<0) - { - return reqSize; //Error code is transmitted unmolested - } - if (reqSize==0) //Size 0 is transformed to max - reqSize=aHostBuffer.MaxLength(); - if ((reqSize%aObjectSize)!=0) - { //Size not multiple of object --> error - return KErrCorrupt; - } - if (reqSize<=aHostBuffer.MaxLength()) - { //Pointer is only set if data fits buffer - aReturnedObject=(const void*)aHostBuffer.Ptr(); - } - reqSize/=aObjectSize; //Return the exact number of objects filled - return reqSize; - } -/** - * Stream the reply data via the buffer associated with the region. - * Some protected accessor optimisation used to manage the reported size of the region after streaming. - * - **/ -TInt RWsDebugSession::DebugInfo(TWsDebugInfoFunc aFunction, TInt aParam, TRegion& aPreAllocatedReturnedRegion)const - { - //Attempt to fit the received data in the preexisting region buffer... - class XRegion:public TRegion - { - public: - using TRegion::AppendRect; - // using TRegion::SetListSize; - using TRegion::RectangleListW; - TInt MaxSize() - { return iAllocedRects; } - void SetListSize(TInt aNewSize) //DANGER no error checking!!! - { iCount=aNewSize; } - }& preAllocatedReturnedRegion=(XRegion&)aPreAllocatedReturnedRegion; - typedef TRect TElt; - TInt reqSize=preAllocatedReturnedRegion.MaxSize(); - const TElt* elements=preAllocatedReturnedRegion.RectangleListW(); - TInt lenBytes=reqSize*sizeof(TElt); - TPtr8 pBuff((TUint8*)elements,lenBytes,lenBytes); - reqSize=DebugInfo(aFunction,aParam,pBuff,elements); - - if (elements) - { - if (reqSize==0) - { - reqSize=preAllocatedReturnedRegion.MaxSize(); - } - preAllocatedReturnedRegion.SetListSize(reqSize); - return reqSize; - } - //If data does not fit in preexisting buffer - //Use a temp array instead - //Still try to block copy into the existing capacity - //I think this use of region copy is more efficient than appending, - //and definitely better than unioning the elements. - if (reqSize>=0) - { - TInt breakLoop=10; - do { - TElt* tempbuff=new TElt[reqSize]; - if (tempbuff==NULL) - { - reqSize=KErrNoMemory; - break; - } - elements=tempbuff; - TInt lenBytes=reqSize*sizeof(TElt); - TPtr8 pBuff((TUint8*)elements,lenBytes,lenBytes); - TInt reqSize2=DebugInfo(aFunction,aParam,pBuff,elements); - if (reqSize2!=0) - reqSize=reqSize2; - if (elements) - { - RRegion r(reqSize,tempbuff); //note this region does not own its memory so should not be closed! - aPreAllocatedReturnedRegion.Copy(r); - if (aPreAllocatedReturnedRegion.CheckError()) - reqSize=KErrNoMemory; - } - delete[] tempbuff; - }while (reqSize>0 && elements==NULL && --breakLoop); - } - if (reqSize>=0 && elements==NULL) - { - preAllocatedReturnedRegion.ForceError(); - reqSize=KErrTimedOut; - } - if (reqSize<0) - { - if (reqSize==KErrCancel) - { - preAllocatedReturnedRegion.Clear(); - } - else - { - preAllocatedReturnedRegion.ForceError(); - } - - } - return reqSize; - } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/ANIMWIN.H --- a/windowing/windowserver/test/ANIMWIN.H Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/test/ANIMWIN.H Wed Jun 23 19:41:15 2010 +0300 @@ -21,7 +21,7 @@ #include #include #include "W32STD.H" -#include "../tlib/testbase.h" +#include "../test/tlib/testbase.h" _LIT(VIDEO_MBM_NAME,"Z:\\WSTEST\\MAILANIM.MBM"); diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/CONNECT.CPP --- a/windowing/windowserver/test/CONNECT.CPP Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/test/CONNECT.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -19,7 +19,7 @@ #include "W32STD.H" #include #include "../SERVER/w32cmd.h" -#include "../tlib/testbase.h" +#include "../test/tlib/testbase.h" #include "ANIMWIN.H" #include "HNDLODR.H" diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/FadeCount.cpp --- a/windowing/windowserver/test/FadeCount.cpp Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/test/FadeCount.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -19,7 +19,7 @@ #include #include "W32STD.H" #include -#include "../tlib/testbase.h" +#include "../test/tlib/testbase.h" const TInt ETestFailed = 1; diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/SHELL.CPP --- a/windowing/windowserver/test/SHELL.CPP Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/test/SHELL.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -21,8 +21,8 @@ #include "../SERVER/w32cmd.h" #include #include -#include "../tlib/testbase.h" -#include "../TClick/CLICK.H" +#include "../test/tlib/testbase.h" +#include "../test/TClick/CLICK.H" #define __USING_PROCESS_ diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/TAutoServer/openwfc/TAutoServer_nga.mmp --- a/windowing/windowserver/test/TAutoServer/openwfc/TAutoServer_nga.mmp Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/test/TAutoServer/openwfc/TAutoServer_nga.mmp Wed Jun 23 19:41:15 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -24,22 +24,19 @@ MACRO TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA MACRO SYMBIAN_GRAPHICS_GCE -USERINCLUDE ../../../../../graphicstest/graphicstestharness/inc ../../../inc ../../../tauto ../../../tauto/openwfc -USERINCLUDE ../../../tredir ../../../tlisten ../../../tframerate ../../../tcontaindrawer ../../t_gdcoverage ../../../tbufferdrawer -USERINCLUDE ../../../tlib ../../ +USERINCLUDE ../../../../../graphicstest/graphicstestharness/inc ../../../inc ../../tauto ../../tauto/openwfc +USERINCLUDE ../../tredir ../../tlisten ../../tframerate ../../tcontaindrawer ../../t_gdcoverage ../../tbufferdrawer +USERINCLUDE ../../tlib ../../ -APP_LAYER_SYSTEMINCLUDE_SYMBIAN -MW_LAYER_SYSTEMINCLUDE_SYMBIAN -OS_LAYER_SYSTEMINCLUDE_SYMBIAN -OS_LAYER_LIBC_SYSTEMINCLUDE - +OS_LAYER_SYSTEMINCLUDE +OS_LAYER_LIBC_SYSTEMINCLUDE SOURCEPATH ../ SOURCE TAutoServer.cpp SOURCEPATH ../../ SOURCE PARSEINIDATA.CPP -SOURCEPATH ../../../tauto +SOURCEPATH ../../tauto SOURCE AUTO.CPP SOURCE TAUTODLL.CPP SOURCE TEvent.CPP diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/TAutoServer/openwfc/TAutoServer_nonnga.mmp --- a/windowing/windowserver/test/TAutoServer/openwfc/TAutoServer_nonnga.mmp Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/test/TAutoServer/openwfc/TAutoServer_nonnga.mmp Wed Jun 23 19:41:15 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -23,12 +23,11 @@ MACRO TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA -USERINCLUDE ../../../../../graphicstest/graphicstestharness/inc ../../../inc ../../../tauto ../../../tauto/openwfc -USERINCLUDE ../../../tredir ../../../tlisten ../../../tframerate ../../../tcontaindrawer ../../t_gdcoverage -USERINCLUDE ../../../tlib ../../ +USERINCLUDE ../../../../../graphicstest/graphicstestharness/inc ../../../inc ../../tauto ../../tauto/openwfc +USERINCLUDE ../../tredir ../../tlisten ../../tframerate ../../tcontaindrawer ../../t_gdcoverage +USERINCLUDE ../../tlib ../../ -MW_LAYER_SYSTEMINCLUDE_SYMBIAN -OS_LAYER_SYSTEMINCLUDE_SYMBIAN +OS_LAYER_SYSTEMINCLUDE OS_LAYER_LIBC_SYSTEMINCLUDE SOURCEPATH ../ @@ -36,7 +35,7 @@ SOURCEPATH ../../ SOURCE PARSEINIDATA.CPP -SOURCEPATH ../../../tauto +SOURCEPATH ../../tauto SOURCE AUTO.CPP SOURCE TAUTODLL.CPP SOURCE TEvent.CPP diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/TClick/CLICK.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/TClick/CLICK.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,708 @@ +// Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Test Key Click Plug-In DLL +// +// + +#include +#include "W32CLICK.H" +#include "CLICK.H" +#include +#if defined(__WINS__) + #include + #include "LOGWIN.H" +#endif + +#define bufSize 64 + +GLREF_D struct TSharedMemory GSharedMemory; + +class MClickMaker + { +public: + virtual void KeyEvent(TEventCode aType,const TKeyEvent& aEvent)=0; + virtual void PointerEvent(const TPointerEvent& aEvent)=0; + virtual void OtherEvent(TInt aType,TAny* aParam)=0; + }; + +struct TGpWinInfo + { + TBool iInUse; + TInt iServerValue; + TInt iNumGroups; + }; + +struct TGpWinIdData + { + TInt iId; + TInt iClient; + }; + +NONSHARABLE_CLASS(TLogClicks) : public MClickMaker + { +public: + void StartLoggingL(); + inline TBool IsLogging() {return iLogging;} + //Pure virtual functions from MClickMaker + void KeyEvent(TEventCode aType,const TKeyEvent& aEvent); + void PointerEvent(const TPointerEvent& aEvent); + void OtherEvent(TInt aType,TAny* aParam=NULL); +private: + TBool iLogging; + }; + +NONSHARABLE_CLASS(CEventClicks) : public CBase, public MClickMaker + { + enum { + EEventBufferSize=32, + EMaxGroupWinClients=6, + EMaxGroupWinIdData=12 + }; +public: + void ConstructL(); + TInt Add(TWsEvent* aEvent); + inline TInt Failed() {return iFailed;} + inline TInt Events() {return iEventsTested;} + void Reset(); + void ExtendedPointerEvent(const TPointerEventData& aPointerEvent); + void ExpectNewWindowGroup(TInt aClient); + void NewWindowGroup(const TGroupWindowOpenData& aGpWinOpen); + void CheckGpWinId(TInt aId); + void ExpectCloseWindowGroup(TInt aId); + void CloseWindowGroup(TInt aId); + void ExpectCloseWindow(TWindowCloseData& aCloseWin); + void CloseWindow(TWindowCloseData& aCloseWin); + void PointerEventInfo(TPointerEventInfo& aPointerEventInfo); + //Pure virtual functions from MClickMaker + void KeyEvent(TEventCode aType,const TKeyEvent& aEvent); + void PointerEvent(const TPointerEvent& aEvent); + void OtherEvent(TInt aType,TAny* aParam=NULL); +private: + TBool GetEvent(TWsEvent& aEvent); + void Fail(); + void AddGroupWindowId(TInt aClient,TInt aGpWinId); + void RemoveGroupWindowId(TInt aGpWinId); +private: + CCirBuf iEventBuffer; + TInt iFailed; + TInt iEventsTested; + TInt iFailedAt; + TGpWinInfo iGroupWins[EMaxGroupWinClients]; + TGpWinIdData iGroupWinIds[EMaxGroupWinIdData]; + TInt iExpectedEvent; + TInt iExpectedEventData; + TInt iExpectedHandle; + TPointerEventInfo iExpectedPointerEventInfo; + TInt iLastNewGpWinId; + TAdvancedPointerEvent iLastPointerEvent; + TBool iExpectingExtendedPointer; + }; + +NONSHARABLE_CLASS(CMyClickMaker) : public CClickMaker + { +public: + ~CMyClickMaker(); + void ConstructL(); + //Virtual function from CClickMaker + void KeyEvent(TEventCode aType,const TKeyEvent& aEvent); + void PointerEvent(const TPointerEvent& aEvent); + void OtherEvent(TInt aType,TAny* aParam); + TInt CommandReplyL(TInt aOpcode, TAny *aArgs); +private: + void LogToWindowL(); +private: + TClickOutputModes iMode; + MClickMaker* iCurrentClick; + TLogClicks iLogClicks; + CEventClicks* iEventClicks; + }; + + +/*TLogClicks*/ + +void TLogClicks::StartLoggingL() + { +#if defined(__WINS__) + if (!IsLogging()) + { + CreateLogWinThreadL(); + iLogging=ETrue; + } +#else + User::Leave(KErrNotSupported); +#endif + } + +void TLogClicks::KeyEvent(TEventCode aType,const TKeyEvent& aEvent) + { + _LIT(KKeyDown, "KEY DOWN "); + _LIT(KKeyUp, "KEY UP "); + _LIT(KKeyEvent, "KEY EVENT "); + _LIT(KKeyRepeat, "KEY REPEAT "); + _LIT(KKeyUnknown, "KEY Unknown"); + _LIT(KKeyDataFormatChar,"'%c',"); + _LIT(KKeyDataFormatCode," Code=%u,"); + _LIT(KKeyDataFormatScan," Scan=%d,"); + _LIT(KKeyDataFormatModRep," Mod=0x%x, Rep=%d"); + TBuf bufPlusZero; + switch (aType) + { + case EEventKey: + bufPlusZero.Copy(KKeyEvent); + break; + case EEventKeyUp: + bufPlusZero.Copy(KKeyUp); + break; + case EEventKeyDown: + bufPlusZero.Copy(KKeyDown); + break; + case EEventKeyRepeat: + bufPlusZero.Copy(KKeyRepeat); + break; + default: + bufPlusZero.Copy(KKeyUnknown); + break; + } + bufPlusZero.AppendFormat(KKeyDataFormatCode,aEvent.iCode); + if (aEvent.iCode!=0) + bufPlusZero.AppendFormat(KKeyDataFormatChar,aEvent.iCode); + bufPlusZero.AppendFormat(KKeyDataFormatScan,aEvent.iScanCode); + if (aEvent.iScanCode!=0) + bufPlusZero.AppendFormat(KKeyDataFormatChar,aEvent.iScanCode); + bufPlusZero.AppendFormat(KKeyDataFormatModRep,aEvent.iModifiers,aEvent.iRepeats); + bufPlusZero.ZeroTerminate(); +#if defined(__WINS__) + Emulator::Escape(); + SendMessage(GSharedMemory.iHwnd, WM_USER+EAppendText, (bufPlusZero.Length()+1)*sizeof(TText), (TInt32)(bufPlusZero.Ptr())); + Emulator::Reenter(); +#endif + } + +void TLogClicks::PointerEvent(const TPointerEvent& aEvent) + { + _LIT(KButtonDown, "POINTER DOWN "); + _LIT(KButtonUp, "POINTER UP "); + _LIT(KButton2Down, "BUTTON 2 DOWN"); + _LIT(KButton2Up, "BUTTON 2 UP "); + _LIT(KButton3Down, "BUTTON 3 DOWN"); + _LIT(KButton3Up, "BUTTON 3 UP "); + _LIT(KButtonDrag, "POINTER DRAG "); + _LIT(KButtonMove, "POINTER MOVE "); + _LIT(KButtonRepeat, "BUTTON REPEAT"); + _LIT(KSwitchOn, "POINTER ON "); + _LIT(KUnknown, "PTR Unknown "); + //_LIT(KPtrDataFormat," Pos=(%d,%d), ScrPos=(%d,%d), Modifiers=%x"); + _LIT(KPtrDataFormat," Pos=(%d,%d), ScrPos=(%d,%d), Mod=%x"); + TBuf bufPlusZero; + switch (aEvent.iType) + { + case TPointerEvent::EButton1Down: + bufPlusZero.Copy(KButtonDown); + break; + case TPointerEvent::EButton1Up: + bufPlusZero.Copy(KButtonUp); + break; + case TPointerEvent::EButton2Down: + bufPlusZero.Copy(KButton2Down); + break; + case TPointerEvent::EButton2Up: + bufPlusZero.Copy(KButton2Up); + break; + case TPointerEvent::EButton3Down: + bufPlusZero.Copy(KButton3Down); + break; + case TPointerEvent::EButton3Up: + bufPlusZero.Copy(KButton3Up); + break; + case TPointerEvent::EDrag: + bufPlusZero.Copy(KButtonDrag); + break; + case TPointerEvent::EMove: + bufPlusZero.Copy(KButtonMove); + break; + case TPointerEvent::EButtonRepeat: + bufPlusZero.Copy(KButtonRepeat); + break; + case TPointerEvent::ESwitchOn: + bufPlusZero.Copy(KSwitchOn); + break; + default: + bufPlusZero.Copy(KUnknown); + break; + } + bufPlusZero.AppendFormat(KPtrDataFormat,aEvent.iPosition.iX,aEvent.iPosition.iY + ,aEvent.iParentPosition.iX,aEvent.iParentPosition.iY,aEvent.iModifiers); + bufPlusZero.ZeroTerminate(); +#if defined(__WINS__) + Emulator::Escape(); + SendMessage(GSharedMemory.iHwnd, WM_USER+EAppendText, (bufPlusZero.Length()+1)*sizeof(TText), (TInt32)(bufPlusZero.Ptr())); + Emulator::Reenter(); +#endif + } + +void TLogClicks::OtherEvent(TInt aType,TAny* aParam) + { + _LIT(KPointer,"POINTER EVENT Ver=%d, ScrPos=(%d,%d), WinClientHandle=0x%x, WinOrigin=%d, WinGpId=%d"); + _LIT(KScreenDeviceChanged,"SCREEN DEVICE CHANGED EVENT, Mode=%d"); + _LIT(KGroupWindowOpen,"GROUP WINDOW OPEN EVENT WinGpId=%d, Client=%d, NumWinGps=%d"); + _LIT(KGroupWindowClose,"GROUP WINDOW CLOSE EVENT WinGpId=%d"); + _LIT(KWindowClose,"WINDOW CLOSE EVENT Client=%d, WinGpId=%d"); + _LIT(KEventUnknown, "EVENT Unknown"); + TBuf bufPlusZero; + switch (aType) + { + case EEventPointer: + { + TPointerEventData& data=*static_cast(aParam); + bufPlusZero.Format(KPointer,data.iVersion,data.iCurrentPos.iX,data.iCurrentPos.iY,data.iClientHandle + ,data.iWindowOrigin.iX,data.iWindowOrigin.iY,data.iWindowGroupId); + } + break; + case EEventScreenDeviceChanged: + { + TClickMakerData& data=*static_cast(aParam); + bufPlusZero.Format(KScreenDeviceChanged,data.screenDeviceMode); + } + break; + case EEventGroupWindowOpen: + { + TGroupWindowOpenData& data=*static_cast(aParam); + bufPlusZero.Format(KGroupWindowOpen,data.iIdentifier,data.iClient,data.iNumClientWindowGroups); + } + break; + case EEventGroupWindowClose: + bufPlusZero.Format(KGroupWindowClose,reinterpret_cast(aParam)); + break; + case EEventWindowClose: + { + TWindowCloseData& data=*static_cast(aParam); + bufPlusZero.Format(KWindowClose,data.iClientHandle,data.iWindowGroupId); + } + break; + default: + bufPlusZero.Copy(KEventUnknown); + break; + } + bufPlusZero.ZeroTerminate(); +#if defined(__WINS__) + Emulator::Escape(); + SendMessage(GSharedMemory.iHwnd, WM_USER+EAppendText, (bufPlusZero.Length()+1)*sizeof(TText), (TInt32)(bufPlusZero.Ptr())); + Emulator::Reenter(); +#endif + } + +/*CEventClicks*/ + +void CEventClicks::ConstructL() + { + iEventBuffer.SetLengthL(EEventBufferSize); + } + +TInt CEventClicks::Add(TWsEvent* aEvent) + { + return (iEventBuffer.Add(aEvent) ? KErrNone:KErrOverflow); + } + +void CEventClicks::Reset() + { + iFailed=EFalse; + iEventsTested=0; + iExpectedEvent=0; + iLastNewGpWinId=0; + } + +void CEventClicks::ExtendedPointerEvent(const TPointerEventData& aPointerEvent) + { + if (!iExpectingExtendedPointer) + { + Fail(); + return; + } + iExpectingExtendedPointer=EFalse; + TBool match=ETrue; + if (0!=aPointerEvent.iVersion) + match=EFalse; + if (iLastPointerEvent.iType!=aPointerEvent.iPointerEvent.iType) + match=EFalse; + if (iLastPointerEvent.iModifiers!=aPointerEvent.iPointerEvent.iModifiers) + match=EFalse; + if (iLastPointerEvent.iPosition!=aPointerEvent.iPointerEvent.iPosition) + match=EFalse; + if (iLastPointerEvent.iParentPosition!=aPointerEvent.iCurrentPos) + match=EFalse; + if (TPointerEventData::EUnspecified!=aPointerEvent.iSource) + match=EFalse; + if (iExpectedPointerEventInfo.iClientHandle && iExpectedPointerEventInfo.iWinGpId>0) + { + if (iLastPointerEvent.iParentPosition-iExpectedPointerEventInfo.iParentOrigin + !=aPointerEvent.iPointerEvent.iParentPosition) + match=EFalse; + if (iExpectedPointerEventInfo.iParentOrigin+iExpectedPointerEventInfo.iWinOrigin + !=aPointerEvent.iWindowOrigin) + match=EFalse; + if (iExpectedPointerEventInfo.iClientHandle!=aPointerEvent.iClientHandle) + match=EFalse; + if (iExpectedPointerEventInfo.iWinGpId!=aPointerEvent.iWindowGroupId) + match=EFalse; + } + if (!match) + Fail(); + } + +void CEventClicks::ExpectNewWindowGroup(TInt aClient) + { + if (iExpectedEvent>0) + Fail(); + iExpectedEvent=EEventGroupWindowOpen; + iExpectedEventData=aClient; + } + +void CEventClicks::NewWindowGroup(const TGroupWindowOpenData& aGpWinOpen) + { + iLastNewGpWinId=aGpWinOpen.iIdentifier; + if (iExpectedEvent!=EEventGroupWindowOpen) + { + Fail(); + return; + } + iExpectedEvent=0; + if (iExpectedEventData>=EMaxGroupWinClients) + return; + AddGroupWindowId(iExpectedEventData,iLastNewGpWinId); + TGpWinInfo& gpWinInfo=iGroupWins[iExpectedEventData]; + if (gpWinInfo.iInUse) + { + if (aGpWinOpen.iClient!=gpWinInfo.iServerValue) + Fail(); + else + { + if (aGpWinOpen.iNumClientWindowGroups!=gpWinInfo.iNumGroups) + Fail(); + ++gpWinInfo.iNumGroups; + } + } + else + { + gpWinInfo.iInUse=ETrue; + gpWinInfo.iServerValue=aGpWinOpen.iClient; + gpWinInfo.iNumGroups=aGpWinOpen.iNumClientWindowGroups+1; + } + } + +void CEventClicks::CheckGpWinId(TInt aId) + { + if (iLastNewGpWinId!=aId) + Fail(); + } + +void CEventClicks::ExpectCloseWindowGroup(TInt aId) + { + if (iExpectedEvent>0) + Fail(); + iExpectedEvent=EEventGroupWindowClose; + iExpectedEventData=aId; + } + +void CEventClicks::CloseWindowGroup(TInt aId) + { + if (iExpectedEvent!=EEventGroupWindowClose || iExpectedEventData!=aId) + Fail(); + if (iExpectedEvent==EEventGroupWindowClose) + iExpectedEvent=0; + RemoveGroupWindowId(aId); + } + +void CEventClicks::ExpectCloseWindow(TWindowCloseData& aCloseWin) + { + if (iExpectedEvent>0) + Fail(); + iExpectedEvent=EEventWindowClose; + iExpectedEventData=aCloseWin.iWindowGroupId; + iExpectedHandle=aCloseWin.iClientHandle; + } + +void CEventClicks::CloseWindow(TWindowCloseData& aCloseWin) + { + if (iExpectedEvent!=EEventWindowClose || iExpectedEventData!=aCloseWin.iWindowGroupId || iExpectedHandle!=aCloseWin.iClientHandle) + Fail(); + if (iExpectedEvent==EEventWindowClose) + iExpectedEvent=0; + } + +void CEventClicks::PointerEventInfo(TPointerEventInfo& aPointerEventInfo) + { + iExpectedPointerEventInfo=aPointerEventInfo; + } + +TBool CEventClicks::GetEvent(TWsEvent& aEvent) + { + ++iEventsTested; + if (iEventBuffer.Remove(&aEvent)<1) + { + Fail(); + return ETrue; + } + return EFalse; + } + +void CEventClicks::Fail() + { + if (!iFailed) + { + iFailed=iEventsTested; + } + } + +void CEventClicks::AddGroupWindowId(TInt aClient,TInt aGpWinId) + { + TInt ii=0; + while (ii0) + ++ii; + if (ii0); + eType=EEventKey; + break; + default: + pass=EFalse; + } + if (!pass) + { + Fail(); + return; + } + TWsEvent eEvent; + if (GetEvent(eEvent)) + return; + if (eEvent.Type()!=eType) + { + Fail(); + return; + } + TKeyEvent keyEvent=*eEvent.Key(); + TUint mask=~(EModifierAutorepeatable|MODIFIER_FLAGS_TO_IGNOR); + if (keyEvent.iCode!=aEvent.iCode || (keyEvent.iModifiers&mask)!=(aEvent.iModifiers&mask) || keyEvent.iScanCode!=aEvent.iScanCode + || (keyEvent.iRepeats==0)!=(aEvent.iRepeats==0)) + { + Fail(); + return; + } + } + +void CEventClicks::PointerEvent(const TPointerEvent& aEvent) + { + // Click events are now all advanced events so in order to test the modifier bits + // appropriately we need to copy them as TAdvancedPointerEvent not TPointerEvent + if(!aEvent.IsAdvancedPointerEvent()) + { + Fail(); + return; + } + iLastPointerEvent=*aEvent.AdvancedPointerEvent(); + + if (iExpectingExtendedPointer) + Fail(); + else + iExpectingExtendedPointer=ETrue; + TWsEvent eEvent; + if (GetEvent(eEvent)) + return; + TAdvancedPointerEvent pEvent=*eEvent.Pointer(); + TUint mask=~(MODIFIER_FLAGS_TO_IGNOR); + if (pEvent.iType!=aEvent.iType || (pEvent.iModifiers&mask)!=(aEvent.iModifiers&mask) + || pEvent.iPosition!=aEvent.iPosition || pEvent.iParentPosition!=aEvent.iParentPosition) + { + Fail(); + return; + } + } + +void CEventClicks::OtherEvent(TInt aType,TAny* aParam) + { + TBool pass=ETrue; + if (aType!=EEventPointer) + ++iEventsTested; + switch (aType) + { + case EEventPointer: + ExtendedPointerEvent(*static_cast(aParam)); + break; + case EEventScreenDeviceChanged: + break; + case EEventGroupWindowOpen: + NewWindowGroup(*static_cast(aParam)); + break; + case EEventGroupWindowClose: + CloseWindowGroup(reinterpret_cast(aParam)); + break; + case EEventWindowClose: + CloseWindow(*static_cast(aParam)); + break; + default: + pass=EFalse; + } + if (!pass) + Fail(); + //GetEvent() is not call here because CWsGroupWindow::EnableScreenChangeEvents() could not be + //been called.This mean that no EEventScreenDeviceChanged will be put in the client queue. + //Instead this event will be always passed to the click plugin if this is present. + } +#pragma warning(default : 4245) + + +/*CMyClickMaker*/ + +CMyClickMaker::~CMyClickMaker() + { + delete iEventClicks; + } + +void CMyClickMaker::ConstructL() + { + iMode=EClickNone; + iEventClicks=new(ELeave) CEventClicks(); + iEventClicks->ConstructL(); + } + +void CMyClickMaker::KeyEvent(TEventCode aType,const TKeyEvent& aEvent) + { + if (iCurrentClick) + iCurrentClick->KeyEvent(aType,aEvent); + } + +void CMyClickMaker::PointerEvent(const TPointerEvent& aEvent) + { + if (iCurrentClick) + iCurrentClick->PointerEvent(aEvent); + } + +void CMyClickMaker::OtherEvent(TInt aType,TAny* aParam) + { + if (iCurrentClick) + iCurrentClick->OtherEvent(aType,aParam); + } + +TInt CMyClickMaker::CommandReplyL(TInt aOpcode,TAny* aArgs) + { + switch (aOpcode) + { + case EClickCommandToggleOutput: + switch (iMode) + { + case EClickNone: + LogToWindowL(); + break; + case EClickCheck: + case EClickToWindow: + iMode=EClickNone; + iCurrentClick=NULL; + break; + } + break; + case EClickCommandSetOutput: + iMode=*STATIC_CAST(TClickOutputModes*,aArgs); + switch (iMode) + { + case EClickNone: + iCurrentClick=NULL; + break; + case EClickCheck: + iCurrentClick=iEventClicks; + iEventClicks->Reset(); + break; + case EClickToWindow: + LogToWindowL(); + break; + } + break; + case EClickEventAdd: + return iEventClicks->Add(STATIC_CAST(TWsEvent*,aArgs)); + case EClickFailed: + return iEventClicks->Failed(); + case EClickEvents: + return iEventClicks->Events(); + case EClickReset: + iEventClicks->Reset(); + break; + case EClickCreateGroupWin: + iEventClicks->ExpectNewWindowGroup(*static_cast(aArgs)); + break; + case EClickCheckGpWinId: + iEventClicks->CheckGpWinId(*static_cast(aArgs)); + break; + case EClickCloseGroupWin: + iEventClicks->ExpectCloseWindowGroup(*static_cast(aArgs)); + break; + case EClickCloseWin: + iEventClicks->ExpectCloseWindow(*static_cast(aArgs)); + break; + case EClickPointerEvent: + iEventClicks->PointerEventInfo(*static_cast(aArgs)); + break; + default:; + } + return KErrNone; + } + +void CMyClickMaker::LogToWindowL() + { + iMode=EClickNone; + iCurrentClick=NULL; + iLogClicks.StartLoggingL(); + iMode=EClickToWindow; + iCurrentClick=&iLogClicks; + } + + +EXPORT_C CClickMaker* CreateClickMakerL() + { + CMyClickMaker* plugIn=new(ELeave) CMyClickMaker; + CleanupStack::PushL(plugIn); + plugIn->ConstructL(); + CleanupStack::Pop(plugIn); + return plugIn; + } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/TClick/CLICK.H --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/TClick/CLICK.H Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,57 @@ +// Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Client interface to the click plugin. +// +// + +#ifndef __CLICK_H__ +#define __CLICK_H__ + +#define CLICK_THIRD_UID 268455780 + +enum TClickOutputModes + { + EClickNone, + EClickCheck, + EClickToWindow, //For WINS only + }; + +enum TClickCommands + { + // Control Between Plug-in Types + EClickCommandToggleOutput=1, + EClickCommandSetOutput, + // Key and Pointer Testing + EClickEventAdd=100, + EClickFailed, + EClickEvents, + EClickReset, + // Other Event Testing + EClickCreateGroupWin=200, + EClickCheckGpWinId, + EClickCloseGroupWin, + EClickCloseWin, + EClickPointerEvent, + }; + +class TPointerEventInfo + { +public: + TInt iClientHandle; + TInt iWinGpId; + TPoint iWinOrigin; //Relative to parent + TPoint iParentOrigin; //Relative to screen + }; + +#endif //__CLICK_H__ diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/TClick/LOGWIN.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/TClick/LOGWIN.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,304 @@ +// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Extracted from DEBLOGWN.CPP +// Code to run the WIN32 windows with the output +// +// + +#include +#include +#include +#include "LOGWIN.H" + +GLDEF_D struct TSharedMemory GSharedMemory; +//GLDEF_D struct HWND__ *Hwnd; +//LOCAL_D RSemaphore Sem; + +const TUint KHeapSize=0x8000; + + +TInt numLines(const CArrayVarSeg &aTextArray, TBool aOutOfMemory) + { + return (TInt)(aOutOfMemory)? + aTextArray.Count(): + aTextArray.Count()-1; + } + +TInt numVisibleLines(TInt aHeight, TInt aTextHeight) + { + return aHeight/aTextHeight; + } + +TInt32 __stdcall WndProc(struct HWND__ *aHwnd, TUint aMessage, TUint wParam, TInt32 lParam) + { + HDC hdc; + PAINTSTRUCT ps; + HFONT hfont; + RECT rect; + TInt i, + paintMin, + paintMax; + static LOGFONT logFont; + static TEXTMETRIC tm; + static TInt textHeight, + width, + height, + scrollMin=0, + scrollMax, + numLinesAbove=scrollMin, + prevNumLinesAbove; + static CArrayVarSeg *pmsg; + static TBool outOfMemory=EFalse; + + switch (aMessage) + { + case WM_CREATE: + hdc=GetDC(aHwnd); + + pmsg=new(ELeave) CArrayVarSeg(20); + { + TBuf<0x20> errorMsg; + errorMsg=_L("ERROR: out of memory"); + errorMsg.ZeroTerminate(); + TRAPD(err,pmsg->AppendL(*errorMsg.Ptr(), (errorMsg.Length()+1)*sizeof(TText))); + if (err!=KErrNone) + return(err); + } + GetTextMetrics(hdc, &tm); + textHeight=tm.tmHeight+tm.tmExternalLeading; + GetClientRect(aHwnd, &rect); + width=rect.right; + height=rect.bottom; + scrollMax=numLines(*pmsg, outOfMemory); + SetScrollPos(aHwnd, SB_VERT, numLinesAbove, TRUE); + SetScrollRange(aHwnd, SB_VERT, scrollMin, scrollMax, FALSE); + logFont.lfHeight=8; + wsprintf(logFont.lfFaceName, (LPCTSTR)_S("courier")); + + ReleaseDC(aHwnd, hdc); + return 0; + case WM_USER+EAppendText: + { + TRAPD(err,pmsg->InsertL(pmsg->Count()-1, *(TText *)lParam, wParam)); + if (err!=KErrNone) + { + pmsg->Delete(0, Max(0, (TInt)pmsg->Count()-1)); + numLinesAbove=scrollMax=scrollMin; + SetScrollPos(aHwnd, SB_VERT, numLinesAbove, TRUE); + SetScrollRange(aHwnd, SB_VERT, scrollMin, scrollMax, FALSE); + hdc=GetDC(aHwnd); + PatBlt(hdc, 0, 0, width, height, WHITENESS); + ReleaseDC(aHwnd, hdc); + return(err); + } + // adjust the scroll position so that the last line added is visible + if (numLinesAboveprevNumLinesAbove) + // scrolling towards end, therefore text moves up on screen + { + TInt numLinesToDraw=numLinesAbove-prevNumLinesAbove; + TInt numLinesToBlt=numVisibleLines(height, textHeight)-numLinesToDraw; + if (numLinesToBlt>0) + ScrollWindow(aHwnd, 0, -numLinesToDraw*textHeight, NULL, NULL); + PatBlt(hdc, 0, numLinesToBlt*textHeight, width, numLinesToDraw*textHeight, WHITENESS); + paintMin=Max(Min(numLinesAbove+numLinesToBlt, scrollMax), scrollMin); + paintMax=Min(paintMin+numLinesToDraw, scrollMax); + for (i=paintMin; i0) + ScrollWindow(aHwnd, 0, numLinesToDraw*textHeight, NULL, NULL); + PatBlt(hdc, 0, 0, width, numLinesToDraw*textHeight, WHITENESS); + paintMin=Max(Min(numLinesAbove, scrollMax), scrollMin); + paintMax=Min(paintMin+numLinesToDraw, scrollMax); + for (i=paintMin; i + +GLREF_C void CreateLogWinThreadL(); + +//GLREF_D struct HWND__ *Hwnd; +// static container for sharing data between Symbian & Windows threads +struct TSharedMemory + { + RSemaphore iStartSemaphore; + struct HWND__* iHwnd; + }; + +enum TWindowsUserMessage + { + EAppendText, + EScrollToPos + }; diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/TClick/multiptrclick.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/TClick/multiptrclick.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,246 @@ +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Test Multi Pointer Click Plug-In DLL +// +// + +#include +#include "W32CLICK.H" +#include "multiptrclick.h" + +class CMultiPtrClickMaker : public CClickMaker + { + enum {EEventBufferSize=32}; +public: + ~CMultiPtrClickMaker(); + void ConstructL(); + //Virtual function from CClickMaker + void KeyEvent(TEventCode aType, const TKeyEvent& aEvent); + void PointerEvent(const TPointerEvent& aEvent); + void OtherEvent(TInt aType, TAny* aParam); + TInt CommandReplyL(TInt aOpcode, TAny *aArgs); + +private: + TInt AddEvent(const TWsEvent* aEvent); + TInt AddEvent(const TPointerEventData* aEvent); + TBool ComparePointerEvents(const TPointerEvent* aExpectedEvent, const TPointerEvent* aActualEvent); + TBool CompareOtherEvents(const TPointerEventData* aExpectedEvent, const TPointerEventData* aActualEvent); +private: + CCirBuf iPtrEventBuffer; + CCirBuf iOtherEventBuffer; + TBuf<255> iErrorDes; + TInt iPtrEventCount; + TInt iOtherEventCount; + TInt iError; + }; + + +void CMultiPtrClickMaker::ConstructL() + { + iPtrEventBuffer.SetLengthL(EEventBufferSize); + iOtherEventBuffer.SetLengthL(EEventBufferSize); + } + +CMultiPtrClickMaker::~CMultiPtrClickMaker() + { + } + +void CMultiPtrClickMaker::KeyEvent(TEventCode /*aType*/,const TKeyEvent& /*aEvent*/) + { + } + +TBool CMultiPtrClickMaker::ComparePointerEvents(const TPointerEvent* aExpectedEvent, const TPointerEvent* aActualEvent) + { + // Check pointer type + if (aExpectedEvent->iType != aActualEvent->iType) + { + _LIT(KEventType, "Actual Wserv Event type = %d Expected Wserv Event Type = %d "); + iErrorDes.Format(KEventType, aActualEvent->iType, aExpectedEvent->iType); + return EFalse; + } + + if (aExpectedEvent->iPosition != aActualEvent->iPosition) + { + _LIT(KPointerPosition, "Actual PointerPosition = (%d, %d) Expected PointerPosition = (%d, %d) "); + iErrorDes.Format(KPointerPosition, aActualEvent->iPosition.iX, aActualEvent->iPosition.iY, aExpectedEvent->iPosition.iX, aExpectedEvent->iPosition.iY); + return EFalse; + } + + if (aExpectedEvent->iParentPosition != aActualEvent->iParentPosition) + { + _LIT(KPointerPosition, "Actual parent Position = (%d, %d) Expected parent Position = (%d, %d) "); + iErrorDes.Format(KPointerPosition, aActualEvent->iParentPosition.iX, aActualEvent->iParentPosition.iY, aExpectedEvent->iParentPosition.iX, aExpectedEvent->iParentPosition.iY); + return EFalse; + } + + if (aExpectedEvent->IsAdvancedPointerEvent() != aActualEvent->IsAdvancedPointerEvent()) + { + _LIT(KPointerPosition, "Actual event is TAdvancedPointerEvent = %d Expected event is TAdvancedPointerEvent = %d "); + iErrorDes.Format(KPointerPosition, aActualEvent->IsAdvancedPointerEvent(), aExpectedEvent->IsAdvancedPointerEvent()); + return EFalse; + } + + if (aExpectedEvent->IsAdvancedPointerEvent()) + { + const TAdvancedPointerEvent& expectedAdvancedEvent = *aExpectedEvent->AdvancedPointerEvent(); + const TAdvancedPointerEvent& actualAdvancedEvent = *aActualEvent->AdvancedPointerEvent(); + + if (expectedAdvancedEvent.PointerNumber() != actualAdvancedEvent.PointerNumber()) + { + _LIT(KPointerNumber, "Actual PointerNumber = %d Expected PointerNumber = %d "); + iErrorDes.Format(KPointerNumber, actualAdvancedEvent.PointerNumber(), expectedAdvancedEvent.PointerNumber()); + return EFalse; + } + + if (expectedAdvancedEvent.Pressure() != actualAdvancedEvent.Pressure()) + { + _LIT(KPointerPressure, "Actual Pressure = %d Expected Pressure = %d "); + iErrorDes.Format(KPointerPressure, actualAdvancedEvent.Pressure(), expectedAdvancedEvent.Pressure()); + return EFalse; + } + + if (expectedAdvancedEvent.Proximity() != actualAdvancedEvent.Proximity()) + { + _LIT(KPointerProximity, "Actual Proximity = %d Expected Proximity = %d "); + iErrorDes.Format(KPointerProximity, actualAdvancedEvent.Proximity(), expectedAdvancedEvent.Proximity()); + return EFalse; + } + } + + return ETrue; + } + +// +void CMultiPtrClickMaker::PointerEvent(const TPointerEvent& aEvent) + { + // If it has already failed then do not test other events + // becasue the error value and its descriptor will be over written + if (iError) + { + return; + } + + // Get pointer event from buffer + TWsEvent expectedEvent; + iPtrEventBuffer.Remove(&expectedEvent); + + // Increment event count + iPtrEventCount++; + + // increment this counter in OtherEvent() becasue first pointer event iscalled and then OtherEvent() is called + if (!ComparePointerEvents(expectedEvent.Pointer(), &aEvent)) + { + iError = iPtrEventCount; + } + } + +TBool CMultiPtrClickMaker::CompareOtherEvents(const TPointerEventData* aExpectedEvent, const TPointerEventData* aActualEvent) + { + if (aExpectedEvent->iCurrentPos != aActualEvent->iCurrentPos) + { + _LIT(KCurrentPosition, "Actual CurrentPosition w.r.t screen = (%d,%d) Expected CurrentPosition w.r.t screen = (%d,%d)"); + iErrorDes.Copy(KCurrentPosition); + iErrorDes.Format(KCurrentPosition, aActualEvent->iCurrentPos.iX, aActualEvent->iCurrentPos.iX, aExpectedEvent->iCurrentPos.iX, aExpectedEvent->iCurrentPos.iY); + return EFalse; + } + + if (aExpectedEvent->iClientHandle != aActualEvent->iClientHandle) + { + _LIT(KWindowHandle, "Actual Window Handle = %d Expected Window Handle = %d "); + iErrorDes.Copy(KWindowHandle); + iErrorDes.Format(KWindowHandle, aActualEvent->iClientHandle, aExpectedEvent->iClientHandle); + return EFalse; + } + + return ComparePointerEvents(&aExpectedEvent->iPointerEvent, &aActualEvent->iPointerEvent); + } + +void CMultiPtrClickMaker::OtherEvent(TInt aType, TAny* aParam) + { + if (aType != EEventPointer) + { + return; + } + + if (iError) + { + return; + } + + TPointerEventData expectedEvent; + iOtherEventBuffer.Remove(&expectedEvent); + + iOtherEventCount++; + + TPointerEventData* data=static_cast(aParam); + + if (!CompareOtherEvents(&expectedEvent, data)) + { + iError = iPtrEventCount; + } + } + +TInt CMultiPtrClickMaker::AddEvent(const TWsEvent* aEvent) + { + return iPtrEventBuffer.Add(aEvent); + } + +TInt CMultiPtrClickMaker::AddEvent(const TPointerEventData* aEvent) + { + return iOtherEventBuffer.Add(aEvent); + } + +TInt CMultiPtrClickMaker::CommandReplyL(TInt aOpcode, TAny *aArgs) + { + TMultiPtrClickArgUnion pData; + pData.any=aArgs; + switch (aOpcode) + { + case EMultiPtrClickEventAdd: + return AddEvent(pData.WsEvent); + case EMultiPtrOtherEventAdd: + return AddEvent(pData.OtherEvent); + case EMultiPtrClickEventError: + return iError; + case EMultiPtrClickEventErrorDesc: + if (iError != KErrNone) + { + RChunk chunk; + chunk.OpenGlobal(KMultiPtrClickChunk, ETrue); + TUint8* desPtr = chunk.Base() + *(static_cast(aArgs)); + TPtr8 ptrDes(desPtr, iErrorDes.Length(), iErrorDes.Length()); + ptrDes.Copy(iErrorDes); + chunk.Close(); + return iErrorDes.Length(); + // returns the error description which gets displayed in logs if test failed + } + break; + case EMultiPtrClickEventReset: + iPtrEventBuffer.Reset(); + iError = 0; + iPtrEventCount = 0; + break; + default:; + } + return(KErrNone); + } + +EXPORT_C CClickMaker* CreateMultiPtrClickMakerL() + { + CMultiPtrClickMaker* plugIn=new(ELeave) CMultiPtrClickMaker; + CleanupStack::PushL(plugIn); + plugIn->ConstructL(); + CleanupStack::Pop(plugIn); + return plugIn; + } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/TClick/multiptrclick.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/TClick/multiptrclick.h Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,47 @@ +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Client interface to the pointer click plugin. +// +// + +#ifndef __MULTIPTRCLICK_H__ +#define __MULTIPTRCLICK_H__ + +#ifndef __W32CLICK_H__ +#include +#endif + +#include + +#define MULTIPTR_CLICK_THIRD_UID 268455781 + +_LIT(KMultiPtrClickChunk, "PointerClickChunk"); + +enum TMultiPtrClickCommands + { + EMultiPtrClickEventAdd, + EMultiPtrClickEventError, + EMultiPtrClickEventErrorDesc, + EMultiPtrClickEventReset, + EMultiPtrOtherEventAdd, + }; + +union TMultiPtrClickArgUnion + { + const TAny* any; + const TWsEvent* WsEvent; + const TPointerEventData* OtherEvent; + }; + +#endif //__MULTIPTRCLICK_H__ diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/t_capability/group/t_wservcapcheck_helium.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/t_capability/group/t_wservcapcheck_helium.pkg Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,37 @@ +; Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +; All rights reserved. +; This component and the accompanying materials are made available +; under the terms of "Eclipse Public License v1.0" +; which accompanies this distribution, and is available +; at the URL "http://www.eclipse.org/legal/epl-v10.html". +; +; Initial Contributors: +; Nokia Corporation - initial contribution. +; +; Contributors: +; +; Description: +; +;File: bitgdi.pkg; +; +;*Languages +&EN +; +;*Standard SIS file header. This section specifies the package name, +;application UID, and version/build numbers. Add the package TYPE here if needed. +#{"TWServCapCheck"},(0x101FB3E8),1,0,1; +; + +;*Unique (Non-Localized) Vendor name +;This is used in combination with signing to prevent the unauthroized +;upgrade of a a package by someone other than the rightful vendor. +:"Nokia" + +;*Localized Vendor Name +;This specifies the localized vendor name(s) corresponding to language(s). +%{"Nokia Test EN"} + +;*Files To Copy... + +"..\scripts\graphics-wserv-capcheck-tsizemode.script"-"c:\graphics\graphics-wserv-capcheck-tsizemode.script" + diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/t_genericplugin/data/ini/wsini_vasco_genericplugin.ini Binary file windowing/windowserver/test/t_genericplugin/data/ini/wsini_vasco_genericplugin.ini has changed diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/t_genericplugin/group/bld.inf --- a/windowing/windowserver/test/t_genericplugin/group/bld.inf Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/test/t_genericplugin/group/bld.inf Wed Jun 23 19:41:15 2010 +0300 @@ -33,6 +33,8 @@ ../data/ini/wsini_nga.ini z:/wstest/genericplugin/wsini_nga.ini +../data/ini/wsini_vasco_genericplugin.ini z:/wstest/genericplugin/wsini_vasco_genericplugin.ini + ../data/ini/wsini_nga_onescreen.ini z:/wstest/genericplugin/wsini_nga_onescreen.ini ../data/ini/wsini_nonnga.ini z:/wstest/genericplugin/wsini_nonnga.ini diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/t_genericplugin/group/t_wservgenericplugin_helium.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/t_genericplugin/group/t_wservgenericplugin_helium.pkg Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,38 @@ +; Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +; All rights reserved. +; This component and the accompanying materials are made available +; under the terms of "Eclipse Public License v1.0" +; which accompanies this distribution, and is available +; at the URL "http://www.eclipse.org/legal/epl-v10.html". +; +; Initial Contributors: +; Nokia Corporation - initial contribution. +; +; Contributors: +; +; Description: +; +;File: bitgdi.pkg; +; +;*Languages +&EN +; +;*Standard SIS file header. This section specifies the package name, +;application UID, and version/build numbers. Add the package TYPE here if needed. +#{"TWservGenericPlugin"},(0x101FB3E8),1,0,1; +; + +;*Unique (Non-Localized) Vendor name +;This is used in combination with signing to prevent the unauthroized +;upgrade of a a package by someone other than the rightful vendor. +:"Nokia" + +;*Localized Vendor Name +;This specifies the localized vendor name(s) corresponding to language(s). +%{"Nokia Test EN"} + +;*Files To Copy... + +"..\scripts\graphics-wserv-genericplugin-load-nga.script"-"c:\wstest\genericplugin\graphics-wserv-genericplugin-load-nga.script" +;"..\scripts\graphics-wserv-genericplugin-load-nonnga.script"-"c:\wstest\genericplugin\graphics-wserv-genericplugin-load-nonnga.script" + diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/t_genericplugin/rom/t_wservgenericplugin.iby --- a/windowing/windowserver/test/t_genericplugin/rom/t_wservgenericplugin.iby Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/test/t_genericplugin/rom/t_wservgenericplugin.iby Wed Jun 23 19:41:15 2010 +0300 @@ -18,6 +18,9 @@ #if (!defined __T_WSERV_GENERICPLUGIN_IBY__) #define __T_WSERV_GENERICPLUGIN_IBY__ +#include +#define WSERV_TEST_WSINI WSERV_TEST_WSINI_GENERICPLUGIN + #include // wserv testexecute server diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/t_integ/group/bld.inf --- a/windowing/windowserver/test/t_integ/group/bld.inf Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/test/t_integ/group/bld.inf Wed Jun 23 19:41:15 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -100,15 +100,15 @@ ../data/ini/wsini_wsgcesurfwin_emulator_color16ma_changetracking.ini /epoc32/release/winscw/urel/z/graphics/wsini_wsgcesurfwin_emulator_color16ma_changetracking.ini PRJ_TESTMMPFILES -t_app1.mmp -t_dsaapp.mmp +//Requires Techview - t_app1.mmp +//Requires Techview - t_dsaapp.mmp t_inidata.mmp t_perfdata.mmp -t_pseudoapp.mmp -t_pseudoapp1.mmp -t_fpsapp.mmp -t_pseudoappengine.mmp -t_pseudoapppopupwindow.mmp +//Requires Techview - t_pseudoapp.mmp +//Requires Techview - t_pseudoapp1.mmp +//Requires Techview - t_fpsapp.mmp +//Requires Techview - t_pseudoappengine.mmp +//Requires Techview - t_pseudoapppopupwindow.mmp t_testsurfacerasterizer.mmp t_winutils.mmp t_wservintegserver.mmp diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/t_integ/group/t_wservinteg_helium.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/t_integ/group/t_wservinteg_helium.pkg Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,46 @@ +; Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +; All rights reserved. +; This component and the accompanying materials are made available +; under the terms of "Eclipse Public License v1.0" +; which accompanies this distribution, and is available +; at the URL "http://www.eclipse.org/legal/epl-v10.html". +; +; Initial Contributors: +; Nokia Corporation - initial contribution. +; +; Contributors: +; +; Description: +; +;File: bitgdi.pkg; +; +;*Languages +&EN +; +;*Standard SIS file header. This section specifies the package name, +;application UID, and version/build numbers. Add the package TYPE here if needed. +#{"TWservInteg"},(0x101FB3E8),1,0,1; +; + +;*Unique (Non-Localized) Vendor name +;This is used in combination with signing to prevent the unauthroized +;upgrade of a a package by someone other than the rightful vendor. +:"Nokia" + +;*Localized Vendor Name +;This specifies the localized vendor name(s) corresponding to language(s). +%{"Nokia Test EN"} + +;*Files To Copy... + +"\epoc32\data\z\graphics\setup-graphics-wserv-integ.script"-"c:\graphics\setup-graphics-wserv-integ.script" +"\epoc32\data\z\graphics\graphics-wserv-integ-basic.script"-"c:\graphics\graphics-wserv-integ-basic.script" +"\epoc32\data\z\graphics\graphics-wserv-integ-surface1.script"-"c:\graphics\graphics-wserv-integ-surface1.script" +"\epoc32\data\z\graphics\graphics-wserv-integ-surface2.script"-"c:\graphics\graphics-wserv-integ-surface2.script" +"\epoc32\data\z\graphics\graphics-wserv-integ-surface3.script"-"c:\graphics\graphics-wserv-integ-surface3.script" +"\epoc32\data\z\graphics\graphics-wserv-integ-surface4.script"-"c:\graphics\graphics-wserv-integ-surface4.script" +"\epoc32\data\z\graphics\graphics-wserv-integ-surface5.script"-"c:\graphics\graphics-wserv-integ-surface5.script" +"\epoc32\data\z\graphics\graphics-wserv-integ-dsa.script"-"c:\graphics\graphics-wserv-integ-dsa.script" +"\epoc32\data\z\graphics\graphics-wserv-integ-surface-screenrotation.script"-"c:\graphics\graphics-wserv-integ-surface-screenrotation.script" +"\epoc32\data\z\graphics\graphics-wserv-integ-surface-multiplescreens.script"-"c:\graphics\graphics-wserv-integ-surface-multiplescreens.script" + diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/t_ratelimiter/data/wsini_vasco_ratelimiter.ini Binary file windowing/windowserver/test/t_ratelimiter/data/wsini_vasco_ratelimiter.ini has changed diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/t_ratelimiter/group/bld.inf --- a/windowing/windowserver/test/t_ratelimiter/group/bld.inf Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/test/t_ratelimiter/group/bld.inf Wed Jun 23 19:41:15 2010 +0300 @@ -26,7 +26,10 @@ ../data/epoc.ini z:/wstest/ratelimiter/epoc.ini ../data/epoc_singlescreen.ini z:/wstest/ratelimiter/epoc_singlescreen.ini + ../data/wsini.ini z:/wstest/ratelimiter/wsini.ini +../data/wsini_vasco_ratelimiter.ini z:/wstest/ratelimiter/wsini_vasco_ratelimiter.ini + ../data/wsini_changetracking.ini z:/wstest/ratelimiter/wsini_changetracking.ini ../data/wsini_hw_singlescreen.ini z:/wstest/ratelimiter/wsini_hw_singlescreen.ini ../data/wsini_hw_multiscreen.ini z:/wstest/ratelimiter/wsini_hw_multiscreen.ini diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/t_ratelimiter/group/t_ratelimiter_helium.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/t_ratelimiter/group/t_ratelimiter_helium.pkg Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,37 @@ +; Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +; All rights reserved. +; This component and the accompanying materials are made available +; under the terms of "Eclipse Public License v1.0" +; which accompanies this distribution, and is available +; at the URL "http://www.eclipse.org/legal/epl-v10.html". +; +; Initial Contributors: +; Nokia Corporation - initial contribution. +; +; Contributors: +; +; Description: +; +;File: bitgdi.pkg; +; +;*Languages +&EN +; +;*Standard SIS file header. This section specifies the package name, +;application UID, and version/build numbers. Add the package TYPE here if needed. +#{"BitGDITest"},(0x101FB3E8),1,0,1; +; + +;*Unique (Non-Localized) Vendor name +;This is used in combination with signing to prevent the unauthroized +;upgrade of a a package by someone other than the rightful vendor. +:"Nokia" + +;*Localized Vendor Name +;This specifies the localized vendor name(s) corresponding to language(s). +%{"Nokia Test EN"} + +;*Files To Copy... + +"..\scripts\graphics-wserv-ratelimiter-test.script"-"c:\wstest\ratelimiter\graphics-wserv-ratelimiter-test.script" + diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/t_ratelimiter/rom/t_ratelimiter.iby --- a/windowing/windowserver/test/t_ratelimiter/rom/t_ratelimiter.iby Fri Jun 11 14:58:47 2010 +0300 +++ b/windowing/windowserver/test/t_ratelimiter/rom/t_ratelimiter.iby Wed Jun 23 19:41:15 2010 +0300 @@ -16,6 +16,9 @@ #ifndef __T_RATELIMITER_IBY__ #define __T_RATELIMITER_IBY__ +#include +#define WSERV_TEST_WSINI WSERV_TEST_WSINI_RATELIMITER + #include // wserv testexecute server diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/t_stress/group/twservstresstest_helium.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/t_stress/group/twservstresstest_helium.pkg Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,39 @@ +; Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +; All rights reserved. +; This component and the accompanying materials are made available +; under the terms of "Eclipse Public License v1.0" +; which accompanies this distribution, and is available +; at the URL "http://www.eclipse.org/legal/epl-v10.html". +; +; Initial Contributors: +; Nokia Corporation - initial contribution. +; +; Contributors: +; +; Description: +; +;File: bitgdi.pkg; +; +;*Languages +&EN +; +;*Standard SIS file header. This section specifies the package name, +;application UID, and version/build numbers. Add the package TYPE here if needed. +#{"TWservStress"},(0x101FB3E8),1,0,1; +; + +;*Unique (Non-Localized) Vendor name +;This is used in combination with signing to prevent the unauthroized +;upgrade of a a package by someone other than the rightful vendor. +:"Nokia" + +;*Localized Vendor Name +;This specifies the localized vendor name(s) corresponding to language(s). +%{"Nokia Test EN"} + +;*Files To Copy... + +;// script files +"..\scripts\wservstresstest.script"-"c:\wstest\wservstresstest.script" +"..\scripts\wservstresslog.script"-"c:\wstest\wservstresslog.script" + diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/t_wdp/group/t_wdp_helium.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/t_wdp/group/t_wdp_helium.pkg Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,37 @@ +; Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +; All rights reserved. +; This component and the accompanying materials are made available +; under the terms of "Eclipse Public License v1.0" +; which accompanies this distribution, and is available +; at the URL "http://www.eclipse.org/legal/epl-v10.html". +; +; Initial Contributors: +; Nokia Corporation - initial contribution. +; +; Contributors: +; +; Description: +; +;File: bitgdi.pkg; +; +;*Languages +&EN +; +;*Standard SIS file header. This section specifies the package name, +;application UID, and version/build numbers. Add the package TYPE here if needed. +#{"TWDP"},(0x101FB3E8),1,0,1; +; + +;*Unique (Non-Localized) Vendor name +;This is used in combination with signing to prevent the unauthroized +;upgrade of a a package by someone other than the rightful vendor. +:"Nokia" + +;*Localized Vendor Name +;This specifies the localized vendor name(s) corresponding to language(s). +%{"Nokia Test EN"} + +;*Files To Copy... + +"..\scripts\graphics-wserv-wdp-test.script"-"c:\wstest\twdp\graphics-wserv-wdp-test.script" + diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tanim/ANIM.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tanim/ANIM.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,438 @@ +// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Test code to tun ANIMDLL.DLL +// +// + +#include +#include +#include +#include "../tlib/testbase.h" +#include "TANIM.H" +#include "ANIMDLL.H" + +#define NONEXISTENT_DLL_NAME _L("Z:\\NONEXISTENT.DLL") +#define ANIM_BITMAP _L("Z:\\WSTEST\\TANIM.MBM") +#define ANIM_DLL_NAME _L("ANIDLL.DLL") + +enum TAnimPanic + { + EAnimPanicBadLoadFailed, + }; + +class CTAnimClient; + +class TestAnim : public RAnim + { +public: + TestAnim(RAnimDll &aDll); + TInt Construct(RWindowBase &aWin,const TPoint &aPos,CFbsBitmap *aBit1,CFbsBitmap *aBit2,CFbsBitmap *aMask,TInt aInterval, CFbsFont *aFont); + void Set(const TPoint &aPos, TInt aInterval); + void TextPos(const TPoint &aPos); + void SetPolyRectL(const TRect &aRect); + void ToggleMask(); + }; + +class CTAnimWindow2 : public CTBlankWindow + { +public: + CTAnimWindow2(RAnimDll &aAnimDll); + ~CTAnimWindow2(); + void ConstructL(CTWinBase &parent, const TPoint &aPos, const TSize &aSize); + void ConstructExtLD(CTWinBase &aParent, const TPoint &aPos, const TSize &aSize); +private: + TestAnim iAnim; + CFbsBitmap iAnimBitmap1; + CFbsBitmap iAnimBitmap2; + }; + +class CTAnimWindow1 : public CTTitledWindow + { +public: + CTAnimWindow1(RAnimDll &aAnimDll); + ~CTAnimWindow1(); + void ConstructL(CTWinBase &parent); + void Draw(); + void AdjustAnimRect(TInt xMove,TInt yMove,TInt modifiers); + void AdjustPolyRectL(TInt xMove,TInt yMove,TInt modifiers); + void ToggleMask(); + TInt SubType(); +private: + TestAnim iAnim; + TPoint iAnimPos; + TRect iAnimPolyRect; + CFbsBitmap iAnimBitmap1; + CFbsBitmap iAnimBitmap2; + CFbsBitmap iMask; + }; + +class CTAnimWindowGroup : public CTWindowGroup + { +public: + CTAnimWindowGroup(CTClient *aClient); + void CursorKeyL(TInt xMove,TInt yMove,TInt modifiers); + void KeyL(const TKeyEvent &aKey, const TTime &aTime); + TInt iCursorMode; + }; + +class CTAnimClient : public CTClient + { +public: + CTAnimClient(); + ~CTAnimClient(); + void ConstructL(); + void KeyL(const TKeyEvent &aKey,const TTime &aTime); + void ExitL(); + void ErrorTests(); + CTBaseWin *CreateTestWindowL(TPoint pos,TSize size,CTWinBase *parent, TInt aType); +private: + TInt iNum; + RAnimDll iAnimDll; + }; + +const TInt Xmove=8; +const TInt Ymove=6; + +void AnimPanic(TInt aPanic) + { + User::Panic(_L("ANIM"),aPanic); + } + +// +// Anim class +// + +TestAnim::TestAnim(RAnimDll &aDll) : RAnim(aDll) + { + } + +TInt TestAnim::Construct(RWindowBase &aWin, const TPoint &aPos, CFbsBitmap *aBit1,CFbsBitmap *aBit2,CFbsBitmap *aMask, TInt aInterval, CFbsFont *aFont) + { + TPckgBuf params; + params().pos=aPos; + params().interval=aInterval; + params().bit1=aBit1->Handle(); + params().bit2=aBit2->Handle(); + params().mask=aMask->Handle(); + params().font=aFont->Handle(); + return(RAnim::Construct(aWin,0,params)); + } + +void TestAnim::Set(const TPoint &aPos, TInt aInterval) + { + TPckgBuf params; + params().pos=aPos; + params().interval=aInterval; + Command(EADllOpcodeMove,params); + } + +void TestAnim::TextPos(const TPoint &aPos) + { + TPckgBuf params; + params()=aPos; + Command(EADllTextPos,params); + } + +void TestAnim::SetPolyRectL(const TRect &aRect) + { + TPckgC params(aRect); + User::LeaveIfError(CommandReply(EADllOpcodePolyLineRect,params)); + } + +void TestAnim::ToggleMask() + { + Command(EADllToggleBitmapMask); + } + +// +// Individual window sub-classes +// + +CTAnimWindow1::CTAnimWindow1(RAnimDll &aAnimDll) : CTTitledWindow(), + iAnim(aAnimDll) + { + } + +CTAnimWindow1::~CTAnimWindow1() + { + iAnim.Close(); + } + +void CTAnimWindow1::ConstructL(CTWinBase &parent) + { + CTTitledWindow::ConstructL(parent); + User::LeaveIfError(iAnimBitmap1.Load(ANIM_BITMAP,EMbmTanimAnim1)); + User::LeaveIfError(iAnimBitmap2.Load(ANIM_BITMAP,EMbmTanimAnim2)); + User::LeaveIfError(iMask.Load(ANIM_BITMAP,EMbmTanimMask)); + iAnimPos=TPoint(10,10); + User::LeaveIfError(iAnim.Construct(iWin, iAnimPos,&iAnimBitmap1,&iAnimBitmap2,&iMask,1,iFont)); + iAnimPolyRect=TRect(TPoint(10,40),TSize(50,50)); + iAnim.SetPolyRectL(iAnimPolyRect); + iAnim.TextPos(TPoint(20,50)); + } + +void CTAnimWindow1::Draw() + { + TInt i; + + CTTitledWindow::Draw(); + iGc->SetPenColor(TRgb::Gray16(8)); + TInt hgt=iSize.iHeight-iTitleHeight; + for(i=0;iDrawLine(TPoint(i,iTitleHeight),TPoint(iSize.iWidth,iTitleHeight+(hgt*i)/iSize.iWidth)); + iGc->DrawLine(TPoint(iSize.iWidth-i,iTitleHeight+hgt),TPoint(iSize.iWidth,iTitleHeight+(hgt*i)/iSize.iWidth)); + iGc->DrawLine(TPoint(iSize.iWidth-i,iTitleHeight+hgt),TPoint(0,iTitleHeight+hgt-(hgt*i)/iSize.iWidth)); + iGc->DrawLine(TPoint(i,iTitleHeight),TPoint(0,iTitleHeight+hgt-(hgt*i)/iSize.iWidth)); + } + } + +void CTAnimWindow1::AdjustAnimRect(TInt xMove,TInt yMove,TInt modifiers) + { + if (modifiers&EModifierCtrl) // 4 times the movement + { + xMove<<=2; + yMove<<=2; + } + iAnimPos+=TPoint(xMove,yMove); + iAnim.Set(iAnimPos,5); + } + +void CTAnimWindow1::AdjustPolyRectL(TInt xMove,TInt yMove,TInt modifiers) + { + if (modifiers&EModifierCtrl) // 4 times the movement + { + xMove<<=2; + yMove<<=2; + } + if (modifiers&EModifierShift) // 4 times the movement + iAnimPolyRect.Grow(xMove,yMove); + else + iAnimPolyRect.Move(TPoint(xMove,yMove)); + iAnim.SetPolyRectL(iAnimPolyRect); + } + +void CTAnimWindow1::ToggleMask() + { + iAnim.ToggleMask(); + } + +TInt CTAnimWindow1::SubType() + { + return(69); + } + +// CTAnimWindow2 // + +CTAnimWindow2::CTAnimWindow2(RAnimDll &aAnimDll) : CTBlankWindow(), + iAnim(aAnimDll) + { + } + +CTAnimWindow2::~CTAnimWindow2() + { + iAnim.Close(); + } + +void CTAnimWindow2::ConstructL(CTWinBase &parent, const TPoint &aPos, const TSize &aSize) + { + CTBlankWindow::ConstructL(parent); + iWin.SetColor(TRgb(128,128,128)); + iWin.SetVisible(EFalse); + SetExt(aPos,aSize); + iWin.Activate(); + User::LeaveIfError(iAnimBitmap1.Load(ANIM_BITMAP,EMbmTanimAnim1)); + User::LeaveIfError(iAnimBitmap2.Load(ANIM_BITMAP,EMbmTanimAnim2)); + User::LeaveIfError(iAnim.Construct(iWin, TPoint(10,10), &iAnimBitmap1, &iAnimBitmap2, &iAnimBitmap1, 1, iFont)); + iWin.SetVisible(ETrue); + } + +void CTAnimWindow2::ConstructExtLD(CTWinBase &aParent, const TPoint &aPos, const TSize &aSize) +// +// Call ConstructL, SetExt and either of these fail destroy this and leave +// + { + TRAPD(err,ConstructL(aParent, aPos, aSize)); + if (err!=KErrNone) + { + delete this; + User::Leave(err); + } + } + +// +// End of CTAnimWindow class // +// + +CTAnimWindowGroup::CTAnimWindowGroup(CTClient *aClient) : CTWindowGroup(aClient) + { + } + +void CTAnimWindowGroup::CursorKeyL(TInt xMove,TInt yMove,TInt modifiers) + { + if (iCursorMode==0) + iCurWin->AdjustSizeL(xMove,yMove,modifiers); + else if (iCurWin->SubType()==69) + { + if (iCursorMode==1) + ((CTAnimWindow1 *)iCurWin)->AdjustAnimRect(xMove,yMove,modifiers); + else + ((CTAnimWindow1 *)iCurWin)->AdjustPolyRectL(xMove,yMove,modifiers); + } + } + +void CTAnimWindowGroup::KeyL(const TKeyEvent &aKey,const TTime &aTime) + { + if (aKey.iModifiers&EModifierCtrl) + { + TInt type=0; + switch(aKey.iCode) + { + case 1: + type=1; + break; + case 2: + type=2; + break; + } + if (type!=0) + { + TPoint pos; + TSize size; + pos.iX=iCurWin->Size().iWidth>>2; + pos.iY=iCurWin->Size().iHeight>>2; + size.iWidth=iCurWin->Size().iWidth>>1; + size.iHeight=iCurWin->Size().iHeight>>1; + SetCurrentWindow(((CTAnimClient *)iClient)->CreateTestWindowL(pos,size,iCurWin,type)); + return; + } + } + if (aKey.iModifiers&EModifierFunc) + { + switch(aKey.iCode) + { + case 'x': + ((CTAnimClient *)iClient)->ExitL(); + break; + } + } + else switch(aKey.iCode) + { + case ' ': + iCursorMode=(iCursorMode+1)%3; + break; + case 8: + CTWin::Delete(iCurWin); + break; + case 9: + if (aKey.iModifiers&EModifierShift) + SetCurrentWindow(iCurWin->Prev()); + else + SetCurrentWindow(iCurWin->Next()); + break; + case 13: + if (iCurWin->SubType()==69) + ((CTAnimWindow1 *)iCurWin)->ToggleMask(); + break; + case EKeyLeftArrow: + CursorKeyL(-Xmove,0,aKey.iModifiers); + break; + case EKeyRightArrow: + CursorKeyL(Xmove,0,aKey.iModifiers); + break; + case EKeyUpArrow: + CursorKeyL(0,-Ymove,aKey.iModifiers); + break; + case EKeyDownArrow: + CursorKeyL(0,Ymove,aKey.iModifiers); + break; + default: + iCurWin->WinKeyL(aKey,aTime); + break; + } + } + +// + +CTAnimClient::CTAnimClient() + { + } + +CTBaseWin *CTAnimClient::CreateTestWindowL(TPoint pos,TSize size,CTWinBase *parent, TInt type) + { + CTBaseWin *win; + if (type==1) + { + win=new(ELeave) CTAnimWindow1(iAnimDll); + win->ConstructExtLD(*parent,pos,size); + win->Activate(); + } + else + { + win=new(ELeave) CTAnimWindow2(iAnimDll); + win->ConstructExtLD(*parent,pos,size); + } + win->AssignGC(*iGc); + return(win); + } + +CTAnimClient::~CTAnimClient() + { + DestroyWindows(); + iAnimDll.Close(); + } + +void CTAnimClient::ErrorTests() + { + RAnimDll animDll=RAnimDll(iWs); + if (animDll.Load(NONEXISTENT_DLL_NAME)!=KErrNotFound) + AnimPanic(EAnimPanicBadLoadFailed); + animDll.Close(); // Close should be harmless, but unnecassary + RAnimDll animDll2=RAnimDll(iWs); + if (animDll2.Load(NONEXISTENT_DLL_NAME)!=KErrNotFound) + AnimPanic(EAnimPanicBadLoadFailed); + } + +void CTAnimClient::ConstructL() + { + CTClient::ConstructL(); + + iGroup=new(ELeave) CTAnimWindowGroup(this); + iGroup->ConstructL(); + + ErrorTests(); + + iAnimDll=RAnimDll(iWs); + User::LeaveIfError(iAnimDll.Load(ANIM_DLL_NAME)); + + CreateTestWindowL(TPoint(30,20),TSize(220,140),iGroup, 1); + CreateTestWindowL(TPoint(260,60),TSize(60,40),iGroup, 2); + iGroup->SetCurrentWindow(iGroup->Child()); + } + +void CTAnimClient::ExitL() + { + CActiveScheduler::Stop(); + User::Leave(0); // Signals RunL not to do another Request() + } + +GLDEF_C CTClient *CreateClientL() + { + return(new(ELeave) CTAnimClient()); + } + +GLDEF_C TInt E32Main() + { + return(TestLibStartUp(CreateClientL)); + } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tanim/ANIM1.PBM Binary file windowing/windowserver/test/tanim/ANIM1.PBM has changed diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tanim/ANIM2.PBM Binary file windowing/windowserver/test/tanim/ANIM2.PBM has changed diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tanim/ANIMDLL.H --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tanim/ANIMDLL.H Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,34 @@ +// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Header defs for ANIMDLL +// +// + +struct CTAParams + { + TPoint pos; + TInt interval; + TInt bit1; + TInt bit2; + TInt mask; + TInt font; + }; + +enum AnimDllOpcodes + { + EADllOpcodeMove, + EADllOpcodePolyLineRect, + EADllToggleBitmapMask, + EADllTextPos, + }; diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tanim/MASK.PBM Binary file windowing/windowserver/test/tanim/MASK.PBM has changed diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tanim/TANIM.H --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tanim/TANIM.H Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,23 @@ +// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Generated by BitmapCompiler +// +// + +enum TMbmTanim + { + EMbmTanimAnim1, + EMbmTanimAnim2, + EMbmTanimMask + }; diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tanim/TANIMDLL.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tanim/TANIMDLL.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,317 @@ +// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Test Animated DLL +// +// + +#include +#include +#include +#include +#include "ANIMDLL.H" + +#define ANIM_TEST_TEXT _L("Testing 123") + +class CTestAnim : public CWindowAnim + { + enum {ENumPolyPoints=9}; +public: + ~CTestAnim(); + virtual void ConstructL(TAny *aArgs, TBool aHasFocus); + virtual void Animate(TDateTime *aDateTime); + virtual void Redraw(); + virtual void Command(TInt aOpcode, TAny *aArgs); + virtual TInt CommandReplyL(TInt aOpcode, TAny *aArgs); + void SetPolyList(const TRect &aRect); + void DrawPolyLine(); + void DrawBitmap(); + void DrawText(); + void TweakPolyList(TInt aState); + void FocusChanged(TBool aState); + void InvalidateText(); + void InvalidateBitmap(); + //Pure virtual function from MEventHandler + virtual TBool OfferRawEvent(const TRawEvent &aRawEvent); +private: + void AppendTime(TDes& aTimeText,const TTime& aTime) const; +private: + TPoint iPos; + TSize iSize; + TInt iColor; + TBool iMasked; + TRect iPolyRect; + TInt iPolyState; + TInt iWiggleSize; + TPoint iTextPos; + TBool iHasFocus; + CArrayFixFlat *iPolyList; + CFbsBitmap iBitmap1; + CFbsBitmap iBitmap2; + CFbsBitmap iMask; + CFbsFont *iFont; + }; + +class CTestAnimDll : public CAnimDll + { +public: + CAnim *CreateInstanceL(TInt aType); +private: + }; + +/*#if defined(__WINS__) +#pragma data_seg(".E32_UID") +__WINS_UID(0, KWservAnimDllUidValue, 0) +#pragma data_seg() +#endif*/ + +EXPORT_C CAnimDll *CreateCAnimDllL() + { + return(new(ELeave) CTestAnimDll()); + } + +// Instance code // + +void CTestAnim::Animate(TDateTime *) + { + if (!iWindowFunctions->IsHidden()) + { + iWindowFunctions->ActivateGc(); + if (iPolyList) + DrawPolyLine(); + } + if (iPolyList) + { + iPolyState=(iPolyState+1)%4; + TweakPolyList(iPolyState); + } + if (!iWindowFunctions->IsHidden()) + { + if (iPolyList) + DrawPolyLine(); + DrawText(); + DrawBitmap(); + } + iColor=(iColor+16)&0xFF; + } + +void CTestAnim::DrawPolyLine() + { + iGc->SetDrawMode(CGraphicsContext::EDrawModeXOR); + iGc->SetPenColor(TRgb(255,255,255)); + iGc->DrawPolyLine(iPolyList); + iGc->SetDrawMode(CGraphicsContext::EDrawModePEN); + iGc->SetPenColor(TRgb(0,0,0)); + } + +void CTestAnim::DrawBitmap() + { + iGc->SetClippingRegion(TRegionFix<1>(TRect(iPos,iSize))); + CFbsBitmap *bitmap=iFunctions->FlashStateOn() ? &iBitmap1 : &iBitmap2; + if (iMasked) + iGc->BitBltMasked(iPos,bitmap, TRect(iSize), &iMask,EFalse); + else + iGc->BitBlt(iPos,bitmap); + iGc->CancelClippingRegion(); + } + +void CTestAnim::AppendTime(TDes& aTimeText,const TTime& aTime) const + { + _LIT(TimeFormat,"%:0%H%:1%T%:2%S"); + TRAPD(err,aTime.FormatL(aTimeText,TimeFormat)); + if (err!=KErrNone) + { + _LIT(DummyTime,"######"); + aTimeText.Append(DummyTime); + } + } + +void CTestAnim::DrawText() + { + if (iHasFocus) + { + iGc->UseFont(iFont); + TBuf<0x20> timebuf; + TTime time(iFunctions->SystemTime()); + AppendTime(timebuf,time); + TRect rect(iTextPos.iX,iTextPos.iY-iFont->AscentInPixels(),iTextPos.iX+iFont->TextWidthInPixels(timebuf),iTextPos.iY-iFont->AscentInPixels()+iFont->HeightInPixels()); + iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + iGc->DrawText(timebuf,rect,iFont->AscentInPixels()); + time.UniversalTime(); + AppendTime(timebuf,time); + rect.Move(0,iFont->HeightInPixels()); + iGc->DrawText(timebuf,rect,iFont->AscentInPixels()); + } + } + +void CTestAnim::Redraw() + { + DrawText(); + DrawBitmap(); + if (iPolyList) + DrawPolyLine(); + } + +void CTestAnim::ConstructL(TAny *aArgs, TBool aHasFocus) + { + iHasFocus=aHasFocus; + iPos=((CTAParams *)aArgs)->pos; + iFunctions->SetInterval(((CTAParams *)aArgs)->interval); + if (iBitmap1.Duplicate(((CTAParams *)aArgs)->bit1)!=KErrNone || + iBitmap2.Duplicate(((CTAParams *)aArgs)->bit2)!=KErrNone || + iMask.Duplicate(((CTAParams *)aArgs)->mask)!=KErrNone) + iFunctions->Panic(); + iSize.iWidth=Min(iBitmap1.SizeInPixels().iWidth,iBitmap2.SizeInPixels().iWidth); + iSize.iHeight=Min(iBitmap1.SizeInPixels().iHeight,iBitmap2.SizeInPixels().iHeight); + iWiggleSize=10; + iFont=iFunctions->DuplicateFontL(((CTAParams *)aArgs)->font); + } + +void CTestAnim::SetPolyList(const TRect &aRect) + { + iPolyRect=aRect; + TSize halfsize=aRect.Size(); + halfsize.iWidth>>=1; + halfsize.iHeight>>=1; + (*iPolyList)[0]=aRect.iTl; + (*iPolyList)[1]=TPoint(aRect.iTl.iX+iWiggleSize,aRect.iTl.iY+halfsize.iHeight); + (*iPolyList)[2]=TPoint(aRect.iTl.iX,aRect.iBr.iY); + (*iPolyList)[3]=TPoint(aRect.iTl.iX+halfsize.iWidth,aRect.iBr.iY-iWiggleSize); + (*iPolyList)[4]=aRect.iBr; + (*iPolyList)[5]=TPoint(aRect.iBr.iX-iWiggleSize,aRect.iTl.iY+halfsize.iHeight); + (*iPolyList)[6]=TPoint(aRect.iBr.iX,aRect.iTl.iY); + (*iPolyList)[7]=TPoint(aRect.iTl.iX+halfsize.iWidth,aRect.iTl.iY+iWiggleSize); + (*iPolyList)[8]=aRect.iTl; + TweakPolyList(iPolyState); + } + +void CTestAnim::TweakPolyList(TInt aState) + { + TSize halfsize=iPolyRect.Size(); + halfsize.iWidth>>=1; + halfsize.iHeight>>=1; + switch(aState) + { + case 0: + (*iPolyList)[7]=TPoint(iPolyRect.iTl.iX+halfsize.iWidth,iPolyRect.iTl.iY+iWiggleSize); + (*iPolyList)[1]=TPoint(iPolyRect.iTl.iX,iPolyRect.iTl.iY+halfsize.iHeight); + break; + case 1: + (*iPolyList)[1]=TPoint(iPolyRect.iTl.iX+iWiggleSize,iPolyRect.iTl.iY+halfsize.iHeight); + (*iPolyList)[3]=TPoint(iPolyRect.iTl.iX+halfsize.iWidth,iPolyRect.iBr.iY); + break; + case 2: + (*iPolyList)[3]=TPoint(iPolyRect.iTl.iX+halfsize.iWidth,iPolyRect.iBr.iY-iWiggleSize); + (*iPolyList)[5]=TPoint(iPolyRect.iBr.iX,iPolyRect.iTl.iY+halfsize.iHeight); + break; + case 3: + (*iPolyList)[5]=TPoint(iPolyRect.iBr.iX-iWiggleSize,iPolyRect.iTl.iY+halfsize.iHeight); + (*iPolyList)[7]=TPoint(iPolyRect.iTl.iX+halfsize.iWidth,iPolyRect.iTl.iY); + break; + } + } + +void CTestAnim::InvalidateText() + { + TRect invalidate; + invalidate.iTl.iX=iTextPos.iX; + invalidate.iTl.iY=iTextPos.iY-iFont->AscentInPixels(); + invalidate.iBr.iX=iTextPos.iX+iFont->TextWidthInPixels(ANIM_TEST_TEXT); + invalidate.iBr.iY=iTextPos.iY+iFont->DescentInPixels(); + iWindowFunctions->Invalidate(invalidate); + } + +void CTestAnim::InvalidateBitmap() + { + iWindowFunctions->Invalidate(TRect(iPos,iSize)); + } + +void CTestAnim::Command(TInt aOpcode, TAny *aArgs) + { + switch(aOpcode) + { + case EADllOpcodeMove: + { + InvalidateBitmap(); + iPos=((CTAParams *)aArgs)->pos; + iWindowFunctions->ActivateGc(); + DrawBitmap(); + iFunctions->SetInterval(((CTAParams *)aArgs)->interval); + } + break; + case EADllTextPos: + { + InvalidateText(); + iTextPos=((CTAParams *)aArgs)->pos; + iWindowFunctions->ActivateGc(); + DrawText(); + } + break; + case EADllToggleBitmapMask: + iMasked=!iMasked; + InvalidateBitmap(); + break; + } + } + +TInt CTestAnim::CommandReplyL(TInt aOpcode, TAny *aArgs) + { + switch(aOpcode) + { + case EADllOpcodePolyLineRect: + iWindowFunctions->ActivateGc(); + if (!iPolyList) + { + iPolyList=new(ELeave) CArrayFixFlat(ENumPolyPoints); + TPoint zeropoint; + for(TInt i=0;iAppendL(zeropoint); + } + else + DrawPolyLine(); + SetPolyList(*((TRect *)aArgs)); + DrawPolyLine(); + break; + default: + iFunctions->Panic(); + } + return(KErrNone); + } + +CTestAnim::~CTestAnim() + { + delete iPolyList; + iFunctions->CloseFont(iFont); + } + +void CTestAnim::FocusChanged(TBool aNewState) + { + iHasFocus=aNewState; + InvalidateText(); + InvalidateBitmap(); + } + +TBool CTestAnim::OfferRawEvent(const TRawEvent &/*aRawEvent*/) + { + return EFalse; + } + +// DLL code // + +CAnim *CTestAnimDll::CreateInstanceL(TInt ) + { + return(new(ELeave) CTestAnim()); + } + +// Dummy E32Dll needed by E32 to build // + diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tanim/tanim.mbm Binary file windowing/windowserver/test/tanim/tanim.mbm has changed diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/AUTO.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/AUTO.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,2543 @@ +// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Automatically test the window server +// +// + + +#include +#include +#include +#include +#include "../tlib/testbase.h" +#include +#include "AUTO.H" + +LOCAL_D const TUint KPanicThreadHeapSize=0x8000; + +GLREF_C TInt ProcPriTestOtherProcess(TAny *aScreenNumber); +GLREF_C TInt ProcToKill(TAny *aScreenNumber); +GLREF_C TInt ProcDirect(TAny *aScreenNumber); +GLREF_C TInt ProcMultiDisplay(TAny *aScreenNumber); + +_LIT(Priority,"ProcPriTest"); +_LIT(ToKill,"ProcToKill"); +_LIT(Direct,"ProcDirect"); +_LIT(MultiDisplay,"ProcMultiDisplay"); + +CProcess::TInitialFunction CProcess::iFunctions[]= + { + TInitialFunction(Priority,ProcPriTestOtherProcess), + TInitialFunction(ToKill,ProcToKill), + TInitialFunction(Direct,ProcDirect), + TInitialFunction(MultiDisplay,ProcMultiDisplay) + }; + +GLDEF_D TestWindow *BaseWin; +GLDEF_D TestWindow *TestWin; +GLDEF_D TestClient *TheClient=NULL; +GLDEF_D CWindowGc *TheGc; +TInt CTestBase::iMaxGrays=0; +TInt CTestBase::iScreenNo=0; +TInt CTestBase::iMaxColors=0; +TInt CTestBase::iNumberTestsPass=0; +TInt CTestBase::iNumberTests=0; +TRect CTestBase::iNormalPointerCursorArea; +TPartialRedrawType CTestBase::iRedrawType=EPartialRedraw_Unknown; +TInt CTestBase::iNumberOfGrpWndsOnPrimaryScreenWithZeroPriority = 0; +TInt CTestDriver::iTestNum=0; + +GLDEF_D TInt TheTestResult=ETestPassed; // start with passed to anticipate empty test table + +const TInt KBorderWinWidth = 5; + +_LIT(Auto,"AUTO "); + +TInt64 TTestRects::iSeed=0; +TRect TTestRects::iList[]={ +// 0-5 + TRect(2,2,2,2), + TRect(2,2,2,2), + TRect(2,2,2,2), + TRect(2,2,2,2), + TRect(2,2,2,2), +// 5-13 + TRect(0,0,0,0), + TRect(2,0,2,0), + TRect(4,0,4,0), + TRect(0,2,0,2), + TRect(2,2,2,2), + TRect(4,2,4,2), + TRect(0,4,0,4), + TRect(2,4,2,4), + TRect(4,4,4,4), +// 13-22 + TRect(0,0,1,1), + TRect(1,0,3,1), + TRect(3,0,4,1), + TRect(0,1,1,3), + TRect(1,1,3,3), + TRect(3,1,4,3), + TRect(0,3,1,4), + TRect(1,3,3,4), + TRect(3,3,4,4), +// 23-31 + TRect(0,0,2,0), + TRect(2,0,4,0), + TRect(0,0,4,0), + TRect(0,2,2,2), + TRect(2,2,4,2), + TRect(0,2,4,2), + TRect(0,4,2,4), + TRect(2,4,4,4), + TRect(0,4,4,4), +// 32-40 + TRect(0,0,0,2), + TRect(0,2,0,4), + TRect(0,0,0,4), + TRect(2,0,2,2), + TRect(2,2,2,4), + TRect(2,0,2,4), + TRect(4,0,4,2), + TRect(4,2,4,4), + TRect(4,0,4,4), +// 41-44 + TRect(0,0,2,2), + TRect(2,0,4,2), + TRect(0,2,2,4), + TRect(2,2,4,4), +// 45-48 + TRect(0,0,3,3), + TRect(1,0,4,3), + TRect(0,1,3,4), + TRect(1,1,4,4), +// 49 + TRect(0,0,4,4), +// 40-53 + TRect(1,2,2,2), + TRect(2,2,3,2), + TRect(2,1,2,2), + TRect(2,2,3,2), +// 54-59 + TRect(1,2,3,2), + TRect(2,1,2,3), + TRect(1,1,2,2), + TRect(1,2,2,3), + TRect(2,2,3,3), + TRect(2,1,3,2), +// 60-63 + TRect(1,1,3,2), + TRect(1,1,2,3), + TRect(1,2,3,3), + TRect(2,1,3,3)}; + +#if defined(__WINS__) +void FindNonMatchingPixelL(TPoint aPt1,TPoint aPt2,TSize aSize) +// This function is purely for use when debugging to find the first non-matching pixel +// when a check of two on screen rects has failed. + { + HBufC8* buf1=HBufC8::NewMaxLC(2*aSize.iWidth); + HBufC8* buf2=HBufC8::NewMaxLC(2*aSize.iWidth); + TPtr8 ptr1=buf1->Des(); + TPtr8 ptr2=buf2->Des(); + TInt row=0; + TBool ret = true; + for (;rowiScreen->GetScanLine(ptr1,aPt1,aSize.iWidth,EColor64K); + TheClient->iScreen->GetScanLine(ptr2,aPt2,aSize.iWidth,EColor64K); + if (ptr1!=ptr2) + break; + ++aPt1.iY; + ++aPt2.iY; + } + TRgb color1,color2; + if (rowiScreen->GetPixel(color1,aPt1); + TheClient->iScreen->GetPixel(color2,aPt2); + if (color1!=color2) + { // Break here to find first pixel that didn't match. + TBuf<256> buf; + _LIT(KFindNonMatchingPixelFmt,"First non matching pixel (%d,%d)"); + buf.Format(KFindNonMatchingPixelFmt,col,row); + TheClient->iWs.LogMessage(buf); + break; + + } + ++aPt1.iX; + ++aPt2.iX; + } + } + CleanupStack::PopAndDestroy(2); + } + +void FindNonMatchingPixel(TPoint aPt1,TPoint aPt2,TSize aSize) + { + TRAPD(ignore,FindNonMatchingPixelL(aPt1,aPt2,aSize)); + } +#endif + +void AutoPanic(TInt aPanic) + { + User::Panic(_L("Auto"),aPanic); + } + +void CleanUpWindow(TAny *aWindow) + { + ((RWindowTreeNode *)aWindow)->Close(); + } + +void PushWindowL(RWindowTreeNode *aWindow) + { + CleanupStack::PushL(TCleanupItem(CleanUpWindow,aWindow)); + } + + +TBool OpacityAndAlphaSupportedL() + { + // If opacity is not implemented, EFalse will be returned + if(TransparencySupportedL()!=KErrNone) + return EFalse; + + const TRgb KTransparencyColor(0,0,0); + RWindow winb(TheClient->iWs); + CleanupClosePushL(winb); + RWindow wint(TheClient->iWs); + CleanupClosePushL(wint); + User::LeaveIfError(winb.Construct(*TheClient->iGroup->GroupWin(), ENullWsHandle)); + User::LeaveIfError(wint.Construct(*TheClient->iGroup->GroupWin(), ENullWsHandle)); + winb.SetExtent(TPoint(0,0), TSize(50,50)); + wint.SetExtent(TPoint(0,0), TSize(50,50)); + winb.SetRequiredDisplayMode(EColor256); + wint.SetRequiredDisplayMode(EColor256); + wint.SetTransparencyFactor(KTransparencyColor); + winb.SetBackgroundColor(TRgb(0,0,255)); + wint.SetBackgroundColor(TRgb(255,0,0)); + winb.Activate(); + wint.Activate(); + + wint.BeginRedraw(); + TheClient->iGc->Activate(wint); + TheClient->iGc->SetOpaque(ETrue); + TheClient->iGc->SetPenStyle(CGraphicsContext::ENullPen); + TheClient->iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + TheClient->iGc->SetBrushColor(TRgb(0,255,0)); + TheClient->iGc->DrawRect(TRect(TPoint(0,0), TSize(50,50))); + TheClient->iGc->SetOpaque(EFalse); + TheClient->iGc->Deactivate(); + wint.EndRedraw(); + TheClient->Flush(); + + // The window should be all green, if opacity is working, or all blue if it isn't. + // If the window has any other colour, then something has broken. + TRgb color; + TheClient->iScreen->GetPixel(color,TPoint(25,25)); + if (color.Red()>0 || ((color.Green()==0) == (color.Blue()==0))) + User::Leave(KErrGeneral); + TBool ret=(color.Green()>0); + + CleanupStack::PopAndDestroy(2,&winb); // wint + return ret; + } + +TInt TransparencySupportedL() + { + // Creates a window and enables alpha transparency, if this feature + // is not enabled, KErrNotSupported will be returned + RWindow win(TheClient->iWs); + User::LeaveIfError(win.Construct(*TheClient->iGroup->GroupWin(), ENullWsHandle)); + win.SetExtent(TPoint(0,0), TSize(50,50)); + TInt ret=win.SetTransparencyAlphaChannel(); + win.Close(); + return ret; + } + +TInt CheckScalingSupportedOrNot() + { + TBool scalingSupported=EFalse; + TSizeMode originalModeData=TheClient->iScreen->GetCurrentScreenModeAttributes(); + TSizeMode tempData=originalModeData; + tempData.iScreenScale=TSize(2,2); + TheClient->iScreen->SetCurrentScreenModeAttributes(tempData); + TSize scale=TheClient->iScreen->GetCurrentScreenModeScale(); + if (scale.iWidth==2 && scale.iHeight==2) + { + scalingSupported=ETrue; + } + TheClient->iScreen->SetCurrentScreenModeAttributes(originalModeData); + TheClient->Flush(); + return scalingSupported; + } + +TBool CheckNonZeroOriginsSupportedOrNot() + { + TBool nonZeroOriginsSupported=EFalse; + TSizeMode sizeMode1=TheClient->iScreen->GetCurrentScreenModeAttributes(); + TSizeMode sizeMode2=sizeMode1; + sizeMode2.iOrigin=TPoint(30,30); + TheClient->iScreen->SetCurrentScreenModeAttributes(sizeMode2); + TPoint origin=TheClient->iScreen->GetCurrentScreenModeScaledOrigin(); + if (origin.iX==30 && origin.iY==30) + { + nonZeroOriginsSupported=ETrue; + } + TheClient->iScreen->SetCurrentScreenModeAttributes(sizeMode1); + TheClient->Flush(); + return nonZeroOriginsSupported; + } + +TPoint PhysicalToLogical(TPoint aPhysicalPtMinusOrigin,TSize aScale) + { + TPoint logicalPt(aPhysicalPtMinusOrigin); + if (aScale.iWidth!=1) + { + logicalPt.iX=(logicalPt.iX>= 0 ? logicalPt.iX/aScale.iWidth : (logicalPt.iX-(aScale.iWidth-1))/aScale.iWidth); + } + if (aScale.iHeight!=1) + { + logicalPt.iY=(logicalPt.iY>= 0 ? logicalPt.iY/aScale.iHeight : (logicalPt.iY-(aScale.iHeight-1))/aScale.iHeight); + } + return logicalPt; + } + +// +// Log window, logs testing // +// + +LogWindow::LogWindow() : CTWin(), iTestTitle(KNullDesC), iSubTitle(KNullDesC), iMessage(KNullDesC) + {} + +void LogWindow::ConstructL(CTWinBase &parent) + { + CTWin::ConstructL(parent); + iTitleHeight=iFont->HeightInPixels()+4; + } + +void LogWindow::DrawSubTitle() + { + iGc->DrawText(iSubTitle, TRect(2,iTitleHeight*2,iSize.iWidth-2,iTitleHeight*3),iFont->AscentInPixels(), CGraphicsContext::ECenter); + } + +void LogWindow::DrawMessage() + { + iGc->DrawText(iMessage, TRect(1,iTitleHeight*4,iSize.iWidth-2,iTitleHeight*5),iFont->AscentInPixels(), CGraphicsContext::ECenter); + } + +void LogWindow::Draw() + { + iGc->SetPenColor(TRgb::Gray16(8)); + iGc->SetPenColor(TRgb::Gray16(0)); + DrawBorder(); + iGc->DrawLine(TPoint(0,iTitleHeight),TPoint(iSize.iWidth,iTitleHeight)); + iGc->DrawText(iTestTitle, TPoint((iSize.iWidth-iFont->TextWidthInPixels(iTestTitle))/2,iFont->AscentInPixels()+2)); + DrawSubTitle(); + DrawMessage(); + } + +/** +This function is not used at the moment but I leave it in in case I need it when I improve the logging in +the log window. +*/ +void LogWindow::LogTest(const TDesC &aTitle,TInt aNum) + { + _LIT(Test,"Test %d,%S"); + iTestTitle.Format(Test,aNum,&aTitle); + TLogMessageText buf; + _LIT(AutoNewTest,"AUTO New Test: "); + buf.Append(AutoNewTest); + buf.Append(iTestTitle); + TheClient->LogMessage(buf); + iMessage.Zero(); + iWin.Invalidate(); + } + +/** +This function is not used at the moment but I leave it in in case I need it when I improve the logging in +the log window. +*/ +const TDesC& LogWindow::LogSubTest(const TDesC &aTitle,TInt aNum) + { + _LIT(SubTest,"Sub-Test[%d], %S"); + iSubTitle.Format(SubTest,aNum,&aTitle); + TLogMessageText buf; + buf.Append(Auto); + buf.Append(iSubTitle); + TheClient->LogMessage(buf); + iMessage.Zero(); + iGc->Activate(iWin); + iGc->UseFont((CFont *)iFont); + iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + DrawSubTitle(); + DrawMessage(); + iGc->Deactivate(); + TheClient->iWs.Flush(); + return iSubTitle; + } + +const TDesC& LogWindow::LogMessage(TBool aLog,const TDesC& aText,TInt aNum) + { + if (aNum!=EDummyValue) + { + _LIT(StringInt,"%S %d"); + iMessage.Format(StringInt,&aText,aNum); + } + else + { + _LIT(String,"%S"); + iMessage.Format(String,&aText); + } + iGc->Activate(iWin); + iGc->UseFont((CFont *)iFont); + iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + DrawMessage(); + iGc->Deactivate(); + if (aLog) + { + TLogMessageText buf; + buf.Append(Auto); + buf.Append(iMessage); + TheClient->LogMessage(buf); + } + TheClient->iWs.Flush(); + return iMessage; + } + + +// +// Test window, simple window used to do test graphics in // +// +TestWindow::TestWindow() : CTWin() + { + } + +TestWindow::~TestWindow() + { + delete iBorderWin; + } + +void TestWindow::SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc) + { + iBorderWin=new(ELeave) CBorderWindow(); + iBorderWin->SetUpL(pos,size,parent,aGc); + TRAPD(err, CTWin::ConstructL(*iBorderWin)); + if (err==KErrNone) + { + SetExt(TPoint(2,2),TSize(size.iWidth-4,size.iHeight-4)); + if (err==KErrNone) + { + Activate(); + AssignGC(aGc); + return; + } + } + delete this; + User::Leave(err); + } + +void TestWindow::Draw() + { + iGc->Clear(); + } + +void TestWindow::ClearWin() + { + TheGc->Activate(*Win()); + TheGc->Clear(); + TheGc->Deactivate(); + } + +void TestWindow::SetBorderExt(TPoint aPos, TSize aSize) + { + iBorderWin->SetExt(aPos, aSize); + } + +CBorderWindow* TestWindow::GetBorderWin() + { + return iBorderWin; + } +// +CBorderWindow::CBorderWindow() : CTWin() + { + } + +void CBorderWindow::ConstructL(CTWinBase &parent) + { + CTWin::ConstructL(parent); + } + +void CBorderWindow::Draw() + { + iGc->SetBrushColor(TRgb::Gray16(0)); + iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + iGc->SetPenStyle(CGraphicsContext::ENullPen); + iGc->DrawRect(TRect(Size())); + } + +// + +TestWindowGroup::TestWindowGroup(CTClient *aClient) : CTWindowGroup(aClient) + { + } + +void TestWindowGroup::BecomeOwning() + { + iGroupWin.DefaultOwningWindow(); + } + +void TestWindowGroup::KeyL(const TKeyEvent &aKey,const TTime &aTime) + { + if (aKey.iModifiers&EModifierFunc) + { + switch(aKey.iCode) + { + case 'f': + TheClient->Driver()->iTest->TriggerFail(); + break; + } + } + else if (iCurWin) + iCurWin->WinKeyL(aKey,aTime); + } + +void TestWindowGroup::KeyDownL(const TKeyEvent &aKey,const TTime &aTime) + { + if (iCurWin) + iCurWin->KeyDownL(aKey,aTime); + } + +void TestWindowGroup::KeyUpL(const TKeyEvent &aKey,const TTime &aTime) + { + if (iCurWin) + iCurWin->KeyUpL(aKey,aTime); + } + +// + +TestClient::TestClient() + {} + +void TestClient::ConstructL() + { + CTClient::ConstructL(); + + iGroup=new(ELeave) TestWindowGroup(this); + iGroup->ConstructL(); + + iScreen->GetScreenSizeModeList(&iScreenModes); + iScreen->SetScreenMode(iScreenModes[0]); + TSize screenSize=iScreen->SizeInPixels(); + + TInt winWidth=(screenSize.iWidth/3)-10; + TInt winHeight=screenSize.iHeight-10; + iStdLogWindow=new(ELeave) LogWindow(); + iStdLogWindow->SetUpL(TPoint(5,5),TSize(winWidth,winHeight),iGroup,*iGc); + BaseWin=new(ELeave) TestWindow(); + BaseWin->SetUpL(TPoint(screenSize.iWidth/3+5,5),TSize(winWidth,winHeight),iGroup,*iGc); + TestWin=new(ELeave) TestWindow(); + TestWin->SetUpL(TPoint(screenSize.iWidth/3*2+5,5),TSize(winWidth,winHeight),iGroup,*iGc); + + iDriver = CTestDriver::CreateL(iScreenNumber); // virtual constructor + + TheGc=new(ELeave) CWindowGc(iScreen); + User::LeaveIfError(TheGc->Construct()); + + _LIT(KTestLog,"WSERV Auto Test Log"); + LogMessage(KTestLog()); + LogAvailableScreenModeL(); + + //This class was designed to be created once and reused by all the tests, now it is created for each test, + //this needs to be changed back so tests like the following are only done once. + TestWsSetBufferSizeL(); + TestWsSetMaxBufferSizeL(); + } + +inline CTestDriver* TestClient::Driver() + { + return iDriver; + } + +TBool TestClient::WaitForEvent() + { + if (iEventHandler->iStatus!=KRequestPending) + return ETrue; + else if (iRedrawEventHandler->iStatus!=KRequestPending) + return EFalse; + User::WaitForRequest(iEventHandler->iStatus,iRedrawEventHandler->iStatus); + TRequestStatus* status=&iEventHandler->iStatus; + TBool ret=ETrue; + if (iEventHandler->iStatus==KRequestPending) + { + status=&iRedrawEventHandler->iStatus; + ret=EFalse; + } + TInt reason=status->Int(); + *status=KRequestPending; + User::RequestComplete(status,reason); + return ret; + } + +TBool TestClient::IsEventWaiting() + { + return (iEventHandler->iStatus!=KRequestPending || iRedrawEventHandler->iStatus!=KRequestPending); + } + +TestClient::~TestClient() + { + iScreenModes.Close(); + delete iDriver; + delete TheGc; + delete iStdLogWindow; + delete BaseWin; + delete TestWin; + } + +void TestClient::LogAvailableScreenModeL() + { + _LIT(KColorModes,"Color Modes: "); + _LIT(KComma,", "); + _LIT(KColor,"Color"); + _LIT(KGrey,"Grey"); + CArrayFixFlat* modeList=new(ELeave) CArrayFixFlat(15); + iWs.GetColorModeList(modeList); + TLogMessageText buf,buf2; + buf.Append(KColorModes); + TDisplayMode mode; + TInt ii=0; + FOREVER + { + mode=STATIC_CAST(TDisplayMode,(*modeList)[ii]); + buf.AppendNum((*modeList)[ii]); + buf2.Append(TDisplayModeUtils::IsDisplayModeColor(mode)?KColor():KGrey()); + buf2.AppendNum(TDisplayModeUtils::NumDisplayModeColors(mode)); + if (mode==EColor16MU) + buf2.Append('U'); + if (++ii==modeList->Count()) + break; + buf.Append(KComma); + buf2.Append(KComma); + } + LogMessage(buf); + LogMessage(buf2); + delete modeList; + } + +void TestClient::TestWsSetBufferSizeL() + { + RWsSession ws; + User::LeaveIfError(ws.Connect()); + ws.SetBufferSizeL(256); // default buffer size 640 + ws.SetBufferSizeL(0x8000); // 16K is max buffer size + ws.SetBufferSizeL(0x4000); + ws.Close(); + } + +void TestClient::TestWsSetMaxBufferSizeL() + { + RWsSession ws; + User::LeaveIfError(ws.Connect()); + // allow buffer to grow bigger than the default 640 bytes + const TInt KBigMessageSize = 800; + ws.SetMaxBufferSizeL(KBigMessageSize + 8); // big message + command header length + + // send the big message to the wserv + TBuf8 bigMessage; + + // LogMessage needs a pointer to a TInt with the message size at the start of the buffer + const TInt szLength = sizeof(TInt); + TInt length = KBigMessageSize - szLength; // length in Unicode characters + bigMessage.Append((TUint8*) &length, szLength); + + _LIT(KLetterA, "a"); + do + { + bigMessage.Append((TUint8*) KLetterA().Ptr(), 2); + } + while (bigMessage.Length() < KBigMessageSize); + + // send to Wserv, note that the message is too long to be logged + ws.TestWrite(ws.WsHandle(), EWsClOpLogMessage, bigMessage.Ptr(), KBigMessageSize); + ws.Flush(); + + ws.Close(); + } + +void TestClient::SetTestClientScreenMode(TInt aMode) + { + iScreen->SetAppScreenMode(aMode); + iScreen->SetScreenMode(aMode); + UpdateTestClientScreenMode(); + } + +void TestClient::UpdateTestClientScreenMode() + { + TSize screenSize=iScreen->SizeInPixels(); + + // Sets new positions and dimensions for the three window and their controlling border windows + + if (screenSize.iHeight > screenSize.iWidth) // Portrait mode + { + TInt winWidth=screenSize.iWidth - (KBorderWinWidth * 2); + TInt winHeight=(screenSize.iHeight/3) - (KBorderWinWidth * 2); + + iStdLogWindow->SetExt(TPoint(KBorderWinWidth,KBorderWinWidth),TSize(winWidth,winHeight)); + BaseWin->SetBorderExt(TPoint(KBorderWinWidth,screenSize.iHeight/3+KBorderWinWidth),TSize(winWidth,winHeight)); + BaseWin->SetExt(TPoint(2,2),TSize(winWidth - (KBorderWinWidth - 1),winHeight - (KBorderWinWidth - 1))); + TestWin->SetBorderExt(TPoint(KBorderWinWidth,screenSize.iHeight/3*2+KBorderWinWidth),TSize(winWidth,winHeight)); + TestWin->SetExt(TPoint(2,2),TSize(winWidth - (KBorderWinWidth - 1),winHeight - (KBorderWinWidth - 1))); + } + else // Landscape modes + { + TInt winWidth=(screenSize.iWidth/3) - (KBorderWinWidth * 2); + TInt winHeight=screenSize.iHeight - (KBorderWinWidth * 2); + + iStdLogWindow->SetExt(TPoint(KBorderWinWidth,KBorderWinWidth),TSize(winWidth,winHeight)); + BaseWin->SetBorderExt(TPoint(screenSize.iWidth/3 + KBorderWinWidth,KBorderWinWidth),TSize(winWidth,winHeight)); + BaseWin->SetExt(TPoint(2,2),TSize(winWidth - (KBorderWinWidth - 1),winHeight - (KBorderWinWidth - 1))); + TestWin->SetBorderExt(TPoint(screenSize.iWidth/3*2+KBorderWinWidth,KBorderWinWidth),TSize(winWidth,winHeight)); + TestWin->SetExt(TPoint(2,2),TSize(winWidth - (KBorderWinWidth - 1),winHeight - (KBorderWinWidth - 1))); + } + + // Remove shading artefacts from window resizing operations + TestWin->Win()->Invalidate(); + TestWin->Win()->BeginRedraw(); + TestWin->ClearWin(); + TestWin->Win()->EndRedraw(); + + BaseWin->Win()->Invalidate(); + BaseWin->Win()->BeginRedraw(); + BaseWin->ClearWin(); + BaseWin->Win()->EndRedraw(); + + TheClient->iWs.Flush(); + } + + +// +// TestDriver, drives the test code // +// +CTestDriver* CTestDriver::CreateL(TInt aScreenNumber) + { + CTestDriver* self = NULL; + if (aScreenNumber==KDefaultScreen) + self = new (ELeave) CTestDriverPrimary(aScreenNumber); + else + self = new (ELeave) CTestDriverSecondary(aScreenNumber); + + return self; + } + +CTestDriver::CTestDriver(TInt aScreenNumber) + : iScreenNumber(aScreenNumber) + { + iStartTime.HomeTime(); + HAL::Get(HALData::EDisplayNumberOfScreens, iNumberOfScreens); + } + +CTestDriver::~CTestDriver() + { + } + +void CTestDriver::DestroyTest() + { + delete iTest; + iTest=NULL; + } + +void CTestDriver::TestComplete2() + { + ++iTestNum; + if (iTestNum==iTestSize) + { + TBuf<64> timeBuf; + TTime endTime; + endTime.HomeTime(); + TTimeIntervalMicroSeconds elapseTime=endTime.MicroSecondsFrom(iStartTime); + TInt64 elapseTime2=elapseTime.Int64()/1000; + TUint diffi = I64LOW(elapseTime2); + _LIT(TestPass,"PASSED"); + _LIT(TestFail,"FAILED"); + TInt noOfTests=CTestBase::iNumberTests; + TInt noOfTestsPass=CTestBase::iNumberTestsPass; + _LIT(TimeBuf,"Elapse Time %d:%02d.%03d %S"); + timeBuf.Format(TimeBuf,diffi/60000,(diffi/1000)%60,diffi%1000000,&(noOfTests==noOfTestsPass?TestPass:TestFail)); + TBuf<60> testReport; + _LIT(Checks,"Checks"); + _LIT(Fails,"Fails"); + _LIT(TestReport,"Tests:%d %S:%d"); + TInt testNumber=(noOfTests==noOfTestsPass? noOfTestsPass : noOfTests-noOfTestsPass); + testReport.Format(TestReport,iTestNum,&(noOfTests==noOfTestsPass?Checks():Fails()),testNumber); + if (noOfTests!=noOfTestsPass) + { + _LIT(NumTests,"/%d"); + testReport.AppendFormat(NumTests,noOfTests); + } + + TBuf<60> logTestReport; + _LIT(LogReport," %S:%d/%d"); + logTestReport.Format(LogReport,&Checks,noOfTestsPass,noOfTests); + TLogMessageText buf; + _LIT(Finished,"AUTO Testing Complete, "); + buf.Append(Finished); + buf.Append(timeBuf); + buf.Append(logTestReport); + TheClient->LogMessage(buf); + + TheTestResult = noOfTests==noOfTestsPass? ETestPassed : ETestFailed; + DoDisplayDialog(timeBuf,testReport); + } + } + +// +// Test driver for primary screen (has digitiser/pointer) +// +CTestDriverPrimary::CTestDriverPrimary(TInt aScreenNumber) : CTestDriver(aScreenNumber) + { + TInt i; + TInt numOfEntries = 1; + for (i=0; i1); + if (aTl>aBr) + { + TInt tmp=aBr; + aBr=aTl; + aTl=tmp; + } + } + +TRect TTestRects::operator[](TInt aIndex) + { + TRect rect; + if (aIndexiTl.iX==pRect->iBr.iX) + RectCoordPair(rect.iTl.iX,rect.iBr.iX,pRect->iTl.iX,iSize.iWidth); + else + { + rect.iTl.iX=RectCoord(pRect->iTl.iX,iSize.iWidth); + rect.iBr.iX=RectCoord(pRect->iBr.iX,iSize.iWidth); + } + if (pRect->iTl.iY==pRect->iBr.iY) + RectCoordPair(rect.iTl.iY,rect.iBr.iY,pRect->iTl.iY,iSize.iHeight); + else + { + rect.iTl.iY=RectCoord(pRect->iTl.iX,iSize.iHeight); + rect.iBr.iY=RectCoord(pRect->iBr.iX,iSize.iHeight); + } + } + else if (aIndexConstructL(aHandle, aSizeInPixels, aDispMode); + return self; + } + +void CBitmap::ConstructL(TInt aHandle,const TSize& aSizeInPixels,TDisplayMode aDispMode) + { + iBitmap=new(ELeave) CFbsBitmap(); + if (aHandle==0) + { + User::LeaveIfError(iBitmap->Create(aSizeInPixels,aDispMode)); + } + else + { + User::LeaveIfError(iBitmap->Duplicate(aHandle)); + } + iDevice=CFbsBitmapDevice::NewL(iBitmap); + User::LeaveIfError(iDevice->CreateContext(iGc)); + } + +CBitmap::~CBitmap() + { + delete iGc; + delete iDevice; + delete iBitmap; + } + + +// CTestBase // + +CTestBase::CTestBase(const TDesC& aTitle,CTWsGraphicsBase* aTestBase) + { + iTestBase=aTestBase; + iTitle.Copy(aTitle); + + iScreenNo = iTestBase->GetScreenFromIni(); + + TheClient=new(ELeave) TestClient(); + + if (CTestBase::iScreenNo == 1) + { + TheClient->SetScreenNumber(1); + iScreenNumber = 1; + } + else + { + TheClient->SetScreenNumber(0); + iScreenNumber = 0; + } + + if (iScreenNumber == 1) + { + iMinWin = new(ELeave) CMinWin(iScreenNumber); + iMinWin->ConstructL(); + } + + iTestNum=CTestDriver::iTestNum; + TheClient->ConstructL(); + TheClient->StdLogWindow().LogTest(iTitle,iTestNum); + iDriver=TheClient->Driver(); + + if (CTestBase::iScreenNo == 1) + { + TheClient->iWs.SetFocusScreen(1); + } + else + { + TheClient->iWs.SetFocusScreen(0); + } + + iTestRects.Construct(*BaseWin->Win()); + iStdTestWindowSize=BaseWin->Size(); + iRedrawType=EPartialRedraw_Unknown; // Reset between tests + if (iMaxGrays+iMaxColors==0) + { + TheClient->iWs.GetDefModeMaxNumColors(iMaxColors,iMaxGrays); + iNormalPointerCursorArea=TheClient->iWs.PointerCursorArea(); + } + } + +CTestBase::~CTestBase() + { + delete iMinWin; + delete TheClient; + } + +void CTestBase::CloseAllPanicWindows() + { + TInt idFocus = TheClient->iWs.GetFocusWindowGroup(); + TWsEvent event; + event.SetType(EEventKey); + TKeyEvent *keyEvent = event.Key(); + keyEvent->iCode = EKeyEscape; + keyEvent->iScanCode = EStdKeyEscape; + keyEvent->iModifiers = 0; + TInt theLimit = 50; + while(idFocus != NULL && (theLimit-- > 0)) + { + TheClient->iWs.SendEventToAllWindowGroups(event); + idFocus = TheClient->iWs.GetFocusWindowGroup(); + } + } + +/** +Returns the size of the standard test windows. +@see iStdTestWindowSize +*/ +const TSize& CTestBase::StdTestWindowSize() + { + return iStdTestWindowSize; + } + +/** Returns the number of greys available in the richest grey mode */ +TInt CTestBase::MaxGrays() const + { + return iMaxGrays; + } + +/** Returns the number of colours available in the richest supported colour mode. */ +TInt CTestBase::MaxColors() const + { + return iMaxColors; + } + +void CTestBase::TriggerFail() + { + iFail=ETrue; + } + +void CTestBase::LogLeave(TInt aErr) + { + TLogMessageText buf; + _LIT(Leave,"AUTO Left with error code %d in "); + buf.AppendFormat(Leave,aErr); + buf.Append(iSubTitle); + TheClient->LogMessage(buf); + } + +void CTestBase::LogSubTest(const TDesC &aSubTitle) + { + Driver()->iSubTestNum++; + iSubTitle=aSubTitle; + iTestBase->Logger().Write(TheClient->StdLogWindow().LogSubTest(aSubTitle,iState)); + } + +void CTestBase::LogMessage(TInt aValue) + { + _LIT(WinID,"Win Id:"); + TheClient->StdLogWindow().LogMessage(EFalse,WinID,aValue); + } + +void CTestBase::LogSubState(TInt aSubState) + { + _LIT(SubTest,"SubState"); + iTestBase->Logger().Write(TheClient->StdLogWindow().LogMessage(ETrue,SubTest,aSubState)); + } + +TBool DoCheckRectRWin(RWindowBase &aWin1,RWindowBase &aWin2,const TRect &aRect) + { + TRect rect1(aRect); + TRect rect2(aRect); + rect1.Move(aWin1.InquireOffset(*TheClient->iGroup->WinTreeNode())); + rect2.Move(aWin2.InquireOffset(*TheClient->iGroup->WinTreeNode())); + TBool match=TheClient->iScreen->RectCompare(rect1,rect2); +#if defined(__WINS__) + if (!match) + FindNonMatchingPixel(rect1.iTl,rect2.iTl,aRect.Size()); +#endif + return match; + } + +TBool DoCheckRectRWin(RWindowBase &aWin1,RWindowBase &aWin2,const TRect &aRect, TUint aFlags) + { + TRect rect1(aRect); + TRect rect2(aRect); + rect1.Move(aWin1.InquireOffset(*TheClient->iGroup->WinTreeNode())); + rect2.Move(aWin2.InquireOffset(*TheClient->iGroup->WinTreeNode())); + TBool match=TheClient->iScreen->RectCompare(rect1,rect2, aFlags); +#if defined(__WINS__) + if (!match) + FindNonMatchingPixel(rect1.iTl,rect2.iTl,aRect.Size()); +#endif + return match; + } + +TBool DoCheckRect(CTBaseWin *aWin1,CTBaseWin *aWin2,const TRect &aRect) + { + return DoCheckRectRWin(*aWin1->BaseWin(), *aWin2->BaseWin(), aRect); + } + +TBool DoCheckRect(CTBaseWin *aWin1,CTBaseWin *aWin2) + { + TSize winSize=aWin1->Size(); + TRect rect1(aWin1->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),winSize); + TRect rect2(aWin2->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),winSize); + return TheClient->iScreen->RectCompare(rect1,rect2); + } + +TBool DoCheckRect(CTBaseWin *aWin1, CTBaseWin *aWin2, const TRect &aRect, TUint aFlags) + { + return DoCheckRectRWin(*aWin1->BaseWin(), *aWin2->BaseWin(), aRect, aFlags); + } + + +/** +Compares the contents of 2 rectangular areas of the screen. + +@param aPos1 The top left corner of the first rectangle. +@param aPos2 The top left corner of the second rectangle. +@param aSize The size of the rectangles +@return ETrue if the 2 areas have the same content, EFalse otherwise. +*/ +TBool DoCheckRect(TPoint aPos1,TPoint aPos2,TSize aSize) + { + return TheClient->iScreen->RectCompare(TRect(aPos1,aSize),TRect(aPos2,aSize)); + } + +void CTestBase::DrawTestBackground(TBool aInvertColors, const TSize &aSize, TInt aGrays/*=16*/) +// +// Draws a standard test background with a mix of colors (shades). +// This is mainly used to test for graphic functions writing outside the intended area. +// +// This code assumes an TheGc is already active on the window to use. +// + { + TheGc->SetBrushColor(TRgb::Gray256(255)); + TInt step=5; + TInt col=0; + TInt colorInc=(aGrays>9 ? 17 : 85); + TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + TheGc->SetPenStyle(CGraphicsContext::ENullPen); + for(TInt row=0;rowSetBrushColor(TRgb::Gray256(aInvertColors ? 255-col:col)); + TheGc->DrawRect(TRect(0,row,aSize.iWidth,row+step)); + col=col+colorInc; + if (col>255) + col=0; + } + } + +void CTestBase::AbortL() + { + CTestDriver* driver=iDriver; + iDriver->DestroyTest(); + driver->TestComplete2(); + User::Leave(ETestFailed); + } + +/*CTWsGraphicsBase*/ + +CTWsGraphicsBase::CTWsGraphicsBase(CTestStep* aStep) : CTGraphicsBase(aStep) + { + } + +CTWsGraphicsBase::~CTWsGraphicsBase() + { + delete iTest; + } + +void CTWsGraphicsBase::CreateTestBaseL(CTTMSGraphicsStep* aTmsStep) + { + __ASSERT_ALWAYS(iTest==NULL,AutoPanic(EAutoPanicRecalledCreateTestBaseL)); + iTest=new(ELeave) CTestBase(iStep->TestStepName(),this); + iTmsStep = aTmsStep; + } +/** +Gets the Screen Number from an .ini file supplied to the RUN_TEST_STEP. Screen number should +be put under the section [useScreen] as screen=0 or screen=1. + +@return Screen number Defined in .ini file, otherwise 0. +*/ +TInt CTWsGraphicsBase::GetScreenFromIni() const + { + _LIT(KUseScreenSection, "useScreen"); + _LIT(KScreen, "screen"); + + TInt screen = 0; + TBool configAvailable = iStep->GetIntFromConfig(KUseScreenSection, KScreen, screen); + if(configAvailable) + { + return screen; + } + else + { + return 0; + } + } + +void CTWsGraphicsBase::TestComplete() + { + _LIT(KTestComplete,"Test complete"); + INFO_PRINTF1(KTestComplete); + CTGraphicsBase::TestComplete(); + } + +void CTWsGraphicsBase::LogMessage(const TText8* aFile,TInt aLine,TRefByValue aFmt,...) + { + TLogMessageText buf; + VA_LIST list; + VA_START(list,aFmt); + buf.AppendFormatList(aFmt,list); + TheClient->LogMessage(buf); + Logger().LogExtra(aFile,aLine,ESevrInfo,buf); + VA_END(list); + } + +TBool CTWsGraphicsBase::CheckRetValue(TBool aPass, const TDesC *aErrorMsg, const TDesC &aErrorFunction) + { + if (!aPass && aErrorMsg) + { + LOG_MESSAGE3(_L("%S %S failed"),aErrorMsg,&aErrorFunction); + iTmsStep->MQCTest(EFalse,((TText8*)__FILE__),__LINE__); + } + iStep->TEST(aPass); + return aPass; + } + +void CTWsGraphicsBase::CompareWindowsSoftFailWinscw(const TText8* aFile, TInt aLine) + { + if (!DoCheckRect(BaseWin, TestWin, BaseWin->Size())) + { +#ifdef __WINS__ + _LIT(KMessage,"ERROR: Test Failed but is ignored on WINSCW"); + Logger().LogExtra(aFile, aLine, ESevrErr, KMessage); +#else // __WINS__ + iStep->TEST(EFalse); + _LIT(KMessage,"ERROR: Test Failed"); + Logger().LogExtra(aFile, aLine, ESevrErr, KMessage); +#endif // __WINS__ + } + } + +void CTWsGraphicsBase::CheckRect(TPoint aPos1,TPoint aPos2,TSize aSize, const TDesC *aErrorMsg) + { + CheckRetValue(DoCheckRect(aPos1,aPos2,aSize),aErrorMsg,_L("CheckRect()")); + } + +void CTWsGraphicsBase::CheckRect(TPoint aPos1,TPoint aPos2,TSize aSize, const TDesC &aErrorMsg) + { + CheckRect(aPos1,aPos2,aSize,&aErrorMsg); + } + +void CTWsGraphicsBase::CheckRectNoMatch(TPoint aPos1,TPoint aPos2,TSize aSize, const TDesC *aErrorMsg) + { + CheckRetValue(!DoCheckRect(aPos1,aPos2,aSize),aErrorMsg,_L("CheckRectNoMatch()")); + } + +void CTWsGraphicsBase::CheckRectNoMatch(TPoint aPos1,TPoint aPos2,TSize aSize, const TDesC &aErrorMsg) + { + CheckRectNoMatch(aPos1,aPos2,aSize,&aErrorMsg); + } + +void CTWsGraphicsBase::CheckRect(CTBaseWin *aWin1,CTBaseWin *aWin2, const TDesC *aErrorMsg) + { + CheckRetValue(DoCheckRect(aWin1,aWin2),aErrorMsg,_L("CheckRect()")); + } + +void CTWsGraphicsBase::CheckRect(CTBaseWin *aWin1,CTBaseWin *aWin2, const TDesC &aErrorMsg) + { + CheckRect(aWin1,aWin2,&aErrorMsg); + } + +void CTWsGraphicsBase::CheckRectNoMatch(CTBaseWin *aWin1,CTBaseWin *aWin2, const TDesC *aErrorMsg) + { + CheckRetValue(!DoCheckRect(aWin1,aWin2),aErrorMsg,_L("CheckRectNoMatch()")); + } + +void CTWsGraphicsBase::CheckRectNoMatch(CTBaseWin *aWin1,CTBaseWin *aWin2, const TDesC &aErrorMsg) + { + CheckRectNoMatch(aWin1,aWin2,&aErrorMsg); + } + +TBool CTWsGraphicsBase::CheckRect(CTBaseWin *aWin1,CTBaseWin *aWin2,const TRect &aRect, const TDesC *aErrorMsg) + { + return CheckRetValue(DoCheckRect(aWin1,aWin2,aRect),aErrorMsg,_L("CheckRect()")); + } + +TBool CTWsGraphicsBase::CheckRect(CTBaseWin *aWin1,CTBaseWin *aWin2,const TRect &aRect, const TDesC &aErrorMsg) + { + return CheckRect(aWin1,aWin2,aRect,&aErrorMsg); + } + +void CTWsGraphicsBase::CheckRectNoMatch(CTBaseWin *aWin1,CTBaseWin *aWin2,const TRect &aRect, const TDesC *aErrorMsg) + { + CheckRetValue(!DoCheckRect(aWin1,aWin2,aRect),aErrorMsg,_L("CheckRectNoMatch()")); + } + +void CTWsGraphicsBase::CheckRectNoMatch(CTBaseWin *aWin1,CTBaseWin *aWin2,const TRect &aRect, const TDesC &aErrorMsg) + { + CheckRectNoMatch(aWin1,aWin2,aRect,&aErrorMsg); + } + +void CTWsGraphicsBase::CompareWindows(const TRect &aRect, const TDesC *aErrorMsg) + { + CheckRetValue(DoCheckRect(BaseWin,TestWin,aRect),aErrorMsg,_L("CompareWindows()")); + } + +TBool CTWsGraphicsBase::CompareWindows(const TDesC *aErrorMsg) + { + return CheckRetValue(DoCheckRect(BaseWin,TestWin,TRect(BaseWin->Size())),aErrorMsg,_L("CompareWindows()")); + } + +void CTWsGraphicsBase::CompareWindows(const TRect &aRect, const TDesC &aErrorMsg) + { + CompareWindows(aRect,&aErrorMsg); + } + +TBool CTWsGraphicsBase::CompareWindows(const TDesC &aErrorMsg) + { + return CompareWindows(&aErrorMsg); + } + +/** +Returns the size of the standard test windows. + +Several tests use 3 windows : one is a log window, one is a reference window +and one is the actual output of the test. All these windows have the same width which is roughly +1/3 of the screen. They also have the same height which is roughly equal to the screen height. +*/ +const TSize& CTWsGraphicsBase::StdTestWindowSize() + { + return iTest->StdTestWindowSize(); + } + +/** Returns the number of greys available in the richest grey mode */ +TInt CTWsGraphicsBase::MaxGrays() const + { + return iTest->MaxGrays(); + } + +/** Returns the number of colours available in the richest supported colour mode. */ +TInt CTWsGraphicsBase::MaxColors() const + { + return iTest->MaxColors(); + } + +// +// Panic testing // +// + +LOCAL_C TInt PanicThreadFunc(TAny *aPtr) + { + CTrapCleanup* CleanUpStack=CTrapCleanup::New(); + SPanicParams *ptr=(SPanicParams *)aPtr; + TInt ret; + TRAP(ret,ret=(*ptr->func)(ptr->num,ptr->ptr)); + delete CleanUpStack; + if (ret==EWsExitReasonBad) + AutoPanic(EAutoPanicPanicFailed); + return(ret); + } + +TInt CTestBase::LaunchPanicThread(RThread &aThread, SPanicParams *aPtr) + { + TBuf<32> threadName; + threadName.Format(TRefByValue(_L("AutoPanicThread%d")),iThreadNumber++); + return(aThread.Create(threadName,PanicThreadFunc,KDefaultStackSize,KPanicThreadHeapSize,KPanicThreadHeapSize,aPtr,EOwnerThread)); + } + +TInt CTestBase::TestPanicL(SPanicParams *aPtr, TInt aExitReason, const TDesC &aCategory, TBool* aTestFinished) + { + RThread thread; + TRequestStatus stat; + TInt err=LaunchPanicThread(thread, aPtr); + if (err==KErrAlreadyExists) + { + // wait for kernel to clear up old threads + // and have several attempts at starting the thread + // if unsuccessful the first time + for (TInt i=0;i<3;i++) + { + User::After(TTimeIntervalMicroSeconds32(100000)); //0.1 secs + err=LaunchPanicThread(thread, aPtr); + if (err!=KErrAlreadyExists) + break; + } + } + User::LeaveIfError(err); + thread.Logon(stat); + User::SetJustInTime(EFalse); + thread.Resume(); + User::WaitForRequest(stat); + User::SetJustInTime(ETrue); + + TBool testFinished=EFalse; + TBool testPassed=ETrue; + if (thread.ExitType()==EExitKill) + { + User::LeaveIfError(thread.ExitReason()); + if(thread.ExitReason()!=EWsExitReasonFinished) + { + testPassed=EFalse; + } + testFinished=ETrue; // Finish tests + } + else + { + if ((thread.ExitCategory().Compare(aCategory)!=0) + || (aExitReason!=EWservNoPanic && thread.ExitReason()!=aExitReason) + || (thread.ExitType()!=EExitPanic)) + { + testPassed=EFalse; + } + } + + if(aTestFinished) + *aTestFinished=testFinished; + thread.Close(); + return(testPassed); + } + +TInt CTestBase::TestWsPanicL(TPanicFunction aFunction, TClientPanic aExitReason, TInt aInt, TAny *aPtr, TBool* aTestFinished) + { + return TestPanicL(aFunction,aExitReason,aInt,aPtr,KWSERV, aTestFinished); + } + +TInt CTestBase::TestW32PanicL(TPanicFunction aFunction, TW32Panic aExitReason, TInt aInt, TAny *aPtr, TBool* aTestFinished) + { + return TestPanicL(aFunction,aExitReason,aInt,aPtr,KW32,aTestFinished); + } + + TInt CTestBase::TestWservPanicL(TPanicFunction aFunction, TWservPanic aExitReason, TInt aInt, TAny *aPtr) + { + _LIT(KWSERV1,"Wserv Internal Panic"); + return TestPanicL(aFunction,aExitReason,aInt,aPtr,KWSERV1); + } + +TInt CTestBase::TestPanicL(TPanicFunction aFunction, TInt aExitReason, TInt aInt, TAny *aPtr, const TDesC &aCategory, TBool* aTestFinished) + { + SPanicParams params; + params.num=aInt; + params.func=aFunction; + params.ptr=aPtr; + return TestPanicL(¶ms, aExitReason, aCategory, aTestFinished); + } + +TBool CTestBase::IsFullRomL() + { + TBool isFullRom = EFalse; + _LIT(KWinName,"EikonServer"); + TInt numWinGroups=TheClient->iWs.NumWindowGroups(); + CArrayFixFlat* list=new(ELeave) CArrayFixFlat(numWinGroups); + TheClient->iWs.WindowGroupList(list); + numWinGroups=list->Count(); // Just in case it changed between originally getting it and getting the actual list + TBuf<64> name; + TInt ii; + for(ii=0;iiiWs.GetWindowGroupNameFromIdentifier((*list)[ii],name); + #ifndef DISABLE_FAIL_DIALOG + TInt ordinalPos=0; + ordinalPos+=ordinalPos; //To stop a warning + ordinalPos= + #endif + TheClient->iWs.GetWindowGroupOrdinalPriority((*list)[ii]); + if (name==KWinName) + { + isFullRom = ETrue; + break; + } + } + delete list; + return isFullRom; + } + +void CTestBase::DelayIfFullRomL() + { + if (IsFullRomL()) + User::After(400000); + } + +TPartialRedrawType CTestBase::RedrawStoreTypeL() + { +/* if (iRedrawType==EPartialRedraw_Unknown) + { + const TRgb KRed=TRgb(255,0,0); + const TRgb KGreen=TRgb(0,255,0); + const TRgb KBlue=TRgb(0,0,255); + CWsScreenDevice* scrDev=TheClient->iScreen; + TSize winSize=scrDev->SizeInPixels(); + CBlankWindow* win=new(ELeave) CBlankWindow(KRed); //Window will be red if WSERV just draws in background color + CleanupStack::PushL(win); + TDisplayMode mode=EColor256; + win->SetUpL(TPoint(),winSize,TheClient->iGroup,*TheClient->iGc,&mode); //Window is activated + win->RealDraw(ETrue); + win->SetColor(KGreen); + CBlankWindow* win2=new(ELeave) CBlankWindow(KRed); + CleanupStack::PushL(win2); + win2->SetUpL(TPoint(),winSize,TheClient->iGroup,*TheClient->iGc,&mode); //New Window completely obscures other window + win2->RealDraw(ETrue); + win->CTWin::DrawNow(); //Window will be green if drawn from stored commands + win2->CTWin::DrawNow(); + win2->SetVisible(EFalse); + TRgb col; + scrDev->GetPixel(col,TPoint(5,5)); //Pixel will be red if storing off by default and green otherwise + if (col==KRed) + { + win->Win()->EnableRedrawStore(ETrue); + win->CTWin::DrawNow(); //Create stored commands + } + else + __ASSERT_ALWAYS(col==KGreen,AutoPanic(EAutoPanicRedrawStoring)); + win->SetColor(KBlue); + TRect redrawRect(TSize(10,10)); + win->Invalidate(redrawRect); + win->Win()->BeginRedraw(redrawRect); + win->DrawNow(redrawRect); //Top left of Window will be blue if it draws itself + win->Win()->EndRedraw(); + win2->SetVisible(ETrue); + win2->SetVisible(EFalse); + scrDev->GetPixel(col,TPoint(5,5)); //Pixel will be red if stored commands were lost + iRedrawType=EPartialRedraw_None; + if (col!=KRed) + { + __ASSERT_ALWAYS(col==KBlue,AutoPanic(EAutoPanicRedrawStoring)); + TheClient->WaitForRedrawsToFinish(); + win2->SetVisible(ETrue); + win2->SetVisible(EFalse); + scrDev->GetPixel(col,TPoint(15,15)); //Pixel will be blue if partial redraw triggers full redraw + iRedrawType=EPartialRedraw_PreserveStoredCmds; + if (col!=KBlue) + { + __ASSERT_ALWAYS(col==KGreen,AutoPanic(EAutoPanicRedrawStoring)); + iRedrawType=EPartialRedraw_FullRedrawSupport; + } + } + CleanupStack::PopAndDestroy(2,win); + } + return iRedrawType;*/ + return EPartialRedraw_FullRedrawSupport; + } + +void CTestBase::SetUpMember(TSpriteMember &aMember) + { + aMember.iMaskBitmap=NULL; + aMember.iInvertMask=EFalse; + aMember.iDrawMode=CGraphicsContext::EDrawModePEN; + aMember.iOffset=TPoint(); + aMember.iInterval=TTimeIntervalMicroSeconds32(0); + } + +void CTestBase::SimulateKeyDownUpWithModifiers(TInt aScanCode,TUint aModifiers) + { + if (aModifiers&EModifierAlt) + SimulateKey(TRawEvent::EKeyDown,EStdKeyLeftFunc); + if (aModifiers&EModifierCtrl) + SimulateKey(TRawEvent::EKeyDown,EStdKeyLeftCtrl); + if (aModifiers&EModifierShift) + SimulateKey(TRawEvent::EKeyDown,EStdKeyLeftShift); + SimulateKeyDownUp(aScanCode); + if (aModifiers&EModifierShift) + SimulateKey(TRawEvent::EKeyUp,EStdKeyLeftShift); + if (aModifiers&EModifierCtrl) + SimulateKey(TRawEvent::EKeyUp,EStdKeyLeftCtrl); + if (aModifiers&EModifierAlt) + SimulateKey(TRawEvent::EKeyUp,EStdKeyLeftFunc); + } + +void CTestBase::SimulateKeyDownUp(TInt aScanCode) + { + __ASSERT_DEBUG(aScanCode<'a' || aScanCode>'z',AutoPanic(EAutoPanicScanCapital)); + SimulateKey(TRawEvent::EKeyDown,aScanCode); + SimulateKey(TRawEvent::EKeyUp,aScanCode); + } + +void CTestBase::SimulatePointerDownUp(TInt aX, TInt aY) + { + SimulatePointer(TRawEvent::EButton1Down,aX,aY); + SimulatePointer(TRawEvent::EButton1Up,aX,aY); + } + +void CTestBase::SimulateKey(TRawEvent::TType aType, TInt aScanCode) + { + TRawEvent rawEvent; + rawEvent.Set(aType,aScanCode); + TheClient->iWs.SimulateRawEvent(rawEvent); + } + +/** + * Determine if the configuration supports pointer event testing. + * + * There are certain circumstances where we want to skip pointer event + * testing because we are simulating pointer events, and don't want to + * simulate a pointer event from an impossible co-ordinate. We'd rather + * just identify that there is no point in doing the test and skip over + * to the next test case. + * + * In particular, when a ROM configured with a digitiser is deployed on a + * Naviengine, with hardware configuration DIP switches which say that there + * is an external screen connected, then no touch pad is active. + * The base port under these conditions returns a digitiser area (0,0,0,0) + * + * @return ETrue if the configuration supports pointer event testing, otherwise + * return EFalse. + */ +TBool CTestBase::ConfigurationSupportsPointerEventTesting() const + { + if (iNormalPointerCursorArea.IsEmpty()) + { + return EFalse; + } + return ETrue; + } + + +void CTestBase::SimulatePointer(TRawEvent::TType aType, TInt aX, TInt aY) + { + __ASSERT_DEBUG(ConfigurationSupportsPointerEventTesting(), AutoPanic(EAutoPanicNoDigitiser)); + + +#ifdef WSERV_TAUTO_LOG_POINTER_EVENTS + TLogMessageText buf; + _LIT(KLog,"SimulatePointer Type=%d Pos=(%d,%d)"); + buf.Format(KLog,aType,aX,aY); + TheClient->LogMessage(buf); +#endif + + TRawEvent rawEvent; + rawEvent.Set(aType,aX,aY); + TheClient->iWs.SimulateRawEvent(rawEvent); + } + +void CTestBase::SimulateEvent(TRawEvent::TType aType) + { + TRawEvent rawEvent; + rawEvent.Set(aType); + TheClient->iWs.SimulateRawEvent(rawEvent); + } + +void CTestBase::LogColors(const CBitmapDevice& aDevice,TPoint aBasePoint, TPoint aStartPoint, TPoint aEndPoint) + { + _LIT(KPixel,"Pixel(%d,%d) R=%d G=%d B=%d"); + TLogMessageText buf; + TBuf8<2560> screen; + const TRgb* pixel; + if (aStartPoint.iX==aEndPoint.iX) + ++aEndPoint.iX; + if (aStartPoint.iY==aEndPoint.iY) + ++aEndPoint.iY; + TInt width=aEndPoint.iX-aStartPoint.iX; + TInt xx,yy; + for (yy=aStartPoint.iY;yyRed(),pixel->Green(),pixel->Blue()); + //RDebug::Print(buf); + TheClient->iWs.LogMessage(buf); + } + } + TheClient->iWs.Flush(); + } + +void CTestBase::LogColors4(const CBitmapDevice& aDevice,TPoint aStartPoint,TInt aLen) + { + _LIT(KValue,"Pixel(%d,%d) Byte %d, Value %d"); + TLogMessageText buf; + TBuf8<2560> screen; + aDevice.GetScanLine(screen,aStartPoint,aLen,EGray4); + TInt len=(aLen+3)/4; + TInt ii; + for (ii=0;iiiWs.LogMessage(buf); + } + } + +void CTestBase::UpdateTestResults(TInt aNoOfTest, TInt aNoOfTestPass) + { + iNumberTests+=aNoOfTest; + iNumberTestsPass+=aNoOfTestPass; + } + +TInt CTestBase::SaveScreen(const TDesC& aFileName) + { + return SaveScreen(aFileName,TheClient->iScreen->SizeInPixels(),TheClient->iScreen->DisplayMode()); + } + +TInt CTestBase::SaveScreen(const TDesC& aFileName,const TSize& aScreenSize,TDisplayMode aColorDepth) + { + TRAPD(err,SaveScreenL(aFileName,aScreenSize,aColorDepth)); + return err; + } + +void CTestBase::SaveScreenL(const TDesC& aFileName,const TSize& aScreenSize,TDisplayMode aColorDepth) + { + CBitmap* copyOfScreen=CBitmap::NewLC(aScreenSize,aColorDepth); + CFbsScreenDevice* scrDevice=CFbsScreenDevice::NewL(iScreenNumber,aColorDepth); + CleanupStack::PushL(scrDevice); + CFbsBitGc* gc; + User::LeaveIfError(scrDevice->CreateContext(gc)); + CleanupStack::PushL(gc); + copyOfScreen->Gc().BitBlt(TPoint(),*gc); + User::LeaveIfError(copyOfScreen->Bitmap().Save(aFileName)); + CleanupStack::PopAndDestroy(3,copyOfScreen); + } + + +/*CProcess*/ +_LIT(KScreenTag,"Screen"); + +void CProcess::GetProcArg(const TWinCommand& aParam,TBufArg& aProcArg) + { + TInt pos = aParam.Find(KScreenTag); + if (pos!=KErrNotFound) + aProcArg = aParam.Left(pos-1); + else + aProcArg = aParam; + } + +void CProcess::GetScreenArg(const TWinCommand& aParam, TInt& aScreenArg) + { + TInt pos = aParam.Find(KScreenTag); + if (pos!=KErrNotFound) + { + TBufArg secondArg(aParam.Right(aParam.Length()-pos)); + if (secondArg.Length()>6) + { + TBuf<1> digit(secondArg.Mid(6,1)); + TLex lex(digit); + lex.Val(aScreenArg); + } + } + } + +TInt CProcess::Start(const TWinCommand& aParam) + { + // parse command line aParam to retrieve value of + // screen number if it is specified + // + // command line format: [screen] + // + TBufArg procArg(_L("")); + TInt screenArg = KDefaultScreen; + + GetProcArg(aParam, procArg); + GetScreenArg(aParam, screenArg); + + TInt ii; + for(ii=0;iiConstructL(aFunctionNo,aScreenNumber); + CleanupStack::Pop(self); + return self; + } + +CProcess* CProcess::NewTL(TInt aFunctionNo,TInt aScreenNumber,TRequestStatus* aStatus /*=NULL*/) + { + CProcess* self=new(ELeave) CProcess(); + CleanupStack::PushL(self); + self->ConstructTL(aFunctionNo,aScreenNumber,aStatus); + CleanupStack::Pop(self); + return self; + } + +CProcess* CProcess::NewThreadL(const TDesC& aName,TThreadFunction aFunction,TThreadStartUp* aPtr + ,TRequestStatus* aStatus) + { + CProcess* self=new(ELeave) CProcess(); + CleanupStack::PushL(self); + self->ConstructL(aName,aFunction,aPtr,aStatus); + CleanupStack::Pop(self); + return self; + } + +CProcess* CProcess::NewThreadRendezvousL(const TDesC& aName,TThreadFunction aFunction,TThreadStartUp* aPtr ,TRequestStatus* aLogonStatus,TRequestStatus& aRendesvouzStatus) + { + CProcess* self=new(ELeave) CProcess(); + CleanupStack::PushL(self); + self->ConstructRendezvousL(aName,aFunction,aPtr,aLogonStatus,aRendesvouzStatus); + CleanupStack::Pop(self); + return self; + } + +CProcess* CProcess::NewThreadRendezvousL(const TDesC& aName,TThreadStartUp* aPtr,TRequestStatus& aRendesvouzStatus) + { + return NewThreadRendezvousL(aName,ThreadInit,aPtr,NULL,aRendesvouzStatus); + } + +CProcess* CProcess::NewThreadL(const TDesC& aName,TThreadStartUp* aPtr) + { + return NewThreadL(aName,ThreadInit,aPtr,NULL); + } + +CProcess* CProcess::NewSimpleThreadL(const TDesC& aName,TThreadStartUp* aPtr,TRequestStatus* aStatus/*=NULL*/) + { + return NewThreadL(aName,SimpleThreadInit,aPtr,aStatus); + } + +_LIT(KSpace," "); +_LIT(KScreenFormat,"%d"); + +void CProcess::ConstructL(TInt aFunctionNo,TInt aScreenNumber/*=KDefaultScreen*/) + { + Close(); + // add screen number into command line param + // format: [screen] + // + TBuf<100> commandLine; + + commandLine = iFunctions[aFunctionNo].iParam; + commandLine.Append(KSpace); + commandLine.Append(KScreenTag); + commandLine.AppendFormat(KScreenFormat,aScreenNumber); + User::LeaveIfError(iOther.Create(RProcess().FileName(),commandLine)); + iCreated|=eOtherCreated; + iOther.Resume(); + } + +void CProcess::ConstructTL(TInt aFunctionNo,TInt aScreenNumber/*=KDefaultScreen*/,TRequestStatus* aStatus) + { + Close(); + TUint flag=eThreadCreated; + TInt err=iThread.Create(iFunctions[aFunctionNo].iParam,iFunctions[aFunctionNo].iFunction + ,KDefaultStackSize,KOtherProcHeapSize,KOtherProcHeapSize,(TAny*)aScreenNumber,EOwnerThread); + User::LeaveIfError(err); + iCreated|=flag; + if (aStatus) + Logon(*aStatus); + iThread.Resume(); + } + + +void CProcess::ConstructL(const TDesC& aName,TThreadFunction aFunction,TThreadStartUp* aPtr,TRequestStatus* aStatus) + { + Close(); + User::LeaveIfError(iThread.Create(aName,aFunction,KDefaultStackSize,KOtherProcHeapSize,KOtherProcHeapSize,aPtr,EOwnerThread)); + iCreated|=eThreadCreated; + if (aStatus) + Logon(*aStatus); + iThread.Resume(); + } + +void CProcess::ConstructRendezvousL(const TDesC& aName,TThreadFunction aFunction,TThreadStartUp* aPtr,TRequestStatus* aLogonStatus,TRequestStatus& aRendezvousStatus) + { + Close(); + User::LeaveIfError(iThread.Create(aName,aFunction,KDefaultStackSize,KOtherProcHeapSize,KOtherProcHeapSize,aPtr,EOwnerThread)); + iCreated|=eThreadCreated; + if (aLogonStatus) + Logon(*aLogonStatus); + + iThread.Rendezvous(aRendezvousStatus); + iThread.Resume(); + } + +void CProcess::Logon(TRequestStatus& aStatus) const + { + if (iCreated&eThreadCreated) + iThread.Logon(aStatus); + else + { + iOther.Logon(aStatus); + } + } + +void CProcess::Terminate(TInt aReason) + { + if (iCreated&eThreadCreated) + iThread.Terminate(aReason); + else + { + iOther.Terminate(aReason); + } + Close(); + } + +void CProcess::Close() + { + if (iCreated&eOtherCreated) + iOther.Close(); + if (iCreated&eThreadCreated) + iThread.Close(); + iCreated=0; + } + +CProcess::~CProcess() + { + Close(); + } + +TBool CProcess::StillAlive() + { + if (iCreated&eOtherCreated) + return iOther.ExitType()==EExitPending; + return iThread.ExitType()==EExitPending; + } + +void CProcess::LeaveIfDied() //Can Leave + { + User::After(200000); //0.2 secs + if (StillAlive()) + return; + if (iCreated&eOtherCreated) + User::Leave(iOther.ExitReason()); + User::Leave(iThread.ExitReason()); + } + +const TInt KFirstInstanceId = 1; +const TInt KOtherInstanceId = 2; + +TBool CProcess::ProcessDied(TInt aScreenNo/*=KDefaultScreen*/) + { + _LIT(pName,"TAutoServer*"); + TFindProcess find(pName); + TFullName name; + + TBool found = EFalse; + TInt instanceId = aScreenNo==KDefaultScreen? KFirstInstanceId : KOtherInstanceId; + // find the correct instance of the process + // required in multi display test + while (!found && find.Next(name)==KErrNone) + { + TPtrC scrId = name.Right(1); + TInt id; + TLex lex(scrId); + lex.Val(id); + if (id==instanceId) + found = ETrue; + } + if (!found) + return EFalse; + + RProcess p; + p.Open(name); + if (p.Id()!=RProcess().Id()) + return EFalse; + p.Close(); + return (find.Next(name)!=KErrNone); + } + +TInt CProcess::ThreadInit(TAny *aPtr) + { + __UHEAP_MARK; + TInt err=KErrNone; + CTrapCleanup* CleanUpStack=CTrapCleanup::New(); + if (CleanUpStack==NULL) + err=KErrNoMemory; + else + { + TRAP(err,InitialiseL(STATIC_CAST(TThreadStartUp*,aPtr))) + delete CleanUpStack; + } + __UHEAP_MARKEND; + return(err); + } + +void CProcess::InitialiseL(TThreadStartUp* aPtr) + { + CActiveScheduler* activeScheduler=new(ELeave) CActiveScheduler; + CActiveScheduler::Install(activeScheduler); + CleanupStack::PushL(activeScheduler); + aPtr->iInitFunction(aPtr->iParam); + CActiveScheduler::Start(); + CleanupStack::PopAndDestroy(activeScheduler); + } + +TInt CProcess::SimpleThreadInit(TAny *aPtr) + { + __UHEAP_MARK; + TInt err=KErrNone; + CTrapCleanup* CleanUpStack=CTrapCleanup::New(); + if (CleanUpStack==NULL) + err=KErrNoMemory; + else + { + TThreadStartUp* ptr=STATIC_CAST(TThreadStartUp*,aPtr); + ptr->iInitFunction(ptr->iParam); + delete CleanUpStack; + } + __UHEAP_MARKEND; + return(err); + } + +/*CMinWin*/ + +CMinWin::CMinWin(TInt aScreenNo): iScreenNo(aScreenNo) + {} + +void CMinWin::ConstructL() + { + User::LeaveIfError(iWs.Connect()); + iScr=new(ELeave) CWsScreenDevice(iWs); + User::LeaveIfError(iScr->Construct(iScreenNo)); + iGroup=RWindowGroup(iWs); + User::LeaveIfError(iGroup.Construct(8970+iScreenNo,ETrue)); + iWin=RWindow(iWs); + User::LeaveIfError(iWin.Construct((RWindowTreeNode)iGroup,(TUint32)this)); + iRect=TSize(10,10); + iWin.SetExtent(TPoint(0,0),iRect.Size()); + iWin.SetRequiredDisplayMode(EColor256); + iWin.SetBackgroundColor(KRgbGreen); + iWin.Activate(); + iGc=new(ELeave) CWindowGc(iScr); + User::LeaveIfError(iGc->Construct()); + + Draw(iRect); + iWs.Flush(); + } + +CMinWin::~CMinWin() + { + delete iGc; + iWin.Close(); + iGroup.Close(); + delete iScr; + iWs.Close(); + } + +void CMinWin::Draw(const TRect& aRect) + { + iWin.BeginRedraw(); + iGc->Activate(iWin); + iGc->SetPenStyle(CGraphicsContext::ENullPen); + iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + iGc->SetBrushColor(KRgbGreen); + iGc->DrawRect(aRect); + iGc->Deactivate(); + iWin.EndRedraw(); + } + + +/*CTimeOut*/ + +void CTimeOut::ConstructL() + { + CTimer::ConstructL(); + CActiveScheduler::Add(this); + } + +void CTimeOut::Start(TTimeIntervalMicroSeconds32 aInterval,TCallBack aCallBack) + { + iCallBack=aCallBack; + After(aInterval); + } + +void CTimeOut::RunL() + { + iCallBack.CallBack(); + } + +/* + * Simply returns the DisplayMode as a string. Used to display mode details on test results. + */ +GLDEF_C TPtrC DisplayModeAsString(TDisplayMode aMode) + { + + TPtrC modeAsString; + + switch(aMode) + { + case ENone: + _LIT(KENoneMode,"ENone"); + modeAsString.Set(KENoneMode); + break; + case EGray2: + _LIT(KEGray2Mode,"EGray2"); + modeAsString.Set(KEGray2Mode); + break; + case EGray4: + _LIT(KEGray4Mode,"EGray4"); + modeAsString.Set(KEGray4Mode); + break; + case EGray16: + _LIT(KEGray16Mode,"EGray16"); + modeAsString.Set(KEGray16Mode); + break; + case EGray256: + _LIT(KEGray256Mode,"EGray256"); + modeAsString.Set(KEGray256Mode); + break; + case EColor16: + _LIT(KEColor16Mode,"EColor16"); + modeAsString.Set(KEColor16Mode); + break; + case EColor256: + _LIT(KEColor256Mode,"EColor256"); + modeAsString.Set(KEColor256Mode); + break; + case EColor64K: + _LIT(KEColor64KMode,"EColor64K"); + modeAsString.Set(KEColor64KMode); + break; + case EColor16M: + _LIT(KEColor16MMode,"EColor16M"); + modeAsString.Set(KEColor16MMode); + break; + case EColor4K: + _LIT(KEColor4KMode,"EColor4K"); + modeAsString.Set(KEColor4KMode); + break; + case EColor16MU: + _LIT(KEColor16MUMode,"EColor16MU"); + modeAsString.Set(KEColor16MUMode); + break; + case EColor16MA: + _LIT(KEColor16MAMode,"EColor16MA"); + modeAsString.Set(KEColor16MAMode); + break; + case EColor16MAP: + _LIT(KEColor16MAPMode,"EColor16MAP"); + modeAsString.Set(KEColor16MAPMode); + break; + default: + _LIT(KUnknownMode,"Unknown"); + modeAsString.Set(KUnknownMode); + break; + } + + return modeAsString; + } + +// Check if an area of a bitmap is of a certain color +GLDEF_C TBool LossyCheckBlankBitmap(const CFbsBitmap& aBitmap, const TRect aArea, const TRgb aCheckColor, TBool aLossyCompare) + { + const TReal errorLimit = (aLossyCompare ? 0.05 : 0.00); //Lossy(default) or exact compare? + + TBool result = ETrue; + /* TInt mismatchedPixels = 0; */ // -- Useful for debugging + TRgb bitmapPix = TRgb(0,0,0,0); //testWin Pixel + for (TInt x = 0; x < aArea.Size().iWidth; x++) + { + for (TInt y = 0; y < aArea.Size().iHeight; y++) + { + aBitmap.GetPixel(bitmapPix, TPoint(x,y)); + + //Check if there are differeces in color between the bitmap and the test color + if(((TReal)abs(bitmapPix.Red() - aCheckColor.Red())/255) > errorLimit || + ((TReal)abs(bitmapPix.Blue() - aCheckColor.Blue())/255) > errorLimit || + ((TReal)abs(bitmapPix.Green() - aCheckColor.Green())/255) > errorLimit || + ((TReal)abs(bitmapPix.Alpha() - aCheckColor.Alpha())/255) > errorLimit) + { + /* mismatchedPixels++; */ // -- Useful for debugging + result = EFalse; + break; + } + } + } + + /* INFO_PRINTF2(_L("Number of different pixels: %i"), mismatchedPixels); */ // -- Useful for debugging + return result; + } + +// Compare a section of two bitmaps +GLDEF_C TBool LossyCompareBitmap(const CFbsBitmap& aBitmap1, const CFbsBitmap& aBitmap2, const TRect aCompareRect, TBool aLossyCompare) + { + const TReal errorLimit = (aLossyCompare ? 0.05 : 0.00); //Lossy or Exact compare? + + TBool result = ETrue; + + if (aBitmap1.DisplayMode() != aBitmap2.DisplayMode()) + { + RDebug::Printf(" DisplayMode difference %d, %d", aBitmap1.DisplayMode(), aBitmap2.DisplayMode()); + } + + TRgb bitmap1Pix = TRgb(0,0,0,0); + TRgb bitmap2Pix = TRgb(0,0,0,0); + for (TInt x = 0; x < aCompareRect.Size().iWidth; x++) + { + for (TInt y = 0; y < aCompareRect.Size().iHeight; y++) + { + aBitmap1.GetPixel(bitmap1Pix, TPoint(x,y)); + aBitmap2.GetPixel(bitmap2Pix, TPoint(x,y)); + + //Check if there are differences between the colors of the two bitmaps + if(((TReal)abs(bitmap1Pix.Red() - bitmap2Pix.Red())/255) > errorLimit || + ((TReal)abs(bitmap1Pix.Blue() - bitmap2Pix.Blue())/255) > errorLimit || + ((TReal)abs(bitmap1Pix.Green() - bitmap2Pix.Green())/255) > errorLimit || + ((TReal)abs(bitmap1Pix.Alpha() - bitmap2Pix.Alpha())/255) > errorLimit) + { + /* + * There was a difference so return without checking the rest of the + * bitmap. If you are seeing Lossy compare errors, and want to diagnose + * further, consider switching over to using a recording version of this + * function, LossyCompareBitmapRecord() + */ + result = EFalse; + break; + } + } + } + + return result; + } + +/** + * Compare two bitmaps, optionally a lossy comparison, recording any differences and saving bitmaps + * + * @param aBitmap1 Bitmap being checked + * @param aBitmap2 Reference Bitmap + * @param aCompareRect Area of bitmap to compare + * @param aLossyCompare ETrue means use a lossy compare strategy, else do an exact compare + * @param aPixelsDifferent Returned value representing the number of pixels which are different + * @param aLogger Facility for logging to be reported by this function + * @return ETrue if the bitmaps are the same (or similar). + * Otherwise EFalse, with logging reporting the differences, and bitmaps saved in c:\logs\ + * @pre c:\logs directory must exist + */ +GLDEF_C TBool LossyCompareBitmapRecord(CFbsBitmap& aBitmap1, CFbsBitmap& aBitmap2, const TRect aCompareRect, TBool aLossyCompare, TInt& aPixelsDifferent, CTestExecuteLogger& aLogger) + { + const TReal errorLimit = (aLossyCompare ? 0.05 : 0.00); //Lossy or Exact compare? + + TBool result = ETrue; + TInt mismatchedPixels = 0; + TRgb bitmap1Pix = TRgb(0,0,0,0); + TRgb bitmap2Pix = TRgb(0,0,0,0); + if (aBitmap1.DisplayMode() != aBitmap2.DisplayMode()) + { + aLogger.LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, + _L(" DisplayMode difference %d, %d"), aBitmap1.DisplayMode(), aBitmap2.DisplayMode()); + } + for (TInt x = 0; x < aCompareRect.Size().iWidth; x++) + { + for (TInt y = 0; y < aCompareRect.Size().iHeight; y++) + { + aBitmap1.GetPixel(bitmap1Pix, TPoint(x,y)); + aBitmap2.GetPixel(bitmap2Pix, TPoint(x,y)); + + //Check if there are differences between the colors of the two bitmaps + if(((TReal)abs(bitmap1Pix.Red() - bitmap2Pix.Red())/255) > errorLimit || + ((TReal)abs(bitmap1Pix.Blue() - bitmap2Pix.Blue())/255) > errorLimit || + ((TReal)abs(bitmap1Pix.Green() - bitmap2Pix.Green())/255) > errorLimit || + ((TReal)abs(bitmap1Pix.Alpha() - bitmap2Pix.Alpha())/255) > errorLimit) + { + mismatchedPixels++; + + aLogger.LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, + _L(" Pixel difference %d,%d: %d"),x,y, bitmap1Pix.Difference(bitmap2Pix)); + result = EFalse; + // we loop around again to pick up all the differences + } + } + } + aPixelsDifferent = mismatchedPixels; + + /* + * When the bitmaps are different, we store them locally in c:\\logs in + * timestamped files. Save() is a non-const method; this is why aBitmap1 + * and aBitmap2 are non-const. Saving can fail, perhaps because we have + * exceeded storage limits. + */ + if (!result) + { + TTime now; + now.UniversalTime(); + TInt timestamp = I64INT(now.Int64() & 0x7fffffffu); + timestamp/=1000; // a millisecond resolution is easier to track + TFileName mbmFileSrc; + mbmFileSrc.Format (_L("c:\\logs\\%d_LossyCompareBitmap1.mbm"), timestamp); + TFileName mbmFileDst; + mbmFileDst.Format (_L("c:\\logs\\%d_LossyCompareBitmap2.mbm"), timestamp); + TInt saveResult1; + TInt saveResult2; + saveResult1 = aBitmap1.Save(mbmFileSrc); + saveResult2 = aBitmap2.Save(mbmFileDst); + if (saveResult1 == KErrNone && saveResult2 == KErrNone) + { + aLogger.LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, + _L(" Bitmaps are different: see %S, %S"), &mbmFileSrc, &mbmFileDst); + } + else + { + aLogger.LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, + _L(" Bitmaps are different, but could not save files into c:\\logs : %d %d"), saveResult1, saveResult2); + } + } + + return result; + } + +// Check if an area of a screen is of a certain color +GLDEF_C TBool LossyCheckBlankWindow(const CWsScreenDevice& aScreen, CFbsBitmap& aBitmap, const TRect aArea, const TRgb aCheckColor) + { + aScreen.CopyScreenToBitmap(&aBitmap, aArea); + return LossyCheckBlankBitmap(aBitmap, aArea, aCheckColor); + } + +// Compare a section of two windows on the screen +GLDEF_C TBool LossyCompareWindow(const CWsScreenDevice& aScreen, CFbsBitmap& aBitmap1, CFbsBitmap& aBitmap2, const TRect aCompareRect) + { + aScreen.CopyScreenToBitmap(&aBitmap1, aCompareRect); + aScreen.CopyScreenToBitmap(&aBitmap2, aCompareRect); + return LossyCompareBitmap(aBitmap1, aBitmap2, aCompareRect); + } + diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/AUTODLL.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/AUTODLL.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,2858 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Auto test Animated DLL functions +// +// + +#include +#include +#include +#include +#include "AUTODLL.H" +#include "TAnimDraw.h" +#include "eventdd.h" +#include +#include + +union TAnimArgUnion + { + const TAny* any; + const TBool* Bool; + const TInt* Int; + const TPoint* Point; + const TSize* Size; + const TRect* Rect; + const TSpriteMemberInfo* SpriteMemberInfo; + const TShadowDrawTest* ShadowDrawTest; + const TDrawTestScreen* DrawTestScreen; + const TSyncTests* SyncTests; + const TTimeChangeTest* TimeChangeTest; + const TAnimRawEvent* AnimRawEvent; + const TWindowGroupInfoParms* WindowGroupInfoParms; + const TSetOrdinalParms* SetOrdinalParms; + const TFrameData* FrameData; + const TRawEvent* RawEvent; + }; + +class CPanicAnim : public CWindowAnim + { + enum TSyncState + { + ESyncStateNull, + ESyncStateStarting, + ESyncStateCounting, + ESyncLeave, + ESyncStateTimeChange1, + ESyncStateTimeChange2, + ESyncStateTimeChange3 + }; + enum {ESyncCount=8}; +public: + ~CPanicAnim(); + virtual void ConstructL(TAny *aArgs, TBool aHasFocus); + virtual void Animate(TDateTime *aDateTime); + virtual void Redraw(); + virtual void Command(TInt aOpcode, TAny *aArgs); + virtual TInt CommandReplyL(TInt aOpcode, TAny *aArgs); + virtual void FocusChanged(TBool aState); + //Pure virtual function from MEventHandler + virtual TBool OfferRawEvent(const TRawEvent &aRawEvent); +private: + void StartSyncTest(MAnimGeneralFunctions::TAnimSync aSync); + void StartTimeChangeTest(); + void DoLeaveInActiveCallback(); + static TInt LeaveInActiveCallback(TAny *aThis); +private: + TRequestStatus *iStatusPtr; + TRequestStatus *iStatusPtr2; + TTime iTime; + TInt iSyncCount; + TSyncState iSyncState; + MAnimGeneralFunctions::TAnimSync iSyncMode; + TBool iLeaveInRedraw; + CIdle* iActivePanicIdle; + }; + +class CPanicAnim2 : public CWindowAnim +// +// Simply panics in the ConstructL() +// + { +public: + virtual void ConstructL(TAny *aArgs, TBool aHasFocus); + virtual void Animate(TDateTime *aDateTime); + virtual void Redraw(); + virtual void Command(TInt aOpcode, TAny *aArgs); + virtual TInt CommandReplyL(TInt aOpcode, TAny *aArgs); + virtual void FocusChanged(TBool aState); + //Pure virtual function from MEventHandler + virtual TBool OfferRawEvent(const TRawEvent &aRawEvent); + }; + +class CAutoAnim3 : public CWindowAnim +// +// test drawing/redrawing +// + { +public: + virtual void ConstructL(TAny *aArgs, TBool aHasFocus); + virtual void Animate(TDateTime *aDateTime); + virtual void Redraw(); + virtual void Command(TInt aOpcode, TAny *aArgs); + virtual TInt CommandReplyL(TInt aOpcode, TAny *aArgs); + virtual void FocusChanged(TBool aState); + void Draw(const TRect &aRect); + void DrawTestScreenL(const TDrawTestScreen* aParams); + //Pure virtual function from MEventHandler + virtual TBool OfferRawEvent(const TRawEvent &aRawEvent); +private: + TRequestStatus *iStatusPtr; + CFbsFont *iFont; + TRect iRect; + TRect iBaseRect; + TInt iMode; + }; + +class CAutoAnimScrBack : public CWindowAnim +// +// test anim drawing behind a backed up window +// + { +public: + virtual void ConstructL(TAny *aArgs, TBool aHasFocus); + virtual void Animate(TDateTime *aDateTime); + virtual void Redraw(); + virtual void Command(TInt aOpcode, TAny *aArgs); + virtual TInt CommandReplyL(TInt aOpcode, TAny *aArgs); + virtual void FocusChanged(TBool aState); + void Draw(); + //Pure virtual function from MEventHandler + virtual TBool OfferRawEvent(const TRawEvent &aRawEvent); +private: + TRect iRect; + TInt iMode; + }; + +class CTestSpriteAnim : public CSpriteAnim + { +public: + virtual void ConstructL(TAny *aArgs); + virtual void Animate(TDateTime *aDateTime); + virtual void Command(TInt aOpcode, TAny *aArgs); + virtual TInt CommandReplyL(TInt aOpcode, TAny *aArgs); + //Pure virtual function from MEventHandler + virtual TBool OfferRawEvent(const TRawEvent &aRawEvent); +private: + TBool CheckMember(const TSpriteMemberInfo& aMemInfo); + void DrawMemberL(TInt aMember); + void DrawMemberL(); + }; + +/** +Used by CAnimTimer below +*/ +class MAnimTimerObserver + { +public: + virtual void DisplayNextFrameL()=0; + }; + +/** +This class is used by CTestFreeTimerAnim to determine when to swap the current frame with the next one. +*/ +class CAnimTimer : public CTimer + { +public: + ~CAnimTimer(); + static CAnimTimer* NewL(MAnimTimerObserver& aObserver); + void RunL(); +private: + CAnimTimer(MAnimTimerObserver& aObserver); + void ConstructL(); +private: + MAnimTimerObserver& iAnim; + }; + +class CTestFreeTimerAnim : public CFreeTimerWindowAnim, public MAnimTimerObserver + { +public: + //from CBase + ~CTestFreeTimerAnim(); + //from CAnim + void Animate(TDateTime *aDateTime); + void Command(TInt aOpcode, TAny *aArgs); + TInt CommandReplyL(TInt aOpcode, TAny *aArgs); + //from CWindowAnim + void ConstructL(TAny *aArgs, TBool aHasFocus); + void Redraw(); + void FocusChanged(TBool aState); + //from MEventHandler + TBool OfferRawEvent(const TRawEvent &aRawEvent); +private: + void DisplayNextFrameL(); +private: + CAnimTimer* iTimer; + TInt iFrameTime; + TRgb iColour; + TRect iRect; + }; + +class CEventTestAnimBase : public CWindowAnim + { + enum {EEventBufferSize=40}; +public: + virtual ~CEventTestAnimBase(); + //Pure virtual functions from CAnim + virtual void Animate(TDateTime *aDateTime); + virtual void Command(TInt aOpcode, TAny *aArgs); + virtual TInt CommandReplyL(TInt aOpcode, TAny *aArgs); + //Pure virtual functions from CWindowAnim + virtual void ConstructL(TAny *aArgs, TBool aHasFocus); + virtual void Redraw(); + virtual void FocusChanged(TBool aState); + //Pure virtual function from MEventHandler + virtual TBool OfferRawEvent(const TRawEvent &aRawEvent); +protected: + void Fail(); + TBool IsIgnorableEvent(const TRawEvent& aRawEvent) const; + TBool GetNextExpectedEvent(TAnimRawEvent& aRawEvent); + TBool CompareEvents(const TRawEvent& aExpectedEvent, const TRawEvent& aActualEvent) const; + TBool HandleRecursiveEvent(const TRawEvent& aRawEvent); + + TInt Error() const; + TInt EventCount() const; + void ResetEventCount(); + TInt TotalExpectedEvents() const; + TInt AddEvent(const TAnimRawEvent* event); +private: + virtual TInt AddExpectedEvent(const TAnimRawEvent* event)=0; +private: + CCirBuf iExpectedEvents; + TInt iError; + TInt iEventCount; + }; + +class CEventTestAnim : public CEventTestAnimBase + { +public: + ~CEventTestAnim(); + //Pure virtual functions from CWindowAnim overridden in CEventTestAnimBase + void ConstructL(TAny* aArgs,TBool aHasFocus); + //Pure virtual functions from CAnim overridden in CEventTestAnimBase + TInt CommandReplyL(TInt aOpcode,TAny* aArgs); + void Command(TInt aOpcode,TAny* aArgs); +private: + TInt UnloadDeviceDriver(); + //Pure virtual function from CEventTestAnimBase + TInt AddExpectedEvent(const TAnimRawEvent* event); +private: + TBool iDevDriverLoaded; + REventDD iLdd; + }; + +class CEventPostingAnim : public CEventTestAnimBase + { +public: + ~CEventPostingAnim(); + //Virtual functions from CEventTestAnimBase + virtual void ConstructL(TAny *aArgs, TBool aHasFocus); + //Virtual function from MEventHandler + virtual TBool OfferRawEvent(const TRawEvent &aRawEvent); +private: + //Pure virtual function from CEventTestAnimBase + virtual TInt AddExpectedEvent(const TAnimRawEvent* event); + }; + +class CRemovableAnim : public CEventTestAnimBase + { +public: + ~CRemovableAnim(); + //Virtual functions from CEventTestAnimBase + virtual TInt CommandReplyL(TInt aOpcode, TAny *aArgs); + virtual TBool OfferRawEvent(const TRawEvent &aRawEvent); +private: + //Pure virtual function from CEventTestAnimBase + virtual TInt AddExpectedEvent(const TAnimRawEvent* event); +private: + TInt iLifetime; + }; + +class CTimerTestAnim : public CWindowAnim + { +public: + ~CTimerTestAnim(); + //Pure virtual functions from CAnim + virtual void Animate(TDateTime *aDateTime); + virtual void Command(TInt aOpcode, TAny *aArgs); + virtual TInt CommandReplyL(TInt aOpcode, TAny *aArgs); + //Pure virtual functions from CWindowAnim + virtual void ConstructL(TAny *aArgs, TBool aHasFocus); + virtual void Redraw(); + virtual void FocusChanged(TBool aState); + //Pure virtual function from MEventHandler + virtual TBool OfferRawEvent(const TRawEvent &aRawEvent); +private: + TInt iTimerCount; + TBool iExpectingTicks; + TBool iFail; + }; + +class CWinFunctionTestAnim : public CWindowAnim + { + //enum {EEventBufferSize=40}; +public: + ~CWinFunctionTestAnim(); + //Pure virtual functions from CAnim + virtual void Animate(TDateTime *aDateTime); + virtual void Command(TInt aOpcode, TAny *aArgs); + virtual TInt CommandReplyL(TInt aOpcode, TAny *aArgs); + //Pure virtual functions from CWindowAnim + virtual void ConstructL(TAny *aArgs, TBool aHasFocus); + virtual void Redraw(); + virtual void FocusChanged(TBool aState); + //Pure virtual function from MEventHandler + virtual TBool OfferRawEvent(const TRawEvent &aRawEvent); +private: + MAnimGeneralFunctionsWindowExtension* iWinFunctions; + }; + +class CNotificationTestAnim : public CWindowAnim + { +public: + CNotificationTestAnim(); + ~CNotificationTestAnim(); + //Pure virtual functions from CAnim + virtual void HandleNotification(const TWsEvent& aEvent); + virtual void Animate(TDateTime *aDateTime); + virtual void Command(TInt aOpcode, TAny *aArgs); + virtual TInt CommandReplyL(TInt aOpcode, TAny *aArgs); + //Pure virtual functions from CWindowAnim + virtual void ConstructL(TAny *aArgs, TBool aHasFocus); + virtual void Redraw(); + virtual void FocusChanged(TBool aState); + //Pure virtual function from MEventHandler + virtual TBool OfferRawEvent(const TRawEvent &aRawEvent); +private: + TFixedArray iDSA; + TBool iHeartbeatState; + TBool iScreenDeviceChanged; + TTime iLastAnimTime; + }; + +class CTransAnim : public CWindowAnim +// +// Test drawing/redrawing in Transparent window. +// + { +public: + //Implementaion for pure virtual functions from CAnim + void ConstructL(TAny* aArgs, TBool aHasFocus); + void Animate(TDateTime* aDateTime); + void Redraw(); + void Command(TInt aOpcode, TAny* aArgs); + TInt CommandReplyL(TInt aOpcode, TAny* aArgs); + void FocusChanged(TBool aState); + TBool OfferRawEvent(const TRawEvent &aRawEvent); +private: + CFbsFont* iFont; + TRect iRect; + TInt iMode; + TInt iDraw; + TRgb iColor; + TInt iCount; + }; + +class CTestHandlerAnim : public CWindowAnim + { + public: + ~CTestHandlerAnim(); + void ConstructL(TAny* aArgs, TBool aHasFocus); + void Redraw(); + void FocusChanged(TBool aState); + TInt CommandReplyL(TInt aOpcode, TAny* aArgs); + void Command(TInt aOpcode, TAny* aArgs); + void Animate(TDateTime* aDateTime); + TBool OfferRawEvent(const TRawEvent &aRawEvent); + private: + }; + +class CCoverageAnim : public CWindowAnim +/** + This class adds functional coverage to CWsAnimGc. + The actual work is handled by the 'Draw' method which calls + each method in turn. + Mostly copied from CAutoAnimScrBack and CAutoAnim3. + @SYMTestCaseID + @SYMPREQ 1841 Add Coverage tests. + @SYMTestCaseDesc Functional coverage. + @SYMTestActions Run functional coverage test on CWsAnimGc. + */ + { +public: + ~CCoverageAnim(); + virtual void ConstructL(TAny *aArgs, TBool aHasFocus); + virtual void Animate(TDateTime *aDateTime); + virtual void Redraw(); + virtual void Command(TInt aOpcode, TAny *aArgs); + virtual TInt CommandReplyL(TInt aOpcode, TAny *aArgs); + virtual void FocusChanged(TBool aState); + void Draw(); + //Pure virtual function from MEventHandler + virtual TBool OfferRawEvent(const TRawEvent &aRawEvent); +private: + TRect iRect; /** rectangle used for all draw ops that require one */ + CFbsFont* iFont; + }; + +class CMultiPointerAnim : public CWindowAnim + { + enum {EEventBufferSize=40}; +public: + virtual ~CMultiPointerAnim(); + //Pure virtual functions from CAnim + virtual void Animate(TDateTime *aDateTime); + virtual void Command(TInt aOpcode, TAny *aArgs); + virtual TInt CommandReplyL(TInt aOpcode, TAny *aArgs); + //Pure virtual functions from CWindowAnim + virtual void ConstructL(TAny *aArgs, TBool aHasFocus); + virtual void Redraw(); + virtual void FocusChanged(TBool aState); + //Pure virtual function from MEventHandler + virtual TBool OfferRawEvent(const TRawEvent &aRawEvent); +protected: + TInt AddEvent(const TAnimRawEvent* aEvent); + TBool CompareEvents(const TRawEvent& aExpectedEvent, const TRawEvent& aActualEvent); +private: + CCirBuf iExpectedEvents; + TBuf<255> iErrorDes; + TInt iEventCount; + TInt iError; + }; + +class CTestAnimDll : public CAnimDll + { +public: + CAnim *CreateInstanceL(TInt aType); +private: + }; + +/*#if defined(__WINS__) +#pragma data_seg(".E32_UID") +__WINS_UID(0, KWservAnimDllUidValue, 0) +#pragma data_seg() +#endif*/ + +EXPORT_C CAnimDll *CreateCAnimDllL() + { + return(new(ELeave) CTestAnimDll()); + } + + +// Panic Tests // +void CPanicAnim::ConstructL(TAny *, TBool ) + { + iWindowFunctions->SetRect(TRect(0,0,1,1)); + iFunctions->SetSync(MAnimGeneralFunctions::ESyncSecond); + if (iFunctions->Sync()!=MAnimGeneralFunctions::ESyncSecond) + User::Leave(KErrGeneral); +// Check the anim time is not ahead of and not more than 2 secs behind the system time + TTime now; + now.UniversalTime(); + TDateTime dt=now.DateTime(); + TDateTime adt=iFunctions->SystemTime(); + if (adt.Day()!=dt.Day()) + User::Leave(KErrGeneral); + + iFunctions->SetSync(MAnimGeneralFunctions::ESyncNone); + if (iFunctions->Sync()!=MAnimGeneralFunctions::ESyncNone) + User::Leave(KErrGeneral); + } + +CPanicAnim::~CPanicAnim() + { + delete iActivePanicIdle; + } + +void CPanicAnim::Animate(TDateTime *aDateTime) + { + switch(iSyncState) + { + case ESyncStateNull: + break; + case ESyncStateStarting: + iTime=iFunctions->SystemTime(); + iSyncState=ESyncStateCounting; + iSyncCount=0; + break; + case ESyncStateCounting: + if (aDateTime) + { + TTimeIntervalSeconds interval; + TTime(*aDateTime).SecondsFrom(iTime, interval); + iSyncCount=interval.Int(); + } + else + iSyncCount++; + if (iSyncCount==ESyncCount) + { + TTimeIntervalMicroSeconds minInterval(0); + TTimeIntervalMicroSeconds maxInterval(0); + iSyncState=ESyncStateNull; + switch(iSyncMode) + { + case MAnimGeneralFunctions::ESyncSecond: + minInterval=iSyncCount*1000000-100000; + maxInterval=iSyncCount*1000000+100000; + break; + default:; + } + TTime time(iFunctions->SystemTime()); + TTimeIntervalMicroSeconds interval=time.MicroSecondsFrom(iTime); + TInt ret=KErrNone; + if (intervalmaxInterval) + ret=KErrGeneral; + iFunctions->Client().RequestComplete(iStatusPtr,ret); + } + break; + case ESyncLeave: + User::Leave(KErrGeneral); // Test: Not allowed to leave, will cause a panic + break; + case ESyncStateTimeChange1: + if (!aDateTime) + { + iFunctions->Client().RequestComplete(iStatusPtr,KErrNone); + iSyncState=ESyncStateTimeChange2; + } + break; + case ESyncStateTimeChange2: + if (!aDateTime) + { + iSyncState=ESyncStateTimeChange3; + break; + } + case ESyncStateTimeChange3: + iFunctions->Client().RequestComplete(iStatusPtr2,aDateTime ? KErrNone : KErrGeneral); + iSyncState=ESyncStateNull; + break; + } + } + +void CPanicAnim::Redraw() + { + if (iLeaveInRedraw) + User::Leave(KErrGeneral); //Test: Not allowed to leave, will cause a panic + } + +void CPanicAnim::Command(TInt aOpcode, TAny *) + { + switch(aOpcode) + { + case EADllPanicCallPanic: + iFunctions->Panic(); + break; + case EADllPanicSetInterval: + iFunctions->SetSync(MAnimGeneralFunctions::ESyncSecond); + iFunctions->SetInterval(1); + break; + case EADllPanicSetNextInterval: + iFunctions->SetSync(MAnimGeneralFunctions::ESyncMinute); + iFunctions->SetNextInterval(1); + break; + case EADllPanicDoubleActivateGC: + iWindowFunctions->ActivateGc(); + iWindowFunctions->ActivateGc(); + break; + case EADllPanicDrawRectWithNoGc: + iGc->DrawRect(TRect(0,0,10,10)); + break; + case EADllPanicDrawTextWithNoFont: + iWindowFunctions->ActivateGc(); + iGc->DrawText(_L("Panic"),TPoint(20,20)); + break; + case EADllPanicLeaveInAnimate: + iFunctions->SetSync(MAnimGeneralFunctions::ESyncFlash); + iSyncState=ESyncLeave; + break; + case EADllPanicLeaveInRedraw: + iLeaveInRedraw=ETrue; + iWindowFunctions->Invalidate(TRect(0,0,10,10)); + break; + case EADllPanicLeave: + //tests a leaving function in a non-leaving function and should not be moved to CommandReplyL as it leaves + User::Leave(KErrGeneral); //LeaveScan: intentional test + break; + case EADllPanicSetVisWithGcActive: + iWindowFunctions->ActivateGc(); + iWindowFunctions->SetVisible(EFalse); + iWindowFunctions->SetVisible(ETrue); + break; + case EADllPanicLeaveInActiveCallback: + iActivePanicIdle=CIdle::NewL(EPriorityHigh); + iActivePanicIdle->Start(TCallBack(CPanicAnim::LeaveInActiveCallback,this)); + break; + case EADllPanicSetClippingRectWithNoGc: + { + // currently this test fails because when deactivated iWin is also NULL and is deferenced in function + TRect rect(20,20,20,20); + iGc->SetClippingRect(rect); + } + break; + case EADllPanicCancelClippingRegionWithNoGc: + // currently this test fails because when deactivated iWin is NULL and function leaves + iGc->CancelClippingRegion(); + break; + case EADllPanicCancelClippingRectWithNoGc: + // currently this test fails because when deactivated iWin is also NULL and is deferenced in function + iGc->CancelClippingRect(); + break; + case EADllPanicSetDrawModeWithNoGc: + iGc->SetDrawMode(CGraphicsContext::EDrawModeAND); + break; + case EADllPanicUseFontWithNoGc: + { + // currently this test fails because does not check for NULL font + CFbsFont* font = NULL; + iGc->UseFont(font); + } + break; + case EADllPanicDiscardFontWithNoGc: + iGc->DiscardFont(); + break; + case EADllPanicSetUnderlineStyleWithNoGc: + iGc->SetUnderlineStyle(EUnderlineOff); + break; + case EADllPanicSetStrikeThoughStyleWithNoGc: + iGc->SetStrikethroughStyle(EStrikethroughOff); + break; + case EADllPanicSetWordJustificationWithNoGc: + iGc->SetWordJustification(0,0); + break; + case EADllPanicSetCharJustificationWithNoGc: + iGc->SetCharJustification(0,0); + break; + case EADllPanicSetPenColorWithNoGc: + { + TRgb rgbs; + iGc->SetPenColor(rgbs); + } + break; + case EADllPanicSetPenStyleWithNoGc: + iGc->SetPenStyle(CGraphicsContext::ESolidPen); + break; + case EADllPanicSetPenSizeWithNoGc: + { + const TSize size; + iGc->SetPenSize(size); + } + break; + case EADllPanicSetBrushColorWithNoGc: + { + TRgb rgbs; + iGc->SetBrushColor(rgbs); + } + break; + case EADllPanicSetBrushStyleWithNoGc: + iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + break; + case EADllPanicSetBrushOriginWithNoGc: + { + TPoint point; + iGc->SetBrushOrigin(point); + } + break; + case EADllPanicUseBrushPatterWithNoGc: + { + CFbsBitmap* bitmap = new(ELeave) CFbsBitmap(); + CleanupStack::PushL(bitmap); + User::LeaveIfError(bitmap->Create(TSize(16,16),EGray4)); + iGc->UseBrushPattern(bitmap); + CleanupStack::PopAndDestroy(bitmap); + } + break; + case EADllPanicDiscardBrushPatternWithNoGc: + iGc->DiscardBrushPattern(); + break; + case EADllPanicSetFadedWithNoGc: + iGc->SetFaded(EFalse); + break; + case EADllPanicSetFadingParametersWithNoGc: + iGc->SetFadingParameters(1,1); + break; + case EADllPanicDrawArcWithNoGc: + { + TRect rect; + iGc->DrawArc(rect, + TPoint(rect.Center().iX, rect.iTl.iY), + TPoint(rect.iBr.iX, rect.Center().iY)); + } + break; + case EADllPanicDrawPieWithNoGc: + { + TRect rect; + iGc->DrawPie(rect, TPoint(rect.Center().iX, rect.iTl.iY), TPoint(rect.iBr.iX, rect.Center().iY)); + } + break; + case EADllPanicDrawLineWithNoGc: + { + const TPoint point1; + const TPoint point2; + iGc->DrawLine(point1, point2); + } + break; + case EADllPanicDrawLineToWithNoGc: + { + const TPoint point; + iGc->DrawLineTo(point); + } + break; + case EADllPanicDrawLineByWithNoGc: + { + const TPoint point; + iGc->DrawLineBy(point); + } + break; + case EADllPanicDrawEllipseWithNoGc: + { + TRect rect(20,20,20,20); + iGc->DrawEllipse(rect); + } + break; + case EADllPanicDrawRoundedRecWithNoGc: + { + TRect rect; + iGc->DrawRoundRect(rect, TSize(rect.Width()/8, rect.Height()/8)); + } + break; + case EADllPanicClearWithRectWithNoGc: + { + TRect rect(20,20,20,20); + iGc->Clear(rect); + } + break; + case EADllPanicClearWithNoGc: + iGc->Clear(); + break; + case EADllPanicBitBltWithNoGc: + { + CFbsBitmap* bitmap = new(ELeave) CFbsBitmap(); + CleanupStack::PushL(bitmap); + User::LeaveIfError(bitmap->Create(TSize(16,16),EGray4)); + iGc->BitBlt(TPoint(0, 0), bitmap); + CleanupStack::PopAndDestroy(bitmap); + } + break; + case EADllPanicBitBltWithRectWithNoGc: + { + CFbsBitmap* bitmap = new(ELeave) CFbsBitmap(); + TRect rect; + CleanupStack::PushL(bitmap); + User::LeaveIfError(bitmap->Create(TSize(16,16),EGray4)); + iGc->BitBlt(TPoint(0, 0), bitmap, rect); + CleanupStack::PopAndDestroy(bitmap); + } + break; + case EADllPanicBitBltMaskedWithNoGc: + { + CFbsBitmap* bitmap = new(ELeave) CFbsBitmap(); + TRect rect; + CleanupStack::PushL(bitmap); + User::LeaveIfError(bitmap->Create(TSize(16,16),EGray4)); + iGc->BitBltMasked(TPoint(0, 0), bitmap, rect, bitmap, EFalse); + CleanupStack::PopAndDestroy(bitmap); + } + break; + case EADllPanicDrawBitmapMaskedFbsBitmapWithNoGc: + { + CFbsBitmap* bitmap = new(ELeave) CFbsBitmap(); + TRect rect; + CleanupStack::PushL(bitmap); + User::LeaveIfError(bitmap->Create(TSize(16,16),EGray4)); + iGc->DrawBitmapMasked(rect, bitmap, rect, bitmap, ETrue); + CleanupStack::PopAndDestroy(bitmap); + } + break; + case EADllPanicDrawBitmapMaskedWsBitmapWithNoGc: + { + CWsBitmap* bitmap = NULL; + TRect rect; + iGc->DrawBitmapMasked(rect, bitmap, rect, bitmap, ETrue); + } + break; + case EADllPanicDrawBitmapPointWithNoGc: + { + CWsBitmap* bitmap = NULL; + TRect rect; + iGc->DrawBitmap(rect.iTl, bitmap); + } + break; + case EADllPanicDrawBitmapWithNoGc: + { + CWsBitmap* bitmap = NULL; + TRect rect; + iGc->DrawBitmap(rect, bitmap); + } + break; + case EADllPanicDrawBitmapRectWithNoGc: + { + CWsBitmap* bitmap = NULL; + TRect rect; + iGc->DrawBitmap(rect, bitmap, TRect(0, 0, 16, 16)); + } + break; + case EADllPanicDrawPolyLinePointsWithNoGc: + { + TRect rect; + CArrayFixFlat* polyPoints = new(ELeave) CArrayFixFlat(3); //CArrayFixFlat + CleanupStack::PushL(polyPoints); + polyPoints->AppendL(rect.iTl); + polyPoints->AppendL(rect.Center()); + polyPoints->AppendL(TPoint(rect.iBr.iX, rect.iTl.iY)); + iGc->DrawPolyLine(&polyPoints->At(0), 3); + CleanupStack::PopAndDestroy(polyPoints); + } + break; + case EADllPanicDrawPolyLineArrayWithNoGc: + { + TRect rect; + CArrayFixFlat* polyPoints = new(ELeave) CArrayFixFlat(3); //CArrayFixFlat + CleanupStack::PushL(polyPoints); + polyPoints->AppendL(rect.iTl); + polyPoints->AppendL(rect.Center()); + polyPoints->AppendL(TPoint(rect.iBr.iX, rect.iTl.iY)); + iGc->DrawPolyLine(polyPoints); + CleanupStack::PopAndDestroy(polyPoints); + } + break; + case EADllPanicMoveToWithNoGc: + { + TPoint point; + iGc->MoveTo(point); + } + break; + case EADllPanicMoveByWithNoGc: + { + TPoint point; + iGc->MoveBy(point); + } + break; + case EADllPanicPlotWithNoGc: + { + TPoint point; + iGc->Plot(point); + } + break; + case EADllPanicSetOriginWithNoGc: + { + TPoint point; + iGc->SetOrigin(point); + } + break; + case EADllPanicCopyRectWithNoGc: + { + TPoint point; + TRect rect; + iGc->CopyRect(point, rect); + } + break; + case EADllPanicResetWithNoGc: + iGc->Reset(); + break; + case EADllPanicMapColorsWithNoGc: + { + TRgb rgbs[2]; + TRect rect; + iGc->MapColors(rect, rgbs, 1, ETrue); + } + break; + case EADllPanicDrawTextWithRectWithNoFont: + iWindowFunctions->ActivateGc(); + iGc->DrawText(_L("Panic"),TRect(20,20,20,20),0); + break; + case EADllPanicDrawTextVerticalWithNoFont: + iWindowFunctions->ActivateGc(); + iGc->DrawTextVertical(_L("Panic"),TPoint(20,20), EFalse); + break; + case EADllPanicDrawTextVerticalWithRectWithNoFont: + iWindowFunctions->ActivateGc(); + iGc->DrawTextVertical(_L("Panic"),TRect(20,20,20,20), 0, EFalse); + break; + case EADllPanicInvalidFocusScreenTooBig: + (static_cast(iFunctions->ExtendedInterface(MAnimGeneralFunctions::EWindowExtensionInterface)))->SetFocusScreen(3000); + break; + case EADllPanicInvalidFocusScreenNegative: + (static_cast(iFunctions->ExtendedInterface(MAnimGeneralFunctions::EWindowExtensionInterface)))->SetFocusScreen(-1); + break; + default: + iFunctions->Panic(); + } + } + +void CPanicAnim::DoLeaveInActiveCallback() + { + iWindowFunctions->ActivateGc(); + User::Leave(KErrUnknown); + } + +TInt CPanicAnim::LeaveInActiveCallback(TAny *aThis) + { + CPanicAnim* panicAnim=(CPanicAnim*)aThis; + panicAnim->DoLeaveInActiveCallback(); + return(KErrNone); + } + +void CPanicAnim::StartSyncTest(MAnimGeneralFunctions::TAnimSync aSync) + { + iFunctions->SetSync(aSync); + iSyncMode=aSync; + iSyncState=ESyncStateStarting; + } + +void CPanicAnim::StartTimeChangeTest() + { + iFunctions->SetSync(MAnimGeneralFunctions::ESyncSecond); + iSyncMode=MAnimGeneralFunctions::ESyncSecond; + iSyncState=ESyncStateTimeChange1; + } + +TInt CPanicAnim::CommandReplyL(TInt aOpcode,TAny* aParams) + { + TAnimArgUnion pData; + pData.any=aParams; + switch(aOpcode) + { + case EADllPanicBadFont: + iFunctions->DuplicateFontL(123); + break; + case EADllPanicBadBitmap: + iFunctions->DuplicateBitmapL(123); + break; + case EADllPanicCallPanic: + iFunctions->Panic(); + break; + case EADllReadRemoteDescriptor: + { + TInt ret=0; + const RMessagePtr2& message=*iFunctions->Message(); + TInt bufLength = message.GetDesLength(KIpcSlot); + TUint16* heapCell=static_cast(User::AllocL(bufLength*2)); + TPtr buf(heapCell,bufLength*2,bufLength*2); + const TInt theError=message.Read(KIpcSlot,buf); + if(theError == KErrNone) + { + for (TInt index=0;indexWindowSize()); + case EADllSyncTests: + iStatusPtr=pData.SyncTests->status; + StartSyncTest(pData.SyncTests->syncMode); + break; + case EADllTimeChangedTest: + iStatusPtr=pData.TimeChangeTest->status; + iStatusPtr2=pData.TimeChangeTest->status2; + StartTimeChangeTest(); + break; + case EADllTestSetVisible: + if (iWindowFunctions->IsHidden()) + goto setVisFailed; + iWindowFunctions->SetVisible(EFalse); + if (!iWindowFunctions->IsHidden()) + goto setVisFailed; + iWindowFunctions->SetVisible(ETrue); + if (iWindowFunctions->IsHidden()) +setVisFailed: return(EFalse); + return(ETrue); + case EADllPanicSetVisWithGcActiveReply: + iWindowFunctions->ActivateGc(); + iWindowFunctions->SetVisible(EFalse); + iWindowFunctions->SetVisible(ETrue); + break; + case EADllPanicSetClippingRegionWithNoGc: + { + // currently this test fails because when deactivated iWin is also NULL and is deferenced in function + RRegion region; + TBool err = iGc->SetClippingRegion(region); + } + break; + case EADllPanicDrawPolygonPointsWithNoGc: + { + TRect rect(20,20,20,20); + CArrayFixFlat* polyPoints = new(ELeave) CArrayFixFlat(3); //CArrayFixFlat + CleanupStack::PushL(polyPoints); + polyPoints->AppendL(rect.iTl); + polyPoints->AppendL(rect.Center()); + polyPoints->AppendL(TPoint(rect.iBr.iX, rect.iTl.iY)); + iGc->DrawPolygon(polyPoints, CGraphicsContext::EWinding); + CleanupStack::PopAndDestroy(polyPoints); + } + break; + case EADllPanicDrawPolygonArrayWithNoGc: + { + TRect rect(20,20,20,20); + CArrayFixFlat* polyPoints = new(ELeave) CArrayFixFlat(3); //CArrayFixFlat + CleanupStack::PushL(polyPoints); + polyPoints->AppendL(rect.iTl); + polyPoints->AppendL(rect.Center()); + polyPoints->AppendL(TPoint(rect.iBr.iX, rect.iTl.iY)); + iGc->DrawPolygon(&polyPoints->At(0), 3, CGraphicsContext::EAlternate); + CleanupStack::PopAndDestroy(polyPoints); + } + break; + case EADllPanicAlphaBlendingBitmapsFbsBitmapWithNoGc: + { + TRect rect(20,20,20,20); + CFbsBitmap* bitmap = new(ELeave) CFbsBitmap(); + CleanupStack::PushL(bitmap); + User::LeaveIfError(bitmap->Create(TSize(16,16),EGray4)); + iGc->AlphaBlendBitmaps(TPoint(0, 0), bitmap, rect, bitmap, TPoint(0,0)); + CleanupStack::PopAndDestroy(bitmap); + } + break; + case EADllPanicDevice: + { + CGraphicsDevice *device = iGc->Device(); + } + break; + default: + iFunctions->Panic(); + } + return(KErrNone); + } + +void CPanicAnim::FocusChanged(TBool ) + { + } + +TBool CPanicAnim::OfferRawEvent(const TRawEvent &/*aRawEvent*/) + { + return EFalse; + } + + +// CPanicAnim2 simply panics in the construct // +void CPanicAnim2::ConstructL(TAny *, TBool ) + { + iFunctions->Panic(); + } + +void CPanicAnim2::Animate(TDateTime *) + {} + +void CPanicAnim2::Redraw() + {} + +void CPanicAnim2::Command(TInt , TAny *) + {} + +TInt CPanicAnim2::CommandReplyL(TInt , TAny *) + {return(0);} + +void CPanicAnim2::FocusChanged(TBool ) + {} + +TBool CPanicAnim2::OfferRawEvent(const TRawEvent &/*aRawEvent*/) + { + return EFalse; + } + + +// CAutoAnim3 test drawing/redrawing // +void CAutoAnim3::ConstructL(TAny *aParam, TBool ) + { + iRect=*((TRect *)aParam); + iWindowFunctions->SetRect(iRect); + iMode=0; + iWindowFunctions->Invalidate(iRect); + iFunctions->SetSync(MAnimGeneralFunctions::ESyncSecond); + } + +void CAutoAnim3::Animate(TDateTime *) + { + iWindowFunctions->ActivateGc(); + if (iMode==1) + { + Draw(iRect); + if (iRect.Width()>20 && iRect.Height()>20) + iRect.Shrink(TSize(20,20)); + else + iRect=iBaseRect; + Draw(iRect); + } + else if (iMode==2) + { + Draw(iRect); + iFunctions->Client().RequestComplete(iStatusPtr,KErrNone); + iFunctions->SetSync(MAnimGeneralFunctions::ESyncNone); + } + else if (iMode==3) + { + // flip between two sizes + if (iRect.iTl.iX == 10) + iRect.SetRect(40,40,80,80); + else + iRect.SetRect(10,10,110,110); + Draw(iRect); + } + } + +void CAutoAnim3::Draw(const TRect &aRect) + { + switch(iMode) + { + case 0: + iGc->SetDrawMode(CGraphicsContext::EDrawModeXOR); + iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + iGc->SetBrushColor(TRgb::Gray256(85)); + iGc->SetPenColor(TRgb::Gray256(170)); + iGc->DrawEllipse(aRect); + iGc->SetBrushStyle(CGraphicsContext::ENullBrush); + break; + case 1: // Shrinking box + iGc->SetDrawMode(CGraphicsContext::EDrawModeXOR); + iGc->SetPenColor(TRgb::Gray256(255)); + iGc->DrawRect(aRect); + break; + case 2: + case 3: + iGc->SetDrawMode(CGraphicsContext::EDrawModePEN); + iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + iGc->SetBrushColor(TRgb::Gray256(85)); + iGc->SetPenColor(TRgb::Gray256(170)); + iGc->DrawEllipse(aRect); + iGc->SetBrushStyle(CGraphicsContext::ENullBrush); + break; + default: + break; + } + } + +void CAutoAnim3::Redraw() + { + Draw(iRect); + } + +void CAutoAnim3::Command(TInt aOpcode,TAny* aParam) + { + TAnimArgUnion pData; + pData.any=aParam; + switch(aOpcode) + { + case EADllSetRect: + iWindowFunctions->ActivateGc(); + Draw(iRect); + iRect=*pData.Rect; + iWindowFunctions->SetRect(iRect); + Draw(iRect); + { //Do more extensive testing + TWindowInfo data; + iWindowFunctions->Parameters(data); + } + break; + case EADllStartAnimate: + iWindowFunctions->ActivateGc(); + Draw(iRect); + iMode=1; + iBaseRect=*pData.Rect; + iRect=iBaseRect; + iWindowFunctions->SetRect(iRect); + iFunctions->SetSync(MAnimGeneralFunctions::ESyncFlash); + Draw(iRect); + break; + case EADllCancelAnimate: + iFunctions->SetSync(MAnimGeneralFunctions::ESyncNone); + iWindowFunctions->ActivateGc(); + Draw(iRect); + iMode=-1; + break; + case EADllSetVisible: + iWindowFunctions->SetVisible(*pData.Bool); + break; + case EADllSetShadowDrawMode: + iMode=2; + break; + case EADllDrawTestScreen: + DrawTestScreenL(pData.DrawTestScreen); //Should move to CommandReplyL as it leaves + break; + case EADllSetMode: + iMode = *pData.Int; + break; + } + } + +TInt CAutoAnim3::CommandReplyL(TInt aOpcode, TAny *aParam) + { + TAnimArgUnion pData; + pData.any = aParam; + TInt ret=0; + switch(aOpcode) + { + case EADllShadowAnimTest: + iFunctions->SetSync(MAnimGeneralFunctions::ESyncFlash); + iStatusPtr=((TShadowDrawTest *)aParam)->status; + break; + case EADllParameterRectValueTest: + { + TWindowInfo wininf; + iWindowFunctions->Parameters(wininf); + TRect comp = *(pData.Rect); + ret=(comp==wininf.iScreenPos); + } + break; + case EADllDoSetSync: + iFunctions->SetSync(static_cast(*pData.Int)); + break; + case EADllSetInterval: + iFunctions->SetInterval(*pData.Int); + break; + } + return(ret); + } + +void CAutoAnim3::FocusChanged(TBool ) + {} + +//void CAutoAnim3::DrawTestScreen(TDrawTestScreen *aParams) +//Function now at bottom of file + +TBool CAutoAnim3::OfferRawEvent(const TRawEvent &/*aRawEvent*/) + { + return EFalse; + } + + +// CAutoAnimScrBack test drawing/redrawing // +void CAutoAnimScrBack::ConstructL(TAny *aParam, TBool ) + { + iRect=*((TRect *)aParam); + iWindowFunctions->SetRect(iRect); + iMode=1; + iFunctions->SetSync(MAnimGeneralFunctions::ESyncFlash); + } + +void CAutoAnimScrBack::Animate(TDateTime *) + { + iWindowFunctions->ActivateGc(); + Draw(); + iFunctions->SetSync(MAnimGeneralFunctions::ESyncNone); + } + +void CAutoAnimScrBack::Draw() + { + iGc->SetDrawMode(CGraphicsContext::EDrawModePEN); + if (iMode==2) + iGc->SetPenSize(TSize(3,3)); + iGc->SetPenColor(TRgb::Gray4(iMode==1 ? 2 : 3)); + iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + iGc->SetBrushColor(TRgb::Gray4(iMode==1 ? 1 : 0)); + iGc->DrawRect(iRect); + } + +void CAutoAnimScrBack::Redraw() + { + Draw(); + } + +void CAutoAnimScrBack::Command(TInt aOpcode,TAny* aParam) + { + TAnimArgUnion pData; + pData.any=aParam; + switch(aOpcode) + { + case EADllDrawOtherRect: + { + TRect oldRect(iRect); + if (iMode==2) + oldRect.Grow(1,1); // To allow for 3x3 pen size + iMode=2; + iRect=*pData.Rect; + TRect fullRect(iRect); + fullRect.Grow(1,1); // To allow for 3x3 pen size + iWindowFunctions->Invalidate(oldRect); + iWindowFunctions->SetRect(fullRect); + iWindowFunctions->Invalidate(fullRect); + } +// iFunctions->ActivateGc(); +// Draw(); + break; + } + } + +TInt CAutoAnimScrBack::CommandReplyL(TInt aOpcode, TAny *) + { + switch(aOpcode) + { + case EADllIsHidden: + return iWindowFunctions->IsHidden(); + } + return(0); + } + +void CAutoAnimScrBack::FocusChanged(TBool ) + {} + +TBool CAutoAnimScrBack::OfferRawEvent(const TRawEvent &/*aRawEvent*/) + { + return EFalse; + } + + +// CTestSpriteAnim test sprite access // +void CTestSpriteAnim::ConstructL(TAny* /*aParam*/) + { + iSpriteFunctions->SizeChangedL(); + iSpriteFunctions->Activate(ETrue); + } + +void CTestSpriteAnim::Animate(TDateTime*) + { + } + +void CTestSpriteAnim::Command(TInt aOpcode,TAny* aParam) + { + TAnimArgUnion pData; + pData.any=aParam; + switch (aOpcode) + { + case EADllSizeChanged: + iSpriteFunctions->Activate(EFalse); + iSpriteFunctions->SizeChangedL(); //Should move to CommandReplyL as it leaves + case EADllActivate: + iSpriteFunctions->Activate(ETrue); + break; + case EADllDeactivate: + iSpriteFunctions->Activate(EFalse); + break; + case EADllSetPos: + iSpriteFunctions->SetPosition(*pData.Point); + break; + case EADllDraw1: + case EADllDraw2: + case EADllDraw3: + DrawMemberL(aOpcode-EADllDraw1); //Should move to CommandReplyL as it leaves + break; + case EADllIncDraw: + DrawMemberL(); //Should move to CommandReplyL as it leaves + break; + default:; + } + } + +TInt CTestSpriteAnim::CommandReplyL(TInt aOpcode,TAny* aParam) + { + TAnimArgUnion pData; + pData.any=aParam; + switch (aOpcode) + { + case EADllCheckMember: + return CheckMember(*pData.SpriteMemberInfo); + default:; + } + return(KErrNone); + } + +TBool CTestSpriteAnim::OfferRawEvent(const TRawEvent& /*aRawEvent*/) + { + return EFalse; + } + +TBool CTestSpriteAnim::CheckMember(const TSpriteMemberInfo& aMemInfo) + { + TSpriteMember spriteMember=*iSpriteFunctions->GetSpriteMember(aMemInfo.iMember); + if (spriteMember.iBitmap->Handle()!=aMemInfo.iBitmapHandle) + return EFalse; + if (aMemInfo.iMaskBitmapHandle==0) + { + if (spriteMember.iMaskBitmap!=NULL) + return EFalse; + } + else + { + if (spriteMember.iMaskBitmap->Handle()!=aMemInfo.iMaskBitmapHandle) + return EFalse; + } + if (spriteMember.iInvertMask!=aMemInfo.iInvertMask) + return EFalse; + if (spriteMember.iDrawMode!=aMemInfo.iDrawMode) + return EFalse; + if (spriteMember.iOffset!=aMemInfo.iOffset) + return EFalse; + if (spriteMember.iInterval!=aMemInfo.iInterval) + return EFalse; + return ETrue; + } + +void CTestSpriteAnim::DrawMemberL(TInt aMember) + { + CFbsBitmap *bitmap=iSpriteFunctions->GetSpriteMember(aMember)->iBitmap; + CFbsBitmapDevice *device=CFbsBitmapDevice::NewL(bitmap); + CleanupStack::PushL(device); + CFbsBitGc *gc; + User::LeaveIfError(device->CreateContext(gc)); + CleanupStack::PushL(gc); + //gc->SetBrushColor(TRgb::Gray4((aMember+1)%3)); + gc->SetBrushStyle(CGraphicsContext::ESolidBrush); + gc->SetPenSize(TSize()); + TSize size=bitmap->SizeInPixels(); + size.SetSize(size.iWidth/2,size.iHeight/2); + TPoint point=size.AsPoint(); + gc->SetBrushColor(TRgb::Gray4(0)); + //TRect rect=bitmap->SizeInPixels(); + gc->DrawRect(TRect(TPoint(),size)); + gc->SetBrushColor(TRgb::Gray4(1)); + gc->DrawRect(TRect(TPoint(point.iX,0),size)); + gc->SetBrushColor(TRgb::Gray4(2)); + gc->DrawRect(TRect(TPoint(0,point.iY),size)); + gc->SetBrushColor(TRgb::Gray4(3)); + gc->DrawRect(TRect(point,size)); + iSpriteFunctions->UpdateMember(aMember,TRect(bitmap->SizeInPixels()),ETrue); + CleanupStack::PopAndDestroy(2); + } + +void CTestSpriteAnim::DrawMemberL() + { + CFbsBitmap *bitmap=iSpriteFunctions->GetSpriteMember(0)->iBitmap; + CFbsBitmapDevice *device=CFbsBitmapDevice::NewL(bitmap); + CleanupStack::PushL(device); + CFbsBitGc *gc; + User::LeaveIfError(device->CreateContext(gc)); + CleanupStack::PushL(gc); + gc->SetPenSize(TSize(3,3)); + gc->SetPenColor(TRgb::Gray4(1)); + TPoint corner=bitmap->SizeInPixels().AsPoint(); + gc->DrawLine(TPoint(),corner); + gc->DrawLine(TPoint(0,corner.iY),TPoint(corner.iX,0)); + iSpriteFunctions->UpdateMember(0,TRect(bitmap->SizeInPixels()),EFalse); + CleanupStack::PopAndDestroy(2); + } + + +// CTestFreeTimerAnim test drawing off own timer // +CTestFreeTimerAnim::~CTestFreeTimerAnim() + { + iTimer->Cancel(); + delete iTimer; + } + +void CTestFreeTimerAnim::ConstructL(TAny* /*aParam*/, TBool ) + { + User::LeaveIfNull(iFunctions); + User::LeaveIfNull(iWindowFunctions); + + //Configure free-timer anim (these values should be the default ones) + iFunctions->SetSync( MAnimGeneralFunctions::ESyncNone ); + iFunctions->SetInterval(0); + + iFrameTime = 100000; //default frametime 0.1s + iTimer = CAnimTimer::NewL(*this); + iRect = iWindowFunctions->WindowSize(); + } + +#define MAX(a,b) (((a)>(b))?(a):(b)) + +void CTestFreeTimerAnim::Animate(TDateTime*) + { + TInt max = MAX(iRect.Width(), iRect.Height()); + if(max <= 0) + { + iRect = iWindowFunctions->WindowSize(); + } + else + { + iRect.Shrink(1,1); + } + + //change colour + switch(iColour.Value()) + { + case 0x000000: //black + case 0xffffff: //white + iColour = KRgbRed; + break; + case 0x0000ff: //red + iColour = KRgbGreen; + break; + case 0x00ff00: //green + iColour = KRgbBlue; + break; + case 0xff0000: //blue + iColour = KRgbBlack; + break; + } + } + +void CTestFreeTimerAnim::Redraw() + { + //draw something in the animated colour + iGc->SetBrushColor(iColour); + iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + iGc->SetPenColor(KRgbBlack); + iGc->DrawRect(iRect); + } + +void CTestFreeTimerAnim::Command(TInt aOpcode, TAny* aArgs) + { + switch(aOpcode) + { + case EStartAnimation: + DisplayNextFrameL(); + break; + case EStopAnimation: + iTimer->Cancel(); + break; + case ESetFrameTime: + ASSERT(aArgs); + iFrameTime = *reinterpret_cast(aArgs); + break; + default: + ASSERT(0); + } + } + +TInt CTestFreeTimerAnim::CommandReplyL(TInt aOpcode, TAny* aArgs) + { + switch(aOpcode) + { + case EStartAnimation: + DisplayNextFrameL(); + break; + case EStopAnimation: + iTimer->Cancel(); + break; + case ESetFrameTime: + ASSERT(aArgs); + iFrameTime = *reinterpret_cast(aArgs); + break; + default: + ASSERT(0); + } + return(KErrNone); + } + +void CTestFreeTimerAnim::FocusChanged(TBool /*aState*/) + { + } + +TBool CTestFreeTimerAnim::OfferRawEvent(const TRawEvent& /*aRawEvent*/) + { + return EFalse; + } + + +void CTestFreeTimerAnim::DisplayNextFrameL() + { + //Reschedule timer callback + iTimer->Cancel(); + iTimer->After(iFrameTime); + + Animate(NULL); //wserv don't animate free-timer animations + + //Schedule wserv redraw + MAnimFreeTimerWindowFunctions* windowFunctions = WindowFunctions(); + ASSERT(windowFunctions); + windowFunctions->ActivateGc(); + windowFunctions->DeactivateGc(); + windowFunctions->Update(); + } + +// +// CAnimTimer class +// + +/** + Constructs a new bitmap animation timer object,and adds the specified active object to the current active scheduler. + +@param aObserver a pointer to MAnimTimerObserver +*/ +CAnimTimer::CAnimTimer(MAnimTimerObserver& aObserver) + :CTimer(EPriorityStandard), + iAnim(aObserver) + { + CActiveScheduler::Add(this); + } + +/** + Frees resources owned by the object prior to deletion. +*/ +CAnimTimer::~CAnimTimer() + { + } + +/** + Creates a new bitmap animation timer object. + +@param aObserver A pointer to the MAnimTimerObserver +@return A pointer to the new bitmap animation timer object. +*/ +CAnimTimer* CAnimTimer::NewL(MAnimTimerObserver& aObserver) + { + CAnimTimer* timer=new(ELeave) CAnimTimer(aObserver); + CleanupStack::PushL(timer); + timer->ConstructL(); + CleanupStack::Pop(); + return timer; + } + +/** + Completes construction of the bitmap animation timer object and + constructs a new asynchronous timer. +*/ +void CAnimTimer::ConstructL() + { + CTimer::ConstructL(); + } + +/** + Handles an active object's request completion event. + Invokes the function to draw the next frame +*/ +void CAnimTimer::RunL() + { + iAnim.DisplayNextFrameL(); + } + +// CEventTestAnimBase base class for event test anims // +CEventTestAnimBase::~CEventTestAnimBase() + { + iFunctions->GetRawEvents(EFalse); + } + +void CEventTestAnimBase::ConstructL(TAny* /*aParam*/, TBool ) + { + iExpectedEvents.SetLengthL(EEventBufferSize); + } + +void CEventTestAnimBase::Animate(TDateTime*) + { + } + +void CEventTestAnimBase::Redraw() + { + } + +void CEventTestAnimBase::Command(TInt /*aOpcode*/, TAny* /*aParam*/) + { + /*switch (aOpcode) + { + default:; + }*/ + } + +void CEventTestAnimBase::FocusChanged(TBool /*aState*/) + { + } + +// Base class common client server interface +TInt CEventTestAnimBase::CommandReplyL(TInt aOpcode,TAny* aParam) + { + TAnimArgUnion pData; + pData.any=aParam; + switch (aOpcode) + { + case EADllAddExpectedEvent: + return AddExpectedEvent(pData.AnimRawEvent); + case EADllNumberOfEventsReceived: + return iEventCount; + case EADllErrorCode: + return iError; + case EADllReset: + iExpectedEvents.Reset(); + iError = 0; + iEventCount = 0; + return KErrNone; + default:; + } + return(KErrNone); + } + +TBool CEventTestAnimBase::HandleRecursiveEvent(const TRawEvent& aRawEvent) + { + if (aRawEvent.ScanCode() == 60) + { + TRawEvent rawEvent; + rawEvent.Set(TRawEvent::EKeyUp, 34); + iFunctions->PostRawEvent(rawEvent); + rawEvent.Set(TRawEvent::EKeyUp, 35); + iFunctions->PostRawEvent(rawEvent); + return ETrue; + } + return EFalse; + } + +TBool CEventTestAnimBase::OfferRawEvent(const TRawEvent& aRawEvent) + { + // Do not consume the following types of events + if (IsIgnorableEvent(aRawEvent)) + { + return EFalse; + } + + // Increment event count if not in an error state + if (!Error()) + { + iEventCount++; + } + + // For anim which generates recursive events + if (aRawEvent.Type() == TRawEvent::EKeyDown && aRawEvent.ScanCode() == 60) + { + return HandleRecursiveEvent(aRawEvent); + } + + TAnimRawEvent event; + + if (!GetNextExpectedEvent(event)) + { + Fail(); + return EFalse; + } + + // Fail if wrong event type + if (!CompareEvents(event.iRawEvent, aRawEvent)) + { + Fail(); + } + + return event.iEat; + } + +TBool CEventTestAnimBase::GetNextExpectedEvent(TAnimRawEvent& aRawEvent) + { + // Get next expected event + if (iExpectedEvents.Remove(&aRawEvent)<1) + { + Fail(); + return EFalse; + } + else + { + return ETrue; + } + } + +TBool CEventTestAnimBase::IsIgnorableEvent(const TRawEvent& aRawEvent) const + { + TRawEvent::TType aType=aRawEvent.Type(); + TBool result = (aType==TRawEvent::EActive || aType==TRawEvent::EInactive || aType==TRawEvent::ERedraw + || (iExpectedEvents.Count()==0 && aType==TRawEvent::EPointerMove)); + + return result; + } + +TBool CEventTestAnimBase::CompareEvents(const TRawEvent& aExpectedEvent, const TRawEvent& aActualEvent) const + { + TRawEvent::TType eType=aExpectedEvent.Type(); + TRawEvent::TType aType=aActualEvent.Type(); + if (eType!=aType) + { + return EFalse; + } + else + { + switch (aType) + { + case TRawEvent::EUpdateModifiers: + { + TInt eMod=aExpectedEvent.Modifiers(),aMod=aActualEvent.Modifiers(); + if (eMod!=aMod) + { + return EFalse; + } + break; + } + case TRawEvent::EKeyDown: + case TRawEvent::EKeyUp: + { + TInt eScan=aExpectedEvent.ScanCode(),aScan=aActualEvent.ScanCode(); + if (eScan!=aScan) + { + return EFalse; + } + break; + } + case TRawEvent::EPointerMove: + case TRawEvent::EPointerSwitchOn: + case TRawEvent::EButton1Down: + case TRawEvent::EButton1Up: + case TRawEvent::EButton2Down: + case TRawEvent::EButton2Up: + case TRawEvent::EButton3Down: + case TRawEvent::EButton3Up: + { + TPoint ePoint=aExpectedEvent.Pos(),aPoint=aActualEvent.Pos(); + if (ePoint!=aPoint) + { + return EFalse; + } + break; + } + default:; + } + } + return ETrue; + } + +void CEventTestAnimBase::Fail() + { + if (iError==0) + { + iError=iEventCount; + } + } + +inline TInt CEventTestAnimBase::Error() const + { + return iError; + } + +inline TInt CEventTestAnimBase::EventCount() const + { + return iEventCount; + } + +inline void CEventTestAnimBase::ResetEventCount() + { + iEventCount = 0; + } + +inline TInt CEventTestAnimBase::TotalExpectedEvents() const + { + return iExpectedEvents.Count(); + } + +inline TInt CEventTestAnimBase::AddEvent(const TAnimRawEvent* aEvent) + { + return iExpectedEvents.Add(aEvent); + } + +// CEventTestAnim test drawing off own timer // +CEventTestAnim::~CEventTestAnim() + { + UnloadDeviceDriver(); + } + +void CEventTestAnim::ConstructL(TAny* aParam, TBool aBool) + { + CEventTestAnimBase::ConstructL(aParam, aBool); + iFunctions->GetRawEvents(ETrue); + iDevDriverLoaded=EFalse; + } + +TInt CEventTestAnim::UnloadDeviceDriver() + { + TInt err=KErrNone; + iLdd.Close(); + if (iDevDriverLoaded) + { + err=User::FreeLogicalDevice(REventDD::BinaryName()); + if (err==KErrNone) + iDevDriverLoaded=EFalse; + } + return err; + } + +TInt CEventTestAnim::AddExpectedEvent(const TAnimRawEvent* aEvent) + { + return (AddEvent(aEvent) ? KErrNone : KErrOverflow); + } + +TInt CEventTestAnim::CommandReplyL(TInt aOpcode,TAny* aParam) + { + switch (aOpcode) + { + case EADllNoEventsAndReset: + { + TInt events=EventCount(); + ResetEventCount(); + return events; + } + case EADllLoadDeviceDriver: + { + TInt err=User::LoadLogicalDevice(REventDD::BinaryName()); + if (err==KErrNone || err==KErrAlreadyExists) + { + TInt err2=iLdd.Open(); + if (err==KErrNone) + { + if (err2==KErrNone) + iDevDriverLoaded=ETrue; + else //Only unload if we loaded it + User::FreeLogicalDevice(REventDD::BinaryName()); + } + err=err2; + } + return err; + } + case EADllUnloadDeviceDriver: + return UnloadDeviceDriver(); + case EADllSendEvent: + { + TAnimRawEvent event; + TInt events=*static_cast(aParam); + TInt err=KErrNone; + TInt ii; + for (ii=events;ii>0;--ii) + { + event.iRawEvent.Set(ii/2==0 ? TRawEvent::ECaseOpen : TRawEvent::ECaseClose); + //TInt err=UserSvr::AddEvent(event.iRawEvent); + //Need to do the above line here, but don't have enough capability + //so call a device driver to do it instead + err=iLdd.SendEvent(event.iRawEvent); + if (err!=KErrNone) + return err; + event.iEat=ETrue; + AddExpectedEvent(&event); + } + return KErrNone; + } + default:; + return CEventTestAnimBase::CommandReplyL(aOpcode, aParam); + } + } + +void CEventTestAnim::Command(TInt aOpcode,TAny* /*aParam*/) + { + switch (aOpcode) + { + case EADllAfterEvent: + if (TotalExpectedEvents()>0) + Fail(); + break; + default:; + } + } + +// CEventPostingAnim test posting of anim events // +CEventPostingAnim::~CEventPostingAnim() + { + } + +void CEventPostingAnim::ConstructL(TAny* aParam, TBool aBool) + { + CEventTestAnimBase::ConstructL(aParam, aBool); + iFunctions->GetRawEvents(ETrue); + } + +TInt CEventPostingAnim::AddExpectedEvent(const TAnimRawEvent* aEvent) + { + return (AddEvent(aEvent) ? KErrNone : KErrOverflow); + } + +TBool CEventPostingAnim::OfferRawEvent(const TRawEvent &aRawEvent) + { + // Call PostRawEvent or PostKeyEvent according to type of the event + TBool ret = CEventTestAnimBase::OfferRawEvent(aRawEvent); + if (ret) + { + if (aRawEvent.Type() == TRawEvent::EKeyDown && aRawEvent.ScanCode() == 45) + { + TKeyEvent event; + event.iCode='J'; + event.iScanCode=0; + event.iModifiers=0; + + // This is to check the normal PostKeyEvent API + iFunctions->PostKeyEvent(event); + + // This is to check the newly added API + iFunctions->EventExtension()->PostKeyEvent(event, 2); + } + else + { + iFunctions->PostRawEvent(aRawEvent); + } + } + return ret; + } + +// CTimerTestAnim check that timer events stop // +CTimerTestAnim::~CTimerTestAnim() + { + } + +void CTimerTestAnim::ConstructL(TAny* /*aParam*/, TBool ) + { + iWindowFunctions->SetRect(TRect(0,0,1,1)); + iFunctions->SetSync(MAnimGeneralFunctions::ESyncSecond); + iExpectingTicks=ETrue; + iFail=EFalse; + } + +void CTimerTestAnim::Animate(TDateTime*) + { + ++iTimerCount; + if (!iExpectingTicks) + iFail=iTimerCount; + } + +void CTimerTestAnim::Redraw() + { + } + +void CTimerTestAnim::Command(TInt aOpcode, TAny* /*aParam*/) + { + switch (aOpcode) + { + case EADllResetCount: + iTimerCount=0; + break; + case EADllNoTimer: + iExpectingTicks=EFalse; + iFunctions->SetSync(MAnimGeneralFunctions::ESyncNone); + break; + case EADllTimerStarted: + iExpectingTicks=ETrue; + iFunctions->SetSync(MAnimGeneralFunctions::ESyncSecond); + break; + default:; + } + } + +TInt CTimerTestAnim::CommandReplyL(TInt aOpcode, TAny* /*aParam*/) + { + switch (aOpcode) + { + case EADllCurrentCount: + return iTimerCount; + case EADllFailed: + return iFail; + default:; + } + return(KErrNone); + } + +void CTimerTestAnim::FocusChanged(TBool /*aState*/) + { + } + +TBool CTimerTestAnim::OfferRawEvent(const TRawEvent& /*aRawEvent*/) + { + return EFalse; + } + + +// CWinFunctionTestAnim test drawing off own timer // +CWinFunctionTestAnim::~CWinFunctionTestAnim() + {} + +void CWinFunctionTestAnim::ConstructL(TAny* /*aParam*/,TBool) + { + iWinFunctions=static_cast + (iFunctions->ExtendedInterface(MAnimGeneralFunctions::EWindowExtensionInterface)); + } + +void CWinFunctionTestAnim::Animate(TDateTime*) + {} + +void CWinFunctionTestAnim::Redraw() + {} + +void CWinFunctionTestAnim::Command(TInt /*aOpcode*/,TAny* /*aParam*/) + { + /*switch (aOpcode) + { + default:; + }*/ + } + +TInt CWinFunctionTestAnim::CommandReplyL(TInt aOpcode,TAny* aParam) + { + TAnimArgUnion pData; + pData.any=aParam; + switch (aOpcode) + { + case EADllScreen: + return iWinFunctions->Screens(); + case EADllFocusScreen: + return iWinFunctions->FocusScreens(); + case EADllWindowGroups: + return iWinFunctions->WindowGroups(*pData.Int); + case EADllWindowGroupInfo: + { + const TWindowGroupInfoParms& params=*pData.WindowGroupInfoParms; + TPckgBuf info; + TBool ret=iWinFunctions->WindowGroupInfo(info(),params.iScreen,params.iOrdinalPosition); + /*const TInt theError=*/(*iFunctions->Message()).Write(KIpcSlot,info); + return ret; + } + case EADllWindowGroupName: + { + const TWindowGroupInfoParms& params=*pData.WindowGroupInfoParms; + TPtrC name; + TBool ret=iWinFunctions->WindowGroupName(name,params.iScreen,params.iOrdinalPosition); + /*const TInt theError=*/(*iFunctions->Message()).Write(KIpcSlot,name); + return ret; + } + case EADllSetOrdinalPosition: + { + const TSetOrdinalParms& params=*pData.SetOrdinalParms; + return iWinFunctions->SetOrdinalPosition(params.iIdentifier,params.iOrdinalPosition,params.iOrdinalPriority); + } + case EADllSetFocusScreen: + { + const TInt& params=*pData.Int; + iWinFunctions->SetFocusScreen(params); + break; + } + default:; + } + return(KErrNone); + } + +void CWinFunctionTestAnim::FocusChanged(TBool /*aState*/) + {} + +TBool CWinFunctionTestAnim::OfferRawEvent(const TRawEvent& /*aRawEvent*/) + { + return EFalse; + } + + +// CNotificationTestAnim +CNotificationTestAnim::CNotificationTestAnim() : iHeartbeatState(EFalse) , iScreenDeviceChanged(ETrue) + { + } + +CNotificationTestAnim::~CNotificationTestAnim() + { +// Removed for test case GRAPHICS-WSERV-0139 for DEF12220 +// iFunctions->RegisterForNotifications(EFalse); + } + +void CNotificationTestAnim::ConstructL(TAny* /*aParam*/, TBool ) + { + iWindowFunctions->SetRect(TRect(0,0,1,1)); + iFunctions->RegisterForNotifications(EDirectScreenAccess|EHeartbeatTimer|EScreenDeviceChange); + iFunctions->SetSync(MAnimGeneralFunctions::ESyncSecond); + iLastAnimTime.UniversalTime(); + } + +void CNotificationTestAnim::HandleNotification(const TWsEvent& aEvent) + { + switch (aEvent.Type()) + { + case EEventDirectScreenAccessBegin: + { + TInt screenNum = *(aEvent.Int()); + iDSA[screenNum] = ETrue; + } + break; + case EEventDirectScreenAccessEnd: + { + TInt screenNum = *(aEvent.Int()); + iDSA[screenNum] = EFalse; + } + break; + case EEventHeartbeatTimerStateChange: + { + iHeartbeatState=*aEvent.Int(); + } + break; + case EEventScreenDeviceChanged: + { + iScreenDeviceChanged=!iScreenDeviceChanged; + } + break; + default: + break; + } + } + +void CNotificationTestAnim::Animate(TDateTime*) + { + iLastAnimTime.UniversalTime(); + } + +void CNotificationTestAnim::Redraw() + { + } + +void CNotificationTestAnim::Command(TInt /*aOpcode*/, TAny* /*aParam*/) + { + } + +TInt CNotificationTestAnim::CommandReplyL(TInt aOpcode,TAny* aParam) + { + TAnimArgUnion pData; + pData.any=aParam; + switch (aOpcode) + { + case EADllQueryDSA: + { + TInt screenNum = *pData.Int; + return iDSA[screenNum]; + } + case EADllQueryHeartbeatState: + { + return iHeartbeatState; + } + case EADllIsAnimating: + { + // Check if the anim DLL is currently animating by comparing + // the current time with the last anim time - if this is greater than a second + // then we are not animating + TTime timeNow; + timeNow.UniversalTime(); + TTimeIntervalMicroSeconds microSecs = timeNow.MicroSecondsFrom(iLastAnimTime); + if(microSecs > TTimeIntervalMicroSeconds(1200000)) // 1 sec plus 0.2 secs to cope with any latency + { + return EFalse; + } + else + { + return ETrue; + } + } + default:; + } + return(KErrNone); + } + +void CNotificationTestAnim::FocusChanged(TBool /*aState*/) + { + } + +TBool CNotificationTestAnim::OfferRawEvent(const TRawEvent& /*aRawEvent*/) + { + return EFalse; + } + +// CTransAnim test drawing// +void CTransAnim::ConstructL(TAny* aParam, TBool) + { + iRect=*static_cast(aParam);//Assigns the animation area + iWindowFunctions->SetRect(iRect); + iFunctions->SetSync(MAnimGeneralFunctions::ESyncFlash); + iFont=NULL; + iColor=TRgb(0,0,0); + } + +void CTransAnim::Animate(TDateTime*) + { + iWindowFunctions->ActivateGc(); + if(iMode==1) //Draw line mode + { + DoDraw(iDraw,*iGc,iColor,iRect); + } + else if(iMode==2) //Draw text mode + { + DoDraw(iDraw,*iGc,iColor,iRect,iFont,iCount); + } + } + +void CTransAnim::Redraw() + { + DoDraw(iDraw,*iGc,iColor,iRect,iFont,iCount); + } + +void CTransAnim::Command(TInt aOpcode,TAny* aParam) + { + TAnimArgUnion pData; + pData.any=aParam; + switch(aOpcode) + { + case EADllDrawNow: //Used to draw a single frame + iWindowFunctions->ActivateGc(); + iMode=1; + iDraw=36; + iColor=TRgb(0,0,0); + DoDraw(iDraw,*iGc,iColor,iRect); + break; + case EADllNextFrame: //Used to draw a continous frame + iMode=2; + iColor=pData.FrameData->color; + iDraw=pData.FrameData->draw; + iCount=pData.FrameData->text; + break; + case EADllStartAnimText: //Used to start text animate + iWindowFunctions->ActivateGc(); + iMode=2; + iDraw=37; + iFont=iFunctions->DuplicateFontL(pData.FrameData->font); + iColor=pData.FrameData->color; + iCount=pData.FrameData->text; + if(pData.FrameData->sync==EStateFlash) + iFunctions->SetSync(MAnimGeneralFunctions::ESyncFlash); + else if(pData.FrameData->sync==EStateSecond) + iFunctions->SetSync(MAnimGeneralFunctions::ESyncSecond); + DoDraw(iDraw,*iGc,iColor,iRect,iFont,iCount); + break; + case EADllEndAnimText: //Used to end text animate + iFunctions->SetSync(MAnimGeneralFunctions::ESyncNone); + iWindowFunctions->ActivateGc(); + iCount=0; + iMode=0; + iFunctions->CloseFont(iFont); + iFont=NULL; + break; + } + } + +TInt CTransAnim::CommandReplyL(TInt /*aOpcode*/, TAny* /*aParam*/) + { + return(0); + } + +void CTransAnim::FocusChanged(TBool /*aState*/) + {} + +TBool CTransAnim::OfferRawEvent(const TRawEvent& /*aRawEvent*/) + { + return EFalse; + } + +// an anim dll that doesn't remove itself from the event handler list +CTestHandlerAnim::~CTestHandlerAnim() + { + } + +void CTestHandlerAnim::ConstructL(TAny* /*aArgs*/, TBool /*aHasFocus*/) + { + iFunctions->GetRawEvents(ETrue); + } + +void CTestHandlerAnim::Redraw() + { + } + +void CTestHandlerAnim::FocusChanged(TBool /*aState*/) + { + } + +TInt CTestHandlerAnim::CommandReplyL(TInt /*aOpcode*/, TAny* /*aArgs*/) + { + return KErrNone; + } + +void CTestHandlerAnim::Command(TInt /*aOpcode*/, TAny* /*aArgs*/) + { + } + +void CTestHandlerAnim::Animate(TDateTime* /*aDateTime*/) + { + } + +TBool CTestHandlerAnim::OfferRawEvent(const TRawEvent &/*aRawEvent*/) + { + return EFalse; + } + +// CRemovableAnim Test removal of anim during event handling // +CRemovableAnim::~CRemovableAnim() + { + } + +TInt CRemovableAnim::AddExpectedEvent(const TAnimRawEvent* aEvent) + { + if (TotalExpectedEvents() + EventCount() < iLifetime) + { + return (AddEvent(aEvent) ? KErrNone : KErrOverflow); + } + else + { + return KErrNone; + } + } + +TInt CRemovableAnim::CommandReplyL(TInt aOpcode,TAny* aParam) + { + TAnimArgUnion pData; + pData.any=aParam; + switch (aOpcode) + { + case EADllSetEventHandlerLifetime: + iLifetime = *pData.Int; + return iLifetime; + case EADllEventHandlerLifetime: + return iLifetime; + case EADllAddToEventHandlers: + iFunctions->GetRawEvents(ETrue); + return KErrNone; + case EADllRemoveFromEventHandlers: + iFunctions->GetRawEvents(EFalse); + return KErrNone; + case EADllTestPassed: + { + // If any unexpected events are received, then Error() > 0 + // If fewer than the number of expected events are received, then TotalExpectedEvents() > 0 + TBool passed = (Error() == 0) && (TotalExpectedEvents() == 0); + return passed; + } + default: + return CEventTestAnimBase::CommandReplyL(aOpcode, aParam); + } + } + + +TBool CRemovableAnim::OfferRawEvent(const TRawEvent& aRawEvent) + { + TBool eat = CEventTestAnimBase::OfferRawEvent(aRawEvent); + + // Remove anim from event handlers if lifetime has been exceeded + if (EventCount() >= iLifetime) + { + iFunctions->GetRawEvents(EFalse); + } + return eat; + } + +// CMultiPointerAnim for Testing multipointerevents for anims // +CMultiPointerAnim::~CMultiPointerAnim() + { + iFunctions->GetRawEvents(EFalse); + } + +// Important thing here is to call GetRawEvents() which Switches animation raw event handling on +void CMultiPointerAnim::ConstructL(TAny */*aArgs*/, TBool /*aHasFocus*/) + { + iExpectedEvents.SetLengthL(EEventBufferSize); + iFunctions->GetRawEvents(ETrue); + } + +void CMultiPointerAnim::Animate(TDateTime */*aDateTime*/) + { + } + +void CMultiPointerAnim::Command(TInt /*aOpcode*/, TAny */*aArgs*/) + { + } + +TInt CMultiPointerAnim::CommandReplyL(TInt aOpcode, TAny *aArgs) + { + TAnimArgUnion pData; + pData.any=aArgs; + switch (aOpcode) + { + case EADllAddExpectedMultiPtrEvent: + return AddEvent(pData.AnimRawEvent); + case EADllMultiPtrEventError: + return iError; + case EADllMultiPtrEventErrorDesc: + if (iError != KErrNone) + { + // returns the error description which gets displayed in logs if test failed + const RMessagePtr2& message=*iFunctions->Message(); + const TInt error=message.Write(KIpcSlot, iErrorDes); + if (error != KErrNone) + { + return error; + } + } + break; + case EADllMultiPtrEventReset: + iExpectedEvents.Reset(); + iError = 0; + iEventCount = 0; + break; + default:; + } + return(KErrNone); + } + +void CMultiPointerAnim::Redraw() + { + } + +void CMultiPointerAnim::FocusChanged(TBool /*aState*/) + { + } + +TBool CMultiPointerAnim::OfferRawEvent(const TRawEvent &aRawEvent) + { + // Ignore following raw events + TRawEvent::TType aType=aRawEvent.Type(); + if (aType==TRawEvent::EActive || aType==TRawEvent::EInactive || aType==TRawEvent::ERedraw + || aType==TRawEvent::EPointerSwitchOn || aType==TRawEvent::EUpdateModifiers) + { + return EFalse; + } + + // If it has already failed then do not test other events becasue the error value + // and its descriptor will be over written + if (iError) + { + return EFalse;; + } + + TAnimRawEvent expectedEvent; + if (iExpectedEvents.Remove(&expectedEvent)<1) + { + return EFalse; + } + + // Increment event count + iEventCount++; + + // Call compare events function passing in both the events + if (!CompareEvents(expectedEvent.iRawEvent, aRawEvent)) + { + iError = iEventCount; + } + + return expectedEvent.iEat; + } + +TInt CMultiPointerAnim::AddEvent(const TAnimRawEvent* aEvent) + { + return iExpectedEvents.Add(aEvent); + } + +TBool CMultiPointerAnim::CompareEvents(const TRawEvent& aExpectedEvent, const TRawEvent& aActualEvent) + { + // Check pointer type + if (aExpectedEvent.Type() != aActualEvent.Type()) + { + _LIT(KEventType, "Actual Event type = %d Expected Event Type = %d "); + iErrorDes.Format(KEventType, aActualEvent.Type(), aExpectedEvent.Type()); + return EFalse; + } + + // Here for EOutOfRange we cannot query Pos or Pos3D... + if (aExpectedEvent.Type() != TRawEvent::EPointer3DOutOfRange) + { + // Check 3d position + TPoint3D expected3DPos = aExpectedEvent.Pos3D(); + TPoint3D actual3DPos = aActualEvent.Pos3D(); + if (expected3DPos.iX != actual3DPos.iX) + { + _LIT(KXPosition, "Actual X coordinate = %d Expected X coordinate = %d "); + iErrorDes.Format(KXPosition, actual3DPos.iX, expected3DPos.iX); + return EFalse; + } + if (expected3DPos.iY != actual3DPos.iY) + { + _LIT(KYPosition, "Actual Y coordinate = %d Expected Y coordinate = %d "); + iErrorDes.Format(KYPosition, actual3DPos.iY, expected3DPos.iY); + return EFalse; + } + if (expected3DPos.iZ != actual3DPos.iZ) + { + _LIT(KZPosition, "Actual Z coordinate = %d Expected Z coordinate = %d "); + iErrorDes.Format(KZPosition, actual3DPos.iZ, expected3DPos.iZ); + return EFalse; + } + } + + // Check pointer number + if (aExpectedEvent.PointerNumber() != aActualEvent.PointerNumber()) + { + _LIT(KPointerNumber, "Actual Pointer number = %d Expected Pointer number = %d "); + iErrorDes.Copy(KPointerNumber); + iErrorDes.Format(KPointerNumber, aActualEvent.PointerNumber(), aExpectedEvent.PointerNumber()); + return EFalse; + } + return ETrue; + } + +// CCoverageAnim test drawing/redrawing // +CCoverageAnim::~CCoverageAnim() + { + if(iFont && iFunctions) + iFunctions->CloseFont(iFont); + } + +/** + Initializes members. + */ +void CCoverageAnim::ConstructL(TAny *aParam, TBool ) + { + iRect=*static_cast(aParam); + iWindowFunctions->SetRect(iRect); + iWindowFunctions->Invalidate(iRect); + + iFunctions->SetSync(MAnimGeneralFunctions::ESyncDay); + if (iFunctions->Sync() != MAnimGeneralFunctions::ESyncDay) + User::Leave(KErrGeneral); + + iFunctions->SetSync(MAnimGeneralFunctions::ESyncMinute); + if (iFunctions->Sync() != MAnimGeneralFunctions::ESyncMinute) + User::Leave(KErrGeneral); + + iFunctions->SetSync(MAnimGeneralFunctions::ESyncSecond); + if (iFunctions->Sync() != MAnimGeneralFunctions::ESyncSecond) + User::Leave(KErrGeneral); + + iFunctions->SetSync(MAnimGeneralFunctions::ESyncFlash); + if (iFunctions->Sync() != MAnimGeneralFunctions::ESyncFlash) + User::Leave(KErrGeneral); + + iFunctions->SetSync(MAnimGeneralFunctions::ESyncNone); + if (iFunctions->Sync() != MAnimGeneralFunctions::ESyncNone) + User::Leave(KErrGeneral); + + iFunctions->SetInterval(1); + iFunctions->SetInterval(0); + iFunctions->SetNextInterval(0); + + User::LeaveIfNull(iFunctions->ExtendedInterface(MAnimGeneralFunctions::ENumberOfExtendedInterfaces)); + User::LeaveIfNull(iFunctions->ExtendedInterface(MAnimGeneralFunctions::EWindowExtensionInterface)); + User::LeaveIfNull(iFunctions->ExtendedInterface(MAnimGeneralFunctions::EEventExtentionInterface)); + User::LeaveIfError(iFunctions->ExtendedInterface(MAnimGeneralFunctions::EInterfaceCount) != NULL); + + #if !defined(SYMBIAN_GRAPHICS_GCE) + // Deprecated in NGA but needs to be tested in NONNGA + User::LeaveIfNull((TAny*)iFunctions->ScreenDevice()); + #endif + + iFunctions->Client(); + } + +/** + Copied from CAutoAnimScrBack. + */ +void CCoverageAnim::Animate(TDateTime *) + { + iWindowFunctions->ActivateGc(); + Draw(); + } + +/** + All methods of the graphic-context are executed one by one. + */ +void CCoverageAnim::Draw() + { + iGc->SetClippingRect(iRect); + iGc->Clear(); + iGc->Clear(iRect); + + iGc->SetDrawMode(CGraphicsContext::EDrawModeAND); + iGc->SetBrushStyle(CGraphicsContext::ENullBrush); + iGc->SetBrushColor(TRgb::Gray256(85)); + iGc->SetBrushOrigin(TPoint(0,0)); + iGc->SetPenColor(TRgb::Gray256(170)); + + //primitive method calls + iGc->SetFaded(ETrue); + iGc->SetFadingParameters(1, 1); + + iGc->SetPenStyle(CGraphicsContext::ESolidPen); + iGc->SetStrikethroughStyle(EStrikethroughOff); + iGc->SetUnderlineStyle(EUnderlineOff); + iGc->SetWordJustification(2, 1); + + if(iFont) + iGc->UseFont(iFont); + + iGc->DrawArc(iRect, + TPoint(iRect.Center().iX, iRect.iTl.iY), + TPoint(iRect.iBr.iX, iRect.Center().iY)); + iGc->DrawLine(iRect.iTl,iRect.Center()); + iGc->DrawLineTo(TPoint(iRect.iBr.iX, iRect.iTl.iY)); + + iGc->DrawLineBy(TPoint(iRect.iTl.iX, iRect.iBr.iY)); + iGc->MoveBy(iRect.iTl + TPoint(1,1)); + iGc->MoveTo(iRect.iTl + TPoint(0,0)); + iGc->SetPenSize(TSize(10,10)); + iGc->Plot(iRect.iTl + TPoint(2,2)); + iGc->SetPenSize(TSize(1,1)); + + CArrayFixFlat* polyPoints = new(ELeave) CArrayFixFlat(3); //CArrayFixFlat + CleanupStack::PushL(polyPoints); + polyPoints->AppendL(iRect.iTl); + polyPoints->AppendL(iRect.Center()); + polyPoints->AppendL(TPoint(iRect.iBr.iX, iRect.iTl.iY)); + + iGc->DrawPolyLine(polyPoints); + iGc->DrawPolyLine(&polyPoints->At(0), 3); + iGc->DrawPolygon(polyPoints, CGraphicsContext::EWinding); + iGc->DrawPolygon(&polyPoints->At(0), 3, CGraphicsContext::EAlternate); + + iGc->DrawPie(iRect, TPoint(iRect.Center().iX, iRect.iTl.iY), TPoint(iRect.iBr.iX, iRect.Center().iY)); + iGc->DrawEllipse(iRect); + iGc->DrawRect(iRect); + iGc->DrawRoundRect(iRect, TSize(iRect.Width()/8, iRect.Height()/8)); + + CleanupStack::PopAndDestroy(polyPoints); + + iGc->CopyRect(TPoint(10, 10), iRect); + + CFbsBitmap* bitmap = new(ELeave) CFbsBitmap(); + CleanupStack::PushL(bitmap); + User::LeaveIfError(bitmap->Create(TSize(16,16),EGray4)); + + iGc->UseBrushPattern(bitmap); + iGc->DrawBitmap(iRect.iTl, bitmap); + iGc->DrawBitmap(iRect, bitmap); + iGc->DrawBitmap(iRect, bitmap, TRect(0, 0, 16, 16)); + iGc->DrawBitmapMasked(iRect, bitmap, TRect(0, 0, 16, 16), bitmap, ETrue); + + iGc->BitBlt(TPoint(0, 0), bitmap); + iGc->BitBlt(TPoint(0, 0), bitmap, iRect); + iGc->BitBltMasked(TPoint(0, 0), bitmap, iRect, bitmap, ETrue); + iGc->AlphaBlendBitmaps(TPoint(0, 0), bitmap, iRect, bitmap, TPoint(0,0)); + + CleanupStack::PopAndDestroy(bitmap); + + iGc->SetCharJustification(1,1); + iGc->SetClippingRect(iRect); + if(iFont) + { + _LIT(KHelloWorld,"Hello World"); + iGc->DrawText(*&KHelloWorld, iRect.iTl); + iGc->DrawText(*&KHelloWorld, iRect, 0, CGraphicsContext::ELeft, 0); + iGc->DrawTextVertical(*&KHelloWorld, iRect.iBr, ETrue); + iGc->DrawTextVertical(*&KHelloWorld, iRect, 0, ETrue, CGraphicsContext::ELeft, 0); + } + + TRgb rgbs[2]; + iGc->MapColors(iRect, rgbs, 1, ETrue); + iGc->DiscardBrushPattern(); + + if(iFont) + iGc->DiscardFont(); + + iFunctions->CloseFont(0); + + TDateTime dt = iFunctions->SystemTime(); + } + +/** + Copied from CAutoAnim3. + */ +void CCoverageAnim::Redraw() + { + Draw(); + } + +/** + Copied from CAutoAnim3. + */ +void CCoverageAnim::Command(TInt ,TAny*) + { + } + +/** + Copied from CAutoAnim3. + */ +TInt CCoverageAnim::CommandReplyL(TInt aOpcode , TAny* aParam) + { + TAnimArgUnion pData; + pData.any=aParam; + switch(aOpcode) + { + case EADllDrawNow: + iFunctions->SetSync(MAnimGeneralFunctions::ESyncFlash); + break; + case EADllSetFont: + if(iFont) + { + iFunctions->CloseFont(iFont); + iFont = NULL; + } + iFont = iFunctions->DuplicateFontL(*pData.Int); + break; + } + return(KErrNone); + } + +/** + Copied from CAutoAnim3. + */ +void CCoverageAnim::FocusChanged(TBool ) + {} + +/** + Copied from CAutoAnim3. + */ +TBool CCoverageAnim::OfferRawEvent(const TRawEvent &/*aRawEvent*/) + { + return EFalse; + } + + +// DLL code // + +CAnim *CTestAnimDll::CreateInstanceL(TInt aType) + { + CAnim *anim=NULL; + switch(aType) + { + case EAnimTypeTest1: + anim=new(ELeave) CPanicAnim(); + break; + case EAnimTypeTest2: + anim=new(ELeave) CPanicAnim2(); + break; + case EAnimTypeTest3: + anim=new(ELeave) CAutoAnim3(); + break; + case EAnimTypeScrBackTest: + anim=new(ELeave) CAutoAnimScrBack(); + break; + case EAnimTypeSprite: + anim=new(ELeave) CTestSpriteAnim(); + break; + case EAnimTypeFreeTimer: + anim=new(ELeave) CTestFreeTimerAnim(); + break; + case EAnimTypeEventTest: + anim=new(ELeave) CEventTestAnim(); + break; + case EAnimTypeNotificationTest: + anim=new(ELeave) CNotificationTestAnim(); + break; + case EAnimTypeTimer: + anim=new(ELeave) CTimerTestAnim(); + break; + case EAnimTypeWindowFunctions: + anim=new(ELeave) CWinFunctionTestAnim(); + break; + case EAnimTypeTrans: + anim=new(ELeave) CTransAnim(); + break; + case EAnimTypeEventHandler: + anim = new (ELeave) CTestHandlerAnim(); + break; + case EAnimTypeRemovableAnim: + anim=new(ELeave) CRemovableAnim(); + break; + case EAnimTypeEventPostingTest: + anim=new(ELeave) CEventPostingAnim(); + break; + case EAnimTypeCoverage: + anim=new(ELeave) CCoverageAnim(); + break; + case EAnimTypeMultiPointer: + anim=new(ELeave) CMultiPointerAnim(); + break; + } + return(anim); + } + +// Dummy E32Dll needed by E32 to build // + +void CAutoAnim3::DrawTestScreenL(const TDrawTestScreen* aParams) +//Moved here as the include messes up the debugging of the rest of the file. + { + CFbsBitmap *aBitmap=iFunctions->DuplicateBitmapL(aParams->bitmap); + CleanupStack::PushL(aBitmap); + CFbsBitmap *aMaskBitmap=iFunctions->DuplicateBitmapL(aParams->maskBitmap); + CleanupStack::PushL(aMaskBitmap); + CFbsFont *aFont=iFont=iFunctions->DuplicateFontL(aParams->font); + TSize size(iWindowFunctions->WindowSize()); + iWindowFunctions->ActivateGc(); + CBitmapContext *gc=iGc; + TBool aExtraDrawBitMap=ETrue; +// +#include "DLLDRAW.H" +// + iFunctions->CloseFont(iFont); + iFont=NULL; + CleanupStack::PopAndDestroy(2); + } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/AUTODLL.H --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/AUTODLL.H Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,352 @@ +// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Header defs for ANIMDLL +// +// + +#ifndef __AUTODLL_H__ +#define __AUTODLL_H__ + + +#if !defined(__W32ADLL_H__) +#include +#endif + +#ifdef SYMBIAN_GRAPHICS_GCE +_LIT(KAnimDLLName,"autodl_nga.dll"); +#else +_LIT(KAnimDLLName,"autodl_nonnga.dll"); +#endif + +const TInt KIpcSlot=1; + +struct CTAParams + { + TPoint pos; + TInt interval; + TInt bit1; + TInt bit2; + }; + +struct TAnimRawEvent + { + //inline TAnimRawEvent(TRawEvent& aRawEvent,TBool aEat) :iRawEvent(aRawEvent), iEat(aEat) {} + TRawEvent iRawEvent; + TBool iEat; + }; + +enum AnimDllPanicOpcodes + { + EADllPanicCallPanic, + EADllPanicSetInterval, + EADllPanicSetNextInterval, + EADllPanicBadFont, + EADllPanicBadBitmap, + EADllPanicLeave, + EADllPanicDestroy, + EADllPanicOpcode, + EADllPanicDoubleActivateGC, + EADllPanicDrawRectWithNoGc, + EADllPanicDrawTextWithNoFont, + EADllPanicLeaveInAnimate, + EADllPanicLeaveInRedraw, + EADllPanicSetVisWithGcActive, + EADllReadRemoteDescriptor, + EADllSyncTests, + EADllTimeChangedTest, + EADllTestWindowSize, + EADllTestSetVisible, + EADllPanicSetVisWithGcActiveReply, + EADllBlankOpCode, + EADllPanicLeaveInActiveCallback, + EADllPanicSetClippingRectWithNoGc, + EADllPanicSetClippingRegionWithNoGc, + EADllPanicCancelClippingRegionWithNoGc, + EADllPanicCancelClippingRectWithNoGc, + EADllPanicSetDrawModeWithNoGc, + EADllPanicUseFontWithNoGc, + EADllPanicDiscardFontWithNoGc, + EADllPanicSetUnderlineStyleWithNoGc, + EADllPanicSetStrikeThoughStyleWithNoGc, + EADllPanicSetWordJustificationWithNoGc, + EADllPanicSetCharJustificationWithNoGc, + EADllPanicSetPenColorWithNoGc, + EADllPanicSetPenStyleWithNoGc, + EADllPanicSetPenSizeWithNoGc, + EADllPanicSetBrushColorWithNoGc, + EADllPanicSetBrushStyleWithNoGc, + EADllPanicSetBrushOriginWithNoGc, + EADllPanicUseBrushPatterWithNoGc, + EADllPanicDiscardBrushPatternWithNoGc, + EADllPanicSetFadedWithNoGc, + EADllPanicSetFadingParametersWithNoGc, + EADllPanicDrawArcWithNoGc, + EADllPanicDrawPieWithNoGc, + EADllPanicDrawLineWithNoGc, + EADllPanicDrawLineToWithNoGc, + EADllPanicDrawLineByWithNoGc, + EADllPanicDrawEllipseWithNoGc, + EADllPanicDrawRoundedRecWithNoGc, + EADllPanicClearWithRectWithNoGc, + EADllPanicClearWithNoGc, + EADllPanicBitBltWithNoGc, + EADllPanicBitBltWithRectWithNoGc, + EADllPanicBitBltMaskedWithNoGc, + EADllPanicDrawBitmapPointWithNoGc, + EADllPanicDrawBitmapWithNoGc, + EADllPanicDrawBitmapRectWithNoGc, + EADllPanicDrawBitmapMaskedFbsBitmapWithNoGc, + EADllPanicDrawBitmapMaskedWsBitmapWithNoGc, + EADllPanicDrawPolyLinePointsWithNoGc, + EADllPanicDrawPolyLineArrayWithNoGc, + EADllPanicDrawPolygonPointsWithNoGc, + EADllPanicDrawPolygonArrayWithNoGc, + EADllPanicMoveToWithNoGc, + EADllPanicMoveByWithNoGc, + EADllPanicPlotWithNoGc, + EADllPanicSetOriginWithNoGc, + EADllPanicCopyRectWithNoGc, + EADllPanicResetWithNoGc, + EADllPanicAlphaBlendingBitmapsFbsBitmapWithNoGc, + EADllPanicMapColorsWithNoGc, + EADllPanicDrawTextWithRectWithNoFont, + EADllPanicDrawTextVerticalWithNoFont, + EADllPanicDrawTextVerticalWithRectWithNoFont, + EADllPanicDevice, + EADllPanicInvalidFocusScreenTooBig, + EADllPanicInvalidFocusScreenNegative, + }; + +enum AnimDllTestOpcodes + { + }; + +enum AnimDllOpcodes3 + { + EADllSetRect, + EADllStartAnimate, + EADllCancelAnimate, + EADllSetVisible, + EADllSetShadowDrawMode, + EADllShadowAnimTest, + EADllDrawTestScreen, + EADllParameterRectValueTest, + EADllDoSetSync, + EADllSetInterval, + EADllSetMode + }; + +enum AnimDllOpcodesScrBack + { + EADllDrawOtherRect, + EADllIsHidden, + }; + +enum AnimDllOpcodesSprite + { + EADllActivate, + EADllDeactivate, + EADllCheckMember, + EADllSizeChanged, + EADllSetPos, + EADllDraw1, + EADllDraw2, + EADllDraw3, + EADllIncDraw, + }; + +enum AnimDllOpcodesFreeTimer + { + EStartAnimation, + EStopAnimation, + ESetFrameTime + }; + +enum AnimDllOpcodesTimer + { + EADllNoTimer, + EADllTimerStarted, + EADllResetCount, + EADllCurrentCount, + EADllFailed, + }; + +enum AnimDllWinFunctions + { + EADllScreen, + EADllFocusScreen, + EADllWindowGroups, + EADllWindowGroupInfo, + EADllWindowGroupName, + EADllSetOrdinalPosition, + EADllSetFocusScreen, + }; + +enum AnimDllOpcodesNotificationTest + { + EADllQueryDSA, + EADllQueryHeartbeatState, + EADllIsAnimating, + }; + +enum AnimDllTransTest + { + EADllDrawNow, + EADllNextFrame, + EADllStartAnimText, + EADllEndAnimText, + EADllSetSync, + EADllSetFont, + }; + +enum TAnimTypes + { + EAnimTypeTest1, + EAnimTypeTest2, + EAnimTypeTest3, + EAnimTypeScrBackTest, + EAnimTypeSprite, + EAnimTypeFreeTimer, + EAnimTypeEventTest, + EAnimTypeEventPostingTest, + EAnimTypeTimer, + EAnimTypeWindowFunctions, + EAnimTypeNotificationTest, + EAnimTypeTrans, + EAnimTypeEventHandler, + EAnimTypeRemovableAnim, + /** CWsAnimGc functional coverage */ + EAnimTypeCoverage, + EAnimTypeMultiPointer, + }; + +enum {ERemoteBufSize=0x10}; +enum FlashState{EStateNone,EStateFlash,EStateSecond,EStateMinute}; + +enum AnimDllOpcodesEventTestAnimBase + { + EADllAddExpectedEvent, + EADllNumberOfEventsReceived, + EADllErrorCode, + EADllReset, + EADllEventAnimBase_EndBaseEnum, + }; + +enum AnimDllOpcodesEventTestAnim + { + EADllNoEventsAndReset=EADllEventAnimBase_EndBaseEnum, + EADllLoadDeviceDriver, + EADllUnloadDeviceDriver, + EADllSendEvent, + EADllAfterEvent, + }; + +enum AnimDllOpcodesRemovableAnim + { + EADllSetEventHandlerLifetime=EADllEventAnimBase_EndBaseEnum, + EADllEventHandlerLifetime, + EADllAddToEventHandlers, + EADllRemoveFromEventHandlers, + EADllTestPassed, + }; + +enum AnimDllOpcodeMultiPointerAnim + { + EADllAddExpectedMultiPtrEvent, + EADllMultiPtrEventError, + EADllMultiPtrEventErrorDesc, + EADllMultiPtrEventReset, + }; + +struct TRemoteBufAddress + { + TAny *descPtr; + }; +struct TSyncTests + { + TRequestStatus *status; + MAnimGeneralFunctions::TAnimSync syncMode; + }; +struct TShadowDrawTest + { + TRequestStatus *status; + }; +struct TTimeChangeTest + { + TRequestStatus *status; + TRequestStatus *status2; + }; +struct TDrawTestScreen + { + TInt bitmap; + TInt maskBitmap; + TInt font; + }; +struct TSpriteMemberInfo + { + inline TSpriteMemberInfo() {} + inline TSpriteMemberInfo(TPoint aSpritePos,TInt aMemberNo,const TSpriteMember& aMember); + TPoint iSpritePos; + TInt iMember; + TInt iBitmapHandle; + TInt iMaskBitmapHandle; + TBool iInvertMask; + CGraphicsContext::TDrawMode iDrawMode; + TPoint iOffset; + TTimeIntervalMicroSeconds32 iInterval; + }; +inline TSpriteMemberInfo::TSpriteMemberInfo(TPoint aSpritePos,TInt aMemberNo,const TSpriteMember& aMember) + :iSpritePos(aSpritePos), iMember(aMemberNo), iBitmapHandle(aMember.iBitmap->Handle()), + iMaskBitmapHandle(aMember.iMaskBitmap ? aMember.iMaskBitmap->Handle():0), iInvertMask(aMember.iInvertMask), + iDrawMode(aMember.iDrawMode), iOffset(aMember.iOffset), iInterval(aMember.iInterval) + {} +struct TWindowGroupInfoParms + { + TInt iScreen; + TInt iOrdinalPosition; + }; +struct TSetOrdinalParms + { + TInt iIdentifier; + TInt iOrdinalPosition; + TInt iOrdinalPriority; + }; +struct TFrameData + { + TInt sync; + TInt font; + TInt bitmap; + TRgb color; + TInt draw; + TInt text; + TRect rect; + }; + +class RTestAnim : public RAnim + { +public: + RTestAnim(); + RTestAnim(RAnimDll &aDll); + inline TInt Construct(const RWindowBase &aWin,TInt aType,const TDesC8 &aParams) {return(RAnim::Construct(aWin,aType,aParams));} + inline TInt Construct(const RWindowBase &aDevice,const TRect &aRect) {return(RAnim::Construct(aDevice, EAnimTypeScrBackTest,TPtrC8((TUint8 *)&aRect,sizeof(aRect))));} + inline TInt Construct(const RWsSprite &aSprite,TInt aType,const TDesC8 &aParams) {return(RAnim::Construct(aSprite,aType,aParams));} + inline TInt CommandReply(TInt aOpcode,const TDesC8& aArgs,const TIpcArgs& aIpcArgs) {return(RAnim::CommandReply(aOpcode,aArgs,aIpcArgs));} + inline TInt CommandReply(TInt aOpcode,const TPtrC8 &aArgs) {return(RAnim::CommandReply(aOpcode,aArgs));} + inline TInt CommandReply(TInt aOpcode) {return(RAnim::CommandReply(aOpcode));} + inline void Command(TInt aOpcode,const TPtrC8 &aArgs) {RAnim::Command(aOpcode,aArgs);} + inline void Command(TInt aOpcode) {RAnim::Command(aOpcode);} + inline void ChangeRect(const TRect &aRect) {RAnim::Command(EADllDrawOtherRect,TPtrC8((TUint8 *)&aRect,sizeof(aRect)));} + }; + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/AUTOTEST.TXT --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/AUTOTEST.TXT Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,316 @@ +Fully Tested +============ +class RWindow : public RWindowBase + { + IMPORT_C void Scroll(const TPoint &aOffset); + IMPORT_C void Scroll(const TPoint &aOffset, const TRect &aRect); + IMPORT_C void Scroll(const TRect &aClipRect, const TPoint &aOffset); + IMPORT_C void Scroll(const TRect &aClipRect, const TPoint &aOffset, const TRect &aRect); + IMPORT_C TInt OrdinalPosition() const; + IMPORT_C void SetOrdinalPosition(TInt aPos); + IMPORT_C void SetOrdinalPosition(TInt aPos,TOrdinalPriority aOrdinalPriority); + } + +class RWs : public RSessionBase + { + } + +class RBitmap : public RDrawBase + { + } + +class RWindowBase : public RDrawBase + { + } + +class RRootWindow : public RWindowBase + { + } + +class RFont : public RFontBase + { + } + +class RBrush : public RBrushBase + { + } + +class RPalette : public RPaletteBase + { + } + +class RGc : public RGdiBase + { + IMPORT_C void GetPixels(const TPoint &aPoint,TInt aNumOfPixels,TPtr8 &aScanLine)const; + IMPORT_C void DrawLine(const TPoint &aPoint1,const TPoint &aPoint2); + IMPORT_C void ClearDI(TRgb aColour); + IMPORT_C void ClearDI(TRgb aColour,const TRect &aRect); + IMPORT_C void ClearTrapezium(const TRect &aRect,TInt aSkew,TBool aHorizontal); + IMPORT_C void DrawDottedLine(const TPoint &aPoint1,const TPoint &aPoint2,TUint aDashPattern,TInt aDashedLength); + IMPORT_C void DrawTrapezium(const TRect &aRect,TInt aSkew,TBool aHorizontal); + IMPORT_C void FillTrapezium(const TRect &aRect,TInt aSkew,TBool aHorizontal); + IMPORT_C void GdiBltMasked(const TPoint &aDestination,const RDrawBase &aDrawPtr,const TRect &aSource,const RDrawBase &aMask,TRgb aCutoff,TBool aLowMasked); + IMPORT_C void DrawParallelogram(const TRect &aRect,TInt aSkew,TBool aHorizontal); + IMPORT_C void ClearParallelogram(const TRect &aRect,TInt aSkew,TBool aHorizontal); + IMPORT_C void FillParallelogram(const TRect &aRect,TInt aSkew,TBool aHorizontal); + IMPORT_C void PaintParallelogram(const TRect &aRect,TInt aSkew,TBool aHorizontal); + IMPORT_C void PaintTrapezium(const TRect &aRect,TInt aSkew,TBool aHorizontal); + IMPORT_C void ResetDotParam(); + } + +Partially tested +================ +class RWindow : public RWindowBase + { + } + +class RWs : public RSessionBase + { + } + +class RBitmap : public RDrawBase + { + } + +class RWindowBase : public RDrawBase + { + } + +class RRootWindow : public RWindowBase + { + } + +class RFont : public RFontBase + { + } + +class RBrush : public RBrushBase + { + } + +class RPalette : public RPaletteBase + { + } + +class RGc : public RGdiBase + { + } + + +Not tested +========== +class RWs : public RSessionBase + { + IMPORT_C RWs(); + IMPORT_C TInt Connect(TUint32 aHandle); + IMPORT_C void Disconnect(); + IMPORT_C TVersion Version(); + IMPORT_C TInt SetHotKey(THotKeyType aType, TUint aKeycode, TUint aModifier, TUint aModifierMask); + IMPORT_C TInt CaptureKey(TUint keyCode,TUint mod_mask,TUint modifiers); + IMPORT_C void CancelHotKey(TInt aHotKey); + IMPORT_C void CancelCaptureKey(TInt aCaptureKey); + IMPORT_C void DisplayInfo(TUint aMode, TDisplayInfo *aInfo); + IMPORT_C void ComputeMode(TComputeMode mode); + IMPORT_C void Info(TInt aClientHandle,TxInfo &aInfo); + IMPORT_C void ReadEvent(TPckgBuf &aEvent,TInt *stat,TUint blocks=0); + IMPORT_C void ReadEventUpdate(TUint blocks); + IMPORT_C void ReadEventCancel(); + IMPORT_C TInt BufferSize(TInt aBufSize); + IMPORT_C void Flush(); + IMPORT_C TBool SetAutoFlush(TBool aState); + IMPORT_C TInt HeapCount() const; + IMPORT_C void SetTextCursor(RWindow &aWin, const TPoint &aPos, const TTextCursor &aCursor); + IMPORT_C void CancelTextCursor(); + IMPORT_C void MarkStart(); + IMPORT_C void CheckNum(TUint aCount); + IMPORT_C void MarkEnd(TUint aCount); + IMPORT_C TInt ResourceCount(); + inline RBuffer *Buffer() const; + }; + +class RBitmap : public RDrawBase + { + IMPORT_C RBitmap(); + IMPORT_C RBitmap(RWs &aWs); + IMPORT_C void Close(); + IMPORT_C void Destroy(); +// IMPORT_C void Construct(TSize &size,TInt colourBits); + IMPORT_C TInt Construct(TSize &size); + IMPORT_C TInt Load(const TDesC &aFileName,TReadWrite access=EReadOnly); + IMPORT_C void Attributes(TAttributes *attrib); + IMPORT_C TUint Handle() const; + IMPORT_C TGdiAttributes Attributes()const; + IMPORT_C TSize Size()const; + }; + +class RWindowBase : public RDrawBase + { + IMPORT_C RWindowBase(); + IMPORT_C RWindowBase(RWs &aWs); + IMPORT_C void Close(); + IMPORT_C void Destroy(); + IMPORT_C TAttributes Attributes(TInt handle); + IMPORT_C TUint32 Parent() const; + IMPORT_C TUint32 PrevSibling() const; + IMPORT_C TUint32 NextSibling() const; + IMPORT_C TUint32 Child() const; + IMPORT_C TPoint InquireOffset(const RWindowBase &aWindow) const; + IMPORT_C TGdiAttributes Attributes() const; + IMPORT_C TUint Handle() const; + IMPORT_C TSize Size() const; + IMPORT_C TPoint Position() const; + }; + +class RWindow : public RWindowBase + { + IMPORT_C RWindow(); + IMPORT_C RWindow(RWs &aWs); + IMPORT_C TInt Construct(const RWindowBase &parent,TUint32 handle); + IMPORT_C void Activate(); + IMPORT_C TAttributes Attributes(); + IMPORT_C void BeginRedraw(); + IMPORT_C void BeginRedraw(const TRect &rect); + IMPORT_C void EndRedraw(); + IMPORT_C void Invalidate(); + IMPORT_C void Invalidate(const TRect &rect); + IMPORT_C void Validate(); + IMPORT_C void Validate(const TRect &rect); + IMPORT_C void SetPosition(const TPoint &point); + IMPORT_C TInt SetSize(const TSize &size); + IMPORT_C TInt SetExtent(const TPoint &point,const TSize &size); + IMPORT_C TInt SetExtent(TInt tlx,TInt tly,TInt width, TInt height); + IMPORT_C void SetAttributes(TUint flags,const TAttributes &windata); + IMPORT_C void SetTextCursor(const TTextCursor cursor); + IMPORT_C void CancelTextCursor(); + IMPORT_C void PointerFilter(TUint32 aFilter); + IMPORT_C void SetPointerGrab(TBool aState); + IMPORT_C void SetPointerCapture(TBool aState); + IMPORT_C void SetBackgroundColour(TRgb aColour); + IMPORT_C void SetVisible(TBool aState); + IMPORT_C TInt SetCurrentRegion(const TRegion &aRegion); + IMPORT_C void CancelCurrentRegion(); + }; + +class RRootWindow : public RWindowBase + { + IMPORT_C RRootWindow(); + IMPORT_C RRootWindow(RWs &aWs); + IMPORT_C TInt Construct(TUint32 clientHandle); + }; + +class RFont : public RFontBase + { + IMPORT_C RFont(); + IMPORT_C RFont(RWs &aWs); + IMPORT_C void Close(); + IMPORT_C void Destroy(); + IMPORT_C TInt Construct(const TFont &aFont); + IMPORT_C TUint Handle()const; + IMPORT_C TInt Height()const; + IMPORT_C TInt Ascent()const; + IMPORT_C TInt Descent()const; + IMPORT_C TInt AverageWidth()const; + IMPORT_C TInt MaximumWidth()const; + IMPORT_C TBool Bold()const; + IMPORT_C TBool Italic()const; + IMPORT_C TBool Underline()const; + IMPORT_C TBool CrossOut()const; + IMPORT_C void WidthTable(TUint aStartChar,TUint aFinishChar,TPtr8 &)const; + IMPORT_C TInt TextWidth(const TDesC &aBuf)const; + IMPORT_C TInt TextCount(const TDesC &aBuf,TInt aPixelCount)const; + IMPORT_C TInt TextCount(const TDesC &aBuf,TInt aPixelCount,TInt &aWidth)const; + }; + +class RBrush : public RBrushBase + { +public: + IMPORT_C RBrush(); + IMPORT_C RBrush(RWs &aWs); + IMPORT_C void Close(); + IMPORT_C void Destroy(); + IMPORT_C TInt Construct(const TDesC &aFileName,RFs &aFileSys); + IMPORT_C TUint Handle()const; + IMPORT_C TSize Size()const; + IMPORT_C TRgb Pixel(const TPoint &aPoint)const; + IMPORT_C void GetPixels(const TPoint &aPoint,TInt aPelLength,TInt aMode,TPtr8 &aBuffer)const; + IMPORT_C void SetThreshold(TUint aThreshold); +private: + TInt32 iHandle; + RBuffer *iBuffer; + }; + +class RPalette : public RPaletteBase + { + IMPORT_C RPalette(); + IMPORT_C RPalette(RWs &aWs); + IMPORT_C void Close(); + IMPORT_C void Destroy(); + IMPORT_C void Clear(); + IMPORT_C void SetEntry(TInt aPaletteIndex,TRgb aPaletteEntry); + IMPORT_C void SetBlock(TInt aStartIndex,TInt aNumberOfEntries,TPtr8 &aBufferOfEntries); + IMPORT_C TRgb GetEntry(TInt aPaletteIndex) const; + IMPORT_C void GetBlock(TInt aStartIndex,TInt aNumberOfEntries,TPtr8 &aBuffer) const; + IMPORT_C TInt Entries() const; + IMPORT_C TUint Handle()const; + }; + +class RGc : public RGdiBase + { + IMPORT_C RGc(); + IMPORT_C RGc(RWs &aWs); + IMPORT_C void Close(); + IMPORT_C void Destroy(); + IMPORT_C TInt Construct(); + IMPORT_C void Activate(const RDrawBase &aDrawable); + IMPORT_C void Deactivate(); + IMPORT_C void FillRect(const TRect &aRect); + IMPORT_C void PrintText(const TPoint &aPosition,const TDesC &aString); + IMPORT_C void PrintText(const TDesC &aString); + IMPORT_C void SetPenGrey4(TUint aGrey4); + IMPORT_C void SetPenGrey16(TUint aGrey16); + IMPORT_C void SetPenGrey256(TUint aGrey256); + IMPORT_C void Clear(); + IMPORT_C void CopyRect(const TPoint &anOffset,const TRect &aRect); + IMPORT_C void DrawEllipse(const TRect &aRect); + IMPORT_C void DrawRect(const TRect &aRect); + IMPORT_C void ClearRect(const TRect &aRect); + IMPORT_C void FillEllipse(const TRect &aRect); + IMPORT_C void PaintEllipse(const TRect &aRect); + IMPORT_C void ClearEllipse(const TRect &aRect); + IMPORT_C void PaintRect(const TRect &aRect); + IMPORT_C void GdiBlt(const RDrawBase &aDevice); + IMPORT_C void GdiBlt(const TPoint &aDestination,const RDrawBase &aDevice); + IMPORT_C void GdiBlt(const TPoint &aDestination,const RDrawBase &aDevice,const TRect &aSource); + IMPORT_C TInt DisplayMode()const; + IMPORT_C TGdiDrawMode DrawMode()const; +// IMPORT_C TUint DisplayModesAvailable()const; + IMPORT_C TRgb Pixel(const TPoint &aPixel)const; + IMPORT_C TSize Size()const; + IMPORT_C RBrushBase *PatternBrush()const; + IMPORT_C TRgb PenColour()const; + IMPORT_C TRgb BrushColour()const; + IMPORT_C TTextBackGround TextBackGround()const; + IMPORT_C void Plot(const TPoint &aPoint); + IMPORT_C void SetBrushGrey4(TUint aGrey4); + IMPORT_C void SetBrushGrey16(TUint aGrey16); + IMPORT_C void SetBrushGrey256(TUint aGrey256); + IMPORT_C void SetPenColour(const TRgb &aColour); + IMPORT_C void SetBrushColour(const TRgb &aColour); + IMPORT_C TInt SetDisplayMode(TUint aDisplayMode); + IMPORT_C void SetDrawMode(TGdiDrawMode aDrawingMode); + IMPORT_C void SetLineWidth(TInt aWidth); + IMPORT_C void SetPatternBrushOrigin(const TPoint &aOrigin); + IMPORT_C void SetTextBackGround(TTextBackGround aBackGroundSetting); + IMPORT_C RFont Font()const; + IMPORT_C void UseFont(const RFontBase &aFont); + IMPORT_C void UsePalette(const RPaletteBase &aPalette); + IMPORT_C void UsePatternBrush(const RBrushBase &aBrush); + IMPORT_C void DiscardFont(); + IMPORT_C void DiscardPalette(); + IMPORT_C void DiscardPatternBrush(); + IMPORT_C TUint Handle() const; + IMPORT_C TInt LoadBitmap(const TDesC &aFileName, RFs &aFileSys); + IMPORT_C TInt LoadBitmapDI(const TDesC &aFileName,RFs &aFileSys); + IMPORT_C TGdiAttributes Attributes()const; + IMPORT_C void RefreshPalette(); + } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/BLUEHASH.PBM Binary file windowing/windowserver/test/tauto/BLUEHASH.PBM has changed diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/DLLDRAW.H --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/DLLDRAW.H Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,144 @@ +// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Lots of different Drawing Commands +// +// + + gc->SetBrushColor(TRgb::Gray4(2)); + gc->Clear(); + gc->SetBrushColor(TRgb::Gray4(0)); + gc->Clear(TRect(2,2,20,5)); + gc->DrawRect(TRect(size)); + gc->SetBrushOrigin(TPoint(1,2)); + gc->SetBrushStyle(CGraphicsContext::EForwardDiagonalHatchBrush); + gc->DrawRect(TRect(30,2,60,8)); + gc->SetBrushOrigin(TPoint(0,0)); + gc->UseBrushPattern(aBitmap); + gc->SetBrushStyle(CGraphicsContext::EPatternedBrush); + gc->DrawRect(TRect(60,2,90,8)); + gc->SetBrushStyle(CGraphicsContext::ENullBrush); + gc->DiscardBrushPattern(); +// + gc->SetPenColor(TRgb::Gray4(1)); + gc->DrawLine(TPoint(10,12),TPoint(22,20)); + gc->SetPenSize(TSize(4,2)); + gc->DrawLine(TPoint(22,10),TPoint(40,20)); + gc->SetPenStyle(CGraphicsContext::EDottedPen); + gc->SetPenSize(TSize(1,1)); + gc->SetPenColor(TRgb::Gray4(0)); + gc->DrawLine(TPoint(40,11),TPoint(60,20)); + gc->SetPenStyle(CGraphicsContext::ESolidPen); + gc->Plot(TPoint(60,10)); +// + gc->BitBlt(TPoint(size.AsPoint()-TPoint(20,20)),aBitmap); + gc->BitBlt(TPoint(10,30),aBitmap,TRect(0,1,8,9)); + gc->BitBltMasked(TPoint(10,40),aBitmap,TRect(1,2,8,9),aMaskBitmap,ETrue); + gc->BitBltMasked(TPoint(20,40),aBitmap,TRect(0,0,9,9),aMaskBitmap,EFalse); + gc->SetOrigin(TPoint(5,50)); + gc->SetDrawMode(CGraphicsContext::EDrawModeXOR); + gc->SetPenColor(TRgb::Gray4(3)); + gc->SetClippingRect(TRect(0,0,20,15)); + //gc->DrawArc(TRect(0,0,20,15),TPoint(10,0),TPoint(1,8)); + gc->CancelClippingRect(); + gc->SetDrawMode(CGraphicsContext::EDrawModePEN); + gc->SetPenColor(TRgb::Gray4(0)); + gc->MoveTo(TPoint(25,0)); + gc->DrawLineTo(TPoint(40,5)); + gc->DrawLineBy(TPoint(-20,10)); +// + CArrayFixFlat* polyLineArray=new(ELeave) CArrayFixFlat(4); + CleanupStack::PushL(polyLineArray); + polyLineArray->AppendL(TPoint(8,0)); + polyLineArray->AppendL(TPoint(16,10)); + polyLineArray->AppendL(TPoint(0,3)); + polyLineArray->AppendL(TPoint(16,3)); + polyLineArray->AppendL(TPoint(0,10)); + polyLineArray->AppendL(TPoint(8,0)); + gc->SetBrushStyle(CGraphicsContext::ESolidBrush); + gc->SetOrigin(TPoint(50,50)); + gc->DrawPolyLine(polyLineArray); + gc->SetOrigin(TPoint(75,50)); + gc->DrawPolyLine(&(polyLineArray->At(0)),polyLineArray->Count()); + polyLineArray->Delete(5); + gc->SetOrigin(TPoint(0,65)); + gc->DrawPolygon(polyLineArray,CGraphicsContext::EWinding); + gc->SetOrigin(TPoint(25,65)); + gc->DrawPolygon(&(polyLineArray->At(0)),polyLineArray->Count(),CGraphicsContext::EWinding); + gc->SetOrigin(TPoint(50,65)); + gc->DrawPolygon(polyLineArray,CGraphicsContext::EAlternate); + gc->SetOrigin(TPoint(75,65)); + gc->DrawPolygon(&(polyLineArray->At(0)),polyLineArray->Count(),CGraphicsContext::EAlternate); + CleanupStack::PopAndDestroy(); + gc->SetBrushStyle(CGraphicsContext::ENullBrush); + gc->SetOrigin(TPoint(0,0)); +// + gc->DrawPie(TRect(5,80,30,100),TPoint(10,65),TPoint(35,80)); + gc->DrawEllipse(TRect(35,80,60,100)); + gc->DrawRoundRect(TRect(65,80,80,100),TSize(5,3)); + gc->DrawBitmap(TRect(10,105,40,120),aBitmap); + gc->DrawBitmap(TRect(45,105,105,125),aBitmap,TRect(5,5,25,20)); +//gc->DrawBitmap(TRect(110,40,205,125),aBitmap,TRect(5,5,25,20)); + if (aExtraDrawBitMap) + gc->DrawBitmap(TPoint(110,70),aBitmap); +// + gc->UseFont(aFont); + TInt height=aFont->HeightInPixels(); + TInt ascent=aFont->AscentInPixels(); + TInt ypos=5; + TInt xpos=100; + gc->DrawText(_L("Test1"),TPoint(xpos,ypos+ascent)); + gc->DrawText(_L("Test2"),TRect(xpos,ypos+height,xpos+50,5+height*2),ascent); + gc->DrawText(_L("Test3"),TRect(xpos,ypos+height*2,xpos+80,5+height*3),ascent,CGraphicsContext::ERight,10); +// + ypos+=ascent+height*3; + gc->SetUnderlineStyle(EUnderlineOn); + gc->DrawText(_L("ULine"),TPoint(xpos,ypos)); + gc->SetUnderlineStyle(EUnderlineOff); +// + gc->SetStrikethroughStyle(EStrikethroughOn); + gc->DrawText(_L("Strike"),TPoint(xpos+50,ypos)); + gc->SetStrikethroughStyle(EStrikethroughOff); + gc->SetCharJustification(15,3); + gc->DrawText(_L("abc"),TPoint(xpos+100,ypos)); +// + gc->SetWordJustification(10,1); + gc->DrawText(_L("Two Words"),TPoint(xpos+5,ypos+height)); +// + xpos = 80; + ypos = 40; + RRegion clipRegion(2); +// + clipRegion.AddRect(TRect(xpos, ypos+10, xpos+30, ypos+20)); + clipRegion.AddRect(TRect(xpos, ypos+30, xpos+30, ypos+40)); + gc->SetClippingRegion(clipRegion); +// + gc->DrawTextVertical(_L("Vertical Text"), TPoint(xpos+10, ypos+10), EFalse); + gc->DrawTextVertical(_L("Vertical Text Box"), TRect(xpos+40, ypos+10, xpos+60, ypos+100), 15, EFalse); +// + gc->CancelClippingRegion(); + clipRegion.Close(); +// + gc->AlphaBlendBitmaps(TPoint(xpos+60, ypos+100), aBitmap, TRect(0, 0, 20,20), aMaskBitmap, TPoint(0, 0)); +// + gc->SetPenColor(TRgb::Gray4(3)); + gc->SetBrushColor(TRgb::Gray4(0)); + gc->SetBrushStyle(CGraphicsContext::ESolidBrush); + xpos = 0; + ypos = 120; + TRect mapColorRect(xpos, ypos, xpos+20, ypos+20); + gc->DrawRect(mapColorRect); + TRgb colours[4] = { TRgb::Gray4(3), TRgb::Gray4(0), TRgb::Gray4(0), TRgb::Gray4(3) }; + gc->MapColors(mapColorRect, colours, 2, ETrue); +// + gc->DiscardFont(); diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/Dither.MBM Binary file windowing/windowserver/test/tauto/Dither.MBM has changed diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/GREYLINE.PBM Binary file windowing/windowserver/test/tauto/GREYLINE.PBM has changed diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/MASK0.PBM Binary file windowing/windowserver/test/tauto/MASK0.PBM has changed diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/MASK1.PBM Binary file windowing/windowserver/test/tauto/MASK1.PBM has changed diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/MASK2.PBM Binary file windowing/windowserver/test/tauto/MASK2.PBM has changed diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TALPHAWIN.H --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TALPHAWIN.H Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,136 @@ + +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef __TALPHAWIN_H__ +#define __TALPHAWIN_H__ + +#include "AUTO.H" +#include "TGraphicsHarness.h" + +class CTDrawOpWin; +class CTAlphaWindow; +class CTAlphaRefWin; + +class CTAlphaWin : public CTWsGraphicsBase + { +public: + CTAlphaWin(CTestStep* aStep); + ~CTAlphaWin(); + void ConstructL(); + void TestCondition(); + void TestConditionL(); +protected: +//from CTGraphicsStep + virtual void RunTestCaseL(TInt aCurTestCase); +private: + void ConfigureDisplayModes(TDisplayMode aRequiredMode); + // The blending test works as follows: + // On the left, we have a window which draws using an opaque half-red colour + // On the right, we have a window which blends using a semi-transparent full-red colour + // The test compares left and right + void TestSemiTransparentDrawingL(); + void TestTransparentDrawingL(); + + // The transparent window tests work as follows: + // On the left, we have transparent windows, on which we perform various various operations + // On the right, we have a reference window, in which we draw what we think the windows on the left should look like + // The test compares the right and the left + void TestInitialConfiguration(); + void TestMove(); + void TestRedraw(); + void TestInvisible(); + void TestChildrenL(); + void TestAntiAliasedTextTransparentL(); + void CheckRectL(const TRect& rect1, const TRect& rect2, TSize aSize, TDisplayMode aRequiredMode, TInt aTolerance, const TDesC& aErrorMsg); + +private: + TFixedArray iTestWin; + CTAlphaRefWin* iRefWin; + }; + +class CTDrawOpWin : public CTWin + { +public: + static CTDrawOpWin* NewL(CTAlphaWin* aTest, CTWinBase* aParent, TPoint aPos, TSize aSize, TRgb aDrawColour); + CTDrawOpWin(CTAlphaWin* aTest, TRgb aDrawColour); + + //Virtual Function from CTBaseWin + void Draw(); + + void SetDrawOp(TInt aDrawOp); +private: + CTAlphaWin* iTest; + TRgb iDrawColour; + TInt iDrawOp; + }; + + +class CTAlphaWindow : public CTWin + { + friend class CTAlphaRefWin; +public: + inline CTAlphaWindow(CTAlphaWin* aTest) : iTest(aTest) {} + ~CTAlphaWindow(); + static CTAlphaWindow* NewL(CTAlphaWin* aTest, CTWinBase* aParent, TPoint aPos, TSize aSize, TInt aDrawState); + + //Virtual Function from CTBaseWin + void Draw(); + + void SetDrawState(TInt aDrawState); + TInt DrawState(); + + void SetVisible(TBool aVisible); + void CreateChildrenL(TInt aDepth); + void DestroyChildren(); +private: + TInt iDrawState; + CTAlphaWin* iTest; + CTAlphaWindow* iChild1; + CTAlphaWindow* iChild2; + }; + +class CTAlphaRefWin : public CTWin + { + // This class is used to draw what we think things should look like, for comparison with what they actually look like +public: + inline CTAlphaRefWin(TFixedArray& aAlphaWin); + static CTAlphaRefWin* NewL(CTWinBase* aParent, TPoint aPos, TSize aSize, TFixedArray& aAlphaWin); + void Draw(); +private: + void DrawWindow(CTAlphaWindow* aWindow, TPoint aOffset); +private: + TFixedArray& iAlphaWin; + }; + +class CTAlphaWinStep : public CTGraphicsStep + { +public: + CTAlphaWinStep(); +protected: + //from CTGraphicsStep + virtual CTGraphicsBase* CreateTestL(); + }; + +_LIT(KTAlphaWinStep,"TAlphaWin"); + + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TAUTO.H --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TAUTO.H Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,25 @@ +// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Generated by BitmapCompiler +// +// + +enum TMbmTauto + { + EMbmTautoBluehash, + EMbmTautoGreyline, + EMbmTautoMask0, + EMbmTautoMask1, + EMbmTautoMask2 + }; diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TAUTODLL.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TAUTODLL.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,2945 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Client side of AUTODLL test code +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include "TAUTODLL.H" +#include "TEVENT.H" + +//#define LOGGING + +// + + +CGraphicsContext::TDrawMode CAnimWindow::iEllipseDrawMode; + +CTAnimDll::CTAnimDll(CTestStep* aStep) : CTWsGraphicsBase(aStep) + { + } + +RTestAnim::RTestAnim() : RAnim() + { + } + +RTestAnim::RTestAnim(RAnimDll &aDll) : RAnim(aDll) + { + } + +LOCAL_C TInt DoPanicTest(TInt aInt, TAny *aScreenNumber) + { + RWsSession ws; + User::LeaveIfError(ws.Connect()); + + // assign to the correct screen + CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws); + User::LeaveIfError(screen->Construct((TInt)aScreenNumber)); + + RWindowGroup group(ws); + User::LeaveIfError(group.Construct(333)); + group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close + RAnimDll animDll=RAnimDll(ws); + User::LeaveIfError(animDll.Load(KAnimDLLName)); + RTestAnim panic(animDll); + RWindow window(ws); + RBlankWindow blankwin(ws); + if (aInt==16 || aInt==17) // Use a blank window for this one + { + User::LeaveIfError(blankwin.Construct(group,123)); + blankwin.SetSize(TSize(10,10)); + blankwin.Activate(); + User::LeaveIfError(panic.Construct(blankwin,EAnimTypeTest1,TPtrC8())); + } + else + { + User::LeaveIfError(window.Construct(group,123)); + window.SetSize(TSize(10,10)); + window.Activate(); + window.BeginRedraw(); + window.EndRedraw(); + if (aInt==0) + User::LeaveIfError(panic.Construct(window,EAnimTypeTest2,TPtrC8())); + User::LeaveIfError(panic.Construct(window,EAnimTypeTest1,TPtrC8())); + } + TPckgBuf dummyParam; + switch(aInt) + { + case 1: + panic.Command(EADllPanicCallPanic); + break; + case 2: + panic.Command(EADllPanicCallPanic,dummyParam); + break; + case 3: + panic.CommandReply(EADllPanicCallPanic); + break; + case 4: + panic.CommandReply(EADllPanicCallPanic,dummyParam); + break; + case 5: + panic.Command(EADllPanicSetInterval); + break; + case 6: + panic.Command(EADllPanicSetNextInterval); + break; + case 7: + panic.CommandReply(EADllPanicBadFont); + break; + case 8: + panic.CommandReply(EADllPanicBadBitmap); + break; + case 9: + panic.Command(EADllPanicLeave); + break; + case 10: + panic.Command(EADllPanicDoubleActivateGC); + break; + case 11: + panic.Command(EADllPanicDrawRectWithNoGc); + break; + case 12: + panic.Command(EADllPanicDrawTextWithNoFont); + break; + case 13: + panic.Command(EADllPanicLeaveInAnimate); + ws.Finish(); + panic.CommandReply(EADllBlankOpCode); + break; + case 14: + panic.Command(EADllPanicLeaveInRedraw); + window.BeginRedraw(); + window.EndRedraw(); + ws.Finish(); + panic.CommandReply(EADllBlankOpCode); + break; + case 15: + ws.TestWrite(animDll.WsHandle(),999,NULL,0); + break; + case 16: + panic.Command(EADllPanicSetVisWithGcActive); + break; + case 17: + panic.CommandReply(EADllPanicSetVisWithGcActiveReply); + break; + case 18: + panic.Command(EADllPanicLeaveInActiveCallback); + ws.Flush(); + User::After(2000000); + panic.CommandReply(EADllBlankOpCode); + break; + case 19: + panic.Command(EADllPanicSetClippingRectWithNoGc); + break; + case 20: + panic.CommandReply(EADllPanicSetClippingRegionWithNoGc); + break; + case 21: + panic.Command(EADllPanicCancelClippingRegionWithNoGc); + break; + case 22: + panic.Command(EADllPanicCancelClippingRectWithNoGc); + break; + case 23: + panic.Command(EADllPanicSetDrawModeWithNoGc); + break; + case 24: + panic.Command(EADllPanicUseFontWithNoGc); + break; + case 25: + panic.Command(EADllPanicDiscardFontWithNoGc); + break; + case 26: + panic.Command(EADllPanicSetUnderlineStyleWithNoGc); + break; + case 27: + panic.Command(EADllPanicSetStrikeThoughStyleWithNoGc); + break; + case 28: + panic.Command(EADllPanicSetWordJustificationWithNoGc); + break; + case 29: + panic.Command(EADllPanicSetCharJustificationWithNoGc); + break; + case 30: + panic.Command(EADllPanicSetPenColorWithNoGc); + break; + case 31: + panic.Command(EADllPanicSetPenStyleWithNoGc); + break; + case 32: + panic.Command(EADllPanicSetPenSizeWithNoGc); + break; + case 33: + panic.Command(EADllPanicSetBrushColorWithNoGc); + break; + case 34: + panic.Command(EADllPanicSetBrushStyleWithNoGc); + break; + case 35: + panic.Command(EADllPanicSetBrushOriginWithNoGc); + break; + case 36: + panic.Command(EADllPanicUseBrushPatterWithNoGc); + break; + case 37: + panic.Command(EADllPanicDiscardBrushPatternWithNoGc); + break; + case 38: + panic.Command(EADllPanicSetFadedWithNoGc); + break; + case 39: + panic.Command(EADllPanicSetFadingParametersWithNoGc); + break; + case 40: + panic.Command(EADllPanicDrawArcWithNoGc); + break; + case 41: + panic.Command(EADllPanicDrawPieWithNoGc); + break; + case 42: + panic.Command(EADllPanicDrawLineWithNoGc); + break; + case 43: + panic.Command(EADllPanicDrawLineToWithNoGc); + break; + case 44: + panic.Command(EADllPanicDrawLineByWithNoGc); + break; + case 45: + panic.Command(EADllPanicDrawEllipseWithNoGc); + break; + case 46: + panic.Command(EADllPanicDrawRoundedRecWithNoGc); + break; + case 47: + panic.Command(EADllPanicClearWithRectWithNoGc); + break; + case 48: + panic.Command(EADllPanicClearWithNoGc); + break; + case 49: + panic.Command(EADllPanicBitBltWithNoGc); + break; + case 50: + panic.Command(EADllPanicBitBltWithRectWithNoGc); + break; + case 51: + panic.Command(EADllPanicBitBltMaskedWithNoGc); + break; + case 52: + panic.Command(EADllPanicDrawBitmapPointWithNoGc); + break; + case 53: + panic.Command(EADllPanicDrawBitmapWithNoGc); + break; + case 54: + panic.Command(EADllPanicDrawBitmapRectWithNoGc); + break; + case 55: + panic.Command(EADllPanicDrawBitmapMaskedFbsBitmapWithNoGc); + break; + case 56: + panic.Command(EADllPanicDrawBitmapMaskedWsBitmapWithNoGc); + break; + case 57: + panic.Command(EADllPanicDrawPolyLinePointsWithNoGc); + break; + case 58: + panic.Command(EADllPanicDrawPolyLineArrayWithNoGc); + break; + case 59: + panic.CommandReply(EADllPanicDrawPolygonPointsWithNoGc); + break; + case 60: + panic.CommandReply(EADllPanicDrawPolygonArrayWithNoGc); + break; + case 61: + panic.Command(EADllPanicMoveToWithNoGc); + break; + case 62: + panic.Command(EADllPanicMoveByWithNoGc); + break; + case 63: + panic.Command(EADllPanicPlotWithNoGc); + break; + case 64: + panic.Command(EADllPanicSetOriginWithNoGc); + break; + case 65: + panic.Command(EADllPanicCopyRectWithNoGc); + break; + case 66: + panic.Command(EADllPanicResetWithNoGc); + break; + case 67: + panic.CommandReply(EADllPanicAlphaBlendingBitmapsFbsBitmapWithNoGc); + break; + case 68: + panic.Command(EADllPanicMapColorsWithNoGc); + break; + case 69: + panic.Command(EADllPanicDrawTextWithRectWithNoFont); + break; + case 70: + panic.Command(EADllPanicDrawTextVerticalWithNoFont); + break; + case 71: + panic.Command(EADllPanicDrawTextVerticalWithRectWithNoFont); + break; + case 72: + panic.CommandReply(EADllPanicDevice); + break; + case 73: + panic.Command(EADllPanicInvalidFocusScreenTooBig); + break; + case 74: + panic.Command(EADllPanicInvalidFocusScreenNegative); + break; + default: + return(EWsExitReasonFinished); + } + + ws.Flush(); + return(EWsExitReasonBad); + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-0125 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Panic tests + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions The test creates an animation and animation's client threads. + Each thread calls some + command of the animation which is expected to panic on certain reason. + The test checks that those client threads will panic returning + a proper panic code. Client threads are created and tested for + the following actions: + 1. A Command() call to an animation which executes + iFunctions->Panic() method. Client thread must panic with + code EWservPanicAnimDll. + 2. A Command() call with dummy parameter to an animation which + executes iFunctions->Panic() method. Client thread must panic + with code EWservPanicAnimDll. + 3. A CommandReply() call to an animation which executes + iFunctions->Panic() method. Client thread must panic with code + EWservPanicAnimDll. + 4. A CommandReply() call with dummy parameter to an animation + which executes iFunctions->Panic() method. Client thread must + panic with code EWservPanicAnimDll. + 5. A command that calls MAnimGeneralFunctions::SetInterval() when + the synchronisation mode is not TAnimSync::ESyncNone. Client + thread must panic with code EWservPanicAnimDll. + 6. A command that calls MAnimGeneralFunctions::SetNextInterval() + when the synchronisation mode is not TAnimSync::ESyncNone. Client + thread must panic with code EWservPanicAnimDll. + 7. A command that calls MAnimGeneralFunctions::DuplicateFontL() to + duplicate undefined font. Client thread must panic with code + EWservPanicFont. + 8. A command that calls MAnimGeneralFunctions::DuplicateBitmapL() + to duplicate undefined bitmap. Client thread must panic with code + EWservPanicBitmap. + 9. A command that calls User::Leave(KErrGeneral). Client thread + must panic with code EWservPanicAnimLeave. + 10. A command that activates window animation's graphical context + twice. Client thread must panic with code EWservPanicAnimDll. + 11. A command that tries to draw a rectangle while graphical + context is not defined yet. Client thread must panic with code + EWservPanicAnimLeave. + 12. A command that tries to draw a text whihout a font defined yet. + Client thread must panic with code EWservPanicNoFont. + 13. A command that causes an animation to leave during execution + of CAnim::Animate() method; and a new command call 4 seconds after + that. Client thread must panic with code EWservPanicAnimLeave. + 14. A command that causes an animation to leave during execution + of CAnim::Redraw() method. The client thread initiates it's window + redraw after that. Client thread must panic with code + EWservPanicAnimLeave. + 15. The client thread calls RWsSession::TestWrite() on animation + DLL server-side handle with opcode 999. Client thread must panic with code + EWservPanicOpcode. + 16. A command that activates graphical context and sets the + window to invisible and then to visible. Client thread must panic + with code EWservPanicAnimDll. + + +@SYMTestExpectedResults See test actions. +*/ +void CTAnimDll::TestPanicsL() + { + TInt index=0; + TBool finishTests=EFalse; + do + { + + + TClientPanic panicCode=EWservPanicAnimDll; + switch(index) + { + // panic the server with a KERN-4. When server fixed these this can be removed. + case 19: + case 20: + case 22: + case 24: + goto bypasstest; + + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + case 10: + case 16: + case 17: + case 18: + case 73: + case 74: + panicCode=EWservPanicAnimDll; + break; + case 7: + panicCode=EWservPanicFont; + break; + case 8: + panicCode=EWservPanicBitmap; + break; + case 12: + case 69: + case 70: + case 71: + panicCode=EWservPanicNoFont; + break; + case 15: + panicCode=EWservPanicOpcode; + break; + case 9: + case 11: + case 13: + case 14: + case 72: + default: // cases 19 - 68 + panicCode=EWservPanicAnimLeave; + break; + } + + TEST(iTest->TestWsPanicL(&DoPanicTest,panicCode,index,(TAny*)iTest->iScreenNumber,&finishTests)); +bypasstest: + if (iTest->iScreenNumber == 0) + iTest->CloseAllPanicWindows(); + index++; + } while(!finishTests); + } + +void CTAnimDll::TestSyncModes(MAnimGeneralFunctions::TAnimSync aSyncMode) + { + RTestAnim anim=RTestAnim(iAnimDll); + User::LeaveIfError(anim.Construct(*iTestWin->BaseWin(),EAnimTypeTest1,TPtrC8())); + CleanupClosePushL(anim); + + TPckgBuf params; + TRequestStatus status(KRequestPending); + params().status=&status; + params().syncMode=aSyncMode; + anim.CommandReply(EADllSyncTests,params); + User::WaitForRequest(status); + TEST(status==KErrNone); + + CleanupStack::PopAndDestroy(&anim); + } + +void CTAnimDll::TestTimeChange() + { + RTestAnim anim=RTestAnim(iAnimDll); + User::LeaveIfError(anim.Construct(*iTestWin->BaseWin(),EAnimTypeTest1,TPtrC8())); + CleanupClosePushL(anim); + + TPckgBuf params; + TRequestStatus status(KRequestPending); + TRequestStatus status2(KRequestPending); + params().status=&status; + params().status2=&status2; + anim.CommandReply(EADllTimeChangedTest,params); + User::WaitForRequest(status); + TTime time; + time.HomeTime(); + time+=TTimeIntervalHours(1); + User::SetHomeTime(time); + User::WaitForRequest(status2); + time.HomeTime(); + time-=TTimeIntervalHours(1); + User::SetHomeTime(time); + TEST(status2==KErrNone); + + CleanupStack::PopAndDestroy(&anim); + } + +void CTAnimDll::ConstructL() + { + TheClient->iGroup->WinTreeNode()->SetOrdinalPosition(0); + iRedrawWin=new(ELeave) CAnimWindow(EFalse, CAnimWindow::ERedraw); + iBackedUpTestWin=new(ELeave) CAnimWindow(EFalse, CAnimWindow::EBackedUp); + iBlankTestWin=new(ELeave) CAnimWindow(EFalse, CAnimWindow::EBlank); + iBaseWin=new(ELeave) CAnimWindow(ETrue, CAnimWindow::ERedraw); + +// + TSize screenSize=TheClient->iGroup->Size(); + TInt winWidth=(screenSize.iWidth/3)-10; + TInt winHeight=screenSize.iHeight-10; + iBaseWin->ConstructL(TPoint(screenSize.iWidth/3+5,5),TSize(winWidth,winHeight)); + iBlankTestWin->ConstructL(TPoint(screenSize.iWidth/3*2+5,5),TSize(winWidth,winHeight)); + ((RBlankWindow *)iBlankTestWin->BaseWin())->SetColor(TRgb::Gray4(2)); + iBackedUpTestWin->ConstructL(TPoint(screenSize.iWidth/3*2+5,5),TSize(winWidth,winHeight)); + iRedrawWin->ConstructL(TPoint(screenSize.iWidth/3*2+5,5),TSize(winWidth,winHeight)); +// + iTestWin=iRedrawWin; +// + iAnimDll=RAnimDll(TheClient->iWs); + TInt retVal = iAnimDll.Load(KAnimDLLName); + TEST(retVal==KErrNone); + if (retVal!=KErrNone) + INFO_PRINTF3(_L("iAnimDll.Load(KAnimDLLName) return value - Expected: %d , Actual: %d"), KErrNone, retVal); + } + +CTAnimDll::~CTAnimDll() + { + iAnimDll.Close(); + delete iBackedUpTestWin; + delete iBlankTestWin; + delete iRedrawWin; + delete iBaseWin; + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-0126 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Miscellaneous animation tests. + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Tests window animation's window funtions like WindowSize(), + IsHidden(), SetVisible(). + Tests RAnimDll's constructor, Close(), Load() and copy-constructor. + +@SYMTestExpectedResults Expects window funtions and RAnimDll's methods work properly. +*/ +void CTAnimDll::Misc() + { + RTestAnim anim=RTestAnim(iAnimDll); + User::LeaveIfError(anim.Construct(*iTestWin->BaseWin(),EAnimTypeTest1,TPtrC8())); + CleanupClosePushL(anim); + + TPckgBuf params; + params()=iTestWin->Size(); + TBool retBool = anim.CommandReply(EADllTestWindowSize,params); + TEST(retBool); + if (!retBool) + INFO_PRINTF3(_L("anim.CommandReply(EADllTestWindowSize,params) return value - Expected: %d , Actual: %d"), ETrue, retBool); + TheClient->iWs.Finish(); + retBool = anim.CommandReply(EADllTestSetVisible); + TEST(retBool); + if (!retBool) + INFO_PRINTF3(_L("anim.CommandReply(EADllTestSetVisible) return value - Expected: %d , Actual: %d"), ETrue, retBool); + CleanupStack::PopAndDestroy(&anim); + + RAnimDll closeme(TheClient->iWs); + closeme.Close(); + RAnimDll animdll(TheClient->iWs); + TInt retVal = animdll.Load(KAnimDLLName); + TEST(retVal==KErrNone); + if (retVal!=KErrNone) + INFO_PRINTF3(_L("animdll.Load(KAnimDLLName) return value - Expected: %d , Actual: %d"), KErrNone, retVal); + + RTestAnim anim2(animdll); + anim2.Close(); + animdll.Close(); + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-0127 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test animation's command call with reply + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Puts an array containing a sequnce of numbers into a command argument. + Performs command call to server, assuming that the server-side + should return a sum of the numbers in sequence. + +@SYMTestExpectedResults Checks that server returns the correct sum. +*/ +void CTAnimDll::RemoteBuffer() + { + RTestAnim anim=RTestAnim(iAnimDll); + User::LeaveIfError(anim.Construct(*iTestWin->BaseWin(),EAnimTypeTest1,TPtrC8())); + CleanupClosePushL(anim); + + TBuf buf(ERemoteBufSize); + TInt total=0; + for (TInt8 index=0;indexiWs); + TInt retVal = extraCopy.Load(KAnimDLLName); + TEST(retVal==KErrNone); + if (retVal!=KErrNone) + INFO_PRINTF3(_L("extraCopy.Load(KAnimDLLName) return value - Expected: %d , Actual: %d"), KErrNone, retVal); + + extraCopy.Close(); + } +// +void CTAnimDll::SyncMode1() + { + TestSyncModes(MAnimGeneralFunctions::ESyncSecond); + } + +void CTAnimDll::CheckWindows() + { + CheckRect(iBaseWin->CtBaseWin(),iTestWin->CtBaseWin(),TRect(iBaseWin->Size()),_L("CTAnimDll::CheckWindows() failed")); + } + +void CTAnimDll::InvalidatePauseAndRedraw(const TRect &aRect,TTimeIntervalMicroSeconds32 aInterval) + { + iTestWin->Invalidate(aRect); + TheClient->iWs.Flush(); + User::After(aInterval); + __ASSERT_DEBUG(iTestWin->iWinType==CAnimWindow::ERedraw,AutoPanic(EAutoPanicWindowType)); + RWindow *win=(RWindow *)iTestWin->BaseWin(); + win->BeginRedraw(); + iTestWin->DoDraw(); + win->EndRedraw(); + TheClient->iWs.Flush(); + } + +void CTAnimDll::RedrawAndCheckWindows(TBool aBlankIt) + { + if (iTestWin->iWinType==CAnimWindow::ERedraw) + { + RWindow *win=(RWindow *)iTestWin->BaseWin(); + win->BeginRedraw(); + iTestWin->DoDraw(aBlankIt); + win->EndRedraw(); + } + RWindow *win=(RWindow *)iBaseWin->BaseWin(); + win->BeginRedraw(); + iBaseWin->DoDraw(aBlankIt); + win->EndRedraw(); + TheClient->WaitForRedrawsToFinish(); + CheckWindows(); + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-0129 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Animation drawing test + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Performs animation drawing ontop of redrawable window, backed-up window and blank window. + Draws the same shapes using directly window graphics on an other window (base window). + The following shapes are drawn: + 1. An animation with a small ellipse drawn in XOR mode on top of redrawable + black-lined gray window. + 2. The same with a bigger ellipse but previously invalidating an + area which intersects the old ellipse and the new ellipse. + 3. Runs an animation that continuously moves a rectangle and shrinks another on top of + redrawable black-lined gray window and then cancels an animation. + The test checks that the window will be identical with the gray base window + that contains only black lines. + 4. An animation with a small ellipse drawn in XOR mode on top of backed-up + black-lined gray window. The test also calls Invalidate() method and performs + a check again to make sure that the test-window and base window are identical. + 5. An animation with a small ellipse drawn in XOR mode on top of the blank + gray window. The test also sends commands to the animation that call windows + SetVisible(EFalse) and SetVisible(ETrue) and checks that the + test-window and base window are identical. + + +@SYMTestExpectedResults Each time performs pixelwise comparisons of animated windows + and the base window expecting the windows to be identical. +*/ +void CTAnimDll::DrawingTestL() + { + // draws a little circle on the base window using window graphics and using window animation on the test window. + RTestAnim drawAnim=RTestAnim(iAnimDll); +// + TRect rect; + TPckgBuf rectPckg; + TPckgBuf boolPckg; + +// + _LIT(KLog1,"Draw Ellipse Test1"); + LOG_MESSAGE(KLog1); + rect = TRect(10,10,50,50); + CAnimWindow::SetEllipseDrawMode(CGraphicsContext::EDrawModeXOR); + iTestWin->Invalidate(); + iTestWin->SetRect(rect); + iBaseWin->Invalidate(); + iBaseWin->SetRect(rect); + rectPckg()=rect; + User::LeaveIfError(drawAnim.Construct(*iTestWin->BaseWin(),EAnimTypeTest3,rectPckg)); + RedrawAndCheckWindows(); +// + _LIT(KLog2,"Draw Ellipse Test2"); + LOG_MESSAGE(KLog2); + iTestWin->Invalidate(TRect(20,20,100,40)); + iBaseWin->Invalidate(TRect(20,20,100,40)); + iBaseWin->DoDrawEllipse(); // Should clear old Ellipse (except invalid bits) + rect=TRect(30,30,200,100); + rectPckg()=rect; + iBaseWin->SetRect(rect); + iBaseWin->DoDrawEllipse(); // Should draw new Ellipse (except invalid bits) + drawAnim.Command(EADllSetRect,rectPckg); + RedrawAndCheckWindows(); + iBaseWin->DoDrawEllipse(); // Clear old ellipse +// + _LIT(KLog3,"Window Overlap Anim Test"); + LOG_MESSAGE(KLog3); + + iBaseWin->SetRect(TRect()); + iBaseWin->DoDraw(); + TheClient->iWs.Finish(); + + // create another window on top and check that animation beneath is not visible + TSize screenSize=TheClient->iGroup->Size(); + TInt winWidth=(screenSize.iWidth/3)-10; + TInt winHeight=screenSize.iHeight-10; + TSize size=iTestWin->Size(); + rectPckg()=TRect(size); + drawAnim.Command(EADllStartAnimate,rectPckg); + + CAnimWindow *topWindow = new (ELeave) CAnimWindow(ETrue, CAnimWindow::ERedraw); + CleanupStack::PushL(topWindow); + topWindow->ConstructL(TPoint(screenSize.iWidth/3*2+5,5),TSize(winWidth,winHeight)); + + RWindow *win=(RWindow *)iTestWin->BaseWin(); + win->BeginRedraw(); + topWindow->DoDraw(EFalse); + win->EndRedraw(); + + TheClient->iWs.Flush(); + for(TInt i=0;iWaitForRedrawsToFinish(); + CheckRect(iBaseWin->CtBaseWin(),iTestWin->CtBaseWin(),TRect(iBaseWin->Size())); + + win->BeginRedraw(rect); + drawAnim.Command(EADllCancelAnimate,rectPckg); + win->EndRedraw(); + + CleanupStack::PopAndDestroy(topWindow); +// + iTestWin->BaseWin()->SetVisible(EFalse); + drawAnim.Close(); +// + _LIT(KLog4,"Draw Ellipse Test4&5"); + LOG_MESSAGE(KLog4); + rect=TRect(20,20,50,50); + iBackedUpTestWin->SetRect(rect); + iBackedUpTestWin->DoDraw(); + iBaseWin->SetRect(rect); + win->BeginRedraw(); + iBaseWin->DoDraw(); + win->EndRedraw(); + TheClient->iWs.Finish(); + + rectPckg()=rect; + User::LeaveIfError(drawAnim.Construct(*iBackedUpTestWin->BaseWin(),EAnimTypeTest3,rectPckg)); + TheClient->iWs.Finish(); + TheClient->WaitForRedrawsToFinish(); + CheckWindows(); + iBackedUpTestWin->Invalidate(); + TheClient->iWs.Flush(); + TheClient->WaitForRedrawsToFinish(); + CheckWindows(); + iBackedUpTestWin->BaseWin()->SetVisible(EFalse); +// + _LIT(KLog5,"Draw Ellipse Test6&7"); + LOG_MESSAGE(KLog5); + rect=TRect(20,20,50,50); + TheClient->iWs.Flush(); + RWindow *winBase=(RWindow *)iBaseWin->BaseWin(); + winBase->BeginRedraw(); + iBaseWin->SetRect(rect); + iBaseWin->DoDraw(ETrue); + winBase->EndRedraw(); + rectPckg()=rect; + User::LeaveIfError(drawAnim.Construct(*iBlankTestWin->BaseWin(),EAnimTypeTest3,rectPckg)); + TheClient->iWs.Flush(); + iBlankTestWin->Invalidate(); + TheClient->iWs.Flush(); + TheClient->WaitForRedrawsToFinish(); + CheckWindows(); + boolPckg()=EFalse; + drawAnim.Command(EADllSetVisible,boolPckg); + TheClient->iWs.Flush(); + boolPckg()=ETrue; + drawAnim.Command(EADllSetVisible,boolPckg); + TheClient->WaitForRedrawsToFinish(); + CheckWindows(); + +//This test does functional coverage by calling code that executes each of the +//server's class (CWsAnimGc) members in turn. + + + _LIT(KLog6,"Draw Primitives (Coverage) Test"); + LOG_MESSAGE(KLog6); + rect = TRect(10,10,150,150); + iBaseWin->BaseWin()->SetVisible(ETrue); + iBaseWin->SetRect(TRect(0,0,0,0)); + winBase->BeginRedraw(); + iBaseWin->DoDraw(); + iBaseWin->SetRect(rect); + iBaseWin->DoDrawCoverage(); + winBase->EndRedraw(); + + iTestWin->BaseWin()->SetVisible(ETrue); + iTestWin->SetRect(rect); + win->BeginRedraw(); + iTestWin->DoDraw(); + win->EndRedraw(); + + rectPckg()=rect; + User::LeaveIfError(drawAnim.Construct(*iTestWin->BaseWin(),EAnimTypeCoverage,rectPckg)); + + //set font + CFbsFont* font; + User::LeaveIfError(TheClient->iGc->Device()->GetNearestFontToDesignHeightInTwips((CFont*&)font, TFontSpec())); + TPckgBuf fontHandle; + fontHandle() = font->Handle(); + const TInt err = drawAnim.CommandReply(EADllSetFont, fontHandle); + TheClient->iGc->Device()->ReleaseFont(font); + User::LeaveIfError(err); + + //draw + User::LeaveIfError(drawAnim.CommandReply(EADllDrawNow)); + + TheClient->iWs.Finish(); + TheClient->WaitForRedrawsToFinish(); + CheckWindows(); + drawAnim.Close(); + } + +void CTAnimDll::ShadowDrawingTestL() + { +// Create a blank window to cast a shadow over the animation + TSize scrSize(TheClient->iScreen->SizeInPixels()); + CTBlankWindow *blank=new(ELeave) CTBlankWindow(); + CleanupStack::PushL(blank); + blank->SetUpL(TPoint(0,10), TSize(scrSize.iWidth,scrSize.iHeight/3), TheClient->iGroup, *TheClient->iGc); + blank->BaseWin()->SetShadowHeight(2); + iBlankTestWin->BaseWin()->SetShadowHeight(0); +// + RTestAnim drawAnim=RTestAnim(iAnimDll); + TRect rect(10,scrSize.iHeight/3-20,50,scrSize.iHeight/3+40); + TPckgBuf rectPckg; + rectPckg()=rect; + User::LeaveIfError(drawAnim.Construct(*iBlankTestWin->BaseWin(),EAnimTypeTest3,rectPckg)); + drawAnim.Command(EADllSetShadowDrawMode); + CAnimWindow::SetEllipseDrawMode(CGraphicsContext::EDrawModePEN); +// + iBlankTestWin->Invalidate(); + iBlankTestWin->SetRect(rect); + iBaseWin->Invalidate(); + iBaseWin->SetRect(rect); + RedrawAndCheckWindows(ETrue); +// + for(TInt ypos=10;ypos>0;ypos-=4) + { + blank->SetPos(TPoint(0,ypos)); + TPckgBuf params; + TRequestStatus status(KRequestPending); + params().status=&status; + drawAnim.CommandReply(EADllShadowAnimTest,params); + User::WaitForRequest(status); + RedrawAndCheckWindows(ETrue); + } +// + CleanupStack::PopAndDestroy(blank); // Destroy the shadow window + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-0130 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Complicated drawing test + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Performs complicated drawing both through the animation on + a blank window and through direct fbs drawing on the second + window. + +@SYMTestExpectedResults Expects the both windows to be are identical +*/ +void CTAnimDll::GeneralDrawingTestL() + { + // This test has been removed as it is no longer relevant + // Anims are not allowed to draw immediately to the screen + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-0131 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Animated window destruction test + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Creates a window and a child window inside it, runs an animation + in the child window in ESyncFlash mode, destroys windows. + +@SYMTestExpectedResults Expects the operations not to fail. +*/ +void CTAnimDll::DestroyWindowTestL() + { + RWindow window(TheClient->iWs); + User::LeaveIfError(window.Construct(*TheClient->iGroup->GroupWin(),123)); + CleanupClosePushL(window); + window.SetSize(TSize(100,100)); + window.Activate(); + RWindow window2(TheClient->iWs); + CleanupClosePushL(window2); + User::LeaveIfError(window2.Construct(window,124)); + window2.Activate(); + window2.BeginRedraw(); // Validate it + window2.EndRedraw(); +// + RTestAnim drawAnim; + drawAnim=RTestAnim(iAnimDll); + TRect rect(10,10,50,50); + TPckgBuf rectPckg; + rectPckg()=rect; + User::LeaveIfError(drawAnim.Construct(window2,EAnimTypeTest3,rectPckg)); + drawAnim.Command(EADllStartAnimate,rectPckg); + CleanupStack::Pop(&window2); + CleanupStack::PopAndDestroy(&window); + TheClient->iWs.Flush(); + User::After(TTimeIntervalMicroSeconds32(2000000)); + window2.Close(); + drawAnim.Close(); + } + +void CTAnimDll::SetUpMember(TSpriteMember &aMember,TInt aType) + { + switch (aType) + { + case 1: + iTest->SetUpMember(aMember); + aMember.iOffset=TPoint(); + aMember.iInterval=TTimeIntervalMicroSeconds32(1); + break; + case 2: + aMember.iInvertMask=EFalse; + aMember.iDrawMode=CGraphicsContext::EDrawModeXOR; + aMember.iOffset=TPoint(1,2); + aMember.iInterval=TTimeIntervalMicroSeconds32(2); + break; + case 3: + aMember.iInvertMask=ETrue; + aMember.iDrawMode=CGraphicsContext::EDrawModeOR; + aMember.iOffset=TPoint(3,4); + aMember.iInterval=TTimeIntervalMicroSeconds32(3); + break; + default: + iTest->SetUpMember(aMember); + } + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-0132 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Sprite animation test + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Creates a sprite with three sprite members and a sprite animation + passing the sprite to it. The test updates sprite members' + properties in various ways verifying that the properties are changing + on the server-side as well. + +@SYMTestExpectedResults Expects that operations above do not fail and that client-side + changes to the sprite affect server-side properly. +*/ +#define HALF_SEC 500000 +void CTAnimDll::SpriteAnimL() + { + // create a sprite, add 3 members to it + RWsSprite sprite(TheClient->iWs); + iRedrawWin->BaseWin()->SetVisible(ETrue); + sprite.Construct(*iRedrawWin->CtBaseWin()->BaseWin(),TPoint(),0); + CleanupClosePushL(sprite); + CFbsBitmap* bitmap1=new(ELeave) CFbsBitmap(); + CleanupStack::PushL(bitmap1); + CFbsBitmap* bitmap2=new(ELeave) CFbsBitmap(); + CleanupStack::PushL(bitmap2); + CFbsBitmap* bitmap3=new(ELeave) CFbsBitmap(); + CleanupStack::PushL(bitmap3); + User::LeaveIfError(bitmap1->Create(TSize(10,12),EGray4)); + User::LeaveIfError(bitmap2->Create(TSize(15,17),EGray4)); + User::LeaveIfError(bitmap3->Create(TSize(20,22),EGray4)); + TSpriteMember member1; + TSpriteMember member2; + TSpriteMember member3; + SetUpMember(member1,1); + member1.iBitmap=bitmap1; + member1.iMaskBitmap=bitmap1; + SetUpMember(member2,2); + member2.iBitmap=bitmap2; + member2.iMaskBitmap=bitmap2; + SetUpMember(member3,3); + member3.iBitmap=bitmap3; + member3.iMaskBitmap=bitmap3; + sprite.AppendMember(member1); + sprite.AppendMember(member2); + sprite.AppendMember(member3); + + // create a sprite animation for the sprite + RTestAnim spriteAnim(iAnimDll); + TPtrC8 des(NULL,0); + TPoint pos(1,2); + User::LeaveIfError(spriteAnim.Construct(sprite,EAnimTypeSprite,des)); + CleanupClosePushL(spriteAnim); + + // call EADllCheckMember-command to verify that sprite animation's members + // have the same properties as the sprite instance + TPckgBuf spriteInfo; + spriteInfo()=TSpriteMemberInfo(TPoint(),0,member1); + TBool retBool = spriteAnim.CommandReply(EADllCheckMember,spriteInfo); + TEST(retBool); + if (!retBool) + INFO_PRINTF3(_L("spriteAnim.CommandReply(EADllCheckMember,spriteInfo) return value - Expected: %d , Actual: %d"), ETrue, retBool); + + sprite.SetPosition(pos); + spriteInfo()=TSpriteMemberInfo(pos,1,member2); + retBool = spriteAnim.CommandReply(EADllCheckMember,spriteInfo); + TEST(retBool); + if (!retBool) + INFO_PRINTF3(_L("spriteAnim.CommandReply(EADllCheckMember,spriteInfo) return value - Expected: %d , Actual: %d"), ETrue, retBool); + + pos.SetXY(3,4); + sprite.SetPosition(pos); + spriteInfo()=TSpriteMemberInfo(pos,2,member3); + retBool = spriteAnim.CommandReply(EADllCheckMember,spriteInfo); + TEST(retBool); + if (!retBool) + INFO_PRINTF3(_L("spriteAnim.CommandReply(EADllCheckMember,spriteInfo) return value - Expected: %d , Actual: %d"), ETrue, retBool); + + // call commands to change sprite members' bitmaps and update members + spriteAnim.Command(EADllDraw1); + spriteAnim.Command(EADllDraw2); + spriteAnim.Command(EADllDraw3); + TheClient->iWs.Flush(); + User::After(HALF_SEC); + + // call commands to change sprite's position + TPckgBuf position; + position().SetXY(60,50); + spriteAnim.Command(EADllSetPos,position); + TheClient->iWs.Flush(); + User::After(HALF_SEC); + + // change 1st member's bitmap size and interval, update it and call command to check + // that the new properties are applied + User::LeaveIfError(bitmap1->Resize(TSize(30,32))); + member1.iMaskBitmap=NULL; + member1.iInterval=TTimeIntervalMicroSeconds32(25); + User::LeaveIfError(sprite.UpdateMember(0,member1)); + spriteInfo()=TSpriteMemberInfo(TPoint(),0,member1); + retBool = spriteAnim.CommandReply(EADllCheckMember,spriteInfo); + TEST(retBool); + if (!retBool) + INFO_PRINTF3(_L("spriteAnim.CommandReply(EADllCheckMember,spriteInfo) return value - Expected: %d , Actual: %d"), ETrue, retBool); + + User::After(HALF_SEC); + + // change 1st member's bitmap size and calls command that invokes + // MAnimSpriteFunctions::SizeChangedL(). Check that new property is applied + spriteAnim.CommandReply(EADllDeactivate); + User::LeaveIfError(bitmap1->Resize(TSize(35,37))); + spriteAnim.Command(EADllSizeChanged); + spriteAnim.CommandReply(EADllActivate); + spriteInfo()=TSpriteMemberInfo(TPoint(),0,member1); + retBool = spriteAnim.CommandReply(EADllCheckMember,spriteInfo); + TEST(retBool); + if (!retBool) + INFO_PRINTF3(_L("spriteAnim.CommandReply(EADllCheckMember,spriteInfo) return value - Expected: %d , Actual: %d"), ETrue, retBool); + + User::After(HALF_SEC); + + // call command that changes 1st member's bitmap image + spriteAnim.Command(EADllIncDraw); + TheClient->iWs.Flush(); + User::After(HALF_SEC); + + + CleanupStack::PopAndDestroy(5,&sprite); + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-0133 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Free timer animation test + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions The test creates a free timer window animation that animates + a shrinking filled rect which changes colour in a predefined way. + +@SYMTestExpectedResults The test verifies that the colour changes gets through to the the display. +*/ + +#define NOT_TIMED_OUT timeWaitingForFrame < frametime<<4 +void CTAnimDll::FreeTimerL() + { + RTestAnim freeTimerAnim(iAnimDll); + User::LeaveIfError(freeTimerAnim.Construct(*iRedrawWin->BaseWin(),EAnimTypeFreeTimer,KNullDesC8)); + CleanupClosePushL(freeTimerAnim); + + const TInt frametime = 100000; // 100 ms + const TInt samplingtime = frametime>>1; // 50 ms + + TPckgC frametimeBuf(frametime); + freeTimerAnim.Command(ESetFrameTime, frametimeBuf); + freeTimerAnim.Command(EStartAnimation); + TheClient->iWs.Flush(); + TheClient->iWs.Finish(); + + TInt x = iRedrawWin->BaseWin()->AbsPosition().iX + (iRedrawWin->BaseWin()->Size().iWidth >> 1); + TInt y = iRedrawWin->BaseWin()->AbsPosition().iY + (iRedrawWin->BaseWin()->Size().iHeight >> 1); + TPoint middle(x,y); + + TRgb color = KRgbMagenta; + TBool foundRedFrame = EFalse; + TBool foundGreenFrame = EFalse; + TBool foundBlueFrame = EFalse; + TBool foundBlackFrame = EFalse; + + //The free-timer animates the colour in this predefined way. + //Test that the screen gets updated. + TInt timeWaitingForFrame = 0; + while(NOT_TIMED_OUT && !(foundRedFrame && foundGreenFrame && foundBlueFrame && foundBlackFrame)) //wait max 16*frametime=1280ms + { + //wait for the colour frame + color = PixelColour(middle); + + if(color == KRgbRed) + { + foundRedFrame = ETrue; + } + else if(color == KRgbGreen) + { + foundGreenFrame = ETrue; + } + else if(color == KRgbBlue) + { + foundBlueFrame = ETrue; + } + else if(color == KRgbBlack) + { + foundBlackFrame = ETrue; + } + + timeWaitingForFrame += samplingtime; + User::After(samplingtime); + } + + TEST(foundRedFrame); + TEST(foundGreenFrame); + TEST(foundBlueFrame); + TEST(foundBlackFrame); + + freeTimerAnim.Command(EStopAnimation); + CleanupStack::PopAndDestroy(&freeTimerAnim); + } + +TRgb CTAnimDll::PixelColour(const TPoint& aPoint) const + { + TRgb pixel; + TheClient->iScreen->GetPixel(pixel, aPoint); + return pixel; + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-0134 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Animation's ESyncSecond sync-mode test + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Creates an animation in ESyncSecond sync-mode. + Checks that animation's Animate() method was called either 9, 10 or 11 + times during a 10-seconds-wait. + The test also checks that if RWsSession::PrepareForSwitchOff() + is called then the Animate() method will not be called until + TRawEvent::EActive event is simulated. + +@SYMTestExpectedResults See actions. +*/ +static const TInt K1Second = 1000000; +static const TInt K3Seconds = 3000000; +static const TInt K9Seconds = 9500000; +void CTAnimDll::DisableTimerL() + { + //Defer start of timerAnim until the systen time are close to a full second + TTime now; + now.HomeTime(); + TInt deferTime = K1Second - now.DateTime().MicroSecond(); + User::After(deferTime); + + //Kick off timerAnim + RTestAnim timerAnim(iAnimDll); + User::LeaveIfError(timerAnim.Construct(*iRedrawWin->BaseWin(),EAnimTypeTimer,KNullDesC8)); + + User::After(K9Seconds); + TInt count=timerAnim.CommandReply(EADllCurrentCount); + +#if defined(LOGGING) + TLogMessageText buf; + _LIT(KLog,"Anim DisableTimer Count=%d"); + buf.Format(KLog,count); + TheClient->LogMessage(buf); +#endif + + TEST(count>=9 && count<=11); + if (count != 10) + INFO_PRINTF2(_L("count>=9 && count<=11 - Expected: 9,10 or 11 , Actual: %d"), count); + +#if defined(__WINS__) + TheClient->iWs.SimulateXyInputType(EXYInputNone); //Turn off pen in case it turns on the timer +#endif + + // reset timer's counter and call RWsSession::PrepareForSwitchOff(), + // check that 3 seconds after the counter = 0 + timerAnim.Command(EADllResetCount); + timerAnim.Command(EADllNoTimer); + TheClient->iWs.PrepareForSwitchOff(); + TheClient->iWs.Flush(); + User::After(K3Seconds); + count=timerAnim.CommandReply(EADllCurrentCount); +#if defined(LOGGING) + buf.Format(KLog,count); + TheClient->LogMessage(buf); +#endif + TEST(count==0); + if (count!=0) + INFO_PRINTF3(_L("count==0 - Expected: %d , Actual: %d"), 0, count); + + + // simulates TRawEvent::EActive event, + // check that the timer didn't ticked until the event were simulated + timerAnim.Command(EADllTimerStarted); + TRawEvent event; + event.Set(TRawEvent::EActive); + TheClient->iWs.SimulateRawEvent(event); +#if defined(__WINS__) + TheClient->iWs.SimulateXyInputType(EXYInputPointer); //Turn pen on again +#endif + TInt retVal = timerAnim.CommandReply(EADllFailed); + TEST(retVal==0); + if (retVal!=0) + INFO_PRINTF3(_L("timerAnim.CommandReply(EADllFailed) return value - Expected: %d , Actual: %d"), 0, retVal); + + timerAnim.Close(); + } + + +/** +@SYMTestCaseID GRAPHICS-WSERV-0135 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Multiple animations test + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Creates multiple animations for a window. + +@SYMTestExpectedResults The test doesn't perform any specific validations. +*/ +void CTAnimDll::MultipleAnimsL() + { + RTestAnim anim1(iAnimDll); + RTestAnim anim2(iAnimDll); + RTestAnim anim3(iAnimDll); + RTestAnim anim4(iAnimDll); + RTestAnim anim5(iAnimDll); + RTestAnim anim6(iAnimDll); + TPtrC8 des(NULL,0); + User::LeaveIfError(anim1.Construct(*iRedrawWin->BaseWin(),EAnimTypeTest3,des)); + CleanupClosePushL(anim1); + User::LeaveIfError(anim2.Construct(*iRedrawWin->BaseWin(),EAnimTypeTest3,des)); + CleanupClosePushL(anim2); + User::LeaveIfError(anim3.Construct(*iRedrawWin->BaseWin(),EAnimTypeTest3,des)); + CleanupClosePushL(anim3); + User::LeaveIfError(anim4.Construct(*iRedrawWin->BaseWin(),EAnimTypeTest3,des)); + CleanupClosePushL(anim4); + User::LeaveIfError(anim5.Construct(*iRedrawWin->BaseWin(),EAnimTypeTest3,des)); + CleanupClosePushL(anim5); + User::LeaveIfError(anim6.Construct(*iRedrawWin->BaseWin(),EAnimTypeTest3,des)); + anim6.Close(); + User::LeaveIfError(anim6.Construct(*iRedrawWin->BaseWin(),EAnimTypeTest3,des)); + anim6.Close(); + User::LeaveIfError(anim6.Construct(*iRedrawWin->BaseWin(),EAnimTypeTest3,des)); + CleanupStack::PopAndDestroy(&anim5); + anim6.Close(); + User::LeaveIfError(anim5.Construct(*iRedrawWin->BaseWin(),EAnimTypeTest3,des)); + CleanupClosePushL(anim5); + User::LeaveIfError(anim6.Construct(*iRedrawWin->BaseWin(),EAnimTypeTest3,des)); + CleanupStack::Pop(&anim5); + CleanupStack::PopAndDestroy(&anim4); + anim5.Close(); + anim6.Close(); + User::LeaveIfError(anim4.Construct(*iRedrawWin->BaseWin(),EAnimTypeTest3,des)); + CleanupStack::PopAndDestroy(&anim3); + anim4.Close(); + User::LeaveIfError(anim3.Construct(*iRedrawWin->BaseWin(),EAnimTypeTest3,des)); + CleanupStack::PopAndDestroy(&anim2); + anim3.Close(); + User::LeaveIfError(anim2.Construct(*iRedrawWin->BaseWin(),EAnimTypeTest3,des)); + CleanupStack::PopAndDestroy(&anim1); + anim2.Close(); + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-0136 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Click plugin DLL test + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Created two handles for a click plugin dll (RSoundPlugIn instances). + Plays with Load(), Unload() methods to verify that they affect + IsLoaded() call result. + Checks that CommandReply() for different opcodes + returns RSoundPlugIn::ESoundWrongPlugIn value. + Plays with SetPenClick(), SetKeyClick() to verify that they affect + PenClickEnabled() and KeyClickEnabled() call result. + + +@SYMTestExpectedResults The test checks that RSoundPlugIn's methods work properly + and that both handles behave identically. +*/ +void CTAnimDll::ClickPlugInL() + { + _LIT(KDllName,"CLICK"); + RWsSession ws; + User::LeaveIfError(ws.Connect()); + CleanupClosePushL(ws); + TBool retBool; + TInt retVal; + + // assign to the correct screen + CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws); + CleanupStack::PushL(screen); + User::LeaveIfError(screen->Construct(iTest->iScreenNumber)); + + RSoundPlugIn click1(ws); + RSoundPlugIn click2(TheClient->iWs); + User::LeaveIfError(click1.Construct()); + CleanupClosePushL(click1); + User::LeaveIfError(click2.Construct()); + CleanupClosePushL(click2); + TBool changeable1; + TBool changeable2; + TBool loaded=click1.IsLoaded(changeable1); + //test that either both are loaded or both are not loaded + TEST(!loaded==!click2.IsLoaded(changeable2)); + if (!loaded!=!click2.IsLoaded(changeable2)) + INFO_PRINTF3(_L("!loaded==!click2.IsLoaded(changeable2) - Expected: %d , Actual: %d"), !loaded, !click2.IsLoaded(changeable2)); + + //test that either both are changeable or both are not changeable + TEST(!changeable1==!changeable2); + if (!changeable1!=!changeable2) + INFO_PRINTF3(_L("!changeable1==!changeable2) - Expected: %d , Actual: %d"), !changeable1, !changeable2); + + if (loaded && changeable1) + { + // unload the first one + User::LeaveIfError(click1.Unload()); + // check that the second is not loaded and still changeable + retBool = !click2.IsLoaded(changeable2); + TEST(retBool); + if (!retBool) + INFO_PRINTF3(_L("!click2.IsLoaded(changeable2) return value - Expected: %d , Actual: %d"), ETrue, retBool); + + TEST(changeable2); + if (!changeable2) + INFO_PRINTF3(_L("changeable2 - Expected: %d , Actual: %d"), ETrue, changeable2); + + + // load the first one and check that the second became loaded and is changeable + User::LeaveIfError(click1.Load(KDllName)); + retBool = click2.IsLoaded(changeable2); + TEST(retBool); + if (!retBool) + INFO_PRINTF3(_L("click2.IsLoaded(changeable2) return value - Expected: %d , Actual: %d"), ETrue, retBool); + + TEST(changeable2); + if (!changeable2) + INFO_PRINTF3(_L("changeable2 - Expected: %d , Actual: %d"), ETrue, changeable2); + + // unload the second one + User::LeaveIfError(click2.Unload()); + // check that the first is not loaded and still changeable + retBool = !click1.IsLoaded(changeable1); + TEST(retBool); + if (!retBool) + INFO_PRINTF3(_L("!click1.IsLoaded(changeable1) return value - Expected: %d , Actual: %d"), ETrue, retBool); + + TEST(changeable1); + if (!changeable1) + INFO_PRINTF3(_L("changeable1 - Expected: %d , Actual: %d"), ETrue, changeable1); + + // load the second one and check that the first one became loaded and is changeable + User::LeaveIfError(click2.Load(KDllName)); + loaded=click1.IsLoaded(changeable1); + TEST(loaded); + if (!loaded) + INFO_PRINTF3(_L("loaded - Expected: %d , Actual: %d"), ETrue, loaded); + + TEST(changeable1); + if (!changeable1) + INFO_PRINTF3(_L("changeable1 - Expected: %d , Actual: %d"), ETrue, changeable1); + } + if (loaded) + { + TPtrC8 des(NULL,0); + retVal = click1.CommandReply(0,des); + TEST(RSoundPlugIn::ESoundWrongPlugIn==retVal); + if (RSoundPlugIn::ESoundWrongPlugIn!=retVal) + INFO_PRINTF3(_L("click1.CommandReply(0,des) return value - Expected: %d , Actual: %d"), RSoundPlugIn::ESoundWrongPlugIn, retVal); + + retVal = click1.CommandReply(1,des); + TEST(RSoundPlugIn::ESoundWrongPlugIn==retVal); + if (RSoundPlugIn::ESoundWrongPlugIn!=retVal) + INFO_PRINTF3(_L("click1.CommandReply(1,des) return value - Expected: %d , Actual: %d"), RSoundPlugIn::ESoundWrongPlugIn, retVal); + + retVal = click1.CommandReply(2,des); + TEST(RSoundPlugIn::ESoundWrongPlugIn==retVal); + if (RSoundPlugIn::ESoundWrongPlugIn!=retVal) + INFO_PRINTF3(_L("click1.CommandReply(2,des) return value - Expected: %d , Actual: %d"), RSoundPlugIn::ESoundWrongPlugIn, retVal); + + retVal = click1.CommandReply(-1,des); + TEST(RSoundPlugIn::ESoundWrongPlugIn==retVal); + if (RSoundPlugIn::ESoundWrongPlugIn!=retVal) + INFO_PRINTF3(_L("click1.CommandReply(-1,des) return value - Expected: %d , Actual: %d"), RSoundPlugIn::ESoundWrongPlugIn, retVal); + + retBool = click1.KeyClickEnabled(); + TEST(retBool); + if (!retBool) + INFO_PRINTF3(_L("click1.KeyClickEnabled() return value - Expected: %d , Actual: %d"), ETrue, retBool); + + retBool = click1.PenClickEnabled(); + TEST(retBool); + if (!retBool) + INFO_PRINTF3(_L("click1.PenClickEnabled() return value - Expected: %d , Actual: %d"), ETrue, retBool); + + click1.SetPenClick(EFalse); + retBool = click1.KeyClickEnabled(); + TEST(retBool); + if (!retBool) + INFO_PRINTF3(_L("click1.KeyClickEnabled() return value - Expected: %d , Actual: %d"), ETrue, retBool); + + retBool = !click1.PenClickEnabled(); + TEST(retBool); + if (!retBool) + INFO_PRINTF3(_L("!click1.PenClickEnabled() return value - Expected: %d , Actual: %d"), ETrue, retBool); + + click1.SetKeyClick(EFalse); + + retBool = !click1.KeyClickEnabled(); + TEST(retBool); + if (!retBool) + INFO_PRINTF3(_L("!click1.KeyClickEnabled() return value - Expected: %d , Actual: %d"), ETrue, retBool); + + retBool = !click1.PenClickEnabled(); + TEST(retBool); + if (!retBool) + INFO_PRINTF3(_L("!click1.PenClickEnabled() return value - Expected: %d , Actual: %d"), ETrue, retBool); + + click1.SetPenClick(ETrue); + retBool = !click1.KeyClickEnabled(); + TEST(retBool); + if (!retBool) + INFO_PRINTF3(_L("!click1.KeyClickEnabled() return value - Expected: %d , Actual: %d"), ETrue, retBool); + + retBool = click1.PenClickEnabled(); + TEST(retBool); + if (!retBool) + INFO_PRINTF3(_L("click1.PenClickEnabled() return value - Expected: %d , Actual: %d"), ETrue, retBool); + + click1.SetKeyClick(ETrue); + retBool = click1.KeyClickEnabled(); + TEST(retBool); + if (!retBool) + INFO_PRINTF3(_L("click1.KeyClickEnabled() return value - Expected: %d , Actual: %d"), ETrue, retBool); + + retBool = click1.PenClickEnabled(); + TEST(retBool); + if (!retBool) + INFO_PRINTF3(_L("click1.PenClickEnabled() return value - Expected: %d , Actual: %d"), ETrue, retBool); + + /*RLibrary lib; + TInt err=lib.Load(KDllName); + if (err==KErrNone) + { + TPtrC8 des(NULL,0); + TEST(lib.Type()[2].iUid==click1.CommandReply(0,des)); + lib.Close(); + }*/ + } + CleanupStack::PopAndDestroy(4,&ws); + } + +void CTAnimDll::TestWindowInfo(RTestAnim& aAnim,TInt aScreen,TInt aPos,TInt aId) + { + TPckgBuf params; + params().iScreen=aScreen; + params().iOrdinalPosition=aPos; + TPckgBuf winGpInfo; + TIpcArgs ipcArgs; + ipcArgs.Set(KIpcSlot,&winGpInfo); + TBool retBool = aAnim.CommandReply(EADllWindowGroupInfo,params,ipcArgs); + TEST(retBool); + if (!retBool) + INFO_PRINTF3(_L("aAnim.CommandReply(EADllWindowGroupInfo,params,ipcArgs) return value - Expected: %d , Actual: %d"), ETrue, retBool); + + MAnimGeneralFunctionsWindowExtension::TWindowGroupInfo& info=winGpInfo(); + TEST(info.iId==aId); + if (info.iId!=aId) + INFO_PRINTF3(_L("winGpInfo() return value - Expected: %d , Actual: %d"), aId, info.iId); + + TInt retVal = TheClient->iWs.GetWindowGroupOrdinalPriority(aId); + TEST(info.iOrdinalPriority==retVal); + if (info.iOrdinalPriority!=retVal) + INFO_PRINTF3(_L("TheClient->iWs.GetWindowGroupOrdinalPriority(aId) return value - Expected: %d , Actual: %d"), info.iOrdinalPriority, retVal); + + TBuf<64> windowGroupNameS; + TBuf<64> windowGroupNameA; + TheClient->iWs.GetWindowGroupNameFromIdentifier(aId,windowGroupNameS); + retVal = windowGroupNameS.Length(); + TEST(info.iNameLength==retVal); + if (info.iNameLength!=retVal) + INFO_PRINTF3(_L("windowGroupNameS.Length() return value - Expected: %d , Actual: %d"), info.iNameLength, retVal); + + if (info.iNameLength<64) + { + ipcArgs.Set(KIpcSlot,&windowGroupNameA); + retBool = aAnim.CommandReply(EADllWindowGroupName,params,ipcArgs); + TEST(retBool); + if (!retBool) + INFO_PRINTF3(_L("aAnim.CommandReply(EADllWindowGroupName,params,ipcArgs) return value - Expected: %d , Actual: %d"), ETrue, retBool); + + if (info.iNameLength>0) + { + TEST(windowGroupNameA==windowGroupNameS); + } + else + { + TEST(windowGroupNameA.Length()==0); + if (windowGroupNameA.Length()!=0) + INFO_PRINTF3(_L("iwindowGroupNameA.Length()==0 - Expected: %d, Actual: %d"), 0, windowGroupNameA.Length()); + } + + } + TEST(info.iParentId>=-1); + if (info.iParentId<-1) + INFO_PRINTF3(_L("info.iParentId>=-1 - Expected: %d or greater, Actual: %d"), -1, info.iParentId); + + } + +void CTAnimDll::TestEventHandlerRemovalL() + { + RTestAnim anim(iAnimDll); + User::LeaveIfError(anim.Construct(*iRedrawWin->BaseWin(),EAnimTypeEventHandler,KNullDesC8)); + anim.Close(); + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-0137 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Animation's extended window functions test + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions The test creates a window animation that has a couple of + commands that work with extended window functions encapsulated + into MAnimGeneralFunctionsWindowExtension class instance. + The test calls those commands to compare MAnimGeneralFunctionsWindowExtension's + methods' results with the results retuned by WSERV client classes. + MAnimGeneralFunctionsWindowExtension methods tested here: + Screens(), FocusScreens(), WindowGroups(), WindowGroupInfo(), + WindowGroupName() + +@SYMTestExpectedResults MAnimGeneralFunctionsWindowExtension methods must give the same results as + the corresponding WSERV client methods would. +*/ +void CTAnimDll::WinFunctionsL() + { + RTestAnim anim(iAnimDll); + User::LeaveIfError(anim.Construct(*iRedrawWin->BaseWin(),EAnimTypeWindowFunctions,KNullDesC8)); + CleanupClosePushL(anim); + TInt screens=anim.CommandReply(EADllScreen); + TEST(screens>0); + if (screens<=0) + INFO_PRINTF3(_L("anim.CommandReply(EADllScreen) return value - Expected: %d or greater, Actual: %d"), 1, screens); + + TInt focusScreen=anim.CommandReply(EADllFocusScreen); + TInt retVal = TheClient->iWs.GetFocusScreen(); + TEST(focusScreen==retVal && focusScreen<=screens); + if (focusScreen!=retVal || focusScreen>screens) + INFO_PRINTF4(_L("anim.CommandReply(EADllFocusScreen) return value - Expected: %d and less than or equal to %d, Actual: %d"), retVal, screens, focusScreen); + + TInt ii; + TPckgBuf screen; + CArrayPtrFlat* wins=new(ELeave) CArrayPtrFlat(screens); + CleanupStack::PushL(wins); + // create one window on each screen + for(ii=0;iiConstructL(); + wins->AppendL(win); + } + if (screens>1) + { + for (ii=screens-1;ii>=0;--ii) + { + TheClient->iWs.SetFocusScreen(ii); + retVal = anim.CommandReply(EADllFocusScreen); + TEST(retVal==ii); + if (retVal!=ii) + INFO_PRINTF3(_L("anim.CommandReply(EADllFocusScreen) return value - Expected: %d, Actual: %d"), ii, retVal); + } + for (ii=screens-1;ii>=0;--ii) + { + screen()=ii; + anim.CommandReply(EADllSetFocusScreen,screen); + retVal = anim.CommandReply(EADllFocusScreen); + TEST(retVal==ii); + if (retVal!=ii) + INFO_PRINTF3(_L("anim.CommandReply(EADllFocusScreen) return value - Expected: %d, Actual: %d"), ii, retVal); + } + } + TheClient->iWs.SetFocusScreen(focusScreen); + retVal = anim.CommandReply(EADllFocusScreen); + TEST(retVal==focusScreen); + if (retVal!=focusScreen) + INFO_PRINTF3(_L("anim.CommandReply(EADllFocusScreen) return value - Expected: %d, Actual: %d"), focusScreen, retVal); + + TInt winGroupsAll=0; + for(ii=0;iiiWs.NumWindowGroups(); + TEST(winGroupsAll==winGroupsS); + if (winGroupsAll!=winGroupsS) + INFO_PRINTF3(_L("TheClient->iWs.NumWindowGroups() return value - Expected: %d, Actual: %d"), winGroupsS, winGroupsAll); + + // the remaining test will use winGroupsA and performed on current focus screen only + screen()=iTest->iScreenNumber; + TInt winGroupsA=anim.CommandReply(EADllWindowGroups,screen); + CArrayFixFlat* windowList=new(ELeave) CArrayFixFlat(3); + CleanupStack::PushL(windowList); + // wserv implementation returns window groups from current focus screen, followed by the rest + TheClient->iWs.WindowGroupList(windowList); + // only interested in window group from current focus screen + for (ii=0;iiiScreenNumber,ii,(*windowList)[ii]); + TPckgBuf winGpInfo; + TIpcArgs ipcArgs; + TPckgBuf params; + params().iScreen=iTest->iScreenNumber; + params().iOrdinalPosition=winGroupsA; + ipcArgs.Set(KIpcSlot,&winGpInfo); + TBuf<64> windowGroupName; + TBool retBool = !anim.CommandReply(EADllWindowGroupInfo,params,ipcArgs); + TEST(retBool); + if (!retBool) + INFO_PRINTF3(_L("!anim.CommandReply(EADllWindowGroupInfo,params,ipcArgs) return value - Expected: %d, Actual: %d"), ETrue, retBool); + + ipcArgs.Set(KIpcSlot,&windowGroupName); + retBool = !anim.CommandReply(EADllWindowGroupName,params,ipcArgs); + TEST(retBool); + if (!retBool) + INFO_PRINTF3(_L("!anim.CommandReply(EADllWindowGroupName,params,ipcArgs) return value - Expected: %d, Actual: %d"), ETrue, retBool); + + /*params().iOrdinalPosition=-1; //Behaviour for negative positions not defined - but as writtin this code will pass + ipcArgs.Set(KIpcSlot,&winGpInfo); + TEST(anim.CommandReply(EADllWindowGroupInfo,params,ipcArgs)); + ipcArgs.Set(KIpcSlot,&windowGroupNameA); + TEST(anim.CommandReply(EADllWindowGroupName,params,ipcArgs));*/ + RWindowGroup group(TheClient->iWs); + User::LeaveIfError(group.Construct(ENullWsHandle)); + CleanupClosePushL(group); + _LIT(KGroupName,"Testxyz1234"); + group.SetName(KGroupName); + group.SetOrdinalPosition(0,TheClient->iWs.GetWindowGroupOrdinalPriority((*windowList)[0])+1); + TInt groupId=group.Identifier(); + TestWindowInfo(anim,iTest->iScreenNumber,0,groupId); + group.SetOrdinalPosition(0,TheClient->iWs.GetWindowGroupOrdinalPriority((*windowList)[winGroupsA-1])-1); + TestWindowInfo(anim,iTest->iScreenNumber,winGroupsA,groupId); + CleanupStack::PopAndDestroy(screens+4,&anim); +// Restore us back to the front + TheClient->iGroup->GroupWin()->SetOrdinalPosition(0); + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-0138 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Animation's extended window functions test 2 + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions The test creates a window animation that has a command + for setting window's ordinal position and priority. + The test creates 4 window groups with the same priority and + checks that they have correct ordinal positions after the creation. + After that the test plays with updating ordinal positions and + priorities of the window groups using the animation's command. + +@SYMTestExpectedResults The test checks that the command was executed with no errors + and affected ordinal positions of the window groups properly. +*/ +void CTAnimDll::WinFunctions2L() + { + RTestAnim anim(iAnimDll); + User::LeaveIfError(anim.Construct(*iRedrawWin->BaseWin(),EAnimTypeWindowFunctions,KNullDesC8)); + CleanupClosePushL(anim); + CArrayFixFlat* windowList=new(ELeave) CArrayFixFlat(3); + TheClient->iWs.WindowGroupList(windowList); + TInt priority=TheClient->iWs.GetWindowGroupOrdinalPriority((*windowList)[0])+2; + delete windowList; + RWindowGroup group1(TheClient->iWs); + User::LeaveIfError(group1.Construct(ENullWsHandle)); + CleanupClosePushL(group1); + group1.SetOrdinalPosition(0,priority); + RWindowGroup group2(TheClient->iWs); + User::LeaveIfError(group2.Construct(ENullWsHandle)); + CleanupClosePushL(group2); + group2.SetOrdinalPosition(0,priority); + RWindowGroup group3(TheClient->iWs); + User::LeaveIfError(group3.Construct(ENullWsHandle)); + CleanupClosePushL(group3); + group3.SetOrdinalPosition(0,priority); + RWindowGroup group4(TheClient->iWs); + User::LeaveIfError(group4.Construct(ENullWsHandle)); + CleanupClosePushL(group4); + group4.SetOrdinalPosition(0,priority); + + TInt retVal = group1.OrdinalPosition(); + TEST(retVal==3); + if (retVal!=3) + INFO_PRINTF3(_L("group1.OrdinalPosition() return value - Expected: %d, Actual: %d"), 3, retVal); + + retVal = group2.OrdinalPosition(); + TEST(retVal==2); + if (retVal!=2) + INFO_PRINTF3(_L("group2.OrdinalPosition() return value - Expected: %d, Actual: %d"), 2, retVal); + + retVal = group3.OrdinalPosition(); + TEST(retVal==1); + if (retVal!=1) + INFO_PRINTF3(_L("group3.OrdinalPosition() return value - Expected: %d, Actual: %d"), 1, retVal); + + retVal = group4.OrdinalPosition(); + TEST(retVal==0); + if (retVal!=0) + INFO_PRINTF3(_L("group4.OrdinalPosition() return value - Expected: %d, Actual: %d"), 0, retVal); + + TPckgBuf params; + params().iIdentifier=group4.Identifier(); + params().iOrdinalPriority=priority; + params().iOrdinalPosition=1; + retVal = anim.CommandReply(EADllSetOrdinalPosition,params); + TEST(retVal==KErrNone); + if (retVal!=KErrNone) + INFO_PRINTF3(_L("anim.CommandReply(EADllSetOrdinalPosition,params) return value - Expected: %d, Actual: %d"), KErrNone, retVal); + + retVal = group3.OrdinalPosition(); + TEST(retVal==0); + if (retVal!=0) + INFO_PRINTF3(_L("group3.OrdinalPosition() return value - Expected: %d, Actual: %d"), 0, retVal); + + retVal = group4.OrdinalPosition(); + TEST(retVal==1); + if (retVal!=1) + INFO_PRINTF3(_L("group4.OrdinalPosition() return value - Expected: %d, Actual: %d"), 1, retVal); + + params().iOrdinalPosition=2; + retVal = anim.CommandReply(EADllSetOrdinalPosition,params); + TEST(retVal==KErrNone); + if (retVal!=KErrNone) + INFO_PRINTF3(_L("anim.CommandReply(EADllSetOrdinalPosition,params) return value - Expected: %d, Actual: %d"), KErrNone, retVal); + + retVal = group2.OrdinalPosition(); + TEST(retVal==1); + if (retVal!=1) + INFO_PRINTF3(_L("group2.OrdinalPosition() return value - Expected: %d, Actual: %d"), 1, retVal); + + retVal = group4.OrdinalPosition(); + TEST(retVal==2); + if (retVal!=2) + INFO_PRINTF3(_L("group4.OrdinalPosition() return value - Expected: %d, Actual: %d"), 2, retVal); + + params().iOrdinalPosition=3; + retVal = anim.CommandReply(EADllSetOrdinalPosition,params); + TEST(retVal==KErrNone); + if (retVal!=KErrNone) + INFO_PRINTF3(_L("anim.CommandReply(EADllSetOrdinalPosition,params) return value - Expected: %d, Actual: %d"), KErrNone, retVal); + + retVal = group1.OrdinalPosition(); + TEST(retVal==2); + if (retVal!=2) + INFO_PRINTF3(_L("group1.OrdinalPosition() return value - Expected: %d, Actual: %d"), 2, retVal); + + retVal = group2.OrdinalPosition(); + TEST(retVal==1); + if (retVal!=1) + INFO_PRINTF3(_L("group2.OrdinalPosition() return value - Expected: %d, Actual: %d"), 1, retVal); + + retVal = group3.OrdinalPosition(); + TEST(retVal==0); + if (retVal!=0) + INFO_PRINTF3(_L("group3.OrdinalPosition() return value - Expected: %d, Actual: %d"), 0, retVal); + + retVal = group4.OrdinalPosition(); + TEST(retVal==3); + if (retVal!=3) + INFO_PRINTF3(_L("group4.OrdinalPosition() return value - Expected: %d, Actual: %d"), 3, retVal); + + params().iOrdinalPriority=priority+1; + params().iOrdinalPosition=3; + retVal = anim.CommandReply(EADllSetOrdinalPosition,params); + TEST(retVal==KErrNone); + if (retVal!=KErrNone) + INFO_PRINTF3(_L("anim.CommandReply(EADllSetOrdinalPosition,params) return value - Expected: %d, Actual: %d"), KErrNone, retVal); + + retVal = group4.OrdinalPosition(); + TEST(retVal==0); + if (retVal!=0) + INFO_PRINTF3(_L("group4.OrdinalPosition() return value - Expected: %d, Actual: %d"), 0, retVal); + + params().iOrdinalPriority=priority; + params().iOrdinalPosition=-2; + retVal = anim.CommandReply(EADllSetOrdinalPosition,params); + TEST(retVal==KErrNone); + if (retVal!=KErrNone) + INFO_PRINTF3(_L("anim.CommandReply(EADllSetOrdinalPosition,params) return value - Expected: %d, Actual: %d"), KErrNone, retVal); + + retVal = group4.OrdinalPosition(); + TEST(retVal==3); + if (retVal!=3) + INFO_PRINTF3(_L("group4.OrdinalPosition() return value - Expected: %d, Actual: %d"), 3, retVal); + + params().iOrdinalPosition=0; + retVal = anim.CommandReply(EADllSetOrdinalPosition,params); + TEST(retVal==KErrNone); + if (retVal!=KErrNone) + INFO_PRINTF3(_L("anim.CommandReply(EADllSetOrdinalPosition,params) return value - Expected: %d, Actual: %d"), KErrNone, retVal); + + retVal = group1.OrdinalPosition(); + TEST(retVal==3); + if (retVal!=3) + INFO_PRINTF3(_L("group1.OrdinalPosition() return value - Expected: %d, Actual: %d"), 3, retVal); + + retVal = group2.OrdinalPosition(); + TEST(retVal==2); + if (retVal!=2) + INFO_PRINTF3(_L("group2.OrdinalPosition() return value - Expected: %d, Actual: %d"), 2, retVal); + + retVal = group3.OrdinalPosition(); + TEST(retVal==1); + if (retVal!=1) + INFO_PRINTF3(_L("group3.OrdinalPosition() return value - Expected: %d, Actual: %d"), 1, retVal); + + retVal = group4.OrdinalPosition(); + TEST(retVal==0); + if (retVal!=0) + INFO_PRINTF3(_L("group4.OrdinalPosition() return value - Expected: %d, Actual: %d"), 0, retVal); + + params().iOrdinalPriority=priority-1; + params().iOrdinalPosition=2; + retVal = anim.CommandReply(EADllSetOrdinalPosition,params); + TEST(retVal==KErrNone); + if (retVal!=KErrNone) + INFO_PRINTF3(_L("anim.CommandReply(EADllSetOrdinalPosition,params) return value - Expected: %d, Actual: %d"), KErrNone, retVal); + + retVal = group1.OrdinalPosition(); + TEST(retVal==2); + if (retVal!=2) + INFO_PRINTF3(_L("group1.OrdinalPosition() return value - Expected: %d, Actual: %d"), 2, retVal); + + retVal = group2.OrdinalPosition(); + TEST(retVal==1); + if (retVal!=1) + INFO_PRINTF3(_L("group2.OrdinalPosition() return value - Expected: %d, Actual: %d"), 1, retVal); + + retVal = group3.OrdinalPosition(); + TEST(retVal==0); + if (retVal!=0) + INFO_PRINTF3(_L("group3.OrdinalPosition() return value - Expected: %d, Actual: %d"), 0, retVal); + + retVal = group4.OrdinalPosition(); + TEST(retVal==0); + if (retVal!=0) + INFO_PRINTF3(_L("group4.OrdinalPosition() return value - Expected: %d, Actual: %d"), 0, retVal); + + + params().iOrdinalPriority=priority; + params().iOrdinalPosition=0; + retVal = anim.CommandReply(EADllSetOrdinalPosition,params); + TEST(retVal==KErrNone); + if (retVal!=KErrNone) + INFO_PRINTF3(_L("anim.CommandReply(EADllSetOrdinalPosition,params) return value - Expected: %d, Actual: %d"), KErrNone, retVal); + + retVal = group1.OrdinalPosition(); + TEST(retVal==3); + if (retVal!=3) + INFO_PRINTF3(_L("group1.OrdinalPosition() return value - Expected: %d, Actual: %d"), 3, retVal); + + retVal = group2.OrdinalPosition(); + TEST(retVal==2); + if (retVal!=2) + INFO_PRINTF3(_L("group2.OrdinalPosition() return value - Expected: %d, Actual: %d"), 2, retVal); + + retVal = group3.OrdinalPosition(); + TEST(retVal==1); + if (retVal!=1) + INFO_PRINTF3(_L("group3.OrdinalPosition() return value - Expected: %d, Actual: %d"), 1, retVal); + + retVal = group4.OrdinalPosition(); + TEST(retVal==0); + if (retVal!=0) + INFO_PRINTF3(_L("group4.OrdinalPosition() return value - Expected: %d, Actual: %d"), 0, retVal); + + CleanupStack::PopAndDestroy(5,&anim); + /*TInt pos1=group1.OrdinalPosition(); + TInt pos2=group2.OrdinalPosition(); + TInt pos3=group3.OrdinalPosition(); + TInt pos4=group4.OrdinalPosition();*/ + } + + +/** +@SYMTestCaseID GRAPHICS-WSERV-0139 + +@SYMDEF DEF081259, DEF122220 + +@SYMTestCaseDesc Animation's notifications test + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions The test works with two screens. An animation is created that keeps + track on all notifications about EDirectScreenAccess, EHeartbeatTimer, + EScreenDeviceChange events. + The test generates those events by performing operations on direct + screen access and simulating TRawEvent::EInactive and TRawEvent::EAactive + events. + +@SYMTestExpectedResults The test checks that the animation didn't miss any of EDirectScreenAccess + or EHeartbeatTimer notifications. (The test doesn't check EScreenDeviceChange + notifications however). + The test also makes sure that the animation didn't animate + during inactive state. + For DEF12220, the test will crash when a untidied notifier from a previous RTestAnim object + is accessed if the fix is not present. If the fix is present, the test should not crash. +*/ +void CTAnimDll::TestNotificationsL() + { + RTestAnim anim(iAnimDll); + User::LeaveIfError(anim.Construct(*iRedrawWin->BaseWin(),EAnimTypeNotificationTest,KNullDesC8)); + CleanupClosePushL(anim); + + TPckgBuf screenNum; + + // initial state - test that we have no DSA on either screen + screenNum() = 0; + TInt dsa=anim.CommandReply(EADllQueryDSA, screenNum); + TEST(!dsa); + if (dsa) + INFO_PRINTF3(_L("anim.CommandReply(EADllQueryDSA, screenNum) return value - Expected: %d, Actual: %d"), 0, dsa); + + screenNum() = 1; + dsa=anim.CommandReply(EADllQueryDSA, screenNum); + TEST(!dsa); + if (dsa) + INFO_PRINTF3(_L("anim.CommandReply(EADllQueryDSA, screenNum) return value - Expected: %d, Actual: %d"), 0, dsa); + + // create first DSA, but don't start it - test that we have no DSA on either screen + CScrollText* dsa1 = CScrollText::NewL(iTest->iScreenNumber,1,*TheClient->iGroup,5,EFalse); + CleanupStack::PushL(dsa1); + screenNum() = 0; + dsa=anim.CommandReply(EADllQueryDSA, screenNum); + TEST(!dsa); + if (dsa) + INFO_PRINTF3(_L("anim.CommandReply(EADllQueryDSA, screenNum) return value - Expected: %d, Actual: %d"), 0, dsa); + + screenNum() = 1; + dsa=anim.CommandReply(EADllQueryDSA, screenNum); + TEST(!dsa); + if (dsa) + INFO_PRINTF3(_L("anim.CommandReply(EADllQueryDSA, screenNum) return value - Expected: %d, Actual: %d"), 0, dsa); + + // start first DSA - test that we have DSA on this screen but not other screen + dsa1->StartL(); + screenNum() = 0; + dsa=anim.CommandReply(EADllQueryDSA, screenNum); + TInt retVal = (screenNum() == iTest->iScreenNumber); + TEST(dsa == retVal); + if (dsa != retVal) + INFO_PRINTF3(_L("dsa == (screenNum() == iTest->iScreenNumber) - Expected: %d, Actual: %d"), retVal, dsa); + + screenNum() = 1; + dsa=anim.CommandReply(EADllQueryDSA, screenNum); + retVal = (screenNum() == iTest->iScreenNumber); + TEST(dsa == retVal); + if (dsa != retVal) + INFO_PRINTF3(_L("dsa == (screenNum() == iTest->iScreenNumber) - Expected: %d, Actual: %d"), retVal, dsa); + + // start second DSA + CScrollText* dsa2 = CScrollText::NewL(iTest->iScreenNumber,2,*TheClient->iGroup,5,EFalse); + CleanupStack::PushL(dsa2); + dsa2->StartL(); + screenNum() = 0; + dsa=anim.CommandReply(EADllQueryDSA, screenNum); + retVal = (screenNum() == iTest->iScreenNumber); + TEST(dsa == retVal); + if (dsa != retVal) + INFO_PRINTF3(_L("dsa == (screenNum() == iTest->iScreenNumber) - Expected: %d, Actual: %d"), retVal, dsa); + + screenNum() = 1; + dsa=anim.CommandReply(EADllQueryDSA, screenNum); + retVal = (screenNum() == iTest->iScreenNumber); + TEST(dsa == retVal); + if (dsa != retVal) + INFO_PRINTF3(_L("dsa == (screenNum() == iTest->iScreenNumber) - Expected: %d, Actual: %d"), retVal, dsa); + + // stop second DSA + dsa2->Stop(); + CleanupStack::PopAndDestroy(dsa2); + screenNum() = 0; + dsa=anim.CommandReply(EADllQueryDSA, screenNum); + retVal = (screenNum() == iTest->iScreenNumber); + TEST(dsa == retVal); + if (dsa != retVal) + INFO_PRINTF3(_L("dsa == (screenNum() == iTest->iScreenNumber) - Expected: %d, Actual: %d"), retVal, dsa); + + screenNum() = 1; + dsa=anim.CommandReply(EADllQueryDSA, screenNum); + retVal = (screenNum() == iTest->iScreenNumber); + TEST(dsa == retVal); + if (dsa != retVal) + INFO_PRINTF3(_L("dsa == (screenNum() == iTest->iScreenNumber) - Expected: %d, Actual: %d"), retVal, dsa); + + // stop first DSA + dsa1->Stop(); + CleanupStack::PopAndDestroy(dsa1); + screenNum() = 0; + dsa=anim.CommandReply(EADllQueryDSA, screenNum); + TEST(!dsa); + if (dsa) + INFO_PRINTF3(_L("anim.CommandReply(EADllQueryDSA, screenNum) return value - Expected: %d, Actual: %d"), 0, dsa); + + screenNum() = 1; + dsa=anim.CommandReply(EADllQueryDSA, screenNum); + TEST(!dsa); + if (dsa) + INFO_PRINTF3(_L("anim.CommandReply(EADllQueryDSA, screenNum) return value - Expected: %d, Actual: %d"), 0, dsa); + + // TEST heartbeat timer start\stop notifications - no longer relevant - has been removed + + CleanupStack::PopAndDestroy(&anim); + + // Create second RTestAnim for DEF12220 test + RTestAnim anim2(iAnimDll); + User::LeaveIfError(anim2.Construct(*iRedrawWin->BaseWin(),EAnimTypeNotificationTest,KNullDesC8)); + CleanupClosePushL(anim2); + + // Create third dsa + CScrollText* dsa3 = CScrollText::NewL(iTest->iScreenNumber,1,*TheClient->iGroup,5,EFalse); + CleanupStack::PushL(dsa3); + // If the fix for DEF12220 is not present, starting dsa3 will cause a crash. + dsa3->StartL(); + dsa3->Stop(); + CleanupStack::PopAndDestroy(dsa3); + CleanupStack::PopAndDestroy(&anim2); + } + +/** + A minimal dsa call to a window with a child window, for running coverage on + ClipWindows member funcion. + +@SYMTestCaseID GRAPHICS-WSERV-0410 + +@SYMPREQ PREQ1841 + +@SYMTestExpectedResults Nothing visible, the CWsClientWindow::ClipWindows +should be partially covered. + */ +void CTAnimDll::TestCoverageL() + { + // create first DSA, but don't start it - test that we have no DSA on either screen + CWindowWithChild* dsa1 = CWindowWithChild::NewL(iTest->iScreenNumber, *TheClient->iGroup, EFalse); + CleanupStack::PushL(dsa1); + + // start first DSA - test that we have DSA on this screen but not other screen + dsa1->StartL(); + dsa1->PerformCoverageCalls(); + dsa1->Stop(); + + // cover another trivial case for a non-visible window + RWindow* cwin = dsa1->ChildWindow(); + + cwin->SetTransparencyAlphaChannel(); + dsa1->ContinueL(); + + //ClipWindows with visible and invisible branches + cwin->SetVisible(EFalse); + + //cover CWsWindow::StatusDump (visible and invisible branch) + TheClient->iWs.LogCommand(RWsSession::ELoggingStatusDump); + + dsa1->Stop(); + dsa1->StartL(); + cwin->SetVisible(ETrue); + dsa1->Stop(); + + CleanupStack::PopAndDestroy(dsa1); + } + +/** + Executes a Panic coverage test for a given test-number. + Most of the first lines copied from DoPanicTest. + CWsWindow is tested through CommandL (case 0-3) and other API funcs + */ +LOCAL_C TInt DoPanicTestCoverage(TInt aTestNum, TAny *aScreenNumber) + { + RWsSession ws; + User::LeaveIfError(ws.Connect()); + + // assign to the correct screen + CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws); + User::LeaveIfError(screen->Construct(reinterpret_cast(aScreenNumber))); + + RWindowGroup group(ws); + User::LeaveIfError(group.Construct(333)); + group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close + RAnimDll animDll=RAnimDll(ws); + User::LeaveIfError(animDll.Load(KAnimDLLName)); + + RWindow window(ws); + User::LeaveIfError(window.Construct(group,123)); + window.SetSize(TSize(10,10)); + window.Activate(); + window.BeginRedraw(); + window.EndRedraw(); + + switch (aTestNum) + { + case 0: //non translucent window + //EWsWinOpSetTransparentRegion -> EWservPanicTransparencyObjNotCreated + { + RRegion r; + window.SetTransparentRegion(r); + break; + } + case 1: + //EWsWinOpSetTransparencyPolicy -> EWservPanicTransparencyObjNotCreated + window.SetTransparencyPolicy(ETransparencyDefault); + break; + case 2: + // -> EWservPanicWindowActive + window.Activate(); + break; + case 3: + // -> EWservPanicCornerParams + window.SetCornerType(EWindowCornerSquare, ECornerTypeMask); + break; + case 4: + // -> EWservPanicCornerParams + window.SetCornerType(ECornerTypeMask, 0); + break; + default: + return EWsExitReasonFinished; + } + ws.Flush(); + + return(EWsExitReasonBad); // Should never get here, but it's baaddd if it does + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-0411 + +@SYMPREQ PREQ1841 + +@SYMTestCaseDesc Does functional coverage for code that Panics + +*/ +void CTAnimDll::TestPanicCoverageL() + { + TClientPanic expectedPanicCode[] = + { + EWservPanicTransparencyObjNotCreated, //0 + EWservPanicTransparencyObjNotCreated, //1 + EWservPanicWindowActive, //2 + EWservPanicCornerParams, //3 + EWservPanicCornerParams, //4 + }; + for (TInt i=0; iTestWsPanicL( + DoPanicTestCoverage, //aFunction + expectedPanicCode[i], //aExitReason + i, //aInt + (TAny*)iTest->iScreenNumber, //aPtr + NULL)); //&finishTests //aTestFinished + iTest->CloseAllPanicWindows(); + } + } + + +/** +@SYMTestCaseID GRAPHICS-CODEBASE-WSERV-0056-0001 + +@SYMPREQ PGM027 + +@SYMTestCaseDesc Tests RAnimDll::Load (by passing invalid file name) + +@SYMTestPriority 1 + +@SYMTestStatus Implemented + +@SYMTestActions Call RAnimDll::Load() by passing invalid file name\n + +@SYMTestExpectedResults Should return with appropiate error message. KErrNotFound + */ +void CTAnimDll::TestLoadApiL() + { + RAnimDll* animDll=new(ELeave) RAnimDll(TheClient->iWs); + CleanupStack::PushL(animDll); + TInt ret=0; + _LIT(KAnimFile,"Nothing.dll"); + _LIT(KEmpty,""); + ret=animDll->Load(KAnimFile); + TEST(ret==KErrNotFound); + ret=animDll->Load(KEmpty); + TEST(ret==KErrNotFound); + CleanupStack::PopAndDestroy(animDll); + } + +TInt CTAnimDll::CheckError(TInt aError,TInt aExpected) + { + if (aError!=0) + { + if (aError>0) + { + _LIT(KLog,"The event at position %d did not match, total number of events=%d"); + LOG_MESSAGE3(KLog,aError,aExpected); + } + else + { + _LIT(KLog,"Only recieved %d events, expecting %d events"); + LOG_MESSAGE3(KLog,-aError,aExpected); + } + return EFalse; + } + return ETrue; + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-0448 + +@SYMCR CR1164 + +@SYMTestCaseDesc Test events get to Anims at a higher priorty than commands + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Create a 2nd thread that sends events via kernal, send also commands from client to an Anim + +@SYMTestExpectedResults Check that events intersperse commands from client +*/ +void CTAnimDll::KeyClickPriorityL() + { + _LIT(KFailedAdd,"Device Driver Failed to Add an Event, error=%d"); + REventAnim* anim=REventAnim::NewL(iTestWin->BaseWin(),&iAnimDll); + TPckgBuf events; + TInt err=anim->CommandReply(EADllLoadDeviceDriver); + if (err!=KErrNone) + { + _LIT(KLog,"Failed to load Device Driver for sending Events"); + TEST(EFalse); + LOG_MESSAGE(KLog); + } + TInt error; + TInt ii; + for (ii=1;ii<5;++ii) + { + events()=ii; + error=anim->CommandReply(EADllSendEvent,events); + if (error!=KErrNone) + LOG_MESSAGE2(KFailedAdd,error); + anim->Command(EADllAfterEvent); + TheClient->Flush(); + error=anim->TestFail(ii); + TEST(CheckError(error,ii)); + } + const TInt iterations=15; + const TInt eventsPerIteration=2; + const TInt totalEvents=iterations*eventsPerIteration; + events()=eventsPerIteration; + for (ii=iterations;ii>0;--ii) + { + error=anim->CommandReply(EADllSendEvent,events); + if (error!=KErrNone) + LOG_MESSAGE2(KFailedAdd,error); + anim->Command(EADllAfterEvent); + } + TheClient->Flush(); + error=anim->TestFail(totalEvents); + TEST(CheckError(error,totalEvents)); + anim->CommandReply(EADllUnloadDeviceDriver); + delete anim; + } + +/** +@SYMDEF INC117828 + +@SYMTestCaseDesc Tests Window Rect returned by CWsAnim::Parameters + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions This test creates a new window which overlaps the screen edge + and creates an animation on this window. An additional + CommandReplyL() option has been added to the AnimDLL to compare + the expected value of this rect with the actual value. + + +@SYMTestExpectedResults The result of the EADllTestParameterRect CommandReplyL call will equal ETrue + if the passed Rect matches, EFalse otherwise. +*/ +void CTAnimDll::ParameterValueTestL() + { + //Window Location & Dimension + TPoint winOrigin(-1,15); + TSize winSize(250,65); + + //Create a new window to perform the test; window needs to overlap the left edge of the screen. + CAnimWindow* paramTestWin = new(ELeave) CAnimWindow(EFalse, CAnimWindow::ERedraw); + CleanupStack::PushL(paramTestWin); + paramTestWin->ConstructL(winOrigin, winSize); + + RTestAnim anim = RTestAnim(iAnimDll); + + TPckgBuf rectPckg; + TRect winRect(winOrigin, winSize); + rectPckg() = winRect; + + anim.Construct(*(paramTestWin->BaseWin()), EAnimTypeTest3, rectPckg); + anim.Command(EADllStartAnimate, rectPckg); + + TPckgBuf boolPckg; + boolPckg() = ETrue; + anim.Command(EADllSetVisible, boolPckg); + + TEST(anim.CommandReply(EADllParameterRectValueTest, rectPckg)); + + boolPckg() = EFalse; + anim.Command(EADllSetVisible, boolPckg); + anim.Command(EADllCancelAnimate); + anim.Close(); + CleanupStack::PopAndDestroy(paramTestWin); + } + +/** +@SYMDEF DEF122176 + +@SYMTestCaseDesc Test the operation of SetInterval with both negative and positive intervals + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions This test uses the test anim CAutoAnim3 in mode 3 which alternates + between drawing a large and a small ellipse at each interval. + The large ellipse is drawn first. + Note that the anims are redrawn at the rate of 2 intervals per second, so + setting an interval of 2 will mean that the anim is redrawn every second. + Step 1: The interval is set to be -2 and the test then waits for 0.9 + seconds (to make sure one interval has passed) then checks that + only the large ellipse has been drawn. + Step 2: The interval is set to be 2 (redraw every second) and the test then + waits for 1.2 seconds (to make sure two intervals have passed) and + checks that the small ellipse has been drawn. + +@SYMTestExpectedResults + After Step 1 a large ellipse will be drawn on both windows. + After Step 1 a small ellipse will be drawn on both windows. + +*/ +void CTAnimDll::TestSetIntervalL() + { + RWsSession ws; + User::LeaveIfError(ws.Connect()); + + // draws a little circle on the base window using window graphics and using window animation on the test window. + RTestAnim drawAnim=RTestAnim(iAnimDll); + + _LIT(KLog1,"SetInterval Test"); + LOG_MESSAGE(KLog1); + TRect rect(10,10,110,110); + CAnimWindow::SetEllipseDrawMode(CGraphicsContext::EDrawModePEN); + iTestWin->Invalidate(); + iTestWin->SetRect(rect); + iBaseWin->Invalidate(); + iBaseWin->SetRect(rect); + TPckgBuf rectPckg; + rectPckg()=rect; + User::LeaveIfError(drawAnim.Construct(*iTestWin->BaseWin(),EAnimTypeTest3,rectPckg)); + + TPckgBuf intPckg; + intPckg() = 3; // mode 3 for this anim flips between drawing a large and a small ellipse + drawAnim.Command(EADllSetMode, intPckg); + + intPckg() = MAnimGeneralFunctions::ESyncNone; + drawAnim.CommandReply(EADllDoSetSync, intPckg); + + // Set an interval of -2 then wait 0.9 seconds, after which only the large ellipse should be visible + intPckg() = -2; + drawAnim.CommandReply(EADllSetInterval, intPckg); + // Draw the large ellipse on the base window to match what the anim should be drawing + iBaseWin->SetRect(rect); + iBaseWin->DoDraw(); + ws.Finish(); + // Check Step 1 completed successfully + RedrawAndCheckWindows(); + + // Set an interval of 2 and wait 0.9 seconds, after which the small ellipse should be visible + intPckg() = 2; + drawAnim.CommandReply(EADllSetInterval, intPckg); + // Draw the small ellipse on the base window to match what the anim should be drawing + iBaseWin->SetRect(TRect(40,40,80,80)); + iBaseWin->DoDraw(); + ws.Finish(); + // Check Step 2 completed successfully + RedrawAndCheckWindows(); + + // clean up + drawAnim.Close(); + ws.Close(); + } + +void CTAnimDll::RunTestCaseL(TInt /*aCurTestCase*/) + { + _LIT(KTest0,"RemoteBuffer"); + _LIT(KTest1,"ExtraCopyTest"); + _LIT(KTest2,"Misc"); + _LIT(KTest3,"SyncMode1"); + _LIT(KTest4,"Anim Dll Panics"); + _LIT(KTest5,"Drawing test"); + _LIT(KTest6,"Shadow drawing test"); + _LIT(KTest7,"General drawing test"); + _LIT(KTest8,"Destroy window test"); + _LIT(KTest9,"Sprite Anim test"); + _LIT(KTest10,"Free Timer test"); + _LIT(KTest11,"Disable Timer test"); + _LIT(KTest12,"Multiple Anims"); + _LIT(KTest13,"ReLoad Click PlugIn"); + _LIT(KTest14,"Window Functions"); + _LIT(KTest15,"Window Functions 2"); + _LIT(KTest16,"Notifications"); + _LIT(KTest17,"Event Handler removal"); + _LIT(KTest18,"Anim dll - Load Api Negative Test"); + _LIT(KTest19,"Key Click Priority Test"); + _LIT(KTest20,"CWsAnim::Parameters() WindowRect Value Test"); + _LIT(KTest21,"SetInterval test"); + _LIT(KTest22,"Client Window Coverage"); + _LIT(KTest23,"Client Window Panic Coverage"); + ((CTAnimDllStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); + +// if (iTest->iState==0) iTest->iState=22; //Use this line to start running tests from a particular test + switch(++iTest->iState) + { + case 1: + ((CTAnimDllStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0127")); + iTest->LogSubTest(KTest0); + RemoteBuffer(); + break; + case 2: + ((CTAnimDllStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0128")); + iTest->LogSubTest(KTest1); + ExtraCopyTest(); + break; + case 3: + ((CTAnimDllStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0126")); + iTest->LogSubTest(KTest2); + Misc(); + break; + case 4: +/** +@SYMTestCaseID GRAPHICS-WSERV-0503 +*/ + ((CTAnimDllStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0503")); + iTest->LogSubTest(KTest3); +// Disabled temporarily (process isolation/ RThread::RequestComplete issue) to allow WSERV test to continue + break; + case 5: + ((CTAnimDllStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0125")); + iTest->LogSubTest(KTest4); + TestPanicsL(); + if (iTest->iScreenNumber == 1) + iTest->CloseAllPanicWindows(); + break; + case 6: + ((CTAnimDllStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0129")); + iTest->LogSubTest(KTest5); + DrawingTestL(); + break; + case 7: +/** +@SYMTestCaseID GRAPHICS-WSERV-0504 +*/ + ((CTAnimDllStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0504")); + iTest->LogSubTest(KTest6); +// Disabled temporarily (process isolation/ RThread::RequestComplete issue) to allow WSERV test to continue + break; + case 8: + ((CTAnimDllStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0130")); + iTest->LogSubTest(KTest7); + GeneralDrawingTestL(); + break; + case 9: + ((CTAnimDllStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0131")); + iTest->LogSubTest(KTest8); + DestroyWindowTestL(); + break; + case 10: + ((CTAnimDllStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0132")); + iTest->LogSubTest(KTest9); + SpriteAnimL(); + break; + case 11: + ((CTAnimDllStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0133")); + iTest->LogSubTest(KTest10); + FreeTimerL(); + break; + case 12: + ((CTAnimDllStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0134")); + iTest->LogSubTest(KTest11); + DisableTimerL(); + break; + case 13: + ((CTAnimDllStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0135")); + iTest->LogSubTest(KTest12); + MultipleAnimsL(); + break; + case 14: + ((CTAnimDllStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0136")); + iTest->LogSubTest(KTest13); + ClickPlugInL(); + break; + case 15: + ((CTAnimDllStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0137")); + iTest->LogSubTest(KTest14); + WinFunctionsL(); + break; + case 16: + ((CTAnimDllStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0138")); + iTest->LogSubTest(KTest15); + WinFunctions2L(); + break; + case 17: + ((CTAnimDllStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0139")); + iTest->LogSubTest(KTest16); + TestNotificationsL(); + break; + case 18: + ((CTAnimDllStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0137")); + iTest->LogSubTest(KTest17); + TestEventHandlerRemovalL(); + break; + case 19: + ((CTAnimDllStep*)iStep)->SetTestStepID(_L("GRAPHICS-CODEBASE-WSERV-0056-0001")); + iTest->LogSubTest(KTest18); + TestLoadApiL(); + break; + case 20: + ((CTAnimDllStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0448")); + iTest->LogSubTest(KTest19); + KeyClickPriorityL(); + break; + case 21: + /** +@SYMTestCaseID GRAPHICS-WSERV-0505 +*/ + ((CTAnimDllStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0505")); + iTest->LogSubTest(KTest20); + ParameterValueTestL(); + break; + case 22: +/** +@SYMTestCaseID GRAPHICS-WSERV-0506 +*/ + ((CTAnimDllStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0506")); + iTest->LogSubTest(KTest21); + TestSetIntervalL(); + case 23: + ((CTAnimDllStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0410")); + iTest->LogSubTest(KTest22); + TestCoverageL(); + break; + case 24: + ((CTAnimDllStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0411")); + iTest->LogSubTest(KTest23); + TestPanicCoverageL(); + default: + ((CTAnimDllStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + ((CTAnimDllStep*)iStep)->CloseTMSGraphicsStep(); + TestComplete(); + } + User::Check(); + ((CTAnimDllStep*)iStep)->RecordTestResultL(); + } + +// + +CAnimRedrawWindow::CAnimRedrawWindow(CAnimWindow *aAnimWindow, TBool aIsBase) : CTWin(), + iAnimWindow(aAnimWindow), + iIsBase(aIsBase) + { + } + +CAnimRedrawWindow::~CAnimRedrawWindow() + { + } + +void CAnimRedrawWindow::Draw() + { + CAnimWindow::Draw(Gc(),Size(),iIsBase,iAnimWindow->iRect,EFalse); + } + +// + +CAnimWindow::CAnimWindow(TBool aIsBase, TWinType aWinType) : iWinType(aWinType), iIsBase(aIsBase) + { + } + + +CAnimWindow::~CAnimWindow() + { + delete iCtWin; + } + +void CAnimWindow::ConstructL(const TPoint &aPos, const TSize &aSize) + { + switch(iWinType) + { + case ERedraw: + iCtWin=new(ELeave) CAnimRedrawWindow(this, iIsBase); + break; + case EBlank: + iCtWin=new(ELeave) CTBlankWindow(); + break; + case EBackedUp: + iCtWin=new(ELeave) CTBackedUpWin(EGray4); + break; + } + iCtWin->SetUpL(aPos, aSize, TheClient->iGroup, *TheClient->iGc); + if (iWinType==ERedraw) + { + static_cast(iCtWin)->Win()->EnableRedrawStore(EFalse); + } + } + +void CAnimWindow::SetEllipseDrawMode(CGraphicsContext::TDrawMode aEllipseDrawMode) + { + iEllipseDrawMode=aEllipseDrawMode; + } + +void CAnimWindow::SetRect(const TRect &aRect) + { + iRect=aRect; + } + +void CAnimWindow::DrawEllipse(CBitmapContext *aGc, const TRect &aRect) + { + aGc->SetDrawMode(iEllipseDrawMode); + aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + aGc->SetBrushColor(TRgb(85,85,85)); + aGc->SetPenColor(TRgb(170,170,170)); + aGc->DrawEllipse(aRect); + } + +void CAnimWindow::Draw(CBitmapContext *aGc, const TSize &aSize, TBool aIsBase, const TRect &aRect, TBool aBlankIt) + { + aGc->SetBrushColor(TRgb::Gray4(2)); + aGc->Clear(); + if (!aBlankIt) + for(TInt i=0;iDrawLine(TPoint(i,0),TPoint(i+10,aSize.iHeight)); + if (aIsBase) + DrawEllipse(aGc, aRect); + } + +void CAnimWindow::DoDraw(TBool aBlankIt) + { + __ASSERT_ALWAYS(iWinType!=EBlank,AutoPanic(EAutoPanicWindowType)); + iCtWin->Gc()->Activate(*(RDrawableWindow *)BaseWin()); + Draw(iCtWin->Gc(),Size(),iIsBase,iRect,aBlankIt); + iCtWin->Gc()->Deactivate(); + } + +void CAnimWindow::DoDrawEllipse() + { + __ASSERT_ALWAYS(iWinType!=EBlank,AutoPanic(EAutoPanicWindowType)); + iCtWin->Gc()->Activate(*(RDrawableWindow *)BaseWin()); + DrawEllipse(iCtWin->Gc(),iRect); + iCtWin->Gc()->Deactivate(); + } + +void CAnimWindow::DoDrawCoverage() + { + __ASSERT_ALWAYS(iWinType!=EBlank,AutoPanic(EAutoPanicWindowType)); + CWindowGc *gc = iCtWin->Gc(); + gc->Activate(*(RDrawableWindow *)BaseWin()); + + gc->SetClippingRect(iRect); + gc->Clear(); + gc->Clear(iRect); + + gc->SetDrawMode(CGraphicsContext::EDrawModeAND); + gc->SetBrushStyle(CGraphicsContext::ENullBrush); + gc->SetBrushColor(TRgb::Gray256(85)); + gc->SetBrushOrigin(TPoint(0,0)); + gc->SetPenColor(TRgb::Gray256(170)); + + //primitive method calls + gc->SetFaded(ETrue); + gc->SetFadingParameters(1, 1); + + gc->SetPenStyle(CGraphicsContext::ESolidPen); + gc->SetStrikethroughStyle(EStrikethroughOff); + gc->SetUnderlineStyle(EUnderlineOff); + gc->SetWordJustification(2, 1); + + CFbsFont* font; + gc->Device()->GetNearestFontInTwips((CFont*&)font, TFontSpec()); + + gc->UseFont(font); + + gc->DrawArc(iRect, + TPoint(iRect.Center().iX, iRect.iTl.iY), + TPoint(iRect.iBr.iX, iRect.Center().iY)); + gc->DrawLine(iRect.iTl,iRect.Center()); + gc->DrawLineTo(TPoint(iRect.iBr.iX, iRect.iTl.iY)); + + gc->DrawLineBy(TPoint(iRect.iTl.iX, iRect.iBr.iY)); + gc->MoveBy(iRect.iTl + TPoint(1,1)); + gc->MoveTo(iRect.iTl + TPoint(0,0)); + gc->SetPenSize(TSize(10,10)); + gc->Plot(iRect.iTl + TPoint(2,2)); + gc->SetPenSize(TSize(1,1)); + + CArrayFixFlat* polyPoints = new(ELeave) CArrayFixFlat(3); //CArrayFixFlat + CleanupStack::PushL(polyPoints); + polyPoints->AppendL(iRect.iTl); + polyPoints->AppendL(iRect.Center()); + polyPoints->AppendL(TPoint(iRect.iBr.iX, iRect.iTl.iY)); + + gc->DrawPolyLine(polyPoints); + gc->DrawPolyLine(&polyPoints->At(0), 3); + gc->DrawPolygon(polyPoints, CGraphicsContext::EWinding); + gc->DrawPolygon(&polyPoints->At(0), 3, CGraphicsContext::EAlternate); + + gc->DrawPie(iRect, TPoint(iRect.Center().iX, iRect.iTl.iY), TPoint(iRect.iBr.iX, iRect.Center().iY)); + gc->DrawEllipse(iRect); + gc->DrawRect(iRect); + gc->DrawRoundRect(iRect, TSize(iRect.Width()/8, iRect.Height()/8)); + + CleanupStack::PopAndDestroy(polyPoints); + + gc->CopyRect(TPoint(10, 10), iRect); + + CFbsBitmap* bitmap = new(ELeave) CFbsBitmap(); + CleanupStack::PushL(bitmap); + User::LeaveIfError(bitmap->Create(TSize(16,16),EGray4)); + + gc->UseBrushPattern(bitmap); + gc->DrawBitmap(iRect.iTl, bitmap); + gc->DrawBitmap(iRect, bitmap); + gc->DrawBitmap(iRect, bitmap, TRect(0, 0, 16, 16)); + gc->DrawBitmapMasked(iRect, bitmap, TRect(0, 0, 16, 16), bitmap, ETrue); + + gc->BitBlt(TPoint(0, 0), bitmap); + gc->BitBlt(TPoint(0, 0), bitmap, iRect); + gc->BitBltMasked(TPoint(0, 0), bitmap, iRect, bitmap, ETrue); + gc->AlphaBlendBitmaps(TPoint(0, 0), bitmap, iRect, bitmap, TPoint(0,0)); + + CleanupStack::PopAndDestroy(bitmap); + + _LIT(KHelloWorld,"Hello World"); + gc->SetCharJustification(1,1); + gc->SetClippingRect(iRect); + gc->DrawText(*&KHelloWorld, iRect.iTl); + gc->DrawText(*&KHelloWorld, iRect, 0, CGraphicsContext::ELeft, 0); + gc->DrawTextVertical(*&KHelloWorld, iRect.iBr, ETrue); + gc->DrawTextVertical(*&KHelloWorld, iRect, 0, ETrue, CGraphicsContext::ELeft, 0); + + TRgb rgbs[2]; + gc->MapColors(iRect, rgbs, 1, ETrue); + gc->DiscardBrushPattern(); + + gc->DiscardFont(); + gc->Device()->ReleaseFont(font); + + gc->Deactivate(); + } + +TSize CAnimWindow::Size() + { + return(iCtWin->Size()); + } + +RWindowBase *CAnimWindow::BaseWin() const + { + return(iCtWin->BaseWin()); + } + +CTBaseWin *CAnimWindow::CtBaseWin() + { + return(iCtWin); + } + +void CAnimWindow::Invalidate() + { + CTUser::Splat(TheClient,TRect(iCtWin->Position(),iCtWin->Size()),TRgb::Gray256(0)); + } + +void CAnimWindow::Invalidate(const TRect &aRect) + { + TRect rect(aRect); + rect.Move(iCtWin->Position()); + CTUser::Splat(TheClient,rect,TRgb::Gray256(0)); + } + +void CAnimWindow::DrawTestScreen(CFbsBitmap *aBitmap, CFbsBitmap *aMaskBitmap, CFbsFont *aFont) + { + iCtWin->Gc()->Activate(*(RDrawableWindow *)BaseWin()); + CBitmapContext *gc=iCtWin->Gc(); + TSize size(Size()); + TBool aExtraDrawBitMap=ETrue; +// +#include "DLLDRAW.H" +// + iCtWin->Gc()->Deactivate(); + } + + +__WS_CONSTRUCT_STEP__(AnimDll) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TAUTODLL.H --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TAUTODLL.H Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,162 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef __TAUTODLL_H__ +#define __TAUTODLL_H__ + +#include +#include +#include "../tlib/testbase.h" +#include "AUTO.H" +#include "TGraphicsHarness.h" + + +#include +#include "AUTODLL.H" + +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA +#include "../nonnga/CLIENT/w32comm.h" +#endif + +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA +#include "../nga/CLIENT/w32comm.h" +#endif + +#include "tdirecta.h" + + +class CAnimWindow; + +class CAnimRedrawWindow : public CTWin + { +public: + CAnimRedrawWindow(CAnimWindow *aAnimWindow, TBool aIsBase); + ~CAnimRedrawWindow(); + void Draw(); +private: + CAnimWindow *iAnimWindow; + TBool iIsBase; + }; + +class CAnimWindow : public CBase + { + friend class CTAnimDll; + friend class CAnimRedrawWindow; +public: + enum TWinType + { + ERedraw, + EBlank, + EBackedUp, + }; +public: + CAnimWindow(TBool aIsBase, TWinType aWinType); + ~CAnimWindow(); + void ConstructL(const TPoint &aPos, const TSize &aSize); + void SetRect(const TRect &aRect); + static void Draw(CBitmapContext *aGc, const TSize &aSize, TBool aIsBase,const TRect &aRect, TBool aBlankIt); + static void DrawEllipse(CBitmapContext *aGc, const TRect &aRect); + void DoDraw(TBool aBlankIt=EFalse); + void DoDrawEllipse(); + void DoDrawCoverage(); + TSize Size(); + RWindowBase *BaseWin() const; + CTBaseWin *CtBaseWin(); + void Invalidate(); + void Invalidate(const TRect &aRect); + static void SetEllipseDrawMode(CGraphicsContext::TDrawMode aEllipseDrawMode); + void DrawTestScreen(CFbsBitmap *aBitmap, CFbsBitmap *aMaskBitmap, CFbsFont *aFont); +protected: + CTBaseWin *iCtWin; + TWinType iWinType; + TBool iIsBase; + TRect iRect; + static CGraphicsContext::TDrawMode iEllipseDrawMode; + }; + + + +class CTAnimDll : public CTWsGraphicsBase + { +public: + CTAnimDll(CTestStep* aStep); + ~CTAnimDll(); + void ConstructL(); + + void TestPanicsL(); + void RemoteBuffer(); + void Misc(); + void ExtraCopyTest(); + void SyncMode1(); + void TestSyncModes(MAnimGeneralFunctions::TAnimSync aSyncMode); + void TestTimeChange(); + void TestLoadApiL(); + void KeyClickPriorityL(); +protected: //Pure virtual from MTestCases + void RunTestCaseL(TInt aCurTestCase); +private: + void InvalidatePauseAndRedraw(const TRect &aRect,TTimeIntervalMicroSeconds32 aInterval); + void RedrawAndCheckWindows(TBool aBlankIt=EFalse); + void SetUpMember(TSpriteMember &aMember,TInt aType); + void DrawingTestL(); + void ShadowDrawingTestL(); + void GeneralDrawingTestL(); + void CheckWindows(); + void DestroyWindowTestL(); + void SpriteAnimL(); + void FreeTimerL(); + void DisableTimerL(); + void MultipleAnimsL(); + void ClickPlugInL(); + void WinFunctionsL(); + void WinFunctions2L(); + void TestNotificationsL(); + void TestCoverageL(); + void TestPanicCoverageL(); + void TestWindowInfo(RTestAnim& aAnim,TInt aScreen,TInt aPos,TInt aId); + void TestEventHandlerRemovalL(); + void ParameterValueTestL(); + void TestSetIntervalL(); + TInt CheckError(TInt aError,TInt aExpected); + TRgb PixelColour(const TPoint& aPoint) const; +private: + RAnimDll iAnimDll; + TSize iWinSize; + CAnimWindow *iTestWin; + CAnimWindow *iRedrawWin; + CAnimWindow *iBaseWin; + CAnimWindow *iBackedUpTestWin; + CAnimWindow *iBlankTestWin; + }; + +class CTAnimDllStep : public CTGraphicsStep + { +public: + CTAnimDllStep(); +protected: + //from CTGraphicsStep + virtual CTGraphicsBase* CreateTestL(); + }; + +_LIT(KTAnimDllStep,"TAnimDll"); + + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TAlphaChannel.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TAlphaChannel.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,1936 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// An alpha channel test case. +// Output different graphics primitives in each window using three graphics modes +// for pen and brush : semi-transparent,transparent, opaque +// Test also exercises anti-aliasing and fading for 16MA display mode +// Moves sprite on the window. Tests a sprite functionality. +// Creates RBackedUpWindow window and moves it over transparent window, +// hides and shows it. +// Moves windows on the screen, overlaps them +// Actions: +// Create a background window, and five foreground windows: +// -transparent and semi-transparent +// -transparent with transparency factor +// -not transparent +// +// + +#include "TAlphaChannel.H" + +const TInt KWindowIndention = 2; +const TInt KSizeKoeff = 15; + + +LOCAL_D TPtrC ColumnName[]={ + _L("Opaque"), + _L("Semi-transparent"), + _L("Transparent"), + _L(""), + _L(""), + _L(""), + }; + +LOCAL_D TPtrC RowName[]={ + _L("n"), + _L("and"), + _L("or"), + _L("xor"), + _L(""), + _L(""), + }; + + +// +// +CTAlphaChannel::CTAlphaChannel(CTestStep* aStep): + CTWsGraphicsBase(aStep), iArrWindow(8) + { + } + +CTAlphaChannel::~CTAlphaChannel() + { + delete iBitmap64K_1; + delete iBitmap16MA_1; + delete iBitmap64K_2; + delete iBitmap16MA_2; + delete iBitmap64K_3; + delete iBitmap16MA_3; + + delete iBitmapMask; + delete iBitmapGray256Mask; + + delete iBitmapContext64K_1; + delete iBitmapContext16MA_1; + delete iBitmapContext64K_2; + delete iBitmapContext16MA_2; + delete iBitmapContext64K_3; + delete iBitmapContext16MA_3; + + delete iBitmapDevice64K_1; + delete iBitmapDevice16MA_1; + delete iBitmapDevice64K_2; + delete iBitmapDevice16MA_2; + delete iBitmapDevice64K_3; + delete iBitmapDevice16MA_3; + + delete iBackgroundWindow; + + + iArrWindow.ResetAndDestroy(); + + if(iFont) + TheClient->iScreen->ReleaseFont(iFont); + if(iFont1) + TheClient->iScreen->ReleaseFont(iFont1); + + BaseWin->SetVisible(ETrue); + TestWin->SetVisible(ETrue); + } + +void CTAlphaChannel::ConstructL() + { + const TInt KIndent = 10; + BaseWin->SetVisible(EFalse); + TestWin->SetVisible(EFalse); + + iText = _L("This is a text"); + iBrushStyle = CGraphicsContext::ESolidBrush; + iPenTable = KRgbBlack; + + TSize screenSize=TheClient->iGroup->Size(); + TInt winWidth=(screenSize.iWidth)-KIndent; + TInt winHeight=screenSize.iHeight-KIndent; + TDisplayMode dispMode = EColor64K; + + //background opaque window + iBackgroundWindow = new (ELeave) CTWinAlpha(); + iBackgroundWindow->SetUpL(TPoint(5,5),TSize(winWidth,winHeight),TheClient->iGroup,*TheClient->iGc, &dispMode); + RWindow *theWin = (RWindow*) (iBackgroundWindow->DrawableWin()); + theWin->SetBackgroundColor(TRgb(255, 0, 0)); + iBackgroundWindow->DrawNow(); + + iSizeForegroundWindow.iWidth = (winWidth - KWindowIndention * 4) / 5 ; + iSizeForegroundWindow.iHeight = winHeight; + + CalculateSizePrimitives(iSizeForegroundWindow); + + //-------------create bitmaps + //create 64K bitmap + iBitmap64K_1 = new (ELeave) CFbsBitmap ; + iBitmap64K_1->Create(iBitmapSize,EColor64K); + iBitmap64K_2 = new (ELeave) CFbsBitmap ; + iBitmap64K_2->Create(iBitmapSize,EColor64K); + iBitmap64K_3 = new (ELeave) CFbsBitmap ; + iBitmap64K_3->Create(iBitmapSize,EColor64K); + iBitmapDevice64K_1 = CFbsBitmapDevice::NewL(iBitmap64K_1); + iBitmapDevice64K_1->CreateContext(iBitmapContext64K_1); + iBitmapDevice64K_2 = CFbsBitmapDevice::NewL(iBitmap64K_2); + iBitmapDevice64K_2->CreateContext(iBitmapContext64K_2); + iBitmapDevice64K_3 = CFbsBitmapDevice::NewL(iBitmap64K_3); + iBitmapDevice64K_3->CreateContext(iBitmapContext64K_3); + + //create 16MA bitmap + iBitmap16MA_1 = new (ELeave) CFbsBitmap ; + iBitmap16MA_1->Create(iBitmapSize, EColor16MA); + iBitmap16MA_2 = new (ELeave) CFbsBitmap ; + iBitmap16MA_2->Create(iBitmapSize, EColor16MA); + iBitmap16MA_3 = new (ELeave) CFbsBitmap ; + iBitmap16MA_3->Create(iBitmapSize, EColor16MA); + + iBitmapDevice16MA_1 = CFbsBitmapDevice::NewL(iBitmap16MA_1); + iBitmapDevice16MA_1->CreateContext(iBitmapContext16MA_1); + iBitmapDevice16MA_2 = CFbsBitmapDevice::NewL(iBitmap16MA_2); + iBitmapDevice16MA_2->CreateContext(iBitmapContext16MA_2); + iBitmapDevice16MA_3 = CFbsBitmapDevice::NewL(iBitmap16MA_3); + iBitmapDevice16MA_3->CreateContext(iBitmapContext16MA_3); + + //create mask bitmap + iBitmapMask = new (ELeave) CFbsBitmap ; + iBitmapMask->Create(iBitmapSize, EGray2); + + CFbsBitmapDevice* theBitmapDevice = CFbsBitmapDevice::NewL(iBitmapMask); + CGraphicsContext* theBitmapContext = NULL; + theBitmapDevice->CreateContext(theBitmapContext); + TRect rect = TRect(iBitmapMask->SizeInPixels()); + theBitmapContext->SetBrushColor(KRgbWhite); + theBitmapContext->SetPenColor(KRgbWhite); + theBitmapContext->SetBrushStyle(CGraphicsContext::ESolidBrush); + theBitmapContext->DrawRect(rect); + + rect.Shrink(4, 4); + theBitmapContext->SetBrushColor(KRgbBlack); + theBitmapContext->SetPenColor(KRgbBlack); + theBitmapContext->DrawEllipse(rect); + delete theBitmapContext; + delete theBitmapDevice; + + //create 256gray bitmap mask + iBitmapGray256Mask = new (ELeave) CFbsBitmap; + iBitmapGray256Mask->Create(iBitmapSize, EGray256); + theBitmapDevice = CFbsBitmapDevice::NewL(iBitmapGray256Mask); + theBitmapDevice->CreateContext(theBitmapContext); + + if(iBitmapSize != TSize(0, 0)) + { + //fill bitmap with 256 gradation of gray + TInt theStep = 256 / iBitmapGray256Mask->SizeInPixels().iWidth; + + for(TInt ii = 0; ii < iBitmapGray256Mask->SizeInPixels().iWidth; ii++) + { + TInt theSingleCol = theStep * ii; + TRgb theCol(theSingleCol, theSingleCol, theSingleCol); + theBitmapContext->SetBrushColor(theCol); + theBitmapContext->SetPenColor(theCol); + TPoint ptFrom(ii, 0); + TPoint ptTo(ii, iBitmapGray256Mask->SizeInPixels().iHeight); + theBitmapContext->DrawLine(ptFrom, ptTo); + } + } + delete theBitmapContext; + delete theBitmapDevice; + //-------------- + TFontSpec fontSpec(KTestFontTypefaceName,600); + + fontSpec.iFontStyle.SetStrokeWeight(EStrokeWeightBold); + fontSpec.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap); + + User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips(iFont, fontSpec)); + + TFontSpec fontSpec1(KTestFontTypefaceName,100); + User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips(iFont1, fontSpec1)); + } + +void CTAlphaChannel::CalculateSizePrimitives(const TSize& aSize) + { + TInt theLen = aSize.iWidth / KSizeKoeff; + + iBitmapSize = TSize(2 * theLen, 2 * theLen); + iRectangleSize = TSize(2 * theLen, 2 * theLen); + iEllipseSize = TSize(4 * theLen, 2 * theLen); + iTriangleSize = TSize(3 * theLen, 2 * theLen); + iFirstCellWidth = static_cast (1.2 * theLen); + iFirstCellHeight = static_cast (1.5 * theLen); + } + +void CTAlphaChannel::DrawOffscreenBitmapsL(const TRgb& /*aPen*/, const TRgb& aBrush, + CGraphicsContext* aBitmapContext64K, CGraphicsContext* aBitmapContext16MA, + CFbsBitmap* aBitmap64K, CFbsBitmap* aBitmap16MA) + { + + if(aBitmapContext64K && aBitmap64K) + { + SEpocBitmapHeader header = aBitmap64K->Header(); + TInt source_buffer_size = header.iBitmapSize / header.iSizeInPixels.iHeight * header.iBitsPerPixel ; + TUint8* buffer = new(ELeave) TUint8[source_buffer_size]; + TPtr8 source_ptr(buffer, source_buffer_size, source_buffer_size); + + TUint16* bufferCur = reinterpret_cast (buffer); + TInt ii; + for(ii = 0; ii < header.iSizeInPixels.iWidth; ++ii) + { + *bufferCur = aBrush._Color64K(); + bufferCur ++; + } + + for(ii = 0; ii < header.iSizeInPixels.iHeight; ++ii) + { + aBitmap64K -> SetScanLine(source_ptr, ii); + } + + delete [] buffer; + } + + if(aBitmapContext16MA && aBitmap16MA) + { + SEpocBitmapHeader header = aBitmap16MA -> Header(); + TInt source_buffer_size = header.iBitmapSize / header.iSizeInPixels.iHeight * header.iBitsPerPixel ; + TUint8* buffer = new(ELeave) TUint8[source_buffer_size]; + TPtr8 source_ptr(buffer, source_buffer_size, source_buffer_size); + + TUint32* bufferCur = reinterpret_cast (buffer); + TInt ii; + for(ii = 0; ii < header.iSizeInPixels.iWidth; ++ii) + { + *bufferCur = aBrush._Color16MA(); + bufferCur ++; + } + + for(ii = 0; ii < header.iSizeInPixels.iHeight; ++ii) + { + aBitmap16MA -> SetScanLine(source_ptr, ii); + } + + delete [] buffer; + } + + } + +enum {EOpaque, ESemiTrans, ETrans}; + +TRgb CTAlphaChannel::GetBrush(TInt aIndex) const + { + switch(aIndex) + { + case EOpaque: + return TRgb(0, 0, 255, 255); + case ESemiTrans: + return TRgb(0, 0, 255, 128); + case ETrans: + return TRgb(0, 0, 255, 0); + default : break; + } + + return TRgb(0, 0, 255, 255); + } + +TRgb CTAlphaChannel::GetPen(TInt aIndex) const + { + switch(aIndex) + { + case EOpaque: + return TRgb(0, 0, 255, 255); + case ESemiTrans: + return TRgb(0, 0, 255, 128); + case ETrans: + return TRgb(0, 0, 255, 0); + default : break; + } + + return TRgb(0, 0, 255, 255); + } + +CGraphicsContext::TDrawMode CTAlphaChannel::GetDrawMode(TInt /*aIndex*/) const + { + return CGraphicsContext::EDrawModePEN; + } + +enum {EAll64K, EAll16MA, EAllDifferent};// later may add EAll16M +void CTAlphaChannel::SetDisplayModeConfiguration(TInt aConfig) + { + switch (aConfig) + { + case EAll64K: + if(iForegroundWindowOpaque) + iForegroundWindowOpaque->SetDisplayMode(EColor64K); + if(iForegroundWindowSemiTrans) + iForegroundWindowSemiTrans->SetDisplayMode(EColor64K); + if(iForegroundWindowTrans) + iForegroundWindowTrans->SetDisplayMode(EColor64K); + break; + case EAll16MA: + if(iForegroundWindowOpaque) + iForegroundWindowOpaque->SetDisplayMode(EColor16MA); + if(iForegroundWindowSemiTrans) + iForegroundWindowSemiTrans->SetDisplayMode(EColor16MA); + if(iForegroundWindowTrans) + iForegroundWindowTrans->SetDisplayMode(EColor16MA); + break; + case EAllDifferent: + if(iForegroundWindowOpaque) + iForegroundWindowOpaque->SetDisplayMode(EColor256); + if(iForegroundWindowSemiTrans) + iForegroundWindowSemiTrans->SetDisplayMode(EColor64K); + if(iForegroundWindowTrans) + iForegroundWindowTrans->SetDisplayMode(EColor16MA); + break; + } + } + +enum {ETiled, EOverlapping}; + +void CTAlphaChannel::SetPositionConfiguration(TInt aConfig) + { + TSize screenSize=TheClient->iGroup->Size(); + TInt winWidth=(screenSize.iWidth)-10; + TInt winHeight=screenSize.iHeight-10; + if (aConfig==ETiled) + { + if(iForegroundWindowOpaque) + iForegroundWindowOpaque->SetPos(TPoint(winWidth/5, 0)); + if(iForegroundWindowSemiTrans) + iForegroundWindowSemiTrans->SetPos(TPoint(2*winWidth/5, 0)); + if(iForegroundWindowTrans) + iForegroundWindowTrans->SetPos(TPoint(3*winWidth/5, 0)); + } + else + { + if(iForegroundWindowOpaque) + iForegroundWindowOpaque->SetPos(TPoint(winWidth/3, -winHeight/3)); + if(iForegroundWindowSemiTrans) + iForegroundWindowSemiTrans->SetPos(TPoint(2*winWidth/5, winHeight/3)); + if(iForegroundWindowTrans) + iForegroundWindowTrans->SetPos(TPoint(winWidth/2, -winHeight/3)); + } + if (iForegroundWindowBottom) + iForegroundWindowBottom->SetPos(TPoint(0, 0)); + if (iForegroundWindowTop) + iForegroundWindowTop->SetPos(TPoint(4*winWidth/5, 0)); + } + +enum {EVaryingTransparency, EVaryingColour}; + +void CTAlphaChannel::SetColourConfiguration(TInt aConfig) + { + RWindow* win; + if (aConfig==EVaryingTransparency) + { + // red background, green foregrounds of varying transparency + win = (RWindow*)(iBackgroundWindow->DrawableWin()); + win->SetBackgroundColor(TRgb(255,0,0,255)); + + if(iForegroundWindowOpaque) + iForegroundWindowOpaque->SetBackgroundColor(TRgb(0,255,0,255)); + if(iForegroundWindowSemiTrans) + iForegroundWindowSemiTrans->SetBackgroundColor(TRgb(0,255,0,128)); + if(iForegroundWindowTrans) + iForegroundWindowTrans->SetBackgroundColor(TRgb(0,255,0,0)); + } + else + { + // white background, semi-transparent foregrounds in primary colours + win = (RWindow*)(iBackgroundWindow->DrawableWin()); + win->SetBackgroundColor(TRgb(255,255,255,255)); + + if(iForegroundWindowOpaque) + iForegroundWindowOpaque->SetBackgroundColor(TRgb(255,0,0,128)); + if(iForegroundWindowSemiTrans) + iForegroundWindowSemiTrans->SetBackgroundColor(TRgb(0,255,0,128)); + if(iForegroundWindowTrans) + iForegroundWindowTrans->SetBackgroundColor(TRgb(0,0,255,128)); + } + } + +void CTAlphaChannel::DoMoving() + { + TPoint pos; + for (TInt i = 0; i<20; i++) + { + if (iForegroundWindowBottom) + { + pos = iForegroundWindowBottom->Position(); + pos += TPoint(1,5); + iForegroundWindowBottom->SetPos(pos); + } + + if (iForegroundWindowOpaque) + { + pos = iForegroundWindowOpaque->Position(); + pos += TPoint(1,5); + iForegroundWindowOpaque->SetPos(pos); + } + + if (iForegroundWindowSemiTrans) + { + pos = iForegroundWindowSemiTrans->Position(); + pos += TPoint(1,5); + iForegroundWindowSemiTrans->SetPos(pos); + } + + if (iForegroundWindowTrans) + { + pos = iForegroundWindowTrans->Position(); + pos += TPoint(1,5); + iForegroundWindowTrans->SetPos(pos); + } + + if (iForegroundWindowTop) + { + pos = iForegroundWindowTop->Position(); + pos += TPoint(1,5); + iForegroundWindowTop->SetPos(pos); + } + + TheClient->iWs.Flush(); + User::After(TTimeIntervalMicroSeconds32(50000)); + } + + } + +void CTAlphaChannel::DoMoveBehind() + { + TPoint pos = iBackgroundWindow->Position(); + for (TInt i = 0; i<20; i++) + { + pos += TPoint(0,5); + iBackgroundWindow->SetPos(pos); + + TheClient->iWs.Flush(); + User::After(TTimeIntervalMicroSeconds32(50000)); + } + iBackgroundWindow->SetPos(TPoint(5,5)); + } + +void CTAlphaChannel::DoInvisibility() + { + RWindow* win; + if (iForegroundWindowBottom) + { + win = (RWindow*)(iForegroundWindowBottom->DrawableWin()); + win->SetVisible(EFalse); + TheClient->iWs.Flush(); + User::After(TTimeIntervalMicroSeconds32(1000000)); + + win->SetVisible(ETrue); + TheClient->iWs.Flush(); + User::After(TTimeIntervalMicroSeconds32(1000000)); + } + if (iForegroundWindowOpaque) + { + win = (RWindow*)(iForegroundWindowOpaque->DrawableWin()); + win->SetVisible(EFalse); + TheClient->iWs.Flush(); + User::After(TTimeIntervalMicroSeconds32(1000000)); + + win->SetVisible(ETrue); + TheClient->iWs.Flush(); + User::After(TTimeIntervalMicroSeconds32(1000000)); + } + if (iForegroundWindowSemiTrans) + { + win = (RWindow*)(iForegroundWindowSemiTrans->DrawableWin()); + win->SetVisible(EFalse); + TheClient->iWs.Flush(); + User::After(TTimeIntervalMicroSeconds32(1000000)); + + win->SetVisible(ETrue); + TheClient->iWs.Flush(); + User::After(TTimeIntervalMicroSeconds32(1000000)); + } + if (iForegroundWindowTrans) + { + win = (RWindow*)(iForegroundWindowTrans->DrawableWin()); + win->SetVisible(EFalse); + TheClient->iWs.Flush(); + User::After(TTimeIntervalMicroSeconds32(1000000)); + + win->SetVisible(ETrue); + TheClient->iWs.Flush(); + User::After(TTimeIntervalMicroSeconds32(1000000)); + } + if (iForegroundWindowTop) + { + win = (RWindow*)(iForegroundWindowTop->DrawableWin()); + win->SetVisible(EFalse); + TheClient->iWs.Flush(); + User::After(TTimeIntervalMicroSeconds32(1000000)); + + win->SetVisible(ETrue); + TheClient->iWs.Flush(); + User::After(TTimeIntervalMicroSeconds32(1000000)); + } + } + +/** + @SYMTestCaseID GRAPHICS-WSERV-0328 + + @SYMTestCaseDesc Testing a Fading. + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions + Set fading parameters. Draw all graphics primitives and bitmaps with + various transparency . + + @SYMTestExpectedResults + All windows should be drawn according their fading values. + */ + +void CTAlphaChannel::TestFading() + { + iIsFading = ETrue; + iBlackFading = 0; + iWhiteFading = 128; + iText.Format(_L("Fading. %dX%d"), iBlackFading, iWhiteFading); + INFO_PRINTF1(iText); + DrawTestWindowsNow(); + + User::After(TTimeIntervalMicroSeconds32(1000000 * 1)); + iIsFading = EFalse; + DrawTestWindowsNow(); + iIsFading = ETrue; + iBlackFading = 128; + iWhiteFading = 255; + iText.Format(_L("Fading. %dX%d"), iBlackFading, iWhiteFading); + INFO_PRINTF1(iText); + DrawTestWindowsNow(); + + iIsFading = EFalse; + } + +/** + @SYMTestCaseID GRAPHICS-WSERV-0329 + + @SYMTestCaseDesc Tests moving of foreground windows. + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions + Set fading parameters. Set position of foreground windows as tile . + + @SYMTestExpectedResults + Foreground window has to be redrawn properly. + */ + +void CTAlphaChannel::TestMoving() + { + SetPositionConfiguration(ETiled); + DoMoving(); + SetPositionConfiguration(ETiled); + } + +/** + @SYMTestCaseID GRAPHICS-WSERV-0330 + + @SYMTestCaseDesc Tests moving of foreground windows. + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions + Set fading parameters. Moves foreground windows over the screen . + + @SYMTestExpectedResults + Foreground window has to be redrawn properly. + */ + + +void CTAlphaChannel::TestMovingOverlapping() + { + TPoint pos; + + for (TInt i = 0; i < 20; i++) + { + if (iForegroundWindowOpaque) + { + pos = iForegroundWindowOpaque->Position(); + pos += TPoint(3,0); + iForegroundWindowOpaque->SetPos(pos); + } + if (iForegroundWindowTrans) + { + pos = iForegroundWindowTrans->Position(); + pos -= TPoint(3,0); + iForegroundWindowTrans->SetPos(pos); + } + TheClient->iWs.Flush(); + User::After(TTimeIntervalMicroSeconds32(50000)); + } + } + +/** + @SYMTestCaseID GRAPHICS-WSERV-0331 + + @SYMTestCaseDesc Testing transparency factor for windows with alpha channel. + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions + Sets background colour with various level of transparency . + + @SYMTestExpectedResults + Foreground window must be redrawn properly. + */ +void CTAlphaChannel::TestChangingTransparencyFactor() + { + TInt i = 0; + while (i <= 255) + { + iForegroundWindowOpaque->SetBackgroundColor(TRgb(0,255,0,255-i)); + iForegroundWindowTrans->SetBackgroundColor(TRgb(0,255,0,i)); + iForegroundWindowOpaque->DrawNow(); + iForegroundWindowTrans->DrawNow(); + i+=15; + } + i=0; + while (i <= 255) + { + iForegroundWindowOpaque->SetBackgroundColor(TRgb(0,255,0,i)); + iForegroundWindowTrans->SetBackgroundColor(TRgb(0,255,0,255-i)); + iForegroundWindowOpaque->DrawNow(); + iForegroundWindowTrans->DrawNow(); + User::After(TTimeIntervalMicroSeconds32(50000));// 20 frames per second + i+=15; + } + } + +/** + @SYMTestCaseID GRAPHICS-WSERV-0332 + + @SYMTestCaseDesc Testing redrawing of foreground windows while their positions and + invisibility have been changed. + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions + Sets position of the foreground windows as overlapping, tiled. + Change visability of semi transparent foreground window. . + + @SYMTestExpectedResults + Foreground window must be redrawn properly. + */ + +void CTAlphaChannel::TestInvisibility() + { + RWindow* win = (RWindow*)(iForegroundWindowSemiTrans->DrawableWin()); + SetPositionConfiguration(EOverlapping); + TheClient->iWs.Flush(); + User::After(TTimeIntervalMicroSeconds32(1000000)); + + win->SetVisible(EFalse); + TheClient->iWs.Flush(); + User::After(TTimeIntervalMicroSeconds32(1000000)); + + win->SetVisible(ETrue); + TheClient->iWs.Flush(); + User::After(TTimeIntervalMicroSeconds32(1000000)); + + SetPositionConfiguration(ETiled); + + } + +/** + @SYMTestCaseID GRAPHICS-WSERV-0333 + + @SYMTestCaseDesc Testing redrawing of foreground windows after a + background window has been moved. + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions + Sets position of the foreground windows as tiled. + Moves background window. + + @SYMTestExpectedResults + Foreground windows must be redrawn properly. + */ +void CTAlphaChannel::TestMoveUnderneath() + { + SetPositionConfiguration(ETiled); + DoMoveBehind(); + } +/** + @SYMTestCaseID GRAPHICS-WSERV-0334 + + @SYMTestCaseDesc Testing redrawing of foreground windows after a + background window has been moved. + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions + Sets different position of the foreground windows: tiled, overlapping. + Moves background window. + + @SYMTestExpectedResults + Foreground windows has to be redrawn properly. + */ + +void CTAlphaChannel::TestMoveBehindInvisible() + { + SetPositionConfiguration(ETiled); + RWindow* win; + win = (RWindow*)(iForegroundWindowOpaque->DrawableWin()); + win->SetVisible(EFalse); + win = (RWindow*)(iForegroundWindowSemiTrans->DrawableWin()); + win->SetVisible(EFalse); + win = (RWindow*)(iForegroundWindowTrans->DrawableWin()); + win->SetVisible(EFalse); + TheClient->iWs.Flush(); + + DoMoveBehind(); + + SetPositionConfiguration(EOverlapping); + DoMoveBehind(); + + win = (RWindow*)(iForegroundWindowOpaque->DrawableWin()); + win->SetVisible(ETrue); + win = (RWindow*)(iForegroundWindowSemiTrans->DrawableWin()); + win->SetVisible(ETrue); + win = (RWindow*)(iForegroundWindowTrans->DrawableWin()); + win->SetVisible(ETrue); + TheClient->iWs.Flush(); + } +/** + @SYMTestCaseID GRAPHICS-WSERV-0335 + + @SYMTestCaseDesc Testing redrawing of foreground windows. + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions + Redraws background window + + @SYMTestExpectedResults + Foreground windows should be redrawn properly, if background window + has been redrawn. + */ +void CTAlphaChannel::TestRedrawBehind() + { + TheClient->iWs.Flush(); + iBackgroundWindow->iState += 1; + iBackgroundWindow->DrawNow(); + TheClient->iWs.Flush(); + User::After(TTimeIntervalMicroSeconds32(1000000)); + } +/** + @SYMTestCaseID GRAPHICS-WSERV-0336 + + @SYMTestCaseDesc Testing transparency with RWsSprite class. + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions + Creates RBackedUpWindow window and moves it over transparent window + appears and dissapears set up window as transparent + + @SYMTestExpectedResults + Must work with transparent windows. + */ + +void CTAlphaChannel::TestAnimationL() + { + for(TInt ii = 0; ii < iArrWindow.Count(); ii++) + { + iArrWindow[ii]->StartAnimationL(); + } + } +/** + @SYMTestCaseID GRAPHICS-WSERV-0337 + + @SYMTestCaseDesc Testing transparency with RBackedUpWindow window class. + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions + Creates RBackedUpWindow window and moves it over transparent window + appears and dissapears set up transparent window as transparent + + @SYMTestExpectedResults + Do not expect correct work of alpha channel with + RBackedUpWindow window class. +*/ +void CTAlphaChannel::TestBackedWindowL() + { + for(TInt ii = 0; ii < iArrWindow.Count(); ii++) + { + iArrWindow[ii]->CreateBackedWindowL(); + } + } + +/** + @SYMTestCaseID GRAPHICS-WSERV-0338 + + @SYMTestCaseDesc Implication of setting SetDrawOpaque on drawing with alpha channel. + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions + Change graphic context to opaque and none opaque and rewdraw all test windows + + @SYMTestExpectedResults + must not impact on output with alpha channel + */ + +void CTAlphaChannel::TestEffectSetOpaque() + { + for(TInt ii = 0; ii < 3; ii++) + { + + for(TInt ii = 0; ii < iArrWindow.Count(); ii++) + { + iArrWindow[ii]->SetDrawOpaque(EFalse); + } + + DrawTestWindowsNow(); + User::After(TTimeIntervalMicroSeconds32(1000000)); + + for(TInt jj = 0; jj < iArrWindow.Count(); jj++) + { + iArrWindow[jj]->SetDrawOpaque(ETrue); + } + + DrawTestWindowsNow(); + User::After(TTimeIntervalMicroSeconds32(1000000)); + } + } + +/** + @SYMTestCaseID GRAPHICS-WSERV-0339 + + @SYMTestCaseDesc Redrawing of child windows with transparency. + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions + Creates a few child windows with various levels of transparency. + Moves parent window over the screen. + @SYMTestExpectedResults + Child and parent windows must be redrawn properly + */ + +void CTAlphaChannel::TestChildWindowL() + { + SetPositionConfiguration(ETiled); + SetColourConfiguration(EVaryingColour); + DrawTestWindowsNow(ETrue); + TDisplayMode mode = EColor64K; + CTWinAlphaForeground* childWin[] = {NULL, NULL, NULL, NULL, NULL}; + if (iForegroundWindowBottom) + { + childWin[0] = CTWinAlphaForeground::NewL(*this, TPoint(0,0),TSize(50,50),iForegroundWindowBottom,*TheClient->iGc, &mode, TRgb(0, 255, 0,128), ENonTransparentAlpha); + childWin[0]->DrawNow(); + } + if (iForegroundWindowOpaque) + { + childWin[1] = CTWinAlphaForeground::NewL(*this, TPoint(0,0),TSize(50,50),iForegroundWindowOpaque,*TheClient->iGc, &mode, TRgb(0, 255, 0,128), ETransparencyFactor); + childWin[1]->DrawNow(); + } + if (iForegroundWindowSemiTrans) + { + childWin[2] = CTWinAlphaForeground::NewL(*this, TPoint(0,0),TSize(50,50),iForegroundWindowSemiTrans,*TheClient->iGc, &mode, TRgb(0, 255, 0,128), ETransparencyAlpha); + childWin[2]->DrawNow(); + } + if (iForegroundWindowTrans) + { + childWin[3] = CTWinAlphaForeground::NewL(*this, TPoint(0,0),TSize(50,50),iForegroundWindowTrans,*TheClient->iGc, &mode, TRgb(0, 255, 0,128), ENonTransparentAlpha); + childWin[3]->DrawNow(); + } + if (iForegroundWindowTop) + { + childWin[4] = CTWinAlphaForeground::NewL(*this, TPoint(0,0),TSize(50,50),iForegroundWindowTop,*TheClient->iGc, &mode, TRgb(0, 255, 0,128), ENonTransparentAlpha); + childWin[4]->DrawNow(); + } + TheClient->iWs.Flush(); + + User::After(TTimeIntervalMicroSeconds32(1000000)); + DoMoving(); + + delete childWin[0]; + delete childWin[1]; + delete childWin[2]; + delete childWin[3]; + delete childWin[4]; + } +/** + @SYMTestCaseID GRAPHICS-WSERV-0340 + + @SYMTestCaseDesc Redrawing of multiple child windows with transparency. + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions + Creates multiple child windows with various levels of transparency. + Moves parent windows over the screen. + @SYMTestExpectedResults + Child and parent windows must be redrawn properly + */ + +void CTAlphaChannel::TestMultipleChildrenL() + { + SetPositionConfiguration(ETiled); + SetColourConfiguration(EVaryingColour); + TDisplayMode mode = EColor64K; + CTWinAlphaForeground* childWin[] = {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}; + if (iForegroundWindowBottom) + { + childWin[0] = CTWinAlphaForeground::NewL(*this, TPoint(0,0),TSize(50,50),iForegroundWindowBottom,*TheClient->iGc, &mode, TRgb(255, 255, 255,128), ETransparencyFactor); + childWin[1] = CTWinAlphaForeground::NewL(*this, TPoint(20,20),TSize(50,50),childWin[0],*TheClient->iGc, &mode, TRgb(255, 255, 255,128), ENonTransparentAlpha); + childWin[0]->DrawNow(); + childWin[1]->DrawNow(); + } + if (iForegroundWindowOpaque) + { + childWin[4] = CTWinAlphaForeground::NewL(*this, TPoint(0,0),TSize(100,100),iForegroundWindowOpaque,*TheClient->iGc, &mode, TRgb(255, 255, 255,128), ETransparencyAlpha); + childWin[5] = CTWinAlphaForeground::NewL(*this, TPoint(20,80),TSize(50,50),iForegroundWindowOpaque,*TheClient->iGc, &mode, TRgb(255, 255, 255,128), ENonTransparentAlpha); + childWin[6] = CTWinAlphaForeground::NewL(*this, TPoint(20,20),TSize(60,60),childWin[4],*TheClient->iGc, &mode, TRgb(0, 255, 0,128), ENonTransparentAlpha); + childWin[7] = CTWinAlphaForeground::NewL(*this, TPoint(20,20),TSize(50,50),childWin[6],*TheClient->iGc, &mode, TRgb(0, 255, 0,128), ENonTransparentAlpha); + childWin[4]->DrawNow(); + childWin[5]->DrawNow(); + childWin[6]->DrawNow(); + childWin[7]->DrawNow(); + } + DrawTestWindowsNow(ETrue); + + TestMoving(); + + delete childWin[0]; + delete childWin[1]; + delete childWin[2]; + delete childWin[3]; + delete childWin[4]; + delete childWin[5]; + delete childWin[6]; + delete childWin[7]; + } + +/** + @SYMTestCaseID GRAPHICS-WSERV-0341 + + @SYMTestCaseDesc Test transparent window which positioned under opaque. + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions + Creates an opaque window on the topt of transparent windows. + Moves transparent windows over the screen. + @SYMTestExpectedResults + Transparent windows must be redrawn properly + */ + +void CTAlphaChannel::TestTransparentMovingUnderOpaqueL() + { + SetColourConfiguration(EVaryingColour); + TDisplayMode mode = EColor64K; + CTWinAlphaForeground* win = CTWinAlphaForeground::NewL(*this, TPoint(0,100),TSize(600,40),TheClient->iGroup,*TheClient->iGc, &mode, TRgb(0, 255, 0,128), ENonTransparentAlpha); + win->DrawNow(); + + TestMoving(); + + delete win; + } +/** + @SYMTestCaseID GRAPHICS-WSERV-0342 + + @SYMTestCaseDesc Changing orinary position of the foreground windows. + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions + Set ordinal position of foreground windows. + @SYMTestExpectedResults + Foreground windows must be redrawn properly + */ + +void CTAlphaChannel::TestSetOrdinalPosition() + { + SetColourConfiguration(EVaryingColour); + SetPositionConfiguration(EOverlapping); + DrawTestWindowsNow(ETrue); + TheClient->iWs.Flush(); + User::After(TTimeIntervalMicroSeconds32(1000000)); + RWindow* win; + for (TInt i=0; i<3; i++) + { + if (iForegroundWindowOpaque) + { + win = (RWindow*)(iForegroundWindowOpaque->DrawableWin()); + win->SetOrdinalPosition(0); + TheClient->iWs.Flush(); + User::After(TTimeIntervalMicroSeconds32(1000000)); + } + if (iForegroundWindowSemiTrans) + { + win = (RWindow*)(iForegroundWindowSemiTrans->DrawableWin()); + win->SetOrdinalPosition(0); + TheClient->iWs.Flush(); + User::After(TTimeIntervalMicroSeconds32(1000000)); + } + if (iForegroundWindowTrans) + { + win = (RWindow*)(iForegroundWindowTrans->DrawableWin()); + win->SetOrdinalPosition(0); + TheClient->iWs.Flush(); + User::After(TTimeIntervalMicroSeconds32(1000000)); + } + } + } + +void CTAlphaChannel::RunTestCaseL(TInt aCurTestCase) + { + User::After(TTimeIntervalMicroSeconds32(1000000 * 2)); + + ((CTAlphaChannelStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); + switch (aCurTestCase) + { + case 1: + ((CTAlphaChannelStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + CreateForegroundWindowsL(iSizeForegroundWindow, EColor16MU); + break; + case 2: + { + CreateForegroundWindowsL(iSizeForegroundWindow, EColor64K); + ((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0339")); + TestChildWindowL(); + ((CTAlphaChannelStep*)iStep)->RecordTestResultL(); + ((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0340")); + TestMultipleChildrenL(); + ((CTAlphaChannelStep*)iStep)->RecordTestResultL(); + ((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0342")); + TestSetOrdinalPosition(); + } + break; + case 3: + ((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0336")); + TestAnimationL(); + case 4: + ((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0337")); + TestBackedWindowL(); + break; + case 5: + ((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0338")); + TestEffectSetOpaque(); + break; + case 6: + ((CTAlphaChannelStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + iIsFading = EFalse; + DrawTestWindowsNow(); + INFO_PRINTF1(_L("Anti-aliasing")); + iIsFading = EFalse; + iDrawText = ETrue; + DrawTestWindowsNow(); + break; + case 7: + SetColourConfiguration(EVaryingColour); + SetPositionConfiguration(EOverlapping); + ((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0335")); + TestRedrawBehind(); + ((CTAlphaChannelStep*)iStep)->RecordTestResultL(); + ((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0329")); + TestMoving(); + ((CTAlphaChannelStep*)iStep)->RecordTestResultL(); + ((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0330")); + TestMovingOverlapping(); + ((CTAlphaChannelStep*)iStep)->RecordTestResultL(); + ((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0341")); + TestMoveBehindInvisible(); + ((CTAlphaChannelStep*)iStep)->RecordTestResultL(); + ((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0334")); + TestTransparentMovingUnderOpaqueL(); + ((CTAlphaChannelStep*)iStep)->RecordTestResultL(); + ((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0331")); + TestInvisibility(); + ((CTAlphaChannelStep*)iStep)->RecordTestResultL(); + ((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0332")); + TestChangingTransparencyFactor(); + break; + case 8: + ((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0328")); + TestFading(); + break; + case 9: + { + ((CTAlphaChannelStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + iDrawText = EFalse; + SetDisplayModeConfiguration(EAll16MA); + } + break; + case 10: + ((CTAlphaChannelStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + iIsFading = EFalse; + DrawTestWindowsNow(); + INFO_PRINTF1(_L("Anti-aliasing")); + iIsFading = EFalse; + iDrawText = ETrue; + DrawTestWindowsNow(); + break; + case 11: + SetColourConfiguration(EVaryingColour); + SetPositionConfiguration(EOverlapping); + ((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0333")); + TestMoveUnderneath(); + ((CTAlphaChannelStep*)iStep)->RecordTestResultL(); + ((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0335")); + TestRedrawBehind(); + ((CTAlphaChannelStep*)iStep)->RecordTestResultL(); + ((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0329")); + TestMoving(); + ((CTAlphaChannelStep*)iStep)->RecordTestResultL(); + ((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0332")); + TestInvisibility(); + ((CTAlphaChannelStep*)iStep)->RecordTestResultL(); + ((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0331")); + TestChangingTransparencyFactor(); + break; + case 12: + ((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0328")); + TestFading(); + break; + case 13: + SetDisplayModeConfiguration(EAllDifferent); + SetColourConfiguration(EVaryingColour); + ((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0333")); + TestMoveUnderneath(); + ((CTAlphaChannelStep*)iStep)->RecordTestResultL(); + ((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0335")); + TestRedrawBehind(); + ((CTAlphaChannelStep*)iStep)->RecordTestResultL(); + ((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0332")); + TestInvisibility(); + ((CTAlphaChannelStep*)iStep)->RecordTestResultL(); + ((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0329")); + TestMoving(); + break; + case 14: + ((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0336")); + TestAnimationL(); + break; + case 15: + ((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0337")); + TestBackedWindowL(); + break; + case 16: + ((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0338")); + TestEffectSetOpaque(); + break; + case 17: + ((CTAlphaChannelStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + ((CTAlphaChannelStep*)iStep)->CloseTMSGraphicsStep(); + TestComplete(); + break; + } + ((CTAlphaChannelStep*)iStep)->RecordTestResultL(); + } + +/** Calculate foreground windows margin and create them*/ +void CTAlphaChannel::CreateForegroundWindowsL(const TSize& aSize, TDisplayMode aMode) + { + TPoint pt = TPoint(5, 5); + + //creating foreground windows + //bottom window + TDisplayMode dispMode = aMode; + iForegroundWindowBottom = CTWinAlphaForeground::NewL(*this, pt,aSize,TheClient->iGroup,*TheClient->iGc, &dispMode, TRgb(0, 255, 0,128), ETransparencyFactor); + iArrWindow.AppendL( iForegroundWindowBottom); + + //dispMode = EColor16MA; + pt.iX += aSize.iWidth + KWindowIndention; + //opaque window + iForegroundWindowOpaque = CTWinAlphaForeground::NewL(*this, pt,aSize,TheClient->iGroup,*TheClient->iGc, &dispMode, TRgb(0, 255, 0, 255), ETransparencyAlpha); + iArrWindow.AppendL( iForegroundWindowOpaque); + + pt.iX += aSize.iWidth + KWindowIndention; + //semi-transparent window + iForegroundWindowSemiTrans = CTWinAlphaForeground::NewL(*this, pt,aSize,TheClient->iGroup,*TheClient->iGc, &dispMode, TRgb(0, 255, 0, 128), ETransparencyAlpha); + iArrWindow.AppendL( iForegroundWindowSemiTrans); + + //transparent window + pt.iX += aSize.iWidth + KWindowIndention; + iForegroundWindowTrans = CTWinAlphaForeground::NewL(*this, pt,aSize,TheClient->iGroup,*TheClient->iGc, &dispMode, TRgb(0, 255, 0, 0), ETransparencyAlpha); + iArrWindow.AppendL( iForegroundWindowTrans); + + // top window + pt.iX += aSize.iWidth + KWindowIndention; + iForegroundWindowTop = CTWinAlphaForeground::NewL(*this, pt,aSize,TheClient->iGroup,*TheClient->iGc, &dispMode, TRgb(0, 255, 0,128), ENonTransparentAlpha); + iArrWindow.AppendL( iForegroundWindowTop); + } + +void CTAlphaChannel::DestroyForegroundWindows() + { + iArrWindow.ResetAndDestroy(); + iForegroundWindowBottom = NULL; + iForegroundWindowOpaque = NULL; + iForegroundWindowSemiTrans = NULL; + iForegroundWindowTrans = NULL; + iForegroundWindowTop = NULL; + } + +/** Draw all foreground windows */ +void CTAlphaChannel::DrawTestWindowsNow(TBool aDrawBackgroundWin) + { + if(iBackgroundWindow && aDrawBackgroundWin) + { + iBackgroundWindow->DrawNow(); + } + + for(TInt ii = 0; ii < iArrWindow.Count(); ii++) + { + iArrWindow[ii]->DrawNow(); + } + } + +//------------- + +CTWinAlphaForeground* CTWinAlphaForeground::NewL(CTAlphaChannel& aTest, TPoint aPos, TSize aSize, CTWinBase *aParent, CWindowGc &aGc, TDisplayMode *aMode, TRgb aCol, TInt aTransparencyType) + { + CTWinAlphaForeground* theWin = new(ELeave) CTWinAlphaForeground(aTest); + + theWin->ConstructL(*aParent); + if (aMode) + theWin->SetDisplayMode(*aMode); + theWin->SetExtL(aPos, aSize); + theWin->AssignGC(aGc); + theWin->PrepareForDrawingL(); + + // for hardware testing only we create an additional bitmap +#ifndef __WINS__ + theWin->CreateBackgroundBitmapL(*aMode); +#endif + + RWindow* win = (RWindow*) (theWin->DrawableWin()); + win->SetShadowHeight(0); + win->SetShadowDisabled(ETrue); + switch (aTransparencyType) + { + case ETransparencyFactor: + { + win->SetTransparencyFactor(aCol); + theWin->SetBackgroundColor(aCol); + } + break; + case ETransparencyAlpha: + win->SetTransparencyAlphaChannel(); + // fall through into next case + case ENonTransparentAlpha: + default: + theWin->SetBackgroundColor(aCol); + break; + } + + theWin->Activate(); + + return theWin; + } + +CTWinAlphaForeground::~CTWinAlphaForeground() + { + if(iPolygon) + { + iPolygon->Reset(); + delete iPolygon; + } + delete iBitmapBackground; + delete iBitmapDeviceBackground; + delete iBitmapContextBackground; + } + +CTWinAlphaForeground::CTWinAlphaForeground(CTAlphaChannel& aTest) + : iTest(aTest) + { + } + + +void CTWinAlphaForeground::SetDisplayMode(TDisplayMode aDisplayMode) + { + BaseWin()->SetRequiredDisplayMode(aDisplayMode); + switch (aDisplayMode) + { + case EColor256: + iTitle1 = _L("256"); + break; + case EColor64K: + iTitle1 = _L("64K"); + break; + case EColor16MU: + iTitle1 = _L("16MU"); + break; + case EColor16MA: + iTitle1 = _L("16MA"); + break; + case EColor16MAP: + iTitle1 = _L("16MAP"); + break; + default: + iTitle1 = _L(""); + break; + } + } + +void CTWinAlphaForeground::SetBackgroundColor(TRgb aRgb) + { + switch (aRgb.Alpha()) + { + case 0: + iTitle2 = _L(" trans "); + break; + case 255: + iTitle2 = _L(" opaque "); + break; + case 128: + default: + iTitle2 = _L(" s-trans "); + break; + } + if (aRgb.Red()) + iTitle2 += _L("R"); + if (aRgb.Green()) + iTitle2 += _L("G"); + if (aRgb.Blue()) + iTitle2 += _L("B"); + + iBackgroundColor = aRgb; + ((RWindow*) DrawableWin())->SetBackgroundColor(aRgb); + } + +void CTWinAlphaForeground::Draw() + { + CBitmapContext* theGc = TheClient->iGc; + ((CWindowGc*)theGc)->SetOpaque(iDrawOpaque); + + if(iBitmapContextBackground) + { + //CGraphicsContext + theGc = iBitmapContextBackground; + CleanBackgroundBitmap(); + } + if(iTest.iFont1) + theGc->UseFont(iTest.iFont1); + + + theGc->SetFaded(EFalse); + DrawTable(*theGc); + + TInt numRows = sizeof(iRows) / sizeof(iRows[0]) ; + + theGc->SetBrushStyle(iTest.iBrushStyle); + if(iTest.iFont && iTest.iDrawText) + { + theGc->DiscardFont(); + theGc->UseFont(iTest.iFont); + } + + theGc->SetFaded(iTest.iIsFading); + + // the factor and offset are calculated as follows: + // iFadeMapFactor = iWhiteFading - iBlackFading; + // iFadeMapOffset = iBlackFading; + + theGc->SetFadingParameters(iTest.iBlackFading, iTest.iWhiteFading); //black and white + + for(TInt ii = 0; ii < numRows - 1; ii++) + { + theGc -> SetBrushStyle(iTest.iBrushStyle); + + TRect theRect = TRect(iCol, iRows[ii], Size().iWidth, iRows[ii + 1]); + + TRgb theBrush = iTest.GetBrush(ii); + TRgb thePen = iTest.GetPen(ii); + + CGraphicsContext::TDrawMode theDrawMode = iTest.GetDrawMode(ii); + + theGc->SetBrushColor(theBrush); + theGc->SetPenColor(thePen); + theGc->SetDrawMode(theDrawMode); + + CGraphicsContext* theBitmapContext64K; + CGraphicsContext* theBitmapContext16MA; + CFbsBitmap* theBitmap64K; + CFbsBitmap* theBitmap16MA; + + switch(ii) + { + case 0: + { + theBitmapContext64K = iTest.iBitmapContext64K_1; + theBitmapContext16MA = iTest.iBitmapContext16MA_1; + theBitmap64K = iTest.iBitmap64K_1; + theBitmap16MA = iTest.iBitmap16MA_1; + break; + } + case 1: + { + theBitmapContext64K = iTest.iBitmapContext64K_2; + theBitmapContext16MA = iTest.iBitmapContext16MA_2; + theBitmap64K = iTest.iBitmap64K_2; + theBitmap16MA = iTest.iBitmap16MA_2; + break; + } + default: + { + theBitmapContext64K = iTest.iBitmapContext64K_3; + theBitmapContext16MA = iTest.iBitmapContext16MA_3; + theBitmap64K = iTest.iBitmap64K_3; + theBitmap16MA = iTest.iBitmap16MA_3; + break; + } + } + if(iTest.iDrawText) + { + DrawTextInCell(*theGc, theRect); + } + else + { + TRAP_IGNORE(iTest.DrawOffscreenBitmapsL(thePen, theBrush, theBitmapContext64K, + theBitmapContext16MA, theBitmap64K, theBitmap16MA)); + DrawPrimitivesInCell(*theGc, theRect, theBitmap64K, theBitmap16MA); + } + TheClient->iWs.Flush(); + } + + theGc->DiscardFont(); + + if(iBitmapContextBackground) + { + theGc = TheClient->iGc; + theGc->BitBlt(TPoint(0, 0), iBitmapBackground); + } + } + +void CTWinAlphaForeground::SetPoligonLocation(const TPoint &ptOffset) + { + TRect rect = TRect(iTest.iTriangleSize); + (*iPolygon)[0] = rect.iTl + ptOffset; + (*iPolygon)[1] = TPoint(rect.iTl.iX, rect.iBr.iY) + ptOffset; + (*iPolygon)[2] = rect.iBr + ptOffset; + } + +/** Define boundary of the table*/ +void CTWinAlphaForeground::CalculateTableMargin() + { + TInt numRows = sizeof(iRows) / sizeof(iRows[0]) ; + iRows[0] = iTest.iFirstCellHeight; + TInt theRowHeight = (Size().iHeight - iTest.iFirstCellHeight) / 3; + for(TInt ii = 1; ii < numRows; ii++) + { + iRows[ii] = iRows[ii-1] + theRowHeight; + } + } + +/** Draw a table which comprises 3 rows: for transparent, semi-transparent + and opaque output + +*/ +void CTWinAlphaForeground::DrawTable(CBitmapContext& aGc) const + { + TInt numRows = sizeof(iRows) / sizeof(iRows[0]) ; + + aGc.SetPenColor(iTest.iPenTable); + + for (TInt ii = 0; ii < numRows - 1; ii++) + { + TBuf<4> iBuf; + TPoint pt1 = TPoint(0, iRows[ii]); + TPoint pt2 = TPoint(Size().iWidth, iRows[ii]); + + aGc.DrawLine(pt1, pt2); + + if(iCol) + { + TPoint pt3 = TPoint(0, iRows[ii]) + TPoint(2,(iRows[1] - iRows[0]) / 2); + switch(ii) + { + case 0: iBuf = _L("o"); break; + case 1: iBuf = _L("s"); break; + case 2: iBuf = _L("t"); break; + default : iBuf = _L(""); break; + } + aGc.DrawText(iBuf, pt3); + } + } + if(iCol) + { + TPoint pt3 = TPoint(iCol, iRows[0]) + TPoint(1,-2); + TBuf<32> text = iTitle1; + text += iTitle2; + aGc.DrawText(text, pt3); + + TPoint pt1 = TPoint(iCol, 0); + TPoint pt2 = TPoint(iCol, Size().iHeight); + aGc.DrawLine(pt1, pt2); + } + + } + +/** Draw truetype font to check anti-aliasing*/ +void CTWinAlphaForeground::DrawTextInCell(CBitmapContext& aGc, const TRect& aRect) + { + TPoint pt(aRect.iTl.iX, aRect.iBr.iY); + pt += TPoint(2, -10); + + aGc.DrawText(_L("ABCD"), pt); + } + +/** Draw graphics primitive in a cell: + rectangle, ellipse, triangle, a few lines, bitmaps + + */ +void CTWinAlphaForeground::DrawPrimitivesInCell(CBitmapContext& aGc, const TRect& aRect, + CFbsBitmap* aBitmap64K, CFbsBitmap* aBitmap16MA) + { + TRect theCellRect = aRect; + theCellRect.Shrink(1, 1); + + //rectangle + TRect rect = TRect(iTest.iRectangleSize); + rect.Move(theCellRect.iTl); + aGc.DrawRect(rect); + + //ellipse + rect = TRect(iTest.iEllipseSize); + rect.Move(theCellRect.iTl + TPoint(iTest.iRectangleSize.iWidth + 5, 0)); + aGc.DrawEllipse(rect); + + //triangle + TPoint pt = TPoint(rect.iBr.iX, rect.iTl.iY) + TPoint(5, 0); + SetPoligonLocation(pt); + aGc.DrawPolygon(iPolygon); + + //DrawLine + pt = pt + TPoint (((*iPolygon)[2]).iX - ((*iPolygon)[0]).iX, 0) + TPoint(5, 2); + rect = TRect(iTest.iTriangleSize); + rect.Move(pt); + aGc.DrawLine(rect.iTl, TPoint(rect.iTl.iX, rect.iBr.iY)); + aGc.DrawLine(TPoint(rect.iTl.iX, rect.iBr.iY), rect.iBr); + aGc.DrawLine(rect.iBr, TPoint(rect.iBr.iX, rect.iTl.iY)); + aGc.DrawLine(TPoint(rect.iBr.iX, rect.iTl.iY), rect.iTl); + aGc.DrawLine(rect.iTl, rect.iBr); + aGc.DrawLine(TPoint(rect.iBr.iX, rect.iTl.iY), TPoint(rect.iTl.iX, rect.iBr.iY)); + + //64K bitmap + aGc.SetBrushStyle(CGraphicsContext::ENullBrush); + pt = TPoint(theCellRect.iTl.iX, rect.iBr.iY) + TPoint(0, 5); + if(aBitmap64K) + { + aGc.BitBlt(pt, aBitmap64K); + pt = pt + TPoint( aBitmap64K->SizeInPixels().iWidth, 0) + TPoint(2, 0); + + aGc.BitBltMasked(pt, + aBitmap64K, TRect(aBitmap64K->SizeInPixels()), + iTest.iBitmapGray256Mask, EFalse); + pt = pt + TPoint( aBitmap64K->SizeInPixels().iWidth, 0) + TPoint(2, 0); + + aGc.BitBltMasked(pt, + aBitmap64K, TRect(aBitmap64K->SizeInPixels()), + iTest.iBitmapMask, EFalse); + + pt = pt + TPoint( aBitmap64K->SizeInPixels().iWidth, 0) + TPoint(2, 0); + } + + if(aBitmap16MA) + { + aGc.BitBlt(pt, aBitmap16MA); + + pt = pt + TPoint( aBitmap16MA->SizeInPixels().iWidth, 0) + TPoint(2, 0); + + aGc.BitBltMasked(pt, + aBitmap16MA, TRect(aBitmap16MA->SizeInPixels()), + iTest.iBitmapGray256Mask, EFalse); + + pt = pt + TPoint( aBitmap16MA->SizeInPixels().iWidth, 0) + TPoint(2,0); + + pt = pt + TPoint( 0, aBitmap16MA->SizeInPixels().iHeight); + } + + pt.iX = aRect.iTl.iX + 2; + pt.iY = pt.iY + 18; + + if(aBitmap64K) + { + TSize size = aBitmap64K->SizeInPixels(); + TRect srcRect(TPoint(0,0),size); + size += TSize(5,5); + TRect destRect(pt - TPoint(0, 8), size); + aGc.DrawBitmap(destRect, aBitmap64K, srcRect); + pt = pt + TPoint( size.iWidth, 0) + TPoint(2, 0); + +#ifdef __WINS__ + destRect.Move(TPoint(aBitmap64K->SizeInPixels().iWidth + 8, 0)); + ((CWindowGc&) aGc).DrawBitmapMasked(destRect, + aBitmap64K, srcRect, + iTest.iBitmapGray256Mask, EFalse); + pt = pt + TPoint( aBitmap64K->SizeInPixels().iWidth, 0) + TPoint(2, 0); +#endif + } + + aGc.DrawText(iTest.iText, pt); + +#ifdef __WINS__ + ((CWindowGc&) aGc).DrawTextVertical(iTest.iText, pt, ETrue); +#endif + } + +/** calculate table's size and size of graphics primitieves */ +void CTWinAlphaForeground::PrepareForDrawingL() + { + iCol = iTest.iFirstCellWidth; + + CalculateTableMargin(); + + //create triangle + iPolygon = new (ELeave) CArrayFixFlat (3); + TRect rect = TRect(iTest.iTriangleSize); + iPolygon->AppendL(rect.iTl); + iPolygon->AppendL(TPoint(rect.iTl.iX, rect.iBr.iY)); + iPolygon->AppendL(rect.iBr); + } + +/** Bitmap is intended to use on target only*/ +void CTWinAlphaForeground::CreateBackgroundBitmapL(const TDisplayMode& aDispMode) + { + ASSERT(!iBitmapBackground); + + TSize size = Size(); + + iBitmapBackground = new (ELeave) CFbsBitmap ; + iBitmapBackground->Create(size,aDispMode); + + iBitmapDeviceBackground = CFbsBitmapDevice::NewL(iBitmapBackground); + CGraphicsContext *&theGc = (CGraphicsContext*&)iBitmapContextBackground; + iBitmapDeviceBackground->CreateContext(theGc); + } + +void CTWinAlphaForeground::CleanBackgroundBitmap() + { + ASSERT(iBitmapBackground); + + TRect rect = TRect(iBitmapBackground->SizeInPixels()); + iBitmapContextBackground->SetBrushColor(iBackgroundColor); + iBitmapContextBackground->SetPenColor(iBackgroundColor); + iBitmapContextBackground->SetBrushStyle(CGraphicsContext::ESolidBrush); + iBitmapContextBackground->DrawRect(rect); + } + +void CTWinAlphaForeground::StartAnimationL() + { + __UHEAP_MARK; + RWsSprite theSprite; + + RDrawableWindow *theWin = DrawableWin(); + + theSprite=RWsSprite(TheClient->iWs); + TPoint theSpritePos = TPoint(10, 10); + TInt theFlags = 0; + theSprite.Construct(*theWin, theSpritePos, theFlags); + TDisplayMode dispMode = EColor256; + //create a ball bitmap for animation + CFbsBitmap* theBitmapBall= new (ELeave) CFbsBitmap; + theBitmapBall->Create(TSize(32, 32), dispMode); + CFbsBitmapDevice* theBitmapDeviceBall = CFbsBitmapDevice::NewL(theBitmapBall); + CGraphicsContext* theBitmapContextBall = NULL; + theBitmapDeviceBall->CreateContext(theBitmapContextBall); + //draw a background + theBitmapContextBall->SetBrushColor(TRgb(128, 0, 255)); + theBitmapContextBall->SetPenColor(TRgb(128, 0, 255)); + theBitmapContextBall->SetBrushStyle(CGraphicsContext::ESolidBrush); + theBitmapContextBall->DrawRect(theBitmapBall->SizeInPixels()); + + //create a ball's mask + CFbsBitmap* theBitmapMask= new (ELeave) CFbsBitmap; + theBitmapMask->Create(TSize(32, 32), dispMode); + CFbsBitmapDevice* theBitmapDeviceMask = CFbsBitmapDevice::NewL(theBitmapMask); + CGraphicsContext* theBitmapContextMask = NULL; + theBitmapDeviceMask->CreateContext(theBitmapContextMask); + //draw a mask + theBitmapContextMask->SetBrushColor(TRgb(0, 0, 0)); + theBitmapContextMask->SetPenColor(TRgb(0, 0, 0)); + theBitmapContextMask->SetBrushStyle(CGraphicsContext::ESolidBrush); + theBitmapContextMask->DrawRect(theBitmapMask->SizeInPixels()); + + theBitmapContextMask->SetBrushColor(TRgb(255, 255, 255)); + theBitmapContextMask->SetPenColor(TRgb(255, 255, 255)); + TRect rect = TRect(theBitmapMask->SizeInPixels()); + theBitmapContextMask->SetPenSize(TSize(6,6)); + theBitmapContextMask->DrawLine(rect.iTl, rect.iBr); + theBitmapContextMask->DrawLine(TPoint(0, rect.iBr.iY), TPoint(rect.iBr.iX, 0)); + + //create a second ball's mask + CFbsBitmap* theBitmapMask1= new (ELeave) CFbsBitmap; + theBitmapMask1->Create(TSize(32, 32), dispMode); + CFbsBitmapDevice* theBitmapDeviceMask1 = CFbsBitmapDevice::NewL(theBitmapMask1); + CGraphicsContext* theBitmapContextMask1 = NULL; + theBitmapDeviceMask1->CreateContext(theBitmapContextMask1); + //draw a mask + theBitmapContextMask1->SetBrushColor(TRgb(0, 0, 0)); + theBitmapContextMask1->SetPenColor(TRgb(0, 0, 0)); + theBitmapContextMask1->SetBrushStyle(CGraphicsContext::ESolidBrush); + theBitmapContextMask1->DrawRect(theBitmapMask1->SizeInPixels()); + + theBitmapContextMask1->SetBrushColor(TRgb(255, 255, 255)); + theBitmapContextMask1->SetPenColor(TRgb(255, 255, 255)); + rect = TRect(theBitmapMask1->SizeInPixels()); + theBitmapContextMask1->SetPenSize(TSize(6,6)); + theBitmapContextMask1->DrawLine(TPoint(rect.iBr.iX/2, 0), TPoint(rect.iBr.iX/2, rect.iBr.iY)); + theBitmapContextMask1->DrawLine(TPoint(0, rect.iBr.iY/2), TPoint(rect.iBr.iX, rect.iBr.iY/2)); + + + TSpriteMember theSpriteList; + theSpriteList.iBitmap = theBitmapBall; + theSpriteList.iMaskBitmap = theBitmapMask; + theSpriteList.iInvertMask = EFalse; + theSpriteList.iDrawMode = CGraphicsContext::EDrawModePEN; + theSpriteList.iOffset = TPoint(0, 0); + theSpriteList.iInterval = TTimeIntervalMicroSeconds32(100000); + theSprite.AppendMember(theSpriteList); + + TSpriteMember theSpriteList1; + theSpriteList1.iBitmap = theBitmapBall; + theSpriteList1.iMaskBitmap = theBitmapMask1; + theSpriteList1.iInvertMask = EFalse; + theSpriteList1.iDrawMode = CGraphicsContext::EDrawModePEN; + theSpriteList1.iOffset = TPoint(0, 0); + theSpriteList1.iInterval = TTimeIntervalMicroSeconds32(100000); + + theSprite.AppendMember(theSpriteList1); + + theSprite.Activate(); + + for(TInt ii = 0; ii < 20; ii++) + { + theSpritePos += TPoint(3, 8); + theSprite.SetPosition(theSpritePos); + TheClient->iWs.Flush(); + User::After(TTimeIntervalMicroSeconds32(50000)); + } + + for(TInt jj = 0; jj < 20; jj++) + { + theSpritePos -= TPoint(0, 8); + theSprite.SetPosition(theSpritePos); + TheClient->iWs.Flush(); + User::After(TTimeIntervalMicroSeconds32(50000)); + } + + theSprite.Close(); + + delete theBitmapContextBall; + delete theBitmapDeviceBall; + + delete theBitmapBall; + + delete theBitmapMask; + delete theBitmapContextMask; + delete theBitmapDeviceMask; + + delete theBitmapMask1; + delete theBitmapContextMask1; + delete theBitmapDeviceMask1; + + __UHEAP_MARKEND; + } + +void CTWinAlphaForeground::CreateBackedWindowL() + { + RBackedUpWindow theBackedWindow(TheClient->iWs); + CleanupClosePushL(theBackedWindow); + + TDisplayMode theDisplayMode = EColor16MA; + + RWindow* theWin = (RWindow*) DrawableWin(); + + theBackedWindow.Construct(*theWin,theDisplayMode, ENullWsHandle); + + TPoint pos =TPoint(10, 10); + TSize size = theWin->Size(); + size.SetSize(size.iWidth / 5, size.iHeight/10); + + theBackedWindow.SetExtentErr(pos, size); + theBackedWindow.SetOrdinalPosition(0); + + + //draw to backed window + TRgb color = TRgb(255, 0, 128); + TInt bitmapHandle = theBackedWindow.BitmapHandle(); + CFbsBitmap bitmapWin; + bitmapWin.Duplicate(bitmapHandle); + //Leave poss here - theBackedWindow could leak + CFbsBitmapDevice* theBitmapDevice = CFbsBitmapDevice::NewL(&bitmapWin); + CGraphicsContext* theBitmapContext = NULL; + theBitmapDevice->CreateContext(theBitmapContext); + theBitmapContext->SetBrushColor(color); + theBitmapContext->SetPenColor(color); + theBitmapContext->SetBrushStyle(CGraphicsContext::ESolidBrush); + theBitmapContext->DrawRect(TRect(bitmapWin.SizeInPixels())); + + color = TRgb(0, 0, 0); + theBitmapContext->SetPenColor(color); + for(TInt kk = 0; kk < bitmapWin.SizeInPixels().iWidth; kk += 8) + { + theBitmapContext->DrawLine(TPoint(kk, 0), TPoint(kk, bitmapWin.SizeInPixels().iHeight)); + } + + + theBackedWindow.Activate(); + TheClient->iWs.Flush(); + User::After(TTimeIntervalMicroSeconds32(500000)); + + //hide the window + theBackedWindow.SetVisible(EFalse); + TheClient->iWs.Flush(); + User::After(TTimeIntervalMicroSeconds32(500000)); + theBackedWindow.SetVisible(ETrue); + TheClient->iWs.Flush(); + + for(TInt ii = 0; ii < 7; ii++) + { + User::After(TTimeIntervalMicroSeconds32(100000)); + pos.iX += 5; + pos.iY += 15; + + theBackedWindow.SetExtentErr(pos, size); + TheClient->iWs.Flush(); + } + + User::After(TTimeIntervalMicroSeconds32(500000)); + + //transparent color. don't expect it to work + pos.iX -= 5; + pos.iY -= 15; + + theBackedWindow.SetExtentErr(pos, size); + color = TRgb(255, 255, 128, 128); + theBitmapContext->SetBrushColor(color); + theBitmapContext->SetPenColor(color); + theBitmapContext->DrawRect(TRect(bitmapWin.SizeInPixels())); + TheClient->iWs.Flush(); + User::After(TTimeIntervalMicroSeconds32(500000)); + + //semi-transparent color + pos.iX -= 5; + pos.iY -= 15; + theBackedWindow.SetExtentErr(pos, size); + color = TRgb(255, 255, 128, 255); + theBitmapContext->SetBrushColor(color); + theBitmapContext->SetPenColor(color); + TheClient->iWs.Flush(); + User::After(TTimeIntervalMicroSeconds32(500000)); + + + CleanupStack::PopAndDestroy(); //bitmapWin + delete theBitmapContext; + delete theBitmapDevice; + + } + + +//------------------- +void CTWinAlpha::Draw() + { + CBitmapContext* theGc = TheClient->iGc; + TSize size = Size(); + + for(TInt ii = 0; ii < size.iHeight; ii += (20+iState)) + { + theGc->DrawLine(TPoint(0, ii), TPoint(size.iWidth, ii)); + } + } + +__WS_CONSTRUCT_STEP__(AlphaChannel) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TAlphaChannel.H --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TAlphaChannel.H Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,218 @@ + +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// TBITMAP.H +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef __TALPHACHANNEL_H__ +#define __TALPHACHANNEL_H__ + +#include "AUTO.H" +#include "../tlib/testbase.h" +#include "TGraphicsHarness.h" + +class CTAlphaChannel; + +/** + Introduces a base class for transparent windows (both background and foreground) +*/ +class CTWinAlpha : public CTWin + { +public: + void Draw(); //we have to overridden it to avoid panic in a based class +public: + TInt iState; + }; + +enum {ETransparencyFactor, ETransparencyAlpha, ENonTransparentAlpha}; + +/** + Introduces a foreground transparent windows. + In order to set any instance of class as transparent it has to be created with + ETransparencyAlpha parameter +*/ +class CTWinAlphaForeground : public CTWin + { +public: + static CTWinAlphaForeground* NewL(CTAlphaChannel& aTest, TPoint aPos, TSize aSize, + CTWinBase* aParent, CWindowGc& aGc, TDisplayMode* aMode, TRgb aCol, TInt aTransparencyType = ENonTransparentAlpha); + ~CTWinAlphaForeground(); + +private: + CTWinAlphaForeground(CTAlphaChannel& aTest); + +public: + void Draw(); + void SetBackgroundColor(TRgb aColor); + void SetDisplayMode(TDisplayMode aDisplayMode); + void StartAnimationL(); + void CreateBackedWindowL(); + inline void SetDrawOpaque(TBool aDrawOpaque = ETrue) + { + iDrawOpaque = aDrawOpaque; + } + +protected: + void DrawTable(CBitmapContext& aGc) const; + void DrawPrimitivesInCell(CBitmapContext& aGc, const TRect& aRect, + CFbsBitmap* aBitmap64K, CFbsBitmap* aBitmap16MA); + void DrawTextInCell(CBitmapContext& aGc, const TRect& aRect); + void PrepareForDrawingL(); + void CalculateTableMargin(); + void SetPoligonLocation(const TPoint &ptOffset); + void CreateBackgroundBitmapL(const TDisplayMode& aDispMode); + void CleanBackgroundBitmap(); + +protected: + TInt iRows[4]; + TInt iCol; // width of the first column + CFbsBitmap* iBitmapBackground; + CFbsBitmapDevice* iBitmapDeviceBackground; + CBitmapContext* iBitmapContextBackground; + TRgb iBackgroundColor; + CArrayFix* iPolygon; + TBuf<16> iTitle1; + TBuf<16> iTitle2; + TBool iDrawOpaque; // this value will set to CWindowGc before drawing, should have any effect on drawing with alpha channel + +private: + CTAlphaChannel& iTest; + }; + +/** Test base class, which exersices drawing graphics operations with alpha channel */ +class CTAlphaChannel : public CTWsGraphicsBase + { +friend class CTWinAlphaForeground; +public: + CTAlphaChannel(CTestStep* aStep); + ~CTAlphaChannel(); + void ConstructL(); + void DrawTestWindowsNow(TBool aDrawBackgroundWin = EFalse); + + void SetWindow64K(); + void SetOpaqueWindow16MA(); + void SetTransparentWindow16MA(); + TInt SetWindow16MAWithMask(); + TInt SetWindow64KWithMask(); + CGraphicsContext::TDrawMode GetDrawMode(TInt aIndex) const; + TRgb GetBrush(TInt aIndex) const; + TRgb GetPen(TInt aIndex) const; + + // test functions + void SetDisplayModeConfiguration(TInt aConfig); + void SetPositionConfiguration(TInt aConfig); + void SetColourConfiguration(TInt aConfig); + void DoMoving(); + void DoMoveBehind(); + void DoInvisibility(); + void TestMoving(); + void TestMovingOverlapping(); + void TestFading(); + void TestChangingTransparencyFactor(); + void TestInvisibility(); + void TestMoveUnderneath(); + void TestMoveBehindInvisible(); + void TestRedrawBehind(); + void TestAnimationL(); + void TestBackedWindowL(); + void TestEffectSetOpaque(); + void TestChildWindowL(); + void TestMultipleChildrenL(); + void TestTransparentMovingUnderOpaqueL(); + void TestSetOrdinalPosition(); + +protected: +//from CTGraphicsStep + virtual void RunTestCaseL(TInt aCurTestCase); + void CreateForegroundWindowsL(const TSize& aSize, TDisplayMode aMode); + void DestroyForegroundWindows(); + void DrawOffscreenBitmapsL(const TRgb& aPen, const TRgb& aBrush, + CGraphicsContext* aBitmapContext64K, CGraphicsContext* aBitmapContext16MA, + CFbsBitmap* aBitmap64K, CFbsBitmap* aBitmap16MA); + void CalculateSizePrimitives(const TSize& aSize); +protected: + TRgb iPenTable; + CGraphicsContext::TBrushStyle iBrushStyle; + CGraphicsContext::TPenStyle iPenStyle; + TSize iSizeForegroundWindow; +private: + CTWinAlpha* iBackgroundWindow; + CTWinAlphaForeground* iForegroundWindowBottom; + CTWinAlphaForeground* iForegroundWindowOpaque; + CTWinAlphaForeground* iForegroundWindowSemiTrans; + CTWinAlphaForeground* iForegroundWindowTrans; + CTWinAlphaForeground* iForegroundWindowTop; + + CArrayPtrFlat iArrWindow; + + + CFbsBitmap* iBitmap64K_1; + CFbsBitmap* iBitmap16MA_1; + CFbsBitmap* iBitmap64K_2; + CFbsBitmap* iBitmap16MA_2; + CFbsBitmap* iBitmap64K_3; + CFbsBitmap* iBitmap16MA_3; + CFbsBitmap* iBitmapMask; + CFbsBitmap* iBitmapGray256Mask; + + CFbsBitmapDevice* iBitmapDevice64K_1; + CFbsBitmapDevice* iBitmapDevice16MA_1; + CFbsBitmapDevice* iBitmapDevice64K_2; + CFbsBitmapDevice* iBitmapDevice16MA_2; + CFbsBitmapDevice* iBitmapDevice64K_3; + CFbsBitmapDevice* iBitmapDevice16MA_3; + + CGraphicsContext* iBitmapContext64K_1; + CGraphicsContext* iBitmapContext16MA_1; + CGraphicsContext* iBitmapContext64K_2; + CGraphicsContext* iBitmapContext16MA_2; + CGraphicsContext* iBitmapContext64K_3; + CGraphicsContext* iBitmapContext16MA_3; + + TBuf<256> iText; + CFont* iFont; // for true type font, needs to exercise anti-aliasing + CFont* iFont1; // title font + + TSize iBitmapSize; + TSize iRectangleSize; + TSize iEllipseSize ; + TSize iTriangleSize ; + TInt iFirstCellWidth ; + TInt iFirstCellHeight; + TBool iDrawText; // if true output text, graphics primitives otherwise + TBool iIsFading; + TUint8 iBlackFading; + TUint8 iWhiteFading; + }; + +class CTAlphaChannelStep : public CTGraphicsStep + { +public: + CTAlphaChannelStep(); +protected: + //from CTGraphicsStep + virtual CTGraphicsBase* CreateTestL(); + }; + +_LIT(KTAlphaChannelStep,"TAlphaChannel"); + + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TAnimDraw.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TAnimDraw.h Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,20 @@ +// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#include +#include +#include "W32STD.H" + +GLREF_C void DoDraw(TInt aDraw,CBitmapContext& aGc,TRgb aColor,TRect aRect,CFbsFont *aFont=NULL,TInt aTextVal=0); diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TAnimdraw.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TAnimdraw.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,47 @@ +// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#include "TAnimDraw.h" + +GLREF_C void DoDraw(TInt aDraw,CBitmapContext& aGc,TRgb aColor,TRect aRect,CFbsFont *aFont,TInt aTextVal) + { + switch (aDraw) + { + case 36: + { + aGc.Clear(); + aGc.SetPenSize(TSize(15,15)); + aGc.SetPenColor(aColor); + aGc.DrawLine(TPoint(aRect.iTl),TPoint(aRect.iBr)); + break; + } + case 37: + { + TBuf<3> buf; + buf.Format(_L("%d"), aTextVal); + aGc.Clear(); + aGc.SetDrawMode(CGraphicsContext::EDrawModePEN); + aGc.SetPenStyle(CGraphicsContext::ESolidPen); + aGc.SetPenSize(TSize(1,1)); + aGc.SetPenColor(aColor); + aGc.UseFont(aFont); + TInt drawHeight=aFont->AscentInPixels(); + aRect.iTl.iY=aRect.iBr.iY/3; + aGc.DrawText(buf,aRect,drawHeight,CGraphicsContext::ECenter); + break; + } + default:; + } + } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TBACKUPW.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TBACKUPW.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,953 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Test backed up windows +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include "TBACKUPW.H" + +CTBackedUpWindow::CTBackedUpWindow(CTestStep* aStep): + CTWsGraphicsBase(aStep) + { + } + + +void CTBackedUpWindow::CheckWindow(CFbsBitmap *aBitmap) + { + TPoint oldPos=iBackedUpWindow.Position(); + iBackedUpWindow.SetPosition(TPoint(0,0)); + + iCheckWindow.SetVisible(ETrue); + iCheckWindow.SetPosition(iCheckPos); + + iCheckWindow.BeginRedraw(); + TheGc->Activate(iCheckWindow); + TheGc->BitBlt(TPoint(0,0), aBitmap); + TheGc->Deactivate(); + iCheckWindow.EndRedraw(); + + TheClient->iWs.Flush(); + TheClient->WaitForRedrawsToFinish(); + TBool retVal = TheClient->iScreen->RectCompare(TRect(iSize),TRect(iCheckPos,iSize)); + TEST(retVal); + if (!retVal) + INFO_PRINTF3(_L("TheClient->iScreen->RectCompare(TRect(iSize),TRect(iCheckPos,iSize)) return value - Expected: %d , Actual: %d"), ETrue, retVal); + + iCheckWindow.SetVisible(EFalse); + iBackedUpWindow.SetPosition(oldPos); + } + +void CTBackedUpWindow::CheckWindow() + { + CheckWindow(&iBitmap); + } + +void CTBackedUpWindow::Draw(TInt aDrawFunc, TAny *aParam) + { + TheGc->Activate(iBackedUpWindow); + Draw(aDrawFunc, aParam, TheGc, iBitGc); + TheGc->Deactivate(); + } + +void CTBackedUpWindow::DrawWithTwoGcsL() + { + RBlankWindow blank(TheClient->iWs); + User::LeaveIfError(blank.Construct(*(TheClient->iGroup->GroupWin()),ENullWsHandle)); + blank.Activate(); + CWindowGc *gc2; + User::LeaveIfError(TheClient->iScreen->CreateContext(gc2)); + CleanupStack::PushL(gc2); + + CFbsFont *font1; + TFontSpec fspec(KTestFontTypefaceName,200); + User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)font1,fspec)); + CFbsFont *font2; + TFontSpec fspec2(KTestFontTypefaceName,400); + User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)font2,fspec2)); + + gc2->Activate(iBackedUpWindow); + gc2->UseFont(font2); + TheGc->Activate(iBackedUpWindow); + TheGc->UseFont(font1); + _LIT(KText,"Testing123"); + TheGc->DrawText(KText,TPoint(20,20)); + gc2->DrawText(KText,TPoint(20,40)); + iBitGc->UseFont(font1); + iBitGc->DrawText(KText,TPoint(20,20)); + iBitGc->UseFont(font2); + iBitGc->DrawText(KText,TPoint(20,40)); + iBitGc->DiscardFont(); + TheGc->Deactivate(); + TheClient->iScreen->ReleaseFont(font2); + TheClient->iScreen->ReleaseFont(font1); + CleanupStack::PopAndDestroy(); + blank.Close(); + } + +void CTBackedUpWindow::Draw(TInt aDrawFunc, TAny *aParam, CBitmapContext *gc1, CBitmapContext *gc2) //DDD + { + CBitmapContext *gc; + for(TInt mode=0;mode<2;mode++) + { + if (mode==0) + gc=gc1; + else + gc=gc2; + gc->Reset(); + switch(aDrawFunc) + { + case 0: + gc->SetBrushColor(*((TRgb *)aParam)); + gc->SetBrushStyle(CGraphicsContext::ESolidBrush); + gc->SetPenStyle(CGraphicsContext::ENullPen); + gc->DrawRect(TRect(iSize)); + break; + case 1: + { + TSize half(iSize.iWidth/2,iSize.iHeight/2); + gc->DrawEllipse(TRect(half)); + gc->DrawEllipse(TRect(TPoint(0,half.iHeight),half)); + TRect rect1(half); + gc->SetOrigin(TPoint(half.iWidth,0)); + gc->SetClippingRect(rect1); + gc->DrawEllipse(rect1); + gc->SetOrigin(TPoint(half.iWidth,half.iHeight)); + gc->SetClippingRect(rect1); + gc->DrawEllipse(rect1); + gc->SetOrigin(TPoint(0,0)); + gc->CancelClippingRect(); + } + break; + case 2: + { + TInt param= *((TInt *)aParam); + if (param&0x1) + gc->DrawLine(TPoint(param+(param*27)%iSize.iWidth,0), + TPoint(iSize.iWidth-((param<<1)+(param*19)%iSize.iWidth),iSize.iHeight)); + else + gc->DrawLine(TPoint(0, (param<<1)+(param*7)%iSize.iHeight), + TPoint(iSize.iWidth,param+(param*13)%iSize.iHeight)); + } + break; + case 3: + { + TPoint pos; + for(;pos.iXDrawLine(pos,pos+TSize(0,iSize.iHeight)); + for(pos.iX=0;pos.iYDrawLine(pos,pos+TSize(iSize.iWidth,0)); + } + break; + } + } + } + +CTBackedUpWindow::~CTBackedUpWindow() + { + iBackedUpWindow.Close(); + iCheckWindow.Close(); + iOomFrontWindow.Close(); + delete iBitGc; + delete iBitmapDevice; + delete iTestBitmap; + delete iMaskBitmap; + } + +void CopyToGray4L(CFbsBitmap*& aDestBitmap,const CFbsBitmap& aSrcBitmap) + { + aDestBitmap=new(ELeave) CFbsBitmap(); + CleanupStack::PushL(aDestBitmap); + User::LeaveIfError(aDestBitmap->Create(aSrcBitmap.SizeInPixels(),EGray4)); + CFbsBitmapDevice* device=CFbsBitmapDevice::NewL(aDestBitmap); + CleanupStack::PushL(device); + CFbsBitGc* gc; + User::LeaveIfError(device->CreateContext(gc)); + gc->BitBlt(TPoint(),&aSrcBitmap); + delete gc; + CleanupStack::PopAndDestroy(device); + CleanupStack::Pop(aDestBitmap); + } + +void CTBackedUpWindow::ConstructL() + { + iBackedUpWindow=RBackedUpWindow(TheClient->iWs); + iBackedUpWindow.Construct(*(TheClient->iGroup->GroupWin()),EGray4,ENullWsHandle); + TSize size=TheClient->iScreen->SizeInTwips(); + iSize=TheClient->iScreen->SizeInPixels(); + iSize.iWidth>>=1; + iSize.iHeight>>=1; + size.iWidth>>=1; + size.iHeight>>=1; + size.iWidth-=1; //Modification to get the mapping factor the same as the screen + size.iHeight-=1; //Ditto + iWinPos.SetXY(iSize.iWidth>>1,iSize.iHeight>>1); + User::LeaveIfError(iBackedUpWindow.SetExtentErr(iWinPos,iSize)); + iBackedUpWindow.Activate(); + + iCheckPos.SetXY(iSize.iWidth,0); + iCheckWindow=RWindow(TheClient->iWs); + iCheckWindow.Construct(*(TheClient->iGroup->GroupWin()),ENullWsHandle); + iCheckWindow.SetSize(iSize); + iCheckWindow.SetVisible(EFalse); + iCheckWindow.Activate(); + + TInt col,grey; + TDisplayMode defMode=TheClient->iWs.GetDefModeMaxNumColors(col,grey); + User::LeaveIfError(iBitmap.Create(iSize,defMode)); + iBitmap.SetSizeInTwips(size); + iBitmapDevice=CFbsBitmapDevice::NewL(&iBitmap); + User::LeaveIfError(iBitmapDevice->CreateContext(iBitGc)); + + TRgb rgb(TRgb::Gray4(2)); + Draw(0,&rgb); + + iTestBitmap=new(ELeave) CFbsBitmap(); + User::LeaveIfError(iTestBitmap->Load(TEST_BITMAP_NAME,0)); + iTestBitmap->SetSizeInTwips(TSize(1500,750)); + iMaskBitmap=new(ELeave) CFbsBitmap(); + User::LeaveIfError(iMaskBitmap->Load(TEST_BITMAP_NAME,0)); + TDisplayMode defMode2=iMaskBitmap->DisplayMode(); + if (defMode>EGray4) + { + CFbsBitmap* bitmap=iTestBitmap; + CopyToGray4L(iTestBitmap,*bitmap); + delete bitmap; + bitmap=iMaskBitmap; + CopyToGray4L(iMaskBitmap,*bitmap); + delete bitmap; + } + defMode2=iMaskBitmap->DisplayMode(); + defMode2=iMaskBitmap->DisplayMode(); + } + +void CTBackedUpWindow::InvisVis() + { + iBackedUpWindow.SetVisible(EFalse); + TheClient->iWs.Flush(); + iBackedUpWindow.SetVisible(ETrue); + TheClient->iWs.Flush(); + } + +void CTBackedUpWindow::WindowOnTop() + { + RBlankWindow blank(TheClient->iWs); + blank.Construct(*(TheClient->iGroup->GroupWin()),ENullWsHandle); + blank.Activate(); + blank.Close(); + TheClient->iWs.Flush(); + + TPoint pos; + TInt sizeMode=0; + TInt draw=13; + + for(pos.iX=-iSize.iWidth;pos.iXiWs); + blank.Construct(*(TheClient->iGroup->GroupWin()),ENullWsHandle); + blank.SetColor(TRgb::Gray256(220)); + blank.SetShadowHeight(2); + blank.SetExtent(pos+iWinPos,TSize((sizeMode&0x1)?iSize.iWidth>>1:iSize.iWidth<<1,(sizeMode&0x2)?iSize.iHeight>>1:iSize.iHeight<<1)); + sizeMode=(sizeMode+1)%4; + blank.Activate(); + Draw(2,&draw); + TheClient->iWs.Flush(); + draw++; + blank.Close(); + } + } + +void CTBackedUpWindow::Resize() + { + RBlankWindow blank(TheClient->iWs); + blank.Construct(*(TheClient->iGroup->GroupWin()),ENullWsHandle); + blank.SetColor(TRgb::Gray256(128)); + blank.Activate(); + TInt xtop=(iSize.iWidth)-(iSize.iWidth>>2); + TInt ytop=(iSize.iHeight)-(iSize.iHeight>>2); + for(TInt winMode=0;winMode<3;winMode++) + { + switch(winMode) + { + case 0: + blank.SetExtent(TPoint(0,ytop),TSize(iSize.iWidth,iSize.iHeight>>1)); + break; + case 1: + blank.SetExtent(TPoint(xtop,0),TSize(iSize.iWidth>>1,iSize.iHeight)); + break; + case 2: + blank.SetExtent(TPoint(xtop,ytop),TSize(iSize.iWidth>>1,iSize.iHeight>>1)); + break; + } + blank.SetShadowHeight(winMode); + TPoint oldPos=iBackedUpWindow.Position(); + TPoint pos=oldPos; + for(TUint i=0;iiWs.Flush(); + } + iBackedUpWindow.SetPosition(oldPos); + } + blank.Close(); + } + +void CTBackedUpWindow::ChildWindows() + { + TPoint pos; + TInt sizeMode=0; + TInt draw=13; + RBlankWindow blank(TheClient->iWs); + for(pos.iX=-(iSize.iWidth>>1);pos.iX>1);pos.iY>2:iSize.iWidth,(sizeMode&0x2)?iSize.iHeight>>2:iSize.iHeight)); + sizeMode=(sizeMode+1)%4; + blank.Activate(); + Draw(2,&draw); + TheClient->iWs.Flush(); + draw++; + blank.Close(); + } + } + +void CTBackedUpWindow::DupBitmapTestL() + { + INFO_PRINTF1(_L("AUTO Dup Bitmap Test ")); + CFbsBitmap *dup=new(ELeave) CFbsBitmap(); + dup->Duplicate(iBackedUpWindow.BitmapHandle()); + CheckWindow(dup); + TRgb rgb(TRgb::Gray4(1)); + Draw(0,&rgb); + CheckWindow(dup); + INFO_PRINTF1(_L(" Done Window Drawing Test")); + + CFbsBitmapDevice *dupDevice=NULL; + TRAPD(err,dupDevice=CFbsBitmapDevice::NewL(dup)); + CFbsBitGc *gc; + if (err==KErrNone && dupDevice->CreateContext(gc)==KErrNone) + { + Draw(3,NULL,gc,iBitGc); // Draw directly to backup bitmap (and test bitmap) + iBackedUpWindow.UpdateScreen(); + INFO_PRINTF1(_L(" First Bitmap Drawing")); + CheckWindow(); + TRgb rgb(TRgb::Gray256(128)); + TInt col,grey; + if (TheClient->iWs.GetDefModeMaxNumColors(col,grey)>EGray4) + rgb=TRgb::Gray4(2); + Draw(0,&rgb,gc,iBitGc); + Draw(1,NULL,gc,iBitGc); + iBackedUpWindow.UpdateScreen(TRegionFix<1>(TRect(iSize))); + INFO_PRINTF1(_L(" Second Bitmap Drawing")); + CheckWindow(); + delete gc; + } + delete dupDevice; + delete dup; + } + +void CTBackedUpWindow::UpdateBitmapTestL() + { + INFO_PRINTF1(_L("AUTO UpdateBitmap ")); + CheckWindow(); + CFbsBitmap *dup=new(ELeave) CFbsBitmap(); + dup->Duplicate(iBackedUpWindow.BitmapHandle()); + Draw(3,NULL); + iBackedUpWindow.UpdateBackupBitmap(); + INFO_PRINTF1(_L(" First Drawing")); + CheckWindow(dup); + TRgb rgb; + if (iSupState==0) + rgb=TRgb::Gray256(128); + else + rgb=TRgb::Gray4(2); + Draw(0,&rgb); + Draw(1,NULL); + iBackedUpWindow.UpdateBackupBitmap(); + INFO_PRINTF1(_L(" Second Drawing")); + CheckWindow(dup); + delete dup; + } + +void CTBackedUpWindow::OOML() + { + iOomFrontWindow=RBlankWindow(TheClient->iWs); + TSize size(iBackedUpWindow.Size()); + size.iWidth>>=1; + size.iHeight>>=1; + TPoint pos(size.iWidth*3/2,size.iHeight*3/2); + iOomFrontWindow.Construct(*(TheClient->iGroup->GroupWin()),ENullWsHandle); + iOomFrontWindow.SetColor(TRgb(TRgb::Gray4(1))); + iOomFrontWindow.SetExtent(pos,size); + iOomFrontWindow.Activate(); + TheClient->iWs.Flush(); + + TPoint buwPos=iBackedUpWindow.Position(); + TSize buwSize=iBackedUpWindow.Size(); + for(TInt count=0;count<100;count++) + { + iOomFrontWindow.SetVisible(ETrue); + TheClient->iWs.HeapSetFail(RHeap::EDeterministic,count); + iBackedUpWindow.SetPosition(buwPos+TPoint(10,5)); + iBackedUpWindow.SetPosition(buwPos); + iOomFrontWindow.SetSize(size+TSize(10,5)); + iOomFrontWindow.SetSize(size); + iBackedUpWindow.SetSizeErr(buwSize+TSize(13,7)); + iBackedUpWindow.SetSizeErr(buwSize); + iOomFrontWindow.SetVisible(EFalse); + TheClient->iWs.HeapSetFail(RHeap::ENone,0); + User::LeaveIfError(iBackedUpWindow.SetSizeErr(buwSize)); + TheClient->WaitForRedrawsToFinish(); + CheckWindow(); + } + + iOomFrontWindow.Close(); + } + +void CTBackedUpWindow::doGraphicFunctionsL(CBitmapContext *gc,TBool aExtraDrawBitMap) + { + TSize size=iBackedUpWindow.Size(); + CFbsFont *aFont; + _LIT(KFontName,"Swiss"); + TFontSpec fspec(KFontName,190); + User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)aFont,fspec)); + CFbsBitmap* aBitmap=iTestBitmap; + CFbsBitmap* aMaskBitmap=iMaskBitmap; + + #include "DLLDRAW.H" // Draws to a Gc called 'gc' + + TheClient->iScreen->ReleaseFont(aFont); + } + +void CTBackedUpWindow::AllGraphicFunctionsL(RBlankWindow &aBlank,TBool aExtraDrawBitMap/*=ETrue*/) + { + aExtraDrawBitMap=EFalse; //Check out when bitblit scaling has changed again + aBlank.SetVisible(ETrue); + TheGc->Activate(iBackedUpWindow); + TRAPD(err,doGraphicFunctionsL(TheGc,aExtraDrawBitMap)); + TheGc->Deactivate(); + User::LeaveIfError(err); + iBitGc->Reset(); + iBitGc->SetUserDisplayMode(EGray4); + doGraphicFunctionsL(iBitGc,aExtraDrawBitMap); + aBlank.SetVisible(EFalse); + CheckWindow(); + } + +void CTBackedUpWindow::AllGraphicFunctionsTestsL() + { + RBlankWindow blank(TheClient->iWs); + TInt xtop=(iSize.iWidth)-(iSize.iWidth>>1); + TInt ytop=(iSize.iHeight)-(iSize.iHeight>>1); + blank.Construct(*(TheClient->iGroup->GroupWin()),ENullWsHandle); + blank.SetColor(TRgb::Gray256(128)); + blank.Activate(); + blank.SetExtent(TPoint(0,ytop),TSize(iSize.iWidth,iSize.iHeight>>2)); + AllGraphicFunctionsL(blank); + blank.SetExtent(TPoint(0,ytop+10),TSize(iSize.iWidth,iSize.iHeight>>2)); + AllGraphicFunctionsL(blank); + blank.SetExtent(TPoint(xtop,ytop),TSize(iSize.iWidth>>1,iSize.iHeight)); + AllGraphicFunctionsL(blank,EFalse); + blank.SetExtent(TPoint(xtop+(iSize.iWidth>>1),ytop),TSize(iSize.iWidth>>1,iSize.iHeight)); + AllGraphicFunctionsL(blank,EFalse); + blank.SetExtent(TPoint(xtop+10,iSize.iHeight),TSize(iSize.iWidth,iSize.iHeight)); + AllGraphicFunctionsL(blank,EFalse); + blank.SetExtent(TPoint(xtop,ytop),iSize); + AllGraphicFunctionsL(blank,EFalse); + blank.SetExtent(TPoint(0,0),TSize(0,0)); + AllGraphicFunctionsL(blank); + blank.Close(); + } + +void CTBackedUpWindow::RunTestCaseL(TInt /*aCurTestCase*/) + { + switch(iSupState) + { + case 0: + for (TInt iSubTest=0;iSubTestiState=iState; +((CTBackedUpWindowStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); + switch(iState) + { +/** +@SYMTestCaseID GRAPHICS-WSERV-0202-0001 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test drawing in a backed up window + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Draw in a backed up window and a normal window and check + the two drawings are the same + +@SYMTestExpectedResults The two drawings are exactly the same +*/ + case 0: + ((CTBackedUpWindowStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0202-0001")); + iTest->LogSubTest(KTest0); + Draw(1,NULL); + CheckWindow(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0202-0002 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test drawing in a backed up window + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Draw in a backed up window and a normal window and check + the two drawings are the same + +@SYMTestExpectedResults The two drawings are exactly the same +*/ + case 1: + ((CTBackedUpWindowStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0202-0002")); + iTest->LogSubTest(KTest1); + Draw(0,&rgb1); + Draw(3,NULL); + Resize(); + CheckWindow(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0203 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test making a backed up window invisible + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Draw in a backed up window and a normal window, make + the backed up window invisible then visible and + then check the two drawings are the same + +@SYMTestExpectedResults The two drawings are exactly the same +*/ + case 2: + ((CTBackedUpWindowStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0203")); + iTest->LogSubTest(KTest2); + Draw(0,&rgb2); + Draw(1,NULL); + InvisVis(); + CheckWindow(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0204 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test drawing in a backed up window and then placing a + window on top of it + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Draw in a backed up window and a normal window, then + place a window on top of the backed up window and then + check the two drawings are the same + +@SYMTestExpectedResults The two drawings are exactly the same +*/ + case 3: + ((CTBackedUpWindowStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0204")); + iTest->LogSubTest(KTest3); + //TRgb rgb(220,220,220); + Draw(0,&rgb3); + Draw(1,NULL); + WindowOnTop(); + CheckWindow(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0205 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test drawing in a backed up window and then drawing in + a child window + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Draw in a backed up window and a normal window, then + create and draw in a child window and then + check the two original drawings are the same + +@SYMTestExpectedResults The two drawings are exactly the same +*/ + case 4: + ((CTBackedUpWindowStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0205")); + iTest->LogSubTest(KTest4); + Draw(0,&rgb4); + Draw(3,NULL); + ChildWindows(); + CheckWindow(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0206 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Out of memeory test for backed up windows + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Out of memeory test for backed up windows + +@SYMTestExpectedResults Backed up window responds correctly when out + of memory +*/ + case 5: + ((CTBackedUpWindowStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0206")); + iTest->LogSubTest(KTest5); + if (!iTest->IsFullRomL()) + { + Draw(0,&rgb5); + Draw(3,NULL); + OOML(); + CheckWindow(); + } + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0207 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test updating a bitmap in a backed up window + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Update a bitmap in a backed up window and a normal window + and check the two bitmaps are the same + +@SYMTestExpectedResults The two bitmaps are exactly the same +*/ + case 6: + ((CTBackedUpWindowStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0207")); + iTest->LogSubTest(KTest6); + Draw(0,&rgb6); + Draw(1,NULL); + UpdateBitmapTestL(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0208 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test updating a duplicate bitmap in a backed up window + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Update a duplicated bitmap in a backed up window and a normal window + and check the two bitmaps are the same + +@SYMTestExpectedResults The two bitmaps are exactly the same +*/ + case 7: + ((CTBackedUpWindowStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0208")); + if (iSupState==0) //Will fail unless the window is fully backup. + break; + iTest->LogSubTest(KTest7); + Draw(0,&rgb7); + Draw(1,NULL); + DupBitmapTestL(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0209 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test drawing with two graphic contexts in a backed up window + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Draw using two graphic contexts in a backed up window and a normal + window and check the two drawings are the same + +@SYMTestExpectedResults The two drawings are exactly the same +*/ + case 8: + ((CTBackedUpWindowStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0209")); + iTest->LogSubTest(KTest8); + Draw(0,&color); + Draw(1,NULL); + DrawWithTwoGcsL(); + CheckWindow(); + break; + +/** +@SYMTestCaseID GRAPHICS-WSERV-0210 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test drawing using all the graphic functions in a backed up window + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Draw using all the graphic functions in a backed up window and a normal + window and check the two drawings are the same + +@SYMTestExpectedResults The two drawings are exactly the same +*/ + case 9: + ((CTBackedUpWindowStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0210")); + iTest->LogSubTest(KTest9); + if(TheClient->iScreen->SizeInPixels() == TSize(640,240)) + AllGraphicFunctionsTestsL(); + break; + + //A Coverage test, nothing spectacular just making the code + //go into CWsGc::Reactivate + case 10: + { +/** +@SYMTestCaseID GRAPHICS-WSERV-0502 +*/ + ((CTBackedUpWindowStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0502")); + iTest->LogSubTest(KTest10); + TheGc->Deactivate(); + RBackedUpWindow extentWindow; + extentWindow=RBackedUpWindow(TheClient->iWs); + extentWindow.Construct(*(TheClient->iGroup->GroupWin()),EGray4,ENullWsHandle); + TheGc->Activate(extentWindow); + TheClient->Flush(); + User::LeaveIfError(extentWindow.SetExtentErr(TPoint(2,2), TSize(4,4))); + extentWindow.Activate(); + extentWindow.Close(); + TheGc->Deactivate(); + break; + } + + //Coverage for various messages for CWsGc::DoDrawCommand + case 11: + { +/** +@SYMTestCaseID GRAPHICS-WSERV-0507 +*/ + ((CTBackedUpWindowStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0507")); + iTest->LogSubTest(KTest11); + TheGc->Activate(iBackedUpWindow); + TheGc->Reset(); + iBitGc->Reset(); + iBitGc->SetUserDisplayMode(EGray4); + + // EWsGcOpDrawWsGraphic + TheGc->DrawWsGraphic(TWsGraphicId(0), TRect(0,0,10,10)); + + //create a large junk buffer so that messages with Ptr suffix will be sent + RBuf8 junkBuf8; + RBuf junkBuf; + junkBuf8.CreateMax(650); // a large enough buffer to sent as Ptr (this value used to crash the code before) + junkBuf.CreateMax(650); // a large enough buffer to sent as Ptr + for (int i=0; iDrawWsGraphic(TWsGraphicId(0), TRect(0,0,10,10), junkBuf8); + + // Set font for drawing on screen + CFbsFont *font1; + TFontSpec fspec(KTestFontTypefaceName,200); + User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)font1,fspec)); + TheGc->UseFont(font1); + iBitGc->UseFont(font1); + + // EWsGcOpDrawTextPtr + TheGc->DrawText(junkBuf, TPoint(0,0)); + iBitGc->DrawText(junkBuf, TPoint(0,0)); + + // EWsGcOpDrawBoxText - unreachable 299-too lo, 300-too hi + + // EWsGcOpDrawBoxTextPtr + TheGc->DrawText(junkBuf, TRect(0,0,10,10), 0, CGraphicsContext::ELeft, 0); + iBitGc->DrawText(junkBuf, TRect(0,0,10,10), 0, CGraphicsContext::ELeft, 0); + + // EWsGcOpDrawTextVerticalPtr + TheGc->DrawTextVertical(junkBuf, TPoint(0,0), ETrue); + iBitGc->DrawTextVertical(junkBuf, TPoint(0,0), ETrue); + + // EWsGcOpDrawBoxTextVerticalPtr + TheGc->DrawTextVertical(junkBuf, TRect(0,0,10,10), 0, ETrue, CGraphicsContext::ELeft, 0); + iBitGc->DrawTextVertical(junkBuf, TRect(0,0,10,10), 0, ETrue, CGraphicsContext::ELeft, 0); + + // EWsGcOpMoveBy + TheGc->MoveBy(TPoint(2,2)); + iBitGc->MoveBy(TPoint(2,2)); + + // a bitmap for bitblt ops + CWsBitmap bmp(TheClient->iWs); + bmp.Create(TSize(16,16), iBackedUpWindow.DisplayMode()); + + // EWsGcOpGdiWsBlt2 + TheGc->BitBlt(TPoint(0,0), &bmp); + iBitGc->BitBlt(TPoint(0,0), &bmp); + + // EWsGcOpGdiWsBlt3 + TheGc->BitBlt(TPoint(0,0), &bmp, TRect(0,0,10,10)); + iBitGc->BitBlt(TPoint(0,0), &bmp, TRect(0,0,10,10)); + + // EWsGcOpGdiWsBltMasked + TheGc->BitBltMasked(TPoint(0,0), &bmp, TRect(0,0,10,10), &bmp, EFalse); + iBitGc->BitBltMasked(TPoint(0,0), &bmp, TRect(0,0,10,10), &bmp, EFalse); + + // EWsGcOpGdiWsAlphaBlendBitmaps + TheGc->AlphaBlendBitmaps(TPoint(0,0), &bmp, TRect(0,0,10,10), &bmp, TPoint(1,1)); + iBitGc->AlphaBlendBitmaps(TPoint(0,0), &bmp, TRect(0,0,10,10), &bmp, TPoint(1,1)); + + // EWsGcOpWsDrawBitmapMasked + TheGc->DrawBitmapMasked(TRect(0,0,10,10), &bmp, TRect(0,0,8,8), &bmp, ETrue); + iBitGc->DrawBitmapMasked(TRect(0,0,10,10), &bmp, TRect(0,0,8,8), &bmp, ETrue); + + // EWsGcOpDrawBitmap + TheGc->DrawBitmap(TPoint(0,0), &bmp); + iBitGc->DrawBitmap(TPoint(0,0), &bmp); + + // EWsGcOpDrawBitmapMasked + TheGc->DrawBitmapMasked(TRect(0,0,10,10), static_cast(&bmp), + TRect(0,0,8,8), static_cast(&bmp), + EFalse); + iBitGc->DrawBitmapMasked(TRect(0,0,10,10), static_cast(&bmp), + TRect(0,0,8,8), static_cast(&bmp), + EFalse); + + // EWsGcOpDrawPolyLineContinued + TheGc->DrawPolyLine(reinterpret_cast(junkBuf8.Ptr()), + TInt(junkBuf8.Size()/sizeof(TPoint))); + iBitGc->DrawPolyLine(reinterpret_cast(junkBuf8.Ptr()), + TInt(junkBuf8.Size()/sizeof(TPoint))); + + // EWsGcOpCopyRect + TheGc->CopyRect(TPoint(0,0), TRect(0,0,10,10)); + iBitGc->CopyRect(TPoint(0,0), TRect(0,0,10,10)); + + //cleanup + TheClient->Flush(); + TheGc->DiscardFont(); + iBitGc->DiscardFont(); + TheClient->iScreen->ReleaseFont(font1); + junkBuf.Close(); + junkBuf8.Close(); + TheGc->Deactivate(); + + CheckWindow(); + + //the following have no client equivalent methods + // EWsGcOpMapColorsLocal + // EWsGcOpDrawPolyLineLocalBufLen + // EWsGcOpDrawPolyLineLocal + // EWsGcOpDrawPolygonLocalBufLen + // EWsGcOpDrawPolygonLocal + // EWsGcOpDrawBitmapLocal + // EWsGcOpDrawBitmap2Local + // EWsGcOpDrawBitmap3Local + // EWsGcOpDrawBitmapMaskedLocal + // EWsGcOpDrawTextPtr1 + // EWsGcOpDrawBoxTextPtr1 + // EWsGcOpDrawTextVerticalPtr1 + // EWsGcOpDrawBoxTextVerticalPtr1 + // EWsGcOpDrawTextLocal + // EWsGcOpDrawBoxTextLocal + // EWsGcOpGdiBlt2Local + // EWsGcOpGdiBlt3Local + // EWsGcOpGdiBltMaskedLocal + ((CTBackedUpWindowStep*)iStep)->CloseTMSGraphicsStep(); + break; + } + + default: + ((CTBackedUpWindowStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + ((CTBackedUpWindowStep*)iStep)->CloseTMSGraphicsStep(); + break; + } + ((CTBackedUpWindowStep*)iStep)->RecordTestResultL(); + } + +__WS_CONSTRUCT_STEP__(BackedUpWindow) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TBACKUPW.H --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TBACKUPW.H Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,93 @@ + +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef __TBACKUPW_H__ +#define __TBACKUPW_H__ + +#include +#include +#include "../tlib/testbase.h" +#include +#include "AUTO.H" +#include "TGraphicsHarness.h" + +const TInt KLastSubtest = 13; + +class CTBackedUpWindow : public CTWsGraphicsBase + { +public: + CTBackedUpWindow(CTestStep* aStep); + ~CTBackedUpWindow(); + void DoTestL(); + void DoSubTestL(TInt iState); + void CheckWindow(); + void CheckWindow(CFbsBitmap *aBitmap); + void Draw(TInt aDrawFunc, TAny *aParam); + void Draw(TInt aDrawFunc, TAny *aParam, CBitmapContext *aGc1, CBitmapContext *aGc2); + void DrawWithTwoGcsL(); + void ConstructL(); + void InvisVis(); + void WindowOnTop(); + void Resize(); + void ChildWindows(); + void DupBitmapTestL(); + void UpdateBitmapTestL(); + void OOML(); + void TestPanicsL(); + void doGraphicFunctionsL(CBitmapContext *gc,TBool aExtraDrawBitMap); + void AllGraphicFunctionsL(RBlankWindow &aBlank,TBool aExtraDrawBitMap=ETrue); + void AllGraphicFunctionsTestsL(); +protected: +//from CTGraphicsStep + virtual void RunTestCaseL(TInt aCurTestCase); +private: + TInt iSupState; + TSize iSize; + TPoint iCheckPos; + TPoint iWinPos; + RWindow iCheckWindow; + RBackedUpWindow iBackedUpWindow; + RBlankWindow iOomFrontWindow; + CFbsBitmap iBitmap; + CFbsBitGc *iBitGc; + CFbsDevice *iBitmapDevice; + CFbsBitmap* iTestBitmap; + CFbsBitmap* iMaskBitmap; + }; + +LOCAL_D const TPoint moveList[]={TPoint(1,0),TPoint(10,20),TPoint(-50,0),TPoint(30,-1),TPoint(-1000,20)}; + + + +class CTBackedUpWindowStep : public CTGraphicsStep + { +public: + CTBackedUpWindowStep(); +protected: + //from CTGraphicsStep + virtual CTGraphicsBase* CreateTestL(); + }; + +_LIT(KTBackedUpWindowStep,"TBackedUpWindow"); + + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TBITMAP.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TBITMAP.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,226 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Test the window server bitmap class +// Test the window server bitmap class +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include "TBITMAP.H" + +// + +CTBitmap::CTBitmap(CTestStep* aStep): + CTWsGraphicsBase(aStep) + { + } + +CTBitmap::~CTBitmap() + { + delete iBitmap1; + delete iBitmap2; + } + +void CTBitmap::ConstructL() + { + } + +void CTBitmap::BasicTestsL() + { + iBitmap1=new(ELeave) CWsBitmap(TheClient->iWs); + iBitmap2=new(ELeave) CWsBitmap(TheClient->iWs); + User::LeaveIfError(iBitmap1->Create(TSize(20,10),EGray4)); +// Re-create should close previous Create + User::LeaveIfError(iBitmap1->Create(TSize(20,10),EGray4)); + User::LeaveIfError(iBitmap2->Duplicate(iBitmap1->Handle())); + TEST(iBitmap1->SizeInPixels()==iBitmap2->SizeInPixels()); + + TInt err=iBitmap2->Load(_L("NOTEXIST.XXX"),0); + TEST(err==KErrNotFound || err==KErrPathNotFound); + if (err!=KErrNotFound && err!=KErrPathNotFound) + INFO_PRINTF4(_L("Bitmap2->Load(_L(NOTEXIST.XXX),0) return value - Expected: %d or %d , Actual: %d"), KErrNotFound, KErrPathNotFound, err); + + TInt retVal = iBitmap2->Handle(); + TEST(retVal==0); + if (retVal!=0) + INFO_PRINTF3(_L("iBitmap2->Handle() return value - Expected: %d , Actual: %d"), 0, retVal); + + RFs fs; + User::LeaveIfError(fs.Connect()); + fs.SetNotifyUser(EFalse); + TInt ret=fs.MkDir(SAVE_BITMAP_NAME); + if (ret!=KErrNone && ret!=KErrAlreadyExists && ret!=KErrPathNotFound) + User::Leave(ret); + fs.Close(); +// + retVal = iBitmap1->Save(SAVE_BITMAP_NAME); + TEST(retVal==KErrNone); + if (retVal!=KErrNone) + INFO_PRINTF3(_L("iBitmap1->Save(SAVE_BITMAP_NAME) return value - Expected: %d , Actual: %d"), KErrNone, retVal); + + retVal = iBitmap2->Load(SAVE_BITMAP_NAME,0); + TEST(retVal==KErrNone); + if (retVal!=KErrNone) + INFO_PRINTF3(_L("iBitmap2->Load(SAVE_BITMAP_NAME,0) return value - Expected: %d , Actual: %d"), KErrNone, retVal); + + TEST(iBitmap1->SizeInPixels()==iBitmap2->SizeInPixels()); + } + + +void CTBitmap::TestFixForPDEF098889L() + { + TRequestStatus status; + TThreadParams params; + params.iScreenNr = TheClient->iWs.GetFocusScreen(); + + RThread thread1; + params.iFunction = Function1PDEF098889L; + TEST(thread1.Create(_L("PDEF098889_1"), ThreadFunction, 0x1000, NULL, ¶ms)==KErrNone); + thread1.Logon(status); + thread1.Resume(); + User::WaitForRequest(status); + TEST(status==KErrNone); + TEST(thread1.ExitType()==EExitKill); + thread1.Close(); + + RThread thread2; + params.iFunction = Function2PDEF098889L; + TEST(thread2.Create(_L("PDEF098889_2"), ThreadFunction, 0x1000, NULL, ¶ms)==KErrNone); + thread2.Logon(status); + thread2.Resume(); + User::WaitForRequest(status); + TEST(status==KErrNone); + TEST(thread2.ExitType()==EExitKill); + thread2.Close(); + } + +TInt CTBitmap::ThreadFunction(TAny* aParams) + { + CTrapCleanup *trap = CTrapCleanup::New(); + __ASSERT_ALWAYS(trap, User::Invariant()); + RWsSession session; + TInt err = session.Connect(); + if (err == KErrNone) + { + CWsScreenDevice *device = new CWsScreenDevice(session); + if (device) + { + err = device->Construct(static_cast(aParams)->iScreenNr); + if (err == KErrNone) + { + TRAP(err, static_cast(aParams)->iFunction(session, *device)); + } + delete device; + } + else + err = KErrNoMemory; + session.Close(); + } + delete trap; + return err; + } + +void CTBitmap::Function1PDEF098889L(RWsSession& aSession, CWsScreenDevice& aDevice) + { + CWindowGc *gc; + User::LeaveIfError(aDevice.CreateContext(gc)); + CleanupStack::PushL(gc); + RWindowGroup group(aSession); + User::LeaveIfError(group.Construct(1, EFalse)); + CWsBitmap *bitmap = new(ELeave) CWsBitmap(aSession); + CleanupStack::PushL(bitmap); + User::LeaveIfError(bitmap->Create(TSize(32, 32), EGray256)); + RWindow window(aSession); + User::LeaveIfError(window.Construct(group, 2)); + window.SetExtent(TPoint(0,0), TSize(32, 32)); + User::LeaveIfError(window.SetRequiredDisplayMode(EColor64K)); + window.Activate(); + window.BeginRedraw(); + gc->Activate(window); + gc->BitBlt(TPoint(0, 0), bitmap); + gc->Deactivate(); + window.EndRedraw(); + CleanupStack::PopAndDestroy(bitmap); + aSession.Flush(); + CleanupStack::PopAndDestroy(gc); + } + +void CTBitmap::Function2PDEF098889L(RWsSession& aSession, CWsScreenDevice& /*aDevice*/) + { + RWindowGroup group(aSession); + User::LeaveIfError(group.Construct(1, EFalse)); + CWsBitmap *bitmap = new(ELeave) CWsBitmap(aSession); + CleanupStack::PushL(bitmap); + User::LeaveIfError(bitmap->Create(TSize(32, 32), EGray256)); + RWindow window(aSession); + User::LeaveIfError(window.Construct(group, 2)); + window.SetExtent(TPoint(0,0), TSize(32, 32)); + User::LeaveIfError(window.SetRequiredDisplayMode(EColor64K)); + User::LeaveIfError(window.SetTransparencyWsBitmap(*bitmap)); + window.Activate(); + CleanupStack::PopAndDestroy(bitmap); + aSession.Flush(); + } + +void CTBitmap::RunTestCaseL(TInt /*aCurTestCase*/) + { + ((CTBitmapStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); + switch(++iTest->iState) + { +/** +@SYMTestCaseID GRAPHICS-WSERV-0201 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test basic bitmap functionality + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Test that bitmaps can be loaded, copied and saved + correctly + +@SYMTestExpectedResults The bitmaps are manipulated withotu error +*/ + case 1: + ((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0201")); + iTest->LogSubTest(_L("Bitmap1")); + BasicTestsL(); + break; + case 2: +/** +@SYMTestCaseID GRAPHICS-WSERV-0532 +*/ + ((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0532")); + if (TransparencySupportedL()==KErrNotSupported) + return; + iTest->LogSubTest(_L("Test fix for PDEF098889")); + TestFixForPDEF098889L(); + break; + default: + ((CTBitmapStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + ((CTBitmapStep*)iStep)->CloseTMSGraphicsStep(); + TestComplete(); + break; + } + ((CTBitmapStep*)iStep)->RecordTestResultL(); + } + +__WS_CONSTRUCT_STEP__(Bitmap) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TBITMAP.H --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TBITMAP.H Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,71 @@ + +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef __TBITMAP_H__ +#define __TBITMAP_H__ + +#include +#include +#include "../tlib/testbase.h" +#include "AUTO.H" +#include "TGraphicsHarness.h" + +#define SAVE_BITMAP_NAME _L("C:\\WSTEST\\SAVE.PBM") + +class CTBitmap : public CTWsGraphicsBase + { +public: + CTBitmap(CTestStep* aStep); + ~CTBitmap(); + void ConstructL(); + void BasicTestsL(); + void TestFixForPDEF098889L(); +private: + struct TThreadParams + { + TInt iScreenNr; + void (*iFunction)(RWsSession& aSession, CWsScreenDevice& aDevice); + }; + static TInt ThreadFunction(TAny* aParams); + static void Function1PDEF098889L(RWsSession& aSession, CWsScreenDevice& aDevice); + static void Function2PDEF098889L(RWsSession& aSession, CWsScreenDevice& aDevice); +protected: +//from CTGraphicsStep + virtual void RunTestCaseL(TInt aCurTestCase); +private: + CWsBitmap *iBitmap1; + CWsBitmap *iBitmap2; + }; + +class CTBitmapStep : public CTGraphicsStep + { +public: + CTBitmapStep(); +protected: + //from CTGraphicsStep + virtual CTGraphicsBase* CreateTestL(); + }; + +_LIT(KTBitmapStep,"TBitmap"); + + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TBLANK.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TBLANK.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,271 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Test blank windows +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + + +#include "TBLANK.H" + + +CBaseWindow::CBaseWindow() : CTWin() + {} + +void CBaseWindow::ConstructL(CTWinBase &parent) + { + CTWin::ConstructL(parent); + } + +void CBaseWindow::Draw() + { + iGc->SetBrushColor(iRgb); + iGc->Clear(); + } + +void CBaseWindow::SetColor(const TRgb &aRgb) + { + iRgb=aRgb; + iGc->Activate(iWin); + Draw(); + iGc->Deactivate(); + } + +// + +TInt DestructCallbackBlank(TAny *aParam) + { + ((CTBlank *)aParam)->doDestruct(); + return(0); + } + + +CTBlank::CTBlank(CTestStep* aStep): + CTWsGraphicsBase(aStep) + { + INFO_PRINTF1(_L("Testing TBlank functions")); + } + +void CTBlank::doDestruct() + { + BaseWin->SetVisible(ETrue); + TestWin->SetVisible(ETrue); + delete iBaseWin; + delete iTestWin; + iBaseWin = NULL; + iTestWin = NULL; +// CActiveScheduler::Stop(); + } + +CTBlank::~CTBlank() + { + TCallBack callBack(DestructCallbackBlank,this); + TheClient->SetRedrawCancelFunction(callBack); +// CActiveScheduler::Start(); + } + +void CTBlank::ConstructL() + { + BaseWin->SetVisible(EFalse); + TestWin->SetVisible(EFalse); + } + +void CTBlank::SetColor(const TRgb &aRgb) + { + iTestWin->SetColor(aRgb); + iBaseWin->SetColor(aRgb); + } + +void CTBlank::InvalidateTestWin(const TRect &aRect) + { + TRect rect(aRect); + rect.Move(iTestWin->BaseWin()->InquireOffset(*(TheClient->iGroup->WinTreeNode()))); + CTUser::Splat(TheClient, rect,TRgb(0,0,0)); + } + +void CTBlank::CheckBlankWindows() + { + User::Heap().Check(); + CheckRect(iBaseWin,iTestWin,TRect(BaseWin->Size()),_L("CheckBlankWindows - CheckRect(iBaseWin,iTestWin,TRect(BaseWin->Size()) failed")); + } + +void CTBlank::RunTestCaseL(TInt /*aCurTestCase*/) + { + TSize screenSize; + TInt winWidth; + TInt winHeight; + ((CTBlankStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); + + switch(++iTest->iState) + { +/** +@SYMTestCaseID GRAPHICS-WSERV-0022 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Create a base and test blank windows and invalidate an + area of the test window + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Two windows are created and an area of a window is + invalidated + +@SYMTestExpectedResults Windows create and invalidate without error +*/ + case 1: + ((CTBlankStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0022")); + iTest->LogSubTest(_L("Blank 1")); + screenSize=TheClient->iGroup->Size(); + winWidth=(screenSize.iWidth/3)-10; + winHeight=screenSize.iHeight-10; + iBaseWin=new(ELeave) CBaseWindow(); + iBaseWin->SetUpL(TPoint(screenSize.iWidth/3+5,5),TSize(winWidth,winHeight),TheClient->iGroup,*TheClient->iGc); + iBaseWin->SetColor(TRgb(255,255,255)); + iTestWin=new(ELeave) CTBlankWindow(); + iTestWin->SetUpL(TPoint(screenSize.iWidth/3*2+5,5),TSize(winWidth,winHeight),TheClient->iGroup,*TheClient->iGc); + SetColor(TRgb::Gray4(2)); + InvalidateTestWin(TRect(10,10,50,50)); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0023 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Check that a base blank window is the same as a + test window which has had an area invalidated + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Check the test window is the same as the base window + +@SYMTestExpectedResults The windows are identical +*/ + case 2: + ((CTBlankStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0023")); + iTest->LogSubTest(_L("Check Blank 1")); + CheckBlankWindows(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0024 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Set a color and invalidate two areas of a test blank + window + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Invalidate two areas of a test blank window + +@SYMTestExpectedResults The window areas are invalidated without error +*/ + case 3: + ((CTBlankStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0024")); + iTest->LogSubTest(_L("Blank 2")); + SetColor(TRgb(0,0,0)); + InvalidateTestWin(TRect(1,1,150,20)); + InvalidateTestWin(TRect(10,-10,20,90)); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0025 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Check a base blank window is identical to a test + blank window which has had two areas invalidated + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Check the test window is the same as the base window + +@SYMTestExpectedResults The windows are identical +*/ + case 4: + ((CTBlankStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0025")); + iTest->LogSubTest(_L("Check Blank 2")); + CheckBlankWindows(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0026 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Set a color and invalidate three areas of a test blank + window + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Invalidate three areas of a test blank window + +@SYMTestExpectedResults The window areas are invalidated without error +*/ + case 5: + ((CTBlankStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0026")); + iTest->LogSubTest(_L("Blank 3")); + SetColor(TRgb(255,255,255)); + InvalidateTestWin(TRect(-1000,100,1000,120)); + InvalidateTestWin(TRect(1,1,150,20)); + InvalidateTestWin(TRect(10,30,20,60)); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0027 + +@@SYMDEF DEF081259 + +@SYMTestCaseDesc Check a base blank window is identical to a test + blank window which has had three areas invalidated + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Check the test window is the same as the base window + +@SYMTestExpectedResults The windows are identical +*/ + case 6: + ((CTBlankStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0027")); + iTest->LogSubTest(_L("Check Blank 3")); + CheckBlankWindows(); + delete iBaseWin; + delete iTestWin; + iBaseWin = NULL; + iTestWin = NULL; + break; + case 7: + ((CTBlankStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + ((CTBlankStep*)iStep)->CloseTMSGraphicsStep(); + TestComplete(); + break; + } + ((CTBlankStep*)iStep)->RecordTestResultL(); + } + +__WS_CONSTRUCT_STEP__(Blank) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TBLANK.H --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TBLANK.H Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,76 @@ + +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef __TBLANK_H__ +#define __TBLANK_H__ + +#include +#include +#include "../tlib/testbase.h" +#include "AUTO.H" +#include "TGraphicsHarness.h" + +class CBaseWindow : public CTWin + { +public: + CBaseWindow(); + void ConstructL(CTWinBase &parent); + virtual void Draw(); + void SetColor(const TRgb &aRgb); +private: + TRgb iRgb; + }; + +class CTBlank : public CTWsGraphicsBase + { +public: + CTBlank(CTestStep* aStep); + ~CTBlank(); +protected: +//from CTGraphicsStep + virtual void RunTestCaseL(TInt aCurTestCase); +public: + void doDestruct(); + void ConstructL(); + void InvalidateTestWin(const TRect &aRect); + void CheckBlankWindows(); + void SetColor(const TRgb &aRgb); +private: + TBool iDoCheck; + TSize iWinSize; + CBaseWindow *iBaseWin; + CTBlankWindow *iTestWin; + }; + +class CTBlankStep : public CTGraphicsStep + { +public: + CTBlankStep(); +protected: + //from CTGraphicsStep + virtual CTGraphicsBase* CreateTestL(); + }; + +_LIT(KTBlankStep,"TBlank"); + + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TBUFFERSECURITY.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TBUFFERSECURITY.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,457 @@ +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// DEF075471 buffer security test +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include "TBUFFERSECURITY.H" +#include "graphics/windowserverconstants.h" + +//Set this #define in buffersecurity.h to add extra logging to this test case (useful when debugging a test fail) +//#define _TBUFS_LOGGING + +//Set this #define in buffersecurity.h to initiate a long running soak test, this should be done periodically +//#define _TBUFS_TEST_SOAK_TEST + + + +LOCAL_C TInt TestWsThreadFunc(TAny* aPtr) + { + TTestThreadData* data = (TTestThreadData*)aPtr; + RWsSession ws; + + TInt err=ws.Connect(); + if (err!=KErrNone) + return(err); + ws.TestWrite(ws.WsHandle(), data->iOpCode, data->iData, data->iDataLength); + ws.Flush(); + ws.Close(); + + return(KErrNone); + } + +LOCAL_C TInt TestAnimDllThreadFunc(TInt aInt, TAny* /*aPtr*/) + { + TBool useTestWrite = (TBool)aInt; + + RWsSession ws; + TInt err=ws.Connect(); + if (err != KErrNone) + return (err); + if (useTestWrite) + { + TUint32 data[2]; + data[0] = 200; + data[1] = 4; + ws.TestWrite(ws.WsHandle(), EWsClOpCreateAnimDll, REINTERPRET_CAST(TUint8*,data), 8); + ws.Flush(); + } + else + { + RAnimDll animDll(ws); + const TPtrC filename(REINTERPRET_CAST(TUint16*,4),200); + animDll.Load(filename); + animDll.Close(); + } + ws.Close(); + + return(KErrNone); + } + +TInt RTestIpcSession::Connect() + { + TVersion v(KWservMajorVersionNumber,KWservMinorVersionNumber,KWservBuildVersionNumber); + TInt err = CreateSession(KWSERVServerName,v); + if (err == KErrNone) + { + err=iWsHandle=SendReceive(EWservMessInit,TIpcArgs()); + } + return err; + } + +TInt RTestIpcSession::SendBadBuffer() + { + TIpcArgs ipcArgs; + TUint32 iData[2]; + iData[0] = 200; + iData[1] = 4; + ipcArgs.Set(KBufferMessageSlot,&iData); + return SendReceive(EWservMessCommandBuffer,ipcArgs); + } + +LOCAL_C TInt TestIpcThreadFunc(TInt /*aInt*/, TAny* /*aPtr*/) + { + RTestIpcSession server; + + TInt handle=server.Connect(); + if (handle >= KErrNone) + server.SendBadBuffer(); + + return(KErrNone); + } + + +CTBufferSecurity::CTBufferSecurity(CTestStep* aStep): + CTWsGraphicsBase(aStep) + { + } + +CTBufferSecurity::~CTBufferSecurity() + { + } + +void CTBufferSecurity::ConstructL() + { + RProperty securityTesting; + TInt err=securityTesting.Attach(KUidWServSecurityTesting,EWServSecTestBufferSecurity); + User::LeaveIfError(err); + err=securityTesting.Define(KUidWServSecurityTesting,EWServSecTestBufferSecurity,RProperty::EInt,KAllowAllPolicy,KWriteDeviceDataMgmtPolicy); + if (err!=KErrAlreadyExists) + User::LeaveIfError(err); + TInt value = ETrue; + err = securityTesting.Set(value); + User::LeaveIfError(err); + } + +void CTBufferSecurity::TestWsBufferL(TInt aOpCode, TUint aDataFill, TBool aEightBit) + { + // create a new thread in which to test each of the TWsClientOpCode values + // so if the thread is panicked the test will not fail. + RThread testThread; + TTestThreadData data; + TRequestStatus status; + TUint8 storeData[KTestDataMax]; + TTestDataStore store; + store.any=storeData; + + //collect initial values + for (TInt count = 0; count < KTestDataMax; count++) + storeData[count] = 0; + switch (aOpCode) + { + case EWsClOpHeapSetFail: + store.heapSetFail->type = RAllocator::ENone; + break; + case EWsClOpSetPointerCursorArea: + store.cursorArea->area = TheClient->iWs.PointerCursorArea(); + break; + case EWsClOpRawEvent: + //skip switch off (would need a timer to turn it back on again) + if (aDataFill == TRawEvent::ESwitchOff) + aDataFill = TRawEvent::ENone; + break; +#if defined(__WINS__) + case EWsClOpSimulateXyInput: + *store.xyInputType = EXYInputMouse; + break; +#endif + } + + data.iOpCode = aOpCode; + if (aEightBit) + { + for (TInt count = 0; count < KTestDataMax; count++) + data.iData[count] = (TUint8)aDataFill; + } + else + { + for (TInt count = 0; count < KTestDataMax32; count++) + data.iData32[count] = aDataFill; + } + data.iDataLength = KTestDataMax; + _LIT(KThreadNameFormat,"BufSecTestWsThread-%d-%d"); + HBufC* threadName = HBufC::NewLC(KThreadNameFormat().Size() + 32); + TPtr threadNamePtr(threadName->Des()); + threadNamePtr.Format(KThreadNameFormat(), aOpCode, aDataFill); + TInt err = testThread.Create(threadNamePtr, TestWsThreadFunc,KDefaultStackSize,KPanicThreadHeapSize,KPanicThreadHeapSize,(TAny*)&data,EOwnerThread); + + if (err != KErrNone) + { + User::After(100000); + err = testThread.Create(threadNamePtr,TestWsThreadFunc,KDefaultStackSize,KPanicThreadHeapSize,KPanicThreadHeapSize,(TAny*)&data,EOwnerThread); + } + CleanupStack::PopAndDestroy(threadName); + testThread.Logon(status); + User::SetJustInTime(EFalse); + testThread.Resume(); + User::WaitForRequest(status); + User::SetJustInTime(ETrue); +#ifdef _TBUFS_LOGGING + TLogMessageText logMessageText; + TBufSStartLogText("TestWsBufferL"); + logMessageText.Format(_L(" OpCode(%d), ExitReason: %d"),aOpCode,testThread.ExitReason()); + TBufSLogFormat(logMessageText); +#endif + + testThread.Close(); + //reset some values to sensible ones + switch (aOpCode) + { + case EWsClOpHeapSetFail: + case EWsClOpSetPointerCursorArea: +#if defined(__WINS__) + case EWsClOpSimulateXyInput: +#endif + RThread resetThread; + TheClient->iWs.TestWrite(TheClient->iWs.WsHandle(), data.iOpCode, storeData, data.iDataLength); + TheClient->iWs.Flush(); + break; + } + } + +void CTBufferSecurity::TestBadStringAnimDllL() + { + TEST(iTest->TestPanicL(&TestAnimDllThreadFunc,3,EFalse,NULL,KLitKernExec)); + } + +void CTBufferSecurity::TestBadStringL() + { + TEST(iTest->TestWsPanicL(&TestAnimDllThreadFunc,EWservPanicBufferPtr,ETrue,NULL)); + } + +void CTBufferSecurity::TestBadIpcL() + { + TEST(iTest->TestWsPanicL(&TestIpcThreadFunc,EWservPanicDescriptor,1)); + } + +void CTBufferSecurity::RunTestCaseL(TInt /*aCurTestCase*/) + { + TInt ii; + ((CTBufferSecurityStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); + switch(++iTest->iState) + { + case 1: + ((CTBufferSecurityStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0022")); + _LIT(KBuffSecTestBadIpcL,"TestBadIpcL"); + iTest->LogSubTest(KBuffSecTestBadIpcL); + TestBadIpcL(); + break; + case 2: +/** +@SYMTestCaseID GRAPHICS-WSERV-0549 +*/ + ((CTBufferSecurityStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0549")); + _LIT(KBuffSecTestBadStringLRAnimDll,"TestBadStringL use RAnimDll"); + iTest->LogSubTest(KBuffSecTestBadStringLRAnimDll); + TestBadStringAnimDllL(); + break; + case 3: +/** +@SYMTestCaseID GRAPHICS-WSERV-0550 +*/ + ((CTBufferSecurityStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0550")); + _LIT(KBuffSecTestBadStringLTestWrite,"TestBadStringL use TestWrite"); + iTest->LogSubTest(KBuffSecTestBadStringLTestWrite); + TestBadStringL(); + break; +#ifdef _TBUFS_TEST_SOAK_TEST + case 4: +/** +@SYMTestCaseID GRAPHICS-WSERV-0551 +*/ + ((CTBufferSecurityStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0551")); + _LIT(KBuffSecTestWsBufferLSoak8bit,"TestWsBufferL Soak 8bit"); + iTest->LogSubTest(KBuffSecTestWsBufferLSoak8bit); + for(ii = EWsClOpDisconnect; ii < EWsClOpLastEnumValue; ii++) + { + TUint8 soak8=0;//gets set as KMaxTUint8 on first iteration + do + { + --soak8; + TestWsBufferL(ii,soak8); + } + while (soak8>0); + } + break; + case 5: +/** +@SYMTestCaseID GRAPHICS-WSERV-0552 +*/ + ((CTBufferSecurityStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0552")); + _LIT(KBuffSecTestWsBufferLSoak32bit,"TestWsBufferL Soak 32bit"); + iTest->LogSubTest(KBuffSecTestWsBufferLSoak32bit); + for(ii = EWsClOpDisconnect; ii < EWsClOpLastEnumValue; ii++) + { + TUint32 soak32=0;//gets set as KMaxTUint8 on first iteration + do + { + --soak32; + TestWsBufferL(ii,soak32,EFalse); + } + while (soak32>0); + } + break; +#else + case 4: +/** +@SYMTestCaseID GRAPHICS-WSERV-0553 +*/ + ((CTBufferSecurityStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0553")); + _LIT(KBuffSecTestWsBufferL0,"TestWsBufferL 0"); + iTest->LogSubTest(KBuffSecTestWsBufferL0); + for(ii = EWsClOpDisconnect; ii < EWsClOpLastEnumValue; ii++) + { + TestWsBufferL(ii,0); + } + break; + case 5: +/** +@SYMTestCaseID GRAPHICS-WSERV-0554 +*/ + ((CTBufferSecurityStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0554")); + _LIT(KBuffSecTestWsBufferL5,"TestWsBufferL 5"); + iTest->LogSubTest(KBuffSecTestWsBufferL5); + for(ii = EWsClOpDisconnect; ii < EWsClOpLastEnumValue; ii++) + { + TestWsBufferL(ii,5); + } + break; + case 6: +/** +@SYMTestCaseID GRAPHICS-WSERV-0555 +*/ + ((CTBufferSecurityStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0555")); + _LIT(KBuffSecTestWsBufferL32,"TestWsBufferL 32"); + iTest->LogSubTest(KBuffSecTestWsBufferL32); + for(ii = EWsClOpDisconnect; ii < EWsClOpLastEnumValue; ii++) + { + TestWsBufferL(ii,32); + } + break; + case 7: +/** +@SYMTestCaseID GRAPHICS-WSERV-0556 +*/ + ((CTBufferSecurityStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0556")); + _LIT(KBuffSecTestWsBufferL64,"TestWsBufferL 64"); + iTest->LogSubTest(KBuffSecTestWsBufferL64); + for(ii = EWsClOpDisconnect; ii < EWsClOpLastEnumValue; ii++) + { + TestWsBufferL(ii,64); + } + break; + case 8: +/** +@SYMTestCaseID GRAPHICS-WSERV-0557 +*/ + ((CTBufferSecurityStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0557")); + _LIT(KBuffSecTestWsBufferL128,"TestWsBufferL 128"); + iTest->LogSubTest(KBuffSecTestWsBufferL128); + for(ii = EWsClOpDisconnect; ii < EWsClOpLastEnumValue; ii++) + { + TestWsBufferL(ii,128); + } + break; + case 9: +/** +@SYMTestCaseID GRAPHICS-WSERV-0558 +*/ + ((CTBufferSecurityStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0558")); + _LIT(KBuffSecTestWsBufferL255,"TestWsBufferL 255"); + iTest->LogSubTest(KBuffSecTestWsBufferL255); + for(ii = EWsClOpDisconnect; ii < EWsClOpLastEnumValue; ii++) + { + TestWsBufferL(ii,255); + } + break; + case 10: +/** +@SYMTestCaseID GRAPHICS-WSERV-0559 +*/ + ((CTBufferSecurityStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0559")); + _LIT(KBuffSecTestWsBufferL325,"TestWsBufferL 32-5"); + iTest->LogSubTest(KBuffSecTestWsBufferL325); + for(ii = EWsClOpDisconnect; ii < EWsClOpLastEnumValue; ii++) + { + TestWsBufferL(ii,5,EFalse); + } + break; + case 11: +/** +@SYMTestCaseID GRAPHICS-WSERV-0560 +*/ + ((CTBufferSecurityStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0560")); + _LIT(KBuffSecTestWsBufferL32128,"TestWsBufferL 32-128"); + iTest->LogSubTest(KBuffSecTestWsBufferL32128); + for(ii = EWsClOpDisconnect; ii < EWsClOpLastEnumValue; ii++) + { + TestWsBufferL(ii,128,EFalse); + } + break; + case 12: +/** +@SYMTestCaseID GRAPHICS-WSERV-0561 +*/ + ((CTBufferSecurityStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0561")); + _LIT(KBuffSecTestWsBufferL32512,"TestWsBufferL 32-512"); + iTest->LogSubTest(KBuffSecTestWsBufferL32512); + for(ii = EWsClOpDisconnect; ii < EWsClOpLastEnumValue; ii++) + { + TestWsBufferL(ii,512,EFalse); + } + break; + case 13: +/** +@SYMTestCaseID GRAPHICS-WSERV-0562 +*/ + ((CTBufferSecurityStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0562")); + _LIT(KBuffSecTestWsBufferL320x01234567,"TestWsBufferL 32-0x01234567"); + iTest->LogSubTest(KBuffSecTestWsBufferL320x01234567); + for(ii = EWsClOpDisconnect; ii < EWsClOpLastEnumValue; ii++) + { + TestWsBufferL(ii,0x01234567,EFalse); + } + break; + case 14: +/** +@SYMTestCaseID GRAPHICS-WSERV-0563 +*/ + ((CTBufferSecurityStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0563")); + _LIT(KBuffSecTestWsBufferL320x89abcdef,"TestWsBufferL 32-0x89abcdef"); + iTest->LogSubTest(KBuffSecTestWsBufferL320x89abcdef); + for(ii = EWsClOpDisconnect; ii < EWsClOpLastEnumValue; ii++) + { + TestWsBufferL(ii,0x89abcdef,EFalse); + } + break; + case 15: +/** +@SYMTestCaseID GRAPHICS-WSERV-0564 +*/ + ((CTBufferSecurityStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0564")); + _LIT(KBuffSecTestWsBufferL320xCCCCCCCC,"TestWsBufferL 32-0xCCCCCCCC"); + iTest->LogSubTest(KBuffSecTestWsBufferL320xCCCCCCCC); + for(ii = EWsClOpDisconnect; ii < EWsClOpLastEnumValue; ii++) + { + TestWsBufferL(ii,0xCCCCCCCC,EFalse); + } + break; +#endif + default: + ((CTBufferSecurityStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + ((CTBufferSecurityStep*)iStep)->CloseTMSGraphicsStep(); + TInt err = RProperty::Set(KUidWServSecurityTesting,EWServSecTestBufferSecurity,EFalse); + User::LeaveIfError(err); + TestComplete(); + } + ((CTBufferSecurityStep*)iStep)->RecordTestResultL(); + } + +__WS_CONSTRUCT_STEP__(BufferSecurity) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TBUFFERSECURITY.H --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TBUFFERSECURITY.H Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,132 @@ +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// DEF075471 buffer security test +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef __TBUFFERSECURITY_H__ +#define __TBUFFERSECURITY_H__ + +#include "AUTO.H" +#include "../tlib/testbase.h" +#include +#include "../SERVER/w32cmd.h" + +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA +#include "../nonnga/CLIENT/w32comm.h" +#endif + +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA +#include "../nga/CLIENT/w32comm.h" +#endif + +#include +#include "TGraphicsHarness.h" + +//Set this #define to add extra logging to this test case (useful when debugging a test fail) +//#define _TBUFS_LOGGING + +//Set this #define to initiate a long running soak test, this should be done periodically +//#define _TBUFS_TEST_SOAK_TEST + +#ifdef _TBUFS_LOGGING +#define TBufSStartLogText StartLogText +#define TBufSLogText LogText +#define TBufSLogFormat LogFormat +#else +#define TBufSStartLogText +#define TBufSLogText +#define TBufSLogFormat +#endif + +LOCAL_D const TUint KPanicThreadHeapSize=0x4000; + +_LIT(KLitKernExec, "KERN-EXEC"); +_LIT(KTestName, "DEF086238 Buffer Security Test"); +static _LIT_SECURITY_POLICY_PASS(KAllowAllPolicy); +static _LIT_SECURITY_POLICY_C1(KWriteDeviceDataMgmtPolicy,ECapabilityWriteDeviceData); +const TInt KTestDataMax = 256; +const TInt KTestDataMax32 = KTestDataMax/4; + +struct TTestThreadData + { + TInt iOpCode; + union + { + TUint8 iData[KTestDataMax]; + TUint32 iData32[KTestDataMax32]; + }; + TInt iDataLength; + }; + +enum KBufSecTestType + { + EBufSecUnInitialised, + EBufSecRandom, + EBufSecZero + }; + +union TTestDataStore + { + TAny *any; + TWsClCmdSetPointerCursorArea* cursorArea; + TWsClCmdHeapSetFail *heapSetFail; + TXYInputType *xyInputType; + }; + +class CTBufferSecurity : public CTWsGraphicsBase + { +public: + CTBufferSecurity(CTestStep* aStep); + ~CTBufferSecurity(); + void TestWsBufferL(TInt aOpCode, TUint aDataFill, TBool aEightBit=ETrue); + void TestBadStringAnimDllL(); + void TestBadStringL(); + void TestBadIpcL(); + void ConstructL(); +protected: +//from CTGraphicsStep + virtual void RunTestCaseL(TInt aCurTestCase); +private: + void TestBufferSecurityL(); + }; + +class RTestIpcSession : public RSessionBase + { +public: + inline RTestIpcSession() {}; + TInt Connect(); + TInt SendBadBuffer(); +private: + TInt iWsHandle; + }; + +class CTBufferSecurityStep : public CTGraphicsStep + { +public: + CTBufferSecurityStep(); +protected: + //from CTGraphicsStep + virtual CTGraphicsBase* CreateTestL(); + }; + +_LIT(KTBufferSecurityStep,"TBufferSecurity"); + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TCAPABILITY.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TCAPABILITY.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,263 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Capability test +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include "TCAPABILITY.H" + +_LIT(KTestResultsFile, "C:\\DATA\\TestResult.Dat"); +_LIT(KSpace, " "); +_LIT(KTest0Name, "All capabilities"); +_LIT(KTest0Exe, "TCAP_ALL.exe"); +_LIT(KTest0Cap, "CAPABILITY_ALL"); +_LIT(KTest1Name, "No capabilities"); +_LIT(KTest1Exe, "TCAP_NONE.exe"); +_LIT(KTest1Cap, "CAPABILITY_NONE"); +_LIT(KTest2Name, "WriteDeviceData and SwEvent capabilities"); +_LIT(KTest2Exe, "TCAP_ONE.exe"); +_LIT(KTest2Cap, "WRITEDATA+SWEVENT"); +_LIT(KTest3Name, "WriteDeviceData and PowerMgnt capabilities"); +_LIT(KTest3Exe, "TCAP_TWO.exe"); +_LIT(KTest3Cap, "WRITEDATA+POWERMGMT"); +_LIT(KTest4Name, "PowerMgnt and SwEvent capabilities"); +_LIT(KTest4Exe, "TCAP_THREE.exe"); +_LIT(KTest4Cap, "POWERMGMT+SWEVENT"); + + +//CCapabilityTest +CTCapability::CTCapability(CTestStep* aStep): + CTWsGraphicsBase(aStep) + { + } + +CTCapability::~CTCapability() + { + } + +void CTCapability::ConstructL() + { + //Empty function ConstructL is pure virtual function and this + //definition required to satisfy the compiler + } + +//Reads the shared files which contains the total tests run and tests passed. +void CTCapability::GetCapabilityTestResultsL(TInt& aNoOfTests, TInt& aNoOfTestsPass) + { + TBuf<256> noOfTest; + TBuf<256> noOfTestPass; + RFs fileSession; + RFile file; + TFileText textFile; + User::LeaveIfError(fileSession.Connect()); + CleanupClosePushL(fileSession); + User::LeaveIfError(file.Open(fileSession,KTestResultsFile,EFileRead)); + CleanupClosePushL(file); + textFile.Set(file); + if(textFile.Read(noOfTest)==KErrNone) + { + TLex lexVar(noOfTest); + lexVar.Val(aNoOfTests); + if(textFile.Read(noOfTestPass)==KErrNone) + { + lexVar=noOfTestPass; + lexVar.Val(aNoOfTestsPass); + } + else + { + aNoOfTestsPass=0; + } + } + CleanupStack::PopAndDestroy(&file); + CleanupStack::PopAndDestroy(&fileSession); + } + + void CTCapability::LaunchNewProcess(const TDesC& aExecutable,const TDesC& aCapability) + { + TBuf<128> args; + args.Append(aCapability); + args.Append(KSpace); + args.AppendNum(TheClient->iGroup->GroupWin()->Identifier()); + RProcess pr; +// TInt noOfTest,noOfTestPass; + if (pr.Create(aExecutable,args)==KErrNone) + { + TRequestStatus status=NULL; + pr.Logon(status); + pr.Resume(); + User::WaitForRequest(status); + //Close all the panic windows to avoid "Hangs the H4" + //PDEF100501: TEF Migrated Test TCapability Hangs the H4 + if (iTest->iScreenNumber == 0) + iTest->CloseAllPanicWindows(); + pr.Close(); +// GetCapabilityTestResultsL(noOfTest,noOfTestPass); +// UpdateTestResults(noOfTest,noOfTestPass); + } + } + +void CTCapability::RunTestCaseL(TInt /*aCurTestCase*/) + { + ((CTCapabilityStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); + switch(++iTest->iState) + { +/** + + @SYMTestCaseID GRAPHICS-WSERV-0305 + + @SYMDEF DEF081259 + + @SYMTestCaseDesc Capability test with a process with all capability + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions The security threat API's are called with all + capability to test whether the API's are accessible or not. + + @SYMTestExpectedResults If the required capability is defined to test code then API should + accessible, otherwise it should panic the test. + +*/ + case 1: + ((CTCapabilityStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0305")); + iTest->LogSubTest(KTest0Name); + LaunchNewProcess(KTest0Exe, KTest0Cap); + break; +/** + + @SYMTestCaseID GRAPHICS-WSERV-0306 + + @SYMDEF DEF081259 + + @SYMTestCaseDesc Capability test with a process with no capability + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions The security threat API's are called with no + capability to test whether the API's are accessible or not. + + @SYMTestExpectedResults If the required capability is defined to test code then API should + accessible, otherwise it should panic the test. + +*/ + case 2: + ((CTCapabilityStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0306")); + //create process with no capability + RDebug::Print(KPlatsecBegin); + iTest->LogSubTest(KTest1Name); + LaunchNewProcess(KTest1Exe,KTest1Cap); + break; +/** + + @SYMTestCaseID GRAPHICS-WSERV-0307 + + @SYMDEF DEF081259 + + @SYMTestCaseDesc Capability test with a process with WriteDevicedata and SwEvent capability + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions The security threat API's are called with WriteDevicedata and SwEvent + capability to test whether the API's are accessible or not. + + @SYMTestExpectedResults If the required capability is defined to test code then API should + accessible, otherwise it should panic the test. + +*/ + case 3: + ((CTCapabilityStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0307")); + //create process with WriteDevicedata and SwEvent capability + iTest->LogSubTest(KTest2Name); + LaunchNewProcess(KTest2Exe,KTest2Cap); + break; +/** + + @SYMTestCaseID GRAPHICS-WSERV-0308 + + @SYMDEF DEF081259 + + @SYMTestCaseDesc Capability test with a process with WriteDevicedata and PowerMgmt capability + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions The security threat API's are called with WriteDevicedata and PowerMgmt + capability to test whether the API's are accessible or not. + + @SYMTestExpectedResults If the required capability is defined to test code then API should + accessible, otherwise it should panic the test. + +*/ + case 4: + ((CTCapabilityStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0308")); + //create process with WriteDevicedata and PowerMgmt capability + iTest->LogSubTest(KTest3Name); + LaunchNewProcess(KTest3Exe,KTest3Cap); + break; +/** + + @SYMTestCaseID GRAPHICS-WSERV-0309 + + @SYMDEF DEF081259 + + @SYMTestCaseDesc Capability test with a process with PowerMgmt and SwEvent capability + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions The security threat API's are called with PowerMgmt and SwEvent + capability to test whether the API's are accessible or not. + + @SYMTestExpectedResults If the required capability is defined to test code then API should + accessible, otherwise it should panic the test. + +*/ + case 5: + ((CTCapabilityStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0309")); + //create process with PowerMgmt and SwEvent capability + iTest->LogSubTest(KTest4Name); + LaunchNewProcess(KTest4Exe, KTest4Cap); + break; + default : + ((CTCapabilityStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + ((CTCapabilityStep*)iStep)->CloseTMSGraphicsStep(); + RDebug::Print(KPlatsecEnd); + RFs fileSession; + User::LeaveIfError(fileSession.Connect()); + CleanupClosePushL(fileSession); + CFileMan *fileMan=CFileMan::NewL(fileSession); + fileMan->Delete(KTestResultsFile); + delete fileMan; + CleanupStack::PopAndDestroy(&fileSession); + TestComplete(); + break; + } + ((CTCapabilityStep*)iStep)->RecordTestResultL(); + } + +__WS_CONSTRUCT_STEP__(Capability) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TCAPABILITY.H --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TCAPABILITY.H Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,56 @@ + +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef __TCAPABILITY_H__ +#define __TCAPABILITY_H__ + +#include "AUTO.H" +#include "../tlib/testbase.h" +#include "TGraphicsHarness.h" + +class CTCapability : public CTWsGraphicsBase + { +public: + CTCapability(CTestStep* aStep); + ~CTCapability(); + void ConstructL(); +protected: +//from CTGraphicsStep + virtual void RunTestCaseL(TInt aCurTestCase); +private: + void GetCapabilityTestResultsL(TInt& aNoOfTest, TInt&aNoOfTestPass); + void LaunchNewProcess(const TDesC& aExecutableName,const TDesC& acapability); + }; + +class CTCapabilityStep : public CTGraphicsStep + { +public: + CTCapabilityStep(); +protected: + //from CTGraphicsStep + virtual CTGraphicsBase* CreateTestL(); + }; + +_LIT(KTCapabilityStep,"TCapability"); + + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TCapKey.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TCapKey.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,877 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Test capture key +// Coverted from TMan test code (TMCAPKEY.CPP) October 2000 +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + + +#include "TCapKey.H" + +#define LOGGING on + +// +// CAbortHandler + +CAbortHandler::CAbortHandler(RWsSession *aWs, CCKAbortConnection *aConnection) : CTEventBase(aWs, 10), iConnection(aConnection) + { + } + +CAbortHandler::~CAbortHandler() + { + Cancel(); + } + +void CAbortHandler::Request() + { + iWs->PriorityKeyReady(&iStatus); + SetActive(); + } + +void CAbortHandler::DoCancel() + { + iWs->PriorityKeyReadyCancel(); + } + +void CAbortHandler::doRunL() + { + TWsPriorityKeyEvent abortEvent; + iWs->GetPriorityKey(abortEvent); + iConnection->ReceivedAbortEvent(abortEvent.Handle(),abortEvent.Key()); + } + +// +// CCKConnection + +CCKConnectionBase::CCKConnectionBase(CTCaptureKey *aTest) : iTest(aTest) + { + } + +void CCKConnectionBase::ConstructL() + { + CTClient::SetScreenNumber(iTest->ScreenNumber()); + CTClient::ConstructL(); + iGroup=new(ELeave) CCKWindowGroup(this, iTest); + iGroup->ConstructL(); + } + +CCKConnection::CCKConnection(CTCaptureKey *aTest, TInt aConnIndex) : CCKConnectionBase(aTest), iConnIndex(aConnIndex) + { + } + +CCKConnection::~CCKConnection() + { + for(TInt index=0;indexGroupWin()->CancelCaptureKey(capKeyHandle[index]); + for(TInt index1=0;index1GroupWin()->CancelCaptureKey(capKeyWithPriorityHandle[index1]); + for(TInt index2=0;index2GroupWin()->CancelCaptureKeyUpAndDowns(capUpDownKeyHandle[index2]); + for(TInt index3=0;index3GroupWin()->CancelCaptureKeyUpAndDowns(capUpDownKeyWithPriorityHandle[index3]); + CTWin::Delete(iWin); + } + +void CCKConnection::SubStateChanged() + { + iWin->Invalidate(); + iWs.Flush(); + } + +void CCKConnection::ConstructL() + { + CCKConnectionBase::ConstructL(); + for(TInt index=0;indexGroupWin()->CaptureKey(capKeys[index].keyCode,capKeys[index].modifier_mask,capKeys[index].modifiers)); + for(TInt index1=0;index1GroupWin()->CaptureKey(capKeysWithPriority[index1].keyCode,capKeysWithPriority[index1].modifier_mask,capKeysWithPriority[index1].modifiers,capKeysWithPriority[index1].priority)); + for(TInt index2=0;index2GroupWin()->CaptureKeyUpAndDowns(capUpAndDownKeys[index2].keyCode, + capUpAndDownKeys[index2].modifier_mask,capUpAndDownKeys[index2].modifiers)); + for(TInt index3=0;index3GroupWin()->CaptureKeyUpAndDowns(capUpAndDownKeysWithPriority[index3].keyCode, + capUpAndDownKeysWithPriority[index3].modifier_mask,capUpAndDownKeysWithPriority[index3].modifiers,capUpAndDownKeysWithPriority[index3].priority)); + TSize screenSize=iGroup->Size(); + TInt winWidth=screenSize.iWidth/2; + TInt winHeight=screenSize.iHeight-10; + iGroup->GroupWin()->AutoForeground(EFalse); // Don't allow clicking to cause foreground, might mess up test + CCKWindow *win=new(ELeave) CCKWindow(iTest, iConnIndex); + win->SetUpL(TPoint(5,5),TSize(winWidth,winHeight),iGroup,*iGc); + iWin=win; + } + +void CCKConnection::KeyTestL(TInt aBool) + { + if (!aBool) + { + CTDialog *dialog= new(ELeave) CTDialog(); + TInt ret=0; + if (dialog) + { + dialog->ConstructLD(*iGroup,*iGc); + dialog->SetTitle(_L("Invalid key press")); + dialog->SetLine1(_L("Try again?")); + dialog->SetNumButtons(2); + dialog->SetButtonText(0,_L("Fail")); + dialog->SetButtonText(1,_L("Retry")); + ret=dialog->Display(); + } + User::Leave(ret==1 ? ECapKeyRetry : ECapKeyFail); + } + } + +void CCKConnection::CheckKeyL(const SCapKeyTestParams &aKeyTest, const TKeyEvent &aKey) + { + KeyTestL(aKeyTest.keyCode==aKey.iCode); + KeyTestL(aKeyTest.modifiers==(aKey.iModifiers&aKeyTest.modifier_mask)); + } + +void CCKConnection::CheckUpDownL(const SCapKeyTestParams &aKeyTest, const TKeyEvent &aKey) + { + if(iTest->Mode()==EModeKeyUpsAndDownsWithPriority) + KeyTestL(aKeyTest.connIndex==iTest->SubState()-15); + KeyTestL(aKeyTest.connIndex==iConnIndex); + KeyTestL(aKeyTest.keyCode==(TUint)aKey.iScanCode); + KeyTestL(aKeyTest.modifiers==(aKey.iModifiers&aKeyTest.modifier_mask)); + } + +void CCKConnection::KeyL(const TKeyEvent &aKey,const TTime &) + { +#if defined(LOGGING) + _LIT(KLog,"CCKConnection::KeyL State=%d SubState=%d Mode=%d KeyCode=%d ScanCode=%d Mod=0x%x"); + iTest->LOG_MESSAGE7(KLog,iTest->State(),iTest->SubState(),iTest->Mode(),aKey.iCode,aKey.iScanCode,aKey.iModifiers); +#endif + if (iTest->Mode()==EModeNormalCapture || iTest->Mode()==EModeNormalCaptureWithPriority) + { + //if (aKey.iCode==EKeyEscape) + // iTest->Abort(); + if(iTest->Mode()==EModeNormalCaptureWithPriority) + { + SCapKeyTestParams tmpCapKeyTest=capKeyTests[iTest->SubState()]; + KeyTestL(tmpCapKeyTest.connIndex==iTest->SubState()-8); + } + TRAPD(ret,CheckKeyL(capKeyTests[iTest->SubState()],aKey)); + if (ret==ECapKeyOkay) + iTest->IncSubState(); + else + { + iTest->TEST(ret==ECapKeyRetry); + if (ret!=ECapKeyRetry) + iTest->INFO_PRINTF3(_L("CheckKeyL(capKeyTests[iTest->SubState()],aKey) return value - Expected: %d, Actual: %d"), ECapKeyRetry, ret); + } + + } + } + +void CCKConnection::CheckUpDownL(const TKeyEvent &aKey) + { + CheckUpDownL(capKeyTests[iTest->SubState()],aKey); + } + +CCKAbortConnection::CCKAbortConnection(CTCaptureKey *aTest) : CCKConnectionBase(aTest) + { + } + +CCKAbortConnection::~CCKAbortConnection() + { + iGroup->GroupWin()->RemovePriorityKey(3,EModifierCtrl,EModifierCtrl); + delete iAbortHandler; + } + +void CCKAbortConnection::ConstructL() + { + CCKConnectionBase::ConstructL(); + User::LeaveIfError(iGroup->GroupWin()->AddPriorityKey(abortKeyTests[0].keyCode,abortKeyTests[0].modifier_mask,abortKeyTests[0].modifiers)); + User::LeaveIfError(iGroup->GroupWin()->AddPriorityKey(abortKeyTests[1].keyCode,abortKeyTests[1].modifier_mask,abortKeyTests[1].modifiers)); + User::LeaveIfError(iGroup->GroupWin()->AddPriorityKey(abortKeyTests[2].keyCode,abortKeyTests[2].modifier_mask,abortKeyTests[2].modifiers)); + iAbortHandler=new(ELeave) CAbortHandler(&iWs, this); + iAbortHandler->Construct(); + iWs.Flush(); + } + +void CCKAbortConnection::ReceivedAbortEvent(TInt aHandle,TKeyEvent* aKey) + { +#if defined(LOGGING) + _LIT(KLog,"CCKAbortConnection::ReceivedAbortEvent State=%d SubState=%d Mode=%d KeyCode=%d ScanCode=%d Mod=0x%x"); + iTest->LOG_MESSAGE7(KLog,iTest->State(),iTest->SubState(),iTest->Mode(),aKey->iCode,aKey->iScanCode,aKey->iModifiers); +#endif + TInt group=reinterpret_cast(iGroup); + iTest->TEST(aHandle==group); + if (aHandle!=group) + { + _LIT(KLog,"Event Handle is not for the right group, expected=%d actual=%d"); + iTest->LOG_MESSAGE3(KLog,group,aHandle); + } + + iTest->TEST(aKey->iCode==abortKeyTests[iAbortKeyIndex].keyCode); + if (aKey->iCode!=abortKeyTests[iAbortKeyIndex].keyCode) + { + _LIT(KLog,"The event KeyCode is not right, expected=%d actual=%d"); + iTest->LOG_MESSAGE3(KLog,abortKeyTests[iAbortKeyIndex].keyCode,aKey->iCode); + } + + iTest->TEST((aKey->iModifiers&abortKeyTests[iAbortKeyIndex].modifier_mask)==abortKeyTests[iAbortKeyIndex].modifiers); + if ((aKey->iModifiers&abortKeyTests[iAbortKeyIndex].modifier_mask)!=abortKeyTests[iAbortKeyIndex].modifiers) + { + _LIT(KLog,"The event modifiers are not right, expected=0x%x actual=0x%x (0x%x) mask=0x%x"); + iTest->LOG_MESSAGE5(KLog,abortKeyTests[iAbortKeyIndex].modifiers,aKey->iModifiers&abortKeyTests[iAbortKeyIndex].modifier_mask + ,aKey->iModifiers,abortKeyTests[iAbortKeyIndex].modifier_mask); + } + iAbortKeyIndex++; + iTest->IncSubState(); + } + +void CCKAbortConnection::Foreground() + { + iGroup->GroupWin()->SetOrdinalPosition(0); + iWs.Flush(); + } + +// +// CCKWindowGroup class // +// + +CCKWindowGroup::CCKWindowGroup(CTClient *aClient, CTCaptureKey *aTest) : CTWindowGroup(aClient), iTest(aTest) + {} + +void CCKWindowGroup::KeyL(const TKeyEvent &aKey,const TTime &time) + { +#if defined(LOGGING) + _LIT(KLog,"CCKWindowGroup::KeyL State=%d SubState=%d Mode=%d KeyCode=%d ScanCode=%d Mod=0x%x"); + iTest->LOG_MESSAGE7(KLog,iTest->State(),iTest->SubState(),iTest->Mode(),aKey.iCode,aKey.iScanCode,aKey.iModifiers); +#endif + if (iTest->Mode()==EModeWaitingForFirstNormalCapWithPriority) + iTest->SetMode(EModeNormalCaptureWithPriority); + if (iCurWin) + iCurWin->WinKeyL(aKey,time); + else + ((CCKConnection *)iClient)->KeyL(aKey,time); + } + +void CCKWindowGroup::KeyDownL(const TKeyEvent &aKey,const TTime &) + { +#if defined(LOGGING) + _LIT(KLog,"CCKWindowGroup::KeyDownL State=%d SubState=%d Mode=%d KeyCode=%d ScanCode=%d Mod=0x%x"); + iTest->LOG_MESSAGE7(KLog,iTest->State(),iTest->SubState(),iTest->Mode(),aKey.iCode,aKey.iScanCode,aKey.iModifiers); +#endif + if (aKey.iScanCode!=EStdKeyLeftShift && aKey.iScanCode!=EStdKeyRightShift) + { + if (iTest->Mode()==EModeWaitingForFirstDown) + iTest->SetMode(EModeKeyUpsAndDowns); + if (iTest->Mode()==EModeWaitingForFirstDownWithPriority) + iTest->SetMode(EModeKeyUpsAndDownsWithPriority); + if (iTest->Mode()==EModeKeyUpsAndDowns || iTest->Mode()==EModeKeyUpsAndDownsWithPriority) + ((CCKConnection *)iClient)->CheckUpDownL(aKey); + } + } + +void CCKWindowGroup::KeyUpL(const TKeyEvent &aKey,const TTime &) + { +#if defined(LOGGING) + _LIT(KLog,"CCKWindowGroup::KeyUpL State=%d SubState=%d Mode=%d KeyCode=%d ScanCode=%d Mod=0x%x"); + iTest->LOG_MESSAGE7(KLog,iTest->State(),iTest->SubState(),iTest->Mode(),aKey.iCode,aKey.iScanCode,aKey.iModifiers); +#endif + if (aKey.iScanCode!=EStdKeyLeftShift && aKey.iScanCode!=EStdKeyRightShift) + { + if (iTest->Mode()==EModeKeyUpsAndDowns || iTest->Mode()==EModeKeyUpsAndDownsWithPriority) + { + ((CCKConnection *)iClient)->CheckUpDownL(aKey); + iTest->IncSubState(); + } + } + } + +// +// CCKWindow, class // +// + +CCKWindow::CCKWindow(CTCaptureKey *aTest, TInt aConnIndex) : CTWin(), iConnIndex(aConnIndex), iTest(aTest) + { + iBack=TRgb::Gray256(230); + } + +void CCKWindow::SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc) + { + ConstructExtLD(*parent,pos,size); + iWin.SetBackgroundColor(iBack); + Activate(); + AssignGC(aGc); + } + +void CCKWindow::Draw() + { + iGc->Clear(); + if (iConnIndex==0) + { + TInt test=iTest->SubState(); + if (testDrawText(TPtrC(capKeyTests[test].txt), TPoint(10,20)); + } + } + +// + +CTCaptureKey::CTCaptureKey(CTestStep* aStep) : CTWsGraphicsBase(aStep) + { + } + +CTCaptureKey::~CTCaptureKey() + { + ((CTCaptureKeyStep*)iStep)->CloseTMSGraphicsStep(); + delete iConn1; + delete iConn2; + delete iConn3; + delete iAbortConn; + } + +void CTCaptureKey::ConstructL() + { + iAbortConn=new(ELeave) CCKAbortConnection(this); + iAbortConn->ConstructL(); + iConn3=new(ELeave) CCKConnection(this,2); + iConn3->ConstructL(); + iConn2=new(ELeave) CCKConnection(this,1); + iConn2->ConstructL(); + iConn1=new(ELeave) CCKConnection(this,0); + iConn1->ConstructL(); + iMode=EModeNormalCapture; + SetSelfDrive(ETrue); + TUint mods=TheClient->iWs.GetModifierState(); + _LIT(KLog,"Initial Modifiers state 0x%x (ideally should be zero)"); + LOG_MESSAGE2(KLog,mods); + } + +TInt CTCaptureKey::SubState() const + { + return(iSubState); + } + +void CTCaptureKey::IncSubState() + { + iSubState++; +#if defined(LOGGING) + _LIT(KLog,"IncSubState State=%d SubState=%d Mode=%d"); + LOG_MESSAGE4(KLog,iState,iSubState,iMode); +#endif + iConn1->SubStateChanged(); + iConn2->SubStateChanged(); + iConn3->SubStateChanged(); + switch(iMode) + { + case EModeNormalCapture: + if (iSubState==numCapKeyTests) + { + CaseComplete(); + return; + } + break; + case EModeNormalCaptureWithPriority: + if (iSubState==numCapKeyTests+numCapKeyWithPriorityTests) + { + CaseComplete(); + return; + } + break; + case EModeKeyUpsAndDowns: + if (iSubState==(numCapKeyTests+numCapKeyWithPriorityTests+numUpDownKeyTests)) + { + CaseComplete(); + return; + } + break; + case EModeKeyUpsAndDownsWithPriority: + if (iSubState==(numCapKeyTests+numCapKeyWithPriorityTests+numUpDownKeyTests+numUpDownKeyWithPriorityTests)) + { + SetSelfDrive(EFalse); + return; + } + break; + case EModeAbortKeys: + if (iSubState==(numCapKeyTests+numCapKeyWithPriorityTests+numUpDownKeyTests+numUpDownKeyWithPriorityTests+numAbortKeyTests)) + ++iState; + TheClient->WaitForRedrawsToFinish(); + return; + default: + break; + } + TheClient->WaitForRedrawsToFinish(); + SendEvents(); + } + +void CTCaptureKey::CapKeyPurgingL() + { + TInt base=Client()->iWs.ResourceCount(); + RWindowGroup groupWin(Client()->iWs); + User::LeaveIfError(groupWin.Construct(ENullWsHandle)); + TInt capHandle=User::LeaveIfError(groupWin.CaptureKey('a',EModifierFunc,EModifierFunc)); + User::LeaveIfError(groupWin.CaptureKey('b',EModifierFunc,EModifierFunc)); + TInt retVal = Client()->iWs.ResourceCount(); + TEST(retVal==(base+3)); + if (retVal!=(base+3)) + INFO_PRINTF3(_L("Client()->iWs.ResourceCount() return value - Expected: %d, Actual: %d"), retVal, (base+3)); + + groupWin.CancelCaptureKey(capHandle); + retVal = Client()->iWs.ResourceCount(); + TEST(retVal==(base+2)); + if (retVal!=(base+2)) + INFO_PRINTF3(_L("Client()->iWs.ResourceCount() return value - Expected: %d, Actual: %d"), retVal, (base+2)); + + groupWin.Close(); + // Check it also freed the extra capture key + retVal = Client()->iWs.ResourceCount(); + TEST(retVal==base); + if (retVal!=base) + INFO_PRINTF3(_L("Client()->iWs.ResourceCount() return value - Expected: %d, Actual: %d"), retVal, base); + + } + +void CTCaptureKey::BadParams() + { + TInt retVal; + TInt resCount=Client()->iWs.ResourceCount(); + for(TInt index=0;indexiGroup->GroupWin()->CaptureKey(errorKeys[index].keyCode,errorKeys[index].modifier_mask,errorKeys[index].modifiers); + TEST(retVal==KErrArgument); + if (retVal!=KErrArgument) + INFO_PRINTF3(_L("Client()->iGroup->GroupWin()->CaptureKey() return value - Expected: %d, Actual: %d"), KErrArgument, retVal); + } + retVal = Client()->iWs.ResourceCount(); + TEST(retVal==resCount); + if (retVal!=resCount) + INFO_PRINTF3(_L("Client()->iWs.ResourceCount() return value - Expected: %d, Actual: %d"), resCount, retVal); + } + +void CTCaptureKey::SetMode(TTestMode aMode) + { +#if defined(LOGGING) + _LIT(KLog,"SetMode State=%d SubState=%d OldMode=%d NewMode=%d"); + LOG_MESSAGE5(KLog,State(),SubState(),iMode,aMode); +#endif + iMode=aMode; + } + +TTestMode CTCaptureKey::Mode() + { + return(iMode); + } + +void CTCaptureKey::SetUpPriorityKeyTest() + { + iMode=EModeAbortKeys; + iAbortConn->Foreground(); + } + +void CTCaptureKey::CaptureWithPriorityTest() //normal key capture but with priority + { + iMode=EModeWaitingForFirstNormalCapWithPriority; + } + +void CTCaptureKey::CaptureUpsAndDownsTest() + { + iMode=EModeWaitingForFirstDown; + } + +void CTCaptureKey::CaptureUpsAndDownsWithPriorityTest() + { + iMode=EModeWaitingForFirstDownWithPriority; + } + +void CTCaptureKey::SendEvents() + { +#if defined(LOGGING) + _LIT(KLog,"SendEvents State=%d SubState=%d"); + LOG_MESSAGE3(KLog,iState,iSubState); +#endif + switch (iSubState) + { + case 0: + iTest->SimulateKeyDownUp('Q'); + break; + case 1: + iTest->SimulateKeyDownUpWithModifiers('W',EModifierAlt); + break; + case 2: + iTest->SimulateKeyDownUp('A'); + break; + case 3: + iTest->SimulateKeyDownUpWithModifiers('S',EModifierAlt|EModifierCtrl); + break; + case 4: + iTest->SimulateKeyDownUpWithModifiers('N',EModifierAlt); + break; + case 5: + iTest->SimulateKeyDownUpWithModifiers('B',EModifierAlt|EModifierCtrl); + break; + case 6: + iTest->SimulateKeyDownUpWithModifiers('D',EModifierAlt); + break; + case 7: + iTest->SimulateKeyDownUpWithModifiers('C',EModifierAlt|EModifierCtrl); + break; + case 8: + iTest->SimulateKeyDownUp('H');//state EModeNormalCaptureWithPriority + break; + case 9: + iTest->SimulateKeyDownUp('J'); + break; + case 10: + iTest->SimulateKeyDownUp('K'); + break; + case 11: + iTest->SimulateKeyDownUp(EStdKeySpace); + break; + case 12: + iTest->SimulateKeyDownUp(EStdKeyEnter); + break; + case 13: + iTest->SimulateKeyDownUpWithModifiers(EStdKeySpace,EModifierShift); + break; + case 14: + iTest->SimulateKeyDownUpWithModifiers(EStdKeyEnter,EModifierShift); + break; + case 15: + iTest->SimulateKeyDownUp('H');//state EModeKeyUpsAndDownsWithPriority + break; + case 16: + iTest->SimulateKeyDownUp('J'); + break; + case 17: + iTest->SimulateKeyDownUp('K'); + break; + case 18: + iTest->SimulateKeyDownUpWithModifiers('C',EModifierCtrl); + break; + case 19: + iTest->SimulateKeyDownUpWithModifiers('D',EModifierCtrl); + break; + case 20: + iTest->SimulateKeyDownUp('Z'); + break; + default: + TEST(EFalse); + } + TheClient->iWs.Flush(); + } + +void CTCaptureKey::CapKeyPowerOffL() + { + const TUint protKey=0xF844; //This value needs to be defined in the WSINI.INI file as a key only capturable by a certain application + RWsSession ws; + User::LeaveIfError(ws.Connect()); + CleanupClosePushL(ws); + + // assign to the correct screen + CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws); + CleanupStack::PushL(screen); + User::LeaveIfError(screen->Construct(iTest->iScreenNumber)); + + RWindowGroup group(ws); + group.Construct(ENullWsHandle); + CleanupClosePushL(group); + group.EnableReceiptOfFocus(EFalse); + group.SetOrdinalPosition(0,5); + RBlankWindow blank(ws); + blank.Construct(group,ENullWsHandle); + CleanupClosePushL(blank); + blank.EnableBackup(); + blank.Activate(); + _LIT(kGroupName1,"Hello"); + group.SetName(kGroupName1); + TInt capHandle = group.CaptureKey(EKeyDevice2,EModifierFunc,EModifierFunc); + TEST(capHandle==KErrPermissionDenied); + if (capHandle!=KErrPermissionDenied) + { + _LIT(KLog1,"Capture Key suceeded when it should of failed, Error/Handle=%d (expected: %d)"); + LOG_MESSAGE3(KLog1,capHandle,KErrPermissionDenied); + _LIT(KLog2,"This is indicative of a bad WSINI file"); + LOG_MESSAGE(KLog2); + } + + capHandle=group.CaptureKeyUpAndDowns(protKey,0,0); + TEST(capHandle==KErrPermissionDenied); + if (capHandle!=KErrPermissionDenied) + { + _LIT(KLog,"Capture Key Up & Down suceeded when it should of failed, Error/Handle=%d (expected: %d)"); + LOG_MESSAGE3(KLog,capHandle,KErrPermissionDenied); + } + + _LIT(kGroupName2,"SysApp"); + group.SetName(kGroupName2); + capHandle = group.CaptureKey(EKeyDevice2,EModifierFunc,EModifierFunc); + TEST(capHandle > 0); + if (capHandle<=0) + { + _LIT(KLog,"Capture Key failed when it should of succeeded, Error=%d"); + LOG_MESSAGE2(KLog,capHandle); + } + + group.CancelCaptureKey(capHandle); + capHandle=group.CaptureKeyUpAndDowns(protKey,0,0); + TEST(capHandle > 0); + if (capHandle<=0) + { + _LIT(KLog,"Capture Key Up & Down failed when it should of succeeded, Error=%d"); + LOG_MESSAGE2(KLog,capHandle); + } + + group.CancelCaptureKeyUpAndDowns(capHandle); + CleanupStack::PopAndDestroy(4,&ws); + } + + +void CTCaptureKey::RunTestCaseL(TInt /*aCurTestCase*/) + { + _LIT(Test0,"Normal capture with priority"); + _LIT(TestNormalCaptureWithPriority,"Normal capture with priority"); + _LIT(TestUpDown,"Capture ups and downs"); + _LIT(TestUpDownWithPriority,"Capture ups and downs with priority"); + _LIT(TestAbort,"Abort key"); + _LIT(TestAbort2,"Abort key extended"); + _LIT(TestErrors,"Errors"); + _LIT(TestCaptureKey,"Capture Key"); + _LIT(TestCapturePowerOffKey,"Capture PowerOff Key"); + + iTest->iState=iState; + ((CTCaptureKeyStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); + switch(iState) + { +/** +@SYMTestCaseID GRAPHICS-WSERV-0140 + + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Normal key capture test + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions The test uses 3 wserv clients with their own window groups. The + clients are registered for different keys to capture. The test + simulates key presses. + +@SYMTestExpectedResults Checks that the key presses are captured correctly . +*/ + case 0: // Dummy one to let capture key tests run + ((CTCaptureKeyStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0140")); + iTest->LogSubTest(Test0); + iState++; + SendEvents(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0141 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Normal key capture test with priorities + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions The test uses 3 wserv clients with their own window groups. The + clients are registered for different keys to capture and with + different priorities. The test simulates key presses. + +@SYMTestExpectedResults Checks that the key presses are captured correctly . +*/ + case 1: + ((CTCaptureKeyStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0141")); + iTest->LogSubTest(TestNormalCaptureWithPriority); + CaptureWithPriorityTest(); + iState++; + SendEvents(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0142 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Up-down key capture test + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions The test uses 3 wserv clients with their own window groups. The + clients are registered for different keys to capture their + up and down events. The test simulates key presses and releases. + +@SYMTestExpectedResults Checks that the key presses and releases are captured correctly . +*/ + case 2: + ((CTCaptureKeyStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0142")); + iTest->LogSubTest(TestUpDown); + CaptureUpsAndDownsTest(); + iState++; + SendEvents(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0143 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Up-down key capture test with priorities + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions The test uses 3 wserv clients with their own window groups. The + clients are registered with different priorities for different keys to capture their + up and down events. The test simulates key presses and releases. + +@SYMTestExpectedResults Checks that the key presses and releases are captured correctly . +*/ + case 3: + ((CTCaptureKeyStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0143")); + iTest->LogSubTest(TestUpDownWithPriority); + CaptureUpsAndDownsWithPriorityTest(); + iState++; + SendEvents(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0144 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Priority key events test + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions The test simulates key events and make sure that the events are + recieved by the registered wserv client. + +@SYMTestExpectedResults Makes sure that key code is the same as a key simulated, event modifiers comply + with registered priority key's modifirs and mask, and that event handle + is a window group of the session. + +*/ + case 4: + ((CTCaptureKeyStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0144")); + if (iSubState==numCapKeyTests+numUpDownKeyWithPriorityTests+numUpDownKeyTests+numUpDownKeyWithPriorityTests) + { + iTest->LogSubTest(TestAbort); + SetUpPriorityKeyTest(); + } + else + iTest->LogSubTest(TestAbort2); + //iState++; + SendEvents(); + TheClient->WaitUntilEventPending(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0145 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Invalid capture keys test + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Memorizes amount of objects that the server has allocated for that client. + Tries to register 3 different capture keys with invalid + modifiers and modifirs mask pair. + +@SYMTestExpectedResults Makes sure that the number of server-side objects for the + session didn't change. +*/ + case 5: + ((CTCaptureKeyStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0145")); + iTest->LogSubTest(TestErrors); + BadParams(); + ((CTCaptureKeyStep*)iStep)->RecordTestResultL(); +/** +@SYMTestCaseID GRAPHICS-WSERV-0146 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Capture keys clean up test + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Memorizes amount of objects that the server has allocated for that client. + Creates a window group and requests two keys to be captured. + Cancels one key capture request and closes the window group. + +@SYMTestExpectedResults Checks that creation of the group or registering a capture key + increased this amount by 1 each time. + Makes sure that the number of server-side objects for the + session in the end of the test is the same as in the beginning. +*/ + ((CTCaptureKeyStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0146")); + iTest->LogSubTest(TestCaptureKey); + CapKeyPurgingL(); + iState++; + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0147 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Capture power off key test + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions The test creates a new session, new window group and a new window + in the group. After that the test gives "Hello" name to the group + and tries to register for key capture of FN+EKeyDevice2 and 0xF844 + buttons. Makes sure that registration fails due to KErrPermissionDenied + error. + Then the test changes the name of the window group to "SysApp" + and tries the registration again. Makes sure that operation + completed successfully. + +@SYMTestExpectedResults See actions +*/ + case 6: + ((CTCaptureKeyStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0147")); + iTest->LogSubTest(TestCapturePowerOffKey); + CapKeyPowerOffL(); + iState++; + break; + default: + ((CTCaptureKeyStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + TestComplete(); + } + ((CTCaptureKeyStep*)iStep)->RecordTestResultL(); + + } + + +__WS_CONSTRUCT_STEP__(CaptureKey) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TCapKey.H --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TCapKey.H Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,313 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef __TCAPKEY_H__ +#define __TCAPKEY_H__ + +#include +#include +#include "../tlib/testbase.h" +#include "AUTO.H" +#include "TGraphicsHarness.h" + +enum TTestMode + { + EModeNormalCapture, + EModeNormalCaptureWithPriority, + EModeWaitingForFirstNormalCapWithPriority, + EModeWaitingForFirstDown, + EModeWaitingForFirstDownWithPriority, + EModeKeyUpsAndDowns, + EModeKeyUpsAndDownsWithPriority, + EModeAbortKeys, + }; +enum TCapKeyRetValues + { + ECapKeyOkay, + ECapKeyRetry, + ECapKeyFail, + }; + +struct SCapKeyParams + { + TInt connIndex; // Connection that should capture this key + TUint keyCode; + TUint modifier_mask; + TUint modifiers; + TInt priority; + }; + +struct SCapKeyTestParams + { + TText *txt; // Text message telling user what to do + TInt connIndex; // Connection that receive the key press + TUint keyCode; // Expected key code + TUint modifier_mask;// Modifiers mask for expected modifiers + TUint modifiers; // Expected modifiers + }; + +struct SAbortKeyTests + { + TUint keyCode; // Expected key code + TUint modifier_mask;// Modifiers mask for expected modifiers + TUint modifiers; // Expected modifiers + }; + +LOCAL_D SCapKeyParams capKeys[]={ + {1,19,EModifierFunc|EModifierCtrl,EModifierFunc|EModifierCtrl,0}, + {2,'b',EModifierFunc|EModifierCtrl,EModifierFunc,0}, + {2,'n',EModifierFunc|EModifierCtrl,EModifierFunc,0}, + {0,3,EModifierFunc|EModifierCtrl,EModifierFunc|EModifierCtrl,0}, + {2,'q',0,0,0}, + {2,'w',0,0,0}, + }; + +LOCAL_D SCapKeyParams capKeysWithPriority[]={ + {2,'h',0,0,7}, + {1,'h',EModifierFunc|EModifierCtrl|EModifierShift,0,7}, + {0,'h',EModifierFunc|EModifierCtrl|EModifierShift,0,7}, + {2,'j',EModifierFunc|EModifierCtrl|EModifierShift,0,6}, + {1,'j',EModifierFunc|EModifierCtrl|EModifierShift,0,6}, + {0,'j',EModifierFunc|EModifierCtrl|EModifierShift,0,5}, + {2,'k',EModifierFunc|EModifierCtrl|EModifierShift,0,4}, + {1,'k',EModifierFunc|EModifierCtrl|EModifierShift,0,3}, + {0,'k',EModifierFunc|EModifierCtrl|EModifierShift,0,2}, + }; + +LOCAL_D SCapKeyParams capUpAndDownKeys[]={ + {2,EStdKeySpace,EModifierFunc|EModifierCtrl|EModifierShift,0,0}, + {2,EStdKeyEnter,EModifierFunc|EModifierCtrl|EModifierShift,EModifierShift,0}, + }; + +LOCAL_D SCapKeyParams capUpAndDownKeysWithPriority[]={ + {2,'H',EModifierFunc|EModifierCtrl|EModifierShift,0,7}, + {1,'H',EModifierFunc|EModifierCtrl|EModifierShift,0,7}, + {0,'H',EModifierFunc|EModifierCtrl|EModifierShift,0,7}, + {2,'J',EModifierFunc|EModifierCtrl|EModifierShift,0,6}, + {1,'J',EModifierFunc|EModifierCtrl|EModifierShift,0,6}, + {0,'J',EModifierFunc|EModifierCtrl|EModifierShift,0,5}, + {2,'K',EModifierFunc|EModifierCtrl|EModifierShift,0,4}, + {1,'K',EModifierFunc|EModifierCtrl|EModifierShift,0,3}, + {0,'K',EModifierFunc|EModifierCtrl|EModifierShift,0,2}, + }; + +LOCAL_D SCapKeyTestParams capKeyTests[]={ + {(TText *)_S("Press q"),2,'q',EModifierFunc|EModifierCtrl|EModifierShift,0}, + {(TText *)_S("Press w"),2,'w',EModifierFunc|EModifierCtrl|EModifierShift,EModifierFunc}, + {(TText *)_S("Press a"),0,'a',0}, + {(TText *)_S("Press s"),1,19,EModifierFunc|EModifierCtrl|EModifierShift,EModifierFunc|EModifierCtrl}, + {(TText *)_S("Press n"),2,'n',EModifierFunc|EModifierCtrl|EModifierShift,EModifierFunc}, + {(TText *)_S("Press b"),0,2,EModifierFunc|EModifierCtrl|EModifierShift,EModifierFunc|EModifierCtrl}, + {(TText *)_S("Press d"),0,'d',EModifierFunc|EModifierCtrl|EModifierShift,EModifierFunc}, + {(TText *)_S("Press c"),0,3,EModifierFunc|EModifierCtrl|EModifierShift,EModifierFunc|EModifierCtrl}, +// +// Capture normal keys with priority +// + {(TText *)_S("Press h"),0,'h',EModifierFunc|EModifierCtrl|EModifierShift,0}, + {(TText *)_S("Press j"),1,'j',EModifierFunc|EModifierCtrl|EModifierShift,0}, + {(TText *)_S("Press k"),2,'k',EModifierFunc|EModifierCtrl|EModifierShift,0}, +// +// Capture ups and downs +// + {(TText *)_S("Press "),2,EStdKeySpace,EModifierFunc|EModifierCtrl|EModifierShift,0}, + {(TText *)_S("Press "),0,EStdKeyEnter,EModifierShift,0}, + {(TText *)_S("Press "),0,EStdKeySpace,EModifierFunc|EModifierCtrl|EModifierShift,EModifierShift}, + {(TText *)_S("Press "),2,EStdKeyEnter,EModifierShift,EModifierShift}, + +// +// Capture ups and downs +// + {(TText *)_S("Press H"),0,'H',EModifierFunc|EModifierCtrl|EModifierShift,0}, + {(TText *)_S("Press J"),1,'J',EModifierFunc|EModifierCtrl|EModifierShift,0}, + {(TText *)_S("Press K"),2,'K',EModifierFunc|EModifierCtrl|EModifierShift,0}, +// +// Priority keys +// + {(TText *)_S("Press c"),0,0,0,0}, + {(TText *)_S("Press d"),0,0,0,0}, + {(TText *)_S("Press z"),0,0,0,0}, + }; + +LOCAL_D SAbortKeyTests abortKeyTests[]={ + {3,EModifierCtrl,EModifierCtrl}, + {4,EModifierCtrl,EModifierCtrl}, + {'z',EModifierFunc|EModifierCtrl|EModifierShift,0} + }; + +struct SErrorCapKey + { + TInt keyCode; + TUint modifier_mask; + TUint modifiers; + }; + +LOCAL_D SErrorCapKey errorKeys[]={ + {'a',EModifierFunc|EModifierShift,EModifierFunc|EModifierCtrl}, + {'1',0,EModifierFunc}, + {3,EModifierCtrl,EModifierCtrl|EModifierShift}, + }; + +const TInt numCapKeys=sizeof(capKeys)/sizeof(capKeys[0]); +const TInt numCapKeysWithPriority=sizeof(capKeysWithPriority)/sizeof(capKeysWithPriority[0]); +const TInt numTests=sizeof(capKeyTests)/sizeof(capKeyTests[0]); +const TInt numErrorKeys=sizeof(errorKeys)/sizeof(errorKeys[0]); +const TInt numAbortKeyTests=sizeof(abortKeyTests)/sizeof(abortKeyTests[0]); +const TInt numUpDownKeys=sizeof(capUpAndDownKeys)/sizeof(capUpAndDownKeys[0]); +const TInt numUpDownKeysWithPriority=sizeof(capUpAndDownKeysWithPriority)/sizeof(capUpAndDownKeysWithPriority[0]); +const TInt numUpDownKeyTests=4; +const TInt numUpDownKeyWithPriorityTests=3; +const TInt numCapKeyWithPriorityTests=3; +const TInt numCapKeyTests=numTests-numAbortKeyTests-numUpDownKeyTests-numUpDownKeyWithPriorityTests-numCapKeyWithPriorityTests; + +LOCAL_D TInt capKeyHandle[numCapKeys]; +LOCAL_D TInt capKeyWithPriorityHandle[numCapKeysWithPriority]; +LOCAL_D TInt capUpDownKeyHandle[numUpDownKeys]; +LOCAL_D TInt capUpDownKeyWithPriorityHandle[numUpDownKeysWithPriority]; + +class CCKWindow; +class CTCaptureKey; +class CCKAbortConnection; + +class CCKConnectionBase : public CTClient + { +public: + CCKConnectionBase(CTCaptureKey *aTest); + void ConstructL(); +protected: + CTCaptureKey *iTest; + }; + +class CCKConnection : public CCKConnectionBase + { +public: + CCKConnection(CTCaptureKey *aTest, TInt aConnIndex); + ~CCKConnection(); + void ConstructL(); + void CheckKeyL(const SCapKeyTestParams &aKeyTest, const TKeyEvent &aKey); + void SubStateChanged(); + void KeyTestL(TInt aBool); + void KeyL(const TKeyEvent &aKey,const TTime &aTime); + void CheckUpDownL(const SCapKeyTestParams &aKeyTest, const TKeyEvent &aKey); + void CheckUpDownL(const TKeyEvent &aKey); + inline TInt Index() {return iConnIndex;} +protected: + TInt iConnIndex; + CCKWindow *iWin; + }; + +class CAbortHandler : public CTEventBase + { +public: + CAbortHandler(RWsSession *aWs, CCKAbortConnection *aConnection); + ~CAbortHandler(); + void Request(); +protected: + void DoCancel(); + void doRunL(); +protected: + CCKAbortConnection *iConnection; + }; + +class CCKAbortConnection : public CCKConnectionBase + { +public: + CCKAbortConnection(CTCaptureKey *aTest); + ~CCKAbortConnection(); + void ConstructL(); + void ReceivedAbortEvent(TInt aHandle, TKeyEvent *aKey); + void Foreground(); +protected: + CAbortHandler *iAbortHandler; + TInt iAbortKeyIndex; + }; + +class CCKWindow : public CTWin + { +public: + CCKWindow(CTCaptureKey *aTest, TInt aConnIndex); + void SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc); + void Draw(); +protected: + TInt iConnIndex; + CTCaptureKey *iTest; + TRgb iBack; + }; + +class CCKWindowGroup : public CTWindowGroup + { +public: + CCKWindowGroup(CTClient *aClient, CTCaptureKey *aTest); + void KeyL(const TKeyEvent &aKey,const TTime &aTime); + void KeyDownL(const TKeyEvent &aKey,const TTime &); + void KeyUpL(const TKeyEvent &aKey,const TTime &); + void CheckUpDown(const SCapKeyTestParams &aKeyTest, const TKeyEvent &aKey); +private: + CTCaptureKey *iTest; + }; + +class CTCaptureKey : public CTWsGraphicsBase + { +public: + CTCaptureKey(CTestStep* aStep); + ~CTCaptureKey(); + void ConstructL(); + void EndCaptureKeyTest(); + inline TInt State() {return iState;} + TInt SubState() const; + void IncSubState(); + void BadParams(); + void CapKeyPurgingL(); + void SetUpPriorityKeyTest(); + void CaptureWithPriorityTest(); + void CaptureUpsAndDownsTest(); + void CaptureUpsAndDownsWithPriorityTest(); + TTestMode Mode(); + void SetMode(TTestMode aMode); + inline TestClient* Client() {return TheClient;} + void SendEvents(); + void CapKeyPowerOffL(); + inline TInt ScreenNumber() {return iTest->ScreenNumber();} +protected: + virtual void RunTestCaseL(TInt aCurTestCase); +private: + CCKConnection *iConn1; + CCKConnection *iConn2; + CCKConnection *iConn3; + CCKAbortConnection *iAbortConn; + TSize iWinSize; + TInt iState; + TInt iSubState; + TTestMode iMode; + }; + +class CTCaptureKeyStep : public CTGraphicsStep + { +public: + CTCaptureKeyStep(); +protected: + //from CTGraphicsStep + virtual CTGraphicsBase* CreateTestL(); + }; + +_LIT(KTCaptureKeyStep,"TCaptureKey"); + + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TDERIVED.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TDERIVED.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,435 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Test classes derived from Wserv client side classes +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include "TDERIVED.H" + +CTDerived::CTDerived(CTestStep* aStep) : CTWsGraphicsBase(aStep) + { + } + +CTDerived::~CTDerived() + { + } + +// +// CDerivedWindowGc // +// + +CDerivedWindowGc::CDerivedWindowGc(CWsScreenDevice *aDevice) : CWindowGc(aDevice) + { + } + +CDerivedWindowGc::~CDerivedWindowGc() + { + } + +void CDerivedWindowGc::DrawLine(const TPoint &aPoint1,const TPoint &aPoint2) + { + CWindowGc::DrawLine(aPoint1+TPoint(10,10), aPoint2-TPoint(10,10)); + } + +// +// RDerivedSession // +// + +TInt RDerivedSession::ResourceCount() + { + return(RWsSession::ResourceCount()+1); + } + +void RDerivedSession::EnableAutoFlush() + { + SetAutoFlush(ETrue); + } + +// +// Derived windows // +// + +RDerivedBlankWindow::RDerivedBlankWindow() + {} +RDerivedBlankWindow::RDerivedBlankWindow(RWsSession &aWs) : RBlankWindow(aWs) + { + } + +void RDerivedBlankWindow::SetColor(TRgb aColor) + { + RBlankWindow::SetColor(~aColor); + } + +void RDerivedBlankWindow::SetColorGray() + { + RBlankWindow::SetColor(TRgb::Gray16(8)); + } + +RDerivedWindow::RDerivedWindow() + {} +RDerivedWindow::RDerivedWindow(RWsSession &aWs) : RWindow(aWs) + { + } + +void RDerivedWindow::SetBackgroundColor(TRgb aColor) + { + RWindow::SetBackgroundColor(~aColor); + } + +void RDerivedWindow::SetBackgroundColorGray() + { + RWindow::SetBackgroundColor(TRgb::Gray16(8)); + } + +RDerivedBackedUpWindow::RDerivedBackedUpWindow() + {} +RDerivedBackedUpWindow::RDerivedBackedUpWindow(RWsSession &aWs) : RBackedUpWindow(aWs) + { + } + +TInt RDerivedBackedUpWindow::BitmapHandle() + { + MaintainBackup(); + return(RBackedUpWindow::BitmapHandle()+1); + }; + +RDerivedWindowGroup::RDerivedWindowGroup() + {} + +RDerivedWindowGroup::RDerivedWindowGroup(RWsSession &aWs) : RWindowGroup(aWs) + { + } + +TName RDerivedWindowGroup::Name() const + { + return(_L("Fred")); + } + +// +// CDerivedScreenDevice // +// + +CDerivedScreenDevice::CDerivedScreenDevice() + {} + +CDerivedScreenDevice::CDerivedScreenDevice(RWsSession &aWs) : CWsScreenDevice(aWs) + {} + +TSize CDerivedScreenDevice::SizeInPixels() const + { + TSize size=CWsScreenDevice::SizeInPixels(); + return(TSize(size.iWidth*2,size.iHeight*2)); + } + +// +// Derived Sprite/Pointer cursor // +// + +RDerivedSprite::RDerivedSprite() + { + } + +RDerivedSprite::RDerivedSprite(RWsSession &aWs) : RWsSprite(aWs) + { + } + +RDerivedPointerCursor::RDerivedPointerCursor() + { + } + +RDerivedPointerCursor::RDerivedPointerCursor(RWsSession &aWs) : RWsPointerCursor(aWs) + { + } + +// + +void CTDerived::ConstructL() + { + TheGc->Activate(*BaseWin->Win()); + TheGc->Clear(); + TheGc->SetBrushColor(TRgb::Gray16(12)); + TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + TheGc->SetPenStyle(CGraphicsContext::ENullPen); + TheGc->DrawRect(TRect(BaseWin->Win()->Size())); + TheGc->Deactivate(); + TheGc->Activate(*TestWin->Win()); + TheGc->Clear(); + TheGc->SetBrushColor(TRgb::Gray16(4)); + TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + TheGc->SetPenStyle(CGraphicsContext::ENullPen); + TheGc->DrawRect(TRect(TestWin->Win()->Size())); + TheGc->Deactivate(); + } + +void CTDerived::DerivedWindowGcL() + { + CDerivedWindowGc *dgc=new(ELeave) CDerivedWindowGc(TheClient->iScreen); + dgc->Construct(); + dgc->Activate(*TestWin->Win()); + dgc->SetBrushStyle(CGraphicsContext::ESolidBrush); + TestWin->Win()->BeginRedraw(); + dgc->DrawRect(TRect(TestWin->Win()->Size())); + dgc->DrawLine(TPoint(0,0),TestWin->Win()->Size().AsPoint()); + TestWin->Win()->EndRedraw(); + dgc->Deactivate(); + delete dgc; + dgc = NULL; + CWindowGc *wgc=new(ELeave) CWindowGc(TheClient->iScreen); + wgc->Construct(); + wgc->Activate(*BaseWin->Win()); + wgc->SetBrushStyle(CGraphicsContext::ESolidBrush); + BaseWin->Win()->BeginRedraw(); + wgc->DrawRect(TRect(TestWin->Win()->Size())); + wgc->DrawLine(TPoint(10,10),TestWin->Win()->Size().AsPoint()-TPoint(10,10)); + BaseWin->Win()->EndRedraw(); + wgc->Deactivate(); + delete wgc; + wgc = NULL; + CompareWindows(_L("CTDerived::DerivedWindowGcL()")); + } + +void CTDerived::DerivedSession() + { + TInt err; + err = iDSession.Connect(); + if (err!=KErrNone) + return; + + // use the correct screen + CWsScreenDevice* screen = NULL; + TRAP(err, screen = new (ELeave) CWsScreenDevice(iDSession)); + if (err!=KErrNone) + { + iDSession.Close(); + return; + } + + if ((err=screen->Construct(iTest->iScreenNumber))!=KErrNone) + { + delete screen; + iDSession.Close(); + return; + } + + delete screen; + + TInt retVal = iDSession.ResourceCount(); + TEST(retVal==1); + if (retVal!=1) + INFO_PRINTF3(_L("iDSession.ResourceCount() return value - Expected: %d, Actual: %d"), 1, retVal); + + iDSession.SetAutoFlush(EFalse); + iDSession.EnableAutoFlush(); + + TBool retBool = iDSession.SetAutoFlush(EFalse); + TEST(retBool); + if (!retBool) + INFO_PRINTF3(_L("iDSession.SetAutoFlush(EFalse) return value - Expected: %d, Actual: %d"), ETrue, retBool); + + iDSession.Close(); + } + +void CTDerived::DerivedWindows() + { +// +// Window group +// + iDGroup=RDerivedWindowGroup(TheClient->iWs); + iDGroup.Construct(222); + iDGroup.Name(); +// +// Redraw up window +// + iDRedraw=RDerivedWindow(TheClient->iWs); + iDRedraw.Construct(iDGroup,12); + iDRedraw.SetBackgroundColor(TRgb(1,2,3)); + iDRedraw.SetBackgroundColorGray(); + iDRedraw.Close(); +// +// Blank up window +// + iDBlank=RDerivedBlankWindow(TheClient->iWs); + iDBlank.Construct(iDGroup,123); + iDBlank.SetColor(TRgb(1,20,50)); + iDBlank.SetColorGray(); + iDBlank.Close(); +// +// Backed up window +// + iDBackedUp=RDerivedBackedUpWindow(TheClient->iWs); + iDBackedUp.Construct(iDGroup,EGray4,1234); + iDBackedUp.BitmapHandle(); + iDBackedUp.Close(); +// + iDGroup.Close(); + } + +void CTDerived::DerivedScreenDeviceL() + { + CWsScreenDevice *wsd=new(ELeave) CWsScreenDevice(TheClient->iWs); + User::LeaveIfError(wsd->Construct(iTest->iScreenNumber)); + TSize size1(wsd->SizeInPixels()); + delete wsd; + CDerivedScreenDevice *dsd=new(ELeave) CDerivedScreenDevice(TheClient->iWs); + User::LeaveIfError(dsd->Construct(iTest->iScreenNumber)); + TSize size2(dsd->SizeInPixels()); + delete dsd; + TEST(size2.iWidth==size1.iWidth*2 && size2.iHeight==size1.iHeight*2); + } + +void CTDerived::DerivedSprite() + { + iDSprite=RDerivedSprite(TheClient->iWs); + TSpriteMember spm; + spm.iBitmap=NULL; + spm.iMaskBitmap=NULL; + spm.iInvertMask=EFalse; + spm.iOffset=TPoint(0,0); // Offset from sprites central position + spm.iInterval=TTimeIntervalMicroSeconds32(1000000); + iDSprite.Construct(*TestWin->Win(), TPoint(10,10), 0); + iDSprite.Close(); +// + iDPCursor=RDerivedPointerCursor(TheClient->iWs); + iDPCursor.Construct(0); + iDPCursor.Close(); + }; + +void CTDerived::RunTestCaseL(TInt /*aCurTestCase*/) + { + ((CTDerivedStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); + switch(++iTest->iState) + { +/** +@SYMTestCaseID GRAPHICS-WSERV-0075 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test derived window graphics context + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Draw using a derived window gc and a normal + window gc and check the dawing is the same + +@SYMTestExpectedResults Drawing is the same with a derived window gc +*/ + case 1: + ((CTDerivedStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0075")); + iTest->LogSubTest(_L("Derived Gc")); + DerivedWindowGcL(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0076 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test derived window server session + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Test that a derived window server session functions + the same as a normal window server session + +@SYMTestExpectedResults The derived window server session functions correctly +*/ + case 2: + ((CTDerivedStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0076")); + iTest->LogSubTest(_L("Derived Session")); + DerivedSession(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0077 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test derived windows and window groups function correctly + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Test that a derived windows and window groups function + the same as the classes they are derived from + +@SYMTestExpectedResults The derived windows and window group functions correctly +*/ + case 3: + ((CTDerivedStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0077")); + iTest->LogSubTest(_L("Derived Blank Window")); + DerivedWindows(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0078 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test derived screen devices function correctly + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Test that a derived screen device function + the same as the class it is derived from + +@SYMTestExpectedResults The derived screen device functions correctly +*/ + case 4: + ((CTDerivedStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0078")); + iTest->LogSubTest(_L("Derived Screed Device")); + DerivedScreenDeviceL(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0079 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test derived sprites and pointer cursors function + correctly + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Test that a derived sprite and pointer cursor + function correctly + +@SYMTestExpectedResults The derived sprite and pointer cursor function + correctly +*/ + case 5: + ((CTDerivedStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0079")); + iTest->LogSubTest(_L("Derived Sprites")); + DerivedSprite(); + break; + case 6: + ((CTDerivedStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + ((CTDerivedStep*)iStep)->CloseTMSGraphicsStep(); + TestComplete(); + break; + } + ((CTDerivedStep*)iStep)->RecordTestResultL(); + } + +__WS_CONSTRUCT_STEP__(Derived) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TDERIVED.H --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TDERIVED.H Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,139 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef __TDERIVED_H__ +#define __TDERIVED_H__ + +#include +#include +#include "../tlib/testbase.h" +#include "AUTO.H" +#include "TGraphicsHarness.h" + +class CDerivedWindowGc : public CWindowGc + { +public: + CDerivedWindowGc(CWsScreenDevice *aDevice); + ~CDerivedWindowGc(); + void DrawLine(const TPoint &aPoint1,const TPoint &aPoint2); + }; + +class RDerivedSession : public RWsSession + { +public: + TInt ResourceCount(); + void EnableAutoFlush(); + }; + +class RDerivedBlankWindow : public RBlankWindow + { +public: + RDerivedBlankWindow(); + RDerivedBlankWindow(RWsSession &aWs); + void SetColor(TRgb aColor); + void SetColorGray(); + }; + +class RDerivedWindow : public RWindow + { +public: + RDerivedWindow(); + RDerivedWindow(RWsSession &aWs); + void SetBackgroundColor(TRgb aColor); + void SetBackgroundColorGray(); + }; + +class RDerivedBackedUpWindow : public RBackedUpWindow + { +public: + RDerivedBackedUpWindow(); + RDerivedBackedUpWindow(RWsSession &aWs); + TInt BitmapHandle(); + }; + +class RDerivedWindowGroup : public RWindowGroup + { +public: + RDerivedWindowGroup(); + RDerivedWindowGroup(RWsSession &aWs); + TName Name() const; + }; + +class CDerivedScreenDevice : public CWsScreenDevice + { +public: + CDerivedScreenDevice(RWsSession &aWs); + CDerivedScreenDevice(); + TSize SizeInPixels() const; + }; + +class RDerivedSprite : public RWsSprite + { +public: + RDerivedSprite(); + RDerivedSprite(RWsSession &aWs); + }; + +class RDerivedPointerCursor : public RWsPointerCursor + { +public: + RDerivedPointerCursor(); + RDerivedPointerCursor(RWsSession &aWs); + }; + +class CTDerived : public CTWsGraphicsBase + { +public: + CTDerived(CTestStep* aStep); + void ConstructL(); + void DerivedWindowGcL(); + void DerivedSession(); + void DerivedWindows(); + void DerivedScreenDeviceL(); + void DerivedSprite(); + ~CTDerived(); +protected: +//from CTGraphicsStep + virtual void RunTestCaseL(TInt aCurTestCase); +private: + TSize iWinSize; + RDerivedSession iDSession; + RDerivedWindow iDRedraw; + RDerivedBlankWindow iDBlank; + RDerivedBackedUpWindow iDBackedUp; + RDerivedWindowGroup iDGroup; + RDerivedSprite iDSprite; + RDerivedPointerCursor iDPCursor; + }; + +class CTDerivedStep : public CTGraphicsStep + { +public: + CTDerivedStep(); +protected: + //from CTGraphicsStep + virtual CTGraphicsBase* CreateTestL(); + }; + +_LIT(KTDerivedStep,"TDerived"); + + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TDirectA.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TDirectA.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,3950 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Test Direct Screen Access +// +// + +#include "tdirecta.h" + +static TRect WinExt; +static TInt WinCol=0; +static TTimeIntervalMicroSeconds32 MoveInterval; +static TTimeIntervalMicroSeconds32 ModeInterval; +static TTimeIntervalMicroSeconds32 FlipInterval; +static TBool ImmediateModeSwitch; +#if defined(LOGGING) + LOCAL_D TLogMessageText LogMessageText; +#endif + +_LIT(SemControl,"Control"); +_LIT(SemNextOp,"TrigerWindow"); +_LIT(FontName,"DejaVu Serif Condensed"); +_LIT(QueueControl,"Queue"); + +LOCAL_D TSize FullScreenModeSize; +LOCAL_D TInt Copy2ndHalfOfScreen; + +const TBool KRegionTrackingOnly = ETrue; +const TBool KDrawingDsa = EFalse; + +const TInt KPanicTestOrdinalPriority=65536; +const TInt KMainTestOrdinalPriority=65535; +const TInt KMainTestBaseWindow=KMainTestOrdinalPriority/3; +const TInt KAboveMainTestBaseWindow = KMainTestBaseWindow +1; + +const TInt KMaxIdlingTime = 25; //used for RegionTrackingOnly DSAs, it represents the maximum number of times the Idling function can be called +//Ids of two RegionTrackingOnly DSAs +const TInt KRegionTrackingOnlyDsaWaitingForAbortSignal = 25; +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA +const TInt KRegionTrackingOnlyDsaNoAbortSignal = 26; +#endif + +const TInt KRegionTrackingOnlyDsaExistLast = 0; +const TInt KDrawingDsaExistLast = 1; +const TInt KShortDelay = 5000; +#define SHORT_DELAY TTimeIntervalMicroSeconds32(KShortDelay) + +_LIT(KSem_DefectFix_KAA_5J3BLW_Name, "DefectFix_KAA_5J3BLW"); + +GLDEF_C TInt ProcDirect(TAny *aScreenNumber) + { + CTrapCleanup* cleanupStack = NULL; + User::LeaveIfNull(cleanupStack = CTrapCleanup::New()); + +#if defined(LOGGING) + _LIT(KWindow,"Window Toggle Vis="); + _LIT(KParams,"%d, Pos=(%d,%d,%d,%d), Col=%d"); +#endif + RSemaphore controlSem; + RSemaphore windowSem; + User::LeaveIfError(controlSem.OpenGlobal(SemControl)); + User::LeaveIfError(windowSem.OpenGlobal(SemNextOp)); + RWsSession ws; + User::LeaveIfError(ws.Connect()); + + // assign to the correct screen + CWsScreenDevice* screen = NULL; + TInt err; + TRAP(err, screen = new (ELeave) CWsScreenDevice(ws)); + if (err!=KErrNone) + return err; + + if ((err=screen->Construct((TInt)aScreenNumber))!=KErrNone) + { + delete screen; + return err; + } + + RWindowGroup group(ws); + User::LeaveIfError(group.Construct(898)); + group.EnableReceiptOfFocus(EFalse); + group.SetOrdinalPosition(0,KAboveMainTestBaseWindow ); + RBlankWindow window(ws); + User::LeaveIfError(window.Construct(group,899)); + TBool vis=EFalse; + window.SetVisible(vis); + window.Activate(); + ws.Flush(); + controlSem.Signal(); + windowSem.Wait(); + RMsgQueueBase queue; + TInt open = queue.OpenGlobal(QueueControl); + TInt data; + while (queue.Receive(&data,sizeof(TInt)) != KErrNone) + { + vis=!vis; + if (vis) + { + window.SetColor(TRgb::Gray4(WinCol)); + window.SetExtent(WinExt.iTl,WinExt.Size()); + #if defined(LOGGING) + LogMessageText.Copy(KWindow); + LogMessageText.AppendFormat(KParams,vis,WinExt.iTl.iX,WinExt.iTl.iY,WinExt.iBr.iX,WinExt.iBr.iY,WinCol); + ws.LogMessage(LogMessageText); + #endif + } + window.SetVisible(vis); + ws.Flush(); + windowSem.Wait(); + } + queue.Close(); + + window.Close(); + group.Close(); + + delete screen; + ws.Close(); + controlSem.Close(); + windowSem.Close(); + + delete cleanupStack; + return(KErrNone); + } + + +/*CDirectScreenAccessOld*/ + +CDirectScreenAccessOld* CDirectScreenAccessOld::NewL(RWsSession& aWs,MAbortDirectScreenAccess& aAborter) + { + CDirectScreenAccessOld* self=new(ELeave) CDirectScreenAccessOld(aWs,aAborter); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +CDirectScreenAccessOld::~CDirectScreenAccessOld() + { + __ASSERT_ALWAYS(!iAborting,AutoPanic(EAutoPanicDirect)); + Cancel(); + iDirectAccess.Close(); + } + +void CDirectScreenAccessOld::ConstructL() + { + User::LeaveIfError(iDirectAccess.Construct()); + CActiveScheduler::Add(this); + } + +TInt CDirectScreenAccessOld::Request(RRegion*& aRegion, RWindowBase& aWindow) + { + TInt ret=iDirectAccess.Request(aRegion,iStatus,aWindow); + if (ret==KErrNone) + SetActive(); + return ret; + } + +void CDirectScreenAccessOld::DoCancel() + { + iDirectAccess.Cancel(); + } + +void CDirectScreenAccessOld::RunL() + { + iAborting=ETrue; + iAborter.AbortNow(REINTERPRET_CAST(RDirectScreenAccess::TTerminationReasons&,iStatus)); + iAborting=EFalse; + iDirectAccess.Completed(); + } + + +/*CColorAnimation*/ + +CColorAnimation* CColorAnimation::NewL(TInt aScreenNumber,TInt aId,MAnimCallBacks& aCallBack,CTWinBase& aParent,TRect aExtent,TBool aStart,TBool aRegionTrackingOnly) + { + CColorAnimation* self=new(ELeave) CColorAnimation(aScreenNumber,aId,aCallBack); + CleanupStack::PushL(self); + self->ConstructL(aParent,aExtent,aRegionTrackingOnly); + if (aStart) + self->StartL(); + CleanupStack::Pop(self); + return self; + } + +CColorAnimation::~CColorAnimation() + { + delete iTimer; + delete iDrawer; + delete iWindow; + delete iWindow2; + TheClient->Flush(); + } + +void CColorAnimation::ConstructL(CTWinBase& aParent,TRect aExtent,TBool aRegionTrackingOnly,TInt aTypeWindow/*=0*/,TInt aSingleWinForMultipleDSA/*=0*/) + { + iRegionTrackingOnly = aRegionTrackingOnly; + // Make sure that the top right corner is not 0,0 + if (aTypeWindow && aExtent.iTl==TPoint(0,0)) + { + aExtent.iTl=TPoint(10,10); + } + RWindowBase* win=NULL; + iSingleWinForMultipleDSA=aSingleWinForMultipleDSA; + if (aSingleWinForMultipleDSA) + { + win=iCallBack.iCallBackWin->BaseWin(); + iWinSize=TheClient->iScreen->SizeInPixels(); + } + else + { + iWindow=new(ELeave) CTBlankWindow(); + iWinSize=aExtent.Size(); + iWindow->ConstructExtLD(aParent,aExtent.iTl,iWinSize); + ChangeModeL(iCallBack.DisplayMode(iId)); + win=iWindow->BaseWin(); + win->SetShadowDisabled(ETrue); + win->Activate(); + } + if (!aTypeWindow) + { + if(iRegionTrackingOnly) + { + iDrawer=CDirectScreenAccess::NewL(TheClient->iWs,*TheClient->iScreen,*win,*this,iRegionTrackingOnly); + } + else + { + //needed for the non NGA case: only the old API is allowed to be used + iDrawer=CDirectScreenAccess::NewL(TheClient->iWs,*TheClient->iScreen,*win,*this); + } + } + else + { + TRect childRect(0,0,100,100); + switch(aTypeWindow) + { + case 1: + { + // Create a Blank Window smaller than it's parent and its top left corner within the parent area and withn the screen area + childRect.Shrink(10,10); + break; + } + case 2: + { + // Create a Blank Window with its top left corner being left side of its parent + childRect.Move(-10,0); + break; + } + } + iWindow2=new(ELeave) CTBlankWindow(); + iWindow2->ConstructExtLD(*iWindow,childRect.iTl,childRect.Size()); + // Finish constructing the window + RWindowBase& win=*iWindow2->BaseWin(); + win.SetShadowDisabled(ETrue); + win.Activate(); + // Create the Direct Screen Access object + if(iRegionTrackingOnly) + { + iDrawer=CDirectScreenAccess::NewL(TheClient->iWs,*TheClient->iScreen,win,*this,iRegionTrackingOnly); + } + else + { + //needed for the non NGA case: only the old API is allowed to be used + iDrawer=CDirectScreenAccess::NewL(TheClient->iWs,*TheClient->iScreen,win,*this); + } + } + TheClient->Flush(); + if (iId == 4) + { + // This clause is needed to prevent sub-test 9 from taking an + // exceedingly large amount of time. The CColorAnimation with iId 4 is + // the one which controls when the test stops. This raise in + // priority compared to the other CColorAnimations, allows it's + // callbacks to get through when otherwise they would take much longer + // due to the volume of callbacks generated by the other + // CColorAnimations + iTimer=CPeriodic::NewL(1); + } + else + { + iTimer=CPeriodic::NewL(0); + } + } + +TPoint CColorAnimation::AbsoluteWindowPosition(TInt aWindowId/*=0*/) + { + if (iSingleWinForMultipleDSA) + { + return iCallBack.iCallBackWin->BaseWin()->AbsPosition(); + } + if (!aWindowId) + { + // Return the absolute position of iWindow, if Color Animation is not for Position Relative to Screen test. + return iWindow->BaseWin()->AbsPosition(); + } + else + { + // Return the absolute position of iWindow2, if it is for Position Relative to Screen test. + return iWindow2->BaseWin()->AbsPosition(); + } + } + +TInt CColorAnimation::DrawColorL(TAny* aAnimation) + { + STATIC_CAST(CColorAnimation*,aAnimation)->DrawColorL(); + return(KErrNone); + } + +TInt CColorAnimation::IdlingL(TAny* aAnimation) + { + (static_cast(aAnimation))->IdlingL(); + return(KErrNone); + } + +void CColorAnimation::StartL(TBool aChildWindow/*=EFalse*/) + { + iDrawer->StartL(); + TRect bounding=iDrawer->DrawingRegion()->BoundingRect(); + TRect window; + if (aChildWindow) + { + window.SetRect(AbsoluteWindowPosition(1),iWinSize); + } + else + { + window.SetRect(AbsoluteWindowPosition(),iWinSize); + } + // Check that the window contains the bounding area (a bounding rect of (0,0,0,0) shouldn't fail the test) + if (!(window.Contains(bounding.iTl) && window.Contains(bounding.iBr-TPoint(1,1))) && bounding.Size()!=TSize(0,0)) + { + iCallBack.Fail(); + // iDrawer->Cancel(); + // iDrawer->StartL(); + // bounding=iDrawer->DrawingRegion()->BoundingRect(); + } + if(!iRegionTrackingOnly) + { + iTimer->Start(0,iCallBack.TimerInterval(iId),TCallBack(CColorAnimation::DrawColorL,this)); + iDrawer->Gc()->SetPenStyle(CGraphicsContext::ENullPen); + iDrawer->Gc()->SetBrushStyle(CGraphicsContext::ESolidBrush); + } + else + { + iTimer->Start(0,iCallBack.TimerInterval(iId),TCallBack(CColorAnimation::IdlingL,this)); + } + } + +void CColorAnimation::StartOrPanic() + { + TRAPD(err,StartL()); + if (err!=KErrNone) + { + iCallBack.LogLeave(err); + iCallBack.Fail(); + } + } + +void CColorAnimation::Stop() + { + iTimer->Cancel(); + iDrawer->Cancel(); + } + +void CColorAnimation::BringWindowToFront() + { + iWindow->WinTreeNode()->SetOrdinalPosition(0); + } + +void CColorAnimation::ChangeModeL(TDisplayMode aMode) + { + User::LeaveIfError(iWindow->BaseWin()->SetRequiredDisplayMode(aMode)); + TheClient->Flush(); + } + +void CColorAnimation::FinishTest() + { + iCallBack.Finished(iId); + } + +inline CDirectScreenAccess* CColorAnimation::GetDrawer() + { + return iDrawer; + } + +void CColorAnimation::DrawColorL() + { + TBool aFinished; + iDrawer->Gc()->SetBrushColor(iCallBack.BrushColorL(iId,iColor,aFinished)); + if (iSingleWinForMultipleDSA==1) + { + iDrawer->Gc()->DrawRect(iWinSize-TSize(iWinSize.iWidth/2,iWinSize.iHeight/2)); + } + else if (iSingleWinForMultipleDSA==2) + { + iDrawer->Gc()->DrawRect(TRect(TPoint(iWinSize.iWidth/2,iWinSize.iHeight/2),TSize(iWinSize.iWidth/2,iWinSize.iHeight/2))); + } + else + { + iDrawer->Gc()->DrawRect(iWinSize); + } + iDrawer->ScreenDevice()->Update(); + if (aFinished) + { + if (iId==1) + { + iWindow->SetSize(TSize(48,52)); + TheClient->Flush(); + } + if (aFinished==1) + Stop(); + iCallBack.Finished(iId); + } + } + +void CColorAnimation::IdlingL() + { + iIdling++; + if(iIdling == KMaxIdlingTime) + { + Stop(); + iIdling = 0; + if (iId == KRegionTrackingOnlyDsaWaitingForAbortSignal) + { + _LIT(KErrorAbortNotReceived,"DSA didn't get an abort signal even though the window was opened in front"); + CallBack().Log((TText8*)__FILE__,__LINE__, ESevrErr,KErrorAbortNotReceived); + CallBack().Fail(); + } + iCallBack.Finished(iId); + } + } + +void CColorAnimation::AbortNow(RDirectScreenAccess::TTerminationReasons /*aReason*/) + { + TInt slow=iCallBack.SlowStopping(iId,iCount); + switch (slow) + { + case eAbortAll: + iCallBack.Finished(iId); + case eAbort: + Stop(); + return; + case eStopDelayed: + User::After(750000); //0.75 secs + break; + default:; + } + ++iCount; + iTimer->Cancel(); + } + +void CColorAnimation::Restart(RDirectScreenAccess::TTerminationReasons /*aReason*/) + { + TRAPD(err,StartL()); + if (err!=KErrNone) + iCallBack.FailedReStart(iId,err); + } + + +/*CScrollingTextDrawer*/ + +CScrollingTextDrawer* CScrollingTextDrawer::NewL(TInt aScreenNumber,CFbsScreenDevice*& aDevice,CFbsBitGc& aGc) + { + CScrollingTextDrawer* self=new(ELeave) CScrollingTextDrawer(aDevice,aGc); + CleanupStack::PushL(self); + self->ConstructL(aScreenNumber); + CleanupStack::Pop(self); + return self; + } + +CScrollingTextDrawer::~CScrollingTextDrawer() + { + if(iFontDevice) + { + iFontDevice->ReleaseFont(iFont); + delete iFontDevice; + } + } + +void CScrollingTextDrawer::ConstructL(TInt aScreenNumber) + { + iFontDevice=CFbsScreenDevice::NewL(aScreenNumber,iDevice->DisplayMode()); + _LIT(text,"ABCDEFGHIJKLMNOPQRSTUVWXYZ"); + iText=text; + CreateFontL(); + //iFirstChar=0; + iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); +#if defined(LOGGING) + iWs.Connect(); + // point to correct screen + CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(iWs); + CleanupStack::PushL(screen); + User::LeaveIfError(screen->Construct(aScreenNumber)); + CleanupStack::Pop(screen); + + _LIT(KConstTextDrawer,"Constructed Text Drawer"); + LogMessageText.Copy(KConstTextDrawer); + iWs.LogMessage(LogMessageText); + iWs.Flush(); + + delete screen; + iWs.Close(); +#endif + } + +void CScrollingTextDrawer::CreateFontL() + { + TInt screenHeight=iDevice->SizeInPixels().iHeight; + TFontSpec fontSpec(FontName,screenHeight); + User::LeaveIfError(iFontDevice->GetNearestFontToDesignHeightInPixels(iFont,fontSpec)); + iGc->UseFont(iFont); + TInt fontHeight=iFont->HeightInPixels(); + iDrawRect.iTl.iY=(screenHeight-fontHeight)/2; + iDrawRect.iBr.iY=iDrawRect.iTl.iY+fontHeight; + iDrawHeight=iFont->AscentInPixels(); + iCharWidth=iFont->CharWidthInPixels(iText[iFirstChar]); + iDrawRect.iBr.iX=Max(iDevice->SizeInPixels().iWidth,iDevice->SizeInPixels().iHeight); + iDrawRect.iTl.iX=iDrawRect.iBr.iX-iCharWidth; + } + +void CScrollingTextDrawer::SetBottomOfTest(TInt aBottom) + { + if (iDrawRect.iBr.iY>aBottom) + { + iDrawRect.iTl.iY-=iDrawRect.iBr.iY-aBottom; + iDrawRect.iBr.iY=aBottom; + } + } + +void CScrollingTextDrawer::Scroll() + { + iCharWidth=iFont->CharWidthInPixels(iText[iFirstChar]); + iDrawRect.iTl.iX-=iJump; + iGc->DrawText(iText.Mid(iFirstChar),iDrawRect,iDrawHeight); + iDevice->Update(); + if (iDrawRect.iTl.iX<-iCharWidth) + { + if (++iFirstChar==iText.Length()) + { + iFirstChar=0; + iDrawRect.iTl.iX=iDevice->SizeInPixels().iWidth; + } + else + iDrawRect.iTl.iX+=iCharWidth; + iCharWidth=iFont->CharWidthInPixels(iText[iFirstChar]); + } + } + + +/*CScrollText*/ + +TInt CScrollText::DrawText(TAny* aAnimation) + { + STATIC_CAST(CScrollText*,aAnimation)->ScrollText(); + return(KErrNone); + } + +CScrollText* CScrollText::NewL(TInt aScreenNumber,TInt aId,CTWindowGroup& aParent,TInt aScrollJump,TBool aStart/*=EFalse*/) + { + CScrollText* self=new(ELeave) CScrollText(aId,aScrollJump,aScreenNumber); + CleanupStack::PushL(self); + self->ConstructL(aParent); + if (aStart) + self->StartL(); + CleanupStack::Pop(self); + return self; + } + +CScrollText::~CScrollText() + { + delete iTimer; + delete iTextDraw; + iTextDraw=NULL; + delete iDrawer; + delete iWindow; + TheClient->Flush(); + } + +void CScrollText::ConstructL(CTWindowGroup& aParent) + { + iWindow=new(ELeave) CTBlankWindow(); + iWindow->ConstructL(aParent); + RWindowBase& win=*iWindow->BaseWin(); + win.Activate(); + iDrawer=CDirectScreenAccess::NewL(TheClient->iWs,*TheClient->iScreen,win,*this); + TheClient->Flush(); + iTimer=CPeriodic::NewL(0); + } + +void CScrollText::StartL() + { + DoContinueL(); + iDrawer->Gc()->SetBrushStyle(CGraphicsContext::ESolidBrush); + if (!iTextDraw) + { + iTextDraw=CScrollingTextDrawer::NewL(iScreenNumber,iDrawer->ScreenDevice(),*iDrawer->Gc()); + iTextDraw->SetScrollJump(iScrollJump); + } + } + +void CScrollText::ContinueL() + { + DoContinueL(); + } + +void CScrollText::DoContinueL() + { + iTimer->Start(0,10000,TCallBack(CScrollText::DrawText,this)); + + //0.01secs + iDrawer->StartL(); + TRect bounding=iDrawer->DrawingRegion()->BoundingRect(); +#if defined(LOGGING) + _LIT(KBoundRect,"Continue Scroll Text Rect=(%d,%d,%d,%d)"); + LogMessageText.Zero(); + LogMessageText.AppendFormat(KBoundRect,bounding.iTl.iX,bounding.iTl.iY,bounding.iBr.iX,bounding.iBr.iY); + TheClient->iWs.LogMessage(LogMessageText); + TheClient->Flush(); +#endif + TRect window=TRect(iWindow->BaseWin()->AbsPosition(),iWindow->Size()); + if (!window.Contains(bounding.iTl) || !window.Contains(bounding.iBr-TPoint(1,1))) + AutoPanic(EAutoPanicTestFailed); + } + +void CScrollText::Stop() + { + iTimer->Cancel(); + iDrawer->Cancel(); + } + +void CScrollText::ScrollText() + { + iTextDraw->Scroll(); + } + +void CScrollText::AbortNow(RDirectScreenAccess::TTerminationReasons aReason) + { + iTimer->Cancel(); + if (!iCounting) + return; + if (iAbortCountDown>0) + --iAbortCountDown; + else + { + if (aReason==RDirectScreenAccess::ETerminateRegion) + { + User::After(1500000); //1.5secs + iAbortCountDown=7; + } + } + } + +void CScrollText::Restart(RDirectScreenAccess::TTerminationReasons /*aReason*/) +//This function is pure virtual and so cannot have an 'L' at the end of it's name + { + ContinueL(); + } + +/*CWindowWithChild*/ + +CWindowWithChild* CWindowWithChild::NewL(TInt aScreenNumber, CTWindowGroup& aParent,TBool aStart/*=EFalse*/) + { + CWindowWithChild* self=new(ELeave) CWindowWithChild(aScreenNumber); + CleanupStack::PushL(self); + self->ConstructL(aParent); + if (aStart) + self->StartL(); + CleanupStack::Pop(self); + return self; + } + +CWindowWithChild::~CWindowWithChild() + { + delete iDrawer; + delete iChildWindow; + delete iWindow; + TheClient->Flush(); + } + +void CWindowWithChild::ConstructL(CTWindowGroup& aParent) + { + iWindow=new(ELeave) CTBlankWindow(); + iWindow->ConstructL(aParent); + + iChildWindow = new(ELeave) CTWin(); + iChildWindow->ConstructWin(*iWindow); + + iChildWindow->SetExt(TPoint(0,0), TSize(4,4)); + RWindowBase& cwin=*iChildWindow->BaseWin(); + cwin.Activate(); + + RWindowBase& win=*iWindow->BaseWin(); + win.Activate(); + + iDrawer=CDirectScreenAccess::NewL(TheClient->iWs,*TheClient->iScreen,win,*this); + + TheClient->Flush(); + } + +void CWindowWithChild::StartL() + { + DoContinueL(); + } + +void CWindowWithChild::ContinueL() + { + DoContinueL(); + } + +void CWindowWithChild::DoContinueL() + { + iDrawer->StartL(); + iRunning = ETrue; + } + +void CWindowWithChild::Stop() + { + iDrawer->Cancel(); + } + +void CWindowWithChild::AbortNow(RDirectScreenAccess::TTerminationReasons /*aReason*/) + { + iRunning = EFalse; + } + +void CWindowWithChild::Restart(RDirectScreenAccess::TTerminationReasons /*aReason*/) +//This function is pure virtual and so cannot have an 'L' at the end of it's name + { + ContinueL(); + } + +void CWindowWithChild::PerformCoverageCalls() + { + //add coverage to commands with no/partial coverage + RWindow& cwin=*iChildWindow->Win(); + TInt priority = 0; + + cwin.SetPointerCapturePriority(priority); + __ASSERT_ALWAYS(cwin.GetPointerCapturePriority()==priority, User::Invariant()); + cwin.ClaimPointerGrab(EFalse); + cwin.EnableBackup(0); + __ASSERT_ALWAYS(cwin.PrevSibling()==0, User::Invariant()); + cwin.Invalidate(TRect(0, 0, 10, 10)); + cwin.FadeBehind(ETrue); + TheClient->Flush(); + // cover (empty) False condition in CWsWindow::SetFadeBehind + cwin.FadeBehind(ETrue); + TheClient->Flush(); + } + +/*CWsBase*/ + +void CWsBase::ConstructL(TInt aScreenNumber, TInt aHandle) + { + User::LeaveIfError(iWs.Connect()); + iScrDev=new(ELeave) CWsScreenDevice(iWs); + User::LeaveIfError(iScrDev->Construct(aScreenNumber)); + iGroup=RWindowGroup(iWs); + User::LeaveIfError(iGroup.Construct(aHandle,EFalse)); + iGroup.SetOrdinalPosition(0,KMainTestBaseWindow); + } + +void CWsBase::CreateBlankWindowL(RBlankWindow& iWin,TInt aHandle) + { + iWin=RBlankWindow(iWs); + User::LeaveIfError(iWin.Construct(iGroup,aHandle)); + } + +CWsBase::~CWsBase() + { + iGroup.Close(); + delete iScrDev; + iWs.Close(); + } + + +/*CAnimating*/ + +TInt CAnimating::StartLC(TAny* aScreenNumber) + { + CAnimating* self=new(ELeave) CAnimating(); + CleanupStack::PushL(self); + self->ConstructL((TInt)aScreenNumber); + return KErrNone; + } + +void CAnimating::ConstructL(TInt aScreenNumber) + { + CWsBase::ConstructL(aScreenNumber,798); +#if defined(LOGGING) + _LIT(KAnimate1,"Constructed CWsBase"); + LogMessageText.Copy(KAnimate1); + iWs.LogMessage(LogMessageText); + iWs.Flush(); +#endif + iGroup.EnableReceiptOfFocus(EFalse); + CreateBlankWindowL(iWindow,799); + User::LeaveIfError(iWindow.SetRequiredDisplayMode(EGray16)); + iWindow.Activate(); +#if defined(LOGGING) + _LIT(KAnimate2,"Set up Windows"); + LogMessageText.Copy(KAnimate2); + iWs.LogMessage(LogMessageText); +#endif + iWs.Flush(); + TDisplayMode displayMode=CWsBase::iScrDev->DisplayMode(); + if (displayModeCreateContext(iGc)); +#if defined(LOGGING) + _LIT(KAnimate3,"Created Screen Device"); + LogMessageText.Copy(KAnimate3); + iWs.LogMessage(LogMessageText); + iWs.Flush(); +#endif + iDirect=CDirectScreenAccessOld::NewL(iWs,*this); + iTimer=CPeriodic::NewL(0); + User::LeaveIfError(iControlSem.OpenGlobal(SemControl,EOwnerThread)); //Must be thread relative, since it won't get cleaned up when the thread is killed otherwise + User::LeaveIfError(iControlQueue.OpenGlobal(QueueControl,EOwnerThread)); //Must be thread relative, since it won't get cleaned up when the thread is killed otherwise + iSemCreated=ETrue; +#if defined(LOGGING) + _LIT(KAnimate5,"Created Direct, Timer and Semaphore"); + LogMessageText.Copy(KAnimate5); + iWs.LogMessage(LogMessageText); + iWs.Flush(); +#endif + iScrSize=iScrDev->SizeInPixels(); + iGc->SetPenStyle(CGraphicsContext::ENullPen); + iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + StartAnimatingL(); +#if defined(LOGGING) + _LIT(KAnimate6,"Started Animation"); + LogMessageText.Copy(KAnimate6); + iWs.LogMessage(LogMessageText); + iWs.Flush(); +#endif + } + +CAnimating::~CAnimating() + //This function should never actually get run in practice + { + if (iSemCreated) + { + iControlSem.Close(); + iControlQueue.Close(); + } + if (iDrawingRegion) + iDrawingRegion->Destroy(); + delete iTimer; + delete iDirect; + delete iGc; + delete iScrDev; + iWindow.Close(); + } + +void CAnimating::AbortNow(RDirectScreenAccess::TTerminationReasons /*aReason*/) + { + iTimer->Cancel(); + iControlSem.Signal(); + TInt data = 2; + iControlQueue.Send(&data,sizeof(TInt)); + User::After(10000000); //10 secs + } + +TInt NextColor(TAny* aAnimation) + { + STATIC_CAST(CAnimating*,aAnimation)->DrawFrame(); + return(KErrNone); + } + +void CAnimating::DrawFrame() + { + iColor=(iColor+3)%16; + iGc->SetBrushColor(TRgb::Gray16(iColor)); + iGc->DrawRect(iScrSize); + iScrDev->Update(); + if (iColor==2) + { + iControlSem.Signal(); + TInt data = 1; + iControlQueue.Send(&data,sizeof(TInt)); + } + } + +void CAnimating::StartAnimatingL() + { + iTimer->Start(0,150000,TCallBack(NextColor,this)); //0.15 secs + + User::LeaveIfError(iDirect->Request(iDrawingRegion,iWindow)); + iGc->SetClippingRegion(iDrawingRegion); + } + + +/*CMoveWindow*/ + +TInt CMoveWindow::StartLC(TAny* aScreenNumber) + { + CMoveWindow* self=new(ELeave) CMoveWindow(); + CleanupStack::PushL(self); + self->ConstructL((TInt)aScreenNumber); + return KErrNone; + } + +TInt CMoveWindow::FlipChange(TAny* aMoveWin) + { + Cast(aMoveWin)->FlipChange(); + return(KErrNone); + } + +TInt CMoveWindow::StateChange(TAny* aMoveWin) + { + Cast(aMoveWin)->StateChange(); + return(KErrNone); + } + +CMoveWindow::~CMoveWindow() + { + delete iStateTimer; + delete iTimer; + iWindow.Close(); + iBackUpWin.Close(); + delete iGc; + } + +TInt MoveWin(TAny* aMoveWin) + { + STATIC_CAST(CMoveWindow*,aMoveWin)->MoveWindow(); + return(KErrNone); + } + +void CMoveWindow::ConstructL(TInt aScreenNumber) + { + CWsBase::ConstructL(aScreenNumber,898); + iBounceArea=TRect(iScrDev->SizeInPixels()); + iSize.iHeight=iBounceArea.iBr.iY/5; + iSize.iWidth=iBounceArea.iBr.iX/5; + iBounceArea.iTl.iX=iBounceArea.iBr.iX/6; + iBounceArea.iBr.iX=5*iBounceArea.iBr.iX/6; + iBounceArea.iTl.iY=iBounceArea.iBr.iY/4; + iBounceArea.iBr.iY=3*iBounceArea.iBr.iY/4; + iDelta=TSize(3,3); + iTl=iBounceArea.iTl; + CreateBlankWindowL(iWindow,899); + iWindow.SetExtent(iTl,iSize); + iWindow.SetShadowDisabled(ETrue); + iWindow.SetColor(TRgb::Gray4(2)); + iWindow.Activate(); + iBackUpWin=RBackedUpWindow(iWs); + User::LeaveIfError(iBackUpWin.Construct(iGroup,EGray4,698)); + User::LeaveIfError(iBackUpWin.SetSizeErr(TSize(2,2))); + iGc=new(ELeave) CWindowGc(iScrDev); + User::LeaveIfError(iGc->Construct()); + iDisplayMode=EGray4; + if (MoveInterval>TTimeIntervalMicroSeconds32(0)) + CreateTimerL(); + if (ModeInterval>TTimeIntervalMicroSeconds32(0)) + { + iStateTimer=CPeriodic::NewL(0); + iStateTimer->Start(ModeInterval,ModeInterval,TCallBack(CMoveWindow::StateChange,this)); + } + if (FlipInterval>TTimeIntervalMicroSeconds32(0)) + { + iDevice=new(ELeave) CWsScreenDevice(iWs); + User::LeaveIfError(iDevice->Construct(aScreenNumber)); + iNumOfModes=iDevice->NumScreenModes(); + if (iNumOfModes>1) + { + iFlipTimer=CPeriodic::NewL(0); + iFlipTimer->Start(FlipInterval,FlipInterval,TCallBack(CMoveWindow::FlipChange,this)); + } + } + iStateCountDown=0; + } + +void CMoveWindow::CreateTimerL() + { + iTimer=CPeriodic::NewL(0); + iTimer->Start(0,MoveInterval,TCallBack(MoveWin,this)); + + } + +void CMoveWindow::MoveWindow() + { + if (--iStateCountDown>=0) + { + if (iStateCountDown==2) + ToggleDisplayMode(); + return; + } + TPoint iBr=iTl+iSize; + TSize iDeltaSize; + if ((iDelta.iHeight<0 && iTl.iY<=iBounceArea.iTl.iY) || (iDelta.iHeight>0 && iBr.iY>=iBounceArea.iBr.iY)) + { + iDelta.iHeight=-iDelta.iHeight; + iDeltaSize.iWidth=2; + } + if ((iDelta.iWidth<0 && iTl.iX<=iBounceArea.iTl.iX) || (iDelta.iWidth>0 && iBr.iX>=iBounceArea.iBr.iX)) + { + iDelta.iWidth=-iDelta.iWidth; + if (iDeltaSize.iWidth==0) + iDeltaSize.iHeight=2; + else + iDeltaSize.iWidth=0; + } + iTl+=iDelta; + iSize+=iDeltaSize; + iWindow.SetExtent(iTl,iSize); + iWs.Flush(); + } + +void CMoveWindow::StateChange() + { + if (ImmediateModeSwitch>1) + { + if (MoveInterval>TTimeIntervalMicroSeconds32(0) && iTimer==NULL) + { + TRAPD(err,CreateTimerL()); + if (err==KErrNone) + ImmediateModeSwitch=ETrue; + } + } + if (ImmediateModeSwitch || MoveInterval==TTimeIntervalMicroSeconds32(0)) + ToggleDisplayMode(); + else + { + if (iStateCountDown<-8) + iStateCountDown=6; + } + } + +void CMoveWindow::ToggleDisplayMode() + { + if(iDisplayMode==EColor16MU) + { + return; //Test probably doesn't work with mode EColor16MU + } + iDisplayMode=(iDisplayMode==EColor16M ? EGray4:EColor16M); +#if defined(LOGGING) + TInt newMode= +#endif + iWindow.SetRequiredDisplayMode(iDisplayMode); + iGc->Activate(iBackUpWin); + iBackUpWin.SetPosition(iDisplayMode==EColor16M ? TPoint(1,0):TPoint(0,1)); +#if defined(LOGGING) + TDisplayMode curentMode=iScrDev->DisplayMode(); + _LIT(KToggleMode,"Toggle Display Mode Mode=%d Window=%d Actual=%d"); + LogMessageText.Zero(); + LogMessageText.AppendFormat(KToggleMode,(TInt&)iDisplayMode,newMode,(TInt&)curentMode); + iWs.LogMessage(LogMessageText); + //iWs.LogCommand(RWsSession::ELoggingStatusDump); +#endif + iWs.Flush(); + iGc->Deactivate(); + } + +void CMoveWindow::FlipChange() + { + if (++iCurrentMode==2) //flip between modes 0 and 1 + iCurrentMode=0; + iDevice->SetScreenMode(iCurrentMode); + iWs.Flush(); + } + +// +// CBugFixColorAnimation +// +// This class is used for reproducing a defect found on 6.1: KAA-5J3BLW "Unnecessary Wserv's DSA abort". +// The problem was that a direct screen access client was getting an unnecessary abort notification +// when a new window (or window group) was created but not visible. +// This class will simulate the direct screen access client and it will check whether the first DSA abort +// is not caused by just creating a window. + +CBugFixColorAnimation* CBugFixColorAnimation::NewL(TInt aScreenNumber,TInt aId,MAnimCallBacks& aCallBack,CTWindowGroup& aParent,TRect aExtent,TBool aStart) + { + CBugFixColorAnimation* self=new(ELeave) CBugFixColorAnimation(aScreenNumber, aId,aCallBack); + CleanupStack::PushL(self); + self->ConstructL(aParent,aExtent); + if (aStart) + { + self->StartL(); + self->Started(); + } + CleanupStack::Pop(self); + return self; + } + +CBugFixColorAnimation::CBugFixColorAnimation(TInt aScreenNumber,TInt aId,MAnimCallBacks& aCallBack) + : CColorAnimation(aScreenNumber, aId, aCallBack) + { + iThreadParam.iScreenNumber = aScreenNumber; + } + +CBugFixColorAnimation::~CBugFixColorAnimation() + { + iSem.Close(); + if(iThread) + { + TRequestStatus status; + iThread->Logon(status); + if (iThread->StillAlive()) + { + iThread->Terminate(KErrNone); + User::WaitForRequest(status); + } + delete iThread; + } + iTestFailed->Cancel(); + delete iTestFailed; + } + + +LOCAL_D TInt TestFailed(TAny* aAnimation) + { + CBugFixColorAnimation* anim=reinterpret_cast(aAnimation); + TRAP_IGNORE( + anim->Stop(); + anim->CallBack().Fail(); + anim->FinishTest(); + ); + return KErrNone; + } + +LOCAL_D TInt CreateNewWindowGroup(TAny* aParam) + { + TDirectThreadParam* param = (TDirectThreadParam*)aParam; + TRect rect = param->iRect; + TBool isInFront = param->iIsInFront; + RWsSession ws; + TInt error=ws.Connect(); + + CWsScreenDevice* screen = NULL; + TRAP(error, screen = new (ELeave) CWsScreenDevice(ws)); + if (error!=KErrNone) + { + ws.Close(); + RThread::Rendezvous(error); + return error; + } + + if ((error=screen->Construct(param->iScreenNumber))!=KErrNone) + { + delete screen; + ws.Close(); + RThread::Rendezvous(error); + return error; + } + RSemaphore sem; + error = sem.OpenGlobal(KSem_DefectFix_KAA_5J3BLW_Name, EOwnerThread); + if (error!=KErrNone) + { + ws.Close(); + RThread::Rendezvous(error); + return error; + } + + RThread::Rendezvous(KErrNone); + + // wait for the dsa to start before creating the new window group + sem.Wait(); + sem.Close(); + + + RWindowGroup group(ws); + group.Construct(431,EFalse); + if(isInFront) + { + group.SetOrdinalPosition(0,KAboveMainTestBaseWindow); + } + else + { + group.SetOrdinalPosition(2); + } + RWindow window(ws); + error=window.Construct(group, 432); + if (error==KErrNone) + { + window.SetExtentErr(rect.iTl, rect.Size()); + window.SetOrdinalPosition(0,0); + ws.Flush(); + window.Activate(); + ws.Flush(); + if(!isInFront) + { + group.SetOrdinalPosition(-1); + } + ws.Flush(); + //Wait for wserv to render new window on top of the existing DSA region. + ws.Finish(); + //Now the window has been rendered (and DSA should have been aborted). + window.Close(); + } + + group.Close(); + delete screen; + ws.Close(); + return error; + } + +void CBugFixColorAnimation::ConstructL(CTWindowGroup& aParent,TRect aExtent) + { + CColorAnimation::ConstructL(aParent, aExtent,KDrawingDsa); + _LIT(ThreadName,"Create new Window"); + iAnimRect=aExtent; + TInt error=iSem.CreateGlobal(KSem_DefectFix_KAA_5J3BLW_Name, 0); + if (error==KErrNone) + { + iThreadParam.iRect = iAnimRect; + iThreadParam.iIsInFront = EFalse; + TThreadStartUp function=TThreadStartUp(CreateNewWindowGroup, &iThreadParam); + TRequestStatus status; + iThread=CProcess::NewThreadRendezvousL(ThreadName,&function, status); + User::WaitForRequest(status); + if (status != KErrNone) + { + RDebug::Printf("the request status is returned to be non KErrNone: %d", status.Int()); + TestFailed(this); + } + iTestFailed = CIdle::NewL(0); + } + else + { + TestFailed(this); + } + } + +void CBugFixColorAnimation::AbortNow(RDirectScreenAccess::TTerminationReasons /*aReason*/) + { + Stop(); + if (!iTestFailed->IsActive()) + { + iTestFailed->Start(TCallBack(TestFailed,this)); + } + } + +void CBugFixColorAnimation::Restart(RDirectScreenAccess::TTerminationReasons aReason) + { + AbortNow(aReason); + } + +TInt CPanicDirect::DoTestOnNewSchedulerL(TInt aInt, TAny* aPtr) + { + CActiveScheduler* activeScheduler=new(ELeave) CActiveScheduler; + CActiveScheduler::Install(activeScheduler); + CleanupStack::PushL(activeScheduler); + DoTestNowL(aInt,aPtr); + CleanupStack::PopAndDestroy(activeScheduler); + return(EWsExitReasonBad); //calls to this method currently all ignore the return code anyway. + } + +TInt CPanicDirect::DoTestOnNewScheduler(TInt aInt, TAny* aPtr) + { + TInt rv=EWsExitReasonBad; + TRAP_IGNORE(rv=DoTestOnNewSchedulerL(aInt,aPtr)); + return(rv); //calls to this method currently all ignore the return code anyway. + } + +void CPanicDirect::DoTestNowL(TInt aInt, TAny* aPtr) + { + CPanicDirect* self=new(ELeave) CPanicDirect(); + CleanupStack::PushL(self); + self->ConstructL((TInt)aPtr, aInt); + self->TestL(); + CleanupStack::PopAndDestroy(self); + } + +void CPanicDirect::ConstructL(TInt aScreenNumber, TInt aInt) + { + iScreenNumber = aScreenNumber; + + User::LeaveIfError(iTimer.CreateLocal()); + User::LeaveIfError(iWs.Connect()); + iWsScrDev=new(ELeave) CWsScreenDevice(iWs); + User::LeaveIfError(iWsScrDev->Construct(iScreenNumber)); + +#if defined(LOGGING) + _LIT(KPanicThead1,"PanicThread: Into ConstructL"); + LogMessageText.Copy(KPanicThead1); + iWs.LogMessage(LogMessageText); + iWs.Flush(); +#endif + iGroup=RWindowGroup(iWs); + User::LeaveIfError(iGroup.Construct(2200+aInt,EFalse)); + iGroup.SetOrdinalPosition(0,KPanicTestOrdinalPriority); + iBlankWin=RBlankWindow(iWs); + User::LeaveIfError(iBlankWin.Construct(iGroup,2300+aInt)); + iBlankWin.Activate(); + iDirect=RDirectScreenAccess(iWs); + User::LeaveIfError(iDirect.Construct()); + iDisplayMode=iWsScrDev->DisplayMode(); +#if defined(LOGGING) + _LIT(KPanicThead2,"PanicThread: Creating Screen Device, Mode=%d"); + LogMessageText.Format(KPanicThead2,iDisplayMode); + iWs.LogMessage(LogMessageText); + iWs.Flush(); +#endif + iScreenDevice=CFbsScreenDevice::NewL(aScreenNumber,iDisplayMode); +#if defined(LOGGING) + _LIT(KPanicThead3,"PanicThread: Created Device"); + LogMessageText.Copy(KPanicThead3); + iWs.LogMessage(LogMessageText); + iWs.Flush(); +#endif + User::LeaveIfError(iScreenDevice->CreateContext(iGc)); +#if defined(LOGGING) + _LIT(KPanicThead4,"PanicThread: Created Context"); + LogMessageText.Copy(KPanicThead4); + iWs.LogMessage(LogMessageText); + iWs.Flush(); +#endif + iTextDraw=CScrollingTextDrawer::NewL(iScreenNumber,iScreenDevice,*iGc); +#if defined(LOGGING) + _LIT(KPanicThead5,"PanicThread: Created ScrollDrawer"); + LogMessageText.Copy(KPanicThead5); + iWs.LogMessage(LogMessageText); + iWs.Flush(); +#endif + iTextDraw->SetScrollJump(4); +#if defined(LOGGING) + _LIT(KCreatedDrawer,"PanicThread: CreatedDrawer"); + LogMessageText.Copy(KCreatedDrawer); + iWs.LogMessage(LogMessageText); + iWs.Flush(); +#endif + iTestNo=aInt; + } + +CPanicDirect::~CPanicDirect() + { + iDirect.Close(); + delete iGc; + delete iScreenDevice; + delete iTextDraw; + iBlankWin.Close(); + iGroup.Close(); + delete iWsScrDev; + iWs.Close(); + if (iRegion) + iRegion->Close(); + iTimer.Close(); + } + +void CPanicDirect::TestL() + { + if (iTestNo==2) + { + iDirect.Completed(); + return; + } + TInt err=iDirect.Request(iRegion,iDirectStatus,iBlankWin); + if (err!=KErrNone || !iRegion) + return; + TRect screen(iScreenDevice->SizeInPixels()); + TRect bounding=iRegion->BoundingRect(); + if (!screen.Contains(bounding.iTl) || !screen.Contains(bounding.iBr-TPoint(1,1))) + goto Cancel; + iGc->SetClippingRegion(iRegion); + iDrawingAllowed=ETrue; + iTimer.After(iTimerStatus,50000); //0.05secs + FOREVER + { + User::WaitForRequest(iDirectStatus,iTimerStatus); + if (iDirectStatus!=KRequestPending) + iDrawingAllowed=EFalse; + else if (iTimerStatus!=KRequestPending) + { + if (iDrawingAllowed) + DoDrawingL(); + iTimer.After(iTimerStatus,50000); //0.05secs + } + else + { + Cancel: + iDirect.Cancel(); + return; + } + } + } + +void CPanicDirect::DoDrawingL() + { + ++iCount; + iTextDraw->Scroll(); + if (iTestNo==1 && iCount==8) + { + iDirect.Request(iRegion,iDirectStatus,iBlankWin); + return; + } + if (iTestNo==3 && iCount==12) + { + iDirect.Completed(); + iDirect.Completed(); + return; + } + if (iTestNo==4 && iCount==16) + { + iBlankWin.SetSize(TSize(20,25)); + delete iRegion; + User::LeaveIfError(iDirect.Request(iRegion,iDirectStatus,iBlankWin)); + return; + } + if (iTestNo==5 && iCount==19) + { + iWs.Close(); + return; + } + } + + +/*CTDirect*/ + +CTDirect::CTDirect(CTestStep* aStep): + CTWsGraphicsBase(aStep) + { + iState = 0; + iNextFrameFinished = ETrue; + iPackagingFinished = EFalse; + iTimerRunning = EFalse; + } + +CTDirect::~CTDirect() + { + DeleteMoveWindow(); + DeleteScroll(); + + delete iAnim; + TheClient->WaitForRedrawsToFinish(); + delete iCallBackWin; + // put focus back to current screen as this test changed the focus screen to primary screen + TheClient->iWs.SetFocusScreen(iTest->iScreenNumber); + } + +void CTDirect::ConstructL() + { + _LIT(KCTDirectConstructL,"AUTO Construct Direct Test"); + LOG_MESSAGE(KCTDirectConstructL); + FullScreenModeSize=TheClient->iScreen->SizeInPixels(); + iIsScalingSupported=CheckScalingSupportedOrNot(); + iNumOfCallBack=0; + iCallBackWin=new(ELeave) CTBlankWindow; + iCallBackWin->ConstructL(*TheClient->iGroup); + User::LeaveIfError(iCallBackWin->BaseWin()->SetRequiredDisplayMode(EColor256)); + iCallBackWin->SetExt(TPoint(),TheClient->iScreen->SizeInPixels()); + iCallBackWin->SetVisible(EFalse); + iCallBackWin->Activate(); + // the following line makes sure that a console object hidden outside of + // screens range doesn't affect test results being on top of tested objects + TheClient->iGroup->GroupWin()->SetOrdinalPosition(0, KMainTestBaseWindow); + } + +void CTDirect::ConstrucBlankWindowL() + { + delete iWin; + iWin=new(ELeave) CTBlankWindow; + iWin->ConstructL(*TheClient->iGroup); + iWin->BaseWin()->SetShadowDisabled(ETrue); + iWin->BaseWin()->Activate(); + TheClient->Flush(); + } + +void CTDirect::InitialiseAnimationL() + { + ConstrucBlankWindowL(); + TInt colors,greys; + TDisplayMode dispMode=TheClient->iWs.GetDefModeMaxNumColors(colors,greys); + iScrDev=CFbsScreenDevice::NewL(iTest->iScreenNumber,dispMode); + User::LeaveIfError(iScrDev->CreateContext(iGc)); + INFO_PRINTF1(_L(" Constructed Screen Device")); + iScrSize=iScrDev->SizeInPixels(); + TFontSpec fontSpec(FontName,iScrSize.iHeight); + fontSpec.iFontStyle.SetStrokeWeight(EStrokeWeightBold); + User::LeaveIfError(iScrDev->GetNearestFontToDesignHeightInPixels(iFont,fontSpec)); + iGc->UseFont(iFont); + iFlags|=eFontSet; + iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + TInt fontHeight=iFont->HeightInPixels(); + iDrawRect.iTl.iY=(iScrSize.iHeight-fontHeight)/2; + iDrawRect.SetHeight(fontHeight); + iDrawHeight=iFont->AscentInPixels(); + TSize winSize(25,20); + iWin2=new(ELeave) CTBlankWindow; + iWin2->ConstructL(*TheClient->iGroup); + iWin2->SetExt(TPoint((iScrSize.iWidth-winSize.iWidth)/2,(iScrSize.iHeight-winSize.iHeight)/2),winSize); + iWin2->SetColor(TRgb::Gray4(2)); + iWin2->BaseWin()->Activate(); + INFO_PRINTF1(_L(" Setup Window")); + iScrDev->Update(); + TheClient->iWs.Finish(); + + User::LeaveIfError(iControlSem.CreateGlobal(SemControl,0,KOwnerType)); + User::LeaveIfError(iControlQueue.CreateGlobal(QueueControl,1,sizeof(TInt),KOwnerType)); + + iFlags|=eDirectControlSem; + User::LeaveIfError(iWinSem.CreateGlobal(SemNextOp,0,KOwnerType)); + iFlags|=eDirectWindowSem; + iProcess=CProcess::NewTL(CProcess::eProcessDirectTest,iTest->iScreenNumber,&iThreadStatus); + INFO_PRINTF1(_L(" Constructed Semaphores & Thread")); + iControlSem.Wait(); + + iTimer=CPeriodic::NewL(iTest->EAutoTestPriority); + iRestart=CIdle::NewL(iTest->EAutoTestPriority+5); + iDirect=CDirectScreenAccessOld::NewL(TheClient->iWs,*this); + } + +void CTDirect::DestroyAnimation() + { + ResetScreenSizeMode(); + if(iProcess && iProcess->StillAlive()) + { + if (iFlags&eDirectControlSem) + { + iControlSem.Signal(); + TInt data = 3; + iControlQueue.Send(&data,sizeof(TInt)); + } + if (iFlags&eDirectWindowSem) + iWinSem.Signal(); + } + + delete iTimer; + iTimer=NULL; + delete iRestart; + iRestart=NULL; + delete iDirect; + iDirect=NULL; + delete iChangeScreenModeTimer; + iChangeScreenModeTimer=NULL; + delete iScreenModeTimer; + iScreenModeTimer=NULL; + + if (iFlags&eFontSet) + { + iGc->DiscardFont(); + iScrDev->ReleaseFont(iFont); + } + delete iGc; + if (iDrawingRegion) + iDrawingRegion->Destroy(); + delete iScrDev; + delete iWin; + delete iWin2; + if (iProcess) + { + User::WaitForRequest(iThreadStatus); + delete iProcess; + iProcess = NULL; + } + if (iFlags&eDirectControlSem) + { + iControlSem.Close(); + iControlQueue.Close(); + } + if (iFlags&eDirectWindowSem) + iWinSem.Close(); + } + +void CTDirect::ResetScreenSizeMode() + { + if (iModeBackup!=ESizeEnforcementNone) + { + TheClient->iScreen->SetScreenModeEnforcement(ESizeEnforcementNone); + iModeBackup=ESizeEnforcementNone; + } + TheClient->iScreen->SetCurrentRotations(0,CFbsBitGc::EGraphicsOrientationNormal); + TheClient->iScreen->SetScreenMode(0); + TPixelsAndRotation pixelsAndRotation; + TheClient->iScreen->GetDefaultScreenSizeAndRotation(pixelsAndRotation); + TheClient->iScreen->SetScreenSizeAndRotation(pixelsAndRotation); + User::After(350000); //0.35secs + } + +void CTDirect::ScanTypeFacesL() + { + CFbsScreenDevice* scrdev=CFbsScreenDevice::NewL(iTest->iScreenNumber,EGray4); + TTypefaceSupport typeFace; + TInt numFaces=scrdev->NumTypefaces(); + TInt ii; + for (ii=0;iiTypefaceSupport(typeFace,ii); + } + delete scrdev; + } + +TInt RestartAnimation(TAny* aTest) + { + STATIC_CAST(CTDirect*,aTest)->Restart(); + return(KErrNone); + } + +TInt NextFrame(TAny* aTest) + { + STATIC_CAST(CTDirect*,aTest)->DrawFrame(); + return(KErrNone); + } + +void CTDirect::AbortNow(RDirectScreenAccess::TTerminationReasons aReason) + { + TEST(aReason==RDirectScreenAccess::ETerminateRegion); + + if (iDelay) + User::After(2000000); //2 secs + if (iCancelNext) + { + iFrameNo=eDirectNumFrames; + iTimer->Cancel(); + iDirect->Cancel(); + TheClient->Flush(); + iNextFrameFinished = ETrue; + iState++; + return; + } + iRestart->Start(TCallBack(RestartAnimation,this)); + } + +TBool CTDirect::Restart() + { + StartDirect(); + return ETrue; + } + +#pragma warning( disable : 4244 ) //conversion from 'int' to 'unsigned short', possible loss of data +TBool CTDirect::DrawFrame() + { + if (iFrameNo==eDirectNumFrames) + { + iState++; + iTimer->Cancel(); + if (iFrameNo==eDirectNumFrames) + iDirect->Cancel(); + iNextFrameFinished = ETrue; + return EFalse; + } + _LIT(Text,"A0"); + TBuf<2> iString(Text); //_LIT(Text,"ABCabc123"); + iString[0]+=iFrameNo; + iString[1]+=iFrameNo; + TInt textWidth=iFont->TextWidthInPixels(iString); + TInt maxTextWidth=Max(textWidth,iLastTextWidth); + iLastTextWidth=textWidth; + if (iLastMaxTextWidth!=maxTextWidth) + { + iLastMaxTextWidth=maxTextWidth; + iDrawRect.iTl.iX=(iScrSize.iWidth-iLastMaxTextWidth)/2; + iDrawRect.SetWidth(iLastMaxTextWidth); + } + TInt colorOffset=iFrameNo%2; + iGc->SetPenColor(TRgb::Gray4(colorOffset)); + iGc->DrawText(iString,iDrawRect,iDrawHeight,CGraphicsContext::ECenter); + iGc->SetPenColor(TRgb::Gray4(1+colorOffset)); + iGc->DrawLine(TPoint(),iScrSize.AsPoint()); + iGc->DrawLine(TPoint(iScrSize.iWidth,0),TPoint(0,iScrSize.iHeight)); + iGc->DrawLine(TPoint(iScrSize.iWidth/2,0),TPoint(iScrSize.iWidth/2,iScrSize.iHeight)); + iGc->DrawLine(TPoint(0,iScrSize.iHeight/2),TPoint(iScrSize.iWidth,iScrSize.iHeight/2)); + iScrDev->Update(); + ++iFrameNo; + if (iFrameNo==iFrameToSignalAfter) + SignalWindow(); + return ETrue; + } +#pragma warning( default : 4244 ) + +void CTDirect::SignalWindow() + { + switch(iState) + { + case 0: + switch(iFrameNo) + { + case 0: + iFrameToSignalAfter=0; + } + return; + case 1: + case 3: + switch(iFrameNo) + { + case 0: + iFrameToSignalAfter=3; + iDelay=(iState==3); + return; + case 3: + WinExt.SetSize(TSize(iScrSize.iWidth/2-5,iScrSize.iHeight/2+30)); + iFrameToSignalAfter=5; + break; + case 5: + iFrameToSignalAfter=7; + break; + case 7: + WinExt.SetSize(TSize(iScrSize.iWidth/2+30,iScrSize.iHeight/2-5)); + WinCol=1; + iFrameToSignalAfter=8; + break; + case 8: + iFrameToSignalAfter=0; + iDelay=EFalse; + break; + } + break; + case 2: + switch(iFrameNo) + { + case 0: + iFrameToSignalAfter=2; + return; + case 2: + WinExt.SetRect(TPoint(iScrSize.iWidth/2-15,iScrSize.iHeight/2-20),TSize(iScrSize.iWidth/3,iScrSize.iHeight/3)); + WinCol=2; + iFrameToSignalAfter=5; + break; + case 5: + iFrameToSignalAfter=6; + break; + case 6: + WinExt.SetRect(TPoint(iScrSize.iWidth/2-50,iScrSize.iHeight/3),TSize(iScrSize.iWidth/4,iScrSize.iHeight/3)); + WinCol=3; + iFrameToSignalAfter=8; + break; + case 8: + iFrameToSignalAfter=0; + break; + } + break; + case 4: + switch(iFrameNo) + { + case 0: + iFrameToSignalAfter=3; + return; + case 3: + iFrameToSignalAfter=6; + iWin2->SetVisible(EFalse); + TheClient->Flush(); + return; + case 6: + iFrameToSignalAfter=0; + iWin2->SetVisible(ETrue); + TheClient->Flush(); + return; + } + break; + case 5: + switch(iFrameNo) + { + case 0: + iFrameToSignalAfter=6; + return; + case 6: + iFrameToSignalAfter=0; + WinExt.SetRect(10,10,20,20); + iCancelNext=ETrue; + break; + } + break; + case 6: + switch(iFrameNo) + { + case 0: + iFrameToSignalAfter=7; + iCancelNext=EFalse; + return; + case 7: + iFrameToSignalAfter=0; + delete iWin; + TheClient->Flush(); + iWin=NULL; + iWindowDead=ETrue; + return; + } + break; + } +#if defined(LOGGING) + _LIT(KSignal,"Signaling Move Window"); + LogMessageText.Copy(KSignal); + TheClient->iWs.LogMessage(LogMessageText); + TheClient->Flush(); +#endif + iWinSem.Signal(); + } + +void CTDirect::StartDirect() + { + if (iWin==NULL) + { + TEST(iWindowDead); + if (!iWindowDead) + INFO_PRINTF3(_L("iWindowDead - Expected: %d, Actual: %d"), ETrue, iWindowDead); + + iFrameNo=eDirectNumFrames; + return; + } + TEST(!iWindowDead); + if (iWindowDead) + INFO_PRINTF3(_L("iWindowDead - Expected: %d, Actual: %d"), EFalse, iWindowDead); + + if (iDrawingRegion) + iDrawingRegion->Destroy(); + TInt retVal = iDirect->Request(iDrawingRegion,*iWin->BaseWin()); + TEST(retVal==KErrNone); + if (retVal!=KErrNone) + INFO_PRINTF3(_L("iDirect->Request(iDrawingRegion,*iWin->BaseWin()) return value - Expected: %d, Actual: %d"), KErrNone, retVal); + + iGc->SetClippingRegion(iDrawingRegion); + } + +void CTDirect::LogLeave(TInt aErr) + { + iTest->LogLeave(aErr); + } + +void CTDirect::Fail() + { + TEST(EFalse); + } + +void CTDirect::Finished(TInt aId) + { + //aId refers to the animation, it is not the test number + _LIT(KCTDirectFinished,"Destroying animation number %d"); + LOG_MESSAGE2(KCTDirectFinished,aId); + switch (aId) + { + case 10: + case 11: + ResetScreenSizeMode(); + case 9: + iPackagingFinished = ETrue; + case 8: + DeleteMoveWindow(); + //iPackagingFinished = ETrue; + if (iScroll) + { + DeleteScroll(); + #if defined(LOGGING) + _LIT(KDeleteScroll,"Deleting Scroll Text Id=%d TimerActive=%d"); + LogMessageText.Zero(); + LogMessageText.AppendFormat(KDeleteScroll,aId,iAnim->IsTimerActive()); + TheClient->iWs.LogMessage(LogMessageText); + TheClient->Flush(); + #endif + } + if (aId==8 && iAnim->IsTimerActive()) + return; + case 1: + case 12: + case 25: //case DSA using Region tracking Only (abort signal expceted) + case 26: //case DSA using Region tracking Only (abort signal not expceted) + { + iPackagingFinished = ETrue; + delete iAnim; + iAnim=NULL; +CHECKHANDLES: + TInt numProcessHandles; + TInt numThreadHandles; + RThread().HandleCount(numProcessHandles,numThreadHandles); + TEST(Abs(numThreadHandles-iNumThreadHandles)<2); + if (Abs(numThreadHandles-iNumThreadHandles)>=2) + INFO_PRINTF3(_L("Abs(numThreadHandles-iNumThreadHandles)<2 - Expected: %d or less, Actual: %d"), 2, Abs(numThreadHandles-iNumThreadHandles)); + } + break; + case 16: + case 15: + { + // Stop the animation and delete it, but make sure that you don't increment iState and call Rquest() + // until this is the second call i.e. one of aId = 15 or aId = 16 has already been finished. + TInt index = aId-15; + iAnims[index]->Stop(); + delete iAnims[index]; + iAnims[index]=NULL; + // This test creates two animations iAnims[0] and iAnims[1]. + // Use (index ^ 1 ) = Toggle the Index, to get the index of other animation. + // If iAnims [ index ^ 1] is NULL then this is the second Call and test is finished. + if (iAnims[index ^ 1] != NULL) + { + return; + } + iPackagingFinished = ETrue; + goto CHECKHANDLES; + } + case 13: + { + iPackagingFinished = ETrue; + delete iBlankTopClientWin1; + // delete iBlankTopClientWin2; + TInt jj; + for (jj=0;jj<4;++jj) + iAnims[jj]->Stop(); + for (jj=0;jj<4;++jj) + delete iAnims[jj]; + break; + } + case 14: + { + iPackagingFinished = ETrue; + iAnims[0]->Stop(); + delete iAnims[0]; + if (iNumOfModes==iCurrentMode) + { + ResetScreenSizeMode(); + iCallBackWin->SetVisible(EFalse); + break; + } + break; + } + case 18: + case 17: + { + // Stop the animation and delete it, but make sure that you don't increment iState and call Rquest() + // until this is the second call i.e. one of aId = 17 or aId = 18 has already been finished. + TInt ii = 0; + TBool finished = ETrue; + if (aId == 17) + { + iAnims[0]->Stop(); + delete iAnims[0]; + iAnims[0] = NULL; + for (ii=1;ii<=iNumAnimation;++ii) + { + if (iAnims[ii]) + { + finished = EFalse; + break; + } + } + } + else // aId == 18 + { + for (ii=1;ii<=iNumAnimation;++ii) + { + iAnims[ii]->Stop(); + delete iAnims[ii]; + iAnims[ii] = NULL; + } + if (iAnims[0]) + { + finished = EFalse; + } + } + if (!finished) + { + return; + } + iPackagingFinished = ETrue; + break; + } + case 19: + { + iPackagingFinished = ETrue; + iAnims[0]->Stop(); + delete iAnims[0]; + break; + } + case 21: + case 20: + { + // Stop the animation and delete it, but make sure that you don't increment iState and call Rquest() + // until this is the second call i.e. one of aId = 20 or aId = 21 has already been finished. + TInt index = aId-20; + iAnims[index]->Stop(); + delete iAnims[index]; + iAnims[index]=NULL; + // This test creates two animations iAnims[0] and iAnims[1]. + // Use (index ^ 1 ) = Toggle the Index, to get the index of other animation. + // If iAnims [ index ^ 1] is NULL then this is the second Call and test is finished. + if (iAnims[index ^ 1] != NULL) + { + return; + } + DeleteMoveWindow(); + iPackagingFinished = ETrue; + goto CHECKHANDLES; + } //unreachable line, no need for break + case 24: + iPackagingFinished = ETrue; + iAnim->Stop(); + delete iAnim; + iAnim=NULL; + //don't want to increase state, so decrement, since it is incremented below + //as part of processing normal completions. This is to reenter the test + //to call Fail() if required + iState--; + break; + + case 27: + case 28: + case 29: + case 30: + case 31: + case 32: + iAnims[aId-27]->Stop(); + delete iAnims[aId-27]; + iAnims[aId-27] = NULL; + if(aId != 32) + { + return; + } + DeleteMoveWindow(); + iPackagingFinished = ETrue; + break; + default: + iPackagingFinished = ETrue; + TInt ii; + for (ii=0;ii<6;++ii) + iAnims[ii]->Stop(); + for (ii=0;ii<6;++ii) + delete iAnims[ii]; + DeleteMoveWindow(); + break; + } +#if defined(LOGGING) + _LIT(KRequest,"Signal Start NextTest Id=%d, State=%d(+1)"); + LogMessageText.Zero(); + LogMessageText.AppendFormat(KRequest,aId,iState); + TheClient->iWs.LogMessage(LogMessageText); + TheClient->Flush(); +#endif + iState++; + } + +void CTDirect::DeleteMoveWindow() + { + if (iMoveWin) + { + TRequestStatus status; + iMoveWin->Logon(status); + if (iMoveWin->StillAlive()) + { + iMoveWin->Terminate(KErrNone); + User::WaitForRequest(status); + } + delete iMoveWin; + iMoveWin=NULL; + } + } + +void CTDirect::DeleteScroll() + { + if (iScroll) + { + TheClient->iScreen->SetScreenMode(0); + iScroll->Stop(); + delete iScroll; + iScroll=NULL; + } + } + +TDisplayMode CTDirect::DisplayMode(TInt aId) + { + switch (aId) + { + case 1: + case 13: + case 15: + case 16: + return EColor16; + case 2: + return EGray16; + case 3: + return EColor16; + case 4: + case 14: + case 17: + case 18: + case 19: + case 24: + return EColor256; + case 5: + return EGray256; + case 6: + return EColor4K; + case 7: + return EColor64K; + case 8: + case 9: + case 10: + case 11: + case 12: + { + TInt colors,grays; + /*TDisplayMode mode=*/TheClient->iWs.GetDefModeMaxNumColors(colors,grays); + if (colors==0) + return EGray4; + return (aId==8? EGray16:EColor16); + } + default:; + return TheClient->iScreen->DisplayMode(); + } + } + +void CTDirect::Log(const TText8* aFile, TInt aLine, TInt aSeverity,const TDesC& aString) + { + Logger().LogExtra(((TText8*)aFile), aLine, aSeverity, aString) ; + } + +TRgb CTDirect::BrushColorL(TInt aId,TInt& aColor,TBool& aFinished) + { + aFinished=EFalse; + switch (aId) + { + case 1: + case 13: + case 14: + case 15: + case 16: + case 17: + case 18: + case 19: + case 20: + case 21: + case 27: + aFinished=(aColor==20); + return TRgb::Color16(27 + aColor++); + case 28: + aFinished=(aColor==17); + return TRgb::Color16(28 + aColor++); + case 29: + aFinished=(aColor==15); + return TRgb::Color16(29 + aColor++); + case 8: + if (aColor==15) + { + ++iCycles; + aFinished=(iCycles==5); + } + else if (!iScroll) + aFinished=ETrue; + else if (!iScroll->IsRunning()) + iScroll->ContinueL(); + { + #if defined(LOGGING) + if (aFinished || iScroll==NULL) + { + _LIT(KColor,"Col=%d Cycles=%d Fin=%d iScroll=%d"); + LogMessageText.Zero(); + LogMessageText.AppendFormat(KColor,aColor,iCycles,aFinished,(TInt&)iScroll); + TheClient->iWs.LogMessage(LogMessageText); + TheClient->Flush(); + } + #endif + } + case 2: + if (aColor==16) + aColor=0; + return TRgb::Gray16(aColor++); + case 9: + case 10: + aFinished=iCycles>3; + case 11: + case 3: + if (aColor==16) + { + ++iCycles; + aColor=0; + } + return TRgb::Color16(aColor++); + case 4: + aFinished=(aColor==256); + return TRgb::Color256(aColor++); + case 5: + if (aColor==256) + aColor=0; + return TRgb::Gray256(aColor++); + case 6: + aColor+=127; + if (aColor>4095) + aColor-=4096; + return TRgb::Color4K(aColor); + case 7: + aColor+=211; + if (aColor>65535) + aColor-=65536; + return TRgb::Color64K(aColor++); + case 12: + aFinished=2*(aColor>5); + return TRgb::Color16(aColor++); + case 24: + iCycles++; + if (iCycles==5) + { + aFinished=ETrue; + CheckForTemporaryDeadlock(); + } + return TRgb::Color16(aColor++); + case 30: + aFinished=(aColor==256); + return TRgb::Color16(aColor++); + case 31: + aFinished=(aColor==100); + return TRgb::Color16(aColor++); + case 32: + aFinished=(aColor==300); + return TRgb::Color16(aColor++); + default:; + aFinished=ETrue; + return TRgb::Gray2(1); //White + } + } + +TInt CTDirect::TimerInterval(TInt aId) + { + switch (aId) + { + case 1: + case 15: + case 16: + case 17: + case 18: + case 20: + case 21: + return 143200; + case 27: + return 200000; + case 28: + return 180000; + case 29: + return 170000; + case 30: + return 200000; + case 31: + return 205000; + case 32: + return 300000; + case 2: + case 25: + case 26: + return 234567; + case 3: + return 200000; + case 4: + return 11718; + case 5: + return 13719; + case 6: + return 14719; + case 7: + return 15719; + case 8: + return 275000; + case 9: + return 210000; + case 10: + return 110000; + case 11: + return 123456; + case 12: + return 10627; + case 19: + return 1000000; + default:; + return 1; + } + } + +void CTDirect::FailedReStart(TInt /*aId*/,TInt /*aReason*/) + { + Fail(); + } + +TInt CTDirect::SlowStopping(TInt aId,TInt aCount) + { + if (aId==8) + return (aCount>1 ? CColorAnimation::eAbortAll : CColorAnimation::eStopNow); + if (aId==9 || aId==10) + return CColorAnimation::eStopNow; + TInt ret=(2*aId-3==aCount%12); + if (ret && aId==5) + { + ++iCount; + if (iCount==5) + return CColorAnimation::eAbort; + } + return ret; + } + +void CTDirect::ModeSwitch() + { + TRAPD(err,iAnim->ChangeModeL(EGray4)); + iWin2->SetSize(TSize(20,25)); + TheClient->Flush(); + if (err!=KErrNone) + Fail(); + } + +TestState CTDirect::AnimateWindowL() + { +// if (!iTimer->IsActive()) + { + + + iFrameNo=0; + SignalWindow(); + + + iTimer->Start(0,200000,TCallBack(NextFrame,this)); //0.2 secs + + StartDirect(); + TEST(iDrawingRegion->BoundingRect()==iScrSize); + } +// else +// { +// int i=0; +// } + return EWait; + } + +TestState CTDirect::AnimationDiesL() + { + INFO_PRINTF1(_L("AUTO Animation Dies ")); + _LIT(ThreadName,"AnimationDie"); + iFirstFunction=TThreadStartUp(CAnimating::StartLC,(TAny*)iTest->iScreenNumber); + CProcess* thread=CProcess::NewThreadL(ThreadName,&iFirstFunction); + CleanupStack::PushL(thread); + thread->LeaveIfDied(); + INFO_PRINTF1(_L(" Constructed Thread")); + iControlSem.Wait(); + RWindowGroup group(TheClient->iWs); + group.Construct(431,EFalse); + RBlankWindow win(TheClient->iWs); + win.Construct(group,432); + win.SetExtent(TPoint(12,34),TSize(56,78)); + win.Activate(); + INFO_PRINTF1(_L(" Constructed Windows")); + iControlSem.Wait(); + User::After(1000000); //1 sec + TRequestStatus threadDied; + thread->Logon(threadDied); + thread->Terminate(KErrGeneral); + INFO_PRINTF1(_L(" Waiting for Thread")); + User::WaitForRequest(threadDied); + CleanupStack::PopAndDestroy(thread); + win.Close(); + group.Close(); + INFO_PRINTF1(_L(" Finished")); + return ENext; + } + +TestState CTDirect::PackagingClassL() + { + ConstrucBlankWindowL(); + TInt numProcessHandles; + RThread().HandleCount(numProcessHandles,iNumThreadHandles); + iAnim=CColorAnimation::NewL(iTest->iScreenNumber,1,*this,*TheClient->iGroup,TRect(10,10,630,230),ETrue); + return EWait; + } + +TestState CTDirect::MultipleL() + { + TSize scrSize=TheClient->iScreen->SizeInPixels(); + + iFlags|=eMultiAnim; + iAnims[0]=CColorAnimation::NewL(iTest->iScreenNumber,2,*this,*TheClient->iGroup, + TRect(0,10,scrSize.iWidth/3+20,scrSize.iHeight/2-5),EFalse); + iAnims[1]=CColorAnimation::NewL(iTest->iScreenNumber,3,*this,*TheClient->iGroup, + TRect(10,scrSize.iHeight/2-20,scrSize.iWidth/3-5,scrSize.iHeight),EFalse); + iAnims[3]=CColorAnimation::NewL(iTest->iScreenNumber,5,*this,*TheClient->iGroup, + TRect(scrSize.iWidth/3-20,scrSize.iHeight/2+5,2*scrSize.iWidth/3+20,scrSize.iHeight-10),EFalse); + iAnims[2]=CColorAnimation::NewL(iTest->iScreenNumber,4,*this,*TheClient->iGroup, + TRect(scrSize.iWidth/3+5,0,2*scrSize.iWidth/3-5,scrSize.iHeight/2+20),EFalse); + iAnims[4]=CColorAnimation::NewL(iTest->iScreenNumber,6,*this,*TheClient->iGroup, + TRect(2*scrSize.iWidth/3-20,15,scrSize.iWidth,scrSize.iHeight/2+50),EFalse); + iAnims[5]=CColorAnimation::NewL(iTest->iScreenNumber,7,*this,*TheClient->iGroup, + TRect(2*scrSize.iWidth/3+5,-20,scrSize.iWidth-15,scrSize.iHeight+10),ETrue); + TInt ii; + for (ii=0;ii<5;++ii) + iAnims[ii]->StartL(); + _LIT(ThreadName,"MoveWin"); + + MoveInterval=100000; //0.1 secs + ModeInterval=1200000; //1.2 sec + ImmediateModeSwitch=EFalse; + iFirstFunction=TThreadStartUp(CMoveWindow::StartLC,(TAny*)iTest->iScreenNumber); + iMoveWin=CProcess::NewThreadL(ThreadName,&iFirstFunction); + return EWait; + } + +TestState CTDirect::MixDsaAndRegionTrackingOnlyL(TBool aWhoExitsLast) + { + TSize scrSize=TheClient->iScreen->SizeInPixels(); + + iFlags|=eMultiAnim; + TUint firstRegionTrackinOnlyDsa = (aWhoExitsLast == KRegionTrackingOnlyDsaExistLast ? 0 : 3); + TUint firstDrawingDsa = (aWhoExitsLast == KDrawingDsaExistLast ? 0 : 3); + + //DSAs who use region tracking only + iAnims[firstRegionTrackinOnlyDsa]=CColorAnimation::NewL(iTest->iScreenNumber,firstRegionTrackinOnlyDsa+27,*this,*TheClient->iGroup, + TRect(10,scrSize.iHeight/2-20,scrSize.iWidth/3-5,scrSize.iHeight),EFalse,KRegionTrackingOnly); + iAnims[firstRegionTrackinOnlyDsa+1]=CColorAnimation::NewL(iTest->iScreenNumber,firstRegionTrackinOnlyDsa+28,*this,*TheClient->iGroup, + TRect(2*scrSize.iWidth/3-20,15,scrSize.iWidth,scrSize.iHeight/2+50),EFalse,KRegionTrackingOnly); + iAnims[firstRegionTrackinOnlyDsa+2]=CColorAnimation::NewL(iTest->iScreenNumber,firstRegionTrackinOnlyDsa+29,*this,*TheClient->iGroup, + TRect(2*scrSize.iWidth/3+5,-20,scrSize.iWidth-15,scrSize.iHeight+10),EFalse,KRegionTrackingOnly); + + //DSAs who actually draw + iAnims[firstDrawingDsa]=CColorAnimation::NewL(iTest->iScreenNumber,firstDrawingDsa+27,*this,*TheClient->iGroup, + TRect(0,10,scrSize.iWidth/3+20,scrSize.iHeight/2-5),EFalse,KDrawingDsa); + iAnims[firstDrawingDsa+1]=CColorAnimation::NewL(iTest->iScreenNumber,firstDrawingDsa+28,*this,*TheClient->iGroup, + TRect(scrSize.iWidth/3+5,0,2*scrSize.iWidth/3-5,scrSize.iHeight/2+20),EFalse,KDrawingDsa); + iAnims[firstDrawingDsa+2]=CColorAnimation::NewL(iTest->iScreenNumber,firstDrawingDsa+29,*this,*TheClient->iGroup, + TRect(scrSize.iWidth/3-20,scrSize.iHeight/2+5,2*scrSize.iWidth/3+20,scrSize.iHeight-10),EFalse,KDrawingDsa); + + TInt ii; + for (ii=0;ii<6;++ii) + { + if(iAnims[ii]) + iAnims[ii]->StartL(); + } + + _LIT(ThreadName,"MoveWin"); + + MoveInterval=100000; //0.1 secs + ModeInterval=1200000; //1.2 secs + ImmediateModeSwitch=EFalse; + iFirstFunction=TThreadStartUp(CMoveWindow::StartLC,(TAny*)iTest->iScreenNumber); + iMoveWin=CProcess::NewThreadL(ThreadName,&iFirstFunction); + return EWait; + } + +TestState CTDirect::TryDifferentSupportedModesL() + { + + RWsSession session; + User::LeaveIfError(session.Connect()); + CWsScreenDevice* device = new(ELeave) CWsScreenDevice(session); + CleanupStack::PushL(device); + User::LeaveIfError(device->Construct(iTest->iScreenNumber)); + TUint numOfModes=device->NumScreenModes(); + _LIT(KTryingCurrentMode,"Trying Mode = %d"); + for(TUint currentMode =0; currentMode < numOfModes; currentMode++) + { + LOG_MESSAGE2(KTryingCurrentMode,currentMode); + device->SetScreenMode(currentMode); + TRAPD(err,iAnims[0]=CColorAnimation::NewL(iTest->iScreenNumber,4,*this,*TheClient->iGroup, + TRect(0,0,50,50),ETrue)); + if(err!=KErrNone) + { + TEST(EFalse); + } + else + { + User::After(2000000); + iAnims[0]->Stop(); + delete iAnims[0]; + } + } + CleanupStack::PopAndDestroy(device); + session.Close(); + iState++; + return EWait; + } + + +TestState CTDirect::FailCodesL() + { + __UHEAP_MARK; + TRequestStatus status; + RRegion region(TRect(0,0,10,10),1); + RRegion* pRegion=®ion; + RDirectScreenAccess direct(TheClient->iWs); + User::LeaveIfError(direct.Construct()); + RBlankWindow window(TheClient->iWs); + User::LeaveIfError(window.Construct(*TheClient->iGroup->WinTreeNode(),1234)); + TInt err=direct.Request(pRegion,status,window); + TEST(err==KErrNone); + if (err!=KErrNone) + INFO_PRINTF3(_L("direct.Request(pRegion,status,window) return value - Expected: %d, Actual: %d"), KErrNone, err); + TEST(pRegion!=NULL); + if (pRegion==NULL) + INFO_PRINTF3(_L("pRegion!=NULL - Expected: %d, Actual: %d"), 0, 0); + pRegion->Destroy(); + direct.Cancel(); + User::WaitForRequest(status); + window.Activate(); + window.SetOrdinalPosition(-2); + pRegion=®ion; + err=direct.Request(pRegion,status,window); + TEST(err==KErrNone); + if (err!=KErrNone) + INFO_PRINTF3(_L("direct.Request(pRegion,status,window) return value - Expected: %d, Actual: %d"), KErrNone, err); + TEST(pRegion!=NULL); + if (pRegion==NULL) + INFO_PRINTF3(_L("pRegion!=NULL - Expected: %d, Actual: %d"), 0, 0); + pRegion->Destroy(); + direct.Cancel(); + User::WaitForRequest(status); +#if defined(__WINS__) + // Loop over the allocations done. + // There is one allocating of the rectangle list and + // one of the region holding the list + for (TInt rate = 1; rate <= 2; rate++) + { + window.SetOrdinalPosition(0); + pRegion=®ion; + TheClient->Flush(); + __UHEAP_FAILNEXT(rate); + err=direct.Request(pRegion,status,window); + TEST(err==KErrNoMemory); + if (err!=KErrNoMemory) + INFO_PRINTF3(_L("direct.Request(pRegion,status,window) return value - Expected: %d, Actual: %d"), KErrNoMemory, err); + + TEST(pRegion==NULL); + if (pRegion!=NULL) + INFO_PRINTF3(_L("pRegion!=NULL - Expected: %d, Actual: %d"), 0, 0); + } +#endif + window.Close(); + direct.Close(); + region.Close(); + __UHEAP_MARKEND; + return ENext; + } + +void CTDirect::ScrolingTextL(TInt aId,TRect aWinRect,TBool aStartThread,TInt aScreenMode/*=0*/) + { + INFO_PRINTF1(_L("AUTO Construct ScrolingText ")); + INFO_PRINTF1(_L(" Constructed Window")); + iCycles=0; + TInt numProcessHandles; + RThread().HandleCount(numProcessHandles,iNumThreadHandles); + iAnim=CColorAnimation::NewL(iTest->iScreenNumber,aId,*this,*TheClient->iGroup,aWinRect,EFalse); + iScroll=CScrollText::NewL(iTest->iScreenNumber,1,*TheClient->iGroup,5,EFalse); + INFO_PRINTF1(_L(" Constructed Text Scroller & Animation")); + iAnim->BringWindowToFront(); + if (aStartThread) + { + _LIT(ThreadName,"MoveWin"); + INFO_PRINTF1(_L(" About to constructed Thread")); + iFirstFunction=TThreadStartUp(CMoveWindow::StartLC,(TAny*)iTest->iScreenNumber); + __ASSERT_DEBUG(!iMoveWin,AutoPanic(EAutoPanicDirect)); + iMoveWin=CProcess::NewThreadL(ThreadName,&iFirstFunction); + INFO_PRINTF1(_L(" Constructed Thread")); + } + if (aScreenMode>0) + { + TInt numScreenModes = TheClient->iScreen->NumScreenModes(); + if (aScreenMode < numScreenModes) + TheClient->iScreen->SetScreenMode(aScreenMode); + else + LOG_MESSAGE(_L("WARNING: Failed to change screen mode")); + // We have to run the test anyway to avoid things going wrong later + } + iAnim->StartOrPanic(); + iScroll->StartL(); + INFO_PRINTF1(_L(" Constructed/Started")); +#if defined(LOGGING) + _LIT(KStarted,"Finished StartUp ScrollText"); + LogMessageText.Copy(KStarted); + TheClient->iWs.LogMessage(LogMessageText); + TheClient->Flush(); +#endif + } + +TestState CTDirect::ScrolingText1L() + { + MoveInterval=0; + ModeInterval=1200000; //1.2 sec + ScrolingTextL(8,TRect(20,20,40,40),ETrue); + return EWait; + } + +TestState CTDirect::RClassL() + { +#if defined(LOGGING) + _LIT(KRClass,"Starting Panic test on RClass"); + LogMessageText.Zero(); + LogMessageText.AppendFormat(KRClass); + TheClient->iWs.LogMessage(LogMessageText); + TheClient->Flush(); +#endif + TEST(iTest->TestWsPanicL(CPanicDirect::DoTestOnNewScheduler,EWservPanicDirectMisuse,1,(TAny*)iTest->iScreenNumber)); +#if defined(LOGGING) + _LIT(KPanic1,"Done First Panic"); + LogMessageText.Zero(); + LogMessageText.AppendFormat(KPanic1); + TheClient->iWs.LogMessage(LogMessageText); + TheClient->Flush(); +#endif +#if defined(__WINS__) +#if defined(LOGGING) + _LIT(KPanic2,"Doing 2 debug panics"); + LogMessageText.Zero(); + LogMessageText.AppendFormat(KPanic2); + TheClient->iWs.LogMessage(LogMessageText); + TheClient->Flush(); +#endif + TEST(iTest->TestW32PanicL(CPanicDirect::DoTestOnNewScheduler,EW32PanicDirectMisuse,2,(TAny*)iTest->iScreenNumber)); + TEST(iTest->TestW32PanicL(CPanicDirect::DoTestOnNewScheduler,EW32PanicDirectMisuse,3,(TAny*)iTest->iScreenNumber)); +#endif +#if defined(LOGGING) + _LIT(KPanicTest,"Trying Panic %d"); + LogMessageText.Zero(); + LogMessageText.AppendFormat(KPanicTest,4); + TheClient->iWs.LogMessage(LogMessageText); + TheClient->Flush(); +#endif + TEST(iTest->TestWsPanicL(CPanicDirect::DoTestOnNewScheduler,EWservPanicDirectMisuse,4,(TAny*)iTest->iScreenNumber)); + TEST(iTest->TestW32PanicL(CPanicDirect::DoTestOnNewScheduler,EW32PanicDirectMisuse,5,(TAny*)iTest->iScreenNumber)); + return ENext; + } + +TestState CTDirect::ScrolingText2L() + { + MoveInterval=81234; //0.08 sec + ModeInterval=140123; //0.14 sec + ImmediateModeSwitch=2; + ScrolingTextL(9,TRect(15,25,45,35),ETrue); + iScroll->SetCountDown(5); + return EWait; + } + +TestState CTDirect::ScrolingText3L() + { + iModeBackup=TheClient->iScreen->ScreenModeEnforcement(); + if (iModeBackup!=ESizeEnforcementNone) + TheClient->iScreen->SetScreenModeEnforcement(ESizeEnforcementNone); + MoveInterval=0; + ModeInterval=0; + FlipInterval=1200000; //1.2 secs + ScrolingTextL(10,TRect(25,30,35,45),ETrue,1); + iScroll->SetBottomOfTest(80); //So it can be seen in both screen modes + return EWait; + } + +TestState CTDirect::ScrolingText4L() + { + iModeBackup=TheClient->iScreen->ScreenModeEnforcement(); + if (iModeBackup!=ESizeEnforcementNone) + TheClient->iScreen->SetScreenModeEnforcement(ESizeEnforcementNone); + MoveInterval=876543; //0.88 secs + ModeInterval=2178900; //2.18 secs + FlipInterval=5000000; //5 secs + ScrolingTextL(11,TRect(30,40,55,65),ETrue); + iScroll->SetBottomOfTest(80); //So it can be seen in both screen modes + return EWait; + } + +void CTDirect::CreateAnimForScreenModeL(TInt aAnimIndex,CTWinBase& aParent,TRect aRect,TInt aId) + { + iAnims[aAnimIndex]=CColorAnimation::NewL(iTest->iScreenNumber,aId,*this,aParent,aRect,EFalse); + iAnims[aAnimIndex]->StartL(); + iAnims[aAnimIndex]->BringWindowToFront(); + } + +void CTDirect::BlankTopClientWindowL(CTBlankWindow& aBlankWindow,TRect aRect) + { + aBlankWindow.ConstructExtLD(*TheClient->iGroup,aRect.iTl,aRect.Size()); + User::LeaveIfError(aBlankWindow.BaseWin()->SetRequiredDisplayMode(EColor256)); + aBlankWindow.BaseWin()->SetShadowDisabled(ETrue); + aBlankWindow.Activate(); + } + +static TInt ChangeScreenModeL(TAny* aTest) + { + STATIC_CAST(CTDirect*,aTest)->ChangeToNextScreenModeL(); + return KErrNone; + } + +void CTDirect::ChangeToNextScreenModeL() + { +#if defined(LOGGING) + _LIT(KChangeMode,"AUTO Screen Mode Pos Test2 CallBack"); + LogMessageText.Copy(KChangeMode); + TheClient->LogMessage(LogMessageText); + TheClient->iWs.LogCommand(RWsSession::ELoggingStatusDump); +#endif + iNumOfModes=TheClient->iScreen->NumScreenModes(); + if (iCurrentMode* rotations=new(ELeave) CArrayFixFlat(1); + CleanupStack::PushL(rotations); + User::LeaveIfError(TheClient->iScreen->GetRotationsList(iCurrentMode,rotations)); + TInt count=rotations->Count(); + TInt jj=0; + if (count>1) + { + for (jj=0;jjiScreen->SetCurrentRotations(oldCurrentMode,REINTERPRET_CAST(CFbsBitGc::TGraphicsOrientation&,currentRotation)); + CleanupStack::PopAndDestroy(rotations); + TheClient->iScreen->GetScreenModeSizeAndRotation(oldCurrentMode,pixelsAndRotation); + TInt screenWidth=pixelsAndRotation.iPixelSize.iWidth; + TInt screenHeight=pixelsAndRotation.iPixelSize.iHeight; + TPoint screenModeOrigin=TheClient->iScreen->GetScreenModeScaledOrigin(oldCurrentMode); + TPoint point1(screenModeOrigin.iX,screenModeOrigin.iY+(screenModeOrigin.iY+screenHeight)/2); + TPoint point2(screenModeOrigin.iX+(screenModeOrigin.iX+screenWidth)/2,screenHeight+screenModeOrigin.iY); + TRect rect0(point1,point2); + TRect rect1(TPoint(0,0),rect0.Size()); + CreateAnimForScreenModeL(0,*TheClient->iGroup,rect1,14); + TPoint pos=iAnims[0]->AbsoluteWindowPosition(); + TEST(pos==TPoint(0,0)); + } + } + +TInt ChangeScreenScaleCallBack(TAny* aTest) + { + static_cast(aTest)->ChangeScreenScale(); + return KErrNone; + } + +void CTDirect::ChangeScreenScale() + { + if (!iNumOfCallBack) + { + iCurrentMode=TheClient->iScreen->CurrentScreenMode(); + iModeData=TheClient->iScreen->GetCurrentScreenModeAttributes(); + iModeData.iScreenScale.SetSize(1,1); + } + TSizeMode testMode=iModeData; + if (!iNumOfCallBack) + { + testMode.iScreenScale.SetSize(2,2); + } + else if (iNumOfCallBack==1) + { + testMode.iScreenScale.SetSize(3,2); + } + else if (iNumOfCallBack==2) + { + testMode.iScreenScale.SetSize(2,3); + } + TheClient->iScreen->SetCurrentScreenModeAttributes(testMode); + TheClient->iScreen->SetAppScreenMode(iCurrentMode); + TheClient->iScreen->SetScreenMode(iCurrentMode); + if (iNumOfCallBack==2) + { + iScreenModeTimer->Cancel(); + delete iScreenModeTimer; + iScreenModeTimer=NULL; + } + iNumOfCallBack++; + } + +/* + * Creates a DSA for screen mode 0. After DSA has displayd 2 or 3 frames screen mode + * scale is changed with a timer. The DSA aborts and restarts once again + * and completes itself in different screen mode. + */ +TestState CTDirect::ScreenModeTestForScalingL() + { + CreateAnimForScreenModeL(0,*TheClient->iGroup,TRect(TSize(10,10)),19); + iScreenModeTimer=CPeriodic::NewL(0); + MoveInterval=2000000; + iScreenModeTimer->Start(1000,MoveInterval,TCallBack(ChangeScreenScaleCallBack,this)); + return EWait; + } + +/* + * Creates a DSA for screen mode 0, tests API AbsoluteWindowPosition() + * Then sets screen mode to last(test) screen mode, here it does the same thing as + * done for screenmode 0, but with diffrerent scale (2,2) (2,3) (3,2) (3,3) and + * with different origin (20,30) (30,20) (20,20). + * Lastly copy back the test screen mode values. + */ +TestState CTDirect::ScreenModeScalingTestL() + { +#if defined(LOGGING) +INFO_PRINTF1("AUTO ScreenModeScalingTest "); +#else +// DisabledStartLogText(); +#endif +INFO_PRINTF1(_L(" Switch to mode 0")); + iModeData.iScreenScale.iWidth=1; + iModeData.iScreenScale.iHeight=1; + TheClient->iScreen->SetCurrentScreenModeAttributes(iModeData); + TheClient->iScreen->SetAppScreenMode(0); + TheClient->iScreen->SetScreenMode(0); + iCurrentMode=0; +INFO_PRINTF1(_L(" Get Parameters")); + iCurrentScreenModeOrigin=TheClient->iScreen->GetDefaultScreenModeOrigin(); + iCurrentScreenModeScale=TheClient->iScreen->GetCurrentScreenModeScale(); + Copy2ndHalfOfScreen=(iCurrentScreenModeOrigin.iX>FullScreenModeSize.iWidth/2? 1 : 0); + TRect testWinRect(PhysicalToLogical(TPoint(),iCurrentScreenModeScale), + PhysicalToLogical(TPoint((Copy2ndHalfOfScreen ? FullScreenModeSize.iWidth : + FullScreenModeSize.iWidth/2), + FullScreenModeSize.iHeight)- + iCurrentScreenModeOrigin,iCurrentScreenModeScale) + ); + testWinRect.Shrink(10,10); +INFO_PRINTF1(_L(" Create Animation")); + CreateAnimForScreenModeL(0,*TheClient->iGroup,testWinRect,17); + TPoint pos0=iAnims[0]->AbsoluteWindowPosition(); + TEST(pos0==TPoint(10,10)); + + TInt numOfModes=TheClient->iScreen->NumScreenModes(); + iCurrentMode=numOfModes-1; +INFO_PRINTF1(_L(" Switch to Last Mode")); + TheClient->iScreen->SetAppScreenMode(iCurrentMode); + TheClient->iScreen->SetScreenMode(iCurrentMode); + TSizeMode storeModeData=TheClient->iScreen->GetCurrentScreenModeAttributes(); + TSizeMode testMode=storeModeData; + iNumAnimation=0; + for (TInt xScale=2;xScale<4;xScale++) + { +INFO_PRINTF1(_L(" New X-Scale")); + for (TInt yScale=2;yScale<4;yScale++) + { +INFO_PRINTF1(_L(" New Y-Scale")); + testMode.iScreenScale=TSize(xScale,yScale); + TestDifferentOriginAndScaleL(testMode,TPoint(20,20)); + TestDifferentOriginAndScaleL(testMode,TPoint(20,30)); + TestDifferentOriginAndScaleL(testMode,TPoint(30,20)); + } + } + TheClient->iScreen->SetScreenMode(iCurrentMode); + TheClient->iScreen->SetCurrentScreenModeAttributes(storeModeData); +INFO_PRINTF1(_L(" Set To Mode 0")); + TheClient->iScreen->SetAppScreenMode(0); + TheClient->iScreen->SetScreenMode(0); + return EWait; + } + +void CTDirect::TestDifferentOriginAndScaleL(TSizeMode &aMode,TPoint aOrigin) + { + aMode.iOrigin=aOrigin; + TheClient->iScreen->SetCurrentScreenModeAttributes(aMode); + TheClient->iScreen->SetAppScreenMode(iCurrentMode); + TheClient->iScreen->SetScreenMode(iCurrentMode); + iCurrentScreenModeOrigin=TheClient->iScreen->GetScreenModeOrigin(iCurrentMode); + iCurrentScreenModeScale=TheClient->iScreen->GetScreenModeScale(iCurrentMode); + Copy2ndHalfOfScreen=(iCurrentScreenModeOrigin.iX>FullScreenModeSize.iWidth/2? 1 : 0); + TRect testWinRect(PhysicalToLogical(TPoint(),iCurrentScreenModeScale), + PhysicalToLogical(TPoint((Copy2ndHalfOfScreen ? FullScreenModeSize.iWidth + : FullScreenModeSize.iWidth/2), + FullScreenModeSize.iHeight) + -iCurrentScreenModeOrigin,iCurrentScreenModeScale) + ); + testWinRect.Shrink(10,10); + ++iNumAnimation; + CreateAnimForScreenModeL(iNumAnimation,*TheClient->iGroup,testWinRect,18); + TPoint pos0=iAnims[iNumAnimation]->AbsoluteWindowPosition(); + TEST(pos0==TPoint(10,10)); + } + +//REQUIREMENT: CR PHAR-5SJGAM, PREQ673 +//Tests that DSA works correctly in screen modes with non-zero screen mode origin. +TestState CTDirect::DSAWithScreenModeOffset1L() + { + TPoint screenModeTwoOrigin=TheClient->iScreen->GetScreenModeScaledOrigin(2); + TPixelsAndRotation pixelsAndRotation; + TheClient->iScreen->GetScreenModeSizeAndRotation(2,pixelsAndRotation); + if(pixelsAndRotation.iRotation != CFbsBitGc::EGraphicsOrientationNormal) + { + TheClient->iScreen->SetCurrentRotations(2, CFbsBitGc::EGraphicsOrientationNormal); + } + TheClient->iScreen->GetScreenModeSizeAndRotation(2,pixelsAndRotation); + //check that the current rotation is normal + __ASSERT_DEBUG(pixelsAndRotation.iRotation==CFbsBitGc::EGraphicsOrientationNormal,AutoPanic(EAutoPanicDirect)); + TInt screenWidthMode2=pixelsAndRotation.iPixelSize.iWidth; + TInt screenHeightMode2=pixelsAndRotation.iPixelSize.iHeight; + TPoint point1(screenModeTwoOrigin.iX,screenModeTwoOrigin.iY+(screenModeTwoOrigin.iY+screenHeightMode2)/2); + TPoint point2(screenModeTwoOrigin.iX+(screenModeTwoOrigin.iX+screenWidthMode2)/2,screenHeightMode2+screenModeTwoOrigin.iY); + TPoint point3(screenModeTwoOrigin.iX+screenWidthMode2,screenModeTwoOrigin.iY+screenHeightMode2); + + SetScreenMode(0,pixelsAndRotation); + TRect rect0(point1,point2); + CreateAnimForScreenModeL(0,*TheClient->iGroup,rect0,13); + TPoint pos0=iAnims[0]->AbsoluteWindowPosition(); + TEST(pos0==point1); + + SetScreenMode(2,pixelsAndRotation); + TRect rect1(TPoint(0,0),rect0.Size()); + CreateAnimForScreenModeL(1,*TheClient->iGroup,rect1,13); + TPoint pos1=iAnims[1]->AbsoluteWindowPosition(); + TEST(pos1==rect1.iTl); + + SetScreenMode(0,pixelsAndRotation); + iBlankTopClientWin1=new(ELeave) CTBlankWindow(); +// TInt ordpos = iBlankTopClientWin1->BaseWin()->OrdinalPosition(); + TRect rect2(TPoint(point2.iX,point1.iY),point3); + BlankTopClientWindowL(*iBlankTopClientWin1,rect2); + TInt x=rect2.Size().iWidth/4; + TPoint animWinPt(x,0); + rect2.Shrink(x,0); + CreateAnimForScreenModeL(2,*iBlankTopClientWin1,TRect(animWinPt,rect2.Size()),13); + TPoint pos2=iAnims[2]->AbsoluteWindowPosition(); + TEST(pos2==rect2.iTl); + + SetScreenMode(2,pixelsAndRotation); + iBlankTopClientWin2=new(ELeave) CTBlankWindow(); +// ordpos = iBlankTopClientWin2->BaseWin()->OrdinalPosition(); + TPoint tl(rect1.iBr.iX,0); + TRect rect3(tl,TPoint(screenWidthMode2,rect1.iBr.iY)); + BlankTopClientWindowL(*iBlankTopClientWin2,rect3); + x=rect3.Size().iWidth/4; + animWinPt=TPoint(x,0); + rect3.Shrink(x,0); + CreateAnimForScreenModeL(3,*iBlankTopClientWin2,TRect(animWinPt,rect3.Size()),13); + TPoint pos3=iAnims[3]->AbsoluteWindowPosition(); + TEST(pos3==(animWinPt+tl)); + + SetScreenMode(0,pixelsAndRotation); + return EWait; + } + +//REQUIREMENT: CR PHAR-5SJGAM, PREQ673 +//Tests that DSA works correctly in screen modes with non-zero screen mode origin and different rotations +TestState CTDirect::DSAWithScreenModeOffset2L() + { + iCurrentMode=0; + TTimeIntervalMicroSeconds32 timeBetweenScreenModeChange=3200000; + iCallBackWin->WinTreeNode()->SetOrdinalPosition(0); + iCallBackWin->SetVisible(ETrue); //Used to forsce screen into Color256 so that it will rotate + iChangeScreenModeTimer=CPeriodic::NewL(0); + iChangeScreenModeTimer->Start(0,timeBetweenScreenModeChange,TCallBack(ChangeScreenModeL,this)); + return EWait; + } + +void CTDirect::SetScreenMode(TInt aMode,TPixelsAndRotation& aPixelsAndRotation) + { + TheClient->iScreen->SetScreenMode(aMode); + TheClient->iScreen->SetScreenModeEnforcement(ESizeEnforcementNone); + TheClient->iScreen->GetDefaultScreenSizeAndRotation(aPixelsAndRotation); + TheClient->iScreen->SetScreenSizeAndRotation(aPixelsAndRotation); + TheClient->Flush(); + } + +TestState CTDirect::DefectFix_KAA_5J3BLW_L() + { + TInt numProcessHandles; + RThread().HandleCount(numProcessHandles,iNumThreadHandles); + const TSize screenSize(TheClient->iScreen->SizeInPixels()); + const TRect dsaRect(0,0,screenSize.iWidth>>2,screenSize.iHeight>>2); + iAnim=CBugFixColorAnimation::NewL(iTest->iScreenNumber, 1, *this, *TheClient->iGroup, dsaRect,ETrue); + return EWait; + } + +TestState CTDirect::RegionTrackingOnlyNotificationsL(TUint aId) + { + TInt numProcessHandles; + RThread().HandleCount(numProcessHandles,iNumThreadHandles); + const TSize screenSize(TheClient->iScreen->SizeInPixels()); + const TRect dsaRect(0,0,screenSize.iWidth>>2,screenSize.iHeight>>2); + TBool isWindowOpenedInFrontOfDsa = (aId == KRegionTrackingOnlyDsaWaitingForAbortSignal); + iAnim=CRegionTrackingOnly::NewL(iTest->iScreenNumber, aId, *this, *TheClient->iGroup, dsaRect,ETrue,isWindowOpenedInFrontOfDsa); + return EWait; + } + +// Tests the new function of getting the window's absolute position +TestState CTDirect::WindowPoistionRelativeToScreenL() + { + //.. delete screen mode timer + delete iChangeScreenModeTimer; + iChangeScreenModeTimer=NULL; + + TInt numProcessHandles; + RThread().HandleCount(numProcessHandles,iNumThreadHandles); + TSize screenSize(TheClient->iScreen->SizeInPixels()); + TRect rect(0,0,screenSize.iWidth>>1,screenSize.iHeight); + rect.Shrink(10,10); + // First animation is for showing that child window is within the visible part of the parent window and within the visible screen area + iAnims[0]=new(ELeave) CColorAnimation(iTest->iScreenNumber,15,*this); + iAnims[0]->ConstructL(*TheClient->iGroup,rect,KDrawingDsa,1); + iAnims[0]->StartL(ETrue); + // First animation is for showing that child window is to the side of visible part of parent window + rect.Move(screenSize.iWidth>>1,0); + iAnims[1]=new(ELeave) CColorAnimation(iTest->iScreenNumber,16,*this); + iAnims[1]->ConstructL(*TheClient->iGroup,rect,KDrawingDsa,2); + iAnims[1]->StartL(ETrue); + return EWait; + } + +TestState CTDirect::MultipleDSAsOnSameWindowL() + { + TInt numProcessHandles; + RThread().HandleCount(numProcessHandles,iNumThreadHandles); + iCallBackWin->SetVisible(ETrue); + iCallBackWin->WinTreeNode()->SetOrdinalPosition(0); + iAnims[0]=new(ELeave) CColorAnimation(iTest->iScreenNumber,20,*this); + iAnims[0]->ConstructL(*TheClient->iGroup,TRect(),KDrawingDsa,0,1); + iAnims[0]->StartL(); + iAnims[1]=new(ELeave) CColorAnimation(iTest->iScreenNumber,21,*this); + iAnims[1]->ConstructL(*TheClient->iGroup,TRect(),KDrawingDsa,0,2); + iAnims[1]->StartL(); + _LIT(ThreadName,"MoveWin"); + MoveInterval=100000; + ModeInterval=0; + FlipInterval=0; + ImmediateModeSwitch=EFalse; + iFirstFunction=TThreadStartUp(CMoveWindow::StartLC,(TAny*)iTest->iScreenNumber); + iMoveWin=CProcess::NewThreadL(ThreadName,&iFirstFunction); + return EWait; + } + +TestState CTDirect::KillAnimationL() + { + TInt numProcessHandles; + RThread().HandleCount(numProcessHandles,iNumThreadHandles); + iAnim=CColorAnimation::NewL(iTest->iScreenNumber,12,*this,*TheClient->iGroup,TRect(15,15,625,225),ETrue); + return EWait; + } + +TestState CTDirect::TemporaryDeadlockL() + { + + if (iTestJustCompleted) + { + if (iTestJustFailed) + { + Fail(); + } + iState++; + return ENext; + } + + //make sure this code isn't called a second time + __ASSERT_ALWAYS(iAnim==NULL,AutoPanic(EAutoPanicDirect)); + + TSize screenSize(TheClient->iScreen->SizeInPixels()); + TRect rect(0,0,screenSize.iWidth>>1,screenSize.iHeight); + rect.Shrink(10,10); + iAnim=new(ELeave) CColorAnimation(iTest->iScreenNumber,24,*this); + iAnim->ConstructL(*TheClient->iGroup,rect,KDrawingDsa,1); + iAnim->StartL(ETrue); + return EWait; + } + +void CTDirect::CheckForTemporaryDeadlock() + { + + TBool result=ETrue; + TInt error; + + + //Create a window for placing on top + TTime beforeTime; + beforeTime.HomeTime(); + + RWindow window(TheClient->iWs); + + error=window.Construct(*TheClient->iGroup->GroupWin(), reinterpret_cast(&window)); + if (error==KErrNone) + { + window.SetOrdinalPosition(0); + window.SetExtent(TPoint(30,30),TSize(10,10)); + window.SetBackgroundColor(TRgb(255,0,255)); + + //make sure the basewin is towards the back + iCallBackWin->BaseWin()->SetOrdinalPosition(5); + + window.SetRequiredDisplayMode(EColor256); + window.Activate(); + TheClient->iWs.Flush(); + //need code similar to below, but the status of the active object we + //really want is too private + //if (!iAnim->IsReadyToAbort()) + // { + // result=EFalse; + // } + window.Close(); + } + else + { + result = EFalse; + } + + TTime afterTime; + afterTime.HomeTime(); + TTimeIntervalMicroSeconds difference = afterTime.MicroSecondsFrom(beforeTime); + + //make time difference 350ms, since the two timers to be checked are 400ms and 500ms + if (difference>TTimeIntervalMicroSeconds(1000*350)) + { + result=EFalse; + } + + iTestJustCompleted = ETrue; + if (result==EFalse) + { + iTestJustFailed=ETrue; + } + } + +void CTDirect::RunTestCaseL(TInt /*aCurTestCase*/) + { + _LIT(Animation1,"Animating"); + _LIT(Animation2,"Animating Dies"); + _LIT(Animation3,"Packaging Class"); + _LIT(Animation4,"Many Animations"); + _LIT(Animation5,"Fail Codes"); + _LIT(Animation6,"Cancel The Other"); + _LIT(Animation7,"'R' Class API"); + _LIT(Animation8,"Switch Clear Type"); + _LIT(Animation9,"SizeMode Change"); + _LIT(Animation10,"Soak Testing"); + _LIT(Animation11,"Kill Animation"); + _LIT(Animation12,"Defect-Fix: KAA-5J3BLW"); + _LIT(Animation13,"Screen Mode Positioning DSA Test 1"); + _LIT(Animation14,"Screen Mode Positioning DSA Test 2"); + _LIT(Animation15,"Position Relative to Screen"); + _LIT(Animation16,"Screen mode Scaling DSA Test 1"); + _LIT(Animation17,"Screen mode Scaling DSA Test 2"); + _LIT(Animation18,"Multiple DSAs on same window"); + _LIT(Animation19,"DSA and windows temporary deadlock"); + _LIT(Animation25,"RegionTrackingOnly DSA, window opened in front"); +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA + _LIT(Animation26,"RegionTrackingOnly DSA, window opened behind"); + _LIT(Animation27,"Mixed DSAs, RegionTrackingOnly DSA last to exit"); + _LIT(Animation28,"Mixed DSAs, drawing DSA last to exit"); + _LIT(Animation29,"Trying all the screen supported modes"); +#endif + TestState ret=ENext; + + if (iTimerRunning && !iPackagingFinished) + { + // Prevent test harness from repeatedly running the test case too quickly. + User::After(SHORT_DELAY); + } + + //if (iState==0) iState=18; + iTest->iState=iState; + ((CTDirectStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); + switch(iState) + { +/** +@SYMTestCaseID GRAPHICS-WSERV-0158 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Create seven seperate animations and run them to completion + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Create animations and start them running. Run until the animations finish. + +@SYMTestExpectedResults The animation run to completion without error +*/ + case 0: + ((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0158")); + if (iNextFrameFinished) + InitialiseAnimationL(); + case 1: + ((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0158")); + case 2: + ((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0158")); + case 3: + ((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0158")); + case 4: + ((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0158")); + case 5: + ((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0158")); + case 6: + ((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0158")); + if (iNextFrameFinished) + { + iTest->LogSubTest(Animation1); + ret=AnimateWindowL(); + iNextFrameFinished=EFalse; + } + else + { + // Prevent test harness from repeatedly running the test case too quickly. + User::After(SHORT_DELAY); + } + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0159 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Check animation dies correctly when run in a thread + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Create animation and run in from a thread that dies. Once the thread + has died check the animation has been dealt with correctly. + +@SYMTestExpectedResults The animation dies correctly +*/ + case 7: + ((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0159")); + iTest->LogSubTest(Animation2); + ret=AnimationDiesL(); + ++iState; + DestroyAnimation(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0160 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Check animation runs correctly in blank window + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Create an animation and run it in a blank window + +@SYMTestExpectedResults The animation runs to completion without error +*/ + case 8: + ((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0160")); + if (!iTimerRunning) + { + iTest->LogSubTest(Animation3); + ret=PackagingClassL(); + iTimerRunning = ETrue; + } + if (iPackagingFinished) + { + iPackagingFinished = EFalse; + iTimerRunning = EFalse; + } + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0161 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Check many animations can be run in the same window + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Create multiple animations in a window and run them all + until completion + +@SYMTestExpectedResults The animations run without error +*/ + case 9: + ((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0161")); + if (!iTimerRunning) + { + iTest->LogSubTest(Animation4); + ret=MultipleL(); + iTimerRunning = ETrue; + } + if (iPackagingFinished) + { + iPackagingFinished = EFalse; + iTimerRunning = EFalse; + } + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0162 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Direct screen access out of memory test + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Direct screen access out of memory test + +@SYMTestExpectedResults The out of memory error is handled correctly +*/ + case 10: + ((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0162")); + iTest->LogSubTest(Animation5); + ret=FailCodesL(); + iState++; + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0163 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Two animations, one scrolling text + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Create two animations, one which scrolls text across the screen and + run them to completion + +@SYMTestExpectedResults The animations run without error +*/ + case 11: + ((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0163")); + if (!iTimerRunning) + { + iTest->LogSubTest(Animation6); + ret=ScrolingText1L(); + iTimerRunning = ETrue; + } + if (iPackagingFinished) + { + iPackagingFinished = EFalse; + iTimerRunning = EFalse; + } + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0164 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test direct screen access panic messages + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Call the direct screen access panic's and check they are handled + correctly + +@SYMTestExpectedResults The panic's are handled correctly +*/ + case 12: + ((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0164")); + iTest->LogSubTest(Animation7); + ret=RClassL(); + iTest->CloseAllPanicWindows(); + iState++; + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0165 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Two animations, one scrolling text + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Create two animations, one which scrolls text across the screen and + run them to completion + +@SYMTestExpectedResults The animations run without error +*/ + case 13: + ((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0165")); + if (!iTimerRunning) + { + iTest->LogSubTest(Animation8); + ret=ScrolingText2L(); + iTimerRunning = ETrue; + } + if (iPackagingFinished) + { + iPackagingFinished = EFalse; + iTimerRunning = EFalse; + } + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0166 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Two animations, one scrolling text. Change the screen mode an run. + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Create two animations, one which scrolls text across the screen and + run them to completion while changing the screen mode + +@SYMTestExpectedResults The animations run without error +*/ + + case 14: + ((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0166")); + if (!iTimerRunning) + { + iTest->LogSubTest(Animation9); + ret=ScrolingText3L(); + if (ret == ENext) + iPackagingFinished = ETrue; + else + iTimerRunning = ETrue; + } + if (iPackagingFinished) + { + iPackagingFinished = EFalse; + iTimerRunning = EFalse; + FlipInterval = 0; // Stops the tests (erroneously) flipping for the rest of the run + } + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0167 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Start an animation then kill it + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Start an animation running then kill it. Check the animation dies correctly + +@SYMTestExpectedResults The animations dies correctly +*/ + case 15: + ((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0167")); + if (!iTimerRunning) + { + iTest->LogSubTest(Animation11); + ret=KillAnimationL(); + iTimerRunning = ETrue; + } + if (iPackagingFinished) + { + iPackagingFinished = EFalse; + iTimerRunning = EFalse; + } + break; + case 16: + ((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0167")); + iTest->LogSubTest(Animation10); //This test is designed to be left running for at least several hours + //ret=ScrolingText4L(); + iState++; + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0168 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc CBugFixColorAnimation + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions This class is used for reproducing a defect found on 6.1: KAA-5J3BLW "Unnecessary Wserv's DSA abort". + The problem was that a direct screen access client was getting an unnecessary abort notification + when a new window (or window group) was created but not visible. + This class will simulate the direct screen access client and it will check whether the first DSA abort + is not caused by just creating a window. + +@SYMTestExpectedResults Abort is not caused when creatung a window +*/ + case 17: + ((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0168")); + if (!iTimerRunning) + { + iTest->LogSubTest(Animation12); + ret=DefectFix_KAA_5J3BLW_L(); + iTimerRunning = ETrue; + } + if (iPackagingFinished) + { + iPackagingFinished = EFalse; + iTimerRunning = EFalse; + } + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0169 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Direct screen access in screen modes with non-zero screen mode origin + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Tests that DSA works correctly in screen modes with non-zero screen mode origin + +@SYMTestExpectedResults The DSA works correctly +*/ + case 18: + ((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0169")); + if (!CheckNonZeroOriginsSupportedOrNot()) + { + INFO_PRINTF1(_L("Non Zero Origins not supported\n")); + iState++; + } + else + { + if (!iTimerRunning) + { + iTest->LogSubTest(Animation13); + ret=DSAWithScreenModeOffset1L(); + iTimerRunning = ETrue; + } + if (iPackagingFinished) + { + iPackagingFinished = EFalse; + iTimerRunning = EFalse; + } + } + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0170 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Direct screen access in screen modes with non-zero screen mode origin + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Tests that DSA works correctly in screen modes with non-zero screen mode origin and different rotations + +@SYMTestExpectedResults The DSA works correctly +*/ + case 19: + ((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0170")); + if (!CheckNonZeroOriginsSupportedOrNot()) + { + INFO_PRINTF1(_L("Non Zero Origins not supported\n")); + iState++; + } + else + { + if (!iTimerRunning) + { + iTest->LogSubTest(Animation14); + ret=DSAWithScreenModeOffset2L(); + iTimerRunning = ETrue; + } + if (iPackagingFinished) + { + iPackagingFinished = EFalse; + iTimerRunning = EFalse; + } + } + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0171 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Window absolute position + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Tests the new function of getting the window's absolute position + +@SYMTestExpectedResults Function works correctly +*/ + case 20: + ((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0171")); + if (!iTimerRunning) + { + iTest->LogSubTest(Animation15); + ret=WindowPoistionRelativeToScreenL(); + iTimerRunning = ETrue; + } + if (iPackagingFinished) + { + iPackagingFinished = EFalse; + iTimerRunning = EFalse; + } + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0172 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test direct screen access restart + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Creates a DSA for screen mode 0. After DSA has displayed 2 or 3 frames screen mode + scale is changed with a timer. The DSA aborts and restarts once again + and completes itself in different screen mode. + +@SYMTestExpectedResults DSA restarts and completes correctly +*/ + case 21: + ((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0172")); + if (iIsScalingSupported) + { + if (!iTimerRunning) + { + iTest->LogSubTest(Animation16); + ret=ScreenModeTestForScalingL(); + iTimerRunning = ETrue; + } + if (iPackagingFinished) + { + iPackagingFinished = EFalse; + iTimerRunning = EFalse; + } + break; + } + iState++; + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0173 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test direct screen access scaling + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Creates a DSA for screen mode 0, tests API AbsoluteWindowPosition() + Then sets screen mode to last(test) screen mode, here it does the same thing as + done for screenmode 0, but with diffrerent scale (2,2) (2,3) (3,2) (3,3) and + with different origin (20,30) (30,20) (20,20). + Lastly copy back the test screen mode values. + +@SYMTestExpectedResults DSA scales correctly +*/ + case 22: + ((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0173")); + if (iIsScalingSupported) + { + if (!iTimerRunning) + { + iTest->LogSubTest(Animation17); + ret=ScreenModeScalingTestL(); + iTimerRunning = ETrue; + } + if (iPackagingFinished) + { + iPackagingFinished = EFalse; + iTimerRunning = EFalse; + } + break; + } + iState++; + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0174 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test multiple direct screen access elements on the same window + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Create a number of direct screen access elements on the same window and + check that they work correctly + +@SYMTestExpectedResults DSAs work correctly +*/ + case 23: + ((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0174")); + if (iIsScalingSupported) + { + if (!iTimerRunning) + { + iTest->LogSubTest(Animation18); + ret=MultipleDSAsOnSameWindowL(); + iTimerRunning = ETrue; + } + if (iPackagingFinished) + { + iPackagingFinished = EFalse; + iTimerRunning = EFalse; + } + break; + } + iState++; + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0175 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Create a temporary deadlock on a DSA and resolve it + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Resolve a temporary deadlock on a DSA + +@SYMTestExpectedResults DSA resolves the deadlock +*/ + case 24: + ((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0175")); + if (!iTimerRunning) + { + iTest->LogSubTest(Animation19); + ret=TemporaryDeadlockL();//for INC072887 - removing a 0.5s delay in wserv. + iTimerRunning = ETrue; + } + if (iPackagingFinished) + { + iPackagingFinished = EFalse; + iTimerRunning = EFalse; + iState++; + } + break; +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA + case 25: +/** +@SYMTestCaseID GRAPHICS-WSERV-0533 +*/ + ((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0533")); + if (!iTimerRunning) + { + FlipInterval=0; + iTest->LogSubTest(Animation25); + //Opens a window in front of a region tracking only DSA + ret=RegionTrackingOnlyNotificationsL(KRegionTrackingOnlyDsaWaitingForAbortSignal); + iTimerRunning = ETrue; + } + if (iPackagingFinished) + { + iPackagingFinished = EFalse; + iTimerRunning = EFalse; + } + break; + case 26: +/** +@SYMTestCaseID GRAPHICS-WSERV-0534 +*/ + ((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0534")); + if (!iTimerRunning) + { + iTest->LogSubTest(Animation26); + //Opens a window behind a region tracking only DSA + ret=RegionTrackingOnlyNotificationsL(KRegionTrackingOnlyDsaNoAbortSignal); + iTimerRunning = ETrue; + } + if (iPackagingFinished) + { + iPackagingFinished = EFalse; + iTimerRunning = EFalse; + } + break; + case 27: +/** +@SYMTestCaseID GRAPHICS-WSERV-0535 +*/ + ((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0535")); + if (!iTimerRunning) + { + iTest->LogSubTest(Animation27); + ret=MixDsaAndRegionTrackingOnlyL(KRegionTrackingOnlyDsaExistLast); + iTimerRunning = ETrue; + } + if (iPackagingFinished) + { + iPackagingFinished = EFalse; + iTimerRunning = EFalse; + } + break; + case 28: +/** +@SYMTestCaseID GRAPHICS-WSERV-0536 +*/ + ((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0536")); + if (!iTimerRunning) + { + iTest->LogSubTest(Animation28); + ret=MixDsaAndRegionTrackingOnlyL(KDrawingDsaExistLast); + iTimerRunning = ETrue; + } + if (iPackagingFinished) + { + iPackagingFinished = EFalse; + iTimerRunning = EFalse; + } + break; + case 29: +/** +@SYMTestCaseID GRAPHICS-WSERV-0537 +*/ + ((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0537")); + if (!iTimerRunning) + { + iTest->LogSubTest(Animation29); + ret=TryDifferentSupportedModesL(); + iTimerRunning = ETrue; + } + if (iPackagingFinished) + { + iPackagingFinished = EFalse; + iTimerRunning = EFalse; + } + break; +#else +//NON NGA negative test for RegionTrackingOnly DSA + case 25: +/** +@SYMTestCaseID GRAPHICS-WSERV-0575 +*/ + ((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0575")); + if (!iTimerRunning) + { + FlipInterval=0; + iTest->LogSubTest(Animation25); + CColorAnimation* temp = NULL; + //Attempt to create a RegionTrackingOnly DSA in non NGA code + TRAPD(err,temp = CColorAnimation::NewL(iTest->iScreenNumber,1,*this,*TheClient->iGroup,TRect(10,10,630,230),ETrue,KRegionTrackingOnly)); + if(err!=KErrNotSupported) + { + _LIT(KCTDirectNonNgaError,"Attempt to creat a RegionTrackingOnly DSA did not return KErrNotSupported on non-NGA"); + LOG_MESSAGE(KCTDirectNonNgaError); + if(temp) + { + delete temp; + } + Fail(); + } + else + { + _LIT(KCTDirectNonNgaSuccess,"RegionTrackingOnly DSA not supported on non-NGA as expected"); + LOG_MESSAGE(KCTDirectNonNgaSuccess); + } + iState++; + } + break; +#endif + default: + ((CTDirectStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + ((CTDirectStep*)iStep)->CloseTMSGraphicsStep(); + TestComplete(); + break; + } + ((CTDirectStep*)iStep)->RecordTestResultL(); + } + +CRegionTrackingOnly* CRegionTrackingOnly::NewL(TInt aScreenNumber,TInt aId,MAnimCallBacks& aCallBack,CTWindowGroup& aParent,TRect aExtent,TBool aStart,TBool aOpenWindowInFrontDsa) + { + CRegionTrackingOnly* self=new(ELeave) CRegionTrackingOnly(aScreenNumber, aId,aCallBack); + CleanupStack::PushL(self); + self->ConstructL(aParent,aExtent,aOpenWindowInFrontDsa); + if (aStart) + { + self->StartL(); + self->Started(); + } + CleanupStack::Pop(self); + return self; + } + +CRegionTrackingOnly::CRegionTrackingOnly(TInt aScreenNumber,TInt aId,MAnimCallBacks& aCallBack) + : CColorAnimation(aScreenNumber, aId, aCallBack) + { + iThreadParam.iScreenNumber = aScreenNumber; + } + +void CRegionTrackingOnly::ConstructL(CTWindowGroup& aParent,TRect aExtent,TBool aOpenWindowInFrontDsa) + { + iExpectedToAbort = aOpenWindowInFrontDsa; + CColorAnimation::ConstructL(aParent, aExtent, KRegionTrackingOnly); + _LIT(ThreadName,"Create new Window"); + + TInt error=iSem.CreateGlobal(KSem_DefectFix_KAA_5J3BLW_Name, 0); + if (error==KErrNone) + { + iAnimRect=aExtent; + iThreadParam.iRect = iAnimRect; + iThreadParam.iIsInFront = aOpenWindowInFrontDsa; + TThreadStartUp function=TThreadStartUp(CreateNewWindowGroup, &iThreadParam); + TRequestStatus status; + iThread=CProcess::NewThreadRendezvousL(ThreadName,&function,status); + User::WaitForRequest(status); + if (status != KErrNone) + { + RDebug::Printf("the request status is returned to be non KErrNone: %d", status.Int()); + TestFailed(this); + } + } + else + { + TestFailed(this); + } + } + +TBool CColorAnimation::TestGcAndScreenDeviceValues() + { + TBool succeeded = ETrue; + _LIT(KErrorLogGraphicContext,"GraphicsContext not NULL when using the region tracking feature only"); + _LIT(KErrorLogScreenDevice,"ScreenDevice not NULL when using the region tracking feature only"); + if(iRegionTrackingOnly && iDrawer->Gc() != NULL) + { + CallBack().Log((TText8*)__FILE__,__LINE__, ESevrErr,KErrorLogGraphicContext); + succeeded = EFalse; + } + if(iRegionTrackingOnly && iDrawer->ScreenDevice() != NULL) + { + CallBack().Log((TText8*)__FILE__,__LINE__, ESevrErr,KErrorLogScreenDevice); + succeeded = EFalse; + } + return succeeded; + } + +void CRegionTrackingOnly::AbortNow(RDirectScreenAccess::TTerminationReasons /*aReason*/) + { + Stop(); + } + +void CRegionTrackingOnly::Restart(RDirectScreenAccess::TTerminationReasons/* aReason*/) + { + if(!TestGcAndScreenDeviceValues()) + { + CallBack().Fail(); + } + if (iExpectedToAbort) + { + _LIT(KExpected,"DSA got an abort signal as expected"); + CallBack().Log((TText8*)__FILE__,__LINE__,ESevrInfo,KExpected); + } + else + { + _LIT(KError,"DSA got an abort signal even though the window was opened behind it"); + CallBack().Log((TText8*)__FILE__,__LINE__,ESevrErr,KError); + CallBack().Fail(); + } + FinishTest(); + } + +CRegionTrackingOnly::~CRegionTrackingOnly() + { + iSem.Close(); + if(iThread) + { + TRequestStatus status; + iThread->Logon(status); + if (iThread->StillAlive()) + { + iThread->Terminate(KErrNone); + User::WaitForRequest(status); + } + delete iThread; + } + } + +__WS_CONSTRUCT_STEP__(Direct) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TEVENT.H --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TEVENT.H Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,423 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + + +#ifndef __TEVENT_H__ +#define __TEVENT_H__ + +#include +#include +#include +#include "../tlib/testbase.h" +#include "AUTO.H" +#include "AUTODLL.H" +#include "../TClick/CLICK.H" +#include "TGraphicsHarness.h" +#ifndef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA +#include +#include +#endif //TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + +const TInt EMaxEventQueueSize=32; +const TInt EMinQueueSize = 2; + + +class CTEventTest; +class CTQueueClient; + +class TWsQTEvent : public TWsEvent + { + friend class CTEventTest; +public: + inline TTime& Time() {return iTime;} + }; + +class CTQueueTestEvent : public CTEvent + { + enum {EEventBufferSize=40}; +public: + CTQueueTestEvent(RWsSession *aWs, CTEventTest *aTest); + void ConstructL(); + void AddExpectedEvent(TWsEvent &aEvent); + inline void ResetCount(TInt aSet) {iEventCount=0;iEventSet=aSet;iLastEventError=EFalse;} + TInt EventsLeft(); + inline void SetCheckTimeStamp(TBool aCheck) {iCheckTimeStamp = aCheck;} +protected: + void doRunL(); +private: + void TestL(TInt aTest); +private: + CCirBuf iEventBuffer; + CTEventTest *iTest; + TInt iEventCount; + TInt iEventSet; + TBool iCheckTimeStamp; + TPartialRedrawType iRedrawType; + TBool iLastEventError; + }; + +const TInt EWinPositionX=6; +const TInt EWinPositionY=9; +const TInt EWinWidth=100; +const TInt EWinHeight=50; +// (6,9) +// +----------------------+ +// | (31,21) | +// | +--------------+ | +// | | | | +// | | | | +// | +--------------+ | +// | (81,46) | +// +----------------------+ (106,59) + +class CTQueueClient : public CTClient + { +private: + enum {EMaxKeysDown=50}; +public: + CTQueueClient(CTEventTest *aTest); + ~CTQueueClient(); + void ConstructL(TBool aCreateChild); + void ConstructEventHandlerL(); + void AddExpectedEvent(TWsEvent &aEvent); + TInt WindowGroupIdentifier(); + CTWinBase* GetHandle(TPoint& aPos); + void SetChildCapture(TInt aCaptureFlags); + inline void ResetCount(TInt aSet) {EventQueue()->ResetCount(aSet);} + inline void EnableFocusChangeEvents() {iGroup->GroupWin()->EnableFocusChangeEvents();} + inline void DisableFocusChangeEvents() {iGroup->GroupWin()->DisableFocusChangeEvents();} + inline void EnableGroupListChangeEvents() {iGroup->GroupWin()->EnableGroupListChangeEvents();} + inline void DisableGroupListChangeEvents() {iGroup->GroupWin()->DisableGroupListChangeEvents();} + inline CTQueueTestEvent* EventQueue() {return STATIC_CAST(CTQueueTestEvent*,iEventHandler);} + inline TPoint ChildTopLeft() {return TPoint(EWinWidth/4,EWinHeight/4);} + inline TSize ChildSize() {return TSize(EWinWidth/2,EWinHeight/2);} + void CreateEventTestGroupOnSecondScreenL(); + void CloseEventTestGroupOnSecondScreen(); +private: + inline TPoint ParentTopLeft() {return TPoint(EWinPositionX,EWinPositionY);} + inline TPoint ChildAbsTopLeft() {return ParentTopLeft()+ChildTopLeft();} +private: + TInt iKeysDown[EMaxKeysDown]; + TInt iNumKeysDown; + CTEventTest *iTest; +public: + CTBackedUpWin *iChildWin; + CTBackedUpWin *iWin; + TBool iChildCapturing; + TBool iCapturing; + CWsScreenDevice* iSndScreen; + RWindowGroup* iWinGp1; + RWindowGroup* iWinGp2; + }; + +class REventAnimBase : public RTestAnim + { +public: + enum EAnimationType + { + EEventAnim, + EEventPostingAnim + }; + REventAnimBase(RAnimDll* aDll) :RTestAnim(*aDll) {} + virtual void Destroy(); + void Reset(); + TInt ErrorCode(); + TInt NumberOfEventsReceived(); + TInt AddExpectedEvent(TBool aEat, const TRawEvent& aEvent); + TInt AddExpectedEvent(const TAnimRawEvent& aEvent); + static RAnimDll* LoadL(); + }; + +/** + Client side handle to server-side anim class used for Anim Event tests + @internalComponent + @test + */ +class REventAnim : public REventAnimBase + { +public: + static REventAnim* NewL(RWindowBase* aWin, RAnimDll* aDll, REventAnimBase::EAnimationType aType=EEventAnim); + inline REventAnim(RAnimDll* aDll) : REventAnimBase(aDll) {} + inline TInt AddEvent(const TAnimRawEvent& aEvent) {return REventAnimBase::AddExpectedEvent(aEvent);}; + inline TInt GetError() {return REventAnimBase::ErrorCode();}; + inline TInt GetNumEvents() {return REventAnimBase::NumberOfEventsReceived();}; + TInt TestFail(TInt aNoEvents); + }; + +/** + Client side handle to server-side anim class used for Event Handler Removal tests + + RRemovableAnim is an anim which removes itself from the event handler list + after receiving n events, where n is the 'lifetime' of the anim measured in events received. + + @internalComponent + @test + */ +class RRemovableAnim : public REventAnimBase + { +public: + static RRemovableAnim* NewLC(RWindowBase* aWin, RAnimDll* aDll); + inline RRemovableAnim(RAnimDll* aDll) : REventAnimBase(aDll) {} + inline TInt AddExpectedEvent(const TRawEvent& aEvent) {return REventAnimBase::AddExpectedEvent(EFalse, aEvent);}; + TInt SetEventHandlerLifetime(TInt aEventCount); + TInt EventHandlerLifetime(); + TInt AddToEventHandlers(); + TInt RemoveFromEventHandlers(); + TBool TestPassed(); + }; + +class CTEventTest : public CTWsGraphicsBase + { + enum { + EKeyboardInitialRepeat1=1234567, + EKeyboardRepeat1=555666, + EKeyboardInitialRepeat2=2121212, + EKeyboardRepeat2=20000, + EDoubleClickTime1=900000, + EDoubleClickGap1=10, + EDoubleClickTime2=4000000, + EDoubleClickGap2=5, + ENumVisWins=2, + EPointerCursorUpdateGap=50000, //0.05secs Same as WsPointer::EPointerUpdateGapInMicroSeconds + EKeyboardInitialRepeat3=2147483447, // Max value + EKeyboardRepeat3=8000, // for repeat 3 + EKeyboardInitialRepeat4=-2, // Min value + EKeyboardRepeat4=6000, // for repeat 4 + EKeyboardRepeat5=7000, // for repeat 4z + EKeyboardRepeat6=-30000, // for repeat 4 + EKeyboardRepeat7=2147483447, // for repeat 4 + }; +public: + CTEventTest(CTestStep* aStep); + ~CTEventTest(); + //TestState DoTestL(); + void ConstructL(); + void General(); + void General2(); + void Failed(); + //void QueuePurgingL(); + //void SendEventL(); + //void InvisibleWindowL(); + //void JavaAdditionsL(); + void WindowCapBugL(); + //void XyInputTypeL(); + //void MovingPointerCursorL(); + //void RotatedModeL(); + //void AnimEvent(); + void CheckTimeInterval(const TTimeIntervalMicroSeconds32 &aTime,TInt EKeyboardRepeat1); + void KeyRepeatRate(TInt aInitialRepeat, TInt aRepeat); + void KeyRepeatRateNegTest(TInt aInitialRepeat, TInt aRepeat); + void DoubleClickSettings(TInt aInterval, TInt aDistance); + void NextSetOfEventsL(); + inline void ResetCount(TInt aSet) {iQueueClient->ResetCount(aSet);} +protected: +//from CTGraphicsStep + virtual void RunTestCaseL(TInt aCurTestCase); +private: + enum + { + EDoRot0 =0x01, + EDoRot90 =0x02, + EDoRot180=0x04, + EDoScale=0x80, + }; + enum TClients + { + ETheClient, + EQueueClient, + }; + enum TCaptureKeyApis + { + ECaptureKey1, + ECaptureKey2, + ECaptureKeyUpAndDowns1, + ECaptureKeyUpAndDowns2, + ECaptureLongKey1, + ECaptureLongKey2, + // Add additional enum values before this line + EMaxCaptureKeyApis + }; + enum TCancelCaptureKeyApis + { + ECancelCaptureKey, + ECancelCaptureKeyUpAndDowns, + ECancelCaptureLongKey, + // Add additional enum values before this line + EMaxCancelCaptureKeyApis + }; +private: + void RunTestsL(TBool aNeedChildWindows=EFalse); + void RunTestsRestoreAreaL(TBool aNeedChildWindows); + void QueuePurge_NextSetOfEventsL(); + void InitializeQueueSizeTestL(TBool aEventReadyCancel); + void SendEventTest_NextSetOfEvents(); + void InvisibleWindow_NextSetOfEvents(); + void JavaAdditions_NextSetOfEvents(); + void XyInputType_NextSetOfEvents(); + void MovingPointerCursor_NextSetOfEventsL(); + void WinCap_NextSetOfEvents(); + void RotatedMode_NextSetOfEventsL(); + void ScreenScaling_NextSetOfEventsL(); + void AnimEvent_NextSetOfEventsL(); + void FocusChanged_NextSetOfEventsL(); + void StopEvents_NextSetOfEventsL(); + void VirtualKeyboard_NextSetOfEventsL(); + void KeyClicks_NextSetOfEvents(); + void CaptureLong_NextSetOfEventsL(); + void Password_NextSetOfEvents(); + void GroupListChanged_NextSetOfEventsL(); + void VisibilityChanged_NextSetOfEventsL(); +#ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS +#ifndef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + void SurfaceVisibilityChanged1_NextSetOfEventsL(); + void SurfaceVisibilityChanged2_NextSetOfEventsL(); + void SurfaceVisibilityChanged3_NextSetOfEventsL(); +#endif //TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA +#endif //SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS + void CheckTimeStamp_NextSetOfEventsL(); + void RepeatableKeysL(); + void PointerCapture_NextSetOfEventsL(); + void PointerBufferPurge_NextSetOfEventsL(); + void MismatchedCapture_NextSetOfEventsL(); + void EventHandlerRemoval_NextSetOfEventsL(); + void EventHandlerRemoval_CreateAnimsL(TInt aAnimCount); + void EventHandlerRemoval_PrepareAnims(const TInt* aLifeTimes, TInt aAnimCount); + void EventHandlerRemoval_CreateExpectedEvents(TInt aEventCount, TInt aLiveAnimCount); + void EventHandlerRemoval_AddExpectedEvent(TRawEvent aEvent, TInt aLiveAnimCount); + void EventHandlerRemoval_CheckExpectedEventsReceivedByAnims(); + void EventHandlerRemoval_CheckRecursionOfProcessRawEvent(); + void EventHandlerRemoval_ManuallyRemoveAllAnims(); + void EventHandlerRemoval_ResetAllAnims(); + void EventHandlerRemoval_RemoveAndResetAllAnims(); + void EventHandlerRemoval_DestroyAllAnims(); + void EventHandlerRemoval_AddEventHandlerMultipleTimes(); + void CheckPointerCursorInDifferentScreenMode(TSizeMode aMode,TPoint aOrigin); + void SimulateAndCheck(TPoint aOrigin,TSize aScale,TInt aXOffset,TInt aYOffset,TPointerEvent::TType aEventType,TRect aPointerCursorArea); + void AddExpectedKey(TInt aEventCode, TInt aScanCode, TInt aCode=0, TInt aRepeats=0, TUint aModifiers=0); + void AddExpectedKeyDownUp(TInt aScanCode, TInt aCode=0, TInt aRepeats=0, TUint aModifiers=0); + void AddExpectedEvent(TInt aEventCode, CTWinBase* aWin); + void AddExpectedEvent(TInt aEventCode); + void AddExpectedEvent(TInt aEventCode,RWindowGroup* aWindow); + void AddExpectedErrorMessage(TWsErrorMessage::TErrorCategory aCategory, TInt aError); + void CalculatePointerEvent(TWsEvent& aEvent,TPointerEvent::TType aType, TPoint aPos); + void CalculatePointerCaptureEvent(TWsEvent& aEvent,TPointerEvent::TType aType, TPoint aPos, TInt aHandle=0); + void AddExpectedPointer(TPointerEvent::TType aType, TPoint aPos); + void AddExpectedPointerCapture(TPointerEvent::TType aType, TPoint aPos, TInt aHandle=0); + void AddExpectedPointerClick(TPointerEvent::TType aType, TPoint aPos); + void AddExpectedPointerDownUp(TPoint aPos); + inline void AddExpectedPointerScr(TPointerEvent::TType aType, TPoint aPos); + inline void AddExpectedPointerDownUpScr(TPoint aPos); + void AddExpectedModifiersChanged(TInt aChangedModifiers, TInt aModifiers); + void AddExpectedEnterExit(TInt aEventCode, TPoint aPos); + void AddExpectedKeyAnim(TRawEvent::TType aEventCode, TInt aScanCode,TBool aEat); + void AddExpectedPointerAnim(TRawEvent::TType aEventCode, TPoint aPoint, TBool aEat=ETrue); + void AddExpectedVisibilityChange(TUint aFlags); + void AddExpectedVisibilityChange(TUint aFlags, CTBlankWindow* aWindow); + inline void SimulatePointerWin(TRawEvent::TType aType, TInt aX, TInt aY); + inline void SimulatePointerDownUpWin(TInt aX, TInt aY); + inline void SimulatePointer(TRawEvent::TType aType, TInt aX, TInt aY); + void doSendEvent(TWsEvent &aEvent); + void SendKey(TInt aEventCode, TInt aScanCode, TInt aCode=0, TInt iRepeats=0); + void SendEvent(TInt aEventCode); + void CreateEventTestGroup(); + void CloseEventTestGroup(); + void CreateAndCloseEventTestGroup(); + void TriggerOomMessage(TTimeIntervalMinutes aPeriod); + TBool SetClickType(TClickOutputModes aType); + CTBlankWindow* NewBlueForgroundWindowL(); + CTBlankWindow* NewBlueForgroundWindow(); + TInt KeyRepeatTime() const; + void EventQueuePtrCrashTest(); + TInt ClickCommandReply(TInt aCommand,TInt aData); + TInt CreateGroupWindow(RWindowGroup& aWinGp,TClients aClient,TInt& aWinGpId); + void CloseGroupWindow(RWindowGroup& aWinGp,TInt aWinGpId); + void CloseWindow(RWindowBase& aWin,TInt aHandle,TInt aWinGpId); + void EventQueueExpansionTestL(); + void RawEventRepeatTest_NextSetOfEventsL(); + void SimulateRepeatEvent(TInt aScanCode, TInt aRepeats=0); +#if !defined(TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA) + void SimulateButton1DownWithSimulatedMove(TInt aX, TInt aY); +#endif + void TestCaptureAndCancelCapturePair(TCaptureKeyApis aCaptureApi, TCancelCaptureKeyApis aCancelCaptureApi); + static TInt GenerateAnEvent(TAny* aEventTest); +private: + CTBlankWindow* iBlankWin; + RBlankWindow iBackingWindow; + TSize iPhysicalScreenSize; + TSize iWinSize; + RWindowGroup iEventTestGroup; + CTWindowGroup *iEventTestGroup2; + CTWindowGroup *iEventTestGroup3; + CTWindowGroup *iEventTestGroup4; + TInt iEventSet; + CTQueueClient *iQueueClient; + TBool iFailed; + REventAnim* iAnim; + TUint iScreenModeTests; //currently contains supported rotation and if screen scaling is possible + TInt iNumScrModes; + RSoundPlugIn iClick; + TBool iAddToClick; + TInt iCaptureKey; + TBool iTurnBackOnCapsLock; + TInt iCurrentMode; + TSizeMode iSizeMode; + TBool iTheClientFlush; + TBool iQuequeClientFlush; + CTBlankWindow* iVisWins1; + CTBlankWindow* iVisWins2; + CTBlankWindow* iVisWins3; + CTransWindow* iTransWin; + RAnimDll* iAnimDll; + RPointerArray* iRemovableAnims; + TBool iIs3DPointer; + TBool iPtrPluginLoaded; + TInt iYOffset; +#ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS +#ifndef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + TSurfaceId iSurfaceId; + RSurfaceManager iSurfaceManager; + CPeriodic* iTimeOutCallback; +#endif // TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA +#endif // SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS + }; + +class CTQueueWindowGroup : public CTWindowGroup + { +public: + CTQueueWindowGroup(CTClient *aClient); + void ConstructL(); +private: + TInt iNumOnEvents; + }; + +class CTEventTestStep : public CTGraphicsStep + { +public: + CTEventTestStep(); +protected: + //from CTGraphicsStep + virtual CTGraphicsBase* CreateTestL(); + }; + +_LIT(KTEventTestStep,"TEventTest"); + + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TEvent.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TEvent.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,7027 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Test window server events +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef __INIPARSER_H__ +#define __INIPARSER_H__ +#endif // __INIPARSER_H__ + +#include "PARSEINIDATA.H" +#include "TEVENT.H" +#include "W32CLICK.H" +#include +#include + +#define FAIL_LOGGING on +//#define DETAILED +#define LOGGING 1 //Uncomment this when there is a fail so that you get more logging + +_LIT(KKeyClickPluginDll, "click.dll"); + +CTQueueClient::CTQueueClient(CTEventTest *aTest) : iTest(aTest) + { + } + +CTQueueClient::~CTQueueClient() + { + CloseEventTestGroupOnSecondScreen(); + iGroup->GroupWin()->EnableReceiptOfFocus(EFalse); + delete iChildWin; + delete iWin; + + } + +void CTQueueClient::ConstructL(TBool aCreateChild) + { + CTClient::ConstructL(); + iGroup=new(ELeave) CTQueueWindowGroup(this); + iGroup->ConstructL(); + iWin=new(ELeave) CTBackedUpWin(EGray4); + iWin->ConstructExtLD(*iGroup,TPoint(EWinPositionX,EWinPositionY),TSize(EWinWidth,EWinHeight)); + iWin->Activate(); + if (aCreateChild) + { + iChildWin=new(ELeave) CTBackedUpWin(EGray4); + iChildWin->ConstructExtLD(*iWin,ChildTopLeft(),ChildSize()); + iChildWin->Activate(); + } + iWs.Flush(); + } + +void CTQueueClient::ConstructEventHandlerL() + { + iEventHandler=new(ELeave) CTQueueTestEvent(&iWs, iTest); + ((CTQueueTestEvent *)iEventHandler)->ConstructL(); + } + +TInt CTQueueClient::WindowGroupIdentifier() + { + return(iGroup->GroupWin()->Identifier()); + } + +CTWinBase* CTQueueClient::GetHandle(TPoint& aPos) + { + if (iCapturing) + return iChildWin; + if (iChildWin && TRect(ChildTopLeft(),ChildSize()).Contains(aPos)) + //if (iChildWin && TRect(TPoint(),ChildSize()).Contains(aPos)) + { + aPos-=ChildTopLeft(); + if (iChildCapturing) + iCapturing=ETrue; + return iChildWin; + } + return iWin; + } + +void CTQueueClient::AddExpectedEvent(TWsEvent &aEvent) + { +#if defined(DETAILED) + _LIT(KLog," Adding Event Type=%d"); + TLogMessageText buf; + buf.Format(KLog,aEvent.Type()); + LogMessage(buf); +#endif + ((CTQueueTestEvent *)iEventHandler)->AddExpectedEvent(aEvent); + } + +void CTQueueClient::SetChildCapture(TInt aCaptureFlags) + { + if (!iChildWin) + return; + iChildWin->BaseWin()->SetPointerCapture(aCaptureFlags); + if (aCaptureFlags|RWindowBase::TCaptureFlagEnabled) + iChildCapturing=ETrue; + } +// + +CTQueueTestEvent::CTQueueTestEvent(RWsSession *aWs, CTEventTest *aTest) : CTEvent(aWs) + { + iTest = aTest; + iCheckTimeStamp = EFalse; + iLastEventError = EFalse; + } + +void CTQueueTestEvent::ConstructL() + { + CTEventBase::Construct(); + iEventBuffer.SetLengthL(EEventBufferSize); + iRedrawType=iTest->TestBase()->RedrawStoreTypeL(); + } + +void CTQueueTestEvent::TestL(TInt aTest) + { + if (!aTest) + { + iTest->Failed(); + User::Leave(ETestFailed); + } + } + +//#define FAIL_LOGGING yes +void CTQueueTestEvent::doRunL() + { + TWsEvent wsEvent; + iWs->GetEvent(wsEvent); + TWsEvent expectedEvent; + +#if defined(FAIL_LOGGING) + TInt eType,wsHan,eHan,wsKeyCode,eKeyCode,wsKeyRepeat,eKeyRepeat,wsKeyScan,eKeyScan; + TLogMessageText buf; + _LIT(KStartString,"AUTO EventTestFail "); +#endif + TInt wsType=wsEvent.Type(); + if (wsEvent.Type()==EEventNull) + TestL(wsEvent.Handle()==0); + else + { + TInt count=iEventBuffer.Count(); + if (count==0 && wsType==EEventFocusGained) + goto End; + if (iLastEventError + && (iRedrawType==EPartialRedraw_FullRedrawSupport || iRedrawType==EPartialRedraw_PreserveStoredCmds) + && wsEvent.Type()==EEventErrorMessage /*&& expectedEvent.Type()!=EEventErrorMessage*/) //Should really check if the next expected event is an error but there is no way to do this without removing it from the buffer + { + #if defined(DETAILED) + _LIT(KLog,"Skip Duplicate Error Message"); + iTest->LOG_MESSAGE(KLog); + #endif + return; //Ignore repeated error events + } + do { + TestL(iEventBuffer.Remove(&expectedEvent)); //Loop needed for REL Build with DEB WSERV and W32 + #if defined(DETAILED) + _LIT(KLog,"Skip event while waiting for error message"); + if (expectedEvent.Type()==EEventErrorMessage && wsEvent.Type()!=expectedEvent.Type()) + iTest->LOG_MESSAGE(KLog); + #endif + } while (expectedEvent.Type()==EEventErrorMessage && wsEvent.Type()!=expectedEvent.Type()); + ++iEventCount; //iEventSet + #if defined(FAIL_LOGGING) + wsType=wsEvent.Type(),eType=expectedEvent.Type(),wsHan=wsEvent.Handle(),eHan=expectedEvent.Handle(); + if (wsType!=eType) + { + _LIT(KEventDiff,"Count=%d Events Differ Exp=%d Act=%d"); + buf.Copy(KStartString); + buf.AppendFormat(KEventDiff,iEventCount,eType,wsType); + iTest->LOG_MESSAGE(buf); + } + else + { + #if defined(DETAILED) + _LIT(KLog," Count=%d Event Type=%d"); + iTest->LOG_MESSAGE3(KLog,iEventCount,wsType); + #endif + } + if (wsHan!=eHan) + { + _LIT(KHandlesDiff,"Count=%d Handles Differ"); + buf.Copy(KStartString); + buf.AppendFormat(KHandlesDiff,iEventCount); + iTest->LOG_MESSAGE(buf); + } + #endif + TestL(wsEvent.Type()==expectedEvent.Type() && wsEvent.Handle()==expectedEvent.Handle()); + } + iLastEventError=(wsEvent.Type()==EEventErrorMessage); + switch(wsEvent.Type()) + { + case EEventKey: + #if defined(FAIL_LOGGING) + wsKeyCode=wsEvent.Key()->iCode,eKeyCode=expectedEvent.Key()->iCode; + if (wsKeyCode!=eKeyCode) + { + _LIT(KKeysDiff,"Count=%d Key Code Exp=%d (%c) Act=%d (%c)"); + buf.Copy(KStartString); + buf.AppendFormat(KKeysDiff,iEventCount,iEventCount,eKeyCode,eKeyCode,wsKeyCode,wsKeyCode); + iTest->LOG_MESSAGE(buf); + } + wsKeyRepeat=wsEvent.Key()->iRepeats,eKeyRepeat=expectedEvent.Key()->iRepeats; + if ((wsKeyRepeat>0)!=(eKeyRepeat>0) || wsKeyRepeatLOG_MESSAGE(buf); + } + #endif + TestL(wsEvent.Key()->iCode==expectedEvent.Key()->iCode && wsEvent.Key()->iRepeats>=expectedEvent.Key()->iRepeats + && (wsEvent.Key()->iRepeats>0)==(expectedEvent.Key()->iRepeats>0)); //Fall Through + case EEventKeyDown: + case EEventKeyUp: + #if defined(FAIL_LOGGING) + wsKeyScan=wsEvent.Key()->iScanCode,eKeyScan=expectedEvent.Key()->iScanCode; + if (wsKeyScan!=eKeyScan) + { + _LIT(KScanDiff,"Count=%d Scan Code Exp=%d (%c) Act=%d (%c)"); + buf.Copy(KStartString); + buf.AppendFormat(KScanDiff,iEventCount,eKeyScan,eKeyScan,wsKeyScan,wsKeyScan); + iTest->LOG_MESSAGE(buf); + } + #endif + TestL(wsEvent.Key()->iScanCode==expectedEvent.Key()->iScanCode); + break; + case EEventModifiersChanged: + { + TBool changeModifiersOK=(wsEvent.ModifiersChanged()->iChangedModifiers + ==expectedEvent.ModifiersChanged()->iChangedModifiers); + TBool modifiersOK=((wsEvent.ModifiersChanged()->iModifiers&wsEvent.ModifiersChanged()->iChangedModifiers)== + (expectedEvent.ModifiersChanged()->iModifiers&wsEvent.ModifiersChanged()->iChangedModifiers)); + #if defined(FAIL_LOGGING) + if (!changeModifiersOK || !modifiersOK) + { + _LIT(KModDiff,"Count=%d Modifiers"); + buf.Copy(KStartString); + buf.AppendFormat(KModDiff,iEventCount); + iTest->LOG_MESSAGE(buf); + } + #endif + TestL(changeModifiersOK); + TestL(modifiersOK); + } + break; + case EEventPointer: + case EEventDragDrop: + { + #if defined(FAIL_LOGGING) + TInt expectedType=expectedEvent.Pointer()->iType, actualType=wsEvent.Pointer()->iType; + TPoint expectedPos=expectedEvent.Pointer()->iPosition, actualPos=wsEvent.Pointer()->iPosition; + if (actualType!=expectedType) + { + _LIT(KPointerDiff,"Count=%d Pointer Type Exp=%d Act=%d"); + buf.Copy(KStartString); + buf.AppendFormat(KPointerDiff,iEventCount,expectedType,actualType); + iTest->LOG_MESSAGE(buf); + } + if (actualPos!=expectedPos) + { + _LIT(KPointerPosDiff,"Count=%d Pointer Pos E=(%d,%d) A=(%d,%d)"); + buf.Copy(KStartString); + buf.AppendFormat(KPointerPosDiff,iEventCount,expectedPos.iX,expectedPos.iY + ,actualPos.iX,actualPos.iY); + iTest->LOG_MESSAGE(buf); + } + #endif + TestL(wsEvent.Pointer()->iType==expectedEvent.Pointer()->iType); + TestL(wsEvent.Pointer()->iPosition==expectedEvent.Pointer()->iPosition); + TInt count=iEventBuffer.Count();count++; //Dummy line to help in debugging. + } + break; + case EEventWindowVisibilityChanged: + { + #if defined(FAIL_LOGGING) + TUint expectedFlags=expectedEvent.VisibilityChanged()->iFlags; + TUint actualFlags=wsEvent.VisibilityChanged()->iFlags; + if (actualFlags!=expectedFlags) + { + _LIT(KVisibilityDiff,"Count=%d Visibility Flags Exp=%d Act=%d"); + buf.Copy(KStartString); + buf.AppendFormat(KVisibilityDiff,iEventCount,expectedFlags,actualFlags); + iTest->LOG_MESSAGE(buf); + } + #endif + TestL(wsEvent.VisibilityChanged()->iFlags==expectedEvent.VisibilityChanged()->iFlags); + TInt count=iEventBuffer.Count();count++; //Dummy line to help in debugging. + } + break; + case EEventMessageReady: + { + const SEventMessageReady message = *(SEventMessageReady*)wsEvent.EventData(); + TestL(message.iMessageUid== TUid::Uid(123)); + } + break; + default:; + } + if(iCheckTimeStamp) + { + const TInt KOffset=100000; //0.1secs + TInt64 offset = expectedEvent.Time().Int64() - wsEvent.Time().Int64(); + #if defined(FAIL_LOGGING) + if(Abs(offset)LOG_MESSAGE(buf); + } + #endif + TestL(Abs(offset)NextSetOfEventsL()); //Not allowed to leave + if(err != KErrNone) + { + buf.Copy(KStartString); + buf.AppendFormat(_L("Subtest does not follow rules set by TEvent test framework, leave code: %d"), err); + iTest->TEST(EFalse); + iTest->LOG_MESSAGE(buf); + User::Leave(err); + } + } + + } + +void CTQueueTestEvent::AddExpectedEvent(TWsEvent &aEvent) + { + if(iCheckTimeStamp) + { + static_cast(aEvent).Time().UniversalTime(); + } + iEventBuffer.Add(&aEvent); + } + +TInt CTQueueTestEvent::EventsLeft() + { + return iEventBuffer.Count(); + } +// + +CTQueueWindowGroup::CTQueueWindowGroup(CTClient *aClient) : CTWindowGroup(aClient) + {} + +void CTQueueWindowGroup::ConstructL() + { + CTWindowGroup::ConstructL(); + User::LeaveIfError(iGroupWin.EnableOnEvents(EEventControlAlways)); + User::LeaveIfError(iGroupWin.EnableGroupChangeEvents()); + } + +// + +/** + Closes and deletes anim DLL. + @param aAnimDll Pointer to the anim Dll to be closed and deleted + */ +LOCAL_C void DestroyAnimDll(TAny* aAnimDll) + { + (static_cast(aAnimDll))->Destroy(); + } + +/** + Destroys an REventAnimBase derived anim + @param aAnim REventAnimBase derived client-side handle to anim + */ +LOCAL_C void DestroyAnim(TAny* aAnim) + { + (static_cast(aAnim))->Destroy(); + } + +/** + Loads the DLL containing the test anims and pushes it onto the cleanup stack. + This function leaves if the operation was unsuccessful. + @return A pointer to the DLL containing test anims + */ +RAnimDll* REventAnimBase::LoadL() + { + RAnimDll* animDll=new(ELeave) RAnimDll(TheClient->iWs); + CleanupStack::PushL(TCleanupItem(DestroyAnimDll,animDll)); + User::LeaveIfError(animDll->Load(KAnimDLLName)); + CleanupStack::Pop(animDll); + return animDll; + } + +/** + Closes the client-side handle to the anim, destroys the DLL and deletes itself. + */ +void REventAnimBase::Destroy() + { + Close(); + delete this; + } + +/** + Resets server-side state of anim + */ +void REventAnimBase::Reset() + { + CommandReply(EADllReset); + } + +/** + @return Under non-error conditions, returns 0. + Under error conditions, returns the number of events received + since the first unexpected event was sent. + */ +TInt REventAnimBase::ErrorCode() + { + return CommandReply(EADllErrorCode); + } + +/** + @return The number of events received by the anim since it was last reset. + */ +TInt REventAnimBase::NumberOfEventsReceived() + { + return CommandReply(EADllNumberOfEventsReceived); + } + +/** + Adds an expected event to the list of events expected by the anim. + @param aEat Indicates if event is expected to be eaten (ETrue 'indicates expected to be eaten') + @param aEvent The expected event + @return KErrNone if succcessful, othewise error code. + */ +TInt REventAnimBase::AddExpectedEvent(TBool aEat, const TRawEvent& aEvent) + { + TAnimRawEvent event; + event.iRawEvent=aEvent; + event.iEat=aEat; + return AddExpectedEvent(event); + } + +/** + Adds an expected event to the list of events expected by the anim. + @param aEvent The expected event + @return KErrNone if succcessful, othewise error code. + */ +TInt REventAnimBase::AddExpectedEvent(const TAnimRawEvent& aEvent) + { + TPckgBuf param; + param()=aEvent; + return CommandReply(EADllAddExpectedEvent,param); + } + +// + +/** + Loads the DLL containing the event test anim and creates an anim for event tests + @param aWin the base window to which the anim is associated (this anim is a Window anim) + @return A pointer to the new REventAnim + */ +REventAnim* REventAnim::NewL(RWindowBase* aWin, RAnimDll* aDll, REventAnimBase::EAnimationType aType/*=EEventAnim*/) + { + REventAnim* self=new(ELeave) REventAnim(aDll); + CleanupStack::PushL(TCleanupItem(DestroyAnim,self)); + User::LeaveIfError(self->Construct(*aWin,(aType == EEventAnim ? EAnimTypeEventTest : EAnimTypeEventPostingTest), TPtrC8())); + CleanupStack::Pop(self); + return self; + } + +/** + Checks if the anim has received the correct events, and resets the sever-side state of the anim + @return positive value if events did not match expected showing the first event that didn't match. + negative value if there were the wrong number of events showing the number of events there were + 0 if correct number of events and they all match + */ +TInt REventAnim::TestFail(TInt aNoEvents) + { + TInt events=CommandReply(EADllErrorCode); + if (events>0) + return events; + events=CommandReply(EADllNoEventsAndReset); + if (events==aNoEvents) + return 0; + return -events; + } + +// +/** + Loads the DLL containing the event test anim and creates an anim for event handler removal tests + @param aWin the base window to which the anim is associated (this anim is a Window anim) + @return A pointer to the new REventAnim + */ +RRemovableAnim* RRemovableAnim::NewLC(RWindowBase* aWin, RAnimDll* aDll) + { + RRemovableAnim* self=new(ELeave) RRemovableAnim(aDll); + CleanupStack::PushL(TCleanupItem(DestroyAnim,self)); + User::LeaveIfError(self->Construct(*aWin,EAnimTypeRemovableAnim,TPtrC8())); + return self; + } + +/** + Sets the lifetime of the anim. This anim will remove itself from the + event handler list after receiving this number of events. + @return The lifetime of the anim + */ +TInt RRemovableAnim::SetEventHandlerLifetime(TInt aEventCount) + { + TPckgBuf param; + param()=aEventCount; + return CommandReply(EADllSetEventHandlerLifetime, param); + } + +/** + Retrieves the lifetime of the anim. This anim will remove itself from the + event handler list after receiving this number of events. + @return The lifetime of the anim + */ +TInt RRemovableAnim::EventHandlerLifetime() + { + return CommandReply(EADllEventHandlerLifetime); + } +/** + Adds the anim to the list of event handlers. + This anim should receive any subsequent events. + @return KErrNone on successful addition. + */ +TInt RRemovableAnim::AddToEventHandlers() + { + return CommandReply(EADllAddToEventHandlers); + } + +/** + Removes the anim from the list of event handlers. + This anim should not receive any subsequent events. + @return KErrNone on successful removal. + */ +TInt RRemovableAnim::RemoveFromEventHandlers() + { + return CommandReply(EADllRemoveFromEventHandlers); + } + +/** + Tests if the anim has received the correct number of events, and that + the events received are all the correct events. + @param aNoEvents The total expected number of events since it was last reset/constructed. + @return ETrue if the anim has received the expected events. + */ +TBool RRemovableAnim::TestPassed() + { + return CommandReply(EADllTestPassed); + } + +// + +CTEventTest::CTEventTest(CTestStep* aStep) : CTWsGraphicsBase(aStep) + { + INFO_PRINTF1(_L("Testing Event functions")); + } + +CTEventTest::~CTEventTest() + { + delete iBlankWin; + iBackingWindow.Close(); + delete iVisWins1; + delete iVisWins2; + delete iVisWins3; + delete iTransWin; + delete iQueueClient; + if (iAnim) + iAnim->Destroy(); + delete iEventTestGroup2; //Just in case it doesn't get deleted normally + delete iEventTestGroup3; //Just in case it doesn't get deleted normally + delete iEventTestGroup4; //Just in case it doesn't get deleted normally + if (iPtrPluginLoaded) + { + iClick.Unload(); + } + iClick.Close(); + if (iTurnBackOnCapsLock) + { + TheClient->iWs.SetModifierState(EModifierCapsLock,ETurnOnModifier); + } + if (iRemovableAnims) + { + EventHandlerRemoval_DestroyAllAnims(); + iRemovableAnims->Close(); + delete iRemovableAnims; + } + if (iAnimDll) + { + iAnimDll->Destroy(); + } +#ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS +#ifndef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + if (!iSurfaceId.IsNull()) + { + iSurfaceManager.CloseSurface(iSurfaceId); + } + iSurfaceManager.Close(); + if(iTimeOutCallback) + { + iTimeOutCallback->Cancel(); + delete iTimeOutCallback; + } +#endif // TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA +#endif // SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS + } + +void CTEventTest::ConstructL() + { + _LIT(KWsIniFile, "z:\\system\\data\\wsini.ini"); + CIniData* iniData = CIniData::NewL(KWsIniFile, ' '); + _LIT( KWsiniYShifting, "YSHIFTING"); + iniData->FindVar(KWsiniYShifting, iYOffset); + delete iniData; + TheClient->iScreen->SetAppScreenMode(0); + TheClient->iScreen->SetScreenMode(0); // in mode 0 TheClient->iScreen->SizeInPixels() + iPhysicalScreenSize = TheClient->iScreen->SizeInPixels(); // is equal to physical screen size + BaseWin->Invalidate(); + BaseWin->Win()->BeginRedraw(); + TheGc->Activate(*BaseWin->Win()); + TheGc->SetBrushColor(TRgb::Gray16(12)); + TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + TheGc->SetPenStyle(CGraphicsContext::ENullPen); + TheGc->DrawRect(TRect(BaseWin->Win()->Size())); + TheGc->Deactivate(); + BaseWin->Win()->EndRedraw(); + TheGc->Activate(*TestWin->Win()); + TheGc->SetBrushColor(TRgb::Gray16(4)); + TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + TheGc->SetPenStyle(CGraphicsContext::ENullPen); + TheGc->DrawRect(TRect(TestWin->Win()->Size())); + TheGc->Deactivate(); + iBackingWindow=RBlankWindow(TheClient->iWs); + iBackingWindow.Construct(*TheClient->iGroup->WinTreeNode(),ENullWsHandle); + iBackingWindow.SetColor(TRgb(0,0xDD,0xDD)); + iBackingWindow.SetOrdinalPosition(-1,-25); + iBackingWindow.Activate(); + iBlankWin=new(ELeave) CTBlankWindow(); + iBlankWin->ConstructL(*TheClient->iGroup); + User::LeaveIfError(iBlankWin->BaseWin()->SetRequiredDisplayMode(EColor256)); + iBlankWin->SetExt(TPoint(),iPhysicalScreenSize); + iBlankWin->SetVisible(EFalse); + iBlankWin->Activate(); + CArrayFixFlat *rotations=new(ELeave) CArrayFixFlat(1); + iNumScrModes=TheClient->iScreen->NumScreenModes(); + TInt modes=Min(2,iNumScrModes); + TInt mode; + TInt rot; + CleanupStack::PushL(rotations); + for (mode=0;modeiScreen->GetRotationsList(mode,rotations)); + for (rot=rotations->Count()-1;rot>=0;--rot) + { + iScreenModeTests|=(1<<(*rotations)[rot]); + } + } + if (CheckScalingSupportedOrNot()) + iScreenModeTests|=EDoScale; + + iClick=RSoundPlugIn(TheClient->iWs); + User::LeaveIfError(iClick.Construct(TUid::Uid(CLICK_THIRD_UID))); + TBool ptrPluginLoadable = EFalse; + iClick.IsLoaded(ptrPluginLoadable); + if (ptrPluginLoadable) + { + User::LeaveIfError(iClick.Load(KKeyClickPluginDll)); + iPtrPluginLoaded = ETrue; + } + CleanupStack::PopAndDestroy(); + if (TheClient->iWs.GetModifierState()&EModifierCapsLock) + { + iTurnBackOnCapsLock=ETrue; + TheClient->iWs.SetModifierState(EModifierCapsLock,ETurnOffModifier); + } + iAnimDll = REventAnimBase::LoadL(); + TInt mods=TheClient->iWs.GetModifierState(); + if (mods&EModifierCapsLock) + iTest->SimulateKeyDownUp(EStdKeyCapsLock); + if (mods&EModifierNumLock) + iTest->SimulateKeyDownUp(EStdKeyNumLock); + //Make sure all the keys we test are in the up state + iTest->SimulateKeyDownUp(EStdKeyLeftShift); + iTest->SimulateKeyDownUp(EStdKeyRightShift); + iTest->SimulateKeyDownUp(EStdKeyLeftFunc); + iTest->SimulateKeyDownUp(EStdKeyLeftCtrl); + iTest->SimulateKeyDownUp(EStdKeyRightCtrl); + mods=TheClient->iWs.GetModifierState(); + _LIT(KLog,"Initial Modifiers state 0x%x (ideally should be zero)"); + LOG_MESSAGE2(KLog,mods); + iTest->DelayIfFullRomL(); + +#if !defined(TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA) + // 2d or 3d pointer? + if(HAL::Get(HALData::EPointer3D,iIs3DPointer)!=KErrNone) + { + iIs3DPointer=EFalse; + } +#endif + } + +void CTEventTest::Failed() + { +#ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS +#ifndef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + if(iTimeOutCallback) + { + iTimeOutCallback->Cancel(); + iTimeOutCallback->Deque(); + delete iTimeOutCallback; + iTimeOutCallback = NULL; + } + TEST(EFalse); +#endif // TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA +#endif // SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS + CActiveScheduler::Stop(); + iFailed=ETrue; + } + +void CTEventTest::CheckTimeInterval(const TTimeIntervalMicroSeconds32 &aTime,TInt aCheckTime) + { + TEST(aTime.Int()==aCheckTime); + if (aTime.Int()!=aCheckTime) + INFO_PRINTF3(_L("aTime.Int()==aCheckTime - Expected: %d, Actual: %d"), aCheckTime, aTime.Int()); + } + +void CTEventTest::KeyRepeatRate(TInt aInitialRepeat, TInt aRepeat) + { + TheClient->iWs.SetKeyboardRepeatRate(TTimeIntervalMicroSeconds32(aInitialRepeat), TTimeIntervalMicroSeconds32(aRepeat)); + TTimeIntervalMicroSeconds32 initialTime; + TTimeIntervalMicroSeconds32 time; + TheClient->iWs.GetKeyboardRepeatRate(initialTime,time); + CheckTimeInterval(initialTime,aInitialRepeat); + CheckTimeInterval(time,aRepeat); + } + +void CTEventTest::DoubleClickSettings(TInt aInterval, TInt aDistance) + { + TheClient->iWs.SetDoubleClick(TTimeIntervalMicroSeconds32(aInterval), aDistance); + TTimeIntervalMicroSeconds32 interval; + TInt distance; + TheClient->iWs.GetDoubleClickSettings(interval, distance); + CheckTimeInterval(interval,aInterval); + TEST(aDistance==distance); + if (aDistance!=distance) + INFO_PRINTF3(_L("aDistance==distance - Expected: %d, Actual: %d"), distance, aDistance); + } + +TInt EventCancelFunc(TAny* aClient) + { + TWsQTEvent event; + event.SetType(EEventModifiersChanged); + ((TModifiersChangedEvent *)event.EventData())->iChangedModifiers=0; + ((TModifiersChangedEvent *)event.EventData())->iModifiers=0; + TheClient->iWs.SendEventToWindowGroup(TheClient->iGroup->GroupWin()->Identifier(),event); +// + TRequestStatus status; + ((CTClient *)aClient)->iWs.EventReady(&status); + ((CTClient *)aClient)->iWs.EventReadyCancel(); + User::WaitForRequest(status); + return(KErrNone); + } + +void CTEventTest::General() + { + TWsQTEvent event; + event.SetType(EEventModifiersChanged); + ((TModifiersChangedEvent *)event.EventData())->iChangedModifiers=0; + ((TModifiersChangedEvent *)event.EventData())->iModifiers=0; + TheClient->iWs.SendEventToWindowGroup(TheClient->iGroup->GroupWin()->Identifier(),event); + TCallBack callBack(EventCancelFunc,TheClient); + TheClient->SetCancelFunction(callBack); +// + TTimeIntervalMicroSeconds32 oldInitialTime; + TTimeIntervalMicroSeconds32 oldTime; + TheClient->iWs.GetKeyboardRepeatRate(oldInitialTime,oldTime); +// + KeyRepeatRate(EKeyboardInitialRepeat1, EKeyboardRepeat1); + KeyRepeatRate(EKeyboardInitialRepeat2, EKeyboardRepeat2); + KeyRepeatRate(EKeyboardInitialRepeat3+200, EKeyboardRepeat3); // Max initial repeat with normal keyboard repeat value + KeyRepeatRate(EKeyboardInitialRepeat3, EKeyboardRepeat7+200); // Max key and initial repeat + KeyRepeatRateNegTest(EKeyboardInitialRepeat4, EKeyboardRepeat4); // -ve initial repeat + KeyRepeatRateNegTest(EKeyboardInitialRepeat2, EKeyboardRepeat6); // -ve keyboard repeat + #if defined __WINS__ || defined __WINSCW__ + KeyRepeatRateNegTest(EKeyboardInitialRepeat3+400, EKeyboardRepeat5); // More than max initial repeat + #endif//defined __WINS__ || defined __WINSCW__ + DoubleClickSettings(EDoubleClickTime1,EDoubleClickGap1); + DoubleClickSettings(EDoubleClickTime2,EDoubleClickGap2); + TheClient->iWs.SetKeyboardRepeatRate(oldInitialTime,oldTime); +// + } + +#define UNIQUE_PRIORITY 123 +void CTEventTest::General2() + { + RWindowGroup& group=*TheClient->iGroup->GroupWin(); + TInt priority=group.OrdinalPriority(); + TInt position=group.OrdinalPosition(); + TInt priorityGain=TheClient->iWs.GetWindowGroupOrdinalPriority(group.Identifier())-priority; + group.SetOrdinalPosition(0,UNIQUE_PRIORITY); + TWsQTEvent event; + event.SetType(EEventModifiersChanged); + ((TModifiersChangedEvent *)event.EventData())->iChangedModifiers=0; + ((TModifiersChangedEvent *)event.EventData())->iModifiers=0; + TheClient->iWs.SendEventToAllWindowGroups(UNIQUE_PRIORITY+priorityGain,event); + TCallBack callBack(EventCancelFunc,TheClient); + TheClient->SetCancelFunction(callBack); + group.SetOrdinalPosition(position,priority); + } + +void CTEventTest::AddExpectedKey(TInt aEventCode, TInt aScanCode, TInt aCode/*=0*/, TInt aRepeats/*=0*/, TUint aModifiers/*=0*/) + { + TPckgBuf evtPkg; + TWsEvent& event=evtPkg(); + if (aEventCode==EEventKey && aCode==0) + aCode=aScanCode; + event.SetType(aEventCode); + event.SetHandle((TInt)iQueueClient->iGroup); + event.Key()->iCode=aCode; + event.Key()->iScanCode=aScanCode; + event.Key()->iModifiers=aModifiers; + event.Key()->iRepeats=aRepeats; + iQueueClient->AddExpectedEvent(event); + if (iAddToClick) + iClick.CommandReply(EClickEventAdd,evtPkg); + } + +void CTEventTest::AddExpectedKeyDownUp(TInt aScanCode, TInt aCode/*=0*/, TInt aRepeats/*=0*/, TUint aModifiers/*=0*/) + { + __ASSERT_DEBUG(aScanCode<'a' || aScanCode>'z',AutoPanic(EAutoPanicScanCapital)); + AddExpectedKey(EEventKeyDown,aScanCode,0,aRepeats,aModifiers); + AddExpectedKey(EEventKey,aScanCode,aCode,aRepeats,aModifiers); + AddExpectedKey(EEventKeyUp,aScanCode,0,aRepeats,aModifiers); + } + +void CTEventTest::AddExpectedEvent(TInt aEventCode, CTWinBase* aWin) + { + TWsQTEvent event; + event.iType=aEventCode; + event.iHandle=REINTERPRET_CAST(TInt,aWin); + iQueueClient->AddExpectedEvent(event); + } + +void CTEventTest::AddExpectedEvent(TInt aEventCode, RWindowGroup* aWindow) + { + TWsQTEvent event; + event.iType=aEventCode; + event.iHandle=(TUint32)aWindow; + iQueueClient->AddExpectedEvent(event); + } + +void CTEventTest::AddExpectedEvent(TInt aEventCode) + { + AddExpectedEvent(aEventCode,iQueueClient->iGroup); + } + +void CTEventTest::AddExpectedErrorMessage(TWsErrorMessage::TErrorCategory aCategory, TInt aError) + { + TWsQTEvent event; + event.iType=EEventErrorMessage; + event.iHandle=(TInt)iQueueClient->iGroup; + event.ErrorMessage()->iErrorCategory=aCategory; + event.ErrorMessage()->iError=aError; + iQueueClient->AddExpectedEvent(event); + } + +void CTEventTest::CalculatePointerEvent(TWsEvent& aEvent,TPointerEvent::TType aType, TPoint aPos) + { +#if !defined(TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA) + TAdvancedPointerEvent& ptrEvent=*aEvent.Pointer(); + aEvent.SetType(EEventPointer); + ptrEvent.iParentPosition=aPos; + // SetHandle must be done after iParentPosition is set, but before iPosition is set. + aEvent.SetHandle(reinterpret_cast(iQueueClient->GetHandle(aPos))); + const TPoint3D point3D(aPos.iX, aPos.iY, 0); + const TInt pointerEventModifiers=0; + const TUint8 pointerNumber=0; + aEvent.InitAdvancedPointerEvent(aType,pointerEventModifiers,point3D,pointerNumber); +#else + TPointerEvent& ptrEvent=*aEvent.Pointer(); + aEvent.SetType(EEventPointer); + ptrEvent.iParentPosition=aPos; //Must be done before next line + aEvent.SetHandle(REINTERPRET_CAST(TInt,iQueueClient->GetHandle(aPos))); + ptrEvent.iType=aType; + ptrEvent.iModifiers=0; + ptrEvent.iPosition=aPos; +#endif + } + +void CTEventTest::CalculatePointerCaptureEvent(TWsEvent& aEvent, TPointerEvent::TType aType, TPoint aPos, TInt aHandle) + { + TPointerEvent& ptrEvent=*aEvent.Pointer(); + aEvent.SetType(EEventPointer); + ptrEvent.iParentPosition=aPos; //Must be done before next line + if(iVisWins1 && iVisWins2) + { + if (TRect(iQueueClient->ChildTopLeft(),iQueueClient->ChildSize()).Contains(aPos) && + !TRect(iQueueClient->ChildTopLeft()+TPoint(15,15),iQueueClient->ChildSize()).Contains(aPos)) + { + aPos-=iQueueClient->ChildTopLeft(); //Pointer is on the first window + aEvent.SetHandle((TInt)iVisWins1); + } + else if (TRect(iQueueClient->ChildTopLeft()+TPoint(15,15),iQueueClient->ChildSize()).Contains(aPos)) + { + aPos-=(iQueueClient->ChildTopLeft()+TPoint(15,15)); //Pointer is on the second window + aEvent.SetHandle((TInt)iVisWins2); + } + else if (TRect(TPoint(EWinPositionX,EWinPositionY),TSize(EWinWidth,EWinHeight)).Contains(aPos)) + { + aPos-=TPoint(EWinPositionX,EWinPositionY); //Pointer is on the parent window + aEvent.SetHandle((TInt)iQueueClient->iWin); + } + else + { + aEvent.SetHandle((TInt)0); //Pointer is not in the same window group + } + } + ptrEvent.iType=aType; + ptrEvent.iModifiers=0; + if(aHandle!=0 && aHandle!=aEvent.Handle()) + { + aEvent.SetHandle(aHandle); + ptrEvent.iPosition=ptrEvent.iParentPosition-(iQueueClient->ChildTopLeft()+TPoint(15,15)); + } + else + { + ptrEvent.iPosition=aPos; + } + } + +void CTEventTest::AddExpectedPointerCapture(TPointerEvent::TType aType, TPoint aPos, TInt aHandle) + { + TPckgBuf evtPkg; + CalculatePointerCaptureEvent(evtPkg(),aType,aPos,aHandle); + iQueueClient->AddExpectedEvent(evtPkg()); + } + +void CTEventTest::AddExpectedPointer(TPointerEvent::TType aType, TPoint aPos) + { + TPckgBuf evtPkg; + CalculatePointerEvent(evtPkg(),aType,aPos); + iQueueClient->AddExpectedEvent(evtPkg()); + if (iAddToClick) + { + evtPkg().Pointer()->iParentPosition+=TPoint(EWinPositionX,EWinPositionY); + iClick.CommandReply(EClickEventAdd,evtPkg); + } + } + +void CTEventTest::AddExpectedPointerClick(TPointerEvent::TType aType, TPoint aPos) + { + TPckgBuf evtPkg; + CalculatePointerEvent(evtPkg(),aType,aPos); + evtPkg().Pointer()->iParentPosition+=TPoint(EWinPositionX,EWinPositionY); + iClick.CommandReply(EClickEventAdd,evtPkg); + } + +void CTEventTest::AddExpectedPointerDownUp(TPoint aPos) + { + AddExpectedPointer(TPointerEvent::EButton1Down,aPos); + AddExpectedPointer(TPointerEvent::EButton1Up,aPos); + } + +void CTEventTest::AddExpectedPointerScr(TPointerEvent::TType aType, TPoint aPos) + { + AddExpectedPointer(aType,TPoint(aPos.iX-EWinPositionX,aPos.iY-EWinPositionY)); + } + +void CTEventTest::AddExpectedPointerDownUpScr(TPoint aPos) + { + AddExpectedPointerDownUp(TPoint(aPos.iX-EWinPositionX,aPos.iY-EWinPositionY)); + } + +void CTEventTest::AddExpectedModifiersChanged(TInt aChangedModifiers, TInt aModifiers) + { + TWsQTEvent event; + event.iType=EEventModifiersChanged; + event.iHandle=(TInt)iQueueClient->iGroup; + event.ModifiersChanged()->iChangedModifiers=aChangedModifiers; + event.ModifiersChanged()->iModifiers=aModifiers; + iQueueClient->AddExpectedEvent(event); + } + +void CTEventTest::AddExpectedEnterExit(TInt aEventCode, TPoint aPos) + { + AddExpectedEvent(aEventCode,iQueueClient->GetHandle(aPos)); + } + +void CTEventTest::AddExpectedKeyAnim(TRawEvent::TType aEventCode, TInt aScanCode, TBool aEat) + { + TAnimRawEvent event; + event.iRawEvent.Set(aEventCode,aScanCode); + event.iEat=aEat; + TInt retVal = iAnim->AddEvent(event); + TEST(retVal==KErrNone); + if (retVal!=KErrNone) + INFO_PRINTF3(_L("iAnim->AddEvent(event) return value - Expected: %d, Actual: %d"), KErrNone, retVal); + + if (!aEat) + AddExpectedKey((aEventCode==TRawEvent::EKeyDown ? EEventKeyDown:EEventKeyUp),aScanCode); + } + +void CTEventTest::AddExpectedPointerAnim(TRawEvent::TType aEventCode, TPoint aPoint, TBool aEat/*=ETrue*/) + { + TAnimRawEvent event; + event.iRawEvent.Set(aEventCode,aPoint.iX,aPoint.iY); + event.iEat=aEat; + + TInt retVal = iAnim->AddEvent(event); + TEST(retVal==KErrNone); + if (retVal!=KErrNone) + INFO_PRINTF3(_L("iAnim->AddEvent(event) return value - Expected: %d, Actual: %d"), KErrNone, retVal); + + if (!aEat) + AddExpectedPointer((aEventCode==TRawEvent::EButton1Down ? TPointerEvent::EButton1Down:TPointerEvent::EButton1Up) + ,aPoint-TPoint(EWinPositionX,EWinPositionY)); + } + +void CTEventTest::AddExpectedVisibilityChange(TUint aFlags) + { + TWsQTEvent event; + event.iType=EEventWindowVisibilityChanged; + event.iHandle=(TInt)iVisWins1; + event.VisibilityChanged()->iFlags=aFlags; + iQueueClient->AddExpectedEvent(event); + } + +void CTEventTest::AddExpectedVisibilityChange(TUint aFlags, CTBlankWindow* aWindow) + { + TWsQTEvent event; + event.iType=EEventWindowVisibilityChanged; + event.iHandle=(TInt)aWindow; + event.VisibilityChanged()->iFlags=aFlags; + iQueueClient->AddExpectedEvent(event); + } + +void CTEventTest::SimulatePointerWin(TRawEvent::TType aType, TInt aX, TInt aY) + { + SimulatePointer(aType,EWinPositionX+aX,EWinPositionY+aY+iYOffset); + } + +void CTEventTest::SimulatePointerDownUpWin(TInt aX, TInt aY) + { + iTest->SimulatePointerDownUp(EWinPositionX+aX,EWinPositionY+aY+iYOffset); + } + +void CTEventTest::SimulatePointer(TRawEvent::TType aType, TInt aX, TInt aY) + { + iTest->SimulatePointer(aType,aX,aY+iYOffset); + } + +#if !defined(TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA) +void CTEventTest::SimulateButton1DownWithSimulatedMove(TInt aX, TInt aY) + { + if(iIs3DPointer) + { + // With advanced pointer events we can have an XYInputType of Pointer coupled with 3DPointer + // which now makes MovesAvailable return ETrue rahter than EFalse, which in turn stops the simulated + // Emove from being generated. + // So... + // If MovesAvailable() returns ETrue, then this move will be used, and the WServ simulated move wont be generated + // If MovesAvailable() returns EFalse, then this move will be filtered out, and the WServ simulated move will be generated + SimulatePointer(TRawEvent::EPointerMove,aX,aY); + } + // then the original button down event + SimulatePointer(TRawEvent::EButton1Down,aX,aY); + } +#endif + +void CTEventTest::NextSetOfEventsL() + { + iQueueClient->ResetCount(iEventSet); + switch (iTest->iState) + { + case 1: + QueuePurge_NextSetOfEventsL(); + break; + case 2: + SendEventTest_NextSetOfEvents(); + break; + case 4: + InvisibleWindow_NextSetOfEvents(); + break; + case 5: + JavaAdditions_NextSetOfEvents(); + break; + case 6: + WinCap_NextSetOfEvents(); + break; + case 7: + XyInputType_NextSetOfEvents(); + break; + case 8: + MovingPointerCursor_NextSetOfEventsL(); + break; + case 9: + RotatedMode_NextSetOfEventsL(); + break; + case 10: + AnimEvent_NextSetOfEventsL(); + break; + case 11: + FocusChanged_NextSetOfEventsL(); + break; + case 12: + StopEvents_NextSetOfEventsL(); + break; + case 13: + VirtualKeyboard_NextSetOfEventsL(); + break; + case 14: + KeyClicks_NextSetOfEvents(); + break; + case 15: + CaptureLong_NextSetOfEventsL(); + break; + case 16: + Password_NextSetOfEvents(); + break; + case 17: + GroupListChanged_NextSetOfEventsL(); + break; + case 18: + RepeatableKeysL(); + break; + case 19: + ScreenScaling_NextSetOfEventsL(); + break; + case 20: + VisibilityChanged_NextSetOfEventsL(); + break; + case 21: + CheckTimeStamp_NextSetOfEventsL(); + break; + case 22: + PointerCapture_NextSetOfEventsL(); + break; + case 23: + EventHandlerRemoval_NextSetOfEventsL(); + break; + // Note that case 24 (which is KTest24) does not use NextSetOfEventsL() + case 25: + MismatchedCapture_NextSetOfEventsL(); + break; + case 26: + PointerBufferPurge_NextSetOfEventsL(); + break; + case 27: + RawEventRepeatTest_NextSetOfEventsL(); + break; + +#ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS +#ifndef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + case 28: + SurfaceVisibilityChanged1_NextSetOfEventsL(); + break; + case 29: + SurfaceVisibilityChanged2_NextSetOfEventsL(); + break; + case 30: + SurfaceVisibilityChanged3_NextSetOfEventsL(); + break; +#endif // TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA +#endif // SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS + + default: + AutoPanic(EAutoPanicWrongTest); + } + } + +void CTEventTest::TriggerOomMessage(TTimeIntervalMinutes aPeriod) + { + TTime time; + if (aPeriod.Int()!=0) // adjust time to affect Oom message triggering + { + time.HomeTime(); + User::SetHomeTime(time+aPeriod); + } + RBlankWindow win(TheClient->iWs); + win.Construct(*(TheClient->iGroup->WinTreeNode()),1); + win.SetColor(TRgb::Gray4(1)); + win.SetExtent(TPoint(10,10),TheClient->iGroup->Size()-TSize(20,20)); + TheClient->iWs.HeapSetFail(RHeap::EDeterministic,1); + win.Activate(); + TheClient->iWs.Flush(); + TheClient->iWs.HeapSetFail(RHeap::ENone,0); + if (aPeriod.Int()!=0) + { + time.HomeTime(); + User::SetHomeTime(time-aPeriod); + } + win.Close(); + } + +TBool CTEventTest::SetClickType(TClickOutputModes aType) + { + TPckgBuf intPkg; + intPkg()=aType; + TInt err=iClick.CommandReply(EClickCommandSetOutput,intPkg); + if (err!=KErrNone) + Failed(); + return err; + } + +void CTEventTest::CreateEventTestGroup() + { + iEventTestGroup=RWindowGroup(TheClient->iWs); + iEventTestGroup.Construct(123, EFalse); + iEventTestGroup.SetName(_L("Fred")); + } + +void CTQueueClient::CreateEventTestGroupOnSecondScreenL() + { + const TInt KSndScreenNo=1; + iSndScreen=new(ELeave) CWsScreenDevice(iWs); + User::LeaveIfError(iSndScreen->Construct(KSndScreenNo)); + iWinGp1 = new(ELeave) RWindowGroup(iWs); + User::LeaveIfError(iWinGp1->Construct((TUint32)iWinGp1,ETrue,iSndScreen)); + iWinGp2 = new (ELeave) RWindowGroup(iWs); + User::LeaveIfError(iWinGp2->Construct((TUint32)iWinGp2,ETrue,iSndScreen)); + } + +void CTQueueClient::CloseEventTestGroupOnSecondScreen() + { + if(iWinGp1) + { + iWinGp1->Close(); + delete iWinGp1; + iWinGp1=NULL; + } + if(iWinGp2) + { + iWinGp2->Close(); + delete iWinGp2; + iWinGp2=NULL; + } + if(iSndScreen) + { + delete iSndScreen; + iSndScreen = NULL; + } + } + +void CTEventTest::CloseEventTestGroup() + { + iEventTestGroup.Close(); + } + +void CTEventTest::CreateAndCloseEventTestGroup() +// +// Create and close a window group to test sending of group changed messages +// + { + CreateEventTestGroup(); + CloseEventTestGroup(); + } + +void CTEventTest::QueuePurge_NextSetOfEventsL() + { +#if defined(LOGGING) + TLogMessageText logMessageText; + _LIT(KSet,"QueuePurge SetOfEvents: %d of 11"); + logMessageText.Format(KSet,iEventSet); + TheClient->LogMessage(logMessageText); +#endif + iTheClientFlush=TheClient->iWs.SetAutoFlush(ETrue); + iQuequeClientFlush=iQueueClient->iWs.SetAutoFlush(ETrue); + switch(iEventSet++) + { + case 0: + iTest->SimulateKey(TRawEvent::EKeyDown,32); + iTest->SimulateKey(TRawEvent::EKeyUp,32); + CreateAndCloseEventTestGroup(); + SimulatePointer(TRawEvent::EButton1Down,10,20); + SimulatePointer(TRawEvent::EButton1Up,20,30); + iTest->SimulateEvent(TRawEvent::ESwitchOn); + CreateAndCloseEventTestGroup(); + // + AddExpectedEvent(EEventFocusGained); + AddExpectedKey(EEventKeyDown,32); + AddExpectedKey(EEventKeyUp,32); + AddExpectedEvent(EEventWindowGroupsChanged); + AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(10-EWinPositionX,20-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(20-EWinPositionX,30-EWinPositionY)); + AddExpectedEvent(EEventSwitchOn); + break; + case 1: + { + for(TInt count=0;count<100;count++) + { + iTest->SimulateKey(TRawEvent::EKeyDown,'A'+(count%26)); + iTest->SimulateKey(TRawEvent::EKeyUp,'A'+(count%26)); + } + for(TInt count2=0;count2iGroup->GroupWin()->EnableModifierChangedEvents(0xFFFFFFFF, EEventControlOnlyWhenVisible)); + for(TInt count=0;count<20;count++) + { + iTest->SimulateEvent(TRawEvent::ESwitchOn); + iTest->SimulateEvent(TRawEvent::ESwitchOn); + iTest->SimulateKey(TRawEvent::EKeyDown,EStdKeyLeftShift); + iTest->SimulateKey(TRawEvent::EKeyDown,EStdKeyRightShift); + iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeyRightShift); + iTest->SimulateEvent(TRawEvent::ESwitchOn); + iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeyLeftShift); + } + for(TInt count2=0;count2<60;count2++) + iTest->SimulateKey(TRawEvent::EKeyDown,'A'); + AddExpectedEvent(EEventSwitchOn); + AddExpectedModifiersChanged(EModifierLeftShift|EModifierRightShift|EModifierShift,0); + for(TInt count3=0;count3iGroup->GroupWin()->DisableModifierChangedEvents(); + } + break; + case 3: + { + SimulatePointer(TRawEvent::EButton1Up,10,20); + SimulatePointer(TRawEvent::EButton2Up,11,22); + SimulatePointer(TRawEvent::EButton1Down,12,23); + SimulatePointer(TRawEvent::EPointerMove,13,24); + SimulatePointer(TRawEvent::EButton3Down,15,25); + SimulatePointer(TRawEvent::EButton1Up,14,24); + for(TInt count2=0;count2<60;count2++) + iTest->SimulateKey(TRawEvent::EKeyDown,'A'); + SimulatePointer(TRawEvent::EButton3Up,15,25); // Should get stripped by unmatched purged down handling code + iTest->SimulateKey(TRawEvent::EKeyUp,'A'); // To stop repeats + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(10-EWinPositionX,20-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton2Up, TPoint(11-EWinPositionX,22-EWinPositionY)); + for(TInt count3=0;count3SimulateKey(TRawEvent::EKeyDown,'B'); + SimulatePointer(TRawEvent::EButton1Down,12,23); + SimulatePointer(TRawEvent::EPointerMove,13,24); + iTest->SimulateKey(TRawEvent::EKeyUp,'B'); + SimulatePointer(TRawEvent::EButton3Down,15,25); + SimulatePointer(TRawEvent::EButton1Up,14,24); + iQueueClient->iWs.PurgePointerEvents(); + iTest->SimulateEvent(TRawEvent::ESwitchOn); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(10-EWinPositionX,20-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton2Up, TPoint(11-EWinPositionX,22-EWinPositionY)); + AddExpectedKey(EEventKeyDown,'B'); + AddExpectedKey(EEventKey,'B','b'); + AddExpectedKey(EEventKeyUp,'B'); +// AddExpectedPointer(TPointerEvent::EButton3Down, TPoint(15-EWinPositionX,25-EWinPositionY)); + AddExpectedEvent(EEventSwitchOn); // To check pointer events purged okay + } + break; + case 5: + CreateEventTestGroup(); + AddExpectedEvent(EEventWindowGroupsChanged); + break; + case 6: + CloseEventTestGroup(); + AddExpectedEvent(EEventWindowGroupsChanged); + break; + case 7: + iQueueClient->iGroup->GroupWin()->DisableGroupChangeEvents(); + CreateAndCloseEventTestGroup(); + iTest->SimulateEvent(TRawEvent::ESwitchOn); + AddExpectedEvent(EEventSwitchOn); + break; + case 8: + SimulatePointer(TRawEvent::EButton1Down,12,23); + iQueueClient->iWs.PurgePointerEvents(); + SimulatePointer(TRawEvent::EButton1Up,13,24); + SimulatePointer(TRawEvent::EButton2Down,12,23); + iQueueClient->iWs.PurgePointerEvents(); + SimulatePointer(TRawEvent::EButton2Up,13,24); + SimulatePointer(TRawEvent::EButton3Down,12,23); + iQueueClient->iWs.PurgePointerEvents(); + SimulatePointer(TRawEvent::EButton3Up,13,24); +// + SendEvent(EEventUser); + AddExpectedEvent(EEventUser); + break; + case 9: + { + for(TInt count5=0;count5<500;count5++) + { + RWindowGroup group(TheClient->iWs); + group.Construct(ENullWsHandle); + group.EnableReceiptOfFocus(EFalse); + group.Close(); + SimulatePointer(TRawEvent::EButton1Up,10,20); + } + for(TInt count4=0;count4iGroup->GroupWin(); + User::LeaveIfError(group->EnableOnEvents(EEventControlOnlyWithKeyboardFocus)); + iTest->SimulateEvent(TRawEvent::ESwitchOn); + SimulatePointer(TRawEvent::EButton3Down,EWinPositionX,EWinPositionY); + AddExpectedEvent(EEventSwitchOn); + AddExpectedPointer(TPointerEvent::EButton3Down, TPoint(0,0)); +// + group->SetOrdinalPosition(-1); + TheClient->iWs.Finish(); + iTest->SimulateEvent(TRawEvent::ESwitchOn); // Shouldn't get it as in background this time + AddExpectedEvent(EEventFocusLost); + group->SetOrdinalPosition(0); + TheClient->iWs.Finish(); + AddExpectedEvent(EEventFocusGained); +// + User::LeaveIfError(group->EnableOnEvents(EEventControlOnlyWhenVisible)); + User::LeaveIfError(group->EnableModifierChangedEvents(EModifierShift, EEventControlOnlyWhenVisible)); + iTest->SimulateEvent(TRawEvent::ESwitchOn); // Should get this as window still visible + AddExpectedEvent(EEventSwitchOn); + iTest->SimulateKey(TRawEvent::EKeyDown,EStdKeyLeftShift); // Should get modifier changed event as window still visible + AddExpectedModifiersChanged(EModifierShift,EModifierShift); + AddExpectedKey(EEventKeyDown,EStdKeyLeftShift); + SimulatePointer(TRawEvent::EButton1Down,EWinPositionX,EWinPositionY); + SimulatePointer(TRawEvent::EButton1Up,EWinPositionX,EWinPositionY); + AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(0,0)); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(0,0)); + iQueueClient->iWin->SetPos(TPoint(-EWinWidth,-EWinHeight)); + TheClient->iWs.Finish(); +// The following two events shouldn't cause an on or mod changed event as the window is now hidden + iTest->SimulateEvent(TRawEvent::ESwitchOn); + iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeyLeftShift); + AddExpectedKey(EEventKeyUp,EStdKeyLeftShift); +// + iQueueClient->iWin->SetPos(TPoint(EWinPositionX,EWinPositionY)); + TheClient->iWs.Finish(); + } + break; + case 11: + { + RWindowGroup *group=iQueueClient->iGroup->GroupWin(); + SendEvent(EEventUser); + AddExpectedEvent(EEventUser); + + if(iTest->IsFullRomL()) + break; +// +// Test focus only messages when with and without focus +// + User::LeaveIfError(group->EnableErrorMessages(EEventControlOnlyWithKeyboardFocus)); + TriggerOomMessage(TTimeIntervalMinutes(3)); + AddExpectedErrorMessage(TWsErrorMessage::EDrawingRegion,KErrNoMemory); + SendEvent(EEventUser); + AddExpectedEvent(EEventUser); + group->SetOrdinalPosition(1); + TriggerOomMessage(TTimeIntervalMinutes(3)); + AddExpectedEvent(EEventFocusLost); + group->SetOrdinalPosition(0); + AddExpectedEvent(EEventFocusGained); + SendEvent(EEventUser+1); + AddExpectedEvent(EEventUser+1); +// +// Test focus only messages when with visible and invisible +// + User::LeaveIfError(group->EnableErrorMessages(EEventControlOnlyWhenVisible)); + TriggerOomMessage(TTimeIntervalMinutes(3)); + AddExpectedErrorMessage(TWsErrorMessage::EDrawingRegion,KErrNoMemory); + iQueueClient->iWin->SetPos(TPoint(-EWinWidth,-EWinHeight)); + TriggerOomMessage(TTimeIntervalMinutes(3)); + SendEvent(EEventUser+2); + AddExpectedEvent(EEventUser+2); + iQueueClient->iWin->SetPos(TPoint(EWinPositionX,EWinPositionY)); +// +// Check always mode sends an event +// + User::LeaveIfError(group->EnableErrorMessages(EEventControlAlways)); + TriggerOomMessage(TTimeIntervalMinutes(3)); + AddExpectedErrorMessage(TWsErrorMessage::EDrawingRegion,KErrNoMemory); +// + iQueueClient->iWin->SetPos(TPoint(-EWinWidth,-EWinHeight)); + TriggerOomMessage(TTimeIntervalMinutes(3)); + AddExpectedErrorMessage(TWsErrorMessage::EDrawingRegion,KErrNoMemory); + iQueueClient->iWin->SetPos(TPoint(EWinPositionX,EWinPositionY)); +// + group->SetOrdinalPosition(1); + AddExpectedEvent(EEventFocusLost); + TriggerOomMessage(TTimeIntervalMinutes(3)); + AddExpectedErrorMessage(TWsErrorMessage::EDrawingRegion,KErrNoMemory); + group->SetOrdinalPosition(0); + AddExpectedEvent(EEventFocusGained); +// +// Check timing of OOM messages +// + TriggerOomMessage(TTimeIntervalMinutes(3)); + AddExpectedErrorMessage(TWsErrorMessage::EDrawingRegion,KErrNoMemory); + TriggerOomMessage(TTimeIntervalMinutes(0)); + User::After(TTimeIntervalMicroSeconds32(1100000)); // 1.1 second + TriggerOomMessage(TTimeIntervalMinutes(0)); + SendEvent(EEventUser+3); + AddExpectedEvent(EEventUser+3); + TriggerOomMessage(TTimeIntervalMinutes(3)); // Forward by a 2 minutes plus the 1.1 from previous test should trigger an OOM event + AddExpectedErrorMessage(TWsErrorMessage::EDrawingRegion,KErrNoMemory); + SendEvent(EEventUser+4); + AddExpectedEvent(EEventUser+4); + TriggerOomMessage(TTimeIntervalMinutes(-1)); // Clock going backwards should trigger an event + AddExpectedErrorMessage(TWsErrorMessage::EDrawingRegion,KErrNoMemory); + User::After(TTimeIntervalMicroSeconds32(800000)); // 8/10ths of a second + TriggerOomMessage(TTimeIntervalMinutes(0)); // Shouldn't trigger an event + SendEvent(EEventUser+5); + AddExpectedEvent(EEventUser+5); + } + break; + default: + TheClient->iWs.DebugInfo(EWsDebugSetEventQueueTest,ETrue); + TRAPD(err, EventQueueExpansionTestL()); + if (err!=KErrNone) + { + iFailed=ETrue; + } + TheClient->iWs.DebugInfo(EWsDebugSetEventQueueTest,EFalse); + CActiveScheduler::Stop(); + break; + } + TheClient->iWs.SetAutoFlush(iTheClientFlush); + iQueueClient->iWs.SetAutoFlush(iQuequeClientFlush); + } + +// Used for testing PDEF112243. +// Create RWsSession/RWindowGroup/RBlankWindow in a loop. In case of odd loop, +// close the session which causes the previous window to gain focus. Also go +// on adding events to the previous session. Along with some change in product +// code and this test code we get some space/memory before globaleventqueue, +// which is the problem faced by licensee for this defect. +void CTEventTest::EventQueueExpansionTestL() + { + const TInt numClients = 5; + TInt cliHanGrpWin = 777; + TInt cliHanBlkWin = 888; + TInt pushed=0; + RWsSession wsSession[numClients]; + RWindowGroup groupWin[numClients]; + RBlankWindow blankWin[numClients]; + + for (TInt i = 0; i < numClients; i++) + { + User::LeaveIfError(wsSession[i].Connect()); + CleanupClosePushL(wsSession[i]); + + groupWin[i] = RWindowGroup(wsSession[i]); + User::LeaveIfError(groupWin[i].Construct(cliHanGrpWin++)); + CleanupClosePushL(groupWin[i]); + groupWin[i].DefaultOwningWindow(); + + blankWin[i] = RBlankWindow(wsSession[i]); + User::LeaveIfError(blankWin[i].Construct(groupWin[i], cliHanBlkWin++)); + if (i%2 == 0) + { + CleanupClosePushL(blankWin[i]); + pushed++; + } + blankWin[i].Activate(); + + if (i%2 == 1) + { + CleanupStack::Pop(2, &wsSession[i]); + wsSession[i].Close(); + + TRawEvent rawEvent; + for (TInt count=0; count < 40; count++) + { + rawEvent.Set(TRawEvent::EKeyDown,'A'+(i%26)); + wsSession[i-1].SimulateRawEvent(rawEvent); + + rawEvent.Set(TRawEvent::EKeyUp,'A'+(i%26)); + wsSession[i-1].SimulateRawEvent(rawEvent); + } + } + } + CleanupStack::PopAndDestroy(pushed*3, &wsSession[0]); + } + +void CTEventTest::doSendEvent(TWsEvent &aEvent) + { + iQueueClient->iWs.SendEventToWindowGroup(iQueueClient->WindowGroupIdentifier(),aEvent); + } + +void CTEventTest::SendKey(TInt aEventCode, TInt aScanCode, TInt aCode/*=0*/, TInt iRepeats/*=0*/) + { + TWsEvent event; + if (aEventCode==EEventKey && aCode==0) + aCode=aScanCode; + event.SetType(aEventCode); + event.Key()->iCode=aCode; + event.Key()->iScanCode=aScanCode; + event.Key()->iModifiers=0; + event.Key()->iRepeats=iRepeats; + doSendEvent(event); + } + +void CTEventTest::SendEvent(TInt aEventCode) + { + TWsQTEvent event; + event.SetType(aEventCode); + doSendEvent(event); + } + +void CTEventTest::SimulateAndCheck(TPoint aOrigin,TSize aScale,TInt aXOffset,TInt aYOffset,TPointerEvent::TType aEventType,TRect aPointerCursorArea) + { + TPoint ptCheck=PhysicalToLogical(TPoint(aOrigin.iX+aXOffset,aOrigin.iY+aYOffset)-aOrigin,aScale); + if (ptCheck.iX < aPointerCursorArea.iTl.iX) + { + ptCheck.iX=aPointerCursorArea.iTl.iX; + } + else if (ptCheck.iX > aPointerCursorArea.iBr.iX) + { + ptCheck.iX=aPointerCursorArea.iBr.iX; + } + if (ptCheck.iY < aPointerCursorArea.iTl.iY) + { + ptCheck.iY=aPointerCursorArea.iTl.iY; + } + else if (ptCheck.iY > aPointerCursorArea.iBr.iY) + { + ptCheck.iY=aPointerCursorArea.iBr.iY; + } + AddExpectedPointer(aEventType,TPoint(ptCheck.iX-EWinPositionX,ptCheck.iY-EWinPositionY)); + } + +void CTEventTest::CheckPointerCursorInDifferentScreenMode(TSizeMode aMode,TPoint aOrigin) + { + aMode.iOrigin=aOrigin; + iQueueClient->iScreen->SetCurrentScreenModeAttributes(aMode); + iQueueClient->iScreen->SetAppScreenMode(iCurrentMode); //This makes the App pick up the new mode parameters + TheClient->iScreen->SetAppScreenMode(iCurrentMode); //Ditto + iQueueClient->iScreen->SetScreenMode(iCurrentMode); //This causes all the windows to be updated + + //.. Tests the general pointer cursor area setting and getting + RWsSession& ws=iQueueClient->iWs; + TRect rect=ws.PointerCursorArea(iCurrentMode); //ws.PointerCursorArea() by default gets first screen mode's pointer cursor area so use other overloaded function + TPoint origin=iQueueClient->iScreen->GetScreenModeOrigin(iCurrentMode); + TSize scale=iQueueClient->iScreen->GetScreenModeScale(iCurrentMode); + TSize fullScreenModeSize=iQueueClient->iScreen->SizeInPixels(); + TRect rect1(PhysicalToLogical(TPoint(),scale),PhysicalToLogical(fullScreenModeSize.AsPoint()-origin,scale)); + TRect rect2=rect1; + rect2.Shrink(20,20); + ws.SetPointerCursorArea(iCurrentMode,rect1); + TEST(ws.PointerCursorArea(iCurrentMode)==rect1); + ws.SetPointerCursorArea(iCurrentMode,rect2); + TEST(ws.PointerCursorArea(iCurrentMode)==rect2); + ws.SetPointerCursorArea(iCurrentMode,rect); + TEST(ws.PointerCursorArea(iCurrentMode)==rect); + + //.. Test events are restricted to correct pointer cursor area + TRect rectPointerCursorArea(10,10,51,51); + iQueueClient->iWs.SetPointerCursorArea(iCurrentMode,rectPointerCursorArea); + TPoint screenModeOrigin=iQueueClient->iScreen->GetDefaultScreenModeOrigin(); + + SimulatePointer(TRawEvent::EButton1Down,screenModeOrigin.iX+5,screenModeOrigin.iY+5); + SimulatePointer(TRawEvent::EButton1Up,screenModeOrigin.iX+25,screenModeOrigin.iY+25); + SimulatePointer(TRawEvent::EButton1Down,screenModeOrigin.iX+50,screenModeOrigin.iY+50); + SimulatePointer(TRawEvent::EButton1Up,screenModeOrigin.iX+75,screenModeOrigin.iY+75); + + SimulatePointer(TRawEvent::EButton1Down,screenModeOrigin.iX+10,screenModeOrigin.iY+15); + SimulatePointer(TRawEvent::EButton1Up,screenModeOrigin.iX+20,screenModeOrigin.iY+5); + SimulatePointer(TRawEvent::EButton1Down,screenModeOrigin.iX+35,screenModeOrigin.iY+40); + SimulatePointer(TRawEvent::EButton1Up,screenModeOrigin.iX+45,screenModeOrigin.iY+70); + + SimulateAndCheck(screenModeOrigin,aMode.iScreenScale,5,5,TPointerEvent::EButton1Down,rectPointerCursorArea); + SimulateAndCheck(screenModeOrigin,aMode.iScreenScale,25,25,TPointerEvent::EButton1Up,rectPointerCursorArea); + SimulateAndCheck(screenModeOrigin,aMode.iScreenScale,50,50,TPointerEvent::EButton1Down,rectPointerCursorArea); + SimulateAndCheck(screenModeOrigin,aMode.iScreenScale,75,75,TPointerEvent::EButton1Up,rectPointerCursorArea); + + SimulateAndCheck(screenModeOrigin,aMode.iScreenScale,10,15,TPointerEvent::EButton1Down,rectPointerCursorArea); + SimulateAndCheck(screenModeOrigin,aMode.iScreenScale,20,5,TPointerEvent::EButton1Up,rectPointerCursorArea); + SimulateAndCheck(screenModeOrigin,aMode.iScreenScale,35,40,TPointerEvent::EButton1Down,rectPointerCursorArea); + SimulateAndCheck(screenModeOrigin,aMode.iScreenScale,45,70,TPointerEvent::EButton1Up,rectPointerCursorArea); + } + +void CTEventTest::SendEventTest_NextSetOfEvents() + { + TTimeIntervalMicroSeconds32 initialTime,time; + TheClient->iWs.GetKeyboardRepeatRate(initialTime,time); + switch(iEventSet++) + { + case 0: + SendKey(EEventKeyDown,1); + SendKey(EEventKeyDown,2); + SendEvent(EEventUser); + SendKey(EEventKeyUp,1); + SendKey(EEventKeyUp,2); + SendEvent(EEventUser+1); + SendEvent(EEventUser+2); +// + AddExpectedEvent(EEventFocusGained); + AddExpectedKey(EEventKeyDown,1); + AddExpectedKey(EEventKeyDown,2); + AddExpectedEvent(EEventUser); + AddExpectedKey(EEventKeyUp,1); + AddExpectedKey(EEventKeyUp,2); + AddExpectedEvent(EEventUser+1); + AddExpectedEvent(EEventUser+2); + break; + case 1: + #if defined(SCREEN_MODE_TESTING) + if (iNumScrModes>1) + { + iQueueClient->iGroup->GroupWin()->EnableScreenChangeEvents(); + + if (SetClickType(EClickCheck)) + return; + iAddToClick=ETrue; + + iQueueClient->iScreen->SetScreenMode(1); + + iAddToClick=EFalse; + SetClickType(EClickNone); + + AddExpectedEvent(EEventScreenDeviceChanged); + SendEvent(EEventUser); + AddExpectedEvent(EEventUser); + iQueueClient->iGroup->GroupWin()->DisableScreenChangeEvents(); + if (iQueueClient->iScreen->ScreenModeEnforcement()==ESizeEnforcementPixelsAndRotation) + AddExpectedEvent(EEventFocusLost); + } + #endif + SendEvent(EEventUser+1); + AddExpectedEvent(EEventUser+1); + break; + case 2: + #if defined(SCREEN_MODE_TESTING) + if (iNumScrModes>1) + { + iQueueClient->iGroup->GroupWin()->EnableScreenChangeEvents(); + + if (SetClickType(EClickCheck)) + return; + iAddToClick=ETrue; + + iQueueClient->iScreen->SetScreenMode(0); + iQueueClient->iScreen->SetScreenMode(1); + iQueueClient->iScreen->SetScreenMode(0); + + iAddToClick=EFalse; + SetClickType(EClickNone); + + AddExpectedEvent(EEventScreenDeviceChanged); // Only one event should get queued + if (iQueueClient->iScreen->ScreenModeEnforcement()==ESizeEnforcementPixelsAndRotation) + AddExpectedEvent(EEventFocusGained); + SendEvent(EEventUser+2); + AddExpectedEvent(EEventUser+2); + iQueueClient->iGroup->GroupWin()->DisableScreenChangeEvents(); + } + #endif + SendEvent(EEventUser+3); + AddExpectedEvent(EEventUser+3); + break; + case 3: + #if defined(SCREEN_MODE_TESTING) + if (iNumScrModes>1) + { + iQueueClient->iGroup->GroupWin()->EnableScreenChangeEvents(); + iQueueClient->iGroup->GroupWin()->DisableScreenChangeEvents(); + + if (SetClickType(EClickCheck)) + return; + iAddToClick=ETrue; + + iQueueClient->iScreen->SetScreenMode(0); + + iAddToClick=EFalse; + SetClickType(EClickNone); + + SendEvent(EEventUser+1); + AddExpectedEvent(EEventUser+1); + } + #endif + SendEvent(EEventUser+4); + AddExpectedEvent(EEventUser+4); + break; + case 4: + iTest->SimulateKey(TRawEvent::EKeyDown,EStdKeySpace); + TheClient->iWs.Flush(); + User::After(initialTime.Int()+time.Int()/3); + iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeySpace); + AddExpectedKey(EEventKeyDown,EStdKeySpace); + AddExpectedKey(EEventKey,EStdKeySpace,' '); + AddExpectedKey(EEventKey,EStdKeySpace,' ',1); + AddExpectedKey(EEventKeyUp,EStdKeySpace); + break; + case 5: //To test sending a key event with iRepeats!=0 + iTest->SimulateKey(TRawEvent::EKeyDown,EStdKeySpace); + TheClient->iWs.Flush(); + User::After(initialTime.Int()+time.Int()/3); + SendKey(EEventKey,EStdKeyHome,EKeyHome,0); + User::After(initialTime.Int()+time.Int()/3); + SendKey(EEventKey,EStdKeyEnd,EKeyEnd,12345); + User::After(initialTime.Int()+time.Int()/3); + iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeySpace); + AddExpectedKey(EEventKeyDown,EStdKeySpace); + AddExpectedKey(EEventKey,EStdKeySpace,' '); + AddExpectedKey(EEventKey,EStdKeySpace,' ',1); + AddExpectedKey(EEventKey,EStdKeyHome,EKeyHome); + AddExpectedKey(EEventKey,EStdKeySpace,' ',1); + AddExpectedKey(EEventKey,EStdKeyEnd,EKeyEnd,1); + AddExpectedKey(EEventKeyUp,EStdKeySpace); + break; + default: + CActiveScheduler::Stop(); + break; + } + TheClient->iWs.Flush(); + } + +void CTEventTest::InvisibleWindow_NextSetOfEvents() + { + switch(iEventSet++) + { + case 0: + SimulatePointer(TRawEvent::EButton1Down,45,30); + SimulatePointer(TRawEvent::EButton1Up,45,30); + SimulatePointer(TRawEvent::EButton1Down,20,10); + SimulatePointer(TRawEvent::EButton1Up,20,10); + TheClient->iWs.Flush(); + iQueueClient->iChildWin->BaseWin()->SetVisible(EFalse); + iQueueClient->iChildWin->BaseWin()->SetVisible(ETrue); + iQueueClient->iWs.Flush(); + SimulatePointer(TRawEvent::EButton1Down,46,31); + SimulatePointer(TRawEvent::EButton1Up,46,31); + AddExpectedEvent(EEventFocusGained); + AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(20-EWinPositionX,10-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(20-EWinPositionX,10-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(46-EWinPositionX,31-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(46-EWinPositionX,31-EWinPositionY)); + break; + case 1: + SimulatePointer(TRawEvent::EButton1Down,21,11); + SimulatePointer(TRawEvent::EButton1Up,21,11); + SimulatePointer(TRawEvent::EButton1Down,44,30); + SimulatePointer(TRawEvent::EButton1Up,44,30); + TheClient->iWs.Flush(); + iQueueClient->iWin->BaseWin()->SetVisible(EFalse); + iQueueClient->iWin->BaseWin()->SetVisible(ETrue); + iQueueClient->iWs.Flush(); + SimulatePointer(TRawEvent::EButton1Down,19,12); + SimulatePointer(TRawEvent::EButton1Up,19,12); + SimulatePointer(TRawEvent::EButton1Down,47,32); + SimulatePointer(TRawEvent::EButton1Up,47,32); + /*AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(44-EWinPositionX,30-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(44-EWinPositionX,30-EWinPositionY));*/ + AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(19-EWinPositionX,12-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(19-EWinPositionX,12-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(47-EWinPositionX,32-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(47-EWinPositionX,32-EWinPositionY)); + break; + default: + CActiveScheduler::Stop(); + break; + } + TheClient->iWs.Flush(); + } + +#define TOP16A 0xAAAA0000 +#define TOP16B 0x55550000 +void CTEventTest::JavaAdditions_NextSetOfEvents() + { + switch(iEventSet++) + { + case 0: + SimulatePointer(TRawEvent::EButton1Down,45,30); + SimulatePointer(TRawEvent::EButton1Up,45,30); + TheClient->iWs.Flush(); + iQueueClient->iWin->BaseWin()->PointerFilter(EPointerMoveEvents,EPointerGenerateSimulatedMove); + iQueueClient->iWs.Flush(); +#if !defined(TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA) + SimulateButton1DownWithSimulatedMove(46,31); +#else + SimulatePointer(TRawEvent::EButton1Down,46,31); +#endif + SimulatePointer(TRawEvent::EButton1Up,46,31); + TheClient->iWs.Flush(); + iQueueClient->iWin->BaseWin()->PointerFilter(EPointerMoveEvents,0); + iQueueClient->iWs.Flush(); + SimulatePointer(TRawEvent::EButton1Down,20,10); + SimulatePointer(TRawEvent::EButton1Up,20,10); + TheClient->iWs.Flush(); + iQueueClient->iWin->BaseWin()->PointerFilter(EPointerMoveEvents,EPointerGenerateSimulatedMove); + iQueueClient->iWs.Flush(); +#if !defined(TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA) + SimulateButton1DownWithSimulatedMove(21,11); +#else + SimulatePointer(TRawEvent::EButton1Down,21,11); +#endif + SimulatePointer(TRawEvent::EButton1Up,21,11); + TheClient->iWs.Flush(); + iQueueClient->iWin->BaseWin()->PointerFilter(EPointerMoveEvents,EPointerMoveEvents); + iQueueClient->iWs.Flush(); + SimulatePointer(TRawEvent::EButton1Down,22,12); + SimulatePointer(TRawEvent::EButton1Up,22,12); + TheClient->iWs.Flush(); + iQueueClient->iWin->BaseWin()->PointerFilter(EPointerMoveEvents,EPointerGenerateSimulatedMove); + iQueueClient->iWs.Flush(); +#if !defined(TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA) + SimulateButton1DownWithSimulatedMove(23,13); +#else + SimulatePointer(TRawEvent::EButton1Down,23,13); +#endif + SimulatePointer(TRawEvent::EButton1Up,23,13); + TheClient->iWs.Flush(); + iQueueClient->iWin->BaseWin()->PointerFilter(EPointerMoveEvents,EPointerFilterMove); + iQueueClient->iWs.Flush(); + SimulatePointer(TRawEvent::EButton1Down,24,14); + SimulatePointer(TRawEvent::EButton1Up,24,14); + AddExpectedEvent(EEventFocusGained); + AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(45-EWinPositionX,30-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(45-EWinPositionX,30-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EMove, TPoint(46-EWinPositionX,31-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(46-EWinPositionX,31-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(46-EWinPositionX,31-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(20-EWinPositionX,10-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(20-EWinPositionX,10-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EMove, TPoint(21-EWinPositionX,11-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(21-EWinPositionX,11-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(21-EWinPositionX,11-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(22-EWinPositionX,12-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(22-EWinPositionX,12-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EMove, TPoint(23-EWinPositionX,13-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(23-EWinPositionX,13-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(23-EWinPositionX,13-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(24-EWinPositionX,14-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(24-EWinPositionX,14-EWinPositionY)); + break; + #if defined(__WINS__) + case 1: + { + RWindowGroup *group=iQueueClient->iGroup->GroupWin(); + group->SetOrdinalPosition(0); + iTest->SimulateKey(TRawEvent::EKeyDown,'2'|TOP16A); + iTest->SimulateKey(TRawEvent::EKeyUp,'2'); + TheClient->iWs.Flush(); + iQueueClient->iWs.SetRemoveKeyCode(EFalse); + iQueueClient->iWs.Flush(); + iTest->SimulateKey(TRawEvent::EKeyDown,'3'|TOP16B); + iTest->SimulateKey(TRawEvent::EKeyUp,'3'); + TheClient->iWs.Flush(); + iQueueClient->iWs.SetRemoveKeyCode(ETrue); + iQueueClient->iWs.Flush(); + iTest->SimulateKey(TRawEvent::EKeyDown,'4'|TOP16B); + iTest->SimulateKey(TRawEvent::EKeyUp,'4'); + AddExpectedKey(EEventKeyDown,'2'); + AddExpectedKey(EEventKey,'2',TOP16A>>16); + AddExpectedKey(EEventKeyUp,'2'); + AddExpectedKey(EEventKeyDown,'3'|TOP16B); + AddExpectedKey(EEventKey,'3',TOP16B>>16); + AddExpectedKey(EEventKeyUp,'3'); + AddExpectedKey(EEventKeyDown,'4'); + AddExpectedKey(EEventKey,'4',TOP16B>>16); + AddExpectedKey(EEventKeyUp,'4'); + break; + } + #endif + default: + CActiveScheduler::Stop(); + break; + } + TheClient->iWs.Flush(); + } + +void CTEventTest::WinCap_NextSetOfEvents() + { + switch(iEventSet++) + { + case 0: + //iQueueClient->SetChildCapture(RWindowBase::TCaptureEnabled); + SimulatePointer(TRawEvent::EButton1Down,35,27); + SimulatePointer(TRawEvent::EButton1Up,25,12); + + + AddExpectedEvent(EEventFocusGained); + AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(35-EWinPositionX,27-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(25-EWinPositionX,12-EWinPositionY)); + break; + + + default: + CActiveScheduler::Stop(); + break; + } + TheClient->iWs.Flush(); + } + +void CTEventTest::XyInputType_NextSetOfEvents() + { + switch(iEventSet++) + { + case 0: + iQueueClient->iWin->BaseWin()->PointerFilter(EPointerMoveEvents|EPointerFilterDrag,EPointerGenerateSimulatedMove); + iQueueClient->iWs.Flush(); +#if !defined(TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA) + SimulateButton1DownWithSimulatedMove(46,31); +#else + SimulatePointer(TRawEvent::EButton1Down,46,31); +#endif + SimulatePointer(TRawEvent::EButton1Up,46,31); + AddExpectedEvent(EEventFocusGained); + AddExpectedPointer(TPointerEvent::EMove, TPoint(46-EWinPositionX,31-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(46-EWinPositionX,31-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(46-EWinPositionX,31-EWinPositionY)); + break; //Must do something + case 1: + { + // check if RWindowGroup::SimulatePointerEvent is working (DEF131563) + RWindowGroup& group = *iQueueClient->iGroup->GroupWin(); + TRawEvent event; + event.Set(TRawEvent::EButton1Down, 10, 10); + group.SimulatePointerEvent(event); + event.Set(TRawEvent::EButton1Up, 10, 10); + group.SimulatePointerEvent(event); + if(!iIs3DPointer) + { + // simulated move will be generated + AddExpectedPointer(TPointerEvent::EMove, TPoint(10 - EWinPositionX, 10 - EWinPositionY)); + } + AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(10 - EWinPositionX, 10 - EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(10 - EWinPositionX, 10 - EWinPositionY)); + } + break; + #if defined(__WINS__) + case 2: +#if !defined(TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA) + SimulateButton1DownWithSimulatedMove(45,32); +#else + SimulatePointer(TRawEvent::EButton1Down,45,32); +#endif + SimulatePointer(TRawEvent::EButton1Up,45,32); + TheClient->iWs.SimulateXyInputType(EXYInputNone); + SimulatePointer(TRawEvent::EButton1Down,44,32); + SimulatePointer(TRawEvent::EPointerMove,43,32); + SimulatePointer(TRawEvent::EButton1Up,43,31); + SimulatePointer(TRawEvent::EButton2Down,44,33); + SimulatePointer(TRawEvent::EButton2Up,44,33); + SimulatePointer(TRawEvent::EButton3Down,43,32); + SimulatePointer(TRawEvent::EButton3Up,43,32); + SimulatePointer(TRawEvent::EPointerSwitchOn,48,32); + TheClient->iWs.SimulateXyInputType(EXYInputPointer); +#if !defined(TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA) + SimulateButton1DownWithSimulatedMove(47,32); +#else + SimulatePointer(TRawEvent::EButton1Down,47,32); +#endif + SimulatePointer(TRawEvent::EButton1Up,47,32); + AddExpectedPointer(TPointerEvent::EMove, TPoint(45-EWinPositionX,32-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(45-EWinPositionX,32-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(45-EWinPositionX,32-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EMove, TPoint(47-EWinPositionX,32-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(47-EWinPositionX,32-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(47-EWinPositionX,32-EWinPositionY)); + break; + case 3: + iQueueClient->iWin->BaseWin()->PointerFilter(EPointerGenerateSimulatedMove,0); + iQueueClient->iWs.Flush(); + TheClient->iWs.SimulateXyInputType(EXYInputPointer); + SimulatePointer(TRawEvent::EButton1Down,49,32); + SimulatePointer(TRawEvent::EPointerMove,50,30); + SimulatePointer(TRawEvent::EButton1Up,50,30); + SimulatePointer(TRawEvent::EButton1Down,51,32); + SimulatePointer(TRawEvent::EPointerMove,52,30); + SimulatePointer(TRawEvent::EButton1Up,52,30); + TheClient->iWs.SimulateXyInputType(EXYInputPointer); + AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(49-EWinPositionX,32-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EDrag, TPoint(50-EWinPositionX,30-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(50-EWinPositionX,30-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(51-EWinPositionX,32-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EDrag, TPoint(52-EWinPositionX,30-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(52-EWinPositionX,30-EWinPositionY)); + break; + case 4: + SimulatePointer(TRawEvent::EButton1Down,49,31); + SimulatePointer(TRawEvent::EButton1Up,49,31); + TheClient->iWs.SimulateXyInputType(EXYInputMouse); + SimulatePointer(TRawEvent::EPointerMove,50,31); + SimulatePointer(TRawEvent::EButton1Down,50,31); + SimulatePointer(TRawEvent::EPointerMove,50,30); + SimulatePointer(TRawEvent::EButton1Up,50,30); + SimulatePointer(TRawEvent::EPointerMove,51,31); + SimulatePointer(TRawEvent::EButton1Down,51,31); + SimulatePointer(TRawEvent::EPointerMove,51,30); + SimulatePointer(TRawEvent::EButton1Up,51,30); + TheClient->iWs.SimulateXyInputType(EXYInputPointer); + SimulatePointer(TRawEvent::EButton1Down,52,31); + SimulatePointer(TRawEvent::EButton1Up,52,31); + AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(49-EWinPositionX,31-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(49-EWinPositionX,31-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EMove, TPoint(50-EWinPositionX,31-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(50-EWinPositionX,31-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EDrag, TPoint(50-EWinPositionX,30-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(50-EWinPositionX,30-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EMove, TPoint(51-EWinPositionX,31-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(51-EWinPositionX,31-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EDrag, TPoint(51-EWinPositionX,30-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(51-EWinPositionX,30-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(52-EWinPositionX,31-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(52-EWinPositionX,31-EWinPositionY)); + break; + case 5: + SimulatePointer(TRawEvent::EButton1Down,69,31); + SimulatePointer(TRawEvent::EButton1Up,69,31); + TheClient->iWs.SimulateXyInputType(EXYInputDeltaMouse); + SimulatePointer(TRawEvent::EPointerMove,-5,-5); + SimulatePointer(TRawEvent::EButton1Down,7,8); + SimulatePointer(TRawEvent::EPointerMove,10,-3); + SimulatePointer(TRawEvent::EButton1Up,-7,-8); + SimulatePointer(TRawEvent::EPointerMove,-4,9); + SimulatePointer(TRawEvent::EButton1Down,123,456); + SimulatePointer(TRawEvent::EPointerMove,15,13); + SimulatePointer(TRawEvent::EButton1Up,-2345,-6789); + TheClient->iWs.SimulateXyInputType(EXYInputPointer); + SimulatePointer(TRawEvent::EButton1Down,62,31); + SimulatePointer(TRawEvent::EButton1Up,62,31); + AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(69-EWinPositionX,31-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(69-EWinPositionX,31-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EMove, TPoint(64-EWinPositionX,26-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(64-EWinPositionX,26-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EDrag, TPoint(74-EWinPositionX,23-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(74-EWinPositionX,23-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EMove, TPoint(70-EWinPositionX,32-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(70-EWinPositionX,32-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EDrag, TPoint(85-EWinPositionX,45-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(85-EWinPositionX,45-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(62-EWinPositionX,31-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(62-EWinPositionX,31-EWinPositionY)); + break; + #endif + default: + CActiveScheduler::Stop(); + break; + } + TheClient->iWs.Flush(); + } + +void CTEventTest::MovingPointerCursor_NextSetOfEventsL() + { + switch(iEventSet++) + { + case 0: + iQueueClient->iWin->BaseWin()->PointerFilter(EPointerFilterMove|EPointerFilterDrag,0); + iQueueClient->iWin->BaseWin()->SetPointerGrab(EFalse); + iQueueClient->iChildWin->BaseWin()->PointerFilter(EPointerFilterMove|EPointerFilterDrag,0); + iQueueClient->iChildWin->BaseWin()->SetPointerGrab(EFalse); + iQueueClient->iWs.Flush(); + //AddExpectedEvent(EEventFocusGained); + break; + #if defined(__WINS__) + case 1: + TheClient->iWs.SimulateXyInputType(EXYInputMouse); + iQueueClient->iChildWin->BaseWin()->PointerFilter(EPointerFilterMove|EPointerFilterDrag,0); + iQueueClient->iWin->BaseWin()->PointerFilter(EPointerFilterMove|EPointerFilterDrag,0); + iQueueClient->iWin->BaseWin()->SetPointerGrab(EFalse); + iQueueClient->iChildWin->BaseWin()->SetPointerGrab(EFalse); + iQueueClient->iWs.Flush(); + SimulatePointer(TRawEvent::EPointerMove,46,31); + SimulatePointer(TRawEvent::EButton1Down,46,31); + SimulatePointer(TRawEvent::EPointerMove,47,32); + SimulatePointer(TRawEvent::EButton1Up,47,32); + AddExpectedPointer(TPointerEvent::EMove, TPoint(46-EWinPositionX,31-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(46-EWinPositionX,31-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EDrag, TPoint(47-EWinPositionX,32-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(47-EWinPositionX,32-EWinPositionY)); + break; + case 2: + TheClient->iWs.SimulateXyInputType(EXYInputDeltaMouse); + TheClient->iWs.SetPointerCursorPosition(TPoint(62,24)); + SimulatePointer(TRawEvent::EPointerMove,-5,-5); + TheClient->iWs.SetPointerCursorPosition(TPoint(60,20)); + SimulatePointer(TRawEvent::EPointerMove,6,7); + SimulatePointer(TRawEvent::EButton1Down,27,38); + SimulatePointer(TRawEvent::EPointerMove,0,0); + TheClient->iWs.SetPointerCursorPosition(TPoint(55,25)); + SimulatePointer(TRawEvent::EPointerMove,4,-13); + TheClient->iWs.SetPointerCursorPosition(TPoint(58,20)); + SimulatePointer(TRawEvent::EButton1Up,45,-678); + TheClient->iWs.Flush(); + iQueueClient->iWin->BaseWin()->PointerFilter(EPointerFilterEnterExit,0); + iQueueClient->iChildWin->BaseWin()->PointerFilter(EPointerFilterEnterExit,0); + iQueueClient->iWs.Flush(); + TheClient->iWs.SetPointerCursorPosition(TPoint(80,45)); + TheClient->iWs.SimulateXyInputType(EXYInputPointer); + AddExpectedPointer(TPointerEvent::EMove, TPoint(57-EWinPositionX,19-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EMove, TPoint(66-EWinPositionX,27-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(66-EWinPositionX,27-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EDrag, TPoint(66-EWinPositionX,27-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EDrag, TPoint(59-EWinPositionX,12-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(58-EWinPositionX,20-EWinPositionY)); + AddExpectedEnterExit(EEventPointerEnter, TPoint(58-EWinPositionX,20-EWinPositionY)); + AddExpectedEnterExit(EEventPointerExit, TPoint(58-EWinPositionX,20-EWinPositionY)); + AddExpectedEnterExit(EEventPointerEnter, TPoint(80-EWinPositionX,45-EWinPositionY)); + break; + case 3: + iQueueClient->iWin->BaseWin()->PointerFilter(EPointerFilterEnterExit,EPointerFilterEnterExit); + iQueueClient->iChildWin->BaseWin()->PointerFilter(EPointerFilterEnterExit,EPointerFilterEnterExit); + iQueueClient->iWs.Flush(); + TheClient->iWs.SetPointerCursorArea(TRect(0,0,70,240)); + TheClient->iWs.SimulateXyInputType(EXYInputDeltaMouse); + TheClient->iWs.SetPointerCursorPosition(TPoint(65,30)); + SimulatePointer(TRawEvent::EPointerMove,20,0); + TheClient->iWs.SetPointerCursorPosition(TPoint(75,32)); + SimulatePointer(TRawEvent::EPointerMove,-1,20); + SimulatePointer(TRawEvent::EButton1Down,29,37); + SimulatePointer(TRawEvent::EPointerMove,25,-13); + SimulatePointer(TRawEvent::EButton1Up,47,-648); + TheClient->iWs.SimulateXyInputType(EXYInputPointer); + AddExpectedPointer(TPointerEvent::EMove, TPoint(69-EWinPositionX,30-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EMove, TPoint(68-EWinPositionX,52-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(68-EWinPositionX,52-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EDrag, TPoint(69-EWinPositionX,39-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(69-EWinPositionX,39-EWinPositionY)); + break; + case 4: + TheClient->iWs.SetPointerCursorArea(TRect(EWinPositionX+2,EWinPositionY+2,EWinPositionX+99,EWinPositionY+49)); + TheClient->iWs.SimulateXyInputType(EXYInputDeltaMouse); + TheClient->iWs.SetPointerCursorPosition(TPoint(56,30)); + SimulatePointer(TRawEvent::EPointerMove,0,-34); + TheClient->iWs.SetPointerCursorPosition(TPoint(56,30)); + SimulatePointer(TRawEvent::EPointerMove,0,0); + SimulatePointer(TRawEvent::EPointerMove,-77,-35); + TheClient->iWs.SetPointerCursorPosition(TPoint(56,30)); + SimulatePointer(TRawEvent::EPointerMove,0,0); + SimulatePointer(TRawEvent::EPointerMove,-78,0); + TheClient->iWs.SetPointerCursorPosition(TPoint(56,30)); + SimulatePointer(TRawEvent::EPointerMove,0,0); + SimulatePointer(TRawEvent::EPointerMove,-79,36); + TheClient->iWs.SetPointerCursorPosition(TPoint(56,30)); + SimulatePointer(TRawEvent::EPointerMove,0,0); + SimulatePointer(TRawEvent::EPointerMove,0,37); + TheClient->iWs.SetPointerCursorPosition(TPoint(56,30)); + SimulatePointer(TRawEvent::EPointerMove,0,0); + SimulatePointer(TRawEvent::EPointerMove,80,38); + TheClient->iWs.SetPointerCursorPosition(TPoint(56,30)); + SimulatePointer(TRawEvent::EPointerMove,0,0); + SimulatePointer(TRawEvent::EPointerMove,81,0); + TheClient->iWs.SetPointerCursorPosition(TPoint(56,30)); + SimulatePointer(TRawEvent::EPointerMove,0,0); + SimulatePointer(TRawEvent::EPointerMove,82,-39); + TheClient->iWs.SetPointerCursorPosition(TPoint(2,2)); + SimulatePointer(TRawEvent::EPointerMove,30,30); + TheClient->iWs.SetPointerCursorPosition(TPoint(1,30)); + SimulatePointer(TRawEvent::EPointerMove,1,0); + TheClient->iWs.SetPointerCursorPosition(TPoint(2,88)); + SimulatePointer(TRawEvent::EPointerMove,30,-30); + TheClient->iWs.SetPointerCursorPosition(TPoint(56,88)); + SimulatePointer(TRawEvent::EPointerMove,0,-1); + TheClient->iWs.SetPointerCursorPosition(TPoint(123,88)); + SimulatePointer(TRawEvent::EPointerMove,-30,-30); + TheClient->iWs.SetPointerCursorPosition(TPoint(123,30)); + SimulatePointer(TRawEvent::EPointerMove,-1,0); + TheClient->iWs.SetPointerCursorPosition(TPoint(123,2)); + SimulatePointer(TRawEvent::EPointerMove,-30,30); + TheClient->iWs.SetPointerCursorPosition(TPoint(56,1)); + SimulatePointer(TRawEvent::EPointerMove,0,1); + TheClient->iWs.SimulateXyInputType(EXYInputPointer); + AddExpectedPointer(TPointerEvent::EMove, TPoint(56-EWinPositionX,2)); + AddExpectedPointer(TPointerEvent::EMove, TPoint(56-EWinPositionX,30-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EMove, TPoint(2,2)); + AddExpectedPointer(TPointerEvent::EMove, TPoint(56-EWinPositionX,30-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EMove, TPoint(2,30-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EMove, TPoint(56-EWinPositionX,30-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EMove, TPoint(2,48)); + AddExpectedPointer(TPointerEvent::EMove, TPoint(56-EWinPositionX,30-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EMove, TPoint(56-EWinPositionX,48)); + AddExpectedPointer(TPointerEvent::EMove, TPoint(56-EWinPositionX,30-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EMove, TPoint(98,48)); + AddExpectedPointer(TPointerEvent::EMove, TPoint(56-EWinPositionX,30-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EMove, TPoint(98,30-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EMove, TPoint(56-EWinPositionX,30-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EMove, TPoint(98,2)); + AddExpectedPointer(TPointerEvent::EMove, TPoint(32,32)); + AddExpectedPointer(TPointerEvent::EMove, TPoint(3,30-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EMove, TPoint(32,18)); + AddExpectedPointer(TPointerEvent::EMove, TPoint(56-EWinPositionX,47)); + AddExpectedPointer(TPointerEvent::EMove, TPoint(68,18)); + AddExpectedPointer(TPointerEvent::EMove, TPoint(97,30-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EMove, TPoint(68,32)); + AddExpectedPointer(TPointerEvent::EMove, TPoint(56-EWinPositionX,3)); + break; + case 5: + TheClient->iWs.SetPointerCursorArea(TRect(0,0,EWinPositionX+100,EWinPositionY+50)); + TheClient->iWs.SimulateXyInputType(EXYInputDeltaMouse); + TheClient->iWs.SetPointerCursorPosition(TPoint(57,31)); + TheClient->iWs.SetPointerCursorArea(TRect(0,35,EWinPositionX+100,EWinPositionY+50)); + SimulatePointer(TRawEvent::EPointerMove,1,0); + TheClient->iWs.SetPointerCursorPosition(TPoint(10,55)); + TheClient->iWs.SetPointerCursorArea(TRect(15,0,EWinPositionX+100,50)); + SimulatePointer(TRawEvent::EPointerMove,1,1); + TheClient->iWs.SetPointerCursorPosition(TPoint(57,31)); + TheClient->iWs.SetPointerCursorArea(TRect(0,0,50,EWinPositionY+50)); + SimulatePointer(TRawEvent::EPointerMove,0,1); + TheClient->iWs.SetPointerCursorPosition(TPoint(10,10)); + TheClient->iWs.SetPointerCursorArea(TRect(15,15,EWinPositionX+100,EWinPositionY+50)); + SimulatePointer(TRawEvent::EPointerMove,1,-1); + TheClient->iWs.SetPointerCursorPosition(TPoint(57,31)); + TheClient->iWs.SetPointerCursorArea(TRect(0,0,EWinPositionX+100,30)); + SimulatePointer(TRawEvent::EPointerMove,-1,0); + TheClient->iWs.SetPointerCursorPosition(TPoint(100,10)); + TheClient->iWs.SetPointerCursorArea(TRect(0,15,95,EWinPositionY+50)); + SimulatePointer(TRawEvent::EPointerMove,-1,-1); + TheClient->iWs.SetPointerCursorPosition(TPoint(57,31)); + TheClient->iWs.SetPointerCursorArea(TRect(60,0,EWinPositionX+100,EWinPositionY+50)); + SimulatePointer(TRawEvent::EPointerMove,0,-1); + TheClient->iWs.SetPointerCursorPosition(TPoint(100,55)); + TheClient->iWs.SetPointerCursorArea(TRect(0,0,95,50)); + SimulatePointer(TRawEvent::EPointerMove,1,-1); + TheClient->iWs.SimulateXyInputType(EXYInputPointer); + AddExpectedPointer(TPointerEvent::EMove, TPoint(58-EWinPositionX,35-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EMove, TPoint(16-EWinPositionX,49-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EMove, TPoint(49-EWinPositionX,32-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EMove, TPoint(16-EWinPositionX,15-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EMove, TPoint(56-EWinPositionX,29-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EMove, TPoint(93-EWinPositionX,15-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EMove, TPoint(60-EWinPositionX,30-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EMove, TPoint(94-EWinPositionX,48-EWinPositionY)); + break; + #endif + default: + TheClient->iWs.SetPointerCursorArea(TRect(0,0,95,50)); + CActiveScheduler::Stop(); + break; + } + TheClient->iWs.Flush(); + } + +void CTEventTest::RotatedMode_NextSetOfEventsL() + { +#if defined(LOGGING) + TLogMessageText logMessageText; + _LIT(KSet,"RotatedMode SetOfEvents: %d Max=4"); + logMessageText.Format(KSet,iEventSet); + INFO_PRINTF1(logMessageText); +#endif + switch(iEventSet++) + { + case 0: + { + iQueueClient->iWin->BaseWin()->PointerFilter(EPointerFilterMove|EPointerFilterDrag,0); + iQueueClient->iWin->BaseWin()->SetPointerGrab(EFalse); + iQueueClient->iWs.Flush(); + TheClient->iWs.SetPointerCursorArea(TRect(10,10,51,51)); + SimulatePointer(TRawEvent::EButton1Down,5,5); + SimulatePointer(TRawEvent::EButton1Up,25,5); + SimulatePointer(TRawEvent::EButton1Down,55,5); + SimulatePointer(TRawEvent::EButton1Up,55,35); + SimulatePointer(TRawEvent::EButton1Down,55,55); + SimulatePointer(TRawEvent::EButton1Up,25,55); + SimulatePointer(TRawEvent::EButton1Down,5,55); + SimulatePointer(TRawEvent::EButton1Up,5,35); + AddExpectedEvent(EEventFocusGained); + AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(10-EWinPositionX,10-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(25-EWinPositionX,10-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(50-EWinPositionX,10-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(50-EWinPositionX,35-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(50-EWinPositionX,50-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(25-EWinPositionX,50-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(10-EWinPositionX,50-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(10-EWinPositionX,35-EWinPositionY)); + } + break; + case 1: + { + TInt enforc=TheClient->iScreen->ScreenModeEnforcement(); + iBlankWin->SetVisible(ETrue); + #if defined(LOGGING) + _LIT(KSet1,"AUTO Rotating Events :1st "); + INFO_PRINTF1(KSet1); + #endif + INFO_PRINTF1(_L(" Set of Events")); + if (iScreenModeTests&EDoRot90) + { + TheClient->iScreen->SetScreenMode(1); + TheClient->iWs.Flush(); + iTest->DelayIfFullRomL(); + INFO_PRINTF1(_L(" Screen mode 1.")); + TPoint screenModeOrigin=TheClient->iScreen->GetDefaultScreenModeOrigin(); + #if defined(__WINS__) + iTest->SimulatePointer(TRawEvent::EButton1Down,20+screenModeOrigin.iX,20+screenModeOrigin.iY); + iTest->SimulatePointer(TRawEvent::EButton1Up,20+screenModeOrigin.iX,20+screenModeOrigin.iY); + #else + // simulate pointer at (20,20) on rotated screen by providing physical coordinates + iTest->SimulatePointer(TRawEvent::EButton1Down,iPhysicalScreenSize.iWidth-1-20+screenModeOrigin.iX,20+screenModeOrigin.iY); + iTest->SimulatePointer(TRawEvent::EButton1Up,iPhysicalScreenSize.iWidth-1-20+screenModeOrigin.iX,20+screenModeOrigin.iY); + #endif + INFO_PRINTF1(_L(" Sent Up and Down 90")); + } + if (iScreenModeTests&EDoRot180) + { + TheClient->iScreen->SetCurrentRotations(0,CFbsBitGc::EGraphicsOrientationRotated180); + TheClient->iScreen->SetScreenMode(0); + INFO_PRINTF1(_L(" Screen mode 0")); + TheClient->iWs.Flush(); + iTest->DelayIfFullRomL(); + INFO_PRINTF1(_L(" Upside Down")); + #if defined(__WINS__) + iTest->SimulatePointer(TRawEvent::EButton1Down,22,22); + iTest->SimulatePointer(TRawEvent::EButton1Up,22,22); + #else + // simulate pointer at (22,22) on rotated screen by providing physical coordinates + iTest->SimulatePointer(TRawEvent::EButton1Down,iPhysicalScreenSize.iWidth-1-22,iPhysicalScreenSize.iHeight-1-22); + iTest->SimulatePointer(TRawEvent::EButton1Up,iPhysicalScreenSize.iWidth-1-22,iPhysicalScreenSize.iHeight-1-22); + #endif + INFO_PRINTF1(_L(" Sent Up and Down 180")); + } + TheClient->iScreen->SetCurrentRotations(0,CFbsBitGc::EGraphicsOrientationNormal); + TheClient->iScreen->SetScreenMode(0); + TheClient->iWs.Flush(); + iTest->DelayIfFullRomL(); + INFO_PRINTF1(_L(" Normal Screen mode")); + if (iScreenModeTests&EDoRot0) + { + SimulatePointer(TRawEvent::EButton1Down,24,24); + SimulatePointer(TRawEvent::EButton1Up,24,24); + } + if (iScreenModeTests&EDoRot90) + { + if (enforc>ESizeEnforcementNone) + { + AddExpectedEvent(EEventFocusLost); + AddExpectedEvent(EEventFocusGained); + } + else + { + AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(20-EWinPositionX,20-EWinPositionY-iYOffset)); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(20-EWinPositionX,20-EWinPositionY-iYOffset)); + } + } + if (iScreenModeTests&EDoRot180) + { + AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(22-EWinPositionX,22-EWinPositionY-iYOffset)); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(22-EWinPositionX,22-EWinPositionY-iYOffset)); + } + if (iScreenModeTests&EDoRot0) + { + AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(24-EWinPositionX,24-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(24-EWinPositionX,24-EWinPositionY)); + } + INFO_PRINTF1(_L(" Added Expected")); + User::After(EPointerCursorUpdateGap); + iBlankWin->SetVisible(EFalse); + } + break; + #if defined(__WINS__) + case 2: + { + TInt enforc=TheClient->iScreen->ScreenModeEnforcement(); + //INFO_PRINTF1("AUTO Rotating Events "); + //INFO_PRINTF1(" :2nd Set of Events"); + TheClient->iWs.SimulateXyInputType(EXYInputDeltaMouse); + TheClient->iWs.SetPointerCursorPosition(TPoint(24+EWinPositionX,24+EWinPositionY)); + if (iScreenModeTests&EDoRot90) + { + TheClient->iScreen->SetScreenMode(1); + TheClient->iWs.Flush(); + iTest->DelayIfFullRomL(); + SimulatePointer(TRawEvent::EPointerMove,1,2); + SimulatePointer(TRawEvent::EButton1Down,56,89); + SimulatePointer(TRawEvent::EPointerMove,2,-1); + SimulatePointer(TRawEvent::EButton1Up,234,456); + } + else + TheClient->iWs.SetPointerCursorPosition(TPoint(27+EWinPositionX,25+EWinPositionY)); + if (iScreenModeTests&EDoRot180) + { + TheClient->iScreen->SetCurrentRotations(0,CFbsBitGc::EGraphicsOrientationRotated180); + TheClient->iScreen->SetScreenMode(0); + TheClient->iWs.Flush(); + iTest->DelayIfFullRomL(); + SimulatePointer(TRawEvent::EPointerMove,-3,4); + SimulatePointer(TRawEvent::EButton1Down,156,289); + SimulatePointer(TRawEvent::EPointerMove,-4,-3); + SimulatePointer(TRawEvent::EButton1Up,2234,3456); + } + else + TheClient->iWs.SetPointerCursorPosition(TPoint(20+EWinPositionX,26+EWinPositionY)); + TheClient->iScreen->SetCurrentRotations(0,CFbsBitGc::EGraphicsOrientationNormal); + TheClient->iScreen->SetScreenMode(0); + TheClient->iWs.Flush(); + iTest->DelayIfFullRomL(); + if (iScreenModeTests&EDoRot0) + { + SimulatePointer(TRawEvent::EButton1Down,24,24); + SimulatePointer(TRawEvent::EButton1Up,24,24); + } + TheClient->iWs.SimulateXyInputType(EXYInputPointer); + TheClient->iWs.Flush(); + if (iScreenModeTests&EDoRot90) + { + if (enforc>ESizeEnforcementNone) + { + AddExpectedEvent(EEventFocusLost); + AddExpectedEvent(EEventFocusGained); + } + else + { + AddExpectedPointer(TPointerEvent::EMove, TPoint(25,26)); + AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(25,26)); + AddExpectedPointer(TPointerEvent::EDrag, TPoint(27,25)); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(27,25)); + } + } + if (iScreenModeTests&EDoRot180) + { + AddExpectedPointer(TPointerEvent::EMove, TPoint(24,29)); + AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(24,29)); + AddExpectedPointer(TPointerEvent::EDrag, TPoint(20,26)); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(20,26)); + } + if (iScreenModeTests&EDoRot0) + { + AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(20,26)); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(20,26)); + } + } + break; + case 3: + { + #if defined(LOGGING) + _LIT(KSet2,"AUTO Rotating Events "); + INFO_PRINTF1(KSet2); + #endif + INFO_PRINTF1(_L(" :3rd Set of Events")); + if (iScreenModeTests&EDoScale) + { + INFO_PRINTF1(_L(" :Screen Scalling Supported")); + iBlankWin->SetVisible(ETrue); + iCurrentMode=iNumScrModes; + --iCurrentMode; + iTheClientFlush=TheClient->iWs.SetAutoFlush(ETrue); + iQuequeClientFlush=iQueueClient->iWs.SetAutoFlush(ETrue); + iQueueClient->iScreen->SetScreenMode(iCurrentMode); + TheClient->iScreen->SetAppScreenMode(iCurrentMode); + iQueueClient->iScreen->SetAppScreenMode(iCurrentMode); + iSizeMode=iQueueClient->iScreen->GetCurrentScreenModeAttributes(); + TSizeMode testMode=iSizeMode; + for (TInt xScale=2;xScale<4;xScale++) + { + INFO_PRINTF1(_L(" :New X-Scale Value")); + for (TInt yScale=2;yScale<4;yScale++) + { + INFO_PRINTF1(_L(" :New Y-Scale Value")); + testMode.iScreenScale.SetSize(xScale,yScale); + CheckPointerCursorInDifferentScreenMode(testMode,TPoint(20,30)); + } + } + User::After(EPointerCursorUpdateGap); + iBlankWin->SetVisible(EFalse); + break; + } + } + case 4: + { + if (iScreenModeTests&EDoScale) + { + TSizeMode testMode=iSizeMode; + iBlankWin->SetVisible(ETrue); + for (TInt xScale=2;xScale<4;xScale++) + { + for (TInt yScale=2;yScale<4;yScale++) + { + testMode.iScreenScale.SetSize(xScale,yScale); + CheckPointerCursorInDifferentScreenMode(testMode,TPoint(30,20)); + } + } + User::After(EPointerCursorUpdateGap); + iBlankWin->SetVisible(EFalse); + break; + } + } + #endif + default: + #if defined(__WINS__) + if (iScreenModeTests&EDoScale) + { + iQueueClient->iScreen->SetScreenMode(iCurrentMode); + iQueueClient->iScreen->SetCurrentScreenModeAttributes(iSizeMode); + iQueueClient->iScreen->SetAppScreenMode(0); + TheClient->iScreen->SetAppScreenMode(0); + iQueueClient->iScreen->SetScreenMode(0); + iBlankWin->SetVisible(EFalse); + TheClient->iWs.SetAutoFlush(iTheClientFlush); + iQueueClient->iWs.SetAutoFlush(iQuequeClientFlush); + } + #endif + User::After(500000); //0.5secs, to allow other screen devices to respond to the flip events + CActiveScheduler::Stop(); + break; + } + TheClient->iWs.Flush(); + } + + +void CTEventTest::ScreenScaling_NextSetOfEventsL() + { +#if defined(LOGGING) + TLogMessageText logMessageText; + _LIT(KSet,"ScreenScaling SetOfEvents: %d (Last=3)"); + logMessageText.Format(KSet,iEventSet); + INFO_PRINTF1(logMessageText); +#endif + if(! (iScreenModeTests & EDoScale)) + { + User::After(500000); + CActiveScheduler::Stop(); + return; + } + switch(iEventSet++) + { + case 0: + { + iTheClientFlush=TheClient->iWs.SetAutoFlush(ETrue); + iQuequeClientFlush=iQueueClient->iWs.SetAutoFlush(ETrue); + iBlankWin->SetVisible(ETrue); + + TInt mode = TheClient->iScreen->CurrentScreenMode(); + + iSizeMode = iQueueClient->iScreen->GetCurrentScreenModeAttributes(); + + iQueueClient->iWin->BaseWin()->PointerFilter(EPointerFilterMove|EPointerFilterDrag,0); + iQueueClient->iWin->BaseWin()->SetPointerGrab(EFalse); + + TSizeMode szMode2 = iSizeMode; + + szMode2.iScreenScale.SetSize(2,2); + + iQueueClient->iScreen->SetCurrentScreenModeAttributes(szMode2); + TheClient->iScreen->SetAppScreenMode(mode); + iQueueClient->iScreen->SetAppScreenMode(mode); + iQueueClient->iScreen->SetScreenMode(mode); + + TPoint theScreenOrigin(iQueueClient->iScreen->GetScreenModeOrigin(mode)); + + SimulatePointer(TRawEvent::EButton1Down, + 20+theScreenOrigin.iX, 20+theScreenOrigin.iY); + SimulatePointer(TRawEvent::EButton1Up, + 20+theScreenOrigin.iX, 20+theScreenOrigin.iY); + iQueueClient->iScreen->SetCurrentScreenModeAttributes(iSizeMode); + TheClient->iScreen->SetAppScreenMode(mode); + iQueueClient->iScreen->SetAppScreenMode(mode); + iQueueClient->iScreen->SetScreenMode(mode); + + AddExpectedEvent(EEventFocusGained); + AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(10-EWinPositionX,10-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(10-EWinPositionX,10-EWinPositionY)); + + break; + } + case 1: + { + TSizeMode szMode2 = iSizeMode; + TInt mode = TheClient->iScreen->CurrentScreenMode(); + + szMode2.iScreenScale.SetSize(2,2); + szMode2.iOrigin.SetXY(20,20); + + iQueueClient->iScreen->SetCurrentScreenModeAttributes(szMode2); + TheClient->iScreen->SetAppScreenMode(mode); + iQueueClient->iScreen->SetAppScreenMode(mode); + iQueueClient->iScreen->SetScreenMode(mode); + + TPoint theScreenOrigin(iQueueClient->iScreen->GetDefaultScreenModeOrigin()); + + SimulatePointer(TRawEvent::EButton1Down, + 30+theScreenOrigin.iX, 30+theScreenOrigin.iY); + SimulatePointer(TRawEvent::EButton1Up, + 26+theScreenOrigin.iX, 20+theScreenOrigin.iY); + SimulatePointer(TRawEvent::EButton1Down, + 40+theScreenOrigin.iX, 60+theScreenOrigin.iY); + SimulatePointer(TRawEvent::EButton1Up, + 26+theScreenOrigin.iX, 20+theScreenOrigin.iY); + + AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(15-EWinPositionX,15-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(13-EWinPositionX,10-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(20-EWinPositionX,30-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(13-EWinPositionX,10-EWinPositionY)); + + iQueueClient->iScreen->SetCurrentScreenModeAttributes(iSizeMode); + TheClient->iScreen->SetAppScreenMode(mode); + iQueueClient->iScreen->SetAppScreenMode(mode); + iQueueClient->iScreen->SetScreenMode(mode); + + theScreenOrigin = TPoint(iQueueClient->iScreen->GetDefaultScreenModeOrigin()); + + SimulatePointer(TRawEvent::EButton1Down, + 30+theScreenOrigin.iX, 30+theScreenOrigin.iY); + SimulatePointer(TRawEvent::EButton1Up, + 26+theScreenOrigin.iX, 20+theScreenOrigin.iY); + SimulatePointer(TRawEvent::EButton1Down, + 40+theScreenOrigin.iX, 50+theScreenOrigin.iY); + SimulatePointer(TRawEvent::EButton1Up, + 26+theScreenOrigin.iX, 20+theScreenOrigin.iY); + + AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(30-EWinPositionX,30-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(26-EWinPositionX,20-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(40-EWinPositionX,50-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(26-EWinPositionX,20-EWinPositionY)); + break; + } + case 2: + { + TInt mode = TheClient->iScreen->CurrentScreenMode(); + TRect theRect = TheClient->iWs.PointerCursorArea(); + + TSizeMode szMode2 = iSizeMode; + + //----------- scaling 2X2 + szMode2.iScreenScale.SetSize(2,2); + + iQueueClient->iScreen->SetCurrentScreenModeAttributes(szMode2); + iQueueClient->iWs.SetPointerCursorArea(mode, TRect(24,10,52,52)); + TheClient->iScreen->SetAppScreenMode(mode); + iQueueClient->iScreen->SetAppScreenMode(mode); + iQueueClient->iScreen->SetScreenMode(mode); + + + TPoint theScreenOrigin(iQueueClient->iScreen->GetDefaultScreenModeOrigin()); + + SimulatePointer(TRawEvent::EButton1Down, + 20+theScreenOrigin.iX, 20+theScreenOrigin.iY); + SimulatePointer(TRawEvent::EButton1Up, + 26+theScreenOrigin.iX, 20+theScreenOrigin.iY); + SimulatePointer(TRawEvent::EButton1Down, + 50+theScreenOrigin.iX, 30+theScreenOrigin.iY); + SimulatePointer(TRawEvent::EButton1Up, + 26+theScreenOrigin.iX, 20+theScreenOrigin.iY); + + AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(24-EWinPositionX,10-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(24-EWinPositionX,10-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(25-EWinPositionX,15-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(24-EWinPositionX,10-EWinPositionY)); + //------------------------ scaling 1X2 + szMode2.iScreenScale.SetSize(1,2); + + iQueueClient->iScreen->SetCurrentScreenModeAttributes(szMode2); + iQueueClient->iWs.SetPointerCursorArea(mode, TRect(24,10,52,52)); + TheClient->iScreen->SetAppScreenMode(mode); + iQueueClient->iScreen->SetAppScreenMode(mode); + iQueueClient->iScreen->SetScreenMode(mode); + + theScreenOrigin = TPoint(iQueueClient->iScreen->GetDefaultScreenModeOrigin()); + + SimulatePointer(TRawEvent::EButton1Down, + 20+theScreenOrigin.iX, 20+theScreenOrigin.iY); + SimulatePointer(TRawEvent::EButton1Up, + 26+theScreenOrigin.iX, 20+theScreenOrigin.iY); + SimulatePointer(TRawEvent::EButton1Down, + 50+theScreenOrigin.iX, 30+theScreenOrigin.iY); + SimulatePointer(TRawEvent::EButton1Up, + 26+theScreenOrigin.iX, 20+theScreenOrigin.iY); + + AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(24-EWinPositionX,10-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(26-EWinPositionX,10-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(50-EWinPositionX,15-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(26-EWinPositionX,10-EWinPositionY)); + //------------------------ scaling 2X1 + szMode2.iScreenScale.SetSize(2,1); + + iQueueClient->iScreen->SetCurrentScreenModeAttributes(szMode2); + iQueueClient->iWs.SetPointerCursorArea(mode, TRect(24,10,52,52)); + TheClient->iScreen->SetAppScreenMode(mode); + iQueueClient->iScreen->SetAppScreenMode(mode); + iQueueClient->iScreen->SetScreenMode(mode); + + theScreenOrigin = TPoint(iQueueClient->iScreen->GetDefaultScreenModeOrigin()); + + SimulatePointer(TRawEvent::EButton1Down, + 20+theScreenOrigin.iX, 20+theScreenOrigin.iY); + SimulatePointer(TRawEvent::EButton1Up, + 26+theScreenOrigin.iX, 20+theScreenOrigin.iY); + SimulatePointer(TRawEvent::EButton1Down, + 50+theScreenOrigin.iX, 30+theScreenOrigin.iY); + SimulatePointer(TRawEvent::EButton1Up, + 26+theScreenOrigin.iX, 20+theScreenOrigin.iY); + + AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(24-EWinPositionX,20-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(24-EWinPositionX,20-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(25-EWinPositionX,30-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(24-EWinPositionX,20-EWinPositionY)); + //------------------------ scaling 3X1 + + szMode2.iScreenScale.SetSize(3,1); + + iQueueClient->iScreen->SetCurrentScreenModeAttributes(szMode2); + iQueueClient->iWs.SetPointerCursorArea(mode, TRect(24,10,52,52)); + TheClient->iScreen->SetAppScreenMode(mode); + iQueueClient->iScreen->SetAppScreenMode(mode); + iQueueClient->iScreen->SetScreenMode(mode); + + theScreenOrigin = TPoint(iQueueClient->iScreen->GetDefaultScreenModeOrigin()); + + SimulatePointer(TRawEvent::EButton1Down, + 21+theScreenOrigin.iX, 20+theScreenOrigin.iY); + SimulatePointer(TRawEvent::EButton1Up, + 30+theScreenOrigin.iX, 20+theScreenOrigin.iY); + SimulatePointer(TRawEvent::EButton1Down, + 75+theScreenOrigin.iX, 30+theScreenOrigin.iY); + SimulatePointer(TRawEvent::EButton1Up, + 30+theScreenOrigin.iX, 20+theScreenOrigin.iY); + + AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(24-EWinPositionX,20-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(24-EWinPositionX,20-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(25-EWinPositionX,30-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(24-EWinPositionX,20-EWinPositionY)); + //------------------------ scaling 3X2 + + szMode2.iScreenScale.SetSize(3,2); + + iQueueClient->iScreen->SetCurrentScreenModeAttributes(szMode2); + iQueueClient->iWs.SetPointerCursorArea(mode, TRect(24,10,52,52)); + TheClient->iScreen->SetAppScreenMode(mode); + iQueueClient->iScreen->SetAppScreenMode(mode); + iQueueClient->iScreen->SetScreenMode(mode); + + theScreenOrigin = TPoint(iQueueClient->iScreen->GetDefaultScreenModeOrigin()); + + SimulatePointer(TRawEvent::EButton1Down, + 21+theScreenOrigin.iX, 20+theScreenOrigin.iY); + SimulatePointer(TRawEvent::EButton1Up, + 30+theScreenOrigin.iX, 20+theScreenOrigin.iY); + SimulatePointer(TRawEvent::EButton1Down, + 75+theScreenOrigin.iX, 30+theScreenOrigin.iY); + SimulatePointer(TRawEvent::EButton1Up, + 30+theScreenOrigin.iX, 20+theScreenOrigin.iY); + + AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(24-EWinPositionX,10-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(24-EWinPositionX,10-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(25-EWinPositionX,15-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(24-EWinPositionX,10-EWinPositionY)); + //------------------------ scaling 3X3 + szMode2.iScreenScale.SetSize(3,3); + + iQueueClient->iScreen->SetCurrentScreenModeAttributes(szMode2); + iQueueClient->iWs.SetPointerCursorArea(mode, TRect(24,10,52,52)); + TheClient->iScreen->SetAppScreenMode(mode); + iQueueClient->iScreen->SetAppScreenMode(mode); + iQueueClient->iScreen->SetScreenMode(mode); + + theScreenOrigin = TPoint(iQueueClient->iScreen->GetDefaultScreenModeOrigin()); + + SimulatePointer(TRawEvent::EButton1Down, + 21+theScreenOrigin.iX, 20+theScreenOrigin.iY); + SimulatePointer(TRawEvent::EButton1Up, + 30+theScreenOrigin.iX, 20+theScreenOrigin.iY); + SimulatePointer(TRawEvent::EButton1Down, + 75+theScreenOrigin.iX, 33+theScreenOrigin.iY); + SimulatePointer(TRawEvent::EButton1Up, + 30+theScreenOrigin.iX, 20+theScreenOrigin.iY); + + AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(24-EWinPositionX,10-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(24-EWinPositionX,10-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(25-EWinPositionX,11-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(24-EWinPositionX,10-EWinPositionY)); + //------------------------ + iQueueClient->iWs.SetPointerCursorArea(mode, theRect); + iQueueClient->iScreen->SetCurrentScreenModeAttributes(iSizeMode); + TheClient->iScreen->SetAppScreenMode(mode); + iQueueClient->iScreen->SetAppScreenMode(mode); + iQueueClient->iScreen->SetScreenMode(mode); + break; + } + case 3: + { + iQueueClient->iWs.SetAutoFlush(ETrue); + TInt theCurMode = iQueueClient->iScreen->CurrentScreenMode(); + TPoint theScreenOrigin; + if (iNumScrModes>2) + { + TheClient->iScreen->SetAppScreenMode(2); + iQueueClient->iScreen->SetAppScreenMode(2); + TheClient->iScreen->SetScreenMode(2); + + theScreenOrigin=iQueueClient->iScreen->GetDefaultScreenModeOrigin(); + SimulatePointer(TRawEvent::EButton1Down, + 30+theScreenOrigin.iX,30+theScreenOrigin.iY); + SimulatePointer(TRawEvent::EButton1Up, + 26+theScreenOrigin.iX,20+theScreenOrigin.iY); + SimulatePointer(TRawEvent::EButton1Down, + 40+theScreenOrigin.iX,60+theScreenOrigin.iY); + SimulatePointer(TRawEvent::EButton1Up, + 26+theScreenOrigin.iX,20+theScreenOrigin.iY); + + AddExpectedPointer(TPointerEvent::EButton1Down, + TPoint(15-EWinPositionX,15-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Up, + TPoint(13-EWinPositionX,10-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Down, + TPoint(20-EWinPositionX,30-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Up, + TPoint(13-EWinPositionX,10-EWinPositionY)); + } + + TheClient->iScreen->SetAppScreenMode(0); + iQueueClient->iScreen->SetAppScreenMode(0); + iQueueClient->iScreen->SetScreenMode(0); + iTest->DelayIfFullRomL(); + + theScreenOrigin = TPoint(iQueueClient->iScreen->GetDefaultScreenModeOrigin()); + + SimulatePointer(TRawEvent::EButton1Down, + 30+theScreenOrigin.iX, 30+theScreenOrigin.iY); + SimulatePointer(TRawEvent::EButton1Up, + 26+theScreenOrigin.iX, 20+theScreenOrigin.iY); + SimulatePointer(TRawEvent::EButton1Down, + 40+theScreenOrigin.iX, 50+theScreenOrigin.iY); + SimulatePointer(TRawEvent::EButton1Up, + 26+theScreenOrigin.iX, 20+theScreenOrigin.iY); + + #if defined(__WINS__) + iQueueClient->iWs.SimulateXyInputType(EXYInputDeltaMouse); + iQueueClient->iWs.SetPointerCursorPosition(TPoint(24+theScreenOrigin.iX,24+theScreenOrigin.iY)); + SimulatePointer(TRawEvent::EPointerMove,1,2); + iQueueClient->iWs.SimulateXyInputType(EXYInputPointer); + #endif + AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(30-EWinPositionX,30-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(26-EWinPositionX,20-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(40-EWinPositionX,50-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(26-EWinPositionX,20-EWinPositionY)); + + #if defined(__WINS__) + AddExpectedPointer(TPointerEvent::EMove, TPoint(25-EWinPositionX,26-EWinPositionY)); + #endif + + iQueueClient->iScreen->SetAppScreenMode(theCurMode); + TheClient->iScreen->SetScreenMode(theCurMode); + break; + } + default: + User::After(EPointerCursorUpdateGap); + iBlankWin->SetVisible(EFalse); + TheClient->iWs.SetAutoFlush(iTheClientFlush); + iQueueClient->iWs.SetAutoFlush(iQuequeClientFlush); + iQueueClient->iScreen->SetCurrentScreenModeAttributes(iSizeMode); + User::After(500000); //0.5secs, to allow other screen devices to respond to the flip events + CActiveScheduler::Stop(); + break; + } + } + +void CTEventTest::AnimEvent_NextSetOfEventsL() + { +#if defined(LOGGING) + TLogMessageText logMessageText; + _LIT(KSet,"AnimEvent SetOfEvents: %d (Max=4)"); + logMessageText.Format(KSet,iEventSet); + INFO_PRINTF1(logMessageText); +#endif + switch(iEventSet++) + { + case 0: + iAnim=REventAnim::NewL(iQueueClient->iWin->BaseWin(), iAnimDll); + AddExpectedEvent(EEventFocusGained); + AddExpectedKeyAnim(TRawEvent::EKeyDown,32,ETrue); + AddExpectedKeyAnim(TRawEvent::EKeyUp,32,ETrue); + AddExpectedKeyAnim(TRawEvent::EKeyDown,33,EFalse); + AddExpectedKeyAnim(TRawEvent::EKeyUp,33,EFalse); + iTest->SimulateKey(TRawEvent::EKeyDown,32); + iTest->SimulateKey(TRawEvent::EKeyUp,32); + iTest->SimulateKey(TRawEvent::EKeyDown,33); + iTest->SimulateKey(TRawEvent::EKeyUp,33); + TheClient->iWs.Flush(); + if (iAnim->TestFail(4)) + Failed(); + break; + case 1: + iQueueClient->iWin->BaseWin()->PointerFilter(EPointerFilterMove|EPointerFilterDrag,0); + iQueueClient->iWin->BaseWin()->SetPointerGrab(EFalse); + iQueueClient->iWs.Flush(); + TheClient->iWs.SetPointerCursorArea(TRect(10,10,51,51)); + AddExpectedPointerAnim(TRawEvent::EButton1Down, TPoint(10,10)); + AddExpectedPointerAnim(TRawEvent::EButton1Up, TPoint(25,10)); + AddExpectedPointerAnim(TRawEvent::EButton1Down, TPoint(50,10)); + AddExpectedPointerAnim(TRawEvent::EButton1Up, TPoint(50,35)); + AddExpectedPointerAnim(TRawEvent::EButton1Down, TPoint(50,50)); + AddExpectedPointerAnim(TRawEvent::EButton1Up, TPoint(25,50)); + AddExpectedPointerAnim(TRawEvent::EButton1Down, TPoint(10,50)); + AddExpectedPointerAnim(TRawEvent::EButton1Up, TPoint(10,35)); + AddExpectedPointerAnim(TRawEvent::EButton1Down, TPoint(30,30),EFalse); + AddExpectedPointerAnim(TRawEvent::EButton1Up, TPoint(30,30),EFalse); + SimulatePointer(TRawEvent::EButton1Down,5,5); + SimulatePointer(TRawEvent::EButton1Up,25,5); + SimulatePointer(TRawEvent::EButton1Down,55,5); + SimulatePointer(TRawEvent::EButton1Up,55,35); + SimulatePointer(TRawEvent::EButton1Down,55,55); + SimulatePointer(TRawEvent::EButton1Up,25,55); + SimulatePointer(TRawEvent::EButton1Down,5,55); + SimulatePointer(TRawEvent::EButton1Up,5,35); + SimulatePointer(TRawEvent::EButton1Down,30,30); + SimulatePointer(TRawEvent::EButton1Up,30,30); + TheClient->iWs.Flush(); + if (iAnim->TestFail(10)) + Failed(); + break; + case 2: + { + #if defined(LOGGING) + _LIT(KLog," :2nd Set of Events Modes=0x%x"); + logMessageText.Format(KLog,iScreenModeTests); + INFO_PRINTF1(logMessageText); + #endif + TInt enforc=TheClient->iScreen->ScreenModeEnforcement(); + iBlankWin->SetVisible(ETrue); + TInt expectedEvents=0; + if (iScreenModeTests&EDoRot90 && enforc==ESizeEnforcementNone) + { + INFO_PRINTF1(_L(" :Rotation 90")); + TheClient->iScreen->SetScreenMode(1); + TheClient->iWs.Flush(); + iTest->DelayIfFullRomL(); + AddExpectedPointerAnim(TRawEvent::EButton1Down, TPoint(20,20-iYOffset)); + AddExpectedPointerAnim(TRawEvent::EButton1Up, TPoint(20,20-iYOffset)); + expectedEvents+=2; + TPoint screenModeOrigin=TheClient->iScreen->GetDefaultScreenModeOrigin(); + #if defined(__WINS__) + iTest->SimulatePointer(TRawEvent::EButton1Down,20+screenModeOrigin.iX,20+screenModeOrigin.iY); + iTest->SimulatePointer(TRawEvent::EButton1Up,20+screenModeOrigin.iX,20+screenModeOrigin.iY); + #else + // simulate pointer at (20,20) on rotated screen by providing physical coordinates + iTest->SimulatePointer(TRawEvent::EButton1Down,iPhysicalScreenSize.iWidth-1-20+screenModeOrigin.iX,20+screenModeOrigin.iY); + iTest->SimulatePointer(TRawEvent::EButton1Up,iPhysicalScreenSize.iWidth-1-20+screenModeOrigin.iX,20+screenModeOrigin.iY); + #endif + } + if (iScreenModeTests&EDoRot180) + { + INFO_PRINTF1(_L(" :Rotation 180")); + TheClient->iScreen->SetCurrentRotations(0,CFbsBitGc::EGraphicsOrientationRotated180); + TheClient->iScreen->SetScreenMode(0); + TheClient->iWs.Flush(); + iTest->DelayIfFullRomL(); + AddExpectedPointerAnim(TRawEvent::EButton1Down, TPoint(22,22-iYOffset)); + AddExpectedPointerAnim(TRawEvent::EButton1Up, TPoint(22,22-iYOffset)); + + expectedEvents+=2; + #if defined(__WINS__) + iTest->SimulatePointer(TRawEvent::EButton1Down,22,22); + iTest->SimulatePointer(TRawEvent::EButton1Up,22,22); + #else + // simulate pointer at (22,22) on rotated screen by providing physical coordinates + iTest->SimulatePointer(TRawEvent::EButton1Down,iPhysicalScreenSize.iWidth-1-22,iPhysicalScreenSize.iHeight-1-22); + iTest->SimulatePointer(TRawEvent::EButton1Up,iPhysicalScreenSize.iWidth-1-22,iPhysicalScreenSize.iHeight-1-22); + #endif + } + TheClient->iScreen->SetCurrentRotations(0,CFbsBitGc::EGraphicsOrientationNormal); + TheClient->iScreen->SetScreenMode(0); + TheClient->iWs.Flush(); + iTest->DelayIfFullRomL(); + if (iScreenModeTests&EDoRot0) + { + INFO_PRINTF1(_L(" :Rotation 0")); + AddExpectedPointerAnim(TRawEvent::EButton1Down, TPoint(24,24),EFalse); + AddExpectedPointerAnim(TRawEvent::EButton1Up, TPoint(24,24),EFalse); + expectedEvents+=2; + SimulatePointer(TRawEvent::EButton1Down,24,24); + SimulatePointer(TRawEvent::EButton1Up,24,24); + } + #if defined(LOGGING) + _LIT(KNumEvents," :Expected Number of Events=%d Actual=%d"); + logMessageText.Format(KNumEvents,expectedEvents,iAnim->GetNumEvents()); + INFO_PRINTF1(logMessageText); + _LIT(KError," :Error Value %d ('0'=OK)"); + logMessageText.Format(KError,iAnim->GetError()); + INFO_PRINTF1(logMessageText); + #endif + if (iAnim->TestFail(expectedEvents)) + Failed(); + User::After(EPointerCursorUpdateGap); + iBlankWin->SetVisible(EFalse); + INFO_PRINTF1(_L(" :Finished 2nd Set")); + } + break; + case 3: + iAnim->Destroy(); iAnim=NULL; + // Create an EventPostingAnim, key down & key up events are simulated. + // The event posting anim sees the key events in turn, and creates duplicates. + // Test checks that each simulated event is received twice. + TRAPD(err, iAnim=REventAnim::NewL(iQueueClient->iWin->BaseWin(), iAnimDll, REventAnimBase::EEventPostingAnim)); + if (err!=KErrNone) + { + Failed(); + return; + } + AddExpectedKeyAnim(TRawEvent::EKeyDown,32,ETrue); + AddExpectedKeyAnim(TRawEvent::EKeyDown,32,EFalse); + AddExpectedKeyAnim(TRawEvent::EKeyUp,32,ETrue); + AddExpectedKeyAnim(TRawEvent::EKeyUp,32,EFalse); + + iTest->SimulateKey(TRawEvent::EKeyDown,32); + iTest->SimulateKey(TRawEvent::EKeyUp,32); + break; + case 4: + // Simulate a key down event, which calls anim's offer raw event + // which inturn calls post key event with old and new API + // Test checks the repeat count for old and new API are as expected. + AddExpectedKeyAnim(TRawEvent::EKeyDown,45,ETrue); + + TKeyEvent event; + event.iCode='J'; + event.iScanCode=0; + event.iModifiers=0; + event.iRepeats=0; + AddExpectedKey(1, event.iScanCode, event.iCode, event.iRepeats, event.iModifiers); + event.iRepeats=2; + AddExpectedKey(1, event.iScanCode, event.iCode, event.iRepeats, event.iModifiers); + + iTest->SimulateKey(TRawEvent::EKeyDown,45); + break; + default: + iAnim->Destroy(); + iAnim=NULL; + CActiveScheduler::Stop(); + break; + } + TheClient->iWs.Flush(); + } + +void CTEventTest::FocusChanged_NextSetOfEventsL() + { +#if defined(LOGGING) + TLogMessageText logMessageText; + _LIT(KSet,"FocusChanged SetOfEvents: %d "); + logMessageText.Format(KSet,iEventSet); + INFO_PRINTF1(logMessageText); +#endif + switch(iEventSet++) + { + case 0: + { + _LIT(AutoFocusTest,"FocusEvents"); + iQueueClient->EnableFocusChangeEvents(); + iEventTestGroup2=new(ELeave) CTWindowGroup(TheClient); + iEventTestGroup2->ConstructL(); + iEventTestGroup2->GroupWin()->SetName(AutoFocusTest); + AddExpectedEvent(EEventFocusGained); + AddExpectedEvent(EEventFocusLost); + AddExpectedEvent(EEventFocusGroupChanged); + AddExpectedEvent(EEventWindowGroupsChanged); + } + break; + case 1: + iEventTestGroup2->GroupWin()->EnableReceiptOfFocus(EFalse); + AddExpectedEvent(EEventFocusGained); + AddExpectedEvent(EEventFocusGroupChanged); + break; + case 2: + iEventTestGroup2->GroupWin()->EnableReceiptOfFocus(ETrue); + AddExpectedEvent(EEventFocusLost); + AddExpectedEvent(EEventFocusGroupChanged); + break; + case 3: + iEventTestGroup2->GroupWin()->SetOrdinalPosition(999); + AddExpectedEvent(EEventFocusGained); + AddExpectedEvent(EEventFocusGroupChanged); + break; + case 4: + iEventTestGroup2->GroupWin()->SetOrdinalPosition(0); + AddExpectedEvent(EEventFocusLost); + AddExpectedEvent(EEventFocusGroupChanged); + break; + case 5: + delete iEventTestGroup2; + iEventTestGroup2=NULL; + AddExpectedEvent(EEventWindowGroupsChanged); + AddExpectedEvent(EEventFocusGroupChanged); + break; + default: + CActiveScheduler::Stop(); + break; + } + TheClient->iWs.Flush(); + } + + +void CTEventTest::StopEvents_NextSetOfEventsL() + { + // we are not running tests 0,1,2 as they currently fail + if(iEventSet==0) + { + iEventSet=3; + AddExpectedEvent(EEventFocusGained); + } + TInt retVal = KErrNone; + + switch(iEventSet++) + { + case 0: // doesn't work if shell gets the off events - will fail on User::LeaveIfError(.... + iQueueClient->iWs.Flush(); + User::LeaveIfError(iQueueClient->iWs.RequestOffEvents(ETrue,iQueueClient->iGroup->WinTreeNode())); + iTest->SimulateEvent(TRawEvent::ESwitchOff); + TheClient->iWs.Flush(); + retVal = iQueueClient->iWs.RequestOffEvents(ETrue,iQueueClient->iWin->WinTreeNode()); + TEST(retVal==KErrAlreadyExists); + if (retVal!=KErrAlreadyExists) + INFO_PRINTF3(_L("iQueueClient->iWs.RequestOffEvents(ETrue,iQueueClient->iWin->WinTreeNode()) return value - Expected: %d, Actual: %d"), KErrAlreadyExists, retVal); + User::LeaveIfError(iQueueClient->iWs.RequestOffEvents(EFalse,iQueueClient->iGroup->WinTreeNode())); + User::LeaveIfError(iQueueClient->iWs.RequestOffEvents(ETrue,iQueueClient->iGroup->WinTreeNode())); + iTest->SimulateEvent(TRawEvent::ESwitchOff); + TheClient->iWs.Flush(); + retVal = iQueueClient->iWs.RequestOffEvents(ETrue,iQueueClient->iGroup->WinTreeNode()); + TEST(retVal==KErrAlreadyExists); + if (retVal!=KErrAlreadyExists) + INFO_PRINTF3(_L("iQueueClient->iWs.RequestOffEvents(ETrue,iQueueClient->iGroup->WinTreeNode()) return value - Expected: %d, Actual: %d"), KErrAlreadyExists, retVal); + User::LeaveIfError(iQueueClient->iWs.RequestOffEvents(EFalse)); + AddExpectedEvent(EEventFocusGained); + AddExpectedEvent(EEventSwitchOff); + AddExpectedEvent(EEventSwitchOff); + break; + + case 1: // doesn't work if shell gets the off events - will fail on User::LeaveIfError(.... + { + TKeyEvent event; + iQueueClient->iWs.Flush(); + User::LeaveIfError(iQueueClient->iWs.RequestOffEvents(ETrue,iQueueClient->iGroup->WinTreeNode())); + event.iCode=EKeyOff; + event.iScanCode=EKeyOff; + event.iModifiers=0; + event.iRepeats=0; + TheClient->iWs.SimulateKeyEvent(event); + TheClient->iWs.Flush(); + User::LeaveIfError(iQueueClient->iWs.RequestOffEvents(EFalse)); + AddExpectedEvent(EEventKeySwitchOff); + } + break; + + case 2: // doesn't work if shell gets the off events - will fail on User::LeaveIfError(.... + { + TKeyEvent event; + event.iCode=EKeyOff; + event.iScanCode=EKeyOff; + event.iModifiers=0; + event.iRepeats=0; + iQueueClient->iWs.Flush(); + User::LeaveIfError(iQueueClient->iWs.RequestOffEvents(ETrue,iQueueClient->iGroup->WinTreeNode())); + iTest->SimulateEvent(TRawEvent::ESwitchOff); + TheClient->iWs.SimulateKeyEvent(event); + iTest->SimulateEvent(TRawEvent::ECaseClose); + TheClient->iWs.Flush(); + retVal = iQueueClient->iWs.RequestOffEvents(ETrue,iQueueClient->iWin->WinTreeNode()); + TEST(retVal==KErrAlreadyExists); + if (retVal!=KErrAlreadyExists) + INFO_PRINTF3(_L("iQueueClient->iWs.RequestOffEvents(ETrue,iQueueClient->iWin->WinTreeNode()) return value - Expected: %d, Actual: %d"), KErrAlreadyExists, retVal); + iTest->SimulateEvent(TRawEvent::ESwitchOff); + iTest->SimulateEvent(TRawEvent::ECaseClose); + TheClient->iWs.SimulateKeyEvent(event); + TheClient->iWs.Flush(); + User::LeaveIfError(iQueueClient->iWs.RequestOffEvents(EFalse,iQueueClient->iGroup->WinTreeNode())); + User::LeaveIfError(iQueueClient->iWs.RequestOffEvents(ETrue,iQueueClient->iWin->WinTreeNode())); + iTest->SimulateEvent(TRawEvent::ECaseClose); + iTest->SimulateEvent(TRawEvent::ESwitchOff); + TheClient->iWs.SimulateKeyEvent(event); + TheClient->iWs.Flush(); + User::LeaveIfError(iQueueClient->iWs.RequestOffEvents(EFalse)); + User::LeaveIfError(iQueueClient->iWs.RequestOffEvents(ETrue,iQueueClient->iChildWin->WinTreeNode())); + iTest->SimulateEvent(TRawEvent::ESwitchOff); + TheClient->iWs.SimulateKeyEvent(event); + iTest->SimulateEvent(TRawEvent::ECaseClose); + TheClient->iWs.Flush(); + User::LeaveIfError(iQueueClient->iWs.RequestOffEvents(EFalse)); + AddExpectedEvent(EEventSwitchOff); + AddExpectedEvent(EEventKeySwitchOff); + AddExpectedEvent(EEventCaseClosed); + AddExpectedEvent(EEventSwitchOff); + AddExpectedEvent(EEventCaseClosed); + AddExpectedEvent(EEventKeySwitchOff); + AddExpectedEvent(EEventCaseClosed,iQueueClient->iWin); + AddExpectedEvent(EEventSwitchOff,iQueueClient->iWin); + AddExpectedEvent(EEventKeySwitchOff,iQueueClient->iWin); + AddExpectedEvent(EEventSwitchOff,iQueueClient->iChildWin); + AddExpectedEvent(EEventKeySwitchOff,iQueueClient->iChildWin); + AddExpectedEvent(EEventCaseClosed,iQueueClient->iChildWin); + } + break; + + case 3: + iQueueClient->iWs.Flush(); + //User::LeaveIfError(iQueueClient->iGroup->WinTreeNode()->EnableOnEvents(EEventControlAlways)); + iTest->SimulateEvent(TRawEvent::ESwitchOn); + iTest->SimulateEvent(TRawEvent::ECaseOpen); + TheClient->iWs.Flush(); + User::LeaveIfError(iQueueClient->iWin->WinTreeNode()->EnableOnEvents(EEventControlAlways)); + iTest->SimulateEvent(TRawEvent::ECaseOpen); + iTest->SimulateEvent(TRawEvent::ESwitchOn); + TheClient->iWs.Flush(); + iQueueClient->iWin->WinTreeNode()->DisableOnEvents(); + AddExpectedEvent(EEventSwitchOn); + //AddExpectedEvent(EEventSwitchOn); + AddExpectedEvent(EEventCaseOpened); + AddExpectedEvent(EEventCaseOpened,iQueueClient->iWin); + AddExpectedEvent(EEventCaseOpened); + AddExpectedEvent(EEventSwitchOn,iQueueClient->iWin); + AddExpectedEvent(EEventSwitchOn); + break; + + case 4: + iQueueClient->iWs.Flush(); + // switch off the device + iTest->SimulateEvent(TRawEvent::ESwitchOff); + // switch it back on. + iTest->SimulateEvent(TRawEvent::ESwitchOn); + TheClient->iWs.Flush(); + // TRawEvent::ESwitchOff never actually comes back. The tests will hang if we look for one + AddExpectedEvent(EEventSwitchOn); + break; + + case 5: + { + TKeyEvent event; + iQueueClient->iWs.Flush(); + event.iCode=EKeyOff; + event.iScanCode=EKeyOff; + event.iModifiers=0; + event.iRepeats=0; + // switch off the device - this one seems to send it to standby rather than off + TheClient->iWs.SimulateKeyEvent(event); + // switch it back on or no further tests will complete + iTest->SimulateEvent(TRawEvent::ESwitchOn); + TheClient->iWs.Flush(); + // again we would expect EEventKeySwitchOff but it doesn't come back. The tests will hang if we look for one + AddExpectedEvent(EEventSwitchOn); + } + break; + + case 6: + iQueueClient->iWs.Flush(); + iTest->SimulateEvent(TRawEvent::ESwitchOn); + iTest->SimulateEvent(TRawEvent::ECaseOpen); + TheClient->iWs.Flush(); + User::LeaveIfError(iQueueClient->iWin->WinTreeNode()->EnableOnEvents(EEventControlAlways)); + iTest->SimulateEvent(TRawEvent::ECaseOpen); + iTest->SimulateEvent(TRawEvent::ESwitchOn); + TheClient->iWs.Flush(); + iQueueClient->iWin->WinTreeNode()->DisableOnEvents(); + AddExpectedEvent(EEventSwitchOn); + AddExpectedEvent(EEventCaseOpened); + AddExpectedEvent(EEventCaseOpened,iQueueClient->iWin); + AddExpectedEvent(EEventCaseOpened); + AddExpectedEvent(EEventSwitchOn,iQueueClient->iWin); + AddExpectedEvent(EEventSwitchOn); + break; + + default: + CActiveScheduler::Stop(); + break; + } + TheClient->iWs.Flush(); + } + +void CTEventTest::VirtualKeyboard_NextSetOfEventsL() + { + const TInt noVirtualKeys=10; + const TInt keyWidth=2*EWinWidth/noVirtualKeys/3; + const TInt keyHeight=EWinHeight/2; + const TInt keySpacing=EWinWidth/noVirtualKeys; + const TInt baseChar='1'; + TInt startX=1; + TInt ii; + switch(iEventSet++) + { + case 0: + iQueueClient->iWin->BaseWin()->SetPointerGrab(EFalse); + for (ii=0;iiiWin->BaseWin()->AddKeyRect(TRect(startX,1,startX+keyWidth,keyHeight),baseChar+ii,EFalse); + startX+=keySpacing; + } + iQueueClient->iWs.Flush(); + iTest->SimulatePointerDownUp(EWinPositionX+1,EWinPositionY+1+iYOffset); + //TheClient->iWs.Flush(); + AddExpectedEvent(EEventFocusGained); + AddExpectedKeyDownUp(baseChar); + break; + case 1: + startX=3; + for (ii=0;iiSimulatePointerDownUp(startX+EWinPositionX+1,EWinPositionY+keyHeight-1+iYOffset); + AddExpectedKeyDownUp(baseChar+ii); + startX+=keySpacing; + } + break; + case 2: + SimulatePointerDownUpWin(keySpacing+1,1); + //SimulatePointerDownUp(EWinPositionX+keySpacing+1,EWinPositionY+1); + iTest->SimulatePointerDownUp(EWinPositionX+keyWidth,EWinPositionY+1+iYOffset); + iTest->SimulatePointerDownUp(EWinPositionX+1,EWinPositionY+keyHeight-1+iYOffset); + iTest->SimulatePointerDownUp(EWinPositionX+keyWidth,EWinPositionY+keyHeight-1+iYOffset); + AddExpectedKeyDownUp(baseChar+1); + AddExpectedKeyDownUp(baseChar); + AddExpectedKeyDownUp(baseChar); + AddExpectedKeyDownUp(baseChar); + break; + case 3: + SimulatePointerDownUpWin(keySpacing+3,4); + SimulatePointerDownUpWin(0,0); //No Pointer event get through even if there are gaps + SimulatePointerDownUpWin(1,0); + SimulatePointerDownUpWin(0,1); + SimulatePointerDownUpWin(keyWidth+1,0); + SimulatePointerDownUpWin(keyWidth,0); + SimulatePointerDownUpWin(keyWidth+1,1); + SimulatePointerDownUpWin(0,keyHeight); + SimulatePointerDownUpWin(1,keyHeight); + SimulatePointerDownUpWin(0,keyHeight-1); + SimulatePointerDownUpWin(keyWidth+1,keyHeight); + SimulatePointerDownUpWin(keyWidth,keyHeight); + SimulatePointerDownUpWin(keyWidth+1,keyHeight-1); + SimulatePointerDownUpWin(2*keySpacing+3,4); + AddExpectedKeyDownUp(baseChar+1); + AddExpectedPointerDownUpScr(TPoint(EWinPositionX+0,EWinPositionY+0)); //No Pointer event get through even if there are gaps + AddExpectedPointerDownUpScr(TPoint(EWinPositionX+1,EWinPositionY+0)); + AddExpectedPointerDownUpScr(TPoint(EWinPositionX+0,EWinPositionY+1)); + AddExpectedPointerDownUpScr(TPoint(EWinPositionX+keyWidth+1,EWinPositionY+0)); + AddExpectedPointerDownUpScr(TPoint(EWinPositionX+keyWidth,EWinPositionY+0)); + AddExpectedPointerDownUpScr(TPoint(EWinPositionX+keyWidth+1,EWinPositionY+1)); + AddExpectedPointerDownUpScr(TPoint(EWinPositionX+0,EWinPositionY+keyHeight)); + AddExpectedPointerDownUpScr(TPoint(EWinPositionX+1,EWinPositionY+keyHeight)); + AddExpectedPointerDownUpScr(TPoint(EWinPositionX+0,EWinPositionY+keyHeight-1)); + AddExpectedPointerDownUpScr(TPoint(EWinPositionX+keyWidth+1,EWinPositionY+keyHeight)); + AddExpectedPointerDownUpScr(TPoint(EWinPositionX+keyWidth,EWinPositionY+keyHeight)); + AddExpectedPointerDownUpScr(TPoint(EWinPositionX+keyWidth+1,EWinPositionY+keyHeight-1)); + AddExpectedKeyDownUp(baseChar+2); + break; + case 4: + SimulatePointerWin(TRawEvent::EButton1Down,keySpacing+2,6); + SimulatePointerWin(TRawEvent::EButton1Up,2*keySpacing+1,5); + SimulatePointerWin(TRawEvent::EButton1Down,2*keySpacing+2,7); + SimulatePointer(TRawEvent::EButton1Up,0,0); + AddExpectedKeyDownUp(baseChar+1); + AddExpectedKeyDownUp(baseChar+2); + break; + default: + CActiveScheduler::Stop(); + break; + } + TheClient->iWs.Flush(); + } + +TInt CTEventTest::ClickCommandReply(TInt aCommand,TInt aData) + { + TPckgBuf intPkg; + intPkg()=aData; + return iClick.CommandReply(aCommand,intPkg); + } + +TInt CTEventTest::CreateGroupWindow(RWindowGroup& aWinGp,TClients aClient,TInt& aWinGpId) + { + ClickCommandReply(EClickCreateGroupWin,aClient); + TInt err=aWinGp.Construct(ENullWsHandle,EFalse); + if (!err) + { + aWinGpId=aWinGp.Identifier(); + ClickCommandReply(EClickCheckGpWinId,aWinGpId); + } + return err; + } + +void CTEventTest::CloseGroupWindow(RWindowGroup& aWinGp,TInt aWinGpId) + { + ClickCommandReply(EClickCloseGroupWin,aWinGpId); + aWinGp.Close(); + } + +void CTEventTest::CloseWindow(RWindowBase& aWin,TInt aHandle,TInt aWinGpId) + { + TPckgBuf winClose; + winClose().iClientHandle=aHandle; + winClose().iWindowGroupId=aWinGpId; + iClick.CommandReply(EClickCloseWin,winClose); + aWin.Close(); + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-0447 + +@SYMCR CR1164 + +@SYMTestCaseDesc Tests that Key Click Plug-in gets new event Information + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Do things that cause the new events to be sent into plug-in. +Creating destroying windows, pointer events. Provide test plug-in with information it needs to check events. + +@SYMTestExpectedResults When Test Plug-in is querried to see if events match what was expected it says that they were. +*/ +void CTEventTest::KeyClicks_NextSetOfEvents() + { +#if defined(LOGGING) + TLogMessageText logMessageText; + _LIT(KSet,"KeyClicks SetOfEvents: %d (last=13)"); + logMessageText.Format(KSet,iEventSet); + INFO_PRINTF1(logMessageText); +#endif + TInt events=-1; + switch(iEventSet++) + { + case 0: + if (SetClickType(EClickCheck)) + return; + iAddToClick=ETrue; + iQueueClient->iWin->BaseWin()->SetPointerGrab(EFalse); + iQueueClient->iChildWin->BaseWin()->SetPointerGrab(EFalse); + AddExpectedEvent(EEventFocusGained); + AddExpectedKeyDownUp(EStdKeySpace,EKeySpace); + iQueueClient->iWs.Flush(); + iTest->SimulateKeyDownUp(EStdKeySpace); //3 events + events=3; + break; + case 1: + AddExpectedKeyDownUp(EStdKeyEnter,EKeyEnter); + AddExpectedKeyDownUp('0'); + AddExpectedKeyDownUp('A','a'); + AddExpectedKeyDownUp('X','x'); + AddExpectedKey(EEventKeyDown,EStdKeyLeftShift,0,0,EModifierLeftShift|EModifierShift); + AddExpectedKey(EEventKeyUp,EStdKeyLeftShift); + iQueueClient->iWs.Flush(); + iTest->SimulateKeyDownUp(EStdKeyEnter); //3 events + iTest->SimulateKeyDownUp('0'); //3 events + iTest->SimulateKeyDownUp('A'); //3 events + iTest->SimulateKeyDownUp('X'); //3 events + iTest->SimulateKeyDownUp(EStdKeyLeftShift); //2 events + events=14; + break; + case 2: + AddExpectedKey(EEventKeyDown,EStdKeyRightShift,0,0,EModifierRightShift|EModifierShift); + AddExpectedKeyDownUp('B','B',0,EModifierRightShift|EModifierShift); + AddExpectedKeyDownUp('W','W',0,EModifierRightShift|EModifierShift); + AddExpectedKey(EEventKeyUp,EStdKeyRightShift); + iQueueClient->iWs.Flush(); + iTest->SimulateKey(TRawEvent::EKeyDown,EStdKeyRightShift); //1 event + iTest->SimulateKeyDownUp('B'); //3 events + iTest->SimulateKeyDownUp('W'); //3 events + iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeyRightShift); //1 event + events=8; + break; + case 3: + AddExpectedKey(EEventKeyDown,'C'); + AddExpectedKey(EEventKey,'C','c'); + AddExpectedKey(EEventKeyDown,'V'); + AddExpectedKey(EEventKey,'V','v'); + AddExpectedKey(EEventKeyUp,'C'); + AddExpectedKey(EEventKeyUp,'V'); + iQueueClient->iWs.Flush(); + iTest->SimulateKey(TRawEvent::EKeyDown,'C'); //2 events + iTest->SimulateKey(TRawEvent::EKeyDown,'V'); //2 events + iTest->SimulateKey(TRawEvent::EKeyUp,'C'); //1 event + iTest->SimulateKey(TRawEvent::EKeyUp,'V'); //1 event + events=6; + break; + case 4: + { + AddExpectedKey(EEventKeyDown,'D'); + AddExpectedKey(EEventKey,'D','d'); + AddExpectedKey(EEventKey,'D','d',1); + AddExpectedKey(EEventKeyUp,'D'); + iQueueClient->iWs.Flush(); + iTest->SimulateKey(TRawEvent::EKeyDown,'D'); //2 events + TTimeIntervalMicroSeconds32 initialTime,time; + TheClient->iWs.GetKeyboardRepeatRate(initialTime,time); + User::After(initialTime.Int()+time.Int()/4); //1 event + iTest->SimulateKey(TRawEvent::EKeyUp,'D'); //1 event + events=4; + } + break; + case 5: + AddExpectedPointerDownUpScr(TPoint(40,25)); + AddExpectedPointerDownUpScr(TPoint(95,30)); + AddExpectedPointer(TPointerEvent::EButton1Down,TPoint(20-EWinPositionX,50-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EDrag,TPoint(45-EWinPositionX,42-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Up,TPoint(45-EWinPositionX,42-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Down,TPoint(98-EWinPositionX,15-EWinPositionY)); + AddExpectedPointerClick(TPointerEvent::EDrag,TPoint(68-EWinPositionX,39-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EDrag,TPoint(41-EWinPositionX,42-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Up,TPoint(50-EWinPositionX,58-EWinPositionY)); + iQueueClient->iWs.Flush(); + iTest->SimulatePointerDownUp(40,25+iYOffset); //2 events + iTest->SimulatePointerDownUp(95,30+iYOffset); //2 events + SimulatePointer(TRawEvent::EButton1Down,20,50); //1 event + SimulatePointer(TRawEvent::EPointerMove,45,42); //1 event + SimulatePointer(TRawEvent::EButton1Up,45,42); //1 event + SimulatePointer(TRawEvent::EButton1Down,98,15); //1 event + SimulatePointer(TRawEvent::EPointerMove,68,39); //1 event + SimulatePointer(TRawEvent::EPointerMove,41,42); //1 event + SimulatePointer(TRawEvent::EButton1Up,50,58); //1 event + events=11; + break; + case 6: + AddExpectedKey(EEventKeyDown,'E'); + AddExpectedKey(EEventKey,'E','e'); + AddExpectedPointerDownUpScr(TPoint(41,24)); + AddExpectedKey(EEventKeyUp,'E'); + AddExpectedPointer(TPointerEvent::EButton1Down,TPoint(23-EWinPositionX,52-EWinPositionY)); + AddExpectedKeyDownUp('1'); + AddExpectedPointer(TPointerEvent::EButton1Up,TPoint(44-EWinPositionX,45-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Down,TPoint(33-EWinPositionX,53-EWinPositionY)); + AddExpectedKey(EEventKeyDown,'F'); + AddExpectedKey(EEventKey,'F','f'); + AddExpectedPointer(TPointerEvent::EButton1Up,TPoint(34-EWinPositionX,47-EWinPositionY)); + AddExpectedKey(EEventKeyUp,'F'); + iQueueClient->iWs.Flush(); + iTest->SimulateKey(TRawEvent::EKeyDown,'E'); //2 events + iTest->SimulatePointerDownUp(41,24+iYOffset); //2 events + iTest->SimulateKey(TRawEvent::EKeyUp,'E'); //1 event + SimulatePointer(TRawEvent::EButton1Down,23,52); //1 event + iTest->SimulateKeyDownUp('1'); //3 events + SimulatePointer(TRawEvent::EButton1Up,44,45); //1 event + SimulatePointer(TRawEvent::EButton1Down,33,53); //1 event + iTest->SimulateKey(TRawEvent::EKeyDown,'F'); //2 events + SimulatePointer(TRawEvent::EButton1Up,34,47); //1 event + iTest->SimulateKey(TRawEvent::EKeyUp,'F'); //1 event + events=15; + break; + case 7: + AddExpectedKeyDownUp('2'); + iAddToClick=EFalse; + AddExpectedKeyDownUp('G','g'); + iAddToClick=ETrue; + AddExpectedPointerDownUpScr(TPoint(42,26)); + AddExpectedKeyDownUp('U','u'); + iQueueClient->iWs.Flush(); + iTest->SimulateKeyDownUp('2'); //3 events + TheClient->iWs.Flush(); + iQueueClient->iGroup->GroupWin()->DisableKeyClick(ETrue); + iQueueClient->iWs.Flush(); + iTest->SimulateKeyDownUp('G'); + iTest->SimulatePointerDownUp(42,26+iYOffset); //2 events + TheClient->iWs.Flush(); + iQueueClient->iGroup->GroupWin()->DisableKeyClick(EFalse); + iQueueClient->iWs.Flush(); + iTest->SimulateKeyDownUp('U'); //3 events + events=8; + break; + case 8: + { + TPckgBuf pointerEventInfo; + pointerEventInfo().iClientHandle=reinterpret_cast(iQueueClient->iChildWin); + pointerEventInfo().iWinGpId=iQueueClient->iGroup->GroupWin()->Identifier(); + pointerEventInfo().iWinOrigin=iQueueClient->ChildTopLeft(); + pointerEventInfo().iParentOrigin.SetXY(EWinPositionX,EWinPositionY); + iClick.CommandReply(EClickPointerEvent,pointerEventInfo); + AddExpectedKeyDownUp('3'); + AddExpectedPointerDownUpScr(TPoint(43,26)); + AddExpectedKeyDownUp('H','h'); + iAddToClick=EFalse; + AddExpectedPointerDownUpScr(TPoint(43,27)); + AddExpectedKeyDownUp('4'); + AddExpectedPointerDownUpScr(TPoint(42,27)); + AddExpectedKeyDownUp('I','i'); + iAddToClick=ETrue; + AddExpectedPointerDownUpScr(TPoint(44,27)); + AddExpectedKeyDownUp('5'); + AddExpectedPointerDownUpScr(TPoint(44,26)); + iQueueClient->iWs.Flush(); + iTest->SimulateKeyDownUp('3'); //3 events + iTest->SimulatePointerDownUp(43,26+iYOffset); //2 events + iClick.SetPenClick(EFalse); + iTest->SimulateKeyDownUp('H'); //3 events + iTest->SimulatePointerDownUp(43,27+iYOffset); + iClick.SetKeyClick(EFalse); + iTest->SimulateKeyDownUp('4'); + iTest->SimulatePointerDownUp(42,27+iYOffset); + iClick.SetPenClick(ETrue); + iTest->SimulateKeyDownUp('I'); + iTest->SimulatePointerDownUp(44,27+iYOffset); //2 events + iClick.SetKeyClick(ETrue); + iTest->SimulateKeyDownUp('5'); //3 events + iTest->SimulatePointerDownUp(44,26+iYOffset); //2 events + pointerEventInfo().iClientHandle=0; + pointerEventInfo().iWinGpId=0; + iClick.CommandReply(EClickPointerEvent,pointerEventInfo); + events=15; + } + break; + case 9: + { + RWindowGroup winGp(iQueueClient->iWs); + TInt winGpId; + TInt ii; + AddExpectedEvent(EEventWindowGroupsChanged); + for (ii=0;ii<2;++ii) //events x2 + { + if (CreateGroupWindow(winGp,EQueueClient,winGpId)) //1 event + Failed(); + CloseGroupWindow(winGp,winGpId); //1 event + iQueueClient->iWs.Flush(); + } + events=4; + } + break; + case 10: + { + RWindowGroup winGp(TheClient->iWs); + RWindowGroup winGp1(iQueueClient->iWs); + RWindowGroup winGp2(iQueueClient->iWs); + TInt winGpId; + TInt winGpId1; + TInt winGpId2; + AddExpectedEvent(EEventWindowGroupsChanged); + if (CreateGroupWindow(winGp,ETheClient,winGpId)) //1 event + Failed(); + CloseGroupWindow(winGp,winGpId); //1 event + TheClient->iWs.Flush(); + if (CreateGroupWindow(winGp1,EQueueClient,winGpId1)) //1 event + Failed(); + if (CreateGroupWindow(winGp2,EQueueClient,winGpId2)) //1 event + Failed(); + if (CreateGroupWindow(winGp,ETheClient,winGpId)) //1 event + Failed(); + CloseGroupWindow(winGp2,winGpId2); //1 event + iQueueClient->iWs.Flush(); + CloseGroupWindow(winGp,winGpId); //1 event + TheClient->iWs.Flush(); + CloseGroupWindow(winGp1,winGpId1); //1 event + iQueueClient->iWs.Flush(); + events=8; + } + break; + case 11: + { + RWindowGroup winGp(iQueueClient->iWs); + TInt winGpId; + AddExpectedEvent(EEventWindowGroupsChanged); + if (CreateGroupWindow(winGp,EQueueClient,winGpId)) //1 event + Failed(); + RWindow win(iQueueClient->iWs); + const TInt handle=79; + if (win.Construct(winGp,handle)) + Failed(); + win.Activate(); + CloseWindow(win,handle,winGpId); //1 event + iQueueClient->iWs.Flush(); + CloseGroupWindow(winGp,winGpId); //1 event + iQueueClient->iWs.Flush(); + events=3; + } + break; + case 12: + { + RWindowGroup winGp1(iQueueClient->iWs); + RWindowGroup winGp2(TheClient->iWs); + TInt winGpId1; + TInt winGpId2; + AddExpectedEvent(EEventWindowGroupsChanged); + if (CreateGroupWindow(winGp2,ETheClient,winGpId2)) //1 event + Failed(); + if (CreateGroupWindow(winGp1,EQueueClient,winGpId1)) //1 event + Failed(); + RWindow win1(iQueueClient->iWs); + RWindow win2(iQueueClient->iWs); + RWindow win(TheClient->iWs); + const TInt handle1a=80; + const TInt handle1b=81; + const TInt handle2a=82; + const TInt handle2b=83; + const TInt handle=84; + if (win1.Construct(winGp1,handle1a)) + Failed(); + win1.Activate(); + if (win2.Construct(win1,handle2a)) + Failed(); + win2.Activate(); + if (win.Construct(winGp2,handle)) + Failed(); + win.Activate(); + CloseWindow(win2,handle2a,winGpId1); //1 event + iQueueClient->iWs.Flush(); + if (win2.Construct(winGp1,handle2b)) + Failed(); + win2.Activate(); + CloseWindow(win1,handle1a,winGpId1); //1 event + iQueueClient->iWs.Flush(); + CloseWindow(win,handle,winGpId2); //1 event + TheClient->iWs.Flush(); + if (win1.Construct(win2,handle1b)) + Failed(); + win1.Activate(); + CloseWindow(win1,handle1b,winGpId1); //1 event + iQueueClient->iWs.Flush(); + CloseGroupWindow(winGp2,winGpId2); //1 event + TheClient->iWs.Flush(); + CloseWindow(win2,handle2b,winGpId1); //1 event + iQueueClient->iWs.Flush(); + CloseGroupWindow(winGp1,winGpId1); //1 event + iQueueClient->iWs.Flush(); + events=9; + } + break; + case 13: + { + TPckgBuf pointerEventInfo; + pointerEventInfo().iClientHandle=reinterpret_cast(iQueueClient->iWin); + pointerEventInfo().iWinGpId=iQueueClient->iGroup->GroupWin()->Identifier(); + pointerEventInfo().iWinOrigin.SetXY(EWinPositionX,EWinPositionY); + pointerEventInfo().iParentOrigin.SetXY(0,0); + iClick.CommandReply(EClickPointerEvent,pointerEventInfo); + AddExpectedPointerDownUpScr(TPoint(43,18)); + AddExpectedPointerDownUpScr(TPoint(43,17)); + AddExpectedPointerDownUpScr(TPoint(42,52)); + AddExpectedPointerDownUpScr(TPoint(24,27)); + AddExpectedPointerDownUpScr(TPoint(94,26)); + iQueueClient->iWs.Flush(); + iTest->SimulatePointerDownUp(43,18+iYOffset); //2 events + iTest->SimulatePointerDownUp(43,17+iYOffset); //2 events + iTest->SimulatePointerDownUp(42,52+iYOffset); //2 events + iTest->SimulatePointerDownUp(24,27+iYOffset); //2 events + iTest->SimulatePointerDownUp(94,26+iYOffset); //2 events + pointerEventInfo().iClientHandle=0; + pointerEventInfo().iWinGpId=0; + iClick.CommandReply(EClickPointerEvent,pointerEventInfo); + events=10; + } + break; + default: + iAddToClick=EFalse; + if (!SetClickType(EClickNone)) + CActiveScheduler::Stop(); + return; + } + TInt failedAt=iClick.CommandReply(EClickFailed,TPtrC8(NULL,0)); + TInt eventsDone=iClick.CommandReply(EClickEvents,TPtrC8(NULL,0)); + if (failedAt!=0 || eventsDone!=events) //iEventSet (already incremented) + { + #if defined(LOGGING) + _LIT(KeyClickFailed,"KeyClick Failed EventSet=%d FailedAt=%d TotalEvents=%d EventsDone=%d"); + logMessageText.Format(KeyClickFailed,iEventSet-1,failedAt,events,eventsDone); + INFO_PRINTF1(logMessageText); + #endif + Failed(); + } + iClick.CommandReply(EClickReset,TPtrC8(NULL,0)); + } + +void CTEventTest::CaptureLong_NextSetOfEventsL() + { + TTimeIntervalMicroSeconds32 initialTime,time; + TheClient->iWs.GetKeyboardRepeatRate(initialTime,time); + #if defined(LOGGING) + TLogMessageText logMessageText; + _LIT(KSet,"CaptureLong SetOfEvents: %d of 14"); + logMessageText.Format(KSet,iEventSet); + INFO_PRINTF1(logMessageText); + #endif + + switch(iEventSet++) + { + case 0: + iQueueClient->iWs.Flush(); + iTest->SimulateKeyDownUp('A'); + AddExpectedEvent(EEventFocusGained); + AddExpectedKeyDownUp('A','a'); + break; + case 1: + iCaptureKey=iQueueClient->iGroup->GroupWin()->CaptureLongKey(' ','a',0,0,2,ELongCaptureNormal); + iQueueClient->iWs.Flush(); + iTest->SimulateKey(TRawEvent::EKeyDown,EStdKeySpace); + TheClient->iWs.Flush(); + User::After(initialTime.Int()+time.Int()/3); + iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeySpace); + AddExpectedKey(EEventKeyDown,EStdKeySpace); + AddExpectedKey(EEventKey,EStdKeySpace,' '); + AddExpectedKey(EEventKey,EStdKeySpace,'a',1); + AddExpectedKey(EEventKeyUp,EStdKeySpace); + iQueueClient->iGroup->GroupWin()->CancelCaptureLongKey(iCaptureKey); + break; + case 2: + iCaptureKey=iQueueClient->iGroup->GroupWin()->CaptureLongKey(' ','a',0,0,2,ELongCaptureWaitShort); + iQueueClient->iWs.Flush(); + iTest->SimulateKey(TRawEvent::EKeyDown,EStdKeySpace); + TheClient->iWs.Flush(); + User::After(initialTime.Int()+time.Int()/3); + iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeySpace); + iTest->SimulateKeyDownUp(EStdKeySpace); + AddExpectedKey(EEventKeyDown,EStdKeySpace); + AddExpectedKey(EEventKey,EStdKeySpace,'a',1); + AddExpectedKey(EEventKeyUp,EStdKeySpace); + AddExpectedKeyDownUp(EStdKeySpace,' '); + iQueueClient->iGroup->GroupWin()->CancelCaptureLongKey(iCaptureKey); + break; + case 3: + iCaptureKey=iQueueClient->iGroup->GroupWin()->CaptureLongKey(' ','a',0,0,2,ELongCaptureNormal|ELongCaptureRepeatEvents); + iQueueClient->iWs.Flush(); + iTest->SimulateKey(TRawEvent::EKeyDown,EStdKeySpace); + TheClient->iWs.Flush(); + User::After(initialTime.Int()+5*time.Int()); + iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeySpace); + AddExpectedKey(EEventKeyDown,EStdKeySpace); + AddExpectedKey(EEventKey,EStdKeySpace,' '); + AddExpectedKey(EEventKey,EStdKeySpace,'a',2); + AddExpectedKey(EEventKeyUp,EStdKeySpace); + iQueueClient->iGroup->GroupWin()->CancelCaptureLongKey(iCaptureKey); + break; + case 4: + iQueueClient->iWs.Flush(); + iTest->SimulateKey(TRawEvent::EKeyDown,'Z'); + TheClient->iWs.Flush(); + User::After(initialTime.Int()+3*time.Int()); + iTest->SimulateKey(TRawEvent::EKeyDown,'Y'); + TheClient->iWs.Flush(); + User::After(initialTime.Int()+2*time.Int()); + iTest->SimulateKey(TRawEvent::EKeyUp,'Z'); + iTest->SimulateKey(TRawEvent::EKeyUp,'Y'); + AddExpectedKey(EEventKeyDown,'Z'); + AddExpectedKey(EEventKey,'Z','z'); + AddExpectedKey(EEventKey,'Z','z',1); + AddExpectedKey(EEventKeyDown,'Y'); + AddExpectedKey(EEventKey,'Y','y'); + AddExpectedKey(EEventKey,'Y','y',1); + AddExpectedKey(EEventKeyUp,'Z'); + AddExpectedKey(EEventKeyUp,'Y'); + break; + case 5: + iQueueClient->iWs.Flush(); + iTest->SimulateKey(TRawEvent::EKeyDown,'Z'); + TheClient->iWs.Flush(); + User::After(initialTime.Int()+3*time.Int()); + iTest->SimulateKey(TRawEvent::EKeyDown,'Y'); + TheClient->iWs.Flush(); + User::After(initialTime.Int()+5*time.Int()/2); + iTest->SimulateKey(TRawEvent::EKeyUp,'Y'); + TheClient->iWs.Flush(); + User::After(initialTime.Int()+2*time.Int()); + iTest->SimulateKey(TRawEvent::EKeyUp,'Z'); + AddExpectedKey(EEventKeyDown,'Z'); + AddExpectedKey(EEventKey,'Z','z'); + AddExpectedKey(EEventKey,'Z','z',1); + AddExpectedKey(EEventKeyDown,'Y'); + AddExpectedKey(EEventKey,'Y','y'); + AddExpectedKey(EEventKey,'Y','y',1); + AddExpectedKey(EEventKeyUp,'Y'); + AddExpectedKey(EEventKey,'Z','z',1); + AddExpectedKey(EEventKeyUp,'Z'); + break; + case 6: + iCaptureKey=iQueueClient->iGroup->GroupWin()->CaptureLongKey(' ','b',0,0,2,ELongCaptureNormal); + iQueueClient->iWs.Flush(); + iTest->SimulateKey(TRawEvent::EKeyDown,'X'); + TheClient->iWs.Flush(); + User::After(initialTime.Int()+3*time.Int()); + iTest->SimulateKeyDownUp(EStdKeySpace); + TheClient->iWs.Flush(); + if(!iTest->IsFullRomL()) + { + User::After(initialTime.Int()+2*time.Int()); + } + iTest->SimulateKey(TRawEvent::EKeyUp,'X'); + AddExpectedKey(EEventKeyDown,'X'); + AddExpectedKey(EEventKey,'X','x'); + AddExpectedKey(EEventKey,'X','x',1); + AddExpectedKey(EEventKeyDown,EStdKeySpace); + AddExpectedKey(EEventKey,EStdKeySpace,' '); + AddExpectedKey(EEventKeyUp,EStdKeySpace); + if(!iTest->IsFullRomL()) + { + AddExpectedKey(EEventKey,'X','x',1); + } + AddExpectedKey(EEventKeyUp,'X'); + iQueueClient->iGroup->GroupWin()->CancelCaptureLongKey(iCaptureKey); + break; + case 7: + iCaptureKey=iQueueClient->iGroup->GroupWin()->CaptureLongKey(' ','b',0,0,2,ELongCaptureNormal|ELongCaptureRepeatEvents); + iQueueClient->iWs.Flush(); + iTest->SimulateKey(TRawEvent::EKeyDown,'X'); + TheClient->iWs.Flush(); + User::After(initialTime.Int()+5*time.Int()); + iTest->SimulateKey(TRawEvent::EKeyDown,EStdKeySpace); + TheClient->iWs.Flush(); + User::After(initialTime.Int()+time.Int()/3); + iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeySpace); + TheClient->iWs.Flush(); + User::ResetInactivityTime(); + User::After(initialTime.Int()+4*time.Int()); + iTest->SimulateKey(TRawEvent::EKeyUp,'X'); + AddExpectedKey(EEventKeyDown,'X'); + AddExpectedKey(EEventKey,'X','x'); + AddExpectedKey(EEventKey,'X','x',1); + AddExpectedKey(EEventKeyDown,EStdKeySpace); + AddExpectedKey(EEventKey,EStdKeySpace,' '); + AddExpectedKey(EEventKey,EStdKeySpace,'b',1); + AddExpectedKey(EEventKeyUp,EStdKeySpace); + AddExpectedKey(EEventKey,'X','x',1); + AddExpectedKey(EEventKeyUp,'X'); + iQueueClient->iGroup->GroupWin()->CancelCaptureLongKey(iCaptureKey); + break; + case 8: + iCaptureKey=iQueueClient->iGroup->GroupWin()->CaptureLongKey(' ','c',0,0,2,ELongCaptureRepeatEvents); + iQueueClient->iWs.Flush(); + iTest->SimulateKey(TRawEvent::EKeyDown,EStdKeySpace); + TheClient->iWs.Flush(); + User::After(initialTime.Int()+5*time.Int()); + iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeySpace); + AddExpectedKey(EEventKeyDown,EStdKeySpace); + AddExpectedKey(EEventKey,EStdKeySpace,'c',1); + AddExpectedKey(EEventKeyUp,EStdKeySpace); + iQueueClient->iGroup->GroupWin()->CancelCaptureLongKey(iCaptureKey); + break; + case 9: + { + TInt captureKey=iQueueClient->iGroup->GroupWin()->CaptureLongKey(EKeyEscape,'e',0,0,2,ELongCaptureNormal|ELongCaptureRepeatEvents); + iCaptureKey=iQueueClient->iGroup->GroupWin()->CaptureLongKey(' ','d',0,0,2,ELongCaptureNormal|ELongCaptureRepeatEvents); + iQueueClient->iWs.Flush(); + iTest->SimulateKey(TRawEvent::EKeyDown,EStdKeySpace); + TheClient->iWs.Flush(); + User::After(initialTime.Int()+5*time.Int()/2); + iTest->SimulateKeyDownUp(EStdKeyEscape); + TheClient->iWs.Flush(); + User::After(initialTime.Int()+3*time.Int()); + iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeySpace); + AddExpectedKey(EEventKeyDown,EStdKeySpace); + AddExpectedKey(EEventKey,EStdKeySpace,' '); + AddExpectedKey(EEventKey,EStdKeySpace,'d',1); + AddExpectedKey(EEventKeyDown,EStdKeyEscape); + AddExpectedKey(EEventKey,EStdKeyEscape,EKeyEscape); + AddExpectedKey(EEventKeyUp,EStdKeyEscape); + AddExpectedKey(EEventKeyUp,EStdKeySpace); + iQueueClient->iGroup->GroupWin()->CancelCaptureLongKey(iCaptureKey); + iQueueClient->iGroup->GroupWin()->CancelCaptureLongKey(captureKey); + } + break; + case 10: + //Cancel a long capture key event whilst a repeat is underway + iCaptureKey=iQueueClient->iGroup->GroupWin()->CaptureLongKey(' ','a',0,0,2,ELongCaptureNormal|ELongCaptureRepeatEvents); + iQueueClient->iWs.Flush(); + iTest->SimulateKey(TRawEvent::EKeyDown,EStdKeySpace); + TheClient->iWs.Flush(); + iQueueClient->iGroup->GroupWin()->CancelCaptureLongKey(iCaptureKey); + User::After(initialTime.Int()+5*time.Int()); + iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeySpace); + AddExpectedKey(EEventKeyDown,EStdKeySpace); + AddExpectedKey(EEventKey,EStdKeySpace,' '); + AddExpectedKey(EEventKeyUp,EStdKeySpace); + break; + case 11: + //Cancel a capture key up and down event whilst a repeat is underway + iCaptureKey=iQueueClient->iGroup->GroupWin()->CaptureKeyUpAndDowns(EStdKeySpace,0,0); + iQueueClient->iWs.Flush(); + iTest->SimulateKey(TRawEvent::EKeyDown,'X'); + TheClient->iWs.Flush(); + iQueueClient->iGroup->GroupWin()->CancelCaptureKeyUpAndDowns(iCaptureKey); + User::After(initialTime.Int()+5*time.Int()); + iTest->SimulateKey(TRawEvent::EKeyUp,'X'); + AddExpectedKey(EEventKeyDown,'X'); + AddExpectedKey(EEventKey,'X','x'); + AddExpectedKey(EEventKeyUp,'X'); + break; + case 12: + //Cancel a capture key event whilst a repeat is underway + iCaptureKey=iQueueClient->iGroup->GroupWin()->CaptureKey(EStdKeySpace,0,0); + iQueueClient->iWs.Flush(); + iTest->SimulateKey(TRawEvent::EKeyDown,'Y'); + TheClient->iWs.Flush(); + iQueueClient->iGroup->GroupWin()->CancelCaptureKey(iCaptureKey); + User::After(initialTime.Int()+5*time.Int()); + iTest->SimulateKey(TRawEvent::EKeyUp,'Y'); + AddExpectedKey(EEventKeyDown,'Y'); + AddExpectedKey(EEventKey,'Y','y'); + AddExpectedKey(EEventKeyUp,'Y'); + break; + case 13: + //Variation on case 12 i.e. change in the timing of the CancelCaptureKey call + iCaptureKey=iQueueClient->iGroup->GroupWin()->CaptureKey(EStdKeySpace,0,0); + iQueueClient->iWs.Flush(); + iTest->SimulateKey(TRawEvent::EKeyDown,'Z'); + TheClient->iWs.Flush(); + User::After(initialTime.Int()+5*time.Int()/2); + iQueueClient->iGroup->GroupWin()->CancelCaptureKey(iCaptureKey); + User::After(initialTime.Int()+5*time.Int()/2); + iTest->SimulateKey(TRawEvent::EKeyUp,'Z'); + AddExpectedKey(EEventKeyDown,'Z'); + AddExpectedKey(EEventKey,'Z','z'); + AddExpectedKey(EEventKey,'Z','z',2); + AddExpectedKey(EEventKeyUp,'Z'); + break; + case 14: + { + // Cancel long capture key event when normal capture key is scheduled for different + // window group. + iCaptureKey=iQueueClient->iGroup->GroupWin()->CaptureLongKey(' ','a',0,0,2,ELongCaptureNormal); + TInt shortCaptKey = TheClient->iGroup->GroupWin()->CaptureKey(' ',0,0); + + iTest->SimulateKey(TRawEvent::EKeyDown,EStdKeySpace); + TheClient->iWs.Flush(); + iQueueClient->iGroup->GroupWin()->CancelCaptureLongKey(iCaptureKey); + User::After(initialTime.Int()+time.Int()/3); + + TheClient->iGroup->GroupWin()->CancelCaptureKey(shortCaptKey); + iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeySpace); + AddExpectedKey(EEventKeyDown,EStdKeySpace); + AddExpectedKey(EEventKeyUp,EStdKeySpace); + } + break; + default: + CActiveScheduler::Stop(); + break; + } + TheClient->iWs.Flush(); + } + +#define PASSWORD_START_OF_DAY 4 +void CTEventTest::Password_NextSetOfEvents() + { + switch(iEventSet++) + { + case 0: + iQueueClient->iWin->BaseWin()->PasswordWindow(EPasswordAlwaysTriggerNow); + iQueueClient->iWs.PasswordEntered(); + iTest->SimulateKeyDownUp('2'); + iQueueClient->iWs.Flush(); + AddExpectedEvent(EEventFocusGained); + AddExpectedEvent(EEventPassword); + AddExpectedKeyDownUp('2'); + break; + case 1: + iQueueClient->iWin->BaseWin()->PasswordWindow(EPasswordOnceADayTriggerNow); + iQueueClient->iWs.PasswordEntered(); + iTest->SimulateKeyDownUp('3'); + iQueueClient->iWs.Flush(); + AddExpectedEvent(EEventPassword); + AddExpectedKeyDownUp('3'); + break; + case 2: + { + TTime time; + time.HomeTime(); + TInt day=time.DayNoInMonth(); + if (day==0) + day=5; + time-=TTimeIntervalDays(day); + time+=TTimeIntervalHours(PASSWORD_START_OF_DAY); + User::SetHomeTime(time); + iQueueClient->iWin->BaseWin()->PasswordWindow(EPasswordOnceADayTriggerNow); + iQueueClient->iWs.PasswordEntered(); + iTest->SimulateKeyDownUp('3'); + iQueueClient->iWs.Flush(); + AddExpectedEvent(EEventPassword); + AddExpectedKeyDownUp('3'); + time+=TTimeIntervalDays(day); + time-=TTimeIntervalHours(PASSWORD_START_OF_DAY); + User::SetHomeTime(time); + } + break; + case 3: + { + TTime time; + time.HomeTime(); + TInt day=time.DayNoInMonth(); + time-=TTimeIntervalDays(day); + time+=TTimeIntervalHours(PASSWORD_START_OF_DAY); + User::SetHomeTime(time); + iQueueClient->iWin->BaseWin()->PasswordWindow(EPasswordOnceADay); + iQueueClient->iWs.PasswordEntered(); + iTest->SimulateEvent(TRawEvent::ESwitchOn); + iTest->SimulateKeyDownUp('3'); + iQueueClient->iWs.Flush(); + AddExpectedEvent(EEventPassword); + AddExpectedEvent(EEventSwitchOn); + AddExpectedKeyDownUp('3'); + time+=TTimeIntervalDays(day); + time-=TTimeIntervalHours(PASSWORD_START_OF_DAY); + User::SetHomeTime(time); + } + break; + default: + CActiveScheduler::Stop(); + break; + } + TheClient->iWs.Flush(); + } + +void CTEventTest::GroupListChanged_NextSetOfEventsL() + { + _LIT(WindowGroup1,"WindowGroupName1"); + _LIT(WindowGroup2,"WindowGroupName2"); + switch(iEventSet++) + { + case 0: + { + _LIT(TestGroup3,"GroupListEvents3"); + iQueueClient->EnableGroupListChangeEvents(); + iEventTestGroup3=new(ELeave) CTWindowGroup(TheClient); + iEventTestGroup3->ConstructL(); + iEventTestGroup3->GroupWin()->SetName(TestGroup3); + AddExpectedEvent(EEventFocusGained); + AddExpectedEvent(EEventFocusLost); + AddExpectedEvent(EEventWindowGroupListChanged); + AddExpectedEvent(EEventWindowGroupsChanged); + } + break; + case 1: + { + _LIT(TestGroup4,"GroupListEvents4"); + iEventTestGroup4=new(ELeave) CTWindowGroup(TheClient); + iEventTestGroup4->ConstructL(); + iEventTestGroup4->GroupWin()->SetName(TestGroup4); + AddExpectedEvent(EEventWindowGroupListChanged); + AddExpectedEvent(EEventWindowGroupsChanged); + } + break; + case 2: + iEventTestGroup3->GroupWin()->SetOrdinalPosition(0); + AddExpectedEvent(EEventWindowGroupListChanged); + break; + case 3: + iEventTestGroup3->GroupWin()->SetOrdinalPosition(999); + AddExpectedEvent(EEventWindowGroupListChanged); + break; + case 4: + iEventTestGroup4->GroupWin()->SetOrdinalPosition(999); + AddExpectedEvent(EEventFocusGained); + AddExpectedEvent(EEventWindowGroupListChanged); + // Testcase for defect INC135635 + // Since iWin has OrdinalPosition Zero (the front) clicking on it won't generate an + // EEventWindowGroupListChanged event as there is no change in the order of the windows + AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(20-EWinPositionX,11-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(20-EWinPositionX,11-EWinPositionY)); + SimulatePointer(TRawEvent::EButton1Down,20,11); + SimulatePointer(TRawEvent::EButton1Up,20,11); + break; + case 5: + iEventTestGroup3->GroupWin()->SetOrdinalPosition(999); + AddExpectedEvent(EEventWindowGroupListChanged); + break; + case 6: + iEventTestGroup3->GroupWin()->SetOrdinalPosition(99); + SimulatePointer(TRawEvent::EButton1Down,20,11); + iEventTestGroup3->GroupWin()->SetName(WindowGroup1); + AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(20-EWinPositionX,11-EWinPositionY)); + AddExpectedEvent(EEventWindowGroupsChanged); + break; + case 7: + iEventTestGroup3->GroupWin()->SetName(WindowGroup2); + SimulatePointer(TRawEvent::EButton1Up,10,20); + AddExpectedEvent(EEventWindowGroupsChanged); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(10-EWinPositionX,20-EWinPositionY)); + break; + case 8: + iEventTestGroup3->GroupWin()->SetName(WindowGroup1); + SimulatePointer(TRawEvent::EButton2Down,20,30); + AddExpectedEvent(EEventWindowGroupsChanged); + AddExpectedPointer(TPointerEvent::EButton2Down, TPoint(20-EWinPositionX,30-EWinPositionY)); + break; + case 9: + SimulatePointer(TRawEvent::EButton1Up,15,15); + iEventTestGroup3->GroupWin()->SetName(WindowGroup2); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(15-EWinPositionX,15-EWinPositionY)); + AddExpectedEvent(EEventWindowGroupsChanged); + break; + case 10: + SimulatePointer(TRawEvent::EButton2Down,25,20); + iEventTestGroup3->GroupWin()->SetName(WindowGroup2); + SimulatePointer(TRawEvent::EButton1Up,15,20); + iEventTestGroup3->GroupWin()->SetName(WindowGroup1); + AddExpectedPointer(TPointerEvent::EButton2Down, TPoint(25-EWinPositionX,20-EWinPositionY)); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(15-EWinPositionX,20-EWinPositionY)); + AddExpectedEvent(EEventWindowGroupsChanged); + break; + case 11: + iEventTestGroup3->GroupWin()->SetName(WindowGroup1); + SimulatePointer(TRawEvent::EButton2Down,12,12); + iEventTestGroup3->GroupWin()->SetName(WindowGroup2); + SimulatePointer(TRawEvent::EButton1Up,12,12); + AddExpectedPointer(TPointerEvent::EButton2Down, TPoint(12-EWinPositionX,12-EWinPositionY)); + AddExpectedEvent(EEventWindowGroupsChanged); + AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(12-EWinPositionX,12-EWinPositionY)); + break; + case 12: + delete iEventTestGroup3; + iEventTestGroup3=NULL; + AddExpectedEvent(EEventWindowGroupsChanged); + AddExpectedEvent(EEventWindowGroupListChanged); + break; + case 13: + delete iEventTestGroup4; + iEventTestGroup4=NULL; + AddExpectedEvent(EEventWindowGroupsChanged); + AddExpectedEvent(EEventWindowGroupListChanged); + break; + default: + CActiveScheduler::Stop(); + break; + } + TheClient->iWs.Flush(); + } + +TInt CTEventTest::KeyRepeatTime() const + { + TTimeIntervalMicroSeconds32 initialTime; + TTimeIntervalMicroSeconds32 time; + TheClient->iWs.GetKeyboardRepeatRate(initialTime,time); + return(initialTime.Int()); + } + +void CTEventTest::RepeatableKeysL() + { + // repeatable key event + TKeyEvent repKeyEvent; + repKeyEvent.iCode='J'; + repKeyEvent.iScanCode=0; + repKeyEvent.iModifiers=EModifierAutorepeatable; + repKeyEvent.iRepeats=0; + + // non-repeatable key event + TKeyEvent keyEvent; + keyEvent.iCode='J'; + keyEvent.iScanCode=0; + keyEvent.iModifiers=0; + keyEvent.iRepeats=0; + + switch(iEventSet++) + { + case 0: + { + TheClient->iWs.SimulateKeyEvent(repKeyEvent); // Create a repeatable key event + TheClient->iWs.SimulateKeyEvent(repKeyEvent); // Create a repeatable key event + TheClient->iWs.SimulateKeyEvent(keyEvent); // Create a non-repeatable key event + TheClient->iWs.Flush(); // Send events + AddExpectedEvent(EEventFocusGained); // Always get a focus gain at start + AddExpectedKey(1, repKeyEvent.iScanCode, repKeyEvent.iCode, repKeyEvent.iRepeats, repKeyEvent.iModifiers);// Expect the event that was created above + AddExpectedKey(1, repKeyEvent.iScanCode, repKeyEvent.iCode, repKeyEvent.iRepeats, repKeyEvent.iModifiers);// Expect the event that was created above + AddExpectedKey(1, keyEvent.iScanCode, keyEvent.iCode, keyEvent.iRepeats, keyEvent.iModifiers);// Expect the event that was created above + break; + } + case 1: + { + TheClient->iWs.SimulateKeyEvent(repKeyEvent); // Create a repeatable key event + TheClient->iWs.SimulateKeyEvent(keyEvent); // Create a non-repeatable key event + TheClient->iWs.Flush(); + iTest->SimulateKey(TRawEvent::EKeyDown, 'A'); // Create a raw event + TheClient->iWs.Flush(); + User::After(KeyRepeatTime()*3/2); + iTest->SimulateKey(TRawEvent::EKeyUp, 'A'); // Create a raw event + TheClient->iWs.Flush(); + AddExpectedKey(1, repKeyEvent.iScanCode, repKeyEvent.iCode, repKeyEvent.iRepeats, repKeyEvent.iModifiers);// Expect the event that was created above + AddExpectedKey(1, keyEvent.iScanCode, keyEvent.iCode, keyEvent.iRepeats, keyEvent.iModifiers);// Expect the event that was created above + AddExpectedKey(EEventKeyDown, 'A'); + AddExpectedKey(EEventKey,'A','a'); + AddExpectedKey(EEventKey,'A','a',1); + AddExpectedKey(EEventKeyUp, 'A'); + break; + } + case 2: + { + iTest->SimulateKey(TRawEvent::EKeyDown, 'A'); // Create a raw event + TheClient->iWs.Flush(); + User::After(KeyRepeatTime()*3/2); + TheClient->iWs.SimulateKeyEvent(repKeyEvent); // Create a repeatable key event + TheClient->iWs.SimulateKeyEvent(keyEvent); // Create a non-repeatable key event + TheClient->iWs.Flush(); // Send event + iTest->SimulateKey(TRawEvent::EKeyUp, 'A'); // Create a raw event + TheClient->iWs.Flush(); + AddExpectedKey(EEventKeyDown, 'A'); + AddExpectedKey(EEventKey,'A','a'); + AddExpectedKey(EEventKey,'A','a',1); + AddExpectedKey(1, repKeyEvent.iScanCode, repKeyEvent.iCode, repKeyEvent.iRepeats, repKeyEvent.iModifiers);// Expect the event that was created above + AddExpectedKey(1, keyEvent.iScanCode, keyEvent.iCode, keyEvent.iRepeats, keyEvent.iModifiers);// Expect the event that was created above + AddExpectedKey(EEventKeyUp, 'A'); + break; + } + default: + CActiveScheduler::Stop(); + break; + } + TheClient->iWs.Flush(); + } + +CTBlankWindow* CTEventTest::NewBlueForgroundWindowL() + { + CTBlankWindow* window; + window=new (ELeave) CTBlankWindow; + CleanupStack::PushL(window); + window->ConstructL(*iQueueClient->iGroup); + User::LeaveIfError(window->BaseWin()->SetRequiredDisplayMode(EColor256)); + CleanupStack::Pop(window); + + window->SetColor(KRgbBlue); + window->SetExt(TPoint(40, 40), TSize(40,40)); + window->BaseWin()->SetOrdinalPosition(0); + return window; + } + +CTBlankWindow* CTEventTest::NewBlueForgroundWindow() + { + CTBlankWindow* window = NULL; + TRAPD(err, window=NewBlueForgroundWindowL()); + if (err != KErrNone) + Failed(); + return window; + } + +#ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS +#ifndef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA +static void CreateSurfaceAttributes(RSurfaceManager::TSurfaceCreationAttributesBuf& aBuffer , const TSize& aSize) + { + RSurfaceManager::TSurfaceCreationAttributes& b = aBuffer(); + + b.iSize.iWidth = aSize.iWidth; + b.iSize.iHeight = aSize.iHeight; + b.iBuffers = 1; // number of buffers in the surface + b.iPixelFormat = EUidPixelFormatARGB_8888; + b.iStride = aSize.iWidth * 4; // Number of bytes between start of one line and start of next + b.iOffsetToFirstBuffer = 0; // way of reserving space before the surface pixel data + b.iAlignment = 4; // alignment, 1,2,4,8 byte aligned + b.iContiguous = EFalse; + b.iMappable = ETrue; + } + +static const TInt KFullyVisible = TWsVisibilityChangedEvent::EPartiallyVisible | TWsVisibilityChangedEvent::EFullyVisible; + +void CTEventTest::SurfaceVisibilityChanged1_NextSetOfEventsL() + { + switch(iEventSet++) + { + case 0: + { + //Setup + LOG_MESSAGE(_L("case 0")); + TInt err = iSurfaceManager.Open(); + if (err != KErrNone) + { + RDebug::Printf("RSurfaceManager::Open() failed", err); + User::Leave(err); + } + + iVisWins1=NewBlueForgroundWindowL(); + iVisWins1->Activate(); + iVisWins1->BaseWin()->EnableVisibilityChangeEvents(); + + AddExpectedEvent(EEventFocusGained); + AddExpectedVisibilityChange(KFullyVisible, iVisWins1); + break; + } + case 1: + { + LOG_MESSAGE(_L("case 1")); + iVisWins2=NewBlueForgroundWindowL(); // will cover iVisWins1 + iVisWins2->BlankWin()->SetColor(); //remove colour to ensure window does not draw to UI layer + iVisWins2->Activate(); + + AddExpectedVisibilityChange(TWsVisibilityChangedEvent::ENotVisible, iVisWins1); + break; + } + case 2: + { + // This case contains the actual test GRAPHICS-WSERV-2669-0015 + LOG_MESSAGE(_L("case 2")); + RSurfaceManager::TSurfaceCreationAttributesBuf surfaceBuf; + CreateSurfaceAttributes(surfaceBuf, iVisWins2->BaseWin()->Size()); + + iSurfaceId = TSurfaceId::CreateNullId(); + TInt err = iSurfaceManager.CreateSurface(surfaceBuf, iSurfaceId); + if (err != KErrNone) + { + RDebug::Printf("RSurfaceManager::CreateSurface() error: %d", err); + TEST(EFalse); + } + + err = iVisWins2->BaseWin()->SetBackgroundSurface(iSurfaceId); + if (err != KErrNone) + { + RDebug::Printf("RWindow::SetBackgroundSurface() error: %d", err); + TEST(EFalse); + } + + iVisWins2->BaseWin()->SetSurfaceTransparency(ETrue); //iVisWins1 will become visible + + AddExpectedVisibilityChange(KFullyVisible, iVisWins1); + break; + } + default: + LOG_MESSAGE(_L("default")); + if (!iSurfaceId.IsNull()) + { + iSurfaceManager.CloseSurface(iSurfaceId); + iSurfaceId = TSurfaceId::CreateNullId(); + } + iSurfaceManager.Close(); + delete iVisWins1; + iVisWins1 = NULL; + delete iVisWins2; + iVisWins2 = NULL; + CActiveScheduler::Stop(); + break; + } + TheClient->iWs.Flush(); + } + +void CTEventTest::SurfaceVisibilityChanged2_NextSetOfEventsL() + { + switch (iEventSet++) + { + case 0: + { + //Win1 - bottom window + //Win2 - middle window with semi-transparent background surface, which totally obscures win1 + LOG_MESSAGE(_L("case 0")); + TInt err = iSurfaceManager.Open(); + if (err != KErrNone) + { + RDebug::Printf("RSurfaceManager::Open() failed", err); + User::Leave(err); + } + + iVisWins1 = NewBlueForgroundWindowL(); + iVisWins1->BaseWin()->EnableVisibilityChangeEvents(); + + iVisWins2 = NewBlueForgroundWindowL(); + iVisWins2->BlankWin()->SetColor(); //remove colour to ensure window does not draw to UI layer + iVisWins2->BaseWin()->EnableVisibilityChangeEvents(); + + iVisWins1->Activate(); //obscured + iVisWins2->Activate(); //visible + + // Create surface for background window + RSurfaceManager::TSurfaceCreationAttributesBuf surfaceBuf; + CreateSurfaceAttributes(surfaceBuf, iVisWins2->BaseWin()->Size()); + + iSurfaceId = TSurfaceId::CreateNullId(); + err = iSurfaceManager.CreateSurface(surfaceBuf, iSurfaceId); + if (err != KErrNone) + { + RDebug::Printf("RSurfaceManager::CreateSurface() error: %d", err); + TEST(EFalse); + } + + err = iVisWins2->BaseWin()->SetBackgroundSurface(iSurfaceId); + if (err != KErrNone) + { + RDebug::Printf("RWindow::SetBackgroundSurface() error: %d", err); + TEST(EFalse); + } + + iVisWins2->BaseWin()->SetSurfaceTransparency(ETrue); //win1 and win2 both visible + + AddExpectedEvent(EEventFocusGained); + AddExpectedVisibilityChange(KFullyVisible, iVisWins2); + AddExpectedVisibilityChange(KFullyVisible, iVisWins1); + break; + } + case 1: + { + //Win3 - opaque top window which obscures win2 and win1 + LOG_MESSAGE(_L("case 1")); + iVisWins3 = NewBlueForgroundWindowL(); + iVisWins3->SetColor(KRgbRed); + iVisWins3->Activate(); + + AddExpectedVisibilityChange(TWsVisibilityChangedEvent::ENotVisible, iVisWins2); + AddExpectedVisibilityChange(TWsVisibilityChangedEvent::ENotVisible, iVisWins1); + break; + } + case 2: + { + //This case contains the actual test GRAPHICS-WSERV-2669-0016 + LOG_MESSAGE(_L("case 2")); + delete iVisWins3; + iVisWins3 = NULL; + + AddExpectedVisibilityChange(KFullyVisible, iVisWins2); + AddExpectedVisibilityChange(KFullyVisible, iVisWins1); + break; + } + default: + LOG_MESSAGE(_L("default")); + if (!iSurfaceId.IsNull()) + { + iSurfaceManager.CloseSurface(iSurfaceId); + iSurfaceId = TSurfaceId::CreateNullId(); + } + iSurfaceManager.Close(); + delete iVisWins1; + iVisWins1 = NULL; + delete iVisWins2; + iVisWins2 = NULL; + delete iVisWins3; + iVisWins3 = NULL; + CActiveScheduler::Stop(); + return; + } + TheClient->iWs.Flush(); + } + +TInt CTEventTest::GenerateAnEvent(TAny* aEventTest) + { + CTEventTest* self = static_cast(aEventTest); + self->LogMessage(((TText8*)__FILE__), __LINE__,_L("Negative test passed OK - no event was generated.")); + //Now we must generate an event to get CTQueueTestEvent out of its wait loop + self->SimulateRepeatEvent(32); + self->AddExpectedKey(EEventKey, 32); + return KErrNone; + } + +void CTEventTest::SurfaceVisibilityChanged3_NextSetOfEventsL() + { + switch (iEventSet++) + { + case 0: + { + //Win1 - Bottom window + //Win2 - Top window with semi-transparent background surface. Does not overlap win1. + LOG_MESSAGE(_L("case 0")); + TInt err = iSurfaceManager.Open(); + if (err != KErrNone) + { + RDebug::Printf("RSurfaceManager::Open() failed", err); + User::Leave(err); + } + iTimeOutCallback = CPeriodic::NewL(CActive::EPriorityIdle); + + iVisWins1 = NewBlueForgroundWindowL(); + iVisWins1->BaseWin()->EnableVisibilityChangeEvents(); + + iVisWins2 = NewBlueForgroundWindowL(); + iVisWins2->BlankWin()->SetColor(); //remove colour to ensure window does not draw to UI layer + TPoint newPos(iVisWins1->Position() + iVisWins1->Size()); + iVisWins2->SetPos(newPos); //to not overlap win1 + + iVisWins1->Activate(); //upper left + iVisWins2->Activate(); //lower right + + // Create surface for background window + RSurfaceManager::TSurfaceCreationAttributesBuf surfaceBuf; + CreateSurfaceAttributes(surfaceBuf, iVisWins2->BaseWin()->Size()); + + iSurfaceId = TSurfaceId::CreateNullId(); + err = iSurfaceManager.CreateSurface(surfaceBuf, iSurfaceId); + if (err != KErrNone) + { + RDebug::Printf("RSurfaceManager::CreateSurface() error: %d", err); + TEST(EFalse); + } + + err = iVisWins2->BaseWin()->SetBackgroundSurface(iSurfaceId); + if (err != KErrNone) + { + RDebug::Printf("RWindow::SetBackgroundSurface() error: %d", err); + TEST(EFalse); + } + + iVisWins2->BaseWin()->SetSurfaceTransparency(ETrue); + + AddExpectedEvent(EEventFocusGained); + AddExpectedVisibilityChange(KFullyVisible, iVisWins1); + break; + } + case 1: + { + //This case contains the actual test GRAPHICS-WSERV-2669-0017 + LOG_MESSAGE(_L("case 1")); + iVisWins2->SetPos(iVisWins1->Position()); //Win2 now overlaps Win1, but because Win2 has + //a transparent surface Win1 is still fully visible + + //Because we don't expect any events we need to generate one to avoid waiting forever. + TCallBack timeout(GenerateAnEvent, this); + iTimeOutCallback->Start(1000000, 10000000, timeout); + break; + } + default: + LOG_MESSAGE(_L("default")); + iTimeOutCallback->Cancel(); + delete iTimeOutCallback; + iTimeOutCallback = NULL; + if (!iSurfaceId.IsNull()) + { + iSurfaceManager.CloseSurface(iSurfaceId); + iSurfaceId = TSurfaceId::CreateNullId(); + } + iSurfaceManager.Close(); + delete iVisWins1; + iVisWins1 = NULL; + delete iVisWins2; + iVisWins2 = NULL; + CActiveScheduler::Stop(); + return; + } + TheClient->iWs.Flush(); + } +#endif //TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA +#endif //SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS + +void CTEventTest::VisibilityChanged_NextSetOfEventsL() + { + const TInt fullyVisible = TWsVisibilityChangedEvent::EPartiallyVisible | TWsVisibilityChangedEvent::EFullyVisible; + + switch(iEventSet++) + { + case 0: //only this case can leave + { + iQueueClient->iWin->BackedUpWin()->MaintainBackup(); + iVisWins1=NewBlueForgroundWindowL(); + iVisWins2=NewBlueForgroundWindowL(); + + iVisWins1->BaseWin()->EnableVisibilityChangeEvents(); + iVisWins1->Activate(); + iVisWins2->SetColor(KRgbGreen); + iVisWins2->SetExt(TPoint(80, 80), TSize(120,120)); + iVisWins2->Activate(); + + AddExpectedEvent(EEventFocusGained); + AddExpectedVisibilityChange(fullyVisible); + } + break; + case 1: + iVisWins1->BaseWin()->SetVisible(EFalse); + AddExpectedVisibilityChange(TWsVisibilityChangedEvent::ENotVisible); + break; + case 2: + iVisWins1->BaseWin()->SetVisible(ETrue); + AddExpectedVisibilityChange(fullyVisible); + break; + case 3: + iVisWins2->SetExt(TPoint(0,0), TSize(120,120)); + AddExpectedVisibilityChange(TWsVisibilityChangedEvent::ENotVisible); + break; + case 4: + iVisWins2->BaseWin()->SetVisible(EFalse); + AddExpectedVisibilityChange(fullyVisible); + break; + case 5: + iVisWins2->BaseWin()->SetVisible(ETrue); + AddExpectedVisibilityChange(TWsVisibilityChangedEvent::ENotVisible); + break; + case 6: + iVisWins2->SetExt(TPoint(60,60), TSize(120,120)); + AddExpectedVisibilityChange(TWsVisibilityChangedEvent::EPartiallyVisible); + break; + case 7: + iVisWins1->SetExt(TPoint(80,80), TSize(40,40)); + AddExpectedVisibilityChange(TWsVisibilityChangedEvent::ENotVisible); + break; + case 8: + iVisWins1->BaseWin()->SetOrdinalPosition(0); + AddExpectedVisibilityChange(fullyVisible); + + if(TransparencySupportedL() != KErrNone) + { + iEventSet += 2; //we shall skip set 9,10 as they work with transparency + } + break; + case 9: + { + TDisplayMode mode = EColor256; + iTransWin=CTransWindow::NewL(iQueueClient->iGroup, TRgb(255, 0, 0, 128), TRect(0,0,200,200), &mode); + iTransWin->CTWin::DrawNow(); + // it gets put at ordinal position 0 + iVisWins2->BaseWin()->SetOrdinalPosition(1); + AddExpectedVisibilityChange(TWsVisibilityChangedEvent::ENotVisible); + } + break; + case 10: + iVisWins1->BaseWin()->SetOrdinalPosition(1); + AddExpectedVisibilityChange(fullyVisible); + break; + case 11: + { + delete iVisWins1; + iVisWins1=NULL; + iVisWins1=NewBlueForgroundWindow(); + + iVisWins1->Activate(); + iVisWins1->BaseWin()->EnableVisibilityChangeEvents(); + + AddExpectedVisibilityChange(fullyVisible); + } + break; + case 12: + { + delete iVisWins1; + iVisWins1=NULL; + iVisWins1=NewBlueForgroundWindow(); + + iVisWins1->Activate(); + iVisWins1->BaseWin()->EnableVisibilityChangeEvents(); + iVisWins1->BaseWin()->SetVisible(EFalse); + + AddExpectedVisibilityChange(TWsVisibilityChangedEvent::ENotVisible); + } + break; + case 13: + { + delete iVisWins1; + iVisWins1=NULL; + iVisWins1=NewBlueForgroundWindow(); + + iVisWins1->BaseWin()->EnableVisibilityChangeEvents(); + iVisWins1->Activate(); + + AddExpectedVisibilityChange(fullyVisible); + } + break; + case 14: + { + delete iVisWins1; + iVisWins1=NULL; + iVisWins1=NewBlueForgroundWindow(); + + iVisWins1->Activate(); + iVisWins1->BaseWin()->SetVisible(EFalse); + iVisWins1->BaseWin()->EnableVisibilityChangeEvents(); + + AddExpectedVisibilityChange(TWsVisibilityChangedEvent::ENotVisible); + } + break; + default: + delete iVisWins1; + delete iVisWins2; + iVisWins1 = NULL; + iVisWins2 = NULL; + delete iTransWin; + iTransWin = NULL; + CActiveScheduler::Stop(); + break; + } + TheClient->iWs.Flush(); + } + +void CTEventTest::CheckTimeStamp_NextSetOfEventsL() + { + iQueueClient->EventQueue()->SetCheckTimeStamp(ETrue); + switch(iEventSet++) + { + case 0: + iTest->SimulateKey(TRawEvent::EKeyDown, 'A'); // Create a raw event + iTest->SimulateKey(TRawEvent::EKeyUp, 'A'); // Create a raw event + AddExpectedEvent(EEventFocusGained); + AddExpectedKey(EEventKeyDown,'A'); + AddExpectedKey(EEventKey,'A','a'); + AddExpectedKey(EEventKeyUp,'A','a'); + break; + case 1: + { + _LIT8(KMsgParam,"CheckTimeStamp"); + TBuf8<0x20> params(KMsgParam); + TInt err = TheClient->iWs.SendMessageToWindowGroup(iQueueClient->WindowGroupIdentifier(),TUid::Uid(123),params); + AddExpectedEvent(EEventMessageReady); + } + break; + default: + CActiveScheduler::Stop(); + break; + } + TheClient->iWs.Flush(); + } + +/** + * @SYMTestCaseID GRAPHICS-WSERV-0001 + * + * @SYMPREQ PREQ525 + * + * @SYMTestCaseDesc Test Capture priority of different top most windows in a Group. + * + * @SYMTestPriority Critical + * + * @SYMTestStatus Implemented + * + * @SYMTestActions Create two different top client windows under one parent window + * in a same window group. Add pointer event by clicking various position on the + * window and Simulate the pointer event. Change the pointer capture flag, capture + * priority and simulate the pointer event. + * + * @SYMTestExpectedResults In general the expected event and the window server event should + * match same event handle, type and pointer position for following cases. + * When pointer capture is disabled and capture priorities are 0, the pointer position on window1 + * window2 or parent window are same as expected. + * When pointer capture is enabled and capture priorities are 0, the pointer position on window2(which is top most now) + * is same as expected. + * When pointer capture is enabled and capture priorities of win1 is greater than win2 + * the pointer position on win1 and win2 are same as expected. + * The combination of above cases should match the general expexted result. + * + */ +void CTEventTest::PointerCapture_NextSetOfEventsL() + { +#if defined(LOGGING) + TLogMessageText logMessageText; + _LIT(KSet,"Pointer Capture SetOfEvents: %d (last=9)"); + logMessageText.Format(KSet,iEventSet); + INFO_PRINTF1(logMessageText); +#endif + switch(iEventSet++) + { + case 0: //Create two top client windows of same group + iVisWins1=new (ELeave) CTBlankWindow; + iVisWins2=new (ELeave) CTBlankWindow; + iVisWins1->ConstructL(*iQueueClient->iGroup); + iVisWins2->ConstructL(*iQueueClient->iGroup); + iVisWins1->SetColor(KRgbBlue); + iVisWins1->SetExt(iQueueClient->ChildTopLeft(),iQueueClient->ChildSize()); + iVisWins1->Activate(); + iVisWins2->SetColor(KRgbGreen); + iVisWins2->SetExt(iQueueClient->ChildTopLeft()+TPoint(15,15),iQueueClient->ChildSize()); + iVisWins2->Activate(); + iQueueClient->iWs.Flush(); + AddExpectedEvent(EEventFocusGained); + break; + case 1: //Pointer capture are disabled and priorities are 0 + iVisWins1->BaseWin()->SetPointerCapture(RWindowBase::TCaptureDisabled); + iVisWins1->BaseWin()->SetPointerCapturePriority(0); + iVisWins2->BaseWin()->SetPointerCapture(RWindowBase::TCaptureDisabled); + iVisWins2->BaseWin()->SetPointerCapturePriority(0); + AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(35,25)); //Pointer on the first window + AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(35,25)); + AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(50,30)); //Pointer on the second window(overlaping on first window) + AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(50,30)); + AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(60,50)); //Pointer on the second window + AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(60,50)); + AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(75,25)); //Pointer on the parent window + AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(75,25)); + iQueueClient->iWs.Flush(); + SimulatePointer(TRawEvent::EButton1Down,35,25); + SimulatePointer(TRawEvent::EButton1Up,35,25); + SimulatePointer(TRawEvent::EButton1Down,50,30); + SimulatePointer(TRawEvent::EButton1Up,50,30); + SimulatePointer(TRawEvent::EButton1Down,60,50); + SimulatePointer(TRawEvent::EButton1Up,60,50); + SimulatePointer(TRawEvent::EButton1Down,75,25); + SimulatePointer(TRawEvent::EButton1Up,75,25); + break; + case 2: //Pointer capture are enabled and priorities are 0 + iVisWins1->BaseWin()->SetPointerCapture(RWindowBase::TCaptureEnabled); + iVisWins2->BaseWin()->SetPointerCapture(RWindowBase::TCaptureEnabled); + iVisWins1->BaseWin()->SetPointerCapturePriority(0); + iVisWins2->BaseWin()->SetPointerCapturePriority(0); + AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(35,25),(TInt)iVisWins2); //Pointer on the first window + AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(35,25),(TInt)iVisWins2); + AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(50,30)); //Pointer on the second window(overlaping on first window) + AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(50,30)); + AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(60,50)); //Pointer on the second window + AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(60,50)); + AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(75,25),(TInt)iVisWins2); //Pointer on the parent window + AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(75,25),(TInt)iVisWins2); + iQueueClient->iWs.Flush(); + SimulatePointer(TRawEvent::EButton1Down,35,25); + SimulatePointer(TRawEvent::EButton1Up,35,25); + SimulatePointer(TRawEvent::EButton1Down,50,30); + SimulatePointer(TRawEvent::EButton1Up,50,30); + SimulatePointer(TRawEvent::EButton1Down,60,50); + SimulatePointer(TRawEvent::EButton1Up,60,50); + SimulatePointer(TRawEvent::EButton1Down,75,25); + SimulatePointer(TRawEvent::EButton1Up,75,25); + break; + case 3: //Pointer capture are enabled and priorities of win1 is higher than win2 + iVisWins1->BaseWin()->SetPointerCapture(RWindowBase::TCaptureEnabled); + iVisWins2->BaseWin()->SetPointerCapture(RWindowBase::TCaptureEnabled); + iVisWins1->BaseWin()->SetPointerCapturePriority(1); + iVisWins2->BaseWin()->SetPointerCapturePriority(0); + AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(35,25)); + AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(35,25)); + AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(50,30)); + AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(50,30)); + AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(60,50)); + AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(60,50)); + AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(75,25),(TInt)iVisWins2); + AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(75,25),(TInt)iVisWins2); + iQueueClient->iWs.Flush(); + SimulatePointer(TRawEvent::EButton1Down,35,25); + SimulatePointer(TRawEvent::EButton1Up,35,25); + SimulatePointer(TRawEvent::EButton1Down,50,30); + SimulatePointer(TRawEvent::EButton1Up,50,30); + SimulatePointer(TRawEvent::EButton1Down,60,50); + SimulatePointer(TRawEvent::EButton1Up,60,50); + SimulatePointer(TRawEvent::EButton1Down,75,25); + SimulatePointer(TRawEvent::EButton1Up,75,25); + break; + case 4: //Pointer capture are enabled and priorities of win1 is equal to win2 + iVisWins1->BaseWin()->SetPointerCapture(RWindowBase::TCaptureEnabled); + iVisWins2->BaseWin()->SetPointerCapture(RWindowBase::TCaptureEnabled); + iVisWins1->BaseWin()->SetPointerCapturePriority(1); + iVisWins2->BaseWin()->SetPointerCapturePriority(1); + AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(35,25),(TInt)iVisWins2); + AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(35,25),(TInt)iVisWins2); + AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(50,30)); + AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(50,30)); + AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(60,50)); + AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(60,50)); + AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(75,25),(TInt)iVisWins2); + AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(75,25),(TInt)iVisWins2); + iQueueClient->iWs.Flush(); + SimulatePointer(TRawEvent::EButton1Down,35,25); + SimulatePointer(TRawEvent::EButton1Up,35,25); + SimulatePointer(TRawEvent::EButton1Down,50,30); + SimulatePointer(TRawEvent::EButton1Up,50,30); + SimulatePointer(TRawEvent::EButton1Down,60,50); + SimulatePointer(TRawEvent::EButton1Up,60,50); + SimulatePointer(TRawEvent::EButton1Down,75,25); + SimulatePointer(TRawEvent::EButton1Up,75,25); + break; + case 5: //Pointer capture are enabled and priorities of win2 is higher than win1 + iVisWins1->BaseWin()->SetPointerCapture(RWindowBase::TCaptureEnabled); + iVisWins2->BaseWin()->SetPointerCapture(RWindowBase::TCaptureEnabled); + iVisWins1->BaseWin()->SetPointerCapturePriority(0); + iVisWins2->BaseWin()->SetPointerCapturePriority(1); + AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(35,25),(TInt)iVisWins2); + AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(35,25),(TInt)iVisWins2); + AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(50,30)); + AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(50,30)); + AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(60,50)); + AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(60,50)); + AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(75,25),(TInt)iVisWins2); + AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(75,25),(TInt)iVisWins2); + iQueueClient->iWs.Flush(); + SimulatePointer(TRawEvent::EButton1Down,35,25); + SimulatePointer(TRawEvent::EButton1Up,35,25); + SimulatePointer(TRawEvent::EButton1Down,50,30); + SimulatePointer(TRawEvent::EButton1Up,50,30); + SimulatePointer(TRawEvent::EButton1Down,60,50); + SimulatePointer(TRawEvent::EButton1Up,60,50); + SimulatePointer(TRawEvent::EButton1Down,75,25); + SimulatePointer(TRawEvent::EButton1Up,75,25); + break; + case 6: //Pointer capture are enabled for all groups and priorities of win1 is higher than win2 + iVisWins1->BaseWin()->SetPointerCapture(RWindowBase::TCaptureEnabled|RWindowBase::TCaptureFlagAllGroups); + iVisWins2->BaseWin()->SetPointerCapture(RWindowBase::TCaptureEnabled|RWindowBase::TCaptureFlagAllGroups); + iVisWins1->BaseWin()->SetPointerCapturePriority(1); + iVisWins2->BaseWin()->SetPointerCapturePriority(0); + AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(35,25)); + AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(35,25)); + AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(50,30)); + AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(50,30)); + AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(60,50)); + AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(60,50)); + AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(75,25),(TInt)iVisWins2); + AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(75,25),(TInt)iVisWins2); + iQueueClient->iWs.Flush(); + SimulatePointer(TRawEvent::EButton1Down,35,25); + SimulatePointer(TRawEvent::EButton1Up,35,25); + SimulatePointer(TRawEvent::EButton1Down,50,30); + SimulatePointer(TRawEvent::EButton1Up,50,30); + SimulatePointer(TRawEvent::EButton1Down,60,50); + SimulatePointer(TRawEvent::EButton1Up,60,50); + SimulatePointer(TRawEvent::EButton1Down,75,25); + SimulatePointer(TRawEvent::EButton1Up,75,25); + break; + case 7: //Pointer capture are enabled and priorities of iWin is higher than the other windows + iVisWins1->BaseWin()->SetPointerCapture(RWindowBase::TCaptureEnabled); + iVisWins2->BaseWin()->SetPointerCapture(RWindowBase::TCaptureEnabled); + iVisWins1->BaseWin()->SetPointerCapturePriority(0); + iVisWins2->BaseWin()->SetPointerCapturePriority(0); + iQueueClient->iWin->BaseWin()->SetPointerCapture(RWindowBase::TCaptureEnabled); + iQueueClient->iWin->BaseWin()->SetPointerCapturePriority(1); + AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(80,20)); //Pointer on the parent window + AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(80,20)); + AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(35,25),(TInt)iVisWins2); + AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(35,25),(TInt)iVisWins2); + AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(60,50)); + AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(60,50)); + AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(50,30)); + AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(50,30)); + AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(75,25)); + AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(75,25)); + iQueueClient->iWs.Flush(); + SimulatePointer(TRawEvent::EButton1Down,80,20); + SimulatePointer(TRawEvent::EButton1Up,80,20); + SimulatePointer(TRawEvent::EButton1Down,35,25); + SimulatePointer(TRawEvent::EButton1Up,35,25); + SimulatePointer(TRawEvent::EButton1Down,60,50); + SimulatePointer(TRawEvent::EButton1Up,60,50); + SimulatePointer(TRawEvent::EButton1Down,50,30); + SimulatePointer(TRawEvent::EButton1Up,50,30); + SimulatePointer(TRawEvent::EButton1Down,75,25); + SimulatePointer(TRawEvent::EButton1Up,75,25); + break; + case 8: //Pointer capture are enabled and priorities of iWin is 0 + iVisWins1->BaseWin()->SetPointerCapture(RWindowBase::TCaptureEnabled); + iVisWins2->BaseWin()->SetPointerCapture(RWindowBase::TCaptureEnabled); + iVisWins1->BaseWin()->SetPointerCapturePriority(1); + iVisWins2->BaseWin()->SetPointerCapturePriority(0); + iQueueClient->iWin->BaseWin()->SetPointerCapture(RWindowBase::TCaptureEnabled); + iQueueClient->iWin->BaseWin()->SetPointerCapturePriority(0); + AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(80,20),(TInt)iVisWins2); //Pointer on the parent window + AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(80,20),(TInt)iVisWins2); + AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(35,25)); + AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(35,25)); + AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(60,50)); + AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(60,50)); + AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(50,30)); + AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(50,30)); + AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(75,25),(TInt)iVisWins2); + AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(75,25),(TInt)iVisWins2); + iQueueClient->iWs.Flush(); + SimulatePointer(TRawEvent::EButton1Down,80,20); + SimulatePointer(TRawEvent::EButton1Up,80,20); + SimulatePointer(TRawEvent::EButton1Down,35,25); + SimulatePointer(TRawEvent::EButton1Up,35,25); + SimulatePointer(TRawEvent::EButton1Down,60,50); + SimulatePointer(TRawEvent::EButton1Up,60,50); + SimulatePointer(TRawEvent::EButton1Down,50,30); + SimulatePointer(TRawEvent::EButton1Up,50,30); + SimulatePointer(TRawEvent::EButton1Down,75,25); + SimulatePointer(TRawEvent::EButton1Up,75,25); + break; + case 9: //Pointer capture are enabled and with different groups + iVisWins1->BaseWin()->SetPointerCapture(RWindowBase::TCaptureEnabled|RWindowBase::TCaptureFlagAllGroups); + iVisWins2->BaseWin()->SetPointerCapture(RWindowBase::TCaptureEnabled|RWindowBase::TCaptureFlagAllGroups); + iVisWins1->BaseWin()->SetPointerCapturePriority(0); + iVisWins2->BaseWin()->SetPointerCapturePriority(0); + iQueueClient->iWin->BaseWin()->SetPointerCapture(RWindowBase::TCaptureEnabled|RWindowBase::TCaptureFlagAllGroups); + iQueueClient->iWin->BaseWin()->SetPointerCapturePriority(1); + AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(25,150),(TInt)iVisWins2); + AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(25,150),(TInt)iVisWins2); + AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(150,25),(TInt)iVisWins2); + AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(150,25),(TInt)iVisWins2); + AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(80,20)); //Pointer on the parent window + AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(80,20)); + AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(35,25),(TInt)iVisWins2); + AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(35,25),(TInt)iVisWins2); + AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(60,50)); + AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(60,50)); + AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(50,30)); + AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(50,30)); + AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(75,25)); + AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(75,25)); + iQueueClient->iWs.Flush(); + SimulatePointer(TRawEvent::EButton1Down,25,150); + SimulatePointer(TRawEvent::EButton1Up,25,150); + SimulatePointer(TRawEvent::EButton1Down,150,25); + SimulatePointer(TRawEvent::EButton1Up,150,25); + SimulatePointer(TRawEvent::EButton1Down,80,20); + SimulatePointer(TRawEvent::EButton1Up,80,20); + SimulatePointer(TRawEvent::EButton1Down,35,25); + SimulatePointer(TRawEvent::EButton1Up,35,25); + SimulatePointer(TRawEvent::EButton1Down,60,50); + SimulatePointer(TRawEvent::EButton1Up,60,50); + SimulatePointer(TRawEvent::EButton1Down,50,30); + SimulatePointer(TRawEvent::EButton1Up,50,30); + SimulatePointer(TRawEvent::EButton1Down,75,25); + SimulatePointer(TRawEvent::EButton1Up,75,25); + break; + default: + delete iVisWins1; + delete iVisWins2; + iVisWins1=NULL; + iVisWins2=NULL; + CActiveScheduler::Stop(); + break; + } + TheClient->iWs.Flush(); + } + +/** +PDEF110849 +Allocate a pointer buffer, send it some events and then disconnect. +Now fill the event queue, causing a purge. +The purge will call void CWsPointerBuffer::DiscardPointerMoveBuffer(TUint aHandle) +in which an access violation occurred because iCurrentBuffer had not been set to NULL. +*/ +void CTEventTest::PointerBufferPurge_NextSetOfEventsL() + { +#if defined(LOGGING) + TLogMessageText logMessageText; + _LIT(KSet,"PointerBufferPurge SetOfEvents: %d of 1"); + logMessageText.Format(KSet,iEventSet); + TheClient->LogMessage(logMessageText); +#endif + iTheClientFlush=TheClient->iWs.SetAutoFlush(ETrue); + iQuequeClientFlush=iQueueClient->iWs.SetAutoFlush(ETrue); + switch(iEventSet++) + { + case 0: + { + RWindowBase& win = *iQueueClient->iWin->BaseWin(); + + // Cause a connect to happen + RDebug::Print(_L("PointerBufferPurge - AllocPointerMoveBuffer()")); + win.AllocPointerMoveBuffer(10, 0); + + // Allow pen events to be received + RDebug::Print(_L("PointerBufferPurge - EnablePointerMoveBuffer()")); + win.EnablePointerMoveBuffer(); + + // Simulate some pen events + RDebug::Print(_L("PointerBufferPurge - Events")); + SimulatePointer(TRawEvent::EPointerMove,10,20); + SimulatePointer(TRawEvent::EButton1Down,10,20); + SimulatePointer(TRawEvent::EPointerMove,11,21); + SimulatePointer(TRawEvent::EButton1Up,11,21); + + // Disconnect + RDebug::Print(_L("PointerBufferPurge - FreePointerMoveBuffer()")); + win.FreePointerMoveBuffer(); + + // Send sufficient events to cause a purge to happen + for (TInt i=0; iiWs.SetAutoFlush(iTheClientFlush); + iQueueClient->iWs.SetAutoFlush(iQuequeClientFlush); + } + +/** + * @SYMTestCaseID GRAPHICS-WSERV-0025 + * + * @SYMDEF DEF085009 + * + * @SYMTestCaseDesc Test removal of event handlers mid-way through processing an event. + * + * @SYMTestPriority Critical + * + * @SYMTestStatus Implemented + * + * @SYMTestActions The following tests use RRemovable anim to replicate the removal of + * event handlers mid-way through processing an event (where an event is offered to each of the + * listed event handlers). + * + * RRemovableAnim is an anim which removes itself from the event handler list + * after receiving n events, where n is the 'lifetime' of the anim measured in events received. + * By setting the lifetimes of a number of these anims, we replicate the removal of event handlers + * mid-way through processing an event. + * + * Event set 0: + * Sends 2 events e1,e2 and expects them be received by wserv event processing. + * + * Event set 1: (Simple scenario) + * Adds 3 removable anims to event handler list + * Sets lifetimes as {1000,2,5} + * Sends 6 events + * Expected events to be received by anims: {6,2,5} + * + * Event set 2: (Manual removal and reset state) + * Manually remove all anims from event handler list + * Sends 2 events + * No events expected to be received by anims + * Resets all anims ready for next test + * + * Event set 3: (Removal of multiple anims on receipt of same event) + * Adds 10 removable anims in event handler list + * Set lifetimes: {1,5,9,3,8,8,8,10,5,2} + * Sends 12 events: + * Expected number of received events for anims: {1,5,9,3,8,8,8,10,5,2} + * + * Event set 4: (Manual removal and reset state) + * Manually remove all anims from event handler list + * Sends 2 events + * No events expected to be received by anims + * Resets all anims ready for next test + * + * Event set 5: (Addition of anims to non-empty event handler list, part 1) + * Adds 6 removable anims in the event handler list + * Set lifetimes: {1,1,1,5,5,5} + * Sends 2 events: + * Expected number of received events for anims: {1,1,1,2,2,2} + * + * Event set 6: (Addition of anims to non-empty event handler list, part 2) + * Readds first 3 anims to event handler list + * Sets lifetimes of these three anims {13,24,6} + * Sends 5 events: + * Expected number of received events for anims: {5,5,5,3,3,3} + * + * Event set 7: (Addition of anims to non-empty event handler list, part 3) + * Sends 16 events: + * Expected number of received events for anims: {8,16,1,0,0,0} + * + * Event set 8: (Manual Removal and reset state) + * Manually remove all anims from event handler list + * Sends 2 events + * No events expected to be received by anims + * Resets all anims ready for next test + * + * Event set 9: (Creating anims which again generate events.) + * Create 3 anims. One anims generates events in its OfferrawEvent function. + * Check the funtionality of ProcessRawEvent in Wserv when it is called + * recursively. Also check the fix for defect INC095892. + * + * @SYMTestExpectedResults + * All events should be received by wserv event processing + * Each anim should only receive events when (number of events received by anim) <= (lifetime of anim) + */ +void CTEventTest::EventHandlerRemoval_NextSetOfEventsL() + { +#if defined(LOGGING) + INFO_PRINTF1(_L("EventHandlerRemoval SetOfEvents: (Max=8)")); +#endif + switch(iEventSet++) + { + case 0: + #if defined(LOGGING) + INFO_PRINTF1(_L("AUTO Event Handler Removal Anim Events")); + #endif + #if defined(DETAILED) + INFO_PRINTF1(_L("No anims in event handler list")); + INFO_PRINTF1(_L(" Send 2 events")); + INFO_PRINTF1(_L(" - Expected to be received by wserv event processing")); + #endif + // Always get a focus gain at start + AddExpectedEvent(EEventFocusGained); + // All expected to be received by wserv event processing + AddExpectedKey(EEventKeyDown,32,ETrue); + AddExpectedKey(EEventKeyUp,32,ETrue); + // Send 2 events - none expected to be received by anims, + iTest->SimulateKey(TRawEvent::EKeyDown,32); + iTest->SimulateKey(TRawEvent::EKeyUp,32); + // Flush events to wserv + TheClient->iWs.Flush(); + // Create all anims for all tests in first event set because + // first event set is only place where leaving functions can be called + EventHandlerRemoval_CreateAnimsL(10); + break; + case 1: + { + #if defined(DETAILED) + INFO_PRINTF1(_L(" Add 3 removable anims to event handler list")); + INFO_PRINTF1(_L(" Set lifetimes for anims: {1000,2,5}")); + INFO_PRINTF1(_L(" Send 6 events")); + INFO_PRINTF1(_L(" - Expected number of received events for anims: {6,2,5}")); + INFO_PRINTF1(_L(" All events expected to be received by wserv event processing")); + #endif + const TInt KLifetimes [] = {1000,2,5}; + EventHandlerRemoval_PrepareAnims(KLifetimes, 3); + EventHandlerRemoval_CreateExpectedEvents(6,3); + // Flush events to wserv + TheClient->iWs.Flush(); + // Check each anim has received the expected events + EventHandlerRemoval_CheckExpectedEventsReceivedByAnims(); + } + break; + case 2: + { + // Remove all anims, check removal was successful + // and reset all anims ready for next test + EventHandlerRemoval_RemoveAndResetAllAnims(); + } + break; + case 3: + { + #if defined(DETAILED) + INFO_PRINTF1(_L(" Add 10 removable anims in event handler list")); + INFO_PRINTF1(_L(" Set lifetimes: {1,5,9,3,8,8,8,10,5,2}")); + INFO_PRINTF1(_L(" Send 12 events")); + INFO_PRINTF1(_L(" - Expected number of received events for anims:{1,5,9,3,8,8,8,10,5,2}")); + INFO_PRINTF1(_L(" All expected to be received by wserv event processing")); + #endif + const TInt KLifetimes [] = {1,5,9,3,8,8,8,10,5,2}; + + // Create anims, set lifetimes, add to event handlers and add to iRemovableAnims array + EventHandlerRemoval_PrepareAnims(KLifetimes, 10); + EventHandlerRemoval_CreateExpectedEvents(12,10); + // Flush events to wserv + TheClient->iWs.Flush(); + // Check each anim has received the expected events + EventHandlerRemoval_CheckExpectedEventsReceivedByAnims(); + } + break; + case 4: + { + // Remove all anims, check removal was successful + // and reset all anims ready for next test + EventHandlerRemoval_RemoveAndResetAllAnims(); + } + break; + case 5: + { + #if defined(DETAILED) + INFO_PRINTF1(_L(" Add 6 removable anims in event handler list")); + INFO_PRINTF1(_L(" Set lifetimes: {1,1,1,5,5,5}")); + INFO_PRINTF1(_L(" Send 2 events")); + INFO_PRINTF1(_L(" - Expected number of received events for anims:{1,1,1,2,2,2}")); + INFO_PRINTF1(_L(" All expected to be received by wserv event processing")); + #endif + const TInt KLifetimes [] = {1,1,1,5,5,5}; + + // Create anims, set lifetimes, add to event handlers and add to iRemovableAnims array + EventHandlerRemoval_PrepareAnims(KLifetimes, 6); + EventHandlerRemoval_CreateExpectedEvents(2, 6); + // Flush events to wserv + TheClient->iWs.Flush(); + // Check each anim has received the expected events + EventHandlerRemoval_CheckExpectedEventsReceivedByAnims(); + } + break; + case 6: + { + #if defined(DETAILED) + INFO_PRINTF1(_L(" Readds first 3 removable anims to event handler list")); + INFO_PRINTF1(_L(" Set lifetimes of these three anims {13,24,6}")); + INFO_PRINTF1(_L(" Send 5 events")); + INFO_PRINTF1(_L(" - Expected number of received events for anims: {5,5,5,3,3,3}")); + INFO_PRINTF1(_L(" All expected to be received by wserv event processing")); + #endif + const TInt KLifetimes [] = {13,24,6}; + + // Create anims, set lifetimes, add to event handlers and add to iRemovableAnims array + EventHandlerRemoval_PrepareAnims(KLifetimes, 3); + EventHandlerRemoval_CreateExpectedEvents(5, 6); + // Flush events to wserv + TheClient->iWs.Flush(); + // Check each anim has received the expected events + EventHandlerRemoval_CheckExpectedEventsReceivedByAnims(); + } + break; + case 7: + { + #if defined(DETAILED) + INFO_PRINTF1(_L(" Send 16 events")); + INFO_PRINTF1(_L(" - Expected number of received events for anims:{8,16,1,0,0,0}")); + INFO_PRINTF1(_L(" All expected to be received by wserv event processing")); + #endif + EventHandlerRemoval_CreateExpectedEvents(16, 3); + // Flush events to wserv + TheClient->iWs.Flush(); + // Check each anim has received the expected events + EventHandlerRemoval_CheckExpectedEventsReceivedByAnims(); + } + break; + case 8: + { + // Remove all anims, check removal was successful + // and reset all anims ready for next test + EventHandlerRemoval_RemoveAndResetAllAnims(); + } + break; + case 9: + EventHandlerRemoval_CheckRecursionOfProcessRawEvent(); + break; + case 10: + EventHandlerRemoval_AddEventHandlerMultipleTimes(); + break; + default: + #if defined(DETAILED) + INFO_PRINTF1(_L(" Test postamble")); + INFO_PRINTF1(_L(" Destroy anims")); + #endif + // Destroy anims + EventHandlerRemoval_DestroyAllAnims(); + iRemovableAnims->Close(); + delete iRemovableAnims; + iRemovableAnims = NULL; + CActiveScheduler::Stop(); + break; + } + TheClient->iWs.Flush(); + } + +/** + * Creates an array of aAnimCount anims on heap + * Assigns array to iRemovableAnims for use in rest of tests + */ +void CTEventTest::EventHandlerRemoval_CreateAnimsL(TInt aAnimCount) + { + RPointerArray* removableAnims = new (ELeave) RPointerArray(); + CleanupStack::PushL(removableAnims); + for (TInt animIndex = 0; animIndex < aAnimCount; animIndex++) + { + RRemovableAnim* anim = RRemovableAnim::NewLC(iQueueClient->iWin->BaseWin(), iAnimDll); + removableAnims->AppendL(anim); + } + CleanupStack::Pop(aAnimCount, (*removableAnims)[0]); + CleanupStack::Pop(removableAnims); + iRemovableAnims = removableAnims; + } + +/** + * Sets lifetimes of anims as specified in aLifeTimes + * Adds anims to event handler list + */ +void CTEventTest::EventHandlerRemoval_PrepareAnims(const TInt* aLifetimes, TInt aAnimCount) + { + for (TInt animIndex = 0; animIndex < aAnimCount; animIndex++) + { + RRemovableAnim* anim = (*iRemovableAnims)[animIndex]; + anim->SetEventHandlerLifetime(aLifetimes[animIndex]); + anim->AddToEventHandlers(); + } + } + +/** + * Creates aEventCount key events to be used in test + * Adds the expected event aEvent to the first aLiveAnimCount anims + * Adds expected events observed by the rest of wserv + * Simulates events on wserv + */ +void CTEventTest::EventHandlerRemoval_CreateExpectedEvents(TInt aEventCount, TInt aLiveAnimCount) + { + RArray events; + + // Add expected events to anims + for (TInt eventCount = 0; eventCount < aEventCount; eventCount++) + { + TRawEvent rawEvent; + TInt scanCode = 33 + eventCount; + // Alternate key down, key up events. + if (eventCount%2 == 0) + { + rawEvent.Set(TRawEvent::EKeyDown, scanCode); + } + else + { + rawEvent.Set(TRawEvent::EKeyUp, scanCode); + } + EventHandlerRemoval_AddExpectedEvent(rawEvent, aLiveAnimCount); + events.Append(rawEvent); + } + + // Simulates expected events + for (TInt eventCount = 0; eventCount < aEventCount; eventCount++) + { + TRawEvent event = events[eventCount]; + iTest->SimulateKey(event.Type(), event.ScanCode()); + } + + events.Close(); + } + +/** + * Adds the expected event aEvent to the first aLiveAnimCount anims + * Adds expected event observed by the rest of wserv + */ +void CTEventTest::EventHandlerRemoval_AddExpectedEvent(TRawEvent aEvent, TInt aLiveAnimCount) + { + // Add event to each of the anims + for (TInt animIndex = 0; animIndex < aLiveAnimCount; animIndex++) + { + TInt err = (*iRemovableAnims)[animIndex]->AddExpectedEvent(aEvent); + } + TInt eventType = (aEvent.Type() == TRawEvent::EKeyDown ? EEventKeyDown : EEventKeyUp); + AddExpectedKey(eventType, aEvent.ScanCode(), ETrue); + } + +/** + * Checks each anim has received the expected events + */ +void CTEventTest::EventHandlerRemoval_CheckExpectedEventsReceivedByAnims() + { + for (TInt animIndex = iRemovableAnims->Count() - 1; animIndex >= 0; animIndex--) + { + if (!(*iRemovableAnims)[animIndex]->TestPassed()) + { + Failed(); + break; + } + } + } + + +/** + * Create three anims. In the first anim's Offer raw event generate two more events + * which will call recursively the process raw event at the server side. + * The second and third anims are just removable anims. To simulate the scenario + * for the defect INC095892. If teh fix for this is defect is not supplied then + * wserv would panic for this test case. + */ +void CTEventTest::EventHandlerRemoval_CheckRecursionOfProcessRawEvent() + { + iTheClientFlush=TheClient->iWs.SetAutoFlush(ETrue); + iQuequeClientFlush=iQueueClient->iWs.SetAutoFlush(ETrue); + + // Create 3 anims + RRemovableAnim* eventRecurAnim = RRemovableAnim::NewLC(iQueueClient->iWin->BaseWin(), iAnimDll); + RRemovableAnim* removableAnim = RRemovableAnim::NewLC(iQueueClient->iWin->BaseWin(), iAnimDll); + RRemovableAnim* eventAnim = RRemovableAnim::NewLC(iQueueClient->iWin->BaseWin(), iAnimDll); + + // Add these anim as event handlers and set thier respective life time + eventRecurAnim->AddToEventHandlers(); + eventRecurAnim->SetEventHandlerLifetime(4); + + removableAnim->AddToEventHandlers(); + removableAnim->SetEventHandlerLifetime(1); + + eventAnim->AddToEventHandlers(); + eventAnim->SetEventHandlerLifetime(2); + + TRawEvent rawEvent1; + TRawEvent rawEvent2; + TRawEvent rawEvent3; + rawEvent1.Set(TRawEvent::EKeyDown, 60); + rawEvent2.Set(TRawEvent::EKeyUp, 34); + rawEvent3.Set(TRawEvent::EKeyUp, 35); + + eventRecurAnim->AddExpectedEvent(rawEvent2); + eventRecurAnim->AddExpectedEvent(rawEvent3); + + removableAnim->AddExpectedEvent(rawEvent2); + + eventAnim->AddExpectedEvent(rawEvent2); + eventAnim->AddExpectedEvent(rawEvent3); + + // Add these events to iQueueClient for testing + AddExpectedKey(EEventKeyUp, 34, ETrue); + AddExpectedKey(EEventKeyUp, 35, ETrue); + + iTest->SimulateKey(rawEvent1.Type(), rawEvent1.ScanCode()); + + CleanupStack::PopAndDestroy(3, eventRecurAnim); + + TheClient->iWs.SetAutoFlush(iTheClientFlush); + iQueueClient->iWs.SetAutoFlush(iQuequeClientFlush); + } + +/** + * Manually removes all anims from event handlers array + */ +void CTEventTest::EventHandlerRemoval_ManuallyRemoveAllAnims() + { + // Manually remove all anims from event handler list + for (TInt animIndex = iRemovableAnims->Count() - 1; animIndex >= 0; animIndex--) + { + (*iRemovableAnims)[animIndex]->RemoveFromEventHandlers(); + } + } + +/** + * Manually removes all anims from event handlers array + */ +void CTEventTest::EventHandlerRemoval_ResetAllAnims() + { + // Manually remove all anims from event handler list + for (TInt animIndex = iRemovableAnims->Count() - 1; animIndex >= 0; animIndex--) + { + (*iRemovableAnims)[animIndex]->Reset(); + (*iRemovableAnims)[animIndex]->SetEventHandlerLifetime(0); + } + } + +/** + * Manually removes all anims from event handler list + * Sends 2 events + * Checks that no events have been received by anims + * Resets all anims ready for next test + */ +void CTEventTest::EventHandlerRemoval_RemoveAndResetAllAnims() + { +#if defined(DETAILED) + INFO_PRINTF1(_L(" Manually remove all anims from event handler list")); + INFO_PRINTF1(_L(" Send 2 events: none expected to be received by anims")); + INFO_PRINTF1(_L(" All expected to be received by wserv event processing")); +#endif + // Manually remove all anims from event handler list + EventHandlerRemoval_ManuallyRemoveAllAnims(); + // All expected to be received by wserv event processing + AddExpectedKey(EEventKeyDown,32,ETrue); + AddExpectedKey(EEventKeyUp,32,ETrue); + // Send 2 events - none expected to be received by anims, + iTest->SimulateKey(TRawEvent::EKeyDown,32); + iTest->SimulateKey(TRawEvent::EKeyUp,32); + // Flush events to wserv + TheClient->iWs.Flush(); + // Check the anims have not received any events + EventHandlerRemoval_CheckExpectedEventsReceivedByAnims(); +#if defined(DETAILED) + INFO_PRINTF1(_L(" Cleanup before next step")); +#endif + // Reset anims + EventHandlerRemoval_ResetAllAnims(); + } + +/** + * Destroys all anims in iRemovableAnims + * Resets iRemovableAnims + */ +void CTEventTest::EventHandlerRemoval_DestroyAllAnims() + { + if (iRemovableAnims) + { + // Destroy anims + for (TInt animIndex = iRemovableAnims->Count() - 1; animIndex >= 0; animIndex--) + { + RRemovableAnim* anim = (*iRemovableAnims)[animIndex]; + if (anim) + { + anim->Destroy(); + } + } + iRemovableAnims->Reset(); + } + } + +/** +SYMTestCaseID GRAPHICS-WSERV-0496 + +@SYMDEF DEF133776 + +@SYMTestCaseDesc Cancels key captures using all combinations of + RWindowGroup::Capture...() and RWindowGroup::Cancel...() APIs. + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Call each of the RWindowGroup::Capture***() APIs followed by + each of the RWindowGroup::CancelCapture***() APIs. + RWindowGroup::Capture***() APIs: + CaptureKey(TUint, TUint, TUint) + CaptureKey(TUint, TUint, TUint, TInt) + CaptureKeyUpAndDowns(TUint, TUint, TUint) + CaptureKeyUpAndDowns(TUint, TUint, TUint, TInt) + CaptureLongKey(TUint, TUint, TUint, TUint, TInt, TUint) + CaptureLongKey(TTimeIntervalMicroSeconds32, TUint, TUint, TUint, TUint, TInt, TUint) + RWindowGroup::CancelCapture***() APIs: + CancelCaptureKey() + CancelCaptureKeyUpAndDowns() + CancelCaptureLongKey() + +@SYMTestExpectedResults WServ should handle matched and mismatched Cancel + and Capture calls without panicking. + */ +void CTEventTest::MismatchedCapture_NextSetOfEventsL() + { + if (iEventSet == 0) + AddExpectedEvent(EEventFocusGained); + + if (iEventSet < (EMaxCaptureKeyApis*EMaxCancelCaptureKeyApis)) + { + TestCaptureAndCancelCapturePair(static_cast(iEventSet%EMaxCaptureKeyApis), static_cast(iEventSet/EMaxCaptureKeyApis)); + iEventSet++; + } + else + { + CActiveScheduler::Stop(); + } + } + +/** Helper function that applies a key capture and then cancels it using the +passed capture and cancel RWindowGroup APIs. + +@param aCaptureApi Enum value specifying the capture API to use +@param aCancelCaptureApi Enum value specifying the cancel capture API to use + */ +void CTEventTest::TestCaptureAndCancelCapturePair(TCaptureKeyApis aCaptureApi, TCancelCaptureKeyApis aCancelCaptureApi) + { +#if defined(LOGGING) + _LIT(KCaptureKey, "CaptureKey"); + _LIT(KCaptureKeyKeyUpAndDowns, "CaptureKeyKeyUpAndDowns"); + _LIT(KCaptureLongKey, "CaptureLongKey"); + _LIT(KCancelCaptureKey, "CancelCaptureKey"); + _LIT(KCancelCaptureKeyKeyUpAndDowns, "CancelCaptureKeyKeyUpAndDowns"); + _LIT(KCancelCaptureLongKey, "CancelCaptureLongKey"); + _LIT(KLog,"TestCaptureAndCancelCapturePair: %S, %S"); + TPtrC captures[EMaxCaptureKeyApis] = {KCaptureKey(), KCaptureKey(), KCaptureKeyKeyUpAndDowns(), KCaptureKeyKeyUpAndDowns(), KCaptureLongKey(), KCaptureLongKey()}; + TPtrC cancelCaptures[EMaxCancelCaptureKeyApis] = {KCancelCaptureKey(), KCancelCaptureKeyKeyUpAndDowns(), KCancelCaptureLongKey()}; + TLogMessageText logMessageText; + logMessageText.Format(KLog, &captures[aCaptureApi], &cancelCaptures[aCancelCaptureApi]); + INFO_PRINTF1(logMessageText); +#endif // LOGGING + + // Start a key capture using one of the six RWindowGroup Capture***() APIs + switch (aCaptureApi) + { + case ECaptureKey1: + case ECaptureKey2: + // Test RWindowGroup::CaptureKey() + if (aCaptureApi == ECaptureKey1) + iCaptureKey = iQueueClient->iGroup->GroupWin()->CaptureKey('A',0,0); + else + iCaptureKey = iQueueClient->iGroup->GroupWin()->CaptureKey('A',0,0,1); // priority 1 (default priority is 0) + iTest->SimulateKey(TRawEvent::EKeyDown, 'A'); + TheClient->iWs.Flush(); + User::After(KeyRepeatTime()*3/2); + iTest->SimulateKey(TRawEvent::EKeyUp, 'A'); + TheClient->iWs.Flush(); + AddExpectedKey(EEventKeyDown, 'A'); + AddExpectedKey(EEventKey,'A','a'); + AddExpectedKey(EEventKey,'A','a',1); + AddExpectedKey(EEventKeyUp, 'A'); + break; + + case ECaptureKeyUpAndDowns1: + case ECaptureKeyUpAndDowns2: + // Test RWindowGroup::CaptureKeyUpAndDowns() + if (aCaptureApi == ECaptureKeyUpAndDowns1) + iCaptureKey=iQueueClient->iGroup->GroupWin()->CaptureKeyUpAndDowns(EStdKeySpace,0,0); + else + iCaptureKey=iQueueClient->iGroup->GroupWin()->CaptureKeyUpAndDowns(EStdKeySpace,0,0,1); // priority 1 (default priority is 0) + iTest->SimulateKey(TRawEvent::EKeyDown,EStdKeySpace); + TheClient->iWs.Flush(); + User::After(KeyRepeatTime()*3/2); + iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeySpace); + TheClient->iWs.Flush(); + AddExpectedKey(EEventKeyDown,EStdKeySpace); + AddExpectedKey(EEventKey,EStdKeySpace,' '); + AddExpectedKey(EEventKey,EStdKeySpace,' ',1); + AddExpectedKey(EEventKeyUp,EStdKeySpace); + break; + + case ECaptureLongKey1: + case ECaptureLongKey2: + { + // Test RWindowGroup::CaptureLongKey() + TTimeIntervalMicroSeconds32 repeat = KeyRepeatTime(); + if (aCaptureApi == ECaptureLongKey1) + { + iCaptureKey = iQueueClient->iGroup->GroupWin()->CaptureLongKey(' ', 'a', 0, 0, 2, ELongCaptureNormal); + } + else + { + repeat = KeyRepeatTime()/2; + iCaptureKey = iQueueClient->iGroup->GroupWin()->CaptureLongKey(repeat, ' ', 'a', 0, 0, 2, ELongCaptureNormal); + } + iQueueClient->iWs.Flush(); + iTest->SimulateKey(TRawEvent::EKeyDown,EStdKeySpace); + TheClient->iWs.Flush(); + User::After(KeyRepeatTime()*3/2); + iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeySpace); + TheClient->iWs.Flush(); + AddExpectedKey(EEventKeyDown,EStdKeySpace); + AddExpectedKey(EEventKey,EStdKeySpace,' '); + AddExpectedKey(EEventKey,EStdKeySpace,'a',1); + AddExpectedKey(EEventKeyUp,EStdKeySpace); + } + break; + + default: + INFO_PRINTF1(_L("Unexpected TCaptureKeyApis value passed to CTEventTest::TestCaptureAndCancelCapturePair()")); + TEST(EFalse); + break; + } + + if (iCaptureKey) + { + // End a capture using one of the three RWindowGroup CancelCapture***() APIs, + // for each Capture***() API each one of these will be called, therefore there will + // be one correct CancelCapture***() APIs called and two incorrect CancelCapture***() + // APIs called for each Capture***() API. + switch (aCancelCaptureApi) + { + case ECancelCaptureKey: + iQueueClient->iGroup->GroupWin()->CancelCaptureKey(iCaptureKey); + break; + case ECancelCaptureKeyUpAndDowns: + iQueueClient->iGroup->GroupWin()->CancelCaptureKeyUpAndDowns(iCaptureKey); + break; + case ECancelCaptureLongKey: + iQueueClient->iGroup->GroupWin()->CancelCaptureLongKey(iCaptureKey); + break; + default: + INFO_PRINTF1(_L("Unexpected TCancelCaptureKeyApis value passed to CTEventTest::TestCaptureAndCancelCapturePair()")); + TEST(EFalse); + break; + } + + // If an mistmatched CancelCapture***() API was called, call the correct one now + // to make sure the Capture/CancelCapture state is clean before the next test starts + if ((aCaptureApi/2) != aCancelCaptureApi) + { + switch (aCaptureApi) + { + case ECaptureKey1: + case ECaptureKey2: + iQueueClient->iGroup->GroupWin()->CancelCaptureKey(iCaptureKey); + break; + case ECaptureKeyUpAndDowns1: + case ECaptureKeyUpAndDowns2: + iQueueClient->iGroup->GroupWin()->CancelCaptureKeyUpAndDowns(iCaptureKey); + break; + case ECaptureLongKey1: + case ECaptureLongKey2: + iQueueClient->iGroup->GroupWin()->CancelCaptureLongKey(iCaptureKey); + break; + } + } + } + + TheClient->iWs.Flush(); + } + +/*void CTEventTest::_NextSetOfEvents() //Template for these functions + { + switch(iEventSet++) + { + case 0: + iQueueClient->iWin->WinTreeNode()->; //Set up window + iQueueClient->iWin->BaseWin()->; + iQueueClient->iGroup->GroupWin()->; + iQueueClient->iWs.Flush(); //Make take effect + SimulateEvent(TRawEvent::); //Create an event + TheClient->iWs.Flush(); //Send event + AddExpectedEvent(EEventFocusGained); //Always get a focus gain at start + AddExpectedEvent(); //Expect the event that was created above + break; + case 1: + iQueueClient->iWs.Flush(); + SimulateEvent(TRawEvent::); + TheClient->iWs.Flush(); + AddExpectedEvent(); + break; + default: + CActiveScheduler::Stop(); + break; + } + TheClient->iWs.Flush(); + }*/ + +/** + @SYMTestCaseID GRAPHICS-WSERV-CODEBASE-WSERV-0051 + + @SYMPREQ PGM027 + + @SYMTestCaseDesc Tests SetKeyboardRepeatRate API. + + @SYMTestPriority 1 + + @SYMTestStatus Implemented + + @SYMTestActions This test tryes to call SetKeyboardRepeatRate with invalid time values\n + + @SYMTestExpectedResults KeyRepeatRateNegTest should tests the API SetKeyboardRepeatRate return value\n + The test should pass and API should return KErrArgument. + + */ +void CTEventTest::KeyRepeatRateNegTest(TInt aInitialRepeat, TInt aRepeat) + { + ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-CODEBASE-WSERV-0051")); + TInt ret=TheClient->iWs.SetKeyboardRepeatRate(TTimeIntervalMicroSeconds32(aInitialRepeat), TTimeIntervalMicroSeconds32(aRepeat)); + TEST(ret==KErrArgument); + TRAPD(err,((CTEventTestStep*)iStep)->RecordTestResultL()); + if (err!=KErrNone) + INFO_PRINTF1(_L("Failed to record test result")); + } + +void CTEventTest::RunTestsL(TBool aNeedChildWindows/*=EFalse*/) + { + iQueueClient=new(ELeave) CTQueueClient(this); + iQueueClient->SetScreenNumber(iTest->iScreenNumber); + iQueueClient->ConstructL(aNeedChildWindows); + iEventSet=0; + TRAPD(err,NextSetOfEventsL()); + if (err!=KErrNone) + { + iFailed=ETrue; + return; + } +// + CActiveScheduler::Start(); +// + TInt eventsLeft=iQueueClient->EventQueue()->EventsLeft(); + if (eventsLeft>0) + iFailed=ETrue; + delete iVisWins1; + iVisWins1 = NULL; + delete iVisWins2; + iVisWins2 = NULL; + delete iQueueClient; + iQueueClient=NULL; + } + +void CTEventTest::RunTestsRestoreAreaL(TBool aNeedChildWindows) + { + TRect area(TheClient->iWs.PointerCursorArea()); + RunTestsL(aNeedChildWindows); + TheClient->iWs.SetPointerCursorArea(area); + } + +/*void CTEventTest::QueuePurgingL() + { + RunTestsL(EFalse); + } + +void CTEventTest::SendEventL() + { + RunTestsL(EFalse); + } + +void CTEventTest::InvisibleWindowL() + { + RunTestsL(ETrue); + } + +void CTEventTest::JavaAdditionsL() + { + RunTestsL(EFalse); + }*/ + +void CTEventTest::WindowCapBugL() + { + RunTestsL(ETrue); + } + +/*void CTEventTest::XyInputTypeL() + { + RunTestsL(EFalse); + } + +void CTEventTest::MovingPointerCursorL() + { + RunTestsRestoreAreaL(ETrue); + } + +void CTEventTest::RotatedModeL() + { + RunTestsRestoreAreaL(EFalse); + }*/ + +/** +* This test creates one anim and calls AddToEventHandlers() twenty times. +* it shouldn't add the same anim to event handler if anim is already in handler. +*/ +void CTEventTest::EventHandlerRemoval_AddEventHandlerMultipleTimes() + { + iTheClientFlush=TheClient->iWs.SetAutoFlush(ETrue); + iQuequeClientFlush=iQueueClient->iWs.SetAutoFlush(ETrue); + + RRemovableAnim* eventTestAnim = RRemovableAnim::NewLC(iQueueClient->iWin->BaseWin(), iAnimDll); + + // Call AddToEventHandlers() on same anim 20 times, it should add this anim in event handler only once + for (TInt count = 0; count < 20; count++) + eventTestAnim->AddToEventHandlers(); + eventTestAnim->SetEventHandlerLifetime(1); + + TRawEvent rawEvent1; + rawEvent1.Set(TRawEvent::EKeyUp, 34); + + eventTestAnim->AddExpectedEvent(rawEvent1); + + // Add these events to iQueueClient for testing + AddExpectedKey(EEventKeyUp, 34, ETrue); + + iTest->SimulateKey(TRawEvent::EKeyUp, 34); + + CleanupStack::PopAndDestroy(eventTestAnim); + TheClient->iWs.SetAutoFlush(iTheClientFlush); + iQueueClient->iWs.SetAutoFlush(iQuequeClientFlush); + } + +void CTEventTest::EventQueuePtrCrashTest() +// Code designed to hit the defect reported in INC109199 & INC105430, needs a very specific sequence of +// events and client disconnections to hit the exact problem state. + { + const TInt KNumTestEvents=6; + const TInt KMaxNumTestEvents=16; + // Number of iterations needs to be as high as the queue granularity to make sure at least + // once around we actually hit the code to change the queue size + const TInt KNumEvTestIterations=4; + const TInt KNumBaseTestSessions=KNumEvTestIterations+1; + const TInt KNumMainTestSessions=13; + const TInt KMaxNumSessions=KNumBaseTestSessions+KNumMainTestSessions+KNumEvTestIterations; + RWsSession wsSessions[KMaxNumSessions]; + RWindowGroup wGroups[KMaxNumSessions]; + for(TInt iterationLoop=0;iterationLoop=KNumBaseTestSessions) + { + TWsEvent event; + for(TInt evLoop=0;evLoopiWs.SendEventToWindowGroup(groupWin[0].Identifier(),event); + TheClient->iWs.SendEventToWindowGroup(groupWin[1].Identifier(),event); + } + + //To create a new client, although the queue is full, wserv will guarantee to initialize + //the queue size of the new queue to at least EMinQueueSize. So that it can response to + //the event. + RWsSession testWsSession; + RWindowGroup testGroupWin; + TRequestStatus testStatus; + if (aEventReadyCancel) + { + //Simulate the heap allocation failure to test expanding spaces by purge + //events from inactive clients when initialize queue size. + TInt failAt = 1; + TInt err; + do { + TheClient->iWs.HeapSetFail(RHeap::EFailNext, failAt++); + TheClient->iWs.Flush(); + err = testWsSession.Connect(); + TheClient->iWs.HeapSetFail(RHeap::ENone, 1); + } while (err == KErrNoMemory); + User::LeaveIfError(err); + } + else + { + User::LeaveIfError(testWsSession.Connect()); + } + CleanupClosePushL(testWsSession); + testGroupWin = RWindowGroup(testWsSession); + User::LeaveIfError(testGroupWin.Construct(cliHanGrpWin++)); + CleanupClosePushL(testGroupWin); + + //Send events to the newly created client. + // The Debug version of WServ puts a EEventFocusGained into the event + // before this test's custom event, so leave one slot in the queue + // for it. +#if (defined _DEBUG) + TInt testEventCount = EMinQueueSize - 1; +#else + TInt testEventCount = EMinQueueSize; +#endif + for(TInt evLoop = 0; evLoop < testEventCount; evLoop++) + { + event.SetType(3001 + evLoop); + TheClient->iWs.SendEventToWindowGroup(testGroupWin.Identifier(),event); + } + + //Check the event queue. + //Having a timer here to avoid infinitely wait for event. + TInt expectedEvent = 3001; + for(TInt evLoop = 0; evLoop < EMinQueueSize; evLoop++) + { + testWsSession.EventReady(&testStatus); + TRequestStatus timerStatus; + timer.After(timerStatus, oneSecond); + User::WaitForRequest(testStatus, timerStatus); + TEST(testStatus == 0); + if (testStatus == 0) + { + // Tests the event + testWsSession.GetEvent(event); + // WServ sometimes puts a EEventFocusGained event into the queue + // before the test's custom event, so ignore it. + if (event.Type() != EEventFocusGained) + { + TEST(event.Type() == expectedEvent); + expectedEvent++; + } + // testStatus has been completed. Cancel the timer. + timer.Cancel(); + User::WaitForRequest(timerStatus); + } + else + { + // Times out, cancel the event notification + testWsSession.EventReadyCancel(); + User::WaitForRequest(testStatus); + } + } + CleanupStack::PopAndDestroy(2*numClients + 2, &wsSession[0]); + } + CleanupStack::PopAndDestroy(&timer); + } + +void CTEventTest::SimulateRepeatEvent(TInt aScanCode, TInt aRepeats/*=0*/) + { + TRawEvent rawEvent; + if (aRepeats) + rawEvent.Set(TRawEvent::EKeyRepeat, aScanCode, aRepeats); + else + rawEvent.Set(TRawEvent::EKeyRepeat, aScanCode); + UserSvr::AddEvent(rawEvent); + } + +void CTEventTest::RawEventRepeatTest_NextSetOfEventsL() + { + switch(iEventSet++) + { + case 0: + // Tests EKeyRepeat without repeat value set. + SimulateRepeatEvent(32); + + // Tests EKeyRepeat with repeat value set to 2. + SimulateRepeatEvent(33,2); + + AddExpectedEvent(EEventFocusGained); + AddExpectedKey(EEventKey, 32); + AddExpectedKey(EEventKey, 33, 0, 2); + break; + default: + CActiveScheduler::Stop(); + break; + } + TheClient->iWs.Flush(); + } + +void CTEventTest::RunTestCaseL(TInt /*aCurTestCase*/) + { + _LIT(KTest0,"General 1"); + _LIT(KTest1,"Event queue purging"); + _LIT(KTest2,"SendEvent"); + _LIT(KTest3,"SendEventToAll"); + _LIT(KTest4,"InvisibleWindow"); + _LIT(KTest5,"JavaAdditions"); + _LIT(KTest6,"WindowCaptureBug"); + _LIT(KTest7,"XYInput Types"); + _LIT(KTest8,"MovingPointerCursor"); + _LIT(KTest9,"Rotated Modes"); + _LIT(KTest10,"Anim Event"); + _LIT(KTest11,"Focus Changed"); + _LIT(KTest12,"On/Off Events"); + _LIT(KTest13,"Virtual Keyboard"); + _LIT(KTest14,"Key Clicks"); + _LIT(KTest15,"Capture Long"); + _LIT(KTest16,"Password Window"); + _LIT(KTest17,"Group List Changed"); + _LIT(KTest18,"Repeatable Key Events"); + _LIT(KTest19,"Screen Scaling"); + _LIT(KTest20,"Visibility Changed Events"); + _LIT(KTest21,"Check Time Stamp Of Events"); + _LIT(KTest22,"Pointer Capture Priority Events"); + _LIT(KTest23,"Event Handler Removal"); + _LIT(KTest24,"Event Queue ptr crash test"); + _LIT(KTest25,"Mismatched Pointer Events"); + _LIT(KTest26,"Pointer Buffer Purge"); + _LIT(KTest27,"TRawEvent test for Repeats"); +#ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS +#ifndef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + _LIT(KTest28,"Transparent Surface Visibility Changed Events 1"); + _LIT(KTest29,"Transparent Surface Visibility Changed Events 2"); + _LIT(KTest30,"Transparent Surface Visibility Changed Events 3"); +#endif // TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA +#endif // SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS + _LIT(KTest31A,"Initialize Queue Size without inactive queue"); + _LIT(KTest31B,"Initialize Queue Size with inactive queue"); + + if (!TestBase()->ConfigurationSupportsPointerEventTesting()) + { + INFO_PRINTF1(_L("Test skipped because config does not support pointer event testing")); + TestComplete(); + return; + } + + //if (iTest->iState==1) iTest->iState=14; //Use this line to skip to a particular test + ((CTEventTestStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); + switch(iTest->iState) + { +/** +@SYMTestCaseID GRAPHICS-WSERV-0053 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Carry out general event tests on WServ + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions General events are sent via WServ + +@SYMTestExpectedResults The events are sent without error +*/ + case 0: + iTest->LogSubTest(KTest0); + General(); + ((CTEventTestStep*)iStep)->SetOverallTestStepID(_L("GRAPHICS-WSERV-0053")); + //iState=8; + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0054 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Carry out event queue purging + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Purge the event queue + +@SYMTestExpectedResults The events queue is purged without error +*/ + case 1: + ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0054")); + iTest->LogSubTest(KTest1); + RunTestsL(); //QueuePurgingL(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0055 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test that events can be sent + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Send events in WServ + +@SYMTestExpectedResults The events are sent without error +*/ + case 2: + ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0055")); + iTest->LogSubTest(KTest2); + RunTestsL(); //SendEventL(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0056 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Send an event to all window groups + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Send an event to all window groups + +@SYMTestExpectedResults The events are sent to all window groups + without error +*/ + case 3: + ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0056")); + iTest->LogSubTest(KTest3); + General2(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0057 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Send events to an invisible window + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Send events to an invisible window + +@SYMTestExpectedResults The events are sent to the window without + error +*/ + case 4: + ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0057")); + iTest->LogSubTest(KTest4); + RunTestsL(ETrue); //InvisibleWindowL(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0058 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Send events for java additions + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Send events for java additions + +@SYMTestExpectedResults The events are sent to the window without + error +*/ + case 5: + ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0058")); + iTest->LogSubTest(KTest5); + RunTestsL(); //JavaAdditionsL(); + break; + + case 6: + ((CTEventTestStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + iTest->LogSubTest(KTest6); + //WindowCapBugL(); //Not finished + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0059 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Send events for x and y inputs + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Send events for x and y inputs + +@SYMTestExpectedResults The events are sent to the window without + error +*/ + case 7: + ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0059")); + iTest->LogSubTest(KTest7); + RunTestsL(); //XyInputTypeL(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0060 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Send events for moving pointer cursor + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Send events for moving pointer cursor + +@SYMTestExpectedResults The events are sent to the window without + error +*/ + case 8: + ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0060")); + iTest->LogSubTest(KTest8); + RunTestsRestoreAreaL(ETrue); //MovingPointerCursorL(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0061 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Send events for rotate mode + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Send events for rotate mode + +@SYMTestExpectedResults The events are sent to the window without + error +*/ + case 9: + ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0061")); + iTest->LogSubTest(KTest9); + RunTestsRestoreAreaL(EFalse); //RotatedModeL(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0062 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Send events for an anim event + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Send events for an anim event + +@SYMTestExpectedResults The events are sent to the window without + error +*/ + case 10: + ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0062")); + iTest->LogSubTest(KTest10); + RunTestsRestoreAreaL(EFalse); //AnimEvent(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0063 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Send events for focus changed + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Send events for focus changed + +@SYMTestExpectedResults The events are sent to the window without + error +*/ + case 11: + ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0063")); + iTest->LogSubTest(KTest11); + RunTestsL(); //FocusChanged(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0064 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Send stop events + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Send stop events + +@SYMTestExpectedResults The events are sent to the window without + error +*/ + case 12: + ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0064")); + iTest->LogSubTest(KTest12); + RunTestsL(ETrue); //StopEvents(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0065 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Send events for the virtual keyboard + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Send events for the virtual keyboard + +@SYMTestExpectedResults The events are sent to the window without + error +*/ + case 13: + ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0065")); + iTest->LogSubTest(KTest13); + RunTestsL(); //VirtualKeyboard(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0066 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Send events for key clicks + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Send stop events + +@SYMTestExpectedResults The events are sent to the window without + error +*/ + case 14: + ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0066")); + iTest->LogSubTest(KTest14); + { + TBool changeable; + if (iClick.IsLoaded(changeable) && !iTest->IsFullRomL()) + RunTestsL(ETrue); //KeyClicks(); + } + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0067 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Send events for capturing large areas of text + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Send events for capturing large areas of text + +@SYMTestExpectedResults The events are sent to the window without + error +*/ + case 15: + ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0067")); + iTest->LogSubTest(KTest15); + RunTestsL(ETrue); //CaptureLong(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0068 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Send events for activating password + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Send events for activating password + +@SYMTestExpectedResults The events are sent to the window without + error +*/ + case 16: + ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0068")); + iTest->LogSubTest(KTest16); + if (!iTest->IsFullRomL()) + RunTestsL(); //Password(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0069 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Send events for activating password + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Send events for activating password + +@SYMTestExpectedResults The events are sent to the window without + error +*/ + case 17: + ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0069")); + iTest->LogSubTest(KTest17); + RunTestsL(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0070 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Send repeatable key events + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Send repeatable key events + +@SYMTestExpectedResults The events are sent to the window without + error +*/ + case 18: + ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0070")); + iTest->LogSubTest(KTest18); + RunTestsL(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0071 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Send Screen Scaling events + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Send Screen Scaling events + +@SYMTestExpectedResults The events are sent to the window without + error +*/ + case 19: + ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0071")); + iTest->LogSubTest(KTest19); + if (iScreenModeTests&EDoScale) + { + RunTestsL(); + } + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0072 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Send Visibility Changed events + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Send Visibility Changed events + +@SYMTestExpectedResults The events are sent to the window without + error +*/ + case 20: + ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0072")); + iTest->LogSubTest(KTest20); + RunTestsL(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0073 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Check Time Stamp Of Sent Events + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Check Time Stamp Of Sent Events + +@SYMTestExpectedResults The time stamps for the events are correct +*/ + case 21: + ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0073")); + iTest->LogSubTest(KTest21); + RunTestsL(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0074 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Send Pointer Capture Priority Events + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Send Pointer Capture Priority Events + +@SYMTestExpectedResults The events are sent to the window without + error +*/ + case 22: + ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0074")); + iTest->LogSubTest(KTest22); + RunTestsL(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0343 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Send Event Handler Removal Events + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Send Event Handler Removal Events + +@SYMTestExpectedResults The events are sent to the window without + error +*/ + case 23: + ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0343")); + iTest->LogSubTest(KTest23); + RunTestsL(); //EventHandlerRemoval(); + break; + case 24: +/** +@SYMTestCaseID GRAPHICS-WSERV-0565 +*/ + ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0565")); + iTest->LogSubTest(KTest24); + EventQueuePtrCrashTest(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0496 + +@SYMDEF DEF133776 + +@SYMTestCaseDesc Cancels key captures using all combinations of + RWindowGroup::Capture...() and RWindowGroup::Cancel...() APIs. + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Call each of the RWindowGroup::Capture***() APIs followed by + each of the RWindowGroup::CancelCapture***() APIs. + RWindowGroup::Capture***() APIs: + CaptureKey(TUint, TUint, TUint) + CaptureKey(TUint, TUint, TUint, TInt) + CaptureKeyUpAndDowns(TUint, TUint, TUint) + CaptureKeyUpAndDowns(TUint, TUint, TUint, TInt) + CaptureLongKey(TUint, TUint, TUint, TUint, TInt, TUint) + CaptureLongKey(TTimeIntervalMicroSeconds32, TUint, TUint, TUint, TUint, TInt, TUint) + RWindowGroup::CancelCapture***() APIs: + CancelCaptureKey() + CancelCaptureKeyUpAndDowns() + CancelCaptureLongKey() + +@SYMTestExpectedResults WServ should handle matched and mismatched Cancel + and Capture calls without panicking. +*/ + case 25: +// Skip this test in debug on the emulator, run it always on hardware as debug ROMs include +// a release version of the production code that doesn't panic + ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0496")); +#if defined(_DEBUG) && !defined (__MARM__) + INFO_PRINTF1(_L("Skipping this test in _DEBUG on emulator to avoid debug only panics, see GRAPHICS-WSERV-0497 for the matching panic test")); +#else + iTest->LogSubTest(KTest25); + RunTestsL(); +#endif + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0444 + +@SYMDEF PDEF110849 + +@SYMTestCaseDesc Pointer Buffer Exception After Event Queue Purge + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Connect to pointer buffer, send it some pointer events and disconnect. + Now send enough events to cause an event queue purge. The purge will + attempt to empty the pointer buffer, but will fail because we have disconnected. + +@SYMTestExpectedResults The purge will realise it does not need to empty the pointer buffer and + so there will not be an access violation - exception. + +*/ + case 26: + ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0444")); + iTest->LogSubTest(KTest26); + RunTestsL(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0484 +@SYMDEF PDEF120721 +@SYMTestCaseDesc Window server guarantees to initialize the queue size of the new queue to + at least EMinQueueSize. +@SYMTestPriority High +@SYMTestStatus Implemented +@SYMTestActions Create multiple clients to connect to window server. + Send enough events to make the event queue full. + Create a new client to connect to window server. + Send events to the new client and test that the new client + can get the events. +@SYMTestExpectedResults Window server guarantees to initialize the size of the new event + queue to EMinQueueSize, so that window server will not lock up + due to the full of global event queue. + +*/ + case 27: + iTest->LogSubTest(KTest27); + RunTestsL(); + break; + +#ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS +#ifndef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA +/** +@SYMTestCaseID GRAPHICS-WSERV-2669-0015 +@SYMREQ REQ13202: Possibility for external layers to appear above UI layer +@SYMTestCaseDesc Window obscured by transparent surface window receives + (EPartiallyVisible | EFullyVisible) when surface is made semi-transparent. +@SYMTestPriority 2 +@SYMPrerequisites Win1 – bottom window + Win2 – middle window with background surface, which totally obscures win1 +@SYMTestActions Call SetSurfaceTransparency(ETrue) on win2 +@SYMTestExpectedResults Win1 receives visibility event +*/ + case 28: + ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-2669-0015")); + iTest->LogSubTest(KTest28); + RunTestsL(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-2669-0016 +@SYMREQ REQ13202: Possibility for external layers to appear above UI layer +@SYMTestCaseDesc Window obscured by semi-transparent surface window receives + (EPartiallyVisible | EFullyVisible) when obscuring window is deleted +@SYMTestPriority 2 +@SYMPrerequisites Win1 – bottom window + Win2 – middle window with semi-transparent background surface, which totally obscures win1 + Win3 – top window which totally obscures win2, and is opaque +@SYMTestActions Delete win3 +@SYMTestExpectedResults Both win1 and win2 receive visibility events +*/ + case 29: + ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-2669-0016")); + iTest->LogSubTest(KTest29); + RunTestsL(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-2669-0017 +@SYMREQ REQ13202: Possibility for external layers to appear above UI layer +@SYMTestCaseDesc Window does not receive any visibiliy event when a semi-transparent + surface is moved onto/above it. +@SYMTestPriority 2 +@SYMPrerequisites Win1 – bottom window + Win2 – top window which does not overlap win1 +@SYMTestActions Move win2 to overlap win1 +@SYMTestExpectedResults No visibility event is received (win1 is still fully visible) +*/ + case 30: + ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-2669-0017")); + iTest->LogSubTest(KTest30); + RunTestsL(); + break; +#endif // TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA +#endif // SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS + +/** +@SYMTestCaseID GRAPHICS-WSERV-0559 +@SYMDEF INC140850 +@SYMTestCaseDesc To check Wserv passes correct repeat value for TRawEvent of type EKeyRepeat. +@SYMTestPriority High +@SYMTestStatus Implemented +@SYMTestActions Simulate TRawEvent of type EKeyRepeat without Repeat value set. + Simulate the above with repeat value set to 2. +@SYMTestExpectedResults Simulated events should match expected events added to the array. +*/ + +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + case 28: +#else +#ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS + case 31: +#else + case 28: +#endif +#endif + // This test was moved to be the last test in the test suite, because it sometimes leaves events in the event queue, + //it can affect the results of other tests. This test case should be the last test in the test suite. + ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0484")); + iTest->LogSubTest(KTest31A); + InitializeQueueSizeTestL(EFalse); + iTest->LogSubTest(KTest31B); + InitializeQueueSizeTestL(ETrue); + break; + + default: + ((CTEventTestStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + ((CTEventTestStep*)iStep)->CloseTMSGraphicsStep(); + TestComplete(); + break; + } + ((CTEventTestStep*)iStep)->RecordTestResultL(); + if (iFailed) + { + TEST(EFalse); + iFailed=EFalse; + } + ++iTest->iState; + } + +__WS_CONSTRUCT_STEP__(EventTest) + diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TFADE.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TFADE.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,2126 @@ +// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Test Fading and UnFading of windows +// +// + +#include "TFADE.H" +#define __DISPLAY_MODE_64K_COLOR + +//CRedrawWin + +CRedrawWin::CRedrawWin(CTFade *aTest) : CTWin(), iTest(aTest) + {} + +CRedrawWin::~CRedrawWin() + { + } + +void CRedrawWin::ConstructL(TRect aArea) + { + + ConstructExtLD(*TheClient->iGroup,aArea.iTl,aArea.Size()); + AssignGC(*TheClient->iGc); + Activate(); + iWin.BeginRedraw(); + iWin.EndRedraw(); + } + +void CRedrawWin::Draw() + { + iTest->Drawing(iTest->Content(),iGc); + } + + +//CFadeTest + +CTFade::CTFade(CTestStep* aStep) : CTWsGraphicsBase(aStep) + { +#if defined (__MARM_THUMB__) + CanFade = false; + CanFadeSet = false; +#endif + } + +void CTFade::ConstructL() + { + iDeviceDisplayMode=TheClient->iScreen->DisplayMode(); + iTestWinSize=StdTestWindowSize(); + iFadeDrawMode = iDeviceDisplayMode; + iTestWinCopy = new (ELeave) CFbsBitmap(); + iTestWinCopy->Create(iTestWinSize,TheClient->iScreen->DisplayMode()); + iCheckWinCopy = new (ELeave) CFbsBitmap(); + iCheckWinCopy->Create(iTestWinSize,TheClient->iScreen->DisplayMode()); + } + +CTFade::~CTFade() + { + __ASSERT_ALWAYS(!iBlankWin,AutoPanic(EAutoFadeWindow)); + delete iTestWinCopy; + delete iCheckWinCopy; + } + +TInt CTFade::Content() + { + return iContent; + } + +void CTFade::CreateBlankWindowL() + { + __ASSERT_ALWAYS(!iBlankWin,AutoPanic(EAutoFadeWindow)); + TSize scrSize(TheClient->iScreen->SizeInPixels()); + iTestWinSize.SetSize(2*scrSize.iWidth/3-6,scrSize.iHeight-6); + iBlankWin=new(ELeave) CTBlankWindow(); + iWindowRect.SetRect(TPoint(3+scrSize.iWidth/3,3),iTestWinSize); + iBlankWin->SetUpL(iWindowRect.iTl,iTestWinSize,TheClient->iGroup,*TheClient->iGc); + iBlankWin->BaseWin()->SetRequiredDisplayMode(EGray16); + } + +void CTFade::DestroyBlankWindow() + { + __ASSERT_ALWAYS(iBlankWin,AutoPanic(EAutoFadeWindow)); + delete iBlankWin; + iBlankWin=NULL; + } + +void CTFade::CreateBackupWindowL(TBool aMaintainBackup) + { + __ASSERT_ALWAYS(!iWin,AutoPanic(EAutoFadeWindow)); + CTBackedUpWin* backUpWin=new(ELeave) CTBackedUpWin(MODE_LT_64K(iDeviceDisplayMode)?iFadeDrawMode:iDeviceDisplayMode); + iWin=backUpWin; + iOwnWindow=ETrue; + iWindowRect.SetRect(TPoint(2*iTestWinSize.iWidth+35,7),iTestWinSize); + backUpWin->ConstructExtLD(*TheClient->iGroup,iWindowRect.iTl,iTestWinSize); + if (aMaintainBackup) + backUpWin->BackedUpWin()->MaintainBackup(); + backUpWin->Activate(); + TheClient->WaitForRedrawsToFinish(); //Without this bitmaps won't draw into the window + } + +void CTFade::CreateRedrawWindowL() + { + __ASSERT_ALWAYS(!iWin,AutoPanic(EAutoFadeWindow)); + iWindowRect.SetRect(TPoint(2*iTestWinSize.iWidth+35,7),iTestWinSize); + CRedrawWin* redrawWin=new(ELeave) CRedrawWin(this); + redrawWin->ConstructL(iWindowRect); + redrawWin->Win()->EnableRedrawStore(EFalse); + iWin=redrawWin; + iOwnWindow=ETrue; + iWin->BaseWin()->SetRequiredDisplayMode(iFadeDrawMode); + } + +void CTFade::DestroyDrawableWindow() + { + __ASSERT_ALWAYS(iWin,AutoPanic(EAutoFadeWindow)); + if (iOwnWindow) + delete iWin; + iWin=NULL; + } + +void CTFade::CreateBitmapsL() + { + iTestWinSize=BaseWin->Size(); + iBaseRect.SetRect(BaseWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),iTestWinSize); + iNormalBitmap.Create(iTestWinSize,MODE_LT_64K(iDeviceDisplayMode)?iFadeDrawMode:iDeviceDisplayMode); + iFadedBitmap.Create(iTestWinSize,MODE_LT_64K(iDeviceDisplayMode)?iFadeDrawMode:iDeviceDisplayMode); + iNormalBitmapDevice=CFbsBitmapDevice::NewL(&iNormalBitmap); + iFadedBitmapDevice=CFbsBitmapDevice::NewL(&iFadedBitmap); + User::LeaveIfError(iNormalBitmapDevice->CreateContext(iNormalBitGc)); + User::LeaveIfError(iFadedBitmapDevice->CreateContext(iFadedBitGc)); + iFadedBitGc->SetFadeMode(ETrue); + iBaseWinMode=BaseWin->BaseWin()->DisplayMode(); + BaseWin->BaseWin()->SetRequiredDisplayMode(iFadeDrawMode); + } + +void CTFade::DestroyBitmaps() + { + delete iNormalBitGc; + delete iFadedBitGc; + delete iNormalBitmapDevice; + delete iFadedBitmapDevice; + BaseWin->BaseWin()->SetRequiredDisplayMode(iBaseWinMode); + } + +void CTFade::Drawing(TInt aDrawFunc, CBitmapContext *gc) + { + TRgb grey=TRgb::Gray4(2); + TInt ii; + gc->Reset(); + switch (aDrawFunc) + { + case 1: + case 2: + Draw(0,&grey,gc); + gc->Reset(); + Draw(1,NULL,gc); + if (aDrawFunc==1) + break; + gc->Reset(); + Draw(3,NULL,gc); + break; + case 3: + Draw(0,&grey,gc); + gc->Reset(); + Draw(3,NULL,gc); + break; + case 4: + grey=TRgb::Gray4(1); + gc->Reset(); + Draw(0,&grey,gc); + gc->Reset(); + for (ii=1;ii<37;ii+=7) + Draw(2,&ii,gc); + break; + case 5: + Draw(0,&grey,gc); + gc->Reset(); + Draw(1,NULL,gc); + gc->Reset(); + for (ii=2;ii<60;ii+=11) + Draw(2,&ii,gc); + break; + case 6: + case 7: + Draw(0,&grey,gc); + gc->Reset(); + Draw(3,NULL,gc); + gc->Reset(); + for (ii=3;ii<70;ii+=13) + Draw(2,&ii,gc); + if (aDrawFunc==6) + break; + gc->Reset(); + Draw(1,NULL,gc); + break; + default:; + } + } + +void CTFade::Draw(TInt aDrawFunc, TAny *aParam, TBool aAlternativeFade/*=EFalse*/, TBool aFade/*=EFalse*/) + { + CWindowGc *gc=TheClient->iGc; + gc->Activate(*iWin->DrawableWin()); + gc->Reset(); + if (aFade) + gc->SetFaded(ETrue); + iNormalBitGc->Reset(); + iFadedBitGc->Reset(); + iFadedBitGc->SetFadeMode(ETrue); + if (aAlternativeFade) + iFadedBitGc->SetFadingParameters(BLACK_ALTERNATE,WHITE_ALTERNATE); + Draw(aDrawFunc,aParam,gc); + Draw(aDrawFunc,aParam,iNormalBitGc); + Draw(aDrawFunc,aParam,iFadedBitGc); + gc->Deactivate(); + if (aAlternativeFade) + iFadedBitGc->SetFadingParameters(BLACK_NORMAL,WHITE_NORMAL); + } + +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA // CWindowGc fading is deprecated in NGA +void CTFade::GCDraw(TInt aDrawFunc, TAny *aParam, TBool aAlternativeFade) + { + CWindowGc *gc=TheClient->iGc; + gc->Activate(*iWin->DrawableWin()); + gc->Reset(); + Draw(aDrawFunc,aParam,gc); + gc->Deactivate(); + gc->Activate(*BaseWin->DrawableWin()); + gc->Reset(); + gc->SetFaded(ETrue); + if (aAlternativeFade) + gc->SetFadingParameters(BLACK_ALTERNATE,WHITE_ALTERNATE); + Draw(aDrawFunc,aParam,gc); + gc->Deactivate(); + } +#endif // TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + +void CTFade::Draw(TInt aDrawFunc, TAny *aParam, CBitmapContext *aGc) + { + switch(aDrawFunc) + { + case 0: + aGc->SetBrushColor(*((TRgb *)aParam)); + aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + aGc->SetPenStyle(CGraphicsContext::ENullPen); + aGc->DrawRect(TRect(iTestWinSize)); + break; + case 1: + { + TSize half(iTestWinSize.iWidth/2,iTestWinSize.iHeight/2); + TRect rect(half); + aGc->DrawEllipse(rect); + aGc->DrawEllipse(TRect(TPoint(0,half.iHeight),half)); + aGc->SetOrigin(TPoint(half.iWidth,0)); + aGc->SetClippingRect(rect); + aGc->DrawEllipse(rect); + aGc->SetOrigin(TPoint(half.iWidth,half.iHeight)); + aGc->SetClippingRect(rect); + aGc->DrawEllipse(rect); + aGc->SetOrigin(TPoint()); + aGc->CancelClippingRect(); + } + break; + case 2: + { + TInt param= *((TInt *)aParam); + if (param&0x1) + aGc->DrawLine(TPoint(param+(param*27)%iTestWinSize.iWidth,0), + TPoint(iTestWinSize.iWidth-((param<<1)+(param*19)%iTestWinSize.iWidth),iTestWinSize.iHeight)); + else + aGc->DrawLine(TPoint(0, (param<<1)+(param*7)%iTestWinSize.iHeight), + TPoint(iTestWinSize.iWidth,param+(param*13)%iTestWinSize.iHeight)); + } + break; + case 3: + { + TPoint pos; + for(;pos.iXDrawLine(pos,pos+TSize(0,iTestWinSize.iHeight)); + for(pos.iX=0;pos.iYDrawLine(pos,pos+TSize(iTestWinSize.iWidth,0)); + } + break; + } + } + +void CTFade::CompareWithBitmap(TBool aFade) + { + TBool match; + CWindowGc& gc=*TheClient->iGc; + CFbsBitmap* bitmap; + TheClient->iWs.Flush(); + if (aFade) + bitmap=&iFadedBitmap; + else + bitmap=&iNormalBitmap; + gc.Activate(*BaseWin->DrawableWin()); + gc.Reset(); + gc.BitBlt(TPoint(),bitmap); + gc.Deactivate(); + TheClient->iWs.Flush(); +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + match=TheClient->iScreen->RectCompare(iBaseRect,iWindowRect); +#else // In NGA comparison has to be lossy because fading can be implemented on hardware + match=LossyCompareWindow(*TheClient->iScreen, *iTestWinCopy, *iCheckWinCopy, iWindowRect); +#endif + TEST(match); + if (!match) + { + _LIT(KLog,"Windows content don't match when they should"); + LOG_MESSAGE(KLog); + } + } + +void CTFade::CompareWindows(TBool aAlternativeFade/*=EFalse*/) + { + if (aAlternativeFade) + iWin->WinTreeNode()->SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly,BLACK_ALTERNATE,WHITE_ALTERNATE); + else + iWin->WinTreeNode()->SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly); + TheClient->iWs.Flush(); + TBool retVal = TheClient->iScreen->RectCompare(iBaseRect,iWindowRect); + TEST(retVal); + if (!retVal) + INFO_PRINTF3(_L("TheClient->iScreen->RectCompare(iBaseRect,iWindowRect) return value - Expected: %d, Actual: %d"), ETrue, retVal); + + iWin->WinTreeNode()->SetFaded(EFalse,RWindowTreeNode::EFadeWindowOnly); + TheClient->iWs.Flush(); + TheClient->WaitForRedrawsToFinish(); + } + +#define FADE(n,col) n/2+col/2 +TInt CTFade::Fade4(TInt aGray4) + { +#if defined(__WINS__) + return FADE(4,aGray4); +#elif defined (__MARM_THUMB__) + return (CanFade ? FADE(4,aGray4):aGray4); +#elif defined (__MARM__) + return FADE(4,aGray4); +#else + return aGray4; +#endif + } + +TInt CTFade::Fade16(TInt aGray16) + { +#if defined(__WINS__) + return FADE(16,aGray16); +#elif defined (__MARM_THUMB__) + return (CanFade ? FADE(16,aGray16):aGray16); +#elif defined (__MARM__) + return FADE(16,aGray16); +#else + return aGray16; +#endif + } + +TRgb CTFade::FadeRgb(TRgb aColor) + { + switch (iFadeDrawMode) + { + case EColor16M: + case EColor16MU: + case EColor16MA: + case EColor16MAP: + break; + default: + aColor=TRgb::Color64K(aColor.Color64K()); + break; + } +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA // Color fading calculation differs in NGA + TInt fadeMapFactor=WHITE_NORMAL-BLACK_NORMAL+1; +#else + TInt fadeMapFactor=WHITE_NORMAL-BLACK_NORMAL; +#endif + TInt fadeMapOffset=BLACK_NORMAL; + TInt value = aColor.Internal(); + + TInt b = (((value & 0x000000ff) * fadeMapFactor) >> 8) + fadeMapOffset; + TInt g = (((value & 0x0000ff00) * fadeMapFactor) >> 16) + fadeMapOffset; + TInt r = (((value & 0x00ff0000) * fadeMapFactor) >> 24) + fadeMapOffset; + return TRgb(r,g,b); + } + +TRgb CTFade::FadeRgb(TRgb aColor, TInt aFadeMapFactor, TInt aFadeMapOffset) + { + switch (iFadeDrawMode) + { + case EColor16M: + case EColor16MU: + case EColor16MA: + case EColor16MAP: + break; + default: + aColor=TRgb::Color64K(aColor.Color64K()); + break; + } + TInt value = aColor.Internal(); + + TInt b = (((value & 0x000000ff) * aFadeMapFactor) >> 8) + aFadeMapOffset; + TInt g = (((value & 0x0000ff00) * aFadeMapFactor) >> 16) + aFadeMapOffset; + TInt r = (((value & 0x00ff0000) * aFadeMapFactor) >> 24) + aFadeMapOffset; + return TRgb(r,g,b); + } + +inline void CTFade::ViewDelay() + // + //This routine can provide a delay which will allow the user to see the colors changing + // + { + TheClient->iWs.Finish(); + /*TheClient->iWs.Flush(); + User::After(1000000);*/ // 1 sec + } + +void CTFade::ColorTest() + { + __ASSERT_ALWAYS(iBlankWin,AutoPanic(EAutoFadeWindow)); + TBool retVal; + TSize size(iTestWinSize); +#if defined(SMALL_RECTS) + size.iWidth=Min(SIZE_X,size.iWidth); + size.iHeight=Min(SIZE_Y,size.iHeight); +#endif + TRect windowRect(iBlankWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),size); + TInt ii; + iBlankWin->BaseWin()->SetRequiredDisplayMode(EGray4); + TheClient->WaitForRedrawsToFinish(); //Force the screen into 4 gray mode + TRgb fadedColor; + for (ii=1;ii<4;ii+=2) //0 and 3 now give dithered colors when fading so causing this test to fail + { + iBlankWin->SetColor(TRgb::Gray4(ii)); + ViewDelay(); + INFO_PRINTF1(_L(" Testing Normal Color")); +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + retVal = CheckBlankWindow(windowRect,TRgb::Gray4(ii),TheClient->iScreen); +#else + TheClient->iScreen->CopyScreenToBitmap(iTestWinCopy, windowRect); + retVal = LossyCheckBlankWindow(*TheClient->iScreen, *iTestWinCopy, windowRect, TRgb::Gray4(ii)); +#endif + TEST(retVal); + if (!retVal) + INFO_PRINTF3(_L("CheckBlankWindow(windowRect,TRgb::Gray4(ii),TheClient->iScreen) return value - Expected: %d, Actual: %d"), ETrue, retVal); + iBlankWin->BaseWin()->SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly); + ViewDelay(); + fadedColor=MODE_LT_64K(iDeviceDisplayMode)?TRgb::Gray4(Fade4(ii)):FadeRgb(TRgb::Gray4(ii)); +#if defined (__MARM_THUMB__) + if (ii==1) + { + CanFade=!CheckBlankWindow(windowRect,fadedColor,TheClient->iScreen); + CanFadeSet=ETrue; + fadedColor=MODE_LT_64K(iDeviceDisplayMode)?TRgb::Gray4(Fade4(ii)):FadeRgb(TRgb::Gray4(ii)); + } +#endif +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + retVal = CheckBlankWindow(windowRect,fadedColor,TheClient->iScreen); +#else + retVal = LossyCheckBlankWindow(*TheClient->iScreen, *iTestWinCopy, windowRect, fadedColor); +#endif + TEST(retVal); + if (!retVal) + INFO_PRINTF3(_L("CheckBlankWindow(windowRect,fadedColor,TheClient->iScreen) return value - Expected: %d, Actual: %d"), ETrue, retVal); + + iBlankWin->BaseWin()->SetFaded(EFalse,RWindowTreeNode::EFadeWindowOnly); + ViewDelay(); + INFO_PRINTF1(_L(" Testing Unfaded Color")); +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + retVal = CheckBlankWindow(windowRect,TRgb::Gray4(ii),TheClient->iScreen); +#else + retVal = LossyCheckBlankWindow(*TheClient->iScreen, *iTestWinCopy, windowRect, TRgb::Gray4(ii)); +#endif + TEST(retVal); + if (!retVal) + INFO_PRINTF3(_L("CheckBlankWindow(windowRect,TRgb::Gray4(ii),TheClient->iScreen) return value - Expected: %d, Actual: %d"), ETrue, retVal); + } + iBlankWin->BaseWin()->SetRequiredDisplayMode(EGray16); + + if (MaxGrays()==0 && MaxColors()<256) + return; + + INFO_PRINTF1(_L(" Doing 16 Gray Colors")); + for (ii=0;ii<16;++ii) + { + iBlankWin->SetColor(TRgb::Gray16(ii)); + ViewDelay(); +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + retVal = CheckBlankWindow(windowRect,TRgb::Gray16(ii),TheClient->iScreen); +#else + retVal = LossyCheckBlankWindow(*TheClient->iScreen, *iTestWinCopy, windowRect, TRgb::Gray16(ii)); +#endif + TEST(retVal); + if (!retVal) + INFO_PRINTF3(_L("CheckBlankWindow(windowRect,TRgb::Gray16(ii),TheClient->iScreen) return value - Expected: %d, Actual: %d"), ETrue, retVal); + + iBlankWin->BaseWin()->SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly); + ViewDelay(); + fadedColor=MODE_LT_64K(iDeviceDisplayMode)?TRgb::Gray16(Fade16(ii)):FadeRgb(TRgb::Gray16(ii)); +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + retVal = CheckBlankWindow(windowRect,fadedColor,TheClient->iScreen); +#else + retVal = LossyCheckBlankWindow(*TheClient->iScreen, *iTestWinCopy, windowRect, fadedColor); +#endif + TEST(retVal); + if (!retVal) + INFO_PRINTF3(_L("CheckBlankWindow(windowRect,fadedColor,TheClient->iScreen) return value - Expected: %d, Actual: %d"), ETrue, retVal); + + iBlankWin->BaseWin()->SetFaded(EFalse,RWindowTreeNode::EFadeWindowOnly); + ViewDelay(); + +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + retVal = CheckBlankWindow(windowRect,TRgb::Gray16(ii),TheClient->iScreen); +#else + retVal = LossyCheckBlankWindow(*TheClient->iScreen, *iTestWinCopy, windowRect, TRgb::Gray16(ii)); +#endif + TEST(retVal); + if (!retVal) + INFO_PRINTF3(_L("CheckBlankWindow(windowRect,TRgb::Gray16(ii),TheClient->iScreen) return value - Expected: %d, Actual: %d"), ETrue, retVal); + } + } + +void CTFade::BlankWindowL() + { + TBool retVal; + if (MaxGrays()==0 && MaxColors()<256) + return; + + __ASSERT_ALWAYS(iBlankWin,AutoPanic(EAutoFadeWindow)); + CTBlankWindow* blankWin=new(ELeave) CTBlankWindow(); + TRect testArea(iWindowRect); + TRect windowRect(testArea); +#if defined(SMALL_RECTS) + TSize size(testArea.Size()); + size.iWidth=Min(2*SIZE_X,size.iWidth); + size.iHeight=Min(2*SIZE_Y,size.iHeight); + testArea.SetHeight(size.iHeight); + testArea.iTl.iX=testArea.iBr.iX-size.iWidth; + windowRect=testArea; + windowRect.Shrink(size.iWidth/4,size.iHeight/4); +#else + windowRect.Shrink(30,30); +#endif + blankWin->SetUpL(windowRect.iTl,windowRect.Size(),TheClient->iGroup,*TheClient->iGc); + for (TInt col=2;col<16;col+=6) + { + iBlankWin->SetColor(TRgb::Gray16(col)); + TheClient->iScreen->CopyScreenToBitmap(iTestWinCopy, windowRect); + iBlankWin->BaseWin()->SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly); + blankWin->SetVisible(EFalse); + TheClient->iWs.Finish(); + TRgb fadedColor=MODE_LT_64K(iDeviceDisplayMode)?TRgb::Gray16(Fade16(col)):FadeRgb(TRgb::Gray16(col)); +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + retVal = CheckBlankWindow(testArea,fadedColor,TheClient->iScreen); +#else + retVal = LossyCheckBlankWindow(*TheClient->iScreen, *iTestWinCopy, windowRect, fadedColor); +#endif + TEST(retVal); + if (!retVal) + INFO_PRINTF3(_L("LossyCheckBlankWindow(*TheClient->iScreen, *iTestWinCopy, windowRect, fadedColor) return value - Expected: %d, Actual: %d"), ETrue, retVal); + + blankWin->SetVisible(ETrue); + iBlankWin->BaseWin()->SetFaded(EFalse,RWindowTreeNode::EFadeWindowOnly); + blankWin->SetVisible(EFalse); + TheClient->iWs.Finish(); + retVal = CheckBlankWindow(testArea,TRgb::Gray16(col),TheClient->iScreen); + TEST(retVal); + if (!retVal) + INFO_PRINTF3(_L("CheckBlankWindow(testArea,TRgb::Gray16(col),TheClient->iScreen) return value - Expected: %d, Actual: %d"), ETrue, retVal); + + blankWin->SetVisible(ETrue); + iBlankWin->SetPos(iWindowRect.iTl+TPoint(15,-15)); + iBlankWin->BaseWin()->SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly); + blankWin->SetVisible(EFalse); + iBlankWin->SetPos(iWindowRect.iTl); + fadedColor=MODE_LT_64K(iDeviceDisplayMode)?TRgb::Gray16(Fade16(col)):FadeRgb(TRgb::Gray16(col)); + TheClient->iWs.Finish(); +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + retVal = CheckBlankWindow(testArea,fadedColor,TheClient->iScreen); +#else + retVal = LossyCheckBlankWindow(*TheClient->iScreen, *iTestWinCopy, windowRect, fadedColor); +#endif + TEST(retVal); + if (!retVal) + INFO_PRINTF3(_L("LossyCheckBlankWindow(*TheClient->iScreen, *iTestWinCopy, windowRect, fadedColor) return value - Expected: %d, Actual: %d"), ETrue, retVal); + + blankWin->SetVisible(ETrue); + iBlankWin->SetPos(iWindowRect.iTl+TPoint(15,-15)); + iBlankWin->BaseWin()->SetFaded(EFalse,RWindowTreeNode::EFadeWindowOnly); + blankWin->SetVisible(EFalse); + iBlankWin->SetPos(iWindowRect.iTl); + TheClient->iWs.Finish(); + retVal = CheckBlankWindow(testArea,TRgb::Gray16(col),TheClient->iScreen); + TEST(retVal); + if (!retVal) + INFO_PRINTF3(_L("CheckBlankWindow(testArea,TRgb::Gray16(col),TheClient->iScreen) return value - Expected: %d, Actual: %d"), ETrue, retVal); + + blankWin->SetVisible(ETrue); + } + delete blankWin; + } + +void CTFade::TestStrips(TRect aRect,TInt aHeight,TInt aNumNotFaded,TBool aInvert/*=EFalse*/) + { + TBool isFaded; + TInt ii; + TRgb col; + for (ii=0;ii<16;++ii) + { + isFaded=((!aInvert)==(!(iiiScreen); +#else + TBool retVal = LossyCheckBlankWindow(*TheClient->iScreen, *iTestWinCopy, aRect, col); +#endif + TEST(retVal); + if (!retVal) + INFO_PRINTF3(_L("CheckBlankWindow(aRect,col,TheClient->iScreen) return value - Expected: %d, Actual: %d"), ETrue, retVal); + + aRect.Move(0,aHeight); + } + } + +void CTFade::FadeChildrenL() + { + if (MaxGrays()==0 && MaxColors()<256) + return; + + TInt retVal; + TBool retBool; + + __ASSERT_ALWAYS(iBlankWin,AutoPanic(EAutoFadeWindow)); + iBlankWin->BaseWin()->SetRequiredDisplayMode(EGray16); + iBlankWin->SetColor(TRgb::Gray16(0)); + CTBlankWindow* win[16]; + win[0]=iBlankWin; + TRect rect(iTestWinSize); + TInt height=iTestWinSize.iHeight/16; + rect.iTl.iY=height; + TInt ii; + for (ii=1;ii<16;++ii) //Causes memory leakage under OOM + { + win[ii]=new(ELeave) CTBlankWindow(); + win[ii]->SetUpL(rect.iTl,rect.Size(),win[ii-1],*TheClient->iGc); + win[ii]->BaseWin()->SetRequiredDisplayMode(EGray16); + win[ii]->SetColor(TRgb::Gray16(ii)); + rect.iBr.iY-=height; + } + rect=iWindowRect; + rect.SetHeight(height); +#if defined(SMALL_RECTS) + TSize size(rect.Size()); + size.iWidth=Min(SIZE_X,size.iWidth); + size.iHeight=Min(SIZE_Y,size.iHeight); + rect.SetSize(size); +#endif + for (ii=0;ii<15;++ii) + { + win[ii]->WinTreeNode()->SetFaded(ETrue,RWindowTreeNode::EFadeIncludeChildren); + retVal = win[ii]->BaseWin()->IsFaded(); + TEST(retVal==1); + if (retVal!=1) + INFO_PRINTF3(_L("win[ii]->BaseWin()->IsFaded() return value - Expected: %d, Actual: %d"), 1, retVal); + + TestStrips(rect,height,ii); + win[ii]->WinTreeNode()->SetFaded(EFalse,RWindowTreeNode::EFadeIncludeChildren); + retBool = !win[ii]->BaseWin()->IsFaded(); + TEST(retBool); + if (!retBool) + INFO_PRINTF3(_L("!win[ii]->BaseWin()->IsFaded() return value - Expected: %d, Actual: %d"), ETrue, retBool); + + TestStrips(rect,height,16); + } + TheClient->iGroup->WinTreeNode()->SetFaded(ETrue,RWindowTreeNode::EFadeIncludeChildren); + TestStrips(rect,height,0); + TheClient->iGroup->WinTreeNode()->SetFaded(EFalse,RWindowTreeNode::EFadeIncludeChildren); + TestStrips(rect,height,16); + for (ii=0;ii<16;++ii) + { + win[ii]->BaseWin()->FadeBehind(ETrue); + retBool = !win[ii]->BaseWin()->IsFaded(); + TEST(retBool); + if (!retBool) + INFO_PRINTF3(_L("!win[ii]->BaseWin()->IsFaded() return value - Expected: %d, Actual: %d"), ETrue, retBool); + + retVal = win[0]->BaseWin()->IsFaded(); + TEST(retVal==(ii>0)); + if (retVal!=(ii>0)) + INFO_PRINTF3(_L("win[0]->BaseWin()->IsFaded() return value - Expected: %d, Actual: %d"), (ii>0), retVal); + + TestStrips(rect,height,ii,ETrue); + win[ii]->BaseWin()->FadeBehind(EFalse); + TestStrips(rect,height,16); + } + iBlankWin->WinTreeNode()->SetFaded(ETrue,RWindowTreeNode::EFadeIncludeChildren); + TestStrips(rect,height,0); + iBlankWin->WinTreeNode()->SetNonFading(ETrue); + TestStrips(rect,height,16); + win[8]->WinTreeNode()->SetNonFading(EFalse); + TestStrips(rect,height,8); + iBlankWin->WinTreeNode()->SetNonFading(EFalse); + TestStrips(rect,height,0); + iBlankWin->WinTreeNode()->SetFaded(EFalse,RWindowTreeNode::EFadeIncludeChildren); + TestStrips(rect,height,16); + win[8]->WinTreeNode()->SetNonFading(ETrue); + TestStrips(rect,height,16); + iBlankWin->WinTreeNode()->SetFaded(ETrue,RWindowTreeNode::EFadeIncludeChildren); + TestStrips(rect,height,8,ETrue); + win[8]->WinTreeNode()->SetNonFading(EFalse); + TestStrips(rect,height,0); + iBlankWin->WinTreeNode()->SetFaded(EFalse,RWindowTreeNode::EFadeIncludeChildren); + TestStrips(rect,height,16); + for (ii=15;ii>0;--ii) + delete win[ii]; + } + +static void ResetAndDestroyWindows(TAny* aPtr) + { + RPointerArray& win = *(static_cast*>(aPtr)); + win.Remove(0); + win.ResetAndDestroy(); + win.Close(); + } + +void CTFade::FadeChildrenAfterNewChildIsCreatedL() + { + if (MaxGrays()==0 && MaxColors()<256) + return; + + TBool retBool; + TInt retVal; + + __ASSERT_ALWAYS(iBlankWin,AutoPanic(EAutoFadeWindow)); + iBlankWin->BaseWin()->SetRequiredDisplayMode(iFadeDrawMode); + iBlankWin->SetColor(TRgb::Gray16(0)); + RPointerArray win; + CleanupStack::PushL(TCleanupItem(ResetAndDestroyWindows, &win)); + TInt height=iTestWinSize.iHeight/NUMBER_OF_WINDOWS; + CTBlankWindow* window=NULL; + TInt ii; + for (TInt firstLoop=0;firstLoopiGroup->WinTreeNode()->SetFaded(ETrue,RWindowTreeNode::EFadeIncludeChildren); + TRect rect(iTestWinSize); + rect.iTl.iY=height; + CTBlankWindow* parent=iBlankWin; + for (TInt secondLoop=0;secondLoop<=firstLoop;) + { + window=new(ELeave) CTBlankWindow(); + CleanupStack::PushL(window); + User::LeaveIfError(win.Append(window)); + CleanupStack::Pop(window); + window->SetUpL(rect.iTl,rect.Size(),parent,*TheClient->iGc); + window->BaseWin()->SetRequiredDisplayMode(iFadeDrawMode); + window->SetColor(TRgb::Gray16(++secondLoop)); + rect.iBr.iY-=height; + parent=window; + retBool = window->BaseWin()->IsFaded(); + TEST(retBool); + if (!retBool) + INFO_PRINTF3(_L("window->BaseWin()->IsFaded() return value - Expected: %d, Actual: %d"), ETrue, retBool); + + } + ++firstLoop; + TheClient->iGroup->WinTreeNode()->SetFaded(EFalse,RWindowTreeNode::EFadeIncludeChildren); + const TInt count=win.Count(); + for(TInt index=0;indexBaseWin()->IsFaded(); + TEST(!retBool); + if (retBool) + INFO_PRINTF3(_L("win[index]->BaseWin()->IsFaded return value - Expected: %d, Actual: %d"), EFalse, retBool); + + } + } + User::LeaveIfError(win.Insert(iBlankWin,0)); + TRect testRect=iWindowRect; + testRect.SetHeight(height); +#if defined(SMALL_RECTS) + TSize size(testRect.Size()); + size.iWidth=Min(SIZE_X,size.iWidth); + size.iHeight=Min(SIZE_Y,size.iHeight); + testRect.SetSize(size); +#endif + for (ii=0;iiWinTreeNode()->SetFaded(ETrue,RWindowTreeNode::EFadeIncludeChildren); + retVal = win[ii]->BaseWin()->IsFaded(); + TEST(retVal==1); + if (retVal!=1) + INFO_PRINTF3(_L("win[index]->BaseWin()->IsFaded return value - Expected: %d, Actual: %d"), 1, retVal); + + TestStrips(testRect,height,ii); + win[ii]->WinTreeNode()->SetFaded(EFalse,RWindowTreeNode::EFadeIncludeChildren); + retBool = !win[ii]->BaseWin()->IsFaded(); + TEST(retBool); + if (!retBool) + INFO_PRINTF3(_L("!win[ii]->BaseWin()->IsFaded() return value - Expected: %d, Actual: %d"), EFalse, retBool); + + TestStrips(testRect,height,NUMBER_OF_WINDOWS); + } + TheClient->iGroup->WinTreeNode()->SetFaded(ETrue,RWindowTreeNode::EFadeIncludeChildren); + TestStrips(testRect,height,0); + TheClient->iGroup->WinTreeNode()->SetFaded(EFalse,RWindowTreeNode::EFadeIncludeChildren); + TestStrips(testRect,height,16); + for (ii=0;iiBaseWin()->FadeBehind(ETrue); + retBool = !win[ii]->BaseWin()->IsFaded(); + TEST(retBool); + if (!retBool) + INFO_PRINTF3(_L("!win[ii]->BaseWin()->IsFaded() return value - Expected: %d, Actual: %d"), EFalse, retBool); + + retVal = win[0]->BaseWin()->IsFaded(); + TEST(retVal==(ii>0)); + if (retVal!=(ii>0)) + INFO_PRINTF3(_L("win[index]->BaseWin()->IsFaded return value - Expected: %d, Actual: %d"), (ii>0), retVal); + + TestStrips(testRect,height,ii,ETrue); + win[ii]->BaseWin()->FadeBehind(EFalse); + TestStrips(testRect,height,NUMBER_OF_WINDOWS); + } + iBlankWin->WinTreeNode()->SetFaded(ETrue,RWindowTreeNode::EFadeIncludeChildren); + TestStrips(testRect,height,0); + iBlankWin->WinTreeNode()->SetNonFading(ETrue); + TestStrips(testRect,height,NUMBER_OF_WINDOWS); + win[8]->WinTreeNode()->SetNonFading(EFalse); + TestStrips(testRect,height,NUMBER_OF_WINDOWS/2); + iBlankWin->WinTreeNode()->SetNonFading(EFalse); + TestStrips(testRect,height,0); + iBlankWin->WinTreeNode()->SetFaded(EFalse,RWindowTreeNode::EFadeIncludeChildren); + TestStrips(testRect,height,NUMBER_OF_WINDOWS); + win[8]->WinTreeNode()->SetNonFading(ETrue); + TestStrips(testRect,height,NUMBER_OF_WINDOWS); + iBlankWin->WinTreeNode()->SetFaded(ETrue,RWindowTreeNode::EFadeIncludeChildren); + TestStrips(testRect,height,NUMBER_OF_WINDOWS/2,ETrue); + win[8]->WinTreeNode()->SetNonFading(EFalse); + TestStrips(testRect,height,0); + iBlankWin->WinTreeNode()->SetFaded(EFalse,RWindowTreeNode::EFadeIncludeChildren); + TestStrips(testRect,height,NUMBER_OF_WINDOWS); + + CleanupStack::PopAndDestroy(&win); + } + +void CTFade::TestBlocks(TRect aRect,TSize aSize,TInt aNumNotFaded,TBool aInvert/*=EFalse*/) + { + TInt count=0; + TInt ii,jj; + TRgb col; + for (ii=0;ii<4;++ii) + { + for (jj=0;jj<4;++jj) + { + if ((!aInvert)!=(!(countiScreen); +#else + TBool retBool = LossyCheckBlankWindow(*TheClient->iScreen, *iTestWinCopy, aRect, col); +#endif + TEST(retBool); + if (!retBool) + INFO_PRINTF3(_L("CheckBlankWindow(aRect,col,TheClient->iScreen) return value - Expected: %d, Actual: %d"), EFalse, retBool); + + aRect.Move(0,aSize.iHeight); + count++; + } + aRect.Move(aSize.iWidth,-jj*aSize.iHeight); + } + } + +void CTFade::FadeBehindL() + { + if (MaxGrays()==0 && MaxColors()<256) + return; + + TBool retBool; + TInt retVal; + + __ASSERT_ALWAYS(iBlankWin,AutoPanic(EAutoFadeWindow)); + iBlankWin->BaseWin()->SetRequiredDisplayMode(EGray16); + iBlankWin->SetColor(TRgb::Gray16(0)); + CTBlankWindow* win[4][4]; + win[0][0]=iBlankWin; + TSize size=iTestWinSize; + TInt height=iTestWinSize.iHeight/4; + TInt width=iTestWinSize.iWidth/4; + TRect rect(iWindowRect.iTl,TSize(width,height)); + TSize rectSize(rect.Size()); + TPoint offset(0,height); + TPoint topLeft; + TInt ii,jj; + CTWinBase* parent; +#if defined(SMALL_RECTS) + TSize rSize(rectSize); + rSize.iWidth=Min(SIZE_X,rSize.iWidth); + rSize.iHeight=Min(SIZE_Y,rSize.iHeight); + rect.SetSize(rSize); +#endif + for (ii=0;ii<4;++ii) //Causes memory leakage under OOM + { + parent=TheClient->iGroup; + topLeft=iWindowRect.iTl+TPoint(ii*width,0); + size.iHeight=iTestWinSize.iHeight; + for (jj=0;jj<4;++jj) + { + if (ii+jj>0) + { + win[ii][jj]=new(ELeave) CTBlankWindow(); + win[ii][jj]->SetUpL(topLeft,size,parent,*TheClient->iGc); + win[ii][jj]->BaseWin()->SetRequiredDisplayMode(EGray16); + win[ii][jj]->SetColor(TRgb::Gray16(4*ii+jj)); + } + size.iHeight-=height; + topLeft=offset; + parent=win[ii][jj]; + } + size.iWidth-=width; + } + for (ii=0;ii<4;++ii) + { + for (jj=0;jj<4;++jj) + { + win[ii][jj]->BaseWin()->FadeBehind(ETrue); + retVal = win[0][0]->BaseWin()->IsFaded(); + TEST(retVal==(ii>0||jj>0)); + if (retVal!=(ii>0||jj>0)) + INFO_PRINTF3(_L("win[0][0]->BaseWin()->IsFaded() return value - Expected: %d, Actual: %d"), (ii>0||jj>0), retVal); + + retBool = !win[ii][jj]->BaseWin()->IsFaded(); + TEST(retBool); + if (!retBool) + INFO_PRINTF3(_L("!win[ii][jj]->BaseWin()->IsFaded() return value - Expected: %d, Actual: %d"), ETrue, retBool); + + TestBlocks(rect,rectSize,4*ii+jj,ETrue); + win[ii][jj]->BaseWin()->FadeBehind(EFalse); + TestBlocks(rect,rectSize,16); + } + } + for (ii=0;ii<4;++ii) + { + for (jj=0;jj<4;++jj) + { + win[ii][jj]->BaseWin()->FadeBehind(ETrue); + TestBlocks(rect,rectSize,4*ii+jj,ETrue); + } + retVal = win[ii][0]->BaseWin()->IsFaded(); + TEST(retVal==3); + if (retVal!=3) + INFO_PRINTF3(_L("win[ii][0]->BaseWin()->IsFaded() return value - Expected: %d, Actual: %d"), 3, retVal); + } + for (ii=3;ii>=0;--ii) + { + retVal = win[ii][0]->BaseWin()->IsFaded(); + TEST(retVal==3); + if (retVal!=3) + INFO_PRINTF3(_L("win[ii][0]->BaseWin()->IsFaded() return value - Expected: %d, Actual: %d"), 3, retVal); + + for (jj=3;jj>=0;--jj) + { + TestBlocks(rect,rectSize,4*ii+jj,ETrue); + win[ii][jj]->BaseWin()->FadeBehind(EFalse); + } + } + TestBlocks(rect,rectSize,0,ETrue); + for (ii=0;ii<4;++ii) + { + for (jj=0;jj<4;++jj) + { + win[ii][jj]->BaseWin()->FadeBehind(ETrue); + } + } + TInt fadeCount; + for (ii=0;ii<4;++ii) + { + for (jj=0;jj<4;++jj) + { + fadeCount=15-(4*ii+jj); + retVal = win[0][0]->BaseWin()->IsFaded(); + TEST(retVal==Min(15,fadeCount+1)); + if (retVal!=Min(15,fadeCount+1)) + INFO_PRINTF3(_L("win[0][0]->BaseWin()->IsFaded() return value - Expected: %d, Actual: %d"), Min(15,fadeCount+1), retVal); + + retVal = win[ii][jj]->BaseWin()->IsFaded(); + TEST(retVal==Max(0,fadeCount)); + if (retVal!=Max(0,fadeCount)) + INFO_PRINTF3(_L("win[ii][jj]->BaseWin()->IsFaded() return value - Expected: %d, Actual: %d"), Max(0,fadeCount), retVal); + + TestBlocks(rect,rectSize,15,ETrue); + win[ii][jj]->BaseWin()->FadeBehind(EFalse); + retVal = win[ii][jj]->BaseWin()->IsFaded(); + TEST(retVal==Max(0,fadeCount)); + if (retVal!=Max(0,fadeCount)) + INFO_PRINTF3(_L("win[ii][jj]->BaseWin()->IsFaded() return value - Expected: %d, Actual: %d"), Max(0,fadeCount), retVal); + + } + } + TestBlocks(rect,rectSize,0,ETrue); + if (Fade16(15)==15) + { + win[3][3]->BaseWin()->FadeBehind(ETrue); //All faded as the only unfaded one is white + for (ii=3;ii>=0;--ii) + { + retVal = win[ii][0]->BaseWin()->IsFaded(); + TEST(retVal==1); + if (retVal!=1) + INFO_PRINTF3(_L("win[ii][0]->BaseWin()->IsFaded() return value - Expected: %d, Actual: %d"), 1, retVal); + + retBool = !win[ii][1]->BaseWin()->IsNonFading(); + TEST(retBool); + if (!retBool) + INFO_PRINTF3(_L("!win[ii][1]->BaseWin()->IsNonFading() return value - Expected: %d, Actual: %d"), ETrue, retBool); + + win[ii][0]->WinTreeNode()->SetNonFading(ETrue); + retBool = win[ii][1]->BaseWin()->IsNonFading(); + TEST(retBool); + if (!retBool) + INFO_PRINTF3(_L("win[ii][1]->BaseWin()->IsNonFading() return value - Expected: %d, Actual: %d"), ETrue, retBool); + + TestBlocks(rect,rectSize,4*ii,ETrue); + } + for (ii=3;ii>=0;--ii) + { + retVal = win[ii][0]->BaseWin()->IsFaded(); + TEST(retVal==1); + if (retVal!=1) + INFO_PRINTF3(_L("win[ii][0]->BaseWin()->IsFaded() return value - Expected: %d, Actual: %d"), 1, retVal); + + retBool = win[ii][1]->BaseWin()->IsNonFading(); + TEST(retBool); + if (!retBool) + INFO_PRINTF3(_L("win[ii][1]->BaseWin()->IsNonFading() return value - Expected: %d, Actual: %d"), ETrue, retBool); + + win[ii][0]->WinTreeNode()->SetNonFading(EFalse); + retBool = !win[ii][1]->BaseWin()->IsNonFading(); + TEST(retBool); + if (!retBool) + INFO_PRINTF3(_L("win[ii][1]->BaseWin()->IsNonFading() return value - Expected: %d, Actual: %d"), ETrue, retBool); + + TestBlocks(rect,rectSize,4*ii); + } + win[3][3]->BaseWin()->FadeBehind(EFalse); + } + for (ii=3;ii>=0;--ii) + { + for (jj=3;jj>=0;--jj) + { + if (ii+jj>0) + delete win[ii][jj]; + } + } + } + +void CTFade::ColorTest2() + { +#if defined(__MARM__) + return; +#else + __ASSERT_ALWAYS(iBlankWin,AutoPanic(EAutoFadeWindow)); + TSize size=iTestWinSize; +#if defined(SMALL_RECTS) + size.iWidth=Min(SIZE_X,size.iWidth); + size.iHeight=Min(SIZE_Y,size.iHeight); +#endif + if (MaxGrays()==0 && MaxColors()<256) + return; + TRect windowRect(iBlankWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),size); + TUint8 bm; + TUint8 wm; + TInt test=0; + TInt ii; + FOREVER + { + TInt fadeMapFactor = 0; + TInt fadeMapOffset = 0; + + switch (test) + { + case 0: //Nothing + bm=0; + wm=15; + break; + case 1: //Shadowing or Quartz fading + bm=0; + wm=7; +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + TheClient->iWs.SetDefaultFadingParameters(0,127); + fadeMapFactor = 128; +#else + TheClient->iWs.SetDefaultFadingParameters(STATIC_CAST(TUint8,bm*17),127); + fadeMapFactor = 127-STATIC_CAST(TUint8,bm*17); +#endif + break; + default: + TheClient->iWs.SetDefaultFadingParameters(BLACK_NORMAL,WHITE_NORMAL); + return; + } + if (wm!=7) + { + fadeMapOffset = STATIC_CAST(TUint8,bm*17); + fadeMapFactor = STATIC_CAST(TUint8,wm*17) - fadeMapOffset; + TheClient->iWs.SetDefaultFadingParameters(STATIC_CAST(TUint8,bm*17),STATIC_CAST(TUint8,wm*17)); + } + + for (ii=0;ii<16;ii+=5) + { + iBlankWin->SetColor(TRgb::Gray16(ii)); + ViewDelay(); +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + TBool retBool=CheckBlankWindow(windowRect,TRgb::Gray16(ii),TheClient->iScreen); +#else + TBool retBool = LossyCheckBlankWindow(*TheClient->iScreen, *iTestWinCopy, windowRect, TRgb::Gray16(ii)); +#endif + TEST(retBool); + if (!retBool) + { + _LIT(KLog,"Setting color on blank window failed mappings=%d color=%d"); + LOG_MESSAGE3(KLog,test,ii); + } + iBlankWin->BaseWin()->SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly); + ViewDelay(); + + TRgb col1 = FadeRgb(TRgb::Gray16(ii), fadeMapFactor, fadeMapOffset); +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + retBool=CheckBlankWindow(windowRect,col1,TheClient->iScreen); +#else + retBool = LossyCheckBlankWindow(*TheClient->iScreen, *iTestWinCopy, windowRect, col1); +#endif + TEST(retBool); + if (!retBool) + { + _LIT(KLog,"Fading the window gave wrong color mappings=%d color=%d"); + LOG_MESSAGE3(KLog,test,ii); + } + iBlankWin->BaseWin()->SetFaded(EFalse,RWindowTreeNode::EFadeWindowOnly); + ViewDelay(); +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + retBool=CheckBlankWindow(windowRect,TRgb::Gray16(ii),TheClient->iScreen); +#else + retBool = LossyCheckBlankWindow(*TheClient->iScreen, *iTestWinCopy, windowRect, TRgb::Gray16(ii)); +#endif + TEST(retBool); + if (!retBool) + { + _LIT(KLog,"Unfading the window gave wrong color mappings=%d color=%d"); + LOG_MESSAGE3(KLog,test,ii); + } + } + ++test; + } +#endif //__MARM__ + } + +void CTFade::FadeTest() + { +#if defined(__MARM__) + return; +#else + __ASSERT_ALWAYS(iBlankWin,AutoPanic(EAutoFadeWindow)); + TSize size=iTestWinSize; +#if defined(SMALL_RECTS) + size.iWidth=Min(SIZE_X,size.iWidth); + size.iHeight=Min(SIZE_Y,size.iHeight); +#endif + if (MaxGrays()==0 && MaxColors()<256) + return; + TRect windowRect(iBlankWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),size); + TUint8 bm; + TUint8 wm; + TUint8 fb; + TUint8 fw; + TInt test=0; + TInt ii; + FOREVER + { + TInt fadeMapFactor = 0; + TInt fadeMapOffset = 0; + fw=0; + switch (test) + { + case 0: //Nothing + bm=0; + wm=15; + break; + case 1: //Shadowing or Quartz fading + + bm=0; + wm=7; + fw=127; + break; + default: + return; + } + fb=STATIC_CAST(TUint8,17*bm); + if (!fw) + fw=STATIC_CAST(TUint8,17*wm); + fadeMapFactor = fw - fb; + fadeMapOffset = fb; + for (ii=0;ii<16;ii+=5) + { + iBlankWin->SetColor(TRgb::Gray16(ii)); + ViewDelay(); +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + TBool retBool = CheckBlankWindow(windowRect,TRgb::Gray16(ii),TheClient->iScreen); +#else + TBool retBool = LossyCheckBlankWindow(*TheClient->iScreen, *iTestWinCopy, windowRect, TRgb::Gray16(ii)); +#endif + TEST(retBool); + if (!retBool) + INFO_PRINTF3(_L("CheckBlankWindow(windowRect,TRgb::Gray16(ii),TheClient->iScreen) return value - Expected: %d, Actual: %d"), ETrue, retBool); + + TRgb col3 = TRgb::Gray16(ii).Internal(); + TRgb col1 = FadeRgb(col3, fadeMapFactor, fadeMapOffset); + iBlankWin->BaseWin()->SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly,fb,fw); + ViewDelay(); +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + retBool = CheckBlankWindow(windowRect,col1,TheClient->iScreen); +#else + retBool = LossyCheckBlankWindow(*TheClient->iScreen, *iTestWinCopy, windowRect, col1); +#endif + TEST(retBool); + if (!retBool) + INFO_PRINTF3(_L("CheckBlankWindow(windowRect,TRgb::Gray16((ii*wb+add)/15),TheClient->iScreen) return value - Expected: %d, Actual: %d"), ETrue, retBool); + + iBlankWin->BaseWin()->SetFaded(EFalse,RWindowTreeNode::EFadeWindowOnly); + ViewDelay(); +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + retBool = CheckBlankWindow(windowRect,TRgb::Gray16(ii),TheClient->iScreen); +#else + retBool = LossyCheckBlankWindow(*TheClient->iScreen, *iTestWinCopy, windowRect, TRgb::Gray16(ii)); +#endif + TEST(retBool); + if (!retBool) + INFO_PRINTF3(_L("CheckBlankWindow(windowRect,TRgb::Gray16(ii),TheClient->iScreen) return value - Expected: %d, Actual: %d"), ETrue, retBool); + + } + ++test; + } +#endif //__MARM__ + } + +void CTFade::Draw(TBool aAlternativeFade/*=EFalse*/) + { + __ASSERT_ALWAYS(iWin,AutoPanic(EAutoFadeWindow)); + TRgb grey=TRgb::Gray4(2); + Draw(0,&grey,aAlternativeFade); + Draw(1,NULL,aAlternativeFade); + iContent=1; + CompareWithBitmap(EFalse); + if (aAlternativeFade) + iWin->WinTreeNode()->SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly,BLACK_ALTERNATE,WHITE_ALTERNATE); + else + iWin->WinTreeNode()->SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly); + CompareWithBitmap(ETrue); + Draw(3,NULL,aAlternativeFade); + iContent=2; + CompareWithBitmap(ETrue); + iWin->WinTreeNode()->SetFaded(EFalse,RWindowTreeNode::EFadeWindowOnly); + CompareWithBitmap(EFalse); + } + +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA +void CTFade::GCDraw() + { + __ASSERT_ALWAYS(iWin,AutoPanic(EAutoFadeWindow)); + TRgb grey=TRgb::Gray4(2); + TInt ii; + GCDraw(0,&grey); + GCDraw(3,NULL); + for (ii=3;ii<70;ii+=13) + GCDraw(2,&ii); + iContent=6; + CompareWindows(); + GCDraw(0,&grey,ETrue); + GCDraw(3,NULL,ETrue); + for (ii=3;ii<70;ii+=13) + GCDraw(2,&ii,ETrue); + GCDraw(1,NULL,ETrue); + iContent=7; + CompareWindows(ETrue); + } +#endif // TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + +void CTFade::ObscuredL() + { + CTBlankWindow* blankWin=new(ELeave) CTBlankWindow(); + TRect windowRect(iWindowRect); + windowRect.Shrink(30,30); + blankWin->SetUpL(windowRect.iTl,windowRect.Size(),TheClient->iGroup,*TheClient->iGc); + + __ASSERT_ALWAYS(iWin,AutoPanic(EAutoFadeWindow)); + TRgb grey=TRgb::Gray4(2); + Draw(0,&grey); + Draw(3,NULL); + iContent=3; + iWin->WinTreeNode()->SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly); + blankWin->SetVisible(EFalse); + CompareWithBitmap(ETrue); + blankWin->SetVisible(ETrue); + grey=TRgb::Gray4(1); + Draw(0,&grey); + for (TInt ii=1;ii<37;ii+=7) + Draw(2,&ii); + iContent=4; + blankWin->SetVisible(EFalse); + CompareWithBitmap(ETrue); + blankWin->SetVisible(ETrue); + iWin->WinTreeNode()->SetFaded(EFalse,RWindowTreeNode::EFadeWindowOnly); + blankWin->SetVisible(EFalse); + CompareWithBitmap(EFalse); + + delete blankWin; + } + +void CTFade::MovingL() + { + CTBlankWindow* blankWin=new(ELeave) CTBlankWindow(); + TRect windowRect(iWindowRect); + windowRect.Shrink(40,40); + blankWin->SetUpL(windowRect.iTl,windowRect.Size(),TheClient->iGroup,*TheClient->iGc); + + __ASSERT_ALWAYS(iWin,AutoPanic(EAutoFadeWindow)); + TRgb grey=TRgb::Gray4(2); + Draw(0,&grey); + Draw(1,NULL); + for (TInt ii=2;ii<60;ii+=11) + Draw(2,&ii); + iContent=5; + blankWin->SetPos(windowRect.iTl+TPoint(25,-25)); + iWin->WinTreeNode()->SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly); + blankWin->SetPos(windowRect.iTl+TPoint(10,25)); + blankWin->SetVisible(EFalse); + CompareWithBitmap(ETrue); + blankWin->SetVisible(ETrue); + blankWin->SetPos(windowRect.iTl+TPoint(25,-25)); + iWin->WinTreeNode()->SetFaded(EFalse,RWindowTreeNode::EFadeWindowOnly); + blankWin->SetPos(windowRect.iTl+TPoint(-5,10)); + blankWin->SetVisible(EFalse); + CompareWithBitmap(EFalse); + + delete blankWin; + } + +void CTFade::SystemFadeL() + { + if (MaxGrays()==0 && MaxColors()<256) + return; + + CTBlankWindow* win[16]; + TInt height=iTestWinSize.iHeight/16; + TRect rect(iWindowRect); + rect.SetHeight(height); + TInt ii; + for (ii=0;ii<16;++ii) //Causes memory leakage under OOM + { + win[ii]=new(ELeave) CTBlankWindow(); + win[ii]->SetUpL(rect.iTl,rect.Size(),TheClient->iGroup,*TheClient->iGc); + win[ii]->BaseWin()->SetRequiredDisplayMode(EGray16); + win[ii]->SetColor(TRgb::Gray16(ii)); + rect.Move(0,height); + } + rect=iWindowRect; + rect.SetHeight(height); +#if defined(SMALL_RECTS) + TSize size(rect.Size()); + size.iWidth=Min(SIZE_X,size.iWidth); + size.iHeight=Min(SIZE_Y,size.iHeight); + rect.SetSize(size); +#endif + + TBool retBool; + + // system fade on + TheClient->iWs.SetSystemFaded(ETrue); + for (ii=0;ii<16;++ii) + { + retBool = win[ii]->BaseWin()->IsFaded(); + TEST(retBool); + if (!retBool) + INFO_PRINTF3(_L("win[ii]->BaseWin()->IsFaded() return value - Expected: %d, Actual: %d"), ETrue, retBool); + } + TestStrips(rect,height,0); + + // system fade off + TheClient->iWs.SetSystemFaded(EFalse); + for (ii=0;ii<16;++ii) + { + retBool = !win[ii]->BaseWin()->IsFaded(); + TEST(retBool); + if (!retBool) + INFO_PRINTF3(_L("!win[ii]->BaseWin()->IsFaded() return value - Expected: %d, Actual: %d"), ETrue, retBool); + } + TestStrips(rect,height,16); + + // Now with half non fading + for (ii=8;ii<16;++ii) + win[ii]->WinTreeNode()->SetNonFading(ETrue); + + // system fade on + TheClient->iWs.SetSystemFaded(ETrue); + TestStrips(rect,height,8,ETrue); + + // system fade off + TheClient->iWs.SetSystemFaded(EFalse); + TestStrips(rect,height,16); + + for (ii=0;ii<16;++ii) + delete win[ii]; + } + +void CTFade::SystemAlternateFadeL() + { +#if defined(__MARM__) + return; +#else + __ASSERT_ALWAYS(iBlankWin,AutoPanic(EAutoFadeWindow)); + TSize size=iTestWinSize; +#if defined(SMALL_RECTS) + size.iWidth=Min(SIZE_X,size.iWidth); + size.iHeight=Min(SIZE_Y,size.iHeight); +#endif + if (MaxGrays()==0 && MaxColors()<256) + return; + TRect windowRect(iBlankWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),size); + TUint8 bm; + TUint8 wm; + TUint8 fb; + TUint8 fw; + TInt wb; + TInt add; + TInt test=0; + TInt ii; + TBool retBool; + FOREVER + { + TInt fadeMapFactor = 0; + TInt fadeMapOffset = 0; + fw=0; + switch (test) + { + case 0: //Nothing + bm=0; + wm=15; + break; + case 1: //Shadowing or Quartz fading + bm=0; + wm=7; + fw=127; + break; + default: + return; + } + wb=wm-bm; + add=15*bm+7; + fb=STATIC_CAST(TUint8,17*bm); + if (!fw) + fw=STATIC_CAST(TUint8,17*wm); + fadeMapFactor = fw - fb; + fadeMapOffset = fb; + for (ii=0;ii<16;ii+=5) + { + iBlankWin->SetColor(TRgb::Gray16(ii)); + ViewDelay(); + TheClient->iWs.Finish(); +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + retBool = CheckBlankWindow(windowRect,TRgb::Gray16(ii),TheClient->iScreen); +#else + retBool = LossyCheckBlankWindow(*TheClient->iScreen, *iTestWinCopy, windowRect, TRgb::Gray16(ii)); +#endif + TEST(retBool); + if (!retBool) + INFO_PRINTF3(_L("CheckBlankWindow(windowRect,TRgb::Gray16(ii),TheClient->iScreen) return value - Expected: %d, Actual: %d"), ETrue, retBool); + + TheClient->iWs.SetSystemFaded(ETrue,fb,fw); + ViewDelay(); + + TRgb col3 = TRgb::Gray16(ii).Internal(); + TRgb col1 = FadeRgb(col3, fadeMapFactor, fadeMapOffset); +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + retBool = CheckBlankWindow(windowRect,col1,TheClient->iScreen); +#else + retBool = LossyCheckBlankWindow(*TheClient->iScreen, *iTestWinCopy, windowRect, col1); +#endif + TEST(retBool); + if (!retBool) + INFO_PRINTF3(_L("CheckBlankWindow(windowRect,TRgb::Gray16((ii*wb+add)/15),TheClient->iScreen) return value - Expected: %d, Actual: %d"), ETrue, retBool); + + TheClient->iWs.SetSystemFaded(EFalse); + ViewDelay(); +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + retBool = CheckBlankWindow(windowRect,TRgb::Gray16(ii),TheClient->iScreen); +#else + retBool = LossyCheckBlankWindow(*TheClient->iScreen, *iTestWinCopy, windowRect, TRgb::Gray16(ii)); +#endif + TEST(retBool); + if (!retBool) + INFO_PRINTF3(_L("CheckBlankWindow(windowRect,TRgb::Gray16(ii),TheClient->iScreen) return value - Expected: %d, Actual: %d"), ETrue, retBool); + } + ++test; + } +#endif //__MARM__ + } + +void CTFade::FadeBehindWhenMovedL() + { + __ASSERT_ALWAYS(iBlankWin,AutoPanic(EAutoFadeWindow)); + TDisplayMode displayMode=iBlankWin->BaseWin()->DisplayMode(); + iBlankWin->BaseWin()->SetRequiredDisplayMode(EGray16); + iBlankWin->SetColor(TRgb::Gray16(1)); + TSize size(iTestWinSize.iHeight/4,iTestWinSize.iWidth/4); + CTBlankWindow* blankWinTemp=new(ELeave) CTBlankWindow(); + CleanupStack::PushL(blankWinTemp); + blankWinTemp->SetUpL(TPoint(5,5),size,iBlankWin,*TheClient->iGc); + blankWinTemp->BaseWin()->SetRequiredDisplayMode(EGray16); + blankWinTemp->SetColor(TRgb::Gray16(15)); + blankWinTemp->BaseWin()->FadeBehind(ETrue); + TheClient->Flush(); + blankWinTemp->SetPos(TPoint(5,120)); + //Check whether the back window is faded or not + TBool retBool = iBlankWin->BaseWin()->IsFaded(); + TEST(retBool); + if (!retBool) + INFO_PRINTF3(_L("iBlankWin->BaseWin()->IsFaded() return value - Expected: %d, Actual: %d"), ETrue, retBool); + +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + CheckRect(iWindowRect.iTl+TPoint(5,5),iWindowRect.iTl+TPoint(75,5),size,_L("CTFade::FadeBehindWhenMovedL()")); +#else + TInt res = LossyCompareWindow(*TheClient->iScreen, *iTestWinCopy, *iCheckWinCopy, TRect(iWindowRect.iTl+TPoint(75,5),size)); + TEST(res); +#endif + + //Check whether the area behind the moved window and any other area on same window are identical + blankWinTemp->BaseWin()->FadeBehind(EFalse); + iBlankWin->BaseWin()->SetRequiredDisplayMode(displayMode); + CleanupStack::PopAndDestroy(blankWinTemp); + } + +void CTFade::FadeBehindTransparentWindowL() + { + const TInt KNumberOfWindows = 3; + CRedrawWin* win[KNumberOfWindows]; + TRect rect(iWindowRect); + rect.Resize(-iWindowRect.Width()/3,-iWindowRect.Height()/3); + rect.Move(iWindowRect.Width()/10,iWindowRect.Height()/5); + TRect rectWin[KNumberOfWindows]; + + for (TInt ii=0; iiConstructExtLD(*TheClient->iGroup,rectWin[ii].iTl,rectWin[ii].Size()); + win[ii]->AssignGC(*TheClient->iGc); + win[ii]->Win()->EnableRedrawStore(EFalse); + win[ii]->BaseWin()->SetRequiredDisplayMode(EColor16MA); + if (ii==0) + { + win[ii]->Win()->SetBackgroundColor(TRgb(200,0,0,255)); + } + else + { + TEST(KErrNone == win[ii]->Win()->SetTransparencyAlphaChannel()); + if (iStep->TestStepResult() != EPass) + { + INFO_PRINTF1(_L("Transparency Alpha channel failed to be enabled")); + } + win[ii]->Win()->SetBackgroundColor(TRgb(40,100,0,0)); //RGB colour is of minor importance, as the window is fully transparent (Alpha=0) + } + win[ii]->Activate(); + + //Make sure each window is drawn to the screen now when the new background + //colour have been set but before the call to SetFaded + win[ii]->Win()->BeginRedraw(); + win[ii]->Win()->EndRedraw(); + + rect.Resize(0,-iWindowRect.Height()/10); + rect.Move(iWindowRect.Width()/10,iWindowRect.Height()/20); + } + TheClient->iWs.Flush(); + TheClient->iWs.Finish(); + + win[0]->Win()->SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly); + win[1]->Win()->SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly); + win[2]->Win()->SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly); + + TheClient->iWs.Flush(); + TheClient->iWs.Finish(); + + // As the windows ovelap on their left side, compare the top left corners of the faded windows in order to verify that + // for the opaque window the directly on top faded area and the faded area under the transparent window (the area that + // overlaps with the transparent windows) have the same colour. + TRgb rgbWin[KNumberOfWindows]; + TheClient->iScreen->GetPixel(rgbWin[0], rectWin[0].iTl); + TheClient->iScreen->GetPixel(rgbWin[1], rectWin[1].iTl); + TheClient->iScreen->GetPixel(rgbWin[2], rectWin[2].iTl); + + TEST( ETrue == (rgbWin[0].Red()==rgbWin[1].Red())&&(rgbWin[0].Green()==rgbWin[1].Green())&&(rgbWin[0].Blue()==rgbWin[1].Blue()) ); + TEST( ETrue == (rgbWin[0].Red()==rgbWin[2].Red())&&(rgbWin[0].Green()==rgbWin[2].Green())&&(rgbWin[0].Blue()==rgbWin[2].Blue()) ); + + for (TInt ii=0; iiSetTestStepID(KUnknownSYMTestCaseIDName); + switch(++iTest->iState) + { +/** +@SYMTestCaseID GRAPHICS-WSERV-0218 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test fading colours in windows + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Fade the colours in windows and check they fade correctly + +@SYMTestExpectedResults Colour fade correctly +*/ + case 1: + ((CTFadeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0218")); + iTest->LogSubTest(_L("Color Check")); + CreateBlankWindowL(); + ColorTest(); + //iTest->iState=5; + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0219 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test fading in a blank window + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Fade in a blank window and check the fading occurs correctly + +@SYMTestExpectedResults Fading in a blank window occurs correctly +*/ + case 2: + ((CTFadeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0219")); + iTest->LogSubTest(_L("Blank Window")); + BlankWindowL(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0220 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test fading in child windows + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Fade in child windows and check the fading occurs correctly + +@SYMTestExpectedResults Fading in the child windows occurs correctly +*/ + case 3: + ((CTFadeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0220")); + iTest->LogSubTest(_L("Fade Children")); + FadeChildrenL(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0221 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test fading in newly created child windows + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Fade in newly created child windows and check the fading occurs correctly + +@SYMTestExpectedResults Fading in the newly created child windows occurs correctly +*/ + case 4: + ((CTFadeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0221")); + iTest->LogSubTest(_L("Fade Children newly created")); + FadeChildrenAfterNewChildIsCreatedL(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0222 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test fading in window behind another window + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Fade in window behind another window and check the fading occurs correctly + +@SYMTestExpectedResults Fading in window occurs correctly +*/ + case 5: + ((CTFadeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0222")); + iTest->LogSubTest(_L("Fade Behind")); + FadeBehindL(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0223 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test differnt fading techniques in a window + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Fade using different fading techniques in a window + and check the fading occurs correctly + +@SYMTestExpectedResults Fading in window occurs correctly +*/ + case 6: + ((CTFadeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0223")); +#if(defined(__DISPLAY_MODE_64K_COLOR)) //The test case Alternative Fadings1&2 & System Fade are not executed for EColor64k + iTest->LogSubTest(_L("Alternative Fadings1")); + ColorTest2(); +#else + LOG_MESSAGE(_L("Alternative Fadings1 test not run")); +#endif + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0224 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test differnt fading techniques in a window + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Fade using different fading techniques in a window + and check the fading occurs correctly + +@SYMTestExpectedResults Fading in window occurs correctly +*/ + case 7: + ((CTFadeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0224")); +#if(defined(__DISPLAY_MODE_64K_COLOR)) //The test case Alternative Fadings1&2 & System Fade are not executed for EColor64k + iTest->LogSubTest(_L("Alternative Fadings2")); + FadeTest(); +#else + LOG_MESSAGE(_L("Alternative Fadings2 test not run")); +#endif + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0225 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test differnt system wide fading techniques in a window + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Fade using different system wide fading techniques in a window + and check the fading occurs correctly + +@SYMTestExpectedResults Fading in system occurs correctly +*/ + case 8: + ((CTFadeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0225")); + iTest->LogSubTest(_L("System Fade")); + SystemFadeL(); + SystemAlternateFadeL(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0226 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test fading in window behind another window when the window has been moved + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Fade in window behind another window and check the fading occurs correctly + +@SYMTestExpectedResults Fading in window occurs correctly +*/ + case 9: + ((CTFadeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0226")); + iTest->LogSubTest(_L("Fade behind moved")); + FadeBehindWhenMovedL(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0227 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Destroy the blnk window used for fading + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Destroy the blnk window used for fading and check it was deleted correctly + +@SYMTestExpectedResults The window is destroyed +*/ + case 10: + ((CTFadeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0227")); + DestroyBlankWindow(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0228 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test backup window creation and drawing + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Create a backup window and draw in it + +@SYMTestExpectedResults The drawing is correct in the window +*/ + case BACKUPWIN: + ((CTFadeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0228")); + iTest->LogSubTest(_L("BackupWin Draw")); + CreateBitmapsL(); + CreateBackupWindowL(EFalse); + Draw(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0229 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test fading with backup window obscured + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Test fading with the backup window obscured + +@SYMTestExpectedResults Fading occurs correctly with window obscured +*/ + case BACKUPWIN+1: + ((CTFadeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0229")); + iTest->LogSubTest(_L("BackupWin Obscured")); + ObscuredL(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0230 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test fading with backup window being moved + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Test fading with the backup window being moved + +@SYMTestExpectedResults Fading occurs correctly with window moved +*/ + case BACKUPWIN+2: + ((CTFadeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0230")); + iTest->LogSubTest(_L("BackupWin Moving")); + MovingL(); + DestroyDrawableWindow(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0231 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test backup window creation and drawing + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Create a backup window and draw in it + +@SYMTestExpectedResults The drawing is correct in the window +*/ + case BACKUPWIN+3: + ((CTFadeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0231")); + iTest->LogSubTest(_L("BackupWin Draw")); + CreateBackupWindowL(ETrue); + Draw(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0232 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test fading with backup window obscured + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Test fading with the backup window obscured + +@SYMTestExpectedResults Fading occurs correctly with window obscured +*/ + case BACKUPWIN+4: + ((CTFadeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0232")); + iTest->LogSubTest(_L("BackupWin Obscured")); + ObscuredL(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0233 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test fading with backup window being moved + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Test fading with the backup window being moved + +@SYMTestExpectedResults Fading occurs correctly with window moved +*/ + case BACKUPWIN+5: + ((CTFadeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0233")); + iTest->LogSubTest(_L("BackupWin Moving")); + MovingL(); + DestroyDrawableWindow(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0234 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test redraw window creation and drawing + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Create a redraw window and draw in it + +@SYMTestExpectedResults The drawing is correct in the window +*/ + case REDRAWWIN: + ((CTFadeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0234")); + iTest->LogSubTest(_L("RedrawWin Draw")); + CreateRedrawWindowL(); + Draw(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0235 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test fading with redraw window obscured + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Test fading with the redraw window obscured + +@SYMTestExpectedResults Fading occurs correctly with window obscured +*/ + case REDRAWWIN+1: + ((CTFadeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0235")); + iTest->LogSubTest(_L("RedrawWin Obscured")); + ObscuredL(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0236 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test fading with redraw window being moved + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Test fading with the redraw window being moved + +@SYMTestExpectedResults Fading occurs correctly with window moved +*/ + case REDRAWWIN+2: + ((CTFadeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0236")); + iTest->LogSubTest(_L("RedrawWin Moving")); + MovingL(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0237 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test different fading techniques within a redraw window + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Test different fading techniques within a redraw window + +@SYMTestExpectedResults Fading occurs correctly for the different techniques +*/ + case REDRAWWIN+3: + ((CTFadeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0237")); + iTest->LogSubTest(_L("AlternativeFadeDraw")); + Draw(ETrue); + break; + +/** +@SYMTestCaseID GRAPHICS-WSERV-0238 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test fading within a redraw window using the graphic context + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Test fading within a redraw window using the graphic context + +@SYMTestExpectedResults Fading occurs correctly in the window +*/ + case REDRAWWIN+4: + ((CTFadeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0238")); +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + iTest->LogSubTest(_L("GC Test")); + GCDraw(); + DestroyDrawableWindow(); + DestroyBitmaps(); +#endif + break; + +/** +@SYMTestCaseID GRAPHICS-WSERV-0538 + +@SYMDEF DEF120965 + +@SYMTestCaseDesc Test fading under transparent window + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Construct opaque window lying under two transparent windows. Fade the opaque and the transparent windows. + +@SYMTestExpectedResults Each of the overlapping areas should be faded only once. +*/ + case REDRAWWIN+5: + { + ((CTFadeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0538")); + iTest->LogSubTest(_L("Fade behind transparent window")); + CRedrawWin* win = new(ELeave) CRedrawWin(this); + win->ConstructL(TRect(0,0,0,0)); + TInt transparency = win->Win()->SetTransparencyAlphaChannel(); + if (transparency!=KErrNotSupported) + { + FadeBehindTransparentWindowL(); + } + else + { + WARN_PRINTF1(_L("Transparency not supported. Skipping test.")); + } + delete win; + break; + } + case REDRAWWIN+6: + ((CTFadeStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + iTest->LogSubTest(_L("Test complete\n")); +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA + DestroyDrawableWindow(); + DestroyBitmaps(); +#endif + ((CTFadeStep*)iStep)->CloseTMSGraphicsStep(); + TestComplete(); + break; + default: + ((CTFadeStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + break; + } + ((CTFadeStep*)iStep)->RecordTestResultL(); + } + +__WS_CONSTRUCT_STEP__(Fade) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TFADE.H --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TFADE.H Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,145 @@ + +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef __TFADE_H__ +#define __TFADE_H__ + +#include "AUTO.H" + +#if defined(__MARM__) + #define SMALL_RECTS +#endif +#define SIZE_X 10 +#define SIZE_Y 5 +#define DRAW_MODE EColor64K //Mode used for testing fadded drawing +#define BLACK_NORMAL 128 +#define WHITE_NORMAL 255 +#define BLACK_ALTERNATE 0 +#define WHITE_ALTERNATE 127 +#define NUMBER_OF_WINDOWS 16 + +#define MODE_LT_64K(mode) (TDisplayModeUtils::NumDisplayModeColors(mode)<65536) + +#define ETrue 1 +#define EFalse 0 + +class CTFade : public CTWsGraphicsBase + { +public: + CTFade(CTestStep* aStep); + ~CTFade(); + void ConstructL(); + TInt Content(); + void Drawing(TInt aDrawFunc, CBitmapContext *gc); + //Different Tests + void ColorTest(); + void BlankWindowL(); + void FadeChildrenL(); + void FadeChildrenAfterNewChildIsCreatedL(); + void FadeBehindL(); + void ColorTest2(); + void FadeTest(); + void Draw(TBool aAlternativeFade=EFalse); + void ObscuredL(); + void MovingL(); +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + void GCDraw(); +#endif + void SystemFadeL(); + void SystemAlternateFadeL(); + void FadeBehindWhenMovedL(); + void FadeBehindTransparentWindowL(); +protected: +//from CTGraphicsStep + virtual void RunTestCaseL(TInt aCurTestCase); +private: + void CreateBlankWindowL(); + void DestroyBlankWindow(); + void CreateBackupWindowL(TBool aMaintainBackup); + void CreateRedrawWindowL(); + void DestroyDrawableWindow(); + void CreateBitmapsL(); + void DestroyBitmaps(); + void Draw(TInt aDrawFunc, TAny *aParam, TBool aAlternativeFade=EFalse, TBool aFade=EFalse); +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + void GCDraw(TInt aDrawFunc, TAny *aParam, TBool aAlternativeFade=EFalse); +#endif + void Draw(TInt aDrawFunc, TAny *aParam, CBitmapContext *gc); + void CompareWithBitmap(TBool aFade); + void CompareWindows(TBool aAlternativeFade=EFalse); + void TestStrips(TRect aRect,TInt aHeight,TInt aNumNotFaded,TBool aInvert=EFalse); + void TestBlocks(TRect aRect,TSize aSize,TInt aNumNotFaded,TBool aInvert=EFalse); + TInt Fade4(TInt aGray4); + TInt Fade16(TInt aGray16); + TRgb FadeRgb(TRgb aColor); + TRgb FadeRgb(TRgb aColor, TInt aFadeMapFactor, TInt aFadeMapOffset); + inline void ViewDelay(); +private: + CTBlankWindow* iBlankWin; + CTDrawableWin* iWin; + TBool iOwnWindow; + TRect iWindowRect; + TRect iBaseRect; + CFbsBitmap iNormalBitmap; + CFbsBitmap iFadedBitmap; + CFbsBitGc *iNormalBitGc; + CFbsBitGc *iFadedBitGc; + CFbsDevice *iNormalBitmapDevice; + CFbsDevice *iFadedBitmapDevice; + TInt iContent; + TDisplayMode iBaseWinMode; + TDisplayMode iDeviceDisplayMode; + TSize iTestWinSize; + TDisplayMode iFadeDrawMode; + CFbsBitmap *iTestWinCopy; + CFbsBitmap *iCheckWinCopy; +#if defined (__MARM_THUMB__) +GLDEF_D TBool CanFade; +GLDEF_D TBool CanFadeSet; +#endif + }; + +class CRedrawWin : public CTWin + { +public: + CRedrawWin(CTFade *aTest); + void ConstructL(TRect aArea); + ~CRedrawWin(); + void Draw(); + +protected: + CTFade* iTest; + }; + +class CTFadeStep : public CTGraphicsStep + { +public: + CTFadeStep(); +protected: + //from CTGraphicsStep + virtual CTGraphicsBase* CreateTestL(); + }; + +_LIT(KTFadeStep,"TFade"); + + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TFADINGBITMAP.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TFADINGBITMAP.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,250 @@ +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// The fix enables the fading effect with alpha-blending, which was not applied bofore. +// The test will load a bitmap and two different masks: on/off and alpha-blend. +// The bitmap will be masked with these masks and displayed before and after +// setting the fading effect. +// All different colour modes are being tested for both mask types. +// The test will check the colour of a specific pixel in the scene before and after the +// fading. The higher values in the After circle means that it has been highlighted. +// The result will be printed in wstest log file. +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include "TFADINGBITMAP.H" + +//=================================================== +// CBaseWin Declaration +//=================================================== + +CBaseWin::CBaseWin(): CTWin() + { + } + +CBaseWin::~CBaseWin() + { + delete iTempBitmap; + delete iMaskGray256; + delete iMaskGray2; + delete iTempMask; + delete iBitmap; + } + +void CBaseWin::ConstructWinL(TPoint aPos, TSize aSize, TBool aVisible) + { + /*** Setting up the window ***/ + iSize = aSize; + SetUpL(aPos, aSize, TheClient->iGroup, *TheClient->iGc, aVisible); + Win()->SetBackgroundColor(TRgb(20, 80, 20)); // dark green background + BaseWin()->SetRequiredDisplayMode(EColor64K); + + /*** 24 bit bitmap ***/ + // the original 24b bitmap to mask + iTempBitmap = new (ELeave) CFbsBitmap(); + User::LeaveIfError(iTempBitmap->Load(_L("Z:\\WSTEST\\WSAUTOTEST.MBM"), EMbmWsautotestCircles24b)); + iBitmap = new (ELeave) CFbsBitmap(); + + /*** on/off mask ***/ + iMaskGray2 = new (ELeave) CFbsBitmap(); + User::LeaveIfError(iMaskGray2->Load(_L("Z:\\WSTEST\\WSAUTOTEST.MBM"), EMbmWsautotestCircles_mask2b)); + + /*** alpha-blend mask ***/ + // holds the 24bit copy of the alpha blend mask which will be + // copied into the proper Gray256 mask, iMaskGray256. + iTempMask = new (ELeave) CFbsBitmap(); + User::LeaveIfError(iTempMask->Load(_L("Z:\\WSTEST\\WSAUTOTEST.MBM"), EMbmWsautotestCircles_mask256)); + // alpha blend mask; copying its data from iTempMask + iMaskGray256 = new (ELeave) CFbsBitmap(); + User::LeaveIfError(iMaskGray256->Create(iTempBitmap->SizeInPixels(),EGray256)); + CFbsBitmapDevice *dev = CFbsBitmapDevice::NewL(iMaskGray256); + CleanupStack::PushL(dev); + CFbsBitGc *gc; + User::LeaveIfError(dev->CreateContext(gc)); + // performing the copying here + gc->BitBlt(TPoint(0,0), iTempMask); + // cleaning up + CleanupStack::Pop(); + delete gc; + gc = NULL; + delete dev; + dev = NULL; + } + +void CBaseWin::Draw() + { + iGc->Clear(); + + // Font intialization + CFont* myFont; + _LIT(KMyFontName,"Swiss"); + TFontSpec myFontSpec = TFontSpec(KMyFontName,16); // to get smallest Swiss font + TFontStyle style = TFontStyle (EPostureUpright, EStrokeWeightBold, EPrintPosNormal); + myFontSpec.iFontStyle = style; + User::LeaveIfError(TheClient->iScreen->GetNearestFontInPixels(myFont, myFontSpec)); + iGc->UseFont(myFont); + iGc->SetPenStyle(CGraphicsContext::ESolidPen); + iGc->SetPenColor(TRgb(255, 255, 255)); + + // drawing text + iGc->DrawText(_L("Fading = OFF"), TPoint(130,15)); + iGc->DrawText(_L("Fading = ON"), TPoint(275,15)); + iGc->DrawText(_L("Alpha blend"), TPoint(15,90)); + iGc->DrawText(_L("on/off mask"), TPoint(15,190)); + TBuf <30> displayMode(_L("Display Mode = ")); + displayMode.Append(iMode); + iGc->DrawText(displayMode, TPoint(385,100)); + + /*** drawing bitmap with its on/off mask and alpha-blending + before and after fading ***/ + iGc->BitBltMasked(TPoint(140,25), iBitmap, + TRect(0,0,100,100), iMaskGray256, EFalse); + // Save the pixel colour of a pixel on the outer ring of the circle + // before fading enabled. + TheClient->iScreen->GetPixel(iNonFadedPixel, TPoint(190,30)); + + iGc->SetFaded(ETrue); + iGc->BitBltMasked(TPoint(270,25), iBitmap, + TRect(0,0,100,100), iMaskGray256, EFalse); + // Save the pixel colour of a pixel on the outer ring of the circle + // after fading enabled. + TheClient->iScreen->GetPixel(iFadedPixel, TPoint(320,30)); + + iGc->SetFaded(EFalse); + + iGc->BitBltMasked(TPoint(140,125), iBitmap, + TRect(0,0,100,100), iMaskGray2, EFalse); + iGc->SetFaded(ETrue); + iGc->BitBltMasked(TPoint(270,125), iBitmap, + TRect(0,0,100,100), iMaskGray2, EFalse); + iGc->SetFaded(EFalse); + + iGc->DiscardFont(); + TheClient->iScreen->ReleaseFont(myFont); + } + + +//=================================================== +// CTFadingBitmap Definition +//=================================================== + +CTFadingBitmap::CTFadingBitmap(CTestStep* aStep): + CTWsGraphicsBase(aStep), iTestResult(ETrue) + { + } + +CTFadingBitmap::~CTFadingBitmap() + { + delete iBgWin; + } + +void CTFadingBitmap::TestFadingL() + { + // Modes to test + TDisplayMode modes[] = + { + EGray2, EGray4, EGray16, EGray256, + EColor16, EColor256, EColor4K, EColor64K, + EColor16M, EColor16MU, EColor16MA, EColor16MAP + }; + + TBuf <12> modesTxt []= + { + _L("EGray2"), _L("EGray4"), _L("EGray16"), _L("EGray256"), + _L("EColor16"), _L("EColor256"), _L("EColor4K"), _L("EColor64K"), + _L("EColor16M"), _L("EColor16MU"), _L("EColor16MA"), _L("EColor16MAP") + }; + + TBuf <100> testTxt; + for( int i = 0; i < 12; i++) + { + testTxt.Format(modesTxt[i]); + INFO_PRINTF1(testTxt); + // Here we copy the content of the temp bitmap, which holds the test bitmap, + // into the bitmap created with alternating color depths. + User::LeaveIfError(iBgWin->iBitmap->Create(iBgWin->iTempBitmap->SizeInPixels(), modes[i])); + CFbsBitmapDevice *dev = CFbsBitmapDevice::NewL(iBgWin->iBitmap); + CleanupStack::PushL(dev); + CFbsBitGc *gc; + User::LeaveIfError(dev->CreateContext(gc)); + // performing the copying here + gc->BitBlt(TPoint(0,0), iBgWin->iTempBitmap); + // setting the mode text to display it + iBgWin->iMode = modesTxt[i]; + // draws the bitmap on screen + iBgWin->DrawNow(); + TheClient->Flush(); + User::After(5000); + // cleaning up + CleanupStack::Pop(); + delete gc; + gc = NULL; + delete dev; + dev = NULL; + + // Here the colours of pixels before and after fading are printed in wstest log + testTxt.Format(_L("Nonfaded circle - color of the outside ring: R=%d G=%d B=%d"), iBgWin->iNonFadedPixel.Red(), iBgWin->iNonFadedPixel.Green(), iBgWin->iNonFadedPixel.Blue()); + INFO_PRINTF1(testTxt); + testTxt.Format(_L("Faded circle - color of the outside ring: R=%d G=%d B=%d"), iBgWin->iFadedPixel.Red(), iBgWin->iFadedPixel.Green(), iBgWin->iFadedPixel.Blue()); + INFO_PRINTF1(testTxt); + + // Checks if the colors are the same before and after the fading. + // The color will be the same only in EGray2 and EGray4 as there are no enough + // color variations to represent the fading and nonfading effects. + if(iTestResult && + iBgWin->iNonFadedPixel.Red() == iBgWin->iFadedPixel.Red() && + iBgWin->iNonFadedPixel.Green() == iBgWin->iFadedPixel.Green() && + iBgWin->iNonFadedPixel.Blue() == iBgWin->iFadedPixel.Blue() && + modes[i] != EGray2 && modes[i] != EGray4) + iTestResult = EFalse; + } + } + +void CTFadingBitmap::ConstructL() + { + // construct the base window of the test in the background + TSize scrSize = TSize(TheClient->iScreen->SizeInPixels()); + iBgWin = new (ELeave) CBaseWin(); + iBgWin->ConstructWinL(TPoint(0,0), scrSize, ETrue); + } + +void CTFadingBitmap::RunTestCaseL(TInt aCurTestCase) + { + ((CTFadingBitmapStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); + switch(aCurTestCase) + { + case 1: +/** +@SYMTestCaseID GRAPHICS-WSERV-0566 +*/ + ((CTFadingBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0566")); + TestFadingL(); + // Fails or passes the test + if(!iTestResult) + TEST(EFalse); + break; + default: + ((CTFadingBitmapStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + ((CTFadingBitmapStep*)iStep)->CloseTMSGraphicsStep(); + TestComplete(); + } + ((CTFadingBitmapStep*)iStep)->RecordTestResultL(); + } + +__WS_CONSTRUCT_STEP__(FadingBitmap) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TFADINGBITMAP.H --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TFADINGBITMAP.H Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,94 @@ +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef __TFADINGBITMAP_H__ +#define __TFADINGBITMAP_H__ + +#include +#include +#include "../tlib/testbase.h" +#include "AUTO.H" +#include "TGraphicsHarness.h" + + +//=================================================== +// CBaseWin Definition +// The plain green background window +//=================================================== + +class CBaseWin : public CTWin + { +public: + CBaseWin(); + ~CBaseWin(); + void Draw(); + void ConstructWinL(TPoint, TSize, TBool); + +public: + CFbsBitmap *iTempBitmap; + CFbsBitmap *iMaskGray256; + CFbsBitmap *iMaskGray2; + CFbsBitmap *iTempMask; + CFbsBitmap *iBitmap; + + TRgb iFadedPixel; + TRgb iNonFadedPixel; + + TBuf <11> iMode; + }; + + +//=================================================== +// CTFadingBitmap Definition +// Bitmaps to be tested +//=================================================== + +class CTFadingBitmap : public CTWsGraphicsBase + { +public: + CTFadingBitmap(CTestStep* aStep); + ~CTFadingBitmap(); + /*Sets the windowing environment,*/ + void ConstructL(); + +protected: + //from CTGraphicsStep - Calls the fading bitmap test. + virtual void RunTestCaseL(TInt aCurTestCase); +private: + void TestFadingL (); + +private: + CBaseWin *iBgWin; + TBool iTestResult; + }; + +class CTFadingBitmapStep : public CTGraphicsStep + { +public: + CTFadingBitmapStep(); +protected: + //from CTGraphicsStep + virtual CTGraphicsBase* CreateTestL(); + }; + +_LIT(KTFadingBitmapStep,"TFadingBitmap"); + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TFLICKERFREE.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TFLICKERFREE.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,139 @@ +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// TMULSCREENS.CPP +// Tests the newly API function added to RWindow which enables/disables +// the usage of Off-Screen Bitmap (OSB). +// The test will draw squares with random colours on screen filling the +// whole drawable area. The drawing will start first with flickering screen +// and will switch to flicker free in 4 seconds. +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include "TFLICKERFREE.H" + +//=================================================== +// CBGWin Declaration +//=================================================== + +CBGWin::CBGWin(): CTWin() + { + } + +CBGWin::~CBGWin() + { + } + +void CBGWin::ConstructWin(TPoint aPos, TSize aSize, TBool aVisible) + { + iSize = aSize; + SetUpL(aPos,iSize,TheClient->iGroup,*TheClient->iGc, aVisible); + BaseWin()->SetRequiredDisplayMode(EColor256); + } + +void CBGWin::Draw() + { + iGc->Clear(); + iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + + TUint propW = iSize.iWidth/32; + TUint propH = iSize.iHeight/12; + + for(TInt i = 0; i < iSize.iWidth ; i+=propW) + { + for(TInt j = 0; j < iSize.iHeight; j+=propH) + { + iGc->SetBrushColor(TRgb( (TInt)(Math::Random()%255), (TInt)(Math::Random()%255), (TInt)(Math::Random()%255) )); + iGc->DrawRect(TRect(i, j, i+propW-1, j+propH-1)); + } + } + } + +void CBGWin::EnableOSBd(TBool aState) + { + iWin.EnableOSB(aState); + } + +//=================================================== +// CFlickerTest Declaration +//=================================================== + +/* This function will be called periodically to draw the rects + on screen.*/ +void CTFlickerFree::TestFlickering() + { + for( int i = 0; i < 40; ++i) + { + // for the first 3 seconds draw with flicker + if(i < 20 ) + iBgWin->EnableOSBd(EFalse); + // for the next 3 seconds draw with flicker free + else if(i >=20 ) + iBgWin->EnableOSBd(ETrue); + + iBgWin->DrawNow(); + + // this draws 20 frames per second for 4 seconds + User::After(50000); + } + } + +CTFlickerFree::CTFlickerFree(CTestStep* aStep): + CTWsGraphicsBase(aStep) + { + } + +CTFlickerFree::~CTFlickerFree() + { + delete iBgWin; + } + +void CTFlickerFree::ConstructL() + { + // get the size of the current client to assign it to the background window + TSize scrSize = TSize(TheClient->iScreen->SizeInPixels()); + + // construct the window in the background + iBgWin = new (ELeave) CBGWin(); + iBgWin->ConstructWin(TPoint(0,0), scrSize, ETrue); + } + +/* Sets the windowing environment, constructs the CPeriod object and + starts the CPeriod object.*/ +void CTFlickerFree::RunTestCaseL(TInt aCurTestCase) + { + ((CTFlickerFreeStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); + switch(aCurTestCase) + { + case 1: +/** +@SYMTestCaseID GRAPHICS-WSERV-0567 +*/ + ((CTFlickerFreeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0567")); + TestFlickering(); + break; + default: + ((CTFlickerFreeStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + ((CTFlickerFreeStep*)iStep)->CloseTMSGraphicsStep(); + TestComplete(); + } + ((CTFlickerFreeStep*)iStep)->RecordTestResultL(); + } + +__WS_CONSTRUCT_STEP__(FlickerFree) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TFLICKERFREE.H --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TFLICKERFREE.H Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,84 @@ +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Tests the usage of Off-Screen Bitmap +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef __TFLICKERFREE_H__ +#define __TFLICKERFREE_H__ + +#include +#include +#include "../tlib/testbase.h" +#include "AUTO.H" +#include //to include math finction rand() +#include "TGraphicsHarness.h" + +//=================================================== +// CBGWin Definition +//=================================================== + +class CBGWin : public CTWin + { +public: + CBGWin(); + ~CBGWin(); + /*Draws and colors the rectagles that are to fill the screen.*/ + void Draw(); + void ConstructWin(TPoint, TSize, TBool); + void EnableOSBd(TBool); + }; + + +//=================================================== +// CFlickerTest Definition +//=================================================== +class CTFlickerFree : public CTWsGraphicsBase + { +public: + CTFlickerFree(CTestStep* aStep); + ~CTFlickerFree(); + /*Sets the windowing environment,*/ + void ConstructL(); + +protected: +//from CTGraphicsStep - Calls the flicker-drawing test. + virtual void RunTestCaseL(TInt aCurTestCase); +private: + /*Starts first with flickering screen and after 4 senconds it + switches to flicker free drawing.*/ + void TestFlickering(); + +private: + CBGWin *iBgWin; + }; + +class CTFlickerFreeStep : public CTGraphicsStep + { +public: + CTFlickerFreeStep(); +protected: + //from CTGraphicsStep + virtual CTGraphicsBase* CreateTestL(); + }; + +_LIT(KTFlickerFreeStep,"TFlickerFree"); + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TGDI.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TGDI.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,1289 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// GDI.CPP +// Test GDI functions +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include "TGDI.H" + +#define TAUTO_BITMAP_NAME _L("Z:\\WSTEST\\TAUTO.MBM") + +//#define LOGGING on //Uncomment this line to get extra test logging - useful if debugging a failure of one of the tests + +typedef CGdiTestLowLevel *(*GdiTestFunc)(); + +_LIT(KMonospaceTestFontTypefaceName,"Arial"); +const TInt KMaxFontSize = 200; + +static inline TBool IsLengthEqual(TInt aLLen, TInt aRLen, TInt aBbLen) + { +// The bounding box of a 'w' is one pixel wider than it should be. W overlaps in to the bounding box of 'x' as the two +// are stuck together. So add a tolerance of -1. + return (((aLLen+aRLen)==aBbLen) || ((aLLen+aRLen-1)==aBbLen)); + } + +struct GdiTest + { + GdiTestFunc func; + const TText *txt; + }; + +GdiTest GdiTestFuncs[]={ + {BoxTextTest,_S("BoxText")}, + {VertTextTest,_S("VertText")}, + /*{JustifiedTextTest,_S("JustifiedText")},*/ // DEF107985 The test for JustifiedText has been removed as it was a bad/useless test + {VertBoxTextTest,_S("VertBoxText")}, + {SetOriginTest,_S("SetOrigin")}, + {PolyLineTest,_S("PolyLine")}, + {PolygonTest,_S("Polygon")}, + {DrawArcTest,_S("DrawArc")}, + {DrawPieTest,_S("DrawPie")}, + {DrawRoundRectTest,_S("DrawRoundRect")}, + {WideLineTest,_S("WideLine")}, + {DrawTextTest,_S("DrawText")}, + {DrawRectTest,_S("DrawRect")}, + }; + +CTestWindow::CTestWindow(TRgb aCol) : CBlankWindow(aCol) + { + } + +CTestWindow::~CTestWindow() + { + } + +void CTestWindow::ConstructL(TPoint aPos,TSize aSize,CTWinBase* aParent, CWindowGc& aGc) + { + iWin=RWindow(TheClient->iWs); + User::LeaveIfError(iWin.Construct(*(aParent->WinTreeNode()),ENullWsHandle)); + SetExt(aPos,aSize); + Activate(); + AssignGC(aGc); + } + +void CGdiTestLowLevel::SetGdiTest(CTGdi *aGdiTest) + { + iGdiTest=aGdiTest; + } + +void CGdiTestLowLevel::AssignGdi(CWindowGc *aGc) + { + iGdi=aGc; + } + +void CGdiTestLowLevel::ConstructL(TInt) + { + } + +void CGdiTestLowLevel::PreTestSetupL(const TRect &,TInt) + { + } + +//=======================================// +// Individual GDI low level test classes // +//=======================================// + + +void CGdiRect::ConstructL(TInt) + { + } + +void CGdiRect::PreTestSetupL(const TRect &, TInt aCount) + { + iBrushCol=TRgb::Gray256(aCount&0x1 ? 0xFF : 0x60); + iPenCol=TRgb::Gray256(aCount&0x1 ? 0xA0 : 0x0); + } + +TInt CGdiRect::Count(TBool ) + { + return(1); + } + +void CGdiDrawRect::BaseTest(const TRect &aRect, TInt aCount) + { + TheTest(aRect,aCount); + } + +void CGdiDrawRect::TheTest(const TRect &aRect, TInt) + { + iGdi->SetBrushColor(iBrushCol); + iGdi->SetPenColor(iPenCol); + iGdi->DrawRect(aRect); + } + +TInt CGdiDrawRect::Count(TBool aMode) + { + return(aMode ? 4:1); + } + +TInt CGdiDrawRoundRect::Count(TBool aMode) + { + return(aMode ? 4:1); + } + +void CGdiDrawRoundRect::BaseTest(const TRect &aRect, TInt aCount) + { + TheTest(aRect,aCount); + } + +void CGdiDrawRoundRect::TheTest(const TRect &aRect, TInt aCount) + { + iGdi->SetBrushColor(iBrushCol); + iGdi->SetPenColor(iPenCol); + TSize size((aRect.iBr.iX-aRect.iTl.iX)/4,(aRect.iBr.iY-aRect.iTl.iY)/4); + switch(aCount) + { + case 0: + size.SetSize((aRect.iBr.iX-aRect.iTl.iX)/4,(aRect.iBr.iY-aRect.iTl.iY)/4); + break; + case 1: + size.SetSize(0,0); + break; + case 2: + size.SetSize((aRect.iBr.iX-aRect.iTl.iX)/2,(aRect.iBr.iY-aRect.iTl.iY)/2); + break; + case 3: + size.SetSize((aRect.iBr.iX-aRect.iTl.iX),(aRect.iBr.iY-aRect.iTl.iY)); + break; + } + iGdi->DrawRoundRect(aRect,size); + } + +TInt CGdiDrawACP::Count(TBool ) + { + return(1); + } + +void CGdiDrawACP::ConstructL(TInt) + { + } + +void CGdiDrawACP::PreTestSetupL(const TRect &, TInt ) + { + iBrushCol=TRgb::Gray256(0xff); + iPenCol=TRgb(0,0,0); + } + +void CGdiDrawArc::BaseTest(const TRect &aRect, TInt aCount) + { + TheTest(aRect,aCount); + } + +void CGdiDrawArc::TheTest(const TRect &aRect, TInt) + { + iGdi->SetBrushColor(iBrushCol); + iGdi->SetPenColor(iPenCol); + TPoint start(aRect.iTl.iX/2+aRect.iBr.iX,aRect.iTl.iY/2+aRect.iBr.iY); + iGdi->DrawArc(aRect,start,TPoint(0,0)); + } + +void CGdiDrawPie::BaseTest(const TRect &aRect, TInt aCount) + { + TheTest(aRect,aCount); + } + +void CGdiDrawPie::TheTest(const TRect &aRect, TInt) + { + iGdi->SetBrushColor(iBrushCol); + iGdi->SetPenColor(iPenCol); + TPoint start(aRect.iTl.iX/2+aRect.iBr.iX,aRect.iTl.iY/2+aRect.iBr.iY); + iGdi->DrawPie(aRect,start,TPoint(0,0)); + } + +// +// Polyline tests +// + +CGdiPolyLine::CGdiPolyLine() : iPnts(5) + {} + +void CGdiPolyLine::PreTestSetupL(const TRect &aRect, TInt aCount) + { + iPnts.Reset(); + TInt wid=aRect.Width(); + TInt hgt=aRect.Height(); + if (aCount==0) + { + TInt pos; + for(pos=0;pos0) + iGdi->DrawLine(prev,iPnts[index]); + prev=iPnts[index]; + } + if (index>0) + iGdi->Plot(iPnts[index-1]); + } + +void CGdiPolyLine::TheTest(const TRect &, TInt ) + { + iGdi->DrawPolyLine(&iPnts); + } + +// +// Polygon tests // +// + +CGdiPolygon::CGdiPolygon() : iPnts(5) + {} + +void CGdiPolygon::PreTestSetupL(const TRect &aRect, TInt ) + { + iPnts.Reset(); + TPoint pnt; + TInt maxPoints=Min((TInt)KMaxPolygonPoints,Min(aRect.Width(),aRect.Height())/KPolygonStep); + TInt numPoints=0; + if (maxPoints>0) + { + iPnts.AppendL(aRect.iTl); + while(numPoints0) + { + numPoints--; + if (numPoints&1) + pnt.SetXY(aRect.iTl.iX+numPoints*KPolygonStep,aRect.iTl.iY+(numPoints+1)*KPolygonStep); + else + pnt.SetXY(aRect.iTl.iX+(numPoints+1)*KPolygonStep,aRect.iTl.iY+numPoints*KPolygonStep); + iPnts.AppendL(pnt); + } + } + } + +void CGdiPolygon::ConstructL(TInt ) + { + } + +TInt CGdiPolygon::Count(TBool aMainTests) + { + return(aMainTests ? 2 : 1); + } + +void CGdiPolygon::BaseTest(const TRect &aRect, TInt ) + { + iGdi->SetPenColor(TRgb::Gray4(2)); + iGdi->SetBrushColor(TRgb::Gray4(1)); + iGdi->SetBrushStyle(CGraphicsContext::ESolidBrush); + TInt maxPoints=Min((TInt)KMaxPolygonPoints,Min(aRect.Width(),aRect.Height())/KPolygonStep); + for(TInt numPoints=0;numPointsDrawRect(TRect(aRect.iTl.iX+numPoints*KPolygonStep + 1,aRect.iTl.iY+numPoints*KPolygonStep + 1, + aRect.iTl.iX+(numPoints+1)*KPolygonStep ,aRect.iTl.iY+(numPoints+1)*KPolygonStep)); + } + +void CGdiPolygon::TheTest(const TRect &, TInt ) +//This is the only one that can leave so it's not worth adding an 'L' + { + iGdi->SetPenColor(TRgb::Gray4(2)); + iGdi->SetBrushColor(TRgb::Gray4(1)); + iGdi->SetBrushStyle(CGraphicsContext::ESolidBrush); + User::LeaveIfError(iGdi->DrawPolygon(&iPnts,CGraphicsContext::EAlternate)); + } + +// + +TInt CGdiWideLine::Count(TBool aMainTests) + { + return(aMainTests ? EMainNumWidths : EMinorNumWidths); + } + +void CGdiWideLine::ConstructL(TInt) + { + } + +void CGdiWideLine::PreTestSetupL(const TRect &, TInt aCount) + { + TInt widths[]={1,4,50,-2, + 48,12345,0,3, + 48,123,0,3, + 4,111,555,1000, + 10,-1,-10,-100}; + iWidth=widths[aCount]; + } + +void CGdiWideLine::BaseTest(const TRect &aRect, TInt) + { + iGdi->SetPenSize(TSize(iWidth,iWidth)); + iGdi->DrawLine(aRect.iTl,aRect.iBr); + iGdi->MoveTo(aRect.iTl+TPoint(0,10)); + iGdi->DrawLineBy(aRect.iBr-aRect.iTl); + iGdi->MoveBy(aRect.iTl-aRect.iBr+TPoint(0,10)); + iGdi->DrawLineTo(aRect.iBr+TPoint(0,20)); + } + +void CGdiWideLine::TheTest(const TRect &aRect, TInt) + { + iGdi->SetPenSize(TSize(iWidth,iWidth)); + iGdi->MoveTo(aRect.iTl); + iGdi->DrawLineBy(aRect.iBr-aRect.iTl); + iGdi->MoveBy(aRect.iTl-aRect.iBr+TPoint(0,10)); + iGdi->DrawLineTo(aRect.iBr+TPoint(0,10)); + iGdi->DrawLine(aRect.iTl+TPoint(0,20),aRect.iBr+TPoint(0,20)); + } + +// +// Set Origin // +// + +CGdiSetOrigin::~CGdiSetOrigin() + { + delete iPolylineArray; + delete iPolygonArray; + TheClient->iScreen->ReleaseFont(iFont); + } + +TInt CGdiSetOrigin::Count(TBool ) + { + return(1); + } + +void CGdiSetOrigin::ConstructL(TInt) + { + iPolylineArray=new(ELeave) CArrayFixFlat(3); + iPolylineArray->AppendL(TPoint(40,1)); + iPolylineArray->AppendL(TPoint(50,11)); + iPolylineArray->AppendL(TPoint(40,21)); + iPolygonArray=new(ELeave) CArrayFixFlat(3); + iPolygonArray->AppendL(TPoint(40,30)); + iPolygonArray->AppendL(TPoint(50,40)); + iPolygonArray->AppendL(TPoint(40,45)); + TFontSpec fspec(KMonospaceTestFontTypefaceName,KMaxFontSize); + User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)iFont,fspec)); + } + +void CGdiSetOrigin::PreTestSetupL(const TRect &, TInt ) + { + } + +void CGdiSetOrigin::DrawIt(const TPoint &aOffset) + { + iGdi->DrawLine(TPoint(10,10)+aOffset,TPoint(20,30)+aOffset); + iGdi->DrawLineBy(TPoint(-10,5)); + iGdi->DrawLineTo(TPoint(20,5)+aOffset); + iGdi->MoveTo(TPoint(20,10)+aOffset); + iGdi->DrawLineTo(TPoint(30,15)+aOffset); + iGdi->MoveBy(TPoint(-10,2)); + iGdi->DrawLineBy(TPoint(10,0)); + iGdi->UseFont(iFont); + iGdi->DrawText(_L("Set Origin Test"),TPoint(40,20)+aOffset); + iGdi->DiscardFont(); + iGdi->DrawRect(TRect(TPoint(10,45)+aOffset,TPoint(20,55)+aOffset)); + iGdi->DrawRoundRect(TRect(TPoint(21,45)+aOffset,TPoint(30,55)+aOffset),TSize(3,2)); + iGdi->DrawEllipse(TRect(TPoint(31,45)+aOffset,TPoint(40,55)+aOffset)); + TInt index; + for(index=0;indexCount();index++) + (*iPolylineArray)[index]+=aOffset; + iGdi->DrawPolyLine(iPolylineArray); + for(index=0;indexCount();index++) + (*iPolylineArray)[index]-=aOffset; + for(index=0;indexCount();index++) + (*iPolygonArray)[index]+=aOffset; + iGdi->SetBrushStyle(CGraphicsContext::ESolidBrush); + User::LeaveIfError(iGdi->DrawPolygon(iPolygonArray,CGraphicsContext::EAlternate)); //Doesn't cause any harm if it leaves + for(index=0;indexCount();index++) + (*iPolygonArray)[index]-=aOffset; + } + +void CGdiSetOrigin::BaseTest(const TRect &aRect, TInt) + { + DrawIt(aRect.iTl); + } + +void CGdiSetOrigin::TheTest(const TRect &aRect, TInt) + { + iGdi->SetOrigin(aRect.iTl); + DrawIt(TPoint(0,0)); + } + +// +// Draw text // +// + +CGdiDrawText::~CGdiDrawText() + { + TheClient->iScreen->ReleaseFont(iFont); + } + +TInt CGdiDrawText::Count(TBool ) + { + return(1); + } + +void CGdiDrawText::ConstructL(TInt) + { + TFontSpec fspec(KMonospaceTestFontTypefaceName,KMaxFontSize); + User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)iFont,fspec)); + TInt index; + for(index=0;indexTextWidthInPixels(iBigBuffer); + for(index=0;indexTextWidthInPixels(iBigBuffer.Left(index)); + TInt rLen=iFont->TextWidthInPixels(iBigBuffer.Right(characters-index)); + TBool result = IsLengthEqual(lLen,rLen,bbLen); + iGdiTest->TEST(result); + if (!result) + { + _LIT(KLog,"Font width metrics error, Width(%dchars)=%d, Width(%dchars)=%d, Width(%dchars)=%d"); + iGdiTest->LOG_MESSAGE7(KLog,index,lLen,characters-index,rLen,characters,bbLen); + } + } + } + +void CGdiDrawText::PreTestSetupL(const TRect&,TInt) + {} + +void CGdiDrawText::BaseTest(const TRect& aRect,TInt) + { + TInt bbLen=iFont->TextWidthInPixels(iBigBuffer); + TInt fAscent=iFont->AscentInPixels(); + TInt fHeight=iFont->HeightInPixels(); + iGdi->UseFont(iFont); +// + iGdi->DrawText(_L("Hello"), TPoint(aRect.iTl.iX, aRect.iTl.iY+fAscent)); + TInt missingChars=iFont->TextCount(iBigBuffer,bbLen-aRect.iBr.iX)-1; // -1 so one off screen char is drawn to handle overhang + if (missingChars>=0) + { + TPtrC bbb=iBigBuffer.Right(iBigBuffer.Length()-missingChars); + TInt lLen=iFont->TextWidthInPixels(iBigBuffer.Left(missingChars)); + TInt rLen=iFont->TextWidthInPixels(bbb); + TBool result = IsLengthEqual(lLen,rLen,bbLen); + iGdiTest->TEST(result); + if (!result) + { + _LIT(KLog,"Font width metrics error, missingChars=%d %d+%d=%d"); + iGdiTest->LOG_MESSAGE5(KLog,missingChars,lLen,rLen,bbLen); + } + iGdi->DrawText(bbb,TPoint(aRect.iBr.iX-rLen,aRect.iTl.iY+fAscent+fHeight)); + } + iGdi->DiscardFont(); + } + +void CGdiDrawText::TheTest(const TRect& aRect,TInt) + { + TInt bbLen=iFont->TextWidthInPixels(iBigBuffer); + TInt fAscent=iFont->AscentInPixels(); + TInt fHeight=iFont->HeightInPixels(); + iGdi->UseFont(iFont); +// + iGdi->DrawText(_L("Hello"), TPoint(aRect.iTl.iX, aRect.iTl.iY+fAscent)); + iGdi->DrawText(iBigBuffer,TPoint(aRect.iBr.iX-bbLen,aRect.iTl.iY+fAscent+fHeight)); + iGdi->DiscardFont(); + } + +// +// Draw vertical text // +// + +CGdiDrawVertText::~CGdiDrawVertText() + { + TheClient->iScreen->ReleaseFont(iFont); + } + +TInt CGdiDrawVertText::Count(TBool ) + { + return(1); + } + +void CGdiDrawVertText::ConstructL(TInt) + { + TFontSpec fspec(KMonospaceTestFontTypefaceName,KMaxFontSize); + User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)iFont,fspec)); + TInt index; + for(index=0;indexTextWidthInPixels(iBigBuffer); + for(index=0;indexTextWidthInPixels(iBigBuffer.Left(index)); + TInt rLen=iFont->TextWidthInPixels(iBigBuffer.Right(iBigBuffer.Length()-index)); + TBool result = IsLengthEqual(lLen,rLen,bbLen); + iGdiTest->TEST(result); + if (!result) + iGdiTest->INFO_PRINTF3(_L("iFont->TextWidthInPixels(iBigBuffer) return value - Expected: %d, Actual: %d"), lLen+rLen, bbLen); + } + } + +void CGdiDrawVertText::PreTestSetupL(const TRect &, TInt ) + { + } + +void CGdiDrawVertText::BaseTest(const TRect &aRect, TInt) + { + TInt bbLen=iFont->TextWidthInPixels(iBigBuffer); + TInt fAscent=iFont->AscentInPixels(); + TInt fHeight=iFont->HeightInPixels(); + iGdi->UseFont(iFont); +// + TInt tlen=iFont->TextWidthInPixels(_L("Hello")); + iGdi->DrawTextVertical(_L("Hello"), TPoint(aRect.iTl.iX+fAscent, aRect.iTl.iY+tlen), ETrue); + iGdi->DrawTextVertical(_L("Hello"), TPoint(aRect.iBr.iX-fAscent, aRect.iTl.iY), EFalse); + TInt missingChars=iFont->TextCount(iBigBuffer,bbLen-aRect.iBr.iY)-1; // -1 so one off screen char is drawn to handle overhang + if (missingChars>=0) + { + TPtrC bbb=iBigBuffer.Right(iBigBuffer.Length()-missingChars); + TInt lLen=iFont->TextWidthInPixels(iBigBuffer.Left(missingChars)); + TInt rLen=iFont->TextWidthInPixels(bbb); + TBool result = IsLengthEqual(lLen,rLen,bbLen); + iGdiTest->TEST(result); + if (!result) + iGdiTest->INFO_PRINTF3(_L("iFont->TextWidthInPixels(iBigBuffer) return value - Expected: %d, Actual: %d"), lLen+rLen, bbLen); + + iGdi->DrawTextVertical(bbb,TPoint(aRect.iTl.iX+fHeight-fAscent+fHeight,aRect.iBr.iY-rLen),EFalse); + } + iGdi->DiscardFont(); + } + +void CGdiDrawVertText::TheTest(const TRect &aRect, TInt) + { + TInt bbLen=iFont->TextWidthInPixels(iBigBuffer); + TInt fAscent=iFont->AscentInPixels(); + TInt fHeight=iFont->HeightInPixels(); + iGdi->UseFont(iFont); +// + TInt tlen=iFont->TextWidthInPixels(_L("Hello")); + iGdi->DrawTextVertical(_L("Hello"), TPoint(aRect.iTl.iX+fAscent, aRect.iTl.iY+tlen), ETrue); + iGdi->DrawTextVertical(_L("Hello"), TPoint(aRect.iBr.iX-fAscent, aRect.iTl.iY), EFalse); + iGdi->DrawTextVertical(iBigBuffer,TPoint(aRect.iTl.iX+fHeight-fAscent+fHeight,aRect.iBr.iY-bbLen),EFalse); + iGdi->DiscardFont(); + } + +// +// Draw Justified text // +// + +// DEF107985 The test for JustifiedText has been removed as it was a bad/useless test. The original test was +// broken after it was migrated to TEF TGdi test. It was not worth fixing as the purpose of test was not clear, +// and fixing it basically required rewriting the whole test. +// + + +// +// Box text // +// + +CGdiBoxText::~CGdiBoxText() + { + TheClient->iScreen->ReleaseFont(iFont); + } + +TInt CGdiBoxText::Count(TBool ) + { + return(1); + } + +void CGdiBoxText::ConstructL(TInt) + { + TFontSpec fspec(KMonospaceTestFontTypefaceName,KMaxFontSize); + User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)iFont,fspec)); + for(TInt index=0;indexTextWidthInPixels(iBigBuffer); + } + +void CGdiBoxText::PreTestSetupL(const TRect &, TInt ) + { + } + +void CGdiBoxText::BaseTest(const TRect &aRect, TInt) + { + TInt rWid=aRect.iBr.iX-aRect.iTl.iX; + TInt fAscent=iFont->AscentInPixels(); + TInt fHeight=iFont->HeightInPixels(); + iGdi->UseFont(iFont); + iGdi->SetBrushStyle(CGraphicsContext::ESolidBrush); +// + TRect rect(aRect); + rect.iBr.iY=rect.iTl.iY+fHeight; +// + TInt missingChars=iFont->TextCount(iBigBuffer,iBbLen-rWid); + TPtrC bbb=iBigBuffer.Right(iBigBuffer.Length()-missingChars); + TInt lLen=iFont->TextWidthInPixels(iBigBuffer.Left(missingChars)); + TInt rLen=iFont->TextWidthInPixels(bbb); + TBool result = IsLengthEqual(lLen,rLen,iBbLen); + iGdiTest->TEST(result); + if (!result) + iGdiTest->INFO_PRINTF3(_L("(lLen+rLen)==iBbLen return value - Expected: %d, Actual: %d"), lLen+rLen, iBbLen); + + iGdi->DrawText(bbb, rect, fAscent,CGraphicsContext::ELeft, rWid-rLen); +// + rect.Move(TPoint(0,fHeight)); + iGdi->DrawText(iBigBuffer, rect, fAscent,CGraphicsContext::ELeft, 0); +// + TBuf<10> buf2(_L("1234567890")); + rect.Move(TPoint(0,fHeight)); + iGdi->DrawText(buf2,rect,fAscent,CGraphicsContext::ERight,rect.Width()-iFont->TextWidthInPixels(buf2)); + } + +void CGdiBoxText::TheTest(const TRect &aRect, TInt) + { + TInt rWid=aRect.iBr.iX-aRect.iTl.iX; + TInt fAscent=iFont->AscentInPixels(); + TInt fHeight=iFont->HeightInPixels(); + iGdi->UseFont(iFont); + iGdi->SetBrushStyle(CGraphicsContext::ESolidBrush); + TRect rect(aRect); + rect.iBr.iY=rect.iTl.iY+fHeight; +// + iGdi->DrawText(iBigBuffer, rect, fAscent, CGraphicsContext::ELeft, rWid-iBbLen); +// + rect.Move(TPoint(0,fHeight)); + iGdi->Clear(rect); + iGdi->SetClippingRegion(TRegionFix<1>(rect)); + iGdi->DrawText(iBigBuffer, rect.iTl+TPoint(0,fAscent)); + TBuf<10> buf2(_L("1234567890")); + rect.Move(TPoint(0,fHeight)); + iGdi->CancelClippingRegion(); + iGdi->DrawText(buf2,rect,fAscent); + } + +// +// Vert Box text // +// + +CGdiVertBoxText::~CGdiVertBoxText() + { + TheClient->iScreen->ReleaseFont(iFont); + } + +TInt CGdiVertBoxText::Count(TBool ) + { + return(1); + } + +void CGdiVertBoxText::ConstructL(TInt) + { + TFontSpec fspec(KMonospaceTestFontTypefaceName,KMaxFontSize); + User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)iFont,fspec)); + for(TInt index=0;indexTextWidthInPixels(iBigBuffer); + } + +void CGdiVertBoxText::PreTestSetupL(const TRect &, TInt ) + { + } + +void CGdiVertBoxText::BaseTest(const TRect &aRect, TInt) + { + TInt rWid=aRect.iBr.iY-aRect.iTl.iY; + TInt fAscent=iFont->AscentInPixels(); + TInt fHeight=iFont->HeightInPixels(); + iGdi->UseFont(iFont); + iGdi->SetBrushStyle(CGraphicsContext::ESolidBrush); +// + TRect rect(aRect); + rect.iBr.iX=rect.iTl.iX+fHeight; +// + TInt missingChars=iFont->TextCount(iBigBuffer,iBbLen-rWid); + TPtrC bbb=iBigBuffer.Right(iBigBuffer.Length()-missingChars+1); + TInt lLen=iFont->TextWidthInPixels(iBigBuffer.Left(missingChars-1)); + TInt rLen=iFont->TextWidthInPixels(bbb); + TBool result = IsLengthEqual(lLen,rLen,iBbLen); + iGdiTest->TEST(result); + if (!result) + iGdiTest->INFO_PRINTF3(_L("(lLen+rLen)==iBbLen return value - Expected: %d, Actual: %d"), lLen+rLen, iBbLen); + + iGdi->DrawTextVertical(bbb, rect, fAscent, ETrue,CGraphicsContext::ELeft, rWid-rLen); +// + rect.iTl.iX=rect.iBr.iX; + rect.iBr.iX=rect.iTl.iX+fHeight; + iGdi->DrawTextVertical(iBigBuffer, rect, fAscent, ETrue,CGraphicsContext::ELeft, 0); + } + +void CGdiVertBoxText::TheTest(const TRect &aRect, TInt) + { + TInt rWid=aRect.iBr.iY-aRect.iTl.iY; + TInt fAscent=iFont->AscentInPixels(); + TInt fHeight=iFont->HeightInPixels(); + iGdi->UseFont(iFont); + iGdi->SetBrushStyle(CGraphicsContext::ESolidBrush); + TRect rect(aRect); + rect.iBr.iX=rect.iTl.iX+fHeight; +// + iGdi->DrawTextVertical(iBigBuffer, rect, fAscent, ETrue, CGraphicsContext::ELeft, rWid-iBbLen); +// + rect.iTl.iX=rect.iBr.iX; + rect.iBr.iX=rect.iTl.iX+fHeight; + iGdi->Clear(rect); + iGdi->SetClippingRegion(TRegionFix<1>(rect)); + iGdi->DrawTextVertical(iBigBuffer, TPoint(rect.iTl.iX+fAscent,rect.iBr.iY), ETrue); + } + + +// +// +CGdiBlitMasked::~CGdiBlitMasked() + { + for(TInt index=0;indexCreateContext(aGc)); +// + aGc->SetBrushColor(TRgb(128,128,128)); + aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + aGc->SetPenStyle(CGraphicsContext::ENullPen); + aGc->DrawRect(TRect(aBitmap->SizeInPixels())); + aGc->SetPenStyle(CGraphicsContext::ESolidPen); + for(TInt index=(-aSize.iHeight);indexDrawLine(TPoint(index,0),TPoint(index+aSize.iHeight,aSize.iHeight)); + aGc->DrawLine(TPoint(index,aSize.iHeight),TPoint(index+aSize.iHeight,0)); + } + } + +void CGdiBlitMasked::createTestBitmapL(CFbsBitmap *&aBitmap, const TSize &aSize) + { + CFbsBitGc *gc=NULL; + CFbsBitmapDevice *device=NULL; + aBitmap=new(ELeave) CFbsBitmap(); + User::LeaveIfError(aBitmap->Create(aSize,EGray16)); + TRAPD(err,doCreateTestBitmapL(aBitmap, gc, device, aSize)); + delete gc; + delete device; + User::LeaveIfError(err); + } + +void CGdiBlitMasked::ConstructL(TInt) + { + TSize max(0,0); + for(TInt index=0;indexLoad(TAUTO_BITMAP_NAME,2+index)); + TSize size=iMask[index]->SizeInPixels(); + if (max.iWidthCreate(max,EGray16)); + iScratchDevice=CFbsBitmapDevice::NewL(iScratch); + User::LeaveIfError(iScratchDevice->CreateContext(iScratchGc)); + + iScratchMask=new(ELeave) CFbsBitmap(); + User::LeaveIfError(iScratchMask->Create(max,EGray16)); + iScratchMaskDevice=CFbsBitmapDevice::NewL(iScratchMask); + User::LeaveIfError(iScratchMaskDevice->CreateContext(iScratchMaskGc)); +// + createTestBitmapL(iBitmap, max); + } + +void CGdiBlitMasked::PreTestSetupL(const TRect &, TInt aCount) + { + iInvertMask=aCount&0x1; + aCount>>=1; + iCurrMask= iMask[aCount%ENumMasks]; + iDrawMode=CGraphicsContext::EDrawModePEN; + } + +void CGdiBlitMasked::BaseTest(const TRect &aRect, TInt) + { +// needs re-writing to emulate tiling of the source rect + if (!aRect.Intersects(TRect(BaseWin->Size()))) + return; + TSize size(aRect.Size()); + TSize bitSize=iBitmap->SizeInPixels(); + if (size.iWidth>bitSize.iWidth) + size.iWidth=bitSize.iWidth; + if (size.iHeight>bitSize.iHeight) + size.iHeight=bitSize.iHeight; +// +// Set up the scratch mask as a black and white bitmap containing the mask to blit +// The mask pattern is replicated all over the scratchmask bitmap +// + iScratchMaskGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + iScratchMaskGc->SetPenStyle(CGraphicsContext::ENullPen); + iScratchMaskGc->SetBrushColor(TRgb(0,0,0)); + iScratchMaskGc->DrawRect(TRect(iScratchMask->SizeInPixels())); + iScratchMaskGc->SetPenColor(TRgb(255,255,255)); + iScratchMaskGc->SetPenStyle(CGraphicsContext::ESolidPen); + TSize maskSize(iCurrMask->SizeInPixels()); + TPoint pos; + TRgb *rgbBuf=(TRgb *)User::AllocL(maskSize.iWidth*sizeof(TRgb)); //Doesn't do any harm if it leaves + for(pos.iY=0;pos.iYGetScanLine(ptr, pos, maskSize.iWidth, ERgb); + for(TInt index=0;indexSetPenColor(rgbBuf[index]); +// if ((isLow && !iLowCutOff) || (!isLow && iLowCutOff)) + iScratchMaskGc->Plot(TPoint(index,pos.iY)); + } + } + User::Free(rgbBuf); + + for(pos.iY=0;pos.iYCopyRect(pos, TRect(maskSize)); +// +// Blit this to the screen in ANDNOT mode to clear all the pixels we want the mask blit to draw to +// + iGdi->SetDrawMode(CGraphicsContext::EDrawModeANDNOT); + iGdi->BitBlt(aRect.iTl, iScratchMask, TRect(size)); +// +// Copy the test bitmap to the scratch bitmap then use the scratch mask to clear all the bits +// that should masked out of the draw to the screen +// + iScratchGc->SetDrawMode(CGraphicsContext::EDrawModePEN); + iScratchGc->BitBlt(TPoint(0,0), iBitmap); + iScratchGc->SetDrawMode(CGraphicsContext::EDrawModeAND); + iScratchGc->BitBlt(TPoint(0,0), iScratchMask); +// +// Now copy the scratch bitmap to the screen in OR mode to get the final result +// + iGdi->SetDrawMode(CGraphicsContext::EDrawModeOR); + iGdi->BitBlt(aRect.iTl, iScratch, TRect(size)); + } + +void CGdiBlitMasked::TheTest(const TRect &aRect, TInt) + { + iGdi->BitBltMasked(aRect.iTl,iBitmap,TRect((aRect.iBr-aRect.iTl).AsSize()), + iCurrMask,iInvertMask); + } +// +// + +CTGdi::CTGdi(CTestStep* aStep) : CTWsGraphicsBase(aStep), iGdiTest (NULL), iTextOffsetX(10),iTextOffsetY(10) + { + } + +void CTGdi::ConstructL() + { + iWinSize=TestWin->Size(); + } + +TSize CTGdi::WinSize() + { + return(iWinSize); + } + +void CTGdi::DoGdiTestL(const TRect &aRect, TInt aNum) + { +// + iGdiTest->PreTestSetupL(aRect,aNum); +// + BaseWin->Win()->Invalidate(); + BaseWin->Win()->BeginRedraw(); + TheGc->Activate(*BaseWin->Win()); + iTest->DrawTestBackground(EFalse,BaseWin->Size()); + iGdiTest->BaseTest(aRect,aNum); + TheGc->Deactivate(); + BaseWin->Win()->EndRedraw(); +// + TestWin->Win()->Invalidate(); + TestWin->Win()->BeginRedraw(); + TheGc->Activate(*TestWin->Win()); + iTest->DrawTestBackground(EFalse,TestWin->Size()); + iGdiTest->TheTest(aRect,aNum); + TheGc->Deactivate(); + TestWin->Win()->EndRedraw(); +// + TheClient->iWs.Flush(); + TheClient->WaitForRedrawsToFinish(); + TheClient->iWs.Finish(); +// + _LIT(KLog,"GDI Substate=%d test=%d rect=(%d,%d,%d,%d) "); + TBuf<64> buf; + buf.Format(KLog,iSubState,aNum,aRect.iTl.iX,aRect.iTl.iY,aRect.iBr.iX,aRect.iBr.iY); + iTestPassing=CompareWindows(buf); + } + +void CTGdi::GdiTestL(CGdiTestLowLevel *aTest) + { + TTestRects::ResetSeed(); + iTestPassing=ETrue; + iGdiTest=aTest; + iGdiTest->SetGdiTest(this); + iGdiTest->AssignGdi(TheGc); + iGdiTest->ConstructL(iTest->iTestRects.Count1()); + TInt index; + TInt index2; + for(index=0; iTestPassing && indexiTestRects.Count2(); ++index) + { + TInt max=iGdiTest->Count(indexiTestRects.Count1()); + TRect rect=iTest->iTestRects[index]; + #if defined(LOGGING) + _LIT(KLog1,"Testing rectangle %d (%d,%d,%d,%d) 1st pass"); + LOG_MESSAGE6(KLog1,index,rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY); + #endif + for(index2=0; iTestPassing && index2iTestRects.Count3(); index++) + { + TRect rect=iTest->iTestRects[index]; + #if defined(LOGGING) + _LIT(KLog2,"Testing rectangle %d (%d,%d,%d,%d) 2nd pass"); + LOG_MESSAGE6(KLog2,index,rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY); + #endif + DoGdiTestL(rect,0); + } + delete iGdiTest; + iGdiTest=NULL; + } + +void CTGdi::NonDrawing() +// +// Test all non-drawing GDI functions +// + { + TDisplayMode mode=TheClient->iScreen->DisplayMode(); + TEST((mode!=ERgb) && (mode!=ENone)); + + RWsSession session; + TInt res = session.Connect(); + TEST(res == KErrNone); + + CArrayFixFlat* modeList= new CArrayFixFlat (15); + if(!modeList) + return; + +#if defined(SYMBIAN_GRAPHICS_GCE) + res = session.GetColorModeList(iTest->iScreenNumber, modeList); +#else + res = session.GetColorModeList(modeList); +#endif //SYMBIAN_GRAPHICS_GCE + session.Close(); + TEST(res == KErrNone); + if(res != KErrNone) + { + modeList->Reset(); + delete modeList; + return; + } + + TBool found = EFalse; + for(TInt ii = 0; ii < modeList->Count() && !found; ii++) + { + TDisplayMode mode1 = (TDisplayMode) ((*modeList)[ii]); + if(mode == mode1) + { + found = ETrue; + } + } + modeList->Reset(); + delete modeList; + + TEST(found); + } + +// +// Auxiliary Fn for Test Case ID CTGdi_TestDefetct_DEF045746 +// This method draws the text represented by aText parameter on the window +// passed to it. +// +void CTGdi::DrawTextOnWindow(const TDesC& aText,CTWin* aWin) + { + aWin->Win()->BeginRedraw(); + TheGc->Activate(*aWin->Win()); + TheGc->Device()->GetNearestFontToDesignHeightInTwips(iFont,TFontSpec(_L("Arial"),250)); + TheGc->UseFont(iFont); + TheGc->Clear(); + TheGc->DrawRect(TRect(aWin->Win()->Size())); + TheGc->DrawText(aText,TPoint(iTextOffsetX,iTextOffsetY)); + TheGc->Device()->ReleaseFont(iFont); + TheGc->Deactivate(); + aWin->Win()->EndRedraw(); + } + + +void CTGdi::TestDefetct_DEF045746L() + { + _LIT(KString,"This is a test window for the defect fix DEF045746 \ + propagated from Opera browser. Most window graphics context drawing\ + functions map to equivalent CFbsBitGc functions they are implemented\ + on the screen with any co-ordinates being relative to the top left\ + corner of the window. However extra clipping is applied. The drawing\ + will always be clipped to the visible part of the window, in addition\ + it will be clipped to the non-invalid part if you are not doing a\ + redraw and to the region being validated if you are doing a redraw."); + + TPtrC TestText(KString().Ptr(),100); + TPtrC LargeText(KString().Ptr()); + TPtrC ShortText(KString().Ptr(),200); + + TSize scrSize=TheClient->iScreen->SizeInPixels(); + TSize winSize; + const TInt windowGap=5; + winSize.SetSize(scrSize.iWidth -2* windowGap,scrSize.iHeight/2 - windowGap); + + iWin=new(ELeave) CTestWindow(TRgb(0,0,0)); + iWin->ConstructL(TPoint(5,5),TSize(winSize),TheClient->iGroup,*TheClient->iGc); + CTestWindow* expectWin= new(ELeave) CTestWindow(TRgb(0,0,0)); + expectWin->ConstructL(TPoint(5,scrSize.iHeight/2 + windowGap),TSize(winSize),TheClient->iGroup,*TheClient->iGc); + DrawTextOnWindow(ShortText,iWin); + DrawTextOnWindow(TestText,expectWin); + TInt fHeight=iFont->HeightInPixels();//Used to compare only pixels where text is drawn + TRect iRect=winSize; + iRect.iTl.iX=iTextOffsetX; + iRect.iTl.iY=iTextOffsetY; + iRect.iBr.iY=iTextOffsetY+fHeight; + CheckRect(iWin,expectWin,iRect,_L("TestDefetct_DEF045746L A")); + iWin->Invalidate(); + DrawTextOnWindow(LargeText,iWin); + CheckRect(iWin,expectWin,iRect,_L("TestDefetct_DEF045746L B")); + delete iWin; + iWin=NULL; + delete expectWin; + expectWin=NULL; + } + +void CTGdi::RunTestCaseL(TInt /*aCurTestCase*/) + { + //_LIT(KTest1,"NonDrawing"); this test is not running + _LIT(KTest2,"DEF045746"); + _LIT(KTest3,"Drawing Tests"); + ((CTGdiStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); + static TTime startTime; + switch(++iTest->iState) + { +/** +@SYMTestCaseID GRAPHICS-WSERV-0262 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test all non-drawing GDI functions + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Check all non-drawing GDI functions operate correctly + +@SYMTestExpectedResults Non-drawing GDI functions operate correctly +*/ + case 1: + // start time log + startTime.HomeTime(); + ((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0262")); + //iTest->LogSubTest(KTest1); + //PeterI this tests whether the display mode is EGray4 or EGray16. + //The actual display mode is EColor16MU so this test will always fail + //NonDrawingL(); + break; +/** + * @SYMTestCaseID GRAPHICS-WSERV-0263 + * + * @SYMPREQ DEF045746 + * + * @SYMTestCaseDesc Test defect fix for DEF045746 + * + * @SYMTestPriority High + * + * @SYMTestStatus Implemented + * + * @SYMTestActions The method tests CWindowGc::DrawText().The test is carried + * out by writing small & very large strings to the window graphic context. + * + * @SYMTestExpectedResults The window with large / small strings written is + * compared with an expected result window. In both the cases strings should + * be displayed. + * + */ + case 2: + ((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0263")); + iTest->LogSubTest(KTest2); + TestDefetct_DEF045746L(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0264 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test all drawing GDI functions + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Check all drawing GDI functions operate correctly + +@SYMTestExpectedResults Drawing GDI functions operate correctly +*/ + case 3: + { + ((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0264")); + iTest->LogSubTest(KTest3); + iSubState = 0; + TheClient->WaitForRedrawsToFinish(); //Just in case the two test windows have any invalid areas + TInt numTests = sizeof(GdiTestFuncs) / sizeof(GdiTestFuncs[0]); + while (iSubState < numTests) + { + LOG_MESSAGE(TPtrC(GdiTestFuncs[iSubState].txt)); + GdiTestL((*GdiTestFuncs[iSubState].func)()); + iSubState++; + } + } + break; + default: + ((CTGdiStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + ((CTGdiStep*)iStep)->CloseTMSGraphicsStep(); + TestComplete(); + // log time and print duration + TTime endTime; + endTime.HomeTime(); + TInt64 duration = endTime.MicroSecondsFrom(startTime).Int64(); + float time = (float) I64LOW(duration) / 1000.0f; + _LIT(KDuration,"Total test duration is %f millisec"); + RDebug::Print(KDuration, time); + break; + } + ((CTGdiStep*)iStep)->RecordTestResultL(); + } + +CGdiTestLowLevel *SetOriginTest() + { + return(new(ELeave) CGdiSetOrigin()); + } + +CGdiTestLowLevel *PolyLineTest() + { + return(new(ELeave) CGdiPolyLine()); + } + +CGdiTestLowLevel *PolygonTest() + { + return(new(ELeave) CGdiPolygon()); + } + +CGdiTestLowLevel *BlitMaskedTest() + { + return(new(ELeave) CGdiBlitMasked()); + } + +CGdiTestLowLevel *DrawArcTest() + { + return(new(ELeave) CGdiDrawArc()); + } + +CGdiTestLowLevel *DrawPieTest() + { + return(new(ELeave) CGdiDrawPie()); + } + +CGdiTestLowLevel *DrawRoundRectTest() + { + return(new(ELeave) CGdiDrawRoundRect()); + } + +CGdiTestLowLevel *BoxTextTest() + { + return(new(ELeave) CGdiBoxText()); + } + +CGdiTestLowLevel *VertTextTest() + { + return(new(ELeave) CGdiDrawVertText()); + } + +CGdiTestLowLevel *VertBoxTextTest() + { + return(new(ELeave) CGdiVertBoxText()); + } + +CGdiTestLowLevel *WideLineTest() + { + return(new(ELeave) CGdiWideLine()); + } + +CGdiTestLowLevel *DrawTextTest() + { + return(new(ELeave) CGdiDrawText()); + } + +CGdiTestLowLevel *DrawRectTest() + { + return(new(ELeave) CGdiDrawRect()); + } + +__WS_CONSTRUCT_STEP__(Gdi) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TGDI.H --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TGDI.H Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,355 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef __TGDI_H__ +#define __TGDI_H__ + +#include +#include +#include "../tlib/testbase.h" +#include +#include "AUTO.H" +#include "TGraphicsHarness.h" + +class CGdiTestLowLevel; + +CGdiTestLowLevel *SetOriginTest(); +CGdiTestLowLevel *PolyLineTest(); +CGdiTestLowLevel *PolygonTest(); +CGdiTestLowLevel *BlitMaskedTest(); +CGdiTestLowLevel *DrawArcTest(); +CGdiTestLowLevel *DrawPieTest(); +CGdiTestLowLevel *DrawRoundRectTest(); +CGdiTestLowLevel *BoxTextTest(); +CGdiTestLowLevel *VertTextTest(); +CGdiTestLowLevel *JustifiedTextTest(); +CGdiTestLowLevel *VertBoxTextTest(); +CGdiTestLowLevel *WideLineTest(); +CGdiTestLowLevel *DrawTextTest(); +CGdiTestLowLevel *DrawRectTest(); + +class CTGdi; +class CGdiTestLowLevel : public CBase +// +// BaseTest uses code that is assumed to be good to draw to one window +// TheTest uses the code beng tested to draw a matching pattern +// + { +public: + void AssignGdi(CWindowGc *aGc); + void SetGdiTest(CTGdi *aGdiTest); + virtual void PreTestSetupL(const TRect &aRect, TInt aCount); + virtual void BaseTest(const TRect &aRect, TInt aCount)=0; + virtual void TheTest(const TRect &aRect, TInt aCount)=0; + virtual void ConstructL(TInt aNumOfRects); + virtual TInt Count(TBool aMainTests)=0; +protected: + CWindowGc *iGdi; + CTGdi *iGdiTest; + }; + +class CGdiRect : public CGdiTestLowLevel + { +public: + void PreTestSetupL(const TRect &aRect, TInt aCount); + void ConstructL(TInt aNumOfRects); + TInt Count(TBool aMainTests); +protected: + TRgb iBrushCol; + TRgb iPenCol; + }; + + +class CGdiDrawRect : public CGdiRect + { +public: + TInt Count(TBool aMainTests); + void BaseTest(const TRect &aRect, TInt aCount); + void TheTest(const TRect &aRect, TInt aCount); + }; + +class CGdiDrawRoundRect : public CGdiRect + { +public: + TInt Count(TBool aMainTests); + void BaseTest(const TRect &aRect, TInt aCount); + void TheTest(const TRect &aRect, TInt aCount); + }; + +class CGdiDrawACP : public CGdiTestLowLevel + { +public: + void PreTestSetupL(const TRect &aRect, TInt aCount); + void ConstructL(TInt aNumOfRects); + TInt Count(TBool aMainTests); +protected: + TRgb iBrushCol; + TRgb iPenCol; + }; + +class CGdiDrawArc : public CGdiDrawACP + { +public: + void BaseTest(const TRect &aRect, TInt aCount); + void TheTest(const TRect &aRect, TInt aCount); + }; + +class CGdiDrawPie : public CGdiDrawACP + { +public: + void BaseTest(const TRect &aRect, TInt aCount); + void TheTest(const TRect &aRect, TInt aCount); + }; + +class CGdiPolyLine : public CGdiTestLowLevel + { +public: + CGdiPolyLine(); + void PreTestSetupL(const TRect &aRect, TInt aCount); + void ConstructL(TInt aNumOfRects); + TInt Count(TBool aMainTests); + void BaseTest(const TRect &aRect, TInt aCount); + void TheTest(const TRect &aRect, TInt aCount); +private: + CArrayFixSeg iPnts; + }; + +class CGdiPolygon : public CGdiTestLowLevel + { +private: + enum {KMaxPolygonPoints=100}; + enum {KPolygonStep=4}; +public: + CGdiPolygon(); + void PreTestSetupL(const TRect &aRect, TInt aCount); + void ConstructL(TInt aNumOfRects); + TInt Count(TBool aMainTests); + void BaseTest(const TRect &aRect, TInt aCount); + void TheTest(const TRect &aRect, TInt aCount); +private: + CArrayFixSeg iPnts; + }; + +class CGdiWideLine : public CGdiTestLowLevel + { +private: + enum TMaxWidths { + EMainNumWidths=16, + EMinorNumWidths=4}; +public: + void PreTestSetupL(const TRect &aRect, TInt aCount); + void BaseTest(const TRect &aRect, TInt aCount); + void TheTest(const TRect &aRect, TInt aCount); + void ConstructL(TInt aNumOfRects); + TInt Count(TBool aMainTests); +private: + TInt iWidth; + }; + +class CGdiSetOrigin : public CGdiTestLowLevel + { +public: + ~CGdiSetOrigin(); + void PreTestSetupL(const TRect &aRect, TInt aCount); + void DrawIt(const TPoint &aOffset); + void BaseTest(const TRect &aRect, TInt aCount); + void TheTest(const TRect &aRect, TInt aCount); + void ConstructL(TInt aNumOfRects); + TInt Count(TBool aMainTests); +private: + CFbsFont *iFont; + CArrayFixFlat *iPolylineArray; + CArrayFixFlat *iPolygonArray; + }; + +class CGdiDrawText : public CGdiTestLowLevel + { +public: + ~CGdiDrawText(); + void PreTestSetupL(const TRect &aRect, TInt aCount); + void BaseTest(const TRect &aRect, TInt aCount); + void TheTest(const TRect &aRect, TInt aCount); + void ConstructL(TInt aNumOfRects); + TInt Count(TBool aMainTests); +private: + TInt iWidth; + CFbsFont *iFont; + TBuf<0x400> iBigBuffer; + }; + +class CGdiDrawVertText : public CGdiTestLowLevel + { +public: + ~CGdiDrawVertText(); + void PreTestSetupL(const TRect &aRect, TInt aCount); + void BaseTest(const TRect &aRect, TInt aCount); + void TheTest(const TRect &aRect, TInt aCount); + void ConstructL(TInt aNumOfRects); + TInt Count(TBool aMainTests); +private: + TInt iWidth; + CFbsFont *iFont; + TBuf<0x400> iBigBuffer; + }; + +//class CGdiDrawJustifiedText : public CGdiTestLowLevel +//DEF107985 The test for JustifiedText has been removed as it was a bad/useless test + +class CGdiBoxText : public CGdiTestLowLevel + { +public: + ~CGdiBoxText(); + void PreTestSetupL(const TRect &aRect, TInt aCount); + void BaseTest(const TRect &aRect, TInt aCount); + void TheTest(const TRect &aRect, TInt aCount); + void ConstructL(TInt aNumOfRects); + TInt Count(TBool aMainTests); +private: + TInt iWidth; + TInt iBbLen; + CFbsFont *iFont; + TBuf<0x400> iBigBuffer; + }; + +class CGdiVertBoxText : public CGdiTestLowLevel + { +public: + ~CGdiVertBoxText(); + void PreTestSetupL(const TRect &aRect, TInt aCount); + void BaseTest(const TRect &aRect, TInt aCount); + void TheTest(const TRect &aRect, TInt aCount); + void ConstructL(TInt aNumOfRects); + TInt Count(TBool aMainTests); +private: + TInt iWidth; + TInt iBbLen; + CFbsFont *iFont; + TBuf<0x400> iBigBuffer; + }; +/* +class CGdiDottedLine : public CGdiTestLowLevel + { + enum TMaxPatterns { + EMainMaxPatterns=5, + EMinorMaxPatterns=3}; +public: + void SetGridRegion(TRegion &grid,const TRect &aRect); + void PreTestSetupL(const TRect &aRect, TInt aCount); + void BaseTest(const TRect &aRect, TInt aCount); + void TheTest(const TRect &aRect, TInt aCount); + void ConstructL(TInt aNumOfRects); + TInt Count(TBool aMainTests); +private: + TUint iPattern; + TInt iPattLen; + static TUint iPatterns[EMainMaxPatterns]; + static TInt iPattLens[EMainMaxPatterns]; + }; +TUint CGdiDottedLine::iPatterns[]={ + 0x55FF0033, + 0xFF00, + 0x1, + 0xFFFF, + 0xF0F0F0}; +TInt CGdiDottedLine::iPattLens[]={ + 32, + 16, + 2, + 32, + 24}; +*/ +class CTestWindow : public CBlankWindow + { +public: + CTestWindow(TRgb aCol); + ~CTestWindow(); + void ConstructL(TPoint aPos,TSize aSize,CTWinBase* aParent, CWindowGc& aGc ); + }; + +class CGdiBlitMasked: public CGdiTestLowLevel + { + enum TNumMasks {ENumMasks=2}; +public: + ~CGdiBlitMasked(); + void PreTestSetupL(const TRect &aRect, TInt aCount); + void BaseTest(const TRect &aRect, TInt aCount); + void TheTest(const TRect &aRect, TInt aCount); + void ConstructL(TInt aNumOfRects); + TInt Count(TBool aMainTests); +private: + void doCreateTestBitmapL(CFbsBitmap *aBitmap, CFbsBitGc *&aGc, CFbsBitmapDevice *&aDevice, const TSize &aSize); + void createTestBitmapL(CFbsBitmap *&aBitmap, const TSize &aSize); +private: + CFbsBitmap *iMask[ENumMasks]; + CFbsBitmap *iBitmap; +// + CFbsBitmap *iScratch; + CFbsBitmapDevice *iScratchDevice; + CFbsBitGc *iScratchGc; +// + CFbsBitmap *iScratchMask; + CFbsBitmapDevice *iScratchMaskDevice; + CFbsBitGc *iScratchMaskGc; +// + TBool iInvertMask; + CFbsBitmap *iCurrMask; + CGraphicsContext::TDrawMode iDrawMode; + }; + +class CTGdi : public CTWsGraphicsBase + { +public: + CTGdi(CTestStep* aStep); + void ConstructL(); + TSize WinSize(); + void GdiTestL(CGdiTestLowLevel *aTest); + void TestDefetct_DEF045746L(); + void DrawTextOnWindow(const TDesC& aText,CTWin* aWin); +protected: +//from CTGraphicsStep + virtual void RunTestCaseL(TInt aCurTestCase); +private: + void DoGdiTestL(const TRect &aRect, TInt aNum); + void NonDrawing(); +private: + TSize iWinSize; + TInt iSubState; + CGdiTestLowLevel *iGdiTest; + CTestWindow* iWin; + CFont* iFont; + TInt iTextOffsetX; + TInt iTextOffsetY; + TBool iTestPassing; + }; + +class CTGdiStep : public CTGraphicsStep + { +public: + CTGdiStep(); +protected: + //from CTGraphicsStep + virtual CTGraphicsBase* CreateTestL(); + }; + +_LIT(KTGdiStep,"TGdi"); + + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TGETPIXEL.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TGETPIXEL.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,395 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// GETPIXEL.CPP +// Automatically test GetPixel +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include "TGETPIXEL.H" + +CTGetPixel::CTGetPixel(CTestStep* aStep): + CTWsGraphicsBase(aStep) + { + } + +CTGetPixel::~CTGetPixel() + { + iWindow.Close(); + User::Free(iRgbBuf); + } + +LOCAL_C TInt DoPanicTest(TInt aFunc, TAny *aScreenNumber) + { + RWsSession ws; + if (ws.Connect()==KErrNone) + switch(aFunc) + { + case 1: // Get pixels into a TPtr 1 pixel too small + { + CWsScreenDevice *screen = new(ELeave) CWsScreenDevice(ws); + User::LeaveIfError(screen->Construct((TInt)aScreenNumber)); + CFbsBitmap *bitmap=new(ELeave) CFbsBitmap(); + TInt bitWid=80; + TRgb *buf=NULL; + if (bitmap->Create(TSize(1,bitWid), EGray16)==KErrNone && (buf=(TRgb *)User::Alloc((bitWid-1)*sizeof(TRgb)))!=NULL) + { + TPtr8 desc((TUint8 *)buf,(bitWid-1)*sizeof(TRgb)); + screen->GetScanLine(desc,TPoint(0,0),bitWid, ERgb); + } + } + break; + } + return(EWsExitReasonBad); + } + +void CTGetPixel::ClearOutRedraws() +// This has been added because partial redraw store can be triggered to request a +// low priority redraw from the window even though in normal circumstances the window +// would not expect to receive any sort of redraw event. + { + iWindow.BeginRedraw(); + iWindow.EndRedraw(); + } + +void CTGetPixel::TestPanicsL() + { + if (!iTest->IsFullRomL()) + { + TEST(iTest->TestWsPanicL(DoPanicTest,EWservPanicInvalidParameter,1,(TAny*)iTest->iScreenNumber)); + } + } + +void CTGetPixel::DrawAndCheckLine(const TPoint &aPos,TInt aLen,TRgb aColor) + { + TheGc->Activate(iWindow); + TheGc->SetPenColor(aColor); + iWindow.BeginRedraw(TRect(aPos,TSize(aLen, 1))); + TheGc->DrawLine(aPos,aPos+TSize(aLen,0)); + iWindow.EndRedraw(); + TheGc->Deactivate(); + iRgbBuf=(TRgb *)User::ReAlloc(iRgbBuf,aLen*sizeof(TRgb)); + TPtr8 ptr((TUint8 *)iRgbBuf,aLen*sizeof(TRgb)); + TheClient->iScreen->GetScanLine(ptr, aPos+iWindow.InquireOffset(*TheClient->iGroup->WinTreeNode()), aLen, EColor16MA); + TRgb result(TRgb::Gray16(aColor.Gray16())); + if (TheClient->iScreen->DisplayMode()==EColor64K) + result=TRgb::Color64K(result.Color64K()); + for(TInt index=0;indexiWs; + TheGc->Activate(*BaseWin->Win()); + TheGc->Clear(); + TheGc->SetBrushColor(TRgb::Gray16(0)); + TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + TheGc->SetPenStyle(CGraphicsContext::ENullPen); + TheGc->DrawRect(TRect(iWinSize)); + TheGc->Deactivate(); + + iWindow.Construct(*TheClient->iGroup->GroupWin(),ENullWsHandle); + iWinSize=TSize(TheClient->iScreen->SizeInPixels()); + iWinSize.iWidth/=3; + iWinSize.iHeight/=3; + iWindow.SetRequiredDisplayMode(EGray16); + TheClient->iWs.Flush(); + iTest->DelayIfFullRomL(); // Need to wait for view server to mess around when display mode changed + TheClient->WaitForRedrawsToFinish();// otherwise it will stomp on top of our window invalidating it. + iWindow.SetExtent(TPoint(iWinSize.iWidth,iWinSize.iHeight),iWinSize); + iWindow.EnableRedrawStore(EFalse); // Otherwise drawing might trigger a redraw when purging redraw store + + iWindow.Activate(); + iWindow.BeginRedraw(); + iWindow.EndRedraw(); + + } + +void CTGetPixel::TestCheckRect() + { + TSize size(TheClient->iScreen->SizeInPixels()); + TEST(TheClient->iScreen->RectCompare(TRect(size),TRect(TPoint(iTest->StdTestWindowSize().iWidth>>1,0),iTest->StdTestWindowSize()))==EFalse); + } + +void CTGetPixel::DrawColorsL() + { + TPoint point(0,0); + TInt color=-1; + iWindow.BeginRedraw(); + FOREVER + { + TheGc->SetPenColor(TRgb::Color256(++color)); + TheGc->Plot(point); + if (color==255) + break; + if (++point.iX==iWinSize.iWidth) + { + point.iX=0; + if (++point.iY==iWinSize.iHeight) + break; + } + } + iWindow.EndRedraw(); + } + +void CTGetPixel::TestColors(CPalette* aPalette) + { + TInt numColors=iWinSize.iWidth; + TPtr8 ptr(REINTERPRET_CAST(TUint8*,iRgbBuf),numColors*sizeof(TRgb)); + TPtr8 paletteData(NULL,0); + TInt color=0; + TPoint point(iWinSize.AsPoint()); + do { + if (color+numColors>256) + numColors=256-color; + TheClient->iScreen->GetScanLine(ptr,point,numColors,EColor16MA); + aPalette->GetDataPtr(color,numColors,paletteData); + TEST(ptr==paletteData); + color+=numColors; + } while (color<256 && ++point.iY<2*iWinSize.iHeight); + } + +void CTGetPixel::CheckPaletteL(CPalette*& aPalette) + { + User::LeaveIfError(TheClient->iScreen->SetCustomPalette(aPalette)); + TestColors(aPalette); + delete aPalette; + User::LeaveIfError(TheClient->iScreen->GetPalette(aPalette)); + TestColors(aPalette); + } + +inline TInt Inc(TInt& aValue) + { + if (aValue>255-83) + aValue-=256-83; + else + aValue+=83; + return aValue; + } + +inline TInt Inc2(TInt& aValue) + { + if (aValue>255-41) + aValue-=256-41; + else + aValue+=41; + return aValue; + } + +void CTGetPixel::PaletteTestL() + { + //INFO_PRINTF1(_L("AUTO PaletteTest ")); + TInt numEntries; + TBool modifiable; + TheClient->iScreen->PaletteAttributes(modifiable,numEntries); + INFO_PRINTF2(_L("Number of entries in the palette %d"), numEntries); + if(numEntries > 65536) + { + INFO_PRINTF1(_L("These test cases has been skipped, as the screen is set up in true colour display mode, where palette is not applicable")); + return; + } + CPalette* palette=NULL; + if (!modifiable) + { + if (numEntries==4) + palette=CPalette::NewDefaultL(EGray4); + else if (numEntries==16) + palette=CPalette::NewDefaultL(EGray16); + else + palette=CPalette::NewL(numEntries); + //INFO_PRINTF1(_L(" Creating Empty Palette, setting it as palette")); + TInt err=TheClient->iScreen->SetCustomPalette(palette); + TEST(err==KErrNoMemory || err==KErrNotSupported || (err==KErrNone && numEntries<=16)); //Series5MX palettes are changeable even though they say they aren't + //INFO_PRINTF1(_L(" Palette setting test passed OK")); + delete palette; + } + TInt err=iWindow.SetRequiredDisplayMode(EColor256); + TheGc->Activate(iWindow); + DrawColorsL(); + //INFO_PRINTF1(_L(" Drawn Colors")); + TheClient->iScreen->PaletteAttributes(modifiable,numEntries); + iRgbBuf=STATIC_CAST(TRgb*,User::ReAllocL(iRgbBuf,Max(256,iWinSize.iWidth)*sizeof(TRgb))); + if (erriScreen->GetPalette(palette); + if (err==KErrNotSupported) + return; + User::LeaveIfError(err); + TestColors(palette); + delete palette; + //INFO_PRINTF1(_L(" Tested Palette OK")); + return; + } + //INFO_PRINTF1(_L(" Palette Changeable")); + TEST(numEntries==256); + CPalette* defPalette=CPalette::NewDefaultL(EColor256); + CleanupStack::PushL(defPalette); + TestColors(defPalette); + User::LeaveIfError(TheClient->iScreen->GetPalette(palette)); + TestColors(palette); + TInt color; + TInt index=0; + for (color=0;color<256;++color) + palette->SetEntry(color,TRgb::Gray256(color)); + CheckPaletteL(palette); + for (color=0;color<256;++color) + palette->SetEntry(color,TRgb(Inc(index),Inc(index),Inc(index))); + CheckPaletteL(palette); + for (color=0;color<256;++color) + palette->SetEntry(color,TRgb(Inc2(index),Inc2(index),Inc2(index))); + CheckPaletteL(palette); + delete palette; + User::LeaveIfError(TheClient->iScreen->SetCustomPalette(defPalette)); + TestColors(defPalette); + CleanupStack::PopAndDestroy(defPalette); + ClearOutRedraws(); + } + +void CTGetPixel::RunTestCaseL(TInt /*aCurTestCase*/) + { + ((CTGetPixelStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); + switch(++iTest->iState) + { +/** +@SYMTestCaseID GRAPHICS-WSERV-0212 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Draw lines and check them by scanning the lines + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Draw lines and then scan them to check that they have + been drawn correctly + +@SYMTestExpectedResults Scanning the lines reveals they have been drawn correctly +*/ + case 1: + ((CTGetPixelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0212")); + TheClient->iWs.SetAutoFlush(ETrue); + iTest->LogSubTest(_L("Basic")); + DrawAndCheckLine(TPoint(0,2),iWinSize.iWidth-2,TRgb::Gray4(0)); + DrawAndCheckLine(TPoint(0,iWinSize.iHeight-2),iWinSize.iWidth,TRgb::Gray4(1)); + DrawAndCheckLine(TPoint(iWinSize.iWidth-1,iWinSize.iHeight-1),1,TRgb::Gray4(2)); + ClearOutRedraws(); + TheClient->iWs.SetAutoFlush(EFalse); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0213 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Draw line on every line of a window and + check them by scanning the lines + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Draw lines on every line of a window and + check them by scanning the lines + +@SYMTestExpectedResults Scanning the lines reveals they have been drawn correctly +*/ + + case 2: + { + ((CTGetPixelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0213")); + iTest->LogSubTest(_L("Full window")); + for(TInt ypos=0;yposSetTestStepID(_L("GRAPHICS-WSERV-0214")); + iTest->LogSubTest(_L("Check Rect")); + TestCheckRect(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0215 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test that the GetScanLine method panics correctly + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Cause the GetScanLine method to panic and chekc the response + +@SYMTestExpectedResults The panic for the GetScanLine method is correct +*/ + case 4: + ((CTGetPixelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0215")); + iTest->LogSubTest(_L("Panic")); + TestPanicsL(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0216 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test that CPalette class functions correctly + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Create a CPalette object and exercise all its methods + +@SYMTestExpectedResults The palette functions as exepcted +*/ + case 5: + ((CTGetPixelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0216")); + iTest->LogSubTest(_L("Palette Test")); + PaletteTestL(); + break; + case 6: + ((CTGetPixelStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + ((CTGetPixelStep*)iStep)->CloseTMSGraphicsStep(); + TestComplete(); + break; + } + ((CTGetPixelStep*)iStep)->RecordTestResultL(); + } + +__WS_CONSTRUCT_STEP__(GetPixel) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TGETPIXEL.H --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TGETPIXEL.H Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,69 @@ + +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef __TGETPIXEL_H__ +#define __TGETPIXEL_H__ + +#include +#include +#include "../tlib/testbase.h" +#include "AUTO.H" +#include "TGraphicsHarness.h" + +class CTGetPixel : public CTWsGraphicsBase + { +public: + CTGetPixel(CTestStep* aStep); + ~CTGetPixel(); + void DrawAndCheckLine(const TPoint &aPos,TInt aLen,TRgb aColor); + void TestCheckRect(); + void GetPixelTest(); + void ConstructL(); + void TestPanicsL(); + void PaletteTestL(); +protected: +//from CTGraphicsStep + virtual void RunTestCaseL(TInt aCurTestCase); +private: + void DrawColorsL(); + void TestColors(CPalette* aPalette); + void CheckPaletteL(CPalette*& aPalette); + void ClearOutRedraws(); +private: + TSize iWinSize; + TRgb *iRgbBuf; + RWindow iWindow; + }; + +class CTGetPixelStep : public CTGraphicsStep + { +public: + CTGetPixelStep(); +protected: + //from CTGraphicsStep + virtual CTGraphicsBase* CreateTestL(); + }; + +_LIT(KTGetPixelStep,"TGetPixel"); + + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TGRAPHICSDRAWER.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TGRAPHICSDRAWER.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,112 @@ +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Tests for the TWsGraphicMsgBufParser +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include "TGRAPHICSDRAWER.H" +#include "Graphics/WSGRAPHICMSGBUF.H" + +CTGraphicsDrawer::CTGraphicsDrawer(CTestStep* aStep): + CTGraphicsBase(aStep) + { + INFO_PRINTF1(_L("Testing TWsGraphicMsgBufParser")); + } + +void CTGraphicsDrawer::RunTestCaseL(TInt aCurTestCase) + { + ((CTGraphicsDrawerStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); + switch(aCurTestCase) + { + case 1: + ((CTGraphicsDrawerStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0449")); + INFO_PRINTF1(_L("TWsGraphicMsgBufParser Indefinite Loop Test")); + IndefiniteLoopL(); + break; + + case 2: + ((CTGraphicsDrawerStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + ((CTGraphicsDrawerStep*)iStep)->CloseTMSGraphicsStep(); + INFO_PRINTF1(_L("Test complete\n")); + TestComplete(); + break; + } + ((CTGraphicsDrawerStep*)iStep)->RecordTestResultL(); + } + + +void CTGraphicsDrawer::ConstructL() + { + } + +CTGraphicsDrawer::~CTGraphicsDrawer() + { + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-0449 + +@SYMDEF DEF110513, PDEF112710 + +@SYMTestCaseDesc Tests that a zero length buffer does not cause an indefinate loop during verify + +@SYMTestPriority Normal + +@SYMTestStatus Implemented + +@SYMTestActions Creates a buffer, puts it into a TWsGraphicMsgBufParser and calls verify on it + then removes the message from the buffer and re-tests verify. + +@SYMTestExpectedResults Test should pass and not timeout +*/ + +void CTGraphicsDrawer::IndefiniteLoopL() + { + RWsGraphicMsgBuf msgBuffer; + msgBuffer.CleanupClosePushL(); + msgBuffer.Append(TUid::Uid(0x12345670),KNullDesC8); + TWsGraphicMsgBufParser msgParser(msgBuffer.Pckg()); + + // test the verify method with a single message in the buffer + if(msgParser.Verify() != KErrNone) + { + INFO_PRINTF1(_L("TWsGraphicMsgBufParser::Verify() failed for buffer length 1")); + TEST(EFalse); + } + + // remove the (only) message so the message buffer now has a length of zero + msgBuffer.Remove(0); + TEST(msgBuffer.Count()==0); + + // test the verify method with an zero length buffer + if(msgParser.Verify() != KErrNone) + { + INFO_PRINTF1(_L("TWsGraphicMsgBufParser::Verify() failed for zero length buffer")); + TEST(EFalse); + } + + CleanupStack::PopAndDestroy(&msgBuffer); + } + +//-------------- +__CONSTRUCT_STEP__(GraphicsDrawer) + + + diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TGRAPHICSDRAWER.H --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TGRAPHICSDRAWER.H Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,59 @@ +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef __TGRAPHICSDRAWER_H__ +#define __TGRAPHICSDRAWER_H__ + +#include +#include +#include "../tlib/testbase.h" +#include "AUTO.H" +#include "TGraphicsHarness.h" + +class CTGraphicsDrawer : public CTGraphicsBase + { +public: + CTGraphicsDrawer(CTestStep* aStep); + ~CTGraphicsDrawer(); + +protected: +//from CTGraphicsStep + virtual void RunTestCaseL(TInt aCurTestCase); +public: + void ConstructL(); + void IndefiniteLoopL(); + +private: + CTestBase *iTest; + }; + +class CTGraphicsDrawerStep : public CTGraphicsStep + { +public: + CTGraphicsDrawerStep(); +protected: + virtual CTGraphicsBase* CreateTestL(); + }; + +_LIT(KTGraphicsDrawerStep,"TGraphicsDrawer"); + + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TGWHANDLE.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TGWHANDLE.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,1870 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// GWHANDLE.CPP +// Test group window handle functions +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include "TGWHANDLE.H" + + +CTGwHandle::CTGwHandle(CTestStep* aStep): + CTWsGraphicsBase(aStep) + { + } + +void CTGwHandle::ConstructL() + { + } + +CTGwHandle::~CTGwHandle() + { + } + +TInt CTGwHandle::NumberOfWndGroupsWithZeroPriority(TInt aScreenNumber) + { + __ASSERT_ALWAYS(aScreenNumber <= 1, User::Invariant()); + return TheClient->iWs.NumWindowGroups(aScreenNumber,0); + } + +void CTGwHandle::GetGwListL(CArrayFixFlat *aWindowHandles) + { + User::LeaveIfError(TheClient->iWs.WindowGroupList(aWindowHandles)); + } + +void CTGwHandle::GetGwListL(CArrayFixFlat *aWindowHandles, TInt aScreenNumber) + { + User::LeaveIfError(TheClient->iWs.WindowGroupList(aWindowHandles, aScreenNumber)); + } + +void CTGwHandle::GetGwListL(TInt aPriority, CArrayFixFlat *aWindowHandles) + { + User::LeaveIfError(TheClient->iWs.WindowGroupList(aPriority,aWindowHandles)); + } + +void CTGwHandle::GetGwListL(RArray* aWindowHandles) + { + User::LeaveIfError(TheClient->iWs.WindowGroupList(aWindowHandles)); + } + +void CTGwHandle::GetGwListL(TInt aPriority, RArray* aWindowHandles) + { + User::LeaveIfError(TheClient->iWs.WindowGroupList(aPriority, aWindowHandles)); + } + +void CTGwHandle::GwNamesL() + { + enum {EConnectHandle1=123456}; + enum {EWindowGroupHandle1=234567}; + enum {EWindowGroupHandle2=666666}; +// + TInt foreground; + User::LeaveIfError(foreground=TheClient->iWs.GetFocusWindowGroup()); + RWsSession ws1; + User::LeaveIfError(ws1.Connect()); + + // assign to the correct screen + CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws1); + CleanupStack::PushL(screen); + User::LeaveIfError(screen->Construct(iTest->iScreenNumber)); + + RWindowGroup gw1(ws1); + User::LeaveIfError(gw1.Construct(EWindowGroupHandle1)); + gw1.SetOwningWindowGroup(foreground); + RWindowGroup gw2(ws1); + User::LeaveIfError(gw2.Construct(EWindowGroupHandle2)); + gw2.SetOwningWindowGroup(foreground); +// + TBuf<8> getName; +// +// Check default name is simply a null string +// + TInt retVal = gw1.Name(getName); + TEST(retVal==KErrNone); + if (retVal!=KErrNone) + INFO_PRINTF3(_L("gw1.Name(getName) return value - Expected: %d, Actual: %d"), KErrNone, retVal); + + TEST(getName==_L("")); + if (getName!=_L("")) + INFO_PRINTF3(_L("getName==_L() - Expected: %d, Actual: %d"), ETrue, EFalse); +// + TBuf<8> name1(_L("A_Name1")); + TBuf<8> name2(_L("A_Name2")); +// + retVal = gw1.SetName(name1); + TEST(retVal==KErrNone); + if (retVal!=KErrNone) + INFO_PRINTF3(_L("gw1.SetName(name1) return value - Expected: %d, Actual: %d"), KErrNone, retVal); + + retVal = gw2.SetName(name2); + TEST(retVal==KErrNone); + if (retVal!=KErrNone) + INFO_PRINTF3(_L("(gw2.SetName(name2) return value - Expected: %d, Actual: %d"), KErrNone, retVal); + + retVal = gw1.Name(getName); + TEST(retVal==KErrNone); + if (retVal!=KErrNone) + INFO_PRINTF3(_L("(gw1.Name(getName) return value - Expected: %d, Actual: %d"), KErrNone, retVal); + + TEST(getName==name1); + if (getName!=name1) + INFO_PRINTF3(_L("getName==name1 - Expected: %d, Actual: %d"), ETrue, EFalse); +// + retVal = gw2.Name(getName); + TEST(retVal==KErrNone); + if (retVal!=KErrNone) + INFO_PRINTF3(_L("(gw2.Name(getName) return value - Expected: %d, Actual: %d"), KErrNone, retVal); + + TEST(getName==name2); + if (getName!=name2) + INFO_PRINTF3(_L("getName==name2 - Expected: %d, Actual: %d"), ETrue, EFalse); + +// +// A few weird characters in the name should work fine +// + retVal = gw2.SetName(_L("xx*")); + TEST(retVal==KErrNone); + if (retVal!=KErrNone) + INFO_PRINTF3(_L("(gw2.SetName(_L(xx*)) return value - Expected: %d, Actual: %d"), KErrNone, retVal); + + retVal = gw2.Name(getName); + TEST(retVal==KErrNone); + if (retVal!=KErrNone) + INFO_PRINTF3(_L("(gw2.Name(getName) return value - Expected: %d, Actual: %d"), KErrNone, retVal); + + TEST(getName==_L("xx*")); + if (getName!=_L("xx*")) + INFO_PRINTF3(_L("getName==_L(xx*) - Expected: %d, Actual: %d"), ETrue, EFalse); + +// + retVal = gw2.SetName(_L(":")); + TEST(retVal==KErrNone); + if (retVal!=KErrNone) + INFO_PRINTF3(_L("(gw2.SetName(_L(:)) return value - Expected: %d, Actual: %d"), KErrNone, retVal); + + retVal = gw2.Name(getName); + TEST(retVal==KErrNone); + if (retVal!=KErrNone) + INFO_PRINTF3(_L("(gw2.Name(getName) return value - Expected: %d, Actual: %d"), KErrNone, retVal); + + TEST(getName==_L(":")); + if (getName!=_L(":")) + INFO_PRINTF3(_L("getName==_L(:) - Expected: %d, Actual: %d"), ETrue, EFalse); + +// +// Setting the name back to a null name +// + retVal = gw2.SetName(_L("")); + TEST(retVal==KErrNone); + if (retVal!=KErrNone) + INFO_PRINTF3(_L("gw2.SetName(_L()) return value - Expected: %d, Actual: %d"), KErrNone, retVal); + + retVal = gw2.Name(getName); + TEST(retVal==KErrNone); + if (retVal!=KErrNone) + INFO_PRINTF3(_L("gw2.Name(getName) return value - Expected: %d, Actual: %d"), KErrNone, retVal); + + TEST(getName==_L("")); + if (getName!=_L("")) + INFO_PRINTF3(_L("getName==_L() - Expected: %d, Actual: %d"), ETrue, EFalse); + +// +// Getting a name into a too short buffer should fill thew whole buffer from the left hand part +// of the window name and return KErrOverflow +// + gw2.SetName(name2); + TBuf<4> shortBuf; + retVal = gw2.Name(shortBuf); + TEST(retVal==KErrOverflow); + if (retVal!=KErrOverflow) + INFO_PRINTF3(_L("gw2.Name(shortBuf) return value - Expected: %d, Actual: %d"), KErrOverflow, retVal); + + TEST(shortBuf==name2.Left(4)); + if (shortBuf!=name2.Left(4)) + INFO_PRINTF3(_L("shortBuf==name2.Left(4) - Expected: %d, Actual: %d"), ETrue, EFalse); + +// +// passing a 0 length TPtr pointing to NULL should be safe, simply returning KErrOverflow +// + TPtr nullPtr(NULL,0); + retVal = gw2.Name(nullPtr); + TEST(retVal==KErrOverflow); + if (retVal!=KErrOverflow) + INFO_PRINTF3(_L("gw2.Name(nullPtr) return value - Expected: %d, Actual: %d"), KErrOverflow, retVal); + + TEST(nullPtr==_L("")); + if (nullPtr!=_L("")) + INFO_PRINTF3(_L("nullPtr==_L() - Expected: %d, Actual: %d"), ETrue, EFalse); + +// +// Getting a null name into a null descriptor +// + gw2.SetName(_L("")); + TPtr nullPtr2(NULL,0); + retVal = gw2.Name(nullPtr); + TEST(retVal==KErrNone); + if (retVal!=KErrNone) + INFO_PRINTF3(_L("gw2.Name(nullPtr) return value - Expected: %d, Actual: %d"), KErrNone, retVal); + + TEST(nullPtr2==_L("")); + if (nullPtr2!=_L("")) + INFO_PRINTF3(_L("nullPtr2==_L() - Expected: %d, Actual: %d"), ETrue, EFalse); +// + gw1.Close(); + gw2.Close(); + CleanupStack::PopAndDestroy(screen); + ws1.Close(); + } + +void CTGwHandle::GwIdentifierTestL() + { + enum {EWindowGroupHandle1=234567}; + enum {EWindowGroupHandle2=666666}; + enum {EWindowGroupHandle3=999}; +// + CArrayFixFlat* windowHandles=new(ELeave) CArrayFixFlat(5); + CleanupStack::PushL(windowHandles); + GetGwListL(0, windowHandles); + TInt retVal = TheClient->iWs.GetFocusWindowGroup(); + TEST(retVal==(*windowHandles)[0]); + if (retVal!=(*windowHandles)[0]) + INFO_PRINTF3(_L("TheClient->iWs.GetFocusWindowGroup() return value - Expected: %d, Actual: %d"), (*windowHandles)[0], retVal); + +// + RWsSession ws1; + User::LeaveIfError(ws1.Connect()); + CleanupClosePushL(ws1); + + // assign to the correct screen + CWsScreenDevice* screen1 = new (ELeave) CWsScreenDevice(ws1); + CleanupStack::PushL(screen1); + User::LeaveIfError(screen1->Construct(iTest->iScreenNumber)); + + RWindowGroup gw1(ws1); + User::LeaveIfError(gw1.Construct(EWindowGroupHandle1)); + gw1.SetOwningWindowGroup((*windowHandles)[0]); + RWsSession ws2; + User::LeaveIfError(ws2.Connect()); + CleanupClosePushL(ws2); + + // assign to the correct screen + CWsScreenDevice* screen2 = new (ELeave) CWsScreenDevice(ws2); + CleanupStack::PushL(screen2); + User::LeaveIfError(screen2->Construct(iTest->iScreenNumber)); + + RWindowGroup gw2(ws2); + User::LeaveIfError(gw2.Construct(EWindowGroupHandle2)); +// + GetGwListL(0, windowHandles); +// + + retVal = gw2.Identifier(); + TEST(retVal==(*windowHandles)[0]); + if (retVal!=(*windowHandles)[0]) + INFO_PRINTF3(_L("gw2.Identifier() return value - Expected: %d, Actual: %d"), (*windowHandles)[0], retVal); + + retVal = gw1.Identifier(); + TEST(retVal==(*windowHandles)[1]); + if (retVal!=(*windowHandles)[1]) + INFO_PRINTF3(_L("gw1.Identifier() return value - Expected: %d, Actual: %d"), (*windowHandles)[1], retVal); + + retVal = TheClient->iWs.GetWindowGroupHandle((*windowHandles)[0]); + TEST(retVal==EWindowGroupHandle2); + if (retVal!=EWindowGroupHandle2) + INFO_PRINTF3(_L("TheClient->iWs.GetWindowGroupHandle((*windowHandles)[0]) return value - Expected: %d, Actual: %d"), EWindowGroupHandle2, retVal); + + retVal = TheClient->iWs.GetWindowGroupHandle((*windowHandles)[1]); + TEST(retVal==EWindowGroupHandle1); + if (retVal!=EWindowGroupHandle1) + INFO_PRINTF3(_L("TheClient->iWs.GetWindowGroupHandle((*windowHandles)[1]) return value - Expected: %d, Actual: %d"), EWindowGroupHandle1, retVal); +// + retVal = TheClient->iWs.GetWindowGroupOrdinalPriority((*windowHandles)[1]); + TEST(retVal==0); + if (retVal!=0) + INFO_PRINTF3(_L("TheClient->iWs.GetWindowGroupOrdinalPriority((*windowHandles)[1]) return value - Expected: %d, Actual: %d"), 0, retVal); + + retVal = TheClient->iWs.GetWindowGroupOrdinalPriority((*windowHandles)[0]); + TEST(retVal==0); + if (retVal!=0) + INFO_PRINTF3(_L("TheClient->iWs.GetWindowGroupOrdinalPriority((*windowHandles)[0]) return value - Expected: %d, Actual: %d"), 0, retVal); + +// + TThreadId threadId; + TheClient->iWs.GetWindowGroupClientThreadId((*windowHandles)[0],threadId); + + TUint64 ret = RThread().Id(); + TEST(ret==threadId); + if (ret!=threadId) + INFO_PRINTF3(_L("RThread().Id() return value - Expected: %d, Actual: %d"), (TInt)threadId, (TInt)ret); + + TheClient->iWs.GetWindowGroupClientThreadId((*windowHandles)[1],threadId); + + TUint64 retVal2 = RThread().Id(); + TEST(retVal2==threadId); + if (retVal2!=threadId) + INFO_PRINTF3(_L("RThread().Id() return value - Expected: %d, Actual: %d"), (TInt)threadId, (TInt)retVal2); +// + retVal = gw1.OrdinalPosition(); + TEST(retVal==1); + if (retVal!=1) + INFO_PRINTF3(_L("gw1.OrdinalPosition() return value - Expected: %d, Actual: %d"), 1, retVal); + + retVal = gw2.OrdinalPosition(); + TEST(retVal==0); + if (retVal!=0) + INFO_PRINTF3(_L("gw2.OrdinalPosition() return value - Expected: %d, Actual: %d"), 0, retVal); + + retVal = TheClient->iWs.SetWindowGroupOrdinalPosition((*windowHandles)[1],0); + TEST(retVal==KErrNone); + if (retVal!=KErrNone) + INFO_PRINTF3(_L("TheClient->iWs.SetWindowGroupOrdinalPosition((*windowHandles)[1],0) return value - Expected: %d, Actual: %d"), KErrNone, retVal); + + retVal = gw1.OrdinalPosition(); + TEST(retVal==0); + if (retVal!=0) + INFO_PRINTF3(_L("gw1.OrdinalPosition() return value - Expected: %d, Actual: %d"), 0, retVal); + + retVal = gw2.OrdinalPosition(); + TEST(retVal==1); + if (retVal!=1) + INFO_PRINTF3(_L("gw2.OrdinalPosition() return value - Expected: %d, Actual: %d"), 1, retVal); +// + retVal = TheClient->iWs.SetWindowGroupOrdinalPosition((*windowHandles)[1],1); + TEST(retVal==KErrNone); + if (retVal!=KErrNone) + INFO_PRINTF3(_L("TheClient->iWs.SetWindowGroupOrdinalPosition((*windowHandles)[1],1) return value - Expected: %d, Actual: %d"), KErrNone, retVal); + + retVal = gw1.OrdinalPosition(); + TEST(retVal==1); + if (retVal!=1) + INFO_PRINTF3(_L("gw1.OrdinalPosition() return value - Expected: %d, Actual: %d"), 1, retVal); + + retVal = gw2.OrdinalPosition(); + TEST(retVal==0); + if (retVal!=0) + INFO_PRINTF3(_L("gw2.OrdinalPosition() return value - Expected: %d, Actual: %d"), 0, retVal); + + retVal = TheClient->iWs.SetWindowGroupOrdinalPosition((*windowHandles)[0],1); + TEST(retVal==KErrNone); + if (retVal!=KErrNone) + INFO_PRINTF3(_L("TheClient->iWs.SetWindowGroupOrdinalPosition((*windowHandles)[0],1) return value - Expected: %d, Actual: %d"), KErrNone, retVal); + + GetGwListL(0, windowHandles); + retVal = TheClient->iWs.GetWindowGroupHandle((*windowHandles)[0]); + TEST(retVal==EWindowGroupHandle1); + if (retVal!=EWindowGroupHandle1) + INFO_PRINTF3(_L("TheClient->iWs.GetWindowGroupHandle((*windowHandles)[0]) return value - Expected: %d, Actual: %d"), EWindowGroupHandle1, retVal); + + retVal = TheClient->iWs.GetWindowGroupHandle((*windowHandles)[1]); + TEST(retVal==EWindowGroupHandle2); + if (retVal!=EWindowGroupHandle2) + INFO_PRINTF3(_L("TheClient->iWs.GetWindowGroupHandle((*windowHandles)[1]) return value - Expected: %d, Actual: %d"), EWindowGroupHandle2, retVal); +// + RWindowGroup gw3(ws2); + User::LeaveIfError(gw3.Construct(EWindowGroupHandle3)); + gw1.SetOrdinalPosition(0,100000); // Assume nothing else in the system is higher, else test will fail + gw3.SetOrdinalPosition(0,100000); + ws1.Flush(); + ws2.Flush(); +// + GetGwListL(100000, windowHandles); + retVal = windowHandles->Count(); + TEST(retVal==2); + if (retVal!=2) + INFO_PRINTF3(_L("windowHandles->Count() return value - Expected: %d, Actual: %d"), 2, retVal); + + retVal = TheClient->iWs.GetWindowGroupHandle((*windowHandles)[0]); + TEST(retVal==EWindowGroupHandle3); + if (retVal!=EWindowGroupHandle3) + INFO_PRINTF3(_L("TheClient->iWs.GetWindowGroupHandle((*windowHandles)[0]) return value - Expected: %d, Actual: %d"), EWindowGroupHandle3, retVal); + + retVal = TheClient->iWs.GetWindowGroupHandle((*windowHandles)[1]); + TEST(retVal==EWindowGroupHandle1); + if (retVal!=EWindowGroupHandle1) + INFO_PRINTF3(_L("TheClient->iWs.GetWindowGroupHandle((*windowHandles)[1]) return value - Expected: %d, Actual: %d"), EWindowGroupHandle1, retVal); + +// + retVal = TheClient->iWs.GetWindowGroupOrdinalPriority((*windowHandles)[0]); + TEST(retVal==100000); + if (retVal!=100000) + INFO_PRINTF3(_L("TheClient->iWs.GetWindowGroupOrdinalPriority((*windowHandles)[0]) return value - Expected: %d, Actual: %d"), 100000, retVal); + + retVal = TheClient->iWs.GetWindowGroupOrdinalPriority((*windowHandles)[1]); + TEST(retVal==100000); + if (retVal!=100000) + INFO_PRINTF3(_L("TheClient->iWs.GetWindowGroupOrdinalPriority((*windowHandles)[1]) return value - Expected: %d, Actual: %d"), 100000, retVal); +// + GetGwListL(-12453, windowHandles); // Test 0 count, Assumes no window with priority + retVal = windowHandles->Count(); + TEST(retVal==0); + if (retVal!=0) + INFO_PRINTF3(_L("windowHandles->Count() return value - Expected: %d, Actual: %d"), 0, retVal); + +// + GetGwListL(windowHandles, iTest->iScreenNumber); + retVal = TheClient->iWs.GetWindowGroupHandle((*windowHandles)[0]); + TEST(retVal==EWindowGroupHandle3); + if (retVal!=EWindowGroupHandle3) + INFO_PRINTF3(_L("TheClient->iWs.GetWindowGroupHandle((*windowHandles)[0]) return value - Expected: %d, Actual: %d"), EWindowGroupHandle3, retVal); + + retVal = TheClient->iWs.GetWindowGroupHandle((*windowHandles)[1]); + TEST(retVal==EWindowGroupHandle1); + if (retVal!=EWindowGroupHandle1) + INFO_PRINTF3(_L("TheClient->iWs.GetWindowGroupHandle((*windowHandles)[1]) return value - Expected: %d, Actual: %d"), EWindowGroupHandle1, retVal); +// +// Check passing bad identifiers +// + retVal = TheClient->iWs.SetWindowGroupOrdinalPosition(-1,0); + TEST(retVal==KErrNotFound); + if (retVal!=KErrNotFound) + INFO_PRINTF3(_L("TheClient->iWs.SetWindowGroupOrdinalPosition(-1,0) return value - Expected: %d, Actual: %d"), KErrNotFound, retVal); + + retVal = TheClient->iWs.GetWindowGroupHandle(-3); + TEST(retVal==KErrNotFound); + if (retVal!=KErrNotFound) + INFO_PRINTF3(_L("TTheClient->iWs.GetWindowGroupHandle(-3) return value - Expected: %d, Actual: %d"), KErrNotFound, retVal); + +// + gw1.Close(); + gw2.Close(); + gw3.Close(); + + CleanupStack::PopAndDestroy(5, windowHandles); + } + +void CTGwHandle::OwnerToForegroundL() + { + enum {EWindowGroupHandle1=234567}; + enum {EWindowGroupHandle2a=666666}; + enum {EWindowGroupHandle2b=666667}; +// + CArrayFixFlat *windowHandles=new(ELeave) CArrayFixFlat(5); + CleanupStack::PushL(windowHandles); + GetGwListL(0, windowHandles); + TInt oldForeground=(*windowHandles)[0]; +// + RWsSession ws1; + User::LeaveIfError(ws1.Connect()); + CleanupClosePushL(ws1); + + // assign to the correct screen + CWsScreenDevice* screen1 = new (ELeave) CWsScreenDevice(ws1); + CleanupStack::PushL(screen1); + User::LeaveIfError(screen1->Construct(iTest->iScreenNumber)); + + RWindowGroup gw1(ws1); + User::LeaveIfError(gw1.Construct(EWindowGroupHandle1)); + CleanupClosePushL(gw1); + RWsSession ws2; + User::LeaveIfError(ws2.Connect()); + CleanupClosePushL(ws2); + + // assign to the correct screen + CWsScreenDevice* screen2 = new (ELeave) CWsScreenDevice(ws2); + CleanupStack::PushL(screen2); + User::LeaveIfError(screen2->Construct(iTest->iScreenNumber)); + + RWindowGroup gw2a(ws2); + User::LeaveIfError(gw2a.Construct(EWindowGroupHandle2a)); + CleanupClosePushL(gw2a); + RWindowGroup gw2b(ws2); + User::LeaveIfError(gw2b.Construct(EWindowGroupHandle2b)); + CleanupClosePushL(gw2b); + gw1.SetOrdinalPosition(1); +// +// Turn auto flushing on as we're using multiple connections and it would be easy to forget to flush one +// + ws1.SetAutoFlush(ETrue); + ws2.SetAutoFlush(ETrue); + TheClient->iWs.SetAutoFlush(ETrue); +// + GetGwListL(0, windowHandles); +// + TInt retVal = gw2b.Identifier(); + TEST(retVal==(*windowHandles)[0]); + if (retVal!=(*windowHandles)[0]) + INFO_PRINTF3(_L("gw2b.Identifier() return value - Expected: %d, Actual: %d"), (*windowHandles)[0], retVal); + + retVal = gw1.Identifier(); + TEST(retVal==(*windowHandles)[1]); + if (retVal!=(*windowHandles)[1]) + INFO_PRINTF3(_L("gw1.Identifier() return value - Expected: %d, Actual: %d"), (*windowHandles)[1], retVal); + + retVal = gw2a.Identifier(); + TEST(retVal==(*windowHandles)[2]); + if (retVal!=(*windowHandles)[2]) + INFO_PRINTF3(_L("gw2a.Identifier() return value - Expected: %d, Actual: %d"), (*windowHandles)[2], retVal); + + retVal = oldForeground; + TEST(retVal==(*windowHandles)[3]); + if (retVal!=(*windowHandles)[3]) + INFO_PRINTF3(_L("oldForeground - Expected: %d, Actual: %d"), (*windowHandles)[3], oldForeground); +// + CleanupStack::PopAndDestroy(&gw2b); + GetGwListL(0, windowHandles); + + retVal = gw2a.Identifier(); + TEST(retVal==(*windowHandles)[0]); + if (retVal!=(*windowHandles)[0]) + INFO_PRINTF3(_L("gw2a.Identifier() return value - Expected: %d, Actual: %d"), (*windowHandles)[0], retVal); + // Check 2a jumped over 1 in the ordinal list + + retVal = gw1.Identifier(); + TEST(retVal==(*windowHandles)[1]); + if (retVal!=(*windowHandles)[1]) + INFO_PRINTF3(_L("gw1.Identifier() return value - Expected: %d, Actual: %d"), (*windowHandles)[1], retVal); + + retVal = oldForeground; + TEST(retVal==(*windowHandles)[2]); + if (retVal!=(*windowHandles)[2]) + INFO_PRINTF3(_L("oldForeground - Expected: %d, Actual: %d"), (*windowHandles)[2], oldForeground); + +// + User::LeaveIfError(gw2b.Construct(EWindowGroupHandle2b)); + CleanupClosePushL(gw2b); + gw2b.SetOwningWindowGroup(oldForeground); + CleanupStack::PopAndDestroy(&gw2b); + GetGwListL(0, windowHandles); + retVal = oldForeground; + TEST(retVal==(*windowHandles)[0]); + if (retVal!=(*windowHandles)[0]) + INFO_PRINTF3(_L("oldForeground - Expected: %d, Actual: %d"), (*windowHandles)[0], oldForeground); + // Check old foreground bought to foreground + + retVal = gw2a.Identifier(); + TEST(retVal==(*windowHandles)[1]); + if (retVal!=(*windowHandles)[1]) + INFO_PRINTF3(_L("gw2a.Identifier() return value - Expected: %d, Actual: %d"), (*windowHandles)[1], retVal); + + retVal = gw1.Identifier(); + TEST(retVal==(*windowHandles)[2]); + if (retVal!=(*windowHandles)[2]) + INFO_PRINTF3(_L("gw1.Identifier() return value - Expected: %d, Actual: %d"), (*windowHandles)[2], retVal); + + TheClient->iWs.SetWindowGroupOrdinalPosition((*windowHandles)[0],2); +// + User::LeaveIfError(gw2b.Construct(EWindowGroupHandle2b)); + CleanupClosePushL(gw2b); + gw2b.SetOwningWindowGroup((*windowHandles)[1]); + gw2b.SetOrdinalPosition(KOrdinalPositionSwitchToOwningWindow); // Should bring 2a to foreground + GetGwListL(0, windowHandles); + + retVal = gw2a.Identifier(); + TEST(retVal==(*windowHandles)[0]); + if (retVal!=(*windowHandles)[0]) + INFO_PRINTF3(_L("gw2a.Identifier() return value - Expected: %d, Actual: %d"), (*windowHandles)[0], retVal); + + retVal = gw2b.Identifier(); + TEST(retVal==(*windowHandles)[1]); + if (retVal!=(*windowHandles)[1]) + INFO_PRINTF3(_L("gw2b.Identifier() return value - Expected: %d, Actual: %d"), (*windowHandles)[1], retVal); + + retVal = gw1.Identifier(); + TEST(retVal==(*windowHandles)[2]); + if (retVal!=(*windowHandles)[2]) + INFO_PRINTF3(_L("gw1.Identifier() return value - Expected: %d, Actual: %d"), (*windowHandles)[2], retVal); +// + CleanupStack::PopAndDestroy(&gw2b); + GetGwListL(0, windowHandles); + retVal = gw2a.Identifier(); + TEST(retVal==(*windowHandles)[0]); + if (retVal!=(*windowHandles)[0]) + INFO_PRINTF3(_L("gw2a.Identifier() return value - Expected: %d, Actual: %d"), (*windowHandles)[0], retVal); + + retVal = gw1.Identifier(); + TEST(retVal==(*windowHandles)[1]); + if (retVal!=(*windowHandles)[1]) + INFO_PRINTF3(_L("gw1.Identifier() return value - Expected: %d, Actual: %d"), (*windowHandles)[1], retVal); +// + CleanupStack::PopAndDestroy(&gw2a); // Should bring shell to foreground + GetGwListL(0, windowHandles); + +// check whether the shell is on + TThreadId threadId; + ws2.GetWindowGroupClientThreadId((*windowHandles)[0],threadId); + TBool shellRunning=ETrue; + + TFullName shellName; + // apply to primary screen only where SHELL is running + TFindThread findThread(iTest->iScreenNumber==KDefaultScreen?_L("WSHELL*::*"):_L("WxSHELL*::*")); + if(findThread.Next(shellName)==KErrNone) + { + RThread shell; + User::LeaveIfError(shell.Open(shellName)); + TEST(shell.Id()==threadId); + if (retVal!=(*windowHandles)[1]) + INFO_PRINTF3(_L("gw1.Identifier() return value - Expected: %d, Actual: %d"), (*windowHandles)[1], retVal); + + shell.Close(); + } + else + { + shellRunning=EFalse; + } + + + // Check gw1 second + retVal = gw1.Identifier(); + TEST(retVal==(*windowHandles)[shellRunning ? 1 : 0]); + if (retVal!=(*windowHandles)[shellRunning ? 1 : 0]) + INFO_PRINTF3(_L("gw1.Identifier() return value - Expected: %d, Actual: %d"), (*windowHandles)[shellRunning ? 1 : 0], retVal); + + retVal = oldForeground; + TEST(retVal==(*windowHandles)[shellRunning ? 2 : 1]); + if (retVal!=(*windowHandles)[shellRunning ? 2 : 1]) + INFO_PRINTF3(_L("gw1.Identifier() return value - Expected: %d, Actual: %d"), (*windowHandles)[shellRunning ? 2 : 1], retVal); + // and oldforeground second + +// + CleanupStack::PopAndDestroy(5, &ws1); +// +// Kick shell back into background, 'cause that's where it belongs +// + TheClient->iWs.SetWindowGroupOrdinalPosition((*windowHandles)[0],-1); + TheClient->iWs.SetAutoFlush(EFalse); +// + CleanupStack::PopAndDestroy(windowHandles); + } + +void CTGwHandle::FindWindowGroupIdentifierTestL() + { + enum {EWindowGroupHandle1=234567}; + enum {EWindowGroupHandle2=666666}; + enum {EWindowGroupHandle3=123}; + TInt foreground=TheClient->iWs.GetFocusWindowGroup(); + RWsSession ws1; + User::LeaveIfError(ws1.Connect()); + + // assign to the correct screen + CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws1); + CleanupStack::PushL(screen); + User::LeaveIfError(screen->Construct(iTest->iScreenNumber)); + CleanupStack::Pop(screen); + + CleanupClosePushL(ws1); +// + RWindowGroup gw1(ws1); + User::LeaveIfError(gw1.Construct(EWindowGroupHandle1)); + CleanupClosePushL(gw1); + gw1.SetOwningWindowGroup(foreground); + RWindowGroup gw2(ws1); + User::LeaveIfError(gw2.Construct(EWindowGroupHandle2)); + CleanupClosePushL(gw2); + gw1.SetOwningWindowGroup(foreground); + RWindowGroup gw3(ws1); + User::LeaveIfError(gw3.Construct(EWindowGroupHandle3)); + CleanupClosePushL(gw3); + gw3.SetOwningWindowGroup(foreground); +// + TInt id1=gw1.Identifier(); + TInt id2=gw2.Identifier(); + TInt id3=gw3.Identifier(); +// + gw1.SetName(_L("qwerty123abcd")); + gw2.SetName(_L("123")); + gw3.SetName(_L("qqqabcdxxx123")); +// + TInt retVal = ws1.FindWindowGroupIdentifier(0,_L("123"),0); + TEST(retVal==id2); + if (retVal!=id2) + INFO_PRINTF3(_L("ws1.FindWindowGroupIdentifier(0,_L(123),0) return value - Expected: %d, Actual: %d"), id2, retVal); + +// + retVal = ws1.FindWindowGroupIdentifier(0,_L("*123*"),0); + TEST(retVal==id3); + if (retVal!=id3) + INFO_PRINTF3(_L("ws1.FindWindowGroupIdentifier(0,_L(*123*),0) return value - Expected: %d, Actual: %d"), id3, retVal); + + retVal = ws1.FindWindowGroupIdentifier(id3,_L("*123*"),0); + TEST(retVal==id2); + if (retVal!=id2) + INFO_PRINTF3(_L("ws1.FindWindowGroupIdentifier(id3,_L(*123*),0) return value - Expected: %d, Actual: %d"), id2, retVal); + + retVal = ws1.FindWindowGroupIdentifier(id2,_L("*123*"),0); + TEST(retVal==id1); + if (retVal!=id1) + INFO_PRINTF3(_L("ws1.FindWindowGroupIdentifier(id2,_L(*123*),0) return value - Expected: %d, Actual: %d"), id1, retVal); + +// + retVal = ws1.FindWindowGroupIdentifier(0,_L("*abcd*"),0); + TEST(retVal==id3); + if (retVal!=id3) + INFO_PRINTF3(_L("ws1.FindWindowGroupIdentifier(0,_L(*abcd*),0) return value - Expected: %d, Actual: %d"), id3, retVal); + + retVal = ws1.FindWindowGroupIdentifier(id3,_L("*abcd*"),0); + TEST(retVal==id1); + if (retVal!=id1) + INFO_PRINTF3(_L("ws1.FindWindowGroupIdentifier(id3,_L(*abcd*),0)return value - Expected: %d, Actual: %d"), id1, retVal); +// + retVal = ws1.FindWindowGroupIdentifier(0,_L("*123*"),7); + TEST(retVal==id3); + if (retVal!=id3) + INFO_PRINTF3(_L("ws1.FindWindowGroupIdentifier(0,_L(*123*),7)return value - Expected: %d, Actual: %d"), id3, retVal); + + retVal = ws1.FindWindowGroupIdentifier(id3,_L("*123*"),7); + TEST(retVal==KErrNotFound); + if (retVal!=KErrNotFound) + INFO_PRINTF3(_L("ws1.FindWindowGroupIdentifier(id3,_L(*123*),7) return value - Expected: %d, Actual: %d"), KErrNotFound, retVal); + + retVal = ws1.FindWindowGroupIdentifier(0,_L("*abc*"),4); + TEST(retVal==id1); + if (retVal!=id1) + INFO_PRINTF3(_L("ws1.FindWindowGroupIdentifier(0,_L(*abc*),4) return value - Expected: %d, Actual: %d"), id1, retVal); + + retVal = ws1.FindWindowGroupIdentifier(id1,_L("*abc*"),4); + TEST(retVal==KErrNotFound); + if (retVal!=KErrNotFound) + INFO_PRINTF3(_L("ws1.FindWindowGroupIdentifier(id1,_L(*abc*),4) return value - Expected: %d, Actual: %d"), KErrNotFound, retVal); + + retVal = ws1.FindWindowGroupIdentifier(0,_L("xxx*"),7); + TEST(retVal==id3); + if (retVal!=id3) + INFO_PRINTF3(_L("ws1.FindWindowGroupIdentifier(0,_L(xxx*),7) return value - Expected: %d, Actual: %d"), id3, retVal); + + retVal = ws1.FindWindowGroupIdentifier(0,_L("xxx*"),8); + TEST(retVal==KErrNotFound); + if (retVal!=KErrNotFound) + INFO_PRINTF3(_L("ws1.FindWindowGroupIdentifier(0,_L(xxx*),8) return value - Expected: %d, Actual: %d"), KErrNotFound, retVal); +// + retVal = ws1.FindWindowGroupIdentifier(id1,_L("12"),0); + TEST(retVal==KErrNotFound); + if (retVal!=KErrNotFound) + INFO_PRINTF3(_L("ws1.FindWindowGroupIdentifier(id1,_L(12),0) return value - Expected: %d, Actual: %d"), KErrNotFound, retVal); + + retVal = ws1.FindWindowGroupIdentifier(id1,_L("qqq"),0); + TEST(retVal==KErrNotFound); + if (retVal!=KErrNotFound) + INFO_PRINTF3(_L("ws1.FindWindowGroupIdentifier(id1,_L(qqq),0) return value - Expected: %d, Actual: %d"), KErrNotFound, retVal); + + retVal = ws1.FindWindowGroupIdentifier(id1,_L("abcd"),3); + TEST(retVal==KErrNotFound); + if (retVal!=KErrNotFound) + INFO_PRINTF3(_L("ws1.FindWindowGroupIdentifier(id1,_L(abcd),3) return value - Expected: %d, Actual: %d"), KErrNotFound, retVal); +// + delete screen; + CleanupStack::PopAndDestroy(4, &ws1); + } + +void CTGwHandle::DefaultOwningWindowL() + { + TInt foreground=TheClient->iWs.GetFocusWindowGroup(); + RWsSession ws1; + User::LeaveIfError(ws1.Connect()); + + // assign to the correct screen + CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws1); + CleanupStack::PushL(screen); + User::LeaveIfError(screen->Construct(iTest->iScreenNumber)); + +// + INFO_PRINTF1(_L("DefaultOwningWindow1")); + RWindowGroup gw1(ws1); + User::LeaveIfError(gw1.Construct(1)); + gw1.SetOwningWindowGroup(foreground); + RWindowGroup gw2(ws1); + User::LeaveIfError(gw2.Construct(2)); + gw2.SetOwningWindowGroup(foreground); + RWindowGroup gw3(ws1); + User::LeaveIfError(gw3.Construct(3)); + gw3.SetOwningWindowGroup(foreground); + RWindowGroup gw4(ws1); + User::LeaveIfError(gw4.Construct(4)); + gw4.SetOwningWindowGroup(foreground); + INFO_PRINTF1(_L(" Created Group Window")); +// + TInt prevOwningGroup=ws1.GetDefaultOwningWindow(); + gw1.DefaultOwningWindow(); + TEST(gw1.Identifier()==ws1.GetDefaultOwningWindow()); + if (gw1.Identifier()!=ws1.GetDefaultOwningWindow()) + INFO_PRINTF3(_L("gw1.Identifier()==ws1.GetDefaultOwningWindow() - Expected: %d, Actual: %d"), ws1.GetDefaultOwningWindow(), gw1.Identifier()); + + gw2.DefaultOwningWindow(); + TEST(gw2.Identifier()==ws1.GetDefaultOwningWindow()); + if (gw2.Identifier()!=ws1.GetDefaultOwningWindow()) + INFO_PRINTF3(_L("gw2.Identifier()==ws1.GetDefaultOwningWindow() - Expected: %d, Actual: %d"), ws1.GetDefaultOwningWindow(), gw2.Identifier()); + + gw2.Close(); + TEST(gw1.Identifier()==ws1.GetDefaultOwningWindow()); + if (gw1.Identifier()!=ws1.GetDefaultOwningWindow()) + INFO_PRINTF3(_L("gw1.Identifier()==ws1.GetDefaultOwningWindow() - Expected: %d, Actual: %d"), ws1.GetDefaultOwningWindow(), gw1.Identifier()); + + gw3.DefaultOwningWindow(); + gw4.DefaultOwningWindow(); + gw3.Close(); + TEST(gw4.Identifier()==ws1.GetDefaultOwningWindow()); + if (gw4.Identifier()!=ws1.GetDefaultOwningWindow()) + INFO_PRINTF3(_L("gw4.Identifier()==ws1.GetDefaultOwningWindow() - Expected: %d, Actual: %d"), ws1.GetDefaultOwningWindow(), gw4.Identifier()); + + gw4.Close(); + TEST(gw1.Identifier()==ws1.GetDefaultOwningWindow()); + if (gw1.Identifier()!=ws1.GetDefaultOwningWindow()) + INFO_PRINTF3(_L("gw1.Identifier()==ws1.GetDefaultOwningWindow() - Expected: %d, Actual: %d"), ws1.GetDefaultOwningWindow(), gw1.Identifier()); + + gw1.Close(); + TEST(prevOwningGroup==ws1.GetDefaultOwningWindow()); + if (prevOwningGroup!=ws1.GetDefaultOwningWindow()) + INFO_PRINTF3(_L("prevOwningGroup==ws1.GetDefaultOwningWindow() - Expected: %d, Actual: %d"), ws1.GetDefaultOwningWindow(), prevOwningGroup); + + INFO_PRINTF1(_L(" Closed Group Window")); + + User::LeaveIfError(gw1.Construct(1)); + gw1.SetOwningWindowGroup(foreground); + User::LeaveIfError(gw2.Construct(2)); + gw2.SetOwningWindowGroup(foreground); + User::LeaveIfError(gw3.Construct(3)); + gw3.SetOwningWindowGroup(foreground); + INFO_PRINTF1(_L(" ReCreated Group Window")); + gw1.DefaultOwningWindow(); + gw1.DefaultOwningWindow(); + gw1.Close(); + gw2.DefaultOwningWindow(); + gw2.DefaultOwningWindow(); + gw3.Close(); + gw2.Close(); + INFO_PRINTF1(_L(" Re-Closed Group Window")); + + User::LeaveIfError(gw1.Construct(1)); + gw1.SetOwningWindowGroup(foreground); + User::LeaveIfError(gw2.Construct(2)); + gw2.SetOwningWindowGroup(foreground); + User::LeaveIfError(gw3.Construct(3)); + gw3.SetOwningWindowGroup(foreground); + User::LeaveIfError(gw4.Construct(4)); + gw4.SetOwningWindowGroup(foreground); + INFO_PRINTF1(_L(" ReCreated Group Window Again")); + gw1.DefaultOwningWindow(); + gw2.DefaultOwningWindow(); + gw1.DefaultOwningWindow(); + gw1.Close(); + gw2.Close(); + gw3.DefaultOwningWindow(); + gw4.DefaultOwningWindow(); + gw3.DefaultOwningWindow(); + gw4.Close(); + gw3.Close(); + INFO_PRINTF1(_L(" Re-Closed Group Window Again")); + + User::LeaveIfError(gw1.Construct(1)); + gw1.DefaultOwningWindow(); + TEST(gw1.Identifier()==ws1.GetDefaultOwningWindow()); + if (gw1.Identifier()!=ws1.GetDefaultOwningWindow()) + INFO_PRINTF3(_L("gw1.Identifier()==ws1.GetDefaultOwningWindow() - Expected: %d, Actual: %d"), ws1.GetDefaultOwningWindow(), gw1.Identifier()); + + gw1.DefaultOwningWindow(); + TEST(gw1.Identifier()==ws1.GetDefaultOwningWindow()); + if (gw1.Identifier()!=ws1.GetDefaultOwningWindow()) + INFO_PRINTF3(_L("gw1.Identifier()==ws1.GetDefaultOwningWindow() - Expected: %d, Actual: %d"), ws1.GetDefaultOwningWindow(), gw1.Identifier()); + + User::LeaveIfError(gw2.Construct(2)); + TEST(gw1.Identifier()==ws1.GetDefaultOwningWindow()); + if (gw1.Identifier()!=ws1.GetDefaultOwningWindow()) + INFO_PRINTF3(_L("gw1.Identifier()==ws1.GetDefaultOwningWindow() - Expected: %d, Actual: %d"), ws1.GetDefaultOwningWindow(), gw1.Identifier()); + + gw2.Close(); + gw1.Close(); + + CleanupStack::PopAndDestroy(screen); + ws1.Close(); + } + +void CTGwHandle::DefaultOwningWindow2L() +//This test originally resulted in a crash, while the above test originally resulted in lockups. + { + RWsSession ws1; + User::LeaveIfError(ws1.Connect()); + + // assign to the correct screen + CWsScreenDevice* screen1 = new (ELeave) CWsScreenDevice(ws1); + CleanupStack::PushL(screen1); + User::LeaveIfError(screen1->Construct(iTest->iScreenNumber)); + + RWsSession ws2; + User::LeaveIfError(ws2.Connect()); + + // assign to the correct screen + CWsScreenDevice* screen2 = new (ELeave) CWsScreenDevice(ws2); + CleanupStack::PushL(screen2); + User::LeaveIfError(screen2->Construct(iTest->iScreenNumber)); + +// + RWindowGroup gw1(ws1); + User::LeaveIfError(gw1.Construct(1)); + RWindowGroup gw2(ws2); + User::LeaveIfError(gw2.Construct(2)); + RWindowGroup gw3(ws1); + User::LeaveIfError(gw3.Construct(3)); +// + const TInt gw1Id=gw1.Identifier(); + gw1.DefaultOwningWindow(); + gw2.DefaultOwningWindow(); + /*const TInt gw2Id=*/gw2.Identifier(); + gw1.DefaultOwningWindow(); + TEST(gw1Id==ws1.GetDefaultOwningWindow()); + if (gw1Id!=ws1.GetDefaultOwningWindow()) + INFO_PRINTF3(_L("gw1Id==ws1.GetDefaultOwningWindow() - Expected: %d, Actual: %d"), ws1.GetDefaultOwningWindow(), gw1Id); + + gw3.DefaultOwningWindow(); + gw3.Close(); + TEST(gw1Id==ws1.GetDefaultOwningWindow()); + if (gw1Id!=ws1.GetDefaultOwningWindow()) + INFO_PRINTF3(_L("gw1Id==ws1.GetDefaultOwningWindow() - Expected: %d, Actual: %d"), ws1.GetDefaultOwningWindow(), gw1Id); + + gw1.Close(); + TInt gw2Id=gw2.Identifier(); + TEST(gw2Id==ws1.GetDefaultOwningWindow()); + if (gw2Id!=ws1.GetDefaultOwningWindow()) + INFO_PRINTF3(_L("gw2Id==ws1.GetDefaultOwningWindow() - Expected: %d, Actual: %d"), ws1.GetDefaultOwningWindow(), gw2Id); + + gw2.SetOrdinalPosition(0); + gw2.Close(); + ws2.Flush(); + TRawEvent rawEvent; + rawEvent.Set(TRawEvent::EKeyDown,32); + TheClient->iWs.SimulateRawEvent(rawEvent); + TheClient->iWs.Flush(); +// + CleanupStack::PopAndDestroy(2,screen1); + ws1.Close(); + ws2.Close(); + } + +#define FREQ 500 +void CTGwHandle::IdentifierWrapAroundTestL() + { + TInt report=-1; + RWsSession ws1; + User::LeaveIfError(ws1.Connect()); + + // assign to the correct screen + CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws1); + CleanupStack::PushL(screen); + User::LeaveIfError(screen->Construct(iTest->iScreenNumber)); + + RWindowGroup gw1(ws1); + User::LeaveIfError(gw1.Construct(1)); + gw1.EnableReceiptOfFocus(EFalse); + TInt id1=gw1.Identifier(); + RWindowGroup gw2(ws1); + User::LeaveIfError(gw2.Construct(2)); + gw2.EnableReceiptOfFocus(EFalse); + TInt id2=gw2.Identifier(); + gw2.Close(); // Allow gw2 id to be re-used + TInt id3; + + do + { + RWindowGroup gw3(ws1); + User::LeaveIfError(gw3.Construct(2)); + gw3.EnableReceiptOfFocus(EFalse); + id3=gw3.Identifier(); + if ((id3/FREQ)!=(report/FREQ)) // || id3<=10) + { + report=id3; + iTest->LogMessage(id3); + } + TEST(id3!=id1); // Check id1 is not re-used as the window hasn't been freed yet + if (id3==id1) + { + _LIT(KErr,"Window Group Id Reused!"); + LOG_MESSAGE(KErr); + } + gw3.Close(); + } while(id3!=id2); + + CleanupStack::PopAndDestroy(screen); + ws1.Close(); + } + +void GwHandleDestroyWindow(TAny* aWindow) + { + static_cast(aWindow)->Destroy(); + } + +RWindowGroup* CTGwHandle::CreateWindowGroupLC(RWsSession& aWs,TUint32 aClientHandle,TInt aParentId/*=0*/) + { + RWindowGroup* gw=new(ELeave) RWindowGroup(aWs); + CleanupStack::PushL(TCleanupItem(&GwHandleDestroyWindow,gw)); + if (aParentId>0) + { + User::LeaveIfError(gw->ConstructChildApp(aParentId,aClientHandle,EFalse)); + } + else + { + User::LeaveIfError(gw->Construct(aClientHandle,EFalse)); + } + return gw; + } + +void CTGwHandle::CreateGroupWindowsLC(RWsSession& aWs) + { + for(TInt ii=ENumGroups-1;ii>=0;--ii) + iGroups[ii]=CreateWindowGroupLC(aWs,ii); + } + +void CTGwHandle::CreateChainedGroupWindowsLC(RWsSession& aWs,TBool aSecondChain) + { + TInt parentId=0; + for(TInt ii=ENumChained-1;ii>=0;--ii) + { + iChained[ii]=CreateWindowGroupLC(aWs,ENumGroups+ii,parentId); + parentId=iChained[ii]->Identifier(); + } + if(aSecondChain) + { + parentId =0; + for(TInt ii=ENumChained-1;ii>=0;--ii) + { + iChained2[ii]=CreateWindowGroupLC(aWs,ENumGroups+ENumGroups+ii,parentId); + parentId=iChained2[ii]->Identifier(); + } + } + } + +void CTGwHandle::MoveGroups(RWindowGroup** aGroups,TInt aGp,TInt aNum,TInt aPos,TInt aInc/*=2*/) + { + TInt ii; + for(ii=aNum;ii>0;--ii) + { + aGroups[aGp]->SetOrdinalPosition(aPos); + aGp+=(aInc>0?1:-1); + aPos+=aInc; + } + } + +void CTGwHandle::TestGroups(TInt aPos) + { + TInt retVal; + TInt ii = 0; + for(ii=0;iiOrdinalPosition(); + TEST(retVal==aPos+ii); + if (retVal!=aPos+ii) + INFO_PRINTF3(_L("iChained[ii]->OrdinalPosition() return value - Expected: %d, Actual: %d"), aPos+ii, retVal); + } + + for(ii=0;iiOrdinalPosition(); + TInt ret = (iiOrdinalPosition() return value - Expected: %d, Actual: %d"), ret, retVal); + } + } + +void CTGwHandle::TestGroupsBefore(TInt aPos) + { + TInt ii; + TInt retVal; + if (aPos>0) + { + for (ii=0;iiOrdinalPosition(); + TEST(retVal==ii); + if (retVal!=ii) + INFO_PRINTF3(_L("iGroups[ii]->OrdinalPosition() return value - Expected: %d, Actual: %d"), ii, retVal); + } + } + for (ii=0;iiOrdinalPosition(); + TEST(retVal==aPos+2*ii); + if (retVal!=aPos+2*ii) + INFO_PRINTF3(_L("iChained[ii]->OrdinalPosition() return value - Expected: %d, Actual: %d"), aPos+2*ii, retVal); + } + for (ii=0;iiOrdinalPosition(); + TEST(retVal==aPos+1+2*ii); + if (retVal!=aPos+1+2*ii) + INFO_PRINTF3(_L("iGroups[aPos+ii]->OrdinalPosition() return value - Expected: %d, Actual: %d"), aPos+1+2*ii, retVal); + } + for (ii=aPos+ENumChained-1;iiOrdinalPosition(); + TEST(retVal==ii+ENumChained); + if (retVal!=ii+ENumChained) + INFO_PRINTF3(_L("iGroups[ii]->OrdinalPosition() return value - Expected: %d, Actual: %d"), ii+ENumChained, retVal); + } + } + +void CTGwHandle::WindowGroupChaining() + { + RWsSession& ws=TheClient->iWs; + CreateGroupWindowsLC(ws); + CreateChainedGroupWindowsLC(ws); + TestGroups(0); + TInt start,target,moveGp; + for(moveGp=0;moveGpstart+1) + MoveGroups(iGroups,target-1,target-start-1,ENumChained+target-1,-1); + if (target0) + MoveGroups(iGroups,0,start,0,1); + MoveGroups(iGroups,start,ENumChained-1,start+1); + TestGroupsBefore(start); + iChained[moveGp]->SetOrdinalPosition(target+moveGp); + TestGroups(target); + } + } + iChained[0]->SetOrdinalPosition(0); + TestGroups(0); + } + CleanupStack::PopAndDestroy(ENumGroups+ENumChained,iGroups[ENumGroups-1]); + } + +void CTGwHandle::WindowGroupChaining2() + { + RWsSession& ws=TheClient->iWs; + RWindowGroup* chain1=CreateWindowGroupLC(ws,1); + chain1->SetOrdinalPosition(0,1); + RWindowGroup* chain2=CreateWindowGroupLC(ws,2,chain1->Identifier()); + TInt retVal = chain2->OrdinalPriority(); + TEST(retVal==1); + if (retVal!=1) + INFO_PRINTF3(_L("chain2->OrdinalPriority() return value - Expected: %d, Actual: %d"), 1, retVal); + + chain1->SetOrdinalPosition(0,2); + retVal = chain2->OrdinalPriority(); + TEST(retVal==2); + if (retVal!=2) + INFO_PRINTF3(_L("chain2->OrdinalPriority() return value - Expected: %d, Actual: %d"), 2, retVal); + + chain2->SetOrdinalPosition(0,3); + retVal = chain1->OrdinalPriority(); + TEST(retVal==3); + if (retVal!=3) + INFO_PRINTF3(_L("chain1->OrdinalPriority() return value - Expected: %d, Actual: %d"), 3, retVal); + + CleanupStack::PopAndDestroy(2,chain1); + + //Test that two different sessions can't chain window-groups without permisson. + //Both sessions must use the same screen. + RWsSession ws2; + User::LeaveIfError(ws2.Connect()); + CleanupClosePushL(ws2); + chain1=CreateWindowGroupLC(ws2,1); + TInt id1=chain1->Identifier(); + + RWsSession ws3; + User::LeaveIfError(ws3.Connect()); + CleanupClosePushL(ws3); + RWindowGroup chain(ws3); + + RDebug::Print(KPlatsecBegin); + retVal = chain.ConstructChildApp(id1,2); + TEST(retVal==KErrPermissionDenied); + if (retVal!=KErrPermissionDenied) + INFO_PRINTF3(_L("chain.ConstructChildApp(id1,2) return value - Expected: %d, Actual: %d"), KErrPermissionDenied, retVal); + + RDebug::Print(KPlatsecEnd); + chain1->AllowProcessToCreateChildWindowGroups(TUid::Uid(0x10205152)); //Secure ID + retVal = chain.ConstructChildApp(id1,2); + TEST(retVal==KErrNone); + if (retVal!=KErrNone) + INFO_PRINTF3(_L("chain.ConstructChildApp(id1,2) return value - Expected: %d, Actual: %d"), KErrNone, retVal); + + chain.Close(); + CleanupStack::PopAndDestroy(3,&ws2); + } + +void CTGwHandle::UnchainWindowGroupsL() + { + RArray* windowHandles=new(ELeave) RArray; + CleanupStack::PushL(windowHandles); + GetGwListL(0,windowHandles); + TInt shellWindow=windowHandles->Count(); + //Creating chained window groups. + CreateChainedGroupWindowsLC(TheClient->iWs); + GetGwListL(0,windowHandles); + //Test total window groups in the list + TInt retVal = windowHandles->Count(); + TEST(retVal==ENumChained+shellWindow); + if (retVal!=ENumChained+shellWindow) + INFO_PRINTF3(_L("windowHandles->Count() return value - Expected: %d, Actual: %d"), ENumChained+shellWindow, retVal); + //Two unchained group windows + + //Test Parent Id + TInt parentId=0; + for(TInt ii=ENumChained-1;ii>=0;ii--) + { + RWsSession::TWindowGroupChainInfo window; + window.iId=iChained[ii]->Identifier(); + TInt loc=windowHandles->Find(window); + TEST(loc!=KErrNotFound); + if (loc==KErrNotFound) + INFO_PRINTF3(_L("windowHandles->Find(window) return value - Expected: %d, Actual: %d"), KErrNotFound, loc); + + if(loc!=KErrNotFound) + { + TEST((*windowHandles)[loc].iParentId==parentId); + if ((*windowHandles)[loc].iParentId!=parentId) + INFO_PRINTF3(_L("(*windowHandles)[loc].iParentId==parentId - Expected: %d, Actual: %d"), parentId, (*windowHandles)[loc].iParentId); + + parentId=window.iId; + } + } + //Test unchaining of chained window groups + for(TInt count=ENumChained-1;count>=0;count--) + { + iChained[count]->Close(); + GetGwListL(0,windowHandles); + TEST(windowHandles->Count()== count+shellWindow); + if (windowHandles->Count()!= count+shellWindow) + INFO_PRINTF3(_L("windowHandles->Count()==count+shellWindow - Expected: %d, Actual: %d"), count+shellWindow, windowHandles->Count()); + + } + CleanupStack::PopAndDestroy(ENumChained,iChained[ENumChained-1]); + + //delete middle windowgroup of chain which should kill all the child windows + CreateChainedGroupWindowsLC(TheClient->iWs); + TInt windowPos=2; + CleanupStack::Pop(2,iChained[1]); //Pop first 2 items iChained[0] and iChained[1] + iChained[windowPos]->Close();//Close the 3rd WindowGroup in the chain.should unchain 4 and 5 window group. + CleanupStack::PopAndDestroy(iChained[windowPos]); + CleanupStack::PushL(TCleanupItem(&GwHandleDestroyWindow,iChained[1])); + CleanupStack::PushL(TCleanupItem(&GwHandleDestroyWindow,iChained[0])); + GetGwListL(0,windowHandles); + retVal = ChainedWindowCount(windowHandles); + TEST(retVal==ENumChained-windowPos-1); + if (retVal!=ENumChained-windowPos-1) + INFO_PRINTF3(_L("ChainedWindowCount(windowHandles) return value - Expected: %d, Actual: %d"), ENumChained-windowPos-1, retVal); + +// CleanupStack::PopAndDestroy(ENumChained-1,iChained[ENumChained-1]); + + windowPos=3; + CleanupStack::Pop(2,iChained[1]); + iChained[windowPos]->Close();//Close the 2nd WindowGroup in the chain. + //should unchain all . + CleanupStack::PopAndDestroy(iChained[windowPos]); + CleanupStack::PushL(TCleanupItem(&GwHandleDestroyWindow,iChained[1])); + CleanupStack::PushL(TCleanupItem(&GwHandleDestroyWindow,iChained[0])); + GetGwListL(0,windowHandles); + retVal = ChainedWindowCount(windowHandles); + TEST(retVal==ENumChained-windowPos-2); + if (retVal!=ENumChained-windowPos-2) + INFO_PRINTF3(_L("ChainedWindowCount(windowHandles) return value - Expected: %d, Actual: %d"), ENumChained-windowPos-2, retVal); + + windowPos=4; + CleanupStack::Pop(2,iChained[1]); + iChained[windowPos]->Close();//Closing parent window group in chain. There should be no chain + CleanupStack::PopAndDestroy(iChained[windowPos]); + CleanupStack::PushL(TCleanupItem(&GwHandleDestroyWindow,iChained[1])); + CleanupStack::PushL(TCleanupItem(&GwHandleDestroyWindow,iChained[0])); + GetGwListL(0,windowHandles); + retVal = ChainedWindowCount(windowHandles); + TEST(retVal==ENumChained-windowPos-1); + if (retVal!=ENumChained-windowPos-1) + INFO_PRINTF3(_L("ChainedWindowCount(windowHandles) return value - Expected: %d, Actual: %d"), ENumChained-windowPos-1, retVal); + + CleanupStack::PopAndDestroy(ENumChained-3,iChained[ENumChained-4]); + windowHandles->Close(); + CleanupStack::PopAndDestroy(windowHandles); + } + +TInt CTGwHandle::ChainedWindowCount(RArray* aWindowHandles) + { + TInt wndGrpCount=0; + for(TInt ii=0;iiCount();ii++) + { + if((*aWindowHandles)[ii].iParentId!=-1) + wndGrpCount++; + } + return wndGrpCount; + } + +void CTGwHandle::TestOrdinalPositionL() + { + TInt noOfGroupWnds = NumberOfWndGroupsWithZeroPriority(iTest->iScreenNumber); + //Creating the chained window groups + CreateChainedGroupWindowsLC(TheClient->iWs); + TestOrdinalPos(0); + //Test the ordinal position of all chained windows by setting the WndPos window + //to chainPos position + for(TInt wndPos=0;wndPosSetOrdinalPosition(chainPos); + TInt dung = chainPos-wndPos; + if(dung > noOfGroupWnds) + { + dung = noOfGroupWnds; + } + dung = Max(dung, 0); + TestOrdinalPos(chainPos - wndPos > noOfGroupWnds ? noOfGroupWnds : Max(chainPos - wndPos, 0)); + } + } + //Test for negative ordinal number + iChained[0]->SetOrdinalPosition(-2); + TestOrdinalPos(noOfGroupWnds); + CleanupStack::PopAndDestroy(ENumChained,iChained[ENumChained-1]); + } + +void CTGwHandle::TestOrdinalPositionNoDebugL() + { + TInt noOfGroupWnds = NumberOfWndGroupsWithZeroPriority(iTest->iScreenNumber); + //Creating the chained window groups + CreateChainedGroupWindowsLC(TheClient->iWs); + //Test the ordinal position of all chained windows + TestOrdinalPosNoDebug(0); + //Test the ordinal position of all chained windows by setting the WndPos window + //to chainPos position + for(TInt wndPos=0;wndPosSetOrdinalPosition(chainPos); + TestOrdinalPosNoDebug(chainPos - wndPos > noOfGroupWnds ? noOfGroupWnds : Max(chainPos - wndPos, 0)); + } + } + //Test for negative ordinal number + iChained[0]->SetOrdinalPosition(-2); + TestOrdinalPosNoDebug(noOfGroupWnds); + CleanupStack::PopAndDestroy(ENumChained,iChained[ENumChained-1]); + } + +void CTGwHandle::TestOrdinalPos(TInt aPos) + { + for(TInt ii=0;iiOrdinalPosition(); + TEST(iCha==aPos++); + if (iCha!=aPos-1) + { + INFO_PRINTF3(_L("iChained[ii]->OrdinalPosition() return value - Expected: %d, Actual: %d"), aPos-1, iCha); + } + } + } + +void CTGwHandle::TestOrdinalPosNoDebug(TInt aPos) + { + for(TInt ii=0;iiOrdinalPosition(); + TEST(iCha==aPos++); + if (iCha!=aPos-1) + INFO_PRINTF3(_L("iChained[ii]->OrdinalPosition() return value - Expected: %d, Actual: %d"), aPos-1, iCha); + + } + } + +void CTGwHandle:: TestclosingclientL() + { + RWsSession ws1; + User::LeaveIfError(ws1.Connect()); + CleanupClosePushL(ws1); + + // assign to the correct screen + CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws1); + CleanupStack::PushL(screen); + User::LeaveIfError(screen->Construct(iTest->iScreenNumber)); + + // Creating first Window Group + RWindowGroup gw1(ws1); + User::LeaveIfError(gw1.Construct(ENullWsHandle)); + ws1.SetWindowGroupOrdinalPosition(gw1.Identifier(),0); + + // Creating second Window Group + RWindowGroup gw2(ws1); + User::LeaveIfError(gw2.Construct(ENullWsHandle)); + gw2.SetOwningWindowGroup(gw1.Identifier()); + gw2.SetOrdinalPosition(1); + CleanupStack::PopAndDestroy(screen); + CleanupStack::PopAndDestroy(&ws1); + } + +void CTGwHandle::TestClearingAndSettingChildGroupsL() + { + RArray windowHandles; + CleanupClosePushL(windowHandles); + //Creating a chain of 5 window groups. + CreateChainedGroupWindowsLC(TheClient->iWs); + TInt ret=KErrNone; + // Want to test clearing and setting of window groups for chain lengths of 5 down to 2 + for(TInt jj=ENumChained-1;jj>0;jj--) + { + // For each window group in the chain, test clearing and setting a child group + for(TInt ii=jj;ii>0;ii--) + { + RWsSession::TWindowGroupChainInfo window1; + window1.iId=iChained[ii]->Identifier(); + GetGwListL(0,&windowHandles); + TInt loc=windowHandles.Find(window1); + TEST(loc!=KErrNotFound); + if(loc!=KErrNotFound) + { + RWsSession::TWindowGroupChainInfo window2; + window2.iId=iChained[ii-1]->Identifier(); + loc = windowHandles.Find(window2); + TEST(loc!=KErrNotFound); + // First test that the parent of the next window in the chain is the previous in the chain + if(loc!=KErrNotFound) + { + TEST(windowHandles[loc].iParentId==window1.iId); + } + // Then clear and test that the parent of the next window in the chain + // is no longer the previous window in the chain + ret=iChained[ii]->ClearChildGroup(); + TEST(ret==KErrNone); + // Try to clear a child group when it's already cleared - should return KErrArgument + ret=iChained[ii]->ClearChildGroup(); + TEST(ret==KErrArgument); + GetGwListL(0,&windowHandles); + loc = windowHandles.Find(window2); + TEST(loc!=KErrNotFound); + // Test that it has no parent (0) or is unchained (-1) + if(loc!=KErrNotFound) + { + if(ii==1) // last in chain therefore unchained, should return -1 + TEST(windowHandles[loc].iParentId==-1); + else // otherwise should return 0 signifying in a chain but with no parent + TEST(windowHandles[loc].iParentId==0); + } + // Reset the former child group as a child to the current group + ret=iChained[ii]->SetChildGroup(window2.iId); + TEST(ret==KErrNone); + // Test that it has now got it's parent back + GetGwListL(0,&windowHandles); + loc = windowHandles.Find(window2); + TEST(loc!=KErrNotFound); + if(loc!=KErrNotFound) + { + TEST(windowHandles[loc].iParentId==window1.iId); + } + } + } + // Reduce chain length by 1 + ret=iChained[jj]->ClearChildGroup(); + TEST(ret==KErrNone); + } + // Try to clear the child group of a window that's not in a queue - returns KErrArgument + ret=iChained[0]->ClearChildGroup(); + TEST(ret==KErrArgument); + // Test calling set on a non-existent window group - fictional id, larger than what exists + ret=iChained[0]->SetChildGroup(9999); + TEST(ret==KErrArgument); + // Cleanup + CleanupStack::PopAndDestroy(ENumChained,iChained[ENumChained-1]); + CleanupStack::PopAndDestroy(&windowHandles); + } + +void CTGwHandle::TestAgainstLoopsWhenAddingChildGroupsL() + { + //Creating two chains of 5 window groups. + CreateChainedGroupWindowsLC(TheClient->iWs,ETrue); + TInt ret=KErrNone; + + //Try to append any of element of this chain to the lastone (itself included) + //All these attempts should fail (otherwise a infinite loop will be set up) + for(TInt ii=ENumChained-1;ii>=0;ii--) + { + TInt windowId = iChained[ii]->Identifier(); + // Try to append it to the last one + ret=iChained[0]->SetChildGroup(windowId); + TEST(ret==KErrArgument); + if(ret!=KErrArgument) + { + _LIT(KLog,"Error: SetChildGroup with a GpWin belonging to the same queue succeeded, return value :%d"); + LOG_MESSAGE2(KLog,ret); + } + } + //Try to append any elements belonging to another chain to the last one of this chain + //All these trials should fail (otherwise a infinite loop will be set up) + //Except for the parent of the second chain. + for(TInt ii=0;iiIdentifier(); + // Try to append it to the last one + ret=iChained[0]->SetChildGroup(windowId); + if(ii != ENumChained-1) + { + TEST(ret==KErrArgument); + if(ret!=KErrArgument) + { + _LIT(KLog,"Error: SetChildGroup with a GpWin which already has a parent succeeded, return value :%d"); + LOG_MESSAGE2(KLog,ret); + } + iChained[0]->ClearChildGroup(); + } + else + { + TEST(ret==KErrNone); + if(ret!=KErrNone) + { + _LIT(KLog,"Error: SetChildGroup with a GpWin with no parent failed, return value :%d"); + LOG_MESSAGE2(KLog,ret); + } + } + } + TInt windowId = iChained2[ENumChained-1]->Identifier(); + ret=iChained[ENumChained-1]->SetChildGroup(windowId); + TEST(ret==KErrArgument); + if(ret!=KErrArgument) + { + _LIT(KLog,"Error: SetChildGroup successful on a GpWin which already has a child, return value :%d"); + LOG_MESSAGE2(KLog,ret); + } + //Now take a window group not belonging to any queue + //just take the parent's chain and pop it + //and try to append it to itself + ret=iChained[ENumChained-1]->ClearChildGroup(); + TEST(ret==KErrNone); + ret=iChained[ENumChained-1]->SetChildGroup(iChained[ENumChained-1]->Identifier()); + TEST(ret==KErrArgument); + if(ret!=KErrArgument) + { + _LIT(KLog,"Error: Setting GpWin as a child of itself succeeded, return value :%d"); + LOG_MESSAGE2(KLog,ret); + } + CleanupStack::PopAndDestroy(ENumChained+ENumChained,iChained[ENumChained-1]); + } +void CTGwHandle::RunTestCaseL(TInt /*aCurTestCase*/) + { + _LIT(KTest0,"Window group names"); + _LIT(KTest1,"Window group identifiers"); + _LIT(KTest2,"Owner to foreground"); + _LIT(KTest3,"FindWindowGroupIdentifier test"); + _LIT(KTest4,"IdentifierWrapAround test"); + _LIT(KTest5,"DefaultOwningWindow test"); + _LIT(KTest6,"DefaultOwningWindow2 test"); + _LIT(KTest7,"Window Group Chaining"); + _LIT(KTest8,"Window Group Chaining2"); + _LIT(KTest9,"Unchaining window group"); + _LIT(KTest10,"Ordinal Postion Test"); + _LIT(KTest11,"CrashTest on closing client"); + _LIT(KTest12,"Setting and Clearing Child Groups"); + _LIT(KTest13,"No Infinite Loops in Setting Child Groups"); + ((CTGwHandleStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); + switch(++iTest->iState) + { +/** + + @SYMTestCaseID GRAPHICS-WSERV-0316 + + @SYMDEF DEF081259 + + @SYMTestCaseDesc Test setting window group names + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions Set the name of a window group to different values and check the + value is set correctly + + @SYMTestExpectedResults The window group name is set correctly + +*/ + case 1: + ((CTGwHandleStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0316")); + //iState=9; break; + iTest->LogSubTest(KTest0); + GwNamesL(); + break; +/** + + @SYMTestCaseID GRAPHICS-WSERV-0317 + + @SYMDEF DEF081259 + + @SYMTestCaseDesc Test setting window group identifiers + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions Set the identifiers of a window groups. manipulate the window groups and + check the identifiers remain correct + + @SYMTestExpectedResults The identifiers are correct for each window group after + manipulation + +*/ + case 2: + ((CTGwHandleStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0317")); + iTest->LogSubTest(KTest1); + GwIdentifierTestL(); + break; +/** + + @SYMTestCaseID GRAPHICS-WSERV-0318 + + @SYMDEF DEF081259 + + @SYMTestCaseDesc Test moving different window groups to the foreground and bringing + back the backgorund + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions Create some window groups and move them in turn to the foreground before + restoring the background + + @SYMTestExpectedResults Window groups move to and from the foreground with error + +*/ + case 3: + ((CTGwHandleStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0318")); + iTest->LogSubTest(KTest2); + OwnerToForegroundL(); + break; +/** + + @SYMTestCaseID GRAPHICS-WSERV-0319 + + @SYMDEF DEF081259 + + @SYMTestCaseDesc Test returning different window groups identifiers by searching + on the name + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions Create some window groups and return their identifiers by searching on + their names + + @SYMTestExpectedResults The correct identifiers are returned for each name + +*/ + case 4: + ((CTGwHandleStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0319")); + iTest->LogSubTest(KTest3); + FindWindowGroupIdentifierTestL(); + break; +/** + + @SYMTestCaseID GRAPHICS-WSERV-0320 + + @SYMDEF DEF081259 + + @SYMTestCaseDesc Test that a windows group identifier is not used twice + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions Assign a window group identifier to one window group and check + the same identifier can not be used for a second group + + @SYMTestExpectedResults Window group identifier can not be reused + +*/ + case 5: + ((CTGwHandleStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0320")); + iTest->LogSubTest(KTest4); + IdentifierWrapAroundTestL(); + break; +/** + + @SYMTestCaseID GRAPHICS-WSERV-0321 + + @SYMDEF DEF081259 + + @SYMTestCaseDesc Test that the default owning window for window groups is set + correctly + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions Set different default owning windows for different window groups. + Check the windows have been set correctly. + + @SYMTestExpectedResults The default owning windows for the groups are set correctly + +*/ + case 6: + ((CTGwHandleStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0321")); + iTest->LogSubTest(KTest5); + DefaultOwningWindowL(); + break; +/** + + @SYMTestCaseID GRAPHICS-WSERV-0322 + + @SYMDEF DEF081259 + + @SYMTestCaseDesc Test that the default owning window for window groups is set + correctly + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions Set different default owning windows for different window groups. + Check the windows have been set correctly. + + @SYMTestExpectedResults The default owning windows for the groups are set correctly + +*/ + case 7: + ((CTGwHandleStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0322")); + iTest->LogSubTest(KTest6); + DefaultOwningWindow2L(); + TheClient->iGroup->WinTreeNode()->SetOrdinalPosition(0); + break; +/** + + @SYMTestCaseID GRAPHICS-WSERV-0323 + + @SYMDEF DEF081259 + + @SYMTestCaseDesc Test that window groups can be chained correctly + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions Create a chain of window groups and check that the chain of groups + can be manipluated correctly + + @SYMTestExpectedResults The chain can be manipulated correctly + +*/ + case 8: + ((CTGwHandleStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0323")); + iTest->LogSubTest(KTest7); + WindowGroupChaining(); + break; +/** + + @SYMTestCaseID GRAPHICS-WSERV-0324 + + @SYMDEF DEF081259 + + @SYMTestCaseDesc Test that window groups can be chained correctly + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions Create a chain of window groups and check that the chain of groups + can be manipluated correctly + + @SYMTestExpectedResults The chain can be manipulated correctly + +*/ + case 9: + ((CTGwHandleStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0324")); + iTest->LogSubTest(KTest8); + WindowGroupChaining2(); + break; +/** + + @SYMTestCaseID GRAPHICS-WSERV-0325 + + @SYMDEF DEF081259 + + @SYMTestCaseDesc Test that window groups can be unchained correctly + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions Create chains of window groups and check that the window groups can be + unchained correctly + + @SYMTestExpectedResults The chain can be unchained correctly + +*/ + case 10: + ((CTGwHandleStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0325")); + iTest->LogSubTest(KTest9); + UnchainWindowGroupsL(); + break; +/** + + @SYMTestCaseID GRAPHICS-WSERV-0326 + + @SYMDEF DEF081259 + + @SYMTestCaseDesc Test the ordinal position of chained window groups + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions Create chains of window groups and check their ordinal position is correct + for different scenarios + + @SYMTestExpectedResults Ordinal position of chained window group is correct + +*/ + case 11: + ((CTGwHandleStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0326")); + iTest->LogSubTest(KTest10); + TestOrdinalPositionL(); + break; + case 12: + ((CTGwHandleStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0326")); + iTest->LogSubTest(KTest10); + TestOrdinalPositionNoDebugL(); + break; +/** + + @SYMTestCaseID GRAPHICS-WSERV-0327 + + @SYMDEF DEF081259 + + @SYMTestCaseDesc Test that window groups are dealt with correctly if their client is closed + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions Create window groups and then close there client. + + @SYMTestExpectedResults The window groups of the closed client are handled without error + +*/ + case 13: + ((CTGwHandleStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0327")); + iTest->LogSubTest(KTest11); + TestclosingclientL(); + break; + case 14: + ((CTGwHandleStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0327")); + iTest->LogSubTest(KTest12); + TestClearingAndSettingChildGroupsL(); + break; + case 15: + ((CTGwHandleStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0327")); + iTest->LogSubTest(KTest13); + TestAgainstLoopsWhenAddingChildGroupsL(); + break; + default: + ((CTGwHandleStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + ((CTGwHandleStep*)iStep)->CloseTMSGraphicsStep(); + TestComplete(); + break; + } + ((CTGwHandleStep*)iStep)->RecordTestResultL(); + } + +__WS_CONSTRUCT_STEP__(GwHandle) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TGWHANDLE.H --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TGWHANDLE.H Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,94 @@ + +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef __TGWHANDLE_H__ +#define __TGWHANDLE_H__ + +#include +#include +#include "../tlib/testbase.h" +#include "AUTO.H" +#include "TGraphicsHarness.h" + +class CTGwHandle : public CTWsGraphicsBase + { +public: + CTGwHandle(CTestStep* aStep); + ~CTGwHandle(); + void ConstructL(); + TInt NumberOfWndGroupsWithZeroPriority(TInt aScreenNumber); + void GetGwListL(CArrayFixFlat *aWindowHandles); + void GetGwListL(CArrayFixFlat *aWindowHandles, TInt aScreenNumber); + void GetGwListL(TInt aPriority, CArrayFixFlat *aWindowHandles); + void GetGwListL(RArray* aWindowHandles); + void GetGwListL(TInt aPriority, RArray* aWindowHandles); + void GwNamesL(); + void GwIdentifierTestL(); + void OwnerToForegroundL(); + void FindWindowGroupIdentifierTestL(); + void IdentifierWrapAroundTestL(); + void DefaultOwningWindowL(); + void DefaultOwningWindow2L(); + void WindowGroupChaining(); + void WindowGroupChaining2(); + void UnchainWindowGroupsL(); + void TestclosingclientL(); + void TestClearingAndSettingChildGroupsL(); +protected: +//from CTGraphicsStep + virtual void RunTestCaseL(TInt aCurTestCase); +private: + enum {ENumGroups=10,ENumChained=5}; +private: + RWindowGroup* CreateWindowGroupLC(RWsSession& aWs,TUint32 aClientHandle,TInt aParentId=0); + void CreateGroupWindowsLC(RWsSession& aWs); + void CreateChainedGroupWindowsLC(RWsSession& aWs,TBool aSecondChain = EFalse); + void TestAgainstLoopsWhenAddingChildGroupsL(); + void MoveGroups(RWindowGroup** aGroups,TInt aGp,TInt aNum,TInt aPos,TInt aInc=2); + void TestGroups(TInt aPos); + void TestGroupsBefore(TInt aPos); + void TestOrdinalPositionL(); + void TestOrdinalPositionNoDebugL(); + void TestOrdinalPos(TInt awndPos); + void TestOrdinalPosNoDebug(TInt awndPos); + TInt ChainedWindowCount(RArray*); +private: + TFullName iFullName; + TSize iWinSize; + RWindowGroup* iGroups[ENumGroups]; + RWindowGroup* iChained[ENumChained]; + RWindowGroup* iChained2[ENumChained]; + }; + +class CTGwHandleStep : public CTGraphicsStep + { +public: + CTGwHandleStep(); +protected: + //from CTGraphicsStep + virtual CTGraphicsBase* CreateTestL(); + }; + +_LIT(KTGwHandleStep,"TGwHandle"); + + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/THeartBeat.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/THeartBeat.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,659 @@ +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Test the Wserv heart beat switch on and off +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include "THeartBeat.h" +#include + +CTHeartBeatTest::CTHeartBeatTest(CTestStep* aStep) : + CTWsGraphicsBase(aStep) + { + } + +CTHeartBeatTest::~CTHeartBeatTest() + { + iAnimDll.Close(); + delete iHbTestWin; + } + +void CTHeartBeatTest::ConstructL() + { + TSize screenSize=TheClient->iGroup->Size(); + TInt winWidth=(screenSize.iWidth/3)-10; + TInt winHeight=screenSize.iHeight-10; + iHbTestWin=new(ELeave) CAnimWindow(EFalse, CAnimWindow::ERedraw); + iHbTestWin->ConstructL(TPoint(screenSize.iWidth/3*2+5,5),TSize(winWidth,winHeight)); + iAnimDll=RAnimDll(TheClient->iWs); + User::LeaveIfError(iAnimDll.Load(KAnimDLLName)); + } + +void CTHeartBeatTest::SetCursor(const TPoint& aPos,const TSize& aSize, TUint aFlags/*=0*/) + { // Default aFlags=0 gives a flashing cursor + TTextCursor tc; + tc.iType=TTextCursor::ETypeRectangle; + tc.iHeight=aSize.iHeight; + tc.iAscent=aSize.iHeight*4/5; + tc.iWidth=aSize.iWidth; + tc.iFlags=aFlags; + tc.iColor=KRgbGreen; + TheClient->iGroup->GroupWin()->SetTextCursor(*iHbTestWin->BaseWin(),TPoint(aPos.iX,aPos.iY+tc.iAscent),tc); + } + +TBool CTHeartBeatTest::SetAutoHeartBeatPauseState(TBool aState) const + { + return(TheClient->iWs.DebugInfo(EWsDebugSetAutoHeartBeatPauseState,aState)); + } + +TBool CTHeartBeatTest::GetHeartBeatTimerState() const + { + return(TheClient->iWs.DebugInfo(EWsDebugHeartBeatState)); + } + +void CTHeartBeatTest::CancelTextCursor() + { + TheClient->iGroup->GroupWin()->CancelTextCursor(); + } + +void CTHeartBeatTest::TestTextCursorTimerL() + { + TEST(!GetHeartBeatTimerState()); + SetCursor(TPoint(0,0),TSize(10,10)); + TEST(GetHeartBeatTimerState()); + CancelTextCursor(); + TEST(!GetHeartBeatTimerState()); +// + TPoint testCursorPos; + TSize testCursorSize(10,10); + SetCursor(testCursorPos,testCursorSize); + TEST(GetHeartBeatTimerState()); + iHbTestWin->BaseWin()->SetVisible(EFalse); + TEST(!GetHeartBeatTimerState()); + iHbTestWin->BaseWin()->SetVisible(ETrue); + TEST(GetHeartBeatTimerState()); +// +// Cover the cursor and check heartbeat disabled + RWindow coverCursor(TheClient->iWs); + CleanupClosePushL(coverCursor); + User::LeaveIfError(coverCursor.Construct(*iHbTestWin->BaseWin(), 0xBADBAD)); + coverCursor.SetExtent(testCursorPos,testCursorSize); + coverCursor.Activate(); + TEST(!GetHeartBeatTimerState()); +// Now fractionally expose the cursor and check heartbeat re-enabled + coverCursor.SetExtent(testCursorPos+TPoint(1,1),testCursorSize); + TEST(GetHeartBeatTimerState()); +// Re-cover it + coverCursor.SetExtent(testCursorPos,testCursorSize); + TEST(!GetHeartBeatTimerState()); +// Enlarge cursor to expose itself then check heartbeat + SetCursor(testCursorPos,TSize(testCursorSize.iWidth+1,testCursorSize.iHeight)); + TEST(GetHeartBeatTimerState()); +// Shrink cursor then check heartbeat + SetCursor(testCursorPos,testCursorSize); + TEST(!GetHeartBeatTimerState()); +// Turn off auto heart beat pausing, should turn timer back on + SetAutoHeartBeatPauseState(EFalse); + TEST(GetHeartBeatTimerState()); +// With auto pausing enabled covering/uncovering the cursor should have no effect, +// timer will always be on + coverCursor.SetVisible(EFalse); + TEST(GetHeartBeatTimerState()); + coverCursor.SetVisible(ETrue); + TEST(GetHeartBeatTimerState()); +// Re-enable auto-pause should turn timer back off + SetAutoHeartBeatPauseState(ETrue); + TEST(!GetHeartBeatTimerState()); +// Destroy covering window and check heartbeat re-enabled + CleanupStack::PopAndDestroy(&coverCursor); + TEST(GetHeartBeatTimerState()); +// Check using no flash flag turns timer off + SetCursor(testCursorPos,testCursorSize,TTextCursor::EFlagNoFlash); + TEST(!GetHeartBeatTimerState()); +// and turning no flash flag off turns timer back on + SetCursor(testCursorPos,testCursorSize); + TEST(GetHeartBeatTimerState()); +// Preparing for switch off should disable the heartbeat until another event is received + TheClient->iWs.PrepareForSwitchOff(); + TEST(!GetHeartBeatTimerState()); +// Any event should wake the hearbeat back up again + TRawEvent rawEvent; + rawEvent.Set(TRawEvent::EPointerMove,0,0); + TheClient->iWs.SimulateRawEvent(rawEvent); + TEST(GetHeartBeatTimerState()); +// + CancelTextCursor(); + TEST(!GetHeartBeatTimerState()); +// Check heartbeat still off as expected + TheClient->iWs.PrepareForSwitchOff(); + TEST(!GetHeartBeatTimerState()); +// Check when hearbeat not required that it's not turned back when coming out of PrepareForSwitchOff() mode. + TheClient->iWs.SimulateRawEvent(rawEvent); + TheClient->Flush(); + TEST(!GetHeartBeatTimerState()); + } + +void CTHeartBeatTest::doTestActiveInactiveEvents(TBool aCursorOn, TBool aAutoPauseOn) + { + SetAutoHeartBeatPauseState(aAutoPauseOn); + if (aCursorOn) + SetCursor(TPoint(0,0),TSize(10,10)); +// Should disable timer, regardless of other states + TRawEvent event; + event.Set(TRawEvent::EInactive); + UserSvr::AddEvent(event); + TEST(!GetHeartBeatTimerState()); +// ...and switch it back on + event.Set(TRawEvent::EActive); + UserSvr::AddEvent(event); + TBool testResult1=EFalse; + if (aAutoPauseOn) + testResult1=aCursorOn; // Only on if cursor is on without auto pause enabled + else + testResult1=ETrue; // Always on if auto pause disabled + TBool hbState=GetHeartBeatTimerState(); + if ((!hbState)!=(!testResult1)) + { + _LIT(KLog,"Fail in TestActiveInactiveEvents(%d.%d) HBState=%d result=%d"); + LOG_MESSAGE5(KLog,aCursorOn,aAutoPauseOn,hbState,testResult1); + } + TEST((!GetHeartBeatTimerState())==(!testResult1)); //Works with any positive value for True +// + if (aCursorOn) + CancelTextCursor(); + } + +void CTHeartBeatTest::TestActiveInactiveEvents() + { + doTestActiveInactiveEvents(EFalse,EFalse); + doTestActiveInactiveEvents(ETrue,EFalse); + doTestActiveInactiveEvents(EFalse,ETrue); + doTestActiveInactiveEvents(ETrue,ETrue); + } + +void CTHeartBeatTest::FailCursorHbTest(const TDesC& aErrorBase, const TDesC* aExtraText, TBool aHbState, TBool aHbCheckState) + { + TBuf<256> error(aErrorBase); + if (aExtraText) + { + error.Append(*aExtraText); + } + _LIT(KHbErrorAppendFmt," HB=%d (Testing for %d)"); + error.AppendFormat(KHbErrorAppendFmt,aHbState,aHbCheckState); + LOG_MESSAGE(error); + TEST(EFalse); + } + +TBool CTHeartBeatTest::ChangeTransAndCheckHeartBeat(TInt aTestMode, RWindow& aTransWin, const TRect& aGraphicRect, TInt aExtraWinTestMode, const TDesC* aErrorMsg, TBool aSetVisibleAfterTransUpdate) + { + TRect cursorRect(aGraphicRect); + cursorRect.Move(iHbTestWin->BaseWin()->InquireOffset(aTransWin)); + TRect winRect(aTransWin.Size()); + __ASSERT_ALWAYS(winRect.Contains(cursorRect.iTl) && winRect.Contains(cursorRect.iBr),AutoPanic(EAutoPanicHeartBeatCursorRect)); +// + TRegionFix<8> transRegion; + TBool heartBeatCheck=EFalse; + switch(aTestMode) + { + case ECursorTransWinTestModeFullTrans: + transRegion.AddRect(winRect); + heartBeatCheck=ETrue; + break; + case ECursorTransWinTestNoTrans: + break; + case ECursorTransWinTestPartialTransCoveringCursor: + transRegion.AddRect(winRect); + transRegion.SubRect(cursorRect); + break; + case ECursorTransWinTestPartialTransExposingCursor: + transRegion.AddRect(cursorRect); + heartBeatCheck=ETrue; + break; + default: + ASSERT(EFalse); + } + TBool invisHeartBeatCheck=ETrue; + switch(aExtraWinTestMode) + { + case ECursorTransWinTestNoTrans: + case ECursorTransWinTestPartialTransCoveringCursor: + heartBeatCheck=EFalse; + invisHeartBeatCheck=EFalse; + break; + default: + break; + } +// + ASSERT(!transRegion.CheckError()); + if (aSetVisibleAfterTransUpdate) + aTransWin.SetVisible(EFalse); + aTransWin.SetTransparentRegion(transRegion); + if (aSetVisibleAfterTransUpdate) + aTransWin.SetVisible(ETrue); +// + TBool testSuccess=ETrue; + TBool heartBeatState=GetHeartBeatTimerState(); + TBool failed1stTest=EFalse; + if ((!heartBeatState)!=(!heartBeatCheck)) //Works with any positive value for True + { + failed1stTest=ETrue; + _LIT(KFailedHbTest,"Failed "); + FailCursorHbTest(KFailedHbTest,aErrorMsg,heartBeatState,heartBeatCheck); + testSuccess=EFalse; + } +// + aTransWin.SetVisible(EFalse); + heartBeatState=GetHeartBeatTimerState(); + _LIT(KGoingInvisAfterTestAppend," after %S"); + TBuf<256> errorExtra; + if (aErrorMsg) + { + errorExtra.Format(KGoingInvisAfterTestAppend,aErrorMsg); + } + if ((!heartBeatState)!=(!invisHeartBeatCheck)) //Works with any positive value for True + { + _LIT(KFailedGoingInvis,"Failed setting trans win invisible"); + FailCursorHbTest(KFailedGoingInvis,&errorExtra,heartBeatState,invisHeartBeatCheck); + testSuccess=EFalse; + } +// + aTransWin.SetVisible(ETrue); + heartBeatState=GetHeartBeatTimerState(); + if (!failed1stTest && (!heartBeatState)!=(!heartBeatCheck)) //Works with any positive value for True + { + _LIT(KFailedResettingVis,"Failed re-setting trans win visible"); + FailCursorHbTest(KFailedResettingVis,&errorExtra,heartBeatState,heartBeatCheck); + testSuccess=EFalse; + } + return(testSuccess); + } + +void CTHeartBeatTest::LoopThroughTransWinTestModes(RWindow& aTransWin, const TRect& aGraphicRect, TInt aExtraWinTestMode) + { + TBuf<256> error; + for(TInt setVisMode=0;setVisMode<2;setVisMode++) + { + if (setVisMode==0) + continue; // zzz setinvis/makevis needed to flush out changes it seems + const TBool setVisibleAfterTransUpdate=setVisMode>0; + for(TInt startTestMode=0;startTestModeiWs); + User::LeaveIfError(transWin1.Construct(*TheClient->iGroup->GroupWin(),0xDEADBAD1)); + CleanupClosePushL(transWin1); + if (transWin1.SetTransparencyFactor(TRgb::Gray256(128))!=KErrNone) + { // Transparency not enabled, skip tests + CleanupStack::PopAndDestroy(&transWin1); + return; + } + transWin1.Activate(); + TEST(GetHeartBeatTimerState()); +// First simply check activating default full screen transparent window doesn't disable the heartbeat + _LIT(KBasicTransCursorTests,"Running basic transparent window cursor heartbeat tests"); + LOG_MESSAGE(KBasicTransCursorTests); + LoopThroughTransWinTestModes(transWin1, aGraphicRect, ECursorTransWinTestNA); +// +// Lots of test code disabled due to bugs in handling of transparent window regions +// See DEF110677, hopefully when the issues in there are addressed the rest of the +// test code here can be enabled +// See sections marked with zzz for places where certain tests are disabled, once DEF110677 +// is marked as fixed these sections should be re-enabled and if problems still occur they +// need to be investigated. +// +// +// Now check more complex modes with two transparent windows over the test window + RWindow transWin2(TheClient->iWs); + User::LeaveIfError(transWin2.Construct(*TheClient->iGroup->GroupWin(),0xDEADBAD2)); + CleanupClosePushL(transWin2); + User::LeaveIfError(transWin2.SetTransparencyFactor(TRgb::Gray256(128))); + TSize screenSize=TheClient->iGroup->Size(); + screenSize.iWidth-=10; + transWin1.SetExtent(TPoint(0,0),screenSize); + transWin2.SetExtent(TPoint(10,0),screenSize); + transWin2.Activate(); + for(TInt win1OrdPos=0;win1OrdPos<2;win1OrdPos++) + { + transWin1.SetOrdinalPosition(win1OrdPos); + _LIT(KOrdinalTransCursorTests,"Running tests with transwin1 ordinal pos=%d"); + LOG_MESSAGE2(KOrdinalTransCursorTests,win1OrdPos); + for(TInt topWinTestMode=0;topWinTestMode msg; + msg.Format(KTopTransWinCursorTest,topWinTestMode); + LOG_MESSAGE(msg); + ChangeTransAndCheckHeartBeat(0, transWin2, aGraphicRect, topWinTestMode, NULL, ETrue); + LoopThroughTransWinTestModes(transWin1, aGraphicRect, topWinTestMode); + } + } + ChangeTransAndCheckHeartBeat(0, transWin2, aGraphicRect, 0, NULL, ETrue); + CleanupStack::PopAndDestroy(&transWin2); + TEST(GetHeartBeatTimerState()); +// + CleanupStack::PopAndDestroy(&transWin1); + TEST(GetHeartBeatTimerState()); + } + +void CTHeartBeatTest::TestTextCursorTimerTransL() + { + TSize testWinSize(iHbTestWin->BaseWin()->Size()); + TRect cursorRect(testWinSize.iWidth/4,testWinSize.iHeight/3,testWinSize.iWidth*3/4,testWinSize.iHeight*2/3); + TEST(!GetHeartBeatTimerState()); + SetCursor(cursorRect.iTl,cursorRect.Size()); + TEST(GetHeartBeatTimerState()); + RunTransWinTestsL(cursorRect); + CancelTextCursor(); + TEST(!GetHeartBeatTimerState()); + } + +void CTHeartBeatTest::TestHeartBeatStopStart(TBool aHeartbeatStateOff,TBool aHeartbeatStateOn,const TDesC& aOffText,const TDesC& aOnText) + { + TEST(!aHeartbeatStateOff); + if (aHeartbeatStateOff) + LOG_MESSAGE2(_L("%S failed to disable heartbeat timer"),&aOffText); + TEST(aHeartbeatStateOn); + if (!aHeartbeatStateOn) + LOG_MESSAGE2(_L("%S failed to re-enable heartbeat timer"),&aOnText); + } + +void CTHeartBeatTest::TestAnimDllL(TBool aSpriteMode, TUint aSpriteFlags) + { + RTestAnim anim(iAnimDll); + TEST(!GetHeartBeatTimerState()); + TSize testWinSize(iHbTestWin->BaseWin()->Size()); + TRect animRect(1,1,testWinSize.iWidth/3,testWinSize.iWidth/5); + TPckgC rectPckg(animRect); + RWsSprite sprite(TheClient->iWs); + CleanupClosePushL(sprite); + if (aSpriteMode) + { + sprite.Construct(*iHbTestWin->BaseWin(),TPoint(),aSpriteFlags); + CFbsBitmap* bitmap1=new(ELeave) CFbsBitmap(); + CleanupStack::PushL(bitmap1); + CFbsBitmap* bitmap2=new(ELeave) CFbsBitmap(); + CleanupStack::PushL(bitmap2); + CFbsBitmap* bitmap3=new(ELeave) CFbsBitmap(); + CleanupStack::PushL(bitmap3); + TSize animSize(animRect.Size()); + User::LeaveIfError(bitmap1->Create(TSize(animSize.iWidth/2,animSize.iHeight/2),EGray4)); + User::LeaveIfError(bitmap2->Create(TSize(animSize.iWidth,animSize.iHeight/3),EGray4)); + User::LeaveIfError(bitmap3->Create(TSize(animSize.iWidth/3,animSize.iHeight),EGray4)); +// + TSpriteMember member1; + member1.iMaskBitmap=NULL; + member1.iInvertMask=EFalse; + member1.iDrawMode=CGraphicsContext::EDrawModePEN; + member1.iOffset=TPoint(); + member1.iInterval=TTimeIntervalMicroSeconds32(1); + member1.iBitmap=bitmap1; + member1.iMaskBitmap=bitmap1; + sprite.AppendMember(member1); +// + TSpriteMember member2; + member2.iInvertMask=EFalse; + member2.iDrawMode=CGraphicsContext::EDrawModeXOR; + member2.iOffset=TPoint(1,2); + member2.iInterval=TTimeIntervalMicroSeconds32(2); + member2.iBitmap=bitmap2; + member2.iMaskBitmap=bitmap2; + sprite.AppendMember(member2); +// + TSpriteMember member3; + member3.iInvertMask=ETrue; + member3.iDrawMode=CGraphicsContext::EDrawModeOR; + member3.iOffset=TPoint(3,4); + member3.iInterval=TTimeIntervalMicroSeconds32(3); + member3.iBitmap=bitmap3; + member3.iMaskBitmap=bitmap3; + sprite.AppendMember(member3); +// + User::LeaveIfError(anim.Construct(sprite,EAnimTypeSprite,rectPckg)); + CleanupStack::PopAndDestroy(3,bitmap1); + } + else + { + User::LeaveIfError(anim.Construct(*iHbTestWin->BaseWin(),EAnimTypeTest3,rectPckg)); + } + CleanupClosePushL(anim); + TEST(GetHeartBeatTimerState()); + + // Cover up the window with the animation and check this disables the heartbeat timer. + RBlankWindow blankwin1(TheClient->iWs); + User::LeaveIfError(blankwin1.Construct(*TheClient->iGroup->GroupWin(),123)); + TPoint winOffset(iHbTestWin->BaseWin()->InquireOffset(*TheClient->iGroup->GroupWin())); + if (aSpriteMode) + blankwin1.SetExtent(winOffset,testWinSize); + else + blankwin1.SetExtent(winOffset+animRect.iTl,animRect.Size()); + blankwin1.Activate(); + TBool heartbeatStateOff=GetHeartBeatTimerState(); + TEST(!heartbeatStateOff); + if (heartbeatStateOff) + { + LOG_MESSAGE(_L("Covering window failed to disable heartbeat timer")); + } + TBool heartbeatStateOn; + if (!aSpriteMode) + { + // Resize the anim so it becomes visible, then shrink back down again + animRect.iBr.iX++; + anim.Command(EADllSetRect,rectPckg); + heartbeatStateOn=GetHeartBeatTimerState(); + animRect.iBr.iX--; + anim.Command(EADllSetRect,rectPckg); + heartbeatStateOff=GetHeartBeatTimerState(); + TestHeartBeatStopStart(heartbeatStateOff,heartbeatStateOn,_L("Shrinking anim"),_L("Growing anim")); + } +// + blankwin1.Close(); + heartbeatStateOn=GetHeartBeatTimerState(); + TEST(heartbeatStateOn); + if (!heartbeatStateOn) + { + LOG_MESSAGE(_L("Un-covering window failed to disable heartbeat timer")); + } + + // Put a transparent window over the animation and check the heartbeat timer is not disabled + RWindow transWin(TheClient->iWs); + User::LeaveIfError(transWin.Construct(*TheClient->iGroup->GroupWin(),123)); + if (transWin.SetTransparencyFactor(TRgb::Gray256(128))==KErrNone) + { + transWin.Activate(); + heartbeatStateOn=GetHeartBeatTimerState(); + TEST(heartbeatStateOn); + if (!heartbeatStateOn) + LOG_MESSAGE(_L("Transparent window caused heartbeat timer to be disabled")); + TRegionFix<1> emptyRegion; + transWin.SetTransparentRegion(emptyRegion); + heartbeatStateOff=GetHeartBeatTimerState(); + TRegionFix<1> fullRegion(transWin.Size()); + transWin.SetTransparentRegion(fullRegion); + heartbeatStateOn=GetHeartBeatTimerState(); + TestHeartBeatStopStart(heartbeatStateOff,heartbeatStateOn,_L("Making covering window opaque"),_L("Making covering window transparent")); + if (aSpriteMode) + { + RBlankWindow blankwin2(TheClient->iWs); + User::LeaveIfError(blankwin2.Construct(*iHbTestWin->BaseWin(),1234)); + blankwin2.Activate(); + heartbeatStateOn=GetHeartBeatTimerState(); + // With ESpriteNoChildClip the heartbeat should still be on as the sprite will still be visible + // Without it blankwin2 will cover up the sprite and cancel the heartbeat + TBool heartBeatCheck=aSpriteFlags&ESpriteNoChildClip; + TEST((!heartbeatStateOn)==(!heartBeatCheck)); //Works with any positive value for True + blankwin2.Close(); + } + transWin.SetTransparentRegion(emptyRegion); + heartbeatStateOff=GetHeartBeatTimerState(); + transWin.Close(); + heartbeatStateOn=GetHeartBeatTimerState(); + TestHeartBeatStopStart(heartbeatStateOff,heartbeatStateOn,_L("Making covering window opaque"),_L("Un-covering window")); + } + else + transWin.Close(); + + // Make the window with the animation invisible and check this disables the heartbeat timer. + iHbTestWin->BaseWin()->SetVisible(EFalse); + heartbeatStateOff=GetHeartBeatTimerState(); + iHbTestWin->BaseWin()->SetVisible(ETrue); + heartbeatStateOn=GetHeartBeatTimerState(); + TestHeartBeatStopStart(heartbeatStateOff,heartbeatStateOn,_L("Making window invisible"),_L("Making window visible")); + + // Move the window with the animation off screen and check this disables the heartbeat timer. + TSize screenSize=TheClient->iGroup->Size(); + TPoint oldPos(iHbTestWin->BaseWin()->Position()); + iHbTestWin->BaseWin()->SetPosition(screenSize.AsPoint()); + heartbeatStateOff=GetHeartBeatTimerState(); + iHbTestWin->BaseWin()->SetPosition(oldPos); + heartbeatStateOn=GetHeartBeatTimerState(); + TestHeartBeatStopStart(heartbeatStateOff,heartbeatStateOn,_L("Moving window offscreen"),_L("Moving window back onscreen")); + TEST(GetHeartBeatTimerState()); + CleanupStack::PopAndDestroy(&anim); + TEST(!GetHeartBeatTimerState()); + CleanupStack::PopAndDestroy(&sprite); + } + +void CTHeartBeatTest::TestAnimDllTransL() + { + RTestAnim anim(iAnimDll); + TSize testWinSize(iHbTestWin->BaseWin()->Size()); + TRect animRect(testWinSize.iWidth/4,testWinSize.iHeight/3,testWinSize.iWidth*3/4,testWinSize.iHeight*2/3); + TPckgBuf rectPckg; + rectPckg()=animRect; + TEST(!GetHeartBeatTimerState()); + User::LeaveIfError(anim.Construct(*iHbTestWin->BaseWin(),EAnimTypeTest3,rectPckg)); + CleanupClosePushL(anim); + TEST(GetHeartBeatTimerState()); +// + RunTransWinTestsL(animRect); +// + CleanupStack::PopAndDestroy(&anim); + TEST(!GetHeartBeatTimerState()); + } + +void CTHeartBeatTest::RunTestCaseL(TInt /*aCurTestCase*/) + { + + switch(++iTest->iState) + { + case 1: +/** +@SYMTestCaseID GRAPHICS-WSERV-0568 +*/ + ((CTHeartBeatTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0568")); + _LIT(KTestTextCursorTimer,"Basic heartbeat timer test"); + iTest->LogSubTest(KTestTextCursorTimer); + TestTextCursorTimerL(); + break; + case 2: +/** +@SYMTestCaseID GRAPHICS-WSERV-0569 +*/ + ((CTHeartBeatTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0569")); + _LIT(KTestTextCursorTimerTrans,"Heartbeat timer test with transparent windows"); + iTest->LogSubTest(KTestTextCursorTimerTrans); + TestTextCursorTimerTransL(); + break; + case 3: +/** +@SYMTestCaseID GRAPHICS-WSERV-0570 +*/ + ((CTHeartBeatTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0570")); + _LIT(KTestAnimDll1,"Anim DLL Heartbeat check (Win)"); + iTest->LogSubTest(KTestAnimDll1); + TestAnimDllL(EFalse,0); + break; + case 4: +/** +@SYMTestCaseID GRAPHICS-WSERV-0571 +*/ + ((CTHeartBeatTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0571")); + _LIT(KTestAnimDll2,"Anim DLL Heartbeat check (Sprite)"); + iTest->LogSubTest(KTestAnimDll2); + TestAnimDllL(ETrue,0); + TestAnimDllL(ETrue,ESpriteNoChildClip); + break; + case 5: +/** +@SYMTestCaseID GRAPHICS-WSERV-0572 +*/ + ((CTHeartBeatTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0572")); + _LIT(KTestAnimDllTrans,"Anim DLL Heartbeat check with transparent windows"); + iTest->LogSubTest(KTestAnimDllTrans); + TestAnimDllTransL(); + break; + case 6: +/** +@SYMTestCaseID GRAPHICS-WSERV-0573 +*/ + ((CTHeartBeatTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0573")); + _LIT(KTestActiveInactiveEvents,"Handling of TRawEvent::EInactive and EActive"); + iTest->LogSubTest(KTestActiveInactiveEvents); + TestActiveInactiveEvents(); + break; + default: + ((CTHeartBeatTestStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + ((CTHeartBeatTestStep*)iStep)->CloseTMSGraphicsStep(); + TestComplete(); + break; + } + ((CTHeartBeatTestStep*)iStep)->RecordTestResultL(); + } + +__WS_CONSTRUCT_STEP__(HeartBeatTest) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/THeartBeat.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/THeartBeat.h Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,82 @@ +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef __THEARTBEAT_H__ +#define __THEARTBEAT_H__ + +#include +#include +#include "AUTO.H" +#include "TAUTODLL.H" + +class CTHeartBeatTest : public CTWsGraphicsBase + { +public: + CTHeartBeatTest(CTestStep* aStep); + ~CTHeartBeatTest(); +protected: +//from MTestCases + void RunTestCaseL(TInt aCurTestCase); +private: + enum TCursorTransWinTestMode + { + ECursorTransWinTestNA=-1, + ECursorTransWinTestModeFullTrans, + ECursorTransWinTestNoTrans, + ECursorTransWinTestPartialTransExposingCursor, + ECursorTransWinTestPartialTransCoveringCursor, + ENumCursorTransWinTestModes, + }; +private: + void SetCursor(const TPoint& aPos,const TSize& aSize, TUint aFlags=0); + void CancelTextCursor(); + void ConstructL(); + void TestTextCursorTimerL(); + void TestTextCursorTimerTransL(); + void RunTransWinTestsL(const TRect& aGraphicRect); + void LoopThroughTransWinTestModes(RWindow& aTransWin, const TRect& aGraphicRect, TInt aExtraWinTestMode); + TBool ChangeTransAndCheckHeartBeat(TInt aTestMode, RWindow& aTransWin, const TRect& aGraphicRect, TInt aExtraWinTestMode, const TDesC* aErrorMsg, TBool aSetVisibleAfterTransUpdate); + void FailCursorHbTest(const TDesC& aErrorBase, const TDesC* aExtraText, TBool aHbState, TBool aHbCheckState); + void TestHeartBeatStopStart(TBool aHeartbeatStateOff,TBool aHeartbeatStateOn,const TDesC& aOffText,const TDesC& aOnText); + TBool GetHeartBeatTimerState() const; + TBool SetAutoHeartBeatPauseState(TBool aState) const; + void TestActiveInactiveEvents(); + void TestAnimDllL(TBool aSpriteMode, TUint aSpriteFlags); + void TestAnimDllTransL(); + void doTestActiveInactiveEvents(TBool aCursorOn, TBool aAutoPauseOn); + static TInt DoPanicTest(TInt aInt, TAny* aScreenNumber); +private: + RAnimDll iAnimDll; + CAnimWindow* iHbTestWin; + }; + +class CTHeartBeatTestStep : public CTGraphicsStep + { +public: + CTHeartBeatTestStep(); +protected: + //from CTGraphicsStep + CTGraphicsBase* CreateTestL(); + }; + +_LIT(KTHeartBeatTestStep,"THeartBeatTest"); + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TKEY.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TKEY.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,1119 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Testing key event, capturing keys and hot keys +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + + +#include "TKEY.H" + +#define LOGGING 1 //Uncomment this when there is a fail so that you get more logging + +GLDEF_D ClientToKill *SecondClient=NULL; + +GLDEF_C CTClient *CreateClientToKillL() + { + return(SecondClient=new(ELeave) ClientToKill()); + } + +GLDEF_C TInt ProcToKill(TAny *aScreenNumber) + { + TInt ret=KErrNone; + ret=TestLibStartUp(CreateClientToKillL,(TInt)aScreenNumber); + return(ret); + } + +CVisibleGroup::CVisibleGroup(TInt aScreenNo): iScreenNo(aScreenNo) + {} + +void CVisibleGroup::ConstructL() + { + User::LeaveIfError(iWs.Connect()); + iScr=new(ELeave) CWsScreenDevice(iWs); + User::LeaveIfError(iScr->Construct(iScreenNo)); + iScr->SetAppScreenMode(iMode); + iGroup=RWindowGroup(iWs); + User::LeaveIfError(iGroup.Construct(NULL,ETrue)); + TInt id=TheClient->iGroup->GroupWin()->Identifier(); + iGroup.SetOwningWindowGroup(id); +#if defined(LOGGING) + TLogMessageText buf; + _LIT(KIds,"Window Group Id: Main=%d, 2nd Client=%d"); + buf.Format(KIds,id,iGroup.Identifier()); + iWs.LogMessage(buf); +#endif + iWs.Flush(); + } + +CVisibleGroup::~CVisibleGroup() + { + iGroup.Close(); + delete iScr; + iWs.Close(); + } + +void CVisibleGroup::SetMode(TInt aMode) + { + iMode=aMode; + iScr->SetAppScreenMode(iMode); + iWs.Flush(); + } + +ClientToKill::ClientToKill() + {} + +void ClientToKill::ConstructL() + { + CTClient::ConstructL(); + RSemaphore sem; + sem.OpenGlobal(KSemaphoreName); + + iGroup=new(ELeave) TestWindowGroup(this); + iGroup->ConstructL(); + + iScreen->SetScreenMode(0); + TSize screenSize=iScreen->SizeInPixels(); + + TInt winWidth=3*screenSize.iWidth/4; + TInt winHeight=3*screenSize.iHeight/4; + iTestWin=new(ELeave) TestWindow(); + iTestWin->SetUpL(TPoint((screenSize.iWidth+4)/8,(screenSize.iHeight+4)/8),TSize(winWidth,winHeight),iGroup,*iGc); + +#if defined(LOGGING) + TLogMessageText buf; + _LIT(KId,"Window Group Id in 2nd Process=%d"); + buf.Format(KId,iGroup->GroupWin()->Identifier()); + LogMessage(buf); +#endif + sem.Signal(); // Signal thread fully initialised + sem.Close(); + } + +ClientToKill::~ClientToKill() + { + delete iTestWin; + } + + +// CTKey + +CTKey::CTKey(CTestStep* aStep) : CTWsGraphicsBase(aStep) + { + } + + + +void CTKey::ConstructL() + { + iSem.CreateGlobal(KSemaphoreName,0,KOwnerType); + iVisibleGroup=new(ELeave) CVisibleGroup(iTest->iScreenNumber); + iVisibleGroup->ConstructL(); + } + +CTKey::~CTKey() + { + delete iVisibleGroup; + iSem.Close(); + // Set focus back to this screen as it went to primary screen when iVisibleGroup was destroyed + // Wserv focus handling made focus screen switch to another screen if there is no + // focusable window group on that particular screen. + TheClient->iWs.SetFocusScreen(iTest->iScreenNumber); + } + +void CTKey::SendKey(TInt aScanCode) + { + TKeyEvent keyEvent; + keyEvent.iCode=aScanCode; + keyEvent.iScanCode=aScanCode; + keyEvent.iModifiers=0; + keyEvent.iRepeats=0; + TheClient->iWs.SimulateKeyEvent(keyEvent); + TheClient->iWs.Flush(); + } + +void CTKey::SendUpDown(TInt aScanCode) + { + TRawEvent rawEvent; + rawEvent.Set(TRawEvent::EKeyDown,aScanCode); + TheClient->iWs.SimulateRawEvent(rawEvent); + rawEvent.Set(TRawEvent::EKeyUp,aScanCode); + TheClient->iWs.SimulateRawEvent(rawEvent); + } + +void CTKey::SendCtrlAltShift(TRawEvent::TType aType) + { + TRawEvent rawEvent; + rawEvent.Set(aType,EStdKeyLeftFunc); + TheClient->iWs.SimulateRawEvent(rawEvent); + rawEvent.Set(aType,EStdKeyLeftCtrl); + TheClient->iWs.SimulateRawEvent(rawEvent); + rawEvent.Set(aType,EStdKeyLeftShift); + TheClient->iWs.SimulateRawEvent(rawEvent); + } + +void CTKey::SendCtrlAltShift(TInt aScanCode) + { + SendCtrlAltShift(TRawEvent::EKeyDown); + SendUpDown(aScanCode); + SendCtrlAltShift(TRawEvent::EKeyUp); + TheClient->iWs.Flush(); + } + +void CTKey::LogWindowGroupIds() + { + CArrayFixFlat* idList=new(ELeave) CArrayFixFlat(5); + if (!idList) + return; + TheClient->iWs.WindowGroupList(0,idList); + TLogMessageText buf; + _LIT(KWinGp,"Window Group Id's: %d"); + _LIT(KId,", %d"); + TInt ii=0; + buf.Format(KWinGp,(*idList)[ii]); + while (++iiCount()) + buf.AppendFormat(KId,(*idList)[ii]); + LOG_MESSAGE(buf); + delete idList; + } + +void CTKey::SetHotKey(THotKey aType, TUint aKeyCode) + { + TheClient->iWs.SetHotKey(aType,aKeyCode-'A'+1,EFuncCtrlShift,EFuncCtrlShift); + } + +void CTKey::KeyOfOrientation() + { + TInt numScreenModes = TheClient->iScreen->NumScreenModes(); + TInt originalScreenMode = TheClient->iScreen->CurrentScreenMode(); + if(numScreenModes >= 2) + { + //1 possible rotation of 180deg found in wsini.ini screenmode 8 + iVisibleGroup->SetMode(numScreenModes-1); + TheClient->iScreen->SetScreenMode(numScreenModes-1); + SendCtrlAltShift('O'); + TheClient->iWs.Flush(); + //1 possible rotation of 90deg found in wsini.ini screenmode 7 + iVisibleGroup->SetMode(numScreenModes-2); + TheClient->iScreen->SetScreenMode(numScreenModes-2); + SendCtrlAltShift('O'); + TheClient->iWs.Flush(); + //reset to original screenmode + iVisibleGroup->SetMode(originalScreenMode); + TheClient->iScreen->SetScreenMode(originalScreenMode); + } + else + { + TEST(numScreenModes>2); + INFO_PRINTF2(_L("numScreenModes - Expected: >2, Actual: %d"), numScreenModes); + } + TPixelsAndRotation originalSizeAndRotation; + TheClient->iScreen->GetScreenModeSizeAndRotation(TheClient->iScreen->CurrentScreenMode(),originalSizeAndRotation); + SendCtrlAltShift('O'); + TheClient->iWs.Flush(); + TPixelsAndRotation sizeAndRotation; + TheClient->iScreen->GetScreenModeSizeAndRotation(TheClient->iScreen->CurrentScreenMode(),sizeAndRotation); + TEST(sizeAndRotation.iRotation!=originalSizeAndRotation.iRotation); + if (sizeAndRotation.iRotation==originalSizeAndRotation.iRotation) + INFO_PRINTF3(_L("iRotation - Not Expected: %d, Actual: %d"), originalSizeAndRotation.iRotation, sizeAndRotation.iRotation); + SendCtrlAltShift('O'); + TheClient->iWs.Flush(); + } + +void CTKey::CycleDisplaySize() + { + // The test does nothing if there is only one possible screen mode -> return + TInt numScreenModes = TheClient->iScreen->NumScreenModes(); + if (numScreenModes<2) + { + TEST(numScreenModes>2); + INFO_PRINTF2(_L("numScreenModes - Expected: >2, Actual: %d"), numScreenModes); + return; + } + //Get original screen mode and size values + TInt originalScreenMode = TheClient->iScreen->CurrentScreenMode(); + TPixelsAndRotation sizeAndRotation; + TheClient->iScreen->GetScreenModeSizeAndRotation(TheClient->iScreen->CurrentScreenMode(),sizeAndRotation); + TSize originalScreenSize = sizeAndRotation.iPixelSize; + + SendCtrlAltShift('U'); + TheClient->iWs.Flush(); + TheClient->iScreen->GetScreenModeSizeAndRotation(TheClient->iScreen->CurrentScreenMode(),sizeAndRotation); + TEST(sizeAndRotation.iPixelSize.iHeight!=originalScreenSize.iHeight && sizeAndRotation.iPixelSize.iWidth!=originalScreenSize.iWidth); + if (sizeAndRotation.iPixelSize.iHeight==originalScreenSize.iHeight || sizeAndRotation.iPixelSize.iWidth==originalScreenSize.iWidth) + INFO_PRINTF5(_L("iPixelSize - Expected: !%d !%d, Actual: %d %d"), originalScreenSize.iHeight, originalScreenSize.iWidth, sizeAndRotation.iPixelSize.iHeight, sizeAndRotation.iPixelSize.iWidth); + TheClient->iScreen->SetScreenMode(originalScreenMode); + TheClient->iWs.Flush(); + } + +void CTKey::KeyOfDeathL() + { + //Key of Death +#if defined(LOGGING) + TLogMessageText buf; + _LIT(KNum1,"Priority Zero Window Groups=%d Total=%d (Before Process Creation)"); + buf.Format(KNum1,TheClient->iWs.NumWindowGroups(0),TheClient->iWs.NumWindowGroups()); + LOG_MESSAGE(buf); + LogWindowGroupIds(); +#endif + CProcess* process = CProcess::NewL(CProcess::eProcessKeyTest,iTest->iScreenNumber); + RWindowGroup group(TheClient->iWs); + group.Construct(1234); + TheClient->Flush(); //Make sure the window group above is created before the one in the other process + TInt id=TheClient->iGroup->GroupWin()->Identifier(); + group.SetOwningWindowGroup(id); + group.DefaultOwningWindow(); + + iSem.Wait(); + User::After(TTimeIntervalMicroSeconds32(100000)); //0.1 secs + TInt numGroups=TheClient->iWs.NumWindowGroups(); + TInt numGroups0=TheClient->iWs.NumWindowGroups(0); + +#if defined(LOGGING) + _LIT(KNum2,"NewWinGpId=%d Priority Zero Window Groups=%d Total=%d (After Process Creation)"); + buf.Format(KNum2,id,numGroups0,numGroups); + LOG_MESSAGE(buf); + _LIT(KLog1,"Sending Key Of Death"); + buf.Copy(KLog1); + LOG_MESSAGE(buf); + LogWindowGroupIds(); +#endif + group.SetOrdinalPosition(1); //Make sure that the window group we have just created is behind the one created by the other process (belt and braces) + SendCtrlAltShift('K'); + TheClient->iWs.Flush(); +#if defined(LOGGING) + _LIT(KLog2,"Sent Key Of Death"); + buf.Copy(KLog2); + LOG_MESSAGE(buf); +#endif + TInt numGroups2; + TInt numGroups0b; + TInt tries=3; + FOREVER //On multi-core platforms need to wait for the Key of Death procedure to complete + { + numGroups2=TheClient->iWs.NumWindowGroups(); + numGroups0b=TheClient->iWs.NumWindowGroups(0); + if (--tries==0) + break; + if (numGroups!=numGroups2 || numGroups0!=numGroups0b) + { + tries=1; + continue; + } + User::After(100000); //0.1secs + } + TEST(numGroups==numGroups2+1); + _LIT(KLog,"KeyOfDeath Num WinGps Before=%d After=%d (should be one less)"); + if (numGroups!=numGroups2+1) + LOG_MESSAGE3(KLog,numGroups,numGroups2); + TEST(numGroups0==numGroups0b+1); + if (numGroups0!=numGroups0b+1) + LOG_MESSAGE3(KLog,numGroups0,numGroups0b); + group.Close(); + + TBool processDead=!process->StillAlive(); + TEST(processDead); + if (!processDead) + { + _LIT(KLog,"Other Thread Still Alive"); + LOG_MESSAGE(KLog); + } + delete process; + +#if defined(LOGGING) + _LIT(KLog3,"Finished KeyOfDeath Test"); + buf.Copy(KLog3); + LOG_MESSAGE(buf); + LogWindowGroupIds(); +#endif + } + +#define CONTRAST_UP 'A' //'a'-'a'+1 +#define CONTRAST_DOWN 'B' //'b'-'a'+1 + +void CTKey::TestContrastL(TBool aChange) + { + TInt contrast=0; + TInt newContrast=0; + TInt maxContrast=0; + User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayContrastMax,maxContrast)); + TInt diff=aChange ? 1:0; + User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayContrast,contrast)); + + SendCtrlAltShift(CONTRAST_UP); + User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayContrast,newContrast)); + if ((contrast==maxContrast) && aChange) + { + TEST(newContrast==0); + if (newContrast!=0) + INFO_PRINTF3(_L("newContrast==0 - Expected: %d, Actual: %d"), 0, newContrast); + } + else + { + TEST(contrast+diff==newContrast); + if (contrast+diff!=newContrast) + INFO_PRINTF3(_L("contrast+diff==newContrast - Expected: %d, Actual: %d"), contrast+diff, newContrast); + } + + SendCtrlAltShift(CONTRAST_DOWN); + User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayContrast,newContrast)); + TEST(contrast==newContrast); + if (contrast!=newContrast) + INFO_PRINTF3(_L("contrast==newContrast - Expected: %d, Actual: %d"), contrast, newContrast); + + SendCtrlAltShift(CONTRAST_DOWN); + User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayContrast,newContrast)); + if (contrast==0) + { + TEST(maxContrast==newContrast); + if (maxContrast!=newContrast) + INFO_PRINTF3(_L("maxContrast==newContrast - Expected: %d, Actual: %d"), maxContrast, newContrast); + + } + else + { + TEST(contrast-diff==newContrast); + if (contrast-diff!=newContrast) + INFO_PRINTF3(_L("contrast-diff==newContrast - Expected: %d, Actual: %d"), contrast-diff, newContrast); + + } + + SendCtrlAltShift(CONTRAST_UP); + User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayContrast,newContrast)); + TEST(contrast==newContrast); + if (contrast!=newContrast) + INFO_PRINTF3(_L("contrast==newContrast - Expected: %d, Actual: %d"), contrast, newContrast); + + } + +void CTKey::TestDefaultContrastL(TBool aChange) + { + TInt contrast=0; + TInt newContrast=0; + TInt maxContrast=0; + User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayContrastMax,maxContrast)); + TInt diff=aChange ? 1:0; + User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayContrast,contrast)); + + SendKey(EKeyIncContrast); + User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayContrast,newContrast)); + if ((contrast==maxContrast) && aChange) + { + TEST(newContrast==0); + if (0!=newContrast) + INFO_PRINTF3(_L("newContrast==0 - Expected: %d, Actual: %d"), 0, newContrast); + } + else + { + TEST(contrast+diff==newContrast); + if (contrast+diff!=newContrast) + INFO_PRINTF3(_L("newContrast==contrast+diff - Expected: %d, Actual: %d"), contrast+diff, newContrast); + } + + SendKey(EKeyDecContrast); + User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayContrast,newContrast)); + TEST(contrast==newContrast); + if (contrast!=newContrast) + INFO_PRINTF3(_L("contrast==newContrast - Expected: %d, Actual: %d"), contrast, newContrast); + + SendKey(EKeyDecContrast); + User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayContrast,newContrast)); + if (contrast==0) + { + TEST(maxContrast==newContrast); + if (maxContrast!=newContrast) + INFO_PRINTF3(_L("maxContrast==newContrast - Expected: %d, Actual: %d"), maxContrast, newContrast); + } + else + { + TEST(contrast-diff==newContrast); + if (contrast-diff!=newContrast) + INFO_PRINTF3(_L("contrast-diff==newContrast - Expected: %d, Actual: %d"), contrast-diff, newContrast); + } + + SendKey(EKeyIncContrast); + User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayContrast,newContrast)); + TEST(contrast==newContrast); + if (contrast!=newContrast) + INFO_PRINTF3(_L("contrast==newContrast - Expected: %d, Actual: %d"), contrast, newContrast); + + } + +void CTKey::ContrastKeysL() + { + TInt maxContrast=0; + TInt contrast=0; + TInt err=HAL::Get(iTest->iScreenNumber,HALData::EDisplayContrastMax,maxContrast); + if (err==KErrNotSupported) + return; + else if (err==KErrNone) + err=HAL::Get(iTest->iScreenNumber,HALData::EDisplayContrast,contrast); + if (err==KErrNotSupported) + return; + TEST(err==KErrNone); + if (err!=KErrNone) + INFO_PRINTF3(_L("HAL::Get(iTest->iScreenNumber,HALData::EDisplayContrast,contrast)=KErrNone - Expected: %d, Actual: %d"), KErrNone, err); + + if (contrast==0) + err=HAL::Set(iTest->iScreenNumber,HALData::EDisplayContrast,++contrast); + else if (contrast==maxContrast) + err=HAL::Set(iTest->iScreenNumber,HALData::EDisplayContrast,--contrast); + if (err==KErrNotSupported) + return; + TEST(err==KErrNone); + if (err!=KErrNone) + INFO_PRINTF3(_L("HAL::Get(iTest->iScreenNumber,HALData::EDisplayContrast,contrast)=KErrNone - Expected: %d, Actual: %d"), KErrNone, err); + TestDefaultContrastL(ETrue); + + SetHotKey(EHotKeyIncContrast,CONTRAST_UP); + SetHotKey(EHotKeyDecContrast,CONTRAST_DOWN); + TestContrastL(ETrue); + TestDefaultContrastL(ETrue); + + TheClient->iWs.ClearHotKeys(EHotKeyIncContrast); + TheClient->iWs.ClearHotKeys(EHotKeyDecContrast); + TestContrastL(EFalse); + TestDefaultContrastL(EFalse); + + TheClient->iWs.RestoreDefaultHotKey(EHotKeyIncContrast); + TheClient->iWs.RestoreDefaultHotKey(EHotKeyDecContrast); + TestContrastL(EFalse); + TestDefaultContrastL(ETrue); + + SetHotKey(EHotKeyIncContrast,CONTRAST_UP); + SetHotKey(EHotKeyDecContrast,CONTRAST_DOWN); + TestContrastL(ETrue); + TestDefaultContrastL(ETrue); + + TheClient->iWs.RestoreDefaultHotKey(EHotKeyIncContrast); + TheClient->iWs.RestoreDefaultHotKey(EHotKeyDecContrast); + TestContrastL(EFalse); + TestDefaultContrastL(ETrue); + } + +#define BACKLIGHT_ON 'A' //'o'-'a'+1 +#define BACKLIGHT_OFF 'B' //'p'-'a'+1 +#define BACKLIGHT_TOGGLE 'C' //'q'-'a'+1 +/** Test for reaction against backlight ON/OFF/TOGGLE buttons defined above. + If aChange is false button presses must not affect the state of backlight. +*/ +void CTKey::TestBackLightL(TBool aChange) + { + TBool state; + SendCtrlAltShift(BACKLIGHT_ON); + User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EBacklightState,state)); + TEST(state==aChange); + if (state!=aChange) + INFO_PRINTF3(_L("state==aChange - Expected: %d, Actual: %d"), aChange, state); + + SendCtrlAltShift(BACKLIGHT_TOGGLE); + User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EBacklightState,state)); + TEST(state==EFalse); + if (state!=EFalse) + INFO_PRINTF3(_L("state==EFalse - Expected: %d, Actual: %d"), EFalse, state); + + SendCtrlAltShift(BACKLIGHT_TOGGLE); + User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EBacklightState,state)); + TEST(state==aChange); + if (state!=aChange) + INFO_PRINTF3(_L("state==aChange - Expected: %d, Actual: %d"), aChange, state); + + SendCtrlAltShift(BACKLIGHT_OFF); + User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EBacklightState,state)); + TEST(state==EFalse); + if (state!=EFalse) + INFO_PRINTF3(_L("state==EFalse - Expected: %d, Actual: %d"), EFalse, state); + + SendCtrlAltShift(BACKLIGHT_TOGGLE); + User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EBacklightState,state)); + TEST(state==aChange); + if (state!=aChange) + INFO_PRINTF3(_L("state==aChange - Expected: %d, Actual: %d"), aChange, state); + + SendCtrlAltShift(BACKLIGHT_TOGGLE); + User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EBacklightState,state)); + TEST(state==EFalse); + if (state!=EFalse) + INFO_PRINTF3(_L("state==EFalse - Expected: %d, Actual: %d"), EFalse, state); + + } + +/** Test for reaction against default backlight ON/OFF/TOGGLE buttons. + If aChange is false button presses must not affect the state of backlight. +*/ +void CTKey::TestDefaultBackLightL(TBool aChange) + { + TBool state; + SendKey(EKeyBacklightOn); + User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EBacklightState,state)); + TEST(state==aChange); + if (state!=aChange) + INFO_PRINTF3(_L("state==aChange - Expected: %d, Actual: %d"), aChange, state); + + SendKey(EKeyBacklightToggle); + User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EBacklightState,state)); + TEST(state==EFalse); + if (state!=EFalse) + INFO_PRINTF3(_L("state==EFalse - Expected: %d, Actual: %d"), EFalse, state); + + SendKey(EKeyBacklightToggle); + User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EBacklightState,state)); + TEST(state==aChange); + if (state!=aChange) + INFO_PRINTF3(_L("state==aChange - Expected: %d, Actual: %d"), aChange, state); + + SendKey(EKeyBacklightOff); + User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EBacklightState,state)); + TEST(state==EFalse); + if (state!=EFalse) + INFO_PRINTF3(_L("state==EFalse - Expected: %d, Actual: %d"), EFalse, state); + + SendKey(EKeyBacklightToggle); + User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EBacklightState,state)); + TEST(state==aChange); + if (state!=aChange) + INFO_PRINTF3(_L("state==aChange - Expected: %d, Actual: %d"), aChange, state); + + SendKey(EKeyBacklightToggle); + User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EBacklightState,state)); + TEST(state==EFalse); + if (state!=EFalse) + INFO_PRINTF3(_L("state==EFalse - Expected: %d, Actual: %d"), EFalse, state); + + } + +void CTKey::BackLightKeysL() + { + // Turns backlight off + TBool prevState; + TInt err=HAL::Get(iTest->iScreenNumber,HALData::EBacklightState,prevState); + if (err==KErrNotSupported) + { + _LIT(KLog,"Cannot test BackLight Key presses as cannot read its state on screen %d"); + LOG_MESSAGE2(KLog,iTest->iScreenNumber); + return; + } + else if (err==KErrNone) + err=HAL::Set(iTest->iScreenNumber,HALData::EBacklightState,EFalse); + if (err==KErrNotSupported) + { + _LIT(KLog,"Cannot test BackLight Key presses as cannot set its state on screen %d"); + LOG_MESSAGE2(KLog,iTest->iScreenNumber); + return; + } + TEST(err==KErrNone); + if (err!=KErrNone) + { + _LIT(KLog,"Reading or Setting BackLight state gave error %d on screen %d"); + LOG_MESSAGE3(KLog,err,iTest->iScreenNumber); + } + + // Tests that default backlight ON/OFF/TOGGLE buttons work + TestDefaultBackLightL(ETrue); + + // Sets user defined backlight buttons and tests that both default and user defined buttons work + SetHotKey(EHotKeyBacklightOn,BACKLIGHT_ON); + SetHotKey(EHotKeyBacklightOff,BACKLIGHT_OFF); + SetHotKey(EHotKeyBacklightToggle,BACKLIGHT_TOGGLE); + TestBackLightL(ETrue); + TestDefaultBackLightL(ETrue); + + // Calls RWsSession::ClearHotKeys and tests that both default and user defined buttons don't work + TheClient->iWs.ClearHotKeys(EHotKeyBacklightOn); + TheClient->iWs.ClearHotKeys(EHotKeyBacklightOff); + TheClient->iWs.ClearHotKeys(EHotKeyBacklightToggle); + TestBackLightL(EFalse); + TestDefaultBackLightL(EFalse); + + // Calls RWsSession::RestoreDefaultHotKey and tests that only default buttons work + TheClient->iWs.RestoreDefaultHotKey(EHotKeyBacklightOn); + TheClient->iWs.RestoreDefaultHotKey(EHotKeyBacklightOff); + TheClient->iWs.RestoreDefaultHotKey(EHotKeyBacklightToggle); + TestBackLightL(EFalse); + TestDefaultBackLightL(ETrue); + + // Sets user defined backlight buttons and tests that both default and user defined buttons work + SetHotKey(EHotKeyBacklightOn,BACKLIGHT_ON); + SetHotKey(EHotKeyBacklightOff,BACKLIGHT_OFF); + SetHotKey(EHotKeyBacklightToggle,BACKLIGHT_TOGGLE); + TestBackLightL(ETrue); + TestDefaultBackLightL(ETrue); + + // Calls RWsSession::RestoreDefaultHotKey and tests that only default buttons work + TheClient->iWs.RestoreDefaultHotKey(EHotKeyBacklightOn); + TheClient->iWs.RestoreDefaultHotKey(EHotKeyBacklightOff); + TheClient->iWs.RestoreDefaultHotKey(EHotKeyBacklightToggle); + TestBackLightL(EFalse); + TestDefaultBackLightL(ETrue); + + //Restores previous backlight state + //err=UserHal::SetBacklightOn(prevState); + err=HAL::Set(iTest->iScreenNumber,HALData::EBacklightState,prevState); + TEST(err==KErrNone); + if (err!=KErrNone) + { + _LIT(KLog,"Failed to set BackLight state back to previous state: %d on screen %d, error code: %d"); + LOG_MESSAGE4(KLog,prevState,iTest->iScreenNumber,err); + } + } + +#define BRIGHTNESS_UP 'N' +#define BRIGHTNESS_DOWN 'J' +/** If aChange is true, checks that programmicaly defined brightness buttons increase and decrease brightness properly. + If aChange is false, checks that programmicaly defined brightness buttons don't affect brightness. +*/ +void CTKey::TestBrightnessL(TBool aChange) + { + TInt brightness; + TInt newBrightness; + TInt diff=aChange ? 1:0; + User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayBrightness,brightness)); + + SendCtrlAltShift(BRIGHTNESS_UP); + User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayBrightness,newBrightness)); + TEST(brightness+diff==newBrightness); + if (brightness+diff!=newBrightness) + INFO_PRINTF3(_L("brightness+diff==newBrightness - Expected: %d, Actual: %d"), newBrightness, brightness+diff); + + SendCtrlAltShift(BRIGHTNESS_DOWN); + User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayBrightness,newBrightness)); + TEST(brightness==newBrightness); + if (brightness!=newBrightness) + INFO_PRINTF3(_L("brightness==newBrightness - Expected: %d, Actual: %d"), newBrightness, brightness); + + SendCtrlAltShift(BRIGHTNESS_DOWN); + User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayBrightness,newBrightness)); + TEST(brightness-diff==newBrightness); + if (brightness-diff!=newBrightness) + INFO_PRINTF3(_L("brightness-diff==newBrightness - Expected: %d, Actual: %d"), newBrightness, brightness-diff); + + SendCtrlAltShift(BRIGHTNESS_UP); + User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayBrightness,newBrightness)); + TEST(brightness==newBrightness); + if (brightness!=newBrightness) + INFO_PRINTF3(_L("brightness==newBrightness - Expected: %d, Actual: %d"), newBrightness, brightness); + } + +/** If aChange is true, checks that default brightness buttons increase and decrease brightness properly (increase/decrease by 1). + If aChange is false, checks that default brightness buttons don't affect brightness. +*/ +void CTKey::TestDefaultBrightnessL(TBool aChange) + { + TInt brightness; + TInt newBrightness; + TInt diff=aChange ? 1:0; + User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayBrightness,brightness)); + + SendKey(EKeyIncBrightness); + User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayBrightness,newBrightness)); + TEST(brightness+diff==newBrightness); + if (brightness+diff!=newBrightness) + INFO_PRINTF3(_L("brightness+diff==newBrightness - Expected: %d, Actual: %d"), newBrightness, brightness+diff); + + SendKey(EKeyDecBrightness); + User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayBrightness,newBrightness)); + TEST(brightness==newBrightness); + if (brightness!=newBrightness) + INFO_PRINTF3(_L("brightness==newBrightness - Expected: %d, Actual: %d"), newBrightness, brightness); + + SendKey(EKeyDecBrightness); + User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayBrightness,newBrightness)); + TEST(brightness-diff==newBrightness); + if (brightness-diff!=newBrightness) + INFO_PRINTF3(_L("brightness-diff==newBrightness - Expected: %d, Actual: %d"), newBrightness, brightness-diff); + + SendKey(EKeyIncBrightness); + User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayBrightness,newBrightness)); + TEST(brightness==newBrightness); + if (brightness!=newBrightness) + INFO_PRINTF3(_L("brightness==newBrightness - Expected: %d, Actual: %d"), newBrightness, brightness); + } + +void CTKey::BrightnessKeysL() + { + INFO_PRINTF1(_L("AUTO Brightness Key Test ")); + TInt maxBrightness; + TInt brightness=0; //To stop warning + // get maximum brightness and current + TInt err=HAL::Get(iTest->iScreenNumber,HALData::EDisplayBrightnessMax,maxBrightness); + if (err==KErrNotSupported) + return; + else if (err==KErrNone) + err=HAL::Get(iTest->iScreenNumber,HALData::EDisplayBrightness,brightness); + if (err==KErrNotSupported) + return; + INFO_PRINTF1(_L(" Supported")); + TEST(err==KErrNone); + if (err!=KErrNone) + INFO_PRINTF3(_L("HAL::Get(iTest->iScreenNumber,HALData::EDisplayBrightness,brightness) return value - Expected: %d, Actual: %d"), KErrNone, err); + + // sets brightness to be neither maximal nor minimal + if (brightness==0) + err=HAL::Set(iTest->iScreenNumber,HALData::EDisplayBrightness,++brightness); + else if (brightness==maxBrightness) + err=HAL::Set(iTest->iScreenNumber,HALData::EDisplayBrightness,--brightness); + if (err==KErrNotSupported) + return; + INFO_PRINTF1(_L(" Changeable")); + TEST(err==KErrNone); + if (err!=KErrNone) + INFO_PRINTF3(_L("HAL::Get(iTest->iScreenNumber,HALData::EDisplayBrightness,brightness) return value - Expected: %d, Actual: %d"), KErrNone, err); + + // Test default brightness buttons increase/decrease brightness by 1 + TestDefaultBrightnessL(ETrue); + + // Add new inc/dec buttons, test that default and program defined brightness buttons increase/decrease brightness by 1 + INFO_PRINTF1(_L(" First Test")); + SetHotKey(EHotKeyIncBrightness,BRIGHTNESS_UP); + SetHotKey(EHotKeyDecBrightness,BRIGHTNESS_DOWN); + TestBrightnessL(ETrue); + TestDefaultBrightnessL(ETrue); + + // Clear brightness buttons, test that default and program defined brightness buttons doesn't affect brightness + INFO_PRINTF1(_L(" Second Test")); + TheClient->iWs.ClearHotKeys(EHotKeyIncBrightness); + TheClient->iWs.ClearHotKeys(EHotKeyDecBrightness); + TestBrightnessL(EFalse); + TestDefaultBrightnessL(EFalse); + + // Restore default brightness buttons, test that only default brightness buttons increase/decrease brightness by 1 + INFO_PRINTF1(_L(" Third Test")); + TheClient->iWs.RestoreDefaultHotKey(EHotKeyIncBrightness); + TheClient->iWs.RestoreDefaultHotKey(EHotKeyDecBrightness); + TestBrightnessL(EFalse); + TestDefaultBrightnessL(ETrue); + + // Add new inc/dec buttons, test that default and program defined brightness buttons increase/decrease brightness by 1 + INFO_PRINTF1(_L(" Fourth Test")); + SetHotKey(EHotKeyIncBrightness,BRIGHTNESS_UP); + SetHotKey(EHotKeyDecBrightness,BRIGHTNESS_DOWN); + TestBrightnessL(ETrue); + TestDefaultBrightnessL(ETrue); + + // Restore default brightness buttons, test that only default brightness buttons increase/decrease brightness by 1 + INFO_PRINTF1(_L(" Fifth Test")); + TheClient->iWs.RestoreDefaultHotKey(EHotKeyIncBrightness); + TheClient->iWs.RestoreDefaultHotKey(EHotKeyDecBrightness); + TestBrightnessL(EFalse); + TestDefaultBrightnessL(ETrue); + } + +void CTKey::TestDefaultScreenSizeModeL(TInt aKeys,TBool aChange) + { + TInt screenMode=TheClient->iScreen->CurrentScreenMode(); + TInt key; + TInt retVal; + for (key=0;keySetMode(key); + SendKey(EKeyScreenDimension0+key); + if (aChange) + { + retVal = TheClient->iScreen->CurrentScreenMode(); + TEST(retVal==key); + if (retVal!=key) + INFO_PRINTF3(_L("TheClient->iScreen->CurrentScreenMode() return value - Expected: %d, Actual: %d"), key, retVal); + } + else + { + retVal = TheClient->iScreen->CurrentScreenMode(); + TEST(retVal==screenMode); + if (retVal!=screenMode) + INFO_PRINTF3(_L("TheClient->iScreen->CurrentScreenMode() return value - Expected: %d, Actual: %d"), screenMode, retVal); + } + } + } + +#define DIMENSION0 'P' +#define DIMENSION1 'Q' +#define DIMENSION2 'R' +#define DIMENSION3 'N' +void CTKey::TestScreenSizeModeL(TInt aKeys,TBool aChange) + { + TInt screenMode=TheClient->iScreen->CurrentScreenMode(); + TInt key; + TInt retVal; + for (key=0;keySetMode(key); + switch (key) + { + case 0: + SendCtrlAltShift(DIMENSION0); + break; + case 1: + SendCtrlAltShift(DIMENSION1); + break; + case 2: + SendCtrlAltShift(DIMENSION2); + break; + case 3: + SendCtrlAltShift(DIMENSION3); + break; + default: + INFO_PRINTF2(_L("Error Invalid Key: %d"),key); + TEST(EFalse); + break; + } + + + if (aChange) + { + retVal = TheClient->iScreen->CurrentScreenMode(); + TEST(retVal==key); + if (retVal!=key) + INFO_PRINTF3(_L("TheClient->iScreen->CurrentScreenMode() return value - Expected: %d, Actual: %d"), key, retVal); + + } + else + { + retVal = TheClient->iScreen->CurrentScreenMode(); + TEST(retVal==screenMode); + if (retVal!=screenMode) + INFO_PRINTF3(_L("TheClient->iScreen->CurrentScreenMode() return value - Expected: %d, Actual: %d"), screenMode, retVal); + + } + } + } + +void CTKey::ScreenSizeModeKeysL() + { + // The test does nothing if there is only one possible screen mode -> return + TInt numScreenModes=TheClient->iScreen->NumScreenModes(); + if (numScreenModes<2) + return; + + // Use at most 4 different modes for the test + if (numScreenModes>4) {numScreenModes=4;} + + // Set screen mode 3 + TInt screenMode=TheClient->iScreen->CurrentScreenMode(); + iVisibleGroup->SetMode(numScreenModes-1); + TheClient->iScreen->SetScreenMode(numScreenModes-1); + + // Test default screen mode switch buttons + TestDefaultScreenSizeModeL(numScreenModes,ETrue); + + // Add new screen mode switch buttons. Test that default and program defined screen mode switch buttons switch modes. + SetHotKey(EHotKeyScreenDimension0,DIMENSION0); + SetHotKey(EHotKeyScreenDimension1,DIMENSION1); + SetHotKey(EHotKeyScreenDimension2,DIMENSION2); + SetHotKey(EHotKeyScreenDimension3,DIMENSION3); + TestDefaultScreenSizeModeL(numScreenModes,ETrue); + TestScreenSizeModeL(numScreenModes,ETrue); + + // Clear all screen mode switch buttons. Test that default and program defined screen mode switch buttons don't affect screen modes + TheClient->iWs.ClearHotKeys(EHotKeyScreenDimension0); + TheClient->iWs.ClearHotKeys(EHotKeyScreenDimension1); + TheClient->iWs.ClearHotKeys(EHotKeyScreenDimension2); + TheClient->iWs.ClearHotKeys(EHotKeyScreenDimension3); + TestDefaultScreenSizeModeL(numScreenModes,EFalse); + TestScreenSizeModeL(numScreenModes,EFalse); + + // Restore default screen mode switch buttons. Test that only default screen mode switch buttons switch screen modes + TheClient->iWs.RestoreDefaultHotKey(EHotKeyScreenDimension0); + TheClient->iWs.RestoreDefaultHotKey(EHotKeyScreenDimension1); + TheClient->iWs.RestoreDefaultHotKey(EHotKeyScreenDimension2); + TheClient->iWs.RestoreDefaultHotKey(EHotKeyScreenDimension3); + TestDefaultScreenSizeModeL(numScreenModes,ETrue); + TestScreenSizeModeL(numScreenModes,EFalse); + + // Add new screen mode switch buttons. Test that default and program defined screen mode switch buttons switch modes. + SetHotKey(EHotKeyScreenDimension0,DIMENSION0); + SetHotKey(EHotKeyScreenDimension1,DIMENSION1); + SetHotKey(EHotKeyScreenDimension2,DIMENSION2); + SetHotKey(EHotKeyScreenDimension3,DIMENSION3); + TestDefaultScreenSizeModeL(numScreenModes,ETrue); + TestScreenSizeModeL(numScreenModes,ETrue); + + // Restore default screen mode switch buttons. Test that only default screen mode switch buttons switch screen modes + TheClient->iWs.RestoreDefaultHotKey(EHotKeyScreenDimension0); + TheClient->iWs.RestoreDefaultHotKey(EHotKeyScreenDimension1); + TheClient->iWs.RestoreDefaultHotKey(EHotKeyScreenDimension2); + TheClient->iWs.RestoreDefaultHotKey(EHotKeyScreenDimension3); + TestDefaultScreenSizeModeL(numScreenModes,ETrue); + TestScreenSizeModeL(numScreenModes,EFalse); + + // Restore initial screen mode + iVisibleGroup->SetMode(screenMode); + TheClient->iScreen->SetScreenMode(screenMode); + } + +void CTKey::RunTestCaseL(TInt /*aCurTestCase*/) + { + _LIT(KTest0,"KeyOfDeath"); + _LIT(KTest1,"Contrast"); + _LIT(KTest2,"BackLight"); + _LIT(KTest3,"Brightness"); + _LIT(KTest4,"Screen Size Mode"); + ((CTKeyStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); +#ifdef _DEBUG + _LIT(KTest5,"Orientation"); + _LIT(KTest6,"CycleDisplaySize"); +#endif + switch(++iTest->iState) + { +/** +@SYMTestCaseID GRAPHICS-WSERV-0106 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Key of Death test + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Creates a new client process and runs it. + Waits until the process is started and simulates Ctrl-Alt-Shift-K press. + When starts the process assumes that TAutoServer.exe exists in z:\sys\bin directory. + Otherwise the test will not exit a wait-state and will be aborted. + +@SYMTestExpectedResults Checks that the process is dead after the Ctrl-Alt-Shift-K press. + Check also that the difference between amounts of window groups efore + death-key press and after death-key press is 1. +*/ + case 1: + ((CTKeyStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0106")); + iTest->LogSubTest(KTest0); + KeyOfDeathL(); + break; + case 2: +/** +@SYMTestCaseID GRAPHICS-WSERV-0539 +*/ + ((CTKeyStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0539")); + iTest->LogSubTest(KTest1); + ContrastKeysL(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0107 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test backlight + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Does nothing if hardware attributes are not supported. + 1. Turns backlight off. + 2. Tests that default backlight ON/OFF/TOGGLE buttons work. + 3. Sets user defined backlight buttons and tests that both default and user defined buttons work. + 4. Calls RWsSession::ClearHotKeys and tests that both default and user defined buttons don't work. + 5. Calls RWsSession::RestoreDefaultHotKey and tests that only default buttons work. + 6. Sets user defined backlight buttons and tests that both default and user defined buttons work. + 7. Calls RWsSession::RestoreDefaultHotKey and tests that only default buttons work. + 8. Restores previous backlight state. + +@SYMTestExpectedResults Expects that actions described above give positive result. + The test also checks that programmatic turn off/on doesn't fail. +*/ + case 3: + ((CTKeyStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0107")); + iTest->LogSubTest(KTest2); + BackLightKeysL(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0108 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test brightness + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Does nothing if hardware attributes are not supported. + 1. Get maximum brightness and current, test that those operations don't fail + 2. Sets brightness to be neither maximal nor minimal, test that those operations don't fail + 3. Test default brightness buttons increase/decrease brightness by 1 + 4. Add new inc/dec buttons, test that default and program defined brightness buttons increase/decrease brightness by 1 + 5. Clear brightness buttons, test that default and program defined brightness buttons doesn't affect brightness + 6. Restore default brightness buttons, test that only default brightness buttons increase/decrease brightness by 1 + 7. Add new inc/dec buttons, test that default and program defined brightness buttons increase/decrease brightness by 1 + 8. Restore default brightness buttons, test that only default brightness buttons increase/decrease brightness by 1 + +@SYMTestExpectedResults Expects that actions described above give positive result. + The test also checks that programmatic brightness increase and decrease doesn't fail. +*/ + case 4: + ((CTKeyStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0108")); + iTest->LogSubTest(KTest3); + BrightnessKeysL(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0109 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test screen mode switching + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions The test does nothing if there is only one possible screen mode. It uses at most 4 different modes for the test. + 1. Test default screen mode switch buttons + 2. Add new screen mode switch buttons. Test that default and program defined screen mode switch buttons switch modes. + 3. Clear all screen mode switch buttons. Test that default and program defined screen mode switch buttons don't affect screen modes + 4. Restore default screen mode switch buttons. Test that only default screen mode switch buttons switch screen modes + 5. Add new screen mode switch buttons. Test that default and program defined screen mode switch buttons switch modes. + 6. Restore default screen mode switch buttons. Test that only default screen mode switch buttons switch screen modes + 7. Restore initial screen mode + + + +@SYMTestExpectedResults Expects that actions described above give positive result. +*/ + case 5: + ((CTKeyStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0109")); + iTest->LogSubTest(KTest4); + ScreenSizeModeKeysL(); + break; +#ifdef _DEBUG + case 6: +/** +@SYMTestCaseID GRAPHICS-WSERV-0540 +*/ + ((CTKeyStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0540")); + iTest->LogSubTest(KTest5); + KeyOfOrientation(); + break; + case 7: +/** +@SYMTestCaseID GRAPHICS-WSERV-0541 +*/ + ((CTKeyStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0541")); + iTest->LogSubTest(KTest6); + CycleDisplaySize(); + break; +#endif + default: + ((CTKeyStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + ((CTKeyStep*)iStep)->CloseTMSGraphicsStep(); + TestComplete(); + } + ((CTKeyStep*)iStep)->RecordTestResultL(); + } + + +__WS_CONSTRUCT_STEP__(Key) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TKEY.H --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TKEY.H Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,115 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef __TKEY_H__ +#define __TKEY_H__ + +#include +#include +#include "../tlib/testbase.h" +#include "AUTO.H" +#include +#include "TGraphicsHarness.h" + +_LIT(KSemaphoreName,"KeyProcSem"); + + +class CVisibleGroup: public CBase + { +public: + CVisibleGroup(TInt aScreenNo); + ~CVisibleGroup(); + void ConstructL(); + void SetMode(TInt aMode); +private: + RWsSession iWs; + RWindowGroup iGroup; + CWsScreenDevice* iScr; + TInt iScreenNo; + TInt iMode; + }; + + +class ClientToKill : public CTClient + { +public: + ClientToKill(); + ~ClientToKill(); + void ConstructL(); +private: + TestWindow *iTestWin; + }; + + + +class CTKey : public CTWsGraphicsBase + { +public: + enum {EFuncCtrlShift=EModifierFunc|EModifierCtrl|EModifierShift}; +public: + CTKey(CTestStep* aStep); + ~CTKey(); + void ConstructL(); + + void KeyOfDeathL(); + void KeyOfOrientation(); + void CycleDisplaySize(); + void ContrastKeysL(); + void BackLightKeysL(); + void BrightnessKeysL(); + void ScreenSizeModeKeysL(); +protected: + virtual void RunTestCaseL(TInt aCurTestCase); +private: + void SendKey(TInt aScanCode); + void SendUpDown(TInt aScanCode); + void SendCtrlAltShift(TInt aScanCode); + void SendCtrlAltShift(TRawEvent::TType aType); + void SetHotKey(THotKey aType, TUint aKeyCode); + void LogWindowGroupIds(); + void TestContrastL(TBool aChange); + void TestDefaultContrastL(TBool aChange); + void TestBackLightL(TBool aChange); + void TestDefaultBackLightL(TBool aChange); + void TestBrightnessL(TBool aChange); + void TestDefaultBrightnessL(TBool aChange); + void TestScreenSizeModeL(TInt aKeys,TBool aChange); + void TestDefaultScreenSizeModeL(TInt aKeys,TBool aChange); + +private: + RSemaphore iSem; + TSize iWinSize; + CVisibleGroup* iVisibleGroup; + }; + +class CTKeyStep : public CTGraphicsStep + { +public: + CTKeyStep(); +protected: + //from CTGraphicsStep + virtual CTGraphicsBase* CreateTestL(); + }; + +_LIT(KTKeyStep,"TKey"); + + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TKRepeat.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TKRepeat.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,464 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Converted from TMan test code May 2001 +// Keyboard repeat test +// +// + +#include "TKRepeat.H" + +#define LOGGING 1 + +// +// CRKWindow, class // +// + +CRKWindow::CRKWindow(CTKRepeat *aTest) : CTWin(), iTest(aTest) + { + } + +void CRKWindow::SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc) + { + ConstructExtLD(*parent,pos,size); + iWin.SetBackgroundColor(TRgb::Gray256(230)); + Activate(); + AssignGC(aGc); + } + +void CRKWindow::Draw() + { + iGc->Clear(); + switch(iState) + { + case EStateWaitingForKeyDown: + iGc->DrawText(_L("Press and hold the space bar"), TPoint(10,20)); + break; + case EStateWaitingForFirstRepeat: + case EStateWaitingForNthRepeat: + { + TBuf<0x40> buf; + buf.Format(TRefByValue(_L("Keep space bar down (%d repeats so far)")),iRepCount); + iGc->DrawText(buf, TPoint(10,20)); + } + break; + case EStateWaitingForKeyUp: + iGc->DrawText(_L("Release space bar"), TPoint(10,20)); + default: + break; + } + } + +void CRKWindow::SetState(TRKStates aState) + { +#if defined(LOGGING) + TLogMessageText logMessageText; + _LIT(KStateChange,"State Change Old=%d New=%d"); + logMessageText.Format(KStateChange,iState,aState); + iTest->LOG_MESSAGE(logMessageText); +#endif + iState=aState; + DrawNow(); + TheClient->WaitForRedrawsToFinish(); + SendEvent(); + } + +void CRKWindow::SendEvent() + { + switch (iState) + { + case EStateWaitingForKeyDown: + case EStateWaitingForKeyUp: + #if defined(LOGGING) + _LIT(KKeyUp,"Send key up event substate 0"); + _LIT(KKeyDown,"Send key down event substate 4"); + iTest->LOG_MESSAGE(iState==EStateWaitingForKeyDown ? KKeyDown() : KKeyUp()); + #endif + iTest->TestBase()->SimulateKey((iState==EStateWaitingForKeyDown ? TRawEvent::EKeyDown : TRawEvent::EKeyUp),EStdKeySpace); + break; + case EStateWaitingForKeyCode: + case EStateWaitingForFirstRepeat: + case EStateWaitingForNthRepeat: + case EStateInactive: + case EStateError: + #if defined(LOGGING) + _LIT(KLog,"SendEvent: substate %d so no event to send"); + iTest->LOG_MESSAGE2(KLog,iState); + #endif + break; + } + } + +TBool CRKWindow::CheckResults() + { +// +// Checks repeat results, first convert everything to 10th's as that what is actually used +// for the timer in the window server. +// +// Return ETrue if the inacuracy in the average time is greater than 1/10th either way +// Allow initial 2/10ths either +// Allow min 2/10ths below +// Allow max 2/10ths above +// + if (iState!=EStateInactive) + return(ETrue); + TInt initial=iInitialGap.Int()/100000; + TInt initialX=iInitialRepeatSet.Int()/100000; + if (initialX==0) + initialX=1; + TInt average=(iTotalGap.Int()/100000)/(iRepCount-1); + TInt repeatX=iRepeatSet.Int()/100000; + if (repeatX==0) + repeatX=1; + TInt min=iMinGap.Int()/100000; + TInt max=iMaxGap.Int()/100000; + if (average>(repeatX+1) || average<(repeatX-1)) + return(ETrue); + if (initial>(initialX+2) || initial<(initialX-2)) + return(ETrue); +#if defined(__MARM_ARM4__) + if (min>(repeatX+1) || min<(repeatX-2) || max>(repeatX+3) || max2*(repeatX+2)) + return(ETrue); + } +#else + if (min>(repeatX+1) || min<(repeatX-2)) + return(ETrue); + if (max>(repeatX+3) || max(_L("Initial=%d [%d], Av=%d [%d], Min=%d, Max=%d")),initial,initialX,average,repeatX,min,max); + } + return(iReport); + } + +void CRKWindow::KeyDownL(const TKeyEvent &aKey,const TTime &) + { +#if defined(LOGGING) + TLogMessageText logMessageText; + _LIT(KKeyDown,"CRKWindow::KeyDownL Code=%d '%c' State=%d (0)"); + logMessageText.Format(KKeyDown,aKey.iScanCode,aKey.iScanCode,iState); + iTest->LOG_MESSAGE(logMessageText); +#endif + switch(iState) + { + case EStateWaitingForKeyDown: + SetState(EStateWaitingForKeyCode); + iDownCode=aKey.iScanCode; + break; + default:; + } + } + +void CRKWindow::KeyUpL(const TKeyEvent &aKey,const TTime &) + { +#if defined(LOGGING) + TLogMessageText logMessageText; + _LIT(KKeyUp,"CRKWindow::KeyUpL Code=%d (%c) State=%d Down=%d"); + logMessageText.Format(KKeyUp,aKey.iScanCode,aKey.iScanCode,iState,iDownCode); + iTest->LOG_MESSAGE(logMessageText); +#endif + if (aKey.iScanCode==iDownCode) + { + switch(iState) + { + case EStateWaitingForKeyUp: + SetState(EStateInactive); + break; + default: + SetState(EStateError); + break; + } + CActiveScheduler::Stop(); + } + } + +void CRKWindow::WinKeyL(const TKeyEvent &aKey,const TTime &aTime) + { + if (aKey.iCode==EKeyEscape) + { + CActiveScheduler::Stop(); + iTest->iAbort=ETrue; + } +#if defined(LOGGING) + TLogMessageText logMessageText; + _LIT(KKey,"CRKWindow::WinKeyL Code=%d (%c) State=%d RepeatCount=%d"); + logMessageText.Format(KKey,aKey.iScanCode,aKey.iScanCode,iState,iRepCount); + iTest->LOG_MESSAGE(logMessageText); +#endif + if (aKey.iCode==32) + { + switch(iState) + { + case EStateWaitingForKeyCode: + SetState(EStateWaitingForFirstRepeat); + iPrevTime=aTime; + break; + case EStateWaitingForFirstRepeat: + iRepCount=1; + iInitialGap = I64LOW(aTime.MicroSecondsFrom(iPrevTime).Int64()); + SetState(EStateWaitingForNthRepeat); + break; + case EStateWaitingForNthRepeat: + if (iRepCount==5) + SetState(EStateWaitingForKeyUp); + else + { + TTimeIntervalMicroSeconds32 gap(I64LOW(aTime.MicroSecondsFrom(iPrevTime).Int64())); + #if defined(LOGGING) + TLogMessageText logMessageText; + _LIT(KRepeatGap,"Repeat after %d"); + logMessageText.AppendFormat(KRepeatGap,gap.Int()); + iTest->LOG_MESSAGE(logMessageText); + TheClient->Flush(); + #endif + if (gapiMaxGap) + iMaxGap=gap; + iTotalGap=iTotalGap.Int()+gap.Int(); // Horrible way to do a += + iRepCount++; + SetState(EStateWaitingForNthRepeat); + } + case EStateWaitingForKeyUp: // Do nothing here + break; + default: + //iTest->Test(EFalse); + iTest->TestBase()->SimulateKey(TRawEvent::EKeyUp,EStdKeySpace); + CActiveScheduler::Stop(); + } + iPrevTime=aTime; + } + } + +void CRKWindow::SetKeyboardRepeatRate(const TTimeIntervalMicroSeconds32 &aInitialTime, const TTimeIntervalMicroSeconds32 &aTime) + { + iInitialRepeatSet=aInitialTime; + iRepeatSet=aTime; + iMinGap=TTimeIntervalMicroSeconds32(100000000); // Any very big number will do + iMaxGap=TTimeIntervalMicroSeconds32(0); + iTotalGap=TTimeIntervalMicroSeconds32(0); + SetState(EStateWaitingForKeyDown); + Client()->iWs.Flush(); + } + +// + +CTKRepeat::CTKRepeat(CTestStep* aStep) : CTWsGraphicsBase(aStep) + { + } + +CTKRepeat::~CTKRepeat() + { + CTWin::Delete(iWin); + Client()->iWs.SetKeyboardRepeatRate(iOldInitialTime, iOldTime); + } + +void CTKRepeat::ConstructL() + { + TheClient->iWs.SetFocusScreen(iTest->iScreenNumber); + iWin=new(ELeave) CRKWindow(this); + TSize screenSize=Client()->iGroup->Size(); + iWin->SetUpL(TPoint(5,5),TSize(Min(Max(screenSize.iWidth/2,250),screenSize.iWidth-10),screenSize.iHeight-10),Client()->iGroup,*Client()->iGc); + Client()->iGroup->WinTreeNode()->SetOrdinalPosition(0); + Client()->iGroup->SetCurrentWindow(iWin); + Client()->iWs.GetKeyboardRepeatRate(iOldInitialTime, iOldTime); + iTest->SimulateKeyDownUp(EStdKeyLeftCtrl); + iTest->SimulateKeyDownUp(EStdKeyRightCtrl); + TInt mods=Client()->iWs.GetModifierState(); + TheClient->WaitForRedrawsToFinish(); //Let all pending events be processed before test begins + _LIT(KLog,"Initial Modifiers state 0x%x (ideally should be zero)"); + LOG_MESSAGE2(KLog,mods); + } + +TInt CTKRepeat::CheckReportL() + { + if (iWin->CheckResults()) + { + /*CTDialog *dialog=new(ELeave) CTDialog(); + dialog->SetTitle(_L("Keyboard repeat innacuracies")); + dialog->SetLine1(iWin->Report()); + dialog->SetNumButtons(3); + dialog->SetButtonText(0,_L("Okay")); + dialog->SetButtonText(1,_L("Retest")); + dialog->SetButtonText(2,_L("Fail")); + dialog->ConstructLD(*Client()->iGroup,*Client()->iGc); + switch(dialog->Display()) + { + case 0: + break; + case 1: + return(ETrue); // Redo test + case 2: + Client()->iGroup->ClearCurrentWindow(); + Test(EFalse); + break; + } + */} + return(EFalse); + } + +void CTKRepeat::TestKeyboardRepeatRateL(const TTimeIntervalMicroSeconds32 &aInitialTime, const TTimeIntervalMicroSeconds32 &aTime) + { + do + { + #if defined(LOGGING) + const TInt KOneSec=1000000; + const TInt KOneHundrethSec=KOneSec/100; + TLogMessageText logMessageText; + _LIT(KRepeatRate,"Repeat Rate Initial=%d.%02dsecs, Subsequent=%d.%02dsecs"); + logMessageText.Format(KRepeatRate,aInitialTime.Int()/KOneSec,(aInitialTime.Int()%KOneSec)/KOneHundrethSec + ,aTime.Int()/KOneSec,(aTime.Int()%KOneSec)/KOneHundrethSec); + LOG_MESSAGE(logMessageText); + #endif + TheClient->iWs.SetKeyboardRepeatRate(aInitialTime, aTime); + iWin->SetKeyboardRepeatRate(aInitialTime, aTime); + CActiveScheduler::Start(); + if (iAbort) + { + iTest->AbortL(); + } + } while(CheckReportL()); + } + +void CTKRepeat::RunTestCaseL(TInt /*aCurTestCase*/) + { + _LIT(KTestName1,"Keyboard Repeat 1"); + _LIT(KTestName2,"Keyboard Repeat 2"); + _LIT(KTestName3,"Keyboard Repeat 3"); + _LIT(KTestName4,"Keyboard Repeat 4"); + ((CTKRepeatStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); + switch(++iTest->iState) + { +/** + + @SYMTestCaseID GRAPHICS-WSERV-0311 + + @SYMDEF DEF081259 + + @SYMTestCaseDesc Test that a key can be repeatedly struck after a second, then every half second + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions Simulate a key being struck first after a second and then repeatedly every + half second and check the response time to the key strike is correct + + @SYMTestExpectedResults Response time each time the key is struck is correct + +*/ + case 1: + ((CTKRepeatStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0311")); + iTest->LogSubTest(KTestName1); + TestKeyboardRepeatRateL(TTimeIntervalMicroSeconds32(1000000), TTimeIntervalMicroSeconds32(500000)); + break; +/** + + @SYMTestCaseID GRAPHICS-WSERV-0312 + + @SYMDEF DEF081259 + + @SYMTestCaseDesc Test that a key can be repeatedly struck after a 5th of a second, then every 10th of a second + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions Simulate a key being struck first after a 5th of a second and then repeatedly every + 10th of a second and check the response time to the key strike is correct + + @SYMTestExpectedResults Response time each time the key is struck is correct + +*/ + case 2: + ((CTKRepeatStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0312")); + iTest->LogSubTest(KTestName2); + TestKeyboardRepeatRateL(TTimeIntervalMicroSeconds32(200000), TTimeIntervalMicroSeconds32(100000)); + break; +/** + + @SYMTestCaseID GRAPHICS-WSERV-0313 + + @SYMDEF DEF081259 + + @SYMTestCaseDesc Test that a key can be repeatedly struck immediately, then every 10th of a second + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions Simulate a key being struck first immediately and then repeatedly every + 10th of a second and check the response time to the key strike is correct + + @SYMTestExpectedResults Response time each time the key is struck is correct + +*/ + case 3: + ((CTKRepeatStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0313")); + iTest->LogSubTest(KTestName3); + TestKeyboardRepeatRateL(TTimeIntervalMicroSeconds32(0), TTimeIntervalMicroSeconds32(100000)); + break; +/** + + @SYMTestCaseID GRAPHICS-WSERV-0314 + + @SYMDEF DEF081259 + + @SYMTestCaseDesc Test that a key can be repeatedly struck after a 10 of a second, then every 10th of a second + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions Simulate a key being struck first after a 10th of a second and then repeatedly every + 10th of a second and check the response time to the key strike is correct + + @SYMTestExpectedResults Response time each time the key is struck is correct + +*/ + + case 4: + ((CTKRepeatStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0314")); + iTest->LogSubTest(KTestName4); + TestKeyboardRepeatRateL(TTimeIntervalMicroSeconds32(100000), TTimeIntervalMicroSeconds32(100000)); + break; + case 5: + ((CTKRepeatStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + ((CTKRepeatStep*)iStep)->CloseTMSGraphicsStep(); + TestComplete(); + break; + } + ((CTKRepeatStep*)iStep)->RecordTestResultL(); + } + +__WS_CONSTRUCT_STEP__(KRepeat) + diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TKRepeat.H --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TKRepeat.H Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,110 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef __TKREPEAT_H__ +#define __TKREPEAT_H__ + +#include +#include +#include +#include "../tlib/testbase.h" +#include "AUTO.H" +#include "TGraphicsHarness.h" + +class CRKWindow; + +class CTKRepeat : public CTWsGraphicsBase + { + friend class CRKWindow; +public: + CTKRepeat(CTestStep* aStep); + ~CTKRepeat(); + void ConstructL(); + void TestKeyboardRepeatRateL(const TTimeIntervalMicroSeconds32 &aInitialTime, const TTimeIntervalMicroSeconds32 &aTime); + TBool CheckReportL(); +public: + TBool iAbort; +protected: +//from CTGraphicsStep + virtual void RunTestCaseL(TInt aCurTestCase); +private: + inline TestClient *Client() {return TheClient;} +private: + TTimeIntervalMicroSeconds32 iOldInitialTime; + TTimeIntervalMicroSeconds32 iOldTime; + CRKWindow *iWin; + TSize iWinSize; + TInt iState; + }; + +class CRKWindow : public CTWin + { + enum TRKStates { + EStateWaitingForKeyDown, + EStateWaitingForKeyCode, + EStateWaitingForFirstRepeat, + EStateWaitingForNthRepeat, + EStateWaitingForKeyUp, + EStateInactive, + EStateError, + }; +public: + CRKWindow(CTKRepeat *aTest); + void SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc); + void SetState(TRKStates aState); + void SetKeyboardRepeatRate(const TTimeIntervalMicroSeconds32 &aInitialTime, const TTimeIntervalMicroSeconds32 &aTime); + void WinKeyL(const TKeyEvent &,const TTime &); + void KeyUpL(const TKeyEvent &aKey,const TTime &aTime); + void KeyDownL(const TKeyEvent &aKey,const TTime &aTime); + void Draw(); + TDesC& Report(); + TBool CheckResults(); + void SendEvent(); +protected: + TInt iConnIndex; + CTKRepeat *iTest; + TRgb iBack; + TRKStates iState; + TInt iDownCode; + TInt iRepCount; + TTimeIntervalMicroSeconds32 iInitialRepeatSet; + TTimeIntervalMicroSeconds32 iRepeatSet; + TTime iPrevTime; + TTimeIntervalMicroSeconds32 iInitialGap; + TTimeIntervalMicroSeconds32 iTotalGap; + TTimeIntervalMicroSeconds32 iMinGap; + TTimeIntervalMicroSeconds32 iMaxGap; + TBuf<0x40> iReport; + }; + +class CTKRepeatStep : public CTGraphicsStep + { +public: + CTKRepeatStep(); +protected: + //from CTGraphicsStep + virtual CTGraphicsBase* CreateTestL(); + }; + +_LIT(KTKRepeatStep,"TKRepeat"); + + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TMDISPLAY.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TMDISPLAY.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,232 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Multiple display test +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + + + +#include "TMDISPLAY.H" +#include +// +// +CTClient* CreateClientL() + { + return (TheClient=new(ELeave) TestClient()); + } + +TInt ProcMultiDisplay(TAny* aScreenNo) + { + return TestLibStartUp(CreateClientL,(TInt)aScreenNo); + } + + +// +// + +CTMultiDisplay::CTMultiDisplay(CTestStep* aStep) : CTWsGraphicsBase(aStep) + { + INFO_PRINTF1(_L("Testing Mutli display functions")); + } + +void CTMultiDisplay::ConstructL() + { + } + +CTMultiDisplay::~CTMultiDisplay() + { + } + +TInt DoSetFocusScreenL(TInt aFocusScreen,TAny* /*aArg*/) + { + RWsSession ws; + User::LeaveIfError(ws.Connect()); + ws.SetFocusScreen(aFocusScreen); + ws.Close(); + return EWsExitReasonBad; + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-0051 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test focusing on the two different screens + available + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Test the response to different calls to focus + on the two screens available + +@SYMTestExpectedResults Foucisng on the different screens is correct +*/ +void CTMultiDisplay::DoFocusScreenTestL() + { + _LIT(KSubTitle,"FocusScreen API"); + INFO_PRINTF1(KSubTitle); + + TInt numberOfScreens; + HAL::Get(HALData::EDisplayNumberOfScreens, numberOfScreens); + TInt oldFocus=TheClient->iWs.GetFocusScreen(); + + // test case #1: out of bounds screen number + // expected result: client panic and focus stays on current screen + TEST(iTest->TestWsPanicL(&DoSetFocusScreenL,EWservPanicScreenNumber,-1,NULL)); + TEST(TheClient->iWs.GetFocusScreen()==oldFocus); + if (TheClient->iWs.GetFocusScreen()!=oldFocus) + INFO_PRINTF3(_L("TheClient->iWs.GetFocusScreen() return value - Expected: %d, Actual: %d"), oldFocus, TheClient->iWs.GetFocusScreen()); + + TEST(iTest->TestWsPanicL(&DoSetFocusScreenL,EWservPanicScreenNumber,numberOfScreens,NULL)); + TEST(TheClient->iWs.GetFocusScreen()==oldFocus); + if (TheClient->iWs.GetFocusScreen()!=oldFocus) + INFO_PRINTF3(_L("TheClient->iWs.GetFocusScreen() return value - Expected: %d, Actual: %d"), oldFocus, TheClient->iWs.GetFocusScreen()); + + + // test case #2: new focus equals to current focus + // expected result: KErrNone and focus stays on current screen + TInt ret = TheClient->iWs.SetFocusScreen(oldFocus); + TEST(ret==KErrNone && TheClient->iWs.GetFocusScreen()==oldFocus); + if (ret!=KErrNone || TheClient->iWs.GetFocusScreen()!=oldFocus) + INFO_PRINTF5(_L("TheClient->iWs.SetFocusScreen(oldFocus)==KErrNone && TheClient->iWs.GetFocusScreen()==oldFocus - Expected: %d and %d, Actual: %d and %d"),KErrNone, oldFocus, ret, TheClient->iWs.GetFocusScreen()); + + + // test case #3: set focus to screen N where screen N is empty (doesn't have any windows) + // expected result: KErrNotFound and focus stays on current screen + TInt i; + for(i=1;iiWs.SetFocusScreen(i); + TEST(ret==KErrNotReady && TheClient->iWs.GetFocusScreen()==oldFocus); + if (ret!=KErrNotReady || TheClient->iWs.GetFocusScreen()!=oldFocus) + INFO_PRINTF5(_L("TheClient->iWs.SetFocusScreen(i)==KErrNotReady && TheClient->iWs.GetFocusScreen()==oldFocus - Expected: %d and %d, Actual: %d and %d"),KErrNotReady, oldFocus, ret, TheClient->iWs.GetFocusScreen()); + } + + // test case #4: set focus to screen N where screen N has focus-able window + // expected result: KErrNone and focus is set to screen N + CArrayPtrFlat* wins; + wins=new(ELeave) CArrayPtrFlat(numberOfScreens); + CleanupStack::PushL(wins); + for(i=0;iConstructL(); + wins->AppendL(win); + } + + for(i=1;iiWs.SetFocusScreen(i); + TEST(ret==KErrNone && TheClient->iWs.GetFocusScreen()==i); + if (ret!=KErrNone || TheClient->iWs.GetFocusScreen()!=i) + INFO_PRINTF5(_L("TheClient->iWs.SetFocusScreen(i)==KErrNone && TheClient->iWs.GetFocusScreen()==i - Expected: %d and %d, Actual: %d and %d"),KErrNone, i, ret, TheClient->iWs.GetFocusScreen()); + + } + + // test case #5: set focus back from screen N to main screen (screen 0) + // expected result: KErrNone and focus is set to screen 0 + ret = TheClient->iWs.SetFocusScreen(0); + TEST(ret==KErrNone && TheClient->iWs.GetFocusScreen()==0); + if (ret!=KErrNone || TheClient->iWs.GetFocusScreen()!=0) + INFO_PRINTF5(_L("TheClient->iWs.SetFocusScreen(0)==KErrNone && TheClient->iWs.GetFocusScreen()==0 - Expected: %d and %d, Actual: %d and %d"),KErrNone, 0, ret, TheClient->iWs.GetFocusScreen()); + + CleanupStack::PopAndDestroy(numberOfScreens+1,wins); + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-0052 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Launch a test from a new process and check + that it passes indepenedent of screen focus + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Focus on a screen, launch a test process, + switch to focus on the other screen, then + then check the test process passed + +@SYMTestExpectedResults The test in the process passed +*/ +void CTMultiDisplay::DoScreenTestL(TInt aScreenNo) + { + _LIT(KSubTest,"Screen %d"); + TBuf<16> subMsg; + + const TInt numScreens=TheClient->iWs.NumberOfScreens(); + if (numScreens<=aScreenNo) + { + _LIT(KLog,"WARNING!! Cannot run test for screen %d as the device only has %d screens."); + LOG_MESSAGE3(KLog,aScreenNo,numScreens); + aScreenNo=numScreens-1; + } + + subMsg.AppendFormat(KSubTest,aScreenNo); + LOG_MESSAGE(subMsg); + + // Must switch focus screen to relevant screen manually + CMinWin* win=new(ELeave) CMinWin(aScreenNo); + CleanupStack::PushL(win); + win->ConstructL(); + TheClient->iWs.SetFocusScreen(aScreenNo); + + CleanupStack::PopAndDestroy(win); + TheClient->iWs.SetFocusScreen(0); + CTestBase::iScreenNo=aScreenNo; + + //Set CTestBase::iNumberOfGrpWndsOnPrimaryScreenWithZeroPriority with the number of window groups + //in default screen with priority zero. This will be used in TGwHandle test case. + CTestBase::iNumberOfGrpWndsOnPrimaryScreenWithZeroPriority = TheClient->iWs.NumWindowGroups(0) - 1; + } + +void CTMultiDisplay::RunTestCaseL(TInt /*aCurTestCase*/) + { + _LIT(KTest1,"Focus Screen"); + _LIT(KTest2,"Screen"); + ((CTMultiDisplayStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); + + switch (++iTest->iState) + { + case 1: + ((CTMultiDisplayStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0051")); + iTest->LogSubTest(KTest1); + DoFocusScreenTestL(); + break; + case 2: + ((CTMultiDisplayStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0052")); + iTest->LogSubTest(KTest2); + DoScreenTestL(1); + break; + default: + ((CTMultiDisplayStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + ((CTMultiDisplayStep*)iStep)->CloseTMSGraphicsStep(); + TestComplete(); + break; + } + ((CTMultiDisplayStep*)iStep)->RecordTestResultL(); + } + +__WS_CONSTRUCT_STEP__(MultiDisplay) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TMDISPLAY.H --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TMDISPLAY.H Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,61 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// TBLANK.H +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef __TMDISPLAY_H__ +#define __TMDISPLAY_H__ + +#include "AUTO.H" +#include "TGraphicsHarness.h" +#include "../tlib/testbase.h" + +class CTMultiDisplay : public CTWsGraphicsBase + { +public: + CTMultiDisplay(CTestStep* aStep); + CTMultiDisplay(); + void ConstructL(); + TestState DoTestL(); + ~CTMultiDisplay(); + +protected: +//from CTGraphicsStep + virtual void RunTestCaseL(TInt aCurTestCase); + +private: + void DoFocusScreenTestL(); + void DoScreenTestL(TInt aScreenNo); + }; + +class CTMultiDisplayStep : public CTGraphicsStep + { +public: + CTMultiDisplayStep(); +protected: + //from CTGraphicsStep + virtual CTGraphicsBase* CreateTestL(); + }; + +_LIT(KTMultiDisplayStep,"TMultiDisplay"); + + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TMESSAGE.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TMESSAGE.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,471 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + + +#include "TMESSAGE.H" + +const TInt KTotalNumberOfTestMessages=5; +const TInt KMaxNumOfMessagesInActiveQueue=21; +const TInt KMaxNumOfSyncMessages=25; +const TInt KNumOfTestCases=7; +TInt MsgCountCheck=0; +TInt SyncSendReceiveCount=0; +TUid UidAtFirstLocation; +TUid UidAtLastLocation; +TBool TestNeedsExtraCheck=EFalse; + +CTMessage::CTMessage(CTestStep* aStep) : CTWsGraphicsBase(aStep), iSyncSendReceiveFlag(EFalse), iCounter(-1), iState(0) + { + } + +TInt CTMessage::CreateAndSendMessages(TInt aCount,TInt aNoOfMessages) + { + CMessageReceiver* msgReceiver=(*iMessageReceiver)[iState]; + TInt identifer=msgReceiver->GroupWin()->Identifier(); + TInt length=aCount*2; + TUint8 modificationFactor=(TUint8 )(aCount*3+1); + TUint8 msgValue=0; + if(!iSyncSendReceiveFlag && TestNeedsExtraCheck) + { + if(aCount==0) + { + UidAtFirstLocation=TUid::Uid(length+(modificationFactor<<24)); + } + else if(aCount==(aNoOfMessages-1)) + { + UidAtLastLocation=TUid::Uid(length+(modificationFactor<<24)); + } + } + iMsg->Des().Zero(); + for(TInt index=0;indexDes().Append(msgValue); + } + return TheClient->iWs.SendMessageToWindowGroup(identifer, TUid::Uid(length+(modificationFactor<<24)), *iMsg); + } + +TInt CTMessage::CallbackLowPriority(TAny* aMessageTest) + { + return static_cast(aMessageTest)->SendSyncMessages(); + } + +TInt CTMessage::SendSyncMessages() + { + if(iSyncSendReceiveFlag && iCounter++iWs.NumWindowGroups(); //Make sure all asyncronus calls have been processed + CTEventBase& eventHandler=*TheClient->EventHandler(); + if (eventHandler.iStatus.Int()==KRequestPending) + CActiveScheduler::Stop(); + else + return ETrue; + return EFalse; + } + +CTMessage::~CTMessage() + { + iMessageReceiver->ResetAndDestroy(); + iMessageReceiver->Close(); + delete iMessageReceiver; + iLowPriorityObject->Cancel(); + delete iLowPriorityObject; + iLowPriorityObject=NULL; + delete iMsg; + } + +void CTMessage::ConstructL() + { + iLowPriorityObject= new(ELeave) CLowPriorityIdle(); + iMessageReceiver=new(ELeave) RPointerArray(KNumOfTestCases); + iMsg=HBufC8::NewL(KMaxNumOfSyncMessages*2); + for(TInt index=0;indexConstructL(); + iMessageReceiver->AppendL(messageReceiver); + } + } + + +CLowPriorityIdle::CLowPriorityIdle() : CIdle(EPriorityIdle) + { + CActiveScheduler::Add(this); + } + +TInt CLowPriorityIdle::RunError(TInt /*aError*/) + { + CActiveScheduler::Stop(); + return KErrNone; + } + +LOCAL_C TInt DoPanicTest(TInt aInt, TAny *) + { + switch(aInt) + { + case 1: + User::Panic(KWSERV,EWservPanicGcActive); + break; + } + return(EWsExitReasonBad); + } + +CMessageReceiver::CMessageReceiver(CTClient *aClient, CTMessage *aTMessage) : CTWindowGroup(aClient), iMsgCount(0) + { + iTMessage = aTMessage; + } + +#define MESSAGES_READ 1 //Change to 2 to test the 16-bit functions too. +void CMessageReceiver::MessageReady(const TWsEvent& aEvent) + { + iTMessage->OnMessageReceived(aEvent, iMsgCount); + } + +void CTMessage::OnMessageReceived(const TWsEvent& aEvent, TInt& aMsgCount) + { + aMsgCount++; + if(aMsgCount>MsgCountCheck) + { + return; + } + if (MESSAGES_READ*(aMsgCount/MESSAGES_READ)iWs.FetchMessage(uid, msgPtr, aEvent); + TEST(retValue==KErrNone); + //GroupWin()->FetchMessage(uid, msgPtr2); + if(TestNeedsExtraCheck) + { + TEST(uid==(aMsgCount==1?UidAtFirstLocation:UidAtLastLocation)); + } + TInt msgLength=(uid.iUid)&0xFFFFFF; + TUint8 uidFactor=(TUint8)((uid.iUid&0xFF000000)>>24); + TBool retVal = msgPtr.Length()==msgLength; + TEST(retVal); + if (!retVal) + INFO_PRINTF3(_L("msgPtr.Length()==msgLength - Expected: %d, Actual: %d"), msgLength, msgPtr.Length()); + + TUint8 check=0; + for(TInt index=0;indexTestWsPanicL(&DoPanicTest,EWservPanicGcActive,1)); + iTest->CloseAllPanicWindows(); + } + +void CTMessage::MessageTests(TInt aNoOfMessages,TInt aMsgCountCheck,TBool aSyncSendReceiveFlag,TBool aTestNeedsExtraCheck) + { + iSyncSendReceiveFlag=aSyncSendReceiveFlag; + TestNeedsExtraCheck=aTestNeedsExtraCheck; + MsgCountCheck=aMsgCountCheck; + iLowPriorityObject->Start(TCallBack(CallbackLowPriority,this)); + + if(iSyncSendReceiveFlag) + { + //Messages will be sent and received one by one using the function SendSyncMessages(). + CActiveScheduler::Start(); + } + else + { + for(TInt count=0;countMessageCount(); + TEST(msgCount==MsgCountCheck); + if (msgCount!=MsgCountCheck) + { + _LIT(KLog,"Number of messages recieved=%d expected=%d"); + LOG_MESSAGE3(KLog,msgCount,MsgCountCheck); + } + } + } + +/** + Test delivery group messages in case when event queue is overflow + */ +void CTMessage::TestMessageQueueOverflowL() + { + const TInt numMaxMessages = 60; + TInt numWasteMessages = 0; + TInt numWgMessages = 5; + + TInt gotRealWasteMessages = 0; + TInt gotRealWgMessages = 0; + + const TInt oneSecond = 1000000; + const TInt allPossibleMessages = 500; + + RWsSession senderWsSession; + RWindowGroup senderGroupWin; + TInt sndrHanGrpWin = 7777; + + RWsSession receiverWsSession; + RWindowGroup receiverGroupWin; + TInt rcvrHanGrpWin = 8888; + + TRequestStatus testStatus; + TRequestStatus timerStatus; + TWsEvent wasteEvent; + TWsEvent event; + + RTimer timer; + timer.CreateLocal(); + CleanupClosePushL(timer); + + // Create sender WsSession and the window group + User::LeaveIfError(senderWsSession.Connect()); + CleanupClosePushL(senderWsSession); + + senderGroupWin = RWindowGroup(senderWsSession); + User::LeaveIfError(senderGroupWin.Construct(sndrHanGrpWin)); + CleanupClosePushL(senderGroupWin); + + // Create reciever WsSession and the window group + User::LeaveIfError(receiverWsSession.Connect()); + CleanupClosePushL(receiverWsSession); + + receiverGroupWin = RWindowGroup(receiverWsSession); + User::LeaveIfError(receiverGroupWin.Construct(rcvrHanGrpWin)); + CleanupClosePushL(receiverGroupWin); + + TInt err = KErrNone; + + // Send waste events to the receiver and overflow the event queue + for (TInt ind = 0; ind < numMaxMessages; ind++) + { + wasteEvent.SetType(sndrHanGrpWin); + err = senderWsSession.SendEventToWindowGroup(receiverGroupWin.Identifier(), wasteEvent); + if (err != KErrNone) + { + numWasteMessages = ind; // Real number waste messages that was sent + break; + } + } + + // Send messages to the receiver + for (TInt ind = 0; ind < numWgMessages; ind++) + { + TInt uidData = ind + sndrHanGrpWin; + TPtr8 msg((unsigned char*) &uidData, sizeof(uidData)); + err = senderWsSession.SendMessageToWindowGroup(receiverGroupWin.Identifier(), TUid::Uid(uidData), msg); + if (err != KErrNone) + { + LOG_MESSAGE2(_L("UnExpected Error Code = %d"),err); + numWgMessages = ind; // Real number window group messages that was sent + } + } + + // Check and count sent messages + for (TInt ind = 0; ind < allPossibleMessages; ind++) + { + receiverWsSession.EventReady(&testStatus); + timer.After(timerStatus, oneSecond); + User::WaitForRequest(testStatus, timerStatus); + if (testStatus == 0) + { + // Test incoming events + receiverWsSession.GetEvent(event); + if (event.Type() == sndrHanGrpWin) + { + ++gotRealWasteMessages; + } + else if (event.Type() == EEventMessageReady) + { + if (gotRealWgMessages == 0) + { + for (TInt ind = 0; ind < numMaxMessages; ind++) + { + wasteEvent.SetType(sndrHanGrpWin); + err = senderWsSession.SendEventToWindowGroup(receiverGroupWin.Identifier(), wasteEvent); + if (err == KErrNone) + { + ++numWasteMessages; + } + else + { + break; + } + } + } + ++gotRealWgMessages; + TUid uid; + TPtr8 msgPtr(NULL,0); + err = receiverWsSession.FetchMessage(uid, msgPtr, event); + User::Free((TAny *) msgPtr.Ptr()); + } + // testStatus has been completed. Hence, Cancel the timer. + timer.Cancel(); + User::WaitForRequest(timerStatus); + } + else + { + // Times out, cancel the event notification + receiverWsSession.EventReadyCancel(); + User::WaitForRequest(testStatus); + // All events were recieved + break; + } + } + + LOG_MESSAGE3(_L("Got Waste message = %d expected =%d"),gotRealWasteMessages,numWasteMessages); + LOG_MESSAGE3(_L("Got Group message = %d expected =%d"),gotRealWgMessages,numWgMessages); + TEST(gotRealWasteMessages == numWasteMessages); + TEST(gotRealWgMessages == numWgMessages); + + CleanupStack::PopAndDestroy(&receiverGroupWin); + CleanupStack::PopAndDestroy(&receiverWsSession); + CleanupStack::PopAndDestroy(&senderGroupWin); + CleanupStack::PopAndDestroy(&senderWsSession); + CleanupStack::PopAndDestroy(&timer); + + TheClient->iWs.Flush(); + + } + +void CTMessage::RunTestCaseL(TInt /*aCurTestCase*/) + { + _LIT(KMsgTest0,"Message test 1"); + _LIT(KMsgTest1,"Message test 2"); + _LIT(KMsgTest2,"Message test 3"); + _LIT(KMsgTest3,"Message test 4"); + _LIT(KMsgTest4,"Message test 5"); + _LIT(KMsgTest5,"Message test 6"); + _LIT(KMsgTest6,"Message test 7"); + _LIT(KMsgTest7,"Message test 8 - when event queue is overflow"); + + iState=iTest->iState; // used by iMessageReceiver array + ((CTMessageStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); + switch(++iTest->iState) + { +/** +@SYMTestCaseID GRAPHICS-WSERV-0084 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test message sending and receiving + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Generates 5 short messages and sends them to window group, window group receives them + +@SYMTestExpectedResults Expects that received messages have the same length and the same content as those sent +*/ + case 1: + ((CTMessageStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0084")); + iTest->LogSubTest(KMsgTest0); + MessageTests(KTotalNumberOfTestMessages,KTotalNumberOfTestMessages,EFalse,EFalse); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0406 + +@SYMDEF DEF102201,DEF141447 + +@SYMTestCaseDesc Test message sending and receiving + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Generates some diffrent size of messages and sends them to window group, window group receives them + +@SYMTestExpectedResults Expects that received messages have the same length and the same content as those sent +*/ + case 2: + ((CTMessageStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0406")); + iTest->LogSubTest(KMsgTest1); + MessageTests(KMaxNumOfMessagesInActiveQueue-1,KMaxNumOfMessagesInActiveQueue-1,EFalse,EFalse); + break; + case 3: + ((CTMessageStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0406")); + iTest->LogSubTest(KMsgTest2); + MessageTests(KMaxNumOfMessagesInActiveQueue,2,EFalse,ETrue); + break; + case 4: + ((CTMessageStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0406")); + iTest->LogSubTest(KMsgTest3); + MessageTests(KMaxNumOfMessagesInActiveQueue+1,2,EFalse,ETrue); + break; + case 5: + ((CTMessageStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0406")); + iTest->LogSubTest(KMsgTest4); + MessageTests(KMaxNumOfMessagesInActiveQueue+2,2,EFalse,ETrue); + break; + case 6: + ((CTMessageStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0406")); + iTest->LogSubTest(KMsgTest5); + SyncSendReceiveCount=KMaxNumOfSyncMessages; + MessageTests(KMaxNumOfSyncMessages,KMaxNumOfSyncMessages,ETrue,EFalse); + break; + case 7: + ((CTMessageStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0406")); + iTest->LogSubTest(KMsgTest6); + MessageTests(KMaxNumOfMessagesInActiveQueue+1,2,EFalse,ETrue); + ((*iMessageReceiver)[iState])->ResetMessageCount(); + SyncSendReceiveCount=KTotalNumberOfTestMessages; + MessageTests(KTotalNumberOfTestMessages,KTotalNumberOfTestMessages,ETrue,EFalse); + break; + case 8: + ((CTMessageStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0406")); + iTest->LogSubTest(KMsgTest7); + TestMessageQueueOverflowL(); + ((CTMessageStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + ((CTMessageStep*)iStep)->CloseTMSGraphicsStep(); + TestComplete(); + return; + } + ((*iMessageReceiver)[iState])->ResetMessageCount(); + ((CTMessageStep*)iStep)->RecordTestResultL(); + } + + +__WS_CONSTRUCT_STEP__(Message) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TMESSAGE.H --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TMESSAGE.H Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,95 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef __TMESSAGE_H__ +#define __TMESSAGE_H__ + +#include +#include +#include "../tlib/testbase.h" +#include "AUTO.H" +#include "TGraphicsHarness.h" + +class CMessageReceiver; + +class CLowPriorityIdle : public CIdle + { +public: + CLowPriorityIdle(); + virtual TInt RunError(TInt aError); + }; + +class CTMessage : public CTWsGraphicsBase + { +public: + CTMessage(CTestStep* aStep); + ~CTMessage(); + void ConstructL(); + void TestPanicsL(); + void MessageTests(TInt aNoOfMessages,TInt aMsgCountCheck,TBool aSyncSendReceiveFlag,TBool aTestNeedsExtraCheck); + void OnMessageReceived(const TWsEvent &aEvent, TInt& aMsgCount); + TInt SendSyncMessages(); + static TInt CallbackLowPriority(TAny *aMessageTest); + TInt CreateAndSendMessages(TInt aCount,TInt aNoOfMessages); + void TestMessageQueueOverflowL(); + +protected: + virtual void RunTestCaseL(TInt aCurTestCase); + +private: + TBool iSyncSendReceiveFlag; + TInt iCounter; + HBufC8* iMsg; + RPointerArray* iMessageReceiver; + CLowPriorityIdle* iLowPriorityObject; + TInt iState; + }; + + +class CMessageReceiver : public CTWindowGroup + { +public: + CMessageReceiver(CTClient *aClient, CTMessage *aTMessage); + void MessageReady(const TWsEvent &aTime); + inline TInt MessageCount() + {return iMsgCount;} + inline void ResetMessageCount() + {iMsgCount=0;} +private: + CTMessage *iTMessage; // CTMessage, to call it's OnMessageReceived when message is received + TInt iMsgCount; + }; + + + +class CTMessageStep : public CTGraphicsStep + { +public: + CTMessageStep(); +protected: + //from CTGraphicsStep + virtual CTGraphicsBase* CreateTestL(); + }; + +_LIT(KTMessageStep,"TMessage"); + + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TMODCHG.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TMODCHG.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,511 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Coverted from TMan test code (TMMODCHG.CPP) August 2000 +// Test modifier changed message +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include "TMODCHG.H" + +#define LOGGING on //Uncoment this line to get extra logging + +struct TModifierChangedTestsParams + { + TText *txt; // Text message telling user what to do + TUint changed; + TUint state; + TUint stateMask; + }; + +LOCAL_D TModifierChangedTestsParams ModifierChangedTests[]={ + {(TText *)_S("Press Caps"),EModifierCapsLock,EModifierCapsLock,EModifierCapsLock}, + {(TText *)_S("Press Caps (again)"),EModifierCapsLock,0,EModifierCapsLock}, + {(TText *)_S("Press left shift"),EModifierShift|EModifierLeftShift,EModifierShift|EModifierLeftShift,EModifierShift|EModifierLeftShift}, + {(TText *)_S("Release left shift"),EModifierShift|EModifierLeftShift,0,EModifierShift|EModifierLeftShift}, + {(TText *)_S("Press right shift"),EModifierShift|EModifierRightShift,EModifierShift|EModifierRightShift,EModifierShift|EModifierRightShift}, + {(TText *)_S("Release right shift"),EModifierShift|EModifierRightShift,0,EModifierShift|EModifierRightShift}, + {(TText *)_S("Press (left) func"),EModifierFunc|EModifierLeftFunc,EModifierFunc|EModifierLeftFunc,EModifierFunc|EModifierLeftFunc}, + {(TText *)_S("Release (left) func"),EModifierFunc|EModifierLeftFunc,0,EModifierFunc|EModifierLeftFunc}, + {(TText *)_S("Press (left) control"),EModifierCtrl|EModifierLeftCtrl,EModifierCtrl|EModifierLeftCtrl,EModifierCtrl|EModifierLeftCtrl}, + {(TText *)_S("Release (left) control"),EModifierCtrl|EModifierLeftCtrl,0,EModifierCtrl|EModifierLeftCtrl}, + }; + +// list of ModifierEvents that should be monitored +LOCAL_D TInt ModifierChangedEvents=EModifierShift|EModifierLeftShift|EModifierRightShift| + EModifierCapsLock|EModifierFunc|EModifierLeftFunc|EModifierCtrl|EModifierLeftCtrl; + +const TInt numTests=sizeof(ModifierChangedTests)/sizeof(ModifierChangedTests[0]); + + +// +// CTEventWindowGroup class // +// + +CTEventWindowGroup::CTEventWindowGroup(CTClient *aClient, CTModifiersChanged *aTest) : CTWindowGroup(aClient), iTest(aTest) + {} + +void CTEventWindowGroup::ConstructL() + { + CTWindowGroup::ConstructL(); + iGroupWin.EnableModifierChangedEvents(ModifierChangedEvents,EEventControlAlways); + } + +void CTEventWindowGroup::ModifiersChanged(const TModifiersChangedEvent &aModifiersChanged, const TTime &) + { + iTest->TestModifiersState(aModifiersChanged); // tests if event is correct + } + +void CTEventWindowGroup::KeyL(const TKeyEvent &aKey,const TTime &) + { + if (aKey.iCode==EKeyEscape || (aKey.iCode==' ' && iTest->iModSetTest)) + iTest->EndTest(); // not really needed, because timer cancels long running tests + } + +// +// CMCWindow, class // +// + +CMCWindow::CMCWindow(CTModifiersChanged *aTest) : CTWin(), iTest(aTest) + { + iBack=TRgb::Gray256(230); + } + +void CMCWindow::SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc) + { + ConstructExtLD(*parent,pos,size); + iWin.SetBackgroundColor(iBack); + Activate(); + AssignGC(aGc); + iLineHeight=iFont->HeightInPixels()*5/4; + iFontAscent=iFont->AscentInPixels(); + iXpos1=4; + iXpos2=iXpos1+12*iFont->TextWidthInPixels(_L("M")); + } + +void CMCWindow::DrawModSetLine(const TDesC &aDes,TInt aModifier,TInt iSettableModifiers) + { + iYpos+=iLineHeight; + iGc->DrawText(aDes, TPoint(iXpos1,iYpos)); + iGc->DrawText(aModifier&iSettableModifiers ? _L("Yes"):_L("No"), TPoint(iXpos2,iYpos)); + } + +void CMCWindow::Draw() + { + iGc->Clear(); + if (iTest->iModSetTest) + { + iYpos=iFontAscent+3; + TBuf<32> buf; + buf.Format(TRefByValue(_L("Settable? [0x%4x]")), iTest->iSettable); + iGc->DrawText(_L("Modifier"), TPoint(iXpos1,iYpos)); + iGc->DrawText(buf, TPoint(iXpos2,iYpos)); + DrawModSetLine(_L("Shift"),EModifierShift,iTest->iSettable); + DrawModSetLine(_L("Left Shift"),EModifierLeftShift,iTest->iSettable); + DrawModSetLine(_L("Func"),EModifierFunc,iTest->iSettable); + DrawModSetLine(_L("Caps"),EModifierCapsLock,iTest->iSettable); + DrawModSetLine(_L("NumLock"),EModifierNumLock,iTest->iSettable); + DrawModSetLine(_L("Double Click"),EModifierDoubleClick,iTest->iSettable); + } + else + iGc->DrawText(TPtrC(ModifierChangedTests[iTest->SubState()].txt), TPoint(10,20)); + } + +// + +CTModifiersChanged::CTModifiersChanged(CTestStep* aStep): CTWsGraphicsBase(aStep), + iSkipFirstModifierEvents(EFalse), iSubSchedulerRunning(EFalse) + { + } + +CTModifiersChanged::~CTModifiersChanged() + { + delete iTimeOut; + delete iWin; + delete iEventGroup; + } + +void CTModifiersChanged::ConstructL() + { + iTimeOut=new(ELeave) CTimeOut(); + iTimeOut->ConstructL(); + iWin=new(ELeave) CMCWindow(this); + iWin->SetUpL(TPoint(10,10),TSize(240,200),Client()->iGroup, *Client()->iGc); + } + +TInt CTModifiersChanged::TimeOut(TAny* aTest) // static + { + static_cast(aTest)->TimeOut(); + return(KErrNone); + } + +void CTModifiersChanged::TimeOut() + { + #if defined(LOGGING) + _LIT(KLogTimeOut,"Test timed out after %d secs."); + LOG_MESSAGE2(KLogTimeOut,KTimeOutAfter/1000000); + #endif + EndTest(); + } + +void CTModifiersChanged::EndTest() + { + TEST(EFalse); // test failed (timeout or manually cancelled) + if (iModSetTest) + { + iModSetTest=EFalse; + iWin->Invalidate(); + } + _LIT(KLogEndTest,"EndTest - State %d - SubState %d"); + LOG_MESSAGE3(KLogEndTest,iTest->iState,iSubState); + if (iSubSchedulerRunning) + { + iSubSchedulerRunning = EFalse; + CActiveScheduler::Stop(); // stop the sub-scheduler, so test-framework can execute the next test + } + } + +TInt CTModifiersChanged::SubState() const + { + return(iSubState); + } + +void CTModifiersChanged::IncSubState() + { + if (iSubStateInvalidate(); + TheClient->WaitForRedrawsToFinish(); + SendEvents(); + } + else if (iSubState>=numTests-1) // test finished successfully + { + if (iSubSchedulerRunning) + { + iSubSchedulerRunning = EFalse; + CActiveScheduler::Stop(); // stop the sub-scheduler, so test-framework can execute the next test + } + } + } + +void CTModifiersChanged::TestModifiersState(const TModifiersChangedEvent &aModifiersChanged) + { + if (iTest->iState==1) // only if currently in test 1 (add another if for further tests) + { + TInt getMods=Client()->iWs.GetModifierState(); // double check the modifiers + #if defined(LOGGING) + if (iSkipFirstModifierEvents) + { + _LIT(KLogIgnored,"### This Event is part of the initial setup and is ignored for the test. ###"); + LOG_MESSAGE(KLogIgnored); + } + TLogMessageText buf; + _LIT(KLog1,"##MC1 SS=%x Test-Modifiers=0x%x Test-Changed=0x%x Test-Mask=0x%x"); + buf.Format(KLog1,iSubState,ModifierChangedTests[iSubState].state,ModifierChangedTests[iSubState].changed,ModifierChangedTests[iSubState].stateMask); + LOG_MESSAGE(buf); + _LIT(KLog2,"##MC2 Event-Modifiers=0x%x Event-Changed=0x%x Get-Modifiers=0x%x"); + buf.Format(KLog2,aModifiersChanged.iModifiers,aModifiersChanged.iChangedModifiers,getMods); + LOG_MESSAGE(buf); + _LIT(KLog3,"##MC3 Changed: (Event) 0x%x==0x%x (Test)"); + buf.Format(KLog3,aModifiersChanged.iChangedModifiers,ModifierChangedTests[iSubState].changed); + LOG_MESSAGE(buf); + _LIT(KLog4,"##MC4 Modifier (with mask): (Event) 0x%x==0x%x (Test)"); + buf.Format(KLog4,aModifiersChanged.iModifiers&ModifierChangedTests[iSubState].stateMask,ModifierChangedTests[iSubState].state); + LOG_MESSAGE(buf); + _LIT(KLog5,"##MC5 Modifier (with mask): (Get) 0x%x==0x%x (Test)"); + buf.Format(KLog5,getMods&ModifierChangedTests[iSubState].stateMask,ModifierChangedTests[iSubState].state); + LOG_MESSAGE(buf); + #endif + if (iSkipFirstModifierEvents) // skip the events caused by the initialization + { + if(--iSkipCounter<=0) + { + iSkipFirstModifierEvents = EFalse; + } + } + else + { + if (aModifiersChanged.iChangedModifiers==ModifierChangedTests[iSubState].changed && + (aModifiersChanged.iModifiers&ModifierChangedTests[iSubState].stateMask)==ModifierChangedTests[iSubState].state && + (getMods&ModifierChangedTests[iSubState].stateMask)==ModifierChangedTests[iSubState].state) + { + IncSubState(); // subtest is successfull + } + else + { + TEST(EFalse); // subtest failed + _LIT(KLogTestFailed,"Modifier Change test failed."); + LOG_MESSAGE(KLogTestFailed); + } + } + } // if test 1 + } + +void CTModifiersChanged::BadParams() + { + } + +/** + * Resets all the modifiers after the test is finished. Make sure that all keys used in the + * test are in the up-state. + */ +void CTModifiersChanged::ResetModifiers() + { + _LIT(KLogResetModifiersError,"Error %d occured while turning off modifier 0x%x"); + TInt err; + if ((err = Client()->iWs.SetModifierState(EModifierCapsLock,ETurnOffModifier)) != KErrNone) + LOG_MESSAGE3(KLogResetModifiersError,err, EModifierCapsLock); + if ((err = Client()->iWs.SetModifierState(EModifierShift,ETurnOffModifier)) != KErrNone) + LOG_MESSAGE3(KLogResetModifiersError,err, EModifierShift); + if ((err = Client()->iWs.SetModifierState(EModifierLeftShift,ETurnOffModifier)) != KErrNone) + LOG_MESSAGE3(KLogResetModifiersError,err, EModifierLeftShift); + if ((err = Client()->iWs.SetModifierState(EModifierRightShift,ETurnOffModifier)) != KErrNone) + LOG_MESSAGE3(KLogResetModifiersError,err, EModifierRightShift); + if ((err = Client()->iWs.SetModifierState(EModifierFunc,ETurnOffModifier)) != KErrNone) + LOG_MESSAGE3(KLogResetModifiersError,err, EModifierFunc); + if ((err = Client()->iWs.SetModifierState(EModifierLeftFunc,ETurnOffModifier)) != KErrNone) + LOG_MESSAGE3(KLogResetModifiersError,err, EModifierLeftFunc); + if ((err = Client()->iWs.SetModifierState(EModifierCtrl,ETurnOffModifier)) != KErrNone) + LOG_MESSAGE3(KLogResetModifiersError,err, EModifierCtrl); + if ((err = Client()->iWs.SetModifierState(EModifierLeftCtrl,ETurnOffModifier)) != KErrNone) + LOG_MESSAGE3(KLogResetModifiersError,err, EModifierLeftCtrl); + } + +/** + * Initialises the Modifier state. All tested modifiers must be in the up-state before the + * test starts. The number of sent key simulations needed for initialization is recorded. + * Each key simulation during initialization causes a ModifierChanged event which should be + * ignored because it's not part of the actual test. + */ +void CTModifiersChanged::ModifierChangedEventsL() + { + iEventGroup=new(ELeave) CTEventWindowGroup(Client(), this); + iEventGroup->ConstructL(); + TInt modifiers=Client()->iWs.GetModifierState(); + + if ((ModifierChangedEvents&modifiers)>0) // reset modifiers if they are in the down-state + { + iSkipFirstModifierEvents = ETrue; + if ((modifiers&EModifierCapsLock)>0) + { + iTest->SimulateKeyDownUp(EStdKeyCapsLock); + ++iSkipCounter; + modifiers=Client()->iWs.GetModifierState(); + } + if ((modifiers&EModifierLeftShift)>0) + { + iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeyLeftShift); + ++iSkipCounter; + modifiers=Client()->iWs.GetModifierState(); + } + if ((modifiers&EModifierRightShift)>0) + { + iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeyRightShift); + ++iSkipCounter; + modifiers=Client()->iWs.GetModifierState(); + } + if ((modifiers&EModifierLeftFunc)>0) + { + iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeyLeftFunc); + ++iSkipCounter; + modifiers=Client()->iWs.GetModifierState(); + } + if ((modifiers&EModifierLeftCtrl)>0) + { + iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeyLeftCtrl); + ++iSkipCounter; + } + } + modifiers=Client()->iWs.GetModifierState(); + _LIT(KLog,"Initial Modifiers state 0x%x (ideally should be zero)"); + LOG_MESSAGE2(KLog,modifiers); + } + +void CTModifiersChanged::CheckModifier(TEventModifier aModifier) + { + TBool retVal; + TInt oldMods=Client()->iWs.GetModifierState(); + Client()->iWs.SetModifierState(aModifier,EToggleModifier); + TInt getMods=Client()->iWs.GetModifierState(); + if (oldMods!=getMods) + { + _LIT(KLogOff,"Attempted to turn off modifiers 0x%x, 0x%x still on"); + _LIT(KLogOn,"Attempted to turn on modifiers 0x%x, 0x%x still off"); + iSettable|=aModifier; + Client()->iWs.SetModifierState(aModifier,ETurnOffModifier); + getMods=Client()->iWs.GetModifierState(); + retVal=!(getMods&aModifier); + TEST(retVal); + if (!retVal) + LOG_MESSAGE3(KLogOff,aModifier,getMods&aModifier); + Client()->iWs.SetModifierState(aModifier,ETurnOnModifier); + getMods=Client()->iWs.GetModifierState(); + retVal=getMods&aModifier; + TEST(retVal); + if (!retVal) + LOG_MESSAGE3(KLogOn,aModifier,getMods&aModifier); + Client()->iWs.SetModifierState(aModifier,ETurnOffModifier); + getMods=Client()->iWs.GetModifierState(); + retVal=!(getMods&aModifier); + TEST(retVal); + if (!retVal) + LOG_MESSAGE3(KLogOff,aModifier,getMods&aModifier); + if (oldMods&aModifier) + Client()->iWs.SetModifierState(aModifier,ETurnOnModifier); + } + else + { + Client()->iWs.SetModifierState(aModifier,ETurnOffModifier); + retVal=oldMods==Client()->iWs.GetModifierState(); + TEST(retVal); + if (!retVal) + { + _LIT(KLog,"Attempted to turn off modifiers 0x%x, suceeded when it should have failed"); + LOG_MESSAGE2(KLog,aModifier); + } + Client()->iWs.SetModifierState(aModifier,ETurnOnModifier); + retVal=oldMods==Client()->iWs.GetModifierState(); + TEST(retVal); + if (!retVal) + { + _LIT(KLog,"Attempted to turn on modifiers 0x%x, suceeded when it should have failed"); + LOG_MESSAGE2(KLog,aModifier); + } + } + } + +void CTModifiersChanged::SetModifiers() + { + iModSetTest=ETrue; + for(TInt mod=1;mod!=0;mod<<=1) + CheckModifier((TEventModifier)mod); + iWin->Invalidate(); + Client()->iWs.Flush(); + } + +void CTModifiersChanged::SendEvents() + { + iTest->LogSubState(iSubState); + switch (iSubState) + { + case 0: + iTest->SimulateKeyDownUp(EStdKeyCapsLock); + break; + case 1: + iTest->SimulateKeyDownUp(EStdKeyCapsLock); + break; + case 2: + iTest->SimulateKey(TRawEvent::EKeyDown,EStdKeyLeftShift); + break; + case 3: + iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeyLeftShift); + break; + case 4: + iTest->SimulateKey(TRawEvent::EKeyDown,EStdKeyRightShift); + break; + case 5: + iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeyRightShift); + break; + case 6: + iTest->SimulateKey(TRawEvent::EKeyDown,EStdKeyLeftFunc); + break; + case 7: + iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeyLeftFunc); + break; + case 8: + iTest->SimulateKey(TRawEvent::EKeyDown,EStdKeyLeftCtrl); + break; + case 9: + iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeyLeftCtrl); + break; + default: + TEST(EFalse); + return; + } + TheClient->iWs.Flush(); + } + +void CTModifiersChanged::RunTestCaseL(TInt /*aCurTestCase*/) + { + _LIT(KModChange,"Modifier Change"); + _LIT(KTestErrors,"Bad Parameter"); + ((CTModifiersChangedStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); + switch(++iTest->iState) + { +/** +@SYMTestCaseID GRAPHICS-WSERV-0239 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test modifier changed message + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Test that modifier changed message functions correctly + +@SYMTestExpectedResults The message functions correctly +*/ + case 1: + ((CTModifiersChangedStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0239")); + iTest->LogSubTest(KModChange); + ModifierChangedEventsL(); + // start a timer to cancel the sub-scheduler + iTimeOut->Start(KTimeOutAfter,TCallBack(CTModifiersChanged::TimeOut,this)); + SendEvents(); + iSubSchedulerRunning = ETrue; + CActiveScheduler::Start(); // sub-scheduler blocks this AO (test-framework) until completion + iTimeOut->Cancel(); + ((CTModifiersChangedStep*)iStep)->RecordTestResultL(); + ((CTModifiersChangedStep*)iStep)->CloseTMSGraphicsStep(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0240 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test bad parameters for modifier changed message + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Test using bad parameters for a modifier changed message + +@SYMTestExpectedResults Responds correctly when bad parameters are used +*/ + case 2: + ((CTModifiersChangedStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0240")); + iTest->LogSubTest(KTestErrors); + BadParams(); + ((CTModifiersChangedStep*)iStep)->RecordTestResultL(); + break; + default: + ResetModifiers(); // reset modifiers, so further tests are not influenced + ((CTModifiersChangedStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + ((CTModifiersChangedStep*)iStep)->CloseTMSGraphicsStep(); + TestComplete(); + } + + + } + +__WS_CONSTRUCT_STEP__(ModifiersChanged) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TMODCHG.H --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TMODCHG.H Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,116 @@ + +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef __TMODCHG_H__ +#define __TMODCHG_H__ + +#include +#include +#include +#include "../tlib/testbase.h" +#include "AUTO.H" +#include "TGraphicsHarness.h" + + +class CTModifiersChanged; + +class CMCWindow : public CTWin + { +public: + CMCWindow(CTModifiersChanged *aTest); + void SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc); + void Draw(); + void DrawModSetLine(const TDesC &aDes,TInt aModifier,TInt iSettableModifiers); +protected: + CTModifiersChanged *iTest; + TRgb iBack; + TInt iLineHeight; + TInt iFontAscent; + TInt iYpos; + TInt iXpos1; + TInt iXpos2; + }; + +class CTEventWindowGroup : public CTWindowGroup + { +public: + CTEventWindowGroup(CTClient *aClient, CTModifiersChanged *iTest); + void ConstructL(); + void ModifiersChanged(const TModifiersChangedEvent &aModifiersChanged ,const TTime &aTime); + void KeyL(const TKeyEvent &aKey,const TTime &aTime); +private: + CTModifiersChanged *iTest; + }; + +class CTModifiersChanged : public CTWsGraphicsBase + { +public: + CTModifiersChanged(CTestStep* aStep); + ~CTModifiersChanged(); + TestState DoTestL(); + void ConstructL(); + void EndTest(); + TInt SubState() const; + void IncSubState(); + void BadParams(); + void ModifierChangedEventsL(); + void SetModifiers(); + void CheckModifier(TEventModifier aModifier); + void TestModifiersState(const TModifiersChangedEvent &aModifiersChanged); +protected: +//from CTGraphicsStep + virtual void RunTestCaseL(TInt aCurTestCase); +private: + inline TestClient* Client() {return TheClient;} + void SendEvents(); + void ResetModifiers(); + static TInt TimeOut(TAny* aTest); + void TimeOut(); +public: + TBool iModSetTest; + TInt iSettable; +private: + enum {KTimeOutAfter=30000000}; // 30 seconds (test takes 8 sec on h4) +private: + TSize iWinSize; + TInt iSubState; + CTEventWindowGroup *iEventGroup; + CMCWindow *iWin; + TBool iSkipFirstModifierEvents; + TInt iSkipCounter; + CTimeOut* iTimeOut; + TBool iSubSchedulerRunning; + }; + +class CTModifiersChangedStep : public CTGraphicsStep + { +public: + CTModifiersChangedStep(); +protected: + //from CTGraphicsStep + virtual CTGraphicsBase* CreateTestL(); + }; + +_LIT(KTModifiersChangedStep,"TModifiersChanged"); + + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TMULSCREENS.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TMULSCREENS.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,666 @@ +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Enable Multiple Displays +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include "TMULSCREENS.h" + +const TInt KFstScreenNo = 0; +const TInt KSndScreenNo = 1; + +CTMulScreens::CTMulScreens(CTestStep* aStep): + CTWsGraphicsBase(aStep) + { + } + +void CTMulScreens::ConstructL() + { + User::LeaveIfError(iRws.Connect()); + iFstScreenDevice =new(ELeave) CWsScreenDevice(iRws); + TInt err = iFstScreenDevice->Construct(KFstScreenNo); + iTest->LogLeave(err); + User::LeaveIfError(err); + iNumScreens = iRws.NumberOfScreens(); + if(KSndScreenNoConstruct(KSndScreenNo); + iTest->LogLeave(err); + User::LeaveIfError(err); + } + INFO_PRINTF2(_L("The number of screens supported on this device is %d"),iNumScreens); + } + +CTMulScreens::~CTMulScreens() + { + iFstWinGp.Close(); + if(KSndScreenNo* aWindowList,TInt aScreenNumber,TInt aPriority) + TInt RWindowGroup::Construct(TUint32 aClientHandle,CWsScreenDevice* aScreenDevice) + TInt RWsSession::GetFocusWindowGroup(TInt aScreenNumber) + + @SYMTestExpectedResults Provided that a second screen is configured in the epoc.ini and the wsini.ini, this test case will create one window group on the first screen + and two window groups on the second screen. + If only one screen is configured, then it will create one group on the primary screen. + Otherwise this function leaves with a system-wide error. +*/ + +void CTMulScreens::TestCreateGroupWindowsL() + { + const TInt fstNumWinGps = iRws.NumWindowGroups(KFstScreenNo,EAllPriorities); + CArrayFixFlat* fstList = new(ELeave) CArrayFixFlat(1); + CleanupStack::PushL(fstList); + TInt err = iRws.WindowGroupList(fstList,KFstScreenNo,EAllPriorities); + TEST(err==KErrNone); + TEST(fstList->Count()==fstNumWinGps); + err = iRws.WindowGroupList(fstList); //test existing api + TEST(err==KErrNone); + TEST(fstList->Count()==(iRws.NumWindowGroups())); + iFstWinGp = RWindowGroup(iRws); + TRAP(err,iFstWinGp.Construct(ENullWsHandle,iFstScreenDevice)); + TEST(err==KErrNone); + if(err==KErrNone) + { + TEST(iRws.NumWindowGroups(KFstScreenNo,EAllPriorities) == (fstNumWinGps+1)); + } + CleanupStack::PopAndDestroy(fstList); + + //Second screen has been configured. + if(KSndScreenNo* sndList =new(ELeave) CArrayFixFlat(1); + CleanupStack::PushL(sndList); + TInt sndNumWinGps = iRws.NumWindowGroups(KSndScreenNo,iSndWinGp.OrdinalPriority()); + err = iRws.WindowGroupList(sndList,KSndScreenNo,iSndWinGp.OrdinalPriority()); + TEST(err==KErrNone); + TEST(sndList->Count()==sndNumWinGps); + + iSndWinGp.SetOrdinalPosition(iSndWinGp.OrdinalPosition(),EAllPriorities); + TInt allPriNumWinGps= iRws.NumWindowGroups(EAllPriorities); + CArrayFixFlat* allPriList =new(ELeave) CArrayFixFlat(1); + CleanupStack::PushL(allPriList); + err = iRws.WindowGroupList(EAllPriorities,allPriList); + TEST(err==KErrNone); + TEST(allPriList->Count()==allPriNumWinGps); + + CleanupStack::PopAndDestroy(2,sndList); + } + RWindowGroup trdWinGp = RWindowGroup(iRws); + TRAP(err,trdWinGp.Construct(ENullWsHandle,ETrue,iSndScreenDevice)); + TEST(err==KErrNone); + if(err==KErrNone) + { + winId = iRws.GetFocusWindowGroup(KSndScreenNo); + TEST(winId==trdWinGp.Identifier()); + trdWinGp.Close(); + } + } + } + +/** + @SYMTestCaseID GRAPHICS-WSERV-0384 + + @SYMPREQ PREQ1227 + + @SYMREQ REQ5541 + + @SYMTestCaseDependencies SYMTestCaseID GRAPHICS-WSERV-0383 + + @SYMTestCaseDesc Create a blank window on each screen. + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions Test that each blank window is created on a different screen. + API Calls:\n + TInt RBlankWindow::Construct(const RWindowTreeNode &parent, TUint32 aClientHandle) where parent is + a Window Group created on each screen. + + @SYMTestExpectedResults The background colour of the first screen changes to blue and that of the second one changes to green. + Otherwise this function leaves with a system-wide error. +*/ +void CTMulScreens::TestCreateBlankWindowsL() + { + RBlankWindow fstBlankWin(iRws); + CleanupClosePushL(fstBlankWin); + TRAPD(err,fstBlankWin.Construct(iFstWinGp,ENullWsHandle)); + TEST(err==KErrNone); + if(err==KErrNone) + { + fstBlankWin.SetRequiredDisplayMode(EColor256); + fstBlankWin.SetColor(TRgb(0,0,255)); // paint the screen blue + fstBlankWin.Activate(); + iRws.Flush(); + TheClient->WaitForRedrawsToFinish(); + User::After(6000000); + } + CleanupStack::PopAndDestroy();//fstBlankWin + + // Second screen + if(KSndScreenNoWaitForRedrawsToFinish(); + User::After(6000000); + } + CleanupStack::PopAndDestroy(); //sndBlankWin + } + } + + +/** + @SYMTestCaseID GRAPHICS-WSERV-0385 + + @SYMPREQ PREQ1227 + + @SYMREQ REQ5541 + + @SYMTestCaseDependencies SYMTestCaseID GRAPHICS-WSERV-0383 + + @SYMTestCaseDesc Test the Window Group that has the keyboard focus for each screen. + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions Call RWsSession::GetFocusWindowGroup on each screen. + API Calls:\n + TInt RWsSession::GetFocusWindowGroup(TInt aScreenNumber) + + @SYMTestExpectedResults The identifier returned by the API for each screen is tested to see if it is the expected Window Group ID; ie the + ID of the window group created in the first test case. +*/ +void CTMulScreens::TestGetFocusWindow() + { + TInt winId = iRws.GetFocusWindowGroup(KFstScreenNo); + TEST(winId==iFstWinGp.Identifier()); + if(KSndScreenNo* aWindowList,TInt aScreenNumber,TInt aPriority) + TInt RWsSession::GetFocusWindowGroup(TInt aScreenNumber) + TInt GetDefaultOwningWindow(TInt aScreenNumber) + TDisplayMode GetDefModeMaxNumColors(TInt aScreenNumber,TInt& aColor,TInt& aGray) const + TInt GetColorModeList(TInt aScreenNumber,CArrayFixFlat* aModeList) const + + @SYMTestExpectedResults The thread panics and exits with reason EWservPanicScreenNumber. +*/ +void CTMulScreens::TestPanicsL() + { + TInt firstTest = 1; + TInt lastTest = 6; + const TInt KInvalidScreenNumber = 2; + for (TInt option=firstTest;option<=lastTest;option++) + { + TEST(iTest->TestWsPanicL(&TestInvalidScreenNumberL,EWservPanicScreenNumber,option,(TAny*)KInvalidScreenNumber)); + } + } + +TInt CTMulScreens::TestInvalidScreenNumberL(TInt aOption, TAny *aScreenNumber) + { + RWsSession wsSession; + wsSession.Connect(); + switch((TInt)aOption) + { + case 1: + wsSession.NumWindowGroups((TInt)aScreenNumber,EAllPriorities); + break; + case 2: + { + CArrayFixFlat* list = new(ELeave) CArrayFixFlat(1); + wsSession.WindowGroupList(list,(TInt)aScreenNumber,EAllPriorities); + } + break; + case 3: + wsSession.GetFocusWindowGroup((TInt)aScreenNumber); + break; + case 4: + wsSession.GetDefaultOwningWindow((TInt)aScreenNumber); + break; + case 5: + { + CArrayFixFlat* list = new(ELeave) CArrayFixFlat(1); + wsSession.GetColorModeList((TInt)aScreenNumber,list); + } + break; + case 6: + { + TInt color,gray; + wsSession.GetDefModeMaxNumColors((TInt)aScreenNumber,color,gray); + } + break; + default: + User::Panic(_L("Default panic"),KErrGeneral); + break; + } + return KErrNone; + } + + +/** + @SYMTestCaseID GRAPHICS-WSERV-0390 + + @SYMPREQ PREQ1227 + + @SYMREQ REQ5541 + + @SYMTestCaseDependencies SYMTestCaseID GRAPHICS-WSERV-0383 + + @SYMTestCaseDesc Test that CWindowGc updates its screendevice each time it is activated on a window. + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions Activate the gc on both RWindows.CWindowGc::Device() is called after each activation has taken place. + API Calls:\n + void CWindowGc::Activate(RDrawableWindow &aDevice); + void CWindowGc::Deactivate(); + CGraphicsDevice* CWindowGc::Device() const + TInt RWindow::Construct(const RWindowTreeNode &parent,TUint32 aHandle); + + @SYMTestExpectedResults CWindowGc::Device() returns the screendevice on which the gc was last activated. +*/ +void CTMulScreens::TestDeviceL() + { + RWindow fstWin(iRws); + User::LeaveIfError(fstWin.Construct(iFstWinGp,ENullWsHandle)); + CleanupClosePushL(fstWin); + fstWin.Activate(); + + CWindowGc* gc=new (ELeave) CWindowGc(iFstScreenDevice); + User::LeaveIfError(gc->Construct()); + CleanupStack::PushL(gc); + gc->Activate(fstWin); + + TEST((CWsScreenDevice*)gc->Device()==iFstScreenDevice); + gc->Deactivate(); + + if(KSndScreenNoActivate(sndWin); + TEST((CWsScreenDevice*)gc->Device()==iSndScreenDevice); + gc->Deactivate(); + CleanupStack::PopAndDestroy(); + } + + CleanupStack::PopAndDestroy(2,&fstWin); + } + +/** + @SYMTestCaseID GRAPHICS-WSERV-0034 + + @SYMPREQ PREQ1227 + + @SYMREQ REQ5541 + + @SYMTestCaseDesc Test that the order of creating a screen device and window group does not matter. + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions Create a window group before creating the screen device. Create a graphics context and call activate on it. + API Calls:\n + TInt RWindowGroup::Construct(TUint32 aClientHandle) + TInt CWsScreenDevice::Construct() + void CWindowGc::Activate(RDrawableWindow &aDevice); + void CWindowGc::Deactivate(); + TInt RWindow::Construct(const RWindowTreeNode &parent,TUint32 aHandle); + + @SYMTestExpectedResults The test code does not panic with EWservPanicGroupWinScreenDeviceDeleted +*/ +void CTMulScreens::TestInitaliseScreenDeviceL() + { + RWsSession rws1; + User::LeaveIfError(rws1.Connect()); + CleanupClosePushL(rws1); + + RWindowGroup gw1(rws1); + User::LeaveIfError(gw1.Construct(ENullWsHandle)); + CleanupClosePushL(gw1); + + CWsScreenDevice* screen1 = new (ELeave) CWsScreenDevice(rws1); + User::LeaveIfError(screen1->Construct()); + CleanupStack::PushL(screen1); + + RWindow win1(rws1); + User::LeaveIfError(win1.Construct(gw1,ETrue)); + CleanupClosePushL(win1); + win1.Activate(); + + CWindowGc* gc=new (ELeave) CWindowGc(screen1); + User::LeaveIfError(gc->Construct()); + CleanupStack::PushL(gc); + gc->Activate(win1); + + CleanupStack::PopAndDestroy(5,&rws1); + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-0492 + +@SYMDEF PDEF126432 + +@SYMTestCaseDesc Test the screen number that a window is located on + +@SYMTestPriority Medium + +@SYMTestStatus Implemented + +@SYMTestActions Create two windows on two screens respectively + and check the screen number that each window is located on + +@SYMTestExpectedResults The screen numbers should match the expected ones +*/ +void CTMulScreens::TestScreenNumbersOfWindowsL() + { + // First screen + RWindow fstWin(iRws); + CleanupClosePushL(fstWin); + TRAPD(err,fstWin.Construct(iFstWinGp,ENullWsHandle)); + TEST(err==KErrNone); + if(err==KErrNone) + { + fstWin.Activate(); + iRws.Flush(); + } + TEST(fstWin.ScreenNumber()==KFstScreenNo); + CleanupStack::PopAndDestroy();//fstWin + + // Second screen + if(KSndScreenNoSetTestStepID(KUnknownSYMTestCaseIDName); + + switch(aCurTestCase) + { + case 1: + ((CTMulScreensStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0383")); + INFO_PRINTF1(KTest0); + TestCreateGroupWindowsL(); + break; + case 2: + ((CTMulScreensStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0384")); + INFO_PRINTF1(KTest1); + TestCreateBlankWindowsL(); + break; + case 3: + ((CTMulScreensStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0385")); + INFO_PRINTF1(KTest2); + TestGetFocusWindow(); + case 4: + ((CTMulScreensStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0386")); + INFO_PRINTF1(KTest3); + TestGetDefaultOwningWindow(); + break; + case 5: + ((CTMulScreensStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0387")); + INFO_PRINTF1(KTest4); + TestSetBackgroundColour(); + break; + case 6: + ((CTMulScreensStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0388")); + INFO_PRINTF1(KTest5); + TestSetShadowVector(); + break; + case 7: + ((CTMulScreensStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0389")); + INFO_PRINTF1(KTest6); + TestPanicsL(); + break; + case 8: + ((CTMulScreensStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0390")); + INFO_PRINTF1(KTest7); + TestDeviceL(); + break; + case 9: + ((CTMulScreensStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0034")); + INFO_PRINTF1(KTest8); + TestInitaliseScreenDeviceL(); + break; + case 10: + ((CTMulScreensStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0492")); + INFO_PRINTF1(KTest9); + TestScreenNumbersOfWindowsL(); + case 11: + ((CTMulScreensStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + ((CTMulScreensStep*)iStep)->CloseTMSGraphicsStep(); + INFO_PRINTF1(_L("All tests completed.\n")); + TestComplete(); + break; + default: + ((CTMulScreensStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + ((CTMulScreensStep*)iStep)->CloseTMSGraphicsStep(); + INFO_PRINTF1(_L("CTMulScreens::RunTestCaseL default case\n")); + break; + } + ((CTMulScreensStep*)iStep)->RecordTestResultL(); + } + +__WS_CONSTRUCT_STEP__(MulScreens) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TMULSCREENS.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TMULSCREENS.h Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,73 @@ +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Enable Multiple Displays +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef __TMULSCREENS_H__ +#define __TMULSCREENS_H__ + +#include +#include +#include "AUTO.H" +#include "TGraphicsHarness.h" + +class CTMulScreens : public CTWsGraphicsBase + { +public: + CTMulScreens(CTestStep* aStep); + ~CTMulScreens(); +protected: +//from CTGraphicsStep + virtual void RunTestCaseL(TInt aCurTestCase); +private: + void ConstructL(); + void TestCreateGroupWindowsL(); + void TestCreateBlankWindowsL(); + void TestGetFocusWindow(); + void TestGetDefaultOwningWindow(); + void TestSetBackgroundColour(); + void TestSetShadowVector(); + void TestPanicsL(); + static TInt TestInvalidScreenNumberL(TInt aOption,TAny* aScreenNumber); + void TestInitaliseScreenDeviceL(); + void TestScreenNumbersOfWindowsL(); + void TestDeviceL(); +private: + RWsSession iRws; + CWsScreenDevice* iFstScreenDevice; + CWsScreenDevice* iSndScreenDevice; + RWindowGroup iFstWinGp; + RWindowGroup iSndWinGp; + TInt iNumScreens; + }; + +class CTMulScreensStep : public CTGraphicsStep + { +public: + CTMulScreensStep(); +protected: + //from CTGraphicsStep + virtual CTGraphicsBase* CreateTestL(); + }; + +_LIT(KTMulScreensStep,"TMulScreens"); + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TMULTCON.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TMULTCON.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,478 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Test multiple connections to the window server +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include "TMULTCON.H" + +const TInt EMaxSubState=3; + +//#define LOGGING on //Uncomment this line to get extra logging + +_LIT(ClickOnMe,"Click on me"); +_LIT(KError,"ERROR"); + + +CTMultiCon::CTMultiCon(CTestStep* aStep) : CTWsGraphicsBase(aStep) + { + } + +CTMultiCon::~CTMultiCon() + { + delete iConn1; + delete iConn2; + delete iConn3; + delete iTimeOut; + } + +void CTMultiCon::EndAutoForegroundTest() + { +#if defined(LOGGING) + _LIT(KLog,"EndAutoForegroundTest SubState %d"); + LOG_MESSAGE2(KLog,iSubState); +#endif + iConn1->iGroup->GroupWin()->EnableReceiptOfFocus(EFalse); + iConn2->iGroup->GroupWin()->EnableReceiptOfFocus(EFalse); + iConn3->iGroup->GroupWin()->EnableReceiptOfFocus(EFalse); + CActiveScheduler::Stop(); + } + +void CTMultiCon::ConstructL() + { + iTimeOut=new(ELeave) CTimeOut(); + iTimeOut->ConstructL(); + TheClient->iWs.SetPointerCursorArea(iTest->iNormalPointerCursorArea); + iScreenSize=TSize(TheClient->iScreen->SizeInPixels()); + iConn3=new(ELeave) CMcConnectionDef(this); + iConn3->ConstructL(); + iConn2=new(ELeave) CMcConnection(this); + iConn2->ConstructL(); + iConn1=new(ELeave) CMcConnectionAf(this); + iConn1->ConstructL(); + iTest->SimulateKeyDownUp(EStdKeyLeftCtrl); + iTest->SimulateKeyDownUp(EStdKeyRightCtrl); + TInt mods=TheClient->iWs.GetModifierState(); + _LIT(KLog,"Initial Modifiers state 0x%x (ideally should be zero)"); + LOG_MESSAGE2(KLog,mods); + } + +TInt CTMultiCon::TimeOut(TAny* aTest) //static + { + static_cast(aTest)->TimeOut(); + return(KErrNone); + } + +void CTMultiCon::TimeOut() + { + TLogMessageText buf; + _LIT(KMultiConTimeOut,"TIMEOUT: Multiple Conection Test, %d, %S"); + buf.AppendFormat(KMultiConTimeOut,iTest->iState,&iTest->iSubTitle); + TheClient->LogMessage(buf); + ++iTimeOutCount; + EndAutoForegroundTest(); + } + + +// +// CMcConnection // +// + +CMcConnectionBase::CMcConnectionBase(CTMultiCon *aTest) : iTest(aTest) + { + } + +CMcConnectionBase::~CMcConnectionBase() + { + CTWin::Delete(iWin); + delete iGc; + } + +void CMcConnectionBase::SubStateChanged() + { + iWin->Invalidate(); + iWs.Flush(); + } + +void CMcConnectionBase::ConstructL() + { + CTClient::SetScreenNumber(iTest->ScreenNumber()); + CTClient::ConstructL(); + User::LeaveIfError(iScreen->CreateContext(iGc)); + } + +CMcConnection::CMcConnection(CTMultiCon *aTest) : CMcConnectionBase(aTest) + { + } + +void CMcConnection::ConstructL() + { + CMcConnectionBase::ConstructL(); + iGroup=new(ELeave) CTWindowGroup(this); + iGroup->ConstructL(); + TSize screenSize=iGroup->Size(); + TInt winWidth=screenSize.iWidth/3; + TInt winHeight=screenSize.iHeight/2-10; + iGroup->GroupWin()->AutoForeground(EFalse); + CMcWindow *win=new(ELeave) CMcWindow(iTest); + win->SetUpL(TPoint(5,5),TSize(winWidth,winHeight),iGroup,*iGc); + iWin=win; + iWs.Flush(); + } + +CMcConnectionAf::CMcConnectionAf(CTMultiCon *aTest) : CMcConnectionBase(aTest) + { + } + +void CMcConnectionAf::ConstructL() + { + CMcConnectionBase::ConstructL(); + iGroup=new(ELeave) CMcWindowGroupAf(this); + iGroup->ConstructL(); + TSize screenSize=iGroup->Size(); + TInt winWidth=screenSize.iWidth/3; + TInt winHeight=screenSize.iHeight/2-10; + iGroup->GroupWin()->AutoForeground(ETrue); + CMcWindowAf *win=new(ELeave) CMcWindowAf(iTest); + win->SetUpL(TPoint(winWidth,5),TSize(winWidth,winHeight),iGroup,*iGc); + iWin=win; + iWs.Flush(); + } + +void CMcConnectionAf::KeyL(const TKeyEvent &aKey) + { +#if defined(LOGGING) + _LIT(KLog1,"KeyL SS=%d (0) GpWinOrdPos=%d (0) Code=%d (32)"); + _LIT(KLog2," '%c'"); + TLogMessageText buf; + buf.Format(KLog1,iTest->SubState(),iGroup->GroupWin()->OrdinalPosition(),aKey.iCode); + if (aKey.iCode>0) + buf.AppendFormat(KLog2,aKey.iCode); + iTest->LOG_MESSAGE(buf); +#endif + switch(aKey.iCode) + { + case ' ': + if (iTest->SubState()==0) + { + iTest->TEST(iGroup->GroupWin()->OrdinalPosition()==0); + iTest->IncSubState(); + } + break; + case EKeyEscape: + iTest->EndAutoForegroundTest(); + break; + } + } + +CMcConnectionDef::CMcConnectionDef(CTMultiCon *aTest) : CMcConnectionBase(aTest) + { + } + +void CMcConnectionDef::ConstructL() + { + CMcConnectionBase::ConstructL(); + iGroup=new(ELeave) CTWindowGroup(this); + iGroup->ConstructL(); + iGroup->GroupWin()->EnableReceiptOfFocus(EFalse); + TSize screenSize=iGroup->Size(); + TInt winWidth=screenSize.iWidth/3-10; + TInt winHeight=(screenSize.iHeight/2)-10; + CMcWindowDef *win=new(ELeave) CMcWindowDef(iTest); + win->SetUpL(TPoint(5+winWidth/2,screenSize.iHeight/2),TSize(winWidth,winHeight),iGroup,*iGc); + iWin=win; + iWs.Flush(); + } + +// +// CMcWindow, base class // +// + +CMcWindowBase::CMcWindowBase(CTMultiCon *aTest) : CTWin(), iTest(aTest) + { + } + +void CMcWindowBase::SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc) + { + ConstructExtLD(*parent,pos,size); + iWin.SetBackgroundColor(iBack); + Activate(); + AssignGC(aGc); + } + +// +// CMcWindow, window used to test multiple connections // +// + +CMcWindow::CMcWindow(CTMultiCon *aTest) : CMcWindowBase(aTest) + { + iBack=TRgb::Gray256(221); + } + +void CMcWindow::PointerL(const TPointerEvent &pointer,const TTime &) + { +#if defined(LOGGING) + _LIT(KLog,"Pointer SS=%d (1) Type=%d (%d) GpWinOrdPos=%d (1)"); + iTest->LOG_MESSAGE5(KLog,iTest->SubState(),pointer.iType,TPointerEvent::EButton1Down,Client()->iGroup->GroupWin()->OrdinalPosition()); +#endif + if (pointer.iType==TPointerEvent::EButton1Down) + { + switch(iTest->SubState()) + { + case 1: + iTest->TEST(Client()->iGroup->GroupWin()->OrdinalPosition()==1); + iTest->IncSubState(); + break; + } + } + } + +void CMcWindow::Draw() + { + iGc->Clear(); + TBuf<0x40> buf; + switch(iTest->SubState()) + { + case 1: + buf.Copy(ClickOnMe); + break; + case 0: + case 2: + case 3: + buf.Copy(KNullDesC); + break; + default: + buf.Copy(KError); + } + iGc->DrawText(buf, TPoint(10,20)); + } + +// +// CMcWindowAf, Auto foreground version of CMcWindow // +// + +CMcWindowAf::CMcWindowAf(CTMultiCon *aTest) : CMcWindowBase(aTest) + { + iBack=TRgb::Gray256(150); + } + +void CMcWindowAf::PointerL(const TPointerEvent &pointer,const TTime &) + { +#if defined(LOGGING) + _LIT(KLog,"PointerL SS=%d (2) Type=%d (%d) GpWinOrdPos=%d (0)"); + iTest->LOG_MESSAGE5(KLog,iTest->SubState(),pointer.iType,TPointerEvent::EButton1Down,Client()->iGroup->GroupWin()->OrdinalPosition()); +#endif + if (pointer.iType==TPointerEvent::EButton1Down) + { + switch(iTest->SubState()) + { + case 2: + iTest->TEST(Client()->iGroup->GroupWin()->OrdinalPosition()==0); + iTest->IncSubState(); + break; + } + } + } + +void CMcWindowAf::Draw() + { + _LIT(PressSpace,"Press "); + iGc->Clear(); + TBuf<0x40> buf; + switch(iTest->SubState()) + { + case 1: + case 3: + break; + case 0: + buf.Copy(PressSpace); + break; + case 2: + buf.Copy(ClickOnMe); + break; + default: + buf.Copy(KError); + } + iGc->DrawText(buf, TPoint(10,20)); + } + +// + +CMcWindowGroupAf::CMcWindowGroupAf(CTClient *aClient) : CTWindowGroup(aClient) + {} + +void CMcWindowGroupAf::KeyL(const TKeyEvent &aKey, const TTime &) + { + ((CMcConnectionAf *)iClient)->KeyL(aKey); + } + +// +// CMcWindowDef, Default auto foreground version of CMcWindow // +// + +CMcWindowDef::CMcWindowDef(CTMultiCon *aTest) : CMcWindowBase(aTest) + { + iBack=TRgb::Gray256(236); + } + +void CMcWindowDef::PointerL(const TPointerEvent &pointer,const TTime &) + { +#if defined(LOGGING) + _LIT(KLog,"PointerL SS=%d (3) Type=%d (%d) GpWinOrdPos=%d (0)"); + iTest->LOG_MESSAGE5(KLog,iTest->SubState(),pointer.iType,TPointerEvent::EButton1Down,Client()->iGroup->GroupWin()->OrdinalPosition()); +#endif + if (pointer.iType==TPointerEvent::EButton1Down) + { + switch(iTest->SubState()) + { + case 3: + iTest->TEST(Client()->iGroup->GroupWin()->OrdinalPosition()==0); + iTest->IncSubState(); + break; + } + } + } + +void CMcWindowDef::Draw() + { + iGc->Clear(); + TBuf<0x40> buf; + switch(iTest->SubState()) + { + case 0: + case 1: + case 2: + break; + case 3: + buf.Copy(ClickOnMe); + break; + default: + buf.Copy(KError); + } + iGc->DrawText(buf, TPoint(10,20)); + } + +// + +TInt CTMultiCon::SubState() const + { + return(iSubState); + } + +void CTMultiCon::IncSubState() + { + if (iSubState==EMaxSubState) + EndAutoForegroundTest(); + else + { + iSubState++; + #if defined(LOGGING) + _LIT(KLog,"New SubState %d"); + LOG_MESSAGE2(KLog,iSubState); + #endif + iConn1->SubStateChanged(); + iConn2->SubStateChanged(); + iConn3->SubStateChanged(); + TheClient->WaitForRedrawsToFinish(); + SendEvents(); + } + } + +void CTMultiCon::SendEvents() + { +#if defined(LOGGING) + _LIT(KLog,"Sending event for substate %d"); + LOG_MESSAGE2(KLog,iSubState); +#endif + + switch (iSubState) + { + case 0: + iTest->SimulateKeyDownUp(EStdKeySpace); + break; + case 1: + iTest->SimulatePointerDownUp(iScreenSize.iWidth/6+5,iScreenSize.iHeight/4); + break; + case 2: + iTest->SimulatePointerDownUp(iScreenSize.iWidth/2,iScreenSize.iHeight/4); + break; + case 3: + iTest->SimulatePointerDownUp(iScreenSize.iWidth/3,3*iScreenSize.iHeight/4-5); + break; + default: + TEST(EFalse); + } + TheClient->iWs.Flush(); + } + +void CTMultiCon::RunTestCaseL(TInt /*aCurTestCase*/) + { + _LIT(KTestMultiCon1,"MultiCon 1"); + _LIT(KTimeOut,"Test Timed Out after %dsecs. SubState=%d"); + ((CTMultiConStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); + + if (!TestBase()->ConfigurationSupportsPointerEventTesting()) + { + INFO_PRINTF1(_L("Test skipped because config does not support pointer event testing")); + TestComplete(); + return; + } + + switch(++iTest->iState) + { +/** + + @SYMTestCaseID GRAPHICS-WSERV-0289 + + @SYMDEF DEF081259 + + @SYMTestCaseDesc Test multiple connections to the window server + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions Make mutiple connections to the window server and check + that the connections are made corectly + + @SYMTestExpectedResults The connections are made correctly + +*/ + case 1: + ((CTMultiConStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0289")); + iTest->LogSubTest(KTestMultiCon1); + iTimeOut->Start(KTimeOutAfter,TCallBack(CTMultiCon::TimeOut,this)); + SendEvents(); + CActiveScheduler::Start(); + iTimeOut->Cancel(); + TEST(iTimeOutCount==0); + if (iTimeOutCount!=0) + LOG_MESSAGE3(KTimeOut,KTimeOutAfter/1000000,iSubState); + break; + default: + ((CTMultiConStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + ((CTMultiConStep*)iStep)->CloseTMSGraphicsStep(); + TestComplete(); + break; + } + ((CTMultiConStep*)iStep)->RecordTestResultL(); + } + +__WS_CONSTRUCT_STEP__(MultiCon) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TMULTCON.H --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TMULTCON.H Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,157 @@ + +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef __TMULTCON_H__ +#define __TMULTCON_H__ + +#include +#include +#include +#include "../tlib/testbase.h" +#include "AUTO.H" +#include "TGraphicsHarness.h" + +class CTMultiCon; +class CMcWindowBase; + +class CMcConnectionBase : public CTClient + { +public: + CMcConnectionBase(CTMultiCon *aTest); + ~CMcConnectionBase(); + virtual void ConstructL(); + void SubStateChanged(); +protected: + CTMultiCon *iTest; + CMcWindowBase *iWin; + CWindowGc *iGc; + }; + +class CMcConnection : public CMcConnectionBase // Sets AutoForeground off + { +public: + CMcConnection(CTMultiCon *aTest); + void ConstructL(); + }; + +class CMcWindowGroupAf : public CTWindowGroup + { +public: + CMcWindowGroupAf(CTClient *aClient); + void KeyL(const TKeyEvent &aKey, const TTime &aTime); + }; + +class CMcConnectionAf : public CMcConnectionBase // Sets AutoForeground on + { +public: + CMcConnectionAf(CTMultiCon *aTest); + void ConstructL(); + void KeyL(const TKeyEvent &aKey); + }; + +class CMcConnectionDef : public CMcConnectionBase // Leaves AutoForeground as the default value + { +public: + CMcConnectionDef(CTMultiCon *aTest); + void ConstructL(); + }; + +class CMcWindowBase : public CTWin + { +public: + CMcWindowBase(CTMultiCon *aTest); + void SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc); + virtual void Draw()=0; + virtual void PointerL(const TPointerEvent &pointer,const TTime &)=0; +protected: + CTMultiCon *iTest; + TRgb iBack; + }; + +class CMcWindow : public CMcWindowBase + { +public: + CMcWindow(CTMultiCon *aTest); + virtual void Draw(); + virtual void PointerL(const TPointerEvent &pointer,const TTime &); + }; + +class CMcWindowAf : public CMcWindowBase + { +public: + CMcWindowAf(CTMultiCon *aTest); + virtual void Draw(); + virtual void PointerL(const TPointerEvent &pointer,const TTime &); + void ConstructL(); + }; + +class CMcWindowDef : public CMcWindowBase + { +public: + CMcWindowDef(CTMultiCon *aTest); + virtual void Draw(); + virtual void PointerL(const TPointerEvent &pointer,const TTime &); + }; + +class CTMultiCon : public CTWsGraphicsBase + { +public: + enum {KTimeOutAfter=10000000}; //10secs +public: + CTMultiCon(CTestStep* aStep); + ~CTMultiCon(); + void ConstructL(); + void EndAutoForegroundTest(); + TInt SubState() const; + void IncSubState(); + static TInt TimeOut(TAny* aTest); + void TimeOut(); + inline TInt ScreenNumber() const {return(iTest->ScreenNumber());} +protected: +//from CTGraphicsStep + virtual void RunTestCaseL(TInt aCurTestCase); +private: + void SendEvents(); +private: + CTimeOut* iTimeOut; + TInt iTimeOutCount; + CMcConnectionAf *iConn1; + CMcConnection *iConn2; + CMcConnectionDef *iConn3; + TSize iScreenSize; + //TInt iState; + TInt iSubState; + }; + +class CTMultiConStep : public CTGraphicsStep + { +public: + CTMultiConStep(); +protected: + //from CTGraphicsStep + virtual CTGraphicsBase* CreateTestL(); + }; + +_LIT(KTMultiConStep,"TMultiCon"); + + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TMemLeakMode.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TMemLeakMode.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,88 @@ +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Enable Wserv memory leak checks +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include "TMemLeakMode.h" +#include + +// +// +CTMemLeakCheckEnable::CTMemLeakCheckEnable(CTestStep* aStep) : CTWsGraphicsBase(aStep) + { + INFO_PRINTF1(_L("Enabling memory leak checks")); + } + +void CTMemLeakCheckEnable::ConstructL() + { + iIsWsTestMode = !iTest->IsFullRomL(); + if (iIsWsTestMode) + { + TheClient->iWs.DebugInfo(EWsDebugSetCheckHeapOnDisconnectMode,EWsCheckHeapOnDisconnectModeAlways); + } + } + +void CTMemLeakCheckEnable::RunTestCaseL(TInt ) + { + if (!iIsWsTestMode) + { +#if defined(__WINS__) + WARN_PRINTF1(_L("Test skipped as TechView appears to be running\n")); +#else + INFO_PRINTF1(_L("Test skipped as TechView appears to be running\n")); +#endif + } + TestComplete(); + } + +__WS_CONSTRUCT_STEP__(MemLeakCheckEnable) + +// +// + +CTMemLeakCheckOneShot::CTMemLeakCheckOneShot(CTestStep* aStep) : CTWsGraphicsBase(aStep) + { + INFO_PRINTF1(_L("Triggering one shot memory leak check")); + } + +void CTMemLeakCheckOneShot::ConstructL() + { + iIsWsTestMode = !iTest->IsFullRomL(); + if (iIsWsTestMode) + { + TheClient->iWs.DebugInfo(EWsDebugSetCheckHeapOnDisconnectMode,EWsCheckHeapOnDisconnectModeOnce); + } + } + +void CTMemLeakCheckOneShot::RunTestCaseL(TInt ) + { + if (!iIsWsTestMode) + { +#if defined(__WINS__) + WARN_PRINTF1(_L("Test skipped as TechView appears to be running\n")); +#else + INFO_PRINTF1(_L("Test skipped as TechView appears to be running\n")); +#endif + } + TestComplete(); + } + +__WS_CONSTRUCT_STEP__(MemLeakCheckOneShot) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TMemLeakMode.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TMemLeakMode.h Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,74 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include +#include +#include "../tlib/testbase.h" +#include "AUTO.H" +#include "TGraphicsHarness.h" + +// CTMemLeakCheckEnable + +class CTMemLeakCheckEnable : public CTWsGraphicsBase + { +public: + CTMemLeakCheckEnable(CTestStep* aStep); + void ConstructL(); +protected: + virtual void RunTestCaseL(TInt aCurTestCase); +private: + TBool iIsWsTestMode; + }; + +class CTMemLeakCheckEnableStep : public CTGraphicsStep + { +public: + CTMemLeakCheckEnableStep(); + TestState DoTestL(); +protected: + virtual CTGraphicsBase* CreateTestL(); + }; + +_LIT(KTMemLeakCheckEnableStep,"TMemLeakCheckEnable"); + +// CTMemLeakCheckOneShot + +class CTMemLeakCheckOneShot : public CTWsGraphicsBase + { +public: + CTMemLeakCheckOneShot(CTestStep* aStep); + void ConstructL(); +protected: + virtual void RunTestCaseL(TInt aCurTestCase); +private: + TBool iIsWsTestMode; + }; + +class CTMemLeakCheckOneShotStep : public CTGraphicsStep + { +public: + CTMemLeakCheckOneShotStep(); + TestState DoTestL(); +protected: + virtual CTGraphicsBase* CreateTestL(); + }; + +_LIT(KTMemLeakCheckOneShotStep,"TMemLeakCheckOneShot"); diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TMulTran.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TMulTran.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,1111 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Test multiple level transparent window +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include "TMulTran.H" + + +LOCAL_D TDisplayMode DisplayMode=EColor64K; +LOCAL_D TSize WinSize; + +static const TRgb KRed=TRgb(255, 0, 0, 128); +static const TRgb KGreen=TRgb(0, 255, 0, 128); +static const TRgb KYellow=TRgb(255, 255, 0, 128); +static const TRgb KBlue=TRgb(0, 0, 255, 128); +static const TRgb KCyan=TRgb(0, 255, 255, 128); + +/*CTransWindow*/ + +CTransWindow* CTransWindow::NewL(RPointerArray& aWindows,TRgb aColor,TRect aPos) + { + CTransWindow* self=NewL(TheClient->iGroup,aColor,aPos,&DisplayMode); + aWindows.Insert(self,0); + return self; + } + +CTransWindow* CTransWindow::NewL(CTWinBase* aParent,TRgb aColor,TRect aPos, TDisplayMode* aDisplayMode) + { + CTransWindow* self=new(ELeave) CTransWindow(aColor); + CleanupStack::PushL(self); + self->SetUpL(aPos.iTl,aPos.Size(),aParent,*TheClient->iGc,aDisplayMode); + User::LeaveIfError(self->iError); + CleanupStack::Pop(self); + return self; + } + +//the following function doesn't activate a window +CTransWindow* CTransWindow::NewL(CTWinBase* aParent,TRgb aColor,TDisplayMode* aDisplayMode) + { + CTransWindow* self=new(ELeave) CTransWindow(aColor); + CleanupStack::PushL(self); + self->ConstructL(*aParent); + if (aDisplayMode) + { + self->BaseWin()->SetRequiredDisplayMode(*aDisplayMode); + } + User::LeaveIfError((self->iError) && (self->iError != KErrNotSupported)); + CleanupStack::Pop(self); + return self; + } + +void CTransWindow::InitWin() + { + AdjustShadow(-1); + iShadowHight=0; + iWin.SetShadowDisabled(ETrue); + iShadowing=EFalse; + iError = iWin.SetTransparencyAlphaChannel(); + iWin.SetBackgroundColor(iCol); + iDrawOpaque=EFalse; + } + +void CTransWindow::ToggleVisibility() + { + iVisible=!iVisible; + SetVisible(iVisible); + } + +void CTransWindow::SetOrdinal(RPointerArray& aWindows,TInt aOldPos,TInt aNewPos) + { + CTransWindow* win=aWindows[aOldPos]; + aWindows.Remove(aOldPos); + aWindows.Insert(win,aNewPos); + win->iWin.SetOrdinalPosition(aNewPos); + } + +void CTransWindow::SetShadowDisabled(TBool aState) + { + iWin.SetShadowDisabled(aState); + iShadowing=!aState; + } + +void CTransWindow::AdjustShadow(TInt aAdjust) + { + CBlankWindow::AdjustShadow(aAdjust); + iShadowHight+=aAdjust; + } + +TPoint CTransWindow::Position() const + { + return CBlankWindow::Position()+iPosOffset; + } + +void CTransWindow::Draw() + { + //don't call CBlankWindow::Draw() since the background is already drawn + + if(iDrawOpaque) + { + iGc->SetPenStyle(CGraphicsContext::ESolidPen); + iGc->SetPenSize(TSize(4,4)); + iGc->SetBrushStyle(CGraphicsContext::ENullBrush); + iGc->SetPenColor(~iCol); + iGc->SetOpaque(ETrue); + iGc->DrawLine(TPoint(0,0),TPoint(1000,1000)); + iGc->SetOpaque(EFalse); + } + } + +/*CTMultipleTrans*/ + +CTMultipleTrans::CTMultipleTrans(CTestStep* aStep) : CTWsGraphicsBase(aStep), iWindows(5), iShadows(EFalse) + { + } + +CTMultipleTrans::~CTMultipleTrans() + { + ((CTMultipleTransStep*)iStep)->CloseTMSGraphicsStep(); + delete iBackgroundWin; + delete iCheckWin; + delete iCheckBitmap; + iWindows.ResetAndDestroy(); + iBlankWin.Close(); + } + +void CTMultipleTrans::ConstructL() + { + if(TransparencySupportedL() == KErrNotSupported) + return; + iMajorTest=0; + const TSize scrSize(TheClient->iScreen->SizeInPixels()); + WinSize.SetSize(scrSize.iWidth/2,scrSize.iHeight); + iBackgroundWin=new(ELeave) CTBlankWindow(); + iBackgroundWin->SetUpL(TPoint(),WinSize,TheClient->iGroup,*TheClient->iGc); + TheClient->WaitForRedrawsToFinish(); + CTBackedUpWin* checkWin=new(ELeave) CTBackedUpWin(DisplayMode); + checkWin->ConstructExtLD(*TheClient->iGroup,TPoint(WinSize.iWidth,0),WinSize); + iCheckWin=checkWin; + RBackedUpWindow& backWin=*iCheckWin->BackedUpWin(); + backWin.SetShadowHeight(0); + iCheckWin->Activate(); + backWin.MaintainBackup(); + iCheckBitmap=CBitmap::NewL(backWin.BitmapHandle()); + iCheckBitmap->Gc().SetPenStyle(CGraphicsContext::ENullPen); + iCheckBitmap->Gc().SetBrushStyle(CGraphicsContext::ESolidBrush); + TheClient->Flush(); + TheClient->WaitForRedrawsToFinish(); + RecreateWindowsL(); + iBlankWin=RBlankWindow(TheClient->iWs); + User::LeaveIfError(iBlankWin.Construct(*TheClient->iGroup->WinTreeNode(),ENullWsHandle)); + iBlankWinVis=EFalse; + iBlankWin.SetVisible(iBlankWinVis); + User::LeaveIfError(iBlankWin.SetRequiredDisplayMode(EColor256)); + iBlankWinCol=TRgb(170,170,170); //Grey + iBlankWin.SetColor(iBlankWinCol); + iBlankWin.SetOrdinalPosition(0,1); //Set the priority to 1 so that the 4 main windows are the first 4 with priory 0 + iBlankWin.Activate(); + iOpacitySupported=EFalse; + } + +void CTMultipleTrans::ShadowRegion(TRegion& aRegion,TInt aWin) + { + TRect rect; + TInt height; + TInt window; + aRegion.Clear(); + RRegion single; + RRegion noShadow1; + RRegion noShadow2; + RRegion temp; + RRegion temp2; + for (window=0;windowGc(); + gc.SetBrushColor(KRgbWhite); + gc.DrawRect(TRect(WinSize)); + TInt windows=iWindows.Count(); + if (iShadows) + { + ShadowRegion(shadowRegion,windows); + gc.ShadowArea(&shadowRegion); + } + TInt window; + for (window=windows;window>0;) + { + CTransWindow& win=*iWindows[--window]; + if (win.IsVisible()) + { + gc.SetBrushColor(win.Color()); + const TPoint& winTopLeft=win.Position(); + gc.DrawRect(TRect(winTopLeft, win.Size())); + + if(win.DrawOpaque()) + { + gc.SetPenColor(~(win.Color())); + gc.SetPenSize(TSize(4,4)); + gc.SetPenStyle(CGraphicsContext::ESolidPen); + gc.SetClippingRect(TRect(TPoint(winTopLeft.iX,winTopLeft.iY),TPoint(winTopLeft.iX + win.Size().iWidth, winTopLeft.iY + win.Size().iHeight))); + gc.DrawLine(TPoint(winTopLeft.iX,winTopLeft.iY),TPoint(winTopLeft.iX+1000, winTopLeft.iY+1000)); + gc.SetPenStyle(CGraphicsContext::ENullPen); + gc.SetClippingRect(TRect(WinSize)); + } + + if (iShadows) + { + ShadowRegion(shadowRegion,window); + gc.ShadowArea(&shadowRegion); + } + } + } + iCheckWin->BackedUpWin()->UpdateScreen(); + TheClient->Flush(); + if (windows>=4) + { + AdvancedCheckRect(); + } + _LIT(KTest,"Multiple Transparent Test, SubTest %d, OpacityOn=%d"); + TBuf<128> buf; + buf.Format(KTest,iTest->iState,iMajorTest); + CheckRect(iBackgroundWin,iCheckWin,TRect(WinSize),buf); + shadowRegion.Close(); + } + +#define OFFSET 2 +void CTMultipleTrans::AdvancedCheckRect() + { + const TSize compareSize(5,5); + const TInt OFFSET2=OFFSET+compareSize.iWidth; + TPoint comparePos=iCheckWin->Position(); + TPoint checkPos; + //Check Single Level for Top Left Win + checkPos=iTopLeft->Position()+TPoint(OFFSET,OFFSET); + CheckRect(checkPos,checkPos+comparePos,compareSize); + //Check Single Level for Top Right Win + checkPos=iTopRight->Position()+TPoint(iTopRight->Size().iWidth-OFFSET2,OFFSET); + CheckRect(checkPos,checkPos+comparePos,compareSize); + //Check Single Level for Bottom Left Win + checkPos=iBotLeft->Position()+TPoint(OFFSET,iBotLeft->Size().iHeight-OFFSET2); + CheckRect(checkPos,checkPos+comparePos,compareSize); + //Check Single Level for Bottom Right Win + checkPos=iBotRight->Position()+TPoint(iBotRight->Size().iWidth-OFFSET2,iBotRight->Size().iHeight-OFFSET2); + CheckRect(checkPos,checkPos+comparePos,compareSize); + //Double level top 2 windows + checkPos=iTopRight->Position()+TPoint(OFFSET,OFFSET); + CheckRect(checkPos,checkPos+comparePos,compareSize); + //Double level left 2 windows + checkPos=iBotLeft->Position()+TPoint(OFFSET,OFFSET); + CheckRect(checkPos,checkPos+comparePos,compareSize); + //Double level bot 2 windows + checkPos=iBotRight->Position()+TPoint(OFFSET,iBotRight->Size().iHeight-OFFSET2); + CheckRect(checkPos,checkPos+comparePos,compareSize); + //Double level right 2 windows + checkPos=iBotRight->Position()+TPoint(iBotRight->Size().iWidth-OFFSET2,OFFSET); + CheckRect(checkPos,checkPos+comparePos,compareSize); + //Triple level all but bot right + checkPos=iTopRight->Position()+TPoint(OFFSET,iTopRight->Size().iHeight-OFFSET2); + CheckRect(checkPos,checkPos+comparePos,compareSize); + //Triple level all but bot left + checkPos=iBotRight->Position()+TPoint(OFFSET,OFFSET); + CheckRect(checkPos,checkPos+comparePos,compareSize); + //Triple level all but top right + checkPos=iTopLeft->Position()+TPoint(iTopLeft->Size().iWidth-OFFSET2,iTopLeft->Size().iHeight-OFFSET2); + CheckRect(checkPos,checkPos+comparePos,compareSize); + //Triple level all but top left + checkPos=iBotLeft->Position()+TPoint(iBotLeft->Size().iWidth-OFFSET2,OFFSET); + CheckRect(checkPos,checkPos+comparePos,compareSize); + //Quad level + checkPos=TPoint(iBotRight->Position().iX,iBotLeft->Position().iY)+TPoint(OFFSET,OFFSET); + CheckRect(checkPos,checkPos+comparePos,compareSize); + } + +void CTMultipleTrans::SimpleTest() + { + CheckDisplay(); + } + +void CTMultipleTrans::ChangeVisibility() + { + TUint toggle; + TUint toggle2; + TInt win; + TInt ii=0; + for (ii=2;ii>0;--ii) + { + for (toggle=1;toggle<16;++toggle) + { + win=0; + toggle2=toggle; + while ((toggle2&0x1)==0) + { + ++win; + toggle2/=2; + } + iWindows[win]->ToggleVisibility(); + CheckDisplay(); + } + } + } + +void CTMultipleTrans::ChangeVisibility2() + { + iBlankWin.SetOrdinalPosition(0,0); + iBlankWin.SetVisible(ETrue); + iBlankWin.SetVisible(EFalse); + CheckDisplay(); + const TInt xSteps=4; + const TInt ySteps=3; + iBlankWinSize.SetSize(WinSize.iWidth/xSteps,WinSize.iHeight/ySteps); + iBlankWin.SetSize(iBlankWinSize); + TInt ordPos,xx,yy; + for (ordPos=0;ordPos<=4;++ordPos) + { + iBlankWin.SetOrdinalPosition(ordPos); + for (xx=0;xx=0;--kk) + { + for (jj=3;jj>kk;--jj) + { + for (ii=jj;ii>=kk;--ii) + { + CTransWindow::SetOrdinal(iWindows,jj,kk); + CheckDisplay(); + } + } + } + for (kk=2;kk>=0;--kk) + { + for (jj=3;jj>kk;--jj) + { + for (ii=jj;ii>=kk;--ii) + { + CTransWindow::SetOrdinal(iWindows,kk,jj); + CheckDisplay(); + } + } + } + } + +TSize CTMultipleTrans::GetSize(TInt aPos) + { //Comments show values for 640x240 screen + const TInt halfSize=40; + const TPoint topLeft=iTopLeft->Position(); //10,10 + const TInt xLeft=WinSize.iWidth/2-topLeft.iX-halfSize; //110 + const TInt xRight=xLeft+2*halfSize; //190 + const TInt yTop=WinSize.iHeight/2-topLeft.iY-halfSize; //70 + const TInt yBot=yTop+2*halfSize; //150 + if (aPos<6) + return TSize(xLeft+16*aPos-8,yTop); //1->118, 5->182 + if (aPos<11) + return TSize(xRight,yTop+16*aPos-88); //6->78, 10->142 + if (aPos<16) + return TSize(xRight-16*aPos+168,yBot); //11->182, 15->118 + return TSize(xLeft,yBot-16*aPos+248); //16->142, 20->78 + } + +void CTMultipleTrans::SizeChange(TInt aJump) + { + TInt ii=aJump; + TSize size; + while (ii<20) + { + size=GetSize(ii); + iTopLeft->SetSize(size); + if(iTopLeft->DrawOpaque()) + { + iTopLeft->CTWin::DrawNow(); + TheClient->Flush(); + } + CheckDisplay(); + ii+=aJump; + if (ii>20) + ii-=20; + } + } + +void CTMultipleTrans::SizeChange() + { + CTransWindow::SetOrdinal(iWindows,2,1); + TSize size=iBotLeft->Size(); + TInt change; + for (change=70;change>=0;change-=14) + { + iBotLeft->SetSize(TSize(size.iWidth-change,size.iHeight)); + if(iBotLeft->DrawOpaque()) + { + iBotLeft->CTWin::DrawNow(); + TheClient->Flush(); + } + CheckDisplay(); + } + size=iTopRight->Size(); + for (change=25;change>-50;change-=14) + { + iTopRight->SetSize(TSize(size.iWidth,size.iHeight+change)); + if(iTopRight->DrawOpaque()) + { + iTopRight->CTWin::DrawNow(); + TheClient->Flush(); + } + CheckDisplay(); + } + iTopRight->SetSize(size); + if(iTopRight->DrawOpaque()) + { + iTopRight->CTWin::DrawNow(); + TheClient->Flush(); + } + CTransWindow::SetOrdinal(iWindows,1,0); + CheckDisplay(); + size=iTopLeft->Size(); + SizeChange(3); + iTopLeft->SetSize(size); + if(iTopLeft->DrawOpaque()) + { + iTopLeft->CTWin::DrawNow(); + TheClient->Flush(); + } + CheckDisplay(); + CTransWindow::SetOrdinal(iWindows,0,2); + CheckDisplay(); + SizeChange(7); + iTopLeft->SetSize(size); + if(iTopLeft->DrawOpaque()) + { + iTopLeft->CTWin::DrawNow(); + TheClient->Flush(); + } + CheckDisplay(); + } + +void CTMultipleTrans::MoveWin() + { + const TPoint topLeftPos=iTopLeft->Position(); + const TPoint topRightPos=iTopRight->Position(); + const TPoint botLeftPos=iBotLeft->Position(); + const TPoint botRightPos=iBotRight->Position(); + const TInt maxMove=Min(topRightPos.iX,botRightPos.iY)-10; + TInt steps,move; + for (steps=2;steps>=0;--steps) + { + move=maxMove*(3-steps)/3; + iTopLeft->SetPos(TPoint(topLeftPos.iX+move,topLeftPos.iY+move)); + CheckDisplay(); + iTopRight->SetPos(TPoint(topRightPos.iX-move,topRightPos.iY+move)); + CheckDisplay(); + iBotRight->SetPos(TPoint(botRightPos.iX-move,botRightPos.iY-move)); + CheckDisplay(); + iBotLeft->SetPos(TPoint(botLeftPos.iX+move,botLeftPos.iY-move)); + CheckDisplay(); + } + for (steps=4;steps>=0;--steps) + { + move=maxMove*steps/5; + iBotLeft->SetPos(TPoint(botLeftPos.iX+move,botLeftPos.iY-move)); + CheckDisplay(); + iTopLeft->SetPos(TPoint(topLeftPos.iX+move,topLeftPos.iY+move)); + CheckDisplay(); + iBotRight->SetPos(TPoint(botRightPos.iX-move,botRightPos.iY-move)); + CheckDisplay(); + iTopRight->SetPos(TPoint(topRightPos.iX-move,topRightPos.iY+move)); + CheckDisplay(); + } + } + +void CTMultipleTrans::GroupWinL() + { + CTWindowGroup* group=new(ELeave) CTWindowGroup(TheClient); + CleanupStack::PushL(group); + group->ConstructL(); + CTransWindow* win=CTransWindow::NewL(group,KCyan,TRect(40,40,WinSize.iWidth-40,WinSize.iHeight-40),&DisplayMode); + win->CTWin::DrawNow(); + if(iMajorTest==1) + { + win->SetDrawOpaque(ETrue); + win->Invalidate(); + TheClient->WaitForRedrawsToFinish(); + } + iWindows.Insert(win,0); + CheckDisplay(); + group->GroupWin()->SetOrdinalPosition(1); + iWindows.Remove(0); + CheckDisplay(); + group->GroupWin()->SetOrdinalPosition(0); + iWindows.Insert(win,0); + CheckDisplay(); + iWindows.Remove(0); + delete win; //Would be better to delete this after the group window but the test window don't support this behaviour currently. + CleanupStack::PopAndDestroy(group); + CheckDisplay(); + } + +void CTMultipleTrans::FadeTranWin() + { + // system fade on + TheClient->iWs.SetSystemFaded(ETrue); + // system fade off + TheClient->iWs.SetSystemFaded(EFalse); + CheckDisplay(); + } + +void CTMultipleTrans::StartShadows() + { + iShadows=ETrue; + iTopLeft->SetShadowDisabled(EFalse); + iTopLeft->AdjustShadow(1); + iTopRight->SetShadowDisabled(EFalse); + iTopRight->AdjustShadow(1); + iBotLeft->SetShadowDisabled(EFalse); + iBotLeft->AdjustShadow(1); + iBotRight->SetShadowDisabled(EFalse); + iBotRight->AdjustShadow(1); + if(!iOpacitySupported) + { + iTopRight->ToggleVisibility(); // In 8.1 this isn't needed. + iTopRight->ToggleVisibility(); + } + CheckDisplay(); + } + +void CTMultipleTrans::ShadowsOnOff() + { + if(!iOpacitySupported) + return; // In 8.1 this isn't needed. + iBotRight->SetShadowDisabled(EFalse); + iBotRight->AdjustShadow(1); + CheckDisplay(); + iBotRight->SetShadowDisabled(ETrue); + CheckDisplay(); + iTopLeft->SetShadowDisabled(EFalse); + iTopLeft->AdjustShadow(1); + CheckDisplay(); + iTopLeft->SetShadowDisabled(ETrue); + CheckDisplay(); + iTopRight->SetShadowDisabled(ETrue); + CheckDisplay(); + iBotLeft->SetShadowDisabled(EFalse); + iBotLeft->AdjustShadow(1); + CheckDisplay(); + iBotLeft->SetShadowDisabled(ETrue); + CheckDisplay(); + iTopLeft->SetShadowDisabled(EFalse); + iTopRight->SetShadowDisabled(EFalse); + iBotLeft->SetShadowDisabled(EFalse); + iBotRight->SetShadowDisabled(EFalse); + iTopLeft->ToggleVisibility(); + CheckDisplay(); + iTopLeft->ToggleVisibility(); + CheckDisplay(); + iTopRight->ToggleVisibility(); + CheckDisplay(); + iTopRight->ToggleVisibility(); + CheckDisplay(); + iBotLeft->ToggleVisibility(); + CheckDisplay(); + iBotLeft->ToggleVisibility(); + CheckDisplay(); + iBotRight->ToggleVisibility(); + CheckDisplay(); + iBotRight->ToggleVisibility(); + CheckDisplay(); + } + +void CTMultipleTrans::StartChildL() + { + CTransWindow* win; + TInt windows=iWindows.Count(); + TInt window; + //Delete the first 4 windows from the array, could use ResetAndDestroy but would be broken by other uses of the array + for (window=windows;window>0;--window) + { + win=iWindows[0]; + iWindows.Remove(0); + delete win; + } + RecreateWindowsL(iBackgroundWin); + CheckDisplay(); + } + +void CTMultipleTrans::StartChild2L() + { + CTransWindow* win; + TInt windows=iWindows.Count(); + TInt window; + //Delete the first 4 windows from the array, could use ResetAndDestroy but would be broken by other uses of the array + for (window=windows;window>0;--window) + { + win=iWindows[0]; + iWindows.Remove(0); + delete win; + } + iShadows=EFalse; + TRect rect=WinSize; + rect.Shrink(10,10); + iBotRight=CTransWindow::NewL(iBackgroundWin,KBlue,rect,&DisplayMode); + iBotRight->CTWin::DrawNow(); + iWindows.Insert(iBotRight,0); + CheckDisplay(); + rect.Resize(-20,-20); + iTopLeft=CTransWindow::NewL(iBotRight,KRed,rect,&DisplayMode); + iTopLeft->CTWin::DrawNow(); + iTopLeft->SetPosOffset(TPoint(10,10)); + iWindows.Insert(iTopLeft,0); + CheckDisplay(); + rect.Resize(-20,-20); + iTopRight=CTransWindow::NewL(iTopLeft,KGreen,rect,&DisplayMode); + iTopRight->CTWin::DrawNow(); + iTopRight->SetPosOffset(TPoint(20,20)); + iWindows.Insert(iTopRight,0); + CheckDisplay(); + rect.Resize(-20,-20); + iBotLeft=CTransWindow::NewL(iTopRight,KYellow,rect,&DisplayMode); + iBotLeft->CTWin::DrawNow(); + iBotLeft->SetPosOffset(TPoint(30,30)); + iWindows.Insert(iBotLeft,0); + if(iMajorTest==1) + { + for (TInt window = 0; window < iWindows.Count(); ++window) + { + iWindows[window]->SetDrawOpaque(ETrue); + iWindows[window]->Invalidate(); + } + TheClient->WaitForRedrawsToFinish(); + } + CheckDisplay(); + } + +void CTMultipleTrans::RecreateWindowsL(CTWinBase *aParent) + { + CTransWindow* win; + TInt windows=iWindows.Count(); + TInt window; + //Delete existing windows: + for (window=windows;window>0;--window) + { + win=iWindows[0]; + iWindows.Remove(0); + delete win; + } + + if(!aParent) + aParent = TheClient->iGroup; + + iBotRight=CTransWindow::NewL(aParent,KBlue,TRect(WinSize.iWidth/2-10,WinSize.iHeight/2-30,WinSize.iWidth-20,WinSize.iHeight-20),&DisplayMode); + iBotRight->CTWin::DrawNow(); + iWindows.Insert(iBotRight,0); + iTopLeft=CTransWindow::NewL(aParent,KRed,TRect(10,10,WinSize.iWidth/2+10,WinSize.iHeight/2+30),&DisplayMode); + iTopLeft->CTWin::DrawNow(); + iWindows.Insert(iTopLeft,0); + iTopRight=CTransWindow::NewL(aParent,KGreen,TRect(WinSize.iWidth/2-30,20,WinSize.iWidth-10,WinSize.iHeight/2+10),&DisplayMode); + iTopRight->CTWin::DrawNow(); + iWindows.Insert(iTopRight,0); + iBotLeft=CTransWindow::NewL(aParent,KYellow,TRect(20,WinSize.iHeight/2-10,WinSize.iWidth/2+30,WinSize.iHeight-10),&DisplayMode); + iBotLeft->CTWin::DrawNow(); + iWindows.Insert(iBotLeft,0); + iShadows=EFalse; + + if(iMajorTest==1) + { + for (TInt window=0;windowSetDrawOpaque(ETrue); + iWindows[window]->Invalidate(); + } + TheClient->WaitForRedrawsToFinish(); + } + } + +void CTMultipleTrans::RunTestCaseL(TInt /*aCurTestCase*/) + { + _LIT(KCheck,"Check"); + _LIT(KSimple,"Simple Test"); + _LIT(KVisibility,"Change Visibility"); + _LIT(KVisibility2,"Change Visibility 2"); + _LIT(KOrdinal,"Ordinal Position"); + _LIT(KSizeChange,"Size Change"); + _LIT(KMoveWin,"Move Window"); + _LIT(KGroupWin,"Group Window Ordinal"); + _LIT(KBackground,"Background Color Changes"); + _LIT(KShadowsOnOff,"Shadows On Off"); + _LIT(KChild1,"Child 1"); + _LIT(KChild2,"Child 2"); + _LIT(KOpacity,"Opaque Drawing"); + _LIT(KTranWinFade,"Fading Transparent Windows"); + ((CTMultipleTransStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); + + switch(iTest->iState) + { + case 0: +/** +@SYMTestCaseID GRAPHICS-WSERV-0500 +*/ + ((CTMultipleTransStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0500")); + // Check to see if Transparency is enabled before running tests + iTest->LogSubTest(KCheck); + if (TransparencySupportedL()==KErrNotSupported) + { + LOG_MESSAGE(_L("Transparency is not supported\n")); + TestComplete(); + return; + } + ++iTest->iState; //Fall Through +/** +@SYMTestCaseID GRAPHICS-WSERV-0111 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Simple transparent windows test. + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Four overlapping transparent windows (RWindow) are created before the test on the screen's left side. + The test draws the windows on the screen's right side using FBS bitmaps direcly. + The test does nothing if transparency is not enabled on the screen. + +@SYMTestExpectedResults Expects that left and rightside bitmaps are identical +*/ + case 1: + ((CTMultipleTransStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0111")); + iTest->LogSubTest(KSimple); + SimpleTest(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0112 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc On/off switching of visibility of transparent windows + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Four overlapping transparent windows (RWindow) are created before the test on the screen's left side. + The test toggles visibility of those four windows going through all + combinations. For each combination it draws visible windows on the screen's right side using FBS bitmaps direcly. + The test does nothing if transparency is not enabled on the screen. + +@SYMTestExpectedResults Expects that left and rightside bitmaps are identical +*/ + case 2: + case 23: + case 42: + ((CTMultipleTransStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0112")); + iTest->LogSubTest(KVisibility); + ChangeVisibility(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0113 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc On/off switching of visibility of a small transparent window on top of existing transparent windows + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Four overlapping transparent windows (RWindow) are created before the test on the screen's left side. + Toggles visibility of 5th blank little window making this appear in different places + with different ordinal position. Draws visible windows on the screen's right side using FBS bitmaps direcly + each time when the 5th window becomes invisible. + The test does nothing if transparency is not enabled on the screen. + +@SYMTestExpectedResults Expects that left and rightside bitmaps are identical +*/ + case 3: + ((CTMultipleTransStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0113")); + iTest->LogSubTest(KVisibility2); + ChangeVisibility2(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0114 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Ordinal positions' switches of intersecting transparent windows + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Four overlapping transparent windows (RWindow) are created before the test on the screen's left side. + Switches ordinal positions of the four windows trying all combinations. Draws visible windows on the screen's right side + using FBS bitmaps direcly each time when a new combination is applied. + The test does nothing if transparency is not enabled on the screen. + + +@SYMTestExpectedResults Expects that left and rightside bitmaps are identical +*/ + case 4: + case 43: + ((CTMultipleTransStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0114")); + iTest->LogSubTest(KOrdinal); + OrdinalPos(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0115 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Changing sizes of intersecting transparent windows + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Four overlapping transparent windows (RWindow) are created before the test on the screen's left side. + Plays with sizes of each of the four windows to affect overlapping. + Draws visible windows on the screen's right side using FBS bitmaps direcly + each time when a new size for a particular window is applied. + The test does nothing if transparency is not enabled on the screen. + + +@SYMTestExpectedResults Expects that left and rightside bitmaps are identical +*/ + case 5: + case 24: + ((CTMultipleTransStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0115")); + iTest->LogSubTest(KSizeChange); + SizeChange(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0116 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Moving intersecting transparent windows + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Four overlapping transparent windows (RWindow) are created before the test on the screen's left side. + Performs moves of those windows one by one making little steps in direction of the center of intersection and backwards. + Draws visible windows on the screen's right side using FBS bitmaps direcly + each time when a position of a particular window changes. + The test does nothing if transparency is not enabled on the screen. + +@SYMTestExpectedResults Expects that left and rightside bitmaps are identical +*/ + case 6: + ((CTMultipleTransStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0116")); + iTest->LogSubTest(KMoveWin); + MoveWin(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0117 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test with a second window group + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Four overlapping transparent windows (RWindow, within the same group) are created before the test on the screen's left side. + Creates a 5th transparent window in a separate window group + on top of existing windows which covers the intersection area of initial 4 windows. + Changes the ordinal position of the group to 1, changes ordinal position + back to 0, removes the new group. + Redraws visible windows on the screen's right side using FBS bitmaps direcly + each time when any change on the screen's left side is performed. + The test does nothing if transparency is not enabled on the screen. + +@SYMTestExpectedResults Expects that left and rightside bitmaps are identical +*/ + case 7: + ((CTMultipleTransStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0117")); + iTest->LogSubTest(KGroupWin); + GroupWinL(); + break; + case 8: + ((CTMultipleTransStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + iTest->LogSubTest(KBackground); + //Change the background color of the 4 test windows and the window behind them + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0118 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc On/off switching of fading + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Four overlapping transparent windows (RWindow) are created before the test on the screen's left side. + Switches system fading on and right after that back to off. + Draws visible windows on the screen's right side using FBS bitmaps direcly + after that. + The test does nothing if transparency is not enabled on the screen. + +@SYMTestExpectedResults Expects that left and rightside bitmaps are identical +*/ + case 9: + ((CTMultipleTransStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0118")); + iTest->LogSubTest(KTranWinFade); + FadeTranWin(); + break; + case 10: + ((CTMultipleTransStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + iTest->iState=21-1; + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0120 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Shadows' on/off test. + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Four overlapping transparent windows (RWindow) with shadowing enabled are created before the test on the screen's left side. + The test plays with on/off-switching of shadowing and visibility for the windows. + The test redraws visible windows on the screen's right side using FBS bitmaps direcly + each time when state of ony window changes. + The test does nothing if transparency is not enabled on the screen. + The test also repeats GRAPHICS-WSERV-0111 - GRAPHICS-WSERV-015 foor the shadowed windows. + +@SYMTestExpectedResults Expects that left and rightside bitmaps are identical +*/ + case 22: + ((CTMultipleTransStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0120")); + iTest->LogSubTest(KShadowsOnOff); + ShadowsOnOff(); + break; + case 25: + ((CTMultipleTransStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + iTest->iState=41-1; + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0121 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Transparent child-windows of a bacground window + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Four overlapping transparent windows (RWindow) with shadowing enabled are created before the test on the screen's left side. + The test removes those windows and creates new four overlapping transparent windows + but as children of existing background window. After that the test redraws visible windows on the screen's right side using FBS bitmaps direcly. + The test does nothing if transparency is not enabled on the screen. + The test also repeats GRAPHICS-WSERV-0111 - GRAPHICS-WSERV-014 foor the shadowed windows. + +@SYMTestExpectedResults Expects that left and rightside bitmaps are identical +*/ + case 41: + ((CTMultipleTransStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0121")); + iTest->LogSubTest(KChild1); + StartChildL(); + break; + case 44: + ((CTMultipleTransStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + iTest->iState=61-1; + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0122 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Four overlapping transparent windows (RWindow) with shadowing enabled are created before the test on the screen's left side. + The test removes those windows and creates new four transparent windows + so that each one (except first) is a child of prevoiusly created window. + The test redraws visible windows on the screen's right side using FBS bitmaps direcly + after each window's creation. + The test does nothing if transparency is not enabled on the screen. + +@SYMTestExpectedResults Expects that left and rightside bitmaps are identical +*/ + case 61: + ((CTMultipleTransStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0122")); + iTest->LogSubTest(KChild2); + StartChild2L(); + break; + default: + ((CTMultipleTransStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0123")); +/** +@SYMTestCaseID GRAPHICS-WSERV-0123 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions The test draws four overlapping transparent windows (RWindow) on the screen's left side. + Each window has an opaque diagonal line (\) which goes from the top-left corner of each window. + The test repeats all tests from GRAPHICS-WSERV-0111 to GRAPHICS-WSERV-0122 + with those four windows and diagonaly lines on them. + +@SYMTestExpectedResults Expects that all tests will obtain results they expected. +*/ + if (iMajorTest==1 || !iOpacitySupported) + { + if (!iOpacitySupported) + { + _LIT(KNoOpacity,"Opacity is not supported"); + LOG_MESSAGE(KNoOpacity); + } + ((CTMultipleTransStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + TestComplete(); + return; + } + LOG_MESSAGE(KOpacity); + iTest->iState=0; + iMajorTest=1; + RecreateWindowsL(); + break; + } + ((CTMultipleTransStep*)iStep)->RecordTestResultL(); + ++iTest->iState; + } + + +__WS_CONSTRUCT_STEP__(MultipleTrans) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TMulTran.H --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TMulTran.H Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,91 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef __TMULTRAN_H__ +#define __TMULTRAN_H__ + +#include +#include +#include "../tlib/testbase.h" +#include "AUTO.H" +#include "TGraphicsHarness.h" + + +class CTMultipleTrans : public CTWsGraphicsBase + { +public: + CTMultipleTrans(CTestStep* aStep); + ~CTMultipleTrans(); + void ConstructL(); + void CheckDisplay(); + void SimpleTest(); + void ChangeVisibility(); + void ChangeVisibility2(); + void OrdinalPos(); + void SizeChange(); + void MoveWin(); + void GroupWinL(); + void StartShadows(); + void ShadowsOnOff(); + void StartChildL(); + void StartChild2L(); + void FadeTranWin(); +protected: //Pure virtual function from MTestCase + void RunTestCaseL(TInt aCurTestCase); +private: + void RecreateWindowsL(CTWinBase *aParent=0); + void ShadowRegion(TRegion& aRegion,TInt aWin); + void AdvancedCheckRect(); + void SizeChange(TInt aJump); + TSize GetSize(TInt aPos); + + +private: + CTBlankWindow* iBackgroundWin; + CTBackedUpWin* iCheckWin; + CBitmap* iCheckBitmap; + RPointerArray iWindows; + CTransWindow* iTopLeft; + CTransWindow* iTopRight; + CTransWindow* iBotLeft; + CTransWindow* iBotRight; + RBlankWindow iBlankWin; + TRgb iBlankWinCol; + TPoint iBlankWinPos; + TSize iBlankWinSize; + TBool iBlankWinVis; + TBool iShadows; + TInt iMajorTest; + TBool iOpacitySupported; + }; + +class CTMultipleTransStep : public CTGraphicsStep + { +public: + CTMultipleTransStep(); +protected: + //from CTGraphicsStep + virtual CTGraphicsBase* CreateTestL(); + }; + +_LIT(KTMultipleTransStep,"TMultipleTrans"); + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TOOM.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TOOM.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,1583 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Out of memory tests +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + + +#include "TOOM.H" + + +typedef COomFailBase *(*COmmCreate)(CTOom *aTest); + +COomFailBase *CreateOomConnect(CTOom *aTest) + {return(new(ELeave) COomConnect(aTest));} + +COomFailBase *CreateOomWindow(CTOom *aTest) + {return(new(ELeave) COomWindow(aTest));} + +COomFailBase *CreateOomWindowGroup(CTOom *aTest) + {return(new(ELeave) COomWindowGroup(aTest));} + +COomFailBase *CreateOomBackedUpWindow(CTOom *aTest) + {return(new(ELeave) COomBackedUpWindow(aTest));} + +COomFailBase *CreateOomBackupResize(CTOom *aTest) + {return(new(ELeave) COomBackupResize(aTest));} + +COomFailBase *CreateOomBlankWindow(CTOom *aTest) + {return(new(ELeave) COomBlankWindow(aTest));} + +COomFailBase *CreateOomGc(CTOom *aTest) + {return(new(ELeave) COomGc(aTest));} + +COomFailBase *CreateOomScreenDevice(CTOom *aTest) + {return(new(ELeave) COomScreenDevice(aTest));} + +COomFailBase *CreateOomPointerBuffer(CTOom *aTest) + {return(new(ELeave) COomPointerBuffer(aTest));} + +COomFailBase *CreateOomPolygon(CTOom *aTest) + {return(new(ELeave) COomPolygon(aTest));} + +COomFailBase *CreateOomPriorityKey(CTOom *aTest) + {return(new(ELeave) COomPriorityKey(aTest));} + +COomFailBase *CreateOomCaptureKey(CTOom *aTest) + {return(new(ELeave) COomCaptureKey(aTest));} + +COomFailBase *CreateOomCaptureKeyUpDown(CTOom *aTest) + {return(new(ELeave) COomCaptureKeyUpDown(aTest));} + +COomFailBase *CreateOomHotKey(CTOom *aTest) + {return(new(ELeave) COomHotKey(aTest));} + +COomFailBase *CreateOomGroupName(CTOom *aTest) + {return(new(ELeave) COomGroupName(aTest));} + +COomFailBase *CreateOomMessageSend(CTOom *aTest) + {return(new(ELeave) COomMessageSend(aTest));} + +COomFailBase *CreateOomMessageFetch(CTOom *aTest) + {return(new(ELeave) COomMessageFetch(aTest));} + +COomFailBase *CreateOomSprite(CTOom *aTest) + {return(new(ELeave) COomSprite(aTest));} + +COomFailBase *CreateOomPointerCursor(CTOom *aTest) + {return(new(ELeave) COomPointerCursor(aTest));} + +COomFailBase *CreateOomCopyScreen(CTOom *aTest) + {return(new(ELeave) COomCopyScreen(aTest));} + +COomFailBase *CreateOomRequestEvents(CTOom *aTest) + {return(new(ELeave) COomRequestEvents(aTest));} + +COomFailBase *CreateOomCustomTextCursor(CTOom *aTest) + {return(new(ELeave) COomCustomTextCursor(aTest));} + +COomFailBase *CreateOomTranspWindow(CTOom *aTest) + {return(new(ELeave) COomTranspWindow(aTest));} + +COomFailBase *CreateOomObscuredWindow(CTOom *aTest) + {return(new(ELeave) COomObscuredWindow(aTest));} + +COmmCreate CreateOomFailTest[]={ + CreateOomConnect, + CreateOomWindow, + CreateOomWindowGroup, + CreateOomBackedUpWindow, + CreateOomBackupResize, + CreateOomBlankWindow, + CreateOomGc, + CreateOomScreenDevice, + CreateOomPointerBuffer, + CreateOomPolygon, + CreateOomPriorityKey, + CreateOomCaptureKey, + CreateOomCaptureKeyUpDown, + CreateOomHotKey, + CreateOomGroupName, + CreateOomSprite, + CreateOomPointerCursor, + CreateOomCopyScreen, + CreateOomRequestEvents, + CreateOomMessageSend, + CreateOomMessageFetch, + CreateOomCustomTextCursor, + CreateOomTranspWindow, + CreateOomObscuredWindow, + }; + +// +// Individual out of memory test classes // +// + +COomFailBase::COomFailBase(CTOom *aTest) : iTest(aTest) + {} + +void COomFailBase::ConstructL() + { + iTest->INFO_PRINTF1(TestName()); + } + +void COomFailBase::PreFail() + {} + +void COomFailBase::ClearUpL() + {} + +void COomFailBase::Flush() + { + iWs.Flush(); + } + +COomConnect::COomConnect(CTOom *aTest) : COomFailBase(aTest) + {} + +TOomTestName COomConnect::TestName() + { + return(_L("Connect")); + } + +/** Creates a wserv session, connects and creates CWsScreenDevice object +*/ +TInt COomConnect::Fail() + { + TInt err = iWs.Connect(); + if (err!=KErrNone) + return err; + + TRAP(err, iDummyScreen = new (ELeave) CWsScreenDevice(iWs)); + if (err!=KErrNone) + { + iWs.Close(); + return err; + } + + if ((err=iDummyScreen->Construct(iTest->ScreenNumber()))!=KErrNone) + { + delete iDummyScreen; + iDummyScreen = NULL; + iWs.Close(); + return err; + } + + return err; + } + +void COomConnect::ClearUpL() + { + if (iDummyScreen) + { + delete iDummyScreen; + iDummyScreen = NULL; + } + iWs.Close(); + } + +// + +COomSetup::COomSetup(CTOom *aTest) : COomFailBase(aTest) + {} + +void COomSetup::ConstructL() + { + COomFailBase::ConstructL(); + User::LeaveIfError(iWs.Connect()); + iDummyScreen = new (ELeave) CWsScreenDevice(iWs); + User::LeaveIfError(iDummyScreen->Construct(iTest->ScreenNumber())); + + iWinGroup=RWindowGroup(iWs); + iWinGroup.Construct(556); + iWinGroup.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close + } + +COomSetup::~COomSetup() + { + iWinGroup.Close(); + delete iDummyScreen; + iDummyScreen = NULL; + + iTest->TEST(iWs.ResourceCount()==0); + if (iWs.ResourceCount()!=0) + iTest->INFO_PRINTF3(_L("iWs.ResourceCount() return value - Expected: %d, Actual: %d"), 0, iWs.ResourceCount()); + + iWs.Close(); + } + +// + +COomWindowGroup::COomWindowGroup(CTOom *aTest) : COomSetup(aTest) + {} + +TOomTestName COomWindowGroup::TestName() + { + return(_L("Window Group")); + } + +/** Creates a RWindowGroup object +*/ +TInt COomWindowGroup::Fail() + { + iFailWinGroup=RWindowGroup(iWs); + return(iFailWinGroup.Construct(987)); + } + +void COomWindowGroup::ClearUpL() + { + iFailWinGroup.Close(); + } + +// + +COomWindow::COomWindow(CTOom *aTest) : COomSetup(aTest) + {} + +TOomTestName COomWindow::TestName() + { + return(_L("Window")); + } + +/** Creates a RWindow object +*/ +TInt COomWindow::Fail() + { + iFailWin=RWindow(iWs); + return(iFailWin.Construct(iWinGroup,11)); + } + +void COomWindow::ClearUpL() + { + iFailWin.Close(); + } + +// + +COomBackedUpWindow::COomBackedUpWindow(CTOom *aTest) : COomSetup(aTest) + {} + +TOomTestName COomBackedUpWindow::TestName() + { + return(_L("Backed up window")); + } + +/** Creates a RBackedUpWindow object +*/ +TInt COomBackedUpWindow::Fail() + { + iFailWin=RBackedUpWindow(iWs); + return(iFailWin.Construct(iWinGroup,EGray16,22)); + } + +void COomBackedUpWindow::ClearUpL() + { + iFailWin.Close(); + } + +// + +COomBackupResize::COomBackupResize(CTOom *aTest) : COomSetup(aTest) + {} + +COomBackupResize::~COomBackupResize() + { + iFailWin.Close(); + } + +TOomTestName COomBackupResize::TestName() + { + return(_L("Resize backed up window")); + } + +void COomBackupResize::ConstructL() + { + COomSetup::ConstructL(); + iFailWin=RBackedUpWindow(iWs); + User::LeaveIfError(iFailWin.Construct(iWinGroup,EGray16,33)); + User::LeaveIfError(iFailWin.SetSizeErr(TSize(10,10))); + iFailWin.Activate(); + } + +/** Sets the size of previously created backed-up window +*/ +TInt COomBackupResize::Fail() + { + return(iFailWin.SetSizeErr(TSize(100,100))); + } + +void COomBackupResize::ClearUpL() +//Virtual fn declared in CoomFailBase. This is the only one that can leave, I think, but one is enough + { + User::LeaveIfError(iFailWin.SetSizeErr(TSize(10,10))); + } + +// + +COomBlankWindow::COomBlankWindow(CTOom *aTest) : COomSetup(aTest) + {} + +TOomTestName COomBlankWindow::TestName() + { + return(_L("Blank window")); + } + +/** Creates a RBlankWindow object +*/ +TInt COomBlankWindow::Fail() + { + iFailWin=RBlankWindow(iWs); + return(iFailWin.Construct(iWinGroup,44)); + } + +void COomBlankWindow::ClearUpL() + { + iFailWin.Close(); + } + +// + +COomPointerBuffer::COomPointerBuffer(CTOom *aTest) : COomSetup(aTest) + {} + +COomPointerBuffer::~COomPointerBuffer() + { + iFailWin.Close(); + } + +TOomTestName COomPointerBuffer::TestName() + { + return(_L("Pointer buffer")); + } + +void COomPointerBuffer::ConstructL() + { + COomSetup::ConstructL(); + iFailWin=RBackedUpWindow(iWs); + User::LeaveIfError(iFailWin.Construct(iWinGroup,EGray16,55)); + User::LeaveIfError(iFailWin.SetSizeErr(TSize(10,10))); + iFailWin.Activate(); + } + +/** Allocates a buffer for storing pointer movements for previously created backed-up window +*/ +TInt COomPointerBuffer::Fail() + { + return(iFailWin.AllocPointerMoveBuffer(10,0)); + } + +void COomPointerBuffer::ClearUpL() + { + iFailWin.FreePointerMoveBuffer(); + } + +// + +COomPriorityKey::COomPriorityKey(CTOom *aTest) : COomSetup(aTest) + {} + +COomPriorityKey::~COomPriorityKey() + { + } + +TOomTestName COomPriorityKey::TestName() + { + return(_L("Priority key")); + } + +void COomPriorityKey::ConstructL() + { + COomSetup::ConstructL(); + } + +/** Adds a priority key for a previously created window group +*/ +TInt COomPriorityKey::Fail() + { + return(iWinGroup.AddPriorityKey(1,0,0)); + } + +void COomPriorityKey::ClearUpL() + { + iWinGroup.RemovePriorityKey(1,0,0); + } + +// + +COomCaptureKey::COomCaptureKey(CTOom *aTest) : COomSetup(aTest) + {} + +COomCaptureKey::~COomCaptureKey() + { + } + +TOomTestName COomCaptureKey::TestName() + { + return(_L("Capture key")); + } + +void COomCaptureKey::ConstructL() + { + COomSetup::ConstructL(); + } + +/** Requests a capture keys for a previously created window group +*/ +TInt COomCaptureKey::Fail() + { + for (iIndex=0;iIndex<(TInt)(sizeof(iCapKey)/sizeof(iCapKey[0]));iIndex++) + { + TInt ret=iWinGroup.CaptureKey('a',0,0); + if (ret<0) + return(ret); + iCapKey[iIndex]=ret; + } + return(KErrNone); + } + +void COomCaptureKey::ClearUpL() + { + for (TInt index=0;index params(_L8("SomeParams")); + return(iWs.SendMessageToWindowGroup(iWinGroup2.Identifier(),TUid::Uid(123),params)); + } + +void COomMessageSend::ClearUpL() + { + iWinGroup2.Close(); + } + +// + +COomMessageFetch::COomMessageFetch(CTOom *aTest) : COomSetup(aTest) + {} + +COomMessageFetch::~COomMessageFetch() + { + } + +TOomTestName COomMessageFetch::TestName() + { + return(_L("MessageFetch")); + } + +void COomMessageFetch::ConstructL() + { + COomSetup::ConstructL(); + } + +#define CLIENT_HANDLE 555 +#define UID_VALUE 123 +#define MESSAGE_LEN 0x20 +void COomMessageFetch::PreFail() + { + iWinGroup2=RWindowGroup(iWs); + iWinGroup2.Construct(CLIENT_HANDLE); + iWinGroup2.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close + TBuf8 params(_L8("SomeParams")); + TBool retVal = iWs.SendMessageToWindowGroup(iWinGroup2.Identifier(),TUid::Uid(UID_VALUE),params); + iTest->TEST(retVal==KErrNone); + if (retVal!=KErrNone) + iTest->INFO_PRINTF3(_L("iWs.SendMessageToWindowGroup() return value - Expected: %d, Actual: %d"), KErrNone, retVal); + } + +/** Fetches a message +*/ +TInt COomMessageFetch::Fail() + { + TWsEvent event; + TPtr8 ptr(NULL,0); + TUid uid; + event.SetType(EEventMessageReady); + event.SetHandle(CLIENT_HANDLE); + event.SetTimeNow(); + SEventMessageReady& eventMessageReady=*(SEventMessageReady*)event.EventData(); + eventMessageReady.iWindowGroupIdentifier=iWinGroup2.Identifier(); + eventMessageReady.iMessageUid=TUid::Uid(UID_VALUE); + eventMessageReady.iMessageParametersSize=MESSAGE_LEN; + TInt ret=TheClient->iWs.FetchMessage(uid,ptr,event); + if (ret==KErrNone) + User::Free((TAny *)ptr.Ptr()); + return(ret); + } + +void COomMessageFetch::ClearUpL() + { + iWinGroup2.Close(); + } + +// + +COomRequestEvents::COomRequestEvents(CTOom *aTest) : COomSetup(aTest) + {} + +COomRequestEvents::~COomRequestEvents() + { + } + +TOomTestName COomRequestEvents::TestName() + { + return(_L("Request events")); + } + +void COomRequestEvents::ConstructL() + { + COomSetup::ConstructL(); + } + +/** Enables window group change events and modifier change events +*/ +TInt COomRequestEvents::Fail() + { + TInt err; + if ((err=iWinGroup.EnableOnEvents())==KErrNone) + if ((err=iWinGroup.EnableGroupChangeEvents())==KErrNone) + err=iWinGroup.EnableModifierChangedEvents(EModifierCapsLock,EEventControlAlways); + return(err); + } + +void COomRequestEvents::ClearUpL() + { + iWinGroup.DisableOnEvents(); + iWinGroup.DisableGroupChangeEvents(); + iWinGroup.DisableModifierChangedEvents(); + } + +// + +COomCopyScreen::COomCopyScreen(CTOom *aTest) : COomSetup(aTest) + {} + +TOomTestName COomCopyScreen::TestName() + { + return(_L("Copy screen")); + } + +COomCopyScreen::~COomCopyScreen() + { + delete iScrDev; + delete iBitmap; + } + +void COomCopyScreen::ConstructL() + { + COomSetup::ConstructL(); + iScrDev=new(ELeave) CWsScreenDevice(iWs); + User::LeaveIfError(iScrDev->Construct(iTest->ScreenNumber())); + iBitmap=new(ELeave) CFbsBitmap(); + User::LeaveIfError(iBitmap->Create(TSize(100,100),EGray4)); + } + +/** Copies screen to bitmap +*/ +TInt COomCopyScreen::Fail() + { + TInt ret=iScrDev->CopyScreenToBitmap(iBitmap); + if (ret==KErrNone) + ret=iScrDev->CopyScreenToBitmap(iBitmap,TRect(10,10,50,50)); + return(ret); + } + +void COomCopyScreen::ClearUpL() + { + } + +// + +COomSpriteBase::COomSpriteBase(CTOom *aTest) : COomSetup(aTest) + {} + +COomSpriteBase::~COomSpriteBase() + { + iWin.Close(); + delete iBitmap; + delete iMask; + delete iBitmap2; + delete iMask2; + } + +void COomSpriteBase::ConstructL() + { + COomSetup::ConstructL(); + iWin=RWindow(iWs); + User::LeaveIfError(iWin.Construct(iWinGroup,33)); + User::LeaveIfError(iWin.SetSizeErr(TSize(100,100))); + iWin.Activate(); + iBitmap=new(ELeave) CFbsBitmap(); + User::LeaveIfError(iBitmap->Create(TSize(10,10),EGray4)); + iBitmap2=new(ELeave) CFbsBitmap(); + User::LeaveIfError(iBitmap2->Create(TSize(40,40),EGray4)); + iMask=new(ELeave) CFbsBitmap(); + User::LeaveIfError(iMask->Create(TSize(10,10),EGray4)); + iMask2=new(ELeave) CFbsBitmap(); + User::LeaveIfError(iMask2->Create(TSize(40,40),EGray4)); + } + +// + +COomSprite::COomSprite(CTOom *aTest) : COomSpriteBase(aTest) + {} + +TOomTestName COomSprite::TestName() + { + return(_L("Sprites")); + } + +/** Creates a sprite. +*/ +TInt COomSprite::Fail() + { + iSprite=RWsSprite(iWs); + TInt err=iSprite.Construct(iWin,TPoint(10,10),0); + if (err==KErrNone) + { + TSpriteMember sprite; + sprite.iBitmap=iBitmap; + sprite.iMaskBitmap=iMask; + sprite.iInvertMask=EFalse; + sprite.iDrawMode=CGraphicsContext::EDrawModePEN; + sprite.iOffset=TPoint(0,0); + sprite.iInterval=TTimeIntervalMicroSeconds32(100000); + if ((err=iSprite.AppendMember(sprite))==KErrNone) + if ((err=iSprite.Activate())==KErrNone) + { + sprite.iBitmap=iBitmap2; // Bigger bitmap to force resize of bitmap + sprite.iMaskBitmap=iMask2; + if ((err=iSprite.AppendMember(sprite))==KErrNone) + err=iSprite.UpdateMember(1,sprite); + } + } + return(err); + } + +void COomSprite::ClearUpL() + { + iSprite.Close(); + } + +// + +COomPointerCursor::COomPointerCursor(CTOom *aTest) : COomSpriteBase(aTest) + {} + +TOomTestName COomPointerCursor::TestName() + { + return(_L("Pointer cursor")); + } + +/** Creates a pointer cursor. +*/ +TInt COomPointerCursor::Fail() + { + iPointerCursor=RWsPointerCursor(iWs); + TInt err=iPointerCursor.Construct(0); + if (err==KErrNone) + { + TSpriteMember sprite; + sprite.iBitmap=iBitmap; + sprite.iMaskBitmap=iMask; + sprite.iInvertMask=EFalse; + sprite.iDrawMode=CGraphicsContext::EDrawModePEN; + sprite.iOffset=TPoint(0,0); + sprite.iInterval=TTimeIntervalMicroSeconds32(100000); + if ((err=iPointerCursor.AppendMember(sprite))==KErrNone) + if ((err=iPointerCursor.Activate())==KErrNone) + { + sprite.iBitmap=iBitmap2; // Bigger bitmap to force resize of bitmap + sprite.iMaskBitmap=iMask2; + if ((err=iPointerCursor.AppendMember(sprite))==KErrNone) + err=iPointerCursor.UpdateMember(1,sprite); + } + } + return(err); + } + +void COomPointerCursor::ClearUpL() + { + iPointerCursor.Close(); + } + +// + +COomGc::COomGc(CTOom *aTest) : COomSetup(aTest) + {} + +COomGc::~COomGc() + { + delete iScrDev; + } + +TOomTestName COomGc::TestName() + { + return(_L("Graphic Context")); + } + +void COomGc::ConstructL() + { + COomSetup::ConstructL(); + iScrDev=new(ELeave) CWsScreenDevice(iWs); + User::LeaveIfError(iScrDev->Construct(iTest->ScreenNumber())); + } + +/** Creates a graphical context for a previously created screen device. +*/ +TInt COomGc::Fail() + { + TRAPD(err,iFailGc=new(ELeave) CWindowGc(iScrDev)); + if (err!=KErrNone) + return(err); + return(iFailGc->Construct()); + } + +void COomGc::ClearUpL() + { + delete iFailGc; + iFailGc=NULL; + } + +// + +COomPolygon::COomPolygon(CTOom *aTest) : COomSetup(aTest), iPnts(5) + {} + +COomPolygon::~COomPolygon() + { + delete iGc; + delete iScrDev; + iWin.Close(); + } + +TOomTestName COomPolygon::TestName() + { + return(_L("Polygon")); + } + +void COomPolygon::ConstructL() + { + COomSetup::ConstructL(); + iScrDev=new(ELeave) CWsScreenDevice(iWs); + User::LeaveIfError(iScrDev->Construct(iTest->ScreenNumber())); + User::LeaveIfError(iScrDev->CreateContext(iGc)); + iWin=RBackedUpWindow(iWs); + User::LeaveIfError(iWin.Construct(iWinGroup,EGray16,33)); + User::LeaveIfError(iWin.SetSizeErr(TSize(40,40))); + iWin.Activate(); + TInt index; + for(index=0;index<20;index+=2) + iPnts.AppendL(TPoint(20+index,index)); + for(index=0;index<20;index+=2) + iPnts.AppendL(TPoint(40-index,20+index)); + for(index=0;index<20;index+=2) + iPnts.AppendL(TPoint(20-index,40-index)); + for(index=0;index<20;index+=2) + iPnts.AppendL(TPoint(index,20-index)); + } + +/** Draws a polygon. +*/ +TInt COomPolygon::Fail() + { + iGc->Activate(iWin); + iGc->Clear(); + iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + iGc->SetBrushColor(TRgb::Gray4(2)); + iGc->SetPenColor(TRgb::Gray4(0)); + TInt err=iGc->DrawPolygon(&iPnts,CGraphicsContext::EAlternate); + if (err!=KErrNone) + return(err); + err=iGc->DrawPolygon(&iPnts,CGraphicsContext::EWinding); + if (err!=KErrNone) + return(err); + return(KErrNone); + } + +void COomPolygon::ClearUpL() + { + iGc->Deactivate(); + } + +// + +COomScreenDevice::COomScreenDevice(CTOom *aTest) : COomSetup(aTest) + {} + +TOomTestName COomScreenDevice::TestName() + { + return(_L("Screen device")); + } + +/** Creates a screen device handle. +*/ +TInt COomScreenDevice::Fail() + { + TRAPD(err,iScrDev=new(ELeave) CWsScreenDevice(iWs)); + if (err!=KErrNone) + return(err); + return(iScrDev->Construct(iTest->ScreenNumber())); + } + +void COomScreenDevice::ClearUpL() + { + delete iScrDev; + iScrDev=NULL; + } + +// + +COomCustomTextCursor::COomCustomTextCursor(CTOom *aTest) : COomSetup(aTest) + {} + +COomCustomTextCursor::~COomCustomTextCursor() + { + delete iMemberArray; + delete iBitmap; + } + +TOomTestName COomCustomTextCursor::TestName() + { + return(_L("Custom Text Cursor")); + } + +void COomCustomTextCursor::ConstructL() + { + COomSetup::ConstructL(); + + iBitmap = new(ELeave) CFbsBitmap; + User::LeaveIfError(iBitmap->Load(TEST_BITMAP_NAME, EMbmWsautotestBmp1)); + + TSpriteMember member; + member.iMaskBitmap=NULL; + member.iInvertMask=EFalse; + member.iDrawMode=CGraphicsContext::EDrawModePEN; + member.iOffset=TPoint(); + member.iInterval=TTimeIntervalMicroSeconds32(0); + member.iBitmap = iBitmap; + + iMemberArray = new(ELeave) CArrayFixFlat(1); + iMemberArray->AppendL(member); + } + +/** Adds a custom text cursor to the server's list of cursors. +*/ +TInt COomCustomTextCursor::Fail() + { + TInt err = TheClient->iWs.SetCustomTextCursor(0x98765432, iMemberArray->Array(), 0, RWsSession::ECustomTextCursorAlignTop); + if (err == KErrAlreadyExists) + return KErrNone; + else + return err; + } + +void COomCustomTextCursor::ClearUpL() + { + } + +COomTranspWindow::COomTranspWindow(CTOom *aTest) : COomSetup(aTest) + {} + +COomTranspWindow::~COomTranspWindow() + { + delete iBackgroundWin; + delete iFirst; + delete iSecond; + + delete iFbsBitmap; + delete iWsBitmap; + delete iFbsBitmapDevice; + delete iFbsBitmapGc; + delete iWsBitmapDevice; + delete iWsBitmapGc; + } + +TOomTestName COomTranspWindow::TestName() + { + return(_L("Transparent Window")); + } + +void COomTranspWindow::ConstructL() + { + COomSetup::ConstructL(); + + iTransparencyEnabled = (TransparencySupportedL() == KErrNone); + if(!iTransparencyEnabled) + return; + + iFbsBitmap = new (ELeave) CFbsBitmap; + + // Do the creation + const TSize KSizeForBitmap(10,10); + iFbsBitmap->Create(KSizeForBitmap,EGray256); + + // Fill the bitmap with a colour + iFbsBitmapDevice=CFbsBitmapDevice::NewL(iFbsBitmap); + + iFbsBitmapDevice->CreateContext(iFbsBitmapGc); + + iFbsBitmapGc->SetPenStyle(CGraphicsContext::ENullPen); + iFbsBitmapGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + iFbsBitmapGc->SetBrushColor(128); + iFbsBitmapGc->DrawRect(TRect(KSizeForBitmap)); + + // Create a CWsBitmap, and fill it with a colour + iWsBitmap = new (ELeave) CWsBitmap(TheClient->iWs); + + // Do the creation + iWsBitmap->Create(KSizeForBitmap,EGray256); + + // Fill the bitmap with a colour + iWsBitmapDevice=CFbsBitmapDevice::NewL(iWsBitmap); + + iWsBitmapDevice->CreateContext(iWsBitmapGc); + iWsBitmapGc->SetPenStyle(CGraphicsContext::ENullPen); + iWsBitmapGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + iWsBitmapGc->SetBrushColor(128); + iWsBitmapGc->DrawRect(TRect(KSizeForBitmap)); + } + + +/** Does nothing if transparency is not enabled. Creates a blank window with +* two transparent child-windows. Tests setting the transparency via a factor, CFbsBitmap +* or a CWsBitmap, and changing from one to the other. +* Changes child-windows' sizes and toggles their visibility. +*/ +TInt COomTranspWindow::Fail() + { + if(!iTransparencyEnabled) + return KErrNone; + TSize scrSize(TheClient->iScreen->SizeInPixels()); + TRAPD(res, iBackgroundWin = new (ELeave) CBlankWindow(TRgb(0,0,238))); + if(res != KErrNone) + { + return res; + } + + TDisplayMode mode=EColor256; + TRAP(res, iBackgroundWin->SetUpL(TPoint(50,50),scrSize-TSize(100,100),TheClient->iGroup,*TheClient->iGc,&mode)); + if(res != KErrNone) + { + return res; + } + + TheClient->Flush(); + TheClient->WaitForRedrawsToFinish(); + + iBackgroundWin->Win()->SetBackgroundColor(TRgb(51,204,51)); + iBackgroundWin->Invalidate(); + + TheClient->Flush(); + TheClient->WaitForRedrawsToFinish(); + + TRect thePos1(20, 20, 60, 60); + TRect thePos2(100, 40, 160, 80); + TRAP(res, iFirst = CTransWindow::NewL(iBackgroundWin, TRgb(255,0,0,128),&mode)); + if(res != KErrNone) + { + return res; + } + + TRAP(res, iSecond = CTransWindow::NewL(iBackgroundWin, TRgb(255,0,0,128),&mode)); + if(res != KErrNone) + { + return res; + } + + TRAP(res, iFirst->SetExtL(thePos1.iTl,thePos1.Size())); + if(res != KErrNone) + { + return res; + } + + TRAP(res, iSecond->SetExtL(thePos2.iTl,thePos2.Size())); + if(res != KErrNone) + { + return res; + } + + res=SetTransparencyTesting(); + if(res != KErrNone) + { + return res; + } + + TheClient->Flush(); + //TheClient->WaitForRedrawsToFinish(); + + iFirst->Activate(); + iFirst->AssignGC(*TheClient->iGc); + + iSecond->Activate(); + iSecond->AssignGC(*TheClient->iGc); + + iFirst->Win()->SetBackgroundColor(TRgb(0, 0, 255)); + iSecond->Win()->SetBackgroundColor(TRgb(0, 0, 255)); + iFirst->Invalidate(); + iSecond->Invalidate(); + + iFirst->AdjustSize(150,10, 0); + iSecond->AdjustSize(150,10, 0); + + TheClient->Flush(); + TheClient->WaitForRedrawsToFinish(); + + iFirst->ToggleVisibility(); + iSecond->ToggleVisibility(); + + TheClient->Flush(); + TheClient->WaitForRedrawsToFinish(); + + iFirst->AdjustSize(200,10, 0); + iSecond->AdjustSize(200,10, 0); + + iFirst->ToggleVisibility(); + iSecond->ToggleVisibility(); + + TheClient->Flush(); + TheClient->WaitForRedrawsToFinish(); + + return KErrNone; + } + + +// This function tests setting the transparency via a factor, CFbsBitmap +// or a CWsBitmap, and changing from one to the other. +TInt COomTranspWindow::SetTransparencyTesting() + { + TInt res; + TLogMessageText buf; + + // Need all nine transitions, from the 3 ways to the same 3 ways. + // The ways are Factor, CWsBitmap, CFbsBitmap + const TRgb KTransparencyFactor(128,128,128); + res=iFirst->Win()->SetTransparencyFactor(KTransparencyFactor); + if (res!=KErrNone) + { + buf=_L("test failure!! with SetTransparencyFactor -1"); + TheClient->LogMessage(buf); + return res; + } + + res=iFirst->Win()->SetTransparencyBitmap(*iFbsBitmap); + if (res!=KErrNone) + { + buf=_L("test failure!! with SetTransparencyBitmap - fbs -2"); + TheClient->LogMessage(buf); + return res; + } + + res=iFirst->Win()->SetTransparencyWsBitmap(*iWsBitmap); + if (res!=KErrNone) + { + buf=_L("test failure!! with SetTransparencyBitmap - Ws -3"); + TheClient->LogMessage(buf); + return res; + } + + res=iFirst->Win()->SetTransparencyFactor(KTransparencyFactor); + if (res!=KErrNone) + { + buf=_L("test failure!! with SetTransparencyBitmap - fbs -4"); + TheClient->LogMessage(buf); + return res; + } + res=iFirst->Win()->SetTransparencyWsBitmap(*iWsBitmap); + if (res!=KErrNone) + { + buf=_L("test failure!! with SetTransparencyBitmap - Ws -5"); + TheClient->LogMessage(buf); + return res; + } + res=iFirst->Win()->SetTransparencyWsBitmap(*iWsBitmap); + if (res!=KErrNone) + { + buf=_L("test failure!! with SetTransparencyBitmap - Ws -6"); + TheClient->LogMessage(buf); + return res; + } + + res=iFirst->Win()->SetTransparencyBitmap(*iFbsBitmap); + if (res!=KErrNone) + { + buf=_L("test failure!! with SetTransparencyBitmap - fbs -7"); + TheClient->LogMessage(buf); + return res; + } + + res=iFirst->Win()->SetTransparencyBitmap(*iFbsBitmap); + if (res!=KErrNone) + { + buf=_L("test failure!! with SetTransparencyBitmap - fbs -8"); + TheClient->LogMessage(buf); + return res; + } + + res=iFirst->Win()->SetTransparencyFactor(KTransparencyFactor); + if (res!=KErrNone) + { + buf=_L("test failure!! with SetTransparencyFactor -9"); + TheClient->LogMessage(buf); + return res; + } + + res=iFirst->Win()->SetTransparencyFactor(KTransparencyFactor); + if (res!=KErrNone) + { + buf=_L("test failure!! with SetTransparencyFactor -10"); + TheClient->LogMessage(buf); + return res; + } + + return res; + } + +void COomTranspWindow::ClearUpL() + { + delete iFirst; + iFirst = NULL; + delete iSecond; + iSecond = NULL; + delete iBackgroundWin; + iBackgroundWin = NULL; + } + +// + +CWindowWithOneLine* CWindowWithOneLine::NewL(CTWinBase& aParent, const TRect& aExtent) + { + CWindowWithOneLine* self = new(ELeave) CWindowWithOneLine; + CleanupStack::PushL(self); + self->ConstructL(aParent); + const TSize screenSize(TheClient->iScreen->SizeInPixels()); + self->SetExtL(aExtent.iTl, aExtent.Size()); + self->AssignGC(*TheClient->iGc); + self->Activate(); + self->DrawNow(); + CleanupStack::Pop(self); + return self; + } + +void CWindowWithOneLine::Draw() + { + iGc->DrawLine(TPoint(0,0), TPoint(Size().iWidth, Size().iHeight)); + } + +// + +COomObscuredWindow::COomObscuredWindow(CTOom *aTest) : COomSetup(aTest) + {} + +TOomTestName COomObscuredWindow::TestName() + { + return(_L("Obscured window")); + } + +TInt COomObscuredWindow::Fail() + { + TRAPD(err, DoFailL()); + return err; + } + + +void COomObscuredWindow::DoFailL() + { +#ifdef __WINS__ + RDebug::Print(_L("COomObscuredWindow::DoFailL - enter")); +#endif + const TRect extent(20, 20, 100, 100); + CBlankWindow* backgroundWindow = new(ELeave) CBlankWindow(TRgb(12, 23, 34)); + CleanupStack::PushL(backgroundWindow); + TDisplayMode mode = EColor16MAP; + backgroundWindow->SetUpL(extent.iTl, extent.Size(), TheClient->iGroup, *TheClient->iGc, &mode); + + CWindowWithOneLine* window = CWindowWithOneLine::NewL(*backgroundWindow, extent); + CleanupStack::PushL(window); +#ifdef __WINS__ + RDebug::Print(_L("COomObscuredWindow - WaitForRedrawsToFinish - 1")); +#endif + TheClient->WaitForRedrawsToFinish(); + + CBlankWindow* obscuringWindow = new(ELeave) CBlankWindow(TRgb(255, 0, 0)); + CleanupStack::PushL(obscuringWindow); + obscuringWindow->SetUpL(extent.iTl, extent.Size(), backgroundWindow, *TheClient->iGc, &mode); + + TheClient->Flush(); +#ifdef __WINS__ + RDebug::Print(_L("COomObscuredWindow - WaitForRedrawsToFinish - 2")); +#endif + TheClient->WaitForRedrawsToFinish(); + + window->Invalidate(); + + for(TInt i = 0; i < 50; i++) + { + RWindow anotherWin(iWs); + User::LeaveIfError(anotherWin.Construct(iWinGroup, 11)); + anotherWin.Close(); + + if(i % 4) + window->Invalidate(); + + TheClient->Flush(); +#ifdef __WINS__ + RDebug::Print(_L("COomObscuredWindow - WaitForRedrawsToFinish - 3 - %d"), i); +#endif + TheClient->WaitForRedrawsToFinish(); + } + + TheClient->Flush(); +#ifdef __WINS__ + RDebug::Print(_L("COomObscuredWindow - WaitForRedrawsToFinish - 4")); +#endif + TheClient->WaitForRedrawsToFinish(); + + CleanupStack::PopAndDestroy(obscuringWindow); + CleanupStack::PopAndDestroy(window); + CleanupStack::PopAndDestroy(backgroundWindow); +#ifdef __WINS__ + RDebug::Print(_L("COomObscuredWindow::DoFailL - exit")); +#endif + } + +void COomObscuredWindow::ClearUpL() + { + } + +// + +CTOom::CTOom(CTestStep* aStep) : CTWsGraphicsBase(aStep) + { + iState = 0; + } + +const TDesC& CTOom::TestName() const + { + _LIT(KTestName,"CTOom"); + return(KTestName()); + } + +void CTOom::DoOomTestL(COomFailBase *aOomTest) + { + //TLogMessageText buf; + TEST(aOomTest!=NULL); + if (aOomTest==NULL) + INFO_PRINTF1(_L("aOomTest - Expected: Not Null, Actual: NULL")); + + TRAPD(ret1,aOomTest->ConstructL()); + TEST(ret1==KErrNone); + if (ret1!=KErrNone) + INFO_PRINTF3(_L("aOomTest->ConstructL() return value - Expected: %d, Actual: %d"), KErrNone, ret1); + + aOomTest->Flush(); + __UHEAP_MARK; +// TInt oldCount=TheClient->iWs.HeapCount(); + for(TInt mode=0;mode<3;mode++) + { + /*buf.Format(_L("OOMTest[%d] Mode=%d"),iState,mode), + TheClient->LogMessage(buf);*/ + TInt successCount=0; + for(TInt count=1;;count++) + { + TInt ret; + aOomTest->PreFail(); + if (mode==0) + TheClient->iWs.HeapSetFail(RHeap::EDeterministic,count); + else if (mode==1) + TheClient->iWs.HeapSetBurstFail(RHeap::EBurstFailNext, count, KMaxTUint16); + else if (mode==3) + { + __UHEAP_SETFAIL(RHeap::EDeterministic,count); //Leavescan will complain about EFailNext, although it isn't a leaving function + } + ret=aOomTest->Fail(); + if (mode==0) + TheClient->iWs.HeapSetFail(RHeap::ENone,0); + else if (mode==1) + TheClient->iWs.HeapSetBurstFail(RHeap::ENone, 0, 0); + else if (mode==2) + { + __UHEAP_RESET; + } + aOomTest->ClearUpL(); //In just 1 case this could leave... + aOomTest->Flush(); + if (ret==KErrNone) + { + if (successCount==10) + break; + successCount++; + } + else + { + /*if (successCount>0) + { + buf.Format(_L("[%d,%d] Count=%d, MaxSuccess=%d"),iState,mode,count,successCount); + TheClient->LogMessage(buf); + }*/ + successCount=0; + /*if (ret!=KErrNoMemory) + { + buf.Format(_L("[%d,%d] Fail, Count=%d, Error=%d"),iState,mode,count,ret); + TheClient->LogMessage(buf); + }*/ + TEST(ret==KErrNoMemory); + if (ret!=KErrNoMemory) + INFO_PRINTF3(_L("aOomTest->Fail() return value - Expected: %d, Actual: %d"), KErrNoMemory, ret); + + } + } + /*buf.Format(_L("[%d,%d] LastCount=%d"),iState,mode,count), + TheClient->LogMessage(buf);*/ + } +// TEST(oldCount>=TheClient->iWs.HeapCount()); + __UHEAP_MARKEND; + delete aOomTest; + /*buf.Format(_L("OOMTest[%d] Finished"),iState); + TheClient->LogMessage(buf);*/ + } + +void CTOom::ConstructL() + { + iShieldWin=RBlankWindow(TheClient->iWs); + User::LeaveIfError(iShieldWin.Construct(*(TheClient->iGroup->GroupWin()),1)); +// iShieldWin.SetOrdinalPosition(0,-1); + iShieldWin.Activate(); + } + +CTOom::~CTOom() + { + iShieldWin.Close(); + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-0124 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Out of memory tests + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Uses deterministic heap failure mode to test WSERV classes against out-of-memory errors. + Sets and unsets deterministic mode using both RWsSession.HeapSetFail() methods and + __UHEAP_SETFAIL/__UHEAP_RESET macros (doing this both client and WSERV threads are tested). + On each step the test creates a failure object and repeatedly asks it to do some work (calling Fail() method). + A failure object is an object which encapsulates some allocation functionality inside it's Fail() method. + The test is performed for 23 different failure objects that do the following: + 1. Creates a wserv session, connects and creates CWsScreenDevice object. + 2. Creates a RWindowGroup object. + 3. Creates a RWindow object. + 4. Creates a RBackedUpWindow object. + 5. Sets the size of previously created backed-up window. + 6. Creates a RBlankWindow object. + 7. Allocates a buffer for storing pointer movements for a previously created backed-up window. + 8. Adds a priority key for a previously created window group. + 9. Requests a capture keys for a previously created window group. + 10. Requests the capture of key-up and key-down events for a previously created window group. + 11. Sets hot key for the session. + 12. Sets the window group's name. + 13. Sends a message to another window group. + 14. Fetches a message. + 15. Enables window group change events and modifier change events. + 16. Copies screen to bitmap. + 17. Creates a sprite. + 18. Creates a pointer cursor. + 19. Creates a graphical context for a previously created screen device. + 20. Draws a polygon. + 21. Creates a screen device handle. + 22. Adds a custom text cursor to the server's list of cursors. + 23. Does nothing if transparency is not enabled. Creates a blank window with + two transparent child-windows. Tests setting the transparency via a factor, CFbsBitmap + or a CWsBitmap, and changing from one to the other. + Changes child-windows' sizes and toggles their visibility. + + +@SYMTestExpectedResults The test checks that the creation failure objects doesn't fail and their's work either causes no errors or causes KErrNoMemory error. +*/ +void CTOom::RunTestCaseL(TInt /*aCurTestCase*/) + { + ((CTOomStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0124")); + if (iState==0) + { + // commented by Anton Golovko, 01.03.2006 while converting to TEF + // the code below prevented the test to do anything. +// if (iTest->IsFullRomL()) +// { +// TestComplete(); +// return; +// } + iOldCount=TheClient->iWs.HeapCount(); + } + else if (iState==sizeof(CreateOomFailTest)/sizeof(CreateOomFailTest[0])) + { + iTest->CloseAllPanicWindows(); + TInt heapCount=TheClient->iWs.HeapCount(); + if (heapCount>iOldCount) + { + TEST(iOldCount>=heapCount-184); //For some uninvestigated reason 184 object get allocated on the server side, partly because of INFO_PRINTF1 + if (iOldCount=heapCount-174 - Expected: %d, Actual: %d"), heapCount-184, iOldCount); + + } + ((CTOomStep*)iStep)->CloseTMSGraphicsStep(); + TestComplete(); + return; + } + DoOomTestL(CreateOomFailTest[iState++](this)); + ((CTOomStep*)iStep)->RecordTestResultL(); + } + + + + +__WS_CONSTRUCT_STEP__(Oom) + diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TOOM.H --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TOOM.H Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,425 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef __TOOM_H__ +#define __TOOM_H__ + +#include +#include +#include "../tlib/testbase.h" +#include "AUTO.H" +#include "TGraphicsHarness.h" + + +typedef TBuf<0x40> TOomTestName; + +class CTOom; + + +class COomFailBase : public CBase + { +public: + COomFailBase(CTOom *aTest); + virtual void ConstructL(); + virtual void PreFail(); + virtual void ClearUpL(); + virtual void Flush(); + virtual TInt Fail()=0; + virtual TOomTestName TestName()=0; +protected: + RWsSession iWs; + CWsScreenDevice* iDummyScreen; + CTOom *iTest; + }; + + +class COomConnect : public COomFailBase + { +public: + COomConnect(CTOom *aTest); + TInt Fail(); + void ClearUpL(); + TOomTestName TestName(); + }; + +class COomSetup : public COomFailBase + { +public: + COomSetup(CTOom *aTest); + ~COomSetup(); + void ConstructL(); +protected: + RWindowGroup iWinGroup; + }; + +class COomWindowGroup : public COomSetup + { +public: + COomWindowGroup(CTOom *aTest); + void ClearUpL(); + TInt Fail(); + TOomTestName TestName(); +private: + RWindowGroup iFailWinGroup; + }; + +class COomWindow : public COomSetup + { +public: + COomWindow(CTOom *aTest); + void ClearUpL(); + TInt Fail(); + TOomTestName TestName(); +private: + RWindow iFailWin; + }; + +class COomBackedUpWindow : public COomSetup + { +public: + COomBackedUpWindow(CTOom *aTest); + void ClearUpL(); + TInt Fail(); + TOomTestName TestName(); +private: + RBackedUpWindow iFailWin; + }; + +class COomBlankWindow : public COomSetup + { +public: + COomBlankWindow(CTOom *aTest); + void ClearUpL(); + TInt Fail(); + TOomTestName TestName(); +private: + RBlankWindow iFailWin; + }; + +class COomGc : public COomSetup + { +public: + COomGc(CTOom *aTest); + ~COomGc(); + void ConstructL(); + void ClearUpL(); + TInt Fail(); + TOomTestName TestName(); +private: + CWsScreenDevice *iScrDev; + CWindowGc *iFailGc; + }; + +class COomPolygon : public COomSetup + { +public: + COomPolygon(CTOom *aTest); + ~COomPolygon(); + void ConstructL(); + void ClearUpL(); + TInt Fail(); + TOomTestName TestName(); +private: + CWsScreenDevice *iScrDev; + RBackedUpWindow iWin; + CWindowGc *iGc; + CArrayFixSeg iPnts; + }; + +class COomScreenDevice : public COomSetup + { +public: + COomScreenDevice(CTOom *aTest); + void ClearUpL(); + TInt Fail(); + TOomTestName TestName(); +private: + CWsScreenDevice *iScrDev; + }; + +class COomBackupResize : public COomSetup + { +public: + COomBackupResize(CTOom *aTest); + ~COomBackupResize(); + void ConstructL(); + void ClearUpL(); + TInt Fail(); + TOomTestName TestName(); +private: + RBackedUpWindow iFailWin; + }; + +class COomPointerBuffer : public COomSetup + { +public: + COomPointerBuffer(CTOom *aTest); + ~COomPointerBuffer(); + void ConstructL(); + void ClearUpL(); + TInt Fail(); + TOomTestName TestName(); +private: + RBackedUpWindow iFailWin; + }; + +class COomPriorityKey : public COomSetup + { +public: + COomPriorityKey(CTOom *aTest); + ~COomPriorityKey(); + void ConstructL(); + void ClearUpL(); + TInt Fail(); + TOomTestName TestName(); + }; + +class COomCaptureKey : public COomSetup + { +public: + COomCaptureKey(CTOom *aTest); + ~COomCaptureKey(); + void ConstructL(); + void ClearUpL(); + TInt Fail(); + TOomTestName TestName(); +private: + TInt32 iCapKey[20]; + TInt iIndex; + }; + +class COomCaptureKeyUpDown : public COomSetup + { +public: + COomCaptureKeyUpDown(CTOom *aTest); + ~COomCaptureKeyUpDown(); + void ConstructL(); + void ClearUpL(); + TInt Fail(); + TOomTestName TestName(); +private: + TInt32 iCapKey[20]; + TInt iIndex; + }; + +class COomHotKey : public COomSetup + { +public: + COomHotKey(CTOom *aTest); + ~COomHotKey(); + void ConstructL(); + void ClearUpL(); + TInt Fail(); + TOomTestName TestName(); + }; + +class COomGroupName : public COomSetup + { +public: + COomGroupName(CTOom *aTest); + ~COomGroupName(); + void ConstructL(); + void ClearUpL(); + TInt Fail(); + TOomTestName TestName(); + }; + +class COomMessageSend: public COomSetup + { +public: + COomMessageSend(CTOom *aTest); + ~COomMessageSend(); + void ConstructL(); + void PreFail(); + void ClearUpL(); + TInt Fail(); + TOomTestName TestName(); +private: + RWindowGroup iWinGroup2; + }; + +class COomMessageFetch: public COomSetup + { +public: + COomMessageFetch(CTOom *aTest); + ~COomMessageFetch(); + void PreFail(); + void ConstructL(); + void ClearUpL(); + TInt Fail(); + TOomTestName TestName(); +private: + RWindowGroup iWinGroup2; + }; + +class COomCopyScreen : public COomSetup + { +public: + COomCopyScreen(CTOom *aTest); + ~COomCopyScreen(); + void ConstructL(); + void ClearUpL(); + TInt Fail(); + TOomTestName TestName(); +private: + CWsScreenDevice *iScrDev; + CFbsBitmap *iBitmap; + }; + +class COomRequestEvents : public COomSetup + { +public: + COomRequestEvents(CTOom *aTest); + ~COomRequestEvents(); + void ConstructL(); + void ClearUpL(); + TInt Fail(); + TOomTestName TestName(); + }; + +class COomSpriteBase : public COomSetup + { +public: + COomSpriteBase(CTOom *aTest); + ~COomSpriteBase(); + void ConstructL(); +protected: + RWindow iWin; + CFbsBitmap *iBitmap; + CFbsBitmap *iMask; + CFbsBitmap *iBitmap2; + CFbsBitmap *iMask2; + }; + +class COomSprite : public COomSpriteBase + { +public: + COomSprite(CTOom *aTest); + void ClearUpL(); + TInt Fail(); + TOomTestName TestName(); +private: + RWsSprite iSprite; + }; + +class COomPointerCursor : public COomSpriteBase + { +public: + COomPointerCursor(CTOom *aTest); + void ClearUpL(); + TInt Fail(); + TOomTestName TestName(); +private: + RWsPointerCursor iPointerCursor; + }; + +class COomCustomTextCursor : public COomSetup + { +public: + COomCustomTextCursor(CTOom *aTest); + ~COomCustomTextCursor(); + void ConstructL(); + void ClearUpL(); + TInt Fail(); + TOomTestName TestName(); +private: + CArrayFixFlat* iMemberArray; + CFbsBitmap* iBitmap; + }; + +class COomTranspWindow : public COomSetup + { +public: + COomTranspWindow(CTOom *aTest); + ~COomTranspWindow(); + void ConstructL(); + void ClearUpL(); + TInt Fail(); + TOomTestName TestName(); + CTransWindow* CreateTransWinL(CTWinBase* aParent,TRgb aColor,TRect aPos, TDisplayMode* aDisplayMode); +private: + TInt SetTransparencyTesting(); + + CBlankWindow* iBackgroundWin; + CTransWindow* iFirst; + CTransWindow* iSecond; + + CFbsBitmap* iFbsBitmap; + CWsBitmap* iWsBitmap; + CFbsBitmapDevice* iFbsBitmapDevice; + CFbsBitGc* iFbsBitmapGc; + CFbsBitmapDevice* iWsBitmapDevice; + CFbsBitGc* iWsBitmapGc; + TBool iTransparencyEnabled; + }; + + +class CWindowWithOneLine : public CTWin + { +public: + static CWindowWithOneLine* NewL(CTWinBase& aParent, const TRect& aExtent); + void Draw(); + }; + +class COomObscuredWindow : public COomSetup + { +public: + COomObscuredWindow(CTOom *aTest); + void ClearUpL(); + TInt Fail(); + TOomTestName TestName(); +private: + void DoFailL(); + }; + +class CTOom : public CTWsGraphicsBase + { +public: + CTOom(CTestStep* aStep); + ~CTOom(); + const TDesC& TestName() const; + void ConstructL(); + void DoOomTestL(COomFailBase *aOomTest); + inline TInt ScreenNumber(){ return iTest->ScreenNumber();} + +protected: + virtual void RunTestCaseL(TInt aCurTestCase); + +private: + TInt iOldCount; + RBlankWindow iShieldWin; + TSize iWinSize; + TInt iState; + }; + +class CTOomStep : public CTGraphicsStep + { +public: + CTOomStep(); +protected: + //from CTGraphicsStep + virtual CTGraphicsBase* CreateTestL(); + }; + +_LIT(KTOomStep,"TOom"); + + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TOOMDRAW.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TOOMDRAW.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,244 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Test out of memory redraws +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include "TOOMDRAW.H" + +void DrawTestScreen(CWindowGc *aGc, const TSize &aSize) + { + aGc->SetPenSize(TSize(10,10)); + aGc->SetBrushStyle(CGraphicsContext::EVerticalHatchBrush); + aGc->DrawRect(TRect(aSize)); + } + +CTestWin::CTestWin() + { + } + +void CTestWin::Draw() + { +#if defined(FULLLOGGING) + _LIT(KLog,"Drawing Test Win:%d %d,%d"); + TLogMessageText buf; + buf.Format(KLog,Size().iWidth>320?1:0,Size().iWidth,Size().iHeight); + TheClient->LogMessage(buf); +#endif + DrawTestScreen(iGc,Size()); + } + +CBaseTestWin::CBaseTestWin() : CTBackedUpWin(EGray4) + {} + +void CBaseTestWin::Resized(const TSize &aNewSize) + { + TheGc->Activate(*DrawableWin()); + DrawTestScreen(TheGc,aNewSize); + TheGc->Deactivate(); + } + +CToomDraw::CToomDraw(CTestStep* aStep): + CTWsGraphicsBase(aStep) + { + } + +CToomDraw::~CToomDraw() + { + TheClient->iWs.HeapSetFail(RHeap::ENone,0); //In case the test crashes and it hasn't been reset + DeleteWindows(); + } + +void CToomDraw::DeleteWindows() + { + delete iTestWin; + iTestWin=NULL; + delete iBaseWin; + iBaseWin=NULL; + delete iBackWin; + iBackWin=NULL; + delete iBlankWin; + iBlankWin=NULL; + } + +void CToomDraw::ConstructL() + { + iScrSize=TheClient->iScreen->SizeInPixels(); + iBlankWin=new(ELeave) CTBlankWindow; + iBlankWin->ConstructL(*TheClient->iGroup); + iBlankWin->SetColor(TRgb::Gray4(2)); //Grey + iBlankWin->Activate(); + iBackWin=new(ELeave) CTestWin(); + iBackWin->SetUpL(TPoint(0,iScrSize.iHeight/4), TSize(iScrSize.iWidth,iScrSize.iHeight/2), TheClient->iGroup, *TheClient->iGc); + iBaseWin=new(ELeave) CBaseTestWin(); + iBaseWin->SetUpL(TPoint(iScrSize.iWidth*2/3,0), TSize(iScrSize.iWidth/3,iScrSize.iHeight), TheClient->iGroup, *TheClient->iGc); + } + +void CToomDraw::CreateTestWinL() + { + iTestWin=new(ELeave) CTestWin(); + iTestWin->ConstructL(*TheClient->iGroup); + iTestWin->SetExtL(TPoint(0,0), TSize(iScrSize.iWidth/3,iScrSize.iHeight)); + iTestWin->AssignGC(*TheClient->iGc); + iTestWin->BaseWin()->SetShadowHeight(2); + } + +void CToomDraw::TriggerOomDrawsL(TInt aCount) + { + if(iTestWin) + { + iTestWin->SetExtL(TPoint(),iScrSize); + } + delete iTestWin; + iTestWin=NULL; + CreateTestWinL(); + TheClient->iWs.HeapSetFail(RHeap::EDeterministic,aCount); + iTestWin->Activate(); + TheClient->iWs.Finish(); + } + +TBool CToomDraw::CheckWindowsL() + { + TLogMessageText buf; + TBool pass = DoCheckRect(iTestWin,iBaseWin); + if (pass) + { + TEST(ETrue); //Adds one to test count + #if defined(FULLLOGGING) + _LIT(KLog,"OOM Draw Test Pass, State=%d"); + buf.Format(KLog,iState); + #endif + iRetryCount=0; + } + else + { + if (iRetryCount==4) + { + if ((iTest->RedrawStoreTypeL()==EPartialRedraw_PreserveStoredCmds || + iTest->RedrawStoreTypeL()==EPartialRedraw_FullRedrawSupport) && (iState==19 || iState==30) || + ((iState>=2 && iState<=6) && (iTest->RedrawStoreTypeL()==EPartialRedraw_None || iTest->RedrawStoreTypeL()==EPartialRedraw_FullRedrawSupport))) + { + #if defined(FULLLOGGING) + _LIT(KLog,"OOM Draw Test Known F a i l, State=%d"); + buf.Format(KLog,iState); + #endif + pass=ETrue; + } + else + { + if (iFailAt==0) + iFailAt=iState; + ++iFails; //mark this test as failed + #if defined(LOGGING) + _LIT(KLog,"OOM Draw Test FAIL, State=%d <------- FAIL"); + buf.Format(KLog,iState); + #endif + ++iState; //and advance to next test + } + iRetryCount=0; + } + else + { + #if defined(FULLLOGGING) + _LIT(KLog,"OOM Draw Test F a i l, State=%d retrying"); + buf.Format(KLog,iState); + #endif + if (++iRetryCount%2==0) + iBackWin->DrawNow(); + } + } + if (buf.Length()>0) + TheClient->LogMessage(buf); + return pass; + } + +void CToomDraw::RunTestCaseL(TInt aCurTestCase) + { + TBool testFinished = false; + ((CToomDrawStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); + switch(aCurTestCase) + { +/** +@SYMTestCaseID GRAPHICS-WSERV-0110 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test trying to draw when out of memory + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Set out of memory and try drawing + +@SYMTestExpectedResults Out of memory drawing is handle correctly +*/ + case 1: + ((CToomDrawStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0110")); + while (!testFinished) + { + if (iDoCheck) + { + TheClient->iWs.HeapSetFail(RHeap::ENone,0); + TheClient->WaitForRedrawsToFinish(); + if (CheckWindowsL()) + { + ++iState; + if (iState==EMaxOOMState) + DeleteWindows(); + } + iDoCheck=EFalse; + TheClient->iWs.Finish(); + } + else + { + if (iState==EMaxOOMState) + { + if (iFails>0) + { + #if defined(LOGING) + _LIT(KLog,"OOM Draw Test Failed, First Fail At %d, Number of Fails %d"); + TLogMessageText buf; + buf.Format(KLog,iFailAt,iFails); + TheClient->LogMessage(buf); + #endif + TEST(iFails==0); + } + User::After(500000); // Let the rest of the world catch up after OOM death + testFinished = true; + } + else if (iState < 3 && iTest->IsFullRomL()) + testFinished = true; + else + TriggerOomDrawsL(iState); + iDoCheck=ETrue; + } + } + break; + case 2: + ((CToomDrawStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + ((CToomDrawStep*)iStep)->CloseTMSGraphicsStep(); + TestComplete(); + break; + } + ((CToomDrawStep*)iStep)->RecordTestResultL(); + } + +__WS_CONSTRUCT_STEP__(oomDraw) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TOOMDRAW.H --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TOOMDRAW.H Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,90 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef __TOOMDRAW_H__ +#define __TOOMDRAW_H__ + +#include +#include +#include "../tlib/testbase.h" +#include "AUTO.H" +#include "TGraphicsHarness.h" + +#define LOGGING yes //Log only failures +#if defined(LOGGING) + #define FULLLOGGING yes +#endif + +class CTestWin : public CTWin + { +public: + CTestWin(); + void Draw(); + }; + +class CBaseTestWin : public CTBackedUpWin + { +public: + CBaseTestWin(); + void Resized(const TSize &aNewSize); + }; + +class CToomDraw : public CTWsGraphicsBase + { +private: + enum {EMaxOOMState=150}; +public: + CToomDraw(CTestStep* aStep); + ~CToomDraw(); + void ConstructL(); + void CreateTestWinL(); + void TriggerOomDrawsL(TInt aCount); + TBool CheckWindowsL(); + void DeleteWindows(); +protected: +//from CTGraphicsStep + virtual void RunTestCaseL(TInt aCurTestCase); +private: + TBool iDoCheck; + TSize iScrSize; + CTBlankWindow* iBlankWin; + CTestWin *iTestWin; + CBaseTestWin *iBaseWin; + CTestWin *iBackWin; + TInt iFails; + TInt iFailAt; + TInt iRetryCount; + TInt iState; + }; + +class CToomDrawStep : public CTGraphicsStep + { +public: + CToomDrawStep(); +protected: + //from CTGraphicsStep + virtual CTGraphicsBase* CreateTestL(); + }; + +_LIT(KToomDrawStep,"TOOMDRAW"); + + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TORDINAL.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TORDINAL.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,579 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// ORDINAL.CPP +// Test ordinal position and priority changes on windows +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include "TORDINAL.H" + +_LIT(KLogNextSibling,"NextSibling of iChild%d is not iChild%d"); +_LIT(KLogNoNextSibling,"iChild%d has a NextSibling when it shouldn't"); +_LIT(KLogPrevSibling,"PrevSibling of iChild%d is not iChild%d"); +_LIT(KLogNoPrevSibling,"iChild%d has a PrevSibling when it shouldn't"); + +CTOrdinal::CTOrdinal(CTestStep* aStep): + CTWsGraphicsBase(aStep) + { + } + +COrdinalWindowBase::COrdinalWindowBase(CTClient *aClient, CTestBase* aTest, CTestStep* aTestStep) : iClient(aClient), iTest(aTest), iTestStep(aTestStep) + { + } + +COrdinalWindow::COrdinalWindow(CTClient *aClient, CTestBase* aTest, CTestStep* aTestStep) : COrdinalWindowBase(aClient, aTest, aTestStep), iClientWin(aClient->iWs) + { + __DECLARE_NAME(_S("COrdinalWindow")); + } + +COrdinalWindowGroup::COrdinalWindowGroup(CTClient *aClient, CTestBase* aTest, CTestStep* aTestStep) : COrdinalWindowBase(aClient, aTest, aTestStep), iGroupWin(aClient->iWs) + { + __DECLARE_NAME(_S("COrdinalWindowGroup")); + } + +COrdinalWindowBase::~COrdinalWindowBase() + { + if (iWin) + iWin->Close(); + } + +void COrdinalWindowBase::Draw() + {} + +inline RWindowTreeNode* COrdinalWindowBase::WinTreeNode() + { + return(iWin); + } + +inline TUint32 COrdinalWindowBase::Handle() + { + return reinterpret_cast(this); + } + +COrdinalWindowBase *COrdinalWindowGroup::NewL(CTClient *aClient, CTestBase* aTest, CTestStep* aTestStep) + { + COrdinalWindowGroup *oWin=new(ELeave) COrdinalWindowGroup(aClient, aTest, aTestStep); + TInt err=oWin->iGroupWin.Construct((TUint32)oWin); + if (err<0) + { + delete oWin; + User::Leave(err); + } + oWin->iWin= &oWin->iGroupWin; + return(oWin); + } + +COrdinalWindowBase *COrdinalWindow::NewL(CTClient* aClient, RWindowTreeNode* aParent, CTestBase* aTest, CTestStep* aTestStep) + { + COrdinalWindow *oWin=new(ELeave) COrdinalWindow(aClient, aTest, aTestStep); + TInt err=oWin->iClientWin.Construct(*aParent,(TUint32)oWin); + if (err!=KErrNone) + { + delete oWin; + User::Leave(err); + } + oWin->iClientWin.Activate(); + oWin->iWin= &oWin->iClientWin; + return(oWin); + } + +TInt COrdinalWindowBase::OrdinalPosition() + { + return(iWin->OrdinalPosition()); + } + +void COrdinalWindowBase::SetOrdinalPosition(TInt aPos) + { + iWin->SetOrdinalPosition(aPos); + } + +void COrdinalWindowBase::SetOrdinalPosition(TInt aPos,TInt aPri) + { + iWin->SetOrdinalPosition(aPos,aPri); + } + +CTOrdinal::~CTOrdinal() + { + delete iClient; + } + +void DZ(COrdinalWindowBase * &aX) + { + delete aX; + aX=NULL; + } + +void CTOrdinal::DestroyWindows() + { + DZ(iParent); + DZ(iParent2); + DZ(iParent3); + for(TInt child=0;childTEST(iWin->OrdinalPosition()==aTestPos); + } + +void COrdinalWindowBase::SetAndTestOP(TInt aPos,TInt aTestPos) + { + iWin->SetOrdinalPosition(aPos); + iTestStep->TEST(iWin->OrdinalPosition()==aTestPos); + } + +void COrdinalWindowBase::SetAndTestOP(TInt aPos) + { + SetAndTestOP(aPos, aPos); + } + +TInt COrdinalWindowBase::SetToLastAndGetOP() + { + iWin->SetOrdinalPosition(-1); + return(iWin->OrdinalPosition()); + } + +TInt COrdinalWindowBase::SetToLastAndGetOPPri(TInt aPri) + { + iWin->SetOrdinalPosition(-1, aPri); + return(iWin->OrdinalPosition()); + } + +void COrdinalWindowBase::SetAndTestOPPri(TInt aPos,TInt aPri,TInt aTestPos) + { + iWin->SetOrdinalPosition(aPos,aPri); + iTestStep->TEST(iWin->OrdinalPosition()==aTestPos); + iTestStep->TEST(iWin->OrdinalPriority()==aPri); + } + +void COrdinalWindowBase::SetAndTestOPPri(TInt aPos,TInt aPri) + { + SetAndTestOPPri(aPos,aPri,aPos); + } + +inline COrdinalWindowBase* COrdinalWindowBase::NextSibling() const + { + return reinterpret_cast(iWin->NextSibling()); + } + +inline COrdinalWindowBase* COrdinalWindowBase::PrevSibling() const + { + return reinterpret_cast(iWin->PrevSibling()); + } + +void CTOrdinal::TestWindowOrderNext(TInt aBefore,TInt aAfter) + { + TInt retVal=(iChild[aBefore]->NextSibling()==iChild[aAfter]); + TEST(retVal); + if (!retVal) + LOG_MESSAGE3(KLogNextSibling,aBefore,aAfter); + } + +void CTOrdinal::TestWindowOrderNext(TInt aLast) + { + TInt retVal=(iChild[aLast]->NextSibling()==0); + TEST(retVal); + if (!retVal) + LOG_MESSAGE2(KLogNoNextSibling,aLast); + } + +void CTOrdinal::TestWindowOrderPrev(TInt aAfter,TInt aBefore) + { + TInt retVal=(iChild[aAfter]->PrevSibling()==iChild[aBefore]); + TEST(retVal); + if (!retVal) + LOG_MESSAGE3(KLogPrevSibling,aAfter,aBefore); + } + +void CTOrdinal::TestWindowOrderPrev(TInt aFirst) + { + TInt retVal=(iChild[aFirst]->PrevSibling()==0); + TEST(retVal); + if (!retVal) + LOG_MESSAGE2(KLogNoPrevSibling,aFirst); + } + +void CTOrdinal::OrdinalPos() + { + TInt last=iChild[0]->SetToLastAndGetOP(); + iChild[0]->SetAndTestOP(0); + iChild[5]->TestOP(5); + iChild[1]->SetAndTestOP(3); + iChild[0]->SetAndTestOP(0); + iChild[0]->SetAndTestOP(-1,last); + iChild[0]->SetAndTestOP(-1000,last); + iChild[0]->SetAndTestOP(2); + iChild[0]->SetAndTestOP(-1000,last); + iChild[0]->SetAndTestOP(0); + for(TInt index=0;index<=5;index++) + iChild[4]->SetAndTestOP(index,index); + iChild[0]->SetAndTestOP(-1,last); + iChild[1]->SetAndTestOP(-1,last); + iChild[2]->SetAndTestOP(-1,last); + iChild[3]->SetAndTestOP(-1,last); + iChild[4]->SetAndTestOP(-1,last); + iChild[5]->SetAndTestOP(-1,last); + TInt child; + for (child=0;childSetToLastAndGetOPPri(12); + iChild[2]->TestOP(last12); + TInt lastKMax=iChild[2]->SetToLastAndGetOPPri(KMaxTInt32); + iChild[2]->TestOP(lastKMax); + TInt last=iChild[2]->SetToLastAndGetOPPri(0); + iChild[2]->TestOP(last); + iChild[2]->SetAndTestOPPri(-1,12,last12); // One and only pri 12 window + iChild[3]->SetAndTestOPPri(-1,KMaxTInt32,lastKMax); // One and only pri KMaxTInt32 window + iChild[1]->SetAndTestOPPri(0,KMaxTInt32); + iChild[5]->SetAndTestOP(-1,last-3); + iChild[1]->TestOP(0); + iChild[0]->SetAndTestOPPri(0,50); + iChild[1]->SetAndTestOPPri(0,50); + iChild[2]->SetAndTestOPPri(0,50); + iChild[3]->SetAndTestOPPri(0,50); + iChild[1]->TestOP(2); + if (iGroupTest) + { + retVal=(reinterpret_cast(iChild[0]->NextSibling())==iClient->iGroup); + TEST(retVal); + if (!retVal) + { + _LIT(KLog,"iChild0 NextSibling is not the main group window"); + LOG_MESSAGE(KLog); + } + retVal=(reinterpret_cast(iClient->iGroup->NextSibling())==iChild[4]); + TEST(retVal); + if (!retVal) + { + _LIT(KLog,"NextSibling of main group window is not iChild4"); + LOG_MESSAGE(KLog); + } + } + else + TestWindowOrderNext(0,4); + TestWindowOrderNext(4,5); + TestWindowOrderNext(5); + iChild[2]->SetAndTestOPPri(5,-1,0); + iChild[3]->SetAndTestOPPri(5,-1,1); + TestWindowOrderNext(5,2); + iChild[0]->SetAndTestOPPri(100000,KMinTInt32,0); + iChild[1]->SetAndTestOPPri(200000,KMinTInt32,1); + iChild[2]->SetAndTestOPPri(300000,KMinTInt32,2); + iChild[5]->SetAndTestOPPri(0,0,0); + iChild[3]->TestOP(0); + iChild[0]->SetAndTestOPPri(0,-1); + iChild[1]->SetAndTestOPPri(0,-1); + iChild[2]->SetAndTestOPPri(0,-1); + iChild[3]->SetAndTestOPPri(0,1); + iChild[4]->SetAndTestOPPri(0,1); + iChild[5]->SetAndTestOPPri(0,1); + TestWindowOrderPrev(0,1); + TestWindowOrderPrev(1,2); + if (iGroupTest) + { + retVal=(reinterpret_cast(iChild[2]->PrevSibling())==iClient->iGroup); + TEST(retVal); + if (!retVal) + { + _LIT(KLog,"iChild2 PrevSibling is not the main group window"); + LOG_MESSAGE(KLog); + } + retVal=(reinterpret_cast(iClient->iGroup->PrevSibling())==iChild[3]); + TEST(retVal); + if (!retVal) + { + _LIT(KLog,"PrevSibling of main group window is not iChild3"); + LOG_MESSAGE(KLog); + } + } + else + TestWindowOrderPrev(2,3); + TestWindowOrderPrev(3,4); + TestWindowOrderPrev(4,5); + TestWindowOrderPrev(5); + } + +void CTOrdinal::ConstructL() + { + iClient=new(ELeave) COrdinalClient(); + iClient->SetScreenNumber(iTest->iScreenNumber); + iClient->ConstructL(); + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-0446 + +@SYMCR CR1164 + +@SYMTestCaseDesc Test ClientHandle function returns right value + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Call this function on windows at various times + +@SYMTestExpectedResults The value set when window was created is returned +*/ +void CTOrdinal::CreateWindowsL(TInt aMode) + { + RWindowTreeNode* parent=NULL; + RWindowTreeNode* base=iClient->iGroup->WinTreeNode(); + TInt errors=0; + + if (base->Child()!=0) + { + _LIT(KErrText,"Main Group Window has children at start of test"); + LOG_MESSAGE(KErrText); + AutoPanic(EAutoPanicGroupWinHasChild); + } + if (base->ClientHandle()!=reinterpret_cast(iClient->iGroup)) + ++errors; + if (base->Parent()!=0) + ++errors; + TEST(errors==0); + if (errors>0) + { + _LIT(KErrText,"Handles of Main Group Window are not as expected"); + LOG_MESSAGE2(KErrText,errors); + } + iGroupTest=EFalse; + switch(aMode) + { + case 3: + iParent=COrdinalWindow::NewL(iClient,base,iTest,iStep); + parent=iParent->WinTreeNode(); + CheckHandlesOnNewWindow(iClient->iGroup,iParent); + break; + case 1: + parent=iClient->iGroup->WinTreeNode(); + break; + case 2: + iParent=COrdinalWindow::NewL(iClient,base,iTest,iStep); + CheckHandlesOnNewWindow(iClient->iGroup,iParent); + iParent2=COrdinalWindow::NewL(iClient,iParent->WinTreeNode(),iTest,iStep); + CheckHandlesOnNewWindow(iParent,iParent2); + iParent3=COrdinalWindow::NewL(iClient,iParent2->WinTreeNode(),iTest,iStep); + parent=iParent3->WinTreeNode(); + CheckHandlesOnNewWindow(iParent2,iParent3); + break; + case 0: + iGroupTest=ETrue; + for (TInt child=ENumChildren-1;child>=0;--child) + iChild[child]=COrdinalWindowGroup::NewL(iClient,iTest,iStep); + CheckHandles(0); + return; + } + for (TInt child=ENumChildren-1;child>=0;--child) + { + iChild[child]=COrdinalWindow::NewL(iClient,parent,iTest,iStep); + if (iChild[child]->Handle()!=parent->Child()) + ++errors; + } + TEST(errors==0); + if (errors>0) + { + _LIT(KErrText,"%d windows were not the first child"); + LOG_MESSAGE2(KErrText,errors); + } + CheckHandles(parent->ClientHandle()); + } + +void CTOrdinal::CheckHandlesOnNewWindow(CTWindowGroup* aParent,COrdinalWindowBase* aWin) + { + TInt errors=0; + if (aParent->WinTreeNode()->Child()!=aWin->Handle()) + ++errors; + if (aWin->WinTreeNode()->Parent()!=reinterpret_cast(aParent)) + ++errors; + CheckHandlesOnNewWindow(errors,aWin); + } + +void CTOrdinal::CheckHandlesOnNewWindow(COrdinalWindowBase* aParent,COrdinalWindowBase* aWin) + { + TInt errors=0; + if (aParent->WinTreeNode()->Child()!=aWin->Handle()) + ++errors; + if (aWin->WinTreeNode()->Parent()!=aParent->Handle()) + ++errors; + CheckHandlesOnNewWindow(errors,aWin); + } + +void CTOrdinal::CheckHandlesOnNewWindow(TInt aErrors,COrdinalWindowBase* aWin) + { + RWindowTreeNode* win=aWin->WinTreeNode(); + if (win->ClientHandle()!=aWin->Handle()) + ++aErrors; + if (win->PrevSibling()!=0) + ++aErrors; + if (win->NextSibling()!=0) + ++aErrors; + if (win->Child()!=0) + ++aErrors; + TEST(aErrors==0); + if (aErrors>0) + { + _LIT(KErrText,"%d errors in handles of newly created window"); + LOG_MESSAGE2(KErrText,aErrors); + } + } + +void CTOrdinal::CheckHandles(TUint aParent) + { + TInt errors=0; + TInt child; + for (child=0;childWinTreeNode()->ClientHandle()!=iChild[child]->Handle()) + ++errors; + } + TEST(errors==0); + if (errors>0) + { + _LIT(KErrText,"%d windows gave wrong client handle"); + LOG_MESSAGE2(KErrText,errors); + errors=0; + } + for (child=0;childWinTreeNode()->Parent()!=aParent) + ++errors; + } + TEST(errors==0); + if (errors>0) + { + _LIT(KErrText,"%d children gave wrong parent handle"); + LOG_MESSAGE2(KErrText,errors); + errors=0; + } + for (child=1;childWinTreeNode()->NextSibling()!=iChild[child]->Handle()) + ++errors; + } + if (iChild[5]->WinTreeNode()->NextSibling()!=0 && !iGroupTest) + ++errors; + TEST(errors==0); + if (errors>0) + { + _LIT(KErrText,"%d windows gave wrong next sibling handle"); + LOG_MESSAGE2(KErrText,errors); + errors=0; + } + if (iChild[0]->WinTreeNode()->PrevSibling()!=0 && !iGroupTest) + ++errors; + for (child=1;childWinTreeNode()->PrevSibling()!=iChild[child-1]->Handle()) + ++errors; + } + TEST(errors==0); + if (errors>0) + { + _LIT(KErrText,"%d windows gave wrong prev sibling handle"); + LOG_MESSAGE2(KErrText,errors); + } + } + +COrdinalClient::COrdinalClient() + { + } + +void COrdinalClient::ConstructL() + { + User::LeaveIfError(iWs.Connect()); + // change to correct screen + // + iScreen = new (ELeave) CWsScreenDevice(iWs); + User::LeaveIfError(iScreen->Construct(iScreenNumber)); + + TheClient->iGroup->WinTreeNode()->SetOrdinalPosition(0,-2000000000); + TheClient->iWs.Flush(); + iGroup=new(ELeave) CTWindowGroup(this); + iGroup->ConstructL(); + } + +COrdinalClient::~COrdinalClient() + { + TheClient->iGroup->WinTreeNode()->SetOrdinalPosition(0,0); + } + +void COrdinalClient::KeyL(const TKeyEvent &,const TTime &) + { + } + +void CTOrdinal::RunTestCaseL(TInt /*aCurTestCase*/) + { + _LIT(KTest1,"Ordinal 1"); + ((CTOrdinalStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); + switch(++iTest->iState) + { +/** +@SYMTestCaseID GRAPHICS-WSERV-0217 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test ordinal position and priority changes on windows + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Set different ordinal positions and priorities on a + number of windows and check they have been set + correctly + +@SYMTestExpectedResults The positions and priorities are set correctly +*/ + case 1: + ((CTOrdinalStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0217")); + iTest->LogSubTest(KTest1); + { + for(TInt index=0;index<4;index++) + { + ((CTOrdinalStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0446")); + CreateWindowsL(index); + ((CTOrdinalStep*)iStep)->RecordTestResultL(); + OrdinalPos(); + OrdinalPriority(); + DestroyWindows(); + } + } + ((CTOrdinalStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0217")); + if (!iStep->TestStepResult() == EPass) + TEST(EFalse); + break; + default: + ((CTOrdinalStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + ((CTOrdinalStep*)iStep)->CloseTMSGraphicsStep(); + TestComplete(); + break; + }; + ((CTOrdinalStep*)iStep)->RecordTestResultL(); + } + +__WS_CONSTRUCT_STEP__(Ordinal) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TORDINAL.H --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TORDINAL.H Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,134 @@ + +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef __TORDINAL_H__ +#define __TORDINAL_H__ + +#include +#include +#include "../tlib/testbase.h" +#include "AUTO.H" +#include "TGraphicsHarness.h" + +class CTOrdinal; + +class COrdinalClient : public CTClient + { +public: + COrdinalClient(); + virtual void KeyL(const TKeyEvent &aKey,const TTime &aTime); + virtual void ConstructL(); + ~COrdinalClient(); + }; + +class COrdinalWindowBase : public CBase + { +public: + COrdinalWindowBase(CTClient *aClient, CTestBase* aTest, CTestStep* aTestStep); + ~COrdinalWindowBase(); + TInt OrdinalPosition(); + void SetOrdinalPosition(TInt aPos); + void SetOrdinalPosition(TInt aPos,TInt aPri); + virtual void Draw(); + void TestOP(TInt aTestPos); + TInt SetToLastAndGetOP(); + TInt SetToLastAndGetOPPri(TInt aPri); + void SetAndTestOP(TInt aPos); + void SetAndTestOP(TInt aPos,TInt aTestPos); + void SetAndTestOPPri(TInt aPos,TInt aPri,TInt aTestPos); + void SetAndTestOPPri(TInt aPos,TInt aPri); + inline COrdinalWindowBase* NextSibling() const; + inline COrdinalWindowBase* PrevSibling() const; + inline RWindowTreeNode* WinTreeNode(); + inline TUint32 Handle(); +protected: + RWindowTreeNode* iWin; +private: + CTClient* iClient; + CTestBase* iTest; + CTestStep* iTestStep; + }; + +class COrdinalWindow : public COrdinalWindowBase + { +public: + COrdinalWindow(CTClient *aClient, CTestBase* aTest, CTestStep* aTestStep); + static COrdinalWindowBase *NewL(CTClient *aClient, RWindowTreeNode *parent, CTestBase* aTest, CTestStep* aTestStep); +private: + RWindow iClientWin; + }; + +class COrdinalWindowGroup : public COrdinalWindowBase + { +public: + COrdinalWindowGroup(CTClient *aClient, CTestBase* aTest, CTestStep* aTestStep); + static COrdinalWindowBase *NewL(CTClient *aClient, CTestBase* aTest, CTestStep* aTestStep); +private: + RWindowGroup iGroupWin; + }; + +class CTOrdinal : public CTWsGraphicsBase + { +public: + CTOrdinal(CTestStep* aStep); + ~CTOrdinal(); + void DestroyWindows(); + void OrdinalPos(); + void OrdinalPriority(); + void ConstructL(); + void CreateWindowsL(TInt aMode); +protected: //virtual function from CTGraphicsStep + void RunTestCaseL(TInt aCurTestCase); +private: + void TestWindowOrderNext(TInt aBefore,TInt aAfter); + void TestWindowOrderNext(TInt aLast); + void TestWindowOrderPrev(TInt aAfter,TInt aBefore); + void TestWindowOrderPrev(TInt aFirst); + void CheckHandlesOnNewWindow(CTWindowGroup* aParent,COrdinalWindowBase* aWin); + void CheckHandlesOnNewWindow(COrdinalWindowBase* aParent,COrdinalWindowBase* aWin); + void CheckHandlesOnNewWindow(TInt aErrors,COrdinalWindowBase* aWin); + void CheckHandles(TUint aParent); +private: + enum {ENumChildren=6}; +private: + COrdinalClient* iClient; + TSize iWinSize; + TBool iGroupTest; + COrdinalWindowBase* iParent; + COrdinalWindowBase* iParent2; + COrdinalWindowBase* iParent3; + COrdinalWindowBase* iChild[ENumChildren]; + }; + +class CTOrdinalStep : public CTGraphicsStep + { +public: + CTOrdinalStep(); +protected: + //from CTGraphicsStep + virtual CTGraphicsBase* CreateTestL(); + }; + +_LIT(KTOrdinalStep,"TOrdinal"); + + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TPANIC.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TPANIC.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,2014 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Test various cases of Wserv panicing client apps +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include "TPANIC.H" +#include "../tlib/testbase.h" +#include +#define TEST_BITMAP _L("Z:\\WSTEST\\WSAUTOTEST.MBM") + +class RWsSessionHacker : public RWsSession + { +public: + inline RWsBuffer *WsBuffer() const {return(iBuffer);}; + inline TInt PanicItSendReceive(TInt aFunction,const TIpcArgs& aArgs) const {return SendReceive(aFunction,aArgs);}; + inline TInt PanicItSend(TInt aFunction,const TIpcArgs& aArgs) const {return Send(aFunction,aArgs);}; + inline TInt PanicItSendReceive(TInt aFunction) const {return SendReceive(aFunction);}; + inline TInt PanicItSend(TInt aFunction) const {return Send(aFunction);}; + }; + +class RWsBufferHacker // copy of original data structure to access buffer data + { +public: + RWsSession* iSession; + CWsGraphic::CManager* iManager; + TBool iAutoFlush; + TPtr8 iBuf; + RWsBuffer* iNext; + TInt iPreviousHandle; + TInt iBufSize; + TInt iMaxBufSize; + TInt iDirectAcessCount; + RArray iBitmapArray; + TBool iInvalidBitmapArray; + }; + +CTPanic::CTPanic(CTestStep* aStep): + CTWsGraphicsBase(aStep) + { + } + +CTPanic::~CTPanic() + { + } + +LOCAL_C TInt DoDeletedParentTest(TInt aInt, TAny *aScreenNumber) + { + RWsSession ws; + User::LeaveIfError(ws.Connect()); + // point to correct screen + CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws); + User::LeaveIfError(screen->Construct((TInt)aScreenNumber)); + + RWindowGroup group(ws); + User::LeaveIfError(group.Construct(888)); + group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close + switch(aInt) + { + case 1: + RWindow win1(ws); + User::LeaveIfError(win1.Construct(group,1)); + RWindow win2(ws); + User::LeaveIfError(win2.Construct(win1,2)); + win1.Close(); + win2.SetExtent(TPoint(1,2),TSize(3,4)); + break; + } + ws.Flush(); + return(EWsExitReasonBad); + } + +LOCAL_C void ReuseWindow(RWsSession& aWs,RWindowGroup& aGroup,RWindow aCopyWin,RWindow* aPtrWin) + { + aPtrWin->Close(); + RWindow win(aWs); + User::LeaveIfError(win.Construct(aGroup,17)); + aCopyWin.SetExtent(TPoint(1,2),TSize(3,4)); + } + +LOCAL_C void ReuseGroupWindow(RWsSession& aWs,RWindowGroup aCopyWin,RWindowGroup* aPtrWin) + { + aPtrWin->Close(); + RWindowGroup group(aWs); + User::LeaveIfError(group.Construct(889)); + group.EnableReceiptOfFocus(EFalse); + aCopyWin.EnableReceiptOfFocus(EFalse); + } + +LOCAL_C void ReuseSprite(RWsSession& aWs,RWindow& aWin,RWsSprite aCopySprite,RWsSprite* aPtrSprite) + { + aPtrSprite->Close(); + RWsSprite sprite(aWs); + sprite.Construct(aWin,TPoint(0,0),0); + aCopySprite.SetPosition(TPoint(22,22)); + } + +LOCAL_C void ReusePointerCursor(RWsSession& aWs,RWsPointerCursor aCopyCursor,RWsPointerCursor* aPtrCursor) + { + aPtrCursor->Close(); + RWsPointerCursor cursor(aWs); + cursor.Construct(0); + aCopyCursor.Activate(); + } + +LOCAL_C TInt DoHandleReUse(TInt aInt, TAny *aScreenNumber) + { + RWsSession ws; + User::LeaveIfError(ws.Connect()); + CWsScreenDevice *scrdev=new(ELeave) CWsScreenDevice(ws); + scrdev->Construct((TInt)aScreenNumber); + RWindowGroup group(ws); + User::LeaveIfError(group.Construct(888)); + group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close + RWindow win(ws); + User::LeaveIfError(win.Construct(group,1)); + switch(aInt) + { + case 2: //WS_HANDLE_WINDOW + ReuseWindow(ws,group,win,&win); + break; + case 3: //WS_HANDLE_GROUP_WINDOW + ReuseGroupWindow(ws,group,&group); + break; + case 4: //WS_HANDLE_SPRITE + { + RWsSprite sprite(ws); + sprite.Construct(win,TPoint(0,0),0); + ReuseSprite(ws,win,sprite,&sprite); + } + break; + case 5: //WS_HANDLE_POINTER_CURSOR + { + RWsPointerCursor cursor(ws); + cursor.Construct(0); + ReusePointerCursor(ws,cursor,&cursor); + } + break; + } + ws.Flush(); + return(EWsExitReasonBad); + } + +LOCAL_C TInt DoScreenDevicePanicTest(TInt aInt, TAny *aScreenNumber) + { + RWsSession ws; + User::LeaveIfError(ws.Connect()); + + CWsScreenDevice *scrdev=new(ELeave) CWsScreenDevice(ws); + User::LeaveIfError(scrdev->Construct((TInt)aScreenNumber)); + + RWindowGroup group(ws); + User::LeaveIfError(group.Construct(888)); + group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close + RWindow win(ws); + User::LeaveIfError(win.Construct(group, 1)); + win.Activate(); + CFbsBitmap *bitmap=new(ELeave) CFbsBitmap; + switch(aInt) + { + case 1: + scrdev->CopyScreenToBitmap(bitmap); + break; + case 2: + scrdev->CopyScreenToBitmap(bitmap,TRect(0,0,10,10)); + break; + default: + return(EWsExitReasonFinished); + } + ws.Flush(); + return(EWsExitReasonBad); + } + +LOCAL_C TInt DoOpcodeTests(TInt aInt, TAny *aScreenNumber) + { + RWsSession ws; + User::LeaveIfError(ws.Connect()); + + CWsScreenDevice *scrdev=new(ELeave) CWsScreenDevice(ws); + User::LeaveIfError(scrdev->Construct((TInt)aScreenNumber)); + + RWindowGroup group(ws); + User::LeaveIfError(group.Construct(888)); + group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close + RWindow win(ws); + User::LeaveIfError(win.Construct(group, 1)); + win.Activate(); + CWindowGc *gc; + scrdev->CreateContext(gc); + switch(aInt) + { + case 1: + ws.TestWrite(ws.WsHandle(),9999,NULL,0); + break; + case 2: + gc->Activate(win); + win.BeginRedraw(); + ws.TestWrite(gc->WsHandle(),9999,NULL,0); + /* This only panics if the command is processed immediately. If it goes into the redraw + store then it will be unable to panic the client untill an additional buffer has been received, + hence the double flush. + */ + win.EndRedraw(); + ws.Finish(); + win.BeginRedraw(); + win.EndRedraw(); + break; + case 3: + ws.TestWrite(scrdev->WsHandle(),9999,NULL,0); + break; + case 4: + { + CWsBitmap *bitmap=new(ELeave) CWsBitmap(ws); + bitmap->Create(TSize(10,10),EGray4); + ws.TestWrite(bitmap->WsHandle(),9999,NULL,0); + } + break; + case 5: + ws.TestWrite(win.WsHandle(),9999,NULL,0); + break; + case 6: + ws.TestWrite(group.WsHandle(),9999,NULL,0); + break; + case 7: + { + RWsSprite sprite(ws); + sprite.Construct(win,TPoint(0,0),0); + ws.TestWrite(sprite.WsHandle(),9999,NULL,0); + } + break; + default: + return(EWsExitReasonFinished); + } + ws.Flush(); + return(EWsExitReasonBad); + } + +TInt DoGraphicsPanicTest(RWsSession& aWs, RWindow& aRWin, RDrawableWindow* aDrawWin, CWindowGc* aGc, CFbsFont* aFont, TInt aTest, TInt aSubTest, TBool aInRedraw, TBool aNeedsValidating) + { + if (aInRedraw || aNeedsValidating) + { + aRWin.BeginRedraw(); + if (!aInRedraw) + { // TransWin without redraw active needs the begin/end to make the redraw store active + aRWin.EndRedraw(); // or else all graphics will simply be ignored and no panics will occur + } + } + aWs.Flush(); + TRect rect01(0,0,1,1); + TPoint point00; + switch(aTest) + { + case 1: + aGc->UseFont(aFont); + switch(aSubTest) + { + case 0: + { + TWsGcCmdBoxText boxText(rect01,0,CGraphicsContext::ELeft,0,0x800000,1); + aWs.TestWrite(aGc->WsHandle(),EWsGcOpDrawBoxText,&boxText,sizeof(boxText)); + } + break; + case 1: + { + TWsGcCmdDrawText dt(point00,600); + aWs.TestWrite(aGc->WsHandle(),EWsGcOpDrawText,&dt,sizeof(dt)); + } + break; + case 2: + { + TWsGcCmdBoxTextOptimised1 dt(rect01,0,600); + aWs.TestWrite(aGc->WsHandle(),EWsGcOpDrawBoxTextOptimised1,&dt,sizeof(dt)); + } + break; + case 3: + { + TWsGcCmdDrawTextVertical dt(point00,600,EFalse); + aWs.TestWrite(aGc->WsHandle(),EWsGcOpDrawTextVertical,&dt,sizeof(dt)); + } + break; + case 4: + { + TWsGcCmdBoxTextVertical dt(rect01); + dt.length=600; + aWs.TestWrite(aGc->WsHandle(),EWsGcOpDrawBoxTextVertical,&dt,sizeof(dt)); + } + break; + case 5: + return(EWsExitReasonFinished); + } + break; + case 2: + { + TInt opcode=0; + switch(aSubTest) + { + case 0: + opcode=EWsGcOpGdiBlt2; + break; + case 1: + opcode=EWsGcOpGdiWsBlt2; + break; + case 2: + return(EWsExitReasonFinished); + } + TWsGcCmdGdiBlt2 gdiBlit(point00,0xBADBAD); + aWs.TestWrite(aGc->WsHandle(),opcode,&gdiBlit,sizeof(gdiBlit)); + if (aInRedraw) + { // Adding two bad bitmaps to redraw store fbs store causes leave as NULL handles of failed bitmaps clash + gdiBlit.handle=0xBADBAD2; + aWs.TestWrite(aGc->WsHandle(),opcode,&gdiBlit,sizeof(gdiBlit)); + } + } + break; + case 3: + { + const TInt KNumBadBmpModes=3; + const TInt KNumTestsPerOpcode=KNumBadBmpModes*2; + enum {KPanicIndexMasked,KPanicIndexDraw,KPanicIndexAlphaBlend,KPanicIndexMax}; + TInt opcodeMode=aSubTest/KNumTestsPerOpcode; + TInt bmpMode=aSubTest%KNumTestsPerOpcode; + TInt bmp1=0xBADBAD; + TInt bmp2=0xBADBAD; + TInt goodBmp; + TInt opcodeBlt; + TInt opcodeDraw; + if (bmpModeCreate(TSize(10,10),EGray4); + goodBmp=goodBitmap->Handle(); + opcodeBlt=EWsGcOpGdiBltMasked; + opcodeDraw=EWsGcOpDrawBitmapMasked; + } + else + { // These two use a CWsBitmap + CWsBitmap* goodBitmap=new(ELeave) CWsBitmap(aWs); + goodBitmap->Create(TSize(10,10),EGray4); + goodBmp=goodBitmap->WsHandle(); + opcodeBlt=EWsGcOpGdiWsBltMasked; + opcodeDraw=EWsGcOpWsDrawBitmapMasked; + } + switch(bmpMode%KNumBadBmpModes) + { + case 0: + bmp2=goodBmp; + break; + case 1: + bmp1=goodBmp; + break; + case 2: // Leave them both bad + break; + } + switch(opcodeMode) + { + case KPanicIndexMasked: + { + TWsGcCmdBltMasked gdiBlitMasked(point00,bmp1,rect01,bmp2,EFalse); + aWs.TestWrite(aGc->WsHandle(),opcodeBlt,&gdiBlitMasked,sizeof(gdiBlitMasked)); + } + break; + case KPanicIndexDraw: + { + TWsGcCmdDrawBitmapMasked maskedBitmap(rect01,bmp1,rect01,bmp2,EFalse); + aWs.TestWrite(aGc->WsHandle(),opcodeDraw,&maskedBitmap,sizeof(maskedBitmap)); + } + break; + case KPanicIndexAlphaBlend: + { + TWsGcCmdAlphaBlendBitmaps alphaBlend(point00,bmp1,rect01,bmp2,point00); + aWs.TestWrite(aGc->WsHandle(),EWsGcOpGdiAlphaBlendBitmaps,&alphaBlend,sizeof(alphaBlend)); + } + break; + case KPanicIndexMax: + return(EWsExitReasonFinished); + } + } + break; + case 4: + switch(aSubTest) + { + case 0: + { + TWsClCmdCreateBitmap createBitmap; + createBitmap.handle=0xB0D; + aWs.TestWrite(aWs.WsHandle(),EWsClOpCreateBitmap,&createBitmap,sizeof(createBitmap)); + } + break; + case 1: + { + TInt badBrush=0xBADB3054; + aWs.TestWrite(aGc->WsHandle(),EWsGcOpUseBrushPattern,&badBrush,sizeof(badBrush)); + } + break; + case 2: + { + TWsGcCmdDrawBitmap drawBitmap(point00,0xBADBAD); + aWs.TestWrite(aGc->WsHandle(),EWsGcOpDrawBitmap,&drawBitmap,sizeof(drawBitmap)); + } + break; + case 3: + return(EWsExitReasonFinished); + } + break; + case 5: + // test bad opcodes + { + TInt opcode=0; + switch(aSubTest) + { + case 0: + opcode=9999; + break; + case 1: + return(EWsExitReasonFinished); + } + aWs.TestWrite(aGc->WsHandle(),opcode,NULL,0); + } + break; + case 6: + {// Test EWsGcOpDrawPolygon with invalid parameters + // First two times has slightly more points specified than exist in the data + // Third time time has a massive number of points in the header + const TInt KNumTestsPerPolyMode=3; + enum TPanicPolyMode {EPanicPolyModePolygon,EPanicPolyModePolyLine,EPanicPolyModeEnd}; + TInt polyMode=aSubTest/KNumTestsPerPolyMode; + if (polyMode==EPanicPolyModeEnd) + return(EWsExitReasonFinished); + TInt subMode=aSubTest%KNumTestsPerPolyMode; + TInt bufPoints=0; + TInt headerPoints=1; + switch(subMode) + { + case 0: + break; + case 1: + bufPoints=2; + headerPoints=8; + break; + case 2: + bufPoints=2; + headerPoints=999999; + break; + } + TInt bufDataLen=bufPoints*sizeof(TPoint); + if (polyMode==EPanicPolyModePolyLine) + bufDataLen+=sizeof(TWsGcCmdDrawPolyLine); + else + bufDataLen+=sizeof(TWsGcCmdDrawPolygon); + TAny* bufData=User::AllocL(bufDataLen); + TPoint* pointPtr; + TInt opcode; + if (polyMode==EPanicPolyModePolyLine) + { + TWsGcCmdDrawPolyLine* drawPolyline=static_cast(bufData); + drawPolyline->numPoints=headerPoints; + drawPolyline->more=EFalse; + drawPolyline->last=point00; + pointPtr=reinterpret_cast(drawPolyline+1); + opcode=EWsGcOpDrawPolyLine; + } + else + { + TWsGcCmdDrawPolygon* drawPolygon=static_cast(bufData); + drawPolygon->numPoints=headerPoints; + drawPolygon->fillRule=CGraphicsContext::EAlternate; + pointPtr=reinterpret_cast(drawPolygon+1); + opcode=EWsGcOpDrawPolygon; + } + const TPoint* endPtr=pointPtr+bufPoints; + TInt pointPos=0; + while(pointPtrWsHandle(),opcode,bufData,bufDataLen); + aWs.Flush(); // Needs flush to make sure EndRedraw() doesn't make buffer bigger and catch out buf len check + } + break; + case 7: + { + // first sets the index to match the total count + // second sets the index negative + // fourth sends too much data + TWsGcCmdStartSegmentedDrawPolygon startPoly; + startPoly.totalNumPoints=8; + aWs.TestWrite(aGc->WsHandle(),EWsGcOpStartSegmentedDrawPolygon,&startPoly,sizeof(startPoly)); + TInt bufDataLen=sizeof(TWsGcCmdSegmentedDrawPolygonData)+startPoly.totalNumPoints*sizeof(TPoint); + TAny* bufData=User::AllocL(bufDataLen); + TWsGcCmdSegmentedDrawPolygonData* polyData=static_cast(bufData); + polyData->numPoints=1; + polyData->index=0; + switch(aSubTest) + { + case 0: + polyData->index=startPoly.totalNumPoints; + break; + case 1: + polyData->index=-123; + break; + case 2: + polyData->numPoints=startPoly.totalNumPoints+1; + break; + case 3: + return(EWsExitReasonFinished); + } + aWs.TestWrite(aGc->WsHandle(),EWsGcOpSegmentedDrawPolygonData,polyData,bufDataLen); + TWsGcCmdDrawSegmentedPolygon drawit; + drawit.fillRule=CGraphicsContext::EAlternate; + aWs.TestWrite(aGc->WsHandle(),EWsGcOpDrawSegmentedPolygon,&drawit,sizeof(drawit)); + } + break; + case 8: + { + if (aSubTest==1) + return(EWsExitReasonFinished); + // This is a test designed to specificially test polylines still work after the previous + // polyline/polygon tests. One potential defect is they leave the common redraw store gc + // in a bad state still holding part of the poly data and causing a EWservPanicBadPolyData + // panic. + // This test is designed to make sure the drawpolyline call works ok and we reach the bad + // opcode panic instead. + TWsGcCmdStartSegmentedDrawPolygon startPoly; + startPoly.totalNumPoints=2; + aWs.TestWrite(aGc->WsHandle(),EWsGcOpStartSegmentedDrawPolygon,&startPoly,sizeof(startPoly)); + struct + { + TWsGcCmdSegmentedDrawPolygonData iPolyData; + TPoint iPoints[2]; + } polyParams; + polyParams.iPoints[0].iX=1; + polyParams.iPoints[0].iY=1; + polyParams.iPoints[1].iX=2; + polyParams.iPoints[1].iY=2; + + polyParams.iPolyData.numPoints=2; + polyParams.iPolyData.index=0; + aWs.TestWrite(aGc->WsHandle(),EWsGcOpSegmentedDrawPolygonData,&polyParams.iPolyData,sizeof(polyParams)); + TWsGcCmdDrawSegmentedPolygon drawit; + drawit.fillRule=CGraphicsContext::EAlternate; + aWs.TestWrite(aGc->WsHandle(),EWsGcOpDrawSegmentedPolygon,&drawit,sizeof(drawit)); + aWs.TestWrite(aGc->WsHandle(),9999,NULL,0); + } + break; + case 9: + if (aSubTest==1) + return(EWsExitReasonFinished); + aGc->Activate(*aDrawWin); // Double activate + break; + case 10: + if (aSubTest==1) + return(EWsExitReasonFinished); + aGc->DrawText(_L("No font"),point00); + break; + case 11: + if (aSubTest==1) + return(EWsExitReasonFinished); + aGc->SetBrushStyle(CGraphicsContext::EPatternedBrush); + aGc->DrawRect(rect01); + break; + case 12: + { + if (aSubTest==1) + return(EWsExitReasonFinished); + aGc->UseFont(aFont); + TPtrC bigAndbad(NULL,5000); // Will go through remote descriptor fetching code + aGc->DrawText(bigAndbad,point00); + } + break; + case 13: + { + if (aSubTest==1) + return(EWsExitReasonFinished); + TInt badHandle=0xDEADBAD; + aWs.TestWrite(aGc->WsHandle(),EWsGcOpUseFont,&badHandle,sizeof(badHandle)); + aGc->DrawText(_L("BOO!"),point00); + } + break; + } + if (aInRedraw) + aRWin.EndRedraw(); + aWs.Finish(); + return(EWsExitReasonBad); + } + +LOCAL_C TInt GraphicsPanicTest(TInt aInt, TAny* aPanicParams) + { + CTPanic::TPanicParams* panicParams=static_cast(aPanicParams); + /* + * Drawing to a transparent window goes via the redraw store. In this + * situation parameters do not get checked during the original processing + * of the incoming graphics commands. They are only caught later when + * playing back from the redraw store. + */ + const TBool useTransWin = panicParams->iRedrawMode==EPanicRedrawModeTransRedraw; + /* + * We always do redraw drawing unless we are using a BackedUpWindow. + * Redraws can affect the way graphics commands are pre-processed, + * as with transparent windows they can also cause commands to get + * buffered in the redraw store and played back later. + */ + const TBool inRedraw = + panicParams->iRedrawMode==EPanicRedrawModeNormalRedraw || + panicParams->iRedrawMode==EPanicRedrawModeTransRedraw || + panicParams->iRedrawMode==EPanicRedrawModeInvisRedraw; + /* + * Drawing to an invisible window skips some of the code where errors + * are caught. Particularly text drawing commands that skip the actual + * drawing, but still process the update of the justification, this + * has the potential of missing parameter checks made during the actual + * drawing, but being caught out when processing the justification update. + */ + const TBool invisWin = panicParams->iRedrawMode==EPanicRedrawModeInvisRedraw; + + RWsSession ws; + User::LeaveIfError(ws.Connect()); + + CWsScreenDevice* scrdev=new(ELeave) CWsScreenDevice(ws); + User::LeaveIfError(scrdev->Construct(panicParams->iScreen)); + + RWindowGroup group(ws); + User::LeaveIfError(group.Construct(888)); + group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close + RDrawableWindow* drawWin; + RWindow rwin(ws); + RBackedUpWindow bwin(ws); + TBool needsValidating=EFalse; + if (useTransWin || inRedraw || invisWin) + { + drawWin=&rwin; + needsValidating=ETrue; + User::LeaveIfError(rwin.Construct(group,1)); + if (useTransWin) + { + rwin.SetTransparencyAlphaChannel(); + } + } + else + { + // EPanicRedrawModeBackedUpWindow case + drawWin=&bwin; + User::LeaveIfError(bwin.Construct(group, EGray4, 1)); + } + const TSize testWinSize(100,100); + User::LeaveIfError(drawWin->SetSizeErr(testWinSize)); + if (invisWin) + drawWin->SetPosition(TPoint(-testWinSize.iWidth,-testWinSize.iHeight)); + drawWin->Activate(); + CWindowGc* gc; + scrdev->CreateContext(gc); + gc->Activate(*drawWin); + CFbsFont* font; + User::LeaveIfError(scrdev->GetNearestFontToDesignHeightInTwips((CFont*&)font,TFontSpec())); + TInt ret=DoGraphicsPanicTest(ws,rwin,drawWin,gc,font,aInt,panicParams->iSubTest,inRedraw,needsValidating); + if (ret!=EWsExitReasonFinished && invisWin) + { + /* + * Some functions are totally skipped on invisible windows, parameter + * errors will be harmlessly ignored in these case. To make the test + * pass we re-do the tests with the window now visible. The purpose + * of the invisible draw tests was not to check the client is always + * panicked doing illegal draws to invisible windows, but to make sure + * they had no harmful side effects. + */ + drawWin->SetPosition(TPoint(0,0)); + gc->Reset(); + ret=DoGraphicsPanicTest(ws,rwin,drawWin,gc,font,aInt,panicParams->iSubTest,inRedraw,needsValidating); + } + return(ret); + } +LOCAL_C TInt DoMiscPanicTest(TInt aSubTest, TAny* ) + { + const TInt KNumPanicFuncsPerMode=EWsClOpLastEnumValue; + const TInt KNumPanicFuncModes=6; + const TInt KNumPanicSendTests=KNumPanicFuncsPerMode*KNumPanicFuncModes; + const TInt KNumRandGarbageTests=500; + if (aSubTest==(KNumPanicSendTests+KNumRandGarbageTests)) + return(EWsExitReasonFinished); + RWsSessionHacker wshacker; + User::LeaveIfError(wshacker.Connect()); + if (aSubTest(0xDEAD),100); + TIpcArgs ipcArgs; + ipcArgs.Set(0,&badDesc); + if (msgFunc&EPanicWservMessAsynchronousService) + { + sendItErr=wshacker.PanicItSend(msgFunc,ipcArgs); + msgFunc&=~EPanicWservMessAsynchronousService; + } + sendItErr=wshacker.PanicItSendReceive(msgFunc,ipcArgs); + } + if (sendItErr==KErrNotSupported) + wshacker.PanicItSendReceive(EWservMessCommandBuffer); // Should always panic + } + else + { + // Fill Wserv buffer with random garbage + RWsBufferHacker* hacker=reinterpret_cast(wshacker.WsBuffer()); + TInt64 seed=aSubTest; + TInt retries=0; + const TInt KMaxRandPanicRetrys=1000; + do + { + const TInt maxLen=hacker->iBuf.MaxLength()-1; + TInt writeLen=1+Math::Rand(seed)%maxLen; + while(writeLen--) + { + TUint8 randData=static_cast(Math::Rand(seed)); + hacker->iBuf.Append(randData); + } + wshacker.Flush(); + retries++; + } while(retriesConstruct((TInt)aScreenNumber)); + + switch(aInt) + { + case 1: + ws.ComputeMode((RWsSession::TComputeMode)543); + break; + } + ws.Flush(); + return(EWsExitReasonBad); + } + +#if defined(_DEBUG) && defined(__WINS__) +LOCAL_C TInt DoCKPanicTest(TInt aInt, TAny *aScreenNumber) + { + RWsSession ws; + User::LeaveIfError(ws.Connect()); + // use correct screen + // + CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws); + User::LeaveIfError(screen->Construct((TInt)aScreenNumber)); + + RWindowGroup group(ws); + group.Construct(888); + group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close + switch(aInt) + { + case 1: + group.CancelCaptureKey(345); + break; + } + ws.Flush(); + return(EWsExitReasonBad); + } +#endif + +LOCAL_C TInt DoEventPanicTest(TInt aInt, TAny *aScreenNumber) + { + RWsSession ws; + User::LeaveIfError(ws.Connect()); + // use correct screen + // + CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws); + User::LeaveIfError(screen->Construct((TInt)aScreenNumber)); + + + switch(aInt) + { + case 1: + TRequestStatus stat; + ws.EventReady(&stat); + ws.EventReady(&stat); + User::After(15000000); //15secs + break; + } + ws.Flush(); + return(EWsExitReasonBad); + } + +LOCAL_C TInt DoTBufPtrTests(TInt aInt, TAny *aScreenNumber) + { + RWsSession ws; + User::LeaveIfError(ws.Connect()); + // use correct screen + // + CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws); + User::LeaveIfError(screen->Construct((TInt)aScreenNumber)); + + switch(aInt) + { + case 1: + { + TWsClCmdLoadAnimDll dt; + dt.length=600; + ws.TestWrite(ws.WsHandle(),EWsClOpCreateAnimDll,&dt,sizeof(dt)); + } + break; + case 2: + { + TInt len=600; + ws.TestWrite(ws.WsHandle(),EWsClOpLogMessage,&len,sizeof(len)); + } + break; + case 3: + { + RWindowGroup group(ws); + group.Construct(888); + group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close + TWsWinCmdSetName dt; + dt.length=600; + dt.ptr=NULL; + ws.TestWrite(group.WsHandle(),EWsWinOpSetName,&dt,sizeof(dt)); + } + break; + case 4: + { + RWindowGroup group(ws); + group.Construct(888); + group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close + TWsWinCmdSetName dt; + dt.length=600; + dt.ptr=(TDesC *)0x1234; + ws.TestWrite(group.WsHandle(),EWsWinOpSetName,&dt,sizeof(dt)); + } + break; + } + ws.Flush(); + return(EWsExitReasonBad); + } + +#if defined(_DEBUG) && defined(__WINS__) +LOCAL_C TInt DoMismatchedCancelCaptureTest(TInt aInt, TAny *aScreenNumber) + { + RWsSession ws; + User::LeaveIfError(ws.Connect()); + // use correct screen + CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws); + User::LeaveIfError(screen->Construct((TInt)aScreenNumber)); + RWindowGroup group(ws); + User::LeaveIfError(group.Construct(888)); + group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close + RWindow win(ws); + User::LeaveIfError(win.Construct(group, 1)); + win.Activate(); + TInt capture; + + switch (aInt) + { + case CTPanic::ECancelCaptureKey: + // Create a capture that is not matched to CancelCaptureKey() + capture = group.CaptureLongKey(' ','a',0,0,2,ELongCaptureNormal); + ws.Flush(); + group.CancelCaptureKey(capture); + break; + case CTPanic::ECancelCaptureKeyUpAndDowns: + // Create a capture that is not matched to CancelCaptureKeyUpAndDowns() + capture = group.CaptureKey('A',0,0); + ws.Flush(); + group.CancelCaptureKeyUpAndDowns(capture); + break; + case CTPanic::ECancelCaptureLongKey: + // Create a capture that is not matched to CancelCaptureLongKey() + capture = group.CaptureKeyUpAndDowns(EStdKeySpace,0,0); + ws.Flush(); + group.CancelCaptureLongKey(capture); + break; + } + + ws.Flush(); + return(EWsExitReasonBad); + } +#endif // _DEBUG + +class ROverrideProtectionInRSessionBase : public RWsSession + { +public: + inline TInt SendReceive(TInt aFunction,TAny *aPtr) const {return(RSessionBase::SendReceive(aFunction,TIpcArgs(aPtr)));}; + }; + +LOCAL_C TInt DoMultiInitPanicTest(TInt , TAny *aScreenNumber) + { + ROverrideProtectionInRSessionBase ws; + User::LeaveIfError(ws.Connect()); + + // use correct screen + // + CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws); + User::LeaveIfError(screen->Construct((TInt)aScreenNumber)); + + RWindowGroup group(ws); + group.Construct(888); + group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close + ws.Flush(); + ws.SendReceive(EWservMessInit,NULL); + + return(EWsExitReasonBad); + } + +LOCAL_C TInt DoSpritePanicTestL(TInt aTest, TAny *aScreenNumber) + { + RWsSession ws; + User::LeaveIfError(ws.Connect()); + // use correct screen + // + CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws); + User::LeaveIfError(screen->Construct((TInt)aScreenNumber)); + + RWindowGroup group(ws); + User::LeaveIfError(group.Construct(889)); + group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close + RBlankWindow win(ws); + User::LeaveIfError(win.Construct(group,898)); + RWsPointerCursor* cursor=(RWsPointerCursor*)&win; + switch (aTest) + { + case 1: + win.SetCustomPointerCursor(*cursor); + break; + case 2: + ws.SetSystemPointerCursor(*cursor,0); + break; + case 3: + { + RAnimDll animDll=RAnimDll(ws); + User::LeaveIfError(animDll.Load(KAnimDLLName)); + RTestAnim anim=RTestAnim(animDll); + RWsSprite* sprite=(RWsSprite*)&win; + User::LeaveIfError(anim.Construct(*sprite,EAnimTypeSprite,TPtrC8())); + } + break; + case 4: + { + CFbsBitmap* bitmap=new(ELeave) CFbsBitmap; + CleanupStack::PushL(bitmap); + User::LeaveIfError(bitmap->Load(TEST_BITMAP_NAME,0)); + win.SetExtent(TPoint(),TSize(150,250)); + win.SetVisible(ETrue); + win.Activate(); + RWsSprite sprite(ws); + User::LeaveIfError(sprite.Construct(win,TPoint(),0)); + TSpriteMember member; + member.iMaskBitmap=NULL; + member.iInvertMask=EFalse; + member.iDrawMode=CGraphicsContext::EDrawModePEN; + member.iOffset=TPoint(); + member.iInterval=TTimeIntervalMicroSeconds32(0); + member.iBitmap=bitmap; + User::LeaveIfError(sprite.AppendMember(member)); + User::LeaveIfError(sprite.Activate()); + User::After(1000000); //1 sec + User::LeaveIfError(bitmap->Resize(bitmap->SizeInPixels() + TSize(200,200))); + User::After(1000000); //1 sec + CleanupStack::Pop(bitmap); + break; + } + } + ws.Flush(); + return(EWsExitReasonBad); + } + +#ifdef __WINS__ +LOCAL_C TInt DoDoubleConstructionTestL(TInt aTest, TAny *aScreenNumber) + { + RWsSession ws; + User::LeaveIfError(ws.Connect()); + + // use correct screen + // + CWsScreenDevice* screen = new(ELeave) CWsScreenDevice(ws); + User::LeaveIfError(screen->Construct((TInt)aScreenNumber)); + + RWindowGroup group(ws); + User::LeaveIfError(group.Construct(890, EFalse)); + RBlankWindow bwin(ws); + User::LeaveIfError(bwin.Construct(group,900)); + + switch (aTest) + { + case 1: + { + RWsSprite sprite = RWsSprite(ws); + User::LeaveIfError(sprite.Construct(bwin,TPoint(),0)); + sprite.Construct(bwin,TPoint(),0); //should panic + sprite.Close(); + } + break; + case 2: + { + RWsPointerCursor cursor(ws); + User::LeaveIfError(cursor.Construct(0)); + cursor.Construct(0); //should panic + cursor.Close(); + } + break; + case 3: + { + RSoundPlugIn click(ws); + User::LeaveIfError(click.Construct()); + click.Construct(); //should panic + click.Close(); + } + break; + case 4: + { + RWindowGroup windowgroup(ws); + User::LeaveIfError(windowgroup.Construct(901)); + windowgroup.Construct(902); //should panic + windowgroup.Close(); + } + break; + case 5: + { + RWindow win(ws); + User::LeaveIfError(win.Construct(group,902)); + win.Construct(group,903); //should panic + win.Close(); + } + break; + case 6: + { + RBlankWindow win(ws); + User::LeaveIfError(win.Construct(group,902)); + win.Construct(group,903); //should panic + win.Close(); + } + break; + case 7: + { + RBackedUpWindow win(ws); + User::LeaveIfError(win.Construct(group,EGray4,902)); + win.Construct(group,EGray4,903); //should panic + win.Close(); + } + break; + case 8: + { + RAnimDll animDll=RAnimDll(ws); + User::LeaveIfError(animDll.Load(KAnimDLLName)); + animDll.Load(KAnimDLLName); //should panic + animDll.Close(); + } + break; + case 9: + { + CWindowGc *gc = new(ELeave) CWindowGc(screen); + User::LeaveIfError(gc->Construct()); + gc->Construct(); //should panic + delete gc; + } + break; + case 10: + { + CWsScreenDevice* screendevice = new (ELeave) CWsScreenDevice(ws); + User::LeaveIfError(screendevice->Construct()); + screendevice->Construct(); //should panic + delete screendevice; + } + break; + default: + break; + } + ws.Flush(); + return(EWsExitReasonBad); + } +#endif + +/** Checks that activating a sprite without members will panic. +*/ +LOCAL_C TInt DoTestSpriteActivatePanicL(TInt aTest, TAny *aScreenNumber) + { + RWsSession ws; + User::LeaveIfError(ws.Connect()); + CWsScreenDevice* screen = new(ELeave) CWsScreenDevice(ws); + User::LeaveIfError(screen->Construct((TInt)aScreenNumber)); + RWindowGroup group(ws); + User::LeaveIfError(group.Construct(891, EFalse, screen)); + RBlankWindow bwin(ws); + User::LeaveIfError(bwin.Construct(group,892)); + + switch(aTest) + { + case 1: + { + RWsSprite sprite = RWsSprite(ws); + User::LeaveIfError(sprite.Construct(group,TPoint(),0)); + sprite.Activate(); //should panic here + sprite.Close(); + } + break; + case 2: + { + RWsSprite sprite = RWsSprite(ws); + User::LeaveIfError(sprite.Construct(bwin,TPoint(),0)); + sprite.Activate(); //should panic here + sprite.Close(); + } + break; + } + return(EWsExitReasonBad); + } + +LOCAL_C TInt DoMoveToGroupPanicTestL(TInt aTest, TAny *aScreenNumber) + { + RWsSession ws; + User::LeaveIfError(ws.Connect()); + // use correct screen + // + CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws); + User::LeaveIfError(screen->Construct((TInt)aScreenNumber)); + + RWindowGroup group(ws); + User::LeaveIfError(group.Construct(887)); + group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close + TInt id=group.Identifier(); + switch (aTest) + { + case 1: + { + RWindowTreeNode* win=&group; + ((RWindowBase*)win)->MoveToGroup(id); + } + break; + case 2: + { + RBlankWindow win1(ws); + User::LeaveIfError(win1.Construct(group,878)); + RBlankWindow win2(ws); + User::LeaveIfError(win2.Construct(win1,788)); + win2.MoveToGroup(id); + } + break; + } + ws.Flush(); + return(EWsExitReasonBad); + } + +LOCAL_C TInt DoGetEventPanicTestL(TInt aTest, TAny *aScreenNumber) + { + RWsSession ws; + User::LeaveIfError(ws.Connect()); + switch(aTest) + { + case 1: + { + TPckgBuf event; + ws.TestWrite(ws.WsHandle(),EWsClOpGetEvent,&event,0); + } + break; + case 2: + { + CWsScreenDevice* screen=new(ELeave) CWsScreenDevice(ws); + User::LeaveIfError(screen->Construct((TInt)aScreenNumber)); + RWindowGroup group(ws); + User::LeaveIfError(group.Construct(555)); // trigger a focus changed event + TRequestStatus stat; + ws.EventReady(&stat); + User::WaitForRequest(stat); + TPtrC8 badDesc(reinterpret_cast(0xDEAD),100); + ws.TestWrite(ws.WsHandle(),EWsClOpGetEvent,&badDesc,0); + } + break; + } + ws.Flush(); + return(EWsExitReasonBad); + } + +LOCAL_C TInt DoWinHandlePanicTestL(TInt aTest, TAny *) + { + RWsSession ws; + User::LeaveIfError(ws.Connect()); + RWindowGroup group1(ws); + RWindowGroup group2(ws); + RWindow win1(ws); + RWindow win2(ws); + switch(aTest) + { + case 1: + User::LeaveIfError(group1.Construct(888)); + User::LeaveIfError(group2.Construct(888)); + break; + case 2: + User::LeaveIfError(group1.Construct(777)); + User::LeaveIfError(win1.Construct(group1,888)); + User::LeaveIfError(win2.Construct(group1,888)); + break; + case 3: + User::LeaveIfError(group1.Construct(777)); + User::LeaveIfError(win1.Construct(group1,777)); + break; + case 4: + User::LeaveIfError(group1.Construct(777)); + User::LeaveIfError(win1.Construct(group1,0)); + break; + } + ws.Flush(); + return(EWsExitReasonBad); + } + +#ifdef __WINS__ +LOCAL_C TInt DoDeleteScreenPanicTestL(TInt aTest, TAny *aScreenNumber) +/** + * Test examples of use of the 'screen device deleted' panic for group windows. + * This is issued to panic the client, if they make API calls to RWindowGroup after having deleted + * the CWsScreenDevice with which that window group is associated. + */ + { + RWsSession ws; + User::LeaveIfError(ws.Connect()); + // point to correct screen + CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws); + User::LeaveIfError(screen->Construct((TInt)aScreenNumber)); + + RWindowGroup group(ws); + User::LeaveIfError(group.Construct(888)); + group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close + switch(aTest) + { + // Test 1: deleting screen then modifying screen change events is illegal + case 1: + { + delete screen, screen=NULL; + group.EnableScreenChangeEvents(); + break; + } + // Test 2: deleting screen then setting window group name is illegal + case 2: + { + delete screen, screen=NULL; + _LIT(KPanicTest, "PanicTest"); + group.SetName(KPanicTest); + break; + } + } + ws.Flush(); + return(EWsExitReasonBad); + } +#endif + +LOCAL_C TInt DoUnInitPanicTest(TInt , TAny *) + { + // Creating a client session outside the test harness for panicking + // before initialisation as the test harness initialises the one it creates. + TVersion version(0,0,0); + _LIT(KServerName, "!Windowserver"); + + RUnInitalisedConnect myUnInit; + + User::LeaveIfError(myUnInit.Connect(KServerName(), version)); + myUnInit.Send(EWservMessCommandBuffer); + + return(EWsExitReasonBad); + } + +void CTPanic::TestScreenDevicePanicsL() + { + TEST(iTest->TestWsPanicL(&DoScreenDevicePanicTest,EWservPanicBitmap,1,(TAny*)iTest->iScreenNumber)); + + TEST(iTest->TestWsPanicL(&DoScreenDevicePanicTest,EWservPanicBitmap,2,(TAny*)iTest->iScreenNumber)); + } + +void CTPanic::TestMiscPanicsL() + { + TBool finished=EFalse; + TInt index=0; + while(!finished) + { + const TBool result = iTest->TestWsPanicL(&DoMiscPanicTest, EWservNoPanic, index, NULL, &finished); + if(!result) + { + INFO_PRINTF2(_L("TestMiscPanicsL %d failed"), index); + TEST(result); + } + index++; + } + } + +void CTPanic::LogHeapInfo() + { + _LIT(KInfoHeapSummary," WsHeap - Count=%d,Total=%d,Free=%d,Max free=%d"); + TPckgBuf heapInfo; + TheClient->iWs.DebugInfo(EWsDebugInfoHeap,heapInfo); + TBuf<256> infoBuf; + infoBuf.Format(KInfoHeapSummary,heapInfo().iCount,heapInfo().iTotal,heapInfo().iAvailable,heapInfo().iLargestAvailable); + INFO_PRINTF1(infoBuf); + } + +void CTPanic::TestGraphicsPanicsL(TClientPanic aExitReason, TInt aIndex, CTPanic::TPanicParams* aPanicParams) + { + TBool finished=EFalse; + aPanicParams->iSubTest=0; + + // uncomment to show which test is being run + INFO_PRINTF3(_L("GraphicsPanicTest %d, mode=%d"),aIndex,aPanicParams->iRedrawMode); + RDebug::Print(_L("GraphicsPanicTest %d, mode=%d"),aIndex,aPanicParams->iRedrawMode); + do + { + // uncomment for detailed view of which sub-test failed + LogHeapInfo(); + INFO_PRINTF4(_L("GraphicsPanicTest %d/%d, mode=%d"),aIndex,aPanicParams->iSubTest,aPanicParams->iRedrawMode); + RDebug::Print(_L("GraphicsPanicTest %d/%d, mode=%d"),aIndex,aPanicParams->iSubTest,aPanicParams->iRedrawMode); + TEST(iTest->TestWsPanicL(&GraphicsPanicTest,aExitReason,aIndex,aPanicParams,&finished)); + aPanicParams->iSubTest++; + } while(!finished); + iTest->CloseAllPanicWindows(); + } + +void CTPanic::TestGraphicsPanicsL(TPanicRedrawMode aRedrawMode) + { + CTPanic::TPanicParams pp; + pp.iScreen=iTest->iScreenNumber; + pp.iRedrawMode=aRedrawMode; + static TClientPanic expectedPanics[]= + { + EWservPanicBufferPtr, + EWservPanicBitmap, + EWservPanicBitmap, + EWservPanicBitmap, + EWservPanicOpcode, + EWservPanicBadPolyData, + EWservPanicBadPolyData, + EWservPanicOpcode, + EWservPanicGcActive, + EWservPanicNoFont, + EWservPanicNoBrush, + EWservPanicDescriptor, + EWservPanicFont, + EWservNoPanic, // Marks the end of the list + }; + TInt panicIndex=0; + TClientPanic expectedPanic; + while((expectedPanic=expectedPanics[panicIndex++])!=EWservNoPanic) + { + TestGraphicsPanicsL(expectedPanic,panicIndex,&pp); + } + } + +void CTPanic::TestGraphicsPanicsL() + { + TestGraphicsPanicsL(EPanicRedrawModeBackedUpWindow); + TestGraphicsPanicsL(EPanicRedrawModeNormalRedraw); + if (TransparencySupportedL()==KErrNone) + { + TestGraphicsPanicsL(EPanicRedrawModeTransRedraw); + } + TestGraphicsPanicsL(EPanicRedrawModeInvisRedraw); + } + +void CTPanic::TestDeletedParentPanicsL() + { + TEST(iTest->TestWsPanicL(&DoDeletedParentTest,EWservPanicParentDeleted,1,(TAny*)iTest->iScreenNumber)); + } + +void CTPanic::TestHandleReUseL() + { + for (TInt ii=2;ii<6;++ii) + { + TEST(iTest->TestWsPanicL(&DoHandleReUse,EWservPanicHandle,ii,(TAny*)iTest->iScreenNumber)); + } + } + +void CTPanic::TestComputeModePanicsL() + { + TEST(iTest->TestWsPanicL(&DoCMPanicTest,EWservPanicSetComputeMode,1,(TAny*)iTest->iScreenNumber)); + } + +void CTPanic::TestCaptureKeyPanicsL() + { +// Run this test in debug on emulator only. +// On a debug ROM the release version of the wserv.exe is included so the test can't be run as no panic happens. +#if defined(_DEBUG) && defined(__WINS__) + TEST(iTest->TestWsPanicL(&DoCKPanicTest,EWservPanicDestroy,1,(TAny*)iTest->iScreenNumber)); +#endif + } + +void CTPanic::TestEventPanicsL() + { + TEST(iTest->TestWsPanicL(&DoEventPanicTest,EWservPanicReadOutstanding,1,(TAny*)iTest->iScreenNumber)); + } + +void CTPanic::TestTPtrPanicsL() + { + TEST(iTest->TestWsPanicL(&DoTBufPtrTests,EWservPanicBufferPtr,1,(TAny*)iTest->iScreenNumber)); + } + +void CTPanic::TestOpcodePanicsL() + { + TInt param=1; + TBool finishTest = EFalse; + while(!finishTest) + { + TEST(iTest->TestWsPanicL(&DoOpcodeTests,EWservPanicOpcode,param,(TAny*)iTest->iScreenNumber,&finishTest)); + param++; + } + } + +void CTPanic::TestMultiInitPanicL() + { + TEST(iTest->TestWsPanicL(&DoMultiInitPanicTest,EWservPanicReInitialise,0,(TAny*)iTest->iScreenNumber)); + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-0472 + +@SYMDEF DEF118618 + +@SYMTestCaseDesc Test defect fixes to system panics + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Check that various defect fixes to system panics are correct. + Also verify that reconstructing a closed object will succeed. + +@SYMTestExpectedResults Panics respond correctly +*/ +void CTPanic::TestDoubleConstructionL() + { +#ifdef __WINS__ + for(TInt test=1;test<11;test++) + { + TEST(iTest->TestW32PanicL(&DoDoubleConstructionTestL,EW32PanicGraphicDoubleConstruction,test,NULL)); + } + TestDoubleConstructionNoPanic(); +#endif + } + +/** Verifies the following scenario is valid: + 1. Create some wserv client-side objects. + 2. Call Close on them. + 3. Reconstruct them and they shouldn't panic this time. */ +void CTPanic::TestDoubleConstructionNoPanic() + { + RWsSession ws; + User::LeaveIfError(ws.Connect()); + + RWindowGroup group(ws); + User::LeaveIfError(group.Construct(890, EFalse)); + RBlankWindow bwin(ws); + User::LeaveIfError(bwin.Construct(group,900)); + + //RWsSprite + RWsSprite sprite(ws); + TEST(KErrNone == sprite.Construct(bwin,TPoint(0,0),0)); + sprite.Close(); + TEST(KErrNone == sprite.Construct(bwin,TPoint(0,0),0)); + sprite.Close(); + + //RWsPointerCursor + RWsPointerCursor cursor(ws); + TEST(KErrNone == cursor.Construct(0)); + cursor.Close(); + TEST(KErrNone == cursor.Construct(0)); + cursor.Close(); + + //RSoundPlugIn + RSoundPlugIn click(ws); + TEST(KErrNone == click.Construct()); + click.Close(); + TEST(KErrNone == click.Construct()); + click.Close(); + + //RWindowGroup + RWindowGroup windowgroup(ws); + TEST(KErrNone ==windowgroup.Construct(901)); + windowgroup.Close(); + TEST(KErrNone ==windowgroup.Construct(901)); + windowgroup.Close(); + + //RWindow + RWindow win1(ws); + TEST(KErrNone == win1.Construct(group,902)); + win1.Close(); + TEST(KErrNone == win1.Construct(group,902)); + win1.Close(); + + //RBlankWindow + RBlankWindow win2(ws); + TEST(KErrNone == win2.Construct(group,902)); + win2.Close(); + TEST(KErrNone == win2.Construct(group,902)); + win2.Close(); + + //RBackedUpWindow + RBackedUpWindow win3(ws); + TEST(KErrNone == win3.Construct(group,EGray4,902)); + win3.Close(); + TEST(KErrNone == win3.Construct(group,EGray4,902)); + win3.Close(); + + //RAnimDll + RAnimDll animDll=RAnimDll(ws); + TEST(KErrNone == animDll.Load(KAnimDLLName)); + animDll.Close(); + TEST(KErrNone == animDll.Load(KAnimDLLName)); + animDll.Close(); + + group.Close(); + bwin.Close(); + ws.Close(); + } + +void CTPanic::TestSpritePanicsL() + { + for(TInt test=1;test<4;test++) + { + TEST(iTest->TestWsPanicL(&DoSpritePanicTestL,EWservPanicSprite,test,(TAny*)iTest->iScreenNumber)); + } + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-0475 + +@SYMDEF DEF118616 + +@SYMTestCaseDesc Test defect fixes to system panics + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Check that various defect fixes to system panics are correct. + +@SYMTestExpectedResults Panics respond correctly +*/ +void CTPanic::TestSpriteActivatePanicL() + { + for(TInt test=1;test<3;test++) + { + TEST(iTest->TestWsPanicL(&DoTestSpriteActivatePanicL,EWservPanicNoSpriteMember,test,NULL)); + } + } + +void CTPanic::TestMoveToGroupPanicsL() + { + TEST(iTest->TestWsPanicL(&DoMoveToGroupPanicTestL,EWservPanicOpcode,1,(TAny*)iTest->iScreenNumber)); + TEST(iTest->TestWsPanicL(&DoMoveToGroupPanicTestL,EWservPanicNotTopClient,2,(TAny*)iTest->iScreenNumber)); + } + +void CTPanic::TestDeleteScreenPanicL() + { +#ifdef __WINS__ + TEST(iTest->TestWsPanicL(&DoDeleteScreenPanicTestL,EWservPanicGroupWinScreenDeviceDeleted,1,(TAny*)iTest->iScreenNumber)); + TEST(iTest->TestWsPanicL(&DoDeleteScreenPanicTestL,EWservPanicGroupWinScreenDeviceDeleted,2,(TAny*)iTest->iScreenNumber)); +#endif + } + +void CTPanic::TestWinHandleErrors() + { +#ifdef __WINS__ + TEST(iTest->TestWsPanicL(&DoWinHandlePanicTestL,EWservPanicDuplicateHandle,1)); + TEST(iTest->TestWsPanicL(&DoWinHandlePanicTestL,EWservPanicDuplicateHandle,2)); + TEST(iTest->TestWsPanicL(&DoWinHandlePanicTestL,EWservPanicDuplicateHandle,3)); +#endif + TEST(iTest->TestWsPanicL(&DoWinHandlePanicTestL,EWservPanicNullHandle,4)); + } + +void CTPanic::TestGetEventErrors() + { + TEST(iTest->TestWsPanicL(&DoGetEventPanicTestL,EWservPanicUnsignalledEventData,1,(TAny*)iTest->iScreenNumber)); + TEST(iTest->TestWsPanicL(&DoGetEventPanicTestL,EWservPanicDescriptor,2,(TAny*)iTest->iScreenNumber)); + } + +void CTPanic::TestUnInitPanicL() + { + TEST(iTest->TestWsPanicL(&DoUnInitPanicTest,EWservPanicUninitialisedClient,0,(TAny*)iTest->iScreenNumber)); + } + +void CTPanic::ConstructL() + { + TheGc->Activate(*BaseWin->Win()); + TheGc->Clear(); + TheGc->SetBrushColor(TRgb::Gray16(12)); + TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + TheGc->SetPenStyle(CGraphicsContext::ENullPen); + TheGc->DrawRect(TRect(BaseWin->Win()->Size())); + TheGc->Deactivate(); + TheGc->Activate(*TestWin->Win()); + TheGc->Clear(); + TheGc->SetBrushColor(TRgb::Gray16(4)); + TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + TheGc->SetPenStyle(CGraphicsContext::ENullPen); + TheGc->DrawRect(TRect(TestWin->Win()->Size())); + TheGc->Deactivate(); +// + _LIT(KReportFullRom,"Warning full ROM, EikSrv present, panic dialogs may interfere with tests"); + _LIT(KReportGoodRom,"ROM OK, No EikSrv present"); + if (iTest->IsFullRomL()) + { + INFO_PRINTF1(KReportFullRom); + } + else + { + INFO_PRINTF1(KReportGoodRom); + } + } + +void CTPanic::TestAlphaBlendingPanicL() + { + INFO_PRINTF1(_L("Masked transparency support has been removed.")); + } + +void CTPanic::TestMismatchedCaptureCancelPanicL() + { +// Run this test in debug on emulator only. +// On a debug ROM the release version of the wserv.exe is included so the test can't be run as no panic happens. +#if defined(_DEBUG) && defined(__WINS__) + TEST(iTest->TestWsPanicL(DoMismatchedCancelCaptureTest,EWservPanicDestroy,ECancelCaptureKey,(TAny*)iTest->iScreenNumber)); + TEST(iTest->TestWsPanicL(DoMismatchedCancelCaptureTest,EWservPanicDestroy,ECancelCaptureKeyUpAndDowns,(TAny*)iTest->iScreenNumber)); + TEST(iTest->TestWsPanicL(DoMismatchedCancelCaptureTest,EWservPanicDestroy,ECancelCaptureLongKey,(TAny*)iTest->iScreenNumber)); +#endif + } + +void CTPanic::RunTestCaseL(TInt /*aCurTestCase*/) + { + ((CTPanicStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); + switch(++iTest->iState) + { +/** +@SYMTestCaseID GRAPHICS-WSERV-0259 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test various system panics + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Check that various system panics respond correctly + +@SYMTestExpectedResults Panics respond correctly +*/ + case 1: + { + ((CTPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0259")); + iTest->LogSubTest(_L("TestCaptureKeyPanicsL")); + TestCaptureKeyPanicsL(); + } + break; + case 2: + { + iTest->LogSubTest(_L("TestEventPanicsL")); + TestEventPanicsL(); + } + break; + case 3: + { + iTest->LogSubTest(_L("TestComputeModePanicsL")); + TestComputeModePanicsL(); + } + break; + case 4: + { +#ifdef __WINS__ +// Only running this under WINS as the tests are a bit excessive, firing off all sorts of illegal +// opcode/flag combinations, as well as buffers of random data. +// Currently on ARM builds they're failing with KErrOutOfMemory, probably running out of handles +// somewhere in the OS. + iTest->LogSubTest(_L("TestMiscPanicsL")); + TestMiscPanicsL(); +#endif + } + break; + case 5: + { + iTest->LogSubTest(_L("TestGraphicsPanicsL")); + TestGraphicsPanicsL(); + } + break; + case 6: + { + iTest->LogSubTest(_L("TestTPtrPanicsL")); + TestTPtrPanicsL(); + } + break; + case 7: + { + iTest->LogSubTest(_L("TestOpcodePanicsL")); + TestOpcodePanicsL(); + } + break; + case 8: + { + iTest->LogSubTest(_L("TestScreenDevicePanicsL")); + TestScreenDevicePanicsL(); + } + break; + case 9: + { + iTest->LogSubTest(_L("TestMultiInitPanicL")); + TestMultiInitPanicL(); + } + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0260 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test various system panics + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Check that various system panics respond correctly + +@SYMTestExpectedResults Panics respond correctly +*/ + case 10: + { + ((CTPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0260")); + iTest->LogSubTest(_L("Panic 2")); + TestSpritePanicsL(); + TestMoveToGroupPanicsL(); + } + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0261 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test defect fixes to system panics + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Check that various defect fixes to system panics are correct + +@SYMTestExpectedResults Panics respond correctly +*/ + case 11: + { + ((CTPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0261")); + _LIT(KPanicTest,"Defect Fixes (Pan.3)"); + iTest->LogSubTest(KPanicTest); + TestDeletedParentPanicsL(); + TestHandleReUseL(); + TestDeleteScreenPanicL(); // DEF069809 + } + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-097969-0001 + +@SYMDEF DEF097969 + +@SYMTestCaseDesc Test defect fixes to system panics + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Check that various defect fixes to system panics are correct + +@SYMTestExpectedResults Panics respond correctly +*/ + case 12: + { + ((CTPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-097969-0001")); + _LIT(KPanicTest,"Server panic defect Fix (Pan.4)"); + iTest->LogSubTest(KPanicTest); + TestUnInitPanicL(); // DEF097969 + } + break; + + case 13: + { +/** +@SYMTestCaseID GRAPHICS-WSERV-0501 +*/ + ((CTPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0501")); + _LIT(KPanicTest,"AlphaBlending Bitmap panic defect Fix (Pan.5)"); + iTest->LogSubTest(KPanicTest); + TestAlphaBlendingPanicL(); // DEF112916 + } + break; + case 14: + { + ((CTPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0472")); + _LIT(KPanicTest,"Double construction panic test"); + iTest->LogSubTest(KPanicTest); + TestDoubleConstructionL(); // DEF118618 + } + break; + case 15: + { + ((CTPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0475")); + _LIT(KPanicTest, "RWsSprite Activate() without members panic test"); + iTest->LogSubTest(KPanicTest); + TestSpriteActivatePanicL(); //DEF118616 + } + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0497 + +@SYMDEF DEF133776 + +@SYMTestCaseDesc Test that a debug only panic occurs when an attempt + is made to cancel a key capture using the wrong cancel capture API. + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Check that calling the each RWindowGroup::CancelCapture***() API + using the handle returned from a mismatched RWindowGroup::Capture***() call causes + a debug only panic. Tests each of the three RWindowGroup::CancelCapture***() APIs. + +@SYMTestExpectedResults Panics respond correctly in debug only. +*/ + case 16: + { + ((CTPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0497")); + _LIT(KPanicTest,"TestMismatchedCaptureCancelPanicL"); + iTest->LogSubTest(KPanicTest); + TestMismatchedCaptureCancelPanicL(); + } + break; +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA + case 17: + { + _LIT(KPanicTest, "Non-Redraw Drawing inside Redrawer Panic Test"); + iTest->LogSubTest(KPanicTest); + TestNonRedrawRedrawerL(); + } +#endif + default: + ((CTPanicStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + ((CTPanicStep*)iStep)->CloseTMSGraphicsStep(); + TestComplete(); + break; + } + ((CTPanicStep*)iStep)->RecordTestResultL(); + } + +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA +LOCAL_C TInt DoTestNonRedrawRedrawerL(TInt /* aInt */, TAny * /* aPtr */) + { + CActiveScheduler* scheduler = new (ELeave) CActiveScheduler(); + CleanupStack::PushL(scheduler); + CActiveScheduler::Install(scheduler); + + RWsSession session; + User::LeaveIfError(session.Connect()); + + CWsScreenDevice *screenDevice = new (ELeave)CWsScreenDevice(session); + User::LeaveIfError(screenDevice->Construct ()); + CWindowGc *gc; + User::LeaveIfError(screenDevice->CreateContext(gc)); + + CNonRedrawWin *nonRedrawWin=CNonRedrawWin::NewL(session, gc); + nonRedrawWin->Invalidate(); + CActiveScheduler::Start(); + User::After(2000000); // so the Redrawer has a chance to run + CActiveScheduler::Stop(); + delete gc; + delete screenDevice; + session.Close(); + CleanupStack::PopAndDestroy(scheduler); + return(EWsExitReasonBad); + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-0121808 +@SYMDEF DEF121808: No more Non-Redraw drawing for NGA (test added during DEF134308) +@SYMTestCaseDesc Test defect fixes to system panics +@SYMTestPriority High +@SYMTestStatus Implemented +@SYMTestActions Check that WServ panics a client which uses Non-Redraw drawing in the Redrawer. +@SYMTestExpectedResults Panics respond correctly +*/ +void CTPanic::TestNonRedrawRedrawerL() + { + TEST(iTest->TestWsPanicL(&DoTestNonRedrawRedrawerL,EWservPanicWindowBeginRedrawNotCalled,NULL,NULL)); + } + +CNonRedrawWin::CRedrawer::CRedrawer(CNonRedrawWin* aWd) : + CActive(CActive::EPriorityStandard), iWd(aWd){ + CActiveScheduler::Add(this); + HandleRedrawEvent(); +} + +CNonRedrawWin::CRedrawer::~CRedrawer(){ + Cancel(); +} + +void CNonRedrawWin::CRedrawer::HandleRedrawEvent(){ + iWd->GetSession().RedrawReady(&iStatus); + SetActive(); +} + +void CNonRedrawWin::CRedrawer::RunL(){ + TWsRedrawEvent redrawEvent; + iWd->GetSession().GetRedraw(redrawEvent); + iWd->Redraw(); + HandleRedrawEvent(); +} + +void CNonRedrawWin::CRedrawer::DoCancel(){ + iWd->GetSession().RedrawReadyCancel(); +} + +CNonRedrawWin* CNonRedrawWin::NewL(RWsSession &aSession, CWindowGc *aGc){ + CNonRedrawWin* self=new(ELeave)CNonRedrawWin(aSession, aGc); + CleanupStack::PushL(self); + self->ConstrucL(); + CleanupStack::Pop(self); + return self; +} + +CNonRedrawWin::CNonRedrawWin(RWsSession &aSession, CWindowGc *aGc): + iSession(aSession), iGc(aGc){} + +CNonRedrawWin::~CNonRedrawWin(){ + delete iRedrawer; + iWd.Close(); + iWdGrp.Close(); +} + +void CNonRedrawWin::Redraw(){ + // This is a Non-Redraw Drawing Redrawer; BeginRedraw()/EndRedraw() + // have been intentionally omitted. + iGc->Activate(iWd); + iGc->SetBrushColor(TRgb(255,0,0)); + iGc->SetPenColor(KRgbBlue); + iGc->SetPenSize(TSize(10,20)); + iGc->DrawRect(TRect(TPoint(10,10),TPoint(50,50))); + iGc->Deactivate(); + iSession.Finish(); +} + +RWsSession &CNonRedrawWin::GetSession(){return iSession;} + +void CNonRedrawWin::Invalidate(){iWd.Invalidate();} + +void CNonRedrawWin::ConstrucL(){ + iWdGrp=RWindowGroup(iSession); + iWdGrp.Construct((TUint32)this,ETrue); + _LIT(KWndGrpName,"NonRedrawWndGrp"); + iWdGrp.SetName(KWndGrpName); + iWd=RWindow(iSession); + iWd.Construct(iWdGrp, 0x101); + User::LeaveIfError(iWd.SetExtentErr(TPoint(0,0),TSize(150,150))); + iWd.SetBackgroundColor(KRgbWhite); + iWd.SetOrdinalPosition(0); + iWd.Activate(); + iRedrawer=new(ELeave) CRedrawer(this); +} +#endif + +TInt RUnInitalisedConnect::Connect(const TDesC &aName, const TVersion &aVersion) + { + return CreateSession(aName, aVersion, 255); + } + +TInt RUnInitalisedConnect::Send(const TInt aMsg) + { + return SendReceive(aMsg); + } + +__WS_CONSTRUCT_STEP__(Panic) +#pragma warning( disable : 4505 ) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TPANIC.H --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TPANIC.H Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,154 @@ + +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef __TPANIC_H__ +#define __TPANIC_H__ + +#include +#include +#include "../tlib/testbase.h" +#include "AUTO.H" +#include "AUTODLL.H" +#include "TGraphicsHarness.h" + +enum TPanicRedrawMode + { + EPanicRedrawModeBackedUpWindow, // Draw to a RBackedUpWindow; no BeginRedraw()/EndRedraw() needed + EPanicRedrawModeNormalRedraw, // Draw in a redraw + EPanicRedrawModeTransRedraw, // Draw to a window under a transparent window in a redraw + EPanicRedrawModeInvisRedraw, // Draw to an invisible window in a redraw + }; + +class CTPanic : public CTWsGraphicsBase + { +public: + struct TPanicParams + { + public: + TInt iScreen; + TPanicRedrawMode iRedrawMode; + TInt iSubTest; + }; + + enum TCancelCaptureType + { + ECancelCaptureKey, + ECancelCaptureKeyUpAndDowns, + ECancelCaptureLongKey + }; +public: + CTPanic(CTestStep* aStep); + ~CTPanic(); + void ConstructL(); +private: + void TestDeletedParentPanicsL(); + void TestScreenDevicePanicsL(); + void TestGraphicsPanicsL(TClientPanic aExitReason, TInt aIndex, CTPanic::TPanicParams* aPanicParams); + void TestGraphicsPanicsL(); + void TestGraphicsPanicsL(TPanicRedrawMode aRedrawMode); + void TestMiscPanicsL(); + void TestComputeModePanicsL(); + void TestCaptureKeyPanicsL(); + void TestEventPanicsL(); + void TestTPtrPanicsL(); + void TestOpcodePanicsL(); + void TestMultiInitPanicL(); + void TestSpritePanicsL(); + void TestMoveToGroupPanicsL(); + void TestHandleReUseL(); + void TestDeleteScreenPanicL(); + void TestWinHandleErrors(); + void TestGetEventErrors(); + void TestUnInitPanicL(); + void TestAlphaBlendingPanicL(); + void TestDoubleConstructionL(); + void TestDoubleConstructionNoPanic(); + void TestSpriteActivatePanicL(); +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA + void TestNonRedrawRedrawerL(); +#endif + void TestMismatchedCaptureCancelPanicL(); + void LogHeapInfo(); +protected: +//from CTGraphicsStep + virtual void RunTestCaseL(TInt aCurTestCase); +private: + TSize iWinSize; + }; + +class CTPanicStep : public CTGraphicsStep + { +public: + CTPanicStep(); +protected: + //from CTGraphicsStep + virtual CTGraphicsBase* CreateTestL(); + }; + +_LIT(KTPanicStep,"TPanic"); + +class RUnInitalisedConnect : public RSessionBase + { + public: + TInt Connect(const TDesC &aName, const TVersion &aVersion); + TInt Send(const TInt aMsg); + }; + +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA +class CNonRedrawWin : public CBase{ + public: + ~CNonRedrawWin(); + static CNonRedrawWin* NewL(RWsSession &aSession, CWindowGc *aGc); + virtual void Redraw(); + RWsSession &GetSession(); + void Invalidate(); + + protected: + CNonRedrawWin(RWsSession &aSession, CWindowGc *aGc); + void ConstrucL(); + + class CRedrawer : public CActive{ + public: + CRedrawer(CNonRedrawWin* aWd); + ~CRedrawer(); + private: + void HandleReDrawEvent(); + void RunL(); + void DoCancel(); + void HandleRedrawEvent(); + + private: + CNonRedrawWin* iWd; + }; + + private: + RWsSession &iSession; + RWindowGroup iWdGrp; + RWindow iWd; + CWindowGc *iGc; + + CRedrawer *iRedrawer; + +}; +#endif + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TPNTCAP.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TPNTCAP.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,1014 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Test pointer capture +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include "TPNTCAP.H" + +#define LOGGING on + +_LIT(ClickOnMe,"Click on me"); + +// +// CMcConnection + +CPcConnection::CPcConnection(CTPointerCapture *aTest) : iTest(aTest) + { + } + +CPcConnection::~CPcConnection() + { + } + +void CPcConnection::ConstructL() + { + CTClient::SetScreenNumber(iTest->TestBase()->ScreenNumber()); + CTClient::ConstructL(); + iGroup=new(ELeave) CTWindowGroup(this); + iGroup->ConstructL(); + iGroup->GroupWin()->SetOrdinalPosition(0,1); + iGroup->GroupWin()->EnableReceiptOfFocus(EFalse); + iWs.Flush(); + } + +// +// CPcWindow, base class // +// + +CPcWindowBase::CPcWindowBase(CTPointerCapture *aTest) : CTWin(), iTest(aTest) + { + } + +void CPcWindowBase::SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc) + { + ConstructExtLD(*parent,pos,size); + iWin.SetBackgroundColor(iBack); + Activate(); + AssignGC(aGc); + } + +void CPcWindowBase::SetUpL(TPoint pos,TSize size,CTWinBase *parent) + { + SetUpL(pos,size,parent,*iTest->Client()->iGc); + } + +void CPcWindowBase::SubStateChanged() + { + iWin.Invalidate(); + Client()->iWs.Flush(); + } + +void CPcWindowBase::Draw(TDesC &aBuf) + { + iGc->Clear(); + iGc->SetPenColor(iBack.Gray4()>1 ? TRgb(0,0,0) : TRgb(255,255,255)); + iGc->DrawText(aBuf, TPoint(10,20)); + } + +void CPcWindowBase::PointerL(const TPointerEvent &pointer,const TTime &) + { +#if defined(LOGGING) + _LIT(KLog1,"Pointer Event Recieved Type=%S State=%d SubState=%d"); + _LIT(KDown,"Down"); + _LIT(KUp,"Up"); + iTest->LOG_MESSAGE4(KLog1,&(pointer.iType?KUp():KDown()),iTest->State(),iTest->SubState()); +#endif + if (pointer.iType==TPointerEvent::EButton1Down && !iTest->iFailed) + { + if (iTest->SubState()==ERootWindow) // Root window click, must not be inside this window + { + if (TRect(Size()).Contains(pointer.iPosition)) + { + iTest->TestFailed(); + return; + } + } + TInt ret; + if ((ret=PointerDown())==EFailed) + iTest->TestFailed(); + else + iTest->IncSubStateL(ret==ENeedsDDEvent); + } +#if defined(LOGGING) + _LIT(KLog2,"End of processing Pointer Event"); + iTest->LOG_MESSAGE(KLog2); +#endif + } + +void CPcWindowBase::DragDropL(const TPointerEvent &pointer,const TTime &) + { +#if defined(LOGGING) + _LIT(KLog,"CPcWindowBase::DragDropL Type=%d State=%d SubState=%d"); + iTest->LOG_MESSAGE4(KLog,pointer.iType,iTest->State(),iTest->SubState()); +#endif + switch(iTest->State()) + { + case ENormalCaptureWithoutFocus: + if (iTest->SubState()==0) + break; + case ECaptureDisabled: + case ENormalCapture: + case ECaptureAllGroups: + iTest->TestFailed(); + break; + } + if (pointer.iType==TPointerEvent::EButton1Down && !iTest->iFailed) + { + if (DragDrop()==EFailed) + iTest->TestFailed(); + else + iTest->GotDDL(); + } + } +// + +CPcWindowMain::CPcWindowMain(CTPointerCapture *aTest) : CPcWindowBase(aTest) + { + iBack=TRgb::Gray256(236); + } + +TPointerCheckRet CPcWindowMain::PointerDown() + { +#if defined(LOGGING) + _LIT(KLog1,"CPcWindowMain::PointerDown State=%d SubState=%d"); + iTest->LOG_MESSAGE3(KLog1,iTest->State(),iTest->SubState()); +#endif + switch(iTest->State()) + { + case ECaptureDisabled: + if (iTest->SubState()==EMainWindow) + return(EOkay); + break; + case ENormalCapture: + switch(iTest->SubState()) + { + case EMainWindow: + case ERootWindow: + return(EOkay); + default: + break; + } + break; + case ECaptureAllGroups: + switch(iTest->SubState()) + { + case EMainWindow: + case EOtherGroup: + case EOtherSession: + case ERootWindow: + return(EOkay); + default: + break; + } + break; + case EDragDropCapture: + switch(iTest->SubState()) + { + case EMainWindow: + return(ENeedsDDEvent); + case ERootWindow: + return(EOkay); + default: + break; + } + break; + case EDragDropCaptureAllGroups: + switch(iTest->SubState()) + { + case EMainWindow: + case EOtherGroup: + case EOtherSession: + return(ENeedsDDEvent); + case ERootWindow: + return(EOkay); + default: + break; + } + break; + case ENormalCaptureWithoutFocus: + switch(iTest->SubState()) + { + case EMainWindow: + return(EOkay); + default: + break; + } + break; + default: + break; + } +#if defined(LOGGING) + _LIT(KLog2,"CPcWindowMain::PointerDown FAILED State=%d SubState=%d"); + iTest->LOG_MESSAGE3(KLog2,iTest->State(),iTest->SubState()); +#endif + return(EFailed); + } + +TPointerCheckRet CPcWindowMain::DragDrop() + { +#if defined(LOGGING) + _LIT(KLog1,"CPcWindowMain::DragDrop State=%d SubState=%d"); + iTest->LOG_MESSAGE3(KLog1,iTest->State(),iTest->SubState()); +#endif + switch(iTest->State()) + { + case EDragDropCapture: + case EDragDropCaptureAllGroups: + switch(iTest->SubState()) + { + case EMainWindow: + return(EOkay); + default: + break; + } + break; + default: + break; + } +#if defined(LOGGING) + _LIT(KLog2,"CPcWindowMain::DragDrop FAILED State=%d SubState=%d"); + iTest->LOG_MESSAGE3(KLog2,iTest->State(),iTest->SubState()); +#endif + return(EFailed); + } + +void CPcWindowMain::Draw() + { + TBuf<0x40> buf; + if (iTest->State()==ECaptureDisabled) + { + switch(iTest->SubState()) + { + case EMainWindow: + buf.Copy(ClickOnMe); + break; + } + } + else + { + switch(iTest->SubState()) + { + case EMainWindow: + buf.Copy(ClickOnMe); + break; + case EChildWindow: + case EOtherGroup: + case EOtherSession: + break; + case ERootWindow: + { + _LIT(ClickOnRoot,"Click on the root window"); + if (iTest->State()"); + buf.Copy(ClickOnRoot); + buf.Append(AndEscape); + } + } + break; + } + } + CPcWindowBase::Draw(buf); + } + +void CPcWindowMain::WinKeyL(const TKeyEvent &aKey,const TTime &) + { + switch(aKey.iCode) + { + case EKeyEscape: + iTest->AbortTests(); + break; + case EKeyEnter: + if (iTest->SubState()==ERootWindow) + iTest->IncSubStateL(EFalse); + break; + } + } + +// + +CPcWindowChild::CPcWindowChild(CTPointerCapture *aTest) : CPcWindowBase(aTest) + { + iBack=TRgb::Gray256(85); + } + +TPointerCheckRet CPcWindowChild::PointerDown() + { +#if defined(LOGGING) + _LIT(KLog1,"CPcWindowChild::PointerDown State=%d SubState=%d"); + iTest->LOG_MESSAGE3(KLog1,iTest->State(),iTest->SubState()); +#endif + switch(iTest->State()) + { + case ECaptureDisabled: + break; + default: + switch(iTest->SubState()) + { + case EChildWindow: + return(EOkay); + default: + break; + } + break; + } +#if defined(LOGGING) + _LIT(KLog2,"CPcWindowChild::PointerDown FAILED State=%d SubState=%d"); + iTest->LOG_MESSAGE3(KLog2,iTest->State(),iTest->SubState()); +#endif + return(EFailed); + } + +TPointerCheckRet CPcWindowChild::DragDrop() + { +#if defined(LOGGING) + _LIT(KLog1,"CPcWindowChild::PointerDown State=%d SubState=%d"); + iTest->LOG_MESSAGE3(KLog1,iTest->State(),iTest->SubState()); +#endif + switch(iTest->State()) + { + case EDragDropCapture: + case EDragDropCaptureAllGroups: + switch(iTest->SubState()) + { + case EChildWindow: + return(EOkay); + default: + break; + } + break; + default: + break; + } +#if defined(LOGGING) + _LIT(KLog2,"CPcWindowChild::PointerDown FAILED State=%d SubState=%d"); + iTest->LOG_MESSAGE3(KLog2,iTest->State(),iTest->SubState()); +#endif + return(EFailed); + } + +void CPcWindowChild::Draw() + { + TBuf<0x40> buf; + if (iTest->State()!=ECaptureDisabled) + { + switch(iTest->SubState()) + { + case EChildWindow: + buf.Copy(ClickOnMe); + break; + default: + break; + } + } + CPcWindowBase::Draw(buf); + } + +// + +CPcWindowNickFocusGroup::CPcWindowNickFocusGroup(CTPointerCapture *aTest, CTClient *aClient) : CTWindowGroup(aClient), iTest(aTest) + { + } + +void CPcWindowNickFocusGroup::KeyL(const TKeyEvent &aKey,const TTime &) + { + if (aKey.iCode==EKeyEscape) + iTest->IncSubStateL(EFalse); + } + +// + +CPcWindowAltGroup::CPcWindowAltGroup(CTPointerCapture *aTest) : CPcWindowBase(aTest) + { + iBack=TRgb::Gray256(236); + } + +TPointerCheckRet CPcWindowAltGroup::PointerDown() + { +#if defined(LOGGING) + _LIT(KLog1,"CPcWindowAltGroup::PointerDown State=%d SubState=%d"); + iTest->LOG_MESSAGE3(KLog1,iTest->State(),iTest->SubState()); +#endif + switch(iTest->State()) + { + case ECaptureDisabled: + if (iTest->SubState()==EChildWindow) + return(EOkay); + break; + case ENormalCapture: + case EDragDropCapture: + case ENormalCaptureWithoutFocus: + switch(iTest->SubState()) + { + case EOtherGroup: + return(EOkay); + default: + break; + } + break; + default: + break; + } +#if defined(LOGGING) + _LIT(KLog2,"CPcWindowAltGroup::PointerDown FAILED State=%d SubState=%d"); + iTest->LOG_MESSAGE3(KLog2,iTest->State(),iTest->SubState()); +#endif + return(EFailed); + } + +TPointerCheckRet CPcWindowAltGroup::DragDrop() + { +#if defined(LOGGING) + _LIT(KLog1,"CPcWindowAltGroup::DragDrop State=%d SubState=%d"); + iTest->LOG_MESSAGE3(KLog1,iTest->State(),iTest->SubState()); +#endif + switch(iTest->State()) + { + case EDragDropCapture: + case EDragDropCaptureAllGroups: + switch(iTest->SubState()) + { + case EOtherGroup: + return(EOkay); + default: + break; + } + break; + default: + break; + } +#if defined(LOGGING) + _LIT(KLog2,"CPcWindowAltGroup::DragDrop FAILED State=%d SubState=%d"); + iTest->LOG_MESSAGE3(KLog2,iTest->State(),iTest->SubState()); +#endif + return(EFailed); + } + +void CPcWindowAltGroup::Draw() + { + TBuf<0x40> buf; + if (iTest->State()==ECaptureDisabled) + { + switch(iTest->SubState()) + { + case EMainWindow: + break; + case EChildWindow: + buf.Copy(ClickOnMe); + break; + } + } + else + { + switch(iTest->SubState()) + { + case EOtherGroup: + buf.Copy(ClickOnMe); + break; + default: + break; + } + } + CPcWindowBase::Draw(buf); + } + +// + +CPcWindowAltConnection::CPcWindowAltConnection(CTPointerCapture *aTest) : CPcWindowBase(aTest) + { + iBack=TRgb::Gray256(236); + } + +TPointerCheckRet CPcWindowAltConnection::PointerDown() + { +#if defined(LOGGING) + _LIT(KLog1,"CPcWindowAltConnection::PointerDown State=%d SubState=%d"); + iTest->LOG_MESSAGE3(KLog1,iTest->State(),iTest->SubState()); +#endif + switch(iTest->State()) + { + case ECaptureDisabled: + if (iTest->SubState()==EChildWindow) + return(EOkay); + break; + case ENormalCapture: + case EDragDropCapture: + case ENormalCaptureWithoutFocus: + switch(iTest->SubState()) + { + case EOtherSession: + return(EOkay); + default: + break; + } + break; + default: + break; + } +#if defined(LOGGING) + _LIT(KLog2,"CPcWindowAltConnection::PointerDown FAILED State=%d SubState=%d"); + iTest->LOG_MESSAGE3(KLog2,iTest->State(),iTest->SubState()); +#endif + return(EFailed); + } + +TPointerCheckRet CPcWindowAltConnection::DragDrop() + { +#if defined(LOGGING) + _LIT(KLog1,"CPcWindowAltConnection::DragDrop State=%d SubState=%d"); + iTest->LOG_MESSAGE3(KLog1,iTest->State(),iTest->SubState()); +#endif + switch(iTest->State()) + { + case EDragDropCapture: + case EDragDropCaptureAllGroups: + switch(iTest->SubState()) + { + case EOtherSession: + return(EOkay); + default: + break; + } + break; + default: + break; + } +#if defined(LOGGING) + _LIT(KLog2,"CPcWindowAltConnection::DragDrop FAILED State=%d SubState=%d"); + iTest->LOG_MESSAGE3(KLog2,iTest->State(),iTest->SubState()); +#endif + return(EFailed); + } + +void CPcWindowAltConnection::Draw() + { + TBuf<0x40> buf; + if (iTest->State()!=ECaptureDisabled) + { + switch(iTest->SubState()) + { + case EOtherSession: + buf.Copy(ClickOnMe); + break; + default: + break; + } + } + CPcWindowBase::Draw(buf); + } + +// + +CTPointerCapture::CTPointerCapture(CTestStep* aStep) : CTWsGraphicsBase(aStep) + { + iSubState=0; + iFailed=EFalse; + } + +CTPointerCapture::~CTPointerCapture() + { + delete iNickFocusBlankWin; + delete iNickFocusGroup; + delete iAltConnectionWin; + delete iAltConnection; + delete iChildWin; + delete iMainWin; + delete iMainGroup; + delete iAltGroupWin; + delete iAltGroup; + } + +void CTPointerCapture::TestFailed() + { + if (iFailed) + { + _LIT(KLog,"Test Failed State=%d SubState=%d"); + LOG_MESSAGE3(KLog,iTest->iState,iSubState); + } + __ASSERT_DEBUG(iFailed==EFalse,AutoPanic(ETManPanicPcFailed)); + TInt dRet=1; +#if !defined(DISABLE_FAIL_DIALOG) + Client()->iGroup->GroupWin()->SetOrdinalPosition(0,10); // Put error dialog on top of test windows + TRAPD(err,dRet=doTestFailedL()); + Client()->iGroup->GroupWin()->SetOrdinalPosition(0,0); +#endif + switch(dRet) + { + case 0: + break; + case 1: + iFailed=ETrue; + NextTest(); + break; + } + } + +TInt CTPointerCapture::doTestFailedL() + { + CTDialog *dialog=new(ELeave) CTDialog(); + dialog->SetTitle(_L("Pointer capture test failed")); + dialog->SetNumButtons(2); + dialog->SetButtonText(0,_L("Retest")); + dialog->SetButtonText(1,_L("Fail")); + dialog->ConstructLD(*Client()->iGroup,*Client()->iGc); + return dialog->Display(); + } + +TInt CTPointerCapture::State() const + { + return(iTest->iState); + } + +TInt CTPointerCapture::SubState() const + { + return(iSubState); + } + +void CTPointerCapture::doIncSubStateL() + { + iSubState++; + TInt max=0; + switch(iTest->iState) + { + case ECaptureDisabled: + max=ESubStates1; + break; + case ENormalCapture: + max=ESubStates2; + break; + case ECaptureAllGroups: + max=ESubStates3; + break; + case EDragDropCapture: + max=ESubStates4; + break; + case EDragDropCaptureAllGroups: + max=ESubStates5; + break; + case ENormalCaptureWithoutFocus: + max=ESubStates6; + break; + } + //SubState 4 has been broken by something in the framework + if (iSubState==max || iSubState==4) + { + #if defined(LOGGING) + _LIT(KLog,"IncState OldState=%d SubState=%d"); + LOG_MESSAGE3(KLog,iTest->iState,iSubState); + #endif + NextTest(); + } + StateChanged(); + TheClient->WaitForRedrawsToFinish(); + if (iSubState>0) + SendEventsL(); + } + +void CTPointerCapture::GotDDL() + { + if (iDDState==DDStateWaiting) + doIncSubStateL(); + else + iDDState=DDStateGot; + } + +void CTPointerCapture::IncSubStateL(TBool aNeedsDD) + { + if (!aNeedsDD) + { + if (iDDState!=DDStateNull) + TestFailed(); + else + doIncSubStateL(); + } + else if (iDDState==DDStateGot) + doIncSubStateL(); + else + iDDState=DDStateWaiting; + } + +void CTPointerCapture::StateChanged() + { + iDDState=DDStateNull; + iChildWin->SubStateChanged(); + iMainWin->SubStateChanged(); + iAltGroupWin->SubStateChanged(); + iAltConnectionWin->SubStateChanged(); + } + +void CTPointerCapture::AbortTests() + { + iTest->iState=99; + } + +void CTPointerCapture::NextTest() + { + TEST(!iFailed); + if (iFailed) + { + _LIT(KLog,"SubTest %d failed"); + LOG_MESSAGE2(KLog,iTest->iState); + } + ++iTest->iState; + iSubState=0; + iFailed=EFalse; + CaseComplete(); + _LIT(KLog,"Done NextTest NewSubTest %d"); + LOG_MESSAGE2(KLog,iTest->iState); + } + +void CTPointerCapture::ConstructL() + { + TheClient->iWs.SetPointerCursorArea(iTest->iNormalPointerCursorArea); + iScreenSize=TSize(TheClient->iScreen->SizeInPixels()); + TInt winWidth2=iScreenSize.iWidth/2-EWinBorderSize*2; + TInt winWidth4=iScreenSize.iWidth/4-EWinBorderSize*2; + TInt winHeight=iScreenSize.iHeight/2-EWinBorderSize*2; +// + iMainGroup=new(ELeave) CTWindowGroup(Client()); + iMainGroup->ConstructL(); + iMainGroup->GroupWin()->SetOrdinalPosition(0,1); + iMainWin=new(ELeave) CPcWindowMain(this); + iMainWin->SetUpL(TPoint(EWinBorderSize,EWinBorderSize) ,TSize(winWidth2,winHeight) ,iMainGroup); + iMainGroup->SetCurrentWindow(iMainWin); + iChildWin=new(ELeave) CPcWindowChild(this); + iChildWin->SetUpL(TPoint(0,winHeight/2) ,TSize(winWidth2,winHeight/2) ,iMainWin); +// + iAltGroup=new(ELeave) CTWindowGroup(Client()); + iAltGroup->ConstructL(); + iAltGroup->GroupWin()->SetOrdinalPosition(0,1); + iAltGroup->GroupWin()->EnableReceiptOfFocus(EFalse); + iAltGroupWin=new(ELeave) CPcWindowAltGroup(this); + iAltGroupWin->SetUpL(TPoint(iScreenSize.iWidth/2+EWinBorderSize,EWinBorderSize) ,TSize(winWidth4,winHeight) ,iAltGroup); +// + iAltConnection=new(ELeave) CPcConnection(this); + iAltConnection->ConstructL(); + iAltConnectionWin=new(ELeave) CPcWindowAltConnection(this); + iAltConnectionWin->SetUpL(TPoint(iScreenSize.iWidth/4*3+EWinBorderSize,EWinBorderSize) ,TSize(winWidth4,winHeight),iAltConnection->iGroup,*iAltConnection->iGc); + iTest->DelayIfFullRomL(); + SetSelfDrive(ETrue); + } + +void CTPointerCapture::NickFocusL() + { + iNickFocusGroup=new(ELeave) CPcWindowNickFocusGroup(this,Client()); + iNickFocusGroup->ConstructL(); + iNickFocusGroup->GroupWin()->SetOrdinalPosition(0,2); + iNickFocusBlankWin=new(ELeave) CTBlankWindow(); + iNickFocusBlankWin->ConstructL(*iNickFocusGroup); + iNickFocusBlankWin->SetSize(TSize(1,1)); + iNickFocusBlankWin->Activate(); + } + +void CTPointerCapture::SetCapture(TInt aCaptureFlags) + { +#if defined(LOGGING) + _LIT(KLog,"Change Capture State=%d CaptureFlags=0x%x"); + LOG_MESSAGE3(KLog,iTest->iState,aCaptureFlags); +#endif + iMainWin->Win()->SetPointerCapture(aCaptureFlags); + } + +void CTPointerCapture::SendEventsL() + { +#if defined(LOGGING) + _LIT(KLog,"SendEvent State=%d SubState=%d"); + LOG_MESSAGE3(KLog,iTest->iState,iSubState); +#endif + switch (iSubState) + { + case 0: + iTest->SimulatePointerDownUp(iScreenSize.iWidth/4,iScreenSize.iHeight/8+EWinBorderSize/2); + break; + case 1: + if (iTest->iState>ECaptureDisabled) + { + iTest->SimulatePointerDownUp(iScreenSize.iWidth/4,3*iScreenSize.iHeight/8-EWinBorderSize/2); + break; + } + case 2: + iTest->SimulatePointerDownUp(5*iScreenSize.iWidth/8,iScreenSize.iHeight/4); + break; + case 3: + iTest->SimulatePointerDownUp(7*iScreenSize.iWidth/8,iScreenSize.iHeight/4); + break; + case 4: + if (iTest->IsFullRomL()) + iTest->SimulateKeyDownUp(EStdKeyEnter); + else + iTest->SimulatePointerDownUp(0,0); + if (iTest->iState==ENormalCaptureWithoutFocus) + { + iTest->SimulateKeyDownUp(EStdKeyEscape); + break; + } + break; + default: + TEST(EFalse); + } + TheClient->iWs.Flush(); + } + +void CTPointerCapture::RunTestCaseL(TInt /*aCurTestCase*/) + { + _LIT(TestNoCapture,"No capture"); + _LIT(TestNormalCapture,"Normal capture"); + _LIT(TestAllGroups,"All groups"); + _LIT(TestDragDrop,"Drag & Drop"); + _LIT(TestDragDropAllGroups,"Drag & Drop All groups"); + _LIT(TestWithoutFocus,"Without focus"); + StateChanged(); + + if (!TestBase()->ConfigurationSupportsPointerEventTesting()) + { + INFO_PRINTF1(_L("Test skipped because config does not support pointer event testing")); + TestComplete(); + return; + } + + ((CTPointerCaptureStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); + switch(iTest->iState) + { +/** + + @SYMTestCaseID GRAPHICS-WSERV-0290 + + @SYMDEF DEF081259 + + @SYMTestCaseDesc Test pointer capture can be disabled + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions Disable the pointer capture to the screen and simulate + capture with the pointer + + @SYMTestExpectedResults The pointer capture has been disabled + +*/ + case ECaptureDisabled: + ((CTPointerCaptureStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0290")); + if (TheClient->iScreen->GetScreenNumber()>0) + { + _LIT(KLog,"Cannot run this test on the 2nd screen - all pointer events goto the 1st screen"); + LOG_MESSAGE(KLog); + TestComplete(); + } + iTest->LogSubTest(TestNoCapture); + SetCapture(RWindowBase::TCaptureDisabled); + break; +/** + + @SYMTestCaseID GRAPHICS-WSERV-0291 + + @SYMDEF DEF081259 + + @SYMTestCaseDesc Test pointer capture can be enabled + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions Enable the pointer capture to the screen and simulate + capture with the pointer + + @SYMTestExpectedResults The pointer capture has been enabled and works + correctly + +*/ + case ENormalCapture: + ((CTPointerCaptureStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0291")); + iTest->LogSubTest(TestNormalCapture); + SetCapture(RWindowBase::TCaptureEnabled); + break; +/** + + @SYMTestCaseID GRAPHICS-WSERV-0292 + + @SYMDEF DEF081259 + + @SYMTestCaseDesc Test pointer capture can be enabled for + windows belonging to any group + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions Enable the pointer capture to all windows and simulate + capture with the pointer + + @SYMTestExpectedResults The pointer capture has been enabled and works + correctly + +*/ + case ECaptureAllGroups: + ((CTPointerCaptureStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0292")); + iTest->LogSubTest(TestAllGroups); + SetCapture(RWindowBase::TCaptureEnabled|RWindowBase::TCaptureFlagAllGroups); + break; +/** + + @SYMTestCaseID GRAPHICS-WSERV-0293 + + @SYMDEF DEF081259 + + @SYMTestCaseDesc Test drag and drop pointer capture can be enabled for + windows belonging to any group + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions Enable drag and drop pointer capture to all windows and simulate + capture with the pointer + + @SYMTestExpectedResults The pointer capture has been enabled and works + correctly + +*/ + case EDragDropCapture: + ((CTPointerCaptureStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0293")); + iTest->LogSubTest(TestDragDrop); + SetCapture(RWindowBase::TCaptureDragDrop&~RWindowBase::TCaptureFlagAllGroups); + break; +/** + + @SYMTestCaseID GRAPHICS-WSERV-0294 + + @SYMDEF DEF081259 + + @SYMTestCaseDesc Test drag and drop pointer capture can be enabled + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions Enable drag and drop pointer capture and simulate + capture with the pointer + + @SYMTestExpectedResults The pointer capture has been enabled and works + correctly + +*/ + case EDragDropCaptureAllGroups: + ((CTPointerCaptureStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0294")); + iTest->LogSubTest(TestDragDropAllGroups); + SetCapture(RWindowBase::TCaptureDragDrop); + break; +/** + + @SYMTestCaseID GRAPHICS-WSERV-0295 + + @SYMDEF DEF081259 + + @SYMTestCaseDesc Test pointer capture can be enabled + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions Enable the pointer capture to the screen and simulate capture + with the pointer when the screen does not have the focus + + @SYMTestExpectedResults The pointer capture has been enabled and works + correctly + +*/ + case ENormalCaptureWithoutFocus: + ((CTPointerCaptureStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0295")); + iTest->LogSubTest(TestWithoutFocus); + NickFocusL(); + SetCapture(RWindowBase::TCaptureEnabled); + break; + default: + ((CTPointerCaptureStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + ((CTPointerCaptureStep*)iStep)->CloseTMSGraphicsStep(); + TestComplete(); + return; + } + ((CTPointerCaptureStep*)iStep)->RecordTestResultL(); + SendEventsL(); + } + +__WS_CONSTRUCT_STEP__(PointerCapture) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TPNTCAP.H --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TPNTCAP.H Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,200 @@ + +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef __TPNTCAP_H__ +#define __TPNTCAP_H__ + +#include +#include +#include +#include "../tlib/testbase.h" +#include "AUTO.H" +#include "TGraphicsHarness.h" + +enum TTestState + { + ECaptureDisabled=0, + ENormalCapture, + ECaptureAllGroups, + EDragDropCapture, + EDragDropCaptureAllGroups, + ENormalCaptureWithoutFocus, + }; + +enum TTestSubState + { + EMainWindow, + EChildWindow, + EOtherGroup, + EOtherSession, + ERootWindow, + }; + +enum TPointerCheckRet + { + EFailed, + EOkay, + ENeedsDDEvent, + }; + +const TInt ESubStates1=2; +const TInt ESubStates2=5; +const TInt ESubStates3=5; +const TInt ESubStates4=5; +const TInt ESubStates5=5; +const TInt ESubStates6=5; + +const TInt EWinBorderSize=10; + +class CPcWindowBase; +class CTPointerCapture; + +class CPcConnection : public CTClient + { +public: + CPcConnection(CTPointerCapture *aTest); + ~CPcConnection(); + virtual void ConstructL(); +protected: + CTPointerCapture *iTest; + }; + +class CPcWindowBase : public CTWin + { +public: + CPcWindowBase(CTPointerCapture *aTest); + void SetUpL(TPoint pos,TSize size,CTWinBase *parent); + void SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc); + void Draw(TDesC &aBuf); + void PointerL(const TPointerEvent &pointer,const TTime &); + void DragDropL(const TPointerEvent &pointer,const TTime &); + virtual TPointerCheckRet PointerDown()=0; + virtual TPointerCheckRet DragDrop()=0; + virtual void SubStateChanged(); +protected: + CTPointerCapture *iTest; + TRgb iBack; + }; + +class CPcWindowChild : public CPcWindowBase + { +public: + CPcWindowChild(CTPointerCapture *aTest); + void Draw(); + TPointerCheckRet PointerDown(); + TPointerCheckRet DragDrop(); + }; + +class CPcWindowMain : public CPcWindowBase + { +public: + CPcWindowMain(CTPointerCapture *aTest); + void Draw(); + TPointerCheckRet PointerDown(); + TPointerCheckRet DragDrop(); + void WinKeyL(const TKeyEvent &aKey,const TTime &aTime); + }; + +class CPcWindowAltGroup : public CPcWindowBase + { +public: + CPcWindowAltGroup(CTPointerCapture *aTest); + void Draw(); + TPointerCheckRet PointerDown(); + TPointerCheckRet DragDrop(); + }; + +class CPcWindowNickFocusGroup : public CTWindowGroup + { +public: + CPcWindowNickFocusGroup(CTPointerCapture *aTest, CTClient *aClient); + void KeyL(const TKeyEvent &aKey,const TTime &aTime); +private: + CTPointerCapture *iTest; + }; + +class CPcWindowAltConnection : public CPcWindowBase + { +public: + CPcWindowAltConnection(CTPointerCapture *aTest); + void Draw(); + TPointerCheckRet PointerDown(); + TPointerCheckRet DragDrop(); + }; + +class CTPointerCapture : public CTWsGraphicsBase + { +private: + enum TDState {DDStateNull, DDStateGot, DDStateWaiting}; +public: + CTPointerCapture(CTestStep* aStep); + ~CTPointerCapture(); + void ConstructL(); + void NextTest(); + void AbortTests(); + TInt State() const; + TInt SubState() const; + void doIncSubStateL(); + void IncSubStateL(TBool aNeedsDD=EFalse); + void GotDDL(); + void StateChanged(); + void TestFailed(); + void NickFocusL(); + void SetCapture(TInt aCaptureFlags); + inline TestClient* Client() {return TheClient;} +protected: +//from CTGraphicsStep + virtual void RunTestCaseL(TInt aCurTestCase); +private: + TInt doTestFailedL(); + void SendEventsL(); +private: + CPcConnection *iAltConnection; + CTWindowGroup *iMainGroup; + CTWindowGroup *iAltGroup; + CPcWindowChild *iChildWin; + CPcWindowMain *iMainWin; + CPcWindowAltGroup *iAltGroupWin; + CPcWindowAltConnection *iAltConnectionWin; + CPcWindowNickFocusGroup *iNickFocusGroup; + CTBlankWindow *iNickFocusBlankWin; + //TInt iState; + TInt iSubState; + TDState iDDState; + TSize iScreenSize; +public: + TBool iFailed; + }; + +class CTPointerCaptureStep : public CTGraphicsStep + { +public: + CTPointerCaptureStep(); +protected: + //from CTGraphicsStep + virtual CTGraphicsBase* CreateTestL(); + }; + +_LIT(KTPointerCaptureStep,"TPointerCapture"); + + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TPNTKEY.H --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TPNTKEY.H Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,112 @@ + +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef __TPNTKEY_H__ +#define __TPNTKEY_H__ + +#include +#include +#include +#include "../tlib/testbase.h" +#include "AUTO.H" +#include "TGraphicsHarness.h" + +const TInt ENumPntKeyTests=6; +const TUint EModifierMask=EModifierCtrl|EModifierShift|EModifierFunc; + +class CTPntKey; + +class CTPntKeyWindow : public CTWin + { +private: + enum {KPointerMoveBufferSize=32}; +public: + CTPntKeyWindow(CTPntKey *aTest); + ~CTPntKeyWindow(); + void SetUpLD(TPoint pos,TSize size,CTWinBase *parent); + void PointerL(const TPointerEvent &pointer,const TTime &aTime); + void KeyUpL(const TKeyEvent &aKey,const TTime &); + void KeyDownL(const TKeyEvent &aKey,const TTime &); + void WinKeyL(const TKeyEvent &aKey,const TTime &); + void SwitchOn(const TTime &aTime); + void NextKey(); + void Test(TInt aCheck); + void Error(TInt aWhere); + void DrawButton(const TRect &aRect, const TDesC &aText); + void Draw(); + void SendEvent(); + void SimulatePointerDownUp(const TRect& aRect); + inline TInt KeyCount() {return iKeyCount;} +private: + TInt iKeyCount; + TRect iKey1; + TRect iKey2; + TRect iKey3; + static TInt iTestScanCodes[ENumPntKeyTests]; + static TUint iTestCodes[ENumPntKeyTests]; + static TUint iTestModifiers[ENumPntKeyTests]; + CTPntKey *iTest; + }; + +class CTPntKey : public CTWsGraphicsBase +{ +private: + enum {KTimeOutAfter=60000000}; //60secs + +public: + CTPntKey(CTestStep* aStep); + ~CTPntKey(); + void ConstructL(); + static TInt TimeOut(TAny* aTest); + void TimeOut(); + void Failed(TInt aWhere); + inline TBool NoDigitiser() const {return iNoDigitiser;} + +protected: //from CTGraphicsStep + virtual void RunTestCaseL(TInt aCurTestCase); + +private: + inline TestClient *Client() {return TheClient;} + +private: + CTimeOut* iTimeOut; + CTPntKeyWindow *iWin; + TSize iWinSize; + TInt iState; + TBool iFailed; + TBool iOldPointerState; + TBool iNoDigitiser; + }; + +class CTPntKeyStep : public CTGraphicsStep + { +public: + CTPntKeyStep(); +protected: + //from CTGraphicsStep + virtual CTGraphicsBase* CreateTestL(); + }; + +_LIT(KTPntKeyStep,"TPntKey"); + + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TPROCPRI.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TPROCPRI.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,194 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Test process priority control +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + + +#include "TPROCPRI.H" + +TName OtherGroupName; + +TInt ProcPriTestOtherProcess(TAny *aScreenNumber) + { + CTrapCleanup* CleanUpStack=CTrapCleanup::New(); + RWsSession ws; + User::LeaveIfError(ws.Connect()); + // use correct screen + // + CWsScreenDevice* screen = NULL; + TInt err; + TRAP(err, screen = new (ELeave) CWsScreenDevice(ws)); + if (err!=KErrNone) + return err; + if ((err=screen->Construct((TInt)aScreenNumber))!=KErrNone) + { + delete screen; + return err; + } + + RWindowGroup group(ws); + group.Construct(888); + group.SetName(OTHER_PROC_GROUP_NAME); + RSemaphore sem1; + RSemaphore sem2; + sem1.OpenGlobal(PROC_PRI_SEMAPHORE_NAME1); + sem2.OpenGlobal(PROC_PRI_SEMAPHORE_NAME2); + sem1.Signal(); // Signal thread fully initialised + sem2.Wait(); // Wait for command to disable focus +// + group.EnableReceiptOfFocus(EFalse); + ws.Flush(); + sem1.Signal(); // Signal focus disabled + sem2.Wait(); // Wait for command to enable focus + + group.EnableReceiptOfFocus(ETrue); + ws.Flush(); + sem1.Signal(); // Signal focus enabled + sem2.Wait(); // Wait until signalled to exit +// + group.EnableReceiptOfFocus(EFalse); // To stop shell being tasked into foreground + delete screen; + ws.Close(); + sem1.Close(); + sem2.Close(); + delete CleanUpStack; + return(KErrNone); + } + +CTProcPri::CTProcPri(CTestStep* aStep) : CTWsGraphicsBase(aStep) + { + } + +CTProcPri::~CTProcPri() + { + if (iFlags&ECreatedSem1) + iSem1.Close(); + if (iFlags&ECreatedSem2) + iSem2.Close(); + delete iProcess; + } + +void CTProcPri::TestPriChangeL() + { + #define BACK_PRI EPriorityForeground + #define FORE_PRI EPriorityForeground + RProcess proc; + TEST(proc.Priority()==BACK_PRI); + if (proc.Priority()!=BACK_PRI) + INFO_PRINTF3(_L("proc.Priority() return value - Expected: %d, Actual: %d"), BACK_PRI, proc.Priority()); + + iSem2.Signal(); + iSem1.Wait(); + + TEST(proc.Priority()==FORE_PRI); + if (proc.Priority()!=FORE_PRI) + INFO_PRINTF3(_L("proc.Priority() return value - Expected: %d, Actual: %d"), FORE_PRI, proc.Priority()); + + iSem2.Signal(); + iSem1.Wait(); + + TEST(proc.Priority()==BACK_PRI); + if (proc.Priority()!=BACK_PRI) + INFO_PRINTF3(_L("proc.Priority() return value - Expected: %d, Actual: %d"), BACK_PRI, proc.Priority()); + + TInt ident; + User::LeaveIfError(ident=TheClient->iWs.FindWindowGroupIdentifier(0,OTHER_PROC_GROUP_NAME,0)); + TInt retVal = TheClient->iWs.SetWindowGroupOrdinalPosition(ident,1); + TEST(retVal==KErrNone); + if (retVal!=KErrNone) + INFO_PRINTF3(_L("TheClient->iWs.SetWindowGroupOrdinalPosition(ident,1) return value - Expected: %d, Actual: %d"), KErrNone, retVal); + + TEST(proc.Priority()==FORE_PRI); + if (proc.Priority()!=FORE_PRI) + INFO_PRINTF3(_L("proc.Priority() return value - Expected: %d, Actual: %d"), FORE_PRI, proc.Priority()); + + retVal = TheClient->iWs.SetWindowGroupOrdinalPosition(ident,0); + TEST(retVal==KErrNone); + if (retVal!=KErrNone) + INFO_PRINTF3(_L("TheClient->iWs.SetWindowGroupOrdinalPosition(ident,0) return value - Expected: %d, Actual: %d"), KErrNone, retVal); + + TEST(proc.Priority()==BACK_PRI); + if (proc.Priority()!=BACK_PRI) + INFO_PRINTF3(_L("proc.Priority() return value - Expected: %d, Actual: %d"), BACK_PRI, proc.Priority()); + + TRequestStatus stat; + iProcess->Logon(stat); //Must Logon before the last Signal so we can be sure that it is still alive to get round a base issue + iSem2.Signal(); + User::WaitForRequest(stat); + + TEST(proc.Priority()==FORE_PRI); + if (proc.Priority()!=FORE_PRI) + INFO_PRINTF3(_L("proc.Priority() return value - Expected: %d, Actual: %d"), FORE_PRI, proc.Priority()); + + } + +void CTProcPri::ConstructL() + { + User::LeaveIfError(iSem1.CreateGlobal(PROC_PRI_SEMAPHORE_NAME1,0,KOwnerType)); + iFlags|=ECreatedSem1; + User::LeaveIfError(iSem2.CreateGlobal(PROC_PRI_SEMAPHORE_NAME2,0,KOwnerType)); + iFlags|=ECreatedSem2; + iProcess=CProcess::NewL(CProcess::eProcessPriortyTest,iTest->iScreenNumber); + iSem1.Wait(); + } + +void CTProcPri::RunTestCaseL(TInt /*aCurTestCase*/) + { + _LIT(KTest1,"Priority Change"); + ((CTProcPriStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); + + switch(++iTest->iState) + { +/** + + @SYMTestCaseID GRAPHICS-WSERV-0315 + + @SYMDEF DEF081259 + + @SYMTestCaseDesc Test that the priority of a process or thread changes depending + on how the the process or thread is being used + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions Create a process or thread and use it. Check the priority of the + process or thread changes depending on how it is being used + + @SYMTestExpectedResults Prioirty of the process of thread changes depending on + how it is being used + +*/ + case 1: + ((CTProcPriStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0315")); + iTest->LogSubTest(KTest1); + TestPriChangeL(); + break; + case 2: + ((CTProcPriStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + ((CTProcPriStep*)iStep)->CloseTMSGraphicsStep(); + TestComplete(); + break; + } + ((CTProcPriStep*)iStep)->RecordTestResultL(); + } + +__WS_CONSTRUCT_STEP__(ProcPri) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TPROCPRI.H --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TPROCPRI.H Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,72 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef __TPROCPRI_H__ +#define __TPROCPRI_H__ + +#include "AUTO.H" +#include "TGraphicsHarness.h" +#include "../tlib/testbase.h" +#include +#include + +#define OTHER_PROC_GROUP_NAME _L("OtherProcGroupWindow") +#define PROC_PRI_SEMAPHORE_NAME1 _L("abcerProcSem1") +#define PROC_PRI_SEMAPHORE_NAME2 _L("OtherProcSem2") + +class CTProcPri : public CTWsGraphicsBase + { +private: + enum + { + ECreatedSem1=0x0001, + ECreatedSem2=0x0002, + }; +public: + CTProcPri(CTestStep* aStep); + ~CTProcPri(); + void ConstructL(); + void TestPriChangeL(); +protected: +//from CTGraphicsStep + virtual void RunTestCaseL(TInt aCurTestCase); +private: + TSize iWinSize; + RSemaphore iSem1; + RSemaphore iSem2; + TUint iFlags; + CProcess* iProcess; + }; + + +class CTProcPriStep : public CTGraphicsStep + { +public: + CTProcPriStep(); +protected: + //from CTGraphicsStep + virtual CTGraphicsBase* CreateTestL(); + }; + +_LIT(KTProcPriStep,"TProcPri"); + + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TPntKey.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TPntKey.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,385 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Converted from TMan test code (TMPNTKEY.CPP) May 2001 +// Test Pointer move/drag buffer +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include "TPNTKEY.H" + +#define LOGGING on //Uncomment this line to get more logging + +TInt CTPntKeyWindow::iTestScanCodes[ENumPntKeyTests]={'A','B',0,'C',EStdKeyEnter,'Y'}; +TUint CTPntKeyWindow::iTestCodes[ENumPntKeyTests]={'a','B',0,'c',EKeyEnter,'y'}; +TUint CTPntKeyWindow::iTestModifiers[ENumPntKeyTests]={0,EModifierShift,0,0,0,0}; + +CTPntKeyWindow::CTPntKeyWindow(CTPntKey *aTest) : iTest(aTest) + {} + +CTPntKeyWindow::~CTPntKeyWindow() + { + } + +void CTPntKeyWindow::SetUpLD(TPoint pos,TSize size,CTWinBase *parent) + { + ConstructExtLD(*parent,pos,size); + iWin.SetPointerGrab(ETrue); + iKey1=TRect(size.iWidth*1/16,size.iHeight/2,size.iWidth*5/16,size.iHeight); + iKey2=TRect(size.iWidth*6/16,size.iHeight/2,size.iWidth*10/16,size.iHeight); + iKey3=TRect(size.iWidth*11/16,size.iHeight/2,size.iWidth*15/16,size.iHeight); + iWin.AddKeyRect(iKey1,'A',EFalse); + iWin.AddKeyRect(iKey2,'B',EFalse); + AssignGC(*Client()->iGc); + BaseWin()->EnableOnEvents(); + Activate(); + } + +void CTPntKeyWindow::Error(TInt aWhere) + { + iTest->Failed(aWhere); + } + +void CTPntKeyWindow::NextKey() + { + if (++iKeyCount!=ENumPntKeyTests) + { + #if defined(LOGGING) + _LIT(KLog,"Next Key KeyCount=%d"); + iTest->LOG_MESSAGE2(KLog,iKeyCount); + #endif + if (iKeyCount==2) + iWin.RemoveAllKeyRects(); + else if (iKeyCount==3) + iWin.AddKeyRect(iKey3,'C',EFalse); + else if (iKeyCount==4) + { + #if !defined(__WINS__) + if (iTest->NoDigitiser()) + { + return; + } + #endif + iWin.RemoveAllKeyRects(); + iWin.AddKeyRect(TRect(Client()->iScreen->SizeInPixels()),'Z',EFalse); + } + else if (iKeyCount==5) + { + iWin.RemoveAllKeyRects(); + Client()->iWs.Flush(); + User::After(500000); // Wait half a second + iWin.AddKeyRect(TRect(Client()->iScreen->SizeInPixels()),'Y',ETrue); + } + Invalidate(); + } + SendEvent(); + } + +void CTPntKeyWindow::SendEvent() + { + TheClient->WaitForRedrawsToFinish(); +#if defined(LOGGING) + _LIT(KLog,"SendEvent KeyCount=%d"); + iTest->LOG_MESSAGE2(KLog,iKeyCount); +#endif + switch(iKeyCount) + { + case 0: + SimulatePointerDownUp(iKey1); + break; + case 1: + iTest->TestBase()->SimulateKey(TRawEvent::EKeyDown,EStdKeyLeftShift); + SimulatePointerDownUp(iKey2); + iTest->TestBase()->SimulateKey(TRawEvent::EKeyUp,EStdKeyLeftShift); + break; + case 2: + case 5: + { + TPoint pos=Position(); + TSize size=Size(); + iTest->TestBase()->SimulatePointerDownUp(pos.iX+size.iWidth/2,pos.iY+size.iHeight/4); + } + break; + case 3: + SimulatePointerDownUp(iKey3); + break; + case 4: + iTest->TestBase()->SimulateKeyDownUp(EStdKeyEnter); + break; + } + } + +void CTPntKeyWindow::SimulatePointerDownUp(const TRect& aRect) + { + iTest->TestBase()->SimulatePointerDownUp((aRect.iTl.iX+aRect.iBr.iX)/2,(aRect.iTl.iY+aRect.iBr.iY)/2); + } + +void CTPntKeyWindow::Test(TInt aCheck) + { + if (!aCheck) + Error(3); + } + +void CTPntKeyWindow::KeyUpL(const TKeyEvent &aKey,const TTime&) + { + if (aKey.iScanCode==iTestScanCodes[iKeyCount]) + NextKey(); + } + +void CTPntKeyWindow::KeyDownL(const TKeyEvent &aKey,const TTime &) + { +#if defined(LOGGING) + _LIT(KLog,"KeyDownL ScanCode=%d '%c' (%d) KeyCount=%d"); + iTest->LOG_MESSAGE5(KLog,aKey.iScanCode,aKey.iScanCode,iTestScanCodes[iKeyCount],iKeyCount); +#endif + if (aKey.iScanCode!=EStdKeyLeftFunc && aKey.iScanCode!=EStdKeyRightFunc && + aKey.iScanCode!=EStdKeyLeftAlt && aKey.iScanCode!=EStdKeyRightAlt && + aKey.iScanCode!=EStdKeyLeftCtrl && aKey.iScanCode!=EStdKeyRightCtrl && + aKey.iScanCode!=EStdKeyLeftShift && aKey.iScanCode!=EStdKeyRightShift && + aKey.iScanCode!=EStdKeyOff && + aKey.iScanCode!=EStdKeyEscape) + Test(aKey.iScanCode==iTestScanCodes[iKeyCount]); + } + +void CTPntKeyWindow::WinKeyL(const TKeyEvent &aKey,const TTime &) + { + if (aKey.iCode!=EKeyEscape) + { +#if defined(LOGGING) + _LIT(KLog1,"WinKeyL1 ScanCode=%d (%d) Code=%d '%c' (%d)"); + _LIT(KLog2,"WinKeyL2 ScanCode=%d Modifiers=0x%x (0x%x) KeyCount=%d"); + iTest->LOG_MESSAGE6(KLog1,aKey.iScanCode,iTestScanCodes[iKeyCount],aKey.iCode,aKey.iCode,iTestCodes[iKeyCount]); + iTest->LOG_MESSAGE5(KLog2,aKey.iScanCode,aKey.iModifiers&EModifierMask,iTestModifiers[iKeyCount]&EModifierMask,iKeyCount); +#endif + Test(aKey.iScanCode==iTestScanCodes[iKeyCount]); + Test(aKey.iCode==iTestCodes[iKeyCount]); + Test((aKey.iModifiers&EModifierMask)==(iTestModifiers[iKeyCount]&EModifierMask)); + } + } + +void CTPntKeyWindow::SwitchOn(const TTime &) + { +#if defined(LOGGING) + _LIT(KLog,"SwitchOn KeyCount=%d"); + iTest->LOG_MESSAGE2(KLog,iKeyCount); +#endif + if (iKeyCount==4) + NextKey(); + else if (iKeyCount!=5) + Error(2); + } + +void CTPntKeyWindow::PointerL(const TPointerEvent &aPointer,const TTime &) + { +#if defined(LOGGING) + _LIT(KLog,"Pointer Event Type=%d Pos=(%d,%d) PPos=(%d,%d) KeyCount=%d"); + iTest->LOG_MESSAGE7(KLog,aPointer.iType,aPointer.iPosition.iX,aPointer.iPosition.iY + ,aPointer.iParentPosition.iX,aPointer.iParentPosition.iY,iKeyCount); +#endif + if (aPointer.iType==TPointerEvent::EButton1Down) + { + if (iKeyCount!=2) + Error(1); + else + NextKey(); + } + } + +void CTPntKeyWindow::DrawButton(const TRect &aRect, const TDesC &aText) + { + iGc->DrawRect(aRect); + iGc->DrawText(aText, TPoint((aRect.iBr.iX+aRect.iTl.iX)/2,(aRect.iBr.iY+aRect.iTl.iY)/2)); + } + +void CTPntKeyWindow::Draw() + { + iGc->SetBrushColor(TRgb::Gray4(0)); + iGc->SetPenColor(TRgb::Gray4(3)); + iGc->Clear(); + DrawButton(iKey1,_L("A")); + DrawButton(iKey2,_L("B")); + DrawButton(iKey3,_L("C")); + switch(iKeyCount) + { + case 0: + iGc->DrawText(_L("Click on 'A'"), TPoint(10,20)); + break; + case 1: + iGc->DrawText(_L("Shift-Click on 'B'"), TPoint(10,20)); + break; + case 2: + iGc->DrawText(_L("Click anywhere in this window"), TPoint(10,20)); + break; + case 3: + iGc->DrawText(_L("Click on 'C'"), TPoint(10,20)); + break; + case 4: +#if defined(__WINS__) // Can't emulate touching dig when switched off under WINS + iGc->DrawText(_L("Switch off and on (or press Enter)"), TPoint(10,20)); +#else + iGc->DrawText(_L("Switch off, then touch the screen to switch on"), TPoint(10,20)); +#endif + break; + case 5: +#if defined(__WINS__) // Can't emulate touching dig when switched off under WINS + iGc->DrawText(_L("Touch anywhere in the window"), TPoint(10,20)); +#else + iGc->DrawText(_L("Switch off and touch the screen to switch on again"), TPoint(10,20)); +#endif + break; + } + } + +CTPntKey::CTPntKey(CTestStep* aStep): + CTWsGraphicsBase(aStep) + { + } + +CTPntKey::~CTPntKey() + { + HAL::Set(HALData::EPenDisplayOn,iOldPointerState); + CTWin::Delete(iWin); + Client()->ResetFocus(); + delete iTimeOut; + } + +TInt CTPntKey::TimeOut(TAny* aTest) //static + { + static_cast(aTest)->TimeOut(); + return(KErrNone); + } + +void CTPntKey::TimeOut() + { + TLogMessageText buf; + _LIT(KPntKeyTimeOut,"TIMEOUT: Pointer Key, %d, %S"); + buf.AppendFormat(KPntKeyTimeOut,iState,&TestBase()->iSubTitle); + TheClient->LogMessage(buf); + Failed(4); + } + +void CTPntKey::Failed(TInt aWhere) + { + _LIT(KLog,"Failed at %d"); + LOG_MESSAGE2(KLog,aWhere); + if (!iFailed) + { + iFailed=ETrue; + Client()->iGroup->ClearCurrentWindow(); + } + } + +void CTPntKey::ConstructL() + { + TInt mods=TheClient->iWs.GetModifierState(); + if (mods&EModifierCapsLock) + iTest->SimulateKeyDownUp(EStdKeyCapsLock); + //Make sure all the keys we test are in the up state + iTest->SimulateKeyDownUp(EStdKeyLeftShift); + iTest->SimulateKeyDownUp(EStdKeyRightShift); + iTest->SimulateKeyDownUp(EStdKeyLeftFunc); + iTest->SimulateKeyDownUp(EStdKeyLeftCtrl); + iTest->SimulateKeyDownUp(EStdKeyRightCtrl); + mods=TheClient->iWs.GetModifierState(); + _LIT(KLog,"Initial Modifiers state 0x%x (ideally should be zero)"); + LOG_MESSAGE2(KLog,mods); + TheClient->iScreen->SetScreenMode(0); //May sure we are in the right screen size mode + TheClient->iScreen->SetAppScreenMode(0); + TheClient->iWs.SetPointerCursorArea(TestBase()->iNormalPointerCursorArea); + CTPntKeyWindow *win=new(ELeave) CTPntKeyWindow(this); + win->SetUpLD(TPoint(20,20),Client()->iScreen->SizeInPixels()-TSize(40,40),Client()->iGroup); + iWin=win; + Client()->iGroup->SetCurrentWindow(iWin); + iNoDigitiser=EFalse; + TInt err=HAL::Get(HALData::EPenDisplayOn,iOldPointerState); + if (err==KErrNotSupported) + { + iNoDigitiser=ETrue; + } + else if (err==KErrNone) + { + err=HAL::Set(HALData::EPenDisplayOn,ETrue); + if (err==KErrNotSupported) + iNoDigitiser=(!iOldPointerState); + } + else + { + TEST(EFalse); + } + TheClient->WaitForRedrawsToFinish(); //Make sure all pending events have been delt with (redraw events are lowest priority) + iTimeOut=new(ELeave) CTimeOut(); + iTimeOut->ConstructL(); + iTimeOut->Start(KTimeOutAfter,TCallBack(CTPntKey::TimeOut,this)); + } + +void CTPntKey::RunTestCaseL(TInt /*aCurTestCase*/) + { + _LIT(KTestName,"Key set 1"); + TEST(!iFailed); + if (iFailed) + { + _LIT(KLog,"Test Failed Substate=%d KeyCount=%d"); + LOG_MESSAGE3(KLog,iTest->iState,iWin->KeyCount()); + } + ((CTPntKeyStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); + switch(++iTest->iState) + { +/** +@SYMTestCaseID GRAPHICS-WSERV-0200 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test Pointer move/drag buffer + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Exercise the pointer move/drag buffer and check + that it functions correctly + +@SYMTestExpectedResults The buffer functions correctly +*/ + case 1: + ((CTPntKeyStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0200")); + iTest->LogSubTest(KTestName); + if (TestBase()->ConfigurationSupportsPointerEventTesting()) + { + iWin->SendEvent(); + TheClient->Flush(); + } + else + { + INFO_PRINTF1(_L("Test skipped because config does not support pointer event testing")); + } + break; + case 2: + ((CTPntKeyStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + ((CTPntKeyStep*)iStep)->CloseTMSGraphicsStep(); + if (TestBase()->ConfigurationSupportsPointerEventTesting()) + { + iTimeOut->Cancel(); + } + TestComplete(); + break; + } + ((CTPntKeyStep*)iStep)->RecordTestResultL(); + } + +__WS_CONSTRUCT_STEP__(PntKey) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TPointer.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TPointer.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,1087 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Test pointer event handling +// Coverted from TMan test code (TMPOINTR.CPP) October 2000 +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include "TPointer.H" + + +//#define LOGGING + +#if defined(LOGGING) + LOCAL_D TLogMessageText LogMessageText; +#endif + + +CPointerWindow::CPointerWindow(CTPointer *aTest) : CTWin(), iTest(aTest) + {} + +void CPointerWindow::SetState(TInt aState) + { +#if defined(LOGGING) + _LIT(KState,"CPointerWindow::SetState(%d) OldState=%d"); + LogMessageText.Format(KState,aState,iState); + TheClient->LogMessage(LogMessageText); +#endif + iState=aState; + iWin.Invalidate(); + switch(aState) + { + case KStateWaitingForTest1: + case KStateWaitingForTest2: + case KStateWaitingForTest3: + case KStateWaitingForTest4: + case KStateWaitingForTest5: + case KStateWaitingForTest6: + case KStateWaitingForTest8: + case KStateWaitingForTest7: + iRepeatRect=TRect(); + break; + case KStateTesting8: + iWin.Close(); + Client()->iWs.Flush(); + User::After(500000); + FinishedTests(); + break; + } + TheClient->WaitForRedrawsToFinish(); + SendEvent(); + } + +void CPointerWindow::ResetTest(TInt aState) + { + TInt newState=KStateFinished; + switch(aState) + { + case KStateTesting1: + newState=KStateWaitingForTest1; + break; + case KStateTesting2: + newState=KStateWaitingForTest2; + break; + case KStateTesting3: + newState=KStateWaitingForTest3; + break; + case KStateTesting4: + newState=KStateWaitingForTest4; + break; + case KStateTesting5: + newState=KStateWaitingForTest5; + break; + case KStateTesting6: + newState=KStateWaitingForTest6; + break; + case KStateTesting8: + newState=KStateWaitingForTest8; + break; + case KStateTesting7: + newState=KStateWaitingForTest7; + break; + } + TheClient->iWs.PurgePointerEvents(); + SetState(newState); + } + +void CPointerWindow::SetUpLD(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc) + { + ConstructExtLD(*parent,pos,size); + iTl=pos; + iSize=size; + Activate(); + AssignGC(aGc); + SetState(KStateWaitingForTest1); + BaseWin()->EnableOnEvents(); + } + +void CPointerWindow::Draw() + { + iGc->Clear(); + iGc->DrawRect(Size()); + iGc->DrawRect(iRepeatRect); + TBuf<0x80> buf; + TBuf<0x80> buf2; + switch(iState) + { + case KStateWaitingForTest1: + { + _LIT(Draw1,"Click anywhere in the window and hold the pointer steady"); + buf.Format(Draw1); + } + break; + case KStateTesting1: + { + _LIT(Draw2,"Hold pointer inside the box"); + buf.Format(Draw2); + } + break; + case KStateWaitingForTest2: + { + _LIT(Draw3,"Release the pointer then click in the window and hold the pointer steady"); + buf.Format(Draw3); + } + break; + case KStateTesting2: + { + _LIT(Draw4,"Drag the pointer outside the box"); + buf.Format(Draw4); + } + break; + case KStateWaitingForTest3: + { + _LIT(Draw5,"Release the pointer then click in the window and hold the pointer steady"); + buf.Format(Draw5); + } + break; + case KStateTesting3: + { + _LIT(Draw6,"Release the pointer"); + buf.Format(Draw6); + } + break; + case KStateWaitingForTest4: + { + _LIT(Draw7,"Click anywhere in the window and move the pointer slightly"); + buf.Format(Draw7); + } + break; + case KStateTesting4: + { + _LIT(Draw8,"Release the pointer"); + buf.Format(Draw8); + } + break; + case KStateWaitingForTest5: + { + _LIT(Draw9,"Click anywhere in the window and move the pointer slightly"); + buf.Format(Draw9); + } + break; + case KStateTesting5: + { + _LIT(Draw10,"Release the pointer"); + buf.Format(Draw10); + break; + } + case KStateWaitingForTest6: + { + _LIT(Draw11,"Click anywhere in the window"); + buf.Format(Draw11); + } + break; + case KStateTesting6: + { + _LIT(Draw12,"Move the pointer"); + buf.Format(Draw12); + } + break; + case KStateWaitingForTest8: + { + _LIT(Draw13,"Click anywhere in the window, and keep the pointer pressed"); + buf.Format(Draw13); + } + break; + case KStateTesting8: + buf.Format(KNullDesC); + break; + case KStateWaitingForTest7: + { + _LIT(Draw14,"Switch off and touch the center of the screen"); + buf.Format(Draw14); + } + break; + case KStateTesting7: + buf.Format(KNullDesC); + break; + } + switch(iState) + { + case KStateTesting1: + { + _LIT(Repeat2,"Repeat (%d/%d), interval=%d.%d"); + buf2.Format(Repeat2,iRepeatCount,KRepeatCount,iInterval.Int()/1000000,(iInterval.Int()%1000000)/100000); + } + break; + case KStateTesting2: + case KStateTesting3: + { + _LIT(Repeat1,"Repeat (%d), interval=%d.%d"); + buf2.Format(Repeat1,iRepeatCount,iInterval.Int()/1000000,(iInterval.Int()%1000000)/100000); + } + break; + } + iGc->DrawText(buf,TPoint(10,20)); + iGc->DrawText(buf2,TPoint(10,40)); + } + +void CPointerWindow::FinishedTests() + { + iState=KStateFinished; + } + +void CPointerWindow::StartNextRepeatTest() + { + iInterval=0; + iRepeatCount=0; + if (iState==KStateWaitingForTest4) + User::After(TTimeIntervalMicroSeconds32(1000000)); + else if (iState==KStateWaitingForTest5) + User::After(TTimeIntervalMicroSeconds32(1000000)); + QueueNextRepeat(); + switch(iState) + { + case KStateWaitingForTest1: + SetState(KStateTesting1); + break; + case KStateWaitingForTest2: + SetState(KStateTesting2); + break; + case KStateWaitingForTest3: + SetState(KStateTesting3); + break; + case KStateWaitingForTest4: + SetState(KStateTesting4); + break; + case KStateWaitingForTest5: + SetState(KStateTesting5); + break; + case KStateWaitingForTest6: + SetState(KStateTesting6); + break; + case KStateWaitingForTest8: + SetState(KStateTesting8); + break; + case KStateWaitingForTest7: + SetState(KStateTesting7); + break; + } + } + +void CPointerWindow::QueueNextRepeat() + { + iInterval=iInterval.Int()+KRepeatIntervalIncrements; +#if defined(LOGGING) + /*_LIT(KRequestRepeat,"Request Repeat, State=%d, Interval=%d"); + TLogMessageText buf; + buf.Format(KRequestRepeat,iState,iInterval.Int()); + TheClient->LogMessage(buf);*/ +#endif + iWin.RequestPointerRepeatEvent(TTimeIntervalMicroSeconds32(iInterval),TRect(iRepeatRect)); + iPrevTime.HomeTime(); + iWin.Invalidate(); + } + +void CPointerWindow::PointerL(const TPointerEvent &aPointer,const TTime &aTime) + { +#if defined(LOGGING) + _LIT(KPointer,"CPointerWindow::PointerL(Type=%d, Pos=(%d,%d), ParPos=(%d,%d), Mod=0x%x) State=%d"); + LogMessageText.Format(KPointer,aPointer.iType,aPointer.iPosition.iX,aPointer.iPosition.iY,aPointer.iParentPosition.iX,aPointer.iParentPosition.iY,aPointer.iModifiers,iState); + TheClient->LogMessage(LogMessageText); +#endif + if (aPointer.iType==TPointerEvent::EButtonRepeat) + { + if (iState!=KStateTesting1 && iState!=KStateTesting2 && iState!=KStateTesting3 && iState!=KStateTesting4) + TestFailed(); + else + { + TTimeIntervalMicroSeconds32 interval(I64LOW(aTime.MicroSecondsFrom(iPrevTime).Int64())); + TBool fail1=(interval.Int()<(iInterval.Int()-KRepeatMargin) || interval.Int()>(iInterval.Int()+KRepeatMargin)); + if (fail1) + { + _LIT(KPointerRepeat1,"Pointer Repeat Interval, Exp=%d, Act=%d, F1=%d, F2=%d"); + TLogMessageText buf; + TBool fail2=(interval.Int()<(iInterval.Int()-2*KRepeatMargin) || interval.Int()>(iInterval.Int()+3*KRepeatMargin)); + buf.Format(KPointerRepeat1,iInterval.Int(),interval.Int(),fail1,fail2); + TheClient->LogMessage(buf); + } + if (interval.Int()<(iInterval.Int()- + #if defined(__MARM_ARM4__) + 2* + #endif + KRepeatMargin) || interval.Int()>(iInterval.Int()+ + #if defined(__MARM_ARM4__) + 3* + #endif + KRepeatMargin)) + TestFailed(); + else + { + if (!iRepeatRect.Contains(aPointer.iPosition) || + aPointer.iParentPosition!=(aPointer.iPosition+iWin.InquireOffset(*Parent()->WinTreeNode()))) + TestFailed(); + else + { + iRepeatCount++; + if (iState==KStateTesting1 && iRepeatCount==KRepeatCount) + { + QueueNextRepeat(); + Client()->iWs.Flush(); + User::After(TTimeIntervalMicroSeconds32(iRepeatCount*KRepeatIntervalIncrements)); + iWin.CancelPointerRepeatEventRequest(); + SetState(KStateWaitingForTest2); + } + else + QueueNextRepeat(); + } + } + } + } + else switch(iState) + { + case KStateWaitingForTest1: + case KStateWaitingForTest2: + case KStateWaitingForTest3: + case KStateWaitingForTest4: + case KStateWaitingForTest8: + if (aPointer.iType==TPointerEvent::EButton1Down) + { + iRepeatRect.iTl=aPointer.iPosition-TPoint(KRepeatRectXExtra,KRepeatRectYExtra); + iRepeatRect.iBr=aPointer.iPosition+TPoint(KRepeatRectXExtra,KRepeatRectYExtra); + StartNextRepeatTest(); + } + break; + case KStateWaitingForTest5: + if (aPointer.iType==TPointerEvent::EButton1Down) + { + iRepeatRect.iTl=aPointer.iPosition; + iRepeatRect.iBr=aPointer.iPosition+TPoint(1,1); + StartNextRepeatTest(); + } + break; + case KStateWaitingForTest6: + if (aPointer.iType==TPointerEvent::EButton1Down) + { + iRepeatRect.iTl=aPointer.iPosition+TPoint(KRepeatRectXExtra,KRepeatRectYExtra); + iRepeatRect.iBr=aPointer.iPosition+TPoint(2*KRepeatRectXExtra,2*KRepeatRectYExtra); + StartNextRepeatTest(); + } + break; + case KStateTesting1: + { + TBool isDrag=(aPointer.iType==TPointerEvent::EDrag); + TestFailed(isDrag); + if (isDrag) + { + iTest->SimulatePointer(TRawEvent::EButton1Down,aPointer.iPosition.iX,aPointer.iPosition.iY); + iTest->SimulatePointer(TRawEvent::EButton1Up,aPointer.iPosition.iX,aPointer.iPosition.iY); + } + } + break; + case KStateTesting2: + if (aPointer.iType==TPointerEvent::EDrag) + SetState(KStateWaitingForTest3); + else + TestFailed(); + break; + case KStateTesting3: + if (aPointer.iType==TPointerEvent::EButton1Up) + SetState(KStateWaitingForTest4); + else + TestFailed(); + break; + case KStateTesting4: + if (aPointer.iType==TPointerEvent::EButton1Up) + SetState(KStateWaitingForTest5); + else + TestFailed(); + break; + case KStateTesting5: + if (aPointer.iType==TPointerEvent::EButton1Up) + SetState(KStateWaitingForTest6); + else if (aPointer.iType!=TPointerEvent::EDrag) + TestFailed(); + break; + case KStateTesting6: + if (aPointer.iType==TPointerEvent::EDrag) + { + //#if !defined(__WINS__) // Can't emulate touching dig when switched off under WINS + // if (iTest->Digitiser()) + SetState(KStateWaitingForTest7); + /* else + #endif + SetState(KStateWaitingForTest8);*/ + } + else + TestFailed(); + break; + case KStateWaitingForTest7: + if (aPointer.iType==TPointerEvent::EButton1Down || aPointer.iType==TPointerEvent::ESwitchOn) + TestFailed(); + break; + case KStateTesting7: + if (aPointer.iType!=TPointerEvent::ESwitchOn) + TestFailed(); + else + SetState(KStateWaitingForTest8); + break; + case KStateTesting8: + break; + } + } + +void CPointerWindow::TestFailed(TBool aRetest/*=EFalse*/) + { + if (iState!=KStateFailed) + { + TInt oldState=iState; + iState=KStateFailed; + if (iTest->TestFailed(oldState,aRetest) || aRetest) + ResetTest(oldState); + } + } + +void CPointerWindow::WinKeyL(const TKeyEvent &aKey,const TTime &) + { +#if defined(LOGGING) + _LIT(KKey,"CPointerWindow::WinKeyL(Code=%d, ScanCode=%d) State=%d"); + LogMessageText.Format(KKey,aKey.iCode,aKey.iScanCode,iState); + TheClient->LogMessage(LogMessageText); +#endif + if (aKey.iCode==EKeyEscape) + FinishedTests(); // Simply skip this test if the Escape key is pressed + } + +void CPointerWindow::SwitchOn(const TTime &) + { +#if defined(LOGGING) + _LIT(KOn,"CPointerWindow::SwitchOn() State=%d"); + LogMessageText.Format(KOn,iState); + TheClient->LogMessage(LogMessageText); +#endif + if (iState==KStateWaitingForTest7) + SetState(KStateTesting7); + else + TestFailed(); + } + +void CPointerWindow::SendEvent() + { +#if defined(LOGGING) + _LIT(KSend,"CPointerWindow::SendEvent() State=%d"); + LogMessageText.Format(KSend,iState); + TheClient->LogMessage(LogMessageText); +#endif + switch (iState) + { + case KStateWaitingForTest1: + iTest->SimulatePointer(TRawEvent::EButton1Down,iTl.iX+iSize.iWidth/4,iTl.iY+iSize.iHeight/4); + break; + //case KStateTesting1: //Do Nothing + // break; + case KStateWaitingForTest2: + iTest->SimulatePointer(TRawEvent::EButton1Up,iTl.iX+iSize.iWidth/4,iTl.iY+iSize.iHeight/4); + iTest->SimulatePointer(TRawEvent::EButton1Down,iTl.iX+iSize.iWidth/2,iTl.iY+iSize.iHeight/4); + break; + case KStateTesting2: + iTest->SimulatePointer(TRawEvent::EPointerMove,iTl.iX+5*iSize.iWidth/8,iTl.iY+iSize.iHeight/4+2); + iTest->SimulatePointer(TRawEvent::EPointerMove,iTl.iX+3*iSize.iWidth/4,iTl.iY+iSize.iHeight/4+4); + break; + case KStateWaitingForTest3: + iTest->SimulatePointer(TRawEvent::EButton1Up,iTl.iX+3*iSize.iWidth/4,iTl.iY+iSize.iHeight/4+4); + iTest->SimulatePointer(TRawEvent::EButton1Down,iTl.iX+iSize.iWidth/4,iTl.iY+iSize.iHeight/2); + break; + case KStateTesting3: + iTest->SimulatePointer(TRawEvent::EButton1Up,iTl.iX+iSize.iWidth/4,iTl.iY+iSize.iHeight/2); + break; + case KStateWaitingForTest4: + iTest->SimulatePointer(TRawEvent::EButton1Down,iTl.iX+iSize.iWidth/2,iTl.iY+iSize.iHeight/2); + iTest->SimulatePointer(TRawEvent::EPointerMove,iTl.iX+iSize.iWidth/2+3,iTl.iY+iSize.iHeight/2+1); + iTest->SimulatePointer(TRawEvent::EPointerMove,iTl.iX+iSize.iWidth/2+6,iTl.iY+iSize.iHeight/2+2); + iTest->SimulatePointer(TRawEvent::EPointerMove,iTl.iX+iSize.iWidth/2+9,iTl.iY+iSize.iHeight/2+3); + iTest->SimulatePointer(TRawEvent::EPointerMove,iTl.iX+iSize.iWidth/2+12,iTl.iY+iSize.iHeight/2+4); + break; + case KStateTesting4: + iTest->SimulatePointer(TRawEvent::EButton1Up,iTl.iX+iSize.iWidth/2+12,iTl.iY+iSize.iHeight/2+4); + break; + case KStateWaitingForTest5: + iTest->SimulatePointer(TRawEvent::EButton1Down,iTl.iX+iSize.iWidth/2,iTl.iY+3*iSize.iHeight/4); + iTest->SimulatePointer(TRawEvent::EPointerMove,iTl.iX+iSize.iWidth/2+3,iTl.iY+3*iSize.iHeight/4+1); + iTest->SimulatePointer(TRawEvent::EPointerMove,iTl.iX+iSize.iWidth/2+6,iTl.iY+3*iSize.iHeight/4+2); + iTest->SimulatePointer(TRawEvent::EPointerMove,iTl.iX+iSize.iWidth/2+9,iTl.iY+3*iSize.iHeight/4+3); + iTest->SimulatePointer(TRawEvent::EPointerMove,iTl.iX+iSize.iWidth/2+12,iTl.iY+3*iSize.iHeight/4+4); + break; + case KStateTesting5: + iTest->SimulatePointer(TRawEvent::EButton1Up,iTl.iX+iSize.iWidth/2+12,iTl.iY+3*iSize.iHeight/4+4); + break; + case KStateWaitingForTest6: + iTest->SimulatePointer(TRawEvent::EButton1Down,iTl.iX+3*iSize.iWidth/4,iTl.iY+3*iSize.iHeight/4); + break; + case KStateTesting6: + iTest->SimulatePointer(TRawEvent::EPointerMove,iTl.iX+3*iSize.iWidth/4+4,iTl.iY+3*iSize.iHeight/4+2); + iTest->SimulatePointer(TRawEvent::EPointerMove,iTl.iX+3*iSize.iWidth/4+8,iTl.iY+3*iSize.iHeight/4+4); + iTest->SimulatePointer(TRawEvent::EPointerMove,iTl.iX+3*iSize.iWidth/4+12,iTl.iY+3*iSize.iHeight/4+6); + iTest->SimulatePointer(TRawEvent::EPointerMove,iTl.iX+3*iSize.iWidth/4+16,iTl.iY+3*iSize.iHeight/4+8); + break; + case KStateWaitingForTest8: + iTest->SimulatePointer(TRawEvent::EButton1Down,iTl.iX+iSize.iWidth/2,iTl.iY+3*iSize.iHeight/4); + break; + case KStateTesting8: + break; + case KStateWaitingForTest7: + iTest->SimulatePointer(TRawEvent::EButton1Up,iTl.iX+3*iSize.iWidth/4+16,iTl.iY+3*iSize.iHeight/4+8); + iTest->SimulateEvent(TRawEvent::ESwitchOn); + iTest->SimulatePointer(TRawEvent::EPointerSwitchOn,iTl.iX+iSize.iWidth/2-1,iTl.iY+iSize.iHeight/2-1); + break; + //case KStateTesting7: //Do Nothing + // break; + /*case KStateFailed: + break; + case KStateFinished: + break;*/ + } + } + +// +// CGrabWindow // +// + +CGrabWindow::CGrabWindow(CTPointer *aTest) : iTest(aTest) + { + } + +void CGrabWindow::SetUpLD(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc) + { + ConstructExtLD(*parent,pos,size); + iTl=pos; + iSize=size; + Activate(); + AssignGC(aGc); + SetState(KGrabStateWaitingForDown); + } + +void CGrabWindow::Draw() + { + iGc->Clear(); + iGc->DrawRect(Size()); + TBuf<0x80> buf; + switch(iState) + { + case KGrabStateWaitingForDown: + case KGrabStateWaitingForDown2: + case KGrabStateWaitingForDown5: + { + _LIT(Draw1,"Press the pointer inside the window"); + buf.Copy(Draw1); + } + break; + case KGrabStateWaitingForDown3: + case KGrabStateWaitingForUp3a: + { + _LIT(Draw2,"Press and release the pointer inside the window"); + buf.Copy(Draw2); + } + break; + case KGrabStateWaitingForDragOut: + { + _LIT(Draw3,"Drag the pointer outside into the outside window"); + buf.Copy(Draw3); + } + break; + case KGrabStateWaitingForUp: + case KGrabStateWaitingForUp2b: + case KGrabStateWaitingForUp5: + { + _LIT(Draw4,"Release the pointer"); + buf.Copy(Draw4); + } + break; + case KGrabStateWaitingForDown4: + { + _LIT(Draw5,"Press then release the pointer"); + buf.Copy(Draw5); + } + break; + default:; + } + iGc->DrawText(buf,TPoint(10,20)); + } + +void CGrabWindow::PointerL(const TPointerEvent &aPointer,const TTime&) + { +#if defined(LOGGING) + _LIT(KPointer,"CGrabWindow::PointerL(Type=%d, Pos=(%d,%d), ParPos=(%d,%d), Mod=0x%x) State=%d"); + LogMessageText.Format(KPointer,aPointer.iType,aPointer.iPosition.iX,aPointer.iPosition.iY,aPointer.iParentPosition.iX,aPointer.iParentPosition.iY,aPointer.iModifiers,iState); + TheClient->LogMessage(LogMessageText); +#endif + switch(iState) + { + case KGrabStateWaitingForDown: + if (aPointer.iType==TPointerEvent::EButton1Down) + SetState(KGrabStateWaitingForDragOut); + break; + case KGrabStateWaitingForDragOut: + if (aPointer.iType!=TPointerEvent::EDrag) + TestFailed(); + else + { + if (!TRect(Size()).Contains(aPointer.iPosition)) + SetState(KGrabStateWaitingForUp); + } + break; + case KGrabStateWaitingForUp: + if (aPointer.iType==TPointerEvent::EDrag) + break; + if (aPointer.iType==TPointerEvent::EButton1Up) + SetState(KGrabStateWaitingForDown2); + else + TestFailed(); + break; + case KGrabStateWaitingForDown2: + if (aPointer.iType!=TPointerEvent::EButton1Down) + TestFailed(); + else + { + iTest->GrabWin2()->BaseWin()->ClaimPointerGrab(); + iTest->GrabWin2()->BaseWin()->ClaimPointerGrab(); // Call twice to check it's harmless + SetState(KGrabStateWaitingForUp2a); + } + break; + case KGrabStateWaitingForUp2a: + SetState(KGrabStateWaitingForDrag2); + break; + case KGrabStateWaitingForDrag2: + break; + case KGrabStateWaitingForUp2b: + TestFailed(); + break; + case KGrabStateWaitingForDown3: + if (aPointer.iType!=TPointerEvent::EButton1Down) + TestFailed(); + else + SetState(KGrabStateWaitingForUp3a); + break; + case KGrabStateWaitingForUp3a: + if (aPointer.iType==TPointerEvent::EButton1Up) + { + iTest->GrabWin2()->BaseWin()->ClaimPointerGrab(); + SetState(KGrabStateWaitingForUp3b); + } + break; + case KGrabStateWaitingForUp3b: + TestFailed(); + break; + case KGrabStateWaitingForDown5: + if (aPointer.iType!=TPointerEvent::EButton1Down) + TestFailed(); + else + { + iTest->GrabWin2()->BaseWin()->ClaimPointerGrab(EFalse); + SetState(KGrabStateWaitingForDrag5); + } + break; + case KGrabStateWaitingForDrag5: + if (aPointer.iType==TPointerEvent::EButton1Up) + TestFailed(); + break; + case KGrabStateWaitingForUp5: + TestFailed(); + break; + case KGrabStateWaitingForDown4: + iWin.Close(); // Close the window with the grab captured in it + SetState(KGrabStateWaitingForUp4); + break; + case KGrabStateFinished: + break; + } + } + +void CGrabWindow::ResetTest() + { + TheClient->iWs.PurgePointerEvents(); + SetState(KGrabStateWaitingForDown); + } + +void CGrabWindow::Pointer2(const TPointerEvent &aPointer) + { + switch(iState) + { + case KGrabStateWaitingForDrag2: + { + if (aPointer.iType==TPointerEvent::EDrag) + { + SetState(KGrabStateWaitingForUp2b); + } + else + { + if (iTest->TestFailed(iState)) + ResetTest(); + } + break; + } + case KGrabStateWaitingForUp2b: + if (aPointer.iType==TPointerEvent::EDrag) // Harmless + break; + if (aPointer.iType==TPointerEvent::EButton1Up) + SetState(KGrabStateWaitingForDown3); + else + TestFailed(); + break; + case KGrabStateWaitingForUp3b: + if (aPointer.iType==TPointerEvent::EButton1Up) + SetState(KGrabStateWaitingForDown5); + else + TestFailed(); + break; + case KGrabStateWaitingForUp4: + FinishedTests(); + break; + case KGrabStateWaitingForDrag5: + { + if (aPointer.iType==TPointerEvent::EDrag) + SetState(KGrabStateWaitingForUp5); + else if (iTest->TestFailed(iState)) + ResetTest(); + break; + } + case KGrabStateWaitingForUp5: + if (aPointer.iType==TPointerEvent::EDrag) // Harmless + break; + if (aPointer.iType==TPointerEvent::EButton1Up) + SetState(KGrabStateWaitingForDown4); + else + TestFailed(); + break; + default:; + } + } + +void CGrabWindow::SetState(TInt aState) + { + iState=aState; + if (aState!=KGrabStateWaitingForUp4) + iWin.Invalidate(); + TheClient->WaitForRedrawsToFinish(); + SendEvent(); + } + +void CGrabWindow::TestFailed() + { +#if defined(LOGGING) + _LIT(KFail,"CGrabWindow::TestFailed() State=%d"); + LogMessageText.Format(KFail,iState); + TheClient->LogMessage(LogMessageText); +#endif + if (iState!=KStateFailed) + { + TInt oldState=iState; + iState=KStateFailed; + if (iTest->TestFailed(oldState)) + ResetTest(); + } + } + +void CGrabWindow::FinishedTests() + { + iState=KGrabStateFinished; + } + +void CGrabWindow::WinKeyL(const TKeyEvent &aKey,const TTime &) + { +#if defined(LOGGING) + _LIT(KKey,"CGrabWindow::WinKeyL(Code=%d, ScanCode=%d) State=%d"); + LogMessageText.Format(KKey,aKey.iCode,aKey.iScanCode,iState); + TheClient->LogMessage(LogMessageText); +#endif + if (aKey.iCode==EKeyEscape) + FinishedTests(); // Simply skip this test if the Escape key is pressed + } + +void CGrabWindow::SendEvent() + { + switch (iState) + { + case KGrabStateWaitingForDown: + iTest->SimulatePointer(TRawEvent::EButton1Down,iTl.iX+iSize.iWidth/3,iTl.iY+iSize.iHeight/3); + break; + case KGrabStateWaitingForDragOut: + iTest->SimulatePointer(TRawEvent::EPointerMove,iTl.iX+iSize.iWidth/6,iTl.iY+iSize.iHeight/6); + iTest->SimulatePointer(TRawEvent::EPointerMove,iTl.iX+1,iTl.iY+1); + iTest->SimulatePointer(TRawEvent::EPointerMove,iTl.iX-10,iTl.iY-10); + break; + case KGrabStateWaitingForUp: + iTest->SimulatePointer(TRawEvent::EPointerMove,iTl.iX-8,iTl.iY-8); + iTest->SimulatePointer(TRawEvent::EButton1Up,iTl.iX-5,iTl.iY-5); + break; + case KGrabStateWaitingForDown2: + iTest->SimulatePointer(TRawEvent::EButton1Down,iTl.iX+2*iSize.iWidth/3,iTl.iY+iSize.iHeight/3); + break; + /*case KGrabStateWaitingForUp2a: //Don't need to do anything for these cases + break; + case KGrabStateWaitingForDrag2: + break;*/ + case KGrabStateWaitingForUp2b: + iTest->SimulatePointer(TRawEvent::EPointerMove,iTl.iX+2*iSize.iWidth/3-3,iTl.iY+iSize.iHeight/3+3); + iTest->SimulatePointer(TRawEvent::EButton1Up,iTl.iX+2*iSize.iWidth/3,iTl.iY+iSize.iHeight/3); + break; + case KGrabStateWaitingForDown3: + iTest->SimulatePointer(TRawEvent::EButton1Down,iTl.iX+2*iSize.iWidth/3,2*iTl.iY+iSize.iHeight/3); + break; + case KGrabStateWaitingForUp3a: + iTest->SimulatePointer(TRawEvent::EButton1Up,iTl.iX+2*iSize.iWidth/3,2*iTl.iY+iSize.iHeight/3); + break; + case KGrabStateWaitingForUp3b: + break; + case KGrabStateWaitingForDown4: + iTest->SimulatePointer(TRawEvent::EButton1Down,iTl.iX+2*iSize.iWidth/5,iTl.iY+iSize.iHeight/3); + break; + case KGrabStateWaitingForUp4: + iTest->SimulatePointer(TRawEvent::EButton1Up,iTl.iX+2*iSize.iWidth/5,iTl.iY+iSize.iHeight/3); + break; + case KGrabStateWaitingForDown5: + iTest->SimulatePointer(TRawEvent::EButton1Down,iTl.iX+iSize.iWidth/3,2*iTl.iY+iSize.iHeight/3); + break; + case KGrabStateWaitingForUp5: + iTest->SimulatePointer(TRawEvent::EButton1Up,iTl.iX+iSize.iWidth/3,2*iTl.iY+iSize.iHeight/3); + break; + //case KGrabStateWaitingForDrag5: //Don't need to do anything for these cases + // break; + /*case KStateFailed: + break; + case KGrabStateFinished: + break;*/ + default:; + } + TheClient->iWs.Flush(); + } + + +// +// CGrabWindow2, used as part of grab tests // +// + +CGrabWindow2::CGrabWindow2(CGrabWindow *aWindow) : iGrabWindow(aWindow) + { + } + +void CGrabWindow2::Draw() + { + iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + iGc->SetBrushColor(TRgb::Gray4(2)); + iGc->DrawRect(Size()); + } + +void CGrabWindow2::PointerL(const TPointerEvent &aPointer,const TTime&) + { +#if defined(LOGGING) + _LIT(KPointer,"CGrabWindow2::PointerL(Type=%d, Pos=(%d,%d), ParPos=(%d,%d), Mod=0x%x)"); + LogMessageText.Format(KPointer,aPointer.iType,aPointer.iPosition.iX,aPointer.iPosition.iY,aPointer.iParentPosition.iX,aPointer.iParentPosition.iY,aPointer.iModifiers); + TheClient->LogMessage(LogMessageText); +#endif + iGrabWindow->Pointer2(aPointer); + } + +// +// CTPointTest // +// + +CTPointer::CTPointer(CTestStep* aStep) : CTWsGraphicsBase(aStep) + { + iState = 0; + } + + +CTPointer::~CTPointer() + { + HAL::Set(HALData::EPenDisplayOn,iOldPointerState); + delete iRepeatWin; + delete iGrabWin; + delete iGrabWin2; + Client()->ResetFocus(); + delete iTimeOut; + } + +void CTPointer::ConstructL() + { + iTimeOut=new(ELeave) CTimeOut(); + iTimeOut->ConstructL(); + iTimeOut->Start(KTimeOutAfter,TCallBack(CTPointer::TimeOut,this)); + + TheClient->iWs.SetPointerCursorArea(iTest->iNormalPointerCursorArea); + iRepeatWin=new(ELeave) CPointerWindow(this); + TSize screenSize(Client()->iScreen->SizeInPixels()); + if (TestBase()->ConfigurationSupportsPointerEventTesting()) + { + iRepeatWin->SetUpLD(TPoint(screenSize.iWidth/8,screenSize.iHeight/8),TSize(screenSize.iWidth*3/4,screenSize.iHeight*3/4),Client()->iGroup,*Client()->iGc); + } + Client()->iGroup->SetCurrentWindow(iRepeatWin); + iNoDigitiser=EFalse; + TInt err=HAL::Get(HALData::EPenDisplayOn,iOldPointerState); + if (err==KErrNotSupported) + iNoDigitiser=ETrue; + else if (err==KErrNone) + err=HAL::Set(HALData::EPenDisplayOn,ETrue); + if (err==KErrNotSupported) + iNoDigitiser=(!iOldPointerState); + else + { + TEST(err==KErrNone); + if (err!=KErrNone) + INFO_PRINTF3(_L("HAL::Set(HALData::EPenDisplayOn,ETrue) return value - Expected: %d, Actual: %d"), KErrNone, err); + } + + } + +TInt CTPointer::TimeOut(TAny* aTest) //static + { + static_cast(aTest)->TimeOut(); + return(KErrNone); + } + +void CTPointer::TimeOut() + { + TLogMessageText buf; + _LIT(KPointerTimeOut,"TIMEOUT: Pointer Test, %d, %S"); + buf.AppendFormat(KPointerTimeOut,iState,&(iTest->iSubTitle)); + TheClient->LogMessage(buf); + ++iTimeOutCount; + if (!TestFailed(-1) && iState<2) + { + iTimeOut->Start(KTimeOutAfter,TCallBack(CTPointer::TimeOut,this)); + } + } + +TBool CTPointer::TestFailed(TInt aCase,TBool aRetry/*=EFalse*/) + { + _LIT(KPointerTest,": Pointer Test, %d, %S, Case %d"); + _LIT(KRetry,"Retry"); + _LIT(KFail,"FAIL"); + TLogMessageText buf; + TInt ret=0; + if (aRetry) + buf.Append(KRetry); + else + { + ret=1; + buf.Append(KFail); + } + buf.AppendFormat(KPointerTest,iState,&(iTest->iSubTitle),aCase); + TheClient->LogMessage(buf); +#if !defined(DISABLE_FAIL_DIALOG) + if (!aRetry) + { + __DEBUGGER(); + TRAPD(err,ret=doTestFailedL()); + } +#endif + switch(ret) + { + case 0: + return(ETrue); // Re-try test + case 1: + break; + } + return(EFalse); + } + +TInt CTPointer::doTestFailedL() + { + //_LIT(Failed,"Pointer repeat test failed"); + _LIT(Retest,"Retest"); + _LIT(Fail,"Fail"); + CTDialog *dialog=new(ELeave) CTDialog(); + dialog->SetNumButtons(2); + dialog->SetButtonText(0,Retest); + dialog->SetButtonText(1,Fail); + dialog->ConstructLD(*Client()->iGroup,*Client()->iGc); + dialog->SetTitle(_L("Pointer repeat test failed")); + dialog->SetFlags(CTDialog::EDialogWaitForButtonUp); + return dialog->Display(); + } + +CGrabWindow2 *CTPointer::GrabWin2() const + { + return(iGrabWin2); + } + +void CTPointer::StartGrabTestL() + { + iGrabWin=new(ELeave) CGrabWindow(this); + iGrabWin2=new(ELeave) CGrabWindow2(iGrabWin); +// + TSize screenSize(Client()->iScreen->SizeInPixels()); + iGrabWin2->SetUpL(TPoint(screenSize.iWidth/8,screenSize.iHeight/8),TSize(screenSize.iWidth*3/4,screenSize.iHeight*3/4),Client()->iGroup,*Client()->iGc); + Client()->iGroup->SetCurrentWindow(iGrabWin2); +// + iGrabWin->SetUpLD(TPoint(screenSize.iWidth/4,screenSize.iHeight/4),TSize(screenSize.iWidth/2,screenSize.iHeight/2),Client()->iGroup,*Client()->iGc); + Client()->iGroup->SetCurrentWindow(iGrabWin); +// + } + + +void CTPointer::RunTestCaseL(TInt /*aCurTestCase*/) + { + _LIT(Repeat,"Repeat tests"); + _LIT(Grab,"Grab tests"); + + iTest->iState=iState; + + if (!TestBase()->ConfigurationSupportsPointerEventTesting()) + { + INFO_PRINTF1(_L("Test skipped because config does not support pointer event testing")); + TestComplete(); + return; + } + + ((CTPointerStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); + switch(iState) + { + case 0: + ((CTPointerStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + iTest->LogSubTest(Repeat); + iState++; + break; +/** + + @SYMTestCaseID GRAPHICS-WSERV-0310 + + @SYMDEF DEF081259 + + @SYMTestCaseDesc Test pointer event handling + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions Simulate pointer events and check the events are then handled correctly + + @SYMTestExpectedResults Pointer events are handled correctly + +*/ + case 1: + ((CTPointerStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0310")); + iTest->LogSubTest(Grab); + + StartGrabTestL(); + iState++; + break; + default: + ((CTPointerStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + ((CTPointerStep*)iStep)->CloseTMSGraphicsStep(); + iTimeOut->Cancel(); + if (iTimeOutCount>0) TEST(EFalse); + if (iTest->IsFullRomL()) User::After(5000000); + TestComplete(); + } + ((CTPointerStep*)iStep)->RecordTestResultL(); + } + + +__WS_CONSTRUCT_STEP__(Pointer) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TPointer.H --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TPointer.H Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,167 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef __TPOINTER_H__ +#define __TPOINTER_H__ + +#include +#include +#include +#include "../tlib/testbase.h" +#include "AUTO.H" +#include "TGraphicsHarness.h" + +class CTPointer; +class CGrabWindow; + +class CPointerWindow : public CTWin + { + enum {KRepeatMargin=200000}; // 0.2 Seconds + enum {KRepeatCount=4}; + enum {KRepeatIntervalIncrements=100000}; + enum {KRepeatRectXExtra=50}; + enum {KRepeatRectYExtra=50}; + enum {KStateWaitingForTest1,KStateFailed,KStateTesting1, + KStateWaitingForTest2,KStateTesting2, + KStateWaitingForTest3,KStateTesting3, + KStateWaitingForTest4,KStateTesting4, + KStateWaitingForTest5,KStateTesting5, + KStateWaitingForTest6,KStateTesting6, + KStateWaitingForTest8,KStateTesting8, + KStateWaitingForTest7,KStateTesting7, + KStateFinished}; +public: + CPointerWindow(CTPointer *aTest); + void SetUpLD(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc); + void Draw(); + void StartNextRepeatTest(); + void QueueNextRepeat(); + void PointerL(const TPointerEvent &aPointer,const TTime&); + void WinKeyL(const TKeyEvent &aKey,const TTime &aTime); +private: + void SwitchOn(const TTime &); + void ResetTest(TInt aState); + void SetState(TInt aState); + void FinishedTests(); + void TestFailed(TBool aRetest=EFalse); + void SendEvent(); +private: + CTPointer *iTest; + TInt iRepeatCount; + TInt iState; + TTimeIntervalMicroSeconds32 iInterval; + TTime iPrevTime; + TRect iRepeatRect; + TPoint iTl; + TSize iSize; + }; + +class CGrabWindow2 : public CTWin + { +public: + CGrabWindow2(CGrabWindow *aWindow); + void SetUpLD(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc); +private: + void Draw(); + void PointerL(const TPointerEvent &aPointer,const TTime&); +private: + CGrabWindow *iGrabWindow; + }; + +class CGrabWindow : public CTWin + { + enum {KGrabStateWaitingForDown,KGrabStateWaitingForDragOut,KGrabStateWaitingForUp,KGrabStateFinished, + KGrabStateWaitingForDown2,KGrabStateWaitingForUp2a,KGrabStateWaitingForDrag2,KGrabStateWaitingForUp2b, + KGrabStateWaitingForDown3,KGrabStateWaitingForUp3a,KGrabStateWaitingForUp3b, + KGrabStateWaitingForDown4,KGrabStateWaitingForUp4, + KGrabStateWaitingForDown5,KGrabStateWaitingForUp5,KGrabStateWaitingForDrag5, + KStateFailed}; +public: + CGrabWindow(CTPointer *aTest); + void Pointer2(const TPointerEvent &aPointer); + void SetUpLD(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc); + void WinKeyL(const TKeyEvent &aKey,const TTime &aTime); +private: + void Draw(); + void SetState(TInt aState); + void ResetTest(); + void PointerL(const TPointerEvent &aPointer,const TTime&); + void TestFailed(); + void FinishedTests(); + void SendEvent(); +private: + TInt iState; + CTPointer *iTest; + TPoint iTl; + TSize iSize; + }; + + +class CTPointer : public CTWsGraphicsBase + { +public: + enum {KTimeOutAfter=20000000}; //20secs +public: + CTPointer(CTestStep* aStep); + ~CTPointer(); + void ConstructL(); + + TBool TestFailed(TInt aCase,TBool aRetry=EFalse); + void StartGrabTestL(); + static TInt TimeOut(TAny* aTest); + void TimeOut(); + CGrabWindow2 *GrabWin2() const; + inline TBool Digitiser() const {return !iNoDigitiser;} + inline void SimulatePointer(TRawEvent::TType aType, TInt aX, TInt aY){iTest->SimulatePointer(aType, aX, aY);} + inline void SimulateEvent(TRawEvent::TType aType){iTest->SimulateEvent(aType);} +protected: + virtual void RunTestCaseL(TInt aCurTestCase); +private: + TInt doTestFailedL(); + inline TestClient* Client() {return TheClient;} + TInt iState; + +private: + CTimeOut* iTimeOut; + TInt iTimeOutCount; + CPointerWindow *iRepeatWin; + CGrabWindow *iGrabWin; + CGrabWindow2 *iGrabWin2; + TSize iWinSize; + //TInt iState; + TBool iOldPointerState; + TBool iNoDigitiser; + }; + + +class CTPointerStep : public CTGraphicsStep + { +public: + CTPointerStep(); +protected: + //from CTGraphicsStep + virtual CTGraphicsBase* CreateTestL(); + }; + +_LIT(KTPointerStep,"TPointer"); + + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TRECTLIST.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TRECTLIST.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,136 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Generate a list of rectangles to be used as parameters for graphics tests +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + + +#include "TRECTLIST.H" + +CTRectList::CTRectList(CTestStep* aStep) : CTWsGraphicsBase(aStep) + { + } + +CTRectList::~CTRectList() + { + } + +void CTRectList::ConstructL() + { + TheGc->Activate(*BaseWin->Win()); + TheGc->SetBrushColor(TRgb::Gray16(14)); + TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + TheGc->SetPenStyle(CGraphicsContext::ENullPen); + TheGc->DrawRect(TRect(BaseWin->Win()->Size())); + TInt scale=16; + TSize size(TestWin->Size()); + TSize scaleSize(size.iWidth/scale,size.iHeight/scale); + iOffset1=TPoint((size.iWidth-scaleSize.iWidth)/2,(size.iWidth-scaleSize.iHeight)/2); + TheGc->DrawRect(TRect(iOffset1,scaleSize)); + TheGc->Deactivate(); +// + TheGc->Activate(*TestWin->Win()); + TheGc->SetBrushColor(TRgb::Gray16(15)); + TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + TheGc->SetPenStyle(CGraphicsContext::ENullPen); + TheGc->DrawRect(TRect(TestWin->Win()->Size())); + { + TInt scale=1; + TSize size(TestWin->Size()); + TSize scaleSize(size.iWidth/scale,size.iHeight/scale); + iOffset2=TPoint((size.iWidth-scaleSize.iWidth)/2,(size.iWidth-scaleSize.iHeight)/2); + TheGc->DrawRect(TRect(iOffset2,scaleSize)); + TheGc->Deactivate(); + } + } + +void CTRectList::RunTestCaseL(TInt /*aCurTestCase*/) + { + ((CTRectListStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); + switch(++iTest->iState) + { + /** +@SYMTestCaseID GRAPHICS-WSERV-0028 + +@@SYMDEF DEF081259 + +@SYMTestCaseDesc Draw rectangles from a list in two different positions + on the screen + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Draw a list of rectangles to the screen + +@SYMTestExpectedResults Rectangles are drawn without error +*/ + case 1: + ((CTRectListStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0028")); + iTest->LogSubTest(_L("RectListCheck")); + { + TheGc->Activate(*BaseWin->Win()); + TheGc->SetPenColor(TRgb::Gray16(7)); + TInt scale=16; + for(TInt index=0;indexiTestRects.Count3();index++) + { + TRect rect=iTest->iTestRects[index]; + rect.iTl.iX/=scale; + rect.iTl.iY/=scale; + rect.iBr.iX/=scale; + rect.iBr.iY/=scale; + rect.Move(iOffset1); + TheGc->DrawRect(rect); + } + TheGc->Deactivate(); + } + { + TheGc->Activate(*TestWin->Win()); + TheGc->SetPenColor(TRgb::Gray16(7)); + TInt scale=1; + for(TInt index=0;indexiTestRects.Count3();index++) + { + TRect rect=iTest->iTestRects[index]; + rect.iTl.iX/=scale; + rect.iTl.iY/=scale; + rect.iBr.iX/=scale; + rect.iBr.iY/=scale; + rect.Move(iOffset2); + TheGc->DrawRect(rect); + } + TheClient->iWs.Flush(); + TheGc->Deactivate(); + } + TEST(ETrue); + break; + case 2: + ((CTRectListStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + iTest->LogSubTest(_L("Panic")); + break; + case 3: + ((CTRectListStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + ((CTRectListStep*)iStep)->CloseTMSGraphicsStep(); + TestComplete(); + break; + } + ((CTRectListStep*)iStep)->RecordTestResultL(); + } + +__WS_CONSTRUCT_STEP__(RectList) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TRECTLIST.H --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TRECTLIST.H Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,60 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Generate a list of rectangles to be used as parameters for graphics tests +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef __TRECTLIST_H__ +#define __TRECTLIST_H__ + +#include +#include +#include "../tlib/testbase.h" +#include "AUTO.H" +#include "TGraphicsHarness.h" + +class CTRectList : public CTWsGraphicsBase + { +public: + CTRectList(CTestStep* aStep); + ~CTRectList(); + void ConstructL(); +protected: +//from CTGraphicsStep + virtual void RunTestCaseL(TInt aCurTestCase); +private: + TPoint iOffset1; + TPoint iOffset2; + TSize iWinSize; + }; + +class CTRectListStep : public CTGraphicsStep + { +public: + CTRectListStep(); +protected: + //from CTGraphicsStep + virtual CTGraphicsBase* CreateTestL(); + }; + +_LIT(KTRectListStep,"TRectList"); + + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TREDRAW.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TREDRAW.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,1586 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Window redraw/validate/invalidate tests +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include "TREDRAW.H" + +LOCAL_D TSize FullScreenModeSize; + +const TRgb KRed = TRgb(255,0,0); +const TRgb KBlack = TRgb(0,0,0); +const TRgb KWhite = TRgb(255,255,255); +const TRgb KTransBisque = TRgb(255,228,196,128); +const TRgb KTransLightSalmon = TRgb(255,160,122,128); +const TRgb KLightSteelBlue = TRgb(176,196,222); +const TRgb KCadetBlue = TRgb(95,158,160); + +TInt CTRedrawOrderWindow::iRedrawNumber=0; + +#define InvalidRegionLogging +#if defined(InvalidRegionLogging) +#define BLOG_MESSAGE(p) (const_cast(&iGraphicsTest))->LogMessage(((TText8*)__FILE__), __LINE__,(p)) +#endif + +// +// // +// + +CTCheckDefectWin* CTCheckDefectWin::NewL(TPoint aPos,TSize aWinSize) + { + CTCheckDefectWin* win=new(ELeave) CTCheckDefectWin; + win->ConstructExtLD(*TheClient->iGroup,aPos,aWinSize); + win->BaseWin()->SetRequiredDisplayMode(EColor256); + win->AssignGC(*TheClient->iGc); + win->BaseWin()->SetShadowDisabled(ETrue); + win->BaseWin()->SetShadowHeight(0); + TheClient->Flush(); + return win; + } + +CRedrawWindow::CRedrawWindow(CTRedrawTest *aTest) : CTWin(), iTest(aTest) + { + } + +CRedrawWindow::~CRedrawWindow() + { + iInvalid.Close(); + } + +void CRedrawWindow::Draw() + { + ReceivedDrawRequest(); + DrawPattern(iTest->WinContent()); + } + +void CRedrawWindow::ReceivedDrawRequest() + { + iDrawRequests++; + } + +TInt CRedrawWindow::DrawRequests() const + { + return iDrawRequests; + } + +void CRedrawWindow::DrawPattern(TInt aPattern) + { + iGc->Clear(); + TPoint drawBase(-10,-20); + TSize drawSize(iSize.iWidth-2*drawBase.iX,iSize.iHeight-2*drawBase.iY); + TPoint offset=drawBase+iOffset; + switch(aPattern) + { + case EDrawGraphPaperlHatched: + { + iGc->DrawRect(TRect(drawBase,drawBase+drawSize)); + iGc->SetPenColor(TRgb(85,85,85)); + iGc->SetDrawMode(CGraphicsContext::EDrawModeXOR); + TInt xpos; + for(xpos=0;xposDrawLine(TPoint(xpos,0)+offset,TPoint(xpos,drawSize.iHeight)+offset); + TInt ypos; + for(ypos=0;yposDrawLine(TPoint(0,ypos)+offset,TPoint(drawSize.iWidth,ypos)+offset); + break; + } + case EDrawSlantingHatched: + { + iGc->SetPenColor(TRgb(255,255,255)); + iGc->SetDrawMode(CGraphicsContext::EDrawModeXOR); + for(TInt xpos=0;xposDrawLine(TPoint(xpos,0)+offset,TPoint(drawSize.iWidth,xpos*drawSize.iHeight/drawSize.iWidth)+offset); + iGc->DrawLine(TPoint(xpos,0)+offset,TPoint(0,drawSize.iHeight-xpos*drawSize.iHeight/drawSize.iWidth)+offset); + iGc->DrawLine(TPoint(xpos,drawSize.iHeight)+offset,TPoint(drawSize.iWidth,drawSize.iHeight-xpos*drawSize.iHeight/drawSize.iWidth)+offset); + iGc->DrawLine(TPoint(xpos,drawSize.iHeight)+offset,TPoint(0,xpos*drawSize.iHeight/drawSize.iWidth)+offset); + } + } + break; + case EDrawCenteredRectangle: + { + TRect rect(5,iSize.iHeight/4,iSize.iWidth-5,iSize.iHeight/2); + iGc->SetDrawMode(CGraphicsContext::EDrawModeXOR); + iGc->SetPenColor(TRgb(255,255,255)); + iGc->DrawRect(rect); + } + break; + default: + // Other pattern values requested are ignored + break; + } + } + +void CRedrawWindow::Reset() + { + iOffset=TPoint(0,0); + iWin.Invalidate(); + iInvalid.Clear(); + } + +/** + * Calculate the window region minus the region covered by the child + * window; this is the "visible region" + */ +void CRedrawWindow::VisibleRegion(RRegion &aRegion) + { + aRegion.Clear(); + aRegion.AddRect(TRect(Size())); + TRect child; + child.iTl=Child()->BaseWin()->InquireOffset(iWin); + child.iBr=child.iTl+Child()->Size(); + aRegion.SubRect(child); + } + + +void CRedrawWindow::ValidateAndClear() + { + Win()->Invalidate(); + Win()->BeginRedraw(); + iGc->Activate(*Win()); + iGc->Clear(); + iGc->Deactivate(); + Win()->EndRedraw(); + } + +void CRedrawWindow::ActivateAndDraw(TInt aPattern, TRegion *aRegion) + { + iGc->Activate(*Win()); + if (aRegion) + iGc->SetClippingRegion(*aRegion); + DrawPattern(aPattern); + iGc->Deactivate(); + } + +CReferenceComparisonRedrawWindow::CReferenceComparisonRedrawWindow(CTRedrawTest *aTest) : CRedrawWindow(aTest) + {} + +/** + * Prepare the invalid region. + * + * Update the invalid region with a rectangle where such a rectangle is minus + * any area covered by a child window. + * + * @param aRect Rectangle to be added to the invalid region + */ +void CReferenceComparisonRedrawWindow::PrepareInvalidation(const TRect &aRect) + { + RRegion clipped_visible; + VisibleRegion(clipped_visible); + clipped_visible.ClipRect(aRect); + iInvalid.Union(clipped_visible); + clipped_visible.Close(); + iInvalid.Tidy(); + } + +/** + * Mop up all pending invalid regions and simulate a Draw(). + * + * Normally, we would rely on WServ to call this window's Draw() method + * to obtain drawing operations to cover the currently invalid regions + * of the window. + * + * This method does that task by marking all invalid regions as clean and + * then performs the drawing required in the invalid portions of the screen. + * + * The purpose of this is to then allow a comparison to be made against a + * different window which does rely on the WServ framework calling back + * to do a Draw(). + * + * @post the window has no outstanding invalid regions + */ +void CReferenceComparisonRedrawWindow::PerformInvalidation() + { + for(TInt index=0;indexActivate(iWin); + iGc->SetClippingRegion(iInvalid); + DrawPattern(iTest->WinContent()); + iGc->Deactivate(); + iWin.EndRedraw(); + } + +CRedrawWindow2::CRedrawWindow2(CTRedrawTest *aTest) : CRedrawWindow(aTest) + { + } + +void CRedrawWindow2::Draw() + { + ReceivedDrawRequest(); + if (iClipped) + iGc->SetClippingRegion(iInvalid); + DrawPattern(iTest->WinContent()); + if (iClipped) + iGc->CancelClippingRegion(); + } + +/** + * Prepare the invalid region. + * @param aRect rectangle to be added to the invalid region + */ +void CRedrawWindow2::PrepareInvalidation(const TRect &aRect) + { + iInvalid.Clear(); + iInvalid.AddRect(aRect); + } + +/** + * Perform invalidation by setting the window's invalid region. + * + * The purpose of this method is to stimulate a call from WServ to the + * Draw() method of this class. + */ +void CRedrawWindow2::PerformInvalidation() + { + iWin.Invalidate(iInvalid.BoundingRect()); + } + +void CRedrawWindow2::Reset() + { + CRedrawWindow::Reset(); + iClipped=EFalse; + } + +CRedrawWindow3::CRedrawWindow3(CTRedrawTest *aTest) : CRedrawWindow(aTest) + { + } + +void CRedrawWindow3::Draw() + { + ReceivedDrawRequest(); + iGc->Clear(); + iGc->SetPenStyle(CGraphicsContext::ENullPen); + iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + iGc->SetBrushColor(TRgb(0,255,255)); + iGc->DrawRect(TRect(TPoint(0,0),TSize(50,50))); + } + +void CRedrawWindow3::PrepareInvalidation(const TRect &aRect) + { + iInvalid.Clear(); + iInvalid.AddRect(aRect); + } + +void CRedrawWindow3::PerformInvalidation() + { + iWin.Invalidate(iInvalid.BoundingRect()); + } + +void CRedrawWindow3::SetUp1L(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc) + { + ConstructL(*parent); + SetExtL(pos,size); + AssignGC(aGc); + } + +void CRedrawWindow3::Redraw(const TRect &aRect) + { + if(!isActive) + {//make an empty redraw + iWin.BeginRedraw(aRect); + iWin.EndRedraw(); + } + else + { + CTWin::Redraw(aRect); + } + } + +void CRedrawWindow3::Activate() + { + isActive = ETrue; + Win()->Activate(); + } + +// + +CTRedrawOrderWindow::CTRedrawOrderWindow(TInt aOrder, CTRedrawTest *aTest) : iTest(aTest), iOrder(aOrder) + {} + +CTRedrawOrderWindow* CTRedrawOrderWindow::NewLC(TInt aOrder,CTWinBase* aParent,const TPoint& aPos,const TSize& aSize,CTRedrawTest* aTest) + { + CTRedrawOrderWindow* self=new(ELeave) CTRedrawOrderWindow(aOrder,aTest); + CleanupStack::PushL(self); + self->SetUpL(aPos,aSize,aParent,*TheGc); + return self; + } + +void CTRedrawOrderWindow::Draw() + { + iGc->SetBrushColor(TRgb::Gray16(iOrder*2)); + iGc->Clear(); + } + +void CTRedrawOrderWindow::ResetRedrawNumber() + { + iRedrawNumber=0; + } + +void CTRedrawOrderWindow::Redraw(const TRect &aRect) + { + if (++iRedrawNumber!=iOrder) + iTest->Failed(iOrder); + CTWin::Redraw(aRect); + } + +// + +TInt DestructCallback(TAny *aParam) + { + ((CTRedrawTest *)aParam)->doDestruct(); + return(0); + } + +CTRedrawTest::CTRedrawTest(CTestStep* aStep): + CTWsGraphicsBase(aStep)//, iInvalidRegionChecker(*this) + {} + +void CTRedrawTest::doDestruct() + { + BaseWin->SetVisible(ETrue); + TestWin->SetVisible(ETrue); + delete iBaseRedrawWin; + delete iTestRedrawWin; + delete iBaseChildWin; + delete iTestChildWin; + } + +CTRedrawTest::~CTRedrawTest() + { + TCallBack callBack(DestructCallback,this); + TheClient->SetRedrawCancelFunction(callBack); + delete iInvalidRegionChecker; + } + +void CTRedrawTest::ConstructL() + { +#if defined(InvalidRegionLogging) + LOG_MESSAGE(_L(" CTRedrawTest::ConstructL()")); + LOG_MESSAGE4(_L(" Ex Wins 0x%08x, 0x%08x, 0x%08x"), BaseWin, TestWin, &(TheClient->StdLogWindow())); +#endif + + iInvalidRegionChecker = new(ELeave)CInvalidRegionChecker(*this); + User::LeaveIfError(iInvalidRegionChecker->AddExcludedWindow(BaseWin)); + User::LeaveIfError(iInvalidRegionChecker->AddExcludedWindow(TestWin)); + User::LeaveIfError(iInvalidRegionChecker->AddExcludedWindow(&(TheClient->StdLogWindow()))); + WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions); + + iWinContent=0; + BaseWin->SetVisible(EFalse); + TestWin->SetVisible(EFalse); + FullScreenModeSize=TheClient->iGroup->Size(); + TInt winWidth=(FullScreenModeSize.iWidth/3)-10; + TInt winHeight=FullScreenModeSize.iHeight-10; + iBaseRedrawWin=new(ELeave) CReferenceComparisonRedrawWindow(this); + iBaseRedrawWin->SetUpL(TPoint(FullScreenModeSize.iWidth/3+5,5),TSize(winWidth,winHeight),TheClient->iGroup,*TheClient->iGc); + iTestRedrawWin=new(ELeave) CRedrawWindow2(this); + iTestRedrawWin->SetUpL(TPoint(FullScreenModeSize.iWidth/3*2+5,5),TSize(winWidth,winHeight),TheClient->iGroup,*TheClient->iGc); + iBaseChildWin=new(ELeave) CBlankWindow(); + iBaseChildWin->SetUpL(TPoint(winWidth>>2,winHeight>>2),TSize(winWidth>>1,winHeight>>1),iBaseRedrawWin,*TheClient->iGc); + iTestChildWin=new(ELeave) CBlankWindow(); + iTestChildWin->SetUpL(TPoint(winWidth>>2,winHeight>>2),TSize(winWidth>>1,winHeight>>1),iTestRedrawWin,*TheClient->iGc); + +#if defined(InvalidRegionLogging) + LOG_MESSAGE5(_L(" In Wins %08x, %08x, %08x, %08x"), iBaseRedrawWin, iBaseChildWin, iTestRedrawWin, iTestChildWin); +#endif + + WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions); + +#if defined(InvalidRegionLogging) + LOG_MESSAGE(_L(" Done")); +#endif + } + +void CTRedrawTest::CheckRedrawWindows() + { + _LIT(KTest,"Redraw Test, SubTest %d "); + TBuf<64> buf; + buf.Format(KTest,iTest->iState); + CheckRect(iBaseRedrawWin,iTestRedrawWin,TRect(iBaseRedrawWin->Size()),buf); + } + +void CTRedrawTest::InvalidateTestWins(const TRect &aRect) + { + iBaseRedrawWin->PrepareInvalidation(aRect); + iTestRedrawWin->PrepareInvalidation(aRect); + iBaseRedrawWin->PerformInvalidation(); + iTestRedrawWin->PerformInvalidation(); + } + +inline TInt CTRedrawTest::WinContent() + { + return iWinContent; + } + +void CTRedrawTest::SetBackground(const TRgb &aRgb) + { + iBaseRedrawWin->iWin.SetBackgroundColor(aRgb); + iTestRedrawWin->iWin.SetBackgroundColor(aRgb); + } + +void CTRedrawTest::DumpRegion(const TRegion &aRegion) + { + _LIT(KLog,"RegionRect %d: (%d,%d,%d,%d)"); + for (TInt ii=0;iiiWin.Position(); + TSize screenSize=TheClient->iGroup->Size(); + iBaseRedrawWin->iWin.Invalidate(); + iTestRedrawWin->iWin.Invalidate(); + iTestRedrawWin->iWin.SetPosition(TPoint(10,10)); + iTestRedrawWin->iWin.SetPosition(TPoint(0,0)); + iTestRedrawWin->iWin.SetPosition(TPoint(-10,-10)); + iTestRedrawWin->iWin.SetPosition(TPoint(screenSize.iWidth-10,screenSize.iHeight-10)); + iTestRedrawWin->iWin.SetPosition(TPoint(screenSize.iWidth,screenSize.iHeight)); + iTestRedrawWin->iWin.SetPosition(TPoint(screenSize.iWidth+10,screenSize.iHeight+10)); + iTestRedrawWin->iWin.SetPosition(old); + RRegion baseInvalidRegion; + RRegion testInvalidRegion; + iBaseRedrawWin->iWin.GetInvalidRegion(baseInvalidRegion); + iTestRedrawWin->iWin.GetInvalidRegion(testInvalidRegion); + CompareRegionsL(baseInvalidRegion,testInvalidRegion); + baseInvalidRegion.Close(); + testInvalidRegion.Close(); + } + +void CTRedrawTest::GetInvalidRegionTestsL() + { + TSize stdWinSize(iTest->StdTestWindowSize()); + CArrayFixFlat* rectList=new(ELeave) CArrayFixFlat(3); + rectList->AppendL(TRect(1,1,5,2)); + rectList->AppendL(TRect(stdWinSize.iWidth>>1,stdWinSize.iHeight>>1,stdWinSize.iWidth,stdWinSize.iHeight)); + rectList->AppendL(TRect(2,0,4,5)); + TestGetInvalidRegionL(rectList); + rectList->Reset(); + rectList->AppendL(TRect(-1000,-1,10000,5)); + rectList->AppendL(TRect(0,0,stdWinSize.iWidth>>1,stdWinSize.iHeight>>1)); + rectList->AppendL(TRect(2,100,2*stdWinSize.iWidth,105)); + TestGetInvalidRegionL(rectList); + delete rectList; + } + +void CTRedrawTest::TestGetInvalidRegionL(const CArrayFixFlat *aRectList) + { + RRegion invalidRegion; + RRegion region; + iTestRedrawWin->iWin.BeginRedraw(); + iTestRedrawWin->iWin.EndRedraw(); + for (TInt index=0;indexCount();index++) + { + iTestRedrawWin->iWin.Invalidate((*aRectList)[index]); + region.AddRect((*aRectList)[index]); + } + //Currently WSERV includes areas under a child or other window in the invalid region + //This is arguable the incorrect thing to do + /*TRect subRect; + subRect.iTl=iTestChildWin->BaseWin()->InquireOffset(iTestRedrawWin->iWin); + subRect.SetSize(iTestChildWin->Size()); + region.SubRect(subRect);*/ + region.ClipRect(TRect(iTestRedrawWin->Size())); + iTestRedrawWin->iWin.GetInvalidRegion(invalidRegion); + CompareRegionsL(region,invalidRegion); + region.Close(); + invalidRegion.Close(); + } + +void CTRedrawTest::Failed(TInt aOrder) + { + _LIT(KLog,"Redraw Order Error, Window Drawn at Position %d should be drawn at Position %d"); + LOG_MESSAGE3(KLog,CTRedrawOrderWindow::RedrawNumber(),aOrder); + if (iRedrawNo==0) + iRedrawNo=CTRedrawOrderWindow::RedrawNumber(); + } + +void CTRedrawTest::CheckOrderL() + { + _LIT(KLog,"Fail in redraw order test, first position of error is %d"); + iRedrawNo=0; + CTRedrawOrderWindow* order1; + CTRedrawOrderWindow* order2; + CTRedrawOrderWindow* order3; + CTRedrawOrderWindow* order4; + CTRedrawOrderWindow* order5; + CTRedrawOrderWindow* order6; + CTRedrawOrderWindow* order7; + order6=CTRedrawOrderWindow::NewLC(6,TheClient->iGroup,TPoint(100,10),TSize(40,40),this); + order7=CTRedrawOrderWindow::NewLC(7,order6,TPoint(0,0),TSize(20,20),this); + order1=CTRedrawOrderWindow::NewLC(1,TheClient->iGroup,TPoint(10,10),TSize(60,40),this); + order4=CTRedrawOrderWindow::NewLC(4,order1,TPoint(20,0),TSize(20,40),this); + order5=CTRedrawOrderWindow::NewLC(5,order4,TPoint(0,0),TSize(20,20),this); + order2=CTRedrawOrderWindow::NewLC(2,order1,TPoint(0,0),TSize(20,40),this); + order3=CTRedrawOrderWindow::NewLC(3,order2,TPoint(0,0),TSize(20,20),this); + TheClient->iWs.Finish(); // Fix for DEF133199 - Intermittant failure with windows out of order + WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions); // Check order is correct after initial creation + TEST(order1!=NULL && order2!=NULL && order3!=NULL && order4!=NULL && order5!=NULL && order6!=NULL && order7!=NULL); // redundant check to shut up the compiler + TEST(iRedrawNo==0); + if (iRedrawNo>0) + LOG_MESSAGE2(KLog,iRedrawNo); + + CTRedrawOrderWindow::ResetRedrawNumber(); + iRedrawNo=0; + CTUser::Splat(TheClient,TRect(0,0,200,60),TRgb(0,0,0)); + TheClient->iWs.Flush(); + WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions); // Check it's still correct on subsequent redraws + TEST(iRedrawNo==0); + if (iRedrawNo>0) + LOG_MESSAGE2(KLog,iRedrawNo); + CTRedrawOrderWindow::ResetRedrawNumber(); + CleanupStack::PopAndDestroy(7,order6); + } + +// For reproducing INC049554 +void CTRedrawTest::CheckDefectINC049554L() + { + if(TransparencySupportedL() == KErrNotSupported) //the defect only happens when transparency enabled + return; + TSize screenSize=TheClient->iScreen->SizeInPixels(); + TPoint winPos(screenSize.iWidth/3,0); + TSize winSize(screenSize.iWidth/3,screenSize.iHeight); + CTCheckDefectWin* lowerWin=CTCheckDefectWin::NewL(winPos,winSize); + CleanupStack::PushL(lowerWin); + lowerWin->Activate(); + TheClient->Flush(); + WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions); + + winPos.iX+=screenSize.iWidth/12; + + CTCheckDefectWin* upperWin=CTCheckDefectWin::NewL(winPos,winSize); + CleanupStack::PushL(upperWin); + upperWin->Activate(); + TheClient->Flush(); + WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions); + + // Invalidate the lower win and while drawing its content, move top window + lowerWin->Invalidate(); + lowerWin->Win()->BeginRedraw(); + TheClient->iGc->Activate(*lowerWin->DrawableWin()); + TheClient->iGc->SetPenStyle(CGraphicsContext::ENullPen); + TheClient->iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + TheClient->iGc->SetBrushColor(TRgb(0,255,0)); + TheClient->iGc->DrawRect(TRect(TPoint(0,0),TSize(50,50))); + + winPos.iX+=screenSize.iWidth/12; + upperWin->SetExt(winPos,winSize); + + TheClient->iGc->SetBrushColor(TRgb(255,0,0)); + TheClient->iGc->DrawRect(TRect(TPoint(0,0),TSize(50,50))); + TheClient->iGc->Deactivate(); + lowerWin->Win()->EndRedraw(); + + TheClient->Flush(); + WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions); + + CleanupStack::PopAndDestroy(upperWin); + + // Create 2 transaprent windows, slightly over lapping the background window + winPos.iX=screenSize.iWidth/3; + TPoint winPosTop(winPos.iX-screenSize.iWidth/6,0); + TSize winSizeTop(screenSize.iWidth/3+screenSize.iWidth/6,screenSize.iHeight/2); + + CTCheckDefectWin* leftWin=CTCheckDefectWin::NewL(winPosTop,winSizeTop); + CleanupStack::PushL(leftWin); + leftWin->Win()->SetTransparencyAlphaChannel(); + leftWin->Win()->SetBackgroundColor(TRgb(0,0,0, 128)); + leftWin->Activate(); + TheClient->iWs.Finish(); + WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions); + + CTCheckDefectWin* rightWin=CTCheckDefectWin::NewL(winPos,winSizeTop); + CleanupStack::PushL(rightWin); + rightWin->Win()->SetTransparencyAlphaChannel(); + rightWin->Win()->SetBackgroundColor(TRgb(0,0,0, 128)); + rightWin->Activate(); + TheClient->iWs.Finish(); + WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions); + + lowerWin->Invalidate(); + lowerWin->Win()->BeginRedraw(); + TheClient->iGc->Activate(*lowerWin->DrawableWin()); + TheClient->iGc->SetPenStyle(CGraphicsContext::ENullPen); + TheClient->iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + TheClient->iGc->SetBrushColor(TRgb(0,255,0)); + TheClient->iGc->DrawRect(TRect(TPoint(0,0),TSize(50,50))); + + TheClient->iGc->SetBrushColor(TRgb(255,0,0)); + TheClient->iGc->DrawRect(TRect(TPoint(0,0),TSize(50,50))); + TheClient->iGc->Deactivate(); + lowerWin->Win()->EndRedraw(); + + TheClient->iWs.Finish(); + WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions); + + CleanupStack::PopAndDestroy(3,lowerWin); + } + + +TInt myKK=1; +_LIT(KSnap,"c:\\TestRect%2i.mbm"); +_LIT(KSnapE,"c:\\TestRect%2iErr.mbm"); +void CTRedrawTest::TestRect() + { + + TBuf<50> snapshotFileName; + snapshotFileName.Zero(); + CFbsBitmap *snapshot=new(ELeave) CFbsBitmap(); + CleanupStack::PushL(snapshot); + User::LeaveIfError(snapshot->Create(TheClient->iScreen->SizeInPixels(),TheClient->iScreen->DisplayMode())); + + User::LeaveIfError(TheClient->iScreen->CopyScreenToBitmap(snapshot)); + + TRect rect1=TRect(TPoint(),TSize(FullScreenModeSize.iWidth/2,FullScreenModeSize.iHeight)); + TRect rect2=TRect(TPoint(FullScreenModeSize.iWidth/2,0),TSize(FullScreenModeSize.iWidth/2,FullScreenModeSize.iHeight)); + TBool retVal = TheClient->iScreen->RectCompare(rect1,rect2); + + RDebug::Printf("Picture %i !!!: Rect1: (%i,%i)->(%i,%i) - Rect2: (%i,%i)->(%i,%i)",myKK, + rect1.iTl.iX,rect1.iTl.iY,rect1.iBr.iX,rect1.iBr.iY, + rect2.iTl.iX,rect2.iTl.iY,rect2.iBr.iX,rect2.iBr.iY); + + + if (retVal) + { + snapshotFileName.Format(KSnap,myKK); + } + else + { + snapshotFileName.Format(KSnapE,myKK); + } + snapshot->Save(snapshotFileName); + CleanupStack::PopAndDestroy(snapshot); + myKK++; + + + + TEST(retVal); + if(!retVal) + INFO_PRINTF3(_L("TheClient->iScreen->RectCompare() return value - Expected: %d, Actual: %d"), ETrue, retVal); + } + +void CTRedrawTest::ConstructAndSetBlankWinLC(RBlankWindow& aWindow, TSize aSize, TPoint aPoint/*=TPoint()*/, + TRgb aBackgroundColor/*=TRgb(0,0,0)*/) + { + User::LeaveIfError(aWindow.Construct(*TheClient->iGroup->GroupWin(), ENullWsHandle)); + CleanupClosePushL(aWindow); + aWindow.SetExtent(aPoint, aSize); + aWindow.SetColor(aBackgroundColor); + aWindow.Activate(); + } + +void CTRedrawTest::ConstructWindowLC(RWindow& aWindow, TSize aSize, TPoint aPoint/*=TPoint()*/, + TRgb aBackgroundColor/*=TRgb(255,255,255)*/, TBool aTransparencyByAlpha/*=EFalse*/, + TDisplayMode aDisplayMode/*=EColor64K*/) + { + User::LeaveIfError(aWindow.Construct(*TheClient->iGroup->GroupWin(), ENullWsHandle)); + CleanupClosePushL(aWindow); + aWindow.SetExtent(aPoint,aSize); + aWindow.SetBackgroundColor(aBackgroundColor); + aWindow.SetRequiredDisplayMode(aDisplayMode); + if (aTransparencyByAlpha) + { + aWindow.SetTransparencyAlphaChannel(); + } + aWindow.Activate(); + } + +void CTRedrawTest::ActivateAndSetGc(CWindowGc& aGc, RWindow& aWindow, CGraphicsContext::TBrushStyle aBrushStyle/*=CGraphicsContext::ESolidBrush*/, TRgb aBrushColor/*=TRgb(0,0,0)*/, + CGraphicsContext::TPenStyle aPenStyle/*=CGraphicsContext::ENullPen*/, TRgb aPenColor/*=TRgb(0,0,0)*/) + { + aGc.Activate(aWindow); + aGc.Reset(); + aGc.SetBrushStyle(aBrushStyle); + aGc.SetBrushColor(aBrushColor); + aGc.SetPenStyle(aPenStyle); + aGc.SetPenColor(aPenColor); + } + +void CTRedrawTest::DrawWin(CWindowGc& aGc, RWindow& aWin, TSize aWinSize, TRgb aRectColor1, TRgb aRectColor2, TInt aNewOrdinalPos/*=0*/, RWindow* aWinToMove/*=NULL*/, TBool aDrawAllPixels/*=EFalse*/) + { + const TUint startX = 10; + const TUint endX = aWinSize.iWidth - startX; + const TUint startY = 10; + const TUint sHeight = (aWinSize.iHeight >> 1) - startY; + ActivateAndSetGc(aGc,aWin); + aWin.BeginRedraw(); + if(aDrawAllPixels) + { + aGc.SetBrushColor(KWhite); + aGc.DrawRect(TRect(aWinSize)); + } + aGc.SetBrushColor(aRectColor1); + aGc.DrawRect(TRect(startX, startY, endX, sHeight)); + if (aWinToMove) + { + aWinToMove->SetOrdinalPosition(aNewOrdinalPos); + TheClient->iWs.Finish(); + } + aGc.SetBrushColor(aRectColor2); + aGc.DrawRect(TRect(startX, sHeight + startY, endX, aWinSize.iHeight - startY)); + aWin.EndRedraw(); + aGc.Deactivate(); + } + +void CTRedrawTest::CheckOrdinalPositionDefectL() + { + if(TransparencySupportedL() == KErrNotSupported) //the defect only happens when transparency enabled + { + return; + } + + const TRgb KTransWinColor = TRgb(0,0,255,128); + const TUint hWidth = FullScreenModeSize.iWidth >> 1; + const TSize windowSize = TSize(hWidth,FullScreenModeSize.iHeight); + const TPoint rightWinStartPt = TPoint(hWidth,0); + + // A Blank Window to clear the screen. + // It is required to clear all the pixels on the screen. + RBlankWindow clrWin(TheClient->iWs); + ConstructAndSetBlankWinLC(clrWin, FullScreenModeSize); + + // Transparent window + RWindow winLeftT(TheClient->iWs); + ConstructWindowLC(winLeftT, windowSize, TPoint(), KTransWinColor,ETrue); + + CWindowGc& gc = *(TheClient->iGc); + // Draw the Transparent Window (winLeftT) on the Left side + DrawWin(gc, winLeftT, windowSize, KTransBisque, KTransLightSalmon); + + // Invisible window + RWindow winRightI(TheClient->iWs); + User::LeaveIfError(winRightI.Construct(*TheClient->iGroup->GroupWin(), ENullWsHandle)); + CleanupClosePushL(winRightI); + winRightI.SetExtent(rightWinStartPt, windowSize); + winRightI.SetVisible(EFalse); + winRightI.Activate(); + + // Transparent window + RWindow winRightT(TheClient->iWs); + ConstructWindowLC(winRightT, windowSize, rightWinStartPt, KTransWinColor,ETrue); + + // Draw the Transparent Window (winRightT) on the Right side and change the + // Ordinal Position for Invisible Window (winRightI) to move it front + // to the Transparent Window. + // Invisible window is behind the Transparent Window + + DrawWin(gc, winRightT, windowSize, KTransBisque, KTransLightSalmon, 0, &winRightI); // Move winRightI to Front of winRightT + TestRect(); + + CleanupStack::PopAndDestroy(4, &clrWin); + } + +// For reproducing PDEF099892 +void CTRedrawTest::CheckDefectPDEF099892L() + { + if(TransparencySupportedL() == KErrNotSupported) //the defect only happens when transparency enabled + { + return; + } + + const TRgb KTransWinColor = TRgb(0,0,255,128); + const TUint hWidth = FullScreenModeSize.iWidth >> 1; + const TUint hHeight = FullScreenModeSize.iHeight >> 1; + const TSize windowSize = TSize(hWidth,FullScreenModeSize.iHeight); + const TSize transWinSize = TSize(hWidth,hHeight + 10); + const TPoint rightWinStartPt = TPoint(hWidth,0); + + // A Blank Window to clear the screen. + // It is required to clear all the pixels on the screen. + RBlankWindow clrWin(TheClient->iWs); + ConstructAndSetBlankWinLC(clrWin, FullScreenModeSize); + + // Create an Opaque and a Transparent Window and Draw them on the + // Left Side of the Screen. Opaque Window is Behind the Transparent Window. + + // Opaque Window + RWindow winLeftOpq(TheClient->iWs); + ConstructWindowLC(winLeftOpq, windowSize, TPoint(), KRed); + + // Transparent window + RWindow winLeftT(TheClient->iWs); + ConstructWindowLC(winLeftT, transWinSize, TPoint(), KTransWinColor, ETrue); + + CWindowGc& gc = *(TheClient->iGc); + // Draw the transparent Window (winLeftT) on the Left side + DrawWin(gc, winLeftT, transWinSize, KTransBisque, KTransLightSalmon); + + // Draw the Opaque Window (winLeftOpq) on the Left side + DrawWin(gc, winLeftOpq, windowSize, KLightSteelBlue, KCadetBlue, 0, NULL, ETrue); + + // Create an Invisible, an Opaque and a Transparent Window and Draw them on the + // Right Side of the Screen. Invisible Window is Behind the Opaque Window and + // Opaque Window is Behind the Transparent Window. + // While drawing the Transparent Window, move the Invisible Window to the Front of Opaque Window. + // And while Drawing the Opaque Window move the Invisible Window again Behind the Opaque Window. + + // Invisible window + RWindow winRightI(TheClient->iWs); + User::LeaveIfError(winRightI.Construct(*TheClient->iGroup->GroupWin(), ENullWsHandle)); + CleanupClosePushL(winRightI); + winRightI.SetExtent(rightWinStartPt, windowSize); + winRightI.SetVisible(EFalse); + winRightI.Activate(); + + // Opaque Window + RWindow winRightOpq(TheClient->iWs); + ConstructWindowLC(winRightOpq, windowSize, rightWinStartPt, KRed); + + // Transparent window + RWindow winRightT(TheClient->iWs); + ConstructWindowLC(winRightT, transWinSize, rightWinStartPt, KTransWinColor, ETrue); + + // Draw the transparent Window (winRightT) on the Right side + DrawWin(gc, winRightT, transWinSize, KTransBisque, KTransLightSalmon, 1, &winRightI ); + + // Draw the Opaque Window (winRightOpq) on the Right side + DrawWin(gc, winRightOpq, windowSize, KLightSteelBlue, KCadetBlue, 2, &winRightI, ETrue); + + // Compare the Left and Right side Rectangles + TestRect(); + + CleanupStack::PopAndDestroy(6, &clrWin); + } + +void CTRedrawTest::CheckMMSDefectL(TBool aMoveBlankWindow) + { + if(TransparencySupportedL() == KErrNotSupported) //the defect only happens when transparency enabled + { + return; + } + + const TRgb KTransWinColor = TRgb(0,0,255,128); + const TUint hWidth = FullScreenModeSize.iWidth >> 1; + const TUint hHeight = FullScreenModeSize.iHeight >> 1; + const TSize windowSize = TSize(hWidth,FullScreenModeSize.iHeight); + const TSize transWinSize = TSize(hWidth - 20,hHeight + 10); + const TPoint rightWinStartPt = TPoint(hWidth,0); + + // A Blank Window to clear the screen. + // It is required to clear all the pixels on the screen. + RBlankWindow clrWin(TheClient->iWs); + ConstructAndSetBlankWinLC(clrWin, FullScreenModeSize); + + // Create an Opaque and a Transparent Window and Draw them on the + // Left Side of the Screen. Opaque Window is Behind the Transparent Window. + + // Opaque Window + RWindow winLeftOpq(TheClient->iWs); + ConstructWindowLC(winLeftOpq, windowSize, TPoint(), KRed); + CWindowGc& gc = *(TheClient->iGc); + // Draw the Opaque Window (winLeftOpq) on the Left side + DrawWin(gc, winLeftOpq, windowSize, KLightSteelBlue, KCadetBlue, 0, NULL, ETrue); + + // Another Window - A Blank Window + RBlankWindow winLeftBlank(TheClient->iWs); + ConstructAndSetBlankWinLC(winLeftBlank, TSize(100,100), TPoint(20,20), TRgb(128,128,128)); + + // Transparent window + RWindow winLeftT(TheClient->iWs); + ConstructWindowLC(winLeftT, transWinSize, TPoint(10, 10), KTransWinColor, ETrue); + // Draw the Transparent Window (winLeftT) on the Left side + DrawWin(gc, winLeftT, transWinSize, KTransBisque, KTransLightSalmon); + + // Invisible window + RWindow winRightI(TheClient->iWs); + User::LeaveIfError(winRightI.Construct(*TheClient->iGroup->GroupWin(), ENullWsHandle)); + CleanupClosePushL(winRightI); + winRightI.SetExtent(rightWinStartPt, windowSize); + winRightI.SetVisible(EFalse); + winRightI.Activate(); + + // Opaque Window + RWindow winRightOpq(TheClient->iWs); + ConstructWindowLC(winRightOpq, windowSize, rightWinStartPt, KRed); + + // Draw the Opaque Window (winRightOpq) on the Right side + DrawWin(gc, winRightOpq, windowSize, KLightSteelBlue, KCadetBlue, 0, NULL, ETrue); + + // Another Window - A Blank Window + RBlankWindow winRightBlank(TheClient->iWs); + ConstructAndSetBlankWinLC(winRightBlank, TSize(100,100), rightWinStartPt + TPoint(20,20), TRgb(128,128,128)); + + // Transparent window + RWindow winRightT(TheClient->iWs); + ConstructWindowLC(winRightT, transWinSize, rightWinStartPt + TPoint(10,10), KTransWinColor, ETrue); + + if (aMoveBlankWindow) + { + winRightBlank.SetOrdinalPosition(0); // Move the Blank Window to the front of the Transparent Window + TheClient->iWs.Finish(); + } + // Draw the transparent Window (winRightT) on the Right side + DrawWin(gc, winRightT, transWinSize, KTransBisque, KTransLightSalmon, 2, &winRightI); + if (aMoveBlankWindow) + { + winRightBlank.SetOrdinalPosition(1); // Move the Blank Window back to behind the Transparent Window + TheClient->iWs.Finish(); + } + TestRect(); + + DrawWin(gc, winRightT, transWinSize, KTransBisque, KTransLightSalmon, 0, &winRightI); + TestRect(); // if aMoveBlankWindow is ETrue then this will test the Defect PDEF099892 + + // Rest of the lines are just to check other possibilities. + // But,currently, they are not affecting the result. + // i.e. the DrawWin() functions called after this line will draw the same thing + // as it was drawn for the DrawWin() called just before this line. + DrawWin(gc, winRightT, transWinSize, KTransBisque, KTransLightSalmon, 1, &winRightI); + TestRect(); + + DrawWin(gc, winRightT, transWinSize, KTransBisque, KTransLightSalmon, 0, &winRightI); + TestRect(); + + DrawWin(gc, winRightT, transWinSize, KTransBisque, KTransLightSalmon, 2, &winRightI); + TestRect(); + + DrawWin(gc, winRightT, transWinSize, KTransBisque, KTransLightSalmon, 1, &winRightI); + TestRect(); + + DrawWin(gc, winRightT, transWinSize, KTransBisque, KTransLightSalmon, 3, &winRightI); + TestRect(); + + CleanupStack::PopAndDestroy(8, &clrWin); + } + +/** + +The test window is receiving a draw request before it activates, +doing an empty redraw, then activating itself, and drawing itself properly in +response to the next redraw request. + +Without the fix the next redraw request will not be received and it will be drawn blank. +*/ +void CTRedrawTest::CheckDefectPDEF117784L() + { + TSize winSize = BaseWin->Size(); + + TInt winWidth=(FullScreenModeSize.iWidth/3)-10; + TInt winHeight=FullScreenModeSize.iHeight-10; + + CRedrawWindow3* baseRedrawWin = new(ELeave) CRedrawWindow3(this); + CleanupStack::PushL(baseRedrawWin); + TPoint ptBase = TPoint(FullScreenModeSize.iWidth/3*2+5,5); + baseRedrawWin->SetUp1L(ptBase,TSize(winWidth,winHeight),TheClient->iGroup,*TheClient->iGc); + baseRedrawWin->SetVisible(ETrue); + baseRedrawWin->Activate(); + + CRedrawWindow3* testRedrawWin = new(ELeave) CRedrawWindow3(this); + CleanupStack::PushL(testRedrawWin); + TPoint ptTest = TPoint(FullScreenModeSize.iWidth/3+5,5); + testRedrawWin->SetUp1L(ptTest,TSize(winWidth,winHeight),TheClient->iGroup,*TheClient->iGc); + testRedrawWin->SetVisible(ETrue); + testRedrawWin->Activate(); + + TheClient->iWs.Finish(); + User::LeaveIfError(iInvalidRegionChecker->AddExcludedWindow(testRedrawWin)); + TBool retVal = WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions); + TEST(retVal == KErrNone); + if(retVal != KErrNone) + { + ERR_PRINTF2(_L("CTRedrawTest::WaitForRedrawsToFinish failed with error: %d"), retVal); + } + iInvalidRegionChecker->RemoveExcludedWindow(testRedrawWin); + + TheClient->iWs.Finish(); + retVal = WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions); + TEST(retVal == KErrNone); + if(retVal != KErrNone) + { + ERR_PRINTF2(_L("CTRedrawTest::WaitForRedrawsToFinish failed with error: %d"), retVal); + } + + retVal = TheClient->iScreen->RectCompare(TRect(TPoint(ptBase),TSize(winWidth,winHeight)),TRect(TPoint(ptTest),TSize(winWidth,winHeight))); + TEST(retVal); + if(!retVal) + { + ERR_PRINTF1(_L("New activated window has lost redraw request")); + } + + CleanupStack::PopAndDestroy(2, baseRedrawWin); + } + +CInvalidRegionChecker::CInvalidRegionChecker(const CTRedrawTest& aGraphicsTest) + : iGraphicsTest(aGraphicsTest) + {} + +CInvalidRegionChecker::~CInvalidRegionChecker() + { + iExcludedWindowArray.Close(); + } + +TInt CInvalidRegionChecker::AddExcludedWindow(const CTWinBase* aExcludedWindow) + { + TInt error = KErrNone; + const CTWinBase** emptySlot = NULL; + for(TInt win=iExcludedWindowArray.Count()-1; win>=0; win--) + { + if(iExcludedWindowArray[win]==aExcludedWindow) + { + // window is already excluded, we don't want to add it twice + return error; + } + if(!emptySlot && iExcludedWindowArray[win]==NULL) + { + emptySlot = &iExcludedWindowArray[win]; + } + } + + if(emptySlot) + { + // re-use the emptyslot + *emptySlot=aExcludedWindow; // re-use the element + } + else + { + // no empty elements re-used, so add a new one + error = iExcludedWindowArray.Append(aExcludedWindow); + } + return error; + }; + +void CInvalidRegionChecker::RemoveExcludedWindow(const CTWinBase* aExcludedWindow) + { + if(iExcludedWindowArray.Count()) + { + for(TInt win=iExcludedWindowArray.Count()-1; win>=0; win--) + { + if(iExcludedWindowArray[win]==aExcludedWindow) + { + iExcludedWindowArray[win]=NULL; // Not worth deleting the array element, just mark it as NULL + return; + } + } + } + }; + +TBool CInvalidRegionChecker::ExcludedWindow(const CTWinBase* aWin) const + { + for(TInt win=iExcludedWindowArray.Count()-1; win>=0; win--) + { + if(aWin == iExcludedWindowArray[win]) + { +#if defined(InvalidRegionLogging) + { + _LIT(KText, " Excluded Window %08x"); + TLogMessageText buf; + buf.Format(KText, aWin); + BLOG_MESSAGE(buf); + } +#endif + return ETrue; + } + } + return EFalse; + } + +void CInvalidRegionChecker::ProcessWindow(const CTWinBase* aTWinBase) + { +#if defined(InvalidRegionLogging) + { + _LIT(KText, " ProcessWindow %08x %d - Child(%08x), Next(%08x), Prev(%08x)"); + TLogMessageText buf; + buf.Format(KText, aTWinBase, iInvalidRegionCount, aTWinBase->Child(), aTWinBase->NextSibling(), aTWinBase->PrevSibling()); + BLOG_MESSAGE(buf); + } +#endif + + if(aTWinBase && !ExcludedWindow(aTWinBase)) + { + RRegion invalidRegion; + static_cast(aTWinBase)->Win()->GetInvalidRegion(invalidRegion); + iInvalidRegionCount += invalidRegion.Count(); + +#if defined(InvalidRegionLogging) + if(invalidRegion.Count()) + { + _LIT(KText, " IR Found for %08x %d"); + TLogMessageText buf; + buf.Format(KText, aTWinBase, invalidRegion.Count()); + BLOG_MESSAGE(buf); + } +#endif + + invalidRegion.Close(); + + if(0==iInvalidRegionCount) + { + ProcessChildWindow(aTWinBase->Child()); + } + } + } + +void CInvalidRegionChecker::ProcessChildWindow(const CTWinBase* aTWinBase) + { + if(aTWinBase) + { + // get the first sibling window + const CTWinBase *sibling=aTWinBase; + const CTWinBase *prevSibling=sibling->PrevSibling(); + while(prevSibling) + { + sibling=prevSibling; + prevSibling=sibling->PrevSibling(); + } + // process all siblings inc. self + while(sibling && (0==iInvalidRegionCount)) + { + ProcessWindow(sibling); + sibling=sibling->NextSibling(); + } + } + } + + +void CInvalidRegionChecker::ProcessWindowGroup(const CTWinBase* aTWinBase) + { + if(aTWinBase && !ExcludedWindow(aTWinBase)) + { + ProcessChildWindow(aTWinBase->Child()); + } + } + +TInt CInvalidRegionChecker::CheckInvalidRegions(const CTWindowGroup* aGroup) + { + iInvalidRegionCount=0; + ProcessWindowGroup(aGroup); +#if defined(InvalidRegionLogging) + { + _LIT(KText, " CheckInvalidRegions %d"); + TLogMessageText buf; + buf.Format(KText, iInvalidRegionCount); + BLOG_MESSAGE(buf); + } +#endif + return iInvalidRegionCount; + } + +TInt CTRedrawTest::WaitForRedrawsToFinish(TRedrawCheckType aRedrawCheckType) + { + TInt error=KErrNone; +#define EnableCheckInvalidRegions +#if defined(EnableCheckInvalidRegions) + if(aRedrawCheckType == ECheckRedrawActiveObjectAndInvalidRegions) + { + TInt regions = 0; + TInt count = 0; + //We do not want to cycle round forever or too long, a limit of 10 has + //been added but this is arbitrary. If CTClient::WaitForRedrawsToFinish + //fails too many times then possibly something else us wrong. + do + { + count++; + error = TheClient->WaitForRedrawsToFinish(); + if(error != KErrNone) + { + RDebug::Printf("CTRedrawTest::WaitForRedrawsToFinish, error %d", error); + } + regions = iInvalidRegionChecker->CheckInvalidRegions(TheClient->iGroup); + if(regions) + { + // Give the server a chance to do the redraws because + // the Animation Scheduler is an idle priority AO + const TUint KOneSecond = 1000000; // us + User::After(KOneSecond>>2); // 0.25s + } + } while (0 < regions && 10 < count); + } + else // ECheckRedrawActiveObjectOnly +#endif // CheckInvalidRegions + { + error = TheClient->WaitForRedrawsToFinish(); + } + return error; + } + +void CTRedrawTest::RunTestCaseL(TInt /*aCurTestCase*/) + { + _LIT(Redraw0,"Redraw1"); + _LIT(Redraw1,"Redraw2"); + _LIT(Redraw2,"GetInvalid"); + _LIT(Redraw3,"MoveInvalid"); + _LIT(Redraw4,"CheckOrder"); + _LIT(Redraw5,"Defect 49554"); + _LIT(Redraw6,"Check Ordinal Position"); + _LIT(Redraw7,"Defect 99892"); + _LIT(Redraw8,"Check MMS Defect 1"); + _LIT(Redraw9,"Check MMS Defect 2"); + _LIT(Redraw10,"Redraw inactive window"); + ((CTRedrawTestStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); + + TInt testWindowDraws = -1; // to prevent RVCT 546-D warning + _LIT(KLog,"RunTestCase %d"); + if (++iTest->iState<6) + LOG_MESSAGE2(KLog,iTest->iState); + switch(iTest->iState) + { +/** +@SYMTestCaseID GRAPHICS-WSERV-0265 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test invalidation a test window and check it + redraws correctly + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Invalidate a test window causing it to redraw + +@SYMTestExpectedResults The test window redraws correctly +*/ + case 1: + ((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0265")); + iTest->LogSubTest(Redraw0); + SetBackground(TRgb::Gray256(128)); + iDrawRequestsFromTestWindow=iTestRedrawWin->DrawRequests(); + InvalidateTestWins(TRect(10,10,50,50)); + break; + case 2: + ((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0265")); + TheClient->iWs.Finish(); + WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions); + testWindowDraws=iTestRedrawWin->DrawRequests(); + if (iDrawRequestsFromTestWindow+1!=testWindowDraws) + { + LOG_MESSAGE3(_L("wrong number of test window draw requests %d %d"), + iDrawRequestsFromTestWindow, + testWindowDraws); + TEST(EFalse); + } + CheckRedrawWindows(); + ++iWinContent; + iTestRedrawWin->Reset(); + iBaseRedrawWin->Reset(); + TheClient->Flush(); + WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0266 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test invalidation a test window and check it + redraws correctly + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Invalidate a test window causing it to redraw + +@SYMTestExpectedResults The test window redraws correctly +*/ + case 3: + ((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0266")); + iTest->LogSubTest(Redraw1); + InvalidateTestWins(TRect(1,1,150,20)); + TheClient->iWs.Finish(); + WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions); + break; + case 4: + ((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0266")); + CheckRedrawWindows(); + ++iWinContent; + iTestRedrawWin->Reset(); + iBaseRedrawWin->Reset(); + TheClient->iWs.Flush(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0267 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test invalidation a region of a test window and check it + redraws correctly + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Invalidate a region of a test window causing it to redraw + +@SYMTestExpectedResults The test window redraws correctly +*/ + case 5: + ((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0267")); + iTest->LogSubTest(Redraw2); + GetInvalidRegionTestsL(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0268 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test moving an invalid region of a test window and check it + redraws correctly + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Move an invalid region of a test window causing it to redraw + +@SYMTestExpectedResults The test window redraws correctly +*/ + case 6: + ((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0268")); + iTest->LogSubTest(Redraw3); + MoveInvalidAreaL(); + break; + +/** +@SYMTestCaseID GRAPHICS-WSERV-0270 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test the order redraws occur in a test window + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Set up a number of redraws for a test window and + invalidate it + +@SYMTestExpectedResults The order the test window redraws occur is correct +*/ + + case 7: + ((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0270")); + iTest->LogSubTest(Redraw4); + CheckOrderL(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0271 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test defect INC049554L does not occur + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Check that defect INC049554L does not occur when a test + window is redrawn + +@SYMTestExpectedResults Defect INC049554L does not occur +*/ + case 8: + ((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0271")); + iTest->LogSubTest(Redraw5); + CheckDefectINC049554L(); + break; +/** + @SYMTestCaseID GRAPHICS-WSERV-0359 + + @SYMDEF PDEF099892 + + @SYMTestCaseDesc Ensure that changing the Ordinal postion of an Invisible Window + does not affect the Transparent Window or Opaque Window redrawing. + + @SYMTestPriority Medium + + @SYMTestStatus Implemented + + @SYMTestActions Create an Invisible Window + Create a Transparent Window + Inside the Begin and End Redraw for the Transparent Window, + change the Ordinal Position for Invisible Window to move it + front to the Transparent Window. + + @SYMTestExpectedResults Changing the Ordinal postion for Invisible Window should not + affect the Transparent Window redrawing. +*/ + case 9: + ((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0359")); + iTest->LogSubTest(Redraw6); + CheckOrdinalPositionDefectL(); + break; +/** + @SYMTestCaseID GRAPHICS-WSERV-0360 + + @SYMDEF PDEF099892 + + @SYMTestCaseDesc Ensure that changing the Ordinal postion of an Invisible window + does not affect the Transparent Window or Opaque Window redrawing. + + @SYMTestPriority Medium + + @SYMTestStatus Implemented + + @SYMTestActions Create an Invisible Window + Create an Opaque Window + Create a Transparent Window + Invisible Window is Behind the Opaque Window + and Opaque Window is Behind the Transparent Window. + While drawing the Transparent Window, move the Invisible Window + to the Front of Opaque Window. And while Drawing the Opaque Window + move the Invisible Window again Behind the Opaque Window. + + @SYMTestExpectedResults Changing the Ordinal postion for Invisible window should not + affect the Transparent Window or Opaque Window redrawing. +*/ + case 10: + ((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0360")); + iTest->LogSubTest(Redraw7); + CheckDefectPDEF099892L(); + break; +/** + @SYMTestCaseID GRAPHICS-WSERV-0361 + + @SYMDEF DEF101548 + + @SYMTestCaseDesc Ensure that changing the Ordinal postion of an Invisible window + does not affect the Transparent Window redrawing. + + @SYMTestPriority Low + + @SYMTestStatus Implemented + + @SYMTestActions Create an Invisible Window + Create an Opaque Window + Create a Blank Window + Create a Transparent Window + Invisible Window is Behind the Opaque Window + Opaque Window is Behind the Blank Window + and Blank Window is Behind the Transparent Window. + While drawing the Transparent Window, move the Invisible Window + to the Front/Back to one or all the Other Windows. + Also move the Blank Window Front/Back to the Transparent Window for other scenario. + + @SYMTestExpectedResults Changing the Ordinal postion for Invisible window should not + affect the Transparent Window redrawing. +*/ + case 11: + ((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0361")); + iTest->LogSubTest(Redraw8); + CheckMMSDefectL(EFalse); + case 12: + ((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0361")); + iTest->LogSubTest(Redraw9); + CheckMMSDefectL(ETrue);// In this case we will move Blank Window Front/Back to the Transparent Window to Test Defect PDEF099892 + break; + case 13: + iTest->LogSubTest(Redraw10); +/** + @SYMTestCaseID GRAPHICS-WSERV-0362 + + @SYMDEF PDEF117784 + + @SYMTestCaseDesc Ensure that drawing request for non active window will not + impact following redrawings + + @SYMTestPriority High + + @SYMTestStatus Implemented + + + @SYMTestActions Create test window as in active + Create base window in active mode. + + The test window is receiving a draw request before it activates, + doing an empty redraw, + Activate test window + Draw test window properly in response to the next redraw request. + + @SYMTestExpectedResults The next redraw request will be received and it will be drawn correctly. +*/ + ((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0362")); + CheckDefectPDEF117784L(); + break; + case 14: + ((CTRedrawTestStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + ((CTRedrawTestStep*)iStep)->CloseTMSGraphicsStep(); + TestComplete(); + break; + default: + TEST(EFalse); + } + ((CTRedrawTestStep*)iStep)->RecordTestResultL(); + } + +__WS_CONSTRUCT_STEP__(RedrawTest) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TREDRAW.H --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TREDRAW.H Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,239 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef __TREDRAW_H__ +#define __TREDRAW_H__ + +#include +#include +#include "../tlib/testbase.h" +#include "AUTO.H" +#include "TScreenModeScaling.h" +#include "TGraphicsHarness.h" + +class CTRedrawTest; + +/** + * Abstract base class to draw a pattern into a window. + * + * This provides a default Draw() implementation which + * DOES NOT set the clipping region before drawing. + */ +class CRedrawWindow : public CTWin + { + friend class CTRedrawTest; +public: + enum TDrawPattern + { + EDrawGraphPaperlHatched = 0, + EDrawSlantingHatched, + EDrawCenteredRectangle + }; +public: + CRedrawWindow(CTRedrawTest* aTest); + ~CRedrawWindow(); +public: + /* + * Draw the window, counting the number of calls. + * @post DrawRequests() returns a value increased by 1. + */ + virtual void Reset(); + virtual void PrepareInvalidation(const TRect& aRect) = 0; + virtual void PerformInvalidation() = 0; + //Virtual function from CTBaseWin + void Draw(); +public: + void ActivateAndDraw(TInt aPattern); + void DrawPattern(TInt aPattern); + void VisibleRegion(RRegion& aRegion); + void ValidateAndClear(); + void ActivateAndDraw(TInt aPattern,TRegion* aRegion); + TInt DrawRequests() const; +protected: + void ReceivedDrawRequest(); + TPoint iOffset; + RRegion iInvalid; + CTRedrawTest *iTest; +private: + TInt iDrawRequests; + }; + +/** + * Concrete class to draw a pattern into a window. + * + */ +class CReferenceComparisonRedrawWindow : public CRedrawWindow + { +public: + CReferenceComparisonRedrawWindow(CTRedrawTest* aTest); +public: + // from CRedrawWindow + void PrepareInvalidation(const TRect& aRect); + void PerformInvalidation(); + }; + +class CRedrawWindow2 : public CRedrawWindow + { +public: + CRedrawWindow2(CTRedrawTest* aTest); +public: + //Virtual function from CTBaseWin overridden in CRedrawWindow + void Draw(); + //Virtual function from CRedrawWindow + void Reset(); + // from CRedrawWindow + void PrepareInvalidation(const TRect& aRect); + void PerformInvalidation(); +private: + TBool iClipped; + }; + +class CRedrawWindow3 : public CRedrawWindow + { +public: + CRedrawWindow3(CTRedrawTest* aTest); +public: + //Virtual function from CTBaseWin overridden in CRedrawWindow + void Draw(); + // from CRedrawWindow + void PrepareInvalidation(const TRect& aRect); + void PerformInvalidation(); +public: + void SetUp1L(TPoint pos,TSize size,CTWinBase* parent,CWindowGc& aGc); + void Activate(); + void Redraw(const TRect& aRect); +protected: + TBool isActive; + }; + +class CTRedrawOrderWindow : public CTWin + { +public: + CTRedrawOrderWindow(TInt aOrder, CTRedrawTest *aTest); + static CTRedrawOrderWindow* NewLC(TInt aOrder,CTWinBase* aParent,const TPoint& aPos,const TSize& aSize,CTRedrawTest* aTest); + inline static TInt RedrawNumber() {return iRedrawNumber;} + static void ResetRedrawNumber(); + void Redraw(const TRect& aRect); + void Draw(); +private: + CTRedrawTest* iTest; + TInt iOrder; + static TInt iRedrawNumber; + }; + +class CTCheckDefectWin : public CBasicWin + { +public: + static CTCheckDefectWin *NewL(TPoint aPos,TSize aWinSize); +private: + CTCheckDefectWin(){} + }; + +class CInvalidRegionChecker : public CBase + { +public: + CInvalidRegionChecker(const CTRedrawTest& aGraphicsTest); + ~CInvalidRegionChecker(); + + TInt CheckInvalidRegions(const CTWindowGroup* aGroup); + TBool ExcludedWindow(const CTWinBase* aTWinBase) const; + TInt AddExcludedWindow(const CTWinBase* aExcludedWindow); + void RemoveExcludedWindow(const CTWinBase* aExcludedWindow); +private: + void ProcessWindowGroup(const CTWinBase* aTWinBase); + void ProcessChildWindow(const CTWinBase* aTWinBase); + void ProcessWindow(const CTWinBase* aTWinBase); +private: + TInt iInvalidRegionCount; + RPointerArray iExcludedWindowArray; + const CTRedrawTest& iGraphicsTest; + }; + +class CTRedrawTest : public CTWsGraphicsBase + { +public: + CTRedrawTest(CTestStep* aStep); + ~CTRedrawTest(); + void doDestruct(); + void ConstructL(); + void CheckRedrawWindows(); + void ProcessBaseInvalidate(); + void SetBackground(const TRgb& aRgb); + void DumpRegion(const TRegion& aRegion); + inline TInt WinContent(); + void InvalidateTestWins(const TRect& aRect); + void MoveInvalidAreaL(); + void TestGetInvalidRegionL(const CArrayFixFlat* aRectList); + void GetInvalidRegionTestsL(); + void CompareRegionsL(const TRegion& aRegion1,const TRegion& aRegion2); + void Failed(TInt aOrder); + void CheckOrderL(); + void TestRect(); + void CheckDefectINC049554L(); + void CheckDefectPDEF099892L(); + void CheckOrdinalPositionDefectL(); + void CheckDefectPDEF117784L(); + void CheckMMSDefectL(TBool aMoveBlankWindow); + void ConstructAndSetBlankWinLC(RBlankWindow& aWindow, TSize aSize, TPoint aPoint=TPoint(), + TRgb aBackgroundColor=TRgb(0,0,0)); + void ConstructWindowLC(RWindow& aWindow, TSize aSize, TPoint aPoint=TPoint(), + TRgb aBackgroundColor=TRgb(255,255,255), TBool aTransparencyByAlpha=EFalse, + TDisplayMode aDisplayMode=EColor64K); + void ActivateAndSetGc(CWindowGc& aGc, RWindow& aWindow, CGraphicsContext::TBrushStyle aBrushStyle=CGraphicsContext::ESolidBrush, TRgb aBrushColor=TRgb(0,0,0), + CGraphicsContext::TPenStyle aPenStyle=CGraphicsContext::ENullPen, TRgb aPenColor=TRgb(0,0,0)); + void DrawWin(CWindowGc& aGc, RWindow& aWin, TSize winSize, TRgb aRectColor1, TRgb aRectColor2, TInt aNewOrdinalPos=0, RWindow* aWinToMove=NULL, TBool aDrawAllPixels=EFalse); + enum TRedrawCheckType + { + ECheckRedrawActiveObjectOnly, + ECheckRedrawActiveObjectAndInvalidRegions + }; + TInt WaitForRedrawsToFinish(TRedrawCheckType aRedrawCheckType); +protected: +//from CTGraphicsStep + virtual void RunTestCaseL(TInt aCurTestCase); +private: + void ValidateAndClear(TestWindow *aWin); +private: + TSize iWinSize; + TBool iDoCheck; + TInt iRedrawNo; + CReferenceComparisonRedrawWindow *iBaseRedrawWin; + CRedrawWindow2 *iTestRedrawWin; + CBlankWindow *iBaseChildWin; + CBlankWindow *iTestChildWin; + TInt iDrawRequestsFromTestWindow; + TInt iWinContent; + CInvalidRegionChecker *iInvalidRegionChecker; + }; + +class CTRedrawTestStep : public CTGraphicsStep + { +public: + CTRedrawTestStep(); +protected: + //from CTGraphicsStep + virtual CTGraphicsBase* CreateTestL(); + }; + +_LIT(KTRedrawTestStep,"TRedrawTest"); + + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TREDRSTR.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TREDRSTR.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,3947 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Test redraw storing +// Tests Storing the Redraw command mechanism in the window server. +// The first time a window is redrawn its commands are stored. When +// the window needs to be redrawn, the stored commands will be used +// rather than issue a redraw request to the client. +// The principle behind this test is to do lots of different types of drawing to a window, +// invalidate the window and test that no redrawing occurred, instead the stored commands +// should be used to generate the content of the window. +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include "TREDRSTR.H" +#include "colorblender.h" + +//#define LOGGING on + +_LIT(KColorUnmatchedFormat, "Check failed, expected color value: 0x%08x, got: 0x%08x"); +#define TEST_COLOR_MATCH(aExpected, aActual) \ + TEST(aExpected == aActual); \ + if(aExpected != aActual) \ + LOG_MESSAGE3(KColorUnmatchedFormat, aExpected.Value(), aActual.Value()) + +/*CPartialRedrawWin*/ +void CPartialRedrawWin::Init() + { + iClientDrawn = EFalse; + iClientCanDraw = ETrue; + Win()->SetRequiredDisplayMode(EColor16MA); + Win()->SetTransparencyAlphaChannel(); + Win()->SetBackgroundColor(TRgb(127,127,127,0)); + } + +void CPartialRedrawWin::Draw() + { + DoDraw(*iGc); + } + +void CPartialRedrawWin::DrawToBmp(CGraphicsContext& aGc) + { + DoDraw(aGc); + } + +void CPartialRedrawWin::DoDraw(CGraphicsContext& aGc) + { + if(!iClientCanDraw) return; + iClientDrawn = ETrue; + CPartialRedrawWin::DrawRects(aGc, iSize, TPoint(0,0), ETrue, EPartialRedraw_Unknown); + } + +/*static*/ +void CPartialRedrawWin::DrawRects(CGraphicsContext& aGc, TSize aSize, TPoint aPosition, + TBool aIsFullRedraw, TPartialRedrawType aPartialRedrawType) + { + aGc.SetPenStyle(CGraphicsContext::ESolidPen); + aGc.SetPenColor(TRgb::Gray256(0)); + aGc.SetBrushStyle(CGraphicsContext::ESolidBrush); + if(aIsFullRedraw) + { + aGc.SetBrushColor(TRgb(200,200,200,127)); + aGc.DrawRect(TRect(aPosition, aSize)); + } + else if (aPartialRedrawType!=EPartialRedraw_PreserveStoredCmds) + { + aGc.SetBrushColor(TRgb(200,200,200,127)); // same color as original background. + aGc.SetPenStyle(CGraphicsContext::ENullPen); + aGc.DrawRect(TRect(TPoint(10,10) + aPosition, aSize - TSize(20,20))); + aGc.SetPenStyle(CGraphicsContext::ESolidPen); + aGc.SetPenColor(TRgb::Gray256(0)); + } + TSize r1 = TSize(aSize.iWidth/3, aSize.iHeight/5); + TSize r2 = TSize(aSize.iWidth/9, 2*aSize.iHeight/3); + aGc.SetBrushColor(TRgb(255, 0, 0, 127)); + aGc.DrawEllipse(TRect(TPoint(aSize.iWidth/3, aSize.iHeight/5)+aPosition, r1)); + aGc.SetBrushColor(TRgb(0, 255, 0, 127)); + aGc.DrawEllipse(TRect(TPoint(aSize.iWidth/3, 3*aSize.iHeight/5)+aPosition, r1)); + aGc.SetBrushColor(TRgb(0, 0, 255, 127)); + aGc.DrawEllipse(TRect(TPoint(4*aSize.iWidth/9, aSize.iHeight/6)+aPosition, r2)); + } + +void CPartialRedrawWin::DrawPartial(TPartialRedrawType aPartialRedrawType) + { + TRect rect = TRect(TPoint(10,10), iSize - TSize(20,20)); + Invalidate(rect); + Win()->BeginRedraw(rect); + iGc->Activate(*Win()); + CPartialRedrawWin::DrawRects(*iGc, iSize, TPoint(0,0), EFalse, aPartialRedrawType); + iGc->Deactivate(); + Win()->EndRedraw(); + } +void CPartialRedrawWin::RedrawSubRectWithBitmapL(TRgb aBitmapColour) + { + TInt bitmapWidth = Win()->Size().iWidth - 20; + TInt bitmapHeight = Win()->Size().iHeight - 20; + TSize bitmapSize(bitmapWidth, bitmapHeight); + + CFbsBitmap* fbsBitmap = new(ELeave) CFbsBitmap(); + CleanupStack::PushL(fbsBitmap); + User::LeaveIfError(fbsBitmap->Create(bitmapSize, EColor16MU)); + + // ensure colour is opaque + aBitmapColour.SetAlpha(255); + + // draw on the bitmap + TBitmapUtil bmpUtil(fbsBitmap); + bmpUtil.Begin(TPoint(0, 0)); + TInt row, col; + for(row = 0; row < bitmapWidth; ++row) + { + bmpUtil.SetPos(TPoint(row, 0)); + for(col = 0; col < bitmapHeight; ++col) + { // diagonal stripes + if ( ((col + row) % 8) < 4 ) + { // colour + bmpUtil.SetPixel(aBitmapColour.Color16M()); + } + else + { // semi-transparent white + TRgb white(255, 255, 255, 128); + bmpUtil.SetPixel(white.Color16M()); + } + bmpUtil.IncYPos(); + } + } + bmpUtil.End(); + + // send bitmap to screen + TRect rect = TRect(TPoint(10,10), bitmapSize); + Invalidate(rect); + Win()->BeginRedraw(rect); + iGc->Activate(*Win()); + iGc->DrawBitmap(rect, fbsBitmap); + iGc->Deactivate(); + Win()->EndRedraw(); + CleanupStack::PopAndDestroy(fbsBitmap); + } + +/* CResetRedrawStoreWin */ + +const TInt KResetRedrawMaxAnimState=4; + +void CResetRedrawStoreWin::PreSetSize(const TSize &aSize) +// Sets the size variable so draw code using it will use the new size +// before the window has actually been resized + { + iSize=aSize; + } + +void CResetRedrawStoreWin::Draw() + { + DoDraw(*iGc); + } + +void CResetRedrawStoreWin::DoDraw(CGraphicsContext& aGc) const + { + aGc.SetPenStyle(CGraphicsContext::ESolidPen); + aGc.SetPenColor(KRgbBlack); + aGc.SetBrushStyle(CGraphicsContext::ESolidBrush); + aGc.SetBrushColor(TRgb(200,200,200,127)); + aGc.DrawRect(TRect(iSize)); + TSize r1(iSize.iWidth/3, iSize.iHeight/5); + TSize r2(iSize.iWidth/9, 2*iSize.iHeight/3); + aGc.SetBrushColor(TRgb(255, 0, 0, 127)); + aGc.DrawEllipse(TRect(TPoint(iSize.iWidth/3, iSize.iHeight/5), r1)); + aGc.SetBrushColor(TRgb(0, 255, 0, 127)); + aGc.DrawEllipse(TRect(TPoint(iSize.iWidth/3, 3*iSize.iHeight/5), r1)); + aGc.SetBrushColor(TRgb(0, 0, 255, 127)); + aGc.DrawEllipse(TRect(TPoint(4*iSize.iWidth/9, iSize.iHeight/6), r2)); + DoDrawAnim(aGc); + } + +TRect CResetRedrawStoreWin::AnimRect() const + { + if (iUpdateInRedraw) + { + TInt row=iAnimState/iSize.iWidth; + TInt col=iAnimState-row*iSize.iWidth; + return(TRect(col,row,col+4,row+4)); + } + return(TRect(iSize.iWidth/6,iSize.iHeight/4,iSize.iWidth*5/6,iSize.iHeight*3/4)); + } + +void CResetRedrawStoreWin::DoDrawAnim(CGraphicsContext& aGc) const + { + if (iAnimState>0) + { + aGc.SetBrushColor(KRgbBlue); + aGc.SetPenStyle(CGraphicsContext::ENullPen); + aGc.SetBrushStyle(CGraphicsContext::ESolidBrush); + TInt animColState=iAnimState%KResetRedrawMaxAnimState; + TRgb animCol(255*animColState/KResetRedrawMaxAnimState,0,255*(KResetRedrawMaxAnimState-animColState)/KResetRedrawMaxAnimState); + aGc.SetBrushColor(animCol); + aGc.DrawRect(AnimRect()); + } + } + +CResetRedrawStoreWin::~CResetRedrawStoreWin() + { + delete iExtraGc; + } + +void CResetRedrawStoreWin::SetUpdateInRedraw(TBool aUpdateInRedraw) + { + iUpdateInRedraw=aUpdateInRedraw; + } + +void CResetRedrawStoreWin::SetKeepGcActive(TBool aState) + { + if (iKeepGcActive!=aState) + { + iKeepGcActive=aState; + if (iKeepGcActive) + { + iExtraGc=new(ELeave) CWindowGc(TheClient->iScreen); + iExtraGc->Construct(); + iExtraGc->Activate(*Win()); + } + else + { + iExtraGc->Deactivate(); + delete iExtraGc; + iExtraGc=NULL; + } + } + } + +TBool CResetRedrawStoreWin::Failed() const + { + return iFailed; + } + +void CResetRedrawStoreWin::UpdateAnim(TInt aSteps) + { + TRect oldAnimRect(AnimRect()); + iAnimState+=aSteps; + if (iUpdateInRedraw) + { + if (iAnimState>=(iSize.iWidth*iSize.iHeight)) + { + iFailed=ETrue; + } + } + else if (iAnimState>KResetRedrawMaxAnimState) + { + iAnimState-=KResetRedrawMaxAnimState; + } + CWindowGc *gc=Gc(); + if (iUpdateInRedraw) + { + Win()->Invalidate(oldAnimRect); + Win()->BeginRedraw(oldAnimRect); + if (iKeepGcActive) + { + DoDraw(*iExtraGc); + } + else + { + gc->Activate(*Win()); + DoDraw(*gc); + gc->Deactivate(); + } + Win()->EndRedraw(); + TRect animRect=AnimRect(); + Win()->Invalidate(animRect); + Win()->BeginRedraw(animRect); + } + if (iKeepGcActive) + DoDrawAnim(*iExtraGc); + else + { + gc->Activate(*Win()); + DoDrawAnim(*gc); + gc->Deactivate(); + } + if (iUpdateInRedraw) + Win()->EndRedraw(); + } + +void CTRedrawStoring::GetTestWinSizeAndPos(TInt aWinIndex, TPoint& aPos, TSize& aSize) const + { + switch(aWinIndex) + { + case 0: + // Centered window half the width of the parent window + aSize.iWidth=iWinSize.iWidth/2; + aSize.iHeight=iWinSize.iHeight/2; + aPos.iX=iWinSize.iWidth/4; + aPos.iY=iWinSize.iHeight/4; + break; + case 1: + // 1/3rd parent window size window positioned 1/3rd spare size in from the bottom right + aSize.iWidth=iWinSize.iWidth/3; + aSize.iHeight=iWinSize.iHeight/3; + aPos.iX=(iWinSize.iWidth-aSize.iWidth)*2/3; + aPos.iY=(iWinSize.iHeight-aSize.iHeight)*2/3; + break; + } + } + +/*CRedrawStoreWin*/ + +void CRedrawStoreWin::Draw() + { + if (iTest->iQueueTest) + iDrawOrder=iTest->iDrawOrder++; + iTest->DoDrawingL(iGc); + } + + +/*CNoDrawWin*/ + +void CNoDrawWin::Draw() + { + //Deliberately have no drawing + } + +/*CBitmapMaskedWin*/ +CBitmapMaskedWin* CBitmapMaskedWin::NewL(CFbsBitmap* aFbsBitmap,CFbsBitmap* aFbsMaskBitmap, + CWsBitmap* aWsBitmap,CWsBitmap* aWsMaskBitmap, + TRgb aBackground,TRect aRect,TBool aInvertMask,TBool aWsFbs) + { + CBitmapMaskedWin* self=new(ELeave) CBitmapMaskedWin(aFbsBitmap,aFbsMaskBitmap,aWsBitmap, + aWsMaskBitmap,aRect,aInvertMask,aWsFbs); + CleanupStack::PushL(self); + self->ConstructL(*TheClient->iGroup); + self->AssignGC(*TheClient->iGc); + self->BaseWin()->SetRequiredDisplayMode(EColor16MU); + self->Win()->SetBackgroundColor(aBackground); + CleanupStack::Pop(self); + return self; + } + +CBitmapMaskedWin::~CBitmapMaskedWin() + { + delete iFbsBitmap; + delete iFbsMaskBitmap; + delete iWsBitmap; + if (!iWsFbs) + { + delete iWsMaskBitmap; + } + } + +void CBitmapMaskedWin::SetDestRectSize(const TSize aSize) + { + iRect.SetSize(aSize); + } + +void CBitmapMaskedWin::Draw() + { + if (iWsFbs) + { + TheClient->iGc->DrawBitmapMasked(iRect,iWsBitmap,TRect(iWsBitmap->SizeInPixels()),iWsMaskBitmap,iInvertMask); + } + else + { + TheClient->iGc->DrawBitmapMasked(iRect,iFbsBitmap,TRect(iFbsBitmap->SizeInPixels()),iFbsMaskBitmap,iInvertMask); + } + } + + +/* TESTCASE: DEF095130 + * TITLE: Redraw store for Alpha Channel Transparency. + * IMPORTANCE: 1 + * + * ACTION: a. Creates a window disable the redrawstore. Set the Alpha channel + * Transparency. + * + * RESULT: Redraw store should be enabled and should redraw correctly. + */ +void CTRedrawStoring::DoRedrawStoreAlphaChannelTransTest() + { + // Create testwin and disable the redraw store + // Set alpha transparency and check if redraw store is enabled + RWindow win(TheClient->iWs); + CleanupClosePushL(win); + User::LeaveIfError(win.Construct(*TheClient->iGroup->GroupWin(), ENullWsHandle)); + win.SetExtent(iWinPos, iWinSize); + win.SetRequiredDisplayMode(EColor256); + win.EnableRedrawStore(EFalse); + win.SetTransparencyAlphaChannel(); + TEST(win.IsRedrawStoreEnabled()); + CleanupStack::PopAndDestroy(&win); + + // Create a window and disable the redraw store + // Set alpha transparency and check if redraw store is enabled + // and check if redraw storing is done correctly + RWindow wint(TheClient->iWs); + CleanupClosePushL(wint); + User::LeaveIfError(wint.Construct(*TheClient->iGroup->GroupWin(), ENullWsHandle)); + wint.SetExtent(iWinPos, iWinSize); + wint.SetRequiredDisplayMode(iTestDisplayMode); + wint.SetBackgroundColor(TRgb(255,255,255)); + wint.SetShadowDisabled(ETrue); + wint.EnableRedrawStore(EFalse); + wint.SetTransparencyAlphaChannel(); + wint.Activate(); + wint.BeginRedraw(); + TheClient->iGc->Activate(wint); + DoDrawingL(23,TheClient->iGc,ETrue); + TheClient->iGc->Deactivate(); + wint.EndRedraw(); + + DoDrawingL(23,iCheckGc,EFalse); + iCheckWin->BackedUpWin()->UpdateScreen(); + + iBlankWin.SetOrdinalPosition(0); + iBlankWin.SetVisible(ETrue); + iBlankWin.SetVisible(EFalse); + + TheClient->Flush(); + TheClient->WaitForRedrawsToFinish(); + TInt gap = 5; + const TSize scrSize(TheClient->iScreen->SizeInPixels()); + TEST(TheClient->iScreen->RectCompare(TRect(TPoint(scrSize.iWidth-2*iWinSize.iWidth-gap,0),iWinSize),TRect(TPoint(scrSize.iWidth-iWinSize.iWidth,0),iWinSize))); + CleanupStack::PopAndDestroy(&wint); + } + +/* TESTCASE: PDEF091091 + * TITLE: Redraw in between begin and end redraw. + * IMPORTANCE: 1 + * + * ACTION: Draws some content to test window in its redraw. Then starts drawing + * to test window by using BeginRedraw and EndRedraw methods. A blank window in + * front of test wndow is made visible and invisible in between BeginRedraw and + * EndRedraw. + * + * + * RESULT: When the window is made visible again redraw should ot happen. + */ +void CTRedrawStoring::DoBeginEndRedraw() + { + // Check whether redrawstoring is working + RedrawWindows(); + iBlankWin.SetVisible(ETrue); + iBlankWin.SetVisible(EFalse); + iClientDidDraw = EFalse; + CheckWindowsMatch(); + TEST(!iClientDidDraw); + if(iClientDidDraw != 0) + INFO_PRINTF3(_L("iClientDidDraw Expected value %d Actual value %d"), 0, iClientDidDraw); + + // Change the size and make the blank window visible + // Then start drawing by BeginRedraw and Activating its gc + // Now make the blank window visible + iTestWin->Win()->Invalidate(); + iBlankWin.SetSize(TSize(40,40)); + iBlankWin.SetVisible(ETrue); + + CWindowGc* gc = iTestWin->Gc(); + RWindow* win = iTestWin->Win(); + win->BeginRedraw(); + gc->Activate(*win); + gc->SetPenStyle(CGraphicsContext::ESolidPen); + gc->SetPenColor(TRgb(0,0,0)); + gc->SetPenSize(TSize(1,1)); + gc->DrawLine(TPoint(iWinSize.iWidth,0), TPoint(0, iWinSize.iHeight)); + iBlankWin.SetVisible(EFalse); + gc->DrawLine(TPoint(0,0), TPoint(iWinSize.iWidth, iWinSize.iHeight)); + iBlankWin.SetVisible(ETrue); + gc->DrawLine(TPoint(iWinSize.iWidth/2,0), TPoint(iWinSize.iWidth/2, iWinSize.iHeight)); + gc->DrawLine(TPoint(0,iWinSize.iHeight/2), TPoint(iWinSize.iWidth, iWinSize.iHeight/2)); + + iCheckGc->Clear(); + iCheckGc->SetPenStyle(CGraphicsContext::ESolidPen); + iCheckGc->SetPenColor(TRgb(0,0,0)); + iCheckGc->SetPenSize(TSize(1,1)); + iCheckGc->DrawLine(TPoint(iWinSize.iWidth/2,0), TPoint(iWinSize.iWidth/2, iWinSize.iHeight)); + iCheckGc->DrawLine(TPoint(0,iWinSize.iHeight/2), TPoint(iWinSize.iWidth, iWinSize.iHeight/2)); + iCheckGc->DrawLine(TPoint(0,0), TPoint(iWinSize.iWidth, iWinSize.iHeight)); + iCheckGc->DrawLine(TPoint(iWinSize.iWidth,0), TPoint(0, iWinSize.iHeight)); + iCheckWin->BackedUpWin()->UpdateScreen(); + + iBlankWin.SetVisible(EFalse); + + // This is to check if any redraw happened in between Begin and EndRedraw + /* Andy commented this out. I'm not entirely sure what it's doing. We just redrew a window + while part of it was hidden, and then revealed the hidden part before calling EndRedraw, and + this is testing that the new draw commands for the region revealed are not processed, or are not + processed correctly. In the new window server they are processed and the region checked matches + the test bitmap. */ +// TInt gap = 5; +// const TSize scrSize(TheClient->iScreen->SizeInPixels()); +// TBool failed=DoCheckRect(TPoint(scrSize.iWidth-2*iWinSize.iWidth-gap,0),TPoint(scrSize.iWidth-iWinSize.iWidth,0),TSize(40,40)); + gc->Deactivate(); + win->EndRedraw(); +/* if (failed) + { + TEST(EFalse); + return; + } */ + + // This is to check redraw is done after EndRedraw has called. + iBlankWin.SetVisible(ETrue); + iBlankWin.SetVisible(EFalse); + CheckRect(iTestWin,iCheckWin,TRect(TSize(40,40)),_L("CTRedrawStoring::DoBeginEndRedraw")); + // Finally bring every thing to normal + RedrawWindows(); + CheckWindowsMatch(); + iBlankWin.SetSize(iWinSize); + } +/** +@SYMTestCaseID GRAPHICS-WSERV-00XX-0006 + +@SYMDEF INC087721 + +@SYMTestCaseDesc Invisible Redraw Storing Test + Tests the non-redraw storing commands are stored/executed properly, + in presence of partial redraw commands. + When a semi-transparent window ST0 sits on top of an opaque window OW1, + you want the screen to be drawn as OW1, then alpha-blend ST0 once. + When ST0 is set to invisible, you want the screen to be drawn as OW1, + i.e. window server to not issue redraw requests for ST0. + When an opaque window OW2 sites on top of an opaque window OW1, + you want the screen to be drawn as OW1, then over-print OW2 once. + When OW2 is set invisible, you want the screen to be drawn as OW1, + i.e. window server to not issue redraw requests for OW2. + The reference document specifies that invisible windows do not receive + any window server events, i.e. no redraw requests. + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Makes invisible a window with an invalid area + +@SYMTestExpectedResults When the window is made visible again it should display correctly + */ +void CTRedrawStoring::DoInvisibleRedrawStoreTestL( TBool aUseTransparency ) + { + /* + * Obtain the color of a particular reference pixel which will be used for + * comparison later on when the blue test window is added covering it. + */ + const TPoint referencePixel(iWinPos+TPoint(50,50)); + TRgb backgroundReferenceColor; + TheClient->Flush(); + TheClient->WaitForRedrawsToFinish(); + TheClient->iWs.Finish(); + TheClient->iScreen->GetPixel(backgroundReferenceColor, referencePixel); + /* + * Add a blue test window: transparent or opaque given parameter aUseTransparency + */ + CInvisibleRedrawWin* testWin=new(ELeave) CInvisibleRedrawWin; + CleanupStack::PushL(testWin); + testWin->ConstructL(*TheClient->iGroup); + testWin->AssignGC(*TheClient->iGc); + testWin->SetExt(iWinPos+TPoint(25,25),TSize(300,200)); + testWin->Win()->SetRequiredDisplayMode(iTestDisplayMode); + testWin->Win()->SetShadowDisabled(ETrue); + if (aUseTransparency) + { + const TInt err = testWin->MakeTransparent(); + if (err) + { + TEST(EFalse); + _LIT(KLog,"Failed to make the window transparent!"); + LOG_MESSAGE(KLog); + } + } + /* + * Make the blue testWin window appear on top of the window at iWinPos + */ + testWin->Win()->Activate(); + testWin->Win()->Invalidate(); + TheClient->iWs.Finish(); + TheClient->WaitForRedrawsToFinish(); + /* + * By making the blue window invisible and then visible we can check to see if + * the window gets re-drawn correctly. Redraws should not come in during the + * invisible phase, because "invisible windows do not receive any window server events" + * but should come in during the visible phase. The background should have been + * drawn first and then the blue window alpha blended exactly once. + */ + testWin->MakeVisible(EFalse); + testWin->Win()->Invalidate(); + testWin->MakeVisible(ETrue); + testWin->Win()->Invalidate(); + /* + * Now check the screen has the desired color at the reference pixel. + */ + TRgb actualColor; + TheClient->Flush(); + TheClient->WaitForRedrawsToFinish(); + TheClient->iWs.Finish(); + TheClient->iScreen->GetPixel(actualColor, referencePixel); + if (aUseTransparency) + { + CColorBlender* blender = CColorBlender::NewLC(iTestDisplayMode); + blender->SetInitialColor(backgroundReferenceColor); + blender->Blend(TRgb(0, 0, 255, 127)); //the blue background of the window + const TRgb expectedColor(blender->Color()); + TEST_COLOR_MATCH(expectedColor, actualColor); + CleanupStack::PopAndDestroy(blender); + } + else + { + TEST_COLOR_MATCH(KRgbBlue, actualColor); + } + CleanupStack::PopAndDestroy(testWin); + } + +/*CInvisibleRedrawWin*/ +CInvisibleRedrawWin::CInvisibleRedrawWin() + : iVisible( ETrue ) + {} + +TInt CInvisibleRedrawWin::MakeTransparent() + { + const TInt err = Win()->SetTransparencyAlphaChannel(); + if(!err) + { + Win()->SetBackgroundColor(TRgb(0, 0, 0, 0)); + iTransparent = ETrue; + } + return err; + } + +void CInvisibleRedrawWin::MakeVisible( TBool aVisible ) + { + iVisible = aVisible; + SetVisible( aVisible ); + } + +void CInvisibleRedrawWin::Redraw() + { + iWin.BeginRedraw(); + DrawIfVisible(); + iWin.EndRedraw(); + } + +void CInvisibleRedrawWin::Redraw( const TRect &aRect ) + { + iWin.BeginRedraw( aRect ); + DrawIfVisible(); + iWin.EndRedraw(); + } + +void CInvisibleRedrawWin::DrawIfVisible() + { + if (iVisible) + { + iGc->Activate( iWin ); + iGc->SetBrushStyle( CGraphicsContext::ESolidBrush ); + if(iTransparent) + iGc->SetBrushColor( TRgb(0, 0, 255, 127) ); + else + iGc->SetBrushColor( KRgbBlue ); + iGc->Clear(); + iGc->Deactivate(); + } + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-0498 + +@SYMDEF INC135845 + +@SYMTestCaseDesc UseBrushPattern test + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Create a bitmap and use as brush. bitmap deleted immediately to + prove that wserv retains the handle + +@SYMTestExpectedResults No Panic BITGDI 13 + */ + +void CTRedrawStoring::DoBrushDrawTestL() + { + CBrushDrawWin* testWin=new(ELeave) CBrushDrawWin; + CleanupStack::PushL(testWin); + testWin->ConstructL(*TheClient->iGroup); + testWin->AssignGC(*TheClient->iGc); + testWin->SetExt(iWinPos+TPoint(25,25),TSize(300,200)); + testWin->Win()->SetRequiredDisplayMode(iTestDisplayMode); + testWin->Win()->SetShadowDisabled(ETrue); + testWin->Activate(); + testWin->SetVisible(ETrue); + + testWin->DrawNow(); + + TheClient->Flush(); + TheClient->WaitForRedrawsToFinish(); + + CleanupStack::PopAndDestroy(testWin); + } + +/*CBrushDrawWin*/ +CBrushDrawWin::CBrushDrawWin() + {} + +void CBrushDrawWin::Draw() + { + Redraw(); + } + +void CBrushDrawWin::Redraw() + { + CFbsBitmap *bitmap=new(ELeave) CFbsBitmap(); + User::LeaveIfError(bitmap->Load(TEST_BITMAP_NAME,0)); + TSize bitSize(bitmap->SizeInPixels()); + iGc->UseBrushPattern(bitmap); + iGc->SetBrushStyle(CGraphicsContext::EPatternedBrush); + iGc->DrawRect(TRect(TPoint(0, 0), bitSize)); + iGc->DiscardBrushPattern(); + delete bitmap; + } + +/*CTRedrawStoring*/ +CTRedrawStoring::CTRedrawStoring(CTestStep* aStep) : CTWsGraphicsBase(aStep) + { + } + +CTRedrawStoring::~CTRedrawStoring() + { + delete iCheckWin; + delete iCheckGc; + delete iCheckDevice; + delete iCheckBitmap; + delete iTestWin; + for(TInt bmp = 0; bmp < 3; ++bmp) + delete iAlphaBitmap[bmp]; + iBlankWin.Close(); + iRegion.Close(); + iWinTestGc.Close(); + delete iNoDrawWin; + delete iTestWinCopy; + delete iCheckWinCopy; + } + +void CTRedrawStoring::ConstructL() + { + iState = 0; + const TInt gap=5; + iTestDisplayMode = TheClient->iScreen->DisplayMode(); + const TSize scrSize(TheClient->iScreen->SizeInPixels()); + iWinSize=TheClient->iScreen->SizeInPixels(); + iWinSize.iWidth=(scrSize.iWidth-gap)/3; + CTBackedUpWin* checkWin=new(ELeave) CTBackedUpWin(iTestDisplayMode); + checkWin->ConstructExtLD(*TheClient->iGroup,TPoint(scrSize.iWidth-iWinSize.iWidth,0),iWinSize); + iCheckWin=checkWin; + iCheckWin->Activate(); + RBackedUpWindow& win=*iCheckWin->BackedUpWin(); + win.MaintainBackup(); + iCheckBitmap=new(ELeave) CFbsBitmap(); + iCheckBitmap->Duplicate(win.BitmapHandle()); + iCheckDevice=CFbsBitmapDevice::NewL(iCheckBitmap); + User::LeaveIfError(iCheckDevice->CreateContext(iCheckGc)); + iCheckGc->SetUserDisplayMode(iTestDisplayMode); + CRedrawStoreWin* testWin=new(ELeave) CRedrawStoreWin(this); + iWinPos.SetXY(scrSize.iWidth-2*iWinSize.iWidth-gap,0); + testWin->ConstructExtLD(*TheClient->iGroup,iWinPos,iWinSize); + iTestWin=testWin; + iTestWin->AssignGC(*TheClient->iGc); + RWindowBase& baseWin=*iTestWin->BaseWin(); + User::LeaveIfError(baseWin.SetRequiredDisplayMode(iTestDisplayMode)); + baseWin.SetShadowHeight(0); + iTestWin->Activate(); + + CNoDrawWin* noDrawWin=new(ELeave) CNoDrawWin(); + iWinPos.SetXY(scrSize.iWidth-2*iWinSize.iWidth-gap,0); + noDrawWin->ConstructExtLD(*TheClient->iGroup,iWinPos,iWinSize); + iNoDrawWin=noDrawWin; + iNoDrawWin->AssignGC(*TheClient->iGc); + RWindowBase& bWin=*iNoDrawWin->BaseWin(); + User::LeaveIfError(bWin.SetRequiredDisplayMode(EColor256)); + bWin.SetShadowHeight(0); + + iBlankWin=RBlankWindow(TheClient->iWs); + User::LeaveIfError(iBlankWin.Construct(*TheClient->iGroup->WinTreeNode(),ENullWsHandle)); + iBlankWin.SetVisible(EFalse); + User::LeaveIfError(iBlankWin.SetRequiredDisplayMode(EColor256)); + iBlankWin.SetColor(TRgb(48,240,32)); + iBlankWin.Activate(); + iWinTestGc=RWindow(TheClient->iWs); + User::LeaveIfError(iWinTestGc.Construct(*TheClient->iGroup->WinTreeNode(),ENullWsHandle)); + iWinTestGc.SetVisible(EFalse); + User::LeaveIfError(iWinTestGc.SetRequiredDisplayMode(EColor256)); + + iDrawMode=EClientRedrawsNormal; + iDoScrollTest=EFalse; + iDrawOrder=0; + //PeterI Alpha is supported but opacity is not +// iAlphaSupported=OpacityAndAlphaSupportedL(); + iAlphaSupported =TransparencySupportedL(); + iXPlus = ETrue; + iYPlus = EFalse; + + // Used for fading test + iTestWinCopy = new (ELeave) CFbsBitmap(); + iTestWinCopy->Create(iTestWin->Size(),TheClient->iScreen->DisplayMode()); + iCheckWinCopy = new (ELeave) CFbsBitmap(); + iCheckWinCopy->Create(iCheckWin->Size(),TheClient->iScreen->DisplayMode()); + } + +void CTRedrawStoring::CheckWindowsMatch() + { + TheClient->Flush(); + if (iDrawMode==EClientRedrawsNormal || iDrawMode==EClientRedrawsScrolled) + TheClient->WaitForRedrawsToFinish(); + TheClient->iWs.Finish(); + if(!iWindowsFaded) + { + _LIT(KLog,"RedrawStoring SubTest %d"); + TBuf<32> buf; + buf.AppendFormat(KLog,iTest->iState); + CheckRect(iTestWin,iCheckWin,TRect(iWinSize),buf); + } + else + { + TInt res = LossyCompareWindow(*TheClient->iScreen, *iTestWinCopy, *iCheckWinCopy, TRect(iCheckWin->Position(), iCheckWin->Size())); + TEST(res); + } + } + +void CTRedrawStoring::CheckWindowsNotMatch() + { + TheClient->Flush(); + TheClient->WaitForRedrawsToFinish(); + TheClient->iWs.Finish(); + CheckRectNoMatch(iTestWin,iCheckWin,TRect(iWinSize),_L("CTRedrawStoring::CheckWindowsNotMatch()")); + } + +void CTRedrawStoring::HideRevealTest() + { + iBlankWin.SetVisible(ETrue); + iBlankWin.SetVisible(EFalse); + CheckWindowsMatch(); + } + +void CTRedrawStoring::MultipleHideReveal(TInt aX,TInt aY) + { + TInt xInc=(iWinSize.iWidth+aX-1)/aX; + TInt yInc=(iWinSize.iHeight+aY-1)/aY; + TInt xEnd=iWinPos.iX+iWinSize.iWidth; + TInt yEnd=iWinPos.iY+iWinSize.iHeight; + TInt xx,yy; + for(xx=iWinPos.iX;xxInvalidate(); + CheckWindowsMatch(); + iDrawMode=EServerRedraw; + } + +void CTRedrawStoring::DoDrawingL(CWindowGc* aWinGc) + { + iClientDidDraw = ETrue; + switch (iDrawMode) + { + case EServerRedraw: + TEST(EFalse); + break; + case EClientRedrawsNormal: + if (iState>0) + { + DoDrawingL(0,aWinGc,ETrue); + DoDrawingL(0,iCheckGc,EFalse); + aWinGc->Deactivate(); + aWinGc->Activate(*iTestWin->DrawableWin()); + } + DoDrawingL(iState,aWinGc,ETrue); + DoDrawingL(iState,iCheckGc,EFalse); + iCheckWin->BackedUpWin()->UpdateScreen(); + break; + case EClientRedrawsScrolled: + { + DoDrawingL(0,aWinGc,ETrue); + TRegionFix<8> region; + region.AddRect(TRect(iWinSize)); + region.SubRect(iScrollTarget); + aWinGc->SetClippingRegion(region); + DoDrawingL(iState,aWinGc,ETrue); + aWinGc->CancelClippingRegion(); + aWinGc->SetClippingRect(iScrollTarget); + aWinGc->SetOrigin(iScrollTarget.iTl-iScrollSource); + DoDrawingL(iState,aWinGc,ETrue); + aWinGc->CancelClippingRect(); + break; + } + } + TheClient->Flush(); + } + +#define KLastDrawingCase 24 //This should always be the same as the value of last case number in the switch statement of the next function +void CTRedrawStoring::DoDrawingL(TInt aDraw,CBitmapContext* aGc,TBool aWinGc) + { + switch (aDraw) + { + case 0: + case 1: + aGc->SetBrushColor(TRgb(255,(aDraw==0?255:0),255)); + aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + aGc->SetPenStyle(CGraphicsContext::ENullPen); + aGc->DrawRect(iWinSize); + iDoScrollTest=EFalse; + break; + case 2: + aGc->SetPenStyle(CGraphicsContext::ESolidPen); + aGc->SetPenSize(TSize(1,1)); + aGc->SetPenColor(TRgb(0,0,0)); + aGc->DrawLine(TPoint(0,10),TPoint(iWinSize.iWidth,10)); + aGc->SetPenColor(TRgb(128,0,0)); + aGc->DrawLine(TPoint(0,iWinSize.iHeight-10),TPoint(iWinSize.iWidth,iWinSize.iHeight-10)); + aGc->SetPenColor(TRgb(0,128,0)); + aGc->DrawLine(TPoint(10,0),TPoint(10,iWinSize.iHeight)); + aGc->SetPenColor(TRgb(0,0,128)); + aGc->DrawLine(TPoint(iWinSize.iWidth-10,0),TPoint(iWinSize.iWidth-10,iWinSize.iHeight)); + iDoScrollTest=EFalse; + break; + case 3: + //Do various drawing using: MoveTo, MoveBy, Plot, DrawLineTo, DrawLineBy + aGc->SetPenStyle(CGraphicsContext::ESolidPen); + aGc->SetPenColor(TRgb(0,0,0)); + aGc->MoveTo(TPoint(iWinSize.iWidth, iWinSize.iHeight)); + aGc->DrawLineTo(TPoint(0, 0)); + aGc->MoveBy(TPoint(iWinSize.iWidth, 0)); + aGc->DrawLineTo(TPoint(0, iWinSize.iHeight)); + aGc->MoveTo(TPoint(0, iWinSize.iHeight/2)); + aGc->DrawLineBy(TPoint(iWinSize.iWidth, 0)); + aGc->SetPenSize(TSize(5,5)); + aGc->Plot(TPoint(iWinSize.iWidth/2, 20)); + aGc->Plot(TPoint(iWinSize.iWidth/2, iWinSize.iHeight/2)); + aGc->Plot(TPoint(iWinSize.iWidth/2, iWinSize.iHeight-20)); + aGc->SetPenSize(TSize(1,1)); + iDoScrollTest=EFalse; + break; + case 4: + //Do various drawing with lines of different widths + { + TInt inc=iWinSize.iHeight/8; + TInt penSize=2; + TInt yy; + aGc->SetPenStyle(CGraphicsContext::ESolidPen); + aGc->SetPenColor(TRgb(0,0,0)); + for (yy=0;yySetPenSize(TSize(penSize,penSize)); + else if (yy%3==1) + aGc->SetPenSize(TSize(penSize,7*penSize/5)); + else + aGc->SetPenSize(TSize(7*penSize/5,penSize)); +#else + aGc->SetPenSize(TSize(penSize,penSize)); +#endif + aGc->DrawLine(TPoint(2,yy),TPoint(iWinSize.iWidth-3,yy)); + penSize+=2; + } + aGc->SetPenSize(TSize(1,1)); + } + iDoScrollTest=ETrue; + break; + case 5: + //Some drawing using fading on the gc + aGc->SetPenStyle(CGraphicsContext::ESolidPen); + aGc->SetPenColor(TRgb(0,0,255)); +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + aGc->SetFaded(ETrue); +#endif + aGc->SetPenSize(TSize(10,10)); + aGc->DrawLine(TPoint(0,iWinSize.iHeight/2-5),TPoint(iWinSize.iWidth,iWinSize.iHeight/2-5)); +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + aGc->SetFaded(EFalse); +#endif + aGc->DrawLine(TPoint(0,iWinSize.iHeight/2+5),TPoint(iWinSize.iWidth, iWinSize.iHeight/2+5)); + aGc->SetPenStyle(CGraphicsContext::ESolidPen); + aGc->SetPenColor(TRgb(0,0,255)); +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + aGc->SetFaded(ETrue); + aGc->SetFadingParameters(0,127); +#endif + aGc->SetPenSize(TSize(10,10)); + aGc->DrawLine(TPoint(iWinSize.iWidth/2-5,0),TPoint(iWinSize.iWidth/2-5,iWinSize.iHeight)); +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + aGc->SetFaded(EFalse); + // default params + aGc->SetFadingParameters(128,255); +#endif + aGc->DrawLine(TPoint(iWinSize.iWidth/2+5,0),TPoint(iWinSize.iWidth/2+5,iWinSize.iHeight)); +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + aGc->SetFaded(EFalse); +#endif + iDoScrollTest=ETrue; + break; + case 6: + // Fading on window + aGc->SetPenStyle(CGraphicsContext::ESolidPen); + aGc->SetPenColor(TRgb(0,255,0)); + aGc->SetPenSize(TSize(10,10)); + aGc->DrawLine(TPoint(0,iWinSize.iHeight/2),TPoint(iWinSize.iWidth,iWinSize.iHeight/2)); + aGc->DrawLine(TPoint(iWinSize.iWidth/2,0),TPoint(iWinSize.iWidth/2,iWinSize.iHeight)); + iDoScrollTest=EFalse; + break; + case 7: + //Some drawing with text - create and destroy the font as soon as used + { + CFbsFont *font; + TFontSpec fspec(_L("Swiss"),190); + User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)font,fspec)); + aGc->SetPenColor(TRgb(0,0,0)); + aGc->UseFont(font); + aGc->DrawText(_L("Hello"), TPoint(20,20)); + aGc->DiscardFont(); + TheClient->iScreen->ReleaseFont(font); + + CFbsFont *font2; + TInt fontSize = 100; + TInt inc = 10; + for (TInt i=0; i<20; i++) + { + TFontSpec fspec2(_L("Ariel"), fontSize); + User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)font2,fspec2)); + aGc->SetPenColor(TRgb(0,0,0)); + aGc->UseFont(font2); + aGc->DrawText(_L("Hello"), TPoint(20,100)); + aGc->DiscardFont(); + TheClient->iScreen->ReleaseFont(font2); + fontSize+=inc; + } + iDoScrollTest=ETrue; + } + break; + case 8: + //Some drawing with bitmaps - create and destroy the bitmap as soon as used + { + CFbsBitmap* testBitmap; + testBitmap=new(ELeave) CFbsBitmap(); + User::LeaveIfError(testBitmap->Load(TEST_BITMAP_NAME,0)); + aGc->DrawBitmap(TRect(TPoint(10,10), TPoint(150,150)), testBitmap); + delete testBitmap; + iDoScrollTest=ETrue; + } + break; + case 9: + //Some drawing with clipping regions and rects + + //clipping rect + + aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + aGc->SetPenStyle(CGraphicsContext::ENullPen); + aGc->SetClippingRect(TRect(TPoint(50,0), TSize(iWinSize.iWidth/2,100))); + aGc->SetBrushColor(TRgb(255,255,0)); + aGc->DrawRect(TRect(TPoint(0,0), TPoint(100,100))); + aGc->SetBrushColor(TRgb(0,128,128)); + aGc->DrawRect(TRect(TPoint(iWinSize.iWidth/2,0), TSize(iWinSize.iWidth/2,100))); + aGc->CancelClippingRect(); + + + //regions + + iRegion.AddRect(TRect(TPoint(0,30), TSize(3*iWinSize.iWidth/4,150))); + iRegion.AddRect(TRect(TPoint(iWinSize.iWidth/2-20, 0), TSize(70,70))); + + aGc->SetClippingRegion(iRegion); + + aGc->SetBrushColor(TRgb(0,200,0)); + aGc->DrawRect(TRect(TPoint(5,5), TPoint(iWinSize.iWidth-50,200))); + aGc->SetBrushColor(TRgb(200,0,0)); + aGc->DrawRect(TRect(TPoint(50,50), TPoint(iWinSize.iWidth/2,150))); + aGc->SetBrushColor(TRgb(0,0,200)); + aGc->DrawRect(TRect(TPoint(20,10), TPoint(100,100))); + + aGc->CancelClippingRegion(); + + iDoScrollTest=EFalse; + break; + case 10: + //Some drawing with deactivating and reactivating the gc on the window (if it is indeed it is window gc) + + aGc->SetBrushColor(TRgb(0,0,255)); + aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + aGc->SetPenStyle(CGraphicsContext::ENullPen); + aGc->DrawRect(TRect(TPoint(20,20), TSize(50,50))); + + if (aWinGc) + { + static_cast(aGc)->Deactivate(); + + // Associate gc with another window and change attributes + static_cast(aGc)->Activate(iWinTestGc); + aGc->SetPenStyle(CGraphicsContext::ESolidPen); + aGc->SetPenColor(TRgb(0,0,255)); + static_cast(aGc)->Deactivate(); + static_cast(aGc)->Activate(*iTestWin->DrawableWin()); + } + + aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + aGc->SetPenStyle(CGraphicsContext::ENullPen); + aGc->SetBrushColor(TRgb(200,0,0)); + aGc->DrawRect(TRect(TPoint(70,70), TSize(50,50))); + iDoScrollTest=EFalse; + break; + case 11: + // Some drawing with polygons + { + aGc->SetBrushColor(TRgb(0,221,0)); + aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + aGc->SetPenStyle(CGraphicsContext::ENullPen); + + TPoint point1(iWinSize.iWidth/3,iWinSize.iHeight/4*3); + TPoint point2(iWinSize.iWidth/2,iWinSize.iHeight/5*4); + TPoint point3(iWinSize.iWidth/3,iWinSize.iHeight-20); + TPoint point4(iWinSize.iWidth/4,iWinSize.iHeight-20); + TPoint point5(iWinSize.iWidth/6,iWinSize.iHeight-60); + + CArrayFix* points; + points = new CArrayFixFlat(5); + points->AppendL(point1); + points->AppendL(point2); + points->AppendL(point3); + points->AppendL(point4); + points->AppendL(point5); + aGc->DrawPolygon(points); + delete points; + + TPoint points2[5]; + points2[0].SetXY(iWinSize.iWidth/2,50); + points2[1].SetXY(iWinSize.iWidth-50,iWinSize.iHeight/2); + points2[2].SetXY(iWinSize.iWidth-70,iWinSize.iHeight/2+30); + points2[3].SetXY(iWinSize.iWidth/3,iWinSize.iHeight/3); + points2[4].SetXY(iWinSize.iWidth/4,iWinSize.iHeight/4); + aGc->SetBrushColor(TRgb(221,0,0)); + aGc->DrawPolygon(points2,5); + iDoScrollTest=ETrue; + } + break; + case 12: + { + // Another Fading on Window Test + aGc->SetPenStyle(CGraphicsContext::ENullPen); + aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + aGc->SetBrushColor(TRgb(51,204,204)); +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + if (!iWindowsFaded || aWinGc) + { + aGc->SetFaded(ETrue); + } +#endif + aGc->DrawRect(TRect(iWinSize.iWidth/4-1,iWinSize.iHeight/4-1,3*iWinSize.iWidth/4+1,3*iWinSize.iHeight/4+1)); +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + aGc->SetFaded(EFalse); +#endif + aGc->SetBrushStyle(CGraphicsContext::ENullBrush); + aGc->SetPenStyle(CGraphicsContext::ESolidPen); + aGc->SetPenColor(TRgb(34,204,34)); + aGc->SetPenSize(TSize(8,8)); + aGc->DrawLine(TPoint(2,iWinSize.iHeight/2+5),TPoint(iWinSize.iWidth-2,iWinSize.iHeight/2-5)); + aGc->DrawLine(TPoint(iWinSize.iWidth/2+5,2),TPoint(iWinSize.iWidth/2-5,iWinSize.iHeight-2)); +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + if (!iWindowsFaded || aWinGc) + { + aGc->SetFaded(ETrue); + } +#endif + aGc->SetPenColor(TRgb(51,221,51)); + aGc->SetPenSize(TSize(3,3)); + aGc->SetBrushColor(TRgb(238,34,238)); + aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + aGc->DrawRect(TRect(3*iWinSize.iWidth/8-1,3*iWinSize.iHeight/8-1,5*iWinSize.iWidth/8+1,5*iWinSize.iHeight/8+1)); +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + aGc->SetFaded(EFalse); +#endif + aGc->SetBrushStyle(CGraphicsContext::ENullBrush); + aGc->SetPenColor(TRgb(238,34,238)); +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + aGc->SetPenSize(TSize(8,9)); +#else + aGc->SetPenSize(TSize(8,8)); +#endif + aGc->DrawRect(TRect(iWinSize.iWidth/8-1,iWinSize.iHeight/8-1,7*iWinSize.iWidth/8+1,7*iWinSize.iHeight/8+1)); + iDoScrollTest=ETrue; + } + break; + case 15: + //Some masked drawing with FBS bitmaps - create and destroy the bitmaps as soon as used + { + CFbsBitmap* testBitmap; + CFbsBitmap* maskBitmap; + testBitmap=new(ELeave) CFbsBitmap(); + CleanupStack::PushL(testBitmap); + maskBitmap=new(ELeave) CFbsBitmap(); + CleanupStack::PushL(maskBitmap); + User::LeaveIfError(testBitmap->Load(TEST_BITMAP_NAME,2)); + User::LeaveIfError(maskBitmap->Load(TEST_BITMAP_NAME,4)); + aGc->BitBltMasked(TPoint(10,10), testBitmap, TRect(TPoint(0, 0), testBitmap->SizeInPixels()), maskBitmap, EFalse); + CleanupStack::PopAndDestroy(2, testBitmap); + iDoScrollTest=ETrue; + } + break; + case 16: + //As above, except using Ws bitmaps + { + CWsBitmap* testBitmap; + CWsBitmap* maskBitmap; + testBitmap=new(ELeave) CWsBitmap(TheClient->iWs); + CleanupStack::PushL(testBitmap); + maskBitmap=new(ELeave) CWsBitmap(TheClient->iWs); + CleanupStack::PushL(maskBitmap); + User::LeaveIfError(testBitmap->Load(TEST_BITMAP_NAME,3)); + User::LeaveIfError(maskBitmap->Load(TEST_BITMAP_NAME,4)); + // If we don't cast to the window gc we don't see the WS version of the BitBltMasked function: + if(aWinGc) + ((CWindowGc*)aGc)->BitBltMasked(TPoint(20,20), testBitmap, TRect(TPoint(0, 0), testBitmap->SizeInPixels()), maskBitmap, EFalse); + else + aGc->BitBltMasked(TPoint(20,20), testBitmap, TRect(TPoint(0, 0), testBitmap->SizeInPixels()), maskBitmap, EFalse); + CleanupStack::PopAndDestroy(2, testBitmap); + iDoScrollTest=ETrue; + } + break; + case 19: + //Some drawing with WS bitmaps + { + if(!iAlphaBitmap[0]) + { + for(TInt bmp = 0; bmp < 3; ++bmp) + { + iAlphaBitmap[bmp] = new(ELeave) CWsBitmap(TheClient->iWs); + User::LeaveIfError(iAlphaBitmap[bmp]->Load(TEST_BITMAP_NAME,2 + bmp)); + } + } + if(aWinGc) + ((CWindowGc*)aGc)->BitBlt(TPoint(20,20), iAlphaBitmap[0]); + else + aGc->BitBlt(TPoint(20,20), iAlphaBitmap[0]); + iDoScrollTest=ETrue; + } + break; + case 20: + //Some drawing with alpha blended bitmaps + if (iAlphaSupported) + { + aGc->SetFaded(EFalse); + TPoint start(0,0); + TSize size = iAlphaBitmap[0]->SizeInPixels(); + TPoint alphastart((start.iX + size.iWidth / 4), (start.iY + size.iHeight / 4)); + + aGc->BitBlt(start, iAlphaBitmap[0], TRect(start, size)); + aGc->AlphaBlendBitmaps(start, iAlphaBitmap[1], TRect(start, size), iAlphaBitmap[2], alphastart); + iDoScrollTest=ETrue; + } + break; + case 21: + // As in previous case, except using FBS bitmaps. + if (iAlphaSupported) + { + aGc->SetFaded(EFalse); + CFbsBitmap* baseBitmap; + CFbsBitmap* testBitmap; + CFbsBitmap* alphaBitmap; + baseBitmap=new(ELeave) CFbsBitmap(); + CleanupStack::PushL(baseBitmap); + testBitmap=new(ELeave) CFbsBitmap(); + CleanupStack::PushL(testBitmap); + alphaBitmap=new(ELeave) CFbsBitmap(); + CleanupStack::PushL(alphaBitmap); + User::LeaveIfError(baseBitmap->Load(TEST_BITMAP_NAME,2)); + User::LeaveIfError(testBitmap->Load(TEST_BITMAP_NAME,3)); + User::LeaveIfError(alphaBitmap->Load(TEST_BITMAP_NAME,4)); + TPoint start(0,0); + TSize size = baseBitmap->SizeInPixels(); + TPoint alphastart((start.iX + size.iWidth / 4), (start.iY + size.iHeight / 4)); + + aGc->BitBlt(start, baseBitmap, TRect(start, size)); + aGc->AlphaBlendBitmaps(start, testBitmap, TRect(start, size), alphaBitmap, alphastart); + + CleanupStack::PopAndDestroy(3, baseBitmap); + iDoScrollTest=ETrue; + } + break; + case 22: + // Some default drawing for Begin EndRedraw test + aGc->SetPenStyle(CGraphicsContext::ESolidPen); + aGc->SetPenSize(TSize(2,2)); + aGc->SetPenColor(TRgb(128,0,0)); + aGc->DrawLine(TPoint(10,10),TPoint(20,10)); + aGc->DrawLine(TPoint(20,10),TPoint(20,20)); + aGc->DrawLine(TPoint(20,20),TPoint(10,20)); + aGc->DrawLine(TPoint(10,20),TPoint(10,10)); + + aGc->SetPenSize(TSize(4,4)); + aGc->SetPenColor(TRgb(0,0,128)); + aGc->DrawLine(TPoint(50,50),TPoint(150,50)); + aGc->DrawLine(TPoint(150,50),TPoint(150,150)); + aGc->DrawLine(TPoint(150,150),TPoint(50,150)); + aGc->DrawLine(TPoint(50,150),TPoint(50,50)); + iDoScrollTest=EFalse; + break; + case 23: + aGc->SetBrushColor(TRgb(244,196,48)); + aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + aGc->SetPenStyle(CGraphicsContext::ENullPen); + aGc->DrawRect(TRect(0,0,iWinSize.iWidth,iWinSize.iHeight/3)); + aGc->SetBrushColor(TRgb(255,255,255)); + aGc->DrawRect(TRect(0,iWinSize.iHeight/3,iWinSize.iWidth,iWinSize.iHeight*2/3)); + aGc->SetBrushColor(TRgb(3,192,60)); + aGc->DrawRect(TRect(0,iWinSize.iHeight*2/3,iWinSize.iWidth,iWinSize.iHeight)); + iDoScrollTest=EFalse; + break; + case 24: + iClientDidDraw=ETrue; + //Draw some rects to screen + aGc->Reset(); + aGc->Clear(); + aGc->SetPenStyle(CGraphicsContext::ESolidPen); + aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + aGc->SetBrushColor(TRgb(98,72,172)); + aGc->DrawRect(TRect(20,iYPoz,250,280+iYPoz)); + aGc->SetBrushColor(TRgb(255,0,0)); + aGc->DrawRect(TRect(0,iYPoz,200,200+iYPoz)); + aGc->SetBrushColor(TRgb(0,255,255)); + aGc->DrawRect(TRect(10,15+iYPoz,250,115+iYPoz)); + aGc->SetBrushColor(TRgb(0,255,0)); + aGc->DrawRect(TRect(0,50+iYPoz,100,250+iYPoz)); + aGc->SetBrushColor(TRgb(255,255,0)); + aGc->DrawRect(TRect(50,50+iYPoz,150,150+iYPoz)); + aGc->SetBrushColor(TRgb(5,25,20)); + aGc->DrawRect(TRect(120,170+iYPoz,220,250+iYPoz)); + break; + } + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-0085 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Do Draw Test + REQUIREMENT: REQ2123 + GT0164/Delta/ 1450, 1460, 1470, 1490, 1500, 1510, 1520, 1530 + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Lots of different type of drawing is done to the test window. + (Including: normal drawing, fonts, bitmaps, fading on the GC, + clipping regions and rects). + A blank window is made visible then invisible above the test window + The blank window's size and position is also changed many times. + +@SYMTestExpectedResults After the initial drawing of the test window, all the draw commands + should be stored by the window server. When the blank window is made + visible/invisible above the test window a redraw message will be sent + to the test window. The window will be redrawn using the draw commands + stored in the server. Once all the redrawing is complete, the test window + will be compared with a bitmap that has had the same draw commands applied + to it. + The test will fail if the bitmaps don't match or if the test window was + redrawn not using the stored server side draw commands. + */ + +void CTRedrawStoring::DoDrawTest() + { + RedrawWindows(); + HideRevealTest(); + iTestWin->SetVisible(EFalse); + iTestWin->SetVisible(ETrue); + CheckWindowsMatch(); + MultipleHideReveal(2,3); + MultipleHideReveal(5,4); + iBlankWin.SetExtent(iWinPos,iWinSize); + HideRevealTest(); + CheckWindowsMatch(); + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-0086 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Fade Window Test + REQUIREMENT: REQ2123 + GT0164/Delta/ 1480 + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions The test window is faded and the GC associated with the bitmap used + to check the test window is faded. The Draw Test in TestCase 1 is then + applied. + +@SYMTestExpectedResults The test window and the check bitmap should both be faded and contain + the same drawing. The test will fail if the bitmaps don't match or if the + test window was redrawn not using the stored server side draw commands. + + */ +void CTRedrawStoring::FadeWindowTest() + { + iWindowsFaded = ETrue; + iTestWin->Win()->SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly); + iCheckGc->SetFaded(ETrue); + DoDrawTest(); + iDrawMode=EClientRedrawsNormal; + iTestWin->Win()->SetFaded(EFalse,RWindowTreeNode::EFadeWindowOnly); + iCheckGc->SetFaded(EFalse); + TheClient->Flush(); + TheClient->WaitForRedrawsToFinish(); + iWindowsFaded = EFalse; + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-0087 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Fade Window Test 2 + REQUIREMENT: REQ2123 + GT0164/Delta/ 1480 + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions The test window is faded and the check window that uses the check bitmap + is faded. A blank window is made visbible/invisible above the test window. + Fading is switched off on both windows, they are redrawn and then compared. + +@SYMTestExpectedResults The test window and the check bitmap should both be faded. After showing + the blank window the test window will contain a couple of rectangles faded due to + Gc fade apart from the overall window fade (will look similar to double fading), whereas + check window will have simply the overall window fade. Once both windows have been + redrawn with the fading switched off, they should not look the same for the same + reason explained above. + + */ +void CTRedrawStoring::FadeWindowTest2L() + { + DoDrawTest(); + iWindowsFaded=ETrue; + iTestWin->BaseWin()->SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly); + iCheckWin->BaseWin()->SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly); + CheckWindowsMatch(); + +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + //perform RedrawWindows() with CheckWindowsNotMatch() + iDrawMode=EClientRedrawsNormal; + iTestWin->Invalidate(); + CheckWindowsNotMatch(); + iDrawMode=EServerRedraw; + + //perform HideRevealTest() with CheckWindowsNotMatch() + iBlankWin.SetVisible(ETrue); + iBlankWin.SetVisible(EFalse); + CheckWindowsNotMatch(); +#endif + + iWindowsFaded=EFalse; + iTestWin->BaseWin()->SetFaded(EFalse,RWindowTreeNode::EFadeWindowOnly); + iCheckWin->BaseWin()->SetFaded(EFalse,RWindowTreeNode::EFadeWindowOnly); + iDrawMode=EClientRedrawsNormal; + DoDrawingL(0,iCheckGc,EFalse); + DoDrawingL(iState,iCheckGc,EFalse); + iCheckWin->BackedUpWin()->UpdateScreen(); + iDrawMode=EServerRedraw; + CheckWindowsMatch(); + HideRevealTest(); + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-0088 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Scroll Test + REQUIREMENT: REQ2123 + GT0164/Delta/ 1540 + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Different areas of the test window are scrolled, the check bitmap + window is also adjusted to reflect this scrolling. The blank window is + then made visible/invisible above the test window + +@SYMTestExpectedResults The test will fail if the bitmaps don't match or if the test window was + redrawn not using the stored server side draw commands. + + */ +void CTRedrawStoring::ScrollTest() + { + CheckWindowsMatch(); + TInt x=iWinSize.iWidth/3; + TInt w=iWinSize.iWidth/4; + SetScrolling(TPoint(10,20),TRect(x,100,x+w,160)); + DoScrollTest(); + x=iWinSize.iWidth/2; + w=iWinSize.iWidth/3; + SetScrolling(TPoint(48,100),TRect(x,10,x+w,80)); + DoScrollTest(); + x=iWinSize.iWidth/10; + w=iWinSize.iWidth/5; + SetScrolling(TPoint(iWinSize.iWidth/2,20),TRect(x,100,x+w,150)); + DoScrollTest(); + } + +void CTRedrawStoring::DoScrollTest() + { + TheClient->Flush(); + iDrawMode=EClientRedrawsScrolled; + CheckWindowsMatch(); + iDrawMode=EServerRedraw; + HideRevealTest(); + RedrawWindows(); + CheckWindowsMatch(); + } + +void CTRedrawStoring::SetScrolling(TPoint aScrollSource, TRect aScrollTarget) + { + iScrollSource=aScrollSource; + iScrollTarget=aScrollTarget; + iTestWin->DrawableWin()->Scroll(iScrollTarget.iTl-iScrollSource,TRect(iScrollSource,iScrollTarget.Size())); + iCheckWin->DrawableWin()->Scroll(iScrollTarget.iTl-iScrollSource,TRect(iScrollSource,iScrollTarget.Size())); + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-0090 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Do Nothing in Redraw Test + REQUIREMENT: REQ2123 + GT0164/Delta/ 1570 + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions A window is created that contains no drawing code. A blank window is + made visible/invisible above this window. + +@SYMTestExpectedResults No buffer will be created server side because there are no draw commands + to store. The server should be able to cope with an empty buffer when the + redraw is issued, caused by the blank win. + + */ +void CTRedrawStoring::DoNothingInRedrawTest() + { + // iNoDrawWin contains no drawing code, therefore no server side + // redraw store buffer will be created in a redraw. + // When a redraw occurs because the blank win is made visible/invisible, + // the server will try and access the non existant buffer, all being well + // nothing should happen because the server can cope with an empty redraw + // buffer. + + iTestWin->SetVisible(EFalse); + iNoDrawWin->Activate(); + TheClient->Flush(); + TheClient->WaitForRedrawsToFinish(); + iDrawMode=EServerRedraw; + iBlankWin.SetOrdinalPosition(0); + iBlankWin.SetVisible(ETrue); + iBlankWin.SetVisible(EFalse); + TheClient->Flush(); + + //return to normal testing state + iNoDrawWin->SetVisible(EFalse); + iTestWin->SetVisible(ETrue); + RedrawWindows(); + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-0091 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Disable Redraw Store Test + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions A windows redraw store is disabled and enabled, and the window is exposed. + +@SYMTestExpectedResults When the redraw store is disabled, a client redraw should occur when the window + is exposed. When it is enabled, no client redraw should occur. However, the + first time it is exposed after enabling the store it will need a client redraw + in order to fill the store. + + */ +void CTRedrawStoring::DoDisableRedrawStoreTest() + { + _LIT(KLog1,"Redraw storing not enabled when expected to be"); + _LIT(KLog2,"No client redraw was done when it was expected"); + RedrawWindows(); + CheckWindowsMatch(); + + iDrawMode=EServerRedraw; + HideRevealTest(); + + iClientDidDraw=EFalse; + TBool isEnabled=iTestWin->Win()->IsRedrawStoreEnabled(); + TEST(isEnabled); + if (!isEnabled) + LOG_MESSAGE(KLog1); + + /*iTestWin->Win()->EnableRedrawStore(EFalse); + isEnabled=iTestWin->Win()->IsRedrawStoreEnabled(); + TEST(!isEnabled); + if (isEnabled) + { + _LIT(KLog,"Redraw storing enabled when expected not to be"); + LOG_MESSAGE(KLog); + } + + iDrawMode=EClientRedrawsNormal; + HideRevealTest(); + TEST(iClientDidDraw); + if (!iClientDidDraw) + { + LOG_MESSAGE(KLog2); + TheClient->WaitForRedrawsToFinish(); + if (iClientDidDraw) + { + _LIT(KLog,"After Waiting Redraws had taken place"); + LOG_MESSAGE(KLog); + } + }*/ + + iTestWin->Win()->EnableRedrawStore(ETrue); + isEnabled=iTestWin->Win()->IsRedrawStoreEnabled(); + TEST(isEnabled); + if (!isEnabled) + LOG_MESSAGE(KLog1); + + HideRevealTest(); + iDrawMode=EServerRedraw; + HideRevealTest(); + + iClientDidDraw=EFalse; + TheClient->iWs.ClearAllRedrawStores(); + iDrawMode=EClientRedrawsNormal; + HideRevealTest(); + TEST(iClientDidDraw); + if (!iClientDidDraw) + { + LOG_MESSAGE(KLog2); + TheClient->WaitForRedrawsToFinish(); + if (iClientDidDraw) + { + _LIT(KLog,"After Waiting Redraws had taken place"); + LOG_MESSAGE(KLog); + } + } + + HideRevealTest(); + iDrawMode=EServerRedraw; + HideRevealTest(); + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-0092 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Resize Redraws + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions A window is resized. + +@SYMTestExpectedResults When the window decreases in size, the server should be able to + redraw it from the store. When it increases in size, a client redraw + should occur. + + */ +void CTRedrawStoring::DoResizeTest() + { + RedrawWindows(); + + TSize oldsize = iTestWin->Win()->Size(); + + iDrawMode=EServerRedraw; + iTestWin->Win()->SetSize(TSize(8, 8)); + TheClient->Flush(); + TheClient->WaitForRedrawsToFinish(); + + iClientDidDraw=EFalse; + iDrawMode=EClientRedrawsNormal; + iTestWin->Win()->SetSize(oldsize); + TheClient->Flush(); + TheClient->WaitForRedrawsToFinish(); + TEST(iClientDidDraw); + if (!iClientDidDraw) + INFO_PRINTF3(_L("iClientDidDraw - Expected: %d, Actual: %d"), ETrue, iClientDidDraw); + + } + +/* TESTCASE: 9 + * TITLE: Font Cache Overflow + * IMPORTANCE: 1 + * REQUIREMENT: DEF065463 + * + * + * API: + * # + * + * ACTION: + * The Font Cache is overflowed + * + * RESULT: + * If the font cache overflows or under out of memory conditions, + * there should be no leaves, panics or incorrect behaviour of the + * local array of font handles. + */ + + void CTRedrawStoring::DoFontCacheOverflowTestL() + { + RWindow window(TheClient->iWs); + User::LeaveIfError(window.Construct(*TheClient->iGroup->WinTreeNode(), ENullWsHandle)); + CleanupClosePushL(window); + window.Activate(); + // Display mode is set after window.Activate() purposely to check that drawing + // is done in the right mode, in order to test fix for DEF083327 + User::LeaveIfError(window.SetRequiredDisplayMode(EColor256)); + + // run test using a single gc + FontCacheOverflowDrawingTestL(EFalse, window); + // reset for next test + window.Invalidate(); + iXPlus = ETrue; + iYPlus = EFalse; + // run test using multiple gcs + FontCacheOverflowDrawingTestL(ETrue, window); + + CleanupStack::PopAndDestroy(&window); + } + +/* TESTCASE: 22 +* TITLE: Scroll Window +* IMPORTANCE: +* REQUIREMENT: +* +* +* API: +* # +* +* ACTION: +* A window is scrolled then a blank window is popped up, made visible and then +* invisible in order to test that partial redraw storing is drawing window +* contents properly after hiding the blank window. +* +* Before the fix, the contents used to disappear as partial redraw storing was +* not storing the commands to draw areas outside the defined clipping rect, in +* this case the area covered by the popped window. Now, the fix makes sure that +* full redraw to the window is applied when there are atored commands but the +* changes are performed only in the covered area. +* +* RESULT: +* When the blank window is hidden, the covered area will be redrawn and will +* contain the original contents before poping the blank window. +* +*/ +void CTRedrawStoring::ScrollWinTest() + { + iDrawMode=EClientRedrawsNormal; + + // Drawing the contents first before scrolling + iTestWin->DrawNow(); + + // Scrolling the test window and updating its y position + iTestWin->DrawableWin()->Scroll(TPoint(0, 25)); + iYPoz += 25; + + // Invalidating and redrawing the area that should be updated + TRect invalidRect(0,25, iWinSize.iWidth, 25*2); + iTestWin->Invalidate(invalidRect); + iTestWin->Redraw(invalidRect); // Redraw is used instead of DrawNow becuase the later calls Invalidate on the whole window + + // Displaying and then hiding the popup blank window + iBlankWin.SetExtent(TPoint(iWinSize.iWidth+40,30), TSize(120, 100)); + iBlankWin.SetVisible(ETrue); + iBlankWin.SetVisible(EFalse); + TheClient->Flush(); + TheClient->WaitForRedrawsToFinish(); + + // Resetting iBlankWin to its original size and position for future use + // by other test cases + iBlankWin.SetExtent(iWinPos, iWinSize); + CheckWindowsMatch(); + iYPoz=0; + } + + +TPoint CTRedrawStoring::ComputeTextPosition(TPoint aPoint) + { + // Bounces text around the screen + const TInt KSpacing = 30; + + if(iXPlus) + { + aPoint.iX += KSpacing; + } + else + { + aPoint.iX -= KSpacing; + } + if(aPoint.iX > iWinSize.iWidth) + { + aPoint.iX = iWinSize.iWidth - (aPoint.iX - iWinSize.iWidth); + iXPlus = EFalse; + } + else if(aPoint.iX < 0) + { + aPoint.iX = -1*aPoint.iX; + iXPlus = ETrue; + } + + if(iYPlus) + { + aPoint.iY += KSpacing; + } + else + { + aPoint.iY -= KSpacing; + } + if(aPoint.iY > iWinSize.iHeight) + { + aPoint.iY = iWinSize.iHeight - (aPoint.iY - iWinSize.iHeight); + iYPlus = EFalse; + } + else if(aPoint.iY < 0) + { + aPoint.iY = -1*aPoint.iY; + iYPlus = ETrue; + } + return aPoint; + } + +void CTRedrawStoring::FontCacheOverflowDrawingTestL(TBool aDiffGc, RWindow& aWindow) + { + const TInt KNumFonts = 250; + const TInt KNumFontTypes = TheClient->iScreen->NumTypefaces(); + const TInt KMaxFontSize = 21; // font sizes to be tested in range 1 to 21 + const TInt KNumTestStyles = 4; + const TInt KNumSizes = KNumFonts/(KNumFontTypes * KNumTestStyles) + 1; // chooses a number of font sizes to overflow cache, rounded up + TInt textStyle = 0; //determines whether text is not changed (0), bold (1), bold and italic (2) or italic (3) + TInt fontType = 0; //increment for different font types + TInt currentSize = 1; // start with a font size of 1 + TInt fontSizeIncrement = KMaxFontSize - currentSize; //defaults to 20 + if(KNumSizes>2) + { + fontSizeIncrement = KMaxFontSize/(KNumSizes-1); + } + TInt numGcs = 1; + if(aDiffGc) + { + numGcs = KNumFonts; + } + _LIT(KTestText,"b8-/+.,*:"); + const TSize KScrSize(TheClient->iScreen->SizeInPixels()); + TSize fontCacheWinSize(KScrSize.iWidth/2,KScrSize.iHeight); + iTestWinPoint.SetXY(fontCacheWinSize.iWidth/2, fontCacheWinSize.iHeight/2); //draw initially near the middle of the screen + + CWindowGc* winGc = NULL; + RArray winGcList; + CleanupClosePushL(winGcList); + + aWindow.BeginRedraw(); + + // fill an array with fonts of different styles (see textStyle comment), types, and sizes + RArray fontArray; + CleanupClosePushL(fontArray); + for(TInt ii = 0; ii < KNumFonts; ii++) + { + if(ii && !(ii % (KNumTestStyles * KNumSizes))) + { + fontType++; + textStyle = 0; + currentSize = 1; + } + else if(ii && !(ii % KNumTestStyles)) + { + currentSize += fontSizeIncrement; + textStyle = 0; + } + TTypefaceSupport support; + TheClient->iScreen->TypefaceSupport(support, fontType); + TFontSpec fspec(support.iTypeface.iName.Des(), currentSize); + switch(textStyle++) + { + case 0: + fspec.iFontStyle.SetPosture(EPostureUpright); + break; + case 1: + fspec.iFontStyle.SetStrokeWeight(EStrokeWeightBold); + break; + case 2: + fspec.iFontStyle.SetPosture(EPostureItalic); + break; + case 3: + fspec.iFontStyle.SetStrokeWeight(EStrokeWeightNormal); + break; + } + CFont* font = NULL; + User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInPixels(font, fspec)); + User::LeaveIfError(fontArray.Append(font)); + font = NULL; + + // Draw to left half of screen using either one gc for all fonts, or using a font per gc, dependent on value of aDiffGc + if(iiiScreen); + CleanupStack::PushL(winGc); + User::LeaveIfError(winGc->Construct()); + winGc->Activate(aWindow); + User::LeaveIfError(winGcList.Append(winGc)); + } + winGc->UseFont(fontArray[ii]); + winGc->SetPenColor(TRgb::Color256(ii)); + winGc->DrawText(KTestText, iTestWinPoint = ComputeTextPosition(iTestWinPoint)); + } + + aWindow.EndRedraw(); + TheClient->Flush(); + + // Copy the drawing to a bitmap and redraw to the right half of the screen + CFbsBitmap* bitmap = new (ELeave) CFbsBitmap; + CleanupStack::PushL(bitmap); + bitmap->Create(TSize(fontCacheWinSize.iWidth, fontCacheWinSize.iHeight), EColor256); + User::LeaveIfError(TheClient->iScreen->CopyScreenToBitmap(bitmap, TRect(fontCacheWinSize))); + TPoint copiedBitmapOrigin(fontCacheWinSize.iWidth, 0); + TRect bitmapArea(copiedBitmapOrigin, bitmap->SizeInPixels()); + aWindow.Invalidate(bitmapArea); + aWindow.BeginRedraw(bitmapArea); + winGc->BitBlt(copiedBitmapOrigin, bitmap); + aWindow.EndRedraw(); + CleanupStack::PopAndDestroy(bitmap); + + // Trigger a redraw (left half of screen) + RBlankWindow blankWindow(TheClient->iWs); + CleanupClosePushL(blankWindow); + User::LeaveIfError(blankWindow.Construct(*TheClient->iGroup->WinTreeNode(), ENullWsHandle)); + blankWindow.SetSize(TSize(fontCacheWinSize.iWidth, fontCacheWinSize.iHeight)); + blankWindow.Activate(); + TheClient->Flush(); + blankWindow.SetVisible(EFalse); + TheClient->Flush(); + CleanupStack::PopAndDestroy(&blankWindow); + TheClient->WaitForRedrawsToFinish(); + // Compare what is redrawn with copy of original drawing + TEST(TheClient->iScreen->RectCompare(TRect(fontCacheWinSize),TRect(copiedBitmapOrigin,fontCacheWinSize))); + // Clean up all memory + for(TInt kk = 0; kk < KNumFonts; kk++) + { + if(kk < numGcs) + { + winGcList[kk]->Deactivate(); + } + TheClient->iScreen->ReleaseFont(fontArray[kk]); + } + CleanupStack::PopAndDestroy(2+numGcs, &winGcList); + } + +// As a full fledged test code is written for this implementation. +// so this test code checks whether this defect is fixed. +void CTRedrawStoring::DoTestDrawBitmapMaskedL(TInt aWsBitmap/*=EFalse*/) + { + // Create a source bitmap with display mode EColor16MU and Fill RGB lines successively + TInt bitmapWidth=iWinSize.iWidth-40; + TInt bitmapHeight=80; + TSize bitmapSize(bitmapWidth,bitmapHeight); + CFbsBitmap* fbsBitmap=NULL; + CWsBitmap* wsBitmap=NULL; + if (aWsBitmap) + { + wsBitmap=new(ELeave) CWsBitmap(TheClient->iWs); + CleanupStack::PushL(wsBitmap); + User::LeaveIfError(wsBitmap->Create(bitmapSize,EColor16MU)); + } + else + { + fbsBitmap=new(ELeave) CFbsBitmap(); + CleanupStack::PushL(fbsBitmap); + User::LeaveIfError(fbsBitmap->Create(bitmapSize,EColor16MU)); + } + + TBitmapUtil bmpUtil(aWsBitmap ? wsBitmap : fbsBitmap); + bmpUtil.Begin(TPoint(0,0)); + TInt row,col; + for(row=0;rowiWs); + CleanupStack::PushL(wsBitmapMask); + User::LeaveIfError(wsBitmapMask->Create(bitmapSize,EGray256)); + } + else + { + fbsBitmapMask=new(ELeave) CFbsBitmap(); + CleanupStack::PushL(fbsBitmapMask); + User::LeaveIfError(fbsBitmapMask->Create(bitmapSize,EGray256)); + } + + TBitmapUtil bmpUtilMask(aWsBitmap ? wsBitmapMask : fbsBitmapMask); + bmpUtilMask.Begin(TPoint(0,0)); + for(row=0;rowiScreen->SizeInPixels(); + iWinRect.SetRect(screenSize.iWidth/3,0,2*screenSize.iWidth/3,screenSize.iHeight); + iBitmapMaskedWin=CBitmapMaskedWin::NewL(fbsBitmap,fbsBitmapMask,wsBitmap,wsBitmapMask,KRgbRed,bitmapSize,EFalse,aWsBitmap); + CleanupStack::PushL(iBitmapMaskedWin); + iBitmapMaskedWin->SetExt(TPoint(screenSize.iWidth/3,0),iWinRect.Size()); + iBitmapMaskedWin->Activate(); + TheClient->Flush(); + TheClient->WaitForRedrawsToFinish(); + + // Create a bitmap window which in its draw function it just bitblts its content + // First fill that bitmap with red color + iTestWinPoint.SetXY(2*screenSize.iWidth/3,0); + iTestBitmap=CBitmap::NewL(iWinRect.Size(),EColor16MU); + CleanupStack::PushL(iTestBitmap); + iTestBitmap->Gc().SetBrushColor(TRgb(255,0,0)); + iTestBitmap->Gc().SetBrushStyle(CGraphicsContext::ESolidBrush); + iTestBitmap->Gc().SetPenStyle(CGraphicsContext::ENullPen); + iTestBitmap->Gc().DrawRect(iWinRect.Size()); + iTestBitmap->Gc().Reset(); + iTestBitmapWin=new(ELeave) CBitMapWin(iTestBitmap); + CleanupStack::PushL(iTestBitmapWin); + iTestBitmapWin->ConstructExtLD(*TheClient->iGroup,iTestWinPoint,iWinRect.Size()); + iTestBitmapWin->BaseWin()->SetRequiredDisplayMode(EColor16MU); + iTestBitmapWin->BaseWin()->SetShadowDisabled(ETrue); + iTestBitmapWin->BaseWin()->SetShadowHeight(0); + iTestBitmapWin->AssignGC(*TheClient->iGc); + iTestBitmapWin->Activate(); + + // This if for testing with Invertmask as EFalse + TSize tempSize=bitmapSize; + DrawBitmapAndCheckL(tempSize,EColor16MU,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),EFalse); + + tempSize.SetSize(bitmapSize.iWidth*11/10,bitmapSize.iHeight*11/10); + iBitmapMaskedWin->SetDestRectSize(tempSize); + iBitmapMaskedWin->DrawNow(); + TheClient->WaitForRedrawsToFinish(); + DrawBitmapAndCheckL(tempSize,EColor16MU,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),EFalse); + + tempSize.SetSize(bitmapSize.iWidth*2/3,bitmapSize.iHeight*2/3); + iBitmapMaskedWin->SetDestRectSize(tempSize); + iBitmapMaskedWin->DrawNow(); + TheClient->WaitForRedrawsToFinish(); + DrawBitmapAndCheckL(tempSize,EColor16MU,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),EFalse); + + // This if for testing with Invertmask as ETrue + tempSize=bitmapSize; + iBitmapMaskedWin->SetInvertMask(ETrue); + iBitmapMaskedWin->SetDestRectSize(tempSize); + iBitmapMaskedWin->DrawNow(); + TheClient->WaitForRedrawsToFinish(); + DrawBitmapAndCheckL(tempSize,EColor16MU,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),ETrue); + + tempSize.SetSize(bitmapSize.iWidth*11/10,bitmapSize.iHeight*11/10); + iBitmapMaskedWin->SetDestRectSize(tempSize); + iBitmapMaskedWin->DrawNow(); + TheClient->WaitForRedrawsToFinish(); + DrawBitmapAndCheckL(tempSize,EColor16MU,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),ETrue); + + tempSize.SetSize(bitmapSize.iWidth*2/3,bitmapSize.iHeight*2/3); + iBitmapMaskedWin->SetDestRectSize(tempSize); + iBitmapMaskedWin->DrawNow(); + TheClient->WaitForRedrawsToFinish(); + DrawBitmapAndCheckL(tempSize,EColor16MU,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),ETrue); + + // With bitmap's display mode as EColor256 and invertmask EFalse + if (aWsBitmap) + { + wsBitmap->SetDisplayMode(EColor256); + } + else + { + fbsBitmap->SetDisplayMode(EColor256); + } + iBitmapMaskedWin->BaseWin()->SetRequiredDisplayMode(EColor256); + TheClient->Flush(); + TheClient->WaitForRedrawsToFinish(); + + // Delete the tempbitmap and tempbitmapwin and recreate once again. + CleanupStack::PopAndDestroy(2); // iTestBitmap, iTestBitmapWin + iTestBitmap=NULL; + iTestBitmapWin=NULL; + iTestBitmap=CBitmap::NewL(iWinRect.Size(),EColor256); + CleanupStack::PushL(iTestBitmap); + iTestBitmap->Gc().SetBrushColor(TRgb(255,0,0)); + iTestBitmap->Gc().SetBrushStyle(CGraphicsContext::ESolidBrush); + iTestBitmap->Gc().SetPenStyle(CGraphicsContext::ENullPen); + iTestBitmap->Gc().DrawRect(iWinRect.Size()); + iTestBitmap->Gc().Reset(); + iTestBitmapWin=new(ELeave) CBitMapWin(iTestBitmap); + CleanupStack::PushL(iTestBitmapWin); + iTestBitmapWin->ConstructExtLD(*TheClient->iGroup,iTestWinPoint,iWinRect.Size()); + iTestBitmapWin->BaseWin()->SetRequiredDisplayMode(EColor256); + iTestBitmapWin->BaseWin()->SetShadowDisabled(ETrue); + iTestBitmapWin->BaseWin()->SetShadowHeight(0); + iTestBitmapWin->AssignGC(*TheClient->iGc); + iTestBitmapWin->Activate(); + TheClient->Flush(); + TheClient->WaitForRedrawsToFinish(); + + tempSize=bitmapSize; + iBitmapMaskedWin->SetInvertMask(EFalse); + iBitmapMaskedWin->SetDestRectSize(tempSize); + iBitmapMaskedWin->DrawNow(); + TheClient->WaitForRedrawsToFinish(); + DrawBitmapAndCheckL(tempSize,EColor256,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),EFalse); + + tempSize.SetSize(bitmapSize.iWidth*11/10,bitmapSize.iHeight*11/10); + iBitmapMaskedWin->SetDestRectSize(tempSize); + iBitmapMaskedWin->DrawNow(); + TheClient->WaitForRedrawsToFinish(); + DrawBitmapAndCheckL(tempSize,EColor256,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),EFalse); + + tempSize.SetSize(bitmapSize.iWidth*2/3,bitmapSize.iHeight*2/3); + iBitmapMaskedWin->SetDestRectSize(tempSize); + iBitmapMaskedWin->DrawNow(); + TheClient->WaitForRedrawsToFinish(); + DrawBitmapAndCheckL(tempSize,EColor256,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),EFalse); + + // With bitmap's display mode as EColor256 and invertmask ETrue + tempSize=bitmapSize; + iBitmapMaskedWin->SetInvertMask(ETrue); + iBitmapMaskedWin->SetDestRectSize(tempSize); + iBitmapMaskedWin->DrawNow(); + TheClient->WaitForRedrawsToFinish(); + DrawBitmapAndCheckL(tempSize,EColor256,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),ETrue); + + tempSize.SetSize(bitmapSize.iWidth*11/10,bitmapSize.iHeight*11/10); + iBitmapMaskedWin->SetDestRectSize(tempSize); + iBitmapMaskedWin->DrawNow(); + TheClient->WaitForRedrawsToFinish(); + DrawBitmapAndCheckL(tempSize,EColor256,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),ETrue); + + tempSize.SetSize(bitmapSize.iWidth*2/3,bitmapSize.iHeight*2/3); + iBitmapMaskedWin->SetDestRectSize(tempSize); + iBitmapMaskedWin->DrawNow(); + TheClient->WaitForRedrawsToFinish(); + DrawBitmapAndCheckL(tempSize,EColor256,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),ETrue); + + //To test if DrawBitmapMask uses stored commands when called to redraw the bitmap. + if (aWsBitmap) + { + delete wsBitmapMask; //deleting the bitmap + wsBitmapMask=NULL; + DrawBitmapAndCheckL(tempSize,EColor256,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),ETrue); + } + CleanupStack::PopAndDestroy(3,iBitmapMaskedWin); // iBitmapMaskedWin,iTestBitmap,iTestBitmapWin + } + +void CTRedrawStoring::DrawBitmapAndCheckL(const TSize aSize,TDisplayMode aDisplayMode,CFbsBitmap* aSrceBitmap,CFbsBitmap* aMaskBitmap,TBool aInvertMask) + { + TBool retVal; + if (aMaskBitmap) + { + TRect srceRect(aSrceBitmap->SizeInPixels()); + TRect destRect(aSize); + CBitmap* srcTempBitmap=CBitmap::NewL(aSize,aDisplayMode); + CleanupStack::PushL(srcTempBitmap); + srcTempBitmap->Gc().DrawBitmap(destRect,aSrceBitmap,srceRect); + CBitmap* maskTempBitmap=CBitmap::NewL(aSize,EGray256); + CleanupStack::PushL(maskTempBitmap); + maskTempBitmap->Gc().DrawBitmap(destRect,aMaskBitmap,srceRect); + iTestBitmap->Gc().SetPenStyle(CGraphicsContext::ENullPen); + iTestBitmap->Gc().SetBrushColor(TRgb(255,0,0)); + iTestBitmap->Gc().SetBrushStyle(CGraphicsContext::ESolidBrush); + iTestBitmap->Gc().DrawRect(iWinRect.Size()); + iTestBitmap->Gc().BitBltMasked(TPoint(),&srcTempBitmap->Bitmap(),destRect,&maskTempBitmap->Bitmap(),aInvertMask); + iTestBitmap->Gc().Reset(); + iTestBitmapWin->DrawNow(); + TheClient->iWs.Finish(); + TheClient->WaitForRedrawsToFinish(); + retVal = TheClient->iScreen->RectCompare(TRect(iWinRect.iTl,aSize),TRect(iTestWinPoint,aSize)); + TEST(retVal); + if (!retVal) + INFO_PRINTF3(_L("TheClient->iScreen->RectCompare() return value - Expected: %d, Actual: %d"), ETrue, retVal); + CleanupStack::PopAndDestroy(2,srcTempBitmap); + } + else + //To test if DrawBitmapMask uses stored commands, when called to redraw the bitmap. + //After the bitmap "wsBitmapMask" is being deleted, the window "iBitmapMaskWin" is first made invisible + //and then visible on the screen. This operation invokes draw function which redraws the bitmap by using the stored commands. + { + iBitmapMaskedWin->SetVisible(EFalse); + iBitmapMaskedWin->SetVisible(ETrue); + retVal = TheClient->iScreen->RectCompare(TRect(iWinRect.iTl,aSize),TRect(iTestWinPoint,aSize)); + TEST(retVal); + if (!retVal) + INFO_PRINTF3(_L("TheClient->iScreen->RectCompare() return value - Expected: %d, Actual: %d"), ETrue, retVal); + } + } + + +/** + @SYMTestCaseID GRAPHICS-CODEBASE-WSERV-0052-0001 + @SYMPREQ PGM027 + + @SYMTestCaseDesc Tests CWsBitmap::BitBltMasked and CFbsBitmap::BitBltMasked API's with \n + By passing Null and unexpected values. + + @SYMTestPriority 1 + + @SYMTestStatus Implemented + + @SYMTestActions Call BitBltMasked with different ways + Source Bitpmap as NULL and MaskBitmap + Source Bitmap and MaskBitmap as NULL (For both CFbsBitmap, CWsBitmap) + + @SYMTestExpectedResults Should not panic even if the passed bitmaps are NULL. + + */ +void CTRedrawStoring::DoBitBltAndMaskedNegTestsL() + { + CWsBitmap* testBitmap=NULL; + CWsBitmap* maskBitmap=NULL; + // Passing null Masked bitmap + (TheClient->iGc)->BitBltMasked(TPoint(20,20), testBitmap, TRect(TPoint(0, 0), TSize(20,20)), maskBitmap, EFalse); + testBitmap=new(ELeave) CWsBitmap(TheClient->iWs); + CleanupStack::PushL(testBitmap); + User::LeaveIfError(testBitmap->Load(TEST_BITMAP_NAME,3)); + (TheClient->iGc)->BitBltMasked(TPoint(20,20), testBitmap, TRect(TPoint(0, 0), TSize(20,20)), maskBitmap, EFalse); + CleanupStack::PopAndDestroy(testBitmap); + testBitmap=NULL; + maskBitmap=new(ELeave) CWsBitmap(TheClient->iWs); + CleanupStack::PushL(maskBitmap); + User::LeaveIfError(maskBitmap->Load(TEST_BITMAP_NAME,4)); + // Passing null source bitmap + (TheClient->iGc)->BitBltMasked(TPoint(20,20), testBitmap, TRect(TPoint(0, 0), TSize(20,20)), maskBitmap, EFalse); + CleanupStack::PopAndDestroy(maskBitmap); + CFbsBitmap* samBitmap=NULL; + CFbsBitmap* mskBitmap=NULL; + // Passing null Masked bitmap + (TheClient->iGc)->BitBltMasked(TPoint(20,20), samBitmap, TRect(TPoint(0, 0), TSize(20,20)), mskBitmap, EFalse); + samBitmap=new(ELeave) CWsBitmap(TheClient->iWs); + CleanupStack::PushL(samBitmap); + User::LeaveIfError(samBitmap->Load(TEST_BITMAP_NAME,3)); + (TheClient->iGc)->BitBltMasked(TPoint(20,20), samBitmap, TRect(TPoint(0, 0), TSize(20,20)), mskBitmap, EFalse); + CleanupStack::PopAndDestroy(samBitmap); + samBitmap=NULL; + mskBitmap=new(ELeave) CWsBitmap(TheClient->iWs); + CleanupStack::PushL(mskBitmap); + User::LeaveIfError(mskBitmap->Load(TEST_BITMAP_NAME,4)); + // Passing null source bitmap + (TheClient->iGc)->BitBltMasked(TPoint(20,20), testBitmap, TRect(TPoint(0, 0), TSize(20,20)), mskBitmap, EFalse); + CleanupStack::PopAndDestroy(mskBitmap); + CWsBitmap* cwBitmap=NULL; + TPoint pos(0,0); + // Passing null CWsBitmap + TheClient->iGc->BitBlt(pos,cwBitmap); + TheClient->iGc->BitBlt(pos,cwBitmap,TRect(0,0,10,10)); + // Passing null CFbsBitmap + CFbsBitmap* fbsBitmap=NULL; + TheClient->iGc->BitBlt(pos,fbsBitmap); + TheClient->iGc->BitBlt(pos,fbsBitmap,TRect(0,0,10,10)); + } + +/* TESTCASE: INC095798 + * TITLE: Partial Draw Now Test + * IMPORTANCE: 1 + * + * ACTION: Changes the color of a rectangle inside a window to simulate CCoeControl::DrawNow() + * for an embedded control that does not own a window. + * + * RESULT: The rectangle should change color immediately, without waiting for a redraw event + * from the Window Server, and this should work with or without partial redraw storing and + * with or without transparency. + */ +void CTRedrawStoring::DoPartialDrawNowTestL( TBool aUseTransparency ) + { + /* + * Obtain the color of a particular reference pixel which will be used for + * comparison later on when the test window is added covering it. + */ + const TPoint referencePixel(iWinPos+TPoint(50,50)); + TRgb backgroundReferenceColor; + TheClient->Flush(); + TheClient->WaitForRedrawsToFinish(); + TheClient->iWs.Finish(); + TheClient->iScreen->GetPixel(backgroundReferenceColor, referencePixel); + /* + * Add a test window which emulates a CONE control with a lodger. + * The window is transparent according to parameter aUseTransparency + */ + CPartialDrawNowWin* testWin=new(ELeave) CPartialDrawNowWin; + CleanupStack::PushL(testWin); + testWin->ConstructL(*TheClient->iGroup); + testWin->AssignGC(*TheClient->iGc); + testWin->SetExt(iWinPos+TPoint(25,25),TSize(300,200)); + testWin->Win()->SetRequiredDisplayMode(iTestDisplayMode); + testWin->Win()->SetShadowDisabled(ETrue); + if (aUseTransparency) + TEST(testWin->MakeTransparent() == KErrNone); + testWin->Win()->Activate(); + testWin->Redraw(); + testWin->SetLodger(TRect(20,20,30,30)); + TheClient->Flush(); + TheClient->WaitForRedrawsToFinish(); + TheClient->iWs.Finish(); + TRgb actualColor; + TheClient->iScreen->GetPixel(actualColor,iWinPos+TPoint(50,50)); + if (aUseTransparency) + { + CColorBlender* blender = CColorBlender::NewLC(iTestDisplayMode); + blender->SetInitialColor(backgroundReferenceColor); + blender->Blend(TRgb(0, 0, 255, 127)); //the blue background of the window + blender->Blend(TRgb(0, 255, 0, 127)); //the green color of the lodger + const TRgb expectedColor = blender->Color(); + TEST_COLOR_MATCH(expectedColor, actualColor); + CleanupStack::PopAndDestroy(blender); + } + else + { + TEST_COLOR_MATCH(KRgbGreen, actualColor); + } + CleanupStack::PopAndDestroy(testWin); + } + +/*CPartialDrawNowWin*/ +CPartialDrawNowWin::CPartialDrawNowWin() + : iLodger( 0, 0, 0, 0 ) + {} + +TInt CPartialDrawNowWin::MakeTransparent() + { + const TInt err = iWin.SetTransparencyAlphaChannel(); + if(!err) + { + iWin.SetBackgroundColor(TRgb(0, 0, 0, 0)); + iTransparent = ETrue; + } + return err; + } + +void CPartialDrawNowWin::SetLodger( const TRect &aLodger ) + { + iLodger = aLodger; + iWin.Invalidate( aLodger ); + Redraw( aLodger ); + } + +void CPartialDrawNowWin::Redraw() + { + iWin.BeginRedraw(); + DrawWindowAndLodger(); + iWin.EndRedraw(); + } + +void CPartialDrawNowWin::Redraw( const TRect &aRect ) + { + iWin.BeginRedraw( aRect ); + DrawWindowAndLodger(); + iWin.EndRedraw(); + } + +void CPartialDrawNowWin::DrawWindowAndLodger() + { + iGc->Activate( iWin ); + iGc->SetPenStyle( CGraphicsContext::ENullPen ); + iGc->SetBrushStyle( CGraphicsContext::ESolidBrush ); + iGc->SetBrushColor( iTransparent ? TRgb(0, 0, 255, 127) : KRgbBlue ); + iGc->Clear(); + if (!iLodger.IsEmpty()) + { + iGc->SetBrushColor( iTransparent ? TRgb(0, 255, 0, 127) : KRgbGreen ); + iGc->DrawRect( iLodger ); + } + iGc->Deactivate(); + } + + + +/* TESTCASE: PDEF101789 + TITLE: Expose Window Test for PDEF101789: WServ does not perform well in 9.2 release. + + ACTION: Draws a base window followed by a top window that completly covers the base window. + The base window has an area invalidated and the top window is then moved out of the + way to expose the bottom window. The invalid are is then drawn to within a begin/end redraw + + RESULT: The invalid area on the base window should be redrawn correctly betweeen the begin/end + redraw pair after the base window has been exposed. The invalid area is drawn in a different + colour to the base window. + */ +void CTRedrawStoring::DoExposeTestL(TInt aIteration) + { + _LIT(KErrorMessage,"Expected colour value does not match actual value : Windows not drawn correctly"); + + TPartialRedrawType type = iTest->RedrawStoreTypeL(); + if(type==EPartialRedraw_FullRedrawSupport) + { + //draw a green coloured base window + CPartialRedrawBottomWin* bottomWin = new (ELeave) CPartialRedrawBottomWin(); + CleanupStack::PushL(bottomWin); + bottomWin->ConstructL(*TheClient->iGroup); + bottomWin->Init(); + bottomWin->AssignGC(*TheClient->iGc); + bottomWin->BaseWin()->SetShadowDisabled(ETrue); + bottomWin->BaseWin()->SetShadowHeight(0); + bottomWin->SetExt(iWinPos+TPoint(10,10), iTest->StdTestWindowSize()); + bottomWin->Win()->Activate(); + bottomWin->DrawPartial(TRect(TPoint(0,0), iTest->StdTestWindowSize())); + TheClient->Flush(); + + //draw a red coloured top window that completely covers the base window + CPartialRedrawTopWin* topWin = new (ELeave) CPartialRedrawTopWin(); + CleanupStack::PushL(topWin); + topWin->ConstructL(*TheClient->iGroup); + topWin->Init(); + topWin->AssignGC(*TheClient->iGc); + topWin->BaseWin()->SetShadowDisabled(ETrue); + topWin->BaseWin()->SetShadowHeight(0); + topWin->SetExt(iWinPos+TPoint(10,10),iTest->StdTestWindowSize()); + topWin->Win()->Activate(); + topWin->DrawPartial(TRect(TPoint(0,0), iTest->StdTestWindowSize())); + TheClient->Flush(); + + //Invalidate the an area on the bottom window. + TRect rect(TPoint(10,10), TSize(iTest->StdTestWindowSize().iWidth/4, iTest->StdTestWindowSize().iHeight/4)); + bottomWin->Win()->Invalidate(rect); + + //Now expose the bottom window by moving the top window out of the way + //using one of the methods below + switch(aIteration) + { + case 0: + topWin->Win()->SetOrdinalPosition(-10); + break; + case 1: + topWin->SetPos(iWinPos + TPoint(150,150)); + break; + case 2: + topWin->SetVisible(EFalse); + break; + } + + //now do a begin/end redraw to draw a blue rect to the invalid area on the bottom window + bottomWin->Win()->BeginRedraw(rect); + bottomWin->Gc()->Activate(*bottomWin->Win()); + bottomWin->Gc()->SetBrushStyle(CGraphicsContext::ESolidBrush); + bottomWin->Gc()->SetBrushColor(TRgb(0,0,255,255)); + bottomWin->Gc()->SetPenStyle(CGraphicsContext::ESolidPen); + bottomWin->Gc()->SetPenColor(0); + bottomWin->Gc()->DrawRect(rect); + bottomWin->Gc()->Deactivate(); + bottomWin->Win()->EndRedraw(); + TheClient->Flush(); + + //get the color of a pixel within the invalid area that should be coloured + //blue if the window is redrawn correctly. In the defect this blue area is NOT drawn + TPoint point =iWinPos + TPoint(30,30); + TRgb colour; + TheClient->iScreen->GetPixel(colour,point); + TRgb expectedColour=TRgb(0,0,255,255); + TEST(colour == expectedColour); + if (colour!=expectedColour) + INFO_PRINTF1(KErrorMessage); + + CleanupStack::PopAndDestroy(2, bottomWin); + } + } +/*CPartialRedrawTopWin*/ +void CPartialRedrawTopWin::Init() + { + Win()->SetRequiredDisplayMode(EColor16MA); + Win()->SetTransparencyAlphaChannel(); + Win()->SetBackgroundColor(TRgb(255,255,255,255)); + } + +void CPartialRedrawTopWin::Draw() + { + DoDraw(); + } + +void CPartialRedrawTopWin::DoDraw() + { + DrawFullWindowRect(); + } + +void CPartialRedrawTopWin::DrawFullWindowRect() + { + TRect rect = TRect(TPoint(0,0),iSize); + iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + iGc->SetBrushColor(TRgb(255,0,0,255)); + iGc->DrawRect(rect); + } + +void CPartialRedrawTopWin::DrawPartial(TRect aRect) + { + Invalidate(aRect); + Win()->BeginRedraw(aRect); + iGc->Activate(*Win()); + DrawFullWindowRect(); + iGc->Deactivate(); + Win()->EndRedraw(); + } + +/*CPartialRedrawBottomWin*/ +void CPartialRedrawBottomWin::Init() + { + Win()->SetRequiredDisplayMode(EColor16MA); + Win()->SetTransparencyAlphaChannel(); + Win()->SetBackgroundColor(TRgb(255,255,255,255)); + } + +void CPartialRedrawBottomWin::Draw() + { + DoDraw(); + } + +void CPartialRedrawBottomWin::DoDraw() + { + DrawFullWindowRect(); + } + +void CPartialRedrawBottomWin::DrawFullWindowRect() + { + TRect rect = TRect(TPoint(0,0),iSize); + iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + iGc->SetBrushColor(TRgb(0,255,0,255)); + iGc->DrawRect(rect); + } + +void CPartialRedrawBottomWin::DrawPartial(TRect aRect) + { + Invalidate(aRect); + Win()->BeginRedraw(aRect); + iGc->Activate(*Win()); + DrawFullWindowRect(); + iGc->Deactivate(); + Win()->EndRedraw(); + } + +//CPartialRedrawTiledWin + +void CPartialRedrawTiledWin::Init(TRgb aColour,TBool aTransparent) + { + iColour=aColour; + Win()->SetRequiredDisplayMode(EColor16MA); + if(aTransparent) + { + Win()->SetTransparencyAlphaChannel(); + } + Win()->SetBackgroundColor(iColour); + } + +void CPartialRedrawTiledWin::Draw() + { + DoDraw(); + } + +void CPartialRedrawTiledWin::DoDraw() + { + DrawFullWindowRect(); + } + +void CPartialRedrawTiledWin::DrawFullWindowRect() + { + TRect rect = TRect(TPoint(0,0),iSize); + iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + iGc->SetBrushColor(iColour); + iGc->DrawRect(rect); + } + +void CPartialRedrawTiledWin::DrawPartial(TRect aRect) + { + Invalidate(aRect); + Win()->BeginRedraw(aRect); + iGc->Activate(*Win()); + DrawFullWindowRect(); + iGc->Deactivate(); + Win()->EndRedraw(); + } + +/* TESTCASE: DEF101889 + TITLE: Expose Window Test for DEF101889 Windows tiled by opaque children do not redraw correctly + under certain use cases + + ACTION: Draws a base window then a further window over it that is tiled by opaque children. + This window is then, either completely or partially, covered by a transparent window. + The tiled window is then set invisible. Drawing is then performed to the base window. + + RESULT: The windows should be correctly drawn. More specifically the transparent top window should draw + the correct window underneath it. i.e. after the setinvisible command the base window should be + drawn + */ +void CTRedrawStoring::DoExposeTest2L(TInt aIteration) + { + //This test reproduces problems found during the fixing of DEF096874: WServ does not perform well in 9.2 release. + //The issues (described later) only exhbit themselves when there are no shadows present in the system. + //Unfortunatly there is no direct way of disabling shadows from the test code so under normal running the + //following tests will never hit the defect and always pass. + //To disable shadows the WSERV source code has to be manually altered by editing the CWsClientWindow::CommandL + //method in clwin.cpp. In the EWsWinOpSetShadowHeight case alter the SetHeightDiff(*pData.Int); function call + //to read SetHeightDiff(0); + //The use cases are related to DEF096874 in that the problem occurs when we have 2 windows overlaying each other + //where the top window is completely tiled by child windows. DEF096874 occurs when the window that is tiled is made + //invisible, with the result that the windows are not redrawn correctly. + //The use cases reproduced by this test are when the two windows are either fully or partially obscured by a + //further transparent window laid over the both of them. When the tiled window is made invisible then + //the windows are not updated properly resulting in either transparency problems or the windows not being drawn + //correctly. + //There are further use cases not addressed here i.e. tiled windows becoming visible underneath a transparent window + //that relate to the same fundamental problem but are correctlly addressed by the defect fix. + + TPartialRedrawType type=iTest->RedrawStoreTypeL(); + if(type!=EPartialRedraw_FullRedrawSupport) + return; + + _LIT(KErrorMessage,"Pixel expected to have colour 0x%x has color 0x%x"); + const TSize winSize=iTest->StdTestWindowSize(); + const TInt offset=winSize.iWidth/2; + + //draw a green coloured base window + CPartialRedrawBottomWin* underWin = new(ELeave) CPartialRedrawBottomWin(); + CleanupStack::PushL(underWin); + underWin->ConstructL(*TheClient->iGroup); + underWin->Init(); + underWin->AssignGC(*TheClient->iGc); + underWin->BaseWin()->SetShadowDisabled(ETrue); + underWin->SetExt(iWinPos+TPoint(10,10),winSize); + underWin->Win()->Activate(); + underWin->DrawPartial(TRect(winSize)); + if (TDisplayModeUtils::NumDisplayModeColors(underWin->BaseWin()->DisplayMode())<=4096) + { + CleanupStack::PopAndDestroy(underWin); + _LIT(KLog,"Cannot run test without more than 4K colors"); + LOG_MESSAGE(KLog); + return; + } + + //draw a red coloured top window that completly covers the base window + CPartialRedrawTopWin* overWin = new (ELeave) CPartialRedrawTopWin(); + CleanupStack::PushL(overWin); + overWin->ConstructL(*TheClient->iGroup); + overWin->Init(); + overWin->AssignGC(*TheClient->iGc); + overWin->BaseWin()->SetShadowDisabled(ETrue); + overWin->SetExt(iWinPos+TPoint(10,10),winSize); + overWin->Win()->Activate(); + overWin->DrawPartial(TRect(winSize)); + + //create the two tiles to attach to the top window + CPartialRedrawTiledWin* tile = new (ELeave) CPartialRedrawTiledWin(); + CleanupStack::PushL(tile); + tile->ConstructL(*overWin); + tile->Init(TRgb(255,255,0,255),EFalse); + tile->AssignGC(*TheClient->iGc); + tile->BaseWin()->SetShadowDisabled(ETrue); + tile->SetSize(winSize); + tile->Win()->Activate(); + tile->DrawPartial(TRect(winSize)); + + //create a transparent window overlaying the whole arrangement + CPartialRedrawTiledWin* transparentWin = new (ELeave) CPartialRedrawTiledWin(); + CleanupStack::PushL(transparentWin); + transparentWin->ConstructL(*TheClient->iGroup); + transparentWin->Init(TRgb(255,255,255,0),ETrue); + transparentWin->AssignGC(*TheClient->iGc); + transparentWin->BaseWin()->SetShadowDisabled(ETrue); + //for the first iteration have the transparent window fully covering the other windows + //for the second iteration have the tansparent window partially covering the other windows. + transparentWin->SetExt(iWinPos+TPoint(10+(aIteration==0?0:offset),10),winSize); + transparentWin->Win()->Activate(); + transparentWin->DrawPartial(TRect(winSize)); + + //Now expose the bottom window (underWin) by setting the top window (overWin) invisible + //the opaque child window (tile) should also go invisible + overWin->SetVisible(EFalse); + TheClient->Flush(); + TheClient->WaitForRedrawsToFinish(); + //get the color of a pixel within the window. If everything has been drawn correctly the + //pixel should be green ( the colour of the base window, underWin) + TPoint point =iWinPos + TPoint(30,30); + TRgb colour; + TheClient->iScreen->GetPixel(colour,point); + TRgb expectedColour=TRgb(0,255,0,255); + TEST(colour == expectedColour); + if (colour!=expectedColour) + LOG_MESSAGE3(KErrorMessage,expectedColour.Value(),colour.Value()); + //for partially covered windows the above code tests the uncovered region so an additional test + //is needed on a pixel in the covered region. + if (aIteration!=0) + { + point+=TPoint(offset,0); + TheClient->iScreen->GetPixel(colour,point); + TEST(colour==expectedColour); + if (colour!=expectedColour) + LOG_MESSAGE3(KErrorMessage,expectedColour.Value(),colour.Value()); + } + CleanupStack::PopAndDestroy(4, underWin); //tile,topWin,transparentWin + } + +/* Test automatically purging the redraw store */ + +CResetRedrawStoreWin* CTRedrawStoring::CreatePartialRedrawWinLC(const TPoint &aPos, const TSize &aSize, CTWin *aParent) + { + CResetRedrawStoreWin* testWin = new (ELeave) CResetRedrawStoreWin(); + CleanupStack::PushL(testWin); + if (aParent) + testWin->ConstructL(*aParent); + else + testWin->ConstructL(*TheClient->iGroup); + testWin->Init(); + testWin->AssignGC(*TheClient->iGc); + testWin->BaseWin()->SetShadowDisabled(ETrue); + testWin->BaseWin()->SetShadowHeight(0); + testWin->Win()->SetVisible(EFalse); + testWin->Win()->Activate(); + testWin->SetExt(aPos,aSize); + testWin->SetVisible(ETrue); + return(testWin); + } + +CNoDrawWin* CTRedrawStoring::CreateNoDrawWinLC(const TPoint &aPos, const TSize &aSize) + { + CNoDrawWin* noDrawWin=new (ELeave) CNoDrawWin(); + CleanupStack::PushL(noDrawWin); + noDrawWin->ConstructExtLD(*TheClient->iGroup, aPos, aSize); + noDrawWin->AssignGC(*TheClient->iGc); + noDrawWin->Win()->SetRequiredDisplayMode(iTestDisplayMode); + noDrawWin->Win()->SetTransparencyAlphaChannel(); + noDrawWin->Win()->SetBackgroundColor(TRgb(127,127,127,127)); + noDrawWin->BaseWin()->SetShadowDisabled(ETrue); + noDrawWin->BaseWin()->SetShadowHeight(0); + noDrawWin->Win()->SetVisible(ETrue); + noDrawWin->Activate(); + noDrawWin->Win()->BeginRedraw(); + noDrawWin->Gc()->Activate(*noDrawWin->Win()); + CPartialRedrawWin::DrawRects(*noDrawWin->Gc(), aSize, + TPoint(0,0), ETrue, EPartialRedraw_Unknown); + noDrawWin->Gc()->Deactivate(); + noDrawWin->Win()->EndRedraw(); + return(noDrawWin); + } + +void CTRedrawStoring::AutoResetRedrawStoreTestsL() + { + //PeterI This tests redraw store resetting by monitoring the wserv heap. + //It currently fails as it performs too many iterations of the test i.e. it doesn't reset as frequently + //as the orignal werv. Needs investigation to determine what the expected number of resets should be for + //the Mk3 wserv. + /* + if (iPartialRedrawType==EPartialRedraw_FullRedrawSupport) + { + const TInt startWsHeapCount=TheClient->iWs.HeapCount(); + const TInt KNumFlagsToTest=4; + const TInt KNumFlagStatesToTest=1<iWs.HeapCount(); + TEST((startWsHeapCount+KHeapTotalSafetyMargin)>=endHeapCount); + } + */ + } + +void CTRedrawStoring::DoAutoResetRedrawStoreTestL(TBool aTwoWins, TBool aAnimateBothWins, TBool aKeepGcActive, TBool aUpdateInRedraw) + { + TRect testRect1(iTestWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),iWinSize); + TRect testRect2(iCheckWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),iWinSize); +// + TSize testWinSize1(iWinSize.iWidth/3,iWinSize.iHeight/3); + TSize testWinSize2(iWinSize.iWidth/2,iWinSize.iHeight/2); + TPoint topLeft=iWinPos+TPoint(100,100); + TInt tooBig=topLeft.iX+testWinSize1.iWidth-testRect1.iBr.iX; + if (tooBig>0) + topLeft.iX-=tooBig; + + CResetRedrawStoreWin* testWin1=CreatePartialRedrawWinLC(topLeft,testWinSize1); + CResetRedrawStoreWin* testWin2=CreatePartialRedrawWinLC(topLeft-TPoint(50,50),testWinSize2); + testWin1->SetUpdateInRedraw(aUpdateInRedraw); + testWin2->SetUpdateInRedraw(aUpdateInRedraw); +// + topLeft+=iCheckWin->Position()-iWinPos; + CResetRedrawStoreWin* tW1=CreatePartialRedrawWinLC(topLeft,testWinSize1); + CResetRedrawStoreWin* tW2=CreatePartialRedrawWinLC(topLeft-TPoint(50,50),testWinSize2); + tW1->SetUpdateInRedraw(aUpdateInRedraw); + tW2->SetUpdateInRedraw(aUpdateInRedraw); +// + TheClient->Flush(); + TheClient->WaitForRedrawsToFinish(); +// + const TInt KNumTestResets1=5; + const TInt KNumTestResets2=15; + const TInt KMaxIterationsPerReset=20; + const TInt numTestResets=aTwoWins?KNumTestResets2:KNumTestResets1; + const TInt maxTotalIterations=numTestResets*KMaxIterationsPerReset; + TInt resets=0; +// + const TInt startWsHeapCount=TheClient->iWs.HeapCount(); + TInt baseWsHeapCount=startWsHeapCount; + TInt prevWsHeapCount=0; + TInt totalIterations=0; + testWin1->SetKeepGcActive(aKeepGcActive); + if (aAnimateBothWins) + testWin2->SetKeepGcActive(aKeepGcActive); + do + { + testWin1->UpdateAnim(1); + testWin1->UpdateAnim(1); + testWin1->UpdateAnim(1); + if (aAnimateBothWins) + testWin2->UpdateAnim(3); + if (aTwoWins) + { + tW1->UpdateAnim(1); + tW1->UpdateAnim(2); + if (aAnimateBothWins) + { + tW2->UpdateAnim(1); + tW2->UpdateAnim(1); + tW2->UpdateAnim(1); + } + } + TBool failed=testWin1->Failed(); + TEST(!failed); + if (failed) + { + _LIT(KLog,"Window had fail flag set"); + LOG_MESSAGE(KLog); + } +// + TheClient->Flush(); + TheClient->WaitForRedrawsToFinish(); + if (aTwoWins && !aUpdateInRedraw) + { + TBool match=TheClient->iScreen->RectCompare(testRect1,testRect2); + TEST(match); + if (!match) + { + _LIT(KLog,"Rectangle Area doesn't match, resets=%d (TwoWins=%d,AnimateBoth=%d,KeepActive=%d,InRedraw=%d)"); + LOG_MESSAGE6(KLog,resets,aTwoWins,aAnimateBothWins,aKeepGcActive,aUpdateInRedraw); + } + } + const TInt wsHeapCount=TheClient->iWs.HeapCount(); + TInt lowGap=wsHeapCount-baseWsHeapCount; + TInt highGap=prevWsHeapCount-wsHeapCount; + if (prevWsHeapCount>0 && ((aAnimateBothWins || aTwoWins)?highGap>0:lowGap=maxTotalIterations) + { + TEST(EFalse); + _LIT(KLog,"Too many iterations, number %d, max expect %d"); + LOG_MESSAGE3(KLog,totalIterations,maxTotalIterations); + break; + } + prevWsHeapCount=wsHeapCount; + } while(resetsiWs.HeapCount(); + const TInt KHeapSafetyMargin=4; // Granularity of buffers can leave odd extra cells, hard to specify an exact amount + TBool heapUsageError=(startWsHeapCount+KHeapSafetyMargin>=endHeapCount); + TEST(heapUsageError); + if (!heapUsageError) + { + _LIT(KLog,"Memory Allocation Error, Before=%d, After=%d (Allowable Margin=%d)"); + LOG_MESSAGE4(KLog,startWsHeapCount,endHeapCount,KHeapSafetyMargin); + } + } + } +// + CleanupStack::PopAndDestroy(4, testWin1); + } + +void CTRedrawStoring::RedrawStoreWithSetExtentL() +/* Test how the redraw store deals with windows changing their extent +*/ + { + TSize testSize(4*iWinSize.iWidth/7, iWinSize.iHeight); + TRect testRect1(iTestWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),testSize); + TRect testRect2(iCheckWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),testSize); + TSize testWinSize1a; + TSize testWinSize2; + TPoint winOffset1; + TPoint winOffset2; + GetTestWinSizeAndPos(1,winOffset1,testWinSize1a); + GetTestWinSizeAndPos(0,winOffset2,testWinSize2); + TPoint winPos1(iWinPos + winOffset1); + enum TSetExtentTestMode {ESetExtentTestModeExpandXY,ESetExtentTestModeExpandY,ESetExtentTestModeShrinkXY,ESetExtentTestModeShrinkY,ESetExtentTestModeShrinkXExpandY,ESetExtentTestModeCount}; + for(TInt extMode=ESetExtentTestModeExpandXY;extModePosition() + winOffset1, testWinSize1a); + CResetRedrawStoreWin* tW2=CreatePartialRedrawWinLC(iCheckWin->Position() + winOffset2, testWinSize2); + TheClient->Flush(); + TheClient->WaitForRedrawsToFinish(); +// + if (invalidateMode==ESetExtentInvalidateTestModeBeforeWithRedraw) + { + testWin1->PreSetSize(testWinSize1a); + testWin1->DrawNow(); + } + if (invalidateMode==ESetExtentInvalidateTestModeBefore) + testWin1->Invalidate(); + testWin1->SetExt(winPos1,testWinSize1a); + if (invalidateMode==ESetExtentInvalidateTestModeAfter) + testWin1->Invalidate(); + TheClient->Flush(); + TBool redrawWaiting=TheClient->WaitUntilRedrawPending(); + TheClient->WaitForRedrawsToFinish(); + TInt testRet=TheClient->iScreen->RectCompare(testRect1,testRect2); + if (!testRet) + { + TEST(EFalse); + _LIT(KRedrawStoreSetExtentFail,"Fade Regions fail: extMode=%d, invalidateMode=%d"); + LOG_MESSAGE3(KRedrawStoreSetExtentFail,extMode,invalidateMode); + } +// + CleanupStack::PopAndDestroy(4, testWin1); + } + } + } + +void CTRedrawStoring::PartialRedrawWithEmptyRedrawStoreL() + { + for(TInt numWins=1;numWins<4;numWins++) + { + const TInt KNumTestFlags=3; + for(TUint flags=0;flags<(1<Position() + winOffset1, testWinSize1); + CResetRedrawStoreWin* testWin2=NULL; + CResetRedrawStoreWin* testWin3=NULL; + if (aChildWindows) + { + TPoint winOffset2(TPoint(testWinSize1.iWidth/4,testWinSize1.iHeight/3)); + testWin2=CreatePartialRedrawWinLC(winOffset2, testWinSize2, aChildWindows?testWin1:NULL); + CreatePartialRedrawWinLC(winOffset2, testWinSize2, aChildWindows?tW1:NULL); + if (aNumWins>2) + { + TPoint winOffset3(TPoint(testWinSize1.iWidth/2,testWinSize1.iHeight*2/3)); + testWin3=CreatePartialRedrawWinLC(winOffset3, testWinSize3, aChildWindows?testWin1:NULL); + CreatePartialRedrawWinLC(winOffset3, testWinSize3, aChildWindows?tW1:NULL); + } + } + else + { + if (aNumWins>1) + { + TPoint winOffset2(TPoint(50,50)); + testWin2=CreatePartialRedrawWinLC(iWinPos + winOffset2, testWinSize2, aChildWindows?testWin1:NULL); + CreatePartialRedrawWinLC(iCheckWin->Position() + winOffset2, testWinSize2, aChildWindows?tW1:NULL); + if (aNumWins>2) + { + TPoint winOffset3(TPoint(iWinSize.iWidth/6,iWinSize.iHeight/3)); + testWin3=CreatePartialRedrawWinLC(iWinPos + winOffset3, testWinSize3, aChildWindows?testWin1:NULL); + CreatePartialRedrawWinLC(iCheckWin->Position() + winOffset3, testWinSize3, aChildWindows?tW1:NULL); + } + } + } + TheClient->Flush(); + TheClient->WaitForRedrawsToFinish(); + iDrawMode=EClientRedrawsNormal; +// + TSize testSize(4*iWinSize.iWidth/7, iWinSize.iHeight); + TRect testRect1(iTestWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),testSize); + TRect testRect2(iCheckWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),testSize); + TRect partialRedrawRect1(0,testWinSize1.iHeight/4,testWinSize1.iWidth,testWinSize1.iHeight*3/4); + TRect partialRedrawRect2(0,testWinSize2.iHeight/4,testWinSize1.iWidth,testWinSize2.iHeight*3/4); + TRect partialRedrawRect3(testWinSize3.iWidth/4,0,testWinSize3.iWidth*3/4,testWinSize3.iHeight); + iBlankWin.SetExtent(iWinPos+winOffset1+partialRedrawRect1.iTl, partialRedrawRect1.Size()); + const TInt KDoWindow1=0x01; + const TInt KDoWindow2=0x02; + const TInt KDoWindow3=0x04; + TInt numWinModes=1<iWs.ClearAllRedrawStores(); + if (invalidateWindowFlags&KDoWindow1) + testWin1->Invalidate(partialRedrawRect1); + if (invalidateWindowFlags&KDoWindow2) + testWin2->Invalidate(partialRedrawRect2); + if (invalidateWindowFlags&KDoWindow3) + testWin3->Invalidate(partialRedrawRect3); + if (aRedrawWindow) + { + if (invalidateWindowFlags&KDoWindow1) + testWin1->Redraw(partialRedrawRect1); + if (invalidateWindowFlags&KDoWindow2) + testWin1->Redraw(partialRedrawRect2); + if (invalidateWindowFlags&KDoWindow3) + testWin1->Redraw(partialRedrawRect3); + } + if (aDoWinOnTop) + { + iBlankWin.SetOrdinalPosition(0); + iBlankWin.SetVisible(ETrue); + iBlankWin.SetVisible(EFalse); + } + TheClient->Flush(); + TheClient->WaitForRedrawsToFinish(); + // + TBool match=TheClient->iScreen->RectCompare(testRect1,testRect2); + TEST(match); + if (!match) + { + _LIT(KLog,"Rectangle area doesn't match, windows=%d, flags=%d,%d,%d"); + LOG_MESSAGE5(KLog,aNumWins,aDoWinOnTop,aRedrawWindow,aChildWindows); + } + } + // Resetting iBlankWin to its original size and position for future use + // by other test cases + iBlankWin.SetExtent(iWinPos,iWinSize); + // window handles which are pushed onto cleanup stack, shall be deleted here + CleanupStack::PopAndDestroy(aNumWins*2,testWin1); + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-103713-0001 + +@SYMDEF PDEF106998 + +@SYMTestCaseDesc Empty Draw Test + +@SYMTestPriority + +@SYMTestStatus Implemented + +@SYMTestActions Draws an empty base window followed by an empty top window. + The top window is drawn in one of two cases: + completely covering the bottom window or + only covering the area that will be drawn to + + A red rectangle is drawn to the bottom window and the top window is made invisible. + +@SYMTestExpectedResults The tested pixel colour should be red. Test will fail if the red rectangle + is not drawn or if an infinite loop is detected. + +*/ +void CTRedrawStoring::DoEmptyDrawTestL(TInt aTestMode) + { + _LIT(KErrorMessage,"Infinite Loop"); + + TPartialRedrawType type = iTest->RedrawStoreTypeL(); + if(type==EPartialRedraw_FullRedrawSupport) + { + TBool testStatus = EFalse; + + //draw an empty, green base window + CPartialRedrawEmptyWin* bottomWin = new (ELeave) CPartialRedrawEmptyWin(); + CleanupStack::PushL(bottomWin); + bottomWin->ConstructL(*TheClient->iGroup); + bottomWin->Init(KRgbGreen); + bottomWin->AssignGC(*TheClient->iGc); + bottomWin->BaseWin()->SetShadowDisabled(ETrue); + bottomWin->BaseWin()->SetShadowHeight(0); + bottomWin->SetExt(iWinPos+TPoint(10,10), iWinSize); + bottomWin->Win()->Activate(); + bottomWin->DrawPartial(TRect(TPoint(0,0), iWinSize)); + TheClient->Flush(); + + //draw an empty, blue top window + CPartialRedrawEmptyWin* topWin = new (ELeave) CPartialRedrawEmptyWin(); + CleanupStack::PushL(topWin); + topWin->ConstructL(*TheClient->iGroup); + topWin->Init(KRgbBlue); + topWin->AssignGC(*TheClient->iGc); + topWin->BaseWin()->SetShadowDisabled(ETrue); + topWin->BaseWin()->SetShadowHeight(0); + + switch(aTestMode) + { + case 0: + // top window is completely covering the base window + topWin->SetExt(iWinPos+TPoint(10,10), iWinSize); + break; + case 1: + // top window only covers the upper left hand corner, + // over where the red rectangle will be drawn + topWin->SetExt(iWinPos+TPoint(-5,-5), iWinSize); + break; + } + + topWin->Win()->Activate(); + topWin->DrawPartial(TRect(TPoint(0,0), iWinSize)); + TheClient->Flush(); + + //Invalidate the an area on the top window. + TRect smallrect(TPoint(10,10), TSize(iWinSize.iWidth/4, iWinSize.iHeight/4)); + topWin->Win()->Invalidate(smallrect); + + //draw a small red rectangle on the bottom window + bottomWin->Win()->BeginRedraw(smallrect); + bottomWin->Gc()->Activate(*bottomWin->Win()); + bottomWin->Gc()->SetBrushStyle(CGraphicsContext::ESolidBrush); + bottomWin->Gc()->SetBrushColor(KRgbRed); + bottomWin->Gc()->SetPenStyle(CGraphicsContext::ESolidPen); + bottomWin->Gc()->SetPenColor(0); + bottomWin->Gc()->DrawRect(smallrect); + bottomWin->Gc()->Deactivate(); + bottomWin->Win()->EndRedraw(); + TheClient->Flush(); + TheClient->WaitForRedrawsToFinish(); + + // hide the top window, so that the bottom window will be redrawn + topWin->SetVisible(EFalse); + TheClient->Flush(); + TheClient->WaitForRedrawsToFinish(); + + // check to see if an 'infinite' loop occured + if ((topWin->ReturnCount() > KEmptyLoopThreshold) || (bottomWin->ReturnCount() > KEmptyLoopThreshold)) + INFO_PRINTF1(KErrorMessage); + + //get the color of a pixel within the invalid area that should be coloured + //red if the window is redrawn correctly. + TPoint point =iWinPos + TPoint(30,30); + TRgb colour; + TheClient->iScreen->GetPixel(colour,point); + TRgb expectedColour = KRgbRed; + + if ((colour == expectedColour) && (topWin->ReturnCount() < KEmptyLoopThreshold) && (bottomWin->ReturnCount() < KEmptyLoopThreshold)) + testStatus = ETrue; + + TEST(testStatus); + + CleanupStack::PopAndDestroy(2, bottomWin); + } + } + +void CTRedrawStoring::DoPolygonRedrawTestSetL() + { + _LIT(KRedrawStoringPolygon0,"Test polygon redraw in opaque window"); + _LIT(KRedrawStoringPolygon1,"Test polygon low priority redraw in opaque window"); + _LIT(KRedrawStoringPolygon2,"Test polygon redraw in transparent window"); + _LIT(KRedrawStoringPolygon3,"Test polygon low priority redraw in transparent window"); + INFO_PRINTF1(KRedrawStoringPolygon0); + DoPolygonRedrawTestL(0,0); // Polygon redraw in opaque window + INFO_PRINTF1(KRedrawStoringPolygon1); + DoPolygonRedrawTestL(0,1); // Polygon low priority redraw in opaque window + INFO_PRINTF1(KRedrawStoringPolygon2); + DoPolygonRedrawTestL(1,0); // Polygon redraw in transparent window + INFO_PRINTF1(KRedrawStoringPolygon3); + DoPolygonRedrawTestL(1,1); // Polygon low priority redraw in transparent window + } + +void CTRedrawStoring::DoPolygonRedrawTestL(TInt aWindowMode, TInt aTestMode) + { + //Used to place windows. + TInt gap = 5; + const TSize scrSize(TheClient->iScreen->SizeInPixels()); + TheClient->iWs.SetBufferSizeL(640); + + CPartialRedrawPolygonWin* polyTestWin = NULL; + if (aTestMode == 0) //If polygon redraw test. + { + //Draw a green test window with a polygon in it. + polyTestWin = new (ELeave) CPartialRedrawPolygonWin(); + CleanupStack::PushL(polyTestWin); + polyTestWin->ConstructL(*TheClient->iGroup); + polyTestWin->Init(aWindowMode, KRgbGreen); //aWindowMode 0=opaque 1=transparent + polyTestWin->AssignGC(*TheClient->iGc); + polyTestWin->BaseWin()->SetShadowDisabled(ETrue); + polyTestWin->BaseWin()->SetShadowHeight(0); + polyTestWin->SetExt(TPoint(scrSize.iWidth-iWinSize.iWidth,0), iWinSize); + polyTestWin->Win()->Activate(); + polyTestWin->DrawPartial(); + TheClient->Flush(); + } + + //Draw a green base window with a polygon in it. + CPartialRedrawPolygonWin* bottomWin = new (ELeave) CPartialRedrawPolygonWin(); + CleanupStack::PushL(bottomWin); + bottomWin->ConstructL(*TheClient->iGroup); + bottomWin->Init(aWindowMode, KRgbGreen); //aWindowMode 0=opaque 1=transparent + bottomWin->AssignGC(*TheClient->iGc); + bottomWin->BaseWin()->SetShadowDisabled(ETrue); + bottomWin->BaseWin()->SetShadowHeight(0); + bottomWin->SetExt(TPoint(scrSize.iWidth-(2*iWinSize.iWidth)-gap,0), iWinSize); + bottomWin->Win()->Activate(); + bottomWin->DrawPartial(); + TheClient->Flush(); + + //Draw an empty, blue transparent top window. + CPartialRedrawEmptyWin* topWin = new (ELeave) CPartialRedrawEmptyWin(); + CleanupStack::PushL(topWin); + topWin->ConstructL(*TheClient->iGroup); + topWin->Init(KRgbBlue); + topWin->AssignGC(*TheClient->iGc); + topWin->BaseWin()->SetShadowDisabled(ETrue); + topWin->BaseWin()->SetShadowHeight(0); + topWin->SetExt(TPoint(scrSize.iWidth-(2*iWinSize.iWidth)-gap,0), iWinSize); + topWin->Win()->Activate(); + topWin->DrawPartial(TRect(TPoint(0,0), iWinSize)); + TheClient->Flush(); + + if (aTestMode == 1) //If polygon low priority redraw test. + { + //Clear all redraw stores. + TheClient->iWs.ClearAllRedrawStores(); + TheClient->Flush(); + TheClient->WaitForRedrawsToFinish(); + } + + //Hide the top window, so the bottom window will be redrawn. + topWin->SetVisible(EFalse); + TheClient->Flush(); + TheClient->WaitForRedrawsToFinish(); + + if (aTestMode==0) //If polygon redraw test. + { + //Compare bottomWin against polyTestWin. + TEST(TheClient->iScreen->RectCompare(TRect(TPoint(scrSize.iWidth-2*iWinSize.iWidth-gap,0),iWinSize),TRect(TPoint(scrSize.iWidth-iWinSize.iWidth,0),iWinSize))); + CleanupStack::PopAndDestroy(3,polyTestWin); + } + else //If polygon low priority redraw test. + { + //Test bottomWin has only called DoDraw once. + TEST(bottomWin->ReturnCount()==1); + if (bottomWin->ReturnCount()!=1) + { + _LIT(KLog,"Number of redraws of bottom window %d, 1 expected (windowMode %d)"); + LOG_MESSAGE3(KLog,bottomWin->ReturnCount(),aWindowMode); + } + CleanupStack::PopAndDestroy(2,bottomWin); + } + } + +void CTRedrawStoring::DoRedrawOOMTestL() + { + _LIT(KFailedTestInfo,"Failure information: redrawCount=%d failRate=%d"); + _LIT(KCompletedTest,"OOM test started succeeding at failRate = %d"); + const TInt KConsecutiveSuccessfulRedraws = 20; + + //draw a white test window + CRedrawRectWin* testWin = new (ELeave) CRedrawRectWin(); + CleanupStack::PushL(testWin); + testWin->ConstructL(*TheClient->iGroup); + testWin->Init(); + testWin->AssignGC(*TheClient->iGc); + testWin->BaseWin()->SetShadowDisabled(ETrue); + testWin->BaseWin()->SetShadowHeight(0); + testWin->SetExt(iWinPos+TPoint(0,0), iWinSize); + testWin->Win()->Activate(); + testWin->DrawNow(); + TheClient->Flush(); + TheClient->WaitForRedrawsToFinish(); + + TPoint pointTest = iWinPos + TPoint(30,30); + TRgb colourTest; + TRgb expectedColour = KRgbGreen; + TInt numberOfSuccessfulRedraws = 0; + TInt failRate = 1; + do + { + expectedColour=((expectedColour==KRgbGreen)?KRgbRed:KRgbGreen); + testWin->ResetWindow(expectedColour); + testWin->SetLogging(failRate<3?this:NULL); + testWin->Win()->Invalidate(); + TheClient->iWs.HeapSetFail(RHeap::EDeterministic,failRate); + TheClient->WaitForRedrawsToFinish(); + TheClient->iWs.HeapSetFail(RHeap::ENone,0); + TheClient->iScreen->GetPixel(colourTest,pointTest); + const TInt redrawCount = testWin->RedrawCount(); + + if (redrawCount>2) //If DoDraw called too often: + { + TBool passed=(failRate<3 && redrawCount<9); //For a failrate of 2 allow upto 8 redraws + TEST(passed); //Fail. + LOG_MESSAGE3(KFailedTestInfo,redrawCount,failRate); + if (!passed) + { + CleanupStack::PopAndDestroy(testWin); + return; + } + } + else if (colourTest==expectedColour && redrawCount==1) //If drawn correctly. + { + #if defined(LOGGING) + _LIT(KLog,"FailRate %d Drawing Corect RedrawCount %d"); + LOG_MESSAGE3(KLog,failRate,redrawCount); + #endif + numberOfSuccessfulRedraws++; + } + else //If not drawn. + { + #if defined(LOGGING) + _LIT(KLog,"FailRate %d Drawing Wrong RedrawCount %d"); + LOG_MESSAGE3(KLog,failRate,redrawCount); + #endif + numberOfSuccessfulRedraws=0; + } + failRate++; + } while (numberOfSuccessfulRedrawsiWs); + CleanupClosePushL(win); + User::LeaveIfError(win.Construct(*TheClient->iGroup->GroupWin(),ENullWsHandle)); + win.SetRequiredDisplayMode(EColor64K); + TPoint winPos(270,70); + win.SetExtent(winPos, TSize(100,100)); + win.SetBackgroundColor( KRgbRed ); + win.Activate(); + + TheGc->Activate(win); + win.BeginRedraw(); + TheGc->SetBrushColor(KRgbGreen); + TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + TheGc->DrawRect(TRect(0,0,100,40)); + win.EndRedraw(); + + win.BeginRedraw(TRect(10,20,20,0)); + TheGc->SetBrushColor(KRgbBlue); + TheGc->DrawRect(TRect(0,0,40,100)); + win.EndRedraw(); + + win.SetVisible(EFalse); + win.SetVisible(ETrue); + TheGc->Deactivate(); + TheClient->Flush(); + + TRgb color; + TheClient->iScreen->GetPixel(color,winPos+TPoint(20,20)); + TBool passed=(color==KRgbGreen); + TEST(passed); + + CleanupStack::Pop(&win); + win.Close(); + } + + +/*CPartialRedrawEmptyWin*/ + +void CPartialRedrawEmptyWin::Init(TRgb aColor) + { + Win()->SetRequiredDisplayMode(EColor16MA); + Win()->SetTransparencyAlphaChannel(); + Win()->SetBackgroundColor(aColor); + iCount = 0; + } + +void CPartialRedrawEmptyWin::Draw() + { + DoDraw(); + iCount++; + } + +void CPartialRedrawEmptyWin::DoDraw() + { + DrawFullWindowRect(); + } + +void CPartialRedrawEmptyWin::DrawFullWindowRect() + { + // Only draw when we've looped too many times + if (ReturnCount() > KEmptyLoopThreshold) + { + TRect rect = TRect(TPoint(0,0),iSize); + iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + iGc->SetBrushColor(KRgbBlack); + iGc->DrawRect(rect); + } + } + +void CPartialRedrawEmptyWin::DrawPartial(TRect aRect) + { + Invalidate(aRect); + Win()->BeginRedraw(aRect); + iGc->Activate(*Win()); + DrawFullWindowRect(); + iGc->Deactivate(); + Win()->EndRedraw(); + } + +inline TInt CPartialRedrawEmptyWin::ReturnCount() + { + return iCount; + } + + +/*CPartialRedrawPolygonWin*/ + +void CPartialRedrawPolygonWin::Init(TInt aWindowMode, TRgb aColor) + { + Win()->SetRequiredDisplayMode(EColor16MA); + if (aWindowMode == 1) + { + Win()->SetTransparencyAlphaChannel(); + } + Win()->SetBackgroundColor(aColor); + iCount = 0; + } + +void CPartialRedrawPolygonWin::Draw() + { + DoDraw(); + iCount++; + } + +void CPartialRedrawPolygonWin::DoDraw() + { + DrawFullWindowPolygonL(); + } + +void CPartialRedrawPolygonWin::DrawFullWindowPolygonL() + { + iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + iGc->SetBrushColor(KRgbBlack); + CArrayFixFlat* longPolygon = new CArrayFixFlat(84); + CleanupStack::PushL(longPolygon); + TInt forLoop = 0, loopValue = 0; + TInt tempX=18, tempY=49; + TPoint polygonPoint(tempX, tempY); + + //Create jagged line for the polygon + for (forLoop=0; forLoop<81; forLoop++) + { + tempX += 2; + if (loopValue==0) + { + tempY +=2; + loopValue = 1; + } + else + { + tempY -=2; + loopValue = 0; + } + polygonPoint.SetXY(tempX, tempY); + longPolygon->AppendL(polygonPoint); + } + polygonPoint.SetXY(tempX,70); + longPolygon->AppendL(polygonPoint); + polygonPoint.SetXY(20,70); + longPolygon->AppendL(polygonPoint); + iGc->DrawPolygon(longPolygon); + CleanupStack::PopAndDestroy(longPolygon); + } + +void CPartialRedrawPolygonWin::DrawPartial() + { + Invalidate(); + Win()->BeginRedraw(); + iGc->Activate(*Win()); + DrawFullWindowPolygonL(); + iGc->Deactivate(); + Win()->EndRedraw(); + } + +inline TInt CPartialRedrawPolygonWin::ReturnCount() + { + return iCount; + } + + +/*CRedrawRectWin*/ + +void CRedrawRectWin::Init() + { + Win()->SetRequiredDisplayMode(EColor16MA); + Win()->SetTransparencyAlphaChannel(); + Win()->SetBackgroundColor(KRgbWhite); + iRedrawCount = 0; + iRectColour = KRgbGreen; + } + +void CRedrawRectWin::Draw() + { + DoDraw(); + iRedrawCount++; + } + +void CRedrawRectWin::DoDraw() + { + DrawFullWindowRect(); + } + +void CRedrawRectWin::DrawFullWindowRect() + { + TRect Rect(TPoint(10,10), TSize(30, 30)); + Gc()->SetBrushStyle(CGraphicsContext::ESolidBrush); + Gc()->SetBrushColor(iRectColour); + Gc()->SetPenStyle(CGraphicsContext::ESolidPen); + Gc()->SetPenColor(0); + Gc()->DrawRect(Rect); + } + +void CRedrawRectWin::DrawNow() + { + Win()->Invalidate(); + Win()->BeginRedraw(); + Gc()->Activate(*Win()); + DrawFullWindowRect(); + Gc()->Deactivate(); + Win()->EndRedraw(); + } + +inline TInt CRedrawRectWin::RedrawCount() + { + return iRedrawCount; + } + +void CRedrawRectWin::ResetWindow(TRgb aColour) + { + iRectColour = aColour; + iRedrawCount = 0; + } + +inline void CRedrawRectWin::SetLogging(CTWsGraphicsBase* aTest) + { + iLog=aTest; + } + +void CRedrawRectWin::Redraw(const TRect& aRect) + { + if (iLog) + { + _LIT(KLog,"Redraw Count %d Rect=(%d,%d,%d,%d)"); + iLog->LOG_MESSAGE6(KLog,RedrawCount(),aRect.iTl.iX,aRect.iTl.iY,aRect.iBr.iX,aRect.iBr.iY); + } + CTWin::Redraw(aRect); + } + + +// + +void CTRedrawStoring::RunTestCaseL(TInt /*aCurTestCase*/) + { + _LIT(KNormalDrawing,"Normal Draw Test"); + _LIT(KFadeWindow1,"Fade Window1"); + _LIT(KFadeWindow2,"Fade Window2"); + _LIT(KRedrawQueue2,"Empty Redraw Queue"); + _LIT(KDisableRedrawStore,"Disable redraw store"); + _LIT(KResizeRedraws,"Redraw on Resize event"); + _LIT(KFontCacheOverflow,"Font Cache Overflow test"); + _LIT(KDrawBitmapMask,"Test DrawBitmapMasked"); + _LIT(KInvisibleRedrawStore,"Test invisible window redraw storing"); + _LIT(KBrushDraw,"Test UseBrushPattern storing"); + _LIT(KInvisibleRedrawStoreTransparent,"Test invisible transparent window redraw storing"); + _LIT(KPartialDrawNow,"Test partial DrawNow"); + _LIT(KPartialDrawNowTransparent,"Test partial transparent DrawNow"); + _LIT(KBeginEndRedraw,"Redraw in between Begin and EndRedraw"); + _LIT(KRedrawStoreAlphaChannelTransparency,"Redraw store for Alpha Channel Transparency"); + _LIT(KDrawBitBltAndMaskedNegTestsL,"Test BitBltMasked by passing Neg,UnExpected Values"); + _LIT(KRedrawStoringExposeWindow,"Redraw Storing Window Exposed"); + _LIT(KRedrawStoringExposeWindow2,"Redraw Storing Window behind Transparent Exposed"); + _LIT(KAutoResetRedrawStore,"Test automatic redraw store reset"); + _LIT(KRedrawStoreWithSetExtent,"Redraw store with set extent"); + _LIT(KPartialRedrawWithEmptyRedrawStore,"Partial redraw with empty redraw store"); + _LIT(KScrollingWin,"Test scrolling when partial redraw is enabled"); + _LIT(KRedrawStoringEmptyDrawWindow0,"Empty window under redraw storing - full case"); + _LIT(KRedrawStoringEmptyDrawWindow1,"Empty window under redraw storing - corner case"); + _LIT(KRedrawOOMTest,"Testing OOM redraw"); + _LIT(KRedrawWithBadRect, "Redraw storing when BeginRedraw with bad rect"); + if (iState==0) + { + // Check to see if Transparency is enabled before running tests + if (TransparencySupportedL()==KErrNotSupported) + { + _LIT(KLog,"Transparency is not enabled"); + LOG_MESSAGE(KLog); + TestComplete(); + return; + } + } + TInt err=KErrNone; + //if (iTest->iState==1) iTest->iState=KLastDrawingCase+2; //Set one less that the test you want to run + iState=++iTest->iState; + ((CTRedrawStoringStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); + switch(iTest->iState) + { + case 6: + ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0086")); + // Special case handled seperately because unfading the + // window requires a redraw + iTest->LogSubTest(KFadeWindow1); + FadeWindowTest(); + break; + case 12: + ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0087")); + iTest->LogSubTest(KFadeWindow2); + FadeWindowTest2L(); + break; + case 14: + ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0090")); + iTest->LogSubTest(KRedrawQueue2); + DoNothingInRedrawTest(); + break; + case 17: + ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0091")); + iTest->LogSubTest(KDisableRedrawStore); + DoDisableRedrawStoreTest(); + break; + case 18: + ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0092")); + iTest->LogSubTest(KResizeRedraws); + DoResizeTest(); + break; + case 22: +/** + @SYMTestCaseID GRAPHICS-WSERV-0508 +*/ + ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0508")); + iTest->LogSubTest(KBeginEndRedraw); + DoBeginEndRedraw(); + break; + case 23: +/** + @SYMTestCaseID GRAPHICS-WSERV-0509 +*/ + ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0509")); + iTest->LogSubTest(KRedrawStoreAlphaChannelTransparency); + DoRedrawStoreAlphaChannelTransTest(); + break; + case 24: +/** + @SYMTestCaseID GRAPHICS-WSERV-0510 +*/ + ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0510")); + iTest->LogSubTest(KScrollingWin); + ScrollWinTest(); + break; + case KLastDrawingCase + 1: +/** + @SYMTestCaseID GRAPHICS-WSERV-0511 +*/ + ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0511")); + iTest->LogSubTest(KDrawBitmapMask); + TRAP(err,DoTestDrawBitmapMaskedL()); + break; + case KLastDrawingCase + 2: + + ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0511")); + iTest->LogSubTest(KDrawBitmapMask); + TRAP(err,DoTestDrawBitmapMaskedL(ETrue)); + break; + case KLastDrawingCase + 3: +/** + @SYMTestCaseID GRAPHICS-WSERV-0512 +*/ + ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0512")); + iTest->LogSubTest(KFontCacheOverflow); + DoFontCacheOverflowTestL(); + break; + case KLastDrawingCase + 4: + ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-00XX-0006")); + iTest->LogSubTest(KInvisibleRedrawStore); + TRAP(err,DoInvisibleRedrawStoreTestL( EFalse )); + break; + case KLastDrawingCase + 5: + ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-00XX-0006")); + iTest->LogSubTest(KInvisibleRedrawStoreTransparent); + TRAP(err,DoInvisibleRedrawStoreTestL( ETrue )); + break; + case KLastDrawingCase + 6: + ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-CODEBASE-WSERV-0052-0001")); + iTest->LogSubTest(KDrawBitBltAndMaskedNegTestsL); + TRAP(err,DoBitBltAndMaskedNegTestsL()); + break; + case KLastDrawingCase + 7: +/** + @SYMTestCaseID GRAPHICS-WSERV-0513 +*/ + ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0513")); + iTest->LogSubTest(KPartialDrawNow); + TRAP(err,DoPartialDrawNowTestL(EFalse)); + break; + case KLastDrawingCase + 8: +/** + @SYMTestCaseID GRAPHICS-WSERV-0514 +*/ + ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0514")); + iTest->LogSubTest(KPartialDrawNowTransparent); + TRAP(err,DoPartialDrawNowTestL(ETrue)); + break; + case KLastDrawingCase + 9: +/** + @SYMTestCaseID GRAPHICS-WSERV-0515 +*/ + ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0515")); + TInt iteration; + for(iteration=0;iteration<3 && err==KErrNone;iteration++) + { + iTest->LogSubTest(KRedrawStoringExposeWindow); + TRAP(err,DoExposeTestL(iteration)); + } + break; + case KLastDrawingCase + 10: + { +/** + @SYMTestCaseID GRAPHICS-WSERV-0516 +*/ + ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0516")); + TInt iteration; + for(iteration=0;iteration<2 && err==KErrNone;iteration++) + { + iTest->LogSubTest(KRedrawStoringExposeWindow2); + TRAP(err,DoExposeTest2L(iteration)); + } + break; + } + case KLastDrawingCase + 11: + ((CTRedrawStoringStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + iTest->LogSubTest(KAutoResetRedrawStore); + AutoResetRedrawStoreTestsL(); + break; + case KLastDrawingCase + 12: +/** + @SYMTestCaseID GRAPHICS-WSERV-0517 +*/ + ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0517")); + iTest->LogSubTest(KRedrawStoreWithSetExtent); + RedrawStoreWithSetExtentL(); + break; + case KLastDrawingCase + 13: +/** + @SYMTestCaseID GRAPHICS-WSERV-0518 +*/ + ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0518")); + iTest->LogSubTest(KPartialRedrawWithEmptyRedrawStore); + PartialRedrawWithEmptyRedrawStoreL(); + break; + case KLastDrawingCase + 14: + ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-103713-0001")); + iTest->LogSubTest(KRedrawStoringEmptyDrawWindow0); + TRAP(err,DoEmptyDrawTestL(0)); // Completely covered case + if (err!=KErrNone) + break; + iTest->LogSubTest(KRedrawStoringEmptyDrawWindow1); + TRAP(err,DoEmptyDrawTestL(1)); // Quarter covered case + break; + +/** +@SYMTestCaseID GRAPHICS-WSERV-0439 + +@SYMDEF DEF107817 + +@SYMTestCaseDesc Drawing polygons with many points panics WServ (redraw store enabled) + +@SYMTestPriority Normal + +@SYMTestStatus Implemented + +@SYMTestActions Draw a polygon in opaque and transparent windows testing redraw and low priority redraw + +@SYMTestExpectedResults Redraw tests display correctly, low priority redraw tests call DoDraw only once +*/ + case KLastDrawingCase + 15: + ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L(" GRAPHICS-WSERV-0439")); + TRAP(err,DoPolygonRedrawTestSetL()); + break; + +/** +@SYMTestCaseID GRAPHICS-WSERV-0442 + +@SYMDEF DEF107984 + +@SYMTestCaseDesc OOM causing infinite redraw loop + +@SYMTestPriority Normal + +@SYMTestStatus Implemented + +@SYMTestActions Redraw rectangles in OOM situations + +@SYMTestExpectedResults There are no extended redraw loops +*/ + case KLastDrawingCase + 16: + ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0442")); + iTest->LogSubTest(KRedrawOOMTest); + TRAP(err,DoRedrawOOMTestL()); + break; + case KLastDrawingCase + 17: +/** + @SYMTestCaseID GRAPHICS-WSERV-0519 +*/ + ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0519")); + iTest->LogSubTest(KRedrawWithBadRect); + TRAP(err,RedrawStoreWithBadRectL()); + break; + case KLastDrawingCase + 18: + ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0498")); + iTest->LogSubTest(KBrushDraw); + TRAP(err,DoBrushDrawTestL()); + break; + case KLastDrawingCase + 19: + ((CTRedrawStoringStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + ((CTRedrawStoringStep*)iStep)->CloseTMSGraphicsStep(); + TestComplete(); + break; + default: + iTest->LogSubTest(KNormalDrawing); + ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0085")); + DoDrawTest(); + if (iDoScrollTest) + ScrollTest(); + } + ((CTRedrawStoringStep*)iStep)->RecordTestResultL(); + if (err!=KErrNone) + { + TEST(EFalse); + _LIT(KLog,"Sub-Test[%d] left with error code %d"); + LOG_MESSAGE3(KLog,iState,err); + } + } + + +__WS_CONSTRUCT_STEP__(RedrawStoring) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TREDRSTR.H --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TREDRSTR.H Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,363 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef __TREDRSTR_H__ +#define __TREDRSTR_H__ + +#include +#include +#include "../../tlib/testbase.h" +#include "AUTO.H" +#include "TGraphicsHarness.h" +#include "TScreenModeScaling.h" + + +class CRedrawStoreWin; +class CNoDrawWin; +class CBitmapMaskedWin; +class CResetRedrawStoreWin; + + +class CTRedrawStoring : public CTWsGraphicsBase + { +public: + CTRedrawStoring(CTestStep* aStep); + ~CTRedrawStoring(); + void ConstructL(); + + void CheckWindowsMatch(); + void CheckWindowsMatchLossy(); + void CheckWindowsNotMatch(); + void HideRevealTest(); + void MultipleHideReveal(TInt aX,TInt aY); + void RedrawWindows(); + void DoDrawingL(CWindowGc* aWinGc); + void DoDrawingL(TInt aDraw,CBitmapContext* aGc,TBool aWinGc); + void ScrollTest(); + void FadeWindowTest(); + void FadeWindowTest2L(); + void DoDrawTest(); + void DoScrollTest(); + void SetScrolling(TPoint aScrollSource, TRect aScrollTarget); + //Pure Virtual Function from CTestBase + void DoNothingInRedrawTest(); + void DoDisableRedrawStoreTest(); + void DoBitBltAndMaskedNegTestsL(); + void DoResizeTest(); + void DoTestDrawBitmapMaskedL(TBool aWsBitmap=EFalse); + void DrawBitmapAndCheckL(const TSize aSize,TDisplayMode aDisplayMode,CFbsBitmap* aSrceBitmap,CFbsBitmap* aMaskBitmap,TBool aInvertMask); + void DoFontCacheOverflowTestL(); + void FontCacheOverflowDrawingTestL(TBool aDiffGc, RWindow& aWindow); + void DoInvisibleRedrawStoreTestL( TBool aUseTransparency ); + void DoBrushDrawTestL(); + void DoPartialDrawNowTestL( TBool aUseTransparency ); + void DoBeginEndRedraw(); + void DoRedrawStoreAlphaChannelTransTest(); + + void DoExposeTestL(TInt aIteration); + void DoExposeTest2L(TInt aIteration); + void DoEmptyDrawTestL(TInt aTestMode); + void DoPolygonRedrawTestSetL(); + void DoPolygonRedrawTestL(TInt aWindowMode, TInt aTestMode); + void DoRedrawOOMTestL(); + void RedrawStoreWithBadRectL(); +protected: + virtual void RunTestCaseL(TInt aCurTestCase); + void DoAutoResetRedrawStoreTestL(TBool aTwoWins, TBool aAnimateBothWins, TBool aKeepGcActive, TBool aUpdateInRedraw); + void AutoResetRedrawStoreTestsL(); + void RedrawStoreWithSetExtentL(); + void PartialRedrawWithEmptyRedrawStoreL(); + void DoPartialRedrawWithEmptyRedrawStoreL(TInt aNumWins, TBool aDoWinOnTop, TBool aRedrawWindow, TBool aChildWindows); + CResetRedrawStoreWin* CreatePartialRedrawWinLC(const TPoint& aPos, const TSize& aSize, CTWin* aParent=NULL); + CNoDrawWin* CreateNoDrawWinLC(const TPoint &aPos, const TSize &aSize); + void GetTestWinSizeAndPos(TInt aWinIndex, TPoint &aPos, TSize &aSize) const; + void ScrollWinTest(); +public: + TInt iDrawOrder; + TBool iQueueTest; + +private: + enum TDrawingMode + { + EServerRedraw, + EClientRedrawsNormal, + EClientRedrawsScrolled, + }; + TPoint ComputeTextPosition(TPoint aPoint); + CTBackedUpWin* iCheckWin; + CFbsBitmap* iCheckBitmap; + CFbsBitmapDevice* iCheckDevice; + CFbsBitGc* iCheckGc; + CRedrawStoreWin* iTestWin; + TSize iWinSize; + TPoint iWinPos; + TDrawingMode iDrawMode; + RBlankWindow iBlankWin; + RRegion iRegion; + RWindow iWinTestGc; + TBool iWindowsFaded; + TRect iScrollTarget; + TPoint iScrollSource; + TBool iDoScrollTest; + CNoDrawWin* iNoDrawWin; + TBool iClientDidDraw; + CWsBitmap* iAlphaBitmap[3]; + TBool iAlphaSupported; + CBitmapMaskedWin* iBitmapMaskedWin; + CBitmap* iTestBitmap; + CBitMapWin* iTestBitmapWin; + TRect iWinRect; + TPoint iTestWinPoint; + TBool iXPlus; + TBool iYPlus; + TInt iState; + TInt iYPoz; + TDisplayMode iTestDisplayMode; + CFbsBitmap *iTestWinCopy; + CFbsBitmap *iCheckWinCopy; + }; + +class CRedrawStoreWin : public CTWin + { +public: + inline CRedrawStoreWin(CTRedrawStoring* aTest) : iDrawOrder(0), iTest(aTest){} + //Virtual Function from CTBaseWin + void Draw(); +public: + TInt iDrawOrder; +private: + CTRedrawStoring *iTest; + }; + +class CNoDrawWin : public CTWin + { +public: + void Draw(); + }; + +class CBrushDrawWin : public CTWin + { +public: + CBrushDrawWin(); + void Draw(); + void Redraw(); + +private: + }; + +class CBitmapMaskedWin : public CTWin + { +public: + static CBitmapMaskedWin* NewL(CFbsBitmap* aFbsBitmap,CFbsBitmap* aFbsMaskBitmap, + CWsBitmap* aWsBitmap,CWsBitmap* aWsMaskBitmap, + TRgb aBackground,TRect aRect,TBool aInvertMask,TBool aWsFbs); + ~CBitmapMaskedWin(); + //Virtual Function from CTBaseWin + void Draw(); + void SetDestRectSize(const TSize aSize); + inline void SetInvertMask(TBool aInvertMask){iInvertMask=aInvertMask;} +private: + inline CBitmapMaskedWin(CFbsBitmap* aFbsBitmap,CFbsBitmap* aFbsMaskBitmap,CWsBitmap* aWsBitmap,CWsBitmap* aWsMaskBitmap, + TRect aRect,TBool aInvertMask,TBool aWsFbs): + iFbsBitmap(aFbsBitmap),iFbsMaskBitmap(aFbsMaskBitmap), + iWsBitmap(aWsBitmap),iWsMaskBitmap(aWsMaskBitmap), + iRect(aRect),iInvertMask(aInvertMask),iWsFbs(aWsFbs) {} +private: + CFbsBitmap* iFbsBitmap; + CFbsBitmap* iFbsMaskBitmap; + CWsBitmap* iWsBitmap; + CWsBitmap* iWsMaskBitmap; + TRect iRect; + TBool iInvertMask; + TBool iWsFbs; + }; + +class CPartialRedrawWin : public CTWin + { +public: + void Init(); + virtual void Draw(); + void DrawToBmp(CGraphicsContext& aGc); + void DrawPartial(TPartialRedrawType aPartialRedrawType); + static void DrawRects(CGraphicsContext& aGc, TSize aSize, TPoint aPosition, + TBool aIsFullRedraw, TPartialRedrawType aPartialRedrawType); + void RedrawSubRectWithBitmapL(TRgb aBitmapColour); +public: + TBool iClientDrawn; + TBool iClientCanDraw; +private: + void DoDraw(CGraphicsContext& aGc); +private: + }; + +class CPartialRedrawBottomWin : public CTWin + { +public: + void Init(); + virtual void Draw(); + void DrawPartial(TRect aRect); + void DrawFullWindowRect(); +private: + void DoDraw(); + }; + +class CPartialRedrawTopWin : public CTWin + { +public: + void Init(); + virtual void Draw(); + void DrawPartial(TRect aRect); + void DrawFullWindowRect(); +private: + void DoDraw(); + }; + +class CPartialRedrawTiledWin : public CTWin + { +public: + void Init(TRgb aColour,TBool aTransparent); + virtual void Draw(); + void DrawPartial(TRect aRect); + void DrawFullWindowRect(); +private: + void DoDraw(); +private: + TRgb iColour; + }; + +class CInvisibleRedrawWin: public CTWin + { +public: + CInvisibleRedrawWin(); + TInt MakeTransparent(); + void MakeVisible( TBool aVisible ); + virtual void Redraw(); + virtual void Redraw( const TRect &aRect ); + +private: + void DrawIfVisible(); + +private: + TBool iVisible; + TBool iTransparent; + }; + +class CPartialDrawNowWin: public CTWin + { +public: + CPartialDrawNowWin(); + TInt MakeTransparent(); + void SetLodger( const TRect &aLodger ); + virtual void Redraw(); + virtual void Redraw( const TRect &aRect ); + +private: + void DrawWindowAndLodger(); + +private: + TRect iLodger; + TBool iTransparent; + }; + +class CPartialRedrawEmptyWin : public CTWin + { +public: + void Init(TRgb aColor); + virtual void Draw(); + void DrawPartial(TRect aRect); + void DrawFullWindowRect(); + inline TInt ReturnCount(); +private: + void DoDraw(); + TInt iCount; + }; + +class CPartialRedrawPolygonWin : public CTWin + { +public: + void Init(TInt aWindowMode, TRgb aColor); + virtual void Draw(); + void DrawPartial(); + void DrawFullWindowPolygonL(); + inline TInt ReturnCount(); +private: + void DoDraw(); + TInt iCount; + }; + +class CRedrawRectWin : public CTWin + { +public: + void Init(); + void DrawNow(); + void DrawFullWindowRect(); + inline TInt RedrawCount(); + void ResetWindow(TRgb aColour); + inline void SetLogging(CTWsGraphicsBase* aTest); + //Virtual function from CTBaseWin + void Draw(); + //Virtual function from CTWin + void Redraw(const TRect& aRect); +private: + void DoDraw(); +private: + TInt iRedrawCount; + TRgb iRectColour; + CTWsGraphicsBase* iLog; + }; + +class CTRedrawStoringStep : public CTGraphicsStep + { +public: + CTRedrawStoringStep(); +protected: + //from CTGraphicsStep + virtual CTGraphicsBase* CreateTestL(); + }; + +class CResetRedrawStoreWin : public CPartialRedrawWin + { +public: + ~CResetRedrawStoreWin(); + void SetUpdateInRedraw(TBool aUpdateInRedraw); + void SetKeepGcActive(TBool aState); + void UpdateAnim(TInt aSteps); + void PreSetSize(const TSize &aSize); + TBool Failed() const; +private: + virtual void Draw(); + void DoDraw(CGraphicsContext& aGc) const; + void DoDrawAnim(CGraphicsContext& aGc) const; + TRect AnimRect() const; +private: + TInt iAnimState; + TBool iKeepGcActive; + TBool iUpdateInRedraw; + TBool iFailed; + CWindowGc* iExtraGc; + }; + +const TInt KEmptyLoopThreshold = 3; + +_LIT(KTRedrawStoringStep,"TRedrawStoring"); + + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TRegion.H --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TRegion.H Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,90 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef __TREGION_H__ +#define __TREGION_H__ + +#include +#include +#include "../tlib/testbase.h" +#include "AUTO.H" +#include +#include "TGraphicsHarness.h" + +class CTRegion : public CTWsGraphicsBase + { +public: + CTRegion(CTestStep* aStep); + ~CTRegion(); + void ConstructL(); + +protected: + virtual void RunTestCaseL(TInt aCurTestCase); + +private: + void DrawNonClippedSample1(CTWin *aDrawable, const TPoint &aOrigin); + void DrawNonClippedSample1(CTWin *aDrawable, const TRegion &aRegion, const TPoint &aOrigin); + void DrawClippedSample1(TestWindow *aDrawable, const TRegion &aRegion, const TRect &aClippingRect, const TPoint &aOrigin); + void DrawNonClippedSample2(CTWin *aDrawable, const TPoint &aOrigin); + void DrawNonClippedSample2(CTWin *aDrawable, const TRegion &aRegion, const TPoint &aOrigin); + void DrawClippedSample2(TestWindow *aDrawable, const TRegion &aRegion, const TRect &aClippingRect, const TPoint &aOrigin); + void DrawClippedSample3(CBitmapContext &aGc); + void DrawNonClippedSample1(CBitmapContext &aGc); + void DrawClippedSample1(CBitmapContext &aGc); + void DrawNonClippedSample2(CBitmapContext &aGc, CFont *aFont); + void DrawClippedSample2(CBitmapContext &aGc, CFont *aFont); + void TestRegionL(const TRegion &aClippingRegion, const TRect &aClippingRect, const TPoint &aOrigin); + void ScrollBugL(); + void ExposeTestL(); + void ExposeTest2L(); + void CoverTestL(); + void OffsetTestL(); + void ClipTestL(); + void CreateChildWindowsL(); + void DeleteChildWindows(); + void ClearBitmapAndWindows(); + void CompareRectsL(TPoint aTl1,TPoint aTl2,TSize aSize); + +private: + CFbsFont *iFont; + CFbsFont *iBitFont; + CFbsBitmap iPicture; + CFbsBitmapDevice *iBitmapDevice; + CWsBitmap *iBitmap; + CFbsBitGc *iBitGc; + TSize iDrawableSize; + CBlankWindow *iBaseChildWin; + CBlankWindow *iTestChildWin; + }; + +class CTRegionStep : public CTGraphicsStep + { +public: + CTRegionStep(); +protected: + //from CTGraphicsStep + virtual CTGraphicsBase* CreateTestL(); + }; + +_LIT(KTRegionStep,"TRegion"); + + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TRegion.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TRegion.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,854 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Code for testing CWindowGc::SetCurrentRegion +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include "TRegion.H" + +TBool RegionCanFade; +TBool RegionCanFadeSet; + +LOCAL_D TBuf<0x10> text=_L("SOME TEXT"); +LOCAL_D TPoint textRefPos(210, 80); + +LOCAL_D TRect regionRectList[]={ + TRect(0,0,0,0), TRect(30,10,70,40),TRect(60,30,80,70),TRect(10,110,70,170), + TRect(190,0,240,60),TRect(62,63,67,115),TRect(0,180,240,200),TRect(40,50,210,130), + TRect(160,130,190,160),TRect(100,140,140,170),TRect(140,170,100,140),TRect(90,120,230,200)}; +LOCAL_D TRect clippingRectList[]={ + TRect(0,0,200,400), TRect(30,10,500,600),TRect(-60,0,80,70),TRect(20,0,170,500), + TRect(0,0,2000,6000),TRect(-1000,-2000,123,195),TRect(10,10,230,190),TRect(0,0,510,730), + TRect(110,30,190,150),TRect(1,1,500,11170),TRect(0,0,800,940),TRect(-10,-20,240,210)}; +LOCAL_D TPoint originList[]={ + TPoint(0,0),TPoint(10,0),TPoint(0,10),TPoint(-5,-20), + TPoint(1,1),TPoint(0,0),TPoint(0,0),TPoint(100,0), + TPoint(0,111),TPoint(90,40),TPoint(0,0),TPoint(-1,0)}; + +CTRegion::CTRegion(CTestStep* aStep) : CTWsGraphicsBase(aStep) + { + } + +void CTRegion::ConstructL() + { + iDrawableSize=TestWin->Size(); +// + User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)iFont,TFontSpec(_L("Arial"),200))); + User::LeaveIfError(iPicture.Load(TEST_BITMAP_NAME,0)); + + iBitmap = new (ELeave) CWsBitmap(TheClient->iWs); + User::LeaveIfError(iBitmap->Create(TSize(iDrawableSize.iWidth+1,iDrawableSize.iHeight),EGray16)); + iBitmap->SetSizeInTwips(TheClient->iScreen); + iBitmapDevice=CFbsBitmapDevice::NewL(iBitmap); + User::LeaveIfError(iBitmapDevice->CreateContext(iBitGc)); + User::LeaveIfError(iBitmapDevice->GetNearestFontToDesignHeightInTwips((CFont *&)iBitFont,TFontSpec(_L("Arial"),200))); + } + +CTRegion::~CTRegion() + { + delete iBitGc; + TheClient->iScreen->ReleaseFont(iFont); + if (iBitmapDevice) + iBitmapDevice->ReleaseFont(iBitFont); + delete iBitmapDevice; + DeleteChildWindows(); + delete iBitmap; + } + +void CTRegion::CreateChildWindowsL() + { + TSize screenSize=TheClient->iGroup->Size(); + TInt winWidth=(screenSize.iWidth/3)-10; + TInt winHeight=screenSize.iHeight-10; + iBaseChildWin=new(ELeave) CBlankWindow(); + iBaseChildWin->SetUpL(BaseWin->Win()->InquireOffset(*TheClient->iGroup->GroupWin())+TPoint(winWidth>>2,winHeight>>2),TSize(winWidth>>2,winHeight>>1),TheClient->iGroup,*TheClient->iGc); + iBaseChildWin->Win()->SetShadowHeight(2); + iTestChildWin=new(ELeave) CBlankWindow(); + iTestChildWin->SetUpL(TestWin->Win()->InquireOffset(*TheClient->iGroup->GroupWin())+TPoint(winWidth>>2,winHeight>>2),TSize(winWidth>>2,winHeight>>1),TheClient->iGroup,*TheClient->iGc); + } + +void CTRegion::DeleteChildWindows() + { + delete iBaseChildWin; + iBaseChildWin=NULL; + delete iTestChildWin; + iTestChildWin=NULL; + } + +void CTRegion::DrawNonClippedSample1(CBitmapContext &aGc) + { + aGc.SetPenColor(TRgb::Gray4(0)); + aGc.SetBrushColor(TRgb::Gray4(2)); + aGc.SetBrushStyle(CGraphicsContext::ESolidBrush); + aGc.DrawRect(TRect(TPoint(30,100), TPoint(120,200))); + TheClient->iWs.Flush(); + } + +void CTRegion::DrawClippedSample1(CBitmapContext &aGc) + { + aGc.SetPenColor(TRgb::Gray4(0)); + aGc.SetBrushColor(TRgb::Gray4(1)); + aGc.SetBrushStyle(CGraphicsContext::ESolidBrush); + aGc.DrawRect(TRect(TSize(100,200))); + +// aGc.BitBlt(TPoint(55,65), iPicture); + + aGc.SetPenStyle(CGraphicsContext::ENullPen); + aGc.SetBrushStyle(CGraphicsContext::ESolidBrush); + aGc.SetBrushColor(TRgb::Gray4(2)); + aGc.DrawEllipse(TRect(TPoint(20,35), TPoint(90,79))); + + aGc.SetBrushColor(TRgb::Gray4(0)); + aGc.DrawEllipse(TRect(TPoint(110,110), TPoint(175,200))); + + aGc.SetBrushColor(TRgb::Gray4(1)); + aGc.DrawEllipse(TRect(TPoint(170,30), TPoint(220,150))); + + aGc.SetBrushColor(TRgb::Gray4(3)); + aGc.DrawEllipse(TRect(TPoint(0,150), TPoint(240,190))); + + aGc.SetPenStyle(CGraphicsContext::ESolidPen); + aGc.SetBrushStyle(CGraphicsContext::ENullBrush); + + TheClient->iWs.Flush(); + } + +void CTRegion::DrawNonClippedSample2(CBitmapContext &aGc, CFont *aFont) + { + aGc.SetPenColor(TRgb::Gray4(0)); + aGc.SetPenColor(TRgb::Gray4(0)); + aGc.UseFont(aFont); + TPoint textPos=textRefPos-TPoint(iFont->TextWidthInPixels(text)*3/4, 0); + aGc.DrawText(text, textPos); + aGc.DiscardFont(); + + TheClient->iWs.Flush(); + } + +void CTRegion::DrawClippedSample2(CBitmapContext &aGc, CFont *aFont) + { + aGc.SetPenColor(TRgb::Gray4(0)); + aGc.SetPenColor(TRgb::Gray4(2)); + aGc.UseFont(aFont); + TPoint textPos=textRefPos-TPoint(iFont->TextWidthInPixels(text)*3/4, -20); + aGc.DrawText(text, textPos); + aGc.DiscardFont(); + aGc.SetBrushColor(TRgb::Gray4(3)); + aGc.SetBrushStyle(CGraphicsContext::ESolidBrush); + aGc.DrawRect(TRect(TPoint(10,100), TPoint(210,120))); + TheClient->iWs.Flush(); + } + +void CTRegion::DrawClippedSample3(CBitmapContext &aGc) + { + aGc.SetPenColor(TRgb::Gray4(0)); + aGc.SetPenColor(TRgb::Gray4(2)); + aGc.DrawRect(TRect(TPoint(10,200), TPoint(20,210))); + } + +void CTRegion::DrawNonClippedSample1(CTWin *aWindow, const TPoint &aOrigin) + { + TheGc->Activate(*aWindow->Win()); + TheGc->SetOrigin(aOrigin); + DrawNonClippedSample1(*TheGc); + TheGc->Deactivate(); + } + +void CTRegion::DrawNonClippedSample1(CTWin *aWindow, const TRegion &aRegion, const TPoint &aOrigin) + { + TheGc->Activate(*aWindow->Win()); + TheGc->SetOrigin(aOrigin); + TheGc->SetClippingRegion(aRegion); + DrawNonClippedSample1(*TheGc); + TheGc->Deactivate(); + } + +void CTRegion::DrawClippedSample1(TestWindow *aWindow, const TRegion &aRegion, const TRect &aClippingRect, const TPoint &aOrigin) + { + TheGc->Activate(*aWindow->Win()); + TheGc->SetOrigin(aOrigin); + TheGc->SetClippingRegion(aRegion); + TheGc->SetClippingRect(aClippingRect); + DrawClippedSample1(*TheGc); + TheGc->Deactivate(); + } + +void CTRegion::DrawNonClippedSample2(CTWin *aWindow, const TPoint &aOrigin) + { + TheGc->Activate(*aWindow->Win()); + TheGc->SetOrigin(aOrigin); + DrawNonClippedSample2(*TheGc,iFont); + TheGc->Deactivate(); + } + +void CTRegion::DrawNonClippedSample2(CTWin *aWindow, const TRegion &aRegion, const TPoint &aOrigin) + { + TheGc->Activate(*aWindow->Win()); + TheGc->SetOrigin(aOrigin); + TheGc->SetClippingRegion(aRegion); + DrawNonClippedSample2(*TheGc,iFont); + TheGc->Deactivate(); + } + +void CTRegion::DrawClippedSample2(TestWindow *aWindow, const TRegion &aRegion, const TRect &aClippingRect, const TPoint &aOrigin) + { + TheGc->Activate(*aWindow->Win()); + TheGc->SetClippingRegion(TRegionFix<1>()); + DrawClippedSample3(*TheGc); // needed to trigger region update in wserv + TheGc->SetOrigin(aOrigin); + TheGc->SetClippingRect(aClippingRect); + TheGc->SetClippingRegion(aRegion); + DrawClippedSample2(*TheGc,iFont); + TheGc->CancelClippingRegion(); + TheGc->Deactivate(); + } + +void CTRegion::ClearBitmapAndWindows() + { + TestWin->Win()->Invalidate(); + TestWin->Win()->BeginRedraw(); + TheGc->Activate(*TestWin->Win()); + TheGc->SetBrushColor(TRgb::Gray4(3)); + TheGc->Clear(); + TheGc->Deactivate(); + TestWin->Win()->EndRedraw(); +// + BaseWin->Win()->Invalidate(); + BaseWin->Win()->BeginRedraw(); + TheGc->Activate(*BaseWin->Win()); + TheGc->SetBrushColor(TRgb::Gray4(3)); + TheGc->Clear(); + TheGc->Deactivate(); + BaseWin->Win()->EndRedraw(); +// + iBitGc->SetBrushColor(TRgb::Gray4(3)); + iBitGc->Clear(); + TheClient->iWs.Flush(); + } + +void CTRegion::TestRegionL(const TRegion &aClippingRegion, const TRect &aClippingRect, const TPoint &aOrigin) + { + if (aClippingRegion.CheckError()) + User::Leave(KErrGeneral); + ClearBitmapAndWindows(); + + // draw to iWindow1 (clipping intermittently) and iBitmap (not clipping) + DrawNonClippedSample1(TestWin,aOrigin); + DrawNonClippedSample1(*iBitGc); + + DrawNonClippedSample2(TestWin,aOrigin); + DrawNonClippedSample2(*iBitGc, iBitFont); + + DrawClippedSample1(TestWin,aClippingRegion,aClippingRect,aOrigin); + DrawClippedSample1(*iBitGc); + + DrawClippedSample2(TestWin,aClippingRegion,aClippingRect,aOrigin); + DrawClippedSample2(*iBitGc, iBitFont); + + // copy each rectangle of the clipping region from iBitmap to iWindow2 + TheGc->Activate(*BaseWin->Win()); + for (TUint i=0; i<(TUint)aClippingRegion.Count(); i++) + { + TRect rect=aClippingRegion.RectangleList()[i]; + rect.Intersection(aClippingRect); + TheGc->SetOrigin(aOrigin); + TheGc->BitBlt(rect.iTl, iBitmap, rect); + TheClient->Flush(); + } + TheGc->Deactivate(); + + // draw the non-clipped samples to everywhere in iWindow2 *except* the clipping region + RRegion inverseClippingRegion(TRect(-aOrigin,iDrawableSize)); + RRegion clip; + clip.Copy(aClippingRegion); + clip.ClipRect(aClippingRect); + inverseClippingRegion.SubRegion(clip); + clip.Close(); + DrawNonClippedSample1(BaseWin,inverseClippingRegion,aOrigin); + DrawNonClippedSample2(BaseWin,inverseClippingRegion,aOrigin); + inverseClippingRegion.Close(); + CompareWindows(_L("CTRegion::TestRegionL")); + } + +void CTRegion::CompareRectsL(TPoint aTl1,TPoint aTl2,TSize aSize) + { + _LIT(KError,"Pixels Differ: (%d,%d),(%d,%d)"); + CFbsScreenDevice* device; + device=CFbsScreenDevice::NewL(KNullDesC,iBaseChildWin->BaseWin()->DisplayMode()); + TPoint br=aTl1+aSize; + TInt startX1=aTl1.iX; + TInt startX2=aTl2.iX; + TSize pixelSize(1,1); + TPoint zero; + while(aTl1.iYRectCompare(TRect(aTl1,pixelSize),*device,TRect(aTl2,pixelSize))) + { + RDebug::Print(KError,aTl1.iX,aTl1.iY,aTl2.iX,aTl2.iY); + iTest->LogColors(*device,zero,aTl1,aTl1); + iTest->LogColors(*device,zero,aTl2,aTl2); + } + ++aTl1.iX; + ++aTl2.iX; + } + aTl1.iX=startX1; + aTl2.iX=startX2; + ++aTl1.iY; + ++aTl2.iY; + } + } + +void CTRegion::ScrollBugL() + { + CBlankWindow* testWin; + RBlankWindow win(TheClient->iWs); + CleanupClosePushL(win); + TSize screenSize=TheClient->iGroup->Size(); + testWin=new(ELeave) CBlankWindow(TRgb::Gray4(0)); + CleanupStack::PushL(testWin); + //testWin->ConstructL(*TheClient->iGroup); + testWin->SetUpL(TPoint(screenSize.iWidth/3,0),TSize(screenSize.iWidth/3,screenSize.iHeight),TheClient->iGroup,*TheGc); + //testWin->Win()->SetBackgroundColor(TRgb::Gray2(1)); + testWin->Win()->EnableRedrawStore(EFalse); + testWin->SetColor(TRgb::Gray4(1)); + testWin->RealDraw(ETrue); + win.Construct(*TheClient->iGroup->WinTreeNode(),3456); + win.SetColor(TRgb::Gray4(2)); + win.SetExtent(TPoint(screenSize.iWidth/3+30,20),TSize(screenSize.iWidth/3-62,25)); + win.Activate(); + TheClient->iWs.Flush(); + TheClient->WaitForRedrawsToFinish(); + win.SetVisible(EFalse); + TheClient->iWs.Flush(); + testWin->Win()->BeginRedraw(); + testWin->DrawNow(); + testWin->SetColor(TRgb::Gray4(2)); + testWin->Win()->Scroll(TPoint(0,-50)); + testWin->DrawNow(); + testWin->Win()->EndRedraw(); + TheClient->iWs.Flush(); + TBool retVal = TheClient->iScreen->RectCompare(TRect(TPoint(screenSize.iWidth/3,0),TSize(screenSize.iWidth/3,screenSize.iHeight/2-30)) + ,TRect(TPoint(screenSize.iWidth/3,screenSize.iHeight/2-30),TSize(screenSize.iWidth/3,screenSize.iHeight/2-30))); + TEST(retVal); + if (!retVal) + INFO_PRINTF3(_L("TheClient->iScreen->RectCompare() return value - Expected: %d, Actual: %d"), ETrue, retVal); + + retVal = !TheClient->iScreen->RectCompare(TRect(TPoint(screenSize.iWidth/3,screenSize.iHeight-60),TSize(10,10)) + ,TRect(TPoint(screenSize.iWidth/3,screenSize.iHeight-50),TSize(10,10))); + TEST(retVal); + if (!retVal) + INFO_PRINTF3(_L("!TheClient->iScreen->RectCompare() return value - Expected: %d, Actual: %d"), ETrue, retVal); + + TheClient->WaitForRedrawsToFinish(); + win.SetVisible(ETrue); + win.SetVisible(EFalse); + testWin->Win()->BeginRedraw(); + testWin->Win()->Scroll(TPoint(0,-50)); + testWin->SetColor(TRgb::Gray4(1)); + testWin->DrawNow(); + testWin->Win()->EndRedraw(); + TheClient->iWs.Flush(); + retVal = TheClient->iScreen->RectCompare(TRect(TPoint(screenSize.iWidth/3+35,0),TSize(screenSize.iWidth/6-35,100)) + ,TRect(TPoint(screenSize.iWidth/2,0),TSize(screenSize.iWidth/6-35,100))); + TEST(retVal); + if (!retVal) + INFO_PRINTF3(_L("TheClient->iScreen->RectCompare() return value - Expected: %d, Actual: %d"), ETrue, retVal); + + retVal = !TheClient->iScreen->RectCompare(TRect(TPoint(screenSize.iWidth/3+30,20),TSize(10,10)) + ,TRect(TPoint(screenSize.iWidth/3+30,50),TSize(10,10))); + TEST(retVal); + if (!retVal) + INFO_PRINTF3(_L("!TheClient->iScreen->RectCompare() return value - Expected: %d, Actual: %d"), ETrue, retVal); + + TheClient->WaitForRedrawsToFinish(); + testWin->Win()->BeginRedraw(); + testWin->DrawNow(); + testWin->Win()->EndRedraw(); + CleanupStack::PopAndDestroy(2,&win); + } + +void CTRegion::ExposeTestL() + { + CBlankWindow* testWin; + TSize screenSize=TheClient->iGroup->Size(); + TRect topHalf(0,0,screenSize.iWidth/3,screenSize.iHeight/2); + TRect leftHalf(0,0,screenSize.iWidth/6,screenSize.iHeight); + testWin=new(ELeave) CBlankWindow(TRgb::Gray4(0)); + CleanupStack::PushL(testWin); + testWin->SetUpL(TPoint(screenSize.iWidth/3,0),TSize(screenSize.iWidth/3,screenSize.iHeight),TheClient->iGroup,*TheGc); + testWin->Win()->EnableRedrawStore(EFalse); + testWin->SetColor(TRgb::Gray4(2)); + testWin->RealDraw(ETrue); + TheClient->iWs.Flush(); + TheClient->WaitForRedrawsToFinish(); + testWin->Win()->BeginRedraw(); + testWin->DrawNow(); + testWin->Win()->Invalidate(topHalf); + testWin->SetColor(TRgb::Gray4(1)); + testWin->DrawNow(); + testWin->Win()->EndRedraw(); + TheClient->iWs.Flush(); + CheckRectNoMatch(TPoint(screenSize.iWidth/3,0),TPoint(screenSize.iWidth/3,screenSize.iHeight/2),TSize(10,10),_L("CTRegion::ExposeTestL() A")); + + TheClient->WaitForRedrawsToFinish(); + CheckRect(TPoint(screenSize.iWidth/3,0),TPoint(screenSize.iWidth/3,screenSize.iHeight/2),TSize(screenSize.iWidth/3,screenSize.iHeight/2),_L("CTRegion::ExposeTestL() B")); + + testWin->Win()->Invalidate(topHalf); + testWin->SetColor(TRgb::Gray4(2)); + testWin->Win()->BeginRedraw(); + testWin->Win()->Invalidate(leftHalf); + testWin->DrawNow(); + testWin->Win()->EndRedraw(); + TheClient->iWs.Flush(); + CheckRect(TPoint(screenSize.iWidth/3,0),TPoint(screenSize.iWidth/3,screenSize.iHeight/2),TSize(screenSize.iWidth/6-10,screenSize.iHeight/2),_L("CTRegion::ExposeTestL() C")); + CheckRectNoMatch(TPoint(screenSize.iWidth/2,0),TPoint(screenSize.iWidth/2,screenSize.iHeight/2),TSize(10,10),_L("CTRegion::ExposeTestL() D")); + CheckRectNoMatch(TPoint(screenSize.iWidth/3,0),TPoint(screenSize.iWidth/2,0),TSize(10,10),_L("CTRegion::ExposeTestL() E")); + CheckRect(TPoint(screenSize.iWidth/3,screenSize.iHeight/2),TPoint(screenSize.iWidth/2,screenSize.iHeight/2),TSize(((screenSize.iWidth/6-5)/4*4),screenSize.iHeight/2),_L("CTRegion::ExposeTestL() F")); + testWin->Win()->BeginRedraw(); + testWin->DrawNow(); + testWin->Win()->EndRedraw(); + TheClient->iWs.Flush(); + + CheckRect(TPoint(screenSize.iWidth/3,0),TPoint(screenSize.iWidth/3,screenSize.iHeight/2),TSize(screenSize.iWidth/6-10,screenSize.iHeight/2),_L("CTRegion::ExposeTestL() G")); + CheckRectNoMatch(TPoint(screenSize.iWidth/2,0),TPoint(screenSize.iWidth/2,screenSize.iHeight/2),TSize(10,10),_L("CTRegion::ExposeTestL() H")); + CheckRect(TPoint(screenSize.iWidth/3,0),TPoint(screenSize.iWidth/2,0),TSize(((screenSize.iWidth/6-5)/4*4),screenSize.iHeight/2),_L("CTRegion::ExposeTestL() I")); + CheckRectNoMatch(TPoint(screenSize.iWidth/3,screenSize.iHeight/2),TPoint(screenSize.iWidth/2,screenSize.iHeight/2),TSize(10,10),_L("CTRegion::ExposeTestL() J")); + + CleanupStack::PopAndDestroy(testWin); + } + +#if defined(__MARM_ARM4__) + #define FADING ETrue +#elif defined(__MARM__) + #define FADING EFalse +#else + #define FADING ETrue +#endif +void CTRegion::ExposeTest2L() + { + TBool canFade=FADING; +#if defined(__MARM_THUMB__) + if (!RegionCanFadeSet) + return; + canFade=RegionCanFade; +#endif + INFO_PRINTF1(_L("AUTO REGN ExpostTest2 ")); + CBlankWindow* testWin; + RBlankWindow win(TheClient->iWs); + CleanupClosePushL(win); + TSize screenSize=TheClient->iGroup->Size(); + TRect topHalf(0,0,screenSize.iWidth/3,screenSize.iHeight/2); + testWin=new(ELeave) CBlankWindow(TRgb::Gray4(0)); + CleanupStack::PushL(testWin); + testWin->SetUpL(TPoint(screenSize.iWidth/3,0),TSize(screenSize.iWidth/3,screenSize.iHeight),TheClient->iGroup,*TheGc); + testWin->Win()->EnableRedrawStore(EFalse); + testWin->Win()->SetRequiredDisplayMode(EGray16); + testWin->SetColor(TRgb::Gray16(12)); + testWin->RealDraw(ETrue); + win.Construct(*TheClient->iGroup->WinTreeNode(),3456); + win.SetColor(TRgb::Gray4(2)); + win.SetExtent(TPoint(0,-screenSize.iHeight),TSize(screenSize.iWidth/3-2,2*screenSize.iHeight)); + win.SetShadowHeight(screenSize.iWidth/9); + win.Activate(); + TheClient->iWs.Flush(); + TheClient->WaitForRedrawsToFinish(); + INFO_PRINTF1(_L(" Constructed Windows")); + testWin->DrawNow(); + testWin->Win()->SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly); + testWin->DrawNow(topHalf); + TheClient->iWs.Flush(); + INFO_PRINTF1(_L(" Drawn TopHalf Faded")); + TBool retVal = TheClient->iScreen->RectCompare(TRect(TPoint(screenSize.iWidth/3,0),TSize(screenSize.iWidth/3,screenSize.iHeight/2)) + ,TRect(TPoint(screenSize.iWidth/3,screenSize.iHeight/2),TSize(screenSize.iWidth/3,screenSize.iHeight/2))); + TEST(retVal); + if (!retVal) + INFO_PRINTF3(_L("TheClient->iScreen->RectCompare() return value - Expected: %d, Actual: %d"), ETrue, retVal); + + testWin->DrawNow(topHalf); + TheClient->iWs.Flush(); + canFade!=TheClient->iScreen->RectCompare(TRect(TPoint(screenSize.iWidth/3,0),TSize(10,10)) + ,TRect(TPoint(screenSize.iWidth/3,screenSize.iHeight/2),TSize(10,10))); + TEST(canFade); + if (!canFade) + INFO_PRINTF3(_L("TheClient->iScreen->RectCompare() return value - Expected: %d, Actual: %d"), ETrue, canFade); + + testWin->DrawNow(); + TheClient->iWs.Flush(); + INFO_PRINTF1(_L(" All Faded (Flush)")); + + retVal = TheClient->iScreen->RectCompare(TRect(TPoint(screenSize.iWidth/3,0),TSize(screenSize.iWidth/3,screenSize.iHeight/2)) + ,TRect(TPoint(screenSize.iWidth/3,screenSize.iHeight/2),TSize(screenSize.iWidth/3,screenSize.iHeight/2))); + TEST(retVal); + if (!retVal) + INFO_PRINTF3(_L("TheClient->iScreen->RectCompare() return value - Expected: %d, Actual: %d"), ETrue, retVal); + + testWin->Win()->SetFaded(EFalse,RWindowTreeNode::EFadeWindowOnly); + TheClient->iWs.Flush(); + TheClient->WaitForRedrawsToFinish(); + INFO_PRINTF1(_L(" Redrawn Screen Unfaded")); + testWin->Win()->Invalidate(topHalf); + testWin->Win()->SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly); + testWin->DrawNow(); + TheClient->iWs.Flush(); + INFO_PRINTF1(_L(" Re Drawn Top Half Faded Again")); + retVal = TheClient->iScreen->RectCompare(TRect(TPoint(screenSize.iWidth/3,0),TSize(screenSize.iWidth/3,screenSize.iHeight/2)) + ,TRect(TPoint(screenSize.iWidth/3,screenSize.iHeight/2),TSize(screenSize.iWidth/3,screenSize.iHeight/2))); + TEST(retVal); + if (!retVal) + INFO_PRINTF3(_L("TheClient->iScreen->RectCompare() return value - Expected: %d, Actual: %d"), ETrue, retVal); + + testWin->DrawNow(); + TheClient->iWs.Flush(); + INFO_PRINTF1(_L(" Re Drawn Top Half Faded Yet Again")); + canFade!=TheClient->iScreen->RectCompare(TRect(TPoint(screenSize.iWidth/3,0),TSize(10,10)) + ,TRect(TPoint(screenSize.iWidth/3,screenSize.iHeight/2),TSize(10,10))); + TEST(canFade); + if (!canFade) + INFO_PRINTF3(_L("TheClient->iScreen->RectCompare() return value - Expected: %d, Actual: %d"), ETrue, canFade); + + testWin->DrawNow(); + TheClient->iWs.Flush(); + INFO_PRINTF1(_L(" All Faded Again")); + retVal = TheClient->iScreen->RectCompare(TRect(TPoint(screenSize.iWidth/3,0),TSize(screenSize.iWidth/3,screenSize.iHeight/2)) + ,TRect(TPoint(screenSize.iWidth/3,screenSize.iHeight/2),TSize(screenSize.iWidth/3,screenSize.iHeight/2))); + TEST(retVal); + if (!retVal) + INFO_PRINTF3(_L("TheClient->iScreen->RectCompare() return value - Expected: %d, Actual: %d"), ETrue, retVal); + + CleanupStack::PopAndDestroy(2,&win); + INFO_PRINTF1(_L(" Killed Windows")); + } + +void CTRegion::CoverTestL() + { + CBlankWindow* testWin; + RBlankWindow win(TheClient->iWs); + CleanupClosePushL(win); + TSize screenSize=TheClient->iGroup->Size(); + testWin=new(ELeave) CBlankWindow(TRgb::Gray4(0)); + CleanupStack::PushL(testWin); + testWin->SetUpL(TPoint(screenSize.iWidth/3,0),TSize(screenSize.iWidth/3,screenSize.iHeight),TheClient->iGroup,*TheGc); + testWin->SetColor(TRgb::Gray4(1)); + testWin->RealDraw(ETrue); + win.Construct(*TheClient->iGroup->WinTreeNode(),3456); + win.SetColor(TRgb::Gray4(0)); + win.SetExtent(TPoint(screenSize.iWidth/3+30,20),TSize(screenSize.iWidth/3-62,25)); + win.SetVisible(EFalse); + win.Activate(); + TheClient->iWs.Flush(); + TheClient->WaitForRedrawsToFinish(); + testWin->DrawNow(); + testWin->SetColor(TRgb::Gray4(2)); + win.SetVisible(ETrue); + testWin->DrawNow(); + TheClient->iWs.Flush(); + CheckRectNoMatch(TPoint(screenSize.iWidth/3,0),TPoint(screenSize.iWidth/3+30,20),TSize(10,10),_L("TRegion::CoverTestL() A")); + + TheClient->WaitForRedrawsToFinish(); + CheckRectNoMatch(TPoint(screenSize.iWidth/3,0),TPoint(screenSize.iWidth/3+30,20),TSize(10,10),_L("TRegion::CoverTestL() B")); + + win.SetVisible(EFalse); + TheClient->iWs.Flush(); + TheClient->WaitForRedrawsToFinish(); + testWin->SetColor(TRgb::Gray4(1)); + testWin->Win()->Invalidate(); + win.SetVisible(ETrue); + testWin->DrawNow(); + TheClient->iWs.Flush(); + CheckRectNoMatch(TPoint(screenSize.iWidth/3,0),TPoint(screenSize.iWidth/3+30,20),TSize(10,10),_L("TRegion::CoverTestL() C")); + + CleanupStack::PopAndDestroy(2,&win); + } + +void CTRegion::OffsetTestL() + { + CBlankWindow* testWin; + RBlankWindow win(TheClient->iWs); + CleanupClosePushL(win); + TSize screenSize=TheClient->iGroup->Size(); + testWin=new(ELeave) CBlankWindow(TRgb::Gray4(0)); + CleanupStack::PushL(testWin); + testWin->SetUpL(TPoint(screenSize.iWidth/3,0),TSize(screenSize.iWidth/3,screenSize.iHeight-40),TheClient->iGroup,*TheGc); + testWin->Win()->EnableRedrawStore(EFalse); + testWin->SetColor(TRgb::Gray4(1)); + testWin->RealDraw(ETrue); + win.Construct(*testWin->WinTreeNode(),3456); + win.SetColor(TRgb::Gray4(2)); + win.SetExtent(TPoint(30,20),TSize(screenSize.iWidth/3-62,25)); + win.Activate(); + TheClient->iWs.Flush(); + TheClient->WaitForRedrawsToFinish(); + win.SetVisible(EFalse); + TheClient->iWs.Flush(); + testWin->DrawNow(); + testWin->SetColor(TRgb::Gray4(2)); + testWin->Win()->SetPosition(TPoint(screenSize.iWidth/3+30,35)); + testWin->DrawNow(); + TheClient->iWs.Flush(); + /* Andy - this is verifying that the complete redraw of the window in the second DrawNow only affects part + of the window. I don't understand it atall. + CheckRectNoMatch(TPoint(screenSize.iWidth/3+60,55),TPoint(screenSize.iWidth/3+70,85),TSize(10,10),_L("CTRegion::OffsetTestL() A")); + */ + TheClient->WaitForRedrawsToFinish(); + CheckRect(TPoint(screenSize.iWidth/3+60,55),TPoint(screenSize.iWidth/3+70,85),TSize(screenSize.iWidth/3-62,25),_L("CTRegion::OffsetTestL() A")); + + win.SetVisible(ETrue); + win.SetVisible(EFalse); + testWin->Win()->SetPosition(TPoint(screenSize.iWidth/3+5,5)); + testWin->SetColor(TRgb::Gray4(1)); + testWin->DrawNow(); + TheClient->iWs.Flush(); + CheckRect(TPoint(screenSize.iWidth/3+60,55),TPoint(screenSize.iWidth/3+55,90),TSize(screenSize.iWidth/3-62,25),_L("CTRegion::OffsetTestL() B")); + /* Andy - this is verifying that the complete redraw of the window during DrawNow only affects part + of the window. I don't understand it atall. + CheckRectNoMatch(TPoint(screenSize.iWidth/3+30,20),TPoint(screenSize.iWidth/3+50,90),TSize(10,10),_L("CTRegion::OffsetTestL() B")); + */ + CleanupStack::PopAndDestroy(2,&win); + } + +void CTRegion::ClipTestL() + { + CBlankWindow* testWin; + RBlankWindow win(TheClient->iWs); + CleanupClosePushL(win); + TSize screenSize=TheClient->iGroup->Size(); + testWin=new(ELeave) CBlankWindow(TRgb::Gray4(0)); + CleanupStack::PushL(testWin); + testWin->SetUpL(TPoint(screenSize.iWidth/3,0),TSize(screenSize.iWidth/3,screenSize.iHeight),TheClient->iGroup,*TheGc); + testWin->Win()->EnableRedrawStore(EFalse); + testWin->SetColor(TRgb::Gray4(1)); + testWin->RealDraw(ETrue); + win.Construct(*testWin->WinTreeNode(),3456); + win.SetColor(TRgb::Gray4(2)); + win.SetExtent(TPoint(30,20),TSize(screenSize.iWidth/3-62,25)); + win.Activate(); + TheClient->iWs.Flush(); + TheClient->WaitForRedrawsToFinish(); + win.SetVisible(EFalse); + TheClient->iWs.Flush(); + testWin->DrawNow(); + testWin->SetColor(TRgb::Gray4(2)); + User::LeaveIfError(testWin->Win()->SetSizeErr(TSize(screenSize.iWidth/6,screenSize.iHeight-2))); + RRegion invalid; + testWin->Win()->GetInvalidRegion(invalid); + testWin->DrawNow(); + TheClient->iWs.Flush(); + TBool retVal = !invalid.CheckError(); + TEST(retVal); + if (!retVal) + INFO_PRINTF3(_L("!invalid.CheckError() return value - Expected: %d, Actual: %d"), ETrue, retVal); + + TEST(invalid.BoundingRect().iBr.iX<=screenSize.iWidth/6); + if (invalid.BoundingRect().iBr.iX>screenSize.iWidth/6) + INFO_PRINTF3(_L("invalid.BoundingRect().iBr.iX<=screenSize.iWidth/6 - Expected: %d, Actual: %d"), screenSize.iWidth/6, invalid.BoundingRect().iBr.iX); + TheClient->iWs.Finish(); + TheClient->WaitForRedrawsToFinish(); + testWin->Win()->GetInvalidRegion(invalid); + + retVal = invalid.IsEmpty(); + TEST(retVal); + if (!retVal) + { + INFO_PRINTF3(_L("!invalid.CheckError() return value - Expected: %d, Actual: %d"), ETrue, retVal); + } + + User::LeaveIfError(testWin->Win()->SetSizeErr(TSize(screenSize.iWidth/3,screenSize.iHeight-4))); + win.SetVisible(ETrue); + win.SetVisible(EFalse); + User::LeaveIfError(testWin->Win()->SetSizeErr(TSize(screenSize.iWidth/6,screenSize.iHeight-6))); + testWin->SetColor(TRgb::Gray4(1)); + testWin->DrawNow(); + TheClient->iWs.Flush(); + //PeterI This is testing an intermediate state i.e. "flicker" and will never pass on mk3 +/* CheckRectNoMatch(TPoint(screenSize.iWidth/3+30,20),TPoint(screenSize.iWidth/3+50,90),TSize(10,10),_L("CTRegion::ClipTestL()")); + TEST(retVal); + if (!retVal) + { + INFO_PRINTF3(_L("!CheckRect() return value - Expected: %d, Actual: %d"), ETrue, retVal); + } + */ + CleanupStack::PopAndDestroy(2,&win); + } + +void CTRegion::RunTestCaseL(TInt /*aCurTestCase*/) + { + ((CTRegionStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); + switch(++iTest->iState) + { +/** +@SYMTestCaseID GRAPHICS-WSERV-0272 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test drawing to a region including clipping + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Draw to a region that has clipping enabled and the check the + drawing occurs correctly + +@SYMTestExpectedResults Drawing to the region occurs correctly +*/ + case 1: + { + ((CTRegionStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0272")); + iTest->LogSubTest(_L("Main")); + RRegion clippingRegion; + CreateChildWindowsL(); + TheClient->iWs.Finish(); + TheClient->WaitForRedrawsToFinish(); + TSize scrSize(TheClient->iScreen->SizeInPixels()); + for(TUint index=0;index<(sizeof(regionRectList)/sizeof(regionRectList[0]));index++) + { + regionRectList[index].SetWidth((regionRectList[index].Width()*scrSize.iWidth)/640); + regionRectList[index].SetHeight((regionRectList[index].Height()*scrSize.iHeight)/240); + clippingRectList[index].SetWidth((clippingRectList[index].Width()*scrSize.iWidth)/640); + clippingRectList[index].SetHeight((clippingRectList[index].Height()*scrSize.iHeight)/240); + originList[index].iX = (originList[index].iX*scrSize.iWidth)/640; + originList[index].iY = (originList[index].iY*scrSize.iHeight)/240; + + clippingRegion.AddRect(regionRectList[index]); + TestRegionL(clippingRegion,clippingRectList[index],originList[index]); + } + clippingRegion.Close(); + DeleteChildWindows(); + } + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0273 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test drawing to a region including clipping as it is exposed + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Draw to a region that has clipping enabled as it is exposed + and the check the drawing occurs correctly + +@SYMTestExpectedResults Drawing to the region occurs correctly +*/ + case 2: + ((CTRegionStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0273")); + //PeterI This appears to be testing "flicker" of a window after an expose + //Mk3 doesn't exhibit this behaviour. Is the flicker expected behaviour? +// iTest->LogSubTest(_L("Expose Test")); +// ExposeTestL(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0274 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test drawing to a region including clipping as it is exposed + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Draw to a region that has clipping enabled as it is exposed + and the check the drawing occurs correctly + +@SYMTestExpectedResults Drawing to the region occurs correctly +*/ + case 3: + ((CTRegionStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0274")); + iTest->LogSubTest(_L("Expose Test2")); + ExposeTest2L(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0275 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test drawing to a region including clipping as it is covered + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Draw to a region that has clipping enabled as it is covered + and the check the drawing occurs correctly + +@SYMTestExpectedResults Drawing to the region occurs correctly +*/ + case 4: + ((CTRegionStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0275")); + iTest->LogSubTest(_L("Cover Test")); + CoverTestL(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0276 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test drawing to a region including clipping and with an offset + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Draw to a region that has clipping enabled and with an offset + and the check the drawing occurs correctly + +@SYMTestExpectedResults Drawing to the region occurs correctly +*/ + case 5: + ((CTRegionStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0276")); + iTest->LogSubTest(_L("Offset Test")); + OffsetTestL(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0277 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test drawing to a region including clipping + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Draw to a region that has clipping enabled + and the check the drawing occurs correctly + +@SYMTestExpectedResults Drawing to the region occurs correctly +*/ + case 6: + ((CTRegionStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0277")); + iTest->LogSubTest(_L("Clip Test")); + ClipTestL(); + break; + default: + ((CTRegionStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + ((CTRegionStep*)iStep)->CloseTMSGraphicsStep(); + TestComplete(); + } + ((CTRegionStep*)iStep)->RecordTestResultL(); + } + + +__WS_CONSTRUCT_STEP__(Region) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TSCRDEV.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TSCRDEV.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,642 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Screen device test code +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include "TSCRDEV.H" + +//Define this to get visible pauses (in test 6: DeviceResSwitchL) +//#define VISIBLE_PAUSES + +//Define this to get extra logging which may be useful in tracking down a fail +//#define EXTRA_LOGGING + +CTScreenDevice::CTScreenDevice(CTestStep* aStep) : CTWsGraphicsBase(aStep) + {} + +CTScreenDevice::~CTScreenDevice() + {} + +void CTScreenDevice::ConstructL() + { + //The following is just another test... it doesn't leave any resources for use by the test class AFAICT... + RWsSession aSession; + CWsScreenDevice *device1; + CWsScreenDevice *device2; + CWsScreenDevice *device3; + + aSession.Connect(); + device1=new(ELeave) CWsScreenDevice(aSession); + device1->Construct(iTest->iScreenNumber); + delete device1; + device1=new(ELeave) CWsScreenDevice(aSession); + device1->Construct(iTest->iScreenNumber); + device2=new(ELeave) CWsScreenDevice(aSession); + device2->Construct(iTest->iScreenNumber); + device3=new(ELeave) CWsScreenDevice(aSession); + device3->Construct(iTest->iScreenNumber); + delete device3; + CFbsFont *font; + User::LeaveIfError(device1->GetNearestFontToDesignHeightInTwips((CFont *&)font,TFontSpec())); + RWindowGroup group(aSession); + group.Construct(777); + group.SetOwningWindowGroup(TheClient->iGroup->GroupWin()->Identifier()); + RWindow win(aSession); + win.Construct(group,77); + CWindowGc *gc=new(ELeave) CWindowGc(device1); + gc->Construct(); + gc->Activate(win); + gc->UseFont(font); + device1->ReleaseFont(font); + aSession.Flush(); + delete gc; + win.Close(); + group.Close(); + delete device1; + delete device2; + aSession.Close(); + } + + +void CTScreenDevice::TestTwipPixelConversions() + { + TInt result=TheClient->iScreen->HorizontalTwipsToPixels(TheClient->iScreen->HorizontalPixelsToTwips(1234)); + TEST(result==1234); + if (result!=1234) + INFO_PRINTF3(_L("TheClient->iScreen->HorizontalTwipsToPixels(TheClient->iScreen->HorizontalPixelsToTwips(1234) return value - Expected: %d, Actual: %d"), 1234, result); + + result=TheClient->iScreen->VerticalTwipsToPixels(TheClient->iScreen->VerticalPixelsToTwips(1234)); + TEST(result==1234); + if (result!=1234) + INFO_PRINTF3(_L("TheClient->iScreen->VerticalTwipsToPixels(TheClient->iScreen->VerticalPixelsToTwips(1234) return value - Expected: %d, Actual: %d"), 1234, result); + + TSize pixels=TheClient->iScreen->SizeInPixels(); + TSize twips=TheClient->iScreen->SizeInTwips(); + TInt conv=TheClient->iScreen->HorizontalPixelsToTwips(pixels.iWidth); + TEST(conv==twips.iWidth); + if (conv!=twips.iWidth) + INFO_PRINTF3(_L("TheClient->iScreen->HorizontalPixelsToTwips(pixels.iWidth) return value - Expected: %d, Actual: %d"), twips.iWidth, conv); + + conv=TheClient->iScreen->VerticalPixelsToTwips(pixels.iHeight); + TEST(conv==twips.iHeight); + if (conv!=twips.iHeight) + INFO_PRINTF3(_L("TheClient->iScreen->VerticalPixelsToTwips(pixels.iHeight) return value - Expected: %d, Actual: %d"), twips.iHeight, conv); + } + +#define TEST_VALUE 100000000 +void CTScreenDevice::TestTwipPixelOverflow() + { + TInt result=TheClient->iScreen->HorizontalTwipsToPixels(TheClient->iScreen->HorizontalPixelsToTwips(TEST_VALUE)); + TEST(result==TEST_VALUE); + if (result!=TEST_VALUE) + INFO_PRINTF3(_L("TheClient->iScreen->HorizontalTwipsToPixels(TheClient->iScreen->HorizontalPixelsToTwips(TEST_VALUE)) return value - Expected: %d, Actual: %d"), TEST_VALUE, result); + + result=TheClient->iScreen->VerticalTwipsToPixels(TheClient->iScreen->VerticalPixelsToTwips(TEST_VALUE)); + TEST(result==TEST_VALUE); + if (result!=TEST_VALUE) + INFO_PRINTF3(_L("TheClient->iScreen->VerticalTwipsToPixels(TheClient->iScreen->VerticalPixelsToTwips(TEST_VALUE)) return value - Expected: %d, Actual: %d"), TEST_VALUE, result); + + result = TheClient->iScreen->HorizontalPixelsToTwips(TEST_VALUE); + TEST(result>0); + if (!result>0) + INFO_PRINTF3(_L("TheClient->iScreen->HorizontalPixelsToTwips(TEST_VALUE) return value - Expected: %d less than, Actual: %d"), 0, result); + + result = TheClient->iScreen->VerticalPixelsToTwips(TEST_VALUE); + TEST(result>0); + if (!result>0) + INFO_PRINTF3(_L("TheClient->iScreen->VerticalPixelsToTwips(TEST_VALUE) return value - Expected: %d less than, Actual: %d"), 0, result); + + result = TheClient->iScreen->HorizontalTwipsToPixels(TEST_VALUE); + TEST(result>0); + if (!result>0) + INFO_PRINTF3(_L("TheClient->iScreen->HorizontalTwipsToPixels(TEST_VALUE) return value - Expected: %d less than, Actual: %d"), 0, result); + + result = TheClient->iScreen->VerticalTwipsToPixels(TEST_VALUE); + TEST(result>0); + if (!result>0) + INFO_PRINTF3(_L("TheClient->iScreen->VerticalTwipsToPixels(TEST_VALUE) return value - Expected: %d less than, Actual: %d"), 0, result); + } + +void CTScreenDevice::TwipsCacheFlushL() + { + RWsSession session; + CWsScreenDevice* device; + CFont* font; + CFont* font2; + const TFontSpec fontspec(KTestFontTypefaceName,250); + TPixelsTwipsAndRotation sizeAndRotation; + + // create a CWsScreenDevice instance + User::LeaveIfError(session.Connect()); + device=new(ELeave) CWsScreenDevice(session); + device->Construct(iTest->iScreenNumber); + + // Record a font height for use by latter tests + User::LeaveIfError(device->GetNearestFontToDesignHeightInTwips(font,fontspec)); + const TInt height0=font->HeightInPixels(); + device->ReleaseFont(font); + + // 1. find font with best-matching height in twips, + // 2. change twips size of the screen (leaving pixel-size same), + // 3. find font with best-matching height in twips, + // 4. make sure that the newly found font is not the same as previous and has the different height in pixels + device->GetDefaultScreenSizeAndRotation(sizeAndRotation); +#if defined(EXTRA_LOGGING) + _LIT(KLog1,"Font height: %d for unchanged device. pixels=%d,%d twips=%d,%d"); + LOG_MESSAGE6(KLog1,height0,sizeAndRotation.iPixelSize.iWidth,sizeAndRotation.iPixelSize.iHeight + ,sizeAndRotation.iTwipsSize.iWidth,sizeAndRotation.iTwipsSize.iHeight); +#endif + sizeAndRotation.iTwipsSize.iHeight=2000; + sizeAndRotation.iTwipsSize.iWidth =3000; + device->SetScreenSizeAndRotation(sizeAndRotation); + + User::LeaveIfError(device->GetNearestFontToDesignHeightInTwips(font,fontspec)); + TInt height=font->HeightInPixels(); +#if defined(EXTRA_LOGGING) + _LIT(KLog2,"Font height: %d for device with twips set to 2000x3000"); + LOG_MESSAGE2(KLog2,height); +#endif + TFontSpec returnedSpec=font->FontSpecInTwips(); + + sizeAndRotation.iTwipsSize.iHeight=4000; + sizeAndRotation.iTwipsSize.iWidth =6000; + device->SetScreenSizeAndRotation(sizeAndRotation); + + User::LeaveIfError(device->GetNearestFontToDesignHeightInTwips(font2,fontspec)); + TInt height2=font2->HeightInPixels(); + TFontSpec returnedSpec2 = font2->FontSpecInTwips(); +#if defined(EXTRA_LOGGING) + _LIT(KLog3,"Font height: %d for device with twips set to 4000x6000"); + LOG_MESSAGE2(KLog3,height2); +#endif + + TEST(font!=font2); + TEST(height!=height2); + _LIT(KLogErrM,"Font Heights in pixels match unexpectantly, height=%d"); + if (height==height2) + INFO_PRINTF2(KLogErrM,height); + + device->ReleaseFont(font2); + device->ReleaseFont(font); + + // 1. find font with best-matching height in twips, + // 2. change pixel size of the screen (leaving twip-size same), + // 3. find font with best-matching height in twips, + // 4. make sure that the newly found font is not the same as previous and has the different height in pixels + device->GetDefaultScreenSizeAndRotation(sizeAndRotation); + sizeAndRotation.iPixelSize.iHeight=240; + sizeAndRotation.iPixelSize.iWidth =640; + device->SetScreenSizeAndRotation(sizeAndRotation); + + User::LeaveIfError(device->GetNearestFontToDesignHeightInTwips(font,fontspec)); + height=font->HeightInPixels(); + returnedSpec=font->FontSpecInTwips(); +#if defined(EXTRA_LOGGING) + _LIT(KLog4,"Font height: %d for device with pixels set to 240x640 twips=%d,%d"); + LOG_MESSAGE4(KLog4,height,sizeAndRotation.iTwipsSize.iWidth,sizeAndRotation.iTwipsSize.iHeight); +#endif + + sizeAndRotation.iPixelSize.iHeight=480; + sizeAndRotation.iPixelSize.iWidth =1280; + device->SetScreenSizeAndRotation(sizeAndRotation); + + User::LeaveIfError(device->GetNearestFontToDesignHeightInTwips(font2,fontspec)); + height2=font2->HeightInPixels(); + returnedSpec2=font2->FontSpecInTwips(); +#if defined(EXTRA_LOGGING) + _LIT(KLog5,"Font height: %d for device with pixels set to 480x1280"); + LOG_MESSAGE2(KLog5,height2); +#endif + + TEST(font!=font2); + TEST(height!=height2); + if (height==height2) + INFO_PRINTF2(KLogErrM,height); + + device->ReleaseFont(font2); + device->ReleaseFont(font); + + // 1. double the width and height of screen in both pixels and twips + // 2. find font with best-matching height in twips, + // 3. make sure that the newly found font is the same as previous and has the same height in pixels + device->GetDefaultScreenSizeAndRotation(sizeAndRotation); + device->SetScreenSizeAndRotation(sizeAndRotation); + User::LeaveIfError(device->GetNearestFontToDesignHeightInTwips(font,fontspec)); + sizeAndRotation.iPixelSize.iHeight*=2; + sizeAndRotation.iPixelSize.iWidth *=2; + sizeAndRotation.iTwipsSize.iHeight*=2; + sizeAndRotation.iTwipsSize.iWidth *=2; + device->SetScreenSizeAndRotation(sizeAndRotation); + + User::LeaveIfError(device->GetNearestFontToDesignHeightInTwips(font2,fontspec)); + height2=font2->HeightInPixels(); +#if defined(EXTRA_LOGGING) + _LIT(KLog6,"Font height: %d for device doubled size. pixels=%d,%d twips=%d,%d"); + LOG_MESSAGE6(KLog6,height2,sizeAndRotation.iPixelSize.iWidth,sizeAndRotation.iPixelSize.iHeight + ,sizeAndRotation.iTwipsSize.iWidth,sizeAndRotation.iTwipsSize.iHeight); +#endif + + TEST(font==font2); + TEST(height0==height2); + _LIT(KLogErrD,"Font Heights in pixels don't match, expected=%d, actual=%d"); + if (height0!=height2) + INFO_PRINTF3(KLogErrD,height0,height2); + + device->ReleaseFont(font2); + device->ReleaseFont(font); + + // 1. swap width and height sizes of screen for both pixels and twips + // 2. find font with best-matching height in twips, + // 3. make sure that the newly found font is the same as previous and has the same height in pixels + device->GetDefaultScreenSizeAndRotation(sizeAndRotation); + device->SetScreenSizeAndRotation(sizeAndRotation); + User::LeaveIfError(device->GetNearestFontToDesignHeightInTwips(font,fontspec)); + TInt swap=sizeAndRotation.iPixelSize.iHeight; + sizeAndRotation.iPixelSize.iHeight=sizeAndRotation.iPixelSize.iWidth; + sizeAndRotation.iPixelSize.iWidth =swap; + swap=sizeAndRotation.iTwipsSize.iHeight; + sizeAndRotation.iTwipsSize.iHeight=sizeAndRotation.iTwipsSize.iWidth; + sizeAndRotation.iTwipsSize.iWidth =swap; + device->SetScreenSizeAndRotation(sizeAndRotation); + User::LeaveIfError(device->GetNearestFontToDesignHeightInTwips(font2,fontspec)); + height2 = font2->HeightInPixels(); +#if defined(EXTRA_LOGGING) + _LIT(KLog7,"Font height: %d for device rotated size. pixels=%d,%d twips=%d,%d"); + LOG_MESSAGE6(KLog7,height2,sizeAndRotation.iPixelSize.iWidth,sizeAndRotation.iPixelSize.iHeight + ,sizeAndRotation.iTwipsSize.iWidth,sizeAndRotation.iTwipsSize.iHeight); +#endif + + TEST(font==font2); + TEST(height0==height2); + if (height0!=height2) + INFO_PRINTF3(KLogErrD,height0,height2); + + device->ReleaseFont(font2); + device->ReleaseFont(font); + + delete device; + session.Close(); + } + +void CTScreenDevice::CheckBitmapL(CFbsBitmap *aBitmap, const TRect &aRect) + { + CFbsBitmapDevice *device=CFbsBitmapDevice::NewL(aBitmap); + CleanupStack::PushL(device); + TInt height=Min(aRect.Size().iHeight,aBitmap->SizeInPixels().iHeight); + TInt width=Min(aRect.Size().iWidth,aBitmap->SizeInPixels().iWidth); + TPoint pos(0,0); + TInt bufLen=CFbsBitmap::ScanLineLength(width,EGray4); + TAny *buf1=User::AllocLC(bufLen); + TAny *buf2=User::AllocLC(bufLen); + TPtr8 scanBuf1((TUint8 *)buf1,bufLen); + TPtr8 scanBuf2((TUint8 *)buf2,bufLen); + TInt oddPixels=width%4; + TInt byte1,byte2; + for(;pos.iYiScreen->GetScanLine(scanBuf1,pos+aRect.iTl,width,EGray4); + device->GetScanLine(scanBuf2,pos,width,EGray4); + if (oddPixels>0) + { + byte1=(scanBuf1[bufLen-1]<<(2*(4-oddPixels)))%256; + byte2=(scanBuf2[bufLen-1]<<(2*(4-oddPixels)))%256; + TEST(byte1==byte2); + if (byte1!=byte2) + INFO_PRINTF3(_L("byte1==byte2 - byte1: %d, byte2 Height: %d"), byte1, byte2); + + scanBuf1=scanBuf1.Left(bufLen-1); + scanBuf2=scanBuf2.Left(bufLen-1); + } + TBool retVal = !scanBuf1.Compare(scanBuf2); + TEST(retVal); + if (!retVal) + INFO_PRINTF3(_L("!scanBuf1.Compare(scanBuf2) return value - Expected: %d, Actual: %d"), ETrue, retVal); + } + CleanupStack::PopAndDestroy(3); + } + +void CTScreenDevice::doTestScreenToBitmapL() + { + RBlankWindow shieldWin(TheClient->iWs); + shieldWin.Construct(*TheClient->iGroup->GroupWin(),1); + shieldWin.SetOrdinalPosition(0,-1); + shieldWin.SetColor(TRgb::Gray4(1)); + shieldWin.Activate(); + CleanupStack::PushL(TCleanupItem(CleanUpWindow,&shieldWin)); + TSize scrSize(TheClient->iScreen->SizeInPixels()); + CWsBitmap *wsBitmap=new(ELeave) CWsBitmap(TheClient->iWs); + CleanupStack::PushL(wsBitmap); + User::LeaveIfError(wsBitmap->Create(scrSize,EGray4)); + CFbsBitmap *bitmap=new(ELeave) CFbsBitmap; + CleanupStack::PushL(bitmap); + + TheClient->iWs.Finish(); + TheClient->WaitForRedrawsToFinish(); + + User::LeaveIfError(bitmap->Create(TSize(30,10),EGray4)); +// + User::LeaveIfError(TheClient->iScreen->CopyScreenToBitmap(wsBitmap)); + CheckBitmapL(wsBitmap,TRect(scrSize)); +// + User::LeaveIfError(TheClient->iScreen->CopyScreenToBitmap(bitmap)); + CheckBitmapL(bitmap,TRect(scrSize)); +// + TRect rect1(111,10,222,20); + User::LeaveIfError(TheClient->iScreen->CopyScreenToBitmap(wsBitmap,rect1)); + CheckBitmapL(wsBitmap,rect1); +// + TRect rect2(10,20,100,200); + User::LeaveIfError(TheClient->iScreen->CopyScreenToBitmap(bitmap,rect2)); + CheckBitmapL(bitmap,rect2); +// +// Now some mad values +// +// Right edge left of left edge + User::LeaveIfError(TheClient->iScreen->CopyScreenToBitmap(bitmap,TRect(100,20,90,200))); +// Off the edge of the screen + User::LeaveIfError(TheClient->iScreen->CopyScreenToBitmap(bitmap,TRect(-10,20,-5,200))); +// Off the edge of the screen again + User::LeaveIfError(TheClient->iScreen->CopyScreenToBitmap(bitmap,TRect(scrSize.AsPoint()+TPoint(5,5),TSize(10,10)))); +// + CleanupStack::PopAndDestroy(3); + } + + + +void CTScreenDevice::TestScreenToBitmap() + { + TRAPD(ret,doTestScreenToBitmapL()); + TEST(ret==KErrNone); + if (ret!=KErrNone) + INFO_PRINTF3(_L("doTestScreenToBitmapL() return value - Expected: %d, Actual: %d"), KErrNone, ret); + } + + +CCachePanic::~CCachePanic() + { + delete iWsScrDev; + iWs.Close(); + } + +void CCachePanic::ConstructL(TInt aScreenNumber, TInt aInt) + { + iScreenNumber = aScreenNumber; + iInt = aInt; + + User::LeaveIfError(iWs.Connect()); + iWsScrDev=new(ELeave) CWsScreenDevice(iWs); + User::LeaveIfError(iWsScrDev->Construct(iScreenNumber)); + } + +TInt CCachePanic::DoTest(CCachePanic* aTestClass) + { + CActiveScheduler* activeScheduler=new(ELeave) CActiveScheduler; + CActiveScheduler::Install(activeScheduler); + CleanupStack::PushL(activeScheduler); + TRAP_IGNORE(aTestClass->TestL()); + CleanupStack::PopAndDestroy(activeScheduler); + return EWsExitReasonFinished; + } + +void CCachePanic::TestL() + { + AutoPanic(EAutoPanicTestFailed); + } + +TInt CTwipsPanic::RunTest(TInt aInt, TAny* aPtr) + { + TInt error = KErrNone; + + CTwipsPanic* self=new(ELeave) CTwipsPanic(); + CleanupStack::PushL(self); + + TRAP(error, self->ConstructL((TInt)aPtr, aInt)); + if (!error) + { + error = CCachePanic::DoTest(self); + } + CleanupStack::PopAndDestroy(self); + return error; + } + +void CTwipsPanic::TestL() + { + TPixelsTwipsAndRotation sizeAndRotation; + TFontSpec fontspec(KTestFontTypefaceName,250); + + CFbsFont *font; + CFbsFont *font2; + + iWsScrDev->GetDefaultScreenSizeAndRotation(sizeAndRotation); + sizeAndRotation.iTwipsSize.iHeight = 2000; + sizeAndRotation.iTwipsSize.iWidth = 3000; + iWsScrDev->SetScreenSizeAndRotation(sizeAndRotation); + iWsScrDev->GetNearestFontToDesignHeightInTwips((CFont *&)font,fontspec); + iWsScrDev->GetNearestFontToDesignHeightInTwips((CFont *&)font2,fontspec); + sizeAndRotation.iTwipsSize.iHeight = 4000; + sizeAndRotation.iTwipsSize.iWidth = 6000; + iWsScrDev->SetScreenSizeAndRotation(sizeAndRotation); + iWsScrDev->ReleaseFont(font); + } + +TInt CScanLinePanic::RunTest(TInt aInt, TAny* aPtr) + { + TInt error = KErrNone; + + CScanLinePanic* self=new(ELeave) CScanLinePanic(); + CleanupStack::PushL(self); + + TRAP(error, self->ConstructL((TInt)aPtr, aInt)); + if (!error) + { + error = CCachePanic::DoTest(self); + } + CleanupStack::PopAndDestroy(self); + return error; + } + +void CScanLinePanic::TestL() + { + switch (iInt) + { + case TESTCASE_GRAPHICS_WSERV_0473: + TestLengthInvariant(); + break; + case TESTCASE_GRAPHICS_WSERV_0474: + TestBufferInvariant(); + break; + } + } + +void CScanLinePanic::TestLengthInvariant() + { + TInt buffLength=50; + TInt length=-1; + TUint8* buffer=new(ELeave) TUint8[buffLength]; + TPtr8 scanline(buffer, buffLength, buffLength); + iWsScrDev->GetScanLine(scanline, TPoint(), length, EColor64K); + delete buffer; + } + +void CScanLinePanic::TestBufferInvariant() + { + TInt buffLength=19; + TInt length=10; + TUint8* buffer=new(ELeave) TUint8[buffLength]; + TPtr8 scanline(buffer, buffLength, buffLength); + iWsScrDev->GetScanLine(scanline, TPoint(), length, EColor64K); + delete buffer; + } + +void CTScreenDevice::RunTestCaseL(TInt /*aCurTestCase*/) + { + ((CTScreenDeviceStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); + switch(++iTest->iState) + { +/** +@SYMTestCaseID GRAPHICS-WSERV-0080 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test twips to pixels conversions + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Converts pixels to twips and then back the result back to pixels. Checks screen size request methods both in pixels and twips + +@SYMTestExpectedResults Expects that back and forth conversions preserve an original value. +*/ + case 1: + ((CTScreenDeviceStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0080")); + iTest->LogSubTest(_L("Screen Device 1")); + TestTwipPixelConversions(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0081 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Tests CWsScreenDevice::CopyScreenToBitmap method + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Creates a blank window on the screen and uses CWsScreenDevice::CopyScreenToBitmap to copy parts of the screen image to either CWsBitmap or CFbsBitmap + +@SYMTestExpectedResults Expects that the method will not fail and that the image is copied correctly making pixel-to-pixel comparisons +*/ + case 2: + ((CTScreenDeviceStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0081")); + iTest->LogSubTest(_L("Copy Screen To Bitmap")); + TestScreenToBitmap(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0082 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test for integrity of twips to pixels conversions providing big values + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Calls twips to pixels (and backward) conversions for 100000000 value + +@SYMTestExpectedResults Expects that back and forth conversions preserve an original value. Make sure that the result is always greater that 0. +*/ + case 3: + ((CTScreenDeviceStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0082")); + iTest->LogSubTest(_L("Twip To Pixels Overflow")); + TestTwipPixelOverflow(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0083 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test that twips-in-pixel ratio change for screen size affects twips-in-pixel ratio of font + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Changes number of twips on screen (leaving number of pixels same), changes number of pixels on screen (leaving number of twips same), makes proportional changes of screen size for both twips and pixels + +@SYMTestExpectedResults Expects that twips-in-pixel ratio of font leaves the same only when screen size was changed through multipying of width by a coefficient (same for both twips and pixels) and multipying of height by a coefficient (same for both twips and pixels) +*/ + case 4: + ((CTScreenDeviceStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0083")); + iTest->LogSubTest(_L("Twips cache flush after device size change")); + TwipsCacheFlushL(); + break; + case 5: + ((CTScreenDeviceStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0083")); + iTest->LogSubTest(_L("Twips cache reset")); + // not expecting any panic + TEST(iTest->TestPanicL(CTwipsPanic::RunTest, 0, 0, (TAny*)iTest->iScreenNumber, _L(""))); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0473 + +@SYMDEF DEF116127 + +@SYMTestCaseDesc Invariant testing length parameter of less then 0 values in CWsScreenDevice::GetScanLine() + method + +@SYMTestActions Calls CWsScreenDevice::GetScanLine with aLength of -1. + +**/ + case 6: + ((CTScreenDeviceStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0473")); + iTest->LogSubTest(_L("Testing ScanLine length invariant")); + TEST(iTest->TestPanicL(CScanLinePanic::RunTest, EWservPanicInvalidParameter, + CScanLinePanic::TESTCASE_GRAPHICS_WSERV_0473, + (TAny*)iTest->iScreenNumber, _L("WSERV"))); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0474 + +@SYMDEF DEF116127 + +@SYMTestCaseDesc Invariant testing buffer parameter for required size. + +@SYMTestActions Calls CWsScreenDevice::GetScanLine with buffer too small to contain requested data. +**/ + case 7: + ((CTScreenDeviceStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0474")); + iTest->LogSubTest(_L("Testing ScanLine buffer invariant")); + TEST(iTest->TestPanicL(CScanLinePanic::RunTest, EWservPanicInvalidParameter, + CScanLinePanic::TESTCASE_GRAPHICS_WSERV_0474, + (TAny*)iTest->iScreenNumber, _L("WSERV"))); + break; + default: + ((CTScreenDeviceStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + ((CTScreenDeviceStep*)iStep)->CloseTMSGraphicsStep(); + TestComplete(); + } + ((CTScreenDeviceStep*)iStep)->RecordTestResultL(); + } + +__WS_CONSTRUCT_STEP__(ScreenDevice) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TSCRDEV.H --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TSCRDEV.H Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,107 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef __TSCRDEV_H__ +#define __TSCRDEV_H__ + +#include +#include "w32std.h" +#include "../tlib/testbase.h" +#include "AUTO.H" +#include "TGraphicsHarness.h" + +class CTScreenDevice : public CTWsGraphicsBase + { +public: + CTScreenDevice(CTestStep* aStep); + ~CTScreenDevice(); + void ConstructL(); + void TestTwipPixelConversions(); + void TestTwipPixelOverflow(); + void TwipsCacheFlushL(); + void CheckBitmapL(CFbsBitmap *aBitmap, const TRect &aRect); + void TestScreenToBitmap(); +protected: + virtual void RunTestCaseL(TInt aCurTestCase); +private: + void doTestScreenToBitmapL(); + }; + +class CTScreenDeviceStep : public CTGraphicsStep + { +public: + CTScreenDeviceStep(); +protected: + //from CTGraphicsStep + virtual CTGraphicsBase* CreateTestL(); + }; + +class CCachePanic : public CBase + { +protected: + CCachePanic() + { + }; + ~CCachePanic(); + virtual void TestL(); + void ConstructL(TInt aScreenNumber, TInt aInt); + static TInt DoTest(CCachePanic* aTestClass); + +protected: + RWsSession iWs; + CWsScreenDevice* iWsScrDev; + TInt iScreenNumber; + TInt iInt; + }; + +class CTwipsPanic : public CCachePanic + { +public: + static TInt RunTest(TInt aInt, TAny* aPtr); + +private: + virtual void TestL(); + }; + +class CScanLinePanic : public CCachePanic + { +public: + enum ScanLineTestCases + { + TESTCASE_GRAPHICS_WSERV_0473 = 0, + TESTCASE_GRAPHICS_WSERV_0474 + }; +public: + static TInt RunTest(TInt aInt, TAny* aPtr); + +private: + virtual void TestL(); + + // Methods for test cases go here +private: + void TestLengthInvariant(); + void TestBufferInvariant(); + + }; + +_LIT(KTScreenDeviceStep,"TScreenDevice"); + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TSCRDEVRESSWITCH.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TSCRDEVRESSWITCH.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,581 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Screen device test code +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include "TSCRDEVRESSWITCH.H" + +//Define this to get visible pauses (in test 6: DeviceResSwitchL) +//#define VISIBLE_PAUSES + +//Define this to get extra logging which may be useful in tracking down a fail +//#define EXTRA_LOGGING + +CTScreenDeviceResSwitch::CTScreenDeviceResSwitch(CTestStep* aStep) : CTWsGraphicsBase(aStep) + {} + +CTScreenDeviceResSwitch::~CTScreenDeviceResSwitch() + {} + +void CTScreenDeviceResSwitch::ConstructL() + { + //The following is just another test... it doesn't leave any resources for use by the test class AFAICT... + RWsSession aSession; + CWsScreenDevice *device1; + CWsScreenDevice *device2; + CWsScreenDevice *device3; + + aSession.Connect(); + device1=new(ELeave) CWsScreenDevice(aSession); + device1->Construct(iTest->iScreenNumber); + delete device1; + device1=new(ELeave) CWsScreenDevice(aSession); + device1->Construct(iTest->iScreenNumber); + device2=new(ELeave) CWsScreenDevice(aSession); + device2->Construct(iTest->iScreenNumber); + device3=new(ELeave) CWsScreenDevice(aSession); + device3->Construct(iTest->iScreenNumber); + delete device3; + CFbsFont *font; + User::LeaveIfError(device1->GetNearestFontToDesignHeightInTwips((CFont *&)font,TFontSpec())); + RWindowGroup group(aSession); + group.Construct(777); + group.SetOwningWindowGroup(TheClient->iGroup->GroupWin()->Identifier()); + RWindow win(aSession); + win.Construct(group,77); + CWindowGc *gc=new(ELeave) CWindowGc(device1); + gc->Construct(); + gc->Activate(win); + gc->UseFont(font); + device1->ReleaseFont(font); + aSession.Flush(); + delete gc; + win.Close(); + group.Close(); + delete device1; + delete device2; + aSession.Close(); + } + + +class CPrimaryColoursWin : public CTWin + { +public: + enum //various size factors + { + kShrinkFactor=5, + kPlotSize=16, + kPlotMargin=4, + kPlotWithMargin=kPlotSize+kPlotMargin, + kPlotsAccross=3, + kPlotsDown=1, + kMinWidth=kPlotWithMargin*kPlotsAccross+kPlotMargin, + kMinHeight=kPlotWithMargin*kPlotsDown+kPlotMargin, + KNumChannels=3, + KNumColours=256 + }; + + CPrimaryColoursWin(); + ~CPrimaryColoursWin(); + //Virtual Function from CTBaseWin + void Draw(); + TInt CountUniquePlottedColours(); + TInt iDrawn; + TInt iNumColours; + TBool iBadPixels[KNumChannels][KNumColours]; + TBuf<0x40> iDisplayText; + }; + +CPrimaryColoursWin::CPrimaryColoursWin() + { + for (TInt channelnum=0;channelnumSetBrushStyle(CGraphicsContext::ESolidBrush); + iGc->SetPenStyle(CGraphicsContext::ESolidPen); + iGc->SetPenColor(TRgb(255, 255, 255)); + iGc->SetBrushColor(TRgb(0, 0, 0)); + TSize winSize = Size(); + iGc->DrawRect(TRect(winSize)); + + CFont* font; + TFontSpec fontSpec(_L(""), 300); + TheClient->iScreen->GetNearestFontInTwips(font, fontSpec); + + if (font) + { + iGc->UseFont(font); + TRect r(TPoint(0, 0), Size()); + r.Shrink(kMinHeight, kMinHeight); + iGc->DrawText(iDisplayText, r, font->AscentInPixels(), iGc->ECenter, 0); + iGc->DiscardFont(); + TheClient->iScreen->ReleaseFont(font); + } + + iNumColours = 0; + TPoint lhsAbs = Win()->AbsPosition(); + + for(TInt channelnum = 0, channelmul = 1, xoordinate = kPlotMargin; channelnum < KNumChannels; channelnum++, channelmul <<= 8, xoordinate += kPlotWithMargin) + { + TRgb lastPixel(255, 255, 255, 255); + + for(TInt colour = 0; colour < KNumColours; colour++) + { + if(!iBadPixels[channelnum][colour]) + { + iGc->SetPenColor(TRgb(colour * channelmul)); + } + else + { + iGc->SetPenColor(TRgb(255, 255, 255)); + } + + TPoint point = TPoint(xoordinate + (colour & 0x0f), kPlotMargin + (colour >> 4)); + iGc->Plot(point); + } + } + + iDrawn=ETrue; + } + +TInt CPrimaryColoursWin::CountUniquePlottedColours() + { + iNumColours = 0; + TPoint lhsAbs = Win()->AbsPosition(); + + for(TInt channelnum = 0, channelmul = 1, xoordinate = kPlotMargin; channelnum < 3; channelnum++, channelmul <<=8 , xoordinate += kPlotWithMargin) + { + TRgb lastPixel(255, 255, 255, 255); + + for(TInt colour = 0; colour < 256; colour++) + { + TRgb readPixel; + TPoint point = TPoint(xoordinate + (colour & 0x0f), kPlotMargin + (colour >> 4)); + TheClient->iScreen->GetPixel(readPixel, lhsAbs + point); + + if(readPixel != lastPixel) + { + lastPixel = readPixel; + iNumColours++; + iBadPixels[channelnum][colour] = EFalse; + } + else + { + iBadPixels[channelnum][colour] = ETrue; + } + } // for loop + } // for loop + + return iNumColours; + } + +/** + Intended primarily as a visual check that the mode is displayed correctly, + for each rotated mode. +**/ +void CTScreenDeviceResSwitch::DeviceResSwitchWithRotationsL() + { + CWsScreenDevice *screen=TheClient->iScreen; + TInt originalScreenMode = screen->CurrentScreenMode(); + TPixelsTwipsAndRotation originalModeSettings; + screen->GetScreenModeSizeAndRotation(originalScreenMode,originalModeSettings); + CArrayFixFlat *rotations=new(ELeave) CArrayFixFlat(1); + CleanupStack::PushL(rotations); + INFO_PRINTF2(_L("ScreenMode and rotation with colour depth. ScreenModes=%i"),TheClient->iScreenModes.Count()); + + for (TInt rr=0,maxrr=3;rriScreenModes.Count();iiiScreenModes[ii]; + if ( screen->GetScreenModeOrigin(ii)!=TPoint(0,0) || screen->GetScreenModeScale(ii)!=TSize(1,1) ) + { + INFO_PRINTF2(_L("ScreenMode %i skipped: has scalind and/ or rotation"),ii); + INFO_PRINTF1(_L("This scaling code is known to be broken if all modes do not support scaling")); + INFO_PRINTF1(_L("See defect DEF111847 and break request 2226")); + INFO_PRINTF5(_L("Origin: %i %i Scale %i %i"), + screen->GetScreenModeOrigin(ii).iX,screen->GetScreenModeOrigin(ii).iY, + screen->GetScreenModeScale(ii).iWidth,screen->GetScreenModeScale(ii).iHeight + ); + continue; + } + + screen->SetAppScreenMode(newMode); + screen->SetScreenMode(newMode); + TInt currentScreenMode = screen->CurrentScreenMode(); + TEST(currentScreenMode == newMode); + + User::LeaveIfError(screen->GetRotationsList(newMode,rotations)); + INFO_PRINTF4(_L("ScreenMode and rotation with colour depth. Mode#%i=%i. Rotations=%i"),ii,newMode,rotations->Count()); + TPixelsTwipsAndRotation currentModeSettings; + screen->GetDefaultScreenSizeAndRotation(currentModeSettings); + screen->SetScreenSizeAndRotation(currentModeSettings); + for (TInt jj=0,maxjj=rotations->Count();jjSetCurrentRotations(newMode,newOrientation); + TheClient->iWs.Flush(); + + TPixelsAndRotation modeSettings; + TheClient->iScreen->GetDefaultScreenSizeAndRotation(modeSettings); + TRect screenRect(TPoint(0,0),modeSettings.iPixelSize); + + //move the debug windows to inside the area + //actually don't bother yet! + if (screenRect.Width()>screenRect.Height()) + { + } + else + { + } + DeviceResSwitchL(); + } + screen->SetCurrentRotations(newMode,currentModeSettings.iRotation); + screen->SetScreenSizeAndRotation(currentModeSettings); + } + + CleanupStack::PopAndDestroy(); + screen->SetScreenMode(originalScreenMode); + screen->SetCurrentRotations(originalScreenMode,originalModeSettings.iRotation); + screen->SetScreenSizeAndRotation(originalModeSettings); + } + +/** + Intended primarily as a visual check that the mode is displayed correctly, + this code also verifies that the number of physical colours matches the reported mode. + Note that although written to test GCE, this test is general and applies to all display versions. +**/ +void CTScreenDeviceResSwitch::DeviceResSwitchL() + { + INFO_PRINTF1(_L("DeviceResSwitchL: Entering function")); + TInt error = KErrNone; + TInt isTransparencySupportedResult = KErrNone; + + TRAP(error, isTransparencySupportedResult = IsTransparencySupportedL()); + + if(error != KErrNone) + { + INFO_PRINTF1(_L("DeviceResSwitchL: Transparency is not supported. Exits.")); + return; + } + + TRAP(error, CalculateDisplayPropertiesL()); + + if(error != KErrNone) + { + INFO_PRINTF1(_L("DeviceResSwitchL: Could not calculate display properties. Test not supported. Exits.")); + return; + } + + TDisplayMode startDisplayMode = TheClient->iScreen->DisplayMode(); + TInt startColoursPixel = TDisplayModeUtils::NumDisplayModeColors(startDisplayMode); + + TPixelsAndRotation modeSettings; + TheClient->iScreen->GetDefaultScreenSizeAndRotation(modeSettings); + TRect r(TPoint(0, 0), modeSettings.iPixelSize); + + // Starts off full-screen. Only shrink it if it will still be large enough to run the test + // It should be... the test only needs 60x20 pixels + + if(r.Width() > r.Height()) + { + if(r.Width() > (CPrimaryColoursWin::kMinWidth) * (CPrimaryColoursWin::kShrinkFactor-2) * 3 / (CPrimaryColoursWin::kShrinkFactor * 2)) + { + r.iTl.iX = r.iBr.iX / 3; + } + } + else + { + if (r.Height() > (CPrimaryColoursWin::kMinHeight) * (CPrimaryColoursWin::kShrinkFactor - 2) * 3/ (CPrimaryColoursWin::kShrinkFactor * 2)) + { + r.iTl.iY = r.iBr.iY / 3; + } + } + if(r.Width() > (CPrimaryColoursWin::kMinWidth) * (CPrimaryColoursWin::kShrinkFactor - 2) / CPrimaryColoursWin::kShrinkFactor) + { + if(r.Height() > (CPrimaryColoursWin::kMinHeight) * (CPrimaryColoursWin::kShrinkFactor - 2) / CPrimaryColoursWin::kShrinkFactor) + { + r.Shrink(r.Width() / CPrimaryColoursWin::kShrinkFactor, r.Height() / CPrimaryColoursWin::kShrinkFactor); + } + } + + for(TInt i = 0; i < EColorLast; i++) + { + TDisplayMode tryMode = TDisplayMode(i); + TInt tryColoursPixel = NumDisplayModeColors(tryMode); + + INFO_PRINTF3(_L("DeviceResSwitchL: tryColoursPixel = %d, tryMode = %d"), tryColoursPixel, tryMode); + + if(TDisplayModeUtils::IsDisplayModeColor(tryMode) && startColoursPixel <= tryColoursPixel) + { + //Create a test window at this mode, and see if it changes the screen mode + { // The braces define the lifetime of testWin. It must be destroyed before we check if mode changed back successfully. + + CPrimaryColoursWin* testWin1 = new (ELeave) CPrimaryColoursWin; + CleanupStack::PushL(testWin1); + + TInt expectedColoursPerChannel = 1; + TInt tt; + + testWin1->SetUpL(r.iTl, r.Size(), TheClient->iGroup, *TheClient->iGc, &tryMode); + TheClient->iWs.Flush(); + TDisplayMode newDisplayMode = TheClient->iScreen->DisplayMode(); + + TEST(TDisplayModeUtils::NumDisplayModeColors(newDisplayMode) >= tryColoursPixel); + + if(!(TDisplayModeUtils::NumDisplayModeColors(newDisplayMode) >= tryColoursPixel)) + { + ERR_PRINTF3(_L("testWin1: newDisplayMode = %d, tryColoursPixel = %d"), newDisplayMode, tryColoursPixel); + } + + // Estimate the minimum number of shades of primary colours given the bits per pixel. + // The maximum is twice this. Very appoximate but seems to work OK for 256 colours. Probably not good for grey modes. + for(tt = tryColoursPixel; tt >= 8; tt >>= 3) + { + expectedColoursPerChannel <<= 1; + } + + // Draw some test data on the test window. + testWin1->DrawNow(); + TheClient->iWs.Flush(); + +#ifdef VISIBLE_PAUSES + TheClient->StdLogWindow().LogMessage(EFalse, _L("Mode: "), tryMode); + User::After(1000000); +#endif + TInt numUniqueColours = testWin1->CountUniquePlottedColours(); + INFO_PRINTF2(_L("testWin1: numUniqueColours = %d"), numUniqueColours); + testWin1->DrawNow(); + TheClient->StdLogWindow().LogMessage(EFalse, _L("Channel Colours: "), numUniqueColours); + TheClient->iWs.Flush(); + +#ifdef VISIBLE_PAUSES + User::After(1000000); +#endif + // Read it back and see if it has the expected quality + TEST(numUniqueColours >= (expectedColoursPerChannel * 3)); + + if(!(numUniqueColours >= (expectedColoursPerChannel * 3))) + { + ERR_PRINTF3(_L("testWin1: numUniqueColours = %d, (expectedColoursPerChannel * 3) = %d"), numUniqueColours, (expectedColoursPerChannel * 3)); + } + + /* + * Defect 107176 was rejected. This test for transparency is therefore removed. + * + */ + if (false) //newDisplayMode != startDisplayMode) // Hide the window under a startmode window and see if we switch back? + if (isTransparencySupportedResult==KErrNone && newDisplayMode != startDisplayMode) // Hide the window under a startmode window and see if we switch back? + /* + * Defect 107176 was rejected. This test for transparency is therefore removed. + * The crash demonstrated by this code is related to the inconsistant support for origin and scale + * See defect DEF111847 and break request 2226 + */ + if (false) //newDisplayMode != startDisplayMode) // Hide the window under a startmode window and see if we switch back? + { + // Demonstration of defect 107176 + // Create a translucent window which obscures the high-colour window + // The existing code reduces the display colour depth because it thinks the obscured window is not visible any more + // However, the obscured window is actually visible trough the transparency + CPrimaryColoursWin* testWin2 = new (ELeave) CPrimaryColoursWin; + CleanupStack::PushL(testWin2); + + testWin2->SetUpL(r.iTl - TPoint(20,20), r.Size() + TSize(40,40), TheClient->iGroup, *TheClient->iGc, &startDisplayMode, ETrue, 0x80); + TheClient->iWs.Flush(); + testWin2->DrawNow(); + TheClient->iWs.Flush(); + + TDisplayMode newnewDisplayMode = TheClient->iScreen->DisplayMode(); + TInt newNumUniqueColours = testWin2->CountUniquePlottedColours(); + INFO_PRINTF2(_L("testWin2: newNumUniqueColours = %d"), newNumUniqueColours); + + TEST(newnewDisplayMode == newDisplayMode); + + if(!(newnewDisplayMode == newDisplayMode)) + { + ERR_PRINTF3(_L("testWin2: newnewDisplayMode = %d, newDisplayMode = %d"), newnewDisplayMode, newDisplayMode); + } + + testWin2->DrawNow(); + TheClient->iWs.Flush(); + +#ifdef VISIBLE_PAUSES + User::After(1000000); +#endif + TheClient->iWs.Flush(); + + CleanupStack::PopAndDestroy(testWin2); + testWin2 = NULL; + } + + CleanupStack::PopAndDestroy(testWin1); + testWin1 = NULL; + } + + TDisplayMode afterDisplayMode = TheClient->iScreen->DisplayMode(); + TEST(afterDisplayMode == startDisplayMode); + + if(afterDisplayMode != startDisplayMode) + { + ERR_PRINTF3(_L("DeviceResSwitchL: Original colour depth not restored. Was %i, now %i (TDisplayMode)"), startDisplayMode, afterDisplayMode); + } + +#ifdef VISIBLE_PAUSES + User::After(1000000); +#endif + } // context + } // for loop ends + + INFO_PRINTF1(_L("DeviceResSwitchL: Returning from function")); + } + +void CTScreenDeviceResSwitch::CalculateDisplayPropertiesL() + { + INFO_PRINTF1(_L("CalculateDisplayPropertiesL: Entering function")); + + TDisplayMode tryMode = (TDisplayMode) (EColorLast - 1); + TPixelsAndRotation modeSettings; + TheClient->iScreen->GetDefaultScreenSizeAndRotation(modeSettings); + TRect r(TPoint(0, 0), modeSettings.iPixelSize); + + CPrimaryColoursWin* tempWin = new (ELeave) CPrimaryColoursWin; + CleanupStack::PushL(tempWin); + + tempWin->SetUpL(r.iTl, r.Size(), TheClient->iGroup, *TheClient->iGc, &tryMode); + TheClient->iWs.Flush(); + + iMaxDisplayMode = TheClient->iScreen->DisplayMode(); + INFO_PRINTF2(_L("CalculateDisplayPropertiesL: iMaxDisplayMode %d"), iMaxDisplayMode); + iMaxDisplayModeColors = TDisplayModeUtils::NumDisplayModeColors(iMaxDisplayMode); + INFO_PRINTF2(_L("CalculateDisplayPropertiesL: iMaxDisplayModeColors %d"), iMaxDisplayModeColors); + + CleanupStack::PopAndDestroy(tempWin); + INFO_PRINTF1(_L("CalculateDisplayPropertiesL: Returning from function")); + } + +TInt CTScreenDeviceResSwitch::NumDisplayModeColors(TDisplayMode aDispMode) + { + TInt dispModeColors = TDisplayModeUtils::NumDisplayModeColors(aDispMode); + + if(dispModeColors > iMaxDisplayModeColors) + { + return iMaxDisplayModeColors; + } + + return dispModeColors; + } + +TInt CTScreenDeviceResSwitch::IsTransparencySupportedL() + { + INFO_PRINTF1(_L("IsTransparencySupportedL: Entering function")); + // Creates a window and sets the transparency, if this feature + // is not enabled, KErrNotSupported will be returned + const TRgb KTransparencyColor(85,85,85); + RWindow win(TheClient->iWs); + win.Construct(*TheClient->iGroup->GroupWin(), ENullWsHandle); + win.SetExtent(TPoint(0,0), TSize(50,50)); + win.SetRequiredDisplayMode(EColor256); + TInt ret = win.SetTransparencyFactor(KTransparencyColor); + win.Close(); + + if(!ret) + { + INFO_PRINTF1(_L("IsTransparencySupportedL: Transparency is supported")); + } + else + { + INFO_PRINTF1(_L("IsTransparencySupportedL: Transparency is not supported")); + } + + INFO_PRINTF1(_L("IsTransparencySupportedL: Returning from function")); + return ret; + } + +void CTScreenDeviceResSwitch::RunTestCaseL(TInt /*aCurTestCase*/) + { + ((CTScreenDeviceResSwitchStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); + switch(++iTest->iState) + { +/** +@SYMTestCaseID GRAPHICS-WSERV-0440 + +@SYMDEF DEF107176 + +@SYMTestCaseDesc Intended primarily as a visual check that the mode is displayed correctly. Checks correct display mode is set. + The test also verifies that the number of physical colours matches the reported mode. + Note that although written to test GCE, this test is general and applies to all display versions. + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Creates a windows with a higher display mode. Then creates a transparent + window with lower display mode that completely covers the first window. + Checks the display mode is not changed to the lower diplay mode when + the higher display mode window is visible through transparency. + +@SYMTestExpectedResults The higher display mode should still be set after the second window is drawn. +*/ + case 1: + ((CTScreenDeviceResSwitchStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0440")); + iTest->LogSubTest(_L("Device resolution switching")); + DeviceResSwitchL(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0520 + +@SYMTestCaseDesc Test for device switching when mode increased. + +@SYMTestActions Windows are created in increasing modes and pixel colours written and read back. + This code verifies that the mode change actually takes place. + I am using this visually to verify that the new GCE is actually changing the mode. + +**/ + case 2: + ((CTScreenDeviceResSwitchStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0520")); + iTest->LogSubTest(_L("More device resolution switching")); + DeviceResSwitchWithRotationsL(); + break; + default: + ((CTScreenDeviceResSwitchStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + ((CTScreenDeviceResSwitchStep*)iStep)->CloseTMSGraphicsStep(); + TestComplete(); + } + ((CTScreenDeviceResSwitchStep*)iStep)->RecordTestResultL(); + } + +__WS_CONSTRUCT_STEP__(ScreenDeviceResSwitch) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TSCRDEVRESSWITCH.H --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TSCRDEVRESSWITCH.H Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,61 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef __TSCRDEVRESSWITCH_H__ +#define __TSCRDEVRESSWITCH_H__ + +#include +#include "w32std.h" +#include "../tlib/testbase.h" +#include "AUTO.H" +#include "TGraphicsHarness.h" + +class CTScreenDeviceResSwitch : public CTWsGraphicsBase + { +public: + CTScreenDeviceResSwitch(CTestStep* aStep); + ~CTScreenDeviceResSwitch(); + void ConstructL(); + void DeviceResSwitchL(); + void DeviceResSwitchWithRotationsL(); +protected: + virtual void RunTestCaseL(TInt aCurTestCase); +private: + TInt NumDisplayModeColors(TDisplayMode aDispMode); + void CalculateDisplayPropertiesL(); + TInt IsTransparencySupportedL(); +private: + TDisplayMode iMaxDisplayMode; + TInt iMaxDisplayModeColors; + }; + +class CTScreenDeviceResSwitchStep : public CTGraphicsStep + { +public: + CTScreenDeviceResSwitchStep(); +protected: + //from CTGraphicsStep + virtual CTGraphicsBase* CreateTestL(); + }; + +_LIT(KTScreenDeviceResSwitchStep,"TScreenDeviceResSwitch"); + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TSCREENMODEPOSITIONING.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TSCREENMODEPOSITIONING.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,1164 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Test code for screen mode positioning CR +// GT 0164 Uikon: A3.26. IM 9. +// Test code for the positioning part of Change Request PHAR-5SJGAM +// ("Enable screen mode positioning and scaling"). +// Note this feature is also in GT0199 as PREQ673"Screen Positioning". +// Tests screen position being configurable for a screen mode - +// eg it is now possible to set in wsini.ini the position on the +// physical screen where the origin of the screen mode's screen will appear. +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include "TSCREENMODEPOSITIONING.H" +#include + +//#define LOGGING on //Uncomment this line to get extra logging useful when there is a tests that fails + +LOCAL_D TSize FullScreenModeSize; +LOCAL_D TDisplayMode ScreenDisplayMode; +LOCAL_D TInt Copy2ndHalfOfScreen; + + +void CBasicWin::Draw() + { + iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + iGc->SetPenStyle(CGraphicsContext::ENullPen); + iGc->SetBrushColor(TRgb(255,0,0)); + TSize winSize=Size(); + iGc->DrawRect(TRect(winSize)); + iGc->SetBrushColor(TRgb(0,221,221)); + iGc->DrawEllipse(TRect(TPoint(winSize.iWidth/2,winSize.iHeight/2),winSize)); + iGc->DrawEllipse(TRect(TPoint(-winSize.iWidth/2,-winSize.iHeight/2),winSize)); + iDrawn=ETrue; + } + +void CSpriteWin::UpdateState(TInt aState) + { + SetState(aState); + DrawNow(); + } + +TPoint CheckSpritePos(233,60); +TPoint CheckSpritePos2(18,60); + +void CSpriteWin::Draw() + { + switch(iState) + { + case 0: + iGc->BitBlt(CheckSpritePos,&iSpriteBitmap); + break; + case 1: + iGc->BitBlt(CheckSpritePos+TPoint(30,30),&iSpriteBitmap); + iGc->BitBlt(CheckSpritePos,&iSpriteBitmap); + break; + case 2: + iGc->BitBlt(CheckSpritePos2+TPoint(-10,40),&iSpriteBitmap); + iGc->BitBlt(CheckSpritePos2+TPoint(-10,20),&iSpriteBitmap); + break; + case 3: + iGc->BitBlt(TPoint(),&iSpriteBitmap); + break; + default: + break; + } + } + +CSpriteWin::~CSpriteWin() + { + } + +void CBmpWin::Draw() + { + iGc->BitBlt(TPoint(),&iScreenBmp); + } + +CConnection2::~CConnection2() + { + delete iScreenBitmap; + delete iBitmapWin; + delete iSpriteWin; + iGroup->GroupWin()->EnableReceiptOfFocus(EFalse); + delete iGroup; + delete iClient; + } + +void CConnection2::ConstructL(CTestBase *aTest,CFbsBitmap& aBitmap) + { + iClient=new(ELeave) CTClient; + iClient->SetScreenNumber(aTest->ScreenNumber()); + iClient->ConstructL(); + iGroup=new(ELeave) CConnection2Group(iClient,this,aTest); + iGroup->ConstructL(); + iGroup->GroupWin()->EnableScreenChangeEvents(); + iClient->Flush(); + iSpriteWin=new(ELeave) CSpriteWin(aBitmap); + iSpriteWin->ConstructExtLD(*iGroup,TPoint(),TSize(433,240)); + User::LeaveIfError(iSpriteWin->BaseWin()->SetRequiredDisplayMode(EColor256)); + iSpriteWin->AssignGC(*iClient->iGc); + iSpriteWin->Activate(); + iSpriteWin->SetVisible(EFalse); + iSpriteWin->BaseWin()->SetShadowDisabled(ETrue); + iSpriteWin->BaseWin()->SetShadowHeight(0); + iScreenBitmap=new(ELeave) CFbsBitmap(); + User::LeaveIfError(iScreenBitmap->Create(TSize(FullScreenModeSize.iWidth/2,FullScreenModeSize.iHeight), ScreenDisplayMode)); + iBitmapWin=new(ELeave) CBmpWin(*iScreenBitmap); + iBitmapWin->ConstructExtLD(*iGroup,TPoint(FullScreenModeSize.iWidth/2,0),iScreenBitmap->SizeInPixels()); + User::LeaveIfError(iBitmapWin->BaseWin()->SetRequiredDisplayMode(EColor256)); + iBitmapWin->AssignGC(*iClient->iGc); + iBitmapWin->Activate(); + iBitmapWin->SetVisible(EFalse); + iBitmapWin->BaseWin()->SetShadowDisabled(ETrue); + iBitmapWin->BaseWin()->SetShadowHeight(0); + } + +void CConnection2::DrawBitmapWin() + { + TPoint pos=(Copy2ndHalfOfScreen? TPoint() : TPoint(FullScreenModeSize.iWidth/2,0)); + iBitmapWin->SetPos(pos); + iBitmapWin->SetVisible(ETrue); + iBitmapWin->DrawNow(); + iClient->Flush(); + } + +CConnection2Group::CConnection2Group(CTClient *aClient, CConnection2 *aSecondConnection, CTestBase *aTest) : CTWindowGroup(aClient), iTest(aTest), iConnection2(aSecondConnection) + {} + + + + +//CTScreenModePositioning +CTScreenModePositioning::CTScreenModePositioning(CTestStep* aStep) : CTWsGraphicsBase(aStep) + { + } + + +CTScreenModePositioning::~CTScreenModePositioning() + { + delete iTestWin; + delete iConnection2; + delete iBlankWin; + delete iBackedUpWin; + delete iTestChildWin; + } + +void CTScreenModePositioning::ConstructL() + { + User::LeaveIfError(iSpriteBitmap.Load(TEST_BITMAP_NAME,0)); + iScalingSupported=CheckScalingSupportedOrNot(); + TheClient->iScreen->SetScreenMode(TheClient->iScreenModes[0]); + FullScreenModeSize=TheClient->iScreen->SizeInPixels(); + ScreenDisplayMode=TheClient->iScreen->DisplayMode(); + iConnection2=new(ELeave) CConnection2; + iConnection2->ConstructL(iTest,iSpriteBitmap); + iBlankWin=new(ELeave) CTBlankWindow(); + iBlankWin->ConstructL(*TheClient->iGroup); + User::LeaveIfError(iBlankWin->BaseWin()->SetRequiredDisplayMode(EColor256)); + iBlankWin->SetExt(TPoint(),FullScreenModeSize); + iBlankWin->SetVisible(EFalse); + iBlankWin->Activate(); + iTestWin=new(ELeave) CBasicWin; + iTestWin->ConstructExtLD(*TheClient->iGroup,TPoint(),FullScreenModeSize); + User::LeaveIfError(iTestWin->BaseWin()->SetRequiredDisplayMode(EColor256)); + iTestWin->AssignGC(*TheClient->iGc); + iTestWin->BaseWin()->SetShadowDisabled(ETrue); + iTestWin->BaseWin()->SetShadowHeight(0); + iTestWin->SetVisible(EFalse); + iTestWin->Activate(); + iBackedUpWin=new(ELeave) CTBackedUpWin(EColor256); + iBackedUpWin->ConstructExtLD(*iTestWin,TPoint(),FullScreenModeSize); + iBackedUpWin->SetVisible(EFalse); + iBackedUpWin->Activate(); + iTestChildWin=new(ELeave) CTBlankWindow(); + iTestChildWin->ConstructL(*iTestWin); + User::LeaveIfError(iTestChildWin->BaseWin()->SetRequiredDisplayMode(EColor256)); + iTestChildWin->BaseWin()->SetShadowDisabled(ETrue); + iTestChildWin->SetColor(KRgbGreen); + iTestChildWin->BaseWin()->SetVisible(EFalse); + iTestChildWin->Activate(); + //The Cursor appearing on screen will affect the result of RectCompare function. + //Set it to the position out of the screen + TheClient->iWs.SetPointerCursorPosition(TPoint(-1,-1)); + } + +void CTScreenModePositioning::ChangeScreenMode(CTClient* aClient,TPixelsAndRotation aPixelsAndRotation,TInt aMode) + { + ChangeScreenMode(aClient,aPixelsAndRotation,ESizeEnforcementNone,aMode); + } + +void CTScreenModePositioning::ChangeScreenMode(CTClient* aClient,TPixelsAndRotation aPixelsAndRotation,TScreenModeEnforcement aScreenModeEnforcement,TInt aMode) + { + aClient->iScreen->SetScreenSizeAndRotation(aPixelsAndRotation); + aClient->iScreen->SetScreenModeEnforcement(aScreenModeEnforcement); + aClient->iScreen->SetScreenMode(aMode); + } + +void CTScreenModePositioning::SetScreenMode(CTClient* aClient,TInt aMode,TScreenModeEnforcement aScreenModeEnforcement) + { + TPixelsAndRotation pixelsAndRotation; + aClient->iScreen->SetScreenModeEnforcement(aScreenModeEnforcement); + aClient->iScreen->SetScreenMode(aMode); + aClient->iScreen->GetDefaultScreenSizeAndRotation(pixelsAndRotation); + aClient->iScreen->SetScreenSizeAndRotation(pixelsAndRotation); + aClient->Flush(); + } + +void CTScreenModePositioning::SetUpSpriteLC(RWsSprite &aSprite, RWsSession &aSession, RWindowTreeNode &aWindow,TInt aFlags) + { + aSprite=RWsSprite(aSession); + User::LeaveIfError(aSprite.Construct(aWindow,TPoint(),aFlags)); + CleanupClosePushL(aSprite); + TSpriteMember member; + iTest->SetUpMember(member); + member.iBitmap=&iSpriteBitmap; + User::LeaveIfError(aSprite.AppendMember(member)); + User::LeaveIfError(aSprite.Activate()); + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-0098 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Window Tests. Please see test cases GRAPHICS-WSERV-(0099-0103) which are a subset of this test case. + REQUIREMENT: CR PHAR-5SJGAM, PREQ673 + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Tests on windows in different screen modes each with differing screen mode origin's defined in the + wsini file. This test case only tests screen modes with 0 orientation. + Goes through each screen mode defined in the wsini file and exercises test cases GRAPHICS-WSERV-(0099-0103) for each mode. + For more details see test cases GRAPHICS-WSERV-(0099-0103) which are a subset of this test case. + +@SYMTestExpectedResults + +*/ +void CTScreenModePositioning::WindowTestsL() + { + TheClient->iGroup->GroupWin()->EnableScreenChangeEvents(); + TInt numOfModes=TheClient->iScreenModes.Count(); + TInt ii; + for (ii=0; iiiScreenModes[ii]; + TPixelsAndRotation pixelsAndRotation; + iCurrentScreenModeOrigin=TheClient->iScreen->GetScreenModeScaledOrigin(iCurrentMode); + iCurrentScreenModeScale=TheClient->iScreen->GetScreenModeScale(iCurrentMode); + TheClient->iScreen->GetScreenModeSizeAndRotation(iCurrentMode,pixelsAndRotation); + iCurrentScreenModeSize=pixelsAndRotation.iPixelSize; + if (iCurrentScreenModeOrigin.iX<=FullScreenModeSize.iWidth/2-10 /*&& iCurrentScreenModeOrigin!=TPoint() */&& pixelsAndRotation.iRotation==CFbsBitGc::EGraphicsOrientationNormal) + { + #if defined(LOGGING) + _LIT(KLog,"Test mode %d"); + LOG_MESSAGE2(KLog,ii); + #endif + TRAPD(ret,DoWindowTestsL()); + if (ret==KErrNone) + continue; + RestoreScreenMode(); + if (retSetVisible(ETrue); + Copy2ndHalfOfScreen=(iCurrentScreenModeOrigin.iX>FullScreenModeSize.iWidth/2? 1 : 0); + TInt testWinWidth=Max(FullScreenModeSize.iWidth/2-iCurrentScreenModeOrigin.iX,iCurrentScreenModeOrigin.iX-FullScreenModeSize.iWidth/2); + iTestWinSize=TSize(testWinWidth,FullScreenModeSize.iHeight-iCurrentScreenModeOrigin.iY-60); + iTestWinSize.iWidth/=(iCurrentScreenModeScale.iWidth > 1 ? iCurrentScreenModeScale.iWidth*2 : iCurrentScreenModeScale.iWidth); + iTestWinSize.iHeight/=(iCurrentScreenModeScale.iHeight > 1 ? iCurrentScreenModeScale.iHeight*2 : iCurrentScreenModeScale.iHeight); +#if defined(LOGGING) + _LIT(KLog1," PosTest1"); + LOG_MESSAGE(KLog1); +#endif + PositionTest1L(TPoint()); +#if defined(LOGGING) + _LIT(KLog2," PosTest2"); + LOG_MESSAGE(KLog2); +#endif + PositionTest1L(TPoint(25,35)); +#if defined(LOGGING) + _LIT(KLog3," PosTest3"); + LOG_MESSAGE(KLog3); +#endif + PositionTest2L(TPoint(10,10)); +#if defined(LOGGING) + _LIT(KLog4," GetInvalidRegion"); + LOG_MESSAGE(KLog4); +#endif + GetInvalidRegionTestL(TPoint(10,10)); +#if defined(LOGGING) + _LIT(KLog5," CreateWin1"); + LOG_MESSAGE(KLog5); +#endif + CreateWindowsTestL(TPoint()); +#if defined(LOGGING) + _LIT(KLog6," CreateWin2"); + LOG_MESSAGE(KLog6); +#endif + CreateWindowsTestL(TPoint(33,15)); +#if defined(LOGGING) + _LIT(KLog7," NextMode"); + LOG_MESSAGE(KLog7); +#endif + NextScreenModeTestL(TPoint(12,6)); + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-0099 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Position Test 1 + REQUIREMENT: CR PHAR-5SJGAM, PREQ673 + API: RWindowBase::InquireOffset(), RWindowBase::AbsPosition(),RWindowBase::Position() + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Sets the new screen mode on the main client's screen device. Checks that an window whose group window + has this screen device is in the correct position and for the origin of the new screen mode. + (Does this by copying the window to a bitmap, switching back to screen mode 0 and then setting the position + of the window to be the expected position. Then the bitmap is blitted to the other half of the screen and the + 2 halves of the screen compared) + +@SYMTestExpectedResults Checks the window is positioned correctly for the origin of the new screen mode. + +*/ +void CTScreenModePositioning::PositionTest1L(TPoint aPos) + { + ((CTScreenModePositioningStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0099")); + SetScreenMode(TheClient,iCurrentMode,ESizeEnforcementPixelsAndRotation); + iTestWin->SetExt(aPos,iTestWinSize); + iTestWin->SetVisible(ETrue); + iTestWin->Invalidate(); + TheClient->Flush(); + TestTopClientWindowPositionAPIs(aPos,iTestWin->BaseWin()); + TheClient->WaitForRedrawsToFinish(); + CopyAndCompareL(aPos); + ((CTScreenModePositioningStep*)iStep)->RecordTestResultL(); + } + +template +class TCleanupSetVisible:public TCleanupItem + { + static void Cleanup(void*v) + { + ((CTWinBase*)v)[0].SetVisible(newstate); + } + public: + TCleanupSetVisible(CTWinBase* v): + TCleanupItem(Cleanup,v) + {} + }; + + +/** +@SYMTestCaseID GRAPHICS-WSERV-0100 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Position Test 2 + REQUIREMENT: CR PHAR-5SJGAM, PREQ673 + API: RWindowBase::SetPosition(),RWindowBase::InquireOffset(), RWindowBase::AbsPosition(),RWindowBase::Position() + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions As in test case GRAPHICS-WSERV-0099 but also tests moving and resizing the window and also does these tests on a backed up child window. + +@SYMTestExpectedResults Checks both the windows are positioned correctly for the origin of the new screen mode. + +*/ +void CTScreenModePositioning::PositionTest2L(TPoint aPos) + { + ((CTScreenModePositioningStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0100")); + SetScreenMode(TheClient,iCurrentMode,ESizeEnforcementPixelsAndRotation); + iTestWin->SetPos(aPos); + + CleanupStack::PushL(TCleanupSetVisible(iBackedUpWin)); + iTestWin->SetVisible(ETrue); + TestTopClientWindowPositionAPIs(aPos,iTestWin->BaseWin()); + TPoint backedUpWinPt=TPoint(iTestWinSize.iWidth/3,iTestWinSize.iHeight/4); + iBackedUpWin->SetExtL(backedUpWinPt,TSize(iTestWinSize.iWidth/6,iTestWinSize.iHeight/6)); + iBackedUpWin->SetVisible(ETrue); + TestChildWindowPositionAPIs(backedUpWinPt,aPos,iBackedUpWin->BaseWin(),iTestWin->BaseWin()); + aPos+=TPoint(20,20); + iTestWin->SetPos(aPos); + TestTopClientWindowPositionAPIs(aPos,iTestWin->BaseWin()); + TestChildWindowPositionAPIs(backedUpWinPt,aPos,iBackedUpWin->BaseWin(),iTestWin->BaseWin()); + iTestWin->Invalidate(); + TheClient->Flush(); + TheClient->WaitForRedrawsToFinish(); + TestTopClientWindowPositionAPIs(aPos,iTestWin->BaseWin()); + TestChildWindowPositionAPIs(backedUpWinPt,aPos,iBackedUpWin->BaseWin(),iTestWin->BaseWin()); + CopyAndCompareL(aPos); + CleanupStack::PopAndDestroy(iBackedUpWin); //TCleanupSetVisible + ((CTScreenModePositioningStep*)iStep)->RecordTestResultL(); + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-0101 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Invalid Region Test + REQUIREMENT: CR PHAR-5SJGAM, PREQ673 + API: RWindow::GetInvalidRegion() + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Sets the new screen mode, then invalidates different parts of the test window. Checks that the above API gets + the correct invalid area from the server. Also tests moving the invalid area. + +@SYMTestExpectedResults Checks the invalid region is correct for the origin of the new screen mode. + +*/ +void CTScreenModePositioning::GetInvalidRegionTestL(TPoint aPos) + { + ((CTScreenModePositioningStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0101")); + SetScreenMode(TheClient,iCurrentMode,ESizeEnforcementPixelsAndRotation); + iTestWin->SetExt(aPos,iTestWinSize); + iTestWin->SetVisible(ETrue); + iTestChildWin->SetExt(TPoint(iTestWinSize.iWidth>>2,iTestWinSize.iHeight>>2),TSize(iTestWinSize.iWidth>>1,iTestWinSize.iHeight>>1)); + iTestChildWin->SetVisible(ETrue); + iTestWin->Win()->BeginRedraw(); + iTestWin->Win()->EndRedraw(); + const TInt KNumRects=3; + TRect rects[KNumRects]; + rects[0]=TRect(1,1,5,2); + rects[1]=TRect(TPoint(iTest->StdTestWindowSize().iWidth>>1,iTest->StdTestWindowSize().iHeight>>1),iTest->StdTestWindowSize()); + rects[2]=TRect(2,0,4,5); + RRegion region; + CleanupClosePushL(region); + for (TInt index=0;indexInvalidate(rects[index]); + region.AddRect(rects[index]); + } + //PeterI original wserv assumes a region hidden beneath a child is not invalid + //Mk3 doesn't make this assumption + //TRect subRect; + //subRect.iTl=iTestChildWin->BaseWin()->InquireOffset(*iTestWin->BaseWin()); + //subRect.SetSize(iTestChildWin->Size()); + //region.Tidy(); + //region.SubRect(subRect); + //region.ClipRect(TRect(iTestWin->Size())); + RRegion invalidRegion; + CleanupClosePushL(invalidRegion); + iTestWin->Win()->GetInvalidRegion(invalidRegion); + CompareRegionsL(region,invalidRegion); + CleanupStack::PopAndDestroy(2,®ion); + TheClient->Flush(); + TheClient->WaitForRedrawsToFinish(); + iTestChildWin->SetVisible(EFalse); + TRect rect1(TPoint(0,0),iTestWinSize); + TestGetInvalidRegionL(rect1); + TInt width=iTestWinSize.iWidth; + TInt height=iTestWinSize.iHeight; + TRect rect2(TPoint(width/6,height/6),TSize(width/3,height/3)); + TestGetInvalidRegionL(rect2); + iTestWin->Invalidate(); + iTestWin->SetPos(TPoint(15,15)); + iTestWin->SetPos(TPoint()); + iTestWin->SetPos(TPoint(-15,-15)); + iTestWin->SetPos(aPos); + RRegion invalid; + RRegion testRegion(rect1); + CleanupClosePushL(invalid); + CleanupClosePushL(testRegion); + iTestWin->Win()->GetInvalidRegion(invalid); + TBool err=invalid.CheckError(); + TEST(!err); + if (err) + { + _LIT(KLog,"Returned Invalid Region has an error"); + LOG_MESSAGE(KLog); + } + + TEST(invalid.BoundingRect().iBr.iX<=iTestWinSize.iWidth); + if (invalid.BoundingRect().iBr.iX>iTestWinSize.iWidth) + { + _LIT(KLog,"Invalid Region extends beyond right edge of window"); + LOG_MESSAGE(KLog); + } + + CompareRegionsL(testRegion,invalid); + CleanupStack::PopAndDestroy(2,&invalid); + iTestWin->DrawNow(); + TheClient->Flush(); + CopyAndCompareL(aPos); + ((CTScreenModePositioningStep*)iStep)->RecordTestResultL(); + } + +void CTScreenModePositioning::CopyAndCompareL(TPoint aPos) + { + CopyScreenAndChangeBackToDefScrModeL(); + iTestWin->SetPos(iCurrentScreenModeOrigin+aPos); + iConnection2->DrawBitmapWin(); + TheClient->WaitForRedrawsToFinish(); + TestRect(); + iConnection2->BitmapWin()->SetVisible(EFalse); + iTestWin->SetVisible(EFalse); + } + +void CTScreenModePositioning::TestGetInvalidRegionL(TRect& aRect) + { + RRegion testRegion; + RRegion invalid; + iTestWin->Invalidate(aRect); + testRegion.AddRect(aRect); + iTestWin->Win()->GetInvalidRegion(invalid); + CompareRegionsL(testRegion,invalid); + invalid.Close(); + testRegion.Close(); + TheClient->Flush(); + TheClient->WaitForRedrawsToFinish(); + } + +void CTScreenModePositioning::CompareRegionsL(const TRegion &aRegion1,const TRegion &aRegion2) + { + _LIT(KLog,"Regions do not contain same area."); + RRegion tmp; + tmp.Copy(aRegion1); + tmp.SubRegion(aRegion2); + if (tmp.CheckError()) + User::Leave(KErrNoMemory); + TBool retVal1=tmp.IsEmpty(); + TEST(retVal1); + if (!retVal1) + LOG_MESSAGE(KLog); + + tmp.Copy(aRegion2); + tmp.SubRegion(aRegion1); + if (tmp.CheckError()) + User::Leave(KErrNoMemory); + TBool retVal2=tmp.IsEmpty(); + TEST(retVal2); + if (!retVal2 && retVal1) + LOG_MESSAGE(KLog); + + tmp.Close(); + } + +void CTScreenModePositioning::TestTopClientWindowPositionAPIs(TPoint aPos,RWindowBase* aWin) + { + TEST(aWin->AbsPosition()==aPos); + TEST(aWin->Position()==aPos); + TEST(aWin->InquireOffset(*TheClient->iGroup->GroupWin())==aPos); + } + +void CTScreenModePositioning::TestChildWindowPositionAPIs(TPoint aPos,TPoint aParentPos,RWindowBase* aWin,RWindowBase* aParentWin) + { + TEST(aWin->AbsPosition()==aParentPos+aPos); + TEST(aWin->Position()==aPos); + TEST(aWin->InquireOffset(*TheClient->iGroup->GroupWin())==aParentPos+aPos); + TEST(aWin->InquireOffset(*aParentWin)==aPos); + } + +void CTScreenModePositioning::RestoreScreenMode() + { + TPixelsAndRotation pixelsAndRotation; + pixelsAndRotation.iPixelSize=FullScreenModeSize; + TheClient->iScreen->GetDefaultScreenSizeAndRotation(pixelsAndRotation); + ChangeScreenMode(TheClient,pixelsAndRotation,ESizeEnforcementNone,TheClient->iScreenModes[0]); + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-0102 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Create Windows Test + REQUIREMENT: CR PHAR-5SJGAM, PREQ673 + API: RWindowBase::SetPosition(),RWindowBase::InquireOffset(), RWindowBase::AbsPosition(),RWindowBase::Position() + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions As in test case GRAPHICS-WSERV-0100 but tests windows that are created in the new screen mode. Also tests moving and resizing these windows + +@SYMTestExpectedResults Checks both the windows are positioned correctly for the origin of the new screen mode. + +*/ +void CTScreenModePositioning::CreateWindowsTestL(TPoint aPos) + { + ((CTScreenModePositioningStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0102")); + SetScreenMode(TheClient,iCurrentMode,ESizeEnforcementPixelsAndRotation); + CBasicWin* basicWin=new(ELeave) CBasicWin; + basicWin->ConstructExtLD(*TheClient->iGroup,aPos,iTestWinSize); + CleanupStack::PushL(basicWin); + TInt mode=basicWin->BaseWin()->SetRequiredDisplayMode(EColor256); + basicWin->AssignGC(*TheClient->iGc); + basicWin->BaseWin()->SetShadowDisabled(ETrue); + basicWin->BaseWin()->SetShadowHeight(0); + basicWin->Activate(); + TheClient->Flush(); + TheClient->WaitForRedrawsToFinish(); + TestTopClientWindowPositionAPIs(aPos,basicWin->BaseWin()); + CTBlankWindow* blankChildWin=new(ELeave) CTBlankWindow ; + CleanupStack::PushL(blankChildWin); + blankChildWin->ConstructL(*basicWin); + blankChildWin->BaseWin()->SetRequiredDisplayMode(EColor256); + blankChildWin->BaseWin()->SetShadowDisabled(ETrue); + blankChildWin->SetColor(KRgbYellow); + TPoint childPos(iTestWinSize.iWidth/4,iTestWinSize.iHeight/4); + blankChildWin->SetExtL(childPos,TSize(iTestWinSize.iWidth/2,iTestWinSize.iHeight/2)); + blankChildWin->Activate(); + TheClient->Flush(); + TheClient->WaitForRedrawsToFinish(); + TestChildWindowPositionAPIs(childPos,aPos,blankChildWin->BaseWin(),basicWin->BaseWin()); + blankChildWin->SetPos(TPoint(-15,-20)); + TheClient->Flush(); + basicWin->DrawNow(); + TestChildWindowPositionAPIs(TPoint(-15,-20),aPos,blankChildWin->BaseWin(),basicWin->BaseWin()); + CopyScreenAndChangeBackToDefScrModeL(); + basicWin->SetPos(iCurrentScreenModeOrigin+aPos); + iConnection2->DrawBitmapWin(); + TheClient->WaitForRedrawsToFinish(); + TestRect(); + iConnection2->BitmapWin()->SetVisible(EFalse); + iTestWin->SetVisible(EFalse); + CleanupStack::PopAndDestroy(blankChildWin); + CleanupStack::PopAndDestroy(basicWin); + ((CTScreenModePositioningStep*)iStep)->RecordTestResultL(); + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-0103 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Changing to next screen mode + REQUIREMENT: CR PHAR-5SJGAM, PREQ673 + API: RWindowBase::SetPosition(),RWindowBase::InquireOffset(), RWindowBase::AbsPosition(),RWindowBase::Position() + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Sets the new screen mode, creates a new child window and then changes to the next screen mode with non-zero origin, + checks windows are in the expected position for the origin of the new screen mode. + +@SYMTestExpectedResults Checks both the windows are positioned correctly for the origin of the new screen mode. + +*/ +void CTScreenModePositioning::NextScreenModeTestL(TPoint aPos) + { + ((CTScreenModePositioningStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0103")); + if (iCurrentScreenModeOrigin==TPoint()) + { + return; + } + TInt numOfModes=TheClient->iScreenModes.Count(); + TInt defaultMode=TheClient->iScreenModes[0]; + TInt lastMode=TheClient->iScreenModes[numOfModes-1]; + TInt mode=(iCurrentModeiScreenModes[ii]) + { + modeIdx=ii; + break; + } + } + TPoint screenModeOrigin(0,0); + TPixelsAndRotation pixelsAndRotation; + while (screenModeOrigin==TPoint()||(pixelsAndRotation.iRotation!=CFbsBitGc::EGraphicsOrientationNormal)) + { + mode=(mode==lastMode? defaultMode : TheClient->iScreenModes[++modeIdx]); + if (mode==iCurrentMode) + { + return; + } + else if (mode==lastMode) + { + modeIdx=0; + } + screenModeOrigin=TheClient->iScreen->GetScreenModeOrigin(mode); + TheClient->iScreen->GetScreenModeSizeAndRotation(mode,pixelsAndRotation); + } + SetScreenMode(TheClient,iCurrentMode,ESizeEnforcementPixelsAndRotation); + iTestWin->SetExt(aPos,iTestWinSize); + iTestWin->SetVisible(ETrue); + TheClient->Flush(); + CBasicWin* basicWin=new(ELeave) CBasicWin; + CleanupStack::PushL(basicWin); + basicWin->ConstructExtLD(*iTestWin,TPoint(),TSize(iTestWinSize.iWidth/5,iTestWinSize.iHeight/5)); + User::LeaveIfError(basicWin->BaseWin()->SetRequiredDisplayMode(EColor256)); + basicWin->AssignGC(*TheClient->iGc); + basicWin->BaseWin()->SetShadowDisabled(ETrue); + basicWin->BaseWin()->SetShadowHeight(0); + basicWin->Activate(); + TPoint pos(iTestWinSize.iWidth/3,iTestWinSize.iWidth/4); + basicWin->SetPos(pos); + TheClient->Flush(); + TheClient->WaitForRedrawsToFinish(); + TestChildWindowPositionAPIs(pos,aPos,basicWin->BaseWin(),iTestWin->BaseWin()); + iCurrentScreenModeScale=TheClient->iScreen->GetScreenModeScale(mode); + iCurrentScreenModeOrigin=TheClient->iScreen->GetScreenModeOrigin(mode); + iTestWinSize.iWidth/=(iCurrentScreenModeScale.iWidth > 1 ? iCurrentScreenModeScale.iWidth*2 : iCurrentScreenModeScale.iWidth); + iTestWinSize.iHeight/=(iCurrentScreenModeScale.iHeight > 1 ? iCurrentScreenModeScale.iHeight*2 : iCurrentScreenModeScale.iHeight); + iTestWin->SetExt(aPos,iTestWinSize); + SetScreenMode(TheClient,mode,ESizeEnforcementPixelsAndRotation); + CopyScreenAndChangeBackToDefScrModeL(); + iTestWin->SetPos(aPos+iCurrentScreenModeOrigin); + basicWin->SetPos(pos); + iConnection2->DrawBitmapWin(); + TestRect(); + iConnection2->BitmapWin()->SetVisible(EFalse); + iTestWin->SetVisible(EFalse); + CleanupStack::PopAndDestroy(basicWin); + iCurrentScreenModeOrigin=TheClient->iScreen->GetScreenModeOrigin(iCurrentMode); + ((CTScreenModePositioningStep*)iStep)->RecordTestResultL(); + } + +void CTScreenModePositioning::CopyScreenAndChangeBackToDefScrModeL() + { + // clear the content of bitmap before it is used for copying + ClearBitmap(iConnection2->iScreenBitmap); + + // Copy the current content of the screen before moving to screen sizemode 0. + if (!iScalingSupported) + { + TPoint pt=(Copy2ndHalfOfScreen? TPoint(FullScreenModeSize.iWidth/2,0) : TPoint()); + User::LeaveIfError(iConnection2->iClient->iScreen->CopyScreenToBitmap(iConnection2->iScreenBitmap,TRect(pt,TSize(FullScreenModeSize.iWidth/2,FullScreenModeSize.iHeight)))); + } + else + { + TPoint pt=(Copy2ndHalfOfScreen? TPoint((iCurrentScreenModeSize.iWidth+iCurrentScreenModeOrigin.iX)/2,0) : -iCurrentScreenModeOrigin); + TPoint ptBottom(FullScreenModeSize.iWidth/2,FullScreenModeSize.iHeight); + ptBottom-=iCurrentScreenModeOrigin; + ptBottom.iX=(ptBottom.iX>=0 ? ptBottom.iX/iCurrentScreenModeScale.iWidth : ((-ptBottom.iX)*iCurrentScreenModeScale.iWidth+ptBottom.iX)/iCurrentScreenModeScale.iWidth+ptBottom.iX); + ptBottom.iY=(ptBottom.iY>=0 ? ptBottom.iY/iCurrentScreenModeScale.iHeight : ((-ptBottom.iY)*iCurrentScreenModeScale.iHeight+ptBottom.iY)/iCurrentScreenModeScale.iHeight+ptBottom.iY); + User::LeaveIfError(iConnection2->iClient->iScreen->CopyScreenToBitmap(iConnection2->iScreenBitmap,TRect(pt,ptBottom))); + } + TheClient->Flush(); + SetScreenMode(TheClient,TheClient->iScreenModes[0],ESizeEnforcementPixelsAndRotation); + TPixelsAndRotation dummySize; + dummySize.iPixelSize=TSize(0,0); + iConnection2->iClient->iScreen->SetScreenSizeAndRotation(dummySize); //to force an update in the server when we do the next line + TPixelsAndRotation pixelsAndRotation; + TheClient->iScreen->GetDefaultScreenSizeAndRotation(pixelsAndRotation); + iConnection2->iClient->iScreen->SetScreenSizeAndRotation(pixelsAndRotation); + iConnection2->iClient->iScreen->SetScreenModeEnforcement(ESizeEnforcementPixelsAndRotation); + iConnection2->iClient->iScreen->SetScreenMode(TheClient->iScreenModes[0]); + } + +TBool CTScreenModePositioning::TestRect() + { + TSize size(FullScreenModeSize.iWidth/2,FullScreenModeSize.iHeight); + TRect right(TPoint(FullScreenModeSize.iWidth/2,0),size); + TBool retVal=TheClient->iScreen->RectCompare(TRect(size),right); +// User::After(2000000); + //Let the pixels cool down for a bit + User::After(10); + TEST(retVal); + if(!retVal) + { + _LIT(KLog,"Left and Right halves of display don't match. RightHalf=(%d,%d,%d,%d)"); + LOG_MESSAGE5(KLog,right.iTl.iX,right.iTl.iY,right.iBr.iX,right.iBr.iY); + } + return retVal; + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-0104 + +@SYMDEF DEF081259, DEF111847 + +@SYMTestCaseDesc Sprite Tests + REQUIREMENT: CR PHAR-5SJGAM, PREQ673 + API: RWsSprite::SetPosition() + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Test sprites associated with group windows in screen modes with non-zero origin: + Sets such a new screen mode and creates 2 sprites. + compares these sprites with some blitted onto the screen in the expected position. + Sets the rotation of screen mode to be 180 deg, sets the position of the sprites + and does the same as above to compare expected position. + Then changes back to screen mode 0 and sets a new positions of the sprites,changes to the new + screen mode and checks the sprites have been moved to the correct position. + Additionally, as part of defect fix DEF111847, this also loops through all display modes above and including Color256, + and if possible tests each with the above described method. Previously, it use to only test Color256. + Display modes lower than EColor256 are not tested as they are not supported for origin change. + +@SYMTestExpectedResults Checks the sprites are positioned correctly according to the origin + of the new screen mode. + +*/ +void CTScreenModePositioning::SpriteTestL() + { + +#if defined(__WINS__) + TBool retVal; + if (iScalingSupported) + { + TDisplayMode curDispMode; // Holds the current display mode being tested + + for(curDispMode = EColor256; curDispMode < EColorLast; curDispMode = TDisplayMode(curDispMode+1)) + { + if (curDispMode == ERgb) + { + continue; + } + // Set screen mode to 3 + iCurrentMode=3; + SetScreenMode(TheClient,iCurrentMode,ESizeEnforcementPixelsAndRotation); + TPoint topLeft(-TheClient->iScreen->GetScreenModeOrigin(iCurrentMode)); + TPoint botRight(TheClient->iScreen->SizeInPixels().AsPoint()); + + // Create a sprite at position (0,0) from current origin + RWsSprite sprite; + TSize spriteSize=iSpriteBitmap.SizeInPixels(); + SetUpSpriteLC(sprite,TheClient->iWs,*iBlankWin->BaseWin()); + TPoint winPos; + if (botRight.iXBaseWin()->SetPosition(winPos); + } + + // Now create a spritewin at top left of the visible screen + CSpriteWin* spriteWin=new(ELeave) CSpriteWin(iSpriteBitmap); + CleanupStack::PushL(spriteWin); + spriteWin->ConstructExtLD(*TheClient->iGroup,topLeft,spriteSize); + + // Set the display mode of the base window + TInt setBlankWinDispMode = iBlankWin->BaseWin()->SetRequiredDisplayMode(curDispMode); + // Set the display mode of the sprite window + TInt setSpriteWinDispMode = spriteWin->BaseWin()->SetRequiredDisplayMode(curDispMode); + + //Only do the tests if the requested mode was actually set on both windows + if(curDispMode == setBlankWinDispMode && curDispMode == setSpriteWinDispMode) + { + //Create and show DisplayMode details message + _LIT(KModeDetails, "Display Mode: "); + TBuf<30> modeDetailsMessage(KModeDetails); + modeDetailsMessage.Append(DisplayModeAsString(curDispMode)); + LOG_MESSAGE(modeDetailsMessage); + + spriteWin->AssignGC(*TheClient->iGc); + spriteWin->SetState(3); + spriteWin->Activate(); + spriteWin->DrawNow(); + TheClient->WaitForRedrawsToFinish(); + retVal=TheClient->iScreen->RectCompare(TRect(topLeft,spriteSize),TRect(winPos,spriteSize),CWsScreenDevice::EIncludeSprite); + TEST(retVal); + if(!retVal) + { + _LIT(KLog,"Initial Drawing of sprite fails - does not compare to same bitmap drawn in window."); + LOG_MESSAGE(KLog); + } + + // Move position of the window and sprite and then test + TPoint spritePos(Min(20,botRight.iX-spriteSize.iWidth-winPos.iX),20); + spriteWin->SetExt(topLeft+spritePos,spriteSize); + sprite.SetPosition(spritePos); + spriteWin->DrawNow(); + TheClient->WaitForRedrawsToFinish(); + retVal=TheClient->iScreen->RectCompare(TRect(topLeft+spritePos,spriteSize),TRect(winPos+spritePos,spriteSize),CWsScreenDevice::EIncludeSprite); + TEST(retVal); + if(!retVal) + { + _LIT(KLog,"Second position of sprite fails - does not compare to same bitmap drawn in window."); + LOG_MESSAGE(KLog); + } + iBlankWin->BaseWin()->SetPosition(TPoint()); + + // Now test the same by moving into other screen mode + iCurrentMode=4; + SetScreenMode(TheClient,iCurrentMode,ESizeEnforcementNone); + spritePos.SetXY(0,160); + sprite.SetPosition(spritePos); + spriteWin->SetExt(TPoint(),spriteSize); + spriteWin->DrawNow(); + TheClient->WaitForRedrawsToFinish(); + retVal=TheClient->iScreen->RectCompare(TRect(TPoint(),spriteSize),TRect(spritePos,spriteSize),CWsScreenDevice::EIncludeSprite); + TEST(retVal); + if(!retVal) + { + _LIT(KLog,"Third position of sprite fails - does not compare to same bitmap drawn in window."); + LOG_MESSAGE(KLog); + } + } + + CleanupStack::PopAndDestroy(spriteWin); + CleanupStack::PopAndDestroy(&sprite); + RestoreScreenMode(); + } + } + else + { + const TInt KScreenModeWithOffset = 2; + TheClient->iGroup->GroupWin()->EnableScreenChangeEvents(); + iTestWin->SetVisible(EFalse); + TheClient->Flush(); + iConnection2->iClient->Flush(); + TheClient->WaitForRedrawsToFinish(); + TPixelsAndRotation pixelsAndRotation1; + TheClient->iScreen->GetScreenModeSizeAndRotation(KScreenModeWithOffset,pixelsAndRotation1); + ChangeScreenMode(TheClient,pixelsAndRotation1,KScreenModeWithOffset); + RWsSprite sprite[2]; + for (TInt ii=0;ii<2;ii++) + { + SetUpSpriteLC(sprite[ii],TheClient->iWs,*TheClient->iGroup->WinTreeNode()); + } + TheClient->Flush(); + TheClient->WaitForRedrawsToFinish(); + TPixelsAndRotation pixelsAndRotation2; + TheClient->iScreen->GetScreenModeSizeAndRotation(0,pixelsAndRotation2); + iConnection2->iSpriteWin->UpdateState(0); + iConnection2->iSpriteWin->SetVisible(ETrue); + iConnection2->iClient->Flush(); + TSize spriteSize=iSpriteBitmap.SizeInPixels(); + TPoint screenMode2Origin; + screenMode2Origin=TheClient->iScreen->GetScreenModeOrigin(KScreenModeWithOffset); + //Check all reference bitmaps can be drawn inside the screen + MDisplayControl* interface = static_cast + (TheClient->iScreen->GetInterface(MDisplayControl::ETypeId)); + if(interface) + { + TDisplayConfiguration config; + interface->GetConfiguration(config); + TSize screenSize; + config.GetResolution(screenSize); + TEST(screenSize.iWidth > screenMode2Origin.iX+CheckSpritePos.iX+spriteSize.iWidth+30 + && screenSize.iHeight > screenMode2Origin.iY+CheckSpritePos.iY + spriteSize.iHeight+30); + } + + retVal = iConnection2->iClient->iScreen->RectCompare(TRect(screenMode2Origin+CheckSpritePos,spriteSize),TRect(screenMode2Origin,spriteSize),CWsScreenDevice::EIncludeSprite); + TEST(retVal); + if(!retVal) + INFO_PRINTF3(_L("iConnection2->iClient->iScreen->RectCompare() return value - Expected: %d, Actual: %d"), ETrue, retVal); + + TheClient->iScreen->SetCurrentRotations(KScreenModeWithOffset,CFbsBitGc::EGraphicsOrientationRotated180); + ChangeScreenMode(TheClient,pixelsAndRotation1,KScreenModeWithOffset); + TheClient->Flush(); + sprite[0].SetPosition(TPoint(0,0)); + sprite[1].SetPosition(TPoint(30,30)); + TheClient->Flush(); + TheClient->WaitForRedrawsToFinish(); + iConnection2->iSpriteWin->UpdateState(1); + iConnection2->iClient->Flush(); + retVal = iConnection2->iClient->iScreen->RectCompare(TRect(screenMode2Origin+CheckSpritePos,spriteSize+TPoint(30,30)),TRect(screenMode2Origin,spriteSize+TPoint(30,30)),CWsScreenDevice::EIncludeSprite); + TEST(retVal); + if(!retVal) + INFO_PRINTF3(_L("iConnection2->iClient->iScreen->RectCompare() return value - Expected: %d, Actual: %d"), ETrue, retVal); + + TheClient->iScreen->SetCurrentRotations(KScreenModeWithOffset,CFbsBitGc::EGraphicsOrientationNormal); + ChangeScreenMode(TheClient,pixelsAndRotation2,0); + iConnection2->iSpriteWin->SetExt(TPoint(215,0),TSize(218,240)); + TheClient->Flush(); + TheClient->WaitForRedrawsToFinish(); + sprite[0].SetPosition(TPoint(-10,20)); + sprite[1].SetPosition(TPoint(-10,40)); + TheClient->Flush(); + TheClient->WaitForRedrawsToFinish(); + ChangeScreenMode(TheClient,pixelsAndRotation1,ESizeEnforcementPixelsAndRotation,KScreenModeWithOffset); + TheClient->Flush(); + TheClient->WaitForRedrawsToFinish(); + iConnection2->iSpriteWin->UpdateState(2); + iConnection2->iClient->Flush(); + retVal = iConnection2->iClient->iScreen->RectCompare(TRect(screenMode2Origin+CheckSpritePos+TPoint(0,20),spriteSize+TPoint(-10,20)),TRect(screenMode2Origin+TPoint(0,20),spriteSize+TPoint(-10,20)),CWsScreenDevice::EIncludeSprite); + TEST(retVal); + if(!retVal) + INFO_PRINTF3(_L("iConnection2->iClient->iScreen->RectCompare() return value - Expected: %d, Actual: %d"), ETrue, retVal); + + CleanupStack::PopAndDestroy(2,&sprite[0]); + iConnection2->iSpriteWin->SetVisible(EFalse); + ChangeScreenMode(TheClient,pixelsAndRotation2,ESizeEnforcementPixelsAndRotation,0); + TheClient->Flush(); + TheClient->WaitForRedrawsToFinish(); + } +#endif + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-0105 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Rotation Tests + REQUIREMENT: CR PHAR-5SJGAM, PREQ673 + API: RWindowBase::InquireOffset(), RWindowBase::AbsPosition(),RWindowBase::Position() + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Goes through all the screen modes defined in the wsini file and all the rotations in + each screen mode. For each case sets the new screen mode and the the rotation on the current + client's screen device. Then sets a suitable size and position of 2 windows (an RWindow + and a child RBackedUpWindow) whose group window has the above screen device. + +@SYMTestExpectedResults Checks the windows are positioned correctly according to the origin and rotation + of the new screen mode. + +*/ +void CTScreenModePositioning::RotationTestsL() + { + RBlankWindow color256(TheClient->iWs); + User::LeaveIfError(color256.Construct(*TheClient->iGroup->GroupWin(),ENullWsHandle)); + CleanupClosePushL(color256); + color256.SetRequiredDisplayMode(EColor256); + color256.SetOrdinalPosition(2); + color256.Activate(); + TInt ii; + for (ii=0;iiiScreenModes.Count();) + { + iCurrentMode=TheClient->iScreenModes[ii]; + SetScreenMode(TheClient,iCurrentMode,ESizeEnforcementPixelsAndRotation); + TPixelsAndRotation pixelsAndRotation; + TheClient->iScreen->GetDefaultScreenSizeAndRotation(pixelsAndRotation); + TInt oldCurrentMode=iCurrentMode; + CArrayFixFlat* rotations=new(ELeave) CArrayFixFlat(1); + CleanupStack::PushL(rotations); + User::LeaveIfError(TheClient->iScreen->GetRotationsList(iCurrentMode,rotations)); + TInt count=rotations->Count(); + TInt jj=0; + if (count>1) + { + for (jj=0;jjiScreen->SetCurrentRotations(oldCurrentMode,REINTERPRET_CAST(CFbsBitGc::TGraphicsOrientation&,currentRotation)); + CleanupStack::PopAndDestroy(rotations); + iCurrentScreenModeOrigin=TheClient->iScreen->GetScreenModeOrigin(oldCurrentMode); + iCurrentScreenModeOrigin=TheClient->iScreen->GetScreenModeScaledOrigin(oldCurrentMode); + TPoint point1(iCurrentScreenModeOrigin.iX,iCurrentScreenModeOrigin.iY+(iCurrentScreenModeOrigin.iY+pixelsAndRotation.iPixelSize.iHeight)/2); + TPoint point2(iCurrentScreenModeOrigin.iX+(iCurrentScreenModeOrigin.iX+pixelsAndRotation.iPixelSize.iWidth)/2,pixelsAndRotation.iPixelSize.iHeight+iCurrentScreenModeOrigin.iY); + TRect rect0(point1,point2); + iTestWin->SetExtL(TPoint(),rect0.Size()); + iTestWin->Invalidate(); + + iTestWin->SetVisible(ETrue); + TheClient->Flush(); + TheClient->WaitForRedrawsToFinish(); + TestTopClientWindowPositionAPIs(TPoint(),iTestWin->BaseWin()); + TPoint backedUpWinPt=TPoint(rect0.Width()/3,rect0.Height()/4); + iBackedUpWin->SetVisible(ETrue); + + CleanupStack::PushL(TCleanupSetVisible(iBackedUpWin)); + CleanupStack::PushL(TCleanupSetVisible(iTestWin)); + + + iBackedUpWin->SetExtL(backedUpWinPt,TSize(rect0.Width()/6,rect0.Height()/6)); + TestChildWindowPositionAPIs(backedUpWinPt,TPoint(),iBackedUpWin->BaseWin(),iTestWin->BaseWin()); + + CleanupStack::PopAndDestroy(2,iBackedUpWin); //TCleanupSetVisible + } + CleanupStack::PopAndDestroy(&color256); + } + +TBool CTScreenModePositioning::ScalingSupportedByDisplayMode() + { + //PeterI Standard ScreenDriver only supports scaling in EColor256 and EColor64k + //see CDrawBitmap::CanBeScaled(), as mk3 is always in 16mu the tests will not pass. + TBool ret=EFalse; + TDisplayMode mode=TheClient->iScreen->DisplayMode(); + if (mode==EColor64K || mode==EColor256) + { + ret=ETrue; + } + return ret; + } +void CTScreenModePositioning::RunTestCaseL(TInt /*aCurTestCase*/) + { + _LIT(KWindowTests,"Window Tests"); + _LIT(KSpriteTest,"Sprite Test"); + _LIT(KRotationTests,"Rotation Tests"); + ((CTScreenModePositioningStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); + switch(iTest->iState) + { + case 0: + ((CTScreenModePositioningStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + if (!CheckNonZeroOriginsSupportedOrNot()) + { + _LIT(KLog,"Non Zero Origins not supported"); + LOG_MESSAGE(KLog); + TestComplete(); + return; + } + break; + case 1: + iTest->LogSubTest(KWindowTests); + if(ScalingSupportedByDisplayMode()) + WindowTestsL(); + ((CTScreenModePositioningStep*)iStep)->SetOverallTestStepID(_L("GRAPHICS-WSERV-0098")); + break; + case 2: + ((CTScreenModePositioningStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0104")); + iTest->LogSubTest(KSpriteTest); + if(ScalingSupportedByDisplayMode()) + SpriteTestL(); + break; + case 3: + ((CTScreenModePositioningStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0105")); + iTest->LogSubTest(KRotationTests); + RotationTestsL(); + break; + default: + ((CTScreenModePositioningStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + ((CTScreenModePositioningStep*)iStep)->CloseTMSGraphicsStep(); + RestoreScreenMode(); + TestComplete(); + return; + } + ((CTScreenModePositioningStep*)iStep)->RecordTestResultL(); + ++iTest->iState; // still used in the remaining code + } + +__WS_CONSTRUCT_STEP__(ScreenModePositioning) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TSCREENMODEPOSITIONING.H --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TSCREENMODEPOSITIONING.H Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,123 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + + +#ifndef __TSCREENMODEPOSITIONING_H__ +#define __TSCREENMODEPOSITIONING_H__ + +#include +#include +#include "../tlib/testbase.h" +#include "AUTO.H" +#include "TScreenModeScaling.h" +#include "TGraphicsHarness.h" + +class CConnection2; + +class CConnection2Group : public CTWindowGroup + { +public: + CConnection2Group(CTClient *aClient, CConnection2 *aSecondConnection, CTestBase *aTest); +private: + CTestBase* iTest; +public: + CConnection2* iConnection2; + }; + +class CConnection2 : public CBase + { +public: + ~CConnection2(); + void ConstructL(CTestBase *aTest,CFbsBitmap& aBitmap); + void DrawBitmapWin(); + CBmpWin* BitmapWin() {return iBitmapWin;} +public: + CTClient* iClient; + CFbsBitmap* iScreenBitmap; + CSpriteWin* iSpriteWin; +private: + CConnection2Group *iGroup; + CBmpWin* iBitmapWin; + }; + + + +class CTScreenModePositioning : public CTWsGraphicsBase + { +public: + CTScreenModePositioning(CTestStep* aStep); + ~CTScreenModePositioning(); + void ConstructL(); + + void WindowTestsL(); + void SpriteTestL(); + void RotationTestsL(); + TBool ScalingSupportedByDisplayMode(); + +protected: + virtual void RunTestCaseL(TInt aCurTestCase); +private: + TBool TestRect(); + void CopyScreenAndChangeBackToDefScrModeL(); + void PositionTest1L(TPoint aPosTSize); + void PositionTest2L(TPoint aPos); + void GetInvalidRegionTestL(TPoint aPos); + void DoWindowTestsL(); + void CreateWindowsTestL(TPoint aPos); + void NextScreenModeTestL(TPoint aPos); + void ChangeScreenMode(CTClient* aClient,TPixelsAndRotation aPixelsAndRotation,TInt aMode); + void ChangeScreenMode(CTClient* aClient,TPixelsAndRotation aPixelsAndRotation,TScreenModeEnforcement aScreenModeEnforcement,TInt aMode); + void SetScreenMode(CTClient* aClient,TInt aMode,TScreenModeEnforcement aScreenModeEnforcement); + void SetUpSpriteLC(RWsSprite &aSprite, RWsSession &aSession, RWindowTreeNode &aWindow,TInt aFlags=ESpriteNoShadows); + void CompareRegionsL(const TRegion &aRegion1,const TRegion &aRegion2); + void TestGetInvalidRegionL(TRect& aRect); + void TestTopClientWindowPositionAPIs(TPoint aPos,RWindowBase* aWin); + void TestChildWindowPositionAPIs(TPoint aPos,TPoint aParentPos,RWindowBase* aWin,RWindowBase* aParentWin); + void CopyAndCompareL(TPoint aPos); + void RestoreScreenMode(); +private: + CFbsBitmap iSpriteBitmap; + CConnection2* iConnection2; + CBasicWin *iTestWin; + CTBackedUpWin* iBackedUpWin; + CTBlankWindow* iBlankWin; + CTBlankWindow* iTestChildWin; + TInt iCurrentMode; + TSize iTestWinSize; + TPoint iCurrentScreenModeOrigin; + TSize iCurrentScreenModeScale; + TSize iCurrentScreenModeSize; + TInt iScalingSupported; + }; + +class CTScreenModePositioningStep : public CTGraphicsStep + { +public: + CTScreenModePositioningStep(); +protected: + //from CTGraphicsStep + virtual CTGraphicsBase* CreateTestL(); + }; + +_LIT(KTScreenModePositioningStep,"TScreenModePositioning"); + + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TSCRMODE.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TSCRMODE.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,1701 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Test screen mode switching +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include "TSCRMODE.H" + +const TInt KBlankWinPosX=10; +const TInt KBlankWinPosY=20; +const TInt KBlankWinSizeX=30; +const TInt KBlankWinSizeY=25; + +const TInt KScreenMode0=0; +const TInt KScreenMode1=1; +_LIT(KScreenModeDisplayMode,"GetScreenModeDisplayMode"); + + +CTScrMode::CTScrMode(CTestStep* aStep) : CTWsGraphicsBase(aStep) + { + } + +// +// Static func to check windows +// + +LOCAL_C TInt DoPanicTest(TInt aInt, TAny *aScreenNumber) + { + RWsSession ws; + CWsScreenDevice *screen=NULL; + if (ws.Connect()==KErrNone) + { + screen = new (ELeave) CWsScreenDevice(ws); + if (screen && screen->Construct((TInt)aScreenNumber)==KErrNone) + { + TPixelsTwipsAndRotation sar; + CFbsBitGc::TGraphicsOrientation rot=CFbsBitGc::EGraphicsOrientationNormal; + TInt mode=0; + switch(aInt) + { + case 0: + case 1: + screen->SetScreenMode(aInt==0?1000:-1); + break; + case 2: + case 3: + screen->GetScreenModeSizeAndRotation(aInt==2?screen->NumScreenModes():-100000, sar); + break; + case 4: + case 5: + screen->GetScreenModeSizeAndRotation(aInt==4?screen->NumScreenModes()+100:-10, sar); + break; + case 6: + mode=screen->NumScreenModes(); + goto SetRot; + case 7: + mode=-55; + goto SetRot; + case 8: + mode=234; + goto SetRot; + case 9: + mode=screen->NumScreenModes()+2; + rot=CFbsBitGc::EGraphicsOrientationRotated270; + SetRot: + screen->SetCurrentRotations(mode,rot); + break; + case 10: + case 11: + ws.SetPointerCursorArea(aInt==10?1000:-1,TRect()); + break; + case 12: + case 13: + ws.PointerCursorArea(aInt==12?1003:-2); + break; + case 14: + case 15: + { + CArrayFixFlat *rotations=new(ELeave) CArrayFixFlat(1); + screen->GetRotationsList(aInt==12?1003:-2,rotations); + } + break; + case 100: + rot=CFbsBitGc::EGraphicsOrientationRotated90; + goto SetRot; + case 101: + rot=CFbsBitGc::EGraphicsOrientationRotated270; + goto SetRot; + case 102: + mode=1; + rot=CFbsBitGc::EGraphicsOrientationRotated270; + goto SetRot; + case 103: + mode=1; + #if defined(__EPOC32__) + rot=CFbsBitGc::EGraphicsOrientationRotated180; + #else + rot=CFbsBitGc::EGraphicsOrientationNormal; + #endif + goto SetRot; + } + ws.Flush(); + } + } + + return(EWsExitReasonBad); + } + +void SetupTestRWindowLC(RWindow& aWindow, const TPoint& aPos, const TSize& aSize, TDisplayMode aDisplayMode) + { + CleanupClosePushL(aWindow); + User::LeaveIfError(aWindow.Construct(*TheClient->iGroup->GroupWin(), (TUint)&aWindow)); + aWindow.SetExtent(aPos, aSize); + User::LeaveIfError(aWindow.SetRequiredDisplayMode(aDisplayMode)); + aWindow.Activate(); + } + +void CTScrMode::TestPanicsL() + { + TInt ii; + for (ii=0;ii<16;++ii) + TEST(iTest->TestWsPanicL(DoPanicTest,EWservPanicScreenModeNumber,ii,(TAny*)iTest->iScreenNumber)); + for (ii=100;ii<104;++ii) + TEST(iTest->TestWsPanicL(DoPanicTest,EWservPanicRotation,ii,(TAny*)iTest->iScreenNumber)); + iTest->CloseAllPanicWindows(); + } + +CTScrMode::~CTScrMode() + { + ((CTScrModeStep*)iStep)->CloseTMSGraphicsStep(); + delete iSecondConnection; + TheClient->iGroup->GroupWin()->DisableScreenChangeEvents(); + SetScreenModeEnforcement(iOldEnfMode); + } + +void CTScrMode::ConstructL() + { + //Remove next line when bitmaps are stored correctly + TestWin->Win()->EnableRedrawStore(EFalse); + BaseWin->Win()->EnableRedrawStore(EFalse); +// + TheClient->iGroup->GroupWin()->EnableScreenChangeEvents(); +// + //TheClient->iWs.SetAutoFlush(ETrue); + ValidateWin(BaseWin,TRgb::Gray256(204)); + ValidateWin(TestWin,TRgb::Gray256(204)); +// + iWinState=0; + iWinPos=TPoint(2*TheClient->iGroup->Size().iWidth/3,0); +// + iSecondConnection=new(ELeave) CSecondConnection; + iSecondConnection->ConstructL(iTest->iScreenNumber, TRect(KBlankWinPosX,KBlankWinPosY,KBlankWinPosX+KBlankWinSizeX,KBlankWinPosY+KBlankWinSizeY),iTest,iStep); +// + iOldEnfMode=TheClient->iScreen->ScreenModeEnforcement(); + if (TheClient->iScreenModes.Count()<2) + { + iTest->iState=1000; // Miss all tests + _LIT(KLog,"Skipping all tests as less that 2 screen size modes"); + LOG_MESSAGE(KLog); + } + else + { + SetScreenModeEnforcement(ESizeEnforcementNone); + TheClient->iScreen->SetScreenMode(TheClient->iScreenModes[0]); + } + } + +void CTScrMode::SetScreenModeEnforcement(TScreenModeEnforcement aMode) + { + iCurEnforcement=aMode; + TheClient->iScreen->SetScreenModeEnforcement(iCurEnforcement); + } + +void CTScrMode::ScaledDrawingL() + { + const TInt KLineXPos=10; + const TInt KLineYPos=30; + const TInt KLineLength=10; + const TInt KXScaleFactor=4; + const TInt KYScaleFactor=3; +// + // Draw rectangle onto TestWin + CWindowGc *gc=TheClient->iGc; + gc->Activate(*(TestWin->Win())); + gc->SetBrushColor(KRgbBlack); + gc->SetBrushStyle(CGraphicsContext::ESolidBrush); + gc->DrawRect(TRect(TPoint(KLineXPos,KLineYPos),TSize(KLineLength*KXScaleFactor,KYScaleFactor))); + gc->Deactivate(); +// + // Draw scaled bitmap onto BaseWin + TSize bitSize(KLineLength,1); + TSize bitTwipSize(TheClient->iScreen->HorizontalPixelsToTwips(bitSize.iWidth*KXScaleFactor), + TheClient->iScreen->VerticalPixelsToTwips(bitSize.iHeight*KYScaleFactor)); + CFbsBitGc *bitGc=NULL; + CFbsBitmapDevice *device=NULL; + CFbsBitmap *bitmap=NULL; + bitmap=new(ELeave) CFbsBitmap(); + CleanupStack::PushL(bitmap); + User::LeaveIfError(bitmap->Create(bitSize,EGray16)); + bitmap->SetSizeInTwips(bitTwipSize); + device=CFbsBitmapDevice::NewL(bitmap); + CleanupStack::PushL(device); + User::LeaveIfError(device->CreateContext(bitGc)); + bitGc->SetBrushColor(KRgbBlack); + bitGc->Clear(); + delete bitGc; +// + gc->Activate(*(BaseWin->Win())); + gc->DrawBitmap(TPoint(KLineXPos,KLineYPos),bitmap); + gc->Deactivate(); +// + TheClient->iWs.Flush(); + + CleanupStack::PopAndDestroy(2); // bitmap,device + + CompareWindows(_L("CTScrMode::ScaledDrawingL() CompareWindows() failed")); + } + +void CTScrMode::ValidateWin(TestWindow *aWin, TRgb aColor) + { + aWin->Win()->Invalidate(); + RedrawWin(*aWin->Win(),aColor); + } + +void CTScrMode::RedrawWin(RWindow &aWin, TRgb aColor) + { + aWin.BeginRedraw(); + TheClient->iGc->Activate(aWin); + TheClient->iGc->SetBrushColor(aColor); + TheClient->iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + TheClient->iGc->SetPenStyle(CGraphicsContext::ENullPen); + TheClient->iGc->Clear(); + TheClient->iGc->Deactivate(); + aWin.EndRedraw(); + } + +void CTScrMode::CheckWindows(TBool aWinIsVis) + { + iSecondConnection->SetWindow2Visibility(aWinIsVis); + TheClient->WaitForRedrawsToFinish(); + TheClient->iWs.Finish(); + CompareWindows(_L("CTScrMode::CheckWindows() CompareWindows() failed")); + } + +void CTScrMode::ScreenRotationsL() + { + CWsScreenDevice *screen=TheClient->iScreen; + CArrayFixFlat *rotations=new(ELeave) CArrayFixFlat(1); + CFbsBitGc::TGraphicsOrientation currentRotation; + TPixelsAndRotation sizeAndRotation; + TPixelsTwipsAndRotation sizeAndRotation2; + TBool found; + TInt numModes=TheClient->iScreenModes.Count(); + TInt count; + TInt ii,jj; + CleanupStack::PushL(rotations); + for (ii=0;iiiScreenModes[ii]; + User::LeaveIfError(screen->GetRotationsList(mode,rotations)); + screen->GetScreenModeSizeAndRotation(mode,sizeAndRotation); + screen->GetScreenModeSizeAndRotation(mode,sizeAndRotation2); + TEST(sizeAndRotation.iPixelSize.iWidth==sizeAndRotation2.iPixelSize.iWidth); + if (sizeAndRotation.iPixelSize.iWidth!=sizeAndRotation2.iPixelSize.iWidth) + INFO_PRINTF3(_L("sizeAndRotation.iPixelSize.iWidth==sizeAndRotation2.iPixelSize.iWidth - Expected: %d, Actual: %d"), sizeAndRotation.iPixelSize.iWidth, sizeAndRotation2.iPixelSize.iWidth); + + TEST(sizeAndRotation.iPixelSize.iHeight==sizeAndRotation2.iPixelSize.iHeight); + if (sizeAndRotation.iPixelSize.iHeight!=sizeAndRotation2.iPixelSize.iHeight) + INFO_PRINTF3(_L("sizeAndRotation.iPixelSize.iHeight==sizeAndRotation2.iPixelSize.iHeight - Expected: %d, Actual: %d"), sizeAndRotation.iPixelSize.iHeight, sizeAndRotation2.iPixelSize.iHeight); + + count=rotations->Count(); + TEST(count>=1); + if (count<1) + INFO_PRINTF3(_L("rotations->Count() return value - Expected: %d or more, Actual: %d"), 1, count); + + TBool retVal; + + if (sizeAndRotation.iPixelSize.iWidth!=sizeAndRotation.iPixelSize.iHeight) + { + TEST(count<=2); + if (count>2) + INFO_PRINTF3(_L("rotations->Count() return value - Expected: %d or less, Actual: %d"), 2, count); + + if (count==2) + { + retVal = (*rotations)[0]+2==(*rotations)[1]; + TEST(retVal); //Must only have rotations 180 degrees apart + if (!retVal) + INFO_PRINTF3(_L("(*rotations)[0]+2==(*rotations)[1] - Expected: %d, Actual: %d"), ETrue, retVal); + } + } + found=EFalse; + for (jj=0;jj1) + { + currentRotation=sizeAndRotation.iRotation; + for (jj=0;jjSetCurrentRotations(mode,REINTERPRET_CAST(CFbsBitGc::TGraphicsOrientation&,(*rotations)[jj])); + screen->GetScreenModeSizeAndRotation(mode,sizeAndRotation); + screen->GetScreenModeSizeAndRotation(mode,sizeAndRotation2); + retVal = (*rotations)[jj]==sizeAndRotation.iRotation; + TEST(retVal); + if (!retVal) + INFO_PRINTF3(_L("(*rotations)[jj]==sizeAndRotation.iRotation - Expected: %d, Actual: %d"), ETrue, retVal); + + retVal = (*rotations)[jj]==sizeAndRotation2.iRotation; + TEST(retVal); + if (!retVal) + INFO_PRINTF3(_L("(*rotations)[jj]==sizeAndRotation2.iRotation - Expected: %d, Actual: %d"), ETrue, retVal); + + } + screen->SetCurrentRotations(mode,REINTERPRET_CAST(CFbsBitGc::TGraphicsOrientation&,currentRotation)); + screen->GetScreenModeSizeAndRotation(mode,sizeAndRotation); + screen->GetScreenModeSizeAndRotation(mode,sizeAndRotation2); + + retVal = currentRotation==sizeAndRotation.iRotation; + TEST(retVal); + if (!retVal) + INFO_PRINTF3(_L("currentRotation==sizeAndRotation.iRotation - Expected: %d, Actual: %d"), ETrue, retVal); + + retVal = currentRotation==sizeAndRotation2.iRotation; + TEST(retVal); + if (!retVal) + INFO_PRINTF3(_L("currentRotation==sizeAndRotation2.iRotation - Expected: %d, Actual: %d"), ETrue, retVal); + } + } + CleanupStack::PopAndDestroy(); + } + +void CTScrMode::MoreScreenRotationsL() + { + RWindow shield4Gray(TheClient->iWs); + // The default display mode needs to be updated to EColor64K for Oghma integ + SetupTestRWindowLC(shield4Gray,TPoint(),TSize(100000,100000),EColor64K); +// + CWsScreenDevice *screen=TheClient->iScreen; + //CFbsBitGc::TGraphicsOrientation currentRotation; + TPixelsAndRotation sizeAndRotation; + TInt currentRotation; + TInt currentMode=FindCurrentMode(); + TInt numModes=TheClient->iScreenModes.Count(); + TInt currentScreenMode; + TInt count; + TInt ii,jj; + CArrayFixFlat *currentRotations=new(ELeave) CArrayFixFlat(1); + CleanupStack::PushL(currentRotations); + currentRotations->ResizeL(numModes); + CArrayFixFlat *originalRotation=new(ELeave) CArrayFixFlat(1); + CleanupStack::PushL(originalRotation); + originalRotation->ResizeL(numModes); + CArrayFixFlat *rotations=new(ELeave) CArrayFixFlat(1); + CleanupStack::PushL(rotations); + for (ii=0;iiiScreenModes[ii]; + screen->GetScreenModeSizeAndRotation(mode,sizeAndRotation); + (*currentRotations)[ii]=sizeAndRotation.iRotation; + (*originalRotation)[ii]=sizeAndRotation.iRotation; + } + for (ii=0;iiiScreenModes[ii]; + screen->SetScreenMode(mode); + currentScreenMode = screen->CurrentScreenMode(); + TEST(currentScreenMode == mode); + if (currentScreenMode != mode) + INFO_PRINTF3(_L("screen->CurrentScreenMode() return value - Expected: %d, Actual: %d"), mode, currentScreenMode); + + screen->GetDefaultScreenSizeAndRotation(sizeAndRotation); + currentRotation=(*currentRotations)[ii]; + TEST(sizeAndRotation.iRotation==currentRotation); + + screen->GetScreenModeSizeAndRotation(mode,sizeAndRotation); + TEST(sizeAndRotation.iRotation==currentRotation); + + User::LeaveIfError(screen->GetRotationsList(mode,rotations)); + count=rotations->Count(); + if (count>1) + { + for (jj=0;jjSetCurrentRotations(mode,REINTERPRET_CAST(CFbsBitGc::TGraphicsOrientation&,currentRotation)); + (*currentRotations)[ii]=currentRotation; + } + } + for (ii=0;iiiScreenModes[ii]; + screen->SetScreenMode(mode); + currentScreenMode = screen->CurrentScreenMode(); + TEST(currentScreenMode == mode); + if (currentScreenMode != mode) + INFO_PRINTF3(_L("(screen->CurrentScreenMode() return value - Expected: %d, Actual: %d"), mode, currentScreenMode); + + screen->GetDefaultScreenSizeAndRotation(sizeAndRotation); + currentRotation=(*currentRotations)[ii]; + TEST(sizeAndRotation.iRotation==currentRotation); + if (sizeAndRotation.iRotation != currentRotation) + INFO_PRINTF3(_L("(screen->GetDefaultScreenSizeAndRotation() return value - Expected: %d, Actual: %d"), currentRotation, sizeAndRotation.iRotation); + + screen->GetScreenModeSizeAndRotation(mode,sizeAndRotation); + TEST(sizeAndRotation.iRotation==currentRotation); + if (sizeAndRotation.iRotation != currentRotation) + INFO_PRINTF3(_L("(screen->GetDefaultScreenSizeAndRotation() return value - Expected: %d, Actual: %d"), currentRotation, sizeAndRotation.iRotation); + + if (currentRotation!=(*originalRotation)[ii]) + screen->SetCurrentRotations(mode,REINTERPRET_CAST(CFbsBitGc::TGraphicsOrientation&,(*originalRotation)[ii])); + } + screen->SetScreenMode(currentMode); + currentScreenMode = screen->CurrentScreenMode(); + TEST(currentScreenMode == currentMode); + if (currentScreenMode != currentMode) + INFO_PRINTF3(_L("(screen->CurrentScreenMode() return value - Expected: %d, Actual: %d"), currentMode, currentScreenMode); + + CleanupStack::PopAndDestroy(4,&shield4Gray); + } + +TInt CTScrMode::FindCurrentMode() + { + CWsScreenDevice *screen=TheClient->iScreen; + TPixelsTwipsAndRotation sizeAndRotation; + TPixelsTwipsAndRotation sizeAndRotation2; + TInt numModes=TheClient->iScreenModes.Count(); + TInt ii; + screen->GetDefaultScreenSizeAndRotation(sizeAndRotation); + for (ii=0;iiiScreenModes[ii]; + screen->GetScreenModeSizeAndRotation(mode,sizeAndRotation2); + if (Equal(sizeAndRotation,sizeAndRotation2)) + return mode; + } + TEST(EFalse); + return -1; + } + +TBool CTScrMode::Equal(const TPixelsTwipsAndRotation& aLeft,const TPixelsTwipsAndRotation& aRight) + { + if (aLeft.iPixelSize!=aRight.iPixelSize) + return EFalse; + if (aLeft.iRotation!=aRight.iRotation) + return EFalse; + if (aLeft.iTwipsSize!=aRight.iTwipsSize) + return EFalse; + return ETrue; + } + +TBool CTScrMode::RectClearBugL() + { + CWsScreenDevice *screen=TheClient->iScreen; + TPixelsTwipsAndRotation sizeAndRotation1; + TPixelsTwipsAndRotation sizeAndRotation2; + TInt screenMode=FindCurrentMode(); + TInt largeMode=0; + TInt smallMode=1; + INFO_PRINTF1(_L("Rotation 1")); + screen->GetScreenModeSizeAndRotation(0,sizeAndRotation1); + INFO_PRINTF1(_L("Rotation 2")); + screen->GetScreenModeSizeAndRotation(1,sizeAndRotation2); + TSize winSize=TSize(Max(sizeAndRotation1.iPixelSize.iWidth,sizeAndRotation2.iPixelSize.iWidth) + ,Max(sizeAndRotation1.iPixelSize.iHeight,sizeAndRotation2.iPixelSize.iHeight)); + if (sizeAndRotation1.iPixelSize.iWidth<=sizeAndRotation2.iPixelSize.iWidth + && sizeAndRotation1.iPixelSize.iHeight<=sizeAndRotation2.iPixelSize.iHeight) + { + largeMode=1; + smallMode=0; + } + if (screenMode!=largeMode) + { + INFO_PRINTF2(_L("Large Mode %d\r\n"),largeMode); + screen->SetScreenMode(largeMode); + } + CBlankWindow *blankWin=new(ELeave) CBlankWindow(TRgb::Gray256(204)); + CleanupStack::PushL(blankWin); + blankWin->SetUpL(TPoint(),winSize,TheClient->iGroup,*TheClient->iGc); + TheClient->iGc->Activate(*blankWin->Win()); //blankWin->Win()->Invalidate(); + blankWin->Draw(); + TheClient->iWs.Flush(); + blankWin->Win()->SetRequiredDisplayMode(EGray4); + INFO_PRINTF2(_L("Small Mode %d\r\n"),smallMode); + screen->SetScreenMode(smallMode); + TheClient->iWs.Flush(); + TheClient->iGc->Deactivate(); + CleanupStack::PopAndDestroy(); + if (screenMode!=smallMode) + { + INFO_PRINTF2(_L("Screen Mode %d\r\n"),screenMode); + screen->SetScreenMode(screenMode); + } + + return ETrue; + } + +void CTScrMode::ScreenModeChange1L() + { + CTWin* color64win; + color64win=new(ELeave) CTWin(); + CleanupStack::PushL(color64win); + color64win->ConstructL(*TheClient->iGroup); + color64win->BaseWin()->SetRequiredDisplayMode(EColor64K); + //color64win->SetBackgroundColor(TRgb(0,0,255)); + color64win->Win()->SetBackgroundColor(); + color64win->Activate(); + TheClient->Flush(); + CTWin* color4win; + color4win=new(ELeave) CTWin(); + CleanupStack::PushL(color4win); + color4win->ConstructL(*TheClient->iGroup); + color4win->BaseWin()->SetRequiredDisplayMode(EColor4K); + //color4win->SetBackgroundColor(TRgb(255,0,0)); + color4win->Win()->SetBackgroundColor(); + color4win->SetSize(TSize(600,200)); + color4win->Activate(); + TheClient->Flush(); + color4win->SetSize(TSize(640,240)); + TheClient->Flush(); + color64win->SetSize(TSize(20,20)); + color64win->WinTreeNode()->SetOrdinalPosition(0); + TheClient->Flush(); + CleanupStack::Pop(2,color64win); + delete color64win; + TheClient->Flush(); + delete color4win; + //CleanupStack::PopAndDestroy(2,color64win); + } + +void CTScrMode::ScreenModeChange2L() + { + CTBlankWindow* color64win; + color64win=new(ELeave) CTBlankWindow(); + CleanupStack::PushL(color64win); + color64win->ConstructL(*TheClient->iGroup); + color64win->BaseWin()->SetRequiredDisplayMode(EColor64K); + color64win->SetColor(TRgb(0,0,255)); + //color64win->SetColor(); + color64win->Activate(); + TheClient->Flush(); + CTBlankWindow* color4win; + color4win=new(ELeave) CTBlankWindow(); + CleanupStack::PushL(color4win); + color4win->ConstructL(*TheClient->iGroup); + color4win->BaseWin()->SetRequiredDisplayMode(EColor4K); + color4win->SetColor(TRgb(255,0,0)); + //color4win->SetColor(); + color4win->SetSize(TSize(600,200)); + color4win->Activate(); + TheClient->Flush(); + color4win->SetSize(TSize(640,240)); + TheClient->Flush(); + color64win->SetSize(TSize(20,20)); + color64win->WinTreeNode()->SetOrdinalPosition(0); + TheClient->Flush(); + CleanupStack::Pop(2,color64win); + delete color64win; + TheClient->Flush(); + delete color4win; + //CleanupStack::PopAndDestroy(2,color64win); + } + +LOCAL_C void ResetAndDestroyWindows(TAny* aPointerArray) + { + static_cast*>(aPointerArray)->ResetAndDestroy(); + } + +LOCAL_C TBool WalkThroughTree(RPointerArray aListOfWindows) + { + TBool ret=ETrue; + TInt count = aListOfWindows.Count(); + while (--count>=0 && ret) + { + RRegion region; + ((aListOfWindows)[count])->Win()->GetInvalidRegion(region); + ret=region.IsEmpty(); + } + return ret; + } + +void CTScrMode::InvisibleWndAndInfiniteRedrawBugL() + { + // Current Test client state + CTClient* clientA=TheClient; + CWsScreenDevice* screenClientA=clientA->iScreen; + const TScreenModeEnforcement screenModeEnforcement = screenClientA->ScreenModeEnforcement(); + const TInt currentScreenMode=FindCurrentMode(); + TPixelsTwipsAndRotation sizeAndRotation; + screenClientA->GetScreenModeSizeAndRotation(currentScreenMode,sizeAndRotation); + + + SecondClientConnection* clientB = new(ELeave) SecondClientConnection(); + CleanupStack::PushL(clientB); + clientB->SetScreenNumber(iTest->iScreenNumber); + clientB->ConstructL(currentScreenMode, sizeAndRotation); + +// Start test + CWindowGc& gc=*clientB->iGc; + RWsSession ws=clientB->iWs; + CTWindowGroup* group=clientB->iGroup; + + const TInt shrinkFactor = 5; + TRect parentRect(0,0, sizeAndRotation.iPixelSize.iWidth, sizeAndRotation.iPixelSize.iHeight); + RPointerArray windows; + CleanupStack::PushL(TCleanupItem(ResetAndDestroyWindows, &windows)); + // create several children + const TInt count = (iTest->iTestLevel==iTest->ELevelQuick ? 5 : 7); + CBlankWindow* blankWin=NULL; + CTWinBase* parent=group; + for (TInt childNum=0; childNumSetUpL(parentRect.iTl, parentRect.Size(), parent, gc); + // make it visible and draw it + blankWin->Win()->Invalidate(); + gc.Activate(*blankWin->Win()); + blankWin->Draw(); + ws.Flush(); + gc.Deactivate(); + // prepare for next window + parent=blankWin; + parentRect.Shrink(shrinkFactor, shrinkFactor); + } + + // change screen mode and check visibility of all windows + + const TInt newScreenMode = (currentScreenMode==KScreenMode0?KScreenMode1:KScreenMode0); + TPixelsTwipsAndRotation sizeAndRotationForDifferentScreenMode; + screenClientA->GetScreenModeSizeAndRotation(newScreenMode, sizeAndRotationForDifferentScreenMode); + screenClientA->SetScreenSizeAndRotation(sizeAndRotationForDifferentScreenMode); + screenClientA->SetScreenMode(newScreenMode); + + TheClient->WaitForRedrawsToFinish(); + TBool retVal = WalkThroughTree(windows); + TEST(retVal); + if (!retVal) + INFO_PRINTF3(_L("WalkThroughTree(windows) return value - Expected: %d, Actual: %d"), ETrue, retVal); + + + screenClientA->SetScreenModeEnforcement(screenModeEnforcement); + screenClientA->SetScreenMode(currentScreenMode); + screenClientA->SetScreenSizeAndRotation(sizeAndRotation); + + // destroy all windows + CleanupStack::PopAndDestroy(2, clientB); // ResetAndDestroyWindows and client + // Needed to get system back into a good state as this test can leave the shell in front of the test app + TheClient->iGroup->GroupWin()->SetOrdinalPosition(0); + } + +//To test the APIs GetScreenModeDisplayMode() & GetDefModeMaxNumColors() +void CTScrMode::GetScreenDisplayMode() + { + TInt color,gray; + CWsScreenDevice *screen=TheClient->iScreen; + TInt currentScreenMode=screen->CurrentScreenMode(); //finding the current screen mode + screen->SetScreenMode(KScreenMode1); //changing the current screen mode to 1 + + //testing the display mode of Screen Mode using the API GetScreenModeDisplayMode() + TDisplayMode displayMode=screen->GetScreenModeDisplayMode(KScreenMode1); + + TEST(displayMode!=ENone); + TEST(displayMode!=ERgb); + //testing the default mode of Screen Mode using the API GetDefModeMaxNumColors() + TDisplayMode defaultMode=TheClient->iWs.GetDefModeMaxNumColors(color,gray); + TDisplayMode defaultModeForScreen=TheClient->iWs.GetDefModeMaxNumColors(screen->GetScreenNumber(),color,gray); + TEST(defaultMode==defaultModeForScreen); + TEST(defaultMode!=ENone); + TEST(defaultMode!=ERgb); + TEST(color == 16777216 || color == 0 || color == 16 || color == 256 || color == 4096 || color == 65536); + TEST(gray == 0 || gray == 2 || gray == 4 || gray == 16 || gray == 256); + screen->SetScreenMode(currentScreenMode); + + CArrayFixFlat* modeList=new CArrayFixFlat(15); + TEST(modeList != NULL); + if(!modeList) + { + return; + } + TInt res = TheClient->iWs.GetColorModeList(modeList); + TEST(res == KErrNone); + TDisplayMode modeMax = ENone; + for(TInt index = 0; index < modeList->Count(); index++) + { + TDisplayMode mode = (TDisplayMode) ((*modeList)[index]); + if(mode > modeMax) + { + modeMax = mode; + } + } + modeList->Reset(); + delete modeList; + TInt realColor = 0; + TInt realGray = 0; + switch(modeMax) + { + case EGray2: + realColor = 2; + realGray = 2; + break; + case EGray4: + realColor = 4; + realGray = 4; + break; + case EGray16: + realColor = 16; + realGray = 16; + break; + case EGray256: + realColor = 256; + realGray = 256; + break; + case EColor16: + realColor = 16; + break; + case EColor256: + realColor = 256; + break; + case EColor4K: + realColor = 4096; + break; + case EColor64K: + realColor = 65536; + break; + case EColor16M: + case EColor16MU: + case EColor16MA: + case EColor16MAP: + realColor = 16777216; + break; + default: + break; + } + + if (realColor > 0) + TEST(realColor == color); + if (realGray > 0) + TEST(gray == realGray); + } + +void CTScrMode::SetScreenModeAfterScreenDeviceDeletedL() + { + // A separate session is needed, because this test will delete the primary screen device + RWsSession ws; + User::LeaveIfError(ws.Connect()); + + // Push the secondary screen device first onto the cleanup stack + // so that we can pop and destroy the primary screen device first + CWsScreenDevice* secondaryScreenDevice = new (ELeave) CWsScreenDevice(ws); + CleanupStack::PushL(secondaryScreenDevice); + + CWsScreenDevice* primaryScreenDevice = new (ELeave) CWsScreenDevice(ws); + CleanupStack::PushL(primaryScreenDevice); + + // Construct the primary screen device first to ensure that it is + // used by the group window + User::LeaveIfError(primaryScreenDevice->Construct(iTest->iScreenNumber)); + User::LeaveIfError(secondaryScreenDevice->Construct(iTest->iScreenNumber)); + + RWindowGroup group(ws); + User::LeaveIfError(group.Construct(888)); + group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close + + RArray screenModes; + primaryScreenDevice->GetScreenSizeModeList(&screenModes); + primaryScreenDevice->SetScreenMode(screenModes[0]); + + // Prematurely destroy the primary screen device used by the group window + CleanupStack::PopAndDestroy(primaryScreenDevice); + + // Simulate screen rotation - call SetScreenMode() + // This would trigger the defective behaviour and wserv would panic if broken + secondaryScreenDevice->SetScreenMode(screenModes[0]); + + // Tidy up + screenModes.Close(); + group.Close(); + CleanupStack::PopAndDestroy(secondaryScreenDevice); + ws.Flush(); + ws.Close(); + } + +void CTScrMode::DrawTestBmpL(CFbsBitmap* aTestBitmap) + { + CFbsBitmapDevice* device=CFbsBitmapDevice::NewL(aTestBitmap); + CleanupStack::PushL(device); + CGraphicsContext* bmpgc; + User::LeaveIfError(device->CreateContext(bmpgc)); + CleanupStack::PushL(bmpgc); + bmpgc->SetPenColor(KRgbDarkRed); + bmpgc->SetBrushColor(KRgbYellow); + bmpgc->SetBrushStyle(CGraphicsContext::ESolidBrush); + bmpgc->SetPenStyle(CGraphicsContext::ESolidPen); + bmpgc->DrawRect(TRect(aTestBitmap->SizeInPixels())); + CleanupStack::PopAndDestroy(2,device); + } + +void CTScrMode::TestDrawingToWindows(CWindowGc* aWinGc1, CWindowGc* aWinGc2, RWindow& aWindow1,RWindow& aWindow2,CFbsBitmap* aBitmap64K,CFbsBitmap* aBitmap16M,CFbsFont* aFont, TBool aAllInRedraw, TBool aUseSystemGc, TBool aUseBmp16M) + { + CFbsBitmap* bitmap=aUseBmp16M?aBitmap16M:aBitmap64K; + TInt ascent=aFont->AscentInPixels(); + for(TInt win=0;win<2;win++) + { + RWindow* winPtr=(win==0)?&aWindow1:&aWindow2; + winPtr->Invalidate(); + winPtr->BeginRedraw(); + CWindowGc* winGc; + if (aUseSystemGc) + { + winGc=TheClient->iGc; + winGc->Activate(*winPtr); + } + else + { + winGc=(win==0)?aWinGc1:aWinGc2; + winGc->Reset(); + } + winGc->SetBrushColor(KRgbBlue); + winGc->Clear(); + if (!aAllInRedraw) + winPtr->EndRedraw(); +// + winGc->BitBlt(TPoint(0,0),bitmap); + winGc->UseFont(aFont); + _LIT(KTestText123,"Test text 123"); + winGc->DrawText(KTestText123,TPoint(0,ascent)); + if (aAllInRedraw) + winPtr->EndRedraw(); + if (aUseSystemGc) + winGc->Deactivate(); + } + TBool winCheck=DoCheckRectRWin(aWindow1,aWindow2,TRect(aWindow1.Size())); + if (!winCheck) + { + TBuf<256> errBuf(_L("Rot-mode test failed")); + if (aAllInRedraw) + errBuf.Append(_L(", All in Redraw")); + if (aUseSystemGc) + errBuf.Append(_L(", System Gc")); + if (aUseBmp16M) + errBuf.Append(_L(", 16M bmp")); + else + errBuf.Append(_L(", 64K bmp")); + INFO_PRINTF1(errBuf); + } + TEST(winCheck); + } + +void SetWsAndAppScreenModes(TInt aMode) + { + TheClient->iScreen->SetScreenMode(aMode); + TheClient->iScreen->SetAppScreenMode(aMode); + } + +TDisplayMode HighestMatch(CArrayFixFlat* aModeList,TInt &aMaxBpp) + { + TDisplayMode highMode=ENone; + TInt highBpp=0; + for(TInt loop=aModeList->Count()-1;loop>=0;loop--) + { + TDisplayMode mode=(TDisplayMode)(*aModeList)[loop]; + TInt bpp; + switch(mode) + { + case EGray2: + bpp=1; + break; + case EGray4: + bpp=2; + break; + case EGray16: + case EColor16: + bpp=4; + break; + case EColor256: + case EGray256: + bpp=8; + break; + case EColor64K: + bpp=16; + break; + case EColor4K: + bpp=12; + break; + case EColor16M: + case EColor16MU: + case EColor16MA: + case EColor16MAP: + bpp=32; + break; + default: + bpp=0; + break; + } + if (bpp>highBpp && bppiGroup->GroupWin()->SetOrdinalPosition(0); +// When switching colour modes Wserv takes into account the full device size, not the clipped size +// associated with any specific screen mode. Therefore any windows designed to influence the screen +// mode must use the appropriately rotated device base screen size, not any cutdown screen mode sizes. + TSize baseScreenSize=TheClient->iScreen->SizeInPixels(); + TSize rotatedBaseSize(baseScreenSize.iHeight,baseScreenSize.iWidth); + TInt maxScreenDimension=Max(baseScreenSize.iHeight,baseScreenSize.iWidth); +// + CArrayFixFlat* modeList=new(ELeave) CArrayFixFlat(15); + CleanupStack::PushL(modeList); + User::LeaveIfError(TheClient->iWs.GetColorModeList(modeList)); + TInt maxBpp=KMaxTInt; + TDisplayMode testDispModeHigh=HighestMatch(modeList,maxBpp); + TDisplayMode testDispModeLow=HighestMatch(modeList,maxBpp); + CleanupStack::PopAndDestroy(modeList); +// If only one available display mode skip tests + if (testDispModeLow==ENone) + return; +// + CFbsFont* font; + TFontSpec fspec; + fspec.iHeight=240; + User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont*&)font,fspec)); +// Create a massive 16M window to make sure 16M is the fallback mode when any area of the screen is exposed + RWindow shield16M(TheClient->iWs); + SetupTestRWindowLC(shield16M,TPoint(),TSize(100000,100000),testDispModeHigh); + RedrawWin(shield16M,KRgbBlack); +// + TInt numModes=TheClient->iScreenModes.Count(); + for(TInt modeIndex=0;modeIndexiScreenModes[modeIndex]; + TPoint origin=TheClient->iScreen->GetScreenModeScaledOrigin(screenMode); + if (origin.iX!=0 || origin.iY!=0) + continue; + TPixelsTwipsAndRotation sar; + TheClient->iScreen->GetScreenModeSizeAndRotation(screenMode,sar); + TSize screenSize=sar.iPixelSize; + if (screenSize.iWidth>baseScreenSize.iWidth || screenSize.iHeight>baseScreenSize.iHeight) + continue; + TSize rotatedScreenDeviceSize(sar.iRotation==CFbsBitGc::EGraphicsOrientationRotated90 || sar.iRotation==CFbsBitGc::EGraphicsOrientationRotated270? + rotatedBaseSize:baseScreenSize); +// + TheClient->iScreen->SetScreenMode(screenMode); +// + TSize screenSize1 = screenSize; + screenSize1.iWidth = Min(screenSize1.iWidth, rotatedScreenDeviceSize.iWidth); //this is to guarantee we won't compare beyond screen size + TSize testSize(screenSize1.iWidth/2,screenSize1.iHeight); + TSize testBmpSize(testSize.iWidth,testSize.iHeight/4); +// + CFbsBitmap* testBitmap64=new(ELeave) CFbsBitmap; + CleanupStack::PushL(testBitmap64); + User::LeaveIfError(testBitmap64->Create(testBmpSize,testDispModeLow)); + DrawTestBmpL(testBitmap64); +// + CFbsBitmap* testBitmap16M=new(ELeave) CFbsBitmap; + CleanupStack::PushL(testBitmap16M); + User::LeaveIfError(testBitmap16M->Create(testBmpSize,testDispModeHigh)); + DrawTestBmpL(testBitmap16M); +// + RWindow window(TheClient->iWs); + SetupTestRWindowLC(window,TPoint(0,0), testSize,testDispModeHigh); + RWindow window2(TheClient->iWs); + SetupTestRWindowLC(window2,TPoint(testSize.iWidth,0),testSize,testDispModeHigh); +// + CWindowGc* winGc1=new(ELeave) CWindowGc(TheClient->iScreen); + CleanupStack::PushL(winGc1); + User::LeaveIfError(winGc1->Construct()); + winGc1->Activate(window); + CWindowGc* winGc2=new(ELeave) CWindowGc(TheClient->iScreen); + CleanupStack::PushL(winGc2); + User::LeaveIfError(winGc2->Construct()); + winGc2->Activate(window2); +// + for(TInt modeIndex2=0;modeIndex2iScreenModes[modeIndex2]; + TPoint origin2=TheClient->iScreen->GetScreenModeScaledOrigin(screenMode2); + if (origin2.iX!=0 || origin2.iY!=0) + continue; + TDisplayMode baseDisplayMode=TheClient->iScreen->DisplayMode(); + INFO_PRINTF5(_L("Testing with screen modes %d/%d, display modes %d/%d"),modeIndex,modeIndex2,testDispModeLow,testDispModeHigh); + SetWsAndAppScreenModes(screenMode2); + TDisplayMode dispMode11 = TheClient->iScreen->DisplayMode(); + TPixelsTwipsAndRotation sar1; + TheClient->iScreen->GetScreenModeSizeAndRotation(screenMode2, sar1); + if(sar1.iRotation == sar.iRotation) + { + continue; + } +// + RWindow window64K(TheClient->iWs); + SetupTestRWindowLC(window64K,TPoint(),TSize(maxScreenDimension,maxScreenDimension),testDispModeLow); + RedrawWin(window64K,KRgbGreen); + // Should now have switched Wserv to 64K mode + TEST(TheClient->iScreen->DisplayMode()==testDispModeLow); +// + RWindow window16M(TheClient->iWs); + SetupTestRWindowLC(window16M,TPoint(),TSize(maxScreenDimension/2,maxScreenDimension/2),testDispModeHigh); + RedrawWin(window16M,KRgbCyan); + // Should switch Wserv back to 16M mode + TEST(TheClient->iScreen->DisplayMode()==testDispModeHigh); +// + window64K.SetOrdinalPosition(-1); + window16M.SetOrdinalPosition(-1); + SetWsAndAppScreenModes(screenMode); + TEST(TheClient->iScreen->DisplayMode()==baseDisplayMode); +// + const TInt KNumTestFlags=3; + const TInt KMaxTestFlags=1<iScreen->DisplayMode()==testDispModeLow); + window64K.SetVisible(EFalse); + TEST(TheClient->iScreen->DisplayMode()==baseDisplayMode); + window64K.SetVisible(ETrue); + TEST(TheClient->iScreen->DisplayMode()==testDispModeLow); + window64K.SetSize(rotatedScreenDeviceSize); + TEST(TheClient->iScreen->DisplayMode()==testDispModeLow); + // Changing screen mode now should expose the 16M window + SetWsAndAppScreenModes(screenMode2); + TEST(TheClient->iScreen->DisplayMode()==testDispModeHigh); + SetWsAndAppScreenModes(screenMode); + // And back to the 64K win covering the screen + TEST(TheClient->iScreen->DisplayMode()==testDispModeLow); +// Create a new group with a 16M window and switching ordinal pos to back and back to front + RWindowGroup testGroup(TheClient->iWs); + CleanupClosePushL(testGroup); + User::LeaveIfError(testGroup.Construct(111,EFalse)); + RWindow testGroupWin(TheClient->iWs); + CleanupClosePushL(testGroupWin); + User::LeaveIfError(testGroupWin.Construct(testGroup, 112)); + testGroupWin.SetExtent(TPoint(), TSize(1,1)); // Just enough to change mode + testGroupWin.SetRequiredDisplayMode(testDispModeHigh); + testGroupWin.Activate(); + TEST(TheClient->iScreen->DisplayMode()==testDispModeHigh); + TInt oldPos=testGroup.OrdinalPosition(); + testGroup.SetOrdinalPosition(oldPos+1); + TEST(TheClient->iScreen->DisplayMode()==testDispModeLow); + testGroup.SetOrdinalPosition(oldPos); + TEST(TheClient->iScreen->DisplayMode()==testDispModeHigh); + CleanupStack::PopAndDestroy(2,&testGroup); + TEST(TheClient->iScreen->DisplayMode()==testDispModeLow); +// + CleanupStack::PopAndDestroy(2,&window64K); + } + CleanupStack::PopAndDestroy(2,winGc1); + CleanupStack::PopAndDestroy(2,&window); + CleanupStack::PopAndDestroy(2,testBitmap64); + } + CleanupStack::PopAndDestroy(&shield16M); + TheClient->iScreen->ReleaseFont(font); + SetWsAndAppScreenModes(TheClient->iScreenModes[0]); + } + +void CTScrMode::RunTestCaseL(TInt /*aCurTestCase*/) + { + TBuf<32> buf; + TBool checkWindowParam=EFalse; + TInt count=0; + TInt mode=0; + TBool enable=EFalse; + TBool disable=EFalse; + TInt retVal; + + ((CTScrModeStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); + switch(++iTest->iState) + { +/** + + @SYMTestCaseID GRAPHICS-WSERV-0296 + + @SYMDEF DEF081259 + + @SYMTestCaseDesc Test screen modes can be set while the screen is rotated + through 180 degrees. + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions Rotate the screen through 180 degrees while setting each + of the screen modes available + + @SYMTestExpectedResults The screen is rotated and screen modes set correctly + +*/ + case 1: + ((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0296")); + iTest->LogSubTest(_L("Orientation1")); + ScreenRotationsL(); + break; +/** + + @SYMTestCaseID GRAPHICS-WSERV-0297 + + @SYMDEF DEF081259 + + @SYMTestCaseDesc Change the screen orientation then test screen modes can + be set while the screen is rotated through 180 degrees. + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions Rotate the screen through 180 degrees while setting each + of the screen modes available + + @SYMTestExpectedResults The screen is rotated and screen modes set correctly + +*/ + case 2: + ((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0297")); + iTest->LogSubTest(_L("Orientation2")); + MoreScreenRotationsL(); + iSubState=0; + break; +/** + + @SYMTestCaseID GRAPHICS-WSERV-0298 + + @SYMDEF DEF081259 + + @SYMTestCaseDesc Test for the rect clear defect while setting screen mode + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions Change the screen mode and check the rect clear defect is + not present + + @SYMTestExpectedResults The defect is not present + +*/ + case 3: + ((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0298")); + iTest->LogSubTest(_L("Rect Clear Defect")); + RectClearBugL(); + break; + case 4: +/** + + @SYMTestCaseID GRAPHICS-WSERV-0299 + + @SYMDEF DEF081259 + + @SYMTestCaseDesc Test display mode can be set for test windows and + that the windows then function correctly + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions Set the display mode in two test windows and then call + methods on the windows + + @SYMTestExpectedResults The windows function correctly + +*/ + ((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0299")); + + iTest->LogSubTest(_L("ScreenModeChange")); + ScreenModeChange1L(); + ScreenModeChange2L(); + break; +/** + + @SYMTestCaseID GRAPHICS-WSERV-0300 + + @SYMDEF DEF081259 + + @SYMTestCaseDesc Test display mode can be set and retrieved + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions Set the display mode in a window and the retrieve it + + @SYMTestExpectedResults The display mode retrieved is the same as the + one set. + +*/ + case 5: + ((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0300")); + iTest->LogSubTest(KScreenModeDisplayMode); + GetScreenDisplayMode(); + break; + + +#if defined(SCREEN_MODE_TESTING) +/** + + @SYMTestCaseID GRAPHICS-WSERV-0301 + + @SYMDEF DEF081259 + + @SYMTestCaseDesc Case 101 to 105 tests that the screen is drawn correctly + as different screen modes and screen orientation are + set for the screen + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions Set different screen modes and orientations for the screen and + redraw the screen + + @SYMTestExpectedResults The screen is drawn correctly for each setting + +*/ + case 101: + ((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0301")); + iSubState = 0; + buf.Format(TRefByValue(_L("Screen mode %d:%d")),101,iSubState); + INFO_PRINTF1(buf); + checkWindowParam=ETrue; + mode=1; + if (iCurEnforcement==ESizeEnforcementPixelsAndRotation) + count+=3; + else if (iCurEnforcement==ESizeEnforcementPixelsTwipsAndRotation) + count+=6; + if (iSecondConnection->DeviceMessageCount()!=count) + { + TLogMessageText buf; + _LIT(KFailCount,"Event Mismatch, Exp=%d, Act=%d"); + buf.Format(KFailCount,count,iSecondConnection->DeviceMessageCount()); + TheClient->iWs.LogMessage(buf); + TheClient->iWs.Flush(); + } + retVal = iSecondConnection->DeviceMessageCount(); + TEST(retVal==count); + if (retVal!=count) + INFO_PRINTF3(_L("(iSecondConnection->DeviceMessageCount() return value - Expected: %d, Actual: %d"),count ,retVal); + + CheckWindows(iCurEnforcement==ESizeEnforcementNone?ETrue:checkWindowParam); + if (enable) + iSecondConnection->EnableMessages(); + if (disable) + iSecondConnection->DisableMessages(); + TheClient->iScreen->SetScreenMode(mode); + TheClient->iWs.Flush(); + iSubState++; + break; + case 102: +/** + @SYMTestCaseID GRAPHICS-WSERV-0521 +*/ + ((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0521")); + buf.Format(TRefByValue(_L("Screen mode %d:%d")),101,iSubState); + INFO_PRINTF1(buf); + checkWindowParam=EFalse; + enable=ETrue; + if (iCurEnforcement==ESizeEnforcementPixelsAndRotation) + count+=3; + else if (iCurEnforcement==ESizeEnforcementPixelsTwipsAndRotation) + count+=6; + if (iSecondConnection->DeviceMessageCount()!=count) + { + TLogMessageText buf; + _LIT(KFailCount,"Event Mismatch, Exp=%d, Act=%d"); + buf.Format(KFailCount,count,iSecondConnection->DeviceMessageCount()); + TheClient->iWs.LogMessage(buf); + TheClient->iWs.Flush(); + } + retVal = iSecondConnection->DeviceMessageCount(); + TEST(retVal==count); + if (retVal!=count) + INFO_PRINTF3(_L("(iSecondConnection->DeviceMessageCount() return value - Expected: %d, Actual: %d"),count ,retVal); + + if (enable) + iSecondConnection->EnableMessages(); + if (disable) + iSecondConnection->DisableMessages(); + TheClient->iScreen->SetScreenMode(mode); + TheClient->iWs.Flush(); + iSubState++; + break; + case 103: +/** + @SYMTestCaseID GRAPHICS-WSERV-0522 +*/ + ((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0522")); + buf.Format(TRefByValue(_L("Screen mode %d:%d")),101,iSubState); + INFO_PRINTF1(buf); + count=1; + mode=1; + checkWindowParam=ETrue; + if (iCurEnforcement==ESizeEnforcementPixelsAndRotation) + count+=3; + else if (iCurEnforcement==ESizeEnforcementPixelsTwipsAndRotation) + count+=6; + if (iSecondConnection->DeviceMessageCount()!=count) + { + TLogMessageText buf; + _LIT(KFailCount,"Event Mismatch, Exp=%d, Act=%d"); + buf.Format(KFailCount,count,iSecondConnection->DeviceMessageCount()); + TheClient->iWs.LogMessage(buf); + TheClient->iWs.Flush(); + } + retVal = iSecondConnection->DeviceMessageCount(); + TEST(retVal==count); + if (retVal!=count) + INFO_PRINTF3(_L("(iSecondConnection->DeviceMessageCount() return value - Expected: %d, Actual: %d"),count ,retVal); + + CheckWindows(iCurEnforcement==ESizeEnforcementNone?ETrue:checkWindowParam); + if (enable) + iSecondConnection->EnableMessages(); + if (disable) + iSecondConnection->DisableMessages(); + TheClient->iScreen->SetScreenMode(mode); + TheClient->iWs.Flush(); + iSubState++; + break; + case 104: +/** + @SYMTestCaseID GRAPHICS-WSERV-0523 +*/ + ((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0523")); + buf.Format(TRefByValue(_L("Screen mode %d:%d")),101,iSubState); + INFO_PRINTF1(buf); + checkWindowParam=ETrue; + count=2; + disable=ETrue; + if (iCurEnforcement==ESizeEnforcementPixelsAndRotation) + count+=3; + else if (iCurEnforcement==ESizeEnforcementPixelsTwipsAndRotation) + count+=6; + if (iSecondConnection->DeviceMessageCount()!=count) + { + TLogMessageText buf; + _LIT(KFailCount,"Event Mismatch, Exp=%d, Act=%d"); + buf.Format(KFailCount,count,iSecondConnection->DeviceMessageCount()); + TheClient->iWs.LogMessage(buf); + TheClient->iWs.Flush(); + } + retVal = iSecondConnection->DeviceMessageCount(); + TEST(retVal==count); + if (retVal!=count) + INFO_PRINTF3(_L("(iSecondConnection->DeviceMessageCount() return value - Expected: %d, Actual: %d"),count ,retVal); + + if (enable) + iSecondConnection->EnableMessages(); + if (disable) + iSecondConnection->DisableMessages(); + TheClient->iScreen->SetScreenMode(mode); + TheClient->iWs.Flush(); + iSubState++; + break; + case 105: +/** + @SYMTestCaseID GRAPHICS-WSERV-0524 +*/ + ((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0524")); + buf.Format(TRefByValue(_L("Screen mode %d:%d")),101,iSubState); + INFO_PRINTF1(buf); + checkWindowParam=EFalse; + count=2; + enable=ETrue; + if (iCurEnforcement==ESizeEnforcementPixelsAndRotation) + count+=3; + else if (iCurEnforcement==ESizeEnforcementPixelsTwipsAndRotation) + count+=6; + if (iSecondConnection->DeviceMessageCount()!=count) + { + TLogMessageText buf; + _LIT(KFailCount,"Event Mismatch, Exp=%d, Act=%d"); + buf.Format(KFailCount,count,iSecondConnection->DeviceMessageCount()); + TheClient->iWs.LogMessage(buf); + TheClient->iWs.Flush(); + } + retVal = iSecondConnection->DeviceMessageCount(); + TEST(retVal==count); + if (retVal!=count) + INFO_PRINTF3(_L("(iSecondConnection->DeviceMessageCount() return value - Expected: %d, Actual: %d"),count ,retVal); + + CheckWindows(iCurEnforcement==ESizeEnforcementNone?ETrue:checkWindowParam); + if (enable) + iSecondConnection->EnableMessages(); + if (disable) + iSecondConnection->DisableMessages(); + TheClient->iScreen->SetScreenMode(mode); + TheClient->iWs.Flush(); + + + iSecondConnection->DisableMessages(); + if (iCurEnforcement==ESizeEnforcementNone) + { // Do it again with different enforcement mode + SetScreenModeEnforcement(ESizeEnforcementPixelsAndRotation); + ResetCounter(100); + } + else if (iCurEnforcement==ESizeEnforcementPixelsAndRotation) + { // Do it again with different enforcement mode + SetScreenModeEnforcement(ESizeEnforcementPixelsTwipsAndRotation); + ResetCounter(100); + } + else + { + SetScreenModeEnforcement(ESizeEnforcementNone); + delete iSecondConnection; + iSecondConnection=NULL; + } + TheClient->iWs.Flush(); + break; +/** + + @SYMTestCaseID GRAPHICS-WSERV-0302 + + @SYMDEF DEF099638 + + @SYMTestCaseDesc Test that a drawing can be scaled while different screen + modes are set + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions Set different screen modes and scale a drawing + + @SYMTestExpectedResults The drawing is redrawn to scale + +*/ + case 110: + { + ((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0302")); + // Ensure that the TestWin and BaseWin will be drawn properly in all screen modes + SetScreenModeEnforcement(ESizeEnforcementPixelsAndRotation); + TheClient->SetTestClientScreenMode(0); + INFO_PRINTF1(_L("Scaled drawing - screen mode 0")); + ScaledDrawingL(); + TheClient->SetTestClientScreenMode(1); + INFO_PRINTF1(_L("Scaled drawing - screen mode 1")); + ScaledDrawingL(); + // Restore screen mode and enforcement mode + TheClient->SetTestClientScreenMode(0); + SetScreenModeEnforcement(iOldEnfMode); + break; + } + +/** + + @SYMTestCaseID GRAPHICS-WSERV-0303 + + @SYMDEF DEF081259 + + @SYMTestCaseDesc Test screen mode and rotation panic messages + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions Test the panics fro screen mode and rotation respond as + expected + + @SYMTestExpectedResults Panics respond as expected + +*/ + case 111: + ((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0303")); + INFO_PRINTF1(_L("Panic")); + TestPanicsL(); + break; +#endif +/** + + @SYMTestCaseID GRAPHICS-WSERV-0304 + + @SYMDEF DEF081259 + + @SYMTestCaseDesc Test that if there are invisible windows and then the + screen mode is changed, the windows are redrawn correctly + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions Create some windows, make some invisible, change the screen + mode and redraw the windows + + @SYMTestExpectedResults The windows are redrawn without error + +*/ + case 112: + ((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0304")); + INFO_PRINTF1(_L("Invisible Wnds And Infinite Redraw Bugs")); // two defects one problem + InvisibleWndAndInfiniteRedrawBugL(); + break; +/** + + @SYMTestCaseID GRAPHICS-WSERV-0358 + + @SYMDEF PDEF096151 + + @SYMTestCaseDesc Ensure that wserv does not panic when calling CWsScreenDevice::SetScreenMode() + after a client has deleted a screen device used by an active group window + + @SYMTestPriority Critical + + @SYMTestStatus Implemented + + @SYMTestActions Creates a RWsSession + Creates a primary screen device + Creates another screen device + Creates a group window + Gets all the valid screen modes + Deletes the primary screen device + Calls SetScreenMode on the second screen device + (this step triggered the defect - panicking wserv) + Cleans up the above + + @SYMTestExpectedResults The call to SetScreenMode should not cause wserv to panic + +*/ + case 113: + ((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0358")); + INFO_PRINTF1(_L("Set screen mode after a client has deleted the screen device")); + SetScreenModeAfterScreenDeviceDeletedL(); + break; + case 114: + INFO_PRINTF1(_L("Rotate/screen mode test")); +/** + @SYMTestCaseID GRAPHICS-WSERV-0525 +*/ + ((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0525")); + TestRotateAndScreenModeL(); + break; + default: + ((CTScrModeStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + if (iTest->iState==115 || iTest->iState>1000) + TestComplete(); + break; + } + ((CTScrModeStep*)iStep)->RecordTestResultL(); + } + +// +// CSecondConnection +// + +CSecondConnection::~CSecondConnection() + { + delete iWindow; + delete iWindow2; + iGroup->GroupWin()->EnableReceiptOfFocus(EFalse); // Stop auto group switching on close + delete iGroup; + delete iClient; + } + +void CSecondConnection::ConstructL(TInt aScreenNumber,const TRect &aWinRect, CTestBase *aTest, CTestStep* aTestStep) + { + iClient=new(ELeave) CTClient; + iClient->SetScreenNumber(aScreenNumber); + iClient->ConstructL(); + iGroup=new(ELeave) CSecondConnectionGroup(iClient,this,aTest,aTestStep); + iGroup->ConstructL(); +// + iWindow=new(ELeave) CTBlankWindow; + iWindow->ConstructL(*iGroup); + iWindow->BaseWin()->SetShadowDisabled(ETrue); + iWindow->SetColor(TRgb::Gray4(1)); + TPoint offset=BaseWin->BaseWin()->InquireOffset((*iGroup->GroupWin())); + iWindow->SetExtL(offset+aWinRect.iTl,aWinRect.Size()); + iWindow->Activate(); +// + iWindow2=new(ELeave) CTBlankWindow; + iWindow2->ConstructL(*iGroup); + iWindow2->BaseWin()->SetShadowDisabled(ETrue); + iWindow2->SetColor(TRgb::Gray4(1)); + TPoint offset2=TestWin->BaseWin()->InquireOffset((*iGroup->GroupWin())); + iWindow2->SetExtL(offset2+aWinRect.iTl,aWinRect.Size()); + iWindow2->BaseWin()->SetVisible(EFalse); + iWindow2->Activate(); + } + +void CSecondConnection::SetWindow2Visibility(TBool aVisible) + { + iWindow2->BaseWin()->SetVisible(aVisible); + iClient->iWs.Flush(); + iClient->iWs.Finish(); + } + +void CSecondConnection::EnableMessages() + { + iGroup->GroupWin()->EnableScreenChangeEvents(); + iClient->iWs.Flush(); + } + +void CSecondConnection::DisableMessages() + { + iGroup->GroupWin()->DisableScreenChangeEvents(); + iClient->iWs.Flush(); + } + +TInt CSecondConnection::DeviceMessageCount() const + { + return(iMessageCount); + } + +void CSecondConnection::ScreenDeviceChanged() + { + iMessageCount++; + } + +// +// CSecondConnectionGroup +// + +CSecondConnectionGroup::CSecondConnectionGroup(CTClient *aClient, CSecondConnection *aSecondConnection, CTestBase *aTest, CTestStep* aTestStep) : CTWindowGroup(aClient), iTest(aTest), iSecondConnection(aSecondConnection), iTestStep(aTestStep) + {} + +void CSecondConnectionGroup::ScreenDeviceChanged() + { + iSecondConnection->ScreenDeviceChanged(); + TPixelsTwipsAndRotation sar; + Client()->iScreen->GetDefaultScreenSizeAndRotation(sar); + Client()->iScreen->SetScreenSizeAndRotation(sar); +// + iTestStep->TEST(Client()->iScreen->SizeInPixels()==sar.iPixelSize); + iTestStep->TEST(Client()->iScreen->SizeInTwips()==sar.iTwipsSize); + TSize pixelConv; + pixelConv.iWidth=Client()->iScreen->HorizontalTwipsToPixels(sar.iTwipsSize.iWidth); + pixelConv.iHeight=Client()->iScreen->VerticalTwipsToPixels(sar.iTwipsSize.iHeight); + iTestStep->TEST(pixelConv==sar.iPixelSize); + } + + +// +// SecondClientConnection +// + +SecondClientConnection::SecondClientConnection() + { + } + +SecondClientConnection::~SecondClientConnection() + { + } + +void SecondClientConnection::ConstructL(TInt aScreenMode, const TPixelsTwipsAndRotation& aSizeAndRotation) + { + CTClient::ConstructL(); + iGroup=new(ELeave) TestWindowGroup(this); + iGroup->ConstructL(); + iScreen->SetScreenModeEnforcement(ESizeEnforcementPixelsAndRotation); + iScreen->SetScreenSizeAndRotation(aSizeAndRotation); + iScreen->SetScreenMode(aScreenMode); + } + +__WS_CONSTRUCT_STEP__(ScrMode) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TSCRMODE.H --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TSCRMODE.H Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,128 @@ + +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef __TSCRMODE_H__ +#define __TSCRMODE_H__ + +#include +#include +#include "../tlib/testbase.h" +#include "AUTO.H" +#include "TGraphicsHarness.h" + +class CSecondConnection; + +class CSecondConnectionGroup : public CTWindowGroup + { +public: + CSecondConnectionGroup(CTClient *aClient, CSecondConnection *aSecondConnection, CTestBase *aTest, CTestStep* aTestStep); + void ScreenDeviceChanged(); +private: + CTestBase *iTest; + CSecondConnection *iSecondConnection; + CTestStep* iTestStep; + }; + +class CSecondConnection : public CBase + { +public: + ~CSecondConnection(); + void ConstructL(TInt aScreenNumber,const TRect &aWinRect, CTestBase *aTest, CTestStep* aTestStep); + void EnableMessages(); + void DisableMessages(); + TInt DeviceMessageCount() const; + void ScreenDeviceChanged(); + void SetWindow2Visibility(TBool aVisible); +public: + CSecondConnectionGroup *iGroup; +private: + CTClient *iClient; + CTBlankWindow *iWindow; + CTBlankWindow *iWindow2; + TInt iMessageCount; + }; + +class SecondClientConnection : public CTClient + { +public: + SecondClientConnection(); + ~SecondClientConnection(); + void ConstructL(TInt aScreenMode, const TPixelsTwipsAndRotation &aSizeAndRotation); + }; + +class CTScrMode : public CTWsGraphicsBase + { +public: + CTScrMode(CTestStep* aStep); + ~CTScrMode(); +protected: +//from CTGraphicsStep + virtual void RunTestCaseL(TInt aCurTestCase); +private: + void ConstructL(); + void doMoveWindowTest(); + TBool MoveWindow(); + void TestPanicsL(); + void ScaledDrawingL(); + void SetScreenModeEnforcement(TScreenModeEnforcement aMode); + void CheckWindows(TBool aWinIsVis); + void ValidateWin(TestWindow *aWin, TRgb aColor); + void RedrawWin(RWindow &aWin, TRgb aColor); + void ScreenRotationsL(); + void MoreScreenRotationsL(); + TBool RectClearBugL(); + void ScreenModeChange1L(); + void ScreenModeChange2L(); + TInt FindCurrentMode(); + TBool Equal(const TPixelsTwipsAndRotation& aLeft,const TPixelsTwipsAndRotation& aRight); + void InvisibleWndAndInfiniteRedrawBugL(); + void GetScreenDisplayMode(); + void SetScreenModeAfterScreenDeviceDeletedL(); + void TestRotateAndScreenModeL(); +private: + void DrawTestBmpL(CFbsBitmap* aTestBitmap); + void TestDrawingToWindows(CWindowGc* aWinGc1, CWindowGc* aWinGc2, RWindow& aWindow1,RWindow& aWindow2,CFbsBitmap* aBitmap64K,CFbsBitmap* aBitmap16M,CFbsFont* aFont,TBool aAllInRedraw, TBool aUseSystemGc, TBool aUseBmp16M); +private: + TInt iSubState; + CSecondConnection *iSecondConnection; + TSize iWinSize; + TPoint iWinPos; + TInt iWinState; + TScreenModeEnforcement iOldEnfMode; + TScreenModeEnforcement iCurEnforcement; + }; + + + +class CTScrModeStep : public CTGraphicsStep + { +public: + CTScrModeStep(); +protected: + //from CTGraphicsStep + virtual CTGraphicsBase* CreateTestL(); + }; + +_LIT(KTScrModeStep,"TScrMode"); + + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TSCROLL.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TSCROLL.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,850 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Window scroll tests +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include "TSCROLL.H" + +#pragma warning(disable : 4710) + +// +// Scroll window, used to test the Scroll() command +// + +void DrawScrollWin(CBitmapContext *aGc, const TPoint &aOffset, const TSize &aSize) + { + aGc->Clear(); + TPoint drawBase(-10,-20); + TSize drawSize(aSize.iWidth-2*drawBase.iX,aSize.iHeight-2*drawBase.iY); + aGc->DrawRect(TRect(drawBase,drawBase+drawSize)); + TPoint offset=drawBase+aOffset; + aGc->SetPenColor(TRgb::Gray4(2)); +// aGc->SetDrawMode(CGraphicsContext::EDrawModeXOR); + aGc->DrawRect(TRect(offset+TPoint(13,23),offset+TPoint(22,32))); + TInt xpos,xplus; + for(xpos=0,xplus=2;xposDrawLine(TPoint(xpos,0)+offset,TPoint(xpos,drawSize.iHeight)+offset); + for(TInt ypos=0,yplus=2;yposDrawLine(TPoint(0,ypos)+offset,TPoint(drawSize.iWidth,ypos)+offset); +// + aGc->SetPenColor(TRgb(0,0,0)); + aGc->SetDrawMode(CGraphicsContext::EDrawModePEN); + TheClient->iWs.Flush(); + for(xpos=0;xposDrawLine(TPoint(xpos,0)+offset,TPoint(drawSize.iWidth,xpos*drawSize.iHeight/drawSize.iWidth)+offset); + aGc->DrawLine(TPoint(xpos,0)+offset,TPoint(0,drawSize.iHeight-xpos*drawSize.iHeight/drawSize.iWidth)+offset); + aGc->DrawLine(TPoint(xpos,drawSize.iHeight)+offset,TPoint(drawSize.iWidth,drawSize.iHeight-xpos*drawSize.iHeight/drawSize.iWidth)+offset); + aGc->DrawLine(TPoint(xpos,drawSize.iHeight)+offset,TPoint(0,xpos*drawSize.iHeight/drawSize.iWidth)+offset); + } + + } + +CScrollWindowNorm::CScrollWindowNorm() : CTWin() + { + } + +void DrawScrollWin(const TPoint &aOffset, const TSize &aSize) + { + ::DrawScrollWin(TheClient->iGc, aOffset, aSize); + } + +void CScrollWindowNorm::Draw() + { + DrawScrollWin(iScrollTest->Offset(), Size()); + } + +void CScrollWindowNorm::SetScrollTest(CScrollTestBase *aScrollTest) + { + iScrollTest=aScrollTest; + } + +// +// CScrollWindowBackedUp +// + +CScrollWindowBackedUp::CScrollWindowBackedUp(TDisplayMode aDisplayMode) : CTBackedUpWin(aDisplayMode) + { + } + +void CScrollWindowBackedUp::Draw() + { + DrawScrollWin(iScrollTest->Offset(), Size()); + } + +void CScrollWindowBackedUp::SetScrollTest(CScrollTestBase *aScrollTest) + { + iScrollTest=aScrollTest; + } + +// +// CScrollTestBase +// + +void CScrollTestBase::Reset() + { + iOffset=TPoint(0,0); + iInvalid.Clear(); + } + +void CScrollTestBase::DoInvalidate() + { + } + +TPoint CScrollTestBase::Offset() const + { + return(iOffset); + } + +CScrollTestBase::~CScrollTestBase() + { + delete iBlankWin; + iInvalid.Close(); + } + +void CScrollTestBaseNorm::ConstructL(const TPoint &aPos, const TSize &aSize) + { + iScrollWin=new(ELeave) CScrollWindowNorm(); + iScrollWin->SetUpL(aPos, aSize, TheClient->iGroup, *TheClient->iGc); + iScrollWin->SetScrollTest(this); + iSize=iScrollWin->Size(); + } + +CScrollTestBaseNorm::~CScrollTestBaseNorm() + { + delete iScrollWin; + } + +void CScrollTestBaseNorm::Redraw() + { + iScrollWin->Redraw(); + } + +void CScrollTestBaseNorm::Reset() + { + iScrollWin->Win()->Invalidate(); + iScrollWin->Redraw(); + CScrollTestBase::Reset(); + } + +CTDrawableWin *CScrollTestBaseNorm::ScrollWin() const + { + return(iScrollWin); + } + +void CScrollTestBaseNorm::AdjustTestScrollRegion(const TRect &aClipRect, const TPoint &aOffset, const TRect &aRect) + { + RRegion clipped_visible; + VisibleRegion(clipped_visible); + clipped_visible.ClipRect(aClipRect); +// +// + RRegion invalidate(aRect); + invalidate.SubRegion(clipped_visible); + invalidate.Offset(aOffset); + invalidate.ClipRect(aClipRect); +// + RRegion invalidate2(aRect); + invalidate2.ClipRect(aClipRect); + invalidate2.Intersect(iInvalid); + invalidate2.Offset(aOffset); + invalidate2.ClipRect(aClipRect); +// + RRegion validate(aRect); + validate.Intersect(clipped_visible); + validate.SubRegion(iInvalid); + validate.Offset(aOffset); + validate.ClipRect(aClipRect); +// + iInvalid.SubRegion(validate); + iInvalid.Union(invalidate); + iInvalid.Union(invalidate2); + RRegion visible; + VisibleRegion(visible); + iInvalid.Intersect(visible); + iInvalid.Tidy(); +// + invalidate2.Close(); + invalidate.Close(); + validate.Close(); + visible.Close(); + clipped_visible.Close(); + + iOffset+=aOffset; + } + +void CScrollTestBaseNorm::VisibleRegion(RRegion &aRegion) + { + aRegion.Clear(); + aRegion.AddRect(TRect(iSize)); + TRect child; + child.iTl=iBlankWin->BaseWin()->InquireOffset(*ScrollWin()->BaseWin()); + child.iBr=child.iTl+iBlankWin->BaseWin()->Size(); + aRegion.SubRect(child); + } + +void CScrollWindow1::DoTestScroll(const TRect &aClipRect, const TPoint &aOffset, const TRect &aRect) + { + TheGc->Activate(*iScrollWin->DrawableWin()); + RRegion region(aRect); + RRegion visible; + VisibleRegion(visible); + visible.ClipRect(aClipRect); + region.Intersect(visible); + visible.Close(); + region.SubRegion(iInvalid); + region.Offset(aOffset); + region.ClipRect(aClipRect); + TheGc->SetClippingRegion(region); + TheGc->CopyRect(aOffset,aRect); + TheGc->Deactivate(); + AdjustTestScrollRegion(aClipRect, aOffset,aRect); + iInvalid.Union(TRegionFix<1>(TRect(aClipRect))); + region.Close(); + } + +void CScrollWindow1::DoTestScroll(const TPoint &aOffset) + { + DoTestScroll(TRect(TPoint(0,0),iSize), aOffset,TRect(-aOffset,iSize)); + } + +void CScrollWindow1::DoTestScroll(const TPoint &aOffset, const TRect &aRect) + { + DoTestScroll(TRect(TPoint(0,0),iSize), aOffset, aRect); + } + +void CScrollWindow1::DoTestScroll(const TRect &aClipRect, const TPoint &aOffset) + { + DoTestScroll(aClipRect, aOffset, TRect(-aOffset.iX,-aOffset.iY,iSize.iWidth-aOffset.iX, iSize.iHeight-aOffset.iY)); + } + +void CScrollWindow1::DoInvalidate() + { + for(TInt index=0;indexInvalidate(iInvalid[index]); + } + +void CScrollWindow2::Reset() + { + CScrollTestBaseNorm::Reset(); + iClipped=EFalse; + } + +CScrollWindow2::CScrollWindow2(CTScroll *aTest) : iTest(aTest) + { + } + +void CScrollWindow2::Draw() + { + if (iClipped) + TheClient->iGc->SetClippingRegion(iInvalid); + iScrollWin->Draw(); + if (iClipped) + TheClient->iGc->CancelClippingRegion(); + } + +void CScrollWindow2::DoTestScroll(const TPoint &aOffset) + { + AdjustTestScrollRegion(TRect(iSize), aOffset, TRect(-aOffset.iX,-aOffset.iY,iSize.iWidth-aOffset.iX, iSize.iHeight-aOffset.iY)); + iClipped=ETrue; + iScrollWin->DrawableWin()->Scroll(aOffset); + } + +void CScrollWindow2::DoTestScroll(const TRect &aClipRect, const TPoint &aOffset) + { + AdjustTestScrollRegion(aClipRect, aOffset, TRect(-aOffset.iX,-aOffset.iY,iSize.iWidth-aOffset.iX, iSize.iHeight-aOffset.iY)); + iClipped=ETrue; + iScrollWin->DrawableWin()->Scroll(aClipRect, aOffset); + } + +void CScrollWindow2::DoTestScroll(const TPoint &aOffset, const TRect &aRect) + { + AdjustTestScrollRegion(TRect(iSize), aOffset, aRect); + iClipped=ETrue; + iScrollWin->DrawableWin()->Scroll(aOffset, aRect); + } + +void CScrollWindow2::DoTestScroll(const TRect &aClipRect, const TPoint &aOffset, const TRect &aRect) + { + AdjustTestScrollRegion(aClipRect, aOffset, aRect); + iClipped=ETrue; + iScrollWin->DrawableWin()->Scroll(aClipRect, aOffset, aRect); + } + +void CScrollWindow3::DrawScrollBit() + { + ::DrawScrollWin(iBitmapGc, iOffset, iSize); + } + +void CScrollWindow3::Reset() + { + CScrollTestBase::Reset(); + iBitmapGc->Clear(TRect(iSize)); + DrawScrollBit(); + DoInvalidate(); + } + +CScrollWindow3::~CScrollWindow3() + { + delete iBitmapGc; + delete iBitmapDevice; + delete iBitmap; + } + +void CScrollWindow3::ConstructL(const TPoint &aPos, const TSize &aSize) + { + CScrollTestBaseNorm::ConstructL(aPos,aSize); + iBitmap=new(ELeave) CFbsBitmap(); + User::LeaveIfError(iBitmap->Create(iSize,EGray4)); + iBitmapDevice=CFbsBitmapDevice::NewL(iBitmap); + User::LeaveIfError(iBitmapDevice->CreateContext(iBitmapGc)); + DrawScrollBit(); + } + +void CScrollWindow3::DoTestScroll(const TRect &aClipRect, const TPoint &aOffset, const TRect &aRect) + { + iOffset+=aOffset; + RRegion blank(aRect); + TRect clipRect(aClipRect); + clipRect.Intersection(TRect(iSize)); + blank.SubRect(clipRect); + blank.Offset(aOffset); + blank.ClipRect(clipRect); + TRect rect(aRect); + rect.Intersection(clipRect); + TRect rect2(clipRect); + rect2.Move(-aOffset); + rect.Intersection(rect2); + iBitmapGc->CopyRect(aOffset,rect); + iBitmapGc->SetClippingRegion(&blank); + iBitmapGc->Clear(TRect(iSize)); + iBitmapGc->SetClippingRegion(NULL); + blank.Close(); + } + +void CScrollWindow3::DoTestScroll(const TPoint &aOffset) + { + DoTestScroll(TRect(iSize), aOffset,TRect(-aOffset.iX,-aOffset.iY,iSize.iWidth-aOffset.iX, iSize.iHeight-aOffset.iY)); + } + +void CScrollWindow3::DoTestScroll(const TPoint &aOffset, const TRect &aRect) + { + DoTestScroll(TRect(iSize), aOffset, aRect); + } + +void CScrollWindow3::DoTestScroll(const TRect &aClipRect, const TPoint &aOffset) + { + DoTestScroll(aClipRect, aOffset, TRect(-aOffset.iX,-aOffset.iY,iSize.iWidth-aOffset.iX, iSize.iHeight-aOffset.iY)); + } + +void CScrollWindow3::Draw() + { + TheGc->BitBlt(TPoint(),iBitmap); + } + +void CScrollWindow3::DoInvalidate() + { + RWindow win=*iScrollWin->Win(); + win.Invalidate(); + win.BeginRedraw(); + TheGc->Activate(win); + Draw(); + TheGc->Deactivate(); + win.EndRedraw(); + } + +void CScrollWindow4::ConstructL(const TPoint &aPos, const TSize &aSize) + { + iScrollWin=new(ELeave) CScrollWindowBackedUp(EGray4); + iScrollWin->SetUpL(aPos, aSize, TheClient->iGroup, *TheClient->iGc); + iScrollWin->SetScrollTest(this); + iSize=iScrollWin->Size(); + TheClient->iGc->Activate(*iScrollWin->DrawableWin()); + TheClient->iGc->Clear(); + DrawScrollWin(TPoint(), iSize); + TheClient->iGc->Deactivate(); + } + +CScrollWindow4::~CScrollWindow4() + { + delete iScrollWin; + } + +void CScrollWindow4::Redraw() + { + } + +void CScrollWindow4::Reset() + { + TheClient->iGc->Activate(*iScrollWin->DrawableWin()); + TheClient->iGc->Clear(); + DrawScrollWin(TPoint(), iSize); + TheClient->iGc->Deactivate(); + CScrollTestBase::Reset(); + } + +void CScrollWindow4::DoTestScroll(const TPoint &aOffset) + { + iScrollWin->DrawableWin()->Scroll(aOffset); + iOffset+=aOffset; + } + +void CScrollWindow4::DoTestScroll(const TPoint &aOffset, const TRect &aRect) + { + iScrollWin->DrawableWin()->Scroll(aOffset, aRect); + iOffset+=aOffset; + } + +void CScrollWindow4::DoTestScroll(const TRect &aClipRect, const TPoint &aOffset) + { + iScrollWin->DrawableWin()->Scroll(aClipRect, aOffset); + iOffset+=aOffset; + } + +void CScrollWindow4::DoTestScroll(const TRect &aClipRect, const TPoint &aOffset, const TRect &aRect) + { + iScrollWin->DrawableWin()->Scroll(aClipRect, aOffset, aRect); + iOffset+=aOffset; + } + +CTDrawableWin *CScrollWindow4::ScrollWin() const + { + return(iScrollWin); + } + +// + +CTScroll::CTScroll(CTestStep* aStep): + CTWsGraphicsBase(aStep) + { + } + +CTScroll::~CTScroll() + { + BaseWin->SetVisible(ETrue); + TestWin->SetVisible(ETrue); + delete iBaseScrollWin; + delete iTestScrollWin; + } + +void CTScroll::ConstructL() + { + BaseWin->SetVisible(EFalse); + TestWin->SetVisible(EFalse); +// + iTest->iState=1; + TSize screenSize=TheClient->iGroup->Size(); + TInt winWidth=(screenSize.iWidth/3)-10; + TInt winHeight=screenSize.iHeight-10; + TInt winBaseX=(screenSize.iWidth/3); + if (iMode==0) + { + iBaseScrollWin=new(ELeave) CScrollWindow1(); + iTestScrollWin=new(ELeave) CScrollWindow2(this); + } + else + { + iBaseScrollWin=new(ELeave) CScrollWindow3(); + iTestScrollWin=new(ELeave) CScrollWindow4(); + } + iWinSize=TSize(winWidth,winHeight); + iBaseScrollWin->ConstructL(TPoint(winBaseX+5,5),iWinSize); + iTestScrollWin->ConstructL(TPoint(winBaseX+winWidth+15,5),iWinSize); + + iBaseScrollWin->iBlankWin=new(ELeave) CTBlankWindow(); + iBaseScrollWin->iBlankWin->SetUpL(iBaseScrollWin->ScrollWin()->BaseWin()->InquireOffset(*TheClient->iGroup->GroupWin())+TPoint(winWidth>>2,winHeight>>2),TSize(winWidth>>2,winHeight>>1),TheClient->iGroup,*TheClient->iGc); + iBaseScrollWin->iBlankWin->BlankWin()->SetShadowHeight(2); + + iTestScrollWin->iBlankWin=new(ELeave) CTBlankWindow(); + iTestScrollWin->iBlankWin->SetUpL(iTestScrollWin->ScrollWin()->BaseWin()->InquireOffset(*TheClient->iGroup->GroupWin())+TPoint(winWidth>>2,winHeight>>2),TSize(winWidth>>2,winHeight>>1),TheClient->iGroup,*TheClient->iGc); + } + +void CTScroll::CheckScrollWindows() + { + CheckRect(iBaseScrollWin->ScrollWin(),iTestScrollWin->ScrollWin(),TRect(iBaseScrollWin->ScrollWin()->Size()),_L("CTScroll::CheckScrollWindows()")); + } + +void CTScroll::DoTestScroll(const TPoint &aOffset) + { + iTestScrollWin->DoTestScroll(aOffset); + iBaseScrollWin->DoTestScroll(aOffset); + } + +void CTScroll::DoTestScroll(const TRect &aClipRect, const TPoint &aOffset) + { + iTestScrollWin->DoTestScroll(aClipRect,aOffset); + iBaseScrollWin->DoTestScroll(aClipRect,aOffset); + } + +void CTScroll::DoTestScroll(const TPoint &aOffset, const TRect &aRect) + { + iTestScrollWin->DoTestScroll(aOffset,aRect); + iBaseScrollWin->DoTestScroll(aOffset,aRect); + } + +void CTScroll::DoTestScroll(const TRect &aClipRect, const TPoint &aOffset, const TRect &aRect) + { + iTestScrollWin->DoTestScroll(aClipRect,aOffset,aRect); + iBaseScrollWin->DoTestScroll(aClipRect,aOffset,aRect); + } + +void CTScroll::FinishedRectScrolls() + { + iBaseScrollWin->DoInvalidate(); + } + +void CTScroll::CheckOomScroll() + { + TheClient->iWs.HeapSetFail(RHeap::ENone,0); + FinishedRectScrolls(); + iTestScrollWin->Redraw(); + iBaseScrollWin->Redraw(); +// if (iMode!=1) // Out of memory scrolling of backed up windows can not work 100% when out of memory +// CheckScrollWindows(); // Redraw window code can't check these cases properly yet + } + +void CTScroll::OomScrolling() + { + iTestScrollWin->iBlankWin->BaseWin()->SetShadowHeight(0); + iBaseScrollWin->iBlankWin->BaseWin()->SetShadowHeight(0); + iTestScrollWin->ScrollWin()->BaseWin()->SetShadowHeight(0); + iTestScrollWin->Redraw(); + iBaseScrollWin->Redraw(); + for(TInt count=1;count<20;count++) + { + TheClient->iWs.HeapSetFail(RHeap::EDeterministic,count); + DoTestScroll(TPoint(50,0)); + CheckOomScroll(); + // + TheClient->iWs.HeapSetFail(RHeap::EDeterministic,count); + iTestScrollWin->Reset(); + iBaseScrollWin->Reset(); + DoTestScroll(TPoint(-6,-14),TRect(20,20,100,50)); + CheckOomScroll(); + // + TheClient->iWs.HeapSetFail(RHeap::EDeterministic,count); + iTestScrollWin->Reset(); + iBaseScrollWin->Reset(); + DoTestScroll(TRect(TPoint(1,1),iWinSize-TSize(1,1)),TPoint(50,0),TRect(10,10,50,50)); + CheckOomScroll(); + } + } + +void CTScroll::RunTestCaseL(TInt /*aCurTestCase*/) + { + _LIT(KScroll,"Scroll"); + //if (iTest->iState==0) iTest->iState=22; + if (iDoCheck) + { + if (iMode==1) // The test code does not mimic scrolling to a non-backed up window properly + { + TheClient->iWs.Flush(); + TheClient->iWs.Finish(); + CheckScrollWindows(); + } + iTestScrollWin->Reset(); + iBaseScrollWin->Reset(); + TheClient->iWs.Flush(); + ++iTest->iState; + iDoCheck=EFalse; + return; + } + ((CTScrollStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); + switch(iTest->iState) + { +/** +@SYMTestCaseID GRAPHICS-WSERV-0249 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test window scrolling by different offsets + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Pass different offsets for scrolling a window by and + check the window is scrolled correctly + +@SYMTestExpectedResults Window scrolls correctly to offsets +*/ + case 1: + ((CTScrollStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0249")); + //DemoWindowScroll(); + iTest->LogSubTest(KScroll); + DoTestScroll(TPoint(6,0)); + DoTestScroll(TPoint(-6,-14)); + DoTestScroll(TPoint(-6,-14)); + DoTestScroll(TPoint(0,10)); + DoTestScroll(TPoint(0,0)); + DoTestScroll(TPoint(10,23)); + break; + case 2: + ((CTScrollStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0249")); + iTest->LogSubTest(KScroll); + DoTestScroll(TPoint(50,0)); + break; + case 3: + ((CTScrollStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0249")); + iTest->LogSubTest(KScroll); + DoTestScroll(TPoint(0,33)); + break; + case 4: + ((CTScrollStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0249")); + iTest->LogSubTest(KScroll); + DoTestScroll(TPoint(-10,0)); + break; + case 5: + ((CTScrollStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0249")); + iTest->LogSubTest(KScroll); + DoTestScroll(TPoint(0,-13)); + break; + case 6: + ((CTScrollStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0249")); + iTest->LogSubTest(KScroll); + DoTestScroll(TPoint(0,0)); + break; + case 7: + ((CTScrollStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0249")); + iTest->LogSubTest(KScroll); + DoTestScroll(TPoint(-234,-1400)); + break; + case 8: + ((CTScrollStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0249")); + iTest->LogSubTest(KScroll); + DoTestScroll(TPoint(-69,15)); + break; + case 9: + ((CTScrollStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0249")); + iTest->LogSubTest(KScroll); + DoTestScroll(TPoint(-234,-1400)); + DoTestScroll(TPoint(233,1401)); + break; + case 10: + ((CTScrollStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0249")); + iTest->LogSubTest(KScroll); + DoTestScroll(TPoint(10,-1)); + DoTestScroll(TPoint(11,-10)); + DoTestScroll(TPoint(-5,-40)); + DoTestScroll(TPoint(0,50)); + break; + +/** +@SYMTestCaseID GRAPHICS-WSERV-0250 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test window scrolling by different offsets and + source rectangles + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Pass different offsets for scroll a window by and + different source rectangles. + Check the window is scrolled correctly + +@SYMTestExpectedResults Window scrolls correctly to offsets and source + rectangles +*/ + case 11: + ((CTScrollStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0250")); + iTest->LogSubTest(KScroll); + DoTestScroll(TPoint(-6,-14),TRect(20,20,100,50)); + DoTestScroll(TPoint(-6,-14),TRect(20,20,100,50)); + DoTestScroll(TPoint(-6,-14),TRect(40,10,130,130)); + break; + case 12: + ((CTScrollStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0250")); + iTest->LogSubTest(KScroll); + DoTestScroll(TPoint(10,-1),TRect(20,20,21,21)); + break; + case 13: + ((CTScrollStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0250")); + iTest->LogSubTest(KScroll); + DoTestScroll(TPoint(-20,-14),TRect(10,10,10,10)); + break; + case 14: + ((CTScrollStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0250")); + iTest->LogSubTest(KScroll); + DoTestScroll(TPoint(-6,-14),TRect(20,20,200,300)); + DoTestScroll(TPoint(10,-24),TRect(20,20,200,300)); + DoTestScroll(TPoint(3,12),TRect(20,20,200,300)); + DoTestScroll(TPoint(-20,19),TRect(20,20,200,300)); + break; + case 15: + ((CTScrollStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0250")); + iTest->LogSubTest(KScroll); + DoTestScroll(TPoint(-6,-14),TRect(20000,200000,30000,300000)); + DoTestScroll(TPoint(10,-24),TRect(20,20,-200,-300)); + DoTestScroll(TPoint(10,-24),TRect(20,20,-200,300)); + DoTestScroll(TPoint(10,-24),TRect(20,20,200,-300)); + DoTestScroll(TPoint(3,12),TRect(-100,-200,1000,2000)); + DoTestScroll(TPoint(-20,19),TRect(0,0,0,0)); + break; + +/** +@SYMTestCaseID GRAPHICS-WSERV-0251 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test window scrolling by different offsets and + clipping rectangles + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Pass different offsets for scroll a window by and + different clipping rectangles. + Check the window is scrolled correctly + +@SYMTestExpectedResults Window scrolls correctly to offsets and clipping + rectangles +*/ + case 16: + ((CTScrollStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0251")); + iTest->LogSubTest(KScroll); + DoTestScroll(TRect(10,10,200,200),TPoint(-6,-14)); + break; + case 17: + ((CTScrollStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0251")); + iTest->LogSubTest(KScroll); + DoTestScroll(TRect(10,50,210,200),TPoint(10,20)); + DoTestScroll(TRect(0,0,100,100),TPoint(-22,4)); + DoTestScroll(TRect(50,50,300,500),TPoint(-5,-2)); + break; + case 18: + ((CTScrollStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0251")); + iTest->LogSubTest(KScroll); + DoTestScroll(TRect(-1000,-10000,23456,1111),TPoint(-6,-14)); + break; + case 19: + ((CTScrollStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0251")); + iTest->LogSubTest(KScroll); + DoTestScroll(TRect(20,5,198,202),TPoint(-100,1)); + DoTestScroll(TRect(1,1,200,123),TPoint(2,1)); + DoTestScroll(TRect(23,23,200,400),TPoint(5,-1)); + break; + case 20: + ((CTScrollStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0251")); + iTest->LogSubTest(KScroll); + DoTestScroll(TRect(0,0,0,0),TPoint(-10,1)); + DoTestScroll(TRect(-1000,1,2000,123),TPoint(2,1)); + DoTestScroll(TRect(23,-23,200,40000),TPoint(5,-1)); + DoTestScroll(TRect(-1000,-10000,23456,1111),TPoint(-6,-14)); + break; + +/** +@SYMTestCaseID GRAPHICS-WSERV-0252 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test window scrolling by different offsets and + clipping ans source rectangles + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Pass different offsets for scroll a window by and + different clipping and source rectangles. + Check the window is scrolled correctly + +@SYMTestExpectedResults Window scrolls correctly to offsets and source + and clipping rectangles +*/ + case 21: + ((CTScrollStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0252")); + iTest->LogSubTest(KScroll); + DoTestScroll(TRect(TPoint(1,1),iWinSize-TSize(1,1)),TPoint(-6,-14),TRect(10,10,50,50)); + DoTestScroll(TRect(TPoint(1,1),iWinSize-TSize(1,1)),TPoint(16,4),TRect(10,10,50,50)); + break; + case 22: + ((CTScrollStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0252")); + iTest->LogSubTest(KScroll); + DoTestScroll(TRect(TPoint(10,100),iWinSize-TSize(0,10)),TPoint(26,22),TRect(iWinSize)); + DoTestScroll(TRect(iWinSize),TPoint(2,-1),TRect(-10,-10,50,50)); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0253 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Out of memory window scrolling test + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Out of memory window scrolling test + +@SYMTestExpectedResults Out of memory scrolling is handled correctly +*/ + case 23: + ((CTScrollStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0253")); + iTest->LogSubTest(KScroll); + OomScrolling(); + iTest->CloseAllPanicWindows(); + ++iTest->iState; + return; + case 24: + ((CTScrollStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0253")); + ++iTest->iState; + ++iMode; + if (iMode==1) + { + delete iBaseScrollWin; + delete iTestScrollWin; + ConstructL(); + } + return; + default: + ((CTScrollStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + ((CTScrollStep*)iStep)->CloseTMSGraphicsStep(); + TestComplete(); + break; + } + ((CTScrollStep*)iStep)->RecordTestResultL(); + FinishedRectScrolls(); + iDoCheck=ETrue; + } + +void CTScroll::DemoWindowScrollL() + //Function to see what scrolling does. + { + CBlankWindow* iWin; + iWin=new(ELeave) CBlankWindow(TRgb(64,64,224)); + iWin->SetUpL(TPoint(20,10),TSize(120,100),TheClient->iGroup,*TheClient->iGc); + iWin->BaseWin()->SetRequiredDisplayMode(EColor256); + iWin->Win()->SetBackgroundColor(TRgb(64,224,64)); + iWin->RealDraw(ETrue); + TheClient->WaitForRedrawsToFinish(); + iWin->DrawableWin()->Scroll(TPoint(8,5),TRect(20,20,100,80)); + TheClient->Flush(); + TheClient->WaitForRedrawsToFinish(); + TheClient->Flush(); + } + + +__WS_CONSTRUCT_STEP__(Scroll) +#pragma warning(default : 4710) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TSCROLL.H --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TSCROLL.H Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,203 @@ + +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef __TSCROLL_H__ +#define __TSCROLL_H__ + +#include +#include +#include "../tlib/testbase.h" +#include +#include "AUTO.H" +#include "TGraphicsHarness.h" + +class CTScroll; +class CScrollTestBase; + +class CScrollWindowNorm : public CTWin + { +public: + CScrollWindowNorm(); + void Draw(); + void SetScrollTest(CScrollTestBase *aScrollTest); +private: + CScrollTestBase *iScrollTest; + }; + +class CScrollWindowBackedUp : public CTBackedUpWin + { +public: + CScrollWindowBackedUp(TDisplayMode aDisplayMode); + void Draw(); + void SetScrollTest(CScrollTestBase *aScrollTest); +private: + CScrollTestBase *iScrollTest; + }; + +class CScrollTestBase : public CBase + { +public: + ~CScrollTestBase(); + virtual void ConstructL(const TPoint &aPos, const TSize &aSize)=0; + virtual void DoTestScroll(const TPoint &aOffset)=0; + virtual void DoTestScroll(const TRect &aClipRect, const TPoint &aOffset)=0; + virtual void DoTestScroll(const TPoint &aOffset, const TRect &aRect)=0; + virtual void DoTestScroll(const TRect &aClipRect, const TPoint &aOffset, const TRect &aRect)=0; + virtual void Reset(); + TPoint Offset() const; + virtual CTDrawableWin *ScrollWin() const=0; + virtual void DoInvalidate(); + virtual void Redraw()=0; +protected: + TSize iSize; + TPoint iOffset; + friend class CTScroll; + RRegion iInvalid; + CTBlankWindow *iBlankWin; + }; + +class CScrollTestBaseNorm : public CScrollTestBase + { +public: + void ConstructL(const TPoint &aPos, const TSize &aSize); + ~CScrollTestBaseNorm(); + virtual CTDrawableWin *ScrollWin() const; + virtual void Reset(); + void VisibleRegion(RRegion &aRegion); + void AdjustTestScrollRegion(const TRect &aClipRect, const TPoint &aOffset, const TRect &aRect); + void DrawScrollWin(const TPoint &aOffset, const TSize &aSize); + void Redraw(); +protected: + CScrollWindowNorm *iScrollWin; + }; + +class CScrollWindow1 : public CScrollTestBaseNorm +// +// Used as control window for a normal redraw window +// + { +public: + void DoTestScroll(const TPoint &aOffset); + void DoTestScroll(const TRect &aClipRect, const TPoint &aOffset); + void DoTestScroll(const TPoint &aOffset, const TRect &aRect); + void DoTestScroll(const TRect &aClipRect, const TPoint &aOffset, const TRect &aRect); + void DoInvalidate(); + }; + +class CScrollWindow2 : public CScrollTestBaseNorm +// +// Used to test a normal redraw window +// + { +public: + CScrollWindow2(CTScroll *aTest); + virtual void Draw(); + virtual void Reset(); + void DoTestScroll(const TPoint &aOffset); + void DoTestScroll(const TRect &aClipRect, const TPoint &aOffset); + void DoTestScroll(const TPoint &aOffset, const TRect &aRect); + void DoTestScroll(const TRect &aClipRect, const TPoint &aOffset, const TRect &aRect); +private: + TBool iClipped; + CTScroll *iTest; + }; + +class CScrollWindow3 : public CScrollTestBaseNorm +// +// Used as control window for testing backed up windows +// + { +public: + void ConstructL(const TPoint &aPos, const TSize &aSize); + ~CScrollWindow3(); + virtual void Reset(); + void Draw(); + void DoTestScroll(const TPoint &aOffset); + void DoTestScroll(const TRect &aClipRect, const TPoint &aOffset); + void DoTestScroll(const TPoint &aOffset, const TRect &aRect); + void DoTestScroll(const TRect &aClipRect, const TPoint &aOffset, const TRect &aRect); + void DoInvalidate(); + void DrawScrollBit(); +private: + CFbsBitmap *iBitmap; + CFbsDevice *iBitmapDevice; + CFbsBitGc *iBitmapGc; + }; + +class CScrollWindow4 : public CScrollTestBase +// +// Tests a backed up window +// + { +public: + ~CScrollWindow4(); + void ConstructL(const TPoint &aPos, const TSize &aSize); + void DoTestScroll(const TPoint &aOffset); + void DoTestScroll(const TRect &aClipRect, const TPoint &aOffset); + void DoTestScroll(const TPoint &aOffset, const TRect &aRect); + void DoTestScroll(const TRect &aClipRect, const TPoint &aOffset, const TRect &aRect); + virtual CTDrawableWin *ScrollWin() const; + virtual void Reset(); + void Redraw(); +protected: + CScrollWindowBackedUp *iScrollWin; + }; + +class CTScroll : public CTWsGraphicsBase + { +public: + CTScroll(CTestStep* aStep); + ~CTScroll(); + void ConstructL(); + void CheckScrollWindows(); + void DoTestScroll(const TPoint &aOffset); + void DoTestScroll(const TRect &aClipRect, const TPoint &aOffset); + void DoTestScroll(const TPoint &aOffset, const TRect &aRect); + void DoTestScroll(const TRect &aClipRect, const TPoint &aOffset, const TRect &aRect); + void FinishedRectScrolls(); + void CheckOomScroll(); + void OomScrolling(); + void DemoWindowScrollL(); +protected: +//from CTGraphicsStep + virtual void RunTestCaseL(TInt aCurTestCase); +private: + TSize iWinSize; + TInt iMode; + TBool iDoCheck; + CScrollTestBase *iBaseScrollWin; + CScrollTestBase *iTestScrollWin; + }; + +class CTScrollStep : public CTGraphicsStep + { +public: + CTScrollStep(); +protected: + //from CTGraphicsStep + virtual CTGraphicsBase* CreateTestL(); + }; + +_LIT(KTScrollStep,"TScroll"); + + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TSPRITE.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TSPRITE.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,996 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include "TSPRITE.H" + +CTTSprite::CTTSprite(CTestStep* aStep): + CTWsGraphicsBase(aStep) + { + INFO_PRINTF1(_L("Testing TSprite functions")); + } + +void CTTSprite::SetUpMember(TSpriteMember &aMember) + { + aMember.iMaskBitmap=NULL; + aMember.iInvertMask=EFalse; + aMember.iDrawMode=CGraphicsContext::EDrawModePEN; + aMember.iOffset=TPoint(); + aMember.iInterval=TTimeIntervalMicroSeconds32(0); + aMember.iBitmap=&iBitmap; + } + +void CTTSprite::SetUpPointerCursorL(RWsPointerCursor &aCursor, RWsSession &aSession) + { + aCursor=RWsPointerCursor(aSession); + TSpriteMember member; + SetUpMember(member); + User::LeaveIfError(aCursor.Construct(0)); + User::LeaveIfError(aCursor.AppendMember(member)); + User::LeaveIfError(aCursor.Activate()); + } + +void CTTSprite::SetUpSpriteL(RWsSprite &aSprite, RWsSession &aSession, RWindowTreeNode &aWindow,TInt aFlags/*=0*/) + { + aSprite=RWsSprite(aSession); + User::LeaveIfError(aSprite.Construct(aWindow,TPoint(),aFlags)); + TSpriteMember member; + SetUpMember(member); + User::LeaveIfError(aSprite.AppendMember(member)); + User::LeaveIfError(aSprite.Activate()); + } + +void CTTSprite::ConstructL() + { + User::LeaveIfError(iBitmap.Load(TEST_BITMAP_NAME,0)); + } + +CTTSprite::~CTTSprite() + { + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-0018 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc General cursor tests involving a sprite + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Carries out cursor and window tests before updating + a cursor's member with a sprite + +@SYMTestExpectedResults When the cursor member is update returns KErrArgument +*/ + +void CTTSprite::GeneralTestsL() + { +// +// Close cursor while still active on a window +// + + RWindow win(TheClient->iWs); + win.Construct(*TheClient->iGroup->GroupWin(),1); + win.Activate(); + SetUpPointerCursorL(iCursor1,TheClient->iWs); + win.SetCustomPointerCursor(iCursor1); + iCursor1.Close(); +// +// Close window while cursor active on it +// + SetUpPointerCursorL(iCursor1,TheClient->iWs); + win.SetCustomPointerCursor(iCursor1); + win.Close(); + iCursor1.Close(); + +// +// Close session with: +// An open cursor active on a window & A closed cursor active on another window +// + RWsSession ws; + User::LeaveIfError(ws.Connect()); + // use correct screen + // + ws.SetFocusScreen(iTest->iScreenNumber); + CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws); + CleanupStack::PushL(screen); + User::LeaveIfError(screen->Construct(0)); + + RWindowGroup group(ws); + User::LeaveIfError(group.Construct(123)); + group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close + RWindow win2(ws); + User::LeaveIfError(win2.Construct(group, 1)); + win2.Activate(); + RWindow win3(ws); + User::LeaveIfError(win3.Construct(group, 2)); + win3.Activate(); +// + SetUpPointerCursorL(iCursor1,ws); + SetUpPointerCursorL(iCursor2,ws); + win2.SetCustomPointerCursor(iCursor1); + win3.SetCustomPointerCursor(iCursor2); +// + TSpriteMember member; + member.iBitmap=member.iMaskBitmap=NULL; + TInt err = iCursor1.UpdateMember(9999,member); + TEST(err==KErrArgument); + if (err!=KErrArgument) + INFO_PRINTF3(_L("iCursor1.UpdateMember(9999,member) return value - Expected: %d, Actual: %d"), KErrArgument, err); + + iCursor1.Close(); + + CleanupStack::PopAndDestroy(screen); + ws.Close(); + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-0019 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Construct a sprite in a group window + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Creates a sprite in a group window + +@SYMTestExpectedResults The sprite is created without error +*/ +void CTTSprite::GroupWindowSpritesL() + { + RWsSprite sprite1; + RWsSprite sprite2; + SetUpSpriteL(sprite1,TheClient->iWs,*TheClient->iGroup->GroupWin()); + SetUpSpriteL(sprite2,TheClient->iWs,*TheClient->iGroup->GroupWin()); + TheClient->iWs.Flush(); + sprite2.Close(); + sprite1.Close(); + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-0020 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Constructs a number of different sprites in different windows + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Creates many sprites in three different windows and the checks + the sprites can be manipulated + +@SYMTestExpectedResults The sprite are created and manipulated without error +*/ +#define NUM_SPRITES 8 +void CTTSprite::LotsSpritesL() + { + CTBlankWindow* win=new(ELeave) CTBlankWindow(); + CTBlankWindow* win2=new(ELeave) CTBlankWindow(); + TSize size(100,120); + win->ConstructL(*TheClient->iGroup); + win2->ConstructL(*win); + win2->SetExt(TPoint(100,100),size); + win2->SetColor(TRgb::Gray4(2)); + RWindowBase window=*win->BaseWin(); + RWindowBase window2=*win2->BaseWin(); + window.Activate(); + window2.Activate(); + RWsSprite sprite[NUM_SPRITES]; + TInt ii; + //TheClient->iWs.SetAutoFlush(ETrue); + for (ii=0;iiiWs,window); + sprite[4].Close(); + sprite[2].SetPosition(TPoint(20,20)); + sprite[0].Close(); + win2->SetExt(TPoint(80,100),size); + sprite[6].SetPosition(TPoint(60,120)); + sprite[7].Close(); + sprite[5].SetPosition(TPoint(100,120)); + sprite[3].Close(); + SetUpSpriteL(sprite[7],TheClient->iWs,window); + sprite[7].SetPosition(TPoint(80,150)); + sprite[1].Close(); + win2->SetExt(TPoint(60,110),size); + sprite[5].SetPosition(TPoint(50,40)); + sprite[7].Close(); + SetUpSpriteL(sprite[0],TheClient->iWs,window); + sprite[0].SetPosition(TPoint(55,65)); + sprite[6].Close(); + win2->SetExt(TPoint(40,90),size); + sprite[2].SetPosition(TPoint(80,45)); + sprite[5].Close(); + sprite[0].SetPosition(TPoint(90,60)); + sprite[2].Close(); + SetUpSpriteL(sprite[2],TheClient->iWs,window); + sprite[2].SetPosition(TPoint(70,80)); + sprite[0].Close(); + win2->SetExt(TPoint(20,80),size); + sprite[2].SetPosition(TPoint(600,200)); + sprite[2].Close(); + SetUpSpriteL(sprite[0],TheClient->iWs,window2,ESpriteFlash); + sprite[0].SetPosition(TPoint(0,25)); + SetUpSpriteL(sprite[1],TheClient->iWs,window2,ESpriteFlash); + SetUpSpriteL(sprite[2],TheClient->iWs,window2,ESpriteFlash); + sprite[2].SetPosition(TPoint(25,0)); + win2->SetExt(TPoint(40,70),size); + CTBlankWindow* win3=new(ELeave) CTBlankWindow(); + win3->ConstructL(*TheClient->iGroup); + win3->SetExt(TPoint(30,60),TSize(30,30)); + win3->SetColor(TRgb::Gray4(1)); + win3->BaseWin()->SetShadowHeight(10); + win3->BaseWin()->Activate(); + User::After(1000000); //1 sec so sprites has time to flash + delete win2; + delete win; + delete win3; + sprite[0].Close(); + sprite[1].Close(); + sprite[2].Close(); + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-0021 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc General PointerCursor Tests + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Exercise the different pointercursor methods of a Window Server Session + +@SYMTestExpectedResults The methods are called without error +*/ +void CTTSprite::GeneralPointerCursor() + { + if (!TestBase()->ConfigurationSupportsPointerEventTesting()) + { + INFO_PRINTF1(_L("Test skipped because config does not support pointer event testing")); + return; + } + TInt currentSMode=TheClient->iScreen->CurrentScreenMode(); + TInt altSMode=-1; + if (TheClient->iScreen->NumScreenModes()>1) + altSMode=(currentSMode==1?0:1); + RWsSession &ws=TheClient->iWs; + TRect rect=ws.PointerCursorArea(); + TRect testRect1(TPoint(rect.iBr.iX/4,rect.iBr.iY/4),TSize(rect.Width()/2,rect.Height()/2)); + TRect testRect2(TPoint(rect.iBr.iX/3,rect.iBr.iY/3),TSize(2*rect.Width()/3,2*rect.Height()/3)); + ws.SetPointerCursorArea(testRect1); + TEST(ws.PointerCursorArea()==testRect1); + TEST(ws.PointerCursorArea(currentSMode)==testRect1); + ws.SetPointerCursorArea(currentSMode,testRect2); + TEST(ws.PointerCursorArea()==testRect2); + TEST(ws.PointerCursorArea(currentSMode)==testRect2); + ws.SetPointerCursorArea(rect); + TEST(ws.PointerCursorArea()==rect); + + if (altSMode>=0) + { + rect=ws.PointerCursorArea(altSMode); + testRect1.iTl.iX=rect.iBr.iX/4; + testRect1.iTl.iY=rect.iBr.iY/4; + testRect1.SetWidth(rect.Width()/2); + testRect1.SetHeight(rect.Height()/2); + ws.SetPointerCursorArea(altSMode,testRect1); + TEST(ws.PointerCursorArea(altSMode)==testRect1); + ws.SetPointerCursorArea(altSMode,rect); + TEST(ws.PointerCursorArea(altSMode)==rect); + } + TPointerCursorMode currentMode=ws.PointerCursorMode(); + TInt ii; + TInt err1; + for(ii=EPointerCursorFirstMode;ii<=EPointerCursorLastMode;ii++) + { + ws.SetPointerCursorMode(STATIC_CAST(TPointerCursorMode,ii)); + err1 = ws.PointerCursorMode(); + TEST(ii==err1); + if (ii!=err1) + INFO_PRINTF3(_L("ws.PointerCursorMode() return value - Expected: %d, Actual: %d"), ii, err1); + } + ws.SetPointerCursorMode(currentMode); + TEST(currentMode==ws.PointerCursorMode()); + TPoint point1(10,12); + TPoint point2(24,20); + ws.PointerCursorPosition(); + ws.SetPointerCursorPosition(point1); + TEST(ws.PointerCursorPosition()==point1); + ws.SetPointerCursorPosition(point2); + TEST(ws.PointerCursorPosition()==point2); + } + + +/** +@SYMTestCaseID GRAPHICS-WSERV-0498 + +@SYMDEF PDEF137614 - Propagation to TB92 + +@SYMTestCaseDesc Test activating a pointer cursor + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Construct and activate a pointer cursor. + Check it is visible. + Deactivate it + Check it is removed + + +@SYMTestExpectedResults + The pointer cursor bitmp should be visible when activated and removed when deactivated. +*/ + +void CTTSprite::PointerCursorVisibleL() + { + if (!TestBase()->ConfigurationSupportsPointerEventTesting()) + { + INFO_PRINTF1(_L("Test skipped because config does not support pointer event testing")); + return; + } + + // The pointer events need time to have an affect on the wserv + static const TInt eventPropagationDelay = 100 * 1000; // 100 ms + + TInt screenNumber = TheClient->iScreen->GetScreenNumber(); + + if(screenNumber != 0) // pointer events only supported on emulator screen 0 + { + LOG_MESSAGE(_L("Pointer Cursor Visible only runs on screen 0")); + return; + } + + // set up objects used in test + // 50x50 red rectangle colour 24 + CFbsBitmap bitmap; + User::LeaveIfError(bitmap.Load(TEST_BITMAP_NAME, 8)); + + TSize bmSize = bitmap.SizeInPixels(); + TPoint bmSample = TPoint(bmSize.iWidth / 2, bmSize.iHeight / 2); + TRgb bmColour; + bitmap.GetPixel(bmColour, bmSample); + TEST(bmColour == KRgbRed); + + // single window, size of screen + RWindow win(TheClient->iWs); + User::LeaveIfError(win.Construct(*TheClient->iGroup->GroupWin(),1)); + win.Activate(); + + // setup cursor mode + TheClient->iWs.SetPointerCursorMode(EPointerCursorWindow); + + // setup cursor to contain single 50x50 red bitmap + RWsPointerCursor iCursor1 = RWsPointerCursor(TheClient->iWs); + TSpriteMember member; + SetUpMember(member); + member.iBitmap=&bitmap; + User::LeaveIfError(iCursor1.Construct(0)); + User::LeaveIfError(iCursor1.AppendMember(member)); + User::LeaveIfError(iCursor1.Activate()); + win.SetCustomPointerCursor(iCursor1); + iCursor1.UpdateMember(0); + + // draw a green rect, size of screen as defined background and wait till it is rendered + win.BeginRedraw(); + TheGc->Activate(win); + TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + TheGc->SetBrushColor(KRgbGreen); + TSize wSize = win.Size(); + TheGc->DrawRect(TRect(TPoint(0,0), wSize)); + TheGc->Deactivate(); + win.EndRedraw(); + TheClient->iWs.Finish(); + + // #### do test #### + // define locations of simulated pointer events and sample positions of where we expect to see the cursor + // The cursor will be moved and a check will be made to see if this has actually happened + + TPoint pos1(wSize.iWidth / 2, wSize.iHeight / 2); // top left of cursor at centre screen + TPoint sample1(pos1 + bmSample); // centre of sprite at pos1 + TPoint pos2 = pos1 - bmSize; // bottom right of cursor at centre screen + TPoint sample2 = pos2 + bmSample; // centre of sprite at pos2 + + TRgb pixel; + + // check initial state of screen at both sample positions + TheClient->iScreen->GetPixel(pixel, sample1); + TEST(pixel == KRgbGreen); + + TheClient->iScreen->GetPixel(pixel, sample2); + TEST(pixel == KRgbGreen); + + TRawEvent e; // to simulate pointer events + + // simulate button 1 down event at pos1 + e.Set(TRawEvent::EButton1Down, pos1.iX, pos1.iY); + e.SetDeviceNumber(screenNumber); + UserSvr::AddEvent(e); + + User::After(eventPropagationDelay); + + // check red cursor visible on top of background + TheClient->iScreen->GetPixel(pixel, sample1); + TEST(pixel == KRgbRed); + + // simulate button 1 up event + e.Set(TRawEvent::EButton1Up, pos1.iX, pos1.iY); + UserSvr::AddEvent(e); + User::After(eventPropagationDelay); + + // Move cursor away to pos2 + e.Set(TRawEvent::EButton1Down, pos2.iX, pos2.iY); + e.SetDeviceNumber(screenNumber); + UserSvr::AddEvent(e); + + User::After(eventPropagationDelay); + + // check cursor has left this position ... + TheClient->iScreen->GetPixel(pixel, sample1); + TEST(pixel == KRgbGreen); + // and arrived at the correct place + TheClient->iScreen->GetPixel(pixel, sample2); + TEST(pixel == KRgbRed); + + // simulate button 1 up event + e.Set(TRawEvent::EButton1Up, pos2.iX, pos2.iY); + UserSvr::AddEvent(e); + User::After(eventPropagationDelay); + + // remove the cursor + win.ClearPointerCursor(); + User::After(eventPropagationDelay); + + // check it has gone + TheClient->iScreen->GetPixel(pixel, sample2); + TEST(pixel == KRgbGreen); + + // #### clean up #### + iCursor1.Close(); + win.Close(); + } + + +/** + @SYMTestCaseID GRAPHICS-CODEBASE-WSERV-0053-0001 + + @SYMPREQ PGM027 + + @SYMTestCaseDesc Tests RWsPointerCursor::UpdateMember APIs. + + @SYMTestPriority 1 + + @SYMTestStatus Implemented + + @SYMTestActions This test calls RWsPointerCursor::UpdateMember + + @SYMTestExpectedResults Should run properly with out any Panics. + + */ +void CTTSprite::SpriteUpdateMemberTestsL() + { + RWsPointerCursor iCursor1; + + CFbsBitmap bitmap; + bitmap.Load(TEST_BITMAP_NAME,0); + + RWindow win(TheClient->iWs); + win.Construct(*TheClient->iGroup->GroupWin(),1); + win.Activate(); + + iCursor1=RWsPointerCursor(TheClient->iWs); + TSpriteMember member; + SetUpMember(member); + member.iBitmap=&bitmap; + User::LeaveIfError(iCursor1.Construct(0)); + User::LeaveIfError(iCursor1.AppendMember(member)); + User::LeaveIfError(iCursor1.Activate()); + win.SetCustomPointerCursor(iCursor1); + iCursor1.UpdateMember(0); + + RWsPointerCursor iCursor2; + bitmap.Load(TEST_NEW_BITMAP_NAME,0); + iCursor2=RWsPointerCursor(TheClient->iWs); + User::LeaveIfError(iCursor2.Construct(0)); + User::LeaveIfError(iCursor2.AppendMember(member)); + User::LeaveIfError(iCursor2.Activate()); + win.SetCustomPointerCursor(iCursor2); + iCursor2.UpdateMember(1); + + iCursor1.Close(); + iCursor2.Close(); + win.Close(); + } + +/** + @SYMTestCaseID GRAPHICS-CODEBASE-WSERV-0054-0001 + + @SYMPREQ PGM027 + + @SYMTestCaseDesc Negative Tests RWsSpriteBase::UpdateMember API. + + @SYMTestPriority 1 + + @SYMTestStatus Implemented + + @SYMTestActions This test calls RWsPointerCursor::UpdateMember + + @SYMTestExpectedResults Should run properly with out any Panics. + + */ +void CTTSprite::SpriteUpdateMemberNegTestsL() + { + RWsPointerCursor iCursor1; + + CFbsBitmap bitmap; + bitmap.Load(TEST_BITMAP_NAME,0); + + RWindow win(TheClient->iWs); + win.Construct(*TheClient->iGroup->GroupWin(),1); + win.Activate(); + + iCursor1=RWsPointerCursor(TheClient->iWs); + TSpriteMember member; + SetUpMember(member); + member.iBitmap=&bitmap; + User::LeaveIfError(iCursor1.Construct(0)); + User::LeaveIfError(iCursor1.AppendMember(member)); + User::LeaveIfError(iCursor1.Activate()); + win.SetCustomPointerCursor(iCursor1); + iCursor1.UpdateMember(-100); + + RWsPointerCursor iCursor2; + bitmap.Load(TEST_NEW_BITMAP_NAME,0); + iCursor2=RWsPointerCursor(TheClient->iWs); + User::LeaveIfError(iCursor2.Construct(0)); + User::LeaveIfError(iCursor2.AppendMember(member)); + User::LeaveIfError(iCursor2.Activate()); + win.SetCustomPointerCursor(iCursor2); + iCursor2.UpdateMember(10000); + + iCursor1.Close(); + iCursor2.Close(); + win.Close(); + } + +/** + @SYMTestCaseID GRAPHICS-CODEBASE-WSERV-0055-0001 + + @SYMPREQ PGM027 + + @SYMTestCaseDesc Tests FindWindowGroupIdentifier API. + + @SYMTestPriority 1 + + @SYMTestStatus Implemented + + @SYMTestActions Create windows session and call FindWindowGroupIdentifier \n + with different thread Id's both with valid thread ids and in valid thread id's. + + @SYMTestExpectedResults Should run properly. + + */ +void CTTSprite::FindWindowGroupThreadTestsL() + { + RThread proc; + TInt ident; + TUint64 id=proc.Id(); + RWsSession ws1; + User::LeaveIfError(ws1.Connect()); + CleanupClosePushL(ws1); + //Positive test for FindWindowGroupIdentifier + ident=ws1.FindWindowGroupIdentifier(0,id); + TEST(ws1.SetWindowGroupOrdinalPosition(ident,0)==KErrNone); + TEST(ws1.SetWindowGroupOrdinalPosition(ident,1)==KErrNone); + //Negative test for FindWindowGroupIdentifier + TInt ret=ws1.FindWindowGroupIdentifier(0,id+200); + TEST(ret==KErrNotFound); + #if defined __WINS__ || defined __WINSCW__ + ret=ws1.FindWindowGroupIdentifier(0,-200); + TEST(ret==KErrNotFound); + #endif//defined __WINS__ || defined __WINSCW__ + CleanupStack::PopAndDestroy(1, &ws1); + ws1.Close(); + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-0462 + +@SYMDEF PDEF114190 + +@SYMTestCaseDesc Test sprite list cleanup when a window is deleted in low memory conditions + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Have a loop which increases the number of allocations in the server thread before failure; + Within the loop: + 1) Create a parent window and a child window of the parent; + 2) Create a sprite on the child window; + 3) Delete the parent window only, but not the child window; + 4) Create a testWindow and do redraw on this window; + 5) Do redraw on the testWindow. This testWindow's redraw will force checking the sprite list. + This would panic the client thread due to this defect because the sprite on the orphaned + window (which is the previous child window) is still in the sprite list; + 6) Delete all the windows involved. + +@SYMTestExpectedResults The sprite should be disabled when a window is deleted; + The client thread should not be panic'd. + The test should pass. +*/ +void CTTSprite::SpriteOnWindowOrphanedTestsL() + { + TInt handles = 344; + TInt loop = 0; + TInt allocFailRate = 0; + TInt err = KErrNone; + + CFbsBitmap* bitmap = new(ELeave) CFbsBitmap; + CleanupStack::PushL(bitmap); + User::LeaveIfError(bitmap->Create(TSize(500, 500), EColor16MU)); + TSpriteMember spritemember; + spritemember.iBitmap = bitmap; + spritemember.iMaskBitmap = NULL; + + RWindowGroup group(TheClient->iWs); + RWindow parent1(TheClient->iWs); + RWindow child1(TheClient->iWs); + RWindow testWindow(TheClient->iWs); + RWsSprite sprite(TheClient->iWs); + + while (loop < 5) + { + TRect mainRect(TPoint(0,0), TSize(500,500)); + err = group.Construct(++handles, EFalse); + if (err == KErrNone) + { + TheClient->iWs.HeapSetFail(RHeap::EDeterministic, allocFailRate); + + //Create parent 1 + err = parent1.Construct(group,++handles); + if (err == KErrNone) + { + parent1.SetExtent(mainRect.iTl, mainRect.Size()); + parent1.EnableRedrawStore(ETrue); + parent1.Activate(); + } + } + + //Create child 1 + if (err == KErrNone) + { + TRect childRect(TPoint (10, 10), TSize (200, 150)); + err = child1.Construct(parent1,++handles); + if (err == KErrNone) + { + child1.SetExtent(childRect.iTl, childRect.Size()); + child1.SetBackgroundColor(TRgb(128,100,255,20)); + child1.Activate(); + } + } + + //Add sprite to child 1 + if (err == KErrNone) + { + err = sprite.Construct(child1,TPoint(10,10), 0); + if (err == KErrNone) + { + err = sprite.AppendMember(spritemember); + if (err == KErrNone) + err = sprite.Activate(); + } + } + + //Only delete parent 1, but not child 1 + parent1.Close(); + + if (err == KErrNone) + { + TRect testRect(TPoint(10, 30), TSize(200, 150)); + //Create testWindow + err = testWindow.Construct(group,++handles); + if (err == KErrNone) + { + testWindow.SetExtent(testRect.iTl, testRect.Size()); + testWindow.SetBackgroundColor(TRgb(128,100,255,20)); + testWindow.EnableRedrawStore(ETrue); + testWindow.Activate(); + testWindow.BeginRedraw(); + testWindow.EndRedraw(); + TheClient->Flush(); + } + } + TheClient->iWs.HeapSetFail(RAllocator::ENone, 0); + + sprite.Close(); + child1.Close(); + testWindow.Close(); + group.Close(); + ++allocFailRate; + loop = (err == KErrNone) ? loop + 1 : 0; + } + CleanupStack::PopAndDestroy(bitmap); + } +void CTTSprite::ResizeMemberL() + { +#ifndef __WINS__ + CTBlankWindow* win=new(ELeave) CTBlankWindow(); + CleanupStack::PushL(win); + win->ConstructL(*TheClient->iGroup); + win->SetExt(TPoint(),TSize(640,240)); + RWindowBase& window=*win->BaseWin(); + window.Activate(); + RWsSprite sprite(TheClient->iWs); + CleanupClosePushL(sprite); + User::LeaveIfError(sprite.Construct(window,TPoint(),0)); + TSpriteMember member; + member.iMaskBitmap=NULL; + member.iInvertMask=EFalse; + member.iDrawMode=CGraphicsContext::EDrawModePEN; + member.iOffset=TPoint(); + member.iInterval=TTimeIntervalMicroSeconds32(250000); + member.iBitmap=&iBitmap; + User::LeaveIfError(sprite.AppendMember(member)); + User::LeaveIfError(sprite.AppendMember(member)); + User::LeaveIfError(sprite.Activate()); + User::After(1000000); // // Interval is 1 sec. + User::LeaveIfError(iBitmap.Resize(iBitmap.SizeInPixels() + TSize(100,100))); + User::After(1000000); // Interval is 1 sec. + CleanupStack::PopAndDestroy(&sprite); + CleanupStack::PopAndDestroy(win); +#endif // __WINS__ + } + + +void CTTSprite::SetUpSpriteL(RWsSprite &aSprite, RWindowTreeNode &aWindow,TPoint aPoint, TSpriteMember aMember, TInt aFlags/*=0*/) + { + User::LeaveIfError(aSprite.Construct(aWindow,aPoint,aFlags)); + User::LeaveIfError(aSprite.AppendMember(aMember)); + User::LeaveIfError(aSprite.Activate()); + } +/** +@SYMTestCaseID GRAPHICS-WSERV-00-0001 + +@SYMDEF PDEF117721 + +@SYMTestCaseDesc Test Screenrotation does not cause panic by sprite with NULL bitmap and NULL maskbitmap + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Defines two sprites and one with Null iBitmap and Null iMaskBitmap, then rotate the screen to 90 degrees + +@SYMTestExpectedResults the screen rotation will not cause wserv a panic +*/ +void CTTSprite::RotateNullSpriteL() + { + if (TheClient->iScreen->NumScreenModes() < 2) + { + LOG_MESSAGE(_L("WARNING: Unable to rotate screen")); + return; + } +// Sprite Members + TSpriteMember spriteMember1,spriteMember2; + SetUpMember(spriteMember1); + SetUpMember(spriteMember2); + spriteMember2.iBitmap = NULL; + +// Create windows + RWindowGroup group(TheClient->iWs); + User::LeaveIfError(group.Construct(ENullWsHandle,EFalse)); //Creates a Group Window + CleanupClosePushL(group); + RBlankWindow win(TheClient->iWs); + User::LeaveIfError(win.Construct(group,ENullWsHandle)); //Creates a Blank Window + CleanupClosePushL(win); + win.SetVisible(ETrue); + win.SetColor(TRgb::Gray4(2)); + win.Activate(); + TheClient->Flush(); + +// Create Sprites + RWsSprite sprite1(TheClient->iWs); + CleanupClosePushL(sprite1); + SetUpSpriteL(sprite1, win,TPoint(20,70),spriteMember1,0); + RWsSprite sprite2(TheClient->iWs); + CleanupClosePushL(sprite2); + SetUpSpriteL(sprite2, win,TPoint(80,130),spriteMember2,0); + RWsSprite sprite3(TheClient->iWs); + CleanupClosePushL(sprite3); + SetUpSpriteL(sprite3, win,TPoint(2800,2130),spriteMember1,0); + TheClient->Flush(); + +// Get the original screen mode + CWsScreenDevice* device = TheClient->iScreen; + TInt originalScreenMode = device->CurrentScreenMode(); + TPixelsTwipsAndRotation originalModeSettings; + device->GetScreenModeSizeAndRotation(originalScreenMode,originalModeSettings); + +// Rotate screens + TPixelsAndRotation pixelsAndRotation; + device->SetScreenMode( 1 ); + device->GetDefaultScreenSizeAndRotation(pixelsAndRotation); + device->SetCurrentRotations(1,pixelsAndRotation.iRotation); + device->SetScreenSizeAndRotation(pixelsAndRotation); + User::After(1000000); + + CleanupStack::PopAndDestroy(5,&group); +// Restore the original screen mode + device->SetScreenMode(originalScreenMode); + device->SetCurrentRotations(originalScreenMode,originalModeSettings.iRotation); + device->SetScreenSizeAndRotation(originalModeSettings); + TheClient->Flush(); + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-GCE-0700 + +@SYMDEF DEF123129 + +@SYMTestCaseDesc Test activating a sprite twice does not cause the system to hang + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Construct a sprite and add a member to it. Activate twice. + +@SYMTestExpectedResults The test should terminate smoothly and it should not hang the system. +*/ +void CTTSprite::DoubleActivateL() + { + RWsSession ws; + User::LeaveIfError(ws.Connect()); + CleanupClosePushL(ws); + + RWindowGroup group(ws); + User::LeaveIfError(group.Construct(890, EFalse)); + CleanupClosePushL(group); + + RWsSprite sprite = RWsSprite(ws); + User::LeaveIfError(sprite.Construct(group,TPoint(),0)); + CleanupClosePushL(sprite); + CFbsBitmap* bitmap=new(ELeave) CFbsBitmap; + CleanupStack::PushL(bitmap); + User::LeaveIfError(bitmap->Create(TSize(10,12),EColor256)); + TSpriteMember member; + member.iMaskBitmap=NULL; + member.iInvertMask=EFalse; + member.iDrawMode=CGraphicsContext::EDrawModePEN; + member.iOffset=TPoint(); + member.iInterval=TTimeIntervalMicroSeconds32(0); + member.iBitmap=bitmap; + User::LeaveIfError(sprite.AppendMember(member)); + User::LeaveIfError(sprite.Activate()); + User::LeaveIfError(sprite.Activate()); + + sprite.Close(); + CleanupStack::PopAndDestroy(4, &ws); + + group.Close(); + ws.Close(); + } + +void CTTSprite::RunTestCaseL(TInt /*aCurTestCase*/) + { + _LIT(KTest1, "General Tests"); + _LIT(KTest2, "Group Window Sprites Tests"); + _LIT(KTest3, "Lots Sprites Tests"); + _LIT(KTest4, "General Pointer Cursor Tests"); + _LIT(KTest5, "Pointer Cursor Visible Tests"); + _LIT(KTest6, "Update member tests"); + _LIT(KTest7, "Negative tests for Update member"); + _LIT(KTest8, "Window Group with Thread"); + _LIT(KTest9, "Resize Sprite Member Tests"); + _LIT(KTest10, "Rotate a NULL sprite"); + _LIT(KTest11, "Sprite On Window Orphaned Tests"); + _LIT(KTest12, "Sprite Double Activation Test"); + + ((CTTSpriteStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); + switch(++iTest->iState) + { + case 1: + ((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0018")); + TheClient->iWs.SetFocusScreen(0); + iTest->LogSubTest(KTest1); + GeneralTestsL(); + break; + case 2: + ((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0019")); + iTest->LogSubTest(KTest2); + GroupWindowSpritesL(); + break; + case 3: + ((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0020")); + iTest->LogSubTest(KTest3); + LotsSpritesL(); + break; + case 4: + ((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0021")); + iTest->LogSubTest(KTest4); + GeneralPointerCursor(); + break; + case 5: + ((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0498")); + iTest->LogSubTest(KTest5); + TRAPD(err, PointerCursorVisibleL()); + TEST(err == KErrNone); + break; + case 6: + ((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-CODEBASE-WSERV-0053-0001")); + iTest->LogSubTest(KTest6); + TRAP(err, SpriteUpdateMemberTestsL()); + TEST(err == KErrNone); + break; + case 7: + ((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-CODEBASE-WSERV-0054-0001")); + iTest->LogSubTest(KTest7); + TRAP(err, SpriteUpdateMemberNegTestsL()); + TEST(err == KErrNone); + break; + case 8: + ((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-CODEBASE-WSERV-0055-0001")); + iTest->LogSubTest(KTest8); + TRAP(err, FindWindowGroupThreadTestsL()); + TEST(err == KErrNone); + break; + case 9: + ((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0526")); + iTest->LogSubTest(KTest9); + ResizeMemberL(); + break; + case 10: + ((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-00-0001")); + iTest->LogSubTest(KTest10); + RotateNullSpriteL(); + break; + case 11: + ((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0462")); + iTest->LogSubTest(KTest11); + SpriteOnWindowOrphanedTestsL(); + break; + case 12: + ((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-GCE-0700")); + iTest->LogSubTest(KTest12); + DoubleActivateL(); + break; + default: + ((CTTSpriteStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + ((CTTSpriteStep*)iStep)->CloseTMSGraphicsStep(); + TestComplete(); + break; + } + ((CTTSpriteStep*)iStep)->RecordTestResultL(); + } + +//-------------- +__WS_CONSTRUCT_STEP__(TSprite) + diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TSPRITE.H --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TSPRITE.H Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,79 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef __TSPRITE_H__ +#define __TSPRITE_H__ + +#include +#include +#include "../tlib/testbase.h" +#include "AUTO.H" +#include "TGraphicsHarness.h" + +#define TEST_NEW_BITMAP_NAME _L("Z:\\WSTEST\\mytest.mbm") + +class CTTSprite : public CTWsGraphicsBase + { +public: + CTTSprite(CTestStep* aStep); + ~CTTSprite(); +protected: +//from CTGraphicsStep + virtual void RunTestCaseL(TInt aCurTestCase); +public: + void ConstructL(); + void GeneralTestsL(); + void GroupWindowSpritesL(); + void LotsSpritesL(); + void GeneralPointerCursor(); + void PointerCursorVisibleL(); + void SpriteUpdateMemberTestsL(); + void SpriteUpdateMemberNegTestsL(); + void FindWindowGroupThreadTestsL(); + void SpriteOnWindowOrphanedTestsL(); + void ResizeMemberL(); + void RotateNullSpriteL(); + void DoubleActivateL(); +private: + void SetUpMember(TSpriteMember &aMember); + void SetUpPointerCursorL(RWsPointerCursor &aCursor, RWsSession &aSession); + void SetUpSpriteL(RWsSprite &aSprite, RWsSession &aSession, RWindowTreeNode &aWindow,TInt aFlags=0); + void SetUpSpriteL(RWsSprite &aSprite, RWindowTreeNode &aWindow,TPoint aPoint, TSpriteMember aMember, TInt aFlags=0); + +private: + RWsPointerCursor iCursor1; + RWsPointerCursor iCursor2; + CFbsBitmap iBitmap; + }; + +class CTTSpriteStep : public CTGraphicsStep + { +public: + CTTSpriteStep(); +protected: + //from CTGraphicsStep + virtual CTGraphicsBase* CreateTestL(); + }; + +_LIT(KTTSpriteStep,"TSprite"); + + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TScreenModeScaling.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TScreenModeScaling.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,1104 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Test code for screen mode scaling CR +// Test code for the Scaling part of Change Request PHAR-5SJGAM +// ("Enable screen mode positioning and scaling"). +// Tests screen scale being configurable for a screen mode - +// eg it is now possible to set in wsini.ini amount by which a screen +// mode's screen will be scaled when drawn on the physical screen. +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include "TScreenModeScaling.h" + +#define MY_TEST_BITMAP _L("Z:\\WSTEST\\MYTEST.MBM") + +LOCAL_D TSize FullScreenModeSize; +LOCAL_D TInt Copy2ndHalfOfScreen; + +void ClearBitmap(CFbsBitmap* aBitMap) + { + // clear the content of bitmap before it is used for copying + CFbsBitmapDevice *device=CFbsBitmapDevice::NewL(aBitMap); + CleanupStack::PushL(device); + CFbsBitGc *gc=NULL; + User::LeaveIfError(device->CreateContext(gc)); + CleanupStack::PushL(gc); + gc->Clear(); + CleanupStack::PopAndDestroy(2,device); + } + +/*CBitMapWin*/ + +void CBitMapWin::Draw() + { + iGc->BitBlt(TPoint(),&iBackup->Bitmap()); + } + +/*CTestSpriteWin*/ + +CTestSpriteWin::~CTestSpriteWin() + { + } + +void CTestSpriteWin::UpdateWin(TPoint aOrigin) + { + SetOrigin(aOrigin); + DrawNow(); + } + +void CTestSpriteWin::Draw() + { + iGc->BitBlt(iOrigin,&iSpriteBitmap); + } + +/*CTScreenModeScaling*/ + +CTScreenModeScaling::CTScreenModeScaling(CTestStep* aStep) : CTWsGraphicsBase(aStep) + { + } + +CTScreenModeScaling::~CTScreenModeScaling() + { + delete iTestWin; + delete iBlankWin; + delete iBackedUpWin; + delete iTestChildWin; + delete iScreenBitmap; + delete iBitmapWin; + delete iCheckWin; + delete iTransWin; + delete iBackgroundWin; + delete iCheckBitmap; + delete iTransparencyBitmap; + delete iBackgroundBitmap; + delete iForegroundBitmap; + } + +void CTScreenModeScaling::ConstructL() + { + iDisplayMode=TheClient->iScreen->DisplayMode(); + if (iDisplayModeiScreen->SetAppScreenMode(TheClient->iScreenModes[0]); + FullScreenModeSize=TheClient->iScreen->SizeInPixels(); + iBlankWin=new(ELeave) CTBlankWindow(); + iBlankWin->ConstructL(*TheClient->iGroup); + User::LeaveIfError(iBlankWin->BaseWin()->SetRequiredDisplayMode(EColor256)); + iBlankWin->SetExt(TPoint(),FullScreenModeSize); + iBlankWin->Activate(); + + iTestWin=new(ELeave) CBasicWin; + iTestWin->ConstructExtLD(*TheClient->iGroup,TPoint(),FullScreenModeSize); + User::LeaveIfError(iTestWin->BaseWin()->SetRequiredDisplayMode(EColor256)); + iTestWin->AssignGC(*TheClient->iGc); + iTestWin->SetVisible(EFalse); + iTestWin->Activate(); + iTestWin->BaseWin()->SetShadowDisabled(ETrue); + iTestWin->BaseWin()->SetShadowHeight(0); + + iBackedUpWin=new(ELeave) CTBackedUpWin(iDisplayMode); + iBackedUpWin->ConstructExtLD(*iTestWin,TPoint(),FullScreenModeSize); + iBackedUpWin->SetVisible(EFalse); + iBackedUpWin->Activate(); + + iTestChildWin=new(ELeave) CTBlankWindow(); + iTestChildWin->ConstructL(*iTestWin); + User::LeaveIfError(iTestChildWin->BaseWin()->SetRequiredDisplayMode(EColor256)); + iTestChildWin->BaseWin()->SetShadowDisabled(ETrue); + iTestChildWin->SetColor(KRgbGreen); + iTestChildWin->BaseWin()->SetVisible(EFalse); + iTestChildWin->Activate(); + + iScreenBitmap=new(ELeave) CFbsBitmap(); + User::LeaveIfError(iScreenBitmap->Create(TSize(FullScreenModeSize.iWidth/2,FullScreenModeSize.iHeight),iDisplayMode)); + + iBitmapWin=new(ELeave) CBmpWin(*iScreenBitmap); + iBitmapWin->ConstructExtLD(*TheClient->iGroup,TPoint(),iScreenBitmap->SizeInPixels()); + User::LeaveIfError(iBitmapWin->BaseWin()->SetRequiredDisplayMode(EColor256)); + iBitmapWin->AssignGC(*TheClient->iGc); + iBitmapWin->Activate(); + iBitmapWin->SetVisible(EFalse); + iBitmapWin->BaseWin()->SetShadowDisabled(ETrue); + iBitmapWin->BaseWin()->SetShadowHeight(0); + + //.. Create all the bitmaps and transparent windows + iWinSize.SetSize(20,20); + iTransparencyBitmap=CBitmap::NewL(iWinSize,EGray256); + iBackgroundBitmap=CBitmap::NewL(iWinSize,iDisplayMode); + iForegroundBitmap=CBitmap::NewL(iWinSize,iDisplayMode); + + CBitMapWin* backgroundWin=new(ELeave) CBitMapWin(iBackgroundBitmap); + backgroundWin->ConstructExtLD(*TheClient->iGroup,TPoint(),iWinSize); + iBackgroundWin=backgroundWin; + User::LeaveIfError(iBackgroundWin->BaseWin()->SetRequiredDisplayMode(EColor256)); + iBackgroundWin->SetVisible(EFalse); + iBackgroundWin->BaseWin()->SetShadowDisabled(ETrue); + iBackgroundWin->BaseWin()->SetShadowHeight(0); + iBackgroundWin->AssignGC(*TheClient->iGc); + iBackgroundWin->Activate(); + + CBitMapWin* transWin=new(ELeave) CBitMapWin(iForegroundBitmap); + transWin->ConstructExtLD(*TheClient->iGroup,TPoint(),iWinSize); + iTransWin=transWin; + RWindowBase& transWinB=*iTransWin->BaseWin(); + User::LeaveIfError(transWinB.SetRequiredDisplayMode(EColor256)); + transWinB.SetShadowDisabled(ETrue); + transWinB.SetShadowHeight(0); + iTransWin->SetVisible(EFalse); + iTransWin->AssignGC(*TheClient->iGc); + iTransWin->Win()->SetTransparencyBitmap(iTransparencyBitmap->Bitmap()); + iTransWin->Activate(); + + CTBackedUpWin* checkWin=new(ELeave) CTBackedUpWin(iDisplayMode); + checkWin->ConstructExtLD(*TheClient->iGroup,TPoint(iWinSize.iWidth+1,0),iWinSize); + iCheckWin=checkWin; + RBackedUpWindow& win=*iCheckWin->BackedUpWin(); + win.SetShadowHeight(0); + iCheckWin->Activate(); + win.MaintainBackup(); + iCheckBitmap=CBitmap::NewL(win.BitmapHandle()); + iCheckWin->BaseWin()->SetShadowDisabled(ETrue); + iCheckWin->BaseWin()->SetShadowHeight(0); + iCheckWin->BaseWin()->SetVisible(EFalse); + TheClient->Flush(); + TheClient->WaitForRedrawsToFinish(); + } + +void CTScreenModeScaling::TestTopClientWindowPositionAPIs(TPoint aPos,RWindowBase* aWin) + { + TEST(aWin->AbsPosition()==aPos); + TEST(aWin->Position()==aPos); + TEST(aWin->InquireOffset(*TheClient->iGroup->GroupWin())==aPos); + } + +void CTScreenModeScaling::TestChildWindowPositionAPIs(TPoint aPos,TPoint aParentPos,RWindowBase* aWin,RWindowBase* aParentWin) + { + TEST(aWin->AbsPosition()==aParentPos+aPos); + TEST(aWin->Position()==aPos); + TEST(aWin->InquireOffset(*TheClient->iGroup->GroupWin())==aParentPos+aPos); + TEST(aWin->InquireOffset(*aParentWin)==aPos); + } + +void CTScreenModeScaling::TestRect() + { + // Here if the width or height of the screen cannot be divided by 2 + // then make both the rect size same by reducing the first or second which ever is smaller + // and make sure that top left corner is not disturbed. + TRect rect1=TRect(PhysicalToLogical(TPoint()-iCurrentScreenModeOrigin,iCurrentScreenModeScale), + PhysicalToLogical(TPoint(FullScreenModeSize.iWidth/2,FullScreenModeSize.iHeight)-iCurrentScreenModeOrigin, + iCurrentScreenModeScale) + ); + TRect rect2=TRect(PhysicalToLogical(TPoint(FullScreenModeSize.iWidth/2,0)-iCurrentScreenModeOrigin, + iCurrentScreenModeScale), + PhysicalToLogical(FullScreenModeSize.AsPoint()-iCurrentScreenModeOrigin, + iCurrentScreenModeScale) + ); + if ((Abs(rect1.iBr.iX-rect1.iTl.iX)>Abs(rect2.iBr.iX-rect2.iTl.iX)) || (Abs(rect1.iBr.iY-rect1.iTl.iY)>Abs(rect2.iBr.iY-rect2.iTl.iY))) + { + rect1.SetRect(rect1.iTl,rect2.Size()); + } + if ((Abs(rect1.iBr.iX-rect1.iTl.iX)iScreen->RectCompare(rect1,rect2); + TEST(retVal); + if (!retVal) + INFO_PRINTF3(_L("TheClient->iScreen->RectCompare(rect1,rect2) return value - Expected: %d, Actual: %d"), ETrue, retVal); + } + +void CTScreenModeScaling::CompareRegionsL(const TRegion &aRegion1,const TRegion &aRegion2) + { + RRegion tmp; + tmp.Copy(aRegion1); + tmp.SubRegion(aRegion2); + if (tmp.CheckError()) + User::Leave(KErrNoMemory); + TBool retVal = tmp.IsEmpty(); + TEST(retVal); + if (!retVal) + INFO_PRINTF3(_L("RRegion1.IsEmpty() return value - Expected: %d, Actual: %d"), ETrue, retVal); + tmp.Copy(aRegion2); + tmp.SubRegion(aRegion1); + if (tmp.CheckError()) + User::Leave(KErrNoMemory); + retVal = tmp.IsEmpty(); + TEST(retVal); + if (!retVal) + INFO_PRINTF3(_L("RRegion2.IsEmpty() return value - Expected: %d, Actual: %d"), ETrue, retVal); + + tmp.Close(); + } + +void CTScreenModeScaling::SetUpSpriteLC(RWsSprite &aSprite, RWsSession &aSession, RWindowTreeNode &aWindow,TInt aFlags) + { + aSprite=RWsSprite(aSession); + User::LeaveIfError(aSprite.Construct(aWindow,TPoint(),aFlags)); + CleanupClosePushL(aSprite); + TSpriteMember member; + iTest->SetUpMember(member); + member.iBitmap=&iSpriteBitmap; + User::LeaveIfError(aSprite.AppendMember(member)); + User::LeaveIfError(aSprite.Activate()); + } + +void CTScreenModeScaling::TestGetInvalidRegionL(TRect& aRect) + { + RRegion testRegion; + RRegion invalid; + iTestWin->Invalidate(aRect); + testRegion.AddRect(aRect); + iTestWin->Win()->GetInvalidRegion(invalid); + CleanupClosePushL(testRegion); + CleanupClosePushL(invalid); + CompareRegionsL(testRegion, invalid); + CleanupStack::PopAndDestroy(2, &testRegion); + TheClient->WaitForRedrawsToFinish(); + } + +void CTScreenModeScaling::CopyAndCompareL() + { + TInt oldOrdinalPriority = TheClient->iGroup->GroupWin()->OrdinalPriority(); + TInt oldOrdinalPosition = TheClient->iGroup->GroupWin()->OrdinalPosition(); + // the following line makes sure that a console object hidden outside of + // screens range doesn't affect test results ocerlapping the bitmap window + TheClient->iGroup->GroupWin()->SetOrdinalPosition(0, 65535); + + // clear the content of bitmap before it is used for copying + ClearBitmap(iScreenBitmap); + + // Copy first half or second half of the screen to a bitmap then paste it to second or first half of the screen + TRect testWinRect(PhysicalToLogical(TPoint((Copy2ndHalfOfScreen ? FullScreenModeSize.iWidth/2 : 0),0)-iCurrentScreenModeOrigin,iCurrentScreenModeScale), + PhysicalToLogical(TPoint((Copy2ndHalfOfScreen ? FullScreenModeSize.iWidth : FullScreenModeSize.iWidth/2),FullScreenModeSize.iHeight)-iCurrentScreenModeOrigin,iCurrentScreenModeScale) + ); + TheClient->iScreen->CopyScreenToBitmap(iScreenBitmap,testWinRect); + iBitmapWin->SetExt(PhysicalToLogical(TPoint((Copy2ndHalfOfScreen ? 0 : FullScreenModeSize.iWidth/2),0)-iCurrentScreenModeOrigin,iCurrentScreenModeScale),testWinRect.Size()); + iBitmapWin->SetVisible(ETrue); + iBitmapWin->DrawNow(); + TheClient->Flush(); + TestRect(); + iBitmapWin->SetVisible(EFalse); + iTestWin->SetVisible(EFalse); + TheClient->Flush(); + + TheClient->iGroup->GroupWin()->SetOrdinalPosition(oldOrdinalPosition, oldOrdinalPriority); + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-0093 + +@SYMDEF DEF081259, DEF111847 + +@SYMTestCaseDesc Window tests + REQUIREMENT: PREQ673 (Screen Scaling) + API: RWindowBase::InquireOffset(), RWindowBase::AbsPosition(),RWindowBase::Position() + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Loops through all the screen modes present in the wsini file, and then moves to the test screen + mode where it goes on changing the screen scale and origin. In each of the wsini screen modes and test + screen modes, it checks the test window's API's RWindowBase::InquireOffset(), RWindowBase::AbsPosition() + RWindowBase::Position(). Then it copies the content from either first or second half to second or first + half and compares both the regions so that its content are same. + Additionally, as part of defect fix DEF111847, this also loops through all the display modes, and if possible + tests each with the above described method. Previously, it use to only test Color256. + +@SYMTestExpectedResults The content of both halves of the screen should match. +*/ +void CTScreenModeScaling::WindowTestsL() + { + INFO_PRINTF1(_L("AUTO WindowTests : ")); + + TDisplayMode curDispMode; // Holds the current display mode being tested + + for(curDispMode = EGray2; curDispMode < EColorLast; curDispMode = TDisplayMode(curDispMode+1)) + { + if (curDispMode == ERgb) + { + continue; + } + CTClient* client=new(ELeave) CTClient(); + CleanupStack::PushL(client); + client->SetScreenNumber(iTest->iScreenNumber); + client->ConstructL(); + client->iGroup=new(ELeave) TestWindowGroup(client); + client->iGroup->ConstructL(); + client->iGroup->WinTreeNode()->SetOrdinalPosition(1); + RBlankWindow testWindow(client->iWs); + User::LeaveIfError(testWindow.Construct(*TheClient->iGroup->GroupWin(),ENullWsHandle)); + CleanupClosePushL(testWindow); + + TInt setDispMode; // Holds the actual display mode that was set + setDispMode = testWindow.SetRequiredDisplayMode(curDispMode); + + //Only do the tests if the requested mode was actually set + if(curDispMode == setDispMode) + { + //Create and show DisplayMode details message + _LIT(KModeDetails, "Display Mode: "); + TBuf<30> modeDetailsMessage(KModeDetails); + modeDetailsMessage.Append(DisplayModeAsString(curDispMode)); + LOG_MESSAGE(modeDetailsMessage); + + testWindow.Activate(); + TheClient->iGroup->GroupWin()->EnableScreenChangeEvents(); + TInt numOfModes=TheClient->iScreenModes.Count(); + TInt ii; + for (ii=0; iiiScreenModes[ii]; + TPixelsAndRotation pixelsAndRotation; + iCurrentScreenModeOrigin=TheClient->iScreen->GetScreenModeOrigin(iCurrentMode); + iCurrentScreenModeScale=TheClient->iScreen->GetScreenModeScale(iCurrentMode); + TheClient->iScreen->GetScreenModeSizeAndRotation(iCurrentMode,pixelsAndRotation); + if (pixelsAndRotation.iRotation==CFbsBitGc::EGraphicsOrientationNormal) + { + INFO_PRINTF1(_L(" Do Tests")); + TRAPD(ret,DoWindowTestsL()); + TEST(ret==KErrNone); + if (ret!=KErrNone) + { + INFO_PRINTF3(_L("DoWindowTestsL() return value - Expected: %d, Actual: %d"), KErrNone, ret); + } + + INFO_PRINTF1(_L(" Window Trees")); + client->iScreen->SetAppScreenMode(iCurrentMode); + client->Flush(); + } + } + TestDifferentScales(numOfModes-1); + } + CleanupStack::PopAndDestroy(2,client); + } + } + +void CTScreenModeScaling::TestDifferentScales(TInt aLastModeIdx) + { + if (aLastModeIdx<0) return; + TPixelsAndRotation pixelsAndRotation; + for (TInt modeCount=aLastModeIdx;modeCount>=0;--modeCount) + { + TheClient->iScreen->GetScreenModeSizeAndRotation(TheClient->iScreenModes[modeCount],pixelsAndRotation); + if (pixelsAndRotation.iRotation==CFbsBitGc::EGraphicsOrientationNormal) + break; + } + iCurrentMode=TheClient->iScreenModes[aLastModeIdx]; + TheClient->iScreen->SetAppScreenMode(iCurrentMode); + TheClient->iScreen->SetScreenMode(iCurrentMode); + TSizeMode storeModeData=TheClient->iScreen->GetCurrentScreenModeAttributes(); + TSizeMode testMode=storeModeData; + for (TInt xScale=1;xScale<4;++xScale) + { + for (TInt yScale=1;yScale<4;++yScale) + { + testMode.iScreenScale=TSize(xScale,yScale); + TestDifferentOrigin(testMode,TPoint(20,20)); + TestDifferentOrigin(testMode,TPoint(20,30)); + TestDifferentOrigin(testMode,TPoint(30,20)); + TestDifferentOrigin(testMode,TPoint(FullScreenModeSize.iWidth/2+640/FullScreenModeSize.iWidth*10,60)); + } + } + TheClient->iScreen->SetScreenMode(iCurrentMode); + TheClient->iScreen->SetCurrentScreenModeAttributes(storeModeData); + TInt defaultMode=TheClient->iScreenModes[0]; + TheClient->iScreen->SetAppScreenMode(defaultMode); + TheClient->iScreen->SetScreenMode(defaultMode); + } + +void CTScreenModeScaling::TestDifferentOrigin(TSizeMode &aMode,TPoint aOrigin) + { + TheClient->iScreen->SetScreenMode(iCurrentMode);//.. this is required because at the end of next screenmode test it will be set to zero screen mode + aMode.iOrigin=aOrigin; + TheClient->iScreen->SetCurrentScreenModeAttributes(aMode); + TheClient->iScreen->SetAppScreenMode(iCurrentMode); + TheClient->iScreen->SetScreenMode(iCurrentMode); + iCurrentScreenModeOrigin=TheClient->iScreen->GetScreenModeOrigin(iCurrentMode); + iCurrentScreenModeScale=TheClient->iScreen->GetScreenModeScale(iCurrentMode); + TRAPD(ret,DoWindowTestsL()); + TEST(ret==KErrNone); + if (ret!=KErrNone) + INFO_PRINTF3(_L("DoWindowTestsL() return value - Expected: %d, Actual: %d"), KErrNone, ret); + } + +void CTScreenModeScaling::DoWindowTestsL() + { + TheClient->iScreen->SetAppScreenMode(iCurrentMode); + TheClient->iScreen->SetScreenMode(iCurrentMode); + Copy2ndHalfOfScreen=(iCurrentScreenModeOrigin.iX>FullScreenModeSize.iWidth/2? 1 : 0); + TRect testWinRect(PhysicalToLogical(TPoint(),iCurrentScreenModeScale), + PhysicalToLogical(TPoint((Copy2ndHalfOfScreen ? FullScreenModeSize.iWidth + : FullScreenModeSize.iWidth/2), + FullScreenModeSize.iHeight)-iCurrentScreenModeOrigin,iCurrentScreenModeScale) + ); + testWinRect.Shrink(10,10); + iTestWinSize=testWinRect.Size(); + PositionTestL(testWinRect.iTl); + testWinRect.Shrink(10,10); + iTestWinSize=testWinRect.Size(); + PositionTestL(testWinRect.iTl); + BackedUpChildWindowTestL(testWinRect.iTl); + GetInvalidRegionTestL(testWinRect.iTl); + //NextScreenModeTestL(testWinRect.iTl); //This test needs a lot more work ### + } + +void CTScreenModeScaling::PositionTestL(TPoint aPostion) + { + iTestWin->SetExt(aPostion,iTestWinSize); + iTestWin->SetVisible(ETrue); + iTestWin->Invalidate(); + TheClient->Flush(); + TheClient->WaitForRedrawsToFinish(); + TestTopClientWindowPositionAPIs(aPostion,iTestWin->BaseWin()); + CopyAndCompareL(); + } + +void CTScreenModeScaling::BackedUpChildWindowTestL(TPoint aPostion) + { + iTestWin->SetVisible(ETrue); + TPoint backedUpWinPt=TPoint(iTestWinSize.iWidth/3,iTestWinSize.iHeight/4); + iBackedUpWin->SetExtL(backedUpWinPt,TSize(iTestWinSize.iWidth/6,iTestWinSize.iHeight/6)); + iBackedUpWin->SetVisible(ETrue); + TestChildWindowPositionAPIs(backedUpWinPt,aPostion,iBackedUpWin->BaseWin(),iTestWin->BaseWin()); + aPostion+=TPoint(10,10); + iTestWin->SetPos(aPostion); + TestTopClientWindowPositionAPIs(aPostion,iTestWin->BaseWin()); + TestChildWindowPositionAPIs(backedUpWinPt,aPostion,iBackedUpWin->BaseWin(),iTestWin->BaseWin()); + iTestWin->Invalidate(); + TheClient->Flush(); + TheClient->WaitForRedrawsToFinish(); + TestTopClientWindowPositionAPIs(aPostion,iTestWin->BaseWin()); + TestChildWindowPositionAPIs(backedUpWinPt,aPostion,iBackedUpWin->BaseWin(),iTestWin->BaseWin()); + CopyAndCompareL(); + iBackedUpWin->SetVisible(EFalse); + } + +void CTScreenModeScaling::NextScreenModeTestL(TPoint aPos) + { + TInt numOfModes=TheClient->iScreenModes.Count(); + TInt defaultMode=TheClient->iScreenModes[0]; + TInt lastMode=TheClient->iScreenModes[numOfModes-1]; + TInt mode=(iCurrentModeiScreenModes[ii]) + { + modeIdx=ii; + break; + } + } + TPoint screenModeOrigin(0,0); + TPixelsAndRotation pixelsAndRotation; + while (screenModeOrigin==TPoint()||(pixelsAndRotation.iRotation!=CFbsBitGc::EGraphicsOrientationNormal)) + { + mode=(mode==lastMode? defaultMode : TheClient->iScreenModes[++modeIdx]); + if (mode==iCurrentMode) + { + return; + } + screenModeOrigin=TheClient->iScreen->GetScreenModeOrigin(mode); + TheClient->iScreen->GetScreenModeSizeAndRotation(mode,pixelsAndRotation); + } + iTestWin->SetExt(aPos,iTestWinSize); + iTestWin->SetVisible(ETrue); + TheClient->Flush(); + CBasicWin* basicWin=new(ELeave) CBasicWin; + CleanupStack::PushL(basicWin); + basicWin->ConstructExtLD(*iTestWin,TPoint(),TSize(iTestWinSize.iWidth/5,iTestWinSize.iHeight/5)); + User::LeaveIfError(basicWin->BaseWin()->SetRequiredDisplayMode(EColor256)); + basicWin->AssignGC(*TheClient->iGc); + basicWin->BaseWin()->SetShadowDisabled(ETrue); + basicWin->BaseWin()->SetShadowHeight(0); + basicWin->Activate(); + TPoint pos(iTestWinSize.iWidth/3,iTestWinSize.iWidth/4); + basicWin->SetPos(pos); + TheClient->Flush(); + TheClient->WaitForRedrawsToFinish(); + TestChildWindowPositionAPIs(pos,aPos,basicWin->BaseWin(),iTestWin->BaseWin()); + iCurrentScreenModeScale=TheClient->iScreen->GetScreenModeScale(mode); + iCurrentScreenModeOrigin=TheClient->iScreen->GetScreenModeOrigin(mode); + Copy2ndHalfOfScreen=(iCurrentScreenModeOrigin.iX>FullScreenModeSize.iWidth/2? 1 : 0); + TheClient->iScreen->SetAppScreenMode(mode); + TheClient->iScreen->SetScreenMode(mode); + iTestWin->SetVisible(ETrue); + CopyAndCompareL(); + TheClient->iScreen->SetAppScreenMode(defaultMode); + TheClient->iScreen->SetScreenMode(defaultMode); + CleanupStack::PopAndDestroy(basicWin); + } + +void CTScreenModeScaling::GetInvalidRegionTestL(TPoint aPos) + { + iTestWin->SetExt(aPos,iTestWinSize); + iTestWin->SetVisible(ETrue); + iTestChildWin->SetExt(TPoint(iTestWinSize.iWidth>>2,iTestWinSize.iHeight>>2),TSize(iTestWinSize.iWidth>>1,iTestWinSize.iHeight>>1)); + iTestChildWin->SetVisible(ETrue); + TheClient->Flush(); // ensure testchildwin is on-screen + + CArrayFixFlat *rectList=new(ELeave) CArrayFixFlat(3); + CleanupStack::PushL(rectList); + rectList->AppendL(TRect(1,1,5,2)); + rectList->AppendL(TRect(iTest->StdTestWindowSize().iWidth>>1,iTest->StdTestWindowSize().iHeight>>1,iTest->StdTestWindowSize().iWidth,iTest->StdTestWindowSize().iHeight)); + rectList->AppendL(TRect(2,0,4,5)); + + // set iTestWin to a 'clean state' before invalidating rects in the window + iTestWin->DrawNow(); + TheClient->Flush(); + + // invalidate the various rectangles in iTestWin & then initiate a redraw of the window + RRegion invalidRegion; + RRegion region; + for (TInt index=0;indexCount();index++) + { + const TRect& myRect = (*rectList)[index]; + iTestWin->Invalidate(myRect); + region.AddRect(myRect); + } + CleanupStack::PopAndDestroy(rectList); + CleanupClosePushL(invalidRegion); + CleanupClosePushL(region); + iTestWin->Win()->GetInvalidRegion(invalidRegion); + CompareRegionsL(region, invalidRegion); + CleanupStack::PopAndDestroy(2,&invalidRegion); + iTestChildWin->SetVisible(EFalse); + + // ensure the test child win is removed + TheClient->Flush(); + TheClient->WaitForRedrawsToFinish(); + + TRect rect1(iTestWinSize); + TestGetInvalidRegionL(rect1); + TInt width=iTestWinSize.iWidth; + TInt height=iTestWinSize.iHeight; + TRect rect2(TPoint(width/6,height/6),TSize(width/3,height/3)); + TestGetInvalidRegionL(rect2); + + // invalidate the entire test window + iTestWin->Invalidate(); + TheClient->Flush(); + + iTestWin->SetPos(TPoint(15,15)); + iTestWin->SetPos(TPoint()); + iTestWin->SetPos(TPoint(-15,-15)); + iTestWin->SetPos(aPos); + RRegion invalid; + RRegion testRegion(rect1); + CleanupClosePushL(invalid); + CleanupClosePushL(testRegion); + iTestWin->Win()->GetInvalidRegion(invalid); + TBool retVal = !invalid.CheckError(); + TEST(retVal); + if (!retVal) + INFO_PRINTF3(_L("RRegion.CheckError() return value - Expected: %d, Actual: %d"), ETrue, retVal); + TEST(invalid.BoundingRect().iBr.iX<=iTestWinSize.iWidth); + if (invalid.BoundingRect().iBr.iX>iTestWinSize.iWidth) + INFO_PRINTF3(_L("invalid.BoundingRect().iBr.iX<=iTestWinSize.iWidth - Expected: %d, Actual: %d"), invalid.BoundingRect().iBr.iX, iTestWinSize.iWidth); + CompareRegionsL(testRegion,invalid); + CleanupStack::PopAndDestroy(2,&invalid); + + // redraw the test window & confirm + iTestWin->DrawNow(); + TheClient->Flush(); + CopyAndCompareL(); + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-0094 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc SpriteTestL + REQUIREMENT: PREQ673 (Screen Scaling) + API: RWsSprite::SetPosition() + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions In the same way as in window tests it shifts the screen modes. + In each screen modes it creates a sprite window and then it moves slightly + either side or bottom of the sprite, then it compares both the regions + to check whether content are same. + +@SYMTestExpectedResults The content of both halves of the screen should match. +*/ +void CTScreenModeScaling::SpriteTestL() + { + CTClient* client=new(ELeave) CTClient(); + CleanupStack::PushL(client); + client->SetScreenNumber(iTest->iScreenNumber); + client->ConstructL(); + client->iGroup=new(ELeave) TestWindowGroup(client); + client->iGroup->ConstructL(); + client->iGroup->WinTreeNode()->SetOrdinalPosition(1); + RBlankWindow color256(client->iWs); + User::LeaveIfError(color256.Construct(*TheClient->iGroup->GroupWin(),ENullWsHandle)); + CleanupClosePushL(color256); + color256.SetRequiredDisplayMode(EColor256); + color256.Activate(); + TInt numOfModes=TheClient->iScreenModes.Count(); + TInt flushState=TheClient->iWs.SetAutoFlush(ETrue); + TInt ii; + for (ii=0; iiiScreenModes[ii]; + TPixelsAndRotation pixelsAndRotation; + iCurrentScreenModeOrigin=TheClient->iScreen->GetScreenModeOrigin(iCurrentMode); + iCurrentScreenModeScale=TheClient->iScreen->GetScreenModeScale(iCurrentMode); + TheClient->iScreen->GetScreenModeSizeAndRotation(iCurrentMode,pixelsAndRotation); + DoSpriteTestsL(); + client->iScreen->SetAppScreenMode(iCurrentMode); + client->Flush(); + } + iCurrentMode=TheClient->iScreenModes[numOfModes-1]; + TheClient->iScreen->SetAppScreenMode(iCurrentMode); + TheClient->iScreen->SetScreenMode(iCurrentMode); + TSizeMode storeModeData=TheClient->iScreen->GetCurrentScreenModeAttributes(); + TSizeMode testMode=storeModeData; + for (TInt xScale=1;xScale<4;xScale++) + { + for (TInt yScale=1;yScale<4;yScale++) + { + testMode.iScreenScale=TSize(xScale,yScale); + TestDifferentOriginAndScaleForSpritesL(testMode,TPoint(20,20)); + TestDifferentOriginAndScaleForSpritesL(testMode,TPoint(20,30)); + TestDifferentOriginAndScaleForSpritesL(testMode,TPoint(30,20)); + TestDifferentOriginAndScaleForSpritesL(testMode,TPoint(FullScreenModeSize.iWidth/2+10,60)); + } + } + TheClient->iScreen->SetScreenMode(iCurrentMode); + TheClient->iScreen->SetCurrentScreenModeAttributes(storeModeData); + TInt defaultMode=TheClient->iScreenModes[0]; + TheClient->iScreen->SetAppScreenMode(defaultMode); + TheClient->iScreen->SetScreenMode(defaultMode); + CleanupStack::PopAndDestroy(2,client); + TheClient->iWs.SetAutoFlush(flushState); + } + +void CTScreenModeScaling::TestDifferentOriginAndScaleForSpritesL(TSizeMode &aMode, TPoint aOrigin) + { + TheClient->iScreen->SetScreenMode(iCurrentMode); + aMode.iOrigin=aOrigin; + TheClient->iScreen->SetCurrentScreenModeAttributes(aMode); + iCurrentScreenModeOrigin=TheClient->iScreen->GetScreenModeOrigin(iCurrentMode); + iCurrentScreenModeScale=TheClient->iScreen->GetScreenModeScale(iCurrentMode); + DoSpriteTestsL(); + } + +void CTScreenModeScaling::DoSpriteTestsL() + { + TheClient->iScreen->SetAppScreenMode(iCurrentMode); + TheClient->iScreen->SetScreenMode(iCurrentMode); + TPixelsAndRotation pixelsAndRotation; + TheClient->iScreen->GetScreenModeSizeAndRotation(iCurrentMode,pixelsAndRotation); + RWsSprite sprite; + TSize spriteSize=iSpriteBitmap.SizeInPixels(); + if (spriteSize.iWidth*iCurrentScreenModeScale.iWidth>FullScreenModeSize.iWidth/2) + spriteSize.iWidth=(FullScreenModeSize.iWidth/2-20)/iCurrentScreenModeScale.iWidth; + SetUpSpriteLC(sprite,TheClient->iWs,*iBlankWin->BaseWin()); + sprite.SetPosition(TPoint()); + CTestSpriteWin* spriteWin=new(ELeave) CTestSpriteWin(iSpriteBitmap); + CleanupStack::PushL(spriteWin); + spriteWin->ConstructExtLD(*TheClient->iGroup,PhysicalToLogical(TPoint()-iCurrentScreenModeOrigin,iCurrentScreenModeScale),spriteSize); + User::LeaveIfError(spriteWin->BaseWin()->SetRequiredDisplayMode(EColor256)); + spriteWin->AssignGC(*TheClient->iGc); + spriteWin->SetVisible(ETrue); + spriteWin->Activate(); + spriteWin->UpdateWin(TPoint()); + spriteWin->BaseWin()->SetShadowDisabled(ETrue); + spriteWin->BaseWin()->SetShadowHeight(0); + TheClient->Flush(); + TheClient->WaitForRedrawsToFinish(); + TPoint spritePosition; + if (iCurrentScreenModeOrigin.iX<=spriteSize.iWidth || iCurrentScreenModeOrigin.iY<=spriteSize.iHeight) + { + if (pixelsAndRotation.iRotation==CFbsBitGc::EGraphicsOrientationNormal || pixelsAndRotation.iRotation==CFbsBitGc::EGraphicsOrientationRotated180) + spritePosition=TPoint(spriteSize.iWidth+1,0); + else + spritePosition=TPoint(0,spriteSize.iHeight+1); + } + sprite.SetPosition(spritePosition); + const TInt KAnimationGrace = 35000; //defined in server.cpp, but can be changed in wsini.ini + User::After(KAnimationGrace); + TBool retVal = TheClient->iScreen->RectCompare(TRect(PhysicalToLogical(TPoint()-iCurrentScreenModeOrigin,iCurrentScreenModeScale),spriteSize),TRect(spritePosition,spriteSize),CWsScreenDevice::EIncludeSprite); + TEST(retVal); + if (!retVal) + INFO_PRINTF3(_L("TheClient->iScreen->RectCompare(rect1,rect2) return value - Expected: %d, Actual: %d"), ETrue, retVal); + + sprite.SetPosition(TPoint()); + CleanupStack::PopAndDestroy(spriteWin); + CleanupStack::PopAndDestroy(&sprite); + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-0095 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Rotation Tests + REQUIREMENT: PREQ673 (Screen Scaling) + API: RWindowBase::InquireOffset(), RWindowBase::AbsPosition(),RWindowBase::Position() + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions For each of the screen mode with all its rotation it checks whether the window + is correctly placed in particular screen mode. Then it creates a child window + and checks whether it s correctly placed. + +@SYMTestExpectedResults Checks the windows are positioned correctly according to the origin,scale and rotation + of the new screen mode. +*/ +void CTScreenModeScaling::RotationTestsL() + { + CTClient* client=new(ELeave) CTClient(); + CleanupStack::PushL(client); + client->SetScreenNumber(iTest->iScreenNumber); + client->ConstructL(); + client->iGroup=new(ELeave) TestWindowGroup(client); + client->iGroup->ConstructL(); + client->iGroup->WinTreeNode()->SetOrdinalPosition(1); + RBlankWindow color256(client->iWs); + User::LeaveIfError(color256.Construct(*TheClient->iGroup->GroupWin(),ENullWsHandle)); + CleanupClosePushL(color256); + color256.SetRequiredDisplayMode(EColor256); + color256.Activate(); + TInt oldCurrentMode=0; + TInt ii; + //TInt screenMode=TheClient->iScreen->CurrentScreenMode(); + for (ii=0;iiiScreenModes.Count();) + { + iCurrentMode=TheClient->iScreenModes[ii]; + if (iCurrentMode!=oldCurrentMode) + { + client->iScreen->SetAppScreenMode(iCurrentMode); + TheClient->iScreen->SetScreenMode(iCurrentMode); + TheClient->iScreen->SetAppScreenMode(iCurrentMode); + } + TPixelsAndRotation pixelsAndRotation; + TheClient->iScreen->GetDefaultScreenSizeAndRotation(pixelsAndRotation); + oldCurrentMode=iCurrentMode; + CArrayFixFlat* rotations=new(ELeave) CArrayFixFlat(1); + CleanupStack::PushL(rotations); + User::LeaveIfError(TheClient->iScreen->GetRotationsList(iCurrentMode,rotations)); + TInt count=rotations->Count(); + TInt jj=0; + if (count>1) + { + for (jj=0;jjiScreen->SetCurrentRotations(oldCurrentMode,REINTERPRET_CAST(CFbsBitGc::TGraphicsOrientation&,currentRotation)); + CleanupStack::PopAndDestroy(rotations); + iCurrentScreenModeOrigin=TheClient->iScreen->GetScreenModeOrigin(oldCurrentMode); + iCurrentScreenModeScale=TheClient->iScreen->GetScreenModeScale(oldCurrentMode); + TRect testWinRect(PhysicalToLogical(TPoint(),iCurrentScreenModeScale), + PhysicalToLogical(TPoint((Copy2ndHalfOfScreen ? FullScreenModeSize.iWidth : FullScreenModeSize.iWidth/2),FullScreenModeSize.iHeight)-iCurrentScreenModeOrigin,iCurrentScreenModeScale) + ); + testWinRect.Shrink(10,10); + iTestWin->SetExtL(testWinRect.iTl,testWinRect.Size()); + iTestWin->Invalidate(); + iTestWin->SetVisible(ETrue); + TheClient->Flush(); + TheClient->WaitForRedrawsToFinish(); + TestTopClientWindowPositionAPIs(testWinRect.iTl,iTestWin->BaseWin()); + TPoint backedUpWinPt=TPoint(testWinRect.Width()/3,testWinRect.Height()/4); + iBackedUpWin->SetVisible(ETrue); + iBackedUpWin->SetExtL(backedUpWinPt,TSize(testWinRect.Width()/6,testWinRect.Height()/6)); + TestChildWindowPositionAPIs(backedUpWinPt,testWinRect.iTl,iBackedUpWin->BaseWin(),iTestWin->BaseWin()); + iTestWin->SetVisible(EFalse); + iBackedUpWin->SetVisible(EFalse); + } + CleanupStack::PopAndDestroy(2,client); + } + +void CTScreenModeScaling::DrawTransparentWindows() + { + //.. First Draw on Backgroundbitmap + iBackgroundBitmap->Gc().SetBrushColor(TRgb(255,0,255)); + iBackgroundBitmap->Gc().SetBrushStyle(CGraphicsContext::ESolidBrush); + iBackgroundBitmap->Gc().SetPenStyle(CGraphicsContext::ENullPen); + iBackgroundBitmap->Gc().DrawRect(iWinSize); + + //.. Invalidate the background bitmap and do bitBlt to iCheckBitmap also + iBackgroundWin->BaseWin()->SetVisible(ETrue); + iBackgroundWin->DrawNow(); + + //.. Copy to checkbitmap + iCheckBitmap->Gc().SetFaded(EFalse); + iCheckBitmap->Gc().BitBlt(TPoint(),&iBackgroundBitmap->Bitmap()); + + //.. Set the grade of transperency + iTransparencyBitmap->Gc().SetBrushColor(TRgb::Gray256(128)); + iTransparencyBitmap->Gc().SetBrushStyle(CGraphicsContext::ESolidBrush); + iTransparencyBitmap->Gc().SetPenStyle(CGraphicsContext::ENullPen); + iTransparencyBitmap->Gc().DrawRect(iWinSize); + + //.. Then draw to the fore ground bitmap and invalidate the second window + iForegroundBitmap->Gc().Reset(); + iForegroundBitmap->Gc().SetPenStyle(CGraphicsContext::ESolidPen); + iForegroundBitmap->Gc().SetPenSize(TSize(1,1)); + iForegroundBitmap->Gc().SetPenColor(TRgb(0,0,0)); + iForegroundBitmap->Gc().DrawLine(TPoint(0,0),TPoint(iWinSize.iWidth,iWinSize.iHeight)); + iForegroundBitmap->Gc().DrawLine(TPoint(iWinSize.iWidth,0),TPoint(0,iWinSize.iHeight)); + iTransWin->BaseWin()->SetVisible(ETrue); + iTransWin->Invalidate(); + iTransWin->DrawNow(); + + iCheckBitmap->Gc().AlphaBlendBitmaps(TPoint(0,0),&iForegroundBitmap->Bitmap(),&iCheckBitmap->Bitmap() + ,TRect(iWinSize),TPoint(0,0),&iTransparencyBitmap->Bitmap(),TPoint(0,0)); + iCheckWin->BaseWin()->SetVisible(ETrue); + iCheckWin->BackedUpWin()->UpdateScreen(); + TheClient->Flush(); + TheClient->WaitForRedrawsToFinish(); + CheckRect(iTransWin,iCheckWin,TRect(iWinSize),_L("DrawTransparentWindows() CheckRect failed")); + } + +// !!! THE COMMENT BELOW IS DISABLED BECAUSE TransparentTests() METHOD IS NOT USED !!! +//** +//@SYMTestCaseID GRAPHICS-WSERV-0096 +// +//@SYMDEF DEF081259 +// +//@SYMTestCaseDesc TransparentTests +// REQUIREMENT: PREQ673 (Screen Scaling) +// API: CWindowGc::AlphaBlendBitmaps() +// +//@SYMTestPriority High +// +//@SYMTestStatus Implemented +// +//@SYMTestActions The main logic behind this test is to copy the content of the background window +// bitmap to checkwindow bitmap and then use the foreground window bitmap and transparency bitmap +// with the function AlphaBlendBitmaps() to get the content present on the combination of +// foreground(transparent) window and background window. Then compare both the regions of the +// window to check whether the content is same. +// +//@SYMTestExpectedResults The content of both halves of the screen should match. +//*/ +void CTScreenModeScaling::TransparentTestsL() + { + TInt flushState=TheClient->iWs.SetAutoFlush(ETrue); + TInt defaultMode=TheClient->iScreenModes[0]; + TheClient->iScreen->SetAppScreenMode(defaultMode); + TheClient->iScreen->SetScreenMode(defaultMode); + CTClient* client=new(ELeave) CTClient(); + CleanupStack::PushL(client); + client->SetScreenNumber(iTest->iScreenNumber); + client->ConstructL(); + client->iGroup=new(ELeave) TestWindowGroup(client); + client->iGroup->ConstructL(); + client->iGroup->WinTreeNode()->SetOrdinalPosition(1); + RBlankWindow color256(client->iWs); + User::LeaveIfError(color256.Construct(*TheClient->iGroup->GroupWin(),ENullWsHandle)); + CleanupClosePushL(color256); + color256.SetRequiredDisplayMode(EColor256); + color256.Activate(); + client->Flush(); + DrawTransparentWindows(); + iCurrentMode=TheClient->iScreenModes[TheClient->iScreenModes.Count()-1]; + TheClient->iScreen->SetAppScreenMode(iCurrentMode); + TheClient->iScreen->SetScreenMode(iCurrentMode); + TSizeMode storeModeData=TheClient->iScreen->GetCurrentScreenModeAttributes(); + TSizeMode testMode=storeModeData; + for (TInt xScale=1;xScale<4;xScale++) + { + for (TInt yScale=1;yScale<4;yScale++) + { + testMode.iScreenScale=TSize(xScale,yScale); + TestDifferentOriginAndScaleForTranspWin(testMode,TPoint(20,20)); + TestDifferentOriginAndScaleForTranspWin(testMode,TPoint(20,30)); + TestDifferentOriginAndScaleForTranspWin(testMode,TPoint(30,20)); + TestDifferentOriginAndScaleForTranspWin(testMode,TPoint(FullScreenModeSize.iWidth/2+1,60)); + } + } + TheClient->iScreen->SetScreenMode(iCurrentMode); + TheClient->iScreen->SetCurrentScreenModeAttributes(storeModeData); + client->iScreen->SetAppScreenMode(iCurrentMode); + client->Flush(); + TheClient->iScreen->SetAppScreenMode(defaultMode); + TheClient->iScreen->SetScreenMode(defaultMode); + TheClient->iWs.SetAutoFlush(flushState); + CleanupStack::PopAndDestroy(2,client); + } + +void CTScreenModeScaling::TestDifferentOriginAndScaleForTranspWin(TSizeMode &aMode,TPoint aOrigin) + { + TheClient->iScreen->SetScreenMode(iCurrentMode); + aMode.iOrigin=aOrigin; + TheClient->iScreen->SetCurrentScreenModeAttributes(aMode); + TheClient->iScreen->SetAppScreenMode(iCurrentMode); + TheClient->iScreen->SetScreenMode(iCurrentMode); + TRAPD(ret,DrawTransparentWindows()); + TEST(ret==KErrNone); + if (ret!=KErrNone) + INFO_PRINTF3(_L("DrawTransparentWindows() return value - Expected: %d, Actual: %d"), KErrNone, ret); + + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-0097 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc AppScreenModeTest + REQUIREMENT: PREQ673 (Screen Scaling) + API: CWsScreenDevice::SetAppScreenMode() + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Enable the visibility of Test window, Call SetAppScreenMode() API with different + screen mode. Check the variable which is set in its draw function. + +@SYMTestExpectedResults The variable should not be set when the application screen mode is different + then current screen mode. +*/ +void CTScreenModeScaling::AppScreenModeTestL() + { + TheClient->iScreen->SetAppScreenMode(0); + TheClient->iScreen->SetScreenMode(0); + iTestWin->iDrawn=EFalse; + iTestWin->SetExtL(TPoint(),TSize(FullScreenModeSize.iWidth/2,FullScreenModeSize.iHeight)); + iTestWin->SetVisible(ETrue); + TheClient->Flush(); + TheClient->WaitForRedrawsToFinish(); + TEST(iTestWin->iDrawn); + if (!iTestWin->iDrawn) + INFO_PRINTF3(_L("iTestWin->iDrawn - Expected: %d, Actual: %d"), ETrue, iTestWin->iDrawn); + + iTestWin->iDrawn=EFalse; + TheClient->iScreen->SetAppScreenMode(2); + TheClient->iScreen->SetScreenMode(0); + iTestWin->Invalidate(); + TheClient->Flush(); + TEST(!iTestWin->iDrawn); + if (iTestWin->iDrawn) + INFO_PRINTF3(_L("iTestWin->iDrawn - Expected: %d, Actual: %d"), EFalse, iTestWin->iDrawn); + + TheClient->iScreen->SetAppScreenMode(0); + TheClient->Flush(); + TheClient->WaitForRedrawsToFinish(); + TEST(iTestWin->iDrawn); + if (!iTestWin->iDrawn) + INFO_PRINTF3(_L("iTestWin->iDrawn - Expected: %d, Actual: %d"), ETrue, iTestWin->iDrawn); + + iTestWin->iDrawn=EFalse; + TheClient->iScreen->SetScreenMode(1); + iTestWin->Invalidate(); + TheClient->Flush(); + TEST(!iTestWin->iDrawn); + if (iTestWin->iDrawn) + INFO_PRINTF3(_L("iTestWin->iDrawn - Expected: %d, Actual: %d"), EFalse, iTestWin->iDrawn); + + iTestWin->SetVisible(EFalse); + TheClient->iScreen->SetAppScreenMode(0); + TheClient->iScreen->SetScreenMode(0); + } + +void CTScreenModeScaling::RunTestCaseL(TInt /*aCurTestCase*/) + { + _LIT(KWindowTests,"Window Tests"); + _LIT(KSpriteTest,"Sprite Test"); + _LIT(KRotationTests,"Rotation Tests"); + _LIT(KTransparentTests,"Transparent Tests"); + _LIT(KAppScreenModeTest,"AppScreenMode Test"); + _LIT(KScalling,"Scaling not Supported"); + _LIT(KModes,"Only one Screen Size Mode"); + + ((CTScreenModeScalingStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); + switch(++iTest->iState) + { + case 1: + { + ((CTScreenModeScalingStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0097")); + TInt numScrModes=TheClient->iScreen->NumScreenModes(); + if (numScrModes<2 || !CheckScalingSupportedOrNot()) + { + if (numScrModes<2) + LOG_MESSAGE(KModes); + else + LOG_MESSAGE(KScalling); + TestComplete(); + return; + } + iTest->LogSubTest(KAppScreenModeTest); + AppScreenModeTestL(); + } + break; + case 2: + ((CTScreenModeScalingStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0093")); + iTest->LogSubTest(KWindowTests); + WindowTestsL(); + break; + case 3: + ((CTScreenModeScalingStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0094")); + iTest->LogSubTest(KSpriteTest); + SpriteTestL(); + break; + case 4: + ((CTScreenModeScalingStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0095")); + iTest->LogSubTest(KRotationTests); + RotationTestsL(); + break; + case 5: + ((CTScreenModeScalingStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + iTest->LogSubTest(KTransparentTests); + //TransparentTestsL(); //This tests currently fails sometimes for reasons not understood #### + break; + default: + { + TInt defaultMode=TheClient->iScreenModes[0]; + TheClient->iScreen->SetAppScreenMode(defaultMode); + TheClient->iScreen->SetScreenMode(defaultMode); + } + ((CTScreenModeScalingStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + ((CTScreenModeScalingStep*)iStep)->CloseTMSGraphicsStep(); + TestComplete(); + return; + } + ((CTScreenModeScalingStep*)iStep)->RecordTestResultL(); + } + +__WS_CONSTRUCT_STEP__(ScreenModeScaling) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TScreenModeScaling.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TScreenModeScaling.h Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,164 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Definitions common for both scren mode positioning and scaling +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef __TSCREENMODESCALING_H__ +#define __TSCREENMODESCALING_H__ + + +#include +#include +#include "../tlib/testbase.h" +#include "AUTO.H" +#include "TGraphicsHarness.h" + +_LIT(ScalingTestName,"Screen Mode Scaling"); + +GLREF_C void ClearBitmap(CFbsBitmap* aBitMap); + +class CBasicWin : public CTWin + { +public: + //Virtual Function from CTBaseWin + void Draw(); + TInt iDrawn; + }; + +class CBmpWin : public CTWin + { +public: + inline CBmpWin(CFbsBitmap& aScreenBmp) :iScreenBmp(aScreenBmp) {} + //Virtual Function from CTBaseWin + void Draw(); +private: + CFbsBitmap& iScreenBmp; + }; + +class CSpriteWin : public CTWin + { +public: + inline CSpriteWin(CFbsBitmap& aSpriteBitmap) :iSpriteBitmap(aSpriteBitmap) {} + ~CSpriteWin(); + inline void SetState(TInt aState) {iState=aState;} + void UpdateState(TInt aState); + //Virtual Function from CTBaseWin + void Draw(); +private: + CFbsBitmap& iSpriteBitmap; + TInt iState; + }; + +class CTestSpriteWin : public CTWin + { +public: + inline CTestSpriteWin(CFbsBitmap& aSpriteBitmap) :iSpriteBitmap(aSpriteBitmap) {} + ~CTestSpriteWin(); + inline void SetOrigin(TPoint aOrigin) {iOrigin=aOrigin;} + void UpdateWin(TPoint aOrigin); + //Virtual Function from CTBaseWin + void Draw(); +private: + CFbsBitmap& iSpriteBitmap; + TPoint iOrigin; + }; + +class CBitMapWin : public CTWin + { +public: + inline CBitMapWin(CBitmap* aBackupBitmap) :iBackup(aBackupBitmap) {} + //Virtual Function from CTBaseWin + void Draw(); +private: + CBitmap* iBackup; + }; + + + +class CTScreenModeScaling : public CTWsGraphicsBase + { +public: + CTScreenModeScaling(CTestStep* aStep); + ~CTScreenModeScaling(); + void ConstructL(); + void WindowTestsL(); + void SpriteTestL(); + void RotationTestsL(); + void TransparentTestsL(); + void AppScreenModeTestL(); + +protected: + virtual void RunTestCaseL(TInt aCurTestCase); + +private: + void DoWindowTestsL(); + void TestTopClientWindowPositionAPIs(TPoint aPos,RWindowBase* aWin); + void TestChildWindowPositionAPIs(TPoint aPos,TPoint aParentPos,RWindowBase* aWin,RWindowBase* aParentWin); + void TestRect(); + void CompareRegionsL(const TRegion &aRegion1,const TRegion &aRegion2); + void TestGetInvalidRegionL(TRect& aRect); + void CopyAndCompareL(); + void PositionTestL(TPoint aPostion); + void BackedUpChildWindowTestL(TPoint aPostion); + void NextScreenModeTestL(TPoint aPos); + void GetInvalidRegionTestL(TPoint aPos); + void TestDifferentScales(TInt aLastMode); + void TestDifferentOrigin(TSizeMode &aMode,TPoint aOrigin); + void DoSpriteTestsL(); + void TestDifferentOriginAndScaleForSpritesL(TSizeMode &aMode,TPoint aOrigin); + void SetUpSpriteLC(RWsSprite &aSprite,RWsSession &aSession,RWindowTreeNode &aWindow,TInt aFlags=ESpriteNoShadows); + void DrawTransparentWindows(); + void TestDifferentOriginAndScaleForTranspWin(TSizeMode &aMode,TPoint aOrigin); +private: + CFbsBitmap iSpriteBitmap; + CBmpWin* iBitmapWin; + CFbsBitmap* iScreenBitmap; + CBasicWin *iTestWin; + CTBackedUpWin* iBackedUpWin; + CTBlankWindow* iBlankWin; + CTBlankWindow* iTestChildWin; + TInt iCurrentMode; + TSize iTestWinSize; + TPoint iCurrentScreenModeOrigin; + TSize iCurrentScreenModeScale; + CTBackedUpWin* iCheckWin; + CBitmap* iCheckBitmap; + CBitmap* iTransparencyBitmap; + CBitmap* iBackgroundBitmap; + CBitmap* iForegroundBitmap; + CBitMapWin* iTransWin; + CBitMapWin* iBackgroundWin; + TSize iWinSize; + TDisplayMode iDisplayMode; + }; + +class CTScreenModeScalingStep : public CTGraphicsStep + { +public: + CTScreenModeScalingStep(); +protected: + //from CTGraphicsStep + virtual CTGraphicsBase* CreateTestL(); + }; + +_LIT(KTScreenModeScalingStep,"TScreenModeScaling"); + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TTEXTCURS.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TTEXTCURS.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,2040 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Test the text cursor. +// +// This suite of tests checks to see if the TextCursors are operating +// correctly for a number of use case scenarios; see doxygen comments +// for each sub-test. This test suite is applicable on both winscw +// emulator and armv5 target hardware. However, it must be noted that +// text cursors are special due to their timeliness. The text cursor +// must flash every second: half a second ON, half a second OFF. One +// consequence of this is that when the test suite is run on emulator, +// the PC must be otherwise quiescent. No other IO or CPU intensive +// activities may occur on the system, because these will cause delays +// to the flashing of the text cursor giving unreliable results. +// Where timeliness is a consideration, we use TEST_SOFTFAIL_WINSCW so +// that if the test fails and we are running on the PC emulator, we only +// record the fact, but don't mark the test as failing. + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include "TTEXTCURS.H" +#include "graphics/windowserverconstants.h" + +const TInt KNumberOfCustoTextCursors = 3; +const TInt KTextCursorInitialIdValue = 1001; +const TInt KTextCursorPanicUid1 = 200; +const TInt KTextCursorPanicUid2 = 2000; +const TInt KTextCursorPanicUid3 = 3000; +const TInt KTextCursorPanicUid4 = 4000; +const TInt KTextCursorPanicUid5 = 5000; + +CTestBase* CTCursorTest::iStaticTest = NULL; +const TInt kWinWidth=400; +const TInt kWinHeight=100; +const TSize kWinSize(kWinWidth,kWinHeight); +const TInt kWinXPos=150; +const TInt kCursorWidth = 10; +const TInt kCursorHeight = 20; +const TSize kCursorSize(kCursorWidth,kCursorHeight); +const TPoint kWin1TopLeft(kWinXPos,0); +const TPoint kWin2TopLeft(kWinXPos,kWinHeight+10); + +LOCAL_D void DeleteSpriteMember(TAny* aSpriteMember) + { + TSpriteMember* member=reinterpret_cast(aSpriteMember); + delete member->iBitmap; + member->iBitmap=NULL; + delete member->iMaskBitmap; + member->iMaskBitmap=NULL; + } + +CCustomTextCursor::~CCustomTextCursor() + { + const TInt count = iSpriteMemberArray.Count(); + for (TInt index=0; indexLoad(TEST_BITMAP_NAME, EMbmWsautotestBmp1)); + spriteMember.iMaskBitmap = new (ELeave) CFbsBitmap; + User::LeaveIfError(spriteMember.iMaskBitmap->Load(TEST_BITMAP_NAME, EMbmWsautotestBmp1mask)); + + User::LeaveIfError(iSpriteMemberArray.Append(spriteMember)); + CleanupStack::Pop(&spriteMember); + + // create unique-id accross screens + // + iIdentifier = KTextCursorInitialIdValue + aScreenNumber*KNumberOfCustoTextCursors + aBmpIndex; + iAlignment = (RWsSession::TCustomTextCursorAlignment)(aBmpIndex); + } + +CCustomTextCursor* CCustomTextCursor::CreateCustomTextCursorL(TInt aScreenNumber,TInt aBmpIndex,CTestBase* aTest) + { + CCustomTextCursor* customTextCursor = new (ELeave) CCustomTextCursor(aTest); + CleanupStack::PushL(customTextCursor); + customTextCursor->ConstructL(aScreenNumber,aBmpIndex); + CleanupStack::Pop(customTextCursor); + return customTextCursor; + } + +/* + * Wrapper class for a list of custom text cursor. + */ +class CCustomTextCursorsWrapper : public CBase + { +public: + static CCustomTextCursorsWrapper* NewLC(TInt aScreenNumber,CTestBase* aTest); + ~CCustomTextCursorsWrapper(); + inline RPointerArray& CustomTextCursorsArray(); + inline CCustomTextCursor& CustomTextCursor(TInt aIndex); +private: + void ConstructL(TInt aScreenNumber,CTestBase* aTest); +private: + RPointerArray iCustomTextCursors; + }; + +inline RPointerArray& CCustomTextCursorsWrapper::CustomTextCursorsArray() + { + return iCustomTextCursors; + } + +inline CCustomTextCursor& CCustomTextCursorsWrapper::CustomTextCursor(TInt aIndex) + { + return *(iCustomTextCursors[aIndex]); + } + +CCustomTextCursorsWrapper* CCustomTextCursorsWrapper::NewLC(TInt aScreenNumber,CTestBase* aTest) + { + CCustomTextCursorsWrapper* self = new(ELeave) CCustomTextCursorsWrapper(); + CleanupStack::PushL(self); + self->ConstructL(aScreenNumber,aTest); + return self; + } + +CCustomTextCursorsWrapper::~CCustomTextCursorsWrapper() + { + iCustomTextCursors.ResetAndDestroy(); + iCustomTextCursors.Close(); + } + +void CCustomTextCursorsWrapper::ConstructL(TInt aScreenNumber, CTestBase* aTest) + { + for (TInt index=0; indexConstruct((TInt)aScreenNumber)); + RWindowGroup group(ws); + if (group.Construct(444)==KErrNone) + { + group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close + RWindow wnd(ws); + if (wnd.Construct(group, TInt32(&ws))==KErrNone) + { + TTextCursor tc; + tc.iHeight=10; + tc.iAscent=5; + tc.iWidth=10; + tc.iFlags=0; + tc.iColor=TRgb(0,0,0); + switch(aInt) + { + case 0: + { + /* TESTCASE: 6.1 + * TITLE: Invalid use of a custom text cursor ID (basic text cursor). + * IMPORTANCE: 1 + * REQUIREMENT: Unknown. + * + * ACTION: This test tries to set a text cursor using an ID which is invalid. + * + * CHECK: The thread should panic with the exit reason EWservPanicInvalidTextCursor + */ + tc.iType=(TTextCursor::EType)KTextCursorPanicUid1; + group.SetTextCursor(wnd,TPoint(10,10),tc); + } + break; + case 1: + { + /* TESTCASE: 6.2 + * TITLE: Invalid use of a window for a text cursor. + * IMPORTANCE: 1 + * REQUIREMENT: REQ 1079, CR RDEF-5F7Q24 (10/04/2003). + * + * ACTION: This test tries to set a text cursor using a window which is not part + * of the window group calling the setting API. + * + * CHECK: The thread should panic with the exit reason EWservPanicWindow + */ + tc.iType=(TTextCursor::EType)KTextCursorPanicUid2; + group.SetTextCursor(*TestWin->Win(),TPoint(10,10),tc); + } + break; + case 2: + { + /* TESTCASE: 6.3 + * TITLE: Invalid use of a custom text cursor ID. + * IMPORTANCE: 1 + * REQUIREMENT: REQ 1079, CR RDEF-5F7Q24 (10/04/2003). + * + * ACTION: This test tries to set a text cursor using an ID which is associated to + * an non-existing custom text cursor. + * + * CHECK: The thread should panic with the exit reason EWservPanicNoCustomTextCursor + */ + tc.iType=(TTextCursor::EType)KTextCursorPanicUid3; + group.SetTextCursor(wnd,TPoint(10,10),tc); + } + break; + case 3: + { + /* TESTCASE: 6.4 + * TITLE: Invalid use of a custom text cursor ID. + * IMPORTANCE: 1 + * REQUIREMENT: REQ 1079, CR RDEF-5F7Q24 (10/04/2003). + * + * ACTION: This test tries to set a custom text cursor which has been set to use + * an invalid alignment. + * + * CHECK: The thread should panic with the exit reason EWservPanicCustomTextCursorAlign + */ + CCustomTextCursor* customTextCursor=NULL; + TRAPD(error, customTextCursor=CCustomTextCursor::CreateCustomTextCursorL((TInt)aScreenNumber,0,iStaticTest)); + if (error==KErrNone) + { + error = ws.SetCustomTextCursor(KTextCursorPanicUid4, customTextCursor->iSpriteMemberArray.Array(), 0, (RWsSession::TCustomTextCursorAlignment)(RWsSession::ECustomTextCursorAlignBottom+1)); + if (error==KErrNone || error==KErrAlreadyExists) + { + tc.iType=(TTextCursor::EType)KTextCursorPanicUid4; + group.SetTextCursor(wnd,TPoint(10,10),tc); + } + } + delete customTextCursor; + } + break; + case 4: + { + /* TESTCASE: 6.5 + * TITLE: Use of an invalid custom text cursor + * IMPORTANCE: 1 + * REQUIREMENT: REQ 1079, CR RDEF-5F7Q24 (10/04/2003). + * + * ACTION: This test tries to set a custom text cursor which does not have + * any sprite member set. + * + * CHECK: The thread should panic with the exit reason EWservPanicNoSpriteMember + */ + RArray spriteMemberArray; + const TInt error = ws.SetCustomTextCursor(KTextCursorPanicUid5, spriteMemberArray.Array(), 0, (RWsSession::TCustomTextCursorAlignment)(RWsSession::ECustomTextCursorAlignBottom)); + if (error==KErrNone || error==KErrAlreadyExists) + { + tc.iType=(TTextCursor::EType)KTextCursorPanicUid5; + group.SetTextCursor(wnd,TPoint(10,10),tc); + } + } + break; + case 5: + { + // Uncover set.cursor.iType < TTextCursor::ETypeFirst code path + tc.iType=(TTextCursor::EType)TTextCursor::ETypeFirst - 1; + group.SetTextCursor(wnd,TPoint(10,10),tc); + } + break; + case 6: + { + // Uncover (set.cursor.iFlags&static_cast(TTextCursor::EPrivateFlags) code path + tc.iFlags=ETextCursorPrivateFlags; + group.SetTextCursor(wnd,TPoint(10,10),tc); + } + break; + case 7: + { + // Uncover (iGroupWin != searchWin) i.e. bogus group window + tc.iType=(TTextCursor::EType)TTextCursor::ETypeRectangle; + RWindow windowNotAssociatedWithAGroup(ws); + group.SetTextCursor(windowNotAssociatedWithAGroup, TPoint(10,10),tc); + } + break; + } + } + ws.Flush(); + } + } + return(EWsExitReasonBad); + } + +void CTCursorTest::TestPanicsL() + { + TEST(iTest->TestWsPanicL(DoPanicTest, EWservPanicInvalidTextCursor, 0, (TAny*)iTest->iScreenNumber)); + TEST(iTest->TestWsPanicL(DoPanicTest, EWservPanicWindow, 1, (TAny*)iTest->iScreenNumber)); + TEST(iTest->TestWsPanicL(DoPanicTest, EWservPanicNoCustomTextCursor, 2, (TAny*)iTest->iScreenNumber)); + TEST(iTest->TestWsPanicL(DoPanicTest, EWservPanicCustomTextCursorAlign, 3, (TAny*)iTest->iScreenNumber)); + TEST(iTest->TestWsPanicL(DoPanicTest, EWservPanicNoSpriteMember, 4, (TAny*)iTest->iScreenNumber)); + TEST(iTest->TestWsPanicL(DoPanicTest, EWservPanicInvalidTextCursor, 5, (TAny*)iTest->iScreenNumber)); + TEST(iTest->TestWsPanicL(DoPanicTest, EWservPanicInvalidTextCursor, 6, (TAny*)iTest->iScreenNumber)); + TEST(iTest->TestWsPanicL(DoPanicTest, EWservPanicWindow, 7, (TAny*)iTest->iScreenNumber)); + iTest->CloseAllPanicWindows(); + } + +void CTCursorTest::TextCursorSetLCoverageTests() + { + ValidateWin(BaseWin,TRgb::Gray256(255)); + ValidateWin(TestWin,TRgb::Gray256(255)); + TTextCursor textCursor; + textCursor.iHeight = 10; + textCursor.iAscent = 0; + textCursor.iWidth = 10; + textCursor.iFlags = 0; + textCursor.iColor = KRgbBlack; + textCursor.iType = (TTextCursor::EType)TTextCursor::ETypeRectangle; + TPoint position(10, 10); + TRect clipRect0(10, 10, 10, 10); + TRect clipRect1(10, 10, 5, 5); + RWindowGroup *group = TheClient->iGroup->GroupWin(); + group->SetTextCursor(*TestWin->Win(), position, textCursor); + /* + * Duplicate the previous SetTextCursor command to uncover the code which checks for any delta in SetL + * compared to the current settings. + */ + group->SetTextCursor(*TestWin->Win(), position, textCursor); + /* + * Change the type only to pick up that difference in SetL. + */ + textCursor.iType++; + group->SetTextCursor(*TestWin->Win(), position, textCursor); + textCursor.iType--; + /* + * Vary the clipping rectangle. + */ + group->SetTextCursor(*TestWin->Win(), position, textCursor, clipRect0); + group->SetTextCursor(*TestWin->Win(), position, textCursor, clipRect1); + /* + * Vary the color. + */ + textCursor.iColor = KRgbGreen; + group->SetTextCursor(*TestWin->Win(), position, textCursor); + textCursor.iColor = KRgbBlack; + group->SetTextCursor(*TestWin->Win(), position, textCursor); + /* + * Vary the target Window. + */ + group->SetTextCursor(*BaseWin->Win(), position, textCursor); + group->SetTextCursor(*TestWin->Win(), position, textCursor); + /* + * Vary the size of the cursor. + */ + textCursor.iWidth++; + group->SetTextCursor(*TestWin->Win(), position, textCursor); + textCursor.iWidth--; + /* + * Set different custom cursors. + */ + CCustomTextCursorsWrapper* customTextCursorsWrapper = CCustomTextCursorsWrapper::NewLC(iTest->iScreenNumber, iTest); + const TInt count = customTextCursorsWrapper->CustomTextCursorsArray().Count(); + for (TInt index=0; indexCustomTextCursor(index); + textCursor.iType = customTextCursor.iIdentifier; + group->SetTextCursor(*TestWin->Win(), position, textCursor); + } + CleanupStack::PopAndDestroy(customTextCursorsWrapper); + /* + * Set the last custom cursor from the above loop again so the + * product code sees the same Custom Text Cursor settings come + * in a second time. + */ + group->SetTextCursor(*TestWin->Win(), position, textCursor); + textCursor.iType = (TTextCursor::EType)TTextCursor::ETypeRectangle; + /* + * Vary the horizontal clipping. + */ + textCursor.iFlags = TTextCursor::EFlagClipHorizontal; + group->SetTextCursor(*TestWin->Win(), position, textCursor); + /* + * Vary the horizontal clipping. + */ + textCursor.iFlags = TTextCursor::EFlagClipVertical; + group->SetTextCursor(*TestWin->Win(), position, textCursor); + /* + * Try both horizontal and vertical clipping. + */ + textCursor.iFlags = TTextCursor::EFlagClipVertical|TTextCursor::EFlagClipHorizontal; + group->SetTextCursor(*TestWin->Win(), position, textCursor); + textCursor.iFlags = 0; + + TheClient->iWs.Flush(); + CancelTextCursor(); + } + +void CTCursorTest::SetCursor(const TPoint &aPos,const TSize &aSize,TRgb aColor, const TRect &aRect, TUint aFlags) + { + TTextCursor tc; + tc.iType=iCursorType; + tc.iHeight=aSize.iHeight; + tc.iAscent=aSize.iHeight*4/5; + tc.iWidth=aSize.iWidth; + tc.iFlags=aFlags; + tc.iColor=aColor; + TheClient->iGroup->GroupWin()->SetTextCursor(*TestWin->Win(),TPoint(aPos.iX,aPos.iY+tc.iAscent),tc,aRect); + } + +void CTCursorTest::SetCursor(const TPoint &aPos,const TSize &aSize,TRgb aColor, TUint aFlags) + { + TTextCursor tc; + tc.iType=iCursorType; + tc.iHeight=aSize.iHeight; + tc.iAscent=aSize.iHeight*4/5; + tc.iWidth=aSize.iWidth; + tc.iFlags=aFlags; + tc.iColor=aColor; + TheClient->iGroup->GroupWin()->SetTextCursor(*TestWin->Win(),TPoint(aPos.iX,aPos.iY+tc.iAscent),tc); + } + +void CTCursorTest::SetCursorPlusBox(const TPoint &aPos,const TSize &aSize,TRgb aColor, const TRect *aClipRect, TUint aFlags) + { + if (aClipRect) + SetCursor(aPos,aSize,aColor,*aClipRect,aFlags); + else + SetCursor(aPos,aSize,aColor,aFlags); + TRect rect(aPos,aSize); + if (aClipRect) + rect.Intersection(*aClipRect); + rect.Grow(2,2); + + TheClient->iGc->Activate(*(TestWin->Win())); + TestWin->Invalidate(rect); + TestWin->Win()->BeginRedraw(rect); + TheClient->iGc->SetPenColor(aColor); + TheClient->iGc->SetDrawMode(CGraphicsContext::EDrawModeXOR); + + TheClient->iGc->DrawRect(rect); + TheClient->iGc->Deactivate(); + TestWin->Win()->EndRedraw(); + + } + +void CTCursorTest::CancelTextCursor() + { + TheClient->iGroup->GroupWin()->CancelTextCursor(); + } + +void CTCursorTest::ConstructL() + { + // for allocating some cached memory + CFbsBitmap* bitmap = new (ELeave) CFbsBitmap; + CleanupStack::PushL(bitmap); + User::LeaveIfError(bitmap->Load(TEST_BITMAP_NAME, 0)); + CleanupStack::PopAndDestroy(bitmap); + + CCustomTextCursorsWrapper* customTextCursorsWrapper = CCustomTextCursorsWrapper::NewLC(iTest->iScreenNumber, iTest); + const TInt count = customTextCursorsWrapper->CustomTextCursorsArray().Count(); + for (TInt index=0; indexCustomTextCursor(index); + TInt err = TheClient->iWs.SetCustomTextCursor(customTextCursor.iIdentifier, customTextCursor.iSpriteMemberArray.Array(), customTextCursor.iSpriteFlags, customTextCursor.iAlignment); + TEST(err == KErrNone || err == KErrAlreadyExists); + if (err!=KErrNone && err != KErrAlreadyExists) + INFO_PRINTF4(_L("TheClient->iWs.SetCustomTextCursor return value - Expected: %d or %d, Actual: %d"), KErrNone, KErrAlreadyExists, err); + + __UHEAP_MARK; + err = TheClient->iWs.SetCustomTextCursor(customTextCursor.iIdentifier, customTextCursor.iSpriteMemberArray.Array(), customTextCursor.iSpriteFlags, customTextCursor.iAlignment); + __UHEAP_MARKEND; + TEST(err == KErrAlreadyExists); + if (err != KErrAlreadyExists) + INFO_PRINTF3(_L("TheClient->iWs.SetCustomTextCursor return value - Expected: %d, Actual: %d"), KErrAlreadyExists, err); + + } + _LIT(KLog,"Text Cursor: Loaded %d Custom Cursors"); + TLogMessageText buf; + buf.Format(KLog,count); + TheClient->LogMessage(buf); + CleanupStack::PopAndDestroy(customTextCursorsWrapper); +// + ValidateWin(BaseWin,TRgb::Gray256(204)); + ValidateWin(TestWin,TRgb::Gray256(204)); +// + SetCursor(TPoint(10,90),TSize(80,100),TRgb(255,255,255)); +// + iWinState=0; + iWinPos=TPoint(2*TheClient->iGroup->Size().iWidth/3,0); +// + iMoveWin=new(ELeave) CBlankWindow(TRgb::Gray256(220)); + TDisplayMode mode=EGray16; + TInt testWinWidth = TestWin->Size().iWidth; + TInt halfTestWinWidth = testWinWidth/2; + TInt halfTestWinHeight = TestWin->Size().iHeight/2; + + iMoveWin->SetUpL(iWinPos,TSize(halfTestWinHeight,halfTestWinHeight), + TheClient->iGroup,*TheClient->iGc,&mode); + + iCheckWin=new(ELeave) CBlankWindow(TRgb::Gray256(220)); + iCheckWin->SetUpL(TPoint(testWinWidth+halfTestWinWidth,halfTestWinHeight), + TSize(halfTestWinWidth,halfTestWinHeight), + TheClient->iGroup,*TheClient->iGc,&mode); + } + +void CTCursorTest::DeleteMoveWindows() + { + delete iMoveWin; + delete iCheckWin; + CancelTextCursor(); + } + +void CTCursorTest::ResetMoveWindowsL() + { + SetCursor(TPoint(10,90),TSize(80,100),TRgb(255,255,255)); + iWinState=0; + iWinPos=TPoint(2*TheClient->iGroup->Size().iWidth/3,0); + iMoveWin->SetExtL(iWinPos,TSize(TestWin->Size().iWidth/2,TestWin->Size().iHeight/2)); + iCheckWin->SetExtL(TPoint(TestWin->Size().iWidth+(TestWin->Size().iWidth>>1),TestWin->Size().iHeight>>1), + TSize(TestWin->Size().iWidth/2,TestWin->Size().iHeight/2)); + } + +TBool CTCursorTest::MoveWindow() + { + TSize scrSize(TheClient->iScreen->SizeInPixels()); + iWinState++; + if (iWinState<20) + iWinPos+=TPoint((4*scrSize.iWidth)/640,(4*scrSize.iHeight)/240); + else if (iWinState<40) + iWinPos+=TPoint((1*scrSize.iWidth)/640,(-3*scrSize.iHeight)/240); + else if (iWinState<60) + iWinPos+=TPoint((-6*scrSize.iWidth)/640,(3*scrSize.iHeight)/240); + else + iWinPos+=TPoint((1*scrSize.iWidth)/640,(-2*scrSize.iHeight)/240); + iMoveWin->SetPos(iWinPos); + return (iWinState==80); + } + +void CTCursorTest::ValidateWin(TestWindow *aWin, TRgb aColor) + { + aWin->Win()->Invalidate(); + RedrawWin(*aWin->Win(),aColor); + } + +void CTCursorTest::RedrawWin(RWindow &aWin, TRgb aColor) + { + aWin.BeginRedraw(); + TheClient->iGc->Activate(aWin); + TheClient->iGc->SetBrushColor(aColor); + TheClient->iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + TheClient->iGc->SetPenStyle(CGraphicsContext::ENullPen); + TheClient->iGc->Clear(); + TheClient->iGc->Deactivate(); + aWin.EndRedraw(); + } + +void CTCursorTest::ScrollTest() + { + const TSize size(20,40); + ValidateWin(TestWin,TRgb::Gray256(255)); + + SetCursor(TPoint(10,20),size,TRgb::Gray256(255),TTextCursor::EFlagNoFlash); + TheClient->iWs.Flush(); + TheClient->WaitForRedrawsToFinish(); + TheClient->iWs.Finish(); + + for(TInt ii=0;ii<20;ii++) + { + TInt dist=(ii&3)*2; + TInt nx=ii&0x1?1:-1; + TInt ny=ii&0x2?1:-1; + TestWin->Win()->Scroll(TPoint(dist*nx,dist*ny),TRect(10,20,30,40)); + TheClient->iWs.Flush(); + } + TheClient->WaitForRedrawsToFinish(); + TheClient->iWs.Finish(); + + BaseWin->Win()->Invalidate(); + BaseWin->Win()->BeginRedraw(); + TheClient->iGc->Activate(*(BaseWin->Win())); + TheClient->iGc->Clear(); + TheClient->iGc->SetBrushColor(TRgb::Gray256(255)); + TheClient->iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + TheClient->iGc->SetPenStyle(CGraphicsContext::ENullPen); + TheClient->iGc->Clear(TRect(TPoint(10,20),size)); + TheClient->iGc->Deactivate(); + BaseWin->Win()->EndRedraw(); + + TheClient->iWs.Flush(); + TheClient->WaitForRedrawsToFinish(); + TheClient->iWs.Finish(); + + /* + * NOTE: Reason for removal of COMPARE_WINDOWS_SOFTFAIL_WINSCW + * Due to the new implementation of sprites in wserv2, the sprites no longer keep a + * backup bitmap of what the screen looks like beneath them. As it is not possible to + * move the sprites associated with the custom text cursors that were created in second + * phase construction of the CTCursorTest object, the COMPARE_WINDOWS_SOFTFAIL_WINSCW; + * macro function has been removed. Otherwise the test case is going to subject to the + * timing of the flashing sprite. An alternative solution would be to assign NULL values + * to the sprite bitmaps in second phase construction, but this is avoided as it would + * trigger failures in some test cases later on (that are depended on these "embedded" + * sprite images). + */ + CancelTextCursor(); + } + +void DrawTestSprite(CBitmapContext *aGc,TInt , const TSize &aSize, TBool aDoMask, TAny *) + { + aGc->SetBrushColor(TRgb::Gray4(aDoMask ? 0 : 2)); + aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + aGc->SetPenStyle(CGraphicsContext::ENullPen); + aGc->DrawRect(TRect(aSize)); + aGc->SetPenStyle(CGraphicsContext::ESolidPen); + aGc->SetPenColor(TRgb::Gray4(aDoMask ? 3 : 0)); + aGc->SetBrushColor(TRgb::Gray4(aDoMask ? 3 : 1)); + aGc->DrawEllipse(TRect(aSize)); + } + +CTSprite *CTCursorTest::CreateTestSpriteLC(RWindowTreeNode &aWindow, const TPoint &aPos, TInt aCount) +// +// At the moment aCount must be 1 or 2 +// + { + TSpriteCreateParams params(TSize(30,70),TPoint(0,0),DrawTestSprite); + TSpriteCreateParams paramarray[2]; + params.iInterval=TTimeIntervalMicroSeconds32(200000); + + paramarray[0]=params; + paramarray[1]=params; + paramarray[1].iSize=TSize(100,10); + CTSprite *sprite=new(ELeave) CTSprite(TheClient->iWs); + CleanupStack::PushL(sprite); + sprite->ConstructL(aWindow,aPos,aCount,¶marray[0],0); + return(sprite); + } + +void CTCursorTest::doMoveWindowTestL() + { + RBlankWindow blankwin(TheClient->iWs); + User::LeaveIfError(blankwin.Construct(*TestWin->Win(),1)); + CleanupStack::PushL(TCleanupItem(CleanUpWindow,&blankwin)); +// + blankwin.SetExtent(TPoint(35,165),TSize(40,40)); + blankwin.SetColor(TRgb::Gray256(220)); + blankwin.Activate(); + TheClient->iWs.SetAutoFlush(ETrue); + User::After(500000); + blankwin.SetPosition(TPoint(25,55)); + User::After(500000); + blankwin.SetPosition(TPoint(30,160)); + User::After(500000); + blankwin.SetPosition(TPoint(12,22)); // Almost totally covering sprite + User::After(500000); + blankwin.SetPosition(TPoint(-100,-100)); // Totally off the sprite + User::After(500000); + blankwin.SetPosition(TPoint(10,20)); // Write on top of sprite + User::After(500000); + blankwin.SetPosition(TPoint(24,24)); // moving off... + User::After(500000); + blankwin.SetPosition(TPoint(38,28)); // ... + User::After(500000); + blankwin.SetPosition(TPoint(58,48)); // ... + User::After(500000); + blankwin.SetPosition(TPoint(92,62)); // ... off + User::After(500000); + CleanupStack::PopAndDestroy(); // blank window + TheClient->iWs.Flush(); + TheClient->WaitForRedrawsToFinish(); + TheClient->iWs.Finish(); + + TheClient->iWs.SetAutoFlush(EFalse); + } + +void CTCursorTest::MoveWindowTest1L() + { + ValidateWin(TestWin,TRgb::Gray256(255)); +// Check it with a static sprite + CTSprite * sprite_static = CreateTestSpriteLC(*TestWin->Win(), TPoint(10,20), 1); + doMoveWindowTestL(); + (sprite_static->Sprite()).SetPosition(TPoint(500,500)); //move the sprite out of the viewing area before the window comparison + CleanupStack::PopAndDestroy(1); // sprite +// Check it an animated sprite + CTSprite * sprite_anim = CreateTestSpriteLC(*TestWin->Win(), TPoint(10,20), 2); + doMoveWindowTestL(); + (sprite_anim->Sprite()).SetPosition(TPoint(500,500)); //move the sprite out of the viewing area before the window comparison + CleanupStack::PopAndDestroy(1); // sprite + } + +void CTCursorTest::MoveWindowTest2L() + { + const TSize size(20,40); +// Check it with a text cursor + ValidateWin(TestWin,TRgb::Gray256(255)); + SetCursor(TPoint(10,25),size,TRgb::Gray256(255),TTextCursor::EFlagNoFlash); + doMoveWindowTestL(); + CancelTextCursor(); +// Check it with an anaimated sprite and a text cursor + ValidateWin(TestWin,TRgb::Gray256(255)); + CTSprite * sprite_anim = CreateTestSpriteLC(*TestWin->Win(), TPoint(10,20), 2); + SetCursor(TPoint(10,45),size,TRgb::Gray256(255),TTextCursor::EFlagNoFlash); + doMoveWindowTestL(); + (sprite_anim->Sprite()).SetPosition(TPoint(500,500)); + CancelTextCursor(); + CleanupStack::PopAndDestroy(1); // sprite + } + +TBool CTCursorTest::IncrementCursorType() + { + // each screen has it own set of cursor + // + // the values would be ETypeLast=2 ETypeLastBasic=1009 + // + if (iCursorType == TTextCursor::ETypeFirst) + { + iCursorType = (TTextCursor::EType)(TTextCursor::ETypeLastBasic + 1 + iTest->iScreenNumber*KNumberOfCustoTextCursors); + return ETrue; + } + else if (iCursorType >= TTextCursor::ETypeLastBasic + (iTest->iScreenNumber+1)*KNumberOfCustoTextCursors) + { + iCursorType = TTextCursor::ETypeFirst; + return EFalse; + } + else + { + iCursorType = (TTextCursor::EType)(iCursorType + 1); + return ETrue; + } + } + +void CTCursorTest::GeneralTestsL() + { + const TInt winColor=255; //Best to use Light Grey that is 170, but this code is bugged and doing so shows them up. + ValidateWin(BaseWin,TRgb::Gray256(255)); + ValidateWin(TestWin,TRgb::Gray256(255)); + SetCursor(TPoint(-1000,10),TSize(10,30),TRgb::Gray256(255)); + TheClient->iWs.Flush(); + SetCursor(TPoint(10,10),TSize(10,30),TRgb::Gray256(255)); + TheClient->iWs.Flush(); + TRect rect(15,15,18,25); + SetCursorPlusBox(TPoint(10,10),TSize(10,30),TRgb::Gray256(255), &rect); + CancelTextCursor(); +// + ValidateWin(BaseWin,TRgb::Gray256(255)); + ValidateWin(TestWin,TRgb::Gray256(255)); + TheClient->iWs.Flush(); + for(TInt winType=0;winType<3;winType++) + { + RWindowBase *cursorwin=NULL; + RBackedUpWindow backcursorwin(TheClient->iWs); + RWindow backwindow(TheClient->iWs); + RBlankWindow backblankwin(TheClient->iWs); + switch(winType) + { + case 0: + cursorwin=&backcursorwin; + User::LeaveIfError(backcursorwin.Construct(*TestWin->BaseWin(),EGray4,1)); + break; + case 1: + cursorwin=&backwindow; + User::LeaveIfError(backwindow.Construct(*TestWin->BaseWin(),1)); + break; + case 2: + cursorwin=&backblankwin; + User::LeaveIfError(backblankwin.Construct(*TestWin->BaseWin(),1)); + break; + } + CleanupStack::PushL(TCleanupItem(CleanUpWindow,cursorwin)); + User::LeaveIfError(cursorwin->SetSizeErr(TestWin->BaseWin()->Size())); + cursorwin->Activate(); +// + TTextCursor tc; + tc.iType=iCursorType; + tc.iHeight=30; + tc.iAscent=0; + tc.iWidth=50; + tc.iFlags=0; + tc.iColor=TRgb::Gray256(255); + TheClient->iGroup->GroupWin()->SetTextCursor(*cursorwin,TPoint(10,10),tc); +// + CreateTestSpriteLC(*cursorwin, TPoint(10,20), 2); +// + if (cursorwin==&backwindow) + RedrawWin(backwindow,TRgb::Gray256(255)); + for(TInt count=0;count<9;count++) + { + RWindowBase *pwin=NULL; + RBackedUpWindow backedup(TheClient->iWs); + RWindow window(TheClient->iWs); + RBlankWindow blankwin(TheClient->iWs); + switch(count%3) + { + case 0: + pwin=&window; + window.Construct(*cursorwin,2); + window.SetBackgroundColor(TRgb(winColor,winColor,winColor)); + break; + case 1: + pwin=&backedup; + backedup.Construct(*cursorwin,EGray4,2); + break; + case 2: + pwin=&blankwin; + blankwin.Construct(*cursorwin,2); + blankwin.SetColor(TRgb(winColor,winColor,winColor)); + break; + } + CleanupStack::PushL(TCleanupItem(CleanUpWindow,pwin)); + pwin->SetExtentErr(TPoint(30,30),TSize(50,80)); + pwin->Activate(); + TheClient->iWs.Flush(); + CleanupStack::PopAndDestroy(); // window + if (cursorwin==&backwindow) + RedrawWin(backwindow,TRgb::Gray256(255)); + TheClient->iWs.Flush(); + TheClient->WaitForRedrawsToFinish(); + COMPARE_WINDOWS_SOFTFAIL_WINSCW; + User::After(200000); // Wait a fifth of a second to make sure the test is run during different states of flashing + } + for(TInt count2=0;count2<4;count2++) + { + cursorwin->SetPosition(TPoint(10,5)); + TheClient->iWs.Flush(); + User::After(100000); + cursorwin->SetPosition(TPoint(5,10)); + TheClient->iWs.Flush(); + User::After(100000); + cursorwin->SetPosition(TPoint(0,0)); + TheClient->iWs.Flush(); + User::After(100000); + TheClient->WaitForRedrawsToFinish(); + COMPARE_WINDOWS_SOFTFAIL_WINSCW; + } + CleanupStack::PopAndDestroy(2); // sprite & window containing sprite and cursor + } + CancelTextCursor(); + } + +void CTCursorTest::INC040489L() + { + INFO_PRINTF1(_L("AUTO_TCur INC040489 ")); + RWindowGroup group1(TheClient->iWs); + PushWindowL(&group1); + User::LeaveIfError(group1.Construct(ENullWsHandle)); + RBlankWindow blank1(TheClient->iWs); + PushWindowL(&blank1); + User::LeaveIfError(blank1.Construct(group1,ENullWsHandle)); + blank1.SetRequiredDisplayMode(EColor4K); + blank1.SetColor(TRgb(250,150,0)); + blank1.Activate(); + RWindowGroup group2(TheClient->iWs); + PushWindowL(&group2); + User::LeaveIfError(group2.Construct(ENullWsHandle)); + RBlankWindow blank2(TheClient->iWs); + PushWindowL(&blank2); + User::LeaveIfError(blank2.Construct(group2,ENullWsHandle)); + blank2.SetRequiredDisplayMode(EColor4K); + blank2.SetColor(TRgb(75,200,125)); + blank2.Activate(); + TheClient->Flush(); + INFO_PRINTF1(_L(" Created Windows ")); + TTextCursor tc; + tc.iType=KTextCursorInitialIdValue + iTest->iScreenNumber*KNumberOfCustoTextCursors; + tc.iHeight=80; + tc.iAscent=10; + tc.iWidth=30; + tc.iFlags=0; + tc.iColor=TRgb::Gray256(255); + INFO_PRINTF1(_L(" About to Set Text Cursor 1 ")); + group2.SetTextCursor(blank2,TPoint(20,20),tc); + TheClient->Flush(); + INFO_PRINTF1(_L(" Set Text Cursor 1 ")); + User::After(2000000); //2sec + TheClient->iWs.PrepareForSwitchOff(); + TheClient->Flush(); + User::After(2000000); //2sec + group1.SetOrdinalPosition(0); + group2.CancelTextCursor(); + TheClient->Flush(); + INFO_PRINTF1(_L(" Canceled Text Cursor ")); + User::After(2000000); //2sec + // + // Before applying the fix, the following operations makes the Custom Text + // Cursor Sprite invisible (happens even without wserv heartbeat suppression) + INFO_PRINTF1(_L(" About to Set Text Cursor 2 ")); + group1.SetOrdinalPosition(2); + group2.SetTextCursor(blank2,TPoint(20,20),tc); + TheClient->Flush(); + INFO_PRINTF1(_L(" Set Text Cursor 2 ")); + User::After(2000000); //2sec + TRawEvent event; + event.Set(TRawEvent::EActive); + TheClient->iWs.SimulateRawEvent(event); + TheClient->Flush(); + INFO_PRINTF1(_L(" Simulated Active Event ")); + User::After(2000000); //2sec + CleanupStack::PopAndDestroy(4, &group1); + INFO_PRINTF1(_L(" End of test ")); + } + +void CTCursorTest::CursorUpdatedBeforeWindowRenderedL() + { + INFO_PRINTF1(_L("CursorUpdatedBeforeWindowRenderedL")); + TheClient->iGroup->WinTreeNode()->SetOrdinalPosition(0); + // We use some unique looking colors otherwise its harder + // to spot which test is which + TRgb kAqua(134, 242, 251); + + iWorkInProgress = new(ELeave) CBlankWindow(kAqua); + iComparisonWindow = new(ELeave) CBlankWindow(kAqua); + CancelTextCursor(); + + const TSize screenSize=TheClient->iGroup->Size(); + const TInt kPad = 5; + const TInt kThirdOfScreenWidth = screenSize.iWidth/3; + const TInt kWinWidth = kThirdOfScreenWidth - 2*kPad; + const TInt kWinHeight = screenSize.iHeight - 2*kPad; + const TSize kWinSize(kWinWidth, kWinHeight); + const TPoint kCursorPos(30, 30); + iComparisonWindow->SetUpL(TPoint(2*kThirdOfScreenWidth + kPad, kPad), kWinSize, TheClient->iGroup, *TheClient->iGc); + iWorkInProgress->SetUpL( TPoint( kThirdOfScreenWidth + kPad, kPad), kWinSize, TheClient->iGroup, *TheClient->iGc); + + TTextCursor nonFlashingCursor; + nonFlashingCursor.iType = TTextCursor::ETypeRectangle; + nonFlashingCursor.iHeight=kCursorHeight; + nonFlashingCursor.iAscent=0; + nonFlashingCursor.iWidth=kCursorWidth; + nonFlashingCursor.iFlags=TTextCursor::EFlagNoFlash; + nonFlashingCursor.iColor = KRgbBlack; + TheClient->iGroup->GroupWin()->SetTextCursor(*iWorkInProgress->BaseWin(), kCursorPos, nonFlashingCursor); + + // Up till this point, there has not been a CWsWindow::Render() for iWorkInProgress + // because the window has not been invalid + + /* + * Here is the crux of the test. We want to create the following condition in a window group: + * 1) None of its windows have yet been Rendered using CWsWindow::Render() + * 2) A text cursor is present + * 3) Focus is lost then received + * + * It used to be the case that Wserv picked up the handle to the Render Stage Text Cursor + * drawer upon a Refresh caused by Rendering the window. But drawing the Text Cursor could + * come either from a Window Render or a change to the state of the Text Cursor, such as + * receiving focus in the window. A bug was experienced when the Text Cursor was drawn in + * a window which never had been rendered. This meant that the handle was not set up causing + * an assert. + * + * The code has been modified since then, to setup the handle to the Render Stage Text + * Cursor during Wserv initialisation. However, to guard against future changes, its + * worthwhile to have this corner case test to ensure it is possible to receive focus + * in a window which has never been rendered. That is because the text cursor state + * is updated in such circumstances, and that might trigger a draw of the cursor in a + * future version of the text cursor code. + */ + TheClient->iGroup->WinTreeNode()->SetOrdinalPosition(1); // lose focus + TheClient->iWs.Finish(); + TheClient->iGroup->WinTreeNode()->SetOrdinalPosition(0); // gain focus + TheClient->iWs.Finish(); + + // If we get this far without a panic or assert, we have passed this test. + + // Now allow CWsWindow::Render() to occur in iWorkInProgress + // The reason for doing this is so that when you watch the test + // progress you can see visual confirmation via the progress message and + // the coloured windows appear on the screen. Otherwise you would think + // that the test had either been skipped or had broken. + iWorkInProgress->Invalidate(); + iWorkInProgress->Redraw(); + iComparisonWindow->Invalidate(); + iComparisonWindow->Redraw(); + TheClient->iWs.Finish(); + delete iWorkInProgress; + iWorkInProgress = NULL; + delete iComparisonWindow; + iComparisonWindow = NULL; + INFO_PRINTF1(_L("End of test")); + } + +void CTCursorTest::INC097774() + { + TTimeIntervalMicroSeconds32 initialRepeatRate; + TTimeIntervalMicroSeconds32 repeatRate; + TheClient->iWs.GetKeyboardRepeatRate(initialRepeatRate,repeatRate); + + //simulates a text cursor moving across the screen as if a user was holding down + //a key to scroll the cursor through a section of text. + //before applying the fix the cursor only shows up intermittently instead of smoothly + //scrolling across the screen. + const TSize cursorSize(3,20); + const TInt moveInterval=10; + SetCursor(TPoint(0,20),cursorSize,TRgb::Gray256(255),TTextCursor::EFlagNoFlash); + TheClient->Flush(); + User::After(initialRepeatRate); + for(TInt offset=10;offset<=100;offset+=moveInterval) + { + SetCursor(TPoint(offset,20),cursorSize,TRgb::Gray256(255),TTextCursor::EFlagNoFlash); + TheClient->Flush(); + User::After(repeatRate); + } + + //simulate clipped text cursor moving accross the screen + TRect rect(0,20,3,40); + SetCursor(TPoint(0,20),cursorSize,TRgb::Gray256(255),rect,TTextCursor::EFlagNoFlash); + TheClient->Flush(); + User::After(initialRepeatRate); + for(TInt offset=10;offset<=100;offset+=moveInterval) + { + rect.Move(moveInterval,0); + SetCursor(TPoint(offset,20),cursorSize,TRgb::Gray256(255),rect,TTextCursor::EFlagNoFlash); + TheClient->Flush(); + User::After(repeatRate); + } + } +/** What happens when a cursor becomes off-screen when the screen is resized/rotated? + * + * + **/ +void CTCursorTest::INC117232() + { + const TInt initialRepeatRate=300000; // 3/10 seconds should be long enough to update everything! + TInt currMode=TheClient->iScreen->CurrentScreenMode(); + TInt testMode=currMode; + TPixelsTwipsAndRotation currModeSize; + TheClient->iScreen->GetScreenModeSizeAndRotation(currMode, currModeSize); + //find a (rotated) mode where the dimensions of the screen shrank + for (TInt mode=0;modeiScreenModes.Count();mode++) + { + TPixelsTwipsAndRotation testModeSize; + TheClient->iScreen->GetScreenModeSizeAndRotation(mode,testModeSize); + if ( testModeSize.iPixelSize.iWidthSetTestStepResult(EInconclusive); //With this line the whole test fails which is too drastic + return; + } + //enable a cursor on the bottom right corner of the screen + TestWin->SetFullScreenExtL(); + TheClient->Flush(); + iCursorType=TTextCursor::ETypeRectangle; + SetCursor(TPoint(-20,-20)+TestWin->Size(),TSize(40,40),KRgbDarkMagenta,TTextCursor::EFlagNoFlash); + TheClient->Flush(); + User::After(initialRepeatRate); + //shrink the screen + TheClient->iScreen->SetScreenMode(testMode); + TheClient->iScreen->SetAppScreenMode(testMode); + //The defect was that WServ would now crash! + TheClient->Flush(); + User::After(initialRepeatRate); + //Set everything back + TheClient->iScreen->SetScreenMode(currMode); + TheClient->iScreen->SetAppScreenMode(currMode); + TheClient->Flush(); + User::After(initialRepeatRate); + } + +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA +/** + * Sets up a text cursor whose attributes indicate it should not be flashing + * and then checks to ensure this is the actual behaviour. + */ +void CTCursorTest::TextCursorNoFlashTestL() + { + TheClient->iGroup->WinTreeNode()->SetOrdinalPosition(0); + // We use some unique looking colors otherwise its harder + // to spot which test is which + TRgb kGentleYellow(251, 249, 198); + TRgb kGentlePink(253, 196, 221); + + iWorkInProgress = new(ELeave) CBlankWindow(kGentleYellow); + iComparisonWindow = new(ELeave) CBlankWindow(kGentleYellow); + CancelTextCursor(); + TheClient->Flush(); + + const TSize screenSize=TheClient->iGroup->Size(); + const TInt kPad = 5; + const TInt kThirdOfScreenWidth = screenSize.iWidth/3; + const TInt kWinWidth = kThirdOfScreenWidth - 2*kPad; + const TInt kWinHeight = screenSize.iHeight - 2*kPad; + const TSize kWinSize(kWinWidth, kWinHeight); + const TPoint kCursorPos(30, 30); + iWorkInProgress->SetUpL( TPoint( kThirdOfScreenWidth + kPad, kPad), kWinSize, TheClient->iGroup, *TheClient->iGc); + iComparisonWindow->SetUpL(TPoint(2*kThirdOfScreenWidth + kPad, kPad), kWinSize, TheClient->iGroup, *TheClient->iGc); + + TTextCursor nonFlashingCursor; + + nonFlashingCursor.iType = TTextCursor::ETypeRectangle; + nonFlashingCursor.iHeight=kCursorHeight; + nonFlashingCursor.iAscent=0; + nonFlashingCursor.iWidth=kCursorWidth; + nonFlashingCursor.iFlags=TTextCursor::EFlagNoFlash; + nonFlashingCursor.iColor = kGentlePink; // We expect a Flicker Buffer Render Stage to ignore this color + + iWorkInProgress->Invalidate(); + iWorkInProgress->Redraw(); + iComparisonWindow->Invalidate(); + iComparisonWindow->Redraw(); + + DrawTextCursorSimilarToRenderStage(*TheClient->iGc, *iComparisonWindow->Win(), kCursorPos, nonFlashingCursor); + TheClient->iGroup->GroupWin()->SetTextCursor(*iWorkInProgress->BaseWin(), kCursorPos, nonFlashingCursor); + TheClient->Flush(); + + CheckCursorDoesNotFlash(iWorkInProgress->BaseWin()->Size()); + + delete iWorkInProgress; + iWorkInProgress = NULL; + delete iComparisonWindow; + iComparisonWindow = NULL; + } + +void CTCursorTest::TextCursorFlashTestL() + { + TheClient->iGroup->WinTreeNode()->SetOrdinalPosition(0); + // We use some unique looking colors otherwise its harder + // to spot which test is which + TRgb kMildPurple(218, 155, 244); + TRgb kPaleGreen(146, 190, 12); + + iWorkInProgress = new(ELeave) CBlankWindow(kMildPurple); + iComparisonWindow = new(ELeave) CBlankWindow(kMildPurple); + CancelTextCursor(); + TheClient->Flush(); + + const TSize screenSize=TheClient->iGroup->Size(); + const TInt kPad = 5; + const TInt kThirdOfScreenWidth = screenSize.iWidth/3; + const TInt kWinWidth = kThirdOfScreenWidth - 2*kPad; + const TInt kWinHeight = screenSize.iHeight - 2*kPad; + const TSize kWinSize(kWinWidth, kWinHeight); + const TPoint kCursorPos(30, 30); + iWorkInProgress->SetUpL( TPoint( kThirdOfScreenWidth + kPad, kPad), kWinSize, TheClient->iGroup, *TheClient->iGc); + iComparisonWindow->SetUpL(TPoint(2*kThirdOfScreenWidth + kPad, kPad), kWinSize, TheClient->iGroup, *TheClient->iGc); + + TTextCursor flashingCursor; + + flashingCursor.iType = TTextCursor::ETypeRectangle; + flashingCursor.iHeight=kCursorHeight; + flashingCursor.iAscent=0; + flashingCursor.iWidth=kCursorWidth; + flashingCursor.iFlags=0; // implies that cursor SHOULD flash + flashingCursor.iColor = kPaleGreen; // We expect a Flicker Buffer Render Stage to ignore this color + + iWorkInProgress->Invalidate(); + iWorkInProgress->Redraw(); + iComparisonWindow->Invalidate(); + iComparisonWindow->Redraw(); + + DrawTextCursorSimilarToRenderStage(*TheClient->iGc, *iComparisonWindow->Win(), kCursorPos, flashingCursor); + TheClient->iGroup->GroupWin()->SetTextCursor(*iWorkInProgress->BaseWin(), kCursorPos, flashingCursor); + TheClient->Flush(); + + CheckCursorDoesFlash(kCursorPos, flashingCursor, kMildPurple); + CancelTextCursor(); + TheClient->Flush(); + + delete iWorkInProgress; + iWorkInProgress = NULL; + delete iComparisonWindow; + iComparisonWindow = NULL; + } + +void CTCursorTest::DrawTextCursorSimilarToRenderStage(CWindowGc& aGc, RWindow& aWin, const TPoint& aPos, const TTextCursor& aTextCursor) + { + // This method duplicates the way in which the default FlickerBuffer Render + // Stage draws a Text Cursor of ETypeRectangle. @see CFbRenderStage::DrawTextCursor + // This code must be kept in sync with the FlickerBuffer Render Stage + + ASSERT(aTextCursor.iType == TTextCursor::ETypeRectangle); + const TRect updatedRegion(aPos,TSize(aTextCursor.iWidth,aTextCursor.iHeight)); + aWin.Invalidate(); + aWin.BeginRedraw(); + aGc.Activate(aWin); + aGc.Clear(); + aGc.SetBrushStyle(CGraphicsContext::ESolidBrush); + aGc.SetBrushColor(KRgbBlack); + aGc.SetPenStyle(CGraphicsContext::ENullPen); + aGc.Clear(updatedRegion); + aGc.Deactivate(); + aWin.EndRedraw(); + } + +void CTCursorTest::CheckCursorDoesNotFlash(const TSize& aSize) + { + const TInt kSampleTime = 100000; // one tenth of a second + const TInt kSampleLimit = 100; + TInt sampleIteration = 0; + TBool comparisonOkay = EFalse; + + while (sampleIteration < kSampleLimit) + { + comparisonOkay = DoCheckRect(iWorkInProgress, iComparisonWindow, TRect(TPoint(), aSize), CWsScreenDevice::EIncludeTextCursor); + if (!comparisonOkay) + { + INFO_PRINTF2(_L("CheckCursorDoesNotFlash difference found after %d milliseconds"), sampleIteration*100); + break; + } + sampleIteration++; + User::After(kSampleTime); + } + TEST(comparisonOkay); + } + +void CTCursorTest::UpdateCountersOnCursorTransition( + const TBool aTransitionedToOn, + TTime& aNow, + TInt64& aDeltaTime, + TTime& aLastDeltaTime, + TInt& aWarmUpIterations, + const TInt& aFlashChangeTime, + const TInt& aToleranceMargin, + TInt& aSampleNumber, + TInt& aToleranceViolations + ) + { + _LIT(KTxtOn, " On"); + _LIT(KTxtOff, "Off"); + TBufC<3> transitionType; + transitionType = aTransitionedToOn ? KTxtOn : KTxtOff; + + aNow.UniversalTime(); + aDeltaTime = aNow.MicroSecondsFrom(aLastDeltaTime).Int64(); + aLastDeltaTime = aNow; + + if (aWarmUpIterations > 0) + { + aWarmUpIterations--; + } + else + { + if (aDeltaTime > aFlashChangeTime + aToleranceMargin || + aDeltaTime < aFlashChangeTime - aToleranceMargin) + { + INFO_PRINTF5(_L(" Iteration %d, Cursor %S after %d, errorDelta %d microseconds"), + aSampleNumber, &transitionType, I64INT(aDeltaTime), I64INT(aDeltaTime - aFlashChangeTime)); + aToleranceViolations++; + } + } + } +void CTCursorTest::CheckCursorDoesFlash(const TPoint& aPos, const TTextCursor& aTextCursor, TRgb /* aBackgroundColor */) + { + + /** + * Quality of Service based thresholding + * + * The idea behind this test is to identify tolerances which would either + * cause the test to fail when the user would perceive the text cursor as + * not flashing uniformly, or would point to an unexpected delay outside + * the way the flashing (and scheduling of animations) is supposed to work. + * + * Potentially the cursor can be late if we miss a V-SYNC from hardware. In + * such cases we expect to see the cursor on the next frame. Since the V-SYNC + * is typically 1/50 second, a tolerance of two frames, or 1/25 second is reasonable. + * + * If the cursor is delayed longer than this, say a long time of 1 second, but this + * does not happen too often, then the user is likely to still be happy. So we + * set the period of testing to 60 seconds, and set the violations limit to 2. + */ + const TInt kOneSecond = 1000000; + const TInt kFlashPeriod = kOneSecond; // comprises one "ON" and one "OFF" + const TInt kToleranceFactor = 25; // meaning 1/25 of a Flash Period + const TInt kNumberTestFlashPeriods = 60; // meaning 60 Flash Periods worth of testing + const TInt kMaximumToleranceViolations = 2; // number of times an occassional flash may be late or early + + const TInt kToleranceMargin = kFlashPeriod / kToleranceFactor; + const TInt kNumberSamples = kNumberTestFlashPeriods * kToleranceFactor; + const TInt kFlashChangeTime = kFlashPeriod / 2; + + // The first couple of changes to the cursor should be ignored because + // when the test is started, the cursor may have been on for a while. + // Then when the cursor goes off, it appears to have switched to the + // off state too early. We therefore ignore the first two changes + // so we start cleanly. + TInt warmUpIterations = 2; + + // Empirically we see that cursors mostly flash with good timeliness apart from + // occasional events causing them to be either early or late. In order to keep + // a tight tolerance (1/50 second is around the screen refresh time) but still + // allow for the occasional variance (seen to be 1/23 second) we use a counter + // toleranceViolations < kMaximumToleranceViolations + TInt toleranceViolations = 0; + TBool cursorShownLastTime = EFalse; + TBool cursorShown = EFalse; + TTime lastDeltaTime; + TTime now; + TInt64 deltaTime = 0; + lastDeltaTime.UniversalTime(); + now.UniversalTime(); + + TRect textCursorRect(TRect(aPos, TSize(aTextCursor.iWidth, aTextCursor.iHeight))); + + for (TInt sampleNumber = 0; sampleNumber < kNumberSamples; sampleNumber++) + { + cursorShown = DoCheckRect(iWorkInProgress, iComparisonWindow, textCursorRect, CWsScreenDevice::EIncludeTextCursor); + + if (cursorShown && !cursorShownLastTime) + { + cursorShownLastTime = ETrue; + UpdateCountersOnCursorTransition( + cursorShownLastTime, now, deltaTime, lastDeltaTime, warmUpIterations, kFlashChangeTime, + kToleranceMargin, sampleNumber, toleranceViolations); + } + else if (!cursorShown && cursorShownLastTime) + { + cursorShownLastTime = EFalse; + UpdateCountersOnCursorTransition( + cursorShownLastTime, now, deltaTime, lastDeltaTime, warmUpIterations, kFlashChangeTime, + kToleranceMargin, sampleNumber, toleranceViolations); + } + + if (toleranceViolations > kMaximumToleranceViolations) + break; + + User::After(kToleranceMargin); + } + // Check was some flashing + TEST_SOFTFAIL_WINSCW(warmUpIterations == 0); + // Check cursor flashed on and off, regularly and on-time + TEST_SOFTFAIL_WINSCW(toleranceViolations <= kMaximumToleranceViolations); + } +#endif // TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA + +void CTCursorTest::MakeCursors(TTextCursor& aTextCursor, TTextCursor& aCustomCursor) + { + aCustomCursor.iType = KTextCursorInitialIdValue + iTest->iScreenNumber*KNumberOfCustoTextCursors; // custom text cursor + aCustomCursor.iAscent=0; + aCustomCursor.iHeight=kCursorHeight; + aCustomCursor.iWidth=kCursorWidth; + aCustomCursor.iFlags=TTextCursor::EFlagNoFlash; + aCustomCursor.iColor=TRgb::Color256(217); + + // Create a standard cursor for the tests + aTextCursor.iType = TTextCursor::ETypeRectangle; // Normal rectangular text cursor + aTextCursor.iHeight=kCursorHeight; + aTextCursor.iAscent=0; + aTextCursor.iWidth=kCursorWidth; + aTextCursor.iFlags=TTextCursor::EFlagNoFlash; + } + +void CTCursorTest::StartDoubleCursorTestL(TInt aTestNumber) + { + // general setup + CBlankWindow* win1=new(ELeave) CBlankWindow(KRgbWhite); + CleanupStack::PushL(win1); + + win1->SetUpL(kWin1TopLeft,kWinSize,TheClient->iGroup,*TheClient->iGc,EColor64K); + + win1->Redraw(); + + // Create the second window + CBlankWindow* win2=new(ELeave) CBlankWindow(KRgbWhite); + CleanupStack::PushL(win2); + + win2->SetUpL(kWin2TopLeft,kWinSize,TheClient->iGroup,*TheClient->iGc,EColor64K); + win2->Redraw(); + + // Create normal and custom cursor for the tests + TTextCursor textCursor; + TTextCursor customCursor; + MakeCursors(textCursor, customCursor); + + TheClient->Flush(); + CWindowGc* winGc = TheClient->iGc; + + switch(aTestNumber) + { + case 1: + CheckNoDoubleCursorTest1L(win1, win2, textCursor, customCursor, winGc); + break; + + case 2: + CheckNoDoubleCursorTest2L(win1, win2, textCursor, customCursor, winGc); + break; + + case 3: + CheckNoDoubleCursorTest3L(win1, win2, textCursor, customCursor, winGc); + break; + + default: + TEST(EFalse); + break; + } + CleanupStack::PopAndDestroy(2); + } + +// DEF098704 +void CTCursorTest::CheckNoDoubleCursorTest1L(CBlankWindow* aWin1, CBlankWindow* aWin2, TTextCursor& /*aTextCursor*/, TTextCursor& aCustomCursor, CWindowGc* aWinGc) + { + // Test that changing the focus of a custom text cursor does not leave that cursor drawn where it was (INC093898) + + TheClient->iGroup->GroupWin()->SetTextCursor(*aWin1->BaseWin(),TPoint(),aCustomCursor); + + // Bit blit the TEST_BITMAP_NAME image to the second window to use as a comparison + // this is the same image that the custom cursor is using + CFbsBitmap* bitmap = new(ELeave) CFbsBitmap; + CleanupStack::PushL(bitmap); + TEST(KErrNone == bitmap->Load(TEST_BITMAP_NAME,0,ETrue)); + + aWinGc->Activate(*aWin2->Win()); + TRect updateArea(TPoint(0,0), bitmap->SizeInPixels()); + aWin2->Win()->Invalidate(updateArea); + aWin2->Win()->BeginRedraw(updateArea); + aWinGc->BitBlt(TPoint(0,0),bitmap); + aWinGc->Deactivate(); + aWin2->Win()->EndRedraw(); + TheClient->Flush(); + doCheckNoDoubleCursor(aWin1,aWin2,kWin1TopLeft,kWin2TopLeft,aCustomCursor,bitmap->SizeInPixels(),CWsScreenDevice::EIncludeSprite); + CleanupStack::PopAndDestroy(1); // bitmap + } + +// DEF098704 +void CTCursorTest::CheckNoDoubleCursorTest2L(CBlankWindow* aWin1, CBlankWindow* aWin2, TTextCursor& /*aTextCursor*/, TTextCursor& aCustomCursor, CWindowGc* aWinGc) + { + //TEST 2: Checks that no artifacts are left behind when a text cursor is moved from under a transparent sprite + + // Construct the window win1 with a transparent sprite + + // Clear the top and bottom windows + ResetWindows(aWinGc,aWin1,aWin2); + + // Create a bitmap and a corresponding bitmap mask + CFbsBitmap* bitmap = new(ELeave) CFbsBitmap; + CleanupStack::PushL(bitmap); + TEST(KErrNone == bitmap->Load(TEST_BITMAP_NAME,0,ETrue)); + CBitmap* spriteBitmap=CBitmap::NewL(kWinSize,EColor256); + CleanupStack::PushL(spriteBitmap); + spriteBitmap->Gc().SetBrushColor(KRgbBlack); + spriteBitmap->Gc().SetBrushStyle(CGraphicsContext::ESolidBrush); + spriteBitmap->Gc().SetPenStyle(CGraphicsContext::ESolidPen); + spriteBitmap->Gc().DrawRect(TRect(kWinSize)); + CBitmap* mask=CBitmap::NewL(kWinSize,EColor256); + CleanupStack::PushL(mask); + mask->Gc().SetBrushStyle(CGraphicsContext::ESolidBrush); + mask->Gc().SetBrushColor(KRgbBlack); + mask->Gc().DrawRect(TRect(kWinSize)); + + // Create a sprite + RWsSprite sprite = RWsSprite(TheClient->iWs); + CleanupClosePushL(sprite); + TEST(KErrNone == sprite.Construct(*aWin1->BaseWin(),TPoint(),0)); + + // Add the bitmap to the sprite + TSpriteMember member; + member.iInvertMask=EFalse; + member.iDrawMode=CGraphicsContext::EDrawModePEN; + member.iOffset=TPoint(); + member.iInterval=TTimeIntervalMicroSeconds32(0); + member.iBitmap = &spriteBitmap->Bitmap(); + member.iMaskBitmap = &mask->Bitmap(); + TEST(KErrNone == sprite.AppendMember(member)); + + // Activate the sprite in win1 + TEST(KErrNone == sprite.Activate()); + + // Put a cursor in win1 + TheClient->iGroup->GroupWin()->SetTextCursor(*aWin1->BaseWin(),TPoint(),aCustomCursor); + + // Bit blit the matching bitmap to the bottom window + TRect bitmapArea(TPoint(0,0), bitmap->SizeInPixels()); + aWin2->Win()->Invalidate(bitmapArea); + aWin2->Win()->BeginRedraw(bitmapArea); + aWinGc->Activate(*aWin2->Win()); + aWinGc->BitBlt(TPoint(),bitmap); + aWinGc->Deactivate(); + aWin2->Win()->EndRedraw(); + + TheClient->Flush(); + doCheckNoDoubleCursor(aWin1,aWin2,kWin1TopLeft,kWin2TopLeft,aCustomCursor,bitmap->SizeInPixels(),CWsScreenDevice::EIncludeSprite); + CleanupStack::PopAndDestroy(4); // sprite, mask, spriteBitmap, bitmap + } + +// DEF098704 +void CTCursorTest::CheckNoDoubleCursorTest3L(CBlankWindow* aWin1, CBlankWindow* aWin2, TTextCursor& aTextCursor,TTextCursor& aCustomCursor, CWindowGc* aWinGc) + { + // + // TEST 3: Test a flashing text cursor does not leave artifacts when a redraw + change position happens during + // the time the cursor flashing 'off' + // + // This test moves a flashing cursor a number of times over a two second period to a seconds position. + // it does it a number of times so some of the redraws will occur during the 'flash off' period + // We then compare the 'after' position to what we expect + // + // There are four possible outcomes when we look at the bitmap after the redraw + move + // Position 1 is the original position, position 2 is the new position after the redraw + // + // cursor artifact @ pos1 and flashed on cursor @ pos2 + // cursor artifact at pos1 and flashed off cursor @ pos2 + // no artifact at pos1 and flashed off cursor @ pos2 + // no artifact at pos1 and flashed on cursor @ pos2 + // + // any artifacts left over will cause the complete test to fail. + // + + // + // PART A: + aTextCursor.iFlags=0; // flashing + + ResetWindows(aWinGc,aWin1,aWin2); + TestForArtifacts(aWin1, aTextCursor); + + // + // PART B - For a non-custom text cursor + aCustomCursor.iFlags=0; // flashing + + ResetWindows(aWinGc,aWin1,aWin2); + TestForArtifacts(aWin1, aCustomCursor); + } + +// moves the cursor between two positions while flashing and tests no artifacts are left at the position it moved from +// The moves take place in a loop so it is tested happening when the cursor is flashed on and also off +void CTCursorTest::TestForArtifacts(CBlankWindow* aWin1, TTextCursor& aCursor) + { + const TInt KIterations = 30; + const TPoint kStartPos(0,0); + const TPoint kMoveToPos(200,0); + TRect r1(kWin1TopLeft,kCursorSize); + TRect r2(kWin2TopLeft,kCursorSize); + const TPoint kWin1TopLeft; + const TPoint kWin2TopLeft; + const TSize aCursorSize; + + TheClient->iGroup->GroupWin()->SetTextCursor(*aWin1->BaseWin(),kStartPos,aCursor); + TheClient->Flush(); + + TInt initialRepeatRate = 1000000; + const TInt KIncrement = 30000; + TInt i=0; + + for(i=0; iiGroup->GroupWin()->SetTextCursor(*aWin1->BaseWin(),kMoveToPos,aCursor); + TheClient->Flush(); + + User::After(initialRepeatRate); + + // check no artifact was left in position 1 by comparing against (blank) win2 + if(!TheClient->iScreen->RectCompare( r1,r2, CWsScreenDevice::EIncludeTextCursor)) + { + break; // detected an artifact remaining, test failed + } + + // move the cursor back to its start position, this resets the flash timer which is why we increment initialRepeatRate + TheClient->iGroup->GroupWin()->SetTextCursor(*aWin1->BaseWin(),kStartPos,aCursor); + TheClient->Flush(); + initialRepeatRate += KIncrement; + } + + // if all went well i should equal KIterations, if it doesnt its because we detected + // an artifact and quit the test early + TEST_SOFTFAIL_WINSCW(i==KIterations); + } + + +// Tests the two windows match, moves the cursor off win 1 then tests they no longer match +void CTCursorTest::doCheckNoDoubleCursor(CBlankWindow* aWin1, + CBlankWindow* aWin2, + const TPoint& aWin1Tl, + const TPoint& aWin2Tl, + const TTextCursor& aCursor, + const TSize& aCursorSize, + CWsScreenDevice::TSpriteInCompare aFlags) + { + TRect r1(aWin1Tl,aCursorSize); + TRect r2(aWin2Tl,aCursorSize); + + TInt compareTries = 0; + const TInt compareLimit = 5; + + TBool correctComparison = EFalse; + while (!correctComparison && compareTries < compareLimit) + { + compareTries++; + User::After(500000); + correctComparison = TheClient->iScreen->RectCompare(r1,r2, aFlags); + } + + INFO_PRINTF3(_L("Result Before %d (attempts %d)"), correctComparison, compareTries); + TEST_SOFTFAIL_WINSCW(correctComparison); + + + // Change the focus off win1, by drawing the text cursor on the second window + TheClient->iGroup->GroupWin()->SetTextCursor(*aWin2->BaseWin(),aWin2Tl,aCursor); + TheClient->Flush(); + + // Cause a redraw + aWin1->CTWin::DrawNow(); + TheClient->WaitForRedrawsToFinish(); + + // make sure any cursor has actually moved + User::After(1000000); // 1 sec + + TBool resultAfter; + resultAfter = !TheClient->iScreen->RectCompare(r1,r2, aFlags); + INFO_PRINTF2(_L("Result After %d"), resultAfter); + TEST_SOFTFAIL_WINSCW(resultAfter); + } + +// resets the windows to their initial state +void CTCursorTest::ResetWindows(CWindowGc* aWinGc,CBlankWindow* aWin1,CBlankWindow* aWin2) + { + TheClient->iGroup->GroupWin()->CancelTextCursor(); + aWinGc->Activate(*aWin1->Win()); + aWinGc->Reset(); + aWinGc->Clear(); + aWinGc->Deactivate(); + + aWin1->Invalidate(); + aWin1->Redraw(); + aWin2->Invalidate(); + aWin2->Redraw(); + TheClient->Flush(); + } + +void CTCursorTest::RunTestCaseL(TInt /*aCurTestCase*/) + { + TBool deleteMove=EFalse; + ((CTCursorTestStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); + + switch(++iTest->iState) + { +/** +@SYMTestCaseID GRAPHICS-WSERV-0241 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test the text cursor functions properly as a window is moved + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Move a window about the screen and meanwhile check the text + cursor functions correctly + +@SYMTestExpectedResults The text cursor functions correctly as the window is moved +*/ + case 1: + ((CTCursorTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0241")); + while (!deleteMove) + { + if (iCursorType==TTextCursor::ETypeFirst) + iTest->LogSubTest(_L("Cursor 1")); + if (MoveWindow()) + { + if (IncrementCursorType()) + { + ResetMoveWindowsL(); + } + else + { + DeleteMoveWindows(); + deleteMove =true; + } + } + } + break; + +/** +@SYMTestCaseID GRAPHICS-WSERV-0242 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test the text cursor functions properly as the window is scrolled + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Scroll the window and meanwhile check the text cursor functions correctly + +@SYMTestExpectedResults The text cursor functions correctly as the window is scrolled +*/ + case 2: + ((CTCursorTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0242")); + iTest->LogSubTest(_L("Cursor 2")); + iCursorType=TTextCursor::ETypeRectangle; + ScrollTest(); + iCursorType=TTextCursor::ETypeFirst; + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0244 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test the text cursor functions properly as a blank window is moved + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Move a blank window about the screen and meanwhile check the text + cursor functions correctly + +@SYMTestExpectedResults The text cursor functions correctly as the blank window is moved +*/ + case 3: + ((CTCursorTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0244")); + iTest->LogSubTest(_L("Move window1")); + MoveWindowTest1L(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0245 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test that a non flashing text cursor functions properly as a + blank window is moved + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Move a blank window about the screen and meanwhile check that a non + flashing text cursor functions correctly + +@SYMTestExpectedResults The text cursor functions correctly as the blank window is moved +*/ + case 4: + ((CTCursorTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0245")); + while (IncrementCursorType()) + { + iTest->LogSubTest(_L("Move window2")); + MoveWindowTest2L(); + } + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0247 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Tests a Custom Text Cursor Sprite visibility after wserv hearbeat suppression + REQUIREMENT: INC040489. + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Create a window group with an associated window for it, then activate it. + Create another window group with an associated window along with a custom cursor, + then active it. Make a call to suppress the wserv hearbeat, which will stop + the custom cursor from flashing with flash ON state. Bring the first window + group to the foreground and cancel the custom test cursor in the second window group. + After that, put the first window group to the background and set the custom test + cursor in the second window group. Simulate a raw key event to start + the wserv heartbeat, which will make the custom cursor flashing. + +@SYMTestExpectedResults The Custom text cursor in the second window group should be visible and flashing, + when it comes to the foreground after the first window group sent to the background. +*/ + case 5: + ((CTCursorTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0247")); + iTest->LogSubTest(_L("Custom Text Cursor Sprite visibility")); + INC040489L(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-2095-0015 + +@SYMTestCaseDesc Text Cursor allows Update before Rendering the owning window + +@SYMTestPriority Normal + +@SYMTestStatus Implemented + +@SYMTestActions Create a window group and two windows, one with a Text Cursor. + Stimulate a state change in the Text Cursor by receiving + window focus, but before the Window has ever been Rendered. + This shakes out logic in RWsTextCursor which depends on + side effects arising from having executed CWsWindow::Render() + +@SYMTestExpectedResults + There should be no panic or assertion. +*/ + case 6: + ((CTCursorTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-2095-0015")); + iTest->LogSubTest(_L("Update before Render")); + CursorUpdatedBeforeWindowRenderedL(); + break; + +/** +@SYMTestCaseID GRAPHICS-WSERV-0248 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Tests a bad use of text cursor functionality from a client. + REQ 1079, CR RDEF-5F7Q24 (10/04/2003). + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions This test case checks whether the window server is able to detect a bad + use of the text cursor functionality (including the custom text cursor) + by a client. + This test case launches several threads and each of them will try + to use the text cursor functionality in a non-proper way. + +@SYMTestExpectedResults Each new thread has panic code associated to it. This is the expected panic when + the thread dies. + The thread once launched is expected to panic and the returning panic code should + match the expected one. +*/ + case 7: + ((CTCursorTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0248")); + iTest->LogSubTest(_L("Panic")); + TestPanicsL(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0400 + +@SYMDEF PDEF099013 + +@SYMTestCaseDesc Cursor moves slowly in text editors. + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions This test case is a VISUAL TEST only on whether a scrolling text cursor is drawn to the + screen correctly. 2 types of cursor are checked both clipped and non clipped cursors. + In each case the test simulates a text cursor moving across the screen as if a user were + holding down a key to scroll the cursor through a section of text. + +@SYMTestExpectedResults The text cursor in both cases should scroll smoothly to the centre of the screen. + In versions prior to this fix the cursor was not correctly drawn and appeared to move + slowly. +*/ + case 8: + ((CTCursorTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0400")); + iTest->LogSubTest(_L("Text Cursor Update Tests")); + INC097774(); + break; + +/** +@SYMTestCaseID GRAPHICS-WSERV-0401 + +@SYMDEF DEF098704 + +@SYMTestCaseDesc Test code for implemented fix to remove double cursors + +@SYMTestPriority Normal + +@SYMTestStatus Implemented + +@SYMTestActions This test case tests for artifacts left over when normal/custon flashing/non-flashing cursors are drawn. + Test that changing the focus of a custom text cursor does not leave that cursor drawn where it was (INC093898) + +@SYMTestExpectedResults +*/ + case 9: + ((CTCursorTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0401")); + iTest->LogSubTest(_L("Double cursors test 1")); + StartDoubleCursorTestL(1); + break; + + /** + @SYMTestCaseID GRAPHICS-WSERV-0402 + + @SYMDEF DEF098704 + + @SYMTestCaseDesc Test code for implemented fix to remove double cursors + + @SYMTestPriority Normal + + @SYMTestStatus Implemented + + @SYMTestActions Checks that no artifacts are left behind when a text cursor is moved from under a transparent sprite + + @SYMTestExpectedResults + */ + case 10: + ((CTCursorTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0402")); + iTest->LogSubTest(_L("Double cursors test 2")); + StartDoubleCursorTestL(2); + break; + + /** + @SYMTestCaseID GRAPHICS-WSERV-0403 + + @SYMDEF DEF098704 + + @SYMTestCaseDesc Test code for implemented fix to remove double cursors + + @SYMTestPriority Normal + + @SYMTestStatus Implemented + + @SYMTestActions This test moves a flashing cursor a number of times over a two second period to a seconds position. + it does it a number of times so some of the redraws will occur during the 'flash off' period + We then compare the 'after' position to what we expect + + @SYMTestExpectedResults + */ + case 11: + ((CTCursorTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0403")); + iTest->LogSubTest(_L("Double cursors test 3")); + StartDoubleCursorTestL(3); + break; + + /** + @SYMTestCaseID GRAPHICS-WSERV-0483 + + @SYMDEF INC117232 + + @SYMTestCaseDesc Test code: Refreshing cursors becoming offscreen due to screen size change should not panic + + @SYMTestPriority Normal + + @SYMTestStatus Implemented + + @SYMTestActions Create a cursor on bottom right of screen, change to a screen mode that excludes that coordinate + + @SYMTestExpectedResults + The server should not panic. + */ + case 12: + ((CTCursorTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0483")); + iTest->LogSubTest(_L("Screen resize invalidate cursor off-screen")); + INC117232(); + break; + + /** + @SYMTestCaseID GRAPHICS-WSERV-2095-0016 + + @SYMTestCaseDesc Text Cursor flag TTextCursor::EFlagNoFlash honored + + @SYMTestPriority Normal + + @SYMTestStatus Implemented + + @SYMTestActions Create a text cursor with the TTextCursor::EFlagNoFlash setting. Observe the screen over + a short period of time to verify that it remains continuously in the Flash ON state. + + @SYMTestExpectedResults + The text cursor should be always shown. + */ + case 13: + #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA + ((CTCursorTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-2095-0016")); + iTest->LogSubTest(_L("Text cursor EFlagNoFlash test")); + TextCursorNoFlashTestL(); + #endif + break; + + /** + @SYMTestCaseID GRAPHICS-WSERV-2095-0009 + + @SYMTestCaseDesc Text Cursor flashes when flag value is 0 + + @SYMTestPriority Normal + + @SYMTestStatus Implemented + + @SYMTestActions Create a text cursor with the 0 flag setting. Observe the screen over + a short period of time to verify that the cursor flashes ON and OFF at + the correct period of one second. + + @SYMTestExpectedResults + The text cursor should flash. + */ + case 14: + #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA + ((CTCursorTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-2095-0009")); + iTest->LogSubTest(_L("Text cursor will Flash test")); + TextCursorFlashTestL(); + #endif + break; + + /** + @SYMTestCaseID GRAPHICS-WSERV-2095-0017 + + @SYMTestCaseDesc Text Cursor handles different valid Cursor Setttings + + @SYMTestPriority Normal + + @SYMTestStatus Implemented + + @SYMTestActions Create a text cursor and then issue a SetTextCursor. Then repeatedly + call SetTextCursor, varying the arguments relating to the Text Cursor + as well as keeping the arguments the same on one occassion. + + @SYMTestExpectedResults + The system should not panic as the arguments supplied are never invalid. + */ + case 15: + ((CTCursorTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-2095-0017")); + iTest->LogSubTest(_L("SetTextCursor test")); + TextCursorSetLCoverageTests(); + break; + + default: + ((CTCursorTestStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + ((CTCursorTestStep*)iStep)->CloseTMSGraphicsStep(); + TestComplete(); + break; + } + ((CTCursorTestStep*)iStep)->RecordTestResultL(); + } + +__WS_CONSTRUCT_STEP__(CursorTest) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TTEXTCURS.H --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TTEXTCURS.H Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,146 @@ + +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef __TTEXTCURS_H__ +#define __TTEXTCURS_H__ + +#include +#include +#include "../tlib/testbase.h" +#include "AUTO.H" +#include "TGraphicsHarness.h" + +/* + * Wrapper class for a custom text cursor. + */ +class CCustomTextCursor : public CBase + { +public: + static CCustomTextCursor* CreateCustomTextCursorL(TInt aScreenNumber,TInt aBmpIndex,CTestBase* aTest); + ~CCustomTextCursor(); + +private: + CCustomTextCursor(CTestBase* aTest); + void ConstructL(TInt aScreenNumber,TInt aBmpIndex); + +public: + TInt iIdentifier; + RArray iSpriteMemberArray; + TUint iSpriteFlags; + RWsSession::TCustomTextCursorAlignment iAlignment; + CTestBase* iTest; + }; + +class CTCursorTest : public CTWsGraphicsBase + { +public: + CTCursorTest(CTestStep* aStep); + ~CTCursorTest(); +protected: +//from CTGraphicsStep + virtual void RunTestCaseL(TInt aCurTestCase); +private: + void SetCursor(const TPoint &aPos,const TSize &aSize,TRgb aColor, TUint aFlags=0); + void SetCursor(const TPoint &aPos,const TSize &aSize,TRgb aColor, const TRect &aRect, TUint aFlags=0); + void SetCursorPlusBox(const TPoint &aPos,const TSize &aSize,TRgb aColor, const TRect *aRect, TUint aFlags=0); + void CancelTextCursor(); + void ConstructL(); + void doMoveWindowTestL(); + TBool MoveWindow(); + void TestPanicsL(); + void ScrollTest(); + void GeneralTestsL(); + void MoveWindowTest1L(); + void MoveWindowTest2L(); + void INC041278L(); + void INC040489L(); + void CursorUpdatedBeforeWindowRenderedL(); + void INC097774(); + void INC117232(); +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA + void TextCursorNoFlashTestL(); + void TextCursorFlashTestL(); + void CheckCursorDoesNotFlash(const TSize& aSize); + void UpdateCountersOnCursorTransition( + const TBool aTransitionedToOn, + TTime& aNow, + TInt64& aDeltaTime, + TTime& aLastDeltaTime, + TInt& aWarmUpIterations, + const TInt& aFlashChangeTime, + const TInt& aToleranceMargin, + TInt& aSampleNumber, + TInt& aToleranceViolations + ); + void CheckCursorDoesFlash(const TPoint& aPos, const TTextCursor& aTextCursor, TRgb aBackgroundColor); + void DrawTextCursorSimilarToRenderStage(CWindowGc& aGc, RWindow& aWin, const TPoint& aPos, const TTextCursor& aTextCursor); +#endif + TBool IncrementCursorType(); + CTSprite* CreateTestSpriteLC(RWindowTreeNode &aWindow, const TPoint &aPos, TInt aCount); + void TestForArtifacts(CBlankWindow* aWin1, TTextCursor& aCursor); + void CheckNoDoubleCursorTest1L(CBlankWindow* aWin1, CBlankWindow* win2, TTextCursor& aTextCursor,TTextCursor& aCustomCursor, CWindowGc* winGc); + void CheckNoDoubleCursorTest2L(CBlankWindow* aWin1, CBlankWindow* win2, TTextCursor& aTextCursor,TTextCursor& aCustomCursor, CWindowGc* winGc); + void CheckNoDoubleCursorTest3L(CBlankWindow* aWin1, CBlankWindow* win2, TTextCursor& aTextCursor,TTextCursor& aCustomCursor, CWindowGc* winGc); + void MakeCursors(TTextCursor& aTextCursor, TTextCursor& aCustomCursor); + void StartDoubleCursorTestL(TInt aTestNumber); + void doCheckNoDoubleCursor(CBlankWindow* aWin1, + CBlankWindow* aWin2, + const TPoint& aWin1Tl, + const TPoint& aWin1T2, + const TTextCursor& aCursor, + const TSize& aCursorSize, + CWsScreenDevice::TSpriteInCompare aFlags); + + void ResetWindows(CWindowGc* aWinGc,CBlankWindow* aWin1,CBlankWindow* aWin2); + void ValidateWin(TestWindow *aWin, TRgb aColor); + void RedrawWin(RWindow &aWin, TRgb aColor); + void DeleteMoveWindows(); + void ResetMoveWindowsL(); + static TInt DoPanicTest(TInt aInt, TAny *aScreenNumber); + void TextCursorSetLCoverageTests(); + +private: + TSize iWinSize; + TPoint iWinPos; + TInt iWinState; + CBlankWindow *iMoveWin; + CBlankWindow *iCheckWin; + CBlankWindow *iWorkInProgress; + CBlankWindow *iComparisonWindow; + TTextCursor::EType iCursorType; + static CTestBase* iStaticTest; // static because it is used by DoPanicTest + }; + + +class CTCursorTestStep : public CTGraphicsStep + { +public: + CTCursorTestStep(); +protected: + //from CTGraphicsStep + virtual CTGraphicsBase* CreateTestL(); + }; + +_LIT(KTCursorTestStep,"TCursorTest"); + + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TTransptAnim.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TTransptAnim.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,367 @@ +// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ +#include "TTransptAnim.h" + +struct FrameSet + { + TRgb* iFrames; + const TInt iFrameCount; + FrameSet(TRgb* aFrames, const TInt aFrameCount) + : iFrames(aFrames), + iFrameCount(aFrameCount) + { + } + }; + +TRgb FrameSequenceAlpha[]= +{ TRgb(255, 0, 0, 50), TRgb(0, 255, 0, 70), TRgb(0, 0, 255, 100), TRgb(255, 255, 0, 150), TRgb(0, 255, 255, 200) }; +TRgb FrameSequenceNoAlpha[] = +{ TRgb(255, 0, 0), TRgb(0, 255, 0), TRgb(0, 0, 255), TRgb(255, 255, 0), TRgb(0, 255, 255) }; + +FrameSet frameSetAlpha(FrameSequenceAlpha, sizeof(FrameSequenceAlpha)/sizeof(TRgb)); +FrameSet frameSetNoAlpha(FrameSequenceNoAlpha, sizeof(FrameSequenceNoAlpha)/sizeof(TRgb)); +FrameSet TestFrameSets[] = + { + frameSetAlpha, frameSetNoAlpha + }; + +static const TInt FRAME_DELAY = 2000000; +static const TInt DRAW_LINE_ANIMATION = 36; +static const TBool ALPHATRANSPARENCY_ON = ETrue; +static const TInt ALPHA_FRAMESET = 0; + +//***************************************************************************** +CTTestCase* CTTransparentAnim::CreateTestCaseL(CTTransparentAnim* aTransAnim, TInt aTestCaseId) + { + CTTestCase* testCase = aTransAnim->GetCurrent(); + + if (!testCase) + { + switch (aTestCaseId) + { + case GraphicsWServ0483 : + testCase = CTGraphicsWServ0483::NewL(); + break; + } + } + + return testCase; + } + +//***************************************************************************** +CTTransparentAnim::CTTransparentAnim(CTestStep* aStep) +: CTWsGraphicsBase(aStep), iCurrentTestCase(NULL) + {} + +CTTransparentAnim::~CTTransparentAnim() + { + TheClient->iWs.SetAutoFlush(EFalse); + } + +void CTTransparentAnim::ConstructL() + { + TheClient->iWs.SetAutoFlush(ETrue); + } + +void CTTransparentAnim::RunTestCaseL(TInt) + { + ((CTTransparentAnimStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0483")); + CTTestCase* testCase = CTTransparentAnim::CreateTestCaseL(this, iTest->iState); + + if (!testCase) + { + TestComplete(); + return ; + } + + TInt err = KErrNone; + + if (!testCase->IsAlreadyRunning()) + { + SetCurrent(testCase); + iTest->LogSubTest(testCase->TestCaseName()); + TRAP(err, testCase->StartL()); + testCase->SetError(err); + } + + if (testCase->IsComplete() || err != KErrNone) + { + ((CTTransparentAnimStep*)iStep)->RecordTestResultL(); + ((CTTransparentAnimStep*)iStep)->CloseTMSGraphicsStep(); + if (testCase->HasFailed()) + { + INFO_PRINTF3(_L("ErrorStatus - Expected: %d, Actual: %d"), ETrue, EFalse); + } + ++iTest->iState; + SetCurrent(NULL); + delete testCase; + } + else + { + // Prevent test harness from repeatedly running the test case too quickly. + User::After(TTimeIntervalMicroSeconds32(FRAME_DELAY)); + } + } + +void CTTransparentAnim::SetCurrent(CTTestCase* aTestCase) + { + iCurrentTestCase = aTestCase; + } + +CTTestCase* CTTransparentAnim::GetCurrent() + { + return iCurrentTestCase; + } + +//***************************************************************************** +CTTAnimation::CTTAnimation(CTWin* aWin, TInt aDrawArg) +: iWin(aWin), iFrameCount(0), iCurrentFrameSet(0), iIsComplete(EFalse), iDrawArg(aDrawArg) + { + iAnimDll = RAnimDll(TheClient->iWs); + iAnimDll.Load(KAnimDLLName); + iDrawAnim = RTestAnim(iAnimDll); + iDrawAnim.Construct(*iWin->BaseWin(), EAnimTypeTrans, TPckgBuf(aWin->Size())); + } + +CTTAnimation::~CTTAnimation() + { + iDrawAnim.Close(); + iAnimDll.Close(); + delete iWin; + } + +void CTTAnimation::StartL() + { + iAnimTimer.ConstructL(); + iAnimTimer.Start(FRAME_DELAY, TCallBack(CTTAnimation::NextFrame,this)); + } + +TBool CTTAnimation::IsComplete() + { + return iIsComplete; + } + +void CTTAnimation::SetCurrentFrameSet(TInt aFrameSet) + { + iCurrentFrameSet = aFrameSet; + } + +CTWin* CTTAnimation::GetWindow() + { + return iWin; + } + +void CTTAnimation::Attach(MAnimationObserver* aObserver) + { + iObserver = aObserver; + } + +TInt CTTAnimation::NextFrame(TAny* aAnim) + { + STATIC_CAST(CTTAnimation*,aAnim)->NextFrame(); + + return KErrNone; + } + +void CTTAnimation::NextFrame() + { + TRgb Color; + TPckgBuf paramsPckg; + + if (iFrameCount == TestFrameSets[iCurrentFrameSet].iFrameCount) + { + iIsComplete = ETrue; + iObserver->Update(this); + return ; + } + + Color = TestFrameSets[iCurrentFrameSet].iFrames[iFrameCount++]; + + paramsPckg().draw = iDrawArg; + paramsPckg().color = Color; + + iDrawAnim.Command(EADllNextFrame, paramsPckg); + + iAnimTimer.Start(FRAME_DELAY, TCallBack(CTTAnimation::NextFrame,this)); + } + +//***************************************************************************** +CTransAnimTimer::CTransAnimTimer() +: CTimer(EPriorityStandard) + {} + +CTransAnimTimer::~CTransAnimTimer() + {} + +void CTransAnimTimer::ConstructL() + { + CTimer::ConstructL(); + CActiveScheduler::Add(this); + } + +void CTransAnimTimer::RunL() + { + iCallBack.CallBack(); + } + +void CTransAnimTimer::Start(TTimeIntervalMicroSeconds32 aInterval,TCallBack aCallBack) + { + iCallBack = aCallBack; + After(aInterval); + } + +//***************************************************************************** +CTTestCase::CTTestCase() +: iError(KErrNone), iIsComplete(EFalse), iIsRunning(EFalse) + {} + +TBool CTTestCase::IsAlreadyRunning() + { + return iIsRunning; + } + +void CTTestCase::Update(CTTAnimation* aAnim) + { + iIsComplete = aAnim->IsComplete(); + } + +TBool CTTestCase::IsComplete() + { + return iIsComplete; + } + +void CTTestCase::StartL() + { + if (!iIsRunning) + { + RunTestCaseL(); + iIsRunning = ETrue; + } + } + +TBool CTTestCase::HasFailed() + { + TBool ret = EFalse; + if (iError != KErrNone) + { + ret = ETrue; + } + return ret; + } + +void CTTestCase::SetIsCompleted(TBool aIsComplete) + { + iIsComplete = aIsComplete; + } + +void CTTestCase::SetError(TInt aError) + { + iError = aError; + } + +//*********************** New Test Case Classes go here************************ + +/** + * @SYMTestCaseID GRAPHICS-WSERV-0483 + * + * @SYMTestCaseDesc There are two animations running, one attached to a transparent + * window using SetTransparencyAlphaChannel and a second animation with a non-transparent + * window. The animations draw a line and then change the color of the line in subsequent + * frames. After the last frame the alpha channel for the first animation is set to + * opaque and then compared with the second animation to make certain that no artifacts + * are present. + * + * @SYMTestPriority High + * + * @SYMTestStatus Implemented + * + * @SYMTestActions An anim is attached with a Transparent window. + * The anim draws several frames using WSERV's Anim animation functionality. + * + * @SYMTestExpectedResults Both animations draw a line and then change it's color, the first + * animation doing it in a tranparent window and the second doing it in a non-transparent window. + **/ +CTGraphicsWServ0483* CTGraphicsWServ0483::NewL() + { + CTGraphicsWServ0483* testCase = new(ELeave) CTGraphicsWServ0483(); + + CleanupStack::PushL(testCase); + testCase->ConstructL(); + CleanupStack::Pop(); + + return testCase; + } + +CTGraphicsWServ0483::~CTGraphicsWServ0483() + { + delete iAnim; + delete iCheckAnim; + } + +void CTGraphicsWServ0483::ConstructL() + { + iAnim = new(ELeave) CTTAnimation(CTAnimWin::NewL( + BaseWin->GetBorderWin()->Position(), + BaseWin->GetBorderWin()->Size()), DRAW_LINE_ANIMATION); + + iCheckAnim = new(ELeave) CTTAnimation(CTAnimWin<>::NewL( + TestWin->GetBorderWin()->Position(), + TestWin->GetBorderWin()->Size()), DRAW_LINE_ANIMATION); + TheClient->WaitForRedrawsToFinish(); + } + +void CTGraphicsWServ0483::RunTestCaseL() + { + iAnim->Attach(this); + iCheckAnim->Attach(this); + + iAnim->SetCurrentFrameSet(ALPHA_FRAMESET); + iAnim->StartL(); + + iCheckAnim->SetCurrentFrameSet(ALPHA_FRAMESET); + iCheckAnim->StartL(); + } + +void CTGraphicsWServ0483::Update(CTTAnimation*) + { + if (iAnim->IsComplete() && iCheckAnim->IsComplete()) + { + TRgb bgColor(150, 150, 150, 255); + iAnim->GetWindow()->Win()->SetBackgroundColor(bgColor); + iAnim->GetWindow()->Win()->Invalidate(); + TheClient->iWs.Finish(); + TheClient->WaitForRedrawsToFinish(); + if (!DoCheckRect(iAnim->GetWindow(), iCheckAnim->GetWindow())) + { + SetError(KErrGeneral); + } + SetIsCompleted(ETrue); + } + } + +TPtrC CTGraphicsWServ0483::TestCaseName() + { + _LIT(KTransparentAlphaChannelAnimationTest, "Transparent Anim Test"); + + return TPtrC(KTransparentAlphaChannelAnimationTest); + } + +__WS_CONSTRUCT_STEP__(TransparentAnim) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TTransptAnim.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TTransptAnim.h Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,203 @@ + +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ +#ifndef __TTRANSPTANIM__ +#define __TTRANSPTANIM__ + +#include +#include +#include +#include "../tlib/testbase.h" +#include "AUTO.H" +#include "AUTODLL.H" + +enum + { + GraphicsWServ0483 = 0 + }; + +class CTTestCase; +class CTransAnimTimer; +class CTTransparentAnim; +class CTTAnimation; +class MAnimationObserver; + +class CTTransparentAnim : public CTWsGraphicsBase + { +public: + static CTTestCase* CreateTestCaseL(CTTransparentAnim*, TInt); +public: + CTTransparentAnim(CTestStep*); + virtual ~CTTransparentAnim(); + void ConstructL(); + + void SetCurrent(CTTestCase*); + CTTestCase* GetCurrent(); +protected: + virtual void RunTestCaseL(TInt); + +private: + CTTestCase* iCurrentTestCase; + }; + +class CTTransparentAnimStep : public CTGraphicsStep + { +public: + CTTransparentAnimStep(); + +protected: + virtual CTGraphicsBase* CreateTestL(); + }; + +class CTransAnimTimer : public CTimer + { +public: + CTransAnimTimer(); + ~CTransAnimTimer(); + void ConstructL(); + void Start(TTimeIntervalMicroSeconds32 aInterval,TCallBack aCallBack); +private: + void RunL(); + TCallBack iCallBack; + }; + +class CTTAnimation + { +public: + CTTAnimation(CTWin*, TInt); + ~CTTAnimation(); + + void StartL(); + TBool IsComplete(); + void SetCurrentFrameSet(TInt); + CTWin* GetWindow(); + void Attach(MAnimationObserver*); +private: + static TInt NextFrame(TAny*); + void NextFrame(); + +private: + CTWin* iWin; + MAnimationObserver* iObserver; + RAnimDll iAnimDll; + RTestAnim iDrawAnim; + CTransAnimTimer iAnimTimer; + TInt iFrameCount; + TInt iCurrentFrameSet; + TBool iIsComplete; + TInt iDrawArg; + }; + +template +class CTAnimWin : public CTWin + { +public: + static CTWin* NewL(TPoint aPosition, TSize aSize) + { + CTAnimWin* w = new(ELeave) CTAnimWin(); + + CleanupStack::PushL(w); + w->ConstructL(aPosition, aSize); + CleanupStack::Pop(); + + return w; + } +public: + virtual ~CTAnimWin(){} + + void Draw(){} +private: + CTAnimWin(){} + + void ConstructL(TPoint aPoint, TSize aSize) + { + TRgb bgColor(150, 150, 150); + ConstructExtLD(*TheClient->iGroup, aPoint, aSize); + AssignGC(*TheClient->iGc); + Win()->SetRequiredDisplayMode(EColor16MA); + if (AlphaTransparency) + { + Win()->SetTransparencyAlphaChannel(); + bgColor.SetAlpha(150); + } + Win()->SetBackgroundColor(bgColor); + Win()->Activate(); + } + }; + +//***************************************************************************** +class MAnimationObserver + { +public: + virtual void Update(CTTAnimation*) = 0; + }; + +class CTTestCase : public MAnimationObserver + { +public: + CTTestCase(); + virtual ~CTTestCase() {} + + TBool IsAlreadyRunning(); + TBool IsComplete(); + void StartL(); + TBool HasFailed(); + void SetError(TInt); + + // Implemented for MAnimationObserver + virtual void Update(CTTAnimation*); + virtual void ConstructL() = 0; + virtual TPtrC TestCaseName() = 0; + +protected: + virtual void RunTestCaseL() = 0; + void SetIsCompleted(TBool); + +private: + TInt iError; + TBool iIsComplete; + TBool iIsRunning; + }; + +class CTGraphicsWServ0483 : public CTTestCase + { +public: + static CTGraphicsWServ0483* NewL(); + +public: + virtual ~CTGraphicsWServ0483(); + virtual void RunTestCaseL(); + + void Update(CTTAnimation*); + +protected: + CTGraphicsWServ0483(){} + virtual void ConstructL(); + virtual TPtrC TestCaseName(); + +private: + CTTAnimation* iAnim; + CTTAnimation* iCheckAnim; + }; + +_LIT(KTTransparentAnimStep,"TTransparentAnim"); + +#endif // __TTRANSPTANIM__ diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TWINDOW.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TWINDOW.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,2943 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// General window tests +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include "TWINDOW.H" + +const TInt ENumCornerInsets=6; +const TInt corner0[ENumCornerInsets]={0,0,0,0,0,0}; +const TInt corner1[ENumCornerInsets]={1,0,0,0,0,0}; +const TInt corner2[ENumCornerInsets]={2,1,0,0,0,0}; +const TInt corner3[ENumCornerInsets]={3,1,1,0,0,0}; +const TInt corner5[ENumCornerInsets]={5,3,2,1,1,0}; +const TInt KBaseUserEvent=61750; //0xF136 - a random number that is unlikely to be used by other applicaions for user event sending + +// + +CWinTestWindow::CWinTestWindow(TRgb aCol) : CBlankWindow(aCol) + { + } + +CWinTestWindow::~CWinTestWindow() + { + delete iChild; + } + +void CWinTestWindow::ConstructL(TPoint pos,TSize size,CTWinBase *aParent, CWindowGc &aGc, TInt aDepth) + { + iWin=RWindow(TheClient->iWs); + User::LeaveIfError(iWin.Construct(*(aParent->WinTreeNode()),ENullWsHandle)); + SetExt(pos,size); + if (aDepth<3) + { + iChild=new(ELeave) CWinTestWindow(TRgb::Gray256(iCol.Gray256()+34)); + size.iWidth-=8; + size.iHeight-=8; + iChild->ConstructL(TPoint(4,4),size,this,aGc,aDepth+1); + } + Activate(); + AssignGC(aGc); + } + +// + +CEvWindowGroup* CEvWindowGroup::NewLC(CTClient* aClient,CTWsGraphicsBase* aTest) + { + CEvWindowGroup* self=new(ELeave) CEvWindowGroup(aClient,aTest); + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } + +CEvWindowGroup::CEvWindowGroup(CTClient* aClient,CTWsGraphicsBase* aTest) : CTWindowGroup(aClient), iTest(aTest) + {} + +void CEvWindowGroup::ConstructL() + { + CTWindowGroup::ConstructL(); + iGroupWin.EnableReceiptOfFocus(EFalse); + } + +void CEvWindowGroup::SetExpectedEvent(TInt aType) + { + iTest->TEST(!iExpectingEvent); + if (iExpectingEvent) + { + _LIT(KLog,"Setting expected event of type %d, when previouse event of type %d has not arrived (GpWinId=%d)."); + iTest->LOG_MESSAGE4(KLog,aType,iExpectedEvent,iGroupWin.Identifier()); + } + iExpectedEvent=aType; + iExpectingEvent=ETrue; + } + +void CEvWindowGroup::SendEvent(TInt aType) + { + TWsEvent event; + event.SetType(aType); + iClient->iWs.SendEventToWindowGroup(iGroupWin.Identifier(),event); + SetExpectedEvent(aType); + iClient->Flush(); + } + +void CEvWindowGroup::UserEvent(TInt aEventType) + { + iTest->TEST(iExpectingEvent && iExpectedEvent==aEventType); + if (!iExpectingEvent || iExpectedEvent!=aEventType) + { + TInt id=iGroupWin.Identifier(); + if (!iExpectingEvent) + { + _LIT(KLog,"Event of type %d recieved when not expecting an event (GpWinId=%d)."); + iTest->LOG_MESSAGE3(KLog,aEventType,id); + } + else + { + _LIT(KLog,"Event of type %d when expecting an event of type %d (GpWinId=%d)."); + iTest->LOG_MESSAGE4(KLog,aEventType,iExpectingEvent,id); + } + } + iExpectingEvent=EFalse; + } + +// + +CTWindowTest::CTWindowTest(CTestStep* aStep) : CTWsGraphicsBase(aStep) + {} + +CTWindowTest::~CTWindowTest() + { + delete iWin; + } + +void CTWindowTest::ConstructL() + {} + +TInt CTWindowTest::MoveGroup(TAny* aParam) + { + RWsSession ws; + TInt err=ws.Connect(); + if (err==KErrNone) + { + TInt command=static_cast(aParam)->iCommand; + err=ws.SetWindowGroupOrdinalPosition(command&EIdMask,(command&EPosMask)>>EPosShift); + ws.Finish(); + ws.Close(); + } + return err; + } + +void CTWindowTest::CreateTestWindowL() + { + iWin=new(ELeave) CWinTestWindow(TRgb(0,0,0)); + iWin->ConstructL(TPoint(1,1),TSize(TestWin->Size().iWidth/2,TestWin->Size().iHeight/2),TheClient->iGroup,*TheClient->iGc,0); + } + +void CTWindowTest::DrawWindows(CWinTestWindow *aWin) + { + if (aWin->iChild) + DrawWindows(aWin->iChild); + aWin->Win()->BeginRedraw(); + TheGc->Activate(*aWin->Win()); + TheGc->DrawRect(TRect(aWin->Win()->Size())); + TheGc->Deactivate(); + aWin->Win()->EndRedraw(); + TheClient->iWs.Flush(); + } + +void CTWindowTest::CheckAndDestroyWindows() + { + DrawWindows(iWin); + delete iWin; + iWin=NULL; + } + +void CTWindowTest::DestroyWindowWithActiveGc() + { + iWin->Win()->BeginRedraw(); + TheGc->Activate(*iWin->Win()); + delete iWin; + TheGc->Deactivate(); + iWin=NULL; + } + +void CTWindowTest::DestroyWindowWithActiveGc2L() + { + iWin->Win()->BeginRedraw(); + TheGc->Activate(*iWin->Win()); + CWindowGc *gc1=new(ELeave) CWindowGc(TheClient->iScreen); + CWindowGc *gc2=new(ELeave) CWindowGc(TheClient->iScreen); + CWindowGc *gc3=new(ELeave) CWindowGc(TheClient->iScreen); + gc1->Construct(); + gc2->Construct(); + gc3->Construct(); + gc1->Activate(*iWin->Win()); + gc2->Activate(*iWin->Win()); + gc3->Activate(*iWin->Win()); + delete iWin; + TheGc->Deactivate(); + delete gc1; + delete gc2; + delete gc3; + iWin=NULL; + } + +LOCAL_C TInt DoPanicTest(TInt aInt, TAny *aScreenNumber) + { + RWsSession ws; + User::LeaveIfError(ws.Connect()); + // use correct screen + // + CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws); + User::LeaveIfError(screen->Construct((TInt)aScreenNumber)); + + RWindowGroup group(ws); + group.Construct(888); + group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close + + RWindow redraw(ws); + redraw.Construct(group,88); + + RBackedUpWindow backedUp(ws); + backedUp.Construct(group,EGray16,99); + + RBlankWindow blank(ws); + blank.Construct(group,111); + + RWindowBase *base=NULL; + TInt source=aInt/10000; + TInt target=(aInt%10000)/100; + TInt panic=aInt%100; + switch(source) + { + case 0: + base= &redraw; + break; + case 1: + base= &backedUp; + break; + case 2: + base= ␣ + break; + } + switch(target) + { + case 0: + { + RWindow *win=(RWindow *)base; + switch(panic) + { + case 0: + win->BeginRedraw(); + break; + case 1: + ws.SetAutoFlush(ETrue); + win->BeginRedraw(TRect(0,0,1,1)); + ws.SetAutoFlush(EFalse); + break; + case 2: + ws.SetAutoFlush(ETrue); + win->EndRedraw(); + ws.SetAutoFlush(EFalse); + break; + case 3: + win->Invalidate(); + break; + case 4: + win->Invalidate(TRect(0,0,1,1)); + break; + case 5: + { + RRegion region; + win->GetInvalidRegion(region); + } + break; + case 6: + win->SetBackgroundColor(TRgb(0,0,0)); + break; + case 7: + return(EWsExitReasonFinished); + } + break; + } + case 1: + { + RBackedUpWindow *win=(RBackedUpWindow *)base; + switch(panic) + { + case 0: + win->BitmapHandle(); + break; + case 1: + win->UpdateScreen(); + break; + case 2: + win->UpdateScreen(TRegionFix<1>(TRect(10,10,20,20))); + break; + case 3: + win->UpdateBackupBitmap(); + break; + case 4: + win->MaintainBackup(); + break; + case 5: + return(EWsExitReasonFinished); + } + break; + } + case 2: + { + RBlankWindow *win=(RBlankWindow *)base; + switch(panic) + { + case 0: + win->SetColor(TRgb(0)); + break; + case 1: + return(EWsExitReasonFinished); + } + break; + } + } + ws.Flush(); + return(EWsExitReasonBad); // Should never get here, but it's baaddd if it does + } + +struct TWsLocalStructure + { + TInt xPos; + TInt yPos; + TInt Length; + TAny *ptr; + }; + +LOCAL_C TInt DoPanicTest2(TInt aInt, TAny *aScreenNumber) + { + RWsSession ws; + User::LeaveIfError(ws.Connect()); +// + CWsScreenDevice *screen=new(ELeave) CWsScreenDevice(ws); + screen->Construct((TInt)aScreenNumber); +// + RWindowGroup group(ws); + group.Construct(999); + group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close + + RWindow win(ws); + win.Construct(group,122); + win.Activate(); + + switch(aInt) + { + case 0: + { + win.BeginRedraw(); + CWindowGc *gc; + screen->CreateContext(gc); + gc->Activate(win); + CFbsFont *font; + screen->GetNearestFontToDesignHeightInTwips((CFont *&)font,TFontSpec()); + gc->UseFont(font); + TWsLocalStructure params; + params.xPos=0; + params.yPos=0; + params.Length=1; + TPckgC pkg(params); + TPtr8 ptr(NULL,10,10); + ws.TestWriteReplyByProvidingRemoteReadAccess(gc->WsHandle(),EWsGcOpDrawTextPtr,pkg,ptr); // Bad source descriptor + } + break; + case 1: + { + TPtr8 bad(NULL,0); // Bad descriptor + ws.TestWriteReplyP(win.WsHandle(),EWsWinOpSize,NULL,0,&bad); // Bad descriptor + } + break; + case 2: + { + TSize size; + TPtr8 bad((TUint8 *)&size,4,4); // Short descriptor + ws.TestWriteReplyP(win.WsHandle(),EWsWinOpSize,NULL,0,&bad); // Short descriptor + } + break; + case 3: + win.EnablePointerMoveBuffer(); + break; + case 4: + { + RBackedUpWindow backup(ws); + backup.Construct(group,EGray16,123); + backup.Activate(); + backup.SetRequiredDisplayMode(EGray16); + } + break; + default: + return(EWsExitReasonFinished); + } + ws.Flush(); + return(EWsExitReasonBad); // Should never get here, but it's baaddd if it does + } + +LOCAL_C TInt CallWindowFuction(RWindowTreeNode* aWin,TInt aWinType,TInt aFunc,RWsSession aWs) + { + switch(aWinType) + { + case 0: //Call functions from RWindowTreeNode + { + RWindowTreeNode* win=aWin; + switch(aFunc) + { + case 0: + win->OrdinalPosition(); + break; + case 1: + win->SetOrdinalPosition(1); + break; + case 2: + win->SetOrdinalPosition(1,2); + break; + case 3: + win->FullOrdinalPosition(); + break; + case 4: + win->Parent(); + break; + case 5: + win->PrevSibling(); + break; + case 6: + win->SetFaded(0,RWindowTreeNode::EFadeIncludeChildren); + break; + case 7: + win->WindowGroupId(); + break; + //The following can be called on a window with no parent without panicking + case 8: + win->ClearPointerCursor(); + break; + case 9: + win->ClientHandle(); + break; + case 10: + win->DisableErrorMessages(); + break; + case 11: + win->DisableFocusChangeEvents(); + break; + case 12: + win->DisableGroupChangeEvents(); + break; + case 13: + win->DisableGroupListChangeEvents(); + break; + case 14: + win->DisableModifierChangedEvents(); + break; + case 15: + win->DisableOnEvents(); + break; + case 16: + win->DisableVisibilityChangeEvents(); + break; + case 17: + win->EnableErrorMessages(EEventControlAlways); + break; + case 18: + win->EnableFocusChangeEvents(); + break; + case 19: + win->EnableGroupChangeEvents(); + break; + case 20: + win->EnableGroupListChangeEvents(); + break; + case 21: + win->EnableModifierChangedEvents(0,EEventControlAlways); + break; + case 22: + win->EnableVisibilityChangeEvents(); + break; + case 23: + win->NextSibling(); + break; + case 24: + win->OrdinalPriority(); + break; + case 25: + win->SetNonFading(0); + break; + case 26: + win->SetPointerCursor(0); + break; + case 27: + win->Child(); + break; + case 28: + return(EWsExitReasonFinished); + default:; + } + } + break; + case 1: //Call functions from RWindowGroup + { + RWindowGroup* win=(RWindowGroup*)aWin; + switch(aFunc) + { + case 0: + win->EnableReceiptOfFocus(ETrue); + break; + case 1: + win->AutoForeground(ETrue); + break; + case 2: + win->SetOrdinalPriorityAdjust(5); + break; + case 3: + win->CaptureKey(20,0,0); + break; + case 4: + win->CaptureKeyUpAndDowns(20,0,0); + break; + case 5: + case 6: + { + RWindowGroup group(aWs); + group.Construct(876); + group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close + if (aFunc==5) + win->CancelCaptureKey(group.CaptureKey(20,0,0)); + else + win->CancelCaptureKeyUpAndDowns(group.CaptureKeyUpAndDowns(20,0,0)); + } + break; + case 7: + win->AddPriorityKey(20,0,0); + break; + case 8: + win->RemovePriorityKey(20,0,0); + break; + case 9: + case 10: + { + RWindowGroup group(aWs); + group.Construct(765); + group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close + RWindow window(aWs); + window.Construct(group,79); + if (aFunc==9) + win->SetTextCursor(window,TPoint(45,46),TTextCursor()); + else + win->SetTextCursor(window,TPoint(55,66),TTextCursor(),TRect(TSize(5,8))); + } + break; + case 11: + win->CancelTextCursor(); + break; + case 12: + win->SetOwningWindowGroup(456); + break; + case 13: + win->DefaultOwningWindow(); + break; + case 14: + { + TBufC<8> text(_L("abcdef")); + win->SetName(text); + } + break; + case 15: + { + TBuf<16> text; + User::LeaveIfError(win->Name(text)); + } + break; + case 16: + win->Identifier(); + break; + case 17: + win->DisableKeyClick(ETrue); + break; + case 18: + /*{ + TPtr8 text(NULL,0); + TUid uid; + User::LeaveIfError(win->FetchMessage(uid,text)); + }*/ + win->Identifier(); + break; + case 19: + User::LeaveIfError(win->EnableScreenChangeEvents()); + break; + case 20: + win->EnableScreenChangeEvents(); + break; + case 21: + win->DisableScreenChangeEvents(); + break; + case 22: + win->SimulatePointerEvent(TRawEvent()); + break; +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA + case 23: + win->SimulateAdvancedPointerEvent(TRawEvent()); + break; + case 24: + return(EWsExitReasonFinished); +#else + case 23: + return(EWsExitReasonFinished); +#endif + default:; + } + } + break; + case 2: //Call functions from RWindowBase + { + RWindowBase* win=(RWindowBase*)aWin; + switch(aFunc) + { + case 0: + win->SetPosition(TPoint(7,8)); + break; + case 1: + User::LeaveIfError(win->SetSizeErr(TSize(21,22))); + break; + case 2: + User::LeaveIfError(win->SetExtentErr(TPoint(8,9),TSize(21,22))); + break; + case 3: + win->ClaimPointerGrab(); + break; + case 4: + win->SetVisible(ETrue); + break; + case 5: + win->EnableBackup(); + break; + case 6: + win->RequestPointerRepeatEvent(TTimeIntervalMicroSeconds32(100000),TRect()); + break; + case 7: + win->PasswordWindow(EPasswordCancel); + break; + case 8: + win->FadeBehind(ETrue); + break; + //These can all be called on a window with no parent without panicking + case 9: + win->SetVisible(EFalse); + break; + case 10: + { + RWindowGroup group(aWs); + group.Construct(567); + group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close + RWindow window(aWs); + window.Construct(group,97); + win->InquireOffset(window); + } + break; + case 11: + win->PointerFilter(0,0); + break; + case 12: + win->SetPointerGrab(ETrue); + break; + case 13: + win->SetPointerCapture(0); + break; + case 14: + win->Size(); + break; + case 15: + win->Position(); + break; + case 16: + User::LeaveIfError(win->SetCornerType(EWindowCorner5,0)); + break; + case 17: + { + TRegionFix<3> region; + User::LeaveIfError(win->SetShape(region)); + } + break; + case 18: + User::LeaveIfError(win->SetRequiredDisplayMode(EColor16)); + break; + case 19: + win->DisplayMode(); + break; + case 20: + win->CancelPointerRepeatEventRequest(); + break; + case 21: + win->AllocPointerMoveBuffer(10,0); + break; + case 22: + win->FreePointerMoveBuffer(); + break; + case 23: + win->DisablePointerMoveBuffer(); + break; + case 24: + { + TBuf8<16> buf; + win->RetrievePointerMoveBuffer(buf); + } + break; + case 25: + win->DiscardPointerMoveBuffer(); + break; + case 26: + User::LeaveIfError(win->AddKeyRect(TRect(TSize(10,10)),20,ETrue)); + break; + case 27: + win->RemoveAllKeyRects(); + break; + case 28: + win->EnablePointerMoveBuffer(); + break; + case 29: + return(EWsExitReasonFinished); + default:; + } + } + break; + case 3: //Call functions from RDrawableWindow + { + RDrawableWindow* win=(RDrawableWindow*)aWin; + switch(aFunc) + { + //The following can be called on a window with no parent without panicking + case 0: + win->Scroll(TPoint(7,8)); + break; + case 1: + win->Scroll(TRect(9,10,11,12),TPoint(13,14)); + break; + case 2: + win->Scroll(TPoint(15,16),TRect(17,18,19,20)); + break; + case 3: + win->Scroll(TRect(21,22,23,24),TPoint(25,26),TRect(27,28,29,30)); + break; + case 4: + return(EWsExitReasonFinished); + default:; + } + } + break; + case 4: //Call functions from RBlankWindow + { + RBlankWindow* win=(RBlankWindow*)aWin; + switch(aFunc) + { + case 0: + win->SetSize(TSize(7,8)); + break; + case 1: + win->SetExtent(TPoint(27,28),TSize(17,18)); + break; + //The following function can be called on a window with no parent without panicking + case 2: + win->SetColor(TRgb::Gray4(2)); + break; + case 3: + return(EWsExitReasonFinished); + default:; + } + } + break; + case 5: //Call functions from RWindow + { + RWindow* win=(RWindow*)aWin; + switch(aFunc) + { + case 0: + win->BeginRedraw(); + break; + case 1: + aWs.SetAutoFlush(ETrue); + win->BeginRedraw(TRect(31,32,43,44)); + aWs.SetAutoFlush(EFalse); + break; + case 2: + win->SetSize(TSize(5,6)); + break; + case 3: + win->SetExtent(TPoint(25,26),TSize(15,16)); + break; + //The following can be called on a window with no parent without panicking + case 4: + win->Invalidate(); + break; + case 5: + win->Invalidate(TRect(51,52,63,64)); + break; + case 6: //These ones don't panic + aWs.SetAutoFlush(ETrue); + win->EndRedraw(); + aWs.SetAutoFlush(EFalse); + break; + case 7: + { + RRegion region; + win->GetInvalidRegion(region); + } + break; + case 8: + win->SetBackgroundColor(TRgb::Gray4(1)); + break; + case 9: + win->SetBackgroundColor(); + break; + case 10: + return(EWsExitReasonFinished); + default:; + } + } + break; + case 6: //Call functions from RBackedUpWindow + { + RBackedUpWindow* win=(RBackedUpWindow*)aWin; + switch(aFunc) //None of these functions panic + { + //The following can be called on a window with no parent without panicking + case 0: + win->BitmapHandle(); + break; + case 1: + win->UpdateBackupBitmap(); + break; + case 2: + win->MaintainBackup(); + break; + case 3: + win->UpdateScreen(); + break; + case 4: + win->UpdateScreen(TRegionFix<1>(TRect(1,1,22,22))); + break; + case 5: + return(EWsExitReasonFinished); + default:; + } + } + break; + } + aWs.Flush(); + return(EWsExitReasonBad); // Should never get here, but it's baaddd if it does + } + +LOCAL_C TInt DoPanicTest3(TInt aInt, TAny *aScreenNumber) + { + TInt winType=aInt/CTWindowTest::EWinTypeFactor; + TInt func=aInt%CTWindowTest::EWinTypeFactor; + RWsSession ws; + User::LeaveIfError(ws.Connect()); + // use correct screen + // + CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws); + User::LeaveIfError(screen->Construct((TInt)aScreenNumber)); + + RWindowGroup group(ws); + group.Construct(888); + group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close + RWindow window(ws); + window.Construct(group,789); + RWindowTreeNode* win; + if (winType==1) + win=&window; + else + win=&group; + + return CallWindowFuction(win,winType,func,ws); + } + +//PanicTestNoPanic +//This function is called from DoPanicTest4 for window functions that should run without +//panicking the user thread if its parent has been deleted. +TInt PanicTestNoPanic(RWindowTreeNode* aWin,TInt aWinType,TInt aFunc,RWsSession aWs,const TInt* const aFuncToSkip) + { + TInt funcReturn; + for(;;) + { + if (aFuncToSkip && *aFuncToSkip == aFunc) + { + aFunc++; + } + funcReturn = CallWindowFuction(aWin,aWinType,aFunc,aWs); + if (funcReturn==EWsExitReasonBad) + { + aFunc++; + } + else if (funcReturn==EWsExitReasonFinished) + { + return EWsExitReasonFinished; + } + else + { + return EWsExitReasonBad; + } + } + } + +LOCAL_C TInt DoPanicTest4(TInt aInt, TAny *aScreenNumber) + { + TInt winType=aInt/CTWindowTest::EWinTypeFactor; + TInt func=aInt%CTWindowTest::EWinTypeFactor; + RWsSession ws; + User::LeaveIfError(ws.Connect()); + // use correct screen + // + CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws); + User::LeaveIfError(screen->Construct((TInt)aScreenNumber)); + + RWindowGroup group(ws); + group.Construct(234); + group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close + RWindow window(ws); + window.Construct(group,897); + RBackedUpWindow backedUp(ws); + backedUp.Construct(group,EGray16,98); + RBlankWindow blank(ws); + blank.Construct(group,169); + RWindowTreeNode* win=&window; + switch (winType) + { + case 0: + { + if (func > 8) //if a func 8+ had panicked, fail the test + { + return EWsExitReasonBad; + } + else if (func==8) + { + group.Close(); + return PanicTestNoPanic(win,winType,func,ws,NULL); + } + } + break; + case 2: + { + if (func>9) //if a func 9+ had panicked, fail the test + { + return EWsExitReasonBad; + } + else if (func==9) //set window visible so that SetVisible(EFalse) (func 9) would crash before fix + { + window.SetVisible(ETrue); + ws.Flush(); + group.Close(); + TInt funcToSkip = 28; //this call needs to have already successfully allocated a pointer cursor + return PanicTestNoPanic(win,winType,func,ws,&funcToSkip); + } + } + break; + case 4: + { + win=␣ + if (func>2) //if a func 2+ had panicked, fail the test + { + return EWsExitReasonBad; + } + else if (func==2) + { + group.Close(); + return PanicTestNoPanic(win,winType,func,ws,NULL); + } + } + break; + case 5: + { + if (func>6) //if a func 4+ had panicked, fail the test + { + return EWsExitReasonBad; + } + else if (func==4 || func==5) + { + if (CallWindowFuction(win,winType,func,ws)==EWsExitReasonBad) + { + func = 1; + } + else + { + return EWsExitReasonBad; + } + } + else if (func==6) + { + group.Close(); + TInt funcToSkip = 6; //Skip the call to EndRedraw in CallWindowFunction, it is not safe to call it on Window casts. + return PanicTestNoPanic(win,winType,func,ws,&funcToSkip); + } + } + break; + case 6: + { + win=&backedUp; + if (func>0) + return EWsExitReasonBad; + else //if (func==0) + { + TInt end=2; + while (func==0) + { + group.Close(); + while (CallWindowFuction(win,winType,func,ws)==EWsExitReasonBad && ++funcConstruct((TInt)aScreenNumber); + + RWindowGroup group(ws); + group.Construct(235); + group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close + RWindow window(ws); + window.Construct(group,896); + CWindowGc *gc=new(ELeave) CWindowGc(scrDev); + gc->Construct(); + gc->Activate(window); + group.Close(); + switch (aTest) + { + case 0: + gc->Deactivate(); + gc->Activate(window); + break; + case 1: + gc->DrawLine(TPoint(0,0),TPoint(10,10)); + break; + default: + return(EWsExitReasonFinished); + } + ws.Flush(); + return(EWsExitReasonBad); // Should never get here, but it's baaddd if it does + } + +#if defined(_DEBUG) +LOCAL_C TInt DoPanicTest6(TInt /*aInt*/, TAny *aScreenNumber) + { + RWsSession ws; + User::LeaveIfError(ws.Connect()); + RWindowGroup group1(ws); + CWsScreenDevice* screen=new(ELeave) CWsScreenDevice(ws); + User::LeaveIfError(screen->Construct((TInt)aScreenNumber)); + group1.Construct(123456,ETrue,screen); + RWindowGroup group2(ws); + group2.Construct(123456,ETrue,screen); // Should panic client here + return(EWsExitReasonBad); // Should never get here + } +#endif + +void CTWindowTest::TestInvalidFunctionsL() +// +// This code casts windows to be different types and then sends messages for the 'cast' that +// should not be sent to the original type of window. These should all result in panics +// + { + static TClientPanic PanicCode[]={EWservPanicDescriptor,EWservPanicDescriptor,EWservPanicDescriptor, + EWservPanicNoPointerBuffer,EWservPanicBackupDisplayMode, + EWservPanicNoFont}; // Dummy end value to catch out overflowing the array + INFO_PRINTF1(_L("AUTO Test Invalid Functions ")); + INFO_PRINTF1(_L(" Opcode Panics")); + + for (TInt source=0;source<3;source++) + for (TInt target=0;target<3;target++) + if (source!=target) + for (TInt panic=0;;panic++) + { + TBool testFinished=EFalse; + TEST(iTest->TestWsPanicL(DoPanicTest,EWservPanicOpcode,source*10000+target*100+panic,(TAny*)iTest->iScreenNumber,&testFinished)); + if (testFinished) + break; + } + _LIT(KSet,"Various Different Panics"); + INFO_PRINTF1(KSet); + RDebug::Print(KPlatsecBegin); + for(TInt index=0;;index++) + { + TBool testFinished=EFalse; + TEST(iTest->TestWsPanicL(DoPanicTest2,PanicCode[index],index,(TAny*)iTest->iScreenNumber,&testFinished)); + if (testFinished) + break; + } + RDebug::Print(KPlatsecEnd); + iTest->CloseAllPanicWindows(); + } + +void CTWindowTest::ShadowAutoClearTest() + { + RWindowGroup group(TheClient->iWs); + group.Construct(1111); + group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close + + RWindow background(TheClient->iWs); + background.Construct(group,133); + background.SetBackgroundColor(); + background.Activate(); + + background.BeginRedraw(); + TheClient->iGc->Activate(background); + TheClient->iGc->SetBrushColor(TRgb::Gray4(1)); + TheClient->iGc->Clear(); + background.EndRedraw(); +// + RBlankWindow tab2(TheClient->iWs); + tab2.Construct(group,144); + tab2.SetExtent(TPoint(10,00),TSize(200,10)); + tab2.SetColor(TRgb::Gray256(170)); + tab2.SetShadowHeight(1); + tab2.Activate(); + RBlankWindow tab1(TheClient->iWs); + tab1.Construct(group,155); + tab1.SetExtent(TPoint(70,00),TSize(10,10)); + tab1.SetColor(TRgb::Gray256(170)); + tab1.SetShadowHeight(1); + tab1.Activate(); + RBlankWindow blank(TheClient->iWs); + blank.Construct(group,156); + blank.SetExtent(TPoint(50,10),TSize(100,100)); + blank.SetColor(TRgb::Gray256(170)); + blank.SetShadowHeight(0); + blank.Activate(); +// + tab1.Close(); + tab1.Construct(group,166); + tab1.SetExtent(TPoint(50,00),TSize(10,10)); + tab1.SetColor(TRgb::Gray256(170)); + tab1.SetShadowHeight(1); + tab1.Activate(); + blank.Close(); + RBlankWindow blank2(TheClient->iWs); + blank2.Construct(group,177); + blank2.SetColor(TRgb::Gray256(255)); + blank2.SetExtent(TPoint(10,10),TSize(100,120)); + blank2.SetShadowHeight(2); + blank2.Activate(); + TheClient->iWs.Flush(); +// + background.BeginRedraw(); + TheClient->iGc->SetBrushColor(TRgb::Gray4(1)); + TheClient->iGc->Clear(); + background.EndRedraw(); +// + tab1.Close(); + tab2.Close(); + blank2.Close(); + background.BeginRedraw(); + TheClient->iGc->Clear(); + TheClient->iGc->Deactivate(); + background.EndRedraw(); + TheClient->iWs.Finish(); + TSize size=TheClient->iScreen->SizeInPixels(); + TBool rectCompare = TheClient->iScreen->RectCompare(TRect(0,0,size.iWidth>>1,size.iHeight),TRect(size.iWidth>>1,0,(size.iWidth>>1)<<1,size.iHeight)); + TEST(rectCompare); + if(!rectCompare) + INFO_PRINTF3(_L("TheClient->iScreen->RectCompare return value - Expected: %d, Actual: %d"), ETrue, rectCompare); + background.Close(); + group.Close(); + } + +void CTWindowTest::ClearRedraw(RWindow &aWindow, TRgb aRgb) + { + aWindow.BeginRedraw(); + TheClient->iGc->Activate(aWindow); + TheClient->iGc->SetBrushColor(aRgb); + TheClient->iGc->Clear(); + TheClient->iGc->Deactivate(); + aWindow.EndRedraw(); + } + +void CTWindowTest::CheckCorner(TCorner aCorner, const TInt *aInsetList) + { + TRect rect(TPoint(1,1),iBlankWin2->Size()); + TPoint pos; + TInt direction; + if (aCorner==ECornerTL || aCorner==ECornerTR) + { + pos.iY=rect.iTl.iY; + direction=1; + } + else + { + pos.iY=rect.iBr.iY-1; + direction= -1; + } + if (aCorner==ECornerTL || aCorner==ECornerBL) + pos.iX=rect.iTl.iX; + else + pos.iX=rect.iBr.iX-8; + TRgb rgbBuf[8]; + TPtr8 desc((TUint8 *)rgbBuf,sizeof(rgbBuf)); + for(TInt count=0;countGetScanLine(desc,pos,8,EColor16MA); + if (aCorner==ECornerTR || aCorner==ECornerBR) + { + for(TInt loop=0;loop<4;loop++) + { + TRgb tmp=rgbBuf[loop]; + rgbBuf[loop]=rgbBuf[8-1-loop]; + rgbBuf[8-1-loop]=tmp; + } + } + // We can't compare rgb value from original source against screen value in EColor64K mode as + // the color component might be truncated (EColor64K is 16-bit using format RGB565), + // ie R or B components might be reduced from 8-bit to 5-bit and G from 8-bit to 6-bit + // + // For example: RGB value of Gray4(1) is 0x555555, it is drawn to screen in RGB565 as 0x52AA, + // when it's converted back to RGB for comparison, the value becomes 0x525552 + TRgb col1=TRgb::Gray4(1); + TRgb col2=TRgb::Gray4(3); + if (iScreenDev->DisplayMode()==EColor64K) + { + col1=TRgb::Color64K(col1.Color64K()); + col2=TRgb::Color64K(col2.Color64K()); + } + TInt loop2=0; + for(;loop2BaseWin()->SetCornerType(aCornerType,aFlags); + if (!(aFlags&EWindowCornerNotTL)) + CheckCorner(ECornerTL, corners); + if (!(aFlags&EWindowCornerNotTR)) + CheckCorner(ECornerTR, corners); + if (!(aFlags&EWindowCornerNotBL)) + CheckCorner(ECornerBL, corners); + if (!(aFlags&EWindowCornerNotBR)) + CheckCorner(ECornerBR, corners); +// + if (aFlags&EWindowCornerNotTL) + CheckCorner(ECornerTL, corner0); + if (aFlags&EWindowCornerNotTR) + CheckCorner(ECornerTR, corner0); + if (aFlags&EWindowCornerNotBL) + CheckCorner(ECornerBL, corner0); + if (aFlags&EWindowCornerNotBR) + CheckCorner(ECornerBR, corner0); + } + +void CTWindowTest::doCornerTestsL() + { + iScreenDev=new(ELeave) CWsScreenDevice(TheClient->iWs); + User::LeaveIfError(iScreenDev->Construct(iTest->iScreenNumber)); + iBlankWin1=new(ELeave) CTBlankWindow(); + iBlankWin1->SetUpL(TPoint(1,1),TSize(100,50),TheClient->iGroup,*TheClient->iGc); + iBlankWin1->SetColor(TRgb::Gray4(1)); + iBlankWin2=new(ELeave) CTBlankWindow(); + iBlankWin2->SetUpL(TPoint(1,1),iBlankWin1->Size(),TheClient->iGroup,*TheClient->iGc); + iBlankWin2->SetColor(TRgb::Gray4(3)); + iBlankWin2->BaseWin()->SetShadowHeight(0); + doCornerTest(EWindowCornerSquare,0); + doCornerTest(EWindowCornerSquare,EWindowCornerNotBL); + doCornerTest(EWindowCorner1,0); // 0 + all corners missing + doCornerTest(EWindowCorner1,EWindowCornerNotTL|EWindowCornerNotTR|EWindowCornerNotBL|EWindowCornerNotBR); + doCornerTest(EWindowCorner2,0); // 0 + all sets of 3 corners missing + doCornerTest(EWindowCorner2,EWindowCornerNotTR|EWindowCornerNotBL|EWindowCornerNotBR); + doCornerTest(EWindowCorner2,EWindowCornerNotTL|EWindowCornerNotBL|EWindowCornerNotBR); + doCornerTest(EWindowCorner2,EWindowCornerNotTL|EWindowCornerNotTR|EWindowCornerNotBR); + doCornerTest(EWindowCorner2,EWindowCornerNotTL|EWindowCornerNotTR|EWindowCornerNotBL); + doCornerTest(EWindowCorner3,0); // 0 + all 4 individual corners missing + doCornerTest(EWindowCorner3,EWindowCornerNotTL); + doCornerTest(EWindowCorner3,EWindowCornerNotTR); + doCornerTest(EWindowCorner3,EWindowCornerNotBL); + doCornerTest(EWindowCorner3,EWindowCornerNotBR); + doCornerTest(EWindowCorner5,0); // 0 + all pairs of corners missing + doCornerTest(EWindowCorner5,EWindowCornerNotTL|EWindowCornerNotTR); + doCornerTest(EWindowCorner5,EWindowCornerNotTL|EWindowCornerNotBL); + doCornerTest(EWindowCorner5,EWindowCornerNotTL|EWindowCornerNotBR); + doCornerTest(EWindowCorner5,EWindowCornerNotTR|EWindowCornerNotBL); + doCornerTest(EWindowCorner5,EWindowCornerNotTR|EWindowCornerNotBR); + doCornerTest(EWindowCorner5,EWindowCornerNotBL|EWindowCornerNotBR); + } + +void CTWindowTest::CornerTests() + { + TRAP_IGNORE(doCornerTestsL()); + delete iBlankWin2; + delete iBlankWin1; + delete iScreenDev; + } + +LOCAL_C void doMegaTreeThread(TInt aScreenNumber) + { + CTrapCleanup::New(); + RWsSession ws; + ws.Connect(); + CWsScreenDevice *scrDev=new(ELeave) CWsScreenDevice(ws); + scrDev->Construct(aScreenNumber); + RWindowGroup group(ws); + group.Construct(1); + group.EnableReceiptOfFocus(EFalse); + RWindow parent(ws); + parent.Construct(group,123); + parent.Activate(); + CWindowGc *gc=new(ELeave) CWindowGc(scrDev); + gc->Construct(); + TSize max(parent.Size()); + RWindow prev=parent; + TBool horiz=EFalse; + TInt color=0; + for(TInt count=0;count<100;count++) + { + RWindow win(ws); + if (win.Construct(prev,ENullWsHandle)!=KErrNone) + break; + win.SetExtent(horiz?TPoint(1,0):TPoint(0,1),max); + win.SetBackgroundColor(TRgb::Gray4(color)); + color=(color+1)%4; + win.Activate(); + win.BeginRedraw(); + gc->Activate(win); + gc->Clear(); + gc->Deactivate(); + win.EndRedraw(); + prev=win; + horiz=!horiz; + } + parent.SetVisible(EFalse); + parent.SetVisible(ETrue); + parent.SetPosition(TPoint(-1,-1)); + parent.SetPosition(TPoint(0,0)); + parent.Close(); + ws.Close(); + } + +LOCAL_C TInt MegaTreeThread(TAny *aScreenNumber) + { + TRAPD(err,doMegaTreeThread((TInt)aScreenNumber)); + return(err); + } + +void CTWindowTest::CreateMegaTree() + { + const TUint KThreadHeapSize=0x2000; + RThread thread; + if (thread.Create(_L("MegaTree"),MegaTreeThread,KDefaultStackSize,KThreadHeapSize,KThreadHeapSize,(TAny*)iTest->iScreenNumber,EOwnerThread)==KErrNone) + { + TRequestStatus stat; + thread.Logon(stat); + thread.Resume(); + User::WaitForRequest(stat); + TEST(stat==KErrNone); + } + thread.Close(); + } + +void CTWindowTest::TiledWindowTestL() + { + RWindow parent(TheClient->iWs); + User::LeaveIfError(parent.Construct(*TheClient->iGroup->GroupWin(),ENullWsHandle)); + CleanupStack::PushL(TCleanupItem(CleanUpWindow,&parent)); + parent.SetExtent(TPoint(10,10),TSize(50,50)); + parent.Activate(); +// + RWindow child1(TheClient->iWs); + User::LeaveIfError(child1.Construct(parent,ENullWsHandle)); + CleanupStack::PushL(TCleanupItem(CleanUpWindow,&child1)); + child1.SetExtent(TPoint(0,0),TSize(50,20)); + child1.Activate(); +// + RWindow child2(TheClient->iWs); + User::LeaveIfError(child2.Construct(parent,ENullWsHandle)); + CleanupStack::PushL(TCleanupItem(CleanUpWindow,&child2)); + child2.SetExtent(TPoint(0,20),TSize(50,30)); + child2.Activate(); +// + child1.BeginRedraw(); + TSize rect1Size(25,20); + TheGc->Activate(child1); + TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + TheGc->DrawRect(TRect(rect1Size)); + TheGc->DrawRect(TRect(TPoint(rect1Size.iWidth,0),rect1Size)); + TheGc->Deactivate(); + child1.EndRedraw(); +// + child2.BeginRedraw(); + TSize rect2Size(25,30); + TheGc->Activate(child2); + TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + TheGc->DrawRect(TRect(rect2Size)); + TheGc->DrawRect(TRect(TPoint(rect2Size.iWidth,0),rect2Size)); + TheGc->Deactivate(); + child2.EndRedraw(); +// +// Left and right halves should be identical +// + TBool rectCompare = !TheClient->iScreen->RectCompare(TRect(10,10,35,60),TRect(35,10,70,60)); + TEST(rectCompare); + if(!rectCompare) + INFO_PRINTF3(_L("TheClient->iScreen->RectCompare return value - Expected: %d, Actual: %d"), ETrue, rectCompare); +// + CleanupStack::PopAndDestroy(3); + } + +void CTWindowTest::TiledWindowTest2L() + { + TSize size(200,240); //Parent Windows + TSize childSize(TSize(size.iWidth/2,size.iHeight/2)); //Child Windows + TSize dialogueSize(50,50); + + TheClient->iWs.SetAutoFlush(ETrue); + RBlankWindow parent1(TheClient->iWs); + User::LeaveIfError(parent1.Construct(*TheClient->iGroup->GroupWin(),ENullWsHandle)); + CleanupStack::PushL(TCleanupItem(CleanUpWindow,&parent1)); + parent1.SetExtent(TPoint(240,0),size); + parent1.SetColor(TRgb::Gray4(2)); + parent1.Activate(); + + TheClient->iWs.SetAutoFlush(ETrue); + RBlankWindow parent2(TheClient->iWs); + User::LeaveIfError(parent2.Construct(*TheClient->iGroup->GroupWin(),ENullWsHandle)); + CleanupStack::PushL(TCleanupItem(CleanUpWindow,&parent2)); + parent2.SetExtent(TPoint(440,0),size); + parent2.SetColor(TRgb::Gray4(2)); + parent2.Activate(); + + TheClient->iWs.SetAutoFlush(ETrue); + RBlankWindow child1(TheClient->iWs); + User::LeaveIfError(child1.Construct(parent1,ENullWsHandle)); + CleanupStack::PushL(TCleanupItem(CleanUpWindow,&child1)); + child1.SetExtent(TPoint(0,0),childSize); + child1.SetColor(TRgb::Gray4(2)); + child1.Activate(); + + TheClient->iWs.SetAutoFlush(ETrue); + RBlankWindow child2(TheClient->iWs); + User::LeaveIfError(child2.Construct(parent1,ENullWsHandle)); + CleanupStack::PushL(TCleanupItem(CleanUpWindow,&child2)); + child2.SetExtent(TPoint(0,childSize.iHeight),childSize); + child2.SetColor(TRgb::Gray4(2)); + child2.Activate(); + + TheClient->iWs.SetAutoFlush(ETrue); + RBlankWindow child3(TheClient->iWs); + User::LeaveIfError(child3.Construct(parent1,ENullWsHandle)); + CleanupStack::PushL(TCleanupItem(CleanUpWindow,&child3)); + child3.SetExtent(TPoint(childSize.iWidth,0),TSize(childSize.iWidth,size.iHeight)); + child3.SetColor(TRgb::Gray4(2)); + child3.Activate(); + + TPoint dialoguePos(375,93); + TheClient->iWs.SetAutoFlush(ETrue); + RBlankWindow dialog1(TheClient->iWs); + User::LeaveIfError(dialog1.Construct(*TheClient->iGroup->GroupWin(),ENullWsHandle)); + CleanupStack::PushL(TCleanupItem(CleanUpWindow,&dialog1)); + dialog1.SetExtent(dialoguePos,dialogueSize); + dialog1.SetColor(TRgb::Gray4(3)); + dialog1.SetShadowHeight(4); + dialog1.Activate(); + + TheClient->iWs.SetAutoFlush(ETrue); + RBlankWindow dialog2(TheClient->iWs); + User::LeaveIfError(dialog2.Construct(*TheClient->iGroup->GroupWin(),ENullWsHandle)); + CleanupStack::PushL(TCleanupItem(CleanUpWindow,&dialog2)); + dialog2.SetExtent(TPoint(dialoguePos.iX+size.iWidth,dialoguePos.iY),dialogueSize); + dialog2.SetColor(TRgb::Gray4(3)); + dialog2.SetShadowHeight(0); + dialog2.Activate(); + + TInt ii; + for (ii=400;ii>374;ii-=25) + dialog1.SetPosition(TPoint(ii,93)); + TheClient->iWs.SetAutoFlush(EFalse); + CleanupStack::PopAndDestroy(7); + } + +void CTWindowTest::ColorTestL() + { + if (iTest->MaxGrays() == 0) + return; + + _LIT(KSet,"AUTO Color Test "); + INFO_PRINTF1(KSet); + RWindow window(TheClient->iWs); + User::LeaveIfError(window.Construct(*TheClient->iGroup->GroupWin(),ENullWsHandle)); + PushWindowL(&window); + window.SetExtent(TPoint(10,10),TSize(50,50)); + window.Activate(); + TInt colorMode,mode; + TInt currentMode=TheClient->iScreen->DisplayMode(); + TEST(currentMode==EGray4 || currentMode==EColor16 || currentMode==EColor256 || currentMode == EColor64K); + if(currentMode!=EGray4 && currentMode!=EColor16 && currentMode!=EColor256 && currentMode != EColor64K) + INFO_PRINTF5(_L("TheClient->iScreen->DisplayMode() return value - Expected: %d or %d or %d, Actual: %d"), EGray4, EColor16, EColor256, currentMode); + INFO_PRINTF1(_L(" Done Setup")); + for(colorMode=EGray4;colorMode log; + log.Format(KModes,colorMode,mode,currentMode); + INFO_PRINTF1(log); + } + if (mode>ERgb && colorMode==EColor64K) + break; + TEST(mode==currentMode || mode==colorMode ); + if (mode!=currentMode && mode!=colorMode) + INFO_PRINTF4(_L("window.DisplayMode() return value - Expected: %d or %d, Actual: %d"), currentMode, colorMode, mode); + INFO_PRINTF1(_L(" Loop 2")); + if (mode>currentMode) + currentMode=mode; + if (colorMode==EColor16) + window.SetSize(TSize(40,60)); + else if (colorMode==EColor4K) + window.SetSize(TSize(60,40)); + mode=TheClient->iScreen->DisplayMode(); + if(TDisplayModeUtils::NumDisplayModeColors(STATIC_CAST(TDisplayMode,currentMode))==16777216) + { + TEST(mode==CFbsDevice::DisplayMode16M()); + if (mode!=CFbsDevice::DisplayMode16M()) + INFO_PRINTF3(_L("window.DisplayMode() return value - Expected: %d, Actual: %d"), CFbsDevice::DisplayMode16M(), mode); + } + else + { + TEST(currentMode==mode || currentMode==colorMode); + if (currentMode!=mode && currentMode!=colorMode) + INFO_PRINTF3(_L("TheClient->iScreen->DisplayMode() return value return value - Expected: %d , Actual: %d"), currentMode, mode); + } + } + INFO_PRINTF1(_L(" Done First Loop")); + TInt color,gray; + TDisplayMode defMode=TheClient->iWs.GetDefModeMaxNumColors(color,gray); + TInt screenNo =TheClient->iScreen->GetScreenNumber(); + TDisplayMode defModeForScreen=TheClient->iWs.GetDefModeMaxNumColors(screenNo,color,gray); + TEST(defMode==defModeForScreen); + if (defMode!=defModeForScreen) + INFO_PRINTF3(_L("TheClient->iScreen->DisplayMode() return value return value - Expected: %d , Actual: %d"), defMode, defModeForScreen); + if (color==16777216 && gray==256) + { + TEST(defMode==EGray4 || defMode==EColor256 || defMode==EColor64K); //WINS + if (defMode!=EGray4 && defMode!=EColor256 && defMode != EColor64K) + INFO_PRINTF4(_L("TheClient->iWs.GetDefModeMaxNumColors(color,gray) return value return value - Expected: %d or %d, Actual: %d"), EGray4, EColor256, defMode); + } + else + { + if (color==0 && gray==16) + { + TEST(defMode==EGray4); //S5 family + if (defMode!=EGray4) + INFO_PRINTF3(_L("TheClient->iScreen->DisplayMode() return value return value - Expected: %d , Actual: %d"), EGray4, defMode); + } + else + { + TLogMessageText buf; + _LIT(KColorSettings,"##Data Most Colors=%d, Most Greys=%d, DefMode=%d"); + buf.Format(KColorSettings,color,gray,defMode); + TheClient->iWs.LogMessage(buf); + TheClient->iWs.Flush(); + TEST(defMode==EGray4 || defMode==EColor256); + if (defMode!=EGray4 && defMode!=EColor256) + INFO_PRINTF4(_L("TheClient->iWs.GetDefModeMaxNumColors(color,gray) return value return value - Expected: %d or %d, Actual: %d"), EGray4, EColor256, defMode); + } + } + CArrayFixFlat *colorModes=new(ELeave) CArrayFixFlat(1); + CleanupStack::PushL(colorModes); + User::LeaveIfError(TheClient->iWs.GetColorModeList(screenNo,colorModes)); + TDisplayMode mostColor=ENone; + TDisplayMode lastGray=ENone; + TDisplayMode dispMode; + TInt ii; + TInt colorModes16M = 0; + INFO_PRINTF1(_L(" Done Setup 2")); + for (ii=0;iiCount();ii++) + { + dispMode=(TDisplayMode)(*colorModes)[ii]; + TEST(dispMode!=ERgb); + if (dispMode==ERgb) + INFO_PRINTF3(_L("(TDisplayMode)(*colorModes)[i] return value - Not Expected: %d , Actual: %d"), ERgb, dispMode); + TEST(dispMode!=ENone); + if (dispMode==ENone) + INFO_PRINTF3(_L("(TDisplayMode)(*colorModes)[i] return value - Not Expected: %d , Actual: %d"), ENone, dispMode); + if (dispMode<=EGray256) + lastGray=dispMode; + else + mostColor=dispMode; + if(dispMode == EColor16M || dispMode == EColor16MU || dispMode == EColor16MA) + colorModes16M++; + } + TEST(mostColor!=ERgb); + if (mostColor==ERgb) + INFO_PRINTF3(_L("mostColor - Not Expected: %d , Actual: %d"), ERgb, mostColor); + TEST(colorModes16M <= 1); + if (colorModes16M > 1) + INFO_PRINTF3(_L("Number of times color Modes 16M - less than or equal to: %d , Actual: %d"), 1, colorModes16M); +#if defined(__WINS__) + TEST(colorModes16M == 1); + if (colorModes16M != 1) + INFO_PRINTF3(_L("Number of times color Modes 16M on wins - equal to: %d , Actual: %d"), 1, colorModes16M); +#endif + TInt retVal; + if (color==0) + { + TEST(mostColor==ENone); + if (mostColor!=ENone) + INFO_PRINTF3(_L("Most color - equal to: %d , Actual: %d"), ENone ,mostColor); + } + else + { + retVal = TDisplayModeUtils::NumDisplayModeColors(mostColor); + TEST(color==retVal); + if (color!=retVal) + INFO_PRINTF3(_L("TDisplayModeUtils::NumDisplayModeColors(mostColor) return value - equal to: %d , Actual: %d"), TDisplayModeUtils::NumDisplayModeColors(mostColor), retVal); + } + if (gray==0) + { + TEST(lastGray==ENone); + if (lastGray!=ENone) + INFO_PRINTF3(_L("LastGray - equal to: %d , Actual: %d"), ENone, lastGray); + } + else + { + retVal = TDisplayModeUtils::NumDisplayModeColors(lastGray); + TEST(gray==retVal); + if(gray!=retVal) + INFO_PRINTF3(_L("Gray - equal to: %d , Actual: %d"), retVal, gray); + } + retVal = TDisplayModeUtils::NumDisplayModeColors(ENone); + TEST(retVal==0); + if (retVal!=0) + INFO_PRINTF3(_L("TDisplayModeUtils::NumDisplayModeColors(ENone) return value - equal to: %d , Actual: %d"), 0, retVal); + CleanupStack::PopAndDestroy(2); //window and mode-array + } + +void CTWindowTest::TestInvalidFunctions2L() +// +// This code casts windows to group windows and vice-versa and then sends messages for the 'cast' that +// should not be sent to the original type of window. These should all result in panics +// + { + for (TInt winType=1;winType<7;++winType) //Skip type 0 (RWindowTreeNode) + for (TInt panic=0;;panic++) + { + TBool testFinished=EFalse; + TEST(iTest->TestWsPanicL(DoPanicTest3,EWservPanicOpcode,EWinTypeFactor*winType+panic,(TAny*)iTest->iScreenNumber,&testFinished)); + if (testFinished) + break; + } + iTest->CloseAllPanicWindows(); + } + +void CTWindowTest::TestDeletedParentPanics1L() + { + for (TInt winType=0;winType<7;++winType) + { + if (winType==1) //Skip type 1 (RWindowGroup) + ++winType; + for (TInt panic=0;;panic++) + { + TBool testFinished=EFalse; + TEST(iTest->TestWsPanicL(DoPanicTest4,EWservPanicParentDeleted,EWinTypeFactor*winType+panic,(TAny*)iTest->iScreenNumber,&testFinished)); + if (testFinished) + break; + } + } + iTest->CloseAllPanicWindows(); + } + +void CTWindowTest::TestDeletedParentPanics2L() + { + for (TInt panic=0;;panic++) + { + TBool testFinished=EFalse; + TEST(iTest->TestWsPanicL(DoPanicTest5,EWservPanicParentDeleted,panic,(TAny*)iTest->iScreenNumber,&testFinished)); + if (testFinished) + break; + } + iTest->CloseAllPanicWindows(); + } + +void CTWindowTest::Bug1L() +// +// Test a defect found with WSERV 099 that caused a full Eikon ROM to crash before even the splach screen appeared +// + { + RWsSession ws; + User::LeaveIfError(ws.Connect()); + // use correct screen + CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws); + CleanupStack::PushL(screen); + User::LeaveIfError(screen->Construct(iTest->iScreenNumber)); + + RWindowGroup group(ws); + group.Construct(344); + group.EnableReceiptOfFocus(EFalse); //Not done by Eikon, but needed to stop shell window comming to front. + RBlankWindow blank(ws); + blank.Construct(group,345); + blank.SetOrdinalPosition(0,1000); + blank.Activate(); + RWindow window(ws); + window.Construct(group,346); + + //Must delete this window to tidy up + window.Close(); + blank.Close(); + group.Close(); + + CleanupStack::PopAndDestroy(screen); + ws.Close(); + } + +void CTWindowTest::TestWindowDelete() + { + TInt handles = 344; + TInt err = KErrNone; + TInt loop = 0; + TInt allocFailRate = 0; + + RWindowGroup group(TheClient->iWs); + RWindow parent1(TheClient->iWs); + RWindow child1(TheClient->iWs); + RWindow testWindow(TheClient->iWs); + + while (loop < 5) + { + err = group.Construct(++handles, EFalse); + if (err == KErrNone) + { + TheClient->iWs.HeapSetFail(RHeap::EDeterministic, allocFailRate); + + //Create parent 1 + err = parent1.Construct(group,++handles); + if (err == KErrNone) + { + parent1.SetExtent(TPoint(10,10),TSize(50,50)); + parent1.Activate(); + } + } + //Create child 1 + if (err == KErrNone) + { + err = child1.Construct(parent1,++handles); + if (err == KErrNone) + { + child1.SetExtent(TPoint(),TSize(50,20)); + child1.Activate(); + } + //Only delete the parent 1, but not the child 1 + parent1.Close(); + } + + if (err == KErrNone) + { + //Create testWindow + err = testWindow.Construct(group,++handles); + if (err == KErrNone) + { + testWindow.SetExtent(TPoint(0,20),TSize(50,30)); + testWindow.Activate(); + } + } + TheClient->iWs.HeapSetFail(RAllocator::ENone, 0); + + child1.Close(); + testWindow.Close(); + group.Close(); + ++allocFailRate; + loop = (err == KErrNone) ? loop + 1 : 0; + } + } +void CTWindowTest::Bug2L() +// +// Test a defect ... +// + { + TSize offset(20,20); + TRect screen(TheClient->iScreen->SizeInPixels()-offset); + TRgb color; + RWsSession ws1; + User::LeaveIfError(ws1.Connect()); + ws1.SetAutoFlush(ETrue); + + // use correct screen + // + CWsScreenDevice* scr1 = new (ELeave) CWsScreenDevice(ws1); + CleanupStack::PushL(scr1); + User::LeaveIfError(scr1->Construct(iTest->iScreenNumber)); + + RWsSession ws2; + User::LeaveIfError(ws2.Connect()); + ws2.SetAutoFlush(ETrue); + + // use correct screen + // + CWsScreenDevice* scr2 = new (ELeave) CWsScreenDevice(ws2); + CleanupStack::PushL(scr2); + User::LeaveIfError(scr2->Construct(iTest->iScreenNumber)); + + RWindowGroup group1a(ws1); + group1a.Construct(344); + group1a.EnableReceiptOfFocus(EFalse); + group1a.SetOrdinalPosition(0,5); + RBlankWindow blank1a(ws1); + blank1a.Construct(group1a,345); + color=TRgb::Gray4(0); + blank1a.SetColor(color); + blank1a.SetExtent(screen.iTl,screen.Size()); + blank1a.EnableBackup(); + blank1a.Activate(); + + RWindowGroup group2(ws2); + group2.Construct(342); + group2.EnableReceiptOfFocus(EFalse); + group2.SetOrdinalPosition(0,5); + RBlankWindow blank2(ws2); + blank2.Construct(group2,347); + color=TRgb::Gray4(1); + blank2.SetColor(color); + blank2.SetExtent(screen.iTl+TSize(20,0),screen.Size()); + blank2.EnableBackup(); + blank2.Activate(); + + RWindowGroup group1b(ws1); + group1b.Construct(343); + //group1b.EnableReceiptOfFocus(EFalse); + group1b.SetOrdinalPosition(0,5); + RBlankWindow blank1b(ws1); + blank1b.Construct(group1b,346); + color=TRgb::Gray4(2); + blank1b.SetColor(color); + blank1b.SetExtent(screen.iTl+offset,screen.Size()); + blank1b.EnableBackup(); + blank1b.Activate(); + + group1b.Close(); + blank1a.Close(); + blank1b.Close(); + blank2.Close(); + group1a.Close(); + group2.Close(); + + CleanupStack::PopAndDestroy(2,scr1); + ws1.Close(); + ws2.Close(); + } + +void CTWindowTest::Bug3L() +// +// Actiate then make visible and backup behind window caused panic. +// + { + TSize offset(20,20); + TRect screen(TheClient->iScreen->SizeInPixels()-offset); + TRgb color; + RWsSession ws; + User::LeaveIfError(ws.Connect()); + ws.SetAutoFlush(ETrue); + + // use correct screen + // + CWsScreenDevice* scr = new (ELeave) CWsScreenDevice(ws); + CleanupStack::PushL(scr); + User::LeaveIfError(scr->Construct(iTest->iScreenNumber)); + + RWindowGroup group(ws); + group.Construct(348); + group.EnableReceiptOfFocus(EFalse); + RBlankWindow blank1(ws); + blank1.Construct(group,341); + color=TRgb::Gray4(1); + blank1.SetColor(color); + blank1.SetExtent(screen.iTl,screen.Size()); + blank1.EnableBackup(); + blank1.SetVisible(EFalse); + blank1.Activate(); + blank1.SetVisible(ETrue); + RBlankWindow blank2(ws); + blank2.Construct(group,342); + color=TRgb::Gray4(2); + blank2.SetColor(color); + blank2.SetExtent(screen.iTl,screen.Size()); + blank2.EnableBackup(); + blank2.SetVisible(EFalse); + blank2.SetVisible(ETrue); + blank2.Activate(); + group.Close(); + blank1.Close(); + blank2.Close(); + + CleanupStack::PopAndDestroy(scr); + ws.Close(); + } + +void CTWindowTest::ErrorCodesL() + { + RWsSession ws; + User::LeaveIfError(ws.Connect()); + // use correct screen + // + CWsScreenDevice* scr = new (ELeave) CWsScreenDevice(ws); + CleanupStack::PushL(scr); + User::LeaveIfError(scr->Construct(iTest->iScreenNumber)); + + + RWindowGroup group(ws); + group.Construct(349); + group.EnableReceiptOfFocus(EFalse); + RWindow window(TheClient->iWs); + User::LeaveIfError(window.Construct(*TheClient->iGroup->GroupWin(),ENullWsHandle)); + TInt retVal = window.MoveToGroup(22222); + TEST(retVal==KErrNotFound); + if (retVal!=KErrNotFound) + INFO_PRINTF3(_L("window.MoveToGroup(22222) return value - equal to: %d , Actual: %d"), KErrNotFound, retVal); + retVal = window.MoveToGroup(group.Identifier()); + TEST(retVal==KErrNotFound); + if (retVal!=KErrNotFound) + INFO_PRINTF3(_L("window.MoveToGroup(group.Identifier()) return value - equal to: %d , Actual: %d"), KErrNotFound, retVal); + window.Close(); + group.Close(); + + CleanupStack::PopAndDestroy(scr); + ws.Close(); + } + +void CTWindowTest::BackColorBugL() +// +// Test a defect with window being drawn with the wrong background color when they are moved on the screen +// + { + TSize scrSize(TheClient->iScreen->SizeInPixels()); + TSize checkSize(12,10); //X-Size needs to be multiple of 4 due to BITGDI change/defect + CBlankWindow* win; + win=new(ELeave) CBlankWindow(TRgb(16,16,240)); + CleanupStack::PushL(win); + win->SetUpL(TPoint(5,5),scrSize-TSize(10,10),TheClient->iGroup,*TheClient->iGc); + TInt mode=win->BaseWin()->SetRequiredDisplayMode(EColor256); + const TDisplayMode actualMode=reinterpret_cast(mode); + if (!TDisplayModeUtils::IsDisplayModeColor(actualMode) || TDisplayModeUtils::NumDisplayModeColors(actualMode)<256) + { + CleanupStack::PopAndDestroy(win); + return; + } + win->RealDraw(ETrue); + win->Win()->SetBackgroundColor(TRgb(64,224,64)); + CBlankWindow* win3; + win3=new(ELeave) CBlankWindow(TRgb::Gray16(8)); + CleanupStack::PushL(win3); + win3->SetUpL(TPoint(12,12),checkSize,TheClient->iGroup,*TheClient->iGc); + win3->BaseWin()->SetRequiredDisplayMode(EColor256); + CBlankWindow* win2; + win2=new(ELeave) CBlankWindow(TRgb(240,16,16)); + CleanupStack::PushL(win2); + win2->SetUpL(TPoint(10,scrSize.iHeight/2),TSize(scrSize.iWidth/3,scrSize.iHeight/2-10),TheClient->iGroup,*TheClient->iGc); + win2->BaseWin()->SetRequiredDisplayMode(EColor256); + win2->RealDraw(EFalse); + + win2->Win()->SetBackgroundColor(TRgb::Gray16(8)); + win2->SetExt(TPoint(scrSize.iWidth/4,30),TSize(scrSize.iWidth/2,2*scrSize.iHeight/3)); + TheClient->iWs.Finish(); + TheClient->WaitForRedrawsToFinish(); + if (!CheckRect(win2,win3,TRect(checkSize))) + { + _LIT(KLog,"After window is moved and resizes it doesn't matches the other window"); + LOG_MESSAGE(KLog); + //Code to save a screen shot useful if this test fails + /*_LIT(KTest,"E:\\logs\\testexecute\\Window%d"); + TBuf<64> buf; + buf.Format(KTest,iTest->iState); + TInt err=iTest->SaveScreen(buf); + _LIT(KLogSave,"Saved screenshot to file %S, (err=%d)"); + LOG_MESSAGE3(KLogSave,&buf,err);*/ + } + TheClient->WaitForRedrawsToFinish(); + CleanupStack::PopAndDestroy(3,win); + } + +void CTWindowTest::FocusChangedL() +// +// Test that the focus change is available when the redraw is +// it should be available before, but it isn't always possible to test that +// + { + _LIT(KThreadName,"MoveGroup"); + _LIT(KEventWaiting,"Event Waiting when none expected."); + TInt command; + iThreadParam.iScreenNumber=iTest->iScreenNumber; + iFirstFunction=TThreadStartUp(CTWindowTest::MoveGroup,&iThreadParam); + TRequestStatus status; + TSize scrSize(TheClient->iScreen->SizeInPixels()); + CTWindowGroup* group1=new(ELeave) CTWindowGroup(TheClient); + group1->ConstructL(); + CleanupStack::PushL(group1); + TInt winId1=group1->GroupWin()->Identifier(); + CBlankWindow* win1=new(ELeave) CBlankWindow(TRgb::Gray4(1)); + CleanupStack::PushL(win1); + win1->SetUpL(TPoint(1,1),TSize(2*scrSize.iWidth/3,2*scrSize.iHeight/3),group1,*TheClient->iGc); + win1->RealDraw(ETrue); + win1->Win()->SetBackgroundColor(TRgb::Gray4(3)); + CTWindowGroup* group2=new(ELeave) CTWindowGroup(TheClient); + group2->ConstructL(); + CleanupStack::PushL(group2); + TInt winId2=group2->GroupWin()->Identifier(); + CBlankWindow* win2=new(ELeave) CBlankWindow(TRgb::Gray4(2)); + CleanupStack::PushL(win2); + win2->SetUpL(TPoint(scrSize.iWidth/3-5,scrSize.iHeight/3-5),TSize(2*scrSize.iWidth/3,2*scrSize.iHeight/3),group2,*TheClient->iGc); + win2->RealDraw(ETrue); + win2->Win()->SetBackgroundColor(TRgb::Gray4(0)); + + TheClient->WaitForRedrawsToFinish(); + TheClient->WaitForAllEventProcessingToFinish(); + command=winId1; + iThreadParam.iCommand=command; + TBool noEventWaiting=!TheClient->IsEventWaiting(); + TEST(noEventWaiting); + if (!noEventWaiting) + LOG_MESSAGE(KEventWaiting); + _LIT(KTest1,"FocusChangedL: 1st test completed"); + LOG_MESSAGE(KTest1); + CProcess* iMoveGroup=CProcess::NewSimpleThreadL(KThreadName,&iFirstFunction,&status); + User::WaitForRequest(status); + delete iMoveGroup; + TEST(TheClient->WaitForEvent()); + TheClient->WaitForAllEventProcessingToFinish(); + + command=winId2; + iThreadParam.iCommand=command; + TheClient->WaitForRedrawsToFinish(); + noEventWaiting=!TheClient->IsEventWaiting(); + TEST(noEventWaiting); + if (!noEventWaiting) + LOG_MESSAGE(KEventWaiting); + _LIT(KTest2,"FocusChangedL: 2nd test completed"); + LOG_MESSAGE(KTest2); + iMoveGroup=CProcess::NewSimpleThreadL(KThreadName,&iFirstFunction,&status); + User::WaitForRequest(status); + delete iMoveGroup; + TEST(TheClient->WaitForEvent()); + TheClient->WaitForAllEventProcessingToFinish(); + + command=winId2|(1<WaitForRedrawsToFinish(); + noEventWaiting=!TheClient->IsEventWaiting(); + TEST(noEventWaiting); + if (!noEventWaiting) + LOG_MESSAGE(KEventWaiting); + _LIT(KTest3,"FocusChangedL: 3rd test completed"); + LOG_MESSAGE(KTest3); + iMoveGroup=CProcess::NewSimpleThreadL(KThreadName,&iFirstFunction,&status); + User::WaitForRequest(status); + delete iMoveGroup; + TEST(TheClient->WaitForEvent()); + TheClient->WaitForAllEventProcessingToFinish(); + + command=winId1|(1<WaitForRedrawsToFinish(); + noEventWaiting=!TheClient->IsEventWaiting(); + TEST(noEventWaiting); + if (!noEventWaiting) + LOG_MESSAGE(KEventWaiting); + _LIT(KTest4,"FocusChangedL: 4th test completed"); + LOG_MESSAGE(KTest4); + iMoveGroup=CProcess::NewSimpleThreadL(KThreadName,&iFirstFunction,&status); + User::WaitForRequest(status); + delete iMoveGroup; + TEST(TheClient->WaitForEvent()); + TheClient->WaitForAllEventProcessingToFinish(); + + TheClient->WaitForRedrawsToFinish(); + noEventWaiting=!TheClient->IsEventWaiting(); + TEST(noEventWaiting); + if (!noEventWaiting) + LOG_MESSAGE(KEventWaiting); + _LIT(KTest5,"FocusChangedL: 5th and last test completed"); + LOG_MESSAGE(KTest5); + CleanupStack::PopAndDestroy(2,group2); + TheClient->Flush(); + TEST(TheClient->WaitForEvent()); + TheClient->WaitForAllEventProcessingToFinish(); + CleanupStack::PopAndDestroy(2,group1); + } + +#define ALT_PRI 78 +void CTWindowTest::EventsToAllL() + { + CTClient* client1=new(ELeave) CTClient; + CleanupStack::PushL(client1); + client1->SetScreenNumber(iTest->iScreenNumber); + client1->ConstructL(); + CTClient* client2=new(ELeave) CTClient; + CleanupStack::PushL(client2); + client2->SetScreenNumber(iTest->iScreenNumber); + client2->ConstructL(); + CEvWindowGroup* group1a=CEvWindowGroup::NewLC(client1,this); + CEvWindowGroup* group1b=CEvWindowGroup::NewLC(client1,this); + CEvWindowGroup* group2a=CEvWindowGroup::NewLC(client2,this); + CEvWindowGroup* group2b=CEvWindowGroup::NewLC(client2,this); + /*_LIT(KLog,"Window Group Id's: %d,%d,%d,%d"); + LOG_MESSAGE5(KLog,group1a->GroupWin()->Identifier(),group1b->GroupWin()->Identifier(),group2a->GroupWin()->Identifier(),group2b->GroupWin()->Identifier());*/ + group1a->SendEvent(KBaseUserEvent+1); + group2b->SendEvent(KBaseUserEvent+2); + client1->WaitForAllEventProcessingToFinish(); + client2->WaitForAllEventProcessingToFinish(); + TWsEvent event; + // Assigned random value because before PREQ1226, TWsevent's data wasn't zero initialised. + // In techview, following function + // void CEikServAppUi::HandleSystemEventL(const TWsEvent& aEvent) + // was relaying on TWsevent's data not be zero + *(event.Int()) = 0XCCCCCCCC; + event.SetType(KBaseUserEvent+3); + group1a->SetExpectedEvent(KBaseUserEvent+3); + group1b->SetExpectedEvent(KBaseUserEvent+3); + group2a->SetExpectedEvent(KBaseUserEvent+3); + group2b->SetExpectedEvent(KBaseUserEvent+3); + TheClient->iWs.SendEventToAllWindowGroups(event); + client1->WaitForAllEventProcessingToFinish(); + client2->WaitForAllEventProcessingToFinish(); + event.SetType(KBaseUserEvent+4); + group1a->SetExpectedEvent(KBaseUserEvent+4); + group1b->SetExpectedEvent(KBaseUserEvent+4); + group2a->SetExpectedEvent(KBaseUserEvent+4); + group2b->SetExpectedEvent(KBaseUserEvent+4); + TheClient->iWs.SendEventToAllWindowGroups(event); + client1->WaitForAllEventProcessingToFinish(); + client2->WaitForAllEventProcessingToFinish(); + event.SetType(KBaseUserEvent+5); + //group1a->SetExpectedEvent(KBaseUserEvent+5); + group1b->SetExpectedEvent(KBaseUserEvent+5); + //group2a->SetExpectedEvent(KBaseUserEvent+5); + group2b->SetExpectedEvent(KBaseUserEvent+5); + TheClient->iWs.SendEventToOneWindowGroupsPerClient(event); + client1->WaitForAllEventProcessingToFinish(); + client2->WaitForAllEventProcessingToFinish(); + group1a->WinTreeNode()->SetOrdinalPosition(0); + client1->Flush(); + event.SetType(KBaseUserEvent+6); + group1a->SetExpectedEvent(KBaseUserEvent+6); + group2b->SetExpectedEvent(KBaseUserEvent+6); + TheClient->iWs.SendEventToOneWindowGroupsPerClient(event); + client1->WaitForAllEventProcessingToFinish(); + client2->WaitForAllEventProcessingToFinish(); + group2b->WinTreeNode()->SetOrdinalPosition(6); + client2->Flush(); + event.SetType(KBaseUserEvent+7); + group1a->SetExpectedEvent(KBaseUserEvent+7); + group2a->SetExpectedEvent(KBaseUserEvent+7); + TheClient->iWs.SendEventToOneWindowGroupsPerClient(event); + client1->WaitForAllEventProcessingToFinish(); + client2->WaitForAllEventProcessingToFinish(); + event.SetType(KBaseUserEvent+8); + group1a->SetExpectedEvent(KBaseUserEvent+8); + group1b->SetExpectedEvent(KBaseUserEvent+8); + group2a->SetExpectedEvent(KBaseUserEvent+8); + group2b->SetExpectedEvent(KBaseUserEvent+8); + TheClient->iWs.SendEventToAllWindowGroups(0,event); + group1a->WinTreeNode()->SetOrdinalPosition(0,ALT_PRI); + client1->Flush(); + client1->WaitForAllEventProcessingToFinish(); + client2->WaitForAllEventProcessingToFinish(); + event.SetType(KBaseUserEvent+9); + group1a->SetExpectedEvent(KBaseUserEvent+9); + TheClient->iWs.SendEventToAllWindowGroups(ALT_PRI,event); + client1->WaitForAllEventProcessingToFinish(); + client2->WaitForAllEventProcessingToFinish(); + group2b->WinTreeNode()->SetOrdinalPosition(0,ALT_PRI); + client2->Flush(); + client1->WaitForAllEventProcessingToFinish(); + client2->WaitForAllEventProcessingToFinish(); + event.SetType(KBaseUserEvent+10); + group1a->SetExpectedEvent(KBaseUserEvent+10); + group2b->SetExpectedEvent(KBaseUserEvent+10); + TheClient->iWs.SendEventToAllWindowGroups(ALT_PRI,event); + client1->WaitForAllEventProcessingToFinish(); + client2->WaitForAllEventProcessingToFinish(); + event.SetType(KBaseUserEvent+11); + group1b->SetExpectedEvent(KBaseUserEvent+11); + group2a->SetExpectedEvent(KBaseUserEvent+11); + TheClient->iWs.SendEventToAllWindowGroups(0,event); + client1->WaitForAllEventProcessingToFinish(); + client2->WaitForAllEventProcessingToFinish(); + event.SetType(KBaseUserEvent); + group1a->SetExpectedEvent(KBaseUserEvent); + group1b->SetExpectedEvent(KBaseUserEvent); + group2a->SetExpectedEvent(KBaseUserEvent); + group2b->SetExpectedEvent(KBaseUserEvent); + TheClient->iWs.SendEventToAllWindowGroups(event); + client1->WaitForAllEventProcessingToFinish(); + client2->WaitForAllEventProcessingToFinish(); + CleanupStack::PopAndDestroy(6,client1); + } + +void DestroyWindow(TAny* aWindow) + { + static_cast(aWindow)->Destroy(); + } + +void CTWindowTest::GroupIdL() + { + const TInt numWindows=10; + RWindowGroup group(TheClient->iWs); + CleanupClosePushL(group); + User::LeaveIfError(group.Construct(ENullWsHandle)); + TInt id=group.Identifier(); + RWindowTreeNode* prevWindow=&group; + TInt ii; + for (ii=0;iiiWs); + CleanupStack::PushL(TCleanupItem(&DestroyWindow,window)); + User::LeaveIfError(window->Construct(*prevWindow,ENullWsHandle)); + TInt retVal = window->WindowGroupId(); + TEST(retVal==id); + if (retVal!=id) + INFO_PRINTF3(_L("window->WindowGroupId() return value - equal to: %d , Actual: %d"), id, retVal); + prevWindow=window; + } + CleanupStack::PopAndDestroy(numWindows+1); + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-0495 + +@SYMDEF PDEF131541 + +@SYMTestCaseDesc Sending Events using one of the functions SendEventToWindowGroup, SendEventToAllWindowGroups (x2) + and SendEventToOneWindowGroupsPerClient when an event queue is full returns an error + +@SYMTestPriority Low + +@SYMTestStatus Implemented + +@SYMTestActions Call the functions repeatly many times and check that an error gets returned eventually + +@SYMTestExpectedResults Functions return the error KErrNoMemory +*/ +const TInt numTest=75; //Must be at least 33 +void CTWindowTest::SaturateSendEvent() + { + const TInt id=TheClient->iGroup->GroupWin()->Identifier(); + TWsEvent event; + event.SetType(KBaseUserEvent); + TInt ii; + + TInt err=KErrNone; + for (ii=0; ii<=numTest && err==KErrNone;) + { + ++ii; + err=TheClient->iWs.SendEventToWindowGroup(id,event); + } + TEST(err==KErrNoMemory); + if (err!=KErrNoMemory) + { + _LIT(KLog,"After %d/%d iterations SendEventToWindowGroup returned the error %d"); + LOG_MESSAGE4(KLog,ii,numTest,err); + } + TheClient->WaitForAllEventProcessingToFinish(); + + err=KErrNone; + for (ii=0; ii<=numTest && err==KErrNone;) + { + ++ii; + err=TheClient->iWs.SendEventToAllWindowGroups(event); + } + TEST(err==KErrNoMemory); + if (err!=KErrNoMemory) + { + _LIT(KLog,"After %d/%d iterations SendEventToAllWindowGroups returned the error %d"); + LOG_MESSAGE4(KLog,ii,numTest,err); + } + TheClient->WaitForAllEventProcessingToFinish(); + User::After(1000000); //1sec, give other sessions a chance to respond to the events + + err=KErrNone; + for (ii=0; ii<=numTest && err==KErrNone;) + { + ++ii; + err=TheClient->iWs.SendEventToAllWindowGroups(0,event); + } + TEST(err==KErrNoMemory); + if (err!=KErrNoMemory) + { + _LIT(KLog,"After %d/%d iterations SendEventToAllWindowGroups_Priority0 returned the error %d"); + LOG_MESSAGE4(KLog,ii,numTest,err); + } + TheClient->WaitForAllEventProcessingToFinish(); + User::After(1000000); //1sec, give other sessions a chance to respond to the events + + err=KErrNone; + for (ii=0; ii<=numTest && err==KErrNone;) + { + ++ii; + err=TheClient->iWs.SendEventToOneWindowGroupsPerClient(event); + } + TEST(err==KErrNoMemory); + if (err!=KErrNoMemory) + { + _LIT(KLog,"After %d/%d iterations SendEventToOneWindowGroupsPerClient returned the error %d"); + LOG_MESSAGE4(KLog,ii,numTest,err); + } + TheClient->WaitForAllEventProcessingToFinish(); + User::After(1000000); //1sec, give other sessions a chance to respond to the events + } + +void CTWindowTest::TestNotSupportedFunctionality() + { + TInt err = KErrNone; + TSize windowSize = TSize(10,10); + TSize testSize = TSize(); + + RWindowGroup group(TheClient->iWs); + RWindow window(TheClient->iWs); + + err = group.Construct((TUint32)&group, EFalse); + TEST(err==KErrNone); + err = window.Construct(group,(TUint32)&window); + TEST(err==KErrNone); + + window.SetExtent(TPoint(0,0),windowSize); + window.Activate(); + + testSize = window.Size(); + TEST((testSize.iWidth==windowSize.iWidth) && (testSize.iHeight==windowSize.iHeight)); + + testSize = window.SizeForEgl(); + TEST((testSize.iWidth==windowSize.iWidth) && (testSize.iHeight==windowSize.iHeight)); + + err = window.FixNativeOrientation(); + TEST(err==KErrNotSupported); + + testSize = window.Size(); + TEST((testSize.iWidth==windowSize.iWidth) && (testSize.iHeight==windowSize.iHeight)); + + testSize = window.SizeForEgl(); + TEST((testSize.iWidth==windowSize.iWidth) && (testSize.iHeight==windowSize.iHeight)); + + window.Close(); + group.Close(); + } + +void CTWindowTest::RunTestCaseL(TInt /*aCurTestCase*/) + { + _LIT(KTest1,"Window"); + _LIT(KTest2,"DestroyWindowWithActiveGc"); + _LIT(KTest3,"Shadow/NoAutoClear"); + _LIT(KTest4,"Corner Tests"); + _LIT(KTest5,"Invalid Window Functions"); + _LIT(KTest7,"Mega-Tree"); + _LIT(KTest8,"Tiled Window One"); + _LIT(KTest9,"Tiled Window Two"); + _LIT(KTest10,"Color Test"); + _LIT(KTest11,"Invalid Window Functions2"); + _LIT(KTest12,"Defect 1"); + _LIT(KTest13,"Defect 2"); + _LIT(KTest14,"Parent Deleted 1"); + _LIT(KTest15,"Parent Deleted 2"); + _LIT(KTest16,"Defect 3"); + _LIT(KTest17,"Background Color"); + _LIT(KTest18,"Focus Changed"); + _LIT(KTest21,"Events To All"); + _LIT(KTest22,"Error Codes"); + _LIT(KTest23,"Group Id"); + _LIT(KTest24,"DeleteParentWindowOnly"); +#if defined(_DEBUG) + _LIT(KTest25,"DuplicateWindowHandles"); +#else + _LIT(KTest25skipped,"DuplicateWindowHandles skipped"); +#endif + + ((CTWindowTestStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + + _LIT(KTest26,"Saturate SendEvent"); + _LIT(KTest27,"Not Supported Functionality"); + + switch(++iTest->iState) + { +/** +@SYMTestCaseID GRAPHICS-WSERV-0029 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test window can be created and destroyed correctly + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Creates and destroys a window + +@SYMTestExpectedResults Window is created and destroyed without error +*/ + case 1: + ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0029")); + iTest->LogSubTest(KTest1); + CreateTestWindowL(); + CheckAndDestroyWindows(); + //iState=17; + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0030 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Creates and destroys window with an active gc + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Create and destroy a window with an active gc + +@SYMTestExpectedResults Window is created and destroyed without error +*/ + case 2: + ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0030")); + iTest->LogSubTest(KTest2); + CreateTestWindowL(); + DestroyWindowWithActiveGc(); + CreateTestWindowL(); + DestroyWindowWithActiveGc2L(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0031 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test that shadow is not automatically cleared when + drawing a window + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Draw windows and check that the shadow is not automatically + cleared + +@SYMTestExpectedResults Screen comparison returns that the shadow was not cleared +*/ + case 3: + ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0031")); + //window shadowing is no longer supported. keep the test to make sure clients can still call the methods + iTest->LogSubTest(KTest3); + ShadowAutoClearTest(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0032 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test the drawing of different types of corner of + a window + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Draw a window with different types of corner + +@SYMTestExpectedResults The window is drawn correctly for each corner type +*/ + case 4: + ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0032")); + iTest->LogSubTest(KTest4); + CornerTests(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0033 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test for panics when window is sent wrong requests + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Send wrong requests to windows and deal with panic + +@SYMTestExpectedResults The windows panic as expected +*/ + case 5: + ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0033")); + iTest->LogSubTest(KTest5); + TestInvalidFunctionsL(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0035 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Draw 100 windows from a thread + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Draw 100 windows from the same thread + +@SYMTestExpectedResults The windows are all drawn without error +*/ + case 6: + ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0035")); + iTest->LogSubTest(KTest7); + CreateMegaTree(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0036 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Check that windows can be drawn in a tiled format + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Draw two windows in a tiled format and check they + are identical + +@SYMTestExpectedResults The tiled windows are identical +*/ + case 7: + ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0036")); + + iTest->LogSubTest(KTest8); + TiledWindowTestL(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0037 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Check that windows and dialogs can be drawn in a + tiled format + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Draw windows and dialogs in a tiled format + +@SYMTestExpectedResults The windows and dialogs are drawn correctly +*/ + case 8: + ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0037")); + iTest->LogSubTest(KTest9); + TiledWindowTest2L(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0038 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Check drawing into a window with different + colour set ups + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Draw in a window using different colour + configurations + +@SYMTestExpectedResults The different colours are drawn correctly +*/ + case 9: + ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0038")); + iTest->LogSubTest(KTest10); + ColorTestL(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0039 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test for panics when window is sent wrong requests + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Send wrong requests to windows and deal with panic + +@SYMTestExpectedResults The windows panic as expected +*/ + case 10: + ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0039")); + iTest->LogSubTest(KTest11); + TestInvalidFunctions2L(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0040 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test for a defect that causes ROM to crash + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Test a defect is not present which causes the ROM + to crash + +@SYMTestExpectedResults The defect is not present +*/ + case 11: + ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0040")); + iTest->LogSubTest(KTest12); + Bug1L(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0041 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test a previous defect has not returned + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Exercise the code the defect was discovered in + +@SYMTestExpectedResults The defect is not present +*/ + case 12: + ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0041")); + iTest->LogSubTest(KTest13); + Bug2L(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0042 + +@SYMDEF DEF081259 + DEF115543 + +@SYMTestCaseDesc Test that when a parent window is deleted a panic + occurs + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Delete a parent window and check for a panic + NOTE: DEF115543 has corrected GRAPHICS-WSERV-0042, and added a lot + more window functions. + +@SYMTestExpectedResults All functions either: + Panic the owner thread with EWservPanicParentDeleted or + Get performed without accessing any NULL iParent pointers in the WSERV thread +*/ + case 13: + ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0042")); + iTest->LogSubTest(KTest14); + TestDeletedParentPanics1L(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0043 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test that when a parent window is deleted a panic + occurs + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Delete a parent window and check for a panic + +@SYMTestExpectedResults The panic occurs as expected +*/ + case 14: + ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0043")); + iTest->LogSubTest(KTest15); + TestDeletedParentPanics2L(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0044 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Check that activate then make visible and backup + behind a window does not panic. + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Activate then make visible and backup + behind a window + +@SYMTestExpectedResults No panic occurs +*/ + case 15: + ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0044")); + iTest->LogSubTest(KTest16); + Bug3L(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0045 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test window being drawn with the correct background + color when they are moved on the screen + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Move window on the screen and check it is drawn with + the correct background colour + +@SYMTestExpectedResults The background coloour is correct +*/ + case 16: + ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0045")); + iTest->LogSubTest(KTest17); + BackColorBugL(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0046 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test that the focus change is available after redraw + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Redraw and check the focus change is available + +@SYMTestExpectedResults The focus change is available +*/ + case 17: + ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0046")); + iTest->LogSubTest(KTest18); + FocusChangedL(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0048 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test that events can be sent to a number of window + groups simultaneously + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Send events to a number of window groups and check + that they all receive them + +@SYMTestExpectedResults The events and sent to the window groups correctly +*/ + case 18: + ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0048")); + iTest->LogSubTest(KTest21); + EventsToAllL(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0049 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Test error code when incorrectly moving a window to + a group. + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Try to move a window to a group and check the error + codes + +@SYMTestExpectedResults The correct error codes are returned +*/ + case 19: + ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0049")); + iTest->LogSubTest(KTest22); + ErrorCodesL(); +/** +@SYMTestCaseID GRAPHICS-WSERV-0050 + +@SYMDEF DEF081259 + +@SYMTestCaseDesc Check that the correct group id is assigned to a + chain of windows + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Create a chain of windows in the same group and check + the all have the same group id + +@SYMTestExpectedResults The windows all have the same group id +*/ + case 20: + ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0050")); + iTest->LogSubTest(KTest23); + GroupIdL(); + break; + +/** +@SYMTestCaseID GRAPHICS-WSERV-0461 + +@SYMDEF PDEF114190 + +@SYMTestCaseDesc Test window redraw queue cleanup when window is deleted in low memory conditions + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Have a loop which increases the number of allocations in the server thread before failure; + Within the loop: + 1) Create a parent window and a child window of the parent; + 2) Delete the parent window only, but not the child window; + 3) Create a testWindow. This new window gets added to the redraw queue which will force it + reordering. This would crash WSERV due to this defect because the orphaned window (which is + the previous child window) is still in the redraw queue + 4) Delete all the windows involved; + +@SYMTestExpectedResults The window redraw queue should be cleaned up when the first window is deleted; + WSERV should not crash. The test should pass. +*/ + case 21: + ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0461")); + iTest->LogSubTest(KTest24); + TestWindowDelete(); + break; + +/** +@SYMTestCaseID GRAPHICS-WSERV-0463 + +@SYMDEF DEF115601 + +@SYMTestCaseDesc Two RWindowGroup objects using same window client handle cause Emulator crash + +@SYMTestPriority Medium + +@SYMTestStatus Implemented + +@SYMTestActions Create two window groups with the same handle. + +@SYMTestExpectedResults WSERV should panic the client thread with the code EWservPanicDuplicateHandle + and then destroy the window groups without crashing WSERV +*/ + case 22: +#if defined(_DEBUG) + ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0463")); + iTest->LogSubTest(KTest25); + TEST(iTest->TestWsPanicL(DoPanicTest6,EWservPanicDuplicateHandle,0,(TAny*)iTest->iScreenNumber,NULL)); + iTest->CloseAllPanicWindows(); +#else + iTest->LogSubTest(KTest25skipped); //Client side panic will only occur in debug builds of WServ +#endif + break; + case 23: + ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0495")); + iTest->LogSubTest(KTest26); + SaturateSendEvent(); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0655 + +@SYMDEF ou1cimx1#329309 + +@SYMTestCaseDesc Fix native orientation functionality not supported + +@SYMTestPriority Medium + +@SYMTestStatus Implemented + +@SYMTestActions Call fucntions related to fix native orientation on a window + +@SYMTestExpectedResults Fix native orientation functionality not supported + */ + case 24: + ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0655")); + iTest->LogSubTest(KTest27); + TestNotSupportedFunctionality(); + break; + default: + ((CTWindowTestStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + ((CTWindowTestStep*)iStep)->CloseTMSGraphicsStep(); + TestComplete(); + break; + } + ((CTWindowTestStep*)iStep)->RecordTestResultL(); + } + +__WS_CONSTRUCT_STEP__(WindowTest) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TWINDOW.H --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TWINDOW.H Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,149 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef __TWINDOW_H__ +#define __TWINDOW_H__ + +#include +#include +#include "AUTO.H" + +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA +#include "../nonnga/CLIENT/w32comm.h" +#endif + +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA +#include "../nga/CLIENT/w32comm.h" +#endif + +#include "../tlib/testbase.h" +#include "TGraphicsHarness.h" + +struct TWindowThreadParam + { + TInt iCommand; + TInt iScreenNumber; + }; + +class CWinTestWindow : public CBlankWindow + { +public: + CWinTestWindow(TRgb aCol); + ~CWinTestWindow(); + void ConstructL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc, TInt aDepth); +public: + CWinTestWindow *iChild; + }; + +class CEvWindowGroup : public CTWindowGroup + { +public: + static CEvWindowGroup* NewLC(CTClient* aClient,CTWsGraphicsBase* aTest); + CEvWindowGroup(CTClient* aClient,CTWsGraphicsBase* aTest); + void SetExpectedEvent(TInt aType); + void SendEvent(TInt aType); + //Virtual functions from CTWindowGroup + void ConstructL(); + void UserEvent(TInt aEventType); +private: + CTWsGraphicsBase* iTest; + TInt iExpectedEvent; + TBool iExpectingEvent; + }; + +class CTWindowTest : public CTWsGraphicsBase + { +public: + enum {EWinTypeFactor=1000}; + enum + { + EIdMask=0x0000FFFF, + EPosMask=0xFFFF0000, + EPosShift=16 + }; +private: + enum TCorner {ECornerTL,ECornerTR,ECornerBL,ECornerBR}; +public: + CTWindowTest(CTestStep* aStep); + ~CTWindowTest(); + TestState DoTestL(); + void ConstructL(); + void CreateTestWindowL(); + void CheckAndDestroyWindows(); + void DestroyWindowWithActiveGc(); + void DestroyWindowWithActiveGc2L(); + void DrawWindows(CWinTestWindow *aWin); + void ClearRedraw(RWindow &aWindow, TRgb aRgb); + void TestInvalidFunctionsL(); + void ShadowAutoClearTest(); + void CreateMegaTree(); + void TiledWindowTestL(); + void TiledWindowTest2L(); + void CornerTests(); + void ColorTestL(); + void TestInvalidFunctions2L(); + void Bug1L(); + void Bug2L(); + void Bug3L(); + void TestDeletedParentPanics1L(); + void TestDeletedParentPanics2L(); + void BackColorBugL(); + void FocusChangedL(); + void FadeRegionsL(); + void FadeRegionsWithRedrawStoringL(); + void EventsToAllL(); + void ErrorCodesL(); + void GroupIdL(); + void doCornerTestsL(); + void doCornerTest(TCornerType aCornerType, TInt aFlags); + void CheckCorner(TCorner aCorner, const TInt *aInsetList); + void ShadowTestL(); + void TestWindowDelete(); + void SaturateSendEvent(); + void TestNotSupportedFunctionality(); +protected: +//from CTGraphicsStep + virtual void RunTestCaseL(TInt aCurTestCase); +private: + static TInt MoveGroup(TAny* aParam); + void DoFadeRegionsL(TBool aRedrawStoring); +private: + CWinTestWindow *iWin; + CTBlankWindow *iBlankWin1; + CTBlankWindow *iBlankWin2; + CWsScreenDevice *iScreenDev; + TThreadStartUp iFirstFunction; + TWindowThreadParam iThreadParam; + }; + +class CTWindowTestStep : public CTGraphicsStep + { +public: + CTWindowTestStep(); +protected: + //from CTGraphicsStep + virtual CTGraphicsBase* CreateTestL(); + }; + +_LIT(KTWindowTestStep,"TWindowTest"); + + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TWSGRAPHS.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TWSGRAPHS.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,2593 @@ +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// This test step contains a series of tests cases to validate the correct behaviour of PREQ1246 implementation. +// In order to create these test cases, basic implementations of the objects involved in this PREQ will be created, +// .i.e. CWsGraphic-derived objects (generically named CWsGraphicTest) and CWsGraphicDrawer-derived objects +// (generically named CWsGraphicDrawerTest). +// Actual construction is performed by a UI-specific entity such as a theme manager. The test code shall replace +// that theme manager functionality, in terms of being the test code who owns a collection of CWsGraphicTest +// objects. +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include "TWSGRAPHS.H" +#include "../inc/WSGRAPHICDRAWERARRAY.H" +#include "../../nga/graphicdrawer/panics.h" +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA +#include "wsbufferdrawer.h" +#endif + +_LIT(KTestExe, "TWSGRAPHICTEST.exe"); +_LIT(KSpace, " "); + +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA +const TInt KCustomTextCursorId = TTextCursor::ETypeLastBasic + 57; // 57 is arbitrary +#endif + +CCrWin* CCrWin::NewL(TInt aScreenId, TBool aDraw) + { + CCrWin* win = new(ELeave) CCrWin; + CleanupStack::PushL(win); + win->ConstructL(aScreenId, aDraw); + CleanupStack::Pop(win); + return win; + } + +CCrWin::~CCrWin() + { + iWin.Close(); + iGroup.Close(); + delete iGc; + delete iScr; + iWs.Close(); + } + +void CCrWin::ConstructL(TInt aScreenId, TBool aDraw) + { + User::LeaveIfError(iWs.Connect()); + iScr = new(ELeave) CWsScreenDevice(iWs); + User::LeaveIfError(iScr->Construct(aScreenId)); + User::LeaveIfError(iScr->CreateContext(iGc)); + iGroup = RWindowGroup(iWs); + User::LeaveIfError(iGroup.Construct(0xbadbabe,ETrue)); + iGroup.SetOrdinalPosition(0,100); + iWin = RWindow(iWs); + User::LeaveIfError(iWin.Construct(iGroup,0xbadcafe)); + iWin.SetRequiredDisplayMode(EColor64K); + iWin.Activate(); + iWs.Flush(); + if (aDraw) + Draw(); + } + +void CCrWin::Draw() + { + iWin.BeginRedraw(); + iGc->Activate(iWin); + iGc->SetBrushColor(KRgbRed); + iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + TRect rect(iScr->SizeInPixels()); + iGc->DrawRect(rect); + iGc->SetBrushColor(KRgbBlue); + iGc->DrawEllipse(TRect(rect.iTl.iX,rect.iTl.iY,rect.iBr.iX/2,rect.iBr.iY)); + iGc->DrawEllipse(TRect(rect.iBr.iX/2,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY)); + iGc->Deactivate(); + iWin.EndRedraw(); + iWs.Flush(); + } + + +void CCrWin::DrawFirstHalf() + { + iWin.BeginRedraw(); + iGc->Activate(iWin); + iGc->SetBrushColor(KRgbRed); + iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + TRect rect(TPoint(0,0),TSize(iScr->SizeInPixels().iWidth/2,iScr->SizeInPixels().iHeight)); + iGc->DrawRect(rect); + iWs.Flush(); + } + +void CCrWin::DrawSecondHalf() + { + TRect rect(TPoint(iScr->SizeInPixels().iWidth/2,0),TSize(iScr->SizeInPixels().iWidth/2,iScr->SizeInPixels().iHeight)); + iGc->DrawRect(rect); + iGc->Deactivate(); + iWin.EndRedraw(); + iWs.Flush(); + } + +/** +The objective of this function is, two animations should run independently +with respective frame rate in the given time interval. +The time delay allows to draw animations freely and the plug-in +calculates number of times DoDraw() function called during this interval. + +@param TInt Wsgrphic test plug-in id. +*/ +void CCrWin::DrawGraphic(TInt aWsId) + { + // draw the animation in two positions + const TSize screenSize = iScr->SizeInPixels(); + const TRect position(0,0,screenSize.iWidth/2,screenSize.iHeight); + const TRect position2((screenSize.iWidth/2)+1,0,screenSize.iWidth,screenSize.iHeight); + //PeterI if CWsGraphic animation areas overlap then when one redraws the other will as well. + //2 separate positions are needed otherwise the framerates will be identical. + + iWin.BeginRedraw(); + iGc->Activate(iWin); + const TUint8 animid1=0; + const TUint8 fps1=20; + TBuf8<2> animData1; + animData1.Append(animid1); //animId1 + animData1.Append(fps1); //20fps + iGc->DrawWsGraphic(aWsId,position,animData1); + iWs.Flush(); + User::After(200000); + const TUint8 animid2=1; + const TUint8 fps2=60; + TBuf8<2> animData2; + animData2.Append(animid2); //animId2 + animData2.Append(fps2); //60fps + iGc->DrawWsGraphic(aWsId,position2,animData2); + iWs.Flush(); + User::After(200000); + iGc->Deactivate(); + iWin.EndRedraw(); + iWs.Flush(); + } + +/** + * Set a standard text cursor on this window. + * @see RWindowGroup::SetTextCursor() + */ +void CCrWin::SetTextCursor(const TPoint &aPos, const TTextCursor &aCursor) + { + iGroup.SetTextCursor(iWin, aPos, aCursor); + } + +/** + * Cancel a text cursor from this window. + * @see RWindowGroup::CancelTextCursor() + */ +void CCrWin::CancelTextCursor() + { + iGroup.CancelTextCursor(); + } + +CCrAlphaWin* CCrAlphaWin::NewL(TInt aScreenId) + { + CCrAlphaWin* win = new(ELeave) CCrAlphaWin; + CleanupStack::PushL(win); + win->ConstructL(aScreenId); + CleanupStack::Pop(win); + return win; + } + +CCrAlphaWin::~CCrAlphaWin() + { + iWin.Close(); + iGroup.Close(); + delete iScr; + iWs.Close(); + } + +void CCrAlphaWin::ConstructL(TInt aScreenId) + { + User::LeaveIfError(iWs.Connect()); + iScr = new(ELeave) CWsScreenDevice(iWs); + User::LeaveIfError(iScr->Construct(aScreenId)); + iGroup = RWindowGroup(iWs); + User::LeaveIfError(iGroup.Construct(0xbadc0de,ETrue)); + iGroup.SetOrdinalPosition(0,100); + iWin = RWindow(iWs); + User::LeaveIfError(iWin.Construct(iGroup,0xbadbeef)); + iWin.SetRequiredDisplayMode(EColor64K); + iWin.SetTransparencyAlphaChannel(); + iWin.SetBackgroundColor(TRgb(0xff,0xff,0,0x80)); + iWin.Activate(); + iWs.Flush(); + } + + +// +// CTWsGraphs +// + +CTWsGraphs::CTWsGraphs(CTestStep* aStep): + CTWsGraphicsBase(aStep) + { + } + +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA +LOCAL_D void DeleteSpriteMember(TAny* aSpriteMember) + { + TSpriteMember* member=reinterpret_cast(aSpriteMember); + delete member->iBitmap; + member->iBitmap=NULL; + delete member->iMaskBitmap; + member->iMaskBitmap=NULL; + } +#endif + +CTWsGraphs::~CTWsGraphs() + { +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + DeleteSpriteMember(&iSpriteMemberArray[0]); + iSpriteMemberArray.Close(); +#endif + delete iGdCoverage; +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + delete iAfter; + delete iBefore; + delete iBackCopy; + delete iFrontCopy; +#endif + delete iListen; + delete iNotify2; + delete iNotify1; +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + delete iRedir; +#endif + } + +void CTWsGraphs::ConstructL() + { +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + iRedir = CWsRedir::NewL(iTest->iScreenNumber,ETrue); + iRedir->SetCallBack(TCallBack(CTWsGraphs::PluginCallBack,this)); +#endif + iNotify1 = CWsNotify::NewL(EFalse); + iNotify2 = CWsNotify::NewL(ETrue); + iListen = CWsListen::NewL(ETrue); + iListen->SetCallBack(TCallBack(CTWsGraphs::PluginCallBack,this)); +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + iFrontCopy = new(ELeave) CFbsBitmap; + iBackCopy = new(ELeave) CFbsBitmap; + iBefore = new(ELeave) CFbsBitmap; + User::LeaveIfError(iBefore->Create(TheClient->iScreen->SizeInPixels(), EColor64K)); + iAfter = new(ELeave) CFbsBitmap; + User::LeaveIfError(iAfter->Create(TheClient->iScreen->SizeInPixels(), EColor64K)); +#endif + iGdCoverage = CWsGdCoverage::NewL(); + iGdCoverage->SetCallBack(TCallBack(CTWsGraphs::PluginCallBack,this)); +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + TSpriteMember spriteMember; + spriteMember.iBitmap = NULL; + spriteMember.iMaskBitmap = NULL; + spriteMember.iInvertMask =EFalse; + spriteMember.iDrawMode = CGraphicsContext::EDrawModePEN; + spriteMember.iOffset = TPoint(); + spriteMember.iInterval = TTimeIntervalMicroSeconds32(0); + CleanupStack::PushL(TCleanupItem(DeleteSpriteMember, &spriteMember)); + spriteMember.iBitmap = new (ELeave) CFbsBitmap; + User::LeaveIfError(spriteMember.iBitmap->Load(TEST_BITMAP_NAME, EMbmWsautotestBmp1)); + spriteMember.iMaskBitmap = new (ELeave) CFbsBitmap; + User::LeaveIfError(spriteMember.iMaskBitmap->Load(TEST_BITMAP_NAME, EMbmWsautotestBmp1mask)); + User::LeaveIfError(iSpriteMemberArray.Append(spriteMember)); + CleanupStack::Pop(&spriteMember); +#endif + } + +void CTWsGraphs::LaunchNewProcess(const TDesC& aExecutable) + { + TBuf<128> args; + args.Append(KSpace); + args.AppendNum(iTest->iScreenNumber); + RProcess pr; + TInt err = pr.Create(aExecutable,args); + if (err == KErrNone) + { + TRequestStatus status; + pr.Logon(status); + pr.Resume(); + User::WaitForRequest(status); + err = pr.ExitReason(); + pr.Close(); + if (err != KErrNone) + { + _LIT(KLog,"%S returned error: %d. Check RDebug output."); + LOG_MESSAGE3(KLog, &aExecutable, err); + } + } + else + { + _LIT(KLog,"Can't create the process (%S), err=%d"); + LOG_MESSAGE3(KLog, &aExecutable, err); + } + TEST(err == KErrNone); + // Restore main test group to foreground. + TheClient->iGroup->GroupWin()->SetOrdinalPosition(0); + } + +TInt CTWsGraphs::PluginCallBack(TAny* /*aArg*/) + { + return (TInt)EWait; + } + +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + +/** + @SYMTestCaseID GRAPHICS-WSERV-0371 + @SYMREQ GT247-CR0714 + @SYMTestCaseDesc Test interface extension + @SYMTestPriority High + @SYMTestStatus Implemented + @SYMTestActions Retrieves object interfaces from Content Rendering Plugin (plugin). + Actions step: + -Create plugin + -Query interfaces obtained from plugin side + @SYMTestExpectedResults Supported interfaces should return non null +*/ +TestState CTWsGraphs::TestInterfaceExtensionL() + { + if (iSubState==0) + { + _LIT(KTestInterfaceExtension, "TestInterfaceExtension"); + INFO_PRINTF1(KTestInterfaceExtension); + + ++iSubState; + Mem::FillZ(&iRedirInfo, sizeof(TRedirectorInfo)); + iRedir->QueryPlugin(iRedirInfo); + return EWait; + } + TEST(iRedirInfo.iScreenConfigInterface!=NULL); + TEST(iRedirInfo.iFrontBufferInterface!=NULL); + TEST(iRedirInfo.iScreenBitmapHandle!=0); + iFrontCopy->Duplicate(iRedirInfo.iScreenBitmapHandle); + + if (TransparencySupportedL()!=KErrNotSupported) + { + TEST(iRedirInfo.iBackBufferInterface!=NULL); + TEST(iRedirInfo.iFlickerBitmapHandle!=0); + iBackCopy->Duplicate(iRedirInfo.iFlickerBitmapHandle); + } + + ++(iTest->iState); + iSubState = 0; + return ENext; + } + +#endif // TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + +void CTWsGraphs::CreateWindowL(TBool aDraw) + { + iWin = CCrWin::NewL(iTest->iScreenNumber, aDraw); + } + +void CTWsGraphs::DestroyWindowL() + { + delete iWin; + iWin = NULL; + } + +void CTWsGraphs::CreateAlphaWindowL() + { + iAlpha = CCrAlphaWin::NewL(iTest->iScreenNumber); + } + +void CTWsGraphs::DestroyAlphaWindowL() + { + delete iAlpha; + iAlpha = NULL; + } + +TBool CTWsGraphs::CompareBitmapArea16Bpp(CFbsBitmap* aBmp1, const TPoint& aPos1, CFbsBitmap* aBmp2, const TPoint& aPos2, const TSize& aSize) + { + const TDisplayMode dispmode = aBmp1->DisplayMode(); + if (dispmode!=aBmp2->DisplayMode()) + return EFalse; + const TInt stride1 = aBmp1->DataStride(); + const TInt stride2 = aBmp2->DataStride(); + const TInt linebytes = aSize.iWidth * 2; + const TInt pixelbytes = 2; + aBmp1->LockHeap(); + const TUint8* p1 = ((const TUint8*)aBmp1->DataAddress())+aPos1.iY*stride1+aPos1.iX*pixelbytes; + const TUint8* p2 = ((const TUint8*)aBmp2->DataAddress())+aPos2.iY*stride2+aPos2.iX*pixelbytes; + for (TInt y=0; yUnlockHeap(); + return EFalse; + } + } + aBmp1->UnlockHeap(); + return ETrue; + } + +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA +TestState CTWsGraphs::TestScreenRedirectionL() + { + if (iSubState==0) + { + _LIT(KTestScreenRedirection, "TestScreenRedirection"); + INFO_PRINTF1(KTestScreenRedirection); + + ++iSubState; + /** + @SYMTestCaseID GRAPHICS-WSERV-0372 + @SYMREQ GT247-CR0714 + @SYMTestCaseDesc Redirect wserv screen drawing to custom graphics context + @SYMTestPriority High + @SYMTestStatus Implemented + @SYMTestActions Redirects wserv screen drawing to bitmap context owned by plugin. + Actions step: + -Draw opaque window. + -Save screen content to a bitmap + -Instruct plugin to redirect wserv screen drawing to a bitmap device + -Draw the same window again + -Retrieve plugin bitmap and compare against the saved bitmap + @SYMTestExpectedResults Bitmap content match + */ + CreateWindowL(); + TheClient->iScreen->CopyScreenToBitmap(iBefore); + DestroyWindowL(); + iRedir->Redirect(CWsRedir::EFrontBuffer, ETrue); + return EWait; + } + + if (iSubState==1) + { + ++iSubState; + CreateWindowL(); + TSize sz = iBefore->SizeInPixels(); + TInt bytes = sz.iWidth*sz.iHeight*2; // EColor64K + iBefore->LockHeap(); + TEST(Mem::Compare((const TUint8*)iFrontCopy->DataAddress(),bytes,(const TUint8*)iBefore->DataAddress(),bytes)==0); + iBefore->UnlockHeap(); + + Mem::FillZ(&iRedirInfo, sizeof(TRedirectorInfo)); + iRedir->QueryPlugin(iRedirInfo); + return EWait; + } + + if (iSubState==2) + { + ++iSubState; + /** + @SYMTestCaseID GRAPHICS-WSERV-0047 + @SYMTestCaseDesc Screen update event + @SYMTestPriority Medium + @SYMTestStatus Implemented + @SYMTestActions Check plugin receive screen update event during redirection + @SYMTestExpectedResults Counter is non-zero + */ + TEST(iRedirInfo.iUpdateCounter>0); + + DestroyWindowL(); + /** + @SYMTestCaseID GRAPHICS-WSERV-0373 + @SYMREQ GT247-CR0714 + @SYMTestCaseDesc Stop wserv screen drawing redirection + @SYMTestPriority High + @SYMTestStatus Implemented + @SYMTestActions Stop wserv screen drawing redirection. + Actions step: + -Instruct plugin to stop wserv screen drawing redirection + -Draw the same window again + -Save screen content to another bitmap + -Compare the saved bitmap against newly saved bitmap + @SYMTestExpectedResults Bitmap content match + */ + iRedir->Redirect(CWsRedir::EFrontBuffer, EFalse); + return EWait; + } + + if (iSubState==3) + { + ++iSubState; + CreateWindowL(); + TheClient->iScreen->CopyScreenToBitmap(iAfter); + TSize sz = iBefore->SizeInPixels(); + TInt bytes = sz.iWidth*sz.iHeight*2; // EColor64K + iAfter->LockHeap(); + TEST(Mem::Compare((const TUint8*)iAfter->DataAddress(),bytes,(const TUint8*)iBefore->DataAddress(),bytes)==0); + iAfter->UnlockHeap(); + DestroyWindowL(); + + Mem::FillZ(&iRedirInfo, sizeof(TRedirectorInfo)); + iRedir->QueryPlugin(iRedirInfo); + return EWait; + } + + /** + @SYMTestCaseID GRAPHICS-WSERV-0374 + @SYMTestCaseDesc Screen update event + @SYMTestPriority Medium + @SYMTestStatus Implemented + @SYMTestActions Check plugin receive no screen update event when redirection is terminated + @SYMTestExpectedResults Counter is zero + */ + TEST(iRedirInfo.iUpdateCounter==0); + + ++(iTest->iState); + iSubState = 0; + + return ENext; + } + +TestState CTWsGraphs::TestTextCursorUnderRedirectionL(TTestCursorType aCursorType) + { + /** + @SYMTestCaseID GRAPHICS-WSERV-0363 + @SYMTestCaseDesc Text Cursor when drawing redirected + @SYMTestPriority Medium + @SYMTestStatus Implemented + @SYMTestActions Action steps: + - Draw the text cursor in the left side of the screen + - Re-direct the Front Buffer + - Move the text cursor to the right side of the screen + - Pause 0.5 seconds because this amount of time is needed + to change from the flash ON phase to the flash OFF phase + - Stop re-directing + - See if when we exit re-direction in a different place in + the phase of the text cursor flashing, whether we get + non-text cursor drawing artefacts in the old location + where the text cursor used to be + @SYMTestExpectedResults Left side of the screen does not show a Text Cursor + */ + + ASSERT(aCursorType == ETestStandardTextCursor || aCursorType == ETestCustomTextCursor); + + // Cursor Flash Period is 1 second (comprising two phases; ON and OFF) + const TInt KCursorFlashPeriod = 1000000; + const TInt KWaitForNextFlashPhase = KCursorFlashPeriod / 2; + + // Size of the cursor; it may be either a standard or custom text cursor + TSize cursorSize = (aCursorType == ETestStandardTextCursor) ? TSize(15, 20) : TSize(80, 80); + + // Original Text Cursor position in the left part of the screen + const TPoint originalCursorPos(45, 40); + + // New Text Cursor position in the right half of the screen + const TPoint newCursorPos((TheClient->iScreen->SizeInPixels().iWidth/2) + 45, 40); + + // Clean area of the screen which never had a text cursor + const TPoint cleanReferencePos(45, 40 + 80); + + /* Initial setup to get a window with a standard flashing text cursor */ + if (iSubState == 0) + { + ++iSubState; + CreateWindowL(ETrue); + + if (aCursorType == ETestStandardTextCursor) + { + _LIT(KTestTextCursorUnderRedirection, "TestTextCursorUnderRedirection(Standard Cursor)"); + INFO_PRINTF1(KTestTextCursorUnderRedirection); + iTextCursor.iType=TTextCursor::ETypeRectangle; + iTextCursor.iHeight=cursorSize.iHeight; + iTextCursor.iAscent=0; + iTextCursor.iWidth=cursorSize.iWidth; + iTextCursor.iFlags=0; // means flash the cursor + iTextCursor.iColor=KRgbGreen; + iWin->SetTextCursor(originalCursorPos, iTextCursor); + } + else if (aCursorType == ETestCustomTextCursor) + { + _LIT(KTestTextCursorUnderRedirection, "TestTextCursorUnderRedirection(Custom Cursor)"); + INFO_PRINTF1(KTestTextCursorUnderRedirection); + + TInt err = TheClient->iWs.SetCustomTextCursor( + KCustomTextCursorId, + iSpriteMemberArray.Array(), + ESpriteFlash, + RWsSession::ECustomTextCursorAlignTop + ); + iTextCursor.iType=KCustomTextCursorId; + iTextCursor.iHeight=cursorSize.iHeight; + iTextCursor.iAscent=0; + iTextCursor.iWidth=cursorSize.iWidth; + iTextCursor.iFlags=TTextCursor::EFlagClipHorizontal; // means flash the cursor and clip the sprite + iTextCursor.iColor=KRgbCyan; + iWin->SetTextCursor(originalCursorPos, iTextCursor); + } + else + { + // unknown type of test being requested + ASSERT(0); + } + iWin->DrawFirstHalf(); + return EWait; + } + /* + * Re-direct drawing to another Front Buffer. Whilst re-directed, change the + * position of the text cursor. Then pause 0.5 seconds because this is how + * long it will take to enter the next phase in the flashing cycle. Finally + * stop re-directing. We exit the re-direction in a different point in the + * phase of the text cursor from when we entered it. + * This is key to testing for faulty behaviour. + */ + if (iSubState==1) + { + ++iSubState; + User::After(KCursorFlashPeriod * 2); // so its easy to visually review progress + iRedir->Redirect(CWsRedir::EFrontBuffer, ETrue); + iWin->SetTextCursor(newCursorPos, iTextCursor); + User::After(KWaitForNextFlashPhase); + iRedir->Redirect(CWsRedir::EFrontBuffer, EFalse); + return EWait; + } + /* + * Paint the right hand side of the screen which should now have a text cursor. + */ + if (iSubState==2) + { + ++iSubState; + iWin->DrawSecondHalf(); + return EWait; + } + /* + * Let the cursor flash a few times, as it assists manual viewing of the progress + * of the test. + */ + if (iSubState==3) + { + ++iSubState; + User::After(KCursorFlashPeriod * 3); + return EWait; + } + /* + * Check to see if the text cursor did move to the right of the screen. + */ + if (iSubState==4) + { + ++iSubState; + + /* When we do a screen comparison, we supply flag 0, which means + * don't include the text cursor. We do this because we are interested + * in screen artefacts. + */ + TEST(TheClient->iScreen->RectCompare( + TRect(originalCursorPos, cursorSize), + TRect(cleanReferencePos, cursorSize), + 0)); // must not supply CWsScreenDevice::EIncludeTextCursor + + return EWait; + } + /* Clean up */ + if (iSubState==5) + { + ++iSubState; + iWin->CancelTextCursor(); + DestroyWindowL(); + } + + iSubState = 0; + + return ENext; + } + +/** + @SYMTestCaseID GRAPHICS-WSERV-0375 + @SYMREQ GT247-CR0714 + @SYMTestCaseDesc Redirect wserv flickerfree drawing to custom graphics context + @SYMTestPriority Medium + @SYMTestStatus Implemented + @SYMTestActions Redirect wserv flickerfree buffer drawing. + Action step: + -Draw opaque window (as background) and transparent window + -Save screen content to a bitmap + -Instruct plugin to redirect wserv flickerfree buffer drawing + -Draw the same opaque window and transparent window again + -Retrieve plugin bitmap and compare against the saved bitmap + @SYMTestExpectedResults Bitmap content match +*/ +/** + @SYMTestCaseID GRAPHICS-WSERV-0376 + @SYMREQ GT247-CR0714 + @SYMTestCaseDesc Stop wserv flickerfree drawing redirection + @SYMTestPriority Medium + @SYMTestStatus Implemented + @SYMTestActions Stop wserv flickerfree buffer drawing redirection. + Action step: + -Instruct plugin to stop wserv filckerfree drawing redirection + -Draw the same opaque and transparent window + -Save screen content to another bitmap + -Compare saved bitmap against newly saved bitmap + @SYMTestExpectedResults Bitmap content match +*/ + +TestState CTWsGraphs::TestFlickerRedirectionL() + { + if (TransparencySupportedL()==KErrNotSupported) + { + ++(iTest->iState); + return ENext; + } + + // flush transparent window destruction created in TransparencySupportedL before + // proceeding with the test + + TheClient->iWs.Flush(); + + if (iSubState==0) + { + _LIT(KTestFlickerRedirection, "TestFlickerRedirection"); + INFO_PRINTF1(KTestFlickerRedirection); + + ++iSubState; + + CreateWindowL(); + CreateAlphaWindowL(); + TheClient->iScreen->CopyScreenToBitmap(iBefore); + DestroyAlphaWindowL(); + DestroyWindowL(); + iRedir->Redirect(CWsRedir::EBackBuffer, ETrue); + return EWait; + } + + if (iSubState==1) + { + ++iSubState; + CreateWindowL(); + CreateAlphaWindowL(); + TSize sz = iBefore->SizeInPixels(); + TInt bytes = sz.iWidth*sz.iHeight*2; // EColor64K + iBefore->LockHeap(); + TInt ret=Mem::Compare((const TUint8*)iBackCopy->DataAddress(),bytes,(const TUint8*)iBefore->DataAddress(),bytes); + TEST(ret==0); + if (ret!=0) + { + _LIT(KLog,"The memory of two bitmaps doesn't match"); + LOG_MESSAGE(KLog); + } + iBefore->UnlockHeap(); + DestroyAlphaWindowL(); + DestroyWindowL(); + iRedir->Redirect(CWsRedir::EBackBuffer, EFalse); + return EWait; + } + + CreateWindowL(); + CreateAlphaWindowL(); + TheClient->iScreen->CopyScreenToBitmap(iAfter); + TSize sz = iBefore->SizeInPixels(); + TInt bytes = sz.iWidth*sz.iHeight*2; // EColor64K + iAfter->LockHeap(); + TEST(Mem::Compare((const TUint8*)iAfter->DataAddress(),bytes,(const TUint8*)iBefore->DataAddress(),bytes)==0); + iAfter->UnlockHeap(); + DestroyAlphaWindowL(); + DestroyWindowL(); + + ++(iTest->iState); + iSubState = 0; + return ENext; + } + +#endif // TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + +/** + @SYMTestCaseID GRAPHICS-WSERV-0377 + @SYMREQ GT247-CR0714 + @SYMTestCaseDesc Enable event notification + @SYMTestPriority Medium + @SYMTestStatus Implemented + @SYMTestActions Enable plugin to register to event notification. + Action step: + -Instruct plugin to register event handler + -Draw fullscreen window (plugin will receive window visibility changed event) + -Query visibility region from plugin side + -Compare window visible region against value obtained by plugin + @SYMTestExpectedResults Visible region match +*/ +/** + @SYMTestCaseID GRAPHICS-WSERV-0378 + @SYMREQ GT247-CR0714 + @SYMTestCaseDesc Disable event notification + @SYMTestPriority Medium + @SYMTestStatus Implemented + @SYMTestActions Disable plugin to register to event notification. + Action step: + -Instruct plugin to unregister event handler + -Destroy fullscreen window (plugin will not receive window visibility changed event) + -Query visibility region from plugin side + + @SYMTestExpectedResults Plugin does not receive events notification +*/ +TestState CTWsGraphs::TestEventNotificationL() + { + if (iSubState==0) + { + _LIT(KTestEventNotification, "TestEventNotification"); + INFO_PRINTF1(KTestEventNotification); + + ++iSubState; + iListen->Enable(ETrue); + CreateWindowL(); + Mem::FillZ(&iListenInfo, sizeof(TListenerInfo)); + TheClient->iWs.Finish(); + TheClient->WaitForRedrawsToFinish(); + iListen->QueryPlugin(iListenInfo); + return EWait; + } + + if (iSubState==1) + { + ++iSubState; + iListen->Enable(EFalse); + TEST(iListenInfo.iNumRect==1); + TEST(iListenInfo.iRect==TRect(TPoint(0,0),TheClient->iScreen->SizeInPixels())); + DestroyWindowL(); + Mem::FillZ(&iListenInfo, sizeof(TListenerInfo)); + iListen->QueryPlugin(iListenInfo); + iListen->Enable(EFalse); + DestroyWindowL(); + return EWait; + } + + TEST(iListenInfo.iNumRect==0); + + ++(iTest->iState); + iSubState = 0; + return ENext; + } + +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + +TestState CTWsGraphs::TestRedirectionUsingWsBackBufferL() + { + if (TransparencySupportedL()==KErrNotSupported) + { + ++(iTest->iState); + return ENext; + } + + // flush transparent window destruction created in TransparencySupportedL before + // proceeding with the test + + TheClient->iWs.Flush(); + + if (iSubState==0) + { + _LIT(KTestRedirectionWsBack, "TestRedirectionUsingWsBackBuffer"); + INFO_PRINTF1(KTestRedirectionWsBack); + + ++iSubState; + + /** + @SYMTestCaseID GRAPHICS-WSERV-0379 + @SYMTestCaseDesc Redirect wserv flickerfree to MWsBackBuffer object + @SYMTestPriority Medium + @SYMTestStatus Implemented + @SYMTestActions -Draw opaque window (as background) and transparent window + -Save screen content to a bitmap + -Instruct plugin to redirect flickerfree buffer to MWsBackBuffer object + -Draw the same opaque window and transparent window again + -Retrieve plugin bitmap and compare against the saved bitmap + @SYMTestExpectedResults Bitmap content match + */ + ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0379")); + CreateWindowL(); + CreateAlphaWindowL(); + TheClient->iScreen->CopyScreenToBitmap(iBefore); + DestroyAlphaWindowL(); + DestroyWindowL(); + iRedir->RedirectUsingWsBackBuffer(ETrue); + return EWait; + } + + if (iSubState==1) + { + ++iSubState; + CreateWindowL(); + CreateAlphaWindowL(); + TSize sz = iBefore->SizeInPixels(); + TInt bytes = sz.iWidth*sz.iHeight*2; // EColor64K + iBefore->LockHeap(); + TInt ret=Mem::Compare((const TUint8*)iBackCopy->DataAddress(),bytes,(const TUint8*)iBefore->DataAddress(),bytes); + TEST(ret==0); + if (ret!=0) + { + _LIT(KLog,"The memory of two bitmaps doesn't match"); + LOG_MESSAGE(KLog); + } + iBefore->UnlockHeap(); + DestroyAlphaWindowL(); + DestroyWindowL(); + + /** + @SYMTestCaseID GRAPHICS-WSERV-0380 + @SYMTestCaseDesc Restore wserv flickerfree redirection from MWsBackBuffer object + @SYMTestPriority Medium + @SYMTestStatus Implemented + @SYMTestActions -Instruct plugin to stop wserv filckerfree drawing redirection + -Draw the same opaque and transparent window + -Save screen content to another bitmap + -Compare saved bitmap against newly saved bitmap + @SYMTestExpectedResults Bitmap content match + */ + ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0380")); + iRedir->RedirectUsingWsBackBuffer(EFalse); + return EWait; + } + + CreateWindowL(); + CreateAlphaWindowL(); + TheClient->iScreen->CopyScreenToBitmap(iAfter); + TSize sz = iBefore->SizeInPixels(); + TInt bytes = sz.iWidth*sz.iHeight*2; // EColor64K + iAfter->LockHeap(); + TEST(Mem::Compare((const TUint8*)iAfter->DataAddress(),bytes,(const TUint8*)iBefore->DataAddress(),bytes)==0); + iAfter->UnlockHeap(); + DestroyAlphaWindowL(); + DestroyWindowL(); +/** + @SYMTestCaseID GRAPHICS-WSERV-0527 +*/ + ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0527")); + ++(iTest->iState); + iSubState = 0; + return ENext; + } + +#endif // TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + +//A call to do coverage through a plugin. +//This can serve as a basis for future coverage to objects exposed by the +//plugin. For now a single simple test is implmeneted. +TestState CTWsGraphs::TestGraphicDrawerCoverage() + { + __ASSERT_ALWAYS(iGdCoverage->RunTest(1)==KErrNone||KErrNotReady, User::Invariant()); + return ENext; + } + +//Simplified non-functional class to create a few dummy CWsGraphicDrawer instances. +//This code is intended to test the Array class, not the Drawer. +//Note that this object is not at all functional! The only guaranteed method is Id(). +//WsGraphicDrawer is declared as a friend and is actually intended to be the factory class for CWsGraphicDrawer +class WsGraphicDrawer:public CWsGraphicDrawer + { +public: + WsGraphicDrawer() + { + } + //stub for virtual construction. Most members are ignored + virtual void ConstructL(MWsGraphicDrawerEnvironment& ,const TGraphicDrawerId& id,MWsClient& ,const TDesC8& ) + { + ConstructL(id); + } + //simplified custom construction + void ConstructL(const TGraphicDrawerId& id) + { + MWsGraphicDrawerEnvironment* nullEnv=NULL; + MWsGraphicDrawerEnvironment& aEnv=*nullEnv; + MWsClient* nullClient=NULL; + MWsClient& aOwner=*nullClient; + this->BaseConstructL(aEnv,id,aOwner); + this->iDtor_ID_Key=TUid::Null(); + + } + //stubs for pure virtual methods + virtual void HandleMessage(const TDesC8& ) + {} + virtual void DoDraw(MWsGc& ,const TRect& ,const TDesC8& ) const + {} + + }; +//Class to allow me to pre-allocate the CWsGraphicDrawerArray so it doesn't pop up a false-positive memory allocation! +class DummyCleanup:public TCleanupItem + { +public: + static void CleanUp(TAny*) {} + DummyCleanup(): TCleanupItem(CleanUp,this) {} + operator DummyCleanup*() { return this; } + + }; + +//Helper function to explain test fails. Most other tests are against KErrNone +void CTWsGraphs::ReportNegativeResultfail(TInt aLine,TInt aResult,TInt aExpectedResult) + { + testBooleanTrue((aResult==aExpectedResult), (TText8*)__FILE__, aLine); + if (aResult!=aExpectedResult) + { + INFO_PRINTF3(_L("Expected return code %i, got %i"),aExpectedResult,aResult); + } + + } + +//This is an attempt to use wserv test's pre-existing Panic handler to perform some negative tests. +//At present this handler appears to be broken: +// 1) It doesn't write to the correct html log file +// 2) It no longer writes to the WSERV.LOG file it was writing to a few versions ago +// 3) It doesn't close the panic window so subsequent tests that check the display output fail. +//That was a waste of effort. +struct CTWsGraphs::WrapTestCall + { + CTWsGraphs* thisThis; + TUint testCount; + TBool continueTests; + TUint testFailedLine; + //This field was intended to allow threaded panicing tests to report other errors + //As I can't get threaded panicing tests to operate correctly, I have not implemented support for the field. + //TBuf<1024> errorMessages; + + WrapTestCall ( CTWsGraphs* thisThis, TUint testCount): + thisThis(thisThis), testCount(testCount) + { continueTests=false;testFailedLine=0; } + }; + +TInt CTWsGraphs::DoNegTestCall(TInt /*aInt*/, TAny *aPtr) + { + CTWsGraphs::WrapTestCall* aWrap=static_cast(aPtr); + aWrap->continueTests=aWrap->thisThis->NegTestAddSwapGDArrayL(aWrap->testCount,aWrap); + return 0; + } + +TBool CTWsGraphs::LaunchNegTestCall(TUint aTestCount,TUint PanicCode,const TDesC &aPanicCategory) + { + WrapTestCall wt(this,aTestCount); + (void)PanicCode; + (void)aPanicCategory; +//I have disabled the panicing tests because they don't output diagnostics +//and the open panic window causes subsequent screen bitmap comparrisson tests to fail. +// iTest->TestPanicL(DoNegTestCall,aPanicCode,3,&wt,aPanicCategory); + return wt.continueTests; + } + +/** + Loops through all the positive and negative tests associated with the GraphicDrawerArray. + The aim is to perform isolated testing of these classes as some are not currently being used. + +**/ +void CTWsGraphs::TestAddSwapGDArrayL() + { + + + INFO_PRINTF1(_L("Positive tests for GraphicDrawerArray")); + for (TInt i=0;PosTestAddSwapGDArrayL(i);i++) + {} + + + + INFO_PRINTF1(_L("Verifying that negative tests for GraphicDrawerArray don't actually panic")); + for (TInt i=1;NegTestAddSwapGDArrayL(i);i++) + {} + } +/** + Resets and deallocates the GDA withoud deleting the objects. + @param testArray the array to reset + @return true if the array was already empty. +**/ +static bool ResetArray(CWsGraphicDrawerArray& testArray) +{ + bool rv=(testArray.IsEmpty()); + MWsClient* nullClient=NULL; + testArray.RemoveAll(*nullClient); + testArray.ResetAndDestroy(); + return rv; +} +/** + @SYMTestCaseID GRAPHICS-WSERV-AddSwapGDArray-0001 + @SYMDEF DEF093926 + + @SYMTestCaseDesc DEF093926: Check for stability of Add and Swap unwind methods in isolation. + Note that this code is testing the functionality of a class internal to CWindowServer. + At present CWindowServer presents just a simple shim on this class, + but if that implementation of CWindowServer changes than this test will be redudant. + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions + The sequence for each of these positive test sections is pretty much the same: + Add one record with id 1234(test for errors) + Add one record with id Badf00d + Swap with another record with id Badf00d + Remove 2 records + result=no leaks + + Add/Swap: no Cleanup item - no leaks after Remove the added items + AddTLC/SwapTLC: Cleanup item requires Commit - check for no leaks after Remove. + AddTLC/SwapTLC: Cleanup item gets executed by forced Leave - check for no leaks after. + AddTLC, SwapTLC in allocation failure scenarios. Add/Swap don't allocate anything! + obsoleted AddLC/SwapLC to ensure correct function when forced Leave - check for no leaks after + obsoleted AddLC/SwapLC to ensure correct function. These will always leak in good case. + @SYMTestExpectedResults + no exceptions or panics within this fn. + only the old AddLC and SwapLC should leak as indicated. + */ +TBool CTWsGraphs::PosTestAddSwapGDArrayL(TInt testcase) + { + ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-AddSwapGDArray-0001")); + CWsGraphicDrawerArray testArray; + //Represents the memory cached in the array once it has been used even when it is then resized to zero +#if defined(_DEBUG) + const TInt KArrayMemUseBaseline=1; +#endif + //Use testArray.IsEmpty() to prove the array is clear when it should be! + TGraphicDrawerId id1234= { 1234, EFalse }; + TGraphicDrawerId idBADF00D= { 0xBADF00D, EFalse }; + WsGraphicDrawer dg1234; + dg1234.ConstructL(id1234); + WsGraphicDrawer dgBADF00D; + dgBADF00D.ConstructL(idBADF00D); + WsGraphicDrawer dgBADF00D_2; + dgBADF00D_2.ConstructL(idBADF00D); + CWsGraphicDrawerArray::XRollBackBase* rollBack1; + TInt errCode=KErrAbort; + TInt leaveCode=KErrNone; + DummyCleanup markerCleanup; + CleanupStack::PushL(markerCleanup); //This allows me to check the stack is clear! + //expected result of this fn: no exceptions or panics. + //Put as much as you like in here, so long as it shouldn't fail. + + __UHEAP_MARK; + __UHEAP_CHECK(0); + TUint expectedLeakCount=0; + TBool returnCode=ETrue; + switch (testcase) + { + case 0: + + INFO_PRINTF1(_L("Sub test P0: AddL/Swap: no Cleanup item")); + TEST(testArray.IsEmpty()); + TRAP(leaveCode,errCode=testArray.Add(&dg1234)); + TEST(errCode==KErrNone); + TEST(leaveCode==KErrNone); + TEST(!testArray.IsEmpty()); + TRAP(leaveCode,errCode=testArray.Add(&dgBADF00D)); + TEST(errCode==KErrNone); + TEST(leaveCode==KErrNone); + TRAP(leaveCode,errCode=testArray.Swap(&dgBADF00D_2)); + TEST(errCode==KErrNone); + TEST(leaveCode==KErrNone); + TRAP(leaveCode,errCode=testArray.Remove(dg1234.Id())); + TEST(errCode==KErrNone); + TEST(leaveCode==KErrNone); + //Note that it is the ID that matters here... dgBADF00D & dgBADF00D_2 have same id. + TRAP(leaveCode,errCode=testArray.Remove(dgBADF00D_2.Id())); + TEST(errCode==KErrNone); + TEST(leaveCode==KErrNone); + TEST(testArray.IsEmpty()); + break; + // + case 1: + INFO_PRINTF1(_L("Sub test P1: AddTLC/SwapTLC: Cleanup item requires Commit.")); + + rollBack1=NULL; + TEST(testArray.IsEmpty()); + TRAP(leaveCode, + rollBack1=testArray.AddTLC(&dg1234); + CleanupStack::Check(rollBack1); + testArray.CommitP(rollBack1); + ) + TEST(rollBack1!=NULL); + TEST(leaveCode==KErrNone); + TEST(!testArray.IsEmpty()); + rollBack1=NULL; + TRAP(leaveCode, + rollBack1=testArray.AddTLC(&dgBADF00D); + CleanupStack::Check(rollBack1); + testArray.CommitP(rollBack1); + ) + TEST(rollBack1!=NULL); + TEST(leaveCode==KErrNone); + rollBack1=NULL; + TRAP(leaveCode, + rollBack1=testArray.SwapTLC(&dgBADF00D_2); + CleanupStack::Check(rollBack1); + testArray.CommitP(rollBack1); + ) + TEST(rollBack1!=NULL); + TEST(leaveCode==KErrNone); + rollBack1=NULL; + TRAP(leaveCode, + rollBack1=testArray.RemoveTLC(dg1234.Id()); + CleanupStack::Check(rollBack1); + testArray.CommitP(rollBack1); + ) + TEST(rollBack1!=NULL); + TEST(leaveCode==KErrNone); + rollBack1=NULL; + TRAP(leaveCode, + rollBack1=testArray.RemoveTLC(dgBADF00D_2.Id()); + CleanupStack::Check(rollBack1); + testArray.CommitP(rollBack1); + ) + TEST(rollBack1!=NULL); + TEST(leaveCode==KErrNone); + rollBack1=NULL; + TEST(testArray.IsEmpty()); + break; + // + case 2: + INFO_PRINTF1(_L("Sub test P2: AddTLC/SwapTLC: Cleanup item gets executed.")); + + rollBack1=NULL; + TEST(testArray.IsEmpty()); + TRAP(leaveCode, + rollBack1=testArray.AddTLC(&dg1234); + User::Leave(1234); + ); + TEST(rollBack1!=NULL); + TEST(leaveCode==1234); + TEST(testArray.IsEmpty()); + rollBack1=NULL; + CleanupStack::Check(markerCleanup); + __UHEAP_CHECK(KArrayMemUseBaseline); + + TRAP(leaveCode, errCode=testArray.Add(&dgBADF00D)); + TEST(errCode==KErrNone); + TEST(leaveCode==KErrNone); + rollBack1=NULL; + TRAP(leaveCode, + rollBack1=testArray.SwapTLC(&dgBADF00D_2); + User::Leave(1234); + ); + TEST(rollBack1!=NULL); + TEST(leaveCode==1234); + TEST(!testArray.IsEmpty()); + rollBack1=NULL; + TRAP(leaveCode, + rollBack1=testArray.RemoveTLC(dgBADF00D_2.Id()); + TEST(testArray.IsEmpty()); + User::Leave(1234); + ); + TEST(rollBack1!=NULL); + TEST(leaveCode==1234); + TEST(!testArray.IsEmpty()); + + + TRAP(leaveCode,errCode=testArray.Remove(dgBADF00D_2.Id())); + TEST(errCode==KErrNone); + TEST(leaveCode==KErrNone); + TEST(testArray.IsEmpty()); + rollBack1=NULL; + break; + // + case 3: + INFO_PRINTF1(_L("Sub test P3: AddLC/SwapLC: Cleanup item gets executed - doesn't leak")); + TEST(testArray.IsEmpty()); + TRAP(leaveCode, + testArray.AddLC(&dg1234); + User::Leave(1234); + ); + TEST(leaveCode==1234); + TEST(testArray.IsEmpty()); + rollBack1=NULL; + __UHEAP_CHECK(KArrayMemUseBaseline); //because it threw it didn't leak + + //use my new method to add the object to be swapped out so no leak + TRAP(leaveCode,errCode=testArray.Add(&dgBADF00D)); + TEST(errCode==KErrNone); + TEST(leaveCode==KErrNone); + __UHEAP_CHECK(KArrayMemUseBaseline); //new method doesn't leak. + rollBack1=NULL; + TRAP(leaveCode, + errCode=testArray.SwapLC(&dgBADF00D_2); + User::Leave(1234); + ); + TEST(errCode==KErrNone); + TEST(leaveCode==1234); + TEST(!testArray.IsEmpty()); + + TRAP(leaveCode,errCode=testArray.Remove(dgBADF00D_2.Id())); + TEST(errCode==KErrNone); + TEST(leaveCode==KErrNone); + TEST(testArray.IsEmpty()); + rollBack1=NULL; + break; + // + case 4: + + //I don't really care whether the individual calls succeed or fail, + //just whether it leaks overall, and that the error codes correspond to no-action + for (TInt faultRate=1;faultRate<5;faultRate++) + { + INFO_PRINTF2(_L("Sub test P4: Add/Swap: memory faulting %i"),faultRate); + __UHEAP_SETFAIL(RAllocator::EDeterministic,faultRate); + TInt err1=KErrNone; + rollBack1=NULL; + TRAP(leaveCode, + errCode=testArray.Add(&dg1234); + ) + err1=errCode; + __UHEAP_SETFAIL(RAllocator::ENone,0); + TRAP(leaveCode,errCode=testArray.Add(&dgBADF00D)); + __UHEAP_SETFAIL(RAllocator::EDeterministic,faultRate); + rollBack1=NULL; + TRAP(leaveCode, + errCode=testArray.Swap(&dgBADF00D_2); + ) + __UHEAP_SETFAIL(RAllocator::ENone,0); + //If the first Add fails then the object should not be removed + if (!err1) + { + TRAP(leaveCode,errCode=testArray.Remove(dg1234.Id())); + TEST(errCode==KErrNone); + TEST(leaveCode==KErrNone); + } + //If the swap fails, then the add still needs to be removed + //Note that it is the ID that matters here... dgBADF00D & dgBADF00D_2 have same id. + TRAP(leaveCode,errCode=testArray.Remove(dgBADF00D_2.Id())); + TEST(errCode==KErrNone); + TEST(leaveCode==KErrNone); + TEST(testArray.IsEmpty()); + ResetArray(testArray); + CleanupStack::Check(markerCleanup); + __UHEAP_CHECK(0); + } + break; + // + case 5: + + //I don't really care whether the individual calls succeed or fail, + //just whether it leaks overall, and that the error codes correspond to no-action + for (TInt faultRate=1;faultRate<5;faultRate++) + { + INFO_PRINTF2(_L("Sub test P5: AddTLC/SwapTLC: memory faulting %i"),faultRate); + __UHEAP_SETFAIL(RAllocator::EDeterministic,faultRate); + TInt err1=KErrNone,err2=KErrNone,err3=KErrNone; + rollBack1=NULL; + TRAP(leaveCode, + rollBack1=testArray.AddTLC(&dg1234); + CleanupStack::Check(rollBack1); + testArray.CommitP(rollBack1); + ) + err1=leaveCode; + __UHEAP_SETFAIL(RAllocator::ENone,0); + TRAP(leaveCode,errCode=testArray.Add(&dgBADF00D)); + __UHEAP_SETFAIL(RAllocator::EDeterministic,faultRate); + rollBack1=NULL; + TRAP(leaveCode, + rollBack1=testArray.SwapTLC(&dgBADF00D_2); + CleanupStack::Check(rollBack1); + testArray.CommitP(rollBack1); + ) + //If the first Add fails then the object should not be removed + if (!err1) + { + TRAP(leaveCode, + rollBack1=testArray.RemoveTLC(dg1234.Id()); + CleanupStack::Check(rollBack1); + testArray.CommitP(rollBack1); + ) + err2=leaveCode; + } + //If the swap fails, then the add still needs to be removed + //Note that it is the ID that matters here... dgBADF00D & dgBADF00D_2 have same id. + TRAP(leaveCode, + rollBack1=testArray.RemoveTLC(dgBADF00D_2.Id()); + CleanupStack::Check(rollBack1); + testArray.CommitP(rollBack1); + ) + err3=leaveCode; + + + __UHEAP_SETFAIL(RAllocator::ENone,0); + //If the Removes failed then the object should be removed again + if (err2) + { + TRAP(leaveCode,errCode=testArray.Remove(dg1234.Id())); + TEST(errCode==KErrNone); + TEST(leaveCode==KErrNone); + } + if (err3) + { + TRAP(leaveCode,errCode=testArray.Remove(dgBADF00D_2.Id())); + TEST(errCode==KErrNone); + TEST(leaveCode==KErrNone); + } + TEST(testArray.IsEmpty()); + ResetArray(testArray); + CleanupStack::Check(markerCleanup); + __UHEAP_CHECK(0); + } + + break; + // + case 6: + //this set does leak: + + INFO_PRINTF1(_L("Sub test P6: AddLC/SwapLC: Cleanup item gets popped - unfixable leaks")); + TEST(testArray.IsEmpty()); + TRAP(leaveCode, + testArray.AddLC(&dg1234); + CleanupStack::Pop(); + ); + TEST(leaveCode==KErrNone); + TEST(!testArray.IsEmpty()); + + CleanupStack::Check(markerCleanup); + __UHEAP_CHECK(KArrayMemUseBaseline+1); + + TRAP(leaveCode, + testArray.AddLC(&dgBADF00D); + CleanupStack::Pop(); + ) + TEST(leaveCode==KErrNone); + CleanupStack::Check(markerCleanup); + __UHEAP_CHECK(KArrayMemUseBaseline+2); + rollBack1=NULL; + TRAP(leaveCode, + errCode=testArray.SwapLC(&dgBADF00D_2); + CleanupStack::Pop(); + ); + TEST(errCode==KErrNone); + TEST(leaveCode==KErrNone); + TEST(!testArray.IsEmpty()); + TRAP(leaveCode,errCode=testArray.Remove(dg1234.Id())); + TEST(errCode==KErrNone); + TEST(leaveCode==KErrNone); + TRAP(leaveCode,errCode=testArray.Remove(dgBADF00D_2.Id())); + TEST(errCode==KErrNone); + TEST(leaveCode==KErrNone); + TEST(testArray.IsEmpty()); + rollBack1=NULL; + expectedLeakCount=3; + break; + // + case 7: + returnCode=EFalse; + break; + } + ResetArray(testArray); + CleanupStack::Check(markerCleanup); + __UHEAP_CHECK(expectedLeakCount); + __UHEAP_MARKENDC(expectedLeakCount); + if (expectedLeakCount!=0) + { //Ensure that the leaked items are no longer associated with this debug level. + //Note that __DbgSetAllocFail(FALSE,RAllocator::EReset,1) resets the debug level to 0, + //so levels can't be nested when using this call. + __UHEAP_MARK; + __UHEAP_TOTAL_RESET; + INFO_PRINTF2(_L("Anticipated %i leaks declassified"),expectedLeakCount); //can't get here if wrong + } + + CleanupStack::PopAndDestroy(markerCleanup); + ((CTWsGraphsStep*)iStep)->RecordTestResultL(); + return returnCode; + } + +/** + @param failcase index to test to perform + @param aWrappedParams represents inter-thread information when test is run on a private thread + if aWrappedParams is NULL then the test is running on the main thread. + @return true if there are higher-numbered fail cases. + + @SYMTestCaseID GRAPHICS-WSERV-NegAddSwapGDArray-0001 + @SYMDEF DEF093926 + + @SYMTestCaseDesc DEF093926: Check for stability of Add and Swap unwind methods in isolation, + specifically checking that bad inputs are rejected gracefully. + Note that this code is testing the functionality of a class internal to CWindowServer. + At present CWindowServer presents just a simple shim on this class, + but if that implementation of CWindowServer changes than this test will be redudant. + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions + + Add/Swap: no Cleanup item - no leaks after Remove the added items + AddTLC/SwapTLC: Cleanup item requires Commit - check for no leaks after Remove. + AddTLC/SwapTLC: Cleanup item gets executed by forced Leave - check for no leaks after. + AddTLC, SwapTLC in allocation failure scenarios. Add/Swap don't allocate anything! + obsoleted AddLC/SwapLC to ensure correct function when forced Leave - check for no leaks after + obsoleted AddLC/SwapLC to ensure correct function. These will always leak in good case. + Calls NegTestAddSwapGDArrayL. + case 1/2/3: Tests AddL, AddLC, AddTLC that a NULL input is rejected + case 4/5/6: Tests SwapL, SwapLC, SwapTLC that a NULL input is rejected + case 7/8/9: Tests AddL, AddLC, AddTLC that a repeat input is rejected + case 10/11/12: Tests SwapL, SwapLC, SwapTLC that a non-repeat input is rejected + @SYMTestExpectedResults + */ +TBool CTWsGraphs::NegTestAddSwapGDArrayL(TInt failcase,WrapTestCall*aWrappedParams) + { + ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-NegAddSwapGDArray-0001")); + _LIT(KCategory,"WsGraphicDrawer"); + if (!aWrappedParams) + { + INFO_PRINTF2(_L("NegTestAddSwapGDArrayL Negative sub test %i"),failcase); + }; + CWsGraphicDrawerArray testArray; + TGraphicDrawerId id1234= { 1234, EFalse }; + TGraphicDrawerId idBADF00D= { 0xBADF00D, EFalse }; + WsGraphicDrawer dg1234; + dg1234.ConstructL(id1234); + WsGraphicDrawer dgBADF00D; + dgBADF00D.ConstructL(idBADF00D); + WsGraphicDrawer dgBADF00D_2; + dgBADF00D_2.ConstructL(idBADF00D); + CWsGraphicDrawerArray::XRollBackBase* rollBack1=NULL; + TInt errCode=KErrAbort; + TInt leaveCode=KErrNone; + TBool returnMoreTests=ETrue; + DummyCleanup markerCleanup; + TBool mayPanic=EFalse; +#ifdef __WINS__ + mayPanic=ETrue; +#endif + + CleanupStack::PushL(markerCleanup); //This allows me to check the stack is clear! + __UHEAP_MARK; + + switch (failcase) + { + case 1: //NULL arg: expected result: returns KErrArgument + TRAP(leaveCode, + errCode=testArray.Add(NULL); + ) + TEST(leaveCode==KErrNone); + ReportNegativeResultfail(__LINE__,errCode,KErrArgument); + break; + case 2: //NULL arg: expected result: throws KErrArgument + TRAP(leaveCode, + rollBack1=testArray.AddTLC(NULL); + TEST(EFalse); //Should never get here! + ) + TEST(rollBack1==NULL); + ReportNegativeResultfail(__LINE__,leaveCode,KErrArgument); + break; + case 3: //NULL arg: expected result: debug: panic. In release doesn't return any information! + if (!aWrappedParams && mayPanic) + { + LaunchNegTestCall(failcase,EWsGraphicDrawerPanicBadArgument,KCategory); + } + else + { + TRAP(leaveCode, + testArray.AddLC(NULL); + User::Leave(1234); //Panics before here in debug. No leak if cleanup is taken. + ); + TEST(leaveCode==1234); //Panics before here in debug + } + break; + // + case 4: //NULL arg: expected result: returns KErrArgument + TRAP(leaveCode, + errCode=testArray.Swap(NULL) + ) + TEST(leaveCode==KErrNone); + ReportNegativeResultfail(__LINE__,errCode,KErrArgument); + break; + case 5: //expected result: throws KErrArgument + TRAP(leaveCode, + rollBack1=testArray.SwapTLC(NULL); + testArray.CommitP(rollBack1); + ) + TEST(rollBack1==NULL); + ReportNegativeResultfail(__LINE__,leaveCode,KErrArgument); + break; + case 6: //NULL arg: expected result: debug: panic. In release doesn't return any information! + if (!aWrappedParams && mayPanic) + { + LaunchNegTestCall(failcase,EWsGraphicDrawerPanicBadArgument,KCategory); + } + else + { + TRAP(leaveCode, + errCode=testArray.SwapLC(NULL); + User::Leave(1234); //Panics before here in debug. No leak if cleanup is taken. + ); + TEST(leaveCode==1234); //Panics before here in debug + TEST(errCode==KErrNotFound); + } + break; + // + case 7: //Add overwrites: expected result: returns KErrAlreadyExists + TRAP(leaveCode, + errCode=testArray.Add(&dg1234); + ) + TEST(errCode==KErrNone); + TEST(leaveCode==KErrNone); + TRAP(leaveCode, + errCode=testArray.Add(&dg1234); //oops! Already added! + ) + TEST(leaveCode==KErrNone); + ReportNegativeResultfail(__LINE__,errCode,KErrAlreadyExists); + break; + case 8: //Add overwrites: expected result: throws KErrAlreadyExists + TRAP(leaveCode, + errCode=testArray.Add(&dg1234); + ) + TEST(errCode==KErrNone); + TEST(leaveCode==KErrNone); + TRAP(leaveCode, + rollBack1=testArray.AddTLC(&dg1234); //oops! Already added! + testArray.CommitP(rollBack1); + ) + TEST(rollBack1==NULL); + ReportNegativeResultfail(__LINE__,leaveCode,KErrAlreadyExists); + break; + case 9: //Add overwrites: expected result: debug: does not panic, but throws KErrAlreadyExists. + TRAP(leaveCode, + errCode=testArray.Add(&dg1234); + ) + TEST(errCode==KErrNone); + TEST(leaveCode==KErrNone); + TRAP(leaveCode, + testArray.AddLC(&dg1234); //oops! Already added! Should leave. + User::Leave(1234); //Should leave before here! No leak if cleanup is taken. + ); + ReportNegativeResultfail(__LINE__,leaveCode,KErrAlreadyExists); + break; + // + case 10: //Swap empty slot: expected result: returns KErrNotFound + TRAP(leaveCode, + errCode=testArray.Swap(&dg1234) //oops! Nothing to swap with! + ) + TEST(leaveCode==KErrNone); + ReportNegativeResultfail(__LINE__,errCode,KErrNotFound); + break; + case 11: //Swap empty slot: expected result: throws KErrNotFound + TRAP(leaveCode, + rollBack1=testArray.SwapTLC(&dg1234); //oops! Nothing to swap with! + testArray.CommitP(rollBack1); + ) + TEST(rollBack1==NULL); + ReportNegativeResultfail(__LINE__,leaveCode,KErrNotFound); + break; + case 12: //Swap empty slot: expected result: debug: panic. In release doesn't return any information! + if (!aWrappedParams && mayPanic) + { + LaunchNegTestCall(failcase,EWsGraphicDrawerPanicBadArgument,KCategory); + } + else + { + TRAP(leaveCode, + errCode=testArray.SwapLC(&dg1234); //oops! Nothing to swap with! + User::Leave(1234); //Panics before here in debug. No leak if cleanup is taken. + ); + TEST(leaveCode==1234); //Panics before here in debug + TEST(errCode==KErrNotFound); //Panics before here in debug + } + break; + + // + default: + returnMoreTests=EFalse; + } + ResetArray(testArray); + CleanupStack::Check(markerCleanup); + __UHEAP_CHECK(0); + __UHEAP_MARKENDC(0); + testArray.Close(); +// CWsGraphicDrawerArray::testArrayValidator::ResetArray(&testArray); + CleanupStack::PopAndDestroy(markerCleanup); + return returnMoreTests; + } + +/** + @SYMTestCaseID GRAPHICS-WSERV-LeakInService-0001 + @SYMDEF DEF093926 + @SYMTestCaseDesc Check for leaks over repeated re-assignments. + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions + Repeatedly create the same bitmap instance + After a few initial wobbles in the server-side HeapCount it should not increase + 5 calls are made without checking the level, then 5 more check the level. + Note that as we are testing the main server heap, + other threads may interrupt and perform operations that change the memory figures. + + @SYMTestExpectedResults The CWsGraphicBitmap objects are created and no leaks are reported. + */ +void CTWsGraphs::DoTestLeakInServiceL() + { + INFO_PRINTF1(_L("DoTestLeakInServiceL")); + const TInt prepCount=5; + const TInt testCount=5; + + + TUid uid1 = {0x10000001}; + TUid uid2 = {0x10000002}; + + TWsGraphicId twsGraphicId1(uid1); + TEST(twsGraphicId1.Uid()==uid1); + + TWsGraphicId twsGraphicId2(uid2); + TEST(twsGraphicId2.Uid()==uid2); + + TWsGraphicId twsGraphicId3(twsGraphicId2); + TEST(twsGraphicId3.Uid()==uid2); + + TWsGraphicId twsGraphicId4(1); + twsGraphicId4.Set(uid1); + TEST(twsGraphicId4.Uid()==uid1); + + TSize screenSize = TheClient->iScreen->SizeInPixels(); + + __UHEAP_RESET; + __UHEAP_MARK; + // Create local shared CWsGraphicBitmap + // Repeat operation for any sign of memory leak... + CFbsBitmap bitmap2; + CFbsBitmap mask2; + + bitmap2.Create(screenSize,TheClient->iScreen->DisplayMode()); + mask2.Create(bitmap2.SizeInPixels(),TheClient->iScreen->DisplayMode()); + + TInt c0=TheClient->iWs.HeapCount(); + CWsGraphicBitmap* bTestX = CWsGraphicBitmap::NewL(twsGraphicId2.Uid(), &bitmap2,&mask2); + for (TInt i=0;iiWs.HeapCount(); + delete bTestX; + //TInt c3=TheClient->iWs.HeapCount(); + bTestX = CWsGraphicBitmap::NewL(twsGraphicId2.Uid(), &bitmap2,&mask2); + //TInt c4=TheClient->iWs.HeapCount(); + } + // Give WSERV a chance to settle. + TheClient->iWs.Finish(); + User::After (1000000); //1s + + TInt c1=TheClient->iWs.HeapCount(); + TInt failures=0; + for (TInt i=0;iiWs.HeapCount(); + delete bTestX; + //TInt c3=TheClient->iWs.HeapCount(); + //The heap count doesn't go down after delete operation + //because the delete message is buffered by the server, because it does not have a return value. + //Aparrently, although CWsGraphicBitmap and TheClient terminate at the same server, + //and use the same general heap (I have tested this under debug), + //they do not share the same session, so flushing TheClient does not effect CWsGraphicBitmap + bTestX = CWsGraphicBitmap::NewL(twsGraphicId2.Uid(), &bitmap2,&mask2); + + // Give WSERV a chance to settle. + TheClient->iWs.Finish(); + User::After (1000000); //1s + + TInt c4=TheClient->iWs.HeapCount(); + //Can compare immediately after allocation as the server doesn't buffer the create command. + if (!(c2==c4)) + { + if (c4 > c2) // only fail the test if the count has increased + { + failures++; + } + INFO_PRINTF2(_L("Server Heap count change accross delete/new = %i"),c4-c2); + } + } + // Outside of main loop to avoid client/wserv interaction during test. + TEST(failures==0); + TInt c5=TheClient->iWs.HeapCount(); + TEST((c1-c5)/testCount==0); //If every call leaked. + if ((c1-c5)/testCount) + { + INFO_PRINTF3(_L("Server Heap count change accross %i delete/new cycles = %i"),testCount,c5-c1); + INFO_PRINTF3(_L("Before %i / After %i"),c1,c5); + } + + delete bTestX; + + __UHEAP_CHECK(0); + __UHEAP_MARKEND; + + } +/** + @SYMTestCaseID GRAPHICS-WSERV-0381 + @SYMDEF DEF095063 + @SYMTestCaseDesc Test case for INC098114 CWsGraphicDrawer::SendMessage panics window server + @SYMTestPriority Medium + @SYMTestStatus Implemented + @SYMTestActions Enable the test flag and reproduce the defect + Action step: + -Instruct plugin to register event handler + -Draw fullscreen window (plugin will receive window visibility changed event) + -Set the test flag + -Query visibility region from plugin side + -Instruct plugin to unregister event handler + -Destroy fullscreen window (plugin will not receive window visibility changed event) + + @SYMTestExpectedResults wserv should not panic with the fix +*/ + +TestState CTWsGraphs::TestSuccessiveMessageL() + { + if (iSubState==0) + { + _LIT(KTestSuccessiveMessage, "TestSuccessiveMessage"); + INFO_PRINTF1(KTestSuccessiveMessage); + + ++iSubState; + iListen->Enable(ETrue); + CreateWindowL(); + Mem::FillZ(&iListenInfo, sizeof(TListenerInfo)); + //Set the test flag to enable the reproduction of defect + iListen->SetTestFlag(); + iListen->QueryPlugin(iListenInfo); + iListen->Enable(EFalse); + DestroyWindowL(); + return EWait; + } + + ++(iTest->iState); + iSubState = 0; + return ENext; + } + +TestState CTWsGraphs::TestWindowGroupChangeL() + { + if (iSubState==0) + { + _LIT(KTestWindowGroupChange, "TestWindowGroupChange"); + INFO_PRINTF1(KTestWindowGroupChange); + + ++iSubState; + iListen->Enable(ETrue); + CreateWindowL(); + Mem::FillZ(&iListenInfo, sizeof(TListenerInfo)); + iListen->QueryPlugin(iListenInfo); + return EWait; + } + + if (iSubState==1) + { + ++iSubState; + iOriginalWindowGroupId = iListenInfo.iWindowGroupId; + iNewWin = CCrWin::NewL(iTest->iScreenNumber, ETrue); + iListen->QueryPlugin(iListenInfo); + return EWait; + } + + TEST(iListenInfo.iWindowGroupId != iOriginalWindowGroupId); + + delete iNewWin; + iNewWin = NULL; + iListen->Enable(EFalse); + DestroyWindowL(); + ++(iTest->iState); + iSubState = 0; + return ENext; + } + +/** + @SYMTestCaseID GRAPHICS-WSERV-0382 + @SYMDEF INC085451 + @SYMTestCaseDesc Test Animation frame rate + @SYMTestPriority Medium + @SYMTestStatus Implemented + @SYMTestActions Simulate an Animation artwork by calling DrawWsGraphic and DoDraw. + Action step: + -Calls DrawWsGraphic for two different animations with different frame rates + -Retrieve the frame count for two differnt frames per seconds + -Test the two frame rate shouldn't be same. + + @SYMTestExpectedResults Animation Frame rate should be different for different frames per second +*/ +TestState CTWsGraphs::TestFrameRateL() + { + //Check for Transparency enabled in wsini.ini + if (TransparencySupportedL()==KErrNotSupported) + { + ++(iTest->iState); + return ENext; + } + + // flush transparent window destruction created in TransparencySupportedL before + // proceeding with the test + TheClient->iWs.Flush(); + + //Here iSubState is 0, when this functions executes first time + // iSubState is 1 means the call is from a callback function. + if(iSubState == 0) + { + _LIT(KTestFrameRate, "TestFrameRate"); + INFO_PRINTF1(KTestFrameRate); + + ++iSubState; + iTestframerate = CGraphicTestFrameRate::NewL(iTest->iScreenNumber); + + //Set the callback function + iTestframerate->SetCallBack(TCallBack(CTWsGraphs::PluginCallBack,this)); + + //Create the window and call the graphic animation + CreateWindowL(EFalse); + iWin->DrawGraphic(iTestframerate->Id().Id()); + return EWait; + } + + //PeterI wait a while for animations to redraw then query the plugin + User::After(2000000); + TheClient->iWs.Flush(); + TheClient->WaitForRedrawsToFinish(); + TheClient->iWs.Finish(); + + //Invoke the plug-in and get the counter value + Mem::FillZ(&iAnimCount, sizeof(TAnimRate)); + + iTestframerate->QueryPlugin(iAnimCount); + TheClient->iWs.Flush(); + TheClient->WaitForRedrawsToFinish(); + TheClient->iWs.Finish(); + + //Compare and test the total frame rate for two different frame counts.... + TEST((iAnimCount.iAnim1>0 && iAnimCount.iAnim2>0) && iAnimCount.iAnim1 !=iAnimCount.iAnim2); + if(iSubState == 1) + { + DestroyWindowL(); + delete iTestframerate; + } + ++(iTest->iState); + iSubState = 0; + return ENext; + } + +/** + @SYMTestCaseID GRAPHICS-WSERV-0438 + @SYMDEF INC103472 + @SYMTestCaseDesc CRedrawRegion::ContainsDrawers does not look for all drawers + @SYMTestPriority Medium + @SYMTestStatus Implemented + @SYMTestActions Create ECom-plugins to enable the scenario, in which there is one simple and one container drawer. + In the container drawer, two other simple drawers are enabled. Each drawer draws a coloured ellipse. + In this case, when the contained drawer is requested to change the colour of the ellipse, the screen will not be updated + without the fix. + Action step: + -Create four CRP graphics. + -Call the simple drawer and container drawer to draw ellipses. The container drawer + also enables two other simple drawers to draw ellipses in different colors. + -Update the color of each ellipse in turn. + -Check that the screen display is as required. + @SYMTestExpectedResults The colour of each ellipse residing in the drawers is successfully updated. Those for the contained drawers wont be updated without the fix. +*/ +void CTWsGraphs::TestNestedDrawerCRP() + { + _LIT(KTestContainDrawer, "Test INC103472: A Contained Drawer"); + INFO_PRINTF1(KTestContainDrawer); + + RWindow window1(TheClient->iWs); + CleanupClosePushL(window1); + User::LeaveIfError(window1.Construct(*TheClient->iGroup->GroupWin(), ENullWsHandle)); + + window1.EnableRedrawStore(ETrue); // Force to enable the redraw storing + window1.SetRequiredDisplayMode(EColor256); // Do not set window size here to avoid hardware test failure + window1.SetBackgroundColor(KRgbDarkGreen); + window1.Activate(); + + // A simple graphic + CWsSimpleGraphicBitmap* wsGraphic1 = CWsSimpleGraphicBitmap::NewL(KSimpleDrawerInterfaceId); + CleanupStack::PushL(wsGraphic1); + // A container graphic + CWsContainGraphicBitmap* wsGraphic2 = CWsContainGraphicBitmap::NewL(KContainDrawerInterfaceId); + CleanupStack::PushL(wsGraphic2); + // A contained graphic residing in the container graphic wsGraphic2 + CWsSimpleGraphicBitmap* wsGraphic3 = CWsInvisibleGraphicBitmap1::NewL(KInvisibleDrawerInterfaceId1); + CleanupStack::PushL(wsGraphic3); + // A contained graphic residing in the container graphic wsGraphic2 + CWsSimpleGraphicBitmap* wsGraphic4 = CWsInvisibleGraphicBitmap2::NewL(KInvisibleDrawerInterfaceId2); + CleanupStack::PushL(wsGraphic4); + + window1.Invalidate(); + window1.BeginRedraw(); + TheClient->iGc->Activate(window1); + TheClient->iGc->Clear(); + // Call CRP drawer to draw the coloured ellipses + TheClient->iGc->DrawWsGraphic(wsGraphic1->Id(),TRect(TPoint(20,20),TSize(300,100))); + TheClient->iGc->DrawWsGraphic(wsGraphic2->Id(),TRect(TPoint(20,100),TSize(300,100))); + + TheClient->iGc->Deactivate(); + window1.EndRedraw(); + TheClient->Flush(); + + // Update the colour of four ellipses residing in four CRP drawers. + TInt err = wsGraphic1->UpdateColor(KRgbRed); + TEST(KErrNone == err); + err = wsGraphic2->UpdateColor(KRgbDarkBlue); + TEST(KErrNone == err); + // If the fix is not inserted, the colour of the third and fourth ellipses residing in the contained drawers wont be updated + err = wsGraphic3->UpdateColor(KRgbDarkMagenta); + TEST(KErrNone == err); + err = wsGraphic4->UpdateColor(KRgbDarkCyan); //won't change the displayed color if there is a right place for flush() + TEST(KErrNone == err); + + TheClient->Flush(); + // Force some delays to wait until the color change + User::After(2000000); + // Test whether the screen content is changed as required + CheckResult(); + CleanupStack::PopAndDestroy(5,&window1); + } + +// Check the screen display with the reference bitmap to ensure the color to be updated correctly +void CTWsGraphs::CheckResult() + { + TSize size = TSize(320,200);//The maximum size of the screen content we are looking at + + // Create a reference bitmap + CFbsBitmap* bitmapRef = new(ELeave) CFbsBitmap; + CleanupStack::PushL(bitmapRef); + User::LeaveIfError(bitmapRef->Create(size, EColor256)); + CFbsBitGc* gc; + CFbsBitmapDevice* bitmapDev = CFbsBitmapDevice::NewL(bitmapRef); + TEST(bitmapDev!=NULL); + CleanupStack::PushL(bitmapDev); + User::LeaveIfError(bitmapDev->CreateContext(gc)); + CleanupStack::PushL(gc); + gc->SetBrushStyle(CGraphicsContext::ESolidBrush); + gc->SetBrushColor(KRgbDarkGreen); + gc->Clear(TRect(TPoint(0,0), size));//background dark green + gc->SetBrushStyle(CGraphicsContext::ESolidBrush); + gc->SetBrushColor(KRgbRed); + gc->DrawEllipse(TRect(TPoint(20,20),TSize(300,100))); //map to the simple drawer + gc->SetBrushStyle(CGraphicsContext::ESolidBrush); + gc->SetBrushColor(KRgbDarkBlue); + gc->DrawEllipse(TRect(TPoint(20,100),TSize(300,100))); //map to the container drawer + gc->SetBrushStyle(CGraphicsContext::ESolidBrush); + gc->SetBrushColor(KRgbDarkMagenta); + gc->DrawEllipse(TRect(TPoint(100,150),TSize(50,50))); //map to the contained drawer + gc->SetBrushStyle(CGraphicsContext::ESolidBrush); + gc->SetBrushColor(KRgbDarkCyan); + gc->DrawEllipse(TRect(TPoint(200,150),TSize(50,50))); //map to the contained drawer + TInt bitmapHeight = bitmapRef->SizeInPixels().iHeight; + TInt bitmapWidth = bitmapRef->SizeInPixels().iWidth; + + // Copy the screen content to bitmap + INFO_PRINTF1(_L("Capture screen content.")); + CFbsBitmap* screenBitmap = new(ELeave) CFbsBitmap(); + CleanupStack::PushL(screenBitmap); + User::LeaveIfError(screenBitmap->Create(size, TheClient->iScreen->DisplayMode())); + TRect rct = TRect(TPoint(0,0), size); + User::LeaveIfError(TheClient->iScreen->CopyScreenToBitmap(screenBitmap,rct)); + + // Compare the displayed bitmap against the reference one + INFO_PRINTF1(_L("Compare the displayed bitmap against the expected one.")); + TInt lineLength=bitmapRef->ScanLineLength(bitmapWidth, EColor256); + HBufC8* compareLineBuf=HBufC8::NewLC(lineLength); + TPtr8 compareLinePtr(compareLineBuf->Des()); + HBufC8* screenLineBuf=HBufC8::NewLC(lineLength); + TPtr8 screenLinePtr(screenLineBuf->Des()); + for (TInt index=0; indexGetScanLine(compareLinePtr, TPoint(0,index), bitmapWidth, EColor256); + screenBitmap->GetScanLine(screenLinePtr, TPoint(0,index),bitmapWidth, EColor256); + TInt compareResult=compareLinePtr.Compare(screenLinePtr); + if (compareResult!=0) + { + INFO_PRINTF2(_L("Scanline compare failed: %d"),index); + TEST(EFalse); + break; + } + } + CleanupStack::PopAndDestroy(6,bitmapRef); + + } + +void ResetScreenMode(TAny* aAny) + { + CWsScreenDevice* screen=static_cast(aAny); + screen->SetScreenMode(0); + screen->SetAppScreenMode(0); + } + +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + +void CTWsGraphs::TestScreenModeChangeL() + { + _LIT(KLog,"Screen Doesn't match bitmap. Size=(%d,%d) winSizeMode=%d redrawMode=%d modeIndex=%d"); +// A simple CRP graphic to draw in the test + CWsSimpleGraphicBitmap* wsGraphic1=CWsSimpleGraphicBitmap::NewL(KSimpleDrawerInterfaceId); + CleanupStack::PushL(wsGraphic1); + RWindow testWin(TheClient->iWs); + CleanupClosePushL(testWin); + User::LeaveIfError(testWin.Construct(*TheClient->iGroup->GroupWin(),0xbadbad)); + testWin.SetRequiredDisplayMode(EColor64K); + testWin.Activate(); +// Cleanup display mode by setting back to 0 if we leave in the tests + CleanupStack::PushL(TCleanupItem(ResetScreenMode,TheClient->iScreen)); + TInt numScreenModes=TheClient->iScreenModes.Count(); + TBool match; + + for(TInt winSizeMode=0;winSizeMode<2;winSizeMode++) + { // Two size modes, fullScreen and non-full screen + for(TInt redrawMode=0;redrawMode<2;redrawMode++) + { // Two redraw modes to test drawing inside and outside of a redraw. + const TBool drawInsideRedraw=(redrawMode==0); + for(TInt modeIndex=0;modeIndexiScreenModes[modeIndex]; + const TPoint origin=TheClient->iScreen->GetScreenModeScaledOrigin(screenMode); + if (origin.iX!=0 || origin.iY!=0) + continue; + // Enable redirection before changing screen mode as this is what we are testing + iRedir->Redirect(CWsRedir::EFrontBuffer, ETrue); + TheClient->iScreen->SetAppScreenMode(screenMode); + TheClient->iScreen->SetScreenMode(screenMode); + + TPixelsAndRotation sizeAndRotation; + TheClient->iScreen->GetDefaultScreenSizeAndRotation(sizeAndRotation); +// + TSize screenSize(TheClient->iScreen->SizeInPixels()); + if(sizeAndRotation.iRotation == CFbsBitGc::EGraphicsOrientationRotated90 || + sizeAndRotation.iRotation == CFbsBitGc::EGraphicsOrientationRotated270) + { + screenSize.iWidth = Min(screenSize.iWidth, 240);//to make sure we won't exceed physical screen size + } + TSize winSize(screenSize); + TPoint winPos; + if (winSizeMode==1) + { + winSize.iWidth=winSize.iWidth*2/3; + winSize.iHeight=winSize.iHeight*3/4; + winPos.iX=(screenSize.iWidth-winSize.iWidth)/4; + winPos.iY=(screenSize.iHeight-winSize.iHeight)*3/4; + } + testWin.SetExtent(winPos,winSize); + TSize halfSize(winSize.iWidth/2,winSize.iHeight); + TRect leftHalf(halfSize); + TRect rightHalf(TPoint(halfSize.iWidth,0),halfSize); + TRect leftEllipse(leftHalf); + leftEllipse.Shrink(4,4); + TRect rightEllipse(rightHalf); + rightEllipse.Shrink(4,4); + // Draw half the screen with redirection on, should only go to redirection test bitmap + // Then draw again with redirection off, this time should go to the screen + // The two steps are drawn with the color of the left/right rectangles swapped. + for(TInt drawStep=0;drawStep<2;drawStep++) + { + TRgb leftColor; + TRgb rightColor; + if (drawStep==0) + { + leftColor=KRgbGreen; + rightColor=KRgbRed; + } + else + { // Turn re-direction off for second time around loop + iRedir->Redirect(CWsRedir::EFrontBuffer, EFalse); + leftColor=KRgbRed; + rightColor=KRgbGreen; + } + testWin.Invalidate(); + testWin.BeginRedraw(); + if (!drawInsideRedraw) + testWin.EndRedraw(); + CWindowGc* testWinGc=TheClient->iGc; + testWinGc->Activate(testWin); + testWinGc->SetBrushColor(leftColor); + testWinGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + testWinGc->DrawRect(leftHalf); + // Call CRP drawer to draw the coloured ellipses + TheClient->iGc->DrawWsGraphic(wsGraphic1->Id(),leftEllipse); + testWinGc->SetBrushColor(rightColor); + testWinGc->DrawRect(rightHalf); + TheClient->iGc->DrawWsGraphic(wsGraphic1->Id(),rightEllipse); + testWinGc->Deactivate(); + if (drawInsideRedraw) + testWin.EndRedraw(); + TheClient->iWs.Flush(); + } + // We now check that the left rect of the re-directed drawing matches the right half + // of the on-screen drawing + CFbsBitmap* screenCopy=new(ELeave) CFbsBitmap; + CleanupStack::PushL(screenCopy); + User::LeaveIfError(screenCopy->Create(screenSize, EColor64K)); + TheClient->iScreen->CopyScreenToBitmap(screenCopy); + match=CompareBitmapArea16Bpp(iFrontCopy,winPos,screenCopy,TPoint(winPos.iX+rightHalf.iTl.iX,winPos.iY),halfSize); + TEST(match); + if (!match) + LOG_MESSAGE6(KLog,screenSize.iWidth,screenSize.iHeight,winSizeMode,redrawMode,modeIndex); + // As a double check also check the right half of the off-screen drawing matches the + // on-screen left half. + match=CompareBitmapArea16Bpp(iFrontCopy,TPoint(winPos.iX+rightHalf.iTl.iX,winPos.iY),screenCopy,winPos,halfSize); + TEST(match); + if (!match) + LOG_MESSAGE6(KLog,screenSize.iWidth,screenSize.iHeight,winSizeMode,redrawMode,modeIndex); + CleanupStack::PopAndDestroy(screenCopy); + } + } + } + CleanupStack::PopAndDestroy(3,wsGraphic1); + + TEST(iNotify1->iResult); + if(iNotify1->iResult==EFalse) + { + INFO_PRINTF1(iNotify1->iError); + } + TEST(iNotify2->iResult); + if(iNotify1->iResult==EFalse) + { + INFO_PRINTF1(iNotify2->iError); + } + } + +#endif // TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + +/** +@SYMTestCaseID GRAPHICS-WSERV-0443 + +@SYMDEF INC109263 + +@SYMTestCaseDesc TWindowServerEvent::NotifyDrawer can refer to a deleted array index causing a crash + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Cause an event that will generate the following behaviour through TWindowServerEvent::NotifyDrawer() + + The for loop performs the following: + 0) Drawer handler 1: Remove handle 1 ; Drawer handler 2: Do nothing + 1) Drawer handler 1: Remove handle 1,Add handle 1 ; Drawer handler 2: Do nothing + 2) Drawer handler 1: Add handle 1 ; Drawer handler 2: Do nothing + 3) Drawer handler 1: Remove handle 2 ; Drawer handler 2: Do nothing + 4) Drawer handler 1: Remove handle 2,Add handle 2 ; Drawer handler 2: Do nothing + 5) Drawer handler 1: Add handle 2 ; Drawer handler 2: Do nothing + 6) Drawer handler 1: Remove handle 1,Remove handle 2 ; Drawer handler 2: Do nothing + + Repeat with handlers 1 and 2 swapped + +@SYMTestExpectedResults Loops through TWindowServerEvent::NotifyDrawer() should complete without crashing wserv +*/ + +void CTWsGraphs::TestNotifyRemoval() + { + _LIT(KTestEventNotification, "TestDrawerEventHandler"); + INFO_PRINTF1(KTestEventNotification); + ++iSubState; + + for (TInt ii = 0; iiSetBehaviour(ii); //Enable this plugin and set it to an event handling method + iNotify2->SetBehaviour(KNotifyDoNothing); //Add a second drawer handler which is enabled but does nothing + CreateWindowL(); //Change visibility activating the event handlers - Fails if wserv crashes! + iNotify1->SetBehaviour(KNotifyDisable); //Disable plugin if still enabled + iNotify2->SetBehaviour(KNotifyDisable); //Disable plugin if still enabled + DestroyWindowL(); + } + INFO_PRINTF1(_L("Swap handlers")); + for (TInt ii = 0; iiSetBehaviour(KNotifyDoNothing); //Add a first drawer handler which is enabled but does nothing + iNotify1->SetBehaviour(ii); //Enable this plugin and set it to an event handling method + CreateWindowL(); //Change visibility activating the event handlers - Fails if wserv crashes! + iNotify2->SetBehaviour(KNotifyDisable); //Disable plugin if still enabled + iNotify1->SetBehaviour(KNotifyDisable); //Disable plugin if still enabled + DestroyWindowL(); + } + + TEST(ETrue); // If the test has failed WServ will have paniced. + } + +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA +/** +@SYMTestCaseID GRAPHICS-WSERV-0491 +@SYMPREQ PREQ39 +@SYMTestPriority High +@SYMTestCaseDesc Draw using a ECom-plugin which has direct access to the screen/OSB buffer +@SYMTestActions Create the plugin + Draw using the plugin + Update the position of the white line to line 70 and test + Update the position of the white line to line 80 and test +@SYMTestExpectedResults White lines are drawn on the correct positions. +*/ +void CTWsGraphs::TestMWsUiBufferL() + { + const TInt KWhiteLinePos = 70; + const TRect KBlueRect(TPoint(50,50),TSize(100,100)); + + // Construct and setup window to be drawn to + RWindow window1 = RWindow(TheClient->iWs); + CleanupClosePushL(window1); + User::LeaveIfError(window1.Construct(*TheClient->iGroup->GroupWin(),ENullWsHandle)); + TSize winSize=TSize(TheClient->iScreen->SizeInPixels()); + window1.SetExtent(TPoint(0,0),winSize); + window1.Activate(); + + CWsBufferGraphic* graphic = CWsBufferGraphic::NewL(); + CleanupStack::PushL(graphic); + + // Draw inital drawing with a Crp which is blue rect and a white line at line 0 + TheGc->Activate(window1); + TheGc->Clear(); + window1.BeginRedraw(); + TheGc->DrawWsGraphic(graphic->Id(),KBlueRect); + window1.EndRedraw(); + TheGc->Deactivate(); + + TheClient->iWs.Finish(); + User::After(2000000); + + // Update the position of the white line to line 70 + INFO_PRINTF1(_L("Update position of white line to line 70")); + graphic->UpdateWhiteLinePos(KWhiteLinePos); + TheClient->iWs.Finish(); + // Force some delays to wait until the line position changes + User::After(2000000); + //Test white line has been drawn and is in the correct postion + TBool res1 = IsWhiteLine(KWhiteLinePos); + TEST(res1); + + // Update the position of the white line to line 80 + INFO_PRINTF1(_L("Update position of white line to line 80")); + graphic->UpdateWhiteLinePos(KWhiteLinePos+10); + TheClient->iWs.Finish(); + // Force some delays to wait until the line position changes + User::After(2000000); + // Test white line has been drawn and is in the correct postion + TBool res2 = IsWhiteLine(KWhiteLinePos+10); + TEST(res2); + + graphic->Destroy(); + CleanupStack::PopAndDestroy(2, &window1); + } + +// Test whether a line is completely white +TBool CTWsGraphs::IsWhiteLine(TInt aWhiteLinePos) + { + TRgb color; + TPoint pixel; + + for(TInt xPos = 0; xPos < TheClient->iScreen->SizeInPixels().iWidth; xPos++) + { + pixel = TPoint(xPos,aWhiteLinePos); + TheClient->iScreen->GetPixel(color,pixel); + if(color.Red() != 255 && color.Blue() != 255 && color.Green() != 255) + { + return EFalse; + } + } + return ETrue; + } +#endif //TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA + +/** + DoTestL() method, called by the WSERV Test Framework. +*/ +void CTWsGraphs::RunTestCaseL(TInt /*aCurTestCase*/) + { + _LIT(KTest1,"DoTestWsGraphics"); + _LIT(KTest2,"DoTestOOMWsGraphics"); + _LIT(KTest3,"Interface Extension"); + _LIT(KTest4,"Screen Redirection"); + _LIT(KTest5,"TextCursor1"); + _LIT(KTest6,"TextCursor2"); + _LIT(KTest7,"Flicker Redirection"); + _LIT(KTest8,"Event Notification"); + _LIT(KTest9,"Successive Message"); + _LIT(KTest10,"Redirection Using WsBackBuffer"); + _LIT(KTest11,"Group Change"); + _LIT(KTest12,"Frame Rate"); + _LIT(KTest13,"Leak In Service"); + _LIT(KTest14,"Add/Swap GDArray"); + _LIT(KTest15,"Nested Drawer CRP"); + _LIT(KTest16,"Notify Removal"); + _LIT(KTest17,"Screen Mode Change"); + _LIT(KTest18,"UI Buffer"); + _LIT(KTest19,"Graphics Drawer Coverage"); + CFbsBitmap bitmap1; + CFbsBitmap mask1; + CWsGraphicBitmap* bTest=NULL; + TSize screenSize=TheClient->iScreen->SizeInPixels(); + + bitmap1.Create(screenSize,TheClient->iScreen->DisplayMode()); + mask1.Create(screenSize,TheClient->iScreen->DisplayMode()); + ((CTWsGraphsStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); + + switch(++iTest->iState) + { + case 1: +/** + @SYMTestCaseID GRAPHICS-WSERV-0528 +*/ + ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0528")); + // Launch new process with PROTSERV capability to run CWSGraphics tests in + iTest->LogSubTest(KTest1); + // This process only launches succesfully when _DEBUG is defined for the build, because it depends + // on the existance of debug macros such as _UHEAP_MARK, _UHEAP_MARKEND, _UHEAP_FAILNEXT, ... etc + LaunchNewProcess(KTestExe); + break; + case 2: + { + /** + @SYMTestCaseID GRAPHICS-WSERV-0017 + + @SYMPREQ PREQ1246 + + @SYMDEF DEF081259 + + @SYMTestCaseDesc Out of memery test when creating a CWsGraphic. + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions Out of memory test when creating a CWsGraphic. + + @SYMTestExpectedResults Whenever an API call fails, it should leave the number + of allocated heap cells unchanged. + */ + ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0017")); + + iTest->LogSubTest(KTest2); + TInt failRate; + for(failRate=1;;failRate++) + { + __UHEAP_RESET; + __UHEAP_SETFAIL(RHeap::EDeterministic,failRate); + __UHEAP_MARK; + + TRAPD(ret,bTest=CWsGraphicBitmap::NewL(&bitmap1,&mask1)); + TEST((ret==KErrNone || ret==KErrNoMemory)); + if (ret!=KErrNone && ret!=KErrNoMemory) + { + _LIT(KLog,"Failed to create CWsGraphicBitmap error=%d"); + LOG_MESSAGE2(KLog,ret); + } + if (ret!=KErrNone) + { + __UHEAP_MARKEND; + } + else + { + TEST(bTest!=NULL); + if (bTest==NULL) + { + _LIT(KLog,"Object creation didn't leave but returned NULL"); + LOG_MESSAGE(KLog); + } + delete bTest; + bTest=NULL; + __UHEAP_MARKEND; + TLogMessageText logMessageText; + _LIT(KSet,"OOM test succeds after %d allocations."); + logMessageText.Format(KSet,failRate); + LOG_MESSAGE(logMessageText); + break; + } + } + __UHEAP_RESET; + } + break; + case 3: + iTest->LogSubTest(KTest3); + ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0371")); +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + + if (TestInterfaceExtensionL()==EWait) + --iTest->iState; +#endif + break; + case 4: + iTest->LogSubTest(KTest4); + ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0372")); +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + if (TestScreenRedirectionL()==EWait) + --iTest->iState; +#endif + break; + case 5: + iTest->LogSubTest(KTest5); + ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0363")); +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + if (TestTextCursorUnderRedirectionL(ETestStandardTextCursor) == EWait) + --iTest->iState; +#endif + break; + case 6: + iTest->LogSubTest(KTest6); + ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0363")); +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + if (TestTextCursorUnderRedirectionL(ETestCustomTextCursor) == EWait) + --iTest->iState; +#endif + break; + case 7: + iTest->LogSubTest(KTest7); + ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0376")); +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + if (TestFlickerRedirectionL()==EWait) + --iTest->iState; +#endif + break; + case 8: + ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0378")); + iTest->LogSubTest(KTest8); + if (TestEventNotificationL()==EWait) + --iTest->iState; + break; + case 9: + ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0381")); + iTest->LogSubTest(KTest9); + if (TestSuccessiveMessageL()==EWait) + --iTest->iState; + break; + case 10: + iTest->LogSubTest(KTest10); + ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0527")); +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + if(TestRedirectionUsingWsBackBufferL()==EWait) + --iTest->iState; +#endif + break; + case 11: +/** + @SYMTestCaseID GRAPHICS-WSERV-0529 +*/ + ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0529")); + iTest->LogSubTest(KTest11); + if(TestWindowGroupChangeL()==EWait) + --iTest->iState; + break; + case 12: + ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0382")); + iTest->LogSubTest(KTest12); + if(TestFrameRateL()==EWait) + --iTest->iState; + break; + case 13: + ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-LeakInService-0001")); + iTest->LogSubTest(KTest13); + DoTestLeakInServiceL(); + break; + case 14: + ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-NegAddSwapGDArray-0001")); + iTest->LogSubTest(KTest14); + TestAddSwapGDArrayL(); + break; + case 15: + ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0438")); + iTest->LogSubTest(KTest15); + TestNestedDrawerCRP(); + break; + case 16: + ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0443")); + iTest->LogSubTest(KTest16); + TestNotifyRemoval(); + break; + case 17: + iTest->LogSubTest(KTest17); + ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0530")); +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA +/** + @SYMTestCaseID GRAPHICS-WSERV-0530 +*/ + + TestScreenModeChangeL(); +#endif + break; + case 18: + iTest->LogSubTest(KTest18); + ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0491")); +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA + + TestMWsUiBufferL(); +#endif + break; + case 19: + iTest->LogSubTest(KTest19); +/** + @SYMTestCaseID GRAPHICS-WSERV-0531 +*/ + ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0531")); + TestGraphicDrawerCoverage(); + break; + default: + ((CTWsGraphsStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + ((CTWsGraphsStep*)iStep)->CloseTMSGraphicsStep(); + TestComplete(); + break; + } + ((CTWsGraphsStep*)iStep)->RecordTestResultL(); + } + +__WS_CONSTRUCT_STEP__(WsGraphs) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/TWSGRAPHS.H --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/TWSGRAPHS.H Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,172 @@ + +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef __TWSGRAPHS_H__ +#define __TWSGRAPHS_H__ + +#include +#include +#include "../tlib/testbase.h" +#include "AUTO.H" +#include "W32STDGRAPHIC.H" +#include "wsredir.h" +#include "wslisten.h" +#include "TGraphicsHarness.h" +#include "wsframerate.h" +#include "wscontaindrawer.h" +#include "wssimpledrawer.h" +#include "listener.h" +#include "wsgdcov.h" + +// +class CCrWin: public CBase + { +public: + static CCrWin* NewL(TInt aScreenId,TBool aDraw=ETrue); + ~CCrWin(); + void DrawFirstHalf(); + void DrawSecondHalf(); + void DrawGraphic(TInt aWsId=0); + void SetTextCursor(const TPoint &aPos, const TTextCursor &aCursor); + void CancelTextCursor(); +private: + void ConstructL(TInt aScreenId,TBool aDraw); + void Draw(); +private: + RWsSession iWs; + CWsScreenDevice* iScr; + RWindowGroup iGroup; + RWindow iWin; + CWindowGc* iGc; + }; + +class CCrAlphaWin: public CBase + { +public: + static CCrAlphaWin* NewL(TInt aScreenId); + ~CCrAlphaWin(); +private: + void ConstructL(TInt aScreenId); +private: + RWsSession iWs; + CWsScreenDevice* iScr; + RWindowGroup iGroup; + RWindow iWin; + }; + +class CTWsGraphs : public CTWsGraphicsBase + { +public: + enum TTestCursorType + { + ETestStandardTextCursor, + ETestCustomTextCursor + }; +public: + CTWsGraphs(CTestStep* aStep); + ~CTWsGraphs(); + void ConstructL(); +public: // list of test cases + void LaunchNewProcess(const TDesC& aExecutable); +protected: +//from CTGraphicsStep + virtual void RunTestCaseL(TInt aCurTestCase); + +private: +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + TestState TestInterfaceExtensionL(); + TestState TestScreenRedirectionL(); + TestState TestTextCursorUnderRedirectionL(TTestCursorType aCursorType); + TestState TestFlickerRedirectionL(); + TestState TestRedirectionUsingWsBackBufferL(); + void TestScreenModeChangeL(); +#endif + TestState TestEventNotificationL(); + void TestAddSwapGDArrayL(); + TestState TestSuccessiveMessageL(); + void ReportNegativeResultfail(TInt aLine,TInt aResult,TInt aExpectedResult); + void DoTestLeakInServiceL(); + void TestNestedDrawerCRP(); + void CheckResult(); + void TestNotifyRemoval(); + TestState TestWindowGroupChangeL(); + TestState TestFrameRateL(); + static TInt PluginCallBack(TAny* aArg); + void CreateWindowL(TBool aDraw=ETrue); + void DestroyWindowL(); + void CreateAlphaWindowL(); + void DestroyAlphaWindowL(); + TBool CompareBitmapArea16Bpp(CFbsBitmap* aBmp1, const TPoint& aPos1, CFbsBitmap* aBmp2, const TPoint& aPos2, const TSize& aSize); + + TBool PosTestAddSwapGDArrayL(TInt testcase); + struct WrapTestCall; + TBool NegTestAddSwapGDArrayL(TInt failcase,WrapTestCall*aWrappedParams=NULL); + static TInt DoNegTestCall(TInt /*aInt*/, TAny *aPtr); + TBool LaunchNegTestCall(TUint aTestCount,TUint aPanicCode,const TDesC &aPanicCategory); + TestState TestGraphicDrawerCoverage(); + // For WsBuffer CRP tests +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA + void TestMWsUiBufferL(); + TBool IsWhiteLine(TInt aWhiteLinePos); +#endif + +private: +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + CWsRedir* iRedir; + CFbsBitmap* iFrontCopy; + CFbsBitmap* iBackCopy; + TRedirectorInfo iRedirInfo; + CFbsBitmap* iBefore; + CFbsBitmap* iAfter; + TTextCursor iTextCursor; + RArray iSpriteMemberArray; +#endif + CWsListen* iListen; + CWsNotify* iNotify1; + CWsNotify* iNotify2; + TListenerInfo iListenInfo; + TInt iSubState; + CCrWin* iWin; + CCrAlphaWin* iAlpha; + TInt iOriginalWindowGroupId; + CCrWin* iNewWin; + CGraphicTestFrameRate* iTestframerate; + TAnimRate iAnimCount; + CWsGdCoverage* iGdCoverage; + }; + +class CTWsGraphsStep : public CTGraphicsStep + { +public: + CTWsGraphsStep(); + +protected: + //from CTGraphicsStep + virtual CTGraphicsBase* CreateTestL(); + }; + + + +_LIT(KTWsGraphsStep,"TWsGraphs"); + + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/colorblender.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/colorblender.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,60 @@ +// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#include "colorblender.h" +#include +#include +#include + +CColorBlender* CColorBlender::NewLC(TDisplayMode aDisplayMode) + { + CColorBlender* self = new(ELeave) CColorBlender; + CleanupStack::PushL(self); + self->iBitmap = new(ELeave) CFbsBitmap; + User::LeaveIfError(self->iBitmap->Create(TSize(1, 1), aDisplayMode)); + self->iDevice = CFbsBitmapDevice::NewL(self->iBitmap); + self->iGc = CFbsBitGc::NewL(); + self->iGc->Activate(self->iDevice); + return self; + } + +CColorBlender::~CColorBlender() + { + delete iBitmap; + delete iDevice; + delete iGc; + } + +void CColorBlender::SetInitialColor(TRgb aColor) + { + iGc->SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); + iGc->SetBrushColor(aColor); + iGc->Clear(); + iGc->SetDrawMode(CGraphicsContext::EDrawModePEN); + } + +void CColorBlender::Blend(TRgb aColor) + { + iGc->SetBrushColor(aColor); + iGc->Clear(); + } + +TRgb CColorBlender::Color() const + { + TRgb color; + iBitmap->GetPixel(color, TPoint(0, 0)); + return color; + } + diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/colorblender.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/colorblender.h Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,39 @@ +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#ifndef __COLORBLENDER_H__ +#define __COLORBLENDER_H__ + +#include + +class CFbsBitGc; +class CFbsBitmap; +class CFbsBitmapDevice; + +class CColorBlender : public CBase + { +public: + static CColorBlender* NewLC(TDisplayMode aDisplayMode); + ~CColorBlender(); + void SetInitialColor(TRgb aColor); + void Blend(TRgb aColor); + TRgb Color() const; +private: + CFbsBitmap* iBitmap; + CFbsBitmapDevice* iDevice; + CFbsBitGc* iGc; + }; + +#endif //__COLORBLENDER_H__ diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/config/graphics-wserv-autotest.ini --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/config/graphics-wserv-autotest.ini Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,4 @@ +//This ini file is used to set the screen number for the wserv autotests using a function called GetScreenFromIni(). + +[useScreen] +screen=1 \ No newline at end of file diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/directgdigcwrapper.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/directgdigcwrapper.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,521 @@ +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#include "directgdigcwrapper.h" +#include "mwsgraphicscontexttodirectgdimappings.h" +#include +#include "stdpanic.h" +#include +#include +#include + +void Panic(TStdPluginPanic aPanic) + { + _LIT(KStdPanicCategory, "WSERV-TEST-PLUGIN"); + User::Panic(KStdPanicCategory, aPanic); + } + +CDirectGdiGcWrapper* CDirectGdiGcWrapper::NewL(RDirectGdiImageTarget& aTarget) + { + CDirectGdiGcWrapper* self = new(ELeave) CDirectGdiGcWrapper; + CleanupStack::PushL(self); + CDirectGdiDriver* driver = CDirectGdiDriver::Static(); + User::LeaveIfNull(driver); + self->iContext = CDirectGdiContext::NewL(*driver); + TInt err = self->iContext->Activate(aTarget); + User::LeaveIfError(err); + self->iErrorCode = KErrNone; + self->iGcBuf = CBufSeg::NewL(512); + //MWsFader + //Default in BitGdi was 128 for the blackMap and 255 for the whiteMap + //SetFadingParameters shows how the fade color is computed + self->iFadeColor.SetInternal(0x80FFFFFF); + + self->iLut = PtrTo16BitNormalisationTable(); + CleanupStack::Pop(self); + return self; + } + +CDirectGdiGcWrapper::~CDirectGdiGcWrapper() + { + delete iContext; + delete iGcBuf; + iClippingRegion.Close(); + } + +void CDirectGdiGcWrapper::BitBlt(const TPoint& aDestPos, const CFbsBitmap& aSourceBitmap) + { + iContext->BitBlt(aDestPos, aSourceBitmap); + } + +void CDirectGdiGcWrapper::BitBlt(const TPoint& aDestPos, const CFbsBitmap& aSourceBitmap, const TRect& aSourceRect) + { + iContext->BitBlt(aDestPos, aSourceBitmap, aSourceRect); + } + +void CDirectGdiGcWrapper::BitBltMasked(const TPoint& aDestPos, const CFbsBitmap& aSourceBitmap, const TRect& aSourceRect, const CFbsBitmap& aMaskBitmap, TBool aInvertMask) + { + iContext->BitBltMasked(aDestPos, aSourceBitmap, aSourceRect, aMaskBitmap, aInvertMask); + } + +void CDirectGdiGcWrapper::BitBltMasked(const TPoint& aDestPos, const CFbsBitmap& aSourceBitmap, const TRect& aSourceRect, const CFbsBitmap& aMaskBitmap, const TPoint& aMaskPos) + { + iContext->BitBltMasked(aDestPos, aSourceBitmap, aSourceRect, aMaskBitmap, aMaskPos); + } + +void CDirectGdiGcWrapper::ResetClippingRegion() + { + iContext->ResetClippingRegion(); + } + +void CDirectGdiGcWrapper::Clear() + { + iContext->Clear(); + } + +void CDirectGdiGcWrapper::Clear(const TRect& aRect) + { + iContext->Clear(aRect); + } + +void CDirectGdiGcWrapper::ResetBrushPattern() + { + iContext->ResetBrushPattern(); + } + +void CDirectGdiGcWrapper::ResetFont() + { + iContext->ResetFont(); + } + +void CDirectGdiGcWrapper::DrawArc(const TRect& aRect, const TPoint& aStart, const TPoint& aEnd) + { + iContext->DrawArc(aRect, aStart, aEnd); + } + +void CDirectGdiGcWrapper::DrawPie(const TRect& aRect, const TPoint& aStart, const TPoint& aEnd) + { + iContext->DrawPie(aRect, aStart, aEnd); + } + +void CDirectGdiGcWrapper::DrawBitmap(const TRect& aDestRect, const CFbsBitmap& aSourceBitmap) + { + iContext->DrawBitmap(aDestRect, aSourceBitmap); + } + +void CDirectGdiGcWrapper::DrawBitmap(const TRect& aDestRect, const CFbsBitmap& aSourceBitmap, const TRect& aSourceRect) + { + iContext->DrawBitmap(aDestRect, aSourceBitmap, aSourceRect); + } + +void CDirectGdiGcWrapper::DrawBitmapMasked(const TRect& aDestRect, const CFbsBitmap& aSourceBitmap, const TRect& aSourceRect, const CFbsBitmap& aMaskBitmap, TBool aInvertMask) + { + iContext->DrawBitmapMasked(aDestRect, aSourceBitmap, aSourceRect, aMaskBitmap, aInvertMask); + } + +void CDirectGdiGcWrapper::DrawRoundRect(const TRect& aRect, const TSize& aEllipse) + { + iContext->DrawRoundRect(aRect, aEllipse); + } + +void CDirectGdiGcWrapper::DrawPolyLine(const TArray& aPointList) + { + iContext->DrawPolyLine(aPointList); + } + +void CDirectGdiGcWrapper::DrawPolyLineNoEndPoint(const TArray& aPointList) + { + iContext->DrawPolyLineNoEndPoint(aPointList); + } + +void CDirectGdiGcWrapper::DrawPolygon(const TArray& aPointList, TFillRule aFillRule) + { + iContext->DrawPolygon(aPointList, MWsGraphicsContextToDirectGdiMappings::Convert(aFillRule)); + } + +void CDirectGdiGcWrapper::DrawEllipse(const TRect& aRect) + { + iContext->DrawEllipse(aRect); + } + +void CDirectGdiGcWrapper::DrawLine(const TPoint& aStart, const TPoint& aEnd) + { + iContext->DrawLine(aStart, aEnd); + } + +void CDirectGdiGcWrapper::DrawLineTo(const TPoint& aPoint) + { + iContext->DrawLineTo(aPoint); + } + +void CDirectGdiGcWrapper::DrawLineBy(const TPoint& aVector) + { + iContext->DrawLineBy(aVector); + } + +void CDirectGdiGcWrapper::DrawRect(const TRect& aRect) + { + iContext->DrawRect(aRect); + } + +void CDirectGdiGcWrapper::DrawText(const TDesC& aText,const TTextParameters* aParam) + { + iContext->DrawText(aText, MWsGraphicsContextToDirectGdiMappings::Convert(aParam)); + } + +void CDirectGdiGcWrapper::DrawText(const TDesC& aText,const TTextParameters* aParam,const TPoint& aPosition) + { + iContext->DrawText(aText, MWsGraphicsContextToDirectGdiMappings::Convert(aParam), aPosition); + } + +void CDirectGdiGcWrapper::DrawText(const TDesC& aText,const TTextParameters* aParam,const TRect& aClipRect) + { + iContext->DrawText(aText, MWsGraphicsContextToDirectGdiMappings::Convert(aParam), aClipRect); + } + +void CDirectGdiGcWrapper::DrawText(const TDesC& aText,const TTextParameters* aParam,const TRect& aClipFillRect,TInt aBaselineOffset, TTextAlign aHrz,TInt aMargin) + { + iContext->DrawText(aText, MWsGraphicsContextToDirectGdiMappings::Convert(aParam), aClipFillRect, aBaselineOffset, MWsGraphicsContextToDirectGdiMappings::Convert(aHrz), aMargin); + } + +void CDirectGdiGcWrapper::DrawTextVertical(const TDesC& aText,const TTextParameters* aParam,TBool aUp) + { + iContext->DrawTextVertical(aText, MWsGraphicsContextToDirectGdiMappings::Convert(aParam), aUp); + } + +void CDirectGdiGcWrapper::DrawTextVertical(const TDesC& aText,const TTextParameters* aParam,const TPoint& aPosition,TBool aUp) + { + iContext->DrawTextVertical(aText, MWsGraphicsContextToDirectGdiMappings::Convert(aParam), aPosition, aUp); + } + +void CDirectGdiGcWrapper::DrawTextVertical(const TDesC& aText,const TTextParameters* aParam,const TRect& aClipRect,TBool aUp) + { + iContext->DrawTextVertical(aText, MWsGraphicsContextToDirectGdiMappings::Convert(aParam), aClipRect, aUp); + } + +void CDirectGdiGcWrapper::DrawTextVertical(const TDesC& aText,const TTextParameters* aParam,const TRect& aClipRect,TInt aBaselineOffset,TBool aUp,TTextAlign aVert,TInt aMargin) + { + iContext->DrawTextVertical(aText, MWsGraphicsContextToDirectGdiMappings::Convert(aParam), aClipRect, aBaselineOffset, aUp, MWsGraphicsContextToDirectGdiMappings::Convert(aVert), aMargin); + } + +void CDirectGdiGcWrapper::DrawTextVertical(const TDesC& aText,const TTextParameters* aParam,const TRect& aClipRect,TInt aBaselineOffset,TInt aTextWidth,TBool aUp,TTextAlign aVert,TInt aMargin) + { + iContext->DrawTextVertical(aText, MWsGraphicsContextToDirectGdiMappings::Convert(aParam), aClipRect, aBaselineOffset, aTextWidth, aUp, MWsGraphicsContextToDirectGdiMappings::Convert(aVert), aMargin); + } + +void CDirectGdiGcWrapper::MoveTo(const TPoint& aPoint) + { + iContext->MoveTo(aPoint); + } + +void CDirectGdiGcWrapper::MoveBy(const TPoint& aVector) + { + iContext->MoveBy(aVector); + } + +void CDirectGdiGcWrapper::Plot(const TPoint& aPoint) + { + iContext->Plot(aPoint); + } + +void CDirectGdiGcWrapper::Reset() + { + iContext->Reset(); + } + +void CDirectGdiGcWrapper::SetBrushColor(const TRgb& aColor) + { + iContext->SetBrushColor(aColor); + } + +void CDirectGdiGcWrapper::SetBrushOrigin(const TPoint& aOrigin) + { + iContext->SetBrushOrigin(aOrigin); + } + +void CDirectGdiGcWrapper::SetBrushStyle(TBrushStyle aBrushStyle) + { + iContext->SetBrushStyle(MWsGraphicsContextToDirectGdiMappings::Convert(aBrushStyle)); + } + +void CDirectGdiGcWrapper::SetClippingRegion(const TRegion& aRegion) + { + CDirectGdiDriver* driver = CDirectGdiDriver::Static(); + driver->GetError(); //make sure that an error has been received + iContext->SetClippingRegion(aRegion); + TInt err = driver->GetError(); + SetError(err); + if(err == KErrNone) + { + iClippingRegion.Copy(aRegion); + } + } + +void CDirectGdiGcWrapper::SetDrawMode(TDrawMode aDrawMode) + { + iContext->SetDrawMode(MWsGraphicsContextToDirectGdiMappings::LossyConvert(aDrawMode)); + } + +void CDirectGdiGcWrapper::SetOrigin(const TPoint& aPoint) + { + iContext->SetOrigin(aPoint); + iOrigin = aPoint; + } + +void CDirectGdiGcWrapper::SetPenColor(const TRgb& aColor) + { + iContext->SetPenColor(aColor); + } + +void CDirectGdiGcWrapper::SetPenStyle(TPenStyle aPenStyle) + { + iContext->SetPenStyle(MWsGraphicsContextToDirectGdiMappings::Convert(aPenStyle)); + } + +void CDirectGdiGcWrapper::SetPenSize(const TSize& aSize) + { + iContext->SetPenSize(aSize); + } + +void CDirectGdiGcWrapper::SetTextShadowColor(const TRgb& aColor) + { + iContext->SetTextShadowColor(aColor); + } + +void CDirectGdiGcWrapper::SetCharJustification(TInt aExcessWidth, TInt aNumChars) + { + iContext->SetCharJustification(aExcessWidth, aNumChars); + } + +void CDirectGdiGcWrapper::SetWordJustification(TInt aExcessWidth, TInt aNumGaps) + { + iContext->SetWordJustification(aExcessWidth, aNumGaps); + } + +void CDirectGdiGcWrapper::SetUnderlineStyle(TFontUnderline aUnderlineStyle) + { + iContext->SetUnderlineStyle(MWsGraphicsContextToDirectGdiMappings::Convert(aUnderlineStyle)); + } + +void CDirectGdiGcWrapper::SetStrikethroughStyle(TFontStrikethrough aStrikethroughStyle) + { + iContext->SetStrikethroughStyle(MWsGraphicsContextToDirectGdiMappings::Convert(aStrikethroughStyle)); + } + +void CDirectGdiGcWrapper::SetBrushPattern(const CFbsBitmap& aBitmap) + { + iContext->SetBrushPattern(aBitmap); + } + +void CDirectGdiGcWrapper::SetBrushPattern(TInt aFbsBitmapHandle) + { + iContext->SetBrushPattern(aFbsBitmapHandle); + } + +void CDirectGdiGcWrapper::SetFont(const CFont* aFont) + { + iContext->SetFont(aFont); + } + +void CDirectGdiGcWrapper::CopyRect(const TPoint& aOffset, const TRect& aRect) + { + iContext->CopyRect(aOffset, aRect); + } + +void CDirectGdiGcWrapper::UpdateJustification(const TDesC& aText,const TTextParameters* aParam) + { + iContext->UpdateJustification(aText, MWsGraphicsContextToDirectGdiMappings::Convert(aParam)); + } + +void CDirectGdiGcWrapper::UpdateJustificationVertical(const TDesC& aText,const TTextParameters* aParam,TBool aUp) + { + iContext->UpdateJustificationVertical(aText, MWsGraphicsContextToDirectGdiMappings::Convert(aParam), aUp); + } + +void CDirectGdiGcWrapper::SetFontNoDuplicate(const CFont* aFont) + { + iContext->SetFontNoDuplicate(static_cast(aFont)); + } + +TBool CDirectGdiGcWrapper::HasBrushPattern() const + { + return iContext->HasBrushPattern(); + } + +TBool CDirectGdiGcWrapper::HasFont() const + { + return iContext->HasFont(); + } + +TRgb CDirectGdiGcWrapper::BrushColor() const + { + return iContext->BrushColor(); + } + +TRgb CDirectGdiGcWrapper::PenColor() const + { + return iContext->PenColor(); + } + +TRgb CDirectGdiGcWrapper::TextShadowColor() const + { + return iContext->TextShadowColor(); + } + +TAny* CDirectGdiGcWrapper::ResolveObjectInterface(TUint /*aTypeId*/) + { + return NULL; + } + +/** +Sets the error code. If the error code is already set to a value other +than KErrNone, the error code will not be modified. + +@param aErr The error code to set. + +@post The error code has been set. +*/ +void CDirectGdiGcWrapper::SetError(TInt aError) + { + if (aError != KErrNone && iErrorCode == KErrNone) + { + iErrorCode = aError; + } + } + +/** +Returns the first error code (set as the result of calling some CDirectGdiGcWrapper API), if any, +since the last call to this function or, if it has not previously been called, since +the CDirectGdiGcWrapper was constructed. Calling this function clears the error code. + +@post The error code has been reset after being read. + +@return The first error code, if any, since the last call to this function or, + if it has not previously been called, since the CDirectGdiGcWrapper was constructed. + KErrNone will indicate that no such error has occurred. +*/ +TInt CDirectGdiGcWrapper::GetError() + { + TInt err = iErrorCode; + iErrorCode = KErrNone; + return err; + } + +TPoint CDirectGdiGcWrapper::Origin() const + { + return iOrigin; + } + +const TRegion& CDirectGdiGcWrapper::ClippingRegion() + { + return iClippingRegion; + } + +TInt CDirectGdiGcWrapper::Push() + { + // the buf format is len+data where data is written by the GC's ExternalizeL() + iGcBuf->Reset(); + CBufBase& buf = *iGcBuf; + const TInt start = buf.Size(); + RBufWriteStream out(buf,start); + TRAPD(err,out.WriteInt32L(0)); + if(!err) + { + TRAP(err,iContext->ExternalizeL(out)); + } + if(err) //rollback addition + { + buf.Delete(start,buf.Size()-start); + } + else //fixup len + { + TRAP_IGNORE(out.CommitL();) // can't see this failing + TPckgBuf pckg(buf.Size()-sizeof(TInt32)-start); + buf.Write(start,pckg); + } + return err; + } + +void CDirectGdiGcWrapper::Pop() + { + CBufBase& buf = *iGcBuf; + TInt ofs = 0; + FOREVER + { + TInt chunk = 0; + RBufReadStream in(buf,ofs); + TRAPD(err,chunk = in.ReadInt32L()); + if(err) + { + STD_ASSERT_DEBUG(err != 0, EStdPanicPopGcSettings); + return; + } + if(ofs+sizeof(TInt32)+chunk >= buf.Size()) // the last chunk? + { + TRAP_IGNORE(iContext->InternalizeL(in)); + buf.Delete(ofs,buf.Size()-ofs); + return; + } + ofs += chunk + sizeof(TInt32); + } + } + +//Default method of fading simply uses bitgdi to perform fading +void CDirectGdiGcWrapper::FadeArea(const TRegion& aRegion) + { + if (!&aRegion || aRegion.CheckError()) + return; + + iContext->Reset(); + iContext->SetClippingRegion(aRegion); + iContext->SetPenStyle(DirectGdi::ENullPen); + iContext->SetBrushStyle(DirectGdi::ESolidBrush); + iContext->SetBrushColor(iFadeColor); + iContext->DrawRect(aRegion.BoundingRect()); + } + +//Default method of fading expects two TUint8's describing the black/white map +//as possible fading parameters +void CDirectGdiGcWrapper::SetFadingParameters(const TDesC8& aData) + { + TPckgBuf buf; + buf.Copy(aData); + TFadingParams parameters = buf(); + + //Situations where blackMap > whiteMap are NOT supported + if (parameters.blackMap > parameters.whiteMap) + { + TUint8 oldMap = parameters.blackMap; + parameters.blackMap = parameters.whiteMap; + parameters.whiteMap = oldMap; + } + + //CFbsBitGc::FadeArea() does the following per color component: + // dst = dst * (whiteMap - blackMap) + blackMap; + + //To achieve the same effect using MWsGraphicsContext we draw a rectangle + //with specific intensity and alpha values: + // dst = dst * (1 - alpha) + intensity * alpha; + //Thus: + // alpha = 1 - whiteMap + blackMap; + // intensity = blackMap / alpha; + + // alpha = 1 - whiteMap + blackMap; + TInt alpha = 255 - parameters.whiteMap + parameters.blackMap; + // intensity = blackMap / alpha; + TInt i = (parameters.blackMap * iLut[alpha]) >> 8; + + iFadeColor.SetInternal(i << 16 | i << 8 | i | alpha << 24); + } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/directgdigcwrapper.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/directgdigcwrapper.h Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,169 @@ +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#ifndef __DIRECTGDIGCWRAPPER_H__ +#define __DIRECTGDIGCWRAPPER_H__ + +#include +#include +#include +#include +#include + + +/* + * Required by MWsFader implementation + */ +struct TFadingParams + { + TUint8 blackMap; + TUint8 whiteMap; + }; + +/** +The purpose of this class is to wrap a @c CDirectGdiContext whenever an +@c MWsGraphicsContext is needed. + +The methods doesn't do anything other than calling the corresponding method +in @c MWsGraphicsContext. + +@see MWsGraphicsContext +@see MWsDrawableSourceProvider +@see CDirectGdiContext; + +@internalComponent +@prototype +*/ +class CDirectGdiGcWrapper : public CBase, public MWsGraphicsContext, public MWsFader + { +public: + static CDirectGdiGcWrapper* NewL(RDirectGdiImageTarget& aTarget); + ~CDirectGdiGcWrapper(); + inline CDirectGdiContext& DirectGdiGc(); + TInt SetDrawDeviceOffset(TPoint& aOrigin); + +public: //from MWsGraphicsContext + void BitBlt(const TPoint& aDestPos, const CFbsBitmap& aSourceBitmap); + void BitBlt(const TPoint& aDestPos, const CFbsBitmap& aSourceBitmap, const TRect& aSourceRect); + void BitBltMasked(const TPoint& aDestPos, const CFbsBitmap& aSourceBitmap, const TRect& aSourceRect, const CFbsBitmap& aMaskBitmap, TBool aInvertMask); + void BitBltMasked(const TPoint& aDestPos, const CFbsBitmap& aSourceBitmap, const TRect& aSourceRect, const CFbsBitmap& aMaskBitmap, const TPoint& aMaskPos); + void ResetClippingRegion(); + void Clear(); + void Clear(const TRect& aRect); + void ResetBrushPattern(); + void ResetFont(); + void DrawArc(const TRect& aRect, const TPoint& aStart, const TPoint& aEnd); + void DrawPie(const TRect& aRect, const TPoint& aStart, const TPoint& aEnd); + void DrawBitmap(const TRect& aDestRect, const CFbsBitmap& aSourceBitmap); + void DrawBitmap(const TRect& aDestRect, const CFbsBitmap& aSourceBitmap, const TRect& aSourceRect); + void DrawBitmapMasked(const TRect& aDestRect, const CFbsBitmap& aSourceBitmap, const TRect& aSourceRect, const CFbsBitmap& aMaskBitmap, TBool aInvertMask); + void DrawRoundRect(const TRect& aRect, const TSize& aEllipse); + void DrawPolyLine(const TArray& aPointList); + void DrawPolyLineNoEndPoint(const TArray& aPointList); + void DrawPolygon(const TArray& aPointList, TFillRule aFillRule=EAlternate); + void DrawEllipse(const TRect& aRect); + void DrawLine(const TPoint& aStart, const TPoint& aEnd); + void DrawLineTo(const TPoint& aPoint); + void DrawLineBy(const TPoint& aVector); + void DrawRect(const TRect& aRect); + void DrawText(const TDesC& aText,const TTextParameters* aParam); + void DrawText(const TDesC& aText,const TTextParameters* aParam,const TPoint& aPosition); + void DrawText(const TDesC& aText,const TTextParameters* aParam,const TRect& aClipRect); + void DrawText(const TDesC& aText,const TTextParameters* aParam,const TRect& aClipFillRect,TInt aBaselineOffset,TTextAlign aHrz=ELeft,TInt aMargin=0); + void DrawTextVertical(const TDesC& aText,const TTextParameters* aParam,TBool aUp); + void DrawTextVertical(const TDesC& aText,const TTextParameters* aParam,const TPoint& aPosition,TBool aUp); + void DrawTextVertical(const TDesC& aText,const TTextParameters* aParam,const TRect& aClipRect,TBool aUp); + void DrawTextVertical(const TDesC& aText,const TTextParameters* aParam,const TRect& aClipRect,TInt aBaselineOffset,TBool aUp,TTextAlign aVert=ELeft,TInt aMargin=0); + void DrawTextVertical(const TDesC& aText,const TTextParameters* aParam,const TRect& aClipRect,TInt aBaselineOffset,TInt aTextWidth,TBool aUp,TTextAlign aVert=ELeft,TInt aMargin=0); + void MoveTo(const TPoint& aPoint); + void MoveBy(const TPoint& aVector); + void Plot(const TPoint& aPoint); + void Reset(); + void SetBrushColor(const TRgb& aColor); + void SetBrushOrigin(const TPoint& aOrigin); + void SetBrushStyle(TBrushStyle aBrushStyle); + void SetClippingRegion(const TRegion& aRegion); + void SetDrawMode(TDrawMode aDrawMode); + void SetOrigin(const TPoint& aPoint = TPoint(0, 0)); + void SetPenColor(const TRgb& aColor); + void SetPenStyle(TPenStyle aPenStyle); + void SetPenSize(const TSize& aSize); + void SetTextShadowColor(const TRgb& aColor); + void SetCharJustification(TInt aExcessWidth, TInt aNumChars); + void SetWordJustification(TInt aExcessWidth, TInt aNumGaps); + void SetUnderlineStyle(TFontUnderline aUnderlineStyle); + void SetStrikethroughStyle(TFontStrikethrough aStrikethroughStyle); + void SetBrushPattern(const CFbsBitmap& aBitmap); + void SetBrushPattern(TInt aFbsBitmapHandle); + void SetFont(const CFont* aFont); + void CopyRect(const TPoint& aOffset, const TRect& aRect); + void UpdateJustification(const TDesC& aText,const TTextParameters* aParam); + void UpdateJustificationVertical(const TDesC& aText,const TTextParameters* aParam,TBool aUp); + void SetFontNoDuplicate(const CFont* aFont); + TBool HasBrushPattern() const; + TBool HasFont() const; + TRgb BrushColor() const; + TRgb PenColor() const; + TRgb TextShadowColor() const; + + // Return current error status of MWsGraphicsContext + TInt GetError(); + // Getters + TPoint Origin() const; + const TRegion& ClippingRegion(); + // Save and retrieve gc settings + TInt Push(); + void Pop(); + +public: // MWsFader + void SetFadingParameters(const TDesC8& aData); + void FadeArea(const TRegion& aRegion); + + //from MWsObjectProvider + TAny* ResolveObjectInterface(TUint aTypeId); + +private: + const CArrayFix* DoCreateCArrayL(const TArray& aPointList); + const CArrayFix* CreateCArray(const TArray& aPointList); + void SetError(TInt aError); + +private: + CDirectGdiContext* iContext; + TInt iErrorCode; + CBufBase* iGcBuf; // used for keeping state when drawing CWsGraphicDrawers + RRegionBuf<20> iClippingRegion; // Clipping region while doing drawing + TPoint iOrigin; // Window Origin + User defined gc origin + + //Required by MWsFader implmentation + TRgb iFadeColor; + const TUint16* iLut; + }; + +struct RDirectGdiImageEntry + { + RDirectGdiDrawableSource* iDrawableSource; + RSgImage iImage; + }; + +// +// CDirectGdiGcWrapper +// + +inline CDirectGdiContext& CDirectGdiGcWrapper::DirectGdiGc() + {return(*iContext);} + + + +#endif //__DIRECTGDIGCWRAPPER_H__ diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/eventdd.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/eventdd.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,111 @@ +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#include +#include "eventdd.h" + +/** + Logical Device (factory class) for 'EventDD' +*/ +class DEventFactory : public DLogicalDevice + { +public: + DEventFactory(); + //Pure virtual funcitons from DLogicalDevice + TInt Install(); + void GetCaps(TDes8& aDes) const; + TInt Create(DLogicalChannelBase*& aChannel); + }; + +class DEventDD : public DLogicalChannelBase + { +public: + //Pure virtual function from DLogicalChannelBase + TInt Request(TInt aReqNo,TAny* a1,TAny* a2); +private: + TInt DoControl(TInt aFunction, TAny* a1, TAny* a2); + TInt SendEvent(TRawEvent* aEvent); + }; + + +/* DLL Factory Function */ + +DECLARE_STANDARD_LDD() + { + return new DEventFactory; + } + + +/* DEventFactory */ + +DEventFactory::DEventFactory() :DLogicalDevice() + { + iVersion=REventDD::VersionRequired(); //Set version number for this device + } + +TInt DEventFactory::Install() + { + return SetName(&REventDD::DriverName()); + } + +void DEventFactory::GetCaps(TDes8& aDes) const + { + Kern::InfoCopy(aDes,KNullDesC8); + } + +TInt DEventFactory::Create(DLogicalChannelBase*& aChannel) + { + aChannel=new DEventDD; + return aChannel?KErrNone:KErrNoMemory; + } + + +/* DEventDD */ // Logical Channel + +TInt DEventDD::Request(TInt aReqNo,TAny* a1,TAny* a2) + { + // Decode the message type and dispatch it to the relevent handler function... + // only using synchronous control messages + if (static_cast(aReqNo)(KMaxTInt)) + return DoControl(aReqNo,a1,a2); + return KErrNotSupported; + } + +/** + Process synchronous 'control' requests +*/ +TInt DEventDD::DoControl(TInt aFunction,TAny* a1,TAny* /*a2*/) + { + TInt ret=KErrNotSupported; + + switch (aFunction) + { + case REventDD::ESendEvent: + ret=SendEvent(static_cast(a1)); + break; + default:; + } + return ret; + } + +TInt DEventDD::SendEvent(TRawEvent* aEvent) + { + TRawEvent event; + kumemget(&event,aEvent,sizeof(TRawEvent)); //fetch event from user memory + NKern::ThreadEnterCS(); + TInt err=Kern::AddEvent(event); + NKern::ThreadLeaveCS(); + return err; + } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/eventdd.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/eventdd.h Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,75 @@ +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#ifndef __EVENTDD_H__ +#define __EVENTDD_H__ + +#ifndef __E32cmn_H__ +#include +#endif + +_LIT(KName,"EventDD"); + + +class REventDD : public RBusLogicalChannel + { + friend class DEventDD; +public: + /** + Structure for holding driver capabilities information + (Just a version number in this example.) + */ + class TCaps + { + public: + TVersion iVersion; + }; + +public: + inline static const TDesC& BinaryName(); + inline static const TDesC& DriverName(); + inline static TVersion VersionRequired(); + inline TInt Open(); + inline TInt SendEvent(TRawEvent& aEvent); +private: + enum TControl + { + ESendEvent + }; + }; + + +inline const TDesC& REventDD::BinaryName() + { + return KName; + } +inline const TDesC& REventDD::DriverName() + { + return KName; + } +inline TVersion REventDD::VersionRequired() + { + return TVersion(1,0,0); + } +inline TInt REventDD::Open() + { + return DoCreate(DriverName(),VersionRequired(),KNullUnit,NULL,NULL,EOwnerThread); + } +inline TInt REventDD::SendEvent(TRawEvent& aEvent) + { + return DoControl(ESendEvent,static_cast(&aEvent)); + } + +#endif //__EVENTDD_H__ diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/mwsgraphicscontexttodirectgdimappings.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/mwsgraphicscontexttodirectgdimappings.h Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,81 @@ +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#ifndef __MWSGRAPHICSCONTEXTTODIRECTGDIMAPPINGS_H__ +#define __MWSGRAPHICSCONTEXTTODIRECTGDIMAPPINGS_H__ + +#include +#include +#include + +class MWsGraphicsContextToDirectGdiMappings + { +public: + static DirectGdi::TFillRule Convert(MWsGraphicsContext::TFillRule aFillRule) { return (DirectGdi::TFillRule)aFillRule; } + static DirectGdi::TPenStyle Convert(MWsGraphicsContext::TPenStyle aPenStyle) { return (DirectGdi::TPenStyle)aPenStyle; } + static DirectGdi::TBrushStyle Convert(MWsGraphicsContext::TBrushStyle aBrushStyle) { return (DirectGdi::TBrushStyle)aBrushStyle; } + static DirectGdi::TTextAlign Convert(MWsGraphicsContext::TTextAlign aTextAlign) { return (DirectGdi::TTextAlign)aTextAlign; } + static DirectGdi::TFontUnderline Convert(MWsGraphicsContext::TFontUnderline aFontUnderline) { return (DirectGdi::TFontUnderline)aFontUnderline; } + static DirectGdi::TFontStrikethrough Convert(MWsGraphicsContext::TFontStrikethrough aFontStrikethrough) { return (DirectGdi::TFontStrikethrough)aFontStrikethrough; } + static const DirectGdi::TTextParameters* Convert(const MWsGraphicsContext::TTextParameters* aParam) { return reinterpret_cast(aParam); } + static DirectGdi::TDrawMode LossyConvert(MWsGraphicsContext::TDrawMode aDrawMode) + {return (aDrawMode==MWsGraphicsContext::EDrawModeWriteAlpha ? DirectGdi::EDrawModeWriteAlpha : DirectGdi::EDrawModePEN);} + }; + + +template +class TArrayWrapper : public TArray + { +public: + TArrayWrapper(const T* aArray, TInt aCount); +private: + static TInt Count(const CBase* aPtr); + static const TAny* At(const CBase* aPtr, TInt aIndex); +private: + const T* iArray; + const TInt iCount; + }; + +template +TArrayWrapper::TArrayWrapper(const T* aArray, TInt aCount) + : TArray(TArrayWrapper::Count, TArrayWrapper::At, reinterpret_cast(this)), iArray(aArray), iCount(aCount) + { + //reinterpret_cast above since this class doesn't derive from CBase but TArray is + //only silly requiring CBase as opposed to TAny, so this is safe + ASSERT(iArray); + } + +template +TInt TArrayWrapper::Count(const CBase* aPtr) + { + //reinterpret_cast since this class doesn't derive from CBase but TArray is + //only silly requiring CBase as opposed to TAny, so this is safe + const TArrayWrapper* self = reinterpret_cast(aPtr); + return self->iCount; + } + +template +const TAny* TArrayWrapper::At(const CBase* aPtr, TInt aIndex) + { + //reinterpret_cast since this class doesn't derive from CBase but TArray is + //only silly requiring CBase as opposed to TAny, so this is safe + const TArrayWrapper* self = reinterpret_cast(aPtr); + if(!Rng(0, aIndex, self->iCount - 1)) + User::Panic(_L("USER"), 130); //out of bounds (RArray/RPointerArray) + return self->iArray + aIndex; + } + + +#endif //__MWSGRAPHICSCONTEXTTODIRECTGDIMAPPINGS_H__ diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/mytest.mbm Binary file windowing/windowserver/test/tauto/mytest.mbm has changed diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/openwfc/AUTO.H --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/openwfc/AUTO.H Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,669 @@ +// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Header for window server auto test code +// +// + + +#ifndef __AUTO_H__ +#define __AUTO_H__ + +#include +#include +#include "../../SERVER/w32cmd.h" +#include +#include "../tlib/testbase.h" +#include +#include "TGraphicsHarness.h" +#include "../../SERVER/openwfc/panics.h" + +#define DISABLE_FAIL_DIALOG + +#define TEST_BITMAP_NAME _L("Z:\\WSTEST\\WSAUTOTEST.MBM") + +#define SCREEN_MODE_TESTING + +#define LOG_MESSAGE(p) LogMessage(((TText8*)__FILE__), __LINE__,(p)) +#define LOG_MESSAGE2(p1,p2) LogMessage(((TText8*)__FILE__), __LINE__,(p1),(p2)) +#define LOG_MESSAGE3(p1,p2,p3) LogMessage(((TText8*)__FILE__), __LINE__,(p1),(p2),(p3)) +#define LOG_MESSAGE4(p1,p2,p3,p4) LogMessage(((TText8*)__FILE__), __LINE__,(p1),(p2),(p3),(p4)) +#define LOG_MESSAGE5(p1,p2,p3,p4,p5) LogMessage(((TText8*)__FILE__), __LINE__,(p1),(p2),(p3),(p4),(p5)) +#define LOG_MESSAGE6(p1,p2,p3,p4,p5,p6) LogMessage(((TText8*)__FILE__), __LINE__,(p1),(p2),(p3),(p4),(p5),(p6)) +#define LOG_MESSAGE7(p1,p2,p3,p4,p5,p6,p7) LogMessage(((TText8*)__FILE__), __LINE__,(p1),(p2),(p3),(p4),(p5),(p6),(p7)) + +// MB 23\11\04 The heap size was only 4k which was causing DSA step 7 to fail on HW. +// Increased heap size to 8k +// 23/02/2009 Again failing with no memory due to COLOR16MAP used. +// Increased heap size to 16k +LOCAL_D const TUint KOtherProcHeapSize=0x4000; +LOCAL_D const TInt KAutoTestPriority=-20; + +TBool DoCheckRect(CTBaseWin *aWin1,CTBaseWin *aWin2,const TRect &aRect); +TBool DoCheckRect(CTBaseWin *aWin1,CTBaseWin *aWin2,const TRect &aRect, TUint aFlags); +TBool DoCheckRectRWin(RWindowBase &aWin1,RWindowBase &aWin2,const TRect &aRect); +TBool DoCheckRectRWin(RWindowBase &aWin1,RWindowBase &aWin2,const TRect &aRect, TUint aFlags); +TBool DoCheckRect(CTBaseWin *aWin1,CTBaseWin *aWin2); +TBool DoCheckRect(TPoint aPos1,TPoint aPos2,TSize aSize); + +_LIT(KWSERV,"WSERV"); +_LIT(KW32,"W32"); +_LIT(KPlatsecBegin,"*PlatSec* ERROR - BEGIN NEGATIVE PLATSEC TESTING"); +_LIT(KPlatsecEnd,"*PlatSec* ERROR - END NEGATIVE PLATSEC TESTING"); +_LIT(KTestFontTypefaceName,"DejaVu Sans Condensed"); + +class TestClient; +class CMinWin; +class CTWsGraphicsBase; + +enum TestState + { + EInvalid, + ENext, + EWait, + EFinished + }; + +enum TAutoPanics + { + EAutoPanicTestFailed, + EAutoPanicPanicFailed, + EAutoPanicTestRectsIndex, + EAutoPanicTestRectsSection, + EAutoPanicUnexpectedLeave, + EAutoPanicTestBrushesIndex, + EAutoPanicWindowType, + EAutoPanicTooManyDownKeys, + EAutoPanicInvalidEvent, + EAutoFadeWindow, + EAutoPanicWrongTest, + EAutoPanicAnimError, + ETManPanicPcFailed, //Panic use in a test copied from TMan + EAutoPanicTestError, //Test returned bad return type + EAutoPanicDirect, //Direct Screen Access logic state error + EAutoPanicScanCapital, //Scan codes must not be lower case letters + EAutoPanicRedrawStoring, //Inconsistent Redraw Storing Behaviour + EAutoPanicRecalledCreateTestBaseL, //Called CreateTestBaseL twice + EAutoPanicHeartBeatCursorRect, //Invalid size of rectangle in ChangeTransAndCheckHeartBeat + EAutoPanicGroupWinHasChild, //Main test group window has child at start of test + EAutoPanicPanicSetTrans, //Error setting transparency during panic tests + EAutoPanicNoDigitiser, //Pointer event when the configuration has no digitiser + }; + +enum TPanicExitReasons + { + EWsExitReasonBad, + EWsExitReasonFinished, + }; + +enum TAutoLeaves + { + ETestPassed=0, + ETestFailed=1, + }; + +typedef TInt (*TPanicFunction)(TInt aInt, TAny *aPtr); + +struct SPanicParams + { + TInt num; + TPanicFunction func; + TAny *ptr; + }; + +class LogWindow : public CTWin + { + enum + { + EDummyValue=-9999 + }; +public: + LogWindow(); + void ConstructL(CTWinBase& aParent); + void Draw(); + void DrawSubTitle(); + void DrawMessage(); + void LogTest(const TDesC &aTitle,TInt aNum); + const TDesC& LogSubTest(const TDesC &aTitle,TInt aNum); + const TDesC& LogMessage(TBool aLog,const TDesC& aText,TInt aNum=EDummyValue); +private: + TBuf<0x40> iTestTitle; + TBuf<0x40> iSubTitle; + TBuf<0x40> iMessage; + TInt iTitleHeight; + }; + +class CTestBase; + +/** +This class is a window that is used to fake a border around the TestWindow defined below. +It simply draws an opaque black window on top of which the TestWindow will be drawn giving the illusion +there is a border. + +@see TestWindow +@internalComponent +@released +*/ +class CBorderWindow : public CTWin + { +public: + CBorderWindow(); + void ConstructL(CTWinBase& aParent); + void Draw(); + }; + +class TestWindow : public CTWin + { +public: + TestWindow(); + ~TestWindow(); + void Draw(); + void SetUpL(TPoint aPos, TSize aSize, CTWinBase* aParent, CWindowGc& aGc); + void ClearWin(); + void SetBorderExt(TPoint aPos, TSize aSize); + CBorderWindow* GetBorderWin(); +private: + CBorderWindow* iBorderWin; + }; + +/** +This class used to run each individual test before the migration to TEF. +Now it doesn't do much and should probably be refactored. + +@internalComponent +@released +*/ +class CTestDriver : public CBase + { +public: + /** Factory function that returns a class derived from CTestDriver */ + static CTestDriver* CreateL(TInt aScreenNumber); + virtual ~CTestDriver(); + +protected: + CTestDriver(TInt aScreenNumber); + +public: + virtual void DoDisplayDialog(TDesC& timeBuf,TDesC& testReport) = 0; + + void TestComplete2(); + void DestroyTest(); + + inline TInt ScreenNumber() {return iScreenNumber;} + inline TInt NumberOfScreens() {return iNumberOfScreens;} + +public: + CTestBase *iTest; + TInt iSubTestNum; + static TInt iTestNum; +protected: + TTime iStartTime; + TInt iScreenNumber; + TInt iTestSize; + TInt iNumberOfScreens; + }; + +/** Variant of CTestDriver used when the tests are run on the primary screen. + +@internalComponent +@released +*/ +class CTestDriverPrimary: public CTestDriver + { +public: + CTestDriverPrimary(TInt aScreenNumber); + void DoDisplayDialog(TDesC& timeBuf,TDesC& testReport); + }; + +/** Variant of CTestDriver used when the tests are run on a secondary screen. + +@internalComponent +@released +*/ +class CTestDriverSecondary : public CTestDriver + { +public: + CTestDriverSecondary(TInt aScreenNumber); + void DoDisplayDialog(TDesC& timeBuf,TDesC& testReport); + }; + +/** List of rectangles use by TGDI.CPP and TRECTLIST.CPP. + +Since only 2 tests make use of this shouldn't it be moved outside of the framework? + +@internalComponent +@released +*/ +class TTestRects + { +private: + enum TRectListLimits + { + EMaxRectFromList=64, + EMaxRectZeroSize=73, + EMaxRectWide=83, + EMaxRectHigh=93 + }; + +public: + void Construct(const RWindow &aWindow); + TInt Count1() const; + TInt Count2() const; + TInt Count3() const; + TRect operator[](TInt aIndex); + static void ResetSeed(); +private: + TInt Rnd(TInt aSize); + TInt RndMax(TInt aSize); + TInt RectCoord(TInt aSection,TInt aSize); + void RectCoordPair(TInt &aTl, TInt &aBr, TInt aSection, TInt aSize); + +private: + TSize iSize; + static TRect iList[64]; + static TInt64 iSeed; + }; + +/** +@internalComponent +@released +*/ +class CBitmap : public CBase + { +public: + static CBitmap* NewLC(const TSize& aSizeInPixels,TDisplayMode aDispMode); + static CBitmap* NewL(const TSize& aSizeInPixels,TDisplayMode aDispMode); + static CBitmap* NewL(TInt aHandle); + static CBitmap* NewL(TDesC& aFileName); + ~CBitmap(); + inline CFbsBitmap& Bitmap() const {return *iBitmap;} + inline CFbsBitmapDevice& Device() const {return *iDevice;} + inline CFbsBitGc& Gc() const {return *iGc;} +private: + static CBitmap* NewLC(TInt aHandle,const TSize& aSizeInPixels,TDisplayMode aDispMode); + void ConstructL(TInt aHandle,const TSize& aSizeInPixels,TDisplayMode aDispMode); +private: + CFbsBitmap* iBitmap; + CFbsBitmapDevice* iDevice; + CFbsBitGc* iGc; + }; + +/*TPartialRedrawType*/ +enum TPartialRedrawType + { + //redraw store type is not yet determined. + EPartialRedraw_Unknown, + //redraw store is discarded on invalidation and begin-redraw on a smaller rect. + EPartialRedraw_None, + // redraw store is preserved on invalidation and begin-redraw on a smaller rect. + EPartialRedraw_PreserveStoredCmds, + // redraw store is appended with partial redraw commands, and old redraw store is suitably modified. + EPartialRedraw_FullRedrawSupport + }; + +class CTestBase : public CBase + { +public: + enum TPriorites + { + EAutoTestPriority=KAutoTestPriority + }; + enum TTestLevel + { + ELevelQuick, // Quick check on main cases for each function + ELevelNormal, // Suitable test level for internal release + ELevelRelease, // Thorough test suitable for official releases + ELevelMega, // Really OTT, takes forever to run, leave it going over the weekend sort of tests + }; +public: + CTestBase(const TDesC &aTitle,CTWsGraphicsBase* aTestBase); + ~CTestBase(); + void StartTestL(TInt aNum, CTestDriver* aDriver, TTestLevel aLevel); + void LogSubTest(const TDesC &aTitle); + void LogMessage(TInt aValue); + void LogSubState(TInt aSubState); + TInt LaunchPanicThread(RThread &aThread, SPanicParams *aPtr); + TInt TestPanicL(SPanicParams *aPtr, TInt aExitReason, const TDesC &aCategory, TBool* aTestFinished=NULL); + TInt TestPanicL(TPanicFunction aFunction, TInt aExitReason, TInt aInt, TAny *aPtr, const TDesC &aCategory, TBool* aTestFinished=NULL); + TInt TestWsPanicL(TPanicFunction aFunction, TClientPanic aExitReason, TInt aInt, TAny *aPtr=NULL, TBool* aTestFinished=NULL); + TInt TestW32PanicL(TPanicFunction aFunction, TW32Panic aExitReason, TInt aInt, TAny *aPtr, TBool* aTestFinished=NULL); + TInt TestWservPanicL(TPanicFunction aFunction, TWservPanic aExitReason, TInt aInt, TAny *aPtr); + void TriggerFail(); + static void DrawTestBackground(TBool aInvertColours, const TSize &aSize, TInt aGrays=16); + inline CTestDriver* Driver(); + void SimulatePointer(TRawEvent::TType aType, TInt aX, TInt aY); + TBool ConfigurationSupportsPointerEventTesting() const; + void SimulateEvent(TRawEvent::TType aType); + void LogColors(const CBitmapDevice& aDevice,TPoint aBasePoint, TPoint aStartPoint, TPoint aEndPoint); + void LogColors4(const CBitmapDevice& aDevice,TPoint aStartPoint,TInt aLen); + inline TInt ScreenNumber() {return iScreenNumber;} + TPartialRedrawType RedrawStoreTypeL(); + TBool IsFullRomL(); + void SimulateKeyDownUpWithModifiers(TInt aScanCode,TUint aModifiers); + void SimulatePointerDownUp(TInt aX, TInt aY); + void SimulateKeyDownUp(TInt aScanCode); + void SimulateKey(TRawEvent::TType aType, TInt aScanCode); + void DelayIfFullRomL(); + void SetUpMember(TSpriteMember &aMember); + void AbortL(); + void LogLeave(TInt aErr); + void CloseAllPanicWindows(); + const TSize& StdTestWindowSize(); + TInt MaxGrays() const; + TInt MaxColors() const; + TInt SaveScreen(const TDesC& aFileName); + TInt SaveScreen(const TDesC& aFileName,const TSize& aScreenSize,TDisplayMode aColorDepth); +protected: + void UpdateTestResults(TInt aNoOfTest, TInt aNoOfTestPass); + void SaveScreenL(const TDesC& aFileName,const TSize& aScreenSize,TDisplayMode aColorDepth); +public: + static TInt iNumberTestsPass; + static TInt iNumberTests; + TInt iState; + TInt iScreenNumber; + static TInt iScreenNo; + TTestRects iTestRects; + static TRect iNormalPointerCursorArea; + TBuf<0x40> iSubTitle; + TTestLevel iTestLevel; + static TInt iNumberOfGrpWndsOnPrimaryScreenWithZeroPriority; // Will be used in TGWHANDLE test. +protected: + CTestDriver* iDriver; +private: + TBuf<0x40> iTitle; + CTWsGraphicsBase* iTestBase; + /** + Several tests use 3 windows : one is a log window, one is a reference window + and one is the actual output of the test. All these windows have the same width which is roughly + 1/3 of the screen. They also have the same height which is roughly equal to the screen height. + */ + TSize iStdTestWindowSize; + CMinWin* iMinWin; + TInt iTestNum; + TBool iFail; // Used to trigger failures to test test code. + TInt iThreadNumber; + /** + The type of redraw store in use. Static members so that RedrawStoreTypeL computes + this value only once and then returns the cached result as this remains the same for + the entire test run. + */ + static TPartialRedrawType iRedrawType; + /** The number of greys available in the richest grey mode. */ + static TInt iMaxGrays; + /** The number of colours available in the richest supported colour mode. */ + static TInt iMaxColors; + }; + +class CTWsGraphicsBase : public CTGraphicsBase + { +public: + CTWsGraphicsBase(CTestStep* aStep); + ~CTWsGraphicsBase(); + void CreateTestBaseL(CTTMSGraphicsStep* aTmsStep); + inline CTestBase *TestBase() const {return(iTest);}; + void TestComplete(); + void LogMessage(const TText8* aFile,TInt aLine,TRefByValue aFmt,...); + TInt GetScreenFromIni() const; +protected: + void CheckRect(TPoint aPos1,TPoint aPos2,TSize aSize, const TDesC *aErrorMsg=NULL); + void CheckRect(TPoint aPos1,TPoint aPos2,TSize aSize, const TDesC &aErrorMsg); + void CheckRectNoMatch(TPoint aPos1,TPoint aPos2,TSize aSize, const TDesC *aErrorMsg=NULL); + void CheckRectNoMatch(TPoint aPos1,TPoint aPos2,TSize aSize, const TDesC &aErrorMsg); + void CheckRect(CTBaseWin *aWin1,CTBaseWin *aWin2, const TDesC *aErrorMsg=NULL); + void CheckRect(CTBaseWin *aWin1,CTBaseWin *aWin2, const TDesC &aErrorMsg); + void CheckRectNoMatch(CTBaseWin *aWin1,CTBaseWin *aWin2, const TDesC *aErrorMsg=NULL); + void CheckRectNoMatch(CTBaseWin *aWin1,CTBaseWin *aWin2, const TDesC &aErrorMsg); + TBool CheckRect(CTBaseWin *aWin1,CTBaseWin *aWin2,const TRect &aRect, const TDesC *aErrorMsg=NULL); + TBool CheckRect(CTBaseWin *aWin1,CTBaseWin *aWin2,const TRect &aRect, const TDesC &aErrorMsg); + void CheckRectNoMatch(CTBaseWin *aWin1,CTBaseWin *aWin2,const TRect &aRect, const TDesC *aErrorMsg=NULL); + void CheckRectNoMatch(CTBaseWin *aWin1,CTBaseWin *aWin2,const TRect &aRect, const TDesC &aErrorMsg); + TBool CompareWindows(const TDesC *aErrorMsg=NULL); + TBool CompareWindows(const TDesC &aErrorMsg); + void CompareWindows(const TRect &aRect, const TDesC *aErrorMsg=NULL); + void CompareWindows(const TRect &aRect, const TDesC &aErrorMsg); + void CompareWindowsSoftFailWinscw(const TText8* aFile, TInt aLine); + const TSize& StdTestWindowSize(); + TInt MaxGrays() const; + TInt MaxColors() const; +private: + TBool CheckRetValue(TBool aPass,const TDesC* aErrorMsg,const TDesC& aErrorFunction); +protected: + CTestBase* iTest; + CTTMSGraphicsStep* iTmsStep; + }; + +class TestWindowGroup : public CTWindowGroup + { +public: + TestWindowGroup(CTClient *aClient); + void BecomeOwning(); + void KeyL(const TKeyEvent &aKey,const TTime &aTime); + void KeyDownL(const TKeyEvent &aKey,const TTime &aTime); + void KeyUpL(const TKeyEvent &aKey,const TTime &aTime); + }; + +class TestClient : public CTClient + { +public: + TestClient(); + ~TestClient(); + void ConstructL(); // virtual from CTClient + void KeyL(const TKeyEvent &aKey,const TTime &aTime); + void Shutdown(); + inline CTestDriver* Driver(); + TBool WaitForEvent(); + TBool IsEventWaiting(); + void LogAvailableScreenModeL(); + void TestWsSetBufferSizeL(); + void TestWsSetMaxBufferSizeL(); + inline LogWindow& StdLogWindow() {return *iStdLogWindow;} + void SetTestClientScreenMode(TInt aMode); + void UpdateTestClientScreenMode(); +public: + RArray iScreenModes; + +private: + /** + Several tests use 3 windows : one is a log window, one is a reference window + and one is the actual output of the test. This member is the log window. + */ + LogWindow* iStdLogWindow; + CTestDriver* iDriver; + }; + +class TThreadStartUp + { +public: + TThreadStartUp() :iInitFunction(0), iParam(0) {} + TThreadStartUp(TThreadFunction aInitFunction,TAny* aParam) :iInitFunction(aInitFunction), iParam(aParam) {} +public: + TThreadFunction iInitFunction; //The call to this fn will prepare a cleanup stack, but this function should not leave. + TAny* iParam; + }; + +#if defined(__WINS__) + const TOwnerType KOwnerType=EOwnerThread; +#else + const TOwnerType KOwnerType=EOwnerProcess; +#endif + +typedef TBuf<32> TBufArg; + +class CProcess : public CBase + { +public: + enum + { + eProcessPriortyTest, + eProcessKeyTest, + eProcessDirectTest, + eProcessMultiDisplayTest, + eNumProcessCalls //Must be last one + }; + struct TInitialFunction + { + inline TInitialFunction(const TDesC& aParam,TThreadFunction aFunction) :iParam(aParam), iFunction(aFunction) {} + TBuf<16> iParam; + TThreadFunction iFunction; + }; +public: + static TInt Start(const TWinCommand& aParam); + static CProcess* NewL(TInt aFunctionNo,TInt aScreenNumber=KDefaultScreen); + static CProcess* NewTL(TInt aFunctionNo,TInt aScreenNumber=KDefaultScreen,TRequestStatus* aClientRequestStatus = NULL); + static CProcess* NewThreadL(const TDesC& aName,TThreadFunction aFunction,TThreadStartUp* aPtr + ,TRequestStatus* aStatus); + static CProcess* NewThreadL(const TDesC& aName,TThreadStartUp* aPtr); + static CProcess* NewThreadRendezvousL(const TDesC& aName,TThreadFunction aFunction,TThreadStartUp* aPtr,TRequestStatus* aLogonStatus,TRequestStatus& aRendezvousStatus); + static CProcess* NewThreadRendezvousL(const TDesC& aName,TThreadStartUp* aPtr,TRequestStatus& aRendezvousStatus); + + static CProcess* NewSimpleThreadL(const TDesC& aName,TThreadStartUp* aPtr,TRequestStatus* aStatus=NULL); + void ConstructL(TInt aFunctionNo,TInt aScreenNumber=KDefaultScreen); + void ConstructTL(TInt aFunctionNo,TInt aScreenNumber=KDefaultScreen,TRequestStatus* aStatus=NULL); + void ConstructL(const TDesC& aName,TThreadFunction aFunction,TThreadStartUp* aPtr,TRequestStatus* aStatus); + void ConstructRendezvousL(const TDesC& aName,TThreadFunction aFunction,TThreadStartUp* aPtr,TRequestStatus* aLogonStatus,TRequestStatus& aRendezvousStatus); + + ~CProcess(); + void Logon(TRequestStatus& aStatus) const; + void Terminate(TInt aReason); + TBool StillAlive(); + void LeaveIfDied(); + static TBool ProcessDied(TInt aScreenNo=KDefaultScreen); +private: + enum + { + eOtherCreated=0x0001, + eThreadCreated=0x0002, + }; +private: + static TInt ThreadInit(TAny *aPtr); + static void InitialiseL(TThreadStartUp* aPtr); + static TInt SimpleThreadInit(TAny *aPtr); + void Close(); + static void GetProcArg(const TWinCommand& aParam,TBufArg& aProcArg); + static void GetScreenArg(const TWinCommand& aParam, TInt& aScreenArg); + +private: + TUint iCreated; + RProcess iOther; + RThread iThread; + static TInitialFunction iFunctions[eNumProcessCalls]; + }; + +GLREF_D TestWindow* BaseWin; +GLREF_D TestWindow* TestWin; +GLREF_D TestClient* TheClient; +GLREF_D CWindowGc* TheGc; + +GLREF_C void AutoPanic(TInt aPanic); +GLREF_C void CleanUpWindow(TAny *aWindow); +GLREF_C void PushWindowL(RWindowTreeNode *aWindow); +GLREF_C TBool OpacityAndAlphaSupportedL(); +GLREF_C TInt TransparencySupportedL(); +GLREF_C TInt CheckScalingSupportedOrNot(); +GLREF_C TBool CheckNonZeroOriginsSupportedOrNot(); +GLREF_C TPoint PhysicalToLogical(TPoint aPhysicalPtMinusOrigin,TSize aScale); +GLREF_C TPtrC DisplayModeAsString(TDisplayMode aMode); +GLREF_C TBool LossyCheckBlankBitmap(const CFbsBitmap& aBitmap, const TRect aArea, const TRgb aCheckColor, TBool aLossyCompare=ETrue); +GLREF_C TBool LossyCompareBitmap(const CFbsBitmap& aBitmap1, const CFbsBitmap& aBitmap2, const TRect aCompareRect, TBool aLossyCompare=ETrue); +GLDEF_C TBool LossyCompareBitmapRecord(CFbsBitmap& aBitmap1, CFbsBitmap& aBitmap2, const TRect aCompareRect, TBool aLossyCompare, TInt& aPixelsDifferent, CTestExecuteLogger& aLogger); +GLREF_C TBool LossyCheckBlankWindow(const CWsScreenDevice& aScreen, CFbsBitmap& aBitmap, const TRect aArea, const TRgb aCheckColor); +GLREF_C TBool LossyCompareWindow(const CWsScreenDevice& aScreen, CFbsBitmap& aBitmap1, CFbsBitmap& aBitmap2, const TRect aCompareRect); + +#define LogText(S) {_LIT(String__LINE__,S); Logger.Log(String__LINE__);} +#define LogFormat(S) {Logger.Log(S);} + +inline CTestDriver* CTestBase::Driver() + { + return iDriver; + } + +class CTransWindow : public CBlankWindow + { +public: + static CTransWindow* NewL(RPointerArray& aWindows,TRgb aColor,TRect aPos); + static CTransWindow* NewL(CTWinBase* aParent,TRgb aColor,TRect aPos,TDisplayMode* aDisplayMode); + static CTransWindow* NewL(CTWinBase* aParent,TRgb aColor,TDisplayMode* aDisplayMode); + void ToggleVisibility(); + static void SetOrdinal(RPointerArray& aWindows,TInt aOldPos,TInt aNewPos); + inline TRgb Color() {return iCol;} + inline TBool IsVisible() {return iVisible;} + void SetShadowDisabled(TBool aState); + inline TBool IsShadowing() {return iShadowing;} + inline TBool ShadowHeight() {return iShadowHight;} + inline void SetPosOffset(TPoint aOffset) {iPosOffset=aOffset;} + virtual void Draw(); + void SetDrawOpaque(TBool aDrawOpaque) { iDrawOpaque = aDrawOpaque; } + TBool DrawOpaque() const { return iDrawOpaque; } + //Virtual functions from CTWinBase overridden in CTBaseWin + void AdjustShadow(TInt aAdjust); + TPoint Position() const; + inline TInt TransparentError() {return iError;} +private: + CTransWindow(TRgb aColor) :CBlankWindow(aColor), iVisible(ETrue) {} + //Virtual function from CTBaseWin + void InitWin(); +private: + TBool iVisible; + TBool iShadowing; + TBool iDrawOpaque; + TInt iShadowHight; + TPoint iPosOffset; + TInt iError; + }; + +class CMinWin : public CBase + { +public: + CMinWin(TInt aScreenNo); + ~CMinWin(); + void ConstructL(); + void Draw(const TRect& aRect); +private: + RWsSession iWs; + RWindow iWin; + RWindowGroup iGroup; + CWsScreenDevice* iScr; + TInt iScreenNo; + TRect iRect; + CWindowGc* iGc; + }; + +class CTimeOut : public CTimer + { +public: + inline CTimeOut(): CTimer((EPriorityLow+EPriorityIdle)/2) {} + void ConstructL(); + void Start(TTimeIntervalMicroSeconds32 aInterval,TCallBack aCallBack); + //Pure virtual from CActive + void RunL(); +private: + TCallBack iCallBack; + }; + +#define COMPARE_WINDOWS_SOFTFAIL_WINSCW CompareWindowsSoftFailWinscw((TText8*)__FILE__, __LINE__) + +#define __WS_CONSTRUCT_STEP__(a) \ + CT##a##Step::CT##a##Step() \ + { \ + SetTestStepName(KT##a##Step); \ + SetLogHeapInfo(ETrue); \ + } \ + \ +CTGraphicsBase* CT##a##Step::CreateTestL() \ + { \ + CTWsGraphicsBase* test=new (ELeave) CT##a (this); \ + test->CreateTestBaseL(this);\ + return test;\ + } + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/stdpanic.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/stdpanic.h Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,64 @@ +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#ifndef __STDPANIC_H__ +#define __STDPANIC_H__ + +enum TStdPluginPanic +{ + EStdPanicTemp = 0, + EStdPanicNoDisplayModeFound = 1, + EStdPanicCreatedOffScreenBitmapInWrongDimensions = 2, + EStdPanicStdRenderStageMustBeFinal = 3, + EStdPanicFlickerBufferRenderStageMustNotBeFinal = 4, + EStdPanicIniFileMissing = 5, // can't find an MWsIniFile instance + EStdPanicPreviousUiSurfaceUnregisterable = 6, + EStdPanicDuplicateUiLayer = 7, // occurs when trying to add a UI layer when another UI layer is already part of the scene + EStdPanicNonMatchingRemovalOfUiLayer = 8, // occurs when removing a UI layer, when it's not the current UI layer + EStdPanicUiSurfaceIsNull = 9, // occurs when the UI surface is NULL + EStdPanicScreenDeviceMissing = 10, // can't get MWsScreenDevice from the next render stage + EStdPanicCompositionContextMissing = 11, // can't get MWsCompositionContext from the next render stage + EStdPanicPopGcSettings = 12, // problem when popping gc settings, previously saved + EStdPanicDrawCommandsInvalidState = 13, //The draw commands state doesn't match with the action that is occuring + EStdPanicInvalidCursorType = 14, // invalid cursor + EStdPanicRegionError = 15, //Region is not NULL and TRegion::CheckError() has returned ETrue, or validation of region state has failed + EStdPanicBadBeginEndSequence = 16, // End() has been called without corresponding Begin(), or Begin() has been called twice. + EStdPanicRedrawNotCompleted = 17, // A redraw has been requested before the previous redraw has completed. + EStdPanicNoContext = 18, // Graphics context from the next rendering stage is not available +}; + +void Panic(TStdPluginPanic aPanic); + +#ifdef _DEBUG +#define STD_ASSERT_DEBUG(c, p) \ + do { \ + if(!(c)) \ + { \ + Panic(p); \ + } \ + } while (EFalse) +#else +#define STD_ASSERT_DEBUG(c, p) +#endif //_DEBUG + +#define STD_ASSERT_ALWAYS(c, p) \ + do { \ + if(!(c)) \ + { \ + Panic(p); \ + } \ + } while (EFalse) + +#endif //__STDPANIC_H__ diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/symball.gif Binary file windowing/windowserver/test/tauto/symball.gif has changed diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/tadvancedpointerevent.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/tadvancedpointerevent.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,411 @@ +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Advanced pointer event unit tests +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include "tadvancedpointerevent.h" + +CTAdvancedPointerEvent::CTAdvancedPointerEvent(CTestStep* aStep) + : CTWsGraphicsBase(aStep) + {} + +CTAdvancedPointerEvent::~CTAdvancedPointerEvent() + {} + +void CTAdvancedPointerEvent::TestPointerEventInit() + { + // Test size of class with hard coded values to prevent regression failure + TEST(sizeof(TPointerEvent) == 24); + + TPointerEvent ptrEvent1 = TPointerEvent(); + ptrEvent1.iType = TPointerEvent::EButton1Down; + TPoint initCoords(10,10); + ptrEvent1.iPosition = initCoords; + ptrEvent1.iParentPosition = initCoords; + ptrEvent1.iModifiers = 0; + + // Construct two TPointerEvent objects. The first using default constructor, the second using the copy constructor. T + { + TPointerEvent ptrEvent2 = TPointerEvent(ptrEvent1); + TEST(0==Mem::Compare(reinterpret_cast(&ptrEvent1),sizeof(TPointerEvent),reinterpret_cast(&ptrEvent2),sizeof(TPointerEvent))); + } + + { + TPointerEvent ptrEvent2(TPointerEvent::EButton1Down, 0, initCoords, initCoords); + TEST(0==Mem::Compare(reinterpret_cast(&ptrEvent1),sizeof(TPointerEvent),reinterpret_cast(&ptrEvent2),sizeof(TPointerEvent))); + } + } + +void AdvancedPointerInit(TWsEvent& aEvent1, TWsEvent& aEvent2, const TPointerEvent::TType aType, const TPoint3D& aPoint3D, const TUint8 aPointerNumber) + { + // init first event + TAdvancedPointerEvent& ptrEvent = *aEvent1.Pointer(); + ptrEvent.iType = aType; + ptrEvent.iModifiers = EModifierAdvancedPointerEvent; // done implicitly by TAdvancedPointerEvent::Init method + ptrEvent.iPosition.iX = aPoint3D.iX; + ptrEvent.iPosition.iY = aPoint3D.iY; + aEvent1.SetPointerNumber(aPointerNumber); + aEvent1.SetPointerZ(aPoint3D.iZ); + + // init 2nd event + aEvent2.InitAdvancedPointerEvent(aType,0,aPoint3D,aPointerNumber); + } + +void CTAdvancedPointerEvent::TestAdvancedPointerInit() + { + // Test size of class with hard coded values to prevent regression failure + TEST(sizeof(TAdvancedPointerEvent) == 32); + + TWsEvent event1; + TWsEvent event2; + + // low value coords, lowest value event type + { + TPoint3D point3D(1,2,3); + AdvancedPointerInit(event1, event2, TPointerEvent::EButton1Down, point3D, 1); + } + TEST(0==Mem::Compare(reinterpret_cast(&event1),sizeof(TWsEvent),reinterpret_cast(&event2),sizeof(TWsEvent))); + + // high value coords, highest value event type and pointer number + { + TPoint3D point3D(KMaxTInt, KMaxTInt-1, KMaxTInt-3); + AdvancedPointerInit(event1, event2, TPointerEvent::EOutOfRange, point3D, KMaxTUint8); + } + TEST(0==Mem::Compare(reinterpret_cast(&event1),sizeof(TWsEvent),reinterpret_cast(&event2),sizeof(TWsEvent))); + + // high negative value coords, highest value event type and pointer number + { + TPoint3D point3D(KMinTInt, KMinTInt+1, KMinTInt+3); + AdvancedPointerInit(event1, event2, TPointerEvent::EOutOfRange, point3D, KMaxTUint8); + } + TEST(0==Mem::Compare(reinterpret_cast(&event1),sizeof(TWsEvent),reinterpret_cast(&event2),sizeof(TWsEvent))); + } + +void CTAdvancedPointerEvent::TestAdvancedPointerGetPointerId() + { + TWsEvent event; + TAdvancedPointerEvent& ptrEvent = *event.Pointer(); + const TPoint3D point3D(1,2,3); + const TUint8 MaxLikelyCommonPointerNumber = 10; + + // Likely Common Values + TUint8 pointerNumber = 0; + for(;pointerNumber<=MaxLikelyCommonPointerNumber;pointerNumber++) + { + event.InitAdvancedPointerEvent(TPointerEvent::EMove,0,point3D,pointerNumber); + TEST(ptrEvent.PointerNumber()==pointerNumber); + } + + // mid-range value + pointerNumber = 127; + event.InitAdvancedPointerEvent(TPointerEvent::EMove,0,point3D,pointerNumber); + TEST(ptrEvent.PointerNumber()==pointerNumber); + + // highest value + pointerNumber = 255; // KMaxTUint8 is there was one defined. + event.InitAdvancedPointerEvent(TPointerEvent::EMove,0,point3D,pointerNumber); + TEST(ptrEvent.PointerNumber()==pointerNumber); + } + +/** helper method for TestAdvancedPointerGetPressureAndProximity() */ +void CTAdvancedPointerEvent::TestAdvancedPointerGetPressureAndProximity(const TPoint3D aPoint3D) + { + TWsEvent event; + event.InitAdvancedPointerEvent(TPointerEvent::EMove, 0, aPoint3D, 0); + TAdvancedPointerEvent ptrEvent = *event.Pointer(); + const TPoint3D positionAndPressure3D = ptrEvent.PositionAndPressure3D(); + TEST(0==Mem::Compare(reinterpret_cast(&aPoint3D),sizeof(TPoint3D),reinterpret_cast(&positionAndPressure3D),sizeof(TPoint3D))); + TInt proximityAndPressure = ptrEvent.ProximityAndPressure(); + TEST(aPoint3D.iZ==proximityAndPressure); + } + +void CTAdvancedPointerEvent::TestAdvancedPointerGetPressureAndProximity() + { + { + // middle value + TPoint3D point3D(0,0,0); + TestAdvancedPointerGetPressureAndProximity(point3D); + } + { + // Typical value + TPoint3D point3D(10,9,8); + TestAdvancedPointerGetPressureAndProximity(point3D); + } + { + // Typical value + TPoint3D point3D(10,9,-8); + TestAdvancedPointerGetPressureAndProximity(point3D); + } + { + // max values + TPoint3D point3D(KMaxTInt-2,KMaxTInt-1,KMaxTInt); + TestAdvancedPointerGetPressureAndProximity(point3D); + } + { + // min values + TPoint3D point3D(KMinTInt+2,KMinTInt+1,KMinTInt); + TestAdvancedPointerGetPressureAndProximity(point3D); + } + } + +void CTAdvancedPointerEvent::TestAdvancedPointerGetPressure() + { + { + // middle value + const TPoint3D point3D(0,0,0); + TWsEvent event; + event.InitAdvancedPointerEvent(TPointerEvent::EMove, 0, point3D, 0); + TAdvancedPointerEvent ptrEvent = *event.Pointer(); + const TPoint3D pressure3D = ptrEvent.Pressure3D(); + TEST(0==Mem::Compare(reinterpret_cast(&point3D),sizeof(TPoint3D),reinterpret_cast(&pressure3D),sizeof(TPoint3D))); + TInt pressure = ptrEvent.Pressure(); + TEST(point3D.iZ==pressure); + } + { + // Typical value + const TPoint3D point3D(10,9,8); + TWsEvent event; + event.InitAdvancedPointerEvent(TPointerEvent::EMove, 0, point3D, 0); + TAdvancedPointerEvent ptrEvent = *event.Pointer(); + const TPoint3D pressure3D = ptrEvent.Pressure3D(); + TEST(0==Mem::Compare(reinterpret_cast(&point3D),sizeof(TPoint3D),reinterpret_cast(&pressure3D),sizeof(TPoint3D))); + TInt pressure = ptrEvent.Pressure(); + TEST(point3D.iZ==pressure); + } + { + // max value + const TPoint3D point3D(KMaxTInt-2,KMaxTInt-1,KMaxTInt); + TWsEvent event; + event.InitAdvancedPointerEvent(TPointerEvent::EMove, 0, point3D, 0); + TAdvancedPointerEvent ptrEvent = *event.Pointer(); + const TPoint3D pressure3D = ptrEvent.Pressure3D(); + TEST(0==Mem::Compare(reinterpret_cast(&point3D),sizeof(TPoint3D),reinterpret_cast(&pressure3D),sizeof(TPoint3D))); + TInt pressure = ptrEvent.Pressure(); + TEST(point3D.iZ==pressure); + } + { + // min value + TPoint3D point3D(KMinTInt+2,KMinTInt+1,KMinTInt); + TWsEvent event; + event.InitAdvancedPointerEvent(TPointerEvent::EMove, 0, point3D, 0); + TAdvancedPointerEvent ptrEvent = *event.Pointer(); + const TPoint3D pressure3D = ptrEvent.Pressure3D(); + point3D.iZ=0; // pressure can't be negative + TEST(0==Mem::Compare(reinterpret_cast(&point3D),sizeof(TPoint3D),reinterpret_cast(&pressure3D),sizeof(TPoint3D))); + TInt pressure = ptrEvent.Pressure(); + TEST(0==pressure); + } + } + +void CTAdvancedPointerEvent::TestAdvancedPointerGetPosition() + { + { + // middle value + const TPoint3D point3D(0,0,0); + TWsEvent event; + event.InitAdvancedPointerEvent(TPointerEvent::EMove, 0, point3D, 0); + TAdvancedPointerEvent ptrEvent = *event.Pointer(); + const TPoint3D position3D = ptrEvent.Position3D(); + TEST(0==Mem::Compare(reinterpret_cast(&point3D),sizeof(TPoint3D),reinterpret_cast(&position3D),sizeof(TPoint3D))); + TInt proximity = ptrEvent.Proximity(); + TEST(point3D.iZ==proximity); + } + { + // typical value + const TPoint3D point3D(10,9,-8); + TWsEvent event; + event.InitAdvancedPointerEvent(TPointerEvent::EMove, 0, point3D, 0); + TAdvancedPointerEvent ptrEvent = *event.Pointer(); + const TPoint3D position3D = ptrEvent.Position3D(); + TEST(0==Mem::Compare(reinterpret_cast(&point3D),sizeof(TPoint3D),reinterpret_cast(&position3D),sizeof(TPoint3D))); + TInt proximity = ptrEvent.Proximity(); + TEST(point3D.iZ==proximity); + } + { + // highest value + TPoint3D point3D(KMaxTInt-2,KMaxTInt-1,KMaxTInt); + TWsEvent event; + event.InitAdvancedPointerEvent(TPointerEvent::EMove, 0, point3D, 0); + TAdvancedPointerEvent ptrEvent = *event.Pointer(); + const TPoint3D position3D = ptrEvent.Position3D(); + point3D.iZ=0; // proximity can't be positive + TEST(0==Mem::Compare(reinterpret_cast(&point3D),sizeof(TPoint3D),reinterpret_cast(&position3D),sizeof(TPoint3D))); + TInt proximity = ptrEvent.Proximity(); + TEST(0==proximity); + } + { + // lowest value + const TPoint3D point3D(KMinTInt+2,KMinTInt+1,KMinTInt); + TWsEvent event; + event.InitAdvancedPointerEvent(TPointerEvent::EMove, 0, point3D, 0); + TAdvancedPointerEvent ptrEvent = *event.Pointer(); + const TPoint3D position3D = ptrEvent.Position3D(); + TEST(0==Mem::Compare(reinterpret_cast(&point3D),sizeof(TPoint3D),reinterpret_cast(&position3D),sizeof(TPoint3D))); + TInt proximity = ptrEvent.Proximity(); + TEST(point3D.iZ==proximity); + } + } + +void CTAdvancedPointerEvent::TestPointerEventCopying() + { + TWsEvent event; + event.InitAdvancedPointerEvent(TPointerEvent::EMove, 0, TPoint3D(2,3,4),1); + TPointerEvent testPointerEvent; + testPointerEvent.iModifiers =0; + testPointerEvent.iParentPosition=TPoint(0,0); + testPointerEvent.iPosition = TPoint(2,3); + testPointerEvent.iType=TPointerEvent::EMove; + + // TPointerEvent to TPointerEvent + // Copy Constructor + { + TPointerEvent* pointerEventPtr = event.Pointer(); + TPointerEvent pointerEvent = *pointerEventPtr; + TEST(0==Mem::Compare(reinterpret_cast(&pointerEvent),sizeof(TPointerEvent),reinterpret_cast(&testPointerEvent),sizeof(TPointerEvent))); + } + // Assignment operator + { + TPointerEvent* pointerEventPtr = event.Pointer(); + TPointerEvent pointerEvent; + pointerEvent = *pointerEventPtr; + TEST(0==Mem::Compare(reinterpret_cast(&pointerEvent),sizeof(TPointerEvent),reinterpret_cast(&testPointerEvent),sizeof(TPointerEvent))); + } + // TAdvancedPointerEvent to TPointerEvent + // Copy Constructor + { + TAdvancedPointerEvent* advancedPointerEventPtr = event.Pointer(); + TPointerEvent pointerEvent = *advancedPointerEventPtr; + TEST(0==Mem::Compare(reinterpret_cast(&pointerEvent),sizeof(TPointerEvent),reinterpret_cast(&testPointerEvent),sizeof(TPointerEvent))); + } + // Assignment operator + { + TAdvancedPointerEvent* advancedPointerEventPtr = event.Pointer(); + TPointerEvent pointerEvent; + pointerEvent = *advancedPointerEventPtr; + TEST(0==Mem::Compare(reinterpret_cast(&pointerEvent),sizeof(TPointerEvent),reinterpret_cast(&testPointerEvent),sizeof(TPointerEvent))); + } + + // TPointerEvent to TPointerEvent + // Copy Method + { + TPointerEvent* pointerEventPtr = event.Pointer(); + TPointerEvent pointerEvent; + pointerEvent.Copy(*pointerEventPtr); + TEST(0==Mem::Compare(reinterpret_cast(&pointerEvent),sizeof(TPointerEvent),reinterpret_cast(&testPointerEvent),sizeof(TPointerEvent))); + } + + // TAdvancedPointerEvent to TPointerEvent + // Copy Constructor + { + TAdvancedPointerEvent* advancedPointerEventPtr = event.Pointer(); + TPointerEvent pointerEvent; + pointerEvent.Copy(*advancedPointerEventPtr); + TEST(0==Mem::Compare(reinterpret_cast(&pointerEvent),sizeof(TPointerEvent),reinterpret_cast(&testPointerEvent),sizeof(TPointerEvent))); + } + + // Assignment operator + { + TAdvancedPointerEvent* advancedPointerEventPtr = event.Pointer(); + TAdvancedPointerEvent advancedPointerEventPtr2; + advancedPointerEventPtr2 = *advancedPointerEventPtr; + TEST(0==Mem::Compare(reinterpret_cast(&advancedPointerEventPtr2),sizeof(TAdvancedPointerEvent),reinterpret_cast(event.Pointer()),sizeof(TAdvancedPointerEvent))); + } + } + +void CTAdvancedPointerEvent::RunTestCaseL(TInt /*aCurTestCase*/) + { + _LIT(KTest1,"PointerEventInit"); + _LIT(KTest2,"AdvancedPointerEventInit"); + _LIT(KTest3,"PointerEventCopying"); + _LIT(KTest4,"AdvancedPointerEventGetPointerId"); + _LIT(KTest5,"AdvancedPointerEventGetPressureAndProximity"); + _LIT(KTest6,"AdvancedPointerEventGetPressure"); + _LIT(KTest7,"AdvancedPointerEventGetPosition"); + + ((CTAdvancedPointerEventStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); + switch(++iTest->iState) + { + case 1: +/** +@SYMTestCaseID GRAPHICS-WSERV-0542 +*/ + ((CTAdvancedPointerEventStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0542")); + iTest->LogSubTest(KTest1); + TestPointerEventInit(); + break; + case 2: +/** +@SYMTestCaseID GRAPHICS-WSERV-0543 +*/ + ((CTAdvancedPointerEventStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0543")); + iTest->LogSubTest(KTest2); + TestAdvancedPointerInit(); + break; + case 3: +/** +@SYMTestCaseID GRAPHICS-WSERV-0544 +*/ + ((CTAdvancedPointerEventStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0544")); + iTest->LogSubTest(KTest3); + TestPointerEventCopying(); + break; + case 4: +/** +@SYMTestCaseID GRAPHICS-WSERV-0545 +*/ + ((CTAdvancedPointerEventStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0545")); + iTest->LogSubTest(KTest4); + TestAdvancedPointerGetPointerId(); + break; + case 5: +/** +@SYMTestCaseID GRAPHICS-WSERV-0546 +*/ + ((CTAdvancedPointerEventStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0546")); + iTest->LogSubTest(KTest5); + TestAdvancedPointerGetPressureAndProximity(); + break; + case 6: +/** +@SYMTestCaseID GRAPHICS-WSERV-0547 +*/ + ((CTAdvancedPointerEventStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0547")); + iTest->LogSubTest(KTest6); + TestAdvancedPointerGetPressure(); + break; + case 7: +/** +@SYMTestCaseID GRAPHICS-WSERV-0548 +*/ + ((CTAdvancedPointerEventStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0548")); + iTest->LogSubTest(KTest7); + TestAdvancedPointerGetPosition(); + break; + default: + ((CTAdvancedPointerEventStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + ((CTAdvancedPointerEventStep*)iStep)->CloseTMSGraphicsStep(); + TestComplete(); + break; + } + ((CTAdvancedPointerEventStep*)iStep)->RecordTestResultL(); + } + +__WS_CONSTRUCT_STEP__(AdvancedPointerEvent) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/tadvancedpointerevent.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/tadvancedpointerevent.h Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,63 @@ + +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// tadvancedpionter.h +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef tadvancedpointerevent_h +#define tadvancedpointerevent_h + +#include "w32std.h" +#include "AUTO.H" +#include "../tlib/testbase.h" +#include "TGraphicsHarness.h" + +class CTAdvancedPointerEvent : public CTWsGraphicsBase + { +public: + CTAdvancedPointerEvent(CTestStep* aStep); + virtual ~CTAdvancedPointerEvent(); +protected: + //from CTGraphicsStep + virtual void RunTestCaseL(TInt aCurTestCase); +private: + void TestPointerEventInit(); + void TestAdvancedPointerInit(); + void TestAdvancedPointerGetPointerId(); + void TestAdvancedPointerGetPressureAndProximity(); + void TestAdvancedPointerGetPressureAndProximity(const TPoint3D aPoint3D); + void TestAdvancedPointerGetPressure(); + void TestAdvancedPointerGetPosition(); + void TestPointerEventCopying(); + }; + +class CTAdvancedPointerEventStep : public CTGraphicsStep + { +public: + CTAdvancedPointerEventStep(); +protected: + //from CTGraphicsStep + virtual CTGraphicsBase* CreateTestL(); + }; + +_LIT(KTAdvancedPointerEventStep,"TAdvancedPointerEvent"); + +#endif // tadvancedpointerevent_h diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/talphawin.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/talphawin.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,1272 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Test alpha channel transparent windows +// Test that draw operations with non-opaque colours do alpha blending in EColor64K and EColor16MA display modes +// Test that alpha channel transparent windows are drawn correctly when windows move, redraw, change visibility, etc. +// In the draw operation tests, the left window draws opaque pink on white background, the right window blends semi-transparent red on white background, +// and the results are compared. +// In the transparent window tests, the right window contains several transparent windows, which are moved, redrawn, visibility changed, etc, +// the left window contains a single window in which we draw what we expect the right window to look like. The results are compared. +// In each case, the left and right windows should be identical +// +// + + +#include "TALPHAWIN.H" + +enum + { + EOpDrawRect, + EOpDrawLine, + EOpDrawEllipse, + EOpDrawText, + EOpDrawTextVertical, + EOpDrawTextAntiAliased, + EOpBitBlt, + EOpBitBltMasked, + ENumDrawOps + }; + + +enum + { + ERed = 0x1, + EGreen = 0x2, + EBlue = 0x4, + + EAlphaTransparency = 0x8, + ETransparencyFactor = 0x10, + // defaults to non-transparent + + EOpaque = 0x20, + ETransparent = 0x40, + // defaults to semi-transparent + + EModeColor64K = 0x80, + EModeColor16MA = 0x100, + // defaults to 64k + + EInvisible = 0x200, + + EActive = 0xf000000 + }; + + +TRgb ColourFromDrawState(TInt aDrawState) + { + TInt red = (aDrawState & ERed) ? 255 : 0; + TInt green = (aDrawState & EGreen) ? 255 : 0; + TInt blue = (aDrawState & EBlue) ? 255 : 0; + TInt alpha = 128; + if (aDrawState & EOpaque) + alpha = 255; + if (aDrawState & ETransparent) + alpha = 0; + return TRgb(red, green, blue, alpha); + } + + + +// +// CTAlphaWinTest +// + +CTAlphaWin::CTAlphaWin(CTestStep* aStep): + CTWsGraphicsBase(aStep) + { + } + +CTAlphaWin::~CTAlphaWin() + { + iTestWin.DeleteAll(); + delete iRefWin; + } + +void CTAlphaWin::ConstructL() + { + if(TransparencySupportedL() == KErrNotSupported) + return; + + TSize winSize = BaseWin->Size(); + + iTestWin[0] = CTAlphaWindow::NewL(this, TestWin, TPoint(0,0), winSize, ERed | EGreen | EBlue | EOpaque); + iTestWin[1] = CTAlphaWindow::NewL(this, TestWin, TPoint(0,0), TSize(winSize.iWidth/2, winSize.iHeight/2), ERed | EAlphaTransparency); + iTestWin[2] = CTAlphaWindow::NewL(this, TestWin, TPoint(winSize.iWidth/3,0), TSize(winSize.iWidth/2, winSize.iHeight/2), EGreen | EAlphaTransparency); + iTestWin[3] = CTAlphaWindow::NewL(this, TestWin, TPoint(winSize.iWidth/6, winSize.iHeight/3), TSize(winSize.iWidth/2, winSize.iHeight/2), EBlue | EAlphaTransparency); + iTestWin[4] = CTAlphaWindow::NewL(this, TestWin, TPoint(winSize.iWidth/4,winSize.iHeight/6), TSize(winSize.iWidth/3,winSize.iHeight/3), ERed | EGreen | EBlue | EAlphaTransparency | ETransparent); + + iRefWin = CTAlphaRefWin::NewL(BaseWin, TPoint(0,0), winSize, iTestWin); + //Clearing the windows + BaseWin->ClearWin(); + TestWin->ClearWin(); + } + +void CTAlphaWin::ConfigureDisplayModes(TDisplayMode aRequiredMode = EColor16M) + { + TInt i; + for (i=0; i<5; i++) + { + iTestWin[i]->BaseWin()->SetRequiredDisplayMode(aRequiredMode); + } + iRefWin->BaseWin()->SetRequiredDisplayMode(aRequiredMode); + } + + +void CTAlphaWin::TestSemiTransparentDrawingL() + { + TSize winSize = BaseWin->Size(); + + // In this window, we draw opaque pink + CTDrawOpWin* drawWin = CTDrawOpWin::NewL(this, BaseWin, TPoint(0,0), winSize, TRgb(255,127,127,255)); + + // In this window, we blend semi-transparent red + CTDrawOpWin* blendWin = CTDrawOpWin::NewL(this, TestWin, TPoint(0,0), winSize, TRgb(255,0,0,128)); + + const TInt tolerance = 9;//8 - wouldn't be enough!! The defect DEF112334 was raised + for (TInt i=EOpDrawRect; iSetDrawOp(i); + blendWin->SetDrawOp(i); + drawWin->DrawNow(); + blendWin->DrawNow(); + TheClient->Flush(); + TheClient->WaitForRedrawsToFinish(); + + if((i == EOpDrawTextAntiAliased) && (TheClient->iScreen->DisplayMode() == EColor16MA) || (TheClient->iScreen->DisplayMode() == EColor16MAP)) + { + TSize winSize=BaseWin->Size(); + TRect rect1(BaseWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),winSize); + TRect rect2(TestWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),winSize); + + CheckRectL(rect1, rect2, winSize, TheClient->iScreen->DisplayMode(), tolerance, _L("CTAlphaWin::TestSemiTransparentDrawingL()")); + } + else + { + CheckRect(BaseWin,TestWin,_L("CTAlphaWin::TestSemiTransparentDrawingL()")); + } + } + delete drawWin; + delete blendWin; + } + +void CTAlphaWin::TestTransparentDrawingL() + { + TSize winSize = BaseWin->Size(); + + // In this window, we draw opaque white + CTDrawOpWin* drawWin = CTDrawOpWin::NewL(this, BaseWin, TPoint(0,0), winSize, TRgb(255,255,255,255)); + + // In this window, we blend transparent red + CTDrawOpWin* blendWin = CTDrawOpWin::NewL(this, TestWin, TPoint(0,0), winSize, TRgb(255,0,0,0)); + + for (TInt i=EOpDrawRect; iSetDrawOp(i); + blendWin->SetDrawOp(i); + drawWin->DrawNow(); + blendWin->DrawNow(); + TheClient->Flush(); + TheClient->WaitForRedrawsToFinish(); + CheckRect(BaseWin,TestWin,_L("CTAlphaWin::TestTransparentDrawingL()")); + } + delete drawWin; + delete blendWin; + } + +void CTAlphaWin::CheckRectL(const TRect& aRect1, const TRect& aRect2, TSize aSize, TDisplayMode aRequiredMode, TInt aTolerance, const TDesC& aErrorMsg) + { + CFbsBitmap *bmp1 = new (ELeave) CFbsBitmap; + CleanupStack::PushL(bmp1); + User::LeaveIfError(bmp1->Create(aSize, aRequiredMode)); + + CFbsBitmap *bmp2 = new (ELeave) CFbsBitmap; + CleanupStack::PushL(bmp2); + User::LeaveIfError(bmp2->Create(aSize, aRequiredMode)); + + User::LeaveIfError(TheClient->iScreen->CopyScreenToBitmap(bmp1, aRect1)); + User::LeaveIfError(TheClient->iScreen->CopyScreenToBitmap(bmp2, aRect2)); + + TRgb *rgbBuf1=(TRgb *)User::AllocL(aSize.iWidth*sizeof(TRgb)); + TRgb *rgbBuf2=(TRgb *)User::Alloc(aSize.iWidth*sizeof(TRgb)); + if(!rgbBuf2) + { + User::Free(rgbBuf1); + User::Leave(KErrNoMemory); + } + TBool equal = ETrue; + TInt maxDeviation = 0; + for(TInt yy = 0; yy < aSize.iHeight && equal; yy++) + { + TPtr8 ptr1((TUint8 *)rgbBuf1,aSize.iWidth*sizeof(TRgb)); + bmp1->GetScanLine(ptr1, TPoint(0, yy), aSize.iWidth, ERgb); + TPtr8 ptr2((TUint8 *)rgbBuf2,aSize.iWidth*sizeof(TRgb)); + bmp2->GetScanLine(ptr2, TPoint(0, yy), aSize.iWidth, ERgb); + + TRgb *rgbBufCur1 = rgbBuf1; + TRgb *rgbBufCur2 = rgbBuf2; + for(TInt ii = 0; ii < aSize.iWidth; ii++) + { + TInt delta = Abs(rgbBufCur1->Red()-rgbBufCur2->Red()); + TInt delta1 = Abs(rgbBufCur1->Green()-rgbBufCur2->Green()); + TInt delta2 = Abs(rgbBufCur1->Blue()-rgbBufCur2->Blue()); + + if((delta > aTolerance) || (delta1 > aTolerance) || (delta2 > aTolerance)) + { + equal = EFalse; + } + TInt maxItermedia = Max(delta1, delta2); + maxItermedia = Max(maxItermedia, delta); + maxDeviation = Max(maxItermedia, maxDeviation); + + rgbBufCur1++; + rgbBufCur2++; + } + } + + User::Free(rgbBuf1); + User::Free(rgbBuf2); + + CleanupStack::PopAndDestroy(2,bmp1); + + if (!equal) + { + INFO_PRINTF3(_L("%S CheckRectA failed, max deviation %d"), &aErrorMsg, maxDeviation); + } + else if(maxDeviation) + { + INFO_PRINTF4(_L("%S CheckRectA passed with tolerance %d, max deviation %d"), &aErrorMsg, aTolerance, maxDeviation); + } + + iStep->TEST(equal); + } + +void CTAlphaWin::TestCondition() + { + // User::After(1000000);// helpful when debugging + iRefWin->DrawNow(); + TheClient->Flush(); + TheClient->WaitForRedrawsToFinish(); + CheckRect(BaseWin,TestWin,_L("CTAlphaWin::TestCondition()")); + } + +void CTAlphaWin::TestConditionL() + { + iRefWin->DrawNow(); + TheClient->Flush(); + TheClient->WaitForRedrawsToFinish(); + + const TInt tolerance = 9; + TSize winSize=BaseWin->Size(); + TRect rect1(BaseWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),winSize); + TRect rect2(TestWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),winSize); + CheckRectL(rect1, rect2, winSize, TheClient->iScreen->DisplayMode(), tolerance, _L("CTAlphaWin::TestCondition()")); + } + +void CTAlphaWin::TestInitialConfiguration() + { + if(TheClient->iScreen->DisplayMode() == EColor64K) + { + TestConditionL(); + } + else + { + TestCondition(); + } + } + +void CTAlphaWin::TestMove() + { + // Test moving windows, both in front and behind + for (TInt i = 0; i<5; i++) + { + TPoint pos = iTestWin[i]->Position(); + pos += TPoint(10,10); + iTestWin[i]->SetPos(pos); + TestCondition(); + } + for (TInt j = 0; j<5; j++) + { + TPoint pos = iTestWin[j]->Position(); + pos -= TPoint(10,10); + iTestWin[j]->SetPos(pos); + TestCondition(); + } + } + + +void CTAlphaWin::TestRedraw() + { + // Test redrawing windows, both in front and behind + for (TInt i=0; i<5; i++) + { + iTestWin[i]->DrawNow(); + TestCondition(); + } + } + + +void CTAlphaWin::TestInvisible() + { + // Test making windows visible and invisible, both in front and behind + for (TInt i=0; i<5; i++) + { + iTestWin[i]->SetVisible(EFalse); + TestCondition(); + iTestWin[i]->SetVisible(ETrue); + TestCondition(); + } + } + +void CTAlphaWin::TestChildrenL() + { + struct CTAlphaWinChildren: public TCleanupItem + { + static void Destroy(TAny* trg) + { + static_cast(trg)->DestroyChildren(); + } + CTAlphaWinChildren(CTAlphaWindow*trg): TCleanupItem(Destroy,trg) + {} + + }; + CleanupStack::PushL(CTAlphaWinChildren(iTestWin[2])); + iTestWin[2]->CreateChildrenL(3); + TestCondition(); + TestMove(); + CleanupStack::PopAndDestroy(iTestWin[2]); + } + + +void CTAlphaWin::TestAntiAliasedTextTransparentL() + { + + //Clear the screen + for (TInt i=0; i<5; i++) + { + iTestWin[i]->SetVisible(EFalse); + } + iRefWin->SetVisible(EFalse); + TheClient->iWs.Flush(); + + //Create a new test window on the left + //Create a transparent window: + TSize winSize = BaseWin->Size(); + + RWindow theWin(TestWin->Client()->iWs); + User::LeaveIfError(theWin.Construct(*(TestWin->WinTreeNode()),(TUint32)&theWin)); + + theWin.SetExtent(TPoint(0,0), winSize); + theWin.SetBackgroundColor(TRgb(127,0,255,127)); + TInt mode=theWin.SetRequiredDisplayMode(EColor16MA); + theWin.SetVisible(ETrue); + theWin.SetTransparencyAlphaChannel(); + theWin.Activate(); + TheClient->iWs.Flush(); + CleanupClosePushL(theWin); + + //get windows screen device. + CWsScreenDevice *device; + device = new (ELeave)CWsScreenDevice(TestWin->Client()->iWs);//(TheClient->iWs); + User::LeaveIfError(device->Construct(iTest->ScreenNumber())); + CleanupStack::PushL(device); + + TFontSpec fs1; + CFont *font1; + CFont *font2; + fs1.iTypeface.iName = KTestFontTypefaceName; + fs1.iHeight = 16; + fs1.iFontStyle.SetBitmapType(EDefaultGlyphBitmap); + int error = TheClient->iScreen->GetNearestFontToDesignHeightInPixels((CFont*&)font1,fs1); + if (error) + { + TheClient->iScreen->ReleaseFont(font1); + User::Panic(_L("font not created"),error); + } + fs1.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap); + error = TheClient->iScreen->GetNearestFontToDesignHeightInPixels((CFont*&)font2,fs1); + if (error) + { + TheClient->iScreen->ReleaseFont(font1); + TheClient->iScreen->ReleaseFont(font2); + User::Panic(_L("font not created"),error); + } + + CWindowGc *gc; + device->CreateContext(gc); + CleanupStack::PushL(gc); + + theWin.Invalidate(); + theWin.BeginRedraw(); + gc->Activate(theWin); + + gc->SetPenStyle( CGraphicsContext::ESolidPen ); + gc->SetPenColor( TRgb( 0, 0, 0, 127 ) ); + + //draw text for anti-aliasing needs an open font (scalable). + int typefaces = TheClient->iScreen->NumTypefaces(); + + gc->UseFont(font1); + gc->SetBrushStyle( CGraphicsContext::ENullBrush ); + gc->DrawText(_L("Test"),TPoint(10,20)); + gc->DiscardFont(); + gc->UseFont(font2); + gc->DrawText(_L("Test"),TPoint(10,60)); + gc->DiscardFont(); + + //destruction and tidying up + gc->Deactivate(); + theWin.EndRedraw(); + TheClient->iWs.Flush(); + + TheClient->iScreen->ReleaseFont(font1); + TheClient->iScreen->ReleaseFont(font2); + CleanupStack::PopAndDestroy(gc);//gc + CleanupStack::PopAndDestroy(device);//device + + //do not close the test window yet since there is a comparison + //required + + //now do the same on an off screen bitmap. Then create a window + //and put the bitmap onto it. + //create a colour bitmap + // + CFbsBitmap *bitmapOne; + bitmapOne = new (ELeave)CFbsBitmap(); + CleanupStack::PushL(bitmapOne); + User::LeaveIfError(bitmapOne->Create(winSize,static_cast(mode))); + + CFbsBitmapDevice *deviceOne=CFbsBitmapDevice::NewL(bitmapOne); + CleanupStack::PushL(deviceOne); + + CFont *font3; + CFont *font4; + fs1.iFontStyle.SetBitmapType(EDefaultGlyphBitmap); + error = TheClient->iScreen->GetNearestFontToDesignHeightInPixels((CFont*&)font3,fs1); + if (error) + { + TheClient->iScreen->ReleaseFont(font3); + User::Panic(_L("font not created"),error); + } + fs1.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap); + error = TheClient->iScreen->GetNearestFontToDesignHeightInPixels((CFont*&)font4,fs1); + if (error) + { + TheClient->iScreen->ReleaseFont(font3); + TheClient->iScreen->ReleaseFont(font4); + User::Panic(_L("font not created"),error); + } + CFbsBitGc *bGcOne = CFbsBitGc::NewL(); + CleanupStack::PushL(bGcOne); + + bGcOne->Activate(deviceOne); + + bGcOne->SetBrushStyle(CGraphicsContext::ESolidBrush); + bGcOne->SetBrushColor(TRgb(127,0,255,127)); + bGcOne->DrawRect(TRect(0,0,winSize.iWidth,winSize.iHeight)); + + bGcOne->SetPenStyle(CGraphicsContext::ESolidPen); + bGcOne->SetPenColor(TRgb(0,0,0,127)); + + bGcOne->UseFont(font3); + bGcOne->SetBrushStyle( CGraphicsContext::ENullBrush ); + bGcOne->DrawText(_L("Test"),TPoint(10,20)); + bGcOne->DiscardFont(); + bGcOne->UseFont(font4); + bGcOne->DrawText(_L("Test"),TPoint(10,60)); + bGcOne->DiscardFont(); + //destruction and tidying up + //measure the text + CFont::TMeasureTextOutput textSize; + font4->MeasureText(_L("Test"),NULL,&textSize); + + TheClient->iScreen->ReleaseFont(font3); + TheClient->iScreen->ReleaseFont(font4); + + //display at the left + RWindow refWin(BaseWin->Client()->iWs); + CleanupClosePushL(refWin); + User::LeaveIfError(refWin.Construct(*(BaseWin->WinTreeNode()),(TUint32)&refWin)); + + refWin.SetExtent(TPoint(0,0), winSize); + refWin.SetRequiredDisplayMode(static_cast(mode)); + refWin.SetVisible(ETrue); + refWin.SetTransparencyAlphaChannel(); + refWin.Activate(); + TheClient->iWs.Flush(); + + //a gc for the ref win + CWsScreenDevice *refDevice; + refDevice = new (ELeave)CWsScreenDevice(BaseWin->Client()->iWs); + User::LeaveIfError(refDevice->Construct(iTest->ScreenNumber())); + CleanupStack::PushL(refDevice); + CWindowGc *gcRef; + refDevice->CreateContext(gcRef); + CleanupStack::PushL(gcRef); + + refWin.Invalidate(); + refWin.BeginRedraw(); + gcRef->Activate(refWin); + gcRef->BitBlt(TPoint(0,0), bitmapOne); + gcRef->Deactivate(); + refWin.EndRedraw(); + TheClient->iWs.Flush(); + + TPoint refPos = refWin.AbsPosition(); + TPoint winPos = theWin.AbsPosition(); + + //Compare the anti-aliased text areas + TInt textLength=textSize.iBounds.iBr.iX; + TInt textHeight=Abs(textSize.iBounds.iTl.iY); + + TRect rect1(refPos.iX+10,refPos.iY+60-textHeight, + refPos.iX+10+textLength,refPos.iY+60); + TRect rect2(winPos.iX+10,winPos.iY+60-textHeight, + winPos.iX+10+textLength,winPos.iY+60); + + TBool match = refDevice->RectCompare(rect1,rect2); + TEST(match); + + CleanupStack::PopAndDestroy(gcRef); + CleanupStack::PopAndDestroy(refDevice); + CleanupStack::PopAndDestroy(&refWin); + + CleanupStack::PopAndDestroy(bGcOne); + CleanupStack::PopAndDestroy(deviceOne); + CleanupStack::PopAndDestroy(bitmapOne); + CleanupStack::PopAndDestroy(&theWin);//theWin + + } +// +// CTDrawOpWin +// + +CTDrawOpWin* CTDrawOpWin::NewL(CTAlphaWin* aTest, CTWinBase* aParent, TPoint aPos, TSize aSize, TRgb aDrawColour) + { + CTDrawOpWin* theWin = new(ELeave) CTDrawOpWin(aTest,aDrawColour); + + theWin->ConstructL(*aParent); + theWin->SetExtL(aPos, aSize); + theWin->AssignGC(*TheClient->iGc); + if (TheClient->iScreen->DisplayMode() == EColor16MA) + { + theWin->BaseWin()->SetRequiredDisplayMode(EColor16MA); + } + else + { + theWin->BaseWin()->SetRequiredDisplayMode(EColor64K); + } + + theWin->Activate(); + theWin->DrawNow(); + + return theWin; + } + +CTDrawOpWin::CTDrawOpWin(CTAlphaWin* aTest, TRgb aDrawColour) +: iTest(aTest), iDrawColour(aDrawColour) + {} + + +void CTDrawOpWin::SetDrawOp(TInt aDrawOp) + { + iDrawOp = aDrawOp; + } + + +void CTDrawOpWin::Draw() + { + _LIT(KText,"Text test"); + + iGc->SetPenColor(iDrawColour); + iGc->SetBrushColor(iDrawColour); + TSize size = Size(); + TInt top = 5; + TInt left = 5; + TInt bottom = size.iHeight - 5; + TInt right = size.iWidth - 5; + TInt square = Min(bottom-top,right-left); + + switch (iDrawOp) + { + case EOpDrawRect: + iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + iGc->SetPenStyle(CGraphicsContext::ENullPen); + iGc->DrawRect(TRect(left,top,right,bottom)); + break; + case EOpDrawLine: + //!! FAILS + //!! The endpoint of the line is drawn twice, with the result that it is darker when we do blending + //!! Not intending to fix at the moment + /* + iGc->SetPenStyle(CGraphicsContext::ESolidPen); + iGc->SetPenSize(TSize(4,4)); + // The lines must not overlap, otherwise the blended lines will be darker at the overlap + iGc->DrawLine(TPoint(left+5,top), TPoint(left+square,top)); + iGc->DrawLine(TPoint(left+5,top+5), TPoint(left+square,top+square)); + iGc->DrawLine(TPoint(left,top+5), TPoint(left,top+square)); + */ + break; + case EOpDrawEllipse: + iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + iGc->SetPenStyle(CGraphicsContext::ENullPen); + iGc->DrawEllipse(TRect(left,top,right,bottom)); + break; + case EOpDrawText: + case EOpDrawTextVertical: + { + iGc->SetBrushStyle(CGraphicsContext::ENullBrush); + iGc->SetPenStyle(CGraphicsContext::ESolidPen); + CFont* font; + TFontSpec fontSpec(KTestFontTypefaceName,200); + User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips(font, fontSpec)); + iGc->UseFont(font); + if (iDrawOp==EOpDrawText) + iGc->DrawText(KText(), TPoint(5,30)); + else + iGc->DrawTextVertical(KText(), TPoint(5,30), EFalse); + iGc->DiscardFont(); + TheClient->iScreen->ReleaseFont(font); + } + break; + case EOpDrawTextAntiAliased: + { + iGc->SetBrushStyle(CGraphicsContext::ENullBrush); + iGc->SetPenStyle(CGraphicsContext::ESolidPen); + CFont* font; + TFontSpec fontSpec(KTestFontTypefaceName,600); + fontSpec.iFontStyle.SetStrokeWeight(EStrokeWeightBold); + fontSpec.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap); + + User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips(font, fontSpec)); + iGc->UseFont(font); + iGc->DrawText(KText(), TPoint(5,30)); + iGc->DiscardFont(); + TheClient->iScreen->ReleaseFont(font); + } + break; + case EOpBitBlt: + break; + case EOpBitBltMasked: + break; + default: + break; + }; + } + + + +// +// CTAlphaWindow +// + +CTAlphaWindow::~CTAlphaWindow() + { + DestroyChildren(); + } + +CTAlphaWindow* CTAlphaWindow::NewL(CTAlphaWin* aTest, CTWinBase* aParent, TPoint aPos, TSize aSize, TInt aDrawState) + { + CTAlphaWindow* theWin = new (ELeave) CTAlphaWindow(aTest); + + theWin->ConstructL(*aParent); + theWin->SetExtL(aPos, aSize); + theWin->SetDrawState(aDrawState); + + theWin->AssignGC(*TheClient->iGc); + + theWin->Activate(); + theWin->iDrawState |= EActive; + theWin->DrawNow(); + + return theWin; + } + +void CTAlphaWindow::SetDrawState(TInt aDrawState) + { + TBool active = iDrawState & EActive; + iDrawState = aDrawState & 0x7fffffff; + + TRgb colour = ColourFromDrawState(iDrawState); + ((RWindow*) DrawableWin())->SetBackgroundColor(colour); + + if (iDrawState & EModeColor16MA) + BaseWin()->SetRequiredDisplayMode(EColor16MA); + else + BaseWin()->SetRequiredDisplayMode(EColor64K); + + BaseWin()->SetVisible(! (iDrawState & EInvisible)); + + if (!active) + { + if (iDrawState & EAlphaTransparency) + ((RWindow*) DrawableWin())->SetTransparencyAlphaChannel(); + else if (iDrawState & ETransparencyFactor) + ((RWindow*) DrawableWin())->SetTransparencyFactor(TRgb(128,128,128)); + } + + if (active) + iDrawState |= EActive; + } + +void CTAlphaWindow::SetVisible(TBool aVisible) + { + if (aVisible) + iDrawState &= ~EInvisible; + else + iDrawState |= EInvisible; + BaseWin()->SetVisible(aVisible); + } + +void CTAlphaWindow::CreateChildrenL(TInt aDepth) + { + DestroyChildren(); + if (aDepth>0) + { + TSize size = Size(); + iChild1 = CTAlphaWindow::NewL(iTest, this, TPoint(size.iWidth/3,0), TSize(2*size.iWidth/3, 2*size.iHeight/3), ERed | EGreen | EBlue | EOpaque); + iChild2 = CTAlphaWindow::NewL(iTest, this, TPoint(0,size.iHeight/3), TSize(2*size.iWidth/3, 2*size.iHeight/3), ERed | EGreen | EBlue | EAlphaTransparency); + iChild2->CreateChildrenL(aDepth-1); + } + } + +void CTAlphaWindow::DestroyChildren() + { + if (iChild1) + { + iChild1->DestroyChildren(); + delete iChild1; + iChild1 = NULL; + } + if (iChild2) + { + iChild2->DestroyChildren(); + delete iChild2; + iChild2 = NULL; + } + } + +TInt CTAlphaWindow::DrawState() + { + return iDrawState; + } + +void CTAlphaWindow::Draw() + { + // we draw a diagonal line from top left to bottom right + // we use the complementary colour to the window background colour + TInt red = (iDrawState & ERed) ? 0 : 255; + TInt green = (iDrawState & EGreen) ? 0 : 255; + TInt blue = (iDrawState & EBlue) ? 0 : 255; + TRgb color(red,green,blue); + + TSize size = Size(); + iGc->SetPenColor(color); + iGc->SetPenSize(TSize(4,4)); + iGc->DrawLine(TPoint(0,0), TPoint(size.iWidth, size.iHeight)); + } + + +// +// CTAlphaRefWin +// + +CTAlphaRefWin::CTAlphaRefWin(TFixedArray& aAlphaWin) +: iAlphaWin(aAlphaWin) + {} + +CTAlphaRefWin* CTAlphaRefWin::NewL(CTWinBase* aParent, TPoint aPos, TSize aSize, TFixedArray& aAlphaWin) + { + CTAlphaRefWin* theWin = new(ELeave) CTAlphaRefWin(aAlphaWin); + + theWin->ConstructL(*aParent); + theWin->SetExtL(aPos, aSize); + theWin->AssignGC(*TheClient->iGc); + theWin->BaseWin()->SetRequiredDisplayMode(EColor64K); + + theWin->Activate(); + theWin->DrawNow(); + + return theWin; + } + +void CTAlphaRefWin::Draw() + { + iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + iGc->SetBrushColor(KRgbWhite); + iGc->Clear(); + + // Note, the order of the windows in the array must correspond to their z-order + for (TInt i=0; i<5; i++) + DrawWindow(iAlphaWin[i], iAlphaWin[i]->Position()); + } + +void CTAlphaRefWin::DrawWindow(CTAlphaWindow* aWindow, TPoint aPos) + { + TInt drawState = aWindow->DrawState(); + if ( (drawState & EInvisible) || ! (drawState & EActive) ) + return; + + TRgb colour = ColourFromDrawState(drawState); + if (drawState & EOpaque) + colour.SetAlpha(255); + if (drawState & ETransparent) + colour.SetAlpha(0); + iGc->SetBrushColor(colour); + + TPoint tl = aPos; + TPoint br = tl + aWindow->Size(); + TRect rect(tl,br); + iGc->Clear(rect); + + TInt red = (drawState & ERed) ? 0 : 255; + TInt green = (drawState & EGreen) ? 0 : 255; + TInt blue = (drawState & EBlue) ? 0 : 255; + colour = TRgb(red,green,blue); + + iGc->SetClippingRect(rect); + + TSize size = Size(); + iGc->SetPenColor(colour); + iGc->SetPenSize(TSize(4,4)); + iGc->DrawLine(tl, br); + + iGc->CancelClippingRect(); + + if (aWindow->iChild1) + DrawWindow(aWindow->iChild1, aPos + aWindow->iChild1->Position() ); + if (aWindow->iChild2) + DrawWindow(aWindow->iChild2, aPos + aWindow->iChild2->Position() ); + } + + +// +// Main test loop +// +void CTAlphaWin::RunTestCaseL(TInt /*aCurTestCase*/) + { + //User::After(TTimeIntervalMicroSeconds32(1000 * 1000)); + ((CTAlphaWinStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); + switch (++iTest->iState) + { +/** + + @SYMTestCaseID GRAPHICS-WSERV-0278 + + @SYMDEF DEF081259 + + @SYMPREQ 915 + + @SYMTestCaseDesc Semi-transparent drawing + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions Use draw operations with semi-transparent pen or brush colours + + @SYMTestExpectedResults Draw operations must do alpha blending + +*/ + case 1: + { + ((CTAlphaWinStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0278")); + if(TransparencySupportedL() == KErrNotSupported) + { + LOG_MESSAGE(_L("Test(1) complete - Transparency not supported\n")); + TestComplete(); + break; + } + TDisplayMode mode = TheClient->iScreen->DisplayMode(); + if (mode < EColor64K) + { + LOG_MESSAGE(_L("Test(1) complete - Display mode < EColor64K\n")); + TestComplete(); + break; + } + _LIT(KSemiTrans64K,"(1) Semi transparent drawing Color64K"); + iTest->LogSubTest(KSemiTrans64K); + TestSemiTransparentDrawingL(); + break; + } + +/** + + @SYMTestCaseID GRAPHICS-WSERV-0287 + + @SYMDEF DEF081259 + + @SYMPREQ 915 + + @SYMTestCaseDesc Invisible. All windows are in EColor16MA display mode. + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions Transparent alpha channel windows are made invisible and visible both in front and behind one another + + @SYMTestExpectedResults The windows are redrawn correctly, as compared to a reference drawing + +*/ + case 2: + ((CTAlphaWinStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0287")); + ConfigureDisplayModes(EColor16MA); + if(TransparencySupportedL()==KErrNone) + { + _LIT(KInvisible16MA,"(2) Invisible Color16MA"); + iTest->LogSubTest(KInvisible16MA); + TestInvisible(); + } + break; + +/** + + @SYMTestCaseID GRAPHICS-WSERV-0280 + + @SYMDEF DEF081259 + + @SYMPREQ 915 + + @SYMTestCaseDesc Initial Configuration. All windows are in EColor64K display mode. + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions Several windows are set to be transparent alpha channel, and given semi-transparent or transparent background colours + + @SYMTestExpectedResults The transparent window configuration matches a reference drawing created using only alpha blending + +*/ + //Test 3 to 6 can't be run without transparency support + case 3: + ((CTAlphaWinStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0280")); + ConfigureDisplayModes(EColor64K); + if(TransparencySupportedL()==KErrNone) + { + _LIT(KInitialConfiguration64K,"(3) Initial configuration Color64K"); + iTest->LogSubTest(KInitialConfiguration64K); + TestInitialConfiguration(); + } + break; +/** + + @SYMTestCaseID GRAPHICS-WSERV-0281 + + @SYMDEF DEF081259 + + @SYMPREQ 915 + + @SYMTestCaseDesc Move. All windows are in EColor64K display mode. + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions Transparent alpha channel windows are moved both in front and behind one another + + @SYMTestExpectedResults The windows are redrawn correctly, as compared to a reference drawing + +*/ + case 4: + ((CTAlphaWinStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0281")); + if(TransparencySupportedL()==KErrNone) + { + _LIT(KMove64K,"(4) Move Color64K"); + iTest->LogSubTest(KMove64K); + TestMove(); + } + break; +/** + + @SYMTestCaseID GRAPHICS-WSERV-0282 + + @SYMDEF DEF081259 + + @SYMPREQ 915 + + @SYMTestCaseDesc Redraw. All windows are in EColor64K display mode. + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions Transparent alpha channel windows are redrawn both in front and behind one another + + @SYMTestExpectedResults The windows are redrawn correctly, as compared to a reference drawing + +*/ + case 5: + ((CTAlphaWinStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0282")); + if(TransparencySupportedL()==KErrNone) + { + _LIT(KRedraw64K,"(5) Redraw Color64K"); + iTest->LogSubTest(KRedraw64K); + TestRedraw(); + } + break; +/** + + @SYMTestCaseID GRAPHICS-WSERV-0283-0001 + + @SYMDEF DEF081259 + + @SYMPREQ 915 + + @SYMTestCaseDesc Invisible. All windows are in EColor64K display mode. + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions Transparent alpha channel windows are made invisible and visible both in front and behind one another + + @SYMTestExpectedResults The windows are redrawn correctly, as compared to a reference drawing + +*/ + case 6: + ((CTAlphaWinStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0283-0001")); + if(TransparencySupportedL()==KErrNone) + { + _LIT(KInvisible64K,"(6) Invisible Color64K"); + iTest->LogSubTest(KInvisible64K); + TestInvisible(); + } + break; +/** + + @SYMTestCaseID GRAPHICS-WSERV-0283-0002 + + @SYMDEF DEF081259 + + @SYMPREQ 915 + + @SYMTestCaseDesc Children. All windows are in EColor64K display mode. + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions Transparent alpha channel windows are given child windows, both transparent and non-transparent, + and are then moved, redrawn, set visible or invisible both in front and behind one another + + @SYMTestExpectedResults The windows are redrawn correctly, as compared to a reference drawing + +*/ + case 7: + ((CTAlphaWinStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0283-0002")); + _LIT(KChildren64K,"(7)Children Color64K"); + iTest->LogSubTest(KChildren64K); + TestChildrenL(); + break; +/** + + @SYMTestCaseID GRAPHICS-WSERV-0356 + + @SYMDEF DEF081259 + + @SYMPREQ 915 + + @SYMTestCaseDesc Initial Configuration. All windows are in EColor64k Dispaly Mode + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions Tests Anti-aliasing of text + + @SYMTestExpectedResults Anti-alisaing should behave correctly + +*/ + case 8: + ((CTAlphaWinStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0356")); + _LIT(KAntiAliasedText64K,"(8) AntiAliasedText DEF082251 Color64K"); + iTest->LogSubTest(KAntiAliasedText64K); + TestAntiAliasedTextTransparentL(); + break; + +/** + + @SYMTestCaseID GRAPHICS-WSERV-0284 + + @SYMDEF DEF081259 + + @SYMPREQ 915 + + @SYMTestCaseDesc Initial Configuration. All windows are in EColor16MA display mode. + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions Several windows are set to be transparent alpha channel, and given semi-transparent or transparent background colours + + @SYMTestExpectedResults The transparent window configuration matches a reference drawing created using only alpha blending + +*/ + case 9: + { + ((CTAlphaWinStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0284")); + ConfigureDisplayModes(EColor16MA); + TDisplayMode mode1 = TheClient->iScreen->DisplayMode(); + _LIT(KInitialConfiguration16MA,"(9)Initial configuration Color16MA"); + iTest->LogSubTest(KInitialConfiguration16MA); + TestInitialConfiguration(); + break; + } +/** + + @SYMTestCaseID GRAPHICS-WSERV-0285 + + @SYMDEF DEF081259 + + @SYMPREQ 915 + + @SYMTestCaseDesc Move. All windows are in EColor16MA display mode. + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions Transparent alpha channel windows are moved both in front and behind one another + + @SYMTestExpectedResults The windows are redrawn correctly, as compared to a reference drawing + +*/ + case 10: + ((CTAlphaWinStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0285")); + _LIT(KMove16MA,"(10)Move Color16MA"); + iTest->LogSubTest(KMove16MA); + TestMove(); + break; +/** + + @SYMTestCaseID GRAPHICS-WSERV-0286 + + @SYMDEF DEF081259 + + @SYMPREQ 915 + + @SYMTestCaseDesc Redraw. All windows are in EColor16MA display mode. + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions Transparent alpha channel windows are redrawn both in front and behind one another + + @SYMTestExpectedResults The windows are redrawn correctly, as compared to a reference drawing + +*/ + case 11: + ((CTAlphaWinStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0286")); + _LIT(KRedraw16MA,"(11)Redraw Color16MA"); + iTest->LogSubTest(KRedraw16MA); + TestRedraw(); + break; + +/** + + @SYMTestCaseID GRAPHICS-WSERV-0279 + + @SYMDEF DEF081259 + + @SYMPREQ 915 + + @SYMTestCaseDesc Transparent drawing + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions Use draw operations with transparent pen or brush colours + + @SYMTestExpectedResults Draw operations with transparent pen or brush colours should leave the destination unchanged + +*/ + + case 12: + ((CTAlphaWinStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0279")); + ConfigureDisplayModes(EColor64K); + _LIT(KTrans64K,"(12) Transparent drawing Color64K"); + iTest->LogSubTest(KTrans64K); + TestTransparentDrawingL(); + break; + + +/** + + @SYMTestCaseID GRAPHICS-WSERV-0288 + + @SYMDEF DEF081259 + + @SYMPREQ 915 + + @SYMTestCaseDesc Children. All windows are in EColor16MA display mode. + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions Transparent alpha channel windows are given child windows, both transparent and non-transparent, + and are then moved, redrawn, set visible or invisible both in front and behind one another + + @SYMTestExpectedResults The windows are redrawn correctly, as compared to a reference drawing + +*/ + case 13: + ((CTAlphaWinStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0288")); + _LIT(KChildren16MA,"(13) Children Color16MA"); + iTest->LogSubTest(KChildren16MA); + TestChildrenL(); + break; +/** + + @SYMTestCaseID GRAPHICS-WSERV-0357 + + @SYMDEF DEF081259 + + @SYMPREQ 915 + + @SYMTestCaseDesc Initial Configuration. All windows are in EColor16MA Dispaly Mode + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions Tests Anti-aliasing of text + + @SYMTestExpectedResults Anti-alisaing should behave correctly + +*/ + case 14: + ((CTAlphaWinStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0357")); + _LIT(KAntiAliasedText16MA,"(14) AntiAliasedText DEF082251 Color16MA"); + iTest->LogSubTest(KAntiAliasedText16MA); + TestAntiAliasedTextTransparentL(); + break; + default: + ((CTAlphaWinStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + ((CTAlphaWinStep*)iStep)->CloseTMSGraphicsStep(); + TestComplete(); + break; + } + ((CTAlphaWinStep*)iStep)->RecordTestResultL(); + } + +__WS_CONSTRUCT_STEP__(AlphaWin) + diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/tauto.mbm Binary file windowing/windowserver/test/tauto/tauto.mbm has changed diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/tclosepanicwindowprocess.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/tclosepanicwindowprocess.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,88 @@ +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// The process to close all the panic window. +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include +#include +#include +#include +#include +#include +#include + +// Simulate 50 escape-keys down to close all the panic window +static TInt CloseAllPanicWindows(RWsSession& aWs) + { + TInt idFocus = aWs.GetFocusWindowGroup(); + TWsEvent event; + event.SetType(EEventKey); + TKeyEvent* keyEvent = event.Key(); + keyEvent->iCode = EKeyEscape; + keyEvent->iScanCode = EStdKeyEscape; + keyEvent->iModifiers = 0; + TInt theLimit = 50; + TInt err = KErrNone; + while(idFocus != NULL && (theLimit-- > 0)) + { + err = aWs.SendEventToAllWindowGroups(event); + if (err != KErrNone && err != KErrNoMemory) + { + return err; + } + User::After(1000); //give it time to process + idFocus = aWs.GetFocusWindowGroup(); + } + return KErrNone; + } + + +// Real main function +void MainL() + { + // Open wserv session + RWsSession ws; + TInt err = ws.Connect(); + if (err != KErrNone) + { + User::Leave(err); + } + + CleanupClosePushL(ws); + + User::LeaveIfError(CloseAllPanicWindows(ws)); + + CleanupStack::PopAndDestroy(&ws); + } + +// Cleanup stack harness +GLDEF_C TInt E32Main() + { + __UHEAP_MARK; + CTrapCleanup* cleanupStack = CTrapCleanup::New(); + TRAPD(error, MainL()); + _LIT(KTCloseAllPanicWindowPanic,"tcloseallpanicwindow"); + // Panic the current process + __ASSERT_ALWAYS(!error, User::Panic(KTCloseAllPanicWindowPanic, error)); + delete cleanupStack; + __UHEAP_MARKEND; + return KErrNone; + } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/tcrpanim.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/tcrpanim.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,1464 @@ +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Implements CTCrpAnim +// Test CRP animations & their interaction with overlapping transparent/non-transparent windows +// & wserv's underlying redraw-store strategies +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include +#include "tcrpanim.h" + +// RUN_SAMPLE_ON_LEFT allows the demo animation to run in the left-hand window during testing. +// Used for demonstration purposes only +#define RUN_SAMPLE_ON_LEFT + +namespace //anonymous local scope + { + const TInt KAnimationFrameDelayTime = 50000; // delay in microseconds between frames + const TInt KShortDelayLoop = 2*KAnimationFrameDelayTime; // delay time in microseconds used in test cases + const TInt KAnimationTotalFrames = 40; // total number of frames in a CWsGraphicBitmapAnimation + const TInt KAnimDimension = 40; // animation width/height. We're enforcing a square animation here + const TInt KFrameMissedAnimationsThreshold = 10; // maximum number of missed frame steps allowed + const TInt KAnimationTearWidthThreshold = 4; // maximum columns permitted between a tear + const TInt KMinGoodFrameThreshold = 30; // percentage threshold for number of good frames detected in a test + const TInt KMaxXY = 200; // arbitrary maximum size of square used to invalidate a window + const TInt KMaxRepeatDraw = 2; // arbitrary value for DrawLine calls during a Draw + TUid KUidTestAnimation2 = {0xBAADF00D}; // unique id. for CWsGraphicBitmapAnimation object + const TUint32 KWhitePixels = 0xFFFFFFFF; // 32-bit mask value for rgb white + const TUint32 KBlackPixels = 0x00000000; // 32-bit value for rgb black + const TPoint KPointZero(0,0); // initial point used for animation creation & manipulation (currently 0,0) + const TPoint KPointOffsite(1000,1000); // point used to draw off-screen + const TDisplayMode KTestDisplayMode = EColor16MU; // display mode used for testing + const TInt KFrameStepCalculation = Max(1, KAnimDimension/Max(1, KAnimationTotalFrames)); // determine framestep size in columns + + enum TColorDetected + { + ECantTell=0, + EDetRed=1, + EDetGreen=2, + EDetBlue=4, + EDetBlack=0x10, + EDetGrey=0x20, + EDetWhite=0x40 + }; + + class CCrpAnim; + class CAnimRedrawWindow : public CTWin + { + public: + CAnimRedrawWindow(CCrpAnim *aAnimWindow, TBool aIsBase); + ~CAnimRedrawWindow(); + void Draw(); + private: + CCrpAnim *iAnimWindow; + TBool iIsBase; + }; + + class CCrpAnim : public CBase + { + friend class CAnimRedrawWindow; + public: + enum TWinType + { + ERedraw, + EBlank, // note: not currently used in tcrpanim tests + EBackedUp // note: not currently used in tcrpanim tests + }; + public: + CCrpAnim(TBool aIsBase, TWinType aWinType); + ~CCrpAnim(); + enum + { + ENoTransparency=0x100 + }; + void ConstructL(const TPoint &aPos, const TSize &aSize,const TInt aAlphaValue=ENoTransparency); + void DoDraw(TBool aBlankIt); + inline void DoDraw(); + void DoDrawEllipse(); + inline TSize Size() {return iCtWin->Size();}; + inline RWindowBase* BaseWin() const {return iCtWin->BaseWin();}; + inline RWindow* Window() const {return STATIC_CAST(RWindow*, iCtWin->BaseWin());}; + inline CTBaseWin* CtBaseWin() {return iCtWin;}; + inline void Invalidate() {CTUser::Splat(TheClient, TRect(iCtWin->Position(), iCtWin->Size()), KRgbGray);}; + void Invalidate(const TRect &aRect); + static void SetEllipseDrawMode(CGraphicsContext::TDrawMode aEllipseDrawMode); + void InvalidateAndRedraw(TBool aUseBlankItMember,TBool aBlankIt,TBool aUseRWindowInvalidate,TRect* aRect=NULL); + + //A bit of an animation interface... + //I have written this interface to be amenable to playing multiple animations, + //which I think needs testing, + //but the underlying implementation assumes one animation at present. + //Your mission, should you choose to accept it, .... + + void SetPosAnimation(const TUid& aUid, const TRect& aRect); + TRect* GetPosAnimation(const TUid& aUid); + TWsGraphicAnimation* SetAnimation(TUid); + TWsGraphicAnimation* GetAnimation(TUid); + TBool RemoveAnimation(TUid); + inline void SetBlankIt(TBool aNewVal) {iBlankIt = aNewVal;}; + inline void SetRepeatDrawMax(TInt aVal) {iRepeatDrawMax = aVal;}; + protected: + static void Draw(CBitmapContext *aGc, const TSize &aSize, TBool aIsBase,const TRect &aRect, TBool aBlankIt,TInt aRepeat, TInt aAlphaValue); + static void DrawEllipse(CBitmapContext *aGc, const TRect &aRect, TInt aAlphaValue); + CTBaseWin *iCtWin; + TWinType iWinType; + TBool iIsBase; + TBool iBlankIt; + TRect iRect; + TInt iRepeatDrawMax; + static CGraphicsContext::TDrawMode iEllipseDrawMode; + TUid iAnimUid; + TWsGraphicAnimation iAnimData; + TRect iAnimPos; + TInt iAlphaValue; + }; + +/* Using this time delay class in order to allow animations to play in our draw. + User::Wait does not allow the draw to occur (aparrently) + Note when using this time-delay class: because other active objects can perform part of their + processing whilst we wait, wrapping calls to this in __UHEAP_MARK / __UHEAP_MARKEND + is likely to fail. The data providers and animators are a major cause of this. +*/ + class CActiveWait : public CActive + { + public: + static CActiveWait* NewL(); + ~CActiveWait(); + void Wait(TInt aDelay); + // From CActive: + void RunL(); + void DoCancel(); + TInt RunError(TInt aError); + protected: + CActiveWait(); + void ConstructL(); + protected: + RTimer iTimer; + TTime iFromTime; + }; + + CActiveWait* CActiveWait::NewL() + { + CActiveWait* self = new (ELeave) CActiveWait; + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + + void CActiveWait::ConstructL() + { + User::LeaveIfError(iTimer.CreateLocal()); + CActiveScheduler::Add(this); + } + + CActiveWait::CActiveWait() : CActive(EPriorityNormal) + { + iFromTime.HomeTime(); + } + + CActiveWait::~CActiveWait() + { + Cancel(); + iTimer.Close(); + } + + void CActiveWait::DoCancel() + { + iTimer.Cancel(); + CActiveScheduler::Stop(); + } + + void CActiveWait::RunL() + { + CActiveScheduler::Stop(); + } + + TInt CActiveWait::RunError(TInt aError) + { + return aError; // exists so a break point can be placed on it. + } + +/* Note when using this : because other active objects can perform part of their + processing whilst we wait, wrapping calls to this in __UHEAP_MARK / __UHEAP_MARKEND + is likely to fail. The data providers and animators are a major cause of this. +*/ + void CActiveWait::Wait(TInt aDelay) + { + iTimer.After(iStatus, aDelay); + SetActive(); + CActiveScheduler::Start(); + } + CGraphicsContext::TDrawMode CCrpAnim::iEllipseDrawMode; + +// + } //end anonymous local scope +// + +/** This fn allocates an animation frame of the specified dimensions. + Not tested outside the current limited parameter set (16/2/2007). + Note the use of 32-bit integers for pixel/colour values. Using display mode lower than 24bpp may not produce correct results + My attempt to write animation generating code that avoids CIclLoader and Decoder class. + @param aDelayUs the display time for the frame + @param aImageType Colour format for colour plane. 24MA currently not flagged correctly I expect. + @param aMaskType Format for mask. ENone for no mask. + @param aImageSize Width/height of bitmap area + @param aImageOffset Optional offset for bitmap area + @param aTotalSize Optional width/height of whole animation (I think) + @return CFrame filled in with allocated bitmaps. The get methods for the bitmaps return const type. +**/ +static CWsGraphicBitmapAnimation::CFrame* NewFrameLC(TInt aDelayUs,TDisplayMode aImageType,TDisplayMode aMaskType,const TSize& aImageSize,const TPoint& aImageOffset=KPointZero,const TSize& aTotalSize=TSize(0,0)) + { + TFrameInfo info; + info.iFrameCoordsInPixels = TRect(aImageOffset,aImageSize); + info.iFrameSizeInTwips = aImageSize; //this is zero in the gif loader + info.iDelay = TTimeIntervalMicroSeconds(aDelayUs); + info.iFlags = TFrameInfo::EColor|TFrameInfo::ELeaveInPlace|TFrameInfo::EUsesFrameSizeInPixels; + if (aMaskType != ENone) + { + info.iFlags|=TFrameInfo::ETransparencyPossible; + } + if ((aTotalSize.iHeight > 0) && (aTotalSize.iWidth > 0)) + { + // restrict the size of the frame to specified size of the animation + info.iOverallSizeInPixels = aTotalSize; + } + else + { + // assign the size of the frame to the size of the entire bitmap area + info.iOverallSizeInPixels = info.iFrameCoordsInPixels.iBr.AsSize(); + } + info.iFrameDisplayMode = aImageType; + info.iBackgroundColor = KRgbGreen; + + CWsGraphicBitmapAnimation::CFrame* frame = CWsGraphicBitmapAnimation::CFrame::NewL(); + CleanupStack::PushL(frame); + frame->SetFrameInfo(info); + CFbsBitmap* bitmap = new(ELeave) CFbsBitmap; + frame->SetBitmap(bitmap); //takes ownership + TSize frameInfoSize = info.iFrameCoordsInPixels.Size(); + User::LeaveIfError(bitmap->Create(frameInfoSize, aImageType)); + if((TFrameInfo::EAlphaChannel|TFrameInfo::ETransparencyPossible) & info.iFlags) + { + CFbsBitmap* mask = new(ELeave) CFbsBitmap; + frame->SetMask(mask); //takes ownership + User::LeaveIfError(mask->Create(frameInfoSize, aMaskType)); + } + return frame; + } + +// +// function called back by TCleanupItem frameListCleanup from within CreateAnimFramesL(..) method +// +void CleanupFrameList(TAny* aPtr) + { + RPointerArray* ptrArray = STATIC_CAST(RPointerArray*, aPtr); + ptrArray->ResetAndDestroy(); + ptrArray->Close(); + } + +/** Helper function for making animation frames. + //Called from CreateAnimL(...) + @param aDelayUs the delay between frames + @param aNumFrames number of frames (approx - image width is a factor) + @param aImageType colour format of colour data. This may not work properly for non-32-bit, but I haven't fully understood TBitmapUtil documentation. + @param aMaskType format for mask - ENone for no mask. + @param aImageSize width/height of animation + @param aBgCol background colour for image non-masked areas. Masked areas are black. + @param aFgCol foreground colour of animating area + @param aFrames frames that the animation is constructed from +**/ +static void CreateAnimFramesL(TInt aDelayUs,TInt aNumFrames,TDisplayMode aImageType,TDisplayMode aMaskType,TSize aImageSize,TRgb aBgCol,TRgb aFgCol, RPointerArray& aFrames) + { + const TInt animWH = aImageSize.iWidth; + const TInt animStep = Max(1,animWH/Max(1,aNumFrames)); //note this intentionally rounds down to avoid overflows + for (TInt ii = 0 ; ii < animWH ; ii += animStep) + { + CWsGraphicBitmapAnimation::CFrame* frame = NewFrameLC(aDelayUs,aImageType,aMaskType,aImageSize,KPointZero,aImageSize); + aFrames.AppendL(frame); + CleanupStack::Pop(frame); + TBitmapUtil utilMask(CONST_CAST(CFbsBitmap*, frame->Mask())); + TBitmapUtil utilCol(CONST_CAST(CFbsBitmap*, frame->Bitmap())); + utilCol.Begin(KPointZero); + + // cycle through the frame's actual bitmap & assign each pixel a value identical to the specified colours + TUint32 colback=aBgCol.Internal(); + TUint32 colfront=aFgCol.Internal(); + TInt row = KErrNone; + TInt col = KErrNone; + for (row = 0 ; row < aImageSize.iHeight ; row++) + { + utilCol.SetPos(TPoint(0, row)); + for (col = 0 ; col < aImageSize.iWidth ; col++) + { + utilCol.SetPixel(colback); + utilCol.IncXPos(); + } + utilCol.SetPos(TPoint(ii, row)); + for (col = 0 ; col < animStep ; col++) //Note I rely on intentional rounding down here! + { + utilCol.SetPixel(colfront); + utilCol.IncXPos(); + } + } + + if (aMaskType) + { + // cycle through each pixel of the frame's mask & assign a default pixel a colour value + utilMask.Begin(KPointZero); + for (row = 0 ; row < aImageSize.iHeight ; row++) + { + utilMask.SetPos(TPoint(0,row)); + for (col = 0 ; col < aImageSize.iWidth ; col++) + { + utilMask.SetPixel(KWhitePixels); + utilMask.IncXPos(); + } + } + + const TInt maxmaskWidth = Min(8,Max(animWH/3,2)); + + //cut the corners off the mask + for (row = 0 ; row < maxmaskWidth ; row++) + { + TInt currentX = maxmaskWidth - row; + TInt xPos = KErrNone; + + utilCol.SetPos(TPoint(0,row)); + utilMask.SetPos(TPoint(0,row)); + for(xPos = currentX ; xPos >= 0 ; xPos--) + { + utilCol.SetPixel(KBlackPixels); + utilCol.IncXPos(); + utilMask.SetPixel(KBlackPixels); + utilMask.IncXPos(); + } + + utilCol.SetPos(TPoint(animWH - 1, row)); + utilMask.SetPos(TPoint(animWH - 1, row)); + for(xPos = currentX ; xPos >= 0 ; xPos--) + { + utilCol.SetPixel(KBlackPixels); + utilCol.DecXPos(); + utilMask.SetPixel(KBlackPixels); + utilMask.DecXPos(); + } + + utilCol.SetPos(TPoint(0, animWH - 1 - row)); + utilMask.SetPos(TPoint(0, animWH - 1 - row)); + for(xPos = currentX ; xPos >= 0 ; xPos--) + { + utilCol.SetPixel(KBlackPixels); + utilCol.IncXPos(); + utilMask.SetPixel(KBlackPixels); + utilMask.IncXPos(); + } + + utilCol.SetPos(TPoint(animWH - 1, animWH - 1 - row)); + utilMask.SetPos(TPoint(animWH - 1, animWH - 1 - row)); + for(xPos = currentX ; xPos >= 0 ; xPos--) + { + utilCol.SetPixel(KBlackPixels); + utilCol.DecXPos(); + utilMask.SetPixel(KBlackPixels); + utilMask.DecXPos(); + } + } + utilMask.End(); + } + utilCol.End(); + } + } + +/** My attempt to write animation generating code that avoids CIclLoader and Decoder class. + //It is better if this test class used it's own generated animation + //rather than relying on the GIF loader in order to reduce the cross-dependencies. + //The animation generated is a simple vertical line moving from left to right. + //To prove the masking, I cut the corners off. + @param aDelayUs the delay between frames + @param aNumFrames number of frames (approx - image width is a factor) + @param aImageType colour format of colour data. This may not work properly for non-32-bit, but I haven't fully understood TBitmapUtil documentation. + @param aMaskType format for mask - ENone for no mask. + @param aImageSize width/height of animation + @param aBgCol background colour for image non-masked areas. Masked areas are black. + @param aFgCol foreground colour of animating area + @param aTUid TUid assigned to animation + @return CWsGraphicBitmapAnimation allocated to represent the final animation +**/ +static CWsGraphicBitmapAnimation* CreateAnimL(TInt aDelayUs,TInt aNumFrames,TDisplayMode aImageType,TDisplayMode aMaskType,TSize aImageSize,TRgb aBgCol,TRgb aFgCol,TUid& aTUid) + { + RPointerArray frames; + TCleanupItem frameListCleanup(CleanupFrameList, &frames); + CleanupStack::PushL(frameListCleanup); + + CreateAnimFramesL(aDelayUs, aNumFrames, aImageType, aMaskType, aImageSize,aBgCol, aFgCol, frames); + + CWsGraphicBitmapAnimation* anim = CWsGraphicBitmapAnimation::NewL(aTUid,frames.Array()); + CleanupStack::PopAndDestroy(&frames); + return anim; + } + +// +// Describes the pure colour of the RGB value. yellow/magenta/cyan set 2 bits. White/grey is seperately flagged. +// This method attempts to determine the strongest primary colour present in any given pixel. +// Note: The algorithm used is known to work for the current test cases only but requires careful review +// for anyone making additional changes to tcrpanim. Given time, improved algorithm should be developed +// to replace the current one +// +TUint PredominantColour(TUint aCol) + { //I don't like all these ifs, but I don't see an easy alternative + //Possibly a bit look-up of the deltas from average would work + //(ignoring the bottom 5 bits =32, not 0x30=48. Ignore bottom 4 bits and accept 3-same answers, or divide by delta?) + // + const TInt Kdelta=0x30; + TInt red=(aCol&0x00ff0000)>>16; + TInt green=(aCol&0x0000ff00)>>8; + TInt blue=(aCol&0x000000ff); + TInt ave=((red+green+blue)*(65536/3))>>16; + TBool rOverA=(red>ave); + TBool gOverA=(green>ave); + TBool bOverA=(blue>ave); + TInt numOverAve=(rOverA?1:0)+(gOverA?1:0)+(bOverA?1:0); + + if (numOverAve==1) + { + if (rOverA) + { + if (red>ave+Kdelta) + { + if ((green-blue)>-Kdelta && (green-blue)ave-Kdelta && blue>ave-Kdelta) + { + if (ave>256-Kdelta) + return EDetWhite; + else + return EDetGrey; + } + } + } + } + + if (gOverA) + { + if (green>ave+Kdelta) + { + if ((blue-red)>-Kdelta && (blue-red)ave-Kdelta && blue>ave-Kdelta) + if (ave>256-Kdelta) + return EDetWhite; + else + return EDetGrey; + } + } + } + + if (bOverA) + { + if (blue>ave+Kdelta) + { + if ((green-red)>-Kdelta && (green-red)ave-Kdelta && green>ave-Kdelta) + if (ave>256-Kdelta) + return EDetWhite; + else + return EDetGrey; + } + } + } + } + else + { + if (!rOverA) + if (red-Kdelta && (green-blue)256-Kdelta) + return EDetWhite; + else + { + if (blue-Kdelta && (blue-red)256-Kdelta) + return EDetWhite; + else + { + if (blue-Kdelta && (green-red)256-Kdelta) + return EDetWhite; + else + { + if (rediGroup->WinTreeNode()->SetOrdinalPosition(0); + iRedrawWin=new(ELeave) CCrpAnim(EFalse, CCrpAnim::ERedraw); + iBaseWin=new(ELeave) CCrpAnim(EFalse, CCrpAnim::ERedraw); + iOverWin=new(ELeave) CCrpAnim(EFalse, CCrpAnim::ERedraw); + + TSize screenSize=TheClient->iGroup->Size(); + TInt winWidth=(screenSize.iWidth/3)-10; + TInt winHeight=screenSize.iHeight-10; + TSize windowSize(winWidth,winHeight); + + iRedrawWin->ConstructL(TPoint(screenSize.iWidth/3*2+5,5), windowSize); + iBaseWin->ConstructL(TPoint(screenSize.iWidth/3+5,5), windowSize); + + //Create a transparent window that exactly overlaps the test window + //If transparency is not supported the leave causes the window to be destroyed and set to NULL. + //There is a test for transparency supported, but that simply creates a temp window to test anyway... + + //Note that when I originally wrote this test to fix PDEF101991, it generated white areas that I detected. + //However, if this transparent window used for extended tests is created over the test window, + //that somehow stops the white fill from occurring. + //The fault still occurs, but the previous screen contents are left behind. + //So now this window is created at an off-screen location. + TRAPD(err, iOverWin->ConstructL(KPointOffsite, windowSize, 0x80); iOverWin->SetBlankIt(ETrue); iOverWin->SetRepeatDrawMax(KMaxRepeatDraw);); + if (err) + { + delete iOverWin; + iOverWin = NULL; + } + + iTestWin = iRedrawWin; + iTestWin->SetRepeatDrawMax(KMaxRepeatDraw); + iBaseWin->SetRepeatDrawMax(KMaxRepeatDraw); + + // create animation object & share it with everyone + iAnim = CreateAnimL(KAnimationFrameDelayTime,KAnimationTotalFrames,KTestDisplayMode,EGray256,TSize(KAnimDimension, KAnimDimension),KRgbBlue,KRgbRed,KUidTestAnimation2); + if (!iAnim) + { + User::Leave(KErrNoMemory); + } + iAnim->ShareGlobally(); + + // calculate minimum length of the red line + const TInt maxmaskHeight = Min(8, Max(KAnimDimension/3,2)); // note this calculation mimics that for the size of the corners cut from the mask in CreateAnimL above + iMinimumCalcRedLine = KAnimDimension - maxmaskHeight*2; // the height of the image minus the two cut corners + + // create the timer object + iWaiter = CActiveWait::NewL(); + + // create screen bitmap object & scanline buffer + iScreenBitmap = new (ELeave) CFbsBitmap; + User::LeaveIfError(iScreenBitmap->Create(TSize(KAnimDimension, KAnimDimension), KTestDisplayMode)); + TInt bufLength = iScreenBitmap->ScanLineLength(windowSize.iHeight, KTestDisplayMode); + iScanlineBuf = HBufC8::NewL(bufLength); + + #ifdef RUN_SAMPLE_ON_LEFT + { + // play animation on iBaseWin window + iBaseWin->SetAnimation(KUidTestAnimation2)->Play(ETrue); + TSize subsize1 = iTestWin->BaseWin()->Size(); + TRect subposition1(subsize1); + CalcCentredAnimPosition(subposition1, subsize1); + iBaseWin->SetPosAnimation(KUidTestAnimation2, subposition1); + iBaseWin->InvalidateAndRedraw(ETrue,EFalse,ETrue); + } + #endif + } + +CTCrpAnim::~CTCrpAnim() + { + delete iRedrawWin; + delete iBaseWin; + delete iOverWin; + if (iAnim) + { + // destroy the animation object + iAnim->UnShareGlobally(); + iAnim->Destroy(); + delete iAnim; + iAnim = NULL; + } + if (iWaiter) + { + // destroy the timer object + delete iWaiter; + iWaiter = NULL; + } + if (iScreenBitmap) + { + // destroy the screen capture of the animation + delete iScreenBitmap; + iScreenBitmap = NULL; + } + if (iScanlineBuf) + { + // destroy the scanline buffer + delete iScanlineBuf; + iScanlineBuf = NULL; + } + User::After(200000); + } + +// +// This method checks the animation contained in the aAnimWin window has progressed. That is +// that it's drawn a sufficient number of concurrent frames to screen & the animation is +// drawn properly to screen +// returns a Bool identifying whether the animation is considered 'good' or not +// +void CTCrpAnim::CheckAnimProgressedL(CAnonAnimWindow* aAnimWin, TInt aAdditionalFrameCount, TBool aCaptureFrameResult) + { + TBool goodAnimation = ETrue; + + // retrieve the rect from the screen's bitmap that contains the animation + CWsScreenDevice* screen = TheClient->iScreen; + TRect animPos = *aAnimWin->GetPosAnimation(KUidTestAnimation2); + CTBaseWin* bWin = aAnimWin->CtBaseWin(); + animPos.Move(bWin->Position()); + User::LeaveIfError(screen->CopyScreenToBitmap(iScreenBitmap, animPos)); + + TInt frameNum = DetermineApproxFrameNum(iScreenBitmap, aCaptureFrameResult); // determines the frame Number & checks quality of animation (no tearing, etc) + TBool frameIdentified=(frameNum>=0); + + if (aCaptureFrameResult) + { + if (frameIdentified) + { + if (iPreviousFrameNum != KErrNotFound) + { + if (iPreviousFrameNum < frameNum) + { + TInt frameStep = KFrameStepCalculation * aAdditionalFrameCount; + iPreviousFrameNum += frameStep; // move to our *expected* framenumber + if (frameNum > iPreviousFrameNum) + { + // the frame number is ahead of it's expected position + // This suggests we've possibly missed animating a frame in wserv + // or test code isn't getting a chance to execute as crp animations taking all cpu cycles + // If its significantly outside norms, we log the fact (as a performance metric) + TInt performance = ((frameNum - iPreviousFrameNum) / frameStep); + if (performance > KFrameMissedAnimationsThreshold) + { + iFrameStatus.iFrameSkipped++; + goodAnimation = EFalse; + } + } + // else we're animating above an acceptable threshold + } + else if (iPreviousFrameNum == frameNum) // potentially not animating anymore + { + iFrameStatus.iFrameIdentical++; + goodAnimation = EFalse; + } + // else animation is progressing fine + } + // ignore iPreviousFrameNum == KErrNotFound + } + else + { + goodAnimation = EFalse; // couldn't id the red line + } + + if (goodAnimation) + { + iFrameStatus.iFrameOK++; + } + } + // else we were only interested in calculating the frameNum + iPreviousFrameNum = frameNum; + } + +// +// method to estimate the framenumber based on the location of the thin, red line. +// Also checks whether tearing of the animation has occured or the animation +// is only partially drawn. +// These are known issues with wserv animation performance & so we give some allowance for error +// +TInt CTCrpAnim::DetermineApproxFrameNum(CFbsBitmap* aBitmap, TBool aCaptureFrameResult) + { + TInt colFirstTear = KErrNotFound; // column id'ing the first tear in the vertical line + TPtr8 des = iScanlineBuf->Des(); // ptr to the scanline buffer + + // locate the thin, red line in the bitmap + for (TInt xPos = 0 ; xPos < aBitmap->SizeInPixels().iWidth ; xPos++) + { + aBitmap->GetVerticalScanLine(des, xPos, EColor16MA); + TUint32* pixel = (TUint32*) des.Ptr(); + TInt colour = KErrNone; + + for (TInt ii = 0 ; ii < aBitmap->SizeInPixels().iHeight ; ii++) + { + colour = PredominantColour(*pixel); + if (colour & EDetRed) + { + if (colFirstTear < 0) + { + // check the length of the red line is a good length + pixel += (iMinimumCalcRedLine - 1); // minus the one pixel to position on last pixel in red line + colour = PredominantColour(*pixel); + if (colour & EDetRed) + { + // good line + return xPos; + } + else // we've detected first part of a torn line + { + colFirstTear = xPos; + } + } + else + { + // located second part of torn line + if ((xPos - colFirstTear) > KAnimationTearWidthThreshold) + { + if (aCaptureFrameResult) + { + iFrameStatus.iFrameTearing++; + } + xPos = KErrNotFound; + } + return xPos; + } + break; + } + pixel++; + } + } + if (aCaptureFrameResult) + { + if (colFirstTear < 0) + { + iFrameStatus.iFrameEmpty++; // we never located any red line at all + } + else + { + iFrameStatus.iFramePartial++; // we only located a single, small part of the red line + } + } + return KErrNotFound; + } + +/** This internal loop tests that the animation and the foreground interact correctly + The primary test is that the outline of the animation + intersects the lines drawn on the foreground correctly, compared to a reference version. + The iBaseWin is already showing this reference anim. + If the animation is not drawn, or the foreground is wiped, then this test will fail. +**/ +void CTCrpAnim::TestSpriteLoopL(TBool aAnimForeground,TBool aDrawForeground) + { + _LIT(KForegroundInfo,"TestSpriteLoop animForeground [%d] drawForeground [%d]"); + INFO_PRINTF3(KForegroundInfo, aAnimForeground, aDrawForeground); + + if (!iOverWin && (aAnimForeground || aDrawForeground)) + { + User::Leave(KErrGeneral); // unable to run this test without iOverWin + } + + ResetFrameCounters(); + iTestWin->RemoveAnimation(KUidTestAnimation2); + iTestWin->SetBlankIt(ETrue); + if (iOverWin) + { + iOverWin->RemoveAnimation(KUidTestAnimation2); + iOverWin->SetBlankIt(ETrue); + } + + // determine which window holds the animation, & which will be invalidated with progressively larger rects + CCrpAnim* animWin=aAnimForeground?iOverWin:iTestWin; + CCrpAnim* paintWin=aDrawForeground?iOverWin:iTestWin; + paintWin->SetBlankIt(EFalse); + + // set & play the animation on the specified window (animWin) + animWin->SetAnimation(KUidTestAnimation2)->Play(ETrue); + TSize subsize1 = paintWin->BaseWin()->Size(); + TRect subposition1(subsize1); + CalcCentredAnimPosition(subposition1, subsize1); + animWin->SetPosAnimation(KUidTestAnimation2, subposition1); + + #ifdef RUN_SAMPLE_ON_LEFT + // play the demo animation in the left-hand window also + iBaseWin->InvalidateAndRedraw(ETrue, EFalse, ETrue); + #endif + + iTestWin->InvalidateAndRedraw(ETrue,EFalse,ETrue); + if (iOverWin) + { + iOverWin->InvalidateAndRedraw(ETrue,EFalse,ETrue); + } + + // invalidate increasingly larger squares on paintWin + // note, some fully overlap the animation, some partially overlap, and some don't overlap at all + TInt invalidateWaitTime=KAnimationFrameDelayTime*3/4; // microseconds + TInt temp = KErrNotFound; + for (TInt step=30;stepInvalidateAndRedraw(ETrue,EFalse,ETrue,&invalidRect); + + // calculate any additional frames that may be drawn by above. Note intentionally ignore frame result + temp = iPreviousFrameNum; + CheckAnimProgressedL(animWin, 1, EFalse); + + //new defect DEF101896: Test runs faster with this line removed, but there is evident tearing + iWaiter->Wait(invalidateWaitTime); //DEF101896 search string: //interrupt_foreground_draw + + if (temp == iPreviousFrameNum) + { + // give wserv more time to animate the frame + iWaiter->Wait(invalidateWaitTime); + } + CheckAnimProgressedL(animWin, 1); // calculate the frame drawn. Capture frame result + } + } + } + + // determine whether the animation was successful (ie: enough Good frames were detected) or not + // Note KMinGoodFrameThreshold is essentially an arbitrary number. This can be adjusted to accommodate + // performance requirements as needed + temp = LogResults(); + TInt quality = 100*iFrameStatus.iFrameOK/temp; + TEST(quality > KMinGoodFrameThreshold); + + ResetFrameCounters(); + iWaiter->Cancel(); + iTestWin->RemoveAnimation(KUidTestAnimation2); + iTestWin->SetBlankIt(ETrue); + if (iOverWin) + { + iOverWin->RemoveAnimation(KUidTestAnimation2); + iOverWin->SetBlankIt(ETrue); + } + } + +// +// resets the frame trackers to intial values +// +void CTCrpAnim::ResetFrameCounters() + { + iPreviousFrameNum = KErrNotFound; + iFrameStatus.iFrameOK = 0; + iFrameStatus.iFramePartial = 0; + iFrameStatus.iFrameIdentical = 0; + iFrameStatus.iFrameEmpty = 0; + iFrameStatus.iFrameTearing = 0; + iFrameStatus.iFrameSkipped = 0; + } + +// +// Log the current frame results & return the total number of frame calculations +// +// Calculated : the total number of frame-checks run +// Good: the frame was successfully drawn to screen & within specified tolerances for tearing, expected position & colour +// Partial: the frame was only partially drawn to screen. Specifcally the animated red line was only partially drawn +// Identical: the frame was in the same position as the last frame +// Empty: no redline was detected at all in the frame +// Skipped: the position of the frame was beyond the expected position +// +// There is a dependency on the timing as to when the frame is animated hence tolerances are used to allow +// for this. +// +TInt CTCrpAnim::LogResults() + { + TInt result = iFrameStatus.iFrameOK + iFrameStatus.iFramePartial + iFrameStatus.iFrameIdentical + + iFrameStatus.iFrameEmpty + iFrameStatus.iFrameTearing + iFrameStatus.iFrameSkipped; + INFO_PRINTF4(_L("\tAnimation results: Calculated[%d], Good[%d], Partial[%d]"), result, iFrameStatus.iFrameOK, iFrameStatus.iFramePartial); + INFO_PRINTF5(_L("\tAnimation results: Identical[%d], Empty[%d], Tearing[%d], Skipped[%d]"), iFrameStatus.iFrameIdentical, iFrameStatus.iFrameEmpty, iFrameStatus.iFrameTearing, iFrameStatus.iFrameSkipped); + return result; + } + +/** This test tests the result of drawing an animation and main draw to two windows that overlap. + The two windows are placed in exactly the same location, so the result of splitting the drawing across them should be "identical". + Note that when the anim and the draw are on different screens the lines are seen merged over the anim. +**/ +void CTCrpAnim::TestOverlappingWindowsL() + { + if (!iOverWin) + { + INFO_PRINTF1(_L("- Test skipped - transparency not supported")); + return; + } + + // setup necessary params + // Note we place the overlapping transparent window (iOverWin) directly on top of the test window (iTestWin) + iOverWin->BaseWin()->SetPosition(iTestWin->BaseWin()->Position()); + + enum + { + EAllBackground=0, + EForegroundDraw=1, + EForegroundAnim=2, + EAllForeGround=3, + ECountModes, + EFirstMode=EAllBackground, + }; + + // test the various permutations of overlapping vs animated windows + for (TInt mode = EFirstMode ; mode < ECountModes ; mode++) + { + INFO_PRINTF2(_L("TestOverlappingWindowsL [%d]"), mode); + TestSpriteLoopL((mode&EForegroundAnim)!=0,(mode&EForegroundDraw)!=0); + } + } + +/** + This method demonstrates clipping of an animation running behind a transparent window. + No main window redraw takes place here. +**/ +void CTCrpAnim::DemoClippingWindowsL() + { + if (!iOverWin) + { + INFO_PRINTF1(_L("- Test skipped - transparency not supported")); + return; + } + + // setup test case params. Note we calculate three different positions for the overlapping window + RWindow* win = iTestWin->Window(); + + TPoint screenPos= win->Position(); + TSize screenSize = win->Size(); + TRect subposition1(screenSize); + CalcCentredAnimPosition(subposition1, screenSize); + + TPoint testPositions[]= + { + //first test: window clips corner of anim + TPoint(screenPos.iX+screenSize.iWidth/2-10,screenPos.iY+screenSize.iHeight/2-10), + //test: window clips all of anim + TPoint(screenPos.iX+screenSize.iWidth/3,screenPos.iY+screenSize.iHeight/3), + //test: window clips none of anim + TPoint(screenPos.iX+screenSize.iWidth*2/3,screenPos.iY+screenSize.iHeight*2/3), + }; + + // calculate roughly number of frames we expect to have drawn + TInt loopWaitTime = KShortDelayLoop; // time given to allow animation to progress (arbitrary number) + float expectedFrameCount = 1; + if (loopWaitTime > KAnimationFrameDelayTime) + { + expectedFrameCount = loopWaitTime/KAnimationFrameDelayTime; + } + + for (TInt ii = 0; ii < ((sizeof testPositions)/(sizeof testPositions[0])) ; ii++) + { + // initialise test windows to known state with no active animations + ResetFrameCounters(); + iTestWin->RemoveAnimation(KUidTestAnimation2); + iTestWin->SetBlankIt(EFalse); + iOverWin->SetBlankIt(ETrue); + iOverWin->RemoveAnimation(KUidTestAnimation2); + + // position animation windows + iTestWin->SetAnimation(KUidTestAnimation2)->Play(ETrue); + iTestWin->SetPosAnimation(KUidTestAnimation2, subposition1); + iOverWin->BaseWin()->SetPosition(testPositions[ii]); // positions the transparent overlapping window + + // redraw both test windows + iTestWin->InvalidateAndRedraw(ETrue,EFalse,ETrue); + iOverWin->InvalidateAndRedraw(ETrue,EFalse,ETrue); + + // run the animation for an arbitrary period + for (TInt loopit = 0 ; loopit < 20 ; loopit++) + { + iWaiter->Wait(loopWaitTime); + CheckAnimProgressedL(iTestWin,static_cast(expectedFrameCount)); // log the frame result + } + + // calculate & log frame results. Test an acceptable number of frames were successfully animated + TInt total = LogResults(); + TInt qA = 100*iFrameStatus.iFrameOK/total; + TEST(qA > KMinGoodFrameThreshold); + } + } + +/** In this version, the background window is updated in patches. + If the animation intersects the transparent window then the whole transparent window is redrawn. +**/ +void CTCrpAnim::TestClippingWindowsL() + { + if (!iOverWin) + { + INFO_PRINTF1(_L("- Test skipped - transparency not supported")); + return; + } + // setup test case params. Note we calculate three different positions for the overlapping window + RWindow* win = iTestWin->Window(); + TPoint screenPos= win->Position(); + TSize screenSize = win->Size(); + + TPoint testPositions[]= + { + //first test: window clips corner of anim + TPoint(screenPos.iX+screenSize.iWidth/2-10,screenPos.iY+screenSize.iHeight/2-10), + //test: window clips all of anim + TPoint(screenPos.iX+screenSize.iWidth/3,screenPos.iY+screenSize.iHeight/3), + //test: window clips none of anim + TPoint(screenPos.iX+screenSize.iWidth*2/3,screenPos.iY+screenSize.iHeight*2/3), + }; + + for (TInt loopIt = 0; loopIt < ((sizeof testPositions)/(sizeof testPositions[0])) ; loopIt++) + { + iOverWin->BaseWin()->SetPosition(testPositions[loopIt]); // position the overlapping window + TestSpriteLoopL(EFalse,EFalse); + } + } + +/** This just demonstrates that an animation plays - for about 1 second. +**/ +void CTCrpAnim::BasicCRPDemo() + { + // draw the animation in two positions + TSize subsize1 = iTestWin->BaseWin()->Size(); + TRect subposition1(subsize1); + CalcCentredAnimPosition(subposition1, subsize1); + + if (iOverWin) + { + iOverWin->BaseWin()->SetPosition(KPointOffsite); //way away! + iOverWin->InvalidateAndRedraw(EFalse,EFalse,ETrue); + } + + CCrpAnim *animWin= iTestWin; + animWin->SetAnimation(KUidTestAnimation2)->Play(ETrue); + animWin->SetPosAnimation(KUidTestAnimation2, subposition1); + iTestWin->InvalidateAndRedraw(ETrue,EFalse,ETrue); + iBaseWin->InvalidateAndRedraw(ETrue,EFalse,ETrue); + + // allow the animation to play for ~1 second. Purpose is to demonstrate animation to an observer + iWaiter->Wait(KShortDelayLoop); + + ResetFrameCounters(); + iWaiter->Cancel(); + iTestWin->RemoveAnimation(KUidTestAnimation2); + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-CRP01-0001 + +@SYMDEF DEF100356 + +@SYMTestCaseDesc CRP animation test for redraw storing interrupting main draw + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Creates a CRP animation and runs it on the server scheduler + while also running redraws of the window. + + With Redraw storing this has been known to cause problems + sharing and resetting the window iDisplayRegion. + This is evidenced by white areas. + + +@SYMTestExpectedResults + The LHS window shows what the animation should look like just animating, + while the RHS window demonstrates the simultanious animation and redraw. + No White patches should be in evidence, and no missing fragments of animation. + The TEST should detect white patches. +*/ +void CTCrpAnim::TestSpriteInterruptsForegroundL() + { + // setup test params + TSize subsize1(iTestWin->BaseWin()->Size()); + TRect subposition1(subsize1); + CalcCentredAnimPosition(subposition1, subsize1); + if (iOverWin) + { + iOverWin->BaseWin()->SetPosition(KPointOffsite); // ensure overlapping transparent window DOESN'T overlap the test window + } + + // execute test loop + TestSpriteLoopL(EFalse,EFalse); + } + +void CTCrpAnim::RunTestCaseL(TInt /*aCurTestCase*/) + { + _LIT(KTest1,"1: Basic CRP demo"); + _LIT(KTest2,"2: sprite anim interrupts foreground"); + _LIT(KTest3,"3: translucent windows"); + _LIT(KTest4,"4: CRP clipping windows"); + _LIT(KTest5,"5: CRP & redraw clipping windows"); + _LIT(KTest6,"6: CRP Invalidation"); + + ((CTCrpAnimStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); + switch(++iTest->iState) + { + case 1: +/** +@SYMTestCaseID GRAPHICS-WSERV-CRP01-0002 +*/ + ((CTCrpAnimStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-CRP01-0002")); + iTest->LogSubTest(KTest1); + BasicCRPDemo(); + break; + case 2: + ((CTCrpAnimStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-CRP01-0001")); + iTest->LogSubTest(KTest2); + TestSpriteInterruptsForegroundL(); + break; + case 3: +/** +@SYMTestCaseID GRAPHICS-WSERV-CRP01-0003 +*/ + ((CTCrpAnimStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-CRP01-0003")); + iTest->LogSubTest(KTest3); + TestOverlappingWindowsL(); + break; + case 4: +/** +@SYMTestCaseID GRAPHICS-WSERV-CRP01-0004 +*/ + ((CTCrpAnimStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-CRP01-0004")); + iTest->LogSubTest(KTest4); + DemoClippingWindowsL(); + break; + case 5: +/** +@SYMTestCaseID GRAPHICS-WSERV-CRP01-0005 +*/ + ((CTCrpAnimStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-CRP01-0005")); + iTest->LogSubTest(KTest5); + TestClippingWindowsL(); + break; + case 6: +/** +@SYMTestCaseID GRAPHICS-WSERV-CRP01-0006 +*/ + ((CTCrpAnimStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-CRP01-0006")); + iTest->LogSubTest(KTest6); + //this testcase is removed, because invalidation is removed from CWsGraphicDrawer destructor (due to flickering) + break; + default: + ((CTCrpAnimStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + ((CTCrpAnimStep*)iStep)->CloseTMSGraphicsStep(); + TestComplete(); + } + ((CTCrpAnimStep*)iStep)->RecordTestResultL(); + } + +// +namespace //anonymous namespace + { +// + CAnimRedrawWindow::CAnimRedrawWindow(CCrpAnim *aAnimWindow, TBool aIsBase) : CTWin(), + iAnimWindow(aAnimWindow), + iIsBase(aIsBase) + { + } + + CAnimRedrawWindow::~CAnimRedrawWindow() + { + } + + void CAnimRedrawWindow::Draw() + { + CCrpAnim::Draw(Gc(),Size(),iIsBase,iAnimWindow->iRect,iAnimWindow->iBlankIt,iAnimWindow->iRepeatDrawMax,iAnimWindow->iAlphaValue); + if (iAnimWindow->iAnimUid!=TUid::Null()) + { + TheClient->Flush(); + Gc()->DrawWsGraphic(iAnimWindow->iAnimUid,iAnimWindow->iAnimPos,iAnimWindow->iAnimData.Pckg()); + TheClient->Flush(); + } + } + + // + + CCrpAnim::CCrpAnim(TBool aIsBase, TWinType aWinType) + : iWinType(aWinType), + iIsBase(aIsBase), + iBlankIt(EFalse), + iRepeatDrawMax(1), + iAnimUid(TUid::Null()), + iAlphaValue(ENoTransparency) + { + } + + CCrpAnim::~CCrpAnim() + { + delete iCtWin; + } + + void CCrpAnim::ConstructL(const TPoint &aPos, const TSize &aSize, TInt aAlphaValue) + { + TDisplayMode reqMode = EColor16MA; //for transparency we need 16ma or 16map mode + TDisplayMode *pReqMode=&reqMode; + switch(iWinType) + { + case ERedraw: + iCtWin = new(ELeave) CAnimRedrawWindow(this, iIsBase); + break; + case EBlank: + iCtWin = new(ELeave) CTBlankWindow(); + break; + case EBackedUp: + iCtWin = new(ELeave) CTBackedUpWin(EColor64K); + pReqMode = NULL; + break; + } + iCtWin->SetUpL(aPos, aSize, TheClient->iGroup, *TheClient->iGc, pReqMode, ETrue); + if (aAlphaValue != ENoTransparency) + { + User::LeaveIfError(Window()->SetTransparencyAlphaChannel()); + //the window itself should be completely transparent, the draw commands will use the alpha value + Window()->SetBackgroundColor(TRgb(0, 0, 0, 0)); + iAlphaValue = aAlphaValue; + } + } + + void CCrpAnim::SetEllipseDrawMode(CGraphicsContext::TDrawMode aEllipseDrawMode) + { + iEllipseDrawMode = aEllipseDrawMode; + } + + void CCrpAnim::DrawEllipse(CBitmapContext *aGc, const TRect &aRect, TInt aAlphaValue) + { + if(aAlphaValue != ENoTransparency) + { + aGc->SetBrushColor(TRgb(85,85,85, aAlphaValue)); + aGc->SetPenColor(TRgb(170,170,170, aAlphaValue)); + } + else + { + aGc->SetBrushColor(TRgb(85,85,85)); + aGc->SetPenColor(TRgb(170,170,170)); + } + aGc->SetDrawMode(iEllipseDrawMode); + aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + aGc->DrawEllipse(aRect); + } + + void CCrpAnim::Draw(CBitmapContext *aGc, const TSize &aSize, TBool aIsBase, const TRect &aRect, TBool aBlankIt,TInt aRepeat, TInt aAlphaValue) + { + static TInt sGrey=0; + sGrey+=3; + if (sGrey>0x40) + sGrey-=0x40; + sGrey=sGrey^0x20; + if(aAlphaValue != ENoTransparency) + { + aGc->SetBrushColor(TRgb(sGrey, sGrey, sGrey, aAlphaValue)); + aGc->SetPenColor(TRgb(KRgbGreen.Value(), aAlphaValue)); + } + else + { + aGc->SetBrushColor(TRgb::Gray256(sGrey)); + aGc->SetPenColor(KRgbGreen); + } + aGc->Clear(); + TInt xPos=aSize.iHeight,yPos=aSize.iWidth; + + // The test windows are created relative to screen size. The + // number of green lines generated needs to be tied into the + // window size to prevent green becoming the dominant colour + // when blended with the second animation, which would + // prevent the PredominantColour() algorithm from discovering + // the red line. + TInt yStep = aSize.iHeight/14; + TInt xStep = aSize.iWidth/6; + + //This paint is intentionally complex and slow so that the animation timer is likely to interrupt it. + if (!aBlankIt) + for (TInt nn = 0 ; nn < aRepeat ; nn++) + for(yPos=0 ; yPos < aSize.iHeight ; yPos += yStep) + for(xPos=0 ; xPos < aSize.iWidth ; xPos += xStep) + aGc->DrawLine(aRect.Center(),TPoint(xPos,yPos)); + if (aIsBase) + DrawEllipse(aGc, aRect, aAlphaValue); + } + + //This simple API may need replacing by a list and search if multiple anims are played together + TWsGraphicAnimation* CCrpAnim::SetAnimation(TUid aUid) + { //currently only have 1 animation - it gets replaced. It could get refiused + iAnimUid=aUid; + return &iAnimData; + } + + TWsGraphicAnimation* CCrpAnim::GetAnimation(TUid aUid) + { //currently only have 1 animation + if (iAnimUid==aUid) + return &iAnimData; + else + return NULL; + } + + void CCrpAnim::SetPosAnimation(const TUid& aUid, const TRect& aRect) + { //currently only have 1 animation + if (iAnimUid==aUid) + iAnimPos = aRect; + } + + TRect* CCrpAnim::GetPosAnimation(const TUid& aUid) + { //currently only have 1 animation + if (iAnimUid==aUid) + return &iAnimPos; + else + return NULL; + } + + TBool CCrpAnim::RemoveAnimation(TUid) + { + iAnimUid=TUid::Null(); + iAnimData.Stop(EFalse); + return ETrue; + } + + void CCrpAnim::DoDraw() + { + DoDraw(iBlankIt); + } + + inline void CCrpAnim::DoDraw(TBool aBlankIt) + { + __ASSERT_ALWAYS(iWinType!=EBlank,AutoPanic(EAutoPanicWindowType)); + iCtWin->Gc()->Activate(*Window()); + Draw(iCtWin->Gc(),Size(),iIsBase,iRect,aBlankIt,iRepeatDrawMax,iAlphaValue); + if (iAnimUid!=TUid::Null()) + iCtWin->Gc()->DrawWsGraphic(iAnimUid,iAnimPos,iAnimData.Pckg()); + iCtWin->Gc()->Deactivate(); + } + + void CCrpAnim::DoDrawEllipse() + { + __ASSERT_ALWAYS(iWinType!=EBlank,AutoPanic(EAutoPanicWindowType)); + iCtWin->Gc()->Activate(*Window()); + DrawEllipse(iCtWin->Gc(),iRect,iAlphaValue); + iCtWin->Gc()->Deactivate(); + } + + void CCrpAnim::InvalidateAndRedraw(TBool /*aUseBlankItMember*/,TBool /*aBlankIt*/,TBool aUseRWindowInvalidate,TRect* aRect) + { + RWindow& win = *Window(); + if (aRect) + { + if (aUseRWindowInvalidate) + win.Invalidate(*aRect); + else + Invalidate(*aRect); + } + else + { + if (aUseRWindowInvalidate) + win.Invalidate(); + else + Invalidate(); + } + if (aRect) + win.BeginRedraw(*aRect); + else + win.BeginRedraw(); + DoDraw(); + win.EndRedraw(); + TheClient->Flush(); + } + + void CCrpAnim::Invalidate(const TRect &aRect) + { + TRect rect(aRect); + rect.Move(iCtWin->Position()); + CTUser::Splat(TheClient,rect,TRgb::Gray256(0)); + } + +// + } //end anonymous namespace +// +__WS_CONSTRUCT_STEP__(CrpAnim) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/tcrpanim.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/tcrpanim.h Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,98 @@ +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// TCrpAnim.H Defines class CTCrpAnim +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef __TCRPANIM_H__ +#define __TCRPANIM_H__ + +#include "AUTO.H" + +_LIT(KTCrpAnimStep,"TCrpAnim"); + +namespace //anonymous local scope + { + class CCrpAnim; + typedef CCrpAnim CAnonAnimWindow; + class CActiveWait; + typedef CActiveWait CAnonActiveWait; + } + +class CTCrpAnim : public CTWsGraphicsBase + { +public: + CTCrpAnim(CTestStep* aStep); + ~CTCrpAnim(); + void ConstructL(); +protected: + virtual void RunTestCaseL(TInt aCurTestCase); +private: + // TAnimFrameResult is a struct designed to track the various frame results + // as the animation progresses. Once the animation is complete, TAnimFrameResult + // provides an easy to read indication as to the animation's performance + struct TAnimFrameResult + { + TInt iFrameOK; + TInt iFramePartial; + TInt iFrameIdentical; + TInt iFrameEmpty; + TInt iFrameTearing; + TInt iFrameSkipped; + }; + void InvalidatePauseAndRedraw(const TRect &aRect,TTimeIntervalMicroSeconds32 aInterval); + void RedrawAndCheckWindows(TBool aBlankIt=EFalse); + void TestSpriteLoopL(TBool aAnimForeground,TBool aDrawForeground); + void CheckAnimProgressedL(CAnonAnimWindow* aAnimWin, TInt aAdditionalFrameCount, TBool aCaptureFrameResult = ETrue); + TInt DetermineApproxFrameNum(CFbsBitmap* aBitmap, TBool aCaptureFrameResult); + void ResetFrameCounters(); + TInt LogResults(); +// The tests + void TestSpriteInterruptsForegroundL(); + void TestSpriteRestartInterruptsForegroundL(); + void BasicCRPDemo(); + void TestOverlappingWindowsL(); + void TestClippingWindowsL(); + void DemoClippingWindowsL(); + void TestInvalidateL(); +private: + CAnonAnimWindow *iTestWin; + CAnonAnimWindow *iOverWin; + CAnonAnimWindow *iRedrawWin; + CAnonAnimWindow *iBaseWin; + TInt iPreviousFrameNum; // identifies the last successfully drawn frame number calculated + TInt iMinimumCalcRedLine; // the calculated minimum length of the red line in the animation + TAnimFrameResult iFrameStatus; // tracker for the performance of each animated frame + CActiveWait* iWaiter; // active object with configurable timer + CWsGraphicBitmapAnimation* iAnim; // ptr to server-side animation object + CFbsBitmap* iScreenBitmap; // bitmap holding screen snap-shot + HBufC8* iScanlineBuf; // buffer holding pixel data on a single vertical scan line + }; + +class CTCrpAnimStep : public CTGraphicsStep + { +public: + CTCrpAnimStep(); +protected: + //from CTGraphicsStep + virtual CTGraphicsBase* CreateTestL(); + }; + +#endif //__TCRPANIM_H__ diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/tdirecta.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/tdirecta.h Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,522 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef __TDIRECTA_H__ +#define __TDIRECTA_H__ + +#include "AUTO.H" +#include +#include +#include "TGraphicsHarness.h" + +//#define LOGGING + +class CColorAnimation; +class CScrollText; +class CScrollingTextDrawer; +class CDirectScreenAccessOld; + + +struct TDirectThreadParam + { + TRect iRect; + TInt iScreenNumber; + TBool iIsInFront; + }; + +class MAnimCallBacks + { +public: + virtual void LogLeave(TInt aErr)=0; + virtual void Fail()=0; + virtual void Finished(TInt aId)=0; + virtual TDisplayMode DisplayMode(TInt aId)=0; + virtual TRgb BrushColorL(TInt aId,TInt& aColor,TBool& aFinished)=0; + virtual TInt TimerInterval(TInt aId)=0; + virtual void FailedReStart(TInt aId,TInt aReason)=0; + virtual TInt SlowStopping(TInt aId,TInt aCount)=0; + virtual void Log(const TText8* aFile, TInt aLine, TInt aSeverity,const TDesC& aString)=0; +public: + CTBlankWindow* iCallBackWin; + }; + +class CTDirect : public CTWsGraphicsBase, public MAbortDirectScreenAccess, public MAnimCallBacks + { +public: + enum + { + eDirectNumFrames=10 + }; + enum + { + eDirectControlSem=0x01, + eDirectWindowSem=0x02, + eFontSet=0x04, + eMultiAnim=0x08, + }; +public: + CTDirect(CTestStep* aStep); + ~CTDirect(); + void ConstructL(); + TBool DrawFrame(); + TBool Restart(); + void ChangeToNextScreenModeL(); + void ChangeScreenScale(); + //The Tests + TestState AnimateWindowL(); + TestState AnimationDiesL(); + TestState PackagingClassL(); + TestState MultipleL(); + TestState FailCodesL(); + TestState ScrolingText1L(); + TestState RClassL(); + TestState ScrolingText2L(); + TestState ScrolingText3L(); + TestState ScrolingText4L(); + TestState DefectFix_KAA_5J3BLW_L(); + TestState KillAnimationL(); + TestState DSAWithScreenModeOffset1L(); + TestState DSAWithScreenModeOffset2L(); + TestState WindowPoistionRelativeToScreenL(); + TestState ScreenModeScalingTestL(); + TestState ScreenModeTestForScalingL(); + TestState MultipleDSAsOnSameWindowL(); + TestState TemporaryDeadlockL(); + TestState RegionTrackingOnlyNotificationsL(TUint aId); + TestState MixDsaAndRegionTrackingOnlyL(TBool aWhoExitsLast); + TestState TryDifferentSupportedModesL(); +protected: +//from CTGraphicsStep + virtual void RunTestCaseL(TInt aCurTestCase); +private: + void ConstrucBlankWindowL(); + void ScanTypeFacesL(); + void InitialiseAnimationL(); + void DestroyAnimation(); + void ResetScreenSizeMode(); + void StartDirect(); + void SignalWindow(); + void ModeSwitch(); + void ScrolingTextL(TInt aId,TRect aWinRect,TBool aStartThread,TInt aScreenMode=0); + void AnimTestL(TInt aId,TRect aWinRect,CTWinBase& aParent); + //Pure virtual function from MAbortDirectScreenAccess + void AbortNow(RDirectScreenAccess::TTerminationReasons aReason); + //Pure virtual functions from MAnimCallBacks + void LogLeave(TInt aErr); + void Fail(); + void Finished(TInt aId); + void DeleteMoveWindow(); + void DeleteScroll(); + TDisplayMode DisplayMode(TInt aId); + TRgb BrushColorL(TInt aId,TInt& aColor,TBool& aFinished); + TInt TimerInterval(TInt aId); + void FailedReStart(TInt aId,TInt aReason); + TInt SlowStopping(TInt aId,TInt aCount); + void Log(const TText8* aFile, TInt aLine, TInt aSeverity,const TDesC& aString); + void SetScreenMode(TInt aMode,TPixelsAndRotation& aPixelsAndRotation); + void CreateAnimForScreenModeL(TInt aAnimIndex,CTWinBase& aParent,TRect aRect,TInt aId); + void BlankTopClientWindowL(CTBlankWindow& aBlankWindow,TRect aRect); + void TestDifferentOriginAndScaleL(TSizeMode &aMode,TPoint aOrigin); + void CheckForTemporaryDeadlock(); +private: + CProcess* iProcess; + CProcess* iMoveWin; + RSemaphore iControlSem; + RMsgQueueBase iControlQueue; + RSemaphore iWinSem; + TRequestStatus iThreadStatus; + TUint iFlags; + CTBlankWindow* iWin; + CTBlankWindow* iWin2; + CFbsScreenDevice* iScrDev; + CFbsBitGc* iGc; + CFont* iFont; + CPeriodic* iTimer; + CIdle* iRestart; + CDirectScreenAccessOld* iDirect; + RRegion* iDrawingRegion; + TSize iScrSize; + TRect iDrawRect; + TInt iDrawHeight; + TInt iFrameNo; + TInt iLastTextWidth; + TInt iLastMaxTextWidth; + TInt iFrameToSignalAfter; + TBool iDelay; + TBool iCancelNext; + TBool iWindowDead; + CColorAnimation* iAnim; + CColorAnimation* iAnims[13]; + TInt iCount; + CScrollText* iScroll; + TInt iCycles; + TScreenModeEnforcement iModeBackup; + TThreadStartUp iFirstFunction; + TInt iNumThreadHandles; + CTBlankWindow* iBlankTopClientWin1; + CTBlankWindow* iBlankTopClientWin2; + CPeriodic* iChangeScreenModeTimer; + TInt iCurrentMode; + TInt iNumOfModes; + TPoint iCurrentScreenModeOrigin; + TSize iCurrentScreenModeScale; + TInt iNumAnimation; + TSizeMode iModeData; + CPeriodic* iScreenModeTimer; + TInt iIsScalingSupported; + TInt iNumOfCallBack; + TBool iTestJustFailed; + TBool iTestJustCompleted; + TInt iState; + TBool iNextFrameFinished; + TBool iPackagingFinished; + TBool iTimerRunning; + }; + +class CDirectScreenAccessOld : public CActive + { +public: + static CDirectScreenAccessOld* NewL(RWsSession& aWs,MAbortDirectScreenAccess& aAborter); + ~CDirectScreenAccessOld(); + TInt Request(RRegion*& aRegion, RWindowBase& aWindow); +private: + inline CDirectScreenAccessOld(RWsSession& aWs,MAbortDirectScreenAccess& aAborter) + : CActive(RDirectScreenAccess::EPriorityVeryHigh), iDirectAccess(aWs), iAborter(aAborter) {} + void ConstructL(); + //Pure virtual functions from CActive + void DoCancel(); + void RunL(); +private: + RDirectScreenAccess iDirectAccess; + MAbortDirectScreenAccess& iAborter; + TBool iAborting; + }; + +class CColorAnimation : public CBase, public MDirectScreenAccess + { +public: + enum + { + eStopNow=EFalse, + eStopDelayed=ETrue, + eAbort=2, + eAbortAll, + }; +public: + static TInt DrawColorL(TAny* aAnimation); + static TInt IdlingL(TAny* aAnimation); + static CColorAnimation* NewL(TInt aScreenNumber,TInt aId,MAnimCallBacks& aCallBack,CTWinBase& aParent,TRect aExtent,TBool aStart,TBool aRegionTrackingOnly = EFalse); + inline CColorAnimation(TInt aScreenNumber,TInt aId,MAnimCallBacks& aCallBack) :iId(aId), iCallBack(aCallBack), iScreenNumber(aScreenNumber) {} + ~CColorAnimation(); + void ConstructL(CTWinBase& aParent,TRect aExtent,TBool aRegionTrackingOnly,TInt aTypeWindow=0,TInt aSingleWinForMultipleDSA=0); + void StartL(TBool aChildWindow=EFalse); + void StartOrPanic(); + void Stop(); + void BringWindowToFront(); + void ChangeModeL(TDisplayMode aMode); + TBool inline IsTimerActive() {return iTimer->IsActive();} + inline MAnimCallBacks& CallBack() { return iCallBack; } + TPoint AbsoluteWindowPosition(TInt aWindowId=0); + inline CDirectScreenAccess* GetDrawer(); + void FinishTest(); + TBool TestGcAndScreenDeviceValues(); + //inline TBool IsReadyToAbort(){return (iDrawer->iStatus!=KRequestPending);} +protected: + void DrawColorL(); + void IdlingL(); + /*pure virtual function from MAbortDirectScreenAccess*/ + void AbortNow(RDirectScreenAccess::TTerminationReasons aReason); + /*pure virtual function from MDirectScreenAccess*/ + void Restart(RDirectScreenAccess::TTerminationReasons aReason); +private: + TInt iId; + CTBlankWindow* iWindow; + CTBlankWindow* iWindow2; + TSize iWinSize; + CDirectScreenAccess* iDrawer; + CPeriodic* iTimer; + MAnimCallBacks& iCallBack; + TInt iColor; + TInt iCount; + TUint iIdling; + TInt iScreenNumber; + TInt iSingleWinForMultipleDSA; + TBool iRegionTrackingOnly; + }; + +class CScrollingTextDrawer : public CBase + { +public: + static CScrollingTextDrawer* NewL(TInt aScreenNumber,CFbsScreenDevice*& aDevice,CFbsBitGc& aGc); + ~CScrollingTextDrawer(); + inline void SetScrollJump(TInt aJump) {iJump=aJump;} + void SetBottomOfTest(TInt aBottom); + void Scroll(); +private: + inline CScrollingTextDrawer(CFbsScreenDevice*& aDevice,CFbsBitGc& aGc) : iDevice(aDevice), iGc(&aGc) {} + void ConstructL(TInt aScreenNumber); + void CreateFontL(); +private: + CFbsScreenDevice*& iDevice; + CFbsScreenDevice* iFontDevice; + CFbsBitGc* iGc; + CFont* iFont; + TBuf<32> iText; + TRect iDrawRect; + TInt iDrawHeight; + TInt iCharWidth; + TInt iFirstChar; + TInt iJump; +#if defined(LOGGING) + RWsSession iWs; +#endif + }; + +class CScrollText : public CBase, public MDirectScreenAccess + { +public: + static TInt DrawText(TAny* aAnimation); + static CScrollText* NewL(TInt aScreenNumber,TInt aId,CTWindowGroup& aParent,TInt aScrollJump,TBool aStart=EFalse); + inline CScrollText(TInt aId,TInt aScrollJump,TInt aScreenNumber) :iId(aId), iScrollJump(aScrollJump), iScreenNumber(aScreenNumber) {} + ~CScrollText(); + void ConstructL(CTWindowGroup& aParent); + void StartL(); + void Stop(); + void ContinueL(); + inline TBool IsRunning() {return iTimer->IsActive();} + inline void SetCountDown(TInt aCountDown) {iAbortCountDown=aCountDown; iCounting=ETrue;} + inline void SetBottomOfTest(TInt aBottom) {iTextDraw->SetBottomOfTest(aBottom);} +private: + void ScrollText(); + void DoContinueL(); + /*pure virtual function from MAbortDirectScreenAccess*/ + void AbortNow(RDirectScreenAccess::TTerminationReasons aReason); + /*pure virtual function from MDirectScreenAccess*/ + void Restart(RDirectScreenAccess::TTerminationReasons aReason); +private: + TInt iId; + CTBlankWindow* iWindow; + TSize iWinSize; + CDirectScreenAccess* iDrawer; + CScrollingTextDrawer* iTextDraw; + CPeriodic* iTimer; + TInt iScrollJump; + TBool iCounting; + TInt iAbortCountDown; + TInt iScreenNumber; + }; + + +/** + A simple class based on CScrollText constructs a blank window that has + a blank window child, used for functional coverage testing of CWsClientWindow + */ +class CWindowWithChild : public CBase, public MDirectScreenAccess + { +public: + static CWindowWithChild* NewL(TInt aScreenNumber, CTWindowGroup& aParent,TBool aStart=EFalse); + inline CWindowWithChild(TInt aScreenNumber) : iScreenNumber(aScreenNumber) {} + ~CWindowWithChild(); + void ConstructL(CTWindowGroup& aParent); + void StartL(); + void Stop(); + void ContinueL(); + inline TBool IsRunning() {return iRunning;} + void PerformCoverageCalls(); + RWindow *ChildWindow() {return iChildWindow->Win();} +private: + void DoContinueL(); + /*pure virtual function from MAbortDirectScreenAccess*/ + void AbortNow(RDirectScreenAccess::TTerminationReasons aReason); + /*pure virtual function from MDirectScreenAccess*/ + void Restart(RDirectScreenAccess::TTerminationReasons aReason); +private: + CTBlankWindow* iWindow; + CTWin * iChildWindow; + TSize iWinSize; + CDirectScreenAccess* iDrawer; + TInt iScreenNumber; + TBool iRunning; + }; + + +class CWsBase : public CBase + { +public: +protected: + ~CWsBase(); + void ConstructL(TInt aScreenNumber,TInt aHandle); + void CreateBlankWindowL(RBlankWindow& iWin,TInt aHandle); +protected: + RWsSession iWs; + CWsScreenDevice *iScrDev; + RWindowGroup iGroup; + }; + +class CAnimating : public CWsBase, public MAbortDirectScreenAccess + { +public: + static TInt StartLC(TAny* aScreenNumber); + //static CAnimating* NewLC(); + void DrawFrame(); + /*pure virtual function from MAbortDirectScreenAccess*/ + void AbortNow(RDirectScreenAccess::TTerminationReasons aReason); +private: + void ConstructL(TInt aScreenNumber); + ~CAnimating(); + void StartAnimatingL(); +private: + RSemaphore iControlSem; + RMsgQueueBase iControlQueue; + TBool iSemCreated; + RBlankWindow iWindow; + CFbsScreenDevice* iScrDev; + CFbsBitGc* iGc; + TSize iScrSize; + CDirectScreenAccessOld* iDirect; + RRegion* iDrawingRegion; + CPeriodic* iTimer; + TInt iColor; + }; + +class CMoveWindow : public CWsBase + { +public: + static TInt StartLC(TAny* aScreenNumber); + static TInt StateChange(TAny* aMoveWin); + static TInt FlipChange(TAny*); + //Call Backs + void MoveWindow(); +private: + inline static CMoveWindow* Cast(TAny* aMoveWin) {return STATIC_CAST(CMoveWindow*,aMoveWin);} + ~CMoveWindow(); + void ConstructL(TInt aScreenNumber); + void CreateTimerL(); + void StateChange(); + void ToggleDisplayMode(); + void FlipChange(); +private: + CPeriodic* iFlipTimer; + CPeriodic* iStateTimer; + CPeriodic* iTimer; + CWsScreenDevice* iDevice; + RBlankWindow iWindow; + TDisplayMode iDisplayMode; + RBackedUpWindow iBackUpWin; + CWindowGc* iGc; + TRect iBounceArea; + TSize iScrSize; + TPoint iTl; + TSize iSize; + TSize iDelta; + TInt iStateCountDown; + TInt iNumOfModes; + TInt iCurrentMode; + }; + +class CBugFixColorAnimation : public CColorAnimation + { +public: + static CBugFixColorAnimation* NewL(TInt aScreenNumber,TInt aId,MAnimCallBacks& aCallBack,CTWindowGroup& aParent,TRect aExtent,TBool aStart=EFalse); + ~CBugFixColorAnimation(); + inline void Started() { iSem.Signal(); } +private: + CBugFixColorAnimation(TInt aScreenNumber,TInt aId,MAnimCallBacks& aCallBack); + void ConstructL(CTWindowGroup& aParent,TRect aExtent); +private: + /*pure virtual function from MAbortDirectScreenAccess*/ + void AbortNow(RDirectScreenAccess::TTerminationReasons aReason); + /*pure virtual function from MDirectScreenAccess*/ + void Restart(RDirectScreenAccess::TTerminationReasons aReason); +private: + CProcess* iThread; + CIdle* iTestFailed; + TRect iAnimRect; + TDirectThreadParam iThreadParam; + RSemaphore iSem; + }; + +class CRegionTrackingOnly : public CColorAnimation + { +public: + static CRegionTrackingOnly* NewL(TInt aScreenNumber,TInt aId,MAnimCallBacks& aCallBack,CTWindowGroup& aParent,TRect aExtent,TBool aStart,TBool aOpenWindowInFrontDsa); + void ConstructL(CTWindowGroup& aParent,TRect aExtent,TBool aOpenWindowInFrontDsa); + ~CRegionTrackingOnly(); + inline void Started() { iSem.Signal(); } +private: + CRegionTrackingOnly(TInt aScreenNumber,TInt aId,MAnimCallBacks& aCallBack); + /*Overriding of bases class virtual functions*/ + void AbortNow(RDirectScreenAccess::TTerminationReasons aReason); + void Restart(RDirectScreenAccess::TTerminationReasons aReason); +private: + CProcess* iThread; + TRect iAnimRect; + TBool iExpectedToAbort; + TDirectThreadParam iThreadParam; + RSemaphore iSem; + }; + +/*CPanicDirect*/ + class CPanicDirect : public CBase + { + public: + static TInt DoTestOnNewScheduler(TInt aInt, TAny* aPtr); + static TInt DoTestOnNewSchedulerL(TInt aInt, TAny* aPtr); + private: + inline CPanicDirect() {} + ~CPanicDirect(); + void ConstructL(TInt aScreenNumber, TInt aInt); + static void DoTestNowL(TInt aInt, TAny* aPtr); + void TestL(); + void DoDrawingL(); +private: + TInt iTestNo; + RWsSession iWs; + CWsScreenDevice* iWsScrDev; + RWindowGroup iGroup; + RBlankWindow iBlankWin; + RDirectScreenAccess iDirect; + TRequestStatus iDirectStatus; + RRegion* iRegion; + RTimer iTimer; + TRequestStatus iTimerStatus; + TBool iDrawingAllowed; + CFbsScreenDevice* iScreenDevice; + CFbsBitGc* iGc; + TDisplayMode iDisplayMode; + CScrollingTextDrawer* iTextDraw; + TInt iCount; + TInt iScreenNumber; + }; + +class CTDirectStep : public CTGraphicsStep + { +public: + CTDirectStep(); +protected: + //from CTGraphicsStep + virtual CTGraphicsBase* CreateTestL(); + }; + +_LIT(KTDirectStep,"TDirect"); + + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/tdirecta2.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/tdirecta2.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,185 @@ +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Test Direct Screen Access on a screen that supports transparency +// +// + +#include "tdirecta2.h" + +const TInt KMainTestOrdinalPriority=65535; +const TInt KOntopOfAllOthersTestOrdinalPriority=65537; + +CTDirect2::CTDirect2(CTestStep* aStep): + CTWsGraphicsBase(aStep) + { + } + +CTDirect2::~CTDirect2() + { + delete iDsa; + delete iUnderWindow; + delete iOverWindow; + delete iScreenDevice; + delete iWindowGroup; + delete iTimer; + + // put focus back to current screen as this test changed the focus screen to primary screen + TheClient->iWs.SetFocusScreen(iTest->iScreenNumber); + } + +void CTDirect2::ConstructL() + { + // the following line makes sure that a console object hidden outside of + // screens range doesn't affect test results being on top of tested objects + TheClient->iGroup->GroupWin()->SetOrdinalPosition(0, KMainTestOrdinalPriority); + } + +TInt CTDirect2::Timeout(TAny* aDirect2) + { + static_cast(aDirect2)->HandleTimeout(); + return KErrNone; + } + +void CTDirect2::HandleTimeout() + { + // Send window group to back to avoid possibility of it + // interfering with other parts of this test + iWindowGroup->GroupWin()->SetOrdinalPosition(0, -1); + + iTimer->Cancel(); // Don't call back again + TEST(EFalse); // Fail the test, as we didn't get a DSA abort within timeout period + iTestCaseComplete = ETrue; // Move to next test case + } + +void CTDirect2::AbortNow(RDirectScreenAccess::TTerminationReasons /*aReason*/) + { + iTimer->Cancel(); // As soon as abort is received, we don't need the timer anymore + } + +void CTDirect2::Restart(RDirectScreenAccess::TTerminationReasons /*aReason*/) + { + // Send window group to back to avoid possibility of it + // interfering with other tests + iWindowGroup->GroupWin()->SetOrdinalPosition(0, -1); + + iTestCaseComplete = ETrue; // Move to next test case + + // Don't bother restarting DSA, we were only interested in making sure the abort was sent by wserv + } + +// Starts DSA on a topmost window, then puts a translucent window ontop of it +// to make sure wserv sends a DSA Abort even though the translucent window +// hasn't changed the visible area of the DSA window +void CTDirect2::StartTranslucentWindowOverDsaL() + { + // Use a new window group so we can put windows ontop of all others + iWindowGroup = new(ELeave) CTWindowGroup(TheClient); + iWindowGroup->ConstructL(); + + // Create new blank window + iUnderWindow = new(ELeave) CTBlankWindow(); + iUnderWindow->SetUpL(TPoint(10,10), TSize(100,100), iWindowGroup, *TheClient->iGc); + iUnderWindow->SetColor(TRgb(0,192,0)); + + // Make window group visible ontop of all others + User::LeaveIfError(iWindowGroup->GroupWin()->SetOrdinalPositionErr(0, KOntopOfAllOthersTestOrdinalPriority)); + TheClient->Flush(); + + // Call Finish() to wait until under window has been rendered. + // Once window has been rendered, we can be sure window server has + // calculated the "top visible" region of the window. + TheClient->iWs.Finish(); + + // Start DSA on under window + iScreenDevice = new(ELeave) CWsScreenDevice(TheClient->iWs); + User::LeaveIfError(iScreenDevice->Construct(iTest->iScreenNumber)); + iDsa = CDirectScreenAccess::NewL(TheClient->iWs, *iScreenDevice, *iUnderWindow->BaseWin(), *this); + iDsa->StartL(); + + // Put translucent window ontop so as to reduce the top visible area, but leave the + // visible area unchanged (as the translucent window doesn't change the visible area + // of the window underneath it). + iOverWindow = new(ELeave) CTTitledWindow(); + _LIT(KTranslucentWindowTitle, "Translucent window"); + iOverWindow->SetUpL(TPoint(60,60), TSize(150,100), iWindowGroup, *TheClient->iGc, NULL, ETrue); + TWindowTitle windowTitle(KTranslucentWindowTitle); + iOverWindow->SetTitle(windowTitle); + iOverWindow->SetColor(TRgb(192, 0, 0, 128)); + TheClient->Flush(); + + // Start a timer, if the timeout triggers, fail the test, as we should get + // an abort DSA from wserv within the timeout + iTimer = CPeriodic::NewL(CActive::EPriorityStandard); + const TInt KTimeoutPeriod = 5000000; // 5 seconds should give the client plenty of time to respond to the abort + iTimer->Start(KTimeoutPeriod, 0, TCallBack(CTDirect2::Timeout, this)); + + // Do nothing more here, once over win is rendered, wserv should cause CAbortTest::AbortNow + // to be called + } + +void CTDirect2::RunTestCaseL(TInt aCurTestCase) + { + ((CTDirect2Step*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); + switch(aCurTestCase) + { +/** +@SYMTestCaseID GRAPHICS-WSERV-0176 + +@SYMDEF PDEF116863 + +@SYMTestCaseDesc Overlapping a translucent window ontop of a DSA window should abort DSA + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Start DSA on a blank window. + Then place a translucent window so that it partially overlaps the DSA window. + +@SYMTestExpectedResults Wserv should send a DSA abort when the translucent window is placed ontop of the DSA window. +*/ + case 1: + ((CTDirect2Step*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0176")); + if (!iOnceOnly) + { + _LIT(DSA1,"Translucent window overlaping DSA window"); + INFO_PRINTF1(DSA1); + StartTranslucentWindowOverDsaL(); // call this only once + iOnceOnly = ETrue; + } + if (!iTestCaseComplete) + { + // Keep calling this test case until iTestCaseComplete is true + ResetCounter(aCurTestCase-1); + } + else + { + iOnceOnly = EFalse; + // Move to next test case in sequence + iTestCaseComplete = EFalse; + } + break; + + default: + INFO_PRINTF1(_L("Test complete\n")); + ((CTDirect2Step*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + ((CTDirect2Step*)iStep)->CloseTMSGraphicsStep(); + TestComplete(); + break; + } + ((CTDirect2Step*)iStep)->RecordTestResultL(); + } + +__WS_CONSTRUCT_STEP__(Direct2) + diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/tdirecta2.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/tdirecta2.h Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,73 @@ +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef __TDIRECTA2_H__ +#define __TDIRECTA2_H__ + +#include "AUTO.H" +#include "TGraphicsHarness.h" + +// This DSA test code only works when run using a screen that supports transparency. +class CTDirect2 : public CTWsGraphicsBase, public MDirectScreenAccess + { +public: + CTDirect2(CTestStep* aStep); + ~CTDirect2(); + void ConstructL(); + + static TInt Timeout(TAny* aAbortTest); + + // from MAbortDirectScreenAccess + void AbortNow(RDirectScreenAccess::TTerminationReasons aReason); + // from MDirectScreenAccess + void Restart(RDirectScreenAccess::TTerminationReasons aReason); + +protected: + //from CTGraphicsStep + void RunTestCaseL(TInt aCurTestCase); + +private: + void StartTranslucentWindowOverDsaL(); + void HandleTimeout(); + +private: + CWsScreenDevice* iScreenDevice; + CTWindowGroup* iWindowGroup; + CTBlankWindow* iUnderWindow; // window to perform DSA on + CTTitledWindow* iOverWindow; // translucent window to overlap DSA window + CDirectScreenAccess* iDsa; + CPeriodic* iTimer; + TBool iTestCaseComplete; + TBool iOnceOnly; + }; + +class CTDirect2Step : public CTGraphicsStep + { +public: + CTDirect2Step(); +protected: + //from CTGraphicsStep + virtual CTGraphicsBase* CreateTestL(); + }; + +_LIT(KTDirect2Step,"TDirect2"); + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/tdrawresource.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/tdrawresource.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,1144 @@ +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include "tdrawresource.h" +#include +#include +#include +#include +#include + + +__WS_CONSTRUCT_STEP__(DrawResource); + + +#if defined(__X86GCC__) +extern "C" TInt atexit(void (*function)(void)) + { + return KErrNone; + } +#endif + +// +// class CTestWsGraphicsContext +// +CTestWsGraphicsContext* CTestWsGraphicsContext::NewL(RDirectGdiImageTarget& aTarget) + { + CTestWsGraphicsContext* self = new(ELeave) CTestWsGraphicsContext; + CleanupStack::PushL(self); + self->ConstructL(aTarget); + CleanupStack::Pop(self); + return self; + } + +void CTestWsGraphicsContext::ConstructL(RDirectGdiImageTarget& aTarget) + { + CDirectGdiDriver* driver = CDirectGdiDriver::Static(); + User::LeaveIfNull(driver); + iContext = CDirectGdiContext::NewL(*driver); + TInt err = iContext->Activate(aTarget); + User::LeaveIfError(err); + } + +CTestWsGraphicsContext::~CTestWsGraphicsContext() + { + delete iContext; + } + +TAny* CTestWsGraphicsContext::ResolveObjectInterface(TUint aTypeId) + { + switch(aTypeId) + { + case MWsDrawableSourceProvider::EWsObjectInterfaceId: + return static_cast(this); + } + return NULL; + + } + +TInt CTestWsGraphicsContext::CreateDrawableSource(const TSgDrawableId& aDrawableId, TAny*& aSource) + { + TRAPD(err, DoCreateDrawableSourceL(aDrawableId, aSource)); + return err; + } + +void CTestWsGraphicsContext::DoCreateDrawableSourceL(const TSgDrawableId& aDrawableId, TAny*& aSource) + { + CDirectGdiDriver* driver = CDirectGdiDriver::Static(); + if (!driver) + { + User::Leave(KErrNotReady); + } + RDirectGdiDrawableSource* drawableSource = new(ELeave) RDirectGdiDrawableSource(*driver); + CleanupStack::PushL(drawableSource); + RSgDrawable drawable; + User::LeaveIfError(drawable.Open(aDrawableId, ESgDoNotRestrictUsage)); + CleanupClosePushL(drawable); + User::LeaveIfError(drawableSource->Create(drawable)); + CleanupStack::PopAndDestroy(); + CleanupStack::Pop(drawableSource); + aSource = drawableSource; + } + +void CTestWsGraphicsContext::CloseDrawableSource(TAny* aSource) + { + RDirectGdiDrawableSource* drawableSource = static_cast(aSource); + drawableSource->Close(); + delete drawableSource; + } + +void CTestWsGraphicsContext::DrawResource(const TAny* aSource, const TPoint& aPos, CWindowGc::TGraphicsRotation aRotation) + { + const RDirectGdiDrawableSource* drawableSource = static_cast(aSource); + iContext->DrawResource(aPos, *drawableSource, (DirectGdi::TGraphicsRotation)aRotation); + iPos = aPos; + iRotation = (DirectGdi::TGraphicsRotation)aRotation; + } + +void CTestWsGraphicsContext::DrawResource(const TAny* aSource, const TRect& aRect, CWindowGc::TGraphicsRotation aRotation) + { + const RDirectGdiDrawableSource* drawableSource = static_cast(aSource); + iContext->DrawResource(aRect, *drawableSource, (DirectGdi::TGraphicsRotation)aRotation); + iDestRect = aRect; + iRotation = (DirectGdi::TGraphicsRotation)aRotation; + } + +void CTestWsGraphicsContext::DrawResource(const TAny* aSource, const TRect& aRectDest, const TRect& aRectSrc, CWindowGc::TGraphicsRotation aRotation) + { + const RDirectGdiDrawableSource* drawableSource = static_cast(aSource); + iContext->DrawResource(aRectDest, *drawableSource, aRectSrc, (DirectGdi::TGraphicsRotation)aRotation); + iDestRect = aRectDest; + iSrcRect = aRectSrc; + iRotation = (DirectGdi::TGraphicsRotation)aRotation; + } + +void CTestWsGraphicsContext::DrawResource(const TAny* aSource, const TRect& aRect, const TDesC8& aParam) + { + const RDirectGdiDrawableSource* drawableSource = static_cast(aSource); + iContext->DrawResource(aRect, *drawableSource, aParam); + iDestRect = aRect; + } + + +void CTestWsGraphicsContext::Clear() + { + iContext->Clear(); + } + +// +// class CTDrawResource +// + +CTDrawResource::CTDrawResource(CTestStep* aStep) + : CTWsGraphicsBase(aStep) + { + } + +CTDrawResource::~CTDrawResource() + { + iWindow.Close(); + delete iRefBitmap; + delete iRotatedRefBitmap; + delete iScaledBitmap; + delete iScaledCroppedBitmap; + delete iCopyBitmap; + delete iBitmapWrongScreenNumber; + + delete iWsGrapicResolver; + delete iGraphicsCon; + + iWsDrawableSource.Close(); + iImage.Close(); + iImageTarget.Close(); + iImageCollection.Close(); + + CDirectGdiDriver* dGdiDriver = CDirectGdiDriver::Static(); + if(dGdiDriver) + { + dGdiDriver->Close(); + } + SgDriver::Close(); + } + +void CTDrawResource::ConstructL() + { + //Constrcut and setup window to be drawn to + iWindow = RWindow(TheClient->iWs); + User::LeaveIfError(iWindow.Construct(*TheClient->iGroup->GroupWin(),ENullWsHandle)); + TSize iWinSize=TSize(TheClient->iScreen->SizeInPixels()); + iWindow.SetExtent(TPoint(0,0),iWinSize); + iWindow.Activate(); + iWindow.BeginRedraw(); + iWindow.EndRedraw(); + + //Creates all reference and copy bitmaps required for all tests + CreateReferenceAndCopyBitmapsL(); + + TInt err = CDirectGdiDriver::Open(); + User::LeaveIfError(err); + err = SgDriver::Open(); + User::LeaveIfError(err); + + //create image target + CDirectGdiDriver* theDGdiDriver = CDirectGdiDriver::Static(); + if(!theDGdiDriver) + { + User::Leave(KErrNotReady); + } + TSgImageInfo info; + info.iUsage = ESgUsageDirectGdiTarget | ESgUsageDirectGdiSource | ESgUsageCompositionSource; + info.iPixelFormat = EUidPixelFormatRGB_565; + info.iSizeInPixels = TSize(200, 200); + info.iShareable = ETrue; + const TInt KImageCount = 1; + err = iImageCollection.Create(info, KImageCount); + User::LeaveIfError(err); + + err = iImageCollection.OpenImage(0, iImage); + User::LeaveIfError(err); + iImageTarget = RDirectGdiImageTarget(*theDGdiDriver); + err = iImageTarget.Create(iImage); + User::LeaveIfError(err); + + // construction of image source + RSgImage sgImage; + CreateSgImageFromBitmapL(sgImage); + CleanupClosePushL(sgImage); + iWsDrawableSource = RWsDrawableSource(TheClient->iWs); + User::LeaveIfError(iWsDrawableSource.Create(sgImage, TheClient->iScreen->GetScreenNumber())); + + //Create dummy MWsGraphicResolver - required RemoteGc testing + iWsGrapicResolver = new (ELeave) CWSGraphicsRes(); + + //Create dummy MWsGraphicsContext - required RemoteGc testing + iGraphicsCon = CTestWsGraphicsContext::NewL(iImageTarget); + + CleanupStack::PopAndDestroy(&sgImage); + } + +void CTDrawResource::RunTestCaseL(TInt aCurTestCase) + { + ((CTDrawResourceStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); + switch(aCurTestCase) + { + case 1: + ((CTDrawResourceStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-DRAWRESOURCE-0001")); + INFO_PRINTF1(_L("DrawResourcePos Test")); + TestDrawResourcePos(); + break; + case 2: + ((CTDrawResourceStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-DRAWRESOURCE-0002")); + INFO_PRINTF1(_L("DrawResourceRect Test")); + TestDrawResourceRect(); + break; + case 3: + ((CTDrawResourceStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-DRAWRESOURCE-0003")); + INFO_PRINTF1(_L("DrawResourceScale Test")); + TestDrawResourceScale(); + break; + case 4: + ((CTDrawResourceStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-DRAWRESOURCE-0004")); + INFO_PRINTF1(_L("RWsDrawableSource Reference Counting Test")); + TestRWsDrawableSourceReferenceCountingL(); + break; + case 5: + ((CTDrawResourceStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-DRAWRESOURCE-0005")); + INFO_PRINTF1(_L("RemoteGcDrawResourcePos Test")); + TestRemoteGcDrawResourcePosL(); + break; + case 6: + ((CTDrawResourceStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-DRAWRESOURCE-0006")); + INFO_PRINTF1(_L("RemoteGcDrawResourceRect Test")); + TestRemoteGcDrawResourceRectL(); + break; + case 7: + ((CTDrawResourceStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-DRAWRESOURCE-0007")); + INFO_PRINTF1(_L("RemoteGcDrawResourceScale Test")); + TestRemoteGcDrawResourceScaleL(); + break; + case 8: + ((CTDrawResourceStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-DRAWRESOURCE-0008")); + INFO_PRINTF1(_L("DrawResourceScreens Test")); + TestDrawResourceScreensL(); + break; + case 9: + ((CTDrawResourceStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-TestCopyScreenToBitmapWithDifferentDisplayModes-0001")); + INFO_PRINTF1(_L("CopyScreenToBitmapWithDifferentDisplayModes Test\n")); + TestCopyScreenToBitmapWithDifferentDisplayModesL(); + break; + case 10: + ((CTDrawResourceStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + ((CTDrawResourceStep*)iStep)->CloseTMSGraphicsStep(); + INFO_PRINTF1(_L("Test complete\n")); + TestComplete(); + break; + } + ((CTDrawResourceStep*)iStep)->RecordTestResultL(); + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-DRAWRESOURCE-0001 +@SYMPREQ PREQ2095 +@SYMTestPriority High +@SYMTestCaseDesc Draw RSgImage using DrawResource(const TPoint&, const RWsDrawableSource&, TGraphicsRotation) +@SYMTestActions Draw to position (0,0) with default rotation (none) + Draw to position (10,10) with 90 degrees rotation +@SYMTestExpectedResults Drawn images should match reference CFbsBitmap +*/ +void CTDrawResource::TestDrawResourcePos() + { + // Draw to TPoint(0,0) with EGraphicsRotationNone + iWindow.BeginRedraw(); + TheGc->Activate(iWindow); + TheGc->Clear(); + MWsDrawResource* dr = static_cast(TheGc->Interface(KMWsDrawResourceInterfaceUid)); + TEST(dr != NULL); + dr->DrawResource(KDestPoint, iWsDrawableSource, CWindowGc::EGraphicsRotationNone); + TheGc->Deactivate(); + iWindow.EndRedraw(); + TheClient->iWs.Finish(); + TheClient->WaitForRedrawsToFinish(); + + //Copy the screen to the copy bitmap + TheClient->iScreen->CopyScreenToBitmap(iCopyBitmap, KCopyTestRect); + + //Compare the bitmaps + INFO_PRINTF1(_L("Draw to TPoint(0,0) with EGraphicsRotationNone")); + TBool compRes = CompareBitmapsByPixel(iCopyBitmap, iRefBitmap); + TEST(compRes); + + /*** Draw to position (10,10) with 90 degrees rotation ***/ + TPoint const KDestPoint2(10,10); + iWindow.BeginRedraw(); + TheGc->Activate(iWindow); + TheGc->Clear(); + dr->DrawResource(KDestPoint2, iWsDrawableSource, KTestRotation); + TheGc->Deactivate(); + iWindow.EndRedraw(); + TheClient->iWs.Finish(); + TheClient->WaitForRedrawsToFinish(); + + //Copy the screen to the copy bitmap + TheClient->iScreen->CopyScreenToBitmap(iCopyBitmap, TRect(KDestPoint2, KSourceSize)); + + //Compare the bitmaps + INFO_PRINTF1(_L("Draw to position (10,10) with 90 degrees rotation")); + compRes = CompareBitmapsByPixel(iCopyBitmap, iRotatedRefBitmap); + TEST(compRes); + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-DRAWRESOURCE-0002 +@SYMPREQ PREQ2095 +@SYMTestPriority High +@SYMTestCaseDesc Draw RSgImage using DrawResource(const TRect& , const RWsDrawableSource&, TGraphicsRotation aRotation) +@SYMTestActions Draw to rect pos (10,10), rect size (60,60) with 90 degrees rotation +@SYMTestExpectedResults Drawn images should match the reference CFbsBitmap +*/ +void CTDrawResource::TestDrawResourceRect() + { + //Use DrawResource + iWindow.BeginRedraw(); + TheGc->Activate(iWindow); + TheGc->Clear(); + MWsDrawResource* dr = static_cast(TheGc->Interface(KMWsDrawResourceInterfaceUid)); + TEST(dr != NULL); + dr->DrawResource(KDestRect, iWsDrawableSource, KTestRotation); + TheGc->Deactivate(); + iWindow.EndRedraw(); + TheClient->iWs.Finish(); + TheClient->WaitForRedrawsToFinish(); + + //Copy the screen to the copy bitmap + TheClient->iScreen->CopyScreenToBitmap(iCopyBitmap, KCopyTestRect); + + //Compare the bitmaps + INFO_PRINTF1(_L("Draw to rect pos (10,10), rect size (60,60) with 90 degrees rotation")); + TInt compRes = CompareBitmapsByPixel(iCopyBitmap, iScaledBitmap); + TEST(compRes); + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-DRAWRESOURCE-0003 +@SYMPREQ PREQ2095 +@SYMTestPriority High +@SYMTestCaseDesc Draw RSgImage using DrawResource(const TRect& , const RWsDrawableSource&, const TRect&, TGraphicsRotation aRotation) +@SYMTestActions Draw the part of the source image (rect Pos (0,0), rect size(50,50)) + to rect pos(10,10), rect size(60,60) and and 90 degrees rotation +@SYMTestExpectedResults Drawn images should match the reference CFbsBitmap +*/ +void CTDrawResource::TestDrawResourceScale() + { + //Use DrawResource + iWindow.BeginRedraw(); + TheGc->Activate(iWindow); + TheGc->Clear(); + MWsDrawResource* dr = static_cast(TheGc->Interface(KMWsDrawResourceInterfaceUid)); + TEST(dr != NULL); + dr->DrawResource(KDestRect, iWsDrawableSource, KSourceRect, KTestRotation); + TheGc->Deactivate(); + iWindow.EndRedraw(); + TheClient->iWs.Finish(); + TheClient->WaitForRedrawsToFinish(); + + //Copy the screen to the copy bitmap + TheClient->iScreen->CopyScreenToBitmap(iCopyBitmap, KCopyTestRect); + + //Compare the bitmaps + INFO_PRINTF1(_L("Draw the part of the source image to rect pos(10,10), rect size(60,60) and and 90 degrees rotation")); + TInt compRes = CompareBitmapsByPixel(iCopyBitmap, iScaledCroppedBitmap); + TEST(compRes); + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-DRAWRESOURCE-0004 +@SYMPREQ PREQ2095 +@SYMTestPriority High +@SYMTestCaseDesc Draw RSgImage using DrawResource(const TPoint&, const RWsDrawableSource&, TGraphicsRotation) after closing the image source +@SYMTestActions Draw to position (0,0) with default rotation (none) after closing the image source +@SYMTestExpectedResults Drawn image should match reference CFbsBitmap +*/ +void CTDrawResource::TestRWsDrawableSourceReferenceCountingL() + { + // construction of image source + RSgImage sgImage; + CreateSgImageFromBitmapL(sgImage); + CleanupClosePushL(sgImage); + RWsDrawableSource drawableSource(TheClient->iWs); + CleanupClosePushL(drawableSource); + User::LeaveIfError(drawableSource.Create(sgImage, TheClient->iScreen->GetScreenNumber())); + + //Draw using DrawResource + iWindow.BeginRedraw(); + TheGc->Activate(iWindow); + TheGc->Clear(); + MWsDrawResource* dr = static_cast(TheGc->Interface(KMWsDrawResourceInterfaceUid)); + TEST(dr != NULL); + dr->DrawResource(KDestPoint, drawableSource, CWindowGc::EGraphicsRotationNone); + TheGc->Deactivate(); + iWindow.EndRedraw(); + + //Close the image source but this should not stop the source from being drawn + drawableSource.Close(); + TheClient->iWs.Finish(); + TheClient->WaitForRedrawsToFinish(); + + //Copy the screen to the copy bitmap + TheClient->iScreen->CopyScreenToBitmap(iCopyBitmap, KCopyTestRect); + + //Compare the bitmaps + INFO_PRINTF1(_L("Draw to TPoint(0,0) with EGraphicsRotationNone")); + TBool compRes = CompareBitmapsByPixel(iCopyBitmap, iRefBitmap); + TEST(compRes); + + CleanupStack::PopAndDestroy(2, &sgImage); + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-DRAWRESOURCE-0005 +@SYMPREQ PREQ2095 +@SYMTestPriority High +@SYMTestCaseDesc Draw RSgImage using RemotGc->DrawResource(const TPoint&, const RWsDrawableSource&, TGraphicsRotation) +@SYMTestActions Record the draw resource commands using CRemoteGc and play the recorded commands on a window using + Play(const TPoint&, const TRect&, RWsSession&, CWindowGc&) and then play the recorded commands using . + Play(const TPoint&, const TRect&, const MWsGraphicResolver&, MWsGraphicsContext&). +@SYMTestExpectedResults Drawn images should match reference CFbsBitmap and also values received by MWsGraphicsContext should + match what was originally sent to DrawResource. +*/ +void CTDrawResource::TestRemoteGcDrawResourcePosL() + { + const TRect KRemotGcSourceRect(0, 0, iWindow.Size().iWidth, iWindow.Size().iHeight); + const TRegionFix<1> KClippingRegion(KRemotGcSourceRect); + CWindowGc::TGraphicsRotation testRotation= CWindowGc::EGraphicsRotationNone; + + //Create remote gc - required RemoteGc testing + CRemoteGc* remoteGc = CRemoteGc::NewL(TheClient->iScreen); + CleanupStack::PushL(remoteGc); + + //Record draw messages + remoteGc->ResetCommandBuffer(); + remoteGc->BeginDraw(KRemotGcSourceRect); + MWsDrawResource* dr = static_cast(remoteGc->Interface(KMWsDrawResourceInterfaceUid)); + TEST(dr != NULL); + dr->DrawResource(KDestPoint, iWsDrawableSource, CWindowGc::EGraphicsRotationNone); + remoteGc->EndDraw(); + + RWsGraphicMsgBuf msgBuf; + CleanupClosePushL(msgBuf); + //Externalize the captured commands from remote gc in to a buffer + remoteGc->ExternalizeL(msgBuf, ETrue); + //Create command buffer - required RemoteGc testing + CCommandBuffer* cmdBuffer = CCommandBuffer::NewL(); + CleanupStack::PushL(cmdBuffer); + //Internalize the buffer with captured commands (from CRemoteGC) in to CCommandBuffer + cmdBuffer->InternalizeL(msgBuf.Pckg()); + + // Play stored commands using Play(const TPoint&, const TRect&, RWsSession&, CWindowGc&) + remoteGc->ResetCommandBuffer(); + iWindow.Invalidate(); + iWindow.BeginRedraw(); + TheGc->Activate(iWindow); + TheGc->Clear(); + cmdBuffer->Play(KPlayOffset, &KClippingRegion, KRemotGcSourceRect, TheClient->iWs, *TheGc); + TheGc->Deactivate(); + iWindow.EndRedraw(); + TheClient->iWs.Finish(); + TheClient->WaitForRedrawsToFinish(); + + //Copy the screen to the copy bitmap + TheClient->iScreen->CopyScreenToBitmap(iCopyBitmap, KCopyTestRect); + + //Compare the bitmaps + INFO_PRINTF1(_L("Using Play(const TPoint&, const TRect&, RWsSession&, CWindowGc&)")); + TBool compRes = CompareBitmapsByPixel(iCopyBitmap, iRefBitmap); + TEST(compRes); + + // Play stored commands using Play(const TPoint&, const TRect&, const MWsGraphicResolver&, MWsGraphicsContext&) + remoteGc->ResetCommandBuffer(); + iWindow.Invalidate(); + iWindow.BeginRedraw(); + TheGc->Activate(iWindow); + TheGc->Clear(); + cmdBuffer->Play(KPlayOffset,&KClippingRegion,KRemotGcSourceRect,*iWsGrapicResolver,*iGraphicsCon); + TheGc->Deactivate(); + iWindow.EndRedraw(); + TheClient->iWs.Finish(); + + //Compare the values received by CTestWsGraphicsContext and the values sent to it + INFO_PRINTF1(_L("Using Play(const TPoint&, const TRect&, const MWsGraphicResolver&, MWsGraphicsContext&)")); + TBool valuesSame = EFalse; + CFbsBitmap* bmp; + BitmapLC(bmp); + compRes = CompareBitmapsByPixel(bmp, iRefBitmap); + CleanupStack::PopAndDestroy(bmp); + + if((iGraphicsCon->iPos == KDestPoint) && (compRes) + && (reinterpret_cast(iGraphicsCon->iRotation)==reinterpret_cast(testRotation))) + valuesSame = ETrue; + TEST(valuesSame); + CleanupStack::PopAndDestroy(3, remoteGc); + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-DRAWRESOURCE-0006 +@SYMPREQ PREQ2095 +@SYMTestPriority High +@SYMTestCaseDesc Draw RSgImage using RemotGc->DrawResource(const TRect&, const RWsDrawableSource&, TGraphicsRotation) +@SYMTestActions Record the draw resource commands using CRemoteGc and play the recorded commands on a window using + Play(const TPoint&, const TRect&, RWsSession&, CWindowGc&) and then play the recorded commands using . + Play(const TPoint&, const TRect&, const MWsGraphicResolver&, MWsGraphicsContext&). +@SYMTestExpectedResults Drawn images should match reference CFbsBitmap and also values received by MWsGraphicsContext should + match what was originally sent to DrawResource. +*/ +void CTDrawResource::TestRemoteGcDrawResourceRectL() + { + const TRect KRemotGcSourceRect(0, 0, iWindow.Size().iWidth, iWindow.Size().iHeight); + const TRegionFix<1> KClippingRegion(KRemotGcSourceRect); + + //Create remote gc - required RemoteGc testing + CRemoteGc* remoteGc = CRemoteGc::NewL(TheClient->iScreen); + CleanupStack::PushL(remoteGc); + + //Record draw messages + remoteGc->BeginDraw(KRemotGcSourceRect); + MWsDrawResource* dr = static_cast(remoteGc->Interface(KMWsDrawResourceInterfaceUid)); + TEST(dr != NULL); + dr->DrawResource(KDestRect, iWsDrawableSource, KTestRotation); + remoteGc->EndDraw(); + + RWsGraphicMsgBuf msgBuf; + CleanupClosePushL(msgBuf); + //Externalize the captured commands from remote gc in to a buffer + remoteGc->ExternalizeL(msgBuf, ETrue); + + //Create command buffer - required RemoteGc testing + CCommandBuffer* cmdBuffer = CCommandBuffer::NewL(); + CleanupStack::PushL(cmdBuffer); + //Internalize the buffer with captured commands (from CRemoteGC) in to CCommandBuffer + cmdBuffer->InternalizeL(msgBuf.Pckg()); + + // Play stored commands using Play(const TRect&, const TRect&, RWsSession&, CWindowGc&) + iWindow.Invalidate(); + iWindow.BeginRedraw(); + TheGc->Activate(iWindow); + TheGc->Clear(); + cmdBuffer->Play(KPlayOffset, &KClippingRegion, KRemotGcSourceRect, TheClient->iWs, *TheGc); + TheGc->Deactivate(); + iWindow.EndRedraw(); + TheClient->iWs.Finish(); + TheClient->WaitForRedrawsToFinish(); + + //Copy the screen to the copy bitmap + TheClient->iScreen->CopyScreenToBitmap(iCopyBitmap, KCopyTestRect); + + //Compare the bitmaps + INFO_PRINTF1(_L("Using Play(const TPoint&, const TRect&, RWsSession&, CWindowGc&)")); + TBool compRes = CompareBitmapsByPixel(iCopyBitmap, iScaledBitmap); + TEST(compRes); + + // Play stored commands using Play(const TPoint&, const TRect&, const MWsGraphicResolver&, MWsGraphicsContext&) + iWindow.Invalidate(); + iWindow.BeginRedraw(); + TheGc->Activate(iWindow); + TheGc->Clear(); + iGraphicsCon->Clear(); + cmdBuffer->Play(KPlayOffset,&KClippingRegion,KRemotGcSourceRect,*iWsGrapicResolver,*iGraphicsCon); + TheGc->Deactivate(); + iWindow.EndRedraw(); + TheClient->iWs.Finish(); + TheClient->WaitForRedrawsToFinish(); + + //Compare the values received by CTestWsGraphicsContext and the values sent to it + INFO_PRINTF1(_L("Using Play(const TPoint&, const TRect&, const MWsGraphicResolver&, MWsGraphicsContext&)")); + TBool valuesSame = EFalse; + + CFbsBitmap* bmp; + BitmapLC(bmp); + compRes = CompareBitmapsByPixel(bmp, iScaledBitmap); + CleanupStack::PopAndDestroy(bmp); + + if((iGraphicsCon->iDestRect == KDestRect) && (compRes) + && (reinterpret_cast(iGraphicsCon->iRotation)==reinterpret_cast(KTestRotation))) + valuesSame = ETrue; + TEST(valuesSame); + CleanupStack::PopAndDestroy(3, remoteGc); + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-DRAWRESOURCE-0007 +@SYMPREQ PREQ2095 +@SYMTestPriority High +@SYMTestCaseDesc Draw RSgImage using RemotGc->DrawResource(const TRect&, const RWsDrawableSource&, const TRect&, TGraphicsRotation) +@SYMTestActions Record the draw resource commands using CRemoteGc and play the recorded commands on a window using + Play(const TPoint&, const TRect&, RWsSession&, CWindowGc&) and then play the recorded commands using . + Play(const TPoint&, const TRect&, const MWsGraphicResolver&, MWsGraphicsContext&). +@SYMTestExpectedResults Drawn images should match reference CFbsBitmap and also values received by MWsGraphicsContext should + match what was originally sent to DrawResource. +*/ +void CTDrawResource::TestRemoteGcDrawResourceScaleL() + { + const TRect KRemotGcSourceRect(0, 0, iWindow.Size().iWidth, iWindow.Size().iHeight); + const TRegionFix<1> KClippingRegion(KRemotGcSourceRect); + + //Create remote gc - required RemoteGc testing + CRemoteGc* remoteGc = CRemoteGc::NewL(TheClient->iScreen); + CleanupStack::PushL(remoteGc); + + //Record draw messages + remoteGc->BeginDraw(KRemotGcSourceRect); + MWsDrawResource* dr = static_cast(remoteGc->Interface(KMWsDrawResourceInterfaceUid)); + TEST(dr != NULL); + dr->DrawResource(KDestRect, iWsDrawableSource, KSourceRect, KTestRotation); + remoteGc->EndDraw(); + + RWsGraphicMsgBuf msgBuf; + CleanupClosePushL(msgBuf); + //Externalize the captured commands from remote gc in to a buffer + remoteGc->ExternalizeL(msgBuf, ETrue); + + //Create command buffer - required RemoteGc testing + CCommandBuffer* cmdBuffer = CCommandBuffer::NewL(); + CleanupStack::PushL(cmdBuffer); + //Internalize the buffer with captured commands (from CRemoteGC) in to CCommandBuffer + cmdBuffer->InternalizeL(msgBuf.Pckg()); + + // Play the stored commands using Play(const TRect&, const TRect&, RWsSession&, CWindowGc&) + remoteGc->ResetCommandBuffer(); + iWindow.Invalidate(); + iWindow.BeginRedraw(); + TheGc->Activate(iWindow); + TheGc->Clear(); + cmdBuffer->Play(KPlayOffset, &KClippingRegion, KRemotGcSourceRect, TheClient->iWs, *TheGc); + TheGc->Deactivate(); + iWindow.EndRedraw(); + TheClient->iWs.Finish(); + TheClient->WaitForRedrawsToFinish(); + //Copy the screen to the copy bitmap + TheClient->iScreen->CopyScreenToBitmap(iCopyBitmap, KCopyTestRect); + + //Compare the bitmaps + INFO_PRINTF1(_L("Using Play(const TPoint&, const TRect&, RWsSession&, CWindowGc&)")); + TBool compRes = CompareBitmapsByPixel(iCopyBitmap, iScaledCroppedBitmap); + TEST(compRes); + + // Play the stored commands using Play(const TPoint&, const TRect&, const MWsGraphicResolver&, MWsGraphicsContext&) + iWindow.Invalidate(); + iWindow.BeginRedraw(); + TheGc->Activate(iWindow); + TheGc->Clear(); + iGraphicsCon->Clear(); + cmdBuffer->Play(KPlayOffset,&KClippingRegion,KRemotGcSourceRect,*iWsGrapicResolver,*iGraphicsCon); + TheGc->Deactivate(); + iWindow.EndRedraw(); + TheClient->iWs.Finish(); + TheClient->WaitForRedrawsToFinish(); + + //Compare the values received by CTestWsGraphicsContext and the values sent to it + INFO_PRINTF1(_L("Using Play(const TPoint&, const TRect&, const MWsGraphicResolver&, MWsGraphicsContext&)")); + TBool valuesSame = EFalse; + + CFbsBitmap* bmp; + BitmapLC(bmp); + compRes = CompareBitmapsByPixel(bmp, iScaledCroppedBitmap); + CleanupStack::PopAndDestroy(bmp); + + if((iGraphicsCon->iDestRect == KDestRect) && (compRes) && (iGraphicsCon->iSrcRect == KSourceRect) + && (reinterpret_cast(iGraphicsCon->iRotation)==reinterpret_cast(KTestRotation))) + valuesSame = ETrue; + TEST(valuesSame); + CleanupStack::PopAndDestroy(3, remoteGc); + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-DRAWRESOURCE-0008 +@SYMPREQ PREQ2095 +@SYMTestPriority High +@SYMTestCaseDesc Negative testing. Draw graphics recourses which associated with different screens. +@SYMTestActions Open RWsDrawableSource associated with the screen which doesn’ exist. + Open RWsDrawableSource associated with the screen which exists but differes from drawing target. + Draw Rectangle and Resource to the screen via CWindowGc + Draw Rectangle and Resource to the screen via CRemoteGc +@SYMTestExpectedResults Opening drawable resource on the screen which doesn’t exist must fail with error code KErrArgument + Drawing primitives will result only rectangles be drawn as drawable recourses get associated with different screen +*/ +void CTDrawResource::TestDrawResourceScreensL() + { + TInt numOfScreens = TheClient->iWs.NumberOfScreens(); + if(numOfScreens < 2) + { + INFO_PRINTF2(_L("This test case will be running if the number of available screens more than 1, current number is %d"), numOfScreens); + return; + } + TInt screenNumber = TheClient->iScreen->GetScreenNumber(); + TInt differentScreen = (screenNumber == 0) ? 1 : 0; + + RSgImage sgImage; + CreateSgImageFromBitmapL(sgImage); + CleanupClosePushL(sgImage); + + RWsDrawableSource drawableSource(TheClient->iWs); + TInt res = drawableSource.Create(sgImage, differentScreen + 200); //wrong screen number + TEST(res == KErrArgument); + + res = drawableSource.Create(iImage, differentScreen); + TEST(res == KErrNotSupported); //in order to succeed the image must be created with flag usage ESgUsageWindowGcSource + + TSgImageInfo info; + User::LeaveIfError(sgImage.GetInfo(info)); + + res = drawableSource.Create(sgImage, differentScreen); + if(res == KErrNotSupported) + { + INFO_PRINTF1(_L("The second screen is not supports drawable source. This test case terminates now.")); + CleanupStack::PopAndDestroy(&sgImage); + return; + } + TEST(res == KErrNone); + User::LeaveIfError(res); + CleanupClosePushL(drawableSource); + + iWindow.BeginRedraw(); + TheGc->Activate(iWindow); + TheGc->Clear(); + TheGc->SetBrushStyle(CFbsBitGc::ESolidBrush); + TheGc->SetPenStyle(CFbsBitGc::ENullPen); + TheGc->SetBrushColor(KRgbGreen); + TheGc->DrawRect(TRect(KDestPoint, info.iSizeInPixels)); + // Draw to TPoint(0,0) with EGraphicsRotationNone but to the different screen + MWsDrawResource* winDr = static_cast(TheGc->Interface(KMWsDrawResourceInterfaceUid)); + TEST(winDr != NULL); + winDr->DrawResource(KDestPoint, drawableSource, CWindowGc::EGraphicsRotationNone); + TheGc->Deactivate(); + iWindow.EndRedraw(); + TheClient->iWs.Finish(); + TheClient->WaitForRedrawsToFinish(); + + //Copy the screen to the copy bitmap + TheClient->iScreen->CopyScreenToBitmap(iCopyBitmap, KCopyTestRect); + + //Compare the bitmaps + INFO_PRINTF1(_L("Draw to TPoint(0,0) with EGraphicsRotationNone but to different screen")); + TBool compRes = CompareBitmapsByPixel(iCopyBitmap, iBitmapWrongScreenNumber); + TEST(compRes); + + //--------------------------- remoteGc + const TRect KRemotGcSourceRect(0, 0, iWindow.Size().iWidth, iWindow.Size().iHeight); + const TRegionFix<1> KClippingRegion(KRemotGcSourceRect); + + //Create remote gc - required RemoteGc testing + CRemoteGc* remoteGc = CRemoteGc::NewL(TheClient->iScreen); + CleanupStack::PushL(remoteGc); + + //Record draw messages + remoteGc->BeginDraw(KRemotGcSourceRect); + remoteGc->SetBrushStyle(CFbsBitGc::ESolidBrush); + remoteGc->SetPenStyle(CFbsBitGc::ENullPen); + remoteGc->SetBrushColor(KRgbGreen); + remoteGc->DrawRect(TRect(KDestPoint, info.iSizeInPixels)); + MWsDrawResource* remDr = static_cast(remoteGc->Interface(KMWsDrawResourceInterfaceUid)); + TEST(remDr != NULL); + remDr->DrawResource(KDestRect, drawableSource, CWindowGc::EGraphicsRotationNone); + remoteGc->EndDraw(); + + RWsGraphicMsgBuf msgBuf; + CleanupClosePushL(msgBuf); + //Externalize the captured commands from remote gc in to a buffer + remoteGc->ExternalizeL(msgBuf, ETrue); + + //Create command buffer - required RemoteGc testing + CCommandBuffer* cmdBuffer = CCommandBuffer::NewL(); + CleanupStack::PushL(cmdBuffer); + //Internalize the buffer with captured commands (from CRemoteGC) in to CCommandBuffer + cmdBuffer->InternalizeL(msgBuf.Pckg()); + + // Play stored commands using Play(const TRect&, const TRect&, RWsSession&, CWindowGc&) + iWindow.Invalidate(); + iWindow.BeginRedraw(); + TheGc->Activate(iWindow); + TheGc->Clear(); + cmdBuffer->Play(KPlayOffset, &KClippingRegion, KRemotGcSourceRect, TheClient->iWs, *TheGc); + TheGc->Deactivate(); + iWindow.EndRedraw(); + TheClient->iWs.Finish(); + TheClient->WaitForRedrawsToFinish(); + + //Copy the screen to the copy bitmap + TheClient->iScreen->CopyScreenToBitmap(iCopyBitmap, KCopyTestRect); + + INFO_PRINTF1(_L("Draw to TPoint(0,0) with EGraphicsRotationNone but to different screen")); + TBool compRes1 = CompareBitmapsByPixel(iCopyBitmap, iBitmapWrongScreenNumber); + TEST(compRes1); + + CleanupStack::PopAndDestroy(5, &sgImage); + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-TestCopyScreenToBitmapWithDifferentDisplayModes-0001 +@SYMPREQ PREQ2095 +@SYMTestPriority High +@SYMTestCaseDesc Get bitmap and scanline from the screen. +@SYMTestActions Draw bitmap in various display modes to the screen. + Retrieve scan line and bitmap from the screen using standard WSERV API. + +@SYMTestExpectedResults Checks that obtained bitmap matches with the reference bitmap. +*/ +void CTDrawResource::TestCopyScreenToBitmapWithDifferentDisplayModesL() + { + TDisplayMode mode = TheClient->iScreen->DisplayMode(); + INFO_PRINTF2(_L("Screen display mode %d"), mode); + CFbsBitmap* bitmap = NULL; + + TSize bitmapSize(163, 120); + CreateBitmapLC(bitmap, bitmapSize, mode); + + iWindow.BeginRedraw(); + TheGc->Activate(iWindow); + TheGc->SetBrushStyle(CWindowGc::ESolidBrush); + TheGc->SetBrushColor(KRgbYellow); + TheGc->Clear(); + const TPoint ptOffset(10, 15); + TheGc->BitBlt(KDestPoint + ptOffset, bitmap); + + TheGc->Deactivate(); + iWindow.EndRedraw(); + TheClient->iWs.Finish(); + TheClient->WaitForRedrawsToFinish(); + + const TInt length = bitmapSize.iWidth; + const TInt height = bitmapSize.iHeight; + const TInt buffersSize = length * 4; + TUint8 *screenData = (TUint8*) User::AllocL(buffersSize); + CleanupStack::PushL(screenData); + TUint8 *bitmapData = (TUint8*) User::AllocL(buffersSize); + CleanupStack::PushL(bitmapData); + TPtr8 ptrScreen (screenData, buffersSize, buffersSize); + TPtr8 ptrBitmap (bitmapData, buffersSize, buffersSize); + + //EGray mode uses dithering in BitGdi, wserv doesnt support this, thus skipping the first mode + for(TInt ii =2; ; ii++) + { + TDisplayMode dispMode = (TDisplayMode)ii; + if(dispMode >= EColorLast) + break; + if(dispMode == ERgb) + continue; + + INFO_PRINTF2(_L("Copy Screen to bitmap, destination mode %d"), dispMode); + + CFbsBitmap *bmp = new (ELeave) CFbsBitmap; + CleanupStack::PushL(bmp); + User::LeaveIfError(bmp->Create(bitmapSize, dispMode)); + TUidPixelFormat pixelFormat = SgUtils::DisplayModeToPixelFormat(dispMode); + const TInt minStride = SgUtils::MinDataStride(length, pixelFormat); + const TInt bitmapStride = bmp->DataStride(); + TEST(minStride <= bitmapStride); + + //Copy the screen to the copy bitmap + TRect rc = bitmapSize; + rc.Move(ptOffset); + TheClient->iScreen->CopyScreenToBitmap(bmp, rc); + CFbsBitmap *bmpRef = NULL; + CreateReferenceBitmapLC(bmpRef, bitmap, dispMode); + TEST(bmpRef->DisplayMode() == dispMode); + + //Compare the bitmaps + TBool compRes = CompareBitmapsByPixel(bmp, bmpRef); + TEST(compRes); + + for(TInt jj = 0; jj < height; jj++) + { + TPoint pt(0, jj); + TPoint ptScreen = pt + ptOffset; + + Mem::Fill(screenData, bitmapStride, 0xff); + Mem::Fill(bitmapData, bitmapStride, 0xff); + + TheClient->iScreen->GetScanLine(ptrScreen, ptScreen, length, dispMode); + bitmap->GetScanLine(ptrBitmap, pt, length, dispMode); + TInt length1 = ptrScreen.Length(); + + TInt res = Mem::Compare(screenData, length1, bitmapData, length1); + TEST(res == 0); + } + CleanupStack::PopAndDestroy(2, bmp); + }//screen modes; + + CleanupStack::PopAndDestroy(3, bitmap); + } + +//Helper function: Creates reference bitmap with specified display mode +void CTDrawResource::CreateReferenceBitmapLC(CFbsBitmap*& aBmpTarget, CFbsBitmap* aBmpSrc, TDisplayMode aDestMode) + { + TSize size = aBmpSrc->SizeInPixels(); + aBmpTarget = new (ELeave) CFbsBitmap; + CleanupStack::PushL(aBmpTarget); + User::LeaveIfError(aBmpTarget->Create(size, aDestMode)); + CFbsBitmapDevice *refBitmapDev = CFbsBitmapDevice::NewL(aBmpTarget); + CleanupStack::PushL(refBitmapDev); + CFbsBitGc *originalBitGc; + User::LeaveIfError(refBitmapDev->CreateContext(originalBitGc)); + CleanupStack::PushL(originalBitGc); + originalBitGc->BitBlt(TPoint(0,0), aBmpSrc); + CleanupStack::PopAndDestroy(2, refBitmapDev); + } + +//Helper function: Creates reference bitmap with specified display mode +void CTDrawResource::CreateBitmapLC(CFbsBitmap*& aBmpTarget, const TSize& aSize, TDisplayMode aDispMode) const + { + aBmpTarget = new (ELeave) CFbsBitmap; + CleanupStack::PushL(aBmpTarget); + User::LeaveIfError(aBmpTarget->Create(aSize, aDispMode)); + CFbsBitmapDevice *refBitmapDev = CFbsBitmapDevice::NewL(aBmpTarget); + CleanupStack::PushL(refBitmapDev); + CFbsBitGc *originalBitGc; + User::LeaveIfError(refBitmapDev->CreateContext(originalBitGc)); + CleanupStack::PushL(originalBitGc); + + TRect rect = TRect(aSize); + rect.Shrink(21, 15); + + originalBitGc->SetBrushStyle(CFbsBitGc::ESolidBrush); + originalBitGc->SetBrushColor(TRgb(0,150,150)); + originalBitGc->DrawRect(TRect(TPoint(0,0), TSize(aSize.iWidth, aSize.iHeight / 2))); + originalBitGc->SetBrushColor(TRgb(150,100,150)); + originalBitGc->DrawRect(TRect(TPoint(0,aSize.iHeight / 2), TSize(aSize.iWidth, aSize.iHeight))); + + originalBitGc->SetBrushColor(TRgb(0,0,128)); + originalBitGc->DrawRect(rect); + + + CleanupStack::PopAndDestroy(2, refBitmapDev); + } + +//Helper function: Creates a RSgImage from a bitmap +void CTDrawResource::CreateSgImageFromBitmapL(RSgImage& aSgImage) + { + TUint32* data = iRefBitmap->DataAddress(); + TInt stride = iRefBitmap->DataStride(); + TSize size = iRefBitmap->SizeInPixels(); + + TSgImageInfo info; + info.iSizeInPixels = size; + info.iScreenId = TheClient->iScreen->CurrentScreenMode(); + info.iShareable = ETrue; //must be shareable since wserv is in other process + info.iUsage = ESgUsageWindowGcSource; + info.iPixelFormat = SgUtils::DisplayModeToPixelFormat(iRefBitmap->DisplayMode()); + + User::LeaveIfError(aSgImage.Create(info, data, stride)); + } + +//Helper function: Creates all reference bitmaps required for all tests +void CTDrawResource::CreateReferenceAndCopyBitmapsL() + { + //Create reference bitmap + iRefBitmap = new (ELeave) CFbsBitmap(); + User::LeaveIfError(iRefBitmap->Create(TSize(160,120),EColor64K)); + + //Setup to draw to original reference bitmap + CFbsBitmapDevice *refBitmapDev = CFbsBitmapDevice::NewL(iRefBitmap); + CleanupStack::PushL(refBitmapDev); + CFbsBitGc *originalBitGc; + User::LeaveIfError(refBitmapDev->CreateContext(originalBitGc)); + CleanupStack::PushL(originalBitGc); + + //Draw to reference bitmap + originalBitGc->SetBrushStyle(CFbsBitGc::ESolidBrush); + originalBitGc->SetBrushColor(TRgb(0,150,150)); + originalBitGc->DrawRect(TRect(TPoint(0,0), TSize(160,60))); + originalBitGc->SetBrushColor(TRgb(150,100,150)); + originalBitGc->DrawRect(TRect(TPoint(0,60), TSize(160,60))); + + //create a rotated version of the reference bitmap + iRotatedRefBitmap = new (ELeave) CFbsBitmap(); + User::LeaveIfError(iRotatedRefBitmap->Create(TSize(120,160),EColor64K)); + + //Setup to draw to rotated reference bitmap + CFbsBitmapDevice *rotRefBitmapDev = CFbsBitmapDevice::NewL(iRotatedRefBitmap); + CleanupStack::PushL(rotRefBitmapDev); + CFbsBitGc *rotatedBitGc; + User::LeaveIfError(rotRefBitmapDev->CreateContext(rotatedBitGc)); + CleanupStack::PushL(rotatedBitGc); + + //Draw to rotated reference bitmap + rotatedBitGc->SetBrushStyle(CFbsBitGc::ESolidBrush); + rotatedBitGc->SetBrushColor(TRgb(0,150,150)); + rotatedBitGc->DrawRect(TRect(TPoint(60,0), TSize(60,160))); + rotatedBitGc->SetBrushColor(TRgb(150,100,150)); + rotatedBitGc->DrawRect(TRect(TPoint(0,0), TSize(60,160))); + + //Prepare a scaled version of the rotated reference bitmap to later compare against + iScaledBitmap = new (ELeave) CFbsBitmap(); + User::LeaveIfError(iScaledBitmap->Create(TSize(160,120),EColor64K)); + //Setup to draw to bitmap + CFbsBitmapDevice *scaledBitDev = CFbsBitmapDevice::NewL(iScaledBitmap); + CleanupStack::PushL(scaledBitDev); + CFbsBitGc *scaledBitGc; + User::LeaveIfError(scaledBitDev->CreateContext(scaledBitGc)); + CleanupStack::PushL(scaledBitGc); + //Draw the rotated reference bitmap scaled + scaledBitGc->DrawBitmap(KDestRect, iRotatedRefBitmap); + + //Prepare a scaled version of the rotated reference bitmap to later compare against + iScaledCroppedBitmap = new (ELeave) CFbsBitmap(); + User::LeaveIfError(iScaledCroppedBitmap->Create(TSize(160,120),EColor64K)); + + //Setup to draw to bitmap + CFbsBitmapDevice *scaledCroppedBitDev = CFbsBitmapDevice::NewL(iScaledCroppedBitmap); + CleanupStack::PushL(scaledCroppedBitDev); + CFbsBitGc *scaledCroppedBitGc; + User::LeaveIfError(scaledCroppedBitDev->CreateContext(scaledCroppedBitGc)); + CleanupStack::PushL(scaledCroppedBitGc); + + //Draw the rotated reference bitmap scaled + TInt width = iRotatedRefBitmap->SizeInPixels().iWidth; + TInt height = iRotatedRefBitmap->SizeInPixels().iHeight; + + TRect rectSrc; + rectSrc.iTl.iX= width - KSourceRect.Height(); + rectSrc.iTl.iY= 0; + rectSrc.iBr.iX= width; + rectSrc.iBr.iY= KSourceRect.Width(); + + scaledCroppedBitGc->DrawBitmap(KDestRect, iRotatedRefBitmap, rectSrc); + + //Prepare bitmap for testing drawable which opened with different screen number + iBitmapWrongScreenNumber = new (ELeave) CFbsBitmap(); + User::LeaveIfError(iBitmapWrongScreenNumber->Create(TSize(160,120),EColor64K)); + //Setup to draw to bitmap + CFbsBitmapDevice *wrongScreenNumberBitDev = CFbsBitmapDevice::NewL(iBitmapWrongScreenNumber); + CleanupStack::PushL(wrongScreenNumberBitDev); + CFbsBitGc *wrongScreenNumberBitGc; + User::LeaveIfError(wrongScreenNumberBitDev->CreateContext(wrongScreenNumberBitGc)); + CleanupStack::PushL(wrongScreenNumberBitGc); + //Draw the rotated reference bitmap scaled + wrongScreenNumberBitGc->SetBrushColor(KRgbGreen); + wrongScreenNumberBitGc->SetBrushStyle(CFbsBitGc::ESolidBrush); + wrongScreenNumberBitGc->SetPenStyle(CFbsBitGc::ENullPen); + wrongScreenNumberBitGc->DrawRect(TRect(0, 0, 160, 120)); // + + //Create a bitmap to copy to with the same display mode as the reference bitmap + iCopyBitmap = new (ELeave) CFbsBitmap(); + User::LeaveIfError(iCopyBitmap->Create(TSize(640,240),EColor64K)); + + CleanupStack::PopAndDestroy(10, refBitmapDev); + } + +//Helper function: This function compares two bitmaps on a pixel by pixel basis */ +TBool CTDrawResource::CompareBitmapsByPixel(CFbsBitmap* aCandidateBitmap, CFbsBitmap* aReferenceBitmap) + { + TBool result = ETrue; + + TSize candidateSize = aCandidateBitmap->SizeInPixels(); + TSize referenceSize = aReferenceBitmap->SizeInPixels(); + + TInt mismatchedPixels = 0; + + TRgb nativePixel; + TRgb referencePixel; + for (TInt x = 0; x < referenceSize.iWidth; x++) + { + for (TInt y = 0; y < referenceSize.iHeight; y++) + { + TPoint point(x,y); + nativePixel = TRgb(0,0,0,0); + referencePixel = TRgb(0,0,0,0); + aCandidateBitmap->GetPixel(nativePixel, point); + aReferenceBitmap->GetPixel(referencePixel, point); + + if (nativePixel != referencePixel) + { + mismatchedPixels++; + result = EFalse; + } + } + } + + INFO_PRINTF2(_L("Number of different pixels: %i"), mismatchedPixels); + return result; + } +//Helper function: This function extracts content of the image associated with the image target and copies it into bitmap +void CTDrawResource::BitmapLC(CFbsBitmap*& aBmp) + { + aBmp = new(ELeave) CFbsBitmap; + CleanupStack::PushL(aBmp); + + TSgImageInfo info; + TInt res = iImage.GetInfo(info); + User::LeaveIfError(res); + + res = aBmp ->Create(info.iSizeInPixels, SgUtils::PixelFormatToDisplayMode(info.iPixelFormat)); + User::LeaveIfError(res); + TUint32* dataAddressDest = aBmp->DataAddress(); + + RSgImage image; + info.iUsage = ESgUsageNone; + info.iCpuAccess = ESgCpuAccessReadOnly; + res = image.Create(info, iImage); + User::LeaveIfError(res); + CleanupClosePushL(image); + const TAny* dataAddress = NULL; + TInt dataStride; + res = image.MapReadOnly(dataAddress, dataStride); + User::LeaveIfError(res); + Mem::Copy(dataAddressDest, dataAddress, dataStride * info.iSizeInPixels.iHeight); + image.Unmap(); + CleanupStack::PopAndDestroy(&image); + } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/tdrawresource.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/tdrawresource.h Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,221 @@ +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef TDRAWRESOURCE_H_ +#define TDRAWRESOURCE_H_ + +#include "AUTO.H" +#include +#include +#include +#include +#include +#include +#include +#include "RemoteGc.h" +#include "CommandBuffer.h" + +class TSgImageInfo; + +_LIT(KTDrawResourceStep, "TDrawResource"); + +const TSize KSourceSize(200,200); //The size of the rect to copy from the screen +const TPoint KDestPoint(0,0); +const TRect KCopyTestRect(TPoint(0,0), TSize(200,200)); //The test rect to copy from the screen +const TRect KSourceRect(TPoint(0,0), TSize(50,50));//Rect of the source image to be drawn +const TRect KDestRect(TPoint(10,10), TSize(60,60));//Rect of the destination to draw to +const CWindowGc::TGraphicsRotation KTestRotation= CWindowGc::EGraphicsRotation90; +const TPoint KPlayOffset(0,0); + + +/** + * Dummy class used to check the values received by MWsGraphicsContext. + * The only funtions overridden with some functionality are the DrawResource functions. + * These simply receive the values and then store them in public member variables. + */ +class CTestWsGraphicsContext : public CBase, public MWsGraphicsContext, public MWsDrawableSourceProvider + { +public: + static CTestWsGraphicsContext* NewL(RDirectGdiImageTarget& aTarget); + ~CTestWsGraphicsContext(); + +public: //from MWsGraphicsContext + void BitBlt(const TPoint&, const CFbsBitmap&){} + void BitBlt(const TPoint&, const CFbsBitmap&, const TRect&){} + void BitBltMasked(const TPoint&, const CFbsBitmap&, const TRect&, const CFbsBitmap&, TBool){} + void BitBltMasked(const TPoint&, const CFbsBitmap&, const TRect&, const CFbsBitmap&, const TPoint&){} + void ResetClippingRegion(){} + void Clear(); + void Clear(const TRect&){} + void ResetBrushPattern(){} + void ResetFont(){} + void DrawArc(const TRect&, const TPoint&, const TPoint&){} + void DrawPie(const TRect&, const TPoint&, const TPoint&){} + void DrawBitmap(const TRect&, const CFbsBitmap&){} + void DrawBitmap(const TRect&, const CFbsBitmap&, const TRect&){} + void DrawBitmapMasked(const TRect&, const CFbsBitmap&,const TRect&, const CFbsBitmap&, TBool){} + void DrawRoundRect(const TRect&, const TSize&){} + void DrawPolyLine(const TArray&){} + void DrawPolyLineNoEndPoint(const TArray&){} + void DrawPolygon(const TArray& , TFillRule ){} + void DrawEllipse(const TRect&){} + void DrawLine(const TPoint&, const TPoint&){} + void DrawLineTo(const TPoint&){} + void DrawLineBy(const TPoint&){} + void DrawRect(const TRect&){} + void DrawText(const TDesC& ,const TTextParameters* ){} + void DrawText(const TDesC& ,const TTextParameters* ,const TPoint& ){} + void DrawText(const TDesC& ,const TTextParameters* ,const TRect& ){} + void DrawText(const TDesC& ,const TTextParameters* ,const TRect& ,TInt ,TTextAlign ,TInt ){} + void DrawTextVertical(const TDesC& ,const TTextParameters* ,TBool ) {} + void DrawTextVertical(const TDesC& ,const TTextParameters* ,const TPoint& ,TBool ){} + void DrawTextVertical(const TDesC& ,const TTextParameters* ,const TRect& ,TBool ){} + void DrawTextVertical(const TDesC& ,const TTextParameters* ,const TRect& ,TInt ,TBool ,TTextAlign ,TInt ){} + void DrawTextVertical(const TDesC& ,const TTextParameters* ,const TRect& ,TInt ,TInt ,TBool ,TTextAlign ,TInt ){} + void MoveTo(const TPoint&){} + void MoveBy(const TPoint&){} + TPoint Origin() const {return TPoint(0,0);} + void Plot(const TPoint&){} + void Reset(){} + void SetBrushColor(const TRgb&){} + void SetBrushOrigin(const TPoint&){} + void SetBrushStyle(TBrushStyle ){} + void SetClippingRegion(const TRegion&){} + void SetDrawMode(TDrawMode){} + void SetOrigin(const TPoint&){} + void SetPenColor(const TRgb&){} + void SetPenStyle(TPenStyle){} + void SetPenSize(const TSize& ){} + void SetTextShadowColor(const TRgb&){} + void SetCharJustification(TInt, TInt){} + void SetWordJustification(TInt, TInt){} + void SetUnderlineStyle(TFontUnderline){} + void SetStrikethroughStyle(TFontStrikethrough){} + void SetBrushPattern(const CFbsBitmap&){} + void SetBrushPattern(TInt){} + void SetFont(const CFont*){} + void CopyRect(const TPoint&, const TRect&){} + void RectDrawnTo(TRect&){} + void UpdateJustification(const TDesC& ,const TTextParameters* ){} + void UpdateJustificationVertical(const TDesC& ,const TTextParameters* ,TBool ){} + void SetFontNoDuplicate(const CFont* ){} + TBool HasBrushPattern() const{return EFalse;} + TBool HasFont() const{return EFalse;} + void InternalizeL(RReadStream&){} + void ExternalizeL(RWriteStream&){} + TRgb BrushColor() const {return iContext->BrushColor();} + TRgb PenColor() const {return iContext->PenColor();} + TRgb TextShadowColor() const {return iContext->TextShadowColor ();} + + const TRegion& ClippingRegion(){return iRegion;} + TInt GetError(){return KErrNone;} + TInt Push(){return KErrNone;} + void Pop(){} + //from MWsObjectProvider + TAny* ResolveObjectInterface(TUint aTypeId); + + //from MWsDrawableSourceProvider + TInt CreateDrawableSource(const TSgDrawableId& aDrawableId, TAny*& aSource); + void CloseDrawableSource(TAny* aSource); + void DrawResource(const TAny* aSource, const TPoint& aPos, CWindowGc::TGraphicsRotation aRotation = CWindowGc::EGraphicsRotationNone); + void DrawResource(const TAny* aSource, const TRect& aRect, CWindowGc::TGraphicsRotation aRotation = CWindowGc::EGraphicsRotationNone); + void DrawResource(const TAny* aSource, const TRect& aRectDest, const TRect& aRectSrc, CWindowGc::TGraphicsRotation aRotation = CWindowGc::EGraphicsRotationNone); + void DrawResource(const TAny* aSource, const TRect& aRect, const TDesC8& aParam); + +private: + void ConstructL(RDirectGdiImageTarget& aTarget); + void DoCreateDrawableSourceL(const TSgDrawableId& aDrawableId, TAny*& aSource); +public: + TPoint iPos; + TRect iDestRect; + TRect iSrcRect; + DirectGdi::TGraphicsRotation iRotation; + RRegion iRegion; +private: + CDirectGdiContext* iContext; + }; + +/** + * Class derived from MWsGraphicResolver. This a dummy implmentation which has no functionality. + * An instance of it is passed to CCommandBuffer::Play to make it a valid call. + */ +class CWSGraphicsRes: public CBase, public MWsGraphicResolver + { +public: + void DrawWsGraphic(TInt, TBool, const TRect&, const TDesC8&) const{} + }; + +class CTDrawResource : public CTWsGraphicsBase + { +public: + CTDrawResource(CTestStep* aStep); + ~CTDrawResource(); + void ConstructL(); +protected: + //from CTGraphicsStep + void RunTestCaseL(TInt aCurTestCase); +private: + void TestDrawResourcePos(); + void TestDrawResourceRect(); + void TestDrawResourceScale(); + void TestRWsDrawableSourceReferenceCountingL(); + void TestRemoteGcDrawResourcePosL(); + void TestRemoteGcDrawResourceRectL(); + void TestRemoteGcDrawResourceScaleL(); + void TestDrawResourceScreensL(); + void TestCopyScreenToBitmapWithDifferentDisplayModesL(); + //Helper functions + TBool CompareBitmapsByPixel(CFbsBitmap* aCandidateBitmap, CFbsBitmap* aReferenceBitmap); + void CreateReferenceAndCopyBitmapsL(); + void CreateSgImageFromBitmapL(RSgImage& aImage); + void BitmapLC(CFbsBitmap*& aBmp); //helper function to extract bitmap from the image + void CreateReferenceBitmapLC(CFbsBitmap*& aBmpTarget, CFbsBitmap* aBmpSrc, TDisplayMode aDestMode); + void CreateBitmapLC(CFbsBitmap*& aBmpTarget, const TSize& aSize, TDisplayMode aDispMode) const; +private: + RWindow iWindow; + CFbsBitmap* iRefBitmap; + CFbsBitmap* iRotatedRefBitmap; + CFbsBitmap* iScaledBitmap; + CFbsBitmap *iScaledCroppedBitmap; + CFbsBitmap* iCopyBitmap; + CFbsBitmap* iBitmapWrongScreenNumber; + CDirectGdiDriver* iDGdiDriver; + + //Required for RemoteGc testing + RSgImageCollection iImageCollection; + RSgImage iImage; + RDirectGdiImageTarget iImageTarget; + RWsDrawableSource iWsDrawableSource; + CTestWsGraphicsContext* iGraphicsCon; + CWSGraphicsRes* iWsGrapicResolver; + }; + +class CTDrawResourceStep : public CTGraphicsStep + { +public: + CTDrawResourceStep(); +protected: + //from CTGraphicsStep + CTGraphicsBase* CreateTestL(); + }; + + +#endif /*TDRAWRESOURCE_H_*/ diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/tgc.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/tgc.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,1864 @@ +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ +#include "tgc.h" +#include "RemoteGc.h" +#include "CommandBuffer.h" +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA +#include "directgdigcwrapper.h" +#include +#include +#include +#endif + +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA +GLDEF_C void CopyImageToBitmapL(CFbsBitmap* aBitmap, const RSgImage& aImage, const TRect& aRect); +GLDEF_C void CopyImageToDestination(TAny* aDataAddressDest, TInt aDataStrideDest, TDisplayMode aDisplayModeDest, + TAny* aDataAddressSrc, TInt aDataStrideSrc, TDisplayMode aDisplayModeSrc, const TRect& aRect); +GLDEF_C void CopyImageToDestination64K(TAny* aDataAddressDest, TInt aDataStrideDest, TDisplayMode aDisplayModeDest, + TUint16* aDataAddressSrc, TInt aDataStrideSrc, const TRect& aRect); + +GLDEF_C void CopyImageToBitmapL(CFbsBitmap* aBitmap, const RSgImage& aImage, const TRect& aRect) + { + TSgImageInfo info; + TInt res = aImage.GetInfo(info); + if(res == KErrNone) + { + info.iUsage = ESgUsageNone; + info.iCpuAccess = ESgCpuAccessReadOnly; + RSgImage image; + res = image.Create(info, aImage); + if(res == KErrNone) + { + const TAny* dataAddressSrc = NULL; + TInt dataStrideSrc = 0; + res = image.MapReadOnly(dataAddressSrc, dataStrideSrc); + if(res == KErrNone) + { + const TDisplayMode displayModeDest = aBitmap->DisplayMode(); + const TDisplayMode displayModeSrc = SgUtils::PixelFormatToDisplayMode(info.iPixelFormat); + TUint32* dataAddressDest = aBitmap->DataAddress(); + const TInt dataStrideDest = aBitmap -> DataStride(); + TSize bitmapSize = aBitmap->SizeInPixels(); + TRect rect = aRect; + TRect rectDest = info.iSizeInPixels; + rect.Intersection(rectDest); + if(rect.Height() > bitmapSize.iHeight) + { + rect.SetHeight(bitmapSize.iHeight); + } + if(rect.Width() > bitmapSize.iWidth) + { + rect.SetWidth(bitmapSize.iWidth); + } + CopyImageToDestination((TAny*)dataAddressDest, dataStrideDest, displayModeDest, (TAny*)dataAddressSrc, + dataStrideSrc, displayModeSrc, rect); + + image.Unmap(); + } + image.Close(); + } + } + } + +GLDEF_C void CopyImageToDestination(TAny* aDataAddressDest, TInt aDataStrideDest, TDisplayMode aDisplayModeDest, + TAny* aDataAddressSrc, TInt aDataStrideSrc, TDisplayMode aDisplayModeSrc, const TRect& aRect) + { + if(aRect.IsEmpty()) + return; + + if((aDisplayModeDest == aDisplayModeSrc) && (aDataStrideSrc == aDataStrideDest)) + { + Mem::Copy(aDataAddressDest, aDataAddressSrc, aDataStrideDest * aRect.Height()); + return; + } + + switch(aDisplayModeSrc) + { + case EColor64K: + { + CopyImageToDestination64K(aDataAddressDest, aDataStrideDest, aDisplayModeDest, + (TUint16*)aDataAddressSrc, aDataStrideSrc, aRect); + break; + } + default: + break; + } + } + +GLDEF_C void CopyImageToDestination64K(TAny* aDataAddressDest, TInt aDataStrideDest, TDisplayMode aDisplayModeDest, + TUint16* aDataAddressSrc, TInt aDataStrideSrc, const TRect& aRect) + { + const TInt bppSrc = 2; + const TInt width = aRect.Width(); + const TInt height = aRect.Height(); + const TInt dataStrideLengthSrc = aDataStrideSrc / bppSrc; + TUint16* dataAddressSrc = aDataAddressSrc + aRect.iTl.iY * dataStrideLengthSrc + aRect.iTl.iX; + const TUint16* dataAddressSrcEnd = dataAddressSrc + dataStrideLengthSrc * height; + + switch(aDisplayModeDest) + { + case EColor64K: + { + TUint16* dataAddressDest = static_cast (aDataAddressDest); + const TInt dataStrideLengthDest = aDataStrideDest / bppSrc; + while(dataAddressSrcEnd > dataAddressSrc) + { + Mem::Copy(dataAddressDest, dataAddressSrc, width * bppSrc); + dataAddressSrc += dataStrideLengthSrc; + dataAddressDest += dataStrideLengthDest; + } + break; + } + case EColor16MU: + { + const TInt bppDest = 4; + TUint32* dataAddressDest = static_cast (aDataAddressDest); + const TInt dataStrideLengthDest = aDataStrideDest / bppDest; + + while(dataAddressSrcEnd > dataAddressSrc) + { + const TUint16* dataAddressSrcLineEnd = dataAddressSrc + width; + TUint32* dataAddressDestCur = dataAddressDest; + TUint16* dataAddressSrcCur = dataAddressSrc; + + while(dataAddressSrcLineEnd > dataAddressSrcCur) + { + *dataAddressDestCur = TRgb::Color64K(*dataAddressSrcCur).Color16MU(); + dataAddressDestCur++; + dataAddressSrcCur++; + } + dataAddressSrc += dataStrideLengthSrc; + dataAddressDest += dataStrideLengthDest; + } + break; + } + case EGray4: + { + TUint8* dataAddressDest = static_cast (aDataAddressDest); + const TInt dataStrideLengthDest = aDataStrideDest; + + while(dataAddressSrcEnd > dataAddressSrc) + { + const TUint8* dataAddressDstLineEnd = dataAddressDest + aDataStrideDest; + TUint8* dataAddressDestCur = dataAddressDest; + TUint16* dataAddressSrcCur = dataAddressSrc; + + while(dataAddressDstLineEnd > dataAddressDestCur) + { + *dataAddressDestCur = 0; + for(TInt index = 0; index < 8; index +=2) + { + TInt col = TRgb::Color64K(*dataAddressSrcCur).Gray4(); + col <<= index; + *dataAddressDestCur |= col; + dataAddressSrcCur++; + } + dataAddressDestCur++; + } + dataAddressSrc += dataStrideLengthSrc; + dataAddressDest += dataStrideLengthDest; + } + break; + } + case EColor256: + { + TUint8* dataAddressDest = static_cast (aDataAddressDest); + const TInt dataStrideLengthDest = aDataStrideDest; + + while(dataAddressSrcEnd > dataAddressSrc) + { + const TUint8* dataAddressDstLineEnd = dataAddressDest + aDataStrideDest; + TUint8* dataAddressDestCur = dataAddressDest; + TUint16* dataAddressSrcCur = dataAddressSrc; + + while(dataAddressDstLineEnd > dataAddressDestCur) + { + *dataAddressDestCur = TRgb::Color64K(*dataAddressSrcCur).Color256(); + dataAddressSrcCur++; + dataAddressDestCur++; + } + dataAddressSrc += dataStrideLengthSrc; + dataAddressDest += dataStrideLengthDest; + } + break; + } + default: + break; + } + } + +TDisplayMode DisplayModeFromPixelFormat(TUidPixelFormat aPixelFormat) + { + switch(aPixelFormat) + { + case EUidPixelFormatARGB_8888_PRE: + return EColor16MAP; + case EUidPixelFormatARGB_8888: + return EColor16MA; + case EUidPixelFormatRGB_565: + return EColor64K; + default: + break; + } + return ENone; + } + +TUidPixelFormat PixelFormatFromDisplayMode(TDisplayMode aDisplayMode) + { + switch (aDisplayMode) + { + case EGray2: + case EGray4: + case EGray16: + case EGray256: + case EColor16: + case EColor256: + case EColor16M: + case EColor16MU: + { + return EUidPixelFormatXRGB_8888; + } + case EColor4K: + { + return EUidPixelFormatXRGB_4444; + } + case EColor64K: + { + return EUidPixelFormatRGB_565; + } + case EColor16MA: + { + return EUidPixelFormatARGB_8888; + } + case EColor16MAP: + { + return EUidPixelFormatARGB_8888_PRE; + } + default: + { + return EUidPixelFormatUnknown; + } + } + } +#endif + +CTGc::CTGc(CTestStep* aStep) : CTWsGraphicsBase(aStep) + { + } + +CTGc::~CTGc() + { + delete iTest; +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA + SgDriver::Close(); + CDirectGdiDriver *directGdiDriver = CDirectGdiDriver::Static(); + if(directGdiDriver) + { + directGdiDriver->Close(); + } +#endif + } + +void CTGc::ConstructL() + { + _LIT(KTestName,"GC Test"); + iTest=new(ELeave) CTestBase(KTestName,this); + +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA + TInt err = CDirectGdiDriver::Open(); + User::LeaveIfError(err); + err = SgDriver::Open(); + if(err != KErrNone) + { + CDirectGdiDriver *directGdiDriver = CDirectGdiDriver::Static(); + if(directGdiDriver) + { + directGdiDriver->Close(); + } + User::Leave(err); + } +#endif + } + +//Class derived from MWsGraphicResolver. Used for playing the commands from command buffer +class CWSGraphicsRes: public CBase, public MWsGraphicResolver + { +public: + void DrawWsGraphic(TInt /*aId*/, TBool /*aIsUid*/, const TRect& /*aRect*/, const TDesC8& /*aData*/) const + { + //Orveriding by giving empty implemention + } + }; + +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA +// +//Class CDrawTextInContextTest +// + +CDrawTextInContextTest::CDrawTextInContextTest(){} + +CDrawTextInContextTest::~CDrawTextInContextTest() + { + delete iRefBitmap; + delete iRefDevice; + delete iRefBitGc; + delete iRemoteGc; + iMsgBuf.Close(); + delete iCommandBuffer; + delete iWsGraphicRes; + + TheClient->iScreen->ReleaseFont(iFont); + + delete iDirectGdiGcWrapper; + if(iWrapperImageTarget) + { + iWrapperImageTarget->Close(); + } + delete iWrapperImageTarget; + iWrapperImage.Close(); + iWrapperImageCollection.Close(); + } + +void CDrawTextInContextTest::BaseConstructL() + { + //Initialise font settings + TFontSpec fsp; + fsp.iTypeface.iName=_L("Series 60 Sans"); + fsp.iHeight=430; + User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont*&)iFont,fsp)); + + //Initialise TTextParameter + iParam.iStart = 27; + iParam.iEnd = 60; + + //Text to draw + iText.Set(_L("This text will not be drawnK.,!\"\x00A3$%^&*()_+-=;'#:@~/<>? Latin This text will not be drawn")); + + //For reference bitmap + iRefBitmap = new(ELeave) CFbsBitmap(); + User::LeaveIfError(iRefBitmap->Create(KBitmapSize, EColor64K)); + iRefDevice = CFbsBitmapDevice::NewL(iRefBitmap); + User::LeaveIfError(iRefDevice->CreateContext(iRefBitGc)); + + CDirectGdiDriver* theDGdiDriver = CDirectGdiDriver::Static(); + User::LeaveIfNull(theDGdiDriver); + + TSgImageInfo info; + info.iUsage = ESgUsageDirectGdiTarget | ESgUsageDirectGdiSource | ESgUsageCompositionSource; + info.iSizeInPixels = KBitmapSize; + info.iPixelFormat = EUidPixelFormatRGB_565; + + TInt res = iWrapperImageCollection.Create(info, 1); + User::LeaveIfError(res); + res = iWrapperImageCollection.OpenImage(0, iWrapperImage); + User::LeaveIfError(res); + iWrapperImageTarget = new (ELeave) RDirectGdiImageTarget(*theDGdiDriver); + res = iWrapperImageTarget->Create(iWrapperImage); + User::LeaveIfError(res); + iDirectGdiGcWrapper = CDirectGdiGcWrapper::NewL(*iWrapperImageTarget); + + //clean image----------------- + CDirectGdiGcWrapper* directGdiGcWrapper = CDirectGdiGcWrapper::NewL(*iWrapperImageTarget); + CleanupStack::PushL(directGdiGcWrapper); + + directGdiGcWrapper->SetDrawMode(MWsGraphicsContext::EDrawModeWriteAlpha); + directGdiGcWrapper->SetBrushColor(KRgbWhite); + directGdiGcWrapper->Clear(); + + CleanupStack::PopAndDestroy(1, directGdiGcWrapper); + //------------------ + + //Used to record draw commands + iRemoteGc = CRemoteGc::NewL(TheClient->iScreen); + + //Used to play recorded draw commands + iCommandBuffer = CCommandBuffer::NewL(); + + //Dummy class created required for CCommandBuffer::Play + iWsGraphicRes = new (ELeave) CWSGraphicsRes(); + + //Offset for CCommandBuffer::Play + iOffset = TPoint(0,0); + + //Result of doing the test + iHasPassedTest = EFalse; + } + +void CDrawTextInContextTest::Test() + { + /* Create reference bitmap by drawing using bitgc */ + iRefBitGc->UseFont(iFont); + DoDrawTextBitGc(); + iRefBitGc->DiscardFont(); + + /* Drawing using CBitGcWrapper via CRemotGc*/ + + //Capturing the commands in remote gc + iRemoteGc->BeginDraw(KBitmapRect); + iRemoteGc->UseFont(iFont); + DoDrawTextRemoteGc(); + iRemoteGc->DiscardFont(); + iRemoteGc->EndDraw(); + + //Externalize the captured commands from remote gc in to a buffer + iRemoteGc->ExternalizeL(iMsgBuf, ETrue); + + //Internalize the buffer with captured commands (from CRemoteGC) in to CCommandBuffer + iCommandBuffer->InternalizeL(iMsgBuf.Pckg()); + + //Play the commands on test window using command buffer + iCommandBuffer->Play(iOffset,&KBitmapRegion,KBitmapRect,*iWsGraphicRes,*iDirectGdiGcWrapper); + + //Test to see if the bitmap drawn to using CRemoteGc is the same as the reference bitmap + CFbsBitmap* bitmap = new (ELeave) CFbsBitmap; + CleanupStack::PushL(bitmap); + + TSgImageInfo info; + iWrapperImage.GetInfo(info); + TDisplayMode displayMode = DisplayModeFromPixelFormat(info.iPixelFormat); + bitmap->Create(info.iSizeInPixels, displayMode); + TRect rect(info.iSizeInPixels); + CopyImageToBitmapL(bitmap, iWrapperImage, rect); + + iHasPassedTest = LossyCompareBitmap(*iRefBitmap, *bitmap, KBitmapRect, EFalse); + + CleanupStack::PopAndDestroy(bitmap); + } + +TBool CDrawTextInContextTest::HasPassedTest() + { + return iHasPassedTest; + } + +// +// Class DrawTextInContextTestPoint +// + +CDrawTextInContextTestPoint::CDrawTextInContextTestPoint(){} + +CDrawTextInContextTestPoint::~CDrawTextInContextTestPoint(){} + +CDrawTextInContextTestPoint* CDrawTextInContextTestPoint::NewL() + { + CDrawTextInContextTestPoint* self = new(ELeave) CDrawTextInContextTestPoint; + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +void CDrawTextInContextTestPoint::ConstructL() + { + BaseConstructL(); + iPosition = TPoint(0,0); + } + +void CDrawTextInContextTestPoint::DoDrawTextBitGc() + { + iRefBitGc->DrawText(iText,&iParam,iPosition); + } + +void CDrawTextInContextTestPoint::DoDrawTextRemoteGc() + { + iRemoteGc->DrawText(iText,&iParam,iPosition); + } + +// +// Class DrawTextInContextTestBox +// + +CDrawTextInContextTestBox::CDrawTextInContextTestBox(){} + +CDrawTextInContextTestBox::~CDrawTextInContextTestBox(){} + +CDrawTextInContextTestBox* CDrawTextInContextTestBox::NewL() + { + CDrawTextInContextTestBox* self = new(ELeave) CDrawTextInContextTestBox; + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +void CDrawTextInContextTestBox::ConstructL() + { + BaseConstructL(); + iClipFillRect = TRect(10,50,640,120); + iBaselineOffset = 40; + iTTextAlign = CGraphicsContext::ELeft; + } + +void CDrawTextInContextTestBox::DoDrawTextBitGc() + { + iRefBitGc->DrawText(iText,&iParam,iClipFillRect,iBaselineOffset,iTTextAlign); + } + +void CDrawTextInContextTestBox::DoDrawTextRemoteGc() + { + iRemoteGc->DrawText(iText,&iParam,iClipFillRect,iBaselineOffset,iTTextAlign); + } + +// +// Class CDrawTextInContextTestPointVertical +// + +CDrawTextInContextTestPointVertical::CDrawTextInContextTestPointVertical(){} + +CDrawTextInContextTestPointVertical::~CDrawTextInContextTestPointVertical(){} + +CDrawTextInContextTestPointVertical* CDrawTextInContextTestPointVertical::NewL() + { + CDrawTextInContextTestPointVertical* self = new(ELeave) CDrawTextInContextTestPointVertical; + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +void CDrawTextInContextTestPointVertical::ConstructL() + { + BaseConstructL(); + iPosition = TPoint(0,0); + iUp = EFalse; + } + +void CDrawTextInContextTestPointVertical::DoDrawTextBitGc() + { + iRefBitGc->DrawTextVertical(iText,&iParam,iPosition,iUp); + } + +void CDrawTextInContextTestPointVertical::DoDrawTextRemoteGc() + { + iRemoteGc->DrawTextVertical(iText,&iParam,iPosition,iUp); + } + +// +// Class CDrawTextInContextTestBoxVertical +// + +CDrawTextInContextTestBoxVertical::CDrawTextInContextTestBoxVertical(){} + +CDrawTextInContextTestBoxVertical::~CDrawTextInContextTestBoxVertical(){} + +CDrawTextInContextTestBoxVertical* CDrawTextInContextTestBoxVertical::NewL() + { + CDrawTextInContextTestBoxVertical* self = new(ELeave) CDrawTextInContextTestBoxVertical; + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +void CDrawTextInContextTestBoxVertical::ConstructL() + { + BaseConstructL(); + iClipFillRect = TRect(10,50,640,120); + iBaselineOffset = 40; + iUp = EFalse; + iTTextAlign = CGraphicsContext::ELeft; + } + +void CDrawTextInContextTestBoxVertical::DoDrawTextBitGc() + { + iRefBitGc->DrawTextVertical(iText,&iParam,iClipFillRect,iBaselineOffset,iUp,iTTextAlign); + } + +void CDrawTextInContextTestBoxVertical::DoDrawTextRemoteGc() + { + iRemoteGc->DrawTextVertical(iText,&iParam,iClipFillRect,iBaselineOffset,iUp,iTTextAlign); + } +#endif //TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA + +void CleanUpFont(TAny* aFont) + { + //Will be called in case of a leave to release the font + CFont* font= static_cast(aFont); + TheClient->iScreen->ReleaseFont(font); + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-0437 +@SYMPREQ PREQ1543 +@SYMTestCaseDesc Draw text using CWindowGc and CRemoteGc with both outline and shadow +effect on. +@SYMTestPriority High +@SYMTestStatus Implemented +@SYMTestActions Create a font with both outline and shadow effects. Record the commands +(like setting colours,drawing text etc) using CRemoteGc and play the recorded commands on a window. Use the same +commands in CWindowGc and draw text on a different window +@SYMTestExpectedResults Text drawn using CWindowGc and CRemoteGc should be same +*/ +void CTGc::TestOutlineAndShadowL() + { + TRect sourceRect(0, 0, TestWin->Size().iWidth, TestWin->Size().iHeight); + TRegionFix<1> clippingRegion(sourceRect); + + CWsScreenDevice* device = TheClient->iScreen; + + _LIT(KText,"Outline and shadow"); + TFontSpec fSpec(KTestFontTypefaceName,23); + fSpec.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap); + fSpec.iFontStyle.SetEffects(FontEffect::EDropShadow, ETrue); + fSpec.iFontStyle.SetEffects(FontEffect::EOutline, ETrue); + + CFont *font; + User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInPixels((CFont *&)font, fSpec)); + CleanupStack::PushL(TCleanupItem(CleanUpFont, font)); + + CRemoteGc* remoteGc = CRemoteGc::NewL(device); + CleanupStack::PushL(remoteGc); + remoteGc->BeginDraw(sourceRect); + //Capturing the commands in remote gc + remoteGc->SetBrushColor(KRgbGreen); + remoteGc->SetShadowColor(KRgbDarkRed); + remoteGc->SetPenColor(KRgbBlack); + remoteGc->UseFont(font); + remoteGc->DrawText(KText, TPoint(2,40)); + remoteGc->DiscardFont(); + remoteGc->EndDraw(); + + RWsGraphicMsgBuf msgBuf; + CleanupClosePushL(msgBuf); + //Externalize the captured commands from remote gc in to a buffer + remoteGc->ExternalizeL(msgBuf, ETrue); + + CWSGraphicsRes* wsGrap = new (ELeave) CWSGraphicsRes(); + CleanupStack::PushL(wsGrap); + + CCommandBuffer* cmdBuf = CCommandBuffer::NewL(); + CleanupStack::PushL(cmdBuf); + //Internalize the buffer with captured commands (from CRemoteGC) + //in to CCommandBuffer + cmdBuf->InternalizeL(msgBuf.Pckg()); + + TestWin->Win()->Invalidate(); + TestWin->Win()->BeginRedraw(); + TheGc->Activate(*TestWin->Win()); + TheGc->Clear(); + //Play the commands on test window using command buffer +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA + cmdBuf->Play(TPoint(0, 0), &clippingRegion, sourceRect, TheClient->iWs, *TheGc); +#else + cmdBuf->Play(TPoint(),TRect(TestWin->Size()),*wsGrap,*TheGc); +#endif + TheGc->Deactivate(); + TestWin->Win()->EndRedraw(); + + BaseWin->Win()->Invalidate(); + BaseWin->Win()->BeginRedraw(); + TheGc->Activate(*BaseWin->Win()); + TheGc->Clear(); + TheGc->SetBrushColor(KRgbGreen); + TheGc->SetShadowColor(KRgbDarkRed); + TheGc->SetPenColor(KRgbBlack); + TheGc->UseFont(font); + //Draw the text on base window using CWindowGC + TheGc->DrawText(KText, TPoint(2, 40)); + TheGc->DiscardFont(); + TheGc->Deactivate(); + BaseWin->Win()->EndRedraw(); + TheClient->iWs.Finish(); + TheClient->WaitForRedrawsToFinish(); + + //Check the text drawn on base and test windows. + CheckRect(BaseWin, TestWin, TRect(0, 0, BaseWin->Size().iWidth, BaseWin->Size().iHeight), _L("CTGc::TestOutlineAndShadowL()")); + + CleanupStack::PopAndDestroy(4, remoteGc); //cmdBuf, wsGrap, msgBuf and remoteGc + CleanupStack::Pop();//font + TheClient->iScreen->ReleaseFont(font); + } + +void CTGc::TestGcClipRectOrigin_DrawContent(TestWindow& aWindow, TBool bActivateBeforeRedraw /*= ETrue*/) + { + TSize winSize = aWindow.Size(); + TPoint gcOrigin(winSize.iWidth >> 3, winSize.iWidth >> 3); + TRect gcClipRect(0, 0, (winSize.iWidth * 3) >> 2, (winSize.iHeight * 3) >> 2); + TRect ellipseRect(gcClipRect); + // Shrink the ellipse for better visibility and to fit well within the clip area. + ellipseRect.Shrink(3, 3); + TSize penSize(1, 1); + + aWindow.Win()->SetBackgroundColor(KRgbGreen); + aWindow.ClearWin(); + aWindow.Win()->Invalidate(); + + if(!bActivateBeforeRedraw) + { + aWindow.Win()->BeginRedraw(); + } + + TheGc->Activate(*(aWindow.Win())); + TheGc->SetOrigin(gcOrigin); + TheGc->SetClippingRect(gcClipRect); + + if(bActivateBeforeRedraw) + { + aWindow.Win()->BeginRedraw(); + } + + TheGc->SetBrushColor(KRgbDarkRed); + TheGc->SetPenColor(KRgbDarkRed); + TheGc->SetPenSize(penSize); + TheGc->SetPenStyle(CGraphicsContext::ESolidPen); + TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + TheGc->DrawEllipse(ellipseRect); + TheGc->SetBrushStyle(CGraphicsContext::ENullBrush); + TheGc->SetPenColor(KRgbYellow); + TheGc->SetPenStyle(CGraphicsContext::EDashedPen); + TheGc->DrawRect(gcClipRect); + + aWindow.Win()->EndRedraw(); + TheGc->Deactivate(); + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-0471 +@SYMTestCaseDesc This test is to verify that the GC correctly applies the clip rect and + origin attributes irrespective of whether the GC is activated on the + window before or after the BeginRedraw. +@SYMDEF PDEF120091 +@SYMTestPriority High +@SYMTestStatus Implemented +@SYMTestActions The test has following steps: + 1. For the Test window follow the steps: + A. Activate the GC on Test window. + B. Set the Origin of the GC to centre of the window. + C. Set the Clipping rectangle of the GC to half the size of the window. + D. In the BeginDraw and EndDraw call bracket perform the following: + a. Draw an ellipse with the rectangle smaller by 5 pixels than the clip rectangle. + b. Draw a rectangle that is size of the clip rectangle. + E. Deactivate the GC. + 2. For the Base window follow the steps: + A. In the BeginDraw and EndDraw call bracket perform the following: + a. Activate the GC on Base window. + b. Set the Origin of the GC to centre of the window. + c. Set the Clipping rectangle of the GC to half the size of the window. + d. Draw an ellipse with the rectangle smaller by 5 pixels than the clip rectangle. + e. Draw a rectangle that is size of the clip rectangle. + f. Deactivate the GC. + 3. Compare Test and Base window. +@SYMTestExpectedResults Both the Test and Base window should have the complete + non-clipped ellipse completely encapsulated within the rectangle. +*/ +void CTGc::TestGcClipRectOrigin() + { + TestGcClipRectOrigin_DrawContent(*BaseWin, EFalse); + TestGcClipRectOrigin_DrawContent(*TestWin, ETrue); + + TheClient->Flush(); + + CheckRect(BaseWin, TestWin, TRect(0, 0, BaseWin->Size().iWidth, BaseWin->Size().iHeight), _L("CTGc::TestGcClipRectOriginL()")); + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-0469 +@SYMDEF INC116406 +@SYMTestCaseDesc Try playback on MWsGraphicsContext and CWindowGc to check that the background colour is +set correctly. +@SYMTestPriority High +@SYMTestStatus Implemented +@SYMTestActions +@SYMTestExpectedResults Text drawn using CWindowGc should use the background colour of +the window, and MWsGraphicsContext should use transparent white. +*/ +void CTGc::TestResetWithBackgroundColorL() + { + const TRect KSourceRect(0, 0, TestWin->Size().iWidth, TestWin->Size().iHeight); + const TRegionFix<1> KClippingRegion(KSourceRect); + + CWsScreenDevice* device = TheClient->iScreen; + + CRemoteGc* remoteGc = CRemoteGc::NewL(device); + CleanupStack::PushL(remoteGc); + + //note this remote GC has not been activated on any window + remoteGc->BeginDraw(KSourceRect); + + //Draw the commands in remote gc + remoteGc->SetBrushColor(KRgbGreen); //nothing green is seen in this test + + remoteGc->Reset(); //This resets the brush colour to the background colour of the window + //where playback is, in the case of playing back to a window + //however with a CFbsBitGc the color is transparent white, as there is no window. + remoteGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + remoteGc->SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); + remoteGc->DrawRect(KSourceRect); + remoteGc->EndDraw(); + +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA + CDirectGdiDriver* theDGdiDriver = CDirectGdiDriver::Static(); + User::LeaveIfNull(theDGdiDriver); + + TSgImageInfo info; + info.iUsage = ESgUsageDirectGdiTarget | ESgUsageCompositionSource; + info.iSizeInPixels = TSize(TestWin->Size().iWidth, TestWin->Size().iHeight); + info.iPixelFormat = EUidPixelFormatXRGB_8888;//among display modes with alpha channel only pre-multiply alpha is supported in directGDI currently + + RSgImageCollection imageCollection; + CleanupClosePushL(imageCollection); + TInt res = imageCollection.Create(info, 1); + User::LeaveIfError(res); + RSgImage image; + CleanupClosePushL(image); + res = imageCollection.OpenImage(0, image); + User::LeaveIfError(res); + RDirectGdiImageTarget imageTarget(*theDGdiDriver); + CleanupClosePushL(imageTarget); + res = imageTarget.Create(image); + User::LeaveIfError(res); +#endif +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + //create a bitmap + CFbsBitmap *bitmap = new (ELeave) CFbsBitmap(); + User::LeaveIfError(bitmap->Create(TSize(TestWin->Size().iWidth, TestWin->Size().iHeight), EColor16MA)); + CleanupStack::PushL(bitmap); + + CFbsBitmapDevice *fbsDevice = CFbsBitmapDevice::NewL(bitmap); + CleanupStack::PushL(fbsDevice); +#endif + + //prepare the command buffer for playback + RWsGraphicMsgBuf msgBuf; + CleanupClosePushL(msgBuf); + + //Externalize the captured commands from remote gc in to a buffer + remoteGc->ExternalizeL(msgBuf, ETrue); + + CWSGraphicsRes* wsGrap = new (ELeave) CWSGraphicsRes(); + CleanupStack::PushL(wsGrap); + + CCommandBuffer* cmdBuf = CCommandBuffer::NewL(); + CleanupStack::PushL(cmdBuf); + cmdBuf->InternalizeL(msgBuf.Pckg()); + + TRgb color; + TRgb testColor(KRgbWhite); +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA + CDirectGdiGcWrapper* directGdiGcWrapper=CDirectGdiGcWrapper::NewL(imageTarget); + CleanupStack::PushL(directGdiGcWrapper); + cmdBuf->Play(TPoint(),&KClippingRegion,KSourceRect,*wsGrap,*directGdiGcWrapper); + + //check that the background has been cleared to transparent white. + image.GetInfo(info); + info.iUsage = ESgUsageNone; + info.iCpuAccess = ESgCpuAccessReadOnly; + RSgImage image1; + CleanupClosePushL(image1); + res = image1.Create(info, image); + const TAny* data; + TInt stride = 0; + res = image1.MapReadOnly(data, stride); + User::LeaveIfError(res); + TPoint pixel(10,10); + TInt offset = pixel.iY * stride + pixel.iX * 4; + TAny* non_const_data = const_cast (data); + TUint8* pointData = static_cast (non_const_data) + offset; + color = *(reinterpret_cast (pointData)); + image1.Unmap(); +#endif +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + CFbsBitGc* fbsBitGc=NULL; + User::LeaveIfError(fbsDevice->CreateContext(fbsBitGc)); + CleanupStack::PushL(fbsBitGc); + fbsBitGc->Activate(fbsDevice); + cmdBuf->Play(TPoint(0, 0), KSourceRect, *wsGrap, *fbsBitGc); + bitmap->GetPixel(color, TPoint(10,10)); + testColor.SetAlpha(0); +#endif + iStep->TEST(color==testColor); + + //now test drawing to a window to ensure that the brush colour is + //the window background colour + + //display a blue window + BaseWin->Win()->SetBackgroundColor(KRgbBlue); + BaseWin->Win()->Invalidate(); + BaseWin->Win()->BeginRedraw(); + TheGc->Activate(*BaseWin->Win()); + TheGc->Clear(); + TheGc->Deactivate(); + BaseWin->Win()->EndRedraw(); + TheClient->iWs.Finish(); + TheClient->WaitForRedrawsToFinish(); + + //start drawing the display commands with a green background + + BaseWin->Win()->SetBackgroundColor(KRgbYellow); + BaseWin->Win()->Invalidate(); + BaseWin->Win()->BeginRedraw(); + TheGc->Activate(*BaseWin->Win()); + + //Play the commands on test window using command buffer +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA + cmdBuf->Play(TPoint(0, 0), &KClippingRegion, KSourceRect, TheClient->iWs, *TheGc); +#else + cmdBuf->Play(TPoint(0, 0), KSourceRect, *wsGrap, *TheGc); +#endif + + TheGc->Deactivate(); + BaseWin->Win()->EndRedraw(); + TheClient->iWs.Finish(); + TheClient->WaitForRedrawsToFinish(); + + //check that the background has been cleared to yellow, using brush colour + TPoint position = BaseWin->Win()->InquireOffset(*TheClient->iGroup->WinTreeNode()); + position.iX+=10; + position.iY+=10; + TheClient->iScreen->GetPixel(color, position); + iStep->TEST(color==KRgbYellow); + + BaseWin->Win()->SetBackgroundColor(KRgbGreen); //set back to original backgroundcolor + +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA + CleanupStack::PopAndDestroy(9, remoteGc); +#else + CleanupStack::PopAndDestroy(7, remoteGc); +#endif + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-0481 +@SYMPREQ 1841 +@SYMTestCaseDesc Create font and graphics with various effect effects. Record the commands +(like setting colours,drawing text etc) using CRemoteGc and play the recorded commands on a window. Use the same +commands in CWindowGc and draw text on a different window +@SYMTestPriority Medium +@SYMTestStatus Implemented +@SYMTestActions +@SYMTestExpectedResults Text/graphics drawn using CWindowGc and CRemoteGc should be same +*/ +void CTGc::TestCommandBufferL() + { + CWsScreenDevice* device = TheClient->iScreen; + + _LIT(KBuffText,"Command Buffer"); + TFontSpec fSpec(KTestFontTypefaceName,23); + fSpec.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap); + fSpec.iFontStyle.SetEffects(FontEffect::EDropShadow, ETrue); + fSpec.iFontStyle.SetEffects(FontEffect::EOutline, ETrue); + + CFont *font; + User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInPixels((CFont *&)font, fSpec)); + CleanupStack::PushL(TCleanupItem(CleanUpFont, font)); + + CRemoteGc* remoteGc = CRemoteGc::NewL(device); + CleanupStack::PushL(remoteGc); + +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA + //-------create image--------- + CDirectGdiDriver* theDGdiDriver = CDirectGdiDriver::Static(); + User::LeaveIfNull(theDGdiDriver); + const TSize KImageSize = TSize(2, 2); + TSgImageInfo info; + info.iUsage = ESgUsageWindowGcSource; + info.iSizeInPixels = KImageSize; + info.iPixelFormat = EUidPixelFormatRGB_565; + info.iShareable = ETrue; + const TInt stride = KImageSize.iWidth * 2; + TUint8* buf = (TUint8*) (User::AllocL(KImageSize.iHeight * stride)); + CleanupStack::PushL(buf); + TUint16* bufCur = ((TUint16*)buf); + *bufCur = KRgbRed.Color64K(); + *(bufCur + 1) = KRgbRed.Color64K(); + *(bufCur + 2) = KRgbRed.Color64K(); + *(bufCur + 3) = KRgbRed.Color64K(); + + RSgImage image; + TInt res = image.Create(info, buf, stride); + User::LeaveIfError(res); + CleanupClosePushL(image); + RWsDrawableSource drawableSource(TheClient->iWs); + res = drawableSource.Create(image, TheClient->iScreen->GetScreenNumber()); + if(res == KErrNotSupported) + { + INFO_PRINTF1(_L("The current screen is not supports drawable source. This test case terminates now.")); + CleanupStack::PopAndDestroy(3, remoteGc); + CleanupStack::Pop();//font + TheClient->iScreen->ReleaseFont(font); + return; + } + User::LeaveIfError(res); + CleanupClosePushL(drawableSource); + //-------end create image--------- +#endif + remoteGc->ResetCommandBuffer(); + remoteGc->BeginDraw(TRect(0, 0, TestWin->Size().iWidth, TestWin->Size().iHeight)); + //Capturing the commands in remote gc + remoteGc->Clear(); + remoteGc->DrawRect(TRect(10,10,30,30)); + remoteGc->Clear(TRect(10,10,11,11)); + remoteGc->CopyRect(TPoint(5,5), TRect(25,25,30,30)); + CFbsBitmap* bitmap = new (ELeave) CFbsBitmap; + CFbsBitmap* bitmapMask = new (ELeave) CFbsBitmap; + User::LeaveIfError(bitmap->Load(_L("Z:\\WSTEST\\WSAUTOTEST.MBM"), EMbmWsautotestCircles24b)); + User::LeaveIfError(bitmapMask->Load(_L("Z:\\WSTEST\\WSAUTOTEST.MBM"), EMbmWsautotestCircles_mask2b)); + remoteGc->BitBlt(TPoint(100,100), bitmap); + remoteGc->BitBlt(TPoint(0,0), bitmap, TRect(0,0,1,1)); + remoteGc->BitBltMasked(TPoint(0,5), bitmap, TRect(0,0,1,1), bitmapMask, EFalse); + CWsBitmap* bitmapWs = new (ELeave) CWsBitmap(TheClient->iWs); + CWsBitmap* bitmapWsMask = new (ELeave) CWsBitmap(TheClient->iWs); + User::LeaveIfError(bitmapWs->Load(_L("Z:\\WSTEST\\TEST.MBM"), 0)); + remoteGc->BitBlt(TPoint(110,110), bitmapWs); + remoteGc->BitBlt(TPoint(5,0), bitmapWs, TRect(0,0,1,1)); + remoteGc->BitBltMasked(TPoint(10,0), bitmap, TRect(0,0,1,1), bitmapWsMask, EFalse); + remoteGc->SetFadingParameters(128,128); + remoteGc->SetFaded(EFalse); + remoteGc->AlphaBlendBitmaps(TPoint(2,2), bitmap, TRect(0,0,1,1), bitmapMask, TPoint(2,2)); + remoteGc->AlphaBlendBitmaps(TPoint(3,3), bitmapWs, TRect(0,0,1,1), bitmapWsMask, TPoint(2,2)); + remoteGc->SetOrigin(TPoint(0,30)); + remoteGc->SetDrawMode(CGraphicsContext::EDrawModePEN); + remoteGc->SetClippingRect(TRect(0,0,10,10)); + remoteGc->SetPenStyle(CGraphicsContext::ESolidPen); + remoteGc->SetPenSize(TSize(1,2)); + remoteGc->UseBrushPattern(bitmap); + remoteGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + remoteGc->SetBrushOrigin(TPoint(0,0)); + remoteGc->DrawPie(TRect(0,0,15,15),TPoint(0,8),TPoint(15,8)); + remoteGc->CancelClippingRect(); + remoteGc->DiscardBrushPattern(); + remoteGc->CancelClippingRegion(); + remoteGc->Reset(); + remoteGc->SetOrigin(TPoint(0,0)); + remoteGc->SetUnderlineStyle(EUnderlineOff); + remoteGc->SetStrikethroughStyle(EStrikethroughOff); + remoteGc->SetWordJustification(1,2); + remoteGc->SetCharJustification(1,2); + remoteGc->UseFont(font); + remoteGc->DrawText(KBuffText,TRect(50,0,100,50),10,CGraphicsContext::ELeft,0); + remoteGc->DrawTextVertical(KBuffText,TPoint(170,20),EFalse); + remoteGc->DrawTextVertical(KBuffText,TRect(120,20,150,100),5,EFalse,CGraphicsContext::ELeft,0); + remoteGc->MoveTo(TPoint(25,150)); + remoteGc->MoveBy(TPoint(5,5)); + remoteGc->DrawLineTo(TPoint(35,160)); + remoteGc->DrawLine(TPoint(35,160),TPoint(25,150)); + remoteGc->DrawLineBy(TPoint(15,6)); + remoteGc->Plot(TPoint(5,5)); + remoteGc->DrawArc(TRect(0,80,10,90),TPoint(0,85),TPoint(10,85)); + remoteGc->DrawEllipse(TRect(0,90,10,100)); + remoteGc->DrawRoundRect(TRect(30,80,50,100),TSize(5,5)); + remoteGc->DrawBitmap(TPoint(150,150),bitmap); + remoteGc->DrawBitmap(TRect(160,160,170,170), bitmap); + remoteGc->DrawBitmap(TRect(175,175,180,180), bitmap, TRect(0,5,5,10)); + remoteGc->DrawBitmapMasked(TRect(185,185,190,190), bitmap, TRect(0,50,5,55),bitmapMask,EFalse); + remoteGc->DrawBitmapMasked(TRect(195,195,200,200), bitmapWs, TRect(0,50,5,55),bitmapWsMask,EFalse); + CArrayFixFlat* polyPoints = new(ELeave) CArrayFixFlat(3); //CArrayFixFlat + CleanupStack::PushL(polyPoints); + TRect rect (200,0,200,100); + polyPoints->AppendL(rect.iTl); + polyPoints->AppendL(rect.Center()); + polyPoints->AppendL(TPoint(rect.iBr.iX, rect.iTl.iY)); + remoteGc->DrawPolyLine(polyPoints); + remoteGc->DrawPolyLine(&polyPoints->At(0), 3); + remoteGc->DrawPolygon(polyPoints, CGraphicsContext::EWinding); + remoteGc->DrawPolygon(&polyPoints->At(0), 3, CGraphicsContext::EAlternate); +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA + MWsDrawResource* dr = static_cast(remoteGc->Interface(KMWsDrawResourceInterfaceUid)); + if(dr) + dr->DrawResource(TPoint(30, 40), drawableSource); +#endif + RRegion region; + remoteGc->SetClippingRegion(region); + remoteGc->DiscardFont(); + remoteGc->EndDraw(); + + RWsGraphicMsgBuf msgBuf; + CleanupClosePushL(msgBuf); + //Externalize the captured commands from remote gc in to a buffer + remoteGc->ExternalizeL(msgBuf, EFalse); + + CCommandBuffer* cmdBuf = CCommandBuffer::NewL(); + CleanupStack::PushL(cmdBuf); + const CCommandBuffer* testCmdBuf = CCommandBuffer::NewL(); + if(cmdBuf->IsIdentical(*testCmdBuf)==EFalse) + { + User::Panic(_L("TestCommandBufferL"), KErrGeneral); + } + delete testCmdBuf; + //Internalize the buffer with captured commands (from CRemoteGC) + //in to CCommandBuffer + cmdBuf->InternalizeL(msgBuf.Pckg()); + + TheGc->Activate(*TestWin->Win()); + TestWin->Win()->Invalidate(); + +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + /* + * Make sure anything that can leave is done outside the + * BeginRedraw/EndRedraw bracket. + */ + CWSGraphicsRes* wsGrap=new(ELeave) CWSGraphicsRes(); + CleanupStack::PushL(wsGrap); +#endif + /* + * Note we need to still do BeginRedraw/EndRedraw for the TestWin Window + * even though the CRemoteGc we are going to Play into TestWin already has + * BeginRedraw/EndRedraw commands issued into it. Those commands just allow + * for replacement of draw ops already in the CRemoteGc to be replaced by + * new draw ops covering the same area. The BeginRedraw/EndRedraws never + * get Play()'ed into TestWin. + */ + TestWin->Win()->BeginRedraw(); + TheGc->Clear(); + //Play the commands on test window using command buffer +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA + cmdBuf->Play(TPoint(), NULL, TRect(TestWin->Size()), TheClient->iWs, *TheGc); +#endif +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + cmdBuf->Play(TPoint(),TRect(TestWin->Size()),*wsGrap,*TheGc); + CleanupStack::PopAndDestroy(wsGrap); +#endif + TheGc->Deactivate(); + TestWin->Win()->EndRedraw(); + remoteGc->ResetCommandBuffer(); + BaseWin->Win()->Invalidate(); + BaseWin->Win()->BeginRedraw(); + TheGc->Activate(*BaseWin->Win()); + TheGc->Clear(); + TheGc->DrawRect(TRect(10,10,30,30)); + TheGc->Clear(TRect(10,10,11,11)); + TheGc->CopyRect(TPoint(5,5), TRect(25,25,30,30)); + TheGc->BitBlt(TPoint(100,100), bitmap); + TheGc->BitBlt(TPoint(0,0), bitmap, TRect(0,0,1,1)); + TheGc->BitBltMasked(TPoint(0,5), bitmap, TRect(0,0,1,1), bitmapMask, EFalse); + TheGc->BitBlt(TPoint(110,110), bitmapWs); + TheGc->BitBlt(TPoint(5,0), bitmapWs, TRect(0,0,1,1)); + TheGc->BitBltMasked(TPoint(10,0), bitmap, TRect(0,0,1,1), bitmapWsMask, EFalse); + TheGc->SetFadingParameters(128,128); + TheGc->SetFaded(EFalse); + TheGc->AlphaBlendBitmaps(TPoint(2,2), bitmap, TRect(0,0,1,1), bitmapMask, TPoint(2,2)); + TheGc->AlphaBlendBitmaps(TPoint(3,3), bitmapWs, TRect(0,0,1,1), bitmapWsMask, TPoint(2,2)); + TheGc->SetOrigin(TPoint(0,30)); + TheGc->SetDrawMode(CGraphicsContext::EDrawModePEN); + TheGc->SetClippingRect(TRect(0,0,10,10)); + TheGc->SetPenStyle(CGraphicsContext::ESolidPen); + TheGc->SetPenSize(TSize(1,2)); + TheGc->UseBrushPattern(bitmap); + TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + TheGc->SetBrushOrigin(TPoint(0,0)); + TheGc->DrawPie(TRect(0,0,15,15),TPoint(0,8),TPoint(15,8)); + TheGc->CancelClippingRect(); + TheGc->DiscardBrushPattern(); + TheGc->CancelClippingRegion(); + TheGc->Reset(); + TheGc->SetOrigin(TPoint(0,0)); + TheGc->SetUnderlineStyle(EUnderlineOff); + TheGc->SetStrikethroughStyle(EStrikethroughOff); + TheGc->SetWordJustification(1,2); + TheGc->SetCharJustification(1,2); + TheGc->UseFont(font); + TheGc->DrawText(KBuffText,TRect(50,0,100,50),10,CGraphicsContext::ELeft,0); + TheGc->DrawTextVertical(KBuffText,TPoint(170,20),EFalse); + TheGc->DrawTextVertical(KBuffText,TRect(120,20,150,100),5,EFalse,CGraphicsContext::ELeft,0); + TheGc->MoveTo(TPoint(25,150)); + TheGc->MoveBy(TPoint(5,5)); + TheGc->DrawLineTo(TPoint(35,160)); + TheGc->DrawLine(TPoint(35,160),TPoint(25,150)); + TheGc->DrawLineBy(TPoint(15,6)); + TheGc->Plot(TPoint(5,5)); + TheGc->DrawArc(TRect(0,80,10,90),TPoint(0,85),TPoint(10,85)); + TheGc->DrawEllipse(TRect(0,90,10,100)); + TheGc->DrawRoundRect(TRect(30,80,50,100),TSize(5,5)); + TheGc->DrawBitmap(TPoint(150,150),bitmap); + TheGc->DrawBitmap(TRect(160,160,170,170), bitmap); + TheGc->DrawBitmap(TRect(175,175,180,180), bitmap, TRect(0,5,5,10)); + TheGc->DrawBitmapMasked(TRect(185,185,190,190), bitmap, TRect(0,50,5,55),bitmapMask,EFalse); + TheGc->DrawBitmapMasked(TRect(195,195,200,200), bitmapWs, TRect(0,50,5,55),bitmapWsMask,EFalse); + TheGc->DrawPolyLine(polyPoints); + TheGc->DrawPolyLine(&polyPoints->At(0), 3); + TheGc->DrawPolygon(polyPoints, CGraphicsContext::EWinding); + TheGc->DrawPolygon(&polyPoints->At(0), 3, CGraphicsContext::EAlternate); +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA + TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + TheGc->SetBrushColor(KRgbRed); + TheGc->SetPenColor(KRgbRed); + TheGc->DrawRect(TRect(30, 40, 32, 42)); +#endif + TheGc->DiscardFont(); + TheGc->Deactivate(); + BaseWin->Win()->EndRedraw(); + TheClient->Flush(); + TheClient->WaitForRedrawsToFinish(); + + //Check the text drawn on base and test windows. + TBool err = CheckRect(BaseWin, TestWin, TRect(0, 0, BaseWin->Size().iWidth, BaseWin->Size().iHeight), _L("CTGc::TestCommandBufferL()")); + if (err) + { + INFO_PRINTF1(_L("The CheckRect function returned error.")); + } + delete bitmap; + INFO_PRINTF1(_L("bitmap deleted.")); + delete bitmapMask; + INFO_PRINTF1(_L("bitmapMask deleted.")); + delete bitmapWs; + INFO_PRINTF1(_L("bitmapWs deleted.")); + delete bitmapWsMask; + INFO_PRINTF1(_L("bitmapWsMask deleted.")); + +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA + CleanupStack::PopAndDestroy(7, remoteGc); +#else + CleanupStack::PopAndDestroy(4, remoteGc); +#endif + CleanupStack::Pop();//font + INFO_PRINTF1(_L("CleanupStack popped.")); + TheClient->iScreen->ReleaseFont(font); + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-0482 +@SYMPREQ 1841 +@SYMTestCaseDesc Play empty command buffer. +@SYMTestPriority Medium +@SYMTestStatus Implemented +@SYMTestActions +@SYMTestExpectedResults return KErrEof error +*/ +void CTGc::TestEmptyCommandBufferL() + { +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + CWSGraphicsRes* wsGrap = new (ELeave) CWSGraphicsRes(); + CleanupStack::PushL(wsGrap); +#endif + + CCommandBuffer* cmdBuf = CCommandBuffer::NewL(); + CleanupStack::PushL(cmdBuf); + + TheGc->Activate(*TestWin->Win()); + TheGc->Clear(); + //Play the commands on test window using command buffer +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + TInt err = cmdBuf->Play(TPoint(),TRect(TestWin->Size()),*wsGrap,*TheGc); +#else + TInt err = cmdBuf->Play(TPoint(),NULL,TRect(TestWin->Size()),TheClient->iWs,*TheGc); +#endif + if(err!=KErrEof) + { + User::Panic(_L("TestEmptyCommandBufferL"), KErrGeneral); + } + TheGc->Deactivate(); +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA + CleanupStack::PopAndDestroy(2, wsGrap); //cmdBuf, wsGrap, msgBuf and remoteGc +#else + CleanupStack::PopAndDestroy(cmdBuf); +#endif + } + +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA +/** +@SYMTestCaseID GRAPHICS-WSERV-0486 +@SYMPREQ PREQ2095 +@SYMTestCaseDesc Draw text using CWindowGc and CRemoteGc with both outline and shadow +effect on. +@SYMTestPriority High +@SYMTestStatus Implemented +@SYMTestActions Create a font with both outline and shadow effects, also use ClippingRect +and ClippingRegion. Record the commands using CRemoteGc and play the recorded commands on a +bitmap using MWsGraphicsContext. Use the same commands in CWindowGc and draw text on a +different window +@SYMTestExpectedResults Text drawn using CWindowGc and CRemoteGc(MWsGraphicsContext) should be same +*/ +void CTGc::TestCRemoteGcAndMWsGraphicsContextClippingRectL() + { + const TRect KTestRect(0, 0, TestWin->Size().iWidth, TestWin->Size().iHeight); + const TRegionFix<1> KTestRegion(KTestRect); + const TRect KClippingRect1(5, 5, TestWin->Size().iWidth-10, 90); + const TRegionFix<1> KClippingRegion(KClippingRect1); + const TRect KClippingRect2(15, 15, TestWin->Size().iWidth-10, TestWin->Size().iHeight-10); + + CWsScreenDevice* device = TheClient->iScreen; + /* + * On hardware, the first screen runs in 64K colors, but the second screen (TV OUT) + * cannot run in this mode, it instead falls back to 16M colors. We need to ensure + * that we use matching color depths for our off-screen bitmaps so that accuracy is + * not lost since we compare bitmaps from the screen versus off-screen. + */ + const TDisplayMode displayMode = device->DisplayMode(); + + _LIT(KText,"RemoteGc & MWsGraphicsContext"); + TFontSpec fSpec(KTestFontTypefaceName,23); + fSpec.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap); + fSpec.iFontStyle.SetEffects(FontEffect::EDropShadow, ETrue); + fSpec.iFontStyle.SetEffects(FontEffect::EOutline, ETrue); + + CFont *font; + User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInPixels((CFont *&)font, fSpec)); + CleanupStack::PushL(TCleanupItem(CleanUpFont, font)); + + //Record the commands using CRemoteGc + CRemoteGc* remoteGc = CRemoteGc::NewL(device); + CleanupStack::PushL(remoteGc); + remoteGc->BeginDraw(KTestRect); + //fill background with white + remoteGc->SetPenStyle(CFbsBitGc::ENullPen); + remoteGc->SetBrushStyle(CFbsBitGc::ESolidBrush); + remoteGc->SetBrushColor(KRgbWhite); + remoteGc->DrawRect(TRect(TPoint(0,0), TestWin->Size())); + remoteGc->SetPenStyle(CFbsBitGc::ESolidPen); + //Capturing the commands in remote gc + remoteGc->SetClippingRect(KClippingRect2); + remoteGc->SetClippingRegion(KClippingRegion); + remoteGc->SetBrushStyle(CFbsBitGc::ESolidBrush); + remoteGc->SetBrushColor(TRgb(0,150,150)); + remoteGc->DrawRect(TRect(TPoint(0,0), TSize(160,60))); + remoteGc->SetBrushColor(TRgb(150,100,150)); + remoteGc->DrawRect(TRect(TPoint(0,60), TSize(160,60))); + remoteGc->SetBrushColor(KRgbGreen); + remoteGc->SetShadowColor(KRgbDarkRed); + remoteGc->SetPenColor(KRgbBlack); + remoteGc->UseFont(font); + remoteGc->DrawText(KText, TPoint(2,40)); + remoteGc->DiscardFont(); + remoteGc->EndDraw(); + + RWsGraphicMsgBuf msgBuf; + CleanupClosePushL(msgBuf); + //Externalize the captured commands from remote gc in to a buffer + remoteGc->ExternalizeL(msgBuf, ETrue); + + CCommandBuffer* cmdBuf = CCommandBuffer::NewL(); + CleanupStack::PushL(cmdBuf); + //Internalize the buffer with captured commands (from CRemoteGC) + //in to CCommandBuffer + cmdBuf->InternalizeL(msgBuf.Pckg()); + + CDirectGdiDriver* theDGdiDriver = CDirectGdiDriver::Static(); + User::LeaveIfNull(theDGdiDriver); + + TSgImageInfo info; + info.iUsage = ESgUsageDirectGdiTarget | ESgUsageDirectGdiSource | ESgUsageCompositionSource; + info.iSizeInPixels = TestWin->Size(); + info.iPixelFormat = PixelFormatFromDisplayMode(displayMode); + + RSgImageCollection imageCollection; + CleanupClosePushL(imageCollection); + TInt res = imageCollection.Create(info, 1); + User::LeaveIfError(res); + RSgImage image; + CleanupClosePushL(image); + res = imageCollection.OpenImage(0, image); + User::LeaveIfError(res); + RDirectGdiImageTarget imageTarget(*theDGdiDriver); + CleanupClosePushL(imageTarget); + + res = imageTarget.Create(image); + User::LeaveIfError(res); + + CDirectGdiGcWrapper* directGdiGcWrapper = CDirectGdiGcWrapper::NewL(imageTarget); + CleanupStack::PushL(directGdiGcWrapper); + + //Dummy class created + CWSGraphicsRes* wsGrap = new (ELeave) CWSGraphicsRes(); + CleanupStack::PushL(wsGrap); + + //Play the commands on test window using command buffer + cmdBuf->Play(TPoint(),&KTestRegion,KTestRect,*wsGrap,*directGdiGcWrapper); + + //Set window back to same as test bitmap background + BaseWin->Win()->SetBackgroundColor(KRgbWhite); + + BaseWin->Win()->Invalidate(); + BaseWin->Win()->BeginRedraw(); + TheGc->Activate(*BaseWin->Win()); + TheGc->Clear(); + TheGc->SetClippingRect(KClippingRect2); + TheGc->SetClippingRegion(KClippingRegion); + TheGc->SetBrushStyle(CFbsBitGc::ESolidBrush); + TheGc->SetBrushColor(TRgb(0,150,150)); + TheGc->DrawRect(TRect(TPoint(0,0), TSize(160,60))); + TheGc->SetBrushColor(TRgb(150,100,150)); + TheGc->DrawRect(TRect(TPoint(0,60), TSize(160,60))); + TheGc->SetBrushColor(KRgbGreen); + TheGc->SetShadowColor(KRgbDarkRed); + TheGc->SetPenColor(KRgbBlack); + TheGc->UseFont(font); + //Draw the text on base window using CWindowGC + TheGc->DrawText(KText, TPoint(2, 40)); + TheGc->DiscardFont(); + TheGc->Deactivate(); + BaseWin->Win()->EndRedraw(); + TheClient->iWs.Finish(); + TheClient->WaitForRedrawsToFinish(); + + //Create a bitmap and then copy the screen to it + TRect rc(TRect(BaseWin->Win()->AbsPosition(), BaseWin->Win()->Size())); + CFbsBitmap *screenBitmap = new (ELeave) CFbsBitmap(); + User::LeaveIfError(screenBitmap->Create(rc.Size(), displayMode)); + CleanupStack::PushL(screenBitmap); + TheClient->iScreen->CopyScreenToBitmap(screenBitmap, rc); + + CFbsBitmap* bitmap = new (ELeave) CFbsBitmap; + CleanupStack::PushL(bitmap); + + image.GetInfo(info); + bitmap->Create(info.iSizeInPixels, displayMode); + TRect rect(info.iSizeInPixels); + CopyImageToBitmapL(bitmap, image, rect); + + //Test to see if the bitmap drawn to using CRemoteGc is the same as the screen copy bitmap + TInt differentPixels = 0; + res = LossyCompareBitmapRecord(*bitmap, *screenBitmap, KTestRect, EFalse, differentPixels, Logger()); + if (differentPixels != 0) + { + INFO_PRINTF2(_L(" Pixels different %d"), differentPixels); + } + TEST(res); + CleanupStack::PopAndDestroy(10, remoteGc); //screenBitmap, imageCollection, image, imageTarget, directGdiGcWrapper, cmdBuf, wsGrap, msgBuf, remoteGc, bitmap + CleanupStack::Pop();//font + TheClient->iScreen->ReleaseFont(font); + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-0487 +@SYMPREQ PREQ2095 +@SYMTestCaseDesc Draw text using CRemoteGc and DrawText(const TDesC&,const TTextParameters*,const TPoint&) +@SYMTestPriority High +@SYMTestStatus Implemented +@SYMTestActions Create a font. Draw text to a bitmap with the font using CFbsBitGc::DrawText. Draw text with the font using CFbsBitGc::DrawText. +Record the same DrawText commands using CRemoteGc and play the recorded commands on a +bitmap using MWsGraphicsContext. Compare the two bitmaps. +@SYMTestExpectedResults Text drawn using CFbsBitGc and CRemoteGc(MWsGraphicsContext) should be the same +*/ +void CTGc::TestCRemoteGcDrawTextInContextPointL() + { + CDrawTextInContextTestPoint* test = CDrawTextInContextTestPoint::NewL(); + CleanupStack::PushL(test); + test->Test(); + TEST(test->HasPassedTest()); + CleanupStack::PopAndDestroy(); //test + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-0488 +@SYMPREQ PREQ2095 +@SYMTestCaseDesc Draw text using CRemoteGc and DrawText(const TDesC&,const TTextParameters*,const TRect&,TInt,TTextAlign,TInt) +@SYMTestPriority High +@SYMTestStatus Implemented +@SYMTestActions Create a font. Draw text to a bitmap with the font using CFbsBitGc::DrawText. Draw text with the font using CFbsBitGc::DrawText. +Record the same DrawText commands using CRemoteGc and play the recorded commands on a +bitmap using MWsGraphicsContext. Compare the two bitmaps. +@SYMTestExpectedResults Text drawn using CFbsBitGc and CRemoteGc(MWsGraphicsContext) should be the same +*/ +void CTGc::TestCRemoteGcDrawTextInContextBoxL() + { + CDrawTextInContextTestBox* test = CDrawTextInContextTestBox::NewL(); + CleanupStack::PushL(test); + test->Test(); + TEST(test->HasPassedTest()); + CleanupStack::PopAndDestroy(); //test + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-0489 +@SYMPREQ PREQ2095 +@SYMTestCaseDesc Draw text using CRemoteGc and DrawTextVertical(const TDesC&,const TTextParameters*,const TPoint&) +@SYMTestPriority High +@SYMTestStatus Implemented +@SYMTestActions Create a font. Draw text to a bitmap with the font using CFbsBitGc::DrawTextVertical. Draw text with the font using CFbsBitGc::DrawText. +Record the same DrawText commands using CRemoteGc and play the recorded commands on a +bitmap using MWsGraphicsContext. Compare the two bitmaps. +@SYMTestExpectedResults Text drawn using CFbsBitGc and CRemoteGc(MWsGraphicsContext) should be the same +*/ +void CTGc::TestCRemoteGcDrawTextInContextPointVerticalL() + { + CDrawTextInContextTestPointVertical* test = CDrawTextInContextTestPointVertical::NewL(); + CleanupStack::PushL(test); + test->Test(); + TEST(test->HasPassedTest()); + CleanupStack::PopAndDestroy(); //test + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-0490 +@SYMPREQ PREQ2095 +@SYMTestCaseDesc Draw text using CRemoteGc and DrawTextVertical(const TDesC&,const TTextParameters*,const TRect&,TInt,TTextAlign,TInt) +@SYMTestPriority High +@SYMTestStatus Implemented +@SYMTestActions Create a font. Draw text to a bitmap with the font using CFbsBitGc::DrawTextVertical. Draw text with the font using CFbsBitGc::DrawText. +Record the same DrawText commands using CRemoteGc and play the recorded commands on a +bitmap using MWsGraphicsContext. Compare the two bitmaps. +@SYMTestExpectedResults Text drawn using CFbsBitGc and CRemoteGc(MWsGraphicsContext) should be the same +*/ +void CTGc::TestCRemoteGcDrawTextInContextBoxVerticalL() + { + CDrawTextInContextTestBoxVertical* test = CDrawTextInContextTestBoxVertical::NewL(); + CleanupStack::PushL(test); + test->Test(); + TEST(test->HasPassedTest()); + CleanupStack::PopAndDestroy(); //test + } +#endif //TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA + +/** +@SYMTestCaseID GRAPHICS-WSERV-0494 +@SYMDEF DEF131255 +@SYMTestCaseDesc Negative test to show that using SetBrushStyle() will not panic WServ with different + brush bitmaps. +@SYMTestPriority High +@SYMTestStatus Implemented +@SYMTestActions Four seperate panic situations are tested: + 1) + Create a regular CFbsBitmap, set as brush pattern, and set brush style to EPatternedBrush. + Draw a line to force the playback to occur. + Call Finish on the GC. + Destroy the brush bitmap. + 2) + Create a regular CFbsBitmap, set as brush pattern, and set brush style to EPatternedBrush. + Draw a line to force the playback to occur. + Destroy the brush bitmap. + Call Finish on the GC. + 3+4) + Create an extended bitmap, set as the brush pattern, and set the brush style to EPatternedBrush. + Draw a line to force the playback to occur. + Set the brush bitmap and style again. + Call Finish on the GC. + Destroy the brush bitmap. +@SYMTestExpectedResults The calls to SetBrushStyle() should not cause WServ to panic when Finish() is called. +*/ +void CTGc::TestGcSetBrushPatternL() + { + // Extended bitmap test data. + const TUint8 KTestData[] = "TEST DATA"; + const TInt KTestDataSize = sizeof(KTestData); + const TUid KTestExtendedBitmapUid = TUid::Uid(0xFFFFFFFF); + + // First try using a regular bitmap as the brush pattern. + BaseWin->Win()->Invalidate(); + BaseWin->Win()->BeginRedraw(); + TheGc->Activate(*BaseWin->Win()); + CFbsBitmap* bitmapRegular = new (ELeave) CFbsBitmap; + CleanupStack::PushL(bitmapRegular); + TInt res = bitmapRegular->Create(TSize(10,10), EColor64K); + TEST(res == KErrNone); + //Record the commands using CWindowGc. + TheGc->UseBrushPattern(bitmapRegular); + TheGc->SetBrushStyle(CGraphicsContext::EPatternedBrush); + // DrawLine() is only used here to force playback of the commands. + TheGc->DrawLine(TPoint(0,0), TPoint(1,1)); + TheGc->Deactivate(); + BaseWin->Win()->EndRedraw(); + TheClient->iWs.Finish(); + CleanupStack::PopAndDestroy(1, bitmapRegular); + + // Secondly, try using a regular bitmap as the brush pattern, but deleting the bitmap + // before calling Finish(). + BaseWin->Win()->Invalidate(); + BaseWin->Win()->BeginRedraw(); + TheGc->Activate(*BaseWin->Win()); + bitmapRegular = new (ELeave) CFbsBitmap; + CleanupStack::PushL(bitmapRegular); + res = bitmapRegular->Create(TSize(10,10), EColor64K); + TEST(res == KErrNone); + //Record the commands using CWindowGc. + TheGc->UseBrushPattern(bitmapRegular); + TheGc->SetBrushStyle(CGraphicsContext::EPatternedBrush); + TheGc->DrawLine(TPoint(0,0), TPoint(1,1)); + CleanupStack::PopAndDestroy(1, bitmapRegular); + TheGc->Deactivate(); + BaseWin->Win()->EndRedraw(); + TheClient->iWs.Finish(); + + // Thirdly, try using an extended bitmap (which is unsupported by DirectGDI) as + // the brush pattern. + BaseWin->Win()->Invalidate(); + BaseWin->Win()->BeginRedraw(); + TheGc->Activate(*BaseWin->Win()); + // Create a dummy extended bitmap to use as a brush bitmap. + // This is unsupported by the default implementation of DirectGDI. + CFbsBitmap* bitmapExtended = new (ELeave) CFbsBitmap; + CleanupStack::PushL(bitmapExtended); + res = bitmapExtended->CreateExtendedBitmap(TSize(10,10), EColor64K, KTestExtendedBitmapUid, KTestData, KTestDataSize); + TEST(res == KErrNone); + //Record the commands using CWindowGc. + TheGc->UseBrushPattern(bitmapExtended); + TheGc->SetBrushStyle(CGraphicsContext::EPatternedBrush); + TheGc->DrawLine(TPoint(0,0), TPoint(100,100)); + TheGc->UseBrushPattern(bitmapExtended); + // Forth, do it twice so that we test the state commands and the drawops commands. + TheGc->SetBrushStyle(CGraphicsContext::EPatternedBrush); + TheGc->DrawLine(TPoint(0,0), TPoint(100,100)); + TheGc->Deactivate(); + BaseWin->Win()->EndRedraw(); + TheClient->iWs.Finish(); + CleanupStack::PopAndDestroy(1, bitmapExtended); + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-0576 +@SYMDEF +@SYMTestCaseDesc Checks window server is still able to draw a bitmap, even after the client has released its handle to the bitmap. +@SYMTestPriority High +@SYMTestStatus Implemented +@SYMTestActions - Draw the bitmap to TestWin (keeping the window hidden) + - Delete the bitmap + - Show TestWin to cause it to be drawn on screen (after the bitmap has been deleted) + - Draw the same bitmap (same image, different bitmap object instance) to BaseWin + - Compare contents of TestWin with BaseWin +@SYMTestExpectedResults TestWin and BaseWin should both show the bitmap. +*/ +void CTGc::TestGcDeleteBitmap1L() + { + CFbsBitmap* bitmap = new (ELeave) CFbsBitmap; + CleanupStack::PushL(bitmap); + TInt ret = bitmap->Load(TEST_BITMAP_NAME,0); + TEST(ret == KErrNone); + + // send drawing to hidden window + TestWin->SetVisible(EFalse); + TestWin->Win()->Invalidate(); + TestWin->Win()->BeginRedraw(); + TheGc->Activate(*TestWin->Win()); + TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + TheGc->SetDrawMode(CGraphicsContext::EDrawModePEN); + TheGc->SetBrushColor(TRgb(255, 0, 0)); + TheGc->Clear(); + TheGc->BitBlt(TPoint(0,0), bitmap); + CleanupStack::PopAndDestroy(bitmap); // before the bitmap is actually deleted, WsFbsDestroyCallBack flushes the command buffer to ensure the bitmap is duplicated in the window server thread + bitmap = NULL; + TheGc->Deactivate(); + TestWin->Win()->EndRedraw(); + TheClient->iWs.Flush(); // calling Flush rather than Finish, as we don't need to wait for any drawing to happen (as the window is currently hidden) + + // make window visible (forcing it to draw) + TestWin->SetVisible(ETrue); + TheClient->iWs.Finish(); // ensure the bitmap has been drawn on test win + + // window server should have duplicated the bitmap when the BitBlt was added to the redraw store, so drawing + // the window now (by making it visible above) should display the bitmap on screen, even + // though we've deleted it in this thread + + // now create the bitmap again, and draw it to the base win (for comparison with test win) + bitmap = new (ELeave) CFbsBitmap; + CleanupStack::PushL(bitmap); + ret = bitmap->Load(TEST_BITMAP_NAME,0); + TEST(ret == KErrNone); + BaseWin->SetVisible(ETrue); + BaseWin->Win()->Invalidate(); + BaseWin->Win()->BeginRedraw(); + TheGc->Activate(*BaseWin->Win()); + TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + TheGc->SetDrawMode(CGraphicsContext::EDrawModePEN); + TheGc->SetBrushColor(TRgb(255, 0, 0)); + TheGc->Clear(); + TheGc->BitBlt(TPoint(0,0), bitmap); + TheGc->Deactivate(); + BaseWin->Win()->EndRedraw(); + TheClient->iWs.Finish(); // ensure the bitmap has been drawn on base win + + CleanupStack::PopAndDestroy(bitmap); + + // the test bitmap should be shown in both base win and test win, so we now check that the + // contents of base win and test win are the same + CheckRect(BaseWin, TestWin, TRect(0, 0, BaseWin->Size().iWidth, BaseWin->Size().iHeight), _L("CTGc::TestGcDeleteBitmap1L()")); + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-0577 +@SYMDEF +@SYMTestCaseDesc Check window server is still able to use a bitmap required by window drawing, even + after the client has released its handle to the bitmap. Also check window server + releases the bitmap, when it's no longer used by window drawing. +@SYMTestPriority High +@SYMTestStatus Implemented +@SYMTestActions - Clean BaseWin and TestWin from content that has been left over from previous test + - Draw test bitmap to TestWin + - Delete the bitmap + - Using a different bitmap object instance, duplicate bitmap (the bitmap is still used by window drawing) + - Delete the bitmap + - Draw new content to TestWin, so that previously drawn bitmap is covered + - Duplicate bitmap (the bitmap is no longer used by window drawing) +@SYMTestExpectedResults Bitmap duplication succeeds, when the bitmap used by window drawing, whereas + bitmap duplication fails, when the bitmap is no longer used by window drawing. +*/ +void CTGc::TestGcDeleteBitmap2L() + { + //send new drawing to test and base windows, in order to cover + //any content has been left on them (through previous test) + BaseWin->SetVisible(ETrue); + BaseWin->Win()->Invalidate(); + BaseWin->Win()->BeginRedraw(); + TheGc->Activate(*BaseWin->Win()); + TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + TheGc->SetDrawMode(CGraphicsContext::EDrawModePEN); + TheGc->SetBrushColor(TRgb(0, 0, 255)); + TheGc->Clear(); + TheGc->Deactivate(); + BaseWin->Win()->EndRedraw(); + + TestWin->SetVisible(ETrue); + TestWin->Win()->Invalidate(); + TestWin->Win()->BeginRedraw(); + TheGc->Activate(*TestWin->Win()); + TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + TheGc->SetDrawMode(CGraphicsContext::EDrawModePEN); + TheGc->SetBrushColor(TRgb(0, 0, 255)); + TheGc->Clear(); + TheGc->Deactivate(); + TestWin->Win()->EndRedraw(); + + TheClient->iWs.Flush(); + TheClient->iWs.Finish(); + + //load test bitmap + CFbsBitmap* bitmap = new (ELeave) CFbsBitmap; + CleanupStack::PushL(bitmap); + TInt ret = bitmap->Load(_L("Z:\\WSTEST\\TESTCIRCLES.MBM"),0); + TEST(ret == KErrNone); + TInt bitmapHandle = bitmap->Handle(); + + //send bitmap drawing to test window + TestWin->Win()->Invalidate(); + TestWin->Win()->BeginRedraw(); + TheGc->Activate(*TestWin->Win()); + TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + TheGc->SetDrawMode(CGraphicsContext::EDrawModePEN); + TheGc->SetBrushColor(TRgb(0, 255, 0)); + TheGc->Clear(); + TheGc->BitBlt(TPoint(0,0), bitmap); + TheGc->Deactivate(); + TestWin->Win()->EndRedraw(); + + CleanupStack::PopAndDestroy(bitmap); + + TheClient->iWs.Flush(); + TheClient->iWs.Finish(); + + //using a new bitmap object instance check that wserv can still duplicate test bitmap (even though + //the initial bitmap object is deleted) , since there is a window segment using it + bitmap = new (ELeave) CFbsBitmap; + CleanupStack::PushL(bitmap); + ret = bitmap->Duplicate(bitmapHandle); + TEST(ret == KErrNone); + CleanupStack::PopAndDestroy(bitmap); + + //send new drawing to test window, in order to cover the bitmap that was previously drawn + TestWin->Win()->Invalidate(); + TestWin->Win()->BeginRedraw(); + TheGc->Activate(*TestWin->Win()); + TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + TheGc->SetDrawMode(CGraphicsContext::EDrawModePEN); + TheGc->SetBrushColor(TRgb(0, 0, 255)); + TheGc->Clear(); + TheGc->Deactivate(); + TestWin->Win()->EndRedraw(); + + TheClient->iWs.Flush(); + TheClient->iWs.Finish(); + + //check that wserv can't duplicate test bitmap, since no window segment uses it any more + bitmap = new (ELeave) CFbsBitmap; + CleanupStack::PushL(bitmap); + ret = bitmap->Duplicate(bitmapHandle); + TEST(ret != KErrNone); + CleanupStack::PopAndDestroy(bitmap); + } + +void CTGc::RunTestCaseL(TInt /*aCurTestCase*/) + { + ((CTGcStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); + switch(++iTest->iState) + { + case 1: + ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0437")); + iTest->LogSubTest(_L("CRemoteGc&CWindowGc, outline and shadow text")); + TestOutlineAndShadowL(); + break; + case 2: + ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0471")); + iTest->LogSubTest(_L("Test GC clip rect and origin attributes.")); + TestGcClipRectOrigin(); + break; + case 3: + ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0469")); + iTest->LogSubTest(_L("CRemoteGc&CWindowGc, reset with background colour")); + TestResetWithBackgroundColorL(); + break; + case 4: + ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0481")); + iTest->LogSubTest(_L("CRemoteGc&CCommandBuffer, coverage tests")); + TestCommandBufferL(); + break; + case 5: + ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0482")); + iTest->LogSubTest(_L("CCommandBuffer, coverage tests")); + TestEmptyCommandBufferL(); + break; + case 6: + ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0494")); + iTest->LogSubTest(_L("CWindowGc, Brush Pattern test")); + TestGcSetBrushPatternL(); + break; + case 7: + ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0576")); + iTest->LogSubTest(_L("CWindowGc, delete bitmap 1")); + TestGcDeleteBitmap1L(); + break; + case 8: + ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0577")); + iTest->LogSubTest(_L("CWindowGc, delete bitmap 2")); + TestGcDeleteBitmap2L(); + break; +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA + case 9: + ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0471")); + iTest->LogSubTest(_L("Test GC clip rect and origin attributes.")); + TestGcClipRectOrigin(); + break; + case 10: + ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0469")); + iTest->LogSubTest(_L("CRemoteGc&CWindowGc, reset with background colour")); + TestResetWithBackgroundColorL(); + break; + case 11: + ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0486")); + iTest->LogSubTest(_L("CRemoteGc&MWsGraphicsContext, clipping rect test")); + TestCRemoteGcAndMWsGraphicsContextClippingRectL(); + break; + case 12: + ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0487")); + iTest->LogSubTest(_L("CRemoteGc, DrawTextInContext Position test")); + TestCRemoteGcDrawTextInContextPointL(); + break; + case 13: + ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0488")); + iTest->LogSubTest(_L("CRemoteGc, DrawTextInContext ClipRect test")); + TestCRemoteGcDrawTextInContextBoxL(); + break; + case 14: + ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0489")); + iTest->LogSubTest(_L("CRemoteGc, DrawTextInContext Pos Vertical test")); + TestCRemoteGcDrawTextInContextPointVerticalL(); + break; + case 15: + ((CTGcStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0490")); + iTest->LogSubTest(_L("CRemoteGc, DrawTextInContext ClipRect Vert test")); + TestCRemoteGcDrawTextInContextBoxVerticalL(); + break; +#endif //TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA + default: + ((CTGcStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + ((CTGcStep*)iStep)->CloseTMSGraphicsStep(); + TestComplete(); + break; + } + ((CTGcStep*)iStep)->RecordTestResultL(); + } + +__CONSTRUCT_STEP__(Gc) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/tgc.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/tgc.h Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,199 @@ +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef __TGC_H__ +#define __TGC_H__ + +#include "AUTO.H" +#include "TGraphicsHarness.h" +#include +#include + +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA +/* + * The following classes are only required for the RemoteGc DrawText tests: . + * CDrawTextInContextTest : is the Abstract base class + * CDrawTextInContextTestPoint : Test DrawText(const TDesC&,const TTextParameters*,const TPoint&) + * CDrawTextInContextTestBox : Test DrawText(const TDesC&,const TTextParameters*,const TRect&,TInt,TTextAlign,TInt) + * CDrawTextInContextTestPointVertical : Test DrawTextVertical(const TDesC&,const TTextParameters*,const TPoint&) + * CDrawTextInContextTestBoxVertical : Test DrawTextVertical(const TDesC&,const TTextParameters*,const TRect&,TInt,TTextAlign,TInt) + */ +class CDirectGdiGcWrapper; +class CRemoteGc; +class CCommandBuffer; +class CWSGraphicsRes; +class RDirectGdiImageTarget; + +const TSize KBitmapSize(620, 240); +const TRect KBitmapRect(TPoint(0,0),TSize(620, 240)); +const TRegionFix<1> KBitmapRegion(KBitmapRect); + +//CDrawTextInContextTest +class CDrawTextInContextTest : public CBase + { +public: + void Test(); + TBool HasPassedTest(); +protected: + CDrawTextInContextTest(); + ~CDrawTextInContextTest(); + void BaseConstructL(); + virtual void DoDrawTextBitGc() = 0; + virtual void DoDrawTextRemoteGc() = 0; +protected: + CFont *iFont; + CGraphicsContext::TTextParameters iParam; + TPtrC iText; + + //For reference bitmap + CFbsBitmap* iRefBitmap; + CFbsBitmapDevice* iRefDevice; + CFbsBitGc* iRefBitGc; + + //For CDirectGdiGcWrapper + RSgImage iWrapperImage; + RDirectGdiImageTarget* iWrapperImageTarget; + RSgImageCollection iWrapperImageCollection; + CDirectGdiGcWrapper* iDirectGdiGcWrapper; + + + //For CRemoteGc + CRemoteGc* iRemoteGc; + RWsGraphicMsgBuf iMsgBuf; + CCommandBuffer* iCommandBuffer; + CWSGraphicsRes* iWsGraphicRes; + TPoint iOffset; + + //Test result + TBool iHasPassedTest; + }; + +//CDrawTextInContextTestPoint +class CDrawTextInContextTestPoint : public CDrawTextInContextTest + { +public: + static CDrawTextInContextTestPoint* NewL(); + ~CDrawTextInContextTestPoint(); + void DoDrawTextBitGc(); + void DoDrawTextRemoteGc(); +private: + CDrawTextInContextTestPoint(); + void ConstructL(); +private: + TPoint iPosition; + }; + +//CDrawTextInContextTestBox +class CDrawTextInContextTestBox : public CDrawTextInContextTest + { +public: + static CDrawTextInContextTestBox* NewL(); + ~CDrawTextInContextTestBox(); + void DoDrawTextBitGc(); + void DoDrawTextRemoteGc(); +private: + CDrawTextInContextTestBox(); + void ConstructL(); +private: + TRect iClipFillRect; + TInt iBaselineOffset; + CGraphicsContext::TTextAlign iTTextAlign; + }; + +//CDrawTextInContextTestPointVertical +class CDrawTextInContextTestPointVertical : public CDrawTextInContextTest + { +public: + static CDrawTextInContextTestPointVertical* NewL(); + ~CDrawTextInContextTestPointVertical(); + void DoDrawTextBitGc(); + void DoDrawTextRemoteGc(); +private: + CDrawTextInContextTestPointVertical(); + void ConstructL(); +private: + TPoint iPosition; + TBool iUp; + }; + +//CDrawTextInContextTestBoxVertical +class CDrawTextInContextTestBoxVertical : public CDrawTextInContextTest + { +public: + static CDrawTextInContextTestBoxVertical* NewL(); + ~CDrawTextInContextTestBoxVertical(); + void DoDrawTextBitGc(); + void DoDrawTextRemoteGc(); +private: + CDrawTextInContextTestBoxVertical(); + void ConstructL(); +private: + TRect iClipFillRect; + TInt iBaselineOffset; + TBool iUp; + CGraphicsContext::TTextAlign iTTextAlign; + }; + +#endif // TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA + +class CTGc : public CTWsGraphicsBase + { +public: + CTGc(CTestStep* aStep); + ~CTGc(); + void ConstructL(); + void TestOutlineAndShadowL(); + void TestGcClipRectOrigin(); + void TestResetWithBackgroundColorL(); + void TestCommandBufferL(); + void TestEmptyCommandBufferL(); + void TestGcSetBrushPatternL(); + void TestGcDeleteBitmap1L(); + void TestGcDeleteBitmap2L(); +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA + void TestCRemoteGcAndMWsGraphicsContextClippingRectL(); + void TestCRemoteGcDrawTextInContextPointL(); + void TestCRemoteGcDrawTextInContextBoxL(); + void TestCRemoteGcDrawTextInContextPointVerticalL(); + void TestCRemoteGcDrawTextInContextBoxVerticalL(); +#endif + +protected: + void TestGcClipRectOrigin_DrawContent(TestWindow& aWindow, TBool bActivateBeforeRedraw = ETrue); + +//from CTWsGraphicsBase + virtual void RunTestCaseL(TInt aCurTestCase); +private: + CTestBase *iTest; + }; + +class CTGcStep : public CTGraphicsStep + { +public: + CTGcStep(); +protected: + //from CTGraphicsStep + virtual CTGraphicsBase* CreateTestL(); + }; + +_LIT(KTGcStep,"TGc"); + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/tmultiptrevent.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/tmultiptrevent.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,4842 @@ +// Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Multi pointer and Z-coordinate test code +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef __INIPARSER_H__ +#define __INIPARSER_H__ +#endif // __INIPARSER_H__ + +#include "PARSEINIDATA.H" +#include "tmultiptrevent.h" +#include +#include + +//#define FAILLOG 1 // Uncomment this code to get detailed log +#define TESTMULTIPOINTER 1 // Comment this line to get detailed log without testing + +_LIT(KMultiPtrPluginDll, "multiptrclick.dll"); + +const TInt KErrDescSize = 128; +const TInt KMaxQueueSize = 32; // Queue size of wserv. In any test we cannot test more than MaxQueueSize events. + +LOCAL_C void DestroyAnim(TAny* aAnim) + { + (static_cast(aAnim))->Destroy(); + } + + +//CTMultiPtrEventBuffer +CTMultiPtrEventBuffer::CTMultiPtrEventBuffer(RWsSession *aWs, CTMultiPtrEventTest *aTest, CTMultiPtrEventClient* aClient) + : CTEvent(aWs), iTest(aTest), iClient(aClient) + { + } + +void CTMultiPtrEventBuffer::ConstructL() + { + CTEventBase::Construct(); + iEventBuffer.SetLengthL(EEventBufferSize); + iMovePtsBuffer.SetLengthL(EMovePtsBuffer); + } + +void CTMultiPtrEventBuffer::AddExpectedEvent(TWsEvent &aEvent) + { + iEventBuffer.Add(&aEvent); + } + +void CTMultiPtrEventBuffer::AddExpectedMovePtEvent(TPoint &aMovePt) + { + iMovePtsBuffer.Add(&aMovePt); + } + +TInt CTMultiPtrEventBuffer::EventsRemaining() + { + return iEventBuffer.Count(); + } + +void CTMultiPtrEventBuffer::GetMoveBufferAndCompareL() + { + TBuf8 buf; + iClient->ParentWin()->BaseWin()->RetrievePointerMoveBuffer(buf); + + TUint bufferSize = buf.Length(); + TUint numLoop = bufferSize/sizeof(TPoint); + + if (iMovePtsBuffer.Count() != numLoop) + { +#if defined(FAILLOG) + TLogMessageText logText; + _LIT(KPointerNumber, "Actual number of move/drag buffer points from Wserv = %d Expected number of move/drag buffer points = %d "); + logText.Format(KPointerNumber, numLoop, iMovePtsBuffer.Count()); + iTest->LOG_MESSAGE(logText); +#endif + TestL(EFalse); + } + + TPoint wsPoint; + TPoint expPoint; + TUint8* BasePtr = const_cast(buf.Ptr()); + for (TUint count = 0; count < numLoop; count++) + { + wsPoint = *(reinterpret_cast(BasePtr)); + iMovePtsBuffer.Remove(&expPoint); + if (wsPoint != expPoint) + { +#if defined(FAILLOG) + TLogMessageText logText; + _LIT(KMoveBufferPoint, "Actual move/drag buffer point from Wserv = ([%d], [%d]) Expected move/drag buffer point = ([%d], [%d])"); + logText.Format(KMoveBufferPoint, wsPoint.iX, wsPoint.iY, expPoint.iX, expPoint.iY); + iTest->LOG_MESSAGE(logText); +#endif + TestL(EFalse); + } + BasePtr = BasePtr + sizeof(TPoint); + } + } + + +#define TESTXL(expr1, oper, expr2, event, expected) \ + TestL(expr1 oper expr2, expr1, expr2, #oper, #expr1 ## #oper ## #expr2, \ + event, expected, __FILE__, __LINE__); + +// Main function which gets the event, checks with the event in buffer +// Then calls function NextSetOfEventsL for running other tests of a particualar test case +void CTMultiPtrEventBuffer::doRunL() + { + // Get the event from wserv + TWsEvent wsEvent; + iWs->GetEvent(wsEvent); + + TWsEvent expectedEvent; + TInt wsType=wsEvent.Type(); + if (wsEvent.Type()==EEventNull) + { + TESTXL(wsEvent.Handle(), ==, 0, &wsEvent, NULL); + goto End; + } + // This code is for running successive anim test code + if (wsEvent.Type()==EEventPointer && wsEvent.Pointer()->iType==TPointerEvent::ESwitchOn) + goto End; + // if this is called accidentally + if (iEventBuffer.Count()==0 && wsType==EEventFocusGained) + goto End; + + iEventBuffer.Remove(&expectedEvent); + iEventCount++; + + if (wsEvent.Type() == EEventPointerBufferReady) + { + GetMoveBufferAndCompareL(); +#if defined(FAILLOG) + TLogMessageText logText; + _LIT(KEventHandle, "Actual Window Handle from Wserv = %d Expected Window Handle = %d "); + logText.Format(KEventHandle, wsEvent.Handle(), expectedEvent.Handle()); + iTest->LOG_MESSAGE(logText); +#endif +#if defined(TESTMULTIPOINTER) + TESTXL(wsEvent.Handle(), ==, expectedEvent.Handle(), &wsEvent, &expectedEvent); +#endif + goto End; + } + + // Test wsEvent and expected event have same handle, position and type. +#if defined(FAILLOG) + { + TLogMessageText logText; + _LIT(KEventCountCheck, "Checking event number = %d"); + logText.Format(KEventCountCheck, iEventCount); + iTest->LOG_MESSAGE(logText); + _LIT(KEventType, "Actual Event type from Wserv = %d Expected Event Type = %d "); + logText.Format(KEventType, wsEvent.Type(), expectedEvent.Type()); + iTest->LOG_MESSAGE(logText); + } +#endif + +#if defined(TESTMULTIPOINTER) + TESTXL(wsEvent.Type(), ==, expectedEvent.Type(), &wsEvent, &expectedEvent); +#endif + // Test pointer number for Enter/Exit events + if (wsType == EEventPointerEnter || wsType == EEventPointerExit) + { +#if defined(FAILLOG) + TLogMessageText logText; + _LIT(KPointerNumber, "Actual PointerNumber for Enter/Exit event from Wserv = %d Expected PointerNumber for Enter/Exit event = %d "); + logText.Format(KPointerNumber, *wsEvent.Int(), *expectedEvent.Int()); + iTest->LOG_MESSAGE(logText); +#endif +#if defined(TESTMULTIPOINTER) + TESTXL(*wsEvent.Int(), ==, *expectedEvent.Int(), &wsEvent, &expectedEvent); +#endif + } + + // Test only if it is a Pointer event + if (wsType==EEventPointer) + { + TAdvancedPointerEvent* expectedPointerEvent=expectedEvent.Pointer(); + TAdvancedPointerEvent* actualPointerEvent=wsEvent.Pointer(); +#if defined(FAILLOG) + TLogMessageText logText; + _LIT(KEventHandle, "Actual Window Handle from Wserv = %d Expected Window Handle = %d "); + logText.Format(KEventHandle, wsEvent.Handle(), expectedEvent.Handle()); + iTest->LOG_MESSAGE(logText); +#endif +#if defined(TESTMULTIPOINTER) + TESTXL(wsEvent.Handle(), ==, expectedEvent.Handle(), &wsEvent, &expectedEvent); +#endif +#if defined(FAILLOG) + _LIT(KPointerType, "Actual PointerType from Wserv = %d Expected PointerType = %d "); + logText.Format(KPointerType, actualPointerEvent->iType, expectedPointerEvent->iType); + iTest->LOG_MESSAGE(logText); +#endif +#if defined(TESTMULTIPOINTER) + TESTXL(actualPointerEvent->iType, ==, expectedPointerEvent->iType, &wsEvent, &expectedEvent); +#endif +#if defined(FAILLOG) + _LIT(KPointerPosition, "Actual PointerPosition from Wserv = (%d, %d) Expected PointerPosition = (%d, %d) "); + logText.Format(KPointerPosition, actualPointerEvent->iPosition.iX, actualPointerEvent->iPosition.iY, expectedPointerEvent->iPosition.iX, expectedPointerEvent->iPosition.iY); + iTest->LOG_MESSAGE(logText); +#endif +#if defined(TESTMULTIPOINTER) + TESTXL(actualPointerEvent->iPosition, ==, expectedPointerEvent->iPosition, &wsEvent, &expectedEvent); +#endif +#if defined(FAILLOG) + _LIT(KPointerNumber, "Actual PointerNumber from Wserv = %d Expected PointerNumber = %d "); + logText.Format(KPointerNumber, actualPointerEvent->PointerNumber(), expectedPointerEvent->PointerNumber()); + iTest->LOG_MESSAGE(logText); +#endif +#if defined(TESTMULTIPOINTER) + TESTXL(actualPointerEvent->PointerNumber(), ==, expectedPointerEvent->PointerNumber(), &wsEvent, &expectedEvent); +#endif +#if defined(FAILLOG) + _LIT(KPointerProximity, "Actual PointerProximity from Wserv = %d Expected PointerProximity = %d "); + logText.Format(KPointerProximity, actualPointerEvent->Proximity(), expectedPointerEvent->Proximity()); + iTest->LOG_MESSAGE(logText); +#endif +#if defined(TESTMULTIPOINTER) + TESTXL(actualPointerEvent->Proximity(), ==, expectedPointerEvent->Proximity(), &wsEvent, &expectedEvent); +#endif +#if defined(FAILLOG) + _LIT(KPointerPressure, "Actual PointerPressure from Wserv = %d Expected PointerPressure = %d "); + logText.Format(KPointerPressure, actualPointerEvent->Pressure(), expectedPointerEvent->Pressure()); + iTest->LOG_MESSAGE(logText); +#endif +#if defined(TESTMULTIPOINTER) + TESTXL(actualPointerEvent->Pressure(), ==, expectedPointerEvent->Pressure(), &wsEvent, &expectedEvent); +#endif +#if defined(FAILLOG) + _LIT(KPointerModifier, "Actual Modifier value from Wserv = 0x%08x Expected Modfier value = 0x%08x "); + logText.Format(KPointerModifier, actualPointerEvent->iModifiers, expectedPointerEvent->iModifiers); + iTest->LOG_MESSAGE(logText); +#endif +#if defined(TESTMULTIPOINTER) + TESTXL((actualPointerEvent->iModifiers&expectedPointerEvent->iModifiers), ==, expectedPointerEvent->iModifiers, &wsEvent, &expectedEvent); +#endif + } +End: + // Call NextSetOfEvents() only for primary client + if (iEventBuffer.Count()==0 && !iClient->IsSecondaryClient()) + { + iTest->NextSetOfEventsL(); // Cannot Leave + } + + // If this is for secondary client and active scheduler(nested loop) has started, this code stops that scheduler + if (iEventBuffer.Count()==0 && iClient->IsSecondaryClient() && iNestedLoopStarted) + { + iNestedLoopStarted = EFalse; + CActiveScheduler::Stop(); + } + } + +void CTMultiPtrEventBuffer::TestL(TInt aTest) + { + if (!aTest) + { + iTest->Failed(); + User::Leave(ETestFailed); + } + } + +static void DumpEvent(const char *aName, const TWsEvent *aEvent) + { + // aEvent may be NULL - if it isn't NULL, we print it's data. + if (aEvent) + { + RDebug::Printf("%s:", aName); + RDebug::Printf("handle = %u", aEvent->Handle()); + RDebug::Printf("type() = %d", aEvent->Type()); + if (aEvent->Type() == EEventPointer) + { + TAdvancedPointerEvent *pointer = aEvent->Pointer(); + RDebug::Printf("pointer type = %d, position = (%d, %d)", + pointer->iType, pointer->iPosition.iX, pointer->iPosition.iY); + RDebug::Printf("PointerNumber() = %d, proximity=%d, pressure=%d", + pointer->PointerNumber(), pointer->Proximity(), pointer->Pressure()); + RDebug::Printf("modifiers = 0x%08x", pointer->iModifiers); + } + else + { + RDebug::Printf("Not a pointer event, event type"); + } + } + else + { + // aEvent is NULL, just let us know it is. + RDebug::Printf("%s: is NULL which means not applicapable"); + } + } + +void CTMultiPtrEventBuffer::TestL(TInt aTest, TInt aVal1, TInt aVal2, const char *aOper, const char *aTestStr, + const TWsEvent *aEvent, const TWsEvent *aExpected, const char *aFile, TUint aLine) + { + if (!aTest) + { + RDebug::Printf("Expression %d %s %d [%s] (=%d) failed [call from %s:%d]", aVal1, aOper, aVal2, aTestStr, aTest, aFile, aLine); + DumpEvent("actual", aEvent); + DumpEvent("expected", aExpected); + iTest->Failed(); + User::Leave(ETestFailed); + } + } + + +void CTMultiPtrEventBuffer::TestL(TInt aTest, TPoint aVal1, TPoint aVal2, const char *oper, const char *aTestStr, + const TWsEvent *aEvent, const TWsEvent *aExpected, const char *aFile, TUint aLine) + { + if (!aTest) + { + RDebug::Printf("Expression (%d, %d) %s (%d, %d) [%s] (=%d) failed [call from %s:%d]", + aVal1.iX, aVal1.iY, oper, aVal2.iX, aVal2.iY, aTestStr, aTest, aFile, aLine); + DumpEvent("actual", aEvent); + DumpEvent("expected", aExpected); + iTest->Failed(); + User::Leave(ETestFailed); + } + } + +//CTMultiPtrEventClient +CTMultiPtrEventClient::CTMultiPtrEventClient(CTMultiPtrEventTest *aTest, TBool aSecondaryClient) + : iTest(aTest), iSecondaryClient(aSecondaryClient) + { + } + +CTMultiPtrEventClient::~CTMultiPtrEventClient() + { + if (iWinAutoFocus1 || iWinAutoFocus2 || iGroupWinAutoFocus2 || iGroupWinAutoFocus1) + { + DeleteGroupBlankWin(); + } + delete iChildWin; + delete iParentWin; + } + +void CTMultiPtrEventClient::ConstructL() + { + CTClient::ConstructL(); + + // Create a group window and assign it iGroup + iGroup = new(ELeave) CTWindowGroup(this); + iGroup->ConstructL(); + + iParentWinSize = iScreen->SizeInPixels(); + iParentWinPos = TPoint(); + + // Change the parent window size and position for secondary client + if (iSecondaryClient) + { + iParentWinSize.iWidth /= 2; + iParentWinPos.iX = iParentWinSize.iWidth; + } + + // Create window/s for this client so that events can come to this client + iParentWin=new(ELeave) CTBlankWindow(); + iParentWin->ConstructL(*iGroup); + iParentWin->SetExt(iParentWinPos, iParentWinSize); + iParentWin->SetColor(KRgbRed); + if (iTest->TestBase()->iState != 12) + { + iParentWin->BaseWin()->EnableAdvancedPointers(); + } + iParentWin->Activate(); + + // Don't create child window for secodary client + if (!iSecondaryClient) + { + iChildWinSize = TSize(iParentWinSize.iWidth/2, iParentWinSize.iHeight); + iChildWinPos = TPoint(iParentWinSize.iWidth/2,0); + + iChildWin=new(ELeave) CTBlankWindow(); + iChildWin->ConstructL(*iGroup); + iChildWin->SetExt(iChildWinPos, iChildWinSize); + iChildWin->SetColor(KRgbRed); + iChildWin->BaseWin()->EnableAdvancedPointers(); + iChildWin->Activate(); + } + } + +void CTMultiPtrEventClient::CalculatePtrPosAndSet3Ddata(TWsEvent& aEvent, TPointerEvent::TType aType, TPoint aPos, TUint aModifiers, TInt aZ, TUint8 aPointerNumber, TUint aHandle) + { + // If in future you need to change parent position then put this in corresponding if statements + aEvent.Pointer()->iParentPosition = aPos; + + // This is for Auto foreground test + if (iTest->TestBase()->iState == 11) + { + if (TRect(iWinPosAutoFocus1, iWinSizeAutoFocus1).Contains(aPos)) + { + aPos -= iWinPosAutoFocus1; + aEvent.SetHandle((TUint)iWinAutoFocus1); + } + else if (TRect(iWinPosAutoFocus2, iWinSizeAutoFocus2).Contains(aPos)) + { + aPos -= iWinPosAutoFocus2; + aEvent.SetHandle((TUint)iWinAutoFocus2); + } + goto SETOTHERDATA; + } + + // Here simulated pointer position is w.r.t to 0,0 + // Actual pointer position is w.r.t windowPosition + if (iSecondaryClient) + { + if (TRect(iParentWinPos, TSize(iParentWinSize.iWidth, iParentWinSize.iHeight)).Contains(aPos)) + { + // Since for secondary client parent window is at half of screensize + aPos -= iParentWinPos; + aEvent.SetHandle((aHandle == 0) ? (TUint)iParentWin : aHandle); + } + } + else + { + // If sent position is on blankWindow then + if (TRect(iParentWinPos, TSize(iParentWinSize.iWidth/2, iParentWinSize.iHeight)).Contains(aPos)) + { + aEvent.SetHandle((aHandle == 0) ? (TUint)iParentWin : aHandle); + } + else // else the pointer event occured on child window + { + // if aPos < 0 then position has been generated in test code and should not be adjusted + if (aPos.iX >= 0) + { + aPos -= iChildWinPos; + } + aEvent.SetHandle((aHandle == 0) ? (TUint)iChildWin : aHandle); + } + } + +SETOTHERDATA: + aEvent.Pointer()->iType = aType; + aEvent.Pointer()->iPosition = aPos; + if(iExpectNonAdvancedPointerEvents) + { + aEvent.Pointer()->iModifiers = aModifiers; + } + else + { + aEvent.Pointer()->iModifiers = aModifiers|EModifierAdvancedPointerEvent; + aEvent.SetPointerNumber(aPointerNumber); + aEvent.SetPointerZ(aZ); + } + } + +void CTMultiPtrEventClient::AddExpectedPointerEvent(TPointerEvent::TType aType, TPoint aPos, TUint8 aPointerNumber, TUint aHandle) + { + AddExpectedPointerEvent(aType, aPos, 0, 0, aPointerNumber, aHandle); + } + +void CTMultiPtrEventClient::AddExpectedPointerEvent(TPointerEvent::TType aType, TPoint aPos, TInt aZ, TUint aModifier, TUint8 aPointerNumber, TUint aHandle) + { + TWsEvent ptrEvent; + ptrEvent.SetType(EEventPointer); + if (aType != TPointerEvent::ESwitchOn) + { + CalculatePtrPosAndSet3Ddata(ptrEvent, aType, aPos, aModifier, aZ, aPointerNumber, aHandle); + } + static_cast(iEventHandler)->AddExpectedEvent(ptrEvent); + } + +void CTMultiPtrEventClient::AddExpectedWsEvent(TEventCode aType, TInt aPointerNumber, TUint aHandle) + { + TWsEvent ptrEvent; + ptrEvent.SetType(aType); + if (aType == EEventPointerEnter || aType == EEventPointerExit) + { + *ptrEvent.Int() = aPointerNumber; + } + if (aType == EEventPointerBufferReady) + { + ptrEvent.SetHandle(aHandle); + } + static_cast(iEventHandler)->AddExpectedEvent(ptrEvent); + } + +void CTMultiPtrEventClient::AddExpectedMovePoint(TPoint aPos) + { + static_cast(iEventHandler)->AddExpectedMovePtEvent(aPos); + } + +// Create and store CTMultiPtrEventBuffer in iEventHandler +void CTMultiPtrEventClient::ConstructEventHandlerL() + { + CTMultiPtrEventBuffer* eventBufferAndHandler = new(ELeave) CTMultiPtrEventBuffer(&iWs, iTest, this); + eventBufferAndHandler->ConstructL(); + iEventHandler = eventBufferAndHandler; + } + +// Create groupwindow and blank window for AutoFocus tests +void CTMultiPtrEventClient::ConstructGroupBlankWinL() + { + iWinPosAutoFocus1 = TPoint(10,10); + iWinSizeAutoFocus1 = TSize(40,40); + + iWinPosAutoFocus2 = TPoint(50,50); + iWinSizeAutoFocus2 = TSize(80,80); + + iGroupWinAutoFocus1 = new(ELeave) CTWindowGroup(this); + iGroupWinAutoFocus1->ConstructL(); + iGroupWinAutoFocus1->GroupWin()->AutoForeground(ETrue); + iGroupWinAutoFocus1->GroupWin()->EnableFocusChangeEvents(); + + iGroupWinAutoFocus2 = new(ELeave) CTWindowGroup(this); + iGroupWinAutoFocus2->ConstructL(); + iGroupWinAutoFocus2->GroupWin()->AutoForeground(ETrue); + iGroupWinAutoFocus2->GroupWin()->EnableFocusChangeEvents(); + + iWinAutoFocus1=new(ELeave) CTBlankWindow(); + iWinAutoFocus1->ConstructL(*iGroupWinAutoFocus1); + iWinAutoFocus1->SetExt(iWinPosAutoFocus1, iWinSizeAutoFocus1); + iWinAutoFocus1->SetColor(KRgbDarkYellow); + iWinAutoFocus1->BaseWin()->EnableAdvancedPointers(); + iWinAutoFocus1->Activate(); + + iWinAutoFocus2=new(ELeave) CTBlankWindow(); + iWinAutoFocus2->ConstructL(*iGroupWinAutoFocus2); + iWinAutoFocus2->SetExt(iWinPosAutoFocus2, iWinSizeAutoFocus2); + iWinAutoFocus2->SetColor(KRgbDarkCyan); + iWinAutoFocus2->BaseWin()->EnableAdvancedPointers(); + iWinAutoFocus2->Activate(); + } + +void CTMultiPtrEventClient::DeleteGroupBlankWin() + { + delete iWinAutoFocus2; + iWinAutoFocus2 = NULL; + delete iGroupWinAutoFocus2; + iGroupWinAutoFocus2 = NULL; + delete iWinAutoFocus1; + iWinAutoFocus1 = NULL; + delete iGroupWinAutoFocus1; + iGroupWinAutoFocus1 = NULL; + } + +TBool CTMultiPtrEventClient::CheckOrdinalPosition(TInt aAutoFocusWin) + { + if (aAutoFocusWin == 1) + { + return iWinAutoFocus1->BaseWin()->OrdinalPosition() == 0; + } + else + { + return iWinAutoFocus2->BaseWin()->OrdinalPosition() == 0; + } + } + +//CTMultiPtrEventTest +CTMultiPtrEventTest::CTMultiPtrEventTest(CTestStep* aStep) + : CTWsGraphicsBase(aStep) + { + } + +CTMultiPtrEventTest::~CTMultiPtrEventTest() + { + ((CTMultiPtrEventTestStep*)iStep)->CloseTMSGraphicsStep(); + delete iMultiPtrEventClient; + DestroyAnimDllAndAnim(); + if (iPtrPluginLoaded) + { + iClick.Unload(); + } + iClick.Close(); + if (iHeap) + { + iHeap->Close(); + iChunk.Close(); + } + DeleteGroupWin(); + } + +void CTMultiPtrEventTest::ConstructL() + { + // Here check if the HAL configuration are correct if not then finish the test case + TInt ret = HAL::Get(HALData::EPointerMaxPointers, iMaxDevPointers); + if (ret != KErrNone || iMaxDevPointers < 2 || iMaxDevPointers > 8) + { + TLogMessageText logText1; + _LIT(KWrongHALConfig, "HAL configuration are incorrect. \n"); + logText1.Append(KWrongHALConfig); + LOG_MESSAGE(logText1); + TEST(EFalse); + User::Leave(ret); + } + + // Get the data by using HAL api + User::LeaveIfError(HAL::Get(HALData::EPointerMaxPointers,iMaxDevPointers)); + User::LeaveIfError(HAL::Get(HALData::EPointerNumberOfPointers,iMaxUiPointers)); + User::LeaveIfError(HAL::Get(HALData::EPointer3DMaxPressure, iMaxPressure)); + User::LeaveIfError(HAL::Get(HALData::EPointer3DPressureStep, iPressureStep)); + User::LeaveIfError(HAL::Get(HALData::EPointer3DMaxProximity, iMaxProximity)); + User::LeaveIfError(HAL::Get(HALData::EPointer3DProximityStep, iProximityStep)); + + _LIT(KWsIniFile, "z:\\system\\data\\wsini.ini"); + CIniData* iniData = CIniData::NewL(KWsIniFile, ' '); + _LIT( KWsiniYShifting, "YSHIFTING"); + iniData->FindVar(KWsiniYShifting, iYOffset); + delete iniData; + TheClient->iScreen->SetAppScreenMode(0); + TheClient->iScreen->SetScreenMode(0); + iPhysicalScreenSize = TheClient->iScreen->SizeInPixels(); + + TheGc->Activate(*BaseWin->Win()); + TheGc->SetBrushColor(TRgb::Gray16(12)); + TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + TheGc->SetPenStyle(CGraphicsContext::ENullPen); + TheGc->DrawRect(TRect(BaseWin->Win()->Size())); + TheGc->Deactivate(); + + TheGc->Activate(*TestWin->Win()); + TheGc->SetBrushColor(TRgb::Gray16(4)); + TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + TheGc->SetPenStyle(CGraphicsContext::ENullPen); + TheGc->DrawRect(TRect(TestWin->Win()->Size())); + TheGc->Deactivate(); + + TheClient->iWs.Flush(); + } + +// Create raw event setting type, X, Y, Z and pointernumber for rawevent +// use UserSvr for simulating the event +void CTMultiPtrEventTest::SimulatePointerEvent(TRawEvent::TType aType, TInt aX, TInt aY, TUint8 aPointerNumber) + { + TRawEvent rawEvent; + rawEvent.Set(aType, aX, aY+iYOffset, aPointerNumber); + UserSvr::AddEvent(rawEvent); + } + +void CTMultiPtrEventTest::SimulatePointerEvent(TRawEvent::TType aType, TInt aX, TInt aY, TInt aZ, TUint8 aPointerNumber) + { + TRawEvent rawEvent; + rawEvent.Set(aType, aX, aY+iYOffset, aZ, aPointerNumber); + UserSvr::AddEvent(rawEvent); + } + +// Simulate multipointer down and up event +void CTMultiPtrEventTest::SimulatePointerDownUp(TInt aX, TInt aY, TInt aZ, TUint8 aPointerNumber) + { + SimulatePointerEvent(TRawEvent::EButton1Down, aX, aY, aZ, aPointerNumber); + SimulatePointerEvent(TRawEvent::EButton1Up, aX, aY, aZ, aPointerNumber); + } + +void CTMultiPtrEventTest::AddExpectedKey(TInt aEventCode, TInt aScanCode, TInt aCode/*=0*/, TInt aRepeats/*=0*/, TUint aModifiers/*=0*/) + { + TPckgBuf evtPkg; + TWsEvent& event=evtPkg(); + if (aEventCode==EEventKey && aCode==0) + aCode=aScanCode; + event.SetType(aEventCode); + event.SetHandle((TUint)iMultiPtrEventClient->iGroup); + event.Key()->iCode=aCode; + event.Key()->iScanCode=aScanCode; + event.Key()->iModifiers=aModifiers; + event.Key()->iRepeats=aRepeats; + iMultiPtrEventClient->EventBuffer()->AddExpectedEvent(event); + } + +void CTMultiPtrEventTest::AddExpectedKeyDownUp(TInt aScanCode, TInt aCode/*=0*/, TInt aRepeats/*=0*/, TUint aModifiers/*=0*/) + { + __ASSERT_DEBUG(aScanCode<'a' || aScanCode>'z',AutoPanic(EAutoPanicScanCapital)); + AddExpectedKey(EEventKeyDown,aScanCode,0,aRepeats,aModifiers); + AddExpectedKey(EEventKey,aScanCode,aCode,aRepeats,aModifiers); + AddExpectedKey(EEventKeyUp,aScanCode,0,aRepeats,aModifiers); + } + +void CTMultiPtrEventTest::AddExpectedPointerEvent(TPointerEvent::TType aType, TPoint aPos, TUint8 aPointerNumber, TUint aHandle) + { + AddExpectedPointerEvent(aType, aPos, 0, 0, aPointerNumber, aHandle); + } + +void CTMultiPtrEventTest::AddExpectedPointerEvent(TPointerEvent::TType aType, TPoint aPos, TInt aZ, TUint aModifier, TUint8 aPointerNumber, TUint aHandle, TBool aSecondaryClient) + { + if (aSecondaryClient) + { + iSecMultiPtrEventClient->AddExpectedPointerEvent(aType, aPos, aZ, aModifier, aPointerNumber, aHandle); + } + else + { + iMultiPtrEventClient->AddExpectedPointerEvent(aType, aPos, aZ, aModifier, aPointerNumber, aHandle); + } + } + +void CTMultiPtrEventTest::SetExpectNonAdvancedPointerEvents(TBool aSecondaryClient) + { + if (aSecondaryClient) + { + iSecMultiPtrEventClient->SetExpectNonAdvancedPointerEvents(); + } + else + { + iMultiPtrEventClient->SetExpectNonAdvancedPointerEvents(); + } + } + +void CTMultiPtrEventTest::ClearExpectNonAdvancedPointerEvents(TBool aSecondaryClient) + { + if (aSecondaryClient) + { + iSecMultiPtrEventClient->ClearExpectNonAdvancedPointerEvents(); + } + else + { + iMultiPtrEventClient->ClearExpectNonAdvancedPointerEvents(); + } + } + +void CTMultiPtrEventTest::AddExpectedPointerDownUp(TPoint aPos, TInt aZ, TUint8 aPointerNumber) + { + AddExpectedPointerEvent(TPointerEvent::EButton1Down, aPos, aZ, 0, aPointerNumber); + AddExpectedPointerEvent(TPointerEvent::EButton1Up, aPos, aZ, 0, aPointerNumber); + } + +void CTMultiPtrEventTest::AddExpectedWsEvent(TEventCode aType, TBool aSecondaryClient, TInt aPointerNumber, TUint aHandle) + { + if (aSecondaryClient) + { + iSecMultiPtrEventClient->AddExpectedWsEvent(aType); + } + else + { + iMultiPtrEventClient->AddExpectedWsEvent(aType, aPointerNumber, aHandle); + } + } + +void CTMultiPtrEventTest::TestDragForMultiPointer(TPoint aPtrPos, TInt aPrValue, TUint8 aPointerNumber) + { + SimulatePointerEvent(TRawEvent::EButton1Down, aPtrPos.iX, aPtrPos.iY, aPrValue, aPointerNumber); + SimulatePointerEvent(TRawEvent::EPointerMove, aPtrPos.iX+2, aPtrPos.iY+1, aPrValue, aPointerNumber); + SimulatePointerEvent(TRawEvent::EButton1Up, aPtrPos.iX+2, aPtrPos.iY+1, 0, aPointerNumber); + AddExpectedPointerEvent(TPointerEvent::EButton1Down, aPtrPos, aPrValue, 0, aPointerNumber); + aPtrPos.iX += 2; aPtrPos.iY += 1; + AddExpectedPointerEvent(TPointerEvent::EDrag, aPtrPos, aPrValue, 0, aPointerNumber); + AddExpectedPointerEvent(TPointerEvent::EButton1Up, aPtrPos, 0, 0, aPointerNumber); + } + +void CTMultiPtrEventTest::SimulateAndAddLoneUpEvents(TInt aNumSimulation, TInt aNumAddition, TPoint aPos) + { + for (TInt count = 0; count < aNumSimulation; count++) + { + SimulatePointerEvent(TRawEvent::EButton1Up, aPos.iX, aPos.iY, 0, 0); + } + for (TInt count = 0; count < aNumAddition; count++) + { + AddExpectedPointerEvent(TPointerEvent::EButton1Up, aPos, 0, 0, 0); + } + } + +void CTMultiPtrEventTest::TestFilteringForMultiPointer(TBool aFiltering) + { + TPoint ptrPos; + TInt ptrNum; + TInt xInc = iPhysicalScreenSize.iWidth/iMaxDevPointers; + TInt yInc = iPhysicalScreenSize.iHeight/iMaxDevPointers; + + for (ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) + { + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, 0, ptrNum); + SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum); + if(!aFiltering) + { + AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, ptrNum); + } + AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, ptrNum); + ptrPos.iX += xInc/2; + ptrPos.iY += yInc/2; + } + + ptrPos.SetXY(0,0); + TPoint interPt = ptrPos; + for (ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) + { + SimulatePointerEvent(TRawEvent::EPointerMove, interPt.iX+2, interPt.iY+1, 0, ptrNum); + SimulatePointerEvent(TRawEvent::EPointerMove, interPt.iX+4, interPt.iY+2, 0, ptrNum); + SimulatePointerEvent(TRawEvent::EPointerMove, interPt.iX+6, interPt.iY+3, 0, ptrNum); + if(!aFiltering) + { + interPt.iX += 6; interPt.iY += 3; + AddExpectedPointerEvent(TPointerEvent::EDrag, interPt, ptrNum); + } + ptrPos.iX += xInc/2; + ptrPos.iY += yInc/2; + interPt = ptrPos; + } + + ptrPos.SetXY(0,0); + interPt = ptrPos; + for (ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) + { + interPt.iX += 6; + interPt.iY += 3; + SimulatePointerEvent(TRawEvent::EButton1Up, interPt.iX, interPt.iY, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EButton1Up, interPt, ptrNum); + ptrPos.iX += xInc/2; + ptrPos.iY += yInc/2; + interPt = ptrPos; + } + } + +void CTMultiPtrEventTest::TestGrabbingForMultiPointer(TBool aGrabbing) + { + TPoint ptrPos; + TInt ptrNum; + TInt xInc = iPhysicalScreenSize.iWidth/iMaxDevPointers; + TInt yInc = iPhysicalScreenSize.iHeight/iMaxDevPointers; + + for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) + { + SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, ptrNum); + ptrPos.iX += xInc/3; // Ensure all Button1Down events are on iParentWin + ptrPos.iY += yInc/3; + } + + ptrPos.SetXY(0,0); + ptrPos.iX += iPhysicalScreenSize.iWidth/2; // Ensure all Drag and Button1Up events are on iChildWin + ptrPos.iY += iPhysicalScreenSize.iHeight/2; + for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) + { + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, 0, ptrNum); + if(aGrabbing) + { + // CalculatePtrPosAndSet3Ddata will subtract iChildWinPos from ptrPos if pointer event occured on child window. Thus we add iChildWinPos here. + AddExpectedPointerEvent(TPointerEvent::EDrag, ptrPos+iMultiPtrEventClient->ChildWin()->Position(), ptrNum, (TUint)iMultiPtrEventClient->ParentWin()); + } + else + { + AddExpectedPointerEvent(TPointerEvent::EDrag, ptrPos, ptrNum); + } + ptrPos.iX += xInc/3; + ptrPos.iY += yInc/3; + } + + ptrPos.SetXY(0,0); + ptrPos.iX += iPhysicalScreenSize.iWidth/2; + ptrPos.iY += iPhysicalScreenSize.iHeight/2; + for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) + { + SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, ptrNum); + if(aGrabbing) + { + AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos+iMultiPtrEventClient->ChildWin()->Position(), ptrNum, (TUint)iMultiPtrEventClient->ParentWin()); + } + else + { + AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, ptrNum); + } + ptrPos.iX += xInc/3; + ptrPos.iY += yInc/3; + } + } + +void CTMultiPtrEventTest::TestCapturingForMultiPointer(TBool aAllWinGroups) + { + TPoint ptrPos; + TInt ptrNum = 0; + TInt xInc = iPhysicalScreenSize.iWidth/iMaxDevPointers; + TInt yInc = iPhysicalScreenSize.iHeight/iMaxDevPointers; + + // These are some typical values which are used only for testing purposes. + // 20mm to screen + // 50mm to screen + // 4N of pressure + // 2N of pressure + SetThresholdValues(-20,-50,4000,2000); + + iMultiPtrEventClient->ChildWin()->BaseWin()->PointerFilter(EPointerMoveEvents, 0); + + if(!aAllWinGroups) + { + for (ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) + { + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, -30, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos-iMultiPtrEventClient->ChildWin()->Position(), -30, 0, ptrNum, (TInt)iMultiPtrEventClient->ChildWin()); + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, -10, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EEnterCloseProximity, ptrPos-iMultiPtrEventClient->ChildWin()->Position(), -10, 0, ptrNum, (TInt)iMultiPtrEventClient->ChildWin()); + SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos-iMultiPtrEventClient->ChildWin()->Position(), 0, 0, ptrNum, (TInt)iMultiPtrEventClient->ChildWin()); + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX+=2, ptrPos.iY+=2, 5000, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EEnterHighPressure, ptrPos-iMultiPtrEventClient->ChildWin()->Position(), 5000, 0, ptrNum, (TInt)iMultiPtrEventClient->ChildWin()); + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX-=2, ptrPos.iY-=2, 1000, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EExitHighPressure, ptrPos-iMultiPtrEventClient->ChildWin()->Position(), 1000, 0, ptrNum, (TInt)iMultiPtrEventClient->ChildWin()); + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX+=2, ptrPos.iY+=2, 1000, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EDrag, ptrPos-iMultiPtrEventClient->ChildWin()->Position(), 1000, 0, ptrNum, (TInt)iMultiPtrEventClient->ChildWin()); + SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos-iMultiPtrEventClient->ChildWin()->Position(), 0, 0, ptrNum, (TInt)iMultiPtrEventClient->ChildWin()); + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX-=2, ptrPos.iY-=2, -60, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EExitCloseProximity, ptrPos-iMultiPtrEventClient->ChildWin()->Position(), -60, 0, ptrNum, (TInt)iMultiPtrEventClient->ChildWin()); + ptrPos.iX += xInc/3; // Ensure all Pointer events are on iParentWin + ptrPos.iY += yInc/3; + } + } + else + { + ptrPos.iX = iPhysicalScreenSize.iWidth/2 + xInc/3; + ptrPos.iY = 0; + + for (ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) + { + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, -10, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EEnterCloseProximity, TPoint(ptrPos.iX+iPhysicalScreenSize.iWidth/2, ptrPos.iY), -10, 0, ptrNum, (TInt)iWinForCapturing); + SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EButton1Down, TPoint(ptrPos.iX+iPhysicalScreenSize.iWidth/2, ptrPos.iY), 0, 0, ptrNum, (TInt)iWinForCapturing); + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX+=2, ptrPos.iY+=2, 5000, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EEnterHighPressure, TPoint(ptrPos.iX+iPhysicalScreenSize.iWidth/2, ptrPos.iY), 5000, 0, ptrNum, (TInt)iWinForCapturing); + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX-=2, ptrPos.iY-=2, 1000, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EExitHighPressure, TPoint(ptrPos.iX+iPhysicalScreenSize.iWidth/2, ptrPos.iY), 1000, 0, ptrNum, (TInt)iWinForCapturing); + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX+=2, ptrPos.iY+=2, 1000, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EDrag, TPoint(ptrPos.iX+iPhysicalScreenSize.iWidth/2, ptrPos.iY), 1000, 0, ptrNum, (TInt)iWinForCapturing); + SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EButton1Up, TPoint(ptrPos.iX+iPhysicalScreenSize.iWidth/2, ptrPos.iY), 0, 0, ptrNum, (TInt)iWinForCapturing); + SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EOutOfRange, TPoint(ptrPos.iX+iPhysicalScreenSize.iWidth/2, ptrPos.iY), 0, 0, ptrNum, (TInt)iWinForCapturing); + ptrPos.iX += xInc/3; + ptrPos.iY += yInc/3; + } + } + } + +void CTMultiPtrEventTest::SetAutoFlush() + { + iTheClientFlush = TheClient->iWs.SetAutoFlush(ETrue); + iClientFlush = iMultiPtrEventClient->iWs.SetAutoFlush(ETrue); + } + +void CTMultiPtrEventTest::ResetFlushStopAS() + { + if (iActiveSchedulerStarted) + { + iActiveSchedulerStarted = EFalse; + CActiveScheduler::Stop(); + } + TheClient->iWs.SetAutoFlush(iTheClientFlush); + iMultiPtrEventClient->iWs.SetAutoFlush(iClientFlush); + } + +// Common function for all test cases +void CTMultiPtrEventTest::RunTestsL() + { + // Create CTMultiPtrEventClient for each test case and call NextSetOfEventsL() + iMultiPtrEventClient = new(ELeave) CTMultiPtrEventClient(this); + iMultiPtrEventClient->SetScreenNumber(iTest->iScreenNumber); + iMultiPtrEventClient->ConstructL(); + + iEventSet=0; + + // Create secondary client for test case number 3 + if (iTest->iState == 3) + { + iSecMultiPtrEventClient = new(ELeave) CTMultiPtrEventClient(this, 1); + iSecMultiPtrEventClient->SetScreenNumber(iTest->iScreenNumber); + iSecMultiPtrEventClient->ConstructL(); + } + + TRAPD(err, NextSetOfEventsL()); + if (err != KErrNone) + { + iFailed = ETrue; + } + + // Start nested activescheduler if it is not failed for the first attempt + if (!iFailed) + { + iActiveSchedulerStarted = ETrue; + CActiveScheduler::Start(); + } + + // + TInt eventsRem = iMultiPtrEventClient->EventBuffer()->EventsRemaining(); + if (eventsRem > 0) + { + iFailed=ETrue; + } + + // Delete secondary client for test case number 3 + if (iTest->iState == 3) + { + delete iSecMultiPtrEventClient; + iSecMultiPtrEventClient = NULL; + } + + delete iMultiPtrEventClient; + iMultiPtrEventClient = NULL; + } + +// Common function for all tests +// Important point to remember is that this function should not leave when running tests +void CTMultiPtrEventTest::NextSetOfEventsL() + { + // For each test case calls its respective tests + + ((CTMultiPtrEventTestStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); + switch (iTest->iState) + { + case 0: +/** +@SYMTestCaseID GRAPHICS-WSERV-ADVANCEDPOINTER-0036 +*/ + ((CTMultiPtrEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-ADVANCEDPOINTER-0036")); + MultiPointerEvents(); + break; + case 1: + ((CTMultiPtrEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-ADVANCEDPOINTER-0014")); + PurgingMultiPointerEvents(); + break; + case 2: + ((CTMultiPtrEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-ADVANCEDPOINTER-0013")); + MultiPointerEventsForAnimsL(); + break; + case 3: + ((CTMultiPtrEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-ADVANCEDPOINTER-0011")); + GetRemainingEventsFromSecondaryClient(); // Does nothing for first time + MultiClientMultiPointerEvents(); + break; + case 4: + ((CTMultiPtrEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-ADVANCEDPOINTER-0027")); + MultiPointerEventsForPointerClickL(); + break; + case 5: + ((CTMultiPtrEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-ADVANCEDPOINTER-0028")); + MultiPointerEventsInDiffScreenModes(); + break; + case 6: + ((CTMultiPtrEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-ADVANCEDPOINTER-0025")); + FilteringMultiPointerEvents(); + break; + case 7: + ((CTMultiPtrEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-ADVANCEDPOINTER-0021")); + GrabbingMultiPointerEvents(); + break; + case 8: + ((CTMultiPtrEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-ADVANCEDPOINTER-0031")); + VirtualKeyBoardForMultiplePointers(); + break; + case 9: + ((CTMultiPtrEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-ADVANCEDPOINTER-0032")); + DoubleClickForMultiplePointers(); + break; + case 10: + ((CTMultiPtrEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-ADVANCEDPOINTER-0015")); + MultiPointerOutOfRangeEvents(); + break; + case 11: + ((CTMultiPtrEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-ADVANCEDPOINTER-0026")); + AutoForeGroundForMultiplePointersL(); + break; + case 12: + ((CTMultiPtrEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-ADVANCEDPOINTER-0029")); + EmulationRulesForMultiplePointers(); + break; + case 13: + ((CTMultiPtrEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-ADVANCEDPOINTER-0034")); + CloseProximityAndHighPressureEventsL(); + break; + case 14: + ((CTMultiPtrEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-ADVANCEDPOINTER-0017")); + OutOfBoundValueTesting(); + break; + case 15: + ((CTMultiPtrEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-ADVANCEDPOINTER-0019")); + CapturingMultiPointerEvents(); + break; + case 16: + ((CTMultiPtrEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-ADVANCEDPOINTER-0035")); + NegativeTestsForProximityPressureEventsL(); + break; + case 17: + ((CTMultiPtrEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-ADVANCEDPOINTER-0034")); + PointerRepeatEventForMultiplePointers(); + break; + // Any new test case should be added here. + // because some of the above tests use testcase number for certain checks + default: + ((CTMultiPtrEventTestStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + AutoPanic(EAutoPanicWrongTest); + } + ((CTMultiPtrEventTestStep*)iStep)->RecordTestResultL(); + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-ADVANCEDPOINTER-0033 +@SYMPREQ PREQ1226 +@SYMREQ REQ9677 +@SYMTestPriority High +@SYMTestCaseDesc To check Wserv sends Pointer Repeat Events for all pointers. +@SYMTestStatus Implemented + +@SYMTestActions Simulate events being passed to the client by implementing each discrete test + over 4 seperate test cases. + In the first test case simulate EButton1Down and add event to a TWsEvent buffer. + In the second test case call RequestPointerRepeatEvent on the base window passing + in a time interval, a rectangle (the 'hitbox') and pointer number. + Add EButtonRepeat to TWsEvent buffer. + In the third test case simulate EPointerMove event within the hitbox, then simulate + an elapsed period of time longer that specified interval. Add only a EButtonRepeat + to TWsEvent buffer. + In the final test case simulate EButton1Up and add event to TWsEvent buffer. + + Repeat steps for the second discrete test, however, in the third test case simulate + EPointerMove event outside the hitbox. In addition add EDrag to TWsEvent buffer + instead of EButtonRepeat. + + A third discrete test will be executed over two test cases and will test + CancelPointerRepeatEventRequest API. + +@SYMTestExpectedResults The received events must match the events added to the buffer except where EPointerMove + events should be filtered out. In addition, EButtonRepeat will be generated by wserv + after calling RequestPointerRepeatEvent and time interval specified has elapsed. + +*/ +void CTMultiPtrEventTest::PointerRepeatEventForMultiplePointers() + { + // Test PointerRepeatEvent for Multiple Pointers + TLogMessageText logText; + _LIT(KSet, "PointerRepeatEventForMultiplePointers SetOfEvents: %d of 10"); + logText.AppendFormat(KSet, iEventSet); + LOG_MESSAGE(logText); + + if (!iEventSet) + { + SetAutoFlush(); + AddExpectedWsEvent(EEventFocusGained); + } + iMultiPtrEventClient->EventBuffer()->SetEventCount(0); + + TPoint ptrPos; + TInt ptrNum; + // Ensure all pointers are on iParentWin + TInt xInc = iPhysicalScreenSize.iWidth/iMaxDevPointers/3; + TInt yInc = iPhysicalScreenSize.iHeight/iMaxDevPointers/3; + + switch(iEventSet++) + { + // Test cases 0 - 3 represent first discrete test for PointerRepeatEvents + case 0: + // Simulate EButton1Down events only. This is in order to simulate the event being passed to the client. + // If the event remained in the window queue the PointerRepeatEvent request would be cancelled when PointerRepeatPurgeCheck is performed. + INFO_PRINTF1(_L("Simulate EButton1Down event for all pointers.")); + for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) + { + SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, ptrNum); + ptrPos.iX+=xInc; + ptrPos.iY+=yInc; + } + break; + case 1: + // Simulate client calling RequestPointerRepeatEvent in response to EButton1Down event being within a 'hitbox'. + INFO_PRINTF1(_L("Simulate PointerRepeatEvent request for all pointers.")); + ptrPos.SetXY(0,0); + for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) + { + iMultiPtrEventClient->ParentWin()->BaseWin()->RequestPointerRepeatEvent(TTimeIntervalMicroSeconds32(100000),TRect(TPoint(0,0), TSize(iPhysicalScreenSize.iWidth/2,iPhysicalScreenSize.iHeight)),ptrNum); + User::After(200000); + AddExpectedPointerEvent(TPointerEvent::EButtonRepeat, ptrPos, ptrNum); + ptrPos.iX+=xInc; + ptrPos.iY+=yInc; + } + break; + case 2: + // Simulate client calling RequestPointerRepeatEvent in response to EButtonRepeat and pointer remaining within the 'hitbox'. + INFO_PRINTF1(_L("Simulate additional PointerRepeatEvent request for all pointers.")); + // New coordinates will be used for a simulated EPointerMove. This event will be filtered out, however, EButtonRepeat will occur at new coordinates + ptrPos.iX = xInc; + ptrPos.iY = yInc; + for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) + { + iMultiPtrEventClient->ParentWin()->BaseWin()->RequestPointerRepeatEvent(TTimeIntervalMicroSeconds32(100000),TRect(TPoint(0,0), TSize(iPhysicalScreenSize.iWidth/2,iPhysicalScreenSize.iHeight)),ptrNum); + // EPointerMove event is filtered out by TWsPointer::PointerRepeatPurgeCheck + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, 0, ptrNum); + User::After(200000); + AddExpectedPointerEvent(TPointerEvent::EButtonRepeat, ptrPos, ptrNum); + ptrPos.iX+=xInc; + ptrPos.iY+=yInc; + } + break; + case 3: + INFO_PRINTF1(_L("Simulate EButton1Up for all pointers.")); + ptrPos.iX = xInc; + ptrPos.iY = yInc; + for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) + { + SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, ptrNum); + ptrPos.iX+=xInc; + ptrPos.iY+=yInc; + } + break; + // Test cases 4 - 7 represent second second discrete test for PointerRepeatEvents + case 4: + // Simulate EButton1Down events only. This is in order to simulate the event being passed to the client. + // If the event remained in the window queue the PointerRepeatEvent request would be cancelled when PointerRepeatPurgeCheck is performed. + INFO_PRINTF1(_L("Simulate EButton1Down event for all pointers.")); + ptrPos.SetXY(0,0); + for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) + { + SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, ptrNum); + ptrPos.iX+=xInc; + ptrPos.iY+=yInc; + } + break; + case 5: + // Simulate client calling RequestPointerRepeatEvent in response to EButton1Down event being within a 'hitbox'. + INFO_PRINTF1(_L("Call RequestPointerRepeatEvent for all pointers.")); + ptrPos.SetXY(0,0); + for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) + { + iMultiPtrEventClient->ParentWin()->BaseWin()->RequestPointerRepeatEvent(TTimeIntervalMicroSeconds32(100000),TRect(TPoint(0,0), TSize(iPhysicalScreenSize.iWidth/3,iPhysicalScreenSize.iHeight)),ptrNum); // hitbox size reduced + User::After(200000); + AddExpectedPointerEvent(TPointerEvent::EButtonRepeat, ptrPos, ptrNum); + ptrPos.iX+=xInc; + ptrPos.iY+=yInc; + } + break; + case 6: + // Simulate client calling RequestPointerRepeatEvent in response to EButtonRepeat and event remaining within the 'hitbox' rect. + // EPointerMove will take pointer out of the hitbox so should not be filtered. PointerRepeatEvent should be cancelled. + INFO_PRINTF1(_L("Simulate a PointerMove event for all pointers to a coordinate outside the hitbox.")); + // New coordinates will be used for a simulated EPointerMove outisde the hitbox. + ptrPos.iX = iPhysicalScreenSize.iWidth/3 + xInc; + ptrPos.iY = 0; + for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) + { + iMultiPtrEventClient->ParentWin()->BaseWin()->RequestPointerRepeatEvent(TTimeIntervalMicroSeconds32(100000),TRect(TPoint(0,0), TSize(iPhysicalScreenSize.iWidth/3,iPhysicalScreenSize.iHeight)),ptrNum); + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, 0, ptrNum); + User::After(200000); + AddExpectedPointerEvent(TPointerEvent::EDrag, ptrPos, ptrNum); + } + break; + case 7: + INFO_PRINTF1(_L("Simulate EButton1Up for all pointers.")); + ptrNum = 0; + ptrPos.iX = iPhysicalScreenSize.iWidth/3 + xInc; + ptrPos.iY = 0; + for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) + { + SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, ptrNum); + } + break; + // Test cases 8 and 9 represent third discrete test for PointerRepeatEvents + case 8: + // Simulate EButton1Down events only. This is in order to simulate the event being passed to the client. + // If the event remained in the window queue the PointerRepeatEvent request would be cancelled when PointerRepeatPurgeCheck is performed. + INFO_PRINTF1(_L("Simulate EButton1Down event for all pointers.")); + ptrPos.SetXY(0,0); + for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) + { + SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, ptrNum); + ptrPos.iX+=xInc; + ptrPos.iY+=yInc; + } + break; + case 9: + // No simulated events. This test case is to explicity call RWindowBase::CancelPointerRepeatEventRequest(const TUint8 aPointerNumber) + INFO_PRINTF1(_L("Call RequestPointerRepeatEvent and CancelPointerRepeatEventRequest for all pointers.")); + ptrPos.SetXY(0,0); + for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) + { + iMultiPtrEventClient->ParentWin()->BaseWin()->RequestPointerRepeatEvent(TTimeIntervalMicroSeconds32(100000),TRect(TPoint(0,0), TSize(iPhysicalScreenSize.iWidth/3,iPhysicalScreenSize.iHeight)),ptrNum); + iMultiPtrEventClient->ParentWin()->BaseWin()->CancelPointerRepeatEventRequest(ptrNum); + ptrPos.iX+=xInc; + ptrPos.iY+=yInc; + } + INFO_PRINTF1(_L("Simulate EButton1Up for all pointers.")); + ptrPos.iX = xInc; + ptrPos.iY = yInc; + for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) + { + SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, ptrNum); + ptrPos.iX+=xInc; + ptrPos.iY+=yInc; + } + break; + default: + ResetFlushStopAS(); + break; + } + LogEventsAdded(); + } + +void CTMultiPtrEventTest::TestErrorCodeL(TInt aExpErrCode, TInt aActualErrCode) + { + if (aExpErrCode != aActualErrCode) + { + TLogMessageText logText; + _LIT(KError, "Expected Error code = %d Actual Actual Error code %d"); + logText.AppendFormat(KError, aExpErrCode, aActualErrCode); + LOG_MESSAGE(logText); + User::Leave(ETestFailed); + } + } + +void CTMultiPtrEventTest::NegativeTestingOfProximityPressureAPIsL() + { + // First send -10 for EnterCloseProximity and -5 for ExitCLoseProximity, it should return KErrArgument + // Then send 20 and 10 which should return KErrNone + // Then sent 10 and 20 which should return KErrArgument + TInt retVal; + retVal = iMultiPtrEventClient->iWs.SetCloseProximityThresholds(-10, -5); + TestErrorCodeL(KErrArgument, retVal); + + retVal = iMultiPtrEventClient->iWs.SetCloseProximityThresholds(20, 10); + TestErrorCodeL(KErrNone, retVal); + + retVal = iMultiPtrEventClient->iWs.SetCloseProximityThresholds(10, 20); + TestErrorCodeL(KErrArgument, retVal); + + // Repeat the above for EnterHighPressure and ExitHighPressure with these values + // -10 and -5 it should return KErrArgument + // -5 and -10 it should return KErrNone + retVal = iMultiPtrEventClient->iWs.SetHighPressureThresholds(-10, -5); + TestErrorCodeL(KErrArgument, retVal); + + retVal = iMultiPtrEventClient->iWs.SetHighPressureThresholds(-5, -10); + TestErrorCodeL(KErrNone, retVal); + } + +void CTMultiPtrEventTest::SimulateProximityAndPressureEvents(TInt aCloseProxEnterValue, TInt aCloseProxExitValue, TInt aHighPresEnterValue, TInt aHighPresExitValue) + { + TPoint ptrPos(10,10); + // Simulate EPointerMove with proximity value > EnterCloseProximity threshold + for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) + { + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, aCloseProxEnterValue, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EEnterCloseProximity, ptrPos, aCloseProxEnterValue, 0, ptrNum); + } + + // Simulate EPointerMove with proximity value < ExitCloseProximity threshold + for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) + { + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, aCloseProxExitValue, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EExitCloseProximity, ptrPos, aCloseProxExitValue, 0, ptrNum); + } + + // Simulate EBUtton1Down with presure value > EnterHighPressure threshold + for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) + { + SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, aHighPresEnterValue, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, aHighPresEnterValue, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EEnterHighPressure, ptrPos, aHighPresEnterValue, 0, ptrNum); + } + + // Simulate EPointerMove with presure value < ExitHighPressure threshold + for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) + { + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, aHighPresExitValue, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EExitHighPressure, ptrPos, aHighPresExitValue, 0, ptrNum); + } + + // Finally simulate Ebutton1Up with proximity value < ExitCloseProximity + for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) + { + SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, aCloseProxExitValue, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, aCloseProxExitValue, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EExitCloseProximity, ptrPos, aCloseProxExitValue, 0, ptrNum); + } + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-ADVANCEDPOINTER-0035 +@SYMPREQ PREQ1226 +@SYMREQ REQ10887, REQ10886 +@SYMTestPriority High +@SYMTestCaseDesc Negative tests for close Proximity and high Pressure events. +@SYMTestStatus Implemented + +@SYMTestActions Set CloseProximity and HighPressure thresholds with positive and negative values. + Simulate Enter/ExitCloseProximity and Enter/ExitHighPressure events. +@SYMTestExpectedResults The received events must match the simulated pointer events +*/ +void CTMultiPtrEventTest::NegativeTestsForProximityPressureEventsL() + { + TLogMessageText logText; + _LIT(KSet, "Negative tests for pressure and proximity events: %d of 3"); + logText.AppendFormat(KSet, iEventSet); + LOG_MESSAGE(logText); + + if (!iEventSet) + { + SetAutoFlush(); + NegativeTestingOfProximityPressureAPIsL(); + AddExpectedWsEvent(EEventFocusGained); + } + iMultiPtrEventClient->EventBuffer()->SetEventCount(0); + switch(iEventSet++) + { + case 0: + // This is to check close proximity threshold API can be given +ve values + // and high pressure threshold API can begiven -ve values + iMultiPtrEventClient->iWs.SetCloseProximityThresholds(50, 20); + iMultiPtrEventClient->iWs.SetHighPressureThresholds(-20, -50); + SimulateProximityAndPressureEvents(60, 10, -10, -60); + break; + case 1: + // Repeat the above with +ve values + iMultiPtrEventClient->iWs.SetCloseProximityThresholds(50, 20); + iMultiPtrEventClient->iWs.SetHighPressureThresholds(50, 20); + SimulateProximityAndPressureEvents(60, 10, 60, 10); + break; + case 2: + // Repeat the above -ve values + iMultiPtrEventClient->iWs.SetCloseProximityThresholds(-20, -50); + iMultiPtrEventClient->iWs.SetHighPressureThresholds(-20, -50); + SimulateProximityAndPressureEvents(-10, -60, -10, -60); + break; + default: + SetThresholdValues(KMaxTInt, KMinTInt, KMaxTInt, KMinTInt); + ResetFlushStopAS(); + break; + } + + LogEventsAdded(); + } + + +void CTMultiPtrEventTest::CreateGroupWinForCapturingL() + { + iGroupWinForCapturing = new(ELeave) CTWindowGroup(iMultiPtrEventClient); + iGroupWinForCapturing->ConstructL(); + iGroupWinForCapturing->GroupWin()->AutoForeground(ETrue); + iGroupWinForCapturing->GroupWin()->EnableFocusChangeEvents(); + + iWinForCapturing = new(ELeave) CTBlankWindow(); + iWinForCapturing->ConstructL(*iGroupWinForCapturing); + iWinForCapturing->SetExt(TPoint(), TSize(iPhysicalScreenSize.iWidth/2, iPhysicalScreenSize.iHeight)); + iWinForCapturing->SetColor(KRgbBlue); + iWinForCapturing->BaseWin()->EnableAdvancedPointers(); + iWinForCapturing->Activate(); + } + +void CTMultiPtrEventTest::DeleteGroupWinForCapturing() + { + if (iWinForCapturing) + { + delete iWinForCapturing; + iWinForCapturing = NULL; + } + if (iGroupWinForCapturing) + { + delete iGroupWinForCapturing; + iGroupWinForCapturing = NULL; + } + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-ADVANCEDPOINTER-0019 +@SYMPREQ PREQ1226 +@SYMREQ REQ9677,REQ9683, +@SYMTestPriority High +@SYMTestCaseDesc Checks Wserv supports Capturing in case of multi pointer events. +@SYMTestStatus Implemented + +@SYMTestActions Create a window with group window as its parent. + Create another window with same parent and partially overlapping the first one. + SetPointerCapture for second window with TCaptureEnabled flag. + Simulate TRawEvent::EButton1Down from each pointer the device supports + + Repeat the above with TCaptureFlagAllGroups flag for SetPointerCapture + and creating windows from different window group + +@SYMTestExpectedResults Even if events were simulated on first window events are delivered to + second window as it is capturing. + With TCaptureFlagAllGroups flag set events are delivered to window which is + capturing even if events were simulated on a window from different group + +*/ +void CTMultiPtrEventTest::CapturingMultiPointerEvents() + { + // Test Capturing of multi pointer events + // 1. Test Wserv supports Capturing in case of multi-pointer events + // 2. Test pointer events are delivered correctly when Capturing is disabled. + TLogMessageText logText; + _LIT(KSet, "CapturingMultiPtrEvents SetOfEvents: %d of 3"); + logText.AppendFormat(KSet, iEventSet); + LOG_MESSAGE(logText); + + if (!iEventSet) + { + SetAutoFlush(); + } + iMultiPtrEventClient->EventBuffer()->SetEventCount(0); + + TPoint ptrPos; + TInt ptrNum; + + switch(iEventSet++) + { + case 0: + INFO_PRINTF1(_L("Ensure pointer state is Out of Range")); + AddExpectedWsEvent(EEventFocusGained); + for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) + { + SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, ptrNum); + SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, ptrNum); + } + break; + case 1: + INFO_PRINTF1(_L("Check Wserv supports Capturing in case of multi-pointer events, within window group")); + iMultiPtrEventClient->ChildWin()->BaseWin()->SetPointerCapture(RWindowBase::TCaptureEnabled); + TestCapturingForMultiPointer(EFalse); + break; + case 2: + INFO_PRINTF1(_L("Check Wserv supports Capturing in case of multi-pointer events, from different window groups")); + TRAPD(err, CreateGroupWinForCapturingL()); // it cannot leave so trap and fail + if (err != KErrNone) + { + Failed(); + } + AddExpectedWsEvent(EEventFocusLost); // First group window losing focus because of second group creation + AddExpectedWsEvent(EEventFocusGained); // Second group window creation + + iWinForCapturing->BaseWin()->SetPointerCapture(RWindowBase::TCaptureEnabled|RWindowBase::TCaptureFlagAllGroups); + TestCapturingForMultiPointer(ETrue); + break; + default: + DeleteGroupWinForCapturing(); + ResetFlushStopAS(); + break; + } + LogEventsAdded(); + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-ADVANCEDPOINTER-0017 +@SYMPREQ PREQ1226 +@SYMREQ Negative Testing +@SYMTestPriority High +@SYMTestCaseDesc Out of bound value testing +@SYMTestStatus Implemented + +@SYMTestActions Simulate raw events of TRawEvent with pointer number greater than EPointerMaxPointers + +@SYMTestExpectedResults The received events must match the events added to the buffer and check that out of bound events are ignored. + +*/ +void CTMultiPtrEventTest::OutOfBoundValueTesting() + { + // Test Wserv ignores pointer events which have a pointer number greater than EPointerMaxPointers. + TLogMessageText logText; + _LIT(KSet, "OutOfBoundValueTesting SetOfEvents: %d of 1"); + logText.AppendFormat(KSet, iEventSet); + LOG_MESSAGE(logText); + + if (!iEventSet) + { + SetAutoFlush(); + AddExpectedWsEvent(EEventFocusGained); + } + iMultiPtrEventClient->EventBuffer()->SetEventCount(0); + + TPoint ptrPos; + TInt ptrNum; + TInt ptrNumOutOfBounds; + + switch(iEventSet++) + { + case 0: + INFO_PRINTF1(_L("Checks Wserv ignores pointer events which have a pointer number greater than EPointerMaxPointers.")); + ptrPos.SetXY(0,0); + ptrNum = iMaxDevPointers-1; // Max value for ptrNum + ptrNumOutOfBounds = iMaxDevPointers; // Invalid ptrNum as pointer numbers are zero indexed + + SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum); + SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNumOutOfBounds); + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX+10, ptrPos.iY+10, 0, ptrNum); + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX+10, ptrPos.iY+10, 0, ptrNumOutOfBounds); + SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX+10, ptrPos.iY+10, 0, ptrNum); + SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX+10, ptrPos.iY+10, 0, ptrNumOutOfBounds); + AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, ptrNum); + ptrPos.iX += 10; ptrPos.iY += 10; + AddExpectedPointerEvent(TPointerEvent::EDrag, ptrPos, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, ptrNum); + break; + default: + ResetFlushStopAS(); + break; + } + LogEventsAdded(); + } + +void CTMultiPtrEventTest::SetThresholdValues(TInt aEnterCloseProx, TInt aExitCloseProx, TInt aEnterHighPres, TInt aExitHighPres) + { + iEnterCloseProximityThreshold = aEnterCloseProx; + iExitCloseProximityThreshold = aExitCloseProx; + iEnterHighPressureThreshold = aEnterHighPres; + iExitHighPressureThreshold = aExitHighPres; + + iMultiPtrEventClient->iWs.SetCloseProximityThresholds(iEnterCloseProximityThreshold,iExitCloseProximityThreshold); + iMultiPtrEventClient->iWs.SetHighPressureThresholds(iEnterHighPressureThreshold,iExitHighPressureThreshold); + } + +void CTMultiPtrEventTest::TestCloseProximityHighPressureAPIsL() + { + // These are some typical values which are used only for testing purposes. + // 20mm to screen + // 50mm to screen + // 4N of pressure + // 2N of pressure + SetThresholdValues(-20,-50,4000,2000); + + if (iMultiPtrEventClient->iWs.GetEnterCloseProximityThreshold() != iEnterCloseProximityThreshold) + { + TLogMessageText logText; + _LIT(KError, "Expected EnterCloseProximityThreshold = %d Actual EnterCloseProximityThreshold %d"); + logText.AppendFormat(KError, iEnterCloseProximityThreshold, iMultiPtrEventClient->iWs.GetEnterCloseProximityThreshold()); + LOG_MESSAGE(logText); + User::Leave(ETestFailed); + } + + if (iMultiPtrEventClient->iWs.GetExitCloseProximityThreshold() != iExitCloseProximityThreshold) + { + TLogMessageText logText; + _LIT(KError, "Expected ExitCloseProximityThreshold = %d Actual ExitCloseProximityThreshold %d"); + logText.AppendFormat(KError, iExitCloseProximityThreshold, iMultiPtrEventClient->iWs.GetExitCloseProximityThreshold()); + LOG_MESSAGE(logText); + User::Leave(ETestFailed); + } + + if (iMultiPtrEventClient->iWs.GetEnterHighPressureThreshold() != iEnterHighPressureThreshold) + { + TLogMessageText logText; + _LIT(KError, "Expected EnterHighPressureThreshold = %d Actual EnterHighPressureThreshold %d"); + logText.AppendFormat(KError, iEnterHighPressureThreshold, iMultiPtrEventClient->iWs.GetEnterHighPressureThreshold()); + LOG_MESSAGE(logText); + User::Leave(ETestFailed); + } + + if (iMultiPtrEventClient->iWs.GetExitHighPressureThreshold() != iExitHighPressureThreshold) + { + TLogMessageText logText; + _LIT(KError, "Expected ExitHighPressureThreshold = %d Actual ExitHighPressureThreshold %d"); + logText.AppendFormat(KError, iExitHighPressureThreshold, iMultiPtrEventClient->iWs.GetExitHighPressureThreshold()); + LOG_MESSAGE(logText); + User::Leave(ETestFailed); + } + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-ADVANCEDPOINTER-0034 +@SYMPREQ PREQ1226 +@SYMREQ REQ10887,REQ10886 +@SYMTestPriority High +@SYMTestCaseDesc Tests close Proximity and high Pressure event types. +@SYMTestStatus Implemented + +@SYMTestActions Set CloseProximity and HighPressure thresholds and simulate events with different Z values +@SYMTestExpectedResults The received events must match the simulated pointer events +*/ +void CTMultiPtrEventTest::CloseProximityAndHighPressureEventsL() + { + TLogMessageText logText; + _LIT(KSet, "Close Proximity and High Pressure events: %d of 11"); + logText.AppendFormat(KSet, iEventSet); + LOG_MESSAGE(logText); + + if (!iEventSet) + { + SetAutoFlush(); + TestCloseProximityHighPressureAPIsL(); + AddExpectedWsEvent(EEventFocusGained); + } + iMultiPtrEventClient->EventBuffer()->SetEventCount(0); + + TPoint ptrPos(10,10); + TInt proxValue; + TInt prValue; + TInt tempCount; + switch(iEventSet++) + { + case 0: + iMultiPtrEventClient->ParentWin()->BaseWin()->PointerFilter(EPointerFilterMove, 0); + // One whole cycle of events + // Simulate out-of-range from all pointers and don't expect out-of-range events + // since all the pointers are already in same state + for (TInt ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) + { + SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum); + } + + // Simulate moves with proximity value < EEnterCloseProximity + proxValue = -30; + for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) + { + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, proxValue, 0, ptrNum); + } + + // Simulate moves with proximity value > EEnterCloseProximity + proxValue = -10; + for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) + { + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EEnterCloseProximity, ptrPos, proxValue, 0, ptrNum); + } + + // Simulate EButton1Down with pressure value < EEnterHighPressure + prValue = 1000; + for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) + { + SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, prValue, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, prValue, 0, ptrNum); + } + + // Simulate moves with pressure value > EEnterHighPressure + prValue = 5000; + for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) + { + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, prValue, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EEnterHighPressure, ptrPos, prValue, 0, ptrNum); + } + + // Simulate moves with pressure value < EExitHighPressure + prValue = 1000; + for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) + { + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, prValue, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EExitHighPressure, ptrPos, prValue, 0, ptrNum); + } + + // Simulate EButton1Up with proximity value > EEnterCloseProximity + proxValue = -10; + for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) + { + SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, proxValue, 0, ptrNum); + } + + // Simulate moves with proximity value < EExitCloseProximity + proxValue = -60; + for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) + { + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EExitCloseProximity, ptrPos, proxValue, 0, ptrNum); + } + break; + case 1: + // Simulate events to meet all scenarios + // Simulate EButton1Down with pressure value < EEnterHighPressure + prValue = 1000; + for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) + { + SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, prValue, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, prValue, 0, ptrNum); + } + + // Simulate EButton1Up with proximity value < EExitCloseProximity + proxValue = -60; + for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) + { + SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, proxValue, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EExitCloseProximity, ptrPos, proxValue, 0, ptrNum); + } + + // Simulate EButton1Down with pressure value > EEnterHighPressure + prValue = 5000; + for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) + { + SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, prValue, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, prValue, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EEnterHighPressure, ptrPos, prValue, 0, ptrNum); + } + + // Simulate EButton1Up with proximity value < EExitCloseProximity + proxValue = -60; + for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) + { + SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, proxValue, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EExitCloseProximity, ptrPos, proxValue, 0, ptrNum); + } + break; + case 2: + // Simulate moves with proximity value > EEnterCloseProximity + proxValue = -10; + for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) + { + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EEnterCloseProximity, ptrPos, proxValue, 0, ptrNum); + } + + // Simulate EButton1Down with pressure value > EEnterHighPressure + prValue = 5000; + for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) + { + SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, prValue, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, prValue, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EEnterHighPressure, ptrPos, prValue, 0, ptrNum); + } + + // Simulate EButton1Up with proximity value > EExitCloseProximity + proxValue = -40; // When you coming up, EEnterCloseProximity is of no use + for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) + { + SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, proxValue, 0, ptrNum); + } + + // Simulate out-of-range events + for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) + { + SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, proxValue, 0, ptrNum); + } + break; + case 3: + // From out-of-range state to EButton1Down + // Simulate EButton1Down with pressure value < EEnterHighPressure + prValue = 1000; + for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) + { + SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, prValue, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, prValue, 0, ptrNum); + } + + // Simulate EButton1Up with proximity value > EExitCloseProximity + proxValue = -40; + for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) + { + SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, proxValue, 0, ptrNum); + } + + // Simulate out-of-range events + for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) + { + SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, proxValue, 0, ptrNum); + } + + // Simulate EButton1Down with pressure value > EEnterHighPressure + prValue = 5000; + for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) + { + SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, prValue, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, prValue, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EEnterHighPressure, ptrPos, prValue, 0, ptrNum); + } + + // Simulate EButton1Up with proximity value > EExitCloseProximity + proxValue = -40; + for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) + { + SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, proxValue, 0, ptrNum); + } + + // Simulate out-of-range events + for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) + { + SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, proxValue, 0, ptrNum); + } + break; + case 4: + // Simulate EButton1Dowm with pressure value < EEnterHighPressure + prValue = 1000; + for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) + { + SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, prValue, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, prValue, 0, ptrNum); + } + + // Simulate EButton1Up with proximity value < EExitCloseProximity + proxValue = -60; + for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) + { + SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, proxValue, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EExitCloseProximity, ptrPos, proxValue, 0, ptrNum); + } + + // Simulate out-of-range from Up/OutOfCloseProximity + for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) + { + SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, proxValue, 0, ptrNum); + } + break; + case 5: + // Purging of proximity and pressure events + // Simulate EnterCloseProximity and ExitCloseProximity events which will be purged + // when you send Button1Up events for KMaxQueueSize + proxValue = -10; + for (TInt ptrNum = 0; (ptrNum < iMaxDevPointers && ptrNum < 4); ptrNum++) + { + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); + } + proxValue = -60; + for (TInt ptrNum = 0; (ptrNum < iMaxDevPointers && ptrNum < 4); ptrNum++) + { + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); + } + for (TInt count = 0; count < KMaxQueueSize; count++) + { + SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, proxValue, 0); + AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, proxValue, 0, 0); + } + break; + case 6: + // Simulate EnterCloseProximity for 4 pointers. + // As we cannot create lone ExitCloseProximity events, so create just moves from next 4 pointers + // Simulate out-of-range for these events on thier respective pointers + // Then simulate EButton1Up events which will purge EnterCloseProximity and move events + // which checks that lone EnterCloseProximity and lone move events will be purged + proxValue = -10; + for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) + { + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); + SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, proxValue, 0, ptrNum); + } + proxValue = -60; + for (TInt ptrNum = iMaxDevPointers/2; ptrNum < iMaxDevPointers; ptrNum++) + { + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); + SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, proxValue, 0, ptrNum); + } + for (TInt count = 0; count < KMaxQueueSize-iMaxDevPointers; count++) + { + SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, proxValue, 0); + AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, proxValue, 0, 0); + } + break; + case 7: + // Bring all other pointers to Up state, becasue of previous test + // Then simulate out-of-range twice for all the pointers + // Then simulate Button1Up which will cause purging of successive out-of-range events + proxValue = -60; + tempCount = 0; + for (TInt ptrNum = 1; ptrNum < iMaxDevPointers; ptrNum++) + { + tempCount++; + SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, proxValue, 0, ptrNum); + } + for (TInt ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) + { + tempCount++; + // Wserv does nothing if current state is outofrange and if receives again EOutOfRange event which is practically not possible + SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum); + SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, proxValue, 0, ptrNum); + } + for (TInt count = 0; count < KMaxQueueSize-tempCount; count++) + { + SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, proxValue, 0); + AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, proxValue, 0, 0); + } + break; + case 8: + // Simulate EButton1Down with pressure value > EnterHIghPressure threshold + // which will cause EButton1Down and EnterHighPressure to be filled in queue + // Simulate ExitHighPressure and EButton1Up events for 2 pointers + // Then simulate EButton1Up events from pointer0 so that all of the above events are purged + prValue = 5000; + for (TInt ptrNum = 0; (ptrNum < iMaxDevPointers && ptrNum < 2); ptrNum++) + { + SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, prValue, ptrNum); + } + prValue = 1000; + for (TInt ptrNum = 0; (ptrNum < iMaxDevPointers && ptrNum < 2); ptrNum++) + { + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, prValue, ptrNum); + // Here these events are purged becasue their correpsonding down event would have been purged + SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, ptrNum); + } + // All the above events get purged by this + for (TInt count = 0; count < KMaxQueueSize; count++) + { + SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 0); + AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, 0); + } + break; + case 9: + // Simulate EButton1Down for 2 pointers, which will generate Button1Down and EnterHighPressure + // Simulate Ebutton1Up events for MaxQueueSize from last pointer so that all the above events are purged + prValue = 5000; + for (TInt ptrNum = 0; (ptrNum < iMaxDevPointers/2 && ptrNum < 2); ptrNum++) + { + SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, prValue, ptrNum); + } + + // This will cause above down and enterhighpressure events to be purged + // When pointer is in outofrange state and when EButton1Up event is sent Wserv sends EnterCloseProximity + // EnterCloseProximity cannot be purged unless the next event is EExitCloseProximity or EOutOfRange + for (TInt count = 0; count < KMaxQueueSize; count++) + { + SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, iMaxDevPointers-1); + AddExpectedPointerEvent((count ? TPointerEvent::EButton1Up : TPointerEvent::EEnterCloseProximity), ptrPos, 0, 0, iMaxDevPointers-1); + } + + // As the first 2 pointers are in down state, and if we send the move events with prValue = 1000 + // This will generate the exithigh pressure events, which will be ignored + // This will also generate the Ebutton1Up event which will also be ignored + prValue = 1000; + for (TInt ptrNum = 0; (ptrNum < iMaxDevPointers/2 && ptrNum < 2); ptrNum++) + { + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, prValue, ptrNum); + SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, ptrNum); + } + break; + case 10: + // This is to just bring all the pointers to out-of-range state + // to make all pointers in valid state for other test to run + // Wserv processes EOutOfRange events only when its current state is not in outofrange. + for (TInt ptrNum = 0; ptrNum < iMaxDevPointers && ptrNum < 2; ptrNum++) + { + SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, 0, 0, ptrNum); + } + SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, iMaxDevPointers-1); + AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, 0, 0, iMaxDevPointers-1); + break; + default: + SetThresholdValues(KMaxTInt, KMinTInt, KMaxTInt, KMinTInt); + ResetFlushStopAS(); + break; + } + + LogEventsAdded(); + } + +void CTMultiPtrEventTest::CreateAnimDllAndAnimL() + { + iAnimDll = new(ELeave) RAnimDll(iMultiPtrEventClient->iWs); + User::LeaveIfError(iAnimDll->Load(KAnimDLLName)); + iAnim = RMultiPointerAnim::NewL(iMultiPtrEventClient->ParentWin()->BaseWin(), iAnimDll); + } + +void CTMultiPtrEventTest::DestroyAnimDllAndAnim() + { + if (iAnim) + { + iAnim->Destroy(); + iAnim = NULL; + } + if (iAnimDll) + { + iAnimDll->Destroy(); + iAnimDll = NULL; + } + } + +void CTMultiPtrEventTest::CreateGroupWinL() + { + iGroupWinForEmul = new(ELeave) CTWindowGroup(iMultiPtrEventClient); + iGroupWinForEmul->ConstructL(); + iGroupWinForEmul->GroupWin()->AutoForeground(ETrue); + iGroupWinForEmul->GroupWin()->EnableFocusChangeEvents(); + + iWinForEmul = new(ELeave) CTBlankWindow(); + iWinForEmul->ConstructL(*iGroupWinForEmul); + iWinForEmul->SetExt(TPoint(50,50), TSize(80,80)); + iWinForEmul->SetColor(KRgbDarkYellow); + iWinForEmul->Activate(); + } + +void CTMultiPtrEventTest::DeleteGroupWin() + { + if (iWinForEmul) + { + delete iWinForEmul; + iWinForEmul = NULL; + } + if (iGroupWinForEmul) + { + delete iGroupWinForEmul; + iGroupWinForEmul = NULL; + } + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-ADVANCEDPOINTER-0029 +@SYMPREQ PREQ1226 +@SYMREQ REQ9688 +@SYMTestPriority High +@SYMTestCaseDesc Tests the emulation rules for Apps, Anims, Autofocus and Buffered delivery +@SYMTestStatus Implemented + +@SYMTestActions Simulate event to make a pointer primary. EnableAdvancedPointers API is not called. And then simulate events from other pointers +@SYMTestExpectedResults The events from other pointer are not received +*/ +void CTMultiPtrEventTest::EmulationRulesForMultiplePointers() + { + TLogMessageText logText; + _LIT(KSet, "Emulation rules set of events: %d of 15"); + logText.AppendFormat(KSet, iEventSet); + LOG_MESSAGE(logText); + + if (!iEventSet) + { + SetExpectNonAdvancedPointerEvents(); + SetAutoFlush(); + AddExpectedWsEvent(EEventFocusGained); + } + iMultiPtrEventClient->EventBuffer()->SetEventCount(0); + + TPoint ptrPos(10,10); + TInt proxValue = -iProximityStep; + TInt prValue = iPressureStep; + TInt ptrNum = 0; + switch(iEventSet++) + { + case 0: + // This event is for simulated/primary pointer + iMultiPtrEventClient->ParentWin()->BaseWin()->PointerFilter(EPointerFilterMove, 0); + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, 0); + AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, proxValue, 0, TAdvancedPointerEvent::EDefaultPointerNumber); + + // Parent window has not called EnableAdvancedPointers API + // So even if we simulate moves and out-of-range these are not delivered to client + for (ptrNum = 1; ptrNum < iMaxDevPointers; ptrNum++) + { + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); + SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum); + } + break; + case 1: + // Since the primary pointer is 0, simulate EButton1Down for making pointer 1 as primary + SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 1); + AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); + + // Simulate move or Ebutton1Down from pointer0 they are NOT sent back to client + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, 0); + SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 0); + SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 0); + + SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 1); + AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); + SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 1); + AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); + break; + case 2: + // Simulate EButton1Down from pointer0 to make it primary + SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 0); + AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, 0); + + // Move from pointer1 + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, 1); + + // Take the zero pointer out-of-range, this will not result in Pointer 1 becoming primary + // and out-of-range event is sent to client + SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 0); + AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, 0); + SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 0); + AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, 0, 0, 0); + + // Send moves from pointer1, but these are not sent to the Client. + ptrPos.iX += 10; + ptrPos.iY += 10; + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, 1); + SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 1); + + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, 1); + AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, proxValue, 0, TAdvancedPointerEvent::EDefaultPointerNumber); + + SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 1); + AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, proxValue, 0, TAdvancedPointerEvent::EDefaultPointerNumber); + break; + case 3: + // Simulate EButton1Down from pointer0 to make it primary + SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 0); + AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); + + // Simulate EButton1Down from pointer1, which is not sent to client + SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 1); + + SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 0); + AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); + + SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 0); + AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); + + // Drag events are not sent becasue pointer1 has NOT become primary + ptrPos.iX += 10; + ptrPos.iY += 10; + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, 0, 1); + + // Simulate up from pointer1, still not primary, so event is not sent + SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 1); + + // Simulate out-of-range from pointer1, still not primary, so event is not sent + SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 1); + + // Now moves from out-of-range to move state + ptrPos.iX += 10; + ptrPos.iY += 10; + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, 0, 1); + AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); + + SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 1); + AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); + break; + case 4: + // pointer0 sends move (becomes primary) + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, 0, 0); + AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); + + // pointer0 sends down + SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 0); + AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); + + // pointer1 sends down, doesn't become primary + SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 1); + + // pointer0 sends up, stays primary + SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 0); + AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); + + // pointer2, pointer3 and pointer4 sends move with proximity -5, -10, -15 + for (ptrNum = 2; ptrNum < iMaxDevPointers; ptrNum++, proxValue -= iProximityStep) + { + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); + } + + // pointer0 sends out-of-range, loses primary pointer, But NO events are sent + SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 0); + AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); + + // Send moves for pointer2, pointer3 and pointer4. + // None of the evnst are sent + ptrPos.SetXY(0,0); + for (ptrNum = 2; ptrNum < iMaxDevPointers; ptrNum++) + { + ptrPos.iX += 10; + ptrPos.iY += 5; + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); + } + + // Drag from pointer1, NOT sent, since it is not primary + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, prValue, 1); + + // Send out-of-range from all pointers + for (ptrNum = 2; ptrNum < iMaxDevPointers; ptrNum++) + { + SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum); + } + + // As the pointer1 is down, this will not become primary even if EButton1Up is called + SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 1); + + // And now sending out-of-range will also not send the event to client as it is not primary + SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 1); + break; + case 5: + // Test cases 5 - 7 represent one discrete test for PointerRepeatEvents + // Case 5 simulates EButton1Down events only. This is to ensure the event is delivered to the client. + // If the event remained in the window queue the PointerRepeatEvent request would be cancelled when PointerRepeatPurgeCheck is performed. + ptrPos.SetXY(0,0); + + // pointer0 sends down (become primary) + SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 0); + AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); + + // pointer1 sends down, doesn't become primary + SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 1); + + // pointer4 sends down + if (4 < iMaxDevPointers) + { + SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 4); + } + break; + case 6: + ptrPos.SetXY(0,0); + // Simulate client calling RequestPointerRepeatEvent in response to EButton1Down event being within a 'hitbox'. + // Legacy API called which does not specify a pointer number. EButtonRepeat should be generated for primary pointer only. + iMultiPtrEventClient->ParentWin()->BaseWin()->RequestPointerRepeatEvent(TTimeIntervalMicroSeconds32(100000),TRect(TPoint(0,0), TSize(20,20))); + User::After(200000); + AddExpectedPointerEvent(TPointerEvent::EButtonRepeat, ptrPos, TAdvancedPointerEvent::EDefaultPointerNumber); + break; + case 7: + // pointer0 sends up + SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 0); + AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, TAdvancedPointerEvent::EDefaultPointerNumber); + + // pointer2 sends out-of-range + SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, ptrPos.iX, ptrPos.iY, 0, 0); + AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, TAdvancedPointerEvent::EDefaultPointerNumber); + + // Send up and out-of-range for pointer1 and 4 + SimulatePointerEvent(TRawEvent::EButton1Up, 0, 0, 0, 1); + SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 1); + + if (4 < iMaxDevPointers) + { + SimulatePointerEvent(TRawEvent::EButton1Up, 0, 0, 0, 4); + SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 4); + } + break; + case 8: + // Autofocus does not work for other than primary pointers + // Create group window which will send focus lost and gained + TRAPD(err, CreateGroupWinL()); // it cannot leave so trap and fail + if (err != KErrNone) + { + Failed(); + } + AddExpectedWsEvent(EEventFocusLost); + AddExpectedWsEvent(EEventFocusGained); + + // Simulate Epointer down which will send focuslost, focusgained and focusgroupchanged events + SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 0); + AddExpectedWsEvent(EEventFocusLost); + AddExpectedWsEvent(EEventFocusGained); + AddExpectedWsEvent(EEventFocusGroupChanged); + AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); + + // Now simulate EButton1Down from first or second pointer on second group + // This should not reflect the autofocus + ptrPos.iX = 60; + ptrPos.iY = 60; + SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 1); + if (2 < iMaxDevPointers) + { + SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 2); + } + SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 1); + if (2 < iMaxDevPointers) + { + SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 2); + } + SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 0); + AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); + SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 0); + AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); + break; + case 9: + // First thing to do in this case is to delete the group window created + DeleteGroupWin(); + + TRAP(err, CreateAnimDllAndAnimL()); // it cannot leave so trap and fail + if (err != KErrNone) + { + Failed(); + } + + // This is the first event which makes first pointer as primary + // When the last argument is EFalse, it means that the event is not consumed by Anim + iAnim->AddExpectedAnimPointerEvent(TRawEvent::EPointerMove, ptrPos, 0, 0, 0, EFalse); + AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, 0, 0); + + // Now simulate moves from other pointers and these events are not sent to anim + for (ptrNum = 1; ptrNum < iMaxDevPointers; ptrNum++) + { + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); + SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum); + } + + // This is to reset the primary pointer + iAnim->AddExpectedAnimPointerEvent(TRawEvent::EPointer3DOutOfRange, ptrPos, 0, 0, 0, EFalse); + AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); + SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 0); + + // Now simulate EButton1Down, which will make it as primary + iAnim->AddExpectedAnimPointerEvent(TRawEvent::EButton1Down, ptrPos, 0, 0, 1, EFalse); + AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); + SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 1); + + // Simulate move or Ebutton1Down from any other prointer they are not sent back to client + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, 0); + SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 0); + SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 0); + + iAnim->AddExpectedAnimPointerEvent(TRawEvent::EButton1Up, ptrPos, 0, 0, 1, EFalse); + AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); + SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 1); + + iAnim->AddExpectedAnimPointerEvent(TRawEvent::EPointer3DOutOfRange, ptrPos, 0, 0, 1, EFalse); + AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); + SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 1); + + // Set the primary pointer to Zero + iAnim->AddExpectedAnimPointerEvent(TRawEvent::EButton1Down, ptrPos, 0, 0, 0, EFalse); + AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); + SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 0); + + // Move from second pointer + // As EnableMultiPointer is not called and this is not a primary pointer so this event + // will cause the pointer 1 into move state + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, 1); + + // Take the zero pointer out-of-range + iAnim->AddExpectedAnimPointerEvent(TRawEvent::EButton1Up, ptrPos, 0, 0, 0, EFalse); + AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); + SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 0); + + iAnim->AddExpectedAnimPointerEvent(TRawEvent::EPointer3DOutOfRange, ptrPos, 0, 0, 0, EFalse); + AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); + SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 0); + + // These moves will not be sent + ptrPos.iX += 10; + ptrPos.iY += 10; + + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, 1); + SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 1); + SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 1); + + TestAndDisplayAnimError(); + + _LIT(KEventsChecked, "Events checked at server side = %d"); + logText.Format(KEventsChecked, 10); + LOG_MESSAGE(logText); + break; + case 10: + DestroyAnimDllAndAnim(); + + // Test for PointerMove buffers + // AllocPointerMoveBuffer, EnablePointerMoveBuffer and then simulate few moves + // Add these moves to another points buffer for testing + // Simulate moves from other pointers, these should not be delivered to clients. + iMultiPtrEventClient->ParentWin()->BaseWin()->AllocPointerMoveBuffer(10, 0); + iMultiPtrEventClient->ParentWin()->BaseWin()->EnablePointerMoveBuffer(); + + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, 0, 0); + AddExpectedWsEvent(EEventPointerBufferReady, EFalse, TAdvancedPointerEvent::EDefaultPointerNumber, (TUint)iMultiPtrEventClient->ParentWin()); + iMultiPtrEventClient->AddExpectedMovePoint(ptrPos); // If this position is above some other window then we need to consider its window postion also + ptrPos.iX += 10; + ptrPos.iY += 10; + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, 0, 0); + iMultiPtrEventClient->AddExpectedMovePoint(ptrPos); + ptrPos.iX += 10; + ptrPos.iY += 10; + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, 0, 0); + iMultiPtrEventClient->AddExpectedMovePoint(ptrPos); + + // These events should not be added to buffer + for (ptrNum = 1; ptrNum < iMaxDevPointers; ptrNum++) + { + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, 0, ptrNum); + ptrPos.iX += 10; + ptrPos.iY += 10; + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, 0, ptrNum); + SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum); + } + break; + case 11: + // Repeat the above for drag events + SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 0); + AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); + + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, 0, 0); + AddExpectedWsEvent(EEventPointerBufferReady, EFalse, TAdvancedPointerEvent::EDefaultPointerNumber, (TUint)iMultiPtrEventClient->ParentWin()); + iMultiPtrEventClient->AddExpectedMovePoint(ptrPos); + ptrPos.iX += 10; + ptrPos.iY += 10; + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, 0, 0); + iMultiPtrEventClient->AddExpectedMovePoint(ptrPos); + ptrPos.iX += 10; + ptrPos.iY += 10; + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, 0, 0); + iMultiPtrEventClient->AddExpectedMovePoint(ptrPos); + + // These events should not be added to buffer + for (ptrNum = 1; ptrNum < iMaxDevPointers; ptrNum++) + { + SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum); + ptrPos.iX += 10; + ptrPos.iY += 10; + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, 0, ptrNum); + SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, ptrNum); + SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum); + } + + SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 0); + AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); + SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 0); + AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); + break; + case 12: + iMultiPtrEventClient->ParentWin()->BaseWin()->FreePointerMoveBuffer(); + iMultiPtrEventClient->ParentWin()->BaseWin()->DisablePointerMoveBuffer(); + + // Pointer Cursor Position test + // This event is for simulating primary pointer + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, 0); + // Here I am not adding the event because this event is deleted by another move of same pointer + if (ptrPos != iMultiPtrEventClient->iWs.PointerCursorPosition()) + { + TEST(EFalse); + Failed(); + } + + iMultiPtrEventClient->iWs.SetPointerCursorPosition(TPoint(20,20)); + if (TPoint(20,20) != iMultiPtrEventClient->iWs.PointerCursorPosition()) + { + TEST(EFalse); + Failed(); + } + + // Now simulate moves from other pointer, this should not have any effect on pointer cursor position + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, 1); + + // Now move the primary pointer, and check the pointer cursor position which should be same as position used for move + ptrPos.iX = 30; + ptrPos.iY = 30; + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, 0); + AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, proxValue, 0, TAdvancedPointerEvent::EDefaultPointerNumber); + if (ptrPos != iMultiPtrEventClient->iWs.PointerCursorPosition()) + { + TEST(EFalse); + Failed(); + } + + // Send out-of-range event which will not lead to pointer 1 becoming primary + SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 0); + AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, proxValue, 0, TAdvancedPointerEvent::EDefaultPointerNumber); + + // Now check the pointer cursor position, which should be same + // as primary even if there is other pointer in up state, but that is not primary + if (ptrPos != iMultiPtrEventClient->iWs.PointerCursorPosition()) + { + TEST(EFalse); + Failed(); + } + + // This is to bring the pointer1 to out-of-range state + SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 1); + + // then send move event and then again check the pointer cursor position + ptrPos.iX = 20; + ptrPos.iY = 20; + SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 1); + AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); + if (ptrPos != iMultiPtrEventClient->iWs.PointerCursorPosition()) + { + TEST(EFalse); + Failed(); + } + + SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 1); + AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); + + SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 1); + AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); + break; + case 13: + { + // Pointer Cursor Area test-1 + iOrigPtrCursorArea = iMultiPtrEventClient->iWs.PointerCursorArea(); + TRect ptrCurArea(0,0,40,40); + iMultiPtrEventClient->iWs.SetPointerCursorArea(ptrCurArea); + + // Simulate move from pointer0 in PointerCursorArea + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, 0); + AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, proxValue, 0, TAdvancedPointerEvent::EDefaultPointerNumber); + + // Simulate move from other pointer, This should have no effect + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, 1); + SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 1); + + SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 0); + AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, proxValue, 0, TAdvancedPointerEvent::EDefaultPointerNumber); + + // Repeat the above with moves outside pointer cursor area + ptrPos.iX = 50; + ptrPos.iY = 50; + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, 0); + TPoint pointInCurArea(39, 39); + AddExpectedPointerEvent(TPointerEvent::EMove, pointInCurArea, proxValue, 0, TAdvancedPointerEvent::EDefaultPointerNumber); + + // Simulate move from other pointer, This should have no effect + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, 1); + SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 1); + + SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 0); + AddExpectedPointerEvent(TPointerEvent::EOutOfRange, pointInCurArea, proxValue, 0, TAdvancedPointerEvent::EDefaultPointerNumber); + } + break; + case 14: + { + // Pointer Cursor Area test-2 + // repeat the above test with button1 down + SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 0); + AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); + + // Simulate move from other pointer, This should have no effect + SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 1); + SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 1); + SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 1); + + SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 0); + AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); + + SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 0); + AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); + + // Repeat the above with moves outside pointer cursor area + ptrPos.iX = 50; + ptrPos.iY = 50; + TPoint pointInCurArea(39, 39); + SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 0); + AddExpectedPointerEvent(TPointerEvent::EButton1Down, pointInCurArea, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); + + // Simulate move from other pointer, This should have no effect + SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 1); + SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 1); + SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 1); + + SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 0); + AddExpectedPointerEvent(TPointerEvent::EButton1Up, pointInCurArea, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); + + SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 0); + AddExpectedPointerEvent(TPointerEvent::EOutOfRange, pointInCurArea, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber); + } + break; + default: + ClearExpectNonAdvancedPointerEvents(); + iMultiPtrEventClient->iWs.SetPointerCursorArea(iOrigPtrCursorArea); + ResetFlushStopAS(); + break; + } + LogEventsAdded(); + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-ADVANCEDPOINTER-0026 +@SYMPREQ PREQ1226 +@SYMREQ REQ9677, REQ9683 +@SYMTestPriority High +@SYMTestCaseDesc Checks Wserv supports Autofocus for multiple pointers +@SYMTestStatus Implemented + +@SYMTestActions Create 2 group window and respective client windows for it. And simulate EButton1Down on each window consecutively +@SYMTestExpectedResults The received events must match the simulated pointer events +*/ +void CTMultiPtrEventTest::AutoForeGroundForMultiplePointersL() + { + TLogMessageText logText; + _LIT(KSet, "Multiple pointer Auto foreground events: %d of 2"); + logText.AppendFormat(KSet, iEventSet); + LOG_MESSAGE(logText); + + if (!iEventSet) + { + SetAutoFlush(); + AddExpectedWsEvent(EEventFocusGained); // This if for the main groupwindow + iMultiPtrEventClient->ConstructGroupBlankWinL(); + + // These are for child group window creation + AddExpectedWsEvent(EEventFocusLost); // This if for the main groupwindow losing focus + AddExpectedWsEvent(EEventFocusGained); // First group window of this test creation + + AddExpectedWsEvent(EEventFocusLost); // First group window losing focus because of second group creation + AddExpectedWsEvent(EEventFocusGained); // Second group window creation + AddExpectedWsEvent(EEventFocusGroupChanged); // First group window's Enable Focus changed flag is set + } + iMultiPtrEventClient->EventBuffer()->SetEventCount(0); + + TPoint win1PtrPos(20,20); + TPoint win2PtrPos(60,60); + TPoint ptrPos; + TInt autoFocusWin; + switch(iEventSet++) + { + case 0: + for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) + { + if ((ptrNum & 1) == 0) + { + ptrPos = win1PtrPos; + autoFocusWin = 1; + } + else + { + ptrPos = win2PtrPos; + autoFocusWin = 0; + } + SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum); + AddExpectedWsEvent(EEventFocusLost); // Second group window losing focus + AddExpectedWsEvent(EEventFocusGained); // First group window gaining focus + if (ptrNum == 0) + { // First group window has already received EEventFocusGroupChanged + AddExpectedWsEvent(EEventFocusGroupChanged); // Second group window's Enable Focus changed flag is set + } + // In the queue only once EEventFocusGroupChanged is sent + AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, ptrNum); + + SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, ptrNum); + + // These events are to clear out the pointer state + SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, 0, 0, ptrNum); + + if (!iMultiPtrEventClient->CheckOrdinalPosition(autoFocusWin)) + { + TEST(EFalse); + Failed(); + } + } + break; + case 1: + for (TInt ptrNum = iMaxDevPointers/2; ptrNum < iMaxDevPointers; ptrNum++) + { + if ((ptrNum & 1) == 0) + { + ptrPos = win1PtrPos; + autoFocusWin = 1; + } + else + { + ptrPos = win2PtrPos; + autoFocusWin = 0; + } + SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum); + AddExpectedWsEvent(EEventFocusLost); // Second group window losing focus + AddExpectedWsEvent(EEventFocusGained); // First group window gaining focus + if (ptrNum == iMaxDevPointers/2) // first loop + { + // When ever a group window changes focus, For all the group/client windows which have + // registered for receiving group window changes recive EEventFocusGroupChanged + // EEventFocusGroupChanged is sent only once in one queue + AddExpectedWsEvent(EEventFocusGroupChanged); + AddExpectedWsEvent(EEventFocusGroupChanged); + } + AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, ptrNum); + + SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, ptrNum); + + // These events are to clear out the pointer state + SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, 0, 0, ptrNum); + if (!iMultiPtrEventClient->CheckOrdinalPosition(autoFocusWin)) + { + TEST(EFalse); + Failed(); + } + } + break; + default: + iMultiPtrEventClient->DeleteGroupBlankWin(); + ResetFlushStopAS(); + break; + } + + LogEventsAdded(); + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-ADVANCEDPOINTER-0015 +@SYMPREQ PREQ1226 +@SYMREQ REQ9684 +@SYMTestPriority High +@SYMTestCaseDesc Checks Wserv supports out-of-range and pointer Enter/Exit events. +@SYMTestStatus Implemented + +@SYMTestActions Simulate moves and EPointer3DOutOfRange from different pointers +@SYMTestExpectedResults The received events must match the simulated pointer events +*/ +void CTMultiPtrEventTest::MultiPointerOutOfRangeEvents() + { + TLogMessageText logText; + _LIT(KSet, "OutOfRange & Enter/Exit events: %d of 4"); + logText.AppendFormat(KSet, iEventSet); + LOG_MESSAGE(logText); + + if (!iEventSet) + { + SetAutoFlush(); + AddExpectedWsEvent(EEventFocusGained); + } + iMultiPtrEventClient->EventBuffer()->SetEventCount(0); + + TPoint ptrPos(10,10); + TInt proxValue = -iProximityStep; + switch(iEventSet++) + { + case 0: + // Simulate moves and EPointer3DOutOfRange from all pointers + iMultiPtrEventClient->ParentWin()->BaseWin()->PointerFilter(EPointerFilterMove, 0); + for (TInt ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) + { + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, proxValue, 0, ptrNum); + + SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, proxValue, 0, ptrNum); + // Here I am not enabling the enter/exit events filter so not getting those + } + break; + case 1: + // Repeat the above by enabling the enter/exit events + iMultiPtrEventClient->ParentWin()->BaseWin()->PointerFilter(EPointerFilterEnterExit, 0); + for (TInt ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum = ptrNum+2) + { + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); + AddExpectedWsEvent(EEventPointerEnter, EFalse, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, proxValue, 0, ptrNum); + + SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum); + AddExpectedWsEvent(EEventPointerExit, EFalse, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, proxValue, 0, ptrNum); + } + break; + case 2: + // Check the moves from one window to other + for (TInt ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum = ptrNum+2) + { + ptrPos.iX = 10; + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); + AddExpectedWsEvent(EEventPointerEnter, EFalse, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, proxValue, 0, ptrNum); + + ptrPos.iX = (iMultiPtrEventClient->ParentWin()->Size().iWidth)/2 + 10; + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); + AddExpectedWsEvent(EEventPointerExit, EFalse, ptrNum); // move and enter of child window is filtered out + } + break; + case 3: + // Since all the pointers are now on child and when we change the pointer filter + // wserv sends enter event to all pointers + iMultiPtrEventClient->ChildWin()->BaseWin()->PointerFilter(EPointerFilterEnterExit, 0); + for (TInt ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum = ptrNum+2) + { + AddExpectedWsEvent(EEventPointerEnter, EFalse, ptrNum); + } + for (TInt ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum = ptrNum+2) + { + ptrPos.iX = ptrPos.iY =10; + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); + AddExpectedWsEvent(EEventPointerExit, EFalse, ptrNum); + AddExpectedWsEvent(EEventPointerEnter, EFalse, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, proxValue, 0, ptrNum); + + SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum); + AddExpectedWsEvent(EEventPointerExit, EFalse, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, proxValue, 0, ptrNum); + } + break; + default: + ResetFlushStopAS(); + break; + } + + LogEventsAdded(); + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-ADVANCEDPOINTER-0032 +@SYMPREQ PREQ1226 +@SYMREQ REQ9677 +@SYMTestPriority High +@SYMTestCaseDesc Checks Wserv supports Double click events for multi pointer events. +@SYMTestStatus Implemented + +@SYMTestActions Simulate double click events from different pointers +@SYMTestExpectedResults The received events must match the simulated pointer events +*/ +void CTMultiPtrEventTest::DoubleClickForMultiplePointers() + { + // Logic involved, double click settings are global no need to test them + // Check that double click events are sent by wserv for all pointers + TLogMessageText logText; + _LIT(KSet, "Double click settings and events: %d of 1"); + logText.AppendFormat(KSet, iEventSet); + LOG_MESSAGE(logText); + + if (!iEventSet) + { + SetAutoFlush(); + AddExpectedWsEvent(EEventFocusGained); + } + iMultiPtrEventClient->EventBuffer()->SetEventCount(0); + + TPoint ptrPos(10,10); + switch(iEventSet++) + { + case 0: + for (TInt ptrNum = 0; ptrNum < Min(iMaxDevPointers, 7); ptrNum++) + { + SimulatePointerDownUp(ptrPos.iX, ptrPos.iY, 0, ptrNum); + SimulatePointerDownUp(ptrPos.iX, ptrPos.iY, 0, ptrNum); + AddExpectedPointerDownUp(ptrPos, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, EModifierDoubleClick, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, ptrNum); + } + break; + default: + ResetFlushStopAS(); + break; + } + + LogEventsAdded(); + } + + +/** +@SYMTestCaseID GRAPHICS-WSERV-ADVANCEDPOINTER-0031 +@SYMPREQ PREQ1226 +@SYMREQ REQ9677 +@SYMTestPriority High +@SYMTestCaseDesc Checks Wserv supports Virtual keyboard for multi pointer events. +@SYMTestStatus Implemented + +@SYMTestActions Create virtual keyboard by AddKeyRect() to a window and simulate pointer events from all pointers +@SYMTestExpectedResults The received events must match the simulated Key events +*/ +void CTMultiPtrEventTest::VirtualKeyBoardForMultiplePointers() + { + TLogMessageText logText; + _LIT(KSet, "VirtualKeyboard SetOfEvents: %d of 8"); + logText.AppendFormat(KSet, iEventSet); + LOG_MESSAGE(logText); + + // Create virtual keyboard for 8 keys on parent window + // give a 5 pixel spacing at start/end and in between keys + const TInt noVirtualKeys = iMaxDevPointers; + const TInt keySpacing = 5; + const TInt keyWidth = ((iPhysicalScreenSize.iWidth/2) - ((noVirtualKeys+1)*keySpacing))/noVirtualKeys; + const TInt keyHeight = keyWidth/2; + TInt startX = keySpacing; + const TInt baseChar ='A'; + + if (!iEventSet) + { + SetAutoFlush(); + for (TInt count=0; count < noVirtualKeys; count++) + { + iMultiPtrEventClient->ParentWin()->BaseWin()->AddKeyRect(TRect(startX, keySpacing, startX+keyWidth, keySpacing+keyHeight), baseChar+count,EFalse); + startX+=(keyWidth+keySpacing); + } + AddExpectedWsEvent(EEventFocusGained); + } + + iMultiPtrEventClient->EventBuffer()->SetEventCount(0); + TPoint ptrPos(keySpacing+(keyWidth/2), keySpacing+(keyHeight/2)); + + TInt count = 0; + if (iEventSet < iMaxDevPointers) + { + for (; ptrPos.iX < (iPhysicalScreenSize.iWidth/2)-5; ptrPos.iX += (keySpacing+keyWidth), count++) + { + SimulatePointerDownUp(ptrPos.iX, ptrPos.iY, 0, iEventSet); + AddExpectedKeyDownUp(baseChar+count); + } + } + else + { + ResetFlushStopAS(); + } + iEventSet++; + + LogEventsAdded(); + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-ADVANCEDPOINTER-0021 +@SYMPREQ PREQ1226 +@SYMREQ REQ9677,REQ9683, +@SYMTestPriority High +@SYMTestCaseDesc Checks Wserv supports Grabbing in case of multi pointer events. +@SYMTestStatus Implemented + +@SYMTestActions Simulate EButton1Down events on iParentWin. Simulate Drag and Button1Up events on iChildWin. + SetPointerGrab is called on iParentWin for first test and disabled for the second. +@SYMTestExpectedResults The Drag and Button1Up events contain a handle to iParentWin when Grabbing active. + The Drag and Button1Up events contain a handle to iChildWin when Grabbing disabled. +*/ +void CTMultiPtrEventTest::GrabbingMultiPointerEvents() + { + // Test Grabbing of multi pointer events + // 1. Test Wserv supports Grabbing in case of multi-pointer events + // 2. Test pointer events are delivered correctly when Grabbing is disabled. + TLogMessageText logText; + _LIT(KSet, "GrabbingMultiPtrEvents SetOfEvents: %d of 2"); + logText.AppendFormat(KSet, iEventSet); + LOG_MESSAGE(logText); + + if (!iEventSet) + { + SetAutoFlush(); + } + + iMultiPtrEventClient->EventBuffer()->SetEventCount(0); + + TPoint ptrPos; + + switch(iEventSet++) + { + case 0: + INFO_PRINTF1(_L("Check Wserv supports Grabbing in case of multi-pointer events")); + // Check pointer events are delivered to the window where the EButton1Down event occured, + // even if subsequent events are simulated outside this window. + AddExpectedWsEvent(EEventFocusGained); + iMultiPtrEventClient->ParentWin()->BaseWin()->PointerFilter(EPointerFilterDrag, 0); + iMultiPtrEventClient->ParentWin()->BaseWin()->SetPointerGrab(ETrue); + TestGrabbingForMultiPointer(ETrue); + break; + case 1: + INFO_PRINTF1(_L("Check pointer events are delivered correctly when Grabbing is disabled.")); + // Check pointer events are delivered to the window on which they occured. + iMultiPtrEventClient->ParentWin()->BaseWin()->SetPointerGrab(EFalse); + TestGrabbingForMultiPointer(EFalse); + break; + default: + ResetFlushStopAS(); + break; + } + LogEventsAdded(); + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-ADVANCEDPOINTER-0025 +@SYMPREQ PREQ1226 +@SYMREQ REQ9677,REQ9683, +@SYMTestPriority High +@SYMTestCaseDesc Checks Wserv supports Filtering in case of multi pointer events. +@SYMTestStatus Implemented + +@SYMTestActions Simulate Move and Drag events. Add only Button1Up and Button1Down to TWsEvent buffer. + Disable Filtering and repeat test with the addition of Move and Drag events to TWsEvent buffer. +@SYMTestExpectedResults The received events must match the expected simulated raw events + The received events must match the simulated raw events +*/ +void CTMultiPtrEventTest::FilteringMultiPointerEvents() + { + // Test Filtering of multi pointer events + // 1. Test pointer move and drag events are filtered correctly by Wserv + // 2. Test pointer events are delivered correctly when Filtered is disabled. + TLogMessageText logText; + _LIT(KSet, "FilteringMultiPtrEvents SetOfEvents: %d of 2"); + logText.AppendFormat(KSet, iEventSet); + LOG_MESSAGE(logText); + + if (!iEventSet) + { + SetAutoFlush(); + } + + iMultiPtrEventClient->EventBuffer()->SetEventCount(0); + + TPoint ptrPos; + + switch(iEventSet++) + { + case 0: + INFO_PRINTF1(_L("Check pointer move and drag events are filtered with multi-pointer events")); + // Check pointer move and drag events are filtered by Wserv + AddExpectedWsEvent(EEventFocusGained); + + // Ensure default values are set i.e. Drag and Move events are filtered out and not delivered to the client. + iMultiPtrEventClient->ParentWin()->BaseWin()->PointerFilter(EPointerFilterDrag|EPointerFilterMove, + EPointerFilterDrag|EPointerFilterMove); + TestFilteringForMultiPointer(ETrue); + break; + case 1: + INFO_PRINTF1(_L("Check pointer move and drag events are not filtered, with multi-pointer events, when filtering is disabled")); + // Check move and drag events are not filtered by Wserv when filtering is disabled + + // Enable Drag and Move events + iMultiPtrEventClient->ParentWin()->BaseWin()->PointerFilter(EPointerFilterDrag|EPointerFilterMove, 0); + TestFilteringForMultiPointer(EFalse); + break; + default: + ResetFlushStopAS(); + break; + } + LogEventsAdded(); + } + +void CTMultiPtrEventTest::SetDefaultScreenMode() + { + iMultiPtrEventClient->iScreen->SetAppScreenMode(0); + TheClient->iScreen->SetAppScreenMode(0); + iMultiPtrEventClient->iScreen->SetScreenMode(0); + iMultiPtrEventClient->iScreen->SetCurrentRotations(0, CFbsBitGc::EGraphicsOrientationNormal); + } + +TPoint PhysicalToLogical(TPoint aPhysicalPt, TPoint aOrigin, TSize aSize) + { + return PhysicalToLogical(aPhysicalPt-aOrigin, aSize); + } + +TPoint CTMultiPtrEventTest::GetPointerPostionOnRotatedMode(TPoint aPointerPos, CFbsBitGc::TGraphicsOrientation aRotation) + { + if (aRotation == CFbsBitGc::EGraphicsOrientationNormal) + { + return aPointerPos; + } + else if (aRotation == CFbsBitGc::EGraphicsOrientationRotated90) + { + // here width is actually height in rotated mode + return TPoint(iPhysicalScreenSize.iWidth - aPointerPos.iY - 1, aPointerPos.iX); + } + else if (aRotation == CFbsBitGc::EGraphicsOrientationRotated180) + { + return TPoint(iPhysicalScreenSize.iWidth - aPointerPos.iX - 1, iPhysicalScreenSize.iHeight - aPointerPos.iY - 1); + } + else if (aRotation == CFbsBitGc::EGraphicsOrientationRotated270) + { + // here width is actually height in rotated mode + return TPoint(aPointerPos.iY, iPhysicalScreenSize.iHeight - aPointerPos.iX -1); + } + return TPoint(0,0); + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-ADVANCEDPOINTER-0028 +@SYMPREQ PREQ1226 +@SYMREQ REQ9677, REQ9683 +@SYMTestPriority High +@SYMTestCaseDesc To check Wserv sends multi pointer events in Different screen modes +@SYMTestStatus Implemented + +@SYMTestActions Simulate multi pointer events in Different screenmodes +@SYMTestExpectedResults The received events must match the simulated raw events +*/ +void CTMultiPtrEventTest::MultiPointerEventsInDiffScreenModes() + { + // Logic inloved, For a particular screen mode check pointer down/up, moves and drags + // for different pointers and for different co-ordinates. + // For each screen mode check these events on diffferent rotation that screen mode supports + // During the last switch case increment the screenmode + TLogMessageText logText; + _LIT(KSet, "Multi pointer events in screenmode(%d): %d of 2"); + logText.AppendFormat(KSet, iCurrentScreenMode+1, iEventSet); + LOG_MESSAGE(logText); + + TInt numScrMode = iMultiPtrEventClient->iScreen->NumScreenModes(); + iMultiPtrEventClient->EventBuffer()->SetEventCount(0); + + if (!iEventSet && !iChangeScreenMode) + { + SetAutoFlush(); + iChangeScreenMode = ETrue; + AddExpectedWsEvent(EEventFocusGained); + } + else + { + if (iChangeScreenMode) + { + if (iCurrentScreenMode >= numScrMode) + { +EndFun: + SetDefaultScreenMode(); + ResetFlushStopAS(); + return; + } + } + } + + if (iChangeScreenMode) + { + iMultiPtrEventClient->iScreen->SetAppScreenMode(iCurrentScreenMode); + TheClient->iScreen->SetAppScreenMode(iCurrentScreenMode); + iMultiPtrEventClient->iScreen->SetScreenMode(iCurrentScreenMode); + iChangeScreenMode = EFalse; + } + + CArrayFixFlat* rotations = NULL; + TRAPD(err, + rotations = new(ELeave) CArrayFixFlat(1); + iMultiPtrEventClient->iScreen->GetRotationsList(iCurrentScreenMode, rotations)); + if (err != KErrNone) + { + if (iEventSet) + { + goto EndFun; + } + else + { + return; + } + } + +#if !defined(__WINS__) + TPoint ptrRotatedPos; + TPoint ptrNormalPos; +#else + TPoint ptrPhyPos; +#endif + TPoint ptrLogPos; + + TInt ptrNum = 0; + TInt proxValue = 0; + // Since screenmode positioning and screenmode scaling is not supported in NGA wserv2 + // but it is supported in Non NGA. But for NGA it will return (0,0) as origin and (1,1) as scale. + TPoint screenOrigin(iMultiPtrEventClient->iScreen->GetDefaultScreenModeOrigin()); + TPoint scaledScreenOrigin(iMultiPtrEventClient->iScreen->GetCurrentScreenModeScaledOrigin()); + TSize scale(iMultiPtrEventClient->iScreen->GetCurrentScreenModeScale()); + + switch(iEventSet++) + { + case 0: + // Simulate Pointer down/up for different rotations of a screenmode + for (TInt rotCou = 0; rotCou < rotations->Count(); rotCou++) + { + CFbsBitGc::TGraphicsOrientation newOrientation = static_cast(rotations[0][rotCou]); + iMultiPtrEventClient->iScreen->SetCurrentRotations(iCurrentScreenMode, newOrientation); + +#if !defined(__WINS__) + ptrNormalPos = screenOrigin; + ptrRotatedPos = GetPointerPostionOnRotatedMode(ptrNormalPos, newOrientation); + SimulatePointerDownUp(ptrRotatedPos.iX, ptrRotatedPos.iY, 0, ptrNum); + ptrLogPos = PhysicalToLogical(ptrNormalPos, screenOrigin, scale); + AddExpectedPointerDownUp(ptrLogPos, 0, ptrNum); + + ptrNormalPos.iX += 10; + ptrNormalPos.iY += 5; + ptrNum = iMaxDevPointers/2; + ptrRotatedPos = GetPointerPostionOnRotatedMode(ptrNormalPos, newOrientation); + SimulatePointerDownUp(ptrRotatedPos.iX, ptrRotatedPos.iY, 0, ptrNum); + ptrLogPos = PhysicalToLogical(ptrNormalPos, screenOrigin, scale); + AddExpectedPointerDownUp(ptrLogPos, 0, ptrNum); + + ptrNormalPos.iX += 5; + ptrNormalPos.iY += 10; + ptrNum = iMaxDevPointers-1; + ptrRotatedPos = GetPointerPostionOnRotatedMode(ptrNormalPos, newOrientation); + SimulatePointerDownUp(ptrRotatedPos.iX, ptrRotatedPos.iY, 0, ptrNum); + ptrLogPos = PhysicalToLogical(ptrNormalPos, screenOrigin, scale); + AddExpectedPointerDownUp(ptrLogPos, 0, ptrNum); + ptrNum = 0; +#else + // This is not needed for NGA, becasue NGA wserv does not support positioning and scaling + // but for early access we are deliverying for NonNGA so we need it. + ptrPhyPos = screenOrigin; + ptrLogPos = PhysicalToLogical(ptrPhyPos, screenOrigin, scale); + SimulatePointerDownUp(ptrPhyPos.iX, ptrPhyPos.iY, 0, ptrNum); + AddExpectedPointerDownUp(ptrLogPos, 0, ptrNum); + ptrPhyPos.iX += 10; + ptrPhyPos.iY += 5; + ptrNum = iMaxDevPointers/2; + ptrLogPos = PhysicalToLogical(ptrPhyPos, screenOrigin, scale); + SimulatePointerDownUp(ptrPhyPos.iX, ptrPhyPos.iY, 0, ptrNum); + AddExpectedPointerDownUp(ptrLogPos, 0, ptrNum); + ptrPhyPos.iX += 5; + ptrPhyPos.iY += 10; + ptrNum = iMaxDevPointers-1; + ptrLogPos = PhysicalToLogical(ptrPhyPos, screenOrigin, scale); + SimulatePointerDownUp(ptrPhyPos.iX, ptrPhyPos.iY, 0, ptrNum); + AddExpectedPointerDownUp(ptrLogPos, 0, ptrNum); + ptrNum = 0; +#endif + } + break; + case 1: + // Simulate moves for different rotations of a screenmode with different Proximity + iMultiPtrEventClient->ParentWin()->BaseWin()->PointerFilter(EPointerFilterMove,0); + for (TInt rotCou = 0; rotCou < rotations->Count(); rotCou++) + { + CFbsBitGc::TGraphicsOrientation newOrientation = static_cast(rotations[0][rotCou]); + iMultiPtrEventClient->iScreen->SetCurrentRotations(iCurrentScreenMode, newOrientation); + +#if !defined(__WINS__) + ptrNormalPos = screenOrigin; + ptrRotatedPos = GetPointerPostionOnRotatedMode(ptrNormalPos, newOrientation); + proxValue = -iProximityStep; + SimulatePointerEvent(TRawEvent::EPointerMove, ptrRotatedPos.iX, ptrRotatedPos.iY, proxValue, ptrNum); + ptrLogPos = PhysicalToLogical(ptrNormalPos, screenOrigin, scale); + AddExpectedPointerEvent(TPointerEvent::EMove, ptrLogPos, proxValue, 0, ptrNum); + SimulatePointerDownUp(ptrRotatedPos.iX, ptrRotatedPos.iY, 0, ptrNum); + AddExpectedPointerDownUp(ptrLogPos, 0, ptrNum); + + ptrNormalPos.iX += 10; + ptrNormalPos.iY += 5; + ptrNum = iMaxDevPointers/2; + if (proxValue-iProximityStep > iMaxProximity) + { + proxValue -= iProximityStep; + } + ptrRotatedPos = GetPointerPostionOnRotatedMode(ptrNormalPos, newOrientation); + SimulatePointerEvent(TRawEvent::EPointerMove, ptrRotatedPos.iX, ptrRotatedPos.iY, proxValue, ptrNum); + ptrLogPos = PhysicalToLogical(ptrNormalPos, screenOrigin, scale); + AddExpectedPointerEvent(TPointerEvent::EMove, ptrLogPos, proxValue, 0, ptrNum); + SimulatePointerDownUp(ptrRotatedPos.iX, ptrRotatedPos.iY, 0, ptrNum); + AddExpectedPointerDownUp(ptrLogPos, 0, ptrNum); + ptrNum = 0; +#else + ptrPhyPos = screenOrigin; + proxValue = -iProximityStep; + ptrLogPos = PhysicalToLogical(ptrPhyPos, screenOrigin, scale); + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPhyPos.iX, ptrPhyPos.iY, proxValue, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EMove, ptrLogPos, proxValue, 0, ptrNum); + SimulatePointerDownUp(ptrPhyPos.iX, ptrPhyPos.iY, 0, ptrNum); + AddExpectedPointerDownUp(ptrLogPos, 0, ptrNum); + + ptrPhyPos.iX += 10; + ptrPhyPos.iY += 5; + ptrNum = iMaxDevPointers/2; + if (proxValue-iProximityStep > iMaxProximity) + { + proxValue -= iProximityStep; + } + ptrLogPos = PhysicalToLogical(ptrPhyPos, screenOrigin, scale); + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPhyPos.iX, ptrPhyPos.iY, proxValue, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EMove, ptrLogPos, proxValue, 0, ptrNum); + SimulatePointerDownUp(ptrPhyPos.iX, ptrPhyPos.iY, 0, ptrNum); + AddExpectedPointerDownUp(ptrLogPos, 0, ptrNum); + ptrNum = 0; +#endif + } + break; + case 2: + { + // Simulate drags for different rotations of a screenmode +#if !defined(__WINS__) + TPoint intNormalPt; + TPoint intRotatedPt; +#else + TPoint interPhyPt; + TPoint interLogPt; +#endif + iMultiPtrEventClient->ParentWin()->BaseWin()->PointerFilter(EPointerFilterDrag,0); + for (TInt rotCou = 0; rotCou < rotations->Count(); rotCou++) + { + CFbsBitGc::TGraphicsOrientation newOrientation = static_cast(rotations[0][rotCou]); + iMultiPtrEventClient->iScreen->SetCurrentRotations(iCurrentScreenMode, newOrientation); +#if !defined(__WINS__) + ptrNormalPos = screenOrigin; + intNormalPt.iX = ptrNormalPos.iX+4; + intNormalPt.iY = ptrNormalPos.iY+5; + ptrRotatedPos = GetPointerPostionOnRotatedMode(ptrNormalPos, newOrientation); + intRotatedPt = GetPointerPostionOnRotatedMode(intNormalPt, newOrientation); + SimulatePointerEvent(TRawEvent::EButton1Down, ptrRotatedPos.iX, ptrRotatedPos.iY, 0, ptrNum); + SimulatePointerEvent(TRawEvent::EPointerMove, intRotatedPt.iX, intRotatedPt.iY, 0, ptrNum); + SimulatePointerEvent(TRawEvent::EButton1Up, intRotatedPt.iX, intRotatedPt.iY, 0, ptrNum); + ptrLogPos = PhysicalToLogical(ptrNormalPos, screenOrigin, scale); + AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrLogPos, 0, 0, ptrNum); + TPoint intLogPt = PhysicalToLogical(intNormalPt, screenOrigin, scale); + AddExpectedPointerEvent(TPointerEvent::EDrag, intLogPt, 0, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EButton1Up, intLogPt, 0, 0, ptrNum); + + ptrNormalPos.iX += 10; + ptrNormalPos.iY += 5; + ptrNum = iMaxDevPointers-1; + intNormalPt.iX = ptrNormalPos.iX+5; + intNormalPt.iY = ptrNormalPos.iY+4; + ptrRotatedPos = GetPointerPostionOnRotatedMode(ptrNormalPos, newOrientation); + intRotatedPt = GetPointerPostionOnRotatedMode(intNormalPt, newOrientation); + SimulatePointerEvent(TRawEvent::EButton1Down, ptrRotatedPos.iX, ptrRotatedPos.iY, 0, ptrNum); + SimulatePointerEvent(TRawEvent::EPointerMove, intRotatedPt.iX, intRotatedPt.iY, 0, ptrNum); + SimulatePointerEvent(TRawEvent::EButton1Up, intRotatedPt.iX, intRotatedPt.iY, 0, ptrNum); + ptrLogPos = PhysicalToLogical(ptrNormalPos, screenOrigin, scale); + AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrLogPos, 0, 0, ptrNum); + intLogPt = PhysicalToLogical(intNormalPt, screenOrigin, scale); + AddExpectedPointerEvent(TPointerEvent::EDrag, intLogPt, 0, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EButton1Up, intLogPt, 0, 0, ptrNum); + + ptrNum = 0; +#else + ptrPhyPos = screenOrigin; + interPhyPt.iX = ptrPhyPos.iX+4; + interPhyPt.iY = ptrPhyPos.iY+5; + ptrLogPos = PhysicalToLogical(ptrPhyPos, screenOrigin, scale); + interLogPt = PhysicalToLogical(interPhyPt, screenOrigin, scale); + SimulatePointerEvent(TRawEvent::EButton1Down, ptrPhyPos.iX, ptrPhyPos.iY, 0, ptrNum); + SimulatePointerEvent(TRawEvent::EPointerMove, interPhyPt.iX, interPhyPt.iY, 0, ptrNum); + SimulatePointerEvent(TRawEvent::EButton1Up, interPhyPt.iX, interPhyPt.iY, 0, ptrNum); + interLogPt = PhysicalToLogical(interPhyPt, screenOrigin, scale); + AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrLogPos, 0, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EDrag, interLogPt, 0, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EButton1Up, interLogPt, 0, 0, ptrNum); + + ptrPhyPos.iX += 10; + ptrPhyPos.iY += 5; + ptrNum = iMaxDevPointers-1; + interPhyPt.iX = ptrPhyPos.iX+5; + interPhyPt.iY = ptrPhyPos.iY+4; + + SimulatePointerEvent(TRawEvent::EButton1Down, ptrPhyPos.iX, ptrPhyPos.iY, 0, ptrNum); + SimulatePointerEvent(TRawEvent::EPointerMove, interPhyPt.iX, interPhyPt.iY, 0, ptrNum); + SimulatePointerEvent(TRawEvent::EButton1Up, interPhyPt.iX, interPhyPt.iY, 0, ptrNum); + + ptrLogPos = PhysicalToLogical(ptrPhyPos, screenOrigin, scale); + interLogPt = PhysicalToLogical(interPhyPt, screenOrigin, scale); + AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrLogPos, 0, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EDrag, interLogPt, 0, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EButton1Up, interLogPt, 0, 0, ptrNum); + ptrNum = 0; +#endif + } + } + iChangeScreenMode = ETrue; + iEventSet = 0; + iCurrentScreenMode++; + break; + default: + break; + } + + delete rotations; + + LogEventsAdded(); + } + +/* + Checks if pointer click plugin has an error when testing its events + If so then it gets the error deescription and displays the same + */ +void CTMultiPtrEventTest::TestAndDisplayPtrClickError() + { + TPckgBuf intPkg; + TInt retErr = iClick.CommandReply(EMultiPtrClickEventError, intPkg); + if (retErr != KErrNone) + { + _LIT(KError, "Failed in Pointer click plugin"); + LOG_MESSAGE(KError); + // Error is ignored here, becasue this function should not leave + TRAPD(errMem, iErrDesc = iHeap->AllocL(KErrDescSize)); + if (errMem == KErrNone) + { + intPkg() = reinterpret_cast(iErrDesc) - iChunk.Base() ; + + // get the error desccription, print it out and stop the tests + TInt retVal = iClick.CommandReply(EADllMultiPtrEventErrorDesc, intPkg); + if (retVal > KErrNone) + { + TPtr8 memPtr2(reinterpret_cast(iErrDesc), retVal, retVal); + HBufC16* buf16 = NULL; + TRAPD(err, buf16 = HBufC16::NewL(retVal)); // Error is ignored here + if (err == KErrNone) + { + buf16->Des().Copy(memPtr2); + LOG_MESSAGE(buf16->Des()); + delete buf16; + } + } + iHeap->Free(iErrDesc); + } + Failed(); + } + iClick.CommandReply(EMultiPtrClickEventReset, intPkg); + } + +void CTMultiPtrEventTest::AddExpectedMultiPtrClickEvent(TPointerEvent::TType aType, TPoint aPos, TInt aZ, TUint aModifier, TUint8 aPointerNumber, TUint aHandle) + { + TPckgBuf evtPkg; + TWsEvent& event=evtPkg(); + event.SetType(EEventPointer); + iMultiPtrEventClient->CalculatePtrPosAndSet3Ddata(event, aType, aPos, aModifier, aZ, aPointerNumber, aHandle); + + // change the parent position here as they r with respect to screen corodinates. + event.Pointer()->iParentPosition = aPos; + + iClick.CommandReply(EMultiPtrClickEventAdd, evtPkg); + AddExpectedMultiPtrClickOtherEvent(aType, aPos, aZ, aModifier, aPointerNumber, aHandle); + } + +void CTMultiPtrEventTest::AddExpectedMultiPtrClickOtherEvent(TPointerEvent::TType aType, TPoint aPos, TInt aZ, TUint aModifier, TUint8 aPointerNumber, TUint aHandle) + { + TWsEvent event; + event.SetType(EEventPointer); + iMultiPtrEventClient->CalculatePtrPosAndSet3Ddata(event, aType, aPos, aModifier, aZ, aPointerNumber, aHandle); + + TPointerEventData otherEvent; + otherEvent.iClientHandle = event.Handle(); + otherEvent.iCurrentPos = aPos; + otherEvent.iPointerEvent = *event.Pointer(); + + TPckgBuf evtPkg(otherEvent); + iClick.CommandReply(EMultiPtrOtherEventAdd, evtPkg); + } + +/* + Function of creating + 1. Pointer click plugin + 2. RChunk for transfering error description from pointer click plugin to current test + 3. RHeap for allocating memory in RChunk +*/ +void CTMultiPtrEventTest::CreatePointerClickPluginL() + { + // tranfer this to another function + iClick=RSoundPlugIn(TheClient->iWs); + User::LeaveIfError(iClick.Construct(TUid::Uid(MULTIPTR_CLICK_THIRD_UID))); + TBool ptrPluginLoadable = EFalse; + iClick.IsLoaded(ptrPluginLoadable); + if (ptrPluginLoadable) + { + User::LeaveIfError(iClick.Load(KMultiPtrPluginDll)); + iPtrPluginLoaded = ETrue; + } + iClick.SetPenClick(ETrue); + iHeap = UserHeap::ChunkHeap(&KMultiPtrClickChunk, 128, 256, 10); + if (iHeap == NULL) + { + User::LeaveNoMemory(); + } + User::LeaveIfError(iChunk.OpenGlobal(KMultiPtrClickChunk, ETrue)); + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-ADVANCEDPOINTER-0027 +@SYMPREQ PREQ1226 +@SYMREQ REQ9677, REQ9683 +@SYMTestPriority High +@SYMTestCaseDesc To check Wserv sends multi pointer events to PointerClickPlugin +@SYMTestStatus Implemented + +@SYMTestActions Simulate multi pointer events for PointerClickPlugin +@SYMTestExpectedResults The received events must match the simulated raw events +*/ +void CTMultiPtrEventTest::MultiPointerEventsForPointerClickL() + { + TLogMessageText logText; + _LIT(KSet, "Multi pointer events for PointerClickPlugin: %d of 4"); + logText.AppendFormat(KSet, iEventSet); + LOG_MESSAGE(logText); + + iMultiPtrEventClient->EventBuffer()->SetEventCount(0); + if (!iEventSet) + { + SetAutoFlush(); + } + + TPoint ptrPos; + TInt ptrNum = 0; + TInt prValue = 0; + TInt proxValue = 0; + TInt xInc = iPhysicalScreenSize.iWidth/iMaxDevPointers; + TInt yInc = iPhysicalScreenSize.iHeight/iMaxDevPointers; + + switch(iEventSet++) + { + case 0: + // Creates RSoundPlugin, loads the plugin DLL, create RChunk and RHeap + CreatePointerClickPluginL(); + AddExpectedWsEvent(EEventFocusGained); + for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) + { + AddExpectedMultiPtrClickEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, ptrNum); + AddExpectedMultiPtrClickEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, ptrNum); + AddExpectedPointerDownUp(ptrPos, 0, ptrNum); + SimulatePointerDownUp(ptrPos.iX, ptrPos.iY, 0, ptrNum); + ptrPos.iX += xInc; + ptrPos.iY += yInc; + } + TestAndDisplayPtrClickError(); + break; + case 1: + // Simulate moves from different pointer with different pressure + iMultiPtrEventClient->ParentWin()->BaseWin()->PointerFilter(EPointerFilterMove,0); + iMultiPtrEventClient->ChildWin()->BaseWin()->PointerFilter(EPointerFilterMove,0); + ptrPos.SetXY(0,0); + prValue = iPressureStep; + for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) + { + AddExpectedMultiPtrClickEvent(TPointerEvent::EMove, ptrPos, prValue, 0, ptrNum); + AddExpectedMultiPtrClickEvent(TPointerEvent::EButton1Down,ptrPos,0,0,ptrNum); + AddExpectedMultiPtrClickEvent(TPointerEvent::EButton1Up,ptrPos,0,0,ptrNum); + AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, prValue, 0, ptrNum); + AddExpectedPointerDownUp(ptrPos, 0, ptrNum); + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, prValue, ptrNum); + SimulatePointerDownUp(ptrPos.iX, ptrPos.iY, 0, ptrNum); + ptrPos.iX += xInc; + ptrPos.iY += yInc; + } + TestAndDisplayPtrClickError(); + break; + case 2: + // Simulate moves from different pointer with different proximity + ptrPos.SetXY(0,0); + proxValue = -iProximityStep; + for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) + { + AddExpectedMultiPtrClickEvent(TPointerEvent::EMove, ptrPos, proxValue, 0, ptrNum); + AddExpectedMultiPtrClickEvent(TPointerEvent::EButton1Down,ptrPos,0,0,ptrNum); + AddExpectedMultiPtrClickEvent(TPointerEvent::EButton1Up,ptrPos,0,0,ptrNum); + AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, proxValue, 0, ptrNum); + AddExpectedPointerDownUp(ptrPos, 0, ptrNum); + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); + SimulatePointerDownUp(ptrPos.iX, ptrPos.iY, 0, ptrNum); + ptrPos.iX += xInc; + ptrPos.iY += yInc; + } + TestAndDisplayPtrClickError(); + break; + case 3: + { + // Simulate drags from all pointers + iMultiPtrEventClient->ParentWin()->BaseWin()->PointerFilter(EPointerFilterDrag,0); + iMultiPtrEventClient->ChildWin()->BaseWin()->PointerFilter(EPointerFilterDrag,0); + ptrPos.SetXY(0,0); + TPoint interPt; + for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) + { + AddExpectedMultiPtrClickEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, ptrNum); + interPt.iX = ptrPos.iX+1; + interPt.iY = ptrPos.iY+2; + AddExpectedMultiPtrClickEvent(TPointerEvent::EDrag, interPt, 0, 0, ptrNum); + AddExpectedMultiPtrClickEvent(TPointerEvent::EButton1Up, interPt, 0, 0, ptrNum); + + AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EDrag, interPt, 0, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EButton1Up, interPt, 0, 0, ptrNum); + + SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum); + SimulatePointerEvent(TRawEvent::EPointerMove, interPt.iX, interPt.iY, 0, ptrNum); + SimulatePointerEvent(TRawEvent::EButton1Up, interPt.iX, interPt.iY, 0, ptrNum); + + ptrPos.iX += xInc; + ptrPos.iY += yInc; + } + TestAndDisplayPtrClickError(); + } + break; + default: + iClick.Unload(); + iClick.Close(); + iPtrPluginLoaded = EFalse; + iHeap->Close(); + iHeap = NULL; + iChunk.Close(); + ResetFlushStopAS(); + break; + } + + LogEventsAdded(); + } + +void CTMultiPtrEventTest::GetRemainingEventsFromSecondaryClient() + { + if (iSecMultiPtrEventClient->EventBuffer()->EventsRemaining() != 0) + { + iSecMultiPtrEventClient->EventBuffer()->SetNestedLoopState(ETrue); + CActiveScheduler::Start(); + } + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-ADVANCEDPOINTER-0011 +@SYMPREQ PREQ1226 +@SYMREQ REQ9677,REQ9674, +@SYMTestPriority High +@SYMTestCaseDesc To check Wserv sends Multi Pointer events to correct clients +@SYMTestStatus Implemented + +@SYMTestActions Simulate multi pointer events on windows from different client. +@SYMTestExpectedResults The received events must match the simulated raw events +*/ +void CTMultiPtrEventTest::MultiClientMultiPointerEvents() + { + // Logic for this test code + // Create a secondary client when running this test + // Simulate events for both main client and secondary simulataneously + // Get events from DoRunL() of event buffer class + // Before running next set of events, get all the events from secondary client + // If test fails on any client make sure both active scheduler are stopped + TLogMessageText logText; + _LIT(KSet, "Multi pointer events for Multi client: %d of 5"); + logText.AppendFormat(KSet, iEventSet); + LOG_MESSAGE(logText); + + iMultiPtrEventClient->EventBuffer()->SetEventCount(0); + iSecMultiPtrEventClient->EventBuffer()->SetEventCount(0); + if (!iEventSet) + { + SetAutoFlush(); + iSecClientFlush = iSecMultiPtrEventClient->iWs.SetAutoFlush(ETrue); + } + + TPoint ptrPos; + TInt ptrNum = 0; + TInt prValue = 0; + TInt proxValue = 0; + TInt xInc = (iPhysicalScreenSize.iWidth/2)/iMaxDevPointers; + TInt yInc = iPhysicalScreenSize.iHeight/iMaxDevPointers; + TPoint secPt(iPhysicalScreenSize.iWidth/2,0); + TInt ptrSecNum = iMaxDevPointers-1; + + switch(iEventSet++) + { + case 0: + ptrPos.SetXY(0,0); + + // These events are generated when primary client is created and its group + // window constructed and then when button down for primary client is called + AddExpectedWsEvent(EEventFocusGained); + AddExpectedWsEvent(EEventFocusLost); + AddExpectedWsEvent(EEventFocusGained); + + // Simulate pointer down/up events for primary client from 0,1,3... pointers and 6,5,4... pointers for secondary client + for (ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) + { + SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, ptrNum); + + SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, ptrNum); + + ptrPos.iX += xInc; + ptrPos.iY += yInc; + } + + ptrPos.iX = iPhysicalScreenSize.iWidth/2; + ptrPos.iY = 0; + + // These events are generated when secondary cleint is created and then when + // button down for primary client is called, then when SetOrdinalPosition is + // called on secondary cleint's group window + AddExpectedWsEvent(EEventFocusGained, ETrue); + AddExpectedWsEvent(EEventFocusLost, ETrue); + iSecMultiPtrEventClient->iGroup->GroupWin()->SetOrdinalPosition(0, 1); + AddExpectedWsEvent(EEventFocusGained, ETrue); + + AddExpectedWsEvent(EEventFocusLost); + + for (ptrNum = iMaxDevPointers/2; ptrNum < iMaxDevPointers; ptrNum++) + { + SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, ptrNum, (TUint)iSecMultiPtrEventClient->ParentWin(), ETrue); + + SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, ptrNum, (TUint)iSecMultiPtrEventClient->ParentWin(), ETrue); + + ptrPos.iX += xInc; + ptrPos.iY += yInc; + } + break; + case 1: + // Simulate move events from primary and secondary client simultaneously with pressure + iMultiPtrEventClient->ParentWin()->BaseWin()->PointerFilter(EPointerFilterMove, 0); + iSecMultiPtrEventClient->ParentWin()->BaseWin()->PointerFilter(EPointerFilterMove, 0); + + ptrPos.SetXY(0,0); + prValue = iPressureStep; + + for (ptrNum = 0; (ptrNum < iMaxDevPointers/2 && ptrSecNum >= iMaxDevPointers/2); ptrNum++, ptrSecNum--) + { + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, prValue, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, prValue, 0, ptrNum); + ptrPos.iX += xInc; + ptrPos.iY += yInc; + + SimulatePointerEvent(TRawEvent::EPointerMove, secPt.iX, secPt.iY, prValue, ptrSecNum); + AddExpectedPointerEvent(TPointerEvent::EMove, secPt, prValue, 0, ptrSecNum, (TUint)iSecMultiPtrEventClient->ParentWin(), ETrue); + secPt.iX += xInc; + secPt.iY += yInc; + } + break; + case 2: + // Simulate move events from primary and secondary client simultaneously with proximity + ptrPos.SetXY(0,0); + proxValue = -iProximityStep; + + for (ptrNum = 0; (ptrNum < iMaxDevPointers/2 && ptrSecNum >= iMaxDevPointers/2); ptrNum++, ptrSecNum--) + { + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, proxValue, 0, ptrNum); + ptrPos.iX += xInc; + ptrPos.iY += yInc; + + SimulatePointerEvent(TRawEvent::EPointerMove, secPt.iX, secPt.iY, proxValue, ptrSecNum); + AddExpectedPointerEvent(TPointerEvent::EMove, secPt, proxValue, 0, ptrSecNum, (TUint)iSecMultiPtrEventClient->ParentWin(), ETrue); + secPt.iX += xInc; + secPt.iY += yInc; + } + break; + case 3: + { + // Simulate drag events on different clients window one after the other + iMultiPtrEventClient->ParentWin()->BaseWin()->PointerFilter(EPointerFilterDrag, 0); + iSecMultiPtrEventClient->ParentWin()->BaseWin()->PointerFilter(EPointerFilterDrag, 0); + + ptrPos.SetXY(0,0); + secPt.iX = iPhysicalScreenSize.iWidth/2; + secPt.iY = 0; + ptrSecNum = iMaxDevPointers-1; + TPoint interPt; + for (ptrNum = 0; (ptrNum < iMaxDevPointers/2 && ptrSecNum >= iMaxDevPointers/2); ptrNum++, ptrSecNum--) + { + SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, ptrNum); + interPt.iX = ptrPos.iX+2; + interPt.iY = ptrPos.iY+1; + SimulatePointerEvent(TRawEvent::EPointerMove, interPt.iX, interPt.iY, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EDrag, interPt, 0, 0, ptrNum); + SimulatePointerEvent(TRawEvent::EButton1Up, interPt.iX, interPt.iY, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EButton1Up, interPt, 0, 0, ptrNum); + ptrPos.iX += xInc; + ptrPos.iY += yInc; + + SimulatePointerEvent(TRawEvent::EButton1Down, secPt.iX, secPt.iY, 0, ptrSecNum); + AddExpectedPointerEvent(TPointerEvent::EButton1Down, secPt, 0, 0, ptrSecNum, (TUint)iSecMultiPtrEventClient->ParentWin(), ETrue); + interPt.iX = secPt.iX+2; + interPt.iY = secPt.iY+1; + SimulatePointerEvent(TRawEvent::EPointerMove, interPt.iX, interPt.iY, 0, ptrSecNum); + AddExpectedPointerEvent(TPointerEvent::EDrag, interPt, 0, 0, ptrSecNum, (TUint)iSecMultiPtrEventClient->ParentWin(), ETrue); + SimulatePointerEvent(TRawEvent::EButton1Up, interPt.iX, interPt.iY, 0, ptrSecNum); + AddExpectedPointerEvent(TPointerEvent::EButton1Up, interPt, 0, 0, ptrSecNum, (TUint)iSecMultiPtrEventClient->ParentWin(), ETrue); + secPt.iX += xInc; + secPt.iY += yInc; + } + } + break; + case 4: + { + // Simulate drag events on different clients, but interleaved each other + ptrPos.SetXY(0,0); + secPt.iX = iPhysicalScreenSize.iWidth/2; + secPt.iY = 0; + ptrSecNum = iMaxDevPointers-1; + TPoint interPt; + + for (ptrNum = 0; (ptrNum < iMaxDevPointers/2 && ptrSecNum >= iMaxDevPointers/2); ptrNum++, ptrSecNum--) + { + SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, ptrNum); + ptrPos.iX += xInc; + ptrPos.iY += yInc; + + SimulatePointerEvent(TRawEvent::EButton1Down, secPt.iX, secPt.iY, 0, ptrSecNum); + AddExpectedPointerEvent(TPointerEvent::EButton1Down, secPt, 0, 0, ptrSecNum, (TUint)iSecMultiPtrEventClient->ParentWin(), ETrue); + secPt.iX += xInc; + secPt.iY += yInc; + } + + ptrPos.SetXY(0,0); + secPt.iX = iPhysicalScreenSize.iWidth/2; + secPt.iY = 0; + ptrSecNum = iMaxDevPointers-1; + for (ptrNum = 0; (ptrNum < iMaxDevPointers/2 && ptrSecNum >= iMaxDevPointers/2); ptrNum++, ptrSecNum--) + { + interPt.iX = ptrPos.iX+2; + interPt.iY = ptrPos.iY+1; + SimulatePointerEvent(TRawEvent::EPointerMove, interPt.iX, interPt.iY, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EDrag, interPt, 0, 0, ptrNum); + ptrPos.iX += xInc; + ptrPos.iY += yInc; + + + interPt.iX = secPt.iX+2; + interPt.iY = secPt.iY+1; + SimulatePointerEvent(TRawEvent::EPointerMove, interPt.iX, interPt.iY, 0, ptrSecNum); + AddExpectedPointerEvent(TPointerEvent::EDrag, interPt, 0, 0, ptrSecNum, (TUint)iSecMultiPtrEventClient->ParentWin(), ETrue); + secPt.iX += xInc; + secPt.iY += yInc; + } + + ptrPos.SetXY(0,0); + secPt.iX = iPhysicalScreenSize.iWidth/2; + secPt.iY = 0; + ptrSecNum = iMaxDevPointers-1; + for (ptrNum = 0; (ptrNum < iMaxDevPointers/2 && ptrSecNum >= iMaxDevPointers/2); ptrNum++, ptrSecNum--) + { + interPt.iX = ptrPos.iX+2; + interPt.iY = ptrPos.iY+1; + SimulatePointerEvent(TRawEvent::EButton1Up, interPt.iX, interPt.iY, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EButton1Up, interPt, 0, 0, ptrNum); + ptrPos.iX += xInc; + ptrPos.iY += yInc; + + interPt.iX = secPt.iX+2; + interPt.iY = secPt.iY+1; + SimulatePointerEvent(TRawEvent::EButton1Up, interPt.iX, interPt.iY, 0, ptrSecNum); + AddExpectedPointerEvent(TPointerEvent::EButton1Up, interPt, 0, 0, ptrSecNum, (TUint)iSecMultiPtrEventClient->ParentWin(), ETrue); + secPt.iX += xInc; + secPt.iY += yInc; + } + } + break; + default: + ResetFlushStopAS(); + iSecMultiPtrEventClient->iWs.SetAutoFlush(iSecClientFlush); + break; + } + + _LIT(KEventsAdded, "Events added to Primary client's buffer = %d"); + logText.Format(KEventsAdded, iMultiPtrEventClient->EventBuffer()->EventsRemaining()); + LOG_MESSAGE(logText); + _LIT(KEventsAdded1, "Events added to Secondary client's buffer = %d"); + logText.Format(KEventsAdded1, iSecMultiPtrEventClient->EventBuffer()->EventsRemaining()); + LOG_MESSAGE(logText); + } + + +// RMultiPointerAnim +RMultiPointerAnim* RMultiPointerAnim::NewL(RWindowBase* aWin, RAnimDll* aDll) + { + RMultiPointerAnim* self=new(ELeave) RMultiPointerAnim(aDll); + CleanupStack::PushL(TCleanupItem(DestroyAnim,self)); + User::LeaveIfError(self->Construct(*aWin, EAnimTypeMultiPointer, TPtrC8())); + CleanupStack::Pop(self); + return self; + } + +TInt RMultiPointerAnim::AddExpectedAnimPointerEvent(TRawEvent::TType aType, TPoint aPos, TInt aZ, TUint /*aModifier*/, TUint8 aPointerNumber, TBool aEat /*= ETrue*/) + { + TRawEvent rawEvent; + rawEvent.Set(aType, aPos.iX, aPos.iY, aZ, aPointerNumber); + TAnimRawEvent animEvent; + animEvent.iRawEvent = rawEvent; + animEvent.iEat = aEat; + TPckgBuf param; + param()=animEvent; + return CommandReply(EADllAddExpectedMultiPtrEvent, param); + } + +void CTMultiPtrEventTest::TestAndDisplayAnimError() + { + TInt err = iAnim->CommandReply(EADllMultiPtrEventError); + if (err != KErrNone) + { + _LIT(KError, "Failed in Anim dll"); + LOG_MESSAGE(KError); + TBuf<255> errDesc; + errDesc.SetMax(); + TIpcArgs ipcArgs; + ipcArgs.Set(KIpcSlot,&errDesc); + // get the error desccription, print it out and stop the tests + TInt retVal = iAnim->CommandReply(EADllMultiPtrEventErrorDesc, KNullDesC8, ipcArgs); + if (retVal == KErrNone) + { + LOG_MESSAGE(errDesc); + } + Failed(); + } + iAnim->CommandReply(EADllMultiPtrEventReset); + } + +/** +@SYMTestCaseID GRAPHICS-WSERV-ADVANCEDPOINTER-0013 +@SYMPREQ PREQ1226 +@SYMREQ REQ9677,REQ9683, +@SYMTestPriority High +@SYMTestCaseDesc To check Wserv sends Multi Pointer events to Anims +@SYMTestStatus Implemented + +@SYMTestActions Simulate multi pointer events for anims +@SYMTestExpectedResults The received events must match the simulated raw events +*/ +void CTMultiPtrEventTest::MultiPointerEventsForAnimsL() + { + // The logic behind these tests is + // Create an anim, which creates animation at server side(which swicthes raw event handling on) + // Add the required events to the animtaion at server side buffer + // Simulate those events and check simulated events are same as required at server side + // If any test fail, error description is got from server and displayed in the log file + TLogMessageText logText; + _LIT(KSet, "Multi pointer events for Anims: %d of 3"); + logText.AppendFormat(KSet, iEventSet); + LOG_MESSAGE(logText); + _LIT(KEventsChecked, "Events checked at server side = %d"); + + iMultiPtrEventClient->EventBuffer()->SetEventCount(0); + if (!iEventSet) + { + SetAutoFlush(); + iAnimDll = new(ELeave) RAnimDll(iMultiPtrEventClient->iWs); + User::LeaveIfError(iAnimDll->Load(KAnimDLLName)); + } + + TPoint ptrPos; + TInt ptrNum = 0; + TInt prValue = 0; + TInt proxValue = 0; + TInt xInc = iPhysicalScreenSize.iWidth/iMaxDevPointers; + TInt yInc = iPhysicalScreenSize.iHeight/iMaxDevPointers; + + switch(iEventSet++) + { + case 0: + // Simulate downup events for all pointers + iAnim = RMultiPointerAnim::NewL(iMultiPtrEventClient->ParentWin()->BaseWin(), iAnimDll); + AddExpectedWsEvent(EEventFocusGained); + for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) + { + iAnim->AddExpectedAnimPointerEvent(TRawEvent::EButton1Down,ptrPos,0,0,ptrNum); + iAnim->AddExpectedAnimPointerEvent(TRawEvent::EButton1Up,ptrPos,0,0,ptrNum); + SimulatePointerDownUp(ptrPos.iX, ptrPos.iY, 0, ptrNum); + ptrPos.iX += xInc; + ptrPos.iY += yInc; + } + TestAndDisplayAnimError(); + logText.Format(KEventsChecked, iMaxDevPointers*2); + LOG_MESSAGE(logText); + break; + case 1: + // Simulate moves from different pointer with different pressure + // Here there is no need for events to be exaclty on the anim window. + // becasue when the animtaions ask for events it will be delivered all the events + // irrespective of where they occured. + ptrPos.SetXY(0,0); + prValue = iPressureStep; + for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) + { + iAnim->AddExpectedAnimPointerEvent(TRawEvent::EPointerMove, ptrPos, prValue, 0, ptrNum); + iAnim->AddExpectedAnimPointerEvent(TRawEvent::EButton1Down,ptrPos,0,0,ptrNum); + iAnim->AddExpectedAnimPointerEvent(TRawEvent::EButton1Up,ptrPos,0,0,ptrNum); + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, prValue, ptrNum); + SimulatePointerDownUp(ptrPos.iX, ptrPos.iY, 0, ptrNum); + ptrPos.iX += xInc; + ptrPos.iY += yInc; + } + TestAndDisplayAnimError(); + + // This is for just to add run the next test + SimulatePointerEvent(TRawEvent::EPointerSwitchOn, 0, 0, 0, 0); + + logText.Format(KEventsChecked, iMaxDevPointers*3); + LOG_MESSAGE(logText); + break; + case 2: + // Simulate moves from different pointer with different proximity + ptrPos.SetXY(0,0); + proxValue = -iProximityStep; + for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) + { + iAnim->AddExpectedAnimPointerEvent(TRawEvent::EPointerMove, ptrPos, proxValue, 0, ptrNum); + iAnim->AddExpectedAnimPointerEvent(TRawEvent::EButton1Down,ptrPos,0,0,ptrNum); + iAnim->AddExpectedAnimPointerEvent(TRawEvent::EButton1Up,ptrPos,0,0,ptrNum); + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); + SimulatePointerDownUp(ptrPos.iX, ptrPos.iY, 0, ptrNum); + ptrPos.iX += xInc; + ptrPos.iY += yInc; + } + TestAndDisplayAnimError(); + + // This is for just to add run the next test + SimulatePointerEvent(TRawEvent::EPointerSwitchOn, 0, 0, 0, 0); + + logText.Format(KEventsChecked, iMaxDevPointers*3); + LOG_MESSAGE(logText); + break; + default: + DestroyAnimDllAndAnim(); + ResetFlushStopAS(); + break; + } + + LogEventsAdded(); + } + + +/** +@SYMTestCaseID GRAPHICS-WSERV-ADVANCEDPOINTER-0014 +@SYMPREQ PREQ1226 +@SYMREQ REQ9677,REQ9683, +@SYMTestPriority High +@SYMTestCaseDesc To check Wserv purges multi pointer events with standard rules +@SYMTestStatus Implemented + +@SYMTestActions Simulate raw events to be purged +@SYMTestExpectedResults The purged events should not be delivered to client +*/ +void CTMultiPtrEventTest::PurgingMultiPointerEvents() + { + // Test purging of multi pointer events + // 1. Test down/up pairs are purged + // 2. Test moves events are purged + // 3. Test drag events are purged + // 4. Test lone down events are purged + // 5. And finally test lone up events are also purged + TLogMessageText logText; + _LIT(KSet, "Purging of multi pointer events: %d of 6"); + logText.AppendFormat(KSet, iEventSet); + LOG_MESSAGE(logText); + + iMultiPtrEventClient->EventBuffer()->SetEventCount(0); + TInt xInc = iPhysicalScreenSize.iWidth/KMaxQueueSize; + TInt yInc = iPhysicalScreenSize.iHeight/KMaxQueueSize; + TPoint ptrPos(xInc,yInc); + TInt ptrNum = 0; + TInt prValue = 0; + TInt proxValue = 0; + + if (!iEventSet) + { + SetAutoFlush(); + } + + // Point to note is that Kernel has an event queue size of 40 + // So make sure that you don't send more than 40 events + switch(iEventSet++) + { + case 0: + // Simulate pointer down/up events for all pointers + // Simulate many up events from any pointer which will purge down/up events + AddExpectedWsEvent(EEventFocusGained); + for (ptrNum = 0; (ptrNum < iMaxDevPointers && ptrNum < 4); ptrNum++) + { + SimulatePointerDownUp(ptrPos.iX, ptrPos.iY, 0, ptrNum); + } + SimulateAndAddLoneUpEvents(KMaxQueueSize, KMaxQueueSize-1, ptrPos); + break; + case 1: + // Repeat the same for Move events + // Simulate moves for all pointers with different pressure and proximity value + iMultiPtrEventClient->ParentWin()->BaseWin()->PointerFilter(EPointerFilterMove, 0); + iMultiPtrEventClient->ChildWin()->BaseWin()->PointerFilter(EPointerFilterMove, 0); + prValue = iPressureStep; + for (ptrNum = 0; (ptrNum < iMaxDevPointers && prValue < iMaxPressure && ptrNum < 4); ptrNum++,prValue+=iPressureStep) + { + ptrPos.iX += xInc/2; + ptrPos.iY += yInc/2; + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, prValue, ptrNum); + } + ptrPos.iX = xInc; + ptrPos.iY = yInc; + proxValue = -iProximityStep; + for (ptrNum = 0; (ptrNum < iMaxDevPointers && proxValue > iMaxProximity && ptrNum < 4); ptrNum++,proxValue-=iProximityStep) + { + ptrPos.iX += xInc/2; + ptrPos.iY += yInc/2; + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); + } + SimulateAndAddLoneUpEvents(KMaxQueueSize, KMaxQueueSize, ptrPos); + break; + case 2: + { + // Repeat the same for drag events + iMultiPtrEventClient->ParentWin()->BaseWin()->PointerFilter(EPointerFilterDrag, 0); + iMultiPtrEventClient->ChildWin()->BaseWin()->PointerFilter(EPointerFilterDrag, 0); + ptrPos.iX = xInc; + ptrPos.iY = yInc; + for (ptrNum = 0; (ptrNum < iMaxDevPointers && ptrNum < 2); ptrNum++) + { + SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum); + ptrPos.iX += xInc/2; + ptrPos.iY += yInc/2; + } + ptrPos.iX = xInc; + ptrPos.iY = yInc; + TPoint interPt = ptrPos; + for (ptrNum = 0; (ptrNum < iMaxDevPointers && ptrNum < 2); ptrNum++) + { + interPt.iX += 2; + interPt.iY += 1; + SimulatePointerEvent(TRawEvent::EPointerMove, interPt.iX, interPt.iY, 0, ptrNum); + ptrPos.iX += xInc/2; + ptrPos.iY += yInc/2; + interPt = ptrPos; + } + ptrPos.iX = xInc; + ptrPos.iY = yInc; + interPt = ptrPos; + for (ptrNum = 0; (ptrNum < iMaxDevPointers && ptrNum < 2); ptrNum++) + { + interPt.iX += 2; + interPt.iY += 1; + SimulatePointerEvent(TRawEvent::EButton1Up, interPt.iX, interPt.iY, 0, ptrNum); + ptrPos.iX += xInc/2; + ptrPos.iY += yInc/2; + interPt = ptrPos; + } + SimulateAndAddLoneUpEvents(KMaxQueueSize, KMaxQueueSize, ptrPos); + } + break; + case 3: + // Repeat the same for lone down events + ptrPos.iX = xInc; + ptrPos.iY = yInc; + for (ptrNum = 0; (ptrNum < iMaxDevPointers && ptrNum < 3); ptrNum++) + { + SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum); + ptrPos.iX += xInc/2; + ptrPos.iY += yInc/2; + } + SimulateAndAddLoneUpEvents(KMaxQueueSize+1, KMaxQueueSize, ptrPos); + + // Before this we had to send dummy 7 EButton1Up events from 1 to 7 pointers so that iLastUnmatchedDown1 + // variable to be reset and that consecutive events was not sent to client. But now EPointer3DOutOfRange + // resets all the variables. + for (ptrNum = 1; (ptrNum < iMaxDevPointers && ptrNum < 3); ptrNum++) + { + SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, ptrPos.iX, ptrPos.iY, 0, ptrNum); + } + break; + case 4: + // Finally for even lone up events, check that when you send events more then the queuesize + // the events are not sent back and they are ignored in wserv + ptrPos.iX = xInc; + ptrPos.iY = yInc; + for (ptrNum = 0; (ptrNum < iMaxDevPointers && ptrNum < 4); ptrNum++) + { + SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, ptrNum); + ptrPos.iX += xInc/2; + ptrPos.iY += yInc/2; + } + ptrPos.iX = xInc; + ptrPos.iY = yInc; + for (TInt count = 0; count < KMaxQueueSize; count++) + { + SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 0); + // For all up events more then KMaxQueueSize, wserv igoners then as the queue if full + if (count < (KMaxQueueSize - iMaxDevPointers)) + { + AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, 0); + } + } + break; + case 5: + // Check PurgePointerEvents works with multi pointer events + ptrPos.iX = xInc; + ptrPos.iY = yInc; + for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) + { + SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, ptrNum); + ptrPos.iX += xInc/2; + ptrPos.iY += yInc/2; + } + ptrPos.iX = xInc; + ptrPos.iY = yInc; + iMultiPtrEventClient->iWs.PurgePointerEvents(); + SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 0); + AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, 0); + break; + default: + ResetFlushStopAS(); + break; + } + LogEventsAdded(); + } + +void CTMultiPtrEventTest::MultiPointerEvents() + { + TLogMessageText logText; + _LIT(KSet, "MultiPtrEvents SetOfEvents: %d of 9"); + logText.AppendFormat(KSet, iEventSet); + LOG_MESSAGE(logText); + + if (!iEventSet) + { + SetAutoFlush(); + } + iMultiPtrEventClient->EventBuffer()->SetEventCount(0); + + TPoint ptrPos; + TInt ptrNum = 0; + TInt prValue = 0; + TInt proxValue = 0; + TInt xInc = iPhysicalScreenSize.iWidth/iMaxDevPointers; + TInt yInc = iPhysicalScreenSize.iHeight/iMaxDevPointers; + + switch(iEventSet++) + { + case 0: + /** + @SYMTestCaseID GRAPHICS-WSERV-ADVANCEDPOINTER-0001 + @SYMPREQ PREQ1226 + @SYMREQ REQ9674,REQ9687, + @SYMTestPriority High + @SYMTestCaseDesc Checks Wserv sends multi touch pointer events received by it + @SYMTestStatus Implemented + + @SYMTestActions Simulate raw events from different pointers + @SYMTestExpectedResults The received events must match the simulated raw events + */ + INFO_PRINTF1(_L("Simulate pointer events from all pointers")); + INFO_PRINTF1(_L("Test pattern is PointerDown0/PointerUp0, PointerDown1/PointerUp1, PointerDown2/PointerUp2...")); + // Test pattern is down0/up0, down1/up1, down2/up2, down3/up3.... + AddExpectedWsEvent(EEventFocusGained); + for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) + { + SimulatePointerDownUp(ptrPos.iX, ptrPos.iY, 0, ptrNum); + AddExpectedPointerDownUp(ptrPos, 0, ptrNum); + ptrPos.iX += xInc; + ptrPos.iY += yInc; + } + break; + case 1: + /** + @SYMTestCaseID GRAPHICS-WSERV-ADVANCEDPOINTER-0003 + @SYMPREQ PREQ1226 + @SYMREQ REQ9674,REQ9687, + @SYMTestPriority High + @SYMTestCaseDesc To check Wserv sends simultaneous multi touch pointer events + @SYMTestStatus Implemented + + @SYMTestActions Simulate simultaneous raw events from different pointers + @SYMTestExpectedResults The received events must match the simulated raw events + */ + INFO_PRINTF1(_L("Test pattern PointerDown0/PointerDown1/PointerDown2/... PointerUp0/PointerUp1/PointerUp2...")); + // Test pattern is pointer0Down/pointer1Down/pointer2Down/pointer3Down.... pointer0Up/pointer1Up/pointer2Up/pointer3Up.... + ptrPos.SetXY(0,0); + for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) + { + SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, ptrNum); + ptrPos.iX += xInc; + ptrPos.iY += yInc; + } + + ptrPos.SetXY(0,0); + for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) + { + SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, ptrNum); + ptrPos.iX += xInc; + ptrPos.iY += yInc; + } + break; + case 2: + /** + @SYMTestCaseID GRAPHICS-WSERV-ADVANCEDPOINTER-0005 + @SYMPREQ PREQ1226 + @SYMREQ REQ9676 + @SYMTestPriority High + @SYMTestCaseDesc To check Wserv sends the multi touch pointer events received + by it along with the Pressure or Proximity + @SYMTestStatus Implemented + + @SYMTestActions Simulate raw events with pressure and proximity from different pointers + @SYMTestExpectedResults The received events must match the simulated raw events + */ + // Simulate Button1Down with differet pressure + // Simulate Button1Up with zero pressure + INFO_PRINTF1(_L("Simulate pointer events with different pressure values")); + ptrPos.SetXY(0,0); + prValue = iPressureStep; + for (; (prValue <= iMaxPressure && ptrPos.iX < iPhysicalScreenSize.iWidth && ptrPos.iY < iPhysicalScreenSize.iHeight); prValue+=iPressureStep) + { + SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, prValue, 0); + SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 0); + AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, prValue, 0, 0); + AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, 0); + ptrPos.iX += xInc; + ptrPos.iY += yInc; + } + + // Test with max pressure it might be that the width may cross the physical screen size + ptrPos.SetXY(0,0); + prValue = iMaxPressure; + SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, prValue, 0); + SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 0); + AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, prValue, 0, 0); + AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, 0); + break; + case 3: + // Simulate EPointerMove with different pressure values and for differernt pointers + INFO_PRINTF1(_L("Simulate pointer events with different pressure values and from different pointers")); + ptrPos.SetXY(0,0); + prValue = iPressureStep; + + // Enable move events + iMultiPtrEventClient->ParentWin()->BaseWin()->PointerFilter(EPointerFilterMove, 0); + iMultiPtrEventClient->ChildWin()->BaseWin()->PointerFilter(EPointerFilterMove, 0); + + // Right now when 2 or more moves occur, wserv deletes all the moves except the last one. + // So test only one move per Pointer and then one set of button down and button up + // Then repeat the same for different pressure values + for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) + { + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, prValue, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, prValue, 0, ptrNum); + ptrPos.iX += xInc; + ptrPos.iY += yInc; + } + + ptrPos.SetXY(0,0); + for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) + { + SimulatePointerDownUp(ptrPos.iX, ptrPos.iY, 0, ptrNum); + AddExpectedPointerDownUp(ptrPos, 0, ptrNum); + ptrPos.iX += xInc; + ptrPos.iY += yInc; + } + + // Test moves with different pressure + ptrPos.SetXY(0,0); + if ((prValue+iPressureStep) <= iMaxPressure) + { + prValue += iPressureStep; + } + ptrNum = 0; + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, prValue, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, prValue, 0, ptrNum); + break; + case 4: + INFO_PRINTF1(_L("Simulate pointer events with different proximity values")); + // Repeat the same test of case 3 for different proximity values + ptrPos.SetXY(0,0); + + proxValue = -iProximityStep; + for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) + { + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, proxValue, 0, ptrNum); + ptrPos.iX += xInc; + ptrPos.iY += yInc; + } + + ptrPos.SetXY(0,0); + for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) + { + SimulatePointerDownUp(ptrPos.iX, ptrPos.iY, 0, ptrNum); + AddExpectedPointerDownUp(ptrPos, 0, ptrNum); + ptrPos.iX += xInc; + ptrPos.iY += yInc; + } + + ptrPos.SetXY(0,0); + if ((proxValue-iProximityStep) > iMaxProximity) + { + proxValue -= iProximityStep; + } + ptrNum = 0; + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, proxValue, 0, ptrNum); + break; + case 5: + /** + @SYMTestCaseID GRAPHICS-WSERV-ADVANCEDPOINTER-0007 + @SYMPREQ PREQ1226 + @SYMREQ REQ9677 + @SYMTestPriority High + @SYMTestCaseDesc To check Wserv sends move/drags of different pointers + @SYMTestStatus Implemented + + @SYMTestActions Simulate raw move and drag events from different pointers + @SYMTestExpectedResults The received events must match the simulated raw events + */ + INFO_PRINTF1(_L("Simulate pointer drag events")); + ptrPos.SetXY(0,0); + iMultiPtrEventClient->ParentWin()->BaseWin()->PointerFilter(EPointerFilterDrag, 0); + + // Simulate EButton1Down and then one move and then EButton1Up event + // which will lead to corresponding drag, do it for all the pointers + for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) + { + TestDragForMultiPointer(ptrPos, 0, ptrNum); + ptrPos.iX += xInc/2; + ptrPos.iY += yInc/2; + } + + // Check the drag with different pressure value with different pointer + prValue = iPressureStep; + ptrPos.iX = xInc; + ptrPos.iY = yInc; + if ((prValue+iPressureStep) <= iMaxPressure) + { + prValue += iPressureStep; + } + ptrNum = 0; + TestDragForMultiPointer(ptrPos, prValue, ptrNum); + break; + case 6: + { + /** + @SYMTestCaseID GRAPHICS-WSERV-ADVANCEDPOINTER-0009 + @SYMPREQ PREQ1226 + @SYMREQ REQ9677, REQ9674 + @SYMTestPriority High + @SYMTestCaseDesc To check Wserv sends simultaneous move/drags of different pointers + @SYMTestStatus Implemented + + @SYMTestActions Simulate simulatneous raw move and drag events from different pointers + @SYMTestExpectedResults The received events must match the simulated raw events + */ + INFO_PRINTF1(_L("Simulate pointer drag events in different pattern")); + // Dragging done in this pattern + // pointer0Down/pointer1Down/pointer2Down/pointer3Down... pointer0Up/pointer1Up/pointer2Up/pointer3Up.... + + ptrPos.SetXY(0,0); + for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) + { + SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, ptrNum); + ptrPos.iX += xInc/2; + ptrPos.iY += yInc/2; + } + + ptrPos.SetXY(0,0); + TPoint interPt = ptrPos; + for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) + { + interPt.iX += 2; + interPt.iY += 1; + SimulatePointerEvent(TRawEvent::EPointerMove, interPt.iX, interPt.iY, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EDrag, interPt, 0, 0, ptrNum); + ptrPos.iX += xInc/2; + ptrPos.iY += yInc/2; + interPt = ptrPos; + } + + ptrPos.SetXY(0,0); + interPt = ptrPos; + for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++) + { + interPt.iX += 2; + interPt.iY += 1; + SimulatePointerEvent(TRawEvent::EButton1Up, interPt.iX, interPt.iY, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EButton1Up, interPt, 0, 0, ptrNum); + ptrPos.iX += xInc/2; + ptrPos.iY += yInc/2; + interPt = ptrPos; + } + break; + } + case 7: + { + // Mixing of drag and moves of different pointers + ptrPos.SetXY(0,0); + for (ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) + { + SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, ptrNum); + ptrPos.iX += xInc/2; + ptrPos.iY += yInc/2; + } + ptrPos.SetXY(0,0); + TPoint interPt = ptrPos; + for (ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) + { + interPt.iX += 2; + interPt.iY += 1; + SimulatePointerEvent(TRawEvent::EPointerMove, interPt.iX, interPt.iY, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EDrag, interPt, 0, 0, ptrNum); + ptrPos.iX += xInc/2; + ptrPos.iY += yInc/2; + interPt = ptrPos; + } + + ptrPos.SetXY(0,0); + interPt = ptrPos; + for (ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) + { + interPt.iX += 2; + interPt.iY += 1; + SimulatePointerEvent(TRawEvent::EButton1Up, interPt.iX, interPt.iY, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EButton1Up, interPt, 0, 0, ptrNum); + ptrPos.iX += xInc/2; + ptrPos.iY += yInc/2; + interPt = ptrPos; + } + + ptrPos.SetXY(0,0); + prValue = iPressureStep; + for (ptrNum = 0; ptrNum < iMaxDevPointers/2 && prValue < iMaxPressure; ptrNum++, prValue+=iPressureStep) + { + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, prValue, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, prValue, 0, ptrNum); + ptrPos.iX += xInc; + ptrPos.iY += yInc; + } + } + break; + case 8: + { + INFO_PRINTF1(_L("Check intermediate Moves and Drags are deleted except last event")); + // Check if intermediate move and drag events are deleted + // The deletion is done with respect to same pointer and same window + xInc = iPhysicalScreenSize.iWidth/KMaxQueueSize; + yInc = iPhysicalScreenSize.iHeight/KMaxQueueSize; + ptrPos.iX = xInc; + ptrPos.iY = yInc; + TInt count = 0; + + for (ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) + { + // Make sure that ptrPos does not go out of screen area, i,e the loop count should not exceed 4 + for (count = proxValue = 0; proxValue > iMaxProximity && count < 4; proxValue=proxValue-(4*iProximityStep), count++) + { + ptrPos.iX += xInc/2; + ptrPos.iY += yInc/2; + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum); + } + // Since the for loop increments the variables at the end + proxValue = proxValue + (4*iProximityStep); + AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, proxValue, 0, ptrNum); + } + + ptrPos.iX = xInc; + ptrPos.iY = yInc; + for (ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) + { + ptrPos.iX += xInc/2; + ptrPos.iY += yInc/2; + SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, ptrNum); + } + + ptrPos.iX = xInc; + ptrPos.iY = yInc; + for (ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) + { + // Make sure that ptrPos does not go out of screen area, i,e the loop count shuld not exceed 4 + for (count = prValue = 0; prValue < iMaxPressure && count < 4; prValue=prValue+(4*iPressureStep), count++) + { + ptrPos.iX += xInc/2; + ptrPos.iY += yInc/2; + SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, prValue, ptrNum); + } + prValue = prValue-(4*iPressureStep); + AddExpectedPointerEvent(TPointerEvent::EDrag, ptrPos, prValue, 0, ptrNum); + } + + ptrPos.iX = xInc; + ptrPos.iY = yInc; + for (ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++) + { + ptrPos.iX += xInc/2; + ptrPos.iY += yInc/2; + SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, ptrNum); + AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, ptrNum); + } + } + break; + default: + ResetFlushStopAS(); + break; + } + + LogEventsAdded(); + } + +// Logs number of events added to test buffer for comaparison +void CTMultiPtrEventTest::LogEventsAdded() + { + TLogMessageText logText1; + _LIT(KEventsAdded, "Events added to buffer = %d"); + logText1.AppendFormat(KEventsAdded, iMultiPtrEventClient->EventBuffer()->EventsRemaining()); + LOG_MESSAGE(logText1); + } + +// If any of the Tests fails, bring the wserv in a consistent state for other test to run, +// stop ActiveScheduler and display some logs where the fail occured. +void CTMultiPtrEventTest::Failed() + { + switch (iTest->iState) + { + case 2: // Anim tests + DestroyAnimDllAndAnim(); + break; + case 3: // MultiClient tests + if (iMultiPtrEventClient->EventBuffer()->NestedLoopState()) + { + iSecMultiPtrEventClient->EventBuffer()->SetNestedLoopState(EFalse); + CActiveScheduler::Stop(); + } + break; + case 4: //PtrClick tests + if (iPtrPluginLoaded) + { + iPtrPluginLoaded = EFalse; + iClick.Unload(); + iClick.Close(); + } + if (iHeap) + { + iHeap->Close(); + iHeap = NULL; + iChunk.Close(); + } + break; + case 5: //Screen mode tests + SetDefaultScreenMode(); + break; + case 11: + iMultiPtrEventClient->DeleteGroupBlankWin(); + break; + case 12: //Emulation tests, iEventSet is incremented in main switch case. + switch (iEventSet) + { + case 9: + DeleteGroupWin(); + break; + case 10: + DestroyAnimDllAndAnim(); + break; + case 11: + case 12: + iMultiPtrEventClient->ParentWin()->BaseWin()->FreePointerMoveBuffer(); + iMultiPtrEventClient->ParentWin()->BaseWin()->DisablePointerMoveBuffer(); + break; + case 14: + case 15: + iMultiPtrEventClient->iWs.SetPointerCursorArea(iOrigPtrCursorArea); + break; + default: + break; + } + break; + case 15: + if (iEventSet > 1) + { + DeleteGroupWinForCapturing(); + } + break; + case 13: + case 16: + SetThresholdValues(KMaxTInt, KMinTInt, KMaxTInt, KMinTInt); + break; + default: + break; + } + + if (iActiveSchedulerStarted) + { + iActiveSchedulerStarted = EFalse; + CActiveScheduler::Stop(); + } + + // Display the test case number, subtest case number and number of events left in the buffer which can be used to + // find out which event actually caused the failure when any test fails + TLogMessageText logText1; + _LIT(KEventsAdded, "Test case number %d Sub test case number %d Events remaining in the buffer %d \n"); + logText1.AppendFormat(KEventsAdded, iTest->iState, iEventSet, iMultiPtrEventClient->EventBuffer()->EventsRemaining()); + LOG_MESSAGE(logText1); + RDebug::Printf("Test case number %d Sub test case number %d Events remaining in the buffer %d \n", iTest->iState, iEventSet, iMultiPtrEventClient->EventBuffer()->EventsRemaining()); + + iFailed=ETrue; + } + +// This function is called by TestExecute Framework, through which all the testcases are run +void CTMultiPtrEventTest::RunTestCaseL(TInt /*aCurTestCase*/) + { + _LIT(KTest0, "MultiPointerEvents with Pressure and Proximity"); + _LIT(KTest1, "Purging Of MultiPointerEvents"); + _LIT(KTest2, "MultiPointerEvents for Anims"); + _LIT(KTest3, "MultiPointerEvents from multi client"); + _LIT(KTest4, "MultiPointerEvents for pointer click plugin"); + _LIT(KTest5, "MultiPointerEvents In Different ScreenModes"); + _LIT(KTest6, "Filtering Of MultiPointerEvents"); + _LIT(KTest7, "Grabbing Of MultiPointerEvents"); + _LIT(KTest8, "VirtualKeyboard for Multiple Pointers"); + _LIT(KTest9, "DoubleClick events for Multiple Pointer"); + _LIT(KTest10, "OutOfRange & EnterExit for Multiple Pointer"); + _LIT(KTest11, "Auto foreground for Multiple Pointer"); + _LIT(KTest12, "Emulation rules for Mulitple Pointers"); + _LIT(KTest13, "Close proximity and High Pressure events"); + _LIT(KTest14, "Out of bound value testing"); + _LIT(KTest15, "Capturing Of MultiPointerEvents"); + _LIT(KTest16, "Negative testing for Proximity and Pressure events"); + _LIT(KTest17, "PointerRepeatEvent for Multiple Pointers"); + + if (!TestBase()->ConfigurationSupportsPointerEventTesting()) + { + INFO_PRINTF1(_L("Test skipped because config does not support pointer event testing")); + TestComplete(); + return; + } + + switch(iTest->iState) + { + case 0: + iTest->LogSubTest(KTest0); + RunTestsL(); + break; + case 1: + iTest->LogSubTest(KTest1); + RunTestsL(); + break; + case 2: + iTest->LogSubTest(KTest2); + RunTestsL(); + break; + case 3: + iTest->LogSubTest(KTest3); + RunTestsL(); + break; + case 4: + iTest->LogSubTest(KTest4); + RunTestsL(); + break; + case 5: + iTest->LogSubTest(KTest5); + RunTestsL(); + break; + case 6: + iTest->LogSubTest(KTest6); + RunTestsL(); + break; + case 7: + iTest->LogSubTest(KTest7); + RunTestsL(); + break; + case 8: + iTest->LogSubTest(KTest8); + RunTestsL(); + break; + case 9: + iTest->LogSubTest(KTest9); + RunTestsL(); + break; + case 10: + iTest->LogSubTest(KTest10); + RunTestsL(); + break; + case 11: + iTest->LogSubTest(KTest11); + RunTestsL(); + break; + case 12: + iTest->LogSubTest(KTest12); + RunTestsL(); + break; + case 13: + iTest->LogSubTest(KTest13); + RunTestsL(); + break; + case 14: + iTest->LogSubTest(KTest14); + RunTestsL(); + break; + case 15: + iTest->LogSubTest(KTest15); + RunTestsL(); + break; + case 16: + iTest->LogSubTest(KTest16); + RunTestsL(); + break; + case 17: + iTest->LogSubTest(KTest17); + RunTestsL(); + break; + case 18: + // Keep this code in last case statement for main test completion + TestComplete(); + break; + default: + AutoPanic(EAutoPanicWrongTest); + } + + // + if (iFailed) + { + TEST(EFalse); + iFailed=EFalse; + } + ++iTest->iState; + } + +// Macro which is used for construction of CTMultiPtrEventTestStep object +// and also used to call CreateTestL() which creates CTMultiPtrEventTest and CTestBase objects +__WS_CONSTRUCT_STEP__(MultiPtrEventTest) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/tmultiptrevent.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/tmultiptrevent.h Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,283 @@ +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef TMULTIPTREVENT_H_ +#define TMULTIPTREVENT_H_ + +#include +#include +#include "w32std.h" +#include "../tlib/testbase.h" +#include "AUTO.H" +#include "AUTODLL.H" +#include "../TClick/multiptrclick.h" +#include "TGraphicsHarness.h" + +class CTMultiPtrEventTest; +class CTMultiPtrEventClient; + +/* + * CTEvent derived class which acts as eventhandler and eventbuffer + * Stores the events in buffer, which is used for comparing events received from wserv. + */ +class CTMultiPtrEventBuffer : public CTEvent + { + enum {EEventBufferSize=40, EMovePtsBuffer=10}; +public: + CTMultiPtrEventBuffer(RWsSession *aWs, CTMultiPtrEventTest *aTest, CTMultiPtrEventClient* aClient); + void ConstructL(); + void AddExpectedEvent(TWsEvent &aEvent); + void AddExpectedMovePtEvent(TPoint &aMovePt); + TInt EventsRemaining(); + void SetEventCount(TInt aCount) {iEventCount = aCount;} + void SetNestedLoopState(TBool aLoopStart) {iNestedLoopStarted = aLoopStart;} + TBool NestedLoopState() {return iNestedLoopStarted;} + void GetMoveBufferAndCompareL(); +protected: + // Pure virtual from CTEventBase + void doRunL(); +private: + void TestL(TInt aTest); + void TestL(TInt aTest, TInt aVal1, TInt aVal2,const char *oper, const char *aTestStr, + const TWsEvent *aEvent, const TWsEvent *aExpected, const char *aFile, TUint aLine); + void TestL(TInt aTest, TPoint aVal1, TPoint aVal2,const char *oper, const char *aTestStr, + const TWsEvent *aEvent, const TWsEvent *aExpected, const char *aFile, TUint aLine); +private: + CCirBuf iEventBuffer; + CCirBuf iMovePtsBuffer; + CTMultiPtrEventTest* iTest; + TInt iEventCount; + CTMultiPtrEventClient* iClient; + TBool iNestedLoopStarted; + }; + + +/* + * CTClient derived class which gives Wserv client environment + * i,e iWs, iScreen, iGc, iGroup, iEventHandler etc... + * Owns CTMultiPtrEventBuffer and stores in iEventhandler of its base class + * Accepts the event from test class and passes them on to buffer class + */ +class CTMultiPtrEventClient : public CTClient + { +public: + CTMultiPtrEventClient(CTMultiPtrEventTest *aTest, TBool aSecondaryClient = EFalse); + ~CTMultiPtrEventClient(); + void ConstructL(); + + inline CTBlankWindow* ParentWin() { return iParentWin; } + inline CTBlankWindow* ChildWin() { return iChildWin; } + inline CTMultiPtrEventBuffer* EventBuffer() {return static_cast(iEventHandler);} + inline void SetExpectNonAdvancedPointerEvents() {iExpectNonAdvancedPointerEvents=ETrue;}; + inline void ClearExpectNonAdvancedPointerEvents() {iExpectNonAdvancedPointerEvents=EFalse;}; + + TBool IsSecondaryClient() {return iSecondaryClient;} + + void AddExpectedPointerEvent(TPointerEvent::TType aType, TPoint aPos, TUint8 aPointerNumber, TUint aHandle = 0); + void AddExpectedPointerEvent(TPointerEvent::TType aType, TPoint aPos, TInt aZ, TUint aModifier, TUint8 aPointerNumber, TUint aHandle = 0); + void AddExpectedWsEvent(TEventCode aType, TInt aPointerNumber = 0, TUint aHandle = 0); + void AddExpectedMovePoint(TPoint aPos); + void CalculatePtrPosAndSet3Ddata(TWsEvent& aEvent, TPointerEvent::TType aType, TPoint aPos, TUint aModifiers, TInt aZ, TUint8 aPointerNumber, TUint aHandle); + void ConstructGroupBlankWinL(); + void DeleteGroupBlankWin(); + TBool CheckOrdinalPosition(TInt aWinAutoFocus1); + + // Virtual from CTClient + void ConstructEventHandlerL(); + +private: + CTMultiPtrEventTest* iTest; + TSize iParentWinSize; + TPoint iParentWinPos; + TSize iChildWinSize; + TPoint iChildWinPos; + CTBlankWindow* iParentWin; + CTBlankWindow* iChildWin; + + TBool iSecondaryClient; + + // For AutoFocus test + CTWindowGroup* iGroupWinAutoFocus1; + CTWindowGroup* iGroupWinAutoFocus2; + CTBlankWindow* iWinAutoFocus1; + CTBlankWindow* iWinAutoFocus2; + + TSize iWinSizeAutoFocus1; + TPoint iWinPosAutoFocus1; + TSize iWinSizeAutoFocus2; + TPoint iWinPosAutoFocus2; + TBool iExpectNonAdvancedPointerEvents; + }; + +class RMultiPointerAnim : public RTestAnim + { +public: + static RMultiPointerAnim* NewL(RWindowBase* aWin, RAnimDll* aDll); + RMultiPointerAnim(RAnimDll* aDll) :RTestAnim(*aDll) {} + TInt AddExpectedAnimPointerEvent(TRawEvent::TType aType, TPoint aPos, TInt aZ, TUint aModifier, TUint8 aPointerNumber, TBool aEat = ETrue); + }; + +/* + * CTWsGraphicsBase derived class which implements RunTestCaseL pure virtual. + * Runs all the testcases for multi poniter events. + * For each test case it creates CTMultiPtrEventClient object and creates a nested activescheduler + * Calls NextSetOfEventsL() which in turn calls respective tests depending upong the testcase number + * For each test simulates the events and adds the same event to CTMultiPtrEventBuffer + * When all the tests for a particular testcase completes stops activescheduler + * Repeats the same for all testcases + */ +class CTMultiPtrEventTest : public CTWsGraphicsBase + { +public: + CTMultiPtrEventTest(CTestStep* aStep); + ~CTMultiPtrEventTest(); + void ConstructL(); + void NextSetOfEventsL(); + void Failed(); + + // Functions for simulating events, which use UserSvr::AddEvent + void SimulatePointerEvent(TRawEvent::TType aType, TInt aX, TInt aY, TUint8 aPointerNumber); + void SimulatePointerEvent(TRawEvent::TType aType, TInt aX, TInt aY, TInt aZ, TUint8 aPointerNumber); + void SimulatePointerDownUp(TInt aX, TInt aY, TInt aZ, TUint8 aPointerNumber); + + // Functions for adding event, calls the client's AddExpectedPointer + void AddExpectedPointerEvent(TPointerEvent::TType aType, TPoint aPos, TUint8 aPointerNumber, TUint aHandle = 0); + void AddExpectedPointerEvent(TPointerEvent::TType aType, TPoint aPos, TInt aZ, TUint aModifier, TUint8 aPointerNumber, TUint aHandle = 0, TBool aSecondaryClient = EFalse); + void AddExpectedPointerDownUp(TPoint aPos, TInt aZ, TUint8 aPointerNumber); + void AddExpectedWsEvent(TEventCode aType, TBool aSecondaryClient = EFalse, TInt aPointerNumber = 0, TUint aHandle = 0); + void AddExpectedMultiPtrClickEvent(TPointerEvent::TType aType, TPoint aPos, TInt aZ, TUint aModifier, TUint8 aPointerNumber, TUint aHandle = 0); + void AddExpectedMultiPtrClickOtherEvent(TPointerEvent::TType aType, TPoint aPos, TInt aZ, TUint aModifier, TUint8 aPointerNumber, TUint aHandle); + + void AddExpectedKey(TInt aEventCode, TInt aScanCode, TInt aCode/*=0*/, TInt aRepeats/*=0*/, TUint aModifiers/*=0*/); + void AddExpectedKeyDownUp(TInt aScanCode, TInt aCode=0, TInt aRepeats=0, TUint aModifiers=0); + + // Supplementary function for tests + void TestDragForMultiPointer(TPoint aPtrPos, TInt aPrValue, TUint8 aPointerNumber); + void SimulateAndAddLoneUpEvents(TInt aNumSimulation, TInt aNumAddition, TPoint aPos); + void TestAndDisplayAnimError(); + void GetRemainingEventsFromSecondaryClient(); + void TestAndDisplayPtrClickError(); + void CreatePointerClickPluginL(); + void SetAutoFlush(); + void ResetFlushStopAS(); + void TestFilteringForMultiPointer(TBool aFiltering); + void TestGrabbingForMultiPointer(TBool aGrabbing); + void CreateGroupWinL(); + void DeleteGroupWin(); + void CreateGroupWinForCapturingL(); + void DeleteGroupWinForCapturing(); + void CreateAnimDllAndAnimL(); + void DestroyAnimDllAndAnim(); + void TestCloseProximityHighPressureAPIsL(); + void TestCapturingForMultiPointer(TBool aAllGroups); + void SetThresholdValues(TInt aEnterCloseProx, TInt aExitCloseProx, TInt aEnterHighPres, TInt aExitHighPres); + void NegativeTestingOfProximityPressureAPIsL(); + void TestErrorCodeL(TInt aExpErrCode, TInt aActualErrCode); + void SimulateProximityAndPressureEvents(TInt aCloseProxEnterValue, TInt aCloseProxExitValue, TInt aHighPresEnterValue, TInt aHighPresExitValue); + void SetDefaultScreenMode(); + TPoint GetPointerPostionOnRotatedMode(TPoint aPointerPos, CFbsBitGc::TGraphicsOrientation aRotation); + void LogEventsAdded(); + + // All tests + void MultiPointerEvents(); + void PurgingMultiPointerEvents(); + void MultiPointerEventsForAnimsL(); + void MultiClientMultiPointerEvents(); + void MultiPointerEventsForPointerClickL(); + void MultiPointerEventsInDiffScreenModes(); + void FilteringMultiPointerEvents(); + void GrabbingMultiPointerEvents(); + void VirtualKeyBoardForMultiplePointers(); + void DoubleClickForMultiplePointers(); + void MultiPointerOutOfRangeEvents(); + void AutoForeGroundForMultiplePointersL(); + void EmulationRulesForMultiplePointers(); + void CloseProximityAndHighPressureEventsL(); + void OutOfBoundValueTesting(); + void CapturingMultiPointerEvents(); + void NegativeTestsForProximityPressureEventsL(); + void PointerRepeatEventForMultiplePointers(); + void SetExpectNonAdvancedPointerEvents(TBool aSecondaryClient=EFalse); + void ClearExpectNonAdvancedPointerEvents(TBool aSecondaryClient=EFalse); + +protected: + void RunTestCaseL(TInt aCurTestCase); +private: + void RunTestsL(); +private: + TInt iEventSet; // Set of events for one particular test case + TBool iFailed; + TBool iActiveSchedulerStarted; + TBool iTheClientFlush; + TBool iClientFlush; + TBool iSecClientFlush; + TSize iPhysicalScreenSize; + TRect iOrigPtrCursorArea; + + TUint iPointerNumber; + TInt iMaxDevPointers; + TInt iMaxUiPointers; + TInt iMaxPressure; + TInt iPressureStep; + TInt iMaxProximity; + TInt iProximityStep; + + TInt iEnterCloseProximityThreshold; + TInt iExitCloseProximityThreshold; + TInt iEnterHighPressureThreshold; + TInt iExitHighPressureThreshold; + + CTMultiPtrEventClient *iMultiPtrEventClient; + CTMultiPtrEventClient *iSecMultiPtrEventClient; + + RAnimDll* iAnimDll; + RMultiPointerAnim* iAnim; + + RSoundPlugIn iClick; + TBool iPtrPluginLoaded; + RChunk iChunk; + RHeap* iHeap; + TAny* iErrDesc; + + TInt iCurrentScreenMode; + TBool iChangeScreenMode; + + CTWindowGroup* iGroupWinForEmul; + CTBlankWindow* iWinForEmul; + + CTWindowGroup* iGroupWinForCapturing; + CTBlankWindow* iWinForCapturing; + + TInt iYOffset; + }; + +class CTMultiPtrEventTestStep : public CTGraphicsStep + { +public: + CTMultiPtrEventTestStep(); +protected: + //from CTGraphicsStep + virtual CTGraphicsBase* CreateTestL(); + }; + +_LIT(KTMultiPtrEventTestStep, "TMultiPtrEventTest"); + +#endif /*TMULTIPTREVENT_H_*/ diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/topaquechild.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/topaquechild.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,167 @@ +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// This file is part of manual test (group\inc113743.mmp) to check Wserv behaviour when +// exposing a transparent window that is obscured by some opaque child window above it. +// Without the fix, that transparent window will be drawn as opaque window +// because its transparent regions is null (not re-created due to its update flag is not +// set as it is not traceable via transparent regions linked list of windows above it. +// Some illustration when the situation will trigger the defect (side view), +// ---- Child (opaque) +// ---------- Parent (transparent) +// ---- Other transparent window obscured by opaque child +// This defect is only reproducable when window shadowing is not used, so it cannot be +// tested from standard Wserv test framework. +// @SYMTestCaseID GRAPHICS-WSERV-0450 +// @SYMDEF INC113743 +// @SYMTestCaseDesc Perform test on Wserv behaviour in exposing transparent windows which is obscured indirectly by opaque child window +// @SYMTestPriority High +// @SYMTestStatus Implemented +// @SYMTestActions Create opaque and transparent windows in the following dimension and z-order +// ---- opaque child +// ---------- transparent parent +// ---- other transparent underneath obscured and non traceable via transparent parent iTransparentRegions +// and then make transparent parent window invisible +// @SYMTestExpectedResults The expected result are: other transparent window underneath is exposed and redrawn properly not becoming opaque +// +// + +#include +#include +#include + +#define ENullWsHandle 0xffffffff + +void MainL() + { + const TSize KTestSize(320,240); + const TSize KHalfSize(160,240); + const TInt KScreenNo = 1; + + RRegion shape; + shape.AddRect(TRect(0,0,160,120)); + shape.AddRect(TRect(160,120,320,240)); + CleanupClosePushL(shape); + + RWsSession ws; + User::LeaveIfError(ws.Connect()); + CleanupClosePushL(ws); + + CWsScreenDevice* scr = new(ELeave) CWsScreenDevice(ws); + CleanupStack::PushL(scr); + User::LeaveIfError(scr->Construct(KScreenNo)); + TDisplayMode displayMode = scr->DisplayMode(); + + CWindowGc* gc = NULL; + User::LeaveIfError(scr->CreateContext(gc)); + CleanupStack::PushL(gc); + + RWindowGroup group(ws); + User::LeaveIfError(group.Construct(0x0badface, ETrue)); + CleanupClosePushL(group); + + // create transparent window underneath that will be obscured by some opaque child window above it + RWindow transWinUnderneath(ws); + User::LeaveIfError(transWinUnderneath.Construct(group, ENullWsHandle)); + CleanupClosePushL(transWinUnderneath); + transWinUnderneath.SetShadowDisabled(ETrue); + transWinUnderneath.SetExtent(TPoint(0,0),KTestSize/*KHalfSize*/); + transWinUnderneath.SetTransparencyAlphaChannel(); + transWinUnderneath.SetRequiredDisplayMode(EColor64K); + transWinUnderneath.SetBackgroundColor(TRgb(255,0,0,128)); + transWinUnderneath.SetShape(shape); + transWinUnderneath.Activate(); + transWinUnderneath.Invalidate(); + transWinUnderneath.BeginRedraw(); + transWinUnderneath.EndRedraw(); + ws.Flush(); + + User::After(1*1000*1000); + + // save the reference image (semi-transparent red window) + CFbsBitmap* refImage = new(ELeave) CFbsBitmap; + CleanupStack::PushL(refImage); + User::LeaveIfError(refImage->Create(KTestSize, displayMode)); + scr->CopyScreenToBitmap(refImage); + + // create transparent window parent which will have opaque child + RWindow transWinParent(ws); + User::LeaveIfError(transWinParent.Construct(group, ENullWsHandle)); + CleanupClosePushL(transWinParent); + transWinParent.SetShadowDisabled(ETrue); + transWinParent.SetExtent(TPoint(0,0),KTestSize); + transWinParent.SetTransparencyAlphaChannel(); + transWinParent.SetRequiredDisplayMode(EColor64K); + transWinParent.SetBackgroundColor(TRgb(255,255,255,0)); + transWinParent.Activate(); + + transWinParent.Invalidate(); + transWinParent.BeginRedraw(); + transWinParent.EndRedraw(); + ws.Flush(); + + // create opaque child window that obscure transparent window underneath (not its parent) + RWindow opaqueWinChild(ws); + User::LeaveIfError(opaqueWinChild.Construct(transWinParent, ENullWsHandle)); + CleanupClosePushL(opaqueWinChild); + opaqueWinChild.SetExtent(TPoint(0,0),KTestSize/*KHalfSize*/); + opaqueWinChild.SetRequiredDisplayMode(EColor64K); + opaqueWinChild.SetShape(shape); + opaqueWinChild.Activate(); + + opaqueWinChild.Invalidate(); + opaqueWinChild.BeginRedraw(); + gc->Activate(opaqueWinChild); + gc->SetBrushStyle(CGraphicsContext::ESolidBrush); + gc->SetPenStyle(CGraphicsContext::ENullPen); + gc->SetBrushColor(KRgbGreen); + gc->Clear(); + gc->SetBrushColor(KRgbBlue); + gc->DrawEllipse(KTestSize/*KHalfSize*/); + gc->Deactivate(); + opaqueWinChild.EndRedraw(); + ws.Flush(); + + User::After(1*1000*1000); + + // preform the test by making transparent window parent invisible + transWinParent.SetVisible(EFalse); + ws.Flush(); + + User::After(2*1000*1000); + + // save the test image (without the fix this would be an opaque red window) + CFbsBitmap* testImage = new(ELeave) CFbsBitmap; + CleanupStack::PushL(testImage); + User::LeaveIfError(testImage->Create(KTestSize, displayMode)); + scr->CopyScreenToBitmap(testImage); + + _LIT(KPanicMsg, "Test Failed"); + TInt nbytes = CFbsBitmap::ScanLineLength(KTestSize.iWidth, displayMode)*KTestSize.iHeight; + if (Mem::Compare((TUint8*)testImage->DataAddress(), nbytes, (TUint8*)refImage->DataAddress(), nbytes)!=0) + User::Panic(KPanicMsg, 0); + + CleanupStack::PopAndDestroy(10, &shape); + } + +GLDEF_C TInt E32Main() + { + CTrapCleanup* cs = CTrapCleanup::New(); + if (!cs) + return KErrNoMemory; + + TRAPD(err,MainL()); + + delete cs; + return err; + } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/tw32cmdbuf.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/tw32cmdbuf.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,283 @@ +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// The fix solves the problem of bitmap drawing command being added to the window server +// command buffer without the bitmap handle(s) being added to the command buffer bitmap array. +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include "tw32cmdbuf.h" + +const TInt KMaxTestIterations = 300; +const TInt KMinTestIterations = 100; + +CTW32CmdBuf::CTW32CmdBuf(CTestStep* aStep): + CTGraphicsBase(aStep) + { + } + +CTW32CmdBuf::~CTW32CmdBuf() + { + } + +void CTW32CmdBuf::ConstructL() + { + } + +void CTW32CmdBuf::RunTestCaseL(TInt aCurTestCase) + { + ((CTW32CmdBufStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); + switch(aCurTestCase) + { + case 1: + ((CTW32CmdBufStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0452")); + INFO_PRINTF1(_L("Test all the drawing commands involving a CFbsBitmap\n")); + DoCmdBufTestsL(); + break; + default: + ((CTW32CmdBufStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + ((CTW32CmdBufStep*)iStep)->CloseTMSGraphicsStep(); + INFO_PRINTF1(_L("Test complete\n")); + TestComplete(); + } + ((CTW32CmdBufStep*)iStep)->RecordTestResultL(); + } + +/** +* TTestFunctionPtr pointer-to-function type definition +*/ +typedef void (*TTestFunctionPtr)(CWindowGc* aGc, CFbsBitmap* aBitmap, CFbsBitmap* aMask); + + +/** +* Calls CWindowGc::DrawBitmap(const TPoint &aTopLeft, const CFbsBitmap *aDevice) +*/ +void CallDrawBitmap1(CWindowGc* aGc, CFbsBitmap* aBitmap, CFbsBitmap* /*aMask*/) + { + aGc->DrawBitmap(TPoint(0, 0), aBitmap); + } + +/** +* Calls CWindowGc::DrawBitmap(const TRect &aDestRect, const CFbsBitmap *aDevice) +*/ +void CallDrawBitmap2(CWindowGc* aGc, CFbsBitmap* aBitmap, CFbsBitmap* /*aMask*/) + { + aGc->DrawBitmap(TRect(0, 0, 100, 100), aBitmap); + } + +/** +* Calls CWindowGc::DrawBitmap(const TRect &aDestRect, const CFbsBitmap *aDevice, const TRect &aSourceRect) +*/ +void CallDrawBitmap3(CWindowGc* aGc, CFbsBitmap* aBitmap, CFbsBitmap* /*aMask*/) + { + aGc->DrawBitmap(TRect(0, 0, 100, 100), aBitmap, TRect(0, 0, 100, 100)); + } + +/** +* Calls CWindowGc::DrawBitmapMasked(const TRect& aDestRect, const CFbsBitmap* aBitmap, const TRect& aSourceRect, const CFbsBitmap* aMaskBitmap, TBool aInvertMask) +*/ +void CallDrawBitmapMasked(CWindowGc* aGc, CFbsBitmap* aBitmap, CFbsBitmap* aMask) + { + aGc->DrawBitmapMasked(TRect(0, 0, 100, 100), aBitmap, TRect(0, 0, 100, 100), aMask, EFalse); + } + +/** +* Calls CWindowGc::UseBrushPattern(const CFbsBitmap *aDevice) +*/ +void CallUseBrushPattern(CWindowGc* aGc, CFbsBitmap* aBitmap, CFbsBitmap* /*aMask*/) + { + aGc->UseBrushPattern(aBitmap); + } + +/** +* Calls CWindowGc::BitBlt(const TPoint &aPos, const CFbsBitmap *aBitmap) +*/ +void CallBitBlt1(CWindowGc* aGc, CFbsBitmap* aBitmap, CFbsBitmap* /*aMask*/) + { + aGc->BitBlt(TPoint(0, 0), aBitmap); + } + +/** +* Calls CWindowGc::BitBlt(const TPoint &aDestination, const CFbsBitmap *aBitmap, const TRect &aSource) +*/ +void CallBitBlt2(CWindowGc* aGc, CFbsBitmap* aBitmap, CFbsBitmap* /*aMask*/) + { + aGc->BitBlt(TPoint(0, 0), aBitmap, TRect(0, 0, 100, 100)); + } + +/** +* Calls CWindowGc::BitBltMasked(const TPoint& aPoint,const CFbsBitmap* aBitmap,const TRect& aSourceRect,const CFbsBitmap* aMaskBitmap,TBool aInvertMask) +*/ +void CallBitBltMasked(CWindowGc* aGc, CFbsBitmap* aBitmap, CFbsBitmap* aMask) + { + aGc->BitBltMasked(TPoint(0, 0), aBitmap, TRect(0, 0, 100, 100), aMask, EFalse); + } + +/** +* Calls CWindowGc::AlphaBlendBitmaps(const TPoint& aDestPt, const CFbsBitmap* aSrcBmp, const TRect& aSrcRect, const CFbsBitmap* aAlphaBmp, const TPoint& aAlphaPt) +*/ +void CallAlphaBlendBitmaps(CWindowGc* aGc, CFbsBitmap* aBitmap, CFbsBitmap* aMask) + { + aGc->AlphaBlendBitmaps(TPoint(0, 0), aBitmap, TRect(0, 0, 100, 100), aMask, TPoint(0, 0)); + } + +/** +* Drawing command function array. +*/ +const TTestFunctionPtr KTestFunctions[] = + { + CallDrawBitmap1, + CallDrawBitmap2, + CallDrawBitmap3, + CallDrawBitmapMasked, + CallUseBrushPattern, + CallBitBlt1, + CallBitBlt2, + CallBitBltMasked, + CallAlphaBlendBitmaps, + }; + +/** + * @SYMTestCaseID GRAPHICS-WSERV-0452 + * @SYMTestCaseDesc Tests drawing commands with bitmap handles. + * @SYMDEF INC111655 + * @SYMFssID CWindowGc::DrawBitmap() \n + * CWindowGc::DrawBitmapMasked()\n + * CWindowGc::UseBrushPattern()\n + * CWindowGc::BitBlt()\n + * CWindowGc::AlphaBlendBitmaps() + * @SYMTestPriority Critical + * @SYMTestType Unit Test + * @SYMTestPurpose To ensure drawing commands with bitmap handles are added to the + command buffer successfully when the buffer is full. + * @SYMTestActions Fill the command buffer with CWindowGc::Clear() commands in a loop until + the buffer is full, create bitmap(s), then call the draw command and then + delete the bitmap handle(s). All tests are done in a second thread. + * @SYMTestExpectedResults The function should not panic. Without the fix the functions will panic + with WSERV 7. + * @SYMTestStatus Implemented + */ +void CTW32CmdBuf::DoCmdBufTestsL() + { + CreateSecondThreadAndDoTestL(ECallDrawBitmap1); + CreateSecondThreadAndDoTestL(ECallDrawBitmap2); + CreateSecondThreadAndDoTestL(ECallDrawBitmap3); + CreateSecondThreadAndDoTestL(ECallDrawBitmapMasked); + CreateSecondThreadAndDoTestL(ECallUseBrushPattern); + CreateSecondThreadAndDoTestL(ECallBitBlt1); + CreateSecondThreadAndDoTestL(ECallBitBlt2); + CreateSecondThreadAndDoTestL(ECallBitBltMasked); + CreateSecondThreadAndDoTestL(ECallAlphaBlendBitmaps); + } + +/** +* Creates a second thread to run the test. +* +* @param aFunctionIndex The drawing function command to be executed. All commands are defined in TestFunctionIndex. +*/ +void CTW32CmdBuf::CreateSecondThreadAndDoTestL(TTestFunctionIndex aFunctionIndex) + { + RThread thread; + TBuf<30> threadName(KTW32CmdBufSecondThread); + static TInt threadSerialNumber = 0; + threadName.AppendNum(++threadSerialNumber); + User::LeaveIfError(thread.Create(threadName, TestCmdBufFunction, KDefaultStackSize, KMinHeapSize, 0x4000, &aFunctionIndex)); + TRequestStatus status; + thread.Logon(status); + thread.Resume(); + User::WaitForRequest(status); + TEST(thread.ExitType()==EExitKill); + TEST(thread.ExitReason() == KErrNone); + thread.Close(); + } + +/** +* Runs the test in a second thread. +* +* @param aFunctionIndex The drawing function command to be executed. All commands are defined in TestFunctionIndex. +*/ +TInt CTW32CmdBuf::DoTestCmdBufFunctionL(TTestFunctionIndex aFunctionIndex) + { + RWsSession session; + User::LeaveIfError(session.Connect()); + CleanupClosePushL(session); + CWsScreenDevice *device = new(ELeave) CWsScreenDevice(session); + CleanupStack::PushL(device); + User::LeaveIfError(device->Construct(CTestBase::iScreenNo)); + CWindowGc* gc; + User::LeaveIfError(device->CreateContext(gc)); + CleanupStack::PushL(gc); + RWindowGroup group(session); + User::LeaveIfError(group.Construct(1, EFalse)); + CleanupClosePushL(group); + RWindow window(session); + User::LeaveIfError(window.Construct(group, 2)); + CleanupClosePushL(window); + window.SetExtent(TPoint(0,0), TSize(200, 200)); + User::LeaveIfError(window.SetRequiredDisplayMode(EColor64K)); + window.Activate(); + gc->Activate(window); + session.SetAutoFlush(EFalse); + window.Invalidate(); + window.BeginRedraw(); + for(TInt i=KMinTestIterations; iClear(); + } + + CFbsBitmap* bitmap = new(ELeave) CFbsBitmap; + CleanupStack::PushL(bitmap); + User::LeaveIfError(bitmap->Create(TSize(100, 100), EColor64K)); + CFbsBitmap* mask = new(ELeave) CFbsBitmap; + CleanupStack::PushL(mask); + User::LeaveIfError(mask->Create(TSize(100, 100), EColor64K)); + KTestFunctions[aFunctionIndex](gc, bitmap, mask); + CleanupStack::PopAndDestroy(2); + session.Flush(); + } + window.EndRedraw(); + gc->Deactivate(); + CleanupStack::PopAndDestroy(5); + return KErrNone; + } + +/** +* Second thread entry function. +* +* @param aInfo The parameter(s) passed to the second thread in this case the function index. +*/ +TInt CTW32CmdBuf::TestCmdBufFunction(TAny* aInfo) + { + if(!aInfo) + { + return KErrArgument; + } + TTestFunctionIndex functionIndex = *(TTestFunctionIndex*)aInfo; + CTrapCleanup *trap = CTrapCleanup::New(); + __ASSERT_ALWAYS(trap, User::Invariant()); + + TRAPD(err, DoTestCmdBufFunctionL(functionIndex)); + + delete trap; + return err; + } + +__CONSTRUCT_STEP__(W32CmdBuf) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/tw32cmdbuf.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/tw32cmdbuf.h Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,73 @@ +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef TW32CMDBUF_H +#define TW32CMDBUF_H + +#include +#include +#include "../tlib/testbase.h" +#include "AUTO.H" +#include "TGraphicsHarness.h" + +_LIT(KTW32CmdBufSecondThread, "TW32CmdBufSecondThread"); + +enum TTestFunctionIndex + { + ECallDrawBitmap1, + ECallDrawBitmap2, + ECallDrawBitmap3, + ECallDrawBitmapMasked, + ECallUseBrushPattern, + ECallBitBlt1, + ECallBitBlt2, + ECallBitBltMasked, + ECallAlphaBlendBitmaps, + }; + +class CTW32CmdBuf : public CTGraphicsBase + { +public: + CTW32CmdBuf(CTestStep* aStep); + ~CTW32CmdBuf(); + void ConstructL(); + +protected: + virtual void RunTestCaseL(TInt aCurTestCase); +private: + void DoCmdBufTestsL(); + void CreateSecondThreadAndDoTestL(TTestFunctionIndex aFunctionIndex); + static TInt TestCmdBufFunction(TAny* aInfo); + static TInt DoTestCmdBufFunctionL(TTestFunctionIndex aFunctionIndex); + }; + +class CTW32CmdBufStep : public CTGraphicsStep + { +public: + CTW32CmdBufStep(); +protected: + //from CTGraphicsStep + virtual CTGraphicsBase* CreateTestL(); + }; + +_LIT(KTW32CmdBufStep,"TW32CmdBuf"); + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/twindowsizecache.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/twindowsizecache.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,2940 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// General window tests +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include "twindowsizecache.h" + +CTWindowSizeCacheTest::CTWindowSizeCacheTest(CTestStep* aStep) : CTWsGraphicsBase(aStep) + {} + +CTWindowSizeCacheTest::~CTWindowSizeCacheTest() + { + } + +void CTWindowSizeCacheTest::ConstructL() + {} + + +void CTWindowSizeCacheTest::TestCreateRWindowL(TSizeCacheStatus aEnableWindowSizeCache) + { + __UHEAP_MARK; + // w* State Initial + RWsSession rws; + TInt err = rws.Connect(); + CleanupClosePushL(rws); + TEST(KErrNone == err); + + if (ETestSizeCacheEnabled == aEnableWindowSizeCache) + { + rws.EnableWindowSizeCacheL(); + } + + RWindowGroup wg(rws); + err = wg.Construct(0); + CleanupClosePushL(wg); + TEST(KErrNone == err); + + // w1 State 0 + RWindow w1(rws); + err = w1.Construct(wg,1); + CleanupClosePushL(w1); + TEST(KErrNone == err); + + // w2 State 0 + RWindow w2(rws); + err = w2.Construct(wg,2); + CleanupClosePushL(w2); + TEST(KErrNone == err); + + CleanupStack::Pop(2); + + // w1 State Final + w1.Close(); + // w2 State Final + w2.Close(); + + RWindow w3(rws); + // w3 State 0 + err = w3.Construct(wg,1); + CleanupClosePushL(w3); + TEST(KErrNone == err); + + CleanupStack::Pop(2); + + // w3 State Final + w3.Close(); + + wg.Close(); + + RWindowGroup wg2(rws); + err = wg2.Construct(0); + CleanupClosePushL(wg2); + TEST(KErrNone == err); + + RWindowGroup wg3(rws); + err = wg3.Construct(1); + CleanupClosePushL(wg3); + TEST(KErrNone == err); + + // w4 State 0 + RWindow w4(rws); + err = w4.Construct(wg2,2); + CleanupClosePushL(w4); + TEST(KErrNone == err); + + // w5 State 0 + RWindow w5(rws); + err = w5.Construct(wg3,3); + CleanupClosePushL(w5); + TEST(KErrNone == err); + + CleanupStack::Pop(5); + + // w4 State Final + w4.Close(); + + // w5 State Final + // Check nothing bad happens when calling Close more than once on RWindow + w5.Close(); + w5.Close(); + + // Check nothing bad happens when calling Close more than once on RWindowGroup + wg2.Close(); + wg2.Close(); + + wg3.Close(); + + // Check nothing bad happens when calling Close more than once on RWsSession + rws.Close(); + rws.Close(); + __UHEAP_MARKEND; + } + +void CTWindowSizeCacheTest::TestCreateRBlankWindowL(TSizeCacheStatus aEnableWindowSizeCache) + { + __UHEAP_MARK; + // w* State Initial + RWsSession rws; + TInt err = rws.Connect(); + CleanupClosePushL(rws); + TEST(KErrNone == err); + + if (ETestSizeCacheEnabled == aEnableWindowSizeCache) + { + rws.EnableWindowSizeCacheL(); + } + + RWindowGroup wg(rws); + err = wg.Construct(0); + CleanupClosePushL(wg); + TEST(KErrNone == err); + + // w1 State 0 + RBlankWindow w1(rws); + err = w1.Construct(wg,1); + CleanupClosePushL(w1); + TEST(KErrNone == err); + + // w2 State 0 + RBlankWindow w2(rws); + err = w2.Construct(wg,2); + CleanupClosePushL(w2); + TEST(KErrNone == err); + + CleanupStack::Pop(2); + + // w1 State Final + w1.Close(); + // w2 State Final + w2.Close(); + + RBlankWindow w3(rws); + // w3 State 0 + err = w3.Construct(wg,1); + CleanupClosePushL(w3); + TEST(KErrNone == err); + + CleanupStack::Pop(2); + + // w3 State Final + w3.Close(); + + wg.Close(); + + RWindowGroup wg2(rws); + err = wg2.Construct(0); + CleanupClosePushL(wg2); + TEST(KErrNone == err); + + RWindowGroup wg3(rws); + err = wg3.Construct(1); + CleanupClosePushL(wg3); + TEST(KErrNone == err); + + // w4 State 0 + RBlankWindow w4(rws); + err = w4.Construct(wg2,2); + CleanupClosePushL(w4); + TEST(KErrNone == err); + + // w5 State 0 + RBlankWindow w5(rws); + err = w5.Construct(wg3,3); + CleanupClosePushL(w5); + TEST(KErrNone == err); + + CleanupStack::Pop(5); + + // w4 State Final + w4.Close(); + + // w5 State Final + // Check nothing bad happens when calling Close more than once on RBlankWindow + w5.Close(); + w5.Close(); + + wg2.Close(); + wg3.Close(); + rws.Close(); + __UHEAP_MARKEND; + } + +void CTWindowSizeCacheTest::TestCreateRBackedUpWindowL(TSizeCacheStatus aEnableWindowSizeCache, TDisplayMode aDisplayMode) + { + __UHEAP_MARK; + // w* State Initial + RWsSession rws; + TInt err = rws.Connect(); + CleanupClosePushL(rws); + TEST(KErrNone == err); + + if (ETestSizeCacheEnabled == aEnableWindowSizeCache) + { + rws.EnableWindowSizeCacheL(); + } + + RWindowGroup wg(rws); + err = wg.Construct(0); + CleanupClosePushL(wg); + TEST(KErrNone == err); + + // w1 State 0 + RBackedUpWindow w1(rws); + err = w1.Construct(wg,aDisplayMode,1); + CleanupClosePushL(w1); + TEST(KErrNone == err); + + // w2 State 0 + RBackedUpWindow w2(rws); + err = w2.Construct(wg,aDisplayMode,2); + CleanupClosePushL(w2); + TEST(KErrNone == err); + + CleanupStack::Pop(2); + + // w1 State Final + w1.Close(); + + // w2 State Final + w2.Close(); + + RBackedUpWindow w3(rws); + // w3 State 0 + err = w3.Construct(wg,aDisplayMode,1); + CleanupClosePushL(w3); + TEST(KErrNone == err); + + CleanupStack::Pop(2); + + // w3 State Final + w3.Close(); + + wg.Close(); + + RWindowGroup wg2(rws); + CleanupClosePushL(wg2); + err = wg2.Construct(0); + TEST(KErrNone == err); + + RWindowGroup wg3(rws); + err = wg3.Construct(1); + CleanupClosePushL(wg3); + TEST(KErrNone == err); + + // w4 State 0 + RBackedUpWindow w4(rws); + err = w4.Construct(wg2,aDisplayMode,2); + CleanupClosePushL(w4); + TEST(KErrNone == err); + + // w5 State 0 + RBackedUpWindow w5(rws); + err = w5.Construct(wg3,aDisplayMode,3); + CleanupClosePushL(w5); + TEST(KErrNone == err); + + CleanupStack::Pop(5); + + // w4 State Final + w4.Close(); + + // w5 State Final + // Check nothing bad happens when calling Close more than once on RBackedUpWindow + w5.Close(); + w5.Close(); + + wg2.Close(); + wg3.Close(); + rws.Close(); + __UHEAP_MARKEND; + } + +void CTWindowSizeCacheTest::TestRWindowNoCacheEntryL(TSizeCacheStatus aEnableWindowSizeCache) + { + __UHEAP_MARK; + // w* State Initial + RWsSession rws; + TInt err = rws.Connect(); + CleanupClosePushL(rws); + TEST(err==KErrNone); + + if (aEnableWindowSizeCache) + { + rws.EnableWindowSizeCacheL(); + } + + RWindowGroup wg(rws); + wg.Construct(0); + CleanupClosePushL(rws); + + // w1 State 0 + RWindow w1(rws); + w1.Construct(wg,1); + CleanupClosePushL(w1); + + // w1 State Final + CleanupStack::Pop(); + w1.Close(); + + CleanupStack::Pop(); + wg.Close(); + + CleanupStack::Pop(); + rws.Close(); + + __UHEAP_MARKEND; + } + +void CTWindowSizeCacheTest::TestRWindowNoCacheEntrySetExtentErrL(TSizeCacheStatus aEnableWindowSizeCache) + { + __UHEAP_MARK; + // w* State Initial + RWsSession rws; + TInt err = rws.Connect(); + CleanupClosePushL(rws); + TEST(err==KErrNone); + + if (aEnableWindowSizeCache) + { + rws.EnableWindowSizeCacheL(); + } + + RWindowGroup wg(rws); + wg.Construct(0); + CleanupClosePushL(rws); + + // w1 State 0 + RWindow w1(rws); + w1.Construct(wg,1); + CleanupClosePushL(w1); + + // w1 State 0 + TPoint point1 (10101,897); + TSize size1 (10001,123); + err = w1.SetExtentErr(point1, size1); + TEST(KErrNone == err); + + // w1 State Final + CleanupStack::Pop(); + w1.Close(); + + CleanupStack::Pop(); + wg.Close(); + + CleanupStack::Pop(); + rws.Close(); + + __UHEAP_MARKEND; + } + +void CTWindowSizeCacheTest::TestRWindowNoCacheEntrySetSizeErrL(TSizeCacheStatus aEnableWindowSizeCache) + { + __UHEAP_MARK; + // w* State Initial + RWsSession rws; + TInt err = rws.Connect(); + CleanupClosePushL(rws); + TEST(err==KErrNone); + + if (aEnableWindowSizeCache) + { + rws.EnableWindowSizeCacheL(); + } + + RWindowGroup wg(rws); + wg.Construct(0); + CleanupClosePushL(rws); + + // w1 State 0 + RWindow w1(rws); + w1.Construct(wg,1); + CleanupClosePushL(w1); + + // w1 State 0 + TSize size1 (10001,123); + err = w1.SetSizeErr(size1); + TEST(KErrNone == err); + + // w1 State Final + CleanupStack::Pop(); + w1.Close(); + + CleanupStack::Pop(); + wg.Close(); + + CleanupStack::Pop(); + rws.Close(); + + __UHEAP_MARKEND; + } + +void CTWindowSizeCacheTest::TestRWindowNoCacheEntrySetExtentL(TSizeCacheStatus aEnableWindowSizeCache) + { + __UHEAP_MARK; + // w* State Initial + RWsSession rws; + TInt err = rws.Connect(); + CleanupClosePushL(rws); + TEST(err==KErrNone); + + if (aEnableWindowSizeCache) + { + rws.EnableWindowSizeCacheL(); + } + + RWindowGroup wg(rws); + wg.Construct(0); + CleanupClosePushL(rws); + + // w1 State 0 + RWindow w1(rws); + w1.Construct(wg,1); + CleanupClosePushL(w1); + + // w1 State 0 + TPoint point1 (10101,897); + TSize size1 (10001,123); + w1.SetExtent(point1, size1); + rws.Flush(); + + // w1 State Final + CleanupStack::Pop(); + w1.Close(); + + CleanupStack::Pop(); + wg.Close(); + + CleanupStack::Pop(); + rws.Close(); + + __UHEAP_MARKEND; + } + +void CTWindowSizeCacheTest::TestRWindowNoCacheEntrySetSizeL(TSizeCacheStatus aEnableWindowSizeCache) + { + __UHEAP_MARK; + // w* State Initial + RWsSession rws; + TInt err = rws.Connect(); + CleanupClosePushL(rws); + TEST(err==KErrNone); + + if (aEnableWindowSizeCache) + { + rws.EnableWindowSizeCacheL(); + } + + RWindowGroup wg(rws); + wg.Construct(0); + CleanupClosePushL(rws); + + // w1 State 0 + RWindow w1(rws); + w1.Construct(wg,1); + CleanupClosePushL(w1); + + // w1 State 0 + TSize size1 (10001,123); + w1.SetSize(size1); + rws.Flush(); + + // w1 State Final + CleanupStack::Pop(); + w1.Close(); + + CleanupStack::Pop(); + wg.Close(); + + CleanupStack::Pop(); + rws.Close(); + + __UHEAP_MARKEND; + } + +void CTWindowSizeCacheTest::TestRWindowNoCacheEntryEnableWindowSizeCacheL() + { + __UHEAP_MARK; + // w* State Initial + RWsSession rws; + TInt err = rws.Connect(); + CleanupClosePushL(rws); + TEST(err==KErrNone); + + rws.EnableWindowSizeCacheL(); + + RWindowGroup wg(rws); + wg.Construct(0); + CleanupClosePushL(rws); + + // w1 State 0 + RWindow w1(rws); + w1.Construct(wg,1); + CleanupClosePushL(w1); + + // w1 State 0 + // Only the first call to EnableWindowSizeCacheL() should have an effect + // All subsequent calls to EnableWindowSizeCacheL() should have no effect + rws.EnableWindowSizeCacheL(); + + // w1 State Final + CleanupStack::Pop(); + w1.Close(); + + CleanupStack::Pop(); + wg.Close(); + + CleanupStack::Pop(); + rws.Close(); + + __UHEAP_MARKEND; + } + +void CTWindowSizeCacheTest::TestRWindowCacheEntryExistsCacheCleanL(TSizeCacheStatus aEnableWindowSizeCache) + { + __UHEAP_MARK; + // w* State Initial + RWsSession rws; + TInt err = rws.Connect(); + CleanupClosePushL(rws); + TEST(err==KErrNone); + + if (aEnableWindowSizeCache) + { + rws.EnableWindowSizeCacheL(); + } + + RWindowGroup wg(rws); + wg.Construct(0); + CleanupClosePushL(rws); + + // w1 State 0 + RWindow w1(rws); + w1.Construct(wg,1); + CleanupClosePushL(w1); + + // w1 State 0 + TSize size1 (10001,123); + w1.SetSize(size1); + rws.Flush(); + + // w1 State 1 + TSize retSize1 = w1.Size(); + TEST(retSize1 == size1); + + // w1 State Final + CleanupStack::Pop(); + w1.Close(); + + CleanupStack::Pop(); + wg.Close(); + + CleanupStack::Pop(); + rws.Close(); + + __UHEAP_MARKEND; + } + +void CTWindowSizeCacheTest::TestRWindowCacheEntryExistsCacheCleanSizeL(TSizeCacheStatus aEnableWindowSizeCache) + { + __UHEAP_MARK; + // w* State Initial + RWsSession rws; + TInt err = rws.Connect(); + CleanupClosePushL(rws); + TEST(err==KErrNone); + + if (aEnableWindowSizeCache) + { + rws.EnableWindowSizeCacheL(); + } + + RWindowGroup wg(rws); + wg.Construct(0); + CleanupClosePushL(rws); + + // w1 State 0 + RWindow w1(rws); + w1.Construct(wg,1); + CleanupClosePushL(w1); + + // w1 State 0 + TSize size1 (10001,123); + w1.SetSize(size1); + rws.Flush(); + + // w1 State 1 + TSize retSize1 = w1.Size(); + TEST(retSize1 == size1); + + // w1 State 1 + TSize retSize2 = w1.Size(); + TEST(retSize2 == size1); + + // w1 State Final + CleanupStack::Pop(); + w1.Close(); + + CleanupStack::Pop(); + wg.Close(); + + CleanupStack::Pop(); + rws.Close(); + + __UHEAP_MARKEND; + } + +void CTWindowSizeCacheTest::TestRWindowCacheEntryExistsCacheCleanEnableWindowSizeCacheL() + { + __UHEAP_MARK; + // w* State Initial + RWsSession rws; + TInt err = rws.Connect(); + CleanupClosePushL(rws); + TEST(err==KErrNone); + + rws.EnableWindowSizeCacheL(); + + RWindowGroup wg(rws); + wg.Construct(0); + CleanupClosePushL(rws); + + // w1 State 0 + RWindow w1(rws); + w1.Construct(wg,1); + CleanupClosePushL(w1); + + // w1 State 0 + TSize size1 (10001,123); + w1.SetSize(size1); + rws.Flush(); + + // w1 State 1 + TSize retSize1 = w1.Size(); + TEST(retSize1 == size1); + + // w1 State 1 + // Only the first call to EnableWindowSizeCacheL() should have an effect + // All subsequent calls to EnableWindowSizeCacheL() should have no effect + rws.EnableWindowSizeCacheL(); + + // w1 State Final + CleanupStack::Pop(); + w1.Close(); + + CleanupStack::Pop(); + wg.Close(); + + CleanupStack::Pop(); + rws.Close(); + + __UHEAP_MARKEND; + } + +void CTWindowSizeCacheTest::TestRWindowCacheEntryExistsCacheCleanEnableWindowSizeCacheLSizeL() + { + __UHEAP_MARK; + // w* State Initial + RWsSession rws; + TInt err = rws.Connect(); + CleanupClosePushL(rws); + TEST(err==KErrNone); + + rws.EnableWindowSizeCacheL(); + + RWindowGroup wg(rws); + wg.Construct(0); + CleanupClosePushL(rws); + + // w1 State 0 + RWindow w1(rws); + w1.Construct(wg,1); + CleanupClosePushL(w1); + + // w1 State 0 + TSize size1 (10001,123); + w1.SetSize(size1); + rws.Flush(); + + // w1 State 1 + TSize retSize1 = w1.Size(); + TEST(retSize1 == size1); + + // w1 State 1 + // Only the first call to EnableWindowSizeCacheL() should have an effect + // All subsequent calls to EnableWindowSizeCacheL() should have no effect + rws.EnableWindowSizeCacheL(); + + // w1 State 1 + TSize retSize2 = w1.Size(); + TEST(retSize2 == size1); + + // w1 State Final + CleanupStack::Pop(); + w1.Close(); + + CleanupStack::Pop(); + wg.Close(); + + CleanupStack::Pop(); + rws.Close(); + + __UHEAP_MARKEND; + } + +void CTWindowSizeCacheTest::TestRWindowCacheEntryExistsCacheDirtySetSizeL(TSizeCacheStatus aEnableWindowSizeCache) + { + __UHEAP_MARK; + // w* State Initial + RWsSession rws; + TInt err = rws.Connect(); + CleanupClosePushL(rws); + TEST(err==KErrNone); + + if (aEnableWindowSizeCache) + { + rws.EnableWindowSizeCacheL(); + } + + RWindowGroup wg(rws); + wg.Construct(0); + CleanupClosePushL(rws); + + // w1 State 0 + RWindow w1(rws); + w1.Construct(wg,1); + CleanupClosePushL(w1); + + // w1 State 0 + TSize size1 (10001,123); + w1.SetSize(size1); + rws.Flush(); + + // w1 State 1 + TSize retSize1 = w1.Size(); + TEST(retSize1 == size1); + + // w1 State 2 + TSize size2 (20002,223); + w1.SetSize(size2); + rws.Flush(); + + // w1 State Final + CleanupStack::Pop(); + w1.Close(); + + CleanupStack::Pop(); + wg.Close(); + + CleanupStack::Pop(); + rws.Close(); + + __UHEAP_MARKEND; + } + +void CTWindowSizeCacheTest::TestRWindowCacheEntryExistsCacheDirtySetExtentL(TSizeCacheStatus aEnableWindowSizeCache) + { + __UHEAP_MARK; + // w* State Initial + RWsSession rws; + TInt err = rws.Connect(); + CleanupClosePushL(rws); + TEST(err==KErrNone); + + if (aEnableWindowSizeCache) + { + rws.EnableWindowSizeCacheL(); + } + + RWindowGroup wg(rws); + wg.Construct(0); + CleanupClosePushL(rws); + + // w1 State 0 + RWindow w1(rws); + w1.Construct(wg,1); + CleanupClosePushL(w1); + + // w1 State 0 + TSize size1 (10001,123); + w1.SetSize(size1); + rws.Flush(); + + // w1 State 1 + TSize retSize1 = w1.Size(); + TEST(retSize1 == size1); + + // w1 State 2 + TPoint point2 (20202,223); + TSize size2 (20002,223); + w1.SetExtent(point2, size2); + rws.Flush(); + + // w1 State Final + CleanupStack::Pop(); + w1.Close(); + + CleanupStack::Pop(); + wg.Close(); + + CleanupStack::Pop(); + rws.Close(); + + __UHEAP_MARKEND; + } + +void CTWindowSizeCacheTest::TestRWindowCacheEntryExistsCacheDirtySetSizeErrL(TSizeCacheStatus aEnableWindowSizeCache) + { + __UHEAP_MARK; + // w* State Initial + RWsSession rws; + TInt err = rws.Connect(); + CleanupClosePushL(rws); + TEST(err==KErrNone); + + if (aEnableWindowSizeCache) + { + rws.EnableWindowSizeCacheL(); + } + + RWindowGroup wg(rws); + wg.Construct(0); + CleanupClosePushL(rws); + + // w1 State 0 + RWindow w1(rws); + w1.Construct(wg,1); + CleanupClosePushL(w1); + + // w1 State 0 + TSize size1 (10001,123); + w1.SetSize(size1); + rws.Flush(); + + // w1 State 1 + TSize retSize1 = w1.Size(); + TEST(retSize1 == size1); + + // w1 State 2 + TSize size2 (20002,223); + err = w1.SetSizeErr(size2); + TEST(KErrNone == err); + + // w1 State Final + CleanupStack::Pop(); + w1.Close(); + + CleanupStack::Pop(); + wg.Close(); + + CleanupStack::Pop(); + rws.Close(); + + __UHEAP_MARKEND; + } + +void CTWindowSizeCacheTest::TestRWindowCacheEntryExistsCacheDirtySetExtentErrL(TSizeCacheStatus aEnableWindowSizeCache) + { + __UHEAP_MARK; + // w* State Initial + RWsSession rws; + TInt err = rws.Connect(); + CleanupClosePushL(rws); + TEST(err==KErrNone); + + if (aEnableWindowSizeCache) + { + rws.EnableWindowSizeCacheL(); + } + + RWindowGroup wg(rws); + wg.Construct(0); + CleanupClosePushL(rws); + + // w1 State 0 + RWindow w1(rws); + w1.Construct(wg,1); + CleanupClosePushL(w1); + + // w1 State 0 + TSize size1 (10001,123); + w1.SetSize(size1); + rws.Flush(); + + // w1 State 1 + TSize retSize1 = w1.Size(); + TEST(retSize1 == size1); + + // w1 State 2 + TPoint point2 (20202,223); + TSize size2 (20002,223); + err = w1.SetExtentErr(point2, size2); + TEST(KErrNone == err); + + // w1 State Final + CleanupStack::Pop(); + w1.Close(); + + CleanupStack::Pop(); + wg.Close(); + + CleanupStack::Pop(); + rws.Close(); + + __UHEAP_MARKEND; + } + +void CTWindowSizeCacheTest::TestRWindowCacheEntryExistsCacheDirtySetSizeTwiceL(TSizeCacheStatus aEnableWindowSizeCache) + { + __UHEAP_MARK; + // w* State Initial + RWsSession rws; + TInt err = rws.Connect(); + CleanupClosePushL(rws); + TEST(err==KErrNone); + + if (aEnableWindowSizeCache) + { + rws.EnableWindowSizeCacheL(); + } + + RWindowGroup wg(rws); + wg.Construct(0); + CleanupClosePushL(rws); + + // w1 State 0 + RWindow w1(rws); + w1.Construct(wg,1); + CleanupClosePushL(w1); + + // w1 State 0 + TSize size1 (10001,123); + w1.SetSize(size1); + rws.Flush(); + + // w1 State 1 + TSize retSize1 = w1.Size(); + TEST(retSize1 == size1); + + // w1 State 2 + TSize size2 (20002,223); + w1.SetSize(size2); + + TSize size3 (30003,323); + // w1 State 2 + w1.SetSize(size3); + rws.Flush(); + + // w1 State Final + CleanupStack::Pop(); + w1.Close(); + + CleanupStack::Pop(); + wg.Close(); + + CleanupStack::Pop(); + rws.Close(); + + __UHEAP_MARKEND; + } + +void CTWindowSizeCacheTest::TestRWindowCacheEntryExistsCacheDirtySetSizeSetExtentL(TSizeCacheStatus aEnableWindowSizeCache) + { + __UHEAP_MARK; + // w* State Initial + RWsSession rws; + TInt err = rws.Connect(); + CleanupClosePushL(rws); + TEST(err==KErrNone); + + if (aEnableWindowSizeCache) + { + rws.EnableWindowSizeCacheL(); + } + + RWindowGroup wg(rws); + wg.Construct(0); + CleanupClosePushL(rws); + + // w1 State 0 + RWindow w1(rws); + w1.Construct(wg,1); + CleanupClosePushL(w1); + + // w1 State 0 + TSize size1 (10001,123); + w1.SetSize(size1); + rws.Flush(); + + // w1 State 1 + TSize retSize1 = w1.Size(); + TEST(retSize1 == size1); + + // w1 State 2 + TSize size2 (20002,223); + w1.SetSize(size2); + + // w1 State 2 + TPoint point3 (30303,232); + TSize size3 (30003,323); + w1.SetExtent(point3, size3); + rws.Flush(); + + // w1 State Final + CleanupStack::Pop(); + w1.Close(); + + CleanupStack::Pop(); + wg.Close(); + + CleanupStack::Pop(); + rws.Close(); + + __UHEAP_MARKEND; + } + +void CTWindowSizeCacheTest::TestRWindowCacheEntryExistsCacheDirtySetSizeSetSizeErrL(TSizeCacheStatus aEnableWindowSizeCache) + { + __UHEAP_MARK; + // w* State Initial + RWsSession rws; + TInt err = rws.Connect(); + CleanupClosePushL(rws); + TEST(err==KErrNone); + + if (aEnableWindowSizeCache) + { + rws.EnableWindowSizeCacheL(); + } + + RWindowGroup wg(rws); + wg.Construct(0); + CleanupClosePushL(rws); + + // w1 State 0 + RWindow w1(rws); + w1.Construct(wg,1); + CleanupClosePushL(w1); + + // w1 State 0 + TSize size1 (10001,123); + w1.SetSize(size1); + rws.Flush(); + + // w1 State 1 + TSize retSize1 = w1.Size(); + TEST(retSize1 == size1); + + // w1 State 2 + TSize size2 (20002,223); + w1.SetSize(size2); + + // w1 State 2 + TSize size3 (30003,323); + err = w1.SetSizeErr(size3); + TEST(KErrNone == err); + + // w1 State Final + CleanupStack::Pop(); + w1.Close(); + + CleanupStack::Pop(); + wg.Close(); + + CleanupStack::Pop(); + rws.Close(); + + __UHEAP_MARKEND; + } + +void CTWindowSizeCacheTest::TestRWindowCacheEntryExistsCacheDirtySetSizeSetExtentErrL(TSizeCacheStatus aEnableWindowSizeCache) + { + __UHEAP_MARK; + // w* State Initial + RWsSession rws; + TInt err = rws.Connect(); + CleanupClosePushL(rws); + TEST(err==KErrNone); + + if (aEnableWindowSizeCache) + { + rws.EnableWindowSizeCacheL(); + } + + RWindowGroup wg(rws); + wg.Construct(0); + CleanupClosePushL(rws); + + // w1 State 0 + RWindow w1(rws); + w1.Construct(wg,1); + CleanupClosePushL(w1); + + // w1 State 0 + TSize size1 (10001,123); + w1.SetSize(size1); + rws.Flush(); + + // w1 State 1 + TSize retSize1 = w1.Size(); + TEST(retSize1 == size1); + + // w1 State 2 + TSize size2 (20002,223); + w1.SetSize(size2); + + // w1 State 2 + TPoint point3 (30303,232); + TSize size3 (30003,323); + err = w1.SetExtentErr(point3, size3); + TEST(KErrNone == err); + + // w1 State Final + CleanupStack::Pop(); + w1.Close(); + + CleanupStack::Pop(); + wg.Close(); + + CleanupStack::Pop(); + rws.Close(); + + __UHEAP_MARKEND; + } + +void CTWindowSizeCacheTest::TestRWindowCacheEntryExistsCacheDirtySetSizeEnableWindowSizeCacheL() + { + __UHEAP_MARK; + // w* State Initial + RWsSession rws; + TInt err = rws.Connect(); + CleanupClosePushL(rws); + TEST(err==KErrNone); + + rws.EnableWindowSizeCacheL(); + + RWindowGroup wg(rws); + wg.Construct(0); + CleanupClosePushL(rws); + + // w1 State 0 + RWindow w1(rws); + w1.Construct(wg,1); + CleanupClosePushL(w1); + + // w1 State 0 + TSize size1 (10001,123); + w1.SetSize(size1); + rws.Flush(); + + // w1 State 1 + TSize retSize1 = w1.Size(); + TEST(retSize1 == size1); + + // w1 State 2 + TSize size2 (20002,223); + w1.SetSize(size2); + + // Only the first call to EnableWindowSizeCacheL() should have an effect + // All subsequent calls to EnableWindowSizeCacheL() should have no effect + rws.EnableWindowSizeCacheL(); + + // w1 State Final + CleanupStack::Pop(); + w1.Close(); + + CleanupStack::Pop(); + wg.Close(); + + CleanupStack::Pop(); + rws.Close(); + + __UHEAP_MARKEND; + } + +//------------------------------------------------------------------------------------------- +void CTWindowSizeCacheTest::TestRWindowCacheEntryExistsCacheDirtyToCleanSetSizeL(TSizeCacheStatus aEnableWindowSizeCache) + { + __UHEAP_MARK; + // w* State Initial + RWsSession rws; + TInt err = rws.Connect(); + CleanupClosePushL(rws); + TEST(err==KErrNone); + + if (aEnableWindowSizeCache) + { + rws.EnableWindowSizeCacheL(); + } + + RWindowGroup wg(rws); + wg.Construct(0); + CleanupClosePushL(rws); + + // w1 State 0 + RWindow w1(rws); + w1.Construct(wg,1); + CleanupClosePushL(w1); + + // w1 State 0 + TSize size1 (10001,123); + w1.SetSize(size1); + rws.Flush(); + + // w1 State 1 + TSize retSize1 = w1.Size(); + TEST(retSize1 == size1); + + // w1 State 2 + TSize size2 (20002,223); + w1.SetSize(size2); + rws.Flush(); + + // w1 State 1 + TSize retSize2 = w1.Size(); + TEST(retSize2 == size2); + + // w1 State Final + CleanupStack::Pop(); + w1.Close(); + + CleanupStack::Pop(); + wg.Close(); + + CleanupStack::Pop(); + rws.Close(); + + __UHEAP_MARKEND; + } + +void CTWindowSizeCacheTest::TestRWindowCacheEntryExistsCacheDirtyToCleanSetExtentL(TSizeCacheStatus aEnableWindowSizeCache) + { + __UHEAP_MARK; + // w* State Initial + RWsSession rws; + TInt err = rws.Connect(); + CleanupClosePushL(rws); + TEST(err==KErrNone); + + if (aEnableWindowSizeCache) + { + rws.EnableWindowSizeCacheL(); + } + + RWindowGroup wg(rws); + wg.Construct(0); + CleanupClosePushL(rws); + + // w1 State 0 + RWindow w1(rws); + w1.Construct(wg,1); + CleanupClosePushL(w1); + + // w1 State 0 + TSize size1 (10001,123); + w1.SetSize(size1); + rws.Flush(); + + // w1 State 1 + TSize retSize1 = w1.Size(); + TEST(retSize1 == size1); + + // w1 State 2 + TPoint point2 (20202,223); + TSize size2 (20002,223); + w1.SetExtent(point2, size2); + rws.Flush(); + + // w1 State 1 + TSize retSize2 = w1.Size(); + TEST(retSize2 == size2); + + // w1 State Final + CleanupStack::Pop(); + w1.Close(); + + CleanupStack::Pop(); + wg.Close(); + + CleanupStack::Pop(); + rws.Close(); + + __UHEAP_MARKEND; + } + +void CTWindowSizeCacheTest::TestRWindowCacheEntryExistsCacheDirtyToCleanSetSizeErrL(TSizeCacheStatus aEnableWindowSizeCache) + { + __UHEAP_MARK; + // w* State Initial + RWsSession rws; + TInt err = rws.Connect(); + CleanupClosePushL(rws); + TEST(err==KErrNone); + + if (aEnableWindowSizeCache) + { + rws.EnableWindowSizeCacheL(); + } + + RWindowGroup wg(rws); + wg.Construct(0); + CleanupClosePushL(rws); + + // w1 State 0 + RWindow w1(rws); + w1.Construct(wg,1); + CleanupClosePushL(w1); + + // w1 State 0 + TSize size1 (10001,123); + w1.SetSize(size1); + rws.Flush(); + + // w1 State 1 + TSize retSize1 = w1.Size(); + TEST(retSize1 == size1); + + // w1 State 2 + TSize size2 (20002,223); + err = w1.SetSizeErr(size2); + TEST(KErrNone == err); + + // w1 State 1 + TSize retSize2 = w1.Size(); + TEST(retSize2 == size2); + + // w1 State Final + CleanupStack::Pop(); + w1.Close(); + + CleanupStack::Pop(); + wg.Close(); + + CleanupStack::Pop(); + rws.Close(); + + __UHEAP_MARKEND; + } + +void CTWindowSizeCacheTest::TestRWindowCacheEntryExistsCacheDirtyToCleanSetExtentErrL(TSizeCacheStatus aEnableWindowSizeCache) + { + __UHEAP_MARK; + // w* State Initial + RWsSession rws; + TInt err = rws.Connect(); + CleanupClosePushL(rws); + TEST(err==KErrNone); + + if (aEnableWindowSizeCache) + { + rws.EnableWindowSizeCacheL(); + } + + RWindowGroup wg(rws); + wg.Construct(0); + CleanupClosePushL(rws); + + // w1 State 0 + RWindow w1(rws); + w1.Construct(wg,1); + CleanupClosePushL(w1); + + // w1 State 0 + TSize size1 (10001,123); + w1.SetSize(size1); + rws.Flush(); + + // w1 State 1 + TSize retSize1 = w1.Size(); + TEST(retSize1 == size1); + + // w1 State 2 + TPoint point2 (20202,223); + TSize size2 (20002,223); + err = w1.SetExtentErr(point2, size2); + TEST(KErrNone == err); + + // w1 State 1 + TSize retSize2 = w1.Size(); + TEST(retSize2 == size2); + + // w1 State Final + CleanupStack::Pop(); + w1.Close(); + + CleanupStack::Pop(); + wg.Close(); + + CleanupStack::Pop(); + rws.Close(); + + __UHEAP_MARKEND; + } + +void CTWindowSizeCacheTest::TestRWindowCacheEntryExistsCacheDirtyToCleanSetSizeTwiceL(TSizeCacheStatus aEnableWindowSizeCache) + { + __UHEAP_MARK; + // w* State Initial + RWsSession rws; + TInt err = rws.Connect(); + CleanupClosePushL(rws); + TEST(err==KErrNone); + + if (aEnableWindowSizeCache) + { + rws.EnableWindowSizeCacheL(); + } + + RWindowGroup wg(rws); + wg.Construct(0); + CleanupClosePushL(rws); + + // w1 State 0 + RWindow w1(rws); + w1.Construct(wg,1); + CleanupClosePushL(w1); + + // w1 State 0 + TSize size1 (10001,123); + w1.SetSize(size1); + rws.Flush(); + + // w1 State 1 + TSize retSize1 = w1.Size(); + TEST(retSize1 == size1); + + // w1 State 2 + TSize size2 (20002,223); + w1.SetSize(size2); + + TSize size3 (30003,323); + // w1 State 2 + w1.SetSize(size3); + rws.Flush(); + + // w1 State 1 + TSize retSize2 = w1.Size(); + TEST(retSize2 == size3); + + // w1 State Final + CleanupStack::Pop(); + w1.Close(); + + CleanupStack::Pop(); + wg.Close(); + + CleanupStack::Pop(); + rws.Close(); + + __UHEAP_MARKEND; + } + +void CTWindowSizeCacheTest::TestRWindowCacheEntryExistsCacheDirtyToCleanSetSizeSetExtentL(TSizeCacheStatus aEnableWindowSizeCache) + { + __UHEAP_MARK; + // w* State Initial + RWsSession rws; + TInt err = rws.Connect(); + CleanupClosePushL(rws); + TEST(err==KErrNone); + + if (aEnableWindowSizeCache) + { + rws.EnableWindowSizeCacheL(); + } + + RWindowGroup wg(rws); + wg.Construct(0); + CleanupClosePushL(rws); + + // w1 State 0 + RWindow w1(rws); + w1.Construct(wg,1); + CleanupClosePushL(w1); + + // w1 State 0 + TSize size1 (10001,123); + w1.SetSize(size1); + rws.Flush(); + + // w1 State 1 + TSize retSize1 = w1.Size(); + TEST(retSize1 == size1); + + // w1 State 2 + TSize size2 (20002,223); + w1.SetSize(size2); + + // w1 State 2 + TPoint point3 (30303,232); + TSize size3 (30003,323); + w1.SetExtent(point3, size3); + rws.Flush(); + + // w1 State 1 + TSize retSize2 = w1.Size(); + TEST(retSize2 == size3); + + // w1 State Final + CleanupStack::Pop(); + w1.Close(); + + CleanupStack::Pop(); + wg.Close(); + + CleanupStack::Pop(); + rws.Close(); + + __UHEAP_MARKEND; + } + +void CTWindowSizeCacheTest::TestRWindowCacheEntryExistsCacheDirtyToCleanSetSizeSetSizeErrL(TSizeCacheStatus aEnableWindowSizeCache) + { + __UHEAP_MARK; + // w* State Initial + RWsSession rws; + TInt err = rws.Connect(); + CleanupClosePushL(rws); + TEST(err==KErrNone); + + if (aEnableWindowSizeCache) + { + rws.EnableWindowSizeCacheL(); + } + + RWindowGroup wg(rws); + wg.Construct(0); + CleanupClosePushL(rws); + + // w1 State 0 + RWindow w1(rws); + w1.Construct(wg,1); + CleanupClosePushL(w1); + + // w1 State 0 + TSize size1 (10001,123); + w1.SetSize(size1); + rws.Flush(); + + // w1 State 1 + TSize retSize1 = w1.Size(); + TEST(retSize1 == size1); + + // w1 State 2 + TSize size2 (20002,223); + w1.SetSize(size2); + + // w1 State 2 + TSize size3 (30003,323); + err = w1.SetSizeErr(size3); + TEST(KErrNone == err); + + // w1 State 1 + TSize retSize2 = w1.Size(); + TEST(retSize2 == size3); + + // w1 State Final + CleanupStack::Pop(); + w1.Close(); + + CleanupStack::Pop(); + wg.Close(); + + CleanupStack::Pop(); + rws.Close(); + + __UHEAP_MARKEND; + } + +void CTWindowSizeCacheTest::TestRWindowCacheEntryExistsCacheDirtyToCleanSetSizeSetExtentErrL(TSizeCacheStatus aEnableWindowSizeCache) + { + __UHEAP_MARK; + // w* State Initial + RWsSession rws; + TInt err = rws.Connect(); + CleanupClosePushL(rws); + TEST(err==KErrNone); + + if (aEnableWindowSizeCache) + { + rws.EnableWindowSizeCacheL(); + } + + RWindowGroup wg(rws); + wg.Construct(0); + CleanupClosePushL(rws); + + // w1 State 0 + RWindow w1(rws); + w1.Construct(wg,1); + CleanupClosePushL(w1); + + // w1 State 0 + TSize size1 (10001,123); + w1.SetSize(size1); + rws.Flush(); + + // w1 State 1 + TSize retSize1 = w1.Size(); + TEST(retSize1 == size1); + + // w1 State 2 + TSize size2 (20002,223); + w1.SetSize(size2); + + // w1 State 2 + TPoint point3 (30303,232); + TSize size3 (30003,323); + err = w1.SetExtentErr(point3, size3); + TEST(KErrNone == err); + + // w1 State 1 + TSize retSize2 = w1.Size(); + TEST(retSize2 == size3); + + // w1 State Final + CleanupStack::Pop(); + w1.Close(); + + CleanupStack::Pop(); + wg.Close(); + + CleanupStack::Pop(); + rws.Close(); + + __UHEAP_MARKEND; + } + +void CTWindowSizeCacheTest::TestRWindowCacheEntryExistsCacheDirtyToCleanSetSizeEnableWindowSizeCacheL() + { + __UHEAP_MARK; + // w* State Initial + RWsSession rws; + TInt err = rws.Connect(); + CleanupClosePushL(rws); + TEST(err==KErrNone); + + rws.EnableWindowSizeCacheL(); + + RWindowGroup wg(rws); + wg.Construct(0); + CleanupClosePushL(rws); + + // w1 State 0 + RWindow w1(rws); + w1.Construct(wg,1); + CleanupClosePushL(w1); + + // w1 State 0 + TSize size1 (10001,123); + w1.SetSize(size1); + rws.Flush(); + + // w1 State 1 + TSize retSize1 = w1.Size(); + TEST(retSize1 == size1); + + // w1 State 2 + TSize size2 (20002,223); + w1.SetSize(size2); + + // Only the first call to EnableWindowSizeCacheL() should have an effect + // All subsequent calls to EnableWindowSizeCacheL() should have no effect + rws.EnableWindowSizeCacheL(); + + // w1 State 1 + TSize retSize2 = w1.Size(); + TEST(retSize2 == size2); + + // w1 State Final + CleanupStack::Pop(); + w1.Close(); + + CleanupStack::Pop(); + wg.Close(); + + CleanupStack::Pop(); + rws.Close(); + + __UHEAP_MARKEND; + } + +//------------------------------------------------------------------------------------------ + +void CTWindowSizeCacheTest::TestRBlankWindowSetSizeSetExtentL(TSizeCacheStatus aEnableWindowSizeCache) + { + __UHEAP_MARK; + // w* State Initial + RWsSession rws; + TInt err = rws.Connect(); + CleanupClosePushL(rws); + TEST(err==KErrNone); + + if (aEnableWindowSizeCache) + { + rws.EnableWindowSizeCacheL(); + } + + RWindowGroup wg(rws); + err = wg.Construct(0); + CleanupClosePushL(rws); + TEST(err==KErrNone); + + // w1 State 0 + RBlankWindow w1(rws); + err = w1.Construct(wg,1); + CleanupClosePushL(w1); + TEST(err==KErrNone); + + // w1 State 0 + TSize size1 (10001,123); + w1.SetSize(size1); + rws.Flush(); + + // w1 State 1 + TSize retSize1 = w1.Size(); + TEST(retSize1 == size1); + + // w1 State 2 + TSize size2 (20002,223); + w1.SetSize(size2); + + // w1 State 2 + TPoint point3 (30303,232); + TSize size3 (30003,323); + w1.SetExtent(point3, size3); + rws.Flush(); + + // w1 State 1 + TSize retSize2 = w1.Size(); + TEST(retSize2 == size3); + + // w1 State 2 + TSize size4 (40004,423); + w1.SetSize(size4); + + // w1 State 1 + TSize retSize3 = w1.Size(); + TEST(retSize3 == size4); + + // w1 State Final + CleanupStack::Pop(); + w1.Close(); + + CleanupStack::Pop(); + wg.Close(); + + CleanupStack::Pop(); + rws.Close(); + + __UHEAP_MARKEND; + } + +//------------------------------------------------------------------------------------------ + +void CTWindowSizeCacheTest::TestRBackedUpWindowSetSizeErrSetExtentErrL(TSizeCacheStatus aEnableWindowSizeCache) + { + __UHEAP_MARK; + // w* State Initial + RWsSession rws; + TInt err = rws.Connect(); + CleanupClosePushL(rws); + TEST(err==KErrNone); + + if (aEnableWindowSizeCache) + { + rws.EnableWindowSizeCacheL(); + } + + RWindowGroup wg(rws); + err = wg.Construct(0); + CleanupClosePushL(rws); + TEST(err==KErrNone); + + // w1 State 0 + RBlankWindow w1(rws); + err = w1.Construct(wg,1); + CleanupClosePushL(w1); + TEST(err==KErrNone); + + // w1 State 0 + TSize size1 (10001,123); + err = w1.SetSizeErr(size1); + TEST(err==KErrNone); + + // w1 State 1 + TSize retSize1 = w1.Size(); + TEST(retSize1 == size1); + + // w1 State 2 + TSize size2 (20002,223); + err = w1.SetSizeErr(size2); + TEST(err==KErrNone); + + // w1 State 2 + TPoint point3 (30303,232); + TSize size3 (30003,323); + err = w1.SetExtentErr(point3, size3); + TEST(err==KErrNone); + + // w1 State 1 + TSize retSize2 = w1.Size(); + TEST(retSize2 == size3); + + // w1 State 2 + TSize size4 (40004,423); + err = w1.SetSizeErr(size4); + TEST(err==KErrNone); + + // w1 State 1 + TSize retSize3 = w1.Size(); + TEST(retSize3 == size4); + + // w1 State Final + CleanupStack::Pop(); + w1.Close(); + + CleanupStack::Pop(); + wg.Close(); + + CleanupStack::Pop(); + rws.Close(); + + __UHEAP_MARKEND; + } + +//------------------------------------------------------------------------------------------ + +TUint64 CTWindowSizeCacheTest::TestRWindowSizePerformanceL(TSizeCacheStatus aEnableWindowSizeCache, TUint aIterations) + { + TUint64 timeDeltaMicroSeconds = 0; + + __UHEAP_MARK; + // w* State Initial + RWsSession rws; + TInt err = rws.Connect(); + TEST(KErrNone == err); + CleanupClosePushL(rws); + + if (ETestSizeCacheEnabled == aEnableWindowSizeCache) + { + rws.EnableWindowSizeCacheL(); + } + + RWindowGroup wg(rws); + err = wg.Construct(0); + TEST(KErrNone == err); + CleanupClosePushL(wg); + + // w1 State 0 + RWindow w1(rws); + err = w1.Construct(wg,1); + TEST(KErrNone == err); + CleanupClosePushL(w1); + + TSize size1 (10001,123); + w1.SetSize(size1); + + TTime start; + TTime end; + start.UniversalTime(); + for (TUint iter = 0; iter < aIterations; ++iter) + { + // w1 State 1 + TSize retSize1 = w1.Size(); + TEST(retSize1 == size1); + } + end.UniversalTime(); + + TTimeIntervalMicroSeconds delta = end.MicroSecondsFrom(start); + timeDeltaMicroSeconds = delta.Int64(); + INFO_PRINTF4(_L("TestRWindowSizePerformanceL - WindowSizeCacheEnabled %d, Iterations %d, Microseconds %Ld"), aEnableWindowSizeCache, aIterations, timeDeltaMicroSeconds); + + // w1 State Final + CleanupStack::Pop(); + w1.Close(); + + CleanupStack::Pop(); + wg.Close(); + + CleanupStack::Pop(); + rws.Close(); + + __UHEAP_MARKEND; + return timeDeltaMicroSeconds; + } + + +//------------------------------------------------------------------------------------------ +/* +Sets the random seed used by CTWindowSizeCacheTest::NextRandom. + */ +void CTWindowSizeCacheTest::SetRandomSeed(TInt64 aSeed) + { + INFO_PRINTF2(_L("Random Seed - %d"), aSeed); + iSeed = aSeed; + } + +/* +Performs an action on RWindow or RWsSession as specified by TRWindowAction aAction. +When the size of the window is changed, aExpectedSize is changed to the size we expect the window to be the next time RWindow::Size is called. +When RWindow::Size is called, we check the size returned matches aExpectedSize. +If aAction requests RWsSession::EnableWindowSizeCache, we call this if TSizeCacheStatus allows this. + +This function was designed for use with random stress tests, with a pseudo-random sequence driving TRWindowAction. + */ +void CTWindowSizeCacheTest::RWindowPerformAction(TRWindowAction aAction, TSizeCacheStatus aEnableWindowSizeCache, RWsSession& aWs, RWindow& aWindow, TSize& aExpectedSize) + { + switch (aAction) + { + case ESetExtent : + { + TPoint point(NextRandom(), NextRandom()); + aExpectedSize.iHeight = NextRandom(); + aExpectedSize.iWidth = NextRandom(); + aWindow.SetExtent(point, aExpectedSize); + aExpectedSize.iHeight = (aExpectedSize.iHeight < 0) ? 0 : aExpectedSize.iHeight; + aExpectedSize.iWidth = (aExpectedSize.iWidth < 0) ? 0 : aExpectedSize.iWidth; + } + break; + case ESetExtentErr : + { + TPoint point(NextRandom(), NextRandom()); + aExpectedSize.iHeight = NextRandom(); + aExpectedSize.iWidth = NextRandom(); + TInt err = aWindow.SetExtentErr(point, aExpectedSize); + TEST(KErrNone == err); + aExpectedSize.iHeight = (aExpectedSize.iHeight < 0) ? 0 : aExpectedSize.iHeight; + aExpectedSize.iWidth = (aExpectedSize.iWidth < 0) ? 0 : aExpectedSize.iWidth; + } + break; + case ESetSize : + { + aExpectedSize.iHeight = NextRandom(); + aExpectedSize.iWidth = NextRandom(); + aWindow.SetSize(aExpectedSize); + aExpectedSize.iHeight = (aExpectedSize.iHeight < 0) ? 0 : aExpectedSize.iHeight; + aExpectedSize.iWidth = (aExpectedSize.iWidth < 0) ? 0 : aExpectedSize.iWidth; + } + break; + case ESetSizeErr : + { + aExpectedSize.iHeight = NextRandom(); + aExpectedSize.iWidth = NextRandom(); + TInt err = aWindow.SetSizeErr(aExpectedSize); + TEST(KErrNone == err); + aExpectedSize.iHeight = (aExpectedSize.iHeight < 0) ? 0 : aExpectedSize.iHeight; + aExpectedSize.iWidth = (aExpectedSize.iWidth < 0) ? 0 : aExpectedSize.iWidth; + } + break; + case ECheckSize : + { + TSize retSize1 = aWindow.Size(); + TEST(retSize1 == aExpectedSize); + } + break; + case EFlushSession : + { + aWs.Flush(); + } + break; + case EEnableWindowSizeCache : + { + if (ETestSizeCacheEnabled == aEnableWindowSizeCache) + { + aWs.EnableWindowSizeCacheL(); + } + } + break; + default : + break; + } + } + +void CTWindowSizeCacheTest::TestRandomisedStressL(TSizeCacheStatus aEnableWindowSizeCache, TUint aIterations) + { + __UHEAP_MARK; + // w* State Initial + RWsSession rws; + TInt err = rws.Connect(); + TEST(KErrNone == err); + CleanupClosePushL(rws); + + if (aEnableWindowSizeCache) + { + rws.EnableWindowSizeCacheL(); + } + + RWindowGroup wg(rws); + err = wg.Construct(0); + TEST(KErrNone == err); + CleanupClosePushL(wg); + + // w1 State 0 + RWindow w1(rws); + err = w1.Construct(wg,1); + TEST(KErrNone == err); + CleanupClosePushL(w1); + + TSize size1 (10001,123); + w1.SetSize(size1); + + for (TUint iter = 0; iter < aIterations; ++iter) + { + TRWindowAction action = static_cast(NextRandom(EMaxAction)); + RWindowPerformAction(action, aEnableWindowSizeCache, rws, w1, size1); + } + + // w1 State Final + CleanupStack::Pop(); + w1.Close(); + + CleanupStack::Pop(); + wg.Close(); + + CleanupStack::Pop(); + rws.Close(); + __UHEAP_MARKEND; + } + +/* +TCleanupOperation for a window pool, implemented as RPointerArray. + */ +void CTWindowSizeCacheTest::CleanupWindowPool(TAny* aPtr) + { + RPointerArray windowPool = *(static_cast*>(aPtr)); + const TUint poolSize = windowPool.Count(); + // Note: ResetAndDestroy deletes referenced objects, so no need to delete items in loop + for (TUint iter = 0; iter < poolSize; ++iter) + { + windowPool[iter]->Close(); + } + windowPool.ResetAndDestroy(); + } + +void CTWindowSizeCacheTest::TestRandomisedStressMultiSessionL(TSizeCacheStatus aEnableWindowSizeCache, TUint aIterations) + { + __UHEAP_MARK; + // w* State Initial + RWsSession rws1; + TInt err = rws1.Connect(); + TEST(KErrNone == err); + CleanupClosePushL(rws1); + + // Multiple sessions in one thread + RWsSession rws2; + err = rws2.Connect(); + TEST(KErrNone == err); + CleanupClosePushL(rws2); + + RWindowGroup rws1_wg1(rws1); + err = rws1_wg1.Construct(0); + CleanupClosePushL(rws1_wg1); + TEST(KErrNone == err); + + RWindowGroup rws2_wg1(rws2); + err = rws2_wg1.Construct(0); + CleanupClosePushL(rws2_wg1); + TEST(KErrNone == err); + + // Multiple window groups in one session + RWindowGroup rws2_wg2(rws2); + err = rws2_wg2.Construct(1); + CleanupClosePushL(rws2_wg2); + TEST(KErrNone == err); + + // Window pool for all windows owned by session rws1 + RPointerArray rws1_windowPool; + CleanupStack::PushL(TCleanupItem(CleanupWindowPool,&rws1_windowPool)); + // Each window in window pool has a corresponding expected size at corresponding array index + RArray rws1_expectedSizePool; + CleanupClosePushL(rws1_expectedSizePool); + + // Window pool for all windows owned by session rws2 + RPointerArray rws2_windowPool; + CleanupStack::PushL(TCleanupItem(CleanupWindowPool,&rws2_windowPool)); + // Each window in window pool has a corresponding expected size at corresponding array index + RArray rws2_expectedSizePool; + CleanupClosePushL(rws2_expectedSizePool); + + // Populate window pool + const TUint KWindowCount_rws1_wg1 = 50; + const TUint KWindowCount_rws2_wg1 = 50; + const TUint KWindowCount_rws2_wg2 = 50; + + // Windows for session 1 belonging to rws1_wg1 + // Many windows - siblings + for (TUint iter = 0; iter < KWindowCount_rws1_wg1; ++iter) + { + RWindow* win = new (ELeave) RWindow(rws1); + CleanupStack::PushL(win); + TInt err = win->Construct(rws1_wg1,iter+1); + TEST(KErrNone == err); + rws1_windowPool.AppendL(win); + CleanupStack::Pop(win); + TSize expectedSize (NextRandom(),NextRandom()); + win->SetSize(expectedSize); + // Wserv flattens size to zero + expectedSize.iHeight = (expectedSize.iHeight < 0) ? 0 : expectedSize.iHeight; + expectedSize.iWidth = (expectedSize.iWidth < 0) ? 0 : expectedSize.iWidth; + rws1_expectedSizePool.AppendL(expectedSize); + TSize retSize1 = win->Size(); + TEST(retSize1 == expectedSize); + } + + // Windows for session 2 belonging to rws2_wg1 + // Many windows - siblings + for (TUint iter = 0; iter < KWindowCount_rws2_wg1; ++iter) + { + RWindow* win = new (ELeave) RWindow(rws2); + CleanupStack::PushL(win); + TInt err = win->Construct(rws2_wg1,iter+2); + TEST(KErrNone == err); + rws2_windowPool.AppendL(win); + CleanupStack::Pop(); + TSize expectedSize (NextRandom(),NextRandom()); + win->SetSize(expectedSize); + // Wserv flattens size to zero + expectedSize.iHeight = (expectedSize.iHeight < 0) ? 0 : expectedSize.iHeight; + expectedSize.iWidth = (expectedSize.iWidth < 0) ? 0 : expectedSize.iWidth; + rws2_expectedSizePool.AppendL(expectedSize); + TSize retSize1 = win->Size(); + TEST(retSize1 == expectedSize); + } + + // Windows for session 2 belonging to rws2_wg2 + // Many windows - children + RWindowTreeNode parent = rws2_wg2; + for (TUint iter = 0; iter < KWindowCount_rws2_wg2; ++iter) + { + RWindow* win = new (ELeave) RWindow(rws2); + CleanupStack::PushL(win); + TInt err = win->Construct(parent,KWindowCount_rws2_wg1+iter+2); + TEST(KErrNone == err); + parent = *win; + rws2_windowPool.AppendL(win); + CleanupStack::Pop(); + TSize expectedSize (NextRandom(),NextRandom()); + win->SetSize(expectedSize); + // Wserv flattens size to zero + expectedSize.iHeight = (expectedSize.iHeight < 0) ? 0 : expectedSize.iHeight; + expectedSize.iWidth = (expectedSize.iWidth < 0) ? 0 : expectedSize.iWidth; + rws2_expectedSizePool.AppendL(expectedSize); + TSize retSize1 = win->Size(); + TEST(retSize1 == expectedSize); + } + + // Stress system by performing actions on windows + for (TUint iter = 0; iter < aIterations; ++iter) + { + TRWindowAction action = static_cast(NextRandom(EMaxAction)); + TUint32 windowPool = NextRandom(2); + switch (windowPool) + { + case 0 : + { + TUint32 target = NextRandom(rws1_windowPool.Count()); + RWindowPerformAction(action, aEnableWindowSizeCache, rws1, *(rws1_windowPool[target]) , rws1_expectedSizePool[target]); + } + break; + case 1 : + { + TUint32 target = NextRandom(rws2_windowPool.Count()); + RWindowPerformAction(action, aEnableWindowSizeCache, rws2, *(rws2_windowPool[target]) , rws2_expectedSizePool[target]); + } + break; + default : + User::Invariant(); + } + } + + + // Cleanup afterwards + CleanupStack::Pop(9); + + CleanupWindowPool(&rws1_windowPool); + rws1_expectedSizePool.Close(); + rws1_wg1.Close(); + rws1.Close(); + + CleanupWindowPool(&rws2_windowPool); + rws2_expectedSizePool.Close(); + rws2_wg1.Close(); + rws2_wg2.Close(); + rws2.Close(); + } + +void CTWindowSizeCacheTest::TestRandomisedStressCacheEntryVolumeL(TSizeCacheStatus aEnableWindowSizeCache, TUint aIterations, TUint aWindowPoolSize) + { + __UHEAP_MARK; + // w* State Initial + RWsSession rws1; + TInt err = rws1.Connect(); + TEST(KErrNone == err); + CleanupClosePushL(rws1); + + if (aEnableWindowSizeCache) + { + rws1.EnableWindowSizeCacheL(); + } + + RWindowGroup rws1_wg1(rws1); + err = rws1_wg1.Construct(0); + TEST(KErrNone == err); + CleanupClosePushL(rws1_wg1); + + RPointerArray windowPool; + CleanupStack::PushL(TCleanupItem(CleanupWindowPool,&windowPool)); + // Each window in window pool has a corresponding expected size at corresponding array index + RArray expectedSizePool; + CleanupClosePushL(expectedSizePool); + + // Populate window pool + for (TUint iter = 0; iter < aWindowPoolSize; ++iter) + { + RWindow* win = new (ELeave) RWindow(rws1); + CleanupStack::PushL(win); + TInt err = win->Construct(rws1_wg1,iter+1); + TEST(KErrNone == err); + windowPool.AppendL(win); + CleanupStack::Pop(win); + + TSize expectedSize (NextRandom(),NextRandom()); + win->SetSize(expectedSize); + // Wserv flattens size to zero + expectedSize.iHeight = (expectedSize.iHeight < 0) ? 0 : expectedSize.iHeight; + expectedSize.iWidth = (expectedSize.iWidth < 0) ? 0 : expectedSize.iWidth; + expectedSizePool.AppendL(expectedSize); + TSize retSize1 = win->Size(); + TEST(retSize1 == expectedSize); + } + + // Stress system by performing actions on windows + for (TUint iter = 0; iter < aIterations; ++iter) + { + TRWindowAction action = static_cast(NextRandom(EMaxAction)); + TUint32 target = NextRandom(aWindowPoolSize); + RWindowPerformAction(action, aEnableWindowSizeCache, rws1, *(windowPool[target]), expectedSizePool[target]); + } + + // Cleanup afterwards + CleanupStack::Pop(4); + + CleanupWindowPool(&windowPool); + expectedSizePool.Close(); + rws1_wg1.Close(); + rws1.Close(); + + __UHEAP_MARKEND; + } + +//------------------------------------------------------------------------------------------ + +void CTWindowSizeCacheTest::TestStressEnableWindowSizeCacheL(TUint aIterations) + { + __UHEAP_MARK; + // w* State Initial + RWsSession rws; + TInt err = rws.Connect(); + CleanupClosePushL(rws); + TEST(err==KErrNone); + + // Only the first call to EnableWindowSizeCacheL() should have an effect + // All subsequent calls to EnableWindowSizeCacheL() should have no effect + for (TUint iter = 0; iter < aIterations; iter++) + { + rws.EnableWindowSizeCacheL(); + } + + RWindowGroup wg(rws); + wg.Construct(0); + CleanupClosePushL(rws); + + // w1 State 0 + RWindow w1(rws); + w1.Construct(wg,1); + CleanupClosePushL(w1); + + TSize size1 (10001,123); + w1.SetSize(size1); + + // w1 State 1 + TSize retSize1 = w1.Size(); + TEST(retSize1 == size1); + + // w1 State 2 + TSize size2 (20002,223); + w1.SetSize(size2); + + // w1 State 2 + // Only the first call to EnableWindowSizeCacheL() should have an effect + // All subsequent calls to EnableWindowSizeCacheL() should have no effect + for (TUint iter = 0; iter < aIterations; iter++) + { + rws.EnableWindowSizeCacheL(); + } + + // w1 State 1 + TSize retSize2 = w1.Size(); + TEST(retSize2 == size2); + + // w1 State Final + CleanupStack::Pop(); + w1.Close(); + + CleanupStack::Pop(); + wg.Close(); + + CleanupStack::Pop(); + rws.Close(); + + __UHEAP_MARKEND; + } + +/* +Tests 701-706 focus on window creation operating correctly, alternating use of the window size cache. +Tests 707-710 aim to cover state transitions for cache entries in the window size cache for RWindow. +Tests 711-712 performs basic verification of size related functionality for RBlankWindow and RBackedUpWindow. +Test 713 focusses on ensuring a performance gain is achieved with window size caching enabled. +Tests 714-720 aim to stress the window size cache with pseudo-random sequences of RWindow size related functions. + +The states in the state machine model used for testing the RWindow size cache in tests 707-710 is as follows: + +State: Initial + Window not yet in existence + +State 0: No Cache entry + Window created, window size cache does not contain an entry for this window + +State 1: Cache entry exists, cache clean + Window created, window size cache exists, contains a valid size + +State 2: Cache entry exists, cache dirty + Window created, window size cache exists, does not contain a valid size + +State: Final + Window destroyed + */ +void CTWindowSizeCacheTest::RunTestCaseL(TInt /*aCurTestCase*/) + { + _LIT(KTest1,"Create RWindow, window size cache off"); + _LIT(KTest2,"Create RWindow, window size cache on"); + _LIT(KTest3,"Create RBlankWindow, window size cache off"); + _LIT(KTest4,"Create RBlankWindow, window size cache on"); + _LIT(KTest5,"Create RBackedUpWindow, window size cache off"); + _LIT(KTest6,"Create RBackedUpWindow, window size cache on"); + + _LIT(KTest7,"RWindow - No cache entry"); + _LIT(KTest8,"RWindow - Cache entry exists, cache clean"); + _LIT(KTest9,"RWindow - Cache entry exists, cache dirty"); + _LIT(KTest10,"RWindow - Cache entry exists, cache dirty->clean"); + + _LIT(KTest11,"RBlankWindow size cache"); + _LIT(KTest12,"RBackedUpWindow size cache"); + + _LIT(KTest13,"RWindow Size Performance"); + _LIT(KTest14,"RWindow Randomised Stress window size cache off"); + _LIT(KTest15,"RWindow Randomised Stress window size cache on"); + _LIT(KTest16,"RWindow Randomised Stress MultiSession cache off"); + _LIT(KTest17,"RWindow Randomised Stress MultiSession cache on"); + _LIT(KTest18,"RWindow Randomised Stress Entry Volume cache off"); + _LIT(KTest19,"RWindow Randomised Stress Entry Volume cache on"); + _LIT(KTest20,"RWsSession stress EnableWindowSizeCacheL"); + + const TDisplayMode displayMode = EColor16MAP; + const TUint KPerformanceIterations = 50000; + const TUint KStressTestIterations = 3000; + const TUint KStressWindowPoolSize = 100; + + ((CTWindowSizeCacheTestStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + + switch(++iTest->iState) + { +/** +@SYMTestCaseID GRAPHICS-WSERV-0701 + +@SYMDEF DevCR BBRE-7UWGHL + +@SYMTestCaseDesc Test creation and destruction for instances of RWindow, window size cache off + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Creates an RWsSession, some RWindowGroup and RWindow instances, and closes them. + +@SYMTestExpectedResults Window objects created successfully, no memory leaks. +*/ + case 1: + ((CTWindowSizeCacheTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0701")); + iTest->LogSubTest(KTest1); + TestCreateRWindowL(ETestSizeCacheNotEnabled); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0702 + +@SYMDEF DevCR BBRE-7UWGHL + +@SYMTestCaseDesc Test creation and destruction for instances of RWindow, window size cache on + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Creates an RWsSession, enables window size cache, creates some RWindowGroup and RWindow instances, and closes them. + +@SYMTestExpectedResults Window objects created successfully, no memory leaks. +*/ + case 2: + ((CTWindowSizeCacheTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0702")); + iTest->LogSubTest(KTest2); + TestCreateRWindowL(ETestSizeCacheEnabled); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0703 + +@SYMDEF DevCR BBRE-7UWGHL + +@SYMTestCaseDesc Test creation and destruction for instances of RBlankWindow, window size cache off + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Creates an RWsSession, creates some RWindowGroup and RBlankWindow instances, and closes them. + +@SYMTestExpectedResults Window objects created successfully, no memory leaks. +*/ + case 3: + ((CTWindowSizeCacheTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0703")); + iTest->LogSubTest(KTest3); + TestCreateRBlankWindowL(ETestSizeCacheNotEnabled); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0704 + +@SYMDEF DevCR BBRE-7UWGHL + +@SYMTestCaseDesc Test creation and destruction for instances of RBlankWindow, window size cache on + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Creates an RWsSession, enables window size cache, creates some RWindowGroup and RBlankWindow instances, and closes them. + +@SYMTestExpectedResults Window objects created successfully, no memory leaks. +*/ + case 4: + ((CTWindowSizeCacheTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0704")); + iTest->LogSubTest(KTest4); + TestCreateRBlankWindowL(ETestSizeCacheEnabled); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0705 + +@SYMDEF DevCR BBRE-7UWGHL + +@SYMTestCaseDesc Test creation and destruction for instances of RBackedUpWindow, window size cache off + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Creates an RWsSession, creates some RWindowGroup and RBackedUpWindow instances, and closes them. + +@SYMTestExpectedResults Window objects created successfully, no memory leaks. +*/ + case 5: + ((CTWindowSizeCacheTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0705")); + iTest->LogSubTest(KTest5); + TestCreateRBackedUpWindowL(ETestSizeCacheNotEnabled, displayMode); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0706 + +@SYMDEF DevCR BBRE-7UWGHL + +@SYMTestCaseDesc Test creation and destruction for instances of RBackedUpWindow, window size cache on + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Creates an RWsSession, enables window size cache, creates some RWindowGroup and RBackedUpWindow instances, and closes them. + +@SYMTestExpectedResults Window objects created successfully, no memory leaks. +*/ + case 6: + ((CTWindowSizeCacheTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0706")); + iTest->LogSubTest(KTest6); + TestCreateRBackedUpWindowL(ETestSizeCacheEnabled, displayMode); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0707 + +@SYMDEF DevCR BBRE-7UWGHL + +@SYMTestCaseDesc Test RWindow size cache - State: No Cache Entry + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Perform the following with window size cache on and off: + Create RWsSession, creates RWindowGroup and RWindow. + Perform one of SetExtent/SetSize/SetExtentErr/SetSizeErr/EnableWindowSizeCacheL. + Clean up. + +@SYMTestExpectedResults Window objects created successfully, no memory leaks. +*/ + case 7: + ((CTWindowSizeCacheTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0707")); + iTest->LogSubTest(KTest7); + TestRWindowNoCacheEntryL(ETestSizeCacheNotEnabled); + TestRWindowNoCacheEntryL(ETestSizeCacheEnabled); + TestRWindowNoCacheEntrySetExtentErrL(ETestSizeCacheNotEnabled); + TestRWindowNoCacheEntrySetExtentErrL(ETestSizeCacheEnabled); + TestRWindowNoCacheEntrySetSizeErrL(ETestSizeCacheNotEnabled); + TestRWindowNoCacheEntrySetSizeErrL(ETestSizeCacheEnabled); + TestRWindowNoCacheEntrySetExtentL(ETestSizeCacheNotEnabled); + TestRWindowNoCacheEntrySetExtentL(ETestSizeCacheEnabled); + TestRWindowNoCacheEntrySetSizeL(ETestSizeCacheNotEnabled); + TestRWindowNoCacheEntrySetSizeL(ETestSizeCacheEnabled); + TestRWindowNoCacheEntryEnableWindowSizeCacheL(); + break; + +/** +@SYMTestCaseID GRAPHICS-WSERV-0708 + +@SYMDEF DevCR BBRE-7UWGHL + +@SYMTestCaseDesc Test RWindow size cache State: Cache entry exists, cache clean + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Perform the following with window size cache on and off: + Create RWsSession, creates RWindowGroup and RWindow, calls SetSize. + Perform one of Size/EnableWindowSizeCacheL. + Check that size returned matches expected size. + Clean up. + +@SYMTestExpectedResults Window objects created successfully, no memory leaks. +*/ + case 8: + ((CTWindowSizeCacheTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0708")); + iTest->LogSubTest(KTest8); + TestRWindowCacheEntryExistsCacheCleanL(ETestSizeCacheNotEnabled); + TestRWindowCacheEntryExistsCacheCleanL(ETestSizeCacheEnabled); + TestRWindowCacheEntryExistsCacheCleanSizeL(ETestSizeCacheNotEnabled); + TestRWindowCacheEntryExistsCacheCleanSizeL(ETestSizeCacheEnabled); + TestRWindowCacheEntryExistsCacheCleanEnableWindowSizeCacheL(); + TestRWindowCacheEntryExistsCacheCleanEnableWindowSizeCacheLSizeL(); + break; + +/** +@SYMTestCaseID GRAPHICS-WSERV-0709 + +@SYMDEF DevCR BBRE-7UWGHL + +@SYMTestCaseDesc Test RWindow size cache State: Cache entry exists, cache dirty + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Perform the following with window size cache on and off: + Create RWsSession, creates RWindowGroup and RWindow. + Calls SetSize, Size, then SetSize to enter state with dirty cache entry. + Perform combinations of SetSize/SetExtent/SetSizeErr/SetExtentErr/EnableWindowSizeCacheL. + Check that size returned matches the last size set on the window whenever size is queried. + Clean up. + +@SYMTestExpectedResults Window objects created successfully, no memory leaks. +*/ + case 9: + ((CTWindowSizeCacheTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0709")); + iTest->LogSubTest(KTest9); + TestRWindowCacheEntryExistsCacheDirtySetSizeL(ETestSizeCacheNotEnabled); + TestRWindowCacheEntryExistsCacheDirtySetSizeL(ETestSizeCacheEnabled); + TestRWindowCacheEntryExistsCacheDirtySetExtentL(ETestSizeCacheNotEnabled); + TestRWindowCacheEntryExistsCacheDirtySetExtentL(ETestSizeCacheEnabled); + TestRWindowCacheEntryExistsCacheDirtySetSizeErrL(ETestSizeCacheNotEnabled); + TestRWindowCacheEntryExistsCacheDirtySetSizeErrL(ETestSizeCacheEnabled); + TestRWindowCacheEntryExistsCacheDirtySetExtentErrL(ETestSizeCacheNotEnabled); + TestRWindowCacheEntryExistsCacheDirtySetExtentErrL(ETestSizeCacheEnabled); + TestRWindowCacheEntryExistsCacheDirtySetSizeTwiceL(ETestSizeCacheNotEnabled); + TestRWindowCacheEntryExistsCacheDirtySetSizeTwiceL(ETestSizeCacheEnabled); + TestRWindowCacheEntryExistsCacheDirtySetSizeSetExtentL(ETestSizeCacheNotEnabled); + TestRWindowCacheEntryExistsCacheDirtySetSizeSetExtentL(ETestSizeCacheEnabled); + TestRWindowCacheEntryExistsCacheDirtySetSizeSetSizeErrL(ETestSizeCacheNotEnabled); + TestRWindowCacheEntryExistsCacheDirtySetSizeSetSizeErrL(ETestSizeCacheEnabled); + TestRWindowCacheEntryExistsCacheDirtySetSizeSetExtentErrL(ETestSizeCacheNotEnabled); + TestRWindowCacheEntryExistsCacheDirtySetSizeSetExtentErrL(ETestSizeCacheEnabled); + TestRWindowCacheEntryExistsCacheDirtySetSizeEnableWindowSizeCacheL(); + break; + + +/** +@SYMTestCaseID GRAPHICS-WSERV-0710 + +@SYMDEF DevCR BBRE-7UWGHL + +@SYMTestCaseDesc Test RWindow size cache State: Cache entry exists, cache dirty -> State: Cache entry exists, cache clean + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Perform the following with window size cache on and off: + Create RWsSession, creates RWindowGroup and RWindow. + Calls SetSize, Size, to enter state with clean cache entry. + Perform combinations of SetSize/SetExtent/SetSizeErr/SetExtentErr/EnableWindowSizeCacheL to enter state with dirty cache entry. + Calls RWindow::Size to re-enter state with clean cache entry. + Check that size returned matches the last size set on the window whenever size is queried. + Clean up. + +@SYMTestExpectedResults Window objects created successfully, no memory leaks. +*/ + case 10: + ((CTWindowSizeCacheTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0710")); + iTest->LogSubTest(KTest10); + TestRWindowCacheEntryExistsCacheDirtyToCleanSetSizeL(ETestSizeCacheNotEnabled); + TestRWindowCacheEntryExistsCacheDirtyToCleanSetSizeL(ETestSizeCacheEnabled); + TestRWindowCacheEntryExistsCacheDirtyToCleanSetExtentL(ETestSizeCacheNotEnabled); + TestRWindowCacheEntryExistsCacheDirtyToCleanSetExtentL(ETestSizeCacheEnabled); + TestRWindowCacheEntryExistsCacheDirtyToCleanSetSizeErrL(ETestSizeCacheNotEnabled); + TestRWindowCacheEntryExistsCacheDirtyToCleanSetSizeErrL(ETestSizeCacheEnabled); + TestRWindowCacheEntryExistsCacheDirtyToCleanSetExtentErrL(ETestSizeCacheNotEnabled); + TestRWindowCacheEntryExistsCacheDirtyToCleanSetExtentErrL(ETestSizeCacheEnabled); + TestRWindowCacheEntryExistsCacheDirtyToCleanSetSizeTwiceL(ETestSizeCacheNotEnabled); + TestRWindowCacheEntryExistsCacheDirtyToCleanSetSizeTwiceL(ETestSizeCacheEnabled); + TestRWindowCacheEntryExistsCacheDirtyToCleanSetSizeSetExtentL(ETestSizeCacheNotEnabled); + TestRWindowCacheEntryExistsCacheDirtyToCleanSetSizeSetExtentL(ETestSizeCacheEnabled); + TestRWindowCacheEntryExistsCacheDirtyToCleanSetSizeSetSizeErrL(ETestSizeCacheNotEnabled); + TestRWindowCacheEntryExistsCacheDirtyToCleanSetSizeSetSizeErrL(ETestSizeCacheEnabled); + TestRWindowCacheEntryExistsCacheDirtyToCleanSetSizeSetExtentErrL(ETestSizeCacheNotEnabled); + TestRWindowCacheEntryExistsCacheDirtyToCleanSetSizeSetExtentErrL(ETestSizeCacheEnabled); + TestRWindowCacheEntryExistsCacheDirtyToCleanSetSizeEnableWindowSizeCacheL(); + break; + +/** +@SYMTestCaseID GRAPHICS-WSERV-0711 + +@SYMDEF DevCR BBRE-7UWGHL + +@SYMTestCaseDesc Test RBlankWindow Size cache behaviour + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Utilises RBlankWindow::SetSize, RBlankWindow::SetExtent, RBlankWindow::Size. + Checks size returned by RBlankWindow::Size. + Cleans up. + +@SYMTestExpectedResults Window objects created successfully, no memory leaks, size returned should be last size set on window +*/ + case 11: + ((CTWindowSizeCacheTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0711")); + iTest->LogSubTest(KTest11); + TestRBlankWindowSetSizeSetExtentL(ETestSizeCacheNotEnabled); + TestRBlankWindowSetSizeSetExtentL(ETestSizeCacheEnabled); + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0712 + +@SYMDEF DevCR BBRE-7UWGHL + +@SYMTestCaseDesc Test RBackedUpWindow Size cache behaviour + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Utilises RBackedUpWindow::SetSizeErr, RBackedUpWindow::SetExtentErr, RBackedUpWindow::Size. + Checks size returned by RBackedUpWindow::Size. + Cleans up. + +@SYMTestExpectedResults Window objects created successfully, no memory leaks, size returned should be last size set on window +*/ + case 12: + ((CTWindowSizeCacheTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0712")); + iTest->LogSubTest(KTest12); + TestRBackedUpWindowSetSizeErrSetExtentErrL(ETestSizeCacheNotEnabled); + TestRBackedUpWindowSetSizeErrSetExtentErrL(ETestSizeCacheEnabled); + break; + +/** +@SYMTestCaseID GRAPHICS-WSERV-0713 + +@SYMDEF DevCR BBRE-7UWGHL + +@SYMTestCaseDesc Compare performance of RWindow::Size function with size cache on and off + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Creates an RWsSession, optionally enables window size cache, creates an RWindowGroup and an RWindow + Calls RWindow::Size KPerformanceIterations times. + Measures time taken - with and without size cache enabled + +@SYMTestExpectedResults Window objects created successfully, no memory leaks, time taken for KPerformanceIterations RWindow::Size() calls with cache enabled should be faster. +*/ + case 13: + { + ((CTWindowSizeCacheTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0713")); + iTest->LogSubTest(KTest13); + TUint64 sizeCacheOffDeltaMicroSeconds = TestRWindowSizePerformanceL(ETestSizeCacheNotEnabled, KPerformanceIterations); + TUint64 sizeCacheOnDeltaMicroSeconds = TestRWindowSizePerformanceL(ETestSizeCacheEnabled, KPerformanceIterations); + TEST(sizeCacheOnDeltaMicroSeconds < sizeCacheOffDeltaMicroSeconds); + INFO_PRINTF1(_L("Accessing size using cache is faster")); + } + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0714 + +@SYMDEF DevCR BBRE-7UWGHL + +@SYMTestCaseDesc Randomised stress test - RWindow size related functions + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Creates an RWsSession, creates some RWindowGroup and RWindow instances, performs random size related actions, cleans up. + +@SYMTestExpectedResults Window objects created successfully, no memory leaks, size for each window matches last size set on window +*/ + case 14: + { + ((CTWindowSizeCacheTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0714")); + iTest->LogSubTest(KTest14); + TInt seed = Math::Random(); + // To replicate a test run, take the random seed from the test log and pass into SetRandomSeed + SetRandomSeed(seed); + TestRandomisedStressL(ETestSizeCacheNotEnabled, KStressTestIterations); + } + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0714 + +@SYMDEF DevCR BBRE-7UWGHL + +@SYMTestCaseDesc Randomised stress test - RWindow size related functions, size cache on + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Creates an RWsSession, enables window size cache, creates some RWindowGroup and RWindow instances, performs random size related actions, cleans up. + +@SYMTestExpectedResults Window objects created successfully, no memory leaks, size for each window matches last size set on window +*/ + case 15: + { + ((CTWindowSizeCacheTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0715")); + iTest->LogSubTest(KTest15); + TInt seed = Math::Random(); + // To replicate a test run, take the random seed from the test log and pass into SetRandomSeed + SetRandomSeed(seed); + TestRandomisedStressL(ETestSizeCacheEnabled, KStressTestIterations); + } + break; + + +/** +@SYMTestCaseID GRAPHICS-WSERV-0716 + +@SYMDEF DevCR BBRE-7UWGHL + +@SYMTestCaseDesc Randomised stress test - RWindow size related functions, multiple sessions + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Creates two RWsSession instances, creates some RWindowGroup and RWindow instances, performs random size related actions, cleans up. + +@SYMTestExpectedResults Window objects created successfully, no memory leaks, size for each window matches last size set on window +*/ + case 16: + { + ((CTWindowSizeCacheTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0716")); + iTest->LogSubTest(KTest16); + TInt seed = Math::Random(); + // To replicate a test run, take the random seed from the test log and pass into SetRandomSeed + SetRandomSeed(seed); + TestRandomisedStressMultiSessionL(ETestSizeCacheNotEnabled, KStressTestIterations); + } + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0717 + +@SYMDEF DevCR BBRE-7UWGHL + +@SYMTestCaseDesc Randomised stress test - RWindow size related functions, multiple sessions, size cache on + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Creates two RWsSession instances, enables window size cache, creates some RWindowGroup and RWindow instances, performs random size related actions, cleans up. + +@SYMTestExpectedResults Window objects created successfully, no memory leaks, size for each window matches last size set on window +*/ + case 17: + { + ((CTWindowSizeCacheTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0717")); + iTest->LogSubTest(KTest17); + TInt seed = Math::Random(); + // To replicate a test run, take the random seed from the test log and pass into SetRandomSeed + SetRandomSeed(seed); + TestRandomisedStressMultiSessionL(ETestSizeCacheEnabled, KStressTestIterations); + } + break; + +/** +@SYMTestCaseID GRAPHICS-WSERV-0718 + +@SYMDEF DevCR BBRE-7UWGHL + +@SYMTestCaseDesc Randomised stress test - RWindow size related functions, large number of windows + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Creates an RWsSession, creates some RWindowGroup and RWindow instances, performs random size related actions, cleans up. + +@SYMTestExpectedResults Window objects created successfully, no memory leaks, size for each window matches last size set on window +*/ + case 18: + { + ((CTWindowSizeCacheTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0718")); + iTest->LogSubTest(KTest18); + TInt seed = Math::Random(); + // To replicate a test run, take the random seed from the test log and pass into SetRandomSeed + SetRandomSeed(seed); + TestRandomisedStressCacheEntryVolumeL(ETestSizeCacheNotEnabled, KStressTestIterations, KStressWindowPoolSize); + } + break; +/** +@SYMTestCaseID GRAPHICS-WSERV-0719 + +@SYMDEF DevCR BBRE-7UWGHL + +@SYMTestCaseDesc Randomised stress test - RWindow size related functions, large number of windows + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Creates an RWsSession, enables window size cache, creates some RWindowGroup and RWindow instances, performs random size related actions, cleans up. + +@SYMTestExpectedResults Window objects created successfully, no memory leaks, size for each window matches last size set on window +*/ + case 19: + { + ((CTWindowSizeCacheTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0719")); + iTest->LogSubTest(KTest19); + TInt seed = Math::Random(); + // To replicate a test run, take the random seed from the test log and pass into SetRandomSeed + SetRandomSeed(seed); + TestRandomisedStressCacheEntryVolumeL(ETestSizeCacheEnabled, KStressTestIterations, KStressWindowPoolSize); + } + break; + +/** +@SYMTestCaseID GRAPHICS-WSERV-0720 + +@SYMDEF DevCR BBRE-7UWGHL + +@SYMTestCaseDesc Test RWsSession::EnableWindowSizeCacheL() API + +@SYMTestPriority High + +@SYMTestStatus Implemented + +@SYMTestActions Creates an RWsSession, calls EnableWindowSizeCacheL() multiple times, uses Size related APIs. + +@SYMTestExpectedResults No memory leaks. +*/ + case 20: + { + ((CTWindowSizeCacheTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0720")); + iTest->LogSubTest(KTest20); + TestStressEnableWindowSizeCacheL(KStressTestIterations); + } + break; + default: + ((CTWindowSizeCacheTestStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); + ((CTWindowSizeCacheTestStep*)iStep)->CloseTMSGraphicsStep(); + TestComplete(); + break; + } + ((CTWindowSizeCacheTestStep*)iStep)->RecordTestResultL(); + } + +__WS_CONSTRUCT_STEP__(WindowSizeCacheTest) diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/twindowsizecache.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/twindowsizecache.h Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,143 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef __TWINDOWSIZECACHE_H__ +#define __TWINDOWSIZECACHE_H__ + +#include +#include +#include "AUTO.H" + +#include "../nga/CLIENT/w32comm.h" + +#include "../tlib/testbase.h" +#include "TGraphicsHarness.h" + +//----------------------------------------------------------- +class CTWindowSizeCacheTest : public CTWsGraphicsBase + { +public: + enum TSizeCacheStatus + { + ETestSizeCacheNotEnabled, + ETestSizeCacheEnabled, + }; + enum TRWindowAction + { + ESetExtent, + ESetExtentErr, + ESetSize, + ESetSizeErr, + ECheckSize, + EFlushSession, + EEnableWindowSizeCache, + EMaxAction, + }; +public: + CTWindowSizeCacheTest(CTestStep* aStep); + ~CTWindowSizeCacheTest(); + TestState DoTestL(); + void ConstructL(); +// + void TestCreateRWindowL(TSizeCacheStatus aEnableWindowSizeCache); + void TestCreateRBlankWindowL(TSizeCacheStatus aEnableWindowSizeCache); + void TestCreateRBackedUpWindowL(TSizeCacheStatus aEnableWindowSizeCache, TDisplayMode aDisplayMode); +// + void TestRWindowNoCacheEntryL(TSizeCacheStatus aEnableWindowSizeCache); + void TestRWindowNoCacheEntrySetExtentErrL(TSizeCacheStatus aEnableWindowSizeCache); + void TestRWindowNoCacheEntrySetSizeErrL(TSizeCacheStatus aEnableWindowSizeCache); + void TestRWindowNoCacheEntrySetExtentL(TSizeCacheStatus aEnableWindowSizeCache); + void TestRWindowNoCacheEntrySetSizeL(TSizeCacheStatus aEnableWindowSizeCache); + void TestRWindowNoCacheEntryEnableWindowSizeCacheL(); +// + void TestRWindowCacheEntryExistsCacheCleanL(TSizeCacheStatus aEnableWindowSizeCache); + void TestRWindowCacheEntryExistsCacheCleanSizeL(TSizeCacheStatus aEnableWindowSizeCache); + void TestRWindowCacheEntryExistsCacheCleanEnableWindowSizeCacheL(); + void TestRWindowCacheEntryExistsCacheCleanEnableWindowSizeCacheLSizeL(); +// + void TestRWindowCacheEntryExistsCacheDirtySetSizeL(TSizeCacheStatus aEnableWindowSizeCache); + void TestRWindowCacheEntryExistsCacheDirtySetExtentL(TSizeCacheStatus aEnableWindowSizeCache); + void TestRWindowCacheEntryExistsCacheDirtySetSizeErrL(TSizeCacheStatus aEnableWindowSizeCache); + void TestRWindowCacheEntryExistsCacheDirtySetExtentErrL(TSizeCacheStatus aEnableWindowSizeCache); + void TestRWindowCacheEntryExistsCacheDirtySetSizeTwiceL(TSizeCacheStatus aEnableWindowSizeCache); + void TestRWindowCacheEntryExistsCacheDirtySetSizeSetExtentL(TSizeCacheStatus aEnableWindowSizeCache); + void TestRWindowCacheEntryExistsCacheDirtySetSizeSetSizeErrL(TSizeCacheStatus aEnableWindowSizeCache); + void TestRWindowCacheEntryExistsCacheDirtySetSizeSetExtentErrL(TSizeCacheStatus aEnableWindowSizeCache); + void TestRWindowCacheEntryExistsCacheDirtySetSizeEnableWindowSizeCacheL(); +// + void TestRWindowCacheEntryExistsCacheDirtyToCleanSetSizeL(TSizeCacheStatus aEnableWindowSizeCache); + void TestRWindowCacheEntryExistsCacheDirtyToCleanSetExtentL(TSizeCacheStatus aEnableWindowSizeCache); + void TestRWindowCacheEntryExistsCacheDirtyToCleanSetSizeErrL(TSizeCacheStatus aEnableWindowSizeCache); + void TestRWindowCacheEntryExistsCacheDirtyToCleanSetExtentErrL(TSizeCacheStatus aEnableWindowSizeCache); + void TestRWindowCacheEntryExistsCacheDirtyToCleanSetSizeTwiceL(TSizeCacheStatus aEnableWindowSizeCache); + void TestRWindowCacheEntryExistsCacheDirtyToCleanSetSizeSetExtentL(TSizeCacheStatus aEnableWindowSizeCache); + void TestRWindowCacheEntryExistsCacheDirtyToCleanSetSizeSetSizeErrL(TSizeCacheStatus aEnableWindowSizeCache); + void TestRWindowCacheEntryExistsCacheDirtyToCleanSetSizeSetExtentErrL(TSizeCacheStatus aEnableWindowSizeCache); + void TestRWindowCacheEntryExistsCacheDirtyToCleanSetSizeEnableWindowSizeCacheL(); +// + void TestRBlankWindowSetSizeSetExtentL(TSizeCacheStatus aEnableWindowSizeCache); + void TestRBackedUpWindowSetSizeErrSetExtentErrL(TSizeCacheStatus aEnableWindowSizeCache); +// + void SetRandomSeed(TInt64 aSeed); + inline TInt NextRandom(TUint aMax = 0); +// + TUint64 TestRWindowSizePerformanceL(TSizeCacheStatus aEnableWindowSizeCache, TUint aIterations); +// + static void CleanupWindowPool(TAny* aPtr); + void RWindowPerformAction(TRWindowAction aAction, TSizeCacheStatus aEnableWindowSizeCache, RWsSession& aWs, RWindow& aWindow, TSize& aExpectedSize); + void TestRandomisedStressL(TSizeCacheStatus aEnableWindowSizeCache, TUint aIterations); + void TestRandomisedStressMultiSessionL(TSizeCacheStatus aEnableWindowSizeCache, TUint aIterations); + void TestRandomisedStressCacheEntryVolumeL(TSizeCacheStatus aEnableWindowSizeCache, TUint aIterations, TUint aWindowPoolSize); + void TestStressEnableWindowSizeCacheL(TUint aIterations); + +protected: +//from CTGraphicsStep + virtual void RunTestCaseL(TInt aCurTestCase); + +private: + TInt64 iSeed; + }; + +//----------------------------------------------------------- +inline TInt CTWindowSizeCacheTest::NextRandom(TUint aMax) + { + TInt random = Math::Rand(iSeed); + if (aMax != 0) + { + random = random % aMax; + } + return random; + } + +//----------------------------------------------------------- +class CTWindowSizeCacheTestStep : public CTGraphicsStep + { +public: + CTWindowSizeCacheTestStep(); +protected: + //from CTGraphicsStep + virtual CTGraphicsBase* CreateTestL(); + }; + +_LIT(KTWindowSizeCacheTestStep,"TWindowSizeCacheTest"); + +//----------------------------------------------------------- +#endif // TWINDOWSIZECACHE diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tauto/wscons.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/wscons.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,113 @@ +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#include +#include + +NONSHARABLE_CLASS(CWsConsole) : public CConsoleBase + { +public: +// Pure virtuals from CConsoleBase + TInt Create(const TDesC& aTitle,TSize aSize); + void Read(TRequestStatus& aStatus); + void ReadCancel(); + void Write(const TDesC& aDes); + TPoint CursorPos() const; + void SetCursorPosAbs(const TPoint& aPoint); + void SetCursorPosRel(const TPoint& aPoint); + void SetCursorHeight(TInt aPercentage); + void SetTitle(const TDesC& aTitle); + void ClearScreen(); + void ClearToEndOfLine(); + TSize ScreenSize() const; + TKeyCode KeyCode() const; + TUint KeyModifiers() const; +private: + TRequestStatus* iStatus; + }; + +// +// CWsConsole +// + +TInt CWsConsole::Create(const TDesC&,TSize ) + { + return(KErrNone); + } + +void CWsConsole::Read(TRequestStatus& aStatus) + { + aStatus=KRequestPending; + iStatus=&aStatus; + User::RequestComplete(iStatus,KErrNone); + } + +void CWsConsole::ReadCancel() + { + User::RequestComplete(iStatus,KErrCancel); + } + +void CWsConsole::Write(const TDesC&) + { + } + +TPoint CWsConsole::CursorPos() const + { + return(TPoint()); + } + +void CWsConsole::SetCursorPosAbs(const TPoint&) + { + } + +void CWsConsole::SetCursorPosRel(const TPoint&) + { + } + +void CWsConsole::SetCursorHeight(TInt ) + { + } + +void CWsConsole::SetTitle(const TDesC&) + { + } + +void CWsConsole::ClearScreen() + { + } + +void CWsConsole::ClearToEndOfLine() + { + } + +TSize CWsConsole::ScreenSize() const + { + return(TSize(32,20)); + } + +TKeyCode CWsConsole::KeyCode() const + { + return(EKeyNull); + } + +TUint CWsConsole::KeyModifiers() const + { + return(0); + } + +EXPORT_C TAny* NewConsole() + { + return new CWsConsole; + } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tbufferdrawer/bufferdrawer.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tbufferdrawer/bufferdrawer.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,89 @@ +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include "bufferdrawer.h" +#include +#include +#include +#include +#include +#include +#include + + +// CWsGraphicDrawer +CWsBufferGraphicDrawer* CWsBufferGraphicDrawer::NewL() + { + return new(ELeave) CWsBufferGraphicDrawer; + } + +CWsBufferGraphicDrawer::~CWsBufferGraphicDrawer() + { + } + +void CWsBufferGraphicDrawer::ConstructL(MWsGraphicDrawerEnvironment& aEnv, const TGraphicDrawerId& aId, MWsClient& aOwner, const TDesC8& /*aData*/) + { + BaseConstructL(aEnv, aId, aOwner); + // default white line number + iWhiteLinePos = 0; + } + +void CWsBufferGraphicDrawer::HandleMessage(const TDesC8& aData) + { + TInt linePos = aData[0]; + DoUpdateWhiteLinePos(linePos); + } + +void CWsBufferGraphicDrawer::DoUpdateWhiteLinePos(TInt aWhiteLinePos) + { + iWhiteLinePos = aWhiteLinePos; + // Invalidate the redrawing + Invalidate(); + } + +void CWsBufferGraphicDrawer::DoDraw(MWsGc& aGc, const TRect& aRect, const TDesC8& /*aData*/) const + { + MWsGraphicsContext* context = static_cast(aGc.ResolveObjectInterface(KMWsGraphicsContext)); + + //Draw a filled rect with the chosen color + context->Push(); + context->SetBrushStyle(MWsGraphicsContext::ESolidBrush); + context->SetBrushColor(KRgbBlue); + context->DrawRect(aRect); + context->Pop(); + + //Obtain access to the screen/OSB buffer + MWsUiBuffer* buffer = static_cast(aGc.ResolveObjectInterface(KMWsUiBufferInterfaceId)); + TAny* data; + TInt stride; + + TInt err = buffer->MapReadWrite(data, stride); + + if (err == KErrNone) + { + //Fill the chosen line with white + TUint8* scanLine = static_cast(data); + scanLine += stride * iWhiteLinePos; + Mem::Fill(scanLine, stride, 0xFF); + + buffer->Unmap(); + } + } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tbufferdrawer/bufferdrawer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tbufferdrawer/bufferdrawer.h Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,54 @@ +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef BUFFERDRAWER_H_ +#define BUFFERDRAWER_H_ + +#include +#include +#include + +// A buffer drawer +NONSHARABLE_CLASS(CWsBufferGraphicDrawer): public CWsGraphicDrawer + { +public: + enum {EImplUid = 0x10285D54}; + +public: + static CWsBufferGraphicDrawer* NewL(); + virtual ~CWsBufferGraphicDrawer(); + // override CWsGraphicDrawer + virtual void ConstructL(MWsGraphicDrawerEnvironment& aEnv,const TGraphicDrawerId& aId, MWsClient& aOwner, const TDesC8& aData); + virtual void HandleMessage(const TDesC8& aData); + +protected: + // override CWsGraphicDrawer + virtual void DoDraw(MWsGc& aGc, const TRect& aRect, const TDesC8& aData) const; + +private: + void DoUpdateWhiteLinePos(TInt aWhiteLinePos); + +private: + TInt iWhiteLinePos; +}; + + +#endif /*BUFFERDRAWER_H_*/ diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tbufferdrawer/bufferdrawer.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tbufferdrawer/bufferdrawer.rss Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,45 @@ +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include + +RESOURCE REGISTRY_INFO registry_info + { + dll_uid = 0x10285D52; + interfaces = + { + INTERFACE_INFO + { + interface_uid = 0x10285D53; + implementations = + { + IMPLEMENTATION_INFO + { + implementation_uid = 0x10285D54; + version_no = 1; + display_name = "CWsBufferGraphicDrawer"; + default_data = ""; + opaque_data = ""; + } + }; + } + }; + } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tbufferdrawer/proxy.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tbufferdrawer/proxy.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,35 @@ +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include +#include "bufferdrawer.h" + + +LOCAL_C const TImplementationProxy KImplementationTable[] = + { + IMPLEMENTATION_PROXY_ENTRY(CWsBufferGraphicDrawer::EImplUid, CWsBufferGraphicDrawer::NewL), + }; + +EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) + { + aTableCount = sizeof(KImplementationTable)/sizeof(TImplementationProxy); + return KImplementationTable; + } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tbufferdrawer/wsbufferdrawer.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tbufferdrawer/wsbufferdrawer.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,97 @@ +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include "wsbufferdrawer.h" +#include + +CWsBufferGraphic::CWsBufferGraphic() + { + } + +EXPORT_C CWsBufferGraphic::~CWsBufferGraphic() + { + } + +EXPORT_C CWsBufferGraphic* CWsBufferGraphic::NewL() + { + CWsBufferGraphic* self = new(ELeave) CWsBufferGraphic; + CleanupStack::PushL(self); + self->BaseConstructL(KBufferDrawerImplId,KNullDesC8()); + CleanupStack::Pop(self); + return self; + } + +EXPORT_C CWsBufferGraphic* CWsBufferGraphic::NewL(TUid aUid) + { + CWsBufferGraphic* self = new(ELeave) CWsBufferGraphic; + CleanupStack::PushL(self); + self->BaseConstructL(aUid,KBufferDrawerImplId,KNullDesC8()); + CleanupStack::Pop(self); + return self; + } + +EXPORT_C CWsBufferGraphic* CWsBufferGraphic::NewL(const TWsGraphicId& aReplace) + { + CWsBufferGraphic* self = new(ELeave) CWsBufferGraphic; + CleanupStack::PushL(self); + self->BaseConstructL(aReplace,KBufferDrawerImplId,KNullDesC8()); + CleanupStack::Pop(self); + return self; + } + +EXPORT_C TInt CWsBufferGraphic::UpdateWhiteLinePos(TInt aWhiteLinePos) + { + // Send the message to server side + TBuf8<1> cmd; + cmd.Append(aWhiteLinePos); + + SendMessage(cmd); + return Flush(); + } + +EXPORT_C void CWsBufferGraphic::HandleMessage(const TDesC8& /*aData*/) + { + } + +EXPORT_C void CWsBufferGraphic::OnReplace() + { + } + +EXPORT_C TInt CWsBufferGraphic::ShareGlobally() + { + return CWsGraphic::ShareGlobally(); + } + +EXPORT_C TInt CWsBufferGraphic::UnShareGlobally() + { + return CWsGraphic::UnShareGlobally(); + } + +EXPORT_C TInt CWsBufferGraphic::Share(TSecureId aClientId) + { + return CWsGraphic::Share(aClientId); + } + +EXPORT_C TInt CWsBufferGraphic::UnShare(TSecureId aClientId) + { + return CWsGraphic::UnShare(aClientId); + } + diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tbufferdrawer/wsbufferdrawer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tbufferdrawer/wsbufferdrawer.h Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,55 @@ +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef WSBUFFERDRAWER_H_ +#define WSBUFFERDRAWER_H_ + + +#include +const TUid KBufferDrawerInterfaceId = {0x10285D53}; +const TUid KBufferDrawerImplId = {0x10285D54}; + +/** Client representation of a window-server-side drawing owned by this Client +@publishedAll +@released +*/ +NONSHARABLE_CLASS(CWsBufferGraphic): public CWsGraphic + { +public: + IMPORT_C static CWsBufferGraphic* NewL(); + IMPORT_C static CWsBufferGraphic* NewL(TUid aUid); + IMPORT_C static CWsBufferGraphic* NewL(const TWsGraphicId& aReplace); + IMPORT_C ~CWsBufferGraphic(); + IMPORT_C TInt UpdateWhiteLinePos(TInt aWhiteLinePos); + +public: // protected virtuals from CWsGraphic promoted to public + IMPORT_C TInt ShareGlobally(); + IMPORT_C TInt UnShareGlobally(); + IMPORT_C TInt Share(TSecureId aClientId); + IMPORT_C TInt UnShare(TSecureId aClientId); + +public: + CWsBufferGraphic(); + void HandleMessage(const TDesC8& aData); + void OnReplace(); +}; + +#endif /*WSBUFFERDRAWER_H_*/ diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tcapability/TCapTest.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tcapability/TCapTest.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,745 @@ +// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Automatically test the window server capabilities. +// +// + +#include +#include "W32STD.H" +#include "../../SERVER/w32cmd.h" +#include +#include +#include + +typedef TInt (*TPanicFunction)(TInt aInt,TDes& capability,TInt aExternalGroupId); +LOCAL_D const TUint KPanicThreadHeapSize=0x2000; +#define EWindowGroupHandle 1234 +#define EWindowGroupHandle2 4567 +_LIT(KCAPABILITY_ALL,"CAPABILITY_ALL"); +_LIT(KCAPABILITY_NONE,"CAPABILITY_NONE"); +_LIT(KWRITEDATA_SWEVENT,"WRITEDATA+SWEVENT"); +_LIT(KWRITEDATA_POWERMGMT,"WRITEDATA+POWERMGMT"); +_LIT(KPOWERMGMT_SWEVENT,"POWERMGMT+SWEVENT"); +_LIT(KSetOrdinalPositionPri,"EWsWinOpSetOrdinalPositionPri Capability Check"); +_LIT(KSetOrdinalPositionErr,"EWsWinOpSetOrdinalPositionErr Capability Check"); +TLogMessageText LogMessageText; + +//Enum for indicating which capability is checked. +enum TTestCapability + { + EWriteDeviceData, + ESwEvent, + EPowerMgmt, + EDoNotTest, + ENoCapReq, + EEikSrvSID, + ESwEventPri, + ENoSwEventPri, + ENoSwEventPriSmallOrdinal, + ESwEventErr, + ENoSwEventErr, + ENoSwEventErrSmallOrdinal, + }; + +//Enum for test exit reasons +enum TTestState + { + EWsExitReasonBad, + EWsTestNext, + EWsTestFinished, + }; + + +TTestCapability gTheTestCapability; +TInt gTestState=KErrNone; + + +//Panics if EWsExitReasonBad +enum TAutoPanics + { + EAutoPanicPanicFailed, + }; + +//Thread function structure +struct SPanicParams + { + TInt num; + TPanicFunction func; + TBuf<256> capability; + TInt externalGroupId; + }; + +class CTestBase + { +public: + CTestBase(); + ~CTestBase(); + void ConstructL(const TDes* aCapabilityTest); + TInt TestWsPanicL(TPanicFunction aFunction, TInt aInt, const TDes& aCommandLine); + void UpdateLogsL(); +private : + TInt TestPanicL(SPanicParams* aPtr); + TInt LaunchPanicThread(RThread& aThread, SPanicParams* aPtr); + void Test(TInt aCondition); +private : + TInt iThreadNumber; + RWsSession iWs; + TBuf<256> iCapabilityTest; + TInt iTestCount; + TInt iTestPass; + }; + +//RWsSession derived class to test the EWservMessShutdown message +class RShellWsSession : public RWsSession + { +public: + void ShutDown(); + }; + +void RShellWsSession::ShutDown() + { + SendReceive(EWservMessShutdown,TIpcArgs(EWservShutdownCheck)); + } + +LOCAL_C TInt PanicThreadFunc(TAny* aPtr) + { + CTrapCleanup* CleanUpStack=CTrapCleanup::New(); + SPanicParams* ptr=(SPanicParams*)aPtr; + TInt ret; + TRAP(ret,ret=(*ptr->func)(ptr->num,ptr->capability,ptr->externalGroupId)); + delete CleanUpStack; + if (ret==EWsExitReasonBad) + { + User::Panic(_L("Auto"),EAutoPanicPanicFailed); + } + return(ret); + } + +CTestBase::CTestBase() + { + } + +CTestBase::~CTestBase() + { + iWs.Close(); + } + +void CTestBase::ConstructL(const TDes* aCapabilityTest) + { + iTestCount=iTestPass=0; + iWs.Connect(); + TLex lex(*aCapabilityTest); + TPtrC capability = lex.NextToken(); + iCapabilityTest.Append(capability); + } + +TInt CTestBase::LaunchPanicThread(RThread& aThread, SPanicParams* aPtr) + { + TBuf<32> threadName; + _LIT(KPanicThread, "AutoPanicThread%d"); + threadName.AppendFormat(KPanicThread,iThreadNumber++); + return(aThread.Create(threadName,PanicThreadFunc,KDefaultStackSize,KPanicThreadHeapSize,KPanicThreadHeapSize,aPtr,EOwnerThread)); + } + +TInt CTestBase::TestPanicL(SPanicParams* aPtr) + { + RThread thread; + TRequestStatus stat; + TInt err=LaunchPanicThread(thread, aPtr); + if (err==KErrAlreadyExists) + { + // wait for kernel to clear up old threads + // and have several attempts at starting the thread + // if unsuccessful the first time + for (TInt i=0;i<3;i++) + { + User::After(TTimeIntervalMicroSeconds32(100000)); //0.1 secs + err=LaunchPanicThread(thread, aPtr); + if (err!=KErrAlreadyExists) + { + break; + } + } + } + User::LeaveIfError(err); + thread.Logon(stat); + User::SetJustInTime(EFalse); + thread.Resume(); + User::WaitForRequest(stat); + User::SetJustInTime(ETrue); + TInt threadExit=thread.ExitReason(); + if (threadExit!=EWsTestFinished) + { + if (gTheTestCapability==ENoCapReq) + { + Test(threadExit==KErrNone); + } + else if(gTheTestCapability==EEikSrvSID) + { + Test(threadExit==KErrPermissionDenied); + } + else if(!iCapabilityTest.Compare(KCAPABILITY_ALL)) + { + if(gTheTestCapability!=EDoNotTest) + { + iTestCount++; + if(gTheTestCapability==ESwEventPri) + { + Test(threadExit==KPasswordWindowGroupPriority); + } + else + { + Test(threadExit==KErrNone); + } + } + } + else if(!iCapabilityTest.Compare(KCAPABILITY_NONE)) + { + if(gTheTestCapability!=EDoNotTest) + { + iTestCount++; + if((gTheTestCapability==ENoSwEventPriSmallOrdinal)||(gTheTestCapability==ENoSwEventPri)) + { + Test(threadExit==KPasswordWindowGroupPriority-1); + } + else if(gTheTestCapability==ENoSwEventErrSmallOrdinal) + { + Test(threadExit==KErrNone); + } + else if(gTheTestCapability==ENoSwEventErr) + { + Test(threadExit==KErrPermissionDenied); + } + else + { + Test((threadExit==EWservPanicPermissionDenied)||(threadExit==KErrPermissionDenied)); + } + } + } + else if(!iCapabilityTest.Compare(KWRITEDATA_SWEVENT)) + { + if(gTheTestCapability==EWriteDeviceData || gTheTestCapability==ESwEvent) + { + iTestCount++; + Test(threadExit==KErrNone); + } + if(gTheTestCapability==EPowerMgmt) + { + iTestCount++; + Test((threadExit==EWservPanicPermissionDenied)||(threadExit==KErrPermissionDenied)); + } + } + else if(!iCapabilityTest.Compare(KWRITEDATA_POWERMGMT)) + { + if(gTheTestCapability==EWriteDeviceData || gTheTestCapability==EPowerMgmt) + { + iTestCount++; + Test(threadExit==KErrNone); + } + if(gTheTestCapability==ESwEvent) + { + iTestCount++; + Test((threadExit==EWservPanicPermissionDenied)||(threadExit==KErrPermissionDenied)); + } + } + else if(!iCapabilityTest.Compare(KPOWERMGMT_SWEVENT)) + { + if(gTheTestCapability==EPowerMgmt || gTheTestCapability==ESwEvent) + { + iTestCount++; + Test(threadExit==KErrNone); + } + if(gTheTestCapability==EWriteDeviceData) + { + iTestCount++; + Test((threadExit==EWservPanicPermissionDenied)||(threadExit==KErrPermissionDenied)); + } + } + } + thread.Close(); + return(threadExit); + } + +TInt CTestBase::TestWsPanicL(TPanicFunction aFunction,TInt aTestNo, const TDes& aCommandLine) + { + TLex lex(aCommandLine); + TPtrC capability = lex.NextToken(); + TPtrC idstr = lex.NextToken(); + lex = idstr; + TInt id = 0; + lex.Val(id); + + SPanicParams params; + params.num=aTestNo; + params.func=aFunction; + params.capability.Copy(capability); + params.externalGroupId = id; + return TestPanicL(¶ms); + } + +void CTestBase::Test(TInt aCondition) + { + if(!aCondition) + { + TLogMessageText buf; + _LIT(Fail,"AUTO Failed in Capability Test : "); + buf.Append(Fail); + buf.Append(iCapabilityTest); + iWs.LogMessage(buf); + iWs.Flush(); + } + else + { + iTestPass++; + } + } + +void CTestBase::UpdateLogsL() + { + TBuf<256> testResult; + RFs fileSession; + RFile resultFile; + User::LeaveIfError(fileSession.Connect()); + CleanupClosePushL(fileSession); + resultFile.Replace(fileSession,_L("C:\\DATA\\TestResult.Dat"),EFileWrite); + CleanupClosePushL(resultFile); + TFileText fileText; + fileText.Set(resultFile); + testResult.Num(iTestCount); + fileText.Write(testResult); + testResult.Num(iTestPass); + fileText.Write(testResult); + resultFile.Close(); + fileSession.Close(); + CleanupStack::PopAndDestroy(&resultFile); + CleanupStack::PopAndDestroy(&fileSession); + } + +TInt TestCapability(TInt aTest, TDes& aCapability, TInt aExternalGroupId) + { + _LIT(KDllName,"CLICK"); + RWsSession ws; + ws.Connect(); + CleanupClosePushL(ws); + RWindowGroup gr1(ws); + RWindowGroup gr2(ws); + gr1.Construct(EWindowGroupHandle,EFalse); + gr2.Construct(EWindowGroupHandle2,EFalse); + CleanupClosePushL(gr1); + CleanupClosePushL(gr2); + TWsEvent event; + RSoundPlugIn click1(ws); + CWsScreenDevice *screenDevice; + TRawEvent rawEvent; + CPalette* defPalette=CPalette::NewDefaultL(EColor256); + TInt ret=KErrNone; + switch(aTest) + { + case 0: + // ws.LogMessage(_L("EWsClOpSetKeyboardRepeatRate Capability Check")); + gTheTestCapability=EWriteDeviceData; + ret=ws.SetKeyboardRepeatRate(TTimeIntervalMicroSeconds32(1000000), TTimeIntervalMicroSeconds32(500000)); + ws.Flush(); + break; + case 1: + // ws.LogMessage(_L("EWsClOpSetDoubleClick Capability Check")); + gTheTestCapability=EWriteDeviceData; + ret=ws.SetDoubleClick(TTimeIntervalMicroSeconds32(900000),10); + ws.Flush(); + break; + case 2: + // ws.LogMessage(_L("EWsClOpSendEventToWindowGroup (external group) Capability Check")); + gTheTestCapability=ESwEvent; + event.SetType(EEventModifiersChanged); + ret=ws.SendEventToWindowGroup(aExternalGroupId,event); + break; + case 3: + // ws.LogMessage(_L("EWsClOpSendEventToAllWindowGroup Capability Check")); + gTheTestCapability=ESwEvent; + event.SetType(EEventModifiersChanged); + ret=ws.SendEventToAllWindowGroups(event); + break; + case 4: + // ws.LogMessage(_L("EWsClOpSendEventToAllWindowGroupPriority Capability Check")); + gTheTestCapability=ESwEvent; + event.SetType(EEventModifiersChanged); + gr1.SetOrdinalPosition(0,1); + ret=ws.SendEventToAllWindowGroups(gr1.OrdinalPriority(),event); + break; + case 5: + // ws.LogMessage(_L("EWsClOpSendEventToOneWindowGroupPerClient Capability Check")); + gTheTestCapability=ESwEvent; + event.SetType(EEventModifiersChanged); + ret=ws.SendEventToOneWindowGroupsPerClient(event); + break; + case 6: + // ws.LogMessage(_L("EWsClOpSendMessageToWindowGroup (external group) Capability Check")); + gTheTestCapability=ESwEvent; + ret=ws.SendMessageToWindowGroup(aExternalGroupId,TUid::Uid(123),_L8("SomeParams")); + break; + case 7: + // ws.LogMessage(_L("EWsClOpClaimSystemPointerCursorList Capability Check")); + gTheTestCapability=EWriteDeviceData; + ret=ws.ClaimSystemPointerCursorList(); + //This may return KErrInUse if succeeds. + if(ret==KErrInUse) + { + ret=KErrNone; + } + break; + case 8: + // ws.LogMessage(_L("EWsClOpSetClientCursorMode Capability Check")); + gTheTestCapability=EWriteDeviceData; + ret=ws.SetClientCursorMode(EPointerCursorNone); + ws.Flush(); + break; + case 9: + //Check only if capability is not defined,since the windowgroup is not focused. + if(aCapability.Compare(KCAPABILITY_ALL)&&aCapability.Compare(KWRITEDATA_POWERMGMT)&&aCapability.Compare(KWRITEDATA_SWEVENT)) + { + // ws.LogMessage(_L("EWsClOpSetPointerCursorPosition Capability Check")); + gTheTestCapability=EWriteDeviceData; + ret=ws.SetPointerCursorPosition(TPoint(60,20)); + ws.Flush(); + } + else + { + gTheTestCapability=EDoNotTest; + } + break; + case 10: + // ws.LogMessage(_L("EWsClOpSetModifierState Capability Check")); + gTheTestCapability=EWriteDeviceData; + ret=ws.SetModifierState(EModifierCapsLock,ETurnOnModifier); + ret=ws.SetModifierState(EModifierCapsLock,ETurnOffModifier); + ws.Flush(); + break; + case 11: + { + // ws.LogMessage(_L("EWsClOpRawEvent Capability Check")); + gTheTestCapability=ESwEvent; + rawEvent.Set(TRawEvent::EActive); + ws.SimulateRawEvent(rawEvent); + ws.Flush(); + } + break; + case 12: + { + // ws.LogMessage(_L("EWsClOpKeyEvent Capability Check")); + gTheTestCapability=ESwEvent; + TKeyEvent keyEvent; + keyEvent.iCode='J'; + keyEvent.iScanCode=0; + keyEvent.iModifiers=EModifierAutorepeatable; + keyEvent.iRepeats=0; + ws.SimulateKeyEvent(keyEvent); + ws.Flush(); + } + break; + case 13: + // ws.LogMessage(_L("EWsClOpSendOffEventsToShell Capability Check")); + gTheTestCapability=EPowerMgmt; + ret=ws.RequestOffEvents(EFalse); + break; + case 14: + // ws.LogMessage(_L("EWsClOpSetFaded Capability Check")); + gTheTestCapability=EWriteDeviceData; + ret=ws.SetSystemFaded(EFalse); + break; + case 15: + //Since there is some problem in running the EWsClOpNoFlickerFree + //code this test is not run if WriteDeviceData capability is defined. + // ws.LogMessage(_L("EWsClOpNoFlickerFree Capability Check")); + if(aCapability.Compare(KCAPABILITY_ALL)&&aCapability.Compare(KWRITEDATA_POWERMGMT)&&aCapability.Compare(KWRITEDATA_SWEVENT)) + { + CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws); + gTheTestCapability=EWriteDeviceData; + TInt err; + if ((err=screen->Construct(0))!=KErrNone) + { + delete screen; + User::Leave(err); + } + ws.TestWrite(ws.WsHandle(), EWsClOpNoFlickerFree, NULL, 0); + ws.Flush(); + delete screen; + } + else + { + gTheTestCapability=EDoNotTest; + } + break; + case 16: + // ws.LogMessage(_L("EWsClOpSetFocusScreen Capability Check")); + gTheTestCapability=EWriteDeviceData; + ret=ws.SetFocusScreen(0); + break; + case 17: + { + //Check only if capability is not defined. Otherwise it will shut down the shell. + if(aCapability.Compare(KCAPABILITY_ALL)&&aCapability.Compare(KWRITEDATA_POWERMGMT)&&aCapability.Compare(KPOWERMGMT_SWEVENT)) + { + // ws.LogMessage(_L("EWservMessShutdown Capability Check")); + gTheTestCapability=EPowerMgmt; + RShellWsSession wsShell; + wsShell.Connect(); + wsShell.ShutDown(); + } + else + { + gTheTestCapability=EDoNotTest; + } + break; + } + case 18: + // ws.LogMessage(_L("EWsWinOpCaptureKey Capability Check")); + gTheTestCapability=ESwEvent; + ret=gr2.CaptureKey('a',EModifierFunc,EModifierFunc); + //If the function succeeds capability check,the ret value is handle identifying the capture key. + if(ret>0) + { + ret=KErrNone; + } + break; + case 19: + // ws.LogMessage(_L("EWsWinOpCaptureKeyUpsAndDowns Capability Check")); + gTheTestCapability=ESwEvent; + ret=gr2.CaptureKeyUpAndDowns('a',0,0); + //If the function succeeds capability check,the ret value is handle identifying the capture key. + if(ret>0) + { + ret=KErrNone; + } + break; + case 20: + // ws.LogMessage(_L("EWsWinOpCaptureLongKey Capability Check")); + gTheTestCapability=ESwEvent; + ret=gr2.CaptureLongKey(EKeyEscape,'e',0,0,2,ELongCaptureNormal|ELongCaptureRepeatEvents); + //If the function succeeds capability check,the ret value is handle identifying the capture key. + if(ret>0) + { + ret=KErrNone; + } + break; + case 21: + // ws.LogMessage(_L("EWsClickOpLoad Capability Check")); + gTheTestCapability=EWriteDeviceData; + click1.Construct(); + CleanupClosePushL(click1); + ret=click1.Load(KDllName); + CleanupStack::PopAndDestroy(&click1); + break; + case 22: + // ws.LogMessage(_L("EWsClickOpUnLoad Capability Check")); + gTheTestCapability=EWriteDeviceData; + click1.Construct(); + ret=click1.Unload(); + break; + case 23: + // ws.LogMessage(_L("EWsSdOpSetScreenMode Capability Check")); + gTheTestCapability=EWriteDeviceData; + screenDevice=new(ELeave) CWsScreenDevice(ws); + CleanupStack::PushL(screenDevice); + screenDevice->Construct(0); + screenDevice->SetScreenMode(0); + CleanupStack::PopAndDestroy(screenDevice); + break; + case 24: + // ws.LogMessage(_L("EWsSdOpSetScreenModeEnforcement Capability Check")); + gTheTestCapability=EWriteDeviceData; + screenDevice=new(ELeave) CWsScreenDevice(ws); + CleanupStack::PushL(screenDevice); + screenDevice->Construct(0); + screenDevice->SetScreenModeEnforcement(ESizeEnforcementNone); + ws.Flush(); + CleanupStack::PopAndDestroy(screenDevice); + break; + case 25: + { + // ws.LogMessage(_L("EWsSdOpSetPalette Capability Check")); + gTheTestCapability=EWriteDeviceData; + screenDevice=new(ELeave) CWsScreenDevice(ws); + CleanupStack::PushL(screenDevice); + screenDevice->Construct(0); + ret=screenDevice->SetCustomPalette(defPalette); + //Returns KErrNotSupported if succeeds capability check. + if(ret==KErrNotSupported) + { + ret=KErrNone; + } + CleanupStack::PopAndDestroy(screenDevice); + } + break; + case 26: + { + //Checking the capability for SetHotKeys + // ws.LogMessage(_L("EWsClOpSetHotKey Capability Check")); + gTheTestCapability=ESwEvent; + ret=ws.SetHotKey(EHotKeyEnableLogging,'e',EModifierFunc|EModifierCtrl|EModifierShift,0); + ws.Flush(); + } + break; + case 27: + { + //Checking the capability for ClearHotKeys + // ws.LogMessage(_L("EWsClOpClearHotKeys Capability Check")); + gTheTestCapability=ESwEvent; + ret=ws.ClearHotKeys(EHotKeyEnableLogging); + ws.Flush(); + } + break; + case 28: + // ws.LogMessage(_L("EWsClOpSendEventToWindowGroup (own group) Capability Check")); + gTheTestCapability=ENoCapReq; + event.SetType(EEventModifiersChanged); + ret=ws.SendEventToWindowGroup(gr1.Identifier(),event); + break; + case 29: + // ws.LogMessage(_L("EWsClOpSendMessageToWindowGroup (own group) Capability Check")); + gTheTestCapability=ENoCapReq; + ret=ws.SendMessageToWindowGroup(gr1.Identifier(),TUid::Uid(123),_L8("SomeParams")); + break; + case 30: + // ws.LogMessage(_L("EWsClOpSetBackLight Capability Check")); + gTheTestCapability=EEikSrvSID; + screenDevice=new(ELeave) CWsScreenDevice(ws); + CleanupStack::PushL(screenDevice); + screenDevice->Construct(0); + ret=screenDevice->SetBackLight(ETrue); //Always returns KErrPermissionDenied. + CleanupStack::PopAndDestroy(screenDevice); + break; + case 31: + { + TBool test=EFalse; + if(!aCapability.Compare(KCAPABILITY_ALL)) + { + gTheTestCapability=ESwEventPri; + test=ETrue; + } + else if(!aCapability.Compare(KCAPABILITY_NONE)) + { + gTheTestCapability=ENoSwEventPri; + test=ETrue; + } + else + { + gTheTestCapability=EDoNotTest; + } + if(test) + { + LogMessageText.Format(KSetOrdinalPositionPri); + ws.LogMessage(LogMessageText); + gr1.SetOrdinalPosition(0,KPasswordWindowGroupPriority); + ret=ws.GetWindowGroupOrdinalPriority(gr1.Identifier()); + } + } + break; + case 32: + if(!aCapability.Compare(KCAPABILITY_NONE)) + { + LogMessageText.Format(KSetOrdinalPositionPri); + ws.LogMessage(LogMessageText); + gTheTestCapability=ENoSwEventPriSmallOrdinal; + gr1.SetOrdinalPosition(0,KPasswordWindowGroupPriority-1); + ret=ws.GetWindowGroupOrdinalPriority(gr1.Identifier()); + } + else + { + gTheTestCapability=EDoNotTest; + } + break; + case 33: + { + TBool test=EFalse; + if(!aCapability.Compare(KCAPABILITY_ALL)) + { + gTheTestCapability=ESwEventErr; + test=ETrue; + } + else if(!aCapability.Compare(KCAPABILITY_NONE)) + { + gTheTestCapability=ENoSwEventErr; + test=ETrue; + } + else + { + gTheTestCapability=EDoNotTest; + } + if(test) + { + LogMessageText.Format(KSetOrdinalPositionErr); + ws.LogMessage(LogMessageText); + ret=gr1.SetOrdinalPositionErr(0,KPasswordWindowGroupPriority); + } + } + break; + case 34: + if(!aCapability.Compare(KCAPABILITY_NONE)) + { + LogMessageText.Format(KSetOrdinalPositionErr); + ws.LogMessage(LogMessageText); + gTheTestCapability=ENoSwEventErrSmallOrdinal; + ret=gr1.SetOrdinalPositionErr(0,KPasswordWindowGroupPriority-1); + } + else + { + gTheTestCapability=EDoNotTest; + } + break; + case 35: + // EWsClOpSetCloseProximityThresholds Capability Check + gTheTestCapability=EWriteDeviceData; + ret=ws.SetCloseProximityThresholds(-20, -50); + ws.SetCloseProximityThresholds(KMaxTInt, KMinTInt); + break; + case 36: + // EWsClOpSetHighPressureThresholds Capability Check + gTheTestCapability=EWriteDeviceData; + ret=ws.SetHighPressureThresholds(4000, 2000); + ws.SetHighPressureThresholds(KMaxTInt, KMinTInt); + break; + default: + ret=gTestState=EWsTestFinished; + } + CleanupStack::PopAndDestroy(&gr2); + CleanupStack::PopAndDestroy(&gr1); + CleanupStack::PopAndDestroy(&ws); + return ret; + } + +void MainL() + { + TBuf<256> commandLine; + User::CommandLine(commandLine); + CTestBase testBase; + testBase.ConstructL(&commandLine); + TInt ii=0; + while(gTestState!=EWsTestFinished) + testBase.TestWsPanicL(&TestCapability,ii++,commandLine) ; +// testBase.UpdateLogsL(); + } + +GLDEF_C TInt E32Main() + { + __UHEAP_MARK; + CTrapCleanup* cleanUpStack=CTrapCleanup::New(); + if(cleanUpStack==NULL) + { + return KErrNoMemory; + } + TRAP_IGNORE(MainL()) + delete cleanUpStack; + __UHEAP_MARKEND; + return(KErrNone); + } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tcontaindrawer/containdrawer.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tcontaindrawer/containdrawer.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,103 @@ +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include "containdrawer.h" +#include "wsgraphicdrawercontext.h" +#include +#include + +const TGraphicDrawerId KChildInterfaceId1={0x1028353A, ETrue}; +const TGraphicDrawerId KChildInterfaceId2={0x1028353C, ETrue}; + + +// CWsGraphicDrawer +CWsContainGraphicDrawer* CWsContainGraphicDrawer::NewL() + { + return new(ELeave) CWsContainGraphicDrawer; + } + +CWsContainGraphicDrawer::~CWsContainGraphicDrawer() + { + if (iContext) + { + iContext->Destroy(); + iContext = NULL; + } + } + +void CWsContainGraphicDrawer::ConstructL(MWsGraphicDrawerEnvironment& aEnv, const TGraphicDrawerId& aId, MWsClient& aOwner, const TDesC8& /*aData*/) + { + BaseConstructL(aEnv, aId, aOwner); + iColor = KRgbWhite; + if (!(aEnv.Screen(0)->ResolveObjectInterface(KMWsCompositionContext) || aEnv.Screen(0)->ResolveObjectInterface(KMWsScene))) + { + iContext = CWsGraphicDrawerNonNgaContext::NewL(); + } + else + { + iContext = CWsGraphicDrawerNgaContext::NewL(); + } + } + +void CWsContainGraphicDrawer::HandleMessage(const TDesC8& aData) + { + TInt red = aData[0]; + TInt green = aData[1]; + TInt blue = aData[2]; + TRgb color(red, green, blue); + DoUpdateColor(color); + } + +void CWsContainGraphicDrawer::DoUpdateColor(TRgb aColor) + { + iColor = aColor; + // Invalidate the redrawing + Invalidate(); + } + +void CWsContainGraphicDrawer::DoDraw(MWsGc& aGc, const TRect& aRect, const TDesC8& aData) const + { + iContext->DrawEllipse(aGc, aRect, iColor); + + // invoke another CRPs to draw their artwork + TRect rect1 = TRect(TPoint(100,150),TSize(50,50)); + const CWsGraphicDrawer* child1 = Env().ResolveGraphic(KChildInterfaceId1); + if (child1) + child1->Draw(aGc, rect1, aData); + TRect rect2 = TRect(TPoint(200,150),TSize(50,50)); + const CWsGraphicDrawer* child2 = Env().ResolveGraphic(KChildInterfaceId2); + if (child2) + child2->Draw(aGc, rect2, aData); + } + +// inherited API to indicate there are contained drawers +TBool CWsContainGraphicDrawer::HasAsChild(const TArray& aIds) const + { + // Two child CRPs + const CWsGraphicDrawer* child1 = Env().ResolveGraphic(KChildInterfaceId1); + const CWsGraphicDrawer* child2 = Env().ResolveGraphic(KChildInterfaceId2); + if (child1 && child1->Contains(aIds)) + return ETrue; + else if (child2 && child2->Contains(aIds)) + return ETrue; + else + return EFalse; + } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tcontaindrawer/containdrawer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tcontaindrawer/containdrawer.h Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,52 @@ +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef __CONTAINDRAWER_H__ +#define __CONTAINDRAWER_H__ + +#include +#include + +class MWsGraphicDrawerContext; + +NONSHARABLE_CLASS(CWsContainGraphicDrawer): public CWsGraphicDrawer + { +public: + enum {EImplUid = 0x10283521}; + +public: + static CWsContainGraphicDrawer* NewL(); + virtual ~CWsContainGraphicDrawer(); + // override CWsGraphicDrawer + virtual void ConstructL(MWsGraphicDrawerEnvironment& aEnv,const TGraphicDrawerId& aId, MWsClient& aOwner, const TDesC8& aData); + virtual void HandleMessage(const TDesC8& aData); +private: + // override CWsGraphicDrawer + virtual void DoDraw(MWsGc& aGc, const TRect& aRect, const TDesC8& aData) const; + virtual TBool HasAsChild(const TArray& aIds) const; + + void DoUpdateColor(TRgb aColor); +private: + MWsGraphicDrawerContext* iContext; + TRgb iColor; +}; + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tcontaindrawer/containdrawer.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tcontaindrawer/containdrawer.rss Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,81 @@ +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include + +RESOURCE REGISTRY_INFO registry_info + { + dll_uid = 0x10283520; + interfaces = + { + INTERFACE_INFO + { + interface_uid = 0x10283522; + implementations = + { + IMPLEMENTATION_INFO + { + implementation_uid = 0x10283521; + version_no = 1; + display_name = "CWsContainDrawer"; + default_data = ""; + opaque_data = ""; + } + }; + interface_uid = 0x1028351B; + implementations = + { + IMPLEMENTATION_INFO + { + implementation_uid = 0x1028351C; + version_no = 1; + display_name = "CWsSimpleDrawer"; + default_data = ""; + opaque_data = ""; + } + }; + interface_uid = 0x1028353A; + implementations = + { + IMPLEMENTATION_INFO + { + implementation_uid = 0x10283539; + version_no = 1; + display_name = "CWsInvisibleDrawer1"; + default_data = ""; + opaque_data = ""; + } + }; + interface_uid = 0x1028353C; + implementations = + { + IMPLEMENTATION_INFO + { + implementation_uid = 0x1028353B; + version_no = 1; + display_name = "CWsInvisibleDrawer2"; + default_data = ""; + opaque_data = ""; + } + }; + } + }; + } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tcontaindrawer/proxy.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tcontaindrawer/proxy.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,39 @@ +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include +#include "containdrawer.h" +#include "simpledrawer.h" + + +LOCAL_C const TImplementationProxy KImplementationTable[] = + { + IMPLEMENTATION_PROXY_ENTRY(CWsContainGraphicDrawer::EImplUid, CWsContainGraphicDrawer::NewL), + IMPLEMENTATION_PROXY_ENTRY(CWsSimpleGraphicDrawer::EImplUid, CWsSimpleGraphicDrawer::NewL), + IMPLEMENTATION_PROXY_ENTRY(CWsInvisibleGraphicDrawer1::EImplUid, CWsInvisibleGraphicDrawer1::NewL), + IMPLEMENTATION_PROXY_ENTRY(CWsInvisibleGraphicDrawer2::EImplUid, CWsInvisibleGraphicDrawer2::NewL), + }; + +EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) + { + aTableCount = sizeof(KImplementationTable)/sizeof(TImplementationProxy); + return KImplementationTable; + } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tcontaindrawer/simpledrawer.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tcontaindrawer/simpledrawer.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,115 @@ +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include "simpledrawer.h" +#include "wsgraphicdrawercontext.h" +#include +#include + +// CWsGraphicDrawer +CWsSimpleGraphicDrawer* CWsSimpleGraphicDrawer::NewL() + { + return new(ELeave) CWsSimpleGraphicDrawer; + } + +CWsSimpleGraphicDrawer::~CWsSimpleGraphicDrawer() + { + if (iContext) + { + iContext->Destroy(); + iContext = NULL; + } + } + +void CWsSimpleGraphicDrawer::ConstructL(MWsGraphicDrawerEnvironment& aEnv, const TGraphicDrawerId& aId, MWsClient& aOwner, const TDesC8& /*aData*/) + { + BaseConstructL(aEnv, aId, aOwner); + // default color + iColor = KRgbBlue; + } + +void CWsSimpleGraphicDrawer::HandleMessage(const TDesC8& aData) + { + TInt red = aData[0]; + TInt green = aData[1]; + TInt blue = aData[2]; + TRgb color(red, green, blue); + DoUpdateColor(color); + } + +void CWsSimpleGraphicDrawer::BaseConstructL(MWsGraphicDrawerEnvironment& aEnv,const TGraphicDrawerId& aId,MWsClient& aOwner) + { + CWsGraphicDrawer::BaseConstructL(aEnv, aId, aOwner); + if (!(aEnv.Screen(0)->ResolveObjectInterface(KMWsCompositionContext) || aEnv.Screen(0)->ResolveObjectInterface(KMWsScene))) + { + iContext = CWsGraphicDrawerNonNgaContext::NewL(); + } + else + { + iContext = CWsGraphicDrawerNgaContext::NewL(); + } + } + +void CWsSimpleGraphicDrawer::DoUpdateColor(TRgb aColor) + { + iColor = aColor; + // Invalidate the redrawing + Invalidate(); + } + +void CWsSimpleGraphicDrawer::DoDraw(MWsGc& aGc, const TRect& aRect, const TDesC8& /*aData*/) const + { + iContext->DrawEllipse(aGc, aRect, iColor); + } + +// First contained (child) drawer +CWsInvisibleGraphicDrawer1* CWsInvisibleGraphicDrawer1::NewL() + { + return new(ELeave) CWsInvisibleGraphicDrawer1; + } + +CWsInvisibleGraphicDrawer1::~CWsInvisibleGraphicDrawer1() + { + } + +void CWsInvisibleGraphicDrawer1::ConstructL(MWsGraphicDrawerEnvironment& aEnv, const TGraphicDrawerId& aId, MWsClient& aOwner, const TDesC8& /*aData*/) + { + BaseConstructL(aEnv, aId, aOwner); + // default color + iColor = KRgbYellow; + } + +// Second contained (child) drawer +CWsInvisibleGraphicDrawer2* CWsInvisibleGraphicDrawer2::NewL() + { + return new(ELeave) CWsInvisibleGraphicDrawer2; + } + +CWsInvisibleGraphicDrawer2::~CWsInvisibleGraphicDrawer2() + { + } + +void CWsInvisibleGraphicDrawer2::ConstructL(MWsGraphicDrawerEnvironment& aEnv, const TGraphicDrawerId& aId, MWsClient& aOwner, const TDesC8& /*aData*/) + { + BaseConstructL(aEnv, aId, aOwner); + // default color + iColor = KRgbCyan; + } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tcontaindrawer/simpledrawer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tcontaindrawer/simpledrawer.h Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,78 @@ +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef __SIMPLEDRAWER_H__ +#define __SIMPLEDRAWER_H__ + +#include +#include + +class MWsGraphicDrawerContext; + +// A simple drawer +NONSHARABLE_CLASS(CWsSimpleGraphicDrawer): public CWsGraphicDrawer//, public MWsEventHandler + { +public: + enum {EImplUid = 0x1028351C}; + +public: + static CWsSimpleGraphicDrawer* NewL(); + virtual ~CWsSimpleGraphicDrawer(); + // override CWsGraphicDrawer + virtual void ConstructL(MWsGraphicDrawerEnvironment& aEnv,const TGraphicDrawerId& aId, MWsClient& aOwner, const TDesC8& aData); + virtual void HandleMessage(const TDesC8& aData); +protected: + // override CWsGraphicDrawer + void BaseConstructL(MWsGraphicDrawerEnvironment& aEnv,const TGraphicDrawerId& aId,MWsClient& aOwner); + virtual void DoDraw(MWsGc& aGc, const TRect& aRect, const TDesC8& aData) const; + void DoUpdateColor(TRgb aColor); +protected: + MWsGraphicDrawerContext* iContext; + TRgb iColor; +}; + +// First Contained (Child) drawer +NONSHARABLE_CLASS(CWsInvisibleGraphicDrawer1): public CWsSimpleGraphicDrawer//, public MWsEventHandler + { +public: + enum {EImplUid = 0x10283539}; + +public: + static CWsInvisibleGraphicDrawer1* NewL(); + virtual ~CWsInvisibleGraphicDrawer1(); + // override CWsGraphicDrawer + virtual void ConstructL(MWsGraphicDrawerEnvironment& aEnv,const TGraphicDrawerId& aId, MWsClient& aOwner, const TDesC8& aData); +}; + +// Second contained (child) drawer +NONSHARABLE_CLASS(CWsInvisibleGraphicDrawer2): public CWsSimpleGraphicDrawer//, public MWsEventHandler + { +public: + enum {EImplUid = 0x1028353B}; + +public: + static CWsInvisibleGraphicDrawer2* NewL(); + virtual ~CWsInvisibleGraphicDrawer2(); + // override CWsGraphicDrawer + virtual void ConstructL(MWsGraphicDrawerEnvironment& aEnv,const TGraphicDrawerId& aId, MWsClient& aOwner, const TDesC8& aData); +}; + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tcontaindrawer/wscontaindrawer.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tcontaindrawer/wscontaindrawer.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,121 @@ +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// The plug-in provides the client side CWsGraphic instance CWsListen, which is used in +// GRAPHICS-WSERV-0438. +// This also provides Test Case INC103472: CRedrawRegion::ContainsDrawers does not look for all drawers. +// The customer incident "INC103472" reports CWsRedrawMsgWindow::CRedrawRegion::ContainsDrawers in wnredraw.cpp +// is suppose to return whether some drawers are contained within a specific region. +// But right now it doesn't check for drawers in drawers. +// So if one drawer from the iDrawerArray contains one of the drawers passed along +// in aDrawers it will still return EFalse when it should return ETrue. +// The fix is added in CWsRedrawMsgWindow::CRedrawRegion::ContainsDrawers(const TArray& aDrawers,const RRegion& aRegion). +// The drawer->Contains() call will end up in HasAsChild(const TArray& aIds), +// where the CWsGraphicDrawer has to look for its own nested drawers and return ETrue or EFalse. +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ +//CWsGraphic +#include "wscontaindrawer.h" + +CWsContainGraphicBitmap::CWsContainGraphicBitmap() + { + } + +EXPORT_C CWsContainGraphicBitmap::~CWsContainGraphicBitmap() + { + iIsReady = EFalse; + } + +EXPORT_C CWsContainGraphicBitmap* CWsContainGraphicBitmap::NewL() + { + CWsContainGraphicBitmap* self = new(ELeave) CWsContainGraphicBitmap; + CleanupStack::PushL(self); + self->BaseConstructL(KContainDrawerImplId,KNullDesC8()); + self->iIsReady = ETrue; + CleanupStack::Pop(self); + return self; + } + +EXPORT_C CWsContainGraphicBitmap* CWsContainGraphicBitmap::NewL(TUid aUid) + { + CWsContainGraphicBitmap* self = new(ELeave) CWsContainGraphicBitmap; + CleanupStack::PushL(self); + self->BaseConstructL(aUid,KContainDrawerImplId,KNullDesC8()); + self->iIsReady = ETrue; + CleanupStack::Pop(self); + return self; + } + +EXPORT_C CWsContainGraphicBitmap* CWsContainGraphicBitmap::NewL(const TWsGraphicId& aReplace) + { + CWsContainGraphicBitmap* self = new(ELeave) CWsContainGraphicBitmap; + CleanupStack::PushL(self); + self->BaseConstructL(aReplace,KContainDrawerImplId,KNullDesC8()); + self->iIsReady = ETrue; + CleanupStack::Pop(self); + return self; + } + +EXPORT_C TInt CWsContainGraphicBitmap::UpdateColor(TRgb aColor) + { + if (!iIsReady) + return KErrNotReady; + // Send the color the server side + TBuf8<3> cmd; + TInt red = aColor.Red(); + TInt green = aColor.Green(); + TInt blue = aColor.Blue(); + //Append the color + cmd.Append(red); + cmd.Append(green); + cmd.Append(blue); + + SendMessage(cmd); + return Flush(); + } + + +EXPORT_C void CWsContainGraphicBitmap::HandleMessage(const TDesC8& /*aData*/) + { + } + +EXPORT_C void CWsContainGraphicBitmap::OnReplace() + { + } + +EXPORT_C TInt CWsContainGraphicBitmap::ShareGlobally() + { + return CWsGraphic::ShareGlobally(); + } + +EXPORT_C TInt CWsContainGraphicBitmap::UnShareGlobally() + { + return CWsGraphic::UnShareGlobally(); + } + +EXPORT_C TInt CWsContainGraphicBitmap::Share(TSecureId aClientId) + { + return CWsGraphic::Share(aClientId); + } + +EXPORT_C TInt CWsContainGraphicBitmap::UnShare(TSecureId aClientId) + { + return CWsGraphic::UnShare(aClientId); + } + diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tcontaindrawer/wscontaindrawer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tcontaindrawer/wscontaindrawer.h Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,55 @@ +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef __WSCONTAINDRAWER_H__ +#define __WSCONTAINDRAWER_H__ + +#include + +const TUid KContainDrawerInterfaceId = {0x10283522}; +const TUid KContainDrawerImplId = {0x10283521}; +/** Client representation of a window-server-side drawing owned by this Client +@publishedAll +@released +*/ +NONSHARABLE_CLASS(CWsContainGraphicBitmap): public CWsGraphic + { +public: + IMPORT_C static CWsContainGraphicBitmap* NewL(); + IMPORT_C static CWsContainGraphicBitmap* NewL(TUid aUid); + IMPORT_C static CWsContainGraphicBitmap* NewL(const TWsGraphicId& aReplace); + IMPORT_C ~CWsContainGraphicBitmap(); +public: + IMPORT_C TInt ShareGlobally(); + IMPORT_C TInt UnShareGlobally(); + IMPORT_C TInt Share(TSecureId aClientId); + IMPORT_C TInt UnShare(TSecureId aClientId); + + IMPORT_C TInt UpdateColor(TRgb aColor); +public: + CWsContainGraphicBitmap(); + void HandleMessage(const TDesC8& aData); + void OnReplace(); +private: + TBool iIsReady; +}; + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tcontaindrawer/wsgraphicdrawercontext.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tcontaindrawer/wsgraphicdrawercontext.h Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,50 @@ +// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#ifndef __WSGRAPHICDRAWERCONTEXT_H__ +#define __WSGRAPHICDRAWERCONTEXT_H__ + +#include +#include + +class MWsGc; +class TRgb; + +class MWsGraphicDrawerContext + { +public: + virtual void Destroy() = 0; + virtual void DrawEllipse(MWsGc& aGc, const TRect& aRect, const TRgb& aColor) const = 0; + }; + +class CWsGraphicDrawerNgaContext : public CBase, public MWsGraphicDrawerContext + { +public: + static MWsGraphicDrawerContext* NewL(); +public: + void Destroy(); + void DrawEllipse(MWsGc& aGc, const TRect& aRect, const TRgb& aColor) const; + }; + +class CWsGraphicDrawerNonNgaContext : public CBase, public MWsGraphicDrawerContext + { +public: + static MWsGraphicDrawerContext* NewL(); +public: + void Destroy(); + void DrawEllipse(MWsGc& aGc, const TRect& aRect, const TRgb& aColor) const; + }; + +#endif // __WSGRAPHICDRAWERCONTEXT_H__ diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tcontaindrawer/wsgraphicdrawerngacontext.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tcontaindrawer/wsgraphicdrawerngacontext.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,42 @@ +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#define SYMBIAN_GRAPHICS_GCE + +#include "wsgraphicdrawercontext.h" +#include + +MWsGraphicDrawerContext* CWsGraphicDrawerNgaContext::NewL() + { + return new(ELeave) CWsGraphicDrawerNgaContext(); + } + +void CWsGraphicDrawerNgaContext::Destroy() + { + delete this; + } + +void CWsGraphicDrawerNgaContext::DrawEllipse(MWsGc& aGc, const TRect& aRect, const TRgb& aColor) const + { + MWsGraphicsContext* context = aGc.ObjectInterface(); + if (context) + { + context->Push(); + context->SetBrushStyle(MWsGraphicsContext::ESolidBrush); + context->SetBrushColor(aColor); + context->DrawEllipse(aRect); + context->Pop(); + } + } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tcontaindrawer/wsgraphicdrawernonngacontext.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tcontaindrawer/wsgraphicdrawernonngacontext.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,40 @@ +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#undef SYMBIAN_GRAPHICS_GCE + +#include "wsgraphicdrawercontext.h" +#include +#include + +MWsGraphicDrawerContext* CWsGraphicDrawerNonNgaContext::NewL() + { + return new(ELeave) CWsGraphicDrawerNonNgaContext(); + } + +void CWsGraphicDrawerNonNgaContext::Destroy() + { + delete this; + } + +void CWsGraphicDrawerNonNgaContext::DrawEllipse(MWsGc& aGc, const TRect& aRect, const TRgb& aColor) const + { + aGc.PushBitGcSettings(); + CFbsBitGc& bitGc = aGc.BitGc(); + bitGc.SetBrushStyle(CGraphicsContext::ESolidBrush); + bitGc.SetBrushColor(aColor); + bitGc.DrawEllipse(aRect); + aGc.PopBitGcSettings(); + } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tcontaindrawer/wssimpledrawer.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tcontaindrawer/wssimpledrawer.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,181 @@ +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// The plug-in provides the client side CWsGraphic instance CWsListen, which is used in +// GRAPHICS-WSERV-0438. +// This also provides Test Case INC103472: CRedrawRegion::ContainsDrawers does not look for all drawers. +// The customer incident "INC103472" reports CWsRedrawMsgWindow::CRedrawRegion::ContainsDrawers in wnredraw.cpp +// is suppose to return wheather some drawers are contained within a specific region. +// But it currently fails to check for drawers in drawers. +// So if one drawer from the iDrawerArray contains one of the drawers passed along +// in aDrawers it will still return EFalse when it should return ETrue. +// The fix is added in CWsRedrawMsgWindow::CRedrawRegion::ContainsDrawers(const TArray& aDrawers,const RRegion& aRegion). +// The drawer->Contains() call will end up in HasAsChild(const TArray& aIds), +// where the CWsGraphicDrawer has to look for its own nested drawers and return ETrue or EFalse. +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ +//CWsGraphic +#include "wssimpledrawer.h" +#include + +CWsSimpleGraphicBitmap::CWsSimpleGraphicBitmap() + { + } + +EXPORT_C CWsSimpleGraphicBitmap::~CWsSimpleGraphicBitmap() + { + iIsReady = EFalse; + } + +EXPORT_C CWsSimpleGraphicBitmap* CWsSimpleGraphicBitmap::NewL() + { + CWsSimpleGraphicBitmap* self = new(ELeave) CWsSimpleGraphicBitmap; + CleanupStack::PushL(self); + self->BaseConstructL(KSimpleDrawerImplId,KNullDesC8()); + self->iIsReady = ETrue; + CleanupStack::Pop(self); + return self; + } + +EXPORT_C CWsSimpleGraphicBitmap* CWsSimpleGraphicBitmap::NewL(TUid aUid) + { + CWsSimpleGraphicBitmap* self = new(ELeave) CWsSimpleGraphicBitmap; + CleanupStack::PushL(self); + self->BaseConstructL(aUid,KSimpleDrawerImplId,KNullDesC8()); + self->iIsReady = ETrue; + CleanupStack::Pop(self); + return self; + } + +EXPORT_C CWsSimpleGraphicBitmap* CWsSimpleGraphicBitmap::NewL(const TWsGraphicId& aReplace) + { + CWsSimpleGraphicBitmap* self = new(ELeave) CWsSimpleGraphicBitmap; + CleanupStack::PushL(self); + self->BaseConstructL(aReplace,KSimpleDrawerImplId,KNullDesC8()); + self->iIsReady = ETrue; + CleanupStack::Pop(self); + return self; + } + +EXPORT_C TInt CWsSimpleGraphicBitmap::UpdateColor(TRgb aColor) + { + if (!iIsReady) + return KErrNotReady; + // Send the message to server side + TBuf8<3> cmd; + TInt red = aColor.Red(); + TInt green = aColor.Green(); + TInt blue = aColor.Blue(); + //Append the color + cmd.Append(red); + cmd.Append(green); + cmd.Append(blue); + + SendMessage(cmd); + return Flush(); + } + +EXPORT_C void CWsSimpleGraphicBitmap::HandleMessage(const TDesC8& /*aData*/) + { + } + +EXPORT_C void CWsSimpleGraphicBitmap::OnReplace() + { + } + +EXPORT_C TInt CWsSimpleGraphicBitmap::ShareGlobally() + { + return CWsGraphic::ShareGlobally(); + } + +EXPORT_C TInt CWsSimpleGraphicBitmap::UnShareGlobally() + { + return CWsGraphic::UnShareGlobally(); + } + +EXPORT_C TInt CWsSimpleGraphicBitmap::Share(TSecureId aClientId) + { + return CWsGraphic::Share(aClientId); + } + +EXPORT_C TInt CWsSimpleGraphicBitmap::UnShare(TSecureId aClientId) + { + return CWsGraphic::UnShare(aClientId); + } + +EXPORT_C CWsInvisibleGraphicBitmap1* CWsInvisibleGraphicBitmap1::NewL() + { + CWsInvisibleGraphicBitmap1* self = new(ELeave) CWsInvisibleGraphicBitmap1; + CleanupStack::PushL(self); + self->BaseConstructL(KInvisibleDrawerImplId1,KNullDesC8()); + self->iIsReady = ETrue; + CleanupStack::Pop(self); + return self; + } + +EXPORT_C CWsInvisibleGraphicBitmap1* CWsInvisibleGraphicBitmap1::NewL(TUid aUid) + { + CWsInvisibleGraphicBitmap1* self = new(ELeave) CWsInvisibleGraphicBitmap1; + CleanupStack::PushL(self); + self->BaseConstructL(aUid,KInvisibleDrawerImplId1,KNullDesC8()); + self->iIsReady = ETrue; + CleanupStack::Pop(self); + return self; + } + +EXPORT_C CWsInvisibleGraphicBitmap1* CWsInvisibleGraphicBitmap1::NewL(const TWsGraphicId& aReplace) + { + CWsInvisibleGraphicBitmap1* self = new(ELeave) CWsInvisibleGraphicBitmap1; + CleanupStack::PushL(self); + self->BaseConstructL(aReplace,KInvisibleDrawerImplId1,KNullDesC8()); + self->iIsReady = ETrue; + CleanupStack::Pop(self); + return self; + } + +EXPORT_C CWsInvisibleGraphicBitmap2* CWsInvisibleGraphicBitmap2::NewL() + { + CWsInvisibleGraphicBitmap2* self = new(ELeave) CWsInvisibleGraphicBitmap2; + CleanupStack::PushL(self); + self->BaseConstructL(KInvisibleDrawerImplId2,KNullDesC8()); + self->iIsReady = ETrue; + CleanupStack::Pop(self); + return self; + } + +EXPORT_C CWsInvisibleGraphicBitmap2* CWsInvisibleGraphicBitmap2::NewL(TUid aUid) + { + CWsInvisibleGraphicBitmap2* self = new(ELeave) CWsInvisibleGraphicBitmap2; + CleanupStack::PushL(self); + self->BaseConstructL(aUid,KInvisibleDrawerImplId2,KNullDesC8()); + self->iIsReady = ETrue; + CleanupStack::Pop(self); + return self; + } + +EXPORT_C CWsInvisibleGraphicBitmap2* CWsInvisibleGraphicBitmap2::NewL(const TWsGraphicId& aReplace) + { + CWsInvisibleGraphicBitmap2* self = new(ELeave) CWsInvisibleGraphicBitmap2; + CleanupStack::PushL(self); + self->BaseConstructL(aReplace,KInvisibleDrawerImplId2,KNullDesC8()); + self->iIsReady = ETrue; + CleanupStack::Pop(self); + return self; + } + diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tcontaindrawer/wssimpledrawer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tcontaindrawer/wssimpledrawer.h Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,92 @@ +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef __WSSIMPLEDRAWER_H__ +#define __WSSIMPLEDRAWER_H__ + + +#include +const TUid KSimpleDrawerInterfaceId = {0x1028351B}; +const TUid KSimpleDrawerImplId = {0x1028351C}; + +/** Client representation of a window-server-side drawing owned by this Client +@publishedAll +@released +*/ +NONSHARABLE_CLASS(CWsSimpleGraphicBitmap): public CWsGraphic + { +public: + IMPORT_C static CWsSimpleGraphicBitmap* NewL(); + IMPORT_C static CWsSimpleGraphicBitmap* NewL(TUid aUid); + IMPORT_C static CWsSimpleGraphicBitmap* NewL(const TWsGraphicId& aReplace); + + IMPORT_C ~CWsSimpleGraphicBitmap(); +public: // protected virtuals from CWsGraphic promoted to public + IMPORT_C TInt ShareGlobally(); + IMPORT_C TInt UnShareGlobally(); + IMPORT_C TInt Share(TSecureId aClientId); + IMPORT_C TInt UnShare(TSecureId aClientId); + + IMPORT_C TInt UpdateColor(TRgb aColor); + +public: + CWsSimpleGraphicBitmap(); + void HandleMessage(const TDesC8& aData); + void OnReplace(); +public: + TBool iIsReady; +}; + + +const TUid KInvisibleDrawerInterfaceId1 = {0x1028353A}; +const TUid KInvisibleDrawerImplId1 = {0x10283539}; + +/** Client representation of a window-server-side drawing owned by this Client +@publishedAll +@released +*/ +NONSHARABLE_CLASS(CWsInvisibleGraphicBitmap1): public CWsSimpleGraphicBitmap + { +public: + IMPORT_C static CWsInvisibleGraphicBitmap1* NewL(); + IMPORT_C static CWsInvisibleGraphicBitmap1* NewL(TUid aUid); + IMPORT_C static CWsInvisibleGraphicBitmap1* NewL(const TWsGraphicId& aReplace); +}; + + +const TUid KInvisibleDrawerInterfaceId2 = {0x1028353C}; +const TUid KInvisibleDrawerImplId2 = {0x1028353B}; + +/** Client representation of a window-server-side drawing owned by this Client +@publishedAll +@released +*/ +NONSHARABLE_CLASS(CWsInvisibleGraphicBitmap2): public CWsSimpleGraphicBitmap + { +public: + IMPORT_C static CWsInvisibleGraphicBitmap2* NewL(); + IMPORT_C static CWsInvisibleGraphicBitmap2* NewL(TUid aUid); + IMPORT_C static CWsInvisibleGraphicBitmap2* NewL(const TWsGraphicId& aReplace); +}; + + + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tcrx/tcrx.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tcrx/tcrx.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,393 @@ +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include +#include "tcrx.h" +#include "wsredir.h" +#include "wslisten.h" + +static TRedirectorInfo TheInfo; + +class CTwoWindow: public CBase + { +public: + static CTwoWindow* NewL(); + ~CTwoWindow(); +private: + void ConstructL(); +private: + RWsSession iWs; + CWsScreenDevice* iScr; + CWindowGc* iGc; + RWindowGroup iGroup; + RWindow iBg; + RWindow iFg; + }; + +CTwoWindow* CTwoWindow::NewL() + { + CTwoWindow* tw = new(ELeave) CTwoWindow; + CleanupStack::PushL(tw); + tw->ConstructL(); + CleanupStack::Pop(tw); + return tw; + } + +CTwoWindow::~CTwoWindow() + { + iFg.Close(); + iBg.Close(); + iGroup.Close(); + delete iGc; + delete iScr; + iWs.Close(); + } + +void CTwoWindow::ConstructL() + { + User::LeaveIfError(iWs.Connect()); + iScr = new(ELeave) CWsScreenDevice(iWs); + User::LeaveIfError(iScr->Construct()); + User::LeaveIfError(iScr->CreateContext(iGc)); + iGroup = RWindowGroup(iWs); + User::LeaveIfError(iGroup.Construct(0xc0de,ETrue)); + + iBg = RWindow(iWs); + User::LeaveIfError(iBg.Construct(iGroup,0xc0debabe)); + iBg.SetRequiredDisplayMode(EColor64K); + iBg.Activate(); + iWs.Flush(); + + iBg.BeginRedraw(); + iGc->Activate(iBg); + iGc->SetBrushColor(KRgbGreen); + iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + TRect rect(iScr->SizeInPixels()); + iGc->DrawRect(rect); + iGc->SetBrushColor(KRgbBlue); + iGc->DrawEllipse(rect); + iGc->Deactivate(); + iBg.EndRedraw(); + iWs.Flush(); + + iFg = RWindow(iWs); + User::LeaveIfError(iFg.Construct(iGroup,0xc0decafe)); + iFg.SetRequiredDisplayMode(EColor64K); + iFg.SetTransparencyAlphaChannel(); + iFg.SetBackgroundColor(TRgb(0xff,0x55,0x55,0x80)); + iFg.Activate(); + iWs.Flush(); + } + +CClient* CClient::NewL() + { + CClient* self = new(ELeave) CClient; + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + + return self; + } + +CClient::CClient(): CActive(CActive::EPriorityStandard) + { + } + +void CClient::ConstructL() + { + CActiveScheduler::Add(this); + User::LeaveIfError(iWs.Connect()); + iScreen = new(ELeave) CWsScreenDevice(iWs); + User::LeaveIfError(iScreen->Construct(0)); + iGroup = RWindowGroup(iWs); + User::LeaveIfError(iGroup.Construct(0xCAFE, ETrue)); + iGc = new(ELeave) CWindowGc(iScreen); + User::LeaveIfError(iGc->Construct()); + iWin = new(ELeave) CWindow(this); + iWin->ConstructL(NULL, EFalse); + iRedraw = CRedrawHandler::NewL(this); + + iRedir = CWsRedir::NewL(); + iListen = CWsListen::NewL(); + + MakeRequest(); + } + +void CClient::HandleCommand(TInt aCmd) + { + switch (aCmd) + { + case 1: + iRedir->Redirect(CWsRedir::EFrontBuffer, ETrue); + break; + + case 2: + iRedir->Redirect(CWsRedir::EBackBuffer, ETrue); + break; + + case 3: + iRedir->Redirect(CWsRedir::EFrontBuffer, EFalse); + break; + + case 4: + iRedir->Redirect(CWsRedir::EBackBuffer, EFalse); + break; + + case 5: + iListen->Enable(ETrue); + break; + + case 6: + iListen->Enable(EFalse); + break; + + case 7: + iRedir->QueryPlugin(TheInfo); + break; + + case 8: + iBlank.Close(); + iBlank = RBlankWindow(iWs); + iBlank.Construct(iGroup, 0xbeef); + iBlank.SetRequiredDisplayMode(EColor64K); + iBlank.SetColor(KRgbRed); + iBlank.SetExtent(TPoint(20,20),TSize(100,100)); + iBlank.Activate(); + break; + + case 9: + ClearTwoWindow(); + DrawTwoWindow(); + break; + + case 10: + CActiveScheduler::Stop(); + break; + } + } + +CClient::~CClient() + { + Deque(); + ClearTwoWindow(); + iBlank.Close(); + + delete iListen; + delete iRedir; + delete iWin; + delete iRedraw; + delete iGc; + delete iScreen; + + iGroup.Close(); + iWs.Close(); + } + +void CClient::DrawTwoWindow() + { + TRAP_IGNORE(iTwo = CTwoWindow::NewL()); + } + +void CClient::ClearTwoWindow() + { + delete iTwo; + iTwo = NULL; + } + +void CClient::RunL() + { + iWs.GetEvent(iEvent); + if (iEvent.Type()==EEventKey) + HandleCommand(iEvent.Key()->iCode-'0'); + MakeRequest(); + } + +void CClient::DoCancel() + { + iWs.EventReadyCancel(); + } + +void CClient::MakeRequest() + { + iWs.EventReady(&iStatus); + SetActive(); + } + +CRedrawHandler* CRedrawHandler::NewL(CClient* aClient) + { + CRedrawHandler* self=new(ELeave) CRedrawHandler(aClient); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + + return self; + } + +CRedrawHandler::CRedrawHandler(CClient* aClient) : CActive(CActive::EPriorityStandard), iClient(aClient) + { + } + +void CRedrawHandler::ConstructL() + { + CActiveScheduler::Add(this); + MakeRequest(); + } + +CRedrawHandler::~CRedrawHandler() + { + Cancel(); + } + +void CRedrawHandler::RunL() + { + TWsRedrawEvent event; + iClient->Ws().GetRedraw(event); + CWindow* win = (CWindow*)event.Handle(); + if (win) + { + TRect rect=event.Rect(); + iClient->Gc().Activate(win->Window()); + win->Window().BeginRedraw(rect); + win->Draw(rect); + win->Window().EndRedraw(); + iClient->Gc().Deactivate(); + } + + MakeRequest(); + } + +void CRedrawHandler::MakeRequest() + { + iClient->Ws().RedrawReady(&iStatus); + SetActive(); + } + +void CRedrawHandler::DoCancel() + { + iClient->Ws().RedrawReadyCancel(); + } + +CWindow::CWindow(CClient* aClient) : iClient(aClient) + { + } + +CWindow::~CWindow() + { + iWin.Close(); + } + +void CWindow::ConstructL(CWindow* aParent, TBool aTransparentFlag) + { + iParent = aParent; + iWin = RWindow(iClient->Ws()); + RWindowTreeNode* node=iParent? &iParent->Window() : (RWindowTreeNode*)&iClient->Group(); + User::LeaveIfError(iWin.Construct(*node, (TUint32)this)); + iWin.SetRequiredDisplayMode(EColor64K); + if (aTransparentFlag) + { + iWin.SetBackgroundColor(TRgb(0,0,0,0x80)); + iWin.SetTransparencyAlphaChannel(); + } + iWin.SetExtent(TPoint(0,0),TSize(240,240)); + iWin.Activate(); + } + +void CWindow::Draw(const TRect& aRect) const + { + CWindowGc& gc = iClient->Gc(); + gc.SetBrushStyle(CGraphicsContext::ESolidBrush); + gc.SetBrushColor(TRgb(0,0,0xff,0xff)); + gc.DrawRect(TRect(aRect.iTl.iX,aRect.iTl.iY,aRect.iBr.iX,aRect.iBr.iY/2)); + gc.SetBrushColor(TRgb(0,0,0xff,0x80)); + gc.DrawRect(TRect(aRect.iTl.iX,aRect.iBr.iY/2,aRect.iBr.iX,aRect.iBr.iY)); + DrawMenu(); + + gc.DrawWsGraphic(iClient->WsRedir()->Id(),TRect(aRect.iTl.iX,aRect.iBr.iY/2,aRect.iBr.iX,aRect.iBr.iY)); + } + +_LIT(KMenu1, "1. Redirect screen"); +_LIT(KMenu2, "2. Redirect flickerfree"); +_LIT(KMenu3, "3. Restore screen"); +_LIT(KMenu4, "4. Restore flickerfree"); +_LIT(KMenu5, "5. Register event listener"); +_LIT(KMenu6, "6. Unregister listener"); +_LIT(KMenu7, "7. Test send receive msg"); +_LIT(KMenu8, "8. Test blank window"); +_LIT(KMenu9, "9. Test two window"); +_LIT(KMenuA, "A. Exit"); + +const TBufC<32> TheMenu[] = + { + (const TDesC&)KMenu1, + (const TDesC&)KMenu2, + (const TDesC&)KMenu3, + (const TDesC&)KMenu4, + (const TDesC&)KMenu5, + (const TDesC&)KMenu6, + (const TDesC&)KMenu7, + (const TDesC&)KMenu8, + (const TDesC&)KMenu9, + (const TDesC&)KMenuA + }; + +_LIT(KTypeFace, "DejaVu Sans Condensed"); + +void CWindow::DrawMenu() const + { + CWsScreenDevice* scr = iClient->Screen(); + CFont* font = NULL; + TFontSpec fs(KTypeFace, 15); + scr->GetNearestFontInPixels(font, fs); + CWindowGc& gc = iClient->Gc(); + gc.UseFont(font); + TInt h = font->HeightInPixels(); + gc.SetPenColor(KRgbYellow); + TInt nMenu = sizeof(TheMenu)/sizeof(TheMenu[0]); + for (TInt ii=0; iiReleaseFont(font); + } + +void MainL() + { + CClient* client=CClient::NewL(); + CActiveScheduler::Start(); + + delete client; + } + +GLDEF_C TInt E32Main() + { + CTrapCleanup* trap=CTrapCleanup::New(); + if (!trap) + return KErrNoMemory; + CActiveScheduler* scheduler = new(ELeave) CActiveScheduler; + CActiveScheduler::Install(scheduler); + + __UHEAP_MARK; + TRAPD(err, MainL()); + __UHEAP_MARKEND; + + delete scheduler; + delete trap; + return err; + } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tcrx/tcrx.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tcrx/tcrx.h Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,128 @@ +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef __TCRX_H__ +#define __TCRX_H__ + +#include +#include + +class CRedrawHandler; +class CWindow; +class CWsListen; +class CWsRedir; +class CTwoWindow; + +class CClient: public CActive + { +public: + static CClient* NewL(); + ~CClient(); + void RunL(); + void DoCancel(); + inline RWsSession& Ws(); + inline RWindowGroup& Group(); + inline CWindowGc& Gc(); + inline CWindow* Win(); + inline CWsScreenDevice* Screen(); + inline CWsRedir* WsRedir(); + inline CWsListen* WsListen(); + void HandleCommand(TInt aCmd); +private: + CClient(); + void ConstructL(); + void MakeRequest(); + void DrawTwoWindow(); + void ClearTwoWindow(); + + RWsSession iWs; + RWindowGroup iGroup; + CWsScreenDevice* iScreen; + CWindowGc* iGc; + TWsEvent iEvent; + CWindow* iWin; + CRedrawHandler* iRedraw; + CWsListen* iListen; + CWsRedir* iRedir; + RBlankWindow iBlank; + CTwoWindow* iTwo; + }; + +class CRedrawHandler: public CActive + { +public: + static CRedrawHandler* NewL(CClient* aClient); + ~CRedrawHandler(); + void RunL(); + void DoCancel(); +private: + CRedrawHandler(CClient* aClient); + void ConstructL(); + void MakeRequest(); + + CClient* iClient; + }; + +class CWindow: public CBase + { +public: + CWindow(CClient* aClient); + void ConstructL(CWindow* aParent, TBool aTransparentFlag); + ~CWindow(); + void Draw(const TRect& aRect) const; + void DrawMenu() const; + inline RWindow& Window(); + inline CWindow* Parent(); + inline TSize Size(); + inline CClient* Client(); +private: + CClient* iClient; + RWindow iWin; + CWindow* iParent; + }; + +// CClient +inline RWsSession& CClient::Ws() + {return iWs;} +inline RWindowGroup& CClient::Group() + {return iGroup;} +inline CWindowGc& CClient::Gc() + {return *iGc;} +inline CWindow* CClient::Win() + {return iWin;} +inline CWsScreenDevice* CClient::Screen() + {return iScreen;} +inline CWsListen* CClient::WsListen() + {return iListen;} +inline CWsRedir* CClient::WsRedir() + {return iRedir;} +// CWindow +inline RWindow& CWindow::Window() + {return iWin;} +inline CWindow* CWindow::Parent() + {return iParent;} +inline TSize CWindow::Size() + {return iWin.Size();} +inline CClient* CWindow::Client() + {return iClient;} + +#endif + diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tcsc/cwsgcecsc.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tcsc/cwsgcecsc.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,656 @@ +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// @file +// +// + +#include +#include +#include "cwsgcecsc.h" +#include "extendtef.h" +#include "teflogextensions.h" +#include "testscreencapture.h" + + +#if defined(__X86GCC__) +extern "C" TInt atexit(void (*function)(void)) + { + return KErrNone; + } +#endif + +void TefUnitFailLeaveL() + { + User::Leave(KErrTEFUnitFail); + } + +CWSGceCsc::CWSGceCsc() + { + } + +CWSGceCsc::~CWSGceCsc() + { + } + +/** +Common set up code for all tests. + +Creates the session and window group for further windows, plus a simple white +background to obscure any unwanted stuff behind the test. Sets up the surface +update session and surface manager, to work with surfaces. Creates a screen +device for use in the tests. +*/ +void CWSGceCsc::SetupL() + { + CWsGceCscBase::SetupL(); + } + +/** +Common tear down code for all tests. + +Windows, group and session created are closed. Screen device is destroyed. +Surfaces, manager and update session are closed. +*/ +void CWSGceCsc::TearDownL() + { + CWsGceCscBase::TearDownL(); + } + +CTestSuite* CWSGceCsc::CreateSuiteL( const TDesC& aName) + { + SUB_SUITE; + ADD_WSGCE_TEST_STEP(CWSGceCsc, GRAPHICS_WSERV_CSC_101L); + ADD_WSGCE_TEST_STEP(CWSGceCsc, GRAPHICS_WSERV_CSC_102L); + ADD_WSGCE_TEST_STEP(CWSGceCsc, GRAPHICS_WSERV_CSC_103L); + ADD_WSGCE_TEST_STEP(CWSGceCsc, GRAPHICS_WSERV_CSC_104L); + ADD_WSGCE_TEST_STEP(CWSGceCsc, GRAPHICS_WSERV_CSC_105L); + END_SUITE; + } + +/** + @SYMTestCaseID GRAPHICS_WSERV_CSC_101L + + @SYMTestCaseDesc Compare the screen composition using the new and legacy API + + @SYMPREQ CSC + + @SYMTestStatus Implemented + + @SYMTestPriority 1 + + @SYMTestPurpose To check that the screen composition retrieved using the new and legacy APIs + + @SYMTestActions Initialization. + Construct a background opaque window. + Create two bitmaps with the size equal with the composition. + Draw something on the screen. + Use legacy API CopyScreenToBitmap() to copy the screen to first bitmap. + Use the the new API to copy the composition of the screen. + Compare the results. + + @SYMTestExpectedResults The bitmap should be identical +*/ +void CWSGceCsc::GRAPHICS_WSERV_CSC_101L() + { + TRect screen(iScreenDevice->SizeInPixels()); + RWindow nonSurfacedWindow(iSession); + iTestName.Format(_L("GRAPHICS_WSERV_CSC_101L")); + + INFO_PRINTF2(_L("%S"),&iTestName); + iDisplayMode = iScreenDevice->DisplayMode(); // Get default display mode + + ConstructOpaqueWindowLC(nonSurfacedWindow, + iCyan, + 0, + TPoint(0, 0), + screen.Size()); + iSession.Flush(); + Pause(1000); + + MTestScreenCapture* csc = static_cast (iScreenDevice->GetInterface(MTestScreenCapture::KUidTestScreenCaptureIf)); + ASSERT_NOT_NULL(csc); + + TSize compositionScreenSize; + + User::LeaveIfError(csc->GetCompositedSize(compositionScreenSize)); + + CFbsBitmap *bmp1 = new (ELeave) CFbsBitmap; + CleanupStack::PushL(bmp1); + User::LeaveIfError(bmp1->Create(compositionScreenSize, EColor16MU)); + + CFbsBitmap *bmp2 = new (ELeave) CFbsBitmap; + CleanupStack::PushL(bmp2); + User::LeaveIfError(bmp2->Create(compositionScreenSize, EColor16MU)); + + iSession.Flush(); + Pause(200); + + iScreenDevice->CopyScreenToBitmap(bmp1); + User::LeaveIfError(csc->ComposeScreen(*bmp2)); + + SetBackgroundColorWindow(nonSurfacedWindow, iRed); + iSession.Flush(); + + Pause(500); + + iGc->Activate(nonSurfacedWindow); + iGc->BitBlt(TPoint(0, 0), bmp1); + iGc->Deactivate(); + iSession.Flush(); + Pause(500); + + SetBackgroundColorWindow(nonSurfacedWindow, iWhite); + iSession.Flush(); + Pause(500); + + iGc->Activate(nonSurfacedWindow); + iGc->BitBlt(TPoint(0, 0), bmp2); + iGc->Deactivate(); + iSession.Flush(); + Pause(500); + + ASSERT_TRUE(Compare(*bmp1, *bmp2)); + + if (GCEIsSupported()) + { + iUtility->DestroyAll(); + } + + CleanupStack::PopAndDestroy(bmp2); + CleanupStack::PopAndDestroy(bmp1); + CleanupStack::PopAndDestroy(&nonSurfacedWindow); + iSession.Flush(); + Pause(1000); + } + +void CWSGceCsc::DrawBasicPattern (RWindow& aWin) + { + TSize rectSize(100, 100); + aWin.Invalidate(); + aWin.BeginRedraw(); + iGc->Activate(aWin); + iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + iGc->SetBrushColor(KRgbDarkRed); + iGc->DrawRect(TRect(TPoint(35, 5), rectSize)); + iGc->SetBrushColor(KRgbBlack); + iGc->DrawRect(TRect(TPoint(55, 15), rectSize)); + iGc->SetBrushColor(KRgbDarkBlue); + iGc->DrawRect(TRect(TPoint(75, 35), rectSize)); + iGc->SetBrushColor(KRgbYellow); + iGc->DrawRect(TRect(TPoint(95, 55), rectSize)); + iGc->Deactivate(); + aWin.EndRedraw(); + iSession.Flush(); + Pause(500); + } + +/** + @SYMTestCaseID GRAPHICS_WSERV_CSC_102L + + @SYMTestCaseDesc Compare the screen composition using the new and legacy API + + @SYMPREQ CSC + + @SYMTestStatus Implemented + + @SYMTestPriority 1 + + @SYMTestPurpose To check that the screen composition retrieved using the new and legacy APIs + + @SYMTestActions Initialization. + Draw a pattern on the screen + Retrieve to a bitmap the UI content using the legacy API + Blank the screen. + Display the retrieved content to a surface + Retrieve the composited content + Compare the UI content with the composited content + NOTE:assumes current screen mode is at 0 offset + + @SYMTestExpectedResults The UI content should be identical with the composited content +*/ +void CWSGceCsc::GRAPHICS_WSERV_CSC_102L() + { + TRect screen(iScreenDevice->SizeInPixels()); + RWindow testWindow(iSession); + RWindow surfacedTestWindow(iSession); + TSurfaceId surfaceID; + + MTestScreenCapture* csc = static_cast (iScreenDevice->GetInterface(MTestScreenCapture::KUidTestScreenCaptureIf)); + ASSERT_NOT_NULL(csc); + + TSize compositionScreenSize; + User::LeaveIfError(csc->GetCompositedSize(compositionScreenSize)); + + iTestName.Format(_L("GRAPHICS_WSERV_CSC_102")); + INFO_PRINTF2(_L("%S"),&iTestName); + + iDisplayMode = iScreenDevice->DisplayMode(); + + TRAPD(err, surfaceID = iUtility->CreateSurfaceL(compositionScreenSize, + KSurfaceFormat, + compositionScreenSize.iWidth * KBytesPerPixel)); + ASSERT_EQUALS(err,KErrNone); + + ConstructOpaqueWindowLC(testWindow, + iWhite, + 0, + TPoint(0, 0), + compositionScreenSize); + + iSession.Flush(); + Pause(100); + + CFbsBitmap *bmp1 = new (ELeave) CFbsBitmap; + CleanupStack::PushL(bmp1); + User::LeaveIfError(bmp1->Create(compositionScreenSize, EColor16MU)); + + CFbsBitmap *bmp2 = new (ELeave) CFbsBitmap; + CleanupStack::PushL(bmp2); + User::LeaveIfError(bmp2->Create(compositionScreenSize, EColor16MU)); + + iSession.Flush(); + Pause(500); + + SetBackgroundColorWindow(testWindow, iWhite); + DrawBasicPattern (testWindow); + + iScreenDevice->CopyScreenToBitmap(bmp1); + iSession.Flush(); + Pause(100); + + ConstructOpaqueSurfacedWindowLC(surfacedTestWindow, + iRed, + 0, + TPoint(0, 0), + compositionScreenSize, + surfaceID); + + TRAP(err,iUtility->FillSurfaceL(surfaceID, iCyan)); + ASSERT_EQUALS(err,KErrNone); + iSession.Flush(); + Pause(500); + + TRAP(err, iUtility->CopyBitmapToSurfaceL(surfaceID, *bmp1)); + ASSERT_EQUALS(err,KErrNone); + iSession.Flush(); + Pause(500); + + User::LeaveIfError(csc->ComposeScreen(*bmp2)); + + ASSERT_TRUE(Compare(*bmp1, *bmp2)); + + iUtility->DestroyAll(); + CleanupStack::PopAndDestroy(&surfacedTestWindow); + CleanupStack::PopAndDestroy(bmp2); + CleanupStack::PopAndDestroy(bmp1); + CleanupStack::PopAndDestroy(&testWindow); + iSession.Flush(); + Pause(1000); + } + +/** + @SYMTestCaseID GRAPHICS_WSERV_CSC_103L + + @SYMTestCaseDesc Test TranslateExtent + + @SYMPREQ CSC + + @SYMTestStatus Implemented + + @SYMTestPriority 1 + + @SYMTestPurpose To check that the correct translated extent is returned to the client + + @SYMTestActions Initialization + Change to app mode with offset and 90 degrees rotation + Translate a rectangle corresponding to the original app mode + Compare the expected rectangle with the translated rectangle + + @SYMTestExpectedResults The translated rectangle should take into account the offset and rotation + and be equal to the expected rectangle +*/ +void CWSGceCsc::GRAPHICS_WSERV_CSC_103L() + { + TRect screen(iScreenDevice->SizeInPixels()); + RWindow testWindow(iSession); + + iTestName.Format(_L("GRAPHICS_WSERV_CSC_103L")); + INFO_PRINTF2(_L("%S"),&iTestName); + + iDisplayMode = iScreenDevice->DisplayMode(); + + ConstructOpaqueWindowLC(testWindow, + iWhite, + 0, + TPoint(0, 0), + screen.Size()); + iSession.Flush(); + Pause(1000); + + // Get the screen modes + RArray modeList; + TInt err = iScreenDevice->GetScreenSizeModeList(&modeList); + ASSERT_TRUE(err > 1); //2 modes expected + ASSERT_TRUE(modeList.Count() > 1); //2 modes expected + + // The initial extent and the expected translated extent + TRect initial(TPoint(10,10), TSize(20,30)); + TRect extent(initial); + TRect expected(TPoint(15,15), TSize(20,30)); + + // Change app mode to 5 pixels offset + iScreenDevice->SetAppScreenMode(modeList[1]); + iScreenDevice->SetScreenMode(modeList[1]); + iSession.Flush(); + Pause(100); + + TPoint origin = iScreenDevice->GetCurrentScreenModeScaledOrigin(); + if(origin != TPoint(0,0)) + { + // Calculate the new extent + MTestScreenCapture* csc = static_cast (iScreenDevice->GetInterface(MTestScreenCapture::KUidTestScreenCaptureIf)); + ASSERT_NOT_NULL(csc); + csc->TranslateExtent(initial, extent); + ASSERT_TRUE(extent == expected); + } + else + { + INFO_PRINTF1(_L("Non zero offset not supported")); + } + // Change app mode + iScreenDevice->SetAppScreenMode(modeList[0]); + iScreenDevice->SetScreenMode(modeList[0]); + iSession.Flush(); + Pause(100); + + modeList.Close(); + CleanupStack::PopAndDestroy(&testWindow); + iSession.Flush(); + Pause(1000); + } + +/** + @SYMTestCaseID GRAPHICS_WSERV_CSC_104L + + @SYMTestCaseDesc Compare the screen composition using bitmaps with different display modes + + @SYMPREQ CSC + + @SYMTestStatus Implemented + + @SYMTestPriority 1 + + @SYMTestPurpose To check that bitmaps with different display modes + + @SYMTestActions Initialization. + Draw a pattern on the screen + Retrieve to a bitmap the UI content using the legacy API + Blank the screen. + Display the retrieved content to a surface + Retrieve the composited content to a 2nd bitmap + Compare the UI content with the composited content + + @SYMTestExpectedResults The bitmaps format should not match and should return KErrArgument +*/ +void CWSGceCsc::GRAPHICS_WSERV_CSC_104L() + { + TRect screen(iScreenDevice->SizeInPixels()); + RWindow testWindow(iSession); + RWindow surfacedTestWindow(iSession); + TSurfaceId surfaceID; + + MTestScreenCapture* csc = static_cast (iScreenDevice->GetInterface(MTestScreenCapture::KUidTestScreenCaptureIf)); + ASSERT_NOT_NULL(csc); + + TSize compositionScreenSize; + User::LeaveIfError(csc->GetCompositedSize(compositionScreenSize)); + + iTestName.Format(_L("GRAPHICS_WSERV_CSC_102")); + INFO_PRINTF2(_L("%S"),&iTestName); + + iDisplayMode = iScreenDevice->DisplayMode(); + + TRAPD(err, surfaceID = iUtility->CreateSurfaceL(compositionScreenSize, + KSurfaceFormat, + compositionScreenSize.iWidth * KBytesPerPixel)); + ASSERT_EQUALS(err,KErrNone); + + ConstructOpaqueWindowLC(testWindow, + iWhite, + 0, + TPoint(0, 0), + compositionScreenSize); + + iSession.Flush(); + Pause(100); + + CFbsBitmap *bmp1 = new (ELeave) CFbsBitmap; + CleanupStack::PushL(bmp1); + User::LeaveIfError(bmp1->Create(compositionScreenSize, EColor16MU)); + + // Invalid bitmap display mode + CFbsBitmap *bmp2 = new (ELeave) CFbsBitmap; + CleanupStack::PushL(bmp2); + User::LeaveIfError(bmp2->Create(compositionScreenSize, EColor256)); + + iSession.Flush(); + Pause(500); + + // Draw a pattern using WServ + SetBackgroundColorWindow(testWindow, iWhite); + + TSize rectSize(100, 100); + testWindow.Invalidate(); + testWindow.BeginRedraw(); + iGc->Activate(testWindow); + iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + iGc->SetBrushColor(KRgbDarkRed); + iGc->DrawRect(TRect(TPoint(35, 5), rectSize)); + iGc->SetBrushColor(KRgbBlack); + iGc->DrawRect(TRect(TPoint(55, 15), rectSize)); + iGc->SetBrushColor(KRgbDarkBlue); + iGc->DrawRect(TRect(TPoint(75, 35), rectSize)); + iGc->SetBrushColor(KRgbYellow); + iGc->DrawRect(TRect(TPoint(95, 55), rectSize)); + iGc->Deactivate(); + testWindow.EndRedraw(); + iSession.Flush(); + Pause(500); + + iScreenDevice->CopyScreenToBitmap(bmp1); + iSession.Flush(); + Pause(100); + + ConstructOpaqueSurfacedWindowLC(surfacedTestWindow, + iRed, + 0, + TPoint(0, 0), + compositionScreenSize, + surfaceID); + + TRAP(err,iUtility->FillSurfaceL(surfaceID, iCyan)); + ASSERT_EQUALS(err,KErrNone); + iSession.Flush(); + Pause(500); + + TRAP(err, iUtility->CopyBitmapToSurfaceL(surfaceID, *bmp1)); + ASSERT_EQUALS(err,KErrNone); + iSession.Flush(); + Pause(500); + + // negative test, it should fail wit KErrArgument + TInt ret = csc->ComposeScreen(*bmp2); + ASSERT_EQUALS(ret, KErrArgument); + + iUtility->DestroyAll(); + CleanupStack::PopAndDestroy(&surfacedTestWindow); + CleanupStack::PopAndDestroy(bmp2); + CleanupStack::PopAndDestroy(bmp1); + CleanupStack::PopAndDestroy(&testWindow); + iSession.Flush(); + Pause(1000); + } + +/** + @SYMTestCaseID GRAPHICS_WSERV_CSC_105L + @SYMTestCaseDesc Correct bitmap size returned when in small screen mode + @SYMDEF DEF139191 + @SYMPREQ CSC + @SYMTestStatus Implemented + @SYMTestPriority 1 + @SYMTestPurpose Checking GetCompositedSize is correct on gce & acceptable behaviour in non gce mode + @SYMTestActions For every available screen mode + Get size from GetCompositedSize + Draw some coloured rectangles on screen + If gce, do a full screen surface, and paste the coloured rectangles into the surface + ComposeScreen - bitmap 1 should be the same as bitmap 2 + Note - non GCE mode - GetCompositedSize returns unrotated appmode size, so only + compares the intersection of that with actual screen size + Note - gce mode - GetCompositedSize returns actual rotated screen size, so + does a complete screen comparison + @SYMTestExpectedResults All asserts should complete. Comparison should succeed! +*/ +void CWSGceCsc::GRAPHICS_WSERV_CSC_105L() + { + iTestName.Format(_L("GRAPHICS_WSERV_CSC_105")); + INFO_PRINTF2(_L("%S"),&iTestName); + TInt err; + //get list of modes + RArray screenModes; + err = iScreenDevice->GetScreenSizeModeList(&screenModes); + ASSERT_TRUE (err > 0); + //get first mode info + TPixelsAndRotation firstModeInfo; + iScreenDevice->GetScreenModeSizeAndRotation(screenModes[0],firstModeInfo); + + //make sure csc is available + MTestScreenCapture* csc = static_cast (iScreenDevice->GetInterface(MTestScreenCapture::KUidTestScreenCaptureIf)); + ASSERT_NOT_NULL(csc); + + TBool differentSizes = EFalse; + TSizeMode currentModeInfo; + TSize compositionScreenSize; + //for every screen mode + for (TInt ii = 0; ii < screenModes.Count(); ++ii && !differentSizes) + { + //set mode + iScreenDevice->SetAppScreenMode(screenModes[ii]); + iScreenDevice->SetScreenMode(screenModes[ii]); + iSession.Flush(); + Pause(100); + //get mode info + currentModeInfo = iScreenDevice->GetCurrentScreenModeAttributes(); + if (currentModeInfo.iScreenSize.iWidth != firstModeInfo.iPixelSize.iWidth || + currentModeInfo.iScreenSize.iHeight != firstModeInfo.iPixelSize.iHeight || + currentModeInfo.iRotation != firstModeInfo.iRotation) + { //note that we have modes of different sizes / rotations + differentSizes = ETrue; + } + + RWindow testWindow(iSession); + RWindow surfacedTestWindow(iSession); + TSurfaceId surfaceID; + + err = csc->GetCompositedSize(compositionScreenSize); + ASSERT_EQUALS (err,KErrNone); + iDisplayMode = iScreenDevice->DisplayMode(); + + if (GCEIsSupported()) + { //create a surface + TRAP(err, surfaceID = iUtility->CreateSurfaceL(compositionScreenSize, + KSurfaceFormat, + compositionScreenSize.iWidth * KBytesPerPixel)); + ASSERT_EQUALS(err,KErrNone); + } + + //create a basic window + ConstructOpaqueWindowLC(testWindow, + iWhite, + 0, + -currentModeInfo.iOrigin, + compositionScreenSize); //negative origin to ensure it fills screen, not app mode area + iSession.Flush(); + Pause(100); + + //bitmap 1 to compare against + CFbsBitmap *bmp1 = new (ELeave) CFbsBitmap; + CleanupStack::PushL(bmp1); + User::LeaveIfError(bmp1->Create(compositionScreenSize, EColor16MU)); + //bitmap 2 to pass into csc + CFbsBitmap *bmp2 = new (ELeave) CFbsBitmap; + CleanupStack::PushL(bmp2); + User::LeaveIfError(bmp2->Create(compositionScreenSize, EColor16MU)); + + //draw coloured rectangles in the test window + SetBackgroundColorWindow(testWindow, iWhite); + DrawBasicPattern (testWindow); + + //copy screen to bitmap 1 + err = iScreenDevice->CopyScreenToBitmap(bmp1); + ASSERT_EQUALS (err,KErrNone); + iSession.Flush(); + Pause(100); + + if (GCEIsSupported()) + { //place a window with a surface into the screen + ConstructOpaqueSurfacedWindowLC(surfacedTestWindow, + iRed, + 0, + -currentModeInfo.iOrigin, + compositionScreenSize, + surfaceID); //negative origin to ensure it fills screen,not app mode area + + //make surface boring cyan + TRAP(err,iUtility->FillSurfaceL(surfaceID, iCyan)); + ASSERT_EQUALS(err,KErrNone); + iSession.Flush(); + Pause(300); + + //paste bitmap 1 contents into the surface + TRAP(err, iUtility->CopyBitmapToSurfaceL(surfaceID, *bmp1)); + ASSERT_EQUALS(err,KErrNone); + iSession.Flush(); + Pause(300); + } + + //use csc to get a copy of the screen + err = csc->ComposeScreen(*bmp2); + ASSERT_EQUALS (err, KErrNone); + + //should match the original bitmap copy of the screen + ASSERT_TRUE(Compare(*bmp1, *bmp2)); + + if (GCEIsSupported()) + { + iUtility->DestroyAll(); + CleanupStack::PopAndDestroy(&surfacedTestWindow); + } + else + { + surfacedTestWindow.Close(); + } + CleanupStack::PopAndDestroy(bmp2); + CleanupStack::PopAndDestroy(bmp1); + CleanupStack::PopAndDestroy(&testWindow); + iSession.Flush(); + Pause(300); + } + if (!differentSizes) + { + INFO_PRINTF1(_L("Didn't find screen modes of different sizes - test inconclusive")); + } + iScreenDevice->SetAppScreenMode(screenModes[0]); + iScreenDevice->SetScreenMode(screenModes[0]); + screenModes.Close(); + } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tcsc/cwsgcecsc.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tcsc/cwsgcecsc.h Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* @file +* +* +*/ + + + +#ifndef CWSGCECSC_H_ +#define CWSGCECSC_H_ + +#include +#include +#include "cwsgcecscbase.h" + +class CWSGceCsc : public CWsGceCscBase +{ +private: + +public: + CWSGceCsc(); + virtual ~CWSGceCsc(); + static CTestSuite* CreateSuiteL(const TDesC &aName); + virtual void SetupL(); + virtual void TearDownL(); + void GRAPHICS_WSERV_CSC_101L(); + void GRAPHICS_WSERV_CSC_102L(); + void GRAPHICS_WSERV_CSC_103L(); + void GRAPHICS_WSERV_CSC_104L(); + void GRAPHICS_WSERV_CSC_105L(); +private: + void DrawBasicPattern (RWindow& aWin); +public: + +private: +}; + +#endif /*CWSGCECSC_H_*/ diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tcsc/cwsgcecscbase.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tcsc/cwsgcecscbase.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,400 @@ +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// @file +// +// + +#include +#include +#include +#include +#include +#include "teflogextensions.h" +#include "globalsettings.h" +#include "CWsGceCscBase.h" +#include +#include +#include +#include + + +CWsGceCscBase::CWsGceCscBase(): +iDoTearDown(EFalse), +iUtility(this, NULL) +{ +} + +CWsGceCscBase::~CWsGceCscBase() +{ +if (iDoTearDown) + TearDownFromDeleteL(); //This mechanism is not entirely clean to use. +} + +void CWsGceCscBase::SetupL() +{ +iDoTearDown=ETrue; +iRed.SetInternal(0xFFFF0000); +iGreen.SetInternal(0xFF00FF00); +iBlue.SetInternal(0xFF0000FF); +iCyan.SetInternal(0xFF00FFFF); +iMagenta.SetInternal(0xFFFF00FF); +iYellow.SetInternal(0xFFFFFF00); +iWhite.SetInternal(0xFFFFFFFF); + +ASSERT_EQUALS_X(iSession.Connect(), KErrNone); + + {//Stolen from TAuto CloseAllPanicWindows() + TInt idFocus = iSession.GetFocusWindowGroup(); + TWsEvent event; + event.SetType(EEventKey); //EEventKeyDown + TKeyEvent *keyEvent = event.Key(); + keyEvent->iCode = EKeyEscape; + keyEvent->iScanCode = EStdKeyEscape; + keyEvent->iModifiers = 0; + TInt theLimit = 50; + while(idFocus != NULL && (theLimit-- > 0)) + { + iSession.SendEventToAllWindowGroups(event); + TInt idNewFocus = iSession.GetFocusWindowGroup(); + if (idNewFocus!=idFocus) + { + INFO_PRINTF1(_L("A window was closed [probably a panic box from the previous test].")); + } + idFocus=idNewFocus; + } + } +TInt err = KErrNone; + +TRAP(err, iScreenDevice = new (ELeave) CWsScreenDevice(iSession)); +PRINT_ON_ERROR2_L(err, _L("Failed to create screen device: %d"), err); +ASSERT_EQUALS_X(iScreenDevice->Construct(TGlobalSettings::Instance().iScreen), KErrNone); +iDisplayMode = iScreenDevice->DisplayMode(); // Get default display mode + +TRAP(err, iGc = new (ELeave) CWindowGc(iScreenDevice)); +PRINT_ON_ERROR2_L(err, _L("Failed to create graphics context: %d"), err); +ASSERT_EQUALS_X(iGc->Construct(), KErrNone); + +iGroup = RWindowGroup(iSession); +ASSERT_EQUALS_X(iGroup.Construct(++iWindowHandle,iScreenDevice), KErrNone); +iSession.Flush(); + +RWindow testTrans(iSession); +ASSERT_EQUALS_X(testTrans.Construct(iGroup, ++iWindowHandle), KErrNone); +iTransparencyEnabled=(testTrans.SetTransparencyFactor(iWhite)==KErrNone); +testTrans.Close(); + +//clean-up if previous test abended + if (PostTestCleanupInstance().iSharedUtility) + { +//Temp removed - may be causing ONB fails! +// if (PostTestCleanupInstance().iSharedUtility->DestroyAll()) +// { +// INFO_PRINTF1(_L("Destroyed some surfaces from previous test.")); +// +// } + } + if (!PostTestCleanupInstance().iCleanedUpOnExit) + PostTestCleanupInstance().iCleanedUpOnExit=EFalse; + + if (!GCEIsSupported()) + { + INFO_PRINTF1(_L("Some Setup skipped: GCE support is not loaded")); + return; + } + + TRAPD(err_FailedToCreateSurfaceUtility, iUtility = CSurfaceUtility::NewL( PostTestCleanupInstance().iSharedUtility)); + ASSERT_EQUALS(err_FailedToCreateSurfaceUtility,KErrNone); + +} + +void CWsGceCscBase::TearDownL() +{ +iDoTearDown=EFalse; +delete iGc; +delete iScreenDevice; + +iGroup.Close(); +iSession.Flush(); +iSession.Close(); + +delete iUtility(); +PostTestCleanupInstance().iCleanedUpOnExit=ETrue; +Pause(1000); +} + +void CWsGceCscBase::TearDownFromDeleteL() +{ +CWsGceCscBase::TearDownL(); +} + +void CWsGceCscBase::Pause(TInt aMilliseconds) +{ +User::After(TTimeIntervalMicroSeconds32(aMilliseconds * 1000)); +} + +/** Test using an indipendent method that GCE version of WServ is running + * This method can only be called after the testcase is started + * + * @return true if WServ version is GCE technology, false if legacy technology + **/ +TBool CWsGceCscBase::GCEIsSupported() const + { + CFbsDrawDevice* screenDevice=NULL; + TDisplayMode displayMode=iScreenDevice->DisplayMode(); + TRAPD(err, screenDevice = CFbsDrawDevice::NewScreenDeviceL(TGlobalSettings::Instance().iScreen, displayMode)); + TBool rv=EFalse; + if(err == KErrNone) + { + TAny* p=NULL; + rv=(screenDevice->GetInterface(KSurfaceInterfaceID, p)==KErrNone); + delete screenDevice; + } + return rv; + } +/** Test using an indipendent method that GCE version of WServ is running + * This method can be called at any time, even by external code, but creates temporary window session objects + * + * @return true if WServ version is GCE technology, false if legacy technology + **/ +TBool CWsGceCscBase::GCEIsSupportedStatic() + { + CFbsDrawDevice* screenDevice=NULL; + RWsSession session; + if (session.Connect()!=KErrNone) + { + return EFalse; + } + CWsScreenDevice screen(session); + if (screen.Construct(TGlobalSettings::Instance().iScreen)!=KErrNone) + { + return EFalse; + } + + TDisplayMode displayMode=screen.DisplayMode(); + TRAPD(err, screenDevice = CFbsDrawDevice::NewScreenDeviceL(TGlobalSettings::Instance().iScreen, displayMode)); + TBool rv=EFalse; + if(err == KErrNone) + { + TAny* p=NULL; + rv=(screenDevice->GetInterface(KSurfaceInterfaceID, p)==KErrNone); + delete screenDevice; + } + return rv; + } + +//Allocating an instance of surface utility here means all test code instances will share the same instance of the utility class. +// Owns the singleton +CWsGceCscBase::TPostTestCleanup& CWsGceCscBase::PostTestCleanupInstance() + { + static + class RPostTestCleanup:public TPostTestCleanup + { + public: + RPostTestCleanup() + { + iSharedUtility=NULL; + iCleanedUpOnExit=ETrue; + } + ~RPostTestCleanup() + { + // I want to cleanly release the surface utility, but at this point the threads have already been pulled down! + // if (iSharedUtility) + // delete iSharedUtility; + iSharedUtility=NULL; //avoid phoenix behaviour + } + } staticInstance; + return staticInstance; + } + +// This handles any non-member uses of the extended ASSERT_XXX macros +extern void TefUnitFailLeaveL(); +/** + * side-effect: log the state info just before I leave! + * Note that this only logs intentional assertion failures. + * Fails due to panics or throws won't log this info. + **/ +void CWsGceCscBase::TefUnitFailLeaveL() + { + for (TInt line=0;lineaHostBuffer.MaxLength()) + { + return reqSize/aObjectSize; + } + if (reqSize==0) + { + reqSize=aHostBuffer.MaxLength(); + } + if ((reqSize%aObjectSize)!=0) + { + return KErrCorrupt; + } + aReturnedObject=(const void*)aHostBuffer.Ptr(); + reqSize/=aObjectSize; + return reqSize; + } + +void CWsGceCscBase::SetCompositionMode(RWindow& aWindow, TDisplayMode aMode) + { + iDisplayMode = (TDisplayMode)aWindow.SetRequiredDisplayMode(aMode); + aWindow.Invalidate(); + aWindow.BeginRedraw(); + aWindow.EndRedraw(); + } + +TBool CWsGceCscBase::Compare(CFbsBitmap& aBitmap1, CFbsBitmap& aBitmap2) + { + if ((aBitmap1.SizeInPixels() == aBitmap2.SizeInPixels()) && + (aBitmap1.DisplayMode() == aBitmap2.DisplayMode())) + { + TSize size = aBitmap1.SizeInPixels(); + TInt width = size.iWidth; + TInt height = size.iHeight; + TRgb color1, color2; + + for (TInt i = 0; i < width; i++) + { + for (TInt j = 0; j < height; j++) + { + aBitmap1.GetPixel(color1, TPoint(i, j)); + aBitmap2.GetPixel(color2, TPoint(i, j)); + if (color1 != color2) + { + return EFalse; + } + } + } + + return ETrue; + } + return EFalse; + } + +void CWsGceCscBase::ConstructOpaqueWindowL(RWindow& aWindow, + const TRgb& aColor, + TInt aPos, + const TPoint &aPoint, + const TSize &aSize) + { + ASSERT_EQUALS_X(aWindow.Construct(iGroup, ++iWindowHandle), KErrNone); + aWindow.SetRequiredDisplayMode(iDisplayMode); + aWindow.SetExtent(aPoint, aSize); + aWindow.SetBackgroundColor(aColor); + aWindow.SetOrdinalPosition(aPos); + aWindow.Activate(); + aWindow.BeginRedraw(); + iGc->Activate(aWindow); + iGc->Deactivate(); + aWindow.EndRedraw(); + } + +void CWsGceCscBase::ConstructOpaqueWindowLC(RWindow& aWindow, + const TRgb& aColor, + TInt aPos, + const TPoint &aPoint, + const TSize &aSize) + { + ASSERT_EQUALS_X(aWindow.Construct(iGroup, ++iWindowHandle), KErrNone); + CleanupClosePushL(aWindow); + aWindow.SetRequiredDisplayMode(iDisplayMode); + aWindow.SetExtent(aPoint, aSize); + aWindow.SetBackgroundColor(aColor); + aWindow.SetOrdinalPosition(aPos); + aWindow.SetVisible(ETrue); + aWindow.Activate(); + aWindow.BeginRedraw(); + iGc->Activate(aWindow); + iGc->Clear(); + iGc->Deactivate(); + aWindow.EndRedraw(); + } + + +void CWsGceCscBase::SetBackgroundColorWindow(RWindow& aWindow, const TRgb& aColor) + { + aWindow.Invalidate(); + aWindow.SetBackgroundColor(aColor); + aWindow.BeginRedraw(); + iGc->Activate(aWindow); + iGc->Deactivate(); + aWindow.EndRedraw(); + } + +void CWsGceCscBase::ConstructOpaqueSurfacedWindowLC(RWindow& aWindow, + const TRgb& aColor, + TInt aPos, + const TPoint &aPoint, + const TSize &aSize, + TSurfaceId& aSurfaceID) + { + ASSERT_EQUALS_X(aWindow.Construct(iGroup, ++iWindowHandle), KErrNone); + CleanupClosePushL(aWindow); + aWindow.SetRequiredDisplayMode(iDisplayMode); + aWindow.SetExtent(aPoint, aSize); + aWindow.SetBackgroundColor(aColor); + aWindow.SetOrdinalPosition(aPos); + ASSERT_EQUALS_X(aWindow.SetBackgroundSurface(aSurfaceID), KErrNone); + aWindow.Activate(); + aWindow.BeginRedraw(); + iGc->Activate(aWindow); + iGc->Deactivate(); + aWindow.EndRedraw(); + } + +void CWsGceCscBase::ConstructOpaqueSurfacedWindowL(RWindow& aWindow, + const TRgb& aColor, + TInt aPos, + const TPoint& aPoint, + const TSize& aSize, + const TSurfaceId& aSurfaceID) + { + ASSERT_EQUALS_X(aWindow.Construct(iGroup, ++iWindowHandle), KErrNone); + aWindow.SetRequiredDisplayMode(iDisplayMode); + aWindow.SetExtent(aPoint, aSize); + aWindow.SetBackgroundColor(aColor); + aWindow.SetOrdinalPosition(aPos); + ASSERT_EQUALS_X(aWindow.SetBackgroundSurface(aSurfaceID), KErrNone); + aWindow.Activate(); + aWindow.BeginRedraw(); + iGc->Activate(aWindow); + iGc->Deactivate(); + aWindow.EndRedraw(); + } + + diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tcsc/cwsgcecscbase.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tcsc/cwsgcecscbase.h Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,181 @@ +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#ifndef TCWGCECSCBASE_H_ +#define TCWGCECSCBASE_H_ + +#include +#include +#include "surfaceutility.h" +#include + +class TPerfProperties +{ +public: + TBool GetValue(TUint aKey); + void PrintAllL(CTestFixture& aLogger); + TBool ResetValue(TUint aKey); + void UpdateAll(); + void ResetAll(); +private: +#ifdef GCE_BACKEND_PROFILING + TInt iValue[EPerfLastKey]; + TInt iPrevValue[EPerfLastKey]; + const static TBuf<100> propertyKeysTxt[EPerfLastKey]; +#endif +}; + +class CWsGceCscBase: public CTestFixture +{ + +public: + template + class SafePointer + { + public: + SafePointer(LoggerOwner* aOwner,Referee* aReferee=NULL): + iOwner(aOwner), iReferee(aReferee) + {} + Referee* operator=(Referee* aReferee) + { + return iReferee=aReferee; + } + Referee*& operator()() + { + return iReferee; + } + Referee* operator->() + { + if (iReferee==NULL) + { + iOwner -> INFO_PRINTF1(_L("Tried to dereference a pointer that is null!")); + User::Panic(_L("null pointer"),__LINE__); + } + return iReferee; + } + private: + LoggerOwner* iOwner; + Referee* iReferee; + }; + +public: + CWsGceCscBase(); + virtual ~CWsGceCscBase(); + virtual void SetupL(); + virtual void TearDownL(); + virtual void TearDownFromDeleteL(); + +protected: + typedef TBuf TTestName; + + class TPostTestCleanup + { + protected: + TPostTestCleanup() {} + public: + CSurfaceUtility* iSharedUtility; + TBool iCleanedUpOnExit; + }; + + + typedef enum TOptimizationLevel + { + EDisable, + EDetectFrontmostFullScreenOpaqueLayer, + EMaximum, + } TOptimizationLevel; + + +protected: + void SetCompositionMode(RWindow& aWindow, TDisplayMode aMode); + + TBool Compare(CFbsBitmap& aBitmap1, CFbsBitmap& aBitmap2); + + void ConstructOpaqueWindowLC(RWindow& aWindow, + const TRgb& aColor, + TInt aPos, + const TPoint& aPoint, + const TSize& aSize); + + void ConstructOpaqueWindowL(RWindow& aWindow, + const TRgb& aColor, + TInt aPos, + const TPoint& aPoint, + const TSize& aSize); + + void SetBackgroundColorWindow(RWindow& aWindow, const TRgb& aColor); + + void ConstructOpaqueSurfacedWindowLC(RWindow& aWindow, + const TRgb& aColor, + TInt aPos, + const TPoint& aPoint, + const TSize& aSize, + TSurfaceId& aSurfaceID); + void ConstructOpaqueSurfacedWindowL(RWindow& aWindow, + const TRgb& aColor, + TInt aPos, + const TPoint& aPoint, + const TSize& aSize, + const TSurfaceId& aSurfaceID); + +protected: + inline TInt ObjIndScr(TInt aScreen,TInt aWin=0,TInt aLayer=0,TInt aExtra=0); + template // DataType may be TSurfaceId, TInt,TRect, TSurfaceConfiguration (not TRegion) + TInt DebugInfo(TWsDebugInfoFunc aFunction, TInt aObjectIndex, TDes8& aHostBuffer,const DataType*&aReturnedObject)const + { + return DebugInfo(aFunction,aObjectIndex,aHostBuffer,(const void*&)aReturnedObject,sizeof(DataType)); + } + TInt DebugInfo(TWsDebugInfoFunc aFunction, + TInt aParam, + TDes8& aHostBuffer, + const void*&aReturnedObject, + TInt aObjectSize)const; + void TefUnitFailLeaveL(); + static void Pause(TInt aMilliseconds=200); + TBool GCEIsSupported() const; + static TBool GCEIsSupportedStatic(); + static TPostTestCleanup& PostTestCleanupInstance(); + +protected: + TBool iDoTearDown; + RWsSession iSession; + RWindowGroup iGroup; + CWsScreenDevice* iScreenDevice; + CWindowGc* iGc; + TInt iWindowHandle; + TBool iTransparencyEnabled; + TRgb iRed, iGreen, iBlue, iCyan, iMagenta, iYellow, iWhite; + TDisplayMode iDisplayMode; + SafePointer iUtility; + static const TInt KMaxInfoLines=5; + TTestName iTestInfo[KMaxInfoLines]; + TTestName iTestName; + static const TUidPixelFormat KSurfaceFormat = EUidPixelFormatXRGB_8888; + static const TInt KBytesPerPixel = 4; // Four bytes per pixel for the format above. + TPerfProperties iProperties; +}; + +inline TInt CWsGceCscBase::ObjIndScr(TInt aScreen, + TInt aWin, + TInt aLayer, + TInt aExtra) + { + return (aScreen< +#include "cwsgcecsc.h" + +_LIT( KServerName, "wsgcecscserver" ); + +GLDEF_C const TTestName ServerName() +/** + * ServerName + * + * @return - The TEF server name + */ + { + TTestName serverName(KServerName); + return serverName; + } + + +GLDEF_C CTestSuite* CreateTestSuiteL() +/** + * Create the overall test suite. + * + * @return - The top level suite + */ + { + START_SUITE; + ADD_TEST_SUITE(CWSGceCsc); + END_SUITE; + } + + +GLDEF_C CTestStep* CreateTEFTestStep(const TDesC& /*aStepName*/, CTEFUnitServer& /* aServer */) +/** + * Create individual test steps, outside the suite. + */ + { + // Initialise test step object to NULL if no TEF step is found + CTestStep* testStep = NULL; + + + + return testStep; + } + diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tcsc/tcsc.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tcsc/tcsc.iby Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +rem Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). + +#if (!defined __TCSC_IBY__) +#define __TCSC_IBY__ + +#include +#define WSERV_TEST_WSINI WSERV_TEST_WSINI_CSC + +#include + +// Display channel test server and test script +file=ABI_DIR\DEBUG_DIR\wsgcecscserver.exe \sys\bin\wsgcecscserver.exe +data=EPOCROOT##epoc32\data\z\wstest\wscsc.script \wstest\wscsc.script + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tcsc/wscsc.script --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tcsc/wscsc.script Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,31 @@ +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// WsGcePerformance.script +// + +LOAD_SUITE wsgcecscserver + +// Run the tests as specified by the wrapping script +// RUN_TEST_STEP 100 wsgcecscserver TEFUnit.CGlobalSettings.Report + +//////////////// +// CSC NGA tests +//////////////// +RUN_TEST_STEP 500 wsgcecscserver TEFUnit.CWSGceCsc.GRAPHICS_WSERV_CSC_101L +RUN_TEST_STEP 500 wsgcecscserver TEFUnit.CWSGceCsc.GRAPHICS_WSERV_CSC_102L +RUN_TEST_STEP 500 wsgcecscserver TEFUnit.CWSGceCsc.GRAPHICS_WSERV_CSC_103L +// Negative test cases +RUN_TEST_STEP 500 wsgcecscserver TEFUnit.CWSGceCsc.GRAPHICS_WSERV_CSC_104L +// Defect test cases +RUN_TEST_STEP 500 wsgcecscserver TEFUnit.CWSGceCsc.GRAPHICS_WSERV_CSC_105L diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tcsc/wscscclassic.script --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tcsc/wscscclassic.script Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,27 @@ +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// WsGcePerformance.script +// + +LOAD_SUITE wsgcecscserver + +// Run the tests as specified by the wrapping script +// RUN_TEST_STEP 100 wsgcecscserver TEFUnit.CGlobalSettings.Report + +//////////////// +// CSC related tests +//////////////// +RUN_TEST_STEP 500 wsgcecscserver TEFUnit.CWSGceCsc.GRAPHICS_WSERV_CSC_101L +RUN_TEST_STEP 500 wsgcecscserver TEFUnit.CWSGceCsc.GRAPHICS_WSERV_CSC_103L +RUN_TEST_STEP 500 wsgcecscserver TEFUnit.CWSGceCsc.GRAPHICS_WSERV_CSC_105L diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tdynamicres/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tdynamicres/group/bld.inf Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,41 @@ +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// @file +// @test +// @internalComponent +// +// + + +PRJ_TESTMMPFILES +#ifndef SMP +#ifdef SYMBIAN_BUILD_GCE +tdynamicres.mmp +#endif // SYMBIAN_BUILD_GCE +tdynamicresclassic.mmp +#endif // SMP +PRJ_TESTEXPORTS + +#ifdef SYMBIAN_BUILD_GCE +../scripts/wsdynamicresbasic_no_scaling.script z:/wstest/dynamicres/wsdynamicresbasic_no_scaling.script +../scripts/wsdynamicresbasic_integer_scaling.script z:/wstest/dynamicres/wsdynamicresbasic_integer_scaling.script +../scripts/wsdynamicresbasic_isotropic_scaling.script z:/wstest/dynamicres/wsdynamicresbasic_isotropic_scaling.script +../scripts/wsdynamicresbasic_anisotropic_scaling.script z:/wstest/dynamicres/wsdynamicresbasic_anisotropic_scaling.script +../scripts/wsdynamicresbasic_openvg_isotropic.script z:/wstest/dynamicres/wsdynamicresbasic_openvg_isotropic.script +#endif // SYMBIAN_BUILD_GCE +wstestdynamicres.iby /epoc32/rom/include/wstestdynamicres.iby +../scripts/wsdynamicresclassic.script z:/wstest/dynamicres/wsdynamicresclassic.script + + + diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tdynamicres/group/tdynamicres.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tdynamicres/group/tdynamicres.mmp Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,65 @@ +// Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file +*/ + +TARGET wsdynamicrestestserver.exe +TARGETTYPE exe +UID 0x1000007A 0x102864B7 + +// For setting the screen mode and registering GUID CRPs +CAPABILITY PowerMgmt WriteDeviceData SwEvent ProtServ +SOURCEPATH ../src + +SOURCE globalsettings.cpp +SOURCE screenselect.cpp +SOURCE surfaceutility.cpp +SOURCE wsgcedebugsession.cpp + +SOURCE t_wsdynamicrestestserver.cpp +SOURCE t_wsdynamicreswinbase.cpp + +SOURCE wsdynamicresbase.cpp +SOURCE wsdynamicresbasic.cpp + +USERINCLUDE ../inc +USERINCLUDE ../../../SERVER ../../../nga/SERVER ../../../inc + +OS_LAYER_SYSTEMINCLUDE + +MACRO SYMBIAN_GRAPHICS_GCE + +STATICLIBRARY tefunit.lib +LIBRARY euser.lib +LIBRARY estlib.lib +LIBRARY testexecuteutils.lib +LIBRARY testexecutelogclient.lib +LIBRARY rfileloggerclient.lib +LIBRARY ws32.lib +LIBRARY surfacemanager.lib +LIBRARY surfaceupdateclient.lib +LIBRARY imageconversion.lib +LIBRARY efsrv.lib +LIBRARY fbscli.lib +LIBRARY gdi.lib +LIBRARY bitgdi.lib +LIBRARY hal.lib +LIBRARY scdv.lib +//LIBRARY samplegraphicsurface.lib w32stdgraphic.lib samplegraphictestsurfacemulti.lib + + +SMPSAFE diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tdynamicres/group/tdynamicresclassic.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tdynamicres/group/tdynamicresclassic.mmp Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,45 @@ +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file +*/ + +TARGET wsdynamicresclassictestserver.exe +TARGETTYPE exe +UID 0x1000007A 0x102864B8 + +// For setting the screen mode and registering GUID CRPs +CAPABILITY PowerMgmt WriteDeviceData SwEvent ProtServ +SOURCEPATH ../src +SOURCE t_wsdynamicresclassictestserver.cpp +SOURCE wsdynamicresclassic.cpp + +USERINCLUDE ../inc + +MW_LAYER_SYSTEMINCLUDE_SYMBIAN +OS_LAYER_SYSTEMINCLUDE_SYMBIAN +OS_LAYER_LIBC_SYSTEMINCLUDE + + +STATICLIBRARY tefunit.lib +LIBRARY euser.lib +LIBRARY estlib.lib +LIBRARY testexecuteutils.lib +LIBRARY testexecutelogclient.lib +LIBRARY rfileloggerclient.lib +LIBRARY ws32.lib + +SMPSAFE diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tdynamicres/group/wstestdynamicres.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tdynamicres/group/wstestdynamicres.iby Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,44 @@ +// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// WSLog.iby +// +// + +#ifndef __WSTESTDYNAMICRES_IBY__ +#define __WSTESTDYNAMICRES_IBY__ + +REM Window Server Dynamic Resolution Test Scripts [no plugins] + +//All these test scripts are copied to the rom. +//Please execute only the tests appropriate to your hardware capabilities. + +//The following test script asserts that the simplest tests to open the new interfaces will fail. +//The Symbian reference H4 does not implement MDisplayControl, but some vendors may create their own support. +file=ABI_DIR\DEBUG_DIR\wsdynamicresclassictestserver.exe System\Libs\wsdynamicresclassictestserver.exe +data=DATAZ_\wstest\dynamicres\wsdynamicresclassic.script wstest\dynamicres\wsdynamicresclassic.script + +//Note the following scripts expect H4 GCE to support MDisplayControl. +//They also optionally benefit from having screen capture installed (dll and wsini.ini) +//The Symbian reference H4 does not implement MDisplayControl, but some vendors may create their own support. +//These represent tests that apply to different scaling modes as specified in wsini.ini +#ifdef SYMBIAN_GRAPHICS_USE_GCE +file=ABI_DIR\DEBUG_DIR\wsdynamicrestestserver.exe System\Libs\wsdynamicrestestserver.exe +data=DATAZ_\wstest\dynamicres\wsdynamicresbasic_anisotropic_scaling.script wstest\dynamicres\wsdynamicresbasic_anisotropic_scaling.script +data=DATAZ_\wstest\dynamicres\wsdynamicresbasic_integer_scaling.script wstest\dynamicres\wsdynamicresbasic_integer_scaling.script +data=DATAZ_\wstest\dynamicres\wsdynamicresbasic_isotropic_scaling.script wstest\dynamicres\wsdynamicresbasic_isotropic_scaling.script +data=DATAZ_\wstest\dynamicres\wsdynamicresbasic_no_scaling.script wstest\dynamicres\wsdynamicresbasic_no_scaling.script +data=DATAZ_\wstest\dynamicres\wsdynamicresbasic_openvg_isotropic.script wstest\dynamicres\wsdynamicresbasic_openvg_isotropic.script +#endif + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tdynamicres/group/wstestdynamicres_helium.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tdynamicres/group/wstestdynamicres_helium.pkg Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,46 @@ +; Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +; All rights reserved. +; This component and the accompanying materials are made available +; under the terms of "Eclipse Public License v1.0" +; which accompanies this distribution, and is available +; at the URL "http://www.eclipse.org/legal/epl-v10.html". +; +; Initial Contributors: +; Nokia Corporation - initial contribution. +; +; Contributors: +; +; Description: +; +;File: bitgdi.pkg; +; +;*Languages +&EN +; +;*Standard SIS file header. This section specifies the package name, +;application UID, and version/build numbers. Add the package TYPE here if needed. +#{"WsTestDynamicRes"},(0x101FB3E8),1,0,1; +; + +;*Unique (Non-Localized) Vendor name +;This is used in combination with signing to prevent the unauthroized +;upgrade of a a package by someone other than the rightful vendor. +:"Nokia" + +;*Localized Vendor Name +;This specifies the localized vendor name(s) corresponding to language(s). +%{"Nokia Test EN"} + +;*Files To Copy... + +;REM Window Server Dynamic Resolution Test Scripts [no plugins] + +;//Please execute only the tests appropriate to your hardware capabilities. +"..\scripts\wsdynamicresclassic.script"-"c:wstest\dynamicres\wsdynamicresclassic.script" + +"..\scripts\wsdynamicresbasic_anisotropic_scaling.script"-"c:wstest\dynamicres\wsdynamicresbasic_anisotropic_scaling.script" +"..\scripts\wsdynamicresbasic_integer_scaling.script"-"c:wstest\dynamicres\wsdynamicresbasic_integer_scaling.script" +"..\scripts\wsdynamicresbasic_isotropic_scaling.script"-"c:wstest\dynamicres\wsdynamicresbasic_isotropic_scaling.script" +"..\scripts\wsdynamicresbasic_no_scaling.script"-"c:wstest\dynamicres\wsdynamicresbasic_no_scaling.script" +"..\scripts\wsdynamicresbasic_openvg_isotropic.script"-"c:wstest\dynamicres\wsdynamicresbasic_openvg_isotropic.script" + diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tdynamicres/inc/globalsettings.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tdynamicres/inc/globalsettings.h Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,52 @@ +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Test class that allows a script to set global values +// +// + +#ifndef __GLOBALSETTINGS_H__ +#define __GLOBALSETTINGS_H__ + +#include +#include +#include +class CTestExecuteLogger; + +class TGlobalSettings + { +public: + static const TGlobalSettings& Instance(); + +public: + TInt iScreen; + TBool iDisconnected; //This value might be changed from CWsDynamicResWinBase::SetupL + }; //once the screen has been connected. + +class CGlobalSettings : public CTestFixture + { +public: + static const TGlobalSettings& Instance(); + + // SetUp and TearDown code + + // Create a suite of all the tests + static CTestSuite* CreateSuiteL(const TDesC& aName); + + //these tests are public to allow the old CScreenSelect to get to them! + void SetScreenNoL(TInt aScreenNo); + void ExpectDisconnectedScreenL(TBool aValue); + }; + + +#endif //__GLOBALSETTINGS_H__ diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tdynamicres/inc/screenselect.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tdynamicres/inc/screenselect.h Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* @file +* +* +*/ + + + +#ifndef __SCREEN_SELECT__ +#define __SCREEN_SELECT__ + +#include + +/** +Test step to set a static screen number selection, which can be used to run the +same test code on an alternate screen by simply adding this step and repeating +the test. + +Test steps which support this must use the static CSelectScreen::Number() +function to get the currently selected screen number, and pass this to the +Construct() call for a CWsScreenDevice. +*/ + +class CScreenSelect : public CTestStep + { +public: + CScreenSelect(TInt aScreenNumber, const TDesC& aStepName); + ~CScreenSelect(); + + static TInt Number(); + + virtual TVerdict doTestStepL(); + +private: + TInt iScreenNumber; + }; + +#endif // __SCREEN_SELECT__ + diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tdynamicres/inc/surfaceutility.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tdynamicres/inc/surfaceutility.h Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,108 @@ +/** +* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +/** + @file +*/ + +#ifndef __SURFACE_UTILITY__ +#define __SURFACE_UTILITY__ + +#include +#include +#include +#include + +#define ENABLE_TEST_LOGGING +#define ALPHA_FIX_24BIT 0xffU //This forces a non-zero value into the X byte of 16MU color values + +#if defined(ENABLE_TEST_LOGGING) +#define LOG(X) RDebug::Printf X +#else +#define LOG(X) +#endif + +class TRgb; +class CFbsBitmap; + +class CSurfaceUtility : public CBase + { +public: + static CSurfaceUtility* NewL(CSurfaceUtility* aClone=NULL); + virtual ~CSurfaceUtility(); + TSize SurfaceSize(const TSurfaceId& aSurface); + void CreateSurfaceFromFileL(const TDesC& aFileName, TSurfaceId& aSurface); + TSurfaceId CreateSurfaceL(const TSize& aSize, TUidPixelFormat aPixelFormat, TInt aStride, TInt aBuffers = 1); + TInt BytesPerPixelL(TUidPixelFormat aPixelFormat); + void FillSurfaceL(TSurfaceId& aSurface, const TRgb& aColor); + void FillChunkL(TSurfaceId& aSurface, RChunk& aChunk, const TRgb& aColor, TInt aBufferNumber); + void FillRectangleL(TSurfaceId& aSurface, const TPoint& aStartPos, const TSize& aSize, const TRgb& aColor); + void FillRectangleNoUpdateL(TSurfaceId& aSurface, const TPoint& aStartPos, const TSize& aSize, const TRgb& aColor); + void GridFillSurfaceL(TSurfaceId& aSurface, const TRgb& aColor, const TRgb& aLines); + void PatternFillSurfaceL(TSurfaceId& aSurface); + void FanFillSurfaceL(TSurfaceId& aSurface, const TRgb& aColor, const TRgb& aLinesTL,const TRgb& aLinesBR); + void LineFillSurfaceL(TSurfaceId& aSurface, const TRgb& aBackColor, const TRgb& aLineColor, TInt aPosition); + CFbsBitmap* EquivalentBitmapL(TSurfaceId& aSurface, CFbsBitmap* aCopyTo=NULL); + void DestroySurface(TSurfaceId& aSurface); + TBool DestroyAll(); + void SubmitUpdate(TInt aScreenNumber, const TSurfaceId& aSurface, const TRegion* aRegion, TInt aBufferNumber = 0); + void MapAndSubmitUpdateL(RChunk& aChunk, TInt aScreenNumber, const TSurfaceId& aSurface, const TRegion* aRegion); + void MapSurfaceL(const TSurfaceId& aSurface, RChunk& aChunk); + void CopyBitmapFromFileToSurfaceL(const TDesC& aFileName, TSurfaceId& aSurface); + void CopyBitmapSurfaceL(const CFbsBitmap* aBitmap, TSurfaceId& aSurface); + void CopyBitmapToSurfaceL(TSurfaceId& aSurface, const CFbsBitmap& aBitmap); +private: + CSurfaceUtility(CSurfaceUtility* aClone); + void ConstructL(); + +private: + RSurfaceManager iManager; + RSurfaceUpdateSession iSurfaceUpdateSession; + //This local object wraps the array operations in a heap switch + //The reason for providing this wrapper is to allow threads to share the surface manager surface ID list. + //In particular, the next test can attempt to release the previous test's surfaces if it paniced. + //Note that the presumption is that the owning thread will be paused, + //so there will be no thread interlock issues with it's heap manager. + class RHeapSurfaceArray + { + public: + typedef RArray Array; + RHeapSurfaceArray(RHeapSurfaceArray* aUseExternalArray=NULL); + + //Emulation of RArray entrypoints. Add more stub methods if required... + TSurfaceId& operator[](TUint aIndex); + void Close(); + TInt Count() const; + inline void Reset(); + void AppendL(const TSurfaceId &anEntry); + TInt Find(const TSurfaceId &anEntry) const; + void Remove(TInt anIndex); + + private: + static void PopHeap(void* mainheap); + static void SwitchHeapLC(RHeap* aNewHeap); + + Array iLocalArray; + Array* iUseArray; + RHeap &iExternalHeapRef; + } iSurfaces; + }; + +#endif // __SURFACE_UTILITY__ + diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tdynamicres/inc/t_wsdynamicreswinbase.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tdynamicres/inc/t_wsdynamicreswinbase.h Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,169 @@ +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// twsgcetestwinbase.h +// +// + +#ifndef TWSDYNAMICRESWINBASE_H_ +#define TWSDYNAMICRESWINBASE_H_ + +#include +#include +#include +#include +#include "wsgcedebugsession.h" +struct TWsDebugWindowId; + +/** + * Base class sets up the tryptich of test windows. + * + * + **/ +class CWsDynamicResWinBase : public CTestFixture +{ +public: + CWsDynamicResWinBase(); + virtual ~CWsDynamicResWinBase(); + virtual void SetupL(); + virtual void SetupL(TBool aUseOtherScreenForInfo); + + virtual void TearDownL(); + virtual void TearDownFromDeleteL(); + + static TBool ActivateWithWipe(CWindowGc* aGc,RWindow& aWin,TRgb aColor=TRgb(0,0)); + + /* Note that each derived test class needs to declare a static function to register tests. + * This should match the following prototype: + static CTestSuite* CreateSuiteL( const TDesC& aName ); + */ + +protected: + static void Pause(TInt aMilliseconds=200); + + TBool GCEIsSupported() const; + static TBool GCEIsSupportedStatic(); + + TBool DisplayHasAlpha() const; + TBool SelectChromaCompositionMode(); + TBool SelectAlphaCompositionMode(TDisplayMode aMode = EColor16MA); + TRgb GceHoleColor(RWindowBase& aWin)const; + void DrawUIContent(RWindow& aWindow); + void DrawPlainUI(RWindow& aWindow,TBool aInvalidate,TRgb aWipeColor=TRgb(0,0)); + void DrawCross(RWindow& aWindow, TRgb aColor, TInt aThickness=1); + void TestPixelL(TPoint aPt, TRgb aColor, TBool aMatch); + TBool TestRectL(TRect aRect,TRgb aInnerColor,TInt aOtherInnerColors,TRgb aOuterColor,TInt aOtherOuterColors,TInt aCornerSize); + void MakeTitleAndCompareWindowsL(TRefByValue aTitle,TRefByValue aDetail=_L("")); + void LargerCompareWindow(TBool aGoLarger=ETrue); + void UpdateTitleWindowL(TRefByValue aDetail,TInt aIndex=0); + void RepaintTitleWindowL(); + void TefUnitFailLeaveL(); + CWindowGc* GcForWindow(RWindow& aWin); + TBool InvalidateRegion(const TRegion& aRegion,RWindow& aWin); + CWindowGc* BeginActivateWithWipe(TBool aInvalidate,RWindow& aWin,TRgb aColor=TRgb(0,0)); + CWindowGc* BeginActivateWithWipe(TBool aInvalidate,TRect aRect,RWindow& aWin,TRgb aColor=TRgb(0,0)); + CWindowGc* BeginActivateWithWipe(const TRegion& aRegion,RWindow& aWin,TRgb aColor); + /** Helper method to find a named screen region + * start/end letter should be 'a' to 'y' (yes that includes 'i') + **/ + static TRect PentCellRect(const TRect& aFullRect,char aStartLetter,char aEndLetter=0); + void CheckAndConnectScreen(); + +protected: + static const TInt KSurfaceWidth = 50; + static const TInt KSurfaceHeight = 50; + TBool iDoTearDown; + RWsDebugSession iSession; + RWindowGroup iGroup; + RWindowGroup iInfoGroupInstance; + RWindowGroup* iInfoGroup; + CWsScreenDevice* iScreenDevice; + CWsScreenDevice* iInfoScreenDevice; + CWindowGc* iGc; + CWindowGc* iInfoGc; + TInt iWindowHandle; + static TBool iTransparencyEnabled; + TRgb iRed, iGreen, iBlue, iCyan, iMagenta, iYellow, iWhite; + TRgb TITLE_BACKGROUND; + TRgb COMPARE_BACKGROUND; + RBlankWindow iBackground; + RWindow iCompare; + RWindow iTitle; + TRect iTestPos; + TRect iCenteredFrontWinRect; + TPoint iTestPointCentre; + TDisplayMode iDisplayMode; + static const TInt KMaxTestName = 80; + typedef TBuf TTestName; + mutable TRgb iLastGceHoleColor; + TTestName iTestName; + static const TInt KMaxInfoLines=5; + TTestName iTestInfo[KMaxInfoLines]; + static CActiveScheduler iScheduler; +}; + +// This little helper class checks that the given bytes contain the expected pattern. +namespace Pattern + { + void Fill(void* aTrg,TInt aOffset,TInt aLength); + TBool Check(void* aTrg,TInt aOffset,TInt aLength); + TBool CheckVal(void* aTrg,TInt aOffset,TInt aLength,char val=0); + } + +//This wrapper for the configuration class allows stress testing of the configuration object + +template +class TestExtend: public TXxxConfiguration + { +public: + char iExtraData[aExtraSize]; + TestExtend(): + TXxxConfiguration(aFalseSize) + { + TXxxConfiguration::iSize=aFalseSize; + Pattern::Fill(this,aFalseSize,sizeof(*this)-aFalseSize); + } + void* operator new(unsigned int,TestExtend* inplace) + { //Use this inplace operator new to pre-initialise the memory + return inplace; + } + void operator delete(void*,TestExtend*) + { //Stops the warning! + } + TestExtend(const TXxxConfiguration&i): + TXxxConfiguration(i) + { + Pattern::Check(this,sizeof(TXxxConfiguration),aExtraSize); + } + TBool WasExtraOverwritten() + { + return Pattern::Check(this,sizeof(TXxxConfiguration),aExtraSize); + } + TBool WasFalseSizeOverwritten() + { + return Pattern::Check(this,aFalseSize,sizeof(*this)-aFalseSize); + } + TBool WasFalseSizeZero() + { + return Pattern::CheckVal(this,aFalseSize,sizeof(TXxxConfiguration)-aFalseSize); + } + void StompValue(TInt aOffsetInLongs,TInt aNewValue) + { + *((TInt*)this+aOffsetInLongs)=aNewValue; + } + TInt ReadValue(TInt aOffsetInLongs) + { + return *((TInt*)this+aOffsetInLongs); + } + }; +#endif /*TWSDYNAMICRESWINBASE_H_*/ diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tdynamicres/inc/teflogextensions.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tdynamicres/inc/teflogextensions.h Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,110 @@ +/* +* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* @file +* +* +*/ + + + +#ifndef __TEF_LOG_EXTENSIONS__ +#define __TEF_LOG_EXTENSIONS__ + +#include + +/* +This file contains extensions to the TEF macros used for logging, defined in +tefunit.h. +*/ + +/* +Wrapper to check for an error, then print it and leave with it if not KErrNone. +do ... while (0) ensures the macro can be treated like a single statement. A +macro is used to get the line number information. +Note that p1 will be evaluated once and only once. +*/ +#define PRINT_ON_ERROR2_L(test, p1, p2) \ + do \ + { \ + TInt result = (test); \ + if (result != KErrNone) \ + { \ + Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, (p1), (p2)); \ + User::Leave(result); \ + } \ + } \ + while (0) + +#define PRINT_ON_ERROR3_L(test, p1, p2, p3) \ + do \ + { \ + TInt result = (test); \ + if (result != KErrNone) \ + { \ + Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, (p1), (p2), (p3)); \ + User::Leave(result); \ + } \ + } \ + while (0) + +/* +Modified version of ASSERT_EQUALS() that will log the expression tested, the +expected result and the actual one. +*/ +#define ASSERT_CONDITION(c) _LIT(KExpression, c); + +#define ASSERT_EQUALS_X(aExpression, aExpected) \ + do \ + { \ + TInt result = (TInt)(aExpression); \ + TInt expected = (TInt)(aExpected); \ + if (result != expected) \ + { \ + ASSERT_CONDITION(#aExpression); \ + Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, _L("%S == %d, not %d"), &KExpression(), result, expected ); \ + User::Leave(KErrTEFUnitFail); \ + } \ + } \ + while (0) + +#define ASSERT_NOT_EQUALS_X(aExpression, aUnexpected) \ + do \ + { \ + TInt result = (TInt)(aExpression); \ + TInt unexpected = (TInt)(aUnexpected); \ + if (result == unexpected) \ + { \ + ASSERT_CONDITION(#aExpression); \ + Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, _L("%S == %d, unexpectedly"), &KExpression(), result ); \ + User::Leave(KErrTEFUnitFail); \ + } \ + } \ + while (0) + +#define ASSERT_TRUE_X(aExpression) \ + do \ + { \ + TBool result = (TBool)(aExpression); \ + if (!result) \ + { \ + ASSERT_CONDITION(#aExpression); \ + Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, _L("%S false"), &KExpression() ); \ + User::Leave(KErrTEFUnitFail); \ + } \ + } \ + while (0) + +#endif // __TEF_LOG_EXTENSIONS__ + diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tdynamicres/inc/wsdynamicresbase.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tdynamicres/inc/wsdynamicresbase.h Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,164 @@ +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#ifndef WSDYNAMICRESBASE_H_ +#define WSDYNAMICRESBASE_H_ + +#include "t_wsdynamicreswinbase.h" +#include +#include "surfaceutility.h" + +//************************************ +// +// Asserting wrapper around dereferencing a pointer that might be NULL. +// I don't want to fill the test code with checks that this pointer is not null before calling surface utility methods.... +// +//************************************ + +template +class SafePointer + { +public: + SafePointer(LoggerOwner* aOwner,Referee* aReferee=NULL): + iOwner(aOwner), iReferee(aReferee) + {} + Referee* operator=(Referee* aReferee) + { + return iReferee=aReferee; + } + Referee*& operator()() + { + return iReferee; + } + Referee* operator->() + { + if (iReferee==NULL) + { + iOwner -> INFO_PRINTF1(_L("Tried to dereference a pointer that is null!")); + User::Panic(_L("null pointer"),__LINE__); + } + return iReferee; + } +private: + LoggerOwner* iOwner; + Referee* iReferee; + }; + +/** + * Base class test harness that provides facilities for windowing and surface testing + * + **/ +class CWsDynamicResBase : public CWsDynamicResWinBase +{ +public: + CWsDynamicResBase(); + virtual ~CWsDynamicResBase(); + + virtual void SetupL(); + virtual void SetupL(TBool aUseOtherScreenForInfo); + virtual void TearDownL(); + virtual void TearDownFromDeleteL(); + /* Note that each derived test class needs to declare a static function to register tests. + * This should match the following prototype: + static CTestSuite* CreateSuiteL( const TDesC& aName ); + */ + + protected: + void UISurfaceL(TSurfaceId& aSurfaceId) const; + void CommonSurfaceWindowSetupL(RWindow& aWindow, TSurfaceId& aSurface, const TRgb& aColor); + void CommonOverlayWindowSetupL(RWindow& aWindow, const TRgb& aColor); + void ResizeTestCommonSetupL(RWindow& aWindow, const TRgb& aColor); + + void MakeTestWindowPairL(TRect aOuterRect,TRgb aOuterColor,TRect aInnerRect,TRgb aInnerColor); + void LargerTestWindow(TInt aPercentOfBack=80); + void DestroyTestWindowPair(TBool aKillTestBack=ETrue,TBool aKillTestFront=ETrue,TBool aKillTestChildren=ETrue); + void MakeTestWindowTripleL(TRect aOuterRect,TRgb aOuterColor,TRect aInnerRect,TRgb aInnerColor,TRect aChildRect,TRgb aChildColor,TRect aSecondChildRect,TRgb aSecondChildColor); + void CreateTestWindowQuadL(TRect aOuterRect,TRgb aOuterColor,TRect aInnerRect,TRgb aInnerColor,TRect aChildRect,TRgb aChildColor,TRect aSecondChildRect,TRgb aSecondChildColor); + void MakeTestWindowTripleL(TRect aOuterRect,TRgb aOuterColor,TRect aInnerRect,TRgb aInnerColor,TRect aChildRect,TRgb aChildColor); + void MakeExtraChildWindowL(const RWindowBase& aFromParent,TRect aChildRect,TRgb aChildColor); + struct LoopingGcPtr; + LoopingGcPtr LoopBeginActivateWithWipe(const TRegion& aRegion,RWindow& aWin,TRgb aColor); + CWindowGc* BeginActivateWithWipe(TBool aInvalidate,RWindow& aWin,TRgb aColor=TRgb(0,0)); + CWindowGc* BeginActivateWithWipe(TBool aInvalidate,TRect aRect,RWindow& aWin,TRgb aColor=TRgb(0,0)); + CWindowGc* BeginActivateWithWipe(const TRegion& aRegion,RWindow& aWin,TRgb aColor); + static CFbsBitmap* RotateBitmapLC(const CFbsBitmap* aSrcBitmap); + + void Pause(TInt aMilliseconds); + TInt RegionDiffForUiLayer(TInt aUiLayer); //returns values from TRegionExtend::TOverlapFlags enumeration + enum FastPathMode + { //Tereat this as bit flags or distinct states as you wish. + EFpExternalOpaque=0, + EFpUiOpaque=1, + EFpUiBlended=2, + EFpUiComplex=3, //If ony this is set then both blended and opaque are full=screen + EFpUiRegions=4, //If this FLAG is set then the regions are less than full-screen. Never occurs on its own + EFpUiRegionsOpaque=5, //If this is set then the regions are less than full-screen + EFpUiRegionsBlended=6, //If this is set then the regions are less than full-screen + EFpUiRegionsComplex=7 //This is the expected setting for windowed cr1108 optimisation. + }; + FastPathMode DeduceUiFastPathMode(); +protected: + SafePointer iUtility; + class TPostTestCleanup + { + protected: + TPostTestCleanup() {} + public: + mutable CSurfaceUtility* iSharedUtility; + mutable TBool iCleanedUpOnExit; + void CreateSharedUtilityL()const ; + }; + static const TPostTestCleanup& PostTestCleanupInstance(); + RWindow iTestBack; + RWindow iTestFront; + RWindow iTestChild; + RWindow iTestSecondChild; + static const TUidPixelFormat KSurfaceFormat = EUidPixelFormatXRGB_8888; + static const TInt KBytesPerPixel = 4; // Four bytes per pixel for the format above. +private: + +}; + +struct CWsDynamicResBase::LoopingGcPtr + { + LoopingGcPtr(const TRegion& aRegion,RWindow& aWin,TRgb aColor,CWindowGc *aGc) + : iRegion(aRegion), iWin(aWin), iColor(aColor), iGc(aGc), iPass(-1) + { operator++(); } + LoopingGcPtr(const LoopingGcPtr& aRhs) + : iRegion(aRhs.iRegion), iWin(aRhs.iWin), + iColor(aRhs.iColor), iGc(aRhs.iGc), + iPass(aRhs.iPass) + {} + void operator ++(); + operator bool() { return iPass>=0?iGc:(CWindowGc *)NULL; } + CWindowGc * operator ->() { return iPass>=0?iGc:(CWindowGc *)NULL; } + const TRegion& iRegion; + RWindow& iWin; + TRgb iColor; + CWindowGc *iGc; + TInt iPass; + }; + +#define LOG_AND_PANIC_IF_NOT_GCE \ + { \ + if (!GCEIsSupported()) \ + { \ + INFO_PRINTF1(_L("Test skipped: GCE support is not loaded")); \ + User::Panic(_L("GCE.Wrong.Mode"),1); \ + return; \ + } \ + } + +#endif /*WSDYNAMICRESBASE_H_*/ diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tdynamicres/inc/wsdynamicresbasic.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tdynamicres/inc/wsdynamicresbasic.h Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,187 @@ +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file +*/ + +#ifndef __WSDYNAMICRESBASIC_H__ +#define __WSDYNAMICRESBASIC_H__ + +#include "wsdynamicresbase.h" +#include +#include +#include +#include +/** + * + **/ + +static TBool cSCLogged =EFalse; + + +class CWsDynamicResBasic : public CWsDynamicResBase +{ + typedef CWsDynamicResBase MyBase; +private: + struct TBitmapRegionPair + { + CFbsBitmap* bitmap; + RRegion* region; + TRect drawRect; + }; + +public: + CWsDynamicResBasic(); + virtual ~CWsDynamicResBasic(); + virtual void SetupL(); + virtual void TearDownL(); + virtual void TearDownFromDeleteL(); + + static CTestSuite* CreateSuiteL( const TDesC& aName ); + + void ResetScreens(); + +protected: +//tests + + //BASIC + void GRAPHICS_WSERV_DYNAMICRES_0001L(); + void GRAPHICS_WSERV_DYNAMICRES_0002L(); + void GRAPHICS_WSERV_DYNAMICRES_0003L(); + void GRAPHICS_WSERV_DYNAMICRES_0004L(); + void GRAPHICS_WSERV_DYNAMICRES_0005L(); + void GRAPHICS_WSERV_DYNAMICRES_0006L(); + void GRAPHICS_WSERV_DYNAMICRES_0007L(); + void GRAPHICS_WSERV_DYNAMICRES_0008L(); + void GRAPHICS_WSERV_DYNAMICRES_0009L(); + void GRAPHICS_WSERV_DYNAMICRES_0010L(); + void GRAPHICS_WSERV_DYNAMICRES_0011L(); + void GRAPHICS_WSERV_DYNAMICRES_0012L(); + void GRAPHICS_WSERV_DYNAMICRES_0013L(); + void GRAPHICS_WSERV_DYNAMICRES_0014L(); + void GRAPHICS_WSERV_DYNAMICRES_0015L(); + void GRAPHICS_WSERV_DYNAMICRES_0016L(); + void GRAPHICS_WSERV_DYNAMICRES_0017L(); + void GRAPHICS_WSERV_DYNAMICRES_0018L(); + + //NEGATIVE + void GRAPHICS_WSERV_DYNAMICRES_0021L(TBool aScaleMode); + + //OOM + void GRAPHICS_WSERV_DYNAMICRES_0031L(); + void GRAPHICS_WSERV_DYNAMICRES_0032L(); + void GRAPHICS_WSERV_DYNAMICRES_0033L(); + void GRAPHICS_WSERV_DYNAMICRES_0034L(); + + //SCREEN CAPTURE + void GRAPHICS_WSERV_DYNAMICRES_0041L(TBool aIsSurface); + void GRAPHICS_WSERV_DYNAMICRES_0042L(TBool aIsSurface); + + //DYNAMIC SCREEN MODE + void GRAPHICS_WSERV_DYNAMICRES_0051L(); + void GRAPHICS_WSERV_DYNAMICRES_0052L(); + void GRAPHICS_WSERV_DYNAMICRES_0053L(); + + //DEFECT + void GRAPHICS_WSERV_DYNAMICRES_0101L(); + void GRAPHICS_WSERV_DYNAMICRES_0102L(); + + + void SetRotation (TDisplayConfiguration& aConfig, const MDisplayControl::TResolution& aResolution); + TBool Compare(const CFbsBitmap& aBitmap, const TRect& aRect1, + const TRect& aRect2, RArray& aRegionArray, TBool aIsSurface); + TRgb GreatestColor(TRgb& aColor) const; + +//data members: +private: + CActiveScheduler iScheduler; +}; + +class CWsDisplayEvent : public CActive + { + +public: + CWsDisplayEvent(RWsSession *aWs); + ~CWsDisplayEvent(); + void Request(); + TInt ConfigSpinner() {return iConfigSpinner;} + TInt ResListSpinner() {return iResListSpinner;} + TInt ReceivedEventCount() {return iReceivedEventCount;} + TInt ReceivedDeviceEventCount() {return iReceivedDeviceEventCount;} + TInt ReceivedPointerEventCount() {return iReceivedPointerEventCount;} + void SetExpectedPointPos(const TPoint& aPos) {iPointerPos = aPos;} + TBool PointerTestPassed() {return iPointerPosTestPass;} +protected: + void DoCancel(); + void RunL(); + +private: + RWsSession *iWs; + TInt iConfigSpinner; + TInt iResListSpinner; + TInt iReceivedEventCount; + TInt iReceivedDeviceEventCount; + TInt iReceivedPointerEventCount; + TPoint iPointerPos; + TBool iPointerPosTestPass; + }; + +class CEventTimer : public CActive + { +public: + static CEventTimer* NewL(); + ~CEventTimer(); + void Wait(TInt aDelay); + // From CActive: + void RunL(); + void DoCancel(); + +protected: + CEventTimer(); + void ConstructL(); + protected: +RTimer iTimer; +}; + + + +class CDSATestDrawing: public CTimer, public MDirectScreenAccess + { +public: + + void Draw(); + + + + static CDSATestDrawing* NewL(); + void ConstructL(); + //from MDirectScreenAccess + void Restart(RDirectScreenAccess::TTerminationReasons aReason); + void AbortNow(RDirectScreenAccess::TTerminationReasons aReason); + ~CDSATestDrawing(); + void SetDSA(CDirectScreenAccess *aDSA){iDSA = aDSA;} + void SetWindow(RWindow &aWindow){iWin = &aWindow;} + void StartDrawingL(CDirectScreenAccess *aDSA); + void RunL(); + +private: + CDSATestDrawing(); + TRect iRect; + RWindow* iWin; + CDirectScreenAccess *iDSA; + }; + +#endif /*__WSDYNAMICRESBASIC_H__*/ diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tdynamicres/inc/wsdynamicresclassic.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tdynamicres/inc/wsdynamicresclassic.h Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,39 @@ +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Test class that allows a script to set global values +// +// + +#ifndef __WSDYNAMICRESCLASSIC_H__ +#define __WSDYNAMICRESCLASSIC_H__ + +#include +#include +class CTestExecuteLogger; + +class CWsDynamicResClassic : public CTestFixture + { +public: + static const CWsDynamicResClassic& Instance(); + + // Create a suite of all the tests + static CTestSuite* CreateSuiteL(const TDesC& aName); + +private: + // Private tests + void GRAPHICS_WSERV_DYNAMICRES_0100L(); + }; + + +#endif //__WSDYNAMICRESCLASSIC_H__ diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tdynamicres/inc/wsgcedebugsession.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tdynamicres/inc/wsgcedebugsession.h Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,98 @@ +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#ifndef WSGCEDEBUGSESSION_H_ +#define WSGCEDEBUGSESSION_H_ + +#include +#include +struct TWsDebugWindowId; + +class RWsDebugSession:public RWsSession + { +public: + RWsDebugSession(TInt aScreenNo = -1); + ~ RWsDebugSession(); + using RWsSession::DebugInfo; //exposes the following two functions: +// TInt DebugInfo(TInt aFunction, TInt aParam=0) const; +// TInt DebugInfo(TInt aFunction, TDes8& aReturnBuf, TInt aParam=0) const; + + /** Returns an array of debug data about the specified object. + * The data is placed in the aHostBuffer + * If data is returned, aReturnedObject points to the start of the returned data, and the return value is the number of DataType objects. + * If no data is returned, aReturnedObject is NULL. + * If so the return code indicates an error code, or the required number of objects. + * The object index is specified using the masks and shifts in TWsDebugClassArgMask + * Various error codes may be returned from the server, some of which may simply explain why no data is available. + * The client may return + * KErrCancel to indicate that there is zero length of data + * KErrCorrupt if the size of the returned data is not an exact multiple of DataType. + * No other type checking is performed. + **/ + template // DataType may be TSurfaceId, TInt,TRect, TSurfaceConfiguration (not TRegion) + TInt DebugInfo(TWsDebugInfoFunc aFunction, TInt aObjectIndex, TDes8& aHostBuffer,const DataType*&aReturnedObject)const + { + return DebugInfo(aFunction,aObjectIndex,aHostBuffer,(const void*&)aReturnedObject,sizeof(DataType)); + } + /** Fills the region object with the specified debug information. + * If required the region is resized to fit the data, which may fail with KErrNoMemory + * The region will be forced to error state if an error code is returned. + * Other details: see overloads + **/ + TInt DebugInfo(TWsDebugInfoFunc aFunction, TInt aObjectIndex, TRegion& aPreAllocatedReturnedRegion)const; + + /** Indicates the start of a "consistancy-critical-read" section and fetches the window list. + * Any number of debug commands can be fetched in the section, then client can check if the were interrupted by a server recalculation. + **/ + TInt ResetUpdatedAndGetSurfaceWindowList (const TWsDebugWindowId*&); + /** Indicates the start or end of a "consistancy-critical-read" section + * Any number of debug commands can be fetched in the section, then client can check if the were interrupted by a server recalculation. + * If this method returns ETrue then the data fetched since the start may be inconsistant, and should be refetched. + * This method may also be used as a dirty way of waiting for a deferred update to occur. + **/ + TBool ResetUpdated(); + /** Returns the screen number assigned when the stub was created. + **/ + TInt DebugScreenNo() { return iScreenNo; } + /** Helper method to correctly format the aObjectIndex parameter. + **/ + inline TInt ObjInd(TInt aWin=0,TInt aLayer=0,TInt aExtra=0) + { return ObjIndScr(iScreenNo,aWin,aLayer,aExtra); } + /** Helper method to correctly format the aObjectIndex parameter. + **/ + inline TInt ObjIndScr(TInt aScreen,TInt aWin=0,TInt aLayer=0,TInt aExtra=0); + + inline TInt Finish(TBool aAndFlush=ETrue) + { + if (aAndFlush) + Flush(); + return RWsSession::Finish(); + } +protected: + // Resolves the template parameter to a size. See overload docs for more info. + TInt DebugInfo(TWsDebugInfoFunc aFunction, TInt aObjectIndex, TDes8& aHostBuffer,const void*&aReturnedObject,TInt aSize)const; + TInt iScreenNo; + TInt iSurfaceUpdateSerial; + RBuf8 iSurfaceListBuffer; + }; +inline TInt RWsDebugSession::ObjIndScr(TInt aScreen,TInt aWin,TInt aLayer,TInt aExtra) + { + return (aScreen< + +TGlobalSettings settings_instance={0,0}; +const TGlobalSettings& TGlobalSettings::Instance() + { + return settings_instance; + } + +// Create a suite of all the tests +CTestSuite* CGlobalSettings::CreateSuiteL(const TDesC& aName) + { + SUB_SUITE_OPT(CGlobalSettings,NULL); + + ADD_TEST_STEP_PARAM_RANGE(SetScreenNoL,0,9); + ADD_TEST_STEP_PARAM_BOOL(ExpectDisconnectedScreenL); + + END_SUITE; + } + +void CGlobalSettings::SetScreenNoL(TInt aScreenNo) + { + RWsSession session; + ASSERT_EQUALS(session.Connect(), KErrNone); + TInt maxScreens=session.NumberOfScreens(); + + if (maxScreens>aScreenNo) + { + INFO_PRINTF2(_L("New screen number for all output selected: %i"),aScreenNo); + { + CWsScreenDevice screen(session); + screen.Construct(aScreenNo); + screen.SetCurrentRotations(0,CFbsBitGc::TGraphicsOrientation(0)); + screen.SetScreenMode(0); + screen.SetAppScreenMode(0); + } + settings_instance.iScreen=aScreenNo; + session.Flush(); + session.Close(); + } + else + { + INFO_PRINTF1(_L("**************************")); + INFO_PRINTF1(_L("")); + INFO_PRINTF3(_L("Can't set screen output to %i. Only got %i screens"),aScreenNo,maxScreens); + INFO_PRINTF2(_L("Screen number for all output remains at: %i"),settings_instance.iScreen); + + INFO_PRINTF1(_L("")); + INFO_PRINTF1(_L("**************************")); + session.Flush(); + session.Close(); + User::Leave(KErrTEFUnitFail); + } + } + +void CGlobalSettings::ExpectDisconnectedScreenL(TBool aValue) + { + settings_instance.iDisconnected=aValue; + } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tdynamicres/src/screenselect.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tdynamicres/src/screenselect.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,64 @@ +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file +*/ + +#include +#include +#include "teflogextensions.h" +#include "screenselect.h" +#include "globalsettings.h" + +//Note that this class now just acts as a stub to the CGlobalSettings::SetScreenNoL() method and data, so both are equivalent. + +CScreenSelect::CScreenSelect(TInt aScreenNumber, const TDesC& aStepName) + { + SetTestStepName(aStepName); + iScreenNumber = aScreenNumber; + } + +CScreenSelect::~CScreenSelect() + { + } + + +TInt CScreenSelect::Number() + { + return TGlobalSettings::Instance().iScreen; + } + + +TVerdict CScreenSelect::doTestStepL() + { + SetTestStepError(EFail); + + CGlobalSettings* globalSettings=new (ELeave) CGlobalSettings; + + globalSettings->SetLoggerL(Logger()); + TRAPD(err,globalSettings->SetScreenNoL( iScreenNumber)); + + if (err==KErrNone) + { + SetTestStepError(EPass); + return EPass; + } + else + { + return EFail; + } + } + diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tdynamicres/src/surfaceutility.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tdynamicres/src/surfaceutility.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,1544 @@ +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file +*/ + +#include +#include +#include "surfaceutility.h" + +CSurfaceUtility::CSurfaceUtility(CSurfaceUtility* aClone/*=NULL*/) + : iSurfaces(aClone?&(aClone->iSurfaces):NULL) + { + } + +CSurfaceUtility* CSurfaceUtility::NewL(CSurfaceUtility* aClone/*=NULL*/) + { + CSurfaceUtility* utility = new (ELeave)CSurfaceUtility(aClone); + CleanupStack::PushL(utility); + utility->ConstructL(); + CleanupStack::Pop(utility); + return utility; + } + +void CSurfaceUtility::ConstructL() + { + TInt r = iManager.Open(); + if (r != KErrNone) + { + LOG(("Surface manager failed to open: %d", r)); + User::Leave(r); + } + + r = iSurfaceUpdateSession.Connect(); + if (r != KErrNone) + { + LOG(("Failed to connect to update server: %d", r)); + User::Leave(r); + } + } + +CSurfaceUtility::~CSurfaceUtility() + { + DestroyAll(); + + iSurfaces.Close(); + + iManager.Close(); + + iSurfaceUpdateSession.Close(); + } + +TBool CSurfaceUtility::DestroyAll() + { + TInt err = KErrNone; + TInt jj = iSurfaces.Count() - 1; + if (jj<0) + return EFalse; + for (; jj >= 0; jj--) + { + err = iManager.CloseSurface(iSurfaces[jj]); + if (err!=KErrNone) + { + LOG(("Error closing surface: 0x%X\n", err)); + } + } + iSurfaces.Reset(); + return ETrue; + } + +/*************************************** + * The aim of the THeapSurfaceArray is to locally switch in the specified heap for any array operation + ***************************************/ + +CSurfaceUtility::RHeapSurfaceArray::RHeapSurfaceArray(RHeapSurfaceArray* aUseExternalArray) + : iUseArray(aUseExternalArray?aUseExternalArray->iUseArray:&this->iLocalArray), + iExternalHeapRef(aUseExternalArray?aUseExternalArray->iExternalHeapRef:User::Heap()) + { + + } +/************************************ + * The following methods have been used by the surfaceutility... some require the heap wrapping, and some don't + * I actually need three different startegies (count em) for 7 methods... + * Some methods only read the existing objects, so don't need a heap swap at all + * Leaving methods have to use PopAndDestroy strategy to restore the heap on leaving or success + * Non-leaving methods must not call PushL, so directly make SwitchHeap calls! + ************************************/ + +// PopAndDestroy method to restore the heap +/*static*/ void CSurfaceUtility::RHeapSurfaceArray::PopHeap(void* aHeapPtr) + { + RHeap* heapPtr=(RHeap*)aHeapPtr; + User::SwitchHeap(heapPtr); + } + +// Switches and pushes the previous heap so it can be restored with PopAndDestroy +/*static*/ void CSurfaceUtility::RHeapSurfaceArray::SwitchHeapLC(RHeap* aNewHeap) + { + CleanupStack::PushL(TCleanupItem(PopHeap,NULL)); + CleanupStack::PushL(TCleanupItem(PopHeap,NULL)); + CleanupStack::PushL(TCleanupItem(PopHeap,NULL)); + CleanupStack::Pop(3); + RHeap* oldHeap=User::SwitchHeap(aNewHeap); + delete new char; + CleanupStack::PushL(TCleanupItem(PopHeap,oldHeap)); + } + + +TSurfaceId& CSurfaceUtility::RHeapSurfaceArray::operator[](TUint aIndex) + { + return iUseArray->operator[](aIndex); + } +// Close only closes the local array, while Reset resets the active array (may be external) +void CSurfaceUtility::RHeapSurfaceArray::Close() + { + RHeap* oldHeap=User::SwitchHeap(&iExternalHeapRef); + iLocalArray.Close(); + User::SwitchHeap(oldHeap); + } +TInt CSurfaceUtility::RHeapSurfaceArray::Count() const + { + return iUseArray->Count(); + } +// Close only closes the local array, while Reset resets the active array (may be external) +inline void CSurfaceUtility::RHeapSurfaceArray::Reset() + { + RHeap* oldHeap=User::SwitchHeap(&iExternalHeapRef); + iUseArray->Reset(); + User::SwitchHeap(oldHeap); + } +void CSurfaceUtility::RHeapSurfaceArray::AppendL(const TSurfaceId &anEntry) + { + SwitchHeapLC(&iExternalHeapRef); + iUseArray->AppendL(anEntry); + CleanupStack::PopAndDestroy(); + } +TInt CSurfaceUtility::RHeapSurfaceArray::Find(const TSurfaceId &anEntry) const + { + return iUseArray->Find(anEntry); + } +void CSurfaceUtility::RHeapSurfaceArray::Remove(TInt anIndex) + { + RHeap* oldHeap=User::SwitchHeap(&iExternalHeapRef); + iUseArray->Remove(anIndex); + User::SwitchHeap(oldHeap); + } + + + + +/** +Cleanup stack helper object, holding references to both utility and surface, so +that the standard Close() semantics can be used. +*/ +class TSurfaceCleanup + { +public: + TSurfaceCleanup(CSurfaceUtility& aUtility, TSurfaceId& aSurface) + : iUtility(aUtility), iSurface(aSurface) + {} + void Close() + { + // Removes the surface from the list of surfaces to clean up, and closes + // the surface reference. + iUtility.DestroySurface(iSurface); + } +private: + CSurfaceUtility& iUtility; + TSurfaceId& iSurface; + }; + +/** +Read the given image file into a new surface. + +@param aFileName The name of the image file. +@param aSurface Filled with the surface ID for the surface containing the pixels. +*/ +void CSurfaceUtility::CreateSurfaceFromFileL(const TDesC& aFileName, TSurfaceId& aSurface) + { + RFs fs; + + User::LeaveIfError(fs.Connect()); + CleanupClosePushL(fs); + CImageDecoder* decoder = CImageDecoder::FileNewL(fs, aFileName, CImageDecoder::EOptionAlwaysThread); + CleanupStack::PushL(decoder); + + const TFrameInfo& info = decoder->FrameInfo(); + + TSize size = info.iOverallSizeInPixels; + TInt stride = size.iWidth << 2; // Default to four bytes per pixel + TDisplayMode bmpFormat = info.iFrameDisplayMode; + TUidPixelFormat pixelFormat = EUidPixelFormatUnknown; + + switch (bmpFormat) + { + case EGray2: + case EGray4: + case EGray16: + case EGray256: + case EColor16: + case EColor256: + case EColor16M: + case EColor16MU: + { + bmpFormat = EColor16MU; + pixelFormat = EUidPixelFormatXRGB_8888; + break; + } + case EColor4K: + { + stride = size.iWidth << 1; + pixelFormat = EUidPixelFormatXRGB_4444; + break; + } + case EColor64K: + { + stride = size.iWidth << 1; + pixelFormat = EUidPixelFormatRGB_565; + break; + } + case EColor16MA: + { + pixelFormat = EUidPixelFormatARGB_8888; + break; + } + case EColor16MAP: + { + pixelFormat = EUidPixelFormatARGB_8888_PRE; + break; + } + default: + { + LOG(("Unsupported display mode: %d", bmpFormat)); + User::Leave(KErrNotSupported); + break; + } + } + + // Create an intermediary bitmap for decoding into + CFbsBitmap* bitmap = new (ELeave) CFbsBitmap(); + CleanupStack::PushL(bitmap); + User::LeaveIfError(bitmap->Create(size, info.iFrameDisplayMode)); + + // Create the final surface. + aSurface = CreateSurfaceL(size, pixelFormat, stride); + TSurfaceCleanup surfaceCleanup(*this, aSurface); + CleanupClosePushL(surfaceCleanup); + + RChunk chunk; + User::LeaveIfError(iManager.MapSurface(aSurface, chunk)); + CleanupClosePushL(chunk); + + // Convert the image file into a Symbian bitmap + TRequestStatus status; + decoder->Convert(&status, *bitmap); + User::WaitForRequest(status); + User::LeaveIfError(status.Int()); + + TInt offsetToFirstBuffer; + User::LeaveIfError(iManager.GetBufferOffset(aSurface, 0, offsetToFirstBuffer)); + + // Copy the data from the bitmap into the surface. + TPoint start; + TUint8 *pSurfStart = chunk.Base() + offsetToFirstBuffer; + for (start.iY = 0; start.iY < size.iHeight; start.iY++) + { + // Set up a descriptor for the current line in the surface and get pixels. + TPtr8 ptr(pSurfStart + start.iY * stride, stride); + bitmap->GetScanLine(ptr, start, size.iWidth, bmpFormat); + } + + CleanupStack::PopAndDestroy(/* chunk */); + CleanupStack::Pop(/* surfaceCleanup */); + CleanupStack::PopAndDestroy(bitmap); + CleanupStack::PopAndDestroy(decoder); + CleanupStack::PopAndDestroy(/* fs */); + } + +void CSurfaceUtility::CopyBitmapSurfaceL(const CFbsBitmap* aBitmap, TSurfaceId& aSurface) + { + RChunk chunk; + User::LeaveIfError(iManager.MapSurface(aSurface, chunk)); + CleanupClosePushL(chunk); + TSize bitmapSize = aBitmap->SizeInPixels(); + TSize size = SurfaceSize(aSurface); + TInt stride = size.iWidth*4; // Default to four bytes per pixel + + TInt offsetToFirstBuffer; + User::LeaveIfError(iManager.GetBufferOffset(aSurface, 0, offsetToFirstBuffer)); + + // Copy the data from the bitmap into the surface. + TPoint start; + TUint8 *pSurfStart = chunk.Base() + offsetToFirstBuffer; + for (start.iY = 0; start.iY < bitmapSize.iHeight; start.iY++) + { + // Set up a descriptor for the current line in the surface and get pixels. + TPtr8 ptr(pSurfStart + start.iY * stride, stride); + aBitmap->GetScanLine(ptr, start, bitmapSize.iWidth, EColor16MU); + } + CleanupStack::PopAndDestroy(/* chunk */); + + } +/** +Copy the bitmap from a file to a surface. + +@param aFileName The name of the image file. +@param aSurface Filled with the surface ID for the surface containing the pixels. +*/ +void CSurfaceUtility::CopyBitmapFromFileToSurfaceL(const TDesC& aFileName, TSurfaceId& aSurface) + { + RFs fs; + + User::LeaveIfError(fs.Connect()); + CleanupClosePushL(fs); + CImageDecoder* decoder = CImageDecoder::FileNewL(fs, aFileName, CImageDecoder::EOptionAlwaysThread); + CleanupStack::PushL(decoder); + + const TFrameInfo& info = decoder->FrameInfo(); + + RSurfaceManager::TInfoBuf infoBuf; + RSurfaceManager::TSurfaceInfoV01& infoSurf = infoBuf(); + User::LeaveIfError(iManager.SurfaceInfo(aSurface, infoBuf)); + + TSize size = infoSurf.iSize; + TDisplayMode bmpFormat = info.iFrameDisplayMode; + TInt stride = size.iWidth << 2; // Default to four bytes per pixel + + // Create an intermediary bitmap for decoding into + CFbsBitmap* bitmap = new (ELeave) CFbsBitmap(); + CleanupStack::PushL(bitmap); + User::LeaveIfError(bitmap->Create(size, info.iFrameDisplayMode)); + + RChunk chunk; + User::LeaveIfError(iManager.MapSurface(aSurface, chunk)); + CleanupClosePushL(chunk); + + // Convert the image file into a Symbian bitmap + TRequestStatus status; + decoder->Convert(&status, *bitmap); + User::WaitForRequest(status); + User::LeaveIfError(status.Int()); + + TInt offsetToFirstBuffer; + User::LeaveIfError(iManager.GetBufferOffset(aSurface, 0, offsetToFirstBuffer)); + + // Copy the data from the bitmap into the surface. + TPoint start; + TUint8 *pSurfStart = chunk.Base() + offsetToFirstBuffer; + for (start.iY = 0; start.iY < size.iHeight; start.iY++) + { + // Set up a descriptor for the current line in the surface and get pixels. + TPtr8 ptr(pSurfStart + start.iY * stride, stride); + bitmap->GetScanLine(ptr, start, size.iWidth, bmpFormat); + } + + CleanupStack::PopAndDestroy(/* chunk */); + CleanupStack::PopAndDestroy(bitmap); + CleanupStack::PopAndDestroy(decoder); + CleanupStack::PopAndDestroy(/* fs */); + } +/** +Get the size of a surface. + +@param aSurface The surface to get the size for. +@return The size in pixels, or empty on failure. +*/ +TSize CSurfaceUtility::SurfaceSize(const TSurfaceId& aSurface) + { + RSurfaceManager::TInfoBuf infoBuf; + RSurfaceManager::TSurfaceInfoV01& info = infoBuf(); + + if (iManager.SurfaceInfo(aSurface, infoBuf) == KErrNone) + { + return info.iSize; + } + + return TSize(); + } + + +/** +Create a surface using the surface manager. + +Stores the ID for tear down, as well as returning it. + +@param aSize Dimensions of the surface. +@param aPixelFormat UID of the pixel format. +@param aStride Stride value for the surface (usually bytes per pixel * width) +@leave May leave due to lack of memory. +@return New surface's ID. +*/ +TSurfaceId CSurfaceUtility::CreateSurfaceL(const TSize& aSize, TUidPixelFormat aPixelFormat, TInt aStride, TInt aBuffers) + { + RSurfaceManager::TSurfaceCreationAttributesBuf bf; + RSurfaceManager::TSurfaceCreationAttributes& b = bf(); + + b.iSize.iWidth = aSize.iWidth; + b.iSize.iHeight = aSize.iHeight; + b.iBuffers = aBuffers; // number of buffers in the surface + b.iPixelFormat = aPixelFormat; + b.iStride = aStride; // Number of bytes between start of one line and start of next + b.iOffsetToFirstBuffer = 0; // way of reserving space before the surface pixel data + b.iAlignment = 4; // alignment, 1,2,4,8 byte aligned + b.iContiguous = EFalse; + b.iMappable = ETrue; + + TSurfaceId surface = TSurfaceId::CreateNullId(); + + User::LeaveIfError(iManager.CreateSurface(bf, surface)); + iSurfaces.AppendL(surface); + return surface; + } + +/** +A helper function that returns the bytes per pixel for a given pixel format uid + +@param aPixelFormat Pixel format UID to convert +@return The bytes per pixel +*/ +TInt CSurfaceUtility::BytesPerPixelL(TUidPixelFormat aPixelFormat) + { + TInt bytesPerPixel = 0; + switch (aPixelFormat) + { + case EUidPixelFormatXRGB_8888: + case EUidPixelFormatARGB_8888: + case EUidPixelFormatARGB_8888_PRE: + { + bytesPerPixel = 4; + break; + } + case EUidPixelFormatXRGB_4444: + case EUidPixelFormatARGB_4444: + case EUidPixelFormatRGB_565: + { + bytesPerPixel = 2; + break; + } + default: + { + User::Leave(KErrNotSupported); + break; + } + } + return bytesPerPixel; + } + +/** +Fill the given surface with a color. + +@param aSurface The surface to be filled. +@param aColor The color to fill it with. +*/ +void CSurfaceUtility::FillSurfaceL(TSurfaceId& aSurface, const TRgb& aColor) + { + RSurfaceManager::TInfoBuf infoBuf; + RSurfaceManager::TSurfaceInfoV01& info = infoBuf(); + + User::LeaveIfError(iManager.SurfaceInfo(aSurface, infoBuf)); + TUint32 color = 0; + TBool use16 = EFalse; + + if (info.iSize.iHeight<0 || info.iSize.iWidth<0 || info.iStride<0) + { + User::Leave(KErrCorrupt); + } + if (info.iSize.iHeight==0 || info.iSize.iWidth==0 || info.iStride==0) + { + User::Leave(KErrNotReady); + } + + switch (info.iPixelFormat) + { + case EUidPixelFormatXRGB_8888: + { + color = aColor.Color16MU(); +#ifdef ALPHA_FIX_24BIT + color |= ((ALPHA_FIX_24BIT)&0xff)<<24; +#endif + break; + } + case EUidPixelFormatARGB_8888: + { + color = aColor.Color16MA(); + break; + } + case EUidPixelFormatARGB_8888_PRE: + { + color = aColor.Color16MAP(); + break; + } + case EUidPixelFormatXRGB_4444: + case EUidPixelFormatARGB_4444: + { + color = aColor.Color4K(); + use16 = ETrue; + break; + } + case EUidPixelFormatRGB_565: + { + color = aColor.Color64K(); + use16 = ETrue; + break; + } + default: + { + User::Leave(KErrNotSupported); + break; + } + } + + RChunk chunk; + User::LeaveIfError(iManager.MapSurface(aSurface, chunk)); + CleanupClosePushL(chunk); + + TInt offsetToFirstBuffer; + User::LeaveIfError(iManager.GetBufferOffset(aSurface, 0, offsetToFirstBuffer)); + TUint8* surfacePtr = chunk.Base() + offsetToFirstBuffer; + TUint8* linePtr = surfacePtr; + + if (use16) + { + if ( info.iSize.iWidth*2>info.iStride) + { + User::Leave(KErrOverflow); + } + TUint16* ptr = reinterpret_cast(surfacePtr); + + // Fill first line + for (TInt xx = 0; xx < info.iSize.iWidth; xx++) + { + ptr[xx] = (TUint16)color; + } + } + else + { + if ( info.iSize.iWidth*4>info.iStride) + { + User::Leave(KErrOverflow); + } + TUint32* ptr = reinterpret_cast(surfacePtr); + + // Fill first line + for (TInt xx = 0; xx < info.iSize.iWidth; xx++) + { + ptr[xx] = color; + } + } + + // Now copy that to the other lines + for (TInt yy = 1; yy < info.iSize.iHeight; yy++) + { + linePtr += info.iStride; + Mem::Copy(linePtr, surfacePtr, info.iSize.iWidth * BytesPerPixelL(info.iPixelFormat)); + } + + TInt err = iSurfaceUpdateSession.SubmitUpdate(KAllScreens, aSurface, 0, NULL); + if (err!=KErrNone) + LOG(("Error submitting update: 0x%X\n", err)); + + CleanupStack::PopAndDestroy(/* chunk */); + } + +/** +Fill the given memory chunk with a color. + +@param aSurface The surface to be filled. +@param aChunk The surface to be filled. +@param aColor The color to fill it with. +*/ +void CSurfaceUtility::FillChunkL(TSurfaceId& aSurface, RChunk& aChunk, const TRgb& aColor, TInt aBufferNumber) + { + RSurfaceManager::TInfoBuf infoBuf; + RSurfaceManager::TSurfaceInfoV01& info = infoBuf(); + + User::LeaveIfError(iManager.SurfaceInfo(aSurface, infoBuf)); + TUint32 color = 0; + TBool use16 = EFalse; + + if (info.iSize.iHeight<0 || info.iSize.iWidth<0 || info.iStride<0) + { + User::Leave(KErrCorrupt); + } + if (info.iSize.iHeight==0 || info.iSize.iWidth==0 || info.iStride==0) + { + User::Leave(KErrNotReady); + } + + switch (info.iPixelFormat) + { + case EUidPixelFormatXRGB_8888: + { + color = aColor.Color16MU(); +#ifdef ALPHA_FIX_24BIT + color |= ((ALPHA_FIX_24BIT)&0xff)<<24; +#endif + break; + } + case EUidPixelFormatARGB_8888: + { + color = aColor.Color16MA(); + break; + } + case EUidPixelFormatARGB_8888_PRE: + { + color = aColor.Color16MAP(); + break; + } + case EUidPixelFormatXRGB_4444: + case EUidPixelFormatARGB_4444: + { + color = aColor.Color4K(); + use16 = ETrue; + break; + } + case EUidPixelFormatRGB_565: + { + color = aColor.Color64K(); + use16 = ETrue; + break; + } + default: + { + User::Leave(KErrNotSupported); + break; + } + } + + User::LeaveIfError(iManager.MapSurface(aSurface, aChunk)); + + TInt offsetToFirstBuffer; + User::LeaveIfError(iManager.GetBufferOffset(aSurface, 0, offsetToFirstBuffer)); + TInt offsetToBufferNumber; + User::LeaveIfError(iManager.GetBufferOffset(aSurface, aBufferNumber, offsetToBufferNumber)); + + TUint8* chunkPtr = aChunk.Base() + offsetToFirstBuffer; + TUint8* linePtr = aChunk.Base() + offsetToBufferNumber; + TUint8* surfPlanePtr = linePtr; + + if (use16) + { + if ( info.iSize.iWidth*2>info.iStride) + { + aChunk.Close(); + User::Leave(KErrOverflow); + } + TUint16* ptr = reinterpret_cast(surfPlanePtr); + + // Fill first line + for (TInt xx = 0; xx < info.iSize.iWidth; xx++) + { + ptr[xx] = (TUint16)color; + } + } + else + { + if ( info.iSize.iWidth*4>info.iStride) + { + aChunk.Close(); + User::Leave(KErrOverflow); + } + TUint32* ptr = reinterpret_cast(surfPlanePtr); + + // Fill first line + for (TInt xx = 0; xx < info.iSize.iWidth; xx++) + { + ptr[xx] = color; + } + } + + // Now copy that to the other lines + for (TInt yy = 1; yy < info.iSize.iHeight; yy++) + { + linePtr += info.iStride; + Mem::Copy(linePtr, surfPlanePtr, info.iSize.iWidth * BytesPerPixelL(info.iPixelFormat)); + } + + aChunk.Close(); + } + +/** +Fill a rectangle on the given surface. + +@param aSurface The surface to be filled. +@param aStartPos Where to place the rectangle. +@param aSize Size of the rectangle. +@param aColor The colour to fill it with. +*/ +void CSurfaceUtility::FillRectangleL(TSurfaceId& aSurface, const TPoint& aStartPos, const TSize& aSize, const TRgb& aColor) + { + FillRectangleNoUpdateL(aSurface, aStartPos, aSize, aColor); + + TInt err = iSurfaceUpdateSession.SubmitUpdate(KAllScreens, aSurface, 0, NULL); + if (err!=KErrNone) + LOG(("Error submitting update: 0x%X\n", err)); + } + +/** +Fill a rectangle on the given surface - does not submit update. + +@param aSurface The surface to be filled. +@param aStartPos Where to place the rectangle. +@param aSize Size of the rectangle. +@param aColor The colour to fill it with. +*/ +void CSurfaceUtility::FillRectangleNoUpdateL(TSurfaceId& aSurface, const TPoint& aStartPos, const TSize& aSize, const TRgb& aColor) + { + RSurfaceManager::TInfoBuf infoBuf; + RSurfaceManager::TSurfaceInfoV01& info = infoBuf(); + + User::LeaveIfError(iManager.SurfaceInfo(aSurface, infoBuf)); + TUint32 color = 0; + TBool use16 = EFalse; + + if (info.iSize.iHeight<0 || info.iSize.iWidth<0 || info.iStride<0) + { + User::Leave(KErrCorrupt); + } + if (info.iSize.iHeight==0 || info.iSize.iWidth==0 || info.iStride==0) + { + User::Leave(KErrNotReady); + } + + switch (info.iPixelFormat) + { + case EUidPixelFormatXRGB_8888: + { + color = aColor.Color16MU(); +#ifdef ALPHA_FIX_24BIT + color |= ((ALPHA_FIX_24BIT)&0xff)<<24; +#endif + break; + } + case EUidPixelFormatARGB_8888: + { + color = aColor.Color16MA(); + break; + } + case EUidPixelFormatARGB_8888_PRE: + { + color = aColor.Color16MAP(); + break; + } + case EUidPixelFormatXRGB_4444: + case EUidPixelFormatARGB_4444: + { + color = aColor.Color4K(); + use16 = ETrue; + break; + } + case EUidPixelFormatRGB_565: + { + color = aColor.Color64K(); + use16 = ETrue; + break; + } + default: + { + User::Leave(KErrNotSupported); + break; + } + } + + RChunk chunk; + User::LeaveIfError(iManager.MapSurface(aSurface, chunk)); + CleanupClosePushL(chunk); + + TInt offsetToFirstBuffer; + User::LeaveIfError(iManager.GetBufferOffset(aSurface, 0, offsetToFirstBuffer)); + TUint8* surfacePtr = chunk.Base() + offsetToFirstBuffer; + + // Check for out of bounds + TBool validRect = ETrue; + TInt surfaceWidth = info.iSize.iWidth; + TInt surfaceHeight = info.iSize.iHeight; + + // Width and Height + if ((aStartPos.iX + aSize.iWidth) > surfaceWidth) + validRect = EFalse; + + if ((aStartPos.iY + aSize.iHeight) > surfaceHeight) + validRect = EFalse; + + // Starting position + if ((aStartPos.iX < 0) || (aStartPos.iY < 0)) + validRect = EFalse; + + if (!validRect) + User::Leave(KErrOverflow); + + if (use16) + { + if ( info.iSize.iWidth*2>info.iStride) + { + User::Leave(KErrOverflow); + } + + TUint16* ptr = reinterpret_cast(surfacePtr); + + // Fill the rectangle + TInt yPos = aStartPos.iY; + TInt xPos = aStartPos.iX; + for (TInt yy = 0; yy < aSize.iHeight; ++yy) + { + ptr = reinterpret_cast(surfacePtr+(yPos*info.iStride)); + for (TInt xx = 0; xx < aSize.iWidth; ++xx) + { + ptr[xPos] = color; + xPos++; + } + xPos = aStartPos.iX; + yPos++; + } + } + else + { + if ( info.iSize.iWidth*4>info.iStride) + { + User::Leave(KErrOverflow); + } + + TUint32* ptr = reinterpret_cast(surfacePtr); + + // Fill the rectangle + TInt yPos = aStartPos.iY; + TInt xPos = aStartPos.iX; + for (TInt yy = 0; yy < aSize.iHeight; ++yy) + { + ptr = reinterpret_cast(surfacePtr+(yPos*info.iStride)); + for (TInt xx = 0; xx < aSize.iWidth; ++xx) + { + ptr[xPos] = color; + xPos++; + } + xPos = aStartPos.iX; + yPos++; + } + } + + CleanupStack::PopAndDestroy(/* chunk */); + } + +/** +Fill the given surface with a grid over a solid color. + +Similar to FillSurfaceL(), but with a grid overlayed. The pitch of the grid is +eight pixels. + +@param aSurface The surface to be filled. +@param aColor The color to fill it with. +@param aLines The color of the grid lines. +*/ +void CSurfaceUtility::GridFillSurfaceL(TSurfaceId& aSurface, const TRgb& aColor, const TRgb& aLines) + { + RSurfaceManager::TInfoBuf infoBuf; + RSurfaceManager::TSurfaceInfoV01& info = infoBuf(); + + User::LeaveIfError(iManager.SurfaceInfo(aSurface, infoBuf)); + TUint32 color = 0; + TUint32 lines = 0; + TBool use16 = EFalse; + + if (info.iSize.iHeight<0 || info.iSize.iWidth<0 || info.iStride<0) + { + User::Leave(KErrCorrupt); + } + if (info.iSize.iHeight==0 || info.iSize.iWidth==0 || info.iStride==0) + { + User::Leave(KErrNotReady); + } + + switch (info.iPixelFormat) + { + case EUidPixelFormatXRGB_8888: + { + color = aColor.Color16MU(); + lines = aLines.Color16MU(); +#ifdef ALPHA_FIX_24BIT + color |= ((ALPHA_FIX_24BIT)&0xff)<<24; + lines |= ((ALPHA_FIX_24BIT)&0xff)<<24; +#endif + break; + } + case EUidPixelFormatARGB_8888: + { + color = aColor.Color16MA(); + lines = aLines.Color16MA(); + break; + } + case EUidPixelFormatARGB_8888_PRE: + { + color = aColor.Color16MAP(); + lines = aLines.Color16MAP(); + break; + } + case EUidPixelFormatXRGB_4444: + case EUidPixelFormatARGB_4444: + { + color = aColor.Color4K(); + lines = aLines.Color4K(); + use16 = ETrue; + break; + } + case EUidPixelFormatRGB_565: + { + color = aColor.Color64K(); + lines = aLines.Color64K(); + use16 = ETrue; + break; + } + default: + { + User::Leave(KErrNotSupported); + break; + } + } + + RChunk chunk; + User::LeaveIfError(iManager.MapSurface(aSurface, chunk)); + CleanupClosePushL(chunk); + + TInt offsetToFirstBuffer; + User::LeaveIfError(iManager.GetBufferOffset(aSurface, 0, offsetToFirstBuffer)); + TUint8* surfacePtr = chunk.Base() + offsetToFirstBuffer; + TUint8* linePtr = surfacePtr; + + if (use16) + { + if ( info.iSize.iWidth*2>info.iStride) + { + User::Leave(KErrOverflow); + } + TUint16* ptr = reinterpret_cast(surfacePtr); + + // Fill first line + for (TInt xx1 = 0; xx1 < info.iSize.iWidth; xx1++) + { + ptr[xx1] = (TUint16)lines; + } + + // Fill second line + ptr = reinterpret_cast(surfacePtr + info.iStride); + for (TInt xx2 = 0; xx2 < info.iSize.iWidth; xx2++) + { + // Vertical line every 8 pixels across + ptr[xx2] = (TUint16)((xx2 & 7) ? color : lines); + } + } + else + { + if ( info.iSize.iWidth*4>info.iStride) + { + User::Leave(KErrOverflow); + } + TUint32* ptr = reinterpret_cast(surfacePtr); + + // Fill first line + for (TInt xx3 = 0; xx3 < info.iSize.iWidth; xx3++) + { + ptr[xx3] = lines; + } + + // Fill second line + ptr = reinterpret_cast(surfacePtr + info.iStride); + for (TInt xx4 = 0; xx4 < info.iSize.iWidth; xx4++) + { + // Vertical line every 8 pixels across + ptr[xx4] = (xx4 & 7) ? color : lines; + } + } + linePtr += info.iStride; + + // Now copy that to the other lines + for (TInt yy = 2; yy < info.iSize.iHeight; yy++) + { + linePtr += info.iStride; + if (yy & 7) + { + // Copy second line + Mem::Copy(linePtr, surfacePtr + info.iStride, info.iSize.iWidth * BytesPerPixelL(info.iPixelFormat)); + } + else + { + // Copy first line + Mem::Copy(linePtr, surfacePtr, info.iSize.iWidth * BytesPerPixelL(info.iPixelFormat)); + } + } + + TInt err =iSurfaceUpdateSession.SubmitUpdate(KAllScreens, aSurface, 0, NULL); + if (err!=KErrNone) + LOG(("Error submitting update: 0x%X\n", err)); + + CleanupStack::PopAndDestroy(/* chunk */); + } + + +/** +Fill the given surface with a pattern suitable for automated testing. + +@param aSurface The surface to be filled. +*/ +void CSurfaceUtility::PatternFillSurfaceL(TSurfaceId& aSurface) + { + RSurfaceManager::TInfoBuf infoBuf; + RSurfaceManager::TSurfaceInfoV01& info = infoBuf(); + + User::LeaveIfError(iManager.SurfaceInfo(aSurface, infoBuf)); + + // Fill the background + FillSurfaceL(aSurface, TRgb(0x00000000)); + + TInt surfaceWidth = info.iSize.iWidth; + TInt surfaceHeight = info.iSize.iHeight; + + // Create the 4 rectangles in the corners + TPoint startPos(0,0); + TSize size(15,15); + TInt rectWidth = size.iWidth; + TInt rectHeight = size.iHeight; + // Top left + FillRectangleL(aSurface, startPos, size, TRgb(0x0000ff)); + + // Top right + startPos.iX = surfaceWidth - rectWidth; + startPos.iY = 0; + FillRectangleL(aSurface, startPos, size, TRgb(0x00ff00)); + + // Bottom left + startPos.iX = 0; + startPos.iY = surfaceHeight - rectHeight; + FillRectangleL(aSurface, startPos, size, TRgb(0x00ffff)); + + // Bottom right + startPos.iX = surfaceWidth - rectWidth; + startPos.iY = surfaceHeight - rectHeight; + FillRectangleL(aSurface, startPos, size, TRgb(0xffffff)); + + // Create the 4 side bars + startPos.iX = 0; + startPos.iY = 6; + size.iWidth = 5; + size.iHeight = surfaceHeight - 12; + // Left + FillRectangleL(aSurface, startPos, size, TRgb(0x808000)); + + startPos.iX = surfaceWidth - size.iWidth; + startPos.iY = 6; + // Right + FillRectangleL(aSurface, startPos, size, TRgb(0xff00ff)); + + startPos.iX = 6; + startPos.iY = surfaceHeight - size.iWidth; + size.iWidth = surfaceWidth - 12; + size.iHeight = 5; + // Top + FillRectangleL(aSurface, startPos, size, TRgb(0xaaaaaa)); + + startPos.iX = 6; + startPos.iY = 0; + // Bottom + FillRectangleL(aSurface, startPos, size, TRgb(0x000080)); + } + + +template void +DdaLine(TUint aX1, TUint aY1,TUint aX2,TUint aY2, TUint aPixPerScan, TIntType* aBuffer, TIntType aColor) + { + TInt dx=aX2-aX1; + TInt dy=aY2-aY1; + TInt adx=dx,sdx=1; + if (adx<0) + { adx=-adx; sdx=-1; } + TInt ady=dy,sdy=aPixPerScan; + if (ady<0) + { ady=-ady; sdy=-aPixPerScan; } + //This is simplistic integert DDA. + //The vertical cases are handled by this 1/2 accumulator: + // If adx is zero then we step in sdy indefinitely + // If ady is zero then we step in sdx indefinitely + TInt accum=adx/2; + + TIntType* bufferend=aBuffer+aX2+aY2*aPixPerScan; + aBuffer+=aX1+aY1*aPixPerScan; + *aBuffer=aColor; + while (aBuffer!=bufferend) + { + if (accum>0) + { + accum-=ady; + aBuffer+=sdx; + } + else + { + accum+=adx; + aBuffer+=sdy; + } + *aBuffer=aColor; + } + + + } +template void +FanFill(const TPoint& aInnerXY,TUint aPixPerScan, TIntType* aSurfacePtr, TIntType aLinesTL, + TIntType aLinesBR, TIntType aLinesTR, TIntType aLinesBL) + { + + DdaLine(aInnerXY.iX,0,aInnerXY.iX-aInnerXY.iX*180/1024,aInnerXY.iY,aPixPerScan,aSurfacePtr,aLinesTR); + DdaLine(aInnerXY.iX,0,aInnerXY.iX-aInnerXY.iX*372/1024,aInnerXY.iY,aPixPerScan,aSurfacePtr,aLinesTR); + DdaLine(aInnerXY.iX,0,aInnerXY.iX-aInnerXY.iX*591/1024,aInnerXY.iY,aPixPerScan,aSurfacePtr,aLinesTR); + DdaLine(aInnerXY.iX,0,aInnerXY.iX-aInnerXY.iX*859/1024,aInnerXY.iY,aPixPerScan,aSurfacePtr,aLinesTR); + + DdaLine(aInnerXY.iX,0,0,aInnerXY.iY*180/1024,aPixPerScan,aSurfacePtr,aLinesTR); + DdaLine(aInnerXY.iX,0,0,aInnerXY.iY*372/1024,aPixPerScan,aSurfacePtr,aLinesTR); + DdaLine(aInnerXY.iX,0,0,aInnerXY.iY*591/1024,aPixPerScan,aSurfacePtr,aLinesTR); + DdaLine(aInnerXY.iX,0,0,aInnerXY.iY*859/1024,aPixPerScan,aSurfacePtr,aLinesTR); + + DdaLine(0,aInnerXY.iY,aInnerXY.iX*180/1024,0,aPixPerScan,aSurfacePtr,aLinesBL); + DdaLine(0,aInnerXY.iY,aInnerXY.iX*372/1024,0,aPixPerScan,aSurfacePtr,aLinesBL); + DdaLine(0,aInnerXY.iY,aInnerXY.iX*591/1024,0,aPixPerScan,aSurfacePtr,aLinesBL); + DdaLine(0,aInnerXY.iY,aInnerXY.iX*859/1024,0,aPixPerScan,aSurfacePtr,aLinesBL); + + DdaLine(0,aInnerXY.iY,aInnerXY.iX,aInnerXY.iY-aInnerXY.iY*180/1024,aPixPerScan,aSurfacePtr,aLinesBL); + DdaLine(0,aInnerXY.iY,aInnerXY.iX,aInnerXY.iY-aInnerXY.iY*372/1024,aPixPerScan,aSurfacePtr,aLinesBL); + DdaLine(0,aInnerXY.iY,aInnerXY.iX,aInnerXY.iY-aInnerXY.iY*591/1024,aPixPerScan,aSurfacePtr,aLinesBL); + DdaLine(0,aInnerXY.iY,aInnerXY.iX,aInnerXY.iY-aInnerXY.iY*859/1024,aPixPerScan,aSurfacePtr,aLinesBL); + + DdaLine(0,0,aInnerXY.iX*180/1024,aInnerXY.iY,aPixPerScan,aSurfacePtr,aLinesTL); + DdaLine(0,0,aInnerXY.iX*372/1024,aInnerXY.iY,aPixPerScan,aSurfacePtr,aLinesTL); + DdaLine(0,0,aInnerXY.iX*591/1024,aInnerXY.iY,aPixPerScan,aSurfacePtr,aLinesTL); + DdaLine(0,0,aInnerXY.iX*859/1024,aInnerXY.iY,aPixPerScan,aSurfacePtr,aLinesTL); + + DdaLine(0,0,aInnerXY.iX,aInnerXY.iY*180/1024,aPixPerScan,aSurfacePtr,aLinesTL); + DdaLine(0,0,aInnerXY.iX,aInnerXY.iY*372/1024,aPixPerScan,aSurfacePtr,aLinesTL); + DdaLine(0,0,aInnerXY.iX,aInnerXY.iY*591/1024,aPixPerScan,aSurfacePtr,aLinesTL); + DdaLine(0,0,aInnerXY.iX,aInnerXY.iY*859/1024,aPixPerScan,aSurfacePtr,aLinesTL); + + DdaLine(0,aInnerXY.iY-aInnerXY.iY*180/1024,aInnerXY.iX,aInnerXY.iY,aPixPerScan,aSurfacePtr,aLinesBR); + DdaLine(0,aInnerXY.iY-aInnerXY.iY*372/1024,aInnerXY.iX,aInnerXY.iY,aPixPerScan,aSurfacePtr,aLinesBR); + DdaLine(0,aInnerXY.iY-aInnerXY.iY*591/1024,aInnerXY.iX,aInnerXY.iY,aPixPerScan,aSurfacePtr,aLinesBR); + DdaLine(0,aInnerXY.iY-aInnerXY.iY*859/1024,aInnerXY.iX,aInnerXY.iY,aPixPerScan,aSurfacePtr,aLinesBR); + + DdaLine(aInnerXY.iX-aInnerXY.iX*180/1024,0,aInnerXY.iX,aInnerXY.iY,aPixPerScan,aSurfacePtr,aLinesBR); + DdaLine(aInnerXY.iX-aInnerXY.iX*372/1024,0,aInnerXY.iX,aInnerXY.iY,aPixPerScan,aSurfacePtr,aLinesBR); + DdaLine(aInnerXY.iX-aInnerXY.iX*591/1024,0,aInnerXY.iX,aInnerXY.iY,aPixPerScan,aSurfacePtr,aLinesBR); + DdaLine(aInnerXY.iX-aInnerXY.iX*859/1024,0,aInnerXY.iX,aInnerXY.iY,aPixPerScan,aSurfacePtr,aLinesBR); + + } +/** +Fill the given surface with a fan of lines over a solid color. + +Similar to FillSurfaceL(), but with a fan of lines overlayed. +One fan is drawn about the top-left, and second fan at bottom-right. +The fan contains 8 segments. + +@param aSurface The surface to be filled. +@param aColor The color to fill it with. +@param aLines The color of the grid lines. +*/ +void CSurfaceUtility::FanFillSurfaceL(TSurfaceId& aSurface, const TRgb& aColor, const TRgb& aLinesTL, const TRgb& aLinesBR) + { + FillSurfaceL(aSurface,aColor); + RSurfaceManager::TInfoBuf infoBuf; + RSurfaceManager::TSurfaceInfoV01& info = infoBuf(); + + User::LeaveIfError(iManager.SurfaceInfo(aSurface, infoBuf)); + TUint32 linesTL = 0; + TUint32 linesBR = 0; + TUint32 linesTR = 0; + TUint32 linesBL = 0; + TBool use16 = EFalse; + TRgb rgbLinesTR(0,0,0); + TRgb rgbLinesBL(255,255,255); + + switch (info.iPixelFormat) + { + case EUidPixelFormatXRGB_8888: + { + linesBR = aLinesBR.Color16MU(); + linesTL = aLinesTL.Color16MU(); + linesTR = rgbLinesTR.Color16MU(); + linesBL = rgbLinesBL.Color16MU(); +#ifdef ALPHA_FIX_24BIT + linesBR |= ((ALPHA_FIX_24BIT)&0xff)<<24; + linesTL |= ((ALPHA_FIX_24BIT)&0xff)<<24; + linesTR |= ((ALPHA_FIX_24BIT)&0xff)<<24; + linesBL |= ((ALPHA_FIX_24BIT)&0xff)<<24; +#endif + break; + } + case EUidPixelFormatARGB_8888: + { + linesBR = aLinesBR.Color16MA(); + linesTL = aLinesTL.Color16MA(); + linesTR = rgbLinesTR.Color16MA(); + linesBL = rgbLinesBL.Color16MA(); + break; + } + case EUidPixelFormatARGB_8888_PRE: + { + linesBR = aLinesBR.Color16MAP(); + linesTL = aLinesTL.Color16MAP(); + linesTR = rgbLinesTR.Color16MAP(); + linesBL = rgbLinesBL.Color16MAP(); + break; + } + case EUidPixelFormatXRGB_4444: + case EUidPixelFormatARGB_4444: + { + linesBR = aLinesBR.Color4K(); + linesTL = aLinesTL.Color4K(); + linesTR = rgbLinesTR.Color4K(); + linesBL = rgbLinesBL.Color4K(); + use16 = ETrue; + break; + } + case EUidPixelFormatRGB_565: + { + linesBR = aLinesBR.Color64K(); + linesTL = aLinesTL.Color64K(); + linesTR = rgbLinesTR.Color64K(); + linesBL = rgbLinesBL.Color64K(); + use16 = ETrue; + break; + } + default: + { + User::Leave(KErrNotSupported); + break; + } + } + if (info.iSize.iHeight<0 || info.iSize.iWidth<0 || info.iStride<0) + { + User::Leave(KErrCorrupt); + } + if (info.iSize.iHeight==0 || info.iSize.iWidth==0 || info.iStride==0) + { + User::Leave(KErrNotReady); + } + RChunk chunk; + User::LeaveIfError(iManager.MapSurface(aSurface, chunk)); + CleanupClosePushL(chunk); + + TInt offsetToFirstBuffer; + User::LeaveIfError(iManager.GetBufferOffset(aSurface, 0, offsetToFirstBuffer)); + TUint8* surfacePtr = chunk.Base() + offsetToFirstBuffer; + TPoint innerXY(info.iSize.iWidth-1,info.iSize.iHeight-1); + if (use16) + { + if ( info.iSize.iWidth*2>info.iStride) + { + User::Leave(KErrOverflow); + } + FanFill(innerXY,info.iStride/2,(TUint16*)surfacePtr,linesTL,linesBR,linesBL,linesTR); + } + else + { + if ( info.iSize.iWidth*4>info.iStride) + { + User::Leave(KErrOverflow); + } + FanFill(innerXY,info.iStride/4,(TUint*)surfacePtr,linesTL,linesBR,linesBL,linesTR); + } + + iSurfaceUpdateSession.SubmitUpdate(KAllScreens, aSurface, 0, NULL); + + CleanupStack::PopAndDestroy(/* chunk */); + } +/** +Fill the given surface with vertical line at the given position + +Similar to FillSurfaceL(), but with a vertical line overlayed. +The position along the surface is given as a percentage from the left + +@param aSurface The surface to be filled. +@param aColor The color to fill it with. +@param aLine The color of the line. +@param aPosition Position of the vertical line given as a percentage across the surface from the left edge +*/ +void CSurfaceUtility::LineFillSurfaceL(TSurfaceId& aSurface, const TRgb& aBackColor, const TRgb& aLineColor, TInt aPosition) + { + if (aPosition<0 || aPosition>100) + { + aPosition=0; + } + FillSurfaceL(aSurface,aBackColor); + RSurfaceManager::TInfoBuf infoBuf; + RSurfaceManager::TSurfaceInfoV01& info = infoBuf(); + + User::LeaveIfError(iManager.SurfaceInfo(aSurface, infoBuf)); + TUint32 lineColor = 0; + TBool use16 = EFalse; + + switch (info.iPixelFormat) + { + case EUidPixelFormatXRGB_8888: + { + lineColor = aLineColor.Color16MU(); +#ifdef ALPHA_FIX_24BIT + lineColor |= ((ALPHA_FIX_24BIT)&0xff)<<24; +#endif + break; + } + case EUidPixelFormatARGB_8888: + { + lineColor = aLineColor.Color16MA(); + break; + } + case EUidPixelFormatARGB_8888_PRE: + { + lineColor = aLineColor.Color16MAP(); + break; + } + case EUidPixelFormatXRGB_4444: + case EUidPixelFormatARGB_4444: + { + lineColor = aLineColor.Color4K(); + use16 = ETrue; + break; + } + case EUidPixelFormatRGB_565: + { + lineColor = aLineColor.Color64K(); + use16 = ETrue; + break; + } + default: + { + User::Leave(KErrNotSupported); + break; + } + } + RChunk chunk; + User::LeaveIfError(iManager.MapSurface(aSurface, chunk)); + + TInt offsetToFirstBuffer; + User::LeaveIfError(iManager.GetBufferOffset(aSurface, 0, offsetToFirstBuffer)); + TUint8* surfacePtr = chunk.Base() + offsetToFirstBuffer; + if (use16) + { + DdaLine((info.iSize.iWidth*aPosition)/100,0,(info.iSize.iWidth*aPosition)/100, + info.iSize.iHeight-1,info.iStride/2,(TUint16*)surfacePtr,lineColor); + } + else + { + DdaLine((info.iSize.iWidth*aPosition)/100,0,(info.iSize.iWidth*aPosition)/100, + info.iSize.iHeight-1,info.iStride/4,(TUint*)surfacePtr,lineColor); + } + + chunk.Close(); + + iSurfaceUpdateSession.SubmitUpdate(KAllScreens, aSurface, 0, NULL); + } +/** + * Generates a bitmap equivalent to the surface. + * Can reuse an existing bitmap or create a new bitmap. + * The existing bitmap must be an exact match (eg previously generated by this method) + **/ +CFbsBitmap* CSurfaceUtility::EquivalentBitmapL(TSurfaceId& aSurface,CFbsBitmap* aCopyToMayBeNull) + { + RSurfaceManager::TInfoBuf infoBuf; + RSurfaceManager::TSurfaceInfoV01& info = infoBuf(); + + User::LeaveIfError(iManager.SurfaceInfo(aSurface, infoBuf)); + TInt bytesPerPixel=0; + TDisplayMode bitmapMode = ENone; + switch (info.iPixelFormat) + { + case EUidPixelFormatXRGB_8888: + { + bitmapMode = EColor16MU; + bytesPerPixel = 4; + break; + } + case EUidPixelFormatARGB_8888: + { + bitmapMode=EColor16MA; + bytesPerPixel = 4; + break; + } + case EUidPixelFormatARGB_8888_PRE: + { + bitmapMode=EColor16MAP; + bytesPerPixel = 4; + break; + } + case EUidPixelFormatXRGB_4444: + case EUidPixelFormatARGB_4444: + { + bitmapMode=EColor4K; + bytesPerPixel = 2; + break; + } + case EUidPixelFormatRGB_565: + { + bitmapMode=EColor64K; + bytesPerPixel = 2; + break; + } + default: + { + User::Leave(KErrNotSupported); + break; + } + } + CFbsBitmap* retVal=NULL; + if (aCopyToMayBeNull) + { + retVal=aCopyToMayBeNull; + if (retVal->SizeInPixels()!=info.iSize) + User::Leave(KErrCorrupt); + if (retVal->DisplayMode()!=bitmapMode) + User::Leave(KErrCorrupt); + } + else + { + retVal=new CFbsBitmap; + CleanupStack::PushL(retVal); + User::LeaveIfError(retVal->Create(info.iSize,bitmapMode)); + } + RChunk chunk; + CleanupClosePushL(chunk); + User::LeaveIfError(iManager.MapSurface(aSurface, chunk)); + TInt offsetToFirstBuffer; + User::LeaveIfError(iManager.GetBufferOffset(aSurface, 0, offsetToFirstBuffer)); + TUint8* surfacePtr = chunk.Base() + offsetToFirstBuffer; + TUint8* bitmapPtr = (TUint8*)retVal->DataAddress(); + TInt copyBytes=info.iSize.iWidth*bytesPerPixel; + for (TInt y=0;yDataStride(); + } + CleanupStack::PopAndDestroy(&chunk); + if (!aCopyToMayBeNull) + CleanupStack::Pop(retVal); + return retVal; + } + +/** +Destroy a surface. + +As well as destroying the surface, it is removed from the set held for +destruction during tear down. + +@param aSurface The surface to be destroyed. +*/ +void CSurfaceUtility::DestroySurface(TSurfaceId& aSurface) + { + TInt index = iSurfaces.Find(aSurface); + + if (index != KErrNotFound) + { + iSurfaces.Remove(index); + } + + TInt err = iManager.CloseSurface(aSurface); + if (err!=KErrNone) + LOG(("Error closing surfaces: 0x%X\n", err)); + } + + +/** +Submit an update to a surface to the update server. + +@param aScreenNumber The screen to be updated where the surface is shown. +@param aSurface The surface which has been updated. +@param aRegion The area of the surface affected, or NULL for all of it.*/ +void CSurfaceUtility::SubmitUpdate(TInt /* aScreenNumber */, const TSurfaceId& aSurface, const TRegion* aRegion,TInt aBufferNumber) + { + TInt err =iSurfaceUpdateSession.SubmitUpdate(KAllScreens, aSurface, aBufferNumber, aRegion); + if (err!=KErrNone) + LOG(("Error submitting update: 0x%X\n", err)); + } + +/** +Map and submit an update to a surface to the update server. + +@param aChunk The chunk of memory to be mapped +@param aScreenNumber The screen to be updated where the surface is shown. +@param aSurface The surface which has been updated. +@param aRegion The area of the surface affected, or NULL for all of it.*/ +void CSurfaceUtility::MapAndSubmitUpdateL(RChunk& aChunk, + TInt /* aScreenNumber */, + const TSurfaceId& aSurface, + const TRegion* aRegion) + { + User::LeaveIfError(iManager.MapSurface(aSurface, aChunk)); + aChunk.Close(); + TInt err =iSurfaceUpdateSession.SubmitUpdate(KAllScreens, aSurface, 0, aRegion); + if (err!=KErrNone) + LOG(("Error submitting update: 0x%X\n", err)); + } + +void CSurfaceUtility::MapSurfaceL(const TSurfaceId& aSurface, RChunk& aChunk) + { + User::LeaveIfError(iManager.MapSurface(aSurface, aChunk)); + } + +void CSurfaceUtility::CopyBitmapToSurfaceL(TSurfaceId& aSurface, const CFbsBitmap& aBitmap) + { + TSize size = SurfaceSize(aSurface); + + TDisplayMode bmpFormat = aBitmap.DisplayMode(); + TInt stride = size.iWidth * 4; // Default to four bytes per pixel + + RChunk chunk; + User::LeaveIfError(iManager.MapSurface(aSurface, chunk)); + CleanupClosePushL(chunk); + + TInt offsetToFirstBuffer; + User::LeaveIfError(iManager.GetBufferOffset(aSurface, 0, offsetToFirstBuffer)); + + // Copy the data from the bitmap into the surface. + TPoint start; + TUint8 *pSurfStart = chunk.Base() + offsetToFirstBuffer; + for (start.iY = 0; start.iY < size.iHeight; start.iY++) + { + // Set up a descriptor for the current line in the surface and get pixels. + TPtr8 ptr(pSurfStart + start.iY * stride, stride); + aBitmap.GetScanLine(ptr, start, size.iWidth, bmpFormat); + } + + TInt err =iSurfaceUpdateSession.SubmitUpdate(KAllScreens, aSurface, 0, NULL); + if (err!=KErrNone) + { + LOG(("Error submitting update: 0x%X\n", err)); + } + + CleanupStack::PopAndDestroy(/* chunk */); + } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tdynamicres/src/t_wsdynamicresclassictestserver.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tdynamicres/src/t_wsdynamicresclassictestserver.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,59 @@ +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file +*/ + +#include "wsdynamicresclassic.h" +#include + +_LIT( KServerName, "wsdynamicresclassictestserver" ); + +GLDEF_C const TTestName ServerName() +/** + * ServerName + * + * @return - The TEF server name + */ + { + TTestName serverName(KServerName); + return serverName; + } + +GLDEF_C CTestSuite* CreateTestSuiteL() +/** + * Create the overall test suite. + * + * @return - The top level suite + */ + { + START_SUITE; + + ADD_TEST_SUITE( CWsDynamicResClassic ); + + END_SUITE; + } + +GLDEF_C CTestStep* CreateTEFTestStep(const TDesC& , CTEFUnitServer& /* aServer */) +/** + * Create individual test steps, outside the suite. + */ + { + // Initialise test step object to NULL if no TEF step is found + CTestStep* testStep = NULL; + + return testStep; + } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tdynamicres/src/t_wsdynamicrestestserver.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tdynamicres/src/t_wsdynamicrestestserver.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,69 @@ +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file +*/ +#include +#include "globalsettings.h" +#include "screenselect.h" +#include "wsdynamicresbase.h" +#include "wsdynamicresbasic.h" + +_LIT( KServerName, "wsdynamicrestestserver" ); + +GLDEF_C const TTestName ServerName() +/** + * ServerName + * + * @return - The TEF server name + */ + { + TTestName serverName(KServerName); + return serverName; + } + +GLDEF_C CTestSuite* CreateTestSuiteL() +/** + * Create the overall test suite. + * + * @return - The top level suite + */ + { + START_SUITE; + ADD_TEST_SUITE( CWsDynamicResBasic ); + ADD_TEST_SUITE( CGlobalSettings ); + END_SUITE; + } + +_LIT(KSelectScreen0, "SelectScreen0"); +_LIT(KSelectScreen1, "SelectScreen1"); + +GLDEF_C CTestStep* CreateTEFTestStep(const TDesC& aStepName, CTEFUnitServer& /* aServer */) +/** + * Create individual test steps, outside the suite. + */ + { + // Initialise test step object to NULL if no TEF step is found + CTestStep* testStep = NULL; + + if (aStepName == KSelectScreen0) + testStep = new CScreenSelect(0, aStepName); + else if (aStepName == KSelectScreen1) + testStep = new CScreenSelect(1, aStepName); + + return testStep; + } + diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tdynamicres/src/t_wsdynamicreswinbase.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tdynamicres/src/t_wsdynamicreswinbase.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,980 @@ +// Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file +*/ + + +#include +#include +#include +#include +#include "teflogextensions.h" +#include "t_wsdynamicreswinbase.h" +#include "globalsettings.h" +#include +#include +#include +#include +#include + +#if (!defined(K_DISPLAY_CH_MAJOR_VERSION_NUMBER) && !defined(K_DISPLAY_CH_MINOR_VERSION_NUMBER)) +#define MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER +#endif + +_LIT(KMonospaceTestFontTypefaceName,"Arial"); +const TInt KMaxFontSize = 150; +TBool CWsDynamicResWinBase::iTransparencyEnabled=EFalse; + +CWsDynamicResWinBase::CWsDynamicResWinBase(): + iDoTearDown(EFalse), + iSession(TGlobalSettings::Instance().iScreen) +{ +} + +void CWsDynamicResWinBase::SetupL() + { + SetupL(EFalse); + } +CActiveScheduler CWsDynamicResWinBase::iScheduler; + +void CWsDynamicResWinBase::SetupL(TBool aUseOtherScreenForInfo) + { + if (CActiveScheduler::Current()!=&iScheduler) + { + new (&iScheduler) CActiveScheduler; + CActiveScheduler::Install(&iScheduler); + } + iDoTearDown=ETrue; + iRed.SetInternal(0xFFFF0000); + iGreen.SetInternal(0xFF00FF00); + iBlue.SetInternal(0xFF0000FF); + iCyan.SetInternal(0xFF00FFFF); + iMagenta.SetInternal(0xFFFF00FF); + iYellow.SetInternal(0xFFFFFF00); + iWhite.SetInternal(0xFFFFFFFF); + iLastGceHoleColor.SetInternal(0); + TITLE_BACKGROUND=iCyan; + COMPARE_BACKGROUND=iBlue; + + ASSERT_EQUALS_X(iSession.Connect(), KErrNone); + + {//Stolen from TAuto CloseAllPanicWindows() + TInt idFocus = iSession.GetFocusWindowGroup(); + TWsEvent event; + event.SetType(EEventKey); //EEventKeyDown + TKeyEvent *keyEvent = event.Key(); + keyEvent->iCode = EKeyEscape; + keyEvent->iScanCode = EStdKeyEscape; + keyEvent->iModifiers = 0; + TInt theLimit = 50; + while(idFocus != NULL && (theLimit-- > 0)) + { + iSession.SendEventToAllWindowGroups(event); + TInt idNewFocus = iSession.GetFocusWindowGroup(); + if (idNewFocus!=idFocus) + { + INFO_PRINTF1(_L("A window was closed [probably a panic box from the previous test].")); + } + idFocus=idNewFocus; + } + } + TInt err = KErrNone; + + TRAP(err, iScreenDevice = new (ELeave) CWsScreenDevice(iSession)); + PRINT_ON_ERROR2_L(err, _L("Failed to create screen device: %d"), err); + ASSERT_EQUALS_X(iScreenDevice->Construct(TGlobalSettings::Instance().iScreen), KErrNone); + iDisplayMode = iScreenDevice->DisplayMode(); // Get default display mode + + CheckAndConnectScreen(); + + TRAP(err, iGc = new (ELeave) CWindowGc(iScreenDevice)); + PRINT_ON_ERROR2_L(err, _L("Failed to create graphics context: %d"), err); + ASSERT_EQUALS_X(iGc->Construct(), KErrNone); + + iGroup = RWindowGroup(iSession); + ASSERT_EQUALS_X(iGroup.Construct(++iWindowHandle,iScreenDevice), KErrNone); + iGroup.SetOrdinalPositionErr(0, KPasswordWindowGroupPriority - 1); // Added code ---- Fastpath + iSession.Flush(); + + if (aUseOtherScreenForInfo) + { + if (iSession.NumberOfScreens()>1) + { //Create server objects for info windows to appear on alternate screen + TInt alternateScreenNum=iSession.NumberOfScreens()-1; + if (TGlobalSettings::Instance().iScreen==alternateScreenNum) + { //Alternate screen is last screen, or first screen if that is being tested. + alternateScreenNum=0; + } + + TRAP(err, iInfoScreenDevice = new (ELeave) CWsScreenDevice(iSession)); + PRINT_ON_ERROR2_L(err, _L("Failed to create second screen device: %d"), err); + ASSERT_EQUALS_X(iInfoScreenDevice->Construct(alternateScreenNum), KErrNone); + + TRAP(err, iInfoGc = new (ELeave) CWindowGc(iInfoScreenDevice)); + PRINT_ON_ERROR2_L(err, _L("Failed to create second graphics context: %d"), err); + ASSERT_EQUALS_X(iInfoGc->Construct(), KErrNone); + + iInfoGroupInstance = RWindowGroup(iSession); + ASSERT_EQUALS_X(iInfoGroupInstance.Construct(++iWindowHandle,iInfoScreenDevice), KErrNone); + iInfoGroup=&iInfoGroupInstance; + } + else + { //If alternate screen is not available then no text or compare windows should be created! + iInfoScreenDevice=iScreenDevice; //it is "convenient" for the device to still be good. + iInfoGc=NULL; + iInfoGroup=NULL; + } + } + else + { // + iInfoScreenDevice=iScreenDevice; + iInfoGc=iGc; + iInfoGroup=&iGroup; + } + + if (iInfoGroup && iInfoGc) + { + // Add a plain background window to obscure anything else that + // happens to be behind the test. Setting this window's display mode is also + // used to set the screen device display mode, and hence the composition + // mode: alpha or chroma key. + iBackground = RBlankWindow(iSession); + ASSERT_EQUALS_X(iBackground.Construct(*iInfoGroup, ++iWindowHandle), KErrNone); + + iBackground.SetOrdinalPosition(100); // Behind anything else in this group. + iBackground.SetColor(TRgb(iWhite)); + //iBackground.SetExtent(TPoint(-1000,-1000),TSize(3000,3000)); + iBackground.Activate(); + iBackground.SetVisible(ETrue); + } + iSession.Flush(); + + RWindow testTrans(iSession); + ASSERT_EQUALS_X(testTrans.Construct(iGroup, ++iWindowHandle), KErrNone); + iTransparencyEnabled=(testTrans.SetTransparencyFactor(iWhite)==KErrNone); + if (iTransparencyEnabled) + { + TTestName testName; + testName.Format(_L("Screen %i, depth %i: Found Trans Man"), + TGlobalSettings::Instance().iScreen + ); + UpdateTitleWindowL(testName,KMaxInfoLines-1); + } + else + { + TTestName testName; + testName.Format(_L("Screen %i, depth %i: No Trans Man"), + TGlobalSettings::Instance().iScreen + ); + UpdateTitleWindowL(testName,KMaxInfoLines-1); + } + testTrans.Close(); + } + + +void CWsDynamicResWinBase::CheckAndConnectScreen() + { + if (TGlobalSettings::Instance().iDisconnected) //set from script file to match wsini keyword SIMULATE_STARTUP_DISCONNECTED + { + //Verify that the display really is disconnected + ASSERT_TRUE_X(iScreenDevice != NULL); + MDisplayControl* interface = static_cast(iScreenDevice->GetInterface(MDisplayControl::ETypeId)); + ASSERT_TRUE_X(interface != NULL); + RArray resolutions; + const TInt err = interface->GetResolutions(resolutions); + ASSERT_EQUALS_X(err, KErrDisconnected); + resolutions.Close(); + } + +#ifndef MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER + //make sure display is attached to screen (only if I/F is available at compile time...) + TInt displayState = ENormalResolution; + UserSvr::HalFunction(EHalGroupDisplay | (TGlobalSettings::Instance().iScreen<<16), EDisplayHalSetDisplayState, &displayState, NULL); + Pause(200); +#endif + + if (TGlobalSettings::Instance().iDisconnected) + { + //Verify that the display now is connected + MDisplayControl* interface = static_cast(iScreenDevice->GetInterface(MDisplayControl::ETypeId)); + RArray resolutions; + const TInt err = interface->GetResolutions(resolutions); + ASSERT_EQUALS_X(err, KErrNone); + const_cast(TGlobalSettings::Instance()).iDisconnected = EFalse; + resolutions.Close(); + } + } + +/** +Common tear down code for all tests. + +Windows, group and session created are closed. Screen device is destroyed. +Surfaces, manager and update session are closed. +*/ +void CWsDynamicResWinBase::TearDownL() + { + iDoTearDown=EFalse; + if (iInfoGc!=iGc) + delete iInfoGc; + delete iGc; + if (iInfoScreenDevice!=iScreenDevice) + delete iInfoScreenDevice; + delete iScreenDevice; + + iGroup.Close(); + if (iInfoGroupInstance.WsHandle()) + iInfoGroupInstance.Close(); + iSession.Flush(); + iSession.Close(); + } +/** + * Note that this is not the ideal mechanism. + * A derived class may thinks its TearDown is safe to do from delete, but in the class it is derived from it may not be safe + **/ +void CWsDynamicResWinBase::TearDownFromDeleteL() + { + CWsDynamicResWinBase::TearDownL(); //Explicitly call the non-derived implementation. + } + +CWsDynamicResWinBase::~CWsDynamicResWinBase() +{ + if (iDoTearDown) + TearDownFromDeleteL(); //This mechanism is not entirely clean to use. +} +/** +Pause for the given number of milliseconds. + +@param aMilliseconds Time to wait in milliseconds. +*/ +void CWsDynamicResWinBase::Pause(TInt aMilliseconds) + { + User::After(TTimeIntervalMicroSeconds32(aMilliseconds * 1000)); + } +// This handles any non-member uses of the extended ASSERT_XXX macros +void TefUnitFailLeaveL() + { + + User::Leave(KErrTEFUnitFail); + } +/** + * side-effect: log the state info just before I leave! + * Note that this only logs intentional assertion failures. + * Fails due to panics or throws won't log this info. + **/ +void CWsDynamicResWinBase::TefUnitFailLeaveL() + { + for (TInt line=0;line aTitle,TRefByValue aDetail) + { + iTestName=aTitle; + iTestInfo[0]=aDetail; + + TRect screenSize(iInfoScreenDevice->SizeInPixels()); + TPoint oneThird(screenSize.iBr.iX/3,screenSize.iBr.iY/3); + TRect winSize(0,0,oneThird.iX,oneThird.iY); + + if (oneThird.iX>oneThird.iY) + { + oneThird.iY=0; + winSize.iBr.iY=screenSize.iBr.iY; + } + else + { + oneThird.iX=0; + winSize.iBr.iX=screenSize.iBr.iX; + } + winSize.Shrink(5,5); + + if (iInfoGc) + { + iTitle=RWindow(iSession); + ASSERT_EQUALS_X(iTitle.Construct(*iInfoGroup, ++iWindowHandle), KErrNone); + iTitle.SetBackgroundColor(iCyan); + iTitle.SetExtent(winSize.iTl,winSize.Size()); + iTitle.Activate(); + + RepaintTitleWindowL(); + iTitle.SetVisible(ETrue); + + winSize.Move(oneThird); + iCompare=RWindow(iSession); + ASSERT_EQUALS_X(iCompare.Construct(*iInfoGroup, ++iWindowHandle), KErrNone); + iCompare.SetBackgroundColor(COMPARE_BACKGROUND); + iCompare.SetExtent(winSize.iTl,winSize.Size()); + iCompare.Activate(); + iCompare.BeginRedraw(); + ActivateWithWipe(iInfoGc,iCompare,COMPARE_BACKGROUND); + + TFontSpec fspec(KMonospaceTestFontTypefaceName,KMaxFontSize); + CFont *font=NULL; + ASSERT_EQUALS(iScreenDevice->GetNearestFontToDesignHeightInTwips(font,fspec),KErrNone); + iInfoGc->UseFont(font); + iInfoGc->DrawText(_L("Simulation"),winSize.Size(),winSize.Size().iHeight-5,iGc->ECenter); + + iInfoGc->Deactivate(); + iCompare.EndRedraw(); + iCompare.SetVisible(ETrue); + if (iScreenDevice!=iInfoScreenDevice) + { + winSize.Move(-oneThird); + } + else + { + winSize.Move(oneThird); + } + } + else + { + winSize=iScreenDevice->SizeInPixels(); + } + + iTestPos=winSize; + iTestPointCentre=winSize.Center(); + iCenteredFrontWinRect=winSize; + iCenteredFrontWinRect.Shrink(winSize.Size().iWidth/3,winSize.Size().iHeight/3); + + } +/** Makes the compare window larger by covering the test window area as well. + * Copes with vertically aligned screens, but will be naughty if called multiple times!!! + * @param aGoLarger If set false, resets the size back. + **/ +void CWsDynamicResWinBase::LargerCompareWindow(TBool aGoLarger) + { + TPoint currPos=iCompare.AbsPosition(); + TSize currSize=iCompare.Size(); + if (currPos.iX>=1; + } + else + { + if (aGoLarger) + currSize.iWidth<<=1; + else + currSize.iWidth>>=1; + } + iCompare.SetSize(currSize); + } + + +/** Puts a line of text on the LHS window. + * Repaints the window. The line of text will also be shown in the log if the test fails. + * @param aDetail The text to display + * @param aIndex The row number to display at + **/ +void CWsDynamicResWinBase::UpdateTitleWindowL(TRefByValue aDetail,TInt aIndex) + { + ASSERT(aIndex>=0 && aIndexActivate(aWin); + aGc->SetBrushColor(aColor); + aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + if (aColor!=TRgb(0,0) && !iTransparencyEnabled) //presume that all redraw-stored windows will draw background + { + aGc->Clear(); + return ETrue; //window was cleared + } + return EFalse; + } + +CWindowGc* CWsDynamicResWinBase::GcForWindow(RWindow& aWin) + { + if (aWin.WsHandle()==NULL) + return NULL; //can't activate uninitialised window. + CWindowGc* gc=iGc; + if (iGc!=iInfoGc) + if (&aWin==&iCompare || &aWin==&iTitle) + gc=iInfoGc; + else if (iInfoGroup && aWin.WindowGroupId()==iInfoGroup->WindowGroupId()) + gc=iInfoGc; + return gc; + } +/** Activates an appropriate predefined GC on the specified window and wipes the background if necessary. + * @param aWin The window to wipe + * @param aColor The colour to wipe with (if necessary) + * @return the GC to use for drawing and deactivate at end. This may be NULL if the window is not "live" + **/ +CWindowGc* CWsDynamicResWinBase::BeginActivateWithWipe(TBool aInvalidate,RWindow& aWin,TRgb aColor) + { + CWindowGc* gc=GcForWindow(aWin); + iSession.Flush(); + if (gc==NULL) + return gc; //can't activate uninitialised window. + if (aInvalidate) + aWin.Invalidate(); + iSession.Flush(); + aWin.BeginRedraw(); + iSession.Flush(); + ActivateWithWipe(gc,aWin,aColor); + return gc; + } + +/** Activates an appropriate predefined GC on the specified window and wipes the background if necessary. + * @param aWin The window to wipe + * @param aColor The colour to wipe with (if necessary) + * @return the GC to use for drawing and deactivate at end. This may be NULL if the window is not "live" + **/ +CWindowGc* CWsDynamicResWinBase::BeginActivateWithWipe(TBool aInvalidate,TRect aRect,RWindow& aWin,TRgb aColor) + { + if (aWin.WsHandle()==NULL) + return NULL; //can't activate uninitialised window. + if (aInvalidate) + aWin.Invalidate(aRect); + aWin.BeginRedraw(aRect); + CWindowGc* gc=iGc; + if (iGc!=iInfoGc) + if (&aWin==&iCompare || &aWin==&iTitle) + gc=iInfoGc; + else if (aWin.WindowGroupId()==iInfoGroup->WindowGroupId()) + gc=iInfoGc; + ActivateWithWipe(gc,aWin,aColor); + return gc; + } + +TBool CWsDynamicResWinBase::InvalidateRegion(const TRegion& aRegion,RWindow& aWin) + { + if (aWin.WsHandle()==NULL) + return false; //can't activate uninitialised window. + for (TInt ii = 0; ii < aRegion.Count(); ii++) + { + aWin.Invalidate(aRegion[ii]); + } + return true; + } + +CWindowGc* CWsDynamicResWinBase::BeginActivateWithWipe(const TRegion& aRegion,RWindow& aWin,TRgb aColor) + { + if (!InvalidateRegion(aRegion,aWin)) + return NULL; //can't activate uninitialised window. + + aWin.BeginRedraw(); + CWindowGc* gc=iGc; + if (iGc!=iInfoGc) + if (&aWin==&iCompare || &aWin==&iTitle) + gc=iInfoGc; + else if (aWin.WindowGroupId()==iInfoGroup->WindowGroupId()) + gc=iInfoGc; + ActivateWithWipe(gc,aWin,aColor); + return gc; + } + + +/** Paints the LHS window with rows of text. + * + **/ +void CWsDynamicResWinBase::RepaintTitleWindowL() + { + if (iTitle.WsHandle()) + { + iTitle.Invalidate(); + + iTitle.BeginRedraw(); + ActivateWithWipe(iInfoGc,iTitle,TITLE_BACKGROUND); + iInfoGc->SetUnderlineStyle(EUnderlineOn); + TSize winSize=iTitle.Size(); + TRect textRect(winSize); + textRect.iBr.iY/=4; + TFontSpec fspec(KMonospaceTestFontTypefaceName,KMaxFontSize); + CFont *font=NULL; + ASSERT_EQUALS(iInfoScreenDevice->GetNearestFontToDesignHeightInTwips(font,fspec),KErrNone); + iInfoGc->UseFont(font); + iInfoGc->DrawText(iTestName,textRect,textRect.iBr.iY/2,iGc->ECenter); + iInfoGc->SetUnderlineStyle(EUnderlineOff); + textRect.iTl.iY=textRect.iBr.iY; + TInt rowHeight=winSize.iHeight*3/(4*(KMaxInfoLines+1)); + textRect.iBr.iY+=rowHeight; + for (TInt index=0;indexDrawText(iTestInfo[index],textRect,textRect.Size().iHeight*3/4,iInfoGc->ECenter); + textRect.Move(0,rowHeight); + } + iInfoGc->DiscardFont(); + iInfoGc->Deactivate(); + iTitle.EndRedraw(); + iInfoScreenDevice->ReleaseFont(font); + + iSession.Flush(); + iSession.Finish(); + } + } + +/** Useful test culled from other GCE test classes. + * + * + * + **/ +TBool CWsDynamicResWinBase::DisplayHasAlpha() const + { + return (iDisplayMode == EColor16MA || iDisplayMode == EColor16MAP); + } +/** Test using an indipendent method that GCE version of WServ is running + * This method can only be called after the testcase is started + * + * @return true if WServ version is GCE technology, false if legacy technology + **/ +TBool CWsDynamicResWinBase::GCEIsSupported() const + { + CFbsDrawDevice* screenDevice=NULL; + TDisplayMode displayMode=iScreenDevice->DisplayMode(); + TRAPD(err, screenDevice = CFbsDrawDevice::NewScreenDeviceL(TGlobalSettings::Instance().iScreen, displayMode)); + TBool rv=EFalse; + if(err == KErrNone) + { + TAny* p=NULL; + rv=(screenDevice->GetInterface(KSurfaceInterfaceID, p)==KErrNone); + delete screenDevice; + } + return rv; + } +/** Test using an indipendent method that GCE version of WServ is running + * This method can be called at any time, even by external code, but creates temporary window session objects + * + * @return true if WServ version is GCE technology, false if legacy technology + **/ +TBool CWsDynamicResWinBase::GCEIsSupportedStatic() + { + CFbsDrawDevice* screenDevice=NULL; + RWsSession session; + if (session.Connect()!=KErrNone) + { + return EFalse; + } + TDisplayMode displayMode=ENone; + {CWsScreenDevice screen(session); + if (screen.Construct(TGlobalSettings::Instance().iScreen)!=KErrNone) + { + return EFalse; + } + displayMode=screen.DisplayMode(); + }//screen destroyed + TRAPD(err, screenDevice = CFbsDrawDevice::NewScreenDeviceL(TGlobalSettings::Instance().iScreen, displayMode)); + TBool rv=EFalse; + if(err == KErrNone) + { + TAny* p=NULL; + rv=(screenDevice->GetInterface(KSurfaceInterfaceID, p)==KErrNone); + delete screenDevice; + } + return rv; + }//session destroyed +/** +Use the full-screen background window to select a display mode that doesn't use +alpha (anything other than EColor16MA or EColor16MAP). Record the mode for use +in setting all other windows. +@return ETrue if an appropriate mode was selected, EFalse otherwise. +*/ +TBool CWsDynamicResWinBase::SelectChromaCompositionMode() + { + // Request EColor64K, but as long as the actual mode doesn't use alpha, it + // doesn't matter too much which one is used. + if (iInfoGc==iGc) + { + iDisplayMode = (TDisplayMode)iBackground.SetRequiredDisplayMode(EColor64K); + iSession.Flush(); // Force switching to the display mode. + } + return !DisplayHasAlpha(); + } +/** Returns the colour used by WServ to paint holes in UI layer to reveal the GCE behind. + * The window should have a surface attached. + * If the method is called after the surface has been detached or the window was removed then + * the previous recorded hole color is returned. + **/ +TRgb CWsDynamicResWinBase::GceHoleColor( RWindowBase& aWin)const + { + if (aWin.WsHandle()==NULL) + { + return iLastGceHoleColor; + } + TRgb retVal=aWin.KeyColor(); + if (retVal==TRgb(0,0)) + { + return iLastGceHoleColor; + } + else + { + iLastGceHoleColor=retVal; + return retVal; + } + } + + +/** +Use the full-screen background window to select a display mode that can use +alpha (either EColor16MA or EColor16MAP). Record the mode for use in setting all +other windows. +@return ETrue if an appropriate mode was selected, EFalse otherwise. +*/ +TBool CWsDynamicResWinBase::SelectAlphaCompositionMode(TDisplayMode aMode) + { + // Request EColor16MA, but as long as the actual mode can use alpha, it + // doesn't matter too much which one is used. + if (iInfoGc==iGc) + { + iDisplayMode = (TDisplayMode)iBackground.SetRequiredDisplayMode(aMode); + iSession.Flush(); // Force switching to the display mode. + } + return DisplayHasAlpha(); + } + +/** + * Interesting UI pattern used by other GCE tests. + * + * + **/ +void CWsDynamicResWinBase::DrawUIContent(RWindow& aWindow) + { + aWindow.BeginRedraw(); + CWindowGc* gc=(&aWindow==&iCompare)?iInfoGc:iGc; + + gc->Activate(aWindow); + + TBool hasAlpha = DisplayHasAlpha(); + + // Draw a red-green graduated box in the central portion of the window, + // with alpha if available. + TPoint start; + TPoint end; + TInt halfW = KSurfaceWidth / 2; + TInt quarterW = halfW / 2; + TInt halfH = KSurfaceHeight / 2; + TInt quarterH = halfH / 2; + + // Set constant ordinals for non-alpha case. + start.iX = quarterW; + end.iX = quarterW + halfW; + + for (TInt yy = 0; yy < halfH; yy++) + { + TInt yval = yy * 255 / (halfH - 1); + start.iY = yy + quarterH; + end.iY = start.iY; + + if (hasAlpha) + { + for (TInt xx = 0; xx < halfW; xx++) + { + TInt xval = xx * 255 / (halfW - 1); + start.iX = xx + quarterW; + end.iX = start.iX + 1; + gc->SetPenColor(TRgb(yval, 255 - yval, 0, xval)); + gc->DrawLine(start, end); + } + } + else + { + gc->SetPenColor(TRgb(yval, 255 - yval, 0)); + gc->DrawLine(start, end); + } + } + + gc->Deactivate(); + aWindow.EndRedraw(); + } + +/** + * Causes the given window to be redrawn. + * Doesn't draw anything except the background wipe, when the transparency manager hasn't + * + **/ +void CWsDynamicResWinBase::DrawPlainUI(RWindow& aWindow,TBool aInvalidate,TRgb aWipeColor) + { + if (CWindowGc* gc=BeginActivateWithWipe(aInvalidate,aWindow,aWipeColor)) + { + //actually does nothing! + gc->Deactivate(); + aWindow.EndRedraw(); + } + } +/** + * Interesting UI pattern used by other GCE tests. + * + * + **/ +void CWsDynamicResWinBase::DrawCross(RWindow& aWindow, TRgb aColor, TInt aThickness) + { + aWindow.BeginRedraw(); + CWindowGc* gc=(&aWindow==&iCompare)?iInfoGc:iGc; + gc->Activate(aWindow); + + // Draw a red diagonal cross in the window. + gc->SetPenColor(aColor); + gc->SetPenSize(TSize(aThickness, aThickness)); + gc->DrawLine(TPoint(0, 0), TPoint(KSurfaceWidth, KSurfaceHeight)); + gc->DrawLine(TPoint(KSurfaceWidth, 0), TPoint(0, KSurfaceHeight)); + + gc->Deactivate(); + aWindow.EndRedraw(); + } + +/** + * Checks the RGB value + * + * + **/ +void CWsDynamicResWinBase::TestPixelL(TPoint aPt, TRgb aColor, TBool aMatch) + { + TRect screenArea(iScreenDevice->SizeInPixels()); + if (aPt.iX < screenArea.iTl.iX) + { + aPt.iX = screenArea.iTl.iX; + } + else if (aPt.iX >= screenArea.iBr.iX) + { + aPt.iX = screenArea.iBr.iX - 1; + } + if (aPt.iY < screenArea.iTl.iY) + { + aPt.iY = screenArea.iTl.iY; + } + else if (aPt.iY >= screenArea.iBr.iY) + { + aPt.iY = screenArea.iBr.iY - 1; + } + + TRgb pixel; + iScreenDevice->GetPixel(pixel, aPt); + if (aMatch) + { + ASSERT_EQUALS_X(pixel.Internal(), aColor.Internal()); + } + else + { + ASSERT_NOT_EQUALS_X(pixel.Internal(), aColor.Internal()); + } + } + +struct CountColour + { + TRgb iColor; + TInt iCount; + TBool operator < (const CountColour& aRhs)const + { return iColor.Value()& aColors) + { + //I am sure one of the find methods would do this, but life is too short! + TInt existingIndex; + for (existingIndex=0;existingIndexDisplayMode(); + switch (displayMode) + { + case EColor4K: + aInnerColor=aInnerColor.Color4K(aInnerColor.Color4K()); + aOuterColor=aOuterColor.Color4K(aOuterColor.Color4K()); + break; + case EColor64K: + aInnerColor=aInnerColor.Color64K(aInnerColor.Color64K()); + aOuterColor=aOuterColor.Color64K(aOuterColor.Color64K()); + break; + case EColor16M: + case EColor16MU: + case EColor16MA: + case EColor16MAP: + break; + default: + ASSERT_EQUALS(EColor16MA,displayMode); //Can't quantise color for this display mode! + } + + RArray innerColors; + innerColors.AppendL(aInnerColor); + RArray outerColors; + outerColors.AppendL(aOuterColor); + TInt cornerSize=aExpectedCornerSize>=0?aExpectedCornerSize:-aExpectedCornerSize; + //Check outside first! + TRgb pixelVal; + for(TPoint pixelPos(aRect.iTl.iX-1,aRect.iTl.iY-1);pixelPos.iXGetPixel(pixelVal, pixelPos); + LogColorL(pixelVal,outerColors); + } + for(TPoint pixelPos(aRect.iTl.iX,aRect.iBr.iY);pixelPos.iX<=aRect.iBr.iX;pixelPos.iX++) + { + iScreenDevice->GetPixel(pixelVal, pixelPos); + LogColorL(pixelVal,outerColors); + } + for(TPoint pixelPos(aRect.iTl.iX-1,aRect.iTl.iY);pixelPos.iY<=aRect.iBr.iY;pixelPos.iY++) + { + iScreenDevice->GetPixel(pixelVal, pixelPos); + LogColorL(pixelVal,outerColors); + } + for(TPoint pixelPos(aRect.iBr.iX,aRect.iTl.iY-1);pixelPos.iYGetPixel(pixelVal, pixelPos); + LogColorL(pixelVal,outerColors); + } + TInt cornerStart=1; + if (cornerSize) + { + cornerStart=cornerSize; + if (aExpectedCornerSize>0) + { + iScreenDevice->GetPixel(pixelVal, aRect.iTl); + LogColorL(pixelVal,outerColors); + iScreenDevice->GetPixel(pixelVal, TPoint(aRect.iTl.iX,aRect.iBr.iY-1)); + LogColorL(pixelVal,outerColors); + iScreenDevice->GetPixel(pixelVal, TPoint(aRect.iBr.iX-1,aRect.iTl.iY)); + LogColorL(pixelVal,outerColors); + iScreenDevice->GetPixel(pixelVal, TPoint(aRect.iBr.iX-1,aRect.iBr.iY-1)); + LogColorL(pixelVal,outerColors); + } + } + + //test inside edges (excluding 4 corner pixels - do them seperately) + for(TPoint pixelPos(aRect.iTl.iX+cornerStart,aRect.iTl.iY);pixelPos.iXGetPixel(pixelVal, pixelPos); + LogColorL(pixelVal,innerColors); + } + for(TPoint pixelPos(aRect.iTl.iX+cornerStart,aRect.iBr.iY-1);pixelPos.iXGetPixel(pixelVal, pixelPos); + LogColorL(pixelVal,innerColors); + } + for(TPoint pixelPos(aRect.iTl.iX,aRect.iTl.iY+cornerStart);pixelPos.iYGetPixel(pixelVal, pixelPos); + LogColorL(pixelVal,innerColors); + } + for(TPoint pixelPos(aRect.iBr.iX-1,aRect.iTl.iY+cornerStart);pixelPos.iYGetPixel(pixelVal, pixelPos); + LogColorL(pixelVal,innerColors); + } + //the 4 corner cells - not checking the whole corner area... + if (aExpectedCornerSize>=0) + { + iScreenDevice->GetPixel(pixelVal, TPoint(aRect.iTl.iX+cornerSize,aRect.iTl.iY+cornerSize)); + LogColorL(pixelVal,innerColors); + iScreenDevice->GetPixel(pixelVal, TPoint(aRect.iTl.iX+cornerSize,aRect.iBr.iY-1-cornerSize)); + LogColorL(pixelVal,innerColors); + iScreenDevice->GetPixel(pixelVal, TPoint(aRect.iBr.iX-1-cornerSize,aRect.iBr.iY-1-cornerSize)); + LogColorL(pixelVal,innerColors); + iScreenDevice->GetPixel(pixelVal, TPoint(aRect.iBr.iX-1-cornerSize,aRect.iTl.iY+cornerSize)); + LogColorL(pixelVal,innerColors); + } + //OK... that has tested all the pixels, now check the result + if (innerColors.Count()>aOtherInnerColors+1) + return EFalse; + if (outerColors.Count()>aOtherOuterColors+1) + return EFalse; + for (TInt index=1;indexendy) + { //swap // s e + starty-=endy; // s-e + endy+=starty; // s + starty=endy-starty; // e + } + if (startx>endx) + { //swap // s e + startx-=endx; // s-e + endx+=startx; // s + startx=endx-startx; // e + } + TSize fullSize=aFullRect.Size(); + return TRect( aFullRect.iTl.iX+fullSize.iWidth*startx/5, + aFullRect.iTl.iY+fullSize.iHeight*starty/5, + aFullRect.iTl.iX+fullSize.iWidth*(endx+1)/5, + aFullRect.iTl.iY+fullSize.iHeight*(endy+1)/5 + ); + } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tdynamicres/src/wsdynamicresbase.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tdynamicres/src/wsdynamicresbase.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,603 @@ +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#include +#include "wsdynamicresbase.h" +#include "teflogextensions.h" +#include "globalsettings.h" +#include +#include +#include +#include +#include "regionextend.h" + + +#if defined(__X86GCC__) +extern "C" TInt atexit(void (*function)(void)) + { + return KErrNone; + } +#endif + +CWsDynamicResBase::CWsDynamicResBase(): + iUtility(this) + { + } + +CWsDynamicResBase::~CWsDynamicResBase() + { + } + +/** +Common set up code for all tests. + +Creates the session and window group for further windows, plus a simple white +background to obscure any unwanted stuff behind the test. Sets up the surface +update session and surface manager, to work with surfaces. Creates a screen +device for use in the tests. +*/ +void CWsDynamicResBase::SetupL() + { + SetupL(EFalse); + } +void CWsDynamicResBase::SetupL(TBool aUseOtherScreenForInfo) + { + CWsDynamicResWinBase::SetupL(aUseOtherScreenForInfo); + + +//clean-up if previous test abended + if (PostTestCleanupInstance().iSharedUtility) + { +//Temp removed - may be causing ONB fails! +// if (PostTestCleanupInstance().iSharedUtility->DestroyAll()) +// { +// INFO_PRINTF1(_L("Destroyed some surfaces from previous test.")); +// +// } + } + if (!PostTestCleanupInstance().iCleanedUpOnExit) + PostTestCleanupInstance().iCleanedUpOnExit=EFalse; + + if (!GCEIsSupported()) + { + INFO_PRINTF1(_L("Some Setup skipped: GCE support is not loaded")); + return; + } + + TRAPD(err_FailedToCreateSurfaceUtility, iUtility = CSurfaceUtility::NewL( PostTestCleanupInstance().iSharedUtility)); + ASSERT_EQUALS(err_FailedToCreateSurfaceUtility,KErrNone); + + + } + +/** +Common tear down code for all tests. + +Windows, group and session created are closed. Screen device is destroyed. +Surfaces, manager and update session are closed. +*/ +void CWsDynamicResBase::TearDownL() + { + CWsDynamicResWinBase::TearDownL(); + delete iUtility(); + PostTestCleanupInstance().iCleanedUpOnExit=ETrue; + //Pause(1000); + } +/** + * Note that this is not the ideal mechanism. + * A derived class may thinks its TearDown is safe to do from delete, but in the class it is derived from it may not be safe + **/ +void CWsDynamicResBase::TearDownFromDeleteL() + { + CWsDynamicResBase::TearDownL(); + } + +//Allocating an instance of surface utility here means all test code instances will share the same instance of the utility class. +// Owns the singleton +/*static*/ const CWsDynamicResBase::TPostTestCleanup& CWsDynamicResBase::PostTestCleanupInstance() + { + static + class RPostTestCleanup:public TPostTestCleanup + { + public: + RPostTestCleanup() + { + iSharedUtility=NULL; + iCleanedUpOnExit=ETrue; + } + ~RPostTestCleanup() + { + // I want to cleanly release the surface utility, but at this point the threads have already been pulled down! + // if (iSharedUtility) + // delete iSharedUtility; + iSharedUtility=NULL; //avoid phoenix behaviour + } + } staticInstance; + return staticInstance; + } + +void CWsDynamicResBase::TPostTestCleanup::CreateSharedUtilityL()const + { + if (iSharedUtility==NULL) + iSharedUtility=CSurfaceUtility::NewL(); + } + +/** +Pause for the given number of milliseconds. + +@param aMilliseconds Time to wait in milliseconds. +*/ +void CWsDynamicResBase::Pause(TInt aMilliseconds) + { + User::After(TTimeIntervalMicroSeconds32(aMilliseconds * 1000)); + } + +/** Creates the normal scenario used by these tests. + * With a large window behind and small window in front. + * If the windows already exist then they are just repositioned and redrawn. + * @param aOuterRect Position of back window + * @param aOuterColor Background colour for back window + * @param aInnerRect Position of front window + * @param aInnerColor Background colour for front window + * + **/ +void CWsDynamicResBase::MakeTestWindowPairL(TRect aOuterRect,TRgb aOuterColor,TRect aInnerRect,TRgb aInnerColor) + { + if (!iTestBack.WsHandle()) + { + iTestBack=RWindow(iSession); + ASSERT_EQUALS_X(iTestBack.Construct(iGroup, ++iWindowHandle), KErrNone); +#ifdef FLICKER + iTestBack.Activate(); +#endif + iTestBack.SetRequiredDisplayMode(iDisplayMode); + iTestBack.SetBackgroundColor(aOuterColor); + iTestBack.SetExtent(aOuterRect.iTl,aOuterRect.Size()); +#ifndef FLICKER + iTestBack.Activate(); +#endif + } + else + { + iTestBack.SetRequiredDisplayMode(iDisplayMode); + iTestBack.SetBackgroundColor(aOuterColor); + iTestBack.SetExtent(aOuterRect.iTl,aOuterRect.Size()); + } + iTestBack.BeginRedraw(); + ActivateWithWipe(iGc,iTestBack,aOuterColor); + iGc->Deactivate(); + iTestBack.EndRedraw(); + iTestBack.SetVisible(ETrue); + + if (!iTestFront.WsHandle()) + { + iTestFront=RWindow(iSession); + ASSERT_EQUALS_X(iTestFront.Construct(iGroup, ++iWindowHandle), KErrNone); +#ifdef FLICKER + iTestFront.Activate(); +#endif + iTestFront.SetRequiredDisplayMode(iDisplayMode); + iTestFront.SetBackgroundColor(aInnerColor); + iTestFront.SetExtent(aInnerRect.iTl,aInnerRect.Size()); + +#ifndef FLICKER + iTestFront.Activate(); +#endif + } + else + { + iTestFront.SetRequiredDisplayMode(iDisplayMode); + iTestFront.SetBackgroundColor(aInnerColor); + iTestFront.SetExtent(aInnerRect.iTl,aInnerRect.Size()); + } + + DrawPlainUI(iTestFront,EFalse,aInnerColor); + iTestFront.SetVisible(ETrue); + + } + +void CWsDynamicResBase::LargerTestWindow(TInt aPercentOfBack) + { + TRect newPos=iTestPos; + TSize backSize=iTestPos.Size(); + newPos.Grow((aPercentOfBack-100)*backSize.iWidth/200,(aPercentOfBack-100)*backSize.iHeight/200); + iCenteredFrontWinRect=newPos; + if (iTestFront.WsHandle()) + { + iTestFront.SetExtent(newPos.iTl,newPos.Size()); + } + + } + +/** Destroys some or all of the test windows so the test can loop (or test the state after destruction. + * The windows are destroyed when the test exits normally. + * Child windows are automatically killed when parent window is killed! + * + **/ +void CWsDynamicResBase::DestroyTestWindowPair(TBool aKillTestBack,TBool aKillTestFront,TBool aKillTestChildren) + { + if (aKillTestBack && iTestBack.WsHandle()) + { + iTestBack.Close(); + } + if (aKillTestFront && iTestFront.WsHandle()) + { + iTestFront.Close(); + } + if (aKillTestChildren) + { + if (iTestChild.WsHandle()) + { + iTestChild.Close(); + } + if (iTestSecondChild.WsHandle()) + { + iTestSecondChild.Close(); + } + } + } +/** Creates a child window inside the front window of the usual test scenario +* With a large window behind and small window in front. + * If the windows already exist then they are just repositioned and redrawn. + * @param aOuterRect Position of back window + * @param aOuterColor Background colour for back window + * @param aInnerRect Position of front window + * @param aInnerColor Background colour for front window + * @param aChildRect Position of child window + * @param aChildColor Background colour for child window + * @param aSecondChildRect Position of Second child window + * @param aSecondChildColor Background colour for Second child window + * + **/ +void CWsDynamicResBase::MakeTestWindowTripleL(TRect aOuterRect,TRgb aOuterColor,TRect aInnerRect,TRgb aInnerColor,TRect aChildRect,TRgb aChildColor,TRect aSecondChildRect,TRgb aSecondChildColor) + { + MakeTestWindowTripleL(aOuterRect,aOuterColor,aInnerRect,aInnerColor,aChildRect,aChildColor); + + MakeExtraChildWindowL(iTestChild,aSecondChildRect,aSecondChildColor); + } + +/** Creates a child window inside the front window of the usual test scenario +* With a large window behind and small window in front. + * If the windows already exist then they are just repositioned and redrawn. + * @param aOuterRect Position of back window + * @param aOuterColor Background colour for back window + * @param aInnerRect Position of front window + * @param aInnerColor Background colour for front window + * @param aChildRect Position of child window + * @param aChildColor Background colour for child window + * @param aSecondChildRect Position of second child window + * @param aSecondChildColor Background colour for second child window + * + **/ +void CWsDynamicResBase::CreateTestWindowQuadL(TRect aOuterRect,TRgb aOuterColor,TRect aInnerRect,TRgb aInnerColor,TRect aChildRect,TRgb aChildColor,TRect aSecondChildRect,TRgb aSecondChildColor) + { + MakeTestWindowTripleL(aOuterRect,aOuterColor,aInnerRect,aInnerColor,aChildRect,aChildColor); + + MakeExtraChildWindowL(iTestFront,aSecondChildRect,aSecondChildColor); + } + +void CWsDynamicResBase::MakeExtraChildWindowL(const RWindowBase& aFromParent,TRect aChildRect,TRgb aChildColor) + { + ASSERT(aFromParent.WsHandle()); + if (!iTestSecondChild.WsHandle()) + { + iTestSecondChild=RWindow(iSession); + ASSERT_EQUALS_X(iTestSecondChild.Construct(aFromParent, ++iWindowHandle), KErrNone); + iTestSecondChild.SetRequiredDisplayMode(iDisplayMode); + } + iTestSecondChild.SetBackgroundColor(aChildColor); + iTestSecondChild.SetExtent(aChildRect.iTl,aChildRect.Size()); + iTestSecondChild.Activate(); + iTestSecondChild.BeginRedraw(); + iGc->Activate(iCompare); + iGc->SetBrushColor(iBlue); + iGc->Clear(); + iGc->Deactivate(); + iTestSecondChild.EndRedraw(); + iTestSecondChild.SetVisible(ETrue); + } + +CWsDynamicResBase::LoopingGcPtr CWsDynamicResBase::LoopBeginActivateWithWipe(const TRegion& aRegion,RWindow& aWin,TRgb aColor) + { + InvalidateRegion(aRegion,aWin); + return LoopingGcPtr(aRegion,aWin,aColor,GcForWindow(aWin)); + } + +//This gets called each itteration of the while loop, and is used to step the rectangle count! +void CWsDynamicResBase::LoopingGcPtr::operator ++() + { + iPass++; + if (iPassActivate(iCompare); + iGc->SetBrushColor(iBlue); + iGc->Clear(); + iGc->Deactivate(); + iTestChild.EndRedraw(); + iTestChild.SetVisible(ETrue); + } +/** + * Generates a valid surfaceID for the current display mode. + * This is then used in negative testing. + * + * + **/ +void CWsDynamicResBase::UISurfaceL(TSurfaceId& aSurfaceId) const + { + CFbsDrawDevice* screenDevice=NULL; + TDisplayMode displayMode=iScreenDevice->DisplayMode(); + screenDevice = CFbsDrawDevice::NewScreenDeviceL(TGlobalSettings::Instance().iScreen, displayMode); + CleanupStack::PushL(screenDevice); + TAny* p=NULL; + User::LeaveIfError(screenDevice->GetInterface(KSurfaceInterfaceID, p)); + MSurfaceId* uiSurface = static_cast(p); + uiSurface->GetSurface(aSurfaceId); + CleanupStack::PopAndDestroy(screenDevice); + } + +/** +Common set up code for creating a surface based window. + +Given window and surface objects and a color: creates the window and surface, +sets the window to a default size (the same as the surface), sets the background +to the bitwise inverse of the given color, sets the surface as the background, +fills the surface with the color and completes a redraw to prevent an event. + +@param aWindow The window object, connected to a session. +@param aSurface The surface object, to be initialized. +@param aColor The color to fill the surface with. +*/ +void CWsDynamicResBase::CommonSurfaceWindowSetupL(RWindow& aWindow, TSurfaceId& aSurface, const TRgb& aColor) + { + TInt err = KErrNone; + + TRAP(err, aSurface = iUtility->CreateSurfaceL(TSize(KSurfaceWidth, KSurfaceHeight), + KSurfaceFormat, KSurfaceWidth * KBytesPerPixel)); + PRINT_ON_ERROR2_L(err, _L("Failed to create surface: %d"), err); + ASSERT_EQUALS_X(aWindow.Construct(iGroup, ++iWindowHandle), KErrNone); + + aWindow.SetRequiredDisplayMode(iDisplayMode); + aWindow.SetExtent(TPoint(0, 0), TSize(KSurfaceWidth, KSurfaceHeight)); + aWindow.SetBackgroundColor(TRgb(aColor.Value() ^ 0xFFFFFF)); + + ASSERT_EQUALS_X(aWindow.SetBackgroundSurface(aSurface), KErrNone); + + TRAP(err, iUtility->FillSurfaceL(aSurface, aColor)); + PRINT_ON_ERROR2_L(err, _L("Failed to fill surface: %d"), err); + DrawUIContent(aWindow); + } + +/** +Common set up code for resizing tests. + +Similar to the common surface window code, but filling the surface with a grid +instead of a solid color. The grid lines are always black. Also, the background +color is always blue. +*/ +void CWsDynamicResBase::ResizeTestCommonSetupL(RWindow& aWindow, const TRgb& aColor) + { + // Session and group created in SetUpL() + + TSurfaceId surface; + TInt err = KErrNone; + + TRAP(err, surface = iUtility->CreateSurfaceL(TSize(KSurfaceWidth, KSurfaceHeight), + KSurfaceFormat, KSurfaceWidth * KBytesPerPixel)); + PRINT_ON_ERROR2_L(err, _L("Failed to create surface: %d"), err); + + ASSERT_EQUALS_X(aWindow.Construct(iGroup, ++iWindowHandle), KErrNone); + + aWindow.SetRequiredDisplayMode(iDisplayMode); + aWindow.SetExtent(TPoint(0, 0), TSize(KSurfaceWidth, KSurfaceHeight)); + aWindow.SetBackgroundColor(iBlue); + ASSERT_EQUALS_X(aWindow.SetBackgroundSurface(surface), KErrNone); + + TRAP(err, iUtility->GridFillSurfaceL(surface, aColor, TRgb(0))); + PRINT_ON_ERROR2_L(err, _L("Failed to grid fill surface: %d"), err); + DrawUIContent(aWindow); + } + +CFbsBitmap* CWsDynamicResBase::RotateBitmapLC(const CFbsBitmap* aSrcBitmap) + { + CFbsBitmap* rv=new CFbsBitmap; + CleanupStack::PushL(rv); + TSize srcSize=aSrcBitmap->SizeInPixels(); + rv->Create(TSize(srcSize.iHeight,srcSize.iWidth),EColor16MA); + TRgb* linestore=new TRgb[srcSize.iHeight]; + TPtr8 buff((unsigned char*)linestore,srcSize.iHeight*sizeof(TRgb),srcSize.iHeight*sizeof(TRgb)); + for (TInt col=0;colSizeInPixels().iWidth;col++) + { + for (TInt row=0,brow=srcSize.iHeight-1;rowGetPixel(linestore[row],TPoint(col,brow)); + } + rv->SetScanLine(buff,col); + } + delete[] linestore; + return rv; + } + + +// +// +// +// Pattern checking. Is a given pattern still present? +// To make life interesting, the pattern is stored backwards! +// The pattern is fibonnacci sequence masked to byte: +// 1 2 3 5 8 13 21 34 55 89 144 233 121 +// 98 219 61 24 85 109 194 47 241 32 17 49 66 +// 115 181 40 221 5 226 231 201 176 121 41 162 +// +// +void Pattern::Fill(void* aTrg,TInt aOffset,TInt aLength) + { + unsigned char* ptr=(unsigned char*)aTrg; + TInt a=0; + TInt b=1; + while (--aLength) + { + TInt c=a+b; + *(ptr+aOffset+aLength)=c&0xff; + a=b; + b=c; + } + } +TBool Pattern::Check(void* aTrg,TInt aOffset,TInt aLength) + { + unsigned char* ptr=(unsigned char*)aTrg; + TInt a=0; + TInt b=1; + while (--aLength) + { + TInt c=a+b; + if (*(ptr+aOffset+aLength)!=c&0xff) + return EFalse; + a=b; + b=c; + } + return ETrue; + } +TBool Pattern::CheckVal(void* aTrg,TInt aOffset,TInt aLength,char val) + { + unsigned char* ptr=(unsigned char*)aTrg; + while (--aLength) + { + if (*(ptr+aOffset+aLength)!=val&0xff) + return EFalse; + } + return ETrue; + } + +//I have removed these only because they use TRegionExtend +// +//TInt CWsDynamicResBase::RegionDiffForUiLayer(TInt aUiLayer) +// { +// EWsDebugGetUILayerConfig, //return: TSurfaceConfig //Index UI layer via EWsDebugArgLayerMask +// EWsDebugGetUILayerBase, //return: TRect[] +// +// RRegion layerRegion; +// TInt layerRegionLen=iSession.DebugInfo(EWsDebugGetUILayerBase,iSession.ObjInd(0,aUiLayer),layerRegion); +// if (layerRegionLen==KErrCancel) +// return TRegionExtend::EExact; +// ASSERT_TRUE(layerRegionLen>=0); +// TBuf8 configBuf(sizeof(TSurfaceConfiguration)); +// const TSurfaceConfiguration* config; +// TInt configLen=iSession.DebugInfo(EWsDebugGetUILayerConfig,iSession.ObjInd(0,aUiLayer),configBuf,config); +// ASSERT_TRUE(configLen>=0); +// TRect layerExtent; +// config->GetExtent(layerExtent); +// TInt retVal=TRegionExtend::Cast(layerRegion).TestDifference(layerExtent.Size()); +// layerRegion.Close(); +// return retVal; +// } +//CWsDynamicResBase::FastPathMode CWsDynamicResBase::DeduceUiFastPathMode() +// { +// TInt blendedRegionState=RegionDiffForUiLayer(0); +// TInt opaqueRegionState=RegionDiffForUiLayer(1); +// if (blendedRegionState&TRegionExtend::ENoIntersect) +// { +// if (opaqueRegionState&TRegionExtend::ENoIntersect) +// { +// return EFpExternalOpaque; //fullscreen fast-path external surface +// } +// else +// if (opaqueRegionState&TRegionExtend::EAdd) +// { +// return (FastPathMode)(EFpUiOpaque|EFpUiRegions); //windowed max-opt no blending +// } +// else +// { +// return EFpUiOpaque; //full-screen fastpath +// } +// } +// else +// { +// if (opaqueRegionState&TRegionExtend::ENoIntersect) +// { +// if (blendedRegionState&TRegionExtend::EAdd) +// { +// return (FastPathMode)(EFpUiBlended|EFpUiRegions); //windowed max-opt no opaque +// } +// else +// { +// return (EFpUiBlended); //full-screen blended +// } +// } +// else +// { +// if ((blendedRegionState|opaqueRegionState)&TRegionExtend::EAdd) +// { +// return (FastPathMode)(EFpUiComplex|EFpUiRegions); //moxed blending, opaque and external max optimisation +// } +// else +// { +// return EFpUiComplex; //Error! blend and opaque both enabled and full-screen! +// } +// } +// +// } +// } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tdynamicres/src/wsdynamicresbasic.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tdynamicres/src/wsdynamicresbasic.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,4540 @@ +// Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file +*/ +#include "wsdynamicresbasic.h" +#include +#include "globalsettings.h" +#include +#include +#include "regionextend.h" +#include +#include +#include +#include +#include "surfaceutility.h" +#include + +//verify which base code is available to the test +#include +#if (!defined(K_DISPLAY_CH_MAJOR_VERSION_NUMBER) && !defined(K_DISPLAY_CH_MINOR_VERSION_NUMBER)) +#define MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER +#endif + + +//#define VISIBLE_PAUSES 1000 +#define OVERLAPPING_CELL 0 //'m' //0 indicates cells do not overlap +/* + * CWsGceTestPlaceSurfExtra implementation + * + * + * + * + */ +CWsDynamicResBasic::CWsDynamicResBasic() +{ +} + +CWsDynamicResBasic::~CWsDynamicResBasic() +{ +} + +void CWsDynamicResBasic::SetupL() + { + MyBase::SetupL(); + } +void CWsDynamicResBasic::TearDownL() + { + MyBase::TearDownL(); + + } +void CWsDynamicResBasic::TearDownFromDeleteL() + { + MyBase::TearDownFromDeleteL(); + } + + +CTestSuite* CWsDynamicResBasic::CreateSuiteL( const TDesC& aName ) + { + //Create the surface manager here, before the test suite creates additional threads + if (GCEIsSupportedStatic()) + { + TRAP_IGNORE(PostTestCleanupInstance().CreateSharedUtilityL()); + } + + SUB_SUITE_OPT(CWsDynamicResBasic,NULL); + + //BASIC + ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0001L); + ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0002L); + ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0003L); + ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0004L); + ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0005L); + ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0006L); + ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0007L); + ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0008L); + ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0009L); + ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0010L); //only run on screen 1 + ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0011L); + ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0012L); //only run on screen 0 + ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0013L); + ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0014L); //only run on screen 1 + ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0015L); //only run with no scaling + ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0016L); //only run with anisotropic scaling + ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0017L); //only run with integer scaling + ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0018L); + + ADD_TEST_STEP_PARAM_BOOL(GRAPHICS_WSERV_DYNAMICRES_0021L); //only run on screen 1 + + //OOM + ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0031L); + ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0032L); + ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0033L); + ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0034L); //dont run with no scaling on screen 0 + + //SCREEN CAPTURE + ADD_TEST_STEP_PARAM_BOOL(GRAPHICS_WSERV_DYNAMICRES_0041L); + ADD_TEST_STEP_PARAM_BOOL(GRAPHICS_WSERV_DYNAMICRES_0042L); + + //DYNAMIC SCREEN MODE - only run these with no scaling and isotropic scaling + ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0051L); + ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0052L); //only run on screen 1 (multiple resolutions) + ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0053L); + + //DEFECT + ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0101L); + ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0102L); + + END_SUITE; + } + +#define LOG_AND_PANIC_IF_NOT_GCE \ + { \ + if (!GCEIsSupported()) \ + { \ + INFO_PRINTF1(_L("Test skipped: GCE support is not loaded")); \ + User::Panic(_L("GCE.Wrong.Mode"),1); \ + return; \ + } \ + } + +CWsDisplayEvent::CWsDisplayEvent(RWsSession *aWs): +CActive(EPriorityStandard), iWs(aWs), iConfigSpinner(0), iResListSpinner(0),iReceivedEventCount(0), +iReceivedPointerEventCount(0), iPointerPosTestPass(ETrue) + { + CActiveScheduler::Add(this); + } +CWsDisplayEvent::~CWsDisplayEvent() + { + Cancel(); + } + +void CWsDisplayEvent::DoCancel() + { + iWs->EventReadyCancel(); + } + +void CWsDisplayEvent::Request() + { + iWs->EventReady(&iStatus); + SetActive(); + } + +void CWsDisplayEvent::RunL() + { + TWsEvent event; + iWs->GetEvent(event); + + if(iStatus == KErrNone) + { + switch(event.Type()) + { + case EEventScreenDeviceChanged: + { + iReceivedDeviceEventCount++; + } + case EEventPointer: + { + iReceivedPointerEventCount++; + TPointerEvent* ptEvent = event.Pointer(); + //make 1 pixels distance allowance, as non integer scalling from composition to app may occur + //1 pixels allowance because we never scale greater than 2 times + if(ptEvent->iPosition.iX < iPointerPos.iX - 1 && ptEvent->iPosition.iX > iPointerPos.iX + 1 + && ptEvent->iPosition.iY < iPointerPos.iY - 1 &&ptEvent->iPosition.iY > iPointerPos.iY + 1) + { + iPointerPosTestPass = EFalse; + } + } + case EEventDisplayChanged: + { + iConfigSpinner = event.DisplayChanged()->iConfigurationChangeId; + iResListSpinner = event.DisplayChanged()->iResolutionListChangeId; + iReceivedEventCount++; + } + break; + default: + break; + } + } + else + User::Leave(iStatus.Int()); + + Request(); + } + +CEventTimer* CEventTimer::NewL() + { + CEventTimer* self = new (ELeave) CEventTimer; + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +void CEventTimer::ConstructL() + { + User::LeaveIfError(iTimer.CreateLocal()); + CActiveScheduler::Add(this); + } + +CEventTimer::CEventTimer() : CActive(EPriorityStandard) + { + + } + +CEventTimer::~CEventTimer() + { + Cancel(); + iTimer.Close(); + } + +void CEventTimer::DoCancel() + { + iTimer.Cancel(); + CActiveScheduler::Stop(); + } + +void CEventTimer::RunL() + { + CActiveScheduler::Stop(); + } + +void CEventTimer::Wait(TInt aDelay) + { + iTimer.After(iStatus, aDelay); + SetActive(); + CActiveScheduler::Start(); + } + +//Set display state to normal and to the first decent resolution +//A failed test could leave it in a bad state +void CWsDynamicResBasic::ResetScreens() + { + Pause(1000); +#ifndef MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER + TInt displayState = ENormalResolution; + UserSvr::HalFunction(EHalGroupDisplay | (iScreenDevice->GetScreenNumber()<<16), EDisplayHalSetDisplayState, &displayState, NULL); +#endif + MDisplayControl* interface = static_cast + (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); + ASSERT_TRUE(interface); + + RArray appModeIndexList; + TInt currMode=iScreenDevice->CurrentScreenMode(); + iScreenDevice->GetScreenSizeModeList(&appModeIndexList); + if (appModeIndexList[0]!=currMode) + { + iScreenDevice->SetAppScreenMode(appModeIndexList[0]); + iScreenDevice->SetScreenMode(appModeIndexList[0]); + } + appModeIndexList.Close(); + + TInt resolutions = interface->NumberOfResolutions(); + ASSERT_TRUE (resolutions > 0); + RArray resolutionList1; + TInt error = interface->GetResolutions(resolutionList1); + ASSERT_EQUALS(error,KErrNone); + ASSERT_EQUALS(resolutionList1.Count(), resolutions); + TDisplayConfiguration config; + TInt goodRes=0; + if (resolutionList1[goodRes].iPixelSize==TSize()) + { + goodRes++; + ASSERT_TRUE(resolutions>goodRes); //First res was blank, and no more to choose! + } + config.SetResolution(resolutionList1[goodRes].iPixelSize); + error=interface->SetConfiguration(config); + ASSERT_EQUALS(error,KErrNone); + resolutionList1.Close(); + } + +/** +@SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0001L +@SYMTestCaseDesc WSERV Screen Device GetInterface returns known interface +@SYMREQ REQ10325 +@SYMPREQ PREQ2102 +@SYMTestType CT +@SYMTestPriority 1 +@SYMTestPurpose Basic classic behaviour +@SYMTestActions + Call GetInterface with a well known GUID +@SYMTestExpectedResults + Returns a pointer +*/ +void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0001L() + { + LOG_AND_PANIC_IF_NOT_GCE; + MakeTitleAndCompareWindowsL(_L("GRAPHICS_WSERV_DYNAMICRES_0001L"),_L("Basic Dynamic Resolution test")); + + MDisplayControlBase* interface1 = static_cast + (iScreenDevice->GetInterface(MDisplayControlBase::ETypeId)); + ASSERT_TRUE(interface1); + + MDisplayControl* interface2 = static_cast + (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); + ASSERT_TRUE(interface2); + + MDisplayMappingBase* interface3 = static_cast + (iScreenDevice->GetInterface(MDisplayMappingBase::ETypeId)); + ASSERT_TRUE(interface3); + + MDisplayMapping* interface4 = static_cast + (iScreenDevice->GetInterface(MDisplayMapping::ETypeId)); + ASSERT_TRUE(interface4); + } + +/** +@SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0002L +@SYMTestCaseDesc Basic test for NumberOfResolutions +@SYMREQ REQ10328 +@SYMPREQ PREQ2102 +@SYMTestType CT +@SYMTestPriority 1 +@SYMTestPurpose NumberOfResolutions returns correctly +@SYMTestActions + GetInterface + then call NumberOfResolutions. +@SYMTestExpectedResults + It shouldn't return KErrNotSupported +*/ +void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0002L() + { + LOG_AND_PANIC_IF_NOT_GCE; + MDisplayControl* interface = static_cast + (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); + ASSERT_TRUE(interface); + TInt resolutions = interface->NumberOfResolutions(); + ASSERT_TRUE (resolutions != KErrNotSupported); + } + +/** +@SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0003L +@SYMTestCaseDesc Basic test for GetResolutions +@SYMREQ REQ10328 +@SYMPREQ PREQ2102 +@SYMTestType CT +@SYMTestPriority +@SYMTestPurpose Check GetResolutions returns a valid TSize RArray +@SYMTestActions + GetInterface + Call NumberOfResolutions + Create an array and garbage fill based on amount of resolutions + Call GetResolutions on this array + Create an array (dont garbage fill) + Call GetResolutions on this empty array + Create an array with smaller size than required + Call GetResolutions on this array + Create an array with larger size than required + Call GetResolutions on this array +@SYMTestExpectedResults + For both GetResolutions calls, it should allocate memory if needed, and fill + with correct sizes +*/ +void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0003L() + { + LOG_AND_PANIC_IF_NOT_GCE; + TInt count; + TInt error; + + MDisplayControl* interface = static_cast + (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); + ASSERT_TRUE(interface); + + TInt resolutions = interface->NumberOfResolutions(); + ASSERT_TRUE (resolutions > 0); + + RArray resolutionList1; + for (count=0;countGetResolutions(resolutionList1); + ASSERT_EQUALS(error,KErrNone); + ASSERT_EQUALS(resolutionList1.Count(), resolutions); + + RArray resolutionList2; + error = interface->GetResolutions(resolutionList2); + ASSERT_EQUALS(error,KErrNone); + ASSERT_EQUALS(resolutionList2.Count(), resolutions); + + RArray resolutionList3; + for (count=0;countGetResolutions(resolutionList3); + ASSERT_EQUALS(error,KErrNone); + ASSERT_EQUALS(resolutionList3.Count(), resolutions); + + RArray resolutionList4; + for (count=0;countGetResolutions(resolutionList4); + ASSERT_EQUALS(error,KErrNone); + ASSERT_EQUALS(resolutionList4.Count(), resolutions); + + for (count=0;count + (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); + ASSERT_TRUE(interface); + + TDisplayConfiguration dispConfig; + interface->GetConfiguration(dispConfig); + ASSERT_TRUE(dispConfig.IsDefined(TDisplayConfigurationBase::EResolution)); + TSize size; + TSize twips; + ASSERT_TRUE(dispConfig.GetResolution(size)); + ASSERT_TRUE(dispConfig.GetResolutionTwips(twips)); + + TDisplayConfiguration dispConfig1(TDisplayConfiguration().Version() + 10); + interface->GetConfiguration(dispConfig1); + ASSERT_TRUE(dispConfig1.IsDefined(TDisplayConfigurationBase::EResolution)); + TSize size1; + TSize twips1; + ASSERT_TRUE(dispConfig1.GetResolution(size1)); + ASSERT_TRUE(dispConfig1.GetResolutionTwips(twips1)); + + TDisplayConfiguration dispConfig2(TDisplayConfiguration1().Version()); + interface->GetConfiguration(dispConfig2); + ASSERT_TRUE(dispConfig2.IsDefined(TDisplayConfigurationBase::EResolution)); + TSize size2; + TSize twips2; + ASSERT_TRUE(dispConfig2.GetResolution(size2)); + ASSERT_TRUE(dispConfig2.GetResolutionTwips(twips2)); + + ASSERT_EQUALS(size, size1); + ASSERT_EQUALS(size, size2); + ASSERT_EQUALS(twips, twips1); + ASSERT_EQUALS(twips, twips2); + } + +/** +@SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0005L +@SYMTestCaseDesc Test getting display change event from event queue +@SYMREQ REQ10329 REQ10330 +@SYMPREQ PREQ2102 +@SYMTestType CT +@SYMTestPriority 1 +@SYMTestPurpose Verify the correct behaviour of display change notification +@SYMTestActions + Run through various ways of changing resolution + For each, check if event has been received +@SYMTestExpectedResults + Based on type of change, check event +*/ +void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0005L() + { + LOG_AND_PANIC_IF_NOT_GCE; + ResetScreens(); +#ifdef MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER + ASSERT_FALSE("Display connection test not compiled because MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER"); +#else + TInt screenNo = iScreenDevice->GetScreenNumber(); + + MDisplayControl* interface = static_cast + (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); + ASSERT_TRUE(interface); + interface->EnableDisplayChangeEvents(ETrue); + ASSERT_TRUE(interface->DisplayChangeEventsEnabled()); + + CWsDisplayEvent* displayEventAO = new(ELeave) CWsDisplayEvent(&iSession); + CleanupStack::PushL(displayEventAO); + displayEventAO->Request(); + CEventTimer *timer = CEventTimer::NewL(); + CleanupStack::PushL(timer); + TInt dispSpinnerValue = displayEventAO->ResListSpinner(); + TInt configSpinnerValue = displayEventAO->ConfigSpinner(); + + iSession.Flush(); + TInt displayState = EDisconnect; + UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL); + + timer->Wait(100000); + ASSERT_TRUE(displayEventAO->ConfigSpinner() >= configSpinnerValue); //this is also a config change + ASSERT_TRUE(displayEventAO->ResListSpinner() > dispSpinnerValue); //1st display change event + dispSpinnerValue = displayEventAO->ResListSpinner(); + configSpinnerValue = displayEventAO->ConfigSpinner(); + + + interface->EnableDisplayChangeEvents(ETrue);//enable again + ASSERT_TRUE(interface->DisplayChangeEventsEnabled()); + interface->EnableDisplayChangeEvents(EFalse);//disable + ASSERT_FALSE(interface->DisplayChangeEventsEnabled()); + interface->EnableDisplayChangeEvents(EFalse);//disable again + interface->EnableDisplayChangeEvents(ETrue);//enable again + iSession.Flush(); + + TDisplayConfiguration disconnectedConfig; + disconnectedConfig.SetResolution(TSize(10,11)); + disconnectedConfig.SetResolutionTwips(TSize(12,13)); + disconnectedConfig.SetRotation(TDisplayConfiguration1::ERotationNormal); + interface->GetConfiguration(disconnectedConfig); + ASSERT_FALSE(disconnectedConfig.IsDefined(disconnectedConfig.EResolution)); + ASSERT_FALSE(disconnectedConfig.IsDefined(disconnectedConfig.EResolutionTwips)); + ASSERT_FALSE(disconnectedConfig.IsDefined(disconnectedConfig.ERotation)); + + displayState = ENormalResolution; + UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL); + + timer->Wait(1000000); + ASSERT_TRUE(displayEventAO->ConfigSpinner() >= configSpinnerValue); //this is a config change if display policy is enabled. not a change otherwise + ASSERT_TRUE(displayEventAO->ResListSpinner() > dispSpinnerValue); //display change event + dispSpinnerValue = displayEventAO->ResListSpinner(); + configSpinnerValue = displayEventAO->ConfigSpinner(); + + TDisplayConfiguration dispConfig, dispConfig2; + TSize resolution,resolution2; + interface->GetConfiguration(dispConfig2); + dispConfig2.GetResolution(resolution2); + RArray resolutions; + TInt err = interface->GetResolutions(resolutions); + ASSERT_EQUALS(err, KErrNone); + dispConfig.SetResolution(resolutions[resolutions.Count()/2].iPixelSize); + err = interface->SetConfiguration(dispConfig); + ASSERT_EQUALS(err, KErrNone); + interface->GetConfiguration(dispConfig); + + timer->Wait(100000); + + if(!(dispConfig2 == dispConfig)) + { + ASSERT_TRUE(displayEventAO->ConfigSpinner() > configSpinnerValue); //a config change, but on screen 0 with DP disabled, as we only have 1 resolution when DP disabled + } + else + { + ASSERT_TRUE(displayEventAO->ConfigSpinner() == configSpinnerValue); + } + ASSERT_EQUALS(displayEventAO->ResListSpinner(), dispSpinnerValue); //this is not a display change event + dispSpinnerValue = displayEventAO->ResListSpinner(); + configSpinnerValue = displayEventAO->ConfigSpinner(); + resolutions.Close(); + + //here we flood the event queue with key events, so the next display change + //can't put event and queue and force the retry AO on server side to kick off + iSession.SetFocusScreen(TGlobalSettings::Instance().iScreen); + for(TInt scanCode = 'a'; scanCode < 't'; scanCode ++) + { + TRawEvent rawEvent; + rawEvent.Set(TRawEvent::EKeyDown,scanCode); + iSession.SimulateRawEvent(rawEvent); + rawEvent.Set(TRawEvent::EKeyUp,scanCode); + iSession.SimulateRawEvent(rawEvent); + } + iSession.Flush(); + + TInt eventCount1 = displayEventAO->ReceivedEventCount(); + //we should still receive this + displayState = EDisconnect; + UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL); + //let retry AO retry more times before we try to get it + User::After(1000000); + + timer->Wait(10000000); + ASSERT_TRUE(displayEventAO->ConfigSpinner()> configSpinnerValue ); //4th config change + ASSERT_TRUE(displayEventAO->ResListSpinner() > dispSpinnerValue); //4th display change event + + //This part is doomed as well. Now the received event count includes all the pointer, device and display change event + /* + TInt eventCount2 = displayEventAO->ReceivedEventCount(); + //make sure retry AO is stopped - we only receive 1 display event + ASSERT_EQUALS(eventCount1 + 1, eventCount2); + */ + displayState = ENormalResolution; + UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL); + + CleanupStack::PopAndDestroy(2, displayEventAO); +#endif + } + +//Adds the first rotation defined in the TResolution to the display configuration +void CWsDynamicResBasic::SetRotation (TDisplayConfiguration& aConfig, const MDisplayControl::TResolution& aResolution) + { + if (aResolution.iFlags.IsSet(MDisplayControlBase::TResolution::ERotationNormalSupported)) + { + aConfig.SetRotation(TDisplayConfiguration1::ERotationNormal); + } + else if (aResolution.iFlags.IsSet(MDisplayControlBase::TResolution::ERotation90Supported)) + { + aConfig.SetRotation(TDisplayConfiguration1::ERotation90CW); + } + else if (aResolution.iFlags.IsSet(MDisplayControlBase::TResolution::ERotation180Supported)) + { + aConfig.SetRotation(TDisplayConfiguration1::ERotation180); + } + else if (aResolution.iFlags.IsSet(MDisplayControlBase::TResolution::ERotation270Supported)) + { + aConfig.SetRotation(TDisplayConfiguration1::ERotation270CW); + } + ASSERT_TRUE(aConfig.IsDefined(aConfig.ERotation)); + } + +/** +@SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0006L +@SYMTestCaseDesc Set Screen display res +@SYMREQ REQ10326 +@SYMPREQ PREQ2102 +@SYMTestType CT +@SYMTestPriority +@SYMTestPurpose Checking window and layer extents continue working +@SYMTestActions + Get resolution list + For every resolution + Set resolution + Draw many rectangles that shrink to demonstrate scaling issues + Draw surface + Move window around +@SYMTestExpectedResults + Every resolution that is supported by current app mode should successfully be set + All rectangles and surface should be visible + As the window moves, the rectangles and surface should move with it, keeping visible +*/ +void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0006L() + { + LOG_AND_PANIC_IF_NOT_GCE; + ResetScreens(); + TInt error; + MakeTitleAndCompareWindowsL(_L("GFX_WSERV_DYNAMICRES_0006L"),_L("Change Resolution")); + + iTestBack=RWindow(iSession); + ASSERT_EQUALS(iTestBack.Construct(iGroup, ++iWindowHandle), KErrNone); + iTestBack.SetRequiredDisplayMode(iDisplayMode); + iTestBack.SetBackgroundColor(TRgb(255,0,0)); + iTestBack.SetExtent(iTestPos.iTl,iTestPos.Size()); + iTestBack.Activate(); + iTestBack.BeginRedraw(); + ActivateWithWipe(iGc,iTestBack,TRgb(255,0,0)); + iGc->Deactivate(); + iTestBack.EndRedraw(); + iTestBack.SetVisible(ETrue); + + struct DrawCompare + { + static void Draw(CWindowGc* aGc) + { + aGc->SetPenStyle(aGc->ESolidPen); + aGc->SetPenColor(TRgb(255,255,255)); + aGc->SetBrushColor(TRgb(0,0,0)); + TRect r(2,2,82,82); + while(r.Width()>0) + { + aGc->DrawRect(r); + r.Shrink(2,2); + } + } + }; + TSurfaceId surfaceID; + TRAPD(err, surfaceID = iUtility->CreateSurfaceL(TSize(200,200), + KSurfaceFormat, 200 * KBytesPerPixel)); + ASSERT_EQUALS(err,KErrNone); + TRAP(err,iUtility->FanFillSurfaceL(surfaceID,iYellow,iRed,iMagenta)); + ASSERT_EQUALS(err,KErrNone); + TSurfaceConfiguration surfConf; + surfConf.SetSurfaceId(surfaceID); + + surfConf.SetExtent(TRect(2,84,82,166)); + iCompare.SetBackgroundSurface(surfConf,EFalse); + + if (CWindowGc* gc=BeginActivateWithWipe(ETrue,iCompare,TRgb(128,128,128))) + { + DrawCompare::Draw(gc); + gc->Deactivate(); + iCompare.EndRedraw(); + + } + iSession.Finish(ETrue); + Pause(1000); + + MDisplayControl* interface = static_cast + (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); + ASSERT_TRUE(interface); + + TInt resolutions = interface->NumberOfResolutions(); + ASSERT_TRUE (resolutions > 0); + + RArray resolutionList1; + error = interface->GetResolutions(resolutionList1); + ASSERT_EQUALS(error,KErrNone); + ASSERT_EQUALS(resolutionList1.Count(), resolutions); + + TDisplayConfiguration dispConfigBefore; + interface->GetConfiguration(dispConfigBefore); + ASSERT_TRUE(dispConfigBefore.IsDefined(dispConfigBefore.EResolution)) + if (resolutions>1) + { + //Got a mode to change to! + TSize resBefore; + TBool ok=dispConfigBefore.GetResolution(resBefore); + ASSERT_TRUE(ok); //we "know" this should be ok, as we just asserted the flag + TBool foundBeforeRes=EFalse; + for (TInt res=0;resSetConfiguration(dispConfigReq); + //ASSERT_EQUALS(errCode,KErrNone); + if (errCode != KErrNone) + { + //Probably current size mode does not support the rotation of the passed in configuration + + ASSERT_EQUALS(errCode,KErrArgument); //failed to find compatible res in the policy + continue; + } + Pause(300); + TRect outerrect(iTestPos.iTl,resolutionList1[res].iPixelSize.AsPoint()); + iTestBack.SetExtent(outerrect.iTl,outerrect.Size()); + iSession.Finish(ETrue); + Pause(300); + if (CWindowGc* gc=BeginActivateWithWipe(ETrue,iCompare,TRgb(128,128,128))) + { + DrawCompare::Draw(gc); + gc->Deactivate(); + iCompare.EndRedraw(); + } + TBuf16<20> s; + s.AppendNum(res); + UpdateTitleWindowL(s,2); + s.Zero(); + s.AppendNum(resolutionList1[res].iPixelSize.iWidth); + s.Append('x'); + s.AppendNum(resolutionList1[res].iPixelSize.iHeight); + UpdateTitleWindowL(s,3); + + iSession.Finish(ETrue); + Pause(300); + outerrect.iBr.iX-=5; + outerrect.iBr.iY-=5; + iTestBack.SetExtent(outerrect.iTl,outerrect.Size()); + iSession.Finish(ETrue); + Pause(300); + TPoint winpos=iCompare.AbsPosition(); + TSize winsize=iCompare.Size(); +// iInfoScreenDevice->ReleaseTwipsCache(); + RepaintTitleWindowL(); + for (TSize z=TSize(1,1);z!=TSize(-1,-1);) + { + for (TInt i=0;i<15;i++) + { + winpos+=z; + iCompare.SetExtent(winpos,winsize); + iSession.Finish(ETrue); + Pause(100); + } + if (z.iHeight && z.iWidth) + z=TSize(0,-1); + else + if (z.iHeight) + z=TSize(-1,0); + else + z=TSize(-1,-1); + } + TDisplayConfiguration dispConfigAfter; + interface->GetConfiguration(dispConfigAfter); + TSize resAfter; + TBool ok=dispConfigAfter.GetResolution(resAfter); + ASSERT_TRUE(ok); + if (resolutionList1[res].iPixelSize!=resAfter) + { + INFO_PRINTF3(_L("Did not receive expected resolution %ix%i"),resolutionList1[res].iPixelSize.iWidth,resolutionList1[res].iPixelSize.iHeight); + INFO_PRINTF3(_L("Instead got %ix%i"),resAfter.iWidth,resAfter.iHeight); + } + } + } + if (resolutionList1[res].iPixelSize==resBefore) + { + foundBeforeRes=ETrue; + } + } + ASSERT_TRUE(foundBeforeRes); + //restore initial res + interface->SetConfiguration(dispConfigBefore); + Pause(1000); + TDisplayConfiguration dispConfigAfter; + interface->GetConfiguration(dispConfigAfter); + TSize resAfter; + ok=dispConfigAfter.GetResolution(resAfter); + ASSERT_TRUE(ok); + ASSERT_EQUALS(resBefore,resAfter); + } + else + { + INFO_PRINTF1(_L("Only 1 resolution configured on this screen - res change test skipped.")); + } + resolutionList1.Close(); + } + +/** +@SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0007L +@SYMTestCaseDesc Coordinates Mapping +@SYMREQ REQ10336 +@SYMPREQ PREQ2102 +@SYMTestType CT +@SYMTestPurpose Basic call to mapcoordinates +@SYMTestActions + Call mapCoordinates +@SYMTestExpectedResults + targetRect should be correctly filled in with same rect as sourceRect +*/ +void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0007L() + { + MDisplayMapping* interface = static_cast + (iScreenDevice->GetInterface(MDisplayMapping::ETypeId)); + ASSERT_TRUE(interface); + TRect sourceRect(10, 10, 30, 50); + TRect targetRect(5,5,10,10); + TInt err = interface->MapCoordinates(EApplicationSpace, sourceRect, EApplicationSpace, targetRect); + ASSERT_EQUALS(err, KErrNone); + ASSERT_EQUALS(sourceRect, targetRect); + } + +/** +@SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0008L +@SYMTestCaseDesc SetModes and mapCoordinates +@SYMREQ REQ10336 +@SYMPREQ PREQ2102 +@SYMTestType CT +@SYMTestPurpose Basic SetSizeMode and complex MapCoordinates function +@SYMTestActions + Set a new size mode + Perform many rect conversions using MapCoordinates +@SYMTestExpectedResults + Ensure that through multiple conversions, accuracy is not lost +*/ +void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0008L() + { + LOG_AND_PANIC_IF_NOT_GCE; + ResetScreens(); + TInt error; + MakeTitleAndCompareWindowsL(_L("GFX_WSERV_DYNAMICRES_0008L"),_L("Change Size Mode")); + + iTestBack=RWindow(iSession); + ASSERT_EQUALS(iTestBack.Construct(iGroup, ++iWindowHandle), KErrNone); + iTestBack.SetRequiredDisplayMode(iDisplayMode); + iTestBack.SetBackgroundColor(TRgb(255,0,0)); + iTestBack.SetExtent(iTestPos.iTl,iTestPos.Size()); + iTestBack.Activate(); + iTestBack.BeginRedraw(); + ActivateWithWipe(iGc,iTestBack,TRgb(255,0,0)); + iGc->Deactivate(); + iTestBack.EndRedraw(); + iTestBack.SetVisible(ETrue); + + + if (CWindowGc* gc=BeginActivateWithWipe(ETrue,iCompare,TRgb(128,128,128))) + { + gc->SetPenStyle(gc->ESolidPen); + gc->SetPenColor(TRgb(255,255,255)); + gc->SetBrushColor(TRgb(0,0,0)); + TRect r(2,2,22,22); + while(r.Width()>0) + { + gc->DrawRect(r); + r.Shrink(2,2); + } + gc->Deactivate(); + iCompare.EndRedraw(); + + } + iSession.Finish(ETrue); + Pause(1000); + + MDisplayControl* interface = static_cast + (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); + ASSERT_TRUE(interface); + + TInt resolutions = interface->NumberOfResolutions(); + ASSERT_TRUE (resolutions > 0); + + RArray resolutionList1; + error = interface->GetResolutions(resolutionList1); + ASSERT_EQUALS(error,KErrNone); + ASSERT_EQUALS(resolutionList1.Count(), resolutions); + + TDisplayConfiguration dispConfigBefore; + interface->GetConfiguration(dispConfigBefore); + ASSERT_TRUE(dispConfigBefore.IsDefined(dispConfigBefore.EResolution)); + + RArray screenModeList; + iInfoScreenDevice->GetScreenSizeModeList(&screenModeList); + ASSERT_TRUE (screenModeList.Count() > 1); + iScreenDevice->SetAppScreenMode(screenModeList[1]); + iScreenDevice->SetScreenMode(screenModeList[1]); + iSession.Finish(ETrue); + Pause(1000); + + MDisplayMapping* interfaceM = static_cast + (iScreenDevice->GetInterface(MDisplayMapping::ETypeId)); + TRect appRect(20, 40, 193, 110); + TRect uiRect(1,2,3,4); + TRect compRect(5,6,7,8); + TRect tempRect(10,11,12,13); + TInt err; + while (ETrue) + { + //quick get for a print + err = interfaceM->MapCoordinates(EApplicationSpace, appRect, EFullScreenSpace, uiRect); + err = interfaceM->MapCoordinates(EApplicationSpace, appRect, ECompositionSpace, compRect); + +// print +// INFO_PRINTF5(_L("appRect : %d , %d - %d , %d"),appRect.iTl.iX,appRect.iTl.iY,appRect.iBr.iX,appRect.iBr.iY); +// INFO_PRINTF5(_L("uiRect : %d , %d - %d , %d"),uiRect.iTl.iX,uiRect.iTl.iY,uiRect.iBr.iX,uiRect.iBr.iY); +// INFO_PRINTF5(_L("compRect : %d , %d - %d , %d"),compRect.iTl.iX,compRect.iTl.iY,compRect.iBr.iX,compRect.iBr.iY); +// INFO_PRINTF1(_L(" ")); + + //longer process to insure conversions both ways dont lose accuracy + err = interfaceM->MapCoordinates(EApplicationSpace, appRect, EFullScreenSpace, uiRect); + err = interfaceM->MapCoordinates(EFullScreenSpace, uiRect, EApplicationSpace, tempRect); + ASSERT_EQUALS(tempRect,appRect); + + err = interfaceM->MapCoordinates(EApplicationSpace, appRect, ECompositionSpace, compRect); + err = interfaceM->MapCoordinates(ECompositionSpace, compRect, EApplicationSpace, tempRect); + ASSERT_EQUALS(tempRect,appRect); + + err = interfaceM->MapCoordinates(EApplicationSpace, appRect, EFullScreenSpace, uiRect); + err = interfaceM->MapCoordinates(EFullScreenSpace, uiRect, ECompositionSpace, compRect); + err = interfaceM->MapCoordinates(ECompositionSpace, compRect, EFullScreenSpace, tempRect); + ASSERT_EQUALS(tempRect,uiRect); + + appRect.iBr.iX--; + appRect.iBr.iY--; + if (appRect.IsEmpty()) + { + break; + } + } + + TRect rect1(5,5,10,10); + TRect rect2(15,15,20,20); + TRect rect3(50,50,50,50); + //1 + err = interfaceM->MapCoordinates(ECompositionSpace, rect1, ECompositionSpace, rect2); + err = interfaceM->MapCoordinates(EFullScreenSpace, rect2, ECompositionSpace, rect3); + ASSERT_EQUALS(rect1,rect2); + + err = interfaceM->MapCoordinates(ECompositionSpace, rect1, EFullScreenSpace, rect2); + err = interfaceM->MapCoordinates(EFullScreenSpace, rect2, ECompositionSpace, rect3); + ASSERT_EQUALS(rect1,rect3); + + err = interfaceM->MapCoordinates(ECompositionSpace, rect1, EApplicationSpace, rect2); + err = interfaceM->MapCoordinates(EApplicationSpace, rect2, ECompositionSpace, rect3); + ASSERT_EQUALS(rect1,rect3); + + err = interfaceM->MapCoordinates(ECompositionSpace, rect1, EDirectScreenAccessSpace, rect2); + err = interfaceM->MapCoordinates(EDirectScreenAccessSpace, rect2, ECompositionSpace, rect3); + ASSERT_EQUALS(rect1,rect3); + + //2 + err = interfaceM->MapCoordinates(EFullScreenSpace, rect1, EFullScreenSpace, rect2); + ASSERT_EQUALS(rect1,rect2); + + err = interfaceM->MapCoordinates(EFullScreenSpace, rect1, EApplicationSpace, rect2); + err = interfaceM->MapCoordinates(EApplicationSpace, rect2, EFullScreenSpace, rect3); + ASSERT_EQUALS(rect1,rect3); + + err = interfaceM->MapCoordinates(EFullScreenSpace, rect1, EDirectScreenAccessSpace, rect2); + err = interfaceM->MapCoordinates(EDirectScreenAccessSpace, rect2, EFullScreenSpace, rect3); + ASSERT_EQUALS(rect1,rect3); + + //3 + err = interfaceM->MapCoordinates(EApplicationSpace, rect1, EApplicationSpace, rect2); + ASSERT_EQUALS(rect1,rect2); + + err = interfaceM->MapCoordinates(EApplicationSpace, rect1, EDirectScreenAccessSpace, rect2); + err = interfaceM->MapCoordinates(EDirectScreenAccessSpace, rect2, EApplicationSpace, rect3); + ASSERT_EQUALS(rect1,rect3); + + //4 + err = interfaceM->MapCoordinates(EDirectScreenAccessSpace, rect1, EDirectScreenAccessSpace, rect2); + ASSERT_EQUALS(rect1,rect2); + + //invalid + err = interfaceM->MapCoordinates(ECompositionSpace, rect1, (TCoordinateSpace)0, rect2); + ASSERT_EQUALS(err,KErrNotSupported); + err = interfaceM->MapCoordinates(EFullScreenSpace, rect1, (TCoordinateSpace)0, rect2); + ASSERT_EQUALS(err,KErrNotSupported); + err = interfaceM->MapCoordinates(EApplicationSpace, rect1, (TCoordinateSpace)0, rect2); + ASSERT_EQUALS(err,KErrNotSupported); + err = interfaceM->MapCoordinates(EDirectScreenAccessSpace, rect1, (TCoordinateSpace)0, rect2); + ASSERT_EQUALS(err,KErrNotSupported); + err = interfaceM->MapCoordinates((TCoordinateSpace)0, rect1, EDirectScreenAccessSpace, rect2); + ASSERT_EQUALS(err,KErrNotSupported); + + TDisplayConfiguration dispConfigAfter; + interface->GetConfiguration(dispConfigAfter); + + screenModeList.Close(); + resolutionList1.Close(); + iScreenDevice->SetAppScreenMode(0); + iScreenDevice->SetScreenMode(0); + } + +/** +@SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0009L +@SYMTestCaseDesc Set Screen display res using app mode +@SYMREQ REQ10336 +@SYMPREQ PREQ2102 +@SYMTestType CT +@SYMTestPurpose SetScreenMode functions correctly +@SYMTestActions + Similar to 0006, but setting every available screen mode instead of resolution +@SYMTestExpectedResults + Every set should work, including modes that involve a rotation! +*/ +void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0009L() + { + LOG_AND_PANIC_IF_NOT_GCE; + ResetScreens(); + TInt error; + iSession.Finish(ETrue); + MakeTitleAndCompareWindowsL(_L("GFX_WSERV_DYNAMICRES_0009L"),_L("Change Size Mode")); + iSession.Finish(ETrue); + + iTestBack=RWindow(iSession); + ASSERT_EQUALS(iTestBack.Construct(iGroup, ++iWindowHandle), KErrNone); + iTestBack.SetRequiredDisplayMode(iDisplayMode); + iTestBack.SetBackgroundColor(TRgb(255,0,0)); + iTestBack.SetExtent(iTestPos.iTl,iTestPos.Size()); + iTestBack.Activate(); + iTestBack.BeginRedraw(); + ActivateWithWipe(iGc,iTestBack,TRgb(255,0,0)); + iGc->Deactivate(); + iTestBack.EndRedraw(); + iTestBack.SetVisible(ETrue); + iSession.Finish(ETrue); + + struct DrawCompare + { + static void Draw(CWindowGc* aGc) + { + aGc->SetPenStyle(aGc->ESolidPen); + aGc->SetPenColor(TRgb(255,255,255)); + aGc->SetBrushColor(TRgb(0,0,0)); + TRect r(2,2,82,82); + while(r.Width()>0) + { + aGc->DrawRect(r); + r.Shrink(2,2); + } + } + }; + TSurfaceId surfaceID; + TRAPD(err, surfaceID = iUtility->CreateSurfaceL(TSize(200,200), + KSurfaceFormat, 200 * KBytesPerPixel)); + ASSERT_EQUALS(err,KErrNone); + TRAP(err,iUtility->FanFillSurfaceL(surfaceID,iYellow,iRed,iMagenta)); + ASSERT_EQUALS(err,KErrNone); + TSurfaceConfiguration surfConf; + surfConf.SetSurfaceId(surfaceID); + + surfConf.SetExtent(TRect(2,84,82,166)); + iCompare.SetBackgroundSurface(surfConf,EFalse); + + if (CWindowGc* gc=BeginActivateWithWipe(ETrue,iCompare,TRgb(128,128,128))) + { + DrawCompare::Draw(gc); + gc->Deactivate(); + iCompare.EndRedraw(); + + } + iSession.Finish(ETrue); + Pause(1000); + RArray screenModeList; + iInfoScreenDevice->GetScreenSizeModeList(&screenModeList); + MDisplayControl* interface = static_cast + (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); + ASSERT_TRUE(interface); + + TInt resolutions = interface->NumberOfResolutions(); + ASSERT_TRUE (resolutions > 0); + + RArray resolutionList1; + error = interface->GetResolutions(resolutionList1); + ASSERT_EQUALS(error,KErrNone); + ASSERT_EQUALS(resolutionList1.Count(), resolutions); + + TDisplayConfiguration dispConfigBefore; + interface->GetConfiguration(dispConfigBefore); + ASSERT_TRUE(dispConfigBefore.IsDefined(dispConfigBefore.EResolution)) + if (screenModeList.Count()>1) + { + //Got a mode to change to! + TSize resBefore; + TBool ok=dispConfigBefore.GetResolution(resBefore); + ASSERT_TRUE(ok); //we "know" this should be ok, as we just asserted the flag + for (TInt res=0;resSetAppScreenMode(screenModeList[res]); + iInfoScreenDevice->SetScreenMode(screenModeList[res]); + iSession.Finish(ETrue); + Pause(300); + + TPixelsAndRotation pr; + iInfoScreenDevice->GetDefaultScreenSizeAndRotation(pr); + TPoint origin=iInfoScreenDevice->GetDefaultScreenModeOrigin(); + Pause(300); + + if (CWindowGc* gc=BeginActivateWithWipe(ETrue,iCompare,TRgb(128,128,128))) + { + DrawCompare::Draw(gc); + gc->Deactivate(); + iCompare.EndRedraw(); + } + if (iTitle.WsHandle()) + { + TPoint infoWinPos; + TSize infoWinSize; + infoWinPos=iTitle.AbsPosition(); + infoWinSize=iTitle.Size(); + infoWinSize.iHeight=pr.iPixelSize.iHeight-2*infoWinPos.iY; + iTitle.SetSize(infoWinSize); + } + TBuf16<20> s; + s.AppendNum(res); + UpdateTitleWindowL(s,1); + s.Zero(); + s.AppendNum(pr.iPixelSize.iWidth); + s.Append('x'); + s.AppendNum(pr.iPixelSize.iHeight); + UpdateTitleWindowL(s,2); + s.Zero(); + s.AppendNum(origin.iX); + s.Append(','); + s.AppendNum(origin.iY); + UpdateTitleWindowL(s,3); + + iSession.Finish(ETrue); + Pause(300); + + TPoint winpos=iCompare.AbsPosition(); + TSize winsize=iCompare.Size(); + + for (TSize z=TSize(1,1);z!=TSize(-1,-1);) + { + for (TInt i=0;i<15;i++) + { + winpos+=z; + iCompare.SetExtent(winpos,winsize); + iSession.Finish(ETrue); + Pause(100); + } + if (z.iHeight && z.iWidth) + z=TSize(0,-1); + else + if (z.iHeight) + z=TSize(-1,0); + else + z=TSize(-1,-1); + } + } + } + } + //restore initial res + if (screenModeList.Count() > 1) + { //set back to basics + iInfoScreenDevice->SetAppScreenMode(screenModeList[0]); + iInfoScreenDevice->SetScreenMode(screenModeList[0]); + Pause(300); + } + + interface->SetConfiguration(dispConfigBefore); + Pause(1000); + TDisplayConfiguration dispConfigAfter; + interface->GetConfiguration(dispConfigAfter); + TSize resAfter; + ok=dispConfigAfter.GetResolution(resAfter); + ASSERT_TRUE(ok); + ASSERT_EQUALS(resBefore,resAfter); + } + else + { + INFO_PRINTF1(_L("Only 1 screen size mode configured on this screen - res change test skipped.")); + } + + screenModeList.Close(); + resolutionList1.Close(); + } + +/** +@SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0010L +@SYMTestCaseDesc Test app mode setting during attach/detach +@SYMREQ REQ10330 +@SYMPREQ PREQ2102 +@SYMTestType CT +@SYMTestPurpose Make sure display resumes last app mode when reattached +@SYMTestActions + Save app mode and display configuration before detach and compare it with those after reattach. + Repeat for a second app mode + If available, repeat with dynamic app mode +@SYMTestExpectedResults + For normal app mode, on reconnect it should re apply the old configuration + For dynamic app mode, on reconnect it should be 0x0 +*/ +void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0010L() + { + LOG_AND_PANIC_IF_NOT_GCE; + ResetScreens(); +#ifdef MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER + ASSERT_FALSE("Test not compiled because MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER"); +#else + TInt error; + iSession.Finish(ETrue); + MakeTitleAndCompareWindowsL(_L("GFX_WSERV_DYNAMICRES_0010L"),_L("detach/attach")); + iSession.Finish(ETrue); + + Pause(1000); + TInt screenNo = iScreenDevice->GetScreenNumber(); + RArray screenModeList; + iInfoScreenDevice->GetScreenSizeModeList(&screenModeList); + + //Find 2 real app modes and 1 dynamic app mode + TInt firstAvailableAppMode = -1; + TInt secondAvailableAppMode = -1; + TInt dynamicAppMode = -1; + for (TInt ii = 0; ii < screenModeList.Count(); ii++) + { + TBool dynamic = iInfoScreenDevice->IsModeDynamic(screenModeList[ii]); + if (dynamic && dynamicAppMode == -1) + { + dynamicAppMode = screenModeList[ii]; + } + if (!dynamic) + { + if (firstAvailableAppMode == -1) + { + firstAvailableAppMode = screenModeList[ii]; + } + else if (secondAvailableAppMode == -1) + { + secondAvailableAppMode = screenModeList[ii]; + } + } + } + ASSERT_TRUE(firstAvailableAppMode!=-1); + ASSERT_TRUE(secondAvailableAppMode!=-1); + + MDisplayControl* interface = static_cast + (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); + ASSERT_TRUE(interface); + + MDisplayMapping* mappingInterface = static_cast + (iScreenDevice->GetInterface(MDisplayMapping::ETypeId)); + ASSERT_TRUE(mappingInterface); + + TInt resolutions = interface->NumberOfResolutions(); + ASSERT_TRUE (resolutions > 0); + + RArray resolutionList1; + error = interface->GetResolutions(resolutionList1); + ASSERT_EQUALS(error,KErrNone); + ASSERT_EQUALS(resolutionList1.Count(), resolutions); + + TDisplayConfiguration configBeforeDetach, configAfterReattach; + TInt appModeBeforeDetach, appModeAfterReattach; + + // + //1st detach - attach sequence + appModeBeforeDetach = firstAvailableAppMode; + iScreenDevice->SetAppScreenMode(appModeBeforeDetach ); + iScreenDevice->SetScreenMode(appModeBeforeDetach ); + Pause(200); + interface->GetConfiguration(configBeforeDetach); + + TInt displayState = EDisconnect; + UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL); + Pause(300); + + //dummy mapping should return KErrNotReady if display is disconnected + TRect dummyRect(1,2,5,8); + error = mappingInterface->MapCoordinates(ECompositionSpace, dummyRect, EFullScreenSpace, dummyRect); + ASSERT_EQUALS(error, KErrNotReady); + + displayState = ENormalResolution; + UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL); + Pause(300); + + interface->GetConfiguration(configAfterReattach); + ASSERT_TRUE(configBeforeDetach==configAfterReattach); + appModeAfterReattach = iScreenDevice->CurrentScreenMode(); + ASSERT_EQUALS(appModeBeforeDetach, appModeAfterReattach); + //1st detach - attach sequence ends here + // + + configBeforeDetach.ClearAll(); + configAfterReattach.ClearAll(); + + // + //2nd detach-attach sequence - non dynamic app mode + iScreenDevice->SetAppScreenMode(secondAvailableAppMode); + iScreenDevice->SetScreenMode(secondAvailableAppMode); + Pause(200); + appModeBeforeDetach = iScreenDevice->CurrentScreenMode(); + interface->GetConfiguration(configBeforeDetach); + displayState = EDisconnect; + UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL); + Pause(300); + //dummy mapping should return KErrNotReady if display is disconnected + error = mappingInterface->MapCoordinates(ECompositionSpace, dummyRect, EFullScreenSpace, dummyRect); + ASSERT_EQUALS(error, KErrNotReady); + + displayState = ENoResolution; + UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL); + Pause(300); + //dummy mapping should return KErrNotReady if display is disconnected + error = mappingInterface->MapCoordinates(ECompositionSpace, dummyRect, EFullScreenSpace, dummyRect); + ASSERT_EQUALS(error, KErrNotReady); + + displayState = ENormalResolution; + UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL); + Pause(300); + + interface->GetConfiguration(configAfterReattach); + ASSERT_TRUE(configBeforeDetach==configAfterReattach); + appModeAfterReattach = iScreenDevice->CurrentScreenMode(); + ASSERT_EQUALS(appModeBeforeDetach, appModeAfterReattach); + //2nd detach-attach sequence ends here + // + + configBeforeDetach.ClearAll(); + configAfterReattach.ClearAll(); + + // + //3rd detach-attach sequence - dynamic app mode + if (dynamicAppMode == -1) + { + screenModeList.Close(); + resolutionList1.Close(); + INFO_PRINTF1(_L("No dynamic app mode, end test")); //not a fail if there isn't a dynamic app mode + return; + } + + iScreenDevice->SetAppScreenMode(dynamicAppMode); + iScreenDevice->SetScreenMode(dynamicAppMode); + Pause(200); + appModeBeforeDetach = iScreenDevice->CurrentScreenMode(); + interface->GetConfiguration(configBeforeDetach); + displayState = EDisconnect; + UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL); + Pause(300); + //dummy mapping should return KErrNotReady if display is disconnected + error = mappingInterface->MapCoordinates(ECompositionSpace, dummyRect, EFullScreenSpace, dummyRect); + ASSERT_EQUALS(error, KErrNotReady); + + displayState = ENoResolution; + UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL); + Pause(300); + //dummy mapping should return KErrNotReady if display is disconnected + error = mappingInterface->MapCoordinates(ECompositionSpace, dummyRect, EFullScreenSpace, dummyRect); + ASSERT_EQUALS(error, KErrNotReady); + + displayState = ENormalResolution; + UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL); + Pause(300); + + interface->GetConfiguration(configAfterReattach); + ASSERT_FALSE(configBeforeDetach==configAfterReattach); + TSize afterReattachSize; + ASSERT_TRUE(configAfterReattach.GetResolution(afterReattachSize)); + ASSERT_EQUALS(afterReattachSize,TSize(0,0)); + ASSERT_TRUE(configAfterReattach.GetResolutionTwips(afterReattachSize)); + ASSERT_EQUALS(afterReattachSize,TSize(0,0)); + + appModeAfterReattach = iScreenDevice->CurrentScreenMode(); + ASSERT_EQUALS(appModeBeforeDetach, appModeAfterReattach); + //3rd detach-attach sequence ends here + // + + screenModeList.Close(); + resolutionList1.Close(); +#endif + } + + +CDSATestDrawing::CDSATestDrawing():CTimer(EPriorityStandard) + {} + +CDSATestDrawing::~CDSATestDrawing() + { + Cancel(); + } +CDSATestDrawing* CDSATestDrawing::NewL() + { + CDSATestDrawing *self = new(ELeave) CDSATestDrawing(); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +void CDSATestDrawing::ConstructL() + { + CTimer::ConstructL(); + CActiveScheduler::Add(this); + } + +void CDSATestDrawing::StartDrawingL(CDirectScreenAccess *aDSA) + { + + if(aDSA) + { + iDSA = aDSA; + } + + if(iDSA) + { + iDSA->StartL(); + + iRect = TRect(TPoint(0,0), iDSA->DrawingRegion()->BoundingRect().Size()); + + iWin->Invalidate(); + iWin->BeginRedraw(); + CFbsBitGc* gc = iDSA->Gc(); + gc->SetBrushColor(TRgb(220,220,220)); + gc->SetBrushStyle(CGraphicsContext::ESolidBrush); + gc->Clear(); + iWin->EndRedraw(); + After(500000); + } + + } + +void CDSATestDrawing::RunL() + { + Draw(); + After(500000); + } + +void CDSATestDrawing::Draw() + { + iWin->Invalidate(); + iWin->BeginRedraw(); + CFbsBitGc* gc = iDSA->Gc(); + gc->SetPenStyle(gc->ESolidPen); + gc->SetPenColor(TRgb(255,0,0)); + gc->SetBrushStyle(gc->ENullBrush); + iRect.Shrink(1, 1); + gc->DrawRect(iRect); + iDSA->ScreenDevice()->Update(); + iWin->EndRedraw(); + + } +void CDSATestDrawing::Restart(RDirectScreenAccess::TTerminationReasons /*aReason*/) + { + + StartDrawingL(NULL); + } + +void CDSATestDrawing::AbortNow(RDirectScreenAccess::TTerminationReasons /*aReason*/) + { + Cancel(); + } + +/** +@SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0011L +@SYMTestCaseDesc Test DSA drawing in different App Mode +@SYMREQ REQ10332 REQ10336 +@SYMPREQ PREQ2102 +@SYMTestType CT +@SYMTestPurpose Test DSA can restart and draw at correct place when screen mode changes +@SYMTestActions + A rectangle will be drawn 1 pixel inside the DSA drawing region, and continue to shrink before the drawing + time runs out. when screen mode changes, DSA should restart and the rectangle should be reset to 1 pixel inside + the new drawing region. + + note: DSA drawing region is clipped by DSA buffer, App Size and the visible area of the window which it drawns in +@SYMTestExpectedResults + All tests should pass. + +*/ +void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0011L() + { + LOG_AND_PANIC_IF_NOT_GCE; + ResetScreens(); + + Pause(1000); + MakeTitleAndCompareWindowsL(_L("GFX_WSERV_DYNAMICRES_0011L"),_L("DSA drawing")); + CDSATestDrawing *dsaDraw = CDSATestDrawing::NewL(); + CleanupStack::PushL(dsaDraw); + CDirectScreenAccess *dsa = CDirectScreenAccess::NewL(iSession, *iScreenDevice, iCompare, *dsaDraw); + CleanupStack::PushL(dsa); + dsaDraw->SetWindow(iCompare); + dsaDraw->StartDrawingL(dsa); + + CEventTimer *timer = CEventTimer::NewL(); + CleanupStack::PushL(timer); + + RArray screenModeList; + iInfoScreenDevice->GetScreenSizeModeList(&screenModeList); + MDisplayControl* interface = static_cast + (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); + ASSERT_TRUE(interface); + + MDisplayMapping* mappingInterface = static_cast + (iScreenDevice->GetInterface(MDisplayMapping::ETypeId)); + ASSERT_TRUE(mappingInterface); + + CFbsScreenDevice *pixelReadBackDevice = CFbsScreenDevice::NewL(iScreenDevice->GetScreenNumber(), iScreenDevice->DisplayMode()); + CleanupStack::PushL(pixelReadBackDevice); + + for (TInt res=0;resSetAppScreenMode(screenModeList[res]); + iScreenDevice->SetScreenMode(screenModeList[res]); + dsa->ScreenDevice()->Update(); + Pause(300); + //wait for DSA to restart + timer->Wait(500000); + TRect regionRect(dsa->DrawingRegion()->BoundingRect()); + + TPoint winpos = iCompare.AbsPosition(); + TSize winsize = iCompare.Size(); + + TPixelsAndRotation pr; + iInfoScreenDevice->GetDefaultScreenSizeAndRotation(pr); + TPoint origin=iInfoScreenDevice->GetDefaultScreenModeOrigin(); + Pause(300); + if (iTitle.WsHandle()) + { + TPoint infoWinPos; + TSize infoWinSize; + infoWinPos=iTitle.AbsPosition(); + infoWinSize=iTitle.Size(); + infoWinSize.iHeight=pr.iPixelSize.iHeight-2*infoWinPos.iY; + iTitle.SetSize(infoWinSize); + } + TBuf16<20> s; + s.AppendNum(res); + UpdateTitleWindowL(s,1); + s.Zero(); + s.AppendNum(pr.iPixelSize.iWidth); + s.Append('x'); + s.AppendNum(pr.iPixelSize.iHeight); + UpdateTitleWindowL(s,2); + s.Zero(); + s.AppendNum(origin.iX); + s.Append(','); + s.AppendNum(origin.iY); + UpdateTitleWindowL(s,3); + + INFO_PRINTF2(_L("---------test %i---------"), res); + INFO_PRINTF3(_L("resolution %i x %i"), pr.iPixelSize.iWidth, pr.iPixelSize.iHeight); + INFO_PRINTF3(_L("Origin (%i, %i)"), origin.iX, origin.iY); + //INFO_PRINTF3(_L("Test Window Origin (%i, %i)"), iCompare.AbsPosition().iX, iCompare.AbsPosition().iY); + INFO_PRINTF3(_L("DSA drawing region bounding rect origin (%i, %i)"), dsa->DrawingRegion()->BoundingRect().iTl.iX, + dsa->DrawingRegion()->BoundingRect().iTl.iY); + INFO_PRINTF3(_L("DSA drawing region bounding rect size (%i x %i)"), dsa->DrawingRegion()->BoundingRect().Width(), + dsa->DrawingRegion()->BoundingRect().Height()); + //give time so DSA AO can start drawing + timer->Wait(5000000); + + + TRect readBackRect; + mappingInterface->MapCoordinates(EApplicationSpace, TRect(0,0,1,1), EDirectScreenAccessSpace, readBackRect); + pixelReadBackDevice->SetDrawDeviceOffset(readBackRect.iTl); + pixelReadBackDevice->SetDeviceOrientation((TDeviceOrientation)(1 << pr.iRotation)); + readBackRect.SetRect(dsa->DrawingRegion()->BoundingRect().iTl, dsa->DrawingRegion()->BoundingRect().iBr); + + if(readBackRect.IsEmpty()) + { + INFO_PRINTF1(_L("DSA drawing region is empty, skip checking pixel colour")); + continue; + } + + //if my rectangle's iTl is (0,0) and iBr is (100,100). Why does it gives me the rect width and height + //both 100? 0 - 100 is 101 pixels drawn. Or does this indicates iBr is exclusive and iTl is inclusive? + //Ruo: Oh I almost believe iBr is exclusive now + TDisplayConfiguration dispConfigAfter2; + interface->GetConfiguration(dispConfigAfter2); + TSize theSize; + dispConfigAfter2.GetResolution(theSize); + TDisplayConfiguration1::TRotation orient; + dispConfigAfter2.GetRotation(orient); + if (orient == TDisplayConfiguration1::ERotation90CW || orient == TDisplayConfiguration1::ERotation270CW) + { + TInt temp = theSize.iHeight; + theSize.iHeight = theSize.iWidth; + theSize.iWidth = temp; + } + TRect uiSize(TPoint(0,0), theSize); + MDisplayMapping* mappingInterface = static_cast + (iScreenDevice->GetInterface(MDisplayMapping::ETypeId)); + ASSERT_TRUE(mappingInterface); + TRect finalSize; + mappingInterface->MapCoordinates(EApplicationSpace, uiSize, ECompositionSpace, finalSize); + + CFbsBitmap* bmp2 = new (ELeave) CFbsBitmap; + CleanupStack::PushL(bmp2); + User::LeaveIfError(bmp2->Create(finalSize.Size(), EColor16MU)); + MTestScreenCapture + * csc = + static_cast (iScreenDevice->GetInterface(MTestScreenCapture::KUidTestScreenCaptureIf)); + + if (csc) + { + TInt errr = csc->ComposeScreen(*bmp2); + ASSERT_TRUE(errr == KErrNone); + } + else + { + if (!cSCLogged) + { + cSCLogged = ETrue; + _LIT(KNoCSC, "CSC testing not enabled as CSC render stage not defined"); + Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrAll, KNoCSC); + } + } + + readBackRect.iBr = readBackRect.iBr - TPoint(1,1); + //check 4 outter corners + TRgb pixelRgb; + TRgb cornerRgb(220, 220, 220); + TRgb innerRgb(255, 0, 0); + readBackRect.Grow(1, 1); + TRect compSpaceReadBackRect; + mappingInterface->MapCoordinates(EApplicationSpace, readBackRect, ECompositionSpace, compSpaceReadBackRect); + + + if (csc) + { + if (finalSize.Contains(compSpaceReadBackRect.iTl)) + { + bmp2->GetPixel(pixelRgb, compSpaceReadBackRect.iTl); + if(!(pixelRgb != cornerRgb)) + { + _LIT(KCompareFailed, "Corner check failed on app mode: %d"); + TBuf<256> x; + x.Format(KCompareFailed, res+1); + Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x); + CleanupStack::PopAndDestroy(bmp2); + continue; + } + } + if (finalSize.Contains(TPoint(compSpaceReadBackRect.iBr.iX, compSpaceReadBackRect.iTl.iY))) + { + bmp2->GetPixel(pixelRgb, TPoint(compSpaceReadBackRect.iBr.iX, compSpaceReadBackRect.iTl.iY)); + if(!(pixelRgb != cornerRgb)) + { + _LIT(KCompareFailed, "Corner check failed on app mode: %d"); + TBuf<256> x; + x.Format(KCompareFailed, res+1); + Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x); + CleanupStack::PopAndDestroy(bmp2); + continue; + } + } + if (finalSize.Contains(compSpaceReadBackRect.iBr)) + { + bmp2->GetPixel(pixelRgb, compSpaceReadBackRect.iBr); + if(!(pixelRgb != cornerRgb)) + { + _LIT(KCompareFailed, "Corner check failed on app mode: %d"); + TBuf<256> x; + x.Format(KCompareFailed, res+1); + Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x); + CleanupStack::PopAndDestroy(bmp2); + continue; + } + } + if (finalSize.Contains(TPoint(compSpaceReadBackRect.iTl.iX, compSpaceReadBackRect.iBr.iY))) + { + bmp2->GetPixel(pixelRgb, TPoint(compSpaceReadBackRect.iTl.iX, compSpaceReadBackRect.iBr.iY)); + if(!(pixelRgb != cornerRgb)) + { + _LIT(KCompareFailed, "Corner check failed on app mode: %d"); + TBuf<256> x; + x.Format(KCompareFailed, res+1); + Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x); + CleanupStack::PopAndDestroy(bmp2); + continue; + } + } + } + + pixelReadBackDevice->GetPixel(pixelRgb, readBackRect.iTl); + ASSERT_TRUE(pixelRgb != cornerRgb); + pixelReadBackDevice->GetPixel(pixelRgb, TPoint(readBackRect.iBr.iX, readBackRect.iTl.iY)); + ASSERT_TRUE(pixelRgb != cornerRgb); + pixelReadBackDevice->GetPixel(pixelRgb, readBackRect.iBr); + ASSERT_TRUE(pixelRgb != cornerRgb); + pixelReadBackDevice->GetPixel(pixelRgb, TPoint(readBackRect.iTl.iX, readBackRect.iBr.iY)); + ASSERT_TRUE(pixelRgb != cornerRgb); + + //check 4 inner corners + readBackRect.Shrink(1,1); + mappingInterface->MapCoordinates(EApplicationSpace, readBackRect, ECompositionSpace, compSpaceReadBackRect); + + if (csc) + { + if (finalSize.Contains(compSpaceReadBackRect.iTl)) + { + bmp2->GetPixel(pixelRgb, compSpaceReadBackRect.iTl); + if(!(pixelRgb == cornerRgb)) + { + _LIT(KCompareFailed, "Corner check failed on app mode: %d"); + TBuf<256> x; + x.Format(KCompareFailed, res+1); + Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x); + CleanupStack::PopAndDestroy(bmp2); + continue; + } + } + if (finalSize.Contains(TPoint(compSpaceReadBackRect.iBr.iX, compSpaceReadBackRect.iTl.iY))) + { + bmp2->GetPixel(pixelRgb, TPoint(compSpaceReadBackRect.iBr.iX, compSpaceReadBackRect.iTl.iY)); + if(!(pixelRgb == cornerRgb)) + { + _LIT(KCompareFailed, "Corner check failed on app mode: %d"); + TBuf<256> x; + x.Format(KCompareFailed, res+1); + Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x); + CleanupStack::PopAndDestroy(bmp2); + continue; + } + } + if (finalSize.Contains(compSpaceReadBackRect.iBr)) + { + bmp2->GetPixel(pixelRgb, compSpaceReadBackRect.iBr); + if(!(pixelRgb == cornerRgb)) + { + _LIT(KCompareFailed, "Corner check failed on app mode: %d"); + TBuf<256> x; + x.Format(KCompareFailed, res+1); + Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x); + CleanupStack::PopAndDestroy(bmp2); + continue; + } + } + if (finalSize.Contains(TPoint(compSpaceReadBackRect.iTl.iX, compSpaceReadBackRect.iBr.iY))) + { + bmp2->GetPixel(pixelRgb, TPoint(compSpaceReadBackRect.iTl.iX, compSpaceReadBackRect.iBr.iY)); + if(!(pixelRgb == cornerRgb)) + { + _LIT(KCompareFailed, "Corner check failed on app mode: %d"); + TBuf<256> x; + x.Format(KCompareFailed, res+1); + Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x); + CleanupStack::PopAndDestroy(bmp2); + continue; + } + } + } + + pixelReadBackDevice->GetPixel(pixelRgb, readBackRect.iTl); + ASSERT_TRUE(pixelRgb == cornerRgb); + pixelReadBackDevice->GetPixel(pixelRgb, TPoint(readBackRect.iBr.iX, readBackRect.iTl.iY)); + ASSERT_TRUE(pixelRgb == cornerRgb); + pixelReadBackDevice->GetPixel(pixelRgb, readBackRect.iBr); + ASSERT_TRUE(pixelRgb == cornerRgb); + pixelReadBackDevice->GetPixel(pixelRgb, TPoint(readBackRect.iTl.iX, readBackRect.iBr.iY)); + ASSERT_TRUE(pixelRgb == cornerRgb); + //check inner colour + if(readBackRect.Width() < 3 || readBackRect.Height() < 3) + { + INFO_PRINTF1(_L("DSA drawing region is too small for drawing inner rectangle skip checking inner colour")); + CleanupStack::PopAndDestroy(bmp2); + continue; + } + + readBackRect.Shrink(1,1); + mappingInterface->MapCoordinates(EApplicationSpace, readBackRect, ECompositionSpace, compSpaceReadBackRect); + + if (csc) + { + if (finalSize.Contains(compSpaceReadBackRect.iTl)) + { + bmp2->GetPixel(pixelRgb, compSpaceReadBackRect.iTl); + if(!(pixelRgb == innerRgb)) + { + _LIT(KCompareFailed, "Corner check failed on app mode: %d"); + TBuf<256> x; + x.Format(KCompareFailed, res+1); + Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x); + CleanupStack::PopAndDestroy(bmp2); + continue; + } + } + if (finalSize.Contains(TPoint(compSpaceReadBackRect.iBr.iX, compSpaceReadBackRect.iTl.iY))) + { + bmp2->GetPixel(pixelRgb, TPoint(compSpaceReadBackRect.iBr.iX, compSpaceReadBackRect.iTl.iY)); + if(!(pixelRgb == innerRgb)) + { + _LIT(KCompareFailed, "Corner check failed on app mode: %d"); + TBuf<256> x; + x.Format(KCompareFailed, res+1); + Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x); + CleanupStack::PopAndDestroy(bmp2); + continue; + } + } + if (finalSize.Contains(compSpaceReadBackRect.iBr)) + { + bmp2->GetPixel(pixelRgb, compSpaceReadBackRect.iBr); + if(!(pixelRgb == innerRgb)) + { + _LIT(KCompareFailed, "Corner check failed on app mode: %d"); + TBuf<256> x; + x.Format(KCompareFailed, res+1); + Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x); + CleanupStack::PopAndDestroy(bmp2); + continue; + } + } + if (finalSize.Contains(TPoint(compSpaceReadBackRect.iTl.iX, compSpaceReadBackRect.iBr.iY))) + { + bmp2->GetPixel(pixelRgb, TPoint(compSpaceReadBackRect.iTl.iX, compSpaceReadBackRect.iBr.iY)); + if(!(pixelRgb == innerRgb)) + { + _LIT(KCompareFailed, "Corner check failed on app mode: %d"); + TBuf<256> x; + x.Format(KCompareFailed, res+1); + Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x); + CleanupStack::PopAndDestroy(bmp2); + continue; + } + } + } + + pixelReadBackDevice->GetPixel(pixelRgb, readBackRect.iTl); + ASSERT_TRUE(pixelRgb == innerRgb); + pixelReadBackDevice->GetPixel(pixelRgb, TPoint(readBackRect.iBr.iX, readBackRect.iTl.iY)); + ASSERT_TRUE(pixelRgb == innerRgb); + pixelReadBackDevice->GetPixel(pixelRgb, readBackRect.iBr); + ASSERT_TRUE(pixelRgb == innerRgb); + pixelReadBackDevice->GetPixel(pixelRgb, TPoint(readBackRect.iTl.iX, readBackRect.iBr.iY)); + ASSERT_TRUE(pixelRgb == innerRgb); + + CleanupStack::PopAndDestroy(bmp2); + } + screenModeList.Close(); + CleanupStack::PopAndDestroy(4, dsaDraw); + } + +/** +@SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0012L +@SYMTestCaseDesc Test Pointer event coordinates are correct in different screen modes. +@SYMREQ REQ10336 +@SYMPREQ PREQ2102 +@SYMTestType CT +@SYMTestPriority 1 +@SYMTestPurpose Test Pointer event coordinates are correct in different screen mode +@SYMTestActions + In each screen mode, the simulated pointer event should always at the same relative position + inside iCompare window +@SYMTestExpectedResults + All test should pass + **NOTE Can only be tested in screen 0 ** +*/ +void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0012L() + { + LOG_AND_PANIC_IF_NOT_GCE; + ResetScreens(); + MakeTitleAndCompareWindowsL(_L("GFX_WSERV_DYNAMICRES_0012L"),_L("Pointer coordinates")); + Pause(300); + + CWsDisplayEvent* displayEventAO = new(ELeave) CWsDisplayEvent(&iSession); + CleanupStack::PushL(displayEventAO); + displayEventAO->Request(); + CEventTimer *timer = CEventTimer::NewL(); + CleanupStack::PushL(timer); + + MDisplayMapping* mappingInterface = static_cast + (iScreenDevice->GetInterface(MDisplayMapping::ETypeId)); + ASSERT_TRUE(mappingInterface); + + RArray screenModeList; + iInfoScreenDevice->GetScreenSizeModeList(&screenModeList); + iSession.SetFocusScreen(TGlobalSettings::Instance().iScreen); + + for (TInt res=0;resSetAppScreenMode(screenModeList[res]); + iScreenDevice->SetScreenMode(screenModeList[res]); + Pause(300); + + //win position in app space + TPoint winPos = iCompare.AbsPosition(); + TSize winSize = iCompare.Size(); + + //pointer event at the origin of window + TRect rectNearWinOrigin(winPos+TPoint(1,1), TSize(1,1)); + //the expected pointer position received by client to compare with the actual point received. + //it's (1,1) because it's relative to window + displayEventAO->SetExpectedPointPos(TPoint(1, 1)); + TRect rectInComp, rectBackInApp; + mappingInterface->MapCoordinates(EApplicationSpace, rectNearWinOrigin, ECompositionSpace, rectInComp); + //as we got the physical coordinates at where we simulate pointer event + TRawEvent rawEvent; + rawEvent.Set(TRawEvent::EButton1Down, rectInComp.iTl.iX, rectInComp.iTl.iY); + iSession.SimulateRawEvent(rawEvent); + rawEvent.Set(TRawEvent::EButton1Up, rectInComp.iTl.iX, rectInComp.iTl.iY); + iSession.SimulateRawEvent(rawEvent); + iSession.Flush(); + timer->Wait(1000); + + ASSERT_EQUALS(displayEventAO->ReceivedPointerEventCount(), res*4+2); + ASSERT_TRUE(displayEventAO->PointerTestPassed()); + + //pointer event at 1/2 width and height inside the window + TRect rectAtWinCenter(winPos+TPoint(winSize.iWidth/2, winSize.iHeight/2), TSize(1,1)); + displayEventAO->SetExpectedPointPos(rectAtWinCenter.iTl - winPos); + mappingInterface->MapCoordinates(EApplicationSpace, rectAtWinCenter, ECompositionSpace, rectInComp); + //as we got the physical coordinates at where we simulate pointer event + rawEvent.Set(TRawEvent::EButton1Down, rectInComp.iTl.iX, rectInComp.iTl.iY); + iSession.SimulateRawEvent(rawEvent); + rawEvent.Set(TRawEvent::EButton1Up, rectInComp.iTl.iX, rectInComp.iTl.iY); + iSession.SimulateRawEvent(rawEvent); + iSession.Flush(); + timer->Wait(1000); + + ASSERT_EQUALS(displayEventAO->ReceivedPointerEventCount(), res*4 + 4); + ASSERT_TRUE(displayEventAO->PointerTestPassed()); + } + screenModeList.Close(); + CleanupStack::PopAndDestroy(2, displayEventAO); + } + +/** +@SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0013L +@SYMTestCaseDesc Test the twips size after detach +@SYMREQ REQ10329 +@SYMPREQ PREQ2102 +@SYMTestType CT +@SYMTestPurpose Make sure the twips size is undefined after detach. +@SYMTestActions + Save display configuration before detach and compare it with the display configuration after detach. +@SYMTestExpectedResults + all tests should pass +*/ +void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0013L() + { + LOG_AND_PANIC_IF_NOT_GCE; + ResetScreens(); +#ifdef MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER + ASSERT_FALSE("Test not compiled because MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER"); +#else + TInt error; + iSession.Finish(ETrue); + MakeTitleAndCompareWindowsL(_L("GFX_WSERV_DYNAMICRES_0013L"),_L("detach/attach - twips size")); + iSession.Finish(ETrue); + + Pause(1000); + TInt screenNo = iScreenDevice->GetScreenNumber(); + RArray screenModeList; + iInfoScreenDevice->GetScreenSizeModeList(&screenModeList); + MDisplayControl* interface = static_cast + (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); + ASSERT_TRUE(interface); + + MDisplayMapping* mappingInterface = static_cast + (iScreenDevice->GetInterface(MDisplayMapping::ETypeId)); + ASSERT_TRUE(mappingInterface); + + TInt resolutions = interface->NumberOfResolutions(); + ASSERT_TRUE (resolutions > 0); + + RArray resolutionList1; + error = interface->GetResolutions(resolutionList1); + ASSERT_EQUALS(error,KErrNone); + ASSERT_EQUALS(resolutionList1.Count(), resolutions); + + TDisplayConfiguration configBeforeDetach; + + // detach the display + interface->GetConfiguration(configBeforeDetach); + TInt displayState = EDisconnect; + UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL); + Pause(300); + + // retrieve the display configuration + interface->GetConfiguration(configBeforeDetach); + ASSERT_FALSE(configBeforeDetach.IsDefined(TDisplayConfiguration::EResolutionTwips)); + + error = interface->GetResolutions(resolutionList1); + ASSERT_EQUALS(error,KErrDisconnected); + + configBeforeDetach.ClearAll(); + + screenModeList.Close(); + resolutionList1.Close(); + + displayState = ENormalResolution; + UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL); +#endif + } + +/** +@SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0014L +@SYMTestCaseDesc Test GetConfiguration immediatly after SetConfiguration +@SYMREQ REQ10328 +@SYMPREQ PREQ2102 +@SYMTestType CT +@SYMTestPurpose Make sure the twips size is buffered so immediate GetConfiguration can get correct twip size +@SYMTestActions + successive SetConfiguration/GetConfiguration pair +@SYMTestExpectedResults + all tests should pass +*/ +void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0014L() + { + MDisplayControl* interface = static_cast + (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); + ASSERT_TRUE(interface); + + RArray resolutions; + TInt err = interface->GetResolutions(resolutions); + ASSERT_EQUALS(err, KErrNone); + TDisplayConfiguration configSet, configGet; + TSize twipsGet, resolutionGet; + + TInt screenNo = iScreenDevice->GetScreenNumber(); + iSession.SetFocusScreen(TGlobalSettings::Instance().iScreen); + for(TInt testIndex = 0; testIndex < 2; testIndex++) + {//run twice +#ifdef MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER + INFO_PRINTF1(_L("Test not compiled because MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER")); +#else + TInt displayState; + displayState = ENormalResolution; + UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL); +#endif + for (TInt i=0;iSetConfiguration(configSet); + if(err != KErrNone) + { + //with scaling, KErrArgument means current config is not compatible with appmode. + //In none scaling, it does mean an error, + //but the purpose of this test is to see if twips size is buffered so we can read it back instantly + //let other tests test the functionality of SetConfiguration. + ASSERT_EQUALS(err, KErrArgument); + + INFO_PRINTF1(_L("this configuration is not compatible with current appmode, skip")); + continue; + } + interface->GetConfiguration(configGet); + ASSERT_TRUE(configGet.IsDefined(TDisplayConfigurationBase::EResolutionTwips)); + ASSERT_TRUE(configGet.IsDefined(TDisplayConfigurationBase::EResolution)); + configGet.GetResolutionTwips(twipsGet); + configGet.GetResolution(resolutionGet); + INFO_PRINTF3(_L("resolution readback: %i x %i"), resolutionGet.iWidth, resolutionGet.iHeight); + INFO_PRINTF3(_L("twips readback: %i x %i"), twipsGet.iWidth, twipsGet.iHeight); + ASSERT_EQUALS(twipsGet, resolutions[i].iTwipsSize); + Pause(300); + } +#ifdef MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER + INFO_PRINTF1(_L("Test not compiled because MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER")); +#else + displayState = EDisconnect; + UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL); +#endif + } + resolutions.Close(); + + } + +/** +@SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0015L +@SYMTestCaseDesc No Scaling doesnt return virtual resolutions +@SYMREQ REQ10336 +@SYMPREQ PREQ2102 +@SYMTestType CT +@SYMTestPriority 1 +@SYMTestPurpose no scaling should mean basic resolution selection +@SYMTestActions + Get resolution list + Should not contain virtual resolutions + Set every app mode + Should not change resolution +@SYMTestExpectedResults + All test should pass + **SENSITIVE TO CHANGES IN EPOC.INI and WSINI.INI** +*/ +void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0015L() + { //ONLY RUN WITH 'NO SCALING' WSINI.INI, can be found in resources + MDisplayControl* interface = static_cast + (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); + ASSERT_TRUE(interface); + + TInt resolutions = interface->NumberOfResolutions(); + TInt screenNumber = iScreenDevice->GetScreenNumber(); + if (screenNumber == 0) + { + ASSERT_EQUALS(resolutions,1); + } + else if (screenNumber == 1) + { + ASSERT_EQUALS(resolutions,4); + } + + RArray resolutionList1; + TInt error = interface->GetResolutions(resolutionList1); + ASSERT_EQUALS(error,KErrNone); + ASSERT_EQUALS(resolutionList1.Count(), resolutions); + + RArray screenModeList; + iInfoScreenDevice->GetScreenSizeModeList(&screenModeList); + + TDisplayConfiguration dispConfig1; + interface->GetConfiguration(dispConfig1); + TSize size1; + ASSERT_TRUE(dispConfig1.GetResolution(size1)); + + for (TInt ii = 0; ii < screenModeList.Count(); ii++) + { + iInfoScreenDevice->SetAppScreenMode(screenModeList[ii]); + iInfoScreenDevice->SetScreenMode(screenModeList[ii]); + iSession.Finish(ETrue); + Pause(300); + + TDisplayConfiguration newConfig; + interface->GetConfiguration(newConfig); + TSize newSize; + ASSERT_TRUE(dispConfig1.GetResolution(newSize)); + ASSERT_EQUALS(size1,newSize); + } + iInfoScreenDevice->SetAppScreenMode(screenModeList[0]); + iInfoScreenDevice->SetScreenMode(screenModeList[0]); + iSession.Finish(ETrue); + Pause(300); + + screenModeList.Close(); + resolutionList1.Close(); + } + +/** +@SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0016L +@SYMTestCaseDesc Anisotropic scaling +@SYMREQ REQ10336 +@SYMPREQ PREQ2102 +@SYMTestType CT +@SYMTestPriority 1 +@SYMTestPurpose Check using twips will cause virtual resolutions to possibly be different +@SYMTestActions + Check the virtual resolution for XXX is correctly XXX + Check when setting the appmode, it choses the correct resolution +@SYMTestExpectedResults + Tests should pass + **SENSITIVE TO CHANGES IN EPOC.INI and WSINI.INI** +*/ +void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0016L() + { //ONLY RUN WITH ANISOTROPIC WSINI.INI + + } + +/** +@SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0017L +@SYMTestCaseDesc Integer scales correctly in policy +@SYMREQ REQ10336 +@SYMPREQ PREQ2102 +@SYMTestType CT +@SYMTestPriority 1 +@SYMTestPurpose Integer scaling should not create resolutions of non integer value! +@SYMTestActions + For every virtual resolution + Check its an integer size of a real resolution +@SYMTestExpectedResults + All should be integers (1:1 , 1:2 , 1:3 or 1:4 in current policy) + **NOTE ONLY RUN WITH INTEGER WSINI.INI** +*/ +void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0017L() + { //ONLY RUN WITH INTEGER WSINI.INI + MDisplayControl* interface = static_cast + (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); + ASSERT_TRUE(interface); + + TInt resolutions = interface->NumberOfResolutions(); + ASSERT_TRUE(resolutions>1); + + RArray resolutionList1; + TInt error = interface->GetResolutions(resolutionList1); + ASSERT_EQUALS(error,KErrNone); + ASSERT_EQUALS(resolutionList1.Count(), resolutions); + + TInt index; + for (index=0;index + (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); + ASSERT_TRUE(interface); + + MDisplayMapping* mapInterface = static_cast + (iScreenDevice->GetInterface(MDisplayMapping::ETypeId)); + ASSERT_TRUE(mapInterface); + + RArray screenModeList; + iInfoScreenDevice->GetScreenSizeModeList(&screenModeList); + + TRect maxWinExtent, refMaxWinExtent; + TSize surfaceSize, surfaceTwips, refSurfaceSize, refSurfaceTwips; + TRect displayWinExtent, refDisplayWinExtent; + for (TInt i = 0; i < screenModeList.Count(); i++) + { + iInfoScreenDevice->SetAppScreenMode(screenModeList[i]); + iInfoScreenDevice->SetScreenMode(screenModeList[i]); + iSession.Finish(ETrue); + Pause(300); + + INFO_PRINTF1(_L("---------------")); + INFO_PRINTF2(_L("screen mode : %i"), screenModeList[i]); + + mapInterface->GetMaximumWindowExtent(maxWinExtent); + INFO_PRINTF3(_L("MaximumWindowExtent Origin: (%i, %i)"), maxWinExtent.iTl.iX, maxWinExtent.iTl.iY); + INFO_PRINTF3(_L("MaximumWindowExtent Size: %i x %i"), maxWinExtent.Width(), maxWinExtent.Height()); + + + TDisplayConfiguration config; + interface->GetConfiguration(config); + ASSERT_TRUE(config.IsDefined(TDisplayConfigurationBase::EResolution)); + TSize fullUiSize; + config.GetResolution(fullUiSize); + error = mapInterface->MapCoordinates(EFullScreenSpace, fullUiSize, EApplicationSpace, refMaxWinExtent); + ASSERT_EQUALS(error, KErrNone); + INFO_PRINTF3(_L("ref MaximumWindowExtent Origin: (%i, %i)"), refMaxWinExtent.iTl.iX, refMaxWinExtent.iTl.iY); + INFO_PRINTF3(_L("ref MaximumWindowExtent Size: %i x %i"), refMaxWinExtent.Width(), refMaxWinExtent.Height()); + ASSERT_EQUALS(maxWinExtent, refMaxWinExtent); + INFO_PRINTF1(_L("Match")); + + mapInterface->GetMaximumSurfaceSize(surfaceSize, surfaceTwips); + INFO_PRINTF3(_L("MaxSurfaceSize: %i x %i"), surfaceSize.iWidth, surfaceSize.iHeight); + INFO_PRINTF3(_L("MaxSurfaceTwips: %i x %i"), surfaceTwips.iWidth, surfaceSize.iHeight); + TRect compositionRect; + error = mapInterface->MapCoordinates(EFullScreenSpace, fullUiSize, ECompositionSpace, compositionRect); + ASSERT_EQUALS(error, KErrNone); + refSurfaceSize = compositionRect.Size(); + INFO_PRINTF3(_L("RefSurfaceSize: %i x %i"), refSurfaceSize.iWidth, refSurfaceSize.iHeight); + ASSERT_TRUE(config.IsDefined(TDisplayConfigurationBase::EResolutionTwips)); + config.GetResolutionTwips(refSurfaceTwips); + INFO_PRINTF3(_L("RefSurfaceTwips: %i x %i"), refSurfaceTwips.iWidth, refSurfaceTwips.iHeight); + ASSERT_EQUALS(surfaceSize, refSurfaceSize); + ASSERT_EQUALS(surfaceTwips, refSurfaceTwips); + INFO_PRINTF1(_L("Match")); + + mapInterface->GetDisplayExtentOfWindow(iCompare, displayWinExtent); + INFO_PRINTF3(_L("DisplayWin origin: (%i, %i)"), displayWinExtent.iTl.iX, displayWinExtent.iTl.iY); + INFO_PRINTF3(_L("DisplayWin Size: (%i x %i"), displayWinExtent.Width(), displayWinExtent.Height()); + error = mapInterface->MapCoordinates(EApplicationSpace, TRect(TPoint(iCompare.AbsPosition()),iCompare.Size()), ECompositionSpace, refDisplayWinExtent); + ASSERT_EQUALS(error, KErrNone); + INFO_PRINTF3(_L("RefDisplayWin origin: (%i, %i)"), refDisplayWinExtent.iTl.iX, refDisplayWinExtent.iTl.iY); + INFO_PRINTF3(_L("RefDisplayWin Size: (%i x %i"), refDisplayWinExtent.Width(), refDisplayWinExtent.Height()); + ASSERT_EQUALS(displayWinExtent, refDisplayWinExtent); + INFO_PRINTF1(_L("Match")); + } + iInfoScreenDevice->SetAppScreenMode(screenModeList[0]); + iInfoScreenDevice->SetScreenMode(screenModeList[0]); + screenModeList.Close(); + } + +/* +@SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0021L +@SYMTestCaseDesc SetResolution negative test +@SYMREQ REQ10326 +@SYMPREQ PREQ2102 +@SYMTestType CT +@SYMTestPriority 1 +@SYMTestPurpose Invalid configurations should return error and change nothing! +@SYMTestActions + Set config with rubbish resolution + Set config with rubbish twips + Set config with valid resolution, rubbish twips + Set config with valid twips, rubbish resolution + Set config with nothing defined +@SYMTestExpectedResults + Should all fail safely and not change any settings. + Config with nothing defined in a scaled mode will reset the resolution to current modes + equivilent virtual resolution + **NOTE ONLY RUN IN SCREEN 1 - we need multiple resolutions available** +*/ +void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0021L(TBool aScaleMode) + { //aScaleMode 0 = no scaling, 1 = integer,isotropic or anisotropic + MDisplayControl* interface = static_cast + (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); + ASSERT_TRUE(interface); + + TInt resolutions = interface->NumberOfResolutions(); + ASSERT_TRUE (resolutions > 1); + + RArray resolutionList1; + TInt error = interface->GetResolutions(resolutionList1); + ASSERT_EQUALS(resolutionList1.Count(), resolutions); + + TDisplayConfiguration original; + original.SetResolution(resolutionList1[0].iPixelSize); + error = interface->SetConfiguration(original); + ASSERT_EQUALS(error,KErrNone); + + TDisplayConfiguration beforeConfig; + TDisplayConfiguration afterConfig; + interface->GetConfiguration(beforeConfig); + + TInt differentRes; + for (differentRes = 1; differentRes < resolutions; differentRes++) + { + if (!(resolutionList1[differentRes].iPixelSize == resolutionList1[0].iPixelSize)) + { + break; + } + } + ASSERT_TRUE(differentRes < resolutions); //otherwise it didnt find a resolution different to the one set + + TDisplayConfiguration test1; + test1.SetResolution(TSize(5,6)); //rubbish resolution! + error = interface->SetConfiguration(test1); + + ASSERT_EQUALS(error,KErrArgument); + + ASSERT_EQUALS(error,KErrArgument); + iSession.Flush(); + interface->GetConfiguration(afterConfig); + ASSERT_TRUE(beforeConfig == afterConfig); + + TDisplayConfiguration test2; + test2.SetResolutionTwips(TSize(7,8)); //rubbish twips! + error = interface->SetConfiguration(test2); + ASSERT_EQUALS(error,KErrArgument); + iSession.Flush(); + interface->GetConfiguration(afterConfig); + ASSERT_TRUE(beforeConfig == afterConfig); + + TDisplayConfiguration test3; + test3.SetResolution(resolutionList1[differentRes].iPixelSize); //ok resolution! + test3.SetResolutionTwips(TSize(9,10)); //rubbish twips! + error = interface->SetConfiguration(test3); + //ASSERT_EQUALS(error,KErrArgument); + if (error != KErrArgument) + { + ASSERT_EQUALS (aScaleMode,0); //if no policy, we currently have issue with confing not being validated + INFO_PRINTF1(_L("config was not honoured!")); + error = interface->SetConfiguration(original); + ASSERT_EQUALS(error,KErrNone); + iSession.Flush(); + Pause(200); + } + else + { + iSession.Flush(); + Pause(200); + interface->GetConfiguration(afterConfig); + ASSERT_TRUE(beforeConfig == afterConfig); + } + + TDisplayConfiguration test4; + test4.SetResolution(TSize(11,12)); //rubbish resolution! + test4.SetResolutionTwips(resolutionList1[differentRes].iTwipsSize); //ok twips! + error = interface->SetConfiguration(test4); + if (error != KErrArgument) + { + ASSERT_EQUALS (aScaleMode,0); //if no policy, we currently have issue with config not being validated + INFO_PRINTF1(_L("config was not honoured!")); + error = interface->SetConfiguration(original); + ASSERT_EQUALS(error,KErrNone); + iSession.Flush(); + Pause(200); + } + else + { + iSession.Flush(); + Pause(200); + interface->GetConfiguration(afterConfig); + ASSERT_TRUE(beforeConfig == afterConfig); + } + + if (aScaleMode) + { + RArray screenModeList; + iInfoScreenDevice->GetScreenSizeModeList(&screenModeList); + ASSERT_TRUE(screenModeList.Count()>1); + //set default screen mode, sets resolution to best fit for this mode + iInfoScreenDevice->SetAppScreenMode(screenModeList[0]); + iInfoScreenDevice->SetScreenMode(screenModeList[0]); //also sets its best resolution + iSession.Finish(ETrue); + Pause(200); + + TDisplayConfiguration newModeConfig; + interface->GetConfiguration(newModeConfig); + //get best fit resolution + TSize newModeRes; + ASSERT_TRUE(newModeConfig.GetResolution(newModeRes)); + + //find a different resolution + TInt i; + for (i = 0; i < resolutions; i++) + { + if (!(resolutionList1[i].iPixelSize == newModeRes)) + { + break; + } + } + ASSERT_TRUE(i < resolutions); //otherwise it didnt find a resolution different to the one set + TDisplayConfiguration newSetConfig; + + //set the different resolution + newSetConfig.SetResolution(resolutionList1[i].iPixelSize); + error = interface->SetConfiguration(newSetConfig); + ASSERT_TRUE(error == KErrNone); + iSession.Flush(); + Pause(200); + TDisplayConfiguration checkConfig; + + //check its set this new resolution + interface->GetConfiguration(checkConfig); + TSize checkSize; + checkConfig.GetResolution(checkSize); + ASSERT_TRUE (checkSize == resolutionList1[i].iPixelSize); + + TDisplayConfiguration emptyConfig; + TDisplayConfiguration newModeConfig2(newModeConfig); + newModeConfig2.Clear(newModeConfig2.EResolutionTwips); + //set empty config, which should reset resolution to current modes default + error = interface->SetConfiguration(emptyConfig);//emptyConfig); + ASSERT_TRUE(error == KErrNone); + iSession.Finish(); + Pause(200); + + interface->GetConfiguration(checkConfig); + ASSERT_TRUE (newModeConfig == checkConfig); //empty config reset res to modes default res + + screenModeList.Close(); + } + else + { + TDisplayConfiguration test5; + error = interface->SetConfiguration(test5); + ASSERT_EQUALS(error,KErrArgument); + } + resolutionList1.Close(); + } + +/** +@SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0031L +@SYMTestCaseDesc SetConfiguration in OOM (changing resolution) +@SYMREQ REQ10326 +@SYMPREQ PREQ2102 +@SYMTestType CT +@SYMTestPriority 1 +@SYMTestPurpose Safety check against OOM +@SYMTestActions + Set OOM failure + Set a resolution that will definately cause a change of resolution + Increase length of time to failure, repeat + Finish after 5 successful changes of resolution +@SYMTestExpectedResults + Set resolution should either return a fail and not have cause a change in resolution, + or it should have returned no fail and have set the new resolution +*/ +void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0031L() + { + MDisplayControl* interface = static_cast + (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); + ASSERT_TRUE(interface); + INFO_PRINTF1(_L("Interface obtained sucessfully.")); + + TInt resolutions = interface->NumberOfResolutions(); + ASSERT_TRUE (resolutions > 0); + INFO_PRINTF1(_L("NumberOfResolutions obtained sucessfully.")); + + RArray resolutionList1; + TInt error = interface->GetResolutions(resolutionList1); + ASSERT_EQUALS(error,KErrNone); + ASSERT_EQUALS(resolutionList1.Count(), resolutions); + INFO_PRINTF1(_L("resolutionList1 has correct number of resolutions.")); + + TInt index; + TDisplayConfiguration dispConfigBefore; + TDisplayConfiguration dispConfigAfter; + + dispConfigBefore.SetResolution(resolutionList1[0].iPixelSize); + interface->SetConfiguration(dispConfigBefore); + interface->GetConfiguration(dispConfigBefore); + ASSERT_TRUE(dispConfigBefore.IsDefined(dispConfigBefore.EResolution)); + INFO_PRINTF1(_L("dispConfigBefore is defined.")); + TSize dispResBefore; + TSize dispResAfter; + dispConfigBefore.GetResolution(dispResBefore); + TDisplayConfiguration::TRotation dispRotBefore; + TDisplayConfiguration::TRotation dispRotReq; + dispConfigBefore.GetRotation(dispRotBefore); + + for (index = 0; index < resolutionList1.Count(); index++) + { + INFO_PRINTF2(_L("Starting resolution %d."), index); + if (resolutionList1[index].iPixelSize.iWidth == 0) + { + continue; + } + TInt heapFail = 1; + TBool notComplete = ETrue; + TInt completeCount = 0; + while (notComplete) + { + TDisplayConfiguration dispConfigReq; + dispConfigReq.SetResolution(resolutionList1[index].iPixelSize); + ASSERT_TRUE(dispConfigReq.IsDefined(dispConfigReq.EResolution)); + SetRotation(dispConfigReq,resolutionList1[index]); //set rotation to first defined in res list + dispConfigReq.GetRotation(dispRotReq); + INFO_PRINTF2(_L("Before heap failure, value of heapfail is %d."), heapFail); + + iSession.Finish(ETrue); + iSession.HeapSetFail(RHeap::EDeterministic,heapFail); + TInt errCode=interface->SetConfiguration(dispConfigReq); + iSession.HeapSetFail(RHeap::ENone,0); + INFO_PRINTF1(_L("After Heap Failure.")); + iSession.Finish(ETrue); + Pause (100); + INFO_PRINTF1(_L("After Session Finish.")); + + interface->GetConfiguration(dispConfigAfter); + ASSERT_TRUE(dispConfigAfter.IsDefined(dispConfigAfter.EResolution)); + dispConfigAfter.GetResolution(dispResAfter); + + TBool worked = ETrue; + if (errCode < KErrNone) + { + worked = EFalse; + ASSERT_EQUALS(dispResAfter,dispResBefore); + if (dispRotReq != dispRotBefore) + { //didnt expect it work-KErrGeneral can mean a memory allocation fail + if (errCode == KErrArgument) + { //if it didnt panic, that is a good enough pass in this instance + worked = ETrue; + } + } + } + else + { + ASSERT_EQUALS(dispResAfter,resolutionList1[index].iPixelSize); + } + if (worked) + { + completeCount++; + if (completeCount == 5) + { + notComplete = EFalse; + } + } + else + { + completeCount = 0; + } + interface->SetConfiguration(dispConfigBefore); + INFO_PRINTF1(_L("After Setting Original Configuration.")); + heapFail++; + if (heapFail == 80) + { + ASSERT_TRUE(0); //worrying amount of fails + } + } + } + resolutionList1.Close(); + } + +/** +@SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0032L +@SYMTestCaseDesc SetAppMode in OOM +@SYMREQ REQ10326 REQ10336 +@SYMPREQ PREQ2102 +@SYMTestType CT +@SYMTestPriority 1 +@SYMTestPurpose Safety check against OOM +@SYMTestActions + Set OOM failure + Set new app mode + Increase length of time to failure, repeat + Finish after 5 successful changes of mode +@SYMTestExpectedResults + SetAppMode should either return a fail and not have cause a change in resolution, + or it should have returned no fail and have set the new resolution +*/ +void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0032L() + { + MDisplayControl* interface = static_cast + (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); + ASSERT_TRUE(interface); + + TInt resolutions = interface->NumberOfResolutions(); + ASSERT_TRUE (resolutions > 0); + RArray screenModeList; + iInfoScreenDevice->GetScreenSizeModeList(&screenModeList); + ASSERT_TRUE (screenModeList.Count()>0); + + iInfoScreenDevice->SetAppScreenMode(screenModeList[0]); + iInfoScreenDevice->SetScreenMode(screenModeList[0]); + + for (TInt index = 1; index < screenModeList.Count(); index++) + { //skip index 0, as that wouldn't be changing mode + TInt heapFail = 1; + TBool notComplete = ETrue; + TInt completeCount = 0; + while (notComplete) + { + iInfoScreenDevice->SetAppScreenMode(screenModeList[index]); + iSession.Finish(ETrue); + iSession.HeapSetFail(RHeap::EDeterministic,heapFail); + iInfoScreenDevice->SetScreenMode(screenModeList[index]); + iSession.HeapSetFail(RHeap::ENone,0); + iSession.Finish(ETrue); + Pause(50); + TInt newMode = iInfoScreenDevice->CurrentScreenMode(); + + if (screenModeList[index] == newMode) + { + completeCount++; + if (completeCount == 5) + { + INFO_PRINTF2(_L("Succeeded with heapFail = %d"),heapFail); + notComplete = EFalse; + } + iInfoScreenDevice->SetAppScreenMode(screenModeList[0]); + iInfoScreenDevice->SetScreenMode(screenModeList[0]); + iSession.Finish(ETrue); + Pause(50); + } + else + { + completeCount = 0; + } + heapFail++; + if (heapFail == 80) + { + ASSERT_TRUE(0); //worrying amount of fails + } + } + } + screenModeList.Close(); + } + +/** +@SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0033L +@SYMTestCaseDesc GetConfiguration in OOM +@SYMREQ REQ10328 +@SYMPREQ PREQ2102 +@SYMTestType CT +@SYMTestPriority 1 +@SYMTestPurpose Safety check against OOM +@SYMTestActions + Set OOM failure + GetConfiguration + Check config + Increase time till failure + Success after 5 completed gets +@SYMTestExpectedResults + Should always succeed +*/ +void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0033L() + { + MDisplayControl* interface = static_cast + (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); + ASSERT_TRUE(interface); + + TInt heapFail = 1; + for (TInt i=0;i<5;i++) + { + TDisplayConfiguration config; + iSession.Finish(ETrue); + iSession.HeapSetFail(RHeap::EDeterministic,heapFail); + interface->GetConfiguration(config); + iSession.HeapSetFail(RHeap::ENone,0); + iSession.Finish(ETrue); + ASSERT_TRUE(config.IsDefined(config.ERotation)); + ASSERT_TRUE(config.IsDefined(config.EResolution)); + ASSERT_TRUE(config.IsDefined(config.EResolutionTwips)); + heapFail++; + } + } + +/** +@SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0034L +@SYMTestCaseDesc GetResolutions in OOM +@SYMREQ REQ10328 +@SYMPREQ PREQ2102 +@SYMTestType CT +@SYMTestPriority 1 +@SYMTestPurpose Safety check against OOM +@SYMTestActions + Set OOM failure + GetResolutions + Check resolutions filled in + Success after 5 completed gets +@SYMTestExpectedResults + Should never panic! +*/ +void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0034L() + { + MDisplayControl* interface = static_cast + (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); + ASSERT_TRUE(interface); + + TInt resolutions = interface->NumberOfResolutions(); + ASSERT_TRUE(resolutions>1); + + RArray resolutionList1; + TInt error = interface->GetResolutions(resolutionList1); + ASSERT_EQUALS(error,KErrNone); + ASSERT_TRUE(resolutionList1.Count() > 0); + + TInt heapFail = 1; + TInt completeCount = 0; + TBool notComplete = ETrue; + while (notComplete) + { + RArray resolutionList2; + iSession.Finish(ETrue); + iSession.HeapSetFail(RHeap::EDeterministic,heapFail); + error = interface->GetResolutions(resolutionList2); + iSession.HeapSetFail(RHeap::ENone,0); + iSession.Finish(ETrue); + if (errorSizeInPixels()); + screenSize.Shrink(5,5); + + RBlankWindow testWindow; + if (iInfoGc) + { + testWindow=RBlankWindow(iSession); + ASSERT_EQUALS(testWindow.Construct(*iInfoGroup, ++iWindowHandle), KErrNone); + testWindow.SetColor(iBlue); + testWindow.SetExtent(screenSize.iTl,screenSize.Size()); + testWindow.Activate(); + + if (testWindow.WsHandle()) + { + iSession.Flush(); + iSession.Finish(); + } + testWindow.SetVisible(ETrue); + } + + iSession.Finish(ETrue); + + RArray screenModeList; + iInfoScreenDevice->GetScreenSizeModeList(&screenModeList); + MDisplayControl* interface = static_cast + (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); + ASSERT_TRUE(interface); + + TInt resolutions = interface->NumberOfResolutions(); + ASSERT_TRUE (resolutions > 0); + + RArray resolutionList1; + error = interface->GetResolutions(resolutionList1); + ASSERT_EQUALS(error,KErrNone); + ASSERT_EQUALS(resolutionList1.Count(), resolutions); + + TDisplayConfiguration dispConfigBefore; + interface->GetConfiguration(dispConfigBefore); + ASSERT_TRUE(dispConfigBefore.IsDefined(dispConfigBefore.EResolution)) + if (screenModeList.Count()>1) + { + //Got a mode to change to! + TSize resBefore; + TBool ok=dispConfigBefore.GetResolution(resBefore); + ASSERT_TRUE(ok); //we "know" this should be ok, as we just asserted the flag + for (TInt res=0;resSetAppScreenMode(screenModeList[res]); + iInfoScreenDevice->SetScreenMode(screenModeList[res]); + iSession.Finish(ETrue); + Pause(300); + + + TSize pr = iInfoScreenDevice->SizeInPixels(); + TPoint origin=iInfoScreenDevice->GetDefaultScreenModeOrigin(); + Pause(300); + TSize winpos; + + TSize surfaceSize = pr; + surfaceSize.iWidth /= 2; + surfaceSize.iWidth -= 20; + surfaceSize.iHeight -= 20; + TSurfaceId surfaceID; + TRAPD(err, surfaceID = iUtility->CreateSurfaceL(surfaceSize, + KSurfaceFormat, surfaceSize.iWidth * KBytesPerPixel)); + ASSERT_EQUALS(err,KErrNone); + TRAP(err,iUtility->PatternFillSurfaceL(surfaceID)); + ASSERT_EQUALS(err,KErrNone); + + CFbsBitmap* equivalentBitmap=NULL; + TRAP(err,equivalentBitmap=iUtility->EquivalentBitmapL(surfaceID)); + CleanupStack::PushL(equivalentBitmap); + ASSERT_EQUALS(err,KErrNone); + + screenSize = iInfoScreenDevice->SizeInPixels(); + TSize testSize = iScreenDevice->SizeInPixels(); + screenSize.Shrink(5,5); + + if (iInfoGc) + { + testWindow.SetExtent(screenSize.iTl,screenSize.Size()); + + if (testWindow.WsHandle()) + { + + iSession.Flush(); + iSession.Finish(); + } + testWindow.SetVisible(ETrue); + } + Pause(200); + iSession.Finish(ETrue); + + RWindow surfWindow; + if (iInfoGc) + { + surfWindow=RWindow(iSession); + ASSERT_EQUALS(surfWindow.Construct(*iInfoGroup, ++iWindowHandle), KErrNone); + surfWindow.SetBackgroundSurface(surfaceID); + surfWindow.SetExtent(screenSize.iTl+TPoint( screenSize.Width()/2 +5,5),surfaceSize); + surfWindow.Activate(); + + if (surfWindow.WsHandle()) + { + surfWindow.Invalidate(); + + surfWindow.BeginRedraw(); + ActivateWithWipe(iInfoGc,surfWindow,iRed); + surfWindow.EndRedraw(); + + iSession.Flush(); + iSession.Finish(); + } + surfWindow.SetVisible(ETrue); + iInfoGc->Deactivate(); + } + + iSession.Finish(ETrue); + + TRect bitmapDrawRect; + bitmapDrawRect = surfaceSize; + + RWindow bmpWindow; + if (iInfoGc) + { + bmpWindow=RWindow(iSession); + ASSERT_EQUALS(bmpWindow.Construct(*iInfoGroup, ++iWindowHandle), KErrNone); + bmpWindow.SetBackgroundColor(iRed); + bmpWindow.SetExtent(screenSize.iTl+TPoint(5,5),surfaceSize); + bmpWindow.Activate(); + + if (bmpWindow.WsHandle()) + { + bmpWindow.Invalidate(); + + bmpWindow.BeginRedraw(); + ActivateWithWipe(iInfoGc,bmpWindow,iRed); + // Not drawing, draw twice?? + iInfoGc->DrawBitmap(bitmapDrawRect, equivalentBitmap); + bmpWindow.EndRedraw(); + + iSession.Flush(); + iSession.Finish(); + } + bmpWindow.SetVisible(ETrue); + iInfoGc->Deactivate(); + } + Pause(200); + iSession.Finish(ETrue); + + + if (iInfoGc) + { + + if (bmpWindow.WsHandle()) + { + bmpWindow.Invalidate(); + + bmpWindow.BeginRedraw(); + ActivateWithWipe(iInfoGc,bmpWindow,iRed); + // Not drawing, draw twice?? + iInfoGc->DrawBitmap(bitmapDrawRect, equivalentBitmap); + bmpWindow.EndRedraw(); + + iSession.Flush(); + iSession.Finish(); + } + bmpWindow.SetVisible(ETrue); + iInfoGc->Deactivate(); + } + Pause(200); + iSession.Finish(ETrue); + + if (iInfoGc) + { + + if (bmpWindow.WsHandle()) + { + bmpWindow.Invalidate(); + + bmpWindow.BeginRedraw(); + ActivateWithWipe(iInfoGc,bmpWindow,iRed); + // Not drawing, draw twice?? + iInfoGc->DrawBitmap(bitmapDrawRect, equivalentBitmap); + bmpWindow.EndRedraw(); + iSession.Flush(); + iSession.Finish(); + } + bmpWindow.SetVisible(ETrue); + iInfoGc->Deactivate(); + } + Pause(200); + iSession.Finish(ETrue); + + RArray regionArray; + + RRegion equivRegion; + TBitmapRegionPair bitmap1Region; + bitmap1Region.bitmap = equivalentBitmap; + bitmap1Region.drawRect = TRect(TPoint(0,0),surfaceSize); + equivRegion.AddRect(TRect(TPoint(0,0),surfaceSize)); + bitmap1Region.region = &equivRegion; + + regionArray.Append(bitmap1Region); + + + TDisplayConfiguration dispConfigAfter2; + interface->GetConfiguration(dispConfigAfter2); + TSize theSize; + dispConfigAfter2.GetResolution(theSize); + TDisplayConfiguration1::TRotation orient; + dispConfigAfter2.GetRotation(orient); + if (orient == TDisplayConfiguration1::ERotation90CW || orient == TDisplayConfiguration1::ERotation270CW) + { + TInt temp = theSize.iHeight; + theSize.iHeight = theSize.iWidth; + theSize.iWidth = temp; + } + TRect uiSize(TPoint(0,0), theSize); + MDisplayMapping* mappingInterface = static_cast + (iScreenDevice->GetInterface(MDisplayMapping::ETypeId)); + ASSERT_TRUE(mappingInterface); + TRect finalSize; + mappingInterface->MapCoordinates(EApplicationSpace, uiSize, ECompositionSpace, finalSize); + + + CFbsBitmap* bmp2 = new (ELeave) CFbsBitmap; + CleanupStack::PushL(bmp2); + User::LeaveIfError(bmp2->Create(finalSize.Size(), EColor16MU)); + + MTestScreenCapture + * csc = + static_cast (iScreenDevice->GetInterface(MTestScreenCapture::KUidTestScreenCaptureIf)); + if (csc) + { + TInt errr = csc->ComposeScreen(*bmp2); + ASSERT_TRUE(errr == KErrNone); + } + else + { + if (!cSCLogged) + { + cSCLogged = ETrue; + _LIT(KNoCSC, "CSC testing not enabled as CSC render stage not defined"); + Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrAll, KNoCSC); + } + } + + + TRect compareRect(bmpWindow.AbsPosition(), bmpWindow.Size()); + TRect testRect(surfWindow.AbsPosition(), surfWindow.Size()); + + if (csc) + { + if(!Compare(*bmp2, compareRect, testRect, regionArray, aIsSurface)) + { + _LIT(KCompareFailed, "Compare Failed on app mode: %d"); + TBuf<256> x; + x.Format(KCompareFailed, res+1); + Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x); + } + } + + CleanupStack::PopAndDestroy(bmp2); + + equivRegion.Close(); + regionArray.Close(); + + CleanupStack::PopAndDestroy(equivalentBitmap); + surfWindow.Close(); + bmpWindow.Close(); + } + } + } + //restore initial res + if (screenModeList.Count() > 1) + { //set back to basics + iInfoScreenDevice->SetAppScreenMode(screenModeList[0]); + iInfoScreenDevice->SetScreenMode(screenModeList[0]); + Pause(300); + } + + interface->SetConfiguration(dispConfigBefore); + Pause(1000); + TDisplayConfiguration dispConfigAfter; + interface->GetConfiguration(dispConfigAfter); + TSize resAfter; + ok=dispConfigAfter.GetResolution(resAfter); + ASSERT_TRUE(ok); + ASSERT_EQUALS(resBefore,resAfter); + } + else + { + INFO_PRINTF1(_L("Only 1 screen size mode configured on this screen - res change test skipped.")); + } + testWindow.Close(); + screenModeList.Close(); + resolutionList1.Close(); + } + + +/** +@SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0042L +@SYMTestCaseDesc Test Drawing of bitmaps (case 0) and surfaces (case 1) in all different resolutions +@SYMREQ REQ10332 +@SYMPREQ PREQ2102 +@SYMTestType CT +@SYMTestPurpose Check to see if Bitmaps and Surfaces are drawn correctly in different resolutions +@SYMTestActions + A Simple pattern will be drawn by a bitmap on the left and a surface on the right, about half the window size each. The Composited Screen Capture code will be used to compare the drawing to a unchanged copy of the bitmap to see if they are drawn correctly + + Note, add .0 to test name to test bitmap drawing and .1 to test surface drawing +@SYMTestExpectedResults + All tests should pass. + +*/ +void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0042L(TBool aIsSurface) + { + LOG_AND_PANIC_IF_NOT_GCE; + ResetScreens(); + TInt error; + iSession.Finish(ETrue); + + TRect screenSize(iInfoScreenDevice->SizeInPixels()); + screenSize.Shrink(5,5); + + RBlankWindow testWindow; + if (iInfoGc) + { + testWindow=RBlankWindow(iSession); + ASSERT_EQUALS(testWindow.Construct(*iInfoGroup, ++iWindowHandle), KErrNone); + testWindow.SetColor(iBlue); + testWindow.SetExtent(screenSize.iTl,screenSize.Size()); + testWindow.Activate(); + + if (testWindow.WsHandle()) + { + iSession.Flush(); + iSession.Finish(); + } + testWindow.SetVisible(ETrue); + } + + iSession.Finish(ETrue); + + RArray screenModeList; + iInfoScreenDevice->GetScreenSizeModeList(&screenModeList); + MDisplayControl* interface = static_cast + (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); + ASSERT_TRUE(interface); + + TInt resolutions = interface->NumberOfResolutions(); + ASSERT_TRUE (resolutions > 0); + + RArray resolutionList1; + error = interface->GetResolutions(resolutionList1); + ASSERT_EQUALS(error,KErrNone); + ASSERT_EQUALS(resolutionList1.Count(), resolutions); + + TDisplayConfiguration dispConfigBefore; + interface->GetConfiguration(dispConfigBefore); + + iInfoScreenDevice->SetAppScreenMode(screenModeList[1]); + iInfoScreenDevice->SetScreenMode(screenModeList[1]); + iSession.Finish(); + Pause(50); + + if (resolutions>1) + { + //Got a mode to change to! + TSize resBefore; + TBool ok=dispConfigBefore.GetResolution(resBefore); + ASSERT_TRUE(ok); //we "know" this should be ok, as we just asserted the flag + for (TInt res=0;resSetConfiguration(dispConfigReq); + //ASSERT_EQUALS(errCode,KErrNone); + if (errCode != KErrNone) + { + //Probably current size mode does not support the rotation of the passed in configuration + + ASSERT_EQUALS(errCode,KErrArgument); //failed to find compatible res in the policy + continue; + } + + + TSize pr = iInfoScreenDevice->SizeInPixels(); + TPoint origin=iInfoScreenDevice->GetDefaultScreenModeOrigin(); + Pause(300); + TSize winpos; + + TSize surfaceSize = pr; + surfaceSize.iWidth /= 2; + surfaceSize.iWidth -= 20; + surfaceSize.iHeight -= 20; + TSurfaceId surfaceID; + TRAPD(err, surfaceID = iUtility->CreateSurfaceL(surfaceSize, + KSurfaceFormat, surfaceSize.iWidth * KBytesPerPixel)); + ASSERT_EQUALS(err,KErrNone); + TRAP(err,iUtility->PatternFillSurfaceL(surfaceID)); + ASSERT_EQUALS(err,KErrNone); + + CFbsBitmap* equivalentBitmap=NULL; + TRAP(err,equivalentBitmap=iUtility->EquivalentBitmapL(surfaceID)); + CleanupStack::PushL(equivalentBitmap); + ASSERT_EQUALS(err,KErrNone); + + screenSize = iInfoScreenDevice->SizeInPixels(); + screenSize.Shrink(5,5); + + if (iInfoGc) + { + testWindow.SetExtent(screenSize.iTl,screenSize.Size()); + + if (testWindow.WsHandle()) + { + + iSession.Flush(); + iSession.Finish(); + } + testWindow.SetVisible(ETrue); + } + Pause(200); + iSession.Finish(ETrue); + + RWindow surfWindow; + if (iInfoGc) + { + surfWindow=RWindow(iSession); + ASSERT_EQUALS(surfWindow.Construct(*iInfoGroup, ++iWindowHandle), KErrNone); + surfWindow.SetBackgroundSurface(surfaceID); + surfWindow.SetExtent(screenSize.iTl+TPoint( screenSize.Width()/2 +5,5),surfaceSize); + surfWindow.Activate(); + + if (surfWindow.WsHandle()) + { + surfWindow.Invalidate(); + + surfWindow.BeginRedraw(); + ActivateWithWipe(iInfoGc,surfWindow,iRed); + surfWindow.EndRedraw(); + + iSession.Flush(); + iSession.Finish(); + } + surfWindow.SetVisible(ETrue); + iInfoGc->Deactivate(); + } + + iSession.Finish(ETrue); + + TRect bitmapDrawRect; + bitmapDrawRect = surfaceSize; + + RWindow bmpWindow; + if (iInfoGc) + { + bmpWindow=RWindow(iSession); + ASSERT_EQUALS(bmpWindow.Construct(*iInfoGroup, ++iWindowHandle), KErrNone); + bmpWindow.SetBackgroundColor(iRed); + bmpWindow.SetExtent(screenSize.iTl+TPoint(5,5),surfaceSize); + bmpWindow.Activate(); + + if (bmpWindow.WsHandle()) + { + bmpWindow.Invalidate(); + + bmpWindow.BeginRedraw(); + ActivateWithWipe(iInfoGc,bmpWindow,iRed); + // Not drawing, draw twice?? + iInfoGc->DrawBitmap(bitmapDrawRect, equivalentBitmap); + bmpWindow.EndRedraw(); + + iSession.Flush(); + iSession.Finish(); + } + bmpWindow.SetVisible(ETrue); + iInfoGc->Deactivate(); + } + Pause(200); + iSession.Finish(ETrue); + + + if (iInfoGc) + { + + if (bmpWindow.WsHandle()) + { + bmpWindow.Invalidate(); + + bmpWindow.BeginRedraw(); + ActivateWithWipe(iInfoGc,bmpWindow,iRed); + // Not drawing, draw twice?? + iInfoGc->DrawBitmap(bitmapDrawRect, equivalentBitmap); + bmpWindow.EndRedraw(); + + iSession.Flush(); + iSession.Finish(); + } + bmpWindow.SetVisible(ETrue); + iInfoGc->Deactivate(); + } + Pause(200); + iSession.Finish(ETrue); + + + + + RArray regionArray; + + RRegion equivRegion; + TBitmapRegionPair bitmap1Region; + bitmap1Region.bitmap = equivalentBitmap; + bitmap1Region.drawRect = TRect(TPoint(0,0),surfaceSize); + equivRegion.AddRect(TRect(TPoint(0,0),surfaceSize)); + bitmap1Region.region = &equivRegion; + + regionArray.Append(bitmap1Region); + + + TDisplayConfiguration dispConfigAfter2; + interface->GetConfiguration(dispConfigAfter2); + TSize theSize; + dispConfigAfter2.GetResolution(theSize); + TDisplayConfiguration1::TRotation orient; + dispConfigAfter2.GetRotation(orient); + if (orient & 0x1) + { + TInt temp = theSize.iHeight; + theSize.iHeight = theSize.iWidth; + theSize.iWidth = temp; + } + TRect uiSize(TPoint(0,0), theSize); + MDisplayMapping* mappingInterface = static_cast + (iScreenDevice->GetInterface(MDisplayMapping::ETypeId)); + ASSERT_TRUE(mappingInterface); + TRect finalSize; + mappingInterface->MapCoordinates(EApplicationSpace, uiSize, ECompositionSpace, finalSize); + + + + + CFbsBitmap* bmp2 = new (ELeave) CFbsBitmap; + CleanupStack::PushL(bmp2); + TInt bmpErr = bmp2->Create(finalSize.Size(), EColor16MU); + ASSERT_EQUALS(bmpErr, KErrNone); + + MTestScreenCapture + * csc = + static_cast (iScreenDevice->GetInterface(MTestScreenCapture::KUidTestScreenCaptureIf)); + if (csc) + { + TInt errr = csc->ComposeScreen(*bmp2); + } + else + { + if (!cSCLogged) + { + cSCLogged = ETrue; + _LIT(KNoCSC, "CSC testing not enabled as CSC render stage not defined"); + Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrAll, KNoCSC); + } + } + TRect compareRect(bmpWindow.AbsPosition(), bmpWindow.Size()); + TRect testRect(surfWindow.AbsPosition(), surfWindow.Size()); + + if (csc) + { + if(!Compare(*bmp2, compareRect, testRect, regionArray, aIsSurface)) + { + _LIT(KCompareFailed, "Compare Failed on resolution: %d"); + TBuf<256> x; + x.Format(KCompareFailed, res+1); + Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x); + } + } + CleanupStack::PopAndDestroy(bmp2); + + equivRegion.Close(); + regionArray.Close(); + + CleanupStack::PopAndDestroy(equivalentBitmap); + surfWindow.Close(); + bmpWindow.Close(); + } + } + //restore initial res + iInfoScreenDevice->SetAppScreenMode(0); + iInfoScreenDevice->SetScreenMode(0); + } + else + { + INFO_PRINTF1(_L("Only 1 screen size mode configured on this screen - res change test skipped.")); + } + testWindow.Close(); + screenModeList.Close(); + resolutionList1.Close(); + } + + +/** + Tests to see if the pixels in the bitmap match what should be drawn with regards to the bitmaps and regions in aBitmapRegionPairArray + It does this by in the case of non-scaled bitmaps, performing a pixel by pixel comparison between what has been drawn to the CSC created bitmap and either the pixels of the bitmap if they are contained within the related region or the pixels of the simulation screen. In the case of scalingm only certain pixels are compared from the CSC bitmap to the comparison drawing as the scaling algorithm is hard to replicate. + + + @param aBitmap a bitmap of the entire screen which should be generated using the Composited Screen Capture code + @param aRect1 A rectangle representing the middle window in the comparison triple + @param aRect2 A rectangle represneting the right window in the comparison triple + @param aBitmapRegionPairArray An array of the different regions that are being drawn on the screen. They should be placed in order such that the closest to the foreground is first and the furthest away is last in the queue. Each member of the array is a misleadingly titled TBitmapRegion pair, the bitmap member of this should be the bitmap that is being drawn to the region of the screen, if the region is just a blank color then a blank color bitmap should be drawn. The region should be the region that the bitmap is being drawn to and should be the same as the clipping region which is set jsut before the bitmap is drawn to screen. Finally the draw rect is the basic rectangle the bitmap is being drawn to and is mainly used to test if the bitmap is being scaled + @return True + */ +TBool CWsDynamicResBasic::Compare(const CFbsBitmap& aBitmap, + const TRect& aRect1, const TRect& aRect2, + RArray& aBitmapRegionPairArray, TBool aIsSurface) + { + MDisplayMapping* mappingInterface = static_cast + (iScreenDevice->GetInterface(MDisplayMapping::ETypeId)); + ASSERT_TRUE(mappingInterface); + + + TRgb color1; + TRgb color2; + + TInt errorPixels =0; + TInt diffPixels = 0; + RRegion ignoreDueToResizing; + TInt regionCount = aBitmapRegionPairArray.Count(); + for (TInt i=regionCount-1; i>=0; i--) + { + if (aBitmapRegionPairArray[i].bitmap->SizeInPixels() + != aBitmapRegionPairArray[i].drawRect.Size()) + { + RArray corners; + corners.Append(aBitmapRegionPairArray[i].drawRect.iTl); + corners.Append(TPoint(aBitmapRegionPairArray[i].drawRect.iBr.iX-1, + aBitmapRegionPairArray[i].drawRect.iTl.iY)); + corners.Append(TPoint(aBitmapRegionPairArray[i].drawRect.iTl.iX, + aBitmapRegionPairArray[i].drawRect.iBr.iY-1)); + corners.Append(aBitmapRegionPairArray[i].drawRect.iBr- TPoint(1,1)); + for (TInt j=0; jContains(corners[j])) + { + inOther = ETrue; + } + } + if (inOther) + { + continue; + } + aBitmap.GetPixel(color1, aRect2.iTl + corners[j]); + aBitmap.GetPixel(color2, aRect1.iTl + corners[j]); + TRgb color3 = GreatestColor(color1); + TRgb color4 = GreatestColor(color2); + if (color3 != color4) + { + // Bitmap copy can be off by a pixel on grid filled surface so allow for green and yellow to be treated equally as they are the background colours, this may allow a misfunctioning gce to pass the test though. + if (color4 == TRgb(0, 1, 0) && color3 == TRgb(1, 1, 0)) + { + } + else + if (color4 == TRgb(1, 1, 0) && color3 == TRgb(0, 1, 0)) + { + } + else + { + corners.Close(); + return EFalse; + } + } + + } + // testPoints contains first the pixel within the destRect followed by the pixel in the original position for comparison to + RArray testPoints; + testPoints.Append(aBitmapRegionPairArray[i].drawRect.Center()); + testPoints.Append(TPoint( + aBitmapRegionPairArray[i].bitmap->SizeInPixels().iWidth/2, + aBitmapRegionPairArray[i].bitmap->SizeInPixels().iHeight/2)); + testPoints.Append(TPoint(aBitmapRegionPairArray[i].drawRect.iTl.iX, + aBitmapRegionPairArray[i].drawRect.Center().iY)); + testPoints.Append(TPoint(0, + aBitmapRegionPairArray[i].bitmap->SizeInPixels().iHeight/2)); + testPoints.Append(TPoint(aBitmapRegionPairArray[i].drawRect.iBr.iX + -1, aBitmapRegionPairArray[i].drawRect.Center().iY)); + testPoints.Append(TPoint( + aBitmapRegionPairArray[i].bitmap->SizeInPixels().iWidth-1, + aBitmapRegionPairArray[i].bitmap->SizeInPixels().iHeight/2)); + TSize sizeee = aBitmapRegionPairArray[i].drawRect.Size(); + if (aBitmapRegionPairArray[i].drawRect.Size().iWidth > 11 && aBitmapRegionPairArray[i].drawRect.Size().iHeight > 20) + { + testPoints.Append(TPoint( + aBitmapRegionPairArray[i].drawRect.Center().iX, aBitmapRegionPairArray[i].drawRect.iTl.iY)); + testPoints.Append(TPoint( + aBitmapRegionPairArray[i].bitmap->SizeInPixels().iWidth/2, 0)); + + testPoints.Append(TPoint( + aBitmapRegionPairArray[i].drawRect.Center().iX, aBitmapRegionPairArray[i].drawRect.iBr.iY-1)); + testPoints.Append(TPoint( + aBitmapRegionPairArray[i].bitmap->SizeInPixels().iWidth/2, + aBitmapRegionPairArray[i].bitmap->SizeInPixels().iHeight-1)); + + if (aBitmapRegionPairArray[i].drawRect.Size().iWidth > 34 + && aBitmapRegionPairArray[i].drawRect.Size().iHeight > 43) + { + testPoints.Append(aBitmapRegionPairArray[i].drawRect.iTl + + TPoint(5, 5)); + testPoints.Append(TPoint(5, 5)); + testPoints.Append(TPoint( + aBitmapRegionPairArray[i].drawRect.iBr.iX - 6, + aBitmapRegionPairArray[i].drawRect.iTl.iY + 5)); + testPoints.Append(TPoint( + aBitmapRegionPairArray[i].bitmap->SizeInPixels().iWidth-6, 5)); + testPoints.Append(TPoint( + aBitmapRegionPairArray[i].drawRect.iTl.iX + 5, + aBitmapRegionPairArray[i].drawRect.iBr.iY -6)); + testPoints.Append(TPoint(5, + aBitmapRegionPairArray[i].bitmap->SizeInPixels().iHeight - 6)); + testPoints.Append(aBitmapRegionPairArray[i].drawRect.iBr + - TPoint(6, 6)); + testPoints.Append(TPoint( + aBitmapRegionPairArray[i].bitmap->SizeInPixels().iWidth-6, + aBitmapRegionPairArray[i].bitmap->SizeInPixels().iHeight-6)); + } + else + { + testPoints.Append(aBitmapRegionPairArray[i].drawRect.iTl + + TPoint(2, 3)); + testPoints.Append(TPoint(5, 5)); + testPoints.Append(TPoint( + aBitmapRegionPairArray[i].drawRect.iBr.iX - 3, + aBitmapRegionPairArray[i].drawRect.iTl.iY + 3)); + testPoints.Append(TPoint( + aBitmapRegionPairArray[i].bitmap->SizeInPixels().iWidth-6, 5)); + testPoints.Append(TPoint( + aBitmapRegionPairArray[i].drawRect.iTl.iX + 2, + aBitmapRegionPairArray[i].drawRect.iBr.iY -4)); + testPoints.Append(TPoint(5, + aBitmapRegionPairArray[i].bitmap->SizeInPixels().iHeight - 6)); + testPoints.Append(aBitmapRegionPairArray[i].drawRect.iBr + - TPoint(3, 4)); + testPoints.Append(TPoint( + aBitmapRegionPairArray[i].bitmap->SizeInPixels().iWidth-6, + aBitmapRegionPairArray[i].bitmap->SizeInPixels().iHeight-6)); + } + } + for (int jj=0; jjContains(testPoints[jj])) + { + continue; + } + for (TInt k=0; kContains(testPoints[jj])) + { + inOther = ETrue; + } + } + if (inOther) + { + continue; + } + TPoint currentPoint = testPoints[jj]; + TRect bound = aBitmapRegionPairArray[i].region->BoundingRect(); + TBool + contat = + aBitmapRegionPairArray[i].region->Contains(testPoints[jj]); + aBitmap.GetPixel(color1, aRect2.iTl + testPoints[jj]); + aBitmapRegionPairArray[i].bitmap->GetPixel(color2, + testPoints[jj+1]); + TRgb color5 = GreatestColor(color1); + TRgb color6 = GreatestColor(color2); + if (color5 != color6) + { + // Bitmap copy can be off by a pixel on grid filled surface so allow for green and yellow to be treated equally as they are the background colours, this may allow a misfunctioning gce to pass the test though. + if (color6 == TRgb(0, 1, 0) && color5 == TRgb(1, 1, 0)) + { + } + else + if (color6 == TRgb(1, 1, 0) && color5 == TRgb(0, 1, 0)) + { + } + else + { + testPoints.Close(); + return EFalse; + } + } + } + + testPoints.Close(); + corners.Close(); + ignoreDueToResizing.Union(*aBitmapRegionPairArray[i].region); + aBitmapRegionPairArray.Remove(i); + } + } + + RRegion superRegion; + + regionCount = aBitmapRegionPairArray.Count(); + + for (TInt i=0; i0) + { + for (TInt i=0; iContains(currentPoint)) + { + if (aIsSurface) + { + TPoint checkPoint = currentPoint + aRect2.iTl; + TRect readBackRect; + mappingInterface->MapCoordinates(EApplicationSpace, TRect(checkPoint, TSize(1,1)), ECompositionSpace, readBackRect); + aBitmap.GetPixel(color1, readBackRect.iTl); + } + else + { + TPoint checkPoint = currentPoint + aRect1.iTl; + TRect readBackRect; + mappingInterface->MapCoordinates(EApplicationSpace, TRect(checkPoint, TSize(1,1)), ECompositionSpace, readBackRect); + aBitmap.GetPixel(color1, readBackRect.iTl); + } + + aBitmapRegionPairArray[arrayIndex].bitmap->GetPixel(color2, currentPoint + - aBitmapRegionPairArray[arrayIndex].drawRect.iTl); + + TRgb color7 = GreatestColor(color1); + TRgb color8 = GreatestColor(color2); + + if (color7 != color8) + { + diffPixels++; + //return EFalse; + } + pointInArray = ETrue; + } + arrayIndex++; + } + while (!pointInArray && !(arrayIndex + >= aBitmapRegionPairArray.Count())); + + if (!pointInArray) + { + aBitmap.GetPixel(color1, TPoint(i + aRect2.iTl.iX + + xStart, j +aRect2.iTl.iY +yStart)); + aBitmap.GetPixel(color2, TPoint(i + aRect1.iTl.iX + +xStart, j +aRect1.iTl.iY+yStart)); + // Bitmap copy is duller on first few iterations so just pick the greatest color or two colors and see if they match + TRgb color3 = GreatestColor(color1); + TRgb color4 = GreatestColor(color2); + + if (color3 != color4) + { + // Bitmap copy can be off by a pixel on grid filled surface so allow for green and yellow to be treated equally as they are the background colours, this may allow a misfunctioning gce to pass the test though. + if (GreatestColor(color2) == TRgb(0, 1, 0) + && GreatestColor(color1) == TRgb(1, 1, 0)) + { + continue; + } + else + if (GreatestColor(color2) == TRgb(1, 1, 0) + && GreatestColor(color1) == TRgb(0, 1, + 0)) + { + continue; + } + else + { + errorPixels++; + //return EFalse; + } + } + } + } + } + } + } + ignoreDueToResizing.Close(); + if (errorPixels+diffPixels < 2) + { + return ETrue; + } + else + { + return EFalse; + } + + } + + +/* + Creates a rough apprxoiamtion to the color pass in. This is used because of issues with the bitmap drwaing in the comparison window. If these issues are fixed then this method can be changed to simply return aColor. + + @param aColor the color to be approximated + @return an approximation of aColor. + */ +TRgb CWsDynamicResBasic::GreatestColor(TRgb& aColor) const + { + TInt test = aColor.Difference(TRgb(0, 0, 0)); + // Accounts for a case when Rgb = 20,20,20 due to poor bitmap drawing + if (aColor == TRgb(32, 32, 32)) + { + return TRgb(0, 0, 0); + } + if (aColor == TRgb(0, 0, 0)) + { + return TRgb(0, 0, 0); + } + TRgb test2; + test2.SetInternal(0xFFFEDF01); + if (aColor == test2) + { + return TRgb(1, 1, 0); + } + + if (test < 70) + { + return TRgb(0, 0, 0); + } + if (aColor.Green() > aColor.Blue()) + { + if (aColor.Green() > aColor.Red()) + { + return TRgb(0, 1, 0); + } + else + if (aColor.Green() == aColor.Red()) + { + return TRgb(1, 1, 0); + } + } + if (aColor.Green() > aColor.Red()) + { + if (aColor.Green() > aColor.Blue()) + { + return TRgb(0, 1, 0); + } + else + if (aColor.Green() == aColor.Blue()) + { + return TRgb(0, 1, 1); + } + } + + if (aColor.Red() > aColor.Green()) + { + if (aColor.Red() > aColor.Blue()) + { + return TRgb(1, 0, 0); + } + else + if (aColor.Red() == aColor.Blue()) + { + return TRgb(1, 0, 1); + } + } + if (aColor.Red() > aColor.Blue()) + { + if (aColor.Red() > aColor.Green()) + { + return TRgb(1, 0, 0); + } + else + if (aColor.Red() == aColor.Green()) + { + return TRgb(1, 1, 0); + } + } + + if (aColor.Blue() > aColor.Red()) + { + if (aColor.Blue() > aColor.Green()) + { + return TRgb(0, 0, 1); + } + else + if (aColor.Blue() == aColor.Green()) + { + return TRgb(0, 1, 1); + } + } + if (aColor.Blue() > aColor.Green()) + { + if (aColor.Blue() > aColor.Red()) + { + return TRgb(0, 0, 1); + } + else + if (aColor.Blue() == aColor.Red()) + { + return TRgb(1, 0, 1); + } + } + + // Should never reach here, but the compiler cannot be sure + return TRgb(0, 0, 0); + } + +/* +@SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0051L +@SYMTestCaseDesc Getting if a mode is dynamic +@SYMREQ REQ11554 +@SYMPREQ PREQ2102 +@SYMTestType CT +@SYMTestPriority 1 +@SYMTestPurpose Check functions work correctly +@SYMTestActions + Do IsModeDynamic for a wrong mode number + Do IsModeDynamic for a mode that isnt dynamic + Do IsModeDynamic for a mode that is dynamic + Do IsCurrentModeDynamic when current mode is not dynamic + Do IsCurrentModeDynamic when current mode is dynamic + MODE 10 must be dynamic +@SYMTestExpectedResults + All should return as expected. +*/ +void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0051L() + { + RArray screenModeList; + iInfoScreenDevice->GetScreenSizeModeList(&screenModeList); + iInfoScreenDevice->SetAppScreenMode(0); + iInfoScreenDevice->SetScreenMode(0); + iSession.Flush(); + Pause(50); + ASSERT_FALSE(iInfoScreenDevice->IsModeDynamic(25)); + ASSERT_FALSE(iInfoScreenDevice->IsModeDynamic(1)); + ASSERT_TRUE(iInfoScreenDevice->IsModeDynamic(10)); + ASSERT_FALSE(iInfoScreenDevice->IsCurrentModeDynamic()); + iInfoScreenDevice->SetAppScreenMode(10); + iInfoScreenDevice->SetScreenMode(10); + iSession.Flush(); + Pause(50); + ASSERT_TRUE(iInfoScreenDevice->IsCurrentModeDynamic()); + screenModeList.Close(); + iInfoScreenDevice->SetAppScreenMode(0); + iInfoScreenDevice->SetScreenMode(0); + } + +/* Takes any 0x0 resolutions out of the res list, useful for some tests +*/ +void ResListCleanup(RArray& aResList) + { + for (TInt ii=0; ii + (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); + ASSERT_TRUE(interface); + + TInt resolutions = interface->NumberOfResolutions(); + ASSERT_TRUE (resolutions > 1); + + RArray resolutionList1; + TInt error = interface->GetResolutions(resolutionList1); + ASSERT_EQUALS(resolutionList1.Count(), resolutions); + ResListCleanup(resolutionList1); //remove any 0x0 + ASSERT_TRUE (resolutionList1.Count() > 1); //without multiple proper res this test is pointless + + TDisplayConfiguration newResolution; + newResolution.SetResolution(resolutionList1[0].iPixelSize); + error = interface->SetConfiguration(newResolution); + ASSERT_EQUALS(error,KErrNone); + + TSizeMode info; + RArray screenModes; + error = iInfoScreenDevice->GetScreenSizeModeList(&screenModes); + ASSERT_TRUE(error>KErrNone); + TInt dynamicMode1 = -1; + TInt dynamicMode2 = -1; + TPixelsTwipsAndRotation modeAttributes; + + //for every app mode, check calculations update correctly + for (TInt ii=0;iiIsModeDynamic(screenMode)) + { + CArrayFixFlat* rotations=new(ELeave) CArrayFixFlat(1); + CleanupStack::PushL(rotations); + TInt error = iInfoScreenDevice->GetRotationsList(screenMode,rotations); + ASSERT_EQUALS(error,KErrNone); + ASSERT_TRUE(rotations->Count()>0); + for (TInt jj = 0; jj < rotations->Count(); jj++) + { + if ((*rotations)[jj] == (TInt)CFbsBitGc::EGraphicsOrientationNormal || + (*rotations)[jj] == (TInt)CFbsBitGc::EGraphicsOrientationRotated180) + { + dynamicMode1 = screenMode; + } + else if ((*rotations)[jj] == (TInt)CFbsBitGc::EGraphicsOrientationRotated90 || + (*rotations)[jj] == (TInt)CFbsBitGc::EGraphicsOrientationRotated270) + { + dynamicMode2 = screenMode; + } + } + CleanupStack::PopAndDestroy(rotations); + continue; //dont want to test dynamic modes + } + + INFO_PRINTF2(_L("ScreenMode %d"),screenMode); + newResolution.ClearAll(); + + iInfoScreenDevice->SetAppScreenMode(screenMode); + iInfoScreenDevice->SetScreenMode(screenMode); + iSession.Flush(); + Pause(50); + + info = iInfoScreenDevice->GetCurrentScreenModeAttributes(); + //These 2 asserts relate to DEF136304 - disconnect on startup causes invalid + //twips values. They need to be calculated when the screen is connected + ASSERT_TRUE(info.iScreenTwipsSize.iWidth < 40000); + ASSERT_TRUE(info.iScreenTwipsSize.iHeight < 40000); + + //test that conversions correlate to values reported by config + TInt test = iInfoScreenDevice->HorizontalTwipsToPixels( + info.iScreenTwipsSize.iWidth); + ASSERT_EQUALS (test,info.iScreenSize.iWidth); + + test = iInfoScreenDevice->VerticalTwipsToPixels( + info.iScreenTwipsSize.iHeight); + ASSERT_EQUALS (test,info.iScreenSize.iHeight); + + test = iInfoScreenDevice->HorizontalPixelsToTwips( + info.iScreenSize.iWidth); + ASSERT_EQUALS (test,info.iScreenTwipsSize.iWidth); + + test = iInfoScreenDevice->VerticalPixelsToTwips( + info.iScreenSize.iHeight); + ASSERT_EQUALS (test,info.iScreenTwipsSize.iHeight); + } + + if (dynamicMode1 == -1 && dynamicMode2 == -1) //expected to find at least 1 dynamic mode + { + ASSERT_TRUE(0); + } + + for (TInt jj=0;jj<2;jj++) //for dynamic mode 1 and 2 + { + TInt dynMode = (jj == 0) ? dynamicMode1 : dynamicMode2; + if (dynMode == -1) + continue; + //set dynamic app mode + iInfoScreenDevice->SetAppScreenMode(dynMode); + iInfoScreenDevice->SetScreenMode(dynMode); + iSession.Flush(); + Pause(50); + ASSERT_TRUE(iInfoScreenDevice->IsModeDynamic(dynMode)); + ASSERT_TRUE(iInfoScreenDevice->IsCurrentModeDynamic()); + ASSERT_EQUALS(dynMode,iInfoScreenDevice->CurrentScreenMode()); + for (TInt ii=0;iiSetConfiguration(newResolution); + + if (jj == 0) + { + if (tempSetRot == TDisplayConfiguration1::ERotation90CW || + tempSetRot == TDisplayConfiguration1::ERotation270CW) //mode rotation will not work with config rotation + { + ASSERT_EQUALS(error,KErrArgument); + continue; + } + } + else //jj == 1 + { + if (tempSetRot == TDisplayConfiguration1::ERotationNormal || + tempSetRot == TDisplayConfiguration1::ERotation180) //mode rotation will not work with config rotation + { + ASSERT_EQUALS(error,KErrArgument); + continue; + } + } + ASSERT_EQUALS(error,KErrNone); + interface->GetConfiguration(newResolution); + iSession.Flush(); + Pause(50); + + //test that conversions correlate to values reported by config + TInt test = iInfoScreenDevice->HorizontalTwipsToPixels( + resolutionList1[ii].iTwipsSize.iWidth); + ASSERT_EQUALS (test,resolutionList1[ii].iPixelSize.iWidth); + + test = iInfoScreenDevice->VerticalTwipsToPixels( + resolutionList1[ii].iTwipsSize.iHeight); + ASSERT_EQUALS (test,resolutionList1[ii].iPixelSize.iHeight); + + test = iInfoScreenDevice->HorizontalPixelsToTwips( + resolutionList1[ii].iPixelSize.iWidth); + ASSERT_EQUALS (test,resolutionList1[ii].iTwipsSize.iWidth); + + test = iInfoScreenDevice->VerticalPixelsToTwips( + resolutionList1[ii].iPixelSize.iHeight); + ASSERT_EQUALS (test,resolutionList1[ii].iTwipsSize.iHeight); + } + } + + resolutionList1.Close(); + screenModes.Close(); + } + +/* +@SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0053L +@SYMTestCaseDesc SetScreenSizeAndRotation +@SYMREQ REQ11554 +@SYMPREQ PREQ2102 +@SYMTestType CT +@SYMTestPriority 1 +@SYMTestPurpose Check functions work correctly +@SYMTestActions + Perform calls to SetScreenSizeAndRotation with the various structure types + MODE 10 must be dynamic +@SYMTestExpectedResults + Cannt fail, used for debugging and coverage. +*/ +void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0053L() + { + MDisplayControl* interface = static_cast + (iScreenDevice->GetInterface(MDisplayControl::ETypeId)); + ASSERT_TRUE(interface); + + TInt resolutions = interface->NumberOfResolutions(); + ASSERT_TRUE (resolutions > 1); + + RArray resolutionList1; + TInt error = interface->GetResolutions(resolutionList1); + ASSERT_EQUALS(resolutionList1.Count(), resolutions); + + //set default app mode and default resolution + iInfoScreenDevice->SetAppScreenMode(0); + iInfoScreenDevice->SetScreenMode(0); + iSession.Flush(); + Pause(50); + TDisplayConfiguration original; + original.SetResolution(resolutionList1[0].iPixelSize); + interface->SetConfiguration(original); + iSession.Flush(); + Pause(50); + + TPixelsAndRotation setup0; + setup0.iPixelSize = TSize(30,40); + setup0.iRotation = CFbsBitGc::EGraphicsOrientationNormal; + + TPixelsTwipsAndRotation setup1; + setup1.iPixelSize = TSize(50,60); + setup1.iTwipsSize = TSize(70,80); + setup1.iRotation = CFbsBitGc::EGraphicsOrientationNormal; + + iInfoScreenDevice->SetScreenSizeAndRotation(setup0); + iInfoScreenDevice->SetScreenSizeAndRotation(setup1); + + //set dynamic app mode + iInfoScreenDevice->SetAppScreenMode(10); + iInfoScreenDevice->SetScreenMode(10); + iSession.Flush(); + Pause(50); + + iInfoScreenDevice->SetScreenSizeAndRotation(setup0); + iInfoScreenDevice->SetScreenSizeAndRotation(setup1); + + const CWsScreenDevice* newDevice = iScreenDevice; + const MDisplayControl* interface2 = (MDisplayControl*) + newDevice->GetInterface(MDisplayControl::ETypeId); + TInt version = interface2->PreferredDisplayVersion(); //for coverage! + (void)version; + + //set default app mode and default resolution + iInfoScreenDevice->SetAppScreenMode(1); + iInfoScreenDevice->SetScreenMode(1); + iSession.Flush(); + Pause(50); + interface->SetConfiguration(original); + iSession.Flush(); + Pause(50); + + resolutionList1.Close(); + } + +/** +@SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0101L +@SYMTestCaseDesc Quick demonstration of app modes sizes and positions on screen +@SYMREQ +@SYMPREQ PREQ2102 +@SYMTestType CT (manual visual test) +@SYMTestPurpose To show app modes +@SYMTestActions + For every app mode + Draw a blue box showing the full size and position of the app mode. + Draw thin red lines demonstrating a window can be drawn outside of the app area to fill + the screen. + Green borders at the edge of the appmode, to show we are drawing up to the edges of the + appmode. +@SYMTestExpectedResults + Blue window should represent appmode (with offset and size) + Red windows should be visible across screen + Green border (made of windows) around the appmode (blue window) +*/ +void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0101L() + { + RArray screenModeList; + iInfoScreenDevice->GetScreenSizeModeList(&screenModeList); + + if (screenModeList.Count()>1) + { + //Got modes to change between! + TSize resBefore; + for (TInt res=0;resSetAppScreenMode(screenModeList[res]); + iInfoScreenDevice->SetScreenMode(screenModeList[res]); + iSession.Flush(); + Pause(50); + + TSize appSize = iInfoScreenDevice->SizeInPixels(); + RWindow backWindow(iSession); + ASSERT_EQUALS(backWindow.Construct(iGroup, 123455), KErrNone); + backWindow.SetRequiredDisplayMode(iDisplayMode); + backWindow.SetBackgroundColor(iCyan); + backWindow.SetExtent(TPoint(40,40),appSize-TSize(40,40)); //shows size of the apparea + backWindow.Activate(); + + TSurfaceId surfaceID; + TRAPD(err, surfaceID = iUtility->CreateSurfaceL(TSize(200,200), + KSurfaceFormat, 200 * KBytesPerPixel)); + ASSERT_EQUALS(err,KErrNone); + TRAP(err,iUtility->FanFillSurfaceL(surfaceID,iYellow,iRed,iMagenta)); + ASSERT_EQUALS(err,KErrNone); + TSurfaceConfiguration surfConf; + surfConf.SetSurfaceId(surfaceID); + + backWindow.SetBackgroundSurface(surfaceID); + + DrawPlainUI(backWindow,ETrue,iBlue); + iSession.Flush(); + Pause(200); + + RWindow longWindow1(iSession); + ASSERT_EQUALS(longWindow1.Construct(iGroup, 123456), KErrNone); + longWindow1.SetRequiredDisplayMode(iDisplayMode); + longWindow1.SetBackgroundColor(iRed); + longWindow1.SetExtent(TPoint(-2000,10),TSize(5000,5)); //shows you can draw outside the apparea + longWindow1.Activate(); + DrawPlainUI(longWindow1,ETrue,iRed); + + iBackground.SetColor(TRgb(0x001000*res|0x800000)); + iSession.SetBackgroundColor(TRgb(0x001000*res+0x40)); + iSession.Flush(); + Pause(100); + + RWindow longWindow2(iSession); + ASSERT_EQUALS(longWindow2.Construct(iGroup, 123457), KErrNone); + longWindow2.SetRequiredDisplayMode(iDisplayMode); + longWindow2.SetBackgroundColor(iRed); + longWindow2.SetExtent(TPoint(20,-2000),TSize(5,5000)); //shows you can draw outside the apparea + longWindow2.Activate(); + DrawPlainUI(longWindow2,ETrue,iRed); + + //borders + RWindow borderTop(iSession); + ASSERT_EQUALS(borderTop.Construct(iGroup, 123460), KErrNone); + borderTop.SetRequiredDisplayMode(iDisplayMode); + borderTop.SetBackgroundColor(iGreen); + borderTop.SetExtent(TPoint(0,0),TSize(appSize.iWidth,5)); //border + borderTop.Activate(); + DrawPlainUI(borderTop,ETrue,iGreen); + + RWindow borderLeft(iSession); + ASSERT_EQUALS(borderLeft.Construct(iGroup, 123461), KErrNone); + borderLeft.SetRequiredDisplayMode(iDisplayMode); + borderLeft.SetBackgroundColor(iGreen); + borderLeft.SetExtent(TPoint(0,0),TSize(5,appSize.iHeight)); //border + borderLeft.Activate(); + DrawPlainUI(borderLeft,ETrue,iGreen); + + RWindow borderRight(iSession); + ASSERT_EQUALS(borderRight.Construct(iGroup, 123462), KErrNone); + borderRight.SetRequiredDisplayMode(iDisplayMode); + borderRight.SetBackgroundColor(iGreen); + borderRight.SetExtent(TPoint(appSize.iWidth-5,0),TSize(5,appSize.iHeight)); //border + borderRight.Activate(); + DrawPlainUI(borderRight,ETrue,iGreen); + + RWindow borderBottom(iSession); + ASSERT_EQUALS(borderBottom.Construct(iGroup, 123463), KErrNone); + borderBottom.SetRequiredDisplayMode(iDisplayMode); + borderBottom.SetBackgroundColor(iGreen); + borderBottom.SetExtent(TPoint(0,appSize.iHeight-5),TSize(appSize.iWidth,5)); //border + borderBottom.Activate(); + DrawPlainUI(borderBottom,ETrue,iGreen); + + iSession.Flush(); + Pause(100); + + backWindow.Close(); + longWindow1.Close(); + longWindow2.Close(); + borderTop.Close(); + borderLeft.Close(); + borderRight.Close(); + borderBottom.Close(); + + iSession.Finish(); + Pause(50); + } + } + else + { + INFO_PRINTF1(_L("Only 1 screen size mode configured on this screen - test skipped.")); + } + + screenModeList.Close(); + iInfoScreenDevice->SetAppScreenMode(0); + iInfoScreenDevice->SetScreenMode(0); + iSession.Finish(ETrue); + Pause(100); + INFO_PRINTF1(_L("Drawing to borderBottom completed.")); + } + +/** +@SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0102L +@SYMTestCaseDesc Quick demonstration of square app modes in all 4 rotations +@SYMREQ +@SYMPREQ PREQ2102 +@SYMTestType CT (manual visual test) +@SYMTestPurpose To show square app mode in all 4 rotations +@SYMTestActions + Draw a blue box showing the full size and position of the app mode. + Draw thin red lines demonstrating a window can be drawn outside of the app area to fill + the screen. + Green borders at the edge of the appmode, to show we are drawing up to the edges of the + appmode. +@SYMTestExpectedResults + Blue window should represent appmode (with offset and size) + Red windows should be visible across screen + Green border (made of windows) around the appmode (blue window) +*/ +void CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0102L() + { + RArray screenModeList; + iInfoScreenDevice->GetScreenSizeModeList(&screenModeList); + + + TSize resBefore; + TInt res; + for (res=0;resSetAppScreenMode(screenModeList[res]); + iInfoScreenDevice->SetScreenMode(screenModeList[res]); + + iSession.Finish(ETrue); + iSession.Flush(); + Pause(50); + + TPixelsAndRotation pr; + iInfoScreenDevice->GetDefaultScreenSizeAndRotation(pr); + if(pr.iPixelSize.iHeight == pr.iPixelSize.iWidth) + { + //found square appmode + break; + } + } + + for(TInt rotation = CFbsBitGc::EGraphicsOrientationNormal; rotation <= CFbsBitGc::EGraphicsOrientationRotated270; rotation++) + { + iScreenDevice->SetCurrentRotations(screenModeList[res], (CFbsBitGc::TGraphicsOrientation)rotation); + iSession.Flush(); + Pause(50); + TDisplayConfiguration dispConfigReq; + TSize appSize = iInfoScreenDevice->SizeInPixels(); + RWindow backWindow(iSession); + ASSERT_EQUALS(backWindow.Construct(iGroup, 123455), KErrNone); + backWindow.SetRequiredDisplayMode(iDisplayMode); + backWindow.SetBackgroundColor(iBlue); + backWindow.SetExtent(TPoint(0,0),appSize); //shows size of the apparea + backWindow.Activate(); + DrawPlainUI(backWindow,ETrue,iBlue); + iSession.Flush(); + Pause(200); + + RWindow longWindow1(iSession); + ASSERT_EQUALS(longWindow1.Construct(iGroup, 123456), KErrNone); + longWindow1.SetRequiredDisplayMode(iDisplayMode); + longWindow1.SetBackgroundColor(iRed); + longWindow1.SetExtent(TPoint(-2000,10),TSize(5000,5)); //shows you can draw outside the apparea + longWindow1.Activate(); + DrawPlainUI(longWindow1,ETrue,iRed); + + iBackground.SetColor(TRgb(0x001000*res|0x800000)); + iSession.SetBackgroundColor(TRgb(0x001000*res+0x40)); + iSession.Flush(); + Pause(100); + + RWindow longWindow2(iSession); + ASSERT_EQUALS(longWindow2.Construct(iGroup, 123457), KErrNone); + longWindow2.SetRequiredDisplayMode(iDisplayMode); + longWindow2.SetBackgroundColor(iRed); + longWindow2.SetExtent(TPoint(20,-2000),TSize(5,5000)); //shows you can draw outside the apparea + longWindow2.Activate(); + DrawPlainUI(longWindow2,ETrue,iRed); + + //borders + RWindow borderTop(iSession); + ASSERT_EQUALS(borderTop.Construct(iGroup, 123460), KErrNone); + borderTop.SetRequiredDisplayMode(iDisplayMode); + borderTop.SetBackgroundColor(iGreen); + borderTop.SetExtent(TPoint(0,0),TSize(appSize.iWidth,5)); //border + borderTop.Activate(); + DrawPlainUI(borderTop,ETrue,iGreen); + + RWindow borderLeft(iSession); + ASSERT_EQUALS(borderLeft.Construct(iGroup, 123461), KErrNone); + borderLeft.SetRequiredDisplayMode(iDisplayMode); + borderLeft.SetBackgroundColor(iGreen); + borderLeft.SetExtent(TPoint(0,0),TSize(5,appSize.iHeight)); //border + borderLeft.Activate(); + DrawPlainUI(borderLeft,ETrue,iGreen); + + RWindow borderRight(iSession); + ASSERT_EQUALS(borderRight.Construct(iGroup, 123462), KErrNone); + borderRight.SetRequiredDisplayMode(iDisplayMode); + borderRight.SetBackgroundColor(iGreen); + borderRight.SetExtent(TPoint(appSize.iWidth-5,0),TSize(5,appSize.iHeight)); //border + borderRight.Activate(); + DrawPlainUI(borderRight,ETrue,iGreen); + + RWindow borderBottom(iSession); + ASSERT_EQUALS(borderBottom.Construct(iGroup, 123463), KErrNone); + borderBottom.SetRequiredDisplayMode(iDisplayMode); + borderBottom.SetBackgroundColor(iGreen); + borderBottom.SetExtent(TPoint(0,appSize.iHeight-5),TSize(appSize.iWidth,5)); //border + borderBottom.Activate(); + DrawPlainUI(borderBottom,ETrue,iGreen); + + iSession.Flush(); + Pause(100); + + backWindow.Close(); + longWindow1.Close(); + longWindow2.Close(); + borderTop.Close(); + borderLeft.Close(); + borderRight.Close(); + borderBottom.Close(); + + iSession.Finish(); + Pause(50); + + } + + + screenModeList.Close(); + iInfoScreenDevice->SetAppScreenMode(0); + iInfoScreenDevice->SetScreenMode(0); + iSession.Finish(ETrue); + Pause(100); + } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tdynamicres/src/wsdynamicresclassic.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tdynamicres/src/wsdynamicresclassic.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,90 @@ +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// TDISPLAYCONFIGURATION.CPP +// Test class for TDisplayConfiguration +// +// + +#include "wsdynamicresclassic.h" +#include +#include "teflogextensions.h" + +struct TLoggerStub +{ + TLoggerStub(CTestExecuteLogger& aLogger) + : iLogger(&aLogger) {} + CTestExecuteLogger* iLogger; + CTestExecuteLogger& operator()()const + { + return *iLogger; + } +}; + +// This handles any non-member uses of the extended ASSERT_XXX macros +void TefUnitFailLeaveL() + { + + User::Leave(KErrTEFUnitFail); + } + +// Create a suite of all the tests +CTestSuite* CWsDynamicResClassic::CreateSuiteL(const TDesC& aName) + { + SUB_SUITE_OPT(CWsDynamicResClassic,NULL); + + ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0100L); + + END_SUITE; + } + +// Published Tests + +/** +@SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0100L +@SYMTestCaseDesc GetInterface in classic +@SYMREQ +@SYMPREQ PREQ2102 +@SYMTestType CT +@SYMTestPriority +@SYMTestPurpose GetInterface should always return NULL in classic +@SYMTestActions + Create an RWsSession + Create a CWsScreenDevice + Call GetInterface with various GUIDS. +@SYMTestExpectedResults + Should always return NULL +**/ +void CWsDynamicResClassic::GRAPHICS_WSERV_DYNAMICRES_0100L() + { + RWsSession session; + session.Connect(); + + CWsScreenDevice* screenDevice = NULL; + + TRAPD(err, screenDevice = new (ELeave) CWsScreenDevice(session)); + PRINT_ON_ERROR2_L(err, _L("Failed to create screen device: %d"), err); + if (screenDevice) + { + ASSERT_EQUALS_X(screenDevice->Construct(0), KErrNone); + + void* interface = screenDevice->GetInterface(12344321); + ASSERT_NULL (interface); + interface = screenDevice->GetInterface(0); + ASSERT_NULL (interface); + } + + delete screenDevice; + session.Close(); + } + diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tdynamicres/src/wsgcedebugsession.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tdynamicres/src/wsgcedebugsession.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,177 @@ +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file +*/ + +#include "wsgcedebugsession.h" + +RWsDebugSession::RWsDebugSession(TInt aScreenNo /*= -1*/): + iScreenNo(aScreenNo), + iSurfaceUpdateSerial(-1) + { + iSurfaceListBuffer.CreateMax(48); + } + +RWsDebugSession::~RWsDebugSession() + { + iSurfaceListBuffer.Close(); + + } + +TBool RWsDebugSession::ResetUpdated() + { + TInt surfaceUpdateSerial=DebugInfo(EWsDebugSerialSurfacesUpdated,iScreenNo); + TBool retVal=(iSurfaceUpdateSerial!=surfaceUpdateSerial); + iSurfaceUpdateSerial=surfaceUpdateSerial; + return retVal; + } + +TInt RWsDebugSession::ResetUpdatedAndGetSurfaceWindowList(const TWsDebugWindowId * & aWinList) + { + iSurfaceUpdateSerial=DebugInfo(EWsDebugSerialSurfacesUpdated,iScreenNo); + TInt reqSize=DebugInfo(EWsDebugSurfaceWindowList,iSurfaceListBuffer,iScreenNo); + while (reqSize>iSurfaceListBuffer.MaxLength()) + { + iSurfaceListBuffer.Close(); + iSurfaceListBuffer.CreateMax(reqSize); + iSurfaceUpdateSerial=DebugInfo(EWsDebugSerialSurfacesUpdated,iScreenNo); + reqSize=DebugInfo(EWsDebugSurfaceWindowList,iSurfaceListBuffer,iScreenNo); + } + if (reqSize==KErrCancel) + { + aWinList=NULL; + return 0; + } + else + { + aWinList=(TWsDebugWindowId*)iSurfaceListBuffer.Ptr(); + return reqSize/sizeof(TWsDebugWindowId); + } + } +/** + * Stream data into the provided buffer and point the return object pointer to it. + * The pointer is left null if the method returns an error code or the buffer is too small. + * The ret5urn code reports + * + **/ +TInt RWsDebugSession::DebugInfo(TWsDebugInfoFunc aFunction, TInt aParam, TDes8& aHostBuffer,const void*&aReturnedObject,TInt aObjectSize)const + { + aHostBuffer.SetMax(); + TInt reqSize=DebugInfo(aFunction,aHostBuffer,aParam); + aReturnedObject=NULL; + if (reqSize<0) + { + return reqSize; //Error code is transmitted unmolested + } + if (reqSize==0) //Size 0 is transformed to max + reqSize=aHostBuffer.MaxLength(); + if ((reqSize%aObjectSize)!=0) + { //Size not multiple of object --> error + return KErrCorrupt; + } + if (reqSize<=aHostBuffer.MaxLength()) + { //Pointer is only set if data fits buffer + aReturnedObject=(const void*)aHostBuffer.Ptr(); + } + reqSize/=aObjectSize; //Return the exact number of objects filled + return reqSize; + } +/** + * Stream the reply data via the buffer associated with the region. + * Some protected accessor optimisation used to manage the reported size of the region after streaming. + * + **/ +TInt RWsDebugSession::DebugInfo(TWsDebugInfoFunc aFunction, TInt aParam, TRegion& aPreAllocatedReturnedRegion)const + { + //Attempt to fit the received data in the preexisting region buffer... + class XRegion:public TRegion + { + public: + using TRegion::AppendRect; + // using TRegion::SetListSize; + using TRegion::RectangleListW; + TInt MaxSize() + { return iAllocedRects; } + void SetListSize(TInt aNewSize) //DANGER no error checking!!! + { iCount=aNewSize; } + }& preAllocatedReturnedRegion=(XRegion&)aPreAllocatedReturnedRegion; + typedef TRect TElt; + TInt reqSize=preAllocatedReturnedRegion.MaxSize(); + const TElt* elements=preAllocatedReturnedRegion.RectangleListW(); + TInt lenBytes=reqSize*sizeof(TElt); + TPtr8 pBuff((TUint8*)elements,lenBytes,lenBytes); + reqSize=DebugInfo(aFunction,aParam,pBuff,elements); + + if (elements) + { + if (reqSize==0) + { + reqSize=preAllocatedReturnedRegion.MaxSize(); + } + preAllocatedReturnedRegion.SetListSize(reqSize); + return reqSize; + } + //If data does not fit in preexisting buffer + //Use a temp array instead + //Still try to block copy into the existing capacity + //I think this use of region copy is more efficient than appending, + //and definitely better than unioning the elements. + if (reqSize>=0) + { + TInt breakLoop=10; + do { + TElt* tempbuff=new TElt[reqSize]; + if (tempbuff==NULL) + { + reqSize=KErrNoMemory; + break; + } + elements=tempbuff; + TInt lenBytes=reqSize*sizeof(TElt); + TPtr8 pBuff((TUint8*)elements,lenBytes,lenBytes); + TInt reqSize2=DebugInfo(aFunction,aParam,pBuff,elements); + if (reqSize2!=0) + reqSize=reqSize2; + if (elements) + { + RRegion r(reqSize,tempbuff); //note this region does not own its memory so should not be closed! + aPreAllocatedReturnedRegion.Copy(r); + if (aPreAllocatedReturnedRegion.CheckError()) + reqSize=KErrNoMemory; + } + delete[] tempbuff; + }while (reqSize>0 && elements==NULL && --breakLoop); + } + if (reqSize>=0 && elements==NULL) + { + preAllocatedReturnedRegion.ForceError(); + reqSize=KErrTimedOut; + } + if (reqSize<0) + { + if (reqSize==KErrCancel) + { + preAllocatedReturnedRegion.Clear(); + } + else + { + preAllocatedReturnedRegion.ForceError(); + } + + } + return reqSize; + } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tframerate/framerate.RSS --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tframerate/framerate.RSS Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,43 @@ +// FRAMERATE.RSS + +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Registry file for framerate test +// +// + +#include + +RESOURCE REGISTRY_INFO test_Info + { + dll_uid = 0x102827FC; + interfaces = + { + INTERFACE_INFO + { + interface_uid = 0x10282929; + implementations = + { + IMPLEMENTATION_INFO + { + implementation_uid = 0x1028292A; + version_no = 1; + display_name = "CGraphicDrawerTestFrameRate"; + default_data = ""; + opaque_data = ""; + } + }; + } + }; + } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tframerate/framerate.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tframerate/framerate.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,95 @@ +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test - Test plug-in to test wsgraphic animation artwork framerate + @internalComponent - Internal Symbian test code +*/ + +#include +#include +#include "framerate.h" +#include "wsgraphicdrawercontext.h" +#include "wsframerate.h" + +//Constant message handle, which is used to send count value between client and plug-in +const TUint8 KCmdCount=0; + +/** +Creates new test framerate object. +*/ +CGraphicDrawerTestFrameRate* CGraphicDrawerTestFrameRate::CreateL() + { + return new(ELeave) CGraphicDrawerTestFrameRate; + } + +CGraphicDrawerTestFrameRate::CGraphicDrawerTestFrameRate() + { + } + +CGraphicDrawerTestFrameRate::~CGraphicDrawerTestFrameRate() + { + } + +void CGraphicDrawerTestFrameRate::ConstructL(MWsGraphicDrawerEnvironment& aEnv,const TGraphicDrawerId& aId,MWsClient& aOwner,const TDesC8& /*aData*/) + { + BaseConstructL(aEnv,aId,aOwner); + if (aEnv.Screen(0)->ResolveObjectInterface(KMWsScreenConfigInterfaceId)) + { + iContext = CWsGraphicDrawerNonNgaContext::NewL(); + } + else + { + iContext = CWsGraphicDrawerNgaContext::NewL(); + } + } + +/** +Simulate two animations of different frame rate with their respective schedule. + +@param MWsGc Window server graphic context to draw the animation +@param TRect Rectangle are required to draw the animation +@param TDesC Parameter value to use inside this function. +*/ +void CGraphicDrawerTestFrameRate::DoDraw(MWsGc& aGc,const TRect& aRect,const TDesC8& aData) const + { + TInt animId = aData[0]; + TInt requestedFps = aData[1]; + ++iCounter[animId]; + //Schedule next redraw based on requested frame rate + TTimeIntervalMicroSeconds nextTick = 1000000/requestedFps; + iContext->ScheduleAnimation(aGc, aRect, nextTick); + } + +/** +Handles message between client and plug-in. + +@param TDesC Constant message command. +*/ +void CGraphicDrawerTestFrameRate::HandleMessage(const TDesC8& aData) + { + switch (aData[0]) + { + case KCmdCount: + TPckgBuf buf; + buf().iAnim1=iCounter[0]; + buf().iAnim2=iCounter[1]; + TInt err = SendMessage(buf); + __ASSERT_DEBUG(err>=KErrNone, User::Invariant()); + break; + } + } + diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tframerate/framerate.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tframerate/framerate.h Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,56 @@ +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test - Test plug-in to test wsgraphic animation artwork framerate + @internalComponent - Internal Symbian test code +*/ + +#ifndef __GRAPHICDRAWERTESTFRAMERATE_H__ +#define __GRAPHICDRAWERTESTFRAMERATE_H__ + +#include +#include "Graphics/WSGRAPHICDRAWER.H" +#include + +//Maximum number of animations at a time. +#define KMaxAnim 100 + +class MWsGraphicDrawerContext; + +/** +Drawer plug-in class used to draw the animation and scheduling. +*/ +NONSHARABLE_CLASS(CGraphicDrawerTestFrameRate): public CWsGraphicDrawer + { +public: + enum + { + EImplUid = 0x1028292A + }; + static CGraphicDrawerTestFrameRate* CreateL(); + ~CGraphicDrawerTestFrameRate(); + void ConstructL(MWsGraphicDrawerEnvironment& aEnv,const TGraphicDrawerId& aId,MWsClient& aOwner,const TDesC8& aData); + void HandleMessage(const TDesC8& aData); +private: + void DoDraw(MWsGc& aGc,const TRect& aRect,const TDesC8& aData) const; +private: + CGraphicDrawerTestFrameRate(); + mutable TInt iCounter[KMaxAnim]; + MWsGraphicDrawerContext* iContext; + }; + +#endif //__GRAPHICDRAWERTESTFRAMERATE_H__ diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tframerate/proxy.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tframerate/proxy.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,35 @@ +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include +#include "framerate.h" + + +LOCAL_C const TImplementationProxy KImplementationTable[] = + { + IMPLEMENTATION_PROXY_ENTRY(CGraphicDrawerTestFrameRate::EImplUid,CGraphicDrawerTestFrameRate::CreateL) + }; + +EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) + { + aTableCount = sizeof(KImplementationTable)/sizeof(TImplementationProxy); + return KImplementationTable; + } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tframerate/wsframerate.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tframerate/wsframerate.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,113 @@ +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test - Test client library used to communicate between framerate plug-in and twsgraphs. + @internalComponent - Internal Symbian test code +*/ + +#include "wsframerate.h" + +//Constant message handle, which is used to send count value between client and plug-in +const TUint8 KCmdCount=0; + +LOCAL_C const TUid KUidWsGraphicTestFrameRate = {0x1028292A}; + +/** +Creates new object of type CGraphicTestFrameRate based on existing plug-in id. +This interally constructs CWsGraphic object + +@param TUid Test plug-in id +*/ + +EXPORT_C CGraphicTestFrameRate* CGraphicTestFrameRate::NewL(TUid aUid) + { + CGraphicTestFrameRate* self = new(ELeave) CGraphicTestFrameRate; + CleanupStack::PushL(self); + self->BaseConstructL(aUid,KUidWsGraphicTestFrameRate,KNullDesC8()); + CleanupStack::Pop(self); + return self; + } + +/** +Creates new object of type CGraphicTestFrameRate based on active screen number. +This interally constructs CWsGraphic object + +@param TInt Screen number +*/ +EXPORT_C CGraphicTestFrameRate* CGraphicTestFrameRate::NewL(TInt aScreen) + { + CGraphicTestFrameRate* self = new(ELeave) CGraphicTestFrameRate; + CleanupStack::PushL(self); + TBuf8<1> data; + data.Append((TUint8)aScreen); + self->BaseConstructL(KUidWsGraphicTestFrameRate,data); + CleanupStack::Pop(self); + return self; + } + +EXPORT_C CGraphicTestFrameRate::~CGraphicTestFrameRate() + { + } + +CGraphicTestFrameRate::CGraphicTestFrameRate() + { + } + +/** +Handles message between client and Twsgraphs test call. + +@param TDesc8 Descriptor values passed between client and plugin +*/ +void CGraphicTestFrameRate::HandleMessage(const TDesC8& aData) + { + if (aData.Size()>1) + { + Mem::Copy(iCount, aData.Ptr(),(aData.Size())); + } + iCallBack.CallBack(); + } + +void CGraphicTestFrameRate::OnReplace() + { + } + +/** +Query a message value from test plug-in. + +@param TAnimRate Drawing count for two animations. +*/ +EXPORT_C TInt CGraphicTestFrameRate::QueryPlugin(TAnimRate& aCount) + { + TBuf8<1> cmd; + cmd.Append(KCmdCount); + SendMessage(cmd); + TInt err = Flush(); + if (err!=KErrNone) + return err; + iCount=&aCount; + return KErrNone; + } + +/** +Set the callback function + +@param TCallBack Name of the callback function to invoke. +*/ +EXPORT_C void CGraphicTestFrameRate::SetCallBack(TCallBack aCallBack) + { + iCallBack = aCallBack; + } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tframerate/wsframerate.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tframerate/wsframerate.h Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,61 @@ +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Test GraphicTestFrameRate plugins +// +// + +/** + @file + @test - Test plug-in to test wsgraphic animation artwork framerate + @internalComponent - Internal Symbian test code +*/ + +#ifndef __GRAPHICTESTFRAMERATE_H__ +#define __GRAPHICTESTFRAMERATE_H__ + +#include "W32STD.H" + +/** +Holds draw count values of two different animations +*/ +NONSHARABLE_STRUCT(TAnimRate) + { + TInt iAnim1; + TInt iAnim2; + }; + +/** Client representation of a test anim that displays its frame-rate + +@publishedPartner +@released +*/ +NONSHARABLE_CLASS(CGraphicTestFrameRate): public CWsGraphic + + { +public: + IMPORT_C static CGraphicTestFrameRate* NewL(TUid aUid); + IMPORT_C static CGraphicTestFrameRate* NewL(TInt aScreen); + IMPORT_C ~CGraphicTestFrameRate(); + IMPORT_C TInt QueryPlugin(TAnimRate& aCount); + IMPORT_C void SetCallBack(TCallBack aCallBack); +private: + CGraphicTestFrameRate(); + void HandleMessage(const TDesC8& aData); + void OnReplace(); +private: + TAnimRate* iCount; + TCallBack iCallBack; + }; + +#endif //__GRAPHICTESTFRAMERATE_H__ diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tframerate/wsgraphicdrawercontext.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tframerate/wsgraphicdrawercontext.h Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,53 @@ +// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#ifndef __WSGRAPHICDRAWERCONTEXT_H__ +#define __WSGRAPHICDRAWERCONTEXT_H__ + +#include +#include + +class MWsGc; +class TRgb; + +class MWsGraphicDrawerContext + { +public: + virtual void Destroy() = 0; + virtual void ScheduleAnimation(MWsGc& aGc, const TRect& aRect,const TTimeIntervalMicroSeconds& aFromNow) = 0; + virtual void ScheduleAnimation(MWsGc& aGc, const TRect& aRect,const TTimeIntervalMicroSeconds& aFromNow,const TTimeIntervalMicroSeconds& aFreq,const TTimeIntervalMicroSeconds& aStop) = 0; + }; + +class CWsGraphicDrawerNgaContext : public CBase, public MWsGraphicDrawerContext + { +public: + static MWsGraphicDrawerContext* NewL(); +public: + void Destroy(); + void ScheduleAnimation(MWsGc& aGc, const TRect& aRect,const TTimeIntervalMicroSeconds& aFromNow); + void ScheduleAnimation(MWsGc& aGc, const TRect& aRect,const TTimeIntervalMicroSeconds& aFromNow,const TTimeIntervalMicroSeconds& aFreq,const TTimeIntervalMicroSeconds& aStop); + }; + +class CWsGraphicDrawerNonNgaContext : public CBase, public MWsGraphicDrawerContext + { +public: + static MWsGraphicDrawerContext* NewL(); +public: + void Destroy(); + void ScheduleAnimation(MWsGc& aGc, const TRect& aRect,const TTimeIntervalMicroSeconds& aFromNow); + void ScheduleAnimation(MWsGc& aGc, const TRect& aRect,const TTimeIntervalMicroSeconds& aFromNow,const TTimeIntervalMicroSeconds& aFreq,const TTimeIntervalMicroSeconds& aStop); + }; + +#endif // __WSGRAPHICDRAWERCONTEXT_H__ diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tframerate/wsgraphicdrawerngacontext.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tframerate/wsgraphicdrawerngacontext.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,39 @@ +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#define SYMBIAN_GRAPHICS_GCE + +#include "wsgraphicdrawercontext.h" +#include + +MWsGraphicDrawerContext* CWsGraphicDrawerNgaContext::NewL() + { + return new(ELeave) CWsGraphicDrawerNgaContext(); + } + +void CWsGraphicDrawerNgaContext::Destroy() + { + delete this; + } + +void CWsGraphicDrawerNgaContext::ScheduleAnimation(MWsGc& aGc, const TRect& aRect,const TTimeIntervalMicroSeconds& aFromNow) + { + aGc.ScheduleAnimation(aRect, aFromNow); + } + +void CWsGraphicDrawerNgaContext::ScheduleAnimation(MWsGc& aGc, const TRect& aRect,const TTimeIntervalMicroSeconds& aFromNow,const TTimeIntervalMicroSeconds& aFreq,const TTimeIntervalMicroSeconds& aStop) + { + aGc.ScheduleAnimation(aRect, aFromNow, aFreq, aStop); + } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tframerate/wsgraphicdrawernonngacontext.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tframerate/wsgraphicdrawernonngacontext.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,40 @@ +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#undef SYMBIAN_GRAPHICS_GCE + +#include "wsgraphicdrawercontext.h" +#include +#include + +MWsGraphicDrawerContext* CWsGraphicDrawerNonNgaContext::NewL() + { + return new(ELeave) CWsGraphicDrawerNonNgaContext(); + } + +void CWsGraphicDrawerNonNgaContext::Destroy() + { + delete this; + } + +void CWsGraphicDrawerNonNgaContext::ScheduleAnimation(MWsGc& aGc, const TRect& aRect,const TTimeIntervalMicroSeconds& aFromNow) + { + aGc.ScheduleAnimation(aRect, aFromNow); + } + +void CWsGraphicDrawerNonNgaContext::ScheduleAnimation(MWsGc& aGc, const TRect& aRect,const TTimeIntervalMicroSeconds& aFromNow,const TTimeIntervalMicroSeconds& aFreq,const TTimeIntervalMicroSeconds& aStop) + { + aGc.ScheduleAnimation(aRect, aFromNow, aFreq, aStop); + } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tlib/TESTBASE.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tlib/TESTBASE.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,1446 @@ +// Copyright (c) 1994-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Base classes used for building window server test code +// +// + +#include +#include +#include +#include +#include "TLIB.H" +#include + +// +// Test code classes +// +// CTWinBase +// CTBaseWin +// CTWin +// CTBackedUpWin +// CTGroupWin +// CTClient +// +// + +_LIT(KTestFontTypefaceName,"DejaVu Sans Condensed"); + +class CStopTheScheduler : public CAsyncOneShot + { +public: + inline CStopTheScheduler(CTClient* aClient,TInt aPriority,TBool aAll) :CAsyncOneShot(aPriority), iClient(aClient), iAll(aAll) {} + inline CStopTheScheduler(CTClient* aClient,TInt aPriority) :CAsyncOneShot(aPriority), iClient(aClient) {} + inline CStopTheScheduler(TInt aPriority) :CAsyncOneShot(aPriority) {} + void RunL(); +public: + CTClient* iClient; + TBool iAll; +#ifdef __WINS__ + TInt iCStopTheSchedulerRunCount; +#endif + }; + + +void TbPanic(TInt aPanic) + { + User::Panic(_L("TestBase"),aPanic); + } + +EXPORT_C CTWinBase::CTWinBase(TInt aType) : iType(aType) + { + __DECLARE_NAME(_S("CTWinBase")); + } + +EXPORT_C CTWinBase *CTWinBase::Parent() const + { + return((CTWinBase *)WinTreeNode()->Parent()); + } + +EXPORT_C CTWinBase *CTWinBase::NextSibling() const + { + return((CTWinBase *)WinTreeNode()->NextSibling()); + } + +EXPORT_C CTWinBase *CTWinBase::PrevSibling() const + { + return((CTWinBase *)WinTreeNode()->PrevSibling()); + } + +EXPORT_C CTClient *CTWinBase::Client() const + { + return(iOwnerWin->Client()); + } + +EXPORT_C CTBaseWin *CTWinBase::Child() const + { + return((CTBaseWin *)WinTreeNode()->Child()); + } + +EXPORT_C TPoint CTWinBase::Position() const + { + return(TPoint(0,0)); + } + +EXPORT_C void CTWinBase::PointerEnter(const TTime&) + { + } + +EXPORT_C void CTWinBase::PointerExit(const TTime&) + { + } + +EXPORT_C void CTWinBase::PointerBufferReady(const TTime&) + { + } + +EXPORT_C void CTWinBase::PointerL(const TPointerEvent&,const TTime&) + { + } + +EXPORT_C void CTWinBase::SwitchOn(const TTime &) + { + } + +EXPORT_C void CTWinBase::ModifiersChanged(const TModifiersChangedEvent &,const TTime &) + { + } + +EXPORT_C void CTWinBase::AdjustOrdinal(TInt) + { + } + +EXPORT_C void CTWinBase::AdjustShadow(TInt) + { + } + +EXPORT_C void CTWinBase::SetVisible(TBool) + { + } + +EXPORT_C TInt CTWinBase::SubType() + { + return(0); + } + +EXPORT_C void CTWinBase::ErrorMessage(const TWsErrorMessage&, const TTime &) + { + } + +EXPORT_C void CTWinBase::__DbgTestInvariant() const + { + WinTreeNode()->__DbgTestInvariant(); + } + +// CTBaseWin // + +EXPORT_C CTBaseWin::CTBaseWin(TInt aType) : CTWinBase(aType) + { + __DECLARE_NAME(_S("CTBaseWin")); + } + +EXPORT_C CTBaseWin::~CTBaseWin() + { + } + +EXPORT_C void CTBaseWin::RelinquishFocus() + { + CTWinBase *parent=Parent(); + CTWindowGroup *group=Group(); + CTWinBase *child=group->Child(); + if (child==this) + child=child->NextSibling(); + group->SetCurrentWindow((parent->iType==EWinTypeClient) ? (CTBaseWin *)parent : (CTBaseWin *)child); + } + +EXPORT_C void CTBaseWin::SetVisible(TBool aState) + { + BaseWin()->SetVisible(aState); + } + +EXPORT_C const RWindowTreeNode *CTBaseWin::WinTreeNode() const + { + return((const RWindowTreeNode *)BaseWin()); + } + +EXPORT_C RWindowTreeNode *CTBaseWin::WinTreeNode() + { + return((RWindowTreeNode *)BaseWin()); + } + +EXPORT_C void CTBaseWin::InitWin() + { + } + +EXPORT_C void CTBaseWin::ConstructExtLD(CTWinBase &aParent, const TPoint &aPos, const TSize &aSize) +// +// Call ConstructL, SetExt and either of these fail destroy this and leave +// + { + TRAPD(err,ConstructL(aParent)); + if (err!=KErrNone) + goto celd_err; + TRAP(err,SetExtL(aPos,aSize)); + if (err!=KErrNone) + { +celd_err: + delete this; + User::Leave(err); + } + } + +EXPORT_C void CTBaseWin::ConstructL(CTWinBase &aParent) + { + TInt ret; + __ASSERT_DEBUG(aParent.iOwnerWin!=NULL,TbPanic(ETestBasePanicNullOwnerWin)); + iOwnerWin=aParent.iOwnerWin; + if ((ret=ConstructWin(aParent))==KErrNone) + { + //TFontSpec fspec(KTestFontTypefaceName,200); + //User::LeaveIfError(Client()->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)iFont, fspec)); + TFontSpec fspec(KTestFontTypefaceName,17); + User::LeaveIfError(Client()->iScreen->GetNearestFontToDesignHeightInPixels((CFont *&)iFont, fspec)); + AdjustShadow(1); + InitWin(); + iSize=BaseWin()->Size(); + } + User::LeaveIfError(ret); + } + +EXPORT_C void CTBaseWin::Activate() + { + BaseWin()->Activate(); + } + +EXPORT_C void CTBaseWin::SetFullScreenExtL() + { + SetExtL(TPoint(0,0), Parent()->Size()); + } + +EXPORT_C void CTBaseWin::SetDefaultExtL() + { + TSize size=Parent()->Size(); + size.iWidth>>=1; + size.iHeight>>=1; + SetExtL(TPoint(size.iWidth>>1,size.iHeight>>1), size); + } + +EXPORT_C void CTBaseWin::AssignGC(CWindowGc &aGc) + { + iGc= &aGc; + } + +EXPORT_C void CTBaseWin::SetPos(const TPoint &aPos) + { + BaseWin()->SetPosition(aPos); + iPos=aPos; + } + +EXPORT_C void CTBaseWin::SetInitialPos(const TPoint &aPos) + { + TSize screen=Client()->iScreen->SizeInPixels(); + TPoint pos(aPos); + TPoint botLeft=pos+iSize; + if (botLeft.iX>screen.iWidth) + pos.iX=Max(0,pos.iX-botLeft.iX+screen.iWidth); + if (botLeft.iY>screen.iHeight) + pos.iY=Max(0,pos.iY-botLeft.iY+screen.iHeight); + SetPos(pos); + } + +EXPORT_C void CTBaseWin::SetExtL(const TPoint &aPos, const TSize &aSize) + { + User::LeaveIfError(BaseWin()->SetExtentErr(aPos,aSize)); + iPos=aPos; + iSize=aSize; + Resized(iSize); + } + +EXPORT_C void CTBaseWin::AdjustSizeL(TInt xMove,TInt yMove,TInt modifiers) + { + if (modifiers&EModifierCtrl) // 4 times the movement + { + xMove<<=2; + yMove<<=2; + } + if (modifiers&EModifierShift) + { + TSize size(iSize.iWidth+xMove,iSize.iHeight+yMove); + + if (size.iWidth<0) + size.iWidth=0; + if (size.iHeight<0) + size.iHeight=0; + if (modifiers&EModifierCtrl) + { + TPoint pos(iPos); + pos.iX-=(xMove>>1); + pos.iY-=(yMove>>1); + SetExtL(pos,size); + } + else + SetSizeL(size); + } + else + SetPos(TPoint(iPos+TPoint(xMove,yMove))); + } + +EXPORT_C void CTBaseWin::SetSizeL(const TSize &aSize) + { + User::LeaveIfError(BaseWin()->SetSizeErr(aSize)); + iSize=aSize; + Resized(iSize); + } + +EXPORT_C TSize CTBaseWin::Size() const + { + return(iSize); + } + +EXPORT_C void CTBaseWin::Resized(const TSize &aSize) +// + { + SetDragRect(TRect(aSize)); + } + +EXPORT_C TPoint CTBaseWin::Position() const + { + return(BaseWin()->Position()); + } + +EXPORT_C void CTBaseWin::Delete(CTBaseWin *aWin) + { + RHeap& heap = User::Heap(); + TUint8* base=heap.Base(); + TInt size=heap.Size(); + TUint8* cell=REINTERPRET_CAST(TUint8*,aWin); + __ASSERT_ALWAYS(base<=cell && cellGroup()) + curwin=tmp->Group()->CurWin(); + do + { + win2=tmp; + while((tmp=win2->Child())!=NULL) + win2=tmp; + if ((tmp=win2->NextSibling())==NULL) + tmp=win2->Parent(); + if (curwin==win2) + ((CTBaseWin *)win2)->RelinquishFocus(); + delete win2; + } while(win2!=aWin); + } + +EXPORT_C void CTBaseWin::KeyUpL(const TKeyEvent &,const TTime&) + { + } + +EXPORT_C void CTBaseWin::KeyDownL(const TKeyEvent &,const TTime&) + { + } + +EXPORT_C void CTBaseWin::WinKeyL(const TKeyEvent &,const TTime&) + { + } + +EXPORT_C void CTBaseWin::PointerL(const TPointerEvent &aPointer,const TTime&) + { + if (iDragging) + { + if (aPointer.iType==TPointerEvent::EDrag) + SetPos(aPointer.iParentPosition-iDragPos); + else + iDragging=EFalse; + return; + } + if (aPointer.iType==TPointerEvent::EButton1Down) + { + if (aPointer.iModifiers&EModifierCtrl) + { + if (aPointer.iModifiers&EModifierShift) + BaseWin()->SetOrdinalPosition(-1); + else + BaseWin()->SetOrdinalPosition(0); + return; + } +#if defined(__WINS__) + else if (aPointer.iModifiers&EModifierShift) + __DbgTestInvariant(); +#endif + else + { + Group()->SetCurrentWindow(this); + if (iDragRect.Contains(aPointer.iPosition)) + { + iDragging=ETrue; + iDragPos=aPointer.iPosition; + return; + } + } + } + } + +EXPORT_C void CTBaseWin::DragDropL(const TPointerEvent &,const TTime &) + { + } + +EXPORT_C void CTBaseWin::AdjustOrdinal(TInt aAdjust) + { + TInt pos=BaseWin()->OrdinalPosition()+aAdjust; + if (pos>=0) + BaseWin()->SetOrdinalPosition(pos); + } + +EXPORT_C void CTBaseWin::AdjustShadow(TInt aAdjust) + { + iShadow+=aAdjust; + if (iShadow<0) + iShadow=0; + BaseWin()->SetShadowHeight(iShadow); + } + +EXPORT_C void CTBaseWin::DrawBorder() + { + iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + iGc->DrawRect(TRect(iSize)); + iGc->SetBrushStyle(CGraphicsContext::ENullBrush); + } + +EXPORT_C void CTBaseWin::SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc, TDisplayMode *aMode,TBool aVisible,TInt aTransparency) + { + ConstructL(*parent); + if (aMode) + BaseWin()->SetRequiredDisplayMode(*aMode); + SetExtL(pos,size); + if (!aVisible) + BaseWin()->SetVisible(aVisible); + if (aTransparency!=ENoTransparency) + { + TInt err=((RWindow*)(BaseWin()))->SetTransparencyFactor(TRgb::_Gray256(aTransparency)); + User::LeaveIfError(err); //asked for transparency when not got none! + } + Activate(); + AssignGC(aGc); + } + +EXPORT_C void CTBaseWin::SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc, TDisplayMode *aMode) + { + SetUpL(pos,size,parent,aGc,aMode,ETrue); + } + +EXPORT_C void CTBaseWin::SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc,TBool aVisible) + { + SetUpL(pos,size,parent,aGc,NULL,aVisible); + } + +EXPORT_C void CTBaseWin::SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc) + { + SetUpL(pos,size,parent,aGc,NULL,ETrue); + } + +EXPORT_C void CTBaseWin::SetDragRect(const TRect &aRect) + { + BaseWin()->PointerFilter(EPointerFilterDrag,0); // Clear the drag filter + BaseWin()->SetPointerGrab(ETrue); + iDragRect=aRect; + } + +EXPORT_C CTWindowGroup *CTBaseWin::Group() const + { + return(iOwnerWin); + } + +EXPORT_C void CTBaseWin::FocusChanged(TBool ) + { + } + +EXPORT_C CTBaseWin *CTBaseWin::Next() + { + CTWinBase *win; + CTWinBase *ret=Child(); + if (ret==NULL) + { + win=this; + while((ret=win->NextSibling())==NULL) + { + ret=win; + win=win->Parent(); + if (win==NULL) // Group window + { + ret=ret->Child(); + break; + } + } + } + return((CTBaseWin *)ret); + } + +EXPORT_C CTBaseWin *CTBaseWin::Prev() + { + CTWinBase *par=Parent(); + CTWinBase *win; + CTWinBase *child; + if ((win=PrevSibling())==NULL) + { + if (par->iType==EWinTypeGroup) + { + CTWinBase *win2=par->Child(); + do + { + win=win2; + while((win2=win->NextSibling())!=NULL) + win=win2; + win2=win->Child(); + } while(win2!=NULL); + } + else + win=par; + } + else + { + child=win->Child(); + while(child!=NULL) + { + win=child; + child=child->NextSibling(); + } + } + return((CTBaseWin *)win); + } + +//EXPORT_C void CTBaseWin::SetDefaultExt() +// { +// TbPanic(ETestBasePanicUnimplementedBaseFunction); +// } + +EXPORT_C void CTBaseWin::Draw() + { + TbPanic(ETestBasePanicUnimplementedBaseFunction); + } + +EXPORT_C void CTBaseWin::__DbgTestInvariant() const + { + CTWinBase::__DbgTestInvariant(); +#if defined(__WINS__) + if (BaseWin()->Size()!=iSize) + User::Invariant(); + TPoint offset; + const CTWinBase *win=this; + const CTWinBase *win2; + while((win2=win->Parent())!=NULL) + { + offset+=((CTBaseWin *)win)->BaseWin()->Position(); + if (BaseWin()->InquireOffset(*(win2->WinTreeNode()))!=offset) + User::Invariant(); + win=win2; + } +#endif + } + +//CTDrawableWin// +// Drawable window // +// + +EXPORT_C CTDrawableWin::CTDrawableWin(TInt aType) : CTBaseWin(aType) + { + __DECLARE_NAME(_S("CTDrawableWin")); + } + +//CTWin// +// Standard client window // +// + +EXPORT_C CTWin::CTWin() : CTDrawableWin(EWinTypeClient) + { + __DECLARE_NAME(_S("CTWin")); + } + +EXPORT_C CTWin::~CTWin() + { + if (iFont) + Client()->iScreen->ReleaseFont(iFont); + iWin.Close(); + } + +EXPORT_C TInt CTWin::ConstructWin(const CTWinBase &aParent) + { + iWin=RWindow(aParent.Client()->iWs); + return(iWin.Construct(*(aParent.WinTreeNode()),(TUint32)this)); + } + +EXPORT_C void CTWin::SetDefaultExt() + { + TSize size=Parent()->Size(); + size.iWidth>>=1; + size.iHeight>>=1; + SetExt(TPoint(size.iWidth>>1,size.iHeight>>1), size); + Invalidate(); + } + +EXPORT_C void CTWin::SetExt(const TPoint &aPos, const TSize &aSize) + { + iWin.SetExtent(aPos,aSize); + iPos=aPos; + iSize=aSize; + Resized(iSize); + } + +EXPORT_C void CTWin::SetSize(const TSize &aSize) + { + iWin.SetSize(aSize); + iSize=aSize; + Resized(iSize); + } + +EXPORT_C void CTWin::AdjustSize(TInt xMove,TInt yMove,TInt modifiers) + { + if (modifiers&EModifierCtrl) // 4 times the movement + { + xMove<<=2; + yMove<<=2; + } + if (modifiers&EModifierShift) + { + TSize size(iSize.iWidth+xMove,iSize.iHeight+yMove); + + if (size.iWidth<0) + size.iWidth=0; + if (size.iHeight<0) + size.iHeight=0; + if (modifiers&EModifierCtrl) + { + TPoint pos(iPos); + pos.iX-=(xMove>>1); + pos.iY-=(yMove>>1); + SetExt(pos,size); + } + else + SetSize(size); + Invalidate(); + } + else + SetPos(TPoint(iPos+TPoint(xMove,yMove))); + } + +EXPORT_C RWindowBase *CTWin::BaseWin() + { + return((RWindowBase *)&iWin); + } + +EXPORT_C const RWindowBase *CTWin::BaseWin() const + { + return((const RWindowBase *)&iWin); + } + +EXPORT_C RDrawableWindow *CTWin::DrawableWin() + { + return((RDrawableWindow *)&iWin); + } + +EXPORT_C const RDrawableWindow *CTWin::DrawableWin() const + { + return((const RDrawableWindow *)&iWin); + } + + +EXPORT_C void CTWin::Invalidate() + { + iWin.Invalidate(); + } + +EXPORT_C void CTWin::Invalidate(const TRect &rect) + { + iWin.Invalidate(rect); + } + +EXPORT_C void CTWin::DrawNow() + { + iWin.Invalidate(); + iWin.BeginRedraw(); + iGc->Activate(iWin); + iGc->UseFont((CFont *)iFont); + Draw(); + iGc->Deactivate(); + iWin.EndRedraw(); + } + +EXPORT_C void CTWin::Redraw() + { + iWin.BeginRedraw(); + iGc->Activate(iWin); + iGc->UseFont((CFont *)iFont); + Draw(); + iGc->Deactivate(); + iWin.EndRedraw(); + } + +EXPORT_C void CTWin::Redraw(const TRect &aRect) + { + iWin.BeginRedraw(aRect); + iGc->Activate(iWin); + iGc->UseFont((CFont *)iFont); + Draw(); + iGc->Deactivate(); + iWin.EndRedraw(); + } + +//CTBackedUpWin// +// Backed up window // +// + +EXPORT_C CTBackedUpWin::CTBackedUpWin(TDisplayMode aDisplayMode) : CTDrawableWin(EWinTypeClient), iDisplayMode(aDisplayMode) + { + __DECLARE_NAME(_S("CTBackedUpWin")); + } + +EXPORT_C CTBackedUpWin::~CTBackedUpWin() + { + if (iFont) + Client()->iScreen->ReleaseFont(iFont); + iWin.Close(); + } + +EXPORT_C TInt CTBackedUpWin::ConstructWin(const CTWinBase &aParent) + { + iWin=RBackedUpWindow(aParent.Client()->iWs); + return(iWin.Construct(*(aParent.WinTreeNode()), iDisplayMode, (TUint32)this)); + } + +EXPORT_C RWindowBase *CTBackedUpWin::BaseWin() + { + return((RWindowBase *)&iWin); + } + +EXPORT_C const RWindowBase *CTBackedUpWin::BaseWin() const + { + return((const RWindowBase *)&iWin); + } + +EXPORT_C RDrawableWindow *CTBackedUpWin::DrawableWin() + { + return((RDrawableWindow *)&iWin); + } + +EXPORT_C const RDrawableWindow *CTBackedUpWin::DrawableWin() const + { + return((const RDrawableWindow *)&iWin); + } + +EXPORT_C RBackedUpWindow *CTBackedUpWin::BackedUpWin() + { + return &iWin; + } + +EXPORT_C const RBackedUpWindow *CTBackedUpWin::BackedUpWin() const + { + return &iWin; + } + +//CTTitledWindow// + +EXPORT_C CTTitledWindow::CTTitledWindow() : CTWin(), iWinColor(TRgb(255,255,255)), iPenColor(TRgb(0,0,0)) + { + __DECLARE_NAME(_S("CTTitledWin")); + } + +EXPORT_C CTTitledWindow::~CTTitledWindow() + { + } + +EXPORT_C void CTTitledWindow::ConstructL(CTWinBase &parent) + { + CTBaseWin::ConstructL(parent); + iTitleHeight=iFont->HeightInPixels()+4; + if (iTitle.Length()==0) + SetTitle(*Client()->Title()); + } + +EXPORT_C void CTTitledWindow::SetColor(TRgb aRgb) + { + iWinColor=aRgb; + iWin.SetBackgroundColor(aRgb); + } + +EXPORT_C void CTTitledWindow::Resized(const TSize &aSize) + { + SetDragRect(TRect(0,0,aSize.iWidth,iTitleHeight)); + } + +EXPORT_C void CTTitledWindow::SetTitle(const TWindowTitle &aTitle) + { + iTitle=aTitle; + } + +EXPORT_C void CTTitledWindow::Draw() + { + iGc->SetPenColor(iPenColor); + iGc->SetBrushColor(iWinColor); + DrawBorder(); + iGc->DrawLine(TPoint(0,iTitleHeight),TPoint(iSize.iWidth,iTitleHeight)); + if (Group()->HasFocus(this)) + { + iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + iGc->SetPenColor(~iPenColor); + iGc->SetBrushColor(~iWinColor); + } + iGc->DrawText(iTitle, TRect(1,1,iSize.iWidth-1,iTitleHeight),iFont->AscentInPixels()+1,CGraphicsContext::ECenter); + iGc->SetPenColor(iPenColor); + iGc->SetBrushColor(iWinColor); + } + +EXPORT_C void CTTitledWindow::FocusChanged(TBool ) + { + iWin.Invalidate(TRect(0,0,iSize.iWidth,iTitleHeight)); + } + +// CTBlankWindow // + +EXPORT_C CTBlankWindow::CTBlankWindow() : CTBaseWin(EWinTypeClient) + { + __DECLARE_NAME(_S("CTBlankWin")); + } + +EXPORT_C void CTBlankWindow::ConstructL(CTWinBase &aParent) + { + CTBaseWin::ConstructL(aParent); + } + +EXPORT_C CTBlankWindow::~CTBlankWindow() + { + if (iFont) + Client()->iScreen->ReleaseFont(iFont); + iWin.Close(); + } + +EXPORT_C void CTBlankWindow::SetExt(const TPoint &aPos, const TSize &aSize) + { + iWin.SetExtent(aPos,aSize); + iPos=aPos; + iSize=aSize; + Resized(iSize); + } + +EXPORT_C void CTBlankWindow::SetSize(const TSize &aSize) + { + iWin.SetSize(aSize); + iSize=aSize; + Resized(iSize); + } + +EXPORT_C void CTBlankWindow::SetColor(const TRgb &aRgb) + { + iWin.SetColor(aRgb); + } + +EXPORT_C TInt CTBlankWindow::ConstructWin(const CTWinBase &aParent) + { + iWin=RBlankWindow(aParent.Client()->iWs); + return(iWin.Construct(*(aParent.WinTreeNode()),(TUint32)this)); + } + +EXPORT_C const RWindowBase *CTBlankWindow::BaseWin() const + { + return((const RWindowBase *)&iWin); + } + +EXPORT_C RWindowBase *CTBlankWindow::BaseWin() + { + return((RWindowBase *)&iWin); + } + +//CTWindowGroup// + +EXPORT_C CTWindowGroup::CTWindowGroup(CTClient *aClient) : CTWinBase(EWinTypeGroup), iGroupWin(aClient->iWs) + { + __DECLARE_NAME(_S("CTWindowGroup")); + iClient=aClient; + iOwnerWin=this; + } + +EXPORT_C CTWindowGroup::~CTWindowGroup() + { + iGroupWin.Close(); + } + +EXPORT_C const RWindowTreeNode *CTWindowGroup::WinTreeNode() const + { + return((const RWindowTreeNode *)&iGroupWin); + } + +EXPORT_C RWindowTreeNode *CTWindowGroup::WinTreeNode() + { + return((RWindowTreeNode *)&iGroupWin); + } + +EXPORT_C void CTWindowGroup::ConstructL() + { + User::LeaveIfError(iGroupWin.Construct((TUint32)this)); + } + +EXPORT_C TSize CTWindowGroup::Size() const + { + return(iClient->iScreen->SizeInPixels()); + } + +EXPORT_C void CTWindowGroup::WinKeyL(const TKeyEvent &,const TTime&) + { + } + +EXPORT_C void CTWindowGroup::KeyL(const TKeyEvent &aKey,const TTime&aTime) + { + if (iCurWin) + iCurWin->WinKeyL(aKey,aTime); + } + +EXPORT_C void CTWindowGroup::KeyUpL(const TKeyEvent &,const TTime&) + { + } + +EXPORT_C void CTWindowGroup::KeyDownL(const TKeyEvent &,const TTime&) + { + } + +EXPORT_C void CTWindowGroup::ClearCurrentWindow() + { + iCurWin=NULL; + } + +EXPORT_C void CTWindowGroup::SetCurrentWindow(CTBaseWin *aWindow) + { + SetCurrentWindow(aWindow, EFalse); + } + +EXPORT_C void CTWindowGroup::SetCurrentWindow(CTBaseWin *aWindow, TBool aLocked) + { + if (iCurWin!=aWindow) + { + if (iFocus && iCurWin) + iCurWin->FocusChanged(EFalse); + iCurWin=aWindow; + if (iFocus && iCurWin) + iCurWin->FocusChanged(ETrue); + } + iLocked=aLocked; + } + +EXPORT_C CTBaseWin *CTWindowGroup::CurWin(void) const + { + return(iCurWin); + } + +EXPORT_C void CTWindowGroup::FocusLost() + { + iFocus=EFalse; + if (iCurWin) + iCurWin->FocusChanged(EFalse); + } + +EXPORT_C void CTWindowGroup::FocusGained() + { + iFocus=ETrue; + if (iCurWin) + iCurWin->FocusChanged(ETrue); + } + +EXPORT_C TBool CTWindowGroup::HasFocus(CTBaseWin *aWin) const + { + return(iFocus && iCurWin==aWin); + } + +EXPORT_C CTClient *CTWindowGroup::Client() const + { + return(iClient); + } + +EXPORT_C CTWindowGroup *CTWindowGroup::Group() const + { + return((CTWindowGroup *)this); + } + +EXPORT_C void CTWindowGroup::PasswordL(const TTime &) + { + TbPanic(ETestBasePanicPassword); + } + +EXPORT_C void CTWindowGroup::MessageReady(const TWsEvent &) +// +// Dummy handler for un-exepected messages (could panic, but better not as the app sending the messages fault really not ours) +// + { + } + +EXPORT_C void CTWindowGroup::ScreenDeviceChanged() + { + TPixelsAndRotation sizeAndRotation; + Client()->iScreen->GetDefaultScreenSizeAndRotation(sizeAndRotation); + Client()->iScreen->SetScreenSizeAndRotation(sizeAndRotation); + } + +EXPORT_C void CTWindowGroup::UserEvent(TInt /*aEventType*/) + { + } + + +// CTClient // + +EXPORT_C CTClient::CTClient() + { + __DECLARE_NAME(_S("CTClient")); + } + +EXPORT_C void CTClient::DestroyWindows() + { + if (iGroup) + { + CTBaseWin *win; + if (iGroup->GroupWin()->WsHandle()!=0) // Check it was created okay + while((win=iGroup->Child())!=NULL && ((TUint)win)!=ENullWsHandle) + CTBaseWin::Delete(win); + delete iGroup; + iGroup=NULL; + } + } + +EXPORT_C CTClient::~CTClient() + { + DestroyWindows(); + delete iGc; + delete iEventHandler; + delete iRedrawEventHandler; + delete iScreen; + TInt count=iWs.ResourceCount(); + __ASSERT_ALWAYS(count==0,TbPanic(ETestBasePanicResourceCount)); + iWs.Close(); + } + +EXPORT_C void CTClient::ConstructEventHandlerL() + { + iEventHandler=new(ELeave) CTEvent(&iWs); + iEventHandler->Construct(); + } + +EXPORT_C void CTClient::ConstructL() + { + User::LeaveIfError(iWs.Connect()); + iScreen=new(ELeave) CWsScreenDevice(iWs); + User::LeaveIfError(iScreen->Construct(iScreenNumber)); + iRedrawEventHandler=new(ELeave) CTRedraw(&iWs); + iRedrawEventHandler->Construct(); + ConstructEventHandlerL(); + iGc=new(ELeave) CWindowGc(iScreen); + User::LeaveIfError(iGc->Construct()); + iTitle.Copy(RThread().FullName()); + } + +EXPORT_C void CTClient::ResetFocus() + { + iGroup->ClearCurrentWindow(); + iGroup->SetCurrentWindow(iGroup->Child()); + } + +EXPORT_C TWindowTitle *CTClient::Title() + { + return(&iTitle); + } + +EXPORT_C TBool CTClient::QueueRead() + { + TBool ret=iEventHandler->IsActive(); + if (ret==EFalse) + iEventHandler->Request(); + return(ret); + } + +EXPORT_C void CTClient::CancelRead() + { + iEventHandler->Cancel(); + } + +EXPORT_C void CTClient::SetCancelFunction(const TCallBack &aCallBack) + { + iEventHandler->SetCancelFunction(aCallBack); + } + +EXPORT_C void CTClient::CancelRedrawRead() + { + iRedrawEventHandler->Cancel(); + } + +EXPORT_C void CTClient::SetRedrawCancelFunction(const TCallBack &aCallBack) + { + iRedrawEventHandler->SetCancelFunction(aCallBack); + } + +EXPORT_C void CTClient::RequestRedraw() + { + iRedrawEventHandler->Request(); + } + +EXPORT_C void CTClient::LogMessage(const TLogMessageText &aMessage) + { + iWs.LogMessage(aMessage); + iWs.Flush(); + } + +EXPORT_C TBool CTClient::IsEventWaiting() + { + iWs.NumWindowGroups(); //Make sure all asyncronus calls have finished + return (iEventHandler->iStatus!=KRequestPending); + } + +TBool CTClient::WaitUntilEventPending(const TRequestStatus& aStatus) + { + if (aStatus!=KRequestPending) + return ETrue; + User::After(2000000); //Need something smarter than this + return (aStatus!=KRequestPending); + } + +EXPORT_C TBool CTClient::WaitUntilRedrawPending() + { + return WaitUntilEventPending(iRedrawEventHandler->iStatus); + } + +EXPORT_C TBool CTClient::WaitUntilEventPending() + { + return WaitUntilEventPending(iEventHandler->iStatus); + } + +EXPORT_C TInt CTClient::WaitForRedrawsToFinish() + { + return WaitForEventsToFinish(EFalse); + } + +EXPORT_C TInt CTClient::WaitForAllEventProcessingToFinish() + { + return WaitForEventsToFinish(ETrue); + } + +TInt CTClient::WaitForEventsToFinish(TBool aAll) + { + CStopTheScheduler* stop=new CStopTheScheduler(this,ETlibRedrawActivePriority-1,aAll); + if (!stop) + return KErrNoMemory; + stop->Call(); + CActiveScheduler::Start(); + delete stop; + return KErrNone; + } + + +// CStopTheScheduler // + +void CStopTheScheduler::RunL() + { +#ifdef __WINS__ + RDebug::Print(_L("CStopTheScheduler::RunL - enter - %d"), iCStopTheSchedulerRunCount); +#endif + if (iClient) + { + iClient->iWs.NumWindowGroups(); //Make sure all asyncronus calls have finished + } + + if (!iClient || (iClient->RedrawHandler()->iStatus==KRequestPending && (!iAll || iClient->EventHandler()->iStatus==KRequestPending))) + { +#ifdef __WINS__ + RDebug::Print(_L("CStopTheScheduler::RunL - Stop - %d"), iCStopTheSchedulerRunCount); +#endif + CActiveScheduler::Stop(); + } + else + { +#ifdef __WINS__ + RDebug::Print(_L("CStopTheScheduler::RunL - Call - %d"), iCStopTheSchedulerRunCount); +#endif + Call(); + } +#ifdef __WINS__ + RDebug::Print(_L("CStopTheScheduler::RunL - exit - %d"), iCStopTheSchedulerRunCount); + iCStopTheSchedulerRunCount++; +#endif + } + +void WaitForRedrawsToFinish() + { + CStopTheScheduler* ps=new CStopTheScheduler(ETlibRedrawActivePriority-1); + if(ps) + { + ps->Call(); + CActiveScheduler::Start(); + delete ps; + } + } + + +// CTEventBase // + +EXPORT_C CTEventBase::CTEventBase(RWsSession *aWs, TInt aPriority) : CActive(aPriority), iWs(aWs) + { + } + +EXPORT_C CTEventBase::~CTEventBase() + { + } + +EXPORT_C void CTEventBase::Construct() + { + CActiveScheduler::Add(this); + Request(); + } + +EXPORT_C void CTEventBase::RunL() + { + if (iStatus==KErrNone) + { + ++iCount; + TRAPD(err,doRunL()); + if (err<=0) // Positive value means this has been destroyed + { + if (iCancelRequested) + CancelHandler(); + Request(); +// if (err!=KErrNone) +// User::LeaveIfError(err); Should have a guaranteed to work error dialog here I guess + } + } + else if (iStatus==KErrCancel && iCancelRequested) + { + CancelHandler(); + Request(); + } + else + TbPanic(ETestBasePanicEventStat); + } + +void CTEventBase::SetCancelFunction(const TCallBack &aCallBack) + { + if (!IsActive() && iCancelRequested) + TbPanic(ETestBasePanicCancelFunction); + iCancelCallBack=aCallBack; + iCancelRequested=ETrue; + DoCancel(); + } + +EXPORT_C void CTEventBase::CancelHandler() + { + iCancelCallBack.CallBack(); + iCancelRequested=EFalse; + } + +// TLibWsEvent // + +EXPORT_C CTWindowGroup *TlibWsEvent::WindowGroup() + { + CTWindowGroup *group=(CTWindowGroup *)Handle(); + __ASSERT_DEBUG(group->iType==EWinTypeGroup,TbPanic(ETestBasePanicWinType)); + return(group); + } + +EXPORT_C CTBaseWin *TlibWsEvent::BaseWin() + { + CTBaseWin *win=(CTBaseWin *)Handle(); + __ASSERT_DEBUG(win->iType==EWinTypeClient || win->iType==EWinTypeGroup,TbPanic(ETestBasePanicWinType)); + return(win); + } + +// CTEvent // + +EXPORT_C CTEvent::CTEvent(RWsSession *aWs) : CTEventBase(aWs, ETlibWsEventActivePriority) + { + __DECLARE_NAME(_S("CTEvent")); + } + +EXPORT_C CTEvent::~CTEvent() + { + Cancel(); + } + +EXPORT_C void CTEvent::DoCancel() + { + iWs->EventReadyCancel(); + } + +EXPORT_C void CTEvent::Request() + { + iWs->EventReady(&iStatus); + SetActive(); + } + +EXPORT_C void CTEvent::LogEvent(const TWsEvent &) + { + } + +EXPORT_C void CTEvent::doRunL() + { + TlibWsEvent event; + + iWs->GetEvent(event); + LogEvent(event); + if (event.Handle()!=0 && event.Handle()!=ENullWsHandle) + { + switch(event.Type()) + { + case EEventKey: + event.WindowGroup()->KeyL(*event.Key(),event.Time()); + break; + case EEventKeyDown: + __ASSERT_ALWAYS(event.Key()->iCode==0 && event.Key()->iRepeats==0, TbPanic(ETestBasePanicKeyParams)); + event.WindowGroup()->KeyDownL(*event.Key(),event.Time()); + break; + case EEventKeyUp: + __ASSERT_ALWAYS(event.Key()->iCode==0 && event.Key()->iRepeats==0, TbPanic(ETestBasePanicKeyParams)); + event.WindowGroup()->KeyUpL(*event.Key(),event.Time()); + break; + case EEventModifiersChanged: + event.BaseWin()->ModifiersChanged(*event.ModifiersChanged(),event.Time()); + break; + case EEventPointer: + event.BaseWin()->PointerL(*event.Pointer(),event.Time()); + break; + case EEventDragDrop: + event.BaseWin()->DragDropL(*event.Pointer(),event.Time()); + break; + case EEventPointerEnter: + event.BaseWin()->PointerEnter(event.Time()); + break; + case EEventPointerExit: + event.BaseWin()->PointerExit(event.Time()); + break; + case EEventPointerBufferReady: + event.BaseWin()->PointerBufferReady(event.Time()); + break; + case EEventSwitchOn: + event.BaseWin()->SwitchOn(event.Time()); + break; + case EEventFocusLost: + event.WindowGroup()->FocusLost(); + break; + case EEventFocusGained: + event.WindowGroup()->FocusGained(); + break; + case EEventPassword: + event.WindowGroup()->PasswordL(event.Time()); + break; + case EEventMessageReady: + event.WindowGroup()->MessageReady(event); + break; + case EEventErrorMessage: + event.WindowGroup()->ErrorMessage(*event.ErrorMessage(), event.Time()); + break; + case EEventSwitchOff: + case EEventKeySwitchOff: + { + TTimeIntervalMicroSeconds32 ii=1000000; + User::After(ii); //WINS does not always work without this! + UserHal::SwitchOff(); + } + break; + case EEventScreenDeviceChanged: + event.WindowGroup()->ScreenDeviceChanged(); + break; + case EEventNull: + break; + default: + if (event.Type()>=EEventUser) + { + event.WindowGroup()->UserEvent(event.Type()); + break; + } + else + { + //if not in BufferSecurity test - panic + TInt value = EFalse; + TInt err = RProperty::Get(KUidWServSecurityTesting,EWServSecTestBufferSecurity,value); + if ((err != KErrNone) || (value != (TInt)ETrue)) + TbPanic(ETestBasePanicInvalidEvent); + } + break; + } + } + } + +EXPORT_C CTRedraw::CTRedraw(RWsSession *aWs) : CTEventBase(aWs, ETlibRedrawActivePriority) + { + __DECLARE_NAME(_S("CTRedraw")); + } + +EXPORT_C CTRedraw::~CTRedraw() + { + Cancel(); + } + +EXPORT_C void CTRedraw::Request() + { + iWs->RedrawReady(&iStatus); + SetActive(); + } + +EXPORT_C void CTRedraw::DoCancel() + { + iWs->RedrawReadyCancel(); + } + +EXPORT_C void CTRedraw::doRunL() + { + TWsRedrawEvent redraw; + iWs->GetRedraw(redraw); + if (redraw.Handle()!=0 && redraw.Handle()!=ENullWsHandle) + { + __ASSERT_ALWAYS(!redraw.Rect().IsEmpty(),TbPanic(ETestBasePanicNullRedraw)); + ((CTWin *)redraw.Handle())->Redraw(redraw.Rect()); + } + } + +EXPORT_C void CTUser::Splat(CTClient *aClient, const TRect &aRect, const TRgb &aRgb) + { + RBlankWindow win(aClient->iWs); + win.Construct(*(aClient->iGroup->WinTreeNode()),1); + win.SetColor(aRgb); + win.SetExtent(aRect.iTl,aRect.Size()); + win.Activate(); + aClient->iWs.Flush(); + win.Close(); + } + +void doTestLibStartUpL(TInt aScreenNumber, CTClient *&aClient, CActiveScheduler *&aActiveScheduler,CTrapCleanup *&aCleanUpStack,TCreateClientFunc aFunc) + { + User::LeaveIfNull(aCleanUpStack=CTrapCleanup::New()); + aActiveScheduler=new(ELeave) CActiveScheduler; + CActiveScheduler::Install(aActiveScheduler); + aClient=aFunc(); + aClient->SetScreenNumber(aScreenNumber); + aClient->ConstructL(); + CActiveScheduler::Start(); + } + +EXPORT_C TInt TestLibStartUp(TCreateClientFunc aFunc,TInt aScreenNumber) + { + __UHEAP_MARK; + CTrapCleanup* cleanUpStack=NULL; + CActiveScheduler *activeScheduler=NULL; + CTClient *client=NULL; + TRAPD(err,doTestLibStartUpL(aScreenNumber, client,activeScheduler,cleanUpStack,aFunc)); + delete client; + delete activeScheduler; + delete cleanUpStack; + __UHEAP_MARKEND; + return(err); + } + +EXPORT_C TInt TestLibStartUp(TCreateClientFunc aFunc) + { + return TestLibStartUp(aFunc, KDefaultScreen); + } + diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tlib/TLDIALOG.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tlib/TLDIALOG.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,463 @@ +// Copyright (c) 1994-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Base classes used for building window server test code +// +// + +#include +#include +#include +#include +#include "TLIB.H" + +const TInt ButtonGap=20; +const TInt ButtonBorderGap=10; +const TInt ButtonBorderMargin=3; +const TInt TextMargin=5; +const TInt KAutoDelaySeconds=60; + +NONSHARABLE_CLASS(CTAutoKey): public CActive + { +public: + static CTAutoKey* NewL(RWsSession& aWs); + ~CTAutoKey(); + void Activate(TInt aDelay); + + void RunL(); + void DoCancel(); + +private: + CTAutoKey(RWsSession& aWs); + void ConstructL(); + + RTimer iTimer; + TInt iDelay; + RWsSession& iWs; + }; + +EXPORT_C CTDialog::CTDialog() : CTTitledWindow(), iNumButtons(1) + { + iButton[0].Copy(_L("Continue")); // Default button + } + +EXPORT_C CTDialog::~CTDialog() + { + if (iIsActive) + CActiveScheduler::Stop(); + delete iAutoKey; + } + +EXPORT_C void CTDialog::ConstructLD(CTWinBase &aParent,CWindowGc &aGc) + { + iOldFocus=aParent.Group()->CurWin(); + TRAPD(err,CTTitledWindow::ConstructL(aParent)); + if (err!=KErrNone) + { + delete this; + User::Leave(err); + } + iActivated=ETrue; + iWin.SetBackgroundColor(TRgb::Gray256(238)); // Light gray + AssignGC(aGc); + iWin.SetPointerCapture(ETrue); + Group()->SetCurrentWindow(this, ETrue); + iAutoKey=CTAutoKey::NewL(Client()->iWs); + } + +EXPORT_C void CTDialog::RelinquishFocus() + { + Group()->SetCurrentWindow(iOldFocus); + } + +EXPORT_C TInt CTDialog::Display() + { + TInt result; + + SetWindowSize(); + if (iWinActive) + BaseWin()->SetVisible(ETrue); + else + { + Activate(); + iWinActive=ETrue; + } + if (iTakeFocus) + Group()->SetCurrentWindow(this); + Group()->GroupWin()->SetOrdinalPosition(0); + iResultPtr=&result; + CTClient *client=Client(); + if (client->QueueRead()) + { + client->iWs.Flush(); + client=NULL; + } + iIsActive=ETrue; + iAutoKey->Activate(KAutoDelaySeconds); + CActiveScheduler::Start(); + if (client) + client->CancelRead(); + return(result); + } + +EXPORT_C void CTDialog::SetFlags(TUint aFlags) + { + iFlags=aFlags; + } + +void CTDialog::SetMaxWid(TInt &aMax, TInt aWid) + { + if (aWid>aMax) + aMax=aWid; + } + +EXPORT_C void CTDialog::SetWindowSize() + { + if (iActivated) + { + TInt max=0; + SetMaxWid(max,iFont->TextWidthInPixels(iTitle)); + SetMaxWid(max,iFont->TextWidthInPixels(iLine1)); + SetMaxWid(max,iFont->TextWidthInPixels(iLine2)); + max+=TextMargin*2; + iButWid=0; + if (iNumButtons>0) + { + for(TInt index=0;indexTextWidthInPixels(iButton[index])); + iButWid+=ButtonBorderMargin*2; + SetMaxWid(max,iButWid*iNumButtons+ButtonGap*(iNumButtons-1)+ButtonBorderGap*2); + } + TSize parSize=Parent()->Size(); + TSize size(max,iFont->HeightInPixels()*8); + TPoint pos((parSize.iWidth-size.iWidth)/2,(parSize.iHeight-size.iHeight)/2); + if (iFlags&EDialogDisplayAtBottom) + pos.iY*=2; + if (iFlags&EDialogDisplayAtLeft) + pos.iX=0; + SetExt(pos,size); + Invalidate(); + } + } + +EXPORT_C void CTDialog::SetLine1(const TDesC &aLine1) + { + iLine1.Copy(aLine1); + } + +EXPORT_C void CTDialog::SetLine2(const TDesC &aLine2) + { + iLine2.Copy(aLine2); + } + +EXPORT_C void CTDialog::SetNumButtons(TInt aNum) + { + if ((TUint)aNum>3) + TbPanic(EDialogButtonCount); + iNumButtons=aNum; + } + +EXPORT_C void CTDialog::SetButtonText(TInt aNum,const TDesC &aButton) + { + if ((TUint)aNum>(TUint)iNumButtons) + TbPanic(EDialogButtonIndex); + iButton[aNum].Copy(aButton); + } + +TRect CTDialog::ButtonRect(TInt aIndex) const + { + TInt chunk=(iSize.iWidth-ButtonBorderMargin*2)/iNumButtons; + TInt midPos=ButtonBorderMargin+chunk*aIndex+chunk/2; + return(TRect(midPos-iButWid/2,iFont->HeightInPixels()*6,midPos+iButWid/2,iFont->HeightInPixels()*7+ButtonBorderMargin*2)); + } + +EXPORT_C void CTDialog::Draw() + { + CTTitledWindow::Draw(); + iGc->SetPenColor(TRgb::Gray16(0)); + iGc->DrawText(iLine1, TPoint((iSize.iWidth-iFont->TextWidthInPixels(iLine1))/2,iFont->HeightInPixels()*3)); + iGc->DrawText(iLine2, TPoint((iSize.iWidth-iFont->TextWidthInPixels(iLine2))/2,iFont->HeightInPixels()*4+2)); + if (iNumButtons!=0) + { + for(TInt index=0;indexSetBrushStyle(CGraphicsContext::ESolidBrush); + iGc->SetBrushColor(TRgb::Gray256(255)); + iGc->DrawRect(rect); + iGc->DrawRect(rect); + iGc->SetBrushStyle(CGraphicsContext::ENullBrush); + TInt midPos=(rect.iTl.iX+rect.iBr.iX)/2; + iGc->DrawText(iButton[index], TPoint((midPos-iFont->TextWidthInPixels(iButton[index])/2), + iFont->HeightInPixels()*6+iFont->AscentInPixels()+ButtonBorderMargin)); + } + } + } + +EXPORT_C void CTDialog::WinKeyL(const TKeyEvent &aKey,const TTime&) + { + switch(aKey.iCode) + { + case EKeyEscape: + case '0': + ButtonPressL(0); + break; + case EKeyEnter: + case '1': + ButtonPressL(iNumButtons>1 ? 1 : 0); // Same as ESC on a single button dialog + break; + case ' ': + case '2': + ButtonPressL(2); + break; + } + } + +EXPORT_C void CTDialog::PointerL(const TPointerEvent &aPointer,const TTime &aTime) + { + if (aPointer.iType==TPointerEvent::EButton1Up) + { + if (iButtonClickOn>0) + { + ButtonPressL(iButtonClickOn-1); + return; + } + } + else if (aPointer.iType==TPointerEvent::EButton1Down) + { + for(TInt index=0;indexiGroup, aClient->iGc); + TRAPD(err,dialog->ConstructLD()); + if (err==KErrNone) + { + dialog->SetTitle(aTitle); + dialog->SetLine1(aLine1); + dialog->SetLine2(aLine2); + dialog->SetNumButtons(1); + dialog->SetButtonText(0,_L("Okay")); + if (dialog->Display()!=0) // delete dialog + TbPanic(EDialogDisplay); + } + } + +void doDisplayDialog(TInt aScreenNumber,const TWindowTitle &aTitle, const TDesC &aLine1, const TDesC &aLine2, CTClient *&aClient, const RWindowGroup *aGroup) + { + aClient=new(ELeave) CTClient(); + aClient->SetScreenNumber(aScreenNumber); + aClient->ConstructL(); +// + aClient->iGroup=new(ELeave) CTWindowGroup(aClient); + aClient->iGroup->ConstructL(); + aClient->iGroup->GroupWin()->SetOrdinalPosition(0,10); + if (aGroup) + aClient->iGroup->GroupWin()->SetOwningWindowGroup(aGroup->Identifier()); +// + TRAP_IGNORE(DisplayDialog(aClient, aTitle, aLine1, aLine2)); + } + +void doDisplayDialog(const TWindowTitle &aTitle, const TDesC &aLine1, const TDesC &aLine2, CTClient *&aClient, const RWindowGroup *aGroup) + { + doDisplayDialog(KDefaultScreen,aTitle,aLine1,aLine2,aClient,aGroup); + } + +EXPORT_C void DisplayDialog(TInt aScreenNumber,const TWindowTitle &aTitle, const TDesC &aLine1, const TDesC &aLine2, const RWindowGroup *aGroup) + { + CTClient *client=NULL; + TRAP_IGNORE(doDisplayDialog(aScreenNumber,aTitle,aLine1,aLine2,client,aGroup)); + delete client; + } + +EXPORT_C void DisplayDialog(const TWindowTitle &aTitle, const TDesC &aLine1, const TDesC &aLine2, const RWindowGroup *aGroup) + { + DisplayDialog(KDefaultScreen,aTitle,aLine1,aLine2,aGroup); + } + + + +//CInfoDialog + +EXPORT_C CInfoDialog::CInfoDialog(CTWindowGroup *aGroupWin,CWindowGc *aGc) :CTDialog(), iGroupWin(aGroupWin), iGc(aGc) + {} + +EXPORT_C void CInfoDialog::ButtonPressL(TInt aButton) + { + if (aButton==0) + { + SetResult(0); + BaseWin()->SetVisible(EFalse); + CActiveScheduler::Stop(); + } + } + +EXPORT_C void CInfoDialog::ConstructLD() + { + _LIT(OK,"Okay"); + CTDialog::ConstructLD(*iGroupWin, *iGc); + SetNumButtons(1); + SetButtonText(0,OK); + SetTakeFocus(); + } + +EXPORT_C void CInfoDialog::TimerResults() + { + TProfile profile[eTimes]; + // TProfile only has default constructor - + // constructor of TProfile does not initialize its members + for (TInt jj=0; jj times; + TBuf<32> counts; + TInt ii=1; + FOREVER + { + AppendProfileTime(times,profile[ii].iTime); + AppendProfileCount(counts,profile[ii].iCount); + if (++ii==eTimes) + break; + AddComma(times); + AddComma(counts); + } + SetLine1(times); + SetLine2(counts); + times.Zero(); + AppendProfileTime(times,profile[0].iTime); + SetTitle(times); + } + +void CInfoDialog::AppendProfileTime(TDes &aDes, TInt aNum) + { + _LIT(ThreeDP,"%d.%03d"); + aDes.AppendFormat(ThreeDP,aNum/eSeconds,(aNum%eSeconds)/1000); + } + +void CInfoDialog::AppendProfileCount(TDes &aDes, TInt aNum) + { + _LIT(Int,"%d"); + aDes.AppendFormat(Int,aNum); + } + +void CInfoDialog::AddComma(TDes &aDes) + { + _LIT(Comma,", "); + aDes.Append(Comma); + } + +CTAutoKey::CTAutoKey(RWsSession& aWs): CActive(0), iWs(aWs) + { + CActiveScheduler::Add(this); + } + +CTAutoKey::~CTAutoKey() + { + Cancel(); + iTimer.Close(); + } + +void CTAutoKey::ConstructL() + { + User::LeaveIfError(iTimer.CreateLocal()); + } + +CTAutoKey* CTAutoKey::NewL(RWsSession& aWs) + { + CTAutoKey* self=new(ELeave) CTAutoKey(aWs); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + +void CTAutoKey::Activate(TInt aDelay) + { + if (IsActive()) + Cancel(); + + iDelay=aDelay*1000000; + iTimer.After(iStatus,iDelay); + SetActive(); + } +void CTAutoKey::RunL() + { + // simulate key event, only needed to run once + TKeyEvent keyEvent; + keyEvent.iCode=EKeyEnter; + keyEvent.iScanCode=EKeyEnter; + keyEvent.iModifiers=0; + keyEvent.iRepeats=0; + iWs.SimulateKeyEvent(keyEvent); + iWs.Flush(); + } + +void CTAutoKey::DoCancel() + { + iTimer.Cancel(); + } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tlib/TLEVENT.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tlib/TLEVENT.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,294 @@ +// Copyright (c) 1994-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Maintains a window displaying last event details +// +// + +#include +#include +#include +#include "testbase.h" + +const TInt NumLogLinesPerEvent=2; + + +// +// Event window // +// + +EXPORT_C CEventWindow::CEventWindow(TInt aLogSize) : CTWin(), iLogSize(aLogSize) + { + } + +EXPORT_C CEventWindow::~CEventWindow() + { + delete[] iLoggedEvents; + RelinquishFocus(); + } + +EXPORT_C void CEventWindow::ConstructL(CTWinBase &parent) + { + CTWin::ConstructL(parent); + iLineHeight=iFont->HeightInPixels()+2; + iLoggedEvents=new(ELeave) TWsEvent[iLogSize]; + iWin.EnableModifierChangedEvents(EModifierFunc|EModifierCapsLock|EModifierNumLock, EEventControlAlways); + iWin.EnableOnEvents(EEventControlAlways); + } + +EXPORT_C void CEventWindow::SetUpL(const TPoint &pos, CTWinBase *parent, CWindowGc &aGc) + { + TRAPD(err,ConstructL(*parent)); + if (err!=KErrNone) + { + delete this; + User::Leave(err); + } + SetExt(pos,TSize(600,iLineHeight*NumLogLinesPerEvent*iLogSize)); + Activate(); + AssignGC(aGc); + } + +void CEventWindow::DrawLine(TInt aLine, const TDesC &aText) + { + iGc->DrawText(aText, TPoint(10,iLineHeight*aLine+iFont->AscentInPixels()+1)); + } + +void CEventWindow::LogEvent(TInt aLogNum, const TWsEvent &aEvent) + { + TBuf<0x80> buf1; + TBuf<0x80> buf2; + TPtrC type(_L("Unknown event type")); + TKeyEvent *key=aEvent.Key(); + switch(aEvent.Type()) + { + case EEventKey: + type.Set(_L("EEventKey")); + buf2.Format(TRefByValue(_L("Code=%d [%c], ScanCode=0x%x, Modifiers=0x%04x, repeats=%d")), key->iCode, key->iCode, key->iScanCode,key->iModifiers,key->iRepeats); + break; + case EEventKeyUp: + type.Set(_L("EEventKeyUp")); + buf2.Format(TRefByValue(_L("scanCode=0x%x, Modifiers=0x%04x")), key->iScanCode, key->iModifiers); + break; + case EEventKeyDown: + type.Set(_L("EEventKeyDown")); + buf2.Format(TRefByValue(_L("scanCode=0x%x, Modifiers=0x%04x")), key->iScanCode, key->iModifiers); + break; + case EEventPointer: + { + TPointerEvent *pointer=aEvent.Pointer(); + TPtrC ptrType(_L("Unknown pointer event")); + switch(pointer->iType) + { + case TPointerEvent::EButton1Up: + ptrType.Set(_L("EButton1Up")); + break; + case TPointerEvent::EButton3Up: + ptrType.Set(_L("EButton3Up")); + break; + case TPointerEvent::EButton2Up: + ptrType.Set(_L("EButton2Up")); + break; + case TPointerEvent::EButton1Down: + ptrType.Set(_L("EButton1Down")); + break; + case TPointerEvent::EButton3Down: + ptrType.Set(_L("EButton3Down")); + break; + case TPointerEvent::EButton2Down: + ptrType.Set(_L("EButton2Down")); + break; + case TPointerEvent::EDrag: + ptrType.Set(_L("EDrag")); + break; + case TPointerEvent::EMove: + ptrType.Set(_L("EMove")); + break; + case TPointerEvent::EButtonRepeat: + ptrType.Set(_L("EButtonRepeat")); + break; + case TPointerEvent::ESwitchOn: + ptrType.Set(_L("ESwitchOn")); + break; + } + type.Set(_L("EEventPointer")); + buf2.Format(TRefByValue(_L("Type=%S, state=0x%x, pos={%d,%d}, parent pos={%d,%d}")),&ptrType, pointer->iModifiers, + pointer->iPosition.iX,pointer->iPosition.iY,pointer->iParentPosition.iX,pointer->iParentPosition.iY); + } + break; + case EEventPointerEnter: + type.Set(_L("EEventPointerEnter")); + break; + case EEventPointerExit: + type.Set(_L("EEventPointerExit")); + break; + case EEventSwitchOn: + type.Set(_L("EEventSwitchOn")); + break; + case EEventModifiersChanged: + type.Set(_L("EEventModifiersChanged")); + buf2.Format(TRefByValue(_L("Changed=0x%x, State=0x%x ")),aEvent.ModifiersChanged()->iChangedModifiers,aEvent.ModifiersChanged()->iModifiers); + break; + case EEventFocusLost: + type.Set(_L("EEventFocusLost")); + break; + case EEventFocusGained: + type.Set(_L("EEventFocusGained")); + break; + default:; + } + TBuf<20> timeBuf; + _LIT(TimeDisc,"%/0%1%/1%2%/2%3%/3 %:0%H%:1%T%:2%S%:3"); + TRAPD(err,aEvent.Time().FormatL(timeBuf,TimeDisc)); + if (err!=KErrNone) + { + _LIT(DummyTime,"########"); + timeBuf.Append(DummyTime); + } + buf1.Format(TRefByValue(_L("%d: %S [%x], %S")), iCount-aLogNum, &type, aEvent.Handle(), &timeBuf); + TInt baseLine=(iLogSize-aLogNum-1)*NumLogLinesPerEvent; + DrawLine(baseLine+0,buf1); + DrawLine(baseLine+1,buf2); + } + +EXPORT_C void CEventWindow::Draw() + { + DrawBorder(); + for(TInt index=0;index0;index--) + iLoggedEvents[index]=iLoggedEvents[index-1]; + iLoggedEvents[0]=aEvent; + DrawNow(); + } + + +// +// Blank window, just sort of sits there looking blank // +// + +EXPORT_C TBool CheckBlankWindow(TRect aArea,TRgb aColor,const CWsScreenDevice* aScreen) +// +// Returns ETrue if the the given rect is all the specified color +// EFalse if it is not +// + { + TInt wid=aArea.Width(); + TAny *buf2=User::AllocL(wid*sizeof(TRgb)); + TRgb *pRgb=(TRgb *)buf2; + Mem::FillZ(buf2,wid*sizeof(TRgb)); + //TRgb tmp(TRgb::Gray16(aColor.Gray16())); + //Truncate color to match color conversion in EColor64K mode before comparison + if (aScreen->DisplayMode()==EColor64K) + aColor=TRgb::Color64K(aColor.Color64K()); + for(TInt i=0;i(buf2),wid*sizeof(TRgb),wid*sizeof(TRgb)); + + TAny *buf=User::AllocL(wid*sizeof(TRgb)); + TPtr8 rgbBuf(reinterpret_cast(buf),wid*sizeof(TRgb)); + + TBool ret=ETrue; + TPoint offset=aArea.iTl; //iWin.InquireOffset(*TheClient->iGroup->WinTreeNode()); + for(;offset.iYGetScanLine(rgbBuf,offset,wid,EColor16MA); + if (rgbBuf.Compare(tstBuf)!=0) + { + ret=EFalse; + break; + } + } + User::FreeZ(buf); + User::FreeZ(buf2); + return(ret); + } + +EXPORT_C CBlankWindow::CBlankWindow() : CTWin() + { + iCol=TRgb::Gray256(128); + } + +EXPORT_C CBlankWindow::CBlankWindow(TRgb aCol) : CTWin(), iCol(aCol), iRealDraw(EFalse) + { + } + +EXPORT_C void CBlankWindow::ConstructL(CTWinBase &parent) + { + CTWin::ConstructL(parent); + iWin.SetBackgroundColor(iCol); + } + +EXPORT_C void CBlankWindow::SetColor(TRgb aColor) + { + iCol=aColor; + } + +EXPORT_C void CBlankWindow::RealDraw(TBool aRealDraw) + { + iRealDraw=aRealDraw; + } + +EXPORT_C void CBlankWindow::Draw() + { + if (!iRealDraw) + iGc->Clear(); + else + { + iGc->SetPenStyle(CGraphicsContext::ENullPen); + iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + iGc->SetBrushColor(iCol); + iGc->DrawRect(TRect(iSize)); + } + } + +EXPORT_C void CBlankWindow::DrawNow() + { + iWin.Invalidate(); + iWin.BeginRedraw(); + iGc->Activate(iWin); + Draw(); + iGc->Deactivate(); + iWin.EndRedraw(); + } + +EXPORT_C void CBlankWindow::DrawNow(TRect& aRect) + { + iWin.Invalidate(aRect); + iWin.BeginRedraw(aRect); + iGc->Activate(iWin); + iGc->SetClippingRect(aRect); + Draw(); + iGc->Deactivate(); + iWin.EndRedraw(); + } + +EXPORT_C TBool CBlankWindow::Check(const CTClient& aClient) +// +// Returns ETrue if the window is Ok, +// EFalse if it is not +// + { + return CheckBlankWindow(TRect(iWin.InquireOffset(*aClient.iGroup->WinTreeNode()),Size()),TRgb::Gray16(iCol.Gray16()),aClient.iScreen); + } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tlib/TLIB.H --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tlib/TLIB.H Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,45 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#ifndef __TLIB_H__ +#define __TLIB_H__ + +#include "testbase.h" + +GLREF_C void TbPanic(TInt aPanic); + +enum TTestBasePanic + { + ETestBasePanicResourceCount, + ETestBasePanicResCountWinFail, + ETestBasePanicResCountWinInit, + ETestBasePanicEventStat, + ETestBasePanicScheduler, + ETestBasePanicKeyParams, + ETestBasePanicInvalidEvent, + ETestBasePanicReadCancelled, + ETestBasePanicUnimplementedBaseFunction, + ETestBasePanicCancelFunction, + ETestBasePanicNullRedraw, + ETestBasePanicNullOwnerWin, + ETestBasePanicWinType, + ETestBasePanicPassword, + EDialogButtonCount, + EDialogButtonIndex, + EDialogDisplay, + ETestBasePanicInvalidHeapAddress, + }; + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tlib/TLSPRITE.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tlib/TLSPRITE.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,223 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Base classes used for building window server test code +// +// + +#include +#include +#include +#include "testbase.h" + +EXPORT_C TSpriteCreateParams::TSpriteCreateParams(TSize aSize,TPoint aOffset,CTSpriteBase::TSpriteDrawFunction aDrawFunc, + TAny *aDrawFuncParam,TBool aMask,CGraphicsContext::TDrawMode aDrawMode) : + iSize(aSize), + iOffset(aOffset), + iDrawFunc(aDrawFunc), + iDrawFuncParam(aDrawFuncParam), + iMask(aMask), + iDrawMode(aDrawMode), + iInterval(0) + {} + +EXPORT_C TSpriteCreateParams::TSpriteCreateParams() : + iDrawFunc(NULL), + iDrawMode(CGraphicsContext::EDrawModePEN), + iInterval(0) + {} + +void CTSpriteBase::CreateBitmapL(CFbsBitmap *&aBitmap, CFbsBitmapDevice *&aBitmapDevice, TSpriteCreateParams *aParams, TBool aDoMask) + { + if (aBitmap==NULL) + { + aBitmap=new(ELeave) CFbsBitmap(); + User::LeaveIfError(aBitmap->Create(aParams->iSize,EGray4)); + } + aBitmapDevice=CFbsBitmapDevice::NewL(aBitmap); + CFbsBitGc *gc=CFbsBitGc::NewL(); + gc->Activate(aBitmapDevice); + aParams->iDrawFunc(gc,0,aParams->iSize,aDoMask,aParams->iDrawFuncParam); + delete gc; + } + +EXPORT_C void CTSpriteBase::RedrawL(CFbsBitmap *&aBitmap, CFbsBitmap *&aMaskBitmap, TSpriteCreateParams *aParams) + { + CFbsBitmapDevice *bitmapDevice=NULL; + TRAPD(err,CreateBitmapL(aBitmap,bitmapDevice,aParams,EFalse)); + if (err==KErrNone) + { + delete bitmapDevice; + bitmapDevice=NULL; + if (aMaskBitmap) + { + TRAP(err,CreateBitmapL(aMaskBitmap,bitmapDevice,aParams,ETrue)); + delete bitmapDevice; + } + SpriteBase().UpdateMember(0); + } + User::LeaveIfError(err); + } + +EXPORT_C void CTSpriteBase::UpdateL(TInt aIndex, TSpriteCreateParams *aParams) + { + CFbsBitmap *bitmap=NULL; + CFbsBitmapDevice *bitmapDevice=NULL; + TRAPD(err,CreateBitmapL(bitmap,bitmapDevice,aParams,EFalse)); + if (err==KErrNone) + { + delete bitmapDevice; + bitmapDevice=NULL; + CFbsBitmap *mask=NULL; + if (aParams->iMask) + TRAP(err,CreateBitmapL(mask,bitmapDevice,aParams,ETrue)); + if (err==KErrNone) + { + TSpriteMember sprite; + sprite.iBitmap=bitmap; + sprite.iMaskBitmap=mask; + sprite.iInvertMask=EFalse; + sprite.iDrawMode=aParams->iDrawMode; + sprite.iInterval=aParams->iInterval; + sprite.iOffset=aParams->iOffset; + err=SpriteBase().UpdateMember(aIndex,sprite); + } + delete mask; + } + delete bitmap; + delete bitmapDevice; + User::LeaveIfError(err); + } + +EXPORT_C CTSprite::CTSprite(RWsSession &aWs) : iSprite(aWs) + { + } + +EXPORT_C CTSprite::~CTSprite() + { + iSprite.Close(); + } + +EXPORT_C RWsSpriteBase &CTSprite::SpriteBase() + { + return(iSprite); + } + +EXPORT_C RWsSprite &CTSprite::Sprite() + { + return(iSprite); + } + +EXPORT_C void CTSprite::ConstructL(RWindowTreeNode &aWindow, const TPoint &aPos, TInt aCount, TSpriteCreateParams *aParams, TInt aFlags) + { + User::LeaveIfError(iSprite.Construct(aWindow,aPos,aFlags)); + for(TInt index=0;indexiMask) + TRAP(err,CreateBitmapL(mask,bitmapDevice,aParams,ETrue)); + if (err==KErrNone) + { + TSpriteMember sprite; + sprite.iBitmap=bitmap; + sprite.iMaskBitmap=mask; + sprite.iInvertMask=EFalse; + sprite.iDrawMode=aParams->iDrawMode; + sprite.iOffset=aParams->iOffset; + sprite.iInterval=aParams->iInterval; + err=iSprite.AppendMember(sprite); + } + } + delete mask; + delete bitmap; + delete bitmapDevice; + User::LeaveIfError(err); + } + User::LeaveIfError(iSprite.Activate()); + } + +EXPORT_C CTPointerCursor::CTPointerCursor(RWsSession &aWs) : iCursor(aWs) + { + } + +EXPORT_C CTPointerCursor::~CTPointerCursor() + { + iCursor.Close(); + } + +EXPORT_C RWsSpriteBase &CTPointerCursor::SpriteBase() + { + return(iCursor); + } + +EXPORT_C RWsPointerCursor &CTPointerCursor::PointerCursor() + { + return(iCursor); + } + +EXPORT_C void CTPointerCursor::ConstructL(TInt aFlags) + { + User::LeaveIfError(iCursor.Construct(aFlags)); + TSpriteMember sprite; + sprite.iBitmap=NULL; + User::LeaveIfError(iCursor.AppendMember(sprite)); + } + +EXPORT_C void CTPointerCursor::ConstructL(TInt aCount, TSpriteCreateParams *aParams, TInt aFlags) + { + CFbsBitmap *bitmap=NULL; + CFbsBitmap *mask=NULL; + TRAPD(err,ConstructL(aCount, aParams, aFlags, bitmap, mask)); + delete bitmap; + delete mask; + User::LeaveIfError(err); + } + +EXPORT_C void CTPointerCursor::ConstructL(TInt aCount, TSpriteCreateParams *aParams, TInt aFlags, CFbsBitmap *&aBitmap, CFbsBitmap *&aMaskBitmap) + { + User::LeaveIfError(iCursor.Construct(aFlags)); + for(TInt index=0;indexiMask) + TRAP(err,CreateBitmapL(aMaskBitmap,bitmapDevice,aParams,ETrue)); + if (err==KErrNone) + { + TSpriteMember sprite; + sprite.iBitmap=aBitmap; + sprite.iMaskBitmap=aMaskBitmap; + sprite.iInvertMask=EFalse; + sprite.iDrawMode=aParams->iDrawMode; + sprite.iInterval=aParams->iInterval; + sprite.iOffset=aParams->iOffset; + err=iCursor.AppendMember(sprite); + } + } + delete bitmapDevice; + bitmapDevice=NULL; + User::LeaveIfError(err); + } + User::LeaveIfError(iCursor.Activate()); + } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tlib/testbase.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tlib/testbase.h Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,562 @@ +// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Base classes definitions used for building window server test code +// +// + +#ifndef __TESTBASE_H__ +#define __TESTBASE_H__ + +enum TTlibActivePriorities + { + ETlibRedrawActivePriority=-10, + ETlibWsEventActivePriority=0, + }; + +const TInt KDefaultScreen = 0; + +//enum {ENullWsHandle=0xFFFFFFFF}; // Events delivered to this handle are thrown away +const TUint32 ENullWsHandle=0xFFFFFFFF; // Events delivered to this handle are thrown away + +typedef TBuf TWindowTitle; +typedef TBuf<0x100> TWinCommand; + +const TUid KUidWServSecurityTesting={0x10205152}; +enum TWServSecTest + { + EWServSecTestBufferSecurity + }; + +class CTClient; // Forward reference +class CTWindowGroup; +class CTBaseWin; +class CTWin; + +typedef CTClient *(*TCreateClientFunc)(); + +IMPORT_C TBool CheckBlankWindow(TRect aArea,TRgb aColor,const CWsScreenDevice* aScreen); + +class CTWinBase : public CBase + { +protected: +public: + IMPORT_C CTWinBase(TInt aType); + IMPORT_C virtual TPoint Position() const; + IMPORT_C virtual void PointerEnter(const TTime &aTime); + IMPORT_C virtual void PointerExit(const TTime &aTime); + IMPORT_C virtual void PointerBufferReady(const TTime &aTime); + IMPORT_C virtual void PointerL(const TPointerEvent &aPointer,const TTime &aTime); + IMPORT_C virtual void SwitchOn(const TTime &aTime); + IMPORT_C virtual void ModifiersChanged(const TModifiersChangedEvent &aModifiersChanged ,const TTime &aTime); + IMPORT_C virtual void ErrorMessage(const TWsErrorMessage &aErrorMessage, const TTime &aTime); + IMPORT_C virtual void SetVisible(TBool aState); + IMPORT_C CTWinBase *Parent() const; + IMPORT_C CTWinBase *NextSibling() const; + IMPORT_C CTWinBase *PrevSibling() const; + IMPORT_C CTBaseWin *Child() const; + IMPORT_C virtual void AdjustOrdinal(TInt adjust); + IMPORT_C virtual void AdjustShadow(TInt aAdjust); + IMPORT_C virtual TInt SubType(); +// Pure virtual definitions + virtual void WinKeyL(const TKeyEvent &aKey,const TTime &aTime)=0; + virtual TSize Size() const=0; + virtual RWindowTreeNode *WinTreeNode()=0; + virtual const RWindowTreeNode *WinTreeNode() const=0; + IMPORT_C virtual CTClient *Client() const; + virtual CTWindowGroup *Group() const=0; + CTWindowGroup *iOwnerWin; +public: + TInt iType; + __DECLARE_TEST; + }; + +class CTBaseWin : public CTWinBase + { +public: + IMPORT_C CTBaseWin(TInt aType); + IMPORT_C ~CTBaseWin(); + IMPORT_C virtual void ConstructL(CTWinBase &parent); + IMPORT_C virtual void ConstructExtLD(CTWinBase &aParent, const TPoint &aPos, const TSize &aSize); + virtual TInt ConstructWin(const CTWinBase &aWs)=0; + IMPORT_C virtual void InitWin(); + IMPORT_C virtual void PointerL(const TPointerEvent &aPointer,const TTime &aTime); + IMPORT_C virtual void DragDropL(const TPointerEvent &aPointer,const TTime &aTime); + IMPORT_C virtual void RelinquishFocus(); + IMPORT_C void Activate(); + IMPORT_C virtual void AssignGC(CWindowGc &aGc); + IMPORT_C CTBaseWin *Next(); + IMPORT_C CTBaseWin *Prev(); + IMPORT_C virtual void SetExtL(const TPoint &aPos, const TSize &aSize); + IMPORT_C virtual void SetSizeL(const TSize &aSize); + IMPORT_C virtual void SetPos(const TPoint &aPos); + IMPORT_C void SetInitialPos(const TPoint &aPos); + IMPORT_C virtual void SetDefaultExtL(); + IMPORT_C virtual void SetFullScreenExtL(); + IMPORT_C virtual void AdjustSizeL(TInt xMove,TInt yMove,TInt resize); + IMPORT_C virtual TSize Size() const; + IMPORT_C virtual void Draw(); + IMPORT_C void DrawBorder(); +// void FillWindow(TInt inset); + IMPORT_C virtual TPoint Position() const; + IMPORT_C static void Delete(CTBaseWin *aWin); + IMPORT_C void AdjustOrdinal(TInt aAdjust); + IMPORT_C virtual void AdjustShadow(TInt aAdjust); + IMPORT_C void SetVisible(TBool aState); + IMPORT_C RWindowTreeNode *WinTreeNode(); + IMPORT_C const RWindowTreeNode *WinTreeNode() const; + IMPORT_C virtual void WinKeyL(const TKeyEvent &aKey,const TTime &aTime); + IMPORT_C virtual void KeyUpL(const TKeyEvent &aKey,const TTime &aTime); + IMPORT_C virtual void KeyDownL(const TKeyEvent &aKey,const TTime &aTime); + IMPORT_C virtual void SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc); + IMPORT_C virtual void SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc, TDisplayMode *aMode); + IMPORT_C void SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc,TBool aVisible); + enum + { + ENoTransparency=0x100 + }; + IMPORT_C virtual void SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc, TDisplayMode *aMode,TBool aVisible,TInt aTransparency=ENoTransparency); + IMPORT_C void SetDragRect(const TRect &aRect); + IMPORT_C virtual void Resized(const TSize &aSize); + IMPORT_C virtual void FocusChanged(TBool aState); + IMPORT_C virtual CTWindowGroup *Group() const; + virtual RWindowBase *BaseWin()=0; + virtual const RWindowBase *BaseWin() const=0; + inline CWindowGc *Gc(); +protected: + TSize iSize; + CWindowGc *iGc; // Not owned by the window, just using it + TPoint iPos; + TInt iShadow; + TRect iDragRect; + TBool iDragging; + TPoint iDragPos; + CFbsFont *iFont; + __DECLARE_TEST; + }; + +class CTDrawableWin : public CTBaseWin + { +public: + IMPORT_C CTDrawableWin(TInt aType); + virtual RDrawableWindow *DrawableWin()=0; + virtual const RDrawableWindow *DrawableWin() const=0; + }; + +class CTWin : public CTDrawableWin + { +public: + IMPORT_C CTWin(); + IMPORT_C ~CTWin(); + inline RWindow *Win() const; + IMPORT_C virtual TInt ConstructWin(const CTWinBase &aWs); + IMPORT_C void Invalidate(); + IMPORT_C void Invalidate(const TRect &rect); + IMPORT_C virtual void Redraw(); + IMPORT_C virtual void Redraw(const TRect &aRect); + IMPORT_C void DrawNow(); + IMPORT_C void SetExt(const TPoint &aPos, const TSize &aSize); + IMPORT_C void SetSize(const TSize &aSize); + IMPORT_C void SetDefaultExt(); + IMPORT_C void AdjustSize(TInt xMove,TInt yMove,TInt resize); + IMPORT_C virtual RWindowBase *BaseWin(); + IMPORT_C virtual const RWindowBase *BaseWin() const; + IMPORT_C virtual RDrawableWindow *DrawableWin(); + IMPORT_C virtual const RDrawableWindow *DrawableWin() const; +protected: + RWindow iWin; + __DECLARE_TEST; + }; + +class CTBackedUpWin : public CTDrawableWin + { +public: + IMPORT_C CTBackedUpWin(TDisplayMode aDisplayMode); + IMPORT_C ~CTBackedUpWin(); + IMPORT_C virtual TInt ConstructWin(const CTWinBase &aWs); + IMPORT_C virtual RWindowBase *BaseWin(); + IMPORT_C virtual const RWindowBase *BaseWin() const; + IMPORT_C virtual RDrawableWindow *DrawableWin(); + IMPORT_C virtual const RDrawableWindow *DrawableWin() const; + IMPORT_C RBackedUpWindow *BackedUpWin(); + IMPORT_C const RBackedUpWindow *BackedUpWin() const; +protected: + RBackedUpWindow iWin; + TDisplayMode iDisplayMode; + __DECLARE_TEST; + }; + +class CTTitledWindow : public CTWin + { +public: + IMPORT_C CTTitledWindow(); + IMPORT_C ~CTTitledWindow(); + IMPORT_C void ConstructL(CTWinBase &parent); + IMPORT_C void Draw(); + IMPORT_C void FocusChanged(TBool aState); + IMPORT_C void SetTitle(const TWindowTitle &aTitle); + IMPORT_C void SetColor(TRgb aRgb); + inline TRgb Color(); +private: + IMPORT_C void Resized(const TSize &aSize); +protected: + TWindowTitle iTitle; + TInt iTitleHeight; + TBool iFocus; + TRgb iWinColor; + TRgb iPenColor; + }; + +class CTBlankWindow : public CTBaseWin + { +public: + IMPORT_C CTBlankWindow(); + IMPORT_C ~CTBlankWindow(); + IMPORT_C void ConstructL(CTWinBase &aParent); + IMPORT_C void SetColor(const TRgb &aRgb); + IMPORT_C virtual TInt ConstructWin(const class CTWinBase&); + IMPORT_C virtual const RWindowBase *BaseWin()const; + IMPORT_C virtual RWindowBase *BaseWin(); + inline const RBlankWindow *BlankWin()const; + inline RBlankWindow *BlankWin(); + IMPORT_C void SetExt(const TPoint &aPos, const TSize &aSize); + IMPORT_C void SetSize(const TSize &aSize); +protected: + RBlankWindow iWin; + }; + +class CTWindowGroup : public CTWinBase + { +public: + IMPORT_C CTWindowGroup(CTClient *aClient); + IMPORT_C ~CTWindowGroup(); + IMPORT_C virtual void ConstructL(); + IMPORT_C void WinKeyL(const TKeyEvent &aKey,const TTime &aTime); + IMPORT_C virtual TSize Size() const; + IMPORT_C RWindowTreeNode *WinTreeNode(); + IMPORT_C const RWindowTreeNode *WinTreeNode() const; + inline RWindowGroup *GroupWin(); + IMPORT_C virtual void KeyL(const TKeyEvent &aKey,const TTime &aTime); + IMPORT_C virtual void KeyUpL(const TKeyEvent &aKey,const TTime &aTime); + IMPORT_C virtual void KeyDownL(const TKeyEvent &aKey,const TTime &aTime); + IMPORT_C virtual void PasswordL(const TTime &aTime); + IMPORT_C virtual void MessageReady(const TWsEvent &aTime); + IMPORT_C virtual void ScreenDeviceChanged(); + IMPORT_C virtual void UserEvent(TInt aEventType); + IMPORT_C void SetCurrentWindow(CTBaseWin *aWindow); + IMPORT_C void SetCurrentWindow(CTBaseWin *aWindow,TBool aLocked); + IMPORT_C CTBaseWin *CurWin(void) const; + IMPORT_C void FocusLost(); + IMPORT_C void FocusGained(); + IMPORT_C TBool HasFocus(CTBaseWin *aWin) const; + IMPORT_C virtual CTWindowGroup *Group() const; + IMPORT_C virtual CTClient *Client() const; + IMPORT_C void ClearCurrentWindow(); +protected: + CTClient *iClient; + CTBaseWin *iCurWin; + RWindowGroup iGroupWin; + TBool iLocked; + TBool iFocus; + }; + +inline RWindowGroup *CTWindowGroup::GroupWin() + {return(&iGroupWin);} + +class CTEventBase : public CActive + { +public: + IMPORT_C CTEventBase(RWsSession *aWs, TInt aPriority); + IMPORT_C ~CTEventBase(); + IMPORT_C void Construct(); + void SetCancelFunction(const TCallBack &aCallBack); + virtual void Request()=0; + inline TInt Count() {return iCount;} +protected: + virtual void doRunL()=0; + IMPORT_C void RunL(); + IMPORT_C void CancelHandler(); +protected: + TBool iCancelRequested; + TCallBack iCancelCallBack; + RWsSession *iWs; + TInt iCount; + }; + +class CTRedraw : public CTEventBase + { +public: + IMPORT_C CTRedraw(RWsSession *aWs); + IMPORT_C ~CTRedraw(); + IMPORT_C void Request(); +protected: + IMPORT_C void DoCancel(); + IMPORT_C void doRunL(); + }; + +class TlibWsEvent : public TWsEvent + { +public: + IMPORT_C CTWindowGroup *WindowGroup(); + IMPORT_C CTBaseWin *BaseWin(); + }; + +class CTEvent : public CTEventBase + { +public: + IMPORT_C CTEvent(RWsSession *aWs); + IMPORT_C ~CTEvent(); + IMPORT_C void Request(); + IMPORT_C virtual void LogEvent(const TWsEvent &aEvent); +protected: + IMPORT_C void DoCancel(); + IMPORT_C void doRunL(); + }; + +class CTClient : public CBase + { +public: + IMPORT_C CTClient(); + IMPORT_C ~CTClient(); + IMPORT_C virtual void ConstructL(); + IMPORT_C virtual void ConstructEventHandlerL(); + IMPORT_C void DestroyWindows(); + IMPORT_C TWindowTitle *Title(); + IMPORT_C void ResetFocus(); + IMPORT_C TBool QueueRead(); + IMPORT_C void CancelRead(); + IMPORT_C void CancelRedrawRead(); + IMPORT_C void SetCancelFunction(const TCallBack &aCallBack); + IMPORT_C void SetRedrawCancelFunction(const TCallBack &aCallBack); + IMPORT_C void RequestRedraw(); + IMPORT_C void LogMessage(const TLogMessageText &aMessage); + inline void Flush() {iWs.Flush();} + inline void SetScreenNumber(TInt aScreenNumber); + IMPORT_C TBool IsEventWaiting(); + IMPORT_C TBool WaitUntilEventPending(); + IMPORT_C TBool WaitUntilRedrawPending(); + inline CTEvent* EventHandler(); + inline CTRedraw* RedrawHandler(); + IMPORT_C TInt WaitForRedrawsToFinish(); + IMPORT_C TInt WaitForAllEventProcessingToFinish(); +private: + TBool WaitUntilEventPending(const TRequestStatus& aStatus); + TInt WaitForEventsToFinish(TBool aAll); +protected: + CTEvent *iEventHandler; + CTRedraw *iRedrawEventHandler; +public: + CWindowGc *iGc; + CTWindowGroup *iGroup; + RWsSession iWs; + CWsScreenDevice *iScreen; +protected: + TWindowTitle iTitle; + TInt iScreenNumber; + }; + +class CTAutoKey; +class CTDialog : public CTTitledWindow + { +public: + enum + { + EDialogWaitForButtonUp=0x0001, + EDialogDisplayAtBottom=0x0002, + EDialogDisplayAtLeft=0x0008, + }; +public: + IMPORT_C CTDialog(); + IMPORT_C ~CTDialog(); + IMPORT_C void ConstructLD(CTWinBase &aParent, CWindowGc &aGc); + IMPORT_C void Draw(); + IMPORT_C void WinKeyL(const TKeyEvent &aKey,const TTime &aTime); + IMPORT_C void PointerL(const TPointerEvent &aPointer,const TTime &aTime); + IMPORT_C virtual void ButtonPressL(TInt aButton); + IMPORT_C void SetLine1(const TDesC &aLine1); + IMPORT_C void SetLine2(const TDesC &aLine2); + IMPORT_C void SetNumButtons(TInt aNum); + IMPORT_C void SetButtonText(TInt aNum,const TDesC &aButton); + IMPORT_C void SetWindowSize(); + IMPORT_C void RelinquishFocus(); + IMPORT_C TInt Display(); + IMPORT_C void SetFlags(TUint aFlags); +protected: + void SetResult(TInt aButton); + inline void SetTakeFocus() {iTakeFocus=ETrue;} +private: + void SetMaxWid(TInt &aMax, TInt aWid); + TRect ButtonRect(TInt aIndex) const; +private: + TBool iIsActive; + TBool iActivated; + TBool iWinActive; + TBool iTakeFocus; + TInt iNumButtons; + TInt iButWid; + CTBaseWin *iOldFocus; + TInt *iResultPtr; + TBuf<0x40> iLine1; + TBuf<0x40> iLine2; + TBuf<0x20> iButton[3]; + TInt iButtonClickOn; + TUint iFlags; + CTAutoKey* iAutoKey; + }; + +class CInfoDialog : public CTDialog + { +private: + enum + { + eSeconds=1000000, + eTimes=6, + }; +public: + IMPORT_C CInfoDialog(CTWindowGroup *aGroupWin,CWindowGc *aGc); + IMPORT_C void ConstructLD(); + IMPORT_C void TimerResults(); + //Virtual function from CTDialog + IMPORT_C void ButtonPressL(TInt aButton); +private: + void AppendProfileTime(TDes &aDes, TInt aNum); + void AppendProfileCount(TDes &aDes, TInt aNum); + void AddComma(TDes &aDes); +private: + CTWindowGroup *iGroupWin; + CWindowGc *iGc; + }; + +class CEventWindow : public CTWin + { +public: + IMPORT_C CEventWindow(TInt aLogSize); + IMPORT_C ~CEventWindow(); + IMPORT_C void ConstructL(CTWinBase &parent); + IMPORT_C void SetUpL(const TPoint &pos, CTWinBase *parent, CWindowGc &aGc); + IMPORT_C void Draw(); + IMPORT_C void WinKeyL(const TKeyEvent &,const TTime &aTime); + IMPORT_C void LogEvent(const TWsEvent &aEvent); +private: + void DrawLine(TInt aLine, const TDesC &aText); + void LogEvent(TInt aLogNum, const TWsEvent &aEvent); +private: + TInt iLineHeight; + TInt iCount; + TInt iLogSize; + TInt iNumLogged; + TWsEvent *iLoggedEvents; + }; + +class CBlankWindow : public CTWin + { +public: + IMPORT_C CBlankWindow(TRgb aCol); + IMPORT_C CBlankWindow(); + IMPORT_C void ConstructL(CTWinBase &parent); + IMPORT_C void SetColor(TRgb aColor); + IMPORT_C void RealDraw(TBool aRealDraw); + IMPORT_C virtual void Draw(); + IMPORT_C void DrawNow(); + IMPORT_C void DrawNow(TRect& aRect); + IMPORT_C TBool Check(const CTClient& aClient); +protected: + TRgb iCol; + TBool iRealDraw; + }; + +struct TSpriteCreateParams; + +class CTSpriteBase : public CBase + { +public: + typedef void (*TSpriteDrawFunction)(CBitmapContext *aGc,TInt aIndex, const TSize &aSize, TBool aDoMask, TAny *aParam); +protected: + virtual RWsSpriteBase &SpriteBase()=0; + void CreateBitmapL(CFbsBitmap *&aBitmap, CFbsBitmapDevice *&aBitmapDevice, TSpriteCreateParams *aParams, TBool aDoMask); +public: + IMPORT_C void UpdateL(TInt aIndex, TSpriteCreateParams *aParams); + IMPORT_C void RedrawL(CFbsBitmap *&aBitmap, CFbsBitmap *&aMaskBitmap, TSpriteCreateParams *aParams); + }; + +class CTSprite : public CTSpriteBase + { +public: + IMPORT_C CTSprite(RWsSession &aWs); + IMPORT_C ~CTSprite(); + IMPORT_C void ConstructL(RWindowTreeNode &aWindow, const TPoint &aPos, TInt aCount, TSpriteCreateParams *aParams, TInt aFlags); + IMPORT_C RWsSpriteBase &SpriteBase(); + IMPORT_C RWsSprite &Sprite(); +private: + RWsSprite iSprite; + }; + +class CTPointerCursor : public CTSpriteBase + { +public: + IMPORT_C CTPointerCursor(RWsSession &aWs); + IMPORT_C ~CTPointerCursor(); + IMPORT_C void ConstructL(TInt aFlags); + IMPORT_C void ConstructL(TInt aCount, TSpriteCreateParams *aParams, TInt aFlags, CFbsBitmap *&aBitmap, CFbsBitmap *&aMaskBitmap); + IMPORT_C void ConstructL(TInt aCount, TSpriteCreateParams *aParams, TInt aFlags); + IMPORT_C RWsSpriteBase &SpriteBase(); + IMPORT_C RWsPointerCursor &PointerCursor(); +private: + RWsPointerCursor iCursor; + }; + +struct TSpriteCreateParams + { +public: + IMPORT_C TSpriteCreateParams(TSize aSize,TPoint aOffset,CTSpriteBase::TSpriteDrawFunction aDrawFunc,TAny *aDrawFuncParam=NULL, TBool aMask=ETrue,CGraphicsContext::TDrawMode aDrawMode=CGraphicsContext::EDrawModePEN); + IMPORT_C TSpriteCreateParams(); +public: + TSize iSize; + TPoint iOffset; + CTSpriteBase::TSpriteDrawFunction iDrawFunc; + TAny *iDrawFuncParam; + TBool iMask; + CGraphicsContext::TDrawMode iDrawMode; + TTimeIntervalMicroSeconds32 iInterval; + }; + +class CTUser + { +public: + IMPORT_C static void Splat(CTClient *aClient, const TRect &aRect, const TRgb &aRgb); + }; + +IMPORT_C void DisplayDialog(const TWindowTitle &aTitle, const TDesC &aLine1, const TDesC &aLine2, const RWindowGroup *aGroup=NULL); +IMPORT_C void DisplayDialog(TInt aScreenNumber,const TWindowTitle &aTitle, const TDesC &aLine1, const TDesC &aLine2, const RWindowGroup *aGroup=NULL); +IMPORT_C void DisplayDialog(CTClient *aClient, const TWindowTitle &aTitle, const TDesC &aLine1, const TDesC &aLine2); +IMPORT_C TInt TestLibStartUp(TCreateClientFunc aFunc); +IMPORT_C TInt TestLibStartUp(TCreateClientFunc aFunc,TInt aScreenNumber); + + +inline TRgb CTTitledWindow::Color() + {return(iWinColor);} +inline CWindowGc *CTBaseWin::Gc() + {return(iGc);} +inline RWindow *CTWin::Win() const + {return((RWindow *)BaseWin());} +inline const RBlankWindow *CTBlankWindow::BlankWin()const + {return(&iWin);} +inline RBlankWindow *CTBlankWindow::BlankWin() + {return(&iWin);} +inline void CTClient::SetScreenNumber(TInt aScreenNumber) + {iScreenNumber=aScreenNumber;} +inline CTEvent* CTClient::EventHandler() + {return iEventHandler;} +inline CTRedraw* CTClient::RedrawHandler() + {return iRedrawEventHandler;} +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tlisten/listener.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tlisten/listener.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,380 @@ +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include "listener.h" +#include "wsgraphicdrawercontext.h" +#include +#include +#include +#include +#ifdef __WINS__ +#include "../debuglog/osbwin.h" +#endif + +const TInt KDefaultScreen = 0; +const TInt KListenDisable = 0; +const TInt KListenEnable = 1; +const TInt KCmdQuery = 2; + +const TUint8 KListenerInfoSig = 0xaa; + +NONSHARABLE_STRUCT(TListenerInfo) + { + TUint8 iSignature; + TInt iNumRect; + TRect iRect; + TInt iWindowGroupId; + }; + +const TInt KMaxColors = 14; +const TInt KColorList[KMaxColors] = + { + 0x555555, + 0x000080, + 0x008000, + 0x008080, + 0x800000, + 0x800080, + 0x808000, + 0x0000ff, + 0x00ff00, + 0x00ffff, + 0xff0000, + 0xff00ff, + 0xffff00, + 0xaaaaaa + }; + +CWsEventListener* CWsEventListener::NewL() + { + return new(ELeave) CWsEventListener; + } + +CWsEventListener::~CWsEventListener() + { + if (iEnabled) + Env().UnregisterEventHandler(this); + +#ifdef __WINS__ + if (!iDisableWin) + delete iWin; +#endif + delete iGc; + delete iDev; + delete iBit; + + if (iDrawerContext) + { + iDrawerContext->Destroy(); + iDrawerContext = NULL; + } + } + +void CWsEventListener::ConstructL(MWsGraphicDrawerEnvironment& aEnv, const TGraphicDrawerId& aId, MWsClient& aOwner, const TDesC8& aData) + { + BaseConstructL(aEnv, aId, aOwner); + +#ifdef __WINS__ + if (aData.Length()>0) + iDisableWin = aData[0]==1; +#endif + + iScreen = aEnv.Screen(KDefaultScreen); + MWsScreenConfig* screenConfig = iScreen->ObjectInterface(); + if (screenConfig) + {// Non NGA + iSize = screenConfig->SizeInPixels(); + iDisplayMode = screenConfig->DisplayMode(); + iDrawerContext = CWsGraphicDrawerNonNgaContext::NewL(); + } + else + {// NGA + MWsScreenDevice* screenDevice = iScreen->ObjectInterface(); + User::LeaveIfNull(screenDevice); + iSize = screenDevice->SizeInPixels(); + iDisplayMode = screenDevice->DisplayMode(); + iDrawerContext = CWsGraphicDrawerNgaContext::NewL(); + } + + iWindowGroupId = KErrNotFound; + + iBit = new(ELeave) CFbsBitmap; + User::LeaveIfError(iBit->Create(iSize,iDisplayMode)); + iDev = CFbsBitmapDevice::NewL(iBit); + User::LeaveIfNull(iDev); + User::LeaveIfError(iDev->CreateContext(iGc)); + iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + iGc->SetPenStyle(CGraphicsContext::ENullPen); + +#ifdef __WINS__ + if (!iDisableWin) + { + _LIT(KListener, "EventListener"); + iWin = CDebugOsbWin::NewL(KListener, iBit->SizeInPixels()); + } +#endif + iReady = ETrue; + } + +void CWsEventListener::HandleMessage(const TDesC8& aData) + { + // wserv already check data size, and won't invoke this handler if it's empty + switch (aData[0]) + { + case KListenEnable: + if (!iEnabled) + { + Env().RegisterEventHandler(this, this, TWservCrEvent::EScreenSizeModeChanged|TWservCrEvent::EWindowVisibilityChanged|TWservCrEvent::EWindowGroupChanged); + iEnabled = ETrue; + } + break; + + case KListenDisable: + if (iEnabled) + { + iEnabled = EFalse; + Env().UnregisterEventHandler(this); + } + break; + + case KCmdQuery: + SendInfo(); + break; + } + } + +void CWsEventListener::DoHandleEvent(const TWservCrEvent& aEvent) + { + if (!iReady) + return; + + switch (aEvent.Type()) + { + case TWservCrEvent::EScreenSizeModeChanged: + OnScreenSizeModeChanged(aEvent.SizeMode()); + break; + + case TWservCrEvent::EWindowVisibilityChanged: + OnWindowVisibilityChanged(aEvent.VisibleRegion()); + break; + + case TWservCrEvent::EWindowGroupChanged: + OnWindowGroupChanged(aEvent.ScreenNumber(), aEvent.WindowGroupIdentifier()); + break; + } + } + +void CWsEventListener::DoDraw(MWsGc& aGc, const TRect& aRect, const TDesC8& /*aData*/) const + { + iDrawerContext->DrawEllipse(aGc, aRect, TRgb(0,255,0,128)); + } + +void CWsEventListener::OnScreenSizeModeChanged(TInt /*aMode*/) + { + iGc->SetBrushColor(KRgbWhite); + iGc->Clear(); + +#ifdef __WINS__ + if (!iDisableWin) + { + iBit->LockHeap(); + iWin->Refresh(iBit->SizeInPixels(), iBit->DisplayMode(), iBit->DataAddress()); + iBit->UnlockHeap(); + } +#endif + } + +TRgb CWsEventListener::CurrentColor() + { + iColorIdx = (iColorIdx+1) % KMaxColors; + return TRgb(KColorList[iColorIdx]); + } + +void CWsEventListener::OnWindowVisibilityChanged(const RRegion* aRegion) + { + if (!aRegion) + return; + + TInt n = aRegion->Count(); + if (n==0) + return; + iGc->SetBrushColor(CurrentColor()); + for (TInt i=0; iDrawRect((*aRegion)[i]); + } + + iSaveNumRect = n; + iSaveRect = (*aRegion)[0]; + +#ifdef __WINS__ + if (!iDisableWin) + { + iBit->LockHeap(); + iWin->Refresh(iBit->SizeInPixels(), iBit->DisplayMode(), iBit->DataAddress()); + iBit->UnlockHeap(); + } +#endif + } + +void CWsEventListener::OnWindowGroupChanged(TInt /*aScreenNumber*/, TInt aWindowGroupId) + { + iWindowGroupId = aWindowGroupId; + } + +void CWsEventListener::SendInfo() + { + TPckgBuf buf; + buf().iSignature = KListenerInfoSig; + buf().iNumRect = iSaveNumRect; + buf().iRect = iSaveRect; + buf().iWindowGroupId = iWindowGroupId; + TInt err = SendMessage(buf); + __ASSERT_ALWAYS(err>=KErrNone, User::Invariant()); + iSaveNumRect = 0; + iSaveRect = TRect(); + } + +CWsEventNotifier* CWsEventNotifier::NewL() + { + return new(ELeave) CWsEventNotifier; + } + +CWsEventNotifier::~CWsEventNotifier() + { + Env().UnregisterEventHandler(this); + } + +void CWsEventNotifier::ConstructL(MWsGraphicDrawerEnvironment& aEnv, const TGraphicDrawerId& aId, MWsClient& aOwner, const TDesC8& /*aData*/) + { + BaseConstructL(aEnv, aId, aOwner); + iEnv = &aEnv; + iTestGraphicDrawerEnvironment = EFalse; + iReady = ETrue; + } + +void CWsEventNotifier::HandleMessage(const TDesC8& aData) + { + // wserv already checked data size, and won't invoke this handler if it's empty + switch (aData[0]) + { //Set how it will handle the first visibility event + case KNotifyRemoveSelf: + case KNotifyRemoveThenAddSelf: + case KNotifyAddSelf: + case KNotifyRemoveOther: + case KNotifyRemoveThenAddOther: + case KNotifyAddOther: + case KNotifyRemoveSelfAndOther: + case KNotifyDoNothing: + Env().RegisterEventHandler(this, this, TWservCrEvent::EWindowVisibilityChanged); + iHandleMethod = aData[0]; + break; + case KNotifyDisable: + Env().UnregisterEventHandler(this); + iHandleMethod = KNotifyDoNothing; + break; + default: + break; + } + } + +void CWsEventNotifier::DoHandleEvent(const TWservCrEvent& /*aEvent*/) + { + if(!iTestGraphicDrawerEnvironment) + { + iTestGraphicDrawerEnvironment = ETrue; + TestGraphicDrawerEnvironment(); + } + + if (iHandleMethod == KNotifyRemoveSelf) + { + Env().UnregisterEventHandler(this); + iHandleMethod = KNotifyDoNothing; + } + else if (iHandleMethod == KNotifyRemoveThenAddSelf) + { + Env().UnregisterEventHandler(this); + Env().RegisterEventHandler(this, this, TWservCrEvent::EWindowVisibilityChanged); + iHandleMethod = KNotifyDoNothing; + } + else if (iHandleMethod == KNotifyAddSelf) + { + Env().RegisterEventHandler(this, this, TWservCrEvent::EWindowVisibilityChanged); + iHandleMethod = KNotifyDoNothing; + } + else if (iHandleMethod == KNotifyRemoveOther) + { + iAnotherPluginID.iId = 0x102754c5; //First method that needs the address of the other plugin + iAnotherPluginID.iIsUid = ETrue; + iAnotherPlugin = const_cast(Env().ResolveGraphic(iAnotherPluginID)); + Env().UnregisterEventHandler(iAnotherPlugin); + iHandleMethod = KNotifyDoNothing; + } + else if (iHandleMethod == KNotifyRemoveThenAddOther) + { + Env().UnregisterEventHandler(iAnotherPlugin); + Env().RegisterEventHandler(iAnotherPlugin, this, TWservCrEvent::EWindowVisibilityChanged); + iHandleMethod = KNotifyDoNothing; + } + else if (iHandleMethod == KNotifyAddOther) + { + Env().RegisterEventHandler(iAnotherPlugin, this, TWservCrEvent::EWindowVisibilityChanged); + iHandleMethod = KNotifyDoNothing; + } + else if (iHandleMethod == KNotifyRemoveSelfAndOther) + { + Env().UnregisterEventHandler(this); + Env().UnregisterEventHandler(iAnotherPlugin); + iHandleMethod = KNotifyDoNothing; + } + } + +void CWsEventNotifier::DoDraw(MWsGc& /*aGc*/, const TRect& /*aRect*/, const TDesC8& /*aData*/) const + { + } + +void CWsEventNotifier::TestGraphicDrawerEnvironment() + { + const MWsGraphicDrawerEnvironment* aEnvConst = iEnv; + TInt lowerbound = -1; + //-tests Screen methods (const and non const) + __ASSERT_ALWAYS(iEnv->Screen(lowerbound)==NULL, SendMessage(_L8("Error:iEnv->Screen(lowerbound) - expected: NULL, actual: !NULL (listener.cpp)"))); + __ASSERT_ALWAYS(iEnv->Screen(iEnv->ScreenCount())==NULL, SendMessage(_L8("Error:iEnv->Screen(iEnv->ScreenCount()) - expected: NULL, actual: !NULL (listener.cpp)"))); + __ASSERT_ALWAYS(aEnvConst->Screen(lowerbound)==NULL, SendMessage(_L8("Error:aEnvConst->Screen(lowerbound) - expected: NULL, actual: !NULL (listener.cpp)"))); + __ASSERT_ALWAYS(aEnvConst->Screen(aEnvConst->ScreenCount())==NULL, SendMessage(_L8("Error:aEnvConst->ScreenCount()) - expected: NULL, actual: !NULL (listener.cpp)"))); + //+test const screen method + const MWsScreen* constScreen = aEnvConst->Screen(aEnvConst->ScreenCount()-1); + __ASSERT_ALWAYS(constScreen!=NULL, SendMessage(_L8("Error:constScreen - expected: !NULL, actual: NULL (listener.cpp)"))); + //+test resolveobjectinterface method + MWsActiveSchedulerDebug* scheduler = iEnv->ObjectInterface(); + __ASSERT_ALWAYS(scheduler!=NULL, SendMessage(_L8("Error:scheduler - expected: !NULL, actual: NULL (listener.cpp)"))); + TUint32 eventMask = 0; + //-tests for registereventhandler and unregistereventhandler + __ASSERT_ALWAYS(iEnv->RegisterEventHandler(NULL,this, TWservCrEvent::EWindowClosing)==KErrArgument, SendMessage(_L8("Error:iEnv->RegisterEventHandler(NULL,this, TWservCrEvent::EWindowClosing) - expected: KErrArgument, actual: !KErrArgument (listener.cpp)"))); + __ASSERT_ALWAYS(iEnv->RegisterEventHandler(this,NULL, TWservCrEvent::EWindowClosing)==KErrArgument, SendMessage(_L8("Error:iEnv->RegisterEventHandler(this,NULL, TWservCrEvent::EWindowClosing) - expected: KErrArgument, actual: !KErrArgument (listener.cpp)"))); + __ASSERT_ALWAYS(iEnv->RegisterEventHandler(this,this, eventMask)==KErrArgument, SendMessage(_L8("Error:iEnv->RegisterEventHandler(this,this, eventMask) - expected: KErrArgument, actual: !KErrArgument (listener.cpp)"))); + __ASSERT_ALWAYS(iEnv->UnregisterEventHandler(NULL)==KErrArgument, SendMessage(_L8("Error:iEnv->UnregisterEventHandler(NULL) - expected: KErrArgument, actual: !KErrArgument (listener.cpp)"))); + //-tests for registerwseventhandler +#ifdef SYMBIAN_GRAPHICS_GCE + __ASSERT_ALWAYS(iEnv->RegisterWsEventHandler(this, eventMask)==KErrArgument, SendMessage(_L8("Error:iEnv->RegisterWsEventHandler(this, eventMask) - expected: KErrArgument, actual: !KErrArgument (listener.cpp)"))); + __ASSERT_ALWAYS(iEnv->RegisterWsEventHandler(NULL, TWservCrEvent::EWindowClosing)==KErrArgument, SendMessage(_L8("Error:iEnv->RegisterWsEventHandler(NULL, TWservCrEvent::EWindowClosing) - expected: KErrArgument, actual: !KErrArgument (listener.cpp)"))); +#endif //SYMBIAN_GRAPHICS_GCE + } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tlisten/listener.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tlisten/listener.h Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,118 @@ +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef __LISTENER_H__ +#define __LISTENER_H__ + +#include +#include "Graphics/WSGRAPHICDRAWER.H" +#include + +class CFbsBitmap; +class CFbsBitmapDevice; +class CFbsBitGc; +class MWsGraphicDrawerContext; +#ifdef __WINS__ +class CDebugOsbWin; +#endif + +const TInt KNotifyRemoveSelf = 0; +const TInt KNotifyRemoveThenAddSelf = 1; +const TInt KNotifyAddSelf = 2; +const TInt KNotifyRemoveOther = 3; +const TInt KNotifyRemoveThenAddOther = 4; +const TInt KNotifyAddOther = 5; +const TInt KNotifyRemoveSelfAndOther = 6; +const TInt KNotifyDoNothing = 7; +const TInt KNotifyDisable = 8; + +NONSHARABLE_CLASS(CWsEventListener): public CWsGraphicDrawer, public MWsEventHandler + { +public: + enum {EImplUid = 0x10281fb7}; + +public: + static CWsEventListener* NewL(); + virtual ~CWsEventListener(); + + // override CWsGraphicDrawer + virtual void ConstructL(MWsGraphicDrawerEnvironment& aEnv,const TGraphicDrawerId& aId, MWsClient& aOwner, const TDesC8& aData); + virtual void HandleMessage(const TDesC8& aData); + // override MWsEventHandler + virtual void DoHandleEvent(const TWservCrEvent& aEvent); +private: + // override CWsGraphicDrawer + virtual void DoDraw(MWsGc& aGc, const TRect& aRect, const TDesC8& aData) const; + + void OnScreenSizeModeChanged(TInt aMode); + void OnWindowVisibilityChanged(const RRegion* aRegion); + TRgb CurrentColor(); + void SendInfo(); + void OnWindowGroupChanged(TInt aScreenNumber, TInt aWindowGroupId); +private: + MWsGraphicDrawerContext* iDrawerContext; + CFbsBitmap* iBit; + CFbsBitmapDevice* iDev; + CFbsBitGc* iGc; +#ifdef __WINS__ + CDebugOsbWin* iWin; + TBool iDisableWin; +#endif + TBool iEnabled; + TBool iReady; + TSize iSize; + TDisplayMode iDisplayMode; + MWsScreen* iScreen; + TInt iColorIdx; + TInt iSaveNumRect; + TRect iSaveRect; + TInt iWindowGroupId; + }; + +NONSHARABLE_CLASS(CWsEventNotifier): public CWsGraphicDrawer, public MWsEventHandler + { +public: + enum { EImplUid1 = 0x102754c4, + EImplUid2 = 0x102754c6}; + +public: + static CWsEventNotifier* NewL(); + virtual ~CWsEventNotifier(); + + // override CWsGraphicDrawer + virtual void ConstructL(MWsGraphicDrawerEnvironment& aEnv,const TGraphicDrawerId& aId, MWsClient& aOwner, const TDesC8& aData); + virtual void HandleMessage(const TDesC8& aData); + // override MWsEventHandler + virtual void DoHandleEvent(const TWservCrEvent& aEvent); +private: + // override CWsGraphicDrawer + virtual void DoDraw(MWsGc& aGc, const TRect& aRect, const TDesC8& aData) const; + void TestGraphicDrawerEnvironment(); +private: + TBool iReady; + TInt iHandleMethod; + TGraphicDrawerId iAnotherPluginID; + CWsGraphicDrawer* iAnotherPlugin; + TBool iTestGraphicDrawerEnvironment; + MWsGraphicDrawerEnvironment* iEnv; + }; + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tlisten/listener.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tlisten/listener.rss Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,75 @@ +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include + +RESOURCE REGISTRY_INFO registry_info + { + dll_uid = 0x10281fb5; + interfaces = + { + INTERFACE_INFO + { + interface_uid = 0x10281fb6; + implementations = + { + IMPLEMENTATION_INFO + { + implementation_uid = 0x10281fb7; + version_no = 1; + display_name = "CWsEventListener"; + default_data = ""; + opaque_data = ""; + } + }; + }, + INTERFACE_INFO + { + interface_uid = 0x102754c3; + implementations = + { + IMPLEMENTATION_INFO + { + implementation_uid = 0x102754c4; + version_no = 1; + display_name = "CWsEventNotifier1"; + default_data = ""; + opaque_data = ""; + } + }; + }, + INTERFACE_INFO + { + interface_uid = 0x102754c5; + implementations = + { + IMPLEMENTATION_INFO + { + implementation_uid = 0x102754c6; + version_no = 1; + display_name = "CWsEventNotifier2"; + default_data = ""; + opaque_data = ""; + } + }; + } + }; + } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tlisten/proxy.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tlisten/proxy.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,37 @@ +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include +#include "listener.h" + + +LOCAL_C const TImplementationProxy KImplementationTable[] = + { + IMPLEMENTATION_PROXY_ENTRY(CWsEventListener::EImplUid, CWsEventListener::NewL), + IMPLEMENTATION_PROXY_ENTRY(CWsEventNotifier::EImplUid1, CWsEventNotifier::NewL), + IMPLEMENTATION_PROXY_ENTRY(CWsEventNotifier::EImplUid2, CWsEventNotifier::NewL) + }; + +EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) + { + aTableCount = sizeof(KImplementationTable)/sizeof(TImplementationProxy); + return KImplementationTable; + } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tlisten/wsgraphicdrawercontext.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tlisten/wsgraphicdrawercontext.h Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,50 @@ +// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#ifndef __WSGRAPHICDRAWERCONTEXT_H__ +#define __WSGRAPHICDRAWERCONTEXT_H__ + +#include +#include + +class MWsGc; +class TRgb; + +class MWsGraphicDrawerContext + { +public: + virtual void Destroy() = 0; + virtual void DrawEllipse(MWsGc& aGc, const TRect& aRect, const TRgb& aColor) const = 0; + }; + +class CWsGraphicDrawerNgaContext : public CBase, public MWsGraphicDrawerContext + { +public: + static MWsGraphicDrawerContext* NewL(); +public: + void Destroy(); + void DrawEllipse(MWsGc& aGc, const TRect& aRect, const TRgb& aColor) const; + }; + +class CWsGraphicDrawerNonNgaContext : public CBase, public MWsGraphicDrawerContext + { +public: + static MWsGraphicDrawerContext* NewL(); +public: + void Destroy(); + void DrawEllipse(MWsGc& aGc, const TRect& aRect, const TRgb& aColor) const; + }; + +#endif // __WSGRAPHICDRAWERCONTEXT_H__ diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tlisten/wsgraphicdrawerngacontext.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tlisten/wsgraphicdrawerngacontext.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,42 @@ +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#define SYMBIAN_GRAPHICS_GCE + +#include "wsgraphicdrawercontext.h" +#include + +MWsGraphicDrawerContext* CWsGraphicDrawerNgaContext::NewL() + { + return new(ELeave) CWsGraphicDrawerNgaContext(); + } + +void CWsGraphicDrawerNgaContext::Destroy() + { + delete this; + } + +void CWsGraphicDrawerNgaContext::DrawEllipse(MWsGc& aGc, const TRect& aRect, const TRgb& aColor) const + { + MWsGraphicsContext* context = aGc.ObjectInterface(); + if (context) + { + context->Push(); + context->SetBrushStyle(MWsGraphicsContext::ESolidBrush); + context->SetBrushColor(aColor); + context->DrawEllipse(aRect); + context->Pop(); + } + } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tlisten/wsgraphicdrawernonngacontext.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tlisten/wsgraphicdrawernonngacontext.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,40 @@ +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#undef SYMBIAN_GRAPHICS_GCE + +#include "wsgraphicdrawercontext.h" +#include +#include + +MWsGraphicDrawerContext* CWsGraphicDrawerNonNgaContext::NewL() + { + return new(ELeave) CWsGraphicDrawerNonNgaContext(); + } + +void CWsGraphicDrawerNonNgaContext::Destroy() + { + delete this; + } + +void CWsGraphicDrawerNonNgaContext::DrawEllipse(MWsGc& aGc, const TRect& aRect, const TRgb& aColor) const + { + aGc.PushBitGcSettings(); + CFbsBitGc& bitGc = aGc.BitGc(); + bitGc.SetBrushStyle(CGraphicsContext::ESolidBrush); + bitGc.SetBrushColor(aColor); + bitGc.DrawEllipse(aRect); + aGc.PopBitGcSettings(); + } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tlisten/wslisten.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tlisten/wslisten.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,178 @@ +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// The plug-in provides the client side CWsGraphic instance CWsListen, which is used in +// GRAPHICS-WSERV-0023 and GRAPHICS-WSERV-0024. +// This is also used for Test Case GRAPHICS-WSERV-0058 for INC094118: CWsGraphicDrawer::SendMessage panics window server. +// The customer incident "INC094118" reports the failure of CWsGraphicDrawer::SendMessage(const TDesC8& aData) +// when the event message iEventMsg is not ready. The defect is reproduced by calling QueryPlugin(aInfo) +// once again to wserv plug-in side in the CWsListen::HandleMessage(const TDesC8& aData), when the event +// message has not yet been reset by CWsGraphic::CManager. Certainly in practice there are many other cases +// which could trigger the defect. +// The fix is added in CWsGraphicMessageQueue::Queue(CMessage* aMessage), where we check whether the iEventMsg +// is empty or not. As a result, if iEventMsg is not ready we do not signal event but keep message untouched in queue. +// nce the iEventMsg is set ready, an event is signaleed immediately if there is a waiting event and message +// will be popped out of the queue. +// The test of defect-fixing INC094118 can be enabled by initialising iTestFlag to ETrue. Setting iTestFlag to +// EFalse will not trigger the defect. A new test case is written to trigger the defect only once. +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include "wslisten.h" + +const TUid KListenerInterfaceId = {0x10281fb6}; +const TUid KListenerImplId = {0x10281fb7}; +const TUid KNotifierInterfaceId1 = {0x102754c3}; +const TUid KNotifierImplId1 = {0x102754c4}; +const TUid KNotifierInterfaceId2 = {0x102754c5}; +const TUid KNotifierImplId2 = {0x102754c6}; + +const TUint8 KCmdDisable = 0; +const TUint8 KCmdEnable = 1; +const TUint8 KCmdQuery = 2; + +EXPORT_C CWsListen* CWsListen::NewL() + { + return NewL(EFalse); + } + +EXPORT_C CWsListen* CWsListen::NewL(TBool aDisableWin) + { + CWsListen* self = new(ELeave) CWsListen; + CleanupStack::PushL(self); + TBuf8<1> data; + data.Append((TUint8)aDisableWin); + self->BaseConstructL(KListenerInterfaceId, KListenerImplId, data); + CleanupStack::Pop(self); + //Initialise the test flag to EFalse if dont want to reproduce the INC094118 and test the fix + self->iTestFlag = EFalse; + self->iIsReady = ETrue; + return self; + } + +EXPORT_C CWsListen::~CWsListen() + { + iIsReady = EFalse; + } + +EXPORT_C void CWsListen::SetTestFlag() + { + //Set the test flag to ETrue if want to reproduce the INC094118 and test the fix + iTestFlag = ETrue; + } + +void CWsListen::HandleMessage(const TDesC8& aData) + { + if (aData[0]==KListenerInfoSig) + Mem::Copy(iReq, aData.Ptr(), aData.Size()); + //The if-statement allows to call QueryPlugin() in HandleMessage() only once to reproduce the defect INC094118. + //Otherwise HandleMessage() will behave as normal. + if (iTestFlag) + { + TListenerInfo aInfo; + QueryPlugin(aInfo) ; + iTestFlag = EFalse; + } + else + { + iCallBack.CallBack(); + } + } + +void CWsListen::OnReplace() + { + } + +EXPORT_C TInt CWsListen::Enable(TBool aEnabled) + { + if (!iIsReady) + return KErrNotReady; + + TBuf8<1> cmd; + cmd.Append(aEnabled? KCmdEnable : KCmdDisable); + SendMessage(cmd); + return Flush(); + } + +EXPORT_C TInt CWsListen::QueryPlugin(TListenerInfo& aInfo) + { + TBuf8<1> cmd; + cmd.Append(KCmdQuery); + SendMessage(cmd); + TInt err = Flush(); + if (err!=KErrNone) + return err; + iReq = &aInfo; + return KErrNone; + } + +EXPORT_C void CWsListen::SetCallBack(TCallBack aCallBack) + { + iCallBack = aCallBack; + } + +EXPORT_C CWsNotify* CWsNotify::NewL() + { + return NewL(EFalse); + } + +EXPORT_C CWsNotify* CWsNotify::NewL(TBool aPluginOrder) + { + CWsNotify* self = new(ELeave) CWsNotify; + CleanupStack::PushL(self); + TBuf8<1> data; + data.Append(8); + if (!aPluginOrder) //Different IDs so 2 plugins may be registered at once + self->BaseConstructL(KNotifierInterfaceId1, KNotifierImplId1, data); + else + self->BaseConstructL(KNotifierInterfaceId2, KNotifierImplId2, data); + CleanupStack::Pop(self); + self->iIsReady = ETrue; + self->iResult = ETrue; + return self; + } + +EXPORT_C CWsNotify::~CWsNotify() + { + iIsReady = EFalse; + } + +void CWsNotify::HandleMessage(const TDesC8& aData) + { + TBuf8<100> KTesting(_L8("Error:")); + if(aData.Find(KTesting)!=KErrNotFound) + { + iError.Copy(aData); + iResult = EFalse; + } + } + +void CWsNotify::OnReplace() + { + } + +EXPORT_C TInt CWsNotify::SetBehaviour(TInt aType) + { + if (!iIsReady) + return KErrNotReady; + TBuf8<1> cmd; + cmd.Append(aType); + SendMessage(cmd); + return Flush(); + } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tlisten/wslisten.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tlisten/wslisten.h Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,76 @@ +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef __WSLISTEN_H__ +#define __WSLISTEN_H__ + +#include + +const TUint8 KListenerInfoSig = 0xaa; + +NONSHARABLE_STRUCT(TListenerInfo) + { + TUint8 iSignature; + TInt iNumRect; + TRect iRect; + TInt iWindowGroupId; + }; + +NONSHARABLE_CLASS(CWsListen): public CWsGraphic + { +public: + IMPORT_C static CWsListen* NewL(); + IMPORT_C static CWsListen* NewL(TBool aDisableWin); + IMPORT_C ~CWsListen(); + IMPORT_C TInt Enable(TBool aEnabled); + IMPORT_C void SetCallBack(TCallBack aCallBack); + IMPORT_C TInt QueryPlugin(TListenerInfo& aInfo); + IMPORT_C void SetTestFlag(); +private: + // override CWsGraphic + virtual void HandleMessage(const TDesC8& aData); + virtual void OnReplace(); +private: + TBool iIsReady; + TCallBack iCallBack; + TListenerInfo* iReq; + TBool iTestFlag; + }; + +NONSHARABLE_CLASS(CWsNotify): public CWsGraphic + { +public: + IMPORT_C static CWsNotify* NewL(); + IMPORT_C static CWsNotify* NewL(TBool aPluginOrder); + IMPORT_C ~CWsNotify(); + IMPORT_C TInt SetBehaviour(TInt aType); +private: + // override CWsGraphic + virtual void HandleMessage(const TDesC8& aData); + virtual void OnReplace(); +private: + TBool iIsReady; +public: + TBool iResult; + TBuf16<100> iError; + }; + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tman/DUMMYM.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tman/DUMMYM.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,60 @@ +// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Simple dummy test, to be used as example for new tests +// +// + +#include +#include "W32STD.H" +#include "../tlib/testbase.h" +#include "TMAN.H" + +class TDummyTest : public CTestBase + { +public: + TDummyTest(); + TestState DoTestL(); + void ConstructL(); +private: + TSize iWinSize; + TInt iState; + }; + +GLDEF_C CTestBase *CreateDummyTest() + { + return(new(ELeave) TDummyTest()); + } + +TDummyTest::TDummyTest() : CTestBase(_L("Dummy")) + {} + +void TDummyTest::ConstructL() + { + } + +TestState TDummyTest::DoTestL() + { + switch(iState) + { + case 0: + LogSubTest(_L("Dummy 1"),1); + TestL(ETrue); + iState++; + break; + default: + return(EFinished); + } + return(ENext); + } + diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tman/HOTKEY2.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tman/HOTKEY2.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,424 @@ +// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Test capture key +// +// + +#include +#include +#include "W32STD.H" +#include "../tlib/testbase.h" +#include "TMAN.H" + +enum THotKeyRetValues + { + EHotKeyOkay, + EHotKeyRetry, + EHotKeyFail, + }; + +struct SHotKeyParams + { + THotKey hotKey; + TUint keyCode; + TUint mod_mask; + TUint modifiers; + }; + +struct SHotKeyTestParams + { + TText *txt; // Text message telling user what to do + }; + +LOCAL_D SHotKeyParams HotKeys[]={ + {EHotKeyEnableLogging,'e',EModifierFunc|EModifierCtrl|EModifierShift,0}, + {EHotKeyDisableLogging,'d',EModifierFunc|EModifierCtrl|EModifierShift,EModifierFunc}, + {EHotKeyOfDeath,'q',0}, + {EHotKeyOfDeath,'w',0}, + }; + +LOCAL_D SHotKeyTestParams HotKeyTests[]={ + {(TText *)_S("Use \"e\" to enable logging")}, + {(TText *)_S("Use \"d\" to disable logging")}, + {(TText *)_S("Use \"q\" to kill the foreground app")}, + {(TText *)_S("Use \"w\" to kill the foreground app")}, + {(TText *)_S("Use \"K\" to kill the foreground app")}, + }; + +LOCAL_D TBool HotKeyTestIsDeathTest[]={EFalse, EFalse, ETrue, ETrue, ETrue}; + +struct SErrorHotKey + { + THotKey hotKey; + TUint keyCode; + TUint mod_mask; + TUint modifiers; + }; + +LOCAL_D SErrorHotKey errorKeys[]={ + {EHotKeyEnableLogging,'a',EModifierFunc|EModifierShift,EModifierFunc|EModifierCtrl}, + {EHotKeyDisableLogging,'1',0,EModifierFunc}, + {EHotKeyEnableLogging,3,EModifierCtrl,EModifierCtrl|EModifierShift}, + {EHotKeyDisableLogging,'a',EModifierFunc|EModifierShift,EModifierFunc|EModifierCtrl}, + {(THotKey)100,'1',0,EModifierFunc}, + {(THotKey)200, 3,EModifierCtrl,EModifierCtrl|EModifierShift}, + }; + +const TInt numHotKeys=sizeof(HotKeys)/sizeof(HotKeys[0]); +const TInt numHotKeyTests=sizeof(HotKeyTests)/sizeof(HotKeyTests[0]); +const TInt numErrorKeys=sizeof(errorKeys)/sizeof(errorKeys[0]); + +class SHKWindow; +class THotKeyTest; +class SHKConnection; + +class SHKDeath : public CActive + { +public: + SHKDeath(TInt aPriority); + void SetConnection(SHKConnection *aConn); + virtual void DoCancel(); + virtual void RunL(); + void Request(); +private: + SHKConnection *iConn; + }; + +class SHKWindowGroup : public CTWindowGroup + { +public: + SHKWindowGroup(CTClient *aClient); + void KeyL(const TKeyEvent &aKey,const TTime &aTime); + }; + +class SHKConnection : public CTClient + { +public: + SHKConnection(THotKeyTest *aTest, TInt aMode); + ~SHKConnection(); + void ConstructL(); + void KeyL(const TKeyEvent &aKey); + void SubStateChangedL(); + void CompleteL(); +protected: + TInt iMode; + SHKDeath iDeath; + THotKeyTest *iTest; + CTWin *iWin; + static TInt iMainWinId; + }; + +class SHKWindow : public CTWin + { +public: + SHKWindow(THotKeyTest *aTest); + void SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc); + void Draw(); +protected: + THotKeyTest *iTest; + TRgb iBack; + }; + +class SHKWindow2 : public CTWin + { +public: + SHKWindow2(); + void SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc); + void Draw(); + }; + +class THotKeyTest : public CTestBase + { +public: + THotKeyTest(); + ~THotKeyTest(); + TestState DoTestL(); + void ConstructL(); + void EndCaptureKeyTest(); + TInt SubState() const; + void IncSubStateL(); + void BadParamsL(); +private: + SHKConnection *iConn1; + TSize iWinSize; + TInt iState; + TInt iSubState; + TBool iIsInActiveScheduler; + }; + +TInt SHKConnection::iMainWinId; + +TInt SubThread(TAny *); + +GLDEF_C CTestBase *CreateHotKeyTest() + { + return(new(ELeave) THotKeyTest()); + } + +THotKeyTest::THotKeyTest() : CTestBase(_L("Hot Key")) + {} + +THotKeyTest::~THotKeyTest() + { + User::SetJustInTime(ETrue); + for(TInt index=0;indexiWs.ClearHotKeys(HotKeys[index].hotKey); + Client()->iWs.RestoreDefaultHotKey(HotKeys[index].hotKey); + } + delete iConn1; + if (iIsInActiveScheduler) + CActiveScheduler::Stop(); + } + +void THotKeyTest::EndCaptureKeyTest() + { + Request(); + } + +void THotKeyTest::ConstructL() + { + iConn1=new(ELeave) SHKConnection(this, EFalse); + iConn1->ConstructL(); + for(TInt index=0;indexiWs.SetHotKey(HotKeys[index].hotKey, HotKeys[index].keyCode,HotKeys[index].mod_mask,HotKeys[index].modifiers)); + User::SetJustInTime(EFalse); + } + +// +// SHKDeath // +// + +SHKDeath::SHKDeath(TInt aPriority) : CActive(aPriority) + { + CActiveScheduler::Add(this); + } + +void SHKDeath::SetConnection(SHKConnection *aConn) + { + iConn=aConn; + } + +void SHKDeath::DoCancel() + { + } + +void SHKDeath::RunL() + { + iConn->CompleteL(); + } + +void SHKDeath::Request() + { + SetActive(); + } + +// + +SHKWindowGroup::SHKWindowGroup(CTClient *aClient) : CTWindowGroup(aClient) + {} + +void SHKWindowGroup::KeyL(const TKeyEvent &aKey,const TTime &) + { + ((SHKConnection *)iClient)->KeyL(aKey); + } + +// +// SHKConnection + +SHKConnection::SHKConnection(THotKeyTest *aTest, TInt aMode) : iMode(aMode), iDeath(100), iTest(aTest) + { + iDeath.SetConnection(this); + } + +SHKConnection::~SHKConnection() + { + iGroup->GroupWin()->EnableReceiptOfFocus(EFalse); + CTWin::Delete(iWin); + } + +void SHKConnection::KeyL(const TKeyEvent &aKey) + { + if (iTest) + { + if (aKey.iCode==EKeyEnter && !HotKeyTestIsDeathTest[iTest->SubState()]) + iTest->IncSubStateL(); + else if (aKey.iCode==EKeyEscape) + iTest->AbortL(); + } + } + +void SHKConnection::CompleteL() + { + iTest->IncSubStateL(); + } + +void SHKConnection::SubStateChangedL() + { + if (HotKeyTestIsDeathTest[iTest->SubState()]) + { + RThread thread; + iMainWinId=iGroup->GroupWin()->Identifier(); + TInt subState=iTest->SubState(); + User::After(100000); + User::LeaveIfError(thread.Create(_L("SubThread"),SubThread,KDefaultStackSize,0x2000,0x2000,&subState,EOwnerThread)); + thread.Logon(iDeath.iStatus); + iDeath.Request(); + thread.Resume(); + thread.Close(); + } + iWin->Invalidate(); + iWs.Flush(); + } + +void SHKConnection::ConstructL() + { + CTClient::ConstructL(); + iGroup=new(ELeave) SHKWindowGroup(this); + iGroup->ConstructL(); + TSize screenSize=iGroup->Size(); + iGroup->GroupWin()->AutoForeground(EFalse); // Don't allow clicking to cause foreground, might mess up test + TInt winWidth; + TInt winHeight; + if (iMode==0) + { + winWidth=screenSize.iWidth/2; + winHeight=screenSize.iHeight-10; + SHKWindow *win=new(ELeave) SHKWindow(iTest); + win->SetUpL(TPoint(5,5),TSize(winWidth,winHeight),iGroup,*iGc); + iWin=win; + } + else + { + winWidth=150; + winHeight=50; + iGroup->GroupWin()->SetOwningWindowGroup(iMainWinId); + SHKWindow2 *win=new(ELeave) SHKWindow2(); + win->SetUpL(TPoint((screenSize.iWidth-winWidth)/2,(screenSize.iHeight-winHeight)/2),TSize(winWidth,winHeight),iGroup,*iGc); + iWin=win; + } + iWs.Flush(); + } + +// +// SHKWindow, class // +// + +SHKWindow::SHKWindow(THotKeyTest *aTest) : CTWin(), iTest(aTest) + { + iBack=TRgb::Gray256(230); + } + +void SHKWindow::SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc) + { + ConstructExtLD(*parent,pos,size); + iWin.SetBackgroundColor(iBack); + Activate(); + AssignGC(aGc); + } + +void SHKWindow::Draw() + { + iGc->Clear(); + iGc->DrawText(TPtrC(HotKeyTests[iTest->SubState()].txt), TPoint(10,20)); + iGc->DrawText(TPtrC(_L("Press when tested okay")), TPoint(10,35)); + iGc->DrawText(TPtrC(_L("or escape to abort tests")), TPoint(10,50)); + } + +// +// SHKWindow2, class // +// + +SHKWindow2::SHKWindow2() : CTWin() + { + } + +void SHKWindow2::SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc) + { + ConstructExtLD(*parent,pos,size); + iWin.SetBackgroundColor(TRgb(0,0,0)); + Activate(); + AssignGC(aGc); + } + +void SHKWindow2::Draw() + { + iGc->SetBrushColor(TRgb::Gray4(1)); + iGc->Clear(); + iGc->SetPenColor(TRgb::Gray4(3)); + iGc->DrawText(TPtrC(_L("Kill me!!!")), TPoint(10,15)); + } + +// + +TInt THotKeyTest::SubState() const + { + return(iSubState); + } + +void THotKeyTest::IncSubStateL() + { + if (iSubState==(numHotKeyTests-1)) + EndCaptureKeyTest(); + else + { + iSubState++; + iConn1->SubStateChangedL(); + } + } + +void THotKeyTest::BadParamsL() + { + TInt resCount=Client()->iWs.ResourceCount(); + for(TInt index=0;indexiWs.SetHotKey(errorKeys[index].hotKey, errorKeys[index].keyCode,errorKeys[index].mod_mask,errorKeys[index].modifiers)==KErrArgument); + TestL(Client()->iWs.ResourceCount()==resCount); + } + +TestState THotKeyTest::DoTestL() + { + switch(iState) + { + case 0: + LogSubTest(_L("Errors"),1); + BadParamsL(); + LogSubTest(_L("CaptureKey"),2); + iState++; + return(EContinue); + default: + return(EFinished); + } + } + +//======================================================// +// Sub thread to do tests and get shot by window server // +//======================================================// + +void SubThreadMain() + { + CActiveScheduler *TheActiveScheduler=new(ELeave) CActiveScheduler; + CActiveScheduler::Install(TheActiveScheduler); + SHKConnection *conn=new(ELeave) SHKConnection(NULL, ETrue); + conn->ConstructL(); + CActiveScheduler::Start(); + delete TheActiveScheduler; + } + +TInt SubThread(TAny *) + { + CTrapCleanup* CleanUpStack=CTrapCleanup::New(); + TRAPD(err,SubThreadMain()); + delete CleanUpStack; + return(err); + } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tman/MULTICON.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tman/MULTICON.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,446 @@ +// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Test multiple connections to the window server +// +// + +#include +#include +#include "W32STD.H" +#include "../tlib/testbase.h" +#include "TMAN.H" + +const TInt EMaxSubState=3; + +class CMcWindowBase; +class TMultiConTest; + +class CMcConnectionBase : public CTClient + { +public: + CMcConnectionBase(TMultiConTest *aTest); + ~CMcConnectionBase(); + virtual void ConstructL(); + void SubStateChanged(); +protected: + TMultiConTest *iTest; + CMcWindowBase *iWin; + CWindowGc *iGc; + }; + +class CMcConnection : public CMcConnectionBase // Sets AutoForeground off + { +public: + CMcConnection(TMultiConTest *aTest); + void ConstructL(); + }; + +class CMcWindowGroupAf : public CTWindowGroup + { +public: + CMcWindowGroupAf(CTClient *aClient); + void KeyL(const TKeyEvent &aKey, const TTime &aTime); + }; + +class CMcConnectionAf : public CMcConnectionBase // Sets AutoForeground on + { +public: + CMcConnectionAf(TMultiConTest *aTest); + void ConstructL(); + void KeyL(const TKeyEvent &aKey); + }; + +class CMcConnectionDef : public CMcConnectionBase // Leaves AutoForeground as the default value + { +public: + CMcConnectionDef(TMultiConTest *aTest); + void ConstructL(); + }; + +class CMcWindowBase : public CTWin + { +public: + CMcWindowBase(TMultiConTest *aTest); + void SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc); + virtual void Draw()=0; + virtual void PointerL(const TPointerEvent &pointer,const TTime &)=0; +protected: + TMultiConTest *iTest; + TRgb iBack; + }; + +class CMcWindow : public CMcWindowBase + { +public: + CMcWindow(TMultiConTest *aTest); + virtual void Draw(); + virtual void PointerL(const TPointerEvent &pointer,const TTime &); + }; + +class CMcWindowAf : public CMcWindowBase + { +public: + CMcWindowAf(TMultiConTest *aTest); + virtual void Draw(); + virtual void PointerL(const TPointerEvent &pointer,const TTime &); + void ConstructL(); + }; + +class CMcWindowDef : public CMcWindowBase + { +public: + CMcWindowDef(TMultiConTest *aTest); + virtual void Draw(); + virtual void PointerL(const TPointerEvent &pointer,const TTime &); + }; + +class TMultiConTest : public CTestBase + { +public: + TMultiConTest(); + ~TMultiConTest(); + TestState DoTestL(); + void ConstructL(); + void EndAutoForegroundTest(); + TInt SubState() const; + void IncSubState(); +private: + CMcConnectionAf *iConn1; + CMcConnection *iConn2; + CMcConnectionDef *iConn3; + TSize iWinSize; + TInt iState; + TInt iSubState; + }; + +GLDEF_C CTestBase *CreateMultiConTest() + { + return(new(ELeave) TMultiConTest()); + } + +TMultiConTest::TMultiConTest() : CTestBase(_L("MultiCon")) + {} + +TMultiConTest::~TMultiConTest() + { + delete iConn1; + delete iConn2; + delete iConn3; + } + +void TMultiConTest::EndAutoForegroundTest() + { + iConn1->iGroup->GroupWin()->EnableReceiptOfFocus(EFalse); + iConn2->iGroup->GroupWin()->EnableReceiptOfFocus(EFalse); + iConn3->iGroup->GroupWin()->EnableReceiptOfFocus(EFalse); + Request(); + } + +void TMultiConTest::ConstructL() + { + iConn3=new(ELeave) CMcConnectionDef(this); + iConn3->ConstructL(); + iConn2=new(ELeave) CMcConnection(this); + iConn2->ConstructL(); + iConn1=new(ELeave) CMcConnectionAf(this); + iConn1->ConstructL(); + } + +// +// CMcConnection + +CMcConnectionBase::CMcConnectionBase(TMultiConTest *aTest) : iTest(aTest) + { + } + +CMcConnectionBase::~CMcConnectionBase() + { + CTWin::Delete(iWin); + delete iGc; + } + +void CMcConnectionBase::SubStateChanged() + { + iWin->Invalidate(); + iWs.Flush(); + } + +void CMcConnectionBase::ConstructL() + { + CTClient::ConstructL(); + User::LeaveIfError(iScreen->CreateContext(iGc)); + } + +CMcConnection::CMcConnection(TMultiConTest *aTest) : CMcConnectionBase(aTest) + { + } + +void CMcConnection::ConstructL() + { + CMcConnectionBase::ConstructL(); + iGroup=new(ELeave) CTWindowGroup(this); + iGroup->ConstructL(); + TSize screenSize=iGroup->Size(); + TInt winWidth=screenSize.iWidth/3; + TInt winHeight=screenSize.iHeight/2-10; + iGroup->GroupWin()->AutoForeground(EFalse); + CMcWindow *win=new(ELeave) CMcWindow(iTest); + win->SetUpL(TPoint(5,5),TSize(winWidth,winHeight),iGroup,*iGc); + iWin=win; + iWs.Flush(); + } + +CMcConnectionAf::CMcConnectionAf(TMultiConTest *aTest) : CMcConnectionBase(aTest) + { + } + +void CMcConnectionAf::ConstructL() + { + CMcConnectionBase::ConstructL(); + iGroup=new(ELeave) CMcWindowGroupAf(this); + iGroup->ConstructL(); + TSize screenSize=iGroup->Size(); + TInt winWidth=screenSize.iWidth/3; + TInt winHeight=screenSize.iHeight/2-10; + iGroup->GroupWin()->AutoForeground(ETrue); + CMcWindowAf *win=new(ELeave) CMcWindowAf(iTest); + win->SetUpL(TPoint(winWidth,5),TSize(winWidth,winHeight),iGroup,*iGc); + iWin=win; + iWs.Flush(); + } + +void CMcConnectionAf::KeyL(const TKeyEvent &aKey) + { + switch(aKey.iCode) + { + case ' ': + if (iTest->SubState()==0) + { + iTest->TestL(iGroup->GroupWin()->OrdinalPosition()==0); + iTest->IncSubState(); + } + break; + case EKeyEscape: + iTest->EndAutoForegroundTest(); + break; + } + } + +CMcConnectionDef::CMcConnectionDef(TMultiConTest *aTest) : CMcConnectionBase(aTest) + { + } + +void CMcConnectionDef::ConstructL() + { + CMcConnectionBase::ConstructL(); + iGroup=new(ELeave) CTWindowGroup(this); + iGroup->ConstructL(); + iGroup->GroupWin()->EnableReceiptOfFocus(EFalse); + TSize screenSize=iGroup->Size(); + TInt winWidth=screenSize.iWidth/3-10; + TInt winHeight=(screenSize.iHeight/2)-10; + CMcWindowDef *win=new(ELeave) CMcWindowDef(iTest); + win->SetUpL(TPoint(5+winWidth/2,screenSize.iHeight/2),TSize(winWidth,winHeight),iGroup,*iGc); + iWin=win; + iWs.Flush(); + } + +// +// CMcWindow, base class // +// + +CMcWindowBase::CMcWindowBase(TMultiConTest *aTest) : CTWin(), iTest(aTest) + { + } + +void CMcWindowBase::SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc) + { + ConstructExtLD(*parent,pos,size); + iWin.SetBackgroundColor(iBack); + Activate(); + AssignGC(aGc); + } + +// +// CMcWindow, window used to test multiple connections // +// + +CMcWindow::CMcWindow(TMultiConTest *aTest) : CMcWindowBase(aTest) + { + iBack=TRgb::Gray256(221); + } + +void CMcWindow::PointerL(const TPointerEvent &pointer,const TTime &) + { + if (pointer.iType==TPointerEvent::EButton1Down) + { + switch(iTest->SubState()) + { + case 1: + iTest->TestL(Client()->iGroup->GroupWin()->OrdinalPosition()==1); + iTest->IncSubState(); + break; + } + } + } + +void CMcWindow::Draw() + { + iGc->Clear(); + TBuf<0x40> buf; + switch(iTest->SubState()) + { + case 1: + buf.Copy(_L("Click on me")); + break; + case 0: + case 2: + case 3: + buf.Copy(_L("")); + break; + default: + buf.Copy(_L("ERROR")); + } + iGc->DrawText(buf, TPoint(10,20)); + } + +// +// CMcWindowAf, Auto foreground version of CMcWindow // +// + +CMcWindowAf::CMcWindowAf(TMultiConTest *aTest) : CMcWindowBase(aTest) + { + iBack=TRgb::Gray256(150); + } + +void CMcWindowAf::PointerL(const TPointerEvent &pointer,const TTime &) + { + if (pointer.iType==TPointerEvent::EButton1Down) + { + switch(iTest->SubState()) + { + case 2: + iTest->TestL(Client()->iGroup->GroupWin()->OrdinalPosition()==0); + iTest->IncSubState(); + break; + } + } + } + +void CMcWindowAf::Draw() + { + iGc->Clear(); + TBuf<0x40> buf; + switch(iTest->SubState()) + { + case 1: + case 3: + break; + case 0: + buf.Copy(_L("Press ")); + break; + case 2: + buf.Copy(_L("Click on me")); + break; + default: + buf.Copy(_L("ERROR")); + } + iGc->DrawText(buf, TPoint(10,20)); + } + +// + +CMcWindowGroupAf::CMcWindowGroupAf(CTClient *aClient) : CTWindowGroup(aClient) + {} + +void CMcWindowGroupAf::KeyL(const TKeyEvent &aKey, const TTime &) + { + ((CMcConnectionAf *)iClient)->KeyL(aKey); + } + +// +// CMcWindowDef, Default auto foreground version of CMcWindow // +// + +CMcWindowDef::CMcWindowDef(TMultiConTest *aTest) : CMcWindowBase(aTest) + { + iBack=TRgb::Gray256(236); + } + +void CMcWindowDef::PointerL(const TPointerEvent &pointer,const TTime &) + { + if (pointer.iType==TPointerEvent::EButton1Down) + { + switch(iTest->SubState()) + { + case 3: + iTest->TestL(Client()->iGroup->GroupWin()->OrdinalPosition()==0); + iTest->IncSubState(); + break; + } + } + } + +void CMcWindowDef::Draw() + { + iGc->Clear(); + TBuf<0x40> buf; + switch(iTest->SubState()) + { + case 0: + case 1: + case 2: + break; + case 3: + buf.Copy(_L("Click on me")); + break; + default: + buf.Copy(_L("ERROR")); + } + iGc->DrawText(buf, TPoint(10,20)); + } + +// + +TInt TMultiConTest::SubState() const + { + return(iSubState); + } + +void TMultiConTest::IncSubState() + { + if (iSubState==EMaxSubState) + EndAutoForegroundTest(); + else + { + iSubState++; + iConn1->SubStateChanged(); + iConn2->SubStateChanged(); + iConn3->SubStateChanged(); + } + } + +TestState TMultiConTest::DoTestL() + { + switch(iState) + { + case 0: + LogSubTest(_L("MultiCon 1"),1); + iState++; + return(EContinue); + default: + return(EFinished); + } +// return(ENext); + } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tman/SCALE.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tman/SCALE.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,135 @@ +// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Test GDI scaling (pixels<->twips) functions +// You can probably delete this test as it is now done by TMSCRMOD for each screen mode. +// +// + +#include +#include "W32STD.H" +#include "../tlib/testbase.h" +#include "TMAN.H" + +class TScaleTest; + +class CScaleWindow : public CTWin + { +public: + CScaleWindow(TScaleTest *aTest); + void SetUpLD(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc); + void Draw(); + void WinKeyL(const TKeyEvent &aKey,const TTime &aTime); +private: + TScaleTest *iTest; + }; + +class TScaleTest : public CTestBase + { +public: + TScaleTest(); + ~TScaleTest(); + TestState DoTestL(); + void ConstructL(); +private: + CScaleWindow *iWin; + TSize iWinSize; + TInt iState; + }; + +GLDEF_C CTestBase *CreateScaleTest() + { + return(new(ELeave) TScaleTest()); + } + +CScaleWindow::CScaleWindow(TScaleTest *aTest) : CTWin(), iTest(aTest) + {} + +void CScaleWindow::SetUpLD(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc) + { + ConstructExtLD(*parent,pos,size); + Activate(); + AssignGC(aGc); + } + +void CScaleWindow::Draw() + { + iGc->Clear(); + TSize twips=Client()->iScreen->SizeInTwips(); + TSize pixels=Client()->iScreen->SizeInPixels(); +// Horizontal line + TInt inches=twips.iWidth/KTwipsPerInch-1; + TInt lineLen=Client()->iScreen->HorizontalTwipsToPixels(inches*KTwipsPerInch); + TPoint linePos=TPoint((pixels.iWidth-lineLen)/2,pixels.iHeight/2); + iGc->DrawLine(linePos,linePos+TPoint(lineLen,0)); + TBuf<0x20> buf; + buf.Format(TRefByValue(_L("Width %d\"")),inches); + iGc->DrawText(buf,TPoint((pixels.iWidth-iFont->TextWidthInPixels(buf))/2,linePos.iY-iFont->HeightInPixels()+iFont->AscentInPixels()-2)); + TInt index; + for(index=0;index<=inches;index++) + { + TInt dx=Client()->iScreen->HorizontalTwipsToPixels(index*KTwipsPerInch); + TInt dy=Client()->iScreen->VerticalTwipsToPixels(KTwipsPerInch/(index==0 || index==inches ? 8 : 16)); + iGc->DrawLine(linePos+TPoint(dx,1), linePos+TPoint(dx,dy)); + } +// Vertical line + inches=twips.iHeight/KTwipsPerInch; + lineLen=Client()->iScreen->VerticalTwipsToPixels(inches*KTwipsPerInch); + linePos.iY=(pixels.iHeight-lineLen)/2; + iGc->DrawLine(linePos,linePos+TPoint(0,lineLen)); + buf.Format(TRefByValue(_L("Height %d\"")),inches); + iGc->DrawText(buf,TPoint(linePos.iX+10, pixels.iHeight/4)); + for(index=0;index<=inches;index++) + { + TInt dx=Client()->iScreen->HorizontalTwipsToPixels(KTwipsPerInch/(index==0 || index==inches ? 8 : 16)); + TInt dy=Client()->iScreen->VerticalTwipsToPixels(index*KTwipsPerInch); + iGc->DrawLine(linePos+TPoint(1,dy), linePos+TPoint(dx,dy)); + } + } + +void CScaleWindow::WinKeyL(const TKeyEvent &,const TTime &) + { + CActiveScheduler::Stop(); + } + +TScaleTest::TScaleTest() : CTestBase(_L("Scale")) + {} + +TScaleTest::~TScaleTest() + { + CTWin::Delete(iWin); + } + +void TScaleTest::ConstructL() + { + CScaleWindow *win=new(ELeave) CScaleWindow(this); + win->SetUpLD(TPoint(0,0),Client()->iScreen->SizeInPixels(),Client()->iGroup,*Client()->iGc); + iWin=win; + Client()->iGroup->SetCurrentWindow(iWin); + } + +TestState TScaleTest::DoTestL() + { + switch(iState) + { + case 0: + LogSubTest(_L("Scale 1"),1); + CActiveScheduler::Start(); + iState++; + break; + default: + return(EFinished); + } + return(ENext); + } + diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tman/TKREPEAT.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tman/TKREPEAT.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,348 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Keyboard repeat test +// +// + +#include +#include +#include "W32STD.H" +#include "../tlib/testbase.h" +#include "TMAN.H" + +class CRKWindow; + +class TKRepeatTest : public CTestBase + { +public: + TKRepeatTest(); + ~TKRepeatTest(); + TestState DoTestL(); + void ConstructL(); + void TestKeyboardRepeatRateL(const TTimeIntervalMicroSeconds32 &aInitialTime, const TTimeIntervalMicroSeconds32 &aTime); + TBool CheckReportL(); +public: + TBool iAbort; +private: + TTimeIntervalMicroSeconds32 iOldInitialTime; + TTimeIntervalMicroSeconds32 iOldTime; + CRKWindow *iWin; + TSize iWinSize; + TInt iState; + }; + +class CRKWindow : public CTWin + { + enum TRKStates { + EStateWaitingForKeyDown, + EStateWaitingForKeyCode, + EStateWaitingForFirstRepeat, + EStateWaitingForNthRepeat, + EStateWaitingForKeyUp, + EStateInactive, + EStateError, + }; +public: + CRKWindow(TKRepeatTest *aTest); + void SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc); + void SetState(TRKStates aState); + void SetKeyboardRepeatRate(const TTimeIntervalMicroSeconds32 &aInitialTime, const TTimeIntervalMicroSeconds32 &aTime); + void WinKeyL(const TKeyEvent &,const TTime &); + void KeyUpL(const TKeyEvent &aKey,const TTime &aTime); + void KeyDownL(const TKeyEvent &aKey,const TTime &aTime); + void Draw(); + TDesC& Report(); + TBool CheckResults(); +protected: + TInt iConnIndex; + TKRepeatTest *iTest; + TRgb iBack; + TRKStates iState; + TInt iDownCode; + TInt iRepCount; + TTimeIntervalMicroSeconds32 iInitialRepeatSet; + TTimeIntervalMicroSeconds32 iRepeatSet; + TTime iPrevTime; + TTimeIntervalMicroSeconds32 iInitialGap; + TTimeIntervalMicroSeconds32 iTotalGap; + TTimeIntervalMicroSeconds32 iMinGap; + TTimeIntervalMicroSeconds32 iMaxGap; + TBuf<0x40> iReport; + }; + +GLDEF_C CTestBase *CreateKRepeatTest() + { + return(new(ELeave) TKRepeatTest()); + } + +// +// CRKWindow, class // +// + +CRKWindow::CRKWindow(TKRepeatTest *aTest) : CTWin(), iTest(aTest) + { + } + +void CRKWindow::SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc) + { + ConstructExtLD(*parent,pos,size); + iWin.SetBackgroundColor(TRgb::Gray256(230)); + Activate(); + AssignGC(aGc); + } + +void CRKWindow::Draw() + { + iGc->Clear(); + switch(iState) + { + case EStateWaitingForKeyDown: + iGc->DrawText(_L("Press and hold the space bar"), TPoint(10,20)); + break; + case EStateWaitingForFirstRepeat: + case EStateWaitingForNthRepeat: + { + TBuf<0x40> buf; + buf.Format(TRefByValue(_L("Keep space bar down (%d repeats so far)")),iRepCount); + iGc->DrawText(buf, TPoint(10,20)); + } + break; + case EStateWaitingForKeyUp: + iGc->DrawText(_L("Release space bar"), TPoint(10,20)); + default: + break; + } + } + +void CRKWindow::SetState(TRKStates aState) + { + iState=aState; + DrawNow(); + } + +TBool CRKWindow::CheckResults() + { +// +// Checks repeat results, first convert everything to 10th's as that what is actually used +// for the timer in the window server. +// +// Return ETrue if the inacuracy in the average time is greater than 1/10th either way +// Allow initial 2/10ths either +// Allow min 2/10ths below +// Allow max 2/10ths above +// + if (iState!=EStateInactive) + return(ETrue); + TInt initial=iInitialGap.Int()/100000; + TInt initialX=iInitialRepeatSet.Int()/100000; + if (initialX==0) + initialX=1; + TInt average=(iTotalGap.Int()/100000)/(iRepCount-1); + TInt repeatX=iRepeatSet.Int()/100000; + if (repeatX==0) + repeatX=1; + TInt min=iMinGap.Int()/100000; + TInt max=iMaxGap.Int()/100000; + if (average>(repeatX+1) || average<(repeatX-1)) + return(ETrue); + if (initial>(initialX+2) || initial<(initialX-2)) + return(ETrue); + if (min>(repeatX+1) || min<(repeatX-2)) + return(ETrue); + if (max>(repeatX+3) || max(_L("Initial=%d [%d], Av=%d [%d], Min=%d, Max=%d")),initial,initialX,average,repeatX,min,max); + } + return(iReport); + } + +void CRKWindow::KeyDownL(const TKeyEvent &aKey,const TTime &) + { + switch(iState) + { + case EStateWaitingForKeyDown: + SetState(EStateWaitingForKeyCode); + iDownCode=aKey.iScanCode; + break; + default:; + } + } + +void CRKWindow::KeyUpL(const TKeyEvent &aKey,const TTime &) + { + if (aKey.iScanCode==iDownCode) + { + switch(iState) + { + case EStateWaitingForKeyUp: + SetState(EStateInactive); + break; + default: + SetState(EStateError); + break; + } + CActiveScheduler::Stop(); + } + } + +void CRKWindow::WinKeyL(const TKeyEvent &aKey,const TTime &aTime) + { + if (aKey.iCode==EKeyEscape) + { + CActiveScheduler::Stop(); + iTest->iAbort=ETrue; + } + if (aKey.iCode==32) + { + switch(iState) + { + case EStateWaitingForKeyCode: + SetState(EStateWaitingForFirstRepeat); + iPrevTime=aTime; + break; + case EStateWaitingForFirstRepeat: + iRepCount=1; + iInitialGap = I64LOW(aTime.MicroSecondsFrom(iPrevTime).Int64()); + SetState(EStateWaitingForNthRepeat); + break; + case EStateWaitingForNthRepeat: + if (iRepCount==5) + SetState(EStateWaitingForKeyUp); + else + { + TTimeIntervalMicroSeconds32 gap(I64LOW(aTime.MicroSecondsFrom(iPrevTime).Int64())); + if (gapiMaxGap) + iMaxGap=gap; + iTotalGap=iTotalGap.Int()+gap.Int(); // Horrible way to do a += + iRepCount++; + SetState(EStateWaitingForNthRepeat); + } + case EStateWaitingForKeyUp: // Do nothing here + break; + default: + iTest->TestL(EFalse); + } + iPrevTime=aTime; + } + } + +void CRKWindow::SetKeyboardRepeatRate(const TTimeIntervalMicroSeconds32 &aInitialTime, const TTimeIntervalMicroSeconds32 &aTime) + { + iInitialRepeatSet=aInitialTime; + iRepeatSet=aTime; + iMinGap=TTimeIntervalMicroSeconds32(100000000); // Any very big number will do + iMaxGap=TTimeIntervalMicroSeconds32(0); + iTotalGap=TTimeIntervalMicroSeconds32(0); + SetState(EStateWaitingForKeyDown); + Client()->iWs.Flush(); + } + +// + +TKRepeatTest::TKRepeatTest() : CTestBase(_L("KRepeat")) + {} + +TKRepeatTest::~TKRepeatTest() + { + CTWin::Delete(iWin); + Client()->iWs.SetKeyboardRepeatRate(iOldInitialTime, iOldTime); + } + +void TKRepeatTest::ConstructL() + { + iWin=new(ELeave) CRKWindow(this); + TSize screenSize=Client()->iGroup->Size(); + iWin->SetUpL(TPoint(5,5),TSize(screenSize.iWidth/2,screenSize.iHeight-10),Client()->iGroup,*Client()->iGc); + Client()->iGroup->SetCurrentWindow(iWin); + Client()->iWs.GetKeyboardRepeatRate(iOldInitialTime, iOldTime); + } + +TInt TKRepeatTest::CheckReportL() + { + if (iWin->CheckResults()) + { + CTDialog *dialog=new(ELeave) CTDialog(); + dialog->SetTitle(_L("Keyboard repeat innacuracies")); + dialog->SetLine1(iWin->Report()); + dialog->SetNumButtons(2); + dialog->SetButtonText(0,_L("Okay")); + dialog->SetButtonText(1,_L("Retest")); + dialog->SetButtonText(2,_L("Fail")); + dialog->ConstructLD(*Client()->iGroup,*Client()->iGc); + switch(dialog->Display()) + { + case 0: + break; + case 1: + return(ETrue); // Redo test + case 2: + TestL(EFalse); + break; + } + } + return(EFalse); + } + +void TKRepeatTest::TestKeyboardRepeatRateL(const TTimeIntervalMicroSeconds32 &aInitialTime, const TTimeIntervalMicroSeconds32 &aTime) + { + do + { + Client()->iWs.SetKeyboardRepeatRate(aInitialTime, aTime); + iWin->SetKeyboardRepeatRate(aInitialTime, aTime); + CActiveScheduler::Start(); + if (iAbort) + AbortL(); + } while(CheckReportL()); + } + +TestState TKRepeatTest::DoTestL() + { + switch(iState) + { + case 0: + LogSubTest(_L("Keyboard Repeat"),1); + TestKeyboardRepeatRateL(TTimeIntervalMicroSeconds32(1000000), TTimeIntervalMicroSeconds32(500000)); + LogSubTest(_L("Keyboard Repeat"),2); + TestKeyboardRepeatRateL(TTimeIntervalMicroSeconds32(200000), TTimeIntervalMicroSeconds32(100000)); + LogSubTest(_L("Keyboard Repeat"),3); + TestKeyboardRepeatRateL(TTimeIntervalMicroSeconds32(0), TTimeIntervalMicroSeconds32(100000)); + LogSubTest(_L("Keyboard Repeat"),4); + TestKeyboardRepeatRateL(TTimeIntervalMicroSeconds32(100000), TTimeIntervalMicroSeconds32(100000)); + iState++; + break; + default: + return(EFinished); + } + return(ENext); + } + diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tman/TMAN.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tman/TMAN.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,490 @@ +// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Manual window server tests +// Note: Wherever possible tests should be put into the TAUTO automatic test +// code test should only go here when manual operation is essential +// +// + +#include +#include "W32STD.H" +#include +#include "TMAN.H" + +#define LOG_TESTS + +class ErrorDialog : public CTDialog + { +public: + ErrorDialog(CTestBase *aTest); + void ButtonPressL(TInt aButton); +private: + CTestBase *iTest; + }; + +class TestWindowGroup : public CTWindowGroup + { +public: + TestWindowGroup(CTClient *aClient); + void ConstructL(); + void KeyL(const TKeyEvent &aKey,const TTime &aTime); + void KeyDownL(const TKeyEvent &aKey,const TTime &aTime); + void KeyUpL(const TKeyEvent &aKey,const TTime &aTime); + }; + +class CTManScheduler : public CActiveScheduler + { +public: + void SetClient(TestClient *aClient); + void Error(TInt anError) const; +private: + void doErrorL(TInt anError) const; +private: + TestClient *iClient; + }; + +typedef CTestBase *(*CTestBaseCreate)(); + +GLREF_C CTestBase *CreateScreenModeTest(); +GLREF_C CTestBase *CreateScaleTest(); +GLREF_C CTestBase *CreateTextTest(); +GLREF_C CTestBase *CreateDummyTest(); +GLREF_C CTestBase *CreateMultiConTest(); +GLREF_C CTestBase *CreateMultiCaptureKeyTest(); +GLREF_C CTestBase *CreateHotKeyTest(); +GLREF_C CTestBase *CreatePointerTest(); +GLREF_C CTestBase *CreatePointerCaptureTest(); +GLREF_C CTestBase *CreatePointerBufferTest(); +GLREF_C CTestBase *CreateModifiersChangedTest(); +GLREF_C CTestBase *CreatePointerKeyTest(); +GLREF_C CTestBase *CreatePasswordTest(); +GLREF_C CTestBase *CreatePointerCursorTest(); +GLREF_C CTestBase *CreateScreenModeTimes(); + +// Tests that have not been converted to tauto yet +CTestBaseCreate CreateTestClass[]={ + CreateScreenModeTimes, + CreatePointerCursorTest, + CreatePointerTest, //Mostly converted + CreatePointerKeyTest, //Mostly converted + CreateModifiersChangedTest, //Partially Conerted + CreatePointerBufferTest, + CreateTextTest, + CreateScaleTest, + CreateDummyTest, + }; + +LogWindow *LogWin; + +void TManPanic(TInt aPanic) + { + User::Panic(_L("Auto"),aPanic); + } + +// +// Log window, logs testing // +// + +LogWindow::LogWindow() : CTWin() + { + } + +void LogWindow::ConstructL(CTWinBase &parent) + { + CTWin::ConstructL(parent); + iTitleHeight=iFont->HeightInPixels()+4; + } + +void LogWindow::Draw() + { + iGc->SetPenColor(TRgb::Gray16(8)); + iGc->SetPenColor(TRgb::Gray16(0)); + DrawBorder(); + iGc->DrawLine(TPoint(0,iTitleHeight),TPoint(iSize.iWidth,iTitleHeight)); + iGc->DrawText(iTestTitle, TPoint((iSize.iWidth-iFont->TextWidthInPixels(iTestTitle))/2,iFont->AscentInPixels()+2)); + } + +void LogWindow::LogTest(TDesC &aTitle,TInt aNum) + { + iTestTitle.Format(TRefByValue(_L("Test %d,%S")),aNum,&aTitle); + iWin.Invalidate(); + Client()->iWs.Flush(); + } + +// +// Test window, simple window used to do test graphics in // +// +TestWindow::TestWindow() : CTWin() + { + } + +void TestWindow::SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc) + { + iBorderWin=new(ELeave) BorderWindow(); + iBorderWin->SetUpL(pos,size,parent,aGc); + CTWin::ConstructExtLD(*iBorderWin,TPoint(2,2),TSize(size.iWidth-4,size.iHeight-4)); + Activate(); + AssignGC(aGc); + } + +void TestWindow::Draw() + { + iGc->Clear(); + } + +// +BorderWindow::BorderWindow() : CTWin() + { + } + +void BorderWindow::ConstructL(CTWinBase &parent) + { + CTWin::ConstructL(parent); + } + +void BorderWindow::Draw() + { + iGc->SetBrushColor(TRgb::Gray16(0)); + iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + iGc->SetPenStyle(CGraphicsContext::ENullPen); + iGc->DrawRect(TRect(Size())); + } + +// + +TestWindowGroup::TestWindowGroup(CTClient *aClient) : CTWindowGroup(aClient) + { + } + +void TestWindowGroup::ConstructL() + { + CTWindowGroup::ConstructL(); + GroupWin()->EnableScreenChangeEvents(); + } + +void TestWindowGroup::KeyDownL(const TKeyEvent &aKey,const TTime &aTime) + { + if (iCurWin) + iCurWin->KeyDownL(aKey,aTime); + } + +void TestWindowGroup::KeyUpL(const TKeyEvent &aKey,const TTime &aTime) + { + if (iCurWin) + iCurWin->KeyUpL(aKey,aTime); + } + +void TestWindowGroup::KeyL(const TKeyEvent &aKey,const TTime &aTime) + { + if (aKey.iModifiers&EModifierFunc) + { + switch(aKey.iCode) + { + case 'f': + ((TestClient *)Client())->Driver()->iTest->TriggerFail(); + break; + } + } + else if (iCurWin) + iCurWin->WinKeyL(aKey,aTime); + } + +// + +TestClient::TestClient() + { + } + +void TestClient::ConstructL() + { + CTClient::ConstructL(); + + iGroup=new(ELeave) TestWindowGroup(this); + iGroup->ConstructL(); + + TSize screenSize=iGroup->Size(); + TInt winWidth=(screenSize.iWidth/3)-10; + TInt winHeight=screenSize.iHeight-10; + LogWin=new(ELeave) LogWindow(); + LogWin->SetUpL(TPoint(5+winWidth*2,5),TSize(winWidth,winHeight),iGroup,*iGc); + iDriver=new(ELeave) TestDriver(this); + } + +TestClient::~TestClient() + { + delete iDriver; + } + +TestDriver *TestClient::Driver() + { + return(iDriver); + } + +// +// Error dialog // +// + +ErrorDialog::ErrorDialog(CTestBase *aTest) : CTDialog(), iTest(aTest) + {} + +void ErrorDialog::ButtonPressL(TInt aButton) + { + switch(aButton) + { + case 0: + { + CTestBase *test=iTest; + CTDialog::Delete(this); + if (test) + test->Driver()->DestroyTest(); + CActiveScheduler::Stop(); + User::Leave(0); // Signals RunL not to do another request + } + break; + case 1: + CTestBase *test=iTest; + CTDialog::Delete(this); + if (test) + { + test->Driver()->TestComplete(); + test->Driver()->DestroyTest(); + } + break; + } + } + +// +// TestDriver, drives the test code // +// + +TestDriver::TestDriver(TestClient *aClient) : CActive(-10), iClient(aClient) + { + CActiveScheduler::Add(this); + Request(); + } + +TestClient *TestDriver::Client() + { + return(iClient); + } + +TestDriver::~TestDriver() + { + Cancel(); + DestroyTest(); + } + +void TestDriver::DoCancel() + { + TRequestStatus *pStat= &iStatus; + RThread().RequestComplete(pStat,KErrCancel); + } + +void TestDriver::Request() + { + TRequestStatus *pStat= &iStatus; + RThread().RequestComplete(pStat,KErrNone); + SetActive(); + } + +void TestDriver::RunL() + { + iTest=(*CreateTestClass[iTestNum])(); + iTest->StartTest(iTestNum,this); + iTest->ConstructL(); + } + +void TestDriver::TestComplete() + { + iTestNum++; + if (iTestNum==sizeof(CreateTestClass)/sizeof(CreateTestClass[0])) + { + DisplayDialog(_L("Tests complete"),_L(""),_L("")); + CActiveScheduler::Stop(); + } + else + Request(); + } + +void TestDriver::DestroyTest() + { + delete iTest; + iTest=NULL; + } + +// CTestBase // + +CTestBase::CTestBase(const TDesC &aTitle) : CActive(-10) + { + CActiveScheduler::Add(this); + iTitle.Copy(aTitle); + } + +CTestBase::~CTestBase() + { + User::Free(iBuf1); + User::Free(iBuf2); + Cancel(); + } + +void CTestBase::DoCancel() + { + TRequestStatus *pStat= &iStatus; + RThread().RequestComplete(pStat,KErrCancel); + } + +void CTestBase::Request() + { + TRequestStatus *pStat= &iStatus; + RThread().RequestComplete(pStat,KErrNone); + SetActive(); + } + +void CTestBase::TriggerFail() + { + iFail=ETrue; + } + +TestClient *CTestBase::Client() + { + return(iDriver->Client()); + } + +void CTestBase::LogLeave(TInt aErr) + { +#if defined(LOG_TESTS) + TLogMessageText buf; + _LIT(KLeave,"MAN Left with error code %d in sub-test %d: "); + buf.AppendFormat(KLeave,aErr,iSubTestNum); + buf.Append(iSubTitle); + Client()->LogMessage(buf); +#else + aErr=KErrNone; //To stop a warning +#endif + } + +void CTestBase::RunL() + { + TInt ret=EInvalid; + TRAPD(err,ret=DoTestL()); + if (err!=KErrNone) + { + LogLeave(err); + if (err!=ETestFailed) + { + User::Leave(err); + } + } + else if (ret==EFinished) + { + iDriver->TestComplete(); + iDriver->DestroyTest(); + } + else if (ret==ENext) + Request(); + } + +void CTestBase::StartTest(TInt aNum, TestDriver *aDriver) + { + iDriver=aDriver; + iTestNum=aNum; + LogWin->LogTest(iTitle,aNum); +#if defined(LOG_TESTS) + TLogMessageText buf; + _LIT(ManNewTest,"MAN New Test %d: "); + buf.AppendFormat(ManNewTest,aNum); + buf.Append(iTitle); + Client()->LogMessage(buf); +#endif + Request(); + } + +void CTestBase::LogSubTest(const TDesC &aSubTitle,TInt aNum) + { + iSubTestNum=aNum; + iSubTitle=aSubTitle; +#if defined(LOG_TESTS) + TLogMessageText buf; + _LIT(ManSubTest,"MAN SubTest %d: "); + buf.AppendFormat(ManSubTest,iSubTestNum); + buf.Append(iSubTitle); + Client()->LogMessage(buf); +#endif + } + +void CTestBase::AbortL() + { + TestDriver *driver=iDriver; + iDriver->DestroyTest(); + driver->TestComplete(); + User::Leave(ETestFailed); + } + +void CTestBase::TestL(TInt aCondition) + { + if (!aCondition || iFail) + { + iFail=EFalse; + ErrorDialog *dialog=new ErrorDialog(this); + if (dialog) + { + dialog->SetTitle(_L("Test failed")); + dialog->SetNumButtons(2); + dialog->SetButtonText(0,_L("Abort all tests")); + dialog->SetButtonText(1,_L("Continue other tests")); + dialog->ConstructLD(*Client()->iGroup,*Client()->iGc); + dialog->Display(); + } + User::Leave(ETestFailed); + } + } + +void CTManScheduler::SetClient(TestClient *aClient) + { + iClient=aClient; + } + +void CTManScheduler::Error(TInt aError) const + { + TRAP_IGNORE(doErrorL(aError)); + CActiveScheduler::Stop(); + } + +void CTManScheduler::doErrorL(TInt aError) const + { + CTDialog *dialog=new(ELeave) CTDialog(); + if (dialog) + { + TWindowTitle title; + title.Format(TRefByValue(_L("Error %d")),aError); + dialog->SetTitle(title); + dialog->SetNumButtons(1); + dialog->SetButtonText(0,_L("Abort tests")); + dialog->ConstructLD(*iClient->iGroup,*iClient->iGc); + dialog->Display(); + } + } + +// + +GLDEF_C CTClient *CreateClientL() + { + return(new(ELeave) TestClient()); + } + + +GLDEF_C TInt E32Main() +{ +return(TestLibStartUp(CreateClientL)); +} diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tman/TMAN.H --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tman/TMAN.H Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,149 @@ +// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Header for window server auto test code +// +// + +#include +#include +#include "W32STD.H" +#include "../tlib/testbase.h" + +class TestClient; + +enum TestState + { + EInvalid, + ENext, + EContinue, + EFinished + }; + +enum TAutoPanics + { + ETManPanicPcFailed, + }; + +enum TAutoLeaves + { + ETestFailed=1, + }; + +class LogWindow : public CTWin + { +public: + LogWindow(); + void ConstructL(CTWinBase &parent); + void Draw(); + void LogTest(TDesC &aTitle,TInt aNum); +private: + TBuf<0x40> iTestTitle; + TInt iTitleHeight; + }; + +class CTestBase; + +class BorderWindow : public CTWin + { +public: + BorderWindow(); + void ConstructL(CTWinBase &parent); + void Draw(); + }; + +class TestWindow : public CTWin + { +public: + TestWindow(); + void Draw(); + void SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc); +private: + BorderWindow *iBorderWin; + friend class CTestBase; + }; + +class TestDriver : public CActive + { +public: + TestDriver(TestClient *aClient); + ~TestDriver(); + void DoCancel(); + void RunL(); + void Request(); + void TestComplete(); + void DestroyTest(); + TestClient *Client(); +public: + CTestBase *iTest; +private: + TInt iTestNum; + TestClient *iClient; + }; + +class CTestBase : public CActive + { +public: + CTestBase(const TDesC &aTitle); + ~CTestBase(); + void DoCancel(); + void RunL(); + void Request(); + void TestL(TInt aCondition); + void StartTest(TInt aNum, TestDriver *aDriver); + void LogSubTest(const TDesC &aTitle,TInt aNum); + void TestPanic(TThreadFunction aFunction, TAny *aPtr, TInt aExitReason, const TDesC &aCategory); + void TestWsPanic(TThreadFunction aFunction, TAny *aPtr, TInt aExitReason); + void TestWsPanic(TThreadFunction aFunction, TInt aInt, TInt aExitReason); + void TriggerFail(); + void LogLeave(TInt aErr); + void CheckRect(CTWin *aWin1,CTWin *aWin2,const TRect &aRect); + void CompareWindows(TRect &aRect); + void CompareWindows(); + void CheckBorder(); + void DrawTestBackground(TBool aInvertColours); + inline TestDriver *Driver(); + virtual TestState DoTestL()=0; + virtual void ConstructL()=0; + TestClient *Client(); + void AbortL(); +protected: + TestDriver *iDriver; + TAny *iBuf1; + TAny *iBuf2; +private: + TInt iTestNum; + TInt iSubTestNum; + TBuf<0x40> iTitle; + TBuf<0x40> iSubTitle; + TBool iFail; // Used to trigger failures to test test code. + }; + +class TestClient : public CTClient + { +public: + TestClient(); + ~TestClient(); + void ConstructL(); + void KeyL(const TKeyEvent &aKey,const TTime &aTime); + void Shutdown(); + TestDriver *Driver(); +private: + TestDriver *iDriver; + }; + +GLREF_D CWindowGc *TheGc; +GLREF_C void TManPanic(TInt aPanic); + +inline TestDriver *CTestBase::Driver() + {return(iDriver);} diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tman/TMCAPKEY.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tman/TMCAPKEY.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,625 @@ +// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Test capture key +// +// + +#include +#include +#include +#include "W32STD.H" +#include "../tlib/testbase.h" +#include "TMAN.H" + +enum TTestMode + { + EModeNormalCapture, + EModeWaitingForFirstDown, + EModeKeyUpsAndDowns, + EModeAbortKeys, + }; +enum TCapKeyRetValues + { + ECapKeyOkay, + ECapKeyRetry, + ECapKeyFail, + }; + +struct SCapKeyParams + { + TInt connIndex; // Connection that should capture this key + TUint keyCode; + TUint modifier_mask; + TUint modifiers; + }; + +struct SCapKeyTestParams + { + TText *txt; // Text message telling user what to do + TInt connIndex; // Connection that receive the key press + TUint keyCode; // Expected key code + TUint modifier_mask;// Modifiers mask for expected modifiers + TUint modifiers; // Expected modifiers + }; + +struct SAbortKeyTests + { + TUint keyCode; // Expected key code + TUint modifier_mask;// Modifiers mask for expected modifiers + TUint modifiers; // Expected modifiers + }; + +LOCAL_D SCapKeyParams capKeys[]={ + {1,19,EModifierFunc|EModifierCtrl,EModifierFunc|EModifierCtrl}, + {2,'b',EModifierFunc|EModifierCtrl,EModifierFunc}, + {2,'n',EModifierFunc|EModifierCtrl,EModifierFunc}, + {0,3,EModifierFunc|EModifierCtrl,EModifierFunc|EModifierCtrl}, + {2,'q',0,0}, + {2,'w',0,0}, + }; + +LOCAL_D SCapKeyParams capUpAndDownKeys[]={ + {2,EStdKeySpace,EModifierFunc|EModifierCtrl|EModifierShift,0}, + {2,EStdKeyEnter,EModifierFunc|EModifierCtrl|EModifierShift,EModifierShift}, + }; + +LOCAL_D SCapKeyTestParams capKeyTests[]={ + {(TText *)_S("Press q"),2,'q',EModifierFunc|EModifierCtrl|EModifierShift,0}, + //{(TText *)_S("Press q"),2,'q',EModifierFunc|EModifierCtrl|EModifierShift,EModifierFunc}, + {(TText *)_S("Press w"),2,'w',EModifierFunc|EModifierCtrl|EModifierShift,EModifierFunc}, + {(TText *)_S("Press a"),0,'a',0}, + //{(TText *)_S("Press a"),1,1,EModifierFunc|EModifierCtrl|EModifierShift,EModifierFunc|EModifierCtrl}, + {(TText *)_S("Press s"),1,19,EModifierFunc|EModifierCtrl|EModifierShift,EModifierFunc|EModifierCtrl}, + //{(TText *)_S("Press b"),2,'b',EModifierFunc|EModifierCtrl|EModifierShift,EModifierFunc}, + {(TText *)_S("Press n"),2,'n',EModifierFunc|EModifierCtrl|EModifierShift,EModifierFunc}, + {(TText *)_S("Press b"),0,2,EModifierFunc|EModifierCtrl|EModifierShift,EModifierFunc|EModifierCtrl}, + //{(TText *)_S("Press c"),0,'c',EModifierFunc|EModifierCtrl|EModifierShift,EModifierFunc}, + {(TText *)_S("Press d"),0,'d',EModifierFunc|EModifierCtrl|EModifierShift,EModifierFunc}, + {(TText *)_S("Press c"),0,3,EModifierFunc|EModifierCtrl|EModifierShift,EModifierFunc|EModifierCtrl}, +// +// Capture ups and downs +// + {(TText *)_S("Press "),2,EStdKeySpace,EModifierFunc|EModifierCtrl|EModifierShift,0}, + {(TText *)_S("Press "),0,EStdKeyEnter,EModifierShift,0}, + {(TText *)_S("Press "),0,EStdKeySpace,EModifierFunc|EModifierCtrl|EModifierShift,EModifierShift}, + {(TText *)_S("Press "),2,EStdKeyEnter,EModifierShift,EModifierShift}, +// +// Priority keys +// + {(TText *)_S("Press c"),0,0,0,0}, + {(TText *)_S("Press d"),0,0,0,0}, + {(TText *)_S("Press z"),0,0,0,0}, + }; + +LOCAL_D SAbortKeyTests abortKeyTests[]={ + {3,EModifierCtrl,EModifierCtrl}, + {4,EModifierCtrl,EModifierCtrl}, + {'z',EModifierFunc|EModifierCtrl|EModifierShift,0} + }; + +struct SErrorCapKey + { + TInt keyCode; + TUint modifier_mask; + TUint modifiers; + }; + +LOCAL_D SErrorCapKey errorKeys[]={ + {'a',EModifierFunc|EModifierShift,EModifierFunc|EModifierCtrl}, + {'1',0,EModifierFunc}, + {3,EModifierCtrl,EModifierCtrl|EModifierShift}, + }; + +const TInt numCapKeys=sizeof(capKeys)/sizeof(capKeys[0]); +const TInt numTests=sizeof(capKeyTests)/sizeof(capKeyTests[0]); +const TInt numErrorKeys=sizeof(errorKeys)/sizeof(errorKeys[0]); +const TInt numAbortKeyTests=sizeof(abortKeyTests)/sizeof(abortKeyTests[0]); +const TInt numUpDownKeys=sizeof(capUpAndDownKeys)/sizeof(capUpAndDownKeys[0]); +const TInt numUpDownKeyTests=4; +const TInt numCapKeyTests=numTests-numAbortKeyTests-numUpDownKeyTests; + +LOCAL_D TInt capKeyHandle[numCapKeys]; +LOCAL_D TInt capUpDownKeyHandle[numUpDownKeys]; + +class CCKWindow; +class TCaptureKeyTest; +class CCKAbortConnection; + +class CCKConnectionBase : public CTClient + { +public: + CCKConnectionBase(TCaptureKeyTest *aTest); + void ConstructL(); +protected: + TCaptureKeyTest *iTest; + }; + +class CCKConnection : public CCKConnectionBase + { +public: + CCKConnection(TCaptureKeyTest *aTest, TInt aConnIndex); + ~CCKConnection(); + void ConstructL(); + void CheckKeyL(const SCapKeyTestParams &aKeyTest, const TKeyEvent &aKey); + void SubStateChanged(); + void KeyTestL(TInt aBool); + void KeyL(const TKeyEvent &aKey,const TTime &aTime); + void CheckUpDownL(const SCapKeyTestParams &aKeyTest, const TKeyEvent &aKey); + void CheckUpDownL(const TKeyEvent &aKey); + inline TInt Index() {return iConnIndex;} +protected: + TInt iConnIndex; + CCKWindow *iWin; + }; + +class CAbortHandler : public CTEventBase + { +public: + CAbortHandler(RWsSession *aWs, CCKAbortConnection *aConnection); + ~CAbortHandler(); + void Request(); +protected: + void DoCancel(); + void doRunL(); +protected: + CCKAbortConnection *iConnection; + }; + +class CCKAbortConnection : public CCKConnectionBase + { +public: + CCKAbortConnection(TCaptureKeyTest *aTest); + ~CCKAbortConnection(); + void ConstructL(); + void ReceivedAbortEventL(TInt aHandle, TKeyEvent *aKey); + void Foreground(); +protected: + CAbortHandler *iAbortHandler; + TInt iAbortKeyIndex; + }; + +class CCKWindow : public CTWin + { +public: + CCKWindow(TCaptureKeyTest *aTest, TInt aConnIndex); + void SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc); + void Draw(); +protected: + TInt iConnIndex; + TCaptureKeyTest *iTest; + TRgb iBack; + }; + +class CCKWindowGroup : public CTWindowGroup + { +public: + CCKWindowGroup(CTClient *aClient, TCaptureKeyTest *aTest); + void KeyL(const TKeyEvent &aKey,const TTime &aTime); + void KeyDownL(const TKeyEvent &aKey,const TTime &); + void KeyUpL(const TKeyEvent &aKey,const TTime &); + void CheckUpDown(const SCapKeyTestParams &aKeyTest, const TKeyEvent &aKey); +private: + TCaptureKeyTest *iTest; + }; + +class TCaptureKeyTest : public CTestBase + { +public: + TCaptureKeyTest(); + ~TCaptureKeyTest(); + TestState DoTestL(); + void ConstructL(); + void EndCaptureKeyTest(); + TInt SubState() const; + void IncSubState(); + void BadParamsL(); + void CapKeyPurgingL(); + void SetUpPriorityKeyTest(); + void TestComplete(); + void CaptureUpsAndDownsTest(); + TTestMode Mode(); + void SetMode(TTestMode aMode); +private: + CCKConnection *iConn1; + CCKConnection *iConn2; + CCKConnection *iConn3; + CCKAbortConnection *iAbortConn; + TSize iWinSize; + TInt iState; + TInt iSubState; + TTestMode iMode; + }; + +GLDEF_C CTestBase *CreateMultiCaptureKeyTest() + { + return(new(ELeave) TCaptureKeyTest()); + } + +// +// CAbortHandler + +CAbortHandler::CAbortHandler(RWsSession *aWs, CCKAbortConnection *aConnection) : CTEventBase(aWs, 10), iConnection(aConnection) + { + } + +CAbortHandler::~CAbortHandler() + { + Cancel(); + } + +void CAbortHandler::Request() + { + iWs->PriorityKeyReady(&iStatus); + SetActive(); + } + +void CAbortHandler::DoCancel() + { + iWs->PriorityKeyReadyCancel(); + } + +void CAbortHandler::doRunL() + { + TWsPriorityKeyEvent abortEvent; + iWs->GetPriorityKey(abortEvent); + iConnection->ReceivedAbortEventL(abortEvent.Handle(),abortEvent.Key()); + } + +// +// CCKConnection + +CCKConnectionBase::CCKConnectionBase(TCaptureKeyTest *aTest) : iTest(aTest) + { + } + +void CCKConnectionBase::ConstructL() + { + CTClient::ConstructL(); + iGroup=new(ELeave) CCKWindowGroup(this, iTest); + iGroup->ConstructL(); + } + +CCKConnection::CCKConnection(TCaptureKeyTest *aTest, TInt aConnIndex) : CCKConnectionBase(aTest), iConnIndex(aConnIndex) + { + } + +CCKConnection::~CCKConnection() + { + for(TInt index=0;indexGroupWin()->CancelCaptureKey(capKeyHandle[index]); + for(TInt index2=0;index2GroupWin()->CancelCaptureKeyUpAndDowns(capUpDownKeyHandle[index2]); + CTWin::Delete(iWin); + } + +void CCKConnection::SubStateChanged() + { + iWin->Invalidate(); + iWs.Flush(); + } + +void CCKConnection::ConstructL() + { + CCKConnectionBase::ConstructL(); + for(TInt index=0;indexGroupWin()->CaptureKey(capKeys[index].keyCode,capKeys[index].modifier_mask,capKeys[index].modifiers)); + for(TInt index2=0;index2GroupWin()->CaptureKeyUpAndDowns(capUpAndDownKeys[index2].keyCode, + capUpAndDownKeys[index2].modifier_mask,capUpAndDownKeys[index2].modifiers)); + TSize screenSize=iGroup->Size(); + TInt winWidth=screenSize.iWidth/2; + TInt winHeight=screenSize.iHeight-10; + iGroup->GroupWin()->AutoForeground(EFalse); // Don't allow clicking to cause foreground, might mess up test + CCKWindow *win=new(ELeave) CCKWindow(iTest, iConnIndex); + win->SetUpL(TPoint(5,5),TSize(winWidth,winHeight),iGroup,*iGc); + iWin=win; + } + +void CCKConnection::KeyTestL(TInt aBool) + { + if (!aBool) + { + CTDialog *dialog=new(ELeave) CTDialog(); + TInt ret=0; + dialog->ConstructLD(*iGroup,*iGc); + dialog->SetTitle(_L("Invalid key press")); + dialog->SetLine1(_L("Try again?")); + dialog->SetNumButtons(2); + dialog->SetButtonText(0,_L("Fail")); + dialog->SetButtonText(1,_L("Retry")); + ret=dialog->Display(); + User::Leave(ret==1 ? ECapKeyRetry : ECapKeyFail); + } + } + +void CCKConnection::CheckKeyL(const SCapKeyTestParams &aKeyTest, const TKeyEvent &aKey) + { + KeyTestL(aKeyTest.connIndex==iConnIndex); + KeyTestL(aKeyTest.keyCode==aKey.iCode); + KeyTestL(aKeyTest.modifiers==(aKey.iModifiers&aKeyTest.modifier_mask)); + } + +void CCKConnection::CheckUpDownL(const SCapKeyTestParams &aKeyTest, const TKeyEvent &aKey) + { + KeyTestL(aKeyTest.connIndex==iConnIndex); + KeyTestL(aKeyTest.keyCode==(TUint)aKey.iScanCode); + KeyTestL(aKeyTest.modifiers==(aKey.iModifiers&aKeyTest.modifier_mask)); + } + +void CCKConnection::KeyL(const TKeyEvent &aKey,const TTime &) + { + if (iTest->Mode()==EModeNormalCapture) + { + if (aKey.iCode==EKeyEscape) + iTest->AbortL(); + TRAPD(ret,CheckKeyL(capKeyTests[iTest->SubState()],aKey)); + if (ret==ECapKeyOkay) + iTest->IncSubState(); + else + iTest->TestL(ret==ECapKeyRetry); + } + } + +void CCKConnection::CheckUpDownL(const TKeyEvent &aKey) + { + CheckUpDownL(capKeyTests[iTest->SubState()],aKey); + } + +CCKAbortConnection::CCKAbortConnection(TCaptureKeyTest *aTest) : CCKConnectionBase(aTest) + { + } + +CCKAbortConnection::~CCKAbortConnection() + { + iGroup->GroupWin()->RemovePriorityKey(3,EModifierCtrl,EModifierCtrl); + delete iAbortHandler; + } + +void CCKAbortConnection::ConstructL() + { + CCKConnectionBase::ConstructL(); + User::LeaveIfError(iGroup->GroupWin()->AddPriorityKey(abortKeyTests[0].keyCode,abortKeyTests[0].modifier_mask,abortKeyTests[0].modifiers)); + User::LeaveIfError(iGroup->GroupWin()->AddPriorityKey(abortKeyTests[1].keyCode,abortKeyTests[1].modifier_mask,abortKeyTests[1].modifiers)); + User::LeaveIfError(iGroup->GroupWin()->AddPriorityKey(abortKeyTests[2].keyCode,abortKeyTests[2].modifier_mask,abortKeyTests[2].modifiers)); + iAbortHandler=new(ELeave) CAbortHandler(&iWs, this); + iAbortHandler->Construct(); + iWs.Flush(); + } + +void CCKAbortConnection::ReceivedAbortEventL(TInt aHandle, TKeyEvent *aKey) + { + iTest->TestL(aHandle==(TInt)iGroup); + iTest->TestL(aKey->iCode==abortKeyTests[iAbortKeyIndex].keyCode); + iTest->TestL((aKey->iModifiers&abortKeyTests[iAbortKeyIndex].modifier_mask)==abortKeyTests[iAbortKeyIndex].modifiers); + iAbortKeyIndex++; + iTest->IncSubState(); + } + +void CCKAbortConnection::Foreground() + { + iGroup->GroupWin()->SetOrdinalPosition(0); + iWs.Flush(); + } + +// +// CCKWindowGroup class // +// + +CCKWindowGroup::CCKWindowGroup(CTClient *aClient, TCaptureKeyTest *aTest) : CTWindowGroup(aClient), iTest(aTest) + {} + +void CCKWindowGroup::KeyL(const TKeyEvent &aKey,const TTime &time) + { + /*TLogMessageText buf(_S("##Recieved Key: ")); + buf.Append(aKey.iScanCode); + buf.Append('('); + buf.AppendNum(aKey.iScanCode); + buf.Append(')'); + if (!iCurWin) + { + buf.Append('('); + buf.AppendNum(((CCKConnection *)iClient)->Index()); + buf.Append(')'); + } + iClient->iWs.LogMessage(buf);*/ + if (iCurWin) + iCurWin->WinKeyL(aKey,time); + else + ((CCKConnection *)iClient)->KeyL(aKey,time); + } + +void CCKWindowGroup::KeyDownL(const TKeyEvent &aKey,const TTime &) + { + if (aKey.iScanCode!=EStdKeyLeftShift && aKey.iScanCode!=EStdKeyRightShift) + { + if (iTest->Mode()==EModeWaitingForFirstDown) + iTest->SetMode(EModeKeyUpsAndDowns); + if (iTest->Mode()==EModeKeyUpsAndDowns) + ((CCKConnection *)iClient)->CheckUpDownL(aKey); + } + } + +void CCKWindowGroup::KeyUpL(const TKeyEvent &aKey,const TTime &) + { + if (aKey.iScanCode!=EStdKeyLeftShift && aKey.iScanCode!=EStdKeyRightShift) + { + if (iTest->Mode()==EModeKeyUpsAndDowns) + { + ((CCKConnection *)iClient)->CheckUpDownL(aKey); + iTest->IncSubState(); + } + } + } + +// +// CCKWindow, class // +// + +CCKWindow::CCKWindow(TCaptureKeyTest *aTest, TInt aConnIndex) : CTWin(), iConnIndex(aConnIndex), iTest(aTest) + { + iBack=TRgb::Gray256(230); + } + +void CCKWindow::SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc) + { + ConstructExtLD(*parent,pos,size); + iWin.SetBackgroundColor(iBack); + Activate(); + AssignGC(aGc); + } + +void CCKWindow::Draw() + { + iGc->Clear(); + if (iConnIndex==0) + iGc->DrawText(TPtrC(capKeyTests[iTest->SubState()].txt), TPoint(10,20)); + } + +// + +TCaptureKeyTest::TCaptureKeyTest() : CTestBase(_L("Capture Key")) + {} + +TCaptureKeyTest::~TCaptureKeyTest() + { + delete iConn1; + delete iConn2; + delete iConn3; + delete iAbortConn; + } + +void TCaptureKeyTest::ConstructL() + { + iAbortConn=new(ELeave) CCKAbortConnection(this); + iAbortConn->ConstructL(); + iConn3=new(ELeave) CCKConnection(this,2); + iConn3->ConstructL(); + iConn2=new(ELeave) CCKConnection(this,1); + iConn2->ConstructL(); + iConn1=new(ELeave) CCKConnection(this,0); + iConn1->ConstructL(); + iMode=EModeNormalCapture; + } + +TInt TCaptureKeyTest::SubState() const + { + return(iSubState); + } + +void TCaptureKeyTest::IncSubState() + { + iSubState++; + iConn1->SubStateChanged(); + iConn2->SubStateChanged(); + iConn3->SubStateChanged(); + switch(iMode) + { + case EModeNormalCapture: + if (iSubState==numCapKeyTests) + TestComplete(); + break; + case EModeKeyUpsAndDowns: + if (iSubState==(numCapKeyTests+numUpDownKeyTests)) + TestComplete(); + break; + case EModeAbortKeys: + if (iSubState==(numCapKeyTests+numUpDownKeyTests+numAbortKeyTests)) + TestComplete(); + break; + default: + break; + } + } + +void TCaptureKeyTest::CapKeyPurgingL() + { + TInt base=Client()->iWs.ResourceCount(); + RWindowGroup groupWin(Client()->iWs); + User::LeaveIfError(groupWin.Construct(ENullWsHandle)); + TInt capHandle=User::LeaveIfError(groupWin.CaptureKey('a',EModifierFunc,EModifierFunc)); + User::LeaveIfError(groupWin.CaptureKey('b',EModifierFunc,EModifierFunc)); + TestL(Client()->iWs.ResourceCount()==(base+3)); + groupWin.CancelCaptureKey(capHandle); + TestL(Client()->iWs.ResourceCount()==(base+2)); + groupWin.Close(); + TestL(Client()->iWs.ResourceCount()==base); // Check it also freed the extra capture key + } + +void TCaptureKeyTest::BadParamsL() + { + TInt resCount=Client()->iWs.ResourceCount(); + for(TInt index=0;indexiGroup->GroupWin()->CaptureKey(errorKeys[index].keyCode,errorKeys[index].modifier_mask,errorKeys[index].modifiers)==KErrArgument); + TestL(Client()->iWs.ResourceCount()==resCount); + } + +void TCaptureKeyTest::TestComplete() + { + Request(); + } + +void TCaptureKeyTest::SetMode(TTestMode aMode) + { + iMode=aMode; + } + +TTestMode TCaptureKeyTest::Mode() + { + return(iMode); + } + +void TCaptureKeyTest::SetUpPriorityKeyTest() + { + iMode=EModeAbortKeys; + iAbortConn->Foreground(); + } + +void TCaptureKeyTest::CaptureUpsAndDownsTest() + { + iMode=EModeWaitingForFirstDown; + } + +TestState TCaptureKeyTest::DoTestL() + { + switch(iState) + { + case 0: // Dummy one to let capture key tests run + iState++; + return(EContinue); + case 1: + LogSubTest(_L("Capture ups and downs"),1); + CaptureUpsAndDownsTest(); + iState++; + return(EContinue); + case 2: + LogSubTest(_L("Abort key"),1); + SetUpPriorityKeyTest(); + iState++; + return(EContinue); + case 3: + LogSubTest(_L("Errors"),1); + BadParamsL(); + CapKeyPurgingL(); + LogSubTest(_L("CaptureKey"),1); + iState++; + return(ENext); + default: + return(EFinished); + } +// return(ENext); + } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tman/TMMODCHG.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tman/TMMODCHG.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,301 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Test modifier changed message +// +// + +#include +#include +#include "W32STD.H" +#include "../tlib/testbase.h" +#include "TMAN.H" + +class CTModifiersChangedTest; + +class CMCWindow : public CTWin + { +public: + CMCWindow(CTModifiersChangedTest *aTest); + void SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc); + void Draw(); + void DrawModSetLine(const TDesC &aDes,TInt aModifier,TInt iSettableModifiers); +protected: + CTModifiersChangedTest *iTest; + TRgb iBack; + TInt iLineHeight; + TInt iFontAscent; + TInt iYpos; + TInt iXpos1; + TInt iXpos2; + }; + +class CTEventWindowGroup : public CTWindowGroup + { +public: + CTEventWindowGroup(CTClient *aClient, CTModifiersChangedTest *iTest); + void ConstructL(); + void ModifiersChanged(const TModifiersChangedEvent &aModifiersChanged ,const TTime &aTime); + void KeyL(const TKeyEvent &aKey,const TTime &aTime); +private: + CTModifiersChangedTest *iTest; + }; + +class CTModifiersChangedTest : public CTestBase + { +public: + CTModifiersChangedTest(); + ~CTModifiersChangedTest(); + TestState DoTestL(); + void ConstructL(); + void EndTest(); + TInt SubState() const; + void IncSubState(); + void BadParams(); + void ModifierChangedEventsL(); + void SetModifiersL(); + void CheckModifierL(TEventModifier aModifier); +public: + TBool iModSetTest; + TInt iSettable; +private: + TSize iWinSize; + TInt iState; + TInt iSubState; + CTEventWindowGroup *iEventGroup; + CMCWindow *iWin; + }; + +struct TModifierChangedTestsParams + { + TText *txt; // Text message telling user what to do + TUint changed; + TUint state; + TUint stateMask; + }; + +LOCAL_D TModifierChangedTestsParams ModifierChangedTests[]={ +#if defined(__WINS__) + {(TText *)_S("Press Caps"),EModifierCapsLock,EModifierCapsLock,EModifierCapsLock}, + {(TText *)_S("Press Caps (again)"),EModifierCapsLock,0,EModifierCapsLock}, +#endif + {(TText *)_S("Press left shift"),EModifierShift|EModifierLeftShift,EModifierShift|EModifierLeftShift,EModifierShift|EModifierLeftShift}, + {(TText *)_S("Release left shift"),EModifierShift|EModifierLeftShift,0,EModifierShift|EModifierLeftShift}, + {(TText *)_S("Press right shift"),EModifierShift|EModifierRightShift,EModifierShift|EModifierRightShift,EModifierShift|EModifierRightShift}, + {(TText *)_S("Release right shift"),EModifierShift|EModifierRightShift,0,EModifierShift|EModifierRightShift}, + {(TText *)_S("Press (left) func"),EModifierFunc|EModifierLeftFunc,EModifierFunc|EModifierLeftFunc,EModifierFunc|EModifierLeftFunc}, + {(TText *)_S("Release (left) func"),EModifierFunc|EModifierLeftFunc,0,EModifierFunc|EModifierLeftFunc}, + {(TText *)_S("Press (left) control"),EModifierCtrl|EModifierLeftCtrl,EModifierCtrl|EModifierLeftCtrl,EModifierCtrl|EModifierLeftCtrl}, + {(TText *)_S("Release (left) control"),EModifierCtrl|EModifierLeftCtrl,0,EModifierCtrl|EModifierLeftCtrl}, + }; + +const TInt numTests=sizeof(ModifierChangedTests)/sizeof(ModifierChangedTests[0]); + +GLDEF_C CTestBase *CreateModifiersChangedTest() + { + return(new(ELeave) CTModifiersChangedTest()); + } + +// +// CTEventWindowGroup class // +// + +CTEventWindowGroup::CTEventWindowGroup(CTClient *aClient, CTModifiersChangedTest *aTest) : CTWindowGroup(aClient), iTest(aTest) + {} + +void CTEventWindowGroup::ConstructL() + { + CTWindowGroup::ConstructL(); + iGroupWin.EnableModifierChangedEvents(EModifierShift|EModifierLeftShift|EModifierRightShift|EModifierCapsLock| + EModifierFunc|EModifierLeftFunc|EModifierCtrl|EModifierLeftCtrl,EEventControlAlways); + } + +void CTEventWindowGroup::ModifiersChanged(const TModifiersChangedEvent &aModifiersChanged ,const TTime &) + { + TInt ss=iTest->SubState(); + TInt getMods=Client()->iWs.GetModifierState(); // Double check the mods with get mods + if (aModifiersChanged.iChangedModifiers==ModifierChangedTests[ss].changed && + (aModifiersChanged.iModifiers&ModifierChangedTests[ss].stateMask)==ModifierChangedTests[ss].state && + (getMods&ModifierChangedTests[ss].stateMask)==ModifierChangedTests[ss].state) + iTest->IncSubState(); + } + +void CTEventWindowGroup::KeyL(const TKeyEvent &aKey,const TTime &) + { + if (aKey.iCode==EKeyEscape || (aKey.iCode==' ' && iTest->iModSetTest)) + iTest->EndTest(); + } + +// +// CMCWindow, class // +// + +CMCWindow::CMCWindow(CTModifiersChangedTest *aTest) : CTWin(), iTest(aTest) + { + iBack=TRgb::Gray256(230); + } + +void CMCWindow::SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc) + { + ConstructExtLD(*parent,pos,size); + iWin.SetBackgroundColor(iBack); + Activate(); + AssignGC(aGc); + iLineHeight=iFont->HeightInPixels()*5/4; + iFontAscent=iFont->AscentInPixels(); + iXpos1=4; + iXpos2=iXpos1+12*iFont->TextWidthInPixels(_L("M")); + } + +void CMCWindow::DrawModSetLine(const TDesC &aDes,TInt aModifier,TInt iSettableModifiers) + { + iYpos+=iLineHeight; + iGc->DrawText(aDes, TPoint(iXpos1,iYpos)); + iGc->DrawText(aModifier&iSettableModifiers ? _L("Yes"):_L("No"), TPoint(iXpos2,iYpos)); + } + +void CMCWindow::Draw() + { + iGc->Clear(); + if (iTest->iModSetTest) + { + iYpos=iFontAscent+3; + TBuf<32> buf; + buf.Format(TRefByValue(_L("Settable? [0x%4x]")), iTest->iSettable); + iGc->DrawText(_L("Modifier"), TPoint(iXpos1,iYpos)); + iGc->DrawText(buf, TPoint(iXpos2,iYpos)); + DrawModSetLine(_L("Shift"),EModifierShift,iTest->iSettable); + DrawModSetLine(_L("Left Shift"),EModifierLeftShift,iTest->iSettable); + DrawModSetLine(_L("Func"),EModifierFunc,iTest->iSettable); + DrawModSetLine(_L("Caps"),EModifierCapsLock,iTest->iSettable); + DrawModSetLine(_L("NumLock"),EModifierNumLock,iTest->iSettable); + DrawModSetLine(_L("Double Click"),EModifierDoubleClick,iTest->iSettable); + } + else + iGc->DrawText(TPtrC(ModifierChangedTests[iTest->SubState()].txt), TPoint(10,20)); + } + +// + +CTModifiersChangedTest::CTModifiersChangedTest() : CTestBase(_L("Capture Key")) + {} + +CTModifiersChangedTest::~CTModifiersChangedTest() + { + delete iWin; + delete iEventGroup; + } + +void CTModifiersChangedTest::EndTest() + { + if (iModSetTest) + { + iModSetTest=EFalse; + iWin->Invalidate(); + } + Request(); + } + +void CTModifiersChangedTest::ConstructL() + { + iWin=new(ELeave) CMCWindow(this); + iWin->SetUpL(TPoint(10,10),TSize(240,200),Client()->iGroup, *Client()->iGc); + } + +TInt CTModifiersChangedTest::SubState() const + { + return(iSubState); + } + +void CTModifiersChangedTest::IncSubState() + { + if (iSubState==(numTests-1)) + EndTest(); + else + { + iSubState++; + iWin->Invalidate(); + } + } + +void CTModifiersChangedTest::BadParams() + { + } + +void CTModifiersChangedTest::ModifierChangedEventsL() + { + iEventGroup=new(ELeave) CTEventWindowGroup(Client(), this); + iEventGroup->ConstructL(); + } + +void CTModifiersChangedTest::CheckModifierL(TEventModifier aModifier) + { + TInt oldMods=Client()->iWs.GetModifierState(); + Client()->iWs.SetModifierState(aModifier, EToggleModifier); + TInt getMods=Client()->iWs.GetModifierState(); + if (oldMods!=getMods) + { + iSettable|=aModifier; + Client()->iWs.SetModifierState(aModifier, ETurnOffModifier); + getMods=Client()->iWs.GetModifierState(); + TestL(!(getMods&aModifier)); + Client()->iWs.SetModifierState(aModifier, ETurnOnModifier); + getMods=Client()->iWs.GetModifierState(); + TestL(getMods&aModifier); + Client()->iWs.SetModifierState(aModifier, ETurnOffModifier); + getMods=Client()->iWs.GetModifierState(); + TestL(!(getMods&aModifier)); + if (oldMods&aModifier) + Client()->iWs.SetModifierState(aModifier, ETurnOnModifier); + } + else + { + Client()->iWs.SetModifierState(aModifier, ETurnOffModifier); + TestL(oldMods==Client()->iWs.GetModifierState()); + Client()->iWs.SetModifierState(aModifier, ETurnOnModifier); + TestL(oldMods==Client()->iWs.GetModifierState()); + } + } + +void CTModifiersChangedTest::SetModifiersL() + { + iModSetTest=ETrue; + for(TInt mod=1;mod!=0;mod<<=1) + CheckModifierL((TEventModifier)mod); + iWin->Invalidate(); + Client()->iWs.Flush(); + } + +TestState CTModifiersChangedTest::DoTestL() + { + switch(iState) + { + case 0: //The first 2 tests have been converted to TAuto test code. + ModifierChangedEventsL(); + /* iState++; + return(EContinue); + case 1: + LogSubTest(_L("Errors"),1); + BadParams(); + break; + case 2:*/ + LogSubTest(_L("Set modifiers"),1); + SetModifiersL(); + iState++; + return(EContinue); + default: + return(EFinished); + } + //iState++; + //return(ENext); + } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tman/TMPNTBUF.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tman/TMPNTBUF.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,283 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Test Pointer move/drag buffer +// +// + +#include +#include "W32STD.H" +#include "../tlib/testbase.h" +#include "TMAN.H" + +class CTPntBufTest; + +class CPntBufWindow : public CTBackedUpWin + { +private: + enum {KPointerMoveBufferSize=32}; +public: + CPntBufWindow(CTPntBufTest *aTest); + ~CPntBufWindow(); + void SetUpLD(TPoint pos,TSize size,CTWinBase *parent); + void PointerBufferReady(const TTime &aTime); + void PointerL(const TPointerEvent &pointer,const TTime &aTime); + void SetUpState(); + void NextTest(); + void WinKeyL(const TKeyEvent &aKey,const TTime &aTime); + void ErrorL(); +private: + //Virtual functions from CTWinBase + void PointerEnter(const TTime&); + void PointerExit(const TTime&); +private: + CTPntBufTest *iTest; + TBool iDragging; + TBool iErrorNest; + TBool iDisabled; + TBool iDiscard; + TInt iMode; + TBool iIgnorNextPoint; + }; + +class CTPntBufTest : public CTestBase + { +public: + CTPntBufTest(); + ~CTPntBufTest(); + TestState DoTestL(); + void FinishedTests(); + void ConstructL(); +private: + CPntBufWindow *iWin; + TSize iWinSize; + TInt iState; + }; + +GLDEF_C CTestBase *CreatePointerBufferTest() + { + return(new(ELeave) CTPntBufTest()); + } + +CPntBufWindow::CPntBufWindow(CTPntBufTest *aTest) : CTBackedUpWin(EGray4), iTest(aTest) + {} + +CPntBufWindow::~CPntBufWindow() + { + delete iGc; + } + +void CPntBufWindow::SetUpLD(TPoint pos,TSize size,CTWinBase *parent) + { + ConstructExtLD(*parent,pos,size); + User::LeaveIfError(iWin.AllocPointerMoveBuffer(KPointerMoveBufferSize,0)); + iWin.SetPointerGrab(ETrue); + iWin.PointerFilter(EPointerFilterEnterExit,0); + Activate(); + User::LeaveIfError(Client()->iScreen->CreateContext(iGc)); + iGc->Activate(iWin); + SetUpState(); + } + +void CPntBufWindow::PointerBufferReady(const TTime &) + { + if (iDiscard) + iWin.DiscardPointerMoveBuffer(); + iGc->SetPenColor(iDragging ? TRgb::Gray4(0) : TRgb::Gray4(1)); + iGc->SetPenSize(iDragging ? TSize(2,2) : TSize(1,1)); + TPoint pnts[KPointerMoveBufferSize]; + TPtr8 ptr((TUint8 *)&pnts,sizeof(pnts)); + TInt numPnts=iWin.RetrievePointerMoveBuffer(ptr); + TInt index=0; + if (iIgnorNextPoint) + { + iGc->MoveTo(pnts[index]); + index=1; + iIgnorNextPoint=EFalse; + } + for(;indexDrawLineTo(pnts[index]); + } + +void CPntBufWindow::ErrorL() + { + if (!iErrorNest) + { + iErrorNest=ETrue; + iTest->TestL(EFalse); + } + } + +void CPntBufWindow::PointerL(const TPointerEvent &pointer,const TTime &) + { + switch(pointer.iType) + { + case TPointerEvent::EButton1Down: + iDragging=ETrue; + iGc->MoveTo(pointer.iPosition); + if (iMode==2) + { + if (pointer.iModifiers&EModifierShift) + { + iDisabled=ETrue; + iWin.DisablePointerMoveBuffer(); + } + else if (pointer.iModifiers&EModifierCtrl) + iDiscard=ETrue; + } + break; + case TPointerEvent::EButton1Up: + if (iDisabled) + { + iDisabled=EFalse; + iWin.EnablePointerMoveBuffer(); + } + iDiscard=EFalse; + iGc->MoveTo(pointer.iPosition); + iDragging=EFalse; + break; + case TPointerEvent::EDrag: + if (iDragging && !iDisabled) + ErrorL(); + break; + case TPointerEvent::EMove: + if (iDragging && !iDisabled) + ErrorL(); + break; + default:; + } + } + +void CPntBufWindow::SetUpState() + { + + iGc->Reset(); + iGc->UseFont((CFont *)iFont); + iGc->Clear(); + switch(iMode) + { + case 0: + iWin.PointerFilter(EPointerFilterMove,EPointerFilterMove); + iGc->DrawText(_L("Drag the pointer around the window and check"), TPoint(10,20)); + iGc->DrawText(_L("a line is drawn following the pointer when"), TPoint(10,40)); + iGc->DrawText(_L("dragging but not when moving"), TPoint(10,60)); + iGc->DrawText(_L("Press when checked"), TPoint(10,90)); + break; + case 1: + iWin.PointerFilter(EPointerFilterMove|EPointerFilterDrag,EPointerFilterDrag); + iGc->DrawText(_L("If pointer moves are supported move the pointer around the "), TPoint(10,20)); + iGc->DrawText(_L("window and check a line is drawn following the pointer"), TPoint(10,40)); + iGc->DrawText(_L("when it is up, and no lines are drawn when dragging"), TPoint(10,60)); + iGc->DrawText(_L("Press if moves not supported or when checked"), TPoint(10,90)); + break; + case 2: + iWin.PointerFilter(EPointerFilterMove|EPointerFilterDrag,0); + iGc->DrawText(_L("Drag and move the pointer around the window and check a"), TPoint(10,20)); + iGc->DrawText(_L("line is drawn following the pointer during both dragging and"), TPoint(10,40)); + iGc->DrawText(_L("moving, also check drag with the shift or control key down doesn't draw"), TPoint(10,60)); + iGc->DrawText(_L("Press when checked"), TPoint(10,90)); + break; + } + } + +void CPntBufWindow::NextTest() + { + if (iMode++==2) + iTest->FinishedTests(); + else + SetUpState(); + } + +void CPntBufWindow::WinKeyL(const TKeyEvent &aKey,const TTime &) + { + switch(aKey.iCode) + { + case ' ': + NextTest(); + break; + case EKeyEscape: + iTest->FinishedTests(); + break; + case '0': + SetUpState(); + break; + case '1': + case '2': + case '3': + { + TInt mode=aKey.iCode-'1'; + if (mode!=iMode) + { + iMode=mode; + SetUpState(); + } + } + break; + } + } + +void CPntBufWindow::PointerEnter(const TTime&) + { + if (iMode==0) + iDragging=ETrue; + else if (iMode==1) + iDragging=EFalse; + iIgnorNextPoint=ETrue; + } + +void CPntBufWindow::PointerExit(const TTime&) + {} + + +/*CTPntBufTest*/ + +CTPntBufTest::CTPntBufTest() : CTestBase(_L("Scale")) + {} + +CTPntBufTest::~CTPntBufTest() + { +#if defined(__WINS__) + Client()->iWs.SimulateXyInputType(EXYInputPointer); +#endif + CTWin::Delete(iWin); + } + +void CTPntBufTest::FinishedTests() + { + Request(); + } + +void CTPntBufTest::ConstructL() + { + CPntBufWindow *win=new(ELeave) CPntBufWindow(this); + win->SetUpLD(TPoint(0,0),Client()->iScreen->SizeInPixels(),Client()->iGroup); + iWin=win; + Client()->iGroup->SetCurrentWindow(iWin); +#if defined(__WINS__) + Client()->iWs.SimulateXyInputType(EXYInputMouse); +#endif + } + +TestState CTPntBufTest::DoTestL() + { + switch(iState) + { + case 0: + LogSubTest(_L("Scale 1"),1); + iState++; + return(EContinue); + default: + return(EFinished); + } +// return(ENext); + } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tman/TMPNTCAP.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tman/TMPNTCAP.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,856 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Test pointer capture +// +// + +#include +#include +#include "W32STD.H" +#include "../tlib/testbase.h" +#include "TMAN.H" + +enum TTestState + { + ECaptureDisabled, + ENormalCapture, + ECaptureAllGroups, + EDragDropCapture, + EDragDropCaptureAllGroups, + ENormalCaptureWithoutFocus, + }; + +enum TTestSubState + { + EMainWindow, + EChildWindow, + EOtherGroup, + EOtherSession, + ERootWindow, + }; + +enum TPointerCheckRet + { + EFailed, + EOkay, + ENeedsDDEvent, + }; + +const TInt ESubStates1=2; +const TInt ESubStates2=5; +const TInt ESubStates3=5; +const TInt ESubStates4=5; +const TInt ESubStates5=5; +const TInt ESubStates6=5; + +const TInt EWinBorderSize=10; + +class CPcWindowBase; +class TPointerCaptureTest; + +class CPcConnection : public CTClient + { +public: + CPcConnection(TPointerCaptureTest *aTest); + ~CPcConnection(); + virtual void ConstructL(); +protected: + TPointerCaptureTest *iTest; + }; + +class CPcWindowBase : public CTWin + { +public: + CPcWindowBase(TPointerCaptureTest *aTest); + void SetUpL(TPoint pos,TSize size,CTWinBase *parent); + void SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc); + void Draw(TDesC &aBuf); + void PointerL(const TPointerEvent &pointer,const TTime &); + void DragDropL(const TPointerEvent &pointer,const TTime &); + virtual TPointerCheckRet PointerDown()=0; + virtual TPointerCheckRet DragDrop()=0; + virtual void SubStateChanged(); +protected: + TPointerCaptureTest *iTest; + TRgb iBack; + }; + +class CPcWindowChild : public CPcWindowBase + { +public: + CPcWindowChild(TPointerCaptureTest *aTest); + void Draw(); + TPointerCheckRet PointerDown(); + TPointerCheckRet DragDrop(); + }; + +class CPcWindowMain : public CPcWindowBase + { +public: + CPcWindowMain(TPointerCaptureTest *aTest); + void Draw(); + TPointerCheckRet PointerDown(); + TPointerCheckRet DragDrop(); + void WinKeyL(const TKeyEvent &aKey,const TTime &aTime); + }; + +class CPcWindowAltGroup : public CPcWindowBase + { +public: + CPcWindowAltGroup(TPointerCaptureTest *aTest); + void Draw(); + TPointerCheckRet PointerDown(); + TPointerCheckRet DragDrop(); + }; + +class CPcWindowNickFocusGroup : public CTWindowGroup + { +public: + CPcWindowNickFocusGroup(TPointerCaptureTest *aTest, CTClient *aClient); + void KeyL(const TKeyEvent &aKey,const TTime &aTime); +private: + TPointerCaptureTest *iTest; + }; + +class CPcWindowAltConnection : public CPcWindowBase + { +public: + CPcWindowAltConnection(TPointerCaptureTest *aTest); + void Draw(); + TPointerCheckRet PointerDown(); + TPointerCheckRet DragDrop(); + }; + +class TPointerCaptureTest : public CTestBase + { +private: + enum TDState {DDStateNull, DDStateGot, DDStateWaiting}; +public: + TPointerCaptureTest(); + ~TPointerCaptureTest(); + TestState DoTestL(); + void ConstructL(); + void NextTest(); + void AbortTests(); + TInt State() const; + TInt SubState() const; + void doIncSubState(); + void IncSubState(TBool aNeedsDD=EFalse); + void GotDD(); + void StateChanged(); + void TestFailed(); + void NickFocusL(); + void SetCapture(TInt aCaptureFlags); + void RestartTest(); +private: + TInt doTestFailedL(); +private: + CPcConnection *iAltConnection; + CTWindowGroup *iMainGroup; + CTWindowGroup *iAltGroup; + CPcWindowChild *iChildWin; + CPcWindowMain *iMainWin; + CPcWindowAltGroup *iAltGroupWin; + CPcWindowAltConnection *iAltConnectionWin; + CPcWindowNickFocusGroup *iNickFocusGroup; + CTBlankWindow *iNickFocusBlankWin; + TInt iState; + TInt iSubState; + TDState iDDState; +public: + TBool iFailed; + }; + +GLDEF_C CTestBase *CreatePointerCaptureTest() + { + return(new(ELeave) TPointerCaptureTest()); + } + +// +// CMcConnection + +CPcConnection::CPcConnection(TPointerCaptureTest *aTest) : iTest(aTest) + { + } + +CPcConnection::~CPcConnection() + { + } + +void CPcConnection::ConstructL() + { + CTClient::ConstructL(); + iGroup=new(ELeave) CTWindowGroup(this); + iGroup->ConstructL(); + iGroup->GroupWin()->SetOrdinalPosition(0,1); + iGroup->GroupWin()->EnableReceiptOfFocus(EFalse); + iWs.Flush(); + } + +// +// CPcWindow, base class // +// + +CPcWindowBase::CPcWindowBase(TPointerCaptureTest *aTest) : CTWin(), iTest(aTest) + { + } + +void CPcWindowBase::SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc) + { + ConstructExtLD(*parent,pos,size); + iWin.SetBackgroundColor(iBack); + Activate(); + AssignGC(aGc); + } + +void CPcWindowBase::SetUpL(TPoint pos,TSize size,CTWinBase *parent) + { + SetUpL(pos,size,parent,*iTest->Client()->iGc); + } + +void CPcWindowBase::SubStateChanged() + { + iWin.Invalidate(); + Client()->iWs.Flush(); + } + +void CPcWindowBase::Draw(TDesC &aBuf) + { + iGc->Clear(); + iGc->SetPenColor(iBack.Gray4()>1 ? TRgb(0,0,0) : TRgb(255,255,255)); + iGc->DrawText(aBuf, TPoint(10,20)); + } + +void CPcWindowBase::PointerL(const TPointerEvent &pointer,const TTime &) + { + if (pointer.iType==TPointerEvent::EButton1Down && !iTest->iFailed) + { + if (iTest->SubState()==ERootWindow) // Root window click, must not be inside this window + { + if (TRect(Size()).Contains(pointer.iPosition)) + { + iTest->TestFailed(); + return; + } + } + TInt ret; + if ((ret=PointerDown())==EFailed) + iTest->TestFailed(); + else + iTest->IncSubState(ret==ENeedsDDEvent); + } + } + +void CPcWindowBase::DragDropL(const TPointerEvent &pointer,const TTime &) + { + switch(iTest->State()) + { + case ECaptureDisabled: + case ENormalCapture: + case ECaptureAllGroups: + case ENormalCaptureWithoutFocus: + iTest->TestFailed(); + break; + } + if (pointer.iType==TPointerEvent::EButton1Down && !iTest->iFailed) + { + if (DragDrop()==EFailed) + iTest->TestFailed(); + else + iTest->GotDD(); + } + } +// + +CPcWindowMain::CPcWindowMain(TPointerCaptureTest *aTest) : CPcWindowBase(aTest) + { + iBack=TRgb::Gray256(236); + } + +TPointerCheckRet CPcWindowMain::PointerDown() + { + switch(iTest->State()) + { + case ECaptureDisabled: + if (iTest->SubState()==EMainWindow) + return(EOkay); + break; + case ENormalCapture: + switch(iTest->SubState()) + { + case EMainWindow: + case ERootWindow: + return(EOkay); + default: + break; + } + break; + case ECaptureAllGroups: + switch(iTest->SubState()) + { + case EMainWindow: + case EOtherGroup: + case EOtherSession: + case ERootWindow: + return(EOkay); + default: + break; + } + break; + case EDragDropCapture: + switch(iTest->SubState()) + { + case EMainWindow: + return(ENeedsDDEvent); + case ERootWindow: + return(EOkay); + default: + break; + } + break; + case EDragDropCaptureAllGroups: + switch(iTest->SubState()) + { + case EMainWindow: + case EOtherGroup: + case EOtherSession: + return(ENeedsDDEvent); + case ERootWindow: + return(EOkay); + default: + break; + } + break; + case ENormalCaptureWithoutFocus: + switch(iTest->SubState()) + { + case EMainWindow: + return(EOkay); + default: + break; + } + break; + default: + break; + } + return(EFailed); + } + +TPointerCheckRet CPcWindowMain::DragDrop() + { + switch(iTest->State()) + { + case EDragDropCapture: + case EDragDropCaptureAllGroups: + switch(iTest->SubState()) + { + case EMainWindow: + return(EOkay); + default: + break; + } + break; + default: + break; + } + return(EFailed); + } + +void CPcWindowMain::Draw() + { + TBuf<0x40> buf; + if (iTest->State()==ECaptureDisabled) + { + switch(iTest->SubState()) + { + case EMainWindow: + buf.Copy(_L("Click on me")); + break; + } + } + else + { + switch(iTest->SubState()) + { + case EMainWindow: + buf.Copy(_L("Click on me")); + break; + case EChildWindow: + case EOtherGroup: + case EOtherSession: + break; + case ERootWindow: + if (iTest->State()==ENormalCaptureWithoutFocus) + buf.Copy(_L("Click on the root window, then press ")); + else + buf.Copy(_L("Click on the root window")); + break; + } + } + CPcWindowBase::Draw(buf); + } + +void CPcWindowMain::WinKeyL(const TKeyEvent &aKey,const TTime &) + { + switch(aKey.iCode) + { + case EKeyEscape: + iTest->AbortTests(); + break; + } + } + +// + +CPcWindowChild::CPcWindowChild(TPointerCaptureTest *aTest) : CPcWindowBase(aTest) + { + iBack=TRgb::Gray256(85); + } + +TPointerCheckRet CPcWindowChild::PointerDown() + { + switch(iTest->State()) + { + case ECaptureDisabled: + break; + default: + switch(iTest->SubState()) + { + case EChildWindow: + return(EOkay); + default: + break; + } + break; + } + return(EFailed); + } + +TPointerCheckRet CPcWindowChild::DragDrop() + { + switch(iTest->State()) + { + case EDragDropCapture: + case EDragDropCaptureAllGroups: + switch(iTest->SubState()) + { + case EChildWindow: + return(EOkay); + default: + break; + } + break; + default: + break; + } + return(EFailed); + } + +void CPcWindowChild::Draw() + { + TBuf<0x40> buf; + if (iTest->State()!=ECaptureDisabled) + { + switch(iTest->SubState()) + { + case EChildWindow: + buf.Copy(_L("Click on me")); + break; + default: + break; + } + } + CPcWindowBase::Draw(buf); + } + +// + +CPcWindowNickFocusGroup::CPcWindowNickFocusGroup(TPointerCaptureTest *aTest, CTClient *aClient) : CTWindowGroup(aClient), iTest(aTest) + { + } + +void CPcWindowNickFocusGroup::KeyL(const TKeyEvent &aKey,const TTime &) + { + if (aKey.iCode==EKeyEscape) + iTest->IncSubState(EFalse); + } + +// + +CPcWindowAltGroup::CPcWindowAltGroup(TPointerCaptureTest *aTest) : CPcWindowBase(aTest) + { + iBack=TRgb::Gray256(236); + } + +TPointerCheckRet CPcWindowAltGroup::PointerDown() + { + switch(iTest->State()) + { + case ECaptureDisabled: + if (iTest->SubState()==EChildWindow) + return(EOkay); + break; + case ENormalCapture: + case EDragDropCapture: + case ENormalCaptureWithoutFocus: + switch(iTest->SubState()) + { + case EOtherGroup: + return(EOkay); + default: + break; + } + break; + default: + break; + } + return(EFailed); + } + +TPointerCheckRet CPcWindowAltGroup::DragDrop() + { + switch(iTest->State()) + { + case EDragDropCapture: + case EDragDropCaptureAllGroups: + switch(iTest->SubState()) + { + case EOtherGroup: + return(EOkay); + default: + break; + } + break; + default: + break; + } + return(EFailed); + } + +void CPcWindowAltGroup::Draw() + { + TBuf<0x40> buf; + if (iTest->State()==ECaptureDisabled) + { + switch(iTest->SubState()) + { + case EMainWindow: + break; + case EChildWindow: + buf.Copy(_L("Click on me")); + break; + } + } + else + { + switch(iTest->SubState()) + { + case EOtherGroup: + buf.Copy(_L("Click on me")); + break; + default: + break; + } + } + CPcWindowBase::Draw(buf); + } + +// + +CPcWindowAltConnection::CPcWindowAltConnection(TPointerCaptureTest *aTest) : CPcWindowBase(aTest) + { + iBack=TRgb::Gray256(236); + } + +TPointerCheckRet CPcWindowAltConnection::PointerDown() + { + switch(iTest->State()) + { + case ECaptureDisabled: + if (iTest->SubState()==EChildWindow) + return(EOkay); + break; + case ENormalCapture: + case EDragDropCapture: + case ENormalCaptureWithoutFocus: + switch(iTest->SubState()) + { + case EOtherSession: + return(EOkay); + default: + break; + } + break; + default: + break; + } + return(EFailed); + } + +TPointerCheckRet CPcWindowAltConnection::DragDrop() + { + switch(iTest->State()) + { + case EDragDropCapture: + case EDragDropCaptureAllGroups: + switch(iTest->SubState()) + { + case EOtherSession: + return(EOkay); + default: + break; + } + break; + default: + break; + } + return(EFailed); + } + +void CPcWindowAltConnection::Draw() + { + TBuf<0x40> buf; + if (iTest->State()!=ECaptureDisabled) + { + switch(iTest->SubState()) + { + case EOtherSession: + buf.Copy(_L("Click on me")); + break; + default: + break; + } + } + CPcWindowBase::Draw(buf); + } + +// + +TPointerCaptureTest::TPointerCaptureTest() : CTestBase(_L("Pointer Capture")) + {} + +TPointerCaptureTest::~TPointerCaptureTest() + { + delete iNickFocusBlankWin; + delete iNickFocusGroup; + delete iAltConnectionWin; + delete iAltConnection; + delete iChildWin; + delete iMainWin; + delete iMainGroup; + delete iAltGroupWin; + delete iAltGroup; + } + +void TPointerCaptureTest::TestFailed() + { + __ASSERT_DEBUG(iFailed==EFalse,TManPanic(ETManPanicPcFailed)); + iFailed=ETrue; + Client()->iGroup->GroupWin()->SetOrdinalPosition(0,10); // Put error dialog on top of test windows + TInt dRet=1; + TRAPD(err,dRet=doTestFailedL()); + Client()->iGroup->GroupWin()->SetOrdinalPosition(0,0); + switch(dRet) + { + case 0: + RestartTest(); + break; + case 1: + TRAP(err,TestL(EFalse)); + break; + } + } + +TInt TPointerCaptureTest::doTestFailedL() + { + CTDialog *dialog=new(ELeave) CTDialog(); + dialog->SetTitle(_L("Pointer capture test failed")); + dialog->SetNumButtons(2); + dialog->SetButtonText(0,_L("Retest")); + dialog->SetButtonText(1,_L("Fail")); + dialog->ConstructLD(*Client()->iGroup,*Client()->iGc); + return dialog->Display(); + } + +TInt TPointerCaptureTest::State() const + { + return(iState); + } + +TInt TPointerCaptureTest::SubState() const + { + return(iSubState); + } + +void TPointerCaptureTest::doIncSubState() + { + iSubState++; + TInt max=0; + switch(iState) + { + case ECaptureDisabled: + max=ESubStates1; + break; + case ENormalCapture: + max=ESubStates2; + break; + case ECaptureAllGroups: + max=ESubStates3; + break; + case EDragDropCapture: + max=ESubStates4; + break; + case EDragDropCaptureAllGroups: + max=ESubStates5; + break; + case ENormalCaptureWithoutFocus: + max=ESubStates6; + break; + } + if (iSubState==max) + NextTest(); + StateChanged(); + } + +void TPointerCaptureTest::GotDD() + { + if (iDDState==DDStateWaiting) + doIncSubState(); + else + iDDState=DDStateGot; + } + +void TPointerCaptureTest::IncSubState(TBool aNeedsDD) + { + if (!aNeedsDD) + { + if (iDDState!=DDStateNull) + TestFailed(); + else + doIncSubState(); + } + else if (iDDState==DDStateGot) + doIncSubState(); + else + iDDState=DDStateWaiting; + } + +void TPointerCaptureTest::StateChanged() + { + iDDState=DDStateNull; + iChildWin->SubStateChanged(); + iMainWin->SubStateChanged(); + iAltGroupWin->SubStateChanged(); + iAltConnectionWin->SubStateChanged(); + } + +void TPointerCaptureTest::AbortTests() + { + iState=99; + Request(); + } + +void TPointerCaptureTest::NextTest() + { + iState++; + Request(); + } + +void TPointerCaptureTest::RestartTest() + { + Request(); + } + +void TPointerCaptureTest::ConstructL() + { + TSize size(Client()->iGroup->Size()); + TInt winWidth2=size.iWidth/2-EWinBorderSize*2; + TInt winWidth4=size.iWidth/4-EWinBorderSize*2; + TInt winHeight=size.iHeight/2-EWinBorderSize*2; +// + iMainGroup=new(ELeave) CTWindowGroup(Client()); + iMainGroup->ConstructL(); + iMainGroup->GroupWin()->SetOrdinalPosition(0,1); + iMainWin=new(ELeave) CPcWindowMain(this); + iMainWin->SetUpL(TPoint(EWinBorderSize,EWinBorderSize) ,TSize(winWidth2,winHeight) ,iMainGroup); + iMainGroup->SetCurrentWindow(iMainWin); + iChildWin=new(ELeave) CPcWindowChild(this); + iChildWin->SetUpL(TPoint(0,winHeight/2) ,TSize(winWidth2,winHeight/2) ,iMainWin); +// + iAltGroup=new(ELeave) CTWindowGroup(Client()); + iAltGroup->ConstructL(); + iAltGroup->GroupWin()->SetOrdinalPosition(0,1); + iAltGroup->GroupWin()->EnableReceiptOfFocus(EFalse); + iAltGroupWin=new(ELeave) CPcWindowAltGroup(this); + iAltGroupWin->SetUpL(TPoint(size.iWidth/2+EWinBorderSize,EWinBorderSize) ,TSize(winWidth4,winHeight) ,iAltGroup); +// + iAltConnection=new(ELeave) CPcConnection(this); + iAltConnection->ConstructL(); + iAltConnectionWin=new(ELeave) CPcWindowAltConnection(this); + iAltConnectionWin->SetUpL(TPoint(size.iWidth/4*3+EWinBorderSize,EWinBorderSize) ,TSize(winWidth4,winHeight),iAltConnection->iGroup,*iAltConnection->iGc); + } + +void TPointerCaptureTest::NickFocusL() + { + iNickFocusGroup=new(ELeave) CPcWindowNickFocusGroup(this,Client()); + iNickFocusGroup->ConstructL(); + iNickFocusGroup->GroupWin()->SetOrdinalPosition(0,2); + iNickFocusBlankWin=new(ELeave) CTBlankWindow(); + iNickFocusBlankWin->ConstructL(*iNickFocusGroup); + iNickFocusBlankWin->SetSize(TSize(1,1)); + iNickFocusBlankWin->Activate(); + } + +void TPointerCaptureTest::SetCapture(TInt aCaptureFlags) + { + iMainWin->Win()->SetPointerCapture(aCaptureFlags); + } + +TestState TPointerCaptureTest::DoTestL() + { + iSubState=0; + iFailed=EFalse; + StateChanged(); + switch(iState) + { + case ECaptureDisabled: + LogSubTest(_L("No capture"),1); + SetCapture(RWindowBase::TCaptureDisabled); + break; + case ENormalCapture: + LogSubTest(_L("Normal capture"),1); + SetCapture(RWindowBase::TCaptureEnabled); + break; + case ECaptureAllGroups: + LogSubTest(_L("All groups"),1); + SetCapture(RWindowBase::TCaptureEnabled|RWindowBase::TCaptureFlagAllGroups); + break; + case EDragDropCapture: + LogSubTest(_L("Drag & Drop"),1); + SetCapture(RWindowBase::TCaptureDragDrop&~RWindowBase::TCaptureFlagAllGroups); + break; + case EDragDropCaptureAllGroups: + LogSubTest(_L("Drag & Drop All groups"),1); + SetCapture(RWindowBase::TCaptureDragDrop); + break; + case ENormalCaptureWithoutFocus: + LogSubTest(_L("Without focus"),1); + NickFocusL(); + SetCapture(RWindowBase::TCaptureEnabled); + break; + default: + return(EFinished); + } + return(EContinue); + } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tman/TMPNTCUR.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tman/TMPNTCUR.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,677 @@ +// Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Tests for various pointer cursors on different windows +// +// + +#include +#include +#include "W32STD.H" +#include "../tlib/testbase.h" +#include "TMAN.H" + +class CPointerCursorWindow : public CTWin + { +public: + ~CPointerCursorWindow(); + void SetChild(CPointerCursorWindow* aChild); + inline CPointerCursorWindow* Child() {return iChild;} + inline void SetBitmap(CFbsBitmap* aBitmap,TBool aTop=ETrue) {iBitmap=aBitmap;iTop=aTop;} + void SetPointerCursor(CTPointerCursor* aCursor); + //Virtual function from CTBaseWin + void SetUpL(TPoint aPos,TSize aSize,CTWinBase *aParent,CWindowGc &aGc); + void Draw(); + void PointerL(const TPointerEvent &aPointer,const TTime &aTime); +private: + CPointerCursorWindow* iChild; + CFbsBitmap* iBitmap; + TBool iTop; + }; + +class CPointerCursorWindowGroup : public CTWindowGroup + { +public: + CPointerCursorWindowGroup(CTClient *aClient); + void SetPointerCursor(CTPointerCursor* aCursor); + void ConstructL(); + }; + +class CStatusWindow : public CTTitledWindow + { +public: + ~CStatusWindow(); + void Construct(CTestBase* aTest); + void DoDraw(); + //virtual functions from CTWinBase overridden by CTBaseWin + void WinKeyL(const TKeyEvent &aKey,const TTime &aTime); + //virtual functions from CTBaseWin + void SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc); + void PointerL(const TPointerEvent &aPointer,const TTime &aTime); + //virtual function from CTBaseWin overridden by CTTitledWindow + void Draw(); +private: + void UpdateString1(); + void UpdateString2(); + void UpdateString3(); + void ChangeXyInputType(); + void ChangePointerCursorMode(); +private: + CTestBase* iTest; + TBuf<16> iString1; + TBuf<16> iString2; + TBuf<16> iString3; + TBuf<32> iString4; + TRect iRect1; + TRect iRect2; + TRect iRect3; + TRect iRect4; + TXYInputType iXyInputType; + TXYInputType iOriginalXyInputType; + TPointerCursorMode iMode; + TPointerCursorMode iOriginalMode; + TBool iSimulatedPenDown; + TBool iUpdateNeeded; + TBool iExit; + }; + +class CPointerCursorTest : public CTestBase + { + enum {eWindowGap=3,eChildWindowGap=2}; + enum {eNumPointerCursors=7}; +public: + CPointerCursorTest(); + ~CPointerCursorTest(); + TestState DoTestL(); + void ConstructL(); +private: + CPointerCursorWindow *CreateWindowL(TInt aNum,TRect aLocation,CTWinBase *aGroup); + void CreatePointerCursorsL(); + void CreateWindowsL(TSize aArea); +private: + TSize iWinSize; + TInt iState; + CStatusWindow *iInfoWindow; + CPointerCursorWindowGroup *iGroup1; + CPointerCursorWindowGroup *iGroup2; + CPointerCursorWindow *iWindows[6]; + CTPointerCursor *iCursors[eNumPointerCursors]; + CFbsBitmap *iBitmaps[eNumPointerCursors]; + }; + + +/*CPointerCursorWindow*/ + +CPointerCursorWindow::~CPointerCursorWindow() + { + delete iChild; + } + +void CPointerCursorWindow::SetChild(CPointerCursorWindow* aChild) + { + iChild=aChild; + iWin.SetShadowDisabled(ETrue); + } + +void CPointerCursorWindow::SetPointerCursor(CTPointerCursor* aCursor) + { + iWin.SetCustomPointerCursor(aCursor->PointerCursor()); + } + +void CPointerCursorWindow::SetUpL(TPoint aPos,TSize aSize,CTWinBase *aParent,CWindowGc &aGc) + { + CTWin::SetUpL(aPos,aSize,aParent,aGc); + iWin.SetShadowDisabled(ETrue); + iWin.SetPointerGrab(EFalse); + } + +void CPointerCursorWindow::Draw() + { + iGc->Reset(); + iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + iGc->DrawRect(Size()); + if (iBitmap) + { + TPoint point(3,3); + if (!iTop) + point.iY=Size().iHeight-iBitmap->SizeInPixels().iHeight-3; + iGc->BitBlt(point,iBitmap); + } + } + +void CPointerCursorWindow::PointerL(const TPointerEvent&,const TTime&) + { + } + + +/*CPointerCursorWindowGroup*/ + +CPointerCursorWindowGroup::CPointerCursorWindowGroup(CTClient *aClient) + :CTWindowGroup(aClient) + {} + +void CPointerCursorWindowGroup::ConstructL() + { + CTWindowGroup::ConstructL(); + iGroupWin.EnableReceiptOfFocus(EFalse); + } + +void CPointerCursorWindowGroup::SetPointerCursor(CTPointerCursor* aCursor) + { + iGroupWin.SetCustomPointerCursor(aCursor->PointerCursor()); + } + + +/*CStatusWindow*/ + +CStatusWindow::~CStatusWindow() + { + Client()->iWs.SetPointerCursorMode(iOriginalMode); +#if defined(__WINS__) + Client()->iWs.SimulateXyInputType(iOriginalXyInputType); +#endif + } + +void CStatusWindow::Construct(CTestBase* aTest) + { + _LIT(Title,"StatusWindow"); + _LIT(String4,"Click here to finish"); + iTest=aTest; + TWindowTitle title(Title); + SetTitle(title); + TInt yy=iTitleHeight+iFont->HeightInPixels()+7; + iRect1.SetRect(3,iTitleHeight+5,iSize.iWidth-1,yy); + TInt yy1=yy+iFont->HeightInPixels()+2; + iRect2.SetRect(3,yy+3,iSize.iWidth-1,yy1); + TInt yy2=yy1+iFont->HeightInPixels()+2; + iRect3.SetRect(3,yy1+3,iSize.iWidth-1,yy2); + iRect4.SetRect(3,yy2+3,iSize.iWidth-1,yy2+iFont->HeightInPixels()+2); + TMachineInfoV1Buf machineInfo; + UserHal::MachineInfo(machineInfo); + iXyInputType=machineInfo().iXYInputType; + iOriginalXyInputType=iXyInputType; + iSimulatedPenDown=EFalse; + // + iString3.Copy(KNullDesC); + if (iXyInputType==EXYInputDeltaMouse) + { + if (HAL::Get(HALData::EMouseState,iSimulatedPenDown)==KErrNone) + UpdateString3(); + } + UpdateString1(); + iMode=Client()->iWs.PointerCursorMode(); + iOriginalMode=iMode; + UpdateString2(); + iUpdateNeeded=EFalse; + iString4.Copy(String4); + iExit=EFalse; + } + +void CStatusWindow::SetUpL(TPoint aPos,TSize aSize,CTWinBase *aParent,CWindowGc &aGc) + { + CTTitledWindow::SetUpL(aPos,aSize,aParent,aGc); + } + +void CStatusWindow::WinKeyL(const TKeyEvent &aKey,const TTime&) + { + switch(aKey.iCode) + { + case EKeyEscape: + iTest->Request(); + break; + case 'M': + case 'm': + if (iXyInputType==EXYInputDeltaMouse) + { + if (HAL::Set(HALData::EMouseState,!iSimulatedPenDown)==KErrNone) + { + iSimulatedPenDown=!iSimulatedPenDown; + UpdateString3(); + DoDraw(); + } + } + break; + #if defined(__WINS__) + case 'I': + case 'i': + case '1': + ChangeXyInputType(); + Client()->iWs.SimulateXyInputType(iXyInputType); + break; + #endif + case 'C': + case 'c': + case '2': + ChangePointerCursorMode(); + Client()->iWs.SetPointerCursorMode(iMode); + break; + default:; + } + } + +void CStatusWindow::PointerL(const TPointerEvent &aPointer,const TTime &aTime) + { +#if defined(__WINS__) + if (iRect1.Contains(aPointer.iPosition)) + { + if (aPointer.iType==TPointerEvent::EButton1Down) + ChangeXyInputType(); + } + else +#endif + if (iRect2.Contains(aPointer.iPosition)) + { + if (aPointer.iType==TPointerEvent::EButton1Down) + ChangePointerCursorMode(); + } + else if (iRect4.Contains(aPointer.iPosition)) + iExit=ETrue; + else + CTTitledWindow::PointerL(aPointer,aTime); + if ((iUpdateNeeded || iExit) && aPointer.iType==TPointerEvent::EButton1Up) + { + if (iExit) + iTest->Request(); + else + { + Client()->iWs.SetPointerCursorMode(iMode); + #if defined(__WINS__) + Client()->iWs.SimulateXyInputType(iXyInputType); + #endif + Client()->iWs.Flush(); + iUpdateNeeded=EFalse; + } + } + } + +void CStatusWindow::Draw() + { + CTTitledWindow::Draw(); + TInt ascent=iFont->AscentInPixels()+1; + iGc->DrawText(iString1,iRect1,ascent,CGraphicsContext::ELeft); + iGc->DrawText(iString2,iRect2,ascent,CGraphicsContext::ELeft); + iGc->DrawText(iString3,iRect3,ascent,CGraphicsContext::ELeft); + iGc->DrawText(iString4,iRect4,ascent,CGraphicsContext::ELeft); + } + +void CStatusWindow::DoDraw() + { + iGc->Activate(iWin); + iGc->UseFont((CFont *)iFont); + Draw(); + iGc->Deactivate(); + } + +void CStatusWindow::UpdateString1() + { + _LIT(Text0,"No Pointer"); + _LIT(Text1,"Pen"); + _LIT(Text2,"Mouse"); + _LIT(Text3,"Relative Mouse"); + switch (iXyInputType) + { + case EXYInputNone: + iString1.Copy(Text0); + break; + case EXYInputPointer: + iString1.Copy(Text1); + break; + case EXYInputMouse: + iString1.Copy(Text2); + break; + case EXYInputDeltaMouse: + iString1.Copy(Text3); + break; + } + } + +void CStatusWindow::UpdateString2() + { + _LIT(Text0,"None"); + _LIT(Text1,"Fixed"); + _LIT(Text2,"Normal"); + _LIT(Text3,"Window"); + switch (iMode) + { + case EPointerCursorNone: + iString2.Copy(Text0); + break; + case EPointerCursorFixed: + iString2.Copy(Text1); + break; + case EPointerCursorNormal: + iString2.Copy(Text2); + break; + case EPointerCursorWindow: + iString2.Copy(Text3); + break; + } + } + +void CStatusWindow::UpdateString3() + { + if (iSimulatedPenDown) + { + _LIT(TextD,"Sim Pen Down"); + iString3.Copy(TextD); + } + else + { + _LIT(TextU,"Sim Pen Up"); + iString3.Copy(TextU); + } + } + +void CStatusWindow::ChangeXyInputType() + { + if (iXyInputType==EXYInputMouse) + iXyInputType=EXYInputPointer; + else if (iXyInputType==EXYInputPointer) + iXyInputType=EXYInputMouse; + UpdateString1(); + DoDraw(); + iUpdateNeeded=ETrue; + } + +void CStatusWindow::ChangePointerCursorMode() + { + TInt mode=(iMode+1)%(EPointerCursorLastMode+1); + iMode=STATIC_CAST(TPointerCursorMode,mode); + UpdateString2(); + DoDraw(); + iUpdateNeeded=ETrue; + } + + +/*Sprite Drawing Functions*/ + +#if defined(__WINS__) + #define DRAW_COLOR 1 +#else + #define DRAW_COLOR 0 +#endif + +void DrawCross(CBitmapContext *aGc,TInt , const TSize &aSize, TBool aDoMask, TAny *aLineWidth) + { + TInt halfLineWidth=(*STATIC_CAST(TInt*,aLineWidth)+1)/2; + TInt lineWidth=2*halfLineWidth+1; //Must be odd + aGc->SetBrushColor(TRgb::Gray4(aDoMask ? 0 : 3)); + aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + aGc->SetPenStyle(CGraphicsContext::ENullPen); + aGc->DrawRect(TRect(aSize)); + aGc->SetPenStyle(CGraphicsContext::ESolidPen); + aGc->SetPenColor(TRgb::Gray4(aDoMask ? 3 : 0)); + aGc->SetPenSize(TSize(lineWidth,lineWidth)); + aGc->DrawLine(TPoint(halfLineWidth,halfLineWidth),TPoint(aSize.iWidth-lineWidth,aSize.iHeight-lineWidth)); + aGc->DrawLine(TPoint(halfLineWidth,aSize.iHeight-lineWidth),TPoint(aSize.iWidth-lineWidth,halfLineWidth)); + } + +void DrawArrow(CBitmapContext *aGc,TInt , const TSize &aSize, TBool aDoMask, TAny *aLineWidth) + { + TInt lineWidth=*STATIC_CAST(TInt*,aLineWidth); + TInt halfLineWidth=(lineWidth-1)/2; + aGc->SetBrushColor(TRgb::Gray4(aDoMask ? 0 : 3)); + aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + aGc->SetPenStyle(CGraphicsContext::ENullPen); + aGc->DrawRect(TRect(aSize)); + aGc->SetPenStyle(CGraphicsContext::ESolidPen); + aGc->SetPenColor(TRgb::Gray4(aDoMask ? 3 : 0)); + aGc->SetPenSize(TSize(1,1)); + aGc->DrawLine(TPoint(0,0),TPoint(lineWidth,0)); + aGc->DrawLine(TPoint(0,0),TPoint(0,lineWidth)); + aGc->SetPenSize(TSize(lineWidth,lineWidth)); + aGc->DrawLine(TPoint(halfLineWidth,halfLineWidth),TPoint(aSize.iWidth-halfLineWidth-1,aSize.iHeight-halfLineWidth-1)); + aGc->DrawLine(TPoint(halfLineWidth,halfLineWidth),TPoint(aSize.iWidth/2,halfLineWidth)); + aGc->DrawLine(TPoint(halfLineWidth,halfLineWidth),TPoint(halfLineWidth,aSize.iHeight/2)); + } + +void DrawSquare(CBitmapContext *aGc,TInt , const TSize &aSize, TBool aDoMask, TAny *) + { + aGc->SetBrushColor(TRgb::Gray4(aDoMask ? 0 : 3)); + aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + aGc->SetPenStyle(CGraphicsContext::ENullPen); + aGc->DrawRect(TRect(aSize)); + aGc->SetBrushColor(TRgb::Gray4(aDoMask ? 3 : DRAW_COLOR)); + aGc->DrawRect(TRect(1,1,aSize.iWidth-1,aSize.iHeight-1)); + } + +void DrawCircle(CBitmapContext *aGc,TInt , const TSize &aSize, TBool aDoMask, TAny *) + { + aGc->SetBrushColor(TRgb::Gray4(aDoMask ? 0 : 3)); + aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + aGc->SetPenStyle(CGraphicsContext::ENullPen); + aGc->DrawRect(TRect(aSize)); + aGc->SetBrushColor(TRgb::Gray4(aDoMask ? 3 : 1)); + aGc->DrawEllipse(TRect(1,1,aSize.iWidth-1,aSize.iHeight-1)); + } + +void DrawTriangle(CBitmapContext *aGc,TInt , const TSize &aSize, TBool aDoMask, TAny *) + { + aGc->SetBrushColor(TRgb::Gray4(aDoMask ? 0 : 3)); + aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + aGc->SetPenStyle(CGraphicsContext::ENullPen); + aGc->DrawRect(TRect(aSize)); + aGc->SetPenStyle(CGraphicsContext::ESolidPen); + aGc->SetPenColor(TRgb::Gray4(aDoMask ? 3 : DRAW_COLOR)); + aGc->SetPenSize(TSize(1,1)); + for(TInt y=0;yDrawLine(TPoint(aSize.iWidth-xfact-1,y),TPoint(aSize.iWidth-1,y)); + } + } + +void DrawOpenSquare(CBitmapContext *aGc,TInt , const TSize &aSize, TBool aDoMask, TAny *aLineWidth) + { + TInt halfLineWidth=*STATIC_CAST(TInt*,aLineWidth)/2; + TInt lineWidth=2*halfLineWidth+1; //Must be odd + aGc->SetBrushColor(TRgb::Gray4(aDoMask ? 0 : 3)); + aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + aGc->SetPenStyle(CGraphicsContext::ENullPen); + aGc->DrawRect(TRect(aSize)); + aGc->SetBrushStyle(CGraphicsContext::ENullBrush); + aGc->SetPenStyle(CGraphicsContext::ESolidPen); + aGc->SetPenColor(TRgb::Gray4(aDoMask ? 3 : DRAW_COLOR)); + aGc->SetPenSize(TSize(lineWidth,lineWidth)); + TPoint botRig(aSize.iWidth-aSize.iWidth/4-1,aSize.iHeight-aSize.iHeight/4-1); + aGc->DrawRect(TRect(aSize.iWidth/4,aSize.iHeight/4,botRig.iX+1,botRig.iY+1)); + aGc->DrawLine(TPoint(halfLineWidth,halfLineWidth),TPoint(aSize.iWidth/4-halfLineWidth,aSize.iHeight/4-halfLineWidth)); + aGc->DrawLine(TPoint(aSize.iWidth-1-halfLineWidth,halfLineWidth),TPoint(botRig.iX+halfLineWidth,aSize.iHeight/4-halfLineWidth)); + aGc->DrawLine(TPoint(aSize.iWidth-1-halfLineWidth,aSize.iHeight-1-halfLineWidth),TPoint(botRig.iX+halfLineWidth,botRig.iY+halfLineWidth)); + aGc->DrawLine(TPoint(halfLineWidth,aSize.iHeight-1-halfLineWidth),TPoint(aSize.iWidth/4-halfLineWidth,botRig.iY+halfLineWidth)); + } + +void DrawOpenCircle(CBitmapContext *aGc,TInt , const TSize &aSize, TBool aDoMask, TAny *aLineWidth) + { + TInt halfLineWidth=*STATIC_CAST(TInt*,aLineWidth)/2; + TInt lineWidth=2*halfLineWidth+1; //Must be odd + aGc->SetBrushColor(TRgb::Gray4(aDoMask ? 0 : 3)); + aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + aGc->SetPenStyle(CGraphicsContext::ENullPen); + aGc->DrawRect(TRect(aSize)); + aGc->SetBrushStyle(CGraphicsContext::ENullBrush); + aGc->SetPenStyle(CGraphicsContext::ESolidPen); + aGc->SetPenColor(TRgb::Gray4(aDoMask ? 3 : DRAW_COLOR)); + aGc->SetPenSize(TSize(lineWidth,lineWidth)); + TPoint botRig(aSize.iWidth-aSize.iWidth/4-1,aSize.iHeight-aSize.iHeight/4-1); + aGc->DrawEllipse(TRect(aSize.iWidth/4+1,aSize.iHeight/4+1,botRig.iX+1,botRig.iY+1)); + aGc->DrawLine(TPoint(aSize.iWidth/2,1+halfLineWidth),TPoint(aSize.iWidth/2,aSize.iHeight/4+1-halfLineWidth)); + aGc->DrawLine(TPoint(aSize.iWidth/2,aSize.iHeight-1-halfLineWidth),TPoint(aSize.iWidth/2,botRig.iY+halfLineWidth)); + aGc->DrawLine(TPoint(1+halfLineWidth,aSize.iWidth/2),TPoint(aSize.iWidth/4+1-halfLineWidth,aSize.iHeight/2)); + aGc->DrawLine(TPoint(aSize.iWidth-1-halfLineWidth,aSize.iHeight/2),TPoint(botRig.iX+halfLineWidth,aSize.iWidth/2)); + } + + +/*CPointerCursorTest*/ + +GLDEF_C CTestBase *CreatePointerCursorTest() + { + return(new(ELeave) CPointerCursorTest()); + } + +CPointerCursorTest::CPointerCursorTest() : CTestBase(_L("PointerCursor")) + {} + +CPointerCursorTest::~CPointerCursorTest() + { + TInt ii; + Client()->iGroup->SetCurrentWindow(NULL); + delete iInfoWindow; + for(ii=0;ii<6;++ii) + { + delete iWindows[ii]; + } + for(ii=0;iiiScreen->SizeInPixels(); + TInt infoWidth=Min(210,5*size.iWidth/12); + size.iWidth=Max(Min(415,size.iWidth-infoWidth),85); + iInfoWindow=new(ELeave) CStatusWindow(); + iInfoWindow->SetUpL(TPoint(size.iWidth,50),TSize(infoWidth,180),Client()->iGroup,*Client()->iGc); + Client()->iGroup->SetCurrentWindow(iInfoWindow); + iInfoWindow->Construct(this); + iGroup1=new(ELeave) CPointerCursorWindowGroup(Client()); + iGroup1->ConstructL(); + iGroup2=new(ELeave) CPointerCursorWindowGroup(Client()); + iGroup2->ConstructL(); + size.iWidth-=5; + CreateWindowsL(size); + CreatePointerCursorsL(); + iGroup1->SetPointerCursor(iCursors[0]); + iWindows[1]->SetBitmap(iBitmaps[0],EFalse); + iWindows[0]->SetPointerCursor(iCursors[1]); + iWindows[0]->SetBitmap(iBitmaps[1]); + iWindows[0]->Child()->SetPointerCursor(iCursors[2]); + iWindows[0]->Child()->SetBitmap(iBitmaps[2]); + iWindows[2]->SetPointerCursor(iCursors[3]); + iWindows[2]->SetBitmap(iBitmaps[3]); + iWindows[2]->Child()->Child()->SetPointerCursor(iCursors[4]); + iWindows[2]->Child()->Child()->SetBitmap(iBitmaps[4]); + iWindows[3]->Child()->SetPointerCursor(iCursors[5]); + iWindows[3]->Child()->SetBitmap(iBitmaps[5]); + iWindows[4]->SetPointerCursor(iCursors[6]); + iWindows[4]->SetBitmap(iBitmaps[6]); + } + +void CPointerCursorTest::CreateWindowsL(TSize aArea) + { + //TSize screenSize=Client()->iScreen->SizeInPixels(); + TInt height=eWindowGap+(aArea.iHeight-5*eWindowGap)/4; + TInt halfWidth=aArea.iWidth/2; + TRect rect(5,eWindowGap,halfWidth,height); + iWindows[0]=CreateWindowL(2,rect,iGroup1); + rect.Move(halfWidth,0); + iWindows[1]=CreateWindowL(2,rect,iGroup1); + rect.Move(-halfWidth,height); + rect.iBr.iX=aArea.iWidth; + iWindows[2]=CreateWindowL(4,rect,iGroup2); + rect.Move(0,height); + rect.iBr.iX=aArea.iWidth-11; + iWindows[3]=CreateWindowL(3,rect,iGroup2); + rect.Move(0,height); + rect.iBr.iX=halfWidth; + iWindows[4]=CreateWindowL(2,rect,iGroup2); + rect.Move(halfWidth,0); + iWindows[5]=CreateWindowL(2,rect,iGroup2); + } + +CPointerCursorWindow* CPointerCursorTest::CreateWindowL(TInt aNum,TRect aLocation,CTWinBase *aGroup) + { + CPointerCursorWindow* firstWin=NULL; + CPointerCursorWindow* parent=NULL; + CPointerCursorWindow* win; + TInt xInc=aLocation.Width()/aNum-eChildWindowGap; + TInt ii; + for (ii=aNum;ii>0;ii--) + { + win=new(ELeave) CPointerCursorWindow(); + CleanupStack::PushL(win); + win->SetUpL(aLocation.iTl,aLocation.Size(),aGroup,*Client()->iGc); + if (!parent) + firstWin=win; + else + { + parent->SetChild(win); + CleanupStack::Pop(); + } + aLocation.iBr=TPoint(-eChildWindowGap,-eChildWindowGap)+aLocation.Size(); + aLocation.iTl.iX=xInc; + aLocation.iTl.iY=eChildWindowGap; + aGroup=win; + parent=win; + } + CleanupStack::Pop(); + return firstWin; + } + +void CPointerCursorTest::CreatePointerCursorsL() + { + const TSize size(32,32); + TSpriteCreateParams params(size,TPoint(-16,-16),DrawSquare); + TSpriteCreateParams paramarray[eNumPointerCursors]; + TInt lineWidth1=3; + TInt lineWidth2=5; + paramarray[2]=params; + params.iDrawFunc=DrawCircle; + paramarray[3]=params; + params.iDrawFunc=DrawOpenSquare; + params.iDrawFuncParam=&lineWidth1; + paramarray[5]=params; + params.iDrawFunc=DrawOpenCircle; + paramarray[6]=params; + params.iOffset=TPoint(0,0); + params.iDrawFunc=DrawArrow; + params.iDrawFuncParam=&lineWidth2; + paramarray[1]=params; + params.iOffset.iX=-31; + params.iDrawFunc=DrawTriangle; + paramarray[4]=params; + params.iOffset=TPoint(-15,-15); + params.iDrawFunc=DrawCross; + paramarray[0]=params; + CFbsBitmap *bitmap; + TInt ii,jj; + TDisplayMode mode=Client()->iWs.GetDefModeMaxNumColors(ii,jj); + for (ii=0;iiCreate(size,mode)); + iCursors[ii]=new(ELeave) CTPointerCursor(Client()->iWs); + iCursors[ii]->ConstructL(1,¶marray[ii],0,iBitmaps[ii],bitmap); + delete bitmap; + } + } + +TestState CPointerCursorTest::DoTestL() + { + switch(iState) + { + case 0: + LogSubTest(_L("Pointer Cursor"),1); + TestL(ETrue); + iState++; + return(EContinue); + default: + return(EFinished); + } + } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tman/TMPNTKEY.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tman/TMPNTKEY.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,305 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Test Pointer move/drag buffer +// +// + +#include +#include +#include "W32STD.H" +#include "../tlib/testbase.h" +#include "TMAN.H" + +const TInt ENumPntKeyTests=6; +const TUint EModifierMask=EModifierCtrl|EModifierShift|EModifierFunc; + +class CTPntKeyTest; + +class CTPntKeyWindow : public CTWin + { +private: + enum {KPointerMoveBufferSize=32}; +public: + CTPntKeyWindow(CTPntKeyTest *aTest); + ~CTPntKeyWindow(); + void SetUpLD(TPoint pos,TSize size,CTWinBase *parent); + void PointerL(const TPointerEvent &pointer,const TTime &aTime); + void KeyUpL(const TKeyEvent &aKey,const TTime &); + void KeyDownL(const TKeyEvent &aKey,const TTime &); + void WinKeyL(const TKeyEvent &aKey,const TTime &); + void SwitchOn(const TTime &aTime); + void SetState(TInt iState); + void NextKey(); + void Test(TInt aCheck); + void Error(); + void DrawButton(const TRect &aRect, const TDesC &aText); + void Draw(); +private: + CTPntKeyTest *iTest; + TInt iKeyCount; + TRect iKey1; + TRect iKey2; + TRect iKey3; + static TInt iTestScanCodes[ENumPntKeyTests]; + static TUint iTestCodes[ENumPntKeyTests]; + static TUint iTestModifiers[ENumPntKeyTests]; + }; + +class CTPntKeyTest : public CTestBase + { +public: + CTPntKeyTest(); + ~CTPntKeyTest(); + TestState DoTestL(); + void FinishedTests(); + void ConstructL(); + void Failed(); + inline TBool NoDigitiser() const {return iNoDigitiser;} +private: + CTPntKeyWindow *iWin; + TSize iWinSize; + TInt iState; + TBool iFailed; + TBool iOldPointerState; + TBool iNoDigitiser; + }; + +TInt CTPntKeyWindow::iTestScanCodes[ENumPntKeyTests]={'A','B',0,'C',EStdKeyEnter,'Y'}; +TUint CTPntKeyWindow::iTestCodes[ENumPntKeyTests]={'a','B',0,'c',EKeyEnter,'y'}; +TUint CTPntKeyWindow::iTestModifiers[ENumPntKeyTests]={0,EModifierShift,0,0,0,0}; + +GLDEF_C CTestBase *CreatePointerKeyTest() + { + return(new(ELeave) CTPntKeyTest()); + } + +CTPntKeyWindow::CTPntKeyWindow(CTPntKeyTest *aTest) : iTest(aTest) + {} + +CTPntKeyWindow::~CTPntKeyWindow() + { + } + +void CTPntKeyWindow::SetUpLD(TPoint pos,TSize size,CTWinBase *parent) + { + ConstructExtLD(*parent,pos,size); + iWin.SetPointerGrab(ETrue); + iKey1=TRect(size.iWidth*1/16,size.iHeight/2,size.iWidth*5/16,size.iHeight); + iKey2=TRect(size.iWidth*6/16,size.iHeight/2,size.iWidth*10/16,size.iHeight); + iKey3=TRect(size.iWidth*11/16,size.iHeight/2,size.iWidth*15/16,size.iHeight); + iWin.AddKeyRect(iKey1,'A',EFalse); + iWin.AddKeyRect(iKey2,'B',EFalse); + AssignGC(*Client()->iGc); + BaseWin()->EnableOnEvents(); + Activate(); + } + +void CTPntKeyWindow::Error() + { + iTest->Failed(); + } + +void CTPntKeyWindow::SetState(TInt iState) + { + iKeyCount=iState-1; + NextKey(); + iTest->Client()->Flush(); + } + +void CTPntKeyWindow::NextKey() + { + if (++iKeyCount==ENumPntKeyTests || iKeyCount>4) + iTest->FinishedTests(); + else + { + if (iKeyCount==2) + iWin.RemoveAllKeyRects(); + else if (iKeyCount==3) + iWin.AddKeyRect(iKey3,'C',EFalse); + else if (iKeyCount==4) + { + #if !defined(__WINS__) + if (iTest->NoDigitiser()) + iTest->FinishedTests(); + #endif + iWin.RemoveAllKeyRects(); + iWin.AddKeyRect(TRect(Client()->iScreen->SizeInPixels()),'Z',EFalse); + } + else if (iKeyCount==5) + { + iWin.RemoveAllKeyRects(); + Client()->iWs.Flush(); + User::After(500000); // Wait half a second + iWin.AddKeyRect(TRect(Client()->iScreen->SizeInPixels()),'Y',ETrue); + } + Invalidate(); + } + } + +void CTPntKeyWindow::Test(TInt aCheck) + { + if (!aCheck) + Error(); + } + +void CTPntKeyWindow::KeyUpL(const TKeyEvent &aKey,const TTime&) + { + if (aKey.iScanCode==iTestScanCodes[iKeyCount]) + NextKey(); + } + +void CTPntKeyWindow::KeyDownL(const TKeyEvent &aKey,const TTime &) + { + if (aKey.iScanCode!=EStdKeyLeftFunc && aKey.iScanCode!=EStdKeyRightFunc && + aKey.iScanCode!=EStdKeyLeftAlt && aKey.iScanCode!=EStdKeyRightAlt && + aKey.iScanCode!=EStdKeyLeftCtrl && aKey.iScanCode!=EStdKeyRightCtrl && + aKey.iScanCode!=EStdKeyLeftShift && aKey.iScanCode!=EStdKeyRightShift && + aKey.iScanCode!=EStdKeyOff && + aKey.iScanCode!=EStdKeyEscape) + Test(aKey.iScanCode==iTestScanCodes[iKeyCount]); + } + +void CTPntKeyWindow::WinKeyL(const TKeyEvent &aKey,const TTime &) + { + if (aKey.iCode==EKeyEscape) + iTest->FinishedTests(); + else + { + Test(aKey.iScanCode==iTestScanCodes[iKeyCount]); + Test(aKey.iCode==iTestCodes[iKeyCount]); + Test((aKey.iModifiers&EModifierMask)==(iTestModifiers[iKeyCount]&EModifierMask)); + } + } + +void CTPntKeyWindow::SwitchOn(const TTime &) + { + if (iKeyCount==4) + NextKey(); + else if (iKeyCount!=5) + Error(); + } + +void CTPntKeyWindow::PointerL(const TPointerEvent &aPointer,const TTime &) + { + if (aPointer.iType==TPointerEvent::EButton1Down) + { + if (iKeyCount!=2) + Error(); + else + NextKey(); + } + } + +void CTPntKeyWindow::DrawButton(const TRect &aRect, const TDesC &aText) + { + iGc->DrawRect(aRect); + iGc->DrawText(aText, TPoint((aRect.iBr.iX+aRect.iTl.iX)/2,(aRect.iBr.iY+aRect.iTl.iY)/2)); + } + +void CTPntKeyWindow::Draw() + { + iGc->SetBrushColor(TRgb::Gray4(0)); + iGc->SetPenColor(TRgb::Gray4(3)); + iGc->Clear(); + DrawButton(iKey1,_L("A")); + DrawButton(iKey2,_L("B")); + DrawButton(iKey3,_L("C")); + switch(iKeyCount) + { + case 0: + iGc->DrawText(_L("Click on 'A'"), TPoint(10,20)); + break; + case 1: + iGc->DrawText(_L("Shift-Click on 'B'"), TPoint(10,20)); + break; + case 2: + iGc->DrawText(_L("Click anywhere in this window"), TPoint(10,20)); + break; + case 3: + iGc->DrawText(_L("Click on 'C'"), TPoint(10,20)); + break; + case 4: +#if defined(__WINS__) // Can't emulate touching dig when switched off under WINS + iGc->DrawText(_L("Switch off and on (or press Enter)"), TPoint(10,20)); +#else + iGc->DrawText(_L("1st Switch off, then touch the screen to switch on"), TPoint(10,20)); +#endif + break; + case 5: +#if defined(__WINS__) // Can't emulate touching dig when switched off under WINS + iGc->DrawText(_L("Touch anywhere in the window"), TPoint(10,20)); +#else + iGc->DrawText(_L("2nd Switch off and touch the screen to switch on"), TPoint(10,20)); +#endif + break; + } + } + +CTPntKeyTest::CTPntKeyTest() : CTestBase(_L("Pointer Key Test")) + {} + +CTPntKeyTest::~CTPntKeyTest() + { + HAL::Set(HALData::EPenDisplayOn,iOldPointerState); + CTWin::Delete(iWin); + Client()->ResetFocus(); + } + +void CTPntKeyTest::Failed() + { + if (!iFailed) + { + iFailed=ETrue; + FinishedTests(); + } + } + +void CTPntKeyTest::FinishedTests() + { + Request(); + } + +void CTPntKeyTest::ConstructL() + { + CTPntKeyWindow *win=new(ELeave) CTPntKeyWindow(this); + win->SetUpLD(TPoint(20,20),Client()->iScreen->SizeInPixels()-TSize(40,40),Client()->iGroup); + iWin=win; + Client()->iGroup->SetCurrentWindow(iWin); + iNoDigitiser=EFalse; + TInt err=HAL::Get(HALData::EPenDisplayOn,iOldPointerState); + if (err==KErrNotSupported) + iNoDigitiser=ETrue; + else if (err==KErrNone) + err=HAL::Set(HALData::EPenDisplayOn,ETrue); + if (err==KErrNotSupported) + iNoDigitiser=(!iOldPointerState); + else + TestL(err==KErrNone); + } + +TestState CTPntKeyTest::DoTestL() + { + TestL(!iFailed); + switch(iState) + { + case 0: + LogSubTest(_L("Key set 1"),1); + iWin->SetState(4); + iState++; + return(EContinue); + default: + return(EFinished); + } +// return(ENext); + } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tman/TMPOINTR.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tman/TMPOINTR.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,808 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Test pointer event handling +// +// + +#include +#include +#include "W32STD.H" +#include "../tlib/testbase.h" +#include "TMAN.H" + +class CTPointerTest; +class CGrabWindow; + +class CPointerWindow : public CTWin + { + enum {KRepeatMargin=200000}; // 0.2 Seconds + enum {KRepeatCount=4}; + enum {KRepeatIntervalIncrements=100000}; + enum {KRepeatRectXExtra=50}; + enum {KRepeatRectYExtra=50}; + enum {KStateWaitingForTest1,KStateFailed,KStateTesting1, + KStateWaitingForTest2,KStateTesting2, + KStateWaitingForTest3,KStateTesting3, + KStateWaitingForTest4,KStateTesting4, + KStateWaitingForTest5,KStateTesting5, + KStateWaitingForTest6,KStateTesting6, + KStateWaitingForTest8,KStateTesting8, + KStateWaitingForTest7,KStateTesting7, + KStateFinished}; +public: + CPointerWindow(CTPointerTest *aTest); + void SetUpLD(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc); + void Draw(); + void StartNextRepeatTest(); + void QueueNextRepeat(); + void PointerL(const TPointerEvent &aPointer,const TTime&); + void WinKeyL(const TKeyEvent &aKey,const TTime &aTime); +private: + void SwitchOn(const TTime &); + void ResetTest(TInt aState); + void SetState(TInt aState); + void FinishedTests(); + void TestFailed(); +private: + CTPointerTest *iTest; + TInt iRepeatCount; + TInt iState; + TTimeIntervalMicroSeconds32 iInterval; + TTime iPrevTime; + TRect iRepeatRect; + }; + +class CGrabWindow2 : public CTWin + { +public: + CGrabWindow2(CGrabWindow *aWindow); + void SetUpLD(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc); +private: + void Draw(); + void PointerL(const TPointerEvent &aPointer,const TTime&); +private: + CGrabWindow *iGrabWindow; + }; + +class CGrabWindow : public CTWin + { + enum {KGrabStateWaitingForDown,KGrabStateWaitingForDragOut,KGrabStateWaitingForUp,KGrabStateFinished, + KGrabStateWaitingForDown2,KGrabStateWaitingForUp2a,KGrabStateWaitingForDrag2,KGrabStateWaitingForUp2b, + KGrabStateWaitingForDown3,KGrabStateWaitingForUp3a,KGrabStateWaitingForUp3b, + KGrabStateWaitingForDown4,KGrabStateWaitingForUp4, + KGrabStateWaitingForDown5,KGrabStateWaitingForUp5,KGrabStateWaitingForDrag5, + KStateFailed}; +public: + CGrabWindow(CTPointerTest *aTest); + void Pointer2(const TPointerEvent &aPointer); + void SetUpLD(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc); + void WinKeyL(const TKeyEvent &aKey,const TTime &aTime); +private: + void Draw(); + void SetState(TInt aState); + void ResetTest(); + void PointerL(const TPointerEvent &aPointer,const TTime&); + void TestFailed(); + void FinishedTests(); +private: + TInt iState; + CTPointerTest *iTest; + }; + +class CTPointerTest : public CTestBase + { +public: + CTPointerTest(); + ~CTPointerTest(); + TBool TestFailed(); + TestState DoTestL(); + void StartGrabTestL(); + void ConstructL(); + CGrabWindow2 *GrabWin2() const; + inline TBool Digitiser() const {return !iNoDigitiser;} +private: + TInt doTestFailedL(); +private: + CPointerWindow *iRepeatWin; + CGrabWindow *iGrabWin; + CGrabWindow2 *iGrabWin2; + TSize iWinSize; + TInt iState; + TBool iOldPointerState; + TBool iNoDigitiser; + }; + +GLDEF_C CTestBase *CreatePointerTest() + { + return(new(ELeave) CTPointerTest()); + } + +CPointerWindow::CPointerWindow(CTPointerTest *aTest) : CTWin(), iTest(aTest) + {} + +void CPointerWindow::SetState(TInt aState) + { + iState=aState; + iWin.Invalidate(); + switch(aState) + { + case KStateWaitingForTest1: + case KStateWaitingForTest2: + case KStateWaitingForTest3: + case KStateWaitingForTest4: + case KStateWaitingForTest5: + case KStateWaitingForTest6: + case KStateWaitingForTest8: + case KStateWaitingForTest7: + iRepeatRect=TRect(); + break; + case KStateTesting8: + iWin.Close(); + Client()->iWs.Flush(); + User::After(500000); + FinishedTests(); + break; + } + } + +void CPointerWindow::ResetTest(TInt aState) + { + TInt newState=KStateFinished; + switch(aState) + { + case KStateTesting1: + newState=KStateWaitingForTest1; + break; + case KStateTesting2: + newState=KStateWaitingForTest2; + break; + case KStateTesting3: + newState=KStateWaitingForTest3; + break; + case KStateTesting4: + newState=KStateWaitingForTest4; + break; + case KStateTesting5: + newState=KStateWaitingForTest5; + break; + case KStateTesting6: + newState=KStateWaitingForTest6; + break; + case KStateTesting8: + newState=KStateWaitingForTest8; + break; + case KStateTesting7: + newState=KStateWaitingForTest7; + break; + } + SetState(newState); + } + +void CPointerWindow::SetUpLD(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc) + { + ConstructExtLD(*parent,pos,size); + Activate(); + AssignGC(aGc); + //SetState(KStateWaitingForTest1); + SetState(KStateWaitingForTest7); //Only unconverted test + BaseWin()->EnableOnEvents(); + } + +void CPointerWindow::Draw() + { + iGc->Clear(); + iGc->DrawRect(Size()); + iGc->DrawRect(iRepeatRect); + TBuf<0x80> buf; + TBuf<0x80> buf2; + switch(iState) + { + case KStateWaitingForTest1: + buf.Format(_L("Click anywhere in the window and hold the pointer steady")); + break; + case KStateTesting1: + buf.Format(_L("Hold pointer inside the box")); + break; + case KStateWaitingForTest2: + buf.Format(_L("Release the pointer then click in the window and hold the pointer steady")); + break; + case KStateTesting2: + buf.Format(_L("Drag the pointer outside the box")); + break; + case KStateWaitingForTest3: + buf.Format(_L("Release the pointer then click in the window and hold the pointer steady")); + break; + case KStateTesting3: + buf.Format(_L("Release the pointer")); + break; + case KStateWaitingForTest4: + buf.Format(_L("Click anywhere in the window and move the pointer slightly")); + break; + case KStateTesting4: + buf.Format(_L("Release the pointer")); + break; + case KStateWaitingForTest5: + buf.Format(_L("Click anywhere in the window and move the pointer slightly")); + break; + case KStateTesting5: + buf.Format(_L("Release the pointer")); + break; + case KStateWaitingForTest6: + buf.Format(_L("Click anywhere in the window")); + break; + case KStateTesting6: + buf.Format(_L("Move the pointer")); + break; + case KStateWaitingForTest8: + buf.Format(_L("Click anywhere in the window, and keep the pointer pressed")); + break; + case KStateTesting8: + buf.Format(_L("")); + break; + case KStateWaitingForTest7: + buf.Format(_L("Switch off and touch the center of the screen")); + break; + case KStateTesting7: + buf.Format(_L("")); + break; + } + switch(iState) + { + case KStateTesting1: + buf2.Format(TRefByValue(_L("Repeat (%d/%d), interval=%d.%d")),iRepeatCount,KRepeatCount,iInterval.Int()/1000000,(iInterval.Int()%1000000)/100000); + break; + case KStateTesting2: + case KStateTesting3: + buf2.Format(TRefByValue(_L("Repeat (%d), interval=%d.%d")),iRepeatCount,iInterval.Int()/1000000,(iInterval.Int()%1000000)/100000); + break; + } + iGc->DrawText(buf,TPoint(10,20)); + iGc->DrawText(buf2,TPoint(10,40)); + } + +void CPointerWindow::FinishedTests() + { + iState=KStateFinished; + iTest->Request(); + } + +void CPointerWindow::StartNextRepeatTest() + { + iInterval=0; + iRepeatCount=0; + if (iState==KStateWaitingForTest4) + User::After(TTimeIntervalMicroSeconds32(1000000)); + else if (iState==KStateWaitingForTest5) + User::After(TTimeIntervalMicroSeconds32(1000000)); + QueueNextRepeat(); + switch(iState) + { + case KStateWaitingForTest1: + SetState(KStateTesting1); + break; + case KStateWaitingForTest2: + SetState(KStateTesting2); + break; + case KStateWaitingForTest3: + SetState(KStateTesting3); + break; + case KStateWaitingForTest4: + SetState(KStateTesting4); + break; + case KStateWaitingForTest5: + SetState(KStateTesting5); + break; + case KStateWaitingForTest6: + SetState(KStateTesting6); + break; + case KStateWaitingForTest8: + SetState(KStateTesting8); + break; + case KStateWaitingForTest7: + SetState(KStateTesting7); + break; + } + } + +void CPointerWindow::QueueNextRepeat() + { + iInterval=iInterval.Int()+KRepeatIntervalIncrements; + iWin.RequestPointerRepeatEvent(TTimeIntervalMicroSeconds32(iInterval),TRect(iRepeatRect)); + iPrevTime.HomeTime(); + iWin.Invalidate(); + } + +void CPointerWindow::PointerL(const TPointerEvent &aPointer,const TTime &aTime) + { + if (aPointer.iType==TPointerEvent::EButtonRepeat) + { + if (iState!=KStateTesting1 && iState!=KStateTesting2 && iState!=KStateTesting3 && iState!=KStateTesting4) + TestFailed(); + else + { + TTimeIntervalMicroSeconds32 interval(I64LOW(aTime.MicroSecondsFrom(iPrevTime).Int64())); + if (interval.Int()<(iInterval.Int()-KRepeatMargin) || interval.Int()>(iInterval.Int()+KRepeatMargin)) + TestFailed(); + else + { + if (!iRepeatRect.Contains(aPointer.iPosition) || + aPointer.iParentPosition!=(aPointer.iPosition+iWin.InquireOffset(*Parent()->WinTreeNode()))) + TestFailed(); + else + { + iRepeatCount++; + if (iState==KStateTesting1 && iRepeatCount==KRepeatCount) + { + QueueNextRepeat(); + Client()->iWs.Flush(); + User::After(TTimeIntervalMicroSeconds32(iRepeatCount*KRepeatIntervalIncrements)); + iWin.CancelPointerRepeatEventRequest(); + SetState(KStateWaitingForTest2); + } + else + QueueNextRepeat(); + } + } + } + } + else switch(iState) + { + case KStateWaitingForTest1: + case KStateWaitingForTest2: + case KStateWaitingForTest3: + case KStateWaitingForTest4: + case KStateWaitingForTest8: + if (aPointer.iType==TPointerEvent::EButton1Down) + { + iRepeatRect.iTl=aPointer.iPosition-TPoint(KRepeatRectXExtra,KRepeatRectYExtra); + iRepeatRect.iBr=aPointer.iPosition+TPoint(KRepeatRectXExtra,KRepeatRectYExtra); + StartNextRepeatTest(); + } + break; + case KStateWaitingForTest5: + if (aPointer.iType==TPointerEvent::EButton1Down) + { + iRepeatRect.iTl=aPointer.iPosition; + iRepeatRect.iBr=aPointer.iPosition+TPoint(1,1); + StartNextRepeatTest(); + } + break; + case KStateWaitingForTest6: + if (aPointer.iType==TPointerEvent::EButton1Down) + { + iRepeatRect.iTl=aPointer.iPosition+TPoint(KRepeatRectXExtra,KRepeatRectYExtra); + iRepeatRect.iBr=aPointer.iPosition+TPoint(2*KRepeatRectXExtra,2*KRepeatRectYExtra); + StartNextRepeatTest(); + } + break; + case KStateTesting1: + TestFailed(); + break; + case KStateTesting2: + if (aPointer.iType==TPointerEvent::EDrag) + SetState(KStateWaitingForTest3); + else + TestFailed(); + break; + case KStateTesting3: + if (aPointer.iType==TPointerEvent::EButton1Up) + SetState(KStateWaitingForTest4); + else + TestFailed(); + break; + case KStateTesting4: + if (aPointer.iType==TPointerEvent::EButton1Up) + SetState(KStateWaitingForTest5); + else + TestFailed(); + break; + case KStateTesting5: + if (aPointer.iType==TPointerEvent::EButton1Up) + SetState(KStateWaitingForTest6); + else if (aPointer.iType!=TPointerEvent::EDrag) + TestFailed(); + break; + case KStateTesting6: + if (aPointer.iType==TPointerEvent::EDrag) + { + #if !defined(__WINS__) // Can't emulate touching dig when switched off under WINS + if (iTest->Digitiser()) + SetState(KStateWaitingForTest7); + else + #endif + SetState(KStateWaitingForTest8); + } + else + TestFailed(); + break; + case KStateWaitingForTest7: + if (aPointer.iType==TPointerEvent::EButton1Down || aPointer.iType==TPointerEvent::ESwitchOn) + TestFailed(); + break; + case KStateTesting7: + if (aPointer.iType!=TPointerEvent::ESwitchOn) + TestFailed(); + else + SetState(KStateTesting8); //Jump straight to end as this is only unconverted test. + //SetState(KStateWaitingForTest8); + break; + case KStateTesting8: + break; + } + } + +void CPointerWindow::TestFailed() + { + if (iState!=KStateFailed) + { + TInt oldState=iState; + iState=KStateFailed; + if (iTest->TestFailed()) + ResetTest(oldState); + } + } + +void CPointerWindow::WinKeyL(const TKeyEvent &aKey,const TTime &) + { + if (aKey.iCode==EKeyEscape) + FinishedTests(); // Simply skip this test if the Escape key is pressed + } + +void CPointerWindow::SwitchOn(const TTime &) + { + if (iState==KStateWaitingForTest7) + SetState(KStateTesting7); + else + TestFailed(); + } + +// +// CGrabWindow // +// + +CGrabWindow::CGrabWindow(CTPointerTest *aTest) : iTest(aTest) + { + } + +void CGrabWindow::SetUpLD(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc) + { + ConstructExtLD(*parent,pos,size); + Activate(); + AssignGC(aGc); + SetState(KGrabStateWaitingForDown); + } + +void CGrabWindow::Draw() + { + iGc->Clear(); + iGc->DrawRect(Size()); + TBuf<0x80> buf; + switch(iState) + { + case KGrabStateWaitingForDown: + case KGrabStateWaitingForDown2: + case KGrabStateWaitingForDown5: + buf.Copy(_L("Press the pointer inside the window")); + break; + case KGrabStateWaitingForDown3: + case KGrabStateWaitingForUp3a: + buf.Copy(_L("Press and release the pointer inside the window")); + break; + case KGrabStateWaitingForDragOut: + buf.Copy(_L("Drag the pointer outside into the outside window")); + break; + case KGrabStateWaitingForDrag2: + buf.Copy(_L("Drag the pointer outside outside both windows")); + break; + case KGrabStateWaitingForUp: + case KGrabStateWaitingForUp2b: + case KGrabStateWaitingForUp5: + buf.Copy(_L("Release the pointer")); + break; + case KGrabStateWaitingForDown4: + buf.Copy(_L("Press then release the pointer")); + break; + default:; + } + iGc->DrawText(buf,TPoint(10,20)); + } + +void CGrabWindow::PointerL(const TPointerEvent &aPointer,const TTime&) + { + switch(iState) + { + case KGrabStateWaitingForDown: + if (aPointer.iType==TPointerEvent::EButton1Down) + SetState(KGrabStateWaitingForDragOut); + break; + case KGrabStateWaitingForDragOut: + if (aPointer.iType!=TPointerEvent::EDrag) + TestFailed(); + else + { + if (!TRect(Size()).Contains(aPointer.iPosition)) + SetState(KGrabStateWaitingForUp); + } + break; + case KGrabStateWaitingForUp: + if (aPointer.iType==TPointerEvent::EDrag) + break; + if (aPointer.iType==TPointerEvent::EButton1Up) + SetState(KGrabStateWaitingForDown2); + else + TestFailed(); + break; + case KGrabStateWaitingForDown2: + if (aPointer.iType!=TPointerEvent::EButton1Down) + TestFailed(); + else + { + iTest->GrabWin2()->BaseWin()->ClaimPointerGrab(); + iTest->GrabWin2()->BaseWin()->ClaimPointerGrab(); // Call twice to check it's harmless + SetState(KGrabStateWaitingForUp2a); + } + break; + case KGrabStateWaitingForUp2a: + SetState(KGrabStateWaitingForDrag2); + break; + case KGrabStateWaitingForDrag2: + break; + case KGrabStateWaitingForUp2b: + TestFailed(); + break; + case KGrabStateWaitingForDown3: + if (aPointer.iType!=TPointerEvent::EButton1Down) + TestFailed(); + else + SetState(KGrabStateWaitingForUp3a); + break; + case KGrabStateWaitingForUp3a: + if (aPointer.iType==TPointerEvent::EButton1Up) + { + iTest->GrabWin2()->BaseWin()->ClaimPointerGrab(); + SetState(KGrabStateWaitingForUp3b); + } + break; + case KGrabStateWaitingForUp3b: + TestFailed(); + break; + case KGrabStateWaitingForDown5: + if (aPointer.iType!=TPointerEvent::EButton1Down) + TestFailed(); + else + { + iTest->GrabWin2()->BaseWin()->ClaimPointerGrab(EFalse); + SetState(KGrabStateWaitingForDrag5); + } + break; + case KGrabStateWaitingForDrag5: + if (aPointer.iType==TPointerEvent::EButton1Up) + TestFailed(); + break; + case KGrabStateWaitingForUp5: + TestFailed(); + break; + case KGrabStateWaitingForDown4: + SetState(KGrabStateWaitingForUp4); + iWin.Close(); // Close the window with the grab captured in it + break; + case KGrabStateFinished: + break; + } + } + +void CGrabWindow::ResetTest() + { + SetState(KGrabStateWaitingForDown); + } + +void CGrabWindow::Pointer2(const TPointerEvent &aPointer) + { + switch(iState) + { + case KGrabStateWaitingForDrag2: + { + if (aPointer.iType==TPointerEvent::EDrag) + { + SetState(KGrabStateWaitingForUp2b); + } + else + { + if (iTest->TestFailed()) + ResetTest(); + } + break; + } + case KGrabStateWaitingForUp2b: + if (aPointer.iType==TPointerEvent::EDrag) // Harmless + break; + if (aPointer.iType==TPointerEvent::EButton1Up) + SetState(KGrabStateWaitingForDown3); + else + TestFailed(); + break; + case KGrabStateWaitingForUp3b: + if (aPointer.iType==TPointerEvent::EButton1Up) + SetState(KGrabStateWaitingForDown5); + else + TestFailed(); + break; + case KGrabStateWaitingForUp4: + FinishedTests(); + break; + case KGrabStateWaitingForDrag5: + { + if (aPointer.iType==TPointerEvent::EDrag) + SetState(KGrabStateWaitingForUp5); + else if (iTest->TestFailed()) + ResetTest(); + break; + } + case KGrabStateWaitingForUp5: + if (aPointer.iType==TPointerEvent::EDrag) // Harmless + break; + if (aPointer.iType==TPointerEvent::EButton1Up) + SetState(KGrabStateWaitingForDown4); + else + TestFailed(); + break; + default:; + } + } + +void CGrabWindow::SetState(TInt aState) + { + iState=aState; + iWin.Invalidate(); + } + +void CGrabWindow::TestFailed() + { + if (iState!=KStateFailed) + { + iState=KStateFailed; + if (iTest->TestFailed()) + ResetTest(); + } + } + +void CGrabWindow::FinishedTests() + { + iState=KGrabStateFinished; + iTest->Request(); + } + +void CGrabWindow::WinKeyL(const TKeyEvent &aKey,const TTime &) + { + if (aKey.iCode==EKeyEscape) + FinishedTests(); // Simply skip this test if the Escape key is pressed + } + +// +// CGrabWindow2, used as part of grab tests // +// + +CGrabWindow2::CGrabWindow2(CGrabWindow *aWindow) : iGrabWindow(aWindow) + { + } + +void CGrabWindow2::Draw() + { + iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + iGc->SetBrushColor(TRgb::Gray4(2)); + iGc->DrawRect(Size()); + } + +void CGrabWindow2::PointerL(const TPointerEvent &aPointer,const TTime&) + { + iGrabWindow->Pointer2(aPointer); + } + +// +// CTPointTest // +// + +CTPointerTest::CTPointerTest() : CTestBase(_L("CTPointerTest")) + {} + +CTPointerTest::~CTPointerTest() + { + HAL::Set(HALData::EPenDisplayOn,iOldPointerState); + delete iRepeatWin; + delete iGrabWin; + delete iGrabWin2; + Client()->ResetFocus(); + } + +void CTPointerTest::ConstructL() + { + iRepeatWin=new(ELeave) CPointerWindow(this); + TSize screenSize(Client()->iScreen->SizeInPixels()); + iRepeatWin->SetUpLD(TPoint(screenSize.iWidth/8,screenSize.iHeight/8),TSize(screenSize.iWidth*3/4,screenSize.iHeight*3/4),Client()->iGroup,*Client()->iGc); + Client()->iGroup->SetCurrentWindow(iRepeatWin); + iNoDigitiser=EFalse; + TInt err=HAL::Get(HALData::EPenDisplayOn,iOldPointerState); + if (err==KErrNotSupported) + iNoDigitiser=ETrue; + else if (err==KErrNone) + err=HAL::Set(HALData::EPenDisplayOn,ETrue); + if (err==KErrNotSupported) + iNoDigitiser=(!iOldPointerState); + else + TestL(err==KErrNone); + } + +TBool CTPointerTest::TestFailed() + { + TInt ret=1; + TRAP_IGNORE(ret=doTestFailedL()); + switch(ret) + { + case 0: + return(ETrue); // Re-try test + case 1: + Request(); + break; + } + return(EFalse); + } + +TInt CTPointerTest::doTestFailedL() + { + CTDialog *dialog=new(ELeave) CTDialog(); + dialog->SetTitle(_L("Pointer repeat test failed")); + dialog->SetNumButtons(2); + dialog->SetButtonText(0,_L("Retest")); + dialog->SetButtonText(1,_L("Fail")); + dialog->ConstructLD(*Client()->iGroup,*Client()->iGc); + return dialog->Display(); + } + +CGrabWindow2 *CTPointerTest::GrabWin2() const + { + return(iGrabWin2); + } + +void CTPointerTest::StartGrabTestL() + { + iGrabWin=new(ELeave) CGrabWindow(this); + iGrabWin2=new(ELeave) CGrabWindow2(iGrabWin); +// + TSize screenSize(Client()->iScreen->SizeInPixels()); + iGrabWin2->SetUpL(TPoint(screenSize.iWidth/8,screenSize.iHeight/8),TSize(screenSize.iWidth*3/4,screenSize.iHeight*3/4),Client()->iGroup,*Client()->iGc); + Client()->iGroup->SetCurrentWindow(iGrabWin2); +// + iGrabWin->SetUpLD(TPoint(screenSize.iWidth/4,screenSize.iHeight/4),TSize(screenSize.iWidth/2,screenSize.iHeight/2),Client()->iGroup,*Client()->iGc); + Client()->iGroup->SetCurrentWindow(iGrabWin); +// + } + +#pragma warning( disable : 4065 ) //switch statement contains 'default' but no 'case' labels +TestState CTPointerTest::DoTestL() + { + switch(iState) + { + #if !defined(__WINS__) //Only unconverted test is MARM only + case 0: + LogSubTest(_L("Repeat tests"),1); + iState++; + return(EContinue); + #endif + + default: + return(EFinished); + } + } +#pragma warning( default : 4065 ) + diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tman/TMSCRMOD.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tman/TMSCRMOD.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,226 @@ +// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Screen mode changing tests +// +// + +#include +#include "W32STD.H" +#include "../tlib/testbase.h" +#include "TMAN.H" + +class CScreenModeTest; + +class CScreenModeWindow : public CTWin + { +public: + CScreenModeWindow(); + void SetUpLD(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc); + void WinKeyL(const TKeyEvent &aKey,const TTime &aTime); + void Draw(); + void ScreenDeviceChanged(); +private: + TInt iSubState; + }; + +class CScreenModeGroup : public CTWindowGroup + { +public: + ~CScreenModeGroup(); + CScreenModeGroup(CTClient *aClient); + void ConstructL(); + void ScreenDeviceChanged(); +private: + CScreenModeWindow *iWindow; + }; + +class CScreenModeTest : public CTestBase + { +public: + CScreenModeTest(); + ~CScreenModeTest(); + TestState DoTestL(); + void ConstructL(); +private: + CScreenModeGroup *iScreenModeGroup; + TSize iWinSize; + TInt iState; + }; + +GLDEF_C CTestBase *CreateScreenModeTest() + { + return(new(ELeave) CScreenModeTest()); + } + +// +// CScreenModeWindow +// + +CScreenModeWindow::CScreenModeWindow() : CTWin() + {} + +void CScreenModeWindow::WinKeyL(const TKeyEvent &aKey,const TTime &) + { + if (aKey.iCode==EKeyEscape || aKey.iCode==EKeyEnter) + { + if (iSubState==0) + { + iSubState=1; + ScreenDeviceChanged(); + Invalidate(); + } + else + CActiveScheduler::Stop(); + } + } + +void CScreenModeWindow::SetUpLD(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc) + { + ConstructExtLD(*parent,pos,size); + Activate(); + AssignGC(aGc); + } + +void CScreenModeWindow::Draw() + { + iGc->Clear(); + TSize winSize(Win()->Size()); + iGc->DrawRect(winSize); + iGc->DrawLine(TPoint(0,0),TPoint(winSize.iWidth,winSize.iHeight)); + iGc->DrawLine(TPoint(0,winSize.iHeight),TPoint(winSize.iWidth,0)); + TInt xpos=winSize.iWidth/2-100; + iGc->DrawText(iSubState==0?_L("Twips not adjusted,"): + _L("Twips adjusted,"),TPoint(xpos,20)); + iGc->DrawText(_L("Cycle through all screen modes,"),TPoint(xpos,40)); + iGc->DrawText(_L("Check the window is resized and rotated correctly,"),TPoint(xpos,60)); + iGc->DrawText(_L("Then press when finished"),TPoint(xpos,80)); +// + TSize twips=Client()->iScreen->SizeInTwips(); + TSize pixels=Client()->iScreen->SizeInPixels(); +// Horizontal line + TInt inches=twips.iWidth/KTwipsPerInch-1; + TInt lineLen=Client()->iScreen->HorizontalTwipsToPixels(inches*KTwipsPerInch); + TPoint linePos=TPoint((pixels.iWidth-lineLen)/2,pixels.iHeight/2); + iGc->DrawLine(linePos,linePos+TPoint(lineLen,0)); + TBuf<0x20> buf; + buf.Format(TRefByValue(_L("Width %d\"")),inches); + iGc->DrawText(buf,TPoint((pixels.iWidth-iFont->TextWidthInPixels(buf))/2,linePos.iY-iFont->HeightInPixels()+iFont->AscentInPixels()-2)); + TInt index; + for(index=0;index<=inches;index++) + { + TInt dx=Client()->iScreen->HorizontalTwipsToPixels(index*KTwipsPerInch); + TInt dy=Client()->iScreen->VerticalTwipsToPixels(KTwipsPerInch/(index==0 || index==inches ? 8 : 16)); + iGc->DrawLine(linePos+TPoint(dx,1), linePos+TPoint(dx,dy)); + } +// Vertical line + inches=twips.iHeight/KTwipsPerInch; + lineLen=Client()->iScreen->VerticalTwipsToPixels(inches*KTwipsPerInch); + linePos.iY=(pixels.iHeight-lineLen)/2; + iGc->DrawLine(linePos,linePos+TPoint(0,lineLen)); + buf.Format(TRefByValue(_L("Height %d\"")),inches); + iGc->DrawText(buf,TPoint(linePos.iX+10, pixels.iHeight/4)); + for(index=0;index<=inches;index++) + { + TInt dx=Client()->iScreen->HorizontalTwipsToPixels(KTwipsPerInch/(index==0 || index==inches ? 8 : 16)); + TInt dy=Client()->iScreen->VerticalTwipsToPixels(index*KTwipsPerInch); + iGc->DrawLine(linePos+TPoint(1,dy), linePos+TPoint(dx,dy)); + } + + } + +void CScreenModeWindow::ScreenDeviceChanged() + { + if (iSubState==0) + { + TPixelsAndRotation sizeAndRotation; + Client()->iScreen->GetDefaultScreenSizeAndRotation(sizeAndRotation); + Client()->iScreen->SetScreenSizeAndRotation(sizeAndRotation); + } + else + { + TPixelsTwipsAndRotation sizeAndRotation; + Client()->iScreen->GetDefaultScreenSizeAndRotation(sizeAndRotation); + Client()->iScreen->SetScreenSizeAndRotation(sizeAndRotation); + } + SetSize(Client()->iScreen->SizeInPixels()); + } + +// +// CScreenModeGroup +// + +CScreenModeGroup::~CScreenModeGroup() + { + GroupWin()->EnableReceiptOfFocus(EFalse); + ClearCurrentWindow(); + Client()->iGroup->SetCurrentWindow(NULL); + CTWin::Delete(iWindow); + } + +CScreenModeGroup::CScreenModeGroup(CTClient *aClient) : CTWindowGroup(aClient) + {} + +void CScreenModeGroup::ConstructL() + { + CTWindowGroup::ConstructL(); + iWindow=new(ELeave) CScreenModeWindow; + iWindow->SetUpLD(TPoint(0,0),Client()->iScreen->SizeInPixels(),this,*Client()->iGc); + SetCurrentWindow(iWindow); + GroupWin()->EnableScreenChangeEvents(); + GroupWin()->SetOrdinalPosition(0); + } + +void CScreenModeGroup::ScreenDeviceChanged() + { + iWindow->ScreenDeviceChanged(); + } + +// +// CScreenModeTest +// + +CScreenModeTest::CScreenModeTest() : CTestBase(_L("Screen mode")) + {} + +CScreenModeTest::~CScreenModeTest() + { + Client()->iGroup->GroupWin()->EnableScreenChangeEvents(); + Client()->iScreen->SetScreenMode(0); + delete iScreenModeGroup; + } + +void CScreenModeTest::ConstructL() + { + Client()->iGroup->GroupWin()->SetOrdinalPosition(0); + Client()->iGroup->GroupWin()->DisableScreenChangeEvents(); +// + iScreenModeGroup=new(ELeave) CScreenModeGroup(Client()); + iScreenModeGroup->ConstructL(); + } + +TestState CScreenModeTest::DoTestL() + { + switch(iState) + { + case 0: + LogSubTest(_L("Screen mode 1"),1); + CActiveScheduler::Start(); + iState++; + break; + default: + return(EFinished); + } + return(ENext); + } + diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tman/TMTScrMd.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tman/TMTScrMd.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,463 @@ +// Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Screen mode changing tests +// +// + +#include +#include +#include "W32STD.H" +#include "../tlib/testbase.h" +#include "TMAN.H" + +class CTimeWindow; + +class CQBlankWindow : public CBlankWindow + { +public: + static TInt iInitialColor; +public: + //Virtual function from CTBaseWin + void InitWin(); +public: + static TSize iSize; + TSglQueLink iLink; + }; + +class CFixScreenModeGroup : public CTWindowGroup + { +public: + static TInt iNoClientWins; +public: + ~CFixScreenModeGroup(); + CFixScreenModeGroup(CTClient *aClient); + void ConstructL(); +public: + TSglQueLink iLink; +private: + TSglQue iWindows; + }; + +class CFlipClient : public CTClient + { +public: + void ConstructL(); +private: + }; + +class CScreenModeTimes : public CTestBase + { +public: + CScreenModeTimes(); + ~CScreenModeTimes(); + TestState DoTestL(); + void ConstructL(); + void DoTimings(); +private: + void CreateGroupL(CTClient* aClient,TSglQue& aQue); + void DeleteGroups(TSglQue& aQue); + void BringToFront(TSglQue& aQue); +private: + TScreenModeEnforcement iEnforcementMode; + CInfoDialog* iDialogue; + CTimeWindow* iInfoWindow; + CFlipClient* iFlipClient; + TSglQue iNormalGroupQue; + TSglQue iFlipGroupQue; + TInt iNoGroupWins; + TInt iState; + }; + +class CTimeWindow : public CTTitledWindow + { +public: + void Construct(CTestBase* aTest); + void SetNumWindows(TInt aGroup,TInt aWin); + void SetTime1(TTimeIntervalMicroSeconds& aTime); + void SetTime2(TTimeIntervalMicroSeconds& aTime); + void DoDraw(); + //virtual function from CTWinBase overridden by CTBaseWin + void WinKeyL(const TKeyEvent &aKey,const TTime &aTime); + //virtual functions from CTBaseWin + void SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc); + void PointerL(const TPointerEvent &aPointer,const TTime &aTime); + //virtual function from CTBaseWin overridden by CTTitledWindow + void Draw(); +private: + inline CScreenModeTimes* Test() {return STATIC_CAST(CScreenModeTimes*,iTest);} + void UpdateString1(); + void UpdateString2(); + void UpdateString3(); +private: + CTestBase* iTest; + TInt iNumGroups; + TInt iNumWins; + TTimeIntervalMicroSeconds iTime1; + TTimeIntervalMicroSeconds iTime2; + TBuf<32> iString1; + TBuf<32> iString2; + TBuf<32> iString3; + TBuf<32> iString4; + TRect iRect1; + TRect iRect2; + TRect iRect3; + TRect iRect4; + TBool iPressed; + TBool iExit; + }; + + +TSize CQBlankWindow::iSize; +TInt CQBlankWindow::iInitialColor; +TInt CFixScreenModeGroup::iNoClientWins=0; + + +GLDEF_C CTestBase *CreateScreenModeTimes() + { + return(new(ELeave) CScreenModeTimes()); + } + + +// +// CFlipClient +// + +void CFlipClient::ConstructL() + { + CTClient::ConstructL(); + TPixelsAndRotation sizeAndRotation; + iScreen->GetScreenModeSizeAndRotation(1,sizeAndRotation); + iScreen->SetScreenSizeAndRotation(sizeAndRotation); + } + + +// +// CTimeWindow +// + +void CTimeWindow::Construct(CTestBase* aTest) + { + _LIT(Title,"StatusWindow"); + _LIT(String4,"Click here to finish"); + const TInt fontHeight=iFont->HeightInPixels(); + iTest=aTest; + TWindowTitle title(Title); + SetTitle(title); + TInt yy=iTitleHeight+fontHeight+7; + iRect1.SetRect(3,iTitleHeight+5,iSize.iWidth-1,yy); + yy+=fontHeight/2; + TInt yy1=yy+fontHeight+2; + iRect2.SetRect(3,yy+3,iSize.iWidth-1,yy1); + TInt yy2=yy1+iFont->HeightInPixels()+2; + iRect3.SetRect(3,yy1+3,iSize.iWidth-1,yy2); + yy2+=fontHeight/2; + iRect4.SetRect(3,yy2+3,iSize.iWidth-1,yy2+iFont->HeightInPixels()+2); + // + iString4.Copy(String4); + iExit=EFalse; + } + +void CTimeWindow::SetUpL(TPoint aPos,TSize aSize,CTWinBase *aParent,CWindowGc &aGc) + { + CTTitledWindow::SetUpL(aPos,aSize,aParent,aGc); + } + +void CTimeWindow::WinKeyL(const TKeyEvent &aKey,const TTime&) + { + switch(aKey.iCode) + { + case EKeyEscape: + iTest->Request(); + break; + default:; + } + } + +void CTimeWindow::PointerL(const TPointerEvent &aPointer,const TTime &aTime) + { + if (iRect2.Contains(aPointer.iPosition) || iRect3.Contains(aPointer.iPosition)) + { + if (aPointer.iType==TPointerEvent::EButton1Down) + iPressed=ETrue; + } + else if (iRect4.Contains(aPointer.iPosition)) + iExit=ETrue; + else + CTTitledWindow::PointerL(aPointer,aTime); + if ((iExit||iPressed) && aPointer.iType==TPointerEvent::EButton1Up) + { + if (iExit) + iTest->Request(); + else + { + Test()->DoTimings(); + DoDraw(); + } + } + } + +void CTimeWindow::Draw() + { + CTTitledWindow::Draw(); + TInt ascent=iFont->AscentInPixels()+1; + iGc->DrawText(iString1,iRect1,ascent,CGraphicsContext::ELeft); + iGc->DrawText(iString2,iRect2,ascent,CGraphicsContext::ELeft); + iGc->DrawText(iString3,iRect3,ascent,CGraphicsContext::ELeft); + iGc->DrawText(iString4,iRect4,ascent,CGraphicsContext::ELeft); + } + +void CTimeWindow::DoDraw() + { + iGc->Activate(iWin); + iGc->UseFont((CFont *)iFont); + Draw(); + iGc->Deactivate(); + } + +void CTimeWindow::SetNumWindows(TInt aGroups,TInt aWins) + { + iNumGroups=aGroups; + iNumWins=aWins; + UpdateString1(); + } + +void CTimeWindow::UpdateString1() + { + _LIT(NumberWin,"Groups (2x)%d, Windows %d"); + iString1.Format(NumberWin,iNumGroups,iNumWins); + } + +void CTimeWindow::SetTime1(TTimeIntervalMicroSeconds& aTime) + { + iTime1=aTime; + UpdateString2(); + } + +void CTimeWindow::SetTime2(TTimeIntervalMicroSeconds& aTime) + { + iTime2=aTime; + UpdateString3(); + } + +_LIT(TimeFormat,"Time%d = %d.%04dsecs"); + +void CTimeWindow::UpdateString2() + { + TInt time = I64LOW(iTime1.Int64()); + iString2.Format(TimeFormat,1,time/1000000,(time%1000000)/100); + } + +void CTimeWindow::UpdateString3() + { + TInt time = I64LOW(iTime2.Int64()); + iString3.Format(TimeFormat,2,time/1000000,(time%1000000)/100); + } + + +// +// CQBlankWindow +// + +void CQBlankWindow::InitWin() + { + SetColor(TRgb::Gray4(iInitialColor)); + iWin.SetSize(iSize); + } + + +// +// CFixScreenModeGroup +// + +CFixScreenModeGroup::~CFixScreenModeGroup() + { + GroupWin()->EnableReceiptOfFocus(EFalse); + ClearCurrentWindow(); + CQBlankWindow* win; + while (!iWindows.IsEmpty()) + { + win=iWindows.First(); + iWindows.Remove(*win); + delete win; + } + } + +CFixScreenModeGroup::CFixScreenModeGroup(CTClient *aClient) : CTWindowGroup(aClient), iWindows(_FOFF(CQBlankWindow,iLink)) + {} + +void CFixScreenModeGroup::ConstructL() + { + CTWindowGroup::ConstructL(); + CQBlankWindow* win; + TInt ii; + for(ii=0;iiConstructL(*this); + win->Activate(); + win->AssignGC(*iClient->iGc); + iWindows.AddLast(*win); + CleanupStack::Pop(win); + Client()->Flush(); + } + SetCurrentWindow(iWindows.First()); + } + +/*void CFixScreenModeGroup::ScreenDeviceChanged() + { + iWindow->ScreenDeviceChanged(); + }*/ + + +// +// CScreenModeTimes +// + +_LIT(TestName,"Screen Mode Times"); +CScreenModeTimes::CScreenModeTimes() : CTestBase(TestName) + ,iNormalGroupQue(_FOFF(CFixScreenModeGroup,iLink)),iFlipGroupQue(_FOFF(CFixScreenModeGroup,iLink)) + {} + +CScreenModeTimes::~CScreenModeTimes() + { + Client()->iGroup->GroupWin()->EnableScreenChangeEvents(); + Client()->iScreen->SetScreenMode(0); + DeleteGroups(iNormalGroupQue); + DeleteGroups(iFlipGroupQue); + Client()->iGroup->SetCurrentWindow(NULL); + delete iFlipClient; + delete iInfoWindow; + if (iEnforcementMode==ESizeEnforcementNone) + Client()->iScreen->SetScreenModeEnforcement(ESizeEnforcementNone); + } + +void CScreenModeTimes::ConstructL() + { + iEnforcementMode=Client()->iScreen->ScreenModeEnforcement(); + if (iEnforcementMode==ESizeEnforcementNone) + Client()->iScreen->SetScreenModeEnforcement(ESizeEnforcementPixelsAndRotation); + iDialogue=new(ELeave) CInfoDialog(Client()->iGroup,Client()->iGc); + iDialogue->ConstructLD(); + iFlipClient=new(ELeave) CFlipClient(); + iFlipClient->ConstructL(); + Client()->iGroup->GroupWin()->DisableScreenChangeEvents(); + iNoGroupWins=12; //20; + CFixScreenModeGroup::iNoClientWins=20; //30; + TSize screenSize=Client()->iScreen->SizeInPixels(); + CQBlankWindow::iSize.iWidth=Max(screenSize.iHeight,screenSize.iWidth); + CQBlankWindow::iSize.iHeight=CQBlankWindow::iSize.iWidth; + TInt ii; + for(ii=0;iiiGroup->GroupWin()->SetOrdinalPosition(0); + iInfoWindow=new(ELeave) CTimeWindow(); + iInfoWindow->SetUpL(TPoint(Max(Min(415,screenSize.iWidth-210),0),Min(50,screenSize.iHeight-180)),TSize(210,180),Client()->iGroup,*Client()->iGc); + Client()->iGroup->SetCurrentWindow(iInfoWindow); + iInfoWindow->Construct(this); + iInfoWindow->WinTreeNode()->SetOrdinalPosition(1); + iInfoWindow->SetNumWindows(iNoGroupWins,CFixScreenModeGroup::iNoClientWins); + + Client()->iGroup->GroupWin()->DisableScreenChangeEvents(); + Client()->iWs.SetAutoFlush(ETrue); + iFlipClient->iWs.SetAutoFlush(ETrue); + Client()->iWs.SetPointerCursorMode(EPointerCursorNone); + } + +void CScreenModeTimes::CreateGroupL(CTClient *aClient,TSglQue& aQue) + { + CFixScreenModeGroup* group; + group=new(ELeave) CFixScreenModeGroup(aClient); + CleanupStack::PushL(group); + group->ConstructL(); + aQue.AddLast(*group); + CleanupStack::Pop(group); + } + +void CScreenModeTimes::DeleteGroups(TSglQue& aQue) + { + CFixScreenModeGroup* group; + while (!aQue.IsEmpty()) + { + group=aQue.First(); + aQue.Remove(*group); + delete group; + } + } + +void CScreenModeTimes::BringToFront(TSglQue& aQue) + { + TSglQueIter iter(aQue); + CFixScreenModeGroup* group=iter++; + group->GroupWin()->SetOrdinalPosition(0); + while ((group=iter++)!=NULL) + group->GroupWin()->SetOrdinalPosition(1); + } + +void CScreenModeTimes::DoTimings() + { + //Timings 1 SCRDEV, DWsScreenDevice::CommandL, around call to SetScreenMode + //Timings 2 GROUPWIN, CWsWindowGroup::SetScreenDeviceValidStates, around main body of function including calls to old way + //Timings 3 CLIWIN, CWsTopClientWindow::SetScreenDeviceValidState, around call to ResetHiddenFlagAndAdjustRegions + //Timings 3 GROUPWIN, CWsWindowGroup::SetScreenDeviceValidStates, around main body of function excluding calls to old way + //Timings 4&5 CLIWIN, CWsClientWindow::ResetHiddenFlagAndAdjustRegions, going invisible and becomming visible sections + Client()->iGroup->GroupWin()->SetOrdinalPosition(-2); + Client()->Flush(); + TTime startTime; + TTime middleTime; + TTime endTime; +__PROFILE_START(0); + startTime.HomeTime(); + BringToFront(iNormalGroupQue); + Client()->iScreen->SetScreenMode(1); + middleTime.HomeTime(); + BringToFront(iFlipGroupQue); + Client()->iScreen->SetScreenMode(0); + endTime.HomeTime(); +__PROFILE_END(0); +#if defined(__PROFILING__) + TProfile profile; + RDebug::ProfileResult(&profile,3,1); + if (profile.iCount>0) + iDialogue->TimerResults(0); +#endif + TTimeIntervalMicroSeconds time=middleTime.MicroSecondsFrom(startTime); + iInfoWindow->SetTime1(time); + time=endTime.MicroSecondsFrom(middleTime); + iInfoWindow->SetTime2(time); + Client()->iGroup->GroupWin()->SetOrdinalPosition(0); +#if defined(__PROFILING__) + if (profile.iCount>0) + iDialogue->Display(); +#endif + } + +TestState CScreenModeTimes::DoTestL() + { + switch(iState) + { + case 0: + LogSubTest(_L("Time ScreenMode Changes"),1); + DoTimings(); + iState++; + return EContinue; + default: + return EFinished; + } + } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tman/TPASSWRD.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tman/TPASSWRD.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,429 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Test Wserv password features +// +// + +#include +#include +#include "W32STD.H" +#include "../tlib/testbase.h" +#include "TMAN.H" + +//#define LOG_TESTS + +#define THE_PASSWORD _L("pass") + +enum TPasswordState + { + ENotStarted, + EWaitForSwitchOff, + EWaitForEnter, + EWaitForA, + EWaitForSwitchOff2, + EWaitForSwitchOff3, + EWaitForSwitchOff4, + EWaitForSwitchOff5, + EWaitForEnter2, + EPasswordFinished, + }; + +class CPasswordTest; + +class CPasswordWindowGroup : public CTWindowGroup + { +public: + CPasswordWindowGroup(CTClient *aClient, CPasswordTest *aTest); + void ConstructL(); + void PasswordL(const TTime &aTime); + void KeyL(const TKeyEvent &aKey,const TTime &aTime); + void SwitchOn(const TTime &aTime); +private: + CPasswordTest *iTest; + }; + +class CPasswordWindowGroup2 : public CTWindowGroup + { +public: + CPasswordWindowGroup2(CTClient *aClient, CPasswordTest *aTest); + void ConstructL(); + void KeyL(const TKeyEvent &aKey,const TTime &aTime); +private: + CPasswordTest *iTest; + }; + +class CPasswordWindow : public CTWin + { +public: + CPasswordWindow(CPasswordTest *aTest); + void Draw(); +private: + CPasswordTest *iTest; + }; + +class CPasswordTest : public CTestBase + { +public: + CPasswordTest(); + ~CPasswordTest(); + TestState DoTestL(); + void ConstructL(); + void Fail(TInt aWhere); + void EnterKeyPressed(TPasswordState aNewState); + void SwitchOn(); + void TestComplete(TPasswordState aNewState); + void PasswordMsgReceivedL(); + TPasswordState PasswordState() const; + void SetPassState(TPasswordState aPassState); + void StartMainPasswordTestL(); + void StartOnceADayPasswordTestL(); + void TurnOffAndOn(); +private: + CPasswordWindowGroup *iGroup; + CPasswordWindowGroup2 *iGroup2; + CPasswordWindow *iPassWin; + CTBlankWindow *iBlankWin; + TSize iWinSize; + TInt iState; + TPasswordState iPassState; + TBool iPasswordTestFailed; + }; + +GLDEF_C CTestBase *CreatePasswordTest() + { + return(new(ELeave) CPasswordTest()); + } + +// + +CPasswordWindowGroup::CPasswordWindowGroup(CTClient *aClient, CPasswordTest *aTest) : + CTWindowGroup(aClient), + iTest(aTest) + { + __DECLARE_NAME(_S("CPasswordWindowGroup")); + } + +void CPasswordWindowGroup::ConstructL() + { + CTWindowGroup::ConstructL(); + GroupWin()->EnableOnEvents(); + } + +void CPasswordWindowGroup::SwitchOn(const TTime &) + { + iTest->SwitchOn(); + } + +void CPasswordWindowGroup::KeyL(const TKeyEvent &aKey,const TTime &) + { + if (aKey.iCode==EKeyEscape) + iTest->TestComplete(EPasswordFinished); + switch(iTest->PasswordState()) + { + case EWaitForEnter: + if (aKey.iCode==EKeyEnter) + iTest->EnterKeyPressed(EWaitForA); + break; + case EWaitForEnter2: + if (aKey.iCode==EKeyEnter) + iTest->TestComplete(EPasswordFinished); + break; + default:; + } + } + +void CPasswordWindowGroup::PasswordL(const TTime &) + { + iTest->TestL(iGroupWin.OrdinalPosition()==0); + iTest->PasswordMsgReceivedL(); + } + +// + +CPasswordWindowGroup2::CPasswordWindowGroup2(CTClient *aClient, CPasswordTest *aTest) : + CTWindowGroup(aClient), + iTest(aTest) + { + __DECLARE_NAME(_S("CPasswordWindowGroup")); + } + +void CPasswordWindowGroup2::ConstructL() + { + CTWindowGroup::ConstructL(); + iGroupWin.CaptureKey('a',0,0); + } + +void CPasswordWindowGroup2::KeyL(const TKeyEvent &aKey,const TTime &) + { + if (iTest->PasswordState()!=EPasswordFinished) + { + if (iTest->PasswordState()!=EWaitForA) + { + #if defined(LOG_TESTS) + TLogMessageText buf; + _LIT(KBadKey,"Bad Key Code=%d(%c) Scan=%d(%c) Rep=%d"); + buf.AppendFormat(KBadKey,aKey.iCode,aKey.iCode,aKey.iScanCode,aKey.iScanCode,aKey.iRepeats); + Client()->LogMessage(buf); + #endif + if (aKey.iRepeats==0) + iTest->Fail(1); + } + else + { + if (aKey.iCode!='a') + iTest->Fail(2); + iTest->TestComplete(EWaitForSwitchOff2); + } + } + } + +// + +CPasswordWindow::CPasswordWindow(CPasswordTest *aTest) : + iTest(aTest) + { + } + +void CPasswordWindow::Draw() + { + iGc->Clear(); + switch(iTest->PasswordState()) + { + case EWaitForSwitchOff: + iGc->DrawText(_L("Please wait, turning off & on [1]"),TPoint(10,20)); + break; + case EWaitForSwitchOff2: + iGc->DrawText(_L("Please wait, turning off & on [2]"),TPoint(10,20)); + break; + case EWaitForSwitchOff3: + iGc->DrawText(_L("Please wait, turning off & on [3]"),TPoint(10,20)); + break; + case EWaitForSwitchOff4: + iGc->DrawText(_L("Please wait, turning off & on [4]"),TPoint(10,20)); + break; + case EWaitForSwitchOff5: + iGc->DrawText(_L("Please wait, turning off & on [5]"),TPoint(10,20)); + break; + case EWaitForEnter: + iGc->DrawText(_L("Try the key of death, then..."),TPoint(10,20)); + iGc->DrawText(_L("Press 'a', then..."),TPoint(10,40)); + iGc->DrawText(_L("Press Enter"),TPoint(10,60)); + break; + case EWaitForEnter2: + iGc->DrawText(_L("Press Enter"),TPoint(10,20)); + break; + case EWaitForA: + iGc->DrawText(_L("Press 'a'"),TPoint(10,20)); + case EPasswordFinished: + break; + default:; + } + } + +// + +CPasswordTest::CPasswordTest() : CTestBase(_L("Password")) + {} + +CPasswordTest::~CPasswordTest() + { + delete iBlankWin; + delete iPassWin; + delete iGroup; + delete iGroup2; + } + +#if defined(LOG_TESTS) +void CPasswordTest::Fail(TInt aWhere) +#else +void CPasswordTest::Fail(TInt /*aWhere*/) +#endif + { +#if defined(LOG_TESTS) + TLogMessageText buf; + _LIT(KFailed,"Password Failed at %d (%d,%d)"); + buf.AppendFormat(KFailed,aWhere,iState,iPassState); + Client()->LogMessage(buf); +#endif + iPasswordTestFailed=ETrue; + Request(); + } + +void CPasswordTest::TurnOffAndOn() + { +/*#if defined(LOG_TESTS) + TLogMessageText buf; + _LIT(KSettingTime,"Setting Off Timer"); + buf.Append(KSettingTime); + Client()->LogMessage(buf); +#endif*/ + RTimer timer; + timer.CreateLocal(); + TTime time; + time.HomeTime(); + time+=TTimeIntervalSeconds(7); // For some reason the O/S won't switch off for less than 6 seconds + TRequestStatus status; + timer.At(status,time); + UserHal::SwitchOff(); + User::WaitForRequest(status); +#if !defined(__WINS__) + TRawEvent event; + event.Set(TRawEvent::ESwitchOn); + UserSvr::AddEvent(event); +#endif +/*#if defined(LOG_TESTS) + TLogMessageText buf; + _LIT(KTimerOff,"Timer Gone Off (P=%d,S=%d)"); + buf.AppendFormat(KTimerOff,iState,iPassState); + Client()->LogMessage(buf); +#endif*/ + } + +TPasswordState CPasswordTest::PasswordState() const + { + return(iPassState); + } + +void CPasswordTest::SetPassState(TPasswordState aPassState) + { + iPassState=aPassState; + iPassWin->DrawNow(); + Client()->iWs.Flush(); +/*#if defined(LOG_TESTS) + TLogMessageText buf; + _LIT(PassTestState,"Password Test(%d), State=%d"); + buf.AppendFormat(PassTestState,iState,aPassState); + Client()->LogMessage(buf); +#endif*/ + switch(aPassState) + { + case EWaitForSwitchOff: + case EWaitForSwitchOff2: + case EWaitForSwitchOff3: + case EWaitForSwitchOff4: + case EWaitForSwitchOff5: + TurnOffAndOn(); + break; + default:; + } + } + +void CPasswordTest::SwitchOn() + { +/*#if defined(LOG_TESTS) + TLogMessageText buf; + _LIT(KTimerOff,"Switch On (P=%d,S=%d)"); + buf.AppendFormat(KTimerOff,iState,iPassState); + Client()->LogMessage(buf); +#endif*/ + switch (iPassState) + { + case EWaitForSwitchOff: + SetPassState(EWaitForEnter); + break; + case EWaitForSwitchOff2: + SetPassState(EWaitForSwitchOff3); + break; + case EWaitForSwitchOff3: + SetPassState(EWaitForSwitchOff4); + break; + case EWaitForSwitchOff4: + { + SetPassState(EWaitForSwitchOff5); + TTime time; + time.HomeTime(); + time+=TTimeIntervalHours(24); + User::SetHomeTime(time); + } + break; + case EWaitForSwitchOff5: + SetPassState(EWaitForEnter2); + break; + default:; + } + } + +void CPasswordTest::PasswordMsgReceivedL() + { + TestL(iPassWin->BaseWin()->OrdinalPosition()==0); + if (iPassState==EWaitForSwitchOff3 || iPassState==EWaitForSwitchOff4) + Fail(3); + } + +void CPasswordTest::EnterKeyPressed(TPasswordState aNewState) + { + iPassWin->BaseWin()->SetOrdinalPosition(-1); + SetPassState(aNewState); + Client()->iWs.PasswordEntered(); + } + +void CPasswordTest::TestComplete(TPasswordState aNewState) + { + Request(); + SetPassState(aNewState); + iPassState=aNewState; + } + +void CPasswordTest::ConstructL() + { + iGroup2=new(ELeave) CPasswordWindowGroup2(Client(),this); + iGroup2->ConstructL(); + iGroup=new(ELeave) CPasswordWindowGroup(Client(),this); + iGroup->ConstructL(); + iPassWin=new(ELeave) CPasswordWindow(this); + iPassWin->ConstructL(*iGroup); + iPassWin->AssignGC(*Client()->iGc); + iPassWin->Activate(); + iBlankWin=new(ELeave) CTBlankWindow(); + iBlankWin->ConstructL(*iGroup); + iBlankWin->SetVisible(EFalse); + iBlankWin->Activate(); + iState=ENotStarted; + } + +void CPasswordTest::StartMainPasswordTestL() + { + if (iPassWin->BaseWin()->PasswordWindow(EPasswordAlways)!=KErrNone) + { + DisplayDialog(_L("Can't do password tests"),_L("Password window"),_L("already exists"), Client()->iGroup->GroupWin()); + AbortL(); + } + SetPassState(EWaitForSwitchOff); + } + +void CPasswordTest::StartOnceADayPasswordTestL() + { + TestL(iPassWin->BaseWin()->PasswordWindow(EPasswordOnceADay)==KErrNone); + } + +TestState CPasswordTest::DoTestL() + { + if (iPasswordTestFailed) + TestL(ETrue); + switch(iState) + { + case 0: + LogSubTest(_L("Password 1"),1); + StartMainPasswordTestL(); + iState++; + return(EContinue); + case 1: + LogSubTest(_L("Password 2"),2); + StartOnceADayPasswordTestL(); + iState++; + return(EContinue); + default: + return(EFinished); + } + } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tman/TTEXT.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tman/TTEXT.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,265 @@ +// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Print some text, to be checked by eye +// +// + +#include +#include +#include "W32STD.H" +#include "../tlib/testbase.h" +#include "TMAN.H" + +class TTextTest; + +enum {EDrawModeFonts,EDrawModeCharJust,EDrawModeWordJust}; + +_LIT(KTestFontTypefaceName,"DejaVu Sans Condensed"); + +class CTextWindow : public CTWin + { +public: + CTextWindow(TTextTest *aTest); + void SetUpLD(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc); + void Draw(); + void WinKeyL(const TKeyEvent &aKey,const TTime &aTime); + void ResetPrintLine(); + void Print(const CFont *aFont, const TDesC &aText); + void PrintLine(const CFont *aFont, const TDesC &aText); + void PrintDivider(); + void PrintStylesL(const TDesC &aText, TFontSpec &aFontSpec, const TFontStyle &aFontStyle); + void DrawCharJustified(const TDesC &aText); + void DrawWordJustified(const TDesC &aText); + TBool NextPage(); + void SetDrawMode(TInt aMode); +private: + TInt iDrawMode; + TTextTest *iTest; + CFbsFont *iTmpFont; + TInt iNumTypeFaces; + TInt iTypeFaceIndex; + TInt iXStartPos; + TInt iYpos; + TInt iXpos; + }; + +class TTextTest : public CTestBase + { +public: + TTextTest(); + ~TTextTest(); + TestState DoTestL(); + void ConstructL(); +private: + CTextWindow *iWin; + TSize iWinSize; + TInt iState; + }; + +GLDEF_C CTestBase *CreateTextTest() + { + return(new(ELeave) TTextTest()); + } + +CTextWindow::CTextWindow(TTextTest *aTest) : CTWin(), iDrawMode(EDrawModeWordJust), iTest(aTest) + {} + +void CTextWindow::SetUpLD(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc) + { + ConstructExtLD(*parent,pos,size); + Activate(); + AssignGC(aGc); + iNumTypeFaces=Client()->iScreen->NumTypefaces(); + } + +void CTextWindow::ResetPrintLine() + { + iXpos=iXStartPos=5; + iYpos=2; + } + +void CTextWindow::PrintDivider() + { + iGc->DrawLine(TPoint(0,iYpos+5),TPoint(Size().iWidth,iYpos+5)); + iYpos+=10; + } + +void CTextWindow::Print(const CFont *aFont, const TDesC &aText) + { + iGc->DrawText(aText, TPoint(iXpos, iYpos+aFont->AscentInPixels())); + iXpos+=aFont->TextWidthInPixels(aText); + } + +void CTextWindow::PrintLine(const CFont *aFont, const TDesC &aText) + { + iGc->DrawText(aText, TPoint(iXpos, iYpos+aFont->AscentInPixels())); + iXpos=iXStartPos; + iYpos+=aFont->HeightInPixels()+2; + } + +TBool CTextWindow::NextPage() + { + if (iTypeFaceIndex==(iNumTypeFaces-1)) + return(ETrue); + ++iTypeFaceIndex; + return(EFalse); + } + +void CTextWindow::PrintStylesL(const TDesC &aText, TFontSpec &aFontSpec, const TFontStyle &aFontStyle) + { + aFontSpec.iFontStyle=aFontStyle; + User::LeaveIfError(Client()->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)iTmpFont, aFontSpec)); + iGc->UseFont(iTmpFont); + Print(iTmpFont,aText); + iGc->SetUnderlineStyle(EUnderlineOn); + Print(iTmpFont,_L("Underline, ")); + iGc->SetStrikethroughStyle(EStrikethroughOn); + Print(iTmpFont,_L("Strikethrough/underline, ")); + iGc->SetUnderlineStyle(EUnderlineOff); + PrintLine(iTmpFont,_L("Strikethrough")); + iGc->SetStrikethroughStyle(EStrikethroughOff); + Client()->iScreen->ReleaseFont(iTmpFont); + iTmpFont=NULL; + } + +void CTextWindow::DrawCharJustified(const TDesC &aText) + { + iGc->SetCharJustification(Size().iWidth-10-iTmpFont->TextWidthInPixels(aText),aText.Length()-1); + PrintLine(iTmpFont, aText); + } + +void CTextWindow::DrawWordJustified(const TDesC &aText) + { + TInt count=0; + for(TInt index=0;indexSetWordJustification(Size().iWidth-10-iTmpFont->TextWidthInPixels(aText),count); + PrintLine(iTmpFont, aText); + } + +void CTextWindow::Draw() +//This function is virtual and so cannot have an 'L' at the end of it's name + { + iGc->Clear(); + ResetPrintLine(); + switch(iDrawMode) + { + case EDrawModeWordJust: + User::LeaveIfError(Client()->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)iTmpFont, TFontSpec(KTestFontTypefaceName,200))); + iGc->UseFont(iTmpFont); + DrawWordJustified(_L("Hello World")); + DrawWordJustified(_L("One Two Three Four Five Six Seven")); + DrawWordJustified(_L("AA B CC D")); + DrawWordJustified(_L("ONEWORD")); + iGc->DiscardFont(); + Client()->iScreen->ReleaseFont(iTmpFont); + iTmpFont=NULL; + break; + case EDrawModeCharJust: + User::LeaveIfError(Client()->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)iTmpFont, TFontSpec(KTestFontTypefaceName,200))); + iGc->UseFont(iTmpFont); + DrawCharJustified(_L("Hello World")); + DrawCharJustified(_L("One Two Three Four Five Six Seven")); + DrawCharJustified(_L("AA B CC D")); + DrawCharJustified(_L("ONEWORD")); + iGc->DiscardFont(); + Client()->iScreen->ReleaseFont(iTmpFont); + iTmpFont=NULL; + break; + case EDrawModeFonts: + { + TTypefaceSupport typefaceSupport; + Client()->iScreen->TypefaceSupport(typefaceSupport,iTypeFaceIndex); + TBuf<0x40> title; + TBuf16 tmpBuf; + tmpBuf.Copy(typefaceSupport.iTypeface.iName); + title.Append(tmpBuf); + title.AppendFormat(TRefByValue(_L(", Heights (Min=%d, Max=%d, Num=%d)")),typefaceSupport.iMinHeightInTwips,typefaceSupport.iMaxHeightInTwips,typefaceSupport.iNumHeights); + PrintLine(iFont,title); + PrintDivider(); + for (TInt tfHeight=0;tfHeightiScreen->FontHeightInTwips(iTypeFaceIndex,tfHeight)); + PrintStylesL(_L("Normal, "), fspec, TFontStyle()); + PrintStylesL(_L("Bold, "), fspec, TFontStyle(EPostureUpright,EStrokeWeightBold,EPrintPosNormal)); + PrintStylesL(_L("Italic, "), fspec, TFontStyle(EPostureItalic,EStrokeWeightNormal,EPrintPosNormal)); + PrintStylesL(_L("Bold/italic, "), fspec, TFontStyle(EPostureItalic,EStrokeWeightBold,EPrintPosNormal)); + if (iYpos>Size().iHeight) + break; + } + } + break; + } + } + +void CTextWindow::WinKeyL(const TKeyEvent &aKey,const TTime &) + { + if (iDrawMode!=EDrawModeFonts || (aKey.iCode==EKeyEscape || NextPage())) + CActiveScheduler::Stop(); + else + iWin.Invalidate(); + } + +void CTextWindow::SetDrawMode(TInt aDrawMode) + { + iDrawMode=aDrawMode; + iWin.Invalidate(); + } + +TTextTest::TTextTest() : CTestBase(_L("Text")) + {} + +TTextTest::~TTextTest() + { + CTWin::Delete(iWin); + } + +void TTextTest::ConstructL() + { + CTextWindow *win=new(ELeave) CTextWindow(this); + win->SetUpLD(TPoint(0,0),Client()->iScreen->SizeInPixels(),Client()->iGroup,*Client()->iGc); + iWin=win; + Client()->iGroup->SetCurrentWindow(iWin); + Client()->iGroup->GroupWin()->SetOrdinalPosition(0); + } + +TestState TTextTest::DoTestL() + { + switch(iState) + { + case 0: + LogSubTest(_L("SetWordJustification"),1); + iWin->SetDrawMode(EDrawModeWordJust); + CActiveScheduler::Start(); + iState++; + break; + case 1: + LogSubTest(_L("SetCharJustification"),2); + iWin->SetDrawMode(EDrawModeCharJust); + CActiveScheduler::Start(); + iState++; + break; + case 2: + LogSubTest(_L("Text 1"),3); + iWin->SetDrawMode(EDrawModeFonts); + CActiveScheduler::Start(); + iState++; + break; + default: + return(EFinished); + } + return(ENext); + } + diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tredir/proxy.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tredir/proxy.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,35 @@ +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include +#include "redirector.h" + + +LOCAL_C const TImplementationProxy KImplementationTable[] = + { + IMPLEMENTATION_PROXY_ENTRY(CWsGcRedirector::EImplUid, CWsGcRedirector::NewL) + }; + +EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) + { + aTableCount = sizeof(KImplementationTable)/sizeof(TImplementationProxy); + return KImplementationTable; + } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tredir/redirector.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tredir/redirector.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,374 @@ +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include "redirector.h" +#include +#include +#include +#include +#ifdef __WINS__ +#include "../debuglog/osbwin.h" +#endif + +const TInt KDefaultScreen = 0; + +const TUint8 KCmdQuery = 0; +const TUint8 KCmdSetGcFront = 1; +const TUint8 KCmdSetGcBack = 2; +const TUint8 KCmdResetGcFront = 3; +const TUint8 KCmdResetGcBack = 4; +const TUint8 KCmdSetBackObject = 5; +const TUint8 KCmdResetBackObject= 6; + +const TUint8 KRedirectorInfoSig = 0x7e; + +NONSHARABLE_STRUCT(TRedirectorInfo) + { + TUint8 iSignature; + TAny* iFrontBufferInterface; + TAny* iBackBufferInterface; + TAny* iScreenConfigInterface; + TInt iScreenBitmapHandle; + TInt iFlickerBitmapHandle; + TInt iUpdateCounter; + }; + +NONSHARABLE_STRUCT(TWsBackBuffer): public MWsBackBuffer + { +public: + TWsBackBuffer(CFbsBitmap* aBit,CFbsBitGc* aGc): iBit(aBit), iGc(aGc) + {} + virtual CFbsBitmap* GetBitmap() + {return iBit;} + virtual CFbsBitGc* GetBitGc() + {return iGc;} + virtual TInt SetBitGc(CFbsBitGc*) + {return KErrNotSupported;} + virtual TInt RedirectTo(MWsBackBuffer*) + {return KErrNotSupported;} + virtual void SetObserver(MWsFlickerFreeBufferObserver* /*aObserver*/) + {ASSERT(0);} + virtual MWsFlickerFreeBufferObserver* Observer() + { + ASSERT(0); + return NULL; + } + virtual CFbsBitGc* GetBitGcCurrent() + { + ASSERT(0); + return NULL; + } + +private: + CFbsBitmap* iBit; + CFbsBitGc* iGc; + }; + +// +CWsGcRedirector* CWsGcRedirector::NewL() + { + return new(ELeave) CWsGcRedirector; + } + +CWsGcRedirector::~CWsGcRedirector() + { +#ifdef __WINS__ + delete iFrontWin; + delete iBackWin; + delete iUpdateDebugWinsTimer; +#endif + + if (iFrontBuf) + iFrontBuf->SetBitGc(NULL); + if (iBackBuf) + iBackBuf->SetBitGc(NULL); + + delete iFrontGc; + delete iFrontDev; + delete iFrontBit; + delete iBackGc; + delete iBackDev; + delete iBackBit; + delete iBadGc; + delete iBackObj; + } + +void CWsGcRedirector::ConstructL(MWsGraphicDrawerEnvironment& aEnv, const TGraphicDrawerId& aId, MWsClient& aOwner, const TDesC8& aData) + { + BaseConstructL(aEnv, aId, aOwner); + +#ifdef __WINS__ + if (aData.Length()>1) + iDisableWin = aData[1]==1; +#endif + iScreenId = KDefaultScreen; + if (aData.Length()>0) + iScreenId = aData[0]; + MWsScreen* scr = aEnv.Screen(iScreenId); + User::LeaveIfNull(scr); + + MWsScreenConfig* cfg = scr->ObjectInterface(); + User::LeaveIfNull(cfg); + + iFrontBuf = scr->ObjectInterface(); + User::LeaveIfNull(iFrontBuf); + iBackBuf = scr->ObjectInterface(); + + iFrontBit = new(ELeave) CFbsBitmap; + iDefaultSize=cfg->SizeInPixels(); + User::LeaveIfError(iFrontBit->Create(iDefaultSize,EColor64K)); + iFrontDev = CFbsBitmapDevice::NewL(iFrontBit); + User::LeaveIfNull(iFrontDev); + User::LeaveIfError(iFrontDev->CreateContext(iFrontGc)); + + User::LeaveIfError(iFrontDev->CreateContext(iBadGc)); + iBadGc->ChangeDevice(NULL); + +#ifdef __WINS__ + if (!iDisableWin) + { + iUpdateDebugWinsTimer = CPeriodic::NewL(0); + iUpdateDebugWinsTimer->Start(0, 300 * 1000, TCallBack(UpdateDebugWindowsCallback, this)); + + _LIT(KRedFront, "RedFront"); + iFrontWin = CDebugOsbWin::NewL(KRedFront, iFrontBit->SizeInPixels()); + } +#endif + + if (iBackBuf) + { + CFbsBitmap* bit = iBackBuf->GetBitmap(); + User::LeaveIfNull(bit); + iBackBit = new(ELeave) CFbsBitmap; + User::LeaveIfError(iBackBit->Create(bit->SizeInPixels(),EColor64K)); + iBackDev = CFbsBitmapDevice::NewL(iBackBit); + User::LeaveIfNull(iBackDev); + User::LeaveIfError(iBackDev->CreateContext(iBackGc)); + + iBackObj = new(ELeave) TWsBackBuffer(iBackBit,iBackGc); +#ifdef __WINS__ + if (!iDisableWin) + { + _LIT(KRedBack, "RedBack"); + iBackWin = CDebugOsbWin::NewL(KRedBack, iBackBit->SizeInPixels()); + } +#endif + } + + // compile check, non-const interface access + MWsGraphicDrawerEnvironment& ee = Env(); + MWsScreen* ss = ee.Screen(iScreenId); + MWsScreenConfig* cc = ss->ObjectInterface(); + } + +void CWsGcRedirector::HandleMessage(const TDesC8& aData) + { + // wserv already check data size, and won't invoke this handler if it's empty + TBuf8<1> ack; + ack.Append(KRedirectorInfoSig); + + switch (aData[0]) + { + case KCmdQuery: + SendInfo(); + break; + + case KCmdSetGcFront: + Env().RegisterEventHandler(this,this,TWservCrEvent::EScreenUpdated|TWservCrEvent::EScreenOrientationChanged|TWservCrEvent::EDeviceOrientationChanged); + + // -test bad gc + __ASSERT_ALWAYS(iFrontBuf->SetBitGc(iBadGc)==KErrArgument, User::Invariant()); + // -test bad gc + __ASSERT_ALWAYS(iFrontBuf->SetBitGc(iBadGc,ETrue)==KErrArgument, User::Invariant()); + // +test + __ASSERT_ALWAYS(iFrontBuf->SetBitGc(iFrontGc,EFalse)==KErrNone, User::Invariant()); + // -test duplicate calls + __ASSERT_ALWAYS(iFrontBuf->SetBitGc(iFrontGc)==KErrAlreadyExists, User::Invariant()); + + SendMessage(ack); + break; + + case KCmdSetGcBack: + if (iBackBuf) + { + // -test bad gc + __ASSERT_ALWAYS(iBackBuf->SetBitGc(iBadGc)==KErrArgument, User::Invariant()); + // +test + __ASSERT_ALWAYS(iBackBuf->SetBitGc(iBackGc)==KErrNone, User::Invariant()); + // -test duplicate calls + __ASSERT_ALWAYS(iBackBuf->SetBitGc(iBackGc)==KErrAlreadyExists, User::Invariant()); + // -test double redirection + __ASSERT_ALWAYS(iBackBuf->RedirectTo(iBackObj)==KErrInUse, User::Invariant()); + } + SendMessage(ack); + break; + + case KCmdResetGcFront: + Env().UnregisterEventHandler(this); + iUpdateCounter = 0; + + __ASSERT_ALWAYS(iFrontBuf->SetBitGc(NULL,EFalse)==KErrNone, User::Invariant()); + // -test duplicate calls + __ASSERT_ALWAYS(iFrontBuf->SetBitGc(NULL,EFalse)==KErrNone, User::Invariant()); + SendMessage(ack); + break; + + case KCmdResetGcBack: + if (iBackBuf) + { + // +test + __ASSERT_ALWAYS(iBackBuf->SetBitGc(NULL)==KErrNone, User::Invariant()); + // -test duplicate calls + __ASSERT_ALWAYS(iBackBuf->SetBitGc(NULL)==KErrNone, User::Invariant()); + } + SendMessage(ack); + break; + + case KCmdSetBackObject: + if (iBackBuf) + { + TWsBackBuffer badObj1(NULL,iBackGc); + // -test bad obj (null bitmap) + __ASSERT_ALWAYS(iBackBuf->RedirectTo(&badObj1)==KErrArgument, User::Invariant()); + // -test bad obj (null gc) + TWsBackBuffer badObj2(iBackBit,NULL); + __ASSERT_ALWAYS(iBackBuf->RedirectTo(&badObj2)==KErrArgument, User::Invariant()); + // -test bad obj (null device) + TWsBackBuffer badObj3(iBackBit,iBadGc); + __ASSERT_ALWAYS(iBackBuf->RedirectTo(&badObj3)==KErrArgument, User::Invariant()); + // +test + __ASSERT_ALWAYS(iBackBuf->RedirectTo(iBackObj)==KErrNone, User::Invariant()); + // -test duplicate calls + __ASSERT_ALWAYS(iBackBuf->RedirectTo(iBackObj)==KErrAlreadyExists, User::Invariant()); + // -test double redirection + __ASSERT_ALWAYS(iBackBuf->SetBitGc(iBackGc)==KErrInUse, User::Invariant()); + } + SendMessage(ack); + break; + + case KCmdResetBackObject: + if (iBackBuf) + { + // +test + __ASSERT_ALWAYS(iBackBuf->RedirectTo(NULL)==KErrNone, User::Invariant()); + // -test duplicate calls + __ASSERT_ALWAYS(iBackBuf->RedirectTo(NULL)==KErrNone, User::Invariant()); + } + SendMessage(ack); + break; + } + } + +void CWsGcRedirector::DoDraw(MWsGc& aGc, const TRect& aRect, const TDesC8& aData) const + { + aGc.PushBitGcSettings(); + CFbsBitGc& bc = aGc.BitGc(); + bc.SetBrushStyle(CGraphicsContext::ESolidBrush); + bc.SetBrushColor(TRgb(255,0,0,128)); + bc.DrawRect(aRect); + TGraphicDrawerId id; + id.iId = 0x10281fb6; + id.iIsUid = ETrue; + const CWsGraphicDrawer* listener = Env().ResolveGraphic(id); + if (listener) + listener->Draw(aGc, aRect, aData); + aGc.PopBitGcSettings(); + + // compile check, const interface access + const MWsGraphicDrawerEnvironment& env = Env(); // Env() const + const MWsScreen* scr = env.Screen(iScreenId); // Screen(TInt) const + const MWsScreenConfig* cfg = scr->ObjectInterface(); // ObjectInterface() const + } + +void CWsGcRedirector::SendInfo() + { + TPckgBuf buf; + MWsScreen* scr = Env().Screen(iScreenId); + if (scr) + { + buf().iSignature = KRedirectorInfoSig; + buf().iFrontBufferInterface = scr->ObjectInterface(); + buf().iBackBufferInterface = scr->ObjectInterface(); + buf().iScreenConfigInterface = scr->ObjectInterface(); + buf().iScreenBitmapHandle = iFrontBit->Handle(); + buf().iFlickerBitmapHandle = iBackBit? iBackBit->Handle() : 0; + buf().iUpdateCounter = iUpdateCounter; + } + TInt err = SendMessage(buf); + __ASSERT_ALWAYS(err>=KErrNone, User::Invariant()); + } + +void CWsGcRedirector::DoHandleEvent(const TWservCrEvent& aEvent) + { + if (aEvent.ScreenNumber()==iScreenId) + { + switch(aEvent.Type()) + { + case TWservCrEvent::EScreenUpdated: + ++iUpdateCounter; + break; + case TWservCrEvent::EDeviceOrientationChanged: + case TWservCrEvent::EScreenOrientationChanged: + { + CFbsBitGc::TGraphicsOrientation orientation=aEvent.Orientation(); + TSize bmpSize; + if (orientation==CFbsBitGc::EGraphicsOrientationNormal || orientation==CFbsBitGc::EGraphicsOrientationRotated180) + bmpSize=iDefaultSize; + else + bmpSize.SetSize(iDefaultSize.iHeight,iDefaultSize.iWidth); + const TSize fBufSize(iFrontBit->SizeInPixels()); + if (fBufSize!=bmpSize) + { + __ASSERT_DEBUG(fBufSize.iWidth==bmpSize.iHeight && fBufSize.iHeight==bmpSize.iWidth, User::Invariant()); + iFrontDev->SwapWidthAndHeight(); + iFrontGc->Activate(iFrontDev); + } + } + break; + } + } + } + +#ifdef __WINS__ +TInt CWsGcRedirector::UpdateDebugWindowsCallback(TAny* aSelf) + { + CWsGcRedirector* self = static_cast(aSelf); + if(!self) + return KErrArgument; + + if(self->iFrontWin && self->iFrontBit) + { + CFbsBitmap* bitmap = self->iFrontBit; + bitmap->LockHeap(); + self->iFrontWin->Refresh(bitmap->SizeInPixels(), bitmap->DisplayMode(), bitmap->DataAddress()); + bitmap->UnlockHeap(); + } + + if(self->iBackWin && self->iBackBit) + { + CFbsBitmap* bitmap = self->iBackBit; + bitmap->LockHeap(); + self->iBackWin->Refresh(bitmap->SizeInPixels(), bitmap->DisplayMode(), bitmap->DataAddress()); + bitmap->UnlockHeap(); + } + return KErrNone; + } +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tredir/redirector.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tredir/redirector.h Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,81 @@ +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef __REDIRECTOR_H__ +#define __REDIRECTOR_H__ + +#include "Graphics/WSGRAPHICDRAWER.H" +#include + +class CFbsBitmap; +class CFbsBitmapDevice; +class CFbsBitGc; +#ifdef __WINS__ +class CDebugOsbWin; +#endif + +class TWsBackBuffer; + +NONSHARABLE_CLASS(CWsGcRedirector): public CWsGraphicDrawer, public MWsEventHandler + { +public: + enum {EImplUid = 0x10281e1e}; + +public: + static CWsGcRedirector* NewL(); + virtual ~CWsGcRedirector(); + + // override CWsGraphicDrawer + virtual void ConstructL(MWsGraphicDrawerEnvironment& aEnv,const TGraphicDrawerId& aId, MWsClient& aOwner, const TDesC8& aData); + virtual void HandleMessage(const TDesC8& aData); + virtual void DoHandleEvent(const TWservCrEvent& aEvent); +private: + // override CWsGraphicDrawer + virtual void DoDraw(MWsGc& aGc, const TRect& aRect, const TDesC8& aData) const; + void SendInfo(); + void OnScreenUpdated(); +#ifdef __WINS__ + static TInt UpdateDebugWindowsCallback(TAny* aSelf); +#endif + +private: + MWsFrontBuffer* iFrontBuf; + MWsBackBuffer* iBackBuf; + CFbsBitmap* iFrontBit; + CFbsBitmapDevice* iFrontDev; + CFbsBitGc* iFrontGc; + CFbsBitmap* iBackBit; + CFbsBitmapDevice* iBackDev; + CFbsBitGc* iBackGc; + CFbsBitGc* iBadGc; + TWsBackBuffer* iBackObj; +#ifdef __WINS__ + CDebugOsbWin* iFrontWin; + CDebugOsbWin* iBackWin; + CPeriodic* iUpdateDebugWinsTimer; + TBool iDisableWin; +#endif + TInt iScreenId; + TInt iUpdateCounter; + TSize iDefaultSize; + }; + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tredir/redirector.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tredir/redirector.rss Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,45 @@ +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include + +RESOURCE REGISTRY_INFO registry_info + { + dll_uid = 0x10281e1c; + interfaces = + { + INTERFACE_INFO + { + interface_uid = 0x10281e1d; + implementations = + { + IMPLEMENTATION_INFO + { + implementation_uid = 0x10281e1e; + version_no = 1; + display_name = "CWsGcRedirector"; + default_data = ""; + opaque_data = ""; + } + }; + } + }; + } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tredir/wsredir.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tredir/wsredir.cpp Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,129 @@ +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include "wsredir.h" + +const TUint8 KCmdQuery = 0; +const TUint8 KCmdSetGcFront = 1; +const TUint8 KCmdSetGcBack = 2; +const TUint8 KCmdResetGcFront = 3; +const TUint8 KCmdResetGcBack = 4; +const TUint8 KCmdSetBackObject = 5; +const TUint8 KCmdResetBackObject= 6; + +const TUid KRedirectorInterfaceId = {0x10281e1d}; +const TUid KRedirectorImplId = {0x10281e1e}; + +EXPORT_C CWsRedir* CWsRedir::NewL() + { + return NewL(0); + } + +EXPORT_C CWsRedir* CWsRedir::NewL(TInt aScreenId) + { + return NewL(aScreenId, EFalse); + } + +EXPORT_C CWsRedir* CWsRedir::NewL(TInt aScreenId, TBool aDisableWin) + { + CWsRedir* self = new(ELeave) CWsRedir; + CleanupStack::PushL(self); + TBuf8<2> data; + data.Append((TUint8)aScreenId); + data.Append((TUint8)aDisableWin); + self->BaseConstructL(KRedirectorInterfaceId, KRedirectorImplId, data); + CleanupStack::Pop(self); + self->iIsReady = ETrue; + return self; + } + +EXPORT_C CWsRedir::~CWsRedir() + { + iIsReady = EFalse; + } + +void CWsRedir::HandleMessage(const TDesC8& aData) + { + if (aData.Size()>1 && aData[0]==KRedirectorInfoSig) + Mem::Copy(iReq, aData.Ptr(), aData.Size()); + iCallBack.CallBack(); + } + +void CWsRedir::OnReplace() + { + } + +EXPORT_C TInt CWsRedir::Redirect(TBufferType aWhich, TBool aHow) + { + if (!iIsReady) + return KErrNotReady; + + TBuf8<1> cmd; + if (aWhich==EFrontBuffer) + { + if (iIsFrontRedirected && aHow) + return KErrArgument; + iIsFrontRedirected = aHow; + cmd.Append(iIsFrontRedirected? KCmdSetGcFront : KCmdResetGcFront); + } + else + { + if (iIsBackRedirected && aHow) + return KErrArgument; + iIsBackRedirected = aHow; + cmd.Append(iIsBackRedirected? KCmdSetGcBack : KCmdResetGcBack); + } + + SendMessage(cmd); + return Flush(); + } + +EXPORT_C TInt CWsRedir::RedirectUsingWsBackBuffer(TBool aHow) + { + if (!iIsReady) + return KErrNotReady; + + TBuf8<1> cmd; + if (iIsBackRedirected && aHow) + return KErrArgument; + iIsBackRedirected = aHow; + cmd.Append(iIsBackRedirected? KCmdSetBackObject : KCmdResetBackObject); + + SendMessage(cmd); + return Flush(); + } + +EXPORT_C TInt CWsRedir::QueryPlugin(TRedirectorInfo& aInfo) + { + TBuf8<1> cmd; + cmd.Append(KCmdQuery); + SendMessage(cmd); + TInt err = Flush(); + if (err!=KErrNone) + return err; + iReq = &aInfo; + return KErrNone; + } + +EXPORT_C void CWsRedir::SetCallBack(TCallBack aCallBack) + { + iCallBack = aCallBack; + } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/tredir/wsredir.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tredir/wsredir.h Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,69 @@ +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#ifndef __WSREDIR_H__ +#define __WSREDIR_H__ + +#include + +const TUint8 KRedirectorInfoSig = 0x7e; + +NONSHARABLE_STRUCT(TRedirectorInfo) + { + TUint8 iSignature; + TAny* iFrontBufferInterface; + TAny* iBackBufferInterface; + TAny* iScreenConfigInterface; + TInt iScreenBitmapHandle; + TInt iFlickerBitmapHandle; + TInt iUpdateCounter; + }; + +NONSHARABLE_CLASS(CWsRedir): public CWsGraphic + { +public: + enum TBufferType + { + EFrontBuffer, + EBackBuffer + }; +public: + IMPORT_C static CWsRedir* NewL(); + IMPORT_C static CWsRedir* NewL(TInt aScreenId); + IMPORT_C static CWsRedir* NewL(TInt aScreenId, TBool aDisableWin); + IMPORT_C ~CWsRedir(); + IMPORT_C TInt Redirect(TBufferType aWhich, TBool aHow); + IMPORT_C TInt RedirectUsingWsBackBuffer(TBool aHow); + IMPORT_C TInt QueryPlugin(TRedirectorInfo& aInfo); + IMPORT_C void SetCallBack(TCallBack aCallBack); +private: + // override CWsGraphic + virtual void HandleMessage(const TDesC8& aData); + virtual void OnReplace(); +private: + TBool iIsFrontRedirected; + TBool iIsBackRedirected; + TBool iIsReady; + TRedirectorInfo* iReq; + TCallBack iCallBack; + }; + +#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/ttime/TTDRWBIT.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/ttime/TTDRWBIT.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,19 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// used for timing text printing +// +// + +#include "ttime.h" + diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/ttime/TTGENRAL.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/ttime/TTGENRAL.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,352 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// used for timing graphics +// +// + +#include "TTIME.H" + +#define TEST_ROM_BITMAP_NAME _L("Z:\\WSTEST\\TROM.MBM") + +enum TFuncType + { + ESimpleFlush, + ESpriteSetting, + EBitmapDevice, + ETrivialFunctions, + ELoadBitmap, + }; + +class TWsTest : public CBase + { +public: + void DoTestL(TInt aOwningGroup, TFuncType aFunc, TInt aParam1, TAny *aParam2); + void SimpleFlush(TInt aParam1, TAny *aParam2); + void SpriteSettingL(TInt aParam1, TAny *aParam2); + void BitmapDeviceL(TInt aParam, TAny *); + void TrivialFunctions(TInt aParam1, TAny *aParam2); + void LoadBitmapL(TInt aParam1, TAny *aParam2); +private: + void createSpriteBitmapL(CFbsBitmap *aBitmap, CFbsBitmapDevice *&aBitmapDevice, const TSize &aSize, TBool aDoMask); +private: + RWsSession iWs; + RWindowGroup iGroup; + RWindow iWindow; + CWsScreenDevice *iDevice; + CWindowGc *iGc; + }; + +TInt CreateWsTest(TInt aOwningGroup, TFuncType aFunc, TInt aParam1, TAny *aParam2) + { + TWsTest *iTest=NULL; + TRAPD(err,iTest=new(ELeave) TWsTest()); + if (err==KErrNone) + { + TRAP(err,iTest->DoTestL(aOwningGroup, aFunc, aParam1, aParam2)); + delete iTest; + } + return(err); + } + +void TWsTest::DoTestL(TInt aOwningGroup, TFuncType aFunc, TInt aParam1, TAny *aParam2) + { + iWs.Connect(); + iDevice=new(ELeave) CWsScreenDevice(iWs); + iDevice->Construct(); + iGroup=RWindowGroup(iWs); + iGroup.Construct(ENullWsHandle); + iGroup.SetOwningWindowGroup(aOwningGroup); +// + iWindow=RWindow(iWs); + iWindow.Construct(iGroup,ENullWsHandle); + iWindow.SetExtent(TPoint(), iDevice->SizeInPixels()); + iWindow.Activate(); +// + iDevice->CreateContext(iGc); + iWindow.BeginRedraw(); + iGc->Activate(iWindow); + iGc->Clear(); + iWindow.EndRedraw(); +// + switch(aFunc) + { + case ESimpleFlush: + SimpleFlush(aParam1, aParam2); + break; + case ESpriteSetting: + SpriteSettingL(aParam1, aParam2); + break; + case EBitmapDevice: + BitmapDeviceL(aParam1, aParam2); + break; + case ETrivialFunctions: + TrivialFunctions(aParam1, aParam2); + break; + case ELoadBitmap: + LoadBitmapL(aParam1, aParam2); + break; + default:; + } + delete iGc; + iWindow.Close(); + iGroup.Close(); + delete iDevice; + iWs.Close(); + } + +// Flush // + +void TWsTest::SimpleFlush(TInt aParam, TAny *) + { + TTimeIntervalMicroSeconds32 interval(100000); + TInt distance=10; + if (aParam==0) + { + TTimeIntervalMicroSeconds32 origInterval; + TInt origDistance; + iWs.GetDoubleClickSettings(origInterval,origDistance); + for(TInt nTimes=0;nTimes<5000-1;nTimes++) + { + iWs.SetDoubleClick(interval,distance); + iWs.Flush(); + } + iWs.SetDoubleClick(origInterval,origDistance); + } + else + { + for(TInt nTimes=0;nTimes<5000;nTimes++) + iWs.GetDoubleClickSettings(interval,distance); + } + } + +TInt SimpleFlushTestFunc(TInt aOwningGroup) + { + return(CreateWsTest(aOwningGroup, ESimpleFlush, 0, NULL)); + } + +TInt SimpleFlushTestFunc2(TInt aOwningGroup) + { + return(CreateWsTest(aOwningGroup, ESimpleFlush, 1, NULL)); + } + +GLDEF_D TTimeTestHeader SimpleFlushTest={_S("Simple Flush[1] x5000"),SimpleFlushTestFunc}; +GLDEF_D TTimeTestHeader SimpleFlushTest2={_S("Simple Flush[2] x5000"),SimpleFlushTestFunc2}; + +// IP Read/Write // + +#if 0 +TInt ReadWriteThreadFunc(TAny *aParams) + { + TWinCommand command; + RProcess().CommandLine(command); + TDesC8 *cmd=&command; + RThread thread; + thread.Open(_L("TimeTest")); + TAny *remotePtr=*(TAny **)aCmd->Ptr(); + TBuf<0x10> buf; + for(TInt count=0;count<100000;count++) + thread.ReadL(remotePtr,buf,0); + } + +void TWsTest::IPReadWriteL(TInt aParam, TAny *) + { + TBuf<0x10> srcData; + srcData.Append(_L("1234567890ABCDEF")); + RProcess process; + TWinCommand command; + *((TAny **)command.Ptr())=&srcData; + User::LeaveIfError(process.Create(_L("TimeThread1"),); + TRequestStatus status; + process.Logon(status); + process.Resume(); + User::WaitForRequest(status); + process.Close(); + } + +TInt SimpleFlushTestFunc(TInt aOwningGroup) + { + return(CreateWsTest(aOwningGroup, ESimpleFlush, 0, NULL)); + } + +TInt SimpleFlushTestFunc2(TInt aOwningGroup) + { + return(CreateWsTest(aOwningGroup, ESimpleFlush, 1, NULL)); + } + +GLDEF_D TTimeTestHeader SimpleFlushTest={_S("Simple Flush[1] x5000"),SimpleFlushTestFunc}; +GLDEF_D TTimeTestHeader SimpleFlushTest2={_S("Simple Flush[2] x5000"),SimpleFlushTestFunc2}; +#endif +// Bitmap device // + +void TWsTest::BitmapDeviceL(TInt aParam, TAny *) + { + CFbsBitmap *bitmap=new(ELeave) CFbsBitmap(); + User::LeaveIfError(bitmap->Create(TSize(10,10),EGray4)); + CFbsBitmapDevice *bitmapDevicePerm=NULL; + if (aParam==1) + bitmapDevicePerm=CFbsBitmapDevice::NewL(bitmap); + for(TInt nTimes=0;nTimes<100;nTimes++) + { + CFbsBitmapDevice *bitmapDevice=CFbsBitmapDevice::NewL(bitmap); + delete bitmapDevice; + } + delete bitmapDevicePerm; + delete bitmap; + } + +TInt BitmapDeviceTestFunc1(TInt aOwningGroup) + { + return(CreateWsTest(aOwningGroup, EBitmapDevice, 0, NULL)); + } + +TInt BitmapDeviceTestFunc2(TInt aOwningGroup) + { + return(CreateWsTest(aOwningGroup, EBitmapDevice, 1, NULL)); + } + +GLDEF_D TTimeTestHeader BitmapDeviceTest1={_S("Bitmap Device (reload)"),BitmapDeviceTestFunc1}; +GLDEF_D TTimeTestHeader BitmapDeviceTest2={_S("Bitmap Device "),BitmapDeviceTestFunc2}; + +// Sprite Setting // + +void TWsTest::createSpriteBitmapL(CFbsBitmap *aBitmap, CFbsBitmapDevice *&aBitmapDevice, const TSize &aSize, TBool aDoMask) + { + User::LeaveIfError(aBitmap->Create(aSize,EGray4)); + aBitmapDevice=CFbsBitmapDevice::NewL(aBitmap); + CFbsBitGc *gc=CFbsBitGc::NewL(); + gc->Activate(aBitmapDevice); + gc->SetBrushColor(TRgb::Gray4(aDoMask ? 0 : 2)); + gc->SetBrushStyle(CGraphicsContext::ESolidBrush); + gc->SetPenStyle(CGraphicsContext::ENullPen); + gc->DrawRect(TRect(aSize)); + gc->SetPenStyle(CGraphicsContext::ESolidPen); + gc->SetPenColor(TRgb::Gray4(aDoMask ? 3 : 0)); + gc->SetBrushColor(TRgb::Gray4(aDoMask ? 3 : 1)); + gc->DrawEllipse(TRect(aSize)); + delete gc; + } + +void TWsTest::SpriteSettingL(TInt , TAny *) + { + RWsSprite sprite; + TSize size(32,32); + sprite=RWsSprite(iWs); + CFbsBitmap *bitmap=new(ELeave) CFbsBitmap(); + CFbsBitmap *mask=new(ELeave) CFbsBitmap(); + CFbsBitmapDevice *bitmapDevice=NULL; //To stop warning + TRAPD(err,createSpriteBitmapL(bitmap,bitmapDevice,size,EFalse)); + delete bitmapDevice; + TRAP(err,createSpriteBitmapL(mask,bitmapDevice,size,ETrue)); + delete bitmapDevice; + TSpriteMember spriteData; + spriteData.iBitmap=bitmap; + spriteData.iMaskBitmap=mask; + spriteData.iInvertMask=EFalse; + spriteData.iInterval=TTimeIntervalMicroSeconds32(0); + User::LeaveIfError(sprite.Construct(iWindow,TPoint(0,0),0)); + User::LeaveIfError(sprite.AppendMember(spriteData)); + User::LeaveIfError(sprite.Activate()); + for(TInt i=0;i<500;i++) + sprite.SetPosition(TPoint(i&0x7f,i&0x7f)); + sprite.Close(); + delete mask; + delete bitmap; + } + +TInt SpriteSettingTestFunc(TInt aOwningGroup) + { + return(CreateWsTest(aOwningGroup, ESpriteSetting, 0, NULL)); + } + +GLDEF_D TTimeTestHeader SpriteTest={_S("Sprite Setting"),SpriteSettingTestFunc}; + +void TWsTest::TrivialFunctions(TInt , TAny *) + { + for(TInt i=0;i<100000;i++) + iWs.FreeSystemPointerCursorList(); + } + +TInt TrivialFunctionsTestFunc(TInt aOwningGroup) + { + return(CreateWsTest(aOwningGroup, ETrivialFunctions, 0, NULL)); + } + +GLDEF_D TTimeTestHeader TrivialFunctionsTest={_S("TrivialFunctions"),TrivialFunctionsTestFunc}; + +void TWsTest::LoadBitmapL(TInt aMode, TAny *) + { + if (aMode<2) + { + for(TInt count=0;count<10;count++) + { + if (aMode==0) + { + CFbsBitmap *bit=new(ELeave) CFbsBitmap(); + User::LeaveIfError(bit->Load(TEST_ROM_BITMAP_NAME,0)); + delete bit; + } + else + { + CWsBitmap *bit=new(ELeave) CWsBitmap(iWs); + User::LeaveIfError(bit->Load(TEST_ROM_BITMAP_NAME,0)); + delete bit; + } + } + } + else for(TInt count=0;count<100;count++) + { + //__PROFILE_START(1) + RFs fs; + User::LeaveIfError(fs.Connect()); + fs.SetNotifyUser(EFalse); + //__PROFILE_END(1) + //__PROFILE_START(2) + TParse parse; + User::LeaveIfError(fs.Parse(TEST_ROM_BITMAP_NAME,parse)); + //__PROFILE_END(2) + //__PROFILE_START(3) + TInt drive; + User::LeaveIfError(RFs::CharToDrive(parse.Drive()[0],drive)); + TDriveInfo driveinfo; + User::LeaveIfError(fs.Drive(driveinfo,drive)); + //__PROFILE_END(3) + //__PROFILE_START(4) + RFile tempfile; + User::LeaveIfError(tempfile.Open(fs,TEST_ROM_BITMAP_NAME,EFileShareAny)); + TInt aAddress; + tempfile.Seek(ESeekAddress,aAddress); + //__PROFILE_END(4) + //__PROFILE_START(5) + tempfile.Close(); + fs.Close(); + //__PROFILE_END(5) + } + } + +TInt LoadBitmapTestFunc(TInt aOwningGroup) + { + return(CreateWsTest(aOwningGroup, ELoadBitmap, 0, NULL)); + } +TInt LoadWsBitmapTestFunc(TInt aOwningGroup) + { + return(CreateWsTest(aOwningGroup, ELoadBitmap, 1, NULL)); + } +TInt LoadRomFileTestFunc(TInt aOwningGroup) + { + return(CreateWsTest(aOwningGroup, ELoadBitmap, 3, NULL)); + } + +GLDEF_D TTimeTestHeader BitmapLoadTest={_S("Load Bitmap"),LoadBitmapTestFunc}; +GLDEF_D TTimeTestHeader WsBitmapLoadTest={_S("Load WsBitmap"),LoadWsBitmapTestFunc}; +GLDEF_D TTimeTestHeader RomFileTest={_S("Rom File"),LoadRomFileTestFunc}; diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/ttime/TTGRAPH.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/ttime/TTGRAPH.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,443 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// used for timing graphics +// +// + +#include "TTIME.H" + +#define TEST_BITMAP_NAME _L("Z:\\WSTEST\\TEST.MBM") + +GLREF_C void Panic(TInt aPanic); + +enum TFuncType + { + EBitmapTest, + EXorTest, + ESmallClearTest, + ERectCompareTest, + EUseFontTest, + EBitBltTest, + EFullScreenBitBltTest, + EMaskedBitBltTest, + EFillPatternTest, + EBackupWindowDrawingTest, + }; + +class TGraphicsTest : public CBase + { +public: + void DoTestL(TInt aOwningGroup, TFuncType aFunc, TInt aParam1, TAny *aParam2); + void DrawBitmapTestL(TInt aParam1, TAny *aParam2); + void XorTest(TInt aParam1, TAny *aParam2); + void SmallClearTest(TInt , TAny *); + void RectCompareTest(TInt , TAny *); + void UseFontTestL(TInt , TAny *); + void BitBltTestL(TInt , TAny *); + void FullScreenBitBltTestL(TInt , TAny *); + void MaskedBitBltTestL(TInt , TAny *); + void FillPatternTestL(TInt , TAny *); + void BackedUpWindowDrawingL(TInt aMode, TAny *); +private: + RWsSession iWs; + CWsScreenDevice *iDevice; + RWindowGroup iGroup; + RWindow iWindow; + RBackedUpWindow iBackedUpWindow; + RDrawableWindow *iWindowPtr; + CWindowGc *iGc; + }; + +TInt CreateGraphicsTest(TInt aOwningGroup, TFuncType aFunc, TInt aParam1, TAny *aParam2) + { + TGraphicsTest *iTest=NULL; + TRAPD(err,iTest=new(ELeave) TGraphicsTest()); + if (err==KErrNone) + { + TRAP(err,iTest->DoTestL(aOwningGroup, aFunc, aParam1, aParam2)); + delete iTest; + } + return(err); + } + +void TGraphicsTest::DoTestL(TInt aOwningGroup, TFuncType aFunc, TInt aParam1, TAny *aParam2) + { + iWs.Connect(); + iDevice=new(ELeave) CWsScreenDevice(iWs); + iDevice->Construct(); + iGroup=RWindowGroup(iWs); + iGroup.Construct(ENullWsHandle); + iGroup.SetOwningWindowGroup(aOwningGroup); +// + if (aFunc==EBackupWindowDrawingTest) + { + iBackedUpWindow=RBackedUpWindow(iWs); + iWindowPtr=&iBackedUpWindow; + iBackedUpWindow.Construct(iGroup,EGray4,ENullWsHandle); + } + else + { + iWindow=RWindow(iWs); + iWindowPtr=&iWindow; + iWindow.Construct(iGroup,ENullWsHandle); + } + User::LeaveIfError(iWindowPtr->SetExtentErr(TPoint(), iDevice->SizeInPixels())); + iWindowPtr->Activate(); + // + iDevice->CreateContext(iGc); + iGc->Activate(*iWindowPtr); + if (iWindowPtr==&iWindow) + { + iWindow.BeginRedraw(); + iGc->Clear(); + iWindow.EndRedraw(); + } + switch(aFunc) + { + case EBitmapTest: + DrawBitmapTestL(aParam1, aParam2); + break; + case EXorTest: + XorTest(aParam1, aParam2); + break; + case ESmallClearTest: + SmallClearTest(aParam1, aParam2); + break; + case ERectCompareTest: + RectCompareTest(aParam1, aParam2); + break; + case EUseFontTest: + UseFontTestL(aParam1, aParam2); + break; + case EBitBltTest: + BitBltTestL(aParam1, aParam2); + break; + case EFullScreenBitBltTest: + FullScreenBitBltTestL(aParam1, aParam2); + break; + case EMaskedBitBltTest: + MaskedBitBltTestL(aParam1, aParam2); + break; + case EFillPatternTest: + FillPatternTestL(aParam1, aParam2); + break; + case EBackupWindowDrawingTest: + BackedUpWindowDrawingL(aParam1, aParam2); + break; + default:; + } +// + delete iGc; + iWindowPtr->Close(); + iGroup.Close(); + delete iDevice; + iWs.Close(); + } + +// Draw bitmap // + +void TGraphicsTest::DrawBitmapTestL(TInt , TAny *) + { + CFbsBitmap *bitmap=new(ELeave) CFbsBitmap; + User::LeaveIfError(bitmap->Load(TEST_BITMAP_NAME,0)); + for(TInt nTimes=0;nTimes<10;nTimes++) + { + iGc->Clear(); + TSize size(iDevice->SizeInPixels()); + iGc->DrawBitmap(TRect(-size.iWidth,-size.iHeight,size.iWidth<<1,size.iHeight<<1),bitmap); + iWs.Flush(); + } + delete bitmap; + } + +TInt DrawBitmapTestFunc(TInt aOwningGroup) + { + return(CreateGraphicsTest(aOwningGroup, EBitmapTest, 0, NULL)); + } + +GLDEF_D TTimeTestHeader DrawBitmapTest={_S("Draw bitmap"),DrawBitmapTestFunc}; + +// XOR Test // + +void TGraphicsTest::XorTest(TInt , TAny *) + { + iGc->SetDrawMode(CGraphicsContext::EDrawModeXOR); + iGc->SetBrushColor(TRgb::Gray256(255)); + iGc->SetPenStyle(CGraphicsContext::ENullPen); + iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + for(TInt count=0;count<10;count++) + { + for(TInt wid=1;wid<320;wid+=3) + { + iGc->DrawRect(TRect(10,10,10+wid,150)); + // iWs.Flush(); + } + } + } + +TInt XorIngTestFunc(TInt aOwningGroup) + { + return(CreateGraphicsTest(aOwningGroup, EXorTest, 0, NULL)); + } + +GLDEF_D TTimeTestHeader XorIngTest={_S("Xor'ing"),XorIngTestFunc}; + +// XOR Test // + +void TGraphicsTest::SmallClearTest(TInt , TAny *) + { + iGc->SetBrushColor(TRgb::Gray256(255)); + iGc->SetPenStyle(CGraphicsContext::ENullPen); + iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + for(TInt count=0;count<500;count++) + { + for(TInt wid=1;wid<30;wid++) + { + iGc->DrawRect(TRect(1,0,10+wid,100)); +// iWs.Flush(); + } + } + } + +TInt SmallClearTestFunc(TInt aOwningGroup) + { + return(CreateGraphicsTest(aOwningGroup, ESmallClearTest, 0, NULL)); + } + +GLDEF_D TTimeTestHeader SmallClearTest={_S("Small clear rect"),SmallClearTestFunc}; + +// XOR Test // + +enum {EMaxWidth=100}; + +void TGraphicsTest::RectCompareTest(TInt , TAny *) + { + TSize size(iDevice->SizeInPixels()); + for(TInt count=0;count<10;count++) + iDevice->RectCompare(TRect(0,0,size.iWidth>>1,size.iHeight),TRect(size.iWidth>>1,0,size.iWidth,size.iHeight)); + } + +TInt RectCompareTestFunc(TInt aOwningGroup) + { + return(CreateGraphicsTest(aOwningGroup, ERectCompareTest, 0, NULL)); + } + +GLDEF_D TTimeTestHeader RectCompareTest={_S("RectCompare"),RectCompareTestFunc}; + +// Use Font // + +void TGraphicsTest::UseFontTestL(TInt , TAny *) + { + CFbsFont *font; + TFontSpec fspec(KTestFontTypefaceName,200); + User::LeaveIfError(iDevice->GetNearestFontToDesignHeightInTwips((CFont *&)font, fspec)); + for(TInt count=0;count<1000;count++) + iGc->UseFont(font); + iDevice->ReleaseFont(font); + } + +TInt UseFontTestFunc(TInt aOwningGroup) + { + return(CreateGraphicsTest(aOwningGroup, EUseFontTest, 0, NULL)); + } + +GLDEF_D TTimeTestHeader UseFontTest={_S("UseFont(x1000)"),UseFontTestFunc}; + +// Small BitBlt // + +void TGraphicsTest::BitBltTestL(TInt , TAny *) + { + CWsBitmap *bitmap=new(ELeave) CWsBitmap(iWs); + TSize size(25,50); + bitmap->Create(size,EGray4); + CFbsDevice *bitmapDevice=CFbsBitmapDevice::NewL(bitmap); + CFbsBitGc *gc=CFbsBitGc::NewL(); + gc->Activate(bitmapDevice); + gc->DrawEllipse(TRect(size)); + delete gc; + delete bitmapDevice; + for(TInt count=0;count<10;count++) + { + iGc->Clear(); + TPoint pos(0,0); + for(TInt xcount=0;xcount<25;xcount++,pos.iX+=size.iWidth) + { + pos.iY=0; + for(TInt ycount=0;ycount<4;ycount++,pos.iY+=size.iHeight) + iGc->BitBlt(pos,bitmap); + } + } + delete bitmap; + } + +TInt BitBltTestFunc(TInt aOwningGroup) + { + return(CreateGraphicsTest(aOwningGroup, EBitBltTest, 0, NULL)); + } + +GLDEF_D TTimeTestHeader BitBltTest={_S("BitBlt"),BitBltTestFunc}; + +// Full Screen BitBlt // + +void TGraphicsTest::FullScreenBitBltTestL(TInt , TAny *) + { + CWsBitmap *bitmap=new(ELeave) CWsBitmap(iWs); + TSize size(640,240); + User::LeaveIfError(bitmap->Create(size,EGray4)); + CFbsDevice *bitmapDevice=CFbsBitmapDevice::NewL(bitmap); + CFbsBitGc *gc=CFbsBitGc::NewL(); + gc->Activate(bitmapDevice); + for(TInt pos=0;posDrawRect(TRect(pos,0,pos+16,size.iHeight)); + iGc->BitBlt(TPoint(0,0),bitmap); + iWs.Flush(); + } + delete gc; + delete bitmapDevice; + delete bitmap; + } + +TInt FullScreenBitBltTestFunc(TInt aOwningGroup) + { + return(CreateGraphicsTest(aOwningGroup, EFullScreenBitBltTest, 0, NULL)); + } + +GLDEF_D TTimeTestHeader FullScreenBitBltTest={_S("FullScreenBitBlt"),FullScreenBitBltTestFunc}; + +// Masked BitBlt // + +void TGraphicsTest::MaskedBitBltTestL(TInt , TAny *) + { + TSize size(24,48); + CWsBitmap *bitmap=new(ELeave) CWsBitmap(iWs); + bitmap->Create(size,EGray4); + CFbsDevice *bitmapDevice=CFbsBitmapDevice::NewL(bitmap); + CFbsBitGc *gc=CFbsBitGc::NewL(); + gc->Activate(bitmapDevice); + gc->DrawEllipse(TRect(size)); + delete bitmapDevice; +// Now do the mask + CWsBitmap *mask=new(ELeave) CWsBitmap(iWs); + mask->Create(size,EGray4); + bitmapDevice=CFbsBitmapDevice::NewL(mask); + gc->Activate(bitmapDevice); + gc->SetPenColor(TRgb::Gray4(3)); + gc->DrawEllipse(TRect(size)); + delete bitmapDevice; +// + delete gc; + for(TInt count=0;count<10;count++) + { + iGc->Clear(); + TPoint pos(0,0); + for(TInt xcount=0;xcount<25;xcount++,pos.iX+=size.iWidth+1) + { + pos.iY=0; + for(TInt ycount=0;ycount<4;ycount++,pos.iY+=size.iHeight) + iGc->BitBltMasked(pos,bitmap,TRect(size),mask,EFalse); + } + } + delete bitmap; + delete mask; + } + +TInt MaskedBitBltTestFunc(TInt aOwningGroup) + { + return(CreateGraphicsTest(aOwningGroup, EMaskedBitBltTest, 0, NULL)); + } + +GLDEF_D TTimeTestHeader MaskedBitBltTest={_S("MaskedBitBlt"),MaskedBitBltTestFunc}; + +// Fill Pattern // + +void TGraphicsTest::FillPatternTestL(TInt , TAny *) + { + TSize scrSize(iDevice->SizeInPixels()); + TSize rectSize(scrSize.iWidth/5-1,scrSize.iHeight/2); + + CWsBitmap *bitmap=new(ELeave) CWsBitmap(iWs); + + TSize bitmapSize(50,40); + bitmap->Create(bitmapSize,EGray4); + CFbsDevice *bitmapDevice=CFbsBitmapDevice::NewL(bitmap); + CFbsBitGc *gc=CFbsBitGc::NewL(); + gc->Activate(bitmapDevice); + gc->SetBrushColor(TRgb::Gray4(2)); + gc->SetBrushStyle(CGraphicsContext::ESolidBrush); + gc->DrawEllipse(TRect(bitmapSize)); + delete bitmapDevice; + delete gc; +// + iGc->UseBrushPattern(bitmap); + iGc->SetBrushStyle(CGraphicsContext::EPatternedBrush); + iGc->SetPenStyle(CGraphicsContext::ESolidPen); + for(TInt count=0;count<50;count++) + { + iGc->Clear(); + TPoint pos(0,0); + for(TInt xcount=0;xcount<5;xcount++,pos.iX+=rectSize.iWidth) + { + pos.iY=0; + for(TInt ycount=0;ycount<2;ycount++,pos.iY+=rectSize.iHeight) + iGc->DrawRect(TRect(pos,rectSize)); + } + } + delete bitmap; + } + +TInt FillPatternTestFunc(TInt aOwningGroup) + { + return(CreateGraphicsTest(aOwningGroup, EFillPatternTest, 0, NULL)); + } + +GLDEF_D TTimeTestHeader FillPatternTest={_S("FillPattern"),FillPatternTestFunc}; + +// Backup Window Drawing // + +void TGraphicsTest::BackedUpWindowDrawingL(TInt aMode, TAny *) + { + TSize scrSize(iDevice->SizeInPixels()); + CFbsFont *font=NULL; + if (aMode==1) + { + TFontSpec fspec(KTestFontTypefaceName,200); + User::LeaveIfError(iDevice->GetNearestFontToDesignHeightInTwips((CFont *&)font, fspec)); + iGc->UseFont(font); + } + iGc->SetPenStyle(CGraphicsContext::ESolidPen); + TPoint pos; + for(TInt count=0;count<10;count++) + { + iGc->Clear(); + for(pos.iY=0;pos.iYDrawLine(pos,pos+TSize(scrSize.iWidth,0)); + } + if (aMode==1) + iDevice->ReleaseFont(font); + } + +TInt BackupWindowDrawingFunc1(TInt aOwningGroup) + { + return(CreateGraphicsTest(aOwningGroup, EBackupWindowDrawingTest, 0, NULL)); + } + +GLDEF_D TTimeTestHeader BackupWindowDrawingCreate1={_S("BackupWindowDrawing 1"),BackupWindowDrawingFunc1}; + +TInt BackupWindowDrawingFunc2(TInt aOwningGroup) + { + return(CreateGraphicsTest(aOwningGroup, EBackupWindowDrawingTest, 1, NULL)); + } + +GLDEF_D TTimeTestHeader BackupWindowDrawingCreate2={_S("BackupWindowDrawing 2"),BackupWindowDrawingFunc2}; diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/ttime/TTIME.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/ttime/TTIME.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,554 @@ +// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Functions to act as bench marks for various window server features +// +// + +#include "TTIME.H" +#include +#include +typedef TBuf<32> TestNameBuf; + +LOCAL_D const TUint KHeapSize=0x10000; + +class CTimeClient; + +class CResultDialog : public CTDialog + { +public: + CResultDialog(CTWindowGroup *aGroupWin,CWindowGc *aGc); + void ButtonPressL(TInt aButton); + void ConstructLD(); +private: + CTWindowGroup *iGroupWin; + CWindowGc *iGc; + }; + +class CListWindow : public CTTitledWindow + { +public: + CListWindow(); + void CloseWindow(); + void ConstructL(CTWinBase &parent, TBool aExitOnEscape); + void Draw(); + virtual void SelectedL(TInt aIndex)=0; + virtual void WinKeyL(const TKeyEvent &aKey,const TTime& aTime); + void SetExt(const TPoint &aPos, const TSize &aSize); + void SetSize(const TSize &); +protected: + virtual TPtrC GetText(TInt aLine)=0; + virtual TInt ListCount()=0; + void SetSize(); +private: + void Resized(const TSize &aSize); + void SetListPos(TInt aNewPos); + TInt TextRowHeight() const; + void RowBox(TRect &aRect, TInt aRow) const; + void PointerL(const TPointerEvent &aPointer,const TTime& aTime); +private: + TInt iListPos; + TTime iPrevTime; + TBool iExitOnEscape; + }; + +class CTestList : public CListWindow + { +public: + CTestList(); + ~CTestList(); + void ConstructL(CTWinBase &parent); + static void AppendProfileNum(TDes &aDes, TInt aNum); + static void AppendProfileCount(TDes &aDes, TInt aNum); + void SelectedL(TInt aIndex); + virtual void WinKeyL(const TKeyEvent &aKey,const TTime& aTime); + void ForegroundAppDialog(); + void AppendToListL(const TDesC &aDesc); +private: + virtual TPtrC GetText(TInt aLine); + virtual TInt ListCount(); +private: + TInt iCount; + CArrayFixSeg iTestNames; + RThread iTimeTest; + }; + +class CTimeTestWindowGroup : public CTWindowGroup + { +public: + CTimeTestWindowGroup(CTClient *aClient); + void KeyL(const TKeyEvent &aKey,const TTime &aTime); + }; + +class CTimeClient : public CTClient + { +public: + CTimeClient(); + void ConstructL(); + void KeyL(const TKeyEvent &aKey,const TTime &aTime); + void Exit(); + CTWin *CreateTestWindowL(TPoint pos,CTWinBase *parent); +private: + TInt iNum; + }; + +const TInt Xmove=8; +const TInt Ymove=6; + +GLREF_D TTimeTestHeader MovingWindowTest1; +GLREF_D TTimeTestHeader MovingWindowTest2; +GLREF_D TTimeTestHeader StackedWindowCreate; +GLREF_D TTimeTestHeader WindowCreateDestroy; +GLREF_D TTimeTestHeader LoadsaText; +GLREF_D TTimeTestHeader DrawBitmapTest; +GLREF_D TTimeTestHeader XorIngTest; +GLREF_D TTimeTestHeader SmallClearTest; +GLREF_D TTimeTestHeader RectCompareTest; +GLREF_D TTimeTestHeader SimpleFlushTest; +GLREF_D TTimeTestHeader SimpleFlushTest2; +GLREF_D TTimeTestHeader UseFontTest; +GLREF_D TTimeTestHeader BitBltTest; +GLREF_D TTimeTestHeader FullScreenBitBltTest; +GLREF_D TTimeTestHeader MaskedBitBltTest; +GLREF_D TTimeTestHeader SpriteTest; +GLREF_D TTimeTestHeader BitmapDeviceTest1; +GLREF_D TTimeTestHeader BitmapDeviceTest2; +GLREF_D TTimeTestHeader FillPatternTest; +GLREF_D TTimeTestHeader BitmapLoadTest; +GLREF_D TTimeTestHeader WsBitmapLoadTest; +GLREF_D TTimeTestHeader RomFileTest; +GLREF_D TTimeTestHeader TrivialFunctionsTest; +GLREF_D TTimeTestHeader BackupWindowDrawingCreate1; +GLREF_D TTimeTestHeader BackupWindowDrawingCreate2; +GLREF_D TTimeTestHeader MenuEmulationCreate; +GLREF_D TTimeTestHeader MenuEmulationCreate2; + +TTimeTestHeader *tests[]={ + &MenuEmulationCreate, + &MenuEmulationCreate2, + &BitmapLoadTest, + &WsBitmapLoadTest, + &RomFileTest, + &TrivialFunctionsTest, + &BackupWindowDrawingCreate1, + &BackupWindowDrawingCreate2, + &MovingWindowTest1, + &MovingWindowTest2, + &StackedWindowCreate, +// &WindowCreateDestroy, + &LoadsaText, + &DrawBitmapTest, +// &BitmapDeviceTest1, +// &BitmapDeviceTest2, +// &XorIngTest, List getting too big +// &SmallClearTest, List getting too big +// &RectCompareTest, + &SpriteTest, +// &SimpleFlushTest, +// &SimpleFlushTest2, +// &UseFontTest, + &BitBltTest, +// &FullScreenBitBltTest, + &MaskedBitBltTest, +// &FillPatternTest, + }; + +void Panic(TInt aPanic) + { + User::Panic(_L("TimeTest"),aPanic); + } + +struct TThreadParams + { + TInt iIndex; + TInt iGroupId; + }; + +TInt TimeThread(TAny *aParams) + { + CTrapCleanup* CleanUpStack=CTrapCleanup::New(); + //__PROFILE_START(0) + TInt ret=tests[((TThreadParams *)aParams)->iIndex]->function(((TThreadParams *)aParams)->iGroupId); + //__PROFILE_END(0) + delete CleanUpStack; + return ret; + } + +// +// List Window // +// + +CListWindow::CListWindow() : CTTitledWindow(), iPrevTime(0) + { + } + +void CListWindow::CloseWindow() + { + CTClient *client=((CTimeClient *)Client()); + delete this; + client->ResetFocus(); + } + +void CListWindow::SetExt(const TPoint &aPos, const TSize &) + { + SetPos(aPos); + } + +void CListWindow::SetSize(const TSize &) + { + } + +void CListWindow::SetSize() + { + iSize.iHeight=ListCount()*(iFont->HeightInPixels()+1)+iTitleHeight+2; + iSize.iWidth=iFont->TextWidthInPixels(*Client()->Title())+30; + for(TInt index=0;indexTextWidthInPixels(GetText(index)); + if (wid>iSize.iWidth) + iSize.iWidth=wid; + } + iSize.iWidth+=4; + iWin.SetSize(iSize); + Resized(iSize); + } + +void CListWindow::ConstructL(CTWinBase &parent, TBool aExitOnEscape) + { + iExitOnEscape=aExitOnEscape; + CTTitledWindow::ConstructL(parent); + } + +void CListWindow::SetListPos(TInt aNewPos) + { + if (aNewPos>=0 && aNewPosHeightInPixels()+1); + } + +void CListWindow::RowBox(TRect &aRect, TInt aRow) const + { + aRect.iTl.iX=2; + aRect.iTl.iY=iTitleHeight+TextRowHeight()*aRow; + aRect.iBr.iX=iSize.iWidth-2; + aRect.iBr.iY=aRect.iTl.iY+TextRowHeight(); + } + +void CListWindow::Draw() + { + CTTitledWindow::Draw(); + iGc->SetPenColor(TRgb::Gray16(0)); + TPoint pos(2,iTitleHeight+iFont->AscentInPixels()+2); + TInt gap=TextRowHeight(); + for(TInt index=0;indexDrawText(GetText(index), pos); + if (index==iListPos) + { + iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); + iGc->SetBrushColor(TRgb::Gray256(255)); + iGc->SetPenStyle(CGraphicsContext::ENullPen); + iGc->SetDrawMode(CGraphicsContext::EDrawModeXOR); + TRect rect; + RowBox(rect,index); + iGc->DrawRect(rect); + iGc->SetBrushStyle(CGraphicsContext::ENullBrush); + iGc->SetPenStyle(CGraphicsContext::ESolidPen); + iGc->SetDrawMode(CGraphicsContext::EDrawModePEN); + } + } + } + +void CListWindow::Resized(const TSize &aSize) + { + SetDragRect(TRect(0,0,aSize.iWidth,iTitleHeight)); + } + +// +// Test list window +// + +CTestList::CTestList() : CListWindow(), iTestNames(4) + { + } + +CTestList::~CTestList() + { + } + +void CTestList::ConstructL(CTWinBase &parent) + { + CListWindow::ConstructL(parent, EFalse); + for(TUint index=0;index<(sizeof(tests)/sizeof(tests[0]));index++) + AppendToListL(TPtrC(tests[index]->title)); + SetSize(); + /*for(TUint index1=0;index1<(sizeof(tests)/sizeof(tests[0]));index1++) + Selected(index1);*/ + } + +void CTestList::AppendProfileNum(TDes &aDes, TInt aNum) + { + aDes.AppendFormat(_L("%d.%02d, "),aNum/1000000,(aNum%1000000)/10000); + } + +void CTestList::AppendProfileCount(TDes &aDes, TInt aNum) + { + aDes.AppendFormat(_L("%d, "),aNum); + } + +#define USE_PROCESS 1 + +void CTestList::SelectedL(TInt aIndex) + { +#if USE_PROCESS + TThreadParams params; + params.iIndex=aIndex; + TName name; + name.Format(_L("TimeTest-%x"),iCount++); + params.iGroupId=Client()->iGroup->GroupWin()->Identifier(); + User::LeaveIfError(iTimeTest.Create(name,TimeThread,KDefaultStackSize*2,KHeapSize,KHeapSize,¶ms,EOwnerThread)); + TRequestStatus status; + iTimeTest.Logon(status); + __PROFILE_RESET(8); + iTimeTest.Resume(); + User::WaitForRequest(status); +#else + TThreadParams params; + params.iIndex=aIndex; + TimeThread(¶ms); +#endif + TBuf<64> buf; + TBuf<64> buf2; + TBuf<64> buf3; + CResultDialog *dialog=new(ELeave) CResultDialog(Client()->iGroup, iGc); + dialog->ConstructLD(); +#if USE_PROCESS + if (status.Int()==KErrNone) + { +#endif +#if !defined(__PROFILING__) + buf=_L("Profiling information not available"); +#else + TProfile profile[6]; + __PROFILE_DISPLAY(6); + for (TInt index=1;index<6;index++) + AppendProfileNum(buf2,profile[index].iTime); + for (TInt index2=1;index2<6;index2++) + AppendProfileCount(buf3,profile[index2].iCount); + buf.Format(_L("Time=%d.%2d"),profile[0].iTime/1000000,(profile[0].iTime%1000000)/10000); +#endif + dialog->SetTitle(buf); +#if USE_PROCESS + } + else + { + dialog->SetTitle(_L("Error in test")); + buf.Format(_L("Error=%d"),status.Int()); + buf2=iTimeTest.ExitCategory(); + } +#endif + dialog->SetLine1(buf2); + dialog->SetLine2(buf3); + dialog->SetNumButtons(1); + dialog->SetButtonText(0,_L("Okay")); + if (dialog->Display()!=0) + Panic(0); + } + +TPtrC CTestList::GetText(TInt aLine) + { + return(TPtrC(iTestNames[aLine])); + } + +TInt CTestList::ListCount() + { + return(iTestNames.Count()); + } + +void CTestList::WinKeyL(const TKeyEvent &aKey,const TTime& aTime) + { + if (aKey.iModifiers&EModifierFunc) + { + switch(aKey.iCode) + { + case EKeyLeftArrow: + AdjustSize(-Xmove,0,aKey.iModifiers); + break; + case EKeyRightArrow: + AdjustSize(Xmove,0,aKey.iModifiers); + break; + case EKeyUpArrow: + AdjustSize(0,-Ymove,aKey.iModifiers); + break; + case EKeyDownArrow: + AdjustSize(0,Ymove,aKey.iModifiers); + break; + default: + goto not_used; + } + } + else + goto not_used; + return; +not_used: + CListWindow::WinKeyL(aKey,aTime); + } + +void CTestList::AppendToListL(const TDesC &aDesc) + { + TestNameBuf buf(aDesc); + iTestNames.AppendL(buf); + } + +// + +CResultDialog::CResultDialog(CTWindowGroup *aGroupWin,CWindowGc *aGc) : CTDialog(), + iGroupWin(aGroupWin), + iGc(aGc) + { + } + +void CResultDialog::ButtonPressL(TInt aButton) + { + if (aButton==0) + CTDialog::ButtonPressL(aButton); + } + +void CResultDialog::ConstructLD() + { + CTDialog::ConstructLD(*iGroupWin, *iGc); + } + +// +// CTimeTestWindowGroup class // +// + +CTimeTestWindowGroup::CTimeTestWindowGroup(CTClient *aClient) : CTWindowGroup(aClient) + { + } + +void CTimeTestWindowGroup::KeyL(const TKeyEvent &aKey,const TTime &aTime) + { + if (aKey.iModifiers&EModifierFunc) + { + switch(aKey.iCode) + { + case 'x': + ((CTimeClient *)Client())->Exit(); + break; + } + } + else + iCurWin->WinKeyL(aKey,aTime); + } + +// + +CTimeClient::CTimeClient() + { + } + +CTWin *CTimeClient::CreateTestWindowL(TPoint pos,CTWinBase *parent) + { + CTWin *win=new(ELeave) CTestList(); + TRAPD(err,win->ConstructL(*parent)); + if (err!=KErrNone) + goto ctw_err; + TRAP(err,win->SetPos(pos)); + if (err!=KErrNone) + { +ctw_err: + delete win; + User::Leave(err); + } + win->Activate(); + win->AssignGC(*iGc); + return(win); + } + +void CTimeClient::ConstructL() + { + CTClient::ConstructL(); + + iGroup=new(ELeave) CTimeTestWindowGroup(this); + iGroup->ConstructL(); + + CreateTestWindowL(TPoint(30,4),iGroup); + iGroup->SetCurrentWindow(iGroup->Child()); + } + +void CTimeClient::Exit() + { + CActiveScheduler::Stop(); + } + +GLDEF_C CTClient *CreateClientL() + { + return(new(ELeave) CTimeClient()); + } + +GLDEF_C TInt E32Main() + { + return(TestLibStartUp(CreateClientL)); + } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/ttime/TTIME.H --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/ttime/TTIME.H Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,35 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Header for window server timing tests +// +// + +#include +#include "W32STD.H" +#include "../tlib/testbase.h" + +enum TTimePanic + { + TTPanicDisplayMode1, + TTPanicDisplayMode2, + }; +typedef TInt (*TTimeTestFunction)(TInt aOwningGroup); +struct TTimeTestHeader + { + const TText *title; + TTimeTestFunction function; + }; + +_LIT(KTestFontTypefaceName,"DejaVu Sans Condensed"); + diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/ttime/TTMOVWIN.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/ttime/TTMOVWIN.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,302 @@ +// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Functions to act as bench marks for various window server features +// +// + +#include "TTIME.H" + +void SetUp(RWindowTreeNode &aParent, RBlankWindow &aBlank, const TPoint &aPos, const TSize &aSize, TInt aColor) + { + aBlank.Construct(aParent,ENullWsHandle); + aBlank.SetColor(TRgb::Gray256(aColor)); + aBlank.SetExtent(aPos, aSize); + aBlank.SetShadowHeight(1); + aBlank.Activate(); + } + +void doMovingWindowTest(TInt aMode, TInt aOwningGroup) + { + RWsSession ws; + ws.Connect(); + CWsScreenDevice *device=new(ELeave) CWsScreenDevice(ws); + device->Construct(); + TPoint pos(10,10); + TSize size(100,100); + TSize scrSize(device->SizeInPixels()); + RBlankWindow blank(ws); + RWindowGroup group(ws); + group.Construct(ENullWsHandle); + group.SetOwningWindowGroup(aOwningGroup); +// + RBlankWindow back(ws); + SetUp(group, back, TPoint(0,0),TSize(640,240), 255); +// + RBlankWindow blank2(ws); + RBlankWindow blank3(ws); + RBlankWindow blank4(ws); + RBlankWindow blank5(ws); + if (aMode==1) + { + SetUp(group, blank2, TPoint(10,10),TSize(240,150), 128); + SetUp(blank2, blank3, TPoint(10,10),TSize(220,130), 255); + SetUp(group, blank4, TPoint(340,-10),TSize(200,70), 64); + SetUp(group, blank5, TPoint(390,-10),TSize(30,250), 128); + } +// + SetUp(group, blank,pos,size, 128); +// + for(pos.iX=10;pos.iX<(scrSize.iWidth-10-size.iWidth);pos.iX+=1) + { + blank.SetPosition(pos); +// ws.Flush(); + } +// + if (aMode==1) + { + blank2.Close(); + blank3.Close(); + blank4.Close(); + blank5.Close(); + } + blank.Close(); + back.Close(); + group.Close(); + delete device; + ws.Close(); + } + +TInt MovingWindowTest1Func(TInt aOwningGroup) + { + doMovingWindowTest(0,aOwningGroup); + return(KErrNone); + } + +GLDEF_D TTimeTestHeader MovingWindowTest1={_S("Moving window test 1"),MovingWindowTest1Func}; + +TInt MovingWindowTest2Func(TInt aOwningGroup) + { + doMovingWindowTest(1,aOwningGroup); + return(KErrNone); + } + +GLDEF_D TTimeTestHeader MovingWindowTest2={_S("Moving window test 2"),MovingWindowTest2Func}; + +TInt CreateAndDestroy(TInt aOwningGroup) + { + RWsSession ws; + ws.Connect(); + CWsScreenDevice *device=new(ELeave) CWsScreenDevice(ws); + device->Construct(); + RWindowGroup group(ws); + group.Construct(ENullWsHandle); + group.SetOwningWindowGroup(aOwningGroup); +// + for (TInt count=0;count<100;count++) + { + RBlankWindow blank(ws); + blank.Construct(group,ENullWsHandle); + blank.SetExtent(TPoint(10,10), TSize(20,20)); + blank.Activate(); + blank.Close(); + } + group.Close(); + delete device; + ws.Close(); + return(KErrNone); + } + +GLDEF_D TTimeTestHeader WindowCreateDestroy={_S("Window create destroy"),CreateAndDestroy}; + +// + +TInt WindowCreate2(TInt aOwningGroup) + { +enum {KNumWindows=20}; + RWsSession ws; + ws.Connect(); + CWsScreenDevice *device=new(ELeave) CWsScreenDevice(ws); + device->Construct(); + RWindowGroup group(ws); + group.Construct(ENullWsHandle); + group.SetOwningWindowGroup(aOwningGroup); + RBlankWindow shield(ws); + shield.Construct(group,ENullWsHandle); + shield.Activate(); + CWindowGc *gc=new(ELeave) CWindowGc(device); + User::LeaveIfError(gc->Construct()); +// + for(TInt times=0;times<2;times++) + { +#if 1 + TSize size(200,100); + RBlankWindow win[KNumWindows]; + TInt count; + for (count=0;countActivate(win[count]); + gc->SetBrushColor(TRgb::Gray4(count&3)); + gc->Clear(); + gc->Deactivate(); + win[count].Activate(); + } +#endif + ws.Flush(); + for (count=0;countConstruct(); + RWindowGroup group(ws); + group.Construct(ENullWsHandle); + group.SetOwningWindowGroup(aOwningGroup); + RBlankWindow shield(ws); + shield.Construct(group,ENullWsHandle); + shield.Activate(); + CWindowGc *gc=new(ELeave) CWindowGc(device); + User::LeaveIfError(gc->Construct()); +// + RWindow win; + TInt count; + for (count=0;count<100;count++) + { + win=RWindow(ws); + win.Construct(group,ENullWsHandle); + win.EnableBackup(); + win.SetExtent(TPoint(10,10), TSize(200,100)); + win.Activate(); + ws.Flush(); + win.Close(); + } + shield.Close(); + group.Close(); + delete device; + ws.Close(); + return(KErrNone); + } + +GLDEF_D TTimeTestHeader BackedUpWindowCreate={_S("Backed up window creating"),BackedUpWindowCreateTest}; + +TInt BackedUpWindowMenuTest(TInt aOwningGroup) +// +// Test designed to emulate menus +// + { + RWsSession ws; + ws.Connect(); + CWsScreenDevice *device=new(ELeave) CWsScreenDevice(ws); + device->Construct(); + RWindowGroup group(ws); + group.Construct(ENullWsHandle); + group.SetOwningWindowGroup(aOwningGroup); + RBlankWindow shield(ws); + shield.Construct(group,ENullWsHandle); + shield.Activate(); + CWindowGc *gc=new(ELeave) CWindowGc(device); + User::LeaveIfError(gc->Construct()); +// + RWindow win; + win=RWindow(ws); + win.Construct(group,ENullWsHandle); + win.EnableBackup(); + win.Activate(); + TInt count; + TInt state=0; + for (count=0;count<200;count++) + { + win.SetVisible(EFalse); + if (state==0) + { + state=1; + win.SetExtent(TPoint(10,10), TSize(200,160)); + } + else + { + state=0; + win.SetExtent(TPoint(100,10), TSize(150,200)); + } + win.SetVisible(ETrue); + win.BeginRedraw(); + gc->Activate(win); + gc->SetBrushStyle(CGraphicsContext::ESolidBrush); + gc->SetBrushColor(TRgb::Gray4((state+1))); + gc->Clear(); + gc->Deactivate(); + win.EndRedraw(); + ws.Flush(); + } + win.Close(); + shield.Close(); + group.Close(); + delete device; + ws.Close(); + return(KErrNone); + } + +GLDEF_D TTimeTestHeader MenuEmulationCreate={_S("Menu emulation"),BackedUpWindowMenuTest}; + +TInt BackedUpWindowMenuTest2(TInt aOwningGroup) + { + CFbsBitmap *bitmaps[1000]; + TInt index; + for(index=0;index<1000;index++) + { + bitmaps[index]=new(ELeave) CFbsBitmap(); + bitmaps[index]->Create(TSize(10,10),EGray4); + } + BackedUpWindowMenuTest(aOwningGroup); + for(index=0;index<1000;index++) + delete bitmaps[index]; + return(KErrNone); + } + +GLDEF_D TTimeTestHeader MenuEmulationCreate2={_S("Menu emulation 2"),BackedUpWindowMenuTest2}; diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/ttime/TTTEXT.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/ttime/TTTEXT.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,71 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// LOADSTXT.CPP +// used for timing text printing +// +// + +#include "TTIME.H" + +TInt LoadsOfText(TInt aOwningGroup) + { + RWsSession ws; + ws.Connect(); + CWsScreenDevice *device=new(ELeave) CWsScreenDevice(ws); + device->Construct(); + RWindowGroup group(ws); + group.Construct(ENullWsHandle); + group.SetOwningWindowGroup(aOwningGroup); + TSize scrSize(device->SizeInPixels()); +// + RWindow window(ws); + window.Construct(group,ENullWsHandle); + window.SetExtent(TPoint(), scrSize); + window.Activate(); +// + CWindowGc *gc; + device->CreateContext(gc); + window.BeginRedraw(); + gc->Activate(window); + gc->Clear(); + window.EndRedraw(); + TFontSpec fspec(KTestFontTypefaceName,200); + CFbsFont *font; + User::LeaveIfError(device->GetNearestFontToDesignHeightInTwips((CFont *&)font, fspec)); + gc->UseFont(font); + TBuf<100> loadsatext(_L("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890zyxwvutsrqponmlkjihgfedcba")); + TInt ascent=font->AscentInPixels(); + TInt fheight=font->HeightInPixels(); + for(TInt nTimes=0;nTimes<10;nTimes++) + { + TPoint pos; +// for(pos.iY=ascent;pos.iYHeightInPixels()) +// gc->DrawText(loadsatext,pos); + for(pos.iY=0;pos.iYDrawText(loadsatext,TRect(pos,TPoint(scrSize.iWidth,pos.iY+fheight)),ascent); + gc->Clear(); + } + gc->Deactivate(); +// + ws.Flush(); + delete gc; + device->ReleaseFont(font); + window.Close(); + group.Close(); + delete device; + ws.Close(); + return(KErrNone); + } + +GLDEF_D TTimeTestHeader LoadsaText={_S("Loads of text"),LoadsOfText}; diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/twsgraphic/TWsGraphicShareTest.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/twsgraphic/TWsGraphicShareTest.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,182 @@ +// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include + +// bitmap to load for comparison +#define MY_TEST_BITMAP _L("Z:\\WSTEST\\MYTEST.MBM") + +const TUint32 ENullWsHandle=0xFFFFFFFF; +const TInt KErrTestExeFailure = -666; + +// class to check if a shared CWsGraphic can be drawn correctly +class CWsGraphicShareBase : public CBase + { +public: + CWsGraphicShareBase(); + ~CWsGraphicShareBase(); + void ConstructL(); + void DoTestDrawGraphicCompareL(TPtrC aShare); +private : + void Test(TInt aCondition); + + +private : + TInt iScreenNumber; + CWindowGc *iGc; + RWsSession iWs; + RWindowGroup *iGroupWin; + CWsScreenDevice *iScreen; + RWindow *iWin; + }; + +CWsGraphicShareBase::CWsGraphicShareBase() + { + iScreenNumber = 0; + } + +CWsGraphicShareBase::~CWsGraphicShareBase() + { + iWin->Close(); + delete iWin; + delete iScreen; + delete iGc; + delete iGroupWin; + iWs.Close(); + } + +void CWsGraphicShareBase::ConstructL() + { + User::LeaveIfError(iWs.Connect()); + iScreen=new(ELeave) CWsScreenDevice(iWs); + User::LeaveIfError(iScreen->Construct(iScreenNumber)); + iGc=new(ELeave) CWindowGc(iScreen); + User::LeaveIfError(iGc->Construct()); + iGroupWin=new(ELeave) RWindowGroup(iWs); + iGroupWin->Construct(1); + + iWin=new(ELeave) RWindow(iWs); + iWin->Construct(*iGroupWin,ENullWsHandle); + iWin->SetRequiredDisplayMode(EColor256); + iWin->SetExtent(TPoint(0,0),iScreen->SizeInPixels()); + iWin->Activate(); + iWin->BeginRedraw(); + iWin->EndRedraw(); + iWs.Flush(); + } + +// Checks that the shared graphic is drawn or not. This is done by creating a new graphic in this process +// which looks the same as the shared graphic. The new graphic is then drawn to the screen followed by an +// attempt to draw the shared graphic. The two graphics are then compared. In cases where the shared graphic +// should be drawn the two graphics should compare exactly. In cases where the shared graphic should not be +// drawn the comparison will fail. + +void CWsGraphicShareBase::DoTestDrawGraphicCompareL(TPtrC aShare) + { + // UID of the shared graphic + TUid uid1 = {0x12000021}; + TWsGraphicId twsGraphicId1(uid1); + + _LIT8(KTestData,"HelloWorld"); + + CFbsBitmap bitmap1; + CFbsBitmap mask1; + + TSize screenSize = iScreen->SizeInPixels(); + User::LeaveIfError(bitmap1.Load(MY_TEST_BITMAP,0)); + mask1.Create(bitmap1.SizeInPixels(),iScreen->DisplayMode()); + + CWsGraphicBitmap* bTest = CWsGraphicBitmap::NewL(&bitmap1,&mask1); + + // divide the screen into two equal rectangles + TRect position1(0,0,screenSize.iWidth/2,screenSize.iHeight); + TRect position2(screenSize.iWidth/2,0,screenSize.iWidth,screenSize.iHeight); + + // draw the new graphic and attempt to draw the shared graphic + iGc->Activate(*iWin); + iWin->Invalidate(); + iWin->BeginRedraw(); + iGc->Clear(position1); + iGc->Clear(position2); + + iGc->DrawWsGraphic(bTest->Id(),position1,KTestData); + iGc->DrawWsGraphic(twsGraphicId1.Uid(),position2,KTestData); + + iGc->Deactivate(); + iWin->EndRedraw(); + + iWs.Flush(); + iWs.Finish(); + // compare the graphic in both positions + if (aShare==_L("false")) + Test(!iScreen->RectCompare(position1,position2)); + else + Test(iScreen->RectCompare(position1,position2)); + + delete bTest; + } + +// Failures are written to WSERV.log +void CWsGraphicShareBase::Test(TInt aCondition) + { + if(!aCondition) + { + TLogMessageText buf; + _LIT(Fail,"AUTO Failed in WsGraphics Test : DrawSharedGraphic"); + buf.Format(Fail); + iWs.LogMessage(buf); + iWs.Flush(); + RProcess().Terminate(KErrTestExeFailure); // terminate this process immediately. Expect TWsGraph test step (TAutoServer.exe) to capture this + } + } + +void MainL() + { + // read the argument from the command line of whether the graphic should be shared or not + TBuf<256> commandLine; + User::CommandLine(commandLine); + TLex lex(commandLine); + TPtrC toShare = lex.NextToken(); + + CActiveScheduler* activeScheduler=new(ELeave) CActiveScheduler; + CActiveScheduler::Install(activeScheduler); + CleanupStack::PushL(activeScheduler); + + CWsGraphicShareBase testBase; + testBase.ConstructL(); + + testBase.DoTestDrawGraphicCompareL(toShare); + + CleanupStack::PopAndDestroy(activeScheduler); + } + +GLDEF_C TInt E32Main() + { + CTrapCleanup* cleanUpStack=CTrapCleanup::New(); + if(cleanUpStack==NULL) + { + return KErrNoMemory; + } + TRAP_IGNORE(MainL()) + delete cleanUpStack; + + return(KErrNone); + } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/test/twsgraphic/TWsGraphicTest.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/twsgraphic/TWsGraphicTest.CPP Wed Jun 23 19:41:15 2010 +0300 @@ -0,0 +1,1610 @@ +// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include +#include +#include "testbase.h" +#include "testbase.h" + +// Bitmap to load for tests +#define MY_TEST_BITMAP _L("Z:\\WSTEST\\MYTEST.MBM") + +// Animation to load for tests +_LIT(KSymBallFile, "Z:\\WSTEST\\symball.gif"); + +// Executables for different sharing of graphic tests +_LIT(KTestExe1, "TWSGRAPHICSHARETEST.exe"); +_LIT(KTestExe2, "TWSGRAPHICSHAREGLOBALTEST.exe"); +_LIT(KTestExe3, "TWSGRAPHICUNSHAREGLOBALTEST.exe"); +_LIT(KTestExe4, "TWSGRAPHICSHARESECURETEST.exe"); +_LIT(KTestExe5, "TWSGRAPHICUNSHARESECURETEST.exe"); + +// Graphic is shared or not in executeable +_LIT(KShare, " true"); +_LIT(KNoShare, " false"); + +TUid KUidTestAnimation = {0x87654321}; +const TInt KDummyGraphicId = 99; +const TInt KMaxLogLength = 256; +const TInt KAnimationRunTime = 5000000; // 5 seconds max time to run a single animation loop + +// Animation loader +class CIclLoader: public CActive + { +public: + CIclLoader(); + ~CIclLoader(); + void ConstructL(const TDesC& aFileName, TBool aUseUID, TBool aReplace); + const TWsGraphicId GetId(); + inline TInt FrameCount() const {return iTotalFrames;}; + inline TBool Ok() const {return !iFailed;}; +protected: + void RunL(); + TInt RunError(TInt aError); + void DoCancel(); +private: + void TestL(TInt aCondition); + CImageDecoder* iDecoder; + CWsGraphicBitmapAnimation* iTestAnimation; + TLogMessageText iTestLog; + TBool iUseUID; + TBool iReplace; + RPointerArray iFrames; + TInt iTotalFrames; + void NextL(); + RFs iFs; + TBool iFailed; + }; + +CIclLoader::CIclLoader(): + CActive(CActive::EPriorityLow) + { + CActiveScheduler::Add(this); + } + +CIclLoader::~CIclLoader() + { + if (iTestAnimation) + { + delete iTestAnimation; + iTestAnimation = NULL; + } + if (iDecoder) + { + delete iDecoder; + iDecoder = NULL; + } + iFrames.ResetAndDestroy(); + iFs.Close(); + } + +const TWsGraphicId CIclLoader::GetId() + { + if (iTestAnimation) + { + return iTestAnimation->Id(); + } + else + { + TWsGraphicId id(KDummyGraphicId); + return id; + } + } + +void CIclLoader::TestL(TInt aCondition) + { + if(!aCondition) + { + RWsSession rWs; + User::LeaveIfError(rWs.Connect()); + TBuf buf; + _LIT(Fail,"AUTO Failed in WsGraphics Test : CIclLoader"); + buf.Append(Fail); + buf.Append(iTestLog); + rWs.LogMessage(buf); + rWs.Flush(); + rWs.Close(); + User::Leave(KErrGeneral); + } + } + +void CIclLoader::ConstructL(const TDesC& aFileName, TBool aUseUID,TBool aReplace) + { + iUseUID = aUseUID; + iReplace = aReplace; + + User::LeaveIfError(iFs.Connect()); + + iDecoder = CImageDecoder::FileNewL(iFs,aFileName); + if(!iDecoder->IsImageHeaderProcessingComplete()) + { + User::Leave(KErrGeneral); + } + NextL(); + } + +void CIclLoader::NextL() + { + // Load a frame from the animation + if (iDecoder && (iDecoder->FrameCount() > iFrames.Count())) + { + const TFrameInfo& info = iDecoder->FrameInfo(iFrames.Count()); + CWsGraphicBitmapAnimation::CFrame* frame = CWsGraphicBitmapAnimation::CFrame::NewL(); + CleanupStack::PushL(frame); + iFrames.AppendL(frame); + CleanupStack::Pop(frame); + frame->SetFrameInfo(info); + TFrameInfo copiedInfo = frame->FrameInfo(); + TestL(info.iFlags==copiedInfo.iFlags); + + TSize bmpSize(info.iFrameCoordsInPixels.Size()); + CFbsBitmap* bitmap = new(ELeave) CFbsBitmap; + frame->SetBitmap(bitmap); //takes ownership + User::LeaveIfError(bitmap->Create(bmpSize,info.iFrameDisplayMode)); + + TDisplayMode maskDispMode; + CFbsBitmap* mask = new(ELeave) CFbsBitmap; + frame->SetMask(mask); //takes ownership + if((TFrameInfo::EAlphaChannel|TFrameInfo::ETransparencyPossible) & info.iFlags) + { + maskDispMode = EGray256; + } + else + { + maskDispMode = EGray2; + } + + User::LeaveIfError(mask->Create(info.iFrameCoordsInPixels.Size(),maskDispMode)); + iDecoder->Convert(&iStatus,*bitmap,*mask,iFrames.Count()-1); + + SetActive(); + } + + // if a frame loaded + else if(iFrames.Count()) + { + _LIT_SECURE_ID(KTestSecId,0x12345678); + + // The extra code around the NewL is checking that no heap failures occur when + // creating the CWsGraphicBitmapAnimation + TInt failRate = 1; + const TInt KMaxIteration = 1000; + for (;failRate < KMaxIteration; failRate++) + { + __UHEAP_RESET; + __UHEAP_SETFAIL(RHeap::EDeterministic,failRate); + __UHEAP_MARK; + + TInt err = KErrGeneral; + if (iUseUID) + {// creating animation using UID + TRAP(err, iTestAnimation = CWsGraphicBitmapAnimation::NewL(KUidTestAnimation,iFrames.Array());); + } + else + {// creating using transient ID allocated by wserv + TRAP(err, iTestAnimation = CWsGraphicBitmapAnimation::NewL(iFrames.Array());); + } + + TestL((err==KErrNone || err==KErrNoMemory)); + + if (err != KErrNone) + { + __UHEAP_MARKEND; + TestL(iTestAnimation == NULL); + } + else + { + break; + } + } + __UHEAP_RESET; + TestL(iTestAnimation != NULL); + TestL(failRate > 1); //Ensure the udeb version of euser.dll is available (i.e. that the rom was build with the -D_DEBUG option) + RDebug::Printf("TWSGraphicTest.CPP: Heapfailure loop completed after %d allocs.", failRate-1); + + // if testing that a created animation can be replaced + if (iReplace) + { + // replace the animation just created with another + TWsGraphicId testId = iTestAnimation->Id(); + TInt testInt = testId.Id(); + + CWsGraphicBitmapAnimation* testReplacement = CWsGraphicBitmapAnimation::NewL(testId,iFrames.Array()); + + delete iTestAnimation; + + iTestAnimation = testReplacement; + + TestL(iTestAnimation->Id().Id()==testInt); + } + + delete iDecoder; + iDecoder = NULL; + iTotalFrames = iFrames.Count(); + iFrames.ResetAndDestroy(); + + // test that the animation methods can be used without error + TestL(iTestAnimation->ShareGlobally()==KErrNone); + TestL(iTestAnimation->UnShareGlobally()==KErrNone); + TestL(iTestAnimation->Share(KTestSecId)==KErrNone); + TestL(iTestAnimation->UnShare(KTestSecId)==KErrNone); + TestL(iTestAnimation->UnShare(KTestSecId)==KErrNotFound); + } + } + +void CIclLoader::RunL() + { + if (iStatus == KErrNone) + { + NextL(); + } + else + { + TestL(EFalse); // kill the test + } + } + +TInt CIclLoader::RunError(TInt aError) + { + RDebug::Printf("CIclLoader::RunError, aError %d", aError); + iFailed = ETrue; + return KErrNone; + } + +void CIclLoader::DoCancel() + { + if(iDecoder) + { + iDecoder->Cancel(); + } + } + +// Class for testing CWsGraphics +class CActiveWait; +class CRedrawAO; +class CWsGraphicBase : public CBase + { +public: + CWsGraphicBase(); + CWsGraphicBase(TInt aScreenNumber); + ~CWsGraphicBase(); + void ConstructL(); + void DoTestL(TInt aTestNo); + void RedrawMe(TRect aRedrawRect, TInt aFrame); + + enum TTestCases + { + ETestCreateGraphicUID, + ETestCreateGraphicID, + ETestUpdateGraphic, + ETestDeleteGraphic, + ETestDrawInvalideBitmapID, + ETestDrawGraphic, + ETestDrawGraphicID, + ETestDrawGraphicCompare, + ETestDrawGraphicSessionHandle, + ETestDrawAnimatedGraphicUID, + ETestDrawAnimatedGraphicID, + ETestCreateMsgGraphicMsgBuf, + ETestDrawReplaceGraphicID, + ETestDrawInvalidAnimationID, + ETestDrawSharedGraphic, + // additional cases to be added here, before ETestMaxNumberOfTests + ETestMaxNumberOfTests + }; + +private : + void PrepGc(); + void RetireGc(); + void RunAnimation(TInt aFrameCount); + void LaunchNewProcessL(const TDesC& aExecutable, TBool aShare); + inline void TestForIdenticalBitmaps(){Test(iScreen->RectCompare(iPosition1,iPosition2));}; + inline void TestForDifferentBitmaps(){Test(!iScreen->RectCompare(iPosition1,iPosition2));}; + void Test(TInt aCondition); + void DoTestCreateGraphicUidL(); + void DoTestCreateGraphicIdL(); + void DoTestUpdateGraphicL(); + void DoTestDrawSharedGraphicL(); + void DoTestDeleteGraphicL(); + void DoTestDrawGraphicL(); + void DoTestDrawGraphicIDL(); + void DoTestDrawGraphicCompareL(); + void DoTestDrawAnimatedGraphicUIDL(); + void DoTestDrawAnimatedGraphicIDL(); + void DoTestDrawGraphicSessionHandleL(); + void DoTestCreateMsgGraphicMsgBufL(); + void DoTestDrawReplaceGraphicIDL(); + void DoTestDrawInvalidBitmapIDL(); + void DoTestDrawInvalidAnimationIDL(); +private : + TInt iScreenNumber; + CWindowGc *iGc; + RWsSession iWs; + RWindowGroup *iGroupWin; + CWsScreenDevice *iScreen; + RWindow *iWin; + TLogMessageText iTestLog; + TRect iPosition1; + TRect iPosition2; + CActiveWait* iTimer; + CRedrawAO* iRedrawListener; + TWsGraphicId iAnimId; + TWsGraphicAnimation iAnimData; + }; + +// +// class CRedrawAO +// request & listen for redraw events from wserv +// if a redraw event is received, notify the observing class +// +class CRedrawAO : public CActive + { +public: + static CRedrawAO* NewL(RWsSession* aWs); + ~CRedrawAO(); + // from CActive: + void RunL(); + void DoCancel(); + TInt RunError(TInt aError); + void RequestRedraw(); + inline void SetFrameCount(TInt aCount){iFrameCount = aCount;}; + inline TInt GetFrameCount() const {return iFrameCount;}; +private: + CRedrawAO(RWsSession* aWs); + void ConstructL(); +private: + RWsSession* iWs; + TInt iFrameCount; + }; + +CRedrawAO* CRedrawAO::NewL(RWsSession* aWs) + { + CRedrawAO* self = new (ELeave) CRedrawAO(aWs); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +CRedrawAO::CRedrawAO(RWsSession* aWs): +CActive(CActive::EPriorityHigh), iWs(aWs) + { + CActiveScheduler::Add(this); + } + +CRedrawAO::~CRedrawAO() + { + // cleanup + Cancel(); + } + +void CRedrawAO::ConstructL() + { + // nothing to construct + } + +void CRedrawAO::RunL() + { + // leave if status is not ok. RunError will process this result + User::LeaveIfError(iStatus.Int()); + TWsRedrawEvent redraw; + iWs->GetRedraw(redraw); + TUint redrawHandle = redraw.Handle(); + if (redrawHandle == ENullWsHandle) + { + User::Leave(KErrBadHandle); // sanity check the client handle isn't a dummy + } + else if (redrawHandle) + { + --iFrameCount; + (reinterpret_cast(redrawHandle))->RedrawMe(redraw.Rect(), iFrameCount); // handle the redraw signal + } + + if (iFrameCount > 0) + { + RequestRedraw(); + } + } + +TInt CRedrawAO::RunError(TInt aError) + { + if (aError != KErrBadHandle) + { + RequestRedraw(); + } + return KErrNone; + } + +void CRedrawAO::DoCancel() + { + // kill all outstanding asynch. wserv requests + iWs->RedrawReadyCancel(); + iFrameCount = KErrNone; + } + +void CRedrawAO::RequestRedraw() + { + if (!IsActive()) + { + iWs->RedrawReady(&iStatus); + SetActive(); + } + } + +// + +class CActiveWait : public CActive + { +public: + static CActiveWait* NewL(); + ~CActiveWait(); + void Wait(TInt aDelay); + // From CActive: + void RunL(); + void DoCancel(); + TInt RunError(TInt aError); +protected: + CActiveWait(); + void ConstructL(); +protected: + RTimer iTimer; + TTime iFromTime; + }; + +CActiveWait* CActiveWait::NewL() + { + CActiveWait* self = new (ELeave) CActiveWait; + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +void CActiveWait::ConstructL() + { + User::LeaveIfError(iTimer.CreateLocal()); + CActiveScheduler::Add(this); + } + +CActiveWait::CActiveWait() : CActive(CActive::EPriorityStandard) + { + iFromTime.HomeTime(); + } + +CActiveWait::~CActiveWait() + { + Cancel(); + iTimer.Close(); + } + +void CActiveWait::DoCancel() + { + iTimer.Cancel(); + CActiveScheduler::Stop(); + } + +void CActiveWait::RunL() + { + CActiveScheduler::Stop(); + } + +TInt CActiveWait::RunError(TInt aError) + { + return aError; // exists so a break point can be placed on it. + } + +void CActiveWait::Wait(TInt aDelay) + + + { + iTimer.After(iStatus, aDelay); + SetActive(); + CActiveScheduler::Start(); + } + +// + +CWsGraphicBase::CWsGraphicBase(TInt aScreenNumber) : iScreenNumber(aScreenNumber), iAnimId(KDummyGraphicId) + { + } + +CWsGraphicBase::~CWsGraphicBase() + { + iWin->Close(); + delete iWin; + delete iScreen; + delete iGc; + delete iGroupWin; + iWs.Close(); + if (iTimer) + { + delete iTimer; + iTimer = NULL; + } + if (iRedrawListener) + { + delete iRedrawListener; + iRedrawListener = NULL; + } + } + +void CWsGraphicBase::ConstructL() + { + User::LeaveIfError(iWs.Connect()); + iScreen=new(ELeave) CWsScreenDevice(iWs); + User::LeaveIfError(iScreen->Construct(iScreenNumber)); + + TSize screenSize = iScreen->SizeInPixels(); + iPosition1.SetRect(0,0,screenSize.iWidth/2,screenSize.iHeight); + iPosition2.SetRect(screenSize.iWidth/2,0,screenSize.iWidth,screenSize.iHeight); + + iTimer = CActiveWait::NewL(); + iRedrawListener = CRedrawAO::NewL(&iWs); + + iGc=new(ELeave) CWindowGc(iScreen); + User::LeaveIfError(iGc->Construct()); + iGroupWin=new(ELeave) RWindowGroup(iWs); + iGroupWin->Construct(1); + + iWin=new(ELeave) RWindow(iWs); + iWin->Construct(*iGroupWin, (TUint32)this); + iWin->EnableRedrawStore(EFalse); // disable the redraw store for these tests + iWin->SetRequiredDisplayMode(EColor256); + iWin->SetExtent(TPoint(0,0),iScreen->SizeInPixels()); + iWin->Activate(); + iWin->BeginRedraw(); + iWin->EndRedraw(); + iWs.Flush(); + } + +// To test whether sharing of graphics works a new process has to be launched. +// The argument is set whether the graphic should be shared or not. +void CWsGraphicBase::LaunchNewProcessL(const TDesC& aExecutable, TBool aShare) + { + TBuf<128> args; + RProcess pr; + TRequestStatus status; + + if (aShare) + { + args.Append(KShare); + } + else + { + args.Append(KNoShare); + } + + User::LeaveIfError(pr.Create(aExecutable,args)); + pr.Logon(status); + pr.Resume(); + User::WaitForRequest(status); + pr.Close(); + + if (status != KErrNone) + { + User::Leave(status.Int()); + } + } + +// +// CWsGraphicBase::PrepGc +// activate a gc & clear the two rects +// +void CWsGraphicBase::PrepGc() + { + iGc->Activate(*iWin); + iWin->Invalidate(); + iWin->BeginRedraw(); + iGc->Clear(iPosition1); + iGc->Clear(iPosition2); + iWs.Flush(); + } + +// +// CWsGraphicBase::RetireGc +// deactivate a gc & flush any outstanding RWindow requests +void CWsGraphicBase::RetireGc() + { + iGc->Deactivate(); + iWin->EndRedraw(); + iWs.Flush(); + } + +// +// CWsGraphicBase::RedrawMe +// called from the redraw listener AO, triggered by a redraw event +// Invalidates the area requiring a redraw & +// initiates a redraw of the CWsGraphicBitmapAnimation's window +// +void CWsGraphicBase::RedrawMe(TRect aRedrawRect, TInt aFrame) + { + // do draw with next frame + if (iAnimData.IsPlaying()) + { + iGc->Activate(*iWin); + iWin->Invalidate(aRedrawRect); + iWin->BeginRedraw(); + iWs.Flush(); + iGc->DrawWsGraphic(iAnimId,iPosition1,iAnimData.Pckg()); + iGc->Deactivate(); + iWin->EndRedraw(); + iWs.Flush(); + + // check for last frame + if (aFrame == 0) + { + iTimer->Cancel(); + } + } + } + +/** + @SYMTestCaseID GRAPHICS-WSERV-0001 + + @SYMPREQ PREQ1246 + + @SYMTestCaseDesc Create Globally and Locally Shared Graphic Bitmaps from UIDs. + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions First test that TWsGraphicIds can be created from UIDs. Then create CWsGraphicBitmap objects through + CWsGraphicBitmap::NewL, passing a UID from a TWsGraphicId. Two different objects are created + 1. Globally shared available to all applications + 2. Locally shared available to selected clients + + @SYMTestExpectedResults The CWsGraphicBitmap objects are created and no errors are reported. + */ +void CWsGraphicBase::DoTestCreateGraphicUidL() + { + iTestLog.Append(_L("CreateGraphicUid")); + + _LIT_SECURE_ID(KTestSecId,0x12345678); + + // Test the creation of TWsGraphicIds from UIDs + TUid uid1 = {0x10000001}; + TUid uid2 = {0x10000002}; + + TWsGraphicId twsGraphicId1(uid1); + Test(twsGraphicId1.Uid()==uid1); + + TWsGraphicId twsGraphicId2(uid2); + Test(twsGraphicId2.Uid()==uid2); + + TWsGraphicId twsGraphicId3(twsGraphicId2); + Test(twsGraphicId3.Uid()==uid2); + + TWsGraphicId twsGraphicId4(1); + twsGraphicId4.Set(uid1); + Test(twsGraphicId4.Uid()==uid1); + + // Create globally shared CWsGraphicBitmap + CFbsBitmap bitmap1; + CFbsBitmap mask1; + + TSize screenSize = iScreen->SizeInPixels(); + bitmap1.Create(screenSize,iScreen->DisplayMode()); + mask1.Create(bitmap1.SizeInPixels(),iScreen->DisplayMode()); + + CWsGraphicBitmap* bTest = CWsGraphicBitmap::NewL(twsGraphicId1.Uid(), &bitmap1,&mask1); + Test(bTest->IsActive()); + + TWsGraphicId tid1 = bTest->Id(); + Test(tid1.Uid()==uid1); + + Test(bTest->ShareGlobally()==KErrNone); + + // Create local shared CWsGraphicBitmap + CFbsBitmap bitmap2; + CFbsBitmap mask2; + + bitmap2.Create(screenSize,iScreen->DisplayMode()); + mask2.Create(bitmap2.SizeInPixels(),iScreen->DisplayMode()); + + CWsGraphicBitmap* bTest2 = CWsGraphicBitmap::NewL(twsGraphicId2.Uid(), &bitmap2,&mask2); + + TWsGraphicId tid2 = bTest2->Id(); + Test(tid2.Uid()==uid2); + + Test(bTest2->Share(KTestSecId)==KErrNone); + + // Test the unsharing of the CWsGraphicBitmaps + Test(bTest->UnShareGlobally()==KErrNone); + Test(bTest2->UnShare(KTestSecId)==KErrNone); + Test(bTest2->UnShare(KTestSecId)==KErrNotFound); + + delete bTest; + delete bTest2; + } + +/** + @SYMTestCaseID GRAPHICS-WSERV-0002 + + @SYMPREQ PREQ1246 + + @SYMTestCaseDesc Create Globally and Locally Shared Graphic Bitmaps. + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions First test that TWsGraphicIds can be created from IDs. Then create CWsGraphicBitmap objects through + CWsGraphicBitmap::NewL. Two different objects are created + 1. Globally shared available to all applications + 2. Locally shared available to selected clients + + @SYMTestExpectedResults The CWsGraphicBitmap objects are created and no errors are reported. + */ +void CWsGraphicBase::DoTestCreateGraphicIdL() + { + iTestLog.Append(_L("CreateGraphicId")); + + _LIT_SECURE_ID(KTestSecId,0x12345678); + + // Test creating TWsGraphicIds from ids first + TUid uid1 = {0x10000001}; + + TWsGraphicId twsGraphicId1(uid1); + + twsGraphicId1.Set(9); + Test(twsGraphicId1.Id()==9); + + TWsGraphicId twsGraphicId2(twsGraphicId1); + Test(twsGraphicId2.Id()==9); + + TWsGraphicId twsGraphicId3(7); + Test(twsGraphicId3.Id()==7); + + // Create globally shared CWsGraphicBitmap + CFbsBitmap bitmap1; + CFbsBitmap mask1; + + TSize screenSize = iScreen->SizeInPixels(); + bitmap1.Create(screenSize,iScreen->DisplayMode()); + mask1.Create(bitmap1.SizeInPixels(),iScreen->DisplayMode()); + + CWsGraphicBitmap* bTest = CWsGraphicBitmap::NewL(&bitmap1,&mask1); + Test(bTest->IsActive()); + + TWsGraphicId tid1 = bTest->Id(); + + Test(bTest->ShareGlobally()==KErrNone); + + // Create local shared CWsGraphicBitmap + CFbsBitmap bitmap2; + CFbsBitmap mask2; + + bitmap2.Create(screenSize,iScreen->DisplayMode()); + mask2.Create(bitmap2.SizeInPixels(),iScreen->DisplayMode()); + + CWsGraphicBitmap* bTest2 = CWsGraphicBitmap::NewL(&bitmap2,&mask2); + + TWsGraphicId tid2 = bTest2->Id(); + + Test(bTest2->Share(KTestSecId)==KErrNone); + + // Test the unsharing of the CWsGraphicBitmaps + Test(bTest->UnShareGlobally()==KErrNone); + Test(bTest2->UnShare(KTestSecId)==KErrNone); + Test(bTest2->UnShare(KTestSecId)==KErrNotFound); + + delete bTest2; + delete bTest; + } + + /** + @SYMTestCaseID GRAPHICS-WSERV-0003 + + @SYMPREQ PREQ1246 + + @SYMTestCaseDesc Update an existing graphic bitmap with new data. + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions The test calls CWsGraphicBitmap::NewL method with new data passed to the CWsGraphicBitmap object. + + + @SYMTestExpectedResults The CWsGraphicBitmap object is updated with no errors reported. + */ +void CWsGraphicBase::DoTestUpdateGraphicL() + { + iTestLog.Append(_L("UpdateGraphic")); + + CFbsBitmap bitmap1; + CFbsBitmap mask1; + CFbsBitmap bitmap2; + CFbsBitmap mask2; + + TSize screenSize = iScreen->SizeInPixels(); + bitmap1.Create(screenSize,iScreen->DisplayMode()); + mask1.Create(bitmap1.SizeInPixels(),iScreen->DisplayMode()); + + CWsGraphic* bTest = CWsGraphicBitmap::NewL(&bitmap1,&mask1); + + bitmap2.Create(screenSize,iScreen->DisplayMode()); + mask2.Create(bitmap2.SizeInPixels(),iScreen->DisplayMode()); + + TWsGraphicId tid1 = bTest->Id(); + TInt testInt = tid1.Id(); + + CWsGraphic* testReplacement = CWsGraphicBitmap::NewL(tid1, &bitmap2,&mask2); + + delete bTest; + bTest = testReplacement; + + Test(bTest->Id().Id()==testInt); + + delete bTest; + } + + + + /** + @SYMTestCaseID GRAPHICS-WSERV-0004 + + @SYMPREQ PREQ1246 + + @SYMTestCaseDesc Try to delete an existing graphic. + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions The test app calls CWsGraphic::Destroy() method, + + @SYMTestExpectedResults The CWsGraphicBitmap object is removed from the Window Server with no + errors reported + */ +void CWsGraphicBase::DoTestDeleteGraphicL() + { + iTestLog.Append(_L("DeleteGraphic")); + + CFbsBitmap bitmap1; + CFbsBitmap mask1; + + TSize screenSize = iScreen->SizeInPixels(); + bitmap1.Create(screenSize,iScreen->DisplayMode()); + mask1.Create(bitmap1.SizeInPixels(),iScreen->DisplayMode()); + + CWsGraphic* bTest = CWsGraphicBitmap::NewL(&bitmap1,&mask1); + + bTest->Destroy(); + + Test(!bTest->IsActive()); + + delete bTest; + } + + /** + @SYMTestCaseID GRAPHICS-WSERV-0005 + + @SYMPREQ PREQ1246 + + @SYMTestCaseDesc Check a bitmap is not drawn if the bitmap and mask it uses are invalid + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions The test app creates a valid and invalid bitmap and attempts to draw them + + @SYMTestExpectedResults The valid bitmap is drawn but the invalid bitmap is not drawn + */ +void CWsGraphicBase::DoTestDrawInvalidBitmapIDL() + { + iTestLog.Append(_L("DrawInvalidBitmapID")); + + CFbsBitmap bitmap1; + CFbsBitmap mask1; + CFbsBitmap *bitmap2 = NULL; + CFbsBitmap *mask2 = NULL; + + User::LeaveIfError(bitmap1.Load(MY_TEST_BITMAP,0)); + mask1.Create(bitmap1.SizeInPixels(),iScreen->DisplayMode()); + + // valid bitmap + CWsGraphicBitmap* bTest = CWsGraphicBitmap::NewL(&bitmap1,&mask1); + + // invalid bitmap + CWsGraphicBitmap* bTest2 = CWsGraphicBitmap::NewL(bitmap2,mask2); + + PrepGc(); + iGc->DrawWsGraphic(bTest->Id(),iPosition1); + iGc->DrawWsGraphic(bTest2->Id(),iPosition2); + RetireGc(); + + // compare the graphic in both positions, should only be graphic in position 1 + TestForDifferentBitmaps(); + + delete bTest2; + delete bTest; + } + + /** + @SYMTestCaseID GRAPHICS-WSERV-0006 + + @SYMPREQ PREQ1246 + + @SYMTestCaseDesc Draw a graphic within a rectangle on the screen, then try to draw with a non-existant graphic + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions The test app calls CWindowGC::DrawWsGraphic() method using the TWGraphicId object, to draw within a rectangle on the screen + + @SYMTestExpectedResults The graphic is drawn on the screen with no errors reported. Drawing with a non-existant graphic causes + nothing to be drawn and no error reported + */ +void CWsGraphicBase::DoTestDrawGraphicL() + { + iTestLog.Append(_L("DrawGraphic")); + + _LIT8(KTestData,"HelloWorld"); + + CFbsBitmap bitmap1; + CFbsBitmap mask1; + + User::LeaveIfError(bitmap1.Load(MY_TEST_BITMAP,0)); + mask1.Create(bitmap1.SizeInPixels(),iScreen->DisplayMode()); + + CWsGraphicBitmap* bTest = CWsGraphicBitmap::NewL(&bitmap1,&mask1); + + PrepGc(); + iGc->DrawWsGraphic(bTest->Id(),iPosition1,KTestData); + TWsGraphicId twsGraphicId1(KDummyGraphicId); // create unrecognised wsbitmap id & attempt to draw it + iGc->DrawWsGraphic(twsGraphicId1,iPosition2,KTestData); + RetireGc(); + + // compare the graphic in both positions, should only be graphic in position 1 + TestForDifferentBitmaps(); + + delete bTest; + } + + /** + @SYMTestCaseID GRAPHICS-WSERV-0007 + + @SYMPREQ PREQ1246 + + @SYMTestCaseDesc Draw a graphic using a transient ID within a rectangle on the screen + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions The test app calls CWindowGC::DrawWsGraphic() using a TWsGraphic object, to draw within + a rectangle on the screen + + @SYMTestExpectedResults The graphic is drawn. + */ +void CWsGraphicBase::DoTestDrawGraphicIDL() + { + iTestLog.Append(_L("DrawGraphicID")); + + CFbsBitmap bitmap1; + CFbsBitmap mask1; + + User::LeaveIfError(bitmap1.Load(MY_TEST_BITMAP,0)); + mask1.Create(bitmap1.SizeInPixels(),iScreen->DisplayMode()); + + CWsGraphicBitmap* bTest = CWsGraphicBitmap::NewL(&bitmap1,&mask1); + + PrepGc(); + iGc->DrawWsGraphic(bTest->Id(),iPosition1); + RetireGc(); + + // compare the graphic in both positions, should only be graphic in position 1 + TestForDifferentBitmaps(); + + delete bTest; + } + + + + /** + @SYMTestCaseID GRAPHICS-WSERV-0008 + + @SYMPREQ PREQ1246 + + @SYMTestCaseDesc Draw a graphic in two different rectangles on the screen and compare them + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions The test app calls CWindowGC::DrawWsGraphic() using the TWsGraphic object, to draw a known bitmap + rectangle on the screen twice in different places. The bitmaps are then compared. + + @SYMTestExpectedResults The two bitmaps are identical + */ +void CWsGraphicBase::DoTestDrawGraphicCompareL() + { + iTestLog.Append(_L("DrawGraphicCompare")); + + _LIT8(KTestData,"HelloWorld"); + + CFbsBitmap bitmap1; + CFbsBitmap mask1; + + CFbsBitmap bitmap2; + CFbsBitmap mask2; + + User::LeaveIfError(bitmap1.Load(MY_TEST_BITMAP,0)); + mask1.Create(bitmap1.SizeInPixels(),iScreen->DisplayMode()); + + User::LeaveIfError(bitmap2.Load(MY_TEST_BITMAP,0)); + mask2.Create(bitmap2.SizeInPixels(),iScreen->DisplayMode()); + + CWsGraphicBitmap* bTest = CWsGraphicBitmap::NewL(&bitmap1,&mask1); + CWsGraphicBitmap* bTest2 = CWsGraphicBitmap::NewL(&bitmap2,&mask2); + + PrepGc(); + //draw the graphic in the two different rectangles + iGc->DrawWsGraphic(bTest->Id(),iPosition1,KTestData); + iGc->DrawWsGraphic(bTest2->Id(),iPosition2,KTestData); + RetireGc(); + + // compare the graphic in both positions. Contents of each rect should be identical + TestForIdenticalBitmaps(); + + delete bTest2; + delete bTest; + } + + /** + @SYMTestCaseID GRAPHICS-WSERV-0009 + + @SYMPREQ PREQ1246 + + @SYMTestCaseDesc Draw a global and local graphic in two different rectangles on the screen and compare them + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions The test app calls CWindowGC::DrawGraphic() using the TWsGraphic object, to draw a known + global and local bitmap rectangle on the screen twice in different places. The bitmaps are then compared. + + @SYMTestExpectedResults The two bitmaps are identical + */ +void CWsGraphicBase::DoTestDrawGraphicSessionHandleL() + { + iTestLog.Append(_L("DrawGraphicSessionHandle")); + _LIT_SECURE_ID(KTestSecId,0x12345678); + + // test TWsGraphicControlState first + _LIT8(KTestData,"HelloWorld"); + + CFbsBitmap bitmap1; + CFbsBitmap mask1; + + CFbsBitmap bitmap2; + CFbsBitmap mask2; + + User::LeaveIfError(bitmap1.Load(MY_TEST_BITMAP,0)); + mask1.Create(bitmap1.SizeInPixels(),iScreen->DisplayMode()); + + User::LeaveIfError(bitmap2.Load(MY_TEST_BITMAP,0)); + mask2.Create(bitmap2.SizeInPixels(),iScreen->DisplayMode()); + + CWsGraphicBitmap* bTest = CWsGraphicBitmap::NewL(&bitmap1,&mask1); + CWsGraphicBitmap* bTest2 = CWsGraphicBitmap::NewL(&bitmap2,&mask2); + + Test(bTest->ShareGlobally()==KErrNone); + Test(bTest2->Share(KTestSecId)==KErrNone); + + PrepGc(); + iGc->DrawWsGraphic(bTest->Id(),iPosition1,KTestData); + iGc->DrawWsGraphic(bTest2->Id(),iPosition2,KTestData); + RetireGc(); + + // compare the graphic in both positions. Contents of each rect should be identical + TestForIdenticalBitmaps(); + + delete bTest2; + delete bTest; + } + + /** + @SYMTestCaseID GRAPHICS-WSERV-0010 + + @SYMPREQ PREQ1246 + + @SYMTestCaseDesc Check an animation can be constructed using a UID, manipulated and then drawn + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions The test app creates CWsGraphicBitmapAnimation object via a UID and then draws the object to the screen + + @SYMTestExpectedResults The object is drawn + */ +void CWsGraphicBase::DoTestDrawAnimatedGraphicUIDL() + { + iTestLog.Append(_L("DrawAnimatedGraphicUID")); + + // test TWsGraphicAnimation first + iAnimData.Play(EFalse); + + // load the animation via a UID + CIclLoader* iclLoader; + iclLoader = new(ELeave) CIclLoader(); + iclLoader->ConstructL(KSymBallFile,ETrue,EFalse); // this is actually an asynchronous operation, so we give it a chance to execute below + + while (iclLoader->Ok() && iclLoader->GetId().Id() == KDummyGraphicId) + { + iTimer->Wait(1000); + } + + Test(iclLoader->Ok()); // fail test if iclLoder experienced problems + + iAnimId = iclLoader->GetId(); + + // animation is ready to be drawn. draw to the 1st position only + PrepGc(); + iGc->DrawWsGraphic(iAnimId,iPosition1,iAnimData.Pckg()); + RetireGc(); + + // run the animation + RunAnimation(iclLoader->FrameCount()); + + // compare the graphic in both positions. + TestForDifferentBitmaps(); + + iTimer->Cancel(); + iclLoader->Cancel(); + delete iclLoader; + } + + /** + @SYMTestCaseID GRAPHICS-WSERV-0011 + + @SYMPREQ PREQ1246 + + @SYMTestCaseDesc Check an animation can be constructed using an ID, manipulated and then drawn + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions The test app creates CWsGraphicBitmapAnimation object via an ID and then draws the object to the screen + + @SYMTestExpectedResults The object is drawn + */ +void CWsGraphicBase::DoTestDrawAnimatedGraphicIDL() + { + iTestLog.Append(_L("DrawAnimatedGraphicID")); + iAnimData.Play(ETrue); + iAnimData.Play(ETrue); + Test(iAnimData.Loops()); + iAnimData.Pause(); + Test(!iAnimData.IsPlaying()); + Test(iAnimData.IsPaused()); + iAnimData.Pause(); + Test(iAnimData.Loops()); + iAnimData.Play(EFalse); + Test(!iAnimData.Loops()); + Test(!iAnimData.IsStopping()); + Test(!iAnimData.IsStopped()); + + // load the animation via an ID + CIclLoader* iclLoader; + iclLoader = new(ELeave) CIclLoader(); + iclLoader->ConstructL(KSymBallFile,EFalse,EFalse); + + while (iclLoader->GetId().Id() == KDummyGraphicId) + { + iTimer->Wait(1000); + } + iAnimId = iclLoader->GetId(); + + PrepGc(); + iGc->DrawWsGraphic(iAnimId,iPosition1,iAnimData.Pckg()); + RetireGc(); + + // run the animation + RunAnimation(iclLoader->FrameCount()); + + // compare the graphic in both positions + TestForDifferentBitmaps(); + + iAnimData.Stop(ETrue); + Test(iAnimData.IsStopped()); + iAnimData.Pause(); + iAnimData.Play(EFalse); + iAnimData.Stop(EFalse); + Test(!iAnimData.IsStopped()); + + iTimer->Cancel(); + iclLoader->Cancel(); + delete iclLoader; + } + + /** + @SYMTestCaseID GRAPHICS-WSERV-0012 + + @SYMPREQ PREQ1246 + + @SYMTestCaseDesc Check an animation can be constructed and then replaced, manipulated and then drawn + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions The test app creates CWsGraphicBitmapAnimation object, the replaces it, and then draws the object + to the screen + + @SYMTestExpectedResults The object is drawn + */ +void CWsGraphicBase::DoTestDrawReplaceGraphicIDL() + { + // test TWsGraphicControlStateTimed first + iTestLog.Append(_L("DrawAnimatedGraphicID")); + _LIT8(KTestData,"HelloWorld"); + iAnimData.Stop(ETrue); + + // load and replace the animation + CIclLoader* iclLoader; + iclLoader = new(ELeave) CIclLoader(); + iclLoader->ConstructL(KSymBallFile,false,true); + + while (iclLoader->GetId().Id() == KDummyGraphicId) + { + iTimer->Wait(1000); + } + iAnimId = iclLoader->GetId(); + + // draw the animation in two positions + PrepGc(); + iGc->DrawWsGraphic(iAnimId,iPosition1,KTestData); + RetireGc(); + + // run the animation + RunAnimation(iclLoader->FrameCount()); + + // compare the graphic in both positions + // Expect identical, as the command buffer used in position1 animation is invalid, therefore never drawn + TestForIdenticalBitmaps(); + + iTimer->Cancel(); + iclLoader->Cancel(); + delete iclLoader; + } + + /** + @SYMTestCaseID GRAPHICS-WSERV-0013 + + @SYMPREQ PREQ1246 + + @SYMTestCaseDesc Check the creation and manipulation of an RWsGraphicMsgBuf object + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions Creates and manipulates an RWsGraphicMsgBuf object + + @SYMTestExpectedResults RWsGraphicMsgBuf functions correctly + */ +void CWsGraphicBase::DoTestCreateMsgGraphicMsgBufL() + { + iTestLog.Append(_L("CreateMsgGraphicMsgBuf")); + + _LIT(KNebraska,"Nebraska"); + _LIT8(KTesting,"Testing"); + RWsGraphicMsgBuf msgBuf; + msgBuf.CleanupClosePushL(); + msgBuf.Append(TUid::Uid(0x12345670),KTesting()); + msgBuf.Append(TUid::Uid(0x12345671),KNebraska()); + msgBuf.Append(TUid::Uid(0x12345670),KTesting()); + + Test(TUid::Uid(0x12345670)==msgBuf.TypeId(0)); + + msgBuf.Remove(0); + const TInt count = msgBuf.Count(); + Test(count == 2); + + iAnimData.Play(ETrue); + msgBuf.Append(iAnimData); + Test(msgBuf.Count() == 3); + + CleanupStack::Pop(); + + // load the animation via a UID + CIclLoader* iclLoader; + iclLoader = new(ELeave) CIclLoader(); + iclLoader->ConstructL(KSymBallFile,true,false); + + while (iclLoader->GetId().Id() == KDummyGraphicId) + { + iTimer->Wait(1000); + } + iAnimId = iclLoader->GetId(); + + PrepGc(); + iGc->DrawWsGraphic(iAnimId,iPosition1,msgBuf.Pckg()); + RetireGc(); + + // run the animation + RunAnimation(iclLoader->FrameCount()); + + // compare the graphic in both positions + TestForDifferentBitmaps(); + + iTimer->Cancel(); + iclLoader->Cancel(); + delete iclLoader; + msgBuf.Close(); + } + + + + /** + @SYMTestCaseID GRAPHICS-WSERV-0014 + + @SYMPREQ PREQ1246 + + @SYMTestCaseDesc Check an animation is not drawn if the command buffer it uses is invalid + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions The test app creates CWsGraphicBitmapAnimation object then draws the animation using + a valid and invalid command buffer + + @SYMTestExpectedResults The animation is drawn while using the valid command buffer but not drawn + when the command buffer is invalid + */ +void CWsGraphicBase::DoTestDrawInvalidAnimationIDL() + { + // test TWsGraphicControlStateTimed first, a valid command buffer + iTestLog.Append(_L("DrawInvalidAnimationID")); + iAnimData.Play(ETrue); + + // invalid command buffer + _LIT8(KTestData2,"12345678"); + + // load and replace the animation + CIclLoader* iclLoader; + iclLoader = new(ELeave) CIclLoader(); + iclLoader->ConstructL(KSymBallFile,false,false); + + while (iclLoader->GetId().Id() == KDummyGraphicId) + { + iTimer->Wait(1000); + } + iAnimId = iclLoader->GetId(); + + PrepGc(); + iGc->DrawWsGraphic(iAnimId,iPosition1,iAnimData.Pckg()); + iGc->DrawWsGraphic(iAnimId,iPosition2,KTestData2); + RetireGc(); + + // run the animation + RunAnimation(iclLoader->FrameCount()); + + // compare the graphic in both positions + TestForDifferentBitmaps(); + + iAnimData.Stop(ETrue); + iTimer->Cancel(); + iclLoader->Cancel(); + delete iclLoader; + } + + /** + @SYMTestCaseID GRAPHICS-WSERV-0015 + + @SYMPREQ PREQ1246 + + @SYMTestCaseDesc Check the sharing of graphics with other clients. + + @SYMTestPriority High + + @SYMTestStatus Implemented + + @SYMTestActions The test app creates CWsGraphicBitmap object an then tests the sharing of the object with + different clients + + @SYMTestExpectedResults The CWsGraphicBitmap object is shared correctly + */ +void CWsGraphicBase::DoTestDrawSharedGraphicL() + { + iTestLog.Append(_L("DrawSharedGraphic")); + _LIT_SECURE_ID(KTestSecId,0x10003a4b); + + TUid uid1 = {0x12000021}; + TWsGraphicId twsGraphicId1(uid1); + + CFbsBitmap bitmap1; + CFbsBitmap mask1; + + User::LeaveIfError(bitmap1.Load(MY_TEST_BITMAP,0)); + mask1.Create(bitmap1.SizeInPixels(),iScreen->DisplayMode()); + + CWsGraphicBitmap* bTest = CWsGraphicBitmap::NewL(twsGraphicId1.Uid(), &bitmap1,&mask1); + + // Try to draw the graphic in an client. Should fail as graphic is not shared + TRAPD(err, LaunchNewProcessL(KTestExe1, EFalse)); + Test(err == KErrNone); + + // Share the graphic globally and try to draw the graphic in an client. Should pass + Test(bTest->ShareGlobally()==KErrNone); + TRAP(err, LaunchNewProcessL(KTestExe2, ETrue)); + Test(err == KErrNone); + + // Unshare the graphic globally and try to draw the graphic in an client. Should fail + Test(bTest->UnShareGlobally()==KErrNone); + TRAP(err, LaunchNewProcessL(KTestExe3, EFalse)); + Test(err == KErrNone); + + // Share the graphic to a client and try to draw the graphic in the client. Should pass + Test(bTest->Share(KTestSecId)==KErrNone); + TRAP(err, LaunchNewProcessL(KTestExe4, ETrue)); + Test(err == KErrNone); + + // Unshare the graphic to a client and try to draw the graphic in the client. Should fail + Test(bTest->UnShare(KTestSecId)==KErrNone); + TRAP(err, LaunchNewProcessL(KTestExe5, EFalse)); + Test(err == KErrNone); + + delete bTest; + } + + +void CWsGraphicBase::DoTestL(TInt aTestNo) + { + switch (aTestNo) + { + case ETestCreateGraphicUID: + DoTestCreateGraphicUidL(); + break; + case ETestCreateGraphicID: + DoTestCreateGraphicIdL(); + break; + case ETestUpdateGraphic: + DoTestUpdateGraphicL(); + break; + case ETestDeleteGraphic: + DoTestDeleteGraphicL(); + break; + case ETestDrawInvalideBitmapID: + DoTestDrawInvalidBitmapIDL(); + break; + case ETestDrawGraphic: + DoTestDrawGraphicL(); + break; + case ETestDrawGraphicID: + DoTestDrawGraphicIDL(); + break; + case ETestDrawGraphicCompare: + DoTestDrawGraphicCompareL(); + break; + case ETestDrawGraphicSessionHandle: + DoTestDrawGraphicSessionHandleL(); + break; +#ifdef _DEBUG + // These tests require debug-only API to simulate OOM. Running + // the tests in non-debug environments invalidates the tests. + case ETestDrawAnimatedGraphicUID: + DoTestDrawAnimatedGraphicUIDL(); + break; + case ETestDrawAnimatedGraphicID: + DoTestDrawAnimatedGraphicIDL(); + break; + case ETestCreateMsgGraphicMsgBuf: + DoTestCreateMsgGraphicMsgBufL(); + break; + case ETestDrawReplaceGraphicID: + DoTestDrawReplaceGraphicIDL(); + break; + case ETestDrawInvalidAnimationID: + DoTestDrawInvalidAnimationIDL(); + break; +#endif + case ETestDrawSharedGraphic: + DoTestDrawSharedGraphicL(); + break; + } + RDebug::Print(iTestLog); + iTestLog.Delete(0,256); + } + +// writes out to WSERV.log if error +void CWsGraphicBase::Test(TInt aCondition) + { + if(!aCondition) + { + TBuf buf; + _LIT(Fail,"AUTO Failed in WsGraphics Test : "); + buf.Append(Fail); + buf.Append(iTestLog); + RDebug::Print(buf); + RProcess().Terminate(KErrGeneral); + } + } + +// +// CWsGraphicBase::RunAnimation +// Redraw event listener is launched & the +// animation is given a total of KAnimationRunTime (25 seconds) to run a single loop +// +void CWsGraphicBase::RunAnimation(TInt aFrameCount) + { + --aFrameCount; // account for the fact the initial frame is already displayed + iRedrawListener->SetFrameCount(aFrameCount); + iRedrawListener->RequestRedraw(); + iTimer->Wait(KAnimationRunTime); + if (iAnimData.IsPlaying()) + { + iAnimData.Stop(ETrue); + } + iRedrawListener->Cancel(); + iAnimData.Stop(EFalse); + Test(iRedrawListener->GetFrameCount() == 0); // ensure the animation ran through until last frame + } + +void MainL() + { + TInt testCount = KErrNone; + + //Read the argument from the command line for current screen number + TBuf<256> commandLine; + User::CommandLine(commandLine); + TLex lex(commandLine); + lex.NextToken(); + lex.SkipSpace(); + TInt screenNumber=(TInt)lex.Get(); + + CActiveScheduler* activeScheduler=new(ELeave) CActiveScheduler; + CActiveScheduler::Install(activeScheduler); + CleanupStack::PushL(activeScheduler); + + CWsGraphicBase testBase(screenNumber); + testBase.ConstructL(); + + // run through all the tests + while (testCount < CWsGraphicBase::ETestMaxNumberOfTests) + { + testBase.DoTestL(testCount); + testCount++; + } + + CleanupStack::PopAndDestroy(activeScheduler); + } + +GLDEF_C TInt E32Main() + { + CTrapCleanup* cleanUpStack=CTrapCleanup::New(); + if(cleanUpStack==NULL) + { + return KErrNoMemory; + } + TRAPD(err, MainL()); + delete cleanUpStack; + return(err); + } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tframerate/framerate.RSS --- a/windowing/windowserver/tframerate/framerate.RSS Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,43 +0,0 @@ -// FRAMERATE.RSS - -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Registry file for framerate test -// -// - -#include - -RESOURCE REGISTRY_INFO test_Info - { - dll_uid = 0x102827FC; - interfaces = - { - INTERFACE_INFO - { - interface_uid = 0x10282929; - implementations = - { - IMPLEMENTATION_INFO - { - implementation_uid = 0x1028292A; - version_no = 1; - display_name = "CGraphicDrawerTestFrameRate"; - default_data = ""; - opaque_data = ""; - } - }; - } - }; - } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tframerate/framerate.cpp --- a/windowing/windowserver/tframerate/framerate.cpp Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,95 +0,0 @@ -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - Test plug-in to test wsgraphic animation artwork framerate - @internalComponent - Internal Symbian test code -*/ - -#include -#include -#include "framerate.h" -#include "wsgraphicdrawercontext.h" -#include "wsframerate.h" - -//Constant message handle, which is used to send count value between client and plug-in -const TUint8 KCmdCount=0; - -/** -Creates new test framerate object. -*/ -CGraphicDrawerTestFrameRate* CGraphicDrawerTestFrameRate::CreateL() - { - return new(ELeave) CGraphicDrawerTestFrameRate; - } - -CGraphicDrawerTestFrameRate::CGraphicDrawerTestFrameRate() - { - } - -CGraphicDrawerTestFrameRate::~CGraphicDrawerTestFrameRate() - { - } - -void CGraphicDrawerTestFrameRate::ConstructL(MWsGraphicDrawerEnvironment& aEnv,const TGraphicDrawerId& aId,MWsClient& aOwner,const TDesC8& /*aData*/) - { - BaseConstructL(aEnv,aId,aOwner); - if (aEnv.Screen(0)->ResolveObjectInterface(KMWsScreenConfigInterfaceId)) - { - iContext = CWsGraphicDrawerNonNgaContext::NewL(); - } - else - { - iContext = CWsGraphicDrawerNgaContext::NewL(); - } - } - -/** -Simulate two animations of different frame rate with their respective schedule. - -@param MWsGc Window server graphic context to draw the animation -@param TRect Rectangle are required to draw the animation -@param TDesC Parameter value to use inside this function. -*/ -void CGraphicDrawerTestFrameRate::DoDraw(MWsGc& aGc,const TRect& aRect,const TDesC8& aData) const - { - TInt animId = aData[0]; - TInt requestedFps = aData[1]; - ++iCounter[animId]; - //Schedule next redraw based on requested frame rate - TTimeIntervalMicroSeconds nextTick = 1000000/requestedFps; - iContext->ScheduleAnimation(aGc, aRect, nextTick); - } - -/** -Handles message between client and plug-in. - -@param TDesC Constant message command. -*/ -void CGraphicDrawerTestFrameRate::HandleMessage(const TDesC8& aData) - { - switch (aData[0]) - { - case KCmdCount: - TPckgBuf buf; - buf().iAnim1=iCounter[0]; - buf().iAnim2=iCounter[1]; - TInt err = SendMessage(buf); - __ASSERT_DEBUG(err>=KErrNone, User::Invariant()); - break; - } - } - diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tframerate/framerate.h --- a/windowing/windowserver/tframerate/framerate.h Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,56 +0,0 @@ -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - Test plug-in to test wsgraphic animation artwork framerate - @internalComponent - Internal Symbian test code -*/ - -#ifndef __GRAPHICDRAWERTESTFRAMERATE_H__ -#define __GRAPHICDRAWERTESTFRAMERATE_H__ - -#include -#include "Graphics/WSGRAPHICDRAWER.H" -#include - -//Maximum number of animations at a time. -#define KMaxAnim 100 - -class MWsGraphicDrawerContext; - -/** -Drawer plug-in class used to draw the animation and scheduling. -*/ -NONSHARABLE_CLASS(CGraphicDrawerTestFrameRate): public CWsGraphicDrawer - { -public: - enum - { - EImplUid = 0x1028292A - }; - static CGraphicDrawerTestFrameRate* CreateL(); - ~CGraphicDrawerTestFrameRate(); - void ConstructL(MWsGraphicDrawerEnvironment& aEnv,const TGraphicDrawerId& aId,MWsClient& aOwner,const TDesC8& aData); - void HandleMessage(const TDesC8& aData); -private: - void DoDraw(MWsGc& aGc,const TRect& aRect,const TDesC8& aData) const; -private: - CGraphicDrawerTestFrameRate(); - mutable TInt iCounter[KMaxAnim]; - MWsGraphicDrawerContext* iContext; - }; - -#endif //__GRAPHICDRAWERTESTFRAMERATE_H__ diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tframerate/proxy.cpp --- a/windowing/windowserver/tframerate/proxy.cpp Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include -#include "framerate.h" - - -LOCAL_C const TImplementationProxy KImplementationTable[] = - { - IMPLEMENTATION_PROXY_ENTRY(CGraphicDrawerTestFrameRate::EImplUid,CGraphicDrawerTestFrameRate::CreateL) - }; - -EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) - { - aTableCount = sizeof(KImplementationTable)/sizeof(TImplementationProxy); - return KImplementationTable; - } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tframerate/wsframerate.cpp --- a/windowing/windowserver/tframerate/wsframerate.cpp Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,113 +0,0 @@ -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - Test client library used to communicate between framerate plug-in and twsgraphs. - @internalComponent - Internal Symbian test code -*/ - -#include "wsframerate.h" - -//Constant message handle, which is used to send count value between client and plug-in -const TUint8 KCmdCount=0; - -LOCAL_C const TUid KUidWsGraphicTestFrameRate = {0x1028292A}; - -/** -Creates new object of type CGraphicTestFrameRate based on existing plug-in id. -This interally constructs CWsGraphic object - -@param TUid Test plug-in id -*/ - -EXPORT_C CGraphicTestFrameRate* CGraphicTestFrameRate::NewL(TUid aUid) - { - CGraphicTestFrameRate* self = new(ELeave) CGraphicTestFrameRate; - CleanupStack::PushL(self); - self->BaseConstructL(aUid,KUidWsGraphicTestFrameRate,KNullDesC8()); - CleanupStack::Pop(self); - return self; - } - -/** -Creates new object of type CGraphicTestFrameRate based on active screen number. -This interally constructs CWsGraphic object - -@param TInt Screen number -*/ -EXPORT_C CGraphicTestFrameRate* CGraphicTestFrameRate::NewL(TInt aScreen) - { - CGraphicTestFrameRate* self = new(ELeave) CGraphicTestFrameRate; - CleanupStack::PushL(self); - TBuf8<1> data; - data.Append((TUint8)aScreen); - self->BaseConstructL(KUidWsGraphicTestFrameRate,data); - CleanupStack::Pop(self); - return self; - } - -EXPORT_C CGraphicTestFrameRate::~CGraphicTestFrameRate() - { - } - -CGraphicTestFrameRate::CGraphicTestFrameRate() - { - } - -/** -Handles message between client and Twsgraphs test call. - -@param TDesc8 Descriptor values passed between client and plugin -*/ -void CGraphicTestFrameRate::HandleMessage(const TDesC8& aData) - { - if (aData.Size()>1) - { - Mem::Copy(iCount, aData.Ptr(),(aData.Size())); - } - iCallBack.CallBack(); - } - -void CGraphicTestFrameRate::OnReplace() - { - } - -/** -Query a message value from test plug-in. - -@param TAnimRate Drawing count for two animations. -*/ -EXPORT_C TInt CGraphicTestFrameRate::QueryPlugin(TAnimRate& aCount) - { - TBuf8<1> cmd; - cmd.Append(KCmdCount); - SendMessage(cmd); - TInt err = Flush(); - if (err!=KErrNone) - return err; - iCount=&aCount; - return KErrNone; - } - -/** -Set the callback function - -@param TCallBack Name of the callback function to invoke. -*/ -EXPORT_C void CGraphicTestFrameRate::SetCallBack(TCallBack aCallBack) - { - iCallBack = aCallBack; - } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tframerate/wsframerate.h --- a/windowing/windowserver/tframerate/wsframerate.h Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,61 +0,0 @@ -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Test GraphicTestFrameRate plugins -// -// - -/** - @file - @test - Test plug-in to test wsgraphic animation artwork framerate - @internalComponent - Internal Symbian test code -*/ - -#ifndef __GRAPHICTESTFRAMERATE_H__ -#define __GRAPHICTESTFRAMERATE_H__ - -#include "W32STD.H" - -/** -Holds draw count values of two different animations -*/ -NONSHARABLE_STRUCT(TAnimRate) - { - TInt iAnim1; - TInt iAnim2; - }; - -/** Client representation of a test anim that displays its frame-rate - -@publishedPartner -@released -*/ -NONSHARABLE_CLASS(CGraphicTestFrameRate): public CWsGraphic - - { -public: - IMPORT_C static CGraphicTestFrameRate* NewL(TUid aUid); - IMPORT_C static CGraphicTestFrameRate* NewL(TInt aScreen); - IMPORT_C ~CGraphicTestFrameRate(); - IMPORT_C TInt QueryPlugin(TAnimRate& aCount); - IMPORT_C void SetCallBack(TCallBack aCallBack); -private: - CGraphicTestFrameRate(); - void HandleMessage(const TDesC8& aData); - void OnReplace(); -private: - TAnimRate* iCount; - TCallBack iCallBack; - }; - -#endif //__GRAPHICTESTFRAMERATE_H__ diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tframerate/wsgraphicdrawercontext.h --- a/windowing/windowserver/tframerate/wsgraphicdrawercontext.h Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +0,0 @@ -// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -#ifndef __WSGRAPHICDRAWERCONTEXT_H__ -#define __WSGRAPHICDRAWERCONTEXT_H__ - -#include -#include - -class MWsGc; -class TRgb; - -class MWsGraphicDrawerContext - { -public: - virtual void Destroy() = 0; - virtual void ScheduleAnimation(MWsGc& aGc, const TRect& aRect,const TTimeIntervalMicroSeconds& aFromNow) = 0; - virtual void ScheduleAnimation(MWsGc& aGc, const TRect& aRect,const TTimeIntervalMicroSeconds& aFromNow,const TTimeIntervalMicroSeconds& aFreq,const TTimeIntervalMicroSeconds& aStop) = 0; - }; - -class CWsGraphicDrawerNgaContext : public CBase, public MWsGraphicDrawerContext - { -public: - static MWsGraphicDrawerContext* NewL(); -public: - void Destroy(); - void ScheduleAnimation(MWsGc& aGc, const TRect& aRect,const TTimeIntervalMicroSeconds& aFromNow); - void ScheduleAnimation(MWsGc& aGc, const TRect& aRect,const TTimeIntervalMicroSeconds& aFromNow,const TTimeIntervalMicroSeconds& aFreq,const TTimeIntervalMicroSeconds& aStop); - }; - -class CWsGraphicDrawerNonNgaContext : public CBase, public MWsGraphicDrawerContext - { -public: - static MWsGraphicDrawerContext* NewL(); -public: - void Destroy(); - void ScheduleAnimation(MWsGc& aGc, const TRect& aRect,const TTimeIntervalMicroSeconds& aFromNow); - void ScheduleAnimation(MWsGc& aGc, const TRect& aRect,const TTimeIntervalMicroSeconds& aFromNow,const TTimeIntervalMicroSeconds& aFreq,const TTimeIntervalMicroSeconds& aStop); - }; - -#endif // __WSGRAPHICDRAWERCONTEXT_H__ diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tframerate/wsgraphicdrawerngacontext.cpp --- a/windowing/windowserver/tframerate/wsgraphicdrawerngacontext.cpp Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,39 +0,0 @@ -// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -#define SYMBIAN_GRAPHICS_GCE - -#include "wsgraphicdrawercontext.h" -#include - -MWsGraphicDrawerContext* CWsGraphicDrawerNgaContext::NewL() - { - return new(ELeave) CWsGraphicDrawerNgaContext(); - } - -void CWsGraphicDrawerNgaContext::Destroy() - { - delete this; - } - -void CWsGraphicDrawerNgaContext::ScheduleAnimation(MWsGc& aGc, const TRect& aRect,const TTimeIntervalMicroSeconds& aFromNow) - { - aGc.ScheduleAnimation(aRect, aFromNow); - } - -void CWsGraphicDrawerNgaContext::ScheduleAnimation(MWsGc& aGc, const TRect& aRect,const TTimeIntervalMicroSeconds& aFromNow,const TTimeIntervalMicroSeconds& aFreq,const TTimeIntervalMicroSeconds& aStop) - { - aGc.ScheduleAnimation(aRect, aFromNow, aFreq, aStop); - } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tframerate/wsgraphicdrawernonngacontext.cpp --- a/windowing/windowserver/tframerate/wsgraphicdrawernonngacontext.cpp Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -#undef SYMBIAN_GRAPHICS_GCE - -#include "wsgraphicdrawercontext.h" -#include -#include - -MWsGraphicDrawerContext* CWsGraphicDrawerNonNgaContext::NewL() - { - return new(ELeave) CWsGraphicDrawerNonNgaContext(); - } - -void CWsGraphicDrawerNonNgaContext::Destroy() - { - delete this; - } - -void CWsGraphicDrawerNonNgaContext::ScheduleAnimation(MWsGc& aGc, const TRect& aRect,const TTimeIntervalMicroSeconds& aFromNow) - { - aGc.ScheduleAnimation(aRect, aFromNow); - } - -void CWsGraphicDrawerNonNgaContext::ScheduleAnimation(MWsGc& aGc, const TRect& aRect,const TTimeIntervalMicroSeconds& aFromNow,const TTimeIntervalMicroSeconds& aFreq,const TTimeIntervalMicroSeconds& aStop) - { - aGc.ScheduleAnimation(aRect, aFromNow, aFreq, aStop); - } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tlib/TESTBASE.CPP --- a/windowing/windowserver/tlib/TESTBASE.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1446 +0,0 @@ -// Copyright (c) 1994-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Base classes used for building window server test code -// -// - -#include -#include -#include -#include -#include "TLIB.H" -#include - -// -// Test code classes -// -// CTWinBase -// CTBaseWin -// CTWin -// CTBackedUpWin -// CTGroupWin -// CTClient -// -// - -_LIT(KTestFontTypefaceName,"DejaVu Sans Condensed"); - -class CStopTheScheduler : public CAsyncOneShot - { -public: - inline CStopTheScheduler(CTClient* aClient,TInt aPriority,TBool aAll) :CAsyncOneShot(aPriority), iClient(aClient), iAll(aAll) {} - inline CStopTheScheduler(CTClient* aClient,TInt aPriority) :CAsyncOneShot(aPriority), iClient(aClient) {} - inline CStopTheScheduler(TInt aPriority) :CAsyncOneShot(aPriority) {} - void RunL(); -public: - CTClient* iClient; - TBool iAll; -#ifdef __WINS__ - TInt iCStopTheSchedulerRunCount; -#endif - }; - - -void TbPanic(TInt aPanic) - { - User::Panic(_L("TestBase"),aPanic); - } - -EXPORT_C CTWinBase::CTWinBase(TInt aType) : iType(aType) - { - __DECLARE_NAME(_S("CTWinBase")); - } - -EXPORT_C CTWinBase *CTWinBase::Parent() const - { - return((CTWinBase *)WinTreeNode()->Parent()); - } - -EXPORT_C CTWinBase *CTWinBase::NextSibling() const - { - return((CTWinBase *)WinTreeNode()->NextSibling()); - } - -EXPORT_C CTWinBase *CTWinBase::PrevSibling() const - { - return((CTWinBase *)WinTreeNode()->PrevSibling()); - } - -EXPORT_C CTClient *CTWinBase::Client() const - { - return(iOwnerWin->Client()); - } - -EXPORT_C CTBaseWin *CTWinBase::Child() const - { - return((CTBaseWin *)WinTreeNode()->Child()); - } - -EXPORT_C TPoint CTWinBase::Position() const - { - return(TPoint(0,0)); - } - -EXPORT_C void CTWinBase::PointerEnter(const TTime&) - { - } - -EXPORT_C void CTWinBase::PointerExit(const TTime&) - { - } - -EXPORT_C void CTWinBase::PointerBufferReady(const TTime&) - { - } - -EXPORT_C void CTWinBase::PointerL(const TPointerEvent&,const TTime&) - { - } - -EXPORT_C void CTWinBase::SwitchOn(const TTime &) - { - } - -EXPORT_C void CTWinBase::ModifiersChanged(const TModifiersChangedEvent &,const TTime &) - { - } - -EXPORT_C void CTWinBase::AdjustOrdinal(TInt) - { - } - -EXPORT_C void CTWinBase::AdjustShadow(TInt) - { - } - -EXPORT_C void CTWinBase::SetVisible(TBool) - { - } - -EXPORT_C TInt CTWinBase::SubType() - { - return(0); - } - -EXPORT_C void CTWinBase::ErrorMessage(const TWsErrorMessage&, const TTime &) - { - } - -EXPORT_C void CTWinBase::__DbgTestInvariant() const - { - WinTreeNode()->__DbgTestInvariant(); - } - -// CTBaseWin // - -EXPORT_C CTBaseWin::CTBaseWin(TInt aType) : CTWinBase(aType) - { - __DECLARE_NAME(_S("CTBaseWin")); - } - -EXPORT_C CTBaseWin::~CTBaseWin() - { - } - -EXPORT_C void CTBaseWin::RelinquishFocus() - { - CTWinBase *parent=Parent(); - CTWindowGroup *group=Group(); - CTWinBase *child=group->Child(); - if (child==this) - child=child->NextSibling(); - group->SetCurrentWindow((parent->iType==EWinTypeClient) ? (CTBaseWin *)parent : (CTBaseWin *)child); - } - -EXPORT_C void CTBaseWin::SetVisible(TBool aState) - { - BaseWin()->SetVisible(aState); - } - -EXPORT_C const RWindowTreeNode *CTBaseWin::WinTreeNode() const - { - return((const RWindowTreeNode *)BaseWin()); - } - -EXPORT_C RWindowTreeNode *CTBaseWin::WinTreeNode() - { - return((RWindowTreeNode *)BaseWin()); - } - -EXPORT_C void CTBaseWin::InitWin() - { - } - -EXPORT_C void CTBaseWin::ConstructExtLD(CTWinBase &aParent, const TPoint &aPos, const TSize &aSize) -// -// Call ConstructL, SetExt and either of these fail destroy this and leave -// - { - TRAPD(err,ConstructL(aParent)); - if (err!=KErrNone) - goto celd_err; - TRAP(err,SetExtL(aPos,aSize)); - if (err!=KErrNone) - { -celd_err: - delete this; - User::Leave(err); - } - } - -EXPORT_C void CTBaseWin::ConstructL(CTWinBase &aParent) - { - TInt ret; - __ASSERT_DEBUG(aParent.iOwnerWin!=NULL,TbPanic(ETestBasePanicNullOwnerWin)); - iOwnerWin=aParent.iOwnerWin; - if ((ret=ConstructWin(aParent))==KErrNone) - { - //TFontSpec fspec(KTestFontTypefaceName,200); - //User::LeaveIfError(Client()->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)iFont, fspec)); - TFontSpec fspec(KTestFontTypefaceName,17); - User::LeaveIfError(Client()->iScreen->GetNearestFontToDesignHeightInPixels((CFont *&)iFont, fspec)); - AdjustShadow(1); - InitWin(); - iSize=BaseWin()->Size(); - } - User::LeaveIfError(ret); - } - -EXPORT_C void CTBaseWin::Activate() - { - BaseWin()->Activate(); - } - -EXPORT_C void CTBaseWin::SetFullScreenExtL() - { - SetExtL(TPoint(0,0), Parent()->Size()); - } - -EXPORT_C void CTBaseWin::SetDefaultExtL() - { - TSize size=Parent()->Size(); - size.iWidth>>=1; - size.iHeight>>=1; - SetExtL(TPoint(size.iWidth>>1,size.iHeight>>1), size); - } - -EXPORT_C void CTBaseWin::AssignGC(CWindowGc &aGc) - { - iGc= &aGc; - } - -EXPORT_C void CTBaseWin::SetPos(const TPoint &aPos) - { - BaseWin()->SetPosition(aPos); - iPos=aPos; - } - -EXPORT_C void CTBaseWin::SetInitialPos(const TPoint &aPos) - { - TSize screen=Client()->iScreen->SizeInPixels(); - TPoint pos(aPos); - TPoint botLeft=pos+iSize; - if (botLeft.iX>screen.iWidth) - pos.iX=Max(0,pos.iX-botLeft.iX+screen.iWidth); - if (botLeft.iY>screen.iHeight) - pos.iY=Max(0,pos.iY-botLeft.iY+screen.iHeight); - SetPos(pos); - } - -EXPORT_C void CTBaseWin::SetExtL(const TPoint &aPos, const TSize &aSize) - { - User::LeaveIfError(BaseWin()->SetExtentErr(aPos,aSize)); - iPos=aPos; - iSize=aSize; - Resized(iSize); - } - -EXPORT_C void CTBaseWin::AdjustSizeL(TInt xMove,TInt yMove,TInt modifiers) - { - if (modifiers&EModifierCtrl) // 4 times the movement - { - xMove<<=2; - yMove<<=2; - } - if (modifiers&EModifierShift) - { - TSize size(iSize.iWidth+xMove,iSize.iHeight+yMove); - - if (size.iWidth<0) - size.iWidth=0; - if (size.iHeight<0) - size.iHeight=0; - if (modifiers&EModifierCtrl) - { - TPoint pos(iPos); - pos.iX-=(xMove>>1); - pos.iY-=(yMove>>1); - SetExtL(pos,size); - } - else - SetSizeL(size); - } - else - SetPos(TPoint(iPos+TPoint(xMove,yMove))); - } - -EXPORT_C void CTBaseWin::SetSizeL(const TSize &aSize) - { - User::LeaveIfError(BaseWin()->SetSizeErr(aSize)); - iSize=aSize; - Resized(iSize); - } - -EXPORT_C TSize CTBaseWin::Size() const - { - return(iSize); - } - -EXPORT_C void CTBaseWin::Resized(const TSize &aSize) -// - { - SetDragRect(TRect(aSize)); - } - -EXPORT_C TPoint CTBaseWin::Position() const - { - return(BaseWin()->Position()); - } - -EXPORT_C void CTBaseWin::Delete(CTBaseWin *aWin) - { - RHeap& heap = User::Heap(); - TUint8* base=heap.Base(); - TInt size=heap.Size(); - TUint8* cell=REINTERPRET_CAST(TUint8*,aWin); - __ASSERT_ALWAYS(base<=cell && cellGroup()) - curwin=tmp->Group()->CurWin(); - do - { - win2=tmp; - while((tmp=win2->Child())!=NULL) - win2=tmp; - if ((tmp=win2->NextSibling())==NULL) - tmp=win2->Parent(); - if (curwin==win2) - ((CTBaseWin *)win2)->RelinquishFocus(); - delete win2; - } while(win2!=aWin); - } - -EXPORT_C void CTBaseWin::KeyUpL(const TKeyEvent &,const TTime&) - { - } - -EXPORT_C void CTBaseWin::KeyDownL(const TKeyEvent &,const TTime&) - { - } - -EXPORT_C void CTBaseWin::WinKeyL(const TKeyEvent &,const TTime&) - { - } - -EXPORT_C void CTBaseWin::PointerL(const TPointerEvent &aPointer,const TTime&) - { - if (iDragging) - { - if (aPointer.iType==TPointerEvent::EDrag) - SetPos(aPointer.iParentPosition-iDragPos); - else - iDragging=EFalse; - return; - } - if (aPointer.iType==TPointerEvent::EButton1Down) - { - if (aPointer.iModifiers&EModifierCtrl) - { - if (aPointer.iModifiers&EModifierShift) - BaseWin()->SetOrdinalPosition(-1); - else - BaseWin()->SetOrdinalPosition(0); - return; - } -#if defined(__WINS__) - else if (aPointer.iModifiers&EModifierShift) - __DbgTestInvariant(); -#endif - else - { - Group()->SetCurrentWindow(this); - if (iDragRect.Contains(aPointer.iPosition)) - { - iDragging=ETrue; - iDragPos=aPointer.iPosition; - return; - } - } - } - } - -EXPORT_C void CTBaseWin::DragDropL(const TPointerEvent &,const TTime &) - { - } - -EXPORT_C void CTBaseWin::AdjustOrdinal(TInt aAdjust) - { - TInt pos=BaseWin()->OrdinalPosition()+aAdjust; - if (pos>=0) - BaseWin()->SetOrdinalPosition(pos); - } - -EXPORT_C void CTBaseWin::AdjustShadow(TInt aAdjust) - { - iShadow+=aAdjust; - if (iShadow<0) - iShadow=0; - BaseWin()->SetShadowHeight(iShadow); - } - -EXPORT_C void CTBaseWin::DrawBorder() - { - iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - iGc->DrawRect(TRect(iSize)); - iGc->SetBrushStyle(CGraphicsContext::ENullBrush); - } - -EXPORT_C void CTBaseWin::SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc, TDisplayMode *aMode,TBool aVisible,TInt aTransparency) - { - ConstructL(*parent); - if (aMode) - BaseWin()->SetRequiredDisplayMode(*aMode); - SetExtL(pos,size); - if (!aVisible) - BaseWin()->SetVisible(aVisible); - if (aTransparency!=ENoTransparency) - { - TInt err=((RWindow*)(BaseWin()))->SetTransparencyFactor(TRgb::_Gray256(aTransparency)); - User::LeaveIfError(err); //asked for transparency when not got none! - } - Activate(); - AssignGC(aGc); - } - -EXPORT_C void CTBaseWin::SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc, TDisplayMode *aMode) - { - SetUpL(pos,size,parent,aGc,aMode,ETrue); - } - -EXPORT_C void CTBaseWin::SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc,TBool aVisible) - { - SetUpL(pos,size,parent,aGc,NULL,aVisible); - } - -EXPORT_C void CTBaseWin::SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc) - { - SetUpL(pos,size,parent,aGc,NULL,ETrue); - } - -EXPORT_C void CTBaseWin::SetDragRect(const TRect &aRect) - { - BaseWin()->PointerFilter(EPointerFilterDrag,0); // Clear the drag filter - BaseWin()->SetPointerGrab(ETrue); - iDragRect=aRect; - } - -EXPORT_C CTWindowGroup *CTBaseWin::Group() const - { - return(iOwnerWin); - } - -EXPORT_C void CTBaseWin::FocusChanged(TBool ) - { - } - -EXPORT_C CTBaseWin *CTBaseWin::Next() - { - CTWinBase *win; - CTWinBase *ret=Child(); - if (ret==NULL) - { - win=this; - while((ret=win->NextSibling())==NULL) - { - ret=win; - win=win->Parent(); - if (win==NULL) // Group window - { - ret=ret->Child(); - break; - } - } - } - return((CTBaseWin *)ret); - } - -EXPORT_C CTBaseWin *CTBaseWin::Prev() - { - CTWinBase *par=Parent(); - CTWinBase *win; - CTWinBase *child; - if ((win=PrevSibling())==NULL) - { - if (par->iType==EWinTypeGroup) - { - CTWinBase *win2=par->Child(); - do - { - win=win2; - while((win2=win->NextSibling())!=NULL) - win=win2; - win2=win->Child(); - } while(win2!=NULL); - } - else - win=par; - } - else - { - child=win->Child(); - while(child!=NULL) - { - win=child; - child=child->NextSibling(); - } - } - return((CTBaseWin *)win); - } - -//EXPORT_C void CTBaseWin::SetDefaultExt() -// { -// TbPanic(ETestBasePanicUnimplementedBaseFunction); -// } - -EXPORT_C void CTBaseWin::Draw() - { - TbPanic(ETestBasePanicUnimplementedBaseFunction); - } - -EXPORT_C void CTBaseWin::__DbgTestInvariant() const - { - CTWinBase::__DbgTestInvariant(); -#if defined(__WINS__) - if (BaseWin()->Size()!=iSize) - User::Invariant(); - TPoint offset; - const CTWinBase *win=this; - const CTWinBase *win2; - while((win2=win->Parent())!=NULL) - { - offset+=((CTBaseWin *)win)->BaseWin()->Position(); - if (BaseWin()->InquireOffset(*(win2->WinTreeNode()))!=offset) - User::Invariant(); - win=win2; - } -#endif - } - -//CTDrawableWin// -// Drawable window // -// - -EXPORT_C CTDrawableWin::CTDrawableWin(TInt aType) : CTBaseWin(aType) - { - __DECLARE_NAME(_S("CTDrawableWin")); - } - -//CTWin// -// Standard client window // -// - -EXPORT_C CTWin::CTWin() : CTDrawableWin(EWinTypeClient) - { - __DECLARE_NAME(_S("CTWin")); - } - -EXPORT_C CTWin::~CTWin() - { - if (iFont) - Client()->iScreen->ReleaseFont(iFont); - iWin.Close(); - } - -EXPORT_C TInt CTWin::ConstructWin(const CTWinBase &aParent) - { - iWin=RWindow(aParent.Client()->iWs); - return(iWin.Construct(*(aParent.WinTreeNode()),(TUint32)this)); - } - -EXPORT_C void CTWin::SetDefaultExt() - { - TSize size=Parent()->Size(); - size.iWidth>>=1; - size.iHeight>>=1; - SetExt(TPoint(size.iWidth>>1,size.iHeight>>1), size); - Invalidate(); - } - -EXPORT_C void CTWin::SetExt(const TPoint &aPos, const TSize &aSize) - { - iWin.SetExtent(aPos,aSize); - iPos=aPos; - iSize=aSize; - Resized(iSize); - } - -EXPORT_C void CTWin::SetSize(const TSize &aSize) - { - iWin.SetSize(aSize); - iSize=aSize; - Resized(iSize); - } - -EXPORT_C void CTWin::AdjustSize(TInt xMove,TInt yMove,TInt modifiers) - { - if (modifiers&EModifierCtrl) // 4 times the movement - { - xMove<<=2; - yMove<<=2; - } - if (modifiers&EModifierShift) - { - TSize size(iSize.iWidth+xMove,iSize.iHeight+yMove); - - if (size.iWidth<0) - size.iWidth=0; - if (size.iHeight<0) - size.iHeight=0; - if (modifiers&EModifierCtrl) - { - TPoint pos(iPos); - pos.iX-=(xMove>>1); - pos.iY-=(yMove>>1); - SetExt(pos,size); - } - else - SetSize(size); - Invalidate(); - } - else - SetPos(TPoint(iPos+TPoint(xMove,yMove))); - } - -EXPORT_C RWindowBase *CTWin::BaseWin() - { - return((RWindowBase *)&iWin); - } - -EXPORT_C const RWindowBase *CTWin::BaseWin() const - { - return((const RWindowBase *)&iWin); - } - -EXPORT_C RDrawableWindow *CTWin::DrawableWin() - { - return((RDrawableWindow *)&iWin); - } - -EXPORT_C const RDrawableWindow *CTWin::DrawableWin() const - { - return((const RDrawableWindow *)&iWin); - } - - -EXPORT_C void CTWin::Invalidate() - { - iWin.Invalidate(); - } - -EXPORT_C void CTWin::Invalidate(const TRect &rect) - { - iWin.Invalidate(rect); - } - -EXPORT_C void CTWin::DrawNow() - { - iWin.Invalidate(); - iWin.BeginRedraw(); - iGc->Activate(iWin); - iGc->UseFont((CFont *)iFont); - Draw(); - iGc->Deactivate(); - iWin.EndRedraw(); - } - -EXPORT_C void CTWin::Redraw() - { - iWin.BeginRedraw(); - iGc->Activate(iWin); - iGc->UseFont((CFont *)iFont); - Draw(); - iGc->Deactivate(); - iWin.EndRedraw(); - } - -EXPORT_C void CTWin::Redraw(const TRect &aRect) - { - iWin.BeginRedraw(aRect); - iGc->Activate(iWin); - iGc->UseFont((CFont *)iFont); - Draw(); - iGc->Deactivate(); - iWin.EndRedraw(); - } - -//CTBackedUpWin// -// Backed up window // -// - -EXPORT_C CTBackedUpWin::CTBackedUpWin(TDisplayMode aDisplayMode) : CTDrawableWin(EWinTypeClient), iDisplayMode(aDisplayMode) - { - __DECLARE_NAME(_S("CTBackedUpWin")); - } - -EXPORT_C CTBackedUpWin::~CTBackedUpWin() - { - if (iFont) - Client()->iScreen->ReleaseFont(iFont); - iWin.Close(); - } - -EXPORT_C TInt CTBackedUpWin::ConstructWin(const CTWinBase &aParent) - { - iWin=RBackedUpWindow(aParent.Client()->iWs); - return(iWin.Construct(*(aParent.WinTreeNode()), iDisplayMode, (TUint32)this)); - } - -EXPORT_C RWindowBase *CTBackedUpWin::BaseWin() - { - return((RWindowBase *)&iWin); - } - -EXPORT_C const RWindowBase *CTBackedUpWin::BaseWin() const - { - return((const RWindowBase *)&iWin); - } - -EXPORT_C RDrawableWindow *CTBackedUpWin::DrawableWin() - { - return((RDrawableWindow *)&iWin); - } - -EXPORT_C const RDrawableWindow *CTBackedUpWin::DrawableWin() const - { - return((const RDrawableWindow *)&iWin); - } - -EXPORT_C RBackedUpWindow *CTBackedUpWin::BackedUpWin() - { - return &iWin; - } - -EXPORT_C const RBackedUpWindow *CTBackedUpWin::BackedUpWin() const - { - return &iWin; - } - -//CTTitledWindow// - -EXPORT_C CTTitledWindow::CTTitledWindow() : CTWin(), iWinColor(TRgb(255,255,255)), iPenColor(TRgb(0,0,0)) - { - __DECLARE_NAME(_S("CTTitledWin")); - } - -EXPORT_C CTTitledWindow::~CTTitledWindow() - { - } - -EXPORT_C void CTTitledWindow::ConstructL(CTWinBase &parent) - { - CTBaseWin::ConstructL(parent); - iTitleHeight=iFont->HeightInPixels()+4; - if (iTitle.Length()==0) - SetTitle(*Client()->Title()); - } - -EXPORT_C void CTTitledWindow::SetColor(TRgb aRgb) - { - iWinColor=aRgb; - iWin.SetBackgroundColor(aRgb); - } - -EXPORT_C void CTTitledWindow::Resized(const TSize &aSize) - { - SetDragRect(TRect(0,0,aSize.iWidth,iTitleHeight)); - } - -EXPORT_C void CTTitledWindow::SetTitle(const TWindowTitle &aTitle) - { - iTitle=aTitle; - } - -EXPORT_C void CTTitledWindow::Draw() - { - iGc->SetPenColor(iPenColor); - iGc->SetBrushColor(iWinColor); - DrawBorder(); - iGc->DrawLine(TPoint(0,iTitleHeight),TPoint(iSize.iWidth,iTitleHeight)); - if (Group()->HasFocus(this)) - { - iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - iGc->SetPenColor(~iPenColor); - iGc->SetBrushColor(~iWinColor); - } - iGc->DrawText(iTitle, TRect(1,1,iSize.iWidth-1,iTitleHeight),iFont->AscentInPixels()+1,CGraphicsContext::ECenter); - iGc->SetPenColor(iPenColor); - iGc->SetBrushColor(iWinColor); - } - -EXPORT_C void CTTitledWindow::FocusChanged(TBool ) - { - iWin.Invalidate(TRect(0,0,iSize.iWidth,iTitleHeight)); - } - -// CTBlankWindow // - -EXPORT_C CTBlankWindow::CTBlankWindow() : CTBaseWin(EWinTypeClient) - { - __DECLARE_NAME(_S("CTBlankWin")); - } - -EXPORT_C void CTBlankWindow::ConstructL(CTWinBase &aParent) - { - CTBaseWin::ConstructL(aParent); - } - -EXPORT_C CTBlankWindow::~CTBlankWindow() - { - if (iFont) - Client()->iScreen->ReleaseFont(iFont); - iWin.Close(); - } - -EXPORT_C void CTBlankWindow::SetExt(const TPoint &aPos, const TSize &aSize) - { - iWin.SetExtent(aPos,aSize); - iPos=aPos; - iSize=aSize; - Resized(iSize); - } - -EXPORT_C void CTBlankWindow::SetSize(const TSize &aSize) - { - iWin.SetSize(aSize); - iSize=aSize; - Resized(iSize); - } - -EXPORT_C void CTBlankWindow::SetColor(const TRgb &aRgb) - { - iWin.SetColor(aRgb); - } - -EXPORT_C TInt CTBlankWindow::ConstructWin(const CTWinBase &aParent) - { - iWin=RBlankWindow(aParent.Client()->iWs); - return(iWin.Construct(*(aParent.WinTreeNode()),(TUint32)this)); - } - -EXPORT_C const RWindowBase *CTBlankWindow::BaseWin() const - { - return((const RWindowBase *)&iWin); - } - -EXPORT_C RWindowBase *CTBlankWindow::BaseWin() - { - return((RWindowBase *)&iWin); - } - -//CTWindowGroup// - -EXPORT_C CTWindowGroup::CTWindowGroup(CTClient *aClient) : CTWinBase(EWinTypeGroup), iGroupWin(aClient->iWs) - { - __DECLARE_NAME(_S("CTWindowGroup")); - iClient=aClient; - iOwnerWin=this; - } - -EXPORT_C CTWindowGroup::~CTWindowGroup() - { - iGroupWin.Close(); - } - -EXPORT_C const RWindowTreeNode *CTWindowGroup::WinTreeNode() const - { - return((const RWindowTreeNode *)&iGroupWin); - } - -EXPORT_C RWindowTreeNode *CTWindowGroup::WinTreeNode() - { - return((RWindowTreeNode *)&iGroupWin); - } - -EXPORT_C void CTWindowGroup::ConstructL() - { - User::LeaveIfError(iGroupWin.Construct((TUint32)this)); - } - -EXPORT_C TSize CTWindowGroup::Size() const - { - return(iClient->iScreen->SizeInPixels()); - } - -EXPORT_C void CTWindowGroup::WinKeyL(const TKeyEvent &,const TTime&) - { - } - -EXPORT_C void CTWindowGroup::KeyL(const TKeyEvent &aKey,const TTime&aTime) - { - if (iCurWin) - iCurWin->WinKeyL(aKey,aTime); - } - -EXPORT_C void CTWindowGroup::KeyUpL(const TKeyEvent &,const TTime&) - { - } - -EXPORT_C void CTWindowGroup::KeyDownL(const TKeyEvent &,const TTime&) - { - } - -EXPORT_C void CTWindowGroup::ClearCurrentWindow() - { - iCurWin=NULL; - } - -EXPORT_C void CTWindowGroup::SetCurrentWindow(CTBaseWin *aWindow) - { - SetCurrentWindow(aWindow, EFalse); - } - -EXPORT_C void CTWindowGroup::SetCurrentWindow(CTBaseWin *aWindow, TBool aLocked) - { - if (iCurWin!=aWindow) - { - if (iFocus && iCurWin) - iCurWin->FocusChanged(EFalse); - iCurWin=aWindow; - if (iFocus && iCurWin) - iCurWin->FocusChanged(ETrue); - } - iLocked=aLocked; - } - -EXPORT_C CTBaseWin *CTWindowGroup::CurWin(void) const - { - return(iCurWin); - } - -EXPORT_C void CTWindowGroup::FocusLost() - { - iFocus=EFalse; - if (iCurWin) - iCurWin->FocusChanged(EFalse); - } - -EXPORT_C void CTWindowGroup::FocusGained() - { - iFocus=ETrue; - if (iCurWin) - iCurWin->FocusChanged(ETrue); - } - -EXPORT_C TBool CTWindowGroup::HasFocus(CTBaseWin *aWin) const - { - return(iFocus && iCurWin==aWin); - } - -EXPORT_C CTClient *CTWindowGroup::Client() const - { - return(iClient); - } - -EXPORT_C CTWindowGroup *CTWindowGroup::Group() const - { - return((CTWindowGroup *)this); - } - -EXPORT_C void CTWindowGroup::PasswordL(const TTime &) - { - TbPanic(ETestBasePanicPassword); - } - -EXPORT_C void CTWindowGroup::MessageReady(const TWsEvent &) -// -// Dummy handler for un-exepected messages (could panic, but better not as the app sending the messages fault really not ours) -// - { - } - -EXPORT_C void CTWindowGroup::ScreenDeviceChanged() - { - TPixelsAndRotation sizeAndRotation; - Client()->iScreen->GetDefaultScreenSizeAndRotation(sizeAndRotation); - Client()->iScreen->SetScreenSizeAndRotation(sizeAndRotation); - } - -EXPORT_C void CTWindowGroup::UserEvent(TInt /*aEventType*/) - { - } - - -// CTClient // - -EXPORT_C CTClient::CTClient() - { - __DECLARE_NAME(_S("CTClient")); - } - -EXPORT_C void CTClient::DestroyWindows() - { - if (iGroup) - { - CTBaseWin *win; - if (iGroup->GroupWin()->WsHandle()!=0) // Check it was created okay - while((win=iGroup->Child())!=NULL && ((TUint)win)!=ENullWsHandle) - CTBaseWin::Delete(win); - delete iGroup; - iGroup=NULL; - } - } - -EXPORT_C CTClient::~CTClient() - { - DestroyWindows(); - delete iGc; - delete iEventHandler; - delete iRedrawEventHandler; - delete iScreen; - TInt count=iWs.ResourceCount(); - __ASSERT_ALWAYS(count==0,TbPanic(ETestBasePanicResourceCount)); - iWs.Close(); - } - -EXPORT_C void CTClient::ConstructEventHandlerL() - { - iEventHandler=new(ELeave) CTEvent(&iWs); - iEventHandler->Construct(); - } - -EXPORT_C void CTClient::ConstructL() - { - User::LeaveIfError(iWs.Connect()); - iScreen=new(ELeave) CWsScreenDevice(iWs); - User::LeaveIfError(iScreen->Construct(iScreenNumber)); - iRedrawEventHandler=new(ELeave) CTRedraw(&iWs); - iRedrawEventHandler->Construct(); - ConstructEventHandlerL(); - iGc=new(ELeave) CWindowGc(iScreen); - User::LeaveIfError(iGc->Construct()); - iTitle.Copy(RThread().FullName()); - } - -EXPORT_C void CTClient::ResetFocus() - { - iGroup->ClearCurrentWindow(); - iGroup->SetCurrentWindow(iGroup->Child()); - } - -EXPORT_C TWindowTitle *CTClient::Title() - { - return(&iTitle); - } - -EXPORT_C TBool CTClient::QueueRead() - { - TBool ret=iEventHandler->IsActive(); - if (ret==EFalse) - iEventHandler->Request(); - return(ret); - } - -EXPORT_C void CTClient::CancelRead() - { - iEventHandler->Cancel(); - } - -EXPORT_C void CTClient::SetCancelFunction(const TCallBack &aCallBack) - { - iEventHandler->SetCancelFunction(aCallBack); - } - -EXPORT_C void CTClient::CancelRedrawRead() - { - iRedrawEventHandler->Cancel(); - } - -EXPORT_C void CTClient::SetRedrawCancelFunction(const TCallBack &aCallBack) - { - iRedrawEventHandler->SetCancelFunction(aCallBack); - } - -EXPORT_C void CTClient::RequestRedraw() - { - iRedrawEventHandler->Request(); - } - -EXPORT_C void CTClient::LogMessage(const TLogMessageText &aMessage) - { - iWs.LogMessage(aMessage); - iWs.Flush(); - } - -EXPORT_C TBool CTClient::IsEventWaiting() - { - iWs.NumWindowGroups(); //Make sure all asyncronus calls have finished - return (iEventHandler->iStatus!=KRequestPending); - } - -TBool CTClient::WaitUntilEventPending(const TRequestStatus& aStatus) - { - if (aStatus!=KRequestPending) - return ETrue; - User::After(2000000); //Need something smarter than this - return (aStatus!=KRequestPending); - } - -EXPORT_C TBool CTClient::WaitUntilRedrawPending() - { - return WaitUntilEventPending(iRedrawEventHandler->iStatus); - } - -EXPORT_C TBool CTClient::WaitUntilEventPending() - { - return WaitUntilEventPending(iEventHandler->iStatus); - } - -EXPORT_C TInt CTClient::WaitForRedrawsToFinish() - { - return WaitForEventsToFinish(EFalse); - } - -EXPORT_C TInt CTClient::WaitForAllEventProcessingToFinish() - { - return WaitForEventsToFinish(ETrue); - } - -TInt CTClient::WaitForEventsToFinish(TBool aAll) - { - CStopTheScheduler* stop=new CStopTheScheduler(this,ETlibRedrawActivePriority-1,aAll); - if (!stop) - return KErrNoMemory; - stop->Call(); - CActiveScheduler::Start(); - delete stop; - return KErrNone; - } - - -// CStopTheScheduler // - -void CStopTheScheduler::RunL() - { -#ifdef __WINS__ - RDebug::Print(_L("CStopTheScheduler::RunL - enter - %d"), iCStopTheSchedulerRunCount); -#endif - if (iClient) - { - iClient->iWs.NumWindowGroups(); //Make sure all asyncronus calls have finished - } - - if (!iClient || (iClient->RedrawHandler()->iStatus==KRequestPending && (!iAll || iClient->EventHandler()->iStatus==KRequestPending))) - { -#ifdef __WINS__ - RDebug::Print(_L("CStopTheScheduler::RunL - Stop - %d"), iCStopTheSchedulerRunCount); -#endif - CActiveScheduler::Stop(); - } - else - { -#ifdef __WINS__ - RDebug::Print(_L("CStopTheScheduler::RunL - Call - %d"), iCStopTheSchedulerRunCount); -#endif - Call(); - } -#ifdef __WINS__ - RDebug::Print(_L("CStopTheScheduler::RunL - exit - %d"), iCStopTheSchedulerRunCount); - iCStopTheSchedulerRunCount++; -#endif - } - -void WaitForRedrawsToFinish() - { - CStopTheScheduler* ps=new CStopTheScheduler(ETlibRedrawActivePriority-1); - if(ps) - { - ps->Call(); - CActiveScheduler::Start(); - delete ps; - } - } - - -// CTEventBase // - -EXPORT_C CTEventBase::CTEventBase(RWsSession *aWs, TInt aPriority) : CActive(aPriority), iWs(aWs) - { - } - -EXPORT_C CTEventBase::~CTEventBase() - { - } - -EXPORT_C void CTEventBase::Construct() - { - CActiveScheduler::Add(this); - Request(); - } - -EXPORT_C void CTEventBase::RunL() - { - if (iStatus==KErrNone) - { - ++iCount; - TRAPD(err,doRunL()); - if (err<=0) // Positive value means this has been destroyed - { - if (iCancelRequested) - CancelHandler(); - Request(); -// if (err!=KErrNone) -// User::LeaveIfError(err); Should have a guaranteed to work error dialog here I guess - } - } - else if (iStatus==KErrCancel && iCancelRequested) - { - CancelHandler(); - Request(); - } - else - TbPanic(ETestBasePanicEventStat); - } - -void CTEventBase::SetCancelFunction(const TCallBack &aCallBack) - { - if (!IsActive() && iCancelRequested) - TbPanic(ETestBasePanicCancelFunction); - iCancelCallBack=aCallBack; - iCancelRequested=ETrue; - DoCancel(); - } - -EXPORT_C void CTEventBase::CancelHandler() - { - iCancelCallBack.CallBack(); - iCancelRequested=EFalse; - } - -// TLibWsEvent // - -EXPORT_C CTWindowGroup *TlibWsEvent::WindowGroup() - { - CTWindowGroup *group=(CTWindowGroup *)Handle(); - __ASSERT_DEBUG(group->iType==EWinTypeGroup,TbPanic(ETestBasePanicWinType)); - return(group); - } - -EXPORT_C CTBaseWin *TlibWsEvent::BaseWin() - { - CTBaseWin *win=(CTBaseWin *)Handle(); - __ASSERT_DEBUG(win->iType==EWinTypeClient || win->iType==EWinTypeGroup,TbPanic(ETestBasePanicWinType)); - return(win); - } - -// CTEvent // - -EXPORT_C CTEvent::CTEvent(RWsSession *aWs) : CTEventBase(aWs, ETlibWsEventActivePriority) - { - __DECLARE_NAME(_S("CTEvent")); - } - -EXPORT_C CTEvent::~CTEvent() - { - Cancel(); - } - -EXPORT_C void CTEvent::DoCancel() - { - iWs->EventReadyCancel(); - } - -EXPORT_C void CTEvent::Request() - { - iWs->EventReady(&iStatus); - SetActive(); - } - -EXPORT_C void CTEvent::LogEvent(const TWsEvent &) - { - } - -EXPORT_C void CTEvent::doRunL() - { - TlibWsEvent event; - - iWs->GetEvent(event); - LogEvent(event); - if (event.Handle()!=0 && event.Handle()!=ENullWsHandle) - { - switch(event.Type()) - { - case EEventKey: - event.WindowGroup()->KeyL(*event.Key(),event.Time()); - break; - case EEventKeyDown: - __ASSERT_ALWAYS(event.Key()->iCode==0 && event.Key()->iRepeats==0, TbPanic(ETestBasePanicKeyParams)); - event.WindowGroup()->KeyDownL(*event.Key(),event.Time()); - break; - case EEventKeyUp: - __ASSERT_ALWAYS(event.Key()->iCode==0 && event.Key()->iRepeats==0, TbPanic(ETestBasePanicKeyParams)); - event.WindowGroup()->KeyUpL(*event.Key(),event.Time()); - break; - case EEventModifiersChanged: - event.BaseWin()->ModifiersChanged(*event.ModifiersChanged(),event.Time()); - break; - case EEventPointer: - event.BaseWin()->PointerL(*event.Pointer(),event.Time()); - break; - case EEventDragDrop: - event.BaseWin()->DragDropL(*event.Pointer(),event.Time()); - break; - case EEventPointerEnter: - event.BaseWin()->PointerEnter(event.Time()); - break; - case EEventPointerExit: - event.BaseWin()->PointerExit(event.Time()); - break; - case EEventPointerBufferReady: - event.BaseWin()->PointerBufferReady(event.Time()); - break; - case EEventSwitchOn: - event.BaseWin()->SwitchOn(event.Time()); - break; - case EEventFocusLost: - event.WindowGroup()->FocusLost(); - break; - case EEventFocusGained: - event.WindowGroup()->FocusGained(); - break; - case EEventPassword: - event.WindowGroup()->PasswordL(event.Time()); - break; - case EEventMessageReady: - event.WindowGroup()->MessageReady(event); - break; - case EEventErrorMessage: - event.WindowGroup()->ErrorMessage(*event.ErrorMessage(), event.Time()); - break; - case EEventSwitchOff: - case EEventKeySwitchOff: - { - TTimeIntervalMicroSeconds32 ii=1000000; - User::After(ii); //WINS does not always work without this! - UserHal::SwitchOff(); - } - break; - case EEventScreenDeviceChanged: - event.WindowGroup()->ScreenDeviceChanged(); - break; - case EEventNull: - break; - default: - if (event.Type()>=EEventUser) - { - event.WindowGroup()->UserEvent(event.Type()); - break; - } - else - { - //if not in BufferSecurity test - panic - TInt value = EFalse; - TInt err = RProperty::Get(KUidWServSecurityTesting,EWServSecTestBufferSecurity,value); - if ((err != KErrNone) || (value != (TInt)ETrue)) - TbPanic(ETestBasePanicInvalidEvent); - } - break; - } - } - } - -EXPORT_C CTRedraw::CTRedraw(RWsSession *aWs) : CTEventBase(aWs, ETlibRedrawActivePriority) - { - __DECLARE_NAME(_S("CTRedraw")); - } - -EXPORT_C CTRedraw::~CTRedraw() - { - Cancel(); - } - -EXPORT_C void CTRedraw::Request() - { - iWs->RedrawReady(&iStatus); - SetActive(); - } - -EXPORT_C void CTRedraw::DoCancel() - { - iWs->RedrawReadyCancel(); - } - -EXPORT_C void CTRedraw::doRunL() - { - TWsRedrawEvent redraw; - iWs->GetRedraw(redraw); - if (redraw.Handle()!=0 && redraw.Handle()!=ENullWsHandle) - { - __ASSERT_ALWAYS(!redraw.Rect().IsEmpty(),TbPanic(ETestBasePanicNullRedraw)); - ((CTWin *)redraw.Handle())->Redraw(redraw.Rect()); - } - } - -EXPORT_C void CTUser::Splat(CTClient *aClient, const TRect &aRect, const TRgb &aRgb) - { - RBlankWindow win(aClient->iWs); - win.Construct(*(aClient->iGroup->WinTreeNode()),1); - win.SetColor(aRgb); - win.SetExtent(aRect.iTl,aRect.Size()); - win.Activate(); - aClient->iWs.Flush(); - win.Close(); - } - -void doTestLibStartUpL(TInt aScreenNumber, CTClient *&aClient, CActiveScheduler *&aActiveScheduler,CTrapCleanup *&aCleanUpStack,TCreateClientFunc aFunc) - { - User::LeaveIfNull(aCleanUpStack=CTrapCleanup::New()); - aActiveScheduler=new(ELeave) CActiveScheduler; - CActiveScheduler::Install(aActiveScheduler); - aClient=aFunc(); - aClient->SetScreenNumber(aScreenNumber); - aClient->ConstructL(); - CActiveScheduler::Start(); - } - -EXPORT_C TInt TestLibStartUp(TCreateClientFunc aFunc,TInt aScreenNumber) - { - __UHEAP_MARK; - CTrapCleanup* cleanUpStack=NULL; - CActiveScheduler *activeScheduler=NULL; - CTClient *client=NULL; - TRAPD(err,doTestLibStartUpL(aScreenNumber, client,activeScheduler,cleanUpStack,aFunc)); - delete client; - delete activeScheduler; - delete cleanUpStack; - __UHEAP_MARKEND; - return(err); - } - -EXPORT_C TInt TestLibStartUp(TCreateClientFunc aFunc) - { - return TestLibStartUp(aFunc, KDefaultScreen); - } - diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tlib/TLDIALOG.CPP --- a/windowing/windowserver/tlib/TLDIALOG.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,463 +0,0 @@ -// Copyright (c) 1994-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Base classes used for building window server test code -// -// - -#include -#include -#include -#include -#include "TLIB.H" - -const TInt ButtonGap=20; -const TInt ButtonBorderGap=10; -const TInt ButtonBorderMargin=3; -const TInt TextMargin=5; -const TInt KAutoDelaySeconds=60; - -NONSHARABLE_CLASS(CTAutoKey): public CActive - { -public: - static CTAutoKey* NewL(RWsSession& aWs); - ~CTAutoKey(); - void Activate(TInt aDelay); - - void RunL(); - void DoCancel(); - -private: - CTAutoKey(RWsSession& aWs); - void ConstructL(); - - RTimer iTimer; - TInt iDelay; - RWsSession& iWs; - }; - -EXPORT_C CTDialog::CTDialog() : CTTitledWindow(), iNumButtons(1) - { - iButton[0].Copy(_L("Continue")); // Default button - } - -EXPORT_C CTDialog::~CTDialog() - { - if (iIsActive) - CActiveScheduler::Stop(); - delete iAutoKey; - } - -EXPORT_C void CTDialog::ConstructLD(CTWinBase &aParent,CWindowGc &aGc) - { - iOldFocus=aParent.Group()->CurWin(); - TRAPD(err,CTTitledWindow::ConstructL(aParent)); - if (err!=KErrNone) - { - delete this; - User::Leave(err); - } - iActivated=ETrue; - iWin.SetBackgroundColor(TRgb::Gray256(238)); // Light gray - AssignGC(aGc); - iWin.SetPointerCapture(ETrue); - Group()->SetCurrentWindow(this, ETrue); - iAutoKey=CTAutoKey::NewL(Client()->iWs); - } - -EXPORT_C void CTDialog::RelinquishFocus() - { - Group()->SetCurrentWindow(iOldFocus); - } - -EXPORT_C TInt CTDialog::Display() - { - TInt result; - - SetWindowSize(); - if (iWinActive) - BaseWin()->SetVisible(ETrue); - else - { - Activate(); - iWinActive=ETrue; - } - if (iTakeFocus) - Group()->SetCurrentWindow(this); - Group()->GroupWin()->SetOrdinalPosition(0); - iResultPtr=&result; - CTClient *client=Client(); - if (client->QueueRead()) - { - client->iWs.Flush(); - client=NULL; - } - iIsActive=ETrue; - iAutoKey->Activate(KAutoDelaySeconds); - CActiveScheduler::Start(); - if (client) - client->CancelRead(); - return(result); - } - -EXPORT_C void CTDialog::SetFlags(TUint aFlags) - { - iFlags=aFlags; - } - -void CTDialog::SetMaxWid(TInt &aMax, TInt aWid) - { - if (aWid>aMax) - aMax=aWid; - } - -EXPORT_C void CTDialog::SetWindowSize() - { - if (iActivated) - { - TInt max=0; - SetMaxWid(max,iFont->TextWidthInPixels(iTitle)); - SetMaxWid(max,iFont->TextWidthInPixels(iLine1)); - SetMaxWid(max,iFont->TextWidthInPixels(iLine2)); - max+=TextMargin*2; - iButWid=0; - if (iNumButtons>0) - { - for(TInt index=0;indexTextWidthInPixels(iButton[index])); - iButWid+=ButtonBorderMargin*2; - SetMaxWid(max,iButWid*iNumButtons+ButtonGap*(iNumButtons-1)+ButtonBorderGap*2); - } - TSize parSize=Parent()->Size(); - TSize size(max,iFont->HeightInPixels()*8); - TPoint pos((parSize.iWidth-size.iWidth)/2,(parSize.iHeight-size.iHeight)/2); - if (iFlags&EDialogDisplayAtBottom) - pos.iY*=2; - if (iFlags&EDialogDisplayAtLeft) - pos.iX=0; - SetExt(pos,size); - Invalidate(); - } - } - -EXPORT_C void CTDialog::SetLine1(const TDesC &aLine1) - { - iLine1.Copy(aLine1); - } - -EXPORT_C void CTDialog::SetLine2(const TDesC &aLine2) - { - iLine2.Copy(aLine2); - } - -EXPORT_C void CTDialog::SetNumButtons(TInt aNum) - { - if ((TUint)aNum>3) - TbPanic(EDialogButtonCount); - iNumButtons=aNum; - } - -EXPORT_C void CTDialog::SetButtonText(TInt aNum,const TDesC &aButton) - { - if ((TUint)aNum>(TUint)iNumButtons) - TbPanic(EDialogButtonIndex); - iButton[aNum].Copy(aButton); - } - -TRect CTDialog::ButtonRect(TInt aIndex) const - { - TInt chunk=(iSize.iWidth-ButtonBorderMargin*2)/iNumButtons; - TInt midPos=ButtonBorderMargin+chunk*aIndex+chunk/2; - return(TRect(midPos-iButWid/2,iFont->HeightInPixels()*6,midPos+iButWid/2,iFont->HeightInPixels()*7+ButtonBorderMargin*2)); - } - -EXPORT_C void CTDialog::Draw() - { - CTTitledWindow::Draw(); - iGc->SetPenColor(TRgb::Gray16(0)); - iGc->DrawText(iLine1, TPoint((iSize.iWidth-iFont->TextWidthInPixels(iLine1))/2,iFont->HeightInPixels()*3)); - iGc->DrawText(iLine2, TPoint((iSize.iWidth-iFont->TextWidthInPixels(iLine2))/2,iFont->HeightInPixels()*4+2)); - if (iNumButtons!=0) - { - for(TInt index=0;indexSetBrushStyle(CGraphicsContext::ESolidBrush); - iGc->SetBrushColor(TRgb::Gray256(255)); - iGc->DrawRect(rect); - iGc->DrawRect(rect); - iGc->SetBrushStyle(CGraphicsContext::ENullBrush); - TInt midPos=(rect.iTl.iX+rect.iBr.iX)/2; - iGc->DrawText(iButton[index], TPoint((midPos-iFont->TextWidthInPixels(iButton[index])/2), - iFont->HeightInPixels()*6+iFont->AscentInPixels()+ButtonBorderMargin)); - } - } - } - -EXPORT_C void CTDialog::WinKeyL(const TKeyEvent &aKey,const TTime&) - { - switch(aKey.iCode) - { - case EKeyEscape: - case '0': - ButtonPressL(0); - break; - case EKeyEnter: - case '1': - ButtonPressL(iNumButtons>1 ? 1 : 0); // Same as ESC on a single button dialog - break; - case ' ': - case '2': - ButtonPressL(2); - break; - } - } - -EXPORT_C void CTDialog::PointerL(const TPointerEvent &aPointer,const TTime &aTime) - { - if (aPointer.iType==TPointerEvent::EButton1Up) - { - if (iButtonClickOn>0) - { - ButtonPressL(iButtonClickOn-1); - return; - } - } - else if (aPointer.iType==TPointerEvent::EButton1Down) - { - for(TInt index=0;indexiGroup, aClient->iGc); - TRAPD(err,dialog->ConstructLD()); - if (err==KErrNone) - { - dialog->SetTitle(aTitle); - dialog->SetLine1(aLine1); - dialog->SetLine2(aLine2); - dialog->SetNumButtons(1); - dialog->SetButtonText(0,_L("Okay")); - if (dialog->Display()!=0) // delete dialog - TbPanic(EDialogDisplay); - } - } - -void doDisplayDialog(TInt aScreenNumber,const TWindowTitle &aTitle, const TDesC &aLine1, const TDesC &aLine2, CTClient *&aClient, const RWindowGroup *aGroup) - { - aClient=new(ELeave) CTClient(); - aClient->SetScreenNumber(aScreenNumber); - aClient->ConstructL(); -// - aClient->iGroup=new(ELeave) CTWindowGroup(aClient); - aClient->iGroup->ConstructL(); - aClient->iGroup->GroupWin()->SetOrdinalPosition(0,10); - if (aGroup) - aClient->iGroup->GroupWin()->SetOwningWindowGroup(aGroup->Identifier()); -// - TRAP_IGNORE(DisplayDialog(aClient, aTitle, aLine1, aLine2)); - } - -void doDisplayDialog(const TWindowTitle &aTitle, const TDesC &aLine1, const TDesC &aLine2, CTClient *&aClient, const RWindowGroup *aGroup) - { - doDisplayDialog(KDefaultScreen,aTitle,aLine1,aLine2,aClient,aGroup); - } - -EXPORT_C void DisplayDialog(TInt aScreenNumber,const TWindowTitle &aTitle, const TDesC &aLine1, const TDesC &aLine2, const RWindowGroup *aGroup) - { - CTClient *client=NULL; - TRAP_IGNORE(doDisplayDialog(aScreenNumber,aTitle,aLine1,aLine2,client,aGroup)); - delete client; - } - -EXPORT_C void DisplayDialog(const TWindowTitle &aTitle, const TDesC &aLine1, const TDesC &aLine2, const RWindowGroup *aGroup) - { - DisplayDialog(KDefaultScreen,aTitle,aLine1,aLine2,aGroup); - } - - - -//CInfoDialog - -EXPORT_C CInfoDialog::CInfoDialog(CTWindowGroup *aGroupWin,CWindowGc *aGc) :CTDialog(), iGroupWin(aGroupWin), iGc(aGc) - {} - -EXPORT_C void CInfoDialog::ButtonPressL(TInt aButton) - { - if (aButton==0) - { - SetResult(0); - BaseWin()->SetVisible(EFalse); - CActiveScheduler::Stop(); - } - } - -EXPORT_C void CInfoDialog::ConstructLD() - { - _LIT(OK,"Okay"); - CTDialog::ConstructLD(*iGroupWin, *iGc); - SetNumButtons(1); - SetButtonText(0,OK); - SetTakeFocus(); - } - -EXPORT_C void CInfoDialog::TimerResults() - { - TProfile profile[eTimes]; - // TProfile only has default constructor - - // constructor of TProfile does not initialize its members - for (TInt jj=0; jj times; - TBuf<32> counts; - TInt ii=1; - FOREVER - { - AppendProfileTime(times,profile[ii].iTime); - AppendProfileCount(counts,profile[ii].iCount); - if (++ii==eTimes) - break; - AddComma(times); - AddComma(counts); - } - SetLine1(times); - SetLine2(counts); - times.Zero(); - AppendProfileTime(times,profile[0].iTime); - SetTitle(times); - } - -void CInfoDialog::AppendProfileTime(TDes &aDes, TInt aNum) - { - _LIT(ThreeDP,"%d.%03d"); - aDes.AppendFormat(ThreeDP,aNum/eSeconds,(aNum%eSeconds)/1000); - } - -void CInfoDialog::AppendProfileCount(TDes &aDes, TInt aNum) - { - _LIT(Int,"%d"); - aDes.AppendFormat(Int,aNum); - } - -void CInfoDialog::AddComma(TDes &aDes) - { - _LIT(Comma,", "); - aDes.Append(Comma); - } - -CTAutoKey::CTAutoKey(RWsSession& aWs): CActive(0), iWs(aWs) - { - CActiveScheduler::Add(this); - } - -CTAutoKey::~CTAutoKey() - { - Cancel(); - iTimer.Close(); - } - -void CTAutoKey::ConstructL() - { - User::LeaveIfError(iTimer.CreateLocal()); - } - -CTAutoKey* CTAutoKey::NewL(RWsSession& aWs) - { - CTAutoKey* self=new(ELeave) CTAutoKey(aWs); - CleanupStack::PushL(self); - self->ConstructL(); - CleanupStack::Pop(); - return self; - } - -void CTAutoKey::Activate(TInt aDelay) - { - if (IsActive()) - Cancel(); - - iDelay=aDelay*1000000; - iTimer.After(iStatus,iDelay); - SetActive(); - } -void CTAutoKey::RunL() - { - // simulate key event, only needed to run once - TKeyEvent keyEvent; - keyEvent.iCode=EKeyEnter; - keyEvent.iScanCode=EKeyEnter; - keyEvent.iModifiers=0; - keyEvent.iRepeats=0; - iWs.SimulateKeyEvent(keyEvent); - iWs.Flush(); - } - -void CTAutoKey::DoCancel() - { - iTimer.Cancel(); - } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tlib/TLEVENT.CPP --- a/windowing/windowserver/tlib/TLEVENT.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,294 +0,0 @@ -// Copyright (c) 1994-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Maintains a window displaying last event details -// -// - -#include -#include -#include -#include "testbase.h" - -const TInt NumLogLinesPerEvent=2; - - -// -// Event window // -// - -EXPORT_C CEventWindow::CEventWindow(TInt aLogSize) : CTWin(), iLogSize(aLogSize) - { - } - -EXPORT_C CEventWindow::~CEventWindow() - { - delete[] iLoggedEvents; - RelinquishFocus(); - } - -EXPORT_C void CEventWindow::ConstructL(CTWinBase &parent) - { - CTWin::ConstructL(parent); - iLineHeight=iFont->HeightInPixels()+2; - iLoggedEvents=new(ELeave) TWsEvent[iLogSize]; - iWin.EnableModifierChangedEvents(EModifierFunc|EModifierCapsLock|EModifierNumLock, EEventControlAlways); - iWin.EnableOnEvents(EEventControlAlways); - } - -EXPORT_C void CEventWindow::SetUpL(const TPoint &pos, CTWinBase *parent, CWindowGc &aGc) - { - TRAPD(err,ConstructL(*parent)); - if (err!=KErrNone) - { - delete this; - User::Leave(err); - } - SetExt(pos,TSize(600,iLineHeight*NumLogLinesPerEvent*iLogSize)); - Activate(); - AssignGC(aGc); - } - -void CEventWindow::DrawLine(TInt aLine, const TDesC &aText) - { - iGc->DrawText(aText, TPoint(10,iLineHeight*aLine+iFont->AscentInPixels()+1)); - } - -void CEventWindow::LogEvent(TInt aLogNum, const TWsEvent &aEvent) - { - TBuf<0x80> buf1; - TBuf<0x80> buf2; - TPtrC type(_L("Unknown event type")); - TKeyEvent *key=aEvent.Key(); - switch(aEvent.Type()) - { - case EEventKey: - type.Set(_L("EEventKey")); - buf2.Format(TRefByValue(_L("Code=%d [%c], ScanCode=0x%x, Modifiers=0x%04x, repeats=%d")), key->iCode, key->iCode, key->iScanCode,key->iModifiers,key->iRepeats); - break; - case EEventKeyUp: - type.Set(_L("EEventKeyUp")); - buf2.Format(TRefByValue(_L("scanCode=0x%x, Modifiers=0x%04x")), key->iScanCode, key->iModifiers); - break; - case EEventKeyDown: - type.Set(_L("EEventKeyDown")); - buf2.Format(TRefByValue(_L("scanCode=0x%x, Modifiers=0x%04x")), key->iScanCode, key->iModifiers); - break; - case EEventPointer: - { - TPointerEvent *pointer=aEvent.Pointer(); - TPtrC ptrType(_L("Unknown pointer event")); - switch(pointer->iType) - { - case TPointerEvent::EButton1Up: - ptrType.Set(_L("EButton1Up")); - break; - case TPointerEvent::EButton3Up: - ptrType.Set(_L("EButton3Up")); - break; - case TPointerEvent::EButton2Up: - ptrType.Set(_L("EButton2Up")); - break; - case TPointerEvent::EButton1Down: - ptrType.Set(_L("EButton1Down")); - break; - case TPointerEvent::EButton3Down: - ptrType.Set(_L("EButton3Down")); - break; - case TPointerEvent::EButton2Down: - ptrType.Set(_L("EButton2Down")); - break; - case TPointerEvent::EDrag: - ptrType.Set(_L("EDrag")); - break; - case TPointerEvent::EMove: - ptrType.Set(_L("EMove")); - break; - case TPointerEvent::EButtonRepeat: - ptrType.Set(_L("EButtonRepeat")); - break; - case TPointerEvent::ESwitchOn: - ptrType.Set(_L("ESwitchOn")); - break; - } - type.Set(_L("EEventPointer")); - buf2.Format(TRefByValue(_L("Type=%S, state=0x%x, pos={%d,%d}, parent pos={%d,%d}")),&ptrType, pointer->iModifiers, - pointer->iPosition.iX,pointer->iPosition.iY,pointer->iParentPosition.iX,pointer->iParentPosition.iY); - } - break; - case EEventPointerEnter: - type.Set(_L("EEventPointerEnter")); - break; - case EEventPointerExit: - type.Set(_L("EEventPointerExit")); - break; - case EEventSwitchOn: - type.Set(_L("EEventSwitchOn")); - break; - case EEventModifiersChanged: - type.Set(_L("EEventModifiersChanged")); - buf2.Format(TRefByValue(_L("Changed=0x%x, State=0x%x ")),aEvent.ModifiersChanged()->iChangedModifiers,aEvent.ModifiersChanged()->iModifiers); - break; - case EEventFocusLost: - type.Set(_L("EEventFocusLost")); - break; - case EEventFocusGained: - type.Set(_L("EEventFocusGained")); - break; - default:; - } - TBuf<20> timeBuf; - _LIT(TimeDisc,"%/0%1%/1%2%/2%3%/3 %:0%H%:1%T%:2%S%:3"); - TRAPD(err,aEvent.Time().FormatL(timeBuf,TimeDisc)); - if (err!=KErrNone) - { - _LIT(DummyTime,"########"); - timeBuf.Append(DummyTime); - } - buf1.Format(TRefByValue(_L("%d: %S [%x], %S")), iCount-aLogNum, &type, aEvent.Handle(), &timeBuf); - TInt baseLine=(iLogSize-aLogNum-1)*NumLogLinesPerEvent; - DrawLine(baseLine+0,buf1); - DrawLine(baseLine+1,buf2); - } - -EXPORT_C void CEventWindow::Draw() - { - DrawBorder(); - for(TInt index=0;index0;index--) - iLoggedEvents[index]=iLoggedEvents[index-1]; - iLoggedEvents[0]=aEvent; - DrawNow(); - } - - -// -// Blank window, just sort of sits there looking blank // -// - -EXPORT_C TBool CheckBlankWindow(TRect aArea,TRgb aColor,const CWsScreenDevice* aScreen) -// -// Returns ETrue if the the given rect is all the specified color -// EFalse if it is not -// - { - TInt wid=aArea.Width(); - TAny *buf2=User::AllocL(wid*sizeof(TRgb)); - TRgb *pRgb=(TRgb *)buf2; - Mem::FillZ(buf2,wid*sizeof(TRgb)); - //TRgb tmp(TRgb::Gray16(aColor.Gray16())); - //Truncate color to match color conversion in EColor64K mode before comparison - if (aScreen->DisplayMode()==EColor64K) - aColor=TRgb::Color64K(aColor.Color64K()); - for(TInt i=0;i(buf2),wid*sizeof(TRgb),wid*sizeof(TRgb)); - - TAny *buf=User::AllocL(wid*sizeof(TRgb)); - TPtr8 rgbBuf(reinterpret_cast(buf),wid*sizeof(TRgb)); - - TBool ret=ETrue; - TPoint offset=aArea.iTl; //iWin.InquireOffset(*TheClient->iGroup->WinTreeNode()); - for(;offset.iYGetScanLine(rgbBuf,offset,wid,EColor16MA); - if (rgbBuf.Compare(tstBuf)!=0) - { - ret=EFalse; - break; - } - } - User::FreeZ(buf); - User::FreeZ(buf2); - return(ret); - } - -EXPORT_C CBlankWindow::CBlankWindow() : CTWin() - { - iCol=TRgb::Gray256(128); - } - -EXPORT_C CBlankWindow::CBlankWindow(TRgb aCol) : CTWin(), iCol(aCol), iRealDraw(EFalse) - { - } - -EXPORT_C void CBlankWindow::ConstructL(CTWinBase &parent) - { - CTWin::ConstructL(parent); - iWin.SetBackgroundColor(iCol); - } - -EXPORT_C void CBlankWindow::SetColor(TRgb aColor) - { - iCol=aColor; - } - -EXPORT_C void CBlankWindow::RealDraw(TBool aRealDraw) - { - iRealDraw=aRealDraw; - } - -EXPORT_C void CBlankWindow::Draw() - { - if (!iRealDraw) - iGc->Clear(); - else - { - iGc->SetPenStyle(CGraphicsContext::ENullPen); - iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - iGc->SetBrushColor(iCol); - iGc->DrawRect(TRect(iSize)); - } - } - -EXPORT_C void CBlankWindow::DrawNow() - { - iWin.Invalidate(); - iWin.BeginRedraw(); - iGc->Activate(iWin); - Draw(); - iGc->Deactivate(); - iWin.EndRedraw(); - } - -EXPORT_C void CBlankWindow::DrawNow(TRect& aRect) - { - iWin.Invalidate(aRect); - iWin.BeginRedraw(aRect); - iGc->Activate(iWin); - iGc->SetClippingRect(aRect); - Draw(); - iGc->Deactivate(); - iWin.EndRedraw(); - } - -EXPORT_C TBool CBlankWindow::Check(const CTClient& aClient) -// -// Returns ETrue if the window is Ok, -// EFalse if it is not -// - { - return CheckBlankWindow(TRect(iWin.InquireOffset(*aClient.iGroup->WinTreeNode()),Size()),TRgb::Gray16(iCol.Gray16()),aClient.iScreen); - } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tlib/TLIB.H --- a/windowing/windowserver/tlib/TLIB.H Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -#ifndef __TLIB_H__ -#define __TLIB_H__ - -#include "testbase.h" - -GLREF_C void TbPanic(TInt aPanic); - -enum TTestBasePanic - { - ETestBasePanicResourceCount, - ETestBasePanicResCountWinFail, - ETestBasePanicResCountWinInit, - ETestBasePanicEventStat, - ETestBasePanicScheduler, - ETestBasePanicKeyParams, - ETestBasePanicInvalidEvent, - ETestBasePanicReadCancelled, - ETestBasePanicUnimplementedBaseFunction, - ETestBasePanicCancelFunction, - ETestBasePanicNullRedraw, - ETestBasePanicNullOwnerWin, - ETestBasePanicWinType, - ETestBasePanicPassword, - EDialogButtonCount, - EDialogButtonIndex, - EDialogDisplay, - ETestBasePanicInvalidHeapAddress, - }; - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tlib/TLSPRITE.CPP --- a/windowing/windowserver/tlib/TLSPRITE.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,223 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Base classes used for building window server test code -// -// - -#include -#include -#include -#include "testbase.h" - -EXPORT_C TSpriteCreateParams::TSpriteCreateParams(TSize aSize,TPoint aOffset,CTSpriteBase::TSpriteDrawFunction aDrawFunc, - TAny *aDrawFuncParam,TBool aMask,CGraphicsContext::TDrawMode aDrawMode) : - iSize(aSize), - iOffset(aOffset), - iDrawFunc(aDrawFunc), - iDrawFuncParam(aDrawFuncParam), - iMask(aMask), - iDrawMode(aDrawMode), - iInterval(0) - {} - -EXPORT_C TSpriteCreateParams::TSpriteCreateParams() : - iDrawFunc(NULL), - iDrawMode(CGraphicsContext::EDrawModePEN), - iInterval(0) - {} - -void CTSpriteBase::CreateBitmapL(CFbsBitmap *&aBitmap, CFbsBitmapDevice *&aBitmapDevice, TSpriteCreateParams *aParams, TBool aDoMask) - { - if (aBitmap==NULL) - { - aBitmap=new(ELeave) CFbsBitmap(); - User::LeaveIfError(aBitmap->Create(aParams->iSize,EGray4)); - } - aBitmapDevice=CFbsBitmapDevice::NewL(aBitmap); - CFbsBitGc *gc=CFbsBitGc::NewL(); - gc->Activate(aBitmapDevice); - aParams->iDrawFunc(gc,0,aParams->iSize,aDoMask,aParams->iDrawFuncParam); - delete gc; - } - -EXPORT_C void CTSpriteBase::RedrawL(CFbsBitmap *&aBitmap, CFbsBitmap *&aMaskBitmap, TSpriteCreateParams *aParams) - { - CFbsBitmapDevice *bitmapDevice=NULL; - TRAPD(err,CreateBitmapL(aBitmap,bitmapDevice,aParams,EFalse)); - if (err==KErrNone) - { - delete bitmapDevice; - bitmapDevice=NULL; - if (aMaskBitmap) - { - TRAP(err,CreateBitmapL(aMaskBitmap,bitmapDevice,aParams,ETrue)); - delete bitmapDevice; - } - SpriteBase().UpdateMember(0); - } - User::LeaveIfError(err); - } - -EXPORT_C void CTSpriteBase::UpdateL(TInt aIndex, TSpriteCreateParams *aParams) - { - CFbsBitmap *bitmap=NULL; - CFbsBitmapDevice *bitmapDevice=NULL; - TRAPD(err,CreateBitmapL(bitmap,bitmapDevice,aParams,EFalse)); - if (err==KErrNone) - { - delete bitmapDevice; - bitmapDevice=NULL; - CFbsBitmap *mask=NULL; - if (aParams->iMask) - TRAP(err,CreateBitmapL(mask,bitmapDevice,aParams,ETrue)); - if (err==KErrNone) - { - TSpriteMember sprite; - sprite.iBitmap=bitmap; - sprite.iMaskBitmap=mask; - sprite.iInvertMask=EFalse; - sprite.iDrawMode=aParams->iDrawMode; - sprite.iInterval=aParams->iInterval; - sprite.iOffset=aParams->iOffset; - err=SpriteBase().UpdateMember(aIndex,sprite); - } - delete mask; - } - delete bitmap; - delete bitmapDevice; - User::LeaveIfError(err); - } - -EXPORT_C CTSprite::CTSprite(RWsSession &aWs) : iSprite(aWs) - { - } - -EXPORT_C CTSprite::~CTSprite() - { - iSprite.Close(); - } - -EXPORT_C RWsSpriteBase &CTSprite::SpriteBase() - { - return(iSprite); - } - -EXPORT_C RWsSprite &CTSprite::Sprite() - { - return(iSprite); - } - -EXPORT_C void CTSprite::ConstructL(RWindowTreeNode &aWindow, const TPoint &aPos, TInt aCount, TSpriteCreateParams *aParams, TInt aFlags) - { - User::LeaveIfError(iSprite.Construct(aWindow,aPos,aFlags)); - for(TInt index=0;indexiMask) - TRAP(err,CreateBitmapL(mask,bitmapDevice,aParams,ETrue)); - if (err==KErrNone) - { - TSpriteMember sprite; - sprite.iBitmap=bitmap; - sprite.iMaskBitmap=mask; - sprite.iInvertMask=EFalse; - sprite.iDrawMode=aParams->iDrawMode; - sprite.iOffset=aParams->iOffset; - sprite.iInterval=aParams->iInterval; - err=iSprite.AppendMember(sprite); - } - } - delete mask; - delete bitmap; - delete bitmapDevice; - User::LeaveIfError(err); - } - User::LeaveIfError(iSprite.Activate()); - } - -EXPORT_C CTPointerCursor::CTPointerCursor(RWsSession &aWs) : iCursor(aWs) - { - } - -EXPORT_C CTPointerCursor::~CTPointerCursor() - { - iCursor.Close(); - } - -EXPORT_C RWsSpriteBase &CTPointerCursor::SpriteBase() - { - return(iCursor); - } - -EXPORT_C RWsPointerCursor &CTPointerCursor::PointerCursor() - { - return(iCursor); - } - -EXPORT_C void CTPointerCursor::ConstructL(TInt aFlags) - { - User::LeaveIfError(iCursor.Construct(aFlags)); - TSpriteMember sprite; - sprite.iBitmap=NULL; - User::LeaveIfError(iCursor.AppendMember(sprite)); - } - -EXPORT_C void CTPointerCursor::ConstructL(TInt aCount, TSpriteCreateParams *aParams, TInt aFlags) - { - CFbsBitmap *bitmap=NULL; - CFbsBitmap *mask=NULL; - TRAPD(err,ConstructL(aCount, aParams, aFlags, bitmap, mask)); - delete bitmap; - delete mask; - User::LeaveIfError(err); - } - -EXPORT_C void CTPointerCursor::ConstructL(TInt aCount, TSpriteCreateParams *aParams, TInt aFlags, CFbsBitmap *&aBitmap, CFbsBitmap *&aMaskBitmap) - { - User::LeaveIfError(iCursor.Construct(aFlags)); - for(TInt index=0;indexiMask) - TRAP(err,CreateBitmapL(aMaskBitmap,bitmapDevice,aParams,ETrue)); - if (err==KErrNone) - { - TSpriteMember sprite; - sprite.iBitmap=aBitmap; - sprite.iMaskBitmap=aMaskBitmap; - sprite.iInvertMask=EFalse; - sprite.iDrawMode=aParams->iDrawMode; - sprite.iInterval=aParams->iInterval; - sprite.iOffset=aParams->iOffset; - err=iCursor.AppendMember(sprite); - } - } - delete bitmapDevice; - bitmapDevice=NULL; - User::LeaveIfError(err); - } - User::LeaveIfError(iCursor.Activate()); - } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tlib/testbase.h --- a/windowing/windowserver/tlib/testbase.h Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,562 +0,0 @@ -// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Base classes definitions used for building window server test code -// -// - -#ifndef __TESTBASE_H__ -#define __TESTBASE_H__ - -enum TTlibActivePriorities - { - ETlibRedrawActivePriority=-10, - ETlibWsEventActivePriority=0, - }; - -const TInt KDefaultScreen = 0; - -//enum {ENullWsHandle=0xFFFFFFFF}; // Events delivered to this handle are thrown away -const TUint32 ENullWsHandle=0xFFFFFFFF; // Events delivered to this handle are thrown away - -typedef TBuf TWindowTitle; -typedef TBuf<0x100> TWinCommand; - -const TUid KUidWServSecurityTesting={0x10205152}; -enum TWServSecTest - { - EWServSecTestBufferSecurity - }; - -class CTClient; // Forward reference -class CTWindowGroup; -class CTBaseWin; -class CTWin; - -typedef CTClient *(*TCreateClientFunc)(); - -IMPORT_C TBool CheckBlankWindow(TRect aArea,TRgb aColor,const CWsScreenDevice* aScreen); - -class CTWinBase : public CBase - { -protected: -public: - IMPORT_C CTWinBase(TInt aType); - IMPORT_C virtual TPoint Position() const; - IMPORT_C virtual void PointerEnter(const TTime &aTime); - IMPORT_C virtual void PointerExit(const TTime &aTime); - IMPORT_C virtual void PointerBufferReady(const TTime &aTime); - IMPORT_C virtual void PointerL(const TPointerEvent &aPointer,const TTime &aTime); - IMPORT_C virtual void SwitchOn(const TTime &aTime); - IMPORT_C virtual void ModifiersChanged(const TModifiersChangedEvent &aModifiersChanged ,const TTime &aTime); - IMPORT_C virtual void ErrorMessage(const TWsErrorMessage &aErrorMessage, const TTime &aTime); - IMPORT_C virtual void SetVisible(TBool aState); - IMPORT_C CTWinBase *Parent() const; - IMPORT_C CTWinBase *NextSibling() const; - IMPORT_C CTWinBase *PrevSibling() const; - IMPORT_C CTBaseWin *Child() const; - IMPORT_C virtual void AdjustOrdinal(TInt adjust); - IMPORT_C virtual void AdjustShadow(TInt aAdjust); - IMPORT_C virtual TInt SubType(); -// Pure virtual definitions - virtual void WinKeyL(const TKeyEvent &aKey,const TTime &aTime)=0; - virtual TSize Size() const=0; - virtual RWindowTreeNode *WinTreeNode()=0; - virtual const RWindowTreeNode *WinTreeNode() const=0; - IMPORT_C virtual CTClient *Client() const; - virtual CTWindowGroup *Group() const=0; - CTWindowGroup *iOwnerWin; -public: - TInt iType; - __DECLARE_TEST; - }; - -class CTBaseWin : public CTWinBase - { -public: - IMPORT_C CTBaseWin(TInt aType); - IMPORT_C ~CTBaseWin(); - IMPORT_C virtual void ConstructL(CTWinBase &parent); - IMPORT_C virtual void ConstructExtLD(CTWinBase &aParent, const TPoint &aPos, const TSize &aSize); - virtual TInt ConstructWin(const CTWinBase &aWs)=0; - IMPORT_C virtual void InitWin(); - IMPORT_C virtual void PointerL(const TPointerEvent &aPointer,const TTime &aTime); - IMPORT_C virtual void DragDropL(const TPointerEvent &aPointer,const TTime &aTime); - IMPORT_C virtual void RelinquishFocus(); - IMPORT_C void Activate(); - IMPORT_C virtual void AssignGC(CWindowGc &aGc); - IMPORT_C CTBaseWin *Next(); - IMPORT_C CTBaseWin *Prev(); - IMPORT_C virtual void SetExtL(const TPoint &aPos, const TSize &aSize); - IMPORT_C virtual void SetSizeL(const TSize &aSize); - IMPORT_C virtual void SetPos(const TPoint &aPos); - IMPORT_C void SetInitialPos(const TPoint &aPos); - IMPORT_C virtual void SetDefaultExtL(); - IMPORT_C virtual void SetFullScreenExtL(); - IMPORT_C virtual void AdjustSizeL(TInt xMove,TInt yMove,TInt resize); - IMPORT_C virtual TSize Size() const; - IMPORT_C virtual void Draw(); - IMPORT_C void DrawBorder(); -// void FillWindow(TInt inset); - IMPORT_C virtual TPoint Position() const; - IMPORT_C static void Delete(CTBaseWin *aWin); - IMPORT_C void AdjustOrdinal(TInt aAdjust); - IMPORT_C virtual void AdjustShadow(TInt aAdjust); - IMPORT_C void SetVisible(TBool aState); - IMPORT_C RWindowTreeNode *WinTreeNode(); - IMPORT_C const RWindowTreeNode *WinTreeNode() const; - IMPORT_C virtual void WinKeyL(const TKeyEvent &aKey,const TTime &aTime); - IMPORT_C virtual void KeyUpL(const TKeyEvent &aKey,const TTime &aTime); - IMPORT_C virtual void KeyDownL(const TKeyEvent &aKey,const TTime &aTime); - IMPORT_C virtual void SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc); - IMPORT_C virtual void SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc, TDisplayMode *aMode); - IMPORT_C void SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc,TBool aVisible); - enum - { - ENoTransparency=0x100 - }; - IMPORT_C virtual void SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc, TDisplayMode *aMode,TBool aVisible,TInt aTransparency=ENoTransparency); - IMPORT_C void SetDragRect(const TRect &aRect); - IMPORT_C virtual void Resized(const TSize &aSize); - IMPORT_C virtual void FocusChanged(TBool aState); - IMPORT_C virtual CTWindowGroup *Group() const; - virtual RWindowBase *BaseWin()=0; - virtual const RWindowBase *BaseWin() const=0; - inline CWindowGc *Gc(); -protected: - TSize iSize; - CWindowGc *iGc; // Not owned by the window, just using it - TPoint iPos; - TInt iShadow; - TRect iDragRect; - TBool iDragging; - TPoint iDragPos; - CFbsFont *iFont; - __DECLARE_TEST; - }; - -class CTDrawableWin : public CTBaseWin - { -public: - IMPORT_C CTDrawableWin(TInt aType); - virtual RDrawableWindow *DrawableWin()=0; - virtual const RDrawableWindow *DrawableWin() const=0; - }; - -class CTWin : public CTDrawableWin - { -public: - IMPORT_C CTWin(); - IMPORT_C ~CTWin(); - inline RWindow *Win() const; - IMPORT_C virtual TInt ConstructWin(const CTWinBase &aWs); - IMPORT_C void Invalidate(); - IMPORT_C void Invalidate(const TRect &rect); - IMPORT_C virtual void Redraw(); - IMPORT_C virtual void Redraw(const TRect &aRect); - IMPORT_C void DrawNow(); - IMPORT_C void SetExt(const TPoint &aPos, const TSize &aSize); - IMPORT_C void SetSize(const TSize &aSize); - IMPORT_C void SetDefaultExt(); - IMPORT_C void AdjustSize(TInt xMove,TInt yMove,TInt resize); - IMPORT_C virtual RWindowBase *BaseWin(); - IMPORT_C virtual const RWindowBase *BaseWin() const; - IMPORT_C virtual RDrawableWindow *DrawableWin(); - IMPORT_C virtual const RDrawableWindow *DrawableWin() const; -protected: - RWindow iWin; - __DECLARE_TEST; - }; - -class CTBackedUpWin : public CTDrawableWin - { -public: - IMPORT_C CTBackedUpWin(TDisplayMode aDisplayMode); - IMPORT_C ~CTBackedUpWin(); - IMPORT_C virtual TInt ConstructWin(const CTWinBase &aWs); - IMPORT_C virtual RWindowBase *BaseWin(); - IMPORT_C virtual const RWindowBase *BaseWin() const; - IMPORT_C virtual RDrawableWindow *DrawableWin(); - IMPORT_C virtual const RDrawableWindow *DrawableWin() const; - IMPORT_C RBackedUpWindow *BackedUpWin(); - IMPORT_C const RBackedUpWindow *BackedUpWin() const; -protected: - RBackedUpWindow iWin; - TDisplayMode iDisplayMode; - __DECLARE_TEST; - }; - -class CTTitledWindow : public CTWin - { -public: - IMPORT_C CTTitledWindow(); - IMPORT_C ~CTTitledWindow(); - IMPORT_C void ConstructL(CTWinBase &parent); - IMPORT_C void Draw(); - IMPORT_C void FocusChanged(TBool aState); - IMPORT_C void SetTitle(const TWindowTitle &aTitle); - IMPORT_C void SetColor(TRgb aRgb); - inline TRgb Color(); -private: - IMPORT_C void Resized(const TSize &aSize); -protected: - TWindowTitle iTitle; - TInt iTitleHeight; - TBool iFocus; - TRgb iWinColor; - TRgb iPenColor; - }; - -class CTBlankWindow : public CTBaseWin - { -public: - IMPORT_C CTBlankWindow(); - IMPORT_C ~CTBlankWindow(); - IMPORT_C void ConstructL(CTWinBase &aParent); - IMPORT_C void SetColor(const TRgb &aRgb); - IMPORT_C virtual TInt ConstructWin(const class CTWinBase&); - IMPORT_C virtual const RWindowBase *BaseWin()const; - IMPORT_C virtual RWindowBase *BaseWin(); - inline const RBlankWindow *BlankWin()const; - inline RBlankWindow *BlankWin(); - IMPORT_C void SetExt(const TPoint &aPos, const TSize &aSize); - IMPORT_C void SetSize(const TSize &aSize); -protected: - RBlankWindow iWin; - }; - -class CTWindowGroup : public CTWinBase - { -public: - IMPORT_C CTWindowGroup(CTClient *aClient); - IMPORT_C ~CTWindowGroup(); - IMPORT_C virtual void ConstructL(); - IMPORT_C void WinKeyL(const TKeyEvent &aKey,const TTime &aTime); - IMPORT_C virtual TSize Size() const; - IMPORT_C RWindowTreeNode *WinTreeNode(); - IMPORT_C const RWindowTreeNode *WinTreeNode() const; - inline RWindowGroup *GroupWin(); - IMPORT_C virtual void KeyL(const TKeyEvent &aKey,const TTime &aTime); - IMPORT_C virtual void KeyUpL(const TKeyEvent &aKey,const TTime &aTime); - IMPORT_C virtual void KeyDownL(const TKeyEvent &aKey,const TTime &aTime); - IMPORT_C virtual void PasswordL(const TTime &aTime); - IMPORT_C virtual void MessageReady(const TWsEvent &aTime); - IMPORT_C virtual void ScreenDeviceChanged(); - IMPORT_C virtual void UserEvent(TInt aEventType); - IMPORT_C void SetCurrentWindow(CTBaseWin *aWindow); - IMPORT_C void SetCurrentWindow(CTBaseWin *aWindow,TBool aLocked); - IMPORT_C CTBaseWin *CurWin(void) const; - IMPORT_C void FocusLost(); - IMPORT_C void FocusGained(); - IMPORT_C TBool HasFocus(CTBaseWin *aWin) const; - IMPORT_C virtual CTWindowGroup *Group() const; - IMPORT_C virtual CTClient *Client() const; - IMPORT_C void ClearCurrentWindow(); -protected: - CTClient *iClient; - CTBaseWin *iCurWin; - RWindowGroup iGroupWin; - TBool iLocked; - TBool iFocus; - }; - -inline RWindowGroup *CTWindowGroup::GroupWin() - {return(&iGroupWin);} - -class CTEventBase : public CActive - { -public: - IMPORT_C CTEventBase(RWsSession *aWs, TInt aPriority); - IMPORT_C ~CTEventBase(); - IMPORT_C void Construct(); - void SetCancelFunction(const TCallBack &aCallBack); - virtual void Request()=0; - inline TInt Count() {return iCount;} -protected: - virtual void doRunL()=0; - IMPORT_C void RunL(); - IMPORT_C void CancelHandler(); -protected: - TBool iCancelRequested; - TCallBack iCancelCallBack; - RWsSession *iWs; - TInt iCount; - }; - -class CTRedraw : public CTEventBase - { -public: - IMPORT_C CTRedraw(RWsSession *aWs); - IMPORT_C ~CTRedraw(); - IMPORT_C void Request(); -protected: - IMPORT_C void DoCancel(); - IMPORT_C void doRunL(); - }; - -class TlibWsEvent : public TWsEvent - { -public: - IMPORT_C CTWindowGroup *WindowGroup(); - IMPORT_C CTBaseWin *BaseWin(); - }; - -class CTEvent : public CTEventBase - { -public: - IMPORT_C CTEvent(RWsSession *aWs); - IMPORT_C ~CTEvent(); - IMPORT_C void Request(); - IMPORT_C virtual void LogEvent(const TWsEvent &aEvent); -protected: - IMPORT_C void DoCancel(); - IMPORT_C void doRunL(); - }; - -class CTClient : public CBase - { -public: - IMPORT_C CTClient(); - IMPORT_C ~CTClient(); - IMPORT_C virtual void ConstructL(); - IMPORT_C virtual void ConstructEventHandlerL(); - IMPORT_C void DestroyWindows(); - IMPORT_C TWindowTitle *Title(); - IMPORT_C void ResetFocus(); - IMPORT_C TBool QueueRead(); - IMPORT_C void CancelRead(); - IMPORT_C void CancelRedrawRead(); - IMPORT_C void SetCancelFunction(const TCallBack &aCallBack); - IMPORT_C void SetRedrawCancelFunction(const TCallBack &aCallBack); - IMPORT_C void RequestRedraw(); - IMPORT_C void LogMessage(const TLogMessageText &aMessage); - inline void Flush() {iWs.Flush();} - inline void SetScreenNumber(TInt aScreenNumber); - IMPORT_C TBool IsEventWaiting(); - IMPORT_C TBool WaitUntilEventPending(); - IMPORT_C TBool WaitUntilRedrawPending(); - inline CTEvent* EventHandler(); - inline CTRedraw* RedrawHandler(); - IMPORT_C TInt WaitForRedrawsToFinish(); - IMPORT_C TInt WaitForAllEventProcessingToFinish(); -private: - TBool WaitUntilEventPending(const TRequestStatus& aStatus); - TInt WaitForEventsToFinish(TBool aAll); -protected: - CTEvent *iEventHandler; - CTRedraw *iRedrawEventHandler; -public: - CWindowGc *iGc; - CTWindowGroup *iGroup; - RWsSession iWs; - CWsScreenDevice *iScreen; -protected: - TWindowTitle iTitle; - TInt iScreenNumber; - }; - -class CTAutoKey; -class CTDialog : public CTTitledWindow - { -public: - enum - { - EDialogWaitForButtonUp=0x0001, - EDialogDisplayAtBottom=0x0002, - EDialogDisplayAtLeft=0x0008, - }; -public: - IMPORT_C CTDialog(); - IMPORT_C ~CTDialog(); - IMPORT_C void ConstructLD(CTWinBase &aParent, CWindowGc &aGc); - IMPORT_C void Draw(); - IMPORT_C void WinKeyL(const TKeyEvent &aKey,const TTime &aTime); - IMPORT_C void PointerL(const TPointerEvent &aPointer,const TTime &aTime); - IMPORT_C virtual void ButtonPressL(TInt aButton); - IMPORT_C void SetLine1(const TDesC &aLine1); - IMPORT_C void SetLine2(const TDesC &aLine2); - IMPORT_C void SetNumButtons(TInt aNum); - IMPORT_C void SetButtonText(TInt aNum,const TDesC &aButton); - IMPORT_C void SetWindowSize(); - IMPORT_C void RelinquishFocus(); - IMPORT_C TInt Display(); - IMPORT_C void SetFlags(TUint aFlags); -protected: - void SetResult(TInt aButton); - inline void SetTakeFocus() {iTakeFocus=ETrue;} -private: - void SetMaxWid(TInt &aMax, TInt aWid); - TRect ButtonRect(TInt aIndex) const; -private: - TBool iIsActive; - TBool iActivated; - TBool iWinActive; - TBool iTakeFocus; - TInt iNumButtons; - TInt iButWid; - CTBaseWin *iOldFocus; - TInt *iResultPtr; - TBuf<0x40> iLine1; - TBuf<0x40> iLine2; - TBuf<0x20> iButton[3]; - TInt iButtonClickOn; - TUint iFlags; - CTAutoKey* iAutoKey; - }; - -class CInfoDialog : public CTDialog - { -private: - enum - { - eSeconds=1000000, - eTimes=6, - }; -public: - IMPORT_C CInfoDialog(CTWindowGroup *aGroupWin,CWindowGc *aGc); - IMPORT_C void ConstructLD(); - IMPORT_C void TimerResults(); - //Virtual function from CTDialog - IMPORT_C void ButtonPressL(TInt aButton); -private: - void AppendProfileTime(TDes &aDes, TInt aNum); - void AppendProfileCount(TDes &aDes, TInt aNum); - void AddComma(TDes &aDes); -private: - CTWindowGroup *iGroupWin; - CWindowGc *iGc; - }; - -class CEventWindow : public CTWin - { -public: - IMPORT_C CEventWindow(TInt aLogSize); - IMPORT_C ~CEventWindow(); - IMPORT_C void ConstructL(CTWinBase &parent); - IMPORT_C void SetUpL(const TPoint &pos, CTWinBase *parent, CWindowGc &aGc); - IMPORT_C void Draw(); - IMPORT_C void WinKeyL(const TKeyEvent &,const TTime &aTime); - IMPORT_C void LogEvent(const TWsEvent &aEvent); -private: - void DrawLine(TInt aLine, const TDesC &aText); - void LogEvent(TInt aLogNum, const TWsEvent &aEvent); -private: - TInt iLineHeight; - TInt iCount; - TInt iLogSize; - TInt iNumLogged; - TWsEvent *iLoggedEvents; - }; - -class CBlankWindow : public CTWin - { -public: - IMPORT_C CBlankWindow(TRgb aCol); - IMPORT_C CBlankWindow(); - IMPORT_C void ConstructL(CTWinBase &parent); - IMPORT_C void SetColor(TRgb aColor); - IMPORT_C void RealDraw(TBool aRealDraw); - IMPORT_C virtual void Draw(); - IMPORT_C void DrawNow(); - IMPORT_C void DrawNow(TRect& aRect); - IMPORT_C TBool Check(const CTClient& aClient); -protected: - TRgb iCol; - TBool iRealDraw; - }; - -struct TSpriteCreateParams; - -class CTSpriteBase : public CBase - { -public: - typedef void (*TSpriteDrawFunction)(CBitmapContext *aGc,TInt aIndex, const TSize &aSize, TBool aDoMask, TAny *aParam); -protected: - virtual RWsSpriteBase &SpriteBase()=0; - void CreateBitmapL(CFbsBitmap *&aBitmap, CFbsBitmapDevice *&aBitmapDevice, TSpriteCreateParams *aParams, TBool aDoMask); -public: - IMPORT_C void UpdateL(TInt aIndex, TSpriteCreateParams *aParams); - IMPORT_C void RedrawL(CFbsBitmap *&aBitmap, CFbsBitmap *&aMaskBitmap, TSpriteCreateParams *aParams); - }; - -class CTSprite : public CTSpriteBase - { -public: - IMPORT_C CTSprite(RWsSession &aWs); - IMPORT_C ~CTSprite(); - IMPORT_C void ConstructL(RWindowTreeNode &aWindow, const TPoint &aPos, TInt aCount, TSpriteCreateParams *aParams, TInt aFlags); - IMPORT_C RWsSpriteBase &SpriteBase(); - IMPORT_C RWsSprite &Sprite(); -private: - RWsSprite iSprite; - }; - -class CTPointerCursor : public CTSpriteBase - { -public: - IMPORT_C CTPointerCursor(RWsSession &aWs); - IMPORT_C ~CTPointerCursor(); - IMPORT_C void ConstructL(TInt aFlags); - IMPORT_C void ConstructL(TInt aCount, TSpriteCreateParams *aParams, TInt aFlags, CFbsBitmap *&aBitmap, CFbsBitmap *&aMaskBitmap); - IMPORT_C void ConstructL(TInt aCount, TSpriteCreateParams *aParams, TInt aFlags); - IMPORT_C RWsSpriteBase &SpriteBase(); - IMPORT_C RWsPointerCursor &PointerCursor(); -private: - RWsPointerCursor iCursor; - }; - -struct TSpriteCreateParams - { -public: - IMPORT_C TSpriteCreateParams(TSize aSize,TPoint aOffset,CTSpriteBase::TSpriteDrawFunction aDrawFunc,TAny *aDrawFuncParam=NULL, TBool aMask=ETrue,CGraphicsContext::TDrawMode aDrawMode=CGraphicsContext::EDrawModePEN); - IMPORT_C TSpriteCreateParams(); -public: - TSize iSize; - TPoint iOffset; - CTSpriteBase::TSpriteDrawFunction iDrawFunc; - TAny *iDrawFuncParam; - TBool iMask; - CGraphicsContext::TDrawMode iDrawMode; - TTimeIntervalMicroSeconds32 iInterval; - }; - -class CTUser - { -public: - IMPORT_C static void Splat(CTClient *aClient, const TRect &aRect, const TRgb &aRgb); - }; - -IMPORT_C void DisplayDialog(const TWindowTitle &aTitle, const TDesC &aLine1, const TDesC &aLine2, const RWindowGroup *aGroup=NULL); -IMPORT_C void DisplayDialog(TInt aScreenNumber,const TWindowTitle &aTitle, const TDesC &aLine1, const TDesC &aLine2, const RWindowGroup *aGroup=NULL); -IMPORT_C void DisplayDialog(CTClient *aClient, const TWindowTitle &aTitle, const TDesC &aLine1, const TDesC &aLine2); -IMPORT_C TInt TestLibStartUp(TCreateClientFunc aFunc); -IMPORT_C TInt TestLibStartUp(TCreateClientFunc aFunc,TInt aScreenNumber); - - -inline TRgb CTTitledWindow::Color() - {return(iWinColor);} -inline CWindowGc *CTBaseWin::Gc() - {return(iGc);} -inline RWindow *CTWin::Win() const - {return((RWindow *)BaseWin());} -inline const RBlankWindow *CTBlankWindow::BlankWin()const - {return(&iWin);} -inline RBlankWindow *CTBlankWindow::BlankWin() - {return(&iWin);} -inline void CTClient::SetScreenNumber(TInt aScreenNumber) - {iScreenNumber=aScreenNumber;} -inline CTEvent* CTClient::EventHandler() - {return iEventHandler;} -inline CTRedraw* CTClient::RedrawHandler() - {return iRedrawEventHandler;} -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tlisten/listener.cpp --- a/windowing/windowserver/tlisten/listener.cpp Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,380 +0,0 @@ -// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include "listener.h" -#include "wsgraphicdrawercontext.h" -#include -#include -#include -#include -#ifdef __WINS__ -#include "../debuglog/osbwin.h" -#endif - -const TInt KDefaultScreen = 0; -const TInt KListenDisable = 0; -const TInt KListenEnable = 1; -const TInt KCmdQuery = 2; - -const TUint8 KListenerInfoSig = 0xaa; - -NONSHARABLE_STRUCT(TListenerInfo) - { - TUint8 iSignature; - TInt iNumRect; - TRect iRect; - TInt iWindowGroupId; - }; - -const TInt KMaxColors = 14; -const TInt KColorList[KMaxColors] = - { - 0x555555, - 0x000080, - 0x008000, - 0x008080, - 0x800000, - 0x800080, - 0x808000, - 0x0000ff, - 0x00ff00, - 0x00ffff, - 0xff0000, - 0xff00ff, - 0xffff00, - 0xaaaaaa - }; - -CWsEventListener* CWsEventListener::NewL() - { - return new(ELeave) CWsEventListener; - } - -CWsEventListener::~CWsEventListener() - { - if (iEnabled) - Env().UnregisterEventHandler(this); - -#ifdef __WINS__ - if (!iDisableWin) - delete iWin; -#endif - delete iGc; - delete iDev; - delete iBit; - - if (iDrawerContext) - { - iDrawerContext->Destroy(); - iDrawerContext = NULL; - } - } - -void CWsEventListener::ConstructL(MWsGraphicDrawerEnvironment& aEnv, const TGraphicDrawerId& aId, MWsClient& aOwner, const TDesC8& aData) - { - BaseConstructL(aEnv, aId, aOwner); - -#ifdef __WINS__ - if (aData.Length()>0) - iDisableWin = aData[0]==1; -#endif - - iScreen = aEnv.Screen(KDefaultScreen); - MWsScreenConfig* screenConfig = iScreen->ObjectInterface(); - if (screenConfig) - {// Non NGA - iSize = screenConfig->SizeInPixels(); - iDisplayMode = screenConfig->DisplayMode(); - iDrawerContext = CWsGraphicDrawerNonNgaContext::NewL(); - } - else - {// NGA - MWsScreenDevice* screenDevice = iScreen->ObjectInterface(); - User::LeaveIfNull(screenDevice); - iSize = screenDevice->SizeInPixels(); - iDisplayMode = screenDevice->DisplayMode(); - iDrawerContext = CWsGraphicDrawerNgaContext::NewL(); - } - - iWindowGroupId = KErrNotFound; - - iBit = new(ELeave) CFbsBitmap; - User::LeaveIfError(iBit->Create(iSize,iDisplayMode)); - iDev = CFbsBitmapDevice::NewL(iBit); - User::LeaveIfNull(iDev); - User::LeaveIfError(iDev->CreateContext(iGc)); - iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - iGc->SetPenStyle(CGraphicsContext::ENullPen); - -#ifdef __WINS__ - if (!iDisableWin) - { - _LIT(KListener, "EventListener"); - iWin = CDebugOsbWin::NewL(KListener, iBit->SizeInPixels()); - } -#endif - iReady = ETrue; - } - -void CWsEventListener::HandleMessage(const TDesC8& aData) - { - // wserv already check data size, and won't invoke this handler if it's empty - switch (aData[0]) - { - case KListenEnable: - if (!iEnabled) - { - Env().RegisterEventHandler(this, this, TWservCrEvent::EScreenSizeModeChanged|TWservCrEvent::EWindowVisibilityChanged|TWservCrEvent::EWindowGroupChanged); - iEnabled = ETrue; - } - break; - - case KListenDisable: - if (iEnabled) - { - iEnabled = EFalse; - Env().UnregisterEventHandler(this); - } - break; - - case KCmdQuery: - SendInfo(); - break; - } - } - -void CWsEventListener::DoHandleEvent(const TWservCrEvent& aEvent) - { - if (!iReady) - return; - - switch (aEvent.Type()) - { - case TWservCrEvent::EScreenSizeModeChanged: - OnScreenSizeModeChanged(aEvent.SizeMode()); - break; - - case TWservCrEvent::EWindowVisibilityChanged: - OnWindowVisibilityChanged(aEvent.VisibleRegion()); - break; - - case TWservCrEvent::EWindowGroupChanged: - OnWindowGroupChanged(aEvent.ScreenNumber(), aEvent.WindowGroupIdentifier()); - break; - } - } - -void CWsEventListener::DoDraw(MWsGc& aGc, const TRect& aRect, const TDesC8& /*aData*/) const - { - iDrawerContext->DrawEllipse(aGc, aRect, TRgb(0,255,0,128)); - } - -void CWsEventListener::OnScreenSizeModeChanged(TInt /*aMode*/) - { - iGc->SetBrushColor(KRgbWhite); - iGc->Clear(); - -#ifdef __WINS__ - if (!iDisableWin) - { - iBit->LockHeap(); - iWin->Refresh(iBit->SizeInPixels(), iBit->DisplayMode(), iBit->DataAddress()); - iBit->UnlockHeap(); - } -#endif - } - -TRgb CWsEventListener::CurrentColor() - { - iColorIdx = (iColorIdx+1) % KMaxColors; - return TRgb(KColorList[iColorIdx]); - } - -void CWsEventListener::OnWindowVisibilityChanged(const RRegion* aRegion) - { - if (!aRegion) - return; - - TInt n = aRegion->Count(); - if (n==0) - return; - iGc->SetBrushColor(CurrentColor()); - for (TInt i=0; iDrawRect((*aRegion)[i]); - } - - iSaveNumRect = n; - iSaveRect = (*aRegion)[0]; - -#ifdef __WINS__ - if (!iDisableWin) - { - iBit->LockHeap(); - iWin->Refresh(iBit->SizeInPixels(), iBit->DisplayMode(), iBit->DataAddress()); - iBit->UnlockHeap(); - } -#endif - } - -void CWsEventListener::OnWindowGroupChanged(TInt /*aScreenNumber*/, TInt aWindowGroupId) - { - iWindowGroupId = aWindowGroupId; - } - -void CWsEventListener::SendInfo() - { - TPckgBuf buf; - buf().iSignature = KListenerInfoSig; - buf().iNumRect = iSaveNumRect; - buf().iRect = iSaveRect; - buf().iWindowGroupId = iWindowGroupId; - TInt err = SendMessage(buf); - __ASSERT_ALWAYS(err>=KErrNone, User::Invariant()); - iSaveNumRect = 0; - iSaveRect = TRect(); - } - -CWsEventNotifier* CWsEventNotifier::NewL() - { - return new(ELeave) CWsEventNotifier; - } - -CWsEventNotifier::~CWsEventNotifier() - { - Env().UnregisterEventHandler(this); - } - -void CWsEventNotifier::ConstructL(MWsGraphicDrawerEnvironment& aEnv, const TGraphicDrawerId& aId, MWsClient& aOwner, const TDesC8& /*aData*/) - { - BaseConstructL(aEnv, aId, aOwner); - iEnv = &aEnv; - iTestGraphicDrawerEnvironment = EFalse; - iReady = ETrue; - } - -void CWsEventNotifier::HandleMessage(const TDesC8& aData) - { - // wserv already checked data size, and won't invoke this handler if it's empty - switch (aData[0]) - { //Set how it will handle the first visibility event - case KNotifyRemoveSelf: - case KNotifyRemoveThenAddSelf: - case KNotifyAddSelf: - case KNotifyRemoveOther: - case KNotifyRemoveThenAddOther: - case KNotifyAddOther: - case KNotifyRemoveSelfAndOther: - case KNotifyDoNothing: - Env().RegisterEventHandler(this, this, TWservCrEvent::EWindowVisibilityChanged); - iHandleMethod = aData[0]; - break; - case KNotifyDisable: - Env().UnregisterEventHandler(this); - iHandleMethod = KNotifyDoNothing; - break; - default: - break; - } - } - -void CWsEventNotifier::DoHandleEvent(const TWservCrEvent& /*aEvent*/) - { - if(!iTestGraphicDrawerEnvironment) - { - iTestGraphicDrawerEnvironment = ETrue; - TestGraphicDrawerEnvironment(); - } - - if (iHandleMethod == KNotifyRemoveSelf) - { - Env().UnregisterEventHandler(this); - iHandleMethod = KNotifyDoNothing; - } - else if (iHandleMethod == KNotifyRemoveThenAddSelf) - { - Env().UnregisterEventHandler(this); - Env().RegisterEventHandler(this, this, TWservCrEvent::EWindowVisibilityChanged); - iHandleMethod = KNotifyDoNothing; - } - else if (iHandleMethod == KNotifyAddSelf) - { - Env().RegisterEventHandler(this, this, TWservCrEvent::EWindowVisibilityChanged); - iHandleMethod = KNotifyDoNothing; - } - else if (iHandleMethod == KNotifyRemoveOther) - { - iAnotherPluginID.iId = 0x102754c5; //First method that needs the address of the other plugin - iAnotherPluginID.iIsUid = ETrue; - iAnotherPlugin = const_cast(Env().ResolveGraphic(iAnotherPluginID)); - Env().UnregisterEventHandler(iAnotherPlugin); - iHandleMethod = KNotifyDoNothing; - } - else if (iHandleMethod == KNotifyRemoveThenAddOther) - { - Env().UnregisterEventHandler(iAnotherPlugin); - Env().RegisterEventHandler(iAnotherPlugin, this, TWservCrEvent::EWindowVisibilityChanged); - iHandleMethod = KNotifyDoNothing; - } - else if (iHandleMethod == KNotifyAddOther) - { - Env().RegisterEventHandler(iAnotherPlugin, this, TWservCrEvent::EWindowVisibilityChanged); - iHandleMethod = KNotifyDoNothing; - } - else if (iHandleMethod == KNotifyRemoveSelfAndOther) - { - Env().UnregisterEventHandler(this); - Env().UnregisterEventHandler(iAnotherPlugin); - iHandleMethod = KNotifyDoNothing; - } - } - -void CWsEventNotifier::DoDraw(MWsGc& /*aGc*/, const TRect& /*aRect*/, const TDesC8& /*aData*/) const - { - } - -void CWsEventNotifier::TestGraphicDrawerEnvironment() - { - const MWsGraphicDrawerEnvironment* aEnvConst = iEnv; - TInt lowerbound = -1; - //-tests Screen methods (const and non const) - __ASSERT_ALWAYS(iEnv->Screen(lowerbound)==NULL, SendMessage(_L8("Error:iEnv->Screen(lowerbound) - expected: NULL, actual: !NULL (listener.cpp)"))); - __ASSERT_ALWAYS(iEnv->Screen(iEnv->ScreenCount())==NULL, SendMessage(_L8("Error:iEnv->Screen(iEnv->ScreenCount()) - expected: NULL, actual: !NULL (listener.cpp)"))); - __ASSERT_ALWAYS(aEnvConst->Screen(lowerbound)==NULL, SendMessage(_L8("Error:aEnvConst->Screen(lowerbound) - expected: NULL, actual: !NULL (listener.cpp)"))); - __ASSERT_ALWAYS(aEnvConst->Screen(aEnvConst->ScreenCount())==NULL, SendMessage(_L8("Error:aEnvConst->ScreenCount()) - expected: NULL, actual: !NULL (listener.cpp)"))); - //+test const screen method - const MWsScreen* constScreen = aEnvConst->Screen(aEnvConst->ScreenCount()-1); - __ASSERT_ALWAYS(constScreen!=NULL, SendMessage(_L8("Error:constScreen - expected: !NULL, actual: NULL (listener.cpp)"))); - //+test resolveobjectinterface method - MWsActiveSchedulerDebug* scheduler = iEnv->ObjectInterface(); - __ASSERT_ALWAYS(scheduler!=NULL, SendMessage(_L8("Error:scheduler - expected: !NULL, actual: NULL (listener.cpp)"))); - TUint32 eventMask = 0; - //-tests for registereventhandler and unregistereventhandler - __ASSERT_ALWAYS(iEnv->RegisterEventHandler(NULL,this, TWservCrEvent::EWindowClosing)==KErrArgument, SendMessage(_L8("Error:iEnv->RegisterEventHandler(NULL,this, TWservCrEvent::EWindowClosing) - expected: KErrArgument, actual: !KErrArgument (listener.cpp)"))); - __ASSERT_ALWAYS(iEnv->RegisterEventHandler(this,NULL, TWservCrEvent::EWindowClosing)==KErrArgument, SendMessage(_L8("Error:iEnv->RegisterEventHandler(this,NULL, TWservCrEvent::EWindowClosing) - expected: KErrArgument, actual: !KErrArgument (listener.cpp)"))); - __ASSERT_ALWAYS(iEnv->RegisterEventHandler(this,this, eventMask)==KErrArgument, SendMessage(_L8("Error:iEnv->RegisterEventHandler(this,this, eventMask) - expected: KErrArgument, actual: !KErrArgument (listener.cpp)"))); - __ASSERT_ALWAYS(iEnv->UnregisterEventHandler(NULL)==KErrArgument, SendMessage(_L8("Error:iEnv->UnregisterEventHandler(NULL) - expected: KErrArgument, actual: !KErrArgument (listener.cpp)"))); - //-tests for registerwseventhandler -#ifdef SYMBIAN_GRAPHICS_GCE - __ASSERT_ALWAYS(iEnv->RegisterWsEventHandler(this, eventMask)==KErrArgument, SendMessage(_L8("Error:iEnv->RegisterWsEventHandler(this, eventMask) - expected: KErrArgument, actual: !KErrArgument (listener.cpp)"))); - __ASSERT_ALWAYS(iEnv->RegisterWsEventHandler(NULL, TWservCrEvent::EWindowClosing)==KErrArgument, SendMessage(_L8("Error:iEnv->RegisterWsEventHandler(NULL, TWservCrEvent::EWindowClosing) - expected: KErrArgument, actual: !KErrArgument (listener.cpp)"))); -#endif //SYMBIAN_GRAPHICS_GCE - } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tlisten/listener.h --- a/windowing/windowserver/tlisten/listener.h Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,118 +0,0 @@ -// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef __LISTENER_H__ -#define __LISTENER_H__ - -#include -#include "Graphics/WSGRAPHICDRAWER.H" -#include - -class CFbsBitmap; -class CFbsBitmapDevice; -class CFbsBitGc; -class MWsGraphicDrawerContext; -#ifdef __WINS__ -class CDebugOsbWin; -#endif - -const TInt KNotifyRemoveSelf = 0; -const TInt KNotifyRemoveThenAddSelf = 1; -const TInt KNotifyAddSelf = 2; -const TInt KNotifyRemoveOther = 3; -const TInt KNotifyRemoveThenAddOther = 4; -const TInt KNotifyAddOther = 5; -const TInt KNotifyRemoveSelfAndOther = 6; -const TInt KNotifyDoNothing = 7; -const TInt KNotifyDisable = 8; - -NONSHARABLE_CLASS(CWsEventListener): public CWsGraphicDrawer, public MWsEventHandler - { -public: - enum {EImplUid = 0x10281fb7}; - -public: - static CWsEventListener* NewL(); - virtual ~CWsEventListener(); - - // override CWsGraphicDrawer - virtual void ConstructL(MWsGraphicDrawerEnvironment& aEnv,const TGraphicDrawerId& aId, MWsClient& aOwner, const TDesC8& aData); - virtual void HandleMessage(const TDesC8& aData); - // override MWsEventHandler - virtual void DoHandleEvent(const TWservCrEvent& aEvent); -private: - // override CWsGraphicDrawer - virtual void DoDraw(MWsGc& aGc, const TRect& aRect, const TDesC8& aData) const; - - void OnScreenSizeModeChanged(TInt aMode); - void OnWindowVisibilityChanged(const RRegion* aRegion); - TRgb CurrentColor(); - void SendInfo(); - void OnWindowGroupChanged(TInt aScreenNumber, TInt aWindowGroupId); -private: - MWsGraphicDrawerContext* iDrawerContext; - CFbsBitmap* iBit; - CFbsBitmapDevice* iDev; - CFbsBitGc* iGc; -#ifdef __WINS__ - CDebugOsbWin* iWin; - TBool iDisableWin; -#endif - TBool iEnabled; - TBool iReady; - TSize iSize; - TDisplayMode iDisplayMode; - MWsScreen* iScreen; - TInt iColorIdx; - TInt iSaveNumRect; - TRect iSaveRect; - TInt iWindowGroupId; - }; - -NONSHARABLE_CLASS(CWsEventNotifier): public CWsGraphicDrawer, public MWsEventHandler - { -public: - enum { EImplUid1 = 0x102754c4, - EImplUid2 = 0x102754c6}; - -public: - static CWsEventNotifier* NewL(); - virtual ~CWsEventNotifier(); - - // override CWsGraphicDrawer - virtual void ConstructL(MWsGraphicDrawerEnvironment& aEnv,const TGraphicDrawerId& aId, MWsClient& aOwner, const TDesC8& aData); - virtual void HandleMessage(const TDesC8& aData); - // override MWsEventHandler - virtual void DoHandleEvent(const TWservCrEvent& aEvent); -private: - // override CWsGraphicDrawer - virtual void DoDraw(MWsGc& aGc, const TRect& aRect, const TDesC8& aData) const; - void TestGraphicDrawerEnvironment(); -private: - TBool iReady; - TInt iHandleMethod; - TGraphicDrawerId iAnotherPluginID; - CWsGraphicDrawer* iAnotherPlugin; - TBool iTestGraphicDrawerEnvironment; - MWsGraphicDrawerEnvironment* iEnv; - }; - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tlisten/listener.rss --- a/windowing/windowserver/tlisten/listener.rss Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,75 +0,0 @@ -// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include - -RESOURCE REGISTRY_INFO registry_info - { - dll_uid = 0x10281fb5; - interfaces = - { - INTERFACE_INFO - { - interface_uid = 0x10281fb6; - implementations = - { - IMPLEMENTATION_INFO - { - implementation_uid = 0x10281fb7; - version_no = 1; - display_name = "CWsEventListener"; - default_data = ""; - opaque_data = ""; - } - }; - }, - INTERFACE_INFO - { - interface_uid = 0x102754c3; - implementations = - { - IMPLEMENTATION_INFO - { - implementation_uid = 0x102754c4; - version_no = 1; - display_name = "CWsEventNotifier1"; - default_data = ""; - opaque_data = ""; - } - }; - }, - INTERFACE_INFO - { - interface_uid = 0x102754c5; - implementations = - { - IMPLEMENTATION_INFO - { - implementation_uid = 0x102754c6; - version_no = 1; - display_name = "CWsEventNotifier2"; - default_data = ""; - opaque_data = ""; - } - }; - } - }; - } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tlisten/proxy.cpp --- a/windowing/windowserver/tlisten/proxy.cpp Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,37 +0,0 @@ -// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include -#include "listener.h" - - -LOCAL_C const TImplementationProxy KImplementationTable[] = - { - IMPLEMENTATION_PROXY_ENTRY(CWsEventListener::EImplUid, CWsEventListener::NewL), - IMPLEMENTATION_PROXY_ENTRY(CWsEventNotifier::EImplUid1, CWsEventNotifier::NewL), - IMPLEMENTATION_PROXY_ENTRY(CWsEventNotifier::EImplUid2, CWsEventNotifier::NewL) - }; - -EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) - { - aTableCount = sizeof(KImplementationTable)/sizeof(TImplementationProxy); - return KImplementationTable; - } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tlisten/wsgraphicdrawercontext.h --- a/windowing/windowserver/tlisten/wsgraphicdrawercontext.h Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,50 +0,0 @@ -// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -#ifndef __WSGRAPHICDRAWERCONTEXT_H__ -#define __WSGRAPHICDRAWERCONTEXT_H__ - -#include -#include - -class MWsGc; -class TRgb; - -class MWsGraphicDrawerContext - { -public: - virtual void Destroy() = 0; - virtual void DrawEllipse(MWsGc& aGc, const TRect& aRect, const TRgb& aColor) const = 0; - }; - -class CWsGraphicDrawerNgaContext : public CBase, public MWsGraphicDrawerContext - { -public: - static MWsGraphicDrawerContext* NewL(); -public: - void Destroy(); - void DrawEllipse(MWsGc& aGc, const TRect& aRect, const TRgb& aColor) const; - }; - -class CWsGraphicDrawerNonNgaContext : public CBase, public MWsGraphicDrawerContext - { -public: - static MWsGraphicDrawerContext* NewL(); -public: - void Destroy(); - void DrawEllipse(MWsGc& aGc, const TRect& aRect, const TRgb& aColor) const; - }; - -#endif // __WSGRAPHICDRAWERCONTEXT_H__ diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tlisten/wsgraphicdrawerngacontext.cpp --- a/windowing/windowserver/tlisten/wsgraphicdrawerngacontext.cpp Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,42 +0,0 @@ -// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -#define SYMBIAN_GRAPHICS_GCE - -#include "wsgraphicdrawercontext.h" -#include - -MWsGraphicDrawerContext* CWsGraphicDrawerNgaContext::NewL() - { - return new(ELeave) CWsGraphicDrawerNgaContext(); - } - -void CWsGraphicDrawerNgaContext::Destroy() - { - delete this; - } - -void CWsGraphicDrawerNgaContext::DrawEllipse(MWsGc& aGc, const TRect& aRect, const TRgb& aColor) const - { - MWsGraphicsContext* context = aGc.ObjectInterface(); - if (context) - { - context->Push(); - context->SetBrushStyle(MWsGraphicsContext::ESolidBrush); - context->SetBrushColor(aColor); - context->DrawEllipse(aRect); - context->Pop(); - } - } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tlisten/wsgraphicdrawernonngacontext.cpp --- a/windowing/windowserver/tlisten/wsgraphicdrawernonngacontext.cpp Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -#undef SYMBIAN_GRAPHICS_GCE - -#include "wsgraphicdrawercontext.h" -#include -#include - -MWsGraphicDrawerContext* CWsGraphicDrawerNonNgaContext::NewL() - { - return new(ELeave) CWsGraphicDrawerNonNgaContext(); - } - -void CWsGraphicDrawerNonNgaContext::Destroy() - { - delete this; - } - -void CWsGraphicDrawerNonNgaContext::DrawEllipse(MWsGc& aGc, const TRect& aRect, const TRgb& aColor) const - { - aGc.PushBitGcSettings(); - CFbsBitGc& bitGc = aGc.BitGc(); - bitGc.SetBrushStyle(CGraphicsContext::ESolidBrush); - bitGc.SetBrushColor(aColor); - bitGc.DrawEllipse(aRect); - aGc.PopBitGcSettings(); - } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tlisten/wslisten.cpp --- a/windowing/windowserver/tlisten/wslisten.cpp Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,178 +0,0 @@ -// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// The plug-in provides the client side CWsGraphic instance CWsListen, which is used in -// GRAPHICS-WSERV-0023 and GRAPHICS-WSERV-0024. -// This is also used for Test Case GRAPHICS-WSERV-0058 for INC094118: CWsGraphicDrawer::SendMessage panics window server. -// The customer incident "INC094118" reports the failure of CWsGraphicDrawer::SendMessage(const TDesC8& aData) -// when the event message iEventMsg is not ready. The defect is reproduced by calling QueryPlugin(aInfo) -// once again to wserv plug-in side in the CWsListen::HandleMessage(const TDesC8& aData), when the event -// message has not yet been reset by CWsGraphic::CManager. Certainly in practice there are many other cases -// which could trigger the defect. -// The fix is added in CWsGraphicMessageQueue::Queue(CMessage* aMessage), where we check whether the iEventMsg -// is empty or not. As a result, if iEventMsg is not ready we do not signal event but keep message untouched in queue. -// nce the iEventMsg is set ready, an event is signaleed immediately if there is a waiting event and message -// will be popped out of the queue. -// The test of defect-fixing INC094118 can be enabled by initialising iTestFlag to ETrue. Setting iTestFlag to -// EFalse will not trigger the defect. A new test case is written to trigger the defect only once. -// -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include "wslisten.h" - -const TUid KListenerInterfaceId = {0x10281fb6}; -const TUid KListenerImplId = {0x10281fb7}; -const TUid KNotifierInterfaceId1 = {0x102754c3}; -const TUid KNotifierImplId1 = {0x102754c4}; -const TUid KNotifierInterfaceId2 = {0x102754c5}; -const TUid KNotifierImplId2 = {0x102754c6}; - -const TUint8 KCmdDisable = 0; -const TUint8 KCmdEnable = 1; -const TUint8 KCmdQuery = 2; - -EXPORT_C CWsListen* CWsListen::NewL() - { - return NewL(EFalse); - } - -EXPORT_C CWsListen* CWsListen::NewL(TBool aDisableWin) - { - CWsListen* self = new(ELeave) CWsListen; - CleanupStack::PushL(self); - TBuf8<1> data; - data.Append((TUint8)aDisableWin); - self->BaseConstructL(KListenerInterfaceId, KListenerImplId, data); - CleanupStack::Pop(self); - //Initialise the test flag to EFalse if dont want to reproduce the INC094118 and test the fix - self->iTestFlag = EFalse; - self->iIsReady = ETrue; - return self; - } - -EXPORT_C CWsListen::~CWsListen() - { - iIsReady = EFalse; - } - -EXPORT_C void CWsListen::SetTestFlag() - { - //Set the test flag to ETrue if want to reproduce the INC094118 and test the fix - iTestFlag = ETrue; - } - -void CWsListen::HandleMessage(const TDesC8& aData) - { - if (aData[0]==KListenerInfoSig) - Mem::Copy(iReq, aData.Ptr(), aData.Size()); - //The if-statement allows to call QueryPlugin() in HandleMessage() only once to reproduce the defect INC094118. - //Otherwise HandleMessage() will behave as normal. - if (iTestFlag) - { - TListenerInfo aInfo; - QueryPlugin(aInfo) ; - iTestFlag = EFalse; - } - else - { - iCallBack.CallBack(); - } - } - -void CWsListen::OnReplace() - { - } - -EXPORT_C TInt CWsListen::Enable(TBool aEnabled) - { - if (!iIsReady) - return KErrNotReady; - - TBuf8<1> cmd; - cmd.Append(aEnabled? KCmdEnable : KCmdDisable); - SendMessage(cmd); - return Flush(); - } - -EXPORT_C TInt CWsListen::QueryPlugin(TListenerInfo& aInfo) - { - TBuf8<1> cmd; - cmd.Append(KCmdQuery); - SendMessage(cmd); - TInt err = Flush(); - if (err!=KErrNone) - return err; - iReq = &aInfo; - return KErrNone; - } - -EXPORT_C void CWsListen::SetCallBack(TCallBack aCallBack) - { - iCallBack = aCallBack; - } - -EXPORT_C CWsNotify* CWsNotify::NewL() - { - return NewL(EFalse); - } - -EXPORT_C CWsNotify* CWsNotify::NewL(TBool aPluginOrder) - { - CWsNotify* self = new(ELeave) CWsNotify; - CleanupStack::PushL(self); - TBuf8<1> data; - data.Append(8); - if (!aPluginOrder) //Different IDs so 2 plugins may be registered at once - self->BaseConstructL(KNotifierInterfaceId1, KNotifierImplId1, data); - else - self->BaseConstructL(KNotifierInterfaceId2, KNotifierImplId2, data); - CleanupStack::Pop(self); - self->iIsReady = ETrue; - self->iResult = ETrue; - return self; - } - -EXPORT_C CWsNotify::~CWsNotify() - { - iIsReady = EFalse; - } - -void CWsNotify::HandleMessage(const TDesC8& aData) - { - TBuf8<100> KTesting(_L8("Error:")); - if(aData.Find(KTesting)!=KErrNotFound) - { - iError.Copy(aData); - iResult = EFalse; - } - } - -void CWsNotify::OnReplace() - { - } - -EXPORT_C TInt CWsNotify::SetBehaviour(TInt aType) - { - if (!iIsReady) - return KErrNotReady; - TBuf8<1> cmd; - cmd.Append(aType); - SendMessage(cmd); - return Flush(); - } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tlisten/wslisten.h --- a/windowing/windowserver/tlisten/wslisten.h Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,76 +0,0 @@ -// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef __WSLISTEN_H__ -#define __WSLISTEN_H__ - -#include - -const TUint8 KListenerInfoSig = 0xaa; - -NONSHARABLE_STRUCT(TListenerInfo) - { - TUint8 iSignature; - TInt iNumRect; - TRect iRect; - TInt iWindowGroupId; - }; - -NONSHARABLE_CLASS(CWsListen): public CWsGraphic - { -public: - IMPORT_C static CWsListen* NewL(); - IMPORT_C static CWsListen* NewL(TBool aDisableWin); - IMPORT_C ~CWsListen(); - IMPORT_C TInt Enable(TBool aEnabled); - IMPORT_C void SetCallBack(TCallBack aCallBack); - IMPORT_C TInt QueryPlugin(TListenerInfo& aInfo); - IMPORT_C void SetTestFlag(); -private: - // override CWsGraphic - virtual void HandleMessage(const TDesC8& aData); - virtual void OnReplace(); -private: - TBool iIsReady; - TCallBack iCallBack; - TListenerInfo* iReq; - TBool iTestFlag; - }; - -NONSHARABLE_CLASS(CWsNotify): public CWsGraphic - { -public: - IMPORT_C static CWsNotify* NewL(); - IMPORT_C static CWsNotify* NewL(TBool aPluginOrder); - IMPORT_C ~CWsNotify(); - IMPORT_C TInt SetBehaviour(TInt aType); -private: - // override CWsGraphic - virtual void HandleMessage(const TDesC8& aData); - virtual void OnReplace(); -private: - TBool iIsReady; -public: - TBool iResult; - TBuf16<100> iError; - }; - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tman/DUMMYM.CPP --- a/windowing/windowserver/tman/DUMMYM.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,60 +0,0 @@ -// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Simple dummy test, to be used as example for new tests -// -// - -#include -#include "W32STD.H" -#include "../tlib/testbase.h" -#include "TMAN.H" - -class TDummyTest : public CTestBase - { -public: - TDummyTest(); - TestState DoTestL(); - void ConstructL(); -private: - TSize iWinSize; - TInt iState; - }; - -GLDEF_C CTestBase *CreateDummyTest() - { - return(new(ELeave) TDummyTest()); - } - -TDummyTest::TDummyTest() : CTestBase(_L("Dummy")) - {} - -void TDummyTest::ConstructL() - { - } - -TestState TDummyTest::DoTestL() - { - switch(iState) - { - case 0: - LogSubTest(_L("Dummy 1"),1); - TestL(ETrue); - iState++; - break; - default: - return(EFinished); - } - return(ENext); - } - diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tman/HOTKEY2.CPP --- a/windowing/windowserver/tman/HOTKEY2.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,424 +0,0 @@ -// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Test capture key -// -// - -#include -#include -#include "W32STD.H" -#include "../tlib/testbase.h" -#include "TMAN.H" - -enum THotKeyRetValues - { - EHotKeyOkay, - EHotKeyRetry, - EHotKeyFail, - }; - -struct SHotKeyParams - { - THotKey hotKey; - TUint keyCode; - TUint mod_mask; - TUint modifiers; - }; - -struct SHotKeyTestParams - { - TText *txt; // Text message telling user what to do - }; - -LOCAL_D SHotKeyParams HotKeys[]={ - {EHotKeyEnableLogging,'e',EModifierFunc|EModifierCtrl|EModifierShift,0}, - {EHotKeyDisableLogging,'d',EModifierFunc|EModifierCtrl|EModifierShift,EModifierFunc}, - {EHotKeyOfDeath,'q',0}, - {EHotKeyOfDeath,'w',0}, - }; - -LOCAL_D SHotKeyTestParams HotKeyTests[]={ - {(TText *)_S("Use \"e\" to enable logging")}, - {(TText *)_S("Use \"d\" to disable logging")}, - {(TText *)_S("Use \"q\" to kill the foreground app")}, - {(TText *)_S("Use \"w\" to kill the foreground app")}, - {(TText *)_S("Use \"K\" to kill the foreground app")}, - }; - -LOCAL_D TBool HotKeyTestIsDeathTest[]={EFalse, EFalse, ETrue, ETrue, ETrue}; - -struct SErrorHotKey - { - THotKey hotKey; - TUint keyCode; - TUint mod_mask; - TUint modifiers; - }; - -LOCAL_D SErrorHotKey errorKeys[]={ - {EHotKeyEnableLogging,'a',EModifierFunc|EModifierShift,EModifierFunc|EModifierCtrl}, - {EHotKeyDisableLogging,'1',0,EModifierFunc}, - {EHotKeyEnableLogging,3,EModifierCtrl,EModifierCtrl|EModifierShift}, - {EHotKeyDisableLogging,'a',EModifierFunc|EModifierShift,EModifierFunc|EModifierCtrl}, - {(THotKey)100,'1',0,EModifierFunc}, - {(THotKey)200, 3,EModifierCtrl,EModifierCtrl|EModifierShift}, - }; - -const TInt numHotKeys=sizeof(HotKeys)/sizeof(HotKeys[0]); -const TInt numHotKeyTests=sizeof(HotKeyTests)/sizeof(HotKeyTests[0]); -const TInt numErrorKeys=sizeof(errorKeys)/sizeof(errorKeys[0]); - -class SHKWindow; -class THotKeyTest; -class SHKConnection; - -class SHKDeath : public CActive - { -public: - SHKDeath(TInt aPriority); - void SetConnection(SHKConnection *aConn); - virtual void DoCancel(); - virtual void RunL(); - void Request(); -private: - SHKConnection *iConn; - }; - -class SHKWindowGroup : public CTWindowGroup - { -public: - SHKWindowGroup(CTClient *aClient); - void KeyL(const TKeyEvent &aKey,const TTime &aTime); - }; - -class SHKConnection : public CTClient - { -public: - SHKConnection(THotKeyTest *aTest, TInt aMode); - ~SHKConnection(); - void ConstructL(); - void KeyL(const TKeyEvent &aKey); - void SubStateChangedL(); - void CompleteL(); -protected: - TInt iMode; - SHKDeath iDeath; - THotKeyTest *iTest; - CTWin *iWin; - static TInt iMainWinId; - }; - -class SHKWindow : public CTWin - { -public: - SHKWindow(THotKeyTest *aTest); - void SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc); - void Draw(); -protected: - THotKeyTest *iTest; - TRgb iBack; - }; - -class SHKWindow2 : public CTWin - { -public: - SHKWindow2(); - void SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc); - void Draw(); - }; - -class THotKeyTest : public CTestBase - { -public: - THotKeyTest(); - ~THotKeyTest(); - TestState DoTestL(); - void ConstructL(); - void EndCaptureKeyTest(); - TInt SubState() const; - void IncSubStateL(); - void BadParamsL(); -private: - SHKConnection *iConn1; - TSize iWinSize; - TInt iState; - TInt iSubState; - TBool iIsInActiveScheduler; - }; - -TInt SHKConnection::iMainWinId; - -TInt SubThread(TAny *); - -GLDEF_C CTestBase *CreateHotKeyTest() - { - return(new(ELeave) THotKeyTest()); - } - -THotKeyTest::THotKeyTest() : CTestBase(_L("Hot Key")) - {} - -THotKeyTest::~THotKeyTest() - { - User::SetJustInTime(ETrue); - for(TInt index=0;indexiWs.ClearHotKeys(HotKeys[index].hotKey); - Client()->iWs.RestoreDefaultHotKey(HotKeys[index].hotKey); - } - delete iConn1; - if (iIsInActiveScheduler) - CActiveScheduler::Stop(); - } - -void THotKeyTest::EndCaptureKeyTest() - { - Request(); - } - -void THotKeyTest::ConstructL() - { - iConn1=new(ELeave) SHKConnection(this, EFalse); - iConn1->ConstructL(); - for(TInt index=0;indexiWs.SetHotKey(HotKeys[index].hotKey, HotKeys[index].keyCode,HotKeys[index].mod_mask,HotKeys[index].modifiers)); - User::SetJustInTime(EFalse); - } - -// -// SHKDeath // -// - -SHKDeath::SHKDeath(TInt aPriority) : CActive(aPriority) - { - CActiveScheduler::Add(this); - } - -void SHKDeath::SetConnection(SHKConnection *aConn) - { - iConn=aConn; - } - -void SHKDeath::DoCancel() - { - } - -void SHKDeath::RunL() - { - iConn->CompleteL(); - } - -void SHKDeath::Request() - { - SetActive(); - } - -// - -SHKWindowGroup::SHKWindowGroup(CTClient *aClient) : CTWindowGroup(aClient) - {} - -void SHKWindowGroup::KeyL(const TKeyEvent &aKey,const TTime &) - { - ((SHKConnection *)iClient)->KeyL(aKey); - } - -// -// SHKConnection - -SHKConnection::SHKConnection(THotKeyTest *aTest, TInt aMode) : iMode(aMode), iDeath(100), iTest(aTest) - { - iDeath.SetConnection(this); - } - -SHKConnection::~SHKConnection() - { - iGroup->GroupWin()->EnableReceiptOfFocus(EFalse); - CTWin::Delete(iWin); - } - -void SHKConnection::KeyL(const TKeyEvent &aKey) - { - if (iTest) - { - if (aKey.iCode==EKeyEnter && !HotKeyTestIsDeathTest[iTest->SubState()]) - iTest->IncSubStateL(); - else if (aKey.iCode==EKeyEscape) - iTest->AbortL(); - } - } - -void SHKConnection::CompleteL() - { - iTest->IncSubStateL(); - } - -void SHKConnection::SubStateChangedL() - { - if (HotKeyTestIsDeathTest[iTest->SubState()]) - { - RThread thread; - iMainWinId=iGroup->GroupWin()->Identifier(); - TInt subState=iTest->SubState(); - User::After(100000); - User::LeaveIfError(thread.Create(_L("SubThread"),SubThread,KDefaultStackSize,0x2000,0x2000,&subState,EOwnerThread)); - thread.Logon(iDeath.iStatus); - iDeath.Request(); - thread.Resume(); - thread.Close(); - } - iWin->Invalidate(); - iWs.Flush(); - } - -void SHKConnection::ConstructL() - { - CTClient::ConstructL(); - iGroup=new(ELeave) SHKWindowGroup(this); - iGroup->ConstructL(); - TSize screenSize=iGroup->Size(); - iGroup->GroupWin()->AutoForeground(EFalse); // Don't allow clicking to cause foreground, might mess up test - TInt winWidth; - TInt winHeight; - if (iMode==0) - { - winWidth=screenSize.iWidth/2; - winHeight=screenSize.iHeight-10; - SHKWindow *win=new(ELeave) SHKWindow(iTest); - win->SetUpL(TPoint(5,5),TSize(winWidth,winHeight),iGroup,*iGc); - iWin=win; - } - else - { - winWidth=150; - winHeight=50; - iGroup->GroupWin()->SetOwningWindowGroup(iMainWinId); - SHKWindow2 *win=new(ELeave) SHKWindow2(); - win->SetUpL(TPoint((screenSize.iWidth-winWidth)/2,(screenSize.iHeight-winHeight)/2),TSize(winWidth,winHeight),iGroup,*iGc); - iWin=win; - } - iWs.Flush(); - } - -// -// SHKWindow, class // -// - -SHKWindow::SHKWindow(THotKeyTest *aTest) : CTWin(), iTest(aTest) - { - iBack=TRgb::Gray256(230); - } - -void SHKWindow::SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc) - { - ConstructExtLD(*parent,pos,size); - iWin.SetBackgroundColor(iBack); - Activate(); - AssignGC(aGc); - } - -void SHKWindow::Draw() - { - iGc->Clear(); - iGc->DrawText(TPtrC(HotKeyTests[iTest->SubState()].txt), TPoint(10,20)); - iGc->DrawText(TPtrC(_L("Press when tested okay")), TPoint(10,35)); - iGc->DrawText(TPtrC(_L("or escape to abort tests")), TPoint(10,50)); - } - -// -// SHKWindow2, class // -// - -SHKWindow2::SHKWindow2() : CTWin() - { - } - -void SHKWindow2::SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc) - { - ConstructExtLD(*parent,pos,size); - iWin.SetBackgroundColor(TRgb(0,0,0)); - Activate(); - AssignGC(aGc); - } - -void SHKWindow2::Draw() - { - iGc->SetBrushColor(TRgb::Gray4(1)); - iGc->Clear(); - iGc->SetPenColor(TRgb::Gray4(3)); - iGc->DrawText(TPtrC(_L("Kill me!!!")), TPoint(10,15)); - } - -// - -TInt THotKeyTest::SubState() const - { - return(iSubState); - } - -void THotKeyTest::IncSubStateL() - { - if (iSubState==(numHotKeyTests-1)) - EndCaptureKeyTest(); - else - { - iSubState++; - iConn1->SubStateChangedL(); - } - } - -void THotKeyTest::BadParamsL() - { - TInt resCount=Client()->iWs.ResourceCount(); - for(TInt index=0;indexiWs.SetHotKey(errorKeys[index].hotKey, errorKeys[index].keyCode,errorKeys[index].mod_mask,errorKeys[index].modifiers)==KErrArgument); - TestL(Client()->iWs.ResourceCount()==resCount); - } - -TestState THotKeyTest::DoTestL() - { - switch(iState) - { - case 0: - LogSubTest(_L("Errors"),1); - BadParamsL(); - LogSubTest(_L("CaptureKey"),2); - iState++; - return(EContinue); - default: - return(EFinished); - } - } - -//======================================================// -// Sub thread to do tests and get shot by window server // -//======================================================// - -void SubThreadMain() - { - CActiveScheduler *TheActiveScheduler=new(ELeave) CActiveScheduler; - CActiveScheduler::Install(TheActiveScheduler); - SHKConnection *conn=new(ELeave) SHKConnection(NULL, ETrue); - conn->ConstructL(); - CActiveScheduler::Start(); - delete TheActiveScheduler; - } - -TInt SubThread(TAny *) - { - CTrapCleanup* CleanUpStack=CTrapCleanup::New(); - TRAPD(err,SubThreadMain()); - delete CleanUpStack; - return(err); - } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tman/MULTICON.CPP --- a/windowing/windowserver/tman/MULTICON.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,446 +0,0 @@ -// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Test multiple connections to the window server -// -// - -#include -#include -#include "W32STD.H" -#include "../tlib/testbase.h" -#include "TMAN.H" - -const TInt EMaxSubState=3; - -class CMcWindowBase; -class TMultiConTest; - -class CMcConnectionBase : public CTClient - { -public: - CMcConnectionBase(TMultiConTest *aTest); - ~CMcConnectionBase(); - virtual void ConstructL(); - void SubStateChanged(); -protected: - TMultiConTest *iTest; - CMcWindowBase *iWin; - CWindowGc *iGc; - }; - -class CMcConnection : public CMcConnectionBase // Sets AutoForeground off - { -public: - CMcConnection(TMultiConTest *aTest); - void ConstructL(); - }; - -class CMcWindowGroupAf : public CTWindowGroup - { -public: - CMcWindowGroupAf(CTClient *aClient); - void KeyL(const TKeyEvent &aKey, const TTime &aTime); - }; - -class CMcConnectionAf : public CMcConnectionBase // Sets AutoForeground on - { -public: - CMcConnectionAf(TMultiConTest *aTest); - void ConstructL(); - void KeyL(const TKeyEvent &aKey); - }; - -class CMcConnectionDef : public CMcConnectionBase // Leaves AutoForeground as the default value - { -public: - CMcConnectionDef(TMultiConTest *aTest); - void ConstructL(); - }; - -class CMcWindowBase : public CTWin - { -public: - CMcWindowBase(TMultiConTest *aTest); - void SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc); - virtual void Draw()=0; - virtual void PointerL(const TPointerEvent &pointer,const TTime &)=0; -protected: - TMultiConTest *iTest; - TRgb iBack; - }; - -class CMcWindow : public CMcWindowBase - { -public: - CMcWindow(TMultiConTest *aTest); - virtual void Draw(); - virtual void PointerL(const TPointerEvent &pointer,const TTime &); - }; - -class CMcWindowAf : public CMcWindowBase - { -public: - CMcWindowAf(TMultiConTest *aTest); - virtual void Draw(); - virtual void PointerL(const TPointerEvent &pointer,const TTime &); - void ConstructL(); - }; - -class CMcWindowDef : public CMcWindowBase - { -public: - CMcWindowDef(TMultiConTest *aTest); - virtual void Draw(); - virtual void PointerL(const TPointerEvent &pointer,const TTime &); - }; - -class TMultiConTest : public CTestBase - { -public: - TMultiConTest(); - ~TMultiConTest(); - TestState DoTestL(); - void ConstructL(); - void EndAutoForegroundTest(); - TInt SubState() const; - void IncSubState(); -private: - CMcConnectionAf *iConn1; - CMcConnection *iConn2; - CMcConnectionDef *iConn3; - TSize iWinSize; - TInt iState; - TInt iSubState; - }; - -GLDEF_C CTestBase *CreateMultiConTest() - { - return(new(ELeave) TMultiConTest()); - } - -TMultiConTest::TMultiConTest() : CTestBase(_L("MultiCon")) - {} - -TMultiConTest::~TMultiConTest() - { - delete iConn1; - delete iConn2; - delete iConn3; - } - -void TMultiConTest::EndAutoForegroundTest() - { - iConn1->iGroup->GroupWin()->EnableReceiptOfFocus(EFalse); - iConn2->iGroup->GroupWin()->EnableReceiptOfFocus(EFalse); - iConn3->iGroup->GroupWin()->EnableReceiptOfFocus(EFalse); - Request(); - } - -void TMultiConTest::ConstructL() - { - iConn3=new(ELeave) CMcConnectionDef(this); - iConn3->ConstructL(); - iConn2=new(ELeave) CMcConnection(this); - iConn2->ConstructL(); - iConn1=new(ELeave) CMcConnectionAf(this); - iConn1->ConstructL(); - } - -// -// CMcConnection - -CMcConnectionBase::CMcConnectionBase(TMultiConTest *aTest) : iTest(aTest) - { - } - -CMcConnectionBase::~CMcConnectionBase() - { - CTWin::Delete(iWin); - delete iGc; - } - -void CMcConnectionBase::SubStateChanged() - { - iWin->Invalidate(); - iWs.Flush(); - } - -void CMcConnectionBase::ConstructL() - { - CTClient::ConstructL(); - User::LeaveIfError(iScreen->CreateContext(iGc)); - } - -CMcConnection::CMcConnection(TMultiConTest *aTest) : CMcConnectionBase(aTest) - { - } - -void CMcConnection::ConstructL() - { - CMcConnectionBase::ConstructL(); - iGroup=new(ELeave) CTWindowGroup(this); - iGroup->ConstructL(); - TSize screenSize=iGroup->Size(); - TInt winWidth=screenSize.iWidth/3; - TInt winHeight=screenSize.iHeight/2-10; - iGroup->GroupWin()->AutoForeground(EFalse); - CMcWindow *win=new(ELeave) CMcWindow(iTest); - win->SetUpL(TPoint(5,5),TSize(winWidth,winHeight),iGroup,*iGc); - iWin=win; - iWs.Flush(); - } - -CMcConnectionAf::CMcConnectionAf(TMultiConTest *aTest) : CMcConnectionBase(aTest) - { - } - -void CMcConnectionAf::ConstructL() - { - CMcConnectionBase::ConstructL(); - iGroup=new(ELeave) CMcWindowGroupAf(this); - iGroup->ConstructL(); - TSize screenSize=iGroup->Size(); - TInt winWidth=screenSize.iWidth/3; - TInt winHeight=screenSize.iHeight/2-10; - iGroup->GroupWin()->AutoForeground(ETrue); - CMcWindowAf *win=new(ELeave) CMcWindowAf(iTest); - win->SetUpL(TPoint(winWidth,5),TSize(winWidth,winHeight),iGroup,*iGc); - iWin=win; - iWs.Flush(); - } - -void CMcConnectionAf::KeyL(const TKeyEvent &aKey) - { - switch(aKey.iCode) - { - case ' ': - if (iTest->SubState()==0) - { - iTest->TestL(iGroup->GroupWin()->OrdinalPosition()==0); - iTest->IncSubState(); - } - break; - case EKeyEscape: - iTest->EndAutoForegroundTest(); - break; - } - } - -CMcConnectionDef::CMcConnectionDef(TMultiConTest *aTest) : CMcConnectionBase(aTest) - { - } - -void CMcConnectionDef::ConstructL() - { - CMcConnectionBase::ConstructL(); - iGroup=new(ELeave) CTWindowGroup(this); - iGroup->ConstructL(); - iGroup->GroupWin()->EnableReceiptOfFocus(EFalse); - TSize screenSize=iGroup->Size(); - TInt winWidth=screenSize.iWidth/3-10; - TInt winHeight=(screenSize.iHeight/2)-10; - CMcWindowDef *win=new(ELeave) CMcWindowDef(iTest); - win->SetUpL(TPoint(5+winWidth/2,screenSize.iHeight/2),TSize(winWidth,winHeight),iGroup,*iGc); - iWin=win; - iWs.Flush(); - } - -// -// CMcWindow, base class // -// - -CMcWindowBase::CMcWindowBase(TMultiConTest *aTest) : CTWin(), iTest(aTest) - { - } - -void CMcWindowBase::SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc) - { - ConstructExtLD(*parent,pos,size); - iWin.SetBackgroundColor(iBack); - Activate(); - AssignGC(aGc); - } - -// -// CMcWindow, window used to test multiple connections // -// - -CMcWindow::CMcWindow(TMultiConTest *aTest) : CMcWindowBase(aTest) - { - iBack=TRgb::Gray256(221); - } - -void CMcWindow::PointerL(const TPointerEvent &pointer,const TTime &) - { - if (pointer.iType==TPointerEvent::EButton1Down) - { - switch(iTest->SubState()) - { - case 1: - iTest->TestL(Client()->iGroup->GroupWin()->OrdinalPosition()==1); - iTest->IncSubState(); - break; - } - } - } - -void CMcWindow::Draw() - { - iGc->Clear(); - TBuf<0x40> buf; - switch(iTest->SubState()) - { - case 1: - buf.Copy(_L("Click on me")); - break; - case 0: - case 2: - case 3: - buf.Copy(_L("")); - break; - default: - buf.Copy(_L("ERROR")); - } - iGc->DrawText(buf, TPoint(10,20)); - } - -// -// CMcWindowAf, Auto foreground version of CMcWindow // -// - -CMcWindowAf::CMcWindowAf(TMultiConTest *aTest) : CMcWindowBase(aTest) - { - iBack=TRgb::Gray256(150); - } - -void CMcWindowAf::PointerL(const TPointerEvent &pointer,const TTime &) - { - if (pointer.iType==TPointerEvent::EButton1Down) - { - switch(iTest->SubState()) - { - case 2: - iTest->TestL(Client()->iGroup->GroupWin()->OrdinalPosition()==0); - iTest->IncSubState(); - break; - } - } - } - -void CMcWindowAf::Draw() - { - iGc->Clear(); - TBuf<0x40> buf; - switch(iTest->SubState()) - { - case 1: - case 3: - break; - case 0: - buf.Copy(_L("Press ")); - break; - case 2: - buf.Copy(_L("Click on me")); - break; - default: - buf.Copy(_L("ERROR")); - } - iGc->DrawText(buf, TPoint(10,20)); - } - -// - -CMcWindowGroupAf::CMcWindowGroupAf(CTClient *aClient) : CTWindowGroup(aClient) - {} - -void CMcWindowGroupAf::KeyL(const TKeyEvent &aKey, const TTime &) - { - ((CMcConnectionAf *)iClient)->KeyL(aKey); - } - -// -// CMcWindowDef, Default auto foreground version of CMcWindow // -// - -CMcWindowDef::CMcWindowDef(TMultiConTest *aTest) : CMcWindowBase(aTest) - { - iBack=TRgb::Gray256(236); - } - -void CMcWindowDef::PointerL(const TPointerEvent &pointer,const TTime &) - { - if (pointer.iType==TPointerEvent::EButton1Down) - { - switch(iTest->SubState()) - { - case 3: - iTest->TestL(Client()->iGroup->GroupWin()->OrdinalPosition()==0); - iTest->IncSubState(); - break; - } - } - } - -void CMcWindowDef::Draw() - { - iGc->Clear(); - TBuf<0x40> buf; - switch(iTest->SubState()) - { - case 0: - case 1: - case 2: - break; - case 3: - buf.Copy(_L("Click on me")); - break; - default: - buf.Copy(_L("ERROR")); - } - iGc->DrawText(buf, TPoint(10,20)); - } - -// - -TInt TMultiConTest::SubState() const - { - return(iSubState); - } - -void TMultiConTest::IncSubState() - { - if (iSubState==EMaxSubState) - EndAutoForegroundTest(); - else - { - iSubState++; - iConn1->SubStateChanged(); - iConn2->SubStateChanged(); - iConn3->SubStateChanged(); - } - } - -TestState TMultiConTest::DoTestL() - { - switch(iState) - { - case 0: - LogSubTest(_L("MultiCon 1"),1); - iState++; - return(EContinue); - default: - return(EFinished); - } -// return(ENext); - } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tman/SCALE.CPP --- a/windowing/windowserver/tman/SCALE.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,135 +0,0 @@ -// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Test GDI scaling (pixels<->twips) functions -// You can probably delete this test as it is now done by TMSCRMOD for each screen mode. -// -// - -#include -#include "W32STD.H" -#include "../tlib/testbase.h" -#include "TMAN.H" - -class TScaleTest; - -class CScaleWindow : public CTWin - { -public: - CScaleWindow(TScaleTest *aTest); - void SetUpLD(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc); - void Draw(); - void WinKeyL(const TKeyEvent &aKey,const TTime &aTime); -private: - TScaleTest *iTest; - }; - -class TScaleTest : public CTestBase - { -public: - TScaleTest(); - ~TScaleTest(); - TestState DoTestL(); - void ConstructL(); -private: - CScaleWindow *iWin; - TSize iWinSize; - TInt iState; - }; - -GLDEF_C CTestBase *CreateScaleTest() - { - return(new(ELeave) TScaleTest()); - } - -CScaleWindow::CScaleWindow(TScaleTest *aTest) : CTWin(), iTest(aTest) - {} - -void CScaleWindow::SetUpLD(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc) - { - ConstructExtLD(*parent,pos,size); - Activate(); - AssignGC(aGc); - } - -void CScaleWindow::Draw() - { - iGc->Clear(); - TSize twips=Client()->iScreen->SizeInTwips(); - TSize pixels=Client()->iScreen->SizeInPixels(); -// Horizontal line - TInt inches=twips.iWidth/KTwipsPerInch-1; - TInt lineLen=Client()->iScreen->HorizontalTwipsToPixels(inches*KTwipsPerInch); - TPoint linePos=TPoint((pixels.iWidth-lineLen)/2,pixels.iHeight/2); - iGc->DrawLine(linePos,linePos+TPoint(lineLen,0)); - TBuf<0x20> buf; - buf.Format(TRefByValue(_L("Width %d\"")),inches); - iGc->DrawText(buf,TPoint((pixels.iWidth-iFont->TextWidthInPixels(buf))/2,linePos.iY-iFont->HeightInPixels()+iFont->AscentInPixels()-2)); - TInt index; - for(index=0;index<=inches;index++) - { - TInt dx=Client()->iScreen->HorizontalTwipsToPixels(index*KTwipsPerInch); - TInt dy=Client()->iScreen->VerticalTwipsToPixels(KTwipsPerInch/(index==0 || index==inches ? 8 : 16)); - iGc->DrawLine(linePos+TPoint(dx,1), linePos+TPoint(dx,dy)); - } -// Vertical line - inches=twips.iHeight/KTwipsPerInch; - lineLen=Client()->iScreen->VerticalTwipsToPixels(inches*KTwipsPerInch); - linePos.iY=(pixels.iHeight-lineLen)/2; - iGc->DrawLine(linePos,linePos+TPoint(0,lineLen)); - buf.Format(TRefByValue(_L("Height %d\"")),inches); - iGc->DrawText(buf,TPoint(linePos.iX+10, pixels.iHeight/4)); - for(index=0;index<=inches;index++) - { - TInt dx=Client()->iScreen->HorizontalTwipsToPixels(KTwipsPerInch/(index==0 || index==inches ? 8 : 16)); - TInt dy=Client()->iScreen->VerticalTwipsToPixels(index*KTwipsPerInch); - iGc->DrawLine(linePos+TPoint(1,dy), linePos+TPoint(dx,dy)); - } - } - -void CScaleWindow::WinKeyL(const TKeyEvent &,const TTime &) - { - CActiveScheduler::Stop(); - } - -TScaleTest::TScaleTest() : CTestBase(_L("Scale")) - {} - -TScaleTest::~TScaleTest() - { - CTWin::Delete(iWin); - } - -void TScaleTest::ConstructL() - { - CScaleWindow *win=new(ELeave) CScaleWindow(this); - win->SetUpLD(TPoint(0,0),Client()->iScreen->SizeInPixels(),Client()->iGroup,*Client()->iGc); - iWin=win; - Client()->iGroup->SetCurrentWindow(iWin); - } - -TestState TScaleTest::DoTestL() - { - switch(iState) - { - case 0: - LogSubTest(_L("Scale 1"),1); - CActiveScheduler::Start(); - iState++; - break; - default: - return(EFinished); - } - return(ENext); - } - diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tman/TKREPEAT.CPP --- a/windowing/windowserver/tman/TKREPEAT.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,348 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Keyboard repeat test -// -// - -#include -#include -#include "W32STD.H" -#include "../tlib/testbase.h" -#include "TMAN.H" - -class CRKWindow; - -class TKRepeatTest : public CTestBase - { -public: - TKRepeatTest(); - ~TKRepeatTest(); - TestState DoTestL(); - void ConstructL(); - void TestKeyboardRepeatRateL(const TTimeIntervalMicroSeconds32 &aInitialTime, const TTimeIntervalMicroSeconds32 &aTime); - TBool CheckReportL(); -public: - TBool iAbort; -private: - TTimeIntervalMicroSeconds32 iOldInitialTime; - TTimeIntervalMicroSeconds32 iOldTime; - CRKWindow *iWin; - TSize iWinSize; - TInt iState; - }; - -class CRKWindow : public CTWin - { - enum TRKStates { - EStateWaitingForKeyDown, - EStateWaitingForKeyCode, - EStateWaitingForFirstRepeat, - EStateWaitingForNthRepeat, - EStateWaitingForKeyUp, - EStateInactive, - EStateError, - }; -public: - CRKWindow(TKRepeatTest *aTest); - void SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc); - void SetState(TRKStates aState); - void SetKeyboardRepeatRate(const TTimeIntervalMicroSeconds32 &aInitialTime, const TTimeIntervalMicroSeconds32 &aTime); - void WinKeyL(const TKeyEvent &,const TTime &); - void KeyUpL(const TKeyEvent &aKey,const TTime &aTime); - void KeyDownL(const TKeyEvent &aKey,const TTime &aTime); - void Draw(); - TDesC& Report(); - TBool CheckResults(); -protected: - TInt iConnIndex; - TKRepeatTest *iTest; - TRgb iBack; - TRKStates iState; - TInt iDownCode; - TInt iRepCount; - TTimeIntervalMicroSeconds32 iInitialRepeatSet; - TTimeIntervalMicroSeconds32 iRepeatSet; - TTime iPrevTime; - TTimeIntervalMicroSeconds32 iInitialGap; - TTimeIntervalMicroSeconds32 iTotalGap; - TTimeIntervalMicroSeconds32 iMinGap; - TTimeIntervalMicroSeconds32 iMaxGap; - TBuf<0x40> iReport; - }; - -GLDEF_C CTestBase *CreateKRepeatTest() - { - return(new(ELeave) TKRepeatTest()); - } - -// -// CRKWindow, class // -// - -CRKWindow::CRKWindow(TKRepeatTest *aTest) : CTWin(), iTest(aTest) - { - } - -void CRKWindow::SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc) - { - ConstructExtLD(*parent,pos,size); - iWin.SetBackgroundColor(TRgb::Gray256(230)); - Activate(); - AssignGC(aGc); - } - -void CRKWindow::Draw() - { - iGc->Clear(); - switch(iState) - { - case EStateWaitingForKeyDown: - iGc->DrawText(_L("Press and hold the space bar"), TPoint(10,20)); - break; - case EStateWaitingForFirstRepeat: - case EStateWaitingForNthRepeat: - { - TBuf<0x40> buf; - buf.Format(TRefByValue(_L("Keep space bar down (%d repeats so far)")),iRepCount); - iGc->DrawText(buf, TPoint(10,20)); - } - break; - case EStateWaitingForKeyUp: - iGc->DrawText(_L("Release space bar"), TPoint(10,20)); - default: - break; - } - } - -void CRKWindow::SetState(TRKStates aState) - { - iState=aState; - DrawNow(); - } - -TBool CRKWindow::CheckResults() - { -// -// Checks repeat results, first convert everything to 10th's as that what is actually used -// for the timer in the window server. -// -// Return ETrue if the inacuracy in the average time is greater than 1/10th either way -// Allow initial 2/10ths either -// Allow min 2/10ths below -// Allow max 2/10ths above -// - if (iState!=EStateInactive) - return(ETrue); - TInt initial=iInitialGap.Int()/100000; - TInt initialX=iInitialRepeatSet.Int()/100000; - if (initialX==0) - initialX=1; - TInt average=(iTotalGap.Int()/100000)/(iRepCount-1); - TInt repeatX=iRepeatSet.Int()/100000; - if (repeatX==0) - repeatX=1; - TInt min=iMinGap.Int()/100000; - TInt max=iMaxGap.Int()/100000; - if (average>(repeatX+1) || average<(repeatX-1)) - return(ETrue); - if (initial>(initialX+2) || initial<(initialX-2)) - return(ETrue); - if (min>(repeatX+1) || min<(repeatX-2)) - return(ETrue); - if (max>(repeatX+3) || max(_L("Initial=%d [%d], Av=%d [%d], Min=%d, Max=%d")),initial,initialX,average,repeatX,min,max); - } - return(iReport); - } - -void CRKWindow::KeyDownL(const TKeyEvent &aKey,const TTime &) - { - switch(iState) - { - case EStateWaitingForKeyDown: - SetState(EStateWaitingForKeyCode); - iDownCode=aKey.iScanCode; - break; - default:; - } - } - -void CRKWindow::KeyUpL(const TKeyEvent &aKey,const TTime &) - { - if (aKey.iScanCode==iDownCode) - { - switch(iState) - { - case EStateWaitingForKeyUp: - SetState(EStateInactive); - break; - default: - SetState(EStateError); - break; - } - CActiveScheduler::Stop(); - } - } - -void CRKWindow::WinKeyL(const TKeyEvent &aKey,const TTime &aTime) - { - if (aKey.iCode==EKeyEscape) - { - CActiveScheduler::Stop(); - iTest->iAbort=ETrue; - } - if (aKey.iCode==32) - { - switch(iState) - { - case EStateWaitingForKeyCode: - SetState(EStateWaitingForFirstRepeat); - iPrevTime=aTime; - break; - case EStateWaitingForFirstRepeat: - iRepCount=1; - iInitialGap = I64LOW(aTime.MicroSecondsFrom(iPrevTime).Int64()); - SetState(EStateWaitingForNthRepeat); - break; - case EStateWaitingForNthRepeat: - if (iRepCount==5) - SetState(EStateWaitingForKeyUp); - else - { - TTimeIntervalMicroSeconds32 gap(I64LOW(aTime.MicroSecondsFrom(iPrevTime).Int64())); - if (gapiMaxGap) - iMaxGap=gap; - iTotalGap=iTotalGap.Int()+gap.Int(); // Horrible way to do a += - iRepCount++; - SetState(EStateWaitingForNthRepeat); - } - case EStateWaitingForKeyUp: // Do nothing here - break; - default: - iTest->TestL(EFalse); - } - iPrevTime=aTime; - } - } - -void CRKWindow::SetKeyboardRepeatRate(const TTimeIntervalMicroSeconds32 &aInitialTime, const TTimeIntervalMicroSeconds32 &aTime) - { - iInitialRepeatSet=aInitialTime; - iRepeatSet=aTime; - iMinGap=TTimeIntervalMicroSeconds32(100000000); // Any very big number will do - iMaxGap=TTimeIntervalMicroSeconds32(0); - iTotalGap=TTimeIntervalMicroSeconds32(0); - SetState(EStateWaitingForKeyDown); - Client()->iWs.Flush(); - } - -// - -TKRepeatTest::TKRepeatTest() : CTestBase(_L("KRepeat")) - {} - -TKRepeatTest::~TKRepeatTest() - { - CTWin::Delete(iWin); - Client()->iWs.SetKeyboardRepeatRate(iOldInitialTime, iOldTime); - } - -void TKRepeatTest::ConstructL() - { - iWin=new(ELeave) CRKWindow(this); - TSize screenSize=Client()->iGroup->Size(); - iWin->SetUpL(TPoint(5,5),TSize(screenSize.iWidth/2,screenSize.iHeight-10),Client()->iGroup,*Client()->iGc); - Client()->iGroup->SetCurrentWindow(iWin); - Client()->iWs.GetKeyboardRepeatRate(iOldInitialTime, iOldTime); - } - -TInt TKRepeatTest::CheckReportL() - { - if (iWin->CheckResults()) - { - CTDialog *dialog=new(ELeave) CTDialog(); - dialog->SetTitle(_L("Keyboard repeat innacuracies")); - dialog->SetLine1(iWin->Report()); - dialog->SetNumButtons(2); - dialog->SetButtonText(0,_L("Okay")); - dialog->SetButtonText(1,_L("Retest")); - dialog->SetButtonText(2,_L("Fail")); - dialog->ConstructLD(*Client()->iGroup,*Client()->iGc); - switch(dialog->Display()) - { - case 0: - break; - case 1: - return(ETrue); // Redo test - case 2: - TestL(EFalse); - break; - } - } - return(EFalse); - } - -void TKRepeatTest::TestKeyboardRepeatRateL(const TTimeIntervalMicroSeconds32 &aInitialTime, const TTimeIntervalMicroSeconds32 &aTime) - { - do - { - Client()->iWs.SetKeyboardRepeatRate(aInitialTime, aTime); - iWin->SetKeyboardRepeatRate(aInitialTime, aTime); - CActiveScheduler::Start(); - if (iAbort) - AbortL(); - } while(CheckReportL()); - } - -TestState TKRepeatTest::DoTestL() - { - switch(iState) - { - case 0: - LogSubTest(_L("Keyboard Repeat"),1); - TestKeyboardRepeatRateL(TTimeIntervalMicroSeconds32(1000000), TTimeIntervalMicroSeconds32(500000)); - LogSubTest(_L("Keyboard Repeat"),2); - TestKeyboardRepeatRateL(TTimeIntervalMicroSeconds32(200000), TTimeIntervalMicroSeconds32(100000)); - LogSubTest(_L("Keyboard Repeat"),3); - TestKeyboardRepeatRateL(TTimeIntervalMicroSeconds32(0), TTimeIntervalMicroSeconds32(100000)); - LogSubTest(_L("Keyboard Repeat"),4); - TestKeyboardRepeatRateL(TTimeIntervalMicroSeconds32(100000), TTimeIntervalMicroSeconds32(100000)); - iState++; - break; - default: - return(EFinished); - } - return(ENext); - } - diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tman/TMAN.CPP --- a/windowing/windowserver/tman/TMAN.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,490 +0,0 @@ -// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Manual window server tests -// Note: Wherever possible tests should be put into the TAUTO automatic test -// code test should only go here when manual operation is essential -// -// - -#include -#include "W32STD.H" -#include -#include "TMAN.H" - -#define LOG_TESTS - -class ErrorDialog : public CTDialog - { -public: - ErrorDialog(CTestBase *aTest); - void ButtonPressL(TInt aButton); -private: - CTestBase *iTest; - }; - -class TestWindowGroup : public CTWindowGroup - { -public: - TestWindowGroup(CTClient *aClient); - void ConstructL(); - void KeyL(const TKeyEvent &aKey,const TTime &aTime); - void KeyDownL(const TKeyEvent &aKey,const TTime &aTime); - void KeyUpL(const TKeyEvent &aKey,const TTime &aTime); - }; - -class CTManScheduler : public CActiveScheduler - { -public: - void SetClient(TestClient *aClient); - void Error(TInt anError) const; -private: - void doErrorL(TInt anError) const; -private: - TestClient *iClient; - }; - -typedef CTestBase *(*CTestBaseCreate)(); - -GLREF_C CTestBase *CreateScreenModeTest(); -GLREF_C CTestBase *CreateScaleTest(); -GLREF_C CTestBase *CreateTextTest(); -GLREF_C CTestBase *CreateDummyTest(); -GLREF_C CTestBase *CreateMultiConTest(); -GLREF_C CTestBase *CreateMultiCaptureKeyTest(); -GLREF_C CTestBase *CreateHotKeyTest(); -GLREF_C CTestBase *CreatePointerTest(); -GLREF_C CTestBase *CreatePointerCaptureTest(); -GLREF_C CTestBase *CreatePointerBufferTest(); -GLREF_C CTestBase *CreateModifiersChangedTest(); -GLREF_C CTestBase *CreatePointerKeyTest(); -GLREF_C CTestBase *CreatePasswordTest(); -GLREF_C CTestBase *CreatePointerCursorTest(); -GLREF_C CTestBase *CreateScreenModeTimes(); - -// Tests that have not been converted to tauto yet -CTestBaseCreate CreateTestClass[]={ - CreateScreenModeTimes, - CreatePointerCursorTest, - CreatePointerTest, //Mostly converted - CreatePointerKeyTest, //Mostly converted - CreateModifiersChangedTest, //Partially Conerted - CreatePointerBufferTest, - CreateTextTest, - CreateScaleTest, - CreateDummyTest, - }; - -LogWindow *LogWin; - -void TManPanic(TInt aPanic) - { - User::Panic(_L("Auto"),aPanic); - } - -// -// Log window, logs testing // -// - -LogWindow::LogWindow() : CTWin() - { - } - -void LogWindow::ConstructL(CTWinBase &parent) - { - CTWin::ConstructL(parent); - iTitleHeight=iFont->HeightInPixels()+4; - } - -void LogWindow::Draw() - { - iGc->SetPenColor(TRgb::Gray16(8)); - iGc->SetPenColor(TRgb::Gray16(0)); - DrawBorder(); - iGc->DrawLine(TPoint(0,iTitleHeight),TPoint(iSize.iWidth,iTitleHeight)); - iGc->DrawText(iTestTitle, TPoint((iSize.iWidth-iFont->TextWidthInPixels(iTestTitle))/2,iFont->AscentInPixels()+2)); - } - -void LogWindow::LogTest(TDesC &aTitle,TInt aNum) - { - iTestTitle.Format(TRefByValue(_L("Test %d,%S")),aNum,&aTitle); - iWin.Invalidate(); - Client()->iWs.Flush(); - } - -// -// Test window, simple window used to do test graphics in // -// -TestWindow::TestWindow() : CTWin() - { - } - -void TestWindow::SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc) - { - iBorderWin=new(ELeave) BorderWindow(); - iBorderWin->SetUpL(pos,size,parent,aGc); - CTWin::ConstructExtLD(*iBorderWin,TPoint(2,2),TSize(size.iWidth-4,size.iHeight-4)); - Activate(); - AssignGC(aGc); - } - -void TestWindow::Draw() - { - iGc->Clear(); - } - -// -BorderWindow::BorderWindow() : CTWin() - { - } - -void BorderWindow::ConstructL(CTWinBase &parent) - { - CTWin::ConstructL(parent); - } - -void BorderWindow::Draw() - { - iGc->SetBrushColor(TRgb::Gray16(0)); - iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - iGc->SetPenStyle(CGraphicsContext::ENullPen); - iGc->DrawRect(TRect(Size())); - } - -// - -TestWindowGroup::TestWindowGroup(CTClient *aClient) : CTWindowGroup(aClient) - { - } - -void TestWindowGroup::ConstructL() - { - CTWindowGroup::ConstructL(); - GroupWin()->EnableScreenChangeEvents(); - } - -void TestWindowGroup::KeyDownL(const TKeyEvent &aKey,const TTime &aTime) - { - if (iCurWin) - iCurWin->KeyDownL(aKey,aTime); - } - -void TestWindowGroup::KeyUpL(const TKeyEvent &aKey,const TTime &aTime) - { - if (iCurWin) - iCurWin->KeyUpL(aKey,aTime); - } - -void TestWindowGroup::KeyL(const TKeyEvent &aKey,const TTime &aTime) - { - if (aKey.iModifiers&EModifierFunc) - { - switch(aKey.iCode) - { - case 'f': - ((TestClient *)Client())->Driver()->iTest->TriggerFail(); - break; - } - } - else if (iCurWin) - iCurWin->WinKeyL(aKey,aTime); - } - -// - -TestClient::TestClient() - { - } - -void TestClient::ConstructL() - { - CTClient::ConstructL(); - - iGroup=new(ELeave) TestWindowGroup(this); - iGroup->ConstructL(); - - TSize screenSize=iGroup->Size(); - TInt winWidth=(screenSize.iWidth/3)-10; - TInt winHeight=screenSize.iHeight-10; - LogWin=new(ELeave) LogWindow(); - LogWin->SetUpL(TPoint(5+winWidth*2,5),TSize(winWidth,winHeight),iGroup,*iGc); - iDriver=new(ELeave) TestDriver(this); - } - -TestClient::~TestClient() - { - delete iDriver; - } - -TestDriver *TestClient::Driver() - { - return(iDriver); - } - -// -// Error dialog // -// - -ErrorDialog::ErrorDialog(CTestBase *aTest) : CTDialog(), iTest(aTest) - {} - -void ErrorDialog::ButtonPressL(TInt aButton) - { - switch(aButton) - { - case 0: - { - CTestBase *test=iTest; - CTDialog::Delete(this); - if (test) - test->Driver()->DestroyTest(); - CActiveScheduler::Stop(); - User::Leave(0); // Signals RunL not to do another request - } - break; - case 1: - CTestBase *test=iTest; - CTDialog::Delete(this); - if (test) - { - test->Driver()->TestComplete(); - test->Driver()->DestroyTest(); - } - break; - } - } - -// -// TestDriver, drives the test code // -// - -TestDriver::TestDriver(TestClient *aClient) : CActive(-10), iClient(aClient) - { - CActiveScheduler::Add(this); - Request(); - } - -TestClient *TestDriver::Client() - { - return(iClient); - } - -TestDriver::~TestDriver() - { - Cancel(); - DestroyTest(); - } - -void TestDriver::DoCancel() - { - TRequestStatus *pStat= &iStatus; - RThread().RequestComplete(pStat,KErrCancel); - } - -void TestDriver::Request() - { - TRequestStatus *pStat= &iStatus; - RThread().RequestComplete(pStat,KErrNone); - SetActive(); - } - -void TestDriver::RunL() - { - iTest=(*CreateTestClass[iTestNum])(); - iTest->StartTest(iTestNum,this); - iTest->ConstructL(); - } - -void TestDriver::TestComplete() - { - iTestNum++; - if (iTestNum==sizeof(CreateTestClass)/sizeof(CreateTestClass[0])) - { - DisplayDialog(_L("Tests complete"),_L(""),_L("")); - CActiveScheduler::Stop(); - } - else - Request(); - } - -void TestDriver::DestroyTest() - { - delete iTest; - iTest=NULL; - } - -// CTestBase // - -CTestBase::CTestBase(const TDesC &aTitle) : CActive(-10) - { - CActiveScheduler::Add(this); - iTitle.Copy(aTitle); - } - -CTestBase::~CTestBase() - { - User::Free(iBuf1); - User::Free(iBuf2); - Cancel(); - } - -void CTestBase::DoCancel() - { - TRequestStatus *pStat= &iStatus; - RThread().RequestComplete(pStat,KErrCancel); - } - -void CTestBase::Request() - { - TRequestStatus *pStat= &iStatus; - RThread().RequestComplete(pStat,KErrNone); - SetActive(); - } - -void CTestBase::TriggerFail() - { - iFail=ETrue; - } - -TestClient *CTestBase::Client() - { - return(iDriver->Client()); - } - -void CTestBase::LogLeave(TInt aErr) - { -#if defined(LOG_TESTS) - TLogMessageText buf; - _LIT(KLeave,"MAN Left with error code %d in sub-test %d: "); - buf.AppendFormat(KLeave,aErr,iSubTestNum); - buf.Append(iSubTitle); - Client()->LogMessage(buf); -#else - aErr=KErrNone; //To stop a warning -#endif - } - -void CTestBase::RunL() - { - TInt ret=EInvalid; - TRAPD(err,ret=DoTestL()); - if (err!=KErrNone) - { - LogLeave(err); - if (err!=ETestFailed) - { - User::Leave(err); - } - } - else if (ret==EFinished) - { - iDriver->TestComplete(); - iDriver->DestroyTest(); - } - else if (ret==ENext) - Request(); - } - -void CTestBase::StartTest(TInt aNum, TestDriver *aDriver) - { - iDriver=aDriver; - iTestNum=aNum; - LogWin->LogTest(iTitle,aNum); -#if defined(LOG_TESTS) - TLogMessageText buf; - _LIT(ManNewTest,"MAN New Test %d: "); - buf.AppendFormat(ManNewTest,aNum); - buf.Append(iTitle); - Client()->LogMessage(buf); -#endif - Request(); - } - -void CTestBase::LogSubTest(const TDesC &aSubTitle,TInt aNum) - { - iSubTestNum=aNum; - iSubTitle=aSubTitle; -#if defined(LOG_TESTS) - TLogMessageText buf; - _LIT(ManSubTest,"MAN SubTest %d: "); - buf.AppendFormat(ManSubTest,iSubTestNum); - buf.Append(iSubTitle); - Client()->LogMessage(buf); -#endif - } - -void CTestBase::AbortL() - { - TestDriver *driver=iDriver; - iDriver->DestroyTest(); - driver->TestComplete(); - User::Leave(ETestFailed); - } - -void CTestBase::TestL(TInt aCondition) - { - if (!aCondition || iFail) - { - iFail=EFalse; - ErrorDialog *dialog=new ErrorDialog(this); - if (dialog) - { - dialog->SetTitle(_L("Test failed")); - dialog->SetNumButtons(2); - dialog->SetButtonText(0,_L("Abort all tests")); - dialog->SetButtonText(1,_L("Continue other tests")); - dialog->ConstructLD(*Client()->iGroup,*Client()->iGc); - dialog->Display(); - } - User::Leave(ETestFailed); - } - } - -void CTManScheduler::SetClient(TestClient *aClient) - { - iClient=aClient; - } - -void CTManScheduler::Error(TInt aError) const - { - TRAP_IGNORE(doErrorL(aError)); - CActiveScheduler::Stop(); - } - -void CTManScheduler::doErrorL(TInt aError) const - { - CTDialog *dialog=new(ELeave) CTDialog(); - if (dialog) - { - TWindowTitle title; - title.Format(TRefByValue(_L("Error %d")),aError); - dialog->SetTitle(title); - dialog->SetNumButtons(1); - dialog->SetButtonText(0,_L("Abort tests")); - dialog->ConstructLD(*iClient->iGroup,*iClient->iGc); - dialog->Display(); - } - } - -// - -GLDEF_C CTClient *CreateClientL() - { - return(new(ELeave) TestClient()); - } - - -GLDEF_C TInt E32Main() -{ -return(TestLibStartUp(CreateClientL)); -} diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tman/TMAN.H --- a/windowing/windowserver/tman/TMAN.H Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,149 +0,0 @@ -// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Header for window server auto test code -// -// - -#include -#include -#include "W32STD.H" -#include "../tlib/testbase.h" - -class TestClient; - -enum TestState - { - EInvalid, - ENext, - EContinue, - EFinished - }; - -enum TAutoPanics - { - ETManPanicPcFailed, - }; - -enum TAutoLeaves - { - ETestFailed=1, - }; - -class LogWindow : public CTWin - { -public: - LogWindow(); - void ConstructL(CTWinBase &parent); - void Draw(); - void LogTest(TDesC &aTitle,TInt aNum); -private: - TBuf<0x40> iTestTitle; - TInt iTitleHeight; - }; - -class CTestBase; - -class BorderWindow : public CTWin - { -public: - BorderWindow(); - void ConstructL(CTWinBase &parent); - void Draw(); - }; - -class TestWindow : public CTWin - { -public: - TestWindow(); - void Draw(); - void SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc); -private: - BorderWindow *iBorderWin; - friend class CTestBase; - }; - -class TestDriver : public CActive - { -public: - TestDriver(TestClient *aClient); - ~TestDriver(); - void DoCancel(); - void RunL(); - void Request(); - void TestComplete(); - void DestroyTest(); - TestClient *Client(); -public: - CTestBase *iTest; -private: - TInt iTestNum; - TestClient *iClient; - }; - -class CTestBase : public CActive - { -public: - CTestBase(const TDesC &aTitle); - ~CTestBase(); - void DoCancel(); - void RunL(); - void Request(); - void TestL(TInt aCondition); - void StartTest(TInt aNum, TestDriver *aDriver); - void LogSubTest(const TDesC &aTitle,TInt aNum); - void TestPanic(TThreadFunction aFunction, TAny *aPtr, TInt aExitReason, const TDesC &aCategory); - void TestWsPanic(TThreadFunction aFunction, TAny *aPtr, TInt aExitReason); - void TestWsPanic(TThreadFunction aFunction, TInt aInt, TInt aExitReason); - void TriggerFail(); - void LogLeave(TInt aErr); - void CheckRect(CTWin *aWin1,CTWin *aWin2,const TRect &aRect); - void CompareWindows(TRect &aRect); - void CompareWindows(); - void CheckBorder(); - void DrawTestBackground(TBool aInvertColours); - inline TestDriver *Driver(); - virtual TestState DoTestL()=0; - virtual void ConstructL()=0; - TestClient *Client(); - void AbortL(); -protected: - TestDriver *iDriver; - TAny *iBuf1; - TAny *iBuf2; -private: - TInt iTestNum; - TInt iSubTestNum; - TBuf<0x40> iTitle; - TBuf<0x40> iSubTitle; - TBool iFail; // Used to trigger failures to test test code. - }; - -class TestClient : public CTClient - { -public: - TestClient(); - ~TestClient(); - void ConstructL(); - void KeyL(const TKeyEvent &aKey,const TTime &aTime); - void Shutdown(); - TestDriver *Driver(); -private: - TestDriver *iDriver; - }; - -GLREF_D CWindowGc *TheGc; -GLREF_C void TManPanic(TInt aPanic); - -inline TestDriver *CTestBase::Driver() - {return(iDriver);} diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tman/TMCAPKEY.CPP --- a/windowing/windowserver/tman/TMCAPKEY.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,625 +0,0 @@ -// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Test capture key -// -// - -#include -#include -#include -#include "W32STD.H" -#include "../tlib/testbase.h" -#include "TMAN.H" - -enum TTestMode - { - EModeNormalCapture, - EModeWaitingForFirstDown, - EModeKeyUpsAndDowns, - EModeAbortKeys, - }; -enum TCapKeyRetValues - { - ECapKeyOkay, - ECapKeyRetry, - ECapKeyFail, - }; - -struct SCapKeyParams - { - TInt connIndex; // Connection that should capture this key - TUint keyCode; - TUint modifier_mask; - TUint modifiers; - }; - -struct SCapKeyTestParams - { - TText *txt; // Text message telling user what to do - TInt connIndex; // Connection that receive the key press - TUint keyCode; // Expected key code - TUint modifier_mask;// Modifiers mask for expected modifiers - TUint modifiers; // Expected modifiers - }; - -struct SAbortKeyTests - { - TUint keyCode; // Expected key code - TUint modifier_mask;// Modifiers mask for expected modifiers - TUint modifiers; // Expected modifiers - }; - -LOCAL_D SCapKeyParams capKeys[]={ - {1,19,EModifierFunc|EModifierCtrl,EModifierFunc|EModifierCtrl}, - {2,'b',EModifierFunc|EModifierCtrl,EModifierFunc}, - {2,'n',EModifierFunc|EModifierCtrl,EModifierFunc}, - {0,3,EModifierFunc|EModifierCtrl,EModifierFunc|EModifierCtrl}, - {2,'q',0,0}, - {2,'w',0,0}, - }; - -LOCAL_D SCapKeyParams capUpAndDownKeys[]={ - {2,EStdKeySpace,EModifierFunc|EModifierCtrl|EModifierShift,0}, - {2,EStdKeyEnter,EModifierFunc|EModifierCtrl|EModifierShift,EModifierShift}, - }; - -LOCAL_D SCapKeyTestParams capKeyTests[]={ - {(TText *)_S("Press q"),2,'q',EModifierFunc|EModifierCtrl|EModifierShift,0}, - //{(TText *)_S("Press q"),2,'q',EModifierFunc|EModifierCtrl|EModifierShift,EModifierFunc}, - {(TText *)_S("Press w"),2,'w',EModifierFunc|EModifierCtrl|EModifierShift,EModifierFunc}, - {(TText *)_S("Press a"),0,'a',0}, - //{(TText *)_S("Press a"),1,1,EModifierFunc|EModifierCtrl|EModifierShift,EModifierFunc|EModifierCtrl}, - {(TText *)_S("Press s"),1,19,EModifierFunc|EModifierCtrl|EModifierShift,EModifierFunc|EModifierCtrl}, - //{(TText *)_S("Press b"),2,'b',EModifierFunc|EModifierCtrl|EModifierShift,EModifierFunc}, - {(TText *)_S("Press n"),2,'n',EModifierFunc|EModifierCtrl|EModifierShift,EModifierFunc}, - {(TText *)_S("Press b"),0,2,EModifierFunc|EModifierCtrl|EModifierShift,EModifierFunc|EModifierCtrl}, - //{(TText *)_S("Press c"),0,'c',EModifierFunc|EModifierCtrl|EModifierShift,EModifierFunc}, - {(TText *)_S("Press d"),0,'d',EModifierFunc|EModifierCtrl|EModifierShift,EModifierFunc}, - {(TText *)_S("Press c"),0,3,EModifierFunc|EModifierCtrl|EModifierShift,EModifierFunc|EModifierCtrl}, -// -// Capture ups and downs -// - {(TText *)_S("Press "),2,EStdKeySpace,EModifierFunc|EModifierCtrl|EModifierShift,0}, - {(TText *)_S("Press "),0,EStdKeyEnter,EModifierShift,0}, - {(TText *)_S("Press "),0,EStdKeySpace,EModifierFunc|EModifierCtrl|EModifierShift,EModifierShift}, - {(TText *)_S("Press "),2,EStdKeyEnter,EModifierShift,EModifierShift}, -// -// Priority keys -// - {(TText *)_S("Press c"),0,0,0,0}, - {(TText *)_S("Press d"),0,0,0,0}, - {(TText *)_S("Press z"),0,0,0,0}, - }; - -LOCAL_D SAbortKeyTests abortKeyTests[]={ - {3,EModifierCtrl,EModifierCtrl}, - {4,EModifierCtrl,EModifierCtrl}, - {'z',EModifierFunc|EModifierCtrl|EModifierShift,0} - }; - -struct SErrorCapKey - { - TInt keyCode; - TUint modifier_mask; - TUint modifiers; - }; - -LOCAL_D SErrorCapKey errorKeys[]={ - {'a',EModifierFunc|EModifierShift,EModifierFunc|EModifierCtrl}, - {'1',0,EModifierFunc}, - {3,EModifierCtrl,EModifierCtrl|EModifierShift}, - }; - -const TInt numCapKeys=sizeof(capKeys)/sizeof(capKeys[0]); -const TInt numTests=sizeof(capKeyTests)/sizeof(capKeyTests[0]); -const TInt numErrorKeys=sizeof(errorKeys)/sizeof(errorKeys[0]); -const TInt numAbortKeyTests=sizeof(abortKeyTests)/sizeof(abortKeyTests[0]); -const TInt numUpDownKeys=sizeof(capUpAndDownKeys)/sizeof(capUpAndDownKeys[0]); -const TInt numUpDownKeyTests=4; -const TInt numCapKeyTests=numTests-numAbortKeyTests-numUpDownKeyTests; - -LOCAL_D TInt capKeyHandle[numCapKeys]; -LOCAL_D TInt capUpDownKeyHandle[numUpDownKeys]; - -class CCKWindow; -class TCaptureKeyTest; -class CCKAbortConnection; - -class CCKConnectionBase : public CTClient - { -public: - CCKConnectionBase(TCaptureKeyTest *aTest); - void ConstructL(); -protected: - TCaptureKeyTest *iTest; - }; - -class CCKConnection : public CCKConnectionBase - { -public: - CCKConnection(TCaptureKeyTest *aTest, TInt aConnIndex); - ~CCKConnection(); - void ConstructL(); - void CheckKeyL(const SCapKeyTestParams &aKeyTest, const TKeyEvent &aKey); - void SubStateChanged(); - void KeyTestL(TInt aBool); - void KeyL(const TKeyEvent &aKey,const TTime &aTime); - void CheckUpDownL(const SCapKeyTestParams &aKeyTest, const TKeyEvent &aKey); - void CheckUpDownL(const TKeyEvent &aKey); - inline TInt Index() {return iConnIndex;} -protected: - TInt iConnIndex; - CCKWindow *iWin; - }; - -class CAbortHandler : public CTEventBase - { -public: - CAbortHandler(RWsSession *aWs, CCKAbortConnection *aConnection); - ~CAbortHandler(); - void Request(); -protected: - void DoCancel(); - void doRunL(); -protected: - CCKAbortConnection *iConnection; - }; - -class CCKAbortConnection : public CCKConnectionBase - { -public: - CCKAbortConnection(TCaptureKeyTest *aTest); - ~CCKAbortConnection(); - void ConstructL(); - void ReceivedAbortEventL(TInt aHandle, TKeyEvent *aKey); - void Foreground(); -protected: - CAbortHandler *iAbortHandler; - TInt iAbortKeyIndex; - }; - -class CCKWindow : public CTWin - { -public: - CCKWindow(TCaptureKeyTest *aTest, TInt aConnIndex); - void SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc); - void Draw(); -protected: - TInt iConnIndex; - TCaptureKeyTest *iTest; - TRgb iBack; - }; - -class CCKWindowGroup : public CTWindowGroup - { -public: - CCKWindowGroup(CTClient *aClient, TCaptureKeyTest *aTest); - void KeyL(const TKeyEvent &aKey,const TTime &aTime); - void KeyDownL(const TKeyEvent &aKey,const TTime &); - void KeyUpL(const TKeyEvent &aKey,const TTime &); - void CheckUpDown(const SCapKeyTestParams &aKeyTest, const TKeyEvent &aKey); -private: - TCaptureKeyTest *iTest; - }; - -class TCaptureKeyTest : public CTestBase - { -public: - TCaptureKeyTest(); - ~TCaptureKeyTest(); - TestState DoTestL(); - void ConstructL(); - void EndCaptureKeyTest(); - TInt SubState() const; - void IncSubState(); - void BadParamsL(); - void CapKeyPurgingL(); - void SetUpPriorityKeyTest(); - void TestComplete(); - void CaptureUpsAndDownsTest(); - TTestMode Mode(); - void SetMode(TTestMode aMode); -private: - CCKConnection *iConn1; - CCKConnection *iConn2; - CCKConnection *iConn3; - CCKAbortConnection *iAbortConn; - TSize iWinSize; - TInt iState; - TInt iSubState; - TTestMode iMode; - }; - -GLDEF_C CTestBase *CreateMultiCaptureKeyTest() - { - return(new(ELeave) TCaptureKeyTest()); - } - -// -// CAbortHandler - -CAbortHandler::CAbortHandler(RWsSession *aWs, CCKAbortConnection *aConnection) : CTEventBase(aWs, 10), iConnection(aConnection) - { - } - -CAbortHandler::~CAbortHandler() - { - Cancel(); - } - -void CAbortHandler::Request() - { - iWs->PriorityKeyReady(&iStatus); - SetActive(); - } - -void CAbortHandler::DoCancel() - { - iWs->PriorityKeyReadyCancel(); - } - -void CAbortHandler::doRunL() - { - TWsPriorityKeyEvent abortEvent; - iWs->GetPriorityKey(abortEvent); - iConnection->ReceivedAbortEventL(abortEvent.Handle(),abortEvent.Key()); - } - -// -// CCKConnection - -CCKConnectionBase::CCKConnectionBase(TCaptureKeyTest *aTest) : iTest(aTest) - { - } - -void CCKConnectionBase::ConstructL() - { - CTClient::ConstructL(); - iGroup=new(ELeave) CCKWindowGroup(this, iTest); - iGroup->ConstructL(); - } - -CCKConnection::CCKConnection(TCaptureKeyTest *aTest, TInt aConnIndex) : CCKConnectionBase(aTest), iConnIndex(aConnIndex) - { - } - -CCKConnection::~CCKConnection() - { - for(TInt index=0;indexGroupWin()->CancelCaptureKey(capKeyHandle[index]); - for(TInt index2=0;index2GroupWin()->CancelCaptureKeyUpAndDowns(capUpDownKeyHandle[index2]); - CTWin::Delete(iWin); - } - -void CCKConnection::SubStateChanged() - { - iWin->Invalidate(); - iWs.Flush(); - } - -void CCKConnection::ConstructL() - { - CCKConnectionBase::ConstructL(); - for(TInt index=0;indexGroupWin()->CaptureKey(capKeys[index].keyCode,capKeys[index].modifier_mask,capKeys[index].modifiers)); - for(TInt index2=0;index2GroupWin()->CaptureKeyUpAndDowns(capUpAndDownKeys[index2].keyCode, - capUpAndDownKeys[index2].modifier_mask,capUpAndDownKeys[index2].modifiers)); - TSize screenSize=iGroup->Size(); - TInt winWidth=screenSize.iWidth/2; - TInt winHeight=screenSize.iHeight-10; - iGroup->GroupWin()->AutoForeground(EFalse); // Don't allow clicking to cause foreground, might mess up test - CCKWindow *win=new(ELeave) CCKWindow(iTest, iConnIndex); - win->SetUpL(TPoint(5,5),TSize(winWidth,winHeight),iGroup,*iGc); - iWin=win; - } - -void CCKConnection::KeyTestL(TInt aBool) - { - if (!aBool) - { - CTDialog *dialog=new(ELeave) CTDialog(); - TInt ret=0; - dialog->ConstructLD(*iGroup,*iGc); - dialog->SetTitle(_L("Invalid key press")); - dialog->SetLine1(_L("Try again?")); - dialog->SetNumButtons(2); - dialog->SetButtonText(0,_L("Fail")); - dialog->SetButtonText(1,_L("Retry")); - ret=dialog->Display(); - User::Leave(ret==1 ? ECapKeyRetry : ECapKeyFail); - } - } - -void CCKConnection::CheckKeyL(const SCapKeyTestParams &aKeyTest, const TKeyEvent &aKey) - { - KeyTestL(aKeyTest.connIndex==iConnIndex); - KeyTestL(aKeyTest.keyCode==aKey.iCode); - KeyTestL(aKeyTest.modifiers==(aKey.iModifiers&aKeyTest.modifier_mask)); - } - -void CCKConnection::CheckUpDownL(const SCapKeyTestParams &aKeyTest, const TKeyEvent &aKey) - { - KeyTestL(aKeyTest.connIndex==iConnIndex); - KeyTestL(aKeyTest.keyCode==(TUint)aKey.iScanCode); - KeyTestL(aKeyTest.modifiers==(aKey.iModifiers&aKeyTest.modifier_mask)); - } - -void CCKConnection::KeyL(const TKeyEvent &aKey,const TTime &) - { - if (iTest->Mode()==EModeNormalCapture) - { - if (aKey.iCode==EKeyEscape) - iTest->AbortL(); - TRAPD(ret,CheckKeyL(capKeyTests[iTest->SubState()],aKey)); - if (ret==ECapKeyOkay) - iTest->IncSubState(); - else - iTest->TestL(ret==ECapKeyRetry); - } - } - -void CCKConnection::CheckUpDownL(const TKeyEvent &aKey) - { - CheckUpDownL(capKeyTests[iTest->SubState()],aKey); - } - -CCKAbortConnection::CCKAbortConnection(TCaptureKeyTest *aTest) : CCKConnectionBase(aTest) - { - } - -CCKAbortConnection::~CCKAbortConnection() - { - iGroup->GroupWin()->RemovePriorityKey(3,EModifierCtrl,EModifierCtrl); - delete iAbortHandler; - } - -void CCKAbortConnection::ConstructL() - { - CCKConnectionBase::ConstructL(); - User::LeaveIfError(iGroup->GroupWin()->AddPriorityKey(abortKeyTests[0].keyCode,abortKeyTests[0].modifier_mask,abortKeyTests[0].modifiers)); - User::LeaveIfError(iGroup->GroupWin()->AddPriorityKey(abortKeyTests[1].keyCode,abortKeyTests[1].modifier_mask,abortKeyTests[1].modifiers)); - User::LeaveIfError(iGroup->GroupWin()->AddPriorityKey(abortKeyTests[2].keyCode,abortKeyTests[2].modifier_mask,abortKeyTests[2].modifiers)); - iAbortHandler=new(ELeave) CAbortHandler(&iWs, this); - iAbortHandler->Construct(); - iWs.Flush(); - } - -void CCKAbortConnection::ReceivedAbortEventL(TInt aHandle, TKeyEvent *aKey) - { - iTest->TestL(aHandle==(TInt)iGroup); - iTest->TestL(aKey->iCode==abortKeyTests[iAbortKeyIndex].keyCode); - iTest->TestL((aKey->iModifiers&abortKeyTests[iAbortKeyIndex].modifier_mask)==abortKeyTests[iAbortKeyIndex].modifiers); - iAbortKeyIndex++; - iTest->IncSubState(); - } - -void CCKAbortConnection::Foreground() - { - iGroup->GroupWin()->SetOrdinalPosition(0); - iWs.Flush(); - } - -// -// CCKWindowGroup class // -// - -CCKWindowGroup::CCKWindowGroup(CTClient *aClient, TCaptureKeyTest *aTest) : CTWindowGroup(aClient), iTest(aTest) - {} - -void CCKWindowGroup::KeyL(const TKeyEvent &aKey,const TTime &time) - { - /*TLogMessageText buf(_S("##Recieved Key: ")); - buf.Append(aKey.iScanCode); - buf.Append('('); - buf.AppendNum(aKey.iScanCode); - buf.Append(')'); - if (!iCurWin) - { - buf.Append('('); - buf.AppendNum(((CCKConnection *)iClient)->Index()); - buf.Append(')'); - } - iClient->iWs.LogMessage(buf);*/ - if (iCurWin) - iCurWin->WinKeyL(aKey,time); - else - ((CCKConnection *)iClient)->KeyL(aKey,time); - } - -void CCKWindowGroup::KeyDownL(const TKeyEvent &aKey,const TTime &) - { - if (aKey.iScanCode!=EStdKeyLeftShift && aKey.iScanCode!=EStdKeyRightShift) - { - if (iTest->Mode()==EModeWaitingForFirstDown) - iTest->SetMode(EModeKeyUpsAndDowns); - if (iTest->Mode()==EModeKeyUpsAndDowns) - ((CCKConnection *)iClient)->CheckUpDownL(aKey); - } - } - -void CCKWindowGroup::KeyUpL(const TKeyEvent &aKey,const TTime &) - { - if (aKey.iScanCode!=EStdKeyLeftShift && aKey.iScanCode!=EStdKeyRightShift) - { - if (iTest->Mode()==EModeKeyUpsAndDowns) - { - ((CCKConnection *)iClient)->CheckUpDownL(aKey); - iTest->IncSubState(); - } - } - } - -// -// CCKWindow, class // -// - -CCKWindow::CCKWindow(TCaptureKeyTest *aTest, TInt aConnIndex) : CTWin(), iConnIndex(aConnIndex), iTest(aTest) - { - iBack=TRgb::Gray256(230); - } - -void CCKWindow::SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc) - { - ConstructExtLD(*parent,pos,size); - iWin.SetBackgroundColor(iBack); - Activate(); - AssignGC(aGc); - } - -void CCKWindow::Draw() - { - iGc->Clear(); - if (iConnIndex==0) - iGc->DrawText(TPtrC(capKeyTests[iTest->SubState()].txt), TPoint(10,20)); - } - -// - -TCaptureKeyTest::TCaptureKeyTest() : CTestBase(_L("Capture Key")) - {} - -TCaptureKeyTest::~TCaptureKeyTest() - { - delete iConn1; - delete iConn2; - delete iConn3; - delete iAbortConn; - } - -void TCaptureKeyTest::ConstructL() - { - iAbortConn=new(ELeave) CCKAbortConnection(this); - iAbortConn->ConstructL(); - iConn3=new(ELeave) CCKConnection(this,2); - iConn3->ConstructL(); - iConn2=new(ELeave) CCKConnection(this,1); - iConn2->ConstructL(); - iConn1=new(ELeave) CCKConnection(this,0); - iConn1->ConstructL(); - iMode=EModeNormalCapture; - } - -TInt TCaptureKeyTest::SubState() const - { - return(iSubState); - } - -void TCaptureKeyTest::IncSubState() - { - iSubState++; - iConn1->SubStateChanged(); - iConn2->SubStateChanged(); - iConn3->SubStateChanged(); - switch(iMode) - { - case EModeNormalCapture: - if (iSubState==numCapKeyTests) - TestComplete(); - break; - case EModeKeyUpsAndDowns: - if (iSubState==(numCapKeyTests+numUpDownKeyTests)) - TestComplete(); - break; - case EModeAbortKeys: - if (iSubState==(numCapKeyTests+numUpDownKeyTests+numAbortKeyTests)) - TestComplete(); - break; - default: - break; - } - } - -void TCaptureKeyTest::CapKeyPurgingL() - { - TInt base=Client()->iWs.ResourceCount(); - RWindowGroup groupWin(Client()->iWs); - User::LeaveIfError(groupWin.Construct(ENullWsHandle)); - TInt capHandle=User::LeaveIfError(groupWin.CaptureKey('a',EModifierFunc,EModifierFunc)); - User::LeaveIfError(groupWin.CaptureKey('b',EModifierFunc,EModifierFunc)); - TestL(Client()->iWs.ResourceCount()==(base+3)); - groupWin.CancelCaptureKey(capHandle); - TestL(Client()->iWs.ResourceCount()==(base+2)); - groupWin.Close(); - TestL(Client()->iWs.ResourceCount()==base); // Check it also freed the extra capture key - } - -void TCaptureKeyTest::BadParamsL() - { - TInt resCount=Client()->iWs.ResourceCount(); - for(TInt index=0;indexiGroup->GroupWin()->CaptureKey(errorKeys[index].keyCode,errorKeys[index].modifier_mask,errorKeys[index].modifiers)==KErrArgument); - TestL(Client()->iWs.ResourceCount()==resCount); - } - -void TCaptureKeyTest::TestComplete() - { - Request(); - } - -void TCaptureKeyTest::SetMode(TTestMode aMode) - { - iMode=aMode; - } - -TTestMode TCaptureKeyTest::Mode() - { - return(iMode); - } - -void TCaptureKeyTest::SetUpPriorityKeyTest() - { - iMode=EModeAbortKeys; - iAbortConn->Foreground(); - } - -void TCaptureKeyTest::CaptureUpsAndDownsTest() - { - iMode=EModeWaitingForFirstDown; - } - -TestState TCaptureKeyTest::DoTestL() - { - switch(iState) - { - case 0: // Dummy one to let capture key tests run - iState++; - return(EContinue); - case 1: - LogSubTest(_L("Capture ups and downs"),1); - CaptureUpsAndDownsTest(); - iState++; - return(EContinue); - case 2: - LogSubTest(_L("Abort key"),1); - SetUpPriorityKeyTest(); - iState++; - return(EContinue); - case 3: - LogSubTest(_L("Errors"),1); - BadParamsL(); - CapKeyPurgingL(); - LogSubTest(_L("CaptureKey"),1); - iState++; - return(ENext); - default: - return(EFinished); - } -// return(ENext); - } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tman/TMMODCHG.CPP --- a/windowing/windowserver/tman/TMMODCHG.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,301 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Test modifier changed message -// -// - -#include -#include -#include "W32STD.H" -#include "../tlib/testbase.h" -#include "TMAN.H" - -class CTModifiersChangedTest; - -class CMCWindow : public CTWin - { -public: - CMCWindow(CTModifiersChangedTest *aTest); - void SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc); - void Draw(); - void DrawModSetLine(const TDesC &aDes,TInt aModifier,TInt iSettableModifiers); -protected: - CTModifiersChangedTest *iTest; - TRgb iBack; - TInt iLineHeight; - TInt iFontAscent; - TInt iYpos; - TInt iXpos1; - TInt iXpos2; - }; - -class CTEventWindowGroup : public CTWindowGroup - { -public: - CTEventWindowGroup(CTClient *aClient, CTModifiersChangedTest *iTest); - void ConstructL(); - void ModifiersChanged(const TModifiersChangedEvent &aModifiersChanged ,const TTime &aTime); - void KeyL(const TKeyEvent &aKey,const TTime &aTime); -private: - CTModifiersChangedTest *iTest; - }; - -class CTModifiersChangedTest : public CTestBase - { -public: - CTModifiersChangedTest(); - ~CTModifiersChangedTest(); - TestState DoTestL(); - void ConstructL(); - void EndTest(); - TInt SubState() const; - void IncSubState(); - void BadParams(); - void ModifierChangedEventsL(); - void SetModifiersL(); - void CheckModifierL(TEventModifier aModifier); -public: - TBool iModSetTest; - TInt iSettable; -private: - TSize iWinSize; - TInt iState; - TInt iSubState; - CTEventWindowGroup *iEventGroup; - CMCWindow *iWin; - }; - -struct TModifierChangedTestsParams - { - TText *txt; // Text message telling user what to do - TUint changed; - TUint state; - TUint stateMask; - }; - -LOCAL_D TModifierChangedTestsParams ModifierChangedTests[]={ -#if defined(__WINS__) - {(TText *)_S("Press Caps"),EModifierCapsLock,EModifierCapsLock,EModifierCapsLock}, - {(TText *)_S("Press Caps (again)"),EModifierCapsLock,0,EModifierCapsLock}, -#endif - {(TText *)_S("Press left shift"),EModifierShift|EModifierLeftShift,EModifierShift|EModifierLeftShift,EModifierShift|EModifierLeftShift}, - {(TText *)_S("Release left shift"),EModifierShift|EModifierLeftShift,0,EModifierShift|EModifierLeftShift}, - {(TText *)_S("Press right shift"),EModifierShift|EModifierRightShift,EModifierShift|EModifierRightShift,EModifierShift|EModifierRightShift}, - {(TText *)_S("Release right shift"),EModifierShift|EModifierRightShift,0,EModifierShift|EModifierRightShift}, - {(TText *)_S("Press (left) func"),EModifierFunc|EModifierLeftFunc,EModifierFunc|EModifierLeftFunc,EModifierFunc|EModifierLeftFunc}, - {(TText *)_S("Release (left) func"),EModifierFunc|EModifierLeftFunc,0,EModifierFunc|EModifierLeftFunc}, - {(TText *)_S("Press (left) control"),EModifierCtrl|EModifierLeftCtrl,EModifierCtrl|EModifierLeftCtrl,EModifierCtrl|EModifierLeftCtrl}, - {(TText *)_S("Release (left) control"),EModifierCtrl|EModifierLeftCtrl,0,EModifierCtrl|EModifierLeftCtrl}, - }; - -const TInt numTests=sizeof(ModifierChangedTests)/sizeof(ModifierChangedTests[0]); - -GLDEF_C CTestBase *CreateModifiersChangedTest() - { - return(new(ELeave) CTModifiersChangedTest()); - } - -// -// CTEventWindowGroup class // -// - -CTEventWindowGroup::CTEventWindowGroup(CTClient *aClient, CTModifiersChangedTest *aTest) : CTWindowGroup(aClient), iTest(aTest) - {} - -void CTEventWindowGroup::ConstructL() - { - CTWindowGroup::ConstructL(); - iGroupWin.EnableModifierChangedEvents(EModifierShift|EModifierLeftShift|EModifierRightShift|EModifierCapsLock| - EModifierFunc|EModifierLeftFunc|EModifierCtrl|EModifierLeftCtrl,EEventControlAlways); - } - -void CTEventWindowGroup::ModifiersChanged(const TModifiersChangedEvent &aModifiersChanged ,const TTime &) - { - TInt ss=iTest->SubState(); - TInt getMods=Client()->iWs.GetModifierState(); // Double check the mods with get mods - if (aModifiersChanged.iChangedModifiers==ModifierChangedTests[ss].changed && - (aModifiersChanged.iModifiers&ModifierChangedTests[ss].stateMask)==ModifierChangedTests[ss].state && - (getMods&ModifierChangedTests[ss].stateMask)==ModifierChangedTests[ss].state) - iTest->IncSubState(); - } - -void CTEventWindowGroup::KeyL(const TKeyEvent &aKey,const TTime &) - { - if (aKey.iCode==EKeyEscape || (aKey.iCode==' ' && iTest->iModSetTest)) - iTest->EndTest(); - } - -// -// CMCWindow, class // -// - -CMCWindow::CMCWindow(CTModifiersChangedTest *aTest) : CTWin(), iTest(aTest) - { - iBack=TRgb::Gray256(230); - } - -void CMCWindow::SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc) - { - ConstructExtLD(*parent,pos,size); - iWin.SetBackgroundColor(iBack); - Activate(); - AssignGC(aGc); - iLineHeight=iFont->HeightInPixels()*5/4; - iFontAscent=iFont->AscentInPixels(); - iXpos1=4; - iXpos2=iXpos1+12*iFont->TextWidthInPixels(_L("M")); - } - -void CMCWindow::DrawModSetLine(const TDesC &aDes,TInt aModifier,TInt iSettableModifiers) - { - iYpos+=iLineHeight; - iGc->DrawText(aDes, TPoint(iXpos1,iYpos)); - iGc->DrawText(aModifier&iSettableModifiers ? _L("Yes"):_L("No"), TPoint(iXpos2,iYpos)); - } - -void CMCWindow::Draw() - { - iGc->Clear(); - if (iTest->iModSetTest) - { - iYpos=iFontAscent+3; - TBuf<32> buf; - buf.Format(TRefByValue(_L("Settable? [0x%4x]")), iTest->iSettable); - iGc->DrawText(_L("Modifier"), TPoint(iXpos1,iYpos)); - iGc->DrawText(buf, TPoint(iXpos2,iYpos)); - DrawModSetLine(_L("Shift"),EModifierShift,iTest->iSettable); - DrawModSetLine(_L("Left Shift"),EModifierLeftShift,iTest->iSettable); - DrawModSetLine(_L("Func"),EModifierFunc,iTest->iSettable); - DrawModSetLine(_L("Caps"),EModifierCapsLock,iTest->iSettable); - DrawModSetLine(_L("NumLock"),EModifierNumLock,iTest->iSettable); - DrawModSetLine(_L("Double Click"),EModifierDoubleClick,iTest->iSettable); - } - else - iGc->DrawText(TPtrC(ModifierChangedTests[iTest->SubState()].txt), TPoint(10,20)); - } - -// - -CTModifiersChangedTest::CTModifiersChangedTest() : CTestBase(_L("Capture Key")) - {} - -CTModifiersChangedTest::~CTModifiersChangedTest() - { - delete iWin; - delete iEventGroup; - } - -void CTModifiersChangedTest::EndTest() - { - if (iModSetTest) - { - iModSetTest=EFalse; - iWin->Invalidate(); - } - Request(); - } - -void CTModifiersChangedTest::ConstructL() - { - iWin=new(ELeave) CMCWindow(this); - iWin->SetUpL(TPoint(10,10),TSize(240,200),Client()->iGroup, *Client()->iGc); - } - -TInt CTModifiersChangedTest::SubState() const - { - return(iSubState); - } - -void CTModifiersChangedTest::IncSubState() - { - if (iSubState==(numTests-1)) - EndTest(); - else - { - iSubState++; - iWin->Invalidate(); - } - } - -void CTModifiersChangedTest::BadParams() - { - } - -void CTModifiersChangedTest::ModifierChangedEventsL() - { - iEventGroup=new(ELeave) CTEventWindowGroup(Client(), this); - iEventGroup->ConstructL(); - } - -void CTModifiersChangedTest::CheckModifierL(TEventModifier aModifier) - { - TInt oldMods=Client()->iWs.GetModifierState(); - Client()->iWs.SetModifierState(aModifier, EToggleModifier); - TInt getMods=Client()->iWs.GetModifierState(); - if (oldMods!=getMods) - { - iSettable|=aModifier; - Client()->iWs.SetModifierState(aModifier, ETurnOffModifier); - getMods=Client()->iWs.GetModifierState(); - TestL(!(getMods&aModifier)); - Client()->iWs.SetModifierState(aModifier, ETurnOnModifier); - getMods=Client()->iWs.GetModifierState(); - TestL(getMods&aModifier); - Client()->iWs.SetModifierState(aModifier, ETurnOffModifier); - getMods=Client()->iWs.GetModifierState(); - TestL(!(getMods&aModifier)); - if (oldMods&aModifier) - Client()->iWs.SetModifierState(aModifier, ETurnOnModifier); - } - else - { - Client()->iWs.SetModifierState(aModifier, ETurnOffModifier); - TestL(oldMods==Client()->iWs.GetModifierState()); - Client()->iWs.SetModifierState(aModifier, ETurnOnModifier); - TestL(oldMods==Client()->iWs.GetModifierState()); - } - } - -void CTModifiersChangedTest::SetModifiersL() - { - iModSetTest=ETrue; - for(TInt mod=1;mod!=0;mod<<=1) - CheckModifierL((TEventModifier)mod); - iWin->Invalidate(); - Client()->iWs.Flush(); - } - -TestState CTModifiersChangedTest::DoTestL() - { - switch(iState) - { - case 0: //The first 2 tests have been converted to TAuto test code. - ModifierChangedEventsL(); - /* iState++; - return(EContinue); - case 1: - LogSubTest(_L("Errors"),1); - BadParams(); - break; - case 2:*/ - LogSubTest(_L("Set modifiers"),1); - SetModifiersL(); - iState++; - return(EContinue); - default: - return(EFinished); - } - //iState++; - //return(ENext); - } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tman/TMPNTBUF.CPP --- a/windowing/windowserver/tman/TMPNTBUF.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,283 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Test Pointer move/drag buffer -// -// - -#include -#include "W32STD.H" -#include "../tlib/testbase.h" -#include "TMAN.H" - -class CTPntBufTest; - -class CPntBufWindow : public CTBackedUpWin - { -private: - enum {KPointerMoveBufferSize=32}; -public: - CPntBufWindow(CTPntBufTest *aTest); - ~CPntBufWindow(); - void SetUpLD(TPoint pos,TSize size,CTWinBase *parent); - void PointerBufferReady(const TTime &aTime); - void PointerL(const TPointerEvent &pointer,const TTime &aTime); - void SetUpState(); - void NextTest(); - void WinKeyL(const TKeyEvent &aKey,const TTime &aTime); - void ErrorL(); -private: - //Virtual functions from CTWinBase - void PointerEnter(const TTime&); - void PointerExit(const TTime&); -private: - CTPntBufTest *iTest; - TBool iDragging; - TBool iErrorNest; - TBool iDisabled; - TBool iDiscard; - TInt iMode; - TBool iIgnorNextPoint; - }; - -class CTPntBufTest : public CTestBase - { -public: - CTPntBufTest(); - ~CTPntBufTest(); - TestState DoTestL(); - void FinishedTests(); - void ConstructL(); -private: - CPntBufWindow *iWin; - TSize iWinSize; - TInt iState; - }; - -GLDEF_C CTestBase *CreatePointerBufferTest() - { - return(new(ELeave) CTPntBufTest()); - } - -CPntBufWindow::CPntBufWindow(CTPntBufTest *aTest) : CTBackedUpWin(EGray4), iTest(aTest) - {} - -CPntBufWindow::~CPntBufWindow() - { - delete iGc; - } - -void CPntBufWindow::SetUpLD(TPoint pos,TSize size,CTWinBase *parent) - { - ConstructExtLD(*parent,pos,size); - User::LeaveIfError(iWin.AllocPointerMoveBuffer(KPointerMoveBufferSize,0)); - iWin.SetPointerGrab(ETrue); - iWin.PointerFilter(EPointerFilterEnterExit,0); - Activate(); - User::LeaveIfError(Client()->iScreen->CreateContext(iGc)); - iGc->Activate(iWin); - SetUpState(); - } - -void CPntBufWindow::PointerBufferReady(const TTime &) - { - if (iDiscard) - iWin.DiscardPointerMoveBuffer(); - iGc->SetPenColor(iDragging ? TRgb::Gray4(0) : TRgb::Gray4(1)); - iGc->SetPenSize(iDragging ? TSize(2,2) : TSize(1,1)); - TPoint pnts[KPointerMoveBufferSize]; - TPtr8 ptr((TUint8 *)&pnts,sizeof(pnts)); - TInt numPnts=iWin.RetrievePointerMoveBuffer(ptr); - TInt index=0; - if (iIgnorNextPoint) - { - iGc->MoveTo(pnts[index]); - index=1; - iIgnorNextPoint=EFalse; - } - for(;indexDrawLineTo(pnts[index]); - } - -void CPntBufWindow::ErrorL() - { - if (!iErrorNest) - { - iErrorNest=ETrue; - iTest->TestL(EFalse); - } - } - -void CPntBufWindow::PointerL(const TPointerEvent &pointer,const TTime &) - { - switch(pointer.iType) - { - case TPointerEvent::EButton1Down: - iDragging=ETrue; - iGc->MoveTo(pointer.iPosition); - if (iMode==2) - { - if (pointer.iModifiers&EModifierShift) - { - iDisabled=ETrue; - iWin.DisablePointerMoveBuffer(); - } - else if (pointer.iModifiers&EModifierCtrl) - iDiscard=ETrue; - } - break; - case TPointerEvent::EButton1Up: - if (iDisabled) - { - iDisabled=EFalse; - iWin.EnablePointerMoveBuffer(); - } - iDiscard=EFalse; - iGc->MoveTo(pointer.iPosition); - iDragging=EFalse; - break; - case TPointerEvent::EDrag: - if (iDragging && !iDisabled) - ErrorL(); - break; - case TPointerEvent::EMove: - if (iDragging && !iDisabled) - ErrorL(); - break; - default:; - } - } - -void CPntBufWindow::SetUpState() - { - - iGc->Reset(); - iGc->UseFont((CFont *)iFont); - iGc->Clear(); - switch(iMode) - { - case 0: - iWin.PointerFilter(EPointerFilterMove,EPointerFilterMove); - iGc->DrawText(_L("Drag the pointer around the window and check"), TPoint(10,20)); - iGc->DrawText(_L("a line is drawn following the pointer when"), TPoint(10,40)); - iGc->DrawText(_L("dragging but not when moving"), TPoint(10,60)); - iGc->DrawText(_L("Press when checked"), TPoint(10,90)); - break; - case 1: - iWin.PointerFilter(EPointerFilterMove|EPointerFilterDrag,EPointerFilterDrag); - iGc->DrawText(_L("If pointer moves are supported move the pointer around the "), TPoint(10,20)); - iGc->DrawText(_L("window and check a line is drawn following the pointer"), TPoint(10,40)); - iGc->DrawText(_L("when it is up, and no lines are drawn when dragging"), TPoint(10,60)); - iGc->DrawText(_L("Press if moves not supported or when checked"), TPoint(10,90)); - break; - case 2: - iWin.PointerFilter(EPointerFilterMove|EPointerFilterDrag,0); - iGc->DrawText(_L("Drag and move the pointer around the window and check a"), TPoint(10,20)); - iGc->DrawText(_L("line is drawn following the pointer during both dragging and"), TPoint(10,40)); - iGc->DrawText(_L("moving, also check drag with the shift or control key down doesn't draw"), TPoint(10,60)); - iGc->DrawText(_L("Press when checked"), TPoint(10,90)); - break; - } - } - -void CPntBufWindow::NextTest() - { - if (iMode++==2) - iTest->FinishedTests(); - else - SetUpState(); - } - -void CPntBufWindow::WinKeyL(const TKeyEvent &aKey,const TTime &) - { - switch(aKey.iCode) - { - case ' ': - NextTest(); - break; - case EKeyEscape: - iTest->FinishedTests(); - break; - case '0': - SetUpState(); - break; - case '1': - case '2': - case '3': - { - TInt mode=aKey.iCode-'1'; - if (mode!=iMode) - { - iMode=mode; - SetUpState(); - } - } - break; - } - } - -void CPntBufWindow::PointerEnter(const TTime&) - { - if (iMode==0) - iDragging=ETrue; - else if (iMode==1) - iDragging=EFalse; - iIgnorNextPoint=ETrue; - } - -void CPntBufWindow::PointerExit(const TTime&) - {} - - -/*CTPntBufTest*/ - -CTPntBufTest::CTPntBufTest() : CTestBase(_L("Scale")) - {} - -CTPntBufTest::~CTPntBufTest() - { -#if defined(__WINS__) - Client()->iWs.SimulateXyInputType(EXYInputPointer); -#endif - CTWin::Delete(iWin); - } - -void CTPntBufTest::FinishedTests() - { - Request(); - } - -void CTPntBufTest::ConstructL() - { - CPntBufWindow *win=new(ELeave) CPntBufWindow(this); - win->SetUpLD(TPoint(0,0),Client()->iScreen->SizeInPixels(),Client()->iGroup); - iWin=win; - Client()->iGroup->SetCurrentWindow(iWin); -#if defined(__WINS__) - Client()->iWs.SimulateXyInputType(EXYInputMouse); -#endif - } - -TestState CTPntBufTest::DoTestL() - { - switch(iState) - { - case 0: - LogSubTest(_L("Scale 1"),1); - iState++; - return(EContinue); - default: - return(EFinished); - } -// return(ENext); - } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tman/TMPNTCAP.CPP --- a/windowing/windowserver/tman/TMPNTCAP.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,856 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Test pointer capture -// -// - -#include -#include -#include "W32STD.H" -#include "../tlib/testbase.h" -#include "TMAN.H" - -enum TTestState - { - ECaptureDisabled, - ENormalCapture, - ECaptureAllGroups, - EDragDropCapture, - EDragDropCaptureAllGroups, - ENormalCaptureWithoutFocus, - }; - -enum TTestSubState - { - EMainWindow, - EChildWindow, - EOtherGroup, - EOtherSession, - ERootWindow, - }; - -enum TPointerCheckRet - { - EFailed, - EOkay, - ENeedsDDEvent, - }; - -const TInt ESubStates1=2; -const TInt ESubStates2=5; -const TInt ESubStates3=5; -const TInt ESubStates4=5; -const TInt ESubStates5=5; -const TInt ESubStates6=5; - -const TInt EWinBorderSize=10; - -class CPcWindowBase; -class TPointerCaptureTest; - -class CPcConnection : public CTClient - { -public: - CPcConnection(TPointerCaptureTest *aTest); - ~CPcConnection(); - virtual void ConstructL(); -protected: - TPointerCaptureTest *iTest; - }; - -class CPcWindowBase : public CTWin - { -public: - CPcWindowBase(TPointerCaptureTest *aTest); - void SetUpL(TPoint pos,TSize size,CTWinBase *parent); - void SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc); - void Draw(TDesC &aBuf); - void PointerL(const TPointerEvent &pointer,const TTime &); - void DragDropL(const TPointerEvent &pointer,const TTime &); - virtual TPointerCheckRet PointerDown()=0; - virtual TPointerCheckRet DragDrop()=0; - virtual void SubStateChanged(); -protected: - TPointerCaptureTest *iTest; - TRgb iBack; - }; - -class CPcWindowChild : public CPcWindowBase - { -public: - CPcWindowChild(TPointerCaptureTest *aTest); - void Draw(); - TPointerCheckRet PointerDown(); - TPointerCheckRet DragDrop(); - }; - -class CPcWindowMain : public CPcWindowBase - { -public: - CPcWindowMain(TPointerCaptureTest *aTest); - void Draw(); - TPointerCheckRet PointerDown(); - TPointerCheckRet DragDrop(); - void WinKeyL(const TKeyEvent &aKey,const TTime &aTime); - }; - -class CPcWindowAltGroup : public CPcWindowBase - { -public: - CPcWindowAltGroup(TPointerCaptureTest *aTest); - void Draw(); - TPointerCheckRet PointerDown(); - TPointerCheckRet DragDrop(); - }; - -class CPcWindowNickFocusGroup : public CTWindowGroup - { -public: - CPcWindowNickFocusGroup(TPointerCaptureTest *aTest, CTClient *aClient); - void KeyL(const TKeyEvent &aKey,const TTime &aTime); -private: - TPointerCaptureTest *iTest; - }; - -class CPcWindowAltConnection : public CPcWindowBase - { -public: - CPcWindowAltConnection(TPointerCaptureTest *aTest); - void Draw(); - TPointerCheckRet PointerDown(); - TPointerCheckRet DragDrop(); - }; - -class TPointerCaptureTest : public CTestBase - { -private: - enum TDState {DDStateNull, DDStateGot, DDStateWaiting}; -public: - TPointerCaptureTest(); - ~TPointerCaptureTest(); - TestState DoTestL(); - void ConstructL(); - void NextTest(); - void AbortTests(); - TInt State() const; - TInt SubState() const; - void doIncSubState(); - void IncSubState(TBool aNeedsDD=EFalse); - void GotDD(); - void StateChanged(); - void TestFailed(); - void NickFocusL(); - void SetCapture(TInt aCaptureFlags); - void RestartTest(); -private: - TInt doTestFailedL(); -private: - CPcConnection *iAltConnection; - CTWindowGroup *iMainGroup; - CTWindowGroup *iAltGroup; - CPcWindowChild *iChildWin; - CPcWindowMain *iMainWin; - CPcWindowAltGroup *iAltGroupWin; - CPcWindowAltConnection *iAltConnectionWin; - CPcWindowNickFocusGroup *iNickFocusGroup; - CTBlankWindow *iNickFocusBlankWin; - TInt iState; - TInt iSubState; - TDState iDDState; -public: - TBool iFailed; - }; - -GLDEF_C CTestBase *CreatePointerCaptureTest() - { - return(new(ELeave) TPointerCaptureTest()); - } - -// -// CMcConnection - -CPcConnection::CPcConnection(TPointerCaptureTest *aTest) : iTest(aTest) - { - } - -CPcConnection::~CPcConnection() - { - } - -void CPcConnection::ConstructL() - { - CTClient::ConstructL(); - iGroup=new(ELeave) CTWindowGroup(this); - iGroup->ConstructL(); - iGroup->GroupWin()->SetOrdinalPosition(0,1); - iGroup->GroupWin()->EnableReceiptOfFocus(EFalse); - iWs.Flush(); - } - -// -// CPcWindow, base class // -// - -CPcWindowBase::CPcWindowBase(TPointerCaptureTest *aTest) : CTWin(), iTest(aTest) - { - } - -void CPcWindowBase::SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc) - { - ConstructExtLD(*parent,pos,size); - iWin.SetBackgroundColor(iBack); - Activate(); - AssignGC(aGc); - } - -void CPcWindowBase::SetUpL(TPoint pos,TSize size,CTWinBase *parent) - { - SetUpL(pos,size,parent,*iTest->Client()->iGc); - } - -void CPcWindowBase::SubStateChanged() - { - iWin.Invalidate(); - Client()->iWs.Flush(); - } - -void CPcWindowBase::Draw(TDesC &aBuf) - { - iGc->Clear(); - iGc->SetPenColor(iBack.Gray4()>1 ? TRgb(0,0,0) : TRgb(255,255,255)); - iGc->DrawText(aBuf, TPoint(10,20)); - } - -void CPcWindowBase::PointerL(const TPointerEvent &pointer,const TTime &) - { - if (pointer.iType==TPointerEvent::EButton1Down && !iTest->iFailed) - { - if (iTest->SubState()==ERootWindow) // Root window click, must not be inside this window - { - if (TRect(Size()).Contains(pointer.iPosition)) - { - iTest->TestFailed(); - return; - } - } - TInt ret; - if ((ret=PointerDown())==EFailed) - iTest->TestFailed(); - else - iTest->IncSubState(ret==ENeedsDDEvent); - } - } - -void CPcWindowBase::DragDropL(const TPointerEvent &pointer,const TTime &) - { - switch(iTest->State()) - { - case ECaptureDisabled: - case ENormalCapture: - case ECaptureAllGroups: - case ENormalCaptureWithoutFocus: - iTest->TestFailed(); - break; - } - if (pointer.iType==TPointerEvent::EButton1Down && !iTest->iFailed) - { - if (DragDrop()==EFailed) - iTest->TestFailed(); - else - iTest->GotDD(); - } - } -// - -CPcWindowMain::CPcWindowMain(TPointerCaptureTest *aTest) : CPcWindowBase(aTest) - { - iBack=TRgb::Gray256(236); - } - -TPointerCheckRet CPcWindowMain::PointerDown() - { - switch(iTest->State()) - { - case ECaptureDisabled: - if (iTest->SubState()==EMainWindow) - return(EOkay); - break; - case ENormalCapture: - switch(iTest->SubState()) - { - case EMainWindow: - case ERootWindow: - return(EOkay); - default: - break; - } - break; - case ECaptureAllGroups: - switch(iTest->SubState()) - { - case EMainWindow: - case EOtherGroup: - case EOtherSession: - case ERootWindow: - return(EOkay); - default: - break; - } - break; - case EDragDropCapture: - switch(iTest->SubState()) - { - case EMainWindow: - return(ENeedsDDEvent); - case ERootWindow: - return(EOkay); - default: - break; - } - break; - case EDragDropCaptureAllGroups: - switch(iTest->SubState()) - { - case EMainWindow: - case EOtherGroup: - case EOtherSession: - return(ENeedsDDEvent); - case ERootWindow: - return(EOkay); - default: - break; - } - break; - case ENormalCaptureWithoutFocus: - switch(iTest->SubState()) - { - case EMainWindow: - return(EOkay); - default: - break; - } - break; - default: - break; - } - return(EFailed); - } - -TPointerCheckRet CPcWindowMain::DragDrop() - { - switch(iTest->State()) - { - case EDragDropCapture: - case EDragDropCaptureAllGroups: - switch(iTest->SubState()) - { - case EMainWindow: - return(EOkay); - default: - break; - } - break; - default: - break; - } - return(EFailed); - } - -void CPcWindowMain::Draw() - { - TBuf<0x40> buf; - if (iTest->State()==ECaptureDisabled) - { - switch(iTest->SubState()) - { - case EMainWindow: - buf.Copy(_L("Click on me")); - break; - } - } - else - { - switch(iTest->SubState()) - { - case EMainWindow: - buf.Copy(_L("Click on me")); - break; - case EChildWindow: - case EOtherGroup: - case EOtherSession: - break; - case ERootWindow: - if (iTest->State()==ENormalCaptureWithoutFocus) - buf.Copy(_L("Click on the root window, then press ")); - else - buf.Copy(_L("Click on the root window")); - break; - } - } - CPcWindowBase::Draw(buf); - } - -void CPcWindowMain::WinKeyL(const TKeyEvent &aKey,const TTime &) - { - switch(aKey.iCode) - { - case EKeyEscape: - iTest->AbortTests(); - break; - } - } - -// - -CPcWindowChild::CPcWindowChild(TPointerCaptureTest *aTest) : CPcWindowBase(aTest) - { - iBack=TRgb::Gray256(85); - } - -TPointerCheckRet CPcWindowChild::PointerDown() - { - switch(iTest->State()) - { - case ECaptureDisabled: - break; - default: - switch(iTest->SubState()) - { - case EChildWindow: - return(EOkay); - default: - break; - } - break; - } - return(EFailed); - } - -TPointerCheckRet CPcWindowChild::DragDrop() - { - switch(iTest->State()) - { - case EDragDropCapture: - case EDragDropCaptureAllGroups: - switch(iTest->SubState()) - { - case EChildWindow: - return(EOkay); - default: - break; - } - break; - default: - break; - } - return(EFailed); - } - -void CPcWindowChild::Draw() - { - TBuf<0x40> buf; - if (iTest->State()!=ECaptureDisabled) - { - switch(iTest->SubState()) - { - case EChildWindow: - buf.Copy(_L("Click on me")); - break; - default: - break; - } - } - CPcWindowBase::Draw(buf); - } - -// - -CPcWindowNickFocusGroup::CPcWindowNickFocusGroup(TPointerCaptureTest *aTest, CTClient *aClient) : CTWindowGroup(aClient), iTest(aTest) - { - } - -void CPcWindowNickFocusGroup::KeyL(const TKeyEvent &aKey,const TTime &) - { - if (aKey.iCode==EKeyEscape) - iTest->IncSubState(EFalse); - } - -// - -CPcWindowAltGroup::CPcWindowAltGroup(TPointerCaptureTest *aTest) : CPcWindowBase(aTest) - { - iBack=TRgb::Gray256(236); - } - -TPointerCheckRet CPcWindowAltGroup::PointerDown() - { - switch(iTest->State()) - { - case ECaptureDisabled: - if (iTest->SubState()==EChildWindow) - return(EOkay); - break; - case ENormalCapture: - case EDragDropCapture: - case ENormalCaptureWithoutFocus: - switch(iTest->SubState()) - { - case EOtherGroup: - return(EOkay); - default: - break; - } - break; - default: - break; - } - return(EFailed); - } - -TPointerCheckRet CPcWindowAltGroup::DragDrop() - { - switch(iTest->State()) - { - case EDragDropCapture: - case EDragDropCaptureAllGroups: - switch(iTest->SubState()) - { - case EOtherGroup: - return(EOkay); - default: - break; - } - break; - default: - break; - } - return(EFailed); - } - -void CPcWindowAltGroup::Draw() - { - TBuf<0x40> buf; - if (iTest->State()==ECaptureDisabled) - { - switch(iTest->SubState()) - { - case EMainWindow: - break; - case EChildWindow: - buf.Copy(_L("Click on me")); - break; - } - } - else - { - switch(iTest->SubState()) - { - case EOtherGroup: - buf.Copy(_L("Click on me")); - break; - default: - break; - } - } - CPcWindowBase::Draw(buf); - } - -// - -CPcWindowAltConnection::CPcWindowAltConnection(TPointerCaptureTest *aTest) : CPcWindowBase(aTest) - { - iBack=TRgb::Gray256(236); - } - -TPointerCheckRet CPcWindowAltConnection::PointerDown() - { - switch(iTest->State()) - { - case ECaptureDisabled: - if (iTest->SubState()==EChildWindow) - return(EOkay); - break; - case ENormalCapture: - case EDragDropCapture: - case ENormalCaptureWithoutFocus: - switch(iTest->SubState()) - { - case EOtherSession: - return(EOkay); - default: - break; - } - break; - default: - break; - } - return(EFailed); - } - -TPointerCheckRet CPcWindowAltConnection::DragDrop() - { - switch(iTest->State()) - { - case EDragDropCapture: - case EDragDropCaptureAllGroups: - switch(iTest->SubState()) - { - case EOtherSession: - return(EOkay); - default: - break; - } - break; - default: - break; - } - return(EFailed); - } - -void CPcWindowAltConnection::Draw() - { - TBuf<0x40> buf; - if (iTest->State()!=ECaptureDisabled) - { - switch(iTest->SubState()) - { - case EOtherSession: - buf.Copy(_L("Click on me")); - break; - default: - break; - } - } - CPcWindowBase::Draw(buf); - } - -// - -TPointerCaptureTest::TPointerCaptureTest() : CTestBase(_L("Pointer Capture")) - {} - -TPointerCaptureTest::~TPointerCaptureTest() - { - delete iNickFocusBlankWin; - delete iNickFocusGroup; - delete iAltConnectionWin; - delete iAltConnection; - delete iChildWin; - delete iMainWin; - delete iMainGroup; - delete iAltGroupWin; - delete iAltGroup; - } - -void TPointerCaptureTest::TestFailed() - { - __ASSERT_DEBUG(iFailed==EFalse,TManPanic(ETManPanicPcFailed)); - iFailed=ETrue; - Client()->iGroup->GroupWin()->SetOrdinalPosition(0,10); // Put error dialog on top of test windows - TInt dRet=1; - TRAPD(err,dRet=doTestFailedL()); - Client()->iGroup->GroupWin()->SetOrdinalPosition(0,0); - switch(dRet) - { - case 0: - RestartTest(); - break; - case 1: - TRAP(err,TestL(EFalse)); - break; - } - } - -TInt TPointerCaptureTest::doTestFailedL() - { - CTDialog *dialog=new(ELeave) CTDialog(); - dialog->SetTitle(_L("Pointer capture test failed")); - dialog->SetNumButtons(2); - dialog->SetButtonText(0,_L("Retest")); - dialog->SetButtonText(1,_L("Fail")); - dialog->ConstructLD(*Client()->iGroup,*Client()->iGc); - return dialog->Display(); - } - -TInt TPointerCaptureTest::State() const - { - return(iState); - } - -TInt TPointerCaptureTest::SubState() const - { - return(iSubState); - } - -void TPointerCaptureTest::doIncSubState() - { - iSubState++; - TInt max=0; - switch(iState) - { - case ECaptureDisabled: - max=ESubStates1; - break; - case ENormalCapture: - max=ESubStates2; - break; - case ECaptureAllGroups: - max=ESubStates3; - break; - case EDragDropCapture: - max=ESubStates4; - break; - case EDragDropCaptureAllGroups: - max=ESubStates5; - break; - case ENormalCaptureWithoutFocus: - max=ESubStates6; - break; - } - if (iSubState==max) - NextTest(); - StateChanged(); - } - -void TPointerCaptureTest::GotDD() - { - if (iDDState==DDStateWaiting) - doIncSubState(); - else - iDDState=DDStateGot; - } - -void TPointerCaptureTest::IncSubState(TBool aNeedsDD) - { - if (!aNeedsDD) - { - if (iDDState!=DDStateNull) - TestFailed(); - else - doIncSubState(); - } - else if (iDDState==DDStateGot) - doIncSubState(); - else - iDDState=DDStateWaiting; - } - -void TPointerCaptureTest::StateChanged() - { - iDDState=DDStateNull; - iChildWin->SubStateChanged(); - iMainWin->SubStateChanged(); - iAltGroupWin->SubStateChanged(); - iAltConnectionWin->SubStateChanged(); - } - -void TPointerCaptureTest::AbortTests() - { - iState=99; - Request(); - } - -void TPointerCaptureTest::NextTest() - { - iState++; - Request(); - } - -void TPointerCaptureTest::RestartTest() - { - Request(); - } - -void TPointerCaptureTest::ConstructL() - { - TSize size(Client()->iGroup->Size()); - TInt winWidth2=size.iWidth/2-EWinBorderSize*2; - TInt winWidth4=size.iWidth/4-EWinBorderSize*2; - TInt winHeight=size.iHeight/2-EWinBorderSize*2; -// - iMainGroup=new(ELeave) CTWindowGroup(Client()); - iMainGroup->ConstructL(); - iMainGroup->GroupWin()->SetOrdinalPosition(0,1); - iMainWin=new(ELeave) CPcWindowMain(this); - iMainWin->SetUpL(TPoint(EWinBorderSize,EWinBorderSize) ,TSize(winWidth2,winHeight) ,iMainGroup); - iMainGroup->SetCurrentWindow(iMainWin); - iChildWin=new(ELeave) CPcWindowChild(this); - iChildWin->SetUpL(TPoint(0,winHeight/2) ,TSize(winWidth2,winHeight/2) ,iMainWin); -// - iAltGroup=new(ELeave) CTWindowGroup(Client()); - iAltGroup->ConstructL(); - iAltGroup->GroupWin()->SetOrdinalPosition(0,1); - iAltGroup->GroupWin()->EnableReceiptOfFocus(EFalse); - iAltGroupWin=new(ELeave) CPcWindowAltGroup(this); - iAltGroupWin->SetUpL(TPoint(size.iWidth/2+EWinBorderSize,EWinBorderSize) ,TSize(winWidth4,winHeight) ,iAltGroup); -// - iAltConnection=new(ELeave) CPcConnection(this); - iAltConnection->ConstructL(); - iAltConnectionWin=new(ELeave) CPcWindowAltConnection(this); - iAltConnectionWin->SetUpL(TPoint(size.iWidth/4*3+EWinBorderSize,EWinBorderSize) ,TSize(winWidth4,winHeight),iAltConnection->iGroup,*iAltConnection->iGc); - } - -void TPointerCaptureTest::NickFocusL() - { - iNickFocusGroup=new(ELeave) CPcWindowNickFocusGroup(this,Client()); - iNickFocusGroup->ConstructL(); - iNickFocusGroup->GroupWin()->SetOrdinalPosition(0,2); - iNickFocusBlankWin=new(ELeave) CTBlankWindow(); - iNickFocusBlankWin->ConstructL(*iNickFocusGroup); - iNickFocusBlankWin->SetSize(TSize(1,1)); - iNickFocusBlankWin->Activate(); - } - -void TPointerCaptureTest::SetCapture(TInt aCaptureFlags) - { - iMainWin->Win()->SetPointerCapture(aCaptureFlags); - } - -TestState TPointerCaptureTest::DoTestL() - { - iSubState=0; - iFailed=EFalse; - StateChanged(); - switch(iState) - { - case ECaptureDisabled: - LogSubTest(_L("No capture"),1); - SetCapture(RWindowBase::TCaptureDisabled); - break; - case ENormalCapture: - LogSubTest(_L("Normal capture"),1); - SetCapture(RWindowBase::TCaptureEnabled); - break; - case ECaptureAllGroups: - LogSubTest(_L("All groups"),1); - SetCapture(RWindowBase::TCaptureEnabled|RWindowBase::TCaptureFlagAllGroups); - break; - case EDragDropCapture: - LogSubTest(_L("Drag & Drop"),1); - SetCapture(RWindowBase::TCaptureDragDrop&~RWindowBase::TCaptureFlagAllGroups); - break; - case EDragDropCaptureAllGroups: - LogSubTest(_L("Drag & Drop All groups"),1); - SetCapture(RWindowBase::TCaptureDragDrop); - break; - case ENormalCaptureWithoutFocus: - LogSubTest(_L("Without focus"),1); - NickFocusL(); - SetCapture(RWindowBase::TCaptureEnabled); - break; - default: - return(EFinished); - } - return(EContinue); - } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tman/TMPNTCUR.CPP --- a/windowing/windowserver/tman/TMPNTCUR.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,677 +0,0 @@ -// Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Tests for various pointer cursors on different windows -// -// - -#include -#include -#include "W32STD.H" -#include "../tlib/testbase.h" -#include "TMAN.H" - -class CPointerCursorWindow : public CTWin - { -public: - ~CPointerCursorWindow(); - void SetChild(CPointerCursorWindow* aChild); - inline CPointerCursorWindow* Child() {return iChild;} - inline void SetBitmap(CFbsBitmap* aBitmap,TBool aTop=ETrue) {iBitmap=aBitmap;iTop=aTop;} - void SetPointerCursor(CTPointerCursor* aCursor); - //Virtual function from CTBaseWin - void SetUpL(TPoint aPos,TSize aSize,CTWinBase *aParent,CWindowGc &aGc); - void Draw(); - void PointerL(const TPointerEvent &aPointer,const TTime &aTime); -private: - CPointerCursorWindow* iChild; - CFbsBitmap* iBitmap; - TBool iTop; - }; - -class CPointerCursorWindowGroup : public CTWindowGroup - { -public: - CPointerCursorWindowGroup(CTClient *aClient); - void SetPointerCursor(CTPointerCursor* aCursor); - void ConstructL(); - }; - -class CStatusWindow : public CTTitledWindow - { -public: - ~CStatusWindow(); - void Construct(CTestBase* aTest); - void DoDraw(); - //virtual functions from CTWinBase overridden by CTBaseWin - void WinKeyL(const TKeyEvent &aKey,const TTime &aTime); - //virtual functions from CTBaseWin - void SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc); - void PointerL(const TPointerEvent &aPointer,const TTime &aTime); - //virtual function from CTBaseWin overridden by CTTitledWindow - void Draw(); -private: - void UpdateString1(); - void UpdateString2(); - void UpdateString3(); - void ChangeXyInputType(); - void ChangePointerCursorMode(); -private: - CTestBase* iTest; - TBuf<16> iString1; - TBuf<16> iString2; - TBuf<16> iString3; - TBuf<32> iString4; - TRect iRect1; - TRect iRect2; - TRect iRect3; - TRect iRect4; - TXYInputType iXyInputType; - TXYInputType iOriginalXyInputType; - TPointerCursorMode iMode; - TPointerCursorMode iOriginalMode; - TBool iSimulatedPenDown; - TBool iUpdateNeeded; - TBool iExit; - }; - -class CPointerCursorTest : public CTestBase - { - enum {eWindowGap=3,eChildWindowGap=2}; - enum {eNumPointerCursors=7}; -public: - CPointerCursorTest(); - ~CPointerCursorTest(); - TestState DoTestL(); - void ConstructL(); -private: - CPointerCursorWindow *CreateWindowL(TInt aNum,TRect aLocation,CTWinBase *aGroup); - void CreatePointerCursorsL(); - void CreateWindowsL(TSize aArea); -private: - TSize iWinSize; - TInt iState; - CStatusWindow *iInfoWindow; - CPointerCursorWindowGroup *iGroup1; - CPointerCursorWindowGroup *iGroup2; - CPointerCursorWindow *iWindows[6]; - CTPointerCursor *iCursors[eNumPointerCursors]; - CFbsBitmap *iBitmaps[eNumPointerCursors]; - }; - - -/*CPointerCursorWindow*/ - -CPointerCursorWindow::~CPointerCursorWindow() - { - delete iChild; - } - -void CPointerCursorWindow::SetChild(CPointerCursorWindow* aChild) - { - iChild=aChild; - iWin.SetShadowDisabled(ETrue); - } - -void CPointerCursorWindow::SetPointerCursor(CTPointerCursor* aCursor) - { - iWin.SetCustomPointerCursor(aCursor->PointerCursor()); - } - -void CPointerCursorWindow::SetUpL(TPoint aPos,TSize aSize,CTWinBase *aParent,CWindowGc &aGc) - { - CTWin::SetUpL(aPos,aSize,aParent,aGc); - iWin.SetShadowDisabled(ETrue); - iWin.SetPointerGrab(EFalse); - } - -void CPointerCursorWindow::Draw() - { - iGc->Reset(); - iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - iGc->DrawRect(Size()); - if (iBitmap) - { - TPoint point(3,3); - if (!iTop) - point.iY=Size().iHeight-iBitmap->SizeInPixels().iHeight-3; - iGc->BitBlt(point,iBitmap); - } - } - -void CPointerCursorWindow::PointerL(const TPointerEvent&,const TTime&) - { - } - - -/*CPointerCursorWindowGroup*/ - -CPointerCursorWindowGroup::CPointerCursorWindowGroup(CTClient *aClient) - :CTWindowGroup(aClient) - {} - -void CPointerCursorWindowGroup::ConstructL() - { - CTWindowGroup::ConstructL(); - iGroupWin.EnableReceiptOfFocus(EFalse); - } - -void CPointerCursorWindowGroup::SetPointerCursor(CTPointerCursor* aCursor) - { - iGroupWin.SetCustomPointerCursor(aCursor->PointerCursor()); - } - - -/*CStatusWindow*/ - -CStatusWindow::~CStatusWindow() - { - Client()->iWs.SetPointerCursorMode(iOriginalMode); -#if defined(__WINS__) - Client()->iWs.SimulateXyInputType(iOriginalXyInputType); -#endif - } - -void CStatusWindow::Construct(CTestBase* aTest) - { - _LIT(Title,"StatusWindow"); - _LIT(String4,"Click here to finish"); - iTest=aTest; - TWindowTitle title(Title); - SetTitle(title); - TInt yy=iTitleHeight+iFont->HeightInPixels()+7; - iRect1.SetRect(3,iTitleHeight+5,iSize.iWidth-1,yy); - TInt yy1=yy+iFont->HeightInPixels()+2; - iRect2.SetRect(3,yy+3,iSize.iWidth-1,yy1); - TInt yy2=yy1+iFont->HeightInPixels()+2; - iRect3.SetRect(3,yy1+3,iSize.iWidth-1,yy2); - iRect4.SetRect(3,yy2+3,iSize.iWidth-1,yy2+iFont->HeightInPixels()+2); - TMachineInfoV1Buf machineInfo; - UserHal::MachineInfo(machineInfo); - iXyInputType=machineInfo().iXYInputType; - iOriginalXyInputType=iXyInputType; - iSimulatedPenDown=EFalse; - // - iString3.Copy(KNullDesC); - if (iXyInputType==EXYInputDeltaMouse) - { - if (HAL::Get(HALData::EMouseState,iSimulatedPenDown)==KErrNone) - UpdateString3(); - } - UpdateString1(); - iMode=Client()->iWs.PointerCursorMode(); - iOriginalMode=iMode; - UpdateString2(); - iUpdateNeeded=EFalse; - iString4.Copy(String4); - iExit=EFalse; - } - -void CStatusWindow::SetUpL(TPoint aPos,TSize aSize,CTWinBase *aParent,CWindowGc &aGc) - { - CTTitledWindow::SetUpL(aPos,aSize,aParent,aGc); - } - -void CStatusWindow::WinKeyL(const TKeyEvent &aKey,const TTime&) - { - switch(aKey.iCode) - { - case EKeyEscape: - iTest->Request(); - break; - case 'M': - case 'm': - if (iXyInputType==EXYInputDeltaMouse) - { - if (HAL::Set(HALData::EMouseState,!iSimulatedPenDown)==KErrNone) - { - iSimulatedPenDown=!iSimulatedPenDown; - UpdateString3(); - DoDraw(); - } - } - break; - #if defined(__WINS__) - case 'I': - case 'i': - case '1': - ChangeXyInputType(); - Client()->iWs.SimulateXyInputType(iXyInputType); - break; - #endif - case 'C': - case 'c': - case '2': - ChangePointerCursorMode(); - Client()->iWs.SetPointerCursorMode(iMode); - break; - default:; - } - } - -void CStatusWindow::PointerL(const TPointerEvent &aPointer,const TTime &aTime) - { -#if defined(__WINS__) - if (iRect1.Contains(aPointer.iPosition)) - { - if (aPointer.iType==TPointerEvent::EButton1Down) - ChangeXyInputType(); - } - else -#endif - if (iRect2.Contains(aPointer.iPosition)) - { - if (aPointer.iType==TPointerEvent::EButton1Down) - ChangePointerCursorMode(); - } - else if (iRect4.Contains(aPointer.iPosition)) - iExit=ETrue; - else - CTTitledWindow::PointerL(aPointer,aTime); - if ((iUpdateNeeded || iExit) && aPointer.iType==TPointerEvent::EButton1Up) - { - if (iExit) - iTest->Request(); - else - { - Client()->iWs.SetPointerCursorMode(iMode); - #if defined(__WINS__) - Client()->iWs.SimulateXyInputType(iXyInputType); - #endif - Client()->iWs.Flush(); - iUpdateNeeded=EFalse; - } - } - } - -void CStatusWindow::Draw() - { - CTTitledWindow::Draw(); - TInt ascent=iFont->AscentInPixels()+1; - iGc->DrawText(iString1,iRect1,ascent,CGraphicsContext::ELeft); - iGc->DrawText(iString2,iRect2,ascent,CGraphicsContext::ELeft); - iGc->DrawText(iString3,iRect3,ascent,CGraphicsContext::ELeft); - iGc->DrawText(iString4,iRect4,ascent,CGraphicsContext::ELeft); - } - -void CStatusWindow::DoDraw() - { - iGc->Activate(iWin); - iGc->UseFont((CFont *)iFont); - Draw(); - iGc->Deactivate(); - } - -void CStatusWindow::UpdateString1() - { - _LIT(Text0,"No Pointer"); - _LIT(Text1,"Pen"); - _LIT(Text2,"Mouse"); - _LIT(Text3,"Relative Mouse"); - switch (iXyInputType) - { - case EXYInputNone: - iString1.Copy(Text0); - break; - case EXYInputPointer: - iString1.Copy(Text1); - break; - case EXYInputMouse: - iString1.Copy(Text2); - break; - case EXYInputDeltaMouse: - iString1.Copy(Text3); - break; - } - } - -void CStatusWindow::UpdateString2() - { - _LIT(Text0,"None"); - _LIT(Text1,"Fixed"); - _LIT(Text2,"Normal"); - _LIT(Text3,"Window"); - switch (iMode) - { - case EPointerCursorNone: - iString2.Copy(Text0); - break; - case EPointerCursorFixed: - iString2.Copy(Text1); - break; - case EPointerCursorNormal: - iString2.Copy(Text2); - break; - case EPointerCursorWindow: - iString2.Copy(Text3); - break; - } - } - -void CStatusWindow::UpdateString3() - { - if (iSimulatedPenDown) - { - _LIT(TextD,"Sim Pen Down"); - iString3.Copy(TextD); - } - else - { - _LIT(TextU,"Sim Pen Up"); - iString3.Copy(TextU); - } - } - -void CStatusWindow::ChangeXyInputType() - { - if (iXyInputType==EXYInputMouse) - iXyInputType=EXYInputPointer; - else if (iXyInputType==EXYInputPointer) - iXyInputType=EXYInputMouse; - UpdateString1(); - DoDraw(); - iUpdateNeeded=ETrue; - } - -void CStatusWindow::ChangePointerCursorMode() - { - TInt mode=(iMode+1)%(EPointerCursorLastMode+1); - iMode=STATIC_CAST(TPointerCursorMode,mode); - UpdateString2(); - DoDraw(); - iUpdateNeeded=ETrue; - } - - -/*Sprite Drawing Functions*/ - -#if defined(__WINS__) - #define DRAW_COLOR 1 -#else - #define DRAW_COLOR 0 -#endif - -void DrawCross(CBitmapContext *aGc,TInt , const TSize &aSize, TBool aDoMask, TAny *aLineWidth) - { - TInt halfLineWidth=(*STATIC_CAST(TInt*,aLineWidth)+1)/2; - TInt lineWidth=2*halfLineWidth+1; //Must be odd - aGc->SetBrushColor(TRgb::Gray4(aDoMask ? 0 : 3)); - aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - aGc->SetPenStyle(CGraphicsContext::ENullPen); - aGc->DrawRect(TRect(aSize)); - aGc->SetPenStyle(CGraphicsContext::ESolidPen); - aGc->SetPenColor(TRgb::Gray4(aDoMask ? 3 : 0)); - aGc->SetPenSize(TSize(lineWidth,lineWidth)); - aGc->DrawLine(TPoint(halfLineWidth,halfLineWidth),TPoint(aSize.iWidth-lineWidth,aSize.iHeight-lineWidth)); - aGc->DrawLine(TPoint(halfLineWidth,aSize.iHeight-lineWidth),TPoint(aSize.iWidth-lineWidth,halfLineWidth)); - } - -void DrawArrow(CBitmapContext *aGc,TInt , const TSize &aSize, TBool aDoMask, TAny *aLineWidth) - { - TInt lineWidth=*STATIC_CAST(TInt*,aLineWidth); - TInt halfLineWidth=(lineWidth-1)/2; - aGc->SetBrushColor(TRgb::Gray4(aDoMask ? 0 : 3)); - aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - aGc->SetPenStyle(CGraphicsContext::ENullPen); - aGc->DrawRect(TRect(aSize)); - aGc->SetPenStyle(CGraphicsContext::ESolidPen); - aGc->SetPenColor(TRgb::Gray4(aDoMask ? 3 : 0)); - aGc->SetPenSize(TSize(1,1)); - aGc->DrawLine(TPoint(0,0),TPoint(lineWidth,0)); - aGc->DrawLine(TPoint(0,0),TPoint(0,lineWidth)); - aGc->SetPenSize(TSize(lineWidth,lineWidth)); - aGc->DrawLine(TPoint(halfLineWidth,halfLineWidth),TPoint(aSize.iWidth-halfLineWidth-1,aSize.iHeight-halfLineWidth-1)); - aGc->DrawLine(TPoint(halfLineWidth,halfLineWidth),TPoint(aSize.iWidth/2,halfLineWidth)); - aGc->DrawLine(TPoint(halfLineWidth,halfLineWidth),TPoint(halfLineWidth,aSize.iHeight/2)); - } - -void DrawSquare(CBitmapContext *aGc,TInt , const TSize &aSize, TBool aDoMask, TAny *) - { - aGc->SetBrushColor(TRgb::Gray4(aDoMask ? 0 : 3)); - aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - aGc->SetPenStyle(CGraphicsContext::ENullPen); - aGc->DrawRect(TRect(aSize)); - aGc->SetBrushColor(TRgb::Gray4(aDoMask ? 3 : DRAW_COLOR)); - aGc->DrawRect(TRect(1,1,aSize.iWidth-1,aSize.iHeight-1)); - } - -void DrawCircle(CBitmapContext *aGc,TInt , const TSize &aSize, TBool aDoMask, TAny *) - { - aGc->SetBrushColor(TRgb::Gray4(aDoMask ? 0 : 3)); - aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - aGc->SetPenStyle(CGraphicsContext::ENullPen); - aGc->DrawRect(TRect(aSize)); - aGc->SetBrushColor(TRgb::Gray4(aDoMask ? 3 : 1)); - aGc->DrawEllipse(TRect(1,1,aSize.iWidth-1,aSize.iHeight-1)); - } - -void DrawTriangle(CBitmapContext *aGc,TInt , const TSize &aSize, TBool aDoMask, TAny *) - { - aGc->SetBrushColor(TRgb::Gray4(aDoMask ? 0 : 3)); - aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - aGc->SetPenStyle(CGraphicsContext::ENullPen); - aGc->DrawRect(TRect(aSize)); - aGc->SetPenStyle(CGraphicsContext::ESolidPen); - aGc->SetPenColor(TRgb::Gray4(aDoMask ? 3 : DRAW_COLOR)); - aGc->SetPenSize(TSize(1,1)); - for(TInt y=0;yDrawLine(TPoint(aSize.iWidth-xfact-1,y),TPoint(aSize.iWidth-1,y)); - } - } - -void DrawOpenSquare(CBitmapContext *aGc,TInt , const TSize &aSize, TBool aDoMask, TAny *aLineWidth) - { - TInt halfLineWidth=*STATIC_CAST(TInt*,aLineWidth)/2; - TInt lineWidth=2*halfLineWidth+1; //Must be odd - aGc->SetBrushColor(TRgb::Gray4(aDoMask ? 0 : 3)); - aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - aGc->SetPenStyle(CGraphicsContext::ENullPen); - aGc->DrawRect(TRect(aSize)); - aGc->SetBrushStyle(CGraphicsContext::ENullBrush); - aGc->SetPenStyle(CGraphicsContext::ESolidPen); - aGc->SetPenColor(TRgb::Gray4(aDoMask ? 3 : DRAW_COLOR)); - aGc->SetPenSize(TSize(lineWidth,lineWidth)); - TPoint botRig(aSize.iWidth-aSize.iWidth/4-1,aSize.iHeight-aSize.iHeight/4-1); - aGc->DrawRect(TRect(aSize.iWidth/4,aSize.iHeight/4,botRig.iX+1,botRig.iY+1)); - aGc->DrawLine(TPoint(halfLineWidth,halfLineWidth),TPoint(aSize.iWidth/4-halfLineWidth,aSize.iHeight/4-halfLineWidth)); - aGc->DrawLine(TPoint(aSize.iWidth-1-halfLineWidth,halfLineWidth),TPoint(botRig.iX+halfLineWidth,aSize.iHeight/4-halfLineWidth)); - aGc->DrawLine(TPoint(aSize.iWidth-1-halfLineWidth,aSize.iHeight-1-halfLineWidth),TPoint(botRig.iX+halfLineWidth,botRig.iY+halfLineWidth)); - aGc->DrawLine(TPoint(halfLineWidth,aSize.iHeight-1-halfLineWidth),TPoint(aSize.iWidth/4-halfLineWidth,botRig.iY+halfLineWidth)); - } - -void DrawOpenCircle(CBitmapContext *aGc,TInt , const TSize &aSize, TBool aDoMask, TAny *aLineWidth) - { - TInt halfLineWidth=*STATIC_CAST(TInt*,aLineWidth)/2; - TInt lineWidth=2*halfLineWidth+1; //Must be odd - aGc->SetBrushColor(TRgb::Gray4(aDoMask ? 0 : 3)); - aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - aGc->SetPenStyle(CGraphicsContext::ENullPen); - aGc->DrawRect(TRect(aSize)); - aGc->SetBrushStyle(CGraphicsContext::ENullBrush); - aGc->SetPenStyle(CGraphicsContext::ESolidPen); - aGc->SetPenColor(TRgb::Gray4(aDoMask ? 3 : DRAW_COLOR)); - aGc->SetPenSize(TSize(lineWidth,lineWidth)); - TPoint botRig(aSize.iWidth-aSize.iWidth/4-1,aSize.iHeight-aSize.iHeight/4-1); - aGc->DrawEllipse(TRect(aSize.iWidth/4+1,aSize.iHeight/4+1,botRig.iX+1,botRig.iY+1)); - aGc->DrawLine(TPoint(aSize.iWidth/2,1+halfLineWidth),TPoint(aSize.iWidth/2,aSize.iHeight/4+1-halfLineWidth)); - aGc->DrawLine(TPoint(aSize.iWidth/2,aSize.iHeight-1-halfLineWidth),TPoint(aSize.iWidth/2,botRig.iY+halfLineWidth)); - aGc->DrawLine(TPoint(1+halfLineWidth,aSize.iWidth/2),TPoint(aSize.iWidth/4+1-halfLineWidth,aSize.iHeight/2)); - aGc->DrawLine(TPoint(aSize.iWidth-1-halfLineWidth,aSize.iHeight/2),TPoint(botRig.iX+halfLineWidth,aSize.iWidth/2)); - } - - -/*CPointerCursorTest*/ - -GLDEF_C CTestBase *CreatePointerCursorTest() - { - return(new(ELeave) CPointerCursorTest()); - } - -CPointerCursorTest::CPointerCursorTest() : CTestBase(_L("PointerCursor")) - {} - -CPointerCursorTest::~CPointerCursorTest() - { - TInt ii; - Client()->iGroup->SetCurrentWindow(NULL); - delete iInfoWindow; - for(ii=0;ii<6;++ii) - { - delete iWindows[ii]; - } - for(ii=0;iiiScreen->SizeInPixels(); - TInt infoWidth=Min(210,5*size.iWidth/12); - size.iWidth=Max(Min(415,size.iWidth-infoWidth),85); - iInfoWindow=new(ELeave) CStatusWindow(); - iInfoWindow->SetUpL(TPoint(size.iWidth,50),TSize(infoWidth,180),Client()->iGroup,*Client()->iGc); - Client()->iGroup->SetCurrentWindow(iInfoWindow); - iInfoWindow->Construct(this); - iGroup1=new(ELeave) CPointerCursorWindowGroup(Client()); - iGroup1->ConstructL(); - iGroup2=new(ELeave) CPointerCursorWindowGroup(Client()); - iGroup2->ConstructL(); - size.iWidth-=5; - CreateWindowsL(size); - CreatePointerCursorsL(); - iGroup1->SetPointerCursor(iCursors[0]); - iWindows[1]->SetBitmap(iBitmaps[0],EFalse); - iWindows[0]->SetPointerCursor(iCursors[1]); - iWindows[0]->SetBitmap(iBitmaps[1]); - iWindows[0]->Child()->SetPointerCursor(iCursors[2]); - iWindows[0]->Child()->SetBitmap(iBitmaps[2]); - iWindows[2]->SetPointerCursor(iCursors[3]); - iWindows[2]->SetBitmap(iBitmaps[3]); - iWindows[2]->Child()->Child()->SetPointerCursor(iCursors[4]); - iWindows[2]->Child()->Child()->SetBitmap(iBitmaps[4]); - iWindows[3]->Child()->SetPointerCursor(iCursors[5]); - iWindows[3]->Child()->SetBitmap(iBitmaps[5]); - iWindows[4]->SetPointerCursor(iCursors[6]); - iWindows[4]->SetBitmap(iBitmaps[6]); - } - -void CPointerCursorTest::CreateWindowsL(TSize aArea) - { - //TSize screenSize=Client()->iScreen->SizeInPixels(); - TInt height=eWindowGap+(aArea.iHeight-5*eWindowGap)/4; - TInt halfWidth=aArea.iWidth/2; - TRect rect(5,eWindowGap,halfWidth,height); - iWindows[0]=CreateWindowL(2,rect,iGroup1); - rect.Move(halfWidth,0); - iWindows[1]=CreateWindowL(2,rect,iGroup1); - rect.Move(-halfWidth,height); - rect.iBr.iX=aArea.iWidth; - iWindows[2]=CreateWindowL(4,rect,iGroup2); - rect.Move(0,height); - rect.iBr.iX=aArea.iWidth-11; - iWindows[3]=CreateWindowL(3,rect,iGroup2); - rect.Move(0,height); - rect.iBr.iX=halfWidth; - iWindows[4]=CreateWindowL(2,rect,iGroup2); - rect.Move(halfWidth,0); - iWindows[5]=CreateWindowL(2,rect,iGroup2); - } - -CPointerCursorWindow* CPointerCursorTest::CreateWindowL(TInt aNum,TRect aLocation,CTWinBase *aGroup) - { - CPointerCursorWindow* firstWin=NULL; - CPointerCursorWindow* parent=NULL; - CPointerCursorWindow* win; - TInt xInc=aLocation.Width()/aNum-eChildWindowGap; - TInt ii; - for (ii=aNum;ii>0;ii--) - { - win=new(ELeave) CPointerCursorWindow(); - CleanupStack::PushL(win); - win->SetUpL(aLocation.iTl,aLocation.Size(),aGroup,*Client()->iGc); - if (!parent) - firstWin=win; - else - { - parent->SetChild(win); - CleanupStack::Pop(); - } - aLocation.iBr=TPoint(-eChildWindowGap,-eChildWindowGap)+aLocation.Size(); - aLocation.iTl.iX=xInc; - aLocation.iTl.iY=eChildWindowGap; - aGroup=win; - parent=win; - } - CleanupStack::Pop(); - return firstWin; - } - -void CPointerCursorTest::CreatePointerCursorsL() - { - const TSize size(32,32); - TSpriteCreateParams params(size,TPoint(-16,-16),DrawSquare); - TSpriteCreateParams paramarray[eNumPointerCursors]; - TInt lineWidth1=3; - TInt lineWidth2=5; - paramarray[2]=params; - params.iDrawFunc=DrawCircle; - paramarray[3]=params; - params.iDrawFunc=DrawOpenSquare; - params.iDrawFuncParam=&lineWidth1; - paramarray[5]=params; - params.iDrawFunc=DrawOpenCircle; - paramarray[6]=params; - params.iOffset=TPoint(0,0); - params.iDrawFunc=DrawArrow; - params.iDrawFuncParam=&lineWidth2; - paramarray[1]=params; - params.iOffset.iX=-31; - params.iDrawFunc=DrawTriangle; - paramarray[4]=params; - params.iOffset=TPoint(-15,-15); - params.iDrawFunc=DrawCross; - paramarray[0]=params; - CFbsBitmap *bitmap; - TInt ii,jj; - TDisplayMode mode=Client()->iWs.GetDefModeMaxNumColors(ii,jj); - for (ii=0;iiCreate(size,mode)); - iCursors[ii]=new(ELeave) CTPointerCursor(Client()->iWs); - iCursors[ii]->ConstructL(1,¶marray[ii],0,iBitmaps[ii],bitmap); - delete bitmap; - } - } - -TestState CPointerCursorTest::DoTestL() - { - switch(iState) - { - case 0: - LogSubTest(_L("Pointer Cursor"),1); - TestL(ETrue); - iState++; - return(EContinue); - default: - return(EFinished); - } - } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tman/TMPNTKEY.CPP --- a/windowing/windowserver/tman/TMPNTKEY.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,305 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Test Pointer move/drag buffer -// -// - -#include -#include -#include "W32STD.H" -#include "../tlib/testbase.h" -#include "TMAN.H" - -const TInt ENumPntKeyTests=6; -const TUint EModifierMask=EModifierCtrl|EModifierShift|EModifierFunc; - -class CTPntKeyTest; - -class CTPntKeyWindow : public CTWin - { -private: - enum {KPointerMoveBufferSize=32}; -public: - CTPntKeyWindow(CTPntKeyTest *aTest); - ~CTPntKeyWindow(); - void SetUpLD(TPoint pos,TSize size,CTWinBase *parent); - void PointerL(const TPointerEvent &pointer,const TTime &aTime); - void KeyUpL(const TKeyEvent &aKey,const TTime &); - void KeyDownL(const TKeyEvent &aKey,const TTime &); - void WinKeyL(const TKeyEvent &aKey,const TTime &); - void SwitchOn(const TTime &aTime); - void SetState(TInt iState); - void NextKey(); - void Test(TInt aCheck); - void Error(); - void DrawButton(const TRect &aRect, const TDesC &aText); - void Draw(); -private: - CTPntKeyTest *iTest; - TInt iKeyCount; - TRect iKey1; - TRect iKey2; - TRect iKey3; - static TInt iTestScanCodes[ENumPntKeyTests]; - static TUint iTestCodes[ENumPntKeyTests]; - static TUint iTestModifiers[ENumPntKeyTests]; - }; - -class CTPntKeyTest : public CTestBase - { -public: - CTPntKeyTest(); - ~CTPntKeyTest(); - TestState DoTestL(); - void FinishedTests(); - void ConstructL(); - void Failed(); - inline TBool NoDigitiser() const {return iNoDigitiser;} -private: - CTPntKeyWindow *iWin; - TSize iWinSize; - TInt iState; - TBool iFailed; - TBool iOldPointerState; - TBool iNoDigitiser; - }; - -TInt CTPntKeyWindow::iTestScanCodes[ENumPntKeyTests]={'A','B',0,'C',EStdKeyEnter,'Y'}; -TUint CTPntKeyWindow::iTestCodes[ENumPntKeyTests]={'a','B',0,'c',EKeyEnter,'y'}; -TUint CTPntKeyWindow::iTestModifiers[ENumPntKeyTests]={0,EModifierShift,0,0,0,0}; - -GLDEF_C CTestBase *CreatePointerKeyTest() - { - return(new(ELeave) CTPntKeyTest()); - } - -CTPntKeyWindow::CTPntKeyWindow(CTPntKeyTest *aTest) : iTest(aTest) - {} - -CTPntKeyWindow::~CTPntKeyWindow() - { - } - -void CTPntKeyWindow::SetUpLD(TPoint pos,TSize size,CTWinBase *parent) - { - ConstructExtLD(*parent,pos,size); - iWin.SetPointerGrab(ETrue); - iKey1=TRect(size.iWidth*1/16,size.iHeight/2,size.iWidth*5/16,size.iHeight); - iKey2=TRect(size.iWidth*6/16,size.iHeight/2,size.iWidth*10/16,size.iHeight); - iKey3=TRect(size.iWidth*11/16,size.iHeight/2,size.iWidth*15/16,size.iHeight); - iWin.AddKeyRect(iKey1,'A',EFalse); - iWin.AddKeyRect(iKey2,'B',EFalse); - AssignGC(*Client()->iGc); - BaseWin()->EnableOnEvents(); - Activate(); - } - -void CTPntKeyWindow::Error() - { - iTest->Failed(); - } - -void CTPntKeyWindow::SetState(TInt iState) - { - iKeyCount=iState-1; - NextKey(); - iTest->Client()->Flush(); - } - -void CTPntKeyWindow::NextKey() - { - if (++iKeyCount==ENumPntKeyTests || iKeyCount>4) - iTest->FinishedTests(); - else - { - if (iKeyCount==2) - iWin.RemoveAllKeyRects(); - else if (iKeyCount==3) - iWin.AddKeyRect(iKey3,'C',EFalse); - else if (iKeyCount==4) - { - #if !defined(__WINS__) - if (iTest->NoDigitiser()) - iTest->FinishedTests(); - #endif - iWin.RemoveAllKeyRects(); - iWin.AddKeyRect(TRect(Client()->iScreen->SizeInPixels()),'Z',EFalse); - } - else if (iKeyCount==5) - { - iWin.RemoveAllKeyRects(); - Client()->iWs.Flush(); - User::After(500000); // Wait half a second - iWin.AddKeyRect(TRect(Client()->iScreen->SizeInPixels()),'Y',ETrue); - } - Invalidate(); - } - } - -void CTPntKeyWindow::Test(TInt aCheck) - { - if (!aCheck) - Error(); - } - -void CTPntKeyWindow::KeyUpL(const TKeyEvent &aKey,const TTime&) - { - if (aKey.iScanCode==iTestScanCodes[iKeyCount]) - NextKey(); - } - -void CTPntKeyWindow::KeyDownL(const TKeyEvent &aKey,const TTime &) - { - if (aKey.iScanCode!=EStdKeyLeftFunc && aKey.iScanCode!=EStdKeyRightFunc && - aKey.iScanCode!=EStdKeyLeftAlt && aKey.iScanCode!=EStdKeyRightAlt && - aKey.iScanCode!=EStdKeyLeftCtrl && aKey.iScanCode!=EStdKeyRightCtrl && - aKey.iScanCode!=EStdKeyLeftShift && aKey.iScanCode!=EStdKeyRightShift && - aKey.iScanCode!=EStdKeyOff && - aKey.iScanCode!=EStdKeyEscape) - Test(aKey.iScanCode==iTestScanCodes[iKeyCount]); - } - -void CTPntKeyWindow::WinKeyL(const TKeyEvent &aKey,const TTime &) - { - if (aKey.iCode==EKeyEscape) - iTest->FinishedTests(); - else - { - Test(aKey.iScanCode==iTestScanCodes[iKeyCount]); - Test(aKey.iCode==iTestCodes[iKeyCount]); - Test((aKey.iModifiers&EModifierMask)==(iTestModifiers[iKeyCount]&EModifierMask)); - } - } - -void CTPntKeyWindow::SwitchOn(const TTime &) - { - if (iKeyCount==4) - NextKey(); - else if (iKeyCount!=5) - Error(); - } - -void CTPntKeyWindow::PointerL(const TPointerEvent &aPointer,const TTime &) - { - if (aPointer.iType==TPointerEvent::EButton1Down) - { - if (iKeyCount!=2) - Error(); - else - NextKey(); - } - } - -void CTPntKeyWindow::DrawButton(const TRect &aRect, const TDesC &aText) - { - iGc->DrawRect(aRect); - iGc->DrawText(aText, TPoint((aRect.iBr.iX+aRect.iTl.iX)/2,(aRect.iBr.iY+aRect.iTl.iY)/2)); - } - -void CTPntKeyWindow::Draw() - { - iGc->SetBrushColor(TRgb::Gray4(0)); - iGc->SetPenColor(TRgb::Gray4(3)); - iGc->Clear(); - DrawButton(iKey1,_L("A")); - DrawButton(iKey2,_L("B")); - DrawButton(iKey3,_L("C")); - switch(iKeyCount) - { - case 0: - iGc->DrawText(_L("Click on 'A'"), TPoint(10,20)); - break; - case 1: - iGc->DrawText(_L("Shift-Click on 'B'"), TPoint(10,20)); - break; - case 2: - iGc->DrawText(_L("Click anywhere in this window"), TPoint(10,20)); - break; - case 3: - iGc->DrawText(_L("Click on 'C'"), TPoint(10,20)); - break; - case 4: -#if defined(__WINS__) // Can't emulate touching dig when switched off under WINS - iGc->DrawText(_L("Switch off and on (or press Enter)"), TPoint(10,20)); -#else - iGc->DrawText(_L("1st Switch off, then touch the screen to switch on"), TPoint(10,20)); -#endif - break; - case 5: -#if defined(__WINS__) // Can't emulate touching dig when switched off under WINS - iGc->DrawText(_L("Touch anywhere in the window"), TPoint(10,20)); -#else - iGc->DrawText(_L("2nd Switch off and touch the screen to switch on"), TPoint(10,20)); -#endif - break; - } - } - -CTPntKeyTest::CTPntKeyTest() : CTestBase(_L("Pointer Key Test")) - {} - -CTPntKeyTest::~CTPntKeyTest() - { - HAL::Set(HALData::EPenDisplayOn,iOldPointerState); - CTWin::Delete(iWin); - Client()->ResetFocus(); - } - -void CTPntKeyTest::Failed() - { - if (!iFailed) - { - iFailed=ETrue; - FinishedTests(); - } - } - -void CTPntKeyTest::FinishedTests() - { - Request(); - } - -void CTPntKeyTest::ConstructL() - { - CTPntKeyWindow *win=new(ELeave) CTPntKeyWindow(this); - win->SetUpLD(TPoint(20,20),Client()->iScreen->SizeInPixels()-TSize(40,40),Client()->iGroup); - iWin=win; - Client()->iGroup->SetCurrentWindow(iWin); - iNoDigitiser=EFalse; - TInt err=HAL::Get(HALData::EPenDisplayOn,iOldPointerState); - if (err==KErrNotSupported) - iNoDigitiser=ETrue; - else if (err==KErrNone) - err=HAL::Set(HALData::EPenDisplayOn,ETrue); - if (err==KErrNotSupported) - iNoDigitiser=(!iOldPointerState); - else - TestL(err==KErrNone); - } - -TestState CTPntKeyTest::DoTestL() - { - TestL(!iFailed); - switch(iState) - { - case 0: - LogSubTest(_L("Key set 1"),1); - iWin->SetState(4); - iState++; - return(EContinue); - default: - return(EFinished); - } -// return(ENext); - } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tman/TMPOINTR.CPP --- a/windowing/windowserver/tman/TMPOINTR.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,808 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Test pointer event handling -// -// - -#include -#include -#include "W32STD.H" -#include "../tlib/testbase.h" -#include "TMAN.H" - -class CTPointerTest; -class CGrabWindow; - -class CPointerWindow : public CTWin - { - enum {KRepeatMargin=200000}; // 0.2 Seconds - enum {KRepeatCount=4}; - enum {KRepeatIntervalIncrements=100000}; - enum {KRepeatRectXExtra=50}; - enum {KRepeatRectYExtra=50}; - enum {KStateWaitingForTest1,KStateFailed,KStateTesting1, - KStateWaitingForTest2,KStateTesting2, - KStateWaitingForTest3,KStateTesting3, - KStateWaitingForTest4,KStateTesting4, - KStateWaitingForTest5,KStateTesting5, - KStateWaitingForTest6,KStateTesting6, - KStateWaitingForTest8,KStateTesting8, - KStateWaitingForTest7,KStateTesting7, - KStateFinished}; -public: - CPointerWindow(CTPointerTest *aTest); - void SetUpLD(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc); - void Draw(); - void StartNextRepeatTest(); - void QueueNextRepeat(); - void PointerL(const TPointerEvent &aPointer,const TTime&); - void WinKeyL(const TKeyEvent &aKey,const TTime &aTime); -private: - void SwitchOn(const TTime &); - void ResetTest(TInt aState); - void SetState(TInt aState); - void FinishedTests(); - void TestFailed(); -private: - CTPointerTest *iTest; - TInt iRepeatCount; - TInt iState; - TTimeIntervalMicroSeconds32 iInterval; - TTime iPrevTime; - TRect iRepeatRect; - }; - -class CGrabWindow2 : public CTWin - { -public: - CGrabWindow2(CGrabWindow *aWindow); - void SetUpLD(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc); -private: - void Draw(); - void PointerL(const TPointerEvent &aPointer,const TTime&); -private: - CGrabWindow *iGrabWindow; - }; - -class CGrabWindow : public CTWin - { - enum {KGrabStateWaitingForDown,KGrabStateWaitingForDragOut,KGrabStateWaitingForUp,KGrabStateFinished, - KGrabStateWaitingForDown2,KGrabStateWaitingForUp2a,KGrabStateWaitingForDrag2,KGrabStateWaitingForUp2b, - KGrabStateWaitingForDown3,KGrabStateWaitingForUp3a,KGrabStateWaitingForUp3b, - KGrabStateWaitingForDown4,KGrabStateWaitingForUp4, - KGrabStateWaitingForDown5,KGrabStateWaitingForUp5,KGrabStateWaitingForDrag5, - KStateFailed}; -public: - CGrabWindow(CTPointerTest *aTest); - void Pointer2(const TPointerEvent &aPointer); - void SetUpLD(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc); - void WinKeyL(const TKeyEvent &aKey,const TTime &aTime); -private: - void Draw(); - void SetState(TInt aState); - void ResetTest(); - void PointerL(const TPointerEvent &aPointer,const TTime&); - void TestFailed(); - void FinishedTests(); -private: - TInt iState; - CTPointerTest *iTest; - }; - -class CTPointerTest : public CTestBase - { -public: - CTPointerTest(); - ~CTPointerTest(); - TBool TestFailed(); - TestState DoTestL(); - void StartGrabTestL(); - void ConstructL(); - CGrabWindow2 *GrabWin2() const; - inline TBool Digitiser() const {return !iNoDigitiser;} -private: - TInt doTestFailedL(); -private: - CPointerWindow *iRepeatWin; - CGrabWindow *iGrabWin; - CGrabWindow2 *iGrabWin2; - TSize iWinSize; - TInt iState; - TBool iOldPointerState; - TBool iNoDigitiser; - }; - -GLDEF_C CTestBase *CreatePointerTest() - { - return(new(ELeave) CTPointerTest()); - } - -CPointerWindow::CPointerWindow(CTPointerTest *aTest) : CTWin(), iTest(aTest) - {} - -void CPointerWindow::SetState(TInt aState) - { - iState=aState; - iWin.Invalidate(); - switch(aState) - { - case KStateWaitingForTest1: - case KStateWaitingForTest2: - case KStateWaitingForTest3: - case KStateWaitingForTest4: - case KStateWaitingForTest5: - case KStateWaitingForTest6: - case KStateWaitingForTest8: - case KStateWaitingForTest7: - iRepeatRect=TRect(); - break; - case KStateTesting8: - iWin.Close(); - Client()->iWs.Flush(); - User::After(500000); - FinishedTests(); - break; - } - } - -void CPointerWindow::ResetTest(TInt aState) - { - TInt newState=KStateFinished; - switch(aState) - { - case KStateTesting1: - newState=KStateWaitingForTest1; - break; - case KStateTesting2: - newState=KStateWaitingForTest2; - break; - case KStateTesting3: - newState=KStateWaitingForTest3; - break; - case KStateTesting4: - newState=KStateWaitingForTest4; - break; - case KStateTesting5: - newState=KStateWaitingForTest5; - break; - case KStateTesting6: - newState=KStateWaitingForTest6; - break; - case KStateTesting8: - newState=KStateWaitingForTest8; - break; - case KStateTesting7: - newState=KStateWaitingForTest7; - break; - } - SetState(newState); - } - -void CPointerWindow::SetUpLD(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc) - { - ConstructExtLD(*parent,pos,size); - Activate(); - AssignGC(aGc); - //SetState(KStateWaitingForTest1); - SetState(KStateWaitingForTest7); //Only unconverted test - BaseWin()->EnableOnEvents(); - } - -void CPointerWindow::Draw() - { - iGc->Clear(); - iGc->DrawRect(Size()); - iGc->DrawRect(iRepeatRect); - TBuf<0x80> buf; - TBuf<0x80> buf2; - switch(iState) - { - case KStateWaitingForTest1: - buf.Format(_L("Click anywhere in the window and hold the pointer steady")); - break; - case KStateTesting1: - buf.Format(_L("Hold pointer inside the box")); - break; - case KStateWaitingForTest2: - buf.Format(_L("Release the pointer then click in the window and hold the pointer steady")); - break; - case KStateTesting2: - buf.Format(_L("Drag the pointer outside the box")); - break; - case KStateWaitingForTest3: - buf.Format(_L("Release the pointer then click in the window and hold the pointer steady")); - break; - case KStateTesting3: - buf.Format(_L("Release the pointer")); - break; - case KStateWaitingForTest4: - buf.Format(_L("Click anywhere in the window and move the pointer slightly")); - break; - case KStateTesting4: - buf.Format(_L("Release the pointer")); - break; - case KStateWaitingForTest5: - buf.Format(_L("Click anywhere in the window and move the pointer slightly")); - break; - case KStateTesting5: - buf.Format(_L("Release the pointer")); - break; - case KStateWaitingForTest6: - buf.Format(_L("Click anywhere in the window")); - break; - case KStateTesting6: - buf.Format(_L("Move the pointer")); - break; - case KStateWaitingForTest8: - buf.Format(_L("Click anywhere in the window, and keep the pointer pressed")); - break; - case KStateTesting8: - buf.Format(_L("")); - break; - case KStateWaitingForTest7: - buf.Format(_L("Switch off and touch the center of the screen")); - break; - case KStateTesting7: - buf.Format(_L("")); - break; - } - switch(iState) - { - case KStateTesting1: - buf2.Format(TRefByValue(_L("Repeat (%d/%d), interval=%d.%d")),iRepeatCount,KRepeatCount,iInterval.Int()/1000000,(iInterval.Int()%1000000)/100000); - break; - case KStateTesting2: - case KStateTesting3: - buf2.Format(TRefByValue(_L("Repeat (%d), interval=%d.%d")),iRepeatCount,iInterval.Int()/1000000,(iInterval.Int()%1000000)/100000); - break; - } - iGc->DrawText(buf,TPoint(10,20)); - iGc->DrawText(buf2,TPoint(10,40)); - } - -void CPointerWindow::FinishedTests() - { - iState=KStateFinished; - iTest->Request(); - } - -void CPointerWindow::StartNextRepeatTest() - { - iInterval=0; - iRepeatCount=0; - if (iState==KStateWaitingForTest4) - User::After(TTimeIntervalMicroSeconds32(1000000)); - else if (iState==KStateWaitingForTest5) - User::After(TTimeIntervalMicroSeconds32(1000000)); - QueueNextRepeat(); - switch(iState) - { - case KStateWaitingForTest1: - SetState(KStateTesting1); - break; - case KStateWaitingForTest2: - SetState(KStateTesting2); - break; - case KStateWaitingForTest3: - SetState(KStateTesting3); - break; - case KStateWaitingForTest4: - SetState(KStateTesting4); - break; - case KStateWaitingForTest5: - SetState(KStateTesting5); - break; - case KStateWaitingForTest6: - SetState(KStateTesting6); - break; - case KStateWaitingForTest8: - SetState(KStateTesting8); - break; - case KStateWaitingForTest7: - SetState(KStateTesting7); - break; - } - } - -void CPointerWindow::QueueNextRepeat() - { - iInterval=iInterval.Int()+KRepeatIntervalIncrements; - iWin.RequestPointerRepeatEvent(TTimeIntervalMicroSeconds32(iInterval),TRect(iRepeatRect)); - iPrevTime.HomeTime(); - iWin.Invalidate(); - } - -void CPointerWindow::PointerL(const TPointerEvent &aPointer,const TTime &aTime) - { - if (aPointer.iType==TPointerEvent::EButtonRepeat) - { - if (iState!=KStateTesting1 && iState!=KStateTesting2 && iState!=KStateTesting3 && iState!=KStateTesting4) - TestFailed(); - else - { - TTimeIntervalMicroSeconds32 interval(I64LOW(aTime.MicroSecondsFrom(iPrevTime).Int64())); - if (interval.Int()<(iInterval.Int()-KRepeatMargin) || interval.Int()>(iInterval.Int()+KRepeatMargin)) - TestFailed(); - else - { - if (!iRepeatRect.Contains(aPointer.iPosition) || - aPointer.iParentPosition!=(aPointer.iPosition+iWin.InquireOffset(*Parent()->WinTreeNode()))) - TestFailed(); - else - { - iRepeatCount++; - if (iState==KStateTesting1 && iRepeatCount==KRepeatCount) - { - QueueNextRepeat(); - Client()->iWs.Flush(); - User::After(TTimeIntervalMicroSeconds32(iRepeatCount*KRepeatIntervalIncrements)); - iWin.CancelPointerRepeatEventRequest(); - SetState(KStateWaitingForTest2); - } - else - QueueNextRepeat(); - } - } - } - } - else switch(iState) - { - case KStateWaitingForTest1: - case KStateWaitingForTest2: - case KStateWaitingForTest3: - case KStateWaitingForTest4: - case KStateWaitingForTest8: - if (aPointer.iType==TPointerEvent::EButton1Down) - { - iRepeatRect.iTl=aPointer.iPosition-TPoint(KRepeatRectXExtra,KRepeatRectYExtra); - iRepeatRect.iBr=aPointer.iPosition+TPoint(KRepeatRectXExtra,KRepeatRectYExtra); - StartNextRepeatTest(); - } - break; - case KStateWaitingForTest5: - if (aPointer.iType==TPointerEvent::EButton1Down) - { - iRepeatRect.iTl=aPointer.iPosition; - iRepeatRect.iBr=aPointer.iPosition+TPoint(1,1); - StartNextRepeatTest(); - } - break; - case KStateWaitingForTest6: - if (aPointer.iType==TPointerEvent::EButton1Down) - { - iRepeatRect.iTl=aPointer.iPosition+TPoint(KRepeatRectXExtra,KRepeatRectYExtra); - iRepeatRect.iBr=aPointer.iPosition+TPoint(2*KRepeatRectXExtra,2*KRepeatRectYExtra); - StartNextRepeatTest(); - } - break; - case KStateTesting1: - TestFailed(); - break; - case KStateTesting2: - if (aPointer.iType==TPointerEvent::EDrag) - SetState(KStateWaitingForTest3); - else - TestFailed(); - break; - case KStateTesting3: - if (aPointer.iType==TPointerEvent::EButton1Up) - SetState(KStateWaitingForTest4); - else - TestFailed(); - break; - case KStateTesting4: - if (aPointer.iType==TPointerEvent::EButton1Up) - SetState(KStateWaitingForTest5); - else - TestFailed(); - break; - case KStateTesting5: - if (aPointer.iType==TPointerEvent::EButton1Up) - SetState(KStateWaitingForTest6); - else if (aPointer.iType!=TPointerEvent::EDrag) - TestFailed(); - break; - case KStateTesting6: - if (aPointer.iType==TPointerEvent::EDrag) - { - #if !defined(__WINS__) // Can't emulate touching dig when switched off under WINS - if (iTest->Digitiser()) - SetState(KStateWaitingForTest7); - else - #endif - SetState(KStateWaitingForTest8); - } - else - TestFailed(); - break; - case KStateWaitingForTest7: - if (aPointer.iType==TPointerEvent::EButton1Down || aPointer.iType==TPointerEvent::ESwitchOn) - TestFailed(); - break; - case KStateTesting7: - if (aPointer.iType!=TPointerEvent::ESwitchOn) - TestFailed(); - else - SetState(KStateTesting8); //Jump straight to end as this is only unconverted test. - //SetState(KStateWaitingForTest8); - break; - case KStateTesting8: - break; - } - } - -void CPointerWindow::TestFailed() - { - if (iState!=KStateFailed) - { - TInt oldState=iState; - iState=KStateFailed; - if (iTest->TestFailed()) - ResetTest(oldState); - } - } - -void CPointerWindow::WinKeyL(const TKeyEvent &aKey,const TTime &) - { - if (aKey.iCode==EKeyEscape) - FinishedTests(); // Simply skip this test if the Escape key is pressed - } - -void CPointerWindow::SwitchOn(const TTime &) - { - if (iState==KStateWaitingForTest7) - SetState(KStateTesting7); - else - TestFailed(); - } - -// -// CGrabWindow // -// - -CGrabWindow::CGrabWindow(CTPointerTest *aTest) : iTest(aTest) - { - } - -void CGrabWindow::SetUpLD(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc) - { - ConstructExtLD(*parent,pos,size); - Activate(); - AssignGC(aGc); - SetState(KGrabStateWaitingForDown); - } - -void CGrabWindow::Draw() - { - iGc->Clear(); - iGc->DrawRect(Size()); - TBuf<0x80> buf; - switch(iState) - { - case KGrabStateWaitingForDown: - case KGrabStateWaitingForDown2: - case KGrabStateWaitingForDown5: - buf.Copy(_L("Press the pointer inside the window")); - break; - case KGrabStateWaitingForDown3: - case KGrabStateWaitingForUp3a: - buf.Copy(_L("Press and release the pointer inside the window")); - break; - case KGrabStateWaitingForDragOut: - buf.Copy(_L("Drag the pointer outside into the outside window")); - break; - case KGrabStateWaitingForDrag2: - buf.Copy(_L("Drag the pointer outside outside both windows")); - break; - case KGrabStateWaitingForUp: - case KGrabStateWaitingForUp2b: - case KGrabStateWaitingForUp5: - buf.Copy(_L("Release the pointer")); - break; - case KGrabStateWaitingForDown4: - buf.Copy(_L("Press then release the pointer")); - break; - default:; - } - iGc->DrawText(buf,TPoint(10,20)); - } - -void CGrabWindow::PointerL(const TPointerEvent &aPointer,const TTime&) - { - switch(iState) - { - case KGrabStateWaitingForDown: - if (aPointer.iType==TPointerEvent::EButton1Down) - SetState(KGrabStateWaitingForDragOut); - break; - case KGrabStateWaitingForDragOut: - if (aPointer.iType!=TPointerEvent::EDrag) - TestFailed(); - else - { - if (!TRect(Size()).Contains(aPointer.iPosition)) - SetState(KGrabStateWaitingForUp); - } - break; - case KGrabStateWaitingForUp: - if (aPointer.iType==TPointerEvent::EDrag) - break; - if (aPointer.iType==TPointerEvent::EButton1Up) - SetState(KGrabStateWaitingForDown2); - else - TestFailed(); - break; - case KGrabStateWaitingForDown2: - if (aPointer.iType!=TPointerEvent::EButton1Down) - TestFailed(); - else - { - iTest->GrabWin2()->BaseWin()->ClaimPointerGrab(); - iTest->GrabWin2()->BaseWin()->ClaimPointerGrab(); // Call twice to check it's harmless - SetState(KGrabStateWaitingForUp2a); - } - break; - case KGrabStateWaitingForUp2a: - SetState(KGrabStateWaitingForDrag2); - break; - case KGrabStateWaitingForDrag2: - break; - case KGrabStateWaitingForUp2b: - TestFailed(); - break; - case KGrabStateWaitingForDown3: - if (aPointer.iType!=TPointerEvent::EButton1Down) - TestFailed(); - else - SetState(KGrabStateWaitingForUp3a); - break; - case KGrabStateWaitingForUp3a: - if (aPointer.iType==TPointerEvent::EButton1Up) - { - iTest->GrabWin2()->BaseWin()->ClaimPointerGrab(); - SetState(KGrabStateWaitingForUp3b); - } - break; - case KGrabStateWaitingForUp3b: - TestFailed(); - break; - case KGrabStateWaitingForDown5: - if (aPointer.iType!=TPointerEvent::EButton1Down) - TestFailed(); - else - { - iTest->GrabWin2()->BaseWin()->ClaimPointerGrab(EFalse); - SetState(KGrabStateWaitingForDrag5); - } - break; - case KGrabStateWaitingForDrag5: - if (aPointer.iType==TPointerEvent::EButton1Up) - TestFailed(); - break; - case KGrabStateWaitingForUp5: - TestFailed(); - break; - case KGrabStateWaitingForDown4: - SetState(KGrabStateWaitingForUp4); - iWin.Close(); // Close the window with the grab captured in it - break; - case KGrabStateFinished: - break; - } - } - -void CGrabWindow::ResetTest() - { - SetState(KGrabStateWaitingForDown); - } - -void CGrabWindow::Pointer2(const TPointerEvent &aPointer) - { - switch(iState) - { - case KGrabStateWaitingForDrag2: - { - if (aPointer.iType==TPointerEvent::EDrag) - { - SetState(KGrabStateWaitingForUp2b); - } - else - { - if (iTest->TestFailed()) - ResetTest(); - } - break; - } - case KGrabStateWaitingForUp2b: - if (aPointer.iType==TPointerEvent::EDrag) // Harmless - break; - if (aPointer.iType==TPointerEvent::EButton1Up) - SetState(KGrabStateWaitingForDown3); - else - TestFailed(); - break; - case KGrabStateWaitingForUp3b: - if (aPointer.iType==TPointerEvent::EButton1Up) - SetState(KGrabStateWaitingForDown5); - else - TestFailed(); - break; - case KGrabStateWaitingForUp4: - FinishedTests(); - break; - case KGrabStateWaitingForDrag5: - { - if (aPointer.iType==TPointerEvent::EDrag) - SetState(KGrabStateWaitingForUp5); - else if (iTest->TestFailed()) - ResetTest(); - break; - } - case KGrabStateWaitingForUp5: - if (aPointer.iType==TPointerEvent::EDrag) // Harmless - break; - if (aPointer.iType==TPointerEvent::EButton1Up) - SetState(KGrabStateWaitingForDown4); - else - TestFailed(); - break; - default:; - } - } - -void CGrabWindow::SetState(TInt aState) - { - iState=aState; - iWin.Invalidate(); - } - -void CGrabWindow::TestFailed() - { - if (iState!=KStateFailed) - { - iState=KStateFailed; - if (iTest->TestFailed()) - ResetTest(); - } - } - -void CGrabWindow::FinishedTests() - { - iState=KGrabStateFinished; - iTest->Request(); - } - -void CGrabWindow::WinKeyL(const TKeyEvent &aKey,const TTime &) - { - if (aKey.iCode==EKeyEscape) - FinishedTests(); // Simply skip this test if the Escape key is pressed - } - -// -// CGrabWindow2, used as part of grab tests // -// - -CGrabWindow2::CGrabWindow2(CGrabWindow *aWindow) : iGrabWindow(aWindow) - { - } - -void CGrabWindow2::Draw() - { - iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - iGc->SetBrushColor(TRgb::Gray4(2)); - iGc->DrawRect(Size()); - } - -void CGrabWindow2::PointerL(const TPointerEvent &aPointer,const TTime&) - { - iGrabWindow->Pointer2(aPointer); - } - -// -// CTPointTest // -// - -CTPointerTest::CTPointerTest() : CTestBase(_L("CTPointerTest")) - {} - -CTPointerTest::~CTPointerTest() - { - HAL::Set(HALData::EPenDisplayOn,iOldPointerState); - delete iRepeatWin; - delete iGrabWin; - delete iGrabWin2; - Client()->ResetFocus(); - } - -void CTPointerTest::ConstructL() - { - iRepeatWin=new(ELeave) CPointerWindow(this); - TSize screenSize(Client()->iScreen->SizeInPixels()); - iRepeatWin->SetUpLD(TPoint(screenSize.iWidth/8,screenSize.iHeight/8),TSize(screenSize.iWidth*3/4,screenSize.iHeight*3/4),Client()->iGroup,*Client()->iGc); - Client()->iGroup->SetCurrentWindow(iRepeatWin); - iNoDigitiser=EFalse; - TInt err=HAL::Get(HALData::EPenDisplayOn,iOldPointerState); - if (err==KErrNotSupported) - iNoDigitiser=ETrue; - else if (err==KErrNone) - err=HAL::Set(HALData::EPenDisplayOn,ETrue); - if (err==KErrNotSupported) - iNoDigitiser=(!iOldPointerState); - else - TestL(err==KErrNone); - } - -TBool CTPointerTest::TestFailed() - { - TInt ret=1; - TRAP_IGNORE(ret=doTestFailedL()); - switch(ret) - { - case 0: - return(ETrue); // Re-try test - case 1: - Request(); - break; - } - return(EFalse); - } - -TInt CTPointerTest::doTestFailedL() - { - CTDialog *dialog=new(ELeave) CTDialog(); - dialog->SetTitle(_L("Pointer repeat test failed")); - dialog->SetNumButtons(2); - dialog->SetButtonText(0,_L("Retest")); - dialog->SetButtonText(1,_L("Fail")); - dialog->ConstructLD(*Client()->iGroup,*Client()->iGc); - return dialog->Display(); - } - -CGrabWindow2 *CTPointerTest::GrabWin2() const - { - return(iGrabWin2); - } - -void CTPointerTest::StartGrabTestL() - { - iGrabWin=new(ELeave) CGrabWindow(this); - iGrabWin2=new(ELeave) CGrabWindow2(iGrabWin); -// - TSize screenSize(Client()->iScreen->SizeInPixels()); - iGrabWin2->SetUpL(TPoint(screenSize.iWidth/8,screenSize.iHeight/8),TSize(screenSize.iWidth*3/4,screenSize.iHeight*3/4),Client()->iGroup,*Client()->iGc); - Client()->iGroup->SetCurrentWindow(iGrabWin2); -// - iGrabWin->SetUpLD(TPoint(screenSize.iWidth/4,screenSize.iHeight/4),TSize(screenSize.iWidth/2,screenSize.iHeight/2),Client()->iGroup,*Client()->iGc); - Client()->iGroup->SetCurrentWindow(iGrabWin); -// - } - -#pragma warning( disable : 4065 ) //switch statement contains 'default' but no 'case' labels -TestState CTPointerTest::DoTestL() - { - switch(iState) - { - #if !defined(__WINS__) //Only unconverted test is MARM only - case 0: - LogSubTest(_L("Repeat tests"),1); - iState++; - return(EContinue); - #endif - - default: - return(EFinished); - } - } -#pragma warning( default : 4065 ) - diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tman/TMSCRMOD.CPP --- a/windowing/windowserver/tman/TMSCRMOD.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,226 +0,0 @@ -// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Screen mode changing tests -// -// - -#include -#include "W32STD.H" -#include "../tlib/testbase.h" -#include "TMAN.H" - -class CScreenModeTest; - -class CScreenModeWindow : public CTWin - { -public: - CScreenModeWindow(); - void SetUpLD(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc); - void WinKeyL(const TKeyEvent &aKey,const TTime &aTime); - void Draw(); - void ScreenDeviceChanged(); -private: - TInt iSubState; - }; - -class CScreenModeGroup : public CTWindowGroup - { -public: - ~CScreenModeGroup(); - CScreenModeGroup(CTClient *aClient); - void ConstructL(); - void ScreenDeviceChanged(); -private: - CScreenModeWindow *iWindow; - }; - -class CScreenModeTest : public CTestBase - { -public: - CScreenModeTest(); - ~CScreenModeTest(); - TestState DoTestL(); - void ConstructL(); -private: - CScreenModeGroup *iScreenModeGroup; - TSize iWinSize; - TInt iState; - }; - -GLDEF_C CTestBase *CreateScreenModeTest() - { - return(new(ELeave) CScreenModeTest()); - } - -// -// CScreenModeWindow -// - -CScreenModeWindow::CScreenModeWindow() : CTWin() - {} - -void CScreenModeWindow::WinKeyL(const TKeyEvent &aKey,const TTime &) - { - if (aKey.iCode==EKeyEscape || aKey.iCode==EKeyEnter) - { - if (iSubState==0) - { - iSubState=1; - ScreenDeviceChanged(); - Invalidate(); - } - else - CActiveScheduler::Stop(); - } - } - -void CScreenModeWindow::SetUpLD(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc) - { - ConstructExtLD(*parent,pos,size); - Activate(); - AssignGC(aGc); - } - -void CScreenModeWindow::Draw() - { - iGc->Clear(); - TSize winSize(Win()->Size()); - iGc->DrawRect(winSize); - iGc->DrawLine(TPoint(0,0),TPoint(winSize.iWidth,winSize.iHeight)); - iGc->DrawLine(TPoint(0,winSize.iHeight),TPoint(winSize.iWidth,0)); - TInt xpos=winSize.iWidth/2-100; - iGc->DrawText(iSubState==0?_L("Twips not adjusted,"): - _L("Twips adjusted,"),TPoint(xpos,20)); - iGc->DrawText(_L("Cycle through all screen modes,"),TPoint(xpos,40)); - iGc->DrawText(_L("Check the window is resized and rotated correctly,"),TPoint(xpos,60)); - iGc->DrawText(_L("Then press when finished"),TPoint(xpos,80)); -// - TSize twips=Client()->iScreen->SizeInTwips(); - TSize pixels=Client()->iScreen->SizeInPixels(); -// Horizontal line - TInt inches=twips.iWidth/KTwipsPerInch-1; - TInt lineLen=Client()->iScreen->HorizontalTwipsToPixels(inches*KTwipsPerInch); - TPoint linePos=TPoint((pixels.iWidth-lineLen)/2,pixels.iHeight/2); - iGc->DrawLine(linePos,linePos+TPoint(lineLen,0)); - TBuf<0x20> buf; - buf.Format(TRefByValue(_L("Width %d\"")),inches); - iGc->DrawText(buf,TPoint((pixels.iWidth-iFont->TextWidthInPixels(buf))/2,linePos.iY-iFont->HeightInPixels()+iFont->AscentInPixels()-2)); - TInt index; - for(index=0;index<=inches;index++) - { - TInt dx=Client()->iScreen->HorizontalTwipsToPixels(index*KTwipsPerInch); - TInt dy=Client()->iScreen->VerticalTwipsToPixels(KTwipsPerInch/(index==0 || index==inches ? 8 : 16)); - iGc->DrawLine(linePos+TPoint(dx,1), linePos+TPoint(dx,dy)); - } -// Vertical line - inches=twips.iHeight/KTwipsPerInch; - lineLen=Client()->iScreen->VerticalTwipsToPixels(inches*KTwipsPerInch); - linePos.iY=(pixels.iHeight-lineLen)/2; - iGc->DrawLine(linePos,linePos+TPoint(0,lineLen)); - buf.Format(TRefByValue(_L("Height %d\"")),inches); - iGc->DrawText(buf,TPoint(linePos.iX+10, pixels.iHeight/4)); - for(index=0;index<=inches;index++) - { - TInt dx=Client()->iScreen->HorizontalTwipsToPixels(KTwipsPerInch/(index==0 || index==inches ? 8 : 16)); - TInt dy=Client()->iScreen->VerticalTwipsToPixels(index*KTwipsPerInch); - iGc->DrawLine(linePos+TPoint(1,dy), linePos+TPoint(dx,dy)); - } - - } - -void CScreenModeWindow::ScreenDeviceChanged() - { - if (iSubState==0) - { - TPixelsAndRotation sizeAndRotation; - Client()->iScreen->GetDefaultScreenSizeAndRotation(sizeAndRotation); - Client()->iScreen->SetScreenSizeAndRotation(sizeAndRotation); - } - else - { - TPixelsTwipsAndRotation sizeAndRotation; - Client()->iScreen->GetDefaultScreenSizeAndRotation(sizeAndRotation); - Client()->iScreen->SetScreenSizeAndRotation(sizeAndRotation); - } - SetSize(Client()->iScreen->SizeInPixels()); - } - -// -// CScreenModeGroup -// - -CScreenModeGroup::~CScreenModeGroup() - { - GroupWin()->EnableReceiptOfFocus(EFalse); - ClearCurrentWindow(); - Client()->iGroup->SetCurrentWindow(NULL); - CTWin::Delete(iWindow); - } - -CScreenModeGroup::CScreenModeGroup(CTClient *aClient) : CTWindowGroup(aClient) - {} - -void CScreenModeGroup::ConstructL() - { - CTWindowGroup::ConstructL(); - iWindow=new(ELeave) CScreenModeWindow; - iWindow->SetUpLD(TPoint(0,0),Client()->iScreen->SizeInPixels(),this,*Client()->iGc); - SetCurrentWindow(iWindow); - GroupWin()->EnableScreenChangeEvents(); - GroupWin()->SetOrdinalPosition(0); - } - -void CScreenModeGroup::ScreenDeviceChanged() - { - iWindow->ScreenDeviceChanged(); - } - -// -// CScreenModeTest -// - -CScreenModeTest::CScreenModeTest() : CTestBase(_L("Screen mode")) - {} - -CScreenModeTest::~CScreenModeTest() - { - Client()->iGroup->GroupWin()->EnableScreenChangeEvents(); - Client()->iScreen->SetScreenMode(0); - delete iScreenModeGroup; - } - -void CScreenModeTest::ConstructL() - { - Client()->iGroup->GroupWin()->SetOrdinalPosition(0); - Client()->iGroup->GroupWin()->DisableScreenChangeEvents(); -// - iScreenModeGroup=new(ELeave) CScreenModeGroup(Client()); - iScreenModeGroup->ConstructL(); - } - -TestState CScreenModeTest::DoTestL() - { - switch(iState) - { - case 0: - LogSubTest(_L("Screen mode 1"),1); - CActiveScheduler::Start(); - iState++; - break; - default: - return(EFinished); - } - return(ENext); - } - diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tman/TMTScrMd.CPP --- a/windowing/windowserver/tman/TMTScrMd.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,463 +0,0 @@ -// Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Screen mode changing tests -// -// - -#include -#include -#include "W32STD.H" -#include "../tlib/testbase.h" -#include "TMAN.H" - -class CTimeWindow; - -class CQBlankWindow : public CBlankWindow - { -public: - static TInt iInitialColor; -public: - //Virtual function from CTBaseWin - void InitWin(); -public: - static TSize iSize; - TSglQueLink iLink; - }; - -class CFixScreenModeGroup : public CTWindowGroup - { -public: - static TInt iNoClientWins; -public: - ~CFixScreenModeGroup(); - CFixScreenModeGroup(CTClient *aClient); - void ConstructL(); -public: - TSglQueLink iLink; -private: - TSglQue iWindows; - }; - -class CFlipClient : public CTClient - { -public: - void ConstructL(); -private: - }; - -class CScreenModeTimes : public CTestBase - { -public: - CScreenModeTimes(); - ~CScreenModeTimes(); - TestState DoTestL(); - void ConstructL(); - void DoTimings(); -private: - void CreateGroupL(CTClient* aClient,TSglQue& aQue); - void DeleteGroups(TSglQue& aQue); - void BringToFront(TSglQue& aQue); -private: - TScreenModeEnforcement iEnforcementMode; - CInfoDialog* iDialogue; - CTimeWindow* iInfoWindow; - CFlipClient* iFlipClient; - TSglQue iNormalGroupQue; - TSglQue iFlipGroupQue; - TInt iNoGroupWins; - TInt iState; - }; - -class CTimeWindow : public CTTitledWindow - { -public: - void Construct(CTestBase* aTest); - void SetNumWindows(TInt aGroup,TInt aWin); - void SetTime1(TTimeIntervalMicroSeconds& aTime); - void SetTime2(TTimeIntervalMicroSeconds& aTime); - void DoDraw(); - //virtual function from CTWinBase overridden by CTBaseWin - void WinKeyL(const TKeyEvent &aKey,const TTime &aTime); - //virtual functions from CTBaseWin - void SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc); - void PointerL(const TPointerEvent &aPointer,const TTime &aTime); - //virtual function from CTBaseWin overridden by CTTitledWindow - void Draw(); -private: - inline CScreenModeTimes* Test() {return STATIC_CAST(CScreenModeTimes*,iTest);} - void UpdateString1(); - void UpdateString2(); - void UpdateString3(); -private: - CTestBase* iTest; - TInt iNumGroups; - TInt iNumWins; - TTimeIntervalMicroSeconds iTime1; - TTimeIntervalMicroSeconds iTime2; - TBuf<32> iString1; - TBuf<32> iString2; - TBuf<32> iString3; - TBuf<32> iString4; - TRect iRect1; - TRect iRect2; - TRect iRect3; - TRect iRect4; - TBool iPressed; - TBool iExit; - }; - - -TSize CQBlankWindow::iSize; -TInt CQBlankWindow::iInitialColor; -TInt CFixScreenModeGroup::iNoClientWins=0; - - -GLDEF_C CTestBase *CreateScreenModeTimes() - { - return(new(ELeave) CScreenModeTimes()); - } - - -// -// CFlipClient -// - -void CFlipClient::ConstructL() - { - CTClient::ConstructL(); - TPixelsAndRotation sizeAndRotation; - iScreen->GetScreenModeSizeAndRotation(1,sizeAndRotation); - iScreen->SetScreenSizeAndRotation(sizeAndRotation); - } - - -// -// CTimeWindow -// - -void CTimeWindow::Construct(CTestBase* aTest) - { - _LIT(Title,"StatusWindow"); - _LIT(String4,"Click here to finish"); - const TInt fontHeight=iFont->HeightInPixels(); - iTest=aTest; - TWindowTitle title(Title); - SetTitle(title); - TInt yy=iTitleHeight+fontHeight+7; - iRect1.SetRect(3,iTitleHeight+5,iSize.iWidth-1,yy); - yy+=fontHeight/2; - TInt yy1=yy+fontHeight+2; - iRect2.SetRect(3,yy+3,iSize.iWidth-1,yy1); - TInt yy2=yy1+iFont->HeightInPixels()+2; - iRect3.SetRect(3,yy1+3,iSize.iWidth-1,yy2); - yy2+=fontHeight/2; - iRect4.SetRect(3,yy2+3,iSize.iWidth-1,yy2+iFont->HeightInPixels()+2); - // - iString4.Copy(String4); - iExit=EFalse; - } - -void CTimeWindow::SetUpL(TPoint aPos,TSize aSize,CTWinBase *aParent,CWindowGc &aGc) - { - CTTitledWindow::SetUpL(aPos,aSize,aParent,aGc); - } - -void CTimeWindow::WinKeyL(const TKeyEvent &aKey,const TTime&) - { - switch(aKey.iCode) - { - case EKeyEscape: - iTest->Request(); - break; - default:; - } - } - -void CTimeWindow::PointerL(const TPointerEvent &aPointer,const TTime &aTime) - { - if (iRect2.Contains(aPointer.iPosition) || iRect3.Contains(aPointer.iPosition)) - { - if (aPointer.iType==TPointerEvent::EButton1Down) - iPressed=ETrue; - } - else if (iRect4.Contains(aPointer.iPosition)) - iExit=ETrue; - else - CTTitledWindow::PointerL(aPointer,aTime); - if ((iExit||iPressed) && aPointer.iType==TPointerEvent::EButton1Up) - { - if (iExit) - iTest->Request(); - else - { - Test()->DoTimings(); - DoDraw(); - } - } - } - -void CTimeWindow::Draw() - { - CTTitledWindow::Draw(); - TInt ascent=iFont->AscentInPixels()+1; - iGc->DrawText(iString1,iRect1,ascent,CGraphicsContext::ELeft); - iGc->DrawText(iString2,iRect2,ascent,CGraphicsContext::ELeft); - iGc->DrawText(iString3,iRect3,ascent,CGraphicsContext::ELeft); - iGc->DrawText(iString4,iRect4,ascent,CGraphicsContext::ELeft); - } - -void CTimeWindow::DoDraw() - { - iGc->Activate(iWin); - iGc->UseFont((CFont *)iFont); - Draw(); - iGc->Deactivate(); - } - -void CTimeWindow::SetNumWindows(TInt aGroups,TInt aWins) - { - iNumGroups=aGroups; - iNumWins=aWins; - UpdateString1(); - } - -void CTimeWindow::UpdateString1() - { - _LIT(NumberWin,"Groups (2x)%d, Windows %d"); - iString1.Format(NumberWin,iNumGroups,iNumWins); - } - -void CTimeWindow::SetTime1(TTimeIntervalMicroSeconds& aTime) - { - iTime1=aTime; - UpdateString2(); - } - -void CTimeWindow::SetTime2(TTimeIntervalMicroSeconds& aTime) - { - iTime2=aTime; - UpdateString3(); - } - -_LIT(TimeFormat,"Time%d = %d.%04dsecs"); - -void CTimeWindow::UpdateString2() - { - TInt time = I64LOW(iTime1.Int64()); - iString2.Format(TimeFormat,1,time/1000000,(time%1000000)/100); - } - -void CTimeWindow::UpdateString3() - { - TInt time = I64LOW(iTime2.Int64()); - iString3.Format(TimeFormat,2,time/1000000,(time%1000000)/100); - } - - -// -// CQBlankWindow -// - -void CQBlankWindow::InitWin() - { - SetColor(TRgb::Gray4(iInitialColor)); - iWin.SetSize(iSize); - } - - -// -// CFixScreenModeGroup -// - -CFixScreenModeGroup::~CFixScreenModeGroup() - { - GroupWin()->EnableReceiptOfFocus(EFalse); - ClearCurrentWindow(); - CQBlankWindow* win; - while (!iWindows.IsEmpty()) - { - win=iWindows.First(); - iWindows.Remove(*win); - delete win; - } - } - -CFixScreenModeGroup::CFixScreenModeGroup(CTClient *aClient) : CTWindowGroup(aClient), iWindows(_FOFF(CQBlankWindow,iLink)) - {} - -void CFixScreenModeGroup::ConstructL() - { - CTWindowGroup::ConstructL(); - CQBlankWindow* win; - TInt ii; - for(ii=0;iiConstructL(*this); - win->Activate(); - win->AssignGC(*iClient->iGc); - iWindows.AddLast(*win); - CleanupStack::Pop(win); - Client()->Flush(); - } - SetCurrentWindow(iWindows.First()); - } - -/*void CFixScreenModeGroup::ScreenDeviceChanged() - { - iWindow->ScreenDeviceChanged(); - }*/ - - -// -// CScreenModeTimes -// - -_LIT(TestName,"Screen Mode Times"); -CScreenModeTimes::CScreenModeTimes() : CTestBase(TestName) - ,iNormalGroupQue(_FOFF(CFixScreenModeGroup,iLink)),iFlipGroupQue(_FOFF(CFixScreenModeGroup,iLink)) - {} - -CScreenModeTimes::~CScreenModeTimes() - { - Client()->iGroup->GroupWin()->EnableScreenChangeEvents(); - Client()->iScreen->SetScreenMode(0); - DeleteGroups(iNormalGroupQue); - DeleteGroups(iFlipGroupQue); - Client()->iGroup->SetCurrentWindow(NULL); - delete iFlipClient; - delete iInfoWindow; - if (iEnforcementMode==ESizeEnforcementNone) - Client()->iScreen->SetScreenModeEnforcement(ESizeEnforcementNone); - } - -void CScreenModeTimes::ConstructL() - { - iEnforcementMode=Client()->iScreen->ScreenModeEnforcement(); - if (iEnforcementMode==ESizeEnforcementNone) - Client()->iScreen->SetScreenModeEnforcement(ESizeEnforcementPixelsAndRotation); - iDialogue=new(ELeave) CInfoDialog(Client()->iGroup,Client()->iGc); - iDialogue->ConstructLD(); - iFlipClient=new(ELeave) CFlipClient(); - iFlipClient->ConstructL(); - Client()->iGroup->GroupWin()->DisableScreenChangeEvents(); - iNoGroupWins=12; //20; - CFixScreenModeGroup::iNoClientWins=20; //30; - TSize screenSize=Client()->iScreen->SizeInPixels(); - CQBlankWindow::iSize.iWidth=Max(screenSize.iHeight,screenSize.iWidth); - CQBlankWindow::iSize.iHeight=CQBlankWindow::iSize.iWidth; - TInt ii; - for(ii=0;iiiGroup->GroupWin()->SetOrdinalPosition(0); - iInfoWindow=new(ELeave) CTimeWindow(); - iInfoWindow->SetUpL(TPoint(Max(Min(415,screenSize.iWidth-210),0),Min(50,screenSize.iHeight-180)),TSize(210,180),Client()->iGroup,*Client()->iGc); - Client()->iGroup->SetCurrentWindow(iInfoWindow); - iInfoWindow->Construct(this); - iInfoWindow->WinTreeNode()->SetOrdinalPosition(1); - iInfoWindow->SetNumWindows(iNoGroupWins,CFixScreenModeGroup::iNoClientWins); - - Client()->iGroup->GroupWin()->DisableScreenChangeEvents(); - Client()->iWs.SetAutoFlush(ETrue); - iFlipClient->iWs.SetAutoFlush(ETrue); - Client()->iWs.SetPointerCursorMode(EPointerCursorNone); - } - -void CScreenModeTimes::CreateGroupL(CTClient *aClient,TSglQue& aQue) - { - CFixScreenModeGroup* group; - group=new(ELeave) CFixScreenModeGroup(aClient); - CleanupStack::PushL(group); - group->ConstructL(); - aQue.AddLast(*group); - CleanupStack::Pop(group); - } - -void CScreenModeTimes::DeleteGroups(TSglQue& aQue) - { - CFixScreenModeGroup* group; - while (!aQue.IsEmpty()) - { - group=aQue.First(); - aQue.Remove(*group); - delete group; - } - } - -void CScreenModeTimes::BringToFront(TSglQue& aQue) - { - TSglQueIter iter(aQue); - CFixScreenModeGroup* group=iter++; - group->GroupWin()->SetOrdinalPosition(0); - while ((group=iter++)!=NULL) - group->GroupWin()->SetOrdinalPosition(1); - } - -void CScreenModeTimes::DoTimings() - { - //Timings 1 SCRDEV, DWsScreenDevice::CommandL, around call to SetScreenMode - //Timings 2 GROUPWIN, CWsWindowGroup::SetScreenDeviceValidStates, around main body of function including calls to old way - //Timings 3 CLIWIN, CWsTopClientWindow::SetScreenDeviceValidState, around call to ResetHiddenFlagAndAdjustRegions - //Timings 3 GROUPWIN, CWsWindowGroup::SetScreenDeviceValidStates, around main body of function excluding calls to old way - //Timings 4&5 CLIWIN, CWsClientWindow::ResetHiddenFlagAndAdjustRegions, going invisible and becomming visible sections - Client()->iGroup->GroupWin()->SetOrdinalPosition(-2); - Client()->Flush(); - TTime startTime; - TTime middleTime; - TTime endTime; -__PROFILE_START(0); - startTime.HomeTime(); - BringToFront(iNormalGroupQue); - Client()->iScreen->SetScreenMode(1); - middleTime.HomeTime(); - BringToFront(iFlipGroupQue); - Client()->iScreen->SetScreenMode(0); - endTime.HomeTime(); -__PROFILE_END(0); -#if defined(__PROFILING__) - TProfile profile; - RDebug::ProfileResult(&profile,3,1); - if (profile.iCount>0) - iDialogue->TimerResults(0); -#endif - TTimeIntervalMicroSeconds time=middleTime.MicroSecondsFrom(startTime); - iInfoWindow->SetTime1(time); - time=endTime.MicroSecondsFrom(middleTime); - iInfoWindow->SetTime2(time); - Client()->iGroup->GroupWin()->SetOrdinalPosition(0); -#if defined(__PROFILING__) - if (profile.iCount>0) - iDialogue->Display(); -#endif - } - -TestState CScreenModeTimes::DoTestL() - { - switch(iState) - { - case 0: - LogSubTest(_L("Time ScreenMode Changes"),1); - DoTimings(); - iState++; - return EContinue; - default: - return EFinished; - } - } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tman/TPASSWRD.CPP --- a/windowing/windowserver/tman/TPASSWRD.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,429 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Test Wserv password features -// -// - -#include -#include -#include "W32STD.H" -#include "../tlib/testbase.h" -#include "TMAN.H" - -//#define LOG_TESTS - -#define THE_PASSWORD _L("pass") - -enum TPasswordState - { - ENotStarted, - EWaitForSwitchOff, - EWaitForEnter, - EWaitForA, - EWaitForSwitchOff2, - EWaitForSwitchOff3, - EWaitForSwitchOff4, - EWaitForSwitchOff5, - EWaitForEnter2, - EPasswordFinished, - }; - -class CPasswordTest; - -class CPasswordWindowGroup : public CTWindowGroup - { -public: - CPasswordWindowGroup(CTClient *aClient, CPasswordTest *aTest); - void ConstructL(); - void PasswordL(const TTime &aTime); - void KeyL(const TKeyEvent &aKey,const TTime &aTime); - void SwitchOn(const TTime &aTime); -private: - CPasswordTest *iTest; - }; - -class CPasswordWindowGroup2 : public CTWindowGroup - { -public: - CPasswordWindowGroup2(CTClient *aClient, CPasswordTest *aTest); - void ConstructL(); - void KeyL(const TKeyEvent &aKey,const TTime &aTime); -private: - CPasswordTest *iTest; - }; - -class CPasswordWindow : public CTWin - { -public: - CPasswordWindow(CPasswordTest *aTest); - void Draw(); -private: - CPasswordTest *iTest; - }; - -class CPasswordTest : public CTestBase - { -public: - CPasswordTest(); - ~CPasswordTest(); - TestState DoTestL(); - void ConstructL(); - void Fail(TInt aWhere); - void EnterKeyPressed(TPasswordState aNewState); - void SwitchOn(); - void TestComplete(TPasswordState aNewState); - void PasswordMsgReceivedL(); - TPasswordState PasswordState() const; - void SetPassState(TPasswordState aPassState); - void StartMainPasswordTestL(); - void StartOnceADayPasswordTestL(); - void TurnOffAndOn(); -private: - CPasswordWindowGroup *iGroup; - CPasswordWindowGroup2 *iGroup2; - CPasswordWindow *iPassWin; - CTBlankWindow *iBlankWin; - TSize iWinSize; - TInt iState; - TPasswordState iPassState; - TBool iPasswordTestFailed; - }; - -GLDEF_C CTestBase *CreatePasswordTest() - { - return(new(ELeave) CPasswordTest()); - } - -// - -CPasswordWindowGroup::CPasswordWindowGroup(CTClient *aClient, CPasswordTest *aTest) : - CTWindowGroup(aClient), - iTest(aTest) - { - __DECLARE_NAME(_S("CPasswordWindowGroup")); - } - -void CPasswordWindowGroup::ConstructL() - { - CTWindowGroup::ConstructL(); - GroupWin()->EnableOnEvents(); - } - -void CPasswordWindowGroup::SwitchOn(const TTime &) - { - iTest->SwitchOn(); - } - -void CPasswordWindowGroup::KeyL(const TKeyEvent &aKey,const TTime &) - { - if (aKey.iCode==EKeyEscape) - iTest->TestComplete(EPasswordFinished); - switch(iTest->PasswordState()) - { - case EWaitForEnter: - if (aKey.iCode==EKeyEnter) - iTest->EnterKeyPressed(EWaitForA); - break; - case EWaitForEnter2: - if (aKey.iCode==EKeyEnter) - iTest->TestComplete(EPasswordFinished); - break; - default:; - } - } - -void CPasswordWindowGroup::PasswordL(const TTime &) - { - iTest->TestL(iGroupWin.OrdinalPosition()==0); - iTest->PasswordMsgReceivedL(); - } - -// - -CPasswordWindowGroup2::CPasswordWindowGroup2(CTClient *aClient, CPasswordTest *aTest) : - CTWindowGroup(aClient), - iTest(aTest) - { - __DECLARE_NAME(_S("CPasswordWindowGroup")); - } - -void CPasswordWindowGroup2::ConstructL() - { - CTWindowGroup::ConstructL(); - iGroupWin.CaptureKey('a',0,0); - } - -void CPasswordWindowGroup2::KeyL(const TKeyEvent &aKey,const TTime &) - { - if (iTest->PasswordState()!=EPasswordFinished) - { - if (iTest->PasswordState()!=EWaitForA) - { - #if defined(LOG_TESTS) - TLogMessageText buf; - _LIT(KBadKey,"Bad Key Code=%d(%c) Scan=%d(%c) Rep=%d"); - buf.AppendFormat(KBadKey,aKey.iCode,aKey.iCode,aKey.iScanCode,aKey.iScanCode,aKey.iRepeats); - Client()->LogMessage(buf); - #endif - if (aKey.iRepeats==0) - iTest->Fail(1); - } - else - { - if (aKey.iCode!='a') - iTest->Fail(2); - iTest->TestComplete(EWaitForSwitchOff2); - } - } - } - -// - -CPasswordWindow::CPasswordWindow(CPasswordTest *aTest) : - iTest(aTest) - { - } - -void CPasswordWindow::Draw() - { - iGc->Clear(); - switch(iTest->PasswordState()) - { - case EWaitForSwitchOff: - iGc->DrawText(_L("Please wait, turning off & on [1]"),TPoint(10,20)); - break; - case EWaitForSwitchOff2: - iGc->DrawText(_L("Please wait, turning off & on [2]"),TPoint(10,20)); - break; - case EWaitForSwitchOff3: - iGc->DrawText(_L("Please wait, turning off & on [3]"),TPoint(10,20)); - break; - case EWaitForSwitchOff4: - iGc->DrawText(_L("Please wait, turning off & on [4]"),TPoint(10,20)); - break; - case EWaitForSwitchOff5: - iGc->DrawText(_L("Please wait, turning off & on [5]"),TPoint(10,20)); - break; - case EWaitForEnter: - iGc->DrawText(_L("Try the key of death, then..."),TPoint(10,20)); - iGc->DrawText(_L("Press 'a', then..."),TPoint(10,40)); - iGc->DrawText(_L("Press Enter"),TPoint(10,60)); - break; - case EWaitForEnter2: - iGc->DrawText(_L("Press Enter"),TPoint(10,20)); - break; - case EWaitForA: - iGc->DrawText(_L("Press 'a'"),TPoint(10,20)); - case EPasswordFinished: - break; - default:; - } - } - -// - -CPasswordTest::CPasswordTest() : CTestBase(_L("Password")) - {} - -CPasswordTest::~CPasswordTest() - { - delete iBlankWin; - delete iPassWin; - delete iGroup; - delete iGroup2; - } - -#if defined(LOG_TESTS) -void CPasswordTest::Fail(TInt aWhere) -#else -void CPasswordTest::Fail(TInt /*aWhere*/) -#endif - { -#if defined(LOG_TESTS) - TLogMessageText buf; - _LIT(KFailed,"Password Failed at %d (%d,%d)"); - buf.AppendFormat(KFailed,aWhere,iState,iPassState); - Client()->LogMessage(buf); -#endif - iPasswordTestFailed=ETrue; - Request(); - } - -void CPasswordTest::TurnOffAndOn() - { -/*#if defined(LOG_TESTS) - TLogMessageText buf; - _LIT(KSettingTime,"Setting Off Timer"); - buf.Append(KSettingTime); - Client()->LogMessage(buf); -#endif*/ - RTimer timer; - timer.CreateLocal(); - TTime time; - time.HomeTime(); - time+=TTimeIntervalSeconds(7); // For some reason the O/S won't switch off for less than 6 seconds - TRequestStatus status; - timer.At(status,time); - UserHal::SwitchOff(); - User::WaitForRequest(status); -#if !defined(__WINS__) - TRawEvent event; - event.Set(TRawEvent::ESwitchOn); - UserSvr::AddEvent(event); -#endif -/*#if defined(LOG_TESTS) - TLogMessageText buf; - _LIT(KTimerOff,"Timer Gone Off (P=%d,S=%d)"); - buf.AppendFormat(KTimerOff,iState,iPassState); - Client()->LogMessage(buf); -#endif*/ - } - -TPasswordState CPasswordTest::PasswordState() const - { - return(iPassState); - } - -void CPasswordTest::SetPassState(TPasswordState aPassState) - { - iPassState=aPassState; - iPassWin->DrawNow(); - Client()->iWs.Flush(); -/*#if defined(LOG_TESTS) - TLogMessageText buf; - _LIT(PassTestState,"Password Test(%d), State=%d"); - buf.AppendFormat(PassTestState,iState,aPassState); - Client()->LogMessage(buf); -#endif*/ - switch(aPassState) - { - case EWaitForSwitchOff: - case EWaitForSwitchOff2: - case EWaitForSwitchOff3: - case EWaitForSwitchOff4: - case EWaitForSwitchOff5: - TurnOffAndOn(); - break; - default:; - } - } - -void CPasswordTest::SwitchOn() - { -/*#if defined(LOG_TESTS) - TLogMessageText buf; - _LIT(KTimerOff,"Switch On (P=%d,S=%d)"); - buf.AppendFormat(KTimerOff,iState,iPassState); - Client()->LogMessage(buf); -#endif*/ - switch (iPassState) - { - case EWaitForSwitchOff: - SetPassState(EWaitForEnter); - break; - case EWaitForSwitchOff2: - SetPassState(EWaitForSwitchOff3); - break; - case EWaitForSwitchOff3: - SetPassState(EWaitForSwitchOff4); - break; - case EWaitForSwitchOff4: - { - SetPassState(EWaitForSwitchOff5); - TTime time; - time.HomeTime(); - time+=TTimeIntervalHours(24); - User::SetHomeTime(time); - } - break; - case EWaitForSwitchOff5: - SetPassState(EWaitForEnter2); - break; - default:; - } - } - -void CPasswordTest::PasswordMsgReceivedL() - { - TestL(iPassWin->BaseWin()->OrdinalPosition()==0); - if (iPassState==EWaitForSwitchOff3 || iPassState==EWaitForSwitchOff4) - Fail(3); - } - -void CPasswordTest::EnterKeyPressed(TPasswordState aNewState) - { - iPassWin->BaseWin()->SetOrdinalPosition(-1); - SetPassState(aNewState); - Client()->iWs.PasswordEntered(); - } - -void CPasswordTest::TestComplete(TPasswordState aNewState) - { - Request(); - SetPassState(aNewState); - iPassState=aNewState; - } - -void CPasswordTest::ConstructL() - { - iGroup2=new(ELeave) CPasswordWindowGroup2(Client(),this); - iGroup2->ConstructL(); - iGroup=new(ELeave) CPasswordWindowGroup(Client(),this); - iGroup->ConstructL(); - iPassWin=new(ELeave) CPasswordWindow(this); - iPassWin->ConstructL(*iGroup); - iPassWin->AssignGC(*Client()->iGc); - iPassWin->Activate(); - iBlankWin=new(ELeave) CTBlankWindow(); - iBlankWin->ConstructL(*iGroup); - iBlankWin->SetVisible(EFalse); - iBlankWin->Activate(); - iState=ENotStarted; - } - -void CPasswordTest::StartMainPasswordTestL() - { - if (iPassWin->BaseWin()->PasswordWindow(EPasswordAlways)!=KErrNone) - { - DisplayDialog(_L("Can't do password tests"),_L("Password window"),_L("already exists"), Client()->iGroup->GroupWin()); - AbortL(); - } - SetPassState(EWaitForSwitchOff); - } - -void CPasswordTest::StartOnceADayPasswordTestL() - { - TestL(iPassWin->BaseWin()->PasswordWindow(EPasswordOnceADay)==KErrNone); - } - -TestState CPasswordTest::DoTestL() - { - if (iPasswordTestFailed) - TestL(ETrue); - switch(iState) - { - case 0: - LogSubTest(_L("Password 1"),1); - StartMainPasswordTestL(); - iState++; - return(EContinue); - case 1: - LogSubTest(_L("Password 2"),2); - StartOnceADayPasswordTestL(); - iState++; - return(EContinue); - default: - return(EFinished); - } - } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tman/TTEXT.CPP --- a/windowing/windowserver/tman/TTEXT.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,265 +0,0 @@ -// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Print some text, to be checked by eye -// -// - -#include -#include -#include "W32STD.H" -#include "../tlib/testbase.h" -#include "TMAN.H" - -class TTextTest; - -enum {EDrawModeFonts,EDrawModeCharJust,EDrawModeWordJust}; - -_LIT(KTestFontTypefaceName,"DejaVu Sans Condensed"); - -class CTextWindow : public CTWin - { -public: - CTextWindow(TTextTest *aTest); - void SetUpLD(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc); - void Draw(); - void WinKeyL(const TKeyEvent &aKey,const TTime &aTime); - void ResetPrintLine(); - void Print(const CFont *aFont, const TDesC &aText); - void PrintLine(const CFont *aFont, const TDesC &aText); - void PrintDivider(); - void PrintStylesL(const TDesC &aText, TFontSpec &aFontSpec, const TFontStyle &aFontStyle); - void DrawCharJustified(const TDesC &aText); - void DrawWordJustified(const TDesC &aText); - TBool NextPage(); - void SetDrawMode(TInt aMode); -private: - TInt iDrawMode; - TTextTest *iTest; - CFbsFont *iTmpFont; - TInt iNumTypeFaces; - TInt iTypeFaceIndex; - TInt iXStartPos; - TInt iYpos; - TInt iXpos; - }; - -class TTextTest : public CTestBase - { -public: - TTextTest(); - ~TTextTest(); - TestState DoTestL(); - void ConstructL(); -private: - CTextWindow *iWin; - TSize iWinSize; - TInt iState; - }; - -GLDEF_C CTestBase *CreateTextTest() - { - return(new(ELeave) TTextTest()); - } - -CTextWindow::CTextWindow(TTextTest *aTest) : CTWin(), iDrawMode(EDrawModeWordJust), iTest(aTest) - {} - -void CTextWindow::SetUpLD(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc) - { - ConstructExtLD(*parent,pos,size); - Activate(); - AssignGC(aGc); - iNumTypeFaces=Client()->iScreen->NumTypefaces(); - } - -void CTextWindow::ResetPrintLine() - { - iXpos=iXStartPos=5; - iYpos=2; - } - -void CTextWindow::PrintDivider() - { - iGc->DrawLine(TPoint(0,iYpos+5),TPoint(Size().iWidth,iYpos+5)); - iYpos+=10; - } - -void CTextWindow::Print(const CFont *aFont, const TDesC &aText) - { - iGc->DrawText(aText, TPoint(iXpos, iYpos+aFont->AscentInPixels())); - iXpos+=aFont->TextWidthInPixels(aText); - } - -void CTextWindow::PrintLine(const CFont *aFont, const TDesC &aText) - { - iGc->DrawText(aText, TPoint(iXpos, iYpos+aFont->AscentInPixels())); - iXpos=iXStartPos; - iYpos+=aFont->HeightInPixels()+2; - } - -TBool CTextWindow::NextPage() - { - if (iTypeFaceIndex==(iNumTypeFaces-1)) - return(ETrue); - ++iTypeFaceIndex; - return(EFalse); - } - -void CTextWindow::PrintStylesL(const TDesC &aText, TFontSpec &aFontSpec, const TFontStyle &aFontStyle) - { - aFontSpec.iFontStyle=aFontStyle; - User::LeaveIfError(Client()->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)iTmpFont, aFontSpec)); - iGc->UseFont(iTmpFont); - Print(iTmpFont,aText); - iGc->SetUnderlineStyle(EUnderlineOn); - Print(iTmpFont,_L("Underline, ")); - iGc->SetStrikethroughStyle(EStrikethroughOn); - Print(iTmpFont,_L("Strikethrough/underline, ")); - iGc->SetUnderlineStyle(EUnderlineOff); - PrintLine(iTmpFont,_L("Strikethrough")); - iGc->SetStrikethroughStyle(EStrikethroughOff); - Client()->iScreen->ReleaseFont(iTmpFont); - iTmpFont=NULL; - } - -void CTextWindow::DrawCharJustified(const TDesC &aText) - { - iGc->SetCharJustification(Size().iWidth-10-iTmpFont->TextWidthInPixels(aText),aText.Length()-1); - PrintLine(iTmpFont, aText); - } - -void CTextWindow::DrawWordJustified(const TDesC &aText) - { - TInt count=0; - for(TInt index=0;indexSetWordJustification(Size().iWidth-10-iTmpFont->TextWidthInPixels(aText),count); - PrintLine(iTmpFont, aText); - } - -void CTextWindow::Draw() -//This function is virtual and so cannot have an 'L' at the end of it's name - { - iGc->Clear(); - ResetPrintLine(); - switch(iDrawMode) - { - case EDrawModeWordJust: - User::LeaveIfError(Client()->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)iTmpFont, TFontSpec(KTestFontTypefaceName,200))); - iGc->UseFont(iTmpFont); - DrawWordJustified(_L("Hello World")); - DrawWordJustified(_L("One Two Three Four Five Six Seven")); - DrawWordJustified(_L("AA B CC D")); - DrawWordJustified(_L("ONEWORD")); - iGc->DiscardFont(); - Client()->iScreen->ReleaseFont(iTmpFont); - iTmpFont=NULL; - break; - case EDrawModeCharJust: - User::LeaveIfError(Client()->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)iTmpFont, TFontSpec(KTestFontTypefaceName,200))); - iGc->UseFont(iTmpFont); - DrawCharJustified(_L("Hello World")); - DrawCharJustified(_L("One Two Three Four Five Six Seven")); - DrawCharJustified(_L("AA B CC D")); - DrawCharJustified(_L("ONEWORD")); - iGc->DiscardFont(); - Client()->iScreen->ReleaseFont(iTmpFont); - iTmpFont=NULL; - break; - case EDrawModeFonts: - { - TTypefaceSupport typefaceSupport; - Client()->iScreen->TypefaceSupport(typefaceSupport,iTypeFaceIndex); - TBuf<0x40> title; - TBuf16 tmpBuf; - tmpBuf.Copy(typefaceSupport.iTypeface.iName); - title.Append(tmpBuf); - title.AppendFormat(TRefByValue(_L(", Heights (Min=%d, Max=%d, Num=%d)")),typefaceSupport.iMinHeightInTwips,typefaceSupport.iMaxHeightInTwips,typefaceSupport.iNumHeights); - PrintLine(iFont,title); - PrintDivider(); - for (TInt tfHeight=0;tfHeightiScreen->FontHeightInTwips(iTypeFaceIndex,tfHeight)); - PrintStylesL(_L("Normal, "), fspec, TFontStyle()); - PrintStylesL(_L("Bold, "), fspec, TFontStyle(EPostureUpright,EStrokeWeightBold,EPrintPosNormal)); - PrintStylesL(_L("Italic, "), fspec, TFontStyle(EPostureItalic,EStrokeWeightNormal,EPrintPosNormal)); - PrintStylesL(_L("Bold/italic, "), fspec, TFontStyle(EPostureItalic,EStrokeWeightBold,EPrintPosNormal)); - if (iYpos>Size().iHeight) - break; - } - } - break; - } - } - -void CTextWindow::WinKeyL(const TKeyEvent &aKey,const TTime &) - { - if (iDrawMode!=EDrawModeFonts || (aKey.iCode==EKeyEscape || NextPage())) - CActiveScheduler::Stop(); - else - iWin.Invalidate(); - } - -void CTextWindow::SetDrawMode(TInt aDrawMode) - { - iDrawMode=aDrawMode; - iWin.Invalidate(); - } - -TTextTest::TTextTest() : CTestBase(_L("Text")) - {} - -TTextTest::~TTextTest() - { - CTWin::Delete(iWin); - } - -void TTextTest::ConstructL() - { - CTextWindow *win=new(ELeave) CTextWindow(this); - win->SetUpLD(TPoint(0,0),Client()->iScreen->SizeInPixels(),Client()->iGroup,*Client()->iGc); - iWin=win; - Client()->iGroup->SetCurrentWindow(iWin); - Client()->iGroup->GroupWin()->SetOrdinalPosition(0); - } - -TestState TTextTest::DoTestL() - { - switch(iState) - { - case 0: - LogSubTest(_L("SetWordJustification"),1); - iWin->SetDrawMode(EDrawModeWordJust); - CActiveScheduler::Start(); - iState++; - break; - case 1: - LogSubTest(_L("SetCharJustification"),2); - iWin->SetDrawMode(EDrawModeCharJust); - CActiveScheduler::Start(); - iState++; - break; - case 2: - LogSubTest(_L("Text 1"),3); - iWin->SetDrawMode(EDrawModeFonts); - CActiveScheduler::Start(); - iState++; - break; - default: - return(EFinished); - } - return(ENext); - } - diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tredir/proxy.cpp --- a/windowing/windowserver/tredir/proxy.cpp Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include -#include "redirector.h" - - -LOCAL_C const TImplementationProxy KImplementationTable[] = - { - IMPLEMENTATION_PROXY_ENTRY(CWsGcRedirector::EImplUid, CWsGcRedirector::NewL) - }; - -EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) - { - aTableCount = sizeof(KImplementationTable)/sizeof(TImplementationProxy); - return KImplementationTable; - } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tredir/redirector.cpp --- a/windowing/windowserver/tredir/redirector.cpp Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,374 +0,0 @@ -// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include "redirector.h" -#include -#include -#include -#include -#ifdef __WINS__ -#include "../debuglog/osbwin.h" -#endif - -const TInt KDefaultScreen = 0; - -const TUint8 KCmdQuery = 0; -const TUint8 KCmdSetGcFront = 1; -const TUint8 KCmdSetGcBack = 2; -const TUint8 KCmdResetGcFront = 3; -const TUint8 KCmdResetGcBack = 4; -const TUint8 KCmdSetBackObject = 5; -const TUint8 KCmdResetBackObject= 6; - -const TUint8 KRedirectorInfoSig = 0x7e; - -NONSHARABLE_STRUCT(TRedirectorInfo) - { - TUint8 iSignature; - TAny* iFrontBufferInterface; - TAny* iBackBufferInterface; - TAny* iScreenConfigInterface; - TInt iScreenBitmapHandle; - TInt iFlickerBitmapHandle; - TInt iUpdateCounter; - }; - -NONSHARABLE_STRUCT(TWsBackBuffer): public MWsBackBuffer - { -public: - TWsBackBuffer(CFbsBitmap* aBit,CFbsBitGc* aGc): iBit(aBit), iGc(aGc) - {} - virtual CFbsBitmap* GetBitmap() - {return iBit;} - virtual CFbsBitGc* GetBitGc() - {return iGc;} - virtual TInt SetBitGc(CFbsBitGc*) - {return KErrNotSupported;} - virtual TInt RedirectTo(MWsBackBuffer*) - {return KErrNotSupported;} - virtual void SetObserver(MWsFlickerFreeBufferObserver* /*aObserver*/) - {ASSERT(0);} - virtual MWsFlickerFreeBufferObserver* Observer() - { - ASSERT(0); - return NULL; - } - virtual CFbsBitGc* GetBitGcCurrent() - { - ASSERT(0); - return NULL; - } - -private: - CFbsBitmap* iBit; - CFbsBitGc* iGc; - }; - -// -CWsGcRedirector* CWsGcRedirector::NewL() - { - return new(ELeave) CWsGcRedirector; - } - -CWsGcRedirector::~CWsGcRedirector() - { -#ifdef __WINS__ - delete iFrontWin; - delete iBackWin; - delete iUpdateDebugWinsTimer; -#endif - - if (iFrontBuf) - iFrontBuf->SetBitGc(NULL); - if (iBackBuf) - iBackBuf->SetBitGc(NULL); - - delete iFrontGc; - delete iFrontDev; - delete iFrontBit; - delete iBackGc; - delete iBackDev; - delete iBackBit; - delete iBadGc; - delete iBackObj; - } - -void CWsGcRedirector::ConstructL(MWsGraphicDrawerEnvironment& aEnv, const TGraphicDrawerId& aId, MWsClient& aOwner, const TDesC8& aData) - { - BaseConstructL(aEnv, aId, aOwner); - -#ifdef __WINS__ - if (aData.Length()>1) - iDisableWin = aData[1]==1; -#endif - iScreenId = KDefaultScreen; - if (aData.Length()>0) - iScreenId = aData[0]; - MWsScreen* scr = aEnv.Screen(iScreenId); - User::LeaveIfNull(scr); - - MWsScreenConfig* cfg = scr->ObjectInterface(); - User::LeaveIfNull(cfg); - - iFrontBuf = scr->ObjectInterface(); - User::LeaveIfNull(iFrontBuf); - iBackBuf = scr->ObjectInterface(); - - iFrontBit = new(ELeave) CFbsBitmap; - iDefaultSize=cfg->SizeInPixels(); - User::LeaveIfError(iFrontBit->Create(iDefaultSize,EColor64K)); - iFrontDev = CFbsBitmapDevice::NewL(iFrontBit); - User::LeaveIfNull(iFrontDev); - User::LeaveIfError(iFrontDev->CreateContext(iFrontGc)); - - User::LeaveIfError(iFrontDev->CreateContext(iBadGc)); - iBadGc->ChangeDevice(NULL); - -#ifdef __WINS__ - if (!iDisableWin) - { - iUpdateDebugWinsTimer = CPeriodic::NewL(0); - iUpdateDebugWinsTimer->Start(0, 300 * 1000, TCallBack(UpdateDebugWindowsCallback, this)); - - _LIT(KRedFront, "RedFront"); - iFrontWin = CDebugOsbWin::NewL(KRedFront, iFrontBit->SizeInPixels()); - } -#endif - - if (iBackBuf) - { - CFbsBitmap* bit = iBackBuf->GetBitmap(); - User::LeaveIfNull(bit); - iBackBit = new(ELeave) CFbsBitmap; - User::LeaveIfError(iBackBit->Create(bit->SizeInPixels(),EColor64K)); - iBackDev = CFbsBitmapDevice::NewL(iBackBit); - User::LeaveIfNull(iBackDev); - User::LeaveIfError(iBackDev->CreateContext(iBackGc)); - - iBackObj = new(ELeave) TWsBackBuffer(iBackBit,iBackGc); -#ifdef __WINS__ - if (!iDisableWin) - { - _LIT(KRedBack, "RedBack"); - iBackWin = CDebugOsbWin::NewL(KRedBack, iBackBit->SizeInPixels()); - } -#endif - } - - // compile check, non-const interface access - MWsGraphicDrawerEnvironment& ee = Env(); - MWsScreen* ss = ee.Screen(iScreenId); - MWsScreenConfig* cc = ss->ObjectInterface(); - } - -void CWsGcRedirector::HandleMessage(const TDesC8& aData) - { - // wserv already check data size, and won't invoke this handler if it's empty - TBuf8<1> ack; - ack.Append(KRedirectorInfoSig); - - switch (aData[0]) - { - case KCmdQuery: - SendInfo(); - break; - - case KCmdSetGcFront: - Env().RegisterEventHandler(this,this,TWservCrEvent::EScreenUpdated|TWservCrEvent::EScreenOrientationChanged|TWservCrEvent::EDeviceOrientationChanged); - - // -test bad gc - __ASSERT_ALWAYS(iFrontBuf->SetBitGc(iBadGc)==KErrArgument, User::Invariant()); - // -test bad gc - __ASSERT_ALWAYS(iFrontBuf->SetBitGc(iBadGc,ETrue)==KErrArgument, User::Invariant()); - // +test - __ASSERT_ALWAYS(iFrontBuf->SetBitGc(iFrontGc,EFalse)==KErrNone, User::Invariant()); - // -test duplicate calls - __ASSERT_ALWAYS(iFrontBuf->SetBitGc(iFrontGc)==KErrAlreadyExists, User::Invariant()); - - SendMessage(ack); - break; - - case KCmdSetGcBack: - if (iBackBuf) - { - // -test bad gc - __ASSERT_ALWAYS(iBackBuf->SetBitGc(iBadGc)==KErrArgument, User::Invariant()); - // +test - __ASSERT_ALWAYS(iBackBuf->SetBitGc(iBackGc)==KErrNone, User::Invariant()); - // -test duplicate calls - __ASSERT_ALWAYS(iBackBuf->SetBitGc(iBackGc)==KErrAlreadyExists, User::Invariant()); - // -test double redirection - __ASSERT_ALWAYS(iBackBuf->RedirectTo(iBackObj)==KErrInUse, User::Invariant()); - } - SendMessage(ack); - break; - - case KCmdResetGcFront: - Env().UnregisterEventHandler(this); - iUpdateCounter = 0; - - __ASSERT_ALWAYS(iFrontBuf->SetBitGc(NULL,EFalse)==KErrNone, User::Invariant()); - // -test duplicate calls - __ASSERT_ALWAYS(iFrontBuf->SetBitGc(NULL,EFalse)==KErrNone, User::Invariant()); - SendMessage(ack); - break; - - case KCmdResetGcBack: - if (iBackBuf) - { - // +test - __ASSERT_ALWAYS(iBackBuf->SetBitGc(NULL)==KErrNone, User::Invariant()); - // -test duplicate calls - __ASSERT_ALWAYS(iBackBuf->SetBitGc(NULL)==KErrNone, User::Invariant()); - } - SendMessage(ack); - break; - - case KCmdSetBackObject: - if (iBackBuf) - { - TWsBackBuffer badObj1(NULL,iBackGc); - // -test bad obj (null bitmap) - __ASSERT_ALWAYS(iBackBuf->RedirectTo(&badObj1)==KErrArgument, User::Invariant()); - // -test bad obj (null gc) - TWsBackBuffer badObj2(iBackBit,NULL); - __ASSERT_ALWAYS(iBackBuf->RedirectTo(&badObj2)==KErrArgument, User::Invariant()); - // -test bad obj (null device) - TWsBackBuffer badObj3(iBackBit,iBadGc); - __ASSERT_ALWAYS(iBackBuf->RedirectTo(&badObj3)==KErrArgument, User::Invariant()); - // +test - __ASSERT_ALWAYS(iBackBuf->RedirectTo(iBackObj)==KErrNone, User::Invariant()); - // -test duplicate calls - __ASSERT_ALWAYS(iBackBuf->RedirectTo(iBackObj)==KErrAlreadyExists, User::Invariant()); - // -test double redirection - __ASSERT_ALWAYS(iBackBuf->SetBitGc(iBackGc)==KErrInUse, User::Invariant()); - } - SendMessage(ack); - break; - - case KCmdResetBackObject: - if (iBackBuf) - { - // +test - __ASSERT_ALWAYS(iBackBuf->RedirectTo(NULL)==KErrNone, User::Invariant()); - // -test duplicate calls - __ASSERT_ALWAYS(iBackBuf->RedirectTo(NULL)==KErrNone, User::Invariant()); - } - SendMessage(ack); - break; - } - } - -void CWsGcRedirector::DoDraw(MWsGc& aGc, const TRect& aRect, const TDesC8& aData) const - { - aGc.PushBitGcSettings(); - CFbsBitGc& bc = aGc.BitGc(); - bc.SetBrushStyle(CGraphicsContext::ESolidBrush); - bc.SetBrushColor(TRgb(255,0,0,128)); - bc.DrawRect(aRect); - TGraphicDrawerId id; - id.iId = 0x10281fb6; - id.iIsUid = ETrue; - const CWsGraphicDrawer* listener = Env().ResolveGraphic(id); - if (listener) - listener->Draw(aGc, aRect, aData); - aGc.PopBitGcSettings(); - - // compile check, const interface access - const MWsGraphicDrawerEnvironment& env = Env(); // Env() const - const MWsScreen* scr = env.Screen(iScreenId); // Screen(TInt) const - const MWsScreenConfig* cfg = scr->ObjectInterface(); // ObjectInterface() const - } - -void CWsGcRedirector::SendInfo() - { - TPckgBuf buf; - MWsScreen* scr = Env().Screen(iScreenId); - if (scr) - { - buf().iSignature = KRedirectorInfoSig; - buf().iFrontBufferInterface = scr->ObjectInterface(); - buf().iBackBufferInterface = scr->ObjectInterface(); - buf().iScreenConfigInterface = scr->ObjectInterface(); - buf().iScreenBitmapHandle = iFrontBit->Handle(); - buf().iFlickerBitmapHandle = iBackBit? iBackBit->Handle() : 0; - buf().iUpdateCounter = iUpdateCounter; - } - TInt err = SendMessage(buf); - __ASSERT_ALWAYS(err>=KErrNone, User::Invariant()); - } - -void CWsGcRedirector::DoHandleEvent(const TWservCrEvent& aEvent) - { - if (aEvent.ScreenNumber()==iScreenId) - { - switch(aEvent.Type()) - { - case TWservCrEvent::EScreenUpdated: - ++iUpdateCounter; - break; - case TWservCrEvent::EDeviceOrientationChanged: - case TWservCrEvent::EScreenOrientationChanged: - { - CFbsBitGc::TGraphicsOrientation orientation=aEvent.Orientation(); - TSize bmpSize; - if (orientation==CFbsBitGc::EGraphicsOrientationNormal || orientation==CFbsBitGc::EGraphicsOrientationRotated180) - bmpSize=iDefaultSize; - else - bmpSize.SetSize(iDefaultSize.iHeight,iDefaultSize.iWidth); - const TSize fBufSize(iFrontBit->SizeInPixels()); - if (fBufSize!=bmpSize) - { - __ASSERT_DEBUG(fBufSize.iWidth==bmpSize.iHeight && fBufSize.iHeight==bmpSize.iWidth, User::Invariant()); - iFrontDev->SwapWidthAndHeight(); - iFrontGc->Activate(iFrontDev); - } - } - break; - } - } - } - -#ifdef __WINS__ -TInt CWsGcRedirector::UpdateDebugWindowsCallback(TAny* aSelf) - { - CWsGcRedirector* self = static_cast(aSelf); - if(!self) - return KErrArgument; - - if(self->iFrontWin && self->iFrontBit) - { - CFbsBitmap* bitmap = self->iFrontBit; - bitmap->LockHeap(); - self->iFrontWin->Refresh(bitmap->SizeInPixels(), bitmap->DisplayMode(), bitmap->DataAddress()); - bitmap->UnlockHeap(); - } - - if(self->iBackWin && self->iBackBit) - { - CFbsBitmap* bitmap = self->iBackBit; - bitmap->LockHeap(); - self->iBackWin->Refresh(bitmap->SizeInPixels(), bitmap->DisplayMode(), bitmap->DataAddress()); - bitmap->UnlockHeap(); - } - return KErrNone; - } -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tredir/redirector.h --- a/windowing/windowserver/tredir/redirector.h Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,81 +0,0 @@ -// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef __REDIRECTOR_H__ -#define __REDIRECTOR_H__ - -#include "Graphics/WSGRAPHICDRAWER.H" -#include - -class CFbsBitmap; -class CFbsBitmapDevice; -class CFbsBitGc; -#ifdef __WINS__ -class CDebugOsbWin; -#endif - -class TWsBackBuffer; - -NONSHARABLE_CLASS(CWsGcRedirector): public CWsGraphicDrawer, public MWsEventHandler - { -public: - enum {EImplUid = 0x10281e1e}; - -public: - static CWsGcRedirector* NewL(); - virtual ~CWsGcRedirector(); - - // override CWsGraphicDrawer - virtual void ConstructL(MWsGraphicDrawerEnvironment& aEnv,const TGraphicDrawerId& aId, MWsClient& aOwner, const TDesC8& aData); - virtual void HandleMessage(const TDesC8& aData); - virtual void DoHandleEvent(const TWservCrEvent& aEvent); -private: - // override CWsGraphicDrawer - virtual void DoDraw(MWsGc& aGc, const TRect& aRect, const TDesC8& aData) const; - void SendInfo(); - void OnScreenUpdated(); -#ifdef __WINS__ - static TInt UpdateDebugWindowsCallback(TAny* aSelf); -#endif - -private: - MWsFrontBuffer* iFrontBuf; - MWsBackBuffer* iBackBuf; - CFbsBitmap* iFrontBit; - CFbsBitmapDevice* iFrontDev; - CFbsBitGc* iFrontGc; - CFbsBitmap* iBackBit; - CFbsBitmapDevice* iBackDev; - CFbsBitGc* iBackGc; - CFbsBitGc* iBadGc; - TWsBackBuffer* iBackObj; -#ifdef __WINS__ - CDebugOsbWin* iFrontWin; - CDebugOsbWin* iBackWin; - CPeriodic* iUpdateDebugWinsTimer; - TBool iDisableWin; -#endif - TInt iScreenId; - TInt iUpdateCounter; - TSize iDefaultSize; - }; - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tredir/redirector.rss --- a/windowing/windowserver/tredir/redirector.rss Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include - -RESOURCE REGISTRY_INFO registry_info - { - dll_uid = 0x10281e1c; - interfaces = - { - INTERFACE_INFO - { - interface_uid = 0x10281e1d; - implementations = - { - IMPLEMENTATION_INFO - { - implementation_uid = 0x10281e1e; - version_no = 1; - display_name = "CWsGcRedirector"; - default_data = ""; - opaque_data = ""; - } - }; - } - }; - } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tredir/wsredir.cpp --- a/windowing/windowserver/tredir/wsredir.cpp Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,129 +0,0 @@ -// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include "wsredir.h" - -const TUint8 KCmdQuery = 0; -const TUint8 KCmdSetGcFront = 1; -const TUint8 KCmdSetGcBack = 2; -const TUint8 KCmdResetGcFront = 3; -const TUint8 KCmdResetGcBack = 4; -const TUint8 KCmdSetBackObject = 5; -const TUint8 KCmdResetBackObject= 6; - -const TUid KRedirectorInterfaceId = {0x10281e1d}; -const TUid KRedirectorImplId = {0x10281e1e}; - -EXPORT_C CWsRedir* CWsRedir::NewL() - { - return NewL(0); - } - -EXPORT_C CWsRedir* CWsRedir::NewL(TInt aScreenId) - { - return NewL(aScreenId, EFalse); - } - -EXPORT_C CWsRedir* CWsRedir::NewL(TInt aScreenId, TBool aDisableWin) - { - CWsRedir* self = new(ELeave) CWsRedir; - CleanupStack::PushL(self); - TBuf8<2> data; - data.Append((TUint8)aScreenId); - data.Append((TUint8)aDisableWin); - self->BaseConstructL(KRedirectorInterfaceId, KRedirectorImplId, data); - CleanupStack::Pop(self); - self->iIsReady = ETrue; - return self; - } - -EXPORT_C CWsRedir::~CWsRedir() - { - iIsReady = EFalse; - } - -void CWsRedir::HandleMessage(const TDesC8& aData) - { - if (aData.Size()>1 && aData[0]==KRedirectorInfoSig) - Mem::Copy(iReq, aData.Ptr(), aData.Size()); - iCallBack.CallBack(); - } - -void CWsRedir::OnReplace() - { - } - -EXPORT_C TInt CWsRedir::Redirect(TBufferType aWhich, TBool aHow) - { - if (!iIsReady) - return KErrNotReady; - - TBuf8<1> cmd; - if (aWhich==EFrontBuffer) - { - if (iIsFrontRedirected && aHow) - return KErrArgument; - iIsFrontRedirected = aHow; - cmd.Append(iIsFrontRedirected? KCmdSetGcFront : KCmdResetGcFront); - } - else - { - if (iIsBackRedirected && aHow) - return KErrArgument; - iIsBackRedirected = aHow; - cmd.Append(iIsBackRedirected? KCmdSetGcBack : KCmdResetGcBack); - } - - SendMessage(cmd); - return Flush(); - } - -EXPORT_C TInt CWsRedir::RedirectUsingWsBackBuffer(TBool aHow) - { - if (!iIsReady) - return KErrNotReady; - - TBuf8<1> cmd; - if (iIsBackRedirected && aHow) - return KErrArgument; - iIsBackRedirected = aHow; - cmd.Append(iIsBackRedirected? KCmdSetBackObject : KCmdResetBackObject); - - SendMessage(cmd); - return Flush(); - } - -EXPORT_C TInt CWsRedir::QueryPlugin(TRedirectorInfo& aInfo) - { - TBuf8<1> cmd; - cmd.Append(KCmdQuery); - SendMessage(cmd); - TInt err = Flush(); - if (err!=KErrNone) - return err; - iReq = &aInfo; - return KErrNone; - } - -EXPORT_C void CWsRedir::SetCallBack(TCallBack aCallBack) - { - iCallBack = aCallBack; - } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/tredir/wsredir.h --- a/windowing/windowserver/tredir/wsredir.h Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,69 +0,0 @@ -// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#ifndef __WSREDIR_H__ -#define __WSREDIR_H__ - -#include - -const TUint8 KRedirectorInfoSig = 0x7e; - -NONSHARABLE_STRUCT(TRedirectorInfo) - { - TUint8 iSignature; - TAny* iFrontBufferInterface; - TAny* iBackBufferInterface; - TAny* iScreenConfigInterface; - TInt iScreenBitmapHandle; - TInt iFlickerBitmapHandle; - TInt iUpdateCounter; - }; - -NONSHARABLE_CLASS(CWsRedir): public CWsGraphic - { -public: - enum TBufferType - { - EFrontBuffer, - EBackBuffer - }; -public: - IMPORT_C static CWsRedir* NewL(); - IMPORT_C static CWsRedir* NewL(TInt aScreenId); - IMPORT_C static CWsRedir* NewL(TInt aScreenId, TBool aDisableWin); - IMPORT_C ~CWsRedir(); - IMPORT_C TInt Redirect(TBufferType aWhich, TBool aHow); - IMPORT_C TInt RedirectUsingWsBackBuffer(TBool aHow); - IMPORT_C TInt QueryPlugin(TRedirectorInfo& aInfo); - IMPORT_C void SetCallBack(TCallBack aCallBack); -private: - // override CWsGraphic - virtual void HandleMessage(const TDesC8& aData); - virtual void OnReplace(); -private: - TBool iIsFrontRedirected; - TBool iIsBackRedirected; - TBool iIsReady; - TRedirectorInfo* iReq; - TCallBack iCallBack; - }; - -#endif diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/ttime/TTDRWBIT.CPP --- a/windowing/windowserver/ttime/TTDRWBIT.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,19 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// used for timing text printing -// -// - -#include "ttime.h" - diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/ttime/TTGENRAL.CPP --- a/windowing/windowserver/ttime/TTGENRAL.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,352 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// used for timing graphics -// -// - -#include "TTIME.H" - -#define TEST_ROM_BITMAP_NAME _L("Z:\\WSTEST\\TROM.MBM") - -enum TFuncType - { - ESimpleFlush, - ESpriteSetting, - EBitmapDevice, - ETrivialFunctions, - ELoadBitmap, - }; - -class TWsTest : public CBase - { -public: - void DoTestL(TInt aOwningGroup, TFuncType aFunc, TInt aParam1, TAny *aParam2); - void SimpleFlush(TInt aParam1, TAny *aParam2); - void SpriteSettingL(TInt aParam1, TAny *aParam2); - void BitmapDeviceL(TInt aParam, TAny *); - void TrivialFunctions(TInt aParam1, TAny *aParam2); - void LoadBitmapL(TInt aParam1, TAny *aParam2); -private: - void createSpriteBitmapL(CFbsBitmap *aBitmap, CFbsBitmapDevice *&aBitmapDevice, const TSize &aSize, TBool aDoMask); -private: - RWsSession iWs; - RWindowGroup iGroup; - RWindow iWindow; - CWsScreenDevice *iDevice; - CWindowGc *iGc; - }; - -TInt CreateWsTest(TInt aOwningGroup, TFuncType aFunc, TInt aParam1, TAny *aParam2) - { - TWsTest *iTest=NULL; - TRAPD(err,iTest=new(ELeave) TWsTest()); - if (err==KErrNone) - { - TRAP(err,iTest->DoTestL(aOwningGroup, aFunc, aParam1, aParam2)); - delete iTest; - } - return(err); - } - -void TWsTest::DoTestL(TInt aOwningGroup, TFuncType aFunc, TInt aParam1, TAny *aParam2) - { - iWs.Connect(); - iDevice=new(ELeave) CWsScreenDevice(iWs); - iDevice->Construct(); - iGroup=RWindowGroup(iWs); - iGroup.Construct(ENullWsHandle); - iGroup.SetOwningWindowGroup(aOwningGroup); -// - iWindow=RWindow(iWs); - iWindow.Construct(iGroup,ENullWsHandle); - iWindow.SetExtent(TPoint(), iDevice->SizeInPixels()); - iWindow.Activate(); -// - iDevice->CreateContext(iGc); - iWindow.BeginRedraw(); - iGc->Activate(iWindow); - iGc->Clear(); - iWindow.EndRedraw(); -// - switch(aFunc) - { - case ESimpleFlush: - SimpleFlush(aParam1, aParam2); - break; - case ESpriteSetting: - SpriteSettingL(aParam1, aParam2); - break; - case EBitmapDevice: - BitmapDeviceL(aParam1, aParam2); - break; - case ETrivialFunctions: - TrivialFunctions(aParam1, aParam2); - break; - case ELoadBitmap: - LoadBitmapL(aParam1, aParam2); - break; - default:; - } - delete iGc; - iWindow.Close(); - iGroup.Close(); - delete iDevice; - iWs.Close(); - } - -// Flush // - -void TWsTest::SimpleFlush(TInt aParam, TAny *) - { - TTimeIntervalMicroSeconds32 interval(100000); - TInt distance=10; - if (aParam==0) - { - TTimeIntervalMicroSeconds32 origInterval; - TInt origDistance; - iWs.GetDoubleClickSettings(origInterval,origDistance); - for(TInt nTimes=0;nTimes<5000-1;nTimes++) - { - iWs.SetDoubleClick(interval,distance); - iWs.Flush(); - } - iWs.SetDoubleClick(origInterval,origDistance); - } - else - { - for(TInt nTimes=0;nTimes<5000;nTimes++) - iWs.GetDoubleClickSettings(interval,distance); - } - } - -TInt SimpleFlushTestFunc(TInt aOwningGroup) - { - return(CreateWsTest(aOwningGroup, ESimpleFlush, 0, NULL)); - } - -TInt SimpleFlushTestFunc2(TInt aOwningGroup) - { - return(CreateWsTest(aOwningGroup, ESimpleFlush, 1, NULL)); - } - -GLDEF_D TTimeTestHeader SimpleFlushTest={_S("Simple Flush[1] x5000"),SimpleFlushTestFunc}; -GLDEF_D TTimeTestHeader SimpleFlushTest2={_S("Simple Flush[2] x5000"),SimpleFlushTestFunc2}; - -// IP Read/Write // - -#if 0 -TInt ReadWriteThreadFunc(TAny *aParams) - { - TWinCommand command; - RProcess().CommandLine(command); - TDesC8 *cmd=&command; - RThread thread; - thread.Open(_L("TimeTest")); - TAny *remotePtr=*(TAny **)aCmd->Ptr(); - TBuf<0x10> buf; - for(TInt count=0;count<100000;count++) - thread.ReadL(remotePtr,buf,0); - } - -void TWsTest::IPReadWriteL(TInt aParam, TAny *) - { - TBuf<0x10> srcData; - srcData.Append(_L("1234567890ABCDEF")); - RProcess process; - TWinCommand command; - *((TAny **)command.Ptr())=&srcData; - User::LeaveIfError(process.Create(_L("TimeThread1"),); - TRequestStatus status; - process.Logon(status); - process.Resume(); - User::WaitForRequest(status); - process.Close(); - } - -TInt SimpleFlushTestFunc(TInt aOwningGroup) - { - return(CreateWsTest(aOwningGroup, ESimpleFlush, 0, NULL)); - } - -TInt SimpleFlushTestFunc2(TInt aOwningGroup) - { - return(CreateWsTest(aOwningGroup, ESimpleFlush, 1, NULL)); - } - -GLDEF_D TTimeTestHeader SimpleFlushTest={_S("Simple Flush[1] x5000"),SimpleFlushTestFunc}; -GLDEF_D TTimeTestHeader SimpleFlushTest2={_S("Simple Flush[2] x5000"),SimpleFlushTestFunc2}; -#endif -// Bitmap device // - -void TWsTest::BitmapDeviceL(TInt aParam, TAny *) - { - CFbsBitmap *bitmap=new(ELeave) CFbsBitmap(); - User::LeaveIfError(bitmap->Create(TSize(10,10),EGray4)); - CFbsBitmapDevice *bitmapDevicePerm=NULL; - if (aParam==1) - bitmapDevicePerm=CFbsBitmapDevice::NewL(bitmap); - for(TInt nTimes=0;nTimes<100;nTimes++) - { - CFbsBitmapDevice *bitmapDevice=CFbsBitmapDevice::NewL(bitmap); - delete bitmapDevice; - } - delete bitmapDevicePerm; - delete bitmap; - } - -TInt BitmapDeviceTestFunc1(TInt aOwningGroup) - { - return(CreateWsTest(aOwningGroup, EBitmapDevice, 0, NULL)); - } - -TInt BitmapDeviceTestFunc2(TInt aOwningGroup) - { - return(CreateWsTest(aOwningGroup, EBitmapDevice, 1, NULL)); - } - -GLDEF_D TTimeTestHeader BitmapDeviceTest1={_S("Bitmap Device (reload)"),BitmapDeviceTestFunc1}; -GLDEF_D TTimeTestHeader BitmapDeviceTest2={_S("Bitmap Device "),BitmapDeviceTestFunc2}; - -// Sprite Setting // - -void TWsTest::createSpriteBitmapL(CFbsBitmap *aBitmap, CFbsBitmapDevice *&aBitmapDevice, const TSize &aSize, TBool aDoMask) - { - User::LeaveIfError(aBitmap->Create(aSize,EGray4)); - aBitmapDevice=CFbsBitmapDevice::NewL(aBitmap); - CFbsBitGc *gc=CFbsBitGc::NewL(); - gc->Activate(aBitmapDevice); - gc->SetBrushColor(TRgb::Gray4(aDoMask ? 0 : 2)); - gc->SetBrushStyle(CGraphicsContext::ESolidBrush); - gc->SetPenStyle(CGraphicsContext::ENullPen); - gc->DrawRect(TRect(aSize)); - gc->SetPenStyle(CGraphicsContext::ESolidPen); - gc->SetPenColor(TRgb::Gray4(aDoMask ? 3 : 0)); - gc->SetBrushColor(TRgb::Gray4(aDoMask ? 3 : 1)); - gc->DrawEllipse(TRect(aSize)); - delete gc; - } - -void TWsTest::SpriteSettingL(TInt , TAny *) - { - RWsSprite sprite; - TSize size(32,32); - sprite=RWsSprite(iWs); - CFbsBitmap *bitmap=new(ELeave) CFbsBitmap(); - CFbsBitmap *mask=new(ELeave) CFbsBitmap(); - CFbsBitmapDevice *bitmapDevice=NULL; //To stop warning - TRAPD(err,createSpriteBitmapL(bitmap,bitmapDevice,size,EFalse)); - delete bitmapDevice; - TRAP(err,createSpriteBitmapL(mask,bitmapDevice,size,ETrue)); - delete bitmapDevice; - TSpriteMember spriteData; - spriteData.iBitmap=bitmap; - spriteData.iMaskBitmap=mask; - spriteData.iInvertMask=EFalse; - spriteData.iInterval=TTimeIntervalMicroSeconds32(0); - User::LeaveIfError(sprite.Construct(iWindow,TPoint(0,0),0)); - User::LeaveIfError(sprite.AppendMember(spriteData)); - User::LeaveIfError(sprite.Activate()); - for(TInt i=0;i<500;i++) - sprite.SetPosition(TPoint(i&0x7f,i&0x7f)); - sprite.Close(); - delete mask; - delete bitmap; - } - -TInt SpriteSettingTestFunc(TInt aOwningGroup) - { - return(CreateWsTest(aOwningGroup, ESpriteSetting, 0, NULL)); - } - -GLDEF_D TTimeTestHeader SpriteTest={_S("Sprite Setting"),SpriteSettingTestFunc}; - -void TWsTest::TrivialFunctions(TInt , TAny *) - { - for(TInt i=0;i<100000;i++) - iWs.FreeSystemPointerCursorList(); - } - -TInt TrivialFunctionsTestFunc(TInt aOwningGroup) - { - return(CreateWsTest(aOwningGroup, ETrivialFunctions, 0, NULL)); - } - -GLDEF_D TTimeTestHeader TrivialFunctionsTest={_S("TrivialFunctions"),TrivialFunctionsTestFunc}; - -void TWsTest::LoadBitmapL(TInt aMode, TAny *) - { - if (aMode<2) - { - for(TInt count=0;count<10;count++) - { - if (aMode==0) - { - CFbsBitmap *bit=new(ELeave) CFbsBitmap(); - User::LeaveIfError(bit->Load(TEST_ROM_BITMAP_NAME,0)); - delete bit; - } - else - { - CWsBitmap *bit=new(ELeave) CWsBitmap(iWs); - User::LeaveIfError(bit->Load(TEST_ROM_BITMAP_NAME,0)); - delete bit; - } - } - } - else for(TInt count=0;count<100;count++) - { - //__PROFILE_START(1) - RFs fs; - User::LeaveIfError(fs.Connect()); - fs.SetNotifyUser(EFalse); - //__PROFILE_END(1) - //__PROFILE_START(2) - TParse parse; - User::LeaveIfError(fs.Parse(TEST_ROM_BITMAP_NAME,parse)); - //__PROFILE_END(2) - //__PROFILE_START(3) - TInt drive; - User::LeaveIfError(RFs::CharToDrive(parse.Drive()[0],drive)); - TDriveInfo driveinfo; - User::LeaveIfError(fs.Drive(driveinfo,drive)); - //__PROFILE_END(3) - //__PROFILE_START(4) - RFile tempfile; - User::LeaveIfError(tempfile.Open(fs,TEST_ROM_BITMAP_NAME,EFileShareAny)); - TInt aAddress; - tempfile.Seek(ESeekAddress,aAddress); - //__PROFILE_END(4) - //__PROFILE_START(5) - tempfile.Close(); - fs.Close(); - //__PROFILE_END(5) - } - } - -TInt LoadBitmapTestFunc(TInt aOwningGroup) - { - return(CreateWsTest(aOwningGroup, ELoadBitmap, 0, NULL)); - } -TInt LoadWsBitmapTestFunc(TInt aOwningGroup) - { - return(CreateWsTest(aOwningGroup, ELoadBitmap, 1, NULL)); - } -TInt LoadRomFileTestFunc(TInt aOwningGroup) - { - return(CreateWsTest(aOwningGroup, ELoadBitmap, 3, NULL)); - } - -GLDEF_D TTimeTestHeader BitmapLoadTest={_S("Load Bitmap"),LoadBitmapTestFunc}; -GLDEF_D TTimeTestHeader WsBitmapLoadTest={_S("Load WsBitmap"),LoadWsBitmapTestFunc}; -GLDEF_D TTimeTestHeader RomFileTest={_S("Rom File"),LoadRomFileTestFunc}; diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/ttime/TTGRAPH.CPP --- a/windowing/windowserver/ttime/TTGRAPH.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,443 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// used for timing graphics -// -// - -#include "TTIME.H" - -#define TEST_BITMAP_NAME _L("Z:\\WSTEST\\TEST.MBM") - -GLREF_C void Panic(TInt aPanic); - -enum TFuncType - { - EBitmapTest, - EXorTest, - ESmallClearTest, - ERectCompareTest, - EUseFontTest, - EBitBltTest, - EFullScreenBitBltTest, - EMaskedBitBltTest, - EFillPatternTest, - EBackupWindowDrawingTest, - }; - -class TGraphicsTest : public CBase - { -public: - void DoTestL(TInt aOwningGroup, TFuncType aFunc, TInt aParam1, TAny *aParam2); - void DrawBitmapTestL(TInt aParam1, TAny *aParam2); - void XorTest(TInt aParam1, TAny *aParam2); - void SmallClearTest(TInt , TAny *); - void RectCompareTest(TInt , TAny *); - void UseFontTestL(TInt , TAny *); - void BitBltTestL(TInt , TAny *); - void FullScreenBitBltTestL(TInt , TAny *); - void MaskedBitBltTestL(TInt , TAny *); - void FillPatternTestL(TInt , TAny *); - void BackedUpWindowDrawingL(TInt aMode, TAny *); -private: - RWsSession iWs; - CWsScreenDevice *iDevice; - RWindowGroup iGroup; - RWindow iWindow; - RBackedUpWindow iBackedUpWindow; - RDrawableWindow *iWindowPtr; - CWindowGc *iGc; - }; - -TInt CreateGraphicsTest(TInt aOwningGroup, TFuncType aFunc, TInt aParam1, TAny *aParam2) - { - TGraphicsTest *iTest=NULL; - TRAPD(err,iTest=new(ELeave) TGraphicsTest()); - if (err==KErrNone) - { - TRAP(err,iTest->DoTestL(aOwningGroup, aFunc, aParam1, aParam2)); - delete iTest; - } - return(err); - } - -void TGraphicsTest::DoTestL(TInt aOwningGroup, TFuncType aFunc, TInt aParam1, TAny *aParam2) - { - iWs.Connect(); - iDevice=new(ELeave) CWsScreenDevice(iWs); - iDevice->Construct(); - iGroup=RWindowGroup(iWs); - iGroup.Construct(ENullWsHandle); - iGroup.SetOwningWindowGroup(aOwningGroup); -// - if (aFunc==EBackupWindowDrawingTest) - { - iBackedUpWindow=RBackedUpWindow(iWs); - iWindowPtr=&iBackedUpWindow; - iBackedUpWindow.Construct(iGroup,EGray4,ENullWsHandle); - } - else - { - iWindow=RWindow(iWs); - iWindowPtr=&iWindow; - iWindow.Construct(iGroup,ENullWsHandle); - } - User::LeaveIfError(iWindowPtr->SetExtentErr(TPoint(), iDevice->SizeInPixels())); - iWindowPtr->Activate(); - // - iDevice->CreateContext(iGc); - iGc->Activate(*iWindowPtr); - if (iWindowPtr==&iWindow) - { - iWindow.BeginRedraw(); - iGc->Clear(); - iWindow.EndRedraw(); - } - switch(aFunc) - { - case EBitmapTest: - DrawBitmapTestL(aParam1, aParam2); - break; - case EXorTest: - XorTest(aParam1, aParam2); - break; - case ESmallClearTest: - SmallClearTest(aParam1, aParam2); - break; - case ERectCompareTest: - RectCompareTest(aParam1, aParam2); - break; - case EUseFontTest: - UseFontTestL(aParam1, aParam2); - break; - case EBitBltTest: - BitBltTestL(aParam1, aParam2); - break; - case EFullScreenBitBltTest: - FullScreenBitBltTestL(aParam1, aParam2); - break; - case EMaskedBitBltTest: - MaskedBitBltTestL(aParam1, aParam2); - break; - case EFillPatternTest: - FillPatternTestL(aParam1, aParam2); - break; - case EBackupWindowDrawingTest: - BackedUpWindowDrawingL(aParam1, aParam2); - break; - default:; - } -// - delete iGc; - iWindowPtr->Close(); - iGroup.Close(); - delete iDevice; - iWs.Close(); - } - -// Draw bitmap // - -void TGraphicsTest::DrawBitmapTestL(TInt , TAny *) - { - CFbsBitmap *bitmap=new(ELeave) CFbsBitmap; - User::LeaveIfError(bitmap->Load(TEST_BITMAP_NAME,0)); - for(TInt nTimes=0;nTimes<10;nTimes++) - { - iGc->Clear(); - TSize size(iDevice->SizeInPixels()); - iGc->DrawBitmap(TRect(-size.iWidth,-size.iHeight,size.iWidth<<1,size.iHeight<<1),bitmap); - iWs.Flush(); - } - delete bitmap; - } - -TInt DrawBitmapTestFunc(TInt aOwningGroup) - { - return(CreateGraphicsTest(aOwningGroup, EBitmapTest, 0, NULL)); - } - -GLDEF_D TTimeTestHeader DrawBitmapTest={_S("Draw bitmap"),DrawBitmapTestFunc}; - -// XOR Test // - -void TGraphicsTest::XorTest(TInt , TAny *) - { - iGc->SetDrawMode(CGraphicsContext::EDrawModeXOR); - iGc->SetBrushColor(TRgb::Gray256(255)); - iGc->SetPenStyle(CGraphicsContext::ENullPen); - iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - for(TInt count=0;count<10;count++) - { - for(TInt wid=1;wid<320;wid+=3) - { - iGc->DrawRect(TRect(10,10,10+wid,150)); - // iWs.Flush(); - } - } - } - -TInt XorIngTestFunc(TInt aOwningGroup) - { - return(CreateGraphicsTest(aOwningGroup, EXorTest, 0, NULL)); - } - -GLDEF_D TTimeTestHeader XorIngTest={_S("Xor'ing"),XorIngTestFunc}; - -// XOR Test // - -void TGraphicsTest::SmallClearTest(TInt , TAny *) - { - iGc->SetBrushColor(TRgb::Gray256(255)); - iGc->SetPenStyle(CGraphicsContext::ENullPen); - iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - for(TInt count=0;count<500;count++) - { - for(TInt wid=1;wid<30;wid++) - { - iGc->DrawRect(TRect(1,0,10+wid,100)); -// iWs.Flush(); - } - } - } - -TInt SmallClearTestFunc(TInt aOwningGroup) - { - return(CreateGraphicsTest(aOwningGroup, ESmallClearTest, 0, NULL)); - } - -GLDEF_D TTimeTestHeader SmallClearTest={_S("Small clear rect"),SmallClearTestFunc}; - -// XOR Test // - -enum {EMaxWidth=100}; - -void TGraphicsTest::RectCompareTest(TInt , TAny *) - { - TSize size(iDevice->SizeInPixels()); - for(TInt count=0;count<10;count++) - iDevice->RectCompare(TRect(0,0,size.iWidth>>1,size.iHeight),TRect(size.iWidth>>1,0,size.iWidth,size.iHeight)); - } - -TInt RectCompareTestFunc(TInt aOwningGroup) - { - return(CreateGraphicsTest(aOwningGroup, ERectCompareTest, 0, NULL)); - } - -GLDEF_D TTimeTestHeader RectCompareTest={_S("RectCompare"),RectCompareTestFunc}; - -// Use Font // - -void TGraphicsTest::UseFontTestL(TInt , TAny *) - { - CFbsFont *font; - TFontSpec fspec(KTestFontTypefaceName,200); - User::LeaveIfError(iDevice->GetNearestFontToDesignHeightInTwips((CFont *&)font, fspec)); - for(TInt count=0;count<1000;count++) - iGc->UseFont(font); - iDevice->ReleaseFont(font); - } - -TInt UseFontTestFunc(TInt aOwningGroup) - { - return(CreateGraphicsTest(aOwningGroup, EUseFontTest, 0, NULL)); - } - -GLDEF_D TTimeTestHeader UseFontTest={_S("UseFont(x1000)"),UseFontTestFunc}; - -// Small BitBlt // - -void TGraphicsTest::BitBltTestL(TInt , TAny *) - { - CWsBitmap *bitmap=new(ELeave) CWsBitmap(iWs); - TSize size(25,50); - bitmap->Create(size,EGray4); - CFbsDevice *bitmapDevice=CFbsBitmapDevice::NewL(bitmap); - CFbsBitGc *gc=CFbsBitGc::NewL(); - gc->Activate(bitmapDevice); - gc->DrawEllipse(TRect(size)); - delete gc; - delete bitmapDevice; - for(TInt count=0;count<10;count++) - { - iGc->Clear(); - TPoint pos(0,0); - for(TInt xcount=0;xcount<25;xcount++,pos.iX+=size.iWidth) - { - pos.iY=0; - for(TInt ycount=0;ycount<4;ycount++,pos.iY+=size.iHeight) - iGc->BitBlt(pos,bitmap); - } - } - delete bitmap; - } - -TInt BitBltTestFunc(TInt aOwningGroup) - { - return(CreateGraphicsTest(aOwningGroup, EBitBltTest, 0, NULL)); - } - -GLDEF_D TTimeTestHeader BitBltTest={_S("BitBlt"),BitBltTestFunc}; - -// Full Screen BitBlt // - -void TGraphicsTest::FullScreenBitBltTestL(TInt , TAny *) - { - CWsBitmap *bitmap=new(ELeave) CWsBitmap(iWs); - TSize size(640,240); - User::LeaveIfError(bitmap->Create(size,EGray4)); - CFbsDevice *bitmapDevice=CFbsBitmapDevice::NewL(bitmap); - CFbsBitGc *gc=CFbsBitGc::NewL(); - gc->Activate(bitmapDevice); - for(TInt pos=0;posDrawRect(TRect(pos,0,pos+16,size.iHeight)); - iGc->BitBlt(TPoint(0,0),bitmap); - iWs.Flush(); - } - delete gc; - delete bitmapDevice; - delete bitmap; - } - -TInt FullScreenBitBltTestFunc(TInt aOwningGroup) - { - return(CreateGraphicsTest(aOwningGroup, EFullScreenBitBltTest, 0, NULL)); - } - -GLDEF_D TTimeTestHeader FullScreenBitBltTest={_S("FullScreenBitBlt"),FullScreenBitBltTestFunc}; - -// Masked BitBlt // - -void TGraphicsTest::MaskedBitBltTestL(TInt , TAny *) - { - TSize size(24,48); - CWsBitmap *bitmap=new(ELeave) CWsBitmap(iWs); - bitmap->Create(size,EGray4); - CFbsDevice *bitmapDevice=CFbsBitmapDevice::NewL(bitmap); - CFbsBitGc *gc=CFbsBitGc::NewL(); - gc->Activate(bitmapDevice); - gc->DrawEllipse(TRect(size)); - delete bitmapDevice; -// Now do the mask - CWsBitmap *mask=new(ELeave) CWsBitmap(iWs); - mask->Create(size,EGray4); - bitmapDevice=CFbsBitmapDevice::NewL(mask); - gc->Activate(bitmapDevice); - gc->SetPenColor(TRgb::Gray4(3)); - gc->DrawEllipse(TRect(size)); - delete bitmapDevice; -// - delete gc; - for(TInt count=0;count<10;count++) - { - iGc->Clear(); - TPoint pos(0,0); - for(TInt xcount=0;xcount<25;xcount++,pos.iX+=size.iWidth+1) - { - pos.iY=0; - for(TInt ycount=0;ycount<4;ycount++,pos.iY+=size.iHeight) - iGc->BitBltMasked(pos,bitmap,TRect(size),mask,EFalse); - } - } - delete bitmap; - delete mask; - } - -TInt MaskedBitBltTestFunc(TInt aOwningGroup) - { - return(CreateGraphicsTest(aOwningGroup, EMaskedBitBltTest, 0, NULL)); - } - -GLDEF_D TTimeTestHeader MaskedBitBltTest={_S("MaskedBitBlt"),MaskedBitBltTestFunc}; - -// Fill Pattern // - -void TGraphicsTest::FillPatternTestL(TInt , TAny *) - { - TSize scrSize(iDevice->SizeInPixels()); - TSize rectSize(scrSize.iWidth/5-1,scrSize.iHeight/2); - - CWsBitmap *bitmap=new(ELeave) CWsBitmap(iWs); - - TSize bitmapSize(50,40); - bitmap->Create(bitmapSize,EGray4); - CFbsDevice *bitmapDevice=CFbsBitmapDevice::NewL(bitmap); - CFbsBitGc *gc=CFbsBitGc::NewL(); - gc->Activate(bitmapDevice); - gc->SetBrushColor(TRgb::Gray4(2)); - gc->SetBrushStyle(CGraphicsContext::ESolidBrush); - gc->DrawEllipse(TRect(bitmapSize)); - delete bitmapDevice; - delete gc; -// - iGc->UseBrushPattern(bitmap); - iGc->SetBrushStyle(CGraphicsContext::EPatternedBrush); - iGc->SetPenStyle(CGraphicsContext::ESolidPen); - for(TInt count=0;count<50;count++) - { - iGc->Clear(); - TPoint pos(0,0); - for(TInt xcount=0;xcount<5;xcount++,pos.iX+=rectSize.iWidth) - { - pos.iY=0; - for(TInt ycount=0;ycount<2;ycount++,pos.iY+=rectSize.iHeight) - iGc->DrawRect(TRect(pos,rectSize)); - } - } - delete bitmap; - } - -TInt FillPatternTestFunc(TInt aOwningGroup) - { - return(CreateGraphicsTest(aOwningGroup, EFillPatternTest, 0, NULL)); - } - -GLDEF_D TTimeTestHeader FillPatternTest={_S("FillPattern"),FillPatternTestFunc}; - -// Backup Window Drawing // - -void TGraphicsTest::BackedUpWindowDrawingL(TInt aMode, TAny *) - { - TSize scrSize(iDevice->SizeInPixels()); - CFbsFont *font=NULL; - if (aMode==1) - { - TFontSpec fspec(KTestFontTypefaceName,200); - User::LeaveIfError(iDevice->GetNearestFontToDesignHeightInTwips((CFont *&)font, fspec)); - iGc->UseFont(font); - } - iGc->SetPenStyle(CGraphicsContext::ESolidPen); - TPoint pos; - for(TInt count=0;count<10;count++) - { - iGc->Clear(); - for(pos.iY=0;pos.iYDrawLine(pos,pos+TSize(scrSize.iWidth,0)); - } - if (aMode==1) - iDevice->ReleaseFont(font); - } - -TInt BackupWindowDrawingFunc1(TInt aOwningGroup) - { - return(CreateGraphicsTest(aOwningGroup, EBackupWindowDrawingTest, 0, NULL)); - } - -GLDEF_D TTimeTestHeader BackupWindowDrawingCreate1={_S("BackupWindowDrawing 1"),BackupWindowDrawingFunc1}; - -TInt BackupWindowDrawingFunc2(TInt aOwningGroup) - { - return(CreateGraphicsTest(aOwningGroup, EBackupWindowDrawingTest, 1, NULL)); - } - -GLDEF_D TTimeTestHeader BackupWindowDrawingCreate2={_S("BackupWindowDrawing 2"),BackupWindowDrawingFunc2}; diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/ttime/TTIME.CPP --- a/windowing/windowserver/ttime/TTIME.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,554 +0,0 @@ -// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Functions to act as bench marks for various window server features -// -// - -#include "TTIME.H" -#include -#include -typedef TBuf<32> TestNameBuf; - -LOCAL_D const TUint KHeapSize=0x10000; - -class CTimeClient; - -class CResultDialog : public CTDialog - { -public: - CResultDialog(CTWindowGroup *aGroupWin,CWindowGc *aGc); - void ButtonPressL(TInt aButton); - void ConstructLD(); -private: - CTWindowGroup *iGroupWin; - CWindowGc *iGc; - }; - -class CListWindow : public CTTitledWindow - { -public: - CListWindow(); - void CloseWindow(); - void ConstructL(CTWinBase &parent, TBool aExitOnEscape); - void Draw(); - virtual void SelectedL(TInt aIndex)=0; - virtual void WinKeyL(const TKeyEvent &aKey,const TTime& aTime); - void SetExt(const TPoint &aPos, const TSize &aSize); - void SetSize(const TSize &); -protected: - virtual TPtrC GetText(TInt aLine)=0; - virtual TInt ListCount()=0; - void SetSize(); -private: - void Resized(const TSize &aSize); - void SetListPos(TInt aNewPos); - TInt TextRowHeight() const; - void RowBox(TRect &aRect, TInt aRow) const; - void PointerL(const TPointerEvent &aPointer,const TTime& aTime); -private: - TInt iListPos; - TTime iPrevTime; - TBool iExitOnEscape; - }; - -class CTestList : public CListWindow - { -public: - CTestList(); - ~CTestList(); - void ConstructL(CTWinBase &parent); - static void AppendProfileNum(TDes &aDes, TInt aNum); - static void AppendProfileCount(TDes &aDes, TInt aNum); - void SelectedL(TInt aIndex); - virtual void WinKeyL(const TKeyEvent &aKey,const TTime& aTime); - void ForegroundAppDialog(); - void AppendToListL(const TDesC &aDesc); -private: - virtual TPtrC GetText(TInt aLine); - virtual TInt ListCount(); -private: - TInt iCount; - CArrayFixSeg iTestNames; - RThread iTimeTest; - }; - -class CTimeTestWindowGroup : public CTWindowGroup - { -public: - CTimeTestWindowGroup(CTClient *aClient); - void KeyL(const TKeyEvent &aKey,const TTime &aTime); - }; - -class CTimeClient : public CTClient - { -public: - CTimeClient(); - void ConstructL(); - void KeyL(const TKeyEvent &aKey,const TTime &aTime); - void Exit(); - CTWin *CreateTestWindowL(TPoint pos,CTWinBase *parent); -private: - TInt iNum; - }; - -const TInt Xmove=8; -const TInt Ymove=6; - -GLREF_D TTimeTestHeader MovingWindowTest1; -GLREF_D TTimeTestHeader MovingWindowTest2; -GLREF_D TTimeTestHeader StackedWindowCreate; -GLREF_D TTimeTestHeader WindowCreateDestroy; -GLREF_D TTimeTestHeader LoadsaText; -GLREF_D TTimeTestHeader DrawBitmapTest; -GLREF_D TTimeTestHeader XorIngTest; -GLREF_D TTimeTestHeader SmallClearTest; -GLREF_D TTimeTestHeader RectCompareTest; -GLREF_D TTimeTestHeader SimpleFlushTest; -GLREF_D TTimeTestHeader SimpleFlushTest2; -GLREF_D TTimeTestHeader UseFontTest; -GLREF_D TTimeTestHeader BitBltTest; -GLREF_D TTimeTestHeader FullScreenBitBltTest; -GLREF_D TTimeTestHeader MaskedBitBltTest; -GLREF_D TTimeTestHeader SpriteTest; -GLREF_D TTimeTestHeader BitmapDeviceTest1; -GLREF_D TTimeTestHeader BitmapDeviceTest2; -GLREF_D TTimeTestHeader FillPatternTest; -GLREF_D TTimeTestHeader BitmapLoadTest; -GLREF_D TTimeTestHeader WsBitmapLoadTest; -GLREF_D TTimeTestHeader RomFileTest; -GLREF_D TTimeTestHeader TrivialFunctionsTest; -GLREF_D TTimeTestHeader BackupWindowDrawingCreate1; -GLREF_D TTimeTestHeader BackupWindowDrawingCreate2; -GLREF_D TTimeTestHeader MenuEmulationCreate; -GLREF_D TTimeTestHeader MenuEmulationCreate2; - -TTimeTestHeader *tests[]={ - &MenuEmulationCreate, - &MenuEmulationCreate2, - &BitmapLoadTest, - &WsBitmapLoadTest, - &RomFileTest, - &TrivialFunctionsTest, - &BackupWindowDrawingCreate1, - &BackupWindowDrawingCreate2, - &MovingWindowTest1, - &MovingWindowTest2, - &StackedWindowCreate, -// &WindowCreateDestroy, - &LoadsaText, - &DrawBitmapTest, -// &BitmapDeviceTest1, -// &BitmapDeviceTest2, -// &XorIngTest, List getting too big -// &SmallClearTest, List getting too big -// &RectCompareTest, - &SpriteTest, -// &SimpleFlushTest, -// &SimpleFlushTest2, -// &UseFontTest, - &BitBltTest, -// &FullScreenBitBltTest, - &MaskedBitBltTest, -// &FillPatternTest, - }; - -void Panic(TInt aPanic) - { - User::Panic(_L("TimeTest"),aPanic); - } - -struct TThreadParams - { - TInt iIndex; - TInt iGroupId; - }; - -TInt TimeThread(TAny *aParams) - { - CTrapCleanup* CleanUpStack=CTrapCleanup::New(); - //__PROFILE_START(0) - TInt ret=tests[((TThreadParams *)aParams)->iIndex]->function(((TThreadParams *)aParams)->iGroupId); - //__PROFILE_END(0) - delete CleanUpStack; - return ret; - } - -// -// List Window // -// - -CListWindow::CListWindow() : CTTitledWindow(), iPrevTime(0) - { - } - -void CListWindow::CloseWindow() - { - CTClient *client=((CTimeClient *)Client()); - delete this; - client->ResetFocus(); - } - -void CListWindow::SetExt(const TPoint &aPos, const TSize &) - { - SetPos(aPos); - } - -void CListWindow::SetSize(const TSize &) - { - } - -void CListWindow::SetSize() - { - iSize.iHeight=ListCount()*(iFont->HeightInPixels()+1)+iTitleHeight+2; - iSize.iWidth=iFont->TextWidthInPixels(*Client()->Title())+30; - for(TInt index=0;indexTextWidthInPixels(GetText(index)); - if (wid>iSize.iWidth) - iSize.iWidth=wid; - } - iSize.iWidth+=4; - iWin.SetSize(iSize); - Resized(iSize); - } - -void CListWindow::ConstructL(CTWinBase &parent, TBool aExitOnEscape) - { - iExitOnEscape=aExitOnEscape; - CTTitledWindow::ConstructL(parent); - } - -void CListWindow::SetListPos(TInt aNewPos) - { - if (aNewPos>=0 && aNewPosHeightInPixels()+1); - } - -void CListWindow::RowBox(TRect &aRect, TInt aRow) const - { - aRect.iTl.iX=2; - aRect.iTl.iY=iTitleHeight+TextRowHeight()*aRow; - aRect.iBr.iX=iSize.iWidth-2; - aRect.iBr.iY=aRect.iTl.iY+TextRowHeight(); - } - -void CListWindow::Draw() - { - CTTitledWindow::Draw(); - iGc->SetPenColor(TRgb::Gray16(0)); - TPoint pos(2,iTitleHeight+iFont->AscentInPixels()+2); - TInt gap=TextRowHeight(); - for(TInt index=0;indexDrawText(GetText(index), pos); - if (index==iListPos) - { - iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); - iGc->SetBrushColor(TRgb::Gray256(255)); - iGc->SetPenStyle(CGraphicsContext::ENullPen); - iGc->SetDrawMode(CGraphicsContext::EDrawModeXOR); - TRect rect; - RowBox(rect,index); - iGc->DrawRect(rect); - iGc->SetBrushStyle(CGraphicsContext::ENullBrush); - iGc->SetPenStyle(CGraphicsContext::ESolidPen); - iGc->SetDrawMode(CGraphicsContext::EDrawModePEN); - } - } - } - -void CListWindow::Resized(const TSize &aSize) - { - SetDragRect(TRect(0,0,aSize.iWidth,iTitleHeight)); - } - -// -// Test list window -// - -CTestList::CTestList() : CListWindow(), iTestNames(4) - { - } - -CTestList::~CTestList() - { - } - -void CTestList::ConstructL(CTWinBase &parent) - { - CListWindow::ConstructL(parent, EFalse); - for(TUint index=0;index<(sizeof(tests)/sizeof(tests[0]));index++) - AppendToListL(TPtrC(tests[index]->title)); - SetSize(); - /*for(TUint index1=0;index1<(sizeof(tests)/sizeof(tests[0]));index1++) - Selected(index1);*/ - } - -void CTestList::AppendProfileNum(TDes &aDes, TInt aNum) - { - aDes.AppendFormat(_L("%d.%02d, "),aNum/1000000,(aNum%1000000)/10000); - } - -void CTestList::AppendProfileCount(TDes &aDes, TInt aNum) - { - aDes.AppendFormat(_L("%d, "),aNum); - } - -#define USE_PROCESS 1 - -void CTestList::SelectedL(TInt aIndex) - { -#if USE_PROCESS - TThreadParams params; - params.iIndex=aIndex; - TName name; - name.Format(_L("TimeTest-%x"),iCount++); - params.iGroupId=Client()->iGroup->GroupWin()->Identifier(); - User::LeaveIfError(iTimeTest.Create(name,TimeThread,KDefaultStackSize*2,KHeapSize,KHeapSize,¶ms,EOwnerThread)); - TRequestStatus status; - iTimeTest.Logon(status); - __PROFILE_RESET(8); - iTimeTest.Resume(); - User::WaitForRequest(status); -#else - TThreadParams params; - params.iIndex=aIndex; - TimeThread(¶ms); -#endif - TBuf<64> buf; - TBuf<64> buf2; - TBuf<64> buf3; - CResultDialog *dialog=new(ELeave) CResultDialog(Client()->iGroup, iGc); - dialog->ConstructLD(); -#if USE_PROCESS - if (status.Int()==KErrNone) - { -#endif -#if !defined(__PROFILING__) - buf=_L("Profiling information not available"); -#else - TProfile profile[6]; - __PROFILE_DISPLAY(6); - for (TInt index=1;index<6;index++) - AppendProfileNum(buf2,profile[index].iTime); - for (TInt index2=1;index2<6;index2++) - AppendProfileCount(buf3,profile[index2].iCount); - buf.Format(_L("Time=%d.%2d"),profile[0].iTime/1000000,(profile[0].iTime%1000000)/10000); -#endif - dialog->SetTitle(buf); -#if USE_PROCESS - } - else - { - dialog->SetTitle(_L("Error in test")); - buf.Format(_L("Error=%d"),status.Int()); - buf2=iTimeTest.ExitCategory(); - } -#endif - dialog->SetLine1(buf2); - dialog->SetLine2(buf3); - dialog->SetNumButtons(1); - dialog->SetButtonText(0,_L("Okay")); - if (dialog->Display()!=0) - Panic(0); - } - -TPtrC CTestList::GetText(TInt aLine) - { - return(TPtrC(iTestNames[aLine])); - } - -TInt CTestList::ListCount() - { - return(iTestNames.Count()); - } - -void CTestList::WinKeyL(const TKeyEvent &aKey,const TTime& aTime) - { - if (aKey.iModifiers&EModifierFunc) - { - switch(aKey.iCode) - { - case EKeyLeftArrow: - AdjustSize(-Xmove,0,aKey.iModifiers); - break; - case EKeyRightArrow: - AdjustSize(Xmove,0,aKey.iModifiers); - break; - case EKeyUpArrow: - AdjustSize(0,-Ymove,aKey.iModifiers); - break; - case EKeyDownArrow: - AdjustSize(0,Ymove,aKey.iModifiers); - break; - default: - goto not_used; - } - } - else - goto not_used; - return; -not_used: - CListWindow::WinKeyL(aKey,aTime); - } - -void CTestList::AppendToListL(const TDesC &aDesc) - { - TestNameBuf buf(aDesc); - iTestNames.AppendL(buf); - } - -// - -CResultDialog::CResultDialog(CTWindowGroup *aGroupWin,CWindowGc *aGc) : CTDialog(), - iGroupWin(aGroupWin), - iGc(aGc) - { - } - -void CResultDialog::ButtonPressL(TInt aButton) - { - if (aButton==0) - CTDialog::ButtonPressL(aButton); - } - -void CResultDialog::ConstructLD() - { - CTDialog::ConstructLD(*iGroupWin, *iGc); - } - -// -// CTimeTestWindowGroup class // -// - -CTimeTestWindowGroup::CTimeTestWindowGroup(CTClient *aClient) : CTWindowGroup(aClient) - { - } - -void CTimeTestWindowGroup::KeyL(const TKeyEvent &aKey,const TTime &aTime) - { - if (aKey.iModifiers&EModifierFunc) - { - switch(aKey.iCode) - { - case 'x': - ((CTimeClient *)Client())->Exit(); - break; - } - } - else - iCurWin->WinKeyL(aKey,aTime); - } - -// - -CTimeClient::CTimeClient() - { - } - -CTWin *CTimeClient::CreateTestWindowL(TPoint pos,CTWinBase *parent) - { - CTWin *win=new(ELeave) CTestList(); - TRAPD(err,win->ConstructL(*parent)); - if (err!=KErrNone) - goto ctw_err; - TRAP(err,win->SetPos(pos)); - if (err!=KErrNone) - { -ctw_err: - delete win; - User::Leave(err); - } - win->Activate(); - win->AssignGC(*iGc); - return(win); - } - -void CTimeClient::ConstructL() - { - CTClient::ConstructL(); - - iGroup=new(ELeave) CTimeTestWindowGroup(this); - iGroup->ConstructL(); - - CreateTestWindowL(TPoint(30,4),iGroup); - iGroup->SetCurrentWindow(iGroup->Child()); - } - -void CTimeClient::Exit() - { - CActiveScheduler::Stop(); - } - -GLDEF_C CTClient *CreateClientL() - { - return(new(ELeave) CTimeClient()); - } - -GLDEF_C TInt E32Main() - { - return(TestLibStartUp(CreateClientL)); - } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/ttime/TTIME.H --- a/windowing/windowserver/ttime/TTIME.H Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Header for window server timing tests -// -// - -#include -#include "W32STD.H" -#include "../tlib/testbase.h" - -enum TTimePanic - { - TTPanicDisplayMode1, - TTPanicDisplayMode2, - }; -typedef TInt (*TTimeTestFunction)(TInt aOwningGroup); -struct TTimeTestHeader - { - const TText *title; - TTimeTestFunction function; - }; - -_LIT(KTestFontTypefaceName,"DejaVu Sans Condensed"); - diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/ttime/TTMOVWIN.CPP --- a/windowing/windowserver/ttime/TTMOVWIN.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,302 +0,0 @@ -// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// Functions to act as bench marks for various window server features -// -// - -#include "TTIME.H" - -void SetUp(RWindowTreeNode &aParent, RBlankWindow &aBlank, const TPoint &aPos, const TSize &aSize, TInt aColor) - { - aBlank.Construct(aParent,ENullWsHandle); - aBlank.SetColor(TRgb::Gray256(aColor)); - aBlank.SetExtent(aPos, aSize); - aBlank.SetShadowHeight(1); - aBlank.Activate(); - } - -void doMovingWindowTest(TInt aMode, TInt aOwningGroup) - { - RWsSession ws; - ws.Connect(); - CWsScreenDevice *device=new(ELeave) CWsScreenDevice(ws); - device->Construct(); - TPoint pos(10,10); - TSize size(100,100); - TSize scrSize(device->SizeInPixels()); - RBlankWindow blank(ws); - RWindowGroup group(ws); - group.Construct(ENullWsHandle); - group.SetOwningWindowGroup(aOwningGroup); -// - RBlankWindow back(ws); - SetUp(group, back, TPoint(0,0),TSize(640,240), 255); -// - RBlankWindow blank2(ws); - RBlankWindow blank3(ws); - RBlankWindow blank4(ws); - RBlankWindow blank5(ws); - if (aMode==1) - { - SetUp(group, blank2, TPoint(10,10),TSize(240,150), 128); - SetUp(blank2, blank3, TPoint(10,10),TSize(220,130), 255); - SetUp(group, blank4, TPoint(340,-10),TSize(200,70), 64); - SetUp(group, blank5, TPoint(390,-10),TSize(30,250), 128); - } -// - SetUp(group, blank,pos,size, 128); -// - for(pos.iX=10;pos.iX<(scrSize.iWidth-10-size.iWidth);pos.iX+=1) - { - blank.SetPosition(pos); -// ws.Flush(); - } -// - if (aMode==1) - { - blank2.Close(); - blank3.Close(); - blank4.Close(); - blank5.Close(); - } - blank.Close(); - back.Close(); - group.Close(); - delete device; - ws.Close(); - } - -TInt MovingWindowTest1Func(TInt aOwningGroup) - { - doMovingWindowTest(0,aOwningGroup); - return(KErrNone); - } - -GLDEF_D TTimeTestHeader MovingWindowTest1={_S("Moving window test 1"),MovingWindowTest1Func}; - -TInt MovingWindowTest2Func(TInt aOwningGroup) - { - doMovingWindowTest(1,aOwningGroup); - return(KErrNone); - } - -GLDEF_D TTimeTestHeader MovingWindowTest2={_S("Moving window test 2"),MovingWindowTest2Func}; - -TInt CreateAndDestroy(TInt aOwningGroup) - { - RWsSession ws; - ws.Connect(); - CWsScreenDevice *device=new(ELeave) CWsScreenDevice(ws); - device->Construct(); - RWindowGroup group(ws); - group.Construct(ENullWsHandle); - group.SetOwningWindowGroup(aOwningGroup); -// - for (TInt count=0;count<100;count++) - { - RBlankWindow blank(ws); - blank.Construct(group,ENullWsHandle); - blank.SetExtent(TPoint(10,10), TSize(20,20)); - blank.Activate(); - blank.Close(); - } - group.Close(); - delete device; - ws.Close(); - return(KErrNone); - } - -GLDEF_D TTimeTestHeader WindowCreateDestroy={_S("Window create destroy"),CreateAndDestroy}; - -// - -TInt WindowCreate2(TInt aOwningGroup) - { -enum {KNumWindows=20}; - RWsSession ws; - ws.Connect(); - CWsScreenDevice *device=new(ELeave) CWsScreenDevice(ws); - device->Construct(); - RWindowGroup group(ws); - group.Construct(ENullWsHandle); - group.SetOwningWindowGroup(aOwningGroup); - RBlankWindow shield(ws); - shield.Construct(group,ENullWsHandle); - shield.Activate(); - CWindowGc *gc=new(ELeave) CWindowGc(device); - User::LeaveIfError(gc->Construct()); -// - for(TInt times=0;times<2;times++) - { -#if 1 - TSize size(200,100); - RBlankWindow win[KNumWindows]; - TInt count; - for (count=0;countActivate(win[count]); - gc->SetBrushColor(TRgb::Gray4(count&3)); - gc->Clear(); - gc->Deactivate(); - win[count].Activate(); - } -#endif - ws.Flush(); - for (count=0;countConstruct(); - RWindowGroup group(ws); - group.Construct(ENullWsHandle); - group.SetOwningWindowGroup(aOwningGroup); - RBlankWindow shield(ws); - shield.Construct(group,ENullWsHandle); - shield.Activate(); - CWindowGc *gc=new(ELeave) CWindowGc(device); - User::LeaveIfError(gc->Construct()); -// - RWindow win; - TInt count; - for (count=0;count<100;count++) - { - win=RWindow(ws); - win.Construct(group,ENullWsHandle); - win.EnableBackup(); - win.SetExtent(TPoint(10,10), TSize(200,100)); - win.Activate(); - ws.Flush(); - win.Close(); - } - shield.Close(); - group.Close(); - delete device; - ws.Close(); - return(KErrNone); - } - -GLDEF_D TTimeTestHeader BackedUpWindowCreate={_S("Backed up window creating"),BackedUpWindowCreateTest}; - -TInt BackedUpWindowMenuTest(TInt aOwningGroup) -// -// Test designed to emulate menus -// - { - RWsSession ws; - ws.Connect(); - CWsScreenDevice *device=new(ELeave) CWsScreenDevice(ws); - device->Construct(); - RWindowGroup group(ws); - group.Construct(ENullWsHandle); - group.SetOwningWindowGroup(aOwningGroup); - RBlankWindow shield(ws); - shield.Construct(group,ENullWsHandle); - shield.Activate(); - CWindowGc *gc=new(ELeave) CWindowGc(device); - User::LeaveIfError(gc->Construct()); -// - RWindow win; - win=RWindow(ws); - win.Construct(group,ENullWsHandle); - win.EnableBackup(); - win.Activate(); - TInt count; - TInt state=0; - for (count=0;count<200;count++) - { - win.SetVisible(EFalse); - if (state==0) - { - state=1; - win.SetExtent(TPoint(10,10), TSize(200,160)); - } - else - { - state=0; - win.SetExtent(TPoint(100,10), TSize(150,200)); - } - win.SetVisible(ETrue); - win.BeginRedraw(); - gc->Activate(win); - gc->SetBrushStyle(CGraphicsContext::ESolidBrush); - gc->SetBrushColor(TRgb::Gray4((state+1))); - gc->Clear(); - gc->Deactivate(); - win.EndRedraw(); - ws.Flush(); - } - win.Close(); - shield.Close(); - group.Close(); - delete device; - ws.Close(); - return(KErrNone); - } - -GLDEF_D TTimeTestHeader MenuEmulationCreate={_S("Menu emulation"),BackedUpWindowMenuTest}; - -TInt BackedUpWindowMenuTest2(TInt aOwningGroup) - { - CFbsBitmap *bitmaps[1000]; - TInt index; - for(index=0;index<1000;index++) - { - bitmaps[index]=new(ELeave) CFbsBitmap(); - bitmaps[index]->Create(TSize(10,10),EGray4); - } - BackedUpWindowMenuTest(aOwningGroup); - for(index=0;index<1000;index++) - delete bitmaps[index]; - return(KErrNone); - } - -GLDEF_D TTimeTestHeader MenuEmulationCreate2={_S("Menu emulation 2"),BackedUpWindowMenuTest2}; diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/ttime/TTTEXT.CPP --- a/windowing/windowserver/ttime/TTTEXT.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,71 +0,0 @@ -// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// LOADSTXT.CPP -// used for timing text printing -// -// - -#include "TTIME.H" - -TInt LoadsOfText(TInt aOwningGroup) - { - RWsSession ws; - ws.Connect(); - CWsScreenDevice *device=new(ELeave) CWsScreenDevice(ws); - device->Construct(); - RWindowGroup group(ws); - group.Construct(ENullWsHandle); - group.SetOwningWindowGroup(aOwningGroup); - TSize scrSize(device->SizeInPixels()); -// - RWindow window(ws); - window.Construct(group,ENullWsHandle); - window.SetExtent(TPoint(), scrSize); - window.Activate(); -// - CWindowGc *gc; - device->CreateContext(gc); - window.BeginRedraw(); - gc->Activate(window); - gc->Clear(); - window.EndRedraw(); - TFontSpec fspec(KTestFontTypefaceName,200); - CFbsFont *font; - User::LeaveIfError(device->GetNearestFontToDesignHeightInTwips((CFont *&)font, fspec)); - gc->UseFont(font); - TBuf<100> loadsatext(_L("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890zyxwvutsrqponmlkjihgfedcba")); - TInt ascent=font->AscentInPixels(); - TInt fheight=font->HeightInPixels(); - for(TInt nTimes=0;nTimes<10;nTimes++) - { - TPoint pos; -// for(pos.iY=ascent;pos.iYHeightInPixels()) -// gc->DrawText(loadsatext,pos); - for(pos.iY=0;pos.iYDrawText(loadsatext,TRect(pos,TPoint(scrSize.iWidth,pos.iY+fheight)),ascent); - gc->Clear(); - } - gc->Deactivate(); -// - ws.Flush(); - delete gc; - device->ReleaseFont(font); - window.Close(); - group.Close(); - delete device; - ws.Close(); - return(KErrNone); - } - -GLDEF_D TTimeTestHeader LoadsaText={_S("Loads of text"),LoadsOfText}; diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/twsgraphic/TWsGraphicShareTest.CPP --- a/windowing/windowserver/twsgraphic/TWsGraphicShareTest.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,182 +0,0 @@ -// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include - -// bitmap to load for comparison -#define MY_TEST_BITMAP _L("Z:\\WSTEST\\MYTEST.MBM") - -const TUint32 ENullWsHandle=0xFFFFFFFF; -const TInt KErrTestExeFailure = -666; - -// class to check if a shared CWsGraphic can be drawn correctly -class CWsGraphicShareBase : public CBase - { -public: - CWsGraphicShareBase(); - ~CWsGraphicShareBase(); - void ConstructL(); - void DoTestDrawGraphicCompareL(TPtrC aShare); -private : - void Test(TInt aCondition); - - -private : - TInt iScreenNumber; - CWindowGc *iGc; - RWsSession iWs; - RWindowGroup *iGroupWin; - CWsScreenDevice *iScreen; - RWindow *iWin; - }; - -CWsGraphicShareBase::CWsGraphicShareBase() - { - iScreenNumber = 0; - } - -CWsGraphicShareBase::~CWsGraphicShareBase() - { - iWin->Close(); - delete iWin; - delete iScreen; - delete iGc; - delete iGroupWin; - iWs.Close(); - } - -void CWsGraphicShareBase::ConstructL() - { - User::LeaveIfError(iWs.Connect()); - iScreen=new(ELeave) CWsScreenDevice(iWs); - User::LeaveIfError(iScreen->Construct(iScreenNumber)); - iGc=new(ELeave) CWindowGc(iScreen); - User::LeaveIfError(iGc->Construct()); - iGroupWin=new(ELeave) RWindowGroup(iWs); - iGroupWin->Construct(1); - - iWin=new(ELeave) RWindow(iWs); - iWin->Construct(*iGroupWin,ENullWsHandle); - iWin->SetRequiredDisplayMode(EColor256); - iWin->SetExtent(TPoint(0,0),iScreen->SizeInPixels()); - iWin->Activate(); - iWin->BeginRedraw(); - iWin->EndRedraw(); - iWs.Flush(); - } - -// Checks that the shared graphic is drawn or not. This is done by creating a new graphic in this process -// which looks the same as the shared graphic. The new graphic is then drawn to the screen followed by an -// attempt to draw the shared graphic. The two graphics are then compared. In cases where the shared graphic -// should be drawn the two graphics should compare exactly. In cases where the shared graphic should not be -// drawn the comparison will fail. - -void CWsGraphicShareBase::DoTestDrawGraphicCompareL(TPtrC aShare) - { - // UID of the shared graphic - TUid uid1 = {0x12000021}; - TWsGraphicId twsGraphicId1(uid1); - - _LIT8(KTestData,"HelloWorld"); - - CFbsBitmap bitmap1; - CFbsBitmap mask1; - - TSize screenSize = iScreen->SizeInPixels(); - User::LeaveIfError(bitmap1.Load(MY_TEST_BITMAP,0)); - mask1.Create(bitmap1.SizeInPixels(),iScreen->DisplayMode()); - - CWsGraphicBitmap* bTest = CWsGraphicBitmap::NewL(&bitmap1,&mask1); - - // divide the screen into two equal rectangles - TRect position1(0,0,screenSize.iWidth/2,screenSize.iHeight); - TRect position2(screenSize.iWidth/2,0,screenSize.iWidth,screenSize.iHeight); - - // draw the new graphic and attempt to draw the shared graphic - iGc->Activate(*iWin); - iWin->Invalidate(); - iWin->BeginRedraw(); - iGc->Clear(position1); - iGc->Clear(position2); - - iGc->DrawWsGraphic(bTest->Id(),position1,KTestData); - iGc->DrawWsGraphic(twsGraphicId1.Uid(),position2,KTestData); - - iGc->Deactivate(); - iWin->EndRedraw(); - - iWs.Flush(); - iWs.Finish(); - // compare the graphic in both positions - if (aShare==_L("false")) - Test(!iScreen->RectCompare(position1,position2)); - else - Test(iScreen->RectCompare(position1,position2)); - - delete bTest; - } - -// Failures are written to WSERV.log -void CWsGraphicShareBase::Test(TInt aCondition) - { - if(!aCondition) - { - TLogMessageText buf; - _LIT(Fail,"AUTO Failed in WsGraphics Test : DrawSharedGraphic"); - buf.Format(Fail); - iWs.LogMessage(buf); - iWs.Flush(); - RProcess().Terminate(KErrTestExeFailure); // terminate this process immediately. Expect TWsGraph test step (TAutoServer.exe) to capture this - } - } - -void MainL() - { - // read the argument from the command line of whether the graphic should be shared or not - TBuf<256> commandLine; - User::CommandLine(commandLine); - TLex lex(commandLine); - TPtrC toShare = lex.NextToken(); - - CActiveScheduler* activeScheduler=new(ELeave) CActiveScheduler; - CActiveScheduler::Install(activeScheduler); - CleanupStack::PushL(activeScheduler); - - CWsGraphicShareBase testBase; - testBase.ConstructL(); - - testBase.DoTestDrawGraphicCompareL(toShare); - - CleanupStack::PopAndDestroy(activeScheduler); - } - -GLDEF_C TInt E32Main() - { - CTrapCleanup* cleanUpStack=CTrapCleanup::New(); - if(cleanUpStack==NULL) - { - return KErrNoMemory; - } - TRAP_IGNORE(MainL()) - delete cleanUpStack; - - return(KErrNone); - } diff -r bf7481649c98 -r 7f25ef56562d windowing/windowserver/twsgraphic/TWsGraphicTest.CPP --- a/windowing/windowserver/twsgraphic/TWsGraphicTest.CPP Fri Jun 11 14:58:47 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1610 +0,0 @@ -// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// - -/** - @file - @test - @internalComponent - Internal Symbian test code -*/ - -#include -#include -#include "testbase.h" -#include "testbase.h" - -// Bitmap to load for tests -#define MY_TEST_BITMAP _L("Z:\\WSTEST\\MYTEST.MBM") - -// Animation to load for tests -_LIT(KSymBallFile, "Z:\\WSTEST\\symball.gif"); - -// Executables for different sharing of graphic tests -_LIT(KTestExe1, "TWSGRAPHICSHARETEST.exe"); -_LIT(KTestExe2, "TWSGRAPHICSHAREGLOBALTEST.exe"); -_LIT(KTestExe3, "TWSGRAPHICUNSHAREGLOBALTEST.exe"); -_LIT(KTestExe4, "TWSGRAPHICSHARESECURETEST.exe"); -_LIT(KTestExe5, "TWSGRAPHICUNSHARESECURETEST.exe"); - -// Graphic is shared or not in executeable -_LIT(KShare, " true"); -_LIT(KNoShare, " false"); - -TUid KUidTestAnimation = {0x87654321}; -const TInt KDummyGraphicId = 99; -const TInt KMaxLogLength = 256; -const TInt KAnimationRunTime = 5000000; // 5 seconds max time to run a single animation loop - -// Animation loader -class CIclLoader: public CActive - { -public: - CIclLoader(); - ~CIclLoader(); - void ConstructL(const TDesC& aFileName, TBool aUseUID, TBool aReplace); - const TWsGraphicId GetId(); - inline TInt FrameCount() const {return iTotalFrames;}; - inline TBool Ok() const {return !iFailed;}; -protected: - void RunL(); - TInt RunError(TInt aError); - void DoCancel(); -private: - void TestL(TInt aCondition); - CImageDecoder* iDecoder; - CWsGraphicBitmapAnimation* iTestAnimation; - TLogMessageText iTestLog; - TBool iUseUID; - TBool iReplace; - RPointerArray iFrames; - TInt iTotalFrames; - void NextL(); - RFs iFs; - TBool iFailed; - }; - -CIclLoader::CIclLoader(): - CActive(CActive::EPriorityLow) - { - CActiveScheduler::Add(this); - } - -CIclLoader::~CIclLoader() - { - if (iTestAnimation) - { - delete iTestAnimation; - iTestAnimation = NULL; - } - if (iDecoder) - { - delete iDecoder; - iDecoder = NULL; - } - iFrames.ResetAndDestroy(); - iFs.Close(); - } - -const TWsGraphicId CIclLoader::GetId() - { - if (iTestAnimation) - { - return iTestAnimation->Id(); - } - else - { - TWsGraphicId id(KDummyGraphicId); - return id; - } - } - -void CIclLoader::TestL(TInt aCondition) - { - if(!aCondition) - { - RWsSession rWs; - User::LeaveIfError(rWs.Connect()); - TBuf buf; - _LIT(Fail,"AUTO Failed in WsGraphics Test : CIclLoader"); - buf.Append(Fail); - buf.Append(iTestLog); - rWs.LogMessage(buf); - rWs.Flush(); - rWs.Close(); - User::Leave(KErrGeneral); - } - } - -void CIclLoader::ConstructL(const TDesC& aFileName, TBool aUseUID,TBool aReplace) - { - iUseUID = aUseUID; - iReplace = aReplace; - - User::LeaveIfError(iFs.Connect()); - - iDecoder = CImageDecoder::FileNewL(iFs,aFileName); - if(!iDecoder->IsImageHeaderProcessingComplete()) - { - User::Leave(KErrGeneral); - } - NextL(); - } - -void CIclLoader::NextL() - { - // Load a frame from the animation - if (iDecoder && (iDecoder->FrameCount() > iFrames.Count())) - { - const TFrameInfo& info = iDecoder->FrameInfo(iFrames.Count()); - CWsGraphicBitmapAnimation::CFrame* frame = CWsGraphicBitmapAnimation::CFrame::NewL(); - CleanupStack::PushL(frame); - iFrames.AppendL(frame); - CleanupStack::Pop(frame); - frame->SetFrameInfo(info); - TFrameInfo copiedInfo = frame->FrameInfo(); - TestL(info.iFlags==copiedInfo.iFlags); - - TSize bmpSize(info.iFrameCoordsInPixels.Size()); - CFbsBitmap* bitmap = new(ELeave) CFbsBitmap; - frame->SetBitmap(bitmap); //takes ownership - User::LeaveIfError(bitmap->Create(bmpSize,info.iFrameDisplayMode)); - - TDisplayMode maskDispMode; - CFbsBitmap* mask = new(ELeave) CFbsBitmap; - frame->SetMask(mask); //takes ownership - if((TFrameInfo::EAlphaChannel|TFrameInfo::ETransparencyPossible) & info.iFlags) - { - maskDispMode = EGray256; - } - else - { - maskDispMode = EGray2; - } - - User::LeaveIfError(mask->Create(info.iFrameCoordsInPixels.Size(),maskDispMode)); - iDecoder->Convert(&iStatus,*bitmap,*mask,iFrames.Count()-1); - - SetActive(); - } - - // if a frame loaded - else if(iFrames.Count()) - { - _LIT_SECURE_ID(KTestSecId,0x12345678); - - // The extra code around the NewL is checking that no heap failures occur when - // creating the CWsGraphicBitmapAnimation - TInt failRate = 1; - const TInt KMaxIteration = 1000; - for (;failRate < KMaxIteration; failRate++) - { - __UHEAP_RESET; - __UHEAP_SETFAIL(RHeap::EDeterministic,failRate); - __UHEAP_MARK; - - TInt err = KErrGeneral; - if (iUseUID) - {// creating animation using UID - TRAP(err, iTestAnimation = CWsGraphicBitmapAnimation::NewL(KUidTestAnimation,iFrames.Array());); - } - else - {// creating using transient ID allocated by wserv - TRAP(err, iTestAnimation = CWsGraphicBitmapAnimation::NewL(iFrames.Array());); - } - - TestL((err==KErrNone || err==KErrNoMemory)); - - if (err != KErrNone) - { - __UHEAP_MARKEND; - TestL(iTestAnimation == NULL); - } - else - { - break; - } - } - __UHEAP_RESET; - TestL(iTestAnimation != NULL); - TestL(failRate > 1); //Ensure the udeb version of euser.dll is available (i.e. that the rom was build with the -D_DEBUG option) - RDebug::Printf("TWSGraphicTest.CPP: Heapfailure loop completed after %d allocs.", failRate-1); - - // if testing that a created animation can be replaced - if (iReplace) - { - // replace the animation just created with another - TWsGraphicId testId = iTestAnimation->Id(); - TInt testInt = testId.Id(); - - CWsGraphicBitmapAnimation* testReplacement = CWsGraphicBitmapAnimation::NewL(testId,iFrames.Array()); - - delete iTestAnimation; - - iTestAnimation = testReplacement; - - TestL(iTestAnimation->Id().Id()==testInt); - } - - delete iDecoder; - iDecoder = NULL; - iTotalFrames = iFrames.Count(); - iFrames.ResetAndDestroy(); - - // test that the animation methods can be used without error - TestL(iTestAnimation->ShareGlobally()==KErrNone); - TestL(iTestAnimation->UnShareGlobally()==KErrNone); - TestL(iTestAnimation->Share(KTestSecId)==KErrNone); - TestL(iTestAnimation->UnShare(KTestSecId)==KErrNone); - TestL(iTestAnimation->UnShare(KTestSecId)==KErrNotFound); - } - } - -void CIclLoader::RunL() - { - if (iStatus == KErrNone) - { - NextL(); - } - else - { - TestL(EFalse); // kill the test - } - } - -TInt CIclLoader::RunError(TInt aError) - { - RDebug::Printf("CIclLoader::RunError, aError %d", aError); - iFailed = ETrue; - return KErrNone; - } - -void CIclLoader::DoCancel() - { - if(iDecoder) - { - iDecoder->Cancel(); - } - } - -// Class for testing CWsGraphics -class CActiveWait; -class CRedrawAO; -class CWsGraphicBase : public CBase - { -public: - CWsGraphicBase(); - CWsGraphicBase(TInt aScreenNumber); - ~CWsGraphicBase(); - void ConstructL(); - void DoTestL(TInt aTestNo); - void RedrawMe(TRect aRedrawRect, TInt aFrame); - - enum TTestCases - { - ETestCreateGraphicUID, - ETestCreateGraphicID, - ETestUpdateGraphic, - ETestDeleteGraphic, - ETestDrawInvalideBitmapID, - ETestDrawGraphic, - ETestDrawGraphicID, - ETestDrawGraphicCompare, - ETestDrawGraphicSessionHandle, - ETestDrawAnimatedGraphicUID, - ETestDrawAnimatedGraphicID, - ETestCreateMsgGraphicMsgBuf, - ETestDrawReplaceGraphicID, - ETestDrawInvalidAnimationID, - ETestDrawSharedGraphic, - // additional cases to be added here, before ETestMaxNumberOfTests - ETestMaxNumberOfTests - }; - -private : - void PrepGc(); - void RetireGc(); - void RunAnimation(TInt aFrameCount); - void LaunchNewProcessL(const TDesC& aExecutable, TBool aShare); - inline void TestForIdenticalBitmaps(){Test(iScreen->RectCompare(iPosition1,iPosition2));}; - inline void TestForDifferentBitmaps(){Test(!iScreen->RectCompare(iPosition1,iPosition2));}; - void Test(TInt aCondition); - void DoTestCreateGraphicUidL(); - void DoTestCreateGraphicIdL(); - void DoTestUpdateGraphicL(); - void DoTestDrawSharedGraphicL(); - void DoTestDeleteGraphicL(); - void DoTestDrawGraphicL(); - void DoTestDrawGraphicIDL(); - void DoTestDrawGraphicCompareL(); - void DoTestDrawAnimatedGraphicUIDL(); - void DoTestDrawAnimatedGraphicIDL(); - void DoTestDrawGraphicSessionHandleL(); - void DoTestCreateMsgGraphicMsgBufL(); - void DoTestDrawReplaceGraphicIDL(); - void DoTestDrawInvalidBitmapIDL(); - void DoTestDrawInvalidAnimationIDL(); -private : - TInt iScreenNumber; - CWindowGc *iGc; - RWsSession iWs; - RWindowGroup *iGroupWin; - CWsScreenDevice *iScreen; - RWindow *iWin; - TLogMessageText iTestLog; - TRect iPosition1; - TRect iPosition2; - CActiveWait* iTimer; - CRedrawAO* iRedrawListener; - TWsGraphicId iAnimId; - TWsGraphicAnimation iAnimData; - }; - -// -// class CRedrawAO -// request & listen for redraw events from wserv -// if a redraw event is received, notify the observing class -// -class CRedrawAO : public CActive - { -public: - static CRedrawAO* NewL(RWsSession* aWs); - ~CRedrawAO(); - // from CActive: - void RunL(); - void DoCancel(); - TInt RunError(TInt aError); - void RequestRedraw(); - inline void SetFrameCount(TInt aCount){iFrameCount = aCount;}; - inline TInt GetFrameCount() const {return iFrameCount;}; -private: - CRedrawAO(RWsSession* aWs); - void ConstructL(); -private: - RWsSession* iWs; - TInt iFrameCount; - }; - -CRedrawAO* CRedrawAO::NewL(RWsSession* aWs) - { - CRedrawAO* self = new (ELeave) CRedrawAO(aWs); - CleanupStack::PushL(self); - self->ConstructL(); - CleanupStack::Pop(self); - return self; - } - -CRedrawAO::CRedrawAO(RWsSession* aWs): -CActive(CActive::EPriorityHigh), iWs(aWs) - { - CActiveScheduler::Add(this); - } - -CRedrawAO::~CRedrawAO() - { - // cleanup - Cancel(); - } - -void CRedrawAO::ConstructL() - { - // nothing to construct - } - -void CRedrawAO::RunL() - { - // leave if status is not ok. RunError will process this result - User::LeaveIfError(iStatus.Int()); - TWsRedrawEvent redraw; - iWs->GetRedraw(redraw); - TUint redrawHandle = redraw.Handle(); - if (redrawHandle == ENullWsHandle) - { - User::Leave(KErrBadHandle); // sanity check the client handle isn't a dummy - } - else if (redrawHandle) - { - --iFrameCount; - (reinterpret_cast(redrawHandle))->RedrawMe(redraw.Rect(), iFrameCount); // handle the redraw signal - } - - if (iFrameCount > 0) - { - RequestRedraw(); - } - } - -TInt CRedrawAO::RunError(TInt aError) - { - if (aError != KErrBadHandle) - { - RequestRedraw(); - } - return KErrNone; - } - -void CRedrawAO::DoCancel() - { - // kill all outstanding asynch. wserv requests - iWs->RedrawReadyCancel(); - iFrameCount = KErrNone; - } - -void CRedrawAO::RequestRedraw() - { - if (!IsActive()) - { - iWs->RedrawReady(&iStatus); - SetActive(); - } - } - -// - -class CActiveWait : public CActive - { -public: - static CActiveWait* NewL(); - ~CActiveWait(); - void Wait(TInt aDelay); - // From CActive: - void RunL(); - void DoCancel(); - TInt RunError(TInt aError); -protected: - CActiveWait(); - void ConstructL(); -protected: - RTimer iTimer; - TTime iFromTime; - }; - -CActiveWait* CActiveWait::NewL() - { - CActiveWait* self = new (ELeave) CActiveWait; - CleanupStack::PushL(self); - self->ConstructL(); - CleanupStack::Pop(self); - return self; - } - -void CActiveWait::ConstructL() - { - User::LeaveIfError(iTimer.CreateLocal()); - CActiveScheduler::Add(this); - } - -CActiveWait::CActiveWait() : CActive(CActive::EPriorityStandard) - { - iFromTime.HomeTime(); - } - -CActiveWait::~CActiveWait() - { - Cancel(); - iTimer.Close(); - } - -void CActiveWait::DoCancel() - { - iTimer.Cancel(); - CActiveScheduler::Stop(); - } - -void CActiveWait::RunL() - { - CActiveScheduler::Stop(); - } - -TInt CActiveWait::RunError(TInt aError) - { - return aError; // exists so a break point can be placed on it. - } - -void CActiveWait::Wait(TInt aDelay) - - - { - iTimer.After(iStatus, aDelay); - SetActive(); - CActiveScheduler::Start(); - } - -// - -CWsGraphicBase::CWsGraphicBase(TInt aScreenNumber) : iScreenNumber(aScreenNumber), iAnimId(KDummyGraphicId) - { - } - -CWsGraphicBase::~CWsGraphicBase() - { - iWin->Close(); - delete iWin; - delete iScreen; - delete iGc; - delete iGroupWin; - iWs.Close(); - if (iTimer) - { - delete iTimer; - iTimer = NULL; - } - if (iRedrawListener) - { - delete iRedrawListener; - iRedrawListener = NULL; - } - } - -void CWsGraphicBase::ConstructL() - { - User::LeaveIfError(iWs.Connect()); - iScreen=new(ELeave) CWsScreenDevice(iWs); - User::LeaveIfError(iScreen->Construct(iScreenNumber)); - - TSize screenSize = iScreen->SizeInPixels(); - iPosition1.SetRect(0,0,screenSize.iWidth/2,screenSize.iHeight); - iPosition2.SetRect(screenSize.iWidth/2,0,screenSize.iWidth,screenSize.iHeight); - - iTimer = CActiveWait::NewL(); - iRedrawListener = CRedrawAO::NewL(&iWs); - - iGc=new(ELeave) CWindowGc(iScreen); - User::LeaveIfError(iGc->Construct()); - iGroupWin=new(ELeave) RWindowGroup(iWs); - iGroupWin->Construct(1); - - iWin=new(ELeave) RWindow(iWs); - iWin->Construct(*iGroupWin, (TUint32)this); - iWin->EnableRedrawStore(EFalse); // disable the redraw store for these tests - iWin->SetRequiredDisplayMode(EColor256); - iWin->SetExtent(TPoint(0,0),iScreen->SizeInPixels()); - iWin->Activate(); - iWin->BeginRedraw(); - iWin->EndRedraw(); - iWs.Flush(); - } - -// To test whether sharing of graphics works a new process has to be launched. -// The argument is set whether the graphic should be shared or not. -void CWsGraphicBase::LaunchNewProcessL(const TDesC& aExecutable, TBool aShare) - { - TBuf<128> args; - RProcess pr; - TRequestStatus status; - - if (aShare) - { - args.Append(KShare); - } - else - { - args.Append(KNoShare); - } - - User::LeaveIfError(pr.Create(aExecutable,args)); - pr.Logon(status); - pr.Resume(); - User::WaitForRequest(status); - pr.Close(); - - if (status != KErrNone) - { - User::Leave(status.Int()); - } - } - -// -// CWsGraphicBase::PrepGc -// activate a gc & clear the two rects -// -void CWsGraphicBase::PrepGc() - { - iGc->Activate(*iWin); - iWin->Invalidate(); - iWin->BeginRedraw(); - iGc->Clear(iPosition1); - iGc->Clear(iPosition2); - iWs.Flush(); - } - -// -// CWsGraphicBase::RetireGc -// deactivate a gc & flush any outstanding RWindow requests -void CWsGraphicBase::RetireGc() - { - iGc->Deactivate(); - iWin->EndRedraw(); - iWs.Flush(); - } - -// -// CWsGraphicBase::RedrawMe -// called from the redraw listener AO, triggered by a redraw event -// Invalidates the area requiring a redraw & -// initiates a redraw of the CWsGraphicBitmapAnimation's window -// -void CWsGraphicBase::RedrawMe(TRect aRedrawRect, TInt aFrame) - { - // do draw with next frame - if (iAnimData.IsPlaying()) - { - iGc->Activate(*iWin); - iWin->Invalidate(aRedrawRect); - iWin->BeginRedraw(); - iWs.Flush(); - iGc->DrawWsGraphic(iAnimId,iPosition1,iAnimData.Pckg()); - iGc->Deactivate(); - iWin->EndRedraw(); - iWs.Flush(); - - // check for last frame - if (aFrame == 0) - { - iTimer->Cancel(); - } - } - } - -/** - @SYMTestCaseID GRAPHICS-WSERV-0001 - - @SYMPREQ PREQ1246 - - @SYMTestCaseDesc Create Globally and Locally Shared Graphic Bitmaps from UIDs. - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions First test that TWsGraphicIds can be created from UIDs. Then create CWsGraphicBitmap objects through - CWsGraphicBitmap::NewL, passing a UID from a TWsGraphicId. Two different objects are created - 1. Globally shared available to all applications - 2. Locally shared available to selected clients - - @SYMTestExpectedResults The CWsGraphicBitmap objects are created and no errors are reported. - */ -void CWsGraphicBase::DoTestCreateGraphicUidL() - { - iTestLog.Append(_L("CreateGraphicUid")); - - _LIT_SECURE_ID(KTestSecId,0x12345678); - - // Test the creation of TWsGraphicIds from UIDs - TUid uid1 = {0x10000001}; - TUid uid2 = {0x10000002}; - - TWsGraphicId twsGraphicId1(uid1); - Test(twsGraphicId1.Uid()==uid1); - - TWsGraphicId twsGraphicId2(uid2); - Test(twsGraphicId2.Uid()==uid2); - - TWsGraphicId twsGraphicId3(twsGraphicId2); - Test(twsGraphicId3.Uid()==uid2); - - TWsGraphicId twsGraphicId4(1); - twsGraphicId4.Set(uid1); - Test(twsGraphicId4.Uid()==uid1); - - // Create globally shared CWsGraphicBitmap - CFbsBitmap bitmap1; - CFbsBitmap mask1; - - TSize screenSize = iScreen->SizeInPixels(); - bitmap1.Create(screenSize,iScreen->DisplayMode()); - mask1.Create(bitmap1.SizeInPixels(),iScreen->DisplayMode()); - - CWsGraphicBitmap* bTest = CWsGraphicBitmap::NewL(twsGraphicId1.Uid(), &bitmap1,&mask1); - Test(bTest->IsActive()); - - TWsGraphicId tid1 = bTest->Id(); - Test(tid1.Uid()==uid1); - - Test(bTest->ShareGlobally()==KErrNone); - - // Create local shared CWsGraphicBitmap - CFbsBitmap bitmap2; - CFbsBitmap mask2; - - bitmap2.Create(screenSize,iScreen->DisplayMode()); - mask2.Create(bitmap2.SizeInPixels(),iScreen->DisplayMode()); - - CWsGraphicBitmap* bTest2 = CWsGraphicBitmap::NewL(twsGraphicId2.Uid(), &bitmap2,&mask2); - - TWsGraphicId tid2 = bTest2->Id(); - Test(tid2.Uid()==uid2); - - Test(bTest2->Share(KTestSecId)==KErrNone); - - // Test the unsharing of the CWsGraphicBitmaps - Test(bTest->UnShareGlobally()==KErrNone); - Test(bTest2->UnShare(KTestSecId)==KErrNone); - Test(bTest2->UnShare(KTestSecId)==KErrNotFound); - - delete bTest; - delete bTest2; - } - -/** - @SYMTestCaseID GRAPHICS-WSERV-0002 - - @SYMPREQ PREQ1246 - - @SYMTestCaseDesc Create Globally and Locally Shared Graphic Bitmaps. - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions First test that TWsGraphicIds can be created from IDs. Then create CWsGraphicBitmap objects through - CWsGraphicBitmap::NewL. Two different objects are created - 1. Globally shared available to all applications - 2. Locally shared available to selected clients - - @SYMTestExpectedResults The CWsGraphicBitmap objects are created and no errors are reported. - */ -void CWsGraphicBase::DoTestCreateGraphicIdL() - { - iTestLog.Append(_L("CreateGraphicId")); - - _LIT_SECURE_ID(KTestSecId,0x12345678); - - // Test creating TWsGraphicIds from ids first - TUid uid1 = {0x10000001}; - - TWsGraphicId twsGraphicId1(uid1); - - twsGraphicId1.Set(9); - Test(twsGraphicId1.Id()==9); - - TWsGraphicId twsGraphicId2(twsGraphicId1); - Test(twsGraphicId2.Id()==9); - - TWsGraphicId twsGraphicId3(7); - Test(twsGraphicId3.Id()==7); - - // Create globally shared CWsGraphicBitmap - CFbsBitmap bitmap1; - CFbsBitmap mask1; - - TSize screenSize = iScreen->SizeInPixels(); - bitmap1.Create(screenSize,iScreen->DisplayMode()); - mask1.Create(bitmap1.SizeInPixels(),iScreen->DisplayMode()); - - CWsGraphicBitmap* bTest = CWsGraphicBitmap::NewL(&bitmap1,&mask1); - Test(bTest->IsActive()); - - TWsGraphicId tid1 = bTest->Id(); - - Test(bTest->ShareGlobally()==KErrNone); - - // Create local shared CWsGraphicBitmap - CFbsBitmap bitmap2; - CFbsBitmap mask2; - - bitmap2.Create(screenSize,iScreen->DisplayMode()); - mask2.Create(bitmap2.SizeInPixels(),iScreen->DisplayMode()); - - CWsGraphicBitmap* bTest2 = CWsGraphicBitmap::NewL(&bitmap2,&mask2); - - TWsGraphicId tid2 = bTest2->Id(); - - Test(bTest2->Share(KTestSecId)==KErrNone); - - // Test the unsharing of the CWsGraphicBitmaps - Test(bTest->UnShareGlobally()==KErrNone); - Test(bTest2->UnShare(KTestSecId)==KErrNone); - Test(bTest2->UnShare(KTestSecId)==KErrNotFound); - - delete bTest2; - delete bTest; - } - - /** - @SYMTestCaseID GRAPHICS-WSERV-0003 - - @SYMPREQ PREQ1246 - - @SYMTestCaseDesc Update an existing graphic bitmap with new data. - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions The test calls CWsGraphicBitmap::NewL method with new data passed to the CWsGraphicBitmap object. - - - @SYMTestExpectedResults The CWsGraphicBitmap object is updated with no errors reported. - */ -void CWsGraphicBase::DoTestUpdateGraphicL() - { - iTestLog.Append(_L("UpdateGraphic")); - - CFbsBitmap bitmap1; - CFbsBitmap mask1; - CFbsBitmap bitmap2; - CFbsBitmap mask2; - - TSize screenSize = iScreen->SizeInPixels(); - bitmap1.Create(screenSize,iScreen->DisplayMode()); - mask1.Create(bitmap1.SizeInPixels(),iScreen->DisplayMode()); - - CWsGraphic* bTest = CWsGraphicBitmap::NewL(&bitmap1,&mask1); - - bitmap2.Create(screenSize,iScreen->DisplayMode()); - mask2.Create(bitmap2.SizeInPixels(),iScreen->DisplayMode()); - - TWsGraphicId tid1 = bTest->Id(); - TInt testInt = tid1.Id(); - - CWsGraphic* testReplacement = CWsGraphicBitmap::NewL(tid1, &bitmap2,&mask2); - - delete bTest; - bTest = testReplacement; - - Test(bTest->Id().Id()==testInt); - - delete bTest; - } - - - - /** - @SYMTestCaseID GRAPHICS-WSERV-0004 - - @SYMPREQ PREQ1246 - - @SYMTestCaseDesc Try to delete an existing graphic. - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions The test app calls CWsGraphic::Destroy() method, - - @SYMTestExpectedResults The CWsGraphicBitmap object is removed from the Window Server with no - errors reported - */ -void CWsGraphicBase::DoTestDeleteGraphicL() - { - iTestLog.Append(_L("DeleteGraphic")); - - CFbsBitmap bitmap1; - CFbsBitmap mask1; - - TSize screenSize = iScreen->SizeInPixels(); - bitmap1.Create(screenSize,iScreen->DisplayMode()); - mask1.Create(bitmap1.SizeInPixels(),iScreen->DisplayMode()); - - CWsGraphic* bTest = CWsGraphicBitmap::NewL(&bitmap1,&mask1); - - bTest->Destroy(); - - Test(!bTest->IsActive()); - - delete bTest; - } - - /** - @SYMTestCaseID GRAPHICS-WSERV-0005 - - @SYMPREQ PREQ1246 - - @SYMTestCaseDesc Check a bitmap is not drawn if the bitmap and mask it uses are invalid - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions The test app creates a valid and invalid bitmap and attempts to draw them - - @SYMTestExpectedResults The valid bitmap is drawn but the invalid bitmap is not drawn - */ -void CWsGraphicBase::DoTestDrawInvalidBitmapIDL() - { - iTestLog.Append(_L("DrawInvalidBitmapID")); - - CFbsBitmap bitmap1; - CFbsBitmap mask1; - CFbsBitmap *bitmap2 = NULL; - CFbsBitmap *mask2 = NULL; - - User::LeaveIfError(bitmap1.Load(MY_TEST_BITMAP,0)); - mask1.Create(bitmap1.SizeInPixels(),iScreen->DisplayMode()); - - // valid bitmap - CWsGraphicBitmap* bTest = CWsGraphicBitmap::NewL(&bitmap1,&mask1); - - // invalid bitmap - CWsGraphicBitmap* bTest2 = CWsGraphicBitmap::NewL(bitmap2,mask2); - - PrepGc(); - iGc->DrawWsGraphic(bTest->Id(),iPosition1); - iGc->DrawWsGraphic(bTest2->Id(),iPosition2); - RetireGc(); - - // compare the graphic in both positions, should only be graphic in position 1 - TestForDifferentBitmaps(); - - delete bTest2; - delete bTest; - } - - /** - @SYMTestCaseID GRAPHICS-WSERV-0006 - - @SYMPREQ PREQ1246 - - @SYMTestCaseDesc Draw a graphic within a rectangle on the screen, then try to draw with a non-existant graphic - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions The test app calls CWindowGC::DrawWsGraphic() method using the TWGraphicId object, to draw within a rectangle on the screen - - @SYMTestExpectedResults The graphic is drawn on the screen with no errors reported. Drawing with a non-existant graphic causes - nothing to be drawn and no error reported - */ -void CWsGraphicBase::DoTestDrawGraphicL() - { - iTestLog.Append(_L("DrawGraphic")); - - _LIT8(KTestData,"HelloWorld"); - - CFbsBitmap bitmap1; - CFbsBitmap mask1; - - User::LeaveIfError(bitmap1.Load(MY_TEST_BITMAP,0)); - mask1.Create(bitmap1.SizeInPixels(),iScreen->DisplayMode()); - - CWsGraphicBitmap* bTest = CWsGraphicBitmap::NewL(&bitmap1,&mask1); - - PrepGc(); - iGc->DrawWsGraphic(bTest->Id(),iPosition1,KTestData); - TWsGraphicId twsGraphicId1(KDummyGraphicId); // create unrecognised wsbitmap id & attempt to draw it - iGc->DrawWsGraphic(twsGraphicId1,iPosition2,KTestData); - RetireGc(); - - // compare the graphic in both positions, should only be graphic in position 1 - TestForDifferentBitmaps(); - - delete bTest; - } - - /** - @SYMTestCaseID GRAPHICS-WSERV-0007 - - @SYMPREQ PREQ1246 - - @SYMTestCaseDesc Draw a graphic using a transient ID within a rectangle on the screen - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions The test app calls CWindowGC::DrawWsGraphic() using a TWsGraphic object, to draw within - a rectangle on the screen - - @SYMTestExpectedResults The graphic is drawn. - */ -void CWsGraphicBase::DoTestDrawGraphicIDL() - { - iTestLog.Append(_L("DrawGraphicID")); - - CFbsBitmap bitmap1; - CFbsBitmap mask1; - - User::LeaveIfError(bitmap1.Load(MY_TEST_BITMAP,0)); - mask1.Create(bitmap1.SizeInPixels(),iScreen->DisplayMode()); - - CWsGraphicBitmap* bTest = CWsGraphicBitmap::NewL(&bitmap1,&mask1); - - PrepGc(); - iGc->DrawWsGraphic(bTest->Id(),iPosition1); - RetireGc(); - - // compare the graphic in both positions, should only be graphic in position 1 - TestForDifferentBitmaps(); - - delete bTest; - } - - - - /** - @SYMTestCaseID GRAPHICS-WSERV-0008 - - @SYMPREQ PREQ1246 - - @SYMTestCaseDesc Draw a graphic in two different rectangles on the screen and compare them - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions The test app calls CWindowGC::DrawWsGraphic() using the TWsGraphic object, to draw a known bitmap - rectangle on the screen twice in different places. The bitmaps are then compared. - - @SYMTestExpectedResults The two bitmaps are identical - */ -void CWsGraphicBase::DoTestDrawGraphicCompareL() - { - iTestLog.Append(_L("DrawGraphicCompare")); - - _LIT8(KTestData,"HelloWorld"); - - CFbsBitmap bitmap1; - CFbsBitmap mask1; - - CFbsBitmap bitmap2; - CFbsBitmap mask2; - - User::LeaveIfError(bitmap1.Load(MY_TEST_BITMAP,0)); - mask1.Create(bitmap1.SizeInPixels(),iScreen->DisplayMode()); - - User::LeaveIfError(bitmap2.Load(MY_TEST_BITMAP,0)); - mask2.Create(bitmap2.SizeInPixels(),iScreen->DisplayMode()); - - CWsGraphicBitmap* bTest = CWsGraphicBitmap::NewL(&bitmap1,&mask1); - CWsGraphicBitmap* bTest2 = CWsGraphicBitmap::NewL(&bitmap2,&mask2); - - PrepGc(); - //draw the graphic in the two different rectangles - iGc->DrawWsGraphic(bTest->Id(),iPosition1,KTestData); - iGc->DrawWsGraphic(bTest2->Id(),iPosition2,KTestData); - RetireGc(); - - // compare the graphic in both positions. Contents of each rect should be identical - TestForIdenticalBitmaps(); - - delete bTest2; - delete bTest; - } - - /** - @SYMTestCaseID GRAPHICS-WSERV-0009 - - @SYMPREQ PREQ1246 - - @SYMTestCaseDesc Draw a global and local graphic in two different rectangles on the screen and compare them - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions The test app calls CWindowGC::DrawGraphic() using the TWsGraphic object, to draw a known - global and local bitmap rectangle on the screen twice in different places. The bitmaps are then compared. - - @SYMTestExpectedResults The two bitmaps are identical - */ -void CWsGraphicBase::DoTestDrawGraphicSessionHandleL() - { - iTestLog.Append(_L("DrawGraphicSessionHandle")); - _LIT_SECURE_ID(KTestSecId,0x12345678); - - // test TWsGraphicControlState first - _LIT8(KTestData,"HelloWorld"); - - CFbsBitmap bitmap1; - CFbsBitmap mask1; - - CFbsBitmap bitmap2; - CFbsBitmap mask2; - - User::LeaveIfError(bitmap1.Load(MY_TEST_BITMAP,0)); - mask1.Create(bitmap1.SizeInPixels(),iScreen->DisplayMode()); - - User::LeaveIfError(bitmap2.Load(MY_TEST_BITMAP,0)); - mask2.Create(bitmap2.SizeInPixels(),iScreen->DisplayMode()); - - CWsGraphicBitmap* bTest = CWsGraphicBitmap::NewL(&bitmap1,&mask1); - CWsGraphicBitmap* bTest2 = CWsGraphicBitmap::NewL(&bitmap2,&mask2); - - Test(bTest->ShareGlobally()==KErrNone); - Test(bTest2->Share(KTestSecId)==KErrNone); - - PrepGc(); - iGc->DrawWsGraphic(bTest->Id(),iPosition1,KTestData); - iGc->DrawWsGraphic(bTest2->Id(),iPosition2,KTestData); - RetireGc(); - - // compare the graphic in both positions. Contents of each rect should be identical - TestForIdenticalBitmaps(); - - delete bTest2; - delete bTest; - } - - /** - @SYMTestCaseID GRAPHICS-WSERV-0010 - - @SYMPREQ PREQ1246 - - @SYMTestCaseDesc Check an animation can be constructed using a UID, manipulated and then drawn - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions The test app creates CWsGraphicBitmapAnimation object via a UID and then draws the object to the screen - - @SYMTestExpectedResults The object is drawn - */ -void CWsGraphicBase::DoTestDrawAnimatedGraphicUIDL() - { - iTestLog.Append(_L("DrawAnimatedGraphicUID")); - - // test TWsGraphicAnimation first - iAnimData.Play(EFalse); - - // load the animation via a UID - CIclLoader* iclLoader; - iclLoader = new(ELeave) CIclLoader(); - iclLoader->ConstructL(KSymBallFile,ETrue,EFalse); // this is actually an asynchronous operation, so we give it a chance to execute below - - while (iclLoader->Ok() && iclLoader->GetId().Id() == KDummyGraphicId) - { - iTimer->Wait(1000); - } - - Test(iclLoader->Ok()); // fail test if iclLoder experienced problems - - iAnimId = iclLoader->GetId(); - - // animation is ready to be drawn. draw to the 1st position only - PrepGc(); - iGc->DrawWsGraphic(iAnimId,iPosition1,iAnimData.Pckg()); - RetireGc(); - - // run the animation - RunAnimation(iclLoader->FrameCount()); - - // compare the graphic in both positions. - TestForDifferentBitmaps(); - - iTimer->Cancel(); - iclLoader->Cancel(); - delete iclLoader; - } - - /** - @SYMTestCaseID GRAPHICS-WSERV-0011 - - @SYMPREQ PREQ1246 - - @SYMTestCaseDesc Check an animation can be constructed using an ID, manipulated and then drawn - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions The test app creates CWsGraphicBitmapAnimation object via an ID and then draws the object to the screen - - @SYMTestExpectedResults The object is drawn - */ -void CWsGraphicBase::DoTestDrawAnimatedGraphicIDL() - { - iTestLog.Append(_L("DrawAnimatedGraphicID")); - iAnimData.Play(ETrue); - iAnimData.Play(ETrue); - Test(iAnimData.Loops()); - iAnimData.Pause(); - Test(!iAnimData.IsPlaying()); - Test(iAnimData.IsPaused()); - iAnimData.Pause(); - Test(iAnimData.Loops()); - iAnimData.Play(EFalse); - Test(!iAnimData.Loops()); - Test(!iAnimData.IsStopping()); - Test(!iAnimData.IsStopped()); - - // load the animation via an ID - CIclLoader* iclLoader; - iclLoader = new(ELeave) CIclLoader(); - iclLoader->ConstructL(KSymBallFile,EFalse,EFalse); - - while (iclLoader->GetId().Id() == KDummyGraphicId) - { - iTimer->Wait(1000); - } - iAnimId = iclLoader->GetId(); - - PrepGc(); - iGc->DrawWsGraphic(iAnimId,iPosition1,iAnimData.Pckg()); - RetireGc(); - - // run the animation - RunAnimation(iclLoader->FrameCount()); - - // compare the graphic in both positions - TestForDifferentBitmaps(); - - iAnimData.Stop(ETrue); - Test(iAnimData.IsStopped()); - iAnimData.Pause(); - iAnimData.Play(EFalse); - iAnimData.Stop(EFalse); - Test(!iAnimData.IsStopped()); - - iTimer->Cancel(); - iclLoader->Cancel(); - delete iclLoader; - } - - /** - @SYMTestCaseID GRAPHICS-WSERV-0012 - - @SYMPREQ PREQ1246 - - @SYMTestCaseDesc Check an animation can be constructed and then replaced, manipulated and then drawn - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions The test app creates CWsGraphicBitmapAnimation object, the replaces it, and then draws the object - to the screen - - @SYMTestExpectedResults The object is drawn - */ -void CWsGraphicBase::DoTestDrawReplaceGraphicIDL() - { - // test TWsGraphicControlStateTimed first - iTestLog.Append(_L("DrawAnimatedGraphicID")); - _LIT8(KTestData,"HelloWorld"); - iAnimData.Stop(ETrue); - - // load and replace the animation - CIclLoader* iclLoader; - iclLoader = new(ELeave) CIclLoader(); - iclLoader->ConstructL(KSymBallFile,false,true); - - while (iclLoader->GetId().Id() == KDummyGraphicId) - { - iTimer->Wait(1000); - } - iAnimId = iclLoader->GetId(); - - // draw the animation in two positions - PrepGc(); - iGc->DrawWsGraphic(iAnimId,iPosition1,KTestData); - RetireGc(); - - // run the animation - RunAnimation(iclLoader->FrameCount()); - - // compare the graphic in both positions - // Expect identical, as the command buffer used in position1 animation is invalid, therefore never drawn - TestForIdenticalBitmaps(); - - iTimer->Cancel(); - iclLoader->Cancel(); - delete iclLoader; - } - - /** - @SYMTestCaseID GRAPHICS-WSERV-0013 - - @SYMPREQ PREQ1246 - - @SYMTestCaseDesc Check the creation and manipulation of an RWsGraphicMsgBuf object - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions Creates and manipulates an RWsGraphicMsgBuf object - - @SYMTestExpectedResults RWsGraphicMsgBuf functions correctly - */ -void CWsGraphicBase::DoTestCreateMsgGraphicMsgBufL() - { - iTestLog.Append(_L("CreateMsgGraphicMsgBuf")); - - _LIT(KNebraska,"Nebraska"); - _LIT8(KTesting,"Testing"); - RWsGraphicMsgBuf msgBuf; - msgBuf.CleanupClosePushL(); - msgBuf.Append(TUid::Uid(0x12345670),KTesting()); - msgBuf.Append(TUid::Uid(0x12345671),KNebraska()); - msgBuf.Append(TUid::Uid(0x12345670),KTesting()); - - Test(TUid::Uid(0x12345670)==msgBuf.TypeId(0)); - - msgBuf.Remove(0); - const TInt count = msgBuf.Count(); - Test(count == 2); - - iAnimData.Play(ETrue); - msgBuf.Append(iAnimData); - Test(msgBuf.Count() == 3); - - CleanupStack::Pop(); - - // load the animation via a UID - CIclLoader* iclLoader; - iclLoader = new(ELeave) CIclLoader(); - iclLoader->ConstructL(KSymBallFile,true,false); - - while (iclLoader->GetId().Id() == KDummyGraphicId) - { - iTimer->Wait(1000); - } - iAnimId = iclLoader->GetId(); - - PrepGc(); - iGc->DrawWsGraphic(iAnimId,iPosition1,msgBuf.Pckg()); - RetireGc(); - - // run the animation - RunAnimation(iclLoader->FrameCount()); - - // compare the graphic in both positions - TestForDifferentBitmaps(); - - iTimer->Cancel(); - iclLoader->Cancel(); - delete iclLoader; - msgBuf.Close(); - } - - - - /** - @SYMTestCaseID GRAPHICS-WSERV-0014 - - @SYMPREQ PREQ1246 - - @SYMTestCaseDesc Check an animation is not drawn if the command buffer it uses is invalid - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions The test app creates CWsGraphicBitmapAnimation object then draws the animation using - a valid and invalid command buffer - - @SYMTestExpectedResults The animation is drawn while using the valid command buffer but not drawn - when the command buffer is invalid - */ -void CWsGraphicBase::DoTestDrawInvalidAnimationIDL() - { - // test TWsGraphicControlStateTimed first, a valid command buffer - iTestLog.Append(_L("DrawInvalidAnimationID")); - iAnimData.Play(ETrue); - - // invalid command buffer - _LIT8(KTestData2,"12345678"); - - // load and replace the animation - CIclLoader* iclLoader; - iclLoader = new(ELeave) CIclLoader(); - iclLoader->ConstructL(KSymBallFile,false,false); - - while (iclLoader->GetId().Id() == KDummyGraphicId) - { - iTimer->Wait(1000); - } - iAnimId = iclLoader->GetId(); - - PrepGc(); - iGc->DrawWsGraphic(iAnimId,iPosition1,iAnimData.Pckg()); - iGc->DrawWsGraphic(iAnimId,iPosition2,KTestData2); - RetireGc(); - - // run the animation - RunAnimation(iclLoader->FrameCount()); - - // compare the graphic in both positions - TestForDifferentBitmaps(); - - iAnimData.Stop(ETrue); - iTimer->Cancel(); - iclLoader->Cancel(); - delete iclLoader; - } - - /** - @SYMTestCaseID GRAPHICS-WSERV-0015 - - @SYMPREQ PREQ1246 - - @SYMTestCaseDesc Check the sharing of graphics with other clients. - - @SYMTestPriority High - - @SYMTestStatus Implemented - - @SYMTestActions The test app creates CWsGraphicBitmap object an then tests the sharing of the object with - different clients - - @SYMTestExpectedResults The CWsGraphicBitmap object is shared correctly - */ -void CWsGraphicBase::DoTestDrawSharedGraphicL() - { - iTestLog.Append(_L("DrawSharedGraphic")); - _LIT_SECURE_ID(KTestSecId,0x10003a4b); - - TUid uid1 = {0x12000021}; - TWsGraphicId twsGraphicId1(uid1); - - CFbsBitmap bitmap1; - CFbsBitmap mask1; - - User::LeaveIfError(bitmap1.Load(MY_TEST_BITMAP,0)); - mask1.Create(bitmap1.SizeInPixels(),iScreen->DisplayMode()); - - CWsGraphicBitmap* bTest = CWsGraphicBitmap::NewL(twsGraphicId1.Uid(), &bitmap1,&mask1); - - // Try to draw the graphic in an client. Should fail as graphic is not shared - TRAPD(err, LaunchNewProcessL(KTestExe1, EFalse)); - Test(err == KErrNone); - - // Share the graphic globally and try to draw the graphic in an client. Should pass - Test(bTest->ShareGlobally()==KErrNone); - TRAP(err, LaunchNewProcessL(KTestExe2, ETrue)); - Test(err == KErrNone); - - // Unshare the graphic globally and try to draw the graphic in an client. Should fail - Test(bTest->UnShareGlobally()==KErrNone); - TRAP(err, LaunchNewProcessL(KTestExe3, EFalse)); - Test(err == KErrNone); - - // Share the graphic to a client and try to draw the graphic in the client. Should pass - Test(bTest->Share(KTestSecId)==KErrNone); - TRAP(err, LaunchNewProcessL(KTestExe4, ETrue)); - Test(err == KErrNone); - - // Unshare the graphic to a client and try to draw the graphic in the client. Should fail - Test(bTest->UnShare(KTestSecId)==KErrNone); - TRAP(err, LaunchNewProcessL(KTestExe5, EFalse)); - Test(err == KErrNone); - - delete bTest; - } - - -void CWsGraphicBase::DoTestL(TInt aTestNo) - { - switch (aTestNo) - { - case ETestCreateGraphicUID: - DoTestCreateGraphicUidL(); - break; - case ETestCreateGraphicID: - DoTestCreateGraphicIdL(); - break; - case ETestUpdateGraphic: - DoTestUpdateGraphicL(); - break; - case ETestDeleteGraphic: - DoTestDeleteGraphicL(); - break; - case ETestDrawInvalideBitmapID: - DoTestDrawInvalidBitmapIDL(); - break; - case ETestDrawGraphic: - DoTestDrawGraphicL(); - break; - case ETestDrawGraphicID: - DoTestDrawGraphicIDL(); - break; - case ETestDrawGraphicCompare: - DoTestDrawGraphicCompareL(); - break; - case ETestDrawGraphicSessionHandle: - DoTestDrawGraphicSessionHandleL(); - break; -#ifdef _DEBUG - // These tests require debug-only API to simulate OOM. Running - // the tests in non-debug environments invalidates the tests. - case ETestDrawAnimatedGraphicUID: - DoTestDrawAnimatedGraphicUIDL(); - break; - case ETestDrawAnimatedGraphicID: - DoTestDrawAnimatedGraphicIDL(); - break; - case ETestCreateMsgGraphicMsgBuf: - DoTestCreateMsgGraphicMsgBufL(); - break; - case ETestDrawReplaceGraphicID: - DoTestDrawReplaceGraphicIDL(); - break; - case ETestDrawInvalidAnimationID: - DoTestDrawInvalidAnimationIDL(); - break; -#endif - case ETestDrawSharedGraphic: - DoTestDrawSharedGraphicL(); - break; - } - RDebug::Print(iTestLog); - iTestLog.Delete(0,256); - } - -// writes out to WSERV.log if error -void CWsGraphicBase::Test(TInt aCondition) - { - if(!aCondition) - { - TBuf buf; - _LIT(Fail,"AUTO Failed in WsGraphics Test : "); - buf.Append(Fail); - buf.Append(iTestLog); - RDebug::Print(buf); - RProcess().Terminate(KErrGeneral); - } - } - -// -// CWsGraphicBase::RunAnimation -// Redraw event listener is launched & the -// animation is given a total of KAnimationRunTime (25 seconds) to run a single loop -// -void CWsGraphicBase::RunAnimation(TInt aFrameCount) - { - --aFrameCount; // account for the fact the initial frame is already displayed - iRedrawListener->SetFrameCount(aFrameCount); - iRedrawListener->RequestRedraw(); - iTimer->Wait(KAnimationRunTime); - if (iAnimData.IsPlaying()) - { - iAnimData.Stop(ETrue); - } - iRedrawListener->Cancel(); - iAnimData.Stop(EFalse); - Test(iRedrawListener->GetFrameCount() == 0); // ensure the animation ran through until last frame - } - -void MainL() - { - TInt testCount = KErrNone; - - //Read the argument from the command line for current screen number - TBuf<256> commandLine; - User::CommandLine(commandLine); - TLex lex(commandLine); - lex.NextToken(); - lex.SkipSpace(); - TInt screenNumber=(TInt)lex.Get(); - - CActiveScheduler* activeScheduler=new(ELeave) CActiveScheduler; - CActiveScheduler::Install(activeScheduler); - CleanupStack::PushL(activeScheduler); - - CWsGraphicBase testBase(screenNumber); - testBase.ConstructL(); - - // run through all the tests - while (testCount < CWsGraphicBase::ETestMaxNumberOfTests) - { - testBase.DoTestL(testCount); - testCount++; - } - - CleanupStack::PopAndDestroy(activeScheduler); - } - -GLDEF_C TInt E32Main() - { - CTrapCleanup* cleanUpStack=CTrapCleanup::New(); - if(cleanUpStack==NULL) - { - return KErrNoMemory; - } - TRAPD(err, MainL()); - delete cleanUpStack; - return(err); - }