From 3b51065c55e622867db89ec50a5e3c35691ebad4 Mon Sep 17 00:00:00 2001 From: alessiob Date: Sat, 18 Mar 2017 03:45:31 -0700 Subject: [PATCH] Conversational Speech generator, adding unit test. Test for the conversational_speech::Config class and renaming. BUG=webrtc:7218 Review-Url: https://codereview.webrtc.org/2749573002 Cr-Commit-Position: refs/heads/master@{#17301} --- .../test/conversational_speech/BUILD.gn | 36 +++++++++++++++---- .../{settings.cc => config.cc} | 10 +++--- .../{settings.h => config.h} | 16 +++++---- .../{convspeech_gen.cc => generator.cc} | 12 +++---- .../generator_unittest.cc | 35 ++++++++++++++++++ 5 files changed, 86 insertions(+), 23 deletions(-) rename webrtc/modules/audio_processing/test/conversational_speech/{settings.cc => config.cc} (72%) rename webrtc/modules/audio_processing/test/conversational_speech/{settings.h => config.h} (79%) rename webrtc/modules/audio_processing/test/conversational_speech/{convspeech_gen.cc => generator.cc} (86%) create mode 100644 webrtc/modules/audio_processing/test/conversational_speech/generator_unittest.cc diff --git a/webrtc/modules/audio_processing/test/conversational_speech/BUILD.gn b/webrtc/modules/audio_processing/test/conversational_speech/BUILD.gn index 5301cb209e..d0cb1e7e7e 100644 --- a/webrtc/modules/audio_processing/test/conversational_speech/BUILD.gn +++ b/webrtc/modules/audio_processing/test/conversational_speech/BUILD.gn @@ -6,26 +6,50 @@ # in the file PATENTS. All contributing project authors may # be found in the AUTHORS file in the root of the source tree. -import("../../../../webrtc.gni") +import("//webrtc/webrtc.gni") group("conversational_speech") { testonly = true deps = [ - ":convspeech_gen", + ":conversational_speech_generator", + ":conversational_speech_generator_unittest", ] } -rtc_executable("convspeech_gen") { +rtc_executable("conversational_speech_generator") { testonly = true sources = [ - "convspeech_gen.cc", - "settings.cc", - "settings.h", + "generator.cc", ] deps = [ + ":lib", "//third_party/gflags", "//webrtc/base:rtc_base_approved", "//webrtc/test:test_support", ] visibility = [ ":*" ] # Only targets in this file can depend on this. +} # bin + +rtc_static_library("lib") { + testonly = true + sources = [ + "config.cc", + "config.h", + ] + deps = [] + visibility = [ ":*" ] # Only targets in this file can depend on this. +} # lib + +rtc_test("conversational_speech_generator_unittest") { + testonly = true + deps = [ + ":lib", + "//testing/gtest", + "//webrtc//base:rtc_base_tests_main", + "//webrtc/test:test_support", + ] + sources = [ + "generator_unittest.cc", + ] + visibility = [ ":*" ] # Only targets in this file can depend on this. } diff --git a/webrtc/modules/audio_processing/test/conversational_speech/settings.cc b/webrtc/modules/audio_processing/test/conversational_speech/config.cc similarity index 72% rename from webrtc/modules/audio_processing/test/conversational_speech/settings.cc rename to webrtc/modules/audio_processing/test/conversational_speech/config.cc index 8b2e88b493..5a0a32267d 100644 --- a/webrtc/modules/audio_processing/test/conversational_speech/settings.cc +++ b/webrtc/modules/audio_processing/test/conversational_speech/config.cc @@ -8,22 +8,24 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "webrtc/modules/audio_processing/test/conversational_speech/settings.h" +#include "webrtc/modules/audio_processing/test/conversational_speech/config.h" namespace webrtc { namespace test { +namespace conversational_speech { -const std::string& ConvSpeechGeneratorSettings::audiotracks_path() const { +const std::string& Config::audiotracks_path() const { return audiotracks_path_; } -const std::string& ConvSpeechGeneratorSettings::timing_filepath() const { +const std::string& Config::timing_filepath() const { return timing_filepath_; } -const std::string& ConvSpeechGeneratorSettings::output_path() const { +const std::string& Config::output_path() const { return output_path_; } +} // namespace conversational_speech } // namespace test } // namespace webrtc diff --git a/webrtc/modules/audio_processing/test/conversational_speech/settings.h b/webrtc/modules/audio_processing/test/conversational_speech/config.h similarity index 79% rename from webrtc/modules/audio_processing/test/conversational_speech/settings.h rename to webrtc/modules/audio_processing/test/conversational_speech/config.h index ea360b7952..bad1145e98 100644 --- a/webrtc/modules/audio_processing/test/conversational_speech/settings.h +++ b/webrtc/modules/audio_processing/test/conversational_speech/config.h @@ -8,18 +8,19 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_TEST_CONVERSATIONAL_SPEECH_SETTINGS_H_ -#define WEBRTC_MODULES_AUDIO_PROCESSING_TEST_CONVERSATIONAL_SPEECH_SETTINGS_H_ +#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_TEST_CONVERSATIONAL_SPEECH_CONFIG_H_ +#define WEBRTC_MODULES_AUDIO_PROCESSING_TEST_CONVERSATIONAL_SPEECH_CONFIG_H_ #include namespace webrtc { namespace test { +namespace conversational_speech { -struct ConvSpeechGeneratorSettings { - ConvSpeechGeneratorSettings(const std::string& audiotracks_path, - const std::string& timing_filepath, - const std::string& output_path) +struct Config { + Config(const std::string& audiotracks_path, + const std::string& timing_filepath, + const std::string& output_path) : audiotracks_path_(audiotracks_path), timing_filepath_(timing_filepath), output_path_(output_path) {} @@ -33,7 +34,8 @@ struct ConvSpeechGeneratorSettings { const std::string output_path_; }; +} // namespace conversational_speech } // namespace test } // namespace webrtc -#endif // WEBRTC_MODULES_AUDIO_PROCESSING_TEST_CONVERSATIONAL_SPEECH_SETTINGS_H_ +#endif // WEBRTC_MODULES_AUDIO_PROCESSING_TEST_CONVERSATIONAL_SPEECH_CONFIG_H_ diff --git a/webrtc/modules/audio_processing/test/conversational_speech/convspeech_gen.cc b/webrtc/modules/audio_processing/test/conversational_speech/generator.cc similarity index 86% rename from webrtc/modules/audio_processing/test/conversational_speech/convspeech_gen.cc rename to webrtc/modules/audio_processing/test/conversational_speech/generator.cc index 2b88597987..923736ffef 100644 --- a/webrtc/modules/audio_processing/test/conversational_speech/convspeech_gen.cc +++ b/webrtc/modules/audio_processing/test/conversational_speech/generator.cc @@ -12,7 +12,7 @@ #include "gflags/gflags.h" #include "webrtc/base/logging.h" -#include "webrtc/modules/audio_processing/test/conversational_speech/settings.h" +#include "webrtc/modules/audio_processing/test/conversational_speech/config.h" #include "webrtc/test/testsupport/fileutils.h" namespace webrtc { @@ -28,7 +28,7 @@ auto file_exists = [](const char* c, const std::string& filepath) { }; const char kUsageDescription[] = - "Usage: convspeech_gen\n" + "Usage: conversational_speech_generator\n" " -i \n" " -t \n" " -o \n" @@ -49,13 +49,13 @@ int main(int argc, char* argv[]) { google::SetUsageMessage(kUsageDescription); google::ParseCommandLineFlags(&argc, &argv, true); - ConvSpeechGeneratorSettings settings(FLAGS_i, FLAGS_t, FLAGS_o); + conversational_speech::Config config(FLAGS_i, FLAGS_t, FLAGS_o); // TODO(alessiob): remove line below once debugged. rtc::LogMessage::LogToDebug(rtc::LS_VERBOSE); - LOG(LS_VERBOSE) << "i = " << settings.audiotracks_path(); - LOG(LS_VERBOSE) << "t = " << settings.timing_filepath(); - LOG(LS_VERBOSE) << "o = " << settings.output_path(); + LOG(LS_VERBOSE) << "i = " << config.audiotracks_path(); + LOG(LS_VERBOSE) << "t = " << config.timing_filepath(); + LOG(LS_VERBOSE) << "o = " << config.output_path(); return 0; } diff --git a/webrtc/modules/audio_processing/test/conversational_speech/generator_unittest.cc b/webrtc/modules/audio_processing/test/conversational_speech/generator_unittest.cc new file mode 100644 index 0000000000..da923bc448 --- /dev/null +++ b/webrtc/modules/audio_processing/test/conversational_speech/generator_unittest.cc @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2017 The WebRTC 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 "webrtc/modules/audio_processing/test/conversational_speech/config.h" +#include "webrtc/test/gtest.h" + +namespace webrtc { +namespace test { +namespace { + +const char* const audiotracks_path = "/path/to/audiotracks"; +const char* const timing_filepath = "/path/to/timing_file.txt"; +const char* const output_path = "/path/to/output_dir"; + +} // namespace + +TEST(ConversationalSpeechTest, Settings) { + conversational_speech::Config config( + audiotracks_path, timing_filepath, output_path); + + // Test getters. + EXPECT_EQ(config.audiotracks_path(), audiotracks_path); + EXPECT_EQ(config.timing_filepath(), timing_filepath); + EXPECT_EQ(config.output_path(), output_path); +} + +} // namespace test +} // namespace webrtc