OLD | NEW |
1 <html> | 1 <html> |
2 <head> | 2 <head> |
3 <script type="text/javascript" src="webrtc_test_utilities.js"></script> | 3 <script type="text/javascript" src="webrtc_test_utilities.js"></script> |
4 <script type="text/javascript"> | 4 <script type="text/javascript"> |
5 $ = function(id) { | 5 $ = function(id) { |
6 return document.getElementById(id); | 6 return document.getElementById(id); |
7 }; | 7 }; |
8 | 8 |
9 setAllEventsOccuredHandler(function() { | 9 setAllEventsOccuredHandler(function() { |
10 reportTestSuccess(); | 10 reportTestSuccess(); |
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
605 assertNotEquals(settings.deviceId, 'default'); | 605 assertNotEquals(settings.deviceId, 'default'); |
606 assertTrue(settings.echoCancellation); | 606 assertTrue(settings.echoCancellation); |
607 stream.getAudioTracks()[0].stop(); | 607 stream.getAudioTracks()[0].stop(); |
608 reportTestSuccess(); | 608 reportTestSuccess(); |
609 }) | 609 }) |
610 }) | 610 }) |
611 .catch(e => { | 611 .catch(e => { |
612 failTest("Unexpected error: " + e) | 612 failTest("Unexpected error: " + e) |
613 }); | 613 }); |
614 } | 614 } |
| 615 |
| 616 function srcObjectAddVideoTrack() { |
| 617 var video = document.createElement('video'); |
| 618 video.autoplay = true; |
| 619 assertEquals(video.srcObject, null); |
| 620 navigator.mediaDevices.getUserMedia({audio: true, video: true}) |
| 621 .then(stream => { |
| 622 video.onplaying = function() { |
| 623 video.onplaying = null; |
| 624 video.onloadstart = function() { |
| 625 failTest("loadstart should not be called"); |
| 626 } |
| 627 |
| 628 video.onresize = function() { |
| 629 assertNotEquals(video.srcObject, null); |
| 630 assertTrue(video.videoHeight > 0); |
| 631 assertTrue(video.videoWidth > 0); |
| 632 reportTestSuccess(); |
| 633 } |
| 634 |
| 635 assertNotEquals(video.srcObject, null); |
| 636 assertEquals(video.videoWidth, 0); |
| 637 assertEquals(video.videoHeight, 0); |
| 638 video.srcObject.addTrack(stream.getVideoTracks()[0]); |
| 639 } |
| 640 video.srcObject = new MediaStream(stream.getAudioTracks()); |
| 641 }) |
| 642 .catch(e => { |
| 643 failTest("Unexpected error: " + e) |
| 644 }); |
| 645 } |
| 646 |
| 647 function srcObjectRemoveVideoTrack() { |
| 648 var video = document.createElement('video'); |
| 649 video.autoplay = true; |
| 650 assertEquals(video.srcObject, null); |
| 651 navigator.mediaDevices.getUserMedia({audio: true, video: true}) |
| 652 .then(stream => { |
| 653 video.onplaying = function() { |
| 654 video.onplaying = null; |
| 655 video.onloadstart = function() { |
| 656 failTest("loadstart should not be called"); |
| 657 } |
| 658 |
| 659 video.onresize = function() { |
| 660 assertNotEquals(video.srcObject, null); |
| 661 assertEquals(0, video.videoHeight); |
| 662 assertEquals(0, video.videoWidth); |
| 663 reportTestSuccess(); |
| 664 } |
| 665 |
| 666 assertNotEquals(video.srcObject, null); |
| 667 assertTrue(video.videoWidth > 0); |
| 668 assertTrue(video.videoHeight > 0); |
| 669 stream.removeTrack(stream.getVideoTracks()[0]); |
| 670 } |
| 671 video.srcObject = stream; |
| 672 }) |
| 673 .catch(e => { |
| 674 failTest("Unexpected error: " + e) |
| 675 }); |
| 676 } |
| 677 |
| 678 function srcObjectRemoveFirstOfTwoVideoTracks() { |
| 679 var canvas = document.createElement('canvas'); |
| 680 var canvas_stream = canvas.captureStream(); |
| 681 var canvas_width = canvas_stream.getVideoTracks()[0].getSettings().width; |
| 682 var canvas_height = canvas_stream.getVideoTracks()[0].getSettings().height; |
| 683 assertTrue(canvas_width > 1); |
| 684 assertTrue(canvas_height > 1); |
| 685 |
| 686 // Paint something on the canvas, so that it produces frames. |
| 687 var ctx = canvas.getContext("2d"); |
| 688 ctx.moveTo(0,0); |
| 689 ctx.lineTo(200,100); |
| 690 ctx.stroke(); |
| 691 |
| 692 var video = document.createElement('video'); |
| 693 video.autoplay = true; |
| 694 assertEquals(video.srcObject, null); |
| 695 var gum_width = canvas_width + 1; |
| 696 var gum_height = canvas_height + 1; |
| 697 navigator.mediaDevices.getUserMedia({ |
| 698 video: { |
| 699 width: {exact: gum_width}, |
| 700 height: {exact: gum_height} |
| 701 } |
| 702 }).then(gum_stream => { |
| 703 var gum_settings = gum_stream.getVideoTracks()[0].getSettings(); |
| 704 assertEquals(gum_width, gum_settings.width) |
| 705 assertEquals(gum_height, gum_settings.height) |
| 706 var big_stream = new MediaStream(); |
| 707 big_stream.addTrack(canvas_stream.getVideoTracks()[0]); |
| 708 big_stream.addTrack(gum_stream.getVideoTracks()[0]); |
| 709 video.onprogress = function() { |
| 710 assertEquals(canvas_width, video.videoWidth); |
| 711 assertEquals(canvas_height, video.videoHeight); |
| 712 assertNotEquals(video.videoWidth, gum_width) |
| 713 assertNotEquals(video.videoHeight, gum_height) |
| 714 video.onprogress = function() { |
| 715 assertEquals(gum_width, video.videoWidth); |
| 716 assertEquals(gum_height, video.videoHeight); |
| 717 assertNotEquals(video.videoWidth, canvas_width) |
| 718 assertNotEquals(video.videoHeight, canvas_height) |
| 719 reportTestSuccess(); |
| 720 } |
| 721 big_stream.removeTrack(big_stream.getVideoTracks()[0]); |
| 722 } |
| 723 video.srcObject = big_stream; |
| 724 }) |
| 725 .catch(e => { |
| 726 failTest("Unexpected error: " + e) |
| 727 }); |
| 728 } |
| 729 |
| 730 function srcObjectReassignSameObject() { |
| 731 var video = document.createElement('video'); |
| 732 video.autoplay = true; |
| 733 assertEquals(video.srcObject, null); |
| 734 navigator.mediaDevices.getUserMedia({audio: true, video: true}) |
| 735 .then(stream => { |
| 736 video.onplaying = function() { |
| 737 video.onplaying = null; |
| 738 video.onloadstart = function() { |
| 739 reportTestSuccess(); |
| 740 } |
| 741 assertNotEquals(video.srcObject, null); |
| 742 assertTrue(video.videoWidth > 0); |
| 743 assertTrue(video.videoHeight > 0); |
| 744 // Reassigning the same object should trigger the load algorithm. |
| 745 video.srcObject = video.srcObject; |
| 746 } |
| 747 video.srcObject = stream; |
| 748 }) |
| 749 .catch(e => { |
| 750 failTest("Unexpected error: " + e) |
| 751 }); |
| 752 } |
615 </script> | 753 </script> |
616 </head> | 754 </head> |
617 <body> | 755 <body> |
618 <table border="0"> | 756 <table border="0"> |
619 <!-- Canvases are named after their corresponding video elements. --> | 757 <!-- Canvases are named after their corresponding video elements. --> |
620 <tr> | 758 <tr> |
621 <td><video id="local-view-1" width="320" height="240" autoplay | 759 <td><video id="local-view-1" width="320" height="240" autoplay |
622 style="display:none"></video></td> | 760 style="display:none"></video></td> |
623 <td><canvas id="local-view-1-canvas" width="320" height="240" | 761 <td><canvas id="local-view-1-canvas" width="320" height="240" |
624 style="display:none"></canvas></td> | 762 style="display:none"></canvas></td> |
625 </tr> | 763 </tr> |
626 <tr> | 764 <tr> |
627 <td><video id="local-view-2" width="320" height="240" autoplay | 765 <td><video id="local-view-2" width="320" height="240" autoplay |
628 style="display:none"></video></td> | 766 style="display:none"></video></td> |
629 <td><canvas id="local-view-2-canvas" width="320" height="240" | 767 <td><canvas id="local-view-2-canvas" width="320" height="240" |
630 style="display:none"></canvas></td> | 768 style="display:none"></canvas></td> |
631 </tr> | 769 </tr> |
632 </table> | 770 </table> |
633 </body> | 771 </body> |
634 </html> | 772 </html> |
OLD | NEW |