| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 kMaxWaitMs); | 150 kMaxWaitMs); |
| 151 | 151 |
| 152 ASSERT_TRUE(capturer_->CaptureFrame()); | 152 ASSERT_TRUE(capturer_->CaptureFrame()); |
| 153 EXPECT_EQ(1, renderer_.num_rendered_frames()); | 153 EXPECT_EQ(1, renderer_.num_rendered_frames()); |
| 154 | 154 |
| 155 capturer_->Stop(); | 155 capturer_->Stop(); |
| 156 EXPECT_EQ_WAIT(MediaSourceInterface::kEnded, state_observer_->state(), | 156 EXPECT_EQ_WAIT(MediaSourceInterface::kEnded, state_observer_->state(), |
| 157 kMaxWaitMs); | 157 kMaxWaitMs); |
| 158 } | 158 } |
| 159 | 159 |
| 160 // Test that a VideoSource can be stopped and restarted. | |
| 161 TEST_F(VideoCapturerTrackSourceTest, StopRestart) { | |
| 162 // Initialize without constraints. | |
| 163 CreateVideoCapturerSource(); | |
| 164 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(), | |
| 165 kMaxWaitMs); | |
| 166 | |
| 167 ASSERT_TRUE(capturer_->CaptureFrame()); | |
| 168 EXPECT_EQ(1, renderer_.num_rendered_frames()); | |
| 169 | |
| 170 source_->Stop(); | |
| 171 EXPECT_EQ_WAIT(MediaSourceInterface::kEnded, state_observer_->state(), | |
| 172 kMaxWaitMs); | |
| 173 | |
| 174 source_->Restart(); | |
| 175 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(), | |
| 176 kMaxWaitMs); | |
| 177 | |
| 178 ASSERT_TRUE(capturer_->CaptureFrame()); | |
| 179 EXPECT_EQ(2, renderer_.num_rendered_frames()); | |
| 180 | |
| 181 source_->Stop(); | |
| 182 } | |
| 183 | |
| 184 // Test that a VideoSource transition to kEnded if the capture device | 160 // Test that a VideoSource transition to kEnded if the capture device |
| 185 // fails. | 161 // fails. |
| 186 TEST_F(VideoCapturerTrackSourceTest, CameraFailed) { | 162 TEST_F(VideoCapturerTrackSourceTest, CameraFailed) { |
| 187 CreateVideoCapturerSource(); | 163 CreateVideoCapturerSource(); |
| 188 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(), | 164 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(), |
| 189 kMaxWaitMs); | 165 kMaxWaitMs); |
| 190 | 166 |
| 191 capturer_->SignalStateChange(capturer_, cricket::CS_FAILED); | 167 capturer_->SignalStateChange(capturer_, cricket::CS_FAILED); |
| 192 EXPECT_EQ_WAIT(MediaSourceInterface::kEnded, state_observer_->state(), | 168 EXPECT_EQ_WAIT(MediaSourceInterface::kEnded, state_observer_->state(), |
| 193 kMaxWaitMs); | 169 kMaxWaitMs); |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 FakeConstraints constraints; | 458 FakeConstraints constraints; |
| 483 constraints.AddOptional(MediaConstraintsInterface::kMaxFrameRate, 0.5); | 459 constraints.AddOptional(MediaConstraintsInterface::kMaxFrameRate, 0.5); |
| 484 | 460 |
| 485 CreateVideoCapturerSource(&constraints); | 461 CreateVideoCapturerSource(&constraints); |
| 486 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(), | 462 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(), |
| 487 kMaxWaitMs); | 463 kMaxWaitMs); |
| 488 const cricket::VideoFormat* format = capturer_->GetCaptureFormat(); | 464 const cricket::VideoFormat* format = capturer_->GetCaptureFormat(); |
| 489 ASSERT_TRUE(format != NULL); | 465 ASSERT_TRUE(format != NULL); |
| 490 EXPECT_EQ(30, format->framerate()); | 466 EXPECT_EQ(30, format->framerate()); |
| 491 } | 467 } |
| OLD | NEW |