| 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 bool value = true; | 395 EXPECT_EQ(rtc::Maybe<bool>(false), source_->options()->video_noise_reduction); |
| 396 EXPECT_TRUE(source_->options()->video_noise_reduction.Get(&value)); | |
| 397 EXPECT_FALSE(value); | |
| 398 } | 396 } |
| 399 | 397 |
| 400 TEST_F(VideoSourceTest, OptionNotSet) { | 398 TEST_F(VideoSourceTest, OptionNotSet) { |
| 401 FakeConstraints constraints; | 399 FakeConstraints constraints; |
| 402 CreateVideoSource(&constraints); | 400 CreateVideoSource(&constraints); |
| 403 bool value; | 401 EXPECT_EQ(rtc::Maybe<bool>(), source_->options()->video_noise_reduction); |
| 404 EXPECT_FALSE(source_->options()->video_noise_reduction.Get(&value)); | |
| 405 } | 402 } |
| 406 | 403 |
| 407 TEST_F(VideoSourceTest, MandatoryOptionOverridesOptional) { | 404 TEST_F(VideoSourceTest, MandatoryOptionOverridesOptional) { |
| 408 FakeConstraints constraints; | 405 FakeConstraints constraints; |
| 409 constraints.AddMandatory( | 406 constraints.AddMandatory( |
| 410 MediaConstraintsInterface::kNoiseReduction, true); | 407 MediaConstraintsInterface::kNoiseReduction, true); |
| 411 constraints.AddOptional( | 408 constraints.AddOptional( |
| 412 MediaConstraintsInterface::kNoiseReduction, false); | 409 MediaConstraintsInterface::kNoiseReduction, false); |
| 413 | 410 |
| 414 CreateVideoSource(&constraints); | 411 CreateVideoSource(&constraints); |
| 415 | 412 |
| 416 bool value = false; | 413 EXPECT_EQ(rtc::Maybe<bool>(true), source_->options()->video_noise_reduction); |
| 417 EXPECT_TRUE(source_->options()->video_noise_reduction.Get(&value)); | |
| 418 EXPECT_TRUE(value); | |
| 419 } | 414 } |
| 420 | 415 |
| 421 TEST_F(VideoSourceTest, InvalidOptionKeyOptional) { | 416 TEST_F(VideoSourceTest, InvalidOptionKeyOptional) { |
| 422 FakeConstraints constraints; | 417 FakeConstraints constraints; |
| 423 constraints.AddOptional( | 418 constraints.AddOptional( |
| 424 MediaConstraintsInterface::kNoiseReduction, false); | 419 MediaConstraintsInterface::kNoiseReduction, false); |
| 425 constraints.AddOptional("invalidKey", false); | 420 constraints.AddOptional("invalidKey", false); |
| 426 | 421 |
| 427 CreateVideoSource(&constraints); | 422 CreateVideoSource(&constraints); |
| 428 | 423 |
| 429 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(), | 424 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(), |
| 430 kMaxWaitMs); | 425 kMaxWaitMs); |
| 431 bool value = true; | 426 EXPECT_EQ(rtc::Maybe<bool>(false), source_->options()->video_noise_reduction); |
| 432 EXPECT_TRUE(source_->options()->video_noise_reduction.Get(&value)); | |
| 433 EXPECT_FALSE(value); | |
| 434 } | 427 } |
| 435 | 428 |
| 436 TEST_F(VideoSourceTest, InvalidOptionKeyMandatory) { | 429 TEST_F(VideoSourceTest, InvalidOptionKeyMandatory) { |
| 437 FakeConstraints constraints; | 430 FakeConstraints constraints; |
| 438 constraints.AddMandatory( | 431 constraints.AddMandatory( |
| 439 MediaConstraintsInterface::kNoiseReduction, false); | 432 MediaConstraintsInterface::kNoiseReduction, false); |
| 440 constraints.AddMandatory("invalidKey", false); | 433 constraints.AddMandatory("invalidKey", false); |
| 441 | 434 |
| 442 CreateVideoSource(&constraints); | 435 CreateVideoSource(&constraints); |
| 443 | 436 |
| 444 EXPECT_EQ_WAIT(MediaSourceInterface::kEnded, state_observer_->state(), | 437 EXPECT_EQ_WAIT(MediaSourceInterface::kEnded, state_observer_->state(), |
| 445 kMaxWaitMs); | 438 kMaxWaitMs); |
| 446 bool value; | 439 EXPECT_EQ(rtc::Maybe<bool>(), source_->options()->video_noise_reduction); |
| 447 EXPECT_FALSE(source_->options()->video_noise_reduction.Get(&value)); | |
| 448 } | 440 } |
| 449 | 441 |
| 450 TEST_F(VideoSourceTest, InvalidOptionValueOptional) { | 442 TEST_F(VideoSourceTest, InvalidOptionValueOptional) { |
| 451 FakeConstraints constraints; | 443 FakeConstraints constraints; |
| 452 constraints.AddOptional( | 444 constraints.AddOptional( |
| 453 MediaConstraintsInterface::kNoiseReduction, "not a boolean"); | 445 MediaConstraintsInterface::kNoiseReduction, "not a boolean"); |
| 454 | 446 |
| 455 CreateVideoSource(&constraints); | 447 CreateVideoSource(&constraints); |
| 456 | 448 |
| 457 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(), | 449 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(), |
| 458 kMaxWaitMs); | 450 kMaxWaitMs); |
| 459 bool value = false; | 451 EXPECT_EQ(rtc::Maybe<bool>(), source_->options()->video_noise_reduction); |
| 460 EXPECT_FALSE(source_->options()->video_noise_reduction.Get(&value)); | |
| 461 } | 452 } |
| 462 | 453 |
| 463 TEST_F(VideoSourceTest, InvalidOptionValueMandatory) { | 454 TEST_F(VideoSourceTest, InvalidOptionValueMandatory) { |
| 464 FakeConstraints constraints; | 455 FakeConstraints constraints; |
| 465 // Optional constraints should be ignored if the mandatory constraints fail. | 456 // Optional constraints should be ignored if the mandatory constraints fail. |
| 466 constraints.AddOptional( | 457 constraints.AddOptional( |
| 467 MediaConstraintsInterface::kNoiseReduction, "false"); | 458 MediaConstraintsInterface::kNoiseReduction, "false"); |
| 468 // Values are case-sensitive and must be all lower-case. | 459 // Values are case-sensitive and must be all lower-case. |
| 469 constraints.AddMandatory( | 460 constraints.AddMandatory( |
| 470 MediaConstraintsInterface::kNoiseReduction, "True"); | 461 MediaConstraintsInterface::kNoiseReduction, "True"); |
| 471 | 462 |
| 472 CreateVideoSource(&constraints); | 463 CreateVideoSource(&constraints); |
| 473 | 464 |
| 474 EXPECT_EQ_WAIT(MediaSourceInterface::kEnded, state_observer_->state(), | 465 EXPECT_EQ_WAIT(MediaSourceInterface::kEnded, state_observer_->state(), |
| 475 kMaxWaitMs); | 466 kMaxWaitMs); |
| 476 bool value; | 467 EXPECT_EQ(rtc::Maybe<bool>(), source_->options()->video_noise_reduction); |
| 477 EXPECT_FALSE(source_->options()->video_noise_reduction.Get(&value)); | |
| 478 } | 468 } |
| 479 | 469 |
| 480 TEST_F(VideoSourceTest, MixedOptionsAndConstraints) { | 470 TEST_F(VideoSourceTest, MixedOptionsAndConstraints) { |
| 481 FakeConstraints constraints; | 471 FakeConstraints constraints; |
| 482 constraints.AddMandatory(MediaConstraintsInterface::kMaxWidth, 352); | 472 constraints.AddMandatory(MediaConstraintsInterface::kMaxWidth, 352); |
| 483 constraints.AddMandatory(MediaConstraintsInterface::kMaxHeight, 288); | 473 constraints.AddMandatory(MediaConstraintsInterface::kMaxHeight, 288); |
| 484 constraints.AddOptional(MediaConstraintsInterface::kMaxFrameRate, 5); | 474 constraints.AddOptional(MediaConstraintsInterface::kMaxFrameRate, 5); |
| 485 | 475 |
| 486 constraints.AddMandatory( | 476 constraints.AddMandatory( |
| 487 MediaConstraintsInterface::kNoiseReduction, false); | 477 MediaConstraintsInterface::kNoiseReduction, false); |
| 488 constraints.AddOptional( | 478 constraints.AddOptional( |
| 489 MediaConstraintsInterface::kNoiseReduction, true); | 479 MediaConstraintsInterface::kNoiseReduction, true); |
| 490 | 480 |
| 491 CreateVideoSource(&constraints); | 481 CreateVideoSource(&constraints); |
| 492 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(), | 482 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(), |
| 493 kMaxWaitMs); | 483 kMaxWaitMs); |
| 494 const cricket::VideoFormat* format = capturer_->GetCaptureFormat(); | 484 const cricket::VideoFormat* format = capturer_->GetCaptureFormat(); |
| 495 ASSERT_TRUE(format != NULL); | 485 ASSERT_TRUE(format != NULL); |
| 496 EXPECT_EQ(352, format->width); | 486 EXPECT_EQ(352, format->width); |
| 497 EXPECT_EQ(288, format->height); | 487 EXPECT_EQ(288, format->height); |
| 498 EXPECT_EQ(30, format->framerate()); | 488 EXPECT_EQ(30, format->framerate()); |
| 499 | 489 |
| 500 bool value = true; | 490 EXPECT_EQ(rtc::Maybe<bool>(false), source_->options()->video_noise_reduction); |
| 501 EXPECT_TRUE(source_->options()->video_noise_reduction.Get(&value)); | |
| 502 EXPECT_FALSE(value); | |
| 503 } | 491 } |
| 504 | 492 |
| 505 // Tests that the source starts video with the default resolution for | 493 // Tests that the source starts video with the default resolution for |
| 506 // screencast if no constraint is set. | 494 // screencast if no constraint is set. |
| 507 TEST_F(VideoSourceTest, ScreencastResolutionNoConstraint) { | 495 TEST_F(VideoSourceTest, ScreencastResolutionNoConstraint) { |
| 508 capturer_->TestWithoutCameraFormats(); | 496 capturer_->TestWithoutCameraFormats(); |
| 509 capturer_->SetScreencast(true); | 497 capturer_->SetScreencast(true); |
| 510 | 498 |
| 511 CreateVideoSource(); | 499 CreateVideoSource(); |
| 512 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(), | 500 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(), |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 constraints.AddOptional(MediaConstraintsInterface::kMaxFrameRate, 0.5); | 541 constraints.AddOptional(MediaConstraintsInterface::kMaxFrameRate, 0.5); |
| 554 | 542 |
| 555 CreateVideoSource(&constraints); | 543 CreateVideoSource(&constraints); |
| 556 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(), | 544 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(), |
| 557 kMaxWaitMs); | 545 kMaxWaitMs); |
| 558 const cricket::VideoFormat* format = capturer_->GetCaptureFormat(); | 546 const cricket::VideoFormat* format = capturer_->GetCaptureFormat(); |
| 559 ASSERT_TRUE(format != NULL); | 547 ASSERT_TRUE(format != NULL); |
| 560 EXPECT_EQ(30, format->framerate()); | 548 EXPECT_EQ(30, format->framerate()); |
| 561 } | 549 } |
| 562 | 550 |
| OLD | NEW |