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_CAlfLCTTextVisual.h" |
|
21 |
|
22 // EXTERNAL INCLUDES |
|
23 #include <EUnitMacros.h> |
|
24 |
|
25 |
|
26 // INTERNAL INCLUDES |
|
27 #include "alf/alflcttextvisual.h" |
|
28 #include "alf/alfdecklayout.h" |
|
29 #include "alf/alfenv.h" |
|
30 #include "alf/alfcontrol.h" |
|
31 |
|
32 #include <aknlayout2def.h> |
|
33 #include <aknlayoutscalable_avkon.cdl.h> |
|
34 #include <aknlayout2hierarchy.h> |
|
35 |
|
36 |
|
37 // ================= |
|
38 // Test Class |
|
39 // ================= |
|
40 |
|
41 // CONSTRUCTION |
|
42 UT_CAlfLCTTextVisual* UT_CAlfLCTTextVisual::NewL() |
|
43 { |
|
44 UT_CAlfLCTTextVisual* self = UT_CAlfLCTTextVisual::NewLC(); |
|
45 CleanupStack::Pop(); |
|
46 |
|
47 return self; |
|
48 } |
|
49 |
|
50 UT_CAlfLCTTextVisual* UT_CAlfLCTTextVisual::NewLC() |
|
51 { |
|
52 UT_CAlfLCTTextVisual* self = new( ELeave ) UT_CAlfLCTTextVisual(); |
|
53 CleanupStack::PushL( self ); |
|
54 |
|
55 self->ConstructL(); |
|
56 |
|
57 return self; |
|
58 } |
|
59 |
|
60 // Destructor (virtual by CBase) |
|
61 UT_CAlfLCTTextVisual::~UT_CAlfLCTTextVisual() |
|
62 { |
|
63 } |
|
64 |
|
65 // Default constructor |
|
66 UT_CAlfLCTTextVisual::UT_CAlfLCTTextVisual() |
|
67 { |
|
68 } |
|
69 |
|
70 // Second phase construct |
|
71 void UT_CAlfLCTTextVisual::ConstructL() |
|
72 { |
|
73 // The ConstructL from the base class CEUnitTestSuiteClass must be called. |
|
74 // It generates the test case table. |
|
75 CEUnitTestSuiteClass::ConstructL(); |
|
76 } |
|
77 |
|
78 // ================= |
|
79 // Tests |
|
80 // ================= |
|
81 |
|
82 void UT_CAlfLCTTextVisual::SetupL( ) |
|
83 { |
|
84 iEnv = CAlfEnv::NewL(); |
|
85 |
|
86 iControl = new( ELeave ) CAlfControl; |
|
87 iControl->ConstructL( *iEnv ); |
|
88 |
|
89 iVisual = (CAlfLCTTextVisual*)iControl->AppendVisualL( EAlfVisualTypeLCTText ); |
|
90 } |
|
91 |
|
92 void UT_CAlfLCTTextVisual::Teardown( ) |
|
93 { |
|
94 if ( iControl && iEnv && !iEnv->FindControl( iControl->Id() ) ) |
|
95 { |
|
96 delete iControl; |
|
97 iControl = NULL; |
|
98 } |
|
99 delete iEnv; |
|
100 iEnv = NULL; |
|
101 } |
|
102 |
|
103 void UT_CAlfLCTTextVisual::UT_CAlfLCTTextVisual_CAlfLCTTextVisualL( ) |
|
104 { |
|
105 __UHEAP_MARK; |
|
106 CAlfLCTTextVisual* visual = new (ELeave) CAlfLCTTextVisual; |
|
107 delete visual; |
|
108 __UHEAP_MARKEND; |
|
109 } |
|
110 |
|
111 void UT_CAlfLCTTextVisual::UT_CAlfLCTTextVisual_ConstructLL( ) |
|
112 { |
|
113 __UHEAP_MARK; |
|
114 CAlfLCTTextVisual* visual = new (ELeave) CAlfLCTTextVisual; |
|
115 CleanupStack::PushL( visual ); |
|
116 visual->ConstructL( *iControl ); |
|
117 CleanupStack::PopAndDestroy( visual ); |
|
118 __UHEAP_MARKEND; |
|
119 } |
|
120 |
|
121 void UT_CAlfLCTTextVisual::UT_CAlfLCTTextVisual_RemoveAndDestroyAllDL( ) |
|
122 { |
|
123 iVisual->RemoveAndDestroyAllD(); |
|
124 iVisual = NULL; |
|
125 } |
|
126 |
|
127 void UT_CAlfLCTTextVisual::UT_CAlfLCTTextVisual_SetTextPane( ) |
|
128 { |
|
129 TAlfAlignHorizontal alignHorizontal(EAlfAlignHLeft); |
|
130 TInt fontId1 = 0x80100004; |
|
131 TInt varietyIndex = 0;// not marked or highlighted |
|
132 |
|
133 TAknTextLineLayout componentLayout = AknLayoutScalable_Avkon::cell_app_pane_t1(varietyIndex).LayoutLine(); |
|
134 TInt fontId2 = componentLayout.iFont; |
|
135 |
|
136 |
|
137 iVisual->SetAlign(alignHorizontal, EAlfAlignVCenter); |
|
138 // @todo can't test alignment, as huitk doesn't provide API |
|
139 |
|
140 // todo: do something else |
|
141 //iVisual->SetFontId(fontId1); |
|
142 //TInt resultFontId = iVisual->FontId(); // Deprecated |
|
143 //EUNIT_ASSERT_EQUALS( fontId1, resultFontId ); |
|
144 |
|
145 TAknLayoutHierarchyComponentHandle cell_app_pane_t1_Handle( |
|
146 KUidAknLayoutSystemId_AknLayout2, |
|
147 AknLayoutScalable_Avkon::KCdlInterfaceUidValue, |
|
148 AknLayoutScalable_Avkon::EApiId_cell_app_pane_t1); |
|
149 cell_app_pane_t1_Handle.SetVarietyIndex(varietyIndex); |
|
150 |
|
151 iVisual->SetTextPane(cell_app_pane_t1_Handle); |
|
152 |
|
153 //resultFontId = iVisual->FontId(); // deprecated |
|
154 // EUNIT_ASSERT_EQUALS( fontId2, resultFontId ); |
|
155 } |
|
156 |
|
157 // ================= |
|
158 // Test Table |
|
159 // ================= |
|
160 |
|
161 |
|
162 EUNIT_BEGIN_TEST_TABLE( |
|
163 UT_CAlfLCTTextVisual, |
|
164 "Alf Unit Tests", |
|
165 "UNIT" ) |
|
166 |
|
167 EUNIT_TEST( |
|
168 "CAlfLCTTextVisual - test ", |
|
169 "CAlfLCTTextVisual", |
|
170 "CAlfLCTTextVisual", |
|
171 "FUNCTIONALITY", |
|
172 SetupL, UT_CAlfLCTTextVisual_CAlfLCTTextVisualL, Teardown) |
|
173 |
|
174 EUNIT_TEST( |
|
175 "ConstructL - test ", |
|
176 "CAlfLCTTextVisual", |
|
177 "ConstructL", |
|
178 "FUNCTIONALITY", |
|
179 SetupL, UT_CAlfLCTTextVisual_ConstructLL, Teardown) |
|
180 |
|
181 EUNIT_TEST( |
|
182 "RemoveAndDestroyAllD - test ", |
|
183 "CAlfLCTTextVisual", |
|
184 "RemoveAndDestroyAllD", |
|
185 "FUNCTIONALITY", |
|
186 SetupL, UT_CAlfLCTTextVisual_RemoveAndDestroyAllDL, Teardown) |
|
187 |
|
188 /** TODO: FIX TEST |
|
189 * THIS TEST IS NOT USED BECAUSE TEST FAILS. |
|
190 * REQUIRES FURTHER STUDY AND FIX. |
|
191 EUNIT_TEST( |
|
192 "SetTextPane - test ", |
|
193 "CAlfLCTTextVisual", |
|
194 "SetTextPane", |
|
195 "FUNCTIONALITY", |
|
196 SetupL, UT_CAlfLCTTextVisual_SetTextPane, Teardown) |
|
197 */ |
|
198 |
|
199 EUNIT_END_TEST_TABLE |
|
200 |
|
201 // END OF FILE |
|