ffmpeg-mappable-media/tests/src/FFMpeg/Format/DefaultVideoFormatTest.php

228 lines
5.8 KiB
PHP
Raw Normal View History

2012-04-13 12:09:11 +02:00
<?php
namespace FFMpeg\Format;
2012-04-13 12:45:41 +02:00
require_once dirname(__FILE__) . '/../../../../src/FFMpeg/Format/DefaultVideoFormat.php';
2012-04-13 12:09:11 +02:00
/**
2012-04-13 12:45:41 +02:00
* Test class for DefaultVideoFormat.
* Generated by PHPUnit on 2012-04-13 at 12:32:40.
2012-04-13 12:09:11 +02:00
*/
2012-04-13 12:45:41 +02:00
class DefaultVideoFormatTest extends \PHPUnit_Framework_TestCase
2012-04-13 12:09:11 +02:00
{
/**
2012-04-13 12:45:41 +02:00
* @var DefaultVideoFormat
2012-04-13 12:09:11 +02:00
*/
protected $object;
2012-04-13 12:45:41 +02:00
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
2012-04-13 12:09:11 +02:00
protected function setUp()
{
2012-04-13 12:45:41 +02:00
$this->object = new DefaultVideoFormatTester(320, 240);
2012-04-13 12:09:11 +02:00
}
/**
2012-04-13 12:45:41 +02:00
* @covers FFMpeg\Format\DefaultVideoFormat::__construct
* @covers FFMpeg\Format\DefaultVideoFormat::getWidth
* @covers FFMpeg\Format\DefaultVideoFormat::getHeight
2012-04-13 12:09:11 +02:00
*/
public function testConstruct()
{
$this->assertEquals(320, $this->object->getWidth());
$this->assertEquals(240, $this->object->getHeight());
}
/**
2012-04-13 12:45:41 +02:00
* @covers FFMpeg\Format\DefaultVideoFormat::setDimensions
2012-04-13 12:09:11 +02:00
*/
public function testSetDimensions()
{
$this->object->setDimensions(240, 640);
$this->assertEquals(240, $this->object->getWidth());
$this->assertEquals(640, $this->object->getHeight());
$this->object->setDimensions(242, 638);
$this->assertEquals(240, $this->object->getWidth());
$this->assertEquals(640, $this->object->getHeight());
}
/**
2012-04-13 12:45:41 +02:00
* @covers FFMpeg\Format\DefaultVideoFormat::setDimensions
2012-04-13 12:09:11 +02:00
* @dataProvider getWrongDimensions
* @expectedException \InvalidArgumentException
*/
public function testWrongDimensions($width, $height)
{
$this->object->setDimensions($width, $height);
}
/**
* Data provider for testWrongDimensions
*
* @return array
*/
public function getWrongDimensions()
{
return array(
array(0, 240),
array(240, 0),
array(-5, 240),
array(240, -5),
array(-5, -5),
array(0, 0)
);
}
/**
2012-04-13 12:45:41 +02:00
* @covers FFMpeg\Format\DefaultVideoFormat::getFrameRate
2012-04-13 12:09:11 +02:00
*/
public function testGetFrameRate()
{
$this->assertEquals(25, $this->object->getFrameRate());
}
/**
2012-04-13 12:45:41 +02:00
* @covers FFMpeg\Format\DefaultVideoFormat::setFrameRate
2012-04-13 12:09:11 +02:00
*/
public function testSetFrameRate()
{
$this->object->setFrameRate(12);
$this->assertEquals(12, $this->object->getFrameRate());
}
/**
2012-04-13 12:45:41 +02:00
* @covers FFMpeg\Format\DefaultVideoFormat::setFrameRate
2012-04-13 12:09:11 +02:00
* @dataProvider getWrongFrameRates
* @expectedException \InvalidArgumentException
*/
public function testSetWrongFrameRates($framerate)
{
$this->object->setFrameRate($framerate);
}
/**
* Data provider for testWrongFrameRates
*
* @return array
*/
public function getWrongFramerates()
{
return array(array(-5), array(0));
}
/**
2012-04-13 12:45:41 +02:00
* @covers FFMpeg\Format\DefaultVideoFormat::getVideoCodec
2012-04-13 12:09:11 +02:00
*/
public function testGetVideoCodec()
{
$this->assertEquals('videocodec2', $this->object->getVideoCodec());
}
/**
2012-04-13 12:45:41 +02:00
* @covers FFMpeg\Format\DefaultVideoFormat::setVideoCodec
2012-04-13 12:09:11 +02:00
*/
public function testSetVideoCodec()
{
$this->object->setVideoCodec('videocodec2');
$this->assertEquals('videocodec2', $this->object->getVideoCodec());
$this->object->setVideoCodec('videocodec1');
$this->assertEquals('videocodec1', $this->object->getVideoCodec());
}
/**
2012-04-13 12:45:41 +02:00
* @covers FFMpeg\Format\DefaultVideoFormat::setVideoCodec
2012-04-13 12:09:11 +02:00
* @expectedException \InvalidArgumentException
*/
public function testSetWrongVideoCodec()
{
$this->object->setVideoCodec('videocodec4');
}
/**
2012-04-13 12:45:41 +02:00
* @covers FFMpeg\Format\DefaultVideoFormat::getGOPsize
2012-04-13 12:09:11 +02:00
*/
public function testGetGOPsize()
{
$this->assertEquals(25, $this->object->getGOPsize());
}
/**
2012-04-13 12:45:41 +02:00
* @covers FFMpeg\Format\DefaultVideoFormat::setGOPsize
2012-04-13 12:09:11 +02:00
*/
public function testSetGOPsize()
{
$this->object->setGOPsize(100);
$this->assertEquals(100, $this->object->getGOPsize());
}
/**
2012-04-13 12:45:41 +02:00
* @covers FFMpeg\Format\DefaultVideoFormat::setGOPsize
2012-04-13 12:09:11 +02:00
* @dataProvider getWrongGOPsize
* @expectedException \InvalidArgumentException
*/
public function testSetWrongGOPSize($GOP)
{
$this->object->setGOPsize($GOP);
}
public function getWrongGOPsize()
{
return array(array(-5), array(0));
}
/**
2012-04-13 12:45:41 +02:00
* @covers FFMpeg\Format\DefaultVideoFormat::getMultiple
2012-04-13 12:09:11 +02:00
*/
public function testGetMultiple()
{
$this->assertEquals(320, $this->object->getMultiple(321, 16));
$this->assertEquals(320, $this->object->getMultiple(319, 16));
$this->assertEquals(320, $this->object->getMultiple(313, 16));
$this->assertEquals(304, $this->object->getMultiple(312, 16));
$this->assertEquals(336, $this->object->getMultiple(329, 16));
$this->assertEquals(16, $this->object->getMultiple(8, 16));
}
2012-04-13 14:15:56 +02:00
/**
* @covers FFMpeg\Format\DefaultVideoFormat::getKiloBitrate
*/
public function testGetKiloBitrate()
{
$this->assertEquals(1000, $this->object->getKiloBitrate());
}
2012-04-13 12:09:11 +02:00
}
2012-04-13 12:45:41 +02:00
class DefaultVideoFormatTester extends DefaultVideoFormat
2012-04-13 12:09:11 +02:00
{
protected $audioCodec = 'audiocodec1';
protected $videoCodec = 'videocodec2';
protected function getAvailableAudioCodecs()
{
return array('audiocodec1', 'audiocodec2', 'audiocodec3');
}
protected function getAvailableVideoCodecs()
{
return array('videocodec1', 'videocodec2');
}
public function getExtraParams()
{
return '-f format';
}
public function getMultiple($value, $multiple)
{
return parent::getMultiple($value, $multiple);
}
}
2012-04-13 12:45:41 +02:00