Cast: Stop logging kVideoFrameSentToEncoder and rename a couple events.
[chromium-blink-merge.git] / remoting / codec / video_encoder_vpx_unittest.cc
blob462af9c247ac222974e36add45e7ca8ebb7486d3
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"
7 #include <limits>
8 #include <vector>
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"
16 namespace {
18 const int kIntMax = std::numeric_limits<int>::max();
20 } // namespace
22 namespace remoting {
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) {
32 int height = 1000;
33 int width = 1000;
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);
41 EXPECT_TRUE(packet);
43 height /= 2;
44 frame.reset(
45 new webrtc::BasicDesktopFrame(webrtc::DesktopSize(width, height)));
46 packet = encoder->Encode(*frame);
47 EXPECT_TRUE(packet);
50 // Test that the DPI information is correctly propagated from the
51 // media::ScreenCaptureData to the VideoPacket.
52 TEST(VideoEncoderVp8Test, TestDpiPropagation) {
53 int height = 32;
54 int width = 32;
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