diff options
Diffstat (limited to 'remoting/base/encoder_vp8_unittest.cc')
-rw-r--r-- | remoting/base/encoder_vp8_unittest.cc | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/remoting/base/encoder_vp8_unittest.cc b/remoting/base/encoder_vp8_unittest.cc index 370fd08..9435cd1 100644 --- a/remoting/base/encoder_vp8_unittest.cc +++ b/remoting/base/encoder_vp8_unittest.cc @@ -1,11 +1,16 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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 <limits> +#include <vector> +#include "base/callback.h" +#include "base/scoped_ptr.h" +#include "remoting/base/capture_data.h" #include "remoting/base/codec_test.h" #include "remoting/base/encoder_vp8.h" +#include "remoting/proto/video.pb.h" #include "testing/gtest/include/gtest/gtest.h" namespace { @@ -21,6 +26,40 @@ TEST(EncoderVp8Test, TestEncoder) { TestEncoder(&encoder, false); } +class EncoderCallback { + public: + void DataAvailable(VideoPacket *packet) { + delete packet; + } +}; + +// Test that calling Encode with a differently-sized CaptureData does not +// leak memory. +TEST(EncoderVp8Test, TestSizeChangeNoLeak) { + int height = 1000; + int width = 1000; + const int kBytesPerPixel = 4; + + EncoderVp8 encoder; + EncoderCallback callback; + + std::vector<uint8> buffer(width * height * kBytesPerPixel); + DataPlanes planes; + planes.data[0] = &buffer.front(); + planes.strides[0] = width; + + scoped_refptr<CaptureData> capture_data(new CaptureData( + planes, gfx::Size(width, height), media::VideoFrame::RGB32)); + encoder.Encode(capture_data, false, + NewCallback(&callback, &EncoderCallback::DataAvailable)); + + height /= 2; + capture_data = new CaptureData(planes, gfx::Size(width, height), + media::VideoFrame::RGB32); + encoder.Encode(capture_data, false, + NewCallback(&callback, &EncoderCallback::DataAvailable)); +} + TEST(EncoderVp8Test, AlignAndClipRect) { // Simple test case (no clipping). gfx::Rect r1(100, 200, 300, 400); |