OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "media/capture/video/video_capture_device.h" | 5 #include "media/capture/video/video_capture_device.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 // We will always get YUYV from the Mac AVFoundation implementations. | 48 // We will always get YUYV from the Mac AVFoundation implementations. |
49 #define MAYBE_CaptureMjpeg DISABLED_CaptureMjpeg | 49 #define MAYBE_CaptureMjpeg DISABLED_CaptureMjpeg |
50 #define MAYBE_TakePhoto TakePhoto | 50 #define MAYBE_TakePhoto TakePhoto |
51 #elif defined(OS_WIN) | 51 #elif defined(OS_WIN) |
52 #define MAYBE_AllocateBadSize AllocateBadSize | 52 #define MAYBE_AllocateBadSize AllocateBadSize |
53 #define MAYBE_CaptureMjpeg CaptureMjpeg | 53 #define MAYBE_CaptureMjpeg CaptureMjpeg |
54 #define MAYBE_TakePhoto DISABLED_TakePhoto | 54 #define MAYBE_TakePhoto DISABLED_TakePhoto |
55 #elif defined(OS_ANDROID) | 55 #elif defined(OS_ANDROID) |
56 #define MAYBE_AllocateBadSize AllocateBadSize | 56 #define MAYBE_AllocateBadSize AllocateBadSize |
57 #define MAYBE_CaptureMjpeg CaptureMjpeg | 57 #define MAYBE_CaptureMjpeg CaptureMjpeg |
58 #define MAYBE_TakePhoto DISABLED_TakePhoto | 58 #define MAYBE_TakePhoto TakePhoto |
59 #elif defined(OS_LINUX) | 59 #elif defined(OS_LINUX) |
60 // AllocateBadSize will hang when a real camera is attached and if more than one | 60 // AllocateBadSize will hang when a real camera is attached and if more than one |
61 // test is trying to use the camera (even across processes). Do NOT renable | 61 // test is trying to use the camera (even across processes). Do NOT renable |
62 // this test without fixing the many bugs associated with it: | 62 // this test without fixing the many bugs associated with it: |
63 // http://crbug.com/94134 http://crbug.com/137260 http://crbug.com/417824 | 63 // http://crbug.com/94134 http://crbug.com/137260 http://crbug.com/417824 |
64 #define MAYBE_AllocateBadSize DISABLED_AllocateBadSize | 64 #define MAYBE_AllocateBadSize DISABLED_AllocateBadSize |
65 #define MAYBE_CaptureMjpeg CaptureMjpeg | 65 #define MAYBE_CaptureMjpeg CaptureMjpeg |
66 #define MAYBE_TakePhoto DISABLED_TakePhoto | 66 #define MAYBE_TakePhoto DISABLED_TakePhoto |
67 #else | 67 #else |
68 #define MAYBE_AllocateBadSize AllocateBadSize | 68 #define MAYBE_AllocateBadSize AllocateBadSize |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 public: | 141 public: |
142 // GMock doesn't support move-only arguments, so we use this forward method. | 142 // GMock doesn't support move-only arguments, so we use this forward method. |
143 void DoOnPhotoTaken(mojom::BlobPtr blob) { | 143 void DoOnPhotoTaken(mojom::BlobPtr blob) { |
144 EXPECT_STREQ("image/jpeg", blob->mime_type.c_str()); | 144 EXPECT_STREQ("image/jpeg", blob->mime_type.c_str()); |
145 ASSERT_GT(blob->data.size(), 4u); | 145 ASSERT_GT(blob->data.size(), 4u); |
146 // Check some bytes that univocally identify |data| as a JPEG File. | 146 // Check some bytes that univocally identify |data| as a JPEG File. |
147 // https://en.wikipedia.org/wiki/JPEG_File_Interchange_Format#File_format_st
ructure | 147 // https://en.wikipedia.org/wiki/JPEG_File_Interchange_Format#File_format_st
ructure |
148 EXPECT_EQ(0xFF, blob->data[0]); // First SOI byte | 148 EXPECT_EQ(0xFF, blob->data[0]); // First SOI byte |
149 EXPECT_EQ(0xD8, blob->data[1]); // Second SOI byte | 149 EXPECT_EQ(0xD8, blob->data[1]); // Second SOI byte |
150 EXPECT_EQ(0xFF, blob->data[2]); // First JFIF-APP0 byte | 150 EXPECT_EQ(0xFF, blob->data[2]); // First JFIF-APP0 byte |
151 EXPECT_EQ(0xE0, blob->data[3]); // Second JFIF-APP0 byte | 151 EXPECT_EQ(0xE0, blob->data[3] & 0xF0); // Second JFIF-APP0/APP1 byte |
152 OnCorrectPhotoTaken(); | 152 OnCorrectPhotoTaken(); |
153 } | 153 } |
154 MOCK_METHOD0(OnCorrectPhotoTaken, void(void)); | 154 MOCK_METHOD0(OnCorrectPhotoTaken, void(void)); |
155 MOCK_METHOD1(OnTakePhotoFailure, | 155 MOCK_METHOD1(OnTakePhotoFailure, |
156 void(const base::Callback<void(mojom::BlobPtr)>&)); | 156 void(const base::Callback<void(mojom::BlobPtr)>&)); |
157 | 157 |
158 private: | 158 private: |
159 friend class base::RefCounted<MockImageCaptureClient>; | 159 friend class base::RefCounted<MockImageCaptureClient>; |
160 virtual ~MockImageCaptureClient() {} | 160 virtual ~MockImageCaptureClient() {} |
161 }; | 161 }; |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
530 &MockImageCaptureClient::OnTakePhotoFailure, image_capture_client_))); | 530 &MockImageCaptureClient::OnTakePhotoFailure, image_capture_client_))); |
531 | 531 |
532 EXPECT_CALL(*image_capture_client_.get(), OnCorrectPhotoTaken()).Times(1); | 532 EXPECT_CALL(*image_capture_client_.get(), OnCorrectPhotoTaken()).Times(1); |
533 device->TakePhoto(std::move(scoped_callback)); | 533 device->TakePhoto(std::move(scoped_callback)); |
534 WaitForCapturedFrame(); | 534 WaitForCapturedFrame(); |
535 | 535 |
536 device->StopAndDeAllocate(); | 536 device->StopAndDeAllocate(); |
537 } | 537 } |
538 | 538 |
539 }; // namespace media | 539 }; // namespace media |
OLD | NEW |