Migrate WebRTC test infra to ABSL_FLAG.
This is the last CL required to migrate WebRTC to ABSL_FLAG, rtc::Flag will be removed soon after this one lands. Bug: webrtc:10616 Change-Id: I2807cec39e28a2737d2c49e2dc23f2a6f98d08f0 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/145727 Reviewed-by: Tommi <tommi@webrtc.org> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#28606}
This commit is contained in:

committed by
Commit Bot

parent
63741c7fa1
commit
2ab97f6f8e
@ -190,7 +190,6 @@ if (rtc_include_tests) {
|
||||
"../api:simulated_network_api",
|
||||
"../call:simulated_network",
|
||||
"../common_audio",
|
||||
"../rtc_base:rtc_base_approved",
|
||||
"../system_wrappers",
|
||||
"../test:fileutils",
|
||||
"../test:perf_test",
|
||||
@ -199,7 +198,8 @@ if (rtc_include_tests) {
|
||||
"../test:test_support",
|
||||
"../test/pc/e2e:network_quality_metrics_reporter",
|
||||
"//testing/gtest",
|
||||
"//third_party/abseil-cpp/absl/memory:memory",
|
||||
"//third_party/abseil-cpp/absl/flags:flag",
|
||||
"//third_party/abseil-cpp/absl/memory",
|
||||
]
|
||||
if (is_android) {
|
||||
deps += [ "//testing/android/native_test:native_test_native_code" ]
|
||||
|
@ -8,21 +8,21 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "absl/flags/flag.h"
|
||||
#include "api/test/simulated_network.h"
|
||||
#include "audio/test/audio_end_to_end_test.h"
|
||||
#include "rtc_base/flags.h"
|
||||
#include "system_wrappers/include/sleep.h"
|
||||
#include "test/testsupport/file_utils.h"
|
||||
|
||||
WEBRTC_DECLARE_int(sample_rate_hz);
|
||||
WEBRTC_DECLARE_bool(quick);
|
||||
ABSL_DECLARE_FLAG(int, sample_rate_hz);
|
||||
ABSL_DECLARE_FLAG(bool, quick);
|
||||
|
||||
namespace webrtc {
|
||||
namespace test {
|
||||
namespace {
|
||||
|
||||
std::string FileSampleRateSuffix() {
|
||||
return std::to_string(FLAG_sample_rate_hz / 1000);
|
||||
return std::to_string(absl::GetFlag(FLAGS_sample_rate_hz) / 1000);
|
||||
}
|
||||
|
||||
class AudioQualityTest : public AudioEndToEndTest {
|
||||
@ -48,11 +48,11 @@ class AudioQualityTest : public AudioEndToEndTest {
|
||||
|
||||
std::unique_ptr<TestAudioDeviceModule::Renderer> CreateRenderer() override {
|
||||
return TestAudioDeviceModule::CreateBoundedWavFileWriter(
|
||||
AudioOutputFile(), FLAG_sample_rate_hz);
|
||||
AudioOutputFile(), absl::GetFlag(FLAGS_sample_rate_hz));
|
||||
}
|
||||
|
||||
void PerformTest() override {
|
||||
if (FLAG_quick) {
|
||||
if (absl::GetFlag(FLAGS_quick)) {
|
||||
// Let the recording run for a small amount of time to check if it works.
|
||||
SleepMs(1000);
|
||||
} else {
|
||||
|
@ -10,18 +10,19 @@
|
||||
// #ifndef AUDIO_TEST_LOW_BANDWIDTH_AUDIO_TEST_FLAGS_H_
|
||||
// #define AUDIO_TEST_LOW_BANDWIDTH_AUDIO_TEST_FLAGS_H_
|
||||
|
||||
#include "rtc_base/flags.h"
|
||||
#include "absl/flags/flag.h"
|
||||
|
||||
WEBRTC_DEFINE_int(sample_rate_hz,
|
||||
16000,
|
||||
"Sample rate (Hz) of the produced audio files.");
|
||||
ABSL_FLAG(int,
|
||||
sample_rate_hz,
|
||||
16000,
|
||||
"Sample rate (Hz) of the produced audio files.");
|
||||
|
||||
WEBRTC_DEFINE_bool(
|
||||
quick,
|
||||
false,
|
||||
"Don't do the full audio recording. "
|
||||
"Used to quickly check that the test runs without crashing.");
|
||||
ABSL_FLAG(bool,
|
||||
quick,
|
||||
false,
|
||||
"Don't do the full audio recording. "
|
||||
"Used to quickly check that the test runs without crashing.");
|
||||
|
||||
WEBRTC_DEFINE_string(test_case_prefix, "", "Test case prefix.");
|
||||
ABSL_FLAG(std::string, test_case_prefix, "", "Test case prefix.");
|
||||
|
||||
// #endif // AUDIO_TEST_LOW_BANDWIDTH_AUDIO_TEST_FLAGS_H_
|
||||
|
@ -8,6 +8,7 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "absl/flags/flag.h"
|
||||
#include "absl/memory/memory.h"
|
||||
#include "api/test/create_network_emulation_manager.h"
|
||||
#include "api/test/create_peerconnection_quality_test_fixture.h"
|
||||
@ -15,15 +16,14 @@
|
||||
#include "api/test/peerconnection_quality_test_fixture.h"
|
||||
#include "api/test/simulated_network.h"
|
||||
#include "call/simulated_network.h"
|
||||
#include "rtc_base/flags.h"
|
||||
#include "test/gtest.h"
|
||||
#include "test/pc/e2e/network_quality_metrics_reporter.h"
|
||||
#include "test/testsupport/file_utils.h"
|
||||
#include "test/testsupport/perf_test.h"
|
||||
|
||||
WEBRTC_DECLARE_string(test_case_prefix);
|
||||
WEBRTC_DECLARE_int(sample_rate_hz);
|
||||
WEBRTC_DECLARE_bool(quick);
|
||||
ABSL_DECLARE_FLAG(std::string, test_case_prefix);
|
||||
ABSL_DECLARE_FLAG(int, sample_rate_hz);
|
||||
ABSL_DECLARE_FLAG(bool, quick);
|
||||
|
||||
namespace webrtc {
|
||||
namespace test {
|
||||
@ -42,11 +42,11 @@ constexpr int kQuickTestDurationSec = 1;
|
||||
std::string GetMetricTestCaseName() {
|
||||
const ::testing::TestInfo* const test_info =
|
||||
::testing::UnitTest::GetInstance()->current_test_info();
|
||||
std::string test_case_prefix(FLAG_test_case_prefix);
|
||||
std::string test_case_prefix(absl::GetFlag(FLAGS_test_case_prefix));
|
||||
if (test_case_prefix.empty()) {
|
||||
return test_info->name();
|
||||
}
|
||||
return std::string(FLAG_test_case_prefix) + "_" + test_info->name();
|
||||
return test_case_prefix + "_" + test_info->name();
|
||||
}
|
||||
|
||||
std::pair<EmulatedNetworkManagerInterface*, EmulatedNetworkManagerInterface*>
|
||||
@ -87,7 +87,7 @@ CreateTestFixture(const std::string& test_case_name,
|
||||
}
|
||||
|
||||
std::string FileSampleRateSuffix() {
|
||||
return std::to_string(FLAG_sample_rate_hz / 1000);
|
||||
return std::to_string(absl::GetFlag(FLAGS_sample_rate_hz) / 1000);
|
||||
}
|
||||
|
||||
std::string AudioInputFile() {
|
||||
@ -135,12 +135,12 @@ TEST(PCLowBandwidthAudioTest, PCGoodNetworkHighBitrate) {
|
||||
audio.mode = AudioConfig::Mode::kFile;
|
||||
audio.input_file_name = AudioInputFile();
|
||||
audio.output_dump_file_name = AudioOutputFile();
|
||||
audio.sampling_frequency_in_hz = FLAG_sample_rate_hz;
|
||||
audio.sampling_frequency_in_hz = absl::GetFlag(FLAGS_sample_rate_hz);
|
||||
alice->SetAudioConfig(std::move(audio));
|
||||
},
|
||||
[](PeerConfigurer* bob) {});
|
||||
fixture->Run(RunParams(TimeDelta::seconds(FLAG_quick ? kQuickTestDurationSec
|
||||
: kTestDurationSec)));
|
||||
fixture->Run(RunParams(TimeDelta::seconds(
|
||||
absl::GetFlag(FLAGS_quick) ? kQuickTestDurationSec : kTestDurationSec)));
|
||||
LogTestResults();
|
||||
}
|
||||
|
||||
@ -160,12 +160,12 @@ TEST(PCLowBandwidthAudioTest, PCMobile2GNetwork) {
|
||||
audio.mode = AudioConfig::Mode::kFile;
|
||||
audio.input_file_name = AudioInputFile();
|
||||
audio.output_dump_file_name = AudioOutputFile();
|
||||
audio.sampling_frequency_in_hz = FLAG_sample_rate_hz;
|
||||
audio.sampling_frequency_in_hz = absl::GetFlag(FLAGS_sample_rate_hz);
|
||||
alice->SetAudioConfig(std::move(audio));
|
||||
},
|
||||
[](PeerConfigurer* bob) {});
|
||||
fixture->Run(RunParams(TimeDelta::seconds(FLAG_quick ? kQuickTestDurationSec
|
||||
: kTestDurationSec)));
|
||||
fixture->Run(RunParams(TimeDelta::seconds(
|
||||
absl::GetFlag(FLAGS_quick) ? kQuickTestDurationSec : kTestDurationSec)));
|
||||
LogTestResults();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user