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

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

Issue 24079003: Add VideoCaptureDevice::GetDeviceSupportedFormats to interface + implementation for Linux and Fake (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed parameter device_name from GetDeviceSupportedFormats. Added explanation to VCD interface. Created 7 years, 3 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
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 "base/memory/scoped_ptr.h" 5 #include "base/memory/scoped_ptr.h"
6 #include "base/message_loop/message_loop.h" 6 #include "base/message_loop/message_loop.h"
7 #include "base/synchronization/waitable_event.h" 7 #include "base/synchronization/waitable_event.h"
8 #include "base/test/test_timeouts.h" 8 #include "base/test/test_timeouts.h"
9 #include "base/threading/thread.h" 9 #include "base/threading/thread.h"
10 #include "media/video/capture/fake_video_capture_device.h" 10 #include "media/video/capture/fake_video_capture_device.h"
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 113
114 virtual void TearDown() { 114 virtual void TearDown() {
115 } 115 }
116 116
117 #if defined(OS_WIN) 117 #if defined(OS_WIN)
118 base::win::ScopedCOMInitializer initialize_com_; 118 base::win::ScopedCOMInitializer initialize_com_;
119 #endif 119 #endif
120 base::WaitableEvent wait_event_; 120 base::WaitableEvent wait_event_;
121 scoped_ptr<MockFrameObserver> frame_observer_; 121 scoped_ptr<MockFrameObserver> frame_observer_;
122 VideoCaptureDevice::Names names_; 122 VideoCaptureDevice::Names names_;
123 VideoCaptureFormats capture_formats_;
123 scoped_ptr<base::MessageLoop> loop_; 124 scoped_ptr<base::MessageLoop> loop_;
124 }; 125 };
125 126
126 TEST_F(VideoCaptureDeviceTest, OpenInvalidDevice) { 127 TEST_F(VideoCaptureDeviceTest, OpenInvalidDevice) {
127 #if defined(OS_WIN) 128 #if defined(OS_WIN)
128 VideoCaptureDevice::Name::CaptureApiType api_type = 129 VideoCaptureDevice::Name::CaptureApiType api_type =
129 VideoCaptureDeviceMFWin::PlatformSupported() 130 VideoCaptureDeviceMFWin::PlatformSupported()
130 ? VideoCaptureDevice::Name::MEDIA_FOUNDATION 131 ? VideoCaptureDevice::Name::MEDIA_FOUNDATION
131 : VideoCaptureDevice::Name::DIRECT_SHOW; 132 : VideoCaptureDevice::Name::DIRECT_SHOW;
132 VideoCaptureDevice::Name device_name("jibberish", "jibberish", api_type); 133 VideoCaptureDevice::Name device_name("jibberish", "jibberish", api_type);
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 EXPECT_CALL(*frame_observer_, OnFrameInfoChanged(_)) 444 EXPECT_CALL(*frame_observer_, OnFrameInfoChanged(_))
444 .Times(AtLeast(action_count / 30)); 445 .Times(AtLeast(action_count / 30));
445 device->Start(); 446 device->Start();
446 for (int i = 0; i < action_count; ++i) { 447 for (int i = 0; i < action_count; ++i) {
447 EXPECT_TRUE(wait_event_.TimedWait(TestTimeouts::action_timeout())); 448 EXPECT_TRUE(wait_event_.TimedWait(TestTimeouts::action_timeout()));
448 } 449 }
449 device->Stop(); 450 device->Stop();
450 device->DeAllocate(); 451 device->DeAllocate();
451 } 452 }
452 453
454 TEST_F(VideoCaptureDeviceTest, GetDeviceSupportedFormats) {
455 VideoCaptureDevice::Names names;
456
457 FakeVideoCaptureDevice::GetDeviceNames(&names);
458 scoped_ptr<VideoCaptureDevice> device(
459 FakeVideoCaptureDevice::Create(names.front()));
460 ASSERT_TRUE(device.get() != NULL);
461 device->GetDeviceSupportedFormats(&capture_formats_);
462
463 EXPECT_GE(capture_formats_.size(), 1u);
464 EXPECT_EQ(capture_formats_[0].width, 640);
465 EXPECT_EQ(capture_formats_[0].height, 480);
466 EXPECT_EQ(capture_formats_[0].color, media::PIXEL_FORMAT_I420);
467 EXPECT_GE(capture_formats_[0].frame_rate, 20);
468 }
469
453 }; // namespace media 470 }; // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698