summaryrefslogtreecommitdiffstats
path: root/content/test
diff options
context:
space:
mode:
authorronghuawu@chromium.org <ronghuawu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-18 09:31:58 +0000
committerronghuawu@chromium.org <ronghuawu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-18 09:31:58 +0000
commit79ba3362a4f39f99385e3261cd1232567ae07c78 (patch)
tree95d624c34f620672a26e737e31d591b502e679dc /content/test
parentdc9058a5c4049b9e576a063308bf66f279f24f9c (diff)
downloadchromium_src-79ba3362a4f39f99385e3261cd1232567ae07c78.zip
chromium_src-79ba3362a4f39f99385e3261cd1232567ae07c78.tar.gz
chromium_src-79ba3362a4f39f99385e3261cd1232567ae07c78.tar.bz2
Add content_browser test for DTMF sender.
Review URL: https://chromiumcodereview.appspot.com/12258033 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@183084 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/test')
-rw-r--r--content/test/data/media/peerconnection-call.html53
1 files changed, 47 insertions, 6 deletions
diff --git a/content/test/data/media/peerconnection-call.html b/content/test/data/media/peerconnection-call.html
index 2a6eded..1616373 100644
--- a/content/test/data/media/peerconnection-call.html
+++ b/content/test/data/media/peerconnection-call.html
@@ -16,6 +16,10 @@
// Number of events that currently have occured.
var gNumberOfEvents = 0;
+ var gLocalStream = null;
+
+ var gSentTones = '';
+
// Test that we can setup call with an audio and video track.
function call(constraints) {
createConnections(null);
@@ -64,6 +68,30 @@
waitForVideo($('remote-view'), 320, 240);
}
+ // Test that we can setup call and send DTMF.
+ function callAndSendDtmf(tones) {
+ createConnections(null);
+ navigator.webkitGetUserMedia({audio:true, video:true}, okCallback,
+ failedCallback);
+ var onCallEstablished = function() {
+ // Send DTMF tones.
+ var localAudioTrack = gLocalStream.getAudioTracks()[0];
+ var dtmfSender = gFirstConnection.createDTMFSender(localAudioTrack);
+ dtmfSender.ontonechange = onToneChange;
+ dtmfSender.insertDTMF(tones);
+ // Wait for the DTMF tones callback.
+ document.title = 'Waiting for dtmf...';
+ addExpectedEvent();
+ var waitDtmf = setInterval(function() {
+ if (gSentTones == tones) {
+ clearInterval(waitDtmf);
+ eventOccured();
+ }
+ }, 100);
+ }
+ detectVideoIn($('remote-view'), 320, 240, onCallEstablished);
+ }
+
// This function is used for setting up a test that:
// 1. Creates a data channel on |gFirstConnection| and sends data to
// |gSecondConnection|.
@@ -111,6 +139,11 @@
}
}
+ function onToneChange(tone) {
+ gSentTones += tone.tone;
+ document.title = gSentTones;
+ }
+
function failedCallback(error) {
document.title = 'getUserMedia request failed with code ' + error.code;
}
@@ -120,6 +153,7 @@
$('local-view').src = localStreamUrl;
callUsingStream(localStream);
+ gLocalStream = localStream;
}
function createConnections(constraints) {
@@ -204,20 +238,27 @@
}
// TODO(phoglund): perhaps use the video detector in chrome/test/data/webrtc/?
- function waitForVideo(videoElement, width, height) {
- document.title = 'Waiting for video...';
- addExpectedEvent();
+ function detectVideoIn(videoElement, width, height, callback) {
var canvas = $('canvas');
- setInterval(function() {
+ var waitVideo = setInterval(function() {
var context = canvas.getContext('2d');
context.drawImage(videoElement, 0, 0, width, height);
var pixels = context.getImageData(0, 0, width, height).data;
- if (isVideoPlaying(pixels, width, height))
- eventOccured();
+ if (isVideoPlaying(pixels, width, height)) {
+ clearInterval(waitVideo);
+ callback();
+ }
}, 100);
}
+ function waitForVideo(videoElement, width, height) {
+ document.title = 'Waiting for video...';
+ addExpectedEvent();
+ detectVideoIn(videoElement, width, height,
+ function () { eventOccured(); });
+ }
+
// This very basic video verification algorithm will be satisfied if any
// pixels are nonzero in a small sample area in the middle. It relies on the
// assumption that a video element with null source just presents zeroes.