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

Side by Side Diff: media/capture/video/video_capture_device_unittest.cc

Issue 2936373002: Revert of media: add video capture device for ARC++ camera HAL v3 (Closed)
Patch Set: Created 3 years, 6 months 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
« no previous file with comments | « media/capture/video/linux/video_capture_device_factory_linux.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
53 #if defined(OS_MACOSX) 46 #if defined(OS_MACOSX)
54 // Mac will always give you the size you ask for and this case will fail. 47 // Mac will always give you the size you ask for and this case will fail.
55 #define MAYBE_AllocateBadSize DISABLED_AllocateBadSize 48 #define MAYBE_AllocateBadSize DISABLED_AllocateBadSize
56 // We will always get YUYV from the Mac AVFoundation implementations. 49 // We will always get YUYV from the Mac AVFoundation implementations.
57 #define MAYBE_CaptureMjpeg DISABLED_CaptureMjpeg 50 #define MAYBE_CaptureMjpeg DISABLED_CaptureMjpeg
58 #define MAYBE_TakePhoto TakePhoto 51 #define MAYBE_TakePhoto TakePhoto
59 #define MAYBE_GetPhotoState GetPhotoState 52 #define MAYBE_GetPhotoState GetPhotoState
60 #elif defined(OS_WIN) 53 #elif defined(OS_WIN)
61 #define MAYBE_AllocateBadSize AllocateBadSize 54 #define MAYBE_AllocateBadSize AllocateBadSize
62 #define MAYBE_CaptureMjpeg CaptureMjpeg 55 #define MAYBE_CaptureMjpeg CaptureMjpeg
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 198
206 const mojom::PhotoState* capabilities() { return state_.get(); } 199 const mojom::PhotoState* capabilities() { return state_.get(); }
207 200
208 private: 201 private:
209 friend class base::RefCountedThreadSafe<MockImageCaptureClient>; 202 friend class base::RefCountedThreadSafe<MockImageCaptureClient>;
210 virtual ~MockImageCaptureClient() {} 203 virtual ~MockImageCaptureClient() {}
211 204
212 mojom::PhotoStatePtr state_; 205 mojom::PhotoStatePtr state_;
213 }; 206 };
214 207
215 #if defined(OS_CHROMEOS)
216
217 class MojoEnabledTestEnvironment final : public testing::Environment {
218 public:
219 MojoEnabledTestEnvironment() : mojo_ipc_thread_("MojoIpcThread") {}
220
221 ~MojoEnabledTestEnvironment() final {}
222
223 void SetUp() final {
224 mojo::edk::Init();
225 mojo_ipc_thread_.StartWithOptions(
226 base::Thread::Options(base::MessageLoop::TYPE_IO, 0));
227 mojo_ipc_support_.reset(new mojo::edk::ScopedIPCSupport(
228 mojo_ipc_thread_.task_runner(),
229 mojo::edk::ScopedIPCSupport::ShutdownPolicy::FAST));
230 VLOG(1) << "Mojo initialized";
231 }
232
233 void TearDown() final {
234 mojo_ipc_support_.reset();
235 VLOG(1) << "Mojo IPC tear down";
236 }
237
238 private:
239 base::Thread mojo_ipc_thread_;
240 std::unique_ptr<mojo::edk::ScopedIPCSupport> mojo_ipc_support_;
241 };
242
243 testing::Environment* const mojo_test_env =
244 testing::AddGlobalTestEnvironment(new MojoEnabledTestEnvironment());
245
246 #endif
247
248 } // namespace 208 } // namespace
249 209
250 class VideoCaptureDeviceTest : public testing::TestWithParam<gfx::Size> { 210 class VideoCaptureDeviceTest : public testing::TestWithParam<gfx::Size> {
251 protected: 211 protected:
252 typedef VideoCaptureDevice::Client Client; 212 typedef VideoCaptureDevice::Client Client;
253 213
254 VideoCaptureDeviceTest() 214 VideoCaptureDeviceTest()
255 : device_descriptors_(new VideoCaptureDeviceDescriptors()), 215 : device_descriptors_(new VideoCaptureDeviceDescriptors()),
256 video_capture_client_(new MockVideoCaptureClient( 216 video_capture_client_(new MockVideoCaptureClient(
257 base::Bind(&VideoCaptureDeviceTest::OnFrameCaptured, 217 base::Bind(&VideoCaptureDeviceTest::OnFrameCaptured,
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 // since we cannot forecast the hardware capabilities. 520 // since we cannot forecast the hardware capabilities.
561 ASSERT_FALSE(device_descriptor); 521 ASSERT_FALSE(device_descriptor);
562 } 522 }
563 523
564 // Starts the camera and verifies that a photo can be taken. The correctness of 524 // Starts the camera and verifies that a photo can be taken. The correctness of
565 // the photo is enforced by MockImageCaptureClient. 525 // the photo is enforced by MockImageCaptureClient.
566 TEST_F(VideoCaptureDeviceTest, MAYBE_TakePhoto) { 526 TEST_F(VideoCaptureDeviceTest, MAYBE_TakePhoto) {
567 if (!FindUsableDevices()) 527 if (!FindUsableDevices())
568 return; 528 return;
569 529
570 #if defined(OS_CHROMEOS)
571 // TODO(jcliang): Remove this after we implement TakePhoto.
572 if (VideoCaptureDeviceFactoryChromeOS::ShouldEnable()) {
573 return;
574 }
575 #endif
576
577 #if defined(OS_ANDROID) 530 #if defined(OS_ANDROID)
578 // TODO(mcasas): fails on Lollipop devices, reconnect https://crbug.com/646840 531 // TODO(mcasas): fails on Lollipop devices, reconnect https://crbug.com/646840
579 if (base::android::BuildInfo::GetInstance()->sdk_int() < 532 if (base::android::BuildInfo::GetInstance()->sdk_int() <
580 base::android::SDK_VERSION_MARSHMALLOW) { 533 base::android::SDK_VERSION_MARSHMALLOW) {
581 return; 534 return;
582 } 535 }
583 #endif 536 #endif
584 537
585 std::unique_ptr<VideoCaptureDevice> device( 538 std::unique_ptr<VideoCaptureDevice> device(
586 video_capture_device_factory_->CreateDevice( 539 video_capture_device_factory_->CreateDevice(
(...skipping 25 matching lines...) Expand all
612 run_loop.Run(); 565 run_loop.Run();
613 566
614 device->StopAndDeAllocate(); 567 device->StopAndDeAllocate();
615 } 568 }
616 569
617 // Starts the camera and verifies that the photo capabilities can be retrieved. 570 // Starts the camera and verifies that the photo capabilities can be retrieved.
618 TEST_F(VideoCaptureDeviceTest, MAYBE_GetPhotoState) { 571 TEST_F(VideoCaptureDeviceTest, MAYBE_GetPhotoState) {
619 if (!FindUsableDevices()) 572 if (!FindUsableDevices())
620 return; 573 return;
621 574
622 #if defined(OS_CHROMEOS)
623 // TODO(jcliang): Remove this after we implement GetPhotoCapabilities.
624 if (VideoCaptureDeviceFactoryChromeOS::ShouldEnable()) {
625 return;
626 }
627 #endif
628
629 #if defined(OS_ANDROID) 575 #if defined(OS_ANDROID)
630 // TODO(mcasas): fails on Lollipop devices, reconnect https://crbug.com/646840 576 // TODO(mcasas): fails on Lollipop devices, reconnect https://crbug.com/646840
631 if (base::android::BuildInfo::GetInstance()->sdk_int() < 577 if (base::android::BuildInfo::GetInstance()->sdk_int() <
632 base::android::SDK_VERSION_MARSHMALLOW) { 578 base::android::SDK_VERSION_MARSHMALLOW) {
633 return; 579 return;
634 } 580 }
635 #endif 581 #endif
636 582
637 std::unique_ptr<VideoCaptureDevice> device( 583 std::unique_ptr<VideoCaptureDevice> device(
638 video_capture_device_factory_->CreateDevice( 584 video_capture_device_factory_->CreateDevice(
(...skipping 24 matching lines...) Expand all
663 609
664 device->GetPhotoState(std::move(scoped_get_callback)); 610 device->GetPhotoState(std::move(scoped_get_callback));
665 run_loop.Run(); 611 run_loop.Run();
666 612
667 ASSERT_TRUE(image_capture_client_->capabilities()); 613 ASSERT_TRUE(image_capture_client_->capabilities());
668 614
669 device->StopAndDeAllocate(); 615 device->StopAndDeAllocate();
670 } 616 }
671 617
672 }; // namespace media 618 }; // namespace media
OLDNEW
« no previous file with comments | « media/capture/video/linux/video_capture_device_factory_linux.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698