| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 VideoCaptureManager | 5 // Unit test for VideoCaptureManager |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 | 202 |
| 203 vcm_->EnumerateDevices(); | 203 vcm_->EnumerateDevices(); |
| 204 | 204 |
| 205 // Wait to get device callback... | 205 // Wait to get device callback... |
| 206 SyncWithVideoCaptureManagerThread(); | 206 SyncWithVideoCaptureManagerThread(); |
| 207 | 207 |
| 208 media_stream::StreamDeviceInfoArray::iterator it = | 208 media_stream::StreamDeviceInfoArray::iterator it = |
| 209 listener_->devices_.begin(); | 209 listener_->devices_.begin(); |
| 210 | 210 |
| 211 int video_session_id_first = vcm_->Open(*it); | 211 int video_session_id_first = vcm_->Open(*it); |
| 212 | |
| 213 // This should trigger an error callback with error code 'kDeviceAlreadyInUse' | |
| 214 ++it; | 212 ++it; |
| 215 int video_session_id_second = vcm_->Open(*it); | 213 int video_session_id_second = vcm_->Open(*it); |
| 216 | 214 |
| 217 vcm_->Close(video_session_id_first); | 215 vcm_->Close(video_session_id_first); |
| 218 vcm_->Close(video_session_id_second); | 216 vcm_->Close(video_session_id_second); |
| 219 | 217 |
| 220 // Wait to check callbacks before removing the listener | 218 // Wait to check callbacks before removing the listener |
| 221 SyncWithVideoCaptureManagerThread(); | 219 SyncWithVideoCaptureManagerThread(); |
| 222 vcm_->Unregister(); | 220 vcm_->Unregister(); |
| 223 } | 221 } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 vcm_->Start(capture_params, frame_observer_.get()); | 266 vcm_->Start(capture_params, frame_observer_.get()); |
| 269 | 267 |
| 270 // Stop shall trigger the Close callback | 268 // Stop shall trigger the Close callback |
| 271 vcm_->Stop(media_stream::VideoCaptureManager::kStartOpenSessionId, NULL); | 269 vcm_->Stop(media_stream::VideoCaptureManager::kStartOpenSessionId, NULL); |
| 272 | 270 |
| 273 // Wait to check callbacks before removing the listener | 271 // Wait to check callbacks before removing the listener |
| 274 SyncWithVideoCaptureManagerThread(); | 272 SyncWithVideoCaptureManagerThread(); |
| 275 vcm_->Unregister(); | 273 vcm_->Unregister(); |
| 276 } | 274 } |
| 277 | 275 |
| 276 // TODO(mflodman) Remove test case below when shut-down bug is resolved, this is |
| 277 // only to verify this temporary solution is ok in regards to the |
| 278 // VideoCaptureManager. |
| 279 // Open the devices and delete manager. |
| 280 TEST_F(VideoCaptureManagerTest, DeleteManager) { |
| 281 InSequence s; |
| 282 EXPECT_CALL(*listener_, DevicesEnumerated(_)) |
| 283 .Times(1); |
| 284 EXPECT_CALL(*listener_, Opened(media_stream::kVideoCapture, _)) |
| 285 .Times(2); |
| 286 |
| 287 vcm_->EnumerateDevices(); |
| 288 |
| 289 // Wait to get device callback... |
| 290 SyncWithVideoCaptureManagerThread(); |
| 291 |
| 292 media_stream::StreamDeviceInfoArray::iterator it = |
| 293 listener_->devices_.begin(); |
| 294 vcm_->Open(*it); |
| 295 ++it; |
| 296 vcm_->Open(*it); |
| 297 |
| 298 // Wait to check callbacks before removing the listener |
| 299 SyncWithVideoCaptureManagerThread(); |
| 300 |
| 301 // Delete the manager. |
| 302 vcm_.reset(); |
| 303 } |
| 304 |
| 278 } // namespace | 305 } // namespace |
| OLD | NEW |