Skip to content
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

Start of split into platform dependent code and testable code #9

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

tangstad
Copy link

I started some work on splitting up the code as we discussed earlier. Consider the code so far as just an introductory example to what I was talking about.

If you want I can continue moving stuff into the current split code or I can assist you in the same work, or you can just use it as an example and ignore it ;)

Platform tests can be run to ensure browser/platform supports
getUserMedia properly and lay the foundation for mockable tests for the
rest of the code not dependent on platform implementation.

These tests are put in a separate runner as they will be run when
updating/changing browser instead of during implementation of the
GumWrapper library on top.

gumwrapper.platformGetUserMedia is added for finding correct platform
getUserMedia function.
To easier do tests while developing, non-minified version of code is used for tests
This is a specifically testable version of GumWrapper allowing
integration with a fake getUserMedia function.
@tagawa
Copy link
Owner

tagawa commented Apr 15, 2013

Thanks for these suggestions. I think I see what you mean.
I'm a bit reluctant to put code in the main library (gumwrapper.js) that's for test purposes only. To keep the distributable part as lightweight as possible, would it still work if window.gumwrapper and its two methods were put in a separate file?

@tangstad
Copy link
Author

There shouldn't be any code in gumwrapper.js that is only for testing, there should be some code there that is both for testing and production, and a very very small piece of code that makes the shared code even easier to use for production. At least that's the intention. I guess I should try to make a clearer example.

For example:

gumwrapper.GenericGum = function(gumfunction) {
 ...
};
gumwrapper.GumWrapper = function(...) {
    return gumwrapper.GenericGum(gumwrapper.platformGetUserMedia, ...);
};

Here GenericGum would have all the functionality, but when testing you would provide an alternative/mock function instead of the actual getUserMedia function. Users would use gumwrapper.GumWrapper which automatically uses the correct getUserMedia.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants