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 25 matching lines...) Expand all Loading... | |
| 36 #include "media/capture/video/mac/video_capture_device_factory_mac.h" | 36 #include "media/capture/video/mac/video_capture_device_factory_mac.h" |
| 37 #endif | 37 #endif |
| 38 | 38 |
| 39 #if defined(OS_ANDROID) | 39 #if defined(OS_ANDROID) |
| 40 #include "base/android/build_info.h" | 40 #include "base/android/build_info.h" |
| 41 #include "base/android/jni_android.h" | 41 #include "base/android/jni_android.h" |
| 42 #include "media/capture/video/android/video_capture_device_android.h" | 42 #include "media/capture/video/android/video_capture_device_android.h" |
| 43 #include "media/capture/video/android/video_capture_device_factory_android.h" | 43 #include "media/capture/video/android/video_capture_device_factory_android.h" |
| 44 #endif | 44 #endif |
| 45 | 45 |
| 46 #if defined(OS_CHROMEOS) | |
| 47 #include "media/capture/video/chromeos/video_capture_device_arc_chromeos.h" | |
| 48 #include "media/capture/video/chromeos/video_capture_device_factory_chromeos.h" | |
| 49 #include "mojo/edk/embedder/embedder.h" | |
| 50 #include "mojo/edk/embedder/scoped_ipc_support.h" | |
| 51 #endif | |
| 52 | |
| 46 #if defined(OS_MACOSX) | 53 #if defined(OS_MACOSX) |
| 47 // Mac will always give you the size you ask for and this case will fail. | 54 // Mac will always give you the size you ask for and this case will fail. |
| 48 #define MAYBE_AllocateBadSize DISABLED_AllocateBadSize | 55 #define MAYBE_AllocateBadSize DISABLED_AllocateBadSize |
| 49 // We will always get YUYV from the Mac AVFoundation implementations. | 56 // We will always get YUYV from the Mac AVFoundation implementations. |
| 50 #define MAYBE_CaptureMjpeg DISABLED_CaptureMjpeg | 57 #define MAYBE_CaptureMjpeg DISABLED_CaptureMjpeg |
| 51 #define MAYBE_TakePhoto TakePhoto | 58 #define MAYBE_TakePhoto TakePhoto |
| 52 #define MAYBE_GetPhotoCapabilities GetPhotoCapabilities | 59 #define MAYBE_GetPhotoCapabilities GetPhotoCapabilities |
| 53 #elif defined(OS_WIN) | 60 #elif defined(OS_WIN) |
| 54 #define MAYBE_AllocateBadSize AllocateBadSize | 61 #define MAYBE_AllocateBadSize AllocateBadSize |
| 55 #define MAYBE_CaptureMjpeg CaptureMjpeg | 62 #define MAYBE_CaptureMjpeg CaptureMjpeg |
| 56 #define MAYBE_TakePhoto TakePhoto | 63 #define MAYBE_TakePhoto TakePhoto |
| 57 #define MAYBE_GetPhotoCapabilities GetPhotoCapabilities | 64 #define MAYBE_GetPhotoCapabilities GetPhotoCapabilities |
| 58 #elif defined(OS_ANDROID) | 65 #elif defined(OS_ANDROID) |
| 59 #define MAYBE_AllocateBadSize AllocateBadSize | 66 #define MAYBE_AllocateBadSize AllocateBadSize |
| 60 #define MAYBE_CaptureMjpeg CaptureMjpeg | 67 #define MAYBE_CaptureMjpeg CaptureMjpeg |
| 61 #define MAYBE_TakePhoto TakePhoto | 68 #define MAYBE_TakePhoto TakePhoto |
| 62 #define MAYBE_GetPhotoCapabilities GetPhotoCapabilities | 69 #define MAYBE_GetPhotoCapabilities GetPhotoCapabilities |
| 63 #elif defined(OS_LINUX) | 70 #elif defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 64 // AllocateBadSize will hang when a real camera is attached and if more than one | 71 // AllocateBadSize will hang when a real camera is attached and if more than one |
| 65 // test is trying to use the camera (even across processes). Do NOT renable | 72 // test is trying to use the camera (even across processes). Do NOT renable |
| 66 // this test without fixing the many bugs associated with it: | 73 // this test without fixing the many bugs associated with it: |
| 67 // http://crbug.com/94134 http://crbug.com/137260 http://crbug.com/417824 | 74 // http://crbug.com/94134 http://crbug.com/137260 http://crbug.com/417824 |
| 68 #define MAYBE_AllocateBadSize DISABLED_AllocateBadSize | 75 #define MAYBE_AllocateBadSize DISABLED_AllocateBadSize |
| 69 #define MAYBE_CaptureMjpeg CaptureMjpeg | 76 #define MAYBE_CaptureMjpeg CaptureMjpeg |
| 70 #define MAYBE_TakePhoto TakePhoto | 77 #define MAYBE_TakePhoto TakePhoto |
| 71 #define MAYBE_GetPhotoCapabilities GetPhotoCapabilities | 78 #define MAYBE_GetPhotoCapabilities GetPhotoCapabilities |
| 79 #elif defined(OS_CHROMEOS) | |
| 80 #define MAYBE_AllocateBadSize DISABLED_AllocateBadSize | |
| 81 #define MAYBE_CaptureMjpeg DISABLED_CaptureMjpeg | |
| 82 #define MAYBE_TakePhoto DISABLED_TakePhoto | |
| 83 #define MAYBE_GetPhotoCapabilities DISABLED_GetPhotoCapabilities | |
| 72 #else | 84 #else |
| 73 #define MAYBE_AllocateBadSize AllocateBadSize | 85 #define MAYBE_AllocateBadSize AllocateBadSize |
| 74 #define MAYBE_CaptureMjpeg CaptureMjpeg | 86 #define MAYBE_CaptureMjpeg CaptureMjpeg |
| 75 #define MAYBE_TakePhoto DISABLED_TakePhoto | 87 #define MAYBE_TakePhoto DISABLED_TakePhoto |
| 76 #define MAYBE_GetPhotoCapabilities DISABLED_GetPhotoCapabilities | 88 #define MAYBE_GetPhotoCapabilities DISABLED_GetPhotoCapabilities |
| 77 #endif | 89 #endif |
| 78 | 90 |
| 79 using ::testing::_; | 91 using ::testing::_; |
| 80 using ::testing::Invoke; | 92 using ::testing::Invoke; |
| 81 using ::testing::SaveArg; | 93 using ::testing::SaveArg; |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 199 | 211 |
| 200 const mojom::PhotoCapabilities* capabilities() { return capabilities_.get(); } | 212 const mojom::PhotoCapabilities* capabilities() { return capabilities_.get(); } |
| 201 | 213 |
| 202 private: | 214 private: |
| 203 friend class base::RefCountedThreadSafe<MockImageCaptureClient>; | 215 friend class base::RefCountedThreadSafe<MockImageCaptureClient>; |
| 204 virtual ~MockImageCaptureClient() {} | 216 virtual ~MockImageCaptureClient() {} |
| 205 | 217 |
| 206 mojom::PhotoCapabilitiesPtr capabilities_; | 218 mojom::PhotoCapabilitiesPtr capabilities_; |
| 207 }; | 219 }; |
| 208 | 220 |
| 221 #if defined(OS_CHROMEOS) | |
| 222 | |
| 223 class MojoTestEnvironment final : public testing::Environment { | |
|
chfremer
2017/05/24 23:36:43
Despite the name, this class does not seem to have
jcliang
2017/05/25 14:23:48
Sounds good. Could you point me an appropriate pla
chfremer
2017/05/25 17:13:07
I am not sure either, but keeping it here will lea
| |
| 224 public: | |
| 225 MojoTestEnvironment() : mojo_ipc_thread_("MojoIpcThread") {} | |
| 226 | |
| 227 ~MojoTestEnvironment() final {} | |
| 228 | |
| 229 void SetUp() final { | |
| 230 mojo::edk::Init(); | |
| 231 mojo_ipc_thread_.StartWithOptions( | |
| 232 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); | |
| 233 mojo_ipc_support_.reset(new mojo::edk::ScopedIPCSupport( | |
| 234 mojo_ipc_thread_.task_runner(), | |
| 235 mojo::edk::ScopedIPCSupport::ShutdownPolicy::FAST)); | |
| 236 VLOG(1) << "Mojo initialized"; | |
| 237 } | |
| 238 | |
| 239 void TearDown() final { | |
| 240 mojo_ipc_support_.reset(); | |
| 241 VLOG(1) << "Mojo IPC tear down"; | |
| 242 } | |
| 243 | |
| 244 private: | |
| 245 base::Thread mojo_ipc_thread_; | |
| 246 std::unique_ptr<mojo::edk::ScopedIPCSupport> mojo_ipc_support_; | |
| 247 }; | |
| 248 | |
| 249 testing::Environment* const mojo_test_env = | |
| 250 testing::AddGlobalTestEnvironment(new MojoTestEnvironment()); | |
| 251 | |
| 252 #endif | |
| 253 | |
| 209 } // namespace | 254 } // namespace |
| 210 | 255 |
| 211 class VideoCaptureDeviceTest : public testing::TestWithParam<gfx::Size> { | 256 class VideoCaptureDeviceTest : public testing::TestWithParam<gfx::Size> { |
| 212 protected: | 257 protected: |
| 213 typedef VideoCaptureDevice::Client Client; | 258 typedef VideoCaptureDevice::Client Client; |
| 214 | 259 |
| 215 VideoCaptureDeviceTest() | 260 VideoCaptureDeviceTest() |
| 216 : device_descriptors_(new VideoCaptureDeviceDescriptors()), | 261 : device_descriptors_(new VideoCaptureDeviceDescriptors()), |
| 217 video_capture_client_(new MockVideoCaptureClient( | 262 video_capture_client_(new MockVideoCaptureClient( |
| 218 base::Bind(&VideoCaptureDeviceTest::OnFrameCaptured, | 263 base::Bind(&VideoCaptureDeviceTest::OnFrameCaptured, |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 610 | 655 |
| 611 device->GetPhotoCapabilities(std::move(scoped_get_callback)); | 656 device->GetPhotoCapabilities(std::move(scoped_get_callback)); |
| 612 run_loop.Run(); | 657 run_loop.Run(); |
| 613 | 658 |
| 614 ASSERT_TRUE(image_capture_client_->capabilities()); | 659 ASSERT_TRUE(image_capture_client_->capabilities()); |
| 615 | 660 |
| 616 device->StopAndDeAllocate(); | 661 device->StopAndDeAllocate(); |
| 617 } | 662 } |
| 618 | 663 |
| 619 }; // namespace media | 664 }; // namespace media |
| OLD | NEW |