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 // Unit test for VideoCaptureController. | 5 // Unit test for VideoCaptureController. |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 | 117 |
118 scoped_refptr<media::VideoFrame> WrapI420Buffer(gfx::Size dimensions, | 118 scoped_refptr<media::VideoFrame> WrapI420Buffer(gfx::Size dimensions, |
119 uint8* data) { | 119 uint8* data) { |
120 return media::VideoFrame::WrapExternalSharedMemory( | 120 return media::VideoFrame::WrapExternalSharedMemory( |
121 media::PIXEL_FORMAT_I420, dimensions, gfx::Rect(dimensions), dimensions, | 121 media::PIXEL_FORMAT_I420, dimensions, gfx::Rect(dimensions), dimensions, |
122 data, | 122 data, |
123 media::VideoFrame::AllocationSize(media::PIXEL_FORMAT_I420, dimensions), | 123 media::VideoFrame::AllocationSize(media::PIXEL_FORMAT_I420, dimensions), |
124 base::SharedMemory::NULLHandle(), 0u, base::TimeDelta()); | 124 base::SharedMemory::NULLHandle(), 0u, base::TimeDelta()); |
125 } | 125 } |
126 | 126 |
127 TestBrowserThreadBundle bundle_; | |
128 scoped_ptr<MockVideoCaptureControllerEventHandler> client_a_; | 127 scoped_ptr<MockVideoCaptureControllerEventHandler> client_a_; |
129 scoped_ptr<MockVideoCaptureControllerEventHandler> client_b_; | 128 scoped_ptr<MockVideoCaptureControllerEventHandler> client_b_; |
130 scoped_ptr<VideoCaptureController> controller_; | 129 scoped_ptr<VideoCaptureController> controller_; |
131 scoped_ptr<media::VideoCaptureDevice::Client> device_; | 130 scoped_ptr<media::VideoCaptureDevice::Client> device_; |
| 131 // Construct/destruct the thread bundle last/first respectively to make sure |
| 132 // that the IO thread is torn down before the main thread goes away, as it |
| 133 // does when running in Chrome. |
| 134 TestBrowserThreadBundle bundle_; |
132 | 135 |
133 private: | 136 private: |
134 DISALLOW_COPY_AND_ASSIGN(VideoCaptureControllerTest); | 137 DISALLOW_COPY_AND_ASSIGN(VideoCaptureControllerTest); |
135 }; | 138 }; |
136 | 139 |
137 // A simple test of VideoCaptureController's ability to add, remove, and keep | 140 // A simple test of VideoCaptureController's ability to add, remove, and keep |
138 // track of clients. | 141 // track of clients. |
139 TEST_F(VideoCaptureControllerTest, AddAndRemoveClients) { | 142 TEST_F(VideoCaptureControllerTest, AddAndRemoveClients) { |
140 media::VideoCaptureParams session_100; | 143 media::VideoCaptureParams session_100; |
141 session_100.requested_format = media::VideoCaptureFormat( | 144 session_100.requested_format = media::VideoCaptureFormat( |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 | 550 |
548 // Second client connects after the error state. It also should get told of | 551 // Second client connects after the error state. It also should get told of |
549 // the error. | 552 // the error. |
550 EXPECT_CALL(*client_b_, DoError(route_id)).Times(1); | 553 EXPECT_CALL(*client_b_, DoError(route_id)).Times(1); |
551 controller_->AddClient( | 554 controller_->AddClient( |
552 route_id, client_b_.get(), base::kNullProcessHandle, 200, session_200); | 555 route_id, client_b_.get(), base::kNullProcessHandle, 200, session_200); |
553 Mock::VerifyAndClearExpectations(client_b_.get()); | 556 Mock::VerifyAndClearExpectations(client_b_.get()); |
554 } | 557 } |
555 | 558 |
556 } // namespace content | 559 } // namespace content |
OLD | NEW |