<?php
/**
 * This file contains unit tests for {@link TranscodingActionDeletePopup} 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/transcodingactiondeletepopup.php");

class TestOfTranscodingActionDeletePopup extends UnitTestCase {
    function test_test() {
    	// Load material for testing
		$contents = '<div>
				<p target="_blank">Target should not be removed in paragraphs
				but rather in <a href="foo/bar.html" target="_blank" class="link">links</a>.
				</p>
			</div>';
    	
		// 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 TranscodingActionDeletePopup($service);
    	
    	// Emulate a Desktop browser and run the linearization
		$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($res, $contents);
    	
    	// Emulate a Nokia8810 and run the linearization
		$evidence = $service->newHTTPEvidenceM(
			array( 'User-Agent' => 'Nokia8810/1.0' ));
    	$res = $action->apply($contents, $evidence);
    	$this->assertEqual($res, '<div>
				<p target="_blank">Target should not be removed in paragraphs
				but rather in <a href="foo/bar.html" class="link">links</a>.
				</p>
			</div>');
		
    }
}

?>