|
1 // Copyright (c) 2005-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 // Tests the grid layout functionalities that controls appearance of columns, rows and their selections.\n |
|
15 // One of the test case tests the functionalitie for Setting , Inserting , Deleting rows and coloums and \n |
|
16 // the other tests whether the grid labels/lines are to be printed/Drawn. |
|
17 // |
|
18 // |
|
19 |
|
20 /** |
|
21 @file |
|
22 @internalComponent - Internal Symbian test code |
|
23 */ |
|
24 |
|
25 #include <s32mem.h> |
|
26 #include "grdstd.h" |
|
27 #include "TGlayStep.h" |
|
28 |
|
29 /** |
|
30 Auxiliary Function for Test Case ID TGlayStep-Test1L & TGlayStep-Test2L.\n |
|
31 Call the ConstructL function of CGridLay.\n |
|
32 ConstructL is the second-phase constructor for constructing the object with definite row boundaries.\n |
|
33 */ |
|
34 void CTGlayStep::ConstructGridLayLC(CGridLay*& aGridLay) |
|
35 { |
|
36 aGridLay = new(ELeave) CGridLay(NULL); |
|
37 CleanupStack::PushL(aGridLay); |
|
38 aGridLay->ConstructL(NULL,NULL,100,100); |
|
39 } |
|
40 /** |
|
41 @SYMTestCaseID UIF-TGlayStep-Test1L |
|
42 |
|
43 @SYMPREQ |
|
44 |
|
45 @SYMTestCaseDesc Tests the functionalitie for Setting , Inserting , Deleting rows and coloums and \n. |
|
46 The CGridLay APIs are being tested.\n |
|
47 |
|
48 @SYMTestPriority High |
|
49 |
|
50 @SYMTestStatus Implemented |
|
51 |
|
52 @SYMTestActions Using the CGridLay APIs, |
|
53 1)Construct the Grid layout.\n |
|
54 2)Set the Coloum width.\n |
|
55 3)Insert a coloum.\n |
|
56 4)Set row height.\n |
|
57 5)Delete the coloum.\n |
|
58 6)Retrieve the parameter set.\n |
|
59 7)Compare the retrieved value with the orginal parameters.\n |
|
60 |
|
61 |
|
62 @SYMTestExpectedResults The test passes when the set parameter values match with the retrieved parameter values.\n |
|
63 |
|
64 */ |
|
65 void CTGlayStep::Test1L() |
|
66 { |
|
67 __UHEAP_MARK; |
|
68 CGridLay* gridLay; |
|
69 ConstructGridLayLC(gridLay); |
|
70 |
|
71 gridLay->SetDefaultColumnWidthInTwips(123); |
|
72 gridLay->SetColumnWidthInTwipsL(5,55); |
|
73 gridLay->SetColumnWidthInTwipsL(12,18,77); |
|
74 gridLay->InsertDeleteColumns(12,2); |
|
75 gridLay->SetRowHeightInTwipsL(6,7,99); |
|
76 gridLay->InsertDeleteRows(2,-2); |
|
77 |
|
78 TEST(gridLay->ColumnWidthInTwips(5)==55); |
|
79 TEST(gridLay->ColumnWidthInTwips(12)==123); // default |
|
80 TEST(gridLay->ColumnWidthInTwips(20)==77); |
|
81 TEST(gridLay->RowHeightInTwips(4)==99); |
|
82 gridLay->SetRowHeightsToDefault(); |
|
83 TEST(gridLay->RowHeightInTwips(4)==gridLay->DefaultRowHeightInTwips()); |
|
84 |
|
85 CleanupStack::PopAndDestroy(); |
|
86 __UHEAP_MARKEND; |
|
87 } |
|
88 /** |
|
89 @SYMTestCaseID UIF-TGlayStep-Test2L |
|
90 |
|
91 @SYMPREQ |
|
92 |
|
93 @SYMTestCaseDesc Tests whether the grid labels are to be printed/Drawn.\n |
|
94 The CGridLay APIs are being tested.\n |
|
95 |
|
96 @SYMTestPriority High |
|
97 |
|
98 @SYMTestStatus Implemented |
|
99 |
|
100 @SYMTestActions Using the CGridLay APIs, |
|
101 1)Construct the Grid layout.\n |
|
102 2)Set that side labels are not to be printed.\n |
|
103 3)Set that side vertical grid lines are not to be drawn.\n |
|
104 4)Sets the default height of rows.\n |
|
105 |
|
106 Create a write stream interface and externalize the CGridLay object.\n |
|
107 Close the stream.\n |
|
108 Re-Initialize the CGridLay object.\n |
|
109 Tests whether side grid labels are printed (returning default settings).\n |
|
110 Tests whether vertical grid lines are to be drawn (returning default settings).\n |
|
111 |
|
112 Create a read stream interface and Internalize CGridLay object |
|
113 Test whether side grid labels are not to be printed (Setting matches with the externalised CGridLay object).\n |
|
114 Tests whether vertical grid lines are not to be drawn(Setting matches with the externalised CGridLay object).\n |
|
115 Test that the default height of rows being set matches with the settings of externalised CGridLay object.\n |
|
116 |
|
117 @SYMTestExpectedResults Test passes if there is no difference in the CGridLay object settings due to externalising and internalising.\n |
|
118 |
|
119 */ |
|
120 void CTGlayStep::Test2L() |
|
121 { |
|
122 __UHEAP_MARK; |
|
123 CBufFlat* bufFlat = CBufFlat::NewL(100); |
|
124 CleanupStack::PushL(bufFlat); |
|
125 |
|
126 CGridLay* gridLay; |
|
127 ConstructGridLayLC(gridLay); |
|
128 |
|
129 gridLay->SetSideLabels(EFalse); |
|
130 gridLay->SetVerticalGridLines(EFalse); |
|
131 gridLay->SetDefaultRowHeightInTwips(333); |
|
132 |
|
133 RBufWriteStream writeStream; |
|
134 writeStream.Open(*bufFlat,0); |
|
135 writeStream << *gridLay; |
|
136 writeStream.Close(); |
|
137 |
|
138 CleanupStack::PopAndDestroy(); // gridLay |
|
139 ConstructGridLayLC(gridLay); |
|
140 // 2 and 8 are the default settings for SideLabels and VerticalGridlInes |
|
141 TEST(gridLay->IsSideLabels()==2); |
|
142 TEST(gridLay->IsVerticalGridLines()==8); |
|
143 |
|
144 RBufReadStream readStream; |
|
145 readStream.Open(*bufFlat,0); |
|
146 readStream >> *gridLay; |
|
147 readStream.Close(); |
|
148 |
|
149 TEST(!gridLay->IsSideLabels()); |
|
150 TEST(!gridLay->IsVerticalGridLines()); |
|
151 TEST(gridLay->DefaultRowHeightInTwips()==333); |
|
152 |
|
153 CleanupStack::PopAndDestroy(2);// gridLay + bufFlat |
|
154 } |
|
155 |
|
156 |
|
157 // |
|
158 CTGlayStep::~CTGlayStep() |
|
159 /** |
|
160 Destructor |
|
161 */ |
|
162 { |
|
163 } |
|
164 |
|
165 CTGlayStep::CTGlayStep() |
|
166 /** |
|
167 Constructor |
|
168 */ |
|
169 { |
|
170 // Call base class method to set up the human readable name for logging |
|
171 SetTestStepName(KTGlayStep); |
|
172 } |
|
173 /** |
|
174 |
|
175 Entry function for the test steps.\n |
|
176 Call the test steps.\n |
|
177 |
|
178 @return TVerdict indicating whether the test step has executed without error.\n |
|
179 |
|
180 */ |
|
181 TVerdict CTGlayStep::doTestStepL() |
|
182 |
|
183 { |
|
184 INFO_PRINTF1(_L("Test Started")); |
|
185 __UHEAP_MARK; |
|
186 |
|
187 INFO_PRINTF1(_L("Setting/Inserting/Deleting Rows and Columns")); |
|
188 |
|
189 SetTestStepID(_L("UIF-TGlayStep-Test1L")); |
|
190 TRAPD(err,CTGlayStep::Test1L()); |
|
191 TEST(err==KErrNone); |
|
192 RecordTestResultL(); |
|
193 INFO_PRINTF1(_L("Externalizing/Internalizing")); |
|
194 SetTestStepID(_L("UIF-TGlayStep-Test2L")); |
|
195 TRAP(err,CTGlayStep::Test2L()); |
|
196 TEST(err==KErrNone); |
|
197 RecordTestResultL(); |
|
198 CloseTMSGraphicsStep(); |
|
199 |
|
200 INFO_PRINTF1(_L("test finished")); |
|
201 |
|
202 __UHEAP_MARKEND; |
|
203 return TestStepResult(); |
|
204 } |