|
1 /* |
|
2 * Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // CLASS HEADER |
|
20 #include "UT_CAlfLCTAnchorLayout.h" |
|
21 |
|
22 // EXTERNAL INCLUDES |
|
23 #include <EUnitMacros.h> |
|
24 |
|
25 |
|
26 // INTERNAL INCLUDES |
|
27 #include "alf/alflctAnchorLayout.h" |
|
28 #include "alf/alfdecklayout.h" |
|
29 #include "alf/alfenv.h" |
|
30 #include "alf/alfcontrol.h" |
|
31 |
|
32 #include <aknutils.h> |
|
33 #include <aknlayout2def.h> |
|
34 #include <aknlayoutscalable_avkon.cdl.h> |
|
35 #include <aknlayout2hierarchy.h> |
|
36 |
|
37 |
|
38 // ================= |
|
39 // Test Class |
|
40 // ================= |
|
41 |
|
42 // CONSTRUCTION |
|
43 UT_CAlfLCTAnchorLayout* UT_CAlfLCTAnchorLayout::NewL() |
|
44 { |
|
45 UT_CAlfLCTAnchorLayout* self = UT_CAlfLCTAnchorLayout::NewLC(); |
|
46 CleanupStack::Pop(); |
|
47 |
|
48 return self; |
|
49 } |
|
50 |
|
51 UT_CAlfLCTAnchorLayout* UT_CAlfLCTAnchorLayout::NewLC() |
|
52 { |
|
53 UT_CAlfLCTAnchorLayout* self = new( ELeave ) UT_CAlfLCTAnchorLayout(); |
|
54 CleanupStack::PushL( self ); |
|
55 |
|
56 self->ConstructL(); |
|
57 |
|
58 return self; |
|
59 } |
|
60 |
|
61 // Destructor (virtual by CBase) |
|
62 UT_CAlfLCTAnchorLayout::~UT_CAlfLCTAnchorLayout() |
|
63 { |
|
64 } |
|
65 |
|
66 // Default constructor |
|
67 UT_CAlfLCTAnchorLayout::UT_CAlfLCTAnchorLayout() |
|
68 { |
|
69 } |
|
70 |
|
71 // Second phase construct |
|
72 void UT_CAlfLCTAnchorLayout::ConstructL() |
|
73 { |
|
74 // The ConstructL from the base class CEUnitTestSuiteClass must be called. |
|
75 // It generates the test case table. |
|
76 CEUnitTestSuiteClass::ConstructL(); |
|
77 } |
|
78 |
|
79 // ================= |
|
80 // Tests |
|
81 // ================= |
|
82 |
|
83 void UT_CAlfLCTAnchorLayout::SetupL( ) |
|
84 { |
|
85 iEnv = CAlfEnv::NewL(); |
|
86 |
|
87 iControl = new( ELeave ) CAlfControl; |
|
88 iControl->ConstructL( *iEnv ); |
|
89 |
|
90 iLayout = (CAlfLCTAnchorLayout*)iControl->AppendLayoutL( EAlfLayoutTypeLCTAnchor ); |
|
91 } |
|
92 |
|
93 void UT_CAlfLCTAnchorLayout::Teardown( ) |
|
94 { |
|
95 if ( iControl && iEnv && !iEnv->FindControl( iControl->Id() ) ) |
|
96 { |
|
97 delete iControl; |
|
98 iControl = NULL; |
|
99 } |
|
100 delete iEnv; |
|
101 iEnv = NULL; |
|
102 } |
|
103 |
|
104 void UT_CAlfLCTAnchorLayout::UT_CAlfLCTAnchorLayout_CAlfLCTAnchorLayoutL( ) |
|
105 { |
|
106 __UHEAP_MARK; |
|
107 CAlfLCTAnchorLayout* visual = new (ELeave) CAlfLCTAnchorLayout; |
|
108 delete visual; |
|
109 __UHEAP_MARKEND; |
|
110 } |
|
111 |
|
112 void UT_CAlfLCTAnchorLayout::UT_CAlfLCTAnchorLayout_ConstructLL( ) |
|
113 { |
|
114 __UHEAP_MARK; |
|
115 CAlfLCTAnchorLayout* visual = new (ELeave) CAlfLCTAnchorLayout; |
|
116 CleanupStack::PushL( visual ); |
|
117 visual->ConstructL( *iControl ); |
|
118 CleanupStack::PopAndDestroy( visual ); |
|
119 __UHEAP_MARKEND; |
|
120 } |
|
121 |
|
122 void UT_CAlfLCTAnchorLayout::UT_CAlfLCTAnchorLayout_RemoveAndDestroyAllDL( ) |
|
123 { |
|
124 iLayout->RemoveAndDestroyAllD(); |
|
125 iLayout = NULL; |
|
126 } |
|
127 |
|
128 void UT_CAlfLCTAnchorLayout::UT_CAlfLCTAnchorLayout_SetAnchors( ) |
|
129 { |
|
130 // first calculate what the layout would be based on the current screen size |
|
131 TSize parentSize; |
|
132 AknLayoutUtils::LayoutMetricsSize(AknLayoutUtils::EScreen, parentSize); |
|
133 TAlfRealSize parentAlfSize(parentSize); |
|
134 iLayout->SetFlag(EAlfVisualFlagManualLayout); |
|
135 iLayout->SetSize(parentAlfSize); |
|
136 |
|
137 #ifdef _DEBUG |
|
138 TAlfTimedPoint checkSize = iLayout->Size(); |
|
139 #endif // _DEBUG |
|
140 |
|
141 TInt cell_app_pane_g1_variety = 0; // not marked or highlighted |
|
142 TAknWindowLineLayout cell_app_pane_g1 = AknLayoutScalable_Avkon::cell_app_pane_g1(cell_app_pane_g1_variety).LayoutLineNoEmptys(); |
|
143 |
|
144 TRect parentRect(parentSize); |
|
145 TAknLayoutRect layoutRect; |
|
146 layoutRect.LayoutRect( parentRect, cell_app_pane_g1); |
|
147 TRect cell_app_pane_g1_Rect = layoutRect.Rect(); |
|
148 TSize cell_app_pane_g1_Size = cell_app_pane_g1_Rect.Size(); |
|
149 |
|
150 // now the results |
|
151 TInt drawingIndex = 0; |
|
152 TAlfTimedPoint timedPoint; |
|
153 TAknLayoutHierarchyComponentHandle cell_app_pane_g1_Handle( |
|
154 KUidAknLayoutSystemId_AknLayout2, |
|
155 AknLayoutScalable_Avkon::KCdlInterfaceUidValue, |
|
156 AknLayoutScalable_Avkon::EApiId_cell_app_pane_g1); |
|
157 cell_app_pane_g1_Handle.SetVarietyIndex(cell_app_pane_g1_variety); |
|
158 |
|
159 iLayout->SetAnchors(drawingIndex, cell_app_pane_g1_Handle, timedPoint); |
|
160 |
|
161 TPoint resultPos; |
|
162 TSize resultSize; |
|
163 iLayout->ChildPos(drawingIndex, resultPos); |
|
164 iLayout->ChildSize(drawingIndex, resultSize); |
|
165 |
|
166 EUNIT_ASSERT_EQUALS( cell_app_pane_g1_Rect.iTl, resultPos ); |
|
167 EUNIT_ASSERT_EQUALS( cell_app_pane_g1_Size, resultSize ); |
|
168 } |
|
169 |
|
170 // ================= |
|
171 // Test Table |
|
172 // ================= |
|
173 |
|
174 |
|
175 EUNIT_BEGIN_TEST_TABLE( |
|
176 UT_CAlfLCTAnchorLayout, |
|
177 "Alf Unit Tests", |
|
178 "UNIT" ) |
|
179 |
|
180 EUNIT_TEST( |
|
181 "CAlfLCTAnchorLayout - test ", |
|
182 "CAlfLCTAnchorLayout", |
|
183 "CAlfLCTAnchorLayout", |
|
184 "FUNCTIONALITY", |
|
185 SetupL, UT_CAlfLCTAnchorLayout_CAlfLCTAnchorLayoutL, Teardown) |
|
186 |
|
187 EUNIT_TEST( |
|
188 "ConstructL - test ", |
|
189 "CAlfLCTAnchorLayout", |
|
190 "ConstructL", |
|
191 "FUNCTIONALITY", |
|
192 SetupL, UT_CAlfLCTAnchorLayout_ConstructLL, Teardown) |
|
193 |
|
194 EUNIT_TEST( |
|
195 "RemoveAndDestroyAllD - test ", |
|
196 "CAlfLCTAnchorLayout", |
|
197 "RemoveAndDestroyAllD", |
|
198 "FUNCTIONALITY", |
|
199 SetupL, UT_CAlfLCTAnchorLayout_RemoveAndDestroyAllDL, Teardown) |
|
200 |
|
201 /** TODO: FIX TEST |
|
202 * THIS TEST IS NOT USED BECAUSE TEST FAILS. |
|
203 * REQUIRES FURTHER STUDY AND FIX. |
|
204 EUNIT_TEST( |
|
205 "SetAnchors - test ", |
|
206 "CAlfLCTAnchorLayout", |
|
207 "SetAnchors", |
|
208 "FUNCTIONALITY", |
|
209 SetupL, UT_CAlfLCTAnchorLayout_SetAnchors, Teardown) |
|
210 */ |
|
211 |
|
212 EUNIT_END_TEST_TABLE |
|
213 |
|
214 // END OF FILE |