| 1 |
lars |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
class TestTableColumnWidth extends GenericTest {
|
|
|
4 |
function testTableColumnWidth1() {
|
|
|
5 |
$media = new Media(array('width' => 100,
|
|
|
6 |
'height' => 200/mm2pt(1)),
|
|
|
7 |
array('top'=>0,
|
|
|
8 |
'bottom'=>0,
|
|
|
9 |
'left'=>0,
|
|
|
10 |
'right'=>0));
|
|
|
11 |
$tree = $this->runPipeline(file_get_contents('test.table.column.width.1.html'),
|
|
|
12 |
$media,
|
|
|
13 |
$pipeline);
|
|
|
14 |
$large = $tree->get_element_by_id('large');
|
|
|
15 |
|
|
|
16 |
$real_width = max($pipeline->output_driver->stringwidth('LARGE', 'Times-Roman', 'iso-8859-1', pt2pt(30)),
|
|
|
17 |
pt2pt(10));
|
|
|
18 |
|
|
|
19 |
$width =& $large->getCSSProperty(CSS_WIDTH);
|
|
|
20 |
$this->assertTrue($width->isConstant());
|
|
|
21 |
$this->assertEqual($width->width, $real_width);
|
|
|
22 |
$this->assertEqual($large->get_width(), $real_width);
|
|
|
23 |
}
|
|
|
24 |
|
|
|
25 |
function testTableColumnWidth2() {
|
|
|
26 |
$media = new Media(array('width' => 100,
|
|
|
27 |
'height' => 200/mm2pt(1)),
|
|
|
28 |
array('top'=>0,
|
|
|
29 |
'bottom'=>0,
|
|
|
30 |
'left'=>0,
|
|
|
31 |
'right'=>0));
|
|
|
32 |
$tree = $this->runPipeline(file_get_contents('test.table.column.width.2.html'),
|
|
|
33 |
$media,
|
|
|
34 |
$pipeline);
|
|
|
35 |
$large = $tree->get_element_by_id('large');
|
|
|
36 |
|
|
|
37 |
$real_width = pt2pt(150);
|
|
|
38 |
|
|
|
39 |
$width =& $large->getCSSProperty(CSS_WIDTH);
|
|
|
40 |
$this->assertTrue($width->isConstant());
|
|
|
41 |
$this->assertEqual($width->width, $real_width);
|
|
|
42 |
$this->assertEqual($large->get_width(), $real_width);
|
|
|
43 |
}
|
|
|
44 |
|
|
|
45 |
function testTableColumnWidth3() {
|
|
|
46 |
$media = null;
|
|
|
47 |
$tree = $this->runPipeline(file_get_contents('test.table.column.width.3.html'), $media);
|
|
|
48 |
|
|
|
49 |
$container_table =& $tree->get_element_by_id('table');
|
|
|
50 |
$cell =& $tree->get_element_by_id('container-cell');
|
|
|
51 |
$table =& $tree->get_element_by_id('contained-table');
|
|
|
52 |
|
|
|
53 |
$this->assertEqual($container_table->get_width(), mm2pt($media->real_width()));
|
|
|
54 |
$this->assertTrue($cell->get_width() >= $table->get_width(),
|
|
|
55 |
sprintf("Cell width (%s) is less than content table width (%s)",
|
|
|
56 |
$cell->get_width(),
|
|
|
57 |
$table->get_width()));
|
|
|
58 |
}
|
|
|
59 |
|
|
|
60 |
function testTableColumnWidth4() {
|
|
|
61 |
$media = null;
|
|
|
62 |
$tree = $this->runPipeline(file_get_contents('test.table.column.width.4.html'), $media);
|
|
|
63 |
|
|
|
64 |
$container_table =& $tree->get_element_by_id('table');
|
|
|
65 |
$cell1 =& $tree->get_element_by_id('cell1');
|
|
|
66 |
$cell2 =& $tree->get_element_by_id('cell2');
|
|
|
67 |
$cell =& $tree->get_element_by_id('container-cell');
|
|
|
68 |
|
|
|
69 |
$this->assertEqual($container_table->get_width(), mm2pt($media->real_width()) * 0.9);
|
|
|
70 |
|
|
|
71 |
$container_cell_width = $cell->get_width();
|
|
|
72 |
$container_cell_min_width = $cell->content[0]->get_width();
|
|
|
73 |
$this->assertTrue($container_cell_min_width <= $container_cell_width,
|
|
|
74 |
sprintf('Container cell width (%s) is less than content minimal width (%s)',
|
|
|
75 |
$container_cell_width,
|
|
|
76 |
$container_cell_min_width));
|
|
|
77 |
|
|
|
78 |
$cell_width = $cell1->get_width() + $cell2->get_width() + $cell->get_width();
|
|
|
79 |
$table_width = $container_table->get_width();
|
|
|
80 |
$this->assertTrue($cell_width <=
|
|
|
81 |
$table_width,
|
|
|
82 |
sprintf('Total cell width (%s) is greater than table width (%s)',
|
|
|
83 |
$cell_width,
|
|
|
84 |
$table_width));
|
|
|
85 |
}
|
|
|
86 |
}
|
|
|
87 |
|
|
|
88 |
?>
|