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

Unified Diff: content/test/data/media/webrtc_test_utilities.js

Issue 478543004: Reland WebRtcBrowserTest.CanSetupVideoCallAndDisableLocalVideo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Disabled under TSAN 2 due to http://crbug.com/408006. Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: content/test/data/media/webrtc_test_utilities.js
diff --git a/content/test/data/media/webrtc_test_utilities.js b/content/test/data/media/webrtc_test_utilities.js
index 3d5435938d03ee8cd5d69cc55973b2fdb87b8e46..6e9cde639dcdf5299182c84cb4a785eca4391d13 100644
--- a/content/test/data/media/webrtc_test_utilities.js
+++ b/content/test/data/media/webrtc_test_utilities.js
@@ -52,6 +52,14 @@ function detectVideoStopped(videoElementName, callback) {
callback);
}
+function detectBlackVideo(videoElementName, callback) {
+ detectVideo(videoElementName,
+ function (pixels, previous_pixels) {
+ return isVideoBlack(pixels);
+ },
+ callback);
+}
+
function detectVideo(videoElementName, predicate, callback) {
console.log('Looking at video in element ' + videoElementName);
@@ -97,6 +105,11 @@ function waitForVideoToStop(videoElement) {
detectVideoStopped(videoElement, function () { eventOccured(); });
}
+function waitForBlackVideo(videoElement) {
+ addExpectedEvent();
+ detectBlackVideo(videoElement, function () { eventOccured(); });
+}
+
// Calculates the current frame rate and compares to |expected_frame_rate|
// |callback| is triggered with value |true| if the calculated frame rate
// is +-1 the expected or |false| if five calculations fail to match
@@ -171,6 +184,16 @@ function isVideoPlaying(pixels, previousPixels) {
return false;
}
+function isVideoBlack(pixels) {
+ for (var i = 0; i < pixels.length; i++) {
+ // |pixels| is in RGBA. Ignore the alpha channel.
+ if (pixels[i] != 0 && (i + 1) % 4 != 0) {
+ return false;
+ }
+ }
+ return true;
+}
+
// This function matches |left| and |right| and fails the test if the
// values don't match using normal javascript equality (i.e. the hard
// types of the operands aren't checked).

Powered by Google App Engine
This is Rietveld 408576698