| OLD | NEW |
| 1 /* | 1 /* |
| 2 * libjingle | 2 * libjingle |
| 3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
| 9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(), | 385 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(), |
| 386 kMaxWaitMs); | 386 kMaxWaitMs); |
| 387 } | 387 } |
| 388 | 388 |
| 389 TEST_F(VideoSourceTest, SetValidOptionValues) { | 389 TEST_F(VideoSourceTest, SetValidOptionValues) { |
| 390 FakeConstraints constraints; | 390 FakeConstraints constraints; |
| 391 constraints.AddMandatory(MediaConstraintsInterface::kNoiseReduction, "false"); | 391 constraints.AddMandatory(MediaConstraintsInterface::kNoiseReduction, "false"); |
| 392 | 392 |
| 393 CreateVideoSource(&constraints); | 393 CreateVideoSource(&constraints); |
| 394 | 394 |
| 395 EXPECT_EQ(rtc::Maybe<bool>(false), source_->options()->video_noise_reduction); | 395 EXPECT_EQ(rtc::Optional<bool>(false), |
| 396 source_->options()->video_noise_reduction); |
| 396 } | 397 } |
| 397 | 398 |
| 398 TEST_F(VideoSourceTest, OptionNotSet) { | 399 TEST_F(VideoSourceTest, OptionNotSet) { |
| 399 FakeConstraints constraints; | 400 FakeConstraints constraints; |
| 400 CreateVideoSource(&constraints); | 401 CreateVideoSource(&constraints); |
| 401 EXPECT_EQ(rtc::Maybe<bool>(), source_->options()->video_noise_reduction); | 402 EXPECT_EQ(rtc::Optional<bool>(), source_->options()->video_noise_reduction); |
| 402 } | 403 } |
| 403 | 404 |
| 404 TEST_F(VideoSourceTest, MandatoryOptionOverridesOptional) { | 405 TEST_F(VideoSourceTest, MandatoryOptionOverridesOptional) { |
| 405 FakeConstraints constraints; | 406 FakeConstraints constraints; |
| 406 constraints.AddMandatory( | 407 constraints.AddMandatory( |
| 407 MediaConstraintsInterface::kNoiseReduction, true); | 408 MediaConstraintsInterface::kNoiseReduction, true); |
| 408 constraints.AddOptional( | 409 constraints.AddOptional( |
| 409 MediaConstraintsInterface::kNoiseReduction, false); | 410 MediaConstraintsInterface::kNoiseReduction, false); |
| 410 | 411 |
| 411 CreateVideoSource(&constraints); | 412 CreateVideoSource(&constraints); |
| 412 | 413 |
| 413 EXPECT_EQ(rtc::Maybe<bool>(true), source_->options()->video_noise_reduction); | 414 EXPECT_EQ(rtc::Optional<bool>(true), |
| 415 source_->options()->video_noise_reduction); |
| 414 } | 416 } |
| 415 | 417 |
| 416 TEST_F(VideoSourceTest, InvalidOptionKeyOptional) { | 418 TEST_F(VideoSourceTest, InvalidOptionKeyOptional) { |
| 417 FakeConstraints constraints; | 419 FakeConstraints constraints; |
| 418 constraints.AddOptional( | 420 constraints.AddOptional( |
| 419 MediaConstraintsInterface::kNoiseReduction, false); | 421 MediaConstraintsInterface::kNoiseReduction, false); |
| 420 constraints.AddOptional("invalidKey", false); | 422 constraints.AddOptional("invalidKey", false); |
| 421 | 423 |
| 422 CreateVideoSource(&constraints); | 424 CreateVideoSource(&constraints); |
| 423 | 425 |
| 424 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(), | 426 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(), |
| 425 kMaxWaitMs); | 427 kMaxWaitMs); |
| 426 EXPECT_EQ(rtc::Maybe<bool>(false), source_->options()->video_noise_reduction); | 428 EXPECT_EQ(rtc::Optional<bool>(false), |
| 429 source_->options()->video_noise_reduction); |
| 427 } | 430 } |
| 428 | 431 |
| 429 TEST_F(VideoSourceTest, InvalidOptionKeyMandatory) { | 432 TEST_F(VideoSourceTest, InvalidOptionKeyMandatory) { |
| 430 FakeConstraints constraints; | 433 FakeConstraints constraints; |
| 431 constraints.AddMandatory( | 434 constraints.AddMandatory( |
| 432 MediaConstraintsInterface::kNoiseReduction, false); | 435 MediaConstraintsInterface::kNoiseReduction, false); |
| 433 constraints.AddMandatory("invalidKey", false); | 436 constraints.AddMandatory("invalidKey", false); |
| 434 | 437 |
| 435 CreateVideoSource(&constraints); | 438 CreateVideoSource(&constraints); |
| 436 | 439 |
| 437 EXPECT_EQ_WAIT(MediaSourceInterface::kEnded, state_observer_->state(), | 440 EXPECT_EQ_WAIT(MediaSourceInterface::kEnded, state_observer_->state(), |
| 438 kMaxWaitMs); | 441 kMaxWaitMs); |
| 439 EXPECT_EQ(rtc::Maybe<bool>(), source_->options()->video_noise_reduction); | 442 EXPECT_EQ(rtc::Optional<bool>(), source_->options()->video_noise_reduction); |
| 440 } | 443 } |
| 441 | 444 |
| 442 TEST_F(VideoSourceTest, InvalidOptionValueOptional) { | 445 TEST_F(VideoSourceTest, InvalidOptionValueOptional) { |
| 443 FakeConstraints constraints; | 446 FakeConstraints constraints; |
| 444 constraints.AddOptional( | 447 constraints.AddOptional( |
| 445 MediaConstraintsInterface::kNoiseReduction, "not a boolean"); | 448 MediaConstraintsInterface::kNoiseReduction, "not a boolean"); |
| 446 | 449 |
| 447 CreateVideoSource(&constraints); | 450 CreateVideoSource(&constraints); |
| 448 | 451 |
| 449 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(), | 452 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(), |
| 450 kMaxWaitMs); | 453 kMaxWaitMs); |
| 451 EXPECT_EQ(rtc::Maybe<bool>(), source_->options()->video_noise_reduction); | 454 EXPECT_EQ(rtc::Optional<bool>(), source_->options()->video_noise_reduction); |
| 452 } | 455 } |
| 453 | 456 |
| 454 TEST_F(VideoSourceTest, InvalidOptionValueMandatory) { | 457 TEST_F(VideoSourceTest, InvalidOptionValueMandatory) { |
| 455 FakeConstraints constraints; | 458 FakeConstraints constraints; |
| 456 // Optional constraints should be ignored if the mandatory constraints fail. | 459 // Optional constraints should be ignored if the mandatory constraints fail. |
| 457 constraints.AddOptional( | 460 constraints.AddOptional( |
| 458 MediaConstraintsInterface::kNoiseReduction, "false"); | 461 MediaConstraintsInterface::kNoiseReduction, "false"); |
| 459 // Values are case-sensitive and must be all lower-case. | 462 // Values are case-sensitive and must be all lower-case. |
| 460 constraints.AddMandatory( | 463 constraints.AddMandatory( |
| 461 MediaConstraintsInterface::kNoiseReduction, "True"); | 464 MediaConstraintsInterface::kNoiseReduction, "True"); |
| 462 | 465 |
| 463 CreateVideoSource(&constraints); | 466 CreateVideoSource(&constraints); |
| 464 | 467 |
| 465 EXPECT_EQ_WAIT(MediaSourceInterface::kEnded, state_observer_->state(), | 468 EXPECT_EQ_WAIT(MediaSourceInterface::kEnded, state_observer_->state(), |
| 466 kMaxWaitMs); | 469 kMaxWaitMs); |
| 467 EXPECT_EQ(rtc::Maybe<bool>(), source_->options()->video_noise_reduction); | 470 EXPECT_EQ(rtc::Optional<bool>(), source_->options()->video_noise_reduction); |
| 468 } | 471 } |
| 469 | 472 |
| 470 TEST_F(VideoSourceTest, MixedOptionsAndConstraints) { | 473 TEST_F(VideoSourceTest, MixedOptionsAndConstraints) { |
| 471 FakeConstraints constraints; | 474 FakeConstraints constraints; |
| 472 constraints.AddMandatory(MediaConstraintsInterface::kMaxWidth, 352); | 475 constraints.AddMandatory(MediaConstraintsInterface::kMaxWidth, 352); |
| 473 constraints.AddMandatory(MediaConstraintsInterface::kMaxHeight, 288); | 476 constraints.AddMandatory(MediaConstraintsInterface::kMaxHeight, 288); |
| 474 constraints.AddOptional(MediaConstraintsInterface::kMaxFrameRate, 5); | 477 constraints.AddOptional(MediaConstraintsInterface::kMaxFrameRate, 5); |
| 475 | 478 |
| 476 constraints.AddMandatory( | 479 constraints.AddMandatory( |
| 477 MediaConstraintsInterface::kNoiseReduction, false); | 480 MediaConstraintsInterface::kNoiseReduction, false); |
| 478 constraints.AddOptional( | 481 constraints.AddOptional( |
| 479 MediaConstraintsInterface::kNoiseReduction, true); | 482 MediaConstraintsInterface::kNoiseReduction, true); |
| 480 | 483 |
| 481 CreateVideoSource(&constraints); | 484 CreateVideoSource(&constraints); |
| 482 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(), | 485 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(), |
| 483 kMaxWaitMs); | 486 kMaxWaitMs); |
| 484 const cricket::VideoFormat* format = capturer_->GetCaptureFormat(); | 487 const cricket::VideoFormat* format = capturer_->GetCaptureFormat(); |
| 485 ASSERT_TRUE(format != NULL); | 488 ASSERT_TRUE(format != NULL); |
| 486 EXPECT_EQ(352, format->width); | 489 EXPECT_EQ(352, format->width); |
| 487 EXPECT_EQ(288, format->height); | 490 EXPECT_EQ(288, format->height); |
| 488 EXPECT_EQ(30, format->framerate()); | 491 EXPECT_EQ(30, format->framerate()); |
| 489 | 492 |
| 490 EXPECT_EQ(rtc::Maybe<bool>(false), source_->options()->video_noise_reduction); | 493 EXPECT_EQ(rtc::Optional<bool>(false), |
| 494 source_->options()->video_noise_reduction); |
| 491 } | 495 } |
| 492 | 496 |
| 493 // Tests that the source starts video with the default resolution for | 497 // Tests that the source starts video with the default resolution for |
| 494 // screencast if no constraint is set. | 498 // screencast if no constraint is set. |
| 495 TEST_F(VideoSourceTest, ScreencastResolutionNoConstraint) { | 499 TEST_F(VideoSourceTest, ScreencastResolutionNoConstraint) { |
| 496 capturer_->TestWithoutCameraFormats(); | 500 capturer_->TestWithoutCameraFormats(); |
| 497 capturer_->SetScreencast(true); | 501 capturer_->SetScreencast(true); |
| 498 | 502 |
| 499 CreateVideoSource(); | 503 CreateVideoSource(); |
| 500 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(), | 504 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(), |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 constraints.AddOptional(MediaConstraintsInterface::kMaxFrameRate, 0.5); | 545 constraints.AddOptional(MediaConstraintsInterface::kMaxFrameRate, 0.5); |
| 542 | 546 |
| 543 CreateVideoSource(&constraints); | 547 CreateVideoSource(&constraints); |
| 544 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(), | 548 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(), |
| 545 kMaxWaitMs); | 549 kMaxWaitMs); |
| 546 const cricket::VideoFormat* format = capturer_->GetCaptureFormat(); | 550 const cricket::VideoFormat* format = capturer_->GetCaptureFormat(); |
| 547 ASSERT_TRUE(format != NULL); | 551 ASSERT_TRUE(format != NULL); |
| 548 EXPECT_EQ(30, format->framerate()); | 552 EXPECT_EQ(30, format->framerate()); |
| 549 } | 553 } |
| 550 | 554 |
| OLD | NEW |