423037c5 by David LaPalomento

Add playlist loader files to karma config.

Merge branch 'master' into feature/playlist-loader

Conflicts:
	test/videojs-hls.html
2 parents 8364bbf5 600ff0f1
...@@ -3,6 +3,8 @@ node_js: ...@@ -3,6 +3,8 @@ node_js:
3 - '0.10' 3 - '0.10'
4 before_script: 4 before_script:
5 - npm install -g grunt-cli 5 - npm install -g grunt-cli
6 - curl https://gist.githubusercontent.com/santiycr/5139565/raw/sauce_connect_setup.sh
7 | bash
6 notifications: 8 notifications:
7 hipchat: 9 hipchat:
8 rooms: 10 rooms:
...@@ -11,9 +13,7 @@ notifications: ...@@ -11,9 +13,7 @@ notifications:
11 channels: 13 channels:
12 - "chat.freenode.net#videojs" 14 - "chat.freenode.net#videojs"
13 use_notice: true 15 use_notice: true
14 #addons: 16 env:
15 #sauce_connect: 17 global:
16 #username: 18 - secure: dM7svnHPPu5IiUMeFWW5zg+iuWNpwt6SSDi3MmVvhSclNMRLesQoRB+7Qq5J/LiKhmjpv1/GlNVV0CTsHMRhZNwQ3fo38eEuTXv99aAflEITXwSEh/VntKViHbGFubn06EnVkJoH6MX3zJ6kbiwc2QdSQbywKzS6l6quUEpWpd0=
17 #secure: "Y++AtTlMXkcPAx+K0cL6uzn4FlmfiIki5bkGCkowoYSCxq1X9tNta39JONSVSeZKBlP58GJwNJdB4Wq1CpJL4NriGc3UvpcgNcrILGOWLczX0zFvXkOIaLn0bUuierf4wzUjk3i6XOh83NrMaX+gBHXb8RVUEBf2z0/WM3zHrEM=" 19 - secure: AnduYGXka5ft1x7V3SuVYqvlKLvJGhUaRNFdy4UDJr3ZVuwpQjE4TMDG8REmJIJvXfHbh4qY4N1cFSGnXkZ4bH21Xk0v9DLhsxbarKz+X2BvPgXs+Af9EQ6vLEy/5S1vMLxfT5+y+Ec5bVNGOsdUZby8Y21CRzSg6ADN9kwPGlE=
18 #access_key:
19 #secure: "bCan88WIWqm6jP4ZtDbLVrrGXe1a33otfQhi7SYp95wHFLemUHS1JyXv+HbbbsW5dNjatfdhzvc47bpw4LbccL6evVR9sb2Tld15TxW2a2WQtMPzvOfj55aP1YQtIxYwy14swifWGK/Lj/A0ZUCUNolCf7DjCK6hZGaWaDRtdIE="
......
...@@ -259,10 +259,31 @@ module.exports = function(grunt) { ...@@ -259,10 +259,31 @@ module.exports = function(grunt) {
259 'concat', 259 'concat',
260 'uglify']); 260 'uglify']);
261 261
262 grunt.registerTask('test', ['jshint', 'manifests-to-js', 'karma:saucelabs']); 262 // The test task will run `karma:saucelabs` when running in travis,
263 // otherwise, it'll default to running karma in chrome.
264 // You can specify which browsers to build with by using grunt-style arguments
265 // or separating them with a comma:
266 // grunt test:chrome:firefox # grunt-style
267 // grunt test:chrome,firefox # comma-separated
268 grunt.registerTask('test', function() {
269 var tasks = this.args;
263 270
264 // travis build task 271 grunt.task.run(['jshint', 'manifests-to-js']);
265 grunt.registerTask('test-local', ['jshint', 'manifests-to-js', 'qunit']);
266 272
273 if (process.env.TRAVIS) {
274 grunt.task.run(['karma:saucelabs']);
275 } else {
276 if (tasks.length === 0) {
277 tasks.push('chrome');
278 }
279 if (tasks.length === 1) {
280 tasks = tasks[0].split(',');
281 }
282 tasks = tasks.map(function(el) {
283 return 'karma:' + el;
284 });
267 285
286 grunt.task.run(tasks);
287 }
288 });
268 }; 289 };
......
...@@ -114,6 +114,25 @@ Fired immediately after a new master or media playlist has been ...@@ -114,6 +114,25 @@ Fired immediately after a new master or media playlist has been
114 downloaded. By default, the plugin only downloads playlists as they 114 downloaded. By default, the plugin only downloads playlists as they
115 are needed. 115 are needed.
116 116
117 ### Testing
118
119 For testing, you can either run `npm test` or use `grunt` directly.
120 If you use `npm test`, it will only run the karma tests using chrome.
121 You can specify which browsers you want the tests to run via grunt's `test` task.
122 You can use either grunt-style arguments or comma separated arguments:
123 ```
124 grunt test:chrome:firefox # grunt-style
125 grunt test:chrome,firefox # comma-separated
126 ```
127 Possible options are:
128 * `chromecanary`
129 * `phantomjs`
130 * `opera`
131 * `chrome`
132 * `safari`
133 * `firefox`
134 * `ie`
135
117 ## Hosting Considerations 136 ## Hosting Considerations
118 Unlike a native HLS implementation, the HLS plugin has to comply with 137 Unlike a native HLS implementation, the HLS plugin has to comply with
119 the browser's security policies. That means that all the files that 138 the browser's security policies. That means that all the files that
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
10 }, 10 },
11 "license": "Apache 2", 11 "license": "Apache 2",
12 "scripts": { 12 "scripts": {
13 "test": "grunt test-local" 13 "test": "grunt test"
14 }, 14 },
15 "devDependencies": { 15 "devDependencies": {
16 "grunt": "~0.4.1", 16 "grunt": "~0.4.1",
......
...@@ -117,6 +117,10 @@ ...@@ -117,6 +117,10 @@
117 return; 117 return;
118 } 118 }
119 119
120 //strip off any carriage returns here so the regex matching
121 //doesn't have to account for them.
122 line = line.replace('\r','');
123
120 // Tags 124 // Tags
121 match = /^#EXTM3U/.exec(line); 125 match = /^#EXTM3U/.exec(line);
122 if (match) { 126 if (match) {
......
...@@ -5,6 +5,45 @@ ...@@ -5,6 +5,45 @@
5 // 3. Run your tests 5 // 3. Run your tests
6 6
7 module.exports = function(config) { 7 module.exports = function(config) {
8 var customLaunchers = {
9 chrome_sl: {
10 singleRun: true,
11 base: 'SauceLabs',
12 browserName: 'chrome',
13 platform: 'Windows 7',
14 version: '34'
15 },
16
17 firefox_sl: {
18 singleRun: true,
19 base: 'SauceLabs',
20 browserName: 'firefox',
21 platform: 'Windows 8'
22 },
23
24 safari_sl: {
25 singleRun: true,
26 base: 'SauceLabs',
27 browserName: 'safari',
28 platform: 'OS X 10.8'
29 },
30
31 ipad_sl: {
32 singleRun: true,
33 base: 'SauceLabs',
34 browserName: 'ipad',
35 platform:'OS X 10.9',
36 version: '7.1'
37 },
38
39 android_sl: {
40 singleRun: true,
41 base: 'SauceLabs',
42 browserName: 'android',
43 platform:'Linux'
44 }
45 };
46
8 config.set({ 47 config.set({
9 // base path, that will be used to resolve files and exclude 48 // base path, that will be used to resolve files and exclude
10 basePath: '', 49 basePath: '',
...@@ -17,20 +56,12 @@ module.exports = function(config) { ...@@ -17,20 +56,12 @@ module.exports = function(config) {
17 // Setting singleRun to true here will start up your specified browsers, run tests, and then shut down the browsers. Helpful to have in a CI environment, where you don't want to leave browsers running continuously. 56 // Setting singleRun to true here will start up your specified browsers, run tests, and then shut down the browsers. Helpful to have in a CI environment, where you don't want to leave browsers running continuously.
18 singleRun: true, 57 singleRun: true,
19 58
20 // Start these browsers, currently available: 59 // custom launchers for sauce labs
21 // - Chrome 60 //define SL browsers
22 // - ChromeCanary 61 customLaunchers: customLaunchers,
23 // - Firefox 62
24 // - Opera 63 // Start these browsers
25 // - Safari (only Mac) 64 browsers: ['chrome_sl', 'ipad_sl'], //Object.keys(customLaunchers),
26 // - PhantomJS
27 // - IE (only Windows)
28 // Example usage:
29 browsers: ['chrome_test'],
30 //'firefox_test',
31 //'safari_test',
32 //'ipad_test',
33 //'android_test'
34 65
35 // List of files / patterns to load in the browser 66 // List of files / patterns to load in the browser
36 // Add any new src files to this list. 67 // Add any new src files to this list.
...@@ -39,23 +70,28 @@ module.exports = function(config) { ...@@ -39,23 +70,28 @@ module.exports = function(config) {
39 // add their paths to this list. 70 // add their paths to this list.
40 71
41 files: [ 72 files: [
73 '../node_modules/sinon/lib/sinon.js',
74 '../node_modules/sinon/lib/sinon/util/event.js',
75 '../node_modules/sinon/lib/sinon/util/fake_xml_http_request.js',
76 '../node_modules/sinon/lib/sinon/util/xhr_ie.js',
77 '../node_modules/sinon/lib/sinon/util/fake_timers.js',
42 '../node_modules/video.js/dist/video-js/video.js', 78 '../node_modules/video.js/dist/video-js/video.js',
43 '../node_modules/videojs-contrib-media-sources/src/videojs-media-sources.js', 79 '../node_modules/videojs-contrib-media-sources/src/videojs-media-sources.js',
44 '../test/karma-qunit-shim.js', 80 '../test/karma-qunit-shim.js',
45 "../src/videojs-hls.js", 81 '../src/videojs-hls.js',
46 "../src/flv-tag.js", 82 '../src/flv-tag.js',
47 "../src/exp-golomb.js", 83 '../src/exp-golomb.js',
48 "../src/h264-stream.js", 84 '../src/h264-stream.js',
49 "../src/aac-stream.js", 85 '../src/aac-stream.js',
50 "../src/segment-parser.js", 86 '../src/segment-parser.js',
51 "../src/stream.js", 87 '../src/stream.js',
52 "../src/m3u8/m3u8-parser.js", 88 '../src/m3u8/m3u8-parser.js',
53 "../tmp/manifests.js", 89 '../src/playlist-loader.js',
54 "../tmp/expected.js", 90 '../tmp/manifests.js',
55 "tsSegment-bc.js", 91 '../tmp/expected.js',
56 "../src/bin-utils.js", 92 'tsSegment-bc.js',
57 "../src/async-queue.js", 93 '../src/bin-utils.js',
58 '../test/*.js' 94 '../test/*.js'
59 ], 95 ],
60 96
61 plugins: [ 97 plugins: [
...@@ -69,16 +105,9 @@ module.exports = function(config) { ...@@ -69,16 +105,9 @@ module.exports = function(config) {
69 'karma-sauce-launcher' 105 'karma-sauce-launcher'
70 ], 106 ],
71 107
72 // list of files to exclude
73 exclude: [
74
75 ],
76
77
78 // test results reporter to use 108 // test results reporter to use
79 // possible values: 'dots', 'progress', 'junit' 109 // possible values: 'dots', 'progress', 'junit'
80 reporters: ['progress'], 110 reporters: ['dots', 'progress'],
81
82 111
83 // web server port 112 // web server port
84 port: 9876, 113 port: 9876,
...@@ -103,46 +132,6 @@ module.exports = function(config) { ...@@ -103,46 +132,6 @@ module.exports = function(config) {
103 build: process.env.TRAVIS_BUILD_NUMBER, 132 build: process.env.TRAVIS_BUILD_NUMBER,
104 testName: process.env.TRAVIS_BUILD_NUMBER + process.env.TRAVIS_BRANCH, 133 testName: process.env.TRAVIS_BUILD_NUMBER + process.env.TRAVIS_BRANCH,
105 recordScreenshots: false 134 recordScreenshots: false
106 },
107
108 //define SL browsers
109 customLaunchers: {
110 chrome_test: {
111 singleRun: true,
112 base: 'SauceLabs',
113 browserName: 'chrome',
114 platform: 'Windows XP'
115 },
116
117 firefox_test: {
118 singleRun: true,
119 base: 'SauceLabs',
120 browserName: 'firefox',
121 platform: 'Windows 8'
122 },
123
124 safari_test: {
125 singleRun: true,
126 base: 'SauceLabs',
127 browserName: 'safari',
128 platform: 'OS X 10.8'
129 },
130
131 ipad_test: {
132 singleRun: true,
133 base: 'SauceLabs',
134 browserName: 'ipad',
135 platform:'OS X 10.8'
136 },
137
138 android_test: {
139 singleRun: true,
140 base: 'SauceLabs',
141 browserName: 'android',
142 platform:'Linux'
143 }
144
145 } 135 }
146
147 }); 136 });
148 }; 137 };
......
...@@ -34,23 +34,28 @@ module.exports = function(config) { ...@@ -34,23 +34,28 @@ module.exports = function(config) {
34 // add their paths to this list. 34 // add their paths to this list.
35 35
36 files: [ 36 files: [
37 '../node_modules/sinon/lib/sinon.js',
38 '../node_modules/sinon/lib/sinon/util/event.js',
39 '../node_modules/sinon/lib/sinon/util/fake_xml_http_request.js',
40 '../node_modules/sinon/lib/sinon/util/xhr_ie.js',
41 '../node_modules/sinon/lib/sinon/util/fake_timers.js',
37 '../node_modules/video.js/dist/video-js/video.js', 42 '../node_modules/video.js/dist/video-js/video.js',
38 '../node_modules/videojs-contrib-media-sources/src/videojs-media-sources.js', 43 '../node_modules/videojs-contrib-media-sources/src/videojs-media-sources.js',
39 '../test/karma-qunit-shim.js', 44 '../test/karma-qunit-shim.js',
40 "../src/videojs-hls.js", 45 '../src/videojs-hls.js',
41 "../src/flv-tag.js", 46 '../src/flv-tag.js',
42 "../src/exp-golomb.js", 47 '../src/exp-golomb.js',
43 "../src/h264-stream.js", 48 '../src/h264-stream.js',
44 "../src/aac-stream.js", 49 '../src/aac-stream.js',
45 "../src/segment-parser.js", 50 '../src/segment-parser.js',
46 "../src/stream.js", 51 '../src/stream.js',
47 "../src/m3u8/m3u8-parser.js", 52 '../src/m3u8/m3u8-parser.js',
48 "../tmp/manifests.js", 53 '../src/playlist-loader.js',
49 "../tmp/expected.js", 54 '../tmp/manifests.js',
50 "tsSegment-bc.js", 55 '../tmp/expected.js',
51 "../src/bin-utils.js", 56 'tsSegment-bc.js',
52 "../src/async-queue.js", 57 '../src/bin-utils.js',
53 '../test/*.js' 58 '../test/*.js'
54 ], 59 ],
55 60
56 plugins: [ 61 plugins: [
...@@ -88,7 +93,7 @@ module.exports = function(config) { ...@@ -88,7 +93,7 @@ module.exports = function(config) {
88 93
89 // level of logging 94 // level of logging
90 // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG 95 // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
91 //logLevel: config.LOG_INFO, 96 logLevel: config.LOG_DISABLE,
92 97
93 // If browser does not capture in given timeout [ms], kill it 98 // If browser does not capture in given timeout [ms], kill it
94 captureTimeout: 60000 99 captureTimeout: 60000
......
...@@ -206,6 +206,23 @@ ...@@ -206,6 +206,23 @@
206 manifest.substring(manifest.indexOf(',') + 1, manifest.length - 1), 206 manifest.substring(manifest.indexOf(',') + 1, manifest.length - 1),
207 'the title is parsed'); 207 'the title is parsed');
208 }); 208 });
209 test('parses #EXTINF tags with carriage returns', function() {
210 var
211 manifest = '#EXTINF:13,Does anyone really use the title attribute?\r\n',
212 element;
213 parseStream.on('data', function(elem) {
214 element = elem;
215 });
216 lineStream.push(manifest);
217
218 ok(element, 'an event was triggered');
219 strictEqual(element.type, 'tag', 'the line type is tag');
220 strictEqual(element.tagType, 'inf', 'the tag type is inf');
221 strictEqual(element.duration, 13, 'the duration is parsed');
222 strictEqual(element.title,
223 manifest.substring(manifest.indexOf(',') + 1, manifest.length - 2),
224 'the title is parsed');
225 });
209 226
210 // #EXT-X-TARGETDURATION 227 // #EXT-X-TARGETDURATION
211 test('parses minimal #EXT-X-TARGETDURATION tags', function() { 228 test('parses minimal #EXT-X-TARGETDURATION tags', function() {
......