-
-
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
Conversation
…n to materialtextureloaded to make it testable
b504f88
to
8c43f5b
Compare
Doing the tests was a bit ugly, but they are now fully functional; in particular, there is not a mechanism to mock things like |
I meant In the system, if you change the utils.device.isIOS call to check the scene value, it should be easily mockable by setting the scene.isIOS. |
…bute; fix shader substitution tests
73d4802
to
ccd5e23
Compare
aaargh, for some reason even though shader substitution test works on firefox and chrome on my machine, it fails on firefox in the cloud. :-/ gonna have to disable those tests for now as I don't have more time to spend on that |
a79a0cb
to
801058c
Compare
src/systems/material.js
Outdated
@@ -146,7 +146,7 @@ module.exports.System = registerSystem('material', { | |||
setTextureProperties(texture, data); | |||
|
|||
// if we're on iOS, and the video is HLS, we currently need to do some hacks | |||
if (utils.device.isIOS() && isHLS(videoEl)) { | |||
if (utils.device.isIOS() && isHLS(videoEl.src || videoEl.getAttribute('src'), videoEl.type || videoEl.getAttribute('type'))) { |
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.
Just to confirm, you tried changing utils.device.isIOS()
here to this.el.sceneEl.isIOS
, and in the test, try mocking sceneEl.isIOS = true
before the assertions?
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, i thought you were saying the substitution had already been done, so only changing the flag was necessary. if the function has to be monkey patched, not sure it is any clearer to do it as you suggest rather than directly manipulating to return desired value
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.
here the check for the property and if none the getAttribute value was unexpectedly required for both synthetic tests and actual real-world usage to work correctly.
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.
Use sceneEl.iIOS here so it doesn't have to run the user agent parse again, and you can stub it in the tests.
docs/core/utils.md
Outdated
@@ -151,6 +151,13 @@ Checks if device is Gear VR. Returns a `boolean`. | |||
|
|||
Checks if device is a smartphone. Returns a `boolean`. | |||
|
|||
## `AFRAME.utils.material` | |||
|
|||
### `AFRAME.utils.material.isHLS (src, type)` |
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.
I don't think this has to be public API
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.
it did to be accessible in tests...?
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.
Public API meaning documented
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.
ah, I understand you now.
This reverts commit 8c43f5b.
@ngokevin good now? |
src/utils/material.js
Outdated
@@ -118,11 +120,16 @@ function handleTextureEvents (el, texture) { | |||
|
|||
// Video events. | |||
if (!texture.image || texture.image.tagName !== 'VIDEO') { return; } | |||
|
|||
texture.image.addEventListener('loadeddata', function emitVideoTextureLoadedDataAll () { | |||
// Check to see if we need to use iOS 10 HLS shader. | |||
if (texture.needsCorrectionBGRA && texture.needsCorrectionFlipY) { |
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.
Can do:
if (texture.needsCorrectionBGRA && texture.needsCorrectionFlipY &&
['standard', 'flat', 'testShader'].indexOf(el.components.material.data.shader) !== -1)
indexOf
to be safe
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.
One thing I was considering is passing needsCorrectionBGRA
and needsCorrectionFlipY
into shaders in general when true, so someone with a custom shader would know when corrections are necessary. Thoughts?
@@ -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. |
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
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 comment
The 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 comment
The 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
|
||
// Mock iOS. NOTE: this doesn't work... el.sceneEl.isIOS = true; | ||
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 comment
The reason will be displayed to describe this comment to others. Learn more.
this.sinon.stub(AFRAME.utils.device.isIOS, () => true)
might work, if we use sinon, the teardown will automatically restore it.
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.
perhaps, but I don't have the time to spare to investigate that
done(); | ||
}); | ||
}); | ||
el.setAttribute('material', {shader: 'testShader', src: videoEl}); |
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 need to specify testShader
?
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.
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
el.setAttribute('material', {shader: 'testShader', src: videoEl}); | ||
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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
the original test on which this was based did so kept it
}); | ||
|
||
// 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 comment
The 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 comment
The 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 comment
The 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.
@ngokevin if you have the time to tidy up whichever of the skipped tests you prefer and get rid of the other one, that should wrap this one up |
Will do right now, thanks! |
Cleaned up at a2d641a
|
nice @ngokevin, thank you! |
Add tests and do minor refactoring per discussion on #2597