Index: content/renderer/media/webrtc/webrtc_video_capturer_adapter_unittest.cc |
diff --git a/content/renderer/media/webrtc/webrtc_video_capturer_adapter_unittest.cc b/content/renderer/media/webrtc/webrtc_video_capturer_adapter_unittest.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..20321f496fff4c05e5e03e750517dac32f047036 |
--- /dev/null |
+++ b/content/renderer/media/webrtc/webrtc_video_capturer_adapter_unittest.cc |
@@ -0,0 +1,64 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include <algorithm> |
+ |
+#include "content/renderer/media/webrtc/webrtc_video_capturer_adapter.h" |
+#include "media/base/video_frame.h" |
+#include "testing/gtest/include/gtest/gtest.h" |
+ |
+namespace content { |
+ |
+class WebRtcVideoCapturerAdapterTest |
+ : public sigslot::has_slots<>, |
tommi (sloooow) - chröme
2014/03/06 10:14:09
this code is in chrome... I don't think we want to
perkj_chrome
2014/03/06 12:45:42
This tests the wrapper that implements a libjingle
tommi (sloooow) - chröme
2014/03/06 13:28:50
Ah, I see. I thought WebRtcVideoCapturerAdapter w
perkj_chrome
2014/03/06 14:22:53
Done.
|
+ public ::testing::Test { |
+ public: |
+ WebRtcVideoCapturerAdapterTest() |
+ :adapter_(false), |
tommi (sloooow) - chröme
2014/03/06 10:14:09
space after :
perkj_chrome
2014/03/06 12:45:42
Done.
perkj_chrome
2014/03/06 12:45:42
Done.
|
+ captured_frame_(NULL) { |
+ adapter_.SignalFrameCaptured.connect( |
+ this, &WebRtcVideoCapturerAdapterTest::OnFrameCaptured); |
+ } |
+ virtual ~WebRtcVideoCapturerAdapterTest() {} |
+ |
+ void TestSourceCropFrame(int capture_w, |
tommi (sloooow) - chröme
2014/03/06 10:14:09
full variable names
perkj_chrome
2014/03/06 12:45:42
Done.
|
+ int capture_h, |
+ int extpected_w, |
tommi (sloooow) - chröme
2014/03/06 10:14:09
expected
perkj_chrome
2014/03/06 12:45:42
Done.
|
+ int expected_h) { |
+ const int visible_width = std::min(capture_w, extpected_w); |
+ const int horiz_crop = ((capture_w - visible_width) / 2) & ~1; |
+ const int visible_height = std::min(capture_h, expected_h); |
+ const int vert_crop = ((expected_h - visible_height) / 2) & ~1; |
+ |
+ gfx::Size coded_size(capture_w, capture_h); |
+ gfx::Rect view_rect(horiz_crop, vert_crop, visible_width, visible_height); |
+ scoped_refptr<media::VideoFrame> frame = |
+ media::VideoFrame::CreateFrame(media::VideoFrame::I420, |
+ coded_size, view_rect, coded_size, |
+ base::TimeDelta()); |
+ adapter_.OnFrameCaptured(frame); |
+ ASSERT_TRUE(captured_frame_ != NULL); |
+ EXPECT_EQ(extpected_w, captured_frame_->width); |
+ EXPECT_EQ(expected_h, captured_frame_->height); |
+ } |
+ protected: |
+ void OnFrameCaptured(cricket::VideoCapturer* capturer, |
+ const cricket::CapturedFrame* frame) { |
+ captured_frame_ = frame; |
+ } |
tommi (sloooow) - chröme
2014/03/06 10:14:09
fix
perkj_chrome
2014/03/06 12:45:42
Done.
|
+ |
+ private: |
+ WebRtcVideoCapturerAdapter adapter_; |
+ const cricket::CapturedFrame* captured_frame_; |
tommi (sloooow) - chröme
2014/03/06 10:14:09
who owns?
perkj_chrome
2014/03/06 12:45:42
Humm- right- this is wrong. It points to a stack v
|
+}; |
+ |
+TEST_F(WebRtcVideoCapturerAdapterTest, CropFrameTo640360) { |
+ TestSourceCropFrame(640, 480, 640, 360); |
+} |
+ |
+TEST_F(WebRtcVideoCapturerAdapterTest, CropFrameTo732489) { |
+ TestSourceCropFrame(1280, 720, 731, 489); |
+} |
+ |
+} // namespace content |