os/graphics/windowing/windowserver/test/t_eventchecker/src/openwfc/scenechecker.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
#include "scenechecker.h"
sl@0
    17
#include <graphics/wselement.h>
sl@0
    18
#include "panics.h"
sl@0
    19
sl@0
    20
CSceneChecker* CSceneChecker::NewL(MWsGraphicDrawerEnvironment& /*aEnv*/, MWsScreen& aScreen)
sl@0
    21
	{
sl@0
    22
	CSceneChecker* self = new(ELeave) CSceneChecker(aScreen);
sl@0
    23
	return self;
sl@0
    24
	}
sl@0
    25
sl@0
    26
CSceneChecker::CSceneChecker(MWsScreen& aScreen)
sl@0
    27
	: iScreen(aScreen)
sl@0
    28
	{
sl@0
    29
	}
sl@0
    30
sl@0
    31
CSceneChecker::~CSceneChecker()
sl@0
    32
	{
sl@0
    33
	iScene = NULL;
sl@0
    34
	iBottomElement = NULL;
sl@0
    35
	iElementsWithoutAssociatedWindow.Reset();
sl@0
    36
	}
sl@0
    37
sl@0
    38
void CSceneChecker::SetScene(MWsScene* aScene)
sl@0
    39
	{
sl@0
    40
	iScene = aScene;
sl@0
    41
	}
sl@0
    42
sl@0
    43
void CSceneChecker::OnEnd()
sl@0
    44
	{
sl@0
    45
	if(iElementSetChanged)
sl@0
    46
		{
sl@0
    47
		if(!iBottomElement)
sl@0
    48
			{
sl@0
    49
			CHK_ASSERT_ALWAYS(iElementSetCount == 0, EEventCheckerPanicElementCountMismatch);
sl@0
    50
			return;
sl@0
    51
			}
sl@0
    52
sl@0
    53
		//walk upwards
sl@0
    54
		MWsElement* layer = iBottomElement;
sl@0
    55
		CHK_ASSERT_ALWAYS(!layer->ElementBelow(), EEventCheckerPanicElementLinksMismatch);
sl@0
    56
		TInt index = 0;
sl@0
    57
		while(layer->ElementAbove())
sl@0
    58
			{
sl@0
    59
			MWsElement* previousElement = layer;
sl@0
    60
			layer = layer->ElementAbove();
sl@0
    61
			index++;
sl@0
    62
			CHK_ASSERT_ALWAYS(layer->ElementBelow() == previousElement, EEventCheckerPanicElementLinksMismatch);
sl@0
    63
			}
sl@0
    64
		CHK_ASSERT_ALWAYS(iElementSetCount == index + 1, EEventCheckerPanicElementCountMismatch);
sl@0
    65
		//walk downwards
sl@0
    66
		CHK_ASSERT_ALWAYS(!layer->ElementAbove(), EEventCheckerPanicElementLinksMismatch);
sl@0
    67
		while(layer->ElementBelow())
sl@0
    68
			{
sl@0
    69
			MWsElement* previousElement = layer;
sl@0
    70
			layer = layer->ElementBelow();
sl@0
    71
			index--;
sl@0
    72
			CHK_ASSERT_ALWAYS(layer->ElementAbove() == previousElement, EEventCheckerPanicElementLinksMismatch);
sl@0
    73
			}
sl@0
    74
		CHK_ASSERT_ALWAYS(layer == iBottomElement, EEventCheckerPanicElementLinksMismatch);
sl@0
    75
		CHK_ASSERT_ALWAYS(index == 0, EEventCheckerPanicElementLinksMismatch);
sl@0
    76
		}
sl@0
    77
sl@0
    78
	CHK_ASSERT_ALWAYS(iElementsWithoutAssociatedWindow.Count() == 0, EEventCheckerPanicElementsWithoutAssociatedWindow);
sl@0
    79
	}
sl@0
    80
	
sl@0
    81
TAny* CSceneChecker::ResolveObjectInterface(TUint aTypeId)
sl@0
    82
	{
sl@0
    83
	switch(aTypeId)
sl@0
    84
		{
sl@0
    85
		case MWsWindowTreeObserver::EWsObjectInterfaceId:
sl@0
    86
			return static_cast<MWsWindowTreeObserver*>(this);
sl@0
    87
		}	
sl@0
    88
	return iScene->ResolveObjectInterface(aTypeId);
sl@0
    89
	}
sl@0
    90
sl@0
    91
TInt CSceneChecker::SetSceneRotation(TSceneRotation aRotation)
sl@0
    92
	{
sl@0
    93
	return iScene->SetSceneRotation(aRotation);
sl@0
    94
	}
sl@0
    95
sl@0
    96
MWsScene::TSceneRotation CSceneChecker::SceneRotation() const
sl@0
    97
	{
sl@0
    98
	return iScene->SceneRotation();
sl@0
    99
	}
sl@0
   100
sl@0
   101
MWsElement* CSceneChecker::CreateSceneElementL()
sl@0
   102
	{
sl@0
   103
	return iScene->CreateSceneElementL();
sl@0
   104
	}
sl@0
   105
sl@0
   106
void CSceneChecker::DestroySceneElement(MWsElement* aElement)
sl@0
   107
	{
sl@0
   108
	if(iBottomElement == aElement || aElement->ElementAbove() || aElement->ElementBelow()) //part of the layer set
sl@0
   109
		{
sl@0
   110
		iElementSetCount--;
sl@0
   111
		iElementSetChanged = ETrue;
sl@0
   112
		if(aElement == iBottomElement)
sl@0
   113
			iBottomElement = iBottomElement->ElementAbove();
sl@0
   114
		}
sl@0
   115
	iScene->DestroySceneElement(aElement);
sl@0
   116
	}
sl@0
   117
sl@0
   118
void CSceneChecker::ComposePendingScene(TSurfaceId& aOffScreenTarget, TRequestStatus* aCompleted)
sl@0
   119
	{
sl@0
   120
	iScene->ComposePendingScene(aOffScreenTarget, aCompleted);
sl@0
   121
	}
sl@0
   122
sl@0
   123
TInt CSceneChecker::InsertSceneElement(MWsElement* aInsertElement, MWsElement* aSubordinateElement)
sl@0
   124
	{
sl@0
   125
	TInt err = KErrNone;
sl@0
   126
sl@0
   127
	iElementSetCount++;
sl@0
   128
	iElementSetChanged = ETrue;
sl@0
   129
	
sl@0
   130
    if(!aSubordinateElement)
sl@0
   131
        {
sl@0
   132
        iBottomElement = aInsertElement;
sl@0
   133
        }
sl@0
   134
    else if(aInsertElement == iBottomElement)
sl@0
   135
        {
sl@0
   136
        iBottomElement = iBottomElement->ElementAbove();
sl@0
   137
        }
sl@0
   138
    
sl@0
   139
    TUint32 flags;
sl@0
   140
    aInsertElement->GetRenderStageFlags(flags);
sl@0
   141
	if(!(flags & MWsElement::EElementIsIndirectlyRenderedUserInterface)) //the UI element won't be associated with any window
sl@0
   142
		{
sl@0
   143
		err = iElementsWithoutAssociatedWindow.Append(aInsertElement);
sl@0
   144
		}
sl@0
   145
	
sl@0
   146
	if(!err)
sl@0
   147
		err = iScene->InsertSceneElement(aInsertElement, aSubordinateElement);
sl@0
   148
sl@0
   149
	//cleanup on error
sl@0
   150
	if(err)
sl@0
   151
		{
sl@0
   152
		const TInt index = iElementsWithoutAssociatedWindow.Find(aInsertElement);
sl@0
   153
		if(index >= 0)
sl@0
   154
			iElementsWithoutAssociatedWindow.Remove(index);
sl@0
   155
		}
sl@0
   156
sl@0
   157
	return err;
sl@0
   158
	}
sl@0
   159
sl@0
   160
TInt CSceneChecker::RemoveSceneElement(MWsElement* aRemoveElement)
sl@0
   161
	{
sl@0
   162
	iElementSetCount--;
sl@0
   163
	iElementSetChanged = ETrue;
sl@0
   164
	if(aRemoveElement == iBottomElement)
sl@0
   165
		iBottomElement = iBottomElement->ElementAbove();
sl@0
   166
	return iScene->RemoveSceneElement(aRemoveElement);
sl@0
   167
	}
sl@0
   168
sl@0
   169
TInt CSceneChecker::RegisterSurface(const TSurfaceId& aSurface)
sl@0
   170
	{
sl@0
   171
	return iScene->RegisterSurface(aSurface);
sl@0
   172
	}
sl@0
   173
sl@0
   174
TInt CSceneChecker::UnregisterSurface(const TSurfaceId& aSurface)
sl@0
   175
	{
sl@0
   176
	return iScene->UnregisterSurface(aSurface);
sl@0
   177
	}
sl@0
   178
sl@0
   179
void CSceneChecker::NodeCreated(const MWsWindowTreeNode& /*aWindowTreeNode*/, MWsWindowTreeNode const* /*aParent*/)
sl@0
   180
	{
sl@0
   181
	}
sl@0
   182
sl@0
   183
void CSceneChecker::NodeReleased(const MWsWindowTreeNode& /*aWindowTreeNode*/)
sl@0
   184
	{
sl@0
   185
	}
sl@0
   186
sl@0
   187
void CSceneChecker::NodeActivated(const MWsWindowTreeNode& /*aWindowTreeNode*/)
sl@0
   188
	{
sl@0
   189
	}
sl@0
   190
sl@0
   191
void CSceneChecker::NodeExtentChanged(const MWsWindowTreeNode& /*aWindowTreeNode*/, const TRect& /*aRect*/)
sl@0
   192
	{
sl@0
   193
	}
sl@0
   194
sl@0
   195
void CSceneChecker::SiblingOrderChanged(const MWsWindowTreeNode& /*aWindowTreeNode*/, TInt /*aNewPosition*/)
sl@0
   196
	{
sl@0
   197
	}
sl@0
   198
sl@0
   199
void CSceneChecker::MovedToWindowGroup(const MWsWindowTreeNode& /*aWindowTreeNode*/, const MWsWindowTreeNode& /*aNewWindowGroup*/)
sl@0
   200
	{
sl@0
   201
	}
sl@0
   202
sl@0
   203
void CSceneChecker::FlagChanged(const MWsWindowTreeNode& /*aWindowTreeNode*/, MWsWindowTreeObserver::TFlags /*aAttribute*/, TBool /*aNewValue*/)
sl@0
   204
	{
sl@0
   205
	}
sl@0
   206
sl@0
   207
void CSceneChecker::AttributeChanged(const MWsWindowTreeNode& /*aWindowTreeNode*/, MWsWindowTreeObserver::TAttributes /*aAttribute*/)
sl@0
   208
	{
sl@0
   209
	}
sl@0
   210
sl@0
   211
void CSceneChecker::TransparentRegionChanged(const MWsWindowTreeNode& /*aWindowTreeNode*/, const TRegion& /*aNewTransparentRegion*/, const TRegion* /*aNewOpaqueRegion*/)
sl@0
   212
	{
sl@0
   213
	}
sl@0
   214
sl@0
   215
void CSceneChecker::ElementAdded(const MWsWindowTreeNode& aWindowTreeNode, const MWsElement& aElement)
sl@0
   216
	{
sl@0
   217
	CHK_ASSERT_ALWAYS(aWindowTreeNode.Window(), EEventCheckerPanicAcquireElementWithoutWindow);
sl@0
   218
	MWsScreen* eventScreen = aWindowTreeNode.Window()->WsScreen();
sl@0
   219
	if(eventScreen == &iScreen)
sl@0
   220
		{
sl@0
   221
		const TInt index = iElementsWithoutAssociatedWindow.Find(&aElement);
sl@0
   222
		CHK_ASSERT_ALWAYS(index >= 0, EEventCheckerPanicAcquireElementForUnknownElement);
sl@0
   223
		iElementsWithoutAssociatedWindow.Remove(index);
sl@0
   224
		}
sl@0
   225
	}
sl@0
   226
sl@0
   227
void CSceneChecker::FadeCountChanged(const MWsWindowTreeNode& /*aWindowTreeNode*/, TInt /*aFadeCount*/)
sl@0
   228
	{
sl@0
   229
	}
sl@0
   230
sl@0
   231
void CSceneChecker::FadeAllChildren(const MWsWindowTreeNode& /*aWindowTreeNode*/, TBool /*aFaded*/)
sl@0
   232
	{
sl@0
   233
	}
sl@0
   234
sl@0
   235
void CSceneChecker::WindowGroupChained(const MWsWindowTreeNode& /*aParent*/, const MWsWindowTreeNode& /*aChild*/)
sl@0
   236
	{
sl@0
   237
	}
sl@0
   238
sl@0
   239
void CSceneChecker::WindowGroupChainBrokenAfter(const MWsWindowTreeNode& /*aWindowGroup*/)
sl@0
   240
	{
sl@0
   241
	}
sl@0
   242
sl@0
   243