) => {
+ fixture.componentInstance.rowspan = 2;
+ fixture.detectChanges();
+
+ let tile = fixture.debugElement.query(By.directive(MdGridTile));
+ expect(getProp(tile, 'height')).toBe('201px');
+
+ fixture.componentInstance.rowspan = 3;
+ fixture.detectChanges();
+ expect(getProp(tile, 'height')).toBe('302px');
+ });
+ });
+
+ it('should lay out tiles correctly for a complex layout', () => {
+ var template = `
+
+
+
+ {{tile.text}}
+
+
+
+ `;
+
+ return builder.overrideTemplate(TestGridList, template)
+ .createAsync(TestGridList).then((fixture: ComponentFixture) => {
+ fixture.componentInstance.tiles = [
+ {cols: 3, rows: 1},
+ {cols: 1, rows: 2},
+ {cols: 1, rows: 1},
+ {cols: 2, rows: 1}
+ ];
+ fixture.detectChanges();
+ fakeAsync(() => {
+ tick();
+ let tiles = fixture.debugElement.queryAll(By.css('md-grid-tile'));
+
+ expect(getProp(tiles[0], 'width')).toBe('299.75px');
+ expect(getProp(tiles[0], 'height')).toBe('100px');
+ expect(getProp(tiles[0], 'left')).toBe('0px');
+ expect(getProp(tiles[0], 'top')).toBe('0px');
+
+ expect(getProp(tiles[1], 'width')).toBe('99.25px');
+ expect(getProp(tiles[1], 'height')).toBe('201px');
+ expect(getProp(tiles[1], 'left')).toBe('300.75px');
+ expect(getProp(tiles[1], 'top')).toBe('0px');
+
+ expect(getProp(tiles[2], 'width')).toBe('99.25px');
+ expect(getProp(tiles[2], 'height')).toBe('100px');
+ expect(getProp(tiles[2], 'left')).toBe('0px');
+ expect(getProp(tiles[2], 'top')).toBe('101px');
+
+ expect(getProp(tiles[3], 'width')).toBe('199.5px');
+ expect(getProp(tiles[3], 'height')).toBe('100px');
+ expect(getProp(tiles[3], 'left')).toBe('100.25px');
+ expect(getProp(tiles[3], 'top')).toBe('101px');
+ });
+ });
+ });
+});
+
+@Component({
+ selector: 'test-grid-list',
+ template: ``,
+ directives: [MD_GRID_LIST_DIRECTIVES]
+})
+class TestGridList {
+ tiles: any[];
+ height: string;
+ colspan: number;
+ rowspan: number;
+}
+
+function getProp(el: any, prop: string): string {
+ return getComputedStyle(el.nativeElement).getPropertyValue(prop);
+}