ffmpeg-mappable-media/tests/src/FFMpeg/Format/Video/DefaultVideoTest.php

201 lines
4.8 KiB
PHP
Raw Normal View History

2012-04-13 12:09:11 +02:00
<?php
2012-05-30 12:24:25 +02:00
namespace FFMpeg\Format\Video;
2012-04-13 12:09:11 +02:00
2012-05-25 20:53:56 +02:00
class DefaultVideoTest extends \PHPUnit_Framework_TestCase
2012-04-13 12:09:11 +02:00
{
/**
2012-05-25 20:53:56 +02:00
* @var DefaultVideo
2012-04-13 12:09:11 +02:00
*/
protected $object;
protected function setUp()
{
2012-05-25 20:53:56 +02:00
$this->object = new DefaultVideoTester();
2012-04-13 12:09:11 +02:00
}
/**
2012-05-30 12:24:25 +02:00
* @covers FFMpeg\Format\Video\DefaultVideo::setDimensions
* @covers FFMpeg\Format\Video\DefaultVideo::getWidth
* @covers FFMpeg\Format\Video\DefaultVideo::getHeight
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(242, $this->object->getWidth());
$this->assertEquals(638, $this->object->getHeight());
2012-04-13 12:09:11 +02:00
}
/**
2012-05-30 12:24:25 +02:00
* @covers FFMpeg\Format\Video\DefaultVideo::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-05-30 12:24:25 +02:00
* @covers FFMpeg\Format\Video\DefaultVideo::getFrameRate
2012-04-13 12:09:11 +02:00
*/
public function testGetFrameRate()
{
$this->assertEquals(25, $this->object->getFrameRate());
}
/**
2012-05-30 12:24:25 +02:00
* @covers FFMpeg\Format\Video\DefaultVideo::setFrameRate
2012-04-13 12:09:11 +02:00
*/
public function testSetFrameRate()
{
$this->object->setFrameRate(12);
$this->assertEquals(12, $this->object->getFrameRate());
}
/**
2012-05-30 12:24:25 +02:00
* @covers FFMpeg\Format\Video\DefaultVideo::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-05-30 12:24:25 +02:00
* @covers FFMpeg\Format\Video\DefaultVideo::getVideoCodec
2012-04-13 12:09:11 +02:00
*/
public function testGetVideoCodec()
{
$this->assertEquals('videocodec2', $this->object->getVideoCodec());
}
/**
2012-05-30 12:24:25 +02:00
* @covers FFMpeg\Format\Video\DefaultVideo::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-05-30 12:24:25 +02:00
* @covers FFMpeg\Format\Video\DefaultVideo::setVideoCodec
2012-04-13 12:09:11 +02:00
* @expectedException \InvalidArgumentException
*/
public function testSetWrongVideoCodec()
{
$this->object->setVideoCodec('videocodec4');
}
/**
2012-05-30 12:24:25 +02:00
* @covers FFMpeg\Format\Video\DefaultVideo::getGOPsize
2012-04-13 12:09:11 +02:00
*/
public function testGetGOPsize()
{
$this->assertEquals(25, $this->object->getGOPsize());
}
/**
2012-05-30 12:24:25 +02:00
* @covers FFMpeg\Format\Video\DefaultVideo::setGOPsize
2012-04-13 12:09:11 +02:00
*/
public function testSetGOPsize()
{
$this->object->setGOPsize(100);
$this->assertEquals(100, $this->object->getGOPsize());
}
/**
2012-05-30 12:24:25 +02:00
* @covers FFMpeg\Format\Video\DefaultVideo::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 14:15:56 +02:00
/**
2012-05-30 12:24:25 +02:00
* @covers FFMpeg\Format\Video\DefaultVideo::getKiloBitrate
2012-04-13 14:15:56 +02:00
*/
public function testGetKiloBitrate()
{
$this->assertEquals(1000, $this->object->getKiloBitrate());
}
2012-10-11 16:28:48 +02:00
/**
* @covers FFMpeg\Format\Video\DefaultVideo::getExtraParams
*/
public function testGetExtraParams()
{
$this->assertTrue(is_array($this->object->getExtraParams()));
}
2012-04-13 12:09:11 +02:00
}
2012-05-25 20:53:56 +02:00
class DefaultVideoTester extends DefaultVideo
2012-04-13 12:09:11 +02:00
{
protected $audioCodec = 'audiocodec1';
protected $videoCodec = 'videocodec2';
public function supportBFrames()
{
return true;
}
2012-04-13 15:44:46 +02:00
public function getAvailableAudioCodecs()
2012-04-13 12:09:11 +02:00
{
return array('audiocodec1', 'audiocodec2', 'audiocodec3');
}
2012-04-13 15:44:46 +02:00
public function getAvailableVideoCodecs()
2012-04-13 12:09:11 +02:00
{
return array('videocodec1', 'videocodec2');
}
public function getExtraParams()
{
2012-10-11 16:28:48 +02:00
return array('-f', 'format');
2012-04-13 12:09:11 +02:00
}
}