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/encode_test_driver.h"
     12 #include "test/video_source.h"
     13 
     14 namespace {
     15 
     16 class ConfigTest : public ::libvpx_test::EncoderTest,
     17     public ::testing::TestWithParam<enum libvpx_test::TestMode> {
     18  public:
     19   ConfigTest() : frame_count_in_(0), frame_count_out_(0), frame_count_max_(0) {}
     20 
     21  protected:
     22   virtual void SetUp() {
     23     InitializeConfig();
     24     SetMode(GetParam());
     25   }
     26 
     27   virtual void BeginPassHook(unsigned int /*pass*/) {
     28     frame_count_in_ = 0;
     29     frame_count_out_ = 0;
     30   }
     31 
     32   virtual void PreEncodeFrameHook(libvpx_test::VideoSource* /*video*/) {
     33     ++frame_count_in_;
     34     abort_ |= (frame_count_in_ >= frame_count_max_);
     35   }
     36 
     37   virtual void FramePktHook(const vpx_codec_cx_pkt_t* /*pkt*/) {
     38     ++frame_count_out_;
     39   }
     40 
     41   virtual bool Continue() const {
     42     return !HasFatalFailure() && !abort_;
     43   }
     44 
     45   unsigned int frame_count_in_;
     46   unsigned int frame_count_out_;
     47   unsigned int frame_count_max_;
     48 };
     49 
     50 TEST_P(ConfigTest, LagIsDisabled) {
     51   frame_count_max_ = 2;
     52   cfg_.g_lag_in_frames = 15;
     53 
     54   libvpx_test::DummyVideoSource video;
     55   ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
     56 
     57   EXPECT_EQ(frame_count_in_, frame_count_out_);
     58 }
     59 
     60 INSTANTIATE_TEST_CASE_P(OnePassModes, ConfigTest, ONE_PASS_TEST_MODES);
     61 }  // namespace
     62