| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -183,6 +183,121 @@ export class GridLayoutTest extends testModule.UITest<RemovalTrackingGridLayout> | |||
| 183 | 183 | GridLayout.setColumnSpan(new Button(), 0); | |
| 184 | 184 | } | |
| 185 | 185 | ||
| 186 | + public test_addChildAtCell_with_all_params() { | ||
| 187 | + let btn = new Button(); | ||
| 188 | + let row: number = 1; | ||
| 189 | + let column: number = 2; | ||
| 190 | + let rowSpan: number = 3; | ||
| 191 | + let columnSpan: number = 4; | ||
| 192 | + this.testView.addChildAtCell(btn, row, column, rowSpan, columnSpan); | ||
| 193 | + TKUnit.assertEqual( | ||
| 194 | + this.row(btn), | ||
| 195 | + row, | ||
| 196 | + "'row' property not applied For GridLayout addChildAtCell." | ||
| 197 | + ); | ||
| 198 | + TKUnit.assertEqual( | ||
| 199 | + this.col(btn), | ||
| 200 | + column, | ||
| 201 | + "'column' property not applied For GridLayout addChildAtCell." | ||
| 202 | + ); | ||
| 203 | + TKUnit.assertEqual( | ||
| 204 | + this.rowSpan(btn), | ||
| 205 | + rowSpan, | ||
| 206 | + "'rowSpan' property not applied For GridLayout addChildAtCell." | ||
| 207 | + ); | ||
| 208 | + TKUnit.assertEqual( | ||
| 209 | + this.colSpan(btn), | ||
| 210 | + columnSpan, | ||
| 211 | + "'columnSpan' property not applied For GridLayout addChildAtCell." | ||
| 212 | + ); | ||
| 213 | + } | ||
| 214 | + | ||
| 215 | + public test_addChildAtCell_without_optional_params() { | ||
| 216 | + let btn = new Button(); | ||
| 217 | + let row: number = 1; | ||
| 218 | + let column: number = 2; | ||
| 219 | + let defaultSpanValue: number = 1; | ||
| 220 | + this.testView.addChildAtCell(btn, row, column); | ||
| 221 | + TKUnit.assertEqual( | ||
| 222 | + this.row(btn), | ||
| 223 | + row, | ||
| 224 | + "'row' property not applied For GridLayout addChildAtCell." | ||
| 225 | + ); | ||
| 226 | + TKUnit.assertEqual( | ||
| 227 | + this.col(btn), | ||
| 228 | + column, | ||
| 229 | + "'column' property not applied For GridLayout addChildAtCell." | ||
| 230 | + ); | ||
| 231 | + TKUnit.assertEqual( | ||
| 232 | + this.rowSpan(btn), | ||
| 233 | + defaultSpanValue, | ||
| 234 | + "'rowSpan' property not applied For GridLayout addChildAtCell without optional params." | ||
| 235 | + ); | ||
| 236 | + TKUnit.assertEqual( | ||
| 237 | + this.colSpan(btn), | ||
| 238 | + defaultSpanValue, | ||
| 239 | + "'colSpan' property not applied For GridLayout addChildAtCell without optional params." | ||
| 240 | + ); | ||
| 241 | + } | ||
| 242 | + | ||
| 243 | + public test_addChildAtCell_without_rowSpan() { | ||
| 244 | + let btn = new Button(); | ||
| 245 | + let row: number = 1; | ||
| 246 | + let column: number = 2; | ||
| 247 | + let columnSpan: number = 2; | ||
| 248 | + let defaultSpanValue: number = 1; | ||
| 249 | + this.testView.addChildAtCell(btn, row, column, undefined, columnSpan); | ||
| 250 | + TKUnit.assertEqual( | ||
| 251 | + this.row(btn), | ||
| 252 | + row, | ||
| 253 | + "'row' property not applied For GridLayout addChildAtCell without rowspan." | ||
| 254 | + ); | ||
| 255 | + TKUnit.assertEqual( | ||
| 256 | + this.col(btn), | ||
| 257 | + column, | ||
| 258 | + "'column' property not applied For GridLayout addChildAtCell without rowspan." | ||
| 259 | + ); | ||
| 260 | + TKUnit.assertEqual( | ||
| 261 | + this.rowSpan(btn), | ||
| 262 | + defaultSpanValue, | ||
| 263 | + "'rowSpan' property not applied For GridLayout addChildAtCell without rowspan." | ||
| 264 | + ); | ||
| 265 | + TKUnit.assertEqual( | ||
| 266 | + this.colSpan(btn), | ||
| 267 | + columnSpan, | ||
| 268 | + "'columnSpan' property not applied For GridLayout addChildAtCell without rowspan." | ||
| 269 | + ); | ||
| 270 | + } | ||
| 271 | + | ||
| 272 | + public test_addChildAtCell_without_columnSpan() { | ||
| 273 | + let btn = new Button(); | ||
| 274 | + let row: number = 1; | ||
| 275 | + let column: number = 2; | ||
| 276 | + let rowSpan: number = 2; | ||
| 277 | + let defaultSpanValue: number = 1; | ||
| 278 | + this.testView.addChildAtCell(btn, row, column, rowSpan); | ||
| 279 | + TKUnit.assertEqual( | ||
| 280 | + this.row(btn), | ||
| 281 | + row, | ||
| 282 | + "'row' property not applied For GridLayout addChildAtCell without columnSpan." | ||
| 283 | + ); | ||
| 284 | + TKUnit.assertEqual( | ||
| 285 | + this.col(btn), | ||
| 286 | + column, | ||
| 287 | + "'column' property not applied For GridLayout addChildAtCell without columnSpan." | ||
| 288 | + ); | ||
| 289 | + TKUnit.assertEqual( | ||
| 290 | + this.rowSpan(btn), | ||
| 291 | + rowSpan, | ||
| 292 | + "'rowSpan' property not applied For GridLayout addChildAtCell without columnSpan." | ||
| 293 | + ); | ||
| 294 | + TKUnit.assertEqual( | ||
| 295 | + this.colSpan(btn), | ||
| 296 | + defaultSpanValue, | ||
| 297 | + "'columnSpan' property not applied For GridLayout addChildAtCell without columnSpan." | ||
| 298 | + ); | ||
| 299 | + } | ||
| 300 | + | ||
| 186 | 301 | public test_addRow_shouldThrow_onNullValues() { | |
| 187 | 302 | TKUnit.assertThrows(() => { | |
| 188 | 303 | this.testView.addRow(null); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -178,6 +178,18 @@ export class GridLayoutBase extends LayoutBase implements GridLayoutDefinition { | |||
| 178 | 178 | this.invalidate(); | |
| 179 | 179 | } | |
| 180 | 180 | ||
| 181 | + public addChildAtCell(view: View, row: number, column: number, rowSpan?: number, columnSpan?: number): void { | ||
| 182 | + this.addChild(view); | ||
| 183 | + GridLayoutBase.setRow(view, row); | ||
| 184 | + GridLayoutBase.setColumn(view, column); | ||
| 185 | + if (rowSpan) { | ||
| 186 | + GridLayoutBase.setRowSpan(view, rowSpan); | ||
| 187 | + } | ||
| 188 | + if (columnSpan) { | ||
| 189 | + GridLayoutBase.setColumnSpan(view, columnSpan); | ||
| 190 | + } | ||
| 191 | + } | ||
| 192 | + | ||
| 181 | 193 | public removeRow(itemSpec: ItemSpec): void { | |
| 182 | 194 | if (!itemSpec) { | |
| 183 | 195 | throw new Error("Value is null."); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -101,6 +101,11 @@ export class GridLayout extends LayoutBase { | |||
| 101 | 101 | */ | |
| 102 | 102 | public addRow(itemSpec: ItemSpec): void; | |
| 103 | 103 | ||
| 104 | + /** | ||
| 105 | + * Adds a child at specific cell in GridLayout. Optional rowSpan and columnSpan attributes | ||
| 106 | + */ | ||
| 107 | + public addChildAtCell(view: View, row: number, column: number, rowSpan?: number, columnSpan?: number): void; | ||
| 108 | + | ||
| 104 | 109 | /** | |
| 105 | 110 | * Removes a column specification from a GridLayout. | |
| 106 | 111 | */ | |
| Back | FazBrowse Home | New Git URL |
0 commit comments