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

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

Issue 2456193004: Image Capture: enable content_browsertests in Linux/CrOs (Closed)
Patch Set: Created 4 years, 1 month 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 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 const HEIGHT = 180;
10 const WIDTH = 320; 9 const WIDTH = 320;
10 const constraints = { width: { max : WIDTH } };
xianglu 2016/10/28 16:33:55 /** @const */ var constraints = { width: { max : W
mcasas 2016/10/28 17:00:49 Done.
11 11
12 // Runs an ImageCapture.getPhotoCapabilities(). 12 // Runs an ImageCapture.getPhotoCapabilities().
13 function testCreateAndGetCapabilities() { 13 function testCreateAndGetCapabilities() {
14 const constraints = { mandatory: { maxHeight: HEIGHT, maxWidth: WIDTH } };
15 navigator.mediaDevices.getUserMedia({"video" : constraints}) 14 navigator.mediaDevices.getUserMedia({"video" : constraints})
16 .then(stream => { 15 .then(stream => {
17 assertEquals('video', stream.getVideoTracks()[0].kind); 16 assertEquals('video', stream.getVideoTracks()[0].kind);
18 return new ImageCapture(stream.getVideoTracks()[0]); 17 return new ImageCapture(stream.getVideoTracks()[0]);
19 }) 18 })
20 .then(capturer => { 19 .then(capturer => {
21 return capturer.getPhotoCapabilities(); 20 return capturer.getPhotoCapabilities();
22 }) 21 })
23 .then(capabilities => { 22 .then(capabilities => {
24 assertNotEquals(0, capabilities.imageHeight.min); 23 // There's nothing to check here since |capabilities| vary per device.
25 assertNotEquals(0, capabilities.imageHeight.current);
26 assertNotEquals(0, capabilities.imageHeight.max);
27 assertNotEquals(0, capabilities.imageWidth.min);
28 assertNotEquals(0, capabilities.imageWidth.current);
29 assertNotEquals(0, capabilities.imageWidth.max);
30 assertNotEquals(0, capabilities.zoom.min);
31 assertNotEquals(0, capabilities.zoom.current);
32 assertNotEquals(0, capabilities.zoom.max);
33
34 reportTestSuccess(); 24 reportTestSuccess();
35 }) 25 })
36 .catch(err => { 26 .catch(err => {
37 return failTest(err.toString()); 27 return failTest(err.toString());
38 }); 28 });
39 } 29 }
40 30
41 // Runs an ImageCapture.takePhoto(). 31 // Runs an ImageCapture.takePhoto().
42 function testCreateAndTakePhoto() { 32 function testCreateAndTakePhoto() {
43 const constraints = { mandatory: { maxHeight: HEIGHT, maxWidth: WIDTH } };
44 navigator.mediaDevices.getUserMedia({"video" : constraints}) 33 navigator.mediaDevices.getUserMedia({"video" : constraints})
45 .then(stream => { 34 .then(stream => {
46 assertEquals('video', stream.getVideoTracks()[0].kind); 35 assertEquals('video', stream.getVideoTracks()[0].kind);
47 return new ImageCapture(stream.getVideoTracks()[0]); 36 return new ImageCapture(stream.getVideoTracks()[0]);
48 }) 37 })
49 .then(capturer => { 38 .then(capturer => {
50 return capturer.takePhoto(); 39 return capturer.takePhoto();
51 }) 40 })
52 .then(blob => { 41 .then(blob => {
53 assertTrue(blob.type != undefined); 42 assertTrue(blob.type != undefined);
54 assertNotEquals(0, blob.size); 43 assertNotEquals(0, blob.size);
55 44
56 reportTestSuccess(); 45 reportTestSuccess();
57 }) 46 })
58 .catch(err => { 47 .catch(err => {
59 return failTest(err.toString()); 48 return failTest(err.toString());
60 }); 49 });
61 } 50 }
62 51
63 // Runs an ImageCapture.grabFrame(). 52 // Runs an ImageCapture.grabFrame().
64 function testCreateAndGrabFrame() { 53 function testCreateAndGrabFrame() {
65 const constraints = { mandatory: { maxHeight: HEIGHT, maxWidth: WIDTH } };
66 navigator.mediaDevices.getUserMedia({"video" : constraints}) 54 navigator.mediaDevices.getUserMedia({"video" : constraints})
67 .then(stream => { 55 .then(stream => {
68 assertEquals('video', stream.getVideoTracks()[0].kind); 56 assertEquals('video', stream.getVideoTracks()[0].kind);
69 return new ImageCapture(stream.getVideoTracks()[0]); 57 return new ImageCapture(stream.getVideoTracks()[0]);
70 }) 58 })
71 .then(capturer => { 59 .then(capturer => {
72 return capturer.grabFrame(); 60 return capturer.grabFrame();
73 }) 61 })
74 .then(imageBitmap => { 62 .then(imageBitmap => {
75 assertEquals(WIDTH, imageBitmap.width); 63 assertEquals(WIDTH, imageBitmap.width);
76 assertEquals(HEIGHT, imageBitmap.height);
77 64
78 reportTestSuccess(); 65 reportTestSuccess();
79 }) 66 })
80 .catch(err => { 67 .catch(err => {
81 return failTest(err.toString()); 68 return failTest(err.toString());
82 }); 69 });
83 } 70 }
84 71
85 </script> 72 </script>
86 </body> 73 </body>
87 </html> 74 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698