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