<?php
/**
 * This file contains unit tests for {@link TranscodingActionResizeImg} class
 * of the TransPythia library.
 * 
 * @author Francois Daoust <fd@w3.org>
 * @package Tests
 * @subpackage TransPythia
 * @version $Revision: 1.1 $
 * @license http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231.html W3C Software Notice and License
 * @copyright Copyright (c) 2009, W3C (MIT, ERCIM, Keio)
 */

require_once("../common/ddrsimpleapi/interface/serviceFactory.php");
require_once("../common/transcoding/transcodingactionresizeimg.php");

class TestOfTranscodingActionResizeImg extends UnitTestCase {
    function test_test() {
    	// Load material for testing
    	$filename = "data/gargantua.html";
    	$file = fopen($filename, "rb");
		$contents = fread($file, filesize($filename));
		fclose($file);
		
		$contents = strstr($contents, '<div id="content">');
		$contents = substr($contents, 0, strpos($contents, "</body>"));
    	
		// Construct service to interact with WURFL database.
    	$service = ServiceFactory::newService(
    		'WURFL',
    		'http://www.w3.org/2008/01/ddr-core-vocabulary',
    		array('wurfl_path'=>'../data/wurfl/'));
    	
    	// Prepare transcoding action
    	$action = new TranscodingActionResizeImg($service);
    	$action->setOption('root_folder', 'data/');
    	$action->setOption('img_cache_uri', 'cache/');
    	
    	// Emulate a Desktop browser and run the pagination
		$evidence = $service->newHTTPEvidenceM(
			array( 'User-Agent' => 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.14) Gecko/2009090216 Ubuntu/9.04 (jaunty) Firefox/3.0.14' ));
    	$res = $action->apply($contents, $evidence);
    	$this->assertEqual($contents, $res);
    	
    	// Emulate a Nokia8810 and run the pagination
		$evidence = $service->newHTTPEvidenceM(
			array( 'User-Agent' => 'Nokia8810/1.0' ));
    	$res = $action->apply($contents, $evidence);
		
    }
}

?>