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 |
/**
|
sl@0
|
17 |
@file
|
sl@0
|
18 |
@test
|
sl@0
|
19 |
@internalComponent - Internal Symbian test coverage code for GraphicDrawer related code
|
sl@0
|
20 |
*/
|
sl@0
|
21 |
|
sl@0
|
22 |
#include "gdcoverage.h"
|
sl@0
|
23 |
#include <fbs.h>
|
sl@0
|
24 |
#include <bitdev.h>
|
sl@0
|
25 |
#include <bitstd.h>
|
sl@0
|
26 |
#include <gdi.h>
|
sl@0
|
27 |
#include <graphics/wsscreendevice.h>
|
sl@0
|
28 |
|
sl@0
|
29 |
const TInt KDefaultScreen = 0;
|
sl@0
|
30 |
|
sl@0
|
31 |
//
|
sl@0
|
32 |
CWsGraphicDrawerCoverage* CWsGraphicDrawerCoverage::NewL()
|
sl@0
|
33 |
{
|
sl@0
|
34 |
return new(ELeave) CWsGraphicDrawerCoverage;
|
sl@0
|
35 |
}
|
sl@0
|
36 |
|
sl@0
|
37 |
CWsGraphicDrawerCoverage::~CWsGraphicDrawerCoverage()
|
sl@0
|
38 |
{
|
sl@0
|
39 |
}
|
sl@0
|
40 |
|
sl@0
|
41 |
void CWsGraphicDrawerCoverage::ConstructL(
|
sl@0
|
42 |
MWsGraphicDrawerEnvironment& aEnv,
|
sl@0
|
43 |
const TGraphicDrawerId& aId,
|
sl@0
|
44 |
MWsClient& aOwner,
|
sl@0
|
45 |
const TDesC8& aData)
|
sl@0
|
46 |
{
|
sl@0
|
47 |
BaseConstructL(aEnv, aId, aOwner);
|
sl@0
|
48 |
|
sl@0
|
49 |
iScreenId = KDefaultScreen;
|
sl@0
|
50 |
if (aData.Length()>0)
|
sl@0
|
51 |
iScreenId = aData[0];
|
sl@0
|
52 |
MWsScreen* scr = aEnv.Screen(iScreenId);
|
sl@0
|
53 |
User::LeaveIfNull(scr);
|
sl@0
|
54 |
|
sl@0
|
55 |
//NGA supports MWsScreenDevice and non-NGA supports MWsScreenConfig, MWsFrontBuffer, MWsBackBuffer
|
sl@0
|
56 |
MWsScreenDevice* screenDevice = scr->ObjectInterface<MWsScreenDevice>();
|
sl@0
|
57 |
if(screenDevice)
|
sl@0
|
58 |
{
|
sl@0
|
59 |
//empty for now
|
sl@0
|
60 |
}
|
sl@0
|
61 |
else
|
sl@0
|
62 |
{
|
sl@0
|
63 |
MWsScreenConfig* cfg = scr->ObjectInterface<MWsScreenConfig>();
|
sl@0
|
64 |
User::LeaveIfNull(cfg);
|
sl@0
|
65 |
TSize sizeInPixels = cfg->ScreenModeSizeInPixels();
|
sl@0
|
66 |
__ASSERT_ALWAYS(sizeInPixels.iWidth>0 && sizeInPixels.iHeight>0, User::Invariant());
|
sl@0
|
67 |
__ASSERT_ALWAYS(cfg->Stride()>0, User::Invariant());
|
sl@0
|
68 |
__ASSERT_ALWAYS(cfg->ScalingFactor()==TSize(1,1), User::Invariant());
|
sl@0
|
69 |
__ASSERT_ALWAYS(cfg->Origin()==TPoint(0,0), User::Invariant());
|
sl@0
|
70 |
|
sl@0
|
71 |
MWsFrontBuffer* fBuffer = scr->ObjectInterface<MWsFrontBuffer>();
|
sl@0
|
72 |
User::LeaveIfNull(fBuffer);
|
sl@0
|
73 |
__ASSERT_ALWAYS(fBuffer->GetBits()!=NULL, User::Invariant());
|
sl@0
|
74 |
__ASSERT_ALWAYS(fBuffer->GetBitGc()!=NULL, User::Invariant());
|
sl@0
|
75 |
}
|
sl@0
|
76 |
|
sl@0
|
77 |
MWsScreenRedraw* redraw = scr->ObjectInterface<MWsScreenRedraw>();
|
sl@0
|
78 |
User::LeaveIfNull(redraw);
|
sl@0
|
79 |
}
|
sl@0
|
80 |
|
sl@0
|
81 |
void CWsGraphicDrawerCoverage::HandleMessage(const TDesC8& aData)
|
sl@0
|
82 |
{
|
sl@0
|
83 |
// wserv already check data size, and won't invoke this handler if it's empty
|
sl@0
|
84 |
TBuf8<1> ack;
|
sl@0
|
85 |
ack.Append(KGdCoverageInfoSig);
|
sl@0
|
86 |
|
sl@0
|
87 |
MWsGraphicDrawerEnvironment& env = Env();
|
sl@0
|
88 |
MWsScreen* scr = env.Screen(iScreenId);
|
sl@0
|
89 |
MWsScreenRedraw* redraw = scr->ObjectInterface<MWsScreenRedraw>();
|
sl@0
|
90 |
|
sl@0
|
91 |
switch (aData[0])
|
sl@0
|
92 |
{
|
sl@0
|
93 |
case KGdCoverageCmdQuery:
|
sl@0
|
94 |
SendInfo();
|
sl@0
|
95 |
break;
|
sl@0
|
96 |
|
sl@0
|
97 |
case KGdCoverageCmdCoverRedraw:
|
sl@0
|
98 |
{
|
sl@0
|
99 |
//Hint: for extra coverage in ScheduleRender find a way to call
|
sl@0
|
100 |
//CWsTop::WindowServer()->AnimationScheduler()->Animate(*scr);
|
sl@0
|
101 |
|
sl@0
|
102 |
//cannot create a real observer, for coverage null is sufficient
|
sl@0
|
103 |
redraw->SetObserver(NULL);
|
sl@0
|
104 |
redraw->IsUpdatePending();
|
sl@0
|
105 |
TTimeIntervalMicroSeconds interval(1);
|
sl@0
|
106 |
redraw->ScheduleRender(interval);
|
sl@0
|
107 |
const TRegion *r = redraw->AnimationRegion();
|
sl@0
|
108 |
redraw->UpdateDevice();
|
sl@0
|
109 |
//although redraw is actually a CScreenRedraw, we cannot include
|
sl@0
|
110 |
//the ScreenRedraw.h here so the following methods are not available:
|
sl@0
|
111 |
//redraw->AddRedrawRegion(*r, ETrue, ERedrawTopOnly);
|
sl@0
|
112 |
//redraw->OnAnimation();
|
sl@0
|
113 |
break;
|
sl@0
|
114 |
}
|
sl@0
|
115 |
|
sl@0
|
116 |
default:
|
sl@0
|
117 |
SendMessage(ack);
|
sl@0
|
118 |
break;
|
sl@0
|
119 |
}
|
sl@0
|
120 |
}
|
sl@0
|
121 |
|
sl@0
|
122 |
void CWsGraphicDrawerCoverage::DoDraw(MWsGc& /*aGc*/, const TRect& /*aRect*/, const TDesC8& /*aData*/) const
|
sl@0
|
123 |
{
|
sl@0
|
124 |
}
|
sl@0
|
125 |
|
sl@0
|
126 |
void CWsGraphicDrawerCoverage::SendInfo()
|
sl@0
|
127 |
{
|
sl@0
|
128 |
TPckgBuf<TGdCoverageInfo> buf;
|
sl@0
|
129 |
MWsScreen* scr = Env().Screen(iScreenId);
|
sl@0
|
130 |
if (scr)
|
sl@0
|
131 |
{
|
sl@0
|
132 |
buf().iSignature = KGdCoverageInfoSig;
|
sl@0
|
133 |
buf().iNumTests = 1;
|
sl@0
|
134 |
}
|
sl@0
|
135 |
TInt err = SendMessage(buf);
|
sl@0
|
136 |
__ASSERT_ALWAYS(err>=KErrNone, User::Invariant());
|
sl@0
|
137 |
}
|
sl@0
|
138 |
|