| OLD | NEW |
| 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 // Number of test events to occur before the test pass. When the test pass, | 9 // Number of test events to occur before the test pass. When the test pass, |
| 10 // the function gAllEventsOccured is called. | 10 // the function gAllEventsOccured is called. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 } | 37 } |
| 38 }, 100); | 38 }, 100); |
| 39 } | 39 } |
| 40 | 40 |
| 41 function waitForVideo(videoElement) { | 41 function waitForVideo(videoElement) { |
| 42 document.title = 'Waiting for video...'; | 42 document.title = 'Waiting for video...'; |
| 43 addExpectedEvent(); | 43 addExpectedEvent(); |
| 44 detectVideoIn(videoElement, function () { eventOccured(); }); | 44 detectVideoIn(videoElement, function () { eventOccured(); }); |
| 45 } | 45 } |
| 46 | 46 |
| 47 function waitForConnectionToStabilize(peerConnection) { |
| 48 addExpectedEvent(); |
| 49 var waitForStabilization = setInterval(function() { |
| 50 if (peerConnection.signalingState == 'stable') { |
| 51 clearInterval(waitForStabilization); |
| 52 eventOccured(); |
| 53 } |
| 54 }, 100); |
| 55 } |
| 56 |
| 47 function addExpectedEvent() { | 57 function addExpectedEvent() { |
| 48 ++gNumberOfExpectedEvents; | 58 ++gNumberOfExpectedEvents; |
| 49 } | 59 } |
| 50 | 60 |
| 51 function eventOccured() { | 61 function eventOccured() { |
| 52 ++gNumberOfEvents; | 62 ++gNumberOfEvents; |
| 53 if (gNumberOfEvents == gNumberOfExpectedEvents) { | 63 if (gNumberOfEvents == gNumberOfExpectedEvents) { |
| 54 gAllEventsOccured(); | 64 gAllEventsOccured(); |
| 55 } | 65 } |
| 56 } | 66 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 71 | 81 |
| 72 // This function matches |left| and |right| and throws an exception if the | 82 // This function matches |left| and |right| and throws an exception if the |
| 73 // values don't match. | 83 // values don't match. |
| 74 function expectEquals(left, right) { | 84 function expectEquals(left, right) { |
| 75 if (left != right) { | 85 if (left != right) { |
| 76 var s = "expectEquals failed left: " + left + " right: " + right; | 86 var s = "expectEquals failed left: " + left + " right: " + right; |
| 77 document.title = s; | 87 document.title = s; |
| 78 throw s; | 88 throw s; |
| 79 } | 89 } |
| 80 } | 90 } |
| OLD | NEW |