-
Notifications
You must be signed in to change notification settings - Fork 29
Adding new tests
If your tests are not related to one of the existing modules you can create a new module. For that reason, create a new folder in the root directory of the project. Assuming our new module is called TestModule
we create a folder TestModule
in DASH-IF-Conformance
.
Each module uses a file called module.php
that is a subclass of ModuleInterface
. For our new module to be correctly registered with the test suite we need to override some of the methods of the parent class. Details about the different available hooks like hookRepresentation
can be found in the moduleInterface. A basic implementation looks like the following:
<?php
namespace DASHIF;
class TestModule extends ModuleInterface
{
public function __construct()
{
parent::__construct();
$this->name = "TestModule";
}
protected function addCLIArguments()
{
global $argumentParser;
$argumentParser->addOption("test", "ts", "test", "Enable Test module checking");
}
public function handleArguments()
{
global $argumentParser;
if ($argumentParser->getOption("test")) {
$this->enabled = true;
}
}
public function hookRepresentation()
{
parent::hookRepresentation();
$this->validateTest();
}
private function validateDolby()
{
include 'impl/validateTest.php';
}
}
$modules[] = new TestModule();
The ModuleInterface
defines different hooks that at certain points of time during the validation process. For instance, the hookRepresentation
hook runs after downloading and validating the first segment of each Period - AdaptationSet combination. By overriding the corresponding hook method, implementations can add new tests. For instance:
public function hookRepresentation()
{
parent::hookRepresentation();
$this->validateSegment();
}
private function validateSegment()
{
include 'impl/validateSegment.php';
}
Note that typically the included files such a impl/validateSegment.php
contain no function but code that is directly executed after being included. For instance, the impl/validateSegment.php
file might look like this:
<?php
global $session;
$rep_xml = $session->getSelectedRepresentationDir() . '/atomInfo.xml';
if (!file_exists($rep_xml)) {
return;
}
$xml = DASHIF\Utility\parseDOM($rep_xml, 'atomlist');
if (!$xml) {
return;
}
$this->validateSegmentCommon($xml);
$this->validateSegmentOnDemand($xml);
A test assertion can be defined with the global $logger
object. The structure is as follows:
$logger->test(
"<Specification>",
"<Section>",
"<Test description>",
$test
"<Fail Type>",
"<Success Message>",
"<Fail Message>"
);
As an example:
$logger->test(
"DASH-IF IOP 4.3",
"Section 6.2.5.2",
"For HEVC video data, if the @bitstreamswitching flag is set to true, all Representations SHALL include " .
"Initialitization Segment containing 'hvcC' box",
$codecBoxes->length > 0,
"FAIL",
$codecBoxes->length . " 'hvcC' boxes found for Period $selectedPeriod Adaptation Set $selectedAdaptation " .
"Representation $selectedRepresentation.",
"No 'hvcC' boxes found for Period $selectedPeriod Adaptation Set $selectedAdaptation " .
"Representation $selectedRepresentation."
);