| 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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 } | 138 } |
| 139 | 139 |
| 140 private: | 140 private: |
| 141 scoped_refptr<base::SingleThreadTaskRunner> main_thread_; | 141 scoped_refptr<base::SingleThreadTaskRunner> main_thread_; |
| 142 base::Callback<void(const VideoCaptureFormat&)> frame_cb_; | 142 base::Callback<void(const VideoCaptureFormat&)> frame_cb_; |
| 143 }; | 143 }; |
| 144 | 144 |
| 145 class MockImageCaptureClient : public base::RefCounted<MockImageCaptureClient> { | 145 class MockImageCaptureClient : public base::RefCounted<MockImageCaptureClient> { |
| 146 public: | 146 public: |
| 147 // GMock doesn't support move-only arguments, so we use this forward method. | 147 // GMock doesn't support move-only arguments, so we use this forward method. |
| 148 void DoOnPhotoTaken(const std::string& mime_type, | 148 void DoOnPhotoTaken(mojom::BlobPtr blob) { |
| 149 const std::vector<uint8_t>& data) { | 149 EXPECT_STREQ("image/jpeg", blob->mime_type.c_str()); |
| 150 EXPECT_STREQ("image/jpeg", mime_type.c_str()); | 150 ASSERT_GT(blob->data.size(), 4u); |
| 151 ASSERT_GT(data.size(), 4u); | |
| 152 // Check some bytes that univocally identify |data| as a JPEG File. | 151 // Check some bytes that univocally identify |data| as a JPEG File. |
| 153 // https://en.wikipedia.org/wiki/JPEG_File_Interchange_Format#File_format_st
ructure | 152 // https://en.wikipedia.org/wiki/JPEG_File_Interchange_Format#File_format_st
ructure |
| 154 EXPECT_EQ(0xFF, data[0]); // First SOI byte | 153 EXPECT_EQ(0xFF, blob->data[0]); // First SOI byte |
| 155 EXPECT_EQ(0xD8, data[1]); // Second SOI byte | 154 EXPECT_EQ(0xD8, blob->data[1]); // Second SOI byte |
| 156 EXPECT_EQ(0xFF, data[2]); // First JFIF-APP0 byte | 155 EXPECT_EQ(0xFF, blob->data[2]); // First JFIF-APP0 byte |
| 157 EXPECT_EQ(0xE0, data[3]); // Second JFIF-APP0 byte | 156 EXPECT_EQ(0xE0, blob->data[3]); // Second JFIF-APP0 byte |
| 158 OnCorrectPhotoTaken(); | 157 OnCorrectPhotoTaken(); |
| 159 } | 158 } |
| 160 MOCK_METHOD0(OnCorrectPhotoTaken, void(void)); | 159 MOCK_METHOD0(OnCorrectPhotoTaken, void(void)); |
| 161 MOCK_METHOD1(OnTakePhotoFailure, | 160 MOCK_METHOD1(OnTakePhotoFailure, |
| 162 void(const base::Callback<void(const std::string&, | 161 void(const base::Callback<void(mojom::BlobPtr)>&)); |
| 163 const std::vector<uint8_t>&)>&)); | |
| 164 | 162 |
| 165 private: | 163 private: |
| 166 friend class base::RefCounted<MockImageCaptureClient>; | 164 friend class base::RefCounted<MockImageCaptureClient>; |
| 167 virtual ~MockImageCaptureClient() {} | 165 virtual ~MockImageCaptureClient() {} |
| 168 }; | 166 }; |
| 169 | 167 |
| 170 class DeviceEnumerationListener | 168 class DeviceEnumerationListener |
| 171 : public base::RefCounted<DeviceEnumerationListener> { | 169 : public base::RefCounted<DeviceEnumerationListener> { |
| 172 public: | 170 public: |
| 173 MOCK_METHOD1(OnEnumeratedDevicesCallbackPtr, | 171 MOCK_METHOD1(OnEnumeratedDevicesCallbackPtr, |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 &MockImageCaptureClient::OnTakePhotoFailure, image_capture_client_))); | 545 &MockImageCaptureClient::OnTakePhotoFailure, image_capture_client_))); |
| 548 | 546 |
| 549 EXPECT_CALL(*image_capture_client_.get(), OnCorrectPhotoTaken()).Times(1); | 547 EXPECT_CALL(*image_capture_client_.get(), OnCorrectPhotoTaken()).Times(1); |
| 550 device->TakePhoto(std::move(scoped_callback)); | 548 device->TakePhoto(std::move(scoped_callback)); |
| 551 WaitForCapturedFrame(); | 549 WaitForCapturedFrame(); |
| 552 | 550 |
| 553 device->StopAndDeAllocate(); | 551 device->StopAndDeAllocate(); |
| 554 } | 552 } |
| 555 | 553 |
| 556 }; // namespace media | 554 }; // namespace media |
| OLD | NEW |