| OLD | NEW |
| 1 /* | 1 /* |
| 2 * libjingle | 2 * libjingle |
| 3 * Copyright 2008 Google Inc. | 3 * Copyright 2008 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 } // namespace | 48 } // namespace |
| 49 | 49 |
| 50 class VideoCapturerTest | 50 class VideoCapturerTest |
| 51 : public sigslot::has_slots<>, | 51 : public sigslot::has_slots<>, |
| 52 public testing::Test { | 52 public testing::Test { |
| 53 public: | 53 public: |
| 54 VideoCapturerTest() | 54 VideoCapturerTest() |
| 55 : capture_state_(cricket::CS_STOPPED), | 55 : capture_state_(cricket::CS_STOPPED), |
| 56 num_state_changes_(0), | 56 num_state_changes_(0), |
| 57 video_frames_received_(0), | 57 video_frames_received_(0), |
| 58 last_frame_elapsed_time_(0), | |
| 59 expects_rotation_applied_(true) { | 58 expects_rotation_applied_(true) { |
| 60 capturer_.SignalVideoFrame.connect(this, &VideoCapturerTest::OnVideoFrame); | 59 capturer_.SignalVideoFrame.connect(this, &VideoCapturerTest::OnVideoFrame); |
| 61 capturer_.SignalStateChange.connect(this, | 60 capturer_.SignalStateChange.connect(this, |
| 62 &VideoCapturerTest::OnStateChange); | 61 &VideoCapturerTest::OnStateChange); |
| 63 } | 62 } |
| 64 | 63 |
| 65 void set_expected_compensation(bool compensation) { | 64 void set_expected_compensation(bool compensation) { |
| 66 expects_rotation_applied_ = compensation; | 65 expects_rotation_applied_ = compensation; |
| 67 } | 66 } |
| 68 | 67 |
| 69 protected: | 68 protected: |
| 70 void OnVideoFrame(cricket::VideoCapturer*, const cricket::VideoFrame* frame) { | 69 void OnVideoFrame(cricket::VideoCapturer*, const cricket::VideoFrame* frame) { |
| 71 ++video_frames_received_; | 70 ++video_frames_received_; |
| 72 last_frame_elapsed_time_ = frame->GetElapsedTime(); | |
| 73 if (expects_rotation_applied_) { | 71 if (expects_rotation_applied_) { |
| 74 EXPECT_EQ(webrtc::kVideoRotation_0, frame->GetRotation()); | 72 EXPECT_EQ(webrtc::kVideoRotation_0, frame->GetRotation()); |
| 75 } else { | 73 } else { |
| 76 EXPECT_EQ(capturer_.GetRotation(), frame->GetRotation()); | 74 EXPECT_EQ(capturer_.GetRotation(), frame->GetRotation()); |
| 77 } | 75 } |
| 78 renderer_.RenderFrame(frame); | 76 renderer_.RenderFrame(frame); |
| 79 } | 77 } |
| 80 void OnStateChange(cricket::VideoCapturer*, | 78 void OnStateChange(cricket::VideoCapturer*, |
| 81 cricket::CaptureState capture_state) { | 79 cricket::CaptureState capture_state) { |
| 82 capture_state_ = capture_state; | 80 capture_state_ = capture_state; |
| 83 ++num_state_changes_; | 81 ++num_state_changes_; |
| 84 } | 82 } |
| 85 cricket::CaptureState capture_state() { return capture_state_; } | 83 cricket::CaptureState capture_state() { return capture_state_; } |
| 86 int num_state_changes() { return num_state_changes_; } | 84 int num_state_changes() { return num_state_changes_; } |
| 87 int video_frames_received() const { | 85 int video_frames_received() const { |
| 88 return video_frames_received_; | 86 return video_frames_received_; |
| 89 } | 87 } |
| 90 int64 last_frame_elapsed_time() const { return last_frame_elapsed_time_; } | |
| 91 | 88 |
| 92 cricket::FakeVideoCapturer capturer_; | 89 cricket::FakeVideoCapturer capturer_; |
| 93 cricket::CaptureState capture_state_; | 90 cricket::CaptureState capture_state_; |
| 94 int num_state_changes_; | 91 int num_state_changes_; |
| 95 int video_frames_received_; | 92 int video_frames_received_; |
| 96 int64 last_frame_elapsed_time_; | |
| 97 cricket::FakeVideoRenderer renderer_; | 93 cricket::FakeVideoRenderer renderer_; |
| 98 bool expects_rotation_applied_; | 94 bool expects_rotation_applied_; |
| 99 }; | 95 }; |
| 100 | 96 |
| 101 TEST_F(VideoCapturerTest, CaptureState) { | 97 TEST_F(VideoCapturerTest, CaptureState) { |
| 102 EXPECT_TRUE(capturer_.enable_video_adapter()); | 98 EXPECT_TRUE(capturer_.enable_video_adapter()); |
| 103 EXPECT_EQ(cricket::CS_RUNNING, capturer_.Start(cricket::VideoFormat( | 99 EXPECT_EQ(cricket::CS_RUNNING, capturer_.Start(cricket::VideoFormat( |
| 104 640, | 100 640, |
| 105 480, | 101 480, |
| 106 cricket::VideoFormat::FpsToInterval(30), | 102 cricket::VideoFormat::FpsToInterval(30), |
| (...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 843 capturer_.set_enable_camera_list(true); | 839 capturer_.set_enable_camera_list(true); |
| 844 capturer_.ConstrainSupportedFormats(vga_format); | 840 capturer_.ConstrainSupportedFormats(vga_format); |
| 845 EXPECT_EQ(2u, capturer_.GetSupportedFormats()->size()); | 841 EXPECT_EQ(2u, capturer_.GetSupportedFormats()->size()); |
| 846 // To make sure it's not just the camera list being broken, add in VGA and | 842 // To make sure it's not just the camera list being broken, add in VGA and |
| 847 // try again. This time, only the VGA format should be there. | 843 // try again. This time, only the VGA format should be there. |
| 848 supported_formats.push_back(vga_format); | 844 supported_formats.push_back(vga_format); |
| 849 capturer_.ResetSupportedFormats(supported_formats); | 845 capturer_.ResetSupportedFormats(supported_formats); |
| 850 ASSERT_EQ(1u, capturer_.GetSupportedFormats()->size()); | 846 ASSERT_EQ(1u, capturer_.GetSupportedFormats()->size()); |
| 851 EXPECT_EQ(vga_format.height, capturer_.GetSupportedFormats()->at(0).height); | 847 EXPECT_EQ(vga_format.height, capturer_.GetSupportedFormats()->at(0).height); |
| 852 } | 848 } |
| OLD | NEW |