Home | History | Annotate | Download | only in test
      1 /*
      2  *  Copyright (c) 2012 The WebM project authors. All Rights Reserved.
      3  *
      4  *  Use of this source code is governed by a BSD-style license
      5  *  that can be found in the LICENSE file in the root of the source
      6  *  tree. An additional intellectual property rights grant can be found
      7  *  in the file PATENTS.  All contributing project authors may
      8  *  be found in the AUTHORS file in the root of the source tree.
      9  */
     10 #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 #include "test/video_source.h"
     15 
     16 namespace {
     17 
     18 class ConfigTest : public ::libvpx_test::EncoderTest,
     19     public ::libvpx_test::CodecTestWithParam<libvpx_test::TestMode> {
     20  protected:
     21   ConfigTest() : EncoderTest(GET_PARAM(0)),
     22                  frame_count_in_(0), frame_count_out_(0), frame_count_max_(0) {}
     23 
     24   virtual void SetUp() {
     25     InitializeConfig();
     26     SetMode(GET_PARAM(1));
     27   }
     28 
     29   virtual void BeginPassHook(unsigned int /*pass*/) {
     30     frame_count_in_ = 0;
     31     frame_count_out_ = 0;
     32   }
     33 
     34   virtual void PreEncodeFrameHook(libvpx_test::VideoSource* /*video*/) {
     35     ++frame_count_in_;
     36     abort_ |= (frame_count_in_ >= frame_count_max_);
     37   }
     38 
     39   virtual void FramePktHook(const vpx_codec_cx_pkt_t* /*pkt*/) {
     40     ++frame_count_out_;
     41   }
     42 
     43   unsigned int frame_count_in_;
     44   unsigned int frame_count_out_;
     45   unsigned int frame_count_max_;
     46 };
     47 
     48 TEST_P(ConfigTest, LagIsDisabled) {
     49   frame_count_max_ = 2;
     50   cfg_.g_lag_in_frames = 15;
     51 
     52   libvpx_test::DummyVideoSource video;
     53   ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
     54 
     55   EXPECT_EQ(frame_count_in_, frame_count_out_);
     56 }
     57 
     58 VP8_INSTANTIATE_TEST_CASE(ConfigTest, ONE_PASS_TEST_MODES);
     59 }  // namespace
     60