Support arbitrary video resolution in getUserMedia API
[WebKit-https.git] / LayoutTests / fast / mediastream / apply-constraints-advanced.html
1 <!DOCTYPE html>
2 <html>
3     <head>
4         <script src="../../resources/js-test-pre.js"></script>
5         <script src="resources/apply-constraints-utils.js"></script>
6         <script>
7
8             let tests = [
9                 {
10                     message: "setup width and height.",
11                     constraint: { width: 640, height: 480 }, 
12                     expected: { width: 640, height: 480 }, 
13                 },
14                 {
15                     message: "advanced width and height are not supported, minimums are less than current, nothing is changed.",
16                     constraint: {
17                                     width: { min: 320 },
18                                     height: { min: 240 },
19                                     advanced: [
20                                         { width: 1920, height: 1280 },
21                                     ]
22                                 },
23                     expected: { width: 640, height: 480 }, 
24                 },
25                 {
26                     message: "first width and height in advanced are too big, second is used.",
27                     constraint: {
28                                     width: { min: 640 },
29                                     height: { min: 480 },
30                                     advanced: [
31                                         { width: 6000, height: 6000 },
32                                         { width: 1280, height: 720 },
33                                     ]
34                                  },
35                     expected: { width: 1280, height: 720 }, 
36                 },
37                 {
38                     message: "reset width and height.",
39                     constraint: { width: 320, height: 240 }, 
40                     expected: { width: 320, height: 240 }, 
41                 },
42                 {
43                     message: "advanced width and height are too big, fall back to required minimums.",
44                     constraint: {
45                                     width: { min: 640 },
46                                     height: {  min: 480 },
47                                     advanced: [
48                                         { width: 7680, height: 4320 },
49                                     ]
50                                 },
51                     expected: { width: 640, height: 480 }, 
52                 },
53                 {
54                     message: "reset width and height.",
55                     constraint: { width: 320, height: 240 }, 
56                     expected: { width: 320, height: 240 }, 
57                 },
58                 {
59                     message: "no required constraints, advanced constraints are ignored.",
60                     constraint: {
61                                     advanced: [
62                                         { facingMode: "left" },
63                                         { facingMode: "right" },
64                                         { facingMode: "environment" },
65                                         { facingMode: "user" },
66                                     ]
67                                 },
68                     expected: { facingMode: "user" }, 
69                 },
70             ];
71
72             let tester = new ConstraintsTest({ video: true }, tests, "Tests applyConstraints on a video stream track.")
73                 .onStreamReady((s) => {
74                     stream = s;
75                     shouldBe('stream.getVideoTracks().length', '1');
76                     shouldBe('stream.getAudioTracks().length', '0');
77                     tester.setStreamTrack(stream.getVideoTracks()[0]);
78                 })
79                 .onVideoReady((v) => {
80                     video = v;
81                     shouldBe('video.videoTracks.length', '1');
82                     shouldBe('video.audioTracks.length', '0');
83                 })
84                 .start();
85
86         </script>
87         <script src="../../resources/js-test-post.js"></script>
88     </head>
89     <body>
90         <video controls id="video"</video>
91         <br>
92         <div id="div"></div>
93
94     </body>
95 </html>
96