Skip to content

Commit

Permalink
MediaStream API: Patch #3 of implementing navigator.getMediaDevices
Browse files Browse the repository at this point in the history
Adds idl files and tests.

Initial patch (1) by tommyw@ from https://codereview.chromium.org/145583015/

BUG=338511

Review URL: https://codereview.chromium.org/286673003

git-svn-id: svn://svn.chromium.org/blink/trunk@175469 bbb929c8-8fbe-4397-9dbb-9b2b20218538
  • Loading branch information
[email protected] committed Jun 4, 2014
1 parent c841600 commit 70b600d
Show file tree
Hide file tree
Showing 6 changed files with 157 additions and 0 deletions.
33 changes: 33 additions & 0 deletions LayoutTests/fast/mediastream/getMediaDevices-expected.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Tests navigator.getMediaDevices

On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".


PASS navigator.getMediaDevices(devicesCallback); did not throw exception.
PASS After getMediaDevices
PASS Devices returned.
PASS devices.length is 3
PASS devices[0].deviceId.length is > 0
PASS devices[1].deviceId.length is > 0
PASS devices[2].deviceId.length is > 0
PASS devices[0].deviceId is not devices[1].deviceId
PASS devices[0].deviceId is not devices[2].deviceId
PASS devices[1].deviceId is not devices[2].deviceId
PASS devices[0].kind is "audioinput"
PASS devices[1].kind is "audiooutput"
PASS devices[2].kind is "videoinput"
PASS devices[0].label.length is > 0
PASS devices[1].label.length is > 0
PASS devices[2].label.length is > 0
PASS devices[0].label is not devices[1].label
PASS devices[0].label is not devices[2].label
PASS devices[1].label is not devices[2].label
PASS devices[0].groupId.length is > 0
PASS devices[1].groupId.length is > 0
PASS devices[2].groupId.length is > 0
PASS devices[0].groupId is devices[1].groupId
PASS devices[0].groupId is not devices[2].groupId
PASS successfullyParsed is true

TEST COMPLETE

51 changes: 51 additions & 0 deletions LayoutTests/fast/mediastream/getMediaDevices.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../resources/js-test.js"></script>
</head>
<body>
<script>
description("Tests navigator.getMediaDevices");

var devices = null;

function devicesCallback(d) {
devices = d;
testPassed('Devices returned.');
shouldBe('devices.length', '3');

shouldBeGreaterThan('devices[0].deviceId.length', '0');
shouldBeGreaterThan('devices[1].deviceId.length', '0');
shouldBeGreaterThan('devices[2].deviceId.length', '0');
shouldNotBe('devices[0].deviceId', 'devices[1].deviceId');
shouldNotBe('devices[0].deviceId', 'devices[2].deviceId');
shouldNotBe('devices[1].deviceId', 'devices[2].deviceId');

shouldBeEqualToString('devices[0].kind', 'audioinput');
shouldBeEqualToString('devices[1].kind', 'audiooutput');
shouldBeEqualToString('devices[2].kind', 'videoinput');

shouldBeGreaterThan('devices[0].label.length', '0');
shouldBeGreaterThan('devices[1].label.length', '0');
shouldBeGreaterThan('devices[2].label.length', '0');
shouldNotBe('devices[0].label', 'devices[1].label');
shouldNotBe('devices[0].label', 'devices[2].label');
shouldNotBe('devices[1].label', 'devices[2].label');

shouldBeGreaterThan('devices[0].groupId.length', '0');
shouldBeGreaterThan('devices[1].groupId.length', '0');
shouldBeGreaterThan('devices[2].groupId.length', '0');
shouldBe('devices[0].groupId', 'devices[1].groupId');
shouldNotBe('devices[0].groupId', 'devices[2].groupId');

finishJSTest();
}

shouldNotThrow("navigator.getMediaDevices(devicesCallback);");
testPassed('After getMediaDevices');

window.jsTestIsAsync = true;
window.successfullyParsed = true;
</script>
</body>
</html>
40 changes: 40 additions & 0 deletions Source/modules/mediastream/MediaDeviceInfo.idl
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright (C) 2014 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY GOOGLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

enum MediaDeviceKind {
"audioinput",
"audiooutput",
"videoinput"
};

[
WillBeGarbageCollected,
NoInterfaceObject
] interface MediaDeviceInfo {
readonly attribute DOMString deviceId;
readonly attribute MediaDeviceKind kind;
readonly attribute DOMString label;
readonly attribute DOMString groupId;
};
29 changes: 29 additions & 0 deletions Source/modules/mediastream/MediaDeviceInfoCallback.idl
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright (C) 2014 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY GOOGLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

callback interface MediaDeviceInfoCallback {
void handleEvent(sequence<MediaDeviceInfo> devices);
};

2 changes: 2 additions & 0 deletions Source/modules/mediastream/NavigatorMediaStream.idl
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@
[RaisesException] void webkitGetUserMedia(Dictionary options,
NavigatorUserMediaSuccessCallback successCallback,
NavigatorUserMediaErrorCallback errorCallback);

[RaisesException] void getMediaDevices(MediaDeviceInfoCallback resultCallback);
};
2 changes: 2 additions & 0 deletions Source/modules/modules.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@
'mediasource/SourceBuffer.idl',
'mediasource/SourceBufferList.idl',
'mediasource/VideoPlaybackQuality.idl',
'mediastream/MediaDeviceInfo.idl',
'mediastream/MediaDeviceInfoCallback.idl',
'mediastream/MediaStream.idl',
'mediastream/MediaStreamEvent.idl',
'mediastream/MediaStreamTrack.idl',
Expand Down

0 comments on commit 70b600d

Please sign in to comment.