Format /test folder

Formatting done via:

git ls-files | grep -E '^test\/.*\.(h|cc|mm)' | xargs clang-format -i

No-Iwyu: Includes didn't change and it isn't related to formatting
Bug: webrtc:42225392
Change-Id: I3a75019dee1ad9bef713d80a5f79cbc56adab472
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/373903
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#43690}
This commit is contained in:
Boris Tsirkin 2025-01-08 06:00:52 -08:00 committed by WebRTC LUCI CQ
parent 825379f4dc
commit 557d387a2e
16 changed files with 128 additions and 108 deletions

View File

@ -40,8 +40,7 @@ bool FakeDecoder::Configure(const Settings& settings) {
return true; return true;
} }
int32_t FakeDecoder::Decode(const EncodedImage& input, int32_t FakeDecoder::Decode(const EncodedImage& input, int64_t render_time_ms) {
int64_t render_time_ms) {
if (input._encodedWidth > 0 && input._encodedHeight > 0) { if (input._encodedWidth > 0 && input._encodedHeight > 0) {
width_ = input._encodedWidth; width_ = input._encodedWidth;
height_ = input._encodedHeight; height_ = input._encodedHeight;

View File

@ -34,8 +34,7 @@ class FakeDecoder : public VideoDecoder {
bool Configure(const Settings& settings) override; bool Configure(const Settings& settings) override;
int32_t Decode(const EncodedImage& input, int32_t Decode(const EncodedImage& input, int64_t render_time_ms) override;
int64_t render_time_ms) override;
int32_t RegisterDecodeCompleteCallback( int32_t RegisterDecodeCompleteCallback(
DecodedImageCallback* callback) override; DecodedImageCallback* callback) override;
@ -62,8 +61,7 @@ class FakeH264Decoder : public FakeDecoder {
public: public:
virtual ~FakeH264Decoder() {} virtual ~FakeH264Decoder() {}
int32_t Decode(const EncodedImage& input, int32_t Decode(const EncodedImage& input, int64_t render_time_ms) override;
int64_t render_time_ms) override;
}; };
} // namespace test } // namespace test

View File

@ -27,8 +27,7 @@ class FakeVp8Decoder : public VideoDecoder {
bool Configure(const Settings& settings) override; bool Configure(const Settings& settings) override;
int32_t Decode(const EncodedImage& input, int32_t Decode(const EncodedImage& input, int64_t render_time_ms) override;
int64_t render_time_ms) override;
int32_t RegisterDecodeCompleteCallback( int32_t RegisterDecodeCompleteCallback(
DecodedImageCallback* callback) override; DecodedImageCallback* callback) override;

View File

@ -15,7 +15,6 @@
namespace webrtc { namespace webrtc {
void FuzzOneInput(const uint8_t* data, size_t size) { void FuzzOneInput(const uint8_t* data, size_t size) {
// Normally we'd check the integrity first, but those checks are // Normally we'd check the integrity first, but those checks are
// fuzzed separately in stun_validator_fuzzer.cc. We still want to // fuzzed separately in stun_validator_fuzzer.cc. We still want to
// fuzz this target since the integrity checks could be forged by a // fuzz this target since the integrity checks could be forged by a

View File

@ -23,14 +23,16 @@ void ConfigureCoverageReportPath() {
dispatch_once(&once_token, ^{ dispatch_once(&once_token, ^{
// Writes the profraw file to the Documents directory, where the app has // Writes the profraw file to the Documents directory, where the app has
// write rights. // write rights.
NSArray* paths = NSArray* paths = NSSearchPathForDirectoriesInDomains(
NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSDocumentDirectory, NSUserDomainMask, YES);
NSString* documents_directory = [paths firstObject]; NSString* documents_directory = [paths firstObject];
NSString* file_name = [documents_directory stringByAppendingPathComponent:@"coverage.profraw"]; NSString* file_name = [documents_directory
stringByAppendingPathComponent:@"coverage.profraw"];
// For documentation, see: // For documentation, see:
// http://clang.llvm.org/docs/SourceBasedCodeCoverage.html // http://clang.llvm.org/docs/SourceBasedCodeCoverage.html
__llvm_profile_set_filename([file_name cStringUsingEncoding:NSUTF8StringEncoding]); __llvm_profile_set_filename(
[file_name cStringUsingEncoding:NSUTF8StringEncoding]);
// Print the path for easier retrieval. // Print the path for easier retrieval.
NSLog(@"Coverage data at %@.", file_name); NSLog(@"Coverage data at %@.", file_name);

View File

@ -29,7 +29,8 @@
self.continueAfterFailure = false; self.continueAfterFailure = false;
id appDelegate = UIApplication.sharedApplication.delegate; id appDelegate = UIApplication.sharedApplication.delegate;
XCTAssertTrue([appDelegate conformsToProtocol:@protocol(GoogleTestRunnerDelegate)]); XCTAssertTrue(
[appDelegate conformsToProtocol:@protocol(GoogleTestRunnerDelegate)]);
id<GoogleTestRunnerDelegate> runnerDelegate = id<GoogleTestRunnerDelegate> runnerDelegate =
static_cast<id<GoogleTestRunnerDelegate>>(appDelegate); static_cast<id<GoogleTestRunnerDelegate>>(appDelegate);

View File

@ -38,7 +38,8 @@
// run in a row, this provides an indication of which one is currently running. // run in a row, this provides an indication of which one is currently running.
// If enabled, runs unittests using the XCTest test runner. // If enabled, runs unittests using the XCTest test runner.
const char kEnableRunIOSUnittestsWithXCTest[] = "enable-run-ios-unittests-with-xctest"; const char kEnableRunIOSUnittestsWithXCTest[] =
"enable-run-ios-unittests-with-xctest";
static int (*g_test_suite)(void) = NULL; static int (*g_test_suite)(void) = NULL;
static int g_argc; static int g_argc;
@ -97,45 +98,57 @@ static std::optional<std::vector<std::string>> g_metrics_to_plot;
int exitStatus = g_test_suite(); int exitStatus = g_test_suite();
NSArray<NSString *> *outputDirectories = NSArray<NSString *> *outputDirectories = NSSearchPathForDirectoriesInDomains(
NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSDocumentDirectory, NSUserDomainMask, YES);
std::vector<std::unique_ptr<webrtc::test::MetricsExporter>> exporters; std::vector<std::unique_ptr<webrtc::test::MetricsExporter>> exporters;
if (g_export_perf_results_new_api) { if (g_export_perf_results_new_api) {
exporters.push_back(std::make_unique<webrtc::test::StdoutMetricsExporter>()); exporters.push_back(
std::make_unique<webrtc::test::StdoutMetricsExporter>());
if (g_write_perf_output) { if (g_write_perf_output) {
// Stores data into a proto file under the app's document directory. // Stores data into a proto file under the app's document directory.
NSString *fileName = @"perftest-output.pb"; NSString *fileName = @"perftest-output.pb";
if ([outputDirectories count] != 0) { if ([outputDirectories count] != 0) {
NSString *outputPath = [outputDirectories[0] stringByAppendingPathComponent:fileName]; NSString *outputPath =
[outputDirectories[0] stringByAppendingPathComponent:fileName];
exporters.push_back(std::make_unique<webrtc::test::ChromePerfDashboardMetricsExporter>( exporters.push_back(
std::make_unique<webrtc::test::ChromePerfDashboardMetricsExporter>(
[NSString stdStringForString:outputPath])); [NSString stdStringForString:outputPath]));
} }
} }
if (!g_webrtc_test_metrics_output_path.empty()) { if (!g_webrtc_test_metrics_output_path.empty()) {
RTC_CHECK_EQ(g_webrtc_test_metrics_output_path.find('/'), std::string::npos) RTC_CHECK_EQ(g_webrtc_test_metrics_output_path.find('/'),
<< "On iOS, --webrtc_test_metrics_output_path must only be a file name."; std::string::npos)
<< "On iOS, --webrtc_test_metrics_output_path must only be a file "
"name.";
if ([outputDirectories count] != 0) { if ([outputDirectories count] != 0) {
NSString *fileName = [NSString stringWithCString:g_webrtc_test_metrics_output_path.c_str() NSString *fileName = [NSString
stringWithCString:g_webrtc_test_metrics_output_path.c_str()
encoding:[NSString defaultCStringEncoding]]; encoding:[NSString defaultCStringEncoding]];
NSString *outputPath = [outputDirectories[0] stringByAppendingPathComponent:fileName]; NSString *outputPath =
exporters.push_back(std::make_unique<webrtc::test::MetricsSetProtoFileExporter>( [outputDirectories[0] stringByAppendingPathComponent:fileName];
exporters.push_back(
std::make_unique<webrtc::test::MetricsSetProtoFileExporter>(
webrtc::test::MetricsSetProtoFileExporter::Options( webrtc::test::MetricsSetProtoFileExporter::Options(
[NSString stdStringForString:outputPath]))); [NSString stdStringForString:outputPath])));
} }
} }
} else { } else {
exporters.push_back(std::make_unique<webrtc::test::PrintResultProxyMetricsExporter>()); exporters.push_back(
std::make_unique<webrtc::test::PrintResultProxyMetricsExporter>());
} }
webrtc::test::ExportPerfMetric(*webrtc::test::GetGlobalMetricsLogger(), std::move(exporters)); webrtc::test::ExportPerfMetric(*webrtc::test::GetGlobalMetricsLogger(),
std::move(exporters));
if (!g_export_perf_results_new_api) { if (!g_export_perf_results_new_api) {
if (g_write_perf_output) { if (g_write_perf_output) {
// Stores data into a proto file under the app's document directory. // Stores data into a proto file under the app's document directory.
NSString *fileName = @"perftest-output.pb"; NSString *fileName = @"perftest-output.pb";
if ([outputDirectories count] != 0) { if ([outputDirectories count] != 0) {
NSString *outputPath = [outputDirectories[0] stringByAppendingPathComponent:fileName]; NSString *outputPath =
[outputDirectories[0] stringByAppendingPathComponent:fileName];
if (!webrtc::test::WritePerfResults([NSString stdStringForString:outputPath])) { if (!webrtc::test::WritePerfResults(
[NSString stdStringForString:outputPath])) {
return 1; return 1;
} }
} }

View File

@ -15,7 +15,9 @@
// Converting a C++ function pointer to an Objective-C block. // Converting a C++ function pointer to an Objective-C block.
typedef void (^TestBlock)(); typedef void (^TestBlock)();
TestBlock functionToBlock(void (*function)()) { TestBlock functionToBlock(void (*function)()) {
return [^(void) { function(); } copy]; return [^(void) {
function();
} copy];
} }
// Class calling the test function on the platform specific thread. // Class calling the test function on the platform specific thread.
@ -63,7 +65,8 @@ void RunTest(void(*test)()) {
withObject:testBlock]; withObject:testBlock];
NSRunLoop *runLoop = [NSRunLoop currentRunLoop]; NSRunLoop *runLoop = [NSRunLoop currentRunLoop];
while ([testRunner running] && [runLoop runMode:NSDefaultRunLoopMode while ([testRunner running] &&
[runLoop runMode:NSDefaultRunLoopMode
beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]) beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]])
; ;
} }

View File

@ -67,7 +67,8 @@
defer:NO]; defer:NO];
NSRect viewFrame = NSMakeRect(0, 0, width_, height_); NSRect viewFrame = NSMakeRect(0, 0, width_, height_);
NSOpenGLView *view = [[NSOpenGLView alloc] initWithFrame:viewFrame pixelFormat:nil]; NSOpenGLView *view = [[NSOpenGLView alloc] initWithFrame:viewFrame
pixelFormat:nil];
context_ = [view openGLContext]; context_ = [view openGLContext];
[[window_ contentView] addSubview:view]; [[window_ contentView] addSubview:view];
@ -95,8 +96,7 @@ VideoRenderer* VideoRenderer::CreatePlatformRenderer(const char* window_title,
return renderer; return renderer;
} }
MacRenderer::MacRenderer() MacRenderer::MacRenderer() : window_(NULL) {}
: window_(NULL) {}
MacRenderer::~MacRenderer() { MacRenderer::~MacRenderer() {
GlRenderer::Destroy(); GlRenderer::Destroy();
@ -107,8 +107,7 @@ bool MacRenderer::Init(const char* window_title, int width, int height) {
initWithTitle:[NSString stringWithUTF8String:window_title] initWithTitle:[NSString stringWithUTF8String:window_title]
width:width width:width
height:height]; height:height];
if (!window_) if (!window_) return false;
return false;
[window_ performSelectorOnMainThread:@selector(createWindow:) [window_ performSelectorOnMainThread:@selector(createWindow:)
withObject:nil withObject:nil
waitUntilDone:YES]; waitUntilDone:YES];
@ -124,5 +123,5 @@ void MacRenderer::OnFrame(const VideoFrame& frame) {
GlRenderer::OnFrame(frame); GlRenderer::OnFrame(frame);
} }
} // test } // namespace test
} // webrtc } // namespace webrtc

View File

@ -15,7 +15,8 @@
#import "sdk/objc/native/api/video_capturer.h" #import "sdk/objc/native/api/video_capturer.h"
#import "sdk/objc/native/src/objc_frame_buffer.h" #import "sdk/objc/native/src/objc_frame_buffer.h"
@interface RTCTestVideoSourceAdapter : NSObject <RTC_OBJC_TYPE (RTCVideoCapturerDelegate)> @interface RTCTestVideoSourceAdapter
: NSObject <RTC_OBJC_TYPE (RTCVideoCapturerDelegate)>
@property(nonatomic) webrtc::test::MacCapturer *capturer; @property(nonatomic) webrtc::test::MacCapturer *capturer;
@end @end
@ -38,15 +39,18 @@
namespace { namespace {
AVCaptureDeviceFormat *SelectClosestFormat(AVCaptureDevice *device, size_t width, size_t height) { AVCaptureDeviceFormat *SelectClosestFormat(AVCaptureDevice *device,
size_t width,
size_t height) {
NSArray<AVCaptureDeviceFormat *> *formats = NSArray<AVCaptureDeviceFormat *> *formats =
[RTC_OBJC_TYPE(RTCCameraVideoCapturer) supportedFormatsForDevice:device]; [RTC_OBJC_TYPE(RTCCameraVideoCapturer) supportedFormatsForDevice:device];
AVCaptureDeviceFormat *selectedFormat = nil; AVCaptureDeviceFormat *selectedFormat = nil;
int currentDiff = INT_MAX; int currentDiff = INT_MAX;
for (AVCaptureDeviceFormat *format in formats) { for (AVCaptureDeviceFormat *format in formats) {
CMVideoDimensions dimension = CMVideoFormatDescriptionGetDimensions(format.formatDescription); CMVideoDimensions dimension =
int diff = CMVideoFormatDescriptionGetDimensions(format.formatDescription);
std::abs((int64_t)width - dimension.width) + std::abs((int64_t)height - dimension.height); int diff = std::abs((int64_t)width - dimension.width) +
std::abs((int64_t)height - dimension.height);
if (diff < currentDiff) { if (diff < currentDiff) {
selectedFormat = format; selectedFormat = format;
currentDiff = diff; currentDiff = diff;
@ -74,8 +78,8 @@ MacCapturer::MacCapturer(size_t width,
[[RTC_OBJC_TYPE(RTCCameraVideoCapturer) alloc] initWithDelegate:adapter]; [[RTC_OBJC_TYPE(RTCCameraVideoCapturer) alloc] initWithDelegate:adapter];
capturer_ = (__bridge_retained void *)capturer; capturer_ = (__bridge_retained void *)capturer;
AVCaptureDevice *device = AVCaptureDevice *device = [[RTC_OBJC_TYPE(RTCCameraVideoCapturer)
[[RTC_OBJC_TYPE(RTCCameraVideoCapturer) captureDevices] objectAtIndex:capture_device_index]; captureDevices] objectAtIndex:capture_device_index];
AVCaptureDeviceFormat *format = SelectClosestFormat(device, width, height); AVCaptureDeviceFormat *format = SelectClosestFormat(device, width, height);
[capturer startCaptureWithDevice:device format:format fps:target_fps]; [capturer startCaptureWithDevice:device format:format fps:target_fps];
} }
@ -90,7 +94,8 @@ MacCapturer *MacCapturer::Create(size_t width,
void MacCapturer::Destroy() { void MacCapturer::Destroy() {
#pragma clang diagnostic push #pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-variable" #pragma clang diagnostic ignored "-Wunused-variable"
RTCTestVideoSourceAdapter *adapter = (__bridge_transfer RTCTestVideoSourceAdapter *)adapter_; RTCTestVideoSourceAdapter *adapter =
(__bridge_transfer RTCTestVideoSourceAdapter *)adapter_;
RTC_OBJC_TYPE(RTCCameraVideoCapturer) *capturer = RTC_OBJC_TYPE(RTCCameraVideoCapturer) *capturer =
(__bridge_transfer RTC_OBJC_TYPE(RTCCameraVideoCapturer) *)capturer_; (__bridge_transfer RTC_OBJC_TYPE(RTCCameraVideoCapturer) *)capturer_;
[capturer stopCapture]; [capturer stopCapture];

View File

@ -113,7 +113,9 @@ class MockNetworkBehaviourInterface : public NetworkBehaviorInterface {
DequeueDeliverablePackets, DequeueDeliverablePackets,
(int64_t), (int64_t),
(override)); (override));
MOCK_METHOD(std::optional<int64_t>, NextDeliveryTimeUs, (), MOCK_METHOD(std::optional<int64_t>,
NextDeliveryTimeUs,
(),
(const, override)); (const, override));
MOCK_METHOD(void, MOCK_METHOD(void,
RegisterDeliveryTimeChangedCallback, RegisterDeliveryTimeChangedCallback,

View File

@ -380,8 +380,8 @@ void PeerScenarioClient::SetSdpOfferAndGetAnswer(
std::function<void()> remote_description_set, std::function<void()> remote_description_set,
std::function<void(std::string)> answer_handler) { std::function<void(std::string)> answer_handler) {
if (!signaling_thread_->IsCurrent()) { if (!signaling_thread_->IsCurrent()) {
signaling_thread_->PostTask([this, remote_offer, remote_description_set, signaling_thread_->PostTask(
answer_handler] { [this, remote_offer, remote_description_set, answer_handler] {
SetSdpOfferAndGetAnswer(remote_offer, remote_description_set, SetSdpOfferAndGetAnswer(remote_offer, remote_description_set,
answer_handler); answer_handler);
}); });
@ -390,9 +390,8 @@ void PeerScenarioClient::SetSdpOfferAndGetAnswer(
RTC_DCHECK_RUN_ON(signaling_thread_); RTC_DCHECK_RUN_ON(signaling_thread_);
peer_connection_->SetRemoteDescription( peer_connection_->SetRemoteDescription(
CreateSessionDescription(SdpType::kOffer, remote_offer), CreateSessionDescription(SdpType::kOffer, remote_offer),
rtc::make_ref_counted< rtc::make_ref_counted<LambdaSetRemoteDescriptionObserver>(
LambdaSetRemoteDescriptionObserver>([this, remote_description_set, [this, remote_description_set, answer_handler](RTCError) {
answer_handler](RTCError) {
RTC_DCHECK_RUN_ON(signaling_thread_); RTC_DCHECK_RUN_ON(signaling_thread_);
if (remote_description_set) { if (remote_description_set) {
// Allow the caller to modify transceivers // Allow the caller to modify transceivers
@ -409,7 +408,8 @@ void PeerScenarioClient::SetSdpOfferAndGetAnswer(
RTC_LOG(LS_INFO) << sdp_answer; RTC_LOG(LS_INFO) << sdp_answer;
peer_connection_->SetLocalDescription( peer_connection_->SetLocalDescription(
std::move(answer), std::move(answer),
rtc::make_ref_counted<LambdaSetLocalDescriptionObserver>( rtc::make_ref_counted<
LambdaSetLocalDescriptionObserver>(
[answer_handler, sdp_answer](RTCError) { [answer_handler, sdp_answer](RTCError) {
answer_handler(sdp_answer); answer_handler(sdp_answer);
})); }));

View File

@ -24,7 +24,8 @@ namespace test {
// For iOS, resource files are added to the application bundle in the root // For iOS, resource files are added to the application bundle in the root
// and not in separate folders as is the case for other platforms. This method // and not in separate folders as is the case for other platforms. This method
// therefore removes any prepended folders and uses only the actual file name. // therefore removes any prepended folders and uses only the actual file name.
std::string IOSResourcePath(absl::string_view name, absl::string_view extension) { std::string IOSResourcePath(absl::string_view name,
absl::string_view extension) {
@autoreleasepool { @autoreleasepool {
NSString* path = [NSString stringForAbslStringView:name]; NSString* path = [NSString stringForAbslStringView:name];
NSString* fileName = path.lastPathComponent; NSString* fileName = path.lastPathComponent;
@ -49,8 +50,7 @@ std::string IOSRootPath() {
std::string IOSOutputPath() { std::string IOSOutputPath() {
@autoreleasepool { @autoreleasepool {
NSString* tempDir = NSTemporaryDirectory(); NSString* tempDir = NSTemporaryDirectory();
if (tempDir == nil) if (tempDir == nil) tempDir = @"/tmp";
tempDir = @"/tmp";
return [NSString stdStringForString:tempDir]; return [NSString stdStringForString:tempDir];
} }
} }

View File

@ -1674,9 +1674,9 @@ VideoCodecTester::RunEncodeDecodeTest(
frame_settings.layers_settings.rbegin()->second; frame_settings.layers_settings.rbegin()->second;
VideoFrame source_frame = video_source.PullFrame( VideoFrame source_frame = video_source.PullFrame(
timestamp_rtp, top_layer.resolution, top_layer.framerate); timestamp_rtp, top_layer.resolution, top_layer.framerate);
encoder.Encode(source_frame, frame_settings, encoder.Encode(
[&decoders, source_frame, frame_settings,
source_frame](const EncodedImage& encoded_frame) { [&decoders, source_frame](const EncodedImage& encoded_frame) {
int sidx = encoded_frame.SpatialIndex().value_or( int sidx = encoded_frame.SpatialIndex().value_or(
encoded_frame.SimulcastIndex().value_or(0)); encoded_frame.SimulcastIndex().value_or(0));
decoders.at(sidx)->Decode(encoded_frame, source_frame); decoders.at(sidx)->Decode(encoded_frame, source_frame);