/* This file is a part of plaYUVer project * Copyright (C) 2014-2021 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ /** * \file TestModuleCreate.cpp * \brief CalypModuleIf testing for YUV420p sequences */ #include "gtest/gtest.h" #include "lib/CalypFrame.h" #include "lib/CalypModuleIf.h" #include "lib/CalypStream.h" #include "modules/CalypModulesFactory.h" class TestModuleProcessNumberOfFrames : public ::testing::Test { protected: // Per-test-case set-up. // Called before the first test in this test case. // Can be omitted if not needed. static void SetUpTestCase() { } // Per-test-case tear-down. // Called after the last test in this test case. // Can be omitted if not needed. static void TearDownTestCase() { pcStream = nullptr; } // Called before each test void SetUp() { std::string moduleName = CALYP_TEST_MODULE_NAME; pcStream = std::make_unique(); pcStream->open( std::string( CALYP_TEST_DATA_DIR ) + std::string( "/BasketballDrill_F10_832x480_yuv420p.yuv" ), 832, 480, ClpPixelFormats::YUV420p, 8, CLP_BIG_ENDIAN, 1, CalypStream::Type::Input ); pcModule = CalypModulesFactory::Get()->CreateModule( moduleName ); } void TearDown() { } std::unique_ptr pcModule; // Some expensive resource shared by all tests. static std::unique_ptr pcStream; }; std::unique_ptr TestModuleProcessNumberOfFrames::pcStream{ nullptr }; TEST_F( TestModuleProcessNumberOfFrames, PROCESS_OK ) { if( pcModule->m_iModuleAPI >= CLP_MODULE_API_2 ) { std::vector apcFrameList; apcFrameList.clear(); for( unsigned int i = 0; i < pcModule->m_uiNumberOfFrames; i++ ) { apcFrameList.push_back( pcStream->getCurrFrame() ); pcStream->setNextFrame(); pcStream->readNextFrame(); } // Let's not test the modules that are not able to be created if( pcModule->create( apcFrameList ) ) { CalypFrame* frame = pcModule->process( apcFrameList ); EXPECT_NE( frame, nullptr ); } } }