Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(161)

Side by Side Diff: content/test/data/media/webrtc_test_utilities.js

Issue 1729683002: Remove old-style constraints from Chrome internals (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Complete the interface change Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // These must match with how the video and canvas tags are declared in html. 5 // These must match with how the video and canvas tags are declared in html.
6 const VIDEO_TAG_WIDTH = 320; 6 const VIDEO_TAG_WIDTH = 320;
7 const VIDEO_TAG_HEIGHT = 240; 7 const VIDEO_TAG_HEIGHT = 240;
8 8
9 // Fake video capture background green is of value 135. 9 // Fake video capture background green is of value 135.
10 const COLOR_BACKGROUND_GREEN = 135; 10 const COLOR_BACKGROUND_GREEN = 135;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 if (canvas == null) { 73 if (canvas == null) {
74 console.log('Waiting for ' + videoElementName + '-canvas' + ' to appear'); 74 console.log('Waiting for ' + videoElementName + '-canvas' + ' to appear');
75 return; 75 return;
76 } 76 }
77 var context = canvas.getContext('2d'); 77 var context = canvas.getContext('2d');
78 context.drawImage(videoElement, 0, 0, width, height); 78 context.drawImage(videoElement, 0, 0, width, height);
79 var pixels = context.getImageData(0, 0 , width, height / 3).data; 79 var pixels = context.getImageData(0, 0 , width, height / 3).data;
80 // Check that there is an old and a new picture with the same size to 80 // Check that there is an old and a new picture with the same size to
81 // compare and use the function |predicate| to detect the video state in 81 // compare and use the function |predicate| to detect the video state in
82 // that case. 82 // that case.
83 // There's a failure(?) mode here where the video generated claims to
84 // have size 2x2. Don't consider that a valid video.
83 if (oldPixels.length == pixels.length && 85 if (oldPixels.length == pixels.length &&
84 predicate(pixels, oldPixels)) { 86 predicate(pixels, oldPixels)) {
85 console.log('Done looking at video in element ' + videoElementName); 87 console.log('Done looking at video in element ' + videoElementName);
88 console.log('DEBUG: video.width = ' + videoElement.videoWidth);
89 console.log('DEBUG: video.height = ' + videoElement.videoHeight);
86 clearInterval(waitVideo); 90 clearInterval(waitVideo);
87 callback(videoElement.videoWidth, videoElement.videoHeight); 91 callback(videoElement.videoWidth, videoElement.videoHeight);
88 } 92 }
89 oldPixels = pixels; 93 oldPixels = pixels;
90 var elapsedTime = new Date().getTime() - startTimeMs; 94 var elapsedTime = new Date().getTime() - startTimeMs;
91 if (elapsedTime > 3000) { 95 if (elapsedTime > 3000) {
92 startTimeMs = new Date().getTime(); 96 startTimeMs = new Date().getTime();
93 console.log('Still waiting for video to satisfy ' + predicate.toString()); 97 console.log('Still waiting for video to satisfy ' + predicate.toString());
98 console.log('DEBUG: video.width = ' + videoElement.videoWidth);
99 console.log('DEBUG: video.height = ' + videoElement.videoHeight);
100 // clearInterval(waitVideo);
101 // callback(0, 0);
94 } 102 }
95 }, 200); 103 }, 200);
96 } 104 }
97 105
98 function waitForVideoWithResolution(element, expected_width, expected_height) { 106 function waitForVideoWithResolution(element, expected_width, expected_height) {
99 addExpectedEvent(); 107 addExpectedEvent();
100 detectVideoPlaying(element, 108 detectVideoPlaying(element,
101 function (width, height) { 109 function (width, height) {
102 assertEquals(expected_width, width); 110 assertEquals(expected_width, width);
103 assertEquals(expected_height, height); 111 assertEquals(expected_height, height);
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 if (device.kind == 'video') 261 if (device.kind == 'video')
254 hasVideoInputDevice = true; 262 hasVideoInputDevice = true;
255 }); 263 });
256 264
257 if (hasVideoInputDevice) 265 if (hasVideoInputDevice)
258 sendValueToTest('has-video-input-device'); 266 sendValueToTest('has-video-input-device');
259 else 267 else
260 sendValueToTest('no-video-input-devices'); 268 sendValueToTest('no-video-input-devices');
261 }); 269 });
262 } 270 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698