| 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 scoped_ptr<media::VideoCaptureDevice::Client> device_; | 106 scoped_ptr<media::VideoCaptureDevice::Client> device_; |
| 107 | 107 |
| 108 private: | 108 private: |
| 109 DISALLOW_COPY_AND_ASSIGN(VideoCaptureControllerTest); | 109 DISALLOW_COPY_AND_ASSIGN(VideoCaptureControllerTest); |
| 110 }; | 110 }; |
| 111 | 111 |
| 112 // A simple test of VideoCaptureController's ability to add, remove, and keep | 112 // A simple test of VideoCaptureController's ability to add, remove, and keep |
| 113 // track of clients. | 113 // track of clients. |
| 114 TEST_F(VideoCaptureControllerTest, AddAndRemoveClients) { | 114 TEST_F(VideoCaptureControllerTest, AddAndRemoveClients) { |
| 115 media::VideoCaptureParams session_100; | 115 media::VideoCaptureParams session_100; |
| 116 session_100.session_id = 100; | |
| 117 session_100.requested_format = media::VideoCaptureFormat( | 116 session_100.requested_format = media::VideoCaptureFormat( |
| 118 320, 240, 30, media::ConstantResolutionVideoCaptureDevice); | 117 gfx::Size(320, 240), 30, media::PIXEL_FORMAT_I420); |
| 119 | |
| 120 media::VideoCaptureParams session_200 = session_100; | 118 media::VideoCaptureParams session_200 = session_100; |
| 121 session_200.session_id = 200; | |
| 122 | 119 |
| 123 media::VideoCaptureParams session_300 = session_100; | 120 media::VideoCaptureParams session_300 = session_100; |
| 124 session_300.session_id = 300; | |
| 125 | 121 |
| 126 media::VideoCaptureParams session_400 = session_100; | 122 media::VideoCaptureParams session_400 = session_100; |
| 127 session_400.session_id = 400; | |
| 128 | 123 |
| 129 // Intentionally use the same route ID for two of the clients: the device_ids | 124 // Intentionally use the same route ID for two of the clients: the device_ids |
| 130 // are a per-VideoCaptureHost namespace, and can overlap across hosts. | 125 // are a per-VideoCaptureHost namespace, and can overlap across hosts. |
| 131 const VideoCaptureControllerID client_a_route_1(44); | 126 const VideoCaptureControllerID client_a_route_1(44); |
| 132 const VideoCaptureControllerID client_a_route_2(30); | 127 const VideoCaptureControllerID client_a_route_2(30); |
| 133 const VideoCaptureControllerID client_b_route_1(30); | 128 const VideoCaptureControllerID client_b_route_1(30); |
| 134 const VideoCaptureControllerID client_b_route_2(1); | 129 const VideoCaptureControllerID client_b_route_2(1); |
| 135 | 130 |
| 136 // Clients in controller: [] | 131 // Clients in controller: [] |
| 137 ASSERT_EQ(0, controller_->GetClientCount()) | 132 ASSERT_EQ(0, controller_->GetClientCount()) |
| 138 << "Client count should initially be zero."; | 133 << "Client count should initially be zero."; |
| 139 controller_->AddClient(client_a_route_1, client_a_.get(), | 134 controller_->AddClient(client_a_route_1, |
| 140 base::kNullProcessHandle, session_100); | 135 client_a_.get(), |
| 136 base::kNullProcessHandle, |
| 137 100, |
| 138 session_100); |
| 141 // Clients in controller: [A/1] | 139 // Clients in controller: [A/1] |
| 142 ASSERT_EQ(1, controller_->GetClientCount()) | 140 ASSERT_EQ(1, controller_->GetClientCount()) |
| 143 << "Adding client A/1 should bump client count.";; | 141 << "Adding client A/1 should bump client count.";; |
| 144 controller_->AddClient(client_a_route_2, client_a_.get(), | 142 controller_->AddClient(client_a_route_2, |
| 145 base::kNullProcessHandle, session_200); | 143 client_a_.get(), |
| 144 base::kNullProcessHandle, |
| 145 200, |
| 146 session_200); |
| 146 // Clients in controller: [A/1, A/2] | 147 // Clients in controller: [A/1, A/2] |
| 147 ASSERT_EQ(2, controller_->GetClientCount()) | 148 ASSERT_EQ(2, controller_->GetClientCount()) |
| 148 << "Adding client A/2 should bump client count."; | 149 << "Adding client A/2 should bump client count."; |
| 149 controller_->AddClient(client_b_route_1, client_b_.get(), | 150 controller_->AddClient(client_b_route_1, |
| 150 base::kNullProcessHandle, session_300); | 151 client_b_.get(), |
| 152 base::kNullProcessHandle, |
| 153 300, |
| 154 session_300); |
| 151 // Clients in controller: [A/1, A/2, B/1] | 155 // Clients in controller: [A/1, A/2, B/1] |
| 152 ASSERT_EQ(3, controller_->GetClientCount()) | 156 ASSERT_EQ(3, controller_->GetClientCount()) |
| 153 << "Adding client B/1 should bump client count."; | 157 << "Adding client B/1 should bump client count."; |
| 154 ASSERT_EQ(200, | 158 ASSERT_EQ(200, |
| 155 controller_->RemoveClient(client_a_route_2, client_a_.get())) | 159 controller_->RemoveClient(client_a_route_2, client_a_.get())) |
| 156 << "Removing client A/1 should return its session_id."; | 160 << "Removing client A/1 should return its session_id."; |
| 157 // Clients in controller: [A/1, B/1] | 161 // Clients in controller: [A/1, B/1] |
| 158 ASSERT_EQ(2, controller_->GetClientCount()); | 162 ASSERT_EQ(2, controller_->GetClientCount()); |
| 159 ASSERT_EQ(static_cast<int>(kInvalidMediaCaptureSessionId), | 163 ASSERT_EQ(static_cast<int>(kInvalidMediaCaptureSessionId), |
| 160 controller_->RemoveClient(client_a_route_2, client_a_.get())) | 164 controller_->RemoveClient(client_a_route_2, client_a_.get())) |
| 161 << "Removing a nonexistant client should fail."; | 165 << "Removing a nonexistant client should fail."; |
| 162 // Clients in controller: [A/1, B/1] | 166 // Clients in controller: [A/1, B/1] |
| 163 ASSERT_EQ(2, controller_->GetClientCount()); | 167 ASSERT_EQ(2, controller_->GetClientCount()); |
| 164 ASSERT_EQ(300, | 168 ASSERT_EQ(300, |
| 165 controller_->RemoveClient(client_b_route_1, client_b_.get())) | 169 controller_->RemoveClient(client_b_route_1, client_b_.get())) |
| 166 << "Removing client B/1 should return its session_id."; | 170 << "Removing client B/1 should return its session_id."; |
| 167 // Clients in controller: [A/1] | 171 // Clients in controller: [A/1] |
| 168 ASSERT_EQ(1, controller_->GetClientCount()); | 172 ASSERT_EQ(1, controller_->GetClientCount()); |
| 169 controller_->AddClient(client_b_route_2, client_b_.get(), | 173 controller_->AddClient(client_b_route_2, |
| 170 base::kNullProcessHandle, session_400); | 174 client_b_.get(), |
| 175 base::kNullProcessHandle, |
| 176 400, |
| 177 session_400); |
| 171 // Clients in controller: [A/1, B/2] | 178 // Clients in controller: [A/1, B/2] |
| 172 | 179 |
| 173 EXPECT_CALL(*client_a_, DoEnded(client_a_route_1)).Times(1); | 180 EXPECT_CALL(*client_a_, DoEnded(client_a_route_1)).Times(1); |
| 174 controller_->StopSession(100); // Session 100 == client A/1 | 181 controller_->StopSession(100); // Session 100 == client A/1 |
| 175 Mock::VerifyAndClearExpectations(client_a_.get()); | 182 Mock::VerifyAndClearExpectations(client_a_.get()); |
| 176 ASSERT_EQ(2, controller_->GetClientCount()) | 183 ASSERT_EQ(2, controller_->GetClientCount()) |
| 177 << "Client should be closed but still exist after StopSession."; | 184 << "Client should be closed but still exist after StopSession."; |
| 178 // Clients in controller: [A/1 (closed, removal pending), B/2] | 185 // Clients in controller: [A/1 (closed, removal pending), B/2] |
| 179 base::RunLoop().RunUntilIdle(); | 186 base::RunLoop().RunUntilIdle(); |
| 180 // Clients in controller: [B/2] | 187 // Clients in controller: [B/2] |
| (...skipping 19 matching lines...) Expand all Loading... |
| 200 // Clients in controller: [] | 207 // Clients in controller: [] |
| 201 ASSERT_EQ(0, controller_->GetClientCount()) | 208 ASSERT_EQ(0, controller_->GetClientCount()) |
| 202 << "Client count should return to zero after all clients are gone."; | 209 << "Client count should return to zero after all clients are gone."; |
| 203 } | 210 } |
| 204 | 211 |
| 205 // This test will connect and disconnect several clients while simulating an | 212 // This test will connect and disconnect several clients while simulating an |
| 206 // active capture device being started and generating frames. It runs on one | 213 // active capture device being started and generating frames. It runs on one |
| 207 // thread and is intended to behave deterministically. | 214 // thread and is intended to behave deterministically. |
| 208 TEST_F(VideoCaptureControllerTest, NormalCaptureMultipleClients) { | 215 TEST_F(VideoCaptureControllerTest, NormalCaptureMultipleClients) { |
| 209 media::VideoCaptureParams session_100; | 216 media::VideoCaptureParams session_100; |
| 210 session_100.session_id = 100; | |
| 211 session_100.requested_format = media::VideoCaptureFormat( | 217 session_100.requested_format = media::VideoCaptureFormat( |
| 212 320, 240, 30, media::ConstantResolutionVideoCaptureDevice); | 218 gfx::Size(320, 240), 30, media::PIXEL_FORMAT_I420); |
| 213 | 219 |
| 214 media::VideoCaptureParams session_200 = session_100; | 220 media::VideoCaptureParams session_200 = session_100; |
| 215 session_200.session_id = 200; | |
| 216 | 221 |
| 217 media::VideoCaptureParams session_300 = session_100; | 222 media::VideoCaptureParams session_300 = session_100; |
| 218 session_300.session_id = 300; | |
| 219 | 223 |
| 220 media::VideoCaptureParams session_1 = session_100; | 224 media::VideoCaptureParams session_1 = session_100; |
| 221 session_1.session_id = 1; | |
| 222 | 225 |
| 223 gfx::Size capture_resolution(444, 200); | 226 gfx::Size capture_resolution(444, 200); |
| 224 | 227 |
| 225 // The device format needn't match the VideoCaptureParams (the camera can do | 228 // The device format needn't match the VideoCaptureParams (the camera can do |
| 226 // what it wants). Pick something random. | 229 // what it wants). Pick something random. |
| 227 media::VideoCaptureCapability device_format( | 230 media::VideoCaptureFormat device_format( |
| 228 10, 10, 25, media::PIXEL_FORMAT_RGB24, | 231 gfx::Size(10, 10), 25, media::PIXEL_FORMAT_RGB24); |
| 229 media::ConstantResolutionVideoCaptureDevice); | |
| 230 | 232 |
| 231 const VideoCaptureControllerID client_a_route_1(0xa1a1a1a1); | 233 const VideoCaptureControllerID client_a_route_1(0xa1a1a1a1); |
| 232 const VideoCaptureControllerID client_a_route_2(0xa2a2a2a2); | 234 const VideoCaptureControllerID client_a_route_2(0xa2a2a2a2); |
| 233 const VideoCaptureControllerID client_b_route_1(0xb1b1b1b1); | 235 const VideoCaptureControllerID client_b_route_1(0xb1b1b1b1); |
| 234 const VideoCaptureControllerID client_b_route_2(0xb2b2b2b2); | 236 const VideoCaptureControllerID client_b_route_2(0xb2b2b2b2); |
| 235 | 237 |
| 236 // Start with two clients. | 238 // Start with two clients. |
| 237 controller_->AddClient(client_a_route_1, client_a_.get(), | 239 controller_->AddClient(client_a_route_1, |
| 238 base::kNullProcessHandle, session_100); | 240 client_a_.get(), |
| 239 controller_->AddClient(client_b_route_1, client_b_.get(), | 241 base::kNullProcessHandle, |
| 240 base::kNullProcessHandle, session_300); | 242 100, |
| 241 controller_->AddClient(client_a_route_2, client_a_.get(), | 243 session_100); |
| 242 base::kNullProcessHandle, session_200); | 244 controller_->AddClient(client_b_route_1, |
| 245 client_b_.get(), |
| 246 base::kNullProcessHandle, |
| 247 300, |
| 248 session_300); |
| 249 controller_->AddClient(client_a_route_2, |
| 250 client_a_.get(), |
| 251 base::kNullProcessHandle, |
| 252 200, |
| 253 session_200); |
| 243 ASSERT_EQ(3, controller_->GetClientCount()); | 254 ASSERT_EQ(3, controller_->GetClientCount()); |
| 244 | 255 |
| 245 // Now, simulate an incoming captured buffer from the capture device. As a | 256 // Now, simulate an incoming captured buffer from the capture device. As a |
| 246 // side effect this will cause the first buffer to be shared with clients. | 257 // side effect this will cause the first buffer to be shared with clients. |
| 247 uint8 buffer_no = 1; | 258 uint8 buffer_no = 1; |
| 248 scoped_refptr<media::VideoCaptureDevice::Client::Buffer> buffer; | 259 scoped_refptr<media::VideoCaptureDevice::Client::Buffer> buffer; |
| 249 buffer = | 260 buffer = |
| 250 device_->ReserveOutputBuffer(media::VideoFrame::I420, capture_resolution); | 261 device_->ReserveOutputBuffer(media::VideoFrame::I420, capture_resolution); |
| 251 ASSERT_TRUE(buffer); | 262 ASSERT_TRUE(buffer); |
| 252 memset(buffer->data(), buffer_no++, buffer->size()); | 263 memset(buffer->data(), buffer_no++, buffer->size()); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 | 303 |
| 293 // The buffer should be delivered to the clients in any order. | 304 // The buffer should be delivered to the clients in any order. |
| 294 EXPECT_CALL(*client_a_, DoBufferReady(client_a_route_1)).Times(1); | 305 EXPECT_CALL(*client_a_, DoBufferReady(client_a_route_1)).Times(1); |
| 295 EXPECT_CALL(*client_b_, DoBufferReady(client_b_route_1)).Times(1); | 306 EXPECT_CALL(*client_b_, DoBufferReady(client_b_route_1)).Times(1); |
| 296 EXPECT_CALL(*client_a_, DoBufferReady(client_a_route_2)).Times(1); | 307 EXPECT_CALL(*client_a_, DoBufferReady(client_a_route_2)).Times(1); |
| 297 base::RunLoop().RunUntilIdle(); | 308 base::RunLoop().RunUntilIdle(); |
| 298 Mock::VerifyAndClearExpectations(client_a_.get()); | 309 Mock::VerifyAndClearExpectations(client_a_.get()); |
| 299 Mock::VerifyAndClearExpectations(client_b_.get()); | 310 Mock::VerifyAndClearExpectations(client_b_.get()); |
| 300 | 311 |
| 301 // Add a fourth client now that some buffers have come through. | 312 // Add a fourth client now that some buffers have come through. |
| 302 controller_->AddClient(client_b_route_2, client_b_.get(), | 313 controller_->AddClient(client_b_route_2, |
| 303 base::kNullProcessHandle, session_1); | 314 client_b_.get(), |
| 315 base::kNullProcessHandle, |
| 316 1, |
| 317 session_1); |
| 304 Mock::VerifyAndClearExpectations(client_b_.get()); | 318 Mock::VerifyAndClearExpectations(client_b_.get()); |
| 305 | 319 |
| 306 // Third, fourth, and fifth buffers. Pretend they all arrive at the same time. | 320 // Third, fourth, and fifth buffers. Pretend they all arrive at the same time. |
| 307 for (int i = 0; i < kPoolSize; i++) { | 321 for (int i = 0; i < kPoolSize; i++) { |
| 308 buffer = device_->ReserveOutputBuffer(media::VideoFrame::I420, | 322 buffer = device_->ReserveOutputBuffer(media::VideoFrame::I420, |
| 309 capture_resolution); | 323 capture_resolution); |
| 310 ASSERT_TRUE(buffer); | 324 ASSERT_TRUE(buffer); |
| 311 memset(buffer->data(), buffer_no++, buffer->size()); | 325 memset(buffer->data(), buffer_no++, buffer->size()); |
| 312 device_->OnIncomingCapturedBuffer(buffer, | 326 device_->OnIncomingCapturedBuffer(buffer, |
| 313 media::VideoFrame::I420, | 327 media::VideoFrame::I420, |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 EXPECT_CALL(*client_b_, DoBufferReady(client_b_route_2)).Times(2); | 388 EXPECT_CALL(*client_b_, DoBufferReady(client_b_route_2)).Times(2); |
| 375 base::RunLoop().RunUntilIdle(); | 389 base::RunLoop().RunUntilIdle(); |
| 376 Mock::VerifyAndClearExpectations(client_a_.get()); | 390 Mock::VerifyAndClearExpectations(client_a_.get()); |
| 377 Mock::VerifyAndClearExpectations(client_b_.get()); | 391 Mock::VerifyAndClearExpectations(client_b_.get()); |
| 378 } | 392 } |
| 379 | 393 |
| 380 // Exercises the OnError() codepath of VideoCaptureController, and tests the | 394 // Exercises the OnError() codepath of VideoCaptureController, and tests the |
| 381 // behavior of various operations after the error state has been signalled. | 395 // behavior of various operations after the error state has been signalled. |
| 382 TEST_F(VideoCaptureControllerTest, ErrorBeforeDeviceCreation) { | 396 TEST_F(VideoCaptureControllerTest, ErrorBeforeDeviceCreation) { |
| 383 media::VideoCaptureParams session_100; | 397 media::VideoCaptureParams session_100; |
| 384 session_100.session_id = 100; | |
| 385 session_100.requested_format = media::VideoCaptureFormat( | 398 session_100.requested_format = media::VideoCaptureFormat( |
| 386 320, 240, 30, media::ConstantResolutionVideoCaptureDevice); | 399 gfx::Size(320, 240), 30, media::PIXEL_FORMAT_I420); |
| 387 | 400 |
| 388 media::VideoCaptureParams session_200 = session_100; | 401 media::VideoCaptureParams session_200 = session_100; |
| 389 session_200.session_id = 200; | |
| 390 | 402 |
| 391 const gfx::Size capture_resolution(320, 240); | 403 const gfx::Size capture_resolution(320, 240); |
| 392 | 404 |
| 393 const VideoCaptureControllerID route_id(0x99); | 405 const VideoCaptureControllerID route_id(0x99); |
| 394 | 406 |
| 395 // Start with one client. | 407 // Start with one client. |
| 396 controller_->AddClient(route_id, client_a_.get(), | 408 controller_->AddClient( |
| 397 base::kNullProcessHandle, session_100); | 409 route_id, client_a_.get(), base::kNullProcessHandle, 100, session_100); |
| 398 device_->OnError(); | 410 device_->OnError(); |
| 399 EXPECT_CALL(*client_a_, DoError(route_id)).Times(1); | 411 EXPECT_CALL(*client_a_, DoError(route_id)).Times(1); |
| 400 base::RunLoop().RunUntilIdle(); | 412 base::RunLoop().RunUntilIdle(); |
| 401 Mock::VerifyAndClearExpectations(client_a_.get()); | 413 Mock::VerifyAndClearExpectations(client_a_.get()); |
| 402 | 414 |
| 403 // Second client connects after the error state. It also should get told of | 415 // Second client connects after the error state. It also should get told of |
| 404 // the error. | 416 // the error. |
| 405 EXPECT_CALL(*client_b_, DoError(route_id)).Times(1); | 417 EXPECT_CALL(*client_b_, DoError(route_id)).Times(1); |
| 406 controller_->AddClient(route_id, client_b_.get(), | 418 controller_->AddClient( |
| 407 base::kNullProcessHandle, session_200); | 419 route_id, client_b_.get(), base::kNullProcessHandle, 200, session_200); |
| 408 base::RunLoop().RunUntilIdle(); | 420 base::RunLoop().RunUntilIdle(); |
| 409 Mock::VerifyAndClearExpectations(client_b_.get()); | 421 Mock::VerifyAndClearExpectations(client_b_.get()); |
| 410 | 422 |
| 411 scoped_refptr<media::VideoCaptureDevice::Client::Buffer> buffer = | 423 scoped_refptr<media::VideoCaptureDevice::Client::Buffer> buffer = |
| 412 device_->ReserveOutputBuffer(media::VideoFrame::I420, capture_resolution); | 424 device_->ReserveOutputBuffer(media::VideoFrame::I420, capture_resolution); |
| 413 ASSERT_TRUE(buffer); | 425 ASSERT_TRUE(buffer); |
| 414 | 426 |
| 415 device_->OnIncomingCapturedBuffer( | 427 device_->OnIncomingCapturedBuffer( |
| 416 buffer, media::VideoFrame::I420, capture_resolution, base::Time(), 30); | 428 buffer, media::VideoFrame::I420, capture_resolution, base::Time(), 30); |
| 417 buffer = NULL; | 429 buffer = NULL; |
| 418 | 430 |
| 419 base::RunLoop().RunUntilIdle(); | 431 base::RunLoop().RunUntilIdle(); |
| 420 } | 432 } |
| 421 | 433 |
| 422 // Exercises the OnError() codepath of VideoCaptureController, and tests the | 434 // Exercises the OnError() codepath of VideoCaptureController, and tests the |
| 423 // behavior of various operations after the error state has been signalled. | 435 // behavior of various operations after the error state has been signalled. |
| 424 TEST_F(VideoCaptureControllerTest, ErrorAfterDeviceCreation) { | 436 TEST_F(VideoCaptureControllerTest, ErrorAfterDeviceCreation) { |
| 425 media::VideoCaptureParams session_100; | 437 media::VideoCaptureParams session_100; |
| 426 session_100.session_id = 100; | |
| 427 session_100.requested_format = media::VideoCaptureFormat( | 438 session_100.requested_format = media::VideoCaptureFormat( |
| 428 320, 240, 30, media::ConstantResolutionVideoCaptureDevice); | 439 gfx::Size(320, 240), 30, media::PIXEL_FORMAT_I420); |
| 429 | 440 |
| 430 media::VideoCaptureParams session_200 = session_100; | 441 media::VideoCaptureParams session_200 = session_100; |
| 431 session_200.session_id = 200; | |
| 432 | 442 |
| 433 const VideoCaptureControllerID route_id(0x99); | 443 const VideoCaptureControllerID route_id(0x99); |
| 434 | 444 |
| 435 // Start with one client. | 445 // Start with one client. |
| 436 controller_->AddClient(route_id, client_a_.get(), | 446 controller_->AddClient( |
| 437 base::kNullProcessHandle, session_100); | 447 route_id, client_a_.get(), base::kNullProcessHandle, 100, session_100); |
| 438 // OnFrameInfo from the VCD should become a no-op after the error occurs. | 448 media::VideoCaptureFormat device_format( |
| 439 media::VideoCaptureCapability device_format( | 449 gfx::Size(10, 10), 25, media::PIXEL_FORMAT_ARGB); |
| 440 10, 10, 25, media::PIXEL_FORMAT_ARGB, | |
| 441 media::ConstantResolutionVideoCaptureDevice); | |
| 442 | 450 |
| 443 // Start the device. Then, before the first buffer, signal an error and | 451 // Start the device. Then, before the first buffer, signal an error and |
| 444 // deliver the buffer. The error should be propagated to clients; the buffer | 452 // deliver the buffer. The error should be propagated to clients; the buffer |
| 445 // should not be. | 453 // should not be. |
| 446 base::RunLoop().RunUntilIdle(); | 454 base::RunLoop().RunUntilIdle(); |
| 447 Mock::VerifyAndClearExpectations(client_a_.get()); | 455 Mock::VerifyAndClearExpectations(client_a_.get()); |
| 448 | 456 |
| 449 const gfx::Size dims(320, 240); | 457 const gfx::Size dims(320, 240); |
| 450 scoped_refptr<media::VideoCaptureDevice::Client::Buffer> buffer = | 458 scoped_refptr<media::VideoCaptureDevice::Client::Buffer> buffer = |
| 451 device_->ReserveOutputBuffer(media::VideoFrame::I420, dims); | 459 device_->ReserveOutputBuffer(media::VideoFrame::I420, dims); |
| 452 ASSERT_TRUE(buffer); | 460 ASSERT_TRUE(buffer); |
| 453 | 461 |
| 454 device_->OnError(); | 462 device_->OnError(); |
| 455 device_->OnIncomingCapturedBuffer(buffer, | 463 device_->OnIncomingCapturedBuffer(buffer, |
| 456 media::VideoFrame::I420, | 464 media::VideoFrame::I420, |
| 457 dims, | 465 dims, |
| 458 base::Time(), | 466 base::Time(), |
| 459 device_format.frame_rate); | 467 device_format.frame_rate); |
| 460 buffer = NULL; | 468 buffer = NULL; |
| 461 | 469 |
| 462 EXPECT_CALL(*client_a_, DoError(route_id)).Times(1); | 470 EXPECT_CALL(*client_a_, DoError(route_id)).Times(1); |
| 463 base::RunLoop().RunUntilIdle(); | 471 base::RunLoop().RunUntilIdle(); |
| 464 Mock::VerifyAndClearExpectations(client_a_.get()); | 472 Mock::VerifyAndClearExpectations(client_a_.get()); |
| 465 | 473 |
| 466 // Second client connects after the error state. It also should get told of | 474 // Second client connects after the error state. It also should get told of |
| 467 // the error. | 475 // the error. |
| 468 EXPECT_CALL(*client_b_, DoError(route_id)).Times(1); | 476 EXPECT_CALL(*client_b_, DoError(route_id)).Times(1); |
| 469 controller_->AddClient(route_id, client_b_.get(), | 477 controller_->AddClient( |
| 470 base::kNullProcessHandle, session_200); | 478 route_id, client_b_.get(), base::kNullProcessHandle, 200, session_200); |
| 471 Mock::VerifyAndClearExpectations(client_b_.get()); | 479 Mock::VerifyAndClearExpectations(client_b_.get()); |
| 472 } | 480 } |
| 473 | 481 |
| 474 } // namespace content | 482 } // namespace content |
| OLD | NEW |