From 0caf7c5d3ee0e51092a51b7d370530862e75fb19 Mon Sep 17 00:00:00 2001 From: Guillaume du Pontavice Date: Tue, 13 Mar 2018 23:11:53 -0700 Subject: [PATCH] testSmoothSwitch : use currentTime instead of readyState as test condition --- tests/functional/auto/setup.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/tests/functional/auto/setup.js b/tests/functional/auto/setup.js index e60865d79d6..ffaace10e50 100644 --- a/tests/functional/auto/setup.js +++ b/tests/functional/auto/setup.js @@ -159,13 +159,19 @@ describe('testing hls.js playback in the browser on "' + browserDescription + '" video.onloadeddata = function () { window.switchToHighestLevel('next'); }; - window.setTimeout(function () { - let readyState = video.readyState; - console.log('[log] > readyState:' + readyState); - callback({ code: readyState, logs: window.logString }); - }, 12000); + window.hls.on(window.Hls.Events.LEVEL_SWITCHED, function (event, data) { + var currentTime = video.currentTime; + if (data.level === window.hls.levels.length - 1) { + console.log('[log] > switched on level:' + data.level); + window.setTimeout(function () { + var newCurrentTime = video.currentTime; + console.log('[log] > currentTime delta :' + (newCurrentTime - currentTime)); + callback({ code: newCurrentTime > currentTime, logs: window.logString }); + }, 2000); + } + }); }, url, config).then(function (result) { - assert.strictEqual(result.code, 4); + assert.strictEqual(result.code, true); }); }; };