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

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

Issue 955253002: Add metadata to media::VideoFrame and plumb it through IPC/MediaStream. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tommi's nits addressed Created 5 years, 9 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/media.gyp ('k') | media/video/capture/video_capture_device.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/bind.h" 5 #include "base/bind.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/run_loop.h" 7 #include "base/run_loop.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/base/video_capture_types.h" 10 #include "media/base/video_capture_types.h"
11 #include "media/video/capture/fake_video_capture_device.h" 11 #include "media/video/capture/fake_video_capture_device.h"
12 #include "media/video/capture/fake_video_capture_device_factory.h" 12 #include "media/video/capture/fake_video_capture_device_factory.h"
13 #include "media/video/capture/video_capture_device.h" 13 #include "media/video/capture/video_capture_device.h"
14 #include "testing/gmock/include/gmock/gmock.h" 14 #include "testing/gmock/include/gmock/gmock.h"
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 16
17 using ::testing::_; 17 using ::testing::_;
18 using ::testing::SaveArg; 18 using ::testing::SaveArg;
19 19
20 namespace media { 20 namespace media {
21 21
22 namespace { 22 namespace {
23 23
24 class MockClient : public VideoCaptureDevice::Client { 24 class MockClient : public VideoCaptureDevice::Client {
25 public: 25 public:
26 MOCK_METHOD2(ReserveOutputBuffer, 26 MOCK_METHOD2(ReserveOutputBuffer,
27 scoped_refptr<Buffer>(VideoFrame::Format format, 27 scoped_refptr<Buffer>(VideoFrame::Format format,
28 const gfx::Size& dimensions)); 28 const gfx::Size& dimensions));
29 MOCK_METHOD4(OnIncomingCapturedVideoFrame, 29 MOCK_METHOD3(OnIncomingCapturedVideoFrame,
30 void(const scoped_refptr<Buffer>& buffer, 30 void(const scoped_refptr<Buffer>& buffer,
31 const VideoCaptureFormat& buffer_format,
32 const scoped_refptr<media::VideoFrame>& frame, 31 const scoped_refptr<media::VideoFrame>& frame,
33 const base::TimeTicks& timestamp)); 32 const base::TimeTicks& timestamp));
34 MOCK_METHOD1(OnError, void(const std::string& reason)); 33 MOCK_METHOD1(OnError, void(const std::string& reason));
35 34
36 explicit MockClient(base::Callback<void(const VideoCaptureFormat&)> frame_cb) 35 explicit MockClient(base::Callback<void(const VideoCaptureFormat&)> frame_cb)
37 : main_thread_(base::MessageLoopProxy::current()), frame_cb_(frame_cb) {} 36 : main_thread_(base::MessageLoopProxy::current()), frame_cb_(frame_cb) {}
38 37
39 void OnIncomingCapturedData(const uint8* data, 38 void OnIncomingCapturedData(const uint8* data,
40 int length, 39 int length,
41 const VideoCaptureFormat& format, 40 const VideoCaptureFormat& format,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 : loop_(new base::MessageLoop()), 74 : loop_(new base::MessageLoop()),
76 client_(new MockClient( 75 client_(new MockClient(
77 base::Bind(&FakeVideoCaptureDeviceTest::OnFrameCaptured, 76 base::Bind(&FakeVideoCaptureDeviceTest::OnFrameCaptured,
78 base::Unretained(this)))), 77 base::Unretained(this)))),
79 video_capture_device_factory_(new FakeVideoCaptureDeviceFactory()) { 78 video_capture_device_factory_(new FakeVideoCaptureDeviceFactory()) {
80 device_enumeration_listener_ = new DeviceEnumerationListener(); 79 device_enumeration_listener_ = new DeviceEnumerationListener();
81 } 80 }
82 81
83 void SetUp() override { 82 void SetUp() override {
84 EXPECT_CALL(*client_, ReserveOutputBuffer(_,_)).Times(0); 83 EXPECT_CALL(*client_, ReserveOutputBuffer(_,_)).Times(0);
85 EXPECT_CALL(*client_, OnIncomingCapturedVideoFrame(_,_,_,_)).Times(0); 84 EXPECT_CALL(*client_, OnIncomingCapturedVideoFrame(_,_,_)).Times(0);
86 } 85 }
87 86
88 void OnFrameCaptured(const VideoCaptureFormat& format) { 87 void OnFrameCaptured(const VideoCaptureFormat& format) {
89 last_format_ = format; 88 last_format_ = format;
90 run_loop_->QuitClosure().Run(); 89 run_loop_->QuitClosure().Run();
91 } 90 }
92 91
93 void WaitForCapturedFrame() { 92 void WaitForCapturedFrame() {
94 run_loop_.reset(new base::RunLoop()); 93 run_loop_.reset(new base::RunLoop());
95 run_loop_->Run(); 94 run_loop_->Run();
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 199
201 // We set TimeWait to 200 action timeouts and this should be enough for at 200 // We set TimeWait to 200 action timeouts and this should be enough for at
202 // least action_count/kFakeCaptureCapabilityChangePeriod calls. 201 // least action_count/kFakeCaptureCapabilityChangePeriod calls.
203 for (int i = 0; i < action_count; ++i) { 202 for (int i = 0; i < action_count; ++i) {
204 WaitForCapturedFrame(); 203 WaitForCapturedFrame();
205 } 204 }
206 device->StopAndDeAllocate(); 205 device->StopAndDeAllocate();
207 } 206 }
208 207
209 }; // namespace media 208 }; // namespace media
OLDNEW
« no previous file with comments | « media/media.gyp ('k') | media/video/capture/video_capture_device.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698