1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "remoting/codec/video_encoder_vpx.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "remoting/codec/codec_test.h"
12 #include "remoting/proto/video.pb.h"
13 #include "testing/gtest/include/gtest/gtest.h"
14 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h"
18 const int kIntMax = std::numeric_limits<int>::max();
24 TEST(VideoEncoderVp8Test, TestVideoEncoder) {
25 scoped_ptr<VideoEncoderVpx> encoder(VideoEncoderVpx::CreateForVP8());
26 TestVideoEncoder(encoder.get(), false);
29 // Test that calling Encode with a differently-sized media::ScreenCaptureData
30 // does not leak memory.
31 TEST(VideoEncoderVp8Test, TestSizeChangeNoLeak) {
35 scoped_ptr<VideoEncoderVpx> encoder(VideoEncoderVpx::CreateForVP8());
37 scoped_ptr<webrtc::DesktopFrame> frame(
38 new webrtc::BasicDesktopFrame(webrtc::DesktopSize(width, height)));
40 scoped_ptr<VideoPacket> packet = encoder->Encode(*frame);
45 new webrtc::BasicDesktopFrame(webrtc::DesktopSize(width, height)));
46 packet = encoder->Encode(*frame);
50 // Test that the DPI information is correctly propagated from the
51 // media::ScreenCaptureData to the VideoPacket.
52 TEST(VideoEncoderVp8Test, TestDpiPropagation) {
56 scoped_ptr<VideoEncoderVpx> encoder(VideoEncoderVpx::CreateForVP8());
58 scoped_ptr<webrtc::DesktopFrame> frame(
59 new webrtc::BasicDesktopFrame(webrtc::DesktopSize(width, height)));
60 frame->set_dpi(webrtc::DesktopVector(96, 97));
61 scoped_ptr<VideoPacket> packet = encoder->Encode(*frame);
62 EXPECT_EQ(packet->format().x_dpi(), 96);
63 EXPECT_EQ(packet->format().y_dpi(), 97);
66 } // namespace remoting