windowing/windowserver/test/tdynamicres/src/wsdynamicresbase.cpp
changeset 187 9f66f99ee56f
parent 103 2717213c588a
equal deleted inserted replaced
103:2717213c588a 187:9f66f99ee56f
   142 void CWsDynamicResBase::Pause(TInt aMilliseconds)
   142 void CWsDynamicResBase::Pause(TInt aMilliseconds)
   143 	{
   143 	{
   144 	User::After(TTimeIntervalMicroSeconds32(aMilliseconds * 1000));
   144 	User::After(TTimeIntervalMicroSeconds32(aMilliseconds * 1000));
   145 	}
   145 	}
   146 
   146 
   147 /**	Creates the normal scenario used by these tests.
       
   148  *  With a large window behind and small window in front.
       
   149  *  If the windows already exist then they are just repositioned and redrawn.
       
   150  * 	@param	aOuterRect	Position of back window
       
   151  * 	@param	aOuterColor	Background colour for back window
       
   152  * 	@param	aInnerRect	Position of front window
       
   153  * 	@param	aInnerColor	Background colour for front window
       
   154  * 
       
   155  **/
       
   156 void CWsDynamicResBase::MakeTestWindowPairL(TRect aOuterRect,TRgb aOuterColor,TRect aInnerRect,TRgb aInnerColor)
       
   157 	{
       
   158 	if (!iTestBack.WsHandle())
       
   159 		{
       
   160 		iTestBack=RWindow(iSession);
       
   161 		ASSERT_EQUALS_X(iTestBack.Construct(iGroup, ++iWindowHandle), KErrNone);
       
   162 #ifdef  FLICKER
       
   163 		iTestBack.Activate();
       
   164 #endif
       
   165 		iTestBack.SetRequiredDisplayMode(iDisplayMode);
       
   166 		iTestBack.SetBackgroundColor(aOuterColor);
       
   167 		iTestBack.SetExtent(aOuterRect.iTl,aOuterRect.Size());
       
   168 #ifndef FLICKER
       
   169 		iTestBack.Activate();
       
   170 #endif
       
   171 		}
       
   172 	else
       
   173 		{
       
   174 		iTestBack.SetRequiredDisplayMode(iDisplayMode);
       
   175 		iTestBack.SetBackgroundColor(aOuterColor);
       
   176 		iTestBack.SetExtent(aOuterRect.iTl,aOuterRect.Size());
       
   177 		}
       
   178 	iTestBack.BeginRedraw();
       
   179 	ActivateWithWipe(iGc,iTestBack,aOuterColor);
       
   180 	iGc->Deactivate();
       
   181 	iTestBack.EndRedraw();
       
   182 	iTestBack.SetVisible(ETrue);
       
   183 	
       
   184 	if (!iTestFront.WsHandle())
       
   185 		{
       
   186 		iTestFront=RWindow(iSession);
       
   187 		ASSERT_EQUALS_X(iTestFront.Construct(iGroup, ++iWindowHandle), KErrNone);
       
   188 #ifdef FLICKER
       
   189 		iTestFront.Activate();
       
   190 #endif
       
   191 		iTestFront.SetRequiredDisplayMode(iDisplayMode);
       
   192 		iTestFront.SetBackgroundColor(aInnerColor);	
       
   193 		iTestFront.SetExtent(aInnerRect.iTl,aInnerRect.Size());
       
   194 
       
   195 #ifndef FLICKER
       
   196 		iTestFront.Activate();
       
   197 #endif
       
   198 		}
       
   199 	else
       
   200 		{
       
   201 		iTestFront.SetRequiredDisplayMode(iDisplayMode);
       
   202 		iTestFront.SetBackgroundColor(aInnerColor);
       
   203 		iTestFront.SetExtent(aInnerRect.iTl,aInnerRect.Size());
       
   204 		}
       
   205 	
       
   206 	DrawPlainUI(iTestFront,EFalse,aInnerColor);
       
   207 	iTestFront.SetVisible(ETrue);
       
   208 	
       
   209 	}
       
   210 
       
   211 void CWsDynamicResBase::LargerTestWindow(TInt aPercentOfBack)
   147 void CWsDynamicResBase::LargerTestWindow(TInt aPercentOfBack)
   212 	{
   148 	{
   213 	TRect newPos=iTestPos;
   149 	TRect newPos=iTestPos;
   214 	TSize backSize=iTestPos.Size();
   150 	TSize backSize=iTestPos.Size();
   215 	newPos.Grow((aPercentOfBack-100)*backSize.iWidth/200,(aPercentOfBack-100)*backSize.iHeight/200);
   151 	newPos.Grow((aPercentOfBack-100)*backSize.iWidth/200,(aPercentOfBack-100)*backSize.iHeight/200);
   219 		iTestFront.SetExtent(newPos.iTl,newPos.Size());
   155 		iTestFront.SetExtent(newPos.iTl,newPos.Size());
   220 		}
   156 		}
   221 	
   157 	
   222 	}
   158 	}
   223 
   159 
   224 /** Destroys some or all of the test windows so the test can loop (or test the state after destruction.
       
   225  *  The windows are destroyed when the test exits normally.
       
   226  * 	Child windows are automatically killed when parent window is killed!
       
   227  * 
       
   228  **/
       
   229 void CWsDynamicResBase::DestroyTestWindowPair(TBool aKillTestBack,TBool aKillTestFront,TBool aKillTestChildren)
       
   230 	{
       
   231 	if (aKillTestBack && iTestBack.WsHandle())
       
   232 		{
       
   233 		iTestBack.Close();
       
   234 		}
       
   235 	if (aKillTestFront && iTestFront.WsHandle())
       
   236 		{
       
   237 		iTestFront.Close();
       
   238 		}
       
   239 	if (aKillTestChildren)
       
   240 		{
       
   241 		if (iTestChild.WsHandle())
       
   242 			{
       
   243 			iTestChild.Close();
       
   244 			}
       
   245 		if (iTestSecondChild.WsHandle())
       
   246 			{
       
   247 			iTestSecondChild.Close();
       
   248 			}
       
   249 		}
       
   250 	}
       
   251 /**	Creates a child window inside the front window of the usual test scenario
       
   252 *  With a large window behind and small window in front.
       
   253  *  If the windows already exist then they are just repositioned and redrawn.
       
   254  * 	@param	aOuterRect	Position of back window
       
   255  * 	@param	aOuterColor	Background colour for back window
       
   256  * 	@param	aInnerRect	Position of front window
       
   257  * 	@param	aInnerColor	Background colour for front window
       
   258  * 	@param	aChildRect	Position of child window
       
   259  * 	@param	aChildColor	Background colour for child window
       
   260  * 	@param	aSecondChildRect	Position of Second child window
       
   261  * 	@param	aSecondChildColor	Background colour for Second child window
       
   262  * 
       
   263  **/
       
   264 void CWsDynamicResBase::MakeTestWindowTripleL(TRect aOuterRect,TRgb aOuterColor,TRect aInnerRect,TRgb aInnerColor,TRect aChildRect,TRgb aChildColor,TRect aSecondChildRect,TRgb aSecondChildColor)
       
   265 	{
       
   266 	MakeTestWindowTripleL(aOuterRect,aOuterColor,aInnerRect,aInnerColor,aChildRect,aChildColor);
       
   267 
       
   268 	MakeExtraChildWindowL(iTestChild,aSecondChildRect,aSecondChildColor);
       
   269 	}
       
   270 
       
   271 /**	Creates a child window inside the front window of the usual test scenario
       
   272 *  With a large window behind and small window in front.
       
   273  *  If the windows already exist then they are just repositioned and redrawn.
       
   274  * 	@param	aOuterRect	Position of back window
       
   275  * 	@param	aOuterColor	Background colour for back window
       
   276  * 	@param	aInnerRect	Position of front window
       
   277  * 	@param	aInnerColor	Background colour for front window
       
   278  * 	@param	aChildRect	Position of child window
       
   279  * 	@param	aChildColor	Background colour for child window
       
   280  *  @param	aSecondChildRect	Position of second child window
       
   281  * 	@param	aSecondChildColor	Background colour for second child window
       
   282  * 
       
   283  **/
       
   284 void CWsDynamicResBase::CreateTestWindowQuadL(TRect aOuterRect,TRgb aOuterColor,TRect aInnerRect,TRgb aInnerColor,TRect aChildRect,TRgb aChildColor,TRect aSecondChildRect,TRgb aSecondChildColor)
       
   285 	{
       
   286 	MakeTestWindowTripleL(aOuterRect,aOuterColor,aInnerRect,aInnerColor,aChildRect,aChildColor);
       
   287 	
       
   288 	MakeExtraChildWindowL(iTestFront,aSecondChildRect,aSecondChildColor);
       
   289 	}
       
   290 
   160 
   291 void CWsDynamicResBase::MakeExtraChildWindowL(const RWindowBase& aFromParent,TRect aChildRect,TRgb aChildColor)
   161 void CWsDynamicResBase::MakeExtraChildWindowL(const RWindowBase& aFromParent,TRect aChildRect,TRgb aChildColor)
   292 	{
   162 	{
   293 	ASSERT(aFromParent.WsHandle());
   163 	ASSERT(aFromParent.WsHandle());
   294 	if (!iTestSecondChild.WsHandle())
   164 	if (!iTestSecondChild.WsHandle())
   345 CWindowGc*	CWsDynamicResBase::BeginActivateWithWipe(const TRegion& aRegion,RWindow& aWin,TRgb aColor)
   215 CWindowGc*	CWsDynamicResBase::BeginActivateWithWipe(const TRegion& aRegion,RWindow& aWin,TRgb aColor)
   346 	{
   216 	{
   347 	return CWsDynamicResWinBase::BeginActivateWithWipe(aRegion,aWin,aColor);
   217 	return CWsDynamicResWinBase::BeginActivateWithWipe(aRegion,aWin,aColor);
   348 	}
   218 	}
   349 
   219 
   350 /**	Creates a child window inside the front window of the usual test scenario
       
   351 *  With a large window behind and small window in front.
       
   352  *  If the windows already exist then they are just repositioned and redrawn.
       
   353  * 	@param	aOuterRect	Position of back window
       
   354  * 	@param	aOuterColor	Background colour for back window
       
   355  * 	@param	aInnerRect	Position of front window
       
   356  * 	@param	aInnerColor	Background colour for front window
       
   357  * 	@param	aChildRect	Position of child window
       
   358  * 	@param	aChildColor	Background colour for child window
       
   359  * 
       
   360  **/
       
   361 void CWsDynamicResBase::MakeTestWindowTripleL(TRect aOuterRect,TRgb aOuterColor,TRect aInnerRect,TRgb aInnerColor,TRect aChildRect,TRgb aChildColor)
       
   362 	{
       
   363 	MakeTestWindowPairL(aOuterRect,aOuterColor,aInnerRect,aInnerColor);
       
   364 	ASSERT(iTestFront.WsHandle());
       
   365 	
       
   366 	if (!iTestChild.WsHandle())
       
   367 		{
       
   368 		iTestChild=RWindow(iSession);
       
   369 		ASSERT_EQUALS_X(iTestChild.Construct(iTestFront, ++iWindowHandle), KErrNone);
       
   370 		iTestChild.SetRequiredDisplayMode(iDisplayMode);
       
   371 		}
       
   372 	iTestChild.SetBackgroundColor(aChildColor);
       
   373 	iTestChild.SetExtent(aChildRect.iTl,aChildRect.Size());
       
   374 	iTestChild.Activate();
       
   375 	iTestChild.BeginRedraw();
       
   376 	iGc->Activate(iCompare);
       
   377 	iGc->SetBrushColor(iBlue);
       
   378 	iGc->Clear();
       
   379 	iGc->Deactivate();
       
   380 	iTestChild.EndRedraw();
       
   381 	iTestChild.SetVisible(ETrue);
       
   382 	}
       
   383 /**	
   220 /**	
   384  * 	Generates a valid surfaceID for the current display mode.
   221  * 	Generates a valid surfaceID for the current display mode.
   385  * 	This is then used in negative testing.
   222  * 	This is then used in negative testing.
   386  * 
   223  * 
   387  * 
   224  *