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

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

Issue 2219813002: Revert of ImageCapture: Queue up requests while device not ready (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 unified diff | Download patch
OLDNEW
1 B<!DOCTYPE html> 1 <!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 var hasVideoInputDevice = false;
13 navigator.mediaDevices.enumerateDevices()
14 .then(devices => {
15 devices.forEach(function(device) {
16 if (device.kind === "videoinput")
17 hasVideoInputDevice = true;
18 });
19
20 if (!hasVideoInputDevice)
21 return Promise.reject("no video devices");
22 })
31 .catch(err => { 23 .catch(err => {
32 console.log('no video devices found, skipping test'); 24 return failTest('Error enumerating devices: ' + err.toString());
33 reportTestSuccess(); 25 });
34 }) 26
35 .then(() => { 27 navigator.mediaDevices.getUserMedia({"video" : true})
36 const constraints = { mandatory: { maxHeight: 180, maxWidth: 320 } };
37 return navigator.mediaDevices.getUserMedia({"video" : constraints});
38 })
39 .then(stream => { 28 .then(stream => {
40 assertEquals('video', stream.getVideoTracks()[0].kind); 29 assertEquals('video', stream.getVideoTracks()[0].kind);
41 return new ImageCapture(stream.getVideoTracks()[0]); 30 return new ImageCapture(stream.getVideoTracks()[0]);
42 }) 31 })
43 .then(capturer => { 32 .then(capturer => {
44 return capturer.getPhotoCapabilities(); 33 return capturer.getPhotoCapabilities();
45 }) 34 })
46 .then(capabilities => { 35 .then(capabilities => {
47 assertNotEquals(0, capabilities.imageHeight.min); 36 assertNotEquals(0, capabilities.imageHeight.min);
48 assertNotEquals(0, capabilities.imageHeight.current); 37 assertNotEquals(0, capabilities.imageHeight.current);
49 assertNotEquals(0, capabilities.imageHeight.max); 38 assertNotEquals(0, capabilities.imageHeight.max);
50 assertNotEquals(0, capabilities.imageWidth.min); 39 assertNotEquals(0, capabilities.imageWidth.min);
51 assertNotEquals(0, capabilities.imageWidth.current); 40 assertNotEquals(0, capabilities.imageWidth.current);
52 assertNotEquals(0, capabilities.imageWidth.max); 41 assertNotEquals(0, capabilities.imageWidth.max);
53 assertNotEquals(0, capabilities.zoom.min); 42 assertNotEquals(0, capabilities.zoom.min);
54 assertNotEquals(0, capabilities.zoom.current); 43 assertNotEquals(0, capabilities.zoom.current);
55 assertNotEquals(0, capabilities.zoom.max); 44 assertNotEquals(0, capabilities.zoom.max);
56 45
57 reportTestSuccess(); 46 reportTestSuccess();
58 }) 47 })
59 .catch(err => { 48 .catch(err => {
60 return failTest(err.toString()); 49 return failTest(err.toString());
61 }); 50 });
62 } 51 }
63 52
64 // Runs an ImageCapture.takePhoto().
65 function testCreateAndTakePhoto() {
66 checkForVideoDevices()
67 .catch(err => {
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 => {
76 assertEquals('video', stream.getVideoTracks()[0].kind);
77 return new ImageCapture(stream.getVideoTracks()[0]);
78 })
79 .then(capturer => {
80 return capturer.takePhoto();
81 })
82 .then(blob => {
83 assertTrue(blob.type != undefined);
84 assertNotEquals(0, blob.size);
85
86 reportTestSuccess();
87 })
88 .catch(err => {
89 return failTest(err.toString());
90 });
91 }
92
93 </script> 53 </script>
94 </body> 54 </body>
95 </html> 55 </html>
OLDNEW
« no previous file with comments | « content/browser/webrtc/webrtc_image_capture_browsertest.cc ('k') | media/capture/video/android/video_capture_device_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698