Skip to content

Commit

Permalink
add all UT
Browse files Browse the repository at this point in the history
  • Loading branch information
RinoReyns committed Nov 16, 2024
1 parent 3f01e8e commit 97085b8
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,15 @@ int WaveProcessingPipeline::CreatePreprocessingModules()

int WaveProcessingPipeline::PreprocessingProcessing()
{
LOG(INFO) << "Prepocessing in progress..";
int status = preprocessing_filter_wrapper_->Process(input_wave_->data, output_wave_->data);
RETURN_ERROR_IF_NOT_SUCCESS_OR_BYPASS(status);
if (status == VST_ERROR_STATUS::SUCCESS)
{
status = SwapInOutBuffers();
RETURN_ERROR_IF_NOT_SUCCESS(status);
}
LOG(INFO) << "Prepocessing finished.";
return status;
}

Expand All @@ -75,7 +77,10 @@ int WaveProcessingPipeline::CreatePostprocessingModules()

int WaveProcessingPipeline::PostprocessingProcessing()
{
return postprocessing_filter_wrapper_->Process(input_wave_->data, output_wave_->data);
LOG(INFO) << "Postpocessing in progress..";
int status = postprocessing_filter_wrapper_->Process(input_wave_->data, output_wave_->data);
LOG(INFO) << "Postpocessing finished.";
return status;
}

int WaveProcessingPipeline::GetConfig()
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
5 changes: 4 additions & 1 deletion VstHost_VisualC++/modules/UnitTests/header/UnitTestsCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ const std::string REF_OUTPUT_WITH_TWO_PLUGINS_2 = UT_DATA_FOLDER + "sine_440
const std::string PROCESSING_CONFIG_PATH = UT_DATA_FOLDER + "processing_config.json";
const std::string PLUGIN_NAME = "plugin_1";
const std::string REF_FILTRATED = UT_DATA_FOLDER + "sine_440_filtrated.wav";
const std::string REF_PRE_POST_PROC = UT_DATA_FOLDER + "sine_440_filtrated_pre_and_post_proc.wav";
const std::string REF_PRE_POST_PROC_ONLY = UT_DATA_FOLDER + "sine_440_filtrated_pre_and_post_proc_only.wav";
const std::string REF_PRE_POST_PROC_BOTH = UT_DATA_FOLDER + "sine_440_filtrated_pre_and_post_proc_both.wav";
const std::string REF_PRE_POST_VST_HOST = UT_DATA_FOLDER + "sine_440_filtrated_pre_post_vst_host.wav";
const std::string REF_PRE_VST_HOST = UT_DATA_FOLDER + "sine_440_filtrated_pre_vst_host.wav";

const float PRECISION_9_DECIMAL_PLACES = 1e-9;
const float PRECISION_8_DECIMAL_PLACES = 1e-8;
Expand Down
98 changes: 83 additions & 15 deletions VstHost_VisualC++/modules/UnitTests/src/VstHostToolUnitTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ namespace VstHostToolUnitTest

void CleanUpUtProducts()
{
/* if (std::filesystem::exists(OUTPUT_WAVE_PATH))
if (std::filesystem::exists(OUTPUT_WAVE_PATH))
{
std::remove(OUTPUT_WAVE_PATH.c_str());
}*/
}

if (std::filesystem::exists(DUMP_JSON_FILE_PATH))
{
Expand Down Expand Up @@ -124,7 +124,7 @@ namespace VstHostToolUnitTest
return status;
}

void AppProcessingWithOutputValidation(std::string ref_path, bool validate_for_macos=true, bool bit_exact=true)
void AppProcessingWithOutputValidation(std::string ref_path, bool validate_quality=true, bool bit_exact=true)
{
std::vector<std::string> arg_params = {
"OfflineToolsUnitTests.exe",
Expand All @@ -146,7 +146,7 @@ namespace VstHostToolUnitTest
std::vector<float> ref;
status = LoadWave(ref_path, &ref);
EXPECT_EQ(status, VST_ERROR_STATUS::SUCCESS);
if (validate_for_macos)
if (validate_quality)
{
if (bit_exact)
{
Expand Down Expand Up @@ -407,8 +407,8 @@ namespace VstHostToolUnitTest

status = JsonUtils::DumpJson(json_config, PROCESSING_CONFIG_PATH);
EXPECT_EQ(status, VST_ERROR_STATUS::SUCCESS);
#ifndef __APPLE__
AppProcessingWithOutputValidation(REF_PRE_POST_PROC, true, false);
#ifdef _WIN32
AppProcessingWithOutputValidation(REF_PRE_POST_PROC_ONLY, true, false);
#else
AppProcessingWithOutputValidation(REF_PRE_POST_PROC, false);
#endif //!__APPLE__
Expand All @@ -424,17 +424,85 @@ namespace VstHostToolUnitTest

status = JsonUtils::DumpJson(json_config, PROCESSING_CONFIG_PATH);
EXPECT_EQ(status, VST_ERROR_STATUS::SUCCESS);
#ifndef __APPLE__
AppProcessingWithOutputValidation(REF_PRE_POST_PROC, true, false);
#ifdef _WIN32
AppProcessingWithOutputValidation(REF_PRE_POST_PROC_ONLY, true, false);
#else
AppProcessingWithOutputValidation(REF_PRE_POST_PROC, false);
#endif //!__APPLE__
#endif //_WIN32
}

TEST_F(VstHostToolTest, RunToolWithPreAndPostprocessing)
{
nlohmann::json json_config;
int status = FirstConfigPreparations(&json_config, false);
EXPECT_EQ(status, VST_ERROR_STATUS::SUCCESS);
json_config[PREPROCESSING_STRING]["filter"]["enable"] = true;
json_config[POSTPROCESSING_STRING]["filter"]["enable"] = true;

status = JsonUtils::DumpJson(json_config, PROCESSING_CONFIG_PATH);
EXPECT_EQ(status, VST_ERROR_STATUS::SUCCESS);
#ifdef _WIN32
AppProcessingWithOutputValidation(REF_PRE_POST_PROC_BOTH, true, false);
#else
AppProcessingWithOutputValidation(REF_PRE_POST_PROC_BOTH, false);
#endif //_WIN32
}

TEST_F(VstHostToolTest, RunToolWithPrePostVstHostProcessing)
{
nlohmann::json json_config;
bool enable_vst_host = true;
std::string ref_file = REF_PRE_POST_VST_HOST;
int status = FirstConfigPreparations(&json_config, enable_vst_host);
EXPECT_EQ(status, VST_ERROR_STATUS::SUCCESS);
json_config[PREPROCESSING_STRING]["filter"]["enable"] = true;
json_config[POSTPROCESSING_STRING]["filter"]["enable"] = true;

status = JsonUtils::DumpJson(json_config, PROCESSING_CONFIG_PATH);
EXPECT_EQ(status, VST_ERROR_STATUS::SUCCESS);
#ifdef _WIN32
AppProcessingWithOutputValidation(ref_file, true, false);
#else
AppProcessingWithOutputValidation(ref_file, false);
#endif //_WIN32
}

TEST_F(VstHostToolTest, RunToolWithPreVstHostProcessing)
{
nlohmann::json json_config;
bool enable_vst_host = true;
std::string ref_file = REF_PRE_VST_HOST;
int status = FirstConfigPreparations(&json_config, enable_vst_host);
EXPECT_EQ(status, VST_ERROR_STATUS::SUCCESS);
json_config[PREPROCESSING_STRING]["filter"]["enable"] = true;
json_config[POSTPROCESSING_STRING]["filter"]["enable"] = false;

status = JsonUtils::DumpJson(json_config, PROCESSING_CONFIG_PATH);
EXPECT_EQ(status, VST_ERROR_STATUS::SUCCESS);
#ifdef _WIN32
AppProcessingWithOutputValidation(ref_file, true, false);
#else
AppProcessingWithOutputValidation(ref_file, false);
#endif //_WIN32
}

TEST_F(VstHostToolTest, RunToolWithPostVstHostProcessing)
{
nlohmann::json json_config;
bool enable_vst_host = true;
std::string ref_file = REF_PRE_VST_HOST;
int status = FirstConfigPreparations(&json_config, enable_vst_host);
EXPECT_EQ(status, VST_ERROR_STATUS::SUCCESS);
json_config[PREPROCESSING_STRING]["filter"]["enable"] = false;
json_config[POSTPROCESSING_STRING]["filter"]["enable"] = true;

status = JsonUtils::DumpJson(json_config, PROCESSING_CONFIG_PATH);
EXPECT_EQ(status, VST_ERROR_STATUS::SUCCESS);
#ifdef _WIN32
AppProcessingWithOutputValidation(ref_file, true, false);
#else
AppProcessingWithOutputValidation(ref_file, false);
#endif //_WIN32
}

// TODO:
// Prepare reference for each test RunToolWithPreprocessingOnly
// also for RunToolWithPostprocessingOnly and
// Add test for pre and post processing
// Add test for preprocessing + vst_host
// Add test for postprocessing + vst_host
}

0 comments on commit 97085b8

Please sign in to comment.