os/graphics/windowing/windowserver/test/tauto/tdirecta2.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/windowing/windowserver/test/tauto/tdirecta2.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,185 @@
     1.4 +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// Test Direct Screen Access on a screen that supports transparency
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +#include "tdirecta2.h"
    1.22 +
    1.23 +const TInt KMainTestOrdinalPriority=65535;
    1.24 +const TInt KOntopOfAllOthersTestOrdinalPriority=65537;
    1.25 +
    1.26 +CTDirect2::CTDirect2(CTestStep* aStep):
    1.27 +	CTWsGraphicsBase(aStep)
    1.28 +	{
    1.29 +	}
    1.30 +
    1.31 +CTDirect2::~CTDirect2()
    1.32 +	{
    1.33 +	delete iDsa;
    1.34 +	delete iUnderWindow;
    1.35 +	delete iOverWindow;
    1.36 +	delete iScreenDevice;
    1.37 +	delete iWindowGroup;
    1.38 +	delete iTimer;
    1.39 +
    1.40 +	// put focus back to current screen as this test changed the focus screen to primary screen
    1.41 +	TheClient->iWs.SetFocusScreen(iTest->iScreenNumber);
    1.42 +	}
    1.43 +
    1.44 +void CTDirect2::ConstructL()
    1.45 +	{
    1.46 +	// the following line makes sure that a console object hidden outside of
    1.47 +	// screens range doesn't affect test results being on top of tested objects
    1.48 +	TheClient->iGroup->GroupWin()->SetOrdinalPosition(0, KMainTestOrdinalPriority);
    1.49 +	}
    1.50 +
    1.51 +TInt CTDirect2::Timeout(TAny* aDirect2)
    1.52 +	{
    1.53 +	static_cast<CTDirect2*>(aDirect2)->HandleTimeout();
    1.54 +	return KErrNone;
    1.55 +	}
    1.56 +
    1.57 +void CTDirect2::HandleTimeout()
    1.58 +	{
    1.59 +	// Send window group to back to avoid possibility of it
    1.60 +	// interfering with other parts of this test
    1.61 +	iWindowGroup->GroupWin()->SetOrdinalPosition(0, -1);
    1.62 +
    1.63 +	iTimer->Cancel(); // Don't call back again
    1.64 +	TEST(EFalse); // Fail the test, as we didn't get a DSA abort within timeout period
    1.65 +	iTestCaseComplete = ETrue; // Move to next test case
    1.66 +	}
    1.67 +
    1.68 +void CTDirect2::AbortNow(RDirectScreenAccess::TTerminationReasons /*aReason*/)
    1.69 +	{
    1.70 +	iTimer->Cancel(); // As soon as abort is received, we don't need the timer anymore
    1.71 +	}
    1.72 +
    1.73 +void CTDirect2::Restart(RDirectScreenAccess::TTerminationReasons /*aReason*/)
    1.74 +	{
    1.75 +	// Send window group to back to avoid possibility of it
    1.76 +	// interfering with other tests
    1.77 +	iWindowGroup->GroupWin()->SetOrdinalPosition(0, -1);
    1.78 +
    1.79 +	iTestCaseComplete = ETrue; // Move to next test case
    1.80 +
    1.81 +	// Don't bother restarting DSA, we were only interested in making sure the abort was sent by wserv
    1.82 +	}
    1.83 +
    1.84 +// Starts DSA on a topmost window, then puts a translucent window ontop of it
    1.85 +// to make sure wserv sends a DSA Abort even though the translucent window
    1.86 +// hasn't changed the visible area of the DSA window
    1.87 +void CTDirect2::StartTranslucentWindowOverDsaL()
    1.88 +	{
    1.89 +	// Use a new window group so we can put windows ontop of all others
    1.90 +	iWindowGroup = new(ELeave) CTWindowGroup(TheClient);
    1.91 +	iWindowGroup->ConstructL();
    1.92 +
    1.93 +	// Create new blank window
    1.94 +	iUnderWindow = new(ELeave) CTBlankWindow();
    1.95 +	iUnderWindow->SetUpL(TPoint(10,10), TSize(100,100), iWindowGroup, *TheClient->iGc);
    1.96 +	iUnderWindow->SetColor(TRgb(0,192,0));
    1.97 +
    1.98 +	// Make window group visible ontop of all others
    1.99 +	User::LeaveIfError(iWindowGroup->GroupWin()->SetOrdinalPositionErr(0, KOntopOfAllOthersTestOrdinalPriority));
   1.100 +	TheClient->Flush();
   1.101 +
   1.102 +	// Call Finish() to wait until under window has been rendered.
   1.103 +	// Once window has been rendered, we can be sure window server has
   1.104 +	// calculated the "top visible" region of the window.
   1.105 +	TheClient->iWs.Finish();
   1.106 +
   1.107 +	// Start DSA on under window
   1.108 +	iScreenDevice = new(ELeave) CWsScreenDevice(TheClient->iWs);
   1.109 +	User::LeaveIfError(iScreenDevice->Construct(iTest->iScreenNumber));
   1.110 +	iDsa = CDirectScreenAccess::NewL(TheClient->iWs, *iScreenDevice, *iUnderWindow->BaseWin(), *this);
   1.111 +	iDsa->StartL();
   1.112 +	
   1.113 +	// Put translucent window ontop so as to reduce the top visible area, but leave the
   1.114 +	// visible area unchanged (as the translucent window doesn't change the visible area
   1.115 +	// of the window underneath it).
   1.116 +	iOverWindow = new(ELeave) CTTitledWindow();
   1.117 +	_LIT(KTranslucentWindowTitle, "Translucent window");
   1.118 +	iOverWindow->SetUpL(TPoint(60,60), TSize(150,100), iWindowGroup, *TheClient->iGc, NULL, ETrue);
   1.119 +	TWindowTitle windowTitle(KTranslucentWindowTitle);
   1.120 +	iOverWindow->SetTitle(windowTitle);
   1.121 +	iOverWindow->SetColor(TRgb(192, 0, 0, 128));
   1.122 +	TheClient->Flush();
   1.123 +
   1.124 +	// Start a timer, if the timeout triggers, fail the test, as we should get
   1.125 +	// an abort DSA from wserv within the timeout
   1.126 +	iTimer = CPeriodic::NewL(CActive::EPriorityStandard);
   1.127 +	const TInt KTimeoutPeriod = 5000000; // 5 seconds should give the client plenty of time to respond to the abort
   1.128 +	iTimer->Start(KTimeoutPeriod, 0, TCallBack(CTDirect2::Timeout, this));
   1.129 +
   1.130 +	// Do nothing more here, once over win is rendered, wserv should cause CAbortTest::AbortNow
   1.131 +	// to be called
   1.132 +	}
   1.133 +
   1.134 +void CTDirect2::RunTestCaseL(TInt aCurTestCase)
   1.135 +	{
   1.136 +	((CTDirect2Step*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
   1.137 +	switch(aCurTestCase)
   1.138 +		{
   1.139 +/**
   1.140 +@SYMTestCaseID		GRAPHICS-WSERV-0176
   1.141 +
   1.142 +@SYMDEF             PDEF116863
   1.143 +
   1.144 +@SYMTestCaseDesc    Overlapping a translucent window ontop of a DSA window should abort DSA 
   1.145 +
   1.146 +@SYMTestPriority    High
   1.147 +
   1.148 +@SYMTestStatus      Implemented
   1.149 +
   1.150 +@SYMTestActions     Start DSA on a blank window.
   1.151 +					Then place a translucent window so that it partially overlaps the DSA window.
   1.152 +
   1.153 +@SYMTestExpectedResults Wserv should send a DSA abort when the translucent window is placed ontop of the DSA window.
   1.154 +*/
   1.155 +	case 1:
   1.156 +		((CTDirect2Step*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0176"));
   1.157 +		if (!iOnceOnly)
   1.158 +			{
   1.159 +			_LIT(DSA1,"Translucent window overlaping DSA window");
   1.160 +			INFO_PRINTF1(DSA1);
   1.161 +			StartTranslucentWindowOverDsaL(); // call this only once
   1.162 +			iOnceOnly = ETrue;
   1.163 +			}
   1.164 +		if (!iTestCaseComplete)
   1.165 +			{
   1.166 +			// Keep calling this test case until iTestCaseComplete is true
   1.167 +			ResetCounter(aCurTestCase-1);
   1.168 +			}
   1.169 +		else
   1.170 +			{
   1.171 +			iOnceOnly = EFalse;
   1.172 +			// Move to next test case in sequence
   1.173 +			iTestCaseComplete = EFalse;
   1.174 +			}	
   1.175 +		break;
   1.176 +
   1.177 +	default:
   1.178 +		INFO_PRINTF1(_L("Test complete\n"));
   1.179 +		((CTDirect2Step*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
   1.180 +		((CTDirect2Step*)iStep)->CloseTMSGraphicsStep();
   1.181 +		TestComplete();
   1.182 +		break;
   1.183 +		}
   1.184 +	((CTDirect2Step*)iStep)->RecordTestResultL();
   1.185 +	}
   1.186 +
   1.187 +__WS_CONSTRUCT_STEP__(Direct2)
   1.188 +