diff --git a/spec/index.spec.js b/spec/index.spec.js index 59b9302..069e7c3 100644 --- a/spec/index.spec.js +++ b/spec/index.spec.js @@ -7,8 +7,17 @@ var cordova = require('./helper/cordova'); var mediaDevices = require('../www/mediadevices'); var MediaStream = require('../www/mediastream'); +var MediaStreamTrack = require('../www/mediastreamtrack'); var mockStream = { id: 'ack', audioTracks: [], videoTracks: [] }; +var mockTrack = { + kind: 'audio', + id: 'ack', + label: 'Internal microphone', + enabled: true, + muted: false, + readyState: 'live' +}; /*! * Specification. @@ -57,4 +66,34 @@ describe('phonegap-plugin-media-stream', function () { expect(typeof stream.clone).toBe('function'); }); }); + + describe('MediaStreamTrack', function () { + it('MediaStreamTrack constructor', function () { + var track = new MediaStreamTrack(mockTrack); + + expect(track).toBeDefined(); + expect(typeof track).toBe('object'); + expect(track.kind).toEqual('audio'); + expect(track.id).toEqual('ack'); + expect(track.label).toEqual('Internal microphone'); + expect(track.enabled).toEqual(true); + expect(track.muted).toEqual(false); + // expect(track.onmute).toEqual(''); + // expect(track.onunmute).toEqual(''); + // expect(track.onended).toEqual(''); + expect(track.readyState).toEqual('live'); + expect(track.clone).toBeDefined(); + expect(typeof track.clone).toBe('function'); + expect(track.stop).toBeDefined(); + expect(typeof track.stop).toBe('function'); + expect(track.getCapabilities).toBeDefined(); + expect(typeof track.getCapabilities).toBe('function'); + expect(track.getConstraints).toBeDefined(); + expect(typeof track.getConstraints).toBe('function'); + expect(track.getSettings).toBeDefined(); + expect(typeof track.getSettings).toBe('function'); + expect(track.applyConstraints).toBeDefined(); + expect(typeof track.applyConstraints).toBe('function'); + }); + }); }); diff --git a/www/mediastreamtrack.js b/www/mediastreamtrack.js new file mode 100644 index 0000000..f5c04a6 --- /dev/null +++ b/www/mediastreamtrack.js @@ -0,0 +1,38 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * +*/ + +var MediaStreamTrack = function (track) { + this.kind = track.kind; + this.id = track.id; + this.label = track.label; + this.enabled = track.enabled; + this.muted = track.muted; + this.readyState = track.readyState; +}; + +MediaStreamTrack.prototype.clone = function () {}; +MediaStreamTrack.prototype.stop = function () {}; +MediaStreamTrack.prototype.getCapabilities = function () {}; +MediaStreamTrack.prototype.getConstraints = function () {}; +MediaStreamTrack.prototype.getSettings = function () {}; +MediaStreamTrack.prototype.applyConstraints = function () {}; + +module.exports = MediaStreamTrack;