Chromium Code Reviews| 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 24 matching lines...) Expand all Loading... | |
| 35 #include "media/capture/video/mac/video_capture_device_factory_mac.h" | 35 #include "media/capture/video/mac/video_capture_device_factory_mac.h" |
| 36 #endif | 36 #endif |
| 37 | 37 |
| 38 #if defined(OS_ANDROID) | 38 #if defined(OS_ANDROID) |
| 39 #include "base/android/build_info.h" | 39 #include "base/android/build_info.h" |
| 40 #include "base/android/jni_android.h" | 40 #include "base/android/jni_android.h" |
| 41 #include "media/capture/video/android/video_capture_device_android.h" | 41 #include "media/capture/video/android/video_capture_device_android.h" |
| 42 #include "media/capture/video/android/video_capture_device_factory_android.h" | 42 #include "media/capture/video/android/video_capture_device_factory_android.h" |
| 43 #endif | 43 #endif |
| 44 | 44 |
| 45 #if defined(OS_CHROMEOS) | |
| 46 #include "media/capture/video/chromeos/video_capture_device_arc_chromeos.h" | |
| 47 #include "media/capture/video/chromeos/video_capture_device_factory_chromeos.h" | |
| 48 #include "mojo/edk/embedder/embedder.h" | |
| 49 #endif | |
| 50 | |
| 45 #if defined(OS_MACOSX) | 51 #if defined(OS_MACOSX) |
| 46 // Mac will always give you the size you ask for and this case will fail. | 52 // Mac will always give you the size you ask for and this case will fail. |
| 47 #define MAYBE_AllocateBadSize DISABLED_AllocateBadSize | 53 #define MAYBE_AllocateBadSize DISABLED_AllocateBadSize |
| 48 // We will always get YUYV from the Mac AVFoundation implementations. | 54 // We will always get YUYV from the Mac AVFoundation implementations. |
| 49 #define MAYBE_CaptureMjpeg DISABLED_CaptureMjpeg | 55 #define MAYBE_CaptureMjpeg DISABLED_CaptureMjpeg |
| 50 #define MAYBE_TakePhoto TakePhoto | 56 #define MAYBE_TakePhoto TakePhoto |
| 51 #define MAYBE_GetPhotoCapabilities DISABLED_GetPhotoCapabilities | 57 #define MAYBE_GetPhotoCapabilities DISABLED_GetPhotoCapabilities |
| 52 #elif defined(OS_WIN) | 58 #elif defined(OS_WIN) |
| 53 #define MAYBE_AllocateBadSize AllocateBadSize | 59 #define MAYBE_AllocateBadSize AllocateBadSize |
| 54 #define MAYBE_CaptureMjpeg CaptureMjpeg | 60 #define MAYBE_CaptureMjpeg CaptureMjpeg |
| 55 #define MAYBE_TakePhoto TakePhoto | 61 #define MAYBE_TakePhoto TakePhoto |
| 56 #define MAYBE_GetPhotoCapabilities DISABLED_GetPhotoCapabilities | 62 #define MAYBE_GetPhotoCapabilities DISABLED_GetPhotoCapabilities |
| 57 #elif defined(OS_ANDROID) | 63 #elif defined(OS_ANDROID) |
| 58 #define MAYBE_AllocateBadSize AllocateBadSize | 64 #define MAYBE_AllocateBadSize AllocateBadSize |
| 59 #define MAYBE_CaptureMjpeg CaptureMjpeg | 65 #define MAYBE_CaptureMjpeg CaptureMjpeg |
| 60 #define MAYBE_TakePhoto TakePhoto | 66 #define MAYBE_TakePhoto TakePhoto |
| 61 #define MAYBE_GetPhotoCapabilities GetPhotoCapabilities | 67 #define MAYBE_GetPhotoCapabilities GetPhotoCapabilities |
| 62 #elif defined(OS_LINUX) | 68 #elif defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 63 // AllocateBadSize will hang when a real camera is attached and if more than one | 69 // AllocateBadSize will hang when a real camera is attached and if more than one |
| 64 // test is trying to use the camera (even across processes). Do NOT renable | 70 // test is trying to use the camera (even across processes). Do NOT renable |
| 65 // this test without fixing the many bugs associated with it: | 71 // this test without fixing the many bugs associated with it: |
| 66 // http://crbug.com/94134 http://crbug.com/137260 http://crbug.com/417824 | 72 // http://crbug.com/94134 http://crbug.com/137260 http://crbug.com/417824 |
| 67 #define MAYBE_AllocateBadSize DISABLED_AllocateBadSize | 73 #define MAYBE_AllocateBadSize DISABLED_AllocateBadSize |
| 68 #define MAYBE_CaptureMjpeg CaptureMjpeg | 74 #define MAYBE_CaptureMjpeg CaptureMjpeg |
| 69 #define MAYBE_TakePhoto TakePhoto | 75 #define MAYBE_TakePhoto TakePhoto |
| 70 #define MAYBE_GetPhotoCapabilities GetPhotoCapabilities | 76 #define MAYBE_GetPhotoCapabilities GetPhotoCapabilities |
| 77 #elif defined(OS_CHROMEOS) | |
| 78 #define MAYBE_AllocateBadSize DISABLED_AllocateBadSize | |
| 79 #define MAYBE_CaptureMjpeg DISABLED_CaptureMjpeg | |
| 80 #define MAYBE_TakePhoto DISABLED_TakePhoto | |
| 81 #define MAYBE_GetPhotoCapabilities DISABLED_GetPhotoCapabilities | |
| 71 #else | 82 #else |
| 72 #define MAYBE_AllocateBadSize AllocateBadSize | 83 #define MAYBE_AllocateBadSize AllocateBadSize |
| 73 #define MAYBE_CaptureMjpeg CaptureMjpeg | 84 #define MAYBE_CaptureMjpeg CaptureMjpeg |
| 74 #define MAYBE_TakePhoto DISABLED_TakePhoto | 85 #define MAYBE_TakePhoto DISABLED_TakePhoto |
| 75 #define MAYBE_GetPhotoCapabilities DISABLED_GetPhotoCapabilities | 86 #define MAYBE_GetPhotoCapabilities DISABLED_GetPhotoCapabilities |
| 76 #endif | 87 #endif |
| 77 | 88 |
| 78 using ::testing::_; | 89 using ::testing::_; |
| 79 using ::testing::Invoke; | 90 using ::testing::Invoke; |
| 80 using ::testing::SaveArg; | 91 using ::testing::SaveArg; |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 198 | 209 |
| 199 const mojom::PhotoCapabilities* capabilities() { return capabilities_.get(); } | 210 const mojom::PhotoCapabilities* capabilities() { return capabilities_.get(); } |
| 200 | 211 |
| 201 private: | 212 private: |
| 202 friend class base::RefCountedThreadSafe<MockImageCaptureClient>; | 213 friend class base::RefCountedThreadSafe<MockImageCaptureClient>; |
| 203 virtual ~MockImageCaptureClient() {} | 214 virtual ~MockImageCaptureClient() {} |
| 204 | 215 |
| 205 mojom::PhotoCapabilitiesPtr capabilities_; | 216 mojom::PhotoCapabilitiesPtr capabilities_; |
| 206 }; | 217 }; |
| 207 | 218 |
| 219 #if defined(OS_CHROMEOS) | |
| 220 | |
| 221 class VideoCaptureDeviceTestEnvironment final : public testing::Environment { | |
|
chfremer
2017/05/18 17:24:39
Despite the name, this class does not seem to have
| |
| 222 public: | |
| 223 VideoCaptureDeviceTestEnvironment() : mojo_ipc_thread_("MojoIpcThread") {} | |
| 224 | |
| 225 ~VideoCaptureDeviceTestEnvironment() final {} | |
| 226 | |
| 227 void SetUp() final { | |
| 228 mojo_ipc_thread_.StartWithOptions( | |
| 229 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); | |
| 230 mojo::edk::Init(); | |
| 231 mojo::edk::InitIPCSupport(mojo_ipc_thread_.task_runner()); | |
| 232 } | |
| 233 | |
| 234 private: | |
| 235 base::Thread mojo_ipc_thread_; | |
| 236 }; | |
| 237 | |
| 238 testing::Environment* const vcd_test_env = | |
| 239 testing::AddGlobalTestEnvironment(new VideoCaptureDeviceTestEnvironment); | |
| 240 | |
| 241 #endif | |
| 242 | |
| 208 } // namespace | 243 } // namespace |
| 209 | 244 |
| 210 class VideoCaptureDeviceTest : public testing::TestWithParam<gfx::Size> { | 245 class VideoCaptureDeviceTest : public testing::TestWithParam<gfx::Size> { |
| 211 protected: | 246 protected: |
| 212 typedef VideoCaptureDevice::Client Client; | 247 typedef VideoCaptureDevice::Client Client; |
| 213 | 248 |
| 214 VideoCaptureDeviceTest() | 249 VideoCaptureDeviceTest() |
| 215 : loop_(new base::MessageLoop()), | 250 : loop_(new base::MessageLoop()), |
| 216 device_descriptors_(new VideoCaptureDeviceDescriptors()), | 251 device_descriptors_(new VideoCaptureDeviceDescriptors()), |
| 217 video_capture_client_(new MockVideoCaptureClient( | 252 video_capture_client_(new MockVideoCaptureClient( |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 610 | 645 |
| 611 device->GetPhotoCapabilities(std::move(scoped_get_callback)); | 646 device->GetPhotoCapabilities(std::move(scoped_get_callback)); |
| 612 run_loop.Run(); | 647 run_loop.Run(); |
| 613 | 648 |
| 614 ASSERT_TRUE(image_capture_client_->capabilities()); | 649 ASSERT_TRUE(image_capture_client_->capabilities()); |
| 615 | 650 |
| 616 device->StopAndDeAllocate(); | 651 device->StopAndDeAllocate(); |
| 617 } | 652 } |
| 618 | 653 |
| 619 }; // namespace media | 654 }; // namespace media |
| OLD | NEW |