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

Side by Side Diff: content/test/data/media/image_capture_test.html

Issue 2341643006: ImageCapture browser tests: use IsWebcamAvailableOnSystem() (Closed)
Patch Set: Rebase to https://crrev.com/2334223012 Created 4 years, 3 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
« no previous file with comments | « content/browser/webrtc/webrtc_webcam_browsertest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 B<!DOCTYPE html> 1 B<!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <!-- Image Capture Browser Test --> 4 <!-- Image Capture Browser Test -->
5 </head> 5 </head>
6 <body> 6 <body>
7 <script type="text/javascript" src="webrtc_test_utilities.js"></script> 7 <script type="text/javascript" src="webrtc_test_utilities.js"></script>
8 <script> 8 <script>
9 9
10 // Returns a Promise that is resolved if there is at least one video device or
11 // rejected otherwise.
12 function checkForVideoDevices() {
13 return new Promise((resolve, reject) => {
14 navigator.mediaDevices.enumerateDevices()
15 .then(devices => {
16 devices.forEach(function(device) {
17 if (device.kind === "videoinput")
18 return resolve();
19 });
20 return reject(new Error('no video devices'));
21 })
22 .catch(err => {
23 return reject(new Error('enumerating devices: ' + err.toString()));
24 });
25 });
26 }
27
28 // Runs an ImageCapture.getPhotoCapabilities(). 10 // Runs an ImageCapture.getPhotoCapabilities().
29 function testCreateAndGetCapabilities() { 11 function testCreateAndGetCapabilities() {
30 checkForVideoDevices() 12 const constraints = { mandatory: { maxHeight: 180, maxWidth: 320 } };
31 .catch(err => { 13 navigator.mediaDevices.getUserMedia({"video" : constraints})
32 console.log('no video devices found, skipping test');
33 reportTestSuccess();
34 })
35 .then(() => {
36 const constraints = { mandatory: { maxHeight: 180, maxWidth: 320 } };
37 return navigator.mediaDevices.getUserMedia({"video" : constraints});
38 })
39 .then(stream => { 14 .then(stream => {
40 assertEquals('video', stream.getVideoTracks()[0].kind); 15 assertEquals('video', stream.getVideoTracks()[0].kind);
41 return new ImageCapture(stream.getVideoTracks()[0]); 16 return new ImageCapture(stream.getVideoTracks()[0]);
42 }) 17 })
43 .then(capturer => { 18 .then(capturer => {
44 return capturer.getPhotoCapabilities(); 19 return capturer.getPhotoCapabilities();
45 }) 20 })
46 .then(capabilities => { 21 .then(capabilities => {
47 assertNotEquals(0, capabilities.imageHeight.min); 22 assertNotEquals(0, capabilities.imageHeight.min);
48 assertNotEquals(0, capabilities.imageHeight.current); 23 assertNotEquals(0, capabilities.imageHeight.current);
49 assertNotEquals(0, capabilities.imageHeight.max); 24 assertNotEquals(0, capabilities.imageHeight.max);
50 assertNotEquals(0, capabilities.imageWidth.min); 25 assertNotEquals(0, capabilities.imageWidth.min);
51 assertNotEquals(0, capabilities.imageWidth.current); 26 assertNotEquals(0, capabilities.imageWidth.current);
52 assertNotEquals(0, capabilities.imageWidth.max); 27 assertNotEquals(0, capabilities.imageWidth.max);
53 assertNotEquals(0, capabilities.zoom.min); 28 assertNotEquals(0, capabilities.zoom.min);
54 assertNotEquals(0, capabilities.zoom.current); 29 assertNotEquals(0, capabilities.zoom.current);
55 assertNotEquals(0, capabilities.zoom.max); 30 assertNotEquals(0, capabilities.zoom.max);
56 31
57 reportTestSuccess(); 32 reportTestSuccess();
58 }) 33 })
59 .catch(err => { 34 .catch(err => {
60 return failTest(err.toString()); 35 return failTest(err.toString());
61 }); 36 });
62 } 37 }
63 38
64 // Runs an ImageCapture.takePhoto(). 39 // Runs an ImageCapture.takePhoto().
65 function testCreateAndTakePhoto() { 40 function testCreateAndTakePhoto() {
66 checkForVideoDevices() 41 const constraints = { mandatory: { maxHeight: 180, maxWidth: 320 } };
67 .catch(err => { 42 navigator.mediaDevices.getUserMedia({"video" : constraints})
68 console.log('no video devices found, skipping test');
69 reportTestSuccess();
70 })
71 .then(() => {
72 const constraints = { mandatory: { maxHeight: 180, maxWidth: 320 } };
73 return navigator.mediaDevices.getUserMedia({"video" : constraints});
74 })
75 .then(stream => { 43 .then(stream => {
76 assertEquals('video', stream.getVideoTracks()[0].kind); 44 assertEquals('video', stream.getVideoTracks()[0].kind);
77 return new ImageCapture(stream.getVideoTracks()[0]); 45 return new ImageCapture(stream.getVideoTracks()[0]);
78 }) 46 })
79 .then(capturer => { 47 .then(capturer => {
80 return capturer.takePhoto(); 48 return capturer.takePhoto();
81 }) 49 })
82 .then(blob => { 50 .then(blob => {
83 assertTrue(blob.type != undefined); 51 assertTrue(blob.type != undefined);
84 assertNotEquals(0, blob.size); 52 assertNotEquals(0, blob.size);
85 53
86 reportTestSuccess(); 54 reportTestSuccess();
87 }) 55 })
88 .catch(err => { 56 .catch(err => {
89 return failTest(err.toString()); 57 return failTest(err.toString());
90 }); 58 });
91 } 59 }
92 60
93 </script> 61 </script>
94 </body> 62 </body>
95 </html> 63 </html>
OLDNEW
« no previous file with comments | « content/browser/webrtc/webrtc_webcam_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698