Remove redundant deinitialization code from HttpCache::Transaction.
[chromium-blink-merge.git] / remoting / codec / video_encoder_vp8_unittest.cc
blob684910d0088d3fc866c80f69d6c7bb1cadeb18f1
1 // Copyright (c) 2012 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_vp8.h"
7 #include <limits>
8 #include <vector>
10 #include "base/bind.h"
11 #include "base/callback.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "remoting/codec/codec_test.h"
14 #include "remoting/proto/video.pb.h"
15 #include "testing/gtest/include/gtest/gtest.h"
16 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h"
18 namespace {
20 const int kIntMax = std::numeric_limits<int>::max();
22 } // namespace
24 namespace remoting {
26 TEST(VideoEncoderVp8Test, TestVideoEncoder) {
27 VideoEncoderVp8 encoder;
28 TestVideoEncoder(&encoder, false);
31 class VideoEncoderCallback {
32 public:
33 void DataAvailable(scoped_ptr<VideoPacket> packet) {
37 // Test that calling Encode with a differently-sized media::ScreenCaptureData
38 // does not leak memory.
39 TEST(VideoEncoderVp8Test, TestSizeChangeNoLeak) {
40 int height = 1000;
41 int width = 1000;
43 VideoEncoderVp8 encoder;
44 VideoEncoderCallback callback;
46 scoped_ptr<webrtc::DesktopFrame> frame(new webrtc::BasicDesktopFrame(
47 webrtc::DesktopSize(width, height)));
49 encoder.Encode(frame.get(), base::Bind(&VideoEncoderCallback::DataAvailable,
50 base::Unretained(&callback)));
52 height /= 2;
53 frame.reset(new webrtc::BasicDesktopFrame(
54 webrtc::DesktopSize(width, height)));
55 encoder.Encode(frame.get(), base::Bind(&VideoEncoderCallback::DataAvailable,
56 base::Unretained(&callback)));
59 class VideoEncoderDpiCallback {
60 public:
61 void DataAvailable(scoped_ptr<VideoPacket> packet) {
62 EXPECT_EQ(packet->format().x_dpi(), 96);
63 EXPECT_EQ(packet->format().y_dpi(), 97);
67 // Test that the DPI information is correctly propagated from the
68 // media::ScreenCaptureData to the VideoPacket.
69 TEST(VideoEncoderVp8Test, TestDpiPropagation) {
70 int height = 32;
71 int width = 32;
73 VideoEncoderVp8 encoder;
74 VideoEncoderDpiCallback callback;
76 scoped_ptr<webrtc::DesktopFrame> frame(new webrtc::BasicDesktopFrame(
77 webrtc::DesktopSize(width, height)));
78 frame->set_dpi(webrtc::DesktopVector(96, 97));
79 encoder.Encode(frame.get(),
80 base::Bind(&VideoEncoderDpiCallback::DataAvailable,
81 base::Unretained(&callback)));
84 } // namespace remoting