Skip to content

Commit

Permalink
Renaming and additional comments (#18)
Browse files Browse the repository at this point in the history
- Rename |commonTests| into |mediaTests|. The former one sounds like
  some set of helpers, not actual tests implementation.
- Move "framework-like" functions responsible for tests creation from
  |common.js| into |mvtTest.js|. Again, this is by far too important to
  be kept in "common" file
- Move |filterTest.js| into |blocklist.js| and rename variables.
  "Test.js" suffix is used for files that declare some tests.
- Fix case of hard-coded all profile name in |blocklist.js|
  • Loading branch information
maciej-kolanski-red authored Jul 15, 2022
1 parent 25d2ff3 commit edcb845
Show file tree
Hide file tree
Showing 8 changed files with 223 additions and 210 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ Source files are auto formatted by [prettier](https://prettier.io/), which shoul
Tests are grouped into test suites, which differ in streaming type (DASH, HLS, HSS, progressive) and player (Shaka Player, dash.js, hls.js, native).

The test list is generated dynamically based on available streams (`mediaStreams.js`), test templates
(`src/commonTests.js`) and selected profile configuration (e.g. `src/profiles.js`).
(`src/mediaTests.js`) and selected profile configuration (e.g. `src/profiles.js`).
Each test is actually an instantiation of a test template e.g. `DASH-FMP4-AVC1-AAC Playback` and
`DASH-DYNAMIC Playback` share the same test code (`src/commonTests.js::testPlayback`),
`DASH-DYNAMIC Playback` share the same test code (`src/mediaTests.js::testPlayback`),
but use different media stream.

There are six media test templates:
Expand Down
4 changes: 2 additions & 2 deletions coverage.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@
"src/mvtTest.js",
"src/common.js",
"src/engineChange.js",
"src/filterTest.js",
"src/blocklist.js",
"src/baseConfig.js",
"src/profiles.js",
"src/engines.js",
"src/codecSupport.js",
"src/commonTests.js",
"src/mediaTests.js",
"src/codecSupportTests.js",
"src/suites.js",
"src/coverage.js",
Expand Down
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@
"src/mvtTest.js",
"src/common.js",
"src/engineChange.js",
"src/filterTest.js",
"src/blocklist.js",
"src/baseConfig.js",
"src/profiles.js",
"src/engines.js",
"src/codecSupport.js",
"src/commonTests.js",
"src/mediaTests.js",
"src/codecSupportTests.js",
"src/suites.js",
"js_mse_eme/harness/main.js",
Expand Down
73 changes: 73 additions & 0 deletions src/blocklist.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:
*
* Copyright 2022 Liberty Global B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
* Very basic implementation capable of marking some tests as optional/hidden.
* Uses test name comparison, so it does not consider player type or engine version.
*/

"use strict";

const BlockStateEnum = {
ENABLED: 0,
HIDDEN: 1,
OPTIONAL: 2,
};

var TestsBlockList = {
"DASH-MULTIPERIOD Playback": BlockStateEnum.OPTIONAL, // TODO(ONEM-26036)
"DASH-MULTIPERIOD Pause": BlockStateEnum.OPTIONAL, // TODO(ONEM-26036)
"DASH-MULTIPERIOD Position": BlockStateEnum.OPTIONAL, // TODO(ONEM-26036)
"DASH-FMP4-MULTIAUDIO AudioTracks": BlockStateEnum.OPTIONAL, // TODO(ONEM-26279)
"PROG-MKV-EAC3 Position": BlockStateEnum.OPTIONAL,
'audio/mp2t; codecs="mp4a.40.29"(aac)': BlockStateEnum.HIDDEN,
'audio/mp2t; codecs="mp4a.69"(mp3)': BlockStateEnum.HIDDEN,
'audio/mp2t; codecs="mp4a.a5"(ac3)': BlockStateEnum.HIDDEN,
'audio/mp2t; codecs="mp4a.a6"(eac3)': BlockStateEnum.HIDDEN,
'audio/x-matroska; codecs="mp4a.40.29"(aac)': BlockStateEnum.HIDDEN,
'audio/x-matroska; codecs="mp4a.69"(mp3)': BlockStateEnum.HIDDEN,
'audio/x-matroska; codecs="mp4a.a5"(ac3)': BlockStateEnum.HIDDEN,
'audio/x-matroska; codecs="mp4a.a6"(eac3)': BlockStateEnum.HIDDEN,
'audio/x-matroska; codecs="opus"(opus)': BlockStateEnum.HIDDEN,
'video/mp2t; codecs="avc1.64002a"(avc1)': BlockStateEnum.OPTIONAL,
'video/webm; codecs="vp09.02.51.08"(vp9)': BlockStateEnum.OPTIONAL,
'video/x-matroska; codecs="avc1.64002a"(avc1)': BlockStateEnum.OPTIONAL,
'video/x-matroska; codecs="hvc1.2.4.L153.00"(hevc)': BlockStateEnum.OPTIONAL,
'video/x-matroska; codecs="vp09.02.51.08"(vp9)': BlockStateEnum.HIDDEN,
};

function isTestHidden(name) {
if (window.localStorage["profile"] === undefined || window.localStorage["profile"] == "all") {
return false;
}
if (name in TestsBlockList && TestsBlockList[name] == BlockStateEnum.HIDDEN) {
return true;
}
return false;
}

function isTestOptional(name) {
if (window.localStorage["profile"] === undefined || window.localStorage["profile"] == "all") {
return false;
}
if (name in TestsBlockList && TestsBlockList[name] == BlockStateEnum.OPTIONAL) {
return true;
}
return false;
}
136 changes: 0 additions & 136 deletions src/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,139 +24,3 @@ var parseParam = function (param, defaultValue) {
var value = regex.exec(document.URL);
return value ? value[2] : defaultValue;
};

// Frameworky like tests
var createMvtTest = function (tests, testId, category, categorySort, name, mandatory = true) {
if (isTestOptional(name)) {
mandatory = false;
console.log("Test " + name + " is not mandatory");
}
var t = createTest(name, category, mandatory, testId, category + " Tests");
t.prototype.index = tests.length;
if (!(categorySort in tests)) {
tests[categorySort] = [];
}
if (isTestHidden(name)) {
console.log("Test " + name + " has been hidden");
} else {
tests[categorySort].push(t);
}
return t;
};

var finalizeTests = function (tests) {
var tests_ = [];
Object.keys(tests)
.sort()
.forEach((category) => {
tests_ = tests_.concat(tests[category]);
});

for (let index = 0; index < tests_.length; ++index) {
tests_[index].prototype.index = index;
}
return tests_;
};

var createBaselineTest = function (tests, engine, media, sortorder, name, func, timeout) {
var testId = media.testBase + "." + sortorder;
var testname = media.name + " " + name;
var categorySort = sortorder + engine.order + name;
var test = createMvtTest(tests, testId, engine.name + " " + name, categorySort, testname);
test.prototype.timeout = timeout;
test.prototype.title = "Test playback of content " + media.name + " using " + engine.name + " " + name;
test.prototype.onload = function (runner, video) {
if (!test.prototype.playing) {
test.prototype.playing = true;
video.playbackRate = 1;
video.play();
func.bind(this)(video, runner);
}
};
test.prototype.content = media;
engine.setup(test, media);
};

var makeBaselineTests = function (medialist) {
var tests = {};
medialist.forEach((media) => {
getEnginesForMedia(media, function (engine) {
createTestsForMedia(media, tests, engine);
});
});
return finalizeTestSuite(tests);
};

var finalizeTestSuite = function (tests) {
return function () {
var info = "Default Timeout: " + TestBase.timeout + "ms";

var fields = ["passes", "failures", "timeouts"];

return { tests: finalizeTests(tests), info: info, fields: fields, viewType: "default" };
};
};

function createTestsForMedia(media, tests, engine) {
createBaselineTest(tests, engine, media, 1, "Playback", testPlayback, TestBase.timeout);
// TODO: ONEM-26308 Fix Pause tests
// createBaselineTest(tests, engine, media, 2, "Pause", testPause, TestBase.timeout);
if (media.duration == undefined || media.duration > 120) {
// TODO: ONEM-26268 Fix Rate tests
// if (media.video) {
// createBaselineTest(tests, engine, media, 3, "Rate", testPlayRate, TestBase.timeout * 3);
// }
createBaselineTest(tests, engine, media, 4, "Position", testSetPosition, TestBase.timeout * 2);
}
if (media.audio && media.audio.languages) {
createBaselineTest(tests, engine, media, 5, "AudioTracks", testChangeAudioTracks, TestBase.timeout);
}
if (media.subtitles && engine.config.subtitles && engine.config.subtitles.includes(media.subtitles.format)) {
createBaselineTest(tests, engine, media, 6, "Subtitles", testSubtitles, TestBase.timeout);
}
}

var makeTests = function (medialist, category) {
var niceNames = {
dash: "DASH",
hls: "HLS",
progressive: "Progressive",
hss: "HSS",
playready: "PlayReady",
custom: "Custom",
};

if (medialist.length != 0) {
var tests = {};
medialist.forEach((media) => {
getEnginesForMedia(media, function (engine) {
if (!(engine.name in tests)) {
tests[engine.name] = {};
}
createTestsForMedia(media, tests[engine.name], engine);
});
});

for (var engine in tests) {
var testlist = tests[engine];
if (testlist.length != 0) {
var category_engine = category.slice();
category_engine.push(engine);

var category_key = category_engine.join("-") + "-test";
var nice_category = category_engine.map((name) => (niceNames[name] ? niceNames[name] : name));
var category_name = nice_category.join(" ");
var testsuite = finalizeTestSuite(testlist);

var test_desc = {
name: category_name + " Tests",
title: category_name + " Tests",
heading: category_name + " Tests",
tests: testsuite,
};
window.testSuiteDescriptions[category_key] = test_desc;
window.testSuiteVersions[testVersion].testSuites.push(category_key);
}
}
}
};
68 changes: 0 additions & 68 deletions src/filterTest.js

This file was deleted.

7 changes: 7 additions & 0 deletions src/commonTests.js → src/mediaTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@
* limitations under the License.
*/

/**
* Implements media tests.
* All |test*| functions represent a media test - a sequence of actions and expectations, which can be executed on
* a given media stream. Same test code is used multiple times on various streams. Binding between test code
* and media stream is implemented in |src/mvtTest.js:createTestsForMedia|.
*/

"use strict";

function waitForEvent(video, runner, event, predicate = null, maxWaitTimeMs = 10000, times = 1) {
Expand Down
Loading

0 comments on commit edcb845

Please sign in to comment.