1<?php 2 3class TestCSSParseMarginBoxes extends GenericTest { 4 function testCSSParseMarginBoxesTopLeftCornerSize() { 5 parse_config_file('../html2ps.config'); 6 $media =& Media::predefined('A4'); 7 $media->set_margins(array('left' => 10, 8 'top' => 10, 9 'right' => 10, 10 'bottom' => 10)); 11 12 $pipeline =& PipelineFactory::create_default_pipeline('utf-8', 'test.pdf'); 13 $pipeline->_setupScales($media); 14 $pipeline->_cssState = array(new CSSState(CSS::get())); 15 16 $boxes = $pipeline->reflow_margin_boxes(1, $media); 17 18 $box =& $boxes[CSS_MARGIN_BOX_SELECTOR_TOP_LEFT_CORNER]; 19 $this->assertEqual($box->get_width(), mm2pt(10)); 20 $this->assertEqual($box->get_height(), mm2pt(10)); 21 } 22 23 function testCSSParseMarginBoxesTopLeftSizeNoContent() { 24 parse_config_file('../html2ps.config'); 25 $media =& Media::predefined('A4'); 26 $media->set_margins(array('left' => 10, 27 'top' => 10, 28 'right' => 10, 29 'bottom' => 10)); 30 31 $pipeline =& PipelineFactory::create_default_pipeline('utf-8', 'test.pdf'); 32 $pipeline->_setupScales($media); 33 $pipeline->_cssState = array(new CSSState(CSS::get())); 34 35 $boxes = $pipeline->reflow_margin_boxes(1, $media); 36 37 $box =& $boxes[CSS_MARGIN_BOX_SELECTOR_TOP_LEFT]; 38 $this->assertEqual($box->get_width(), mm2pt(0)); 39 $this->assertEqual($box->get_height(), mm2pt(10)); 40 } 41 42 function testCSSParseMarginBoxesTopLeftSize() { 43 parse_config_file('../html2ps.config'); 44 $media =& Media::predefined('A4'); 45 $media->set_margins(array('left' => 10, 46 'top' => 10, 47 'right' => 10, 48 'bottom' => 10)); 49 50 $pipeline =& PipelineFactory::create_default_pipeline('utf-8', 'test.pdf'); 51 $pipeline->_prepare($media); 52 $pipeline->_cssState = array(new CSSState(CSS::get())); 53 parse_css_atpage_rules('@page { @top-left { content: "TEXT"; } }', $pipeline); 54 55 $boxes = $pipeline->reflow_margin_boxes(1, $media); 56 57 $box =& $boxes[CSS_MARGIN_BOX_SELECTOR_TOP_LEFT]; 58 $this->assertNotEqual($box->get_width(), 0); 59 $expected_width = $pipeline->output_driver->stringwidth('TEXT', 'Times-Roman', 'iso-8859-1', 12); 60 $this->assertTrue($box->get_width() >= $expected_width); 61 $this->assertEqual($box->get_height(), mm2pt(10)); 62 } 63} 64 65?>