-
-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add iOS HLS tests #2668
Add iOS HLS tests #2668
Changes from all commits
7b8ceba
84b8894
8c43f5b
ccd5e23
801058c
4acdbca
94b5c21
622dc98
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -152,6 +152,114 @@ suite('shader', function () { | |
instance.attributes['src'])); | ||
}); | ||
|
||
// Skip since this fails Travis CI Firefox run, even though it works on Chrome, and with local Firefox. | ||
test.skip('iOS HLS video uses appropriate shader', function (done) { | ||
var shader = this.shader; | ||
var el = this.el; | ||
var initSpy = this.sinon.spy(shader.prototype, 'init'); | ||
var updateSpy = this.sinon.spy(shader.prototype, 'update'); | ||
assert.notOk(initSpy.called); | ||
assert.notOk(updateSpy.called); | ||
|
||
// Mock iOS. NOTE: this doesn't work... el.sceneEl.isIOS = true; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any ideas why this wouldn't work? We set the boolean and it checks the boolean There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it may work now (I didn't clean up the skipped tests per the last changes) but I don't have the time to spare to investigate that |
||
var realIsIOS = AFRAME.utils.device.isIOS; | ||
AFRAME.utils.device.isIOS = function () { return true; }; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. perhaps, but I don't have the time to spare to investigate that |
||
assert.equal(AFRAME.utils.device.isIOS(), true); | ||
|
||
// Set up and verify video element to be treated as HLS. | ||
var videoEl = document.createElement('video'); | ||
videoEl.src = VIDEO; | ||
videoEl.type = 'application/x-mpegurl'; | ||
assert.equal(AFRAME.utils.material.isHLS(videoEl.src, videoEl.type), true); | ||
|
||
// With Travis CI, the actual videos are apparently never loaded fully, | ||
// so checking shader instance in materialvideoloadeddata fails; | ||
// however shader substition is still performed, so the test does not fail. | ||
el.addEventListener('materialvideoloadeddata', function () { | ||
var material = el.components.material; | ||
if (!material) { return; } | ||
|
||
// Verify system thought this was iOS HLS. | ||
assert.equal(AFRAME.utils.device.isIOS(), true); | ||
assert.equal(AFRAME.utils.material.isHLS(videoEl.src, videoEl.type), true); | ||
|
||
// Wait for other handlers to fire. | ||
setTimeout(function () { | ||
// Undo mock of iOS. | ||
AFRAME.utils.device.isIOS = realIsIOS; | ||
|
||
// Verify shader was substituted. | ||
assert.equal(material.data.shader, 'ios10hls'); | ||
|
||
done(); | ||
}); | ||
}); | ||
el.setAttribute('material', {shader: 'testShader', src: videoEl}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to specify There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know, the original test on which this was based did so kept it, I don't have the time to spare to investigate that |
||
var material = el.components.material; | ||
var instance = material.shader; | ||
assert.ok(instance); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we need to assert these, should keep focused on what we want to assert (e.g., the shader is switched) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the original test on which this was based did so kept it |
||
assert.ok(initSpy.calledOnce); | ||
assert.ok(updateSpy.calledOnce); | ||
// The value won't be assigned until the texture loads. | ||
assert.ok(instance.uniforms['src']); | ||
assert.notOk(instance.attributes && (instance.attributes['map'] || | ||
instance.attributes['src'])); | ||
}); | ||
|
||
// Skip since this fails Travis CI Firefox run, even though it works on Chrome, and with local Firefox. | ||
test.skip('iOS HLS video uses appropriate shader (setAttribute)', function (done) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a large test, hard to spot what's different from the previous one There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. agreed, maybe we should just remove the skipped tests for now? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think one of the two tests should suffice, I can help try to simplify. |
||
var shader = this.shader; | ||
var el = this.el; | ||
var initSpy = this.sinon.spy(shader.prototype, 'init'); | ||
var updateSpy = this.sinon.spy(shader.prototype, 'update'); | ||
assert.notOk(initSpy.called); | ||
assert.notOk(updateSpy.called); | ||
|
||
// Mock iOS. NOTE: this doesn't work... el.sceneEl.isIOS = true; | ||
var realIsIOS = AFRAME.utils.device.isIOS; | ||
AFRAME.utils.device.isIOS = function () { return true; }; | ||
assert.equal(AFRAME.utils.device.isIOS(), true); | ||
|
||
// Set up and verify video element to be treated as HLS. | ||
var videoEl = document.createElement('video'); | ||
videoEl.setAttribute('src', VIDEO); | ||
videoEl.setAttribute('type', 'application/x-mpegurl'); | ||
assert.equal(AFRAME.utils.material.isHLS(videoEl.getAttribute('src'), videoEl.getAttribute('type')), true); | ||
|
||
// With Travis CI, the actual videos are apparently never loaded fully, | ||
// so checking shader instance in materialvideoloadeddata fails; | ||
// however shader substition is still performed, so the test does not fail. | ||
el.addEventListener('materialvideoloadeddata', function () { | ||
var material = el.components.material; | ||
if (!material) { return; } | ||
|
||
// Verify system thought this was iOS HLS. | ||
assert.equal(AFRAME.utils.device.isIOS(), true); | ||
assert.equal(AFRAME.utils.material.isHLS(videoEl.getAttribute('src'), videoEl.getAttribute('type')), true); | ||
|
||
// Wait for other handlers to fire. | ||
setTimeout(function () { | ||
// Undo mock of iOS. | ||
AFRAME.utils.device.isIOS = realIsIOS; | ||
|
||
// Verify shader was substituted. | ||
assert.equal(material.data.shader, 'ios10hls'); | ||
|
||
done(); | ||
}); | ||
}); | ||
el.setAttribute('material', {shader: 'testShader', src: videoEl}); | ||
var material = el.components.material; | ||
var instance = material.shader; | ||
assert.ok(instance); | ||
assert.ok(initSpy.calledOnce); | ||
assert.ok(updateSpy.calledOnce); | ||
// The value won't be assigned until the texture loads. | ||
assert.ok(instance.uniforms['src']); | ||
assert.notOk(instance.attributes && (instance.attributes['map'] || | ||
instance.attributes['src'])); | ||
}); | ||
|
||
test('otherMap loads inline video', function (done) { | ||
var shader = this.shader; | ||
var el = this.el; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* global assert, suite, test */ | ||
var isHLS = require('utils').material.isHLS; | ||
|
||
suite('utils.isHLS', function () { | ||
test('survives falsy input (negative)', function () { | ||
assert.equal(isHLS(undefined, undefined), false); | ||
assert.equal(isHLS('', ''), false); | ||
assert.equal(isHLS(null, null), false); | ||
assert.equal(isHLS(0, 0), false); | ||
}); | ||
|
||
test('type application/x-mpegurl', function () { | ||
assert.equal(isHLS(undefined, 'application/x-mpegurl'), true); | ||
}); | ||
|
||
test('type application/x-mpegURL', function () { | ||
assert.equal(isHLS(undefined, 'application/x-mpegURL'), true); | ||
}); | ||
|
||
test('type application/vnd.apple.mpegurl', function () { | ||
assert.equal(isHLS(undefined, 'application/vnd.apple.mpegurl'), true); | ||
}); | ||
|
||
test('type application/x-mpegurl even if src says .mp4', function () { | ||
assert.equal(isHLS('dummy.mp4', 'application/x-mpegurl'), true); | ||
}); | ||
|
||
test('src containing .mp4 (negative)', function () { | ||
assert.equal(isHLS('dummy.mp4', ''), false); | ||
}); | ||
|
||
test('src containing .m3u8', function () { | ||
assert.equal(isHLS('dummy.m3u8', ''), true); | ||
}); | ||
|
||
test('src containing .M3U8', function () { | ||
assert.equal(isHLS('dummy.M3U8', ''), true); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we know where Firefox fails? Might be a timing issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, but it is irrelevant since the actual substitution code won't be ever really be fired using Firefox, and I don't have the time to spare to investigate that