config_test.cc 1.7 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
/*
 *  Copyright (c) 2012 The WebM project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
 *  in the file PATENTS.  All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.
 */
#include "third_party/googletest/src/include/gtest/gtest.h"
11
#include "test/codec_factory.h"
12
#include "test/encode_test_driver.h"
13
#include "test/util.h"
14 15 16 17 18
#include "test/video_source.h"

namespace {

class ConfigTest : public ::libvpx_test::EncoderTest,
19
    public ::libvpx_test::CodecTestWithParam<libvpx_test::TestMode> {
20
 protected:
21 22
  ConfigTest() : EncoderTest(GET_PARAM(0)),
                 frame_count_in_(0), frame_count_out_(0), frame_count_max_(0) {}
23
  virtual ~ConfigTest() {}
24

25 26
  virtual void SetUp() {
    InitializeConfig();
27
    SetMode(GET_PARAM(1));
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
  }

  virtual void BeginPassHook(unsigned int /*pass*/) {
    frame_count_in_ = 0;
    frame_count_out_ = 0;
  }

  virtual void PreEncodeFrameHook(libvpx_test::VideoSource* /*video*/) {
    ++frame_count_in_;
    abort_ |= (frame_count_in_ >= frame_count_max_);
  }

  virtual void FramePktHook(const vpx_codec_cx_pkt_t* /*pkt*/) {
    ++frame_count_out_;
  }

  unsigned int frame_count_in_;
  unsigned int frame_count_out_;
  unsigned int frame_count_max_;
};

TEST_P(ConfigTest, LagIsDisabled) {
  frame_count_max_ = 2;
  cfg_.g_lag_in_frames = 15;

  libvpx_test::DummyVideoSource video;
  ASSERT_NO_FATAL_FAILURE(RunLoop(&video));

  EXPECT_EQ(frame_count_in_, frame_count_out_);
}

59
VP8_INSTANTIATE_TEST_CASE(ConfigTest, ONE_PASS_TEST_MODES);
60
}  // namespace