1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/windowing/windowserver/test/t_stress/src/stresslet.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,182 @@
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 +//
1.18 +
1.19 +/**
1.20 + @file
1.21 + @test
1.22 + @internalComponent
1.23 +*/
1.24 +
1.25 +#include "stresslet.h"
1.26 +#include "panic.h"
1.27 +
1.28 +//
1.29 +// CStresslet::CRedrawHandler
1.30 +//
1.31 +
1.32 +CStresslet::CRedrawHandler* CStresslet::CRedrawHandler::NewL(CStresslet& aStresslet)
1.33 + {
1.34 + CRedrawHandler * self = new (ELeave) CRedrawHandler(aStresslet);
1.35 + CleanupStack::PushL (self);
1.36 + self->ConstructL ();
1.37 + CleanupStack::Pop ();
1.38 + return self;
1.39 + }
1.40 +
1.41 +CStresslet::CRedrawHandler::~CRedrawHandler ()
1.42 + {
1.43 + Cancel ();
1.44 + }
1.45 +
1.46 +CStresslet::CRedrawHandler::CRedrawHandler(CStresslet& aStresslet) :
1.47 + CActive(EPriorityNormal), iStresslet(aStresslet)
1.48 + {
1.49 + }
1.50 +
1.51 +void CStresslet::CRedrawHandler::ConstructL ()
1.52 + {
1.53 + CActiveScheduler::Add (this);
1.54 + iStresslet.Session().RedrawReady (&iStatus);
1.55 + SetActive ();
1.56 + }
1.57 +
1.58 +void CStresslet::CRedrawHandler::RunL ()
1.59 + {
1.60 + iStresslet.Session().GetRedraw (iRedrawEvent);
1.61 +
1.62 + if(iRedrawEvent.Handle () != 0)
1.63 + {
1.64 + iStresslet.HandleRedraw (iRedrawEvent);
1.65 + }
1.66 +
1.67 + iStresslet.Session().RedrawReady (&iStatus);
1.68 + SetActive ();
1.69 + }
1.70 +
1.71 +void CStresslet::CRedrawHandler::DoCancel ()
1.72 + {
1.73 + iStresslet.Session().RedrawReadyCancel ();
1.74 + }
1.75 +
1.76 +//
1.77 +// CStresslet::CEventHandler
1.78 +//
1.79 +
1.80 +CStresslet::CEventHandler* CStresslet::CEventHandler::NewL (CStresslet& aStresslet)
1.81 + {
1.82 + CEventHandler * self = new (ELeave) CEventHandler(aStresslet);
1.83 + CleanupStack::PushL (self);
1.84 + self->ConstructL ();
1.85 + CleanupStack::Pop ();
1.86 + return self;
1.87 + }
1.88 +
1.89 +CStresslet::CEventHandler::~CEventHandler ()
1.90 + {
1.91 + Cancel ();
1.92 + }
1.93 +
1.94 +CStresslet::CEventHandler::CEventHandler (CStresslet& aStresslet) :
1.95 + CActive(EPriorityNormal), iStresslet(aStresslet)
1.96 + {
1.97 + }
1.98 +
1.99 +void CStresslet::CEventHandler::ConstructL ()
1.100 + {
1.101 + CActiveScheduler::Add (this);
1.102 + iStresslet.Session().EventReady (&iStatus);
1.103 + SetActive ();
1.104 + }
1.105 +
1.106 +void CStresslet::CEventHandler::RunL ()
1.107 + {
1.108 + iStresslet.Session().GetEvent (iEvent);
1.109 +
1.110 + iStresslet.HandleEvent (iEvent);
1.111 +
1.112 + iStresslet.Session().EventReady (&iStatus);
1.113 + SetActive ();
1.114 +
1.115 + }
1.116 +
1.117 +void CStresslet::CEventHandler::DoCancel ()
1.118 + {
1.119 + iStresslet.Session().EventReadyCancel ();
1.120 + }
1.121 +
1.122 +//
1.123 +// CStresslet::CStresslet
1.124 +//
1.125 +
1.126 +CStresslet::CStresslet (MTestStepReporter& aReporter) :
1.127 + iReporter(aReporter)
1.128 + {
1.129 + }
1.130 +
1.131 +MTestStepReporter& CStresslet::Reporter ()
1.132 + {
1.133 + return iReporter;
1.134 + }
1.135 +
1.136 +void CStresslet::ConcludeNow (void)
1.137 + {
1.138 + CActiveScheduler::Stop ();
1.139 + }
1.140 +
1.141 +void CStresslet::LaunchL (CStresslet* aStresslet)
1.142 + {
1.143 + CStresslet* obj = aStresslet;
1.144 +
1.145 + CActiveScheduler* runner = new (ELeave) CActiveScheduler;
1.146 + CleanupStack::PushL (runner);
1.147 + CActiveScheduler::Install (runner);
1.148 +
1.149 + obj->ConstructL();
1.150 +
1.151 + CActiveScheduler::Start (); //runner
1.152 +
1.153 + delete obj;
1.154 +
1.155 + CleanupStack::PopAndDestroy (runner);
1.156 + }
1.157 +
1.158 +void CStresslet::ConstructL()
1.159 + {
1.160 + User::LeaveIfError(iWs.Connect());
1.161 + iRedrawHandler = CRedrawHandler::NewL (*this);
1.162 + iEventHandler = CEventHandler::NewL (*this);
1.163 + iScreenDevice = new (ELeave)CWsScreenDevice(iWs);
1.164 + User::LeaveIfError(iScreenDevice->Construct ());
1.165 + User::LeaveIfError(iScreenDevice->CreateContext (iGc));
1.166 + StartL ();
1.167 + }
1.168 +
1.169 +CStresslet::~CStresslet ()
1.170 + {
1.171 + delete iRedrawHandler;
1.172 + delete iEventHandler;
1.173 + iWs.Close ();
1.174 + }
1.175 +
1.176 +RWsSession& CStresslet::Session ()
1.177 + {
1.178 + return iWs;
1.179 + }
1.180 +
1.181 +CWindowGc& CStresslet::WindowGc()
1.182 + {
1.183 + __ASSERT_ALWAYS(iGc, Panic(EPanic1));
1.184 + return *iGc;
1.185 + }