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

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

Issue 1105163004: Revert of [media] Replace MessageLoopProxy usage with ThreadTaskRunnerHandle (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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/video/capture/mac/video_capture_device_mac.mm ('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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/bind_helpers.h" 6 #include "base/bind_helpers.h"
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop/message_loop_proxy.h"
9 #include "base/run_loop.h" 10 #include "base/run_loop.h"
10 #include "base/single_thread_task_runner.h"
11 #include "base/test/test_timeouts.h" 11 #include "base/test/test_timeouts.h"
12 #include "base/thread_task_runner_handle.h"
13 #include "base/threading/thread.h" 12 #include "base/threading/thread.h"
14 #include "media/base/video_capture_types.h" 13 #include "media/base/video_capture_types.h"
15 #include "media/video/capture/video_capture_device.h" 14 #include "media/video/capture/video_capture_device.h"
16 #include "media/video/capture/video_capture_device_factory.h" 15 #include "media/video/capture/video_capture_device_factory.h"
17 #include "testing/gmock/include/gmock/gmock.h" 16 #include "testing/gmock/include/gmock/gmock.h"
18 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
19 18
20 #if defined(OS_WIN) 19 #if defined(OS_WIN)
21 #include "base/win/scoped_com_initializer.h" 20 #include "base/win/scoped_com_initializer.h"
22 #include "media/video/capture/win/video_capture_device_factory_win.h" 21 #include "media/video/capture/win/video_capture_device_factory_win.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 size_t v_stride, 73 size_t v_stride,
75 const VideoCaptureFormat& frame_format, 74 const VideoCaptureFormat& frame_format,
76 int clockwise_rotation, 75 int clockwise_rotation,
77 const base::TimeTicks& timestamp)); 76 const base::TimeTicks& timestamp));
78 MOCK_METHOD0(DoReserveOutputBuffer, void(void)); 77 MOCK_METHOD0(DoReserveOutputBuffer, void(void));
79 MOCK_METHOD0(DoOnIncomingCapturedBuffer, void(void)); 78 MOCK_METHOD0(DoOnIncomingCapturedBuffer, void(void));
80 MOCK_METHOD0(DoOnIncomingCapturedVideoFrame, void(void)); 79 MOCK_METHOD0(DoOnIncomingCapturedVideoFrame, void(void));
81 MOCK_METHOD1(OnError, void(const std::string& reason)); 80 MOCK_METHOD1(OnError, void(const std::string& reason));
82 81
83 explicit MockClient(base::Callback<void(const VideoCaptureFormat&)> frame_cb) 82 explicit MockClient(base::Callback<void(const VideoCaptureFormat&)> frame_cb)
84 : main_thread_(base::ThreadTaskRunnerHandle::Get()), 83 : main_thread_(base::MessageLoopProxy::current()), frame_cb_(frame_cb) {}
85 frame_cb_(frame_cb) {}
86 84
87 void OnIncomingCapturedData(const uint8* data, 85 void OnIncomingCapturedData(const uint8* data,
88 int length, 86 int length,
89 const VideoCaptureFormat& format, 87 const VideoCaptureFormat& format,
90 int rotation, 88 int rotation,
91 const base::TimeTicks& timestamp) override { 89 const base::TimeTicks& timestamp) override {
92 ASSERT_GT(length, 0); 90 ASSERT_GT(length, 0);
93 ASSERT_TRUE(data != NULL); 91 ASSERT_TRUE(data != NULL);
94 main_thread_->PostTask(FROM_HERE, base::Bind(frame_cb_, format)); 92 main_thread_->PostTask(FROM_HERE, base::Bind(frame_cb_, format));
95 } 93 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 class VideoCaptureDeviceTest : public testing::Test { 134 class VideoCaptureDeviceTest : public testing::Test {
137 protected: 135 protected:
138 typedef VideoCaptureDevice::Client Client; 136 typedef VideoCaptureDevice::Client Client;
139 137
140 VideoCaptureDeviceTest() 138 VideoCaptureDeviceTest()
141 : loop_(new base::MessageLoop()), 139 : loop_(new base::MessageLoop()),
142 client_( 140 client_(
143 new MockClient(base::Bind(&VideoCaptureDeviceTest::OnFrameCaptured, 141 new MockClient(base::Bind(&VideoCaptureDeviceTest::OnFrameCaptured,
144 base::Unretained(this)))), 142 base::Unretained(this)))),
145 video_capture_device_factory_(VideoCaptureDeviceFactory::CreateFactory( 143 video_capture_device_factory_(VideoCaptureDeviceFactory::CreateFactory(
146 base::ThreadTaskRunnerHandle::Get())) { 144 base::MessageLoopProxy::current())) {
147 device_enumeration_listener_ = new DeviceEnumerationListener(); 145 device_enumeration_listener_ = new DeviceEnumerationListener();
148 } 146 }
149 147
150 void SetUp() override { 148 void SetUp() override {
151 #if defined(OS_ANDROID) 149 #if defined(OS_ANDROID)
152 VideoCaptureDeviceAndroid::RegisterVideoCaptureDevice( 150 VideoCaptureDeviceAndroid::RegisterVideoCaptureDevice(
153 base::android::AttachCurrentThread()); 151 base::android::AttachCurrentThread());
154 #endif 152 #endif
155 EXPECT_CALL(*client_, OnIncomingCapturedYuvData(_,_,_,_,_,_,_,_,_)) 153 EXPECT_CALL(*client_, OnIncomingCapturedYuvData(_,_,_,_,_,_,_,_,_))
156 .Times(0); 154 .Times(0);
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 // Use PIXEL_FORMAT_MAX to iterate all device names for testing 455 // Use PIXEL_FORMAT_MAX to iterate all device names for testing
458 // GetDeviceSupportedFormats(). 456 // GetDeviceSupportedFormats().
459 scoped_ptr<VideoCaptureDevice::Name> name = 457 scoped_ptr<VideoCaptureDevice::Name> name =
460 GetFirstDeviceNameSupportingPixelFormat(PIXEL_FORMAT_MAX); 458 GetFirstDeviceNameSupportingPixelFormat(PIXEL_FORMAT_MAX);
461 // Verify no camera returned for PIXEL_FORMAT_MAX. Nothing else to test here 459 // Verify no camera returned for PIXEL_FORMAT_MAX. Nothing else to test here
462 // since we cannot forecast the hardware capabilities. 460 // since we cannot forecast the hardware capabilities.
463 ASSERT_FALSE(name); 461 ASSERT_FALSE(name);
464 } 462 }
465 463
466 }; // namespace media 464 }; // namespace media
OLDNEW
« no previous file with comments | « media/video/capture/mac/video_capture_device_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698