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 "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/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 | 60 |
61 namespace media { | 61 namespace media { |
62 namespace { | 62 namespace { |
63 | 63 |
64 static const gfx::Size kCaptureSizes[] = {gfx::Size(640, 480), | 64 static const gfx::Size kCaptureSizes[] = {gfx::Size(640, 480), |
65 gfx::Size(1280, 720)}; | 65 gfx::Size(1280, 720)}; |
66 | 66 |
67 class MockClient : public VideoCaptureDevice::Client { | 67 class MockClient : public VideoCaptureDevice::Client { |
68 public: | 68 public: |
69 MOCK_METHOD9(OnIncomingCapturedYuvData, | 69 MOCK_METHOD9(OnIncomingCapturedYuvData, |
70 void(const uint8* y_data, | 70 void(const uint8_t* y_data, |
71 const uint8* u_data, | 71 const uint8_t* u_data, |
72 const uint8* v_data, | 72 const uint8_t* v_data, |
73 size_t y_stride, | 73 size_t y_stride, |
74 size_t u_stride, | 74 size_t u_stride, |
75 size_t v_stride, | 75 size_t v_stride, |
76 const VideoCaptureFormat& frame_format, | 76 const VideoCaptureFormat& frame_format, |
77 int clockwise_rotation, | 77 int clockwise_rotation, |
78 const base::TimeTicks& timestamp)); | 78 const base::TimeTicks& timestamp)); |
79 MOCK_METHOD0(DoReserveOutputBuffer, void(void)); | 79 MOCK_METHOD0(DoReserveOutputBuffer, void(void)); |
80 MOCK_METHOD0(DoOnIncomingCapturedBuffer, void(void)); | 80 MOCK_METHOD0(DoOnIncomingCapturedBuffer, void(void)); |
81 MOCK_METHOD0(DoOnIncomingCapturedVideoFrame, void(void)); | 81 MOCK_METHOD0(DoOnIncomingCapturedVideoFrame, void(void)); |
82 MOCK_METHOD2(OnError, | 82 MOCK_METHOD2(OnError, |
83 void(const tracked_objects::Location& from_here, | 83 void(const tracked_objects::Location& from_here, |
84 const std::string& reason)); | 84 const std::string& reason)); |
85 MOCK_CONST_METHOD0(GetBufferPoolUtilization, double(void)); | 85 MOCK_CONST_METHOD0(GetBufferPoolUtilization, double(void)); |
86 | 86 |
87 explicit MockClient(base::Callback<void(const VideoCaptureFormat&)> frame_cb) | 87 explicit MockClient(base::Callback<void(const VideoCaptureFormat&)> frame_cb) |
88 : main_thread_(base::ThreadTaskRunnerHandle::Get()), | 88 : main_thread_(base::ThreadTaskRunnerHandle::Get()), |
89 frame_cb_(frame_cb) {} | 89 frame_cb_(frame_cb) {} |
90 | 90 |
91 void OnIncomingCapturedData(const uint8* data, | 91 void OnIncomingCapturedData(const uint8_t* data, |
92 int length, | 92 int length, |
93 const VideoCaptureFormat& format, | 93 const VideoCaptureFormat& format, |
94 int rotation, | 94 int rotation, |
95 const base::TimeTicks& timestamp) override { | 95 const base::TimeTicks& timestamp) override { |
96 ASSERT_GT(length, 0); | 96 ASSERT_GT(length, 0); |
97 ASSERT_TRUE(data != NULL); | 97 ASSERT_TRUE(data != NULL); |
98 main_thread_->PostTask(FROM_HERE, base::Bind(frame_cb_, format)); | 98 main_thread_->PostTask(FROM_HERE, base::Bind(frame_cb_, format)); |
99 } | 99 } |
100 | 100 |
101 // Trampoline methods to workaround GMOCK problems with scoped_ptr<>. | 101 // Trampoline methods to workaround GMOCK problems with scoped_ptr<>. |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 // GetDeviceSupportedFormats(). | 472 // GetDeviceSupportedFormats(). |
473 scoped_ptr<VideoCaptureDevice::Name> name = | 473 scoped_ptr<VideoCaptureDevice::Name> name = |
474 GetFirstDeviceNameSupportingPixelFormat(PIXEL_FORMAT_MAX); | 474 GetFirstDeviceNameSupportingPixelFormat(PIXEL_FORMAT_MAX); |
475 // Verify no camera returned for PIXEL_FORMAT_MAX. Nothing else | 475 // Verify no camera returned for PIXEL_FORMAT_MAX. Nothing else |
476 // to test here | 476 // to test here |
477 // since we cannot forecast the hardware capabilities. | 477 // since we cannot forecast the hardware capabilities. |
478 ASSERT_FALSE(name); | 478 ASSERT_FALSE(name); |
479 } | 479 } |
480 | 480 |
481 }; // namespace media | 481 }; // namespace media |
OLD | NEW |