os/graphics/windowing/windowserver/test/t_stress/src/stresslet.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 /**
    17  @file
    18  @test
    19  @internalComponent
    20 */
    21 
    22 #include "stresslet.h"
    23 #include "panic.h"
    24 
    25 //
    26 // CStresslet::CRedrawHandler
    27 //
    28 
    29 CStresslet::CRedrawHandler* CStresslet::CRedrawHandler::NewL(CStresslet& aStresslet)
    30 	{
    31 	CRedrawHandler * self = new (ELeave) CRedrawHandler(aStresslet);
    32 	CleanupStack::PushL (self);
    33 	self->ConstructL ();
    34 	CleanupStack::Pop ();	
    35 	return self;
    36 	}
    37 
    38 CStresslet::CRedrawHandler::~CRedrawHandler ()
    39 	{
    40 	Cancel ();
    41 	}
    42 
    43 CStresslet::CRedrawHandler::CRedrawHandler(CStresslet& aStresslet) :
    44 	CActive(EPriorityNormal), iStresslet(aStresslet)
    45 	{
    46 	}
    47 
    48 void CStresslet::CRedrawHandler::ConstructL ()
    49 	{
    50 	CActiveScheduler::Add (this);
    51 	iStresslet.Session().RedrawReady (&iStatus);
    52 	SetActive ();
    53 	}
    54 
    55 void CStresslet::CRedrawHandler::RunL ()
    56 	{
    57 	iStresslet.Session().GetRedraw (iRedrawEvent);
    58 
    59 	if(iRedrawEvent.Handle () != 0)
    60 		{
    61 		iStresslet.HandleRedraw (iRedrawEvent);
    62 		}
    63 
    64 	iStresslet.Session().RedrawReady (&iStatus); 
    65 	SetActive ();								 
    66 	}
    67 
    68 void CStresslet::CRedrawHandler::DoCancel ()
    69 	{
    70 	iStresslet.Session().RedrawReadyCancel ();
    71 	}
    72 
    73 //
    74 // CStresslet::CEventHandler
    75 //
    76 
    77 CStresslet::CEventHandler* CStresslet::CEventHandler::NewL (CStresslet& aStresslet)
    78 	{
    79 	CEventHandler * self = new (ELeave) CEventHandler(aStresslet);
    80 	CleanupStack::PushL (self);
    81 	self->ConstructL ();
    82 	CleanupStack::Pop (); 
    83 	return self;
    84 	}
    85 
    86 CStresslet::CEventHandler::~CEventHandler ()
    87 	{
    88 	Cancel ();
    89 	}
    90 
    91 CStresslet::CEventHandler::CEventHandler (CStresslet& aStresslet) :
    92 	CActive(EPriorityNormal), iStresslet(aStresslet)
    93 	{
    94 	}
    95 
    96 void CStresslet::CEventHandler::ConstructL ()
    97 	{
    98 	CActiveScheduler::Add (this);
    99 	iStresslet.Session().EventReady (&iStatus);
   100 	SetActive ();
   101 	}
   102 
   103 void CStresslet::CEventHandler::RunL ()
   104 	{
   105 	iStresslet.Session().GetEvent (iEvent);
   106 
   107 	iStresslet.HandleEvent (iEvent);
   108 	
   109 	iStresslet.Session().EventReady (&iStatus);		
   110 	SetActive ();									
   111 	
   112 	}
   113 
   114 void CStresslet::CEventHandler::DoCancel ()
   115 	{
   116 	iStresslet.Session().EventReadyCancel ();
   117 	}
   118 
   119 //
   120 // CStresslet::CStresslet
   121 //
   122 
   123 CStresslet::CStresslet (MTestStepReporter& aReporter) :
   124 	iReporter(aReporter)
   125 	{
   126 	}
   127 
   128 MTestStepReporter& CStresslet::Reporter ()
   129 	{
   130 	return iReporter;
   131 	}
   132 
   133 void CStresslet::ConcludeNow (void)
   134 	{
   135 	CActiveScheduler::Stop ();
   136 	}
   137 
   138 void CStresslet::LaunchL (CStresslet* aStresslet)
   139 	{
   140 	CStresslet* obj = aStresslet;
   141 
   142 	CActiveScheduler* runner = new (ELeave) CActiveScheduler;
   143 	CleanupStack::PushL (runner);
   144 	CActiveScheduler::Install (runner);
   145 
   146 	obj->ConstructL();
   147 	
   148 	CActiveScheduler::Start (); //runner
   149 
   150 	delete obj;
   151 
   152 	CleanupStack::PopAndDestroy (runner);
   153 	}
   154 
   155 void CStresslet::ConstructL()
   156 	{
   157 	User::LeaveIfError(iWs.Connect());
   158 	iRedrawHandler = CRedrawHandler::NewL (*this);
   159 	iEventHandler = CEventHandler::NewL (*this);
   160 	iScreenDevice = new (ELeave)CWsScreenDevice(iWs);
   161 	User::LeaveIfError(iScreenDevice->Construct ());
   162 	User::LeaveIfError(iScreenDevice->CreateContext (iGc));
   163 	StartL ();
   164 	}
   165 
   166 CStresslet::~CStresslet ()
   167 	{
   168 	delete iRedrawHandler;
   169 	delete iEventHandler;
   170 	iWs.Close ();
   171 	}
   172 
   173 RWsSession& CStresslet::Session ()
   174 	{
   175 	return iWs;
   176 	}
   177 
   178 CWindowGc& CStresslet::WindowGc()
   179 	{
   180 	__ASSERT_ALWAYS(iGc, Panic(EPanic1));
   181 	return *iGc;
   182 	}