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}
diff --git a/test/fake_decoder.cc b/test/fake_decoder.cc index fc38531..e816eae 100644 --- a/test/fake_decoder.cc +++ b/test/fake_decoder.cc
@@ -40,8 +40,7 @@ return true; } -int32_t FakeDecoder::Decode(const EncodedImage& input, - int64_t render_time_ms) { +int32_t FakeDecoder::Decode(const EncodedImage& input, int64_t render_time_ms) { if (input._encodedWidth > 0 && input._encodedHeight > 0) { width_ = input._encodedWidth; height_ = input._encodedHeight;
diff --git a/test/fake_decoder.h b/test/fake_decoder.h index e14eae0..8487e36 100644 --- a/test/fake_decoder.h +++ b/test/fake_decoder.h
@@ -34,8 +34,7 @@ bool Configure(const Settings& settings) override; - int32_t Decode(const EncodedImage& input, - int64_t render_time_ms) override; + int32_t Decode(const EncodedImage& input, int64_t render_time_ms) override; int32_t RegisterDecodeCompleteCallback( DecodedImageCallback* callback) override; @@ -62,8 +61,7 @@ public: virtual ~FakeH264Decoder() {} - int32_t Decode(const EncodedImage& input, - int64_t render_time_ms) override; + int32_t Decode(const EncodedImage& input, int64_t render_time_ms) override; }; } // namespace test
diff --git a/test/fake_encoder.cc b/test/fake_encoder.cc index a2f49a0..609afc5 100644 --- a/test/fake_encoder.cc +++ b/test/fake_encoder.cc
@@ -269,7 +269,7 @@ uint32_t bitrate = current_rate_settings_.bitrate.GetBitrate( spatial_idx, temporal_idx); bitrate = static_cast<uint32_t>( - (bitrate* int64_t{max_target_bitrate_kbps_}) / + (bitrate * int64_t{max_target_bitrate_kbps_}) / allocated_bitrate_kbps); current_rate_settings_.bitrate.SetBitrate(spatial_idx, temporal_idx, bitrate);
diff --git a/test/fake_vp8_decoder.h b/test/fake_vp8_decoder.h index 95cc4b6..5bfe3a4 100644 --- a/test/fake_vp8_decoder.h +++ b/test/fake_vp8_decoder.h
@@ -27,8 +27,7 @@ bool Configure(const Settings& settings) override; - int32_t Decode(const EncodedImage& input, - int64_t render_time_ms) override; + int32_t Decode(const EncodedImage& input, int64_t render_time_ms) override; int32_t RegisterDecodeCompleteCallback( DecodedImageCallback* callback) override;
diff --git a/test/fuzzers/stun_parser_fuzzer.cc b/test/fuzzers/stun_parser_fuzzer.cc index c8aad8c..95b1b14 100644 --- a/test/fuzzers/stun_parser_fuzzer.cc +++ b/test/fuzzers/stun_parser_fuzzer.cc
@@ -15,7 +15,6 @@ namespace webrtc { void FuzzOneInput(const uint8_t* data, size_t size) { - // Normally we'd check the integrity first, but those checks are // fuzzed separately in stun_validator_fuzzer.cc. We still want to // fuzz this target since the integrity checks could be forged by a
diff --git a/test/ios/coverage_util_ios.mm b/test/ios/coverage_util_ios.mm index c21a16d..0486dc4 100644 --- a/test/ios/coverage_util_ios.mm +++ b/test/ios/coverage_util_ios.mm
@@ -23,14 +23,16 @@ dispatch_once(&once_token, ^{ // Writes the profraw file to the Documents directory, where the app has // write rights. - NSArray* paths = - NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); + NSArray* paths = NSSearchPathForDirectoriesInDomains( + NSDocumentDirectory, NSUserDomainMask, YES); NSString* documents_directory = [paths firstObject]; - NSString* file_name = [documents_directory stringByAppendingPathComponent:@"coverage.profraw"]; + NSString* file_name = [documents_directory + stringByAppendingPathComponent:@"coverage.profraw"]; // For documentation, see: // 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. NSLog(@"Coverage data at %@.", file_name);
diff --git a/test/ios/google_test_runner.mm b/test/ios/google_test_runner.mm index 87b7f7d..d173b9f 100644 --- a/test/ios/google_test_runner.mm +++ b/test/ios/google_test_runner.mm
@@ -29,7 +29,8 @@ self.continueAfterFailure = false; id appDelegate = UIApplication.sharedApplication.delegate; - XCTAssertTrue([appDelegate conformsToProtocol:@protocol(GoogleTestRunnerDelegate)]); + XCTAssertTrue( + [appDelegate conformsToProtocol:@protocol(GoogleTestRunnerDelegate)]); id<GoogleTestRunnerDelegate> runnerDelegate = static_cast<id<GoogleTestRunnerDelegate>>(appDelegate);
diff --git a/test/ios/test_support.mm b/test/ios/test_support.mm index 80208d5..df8f9df 100644 --- a/test/ios/test_support.mm +++ b/test/ios/test_support.mm
@@ -38,7 +38,8 @@ // run in a row, this provides an indication of which one is currently running. // 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_argc; @@ -97,45 +98,57 @@ int exitStatus = g_test_suite(); - NSArray<NSString *> *outputDirectories = - NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); + NSArray<NSString *> *outputDirectories = NSSearchPathForDirectoriesInDomains( + NSDocumentDirectory, NSUserDomainMask, YES); std::vector<std::unique_ptr<webrtc::test::MetricsExporter>> exporters; 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) { // Stores data into a proto file under the app's document directory. NSString *fileName = @"perftest-output.pb"; 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>( - [NSString stdStringForString:outputPath])); + exporters.push_back( + std::make_unique<webrtc::test::ChromePerfDashboardMetricsExporter>( + [NSString stdStringForString:outputPath])); } } if (!g_webrtc_test_metrics_output_path.empty()) { - RTC_CHECK_EQ(g_webrtc_test_metrics_output_path.find('/'), std::string::npos) - << "On iOS, --webrtc_test_metrics_output_path must only be a file name."; + RTC_CHECK_EQ(g_webrtc_test_metrics_output_path.find('/'), + std::string::npos) + << "On iOS, --webrtc_test_metrics_output_path must only be a file " + "name."; if ([outputDirectories count] != 0) { - NSString *fileName = [NSString stringWithCString:g_webrtc_test_metrics_output_path.c_str() - encoding:[NSString defaultCStringEncoding]]; - NSString *outputPath = [outputDirectories[0] stringByAppendingPathComponent:fileName]; - exporters.push_back(std::make_unique<webrtc::test::MetricsSetProtoFileExporter>( - webrtc::test::MetricsSetProtoFileExporter::Options( - [NSString stdStringForString:outputPath]))); + NSString *fileName = [NSString + stringWithCString:g_webrtc_test_metrics_output_path.c_str() + encoding:[NSString defaultCStringEncoding]]; + NSString *outputPath = + [outputDirectories[0] stringByAppendingPathComponent:fileName]; + exporters.push_back( + std::make_unique<webrtc::test::MetricsSetProtoFileExporter>( + webrtc::test::MetricsSetProtoFileExporter::Options( + [NSString stdStringForString:outputPath]))); } } } 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_write_perf_output) { // Stores data into a proto file under the app's document directory. NSString *fileName = @"perftest-output.pb"; 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; } }
diff --git a/test/mac/run_test.mm b/test/mac/run_test.mm index 38c6c8f..b6d60ec 100644 --- a/test/mac/run_test.mm +++ b/test/mac/run_test.mm
@@ -13,9 +13,11 @@ #include "test/run_test.h" // Converting a C++ function pointer to an Objective-C block. -typedef void(^TestBlock)(); -TestBlock functionToBlock(void(*function)()) { - return [^(void) { function(); } copy]; +typedef void (^TestBlock)(); +TestBlock functionToBlock(void (*function)()) { + return [^(void) { + function(); + } copy]; } // Class calling the test function on the platform specific thread. @@ -50,7 +52,7 @@ namespace webrtc { namespace test { -void RunTest(void(*test)()) { +void RunTest(void (*test)()) { @autoreleasepool { [NSApplication sharedApplication]; @@ -63,8 +65,9 @@ withObject:testBlock]; NSRunLoop *runLoop = [NSRunLoop currentRunLoop]; - while ([testRunner running] && [runLoop runMode:NSDefaultRunLoopMode - beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]) + while ([testRunner running] && + [runLoop runMode:NSDefaultRunLoopMode + beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]) ; } }
diff --git a/test/mac/video_renderer_mac.mm b/test/mac/video_renderer_mac.mm index c8ba232..04e4b76 100644 --- a/test/mac/video_renderer_mac.mm +++ b/test/mac/video_renderer_mac.mm
@@ -31,8 +31,8 @@ @end @implementation CocoaWindow - static NSInteger nextXOrigin_; - static NSInteger nextYOrigin_; +static NSInteger nextXOrigin_; +static NSInteger nextYOrigin_; - (id)initWithTitle:(NSString *)title width:(int)width height:(int)height { self = [super init]; @@ -67,7 +67,8 @@ defer:NO]; 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]; [[window_ contentView] addSubview:view]; @@ -84,10 +85,10 @@ namespace webrtc { namespace test { -VideoRenderer* VideoRenderer::CreatePlatformRenderer(const char* window_title, +VideoRenderer *VideoRenderer::CreatePlatformRenderer(const char *window_title, size_t width, size_t height) { - MacRenderer* renderer = new MacRenderer(); + MacRenderer *renderer = new MacRenderer(); if (!renderer->Init(window_title, width, height)) { delete renderer; return NULL; @@ -95,20 +96,18 @@ return renderer; } -MacRenderer::MacRenderer() - : window_(NULL) {} +MacRenderer::MacRenderer() : window_(NULL) {} MacRenderer::~MacRenderer() { GlRenderer::Destroy(); } -bool MacRenderer::Init(const char* window_title, int width, int height) { +bool MacRenderer::Init(const char *window_title, int width, int height) { window_ = [[CocoaWindow alloc] initWithTitle:[NSString stringWithUTF8String:window_title] - width:width - height:height]; - if (!window_) - return false; + width:width + height:height]; + if (!window_) return false; [window_ performSelectorOnMainThread:@selector(createWindow:) withObject:nil waitUntilDone:YES]; @@ -119,10 +118,10 @@ return true; } -void MacRenderer::OnFrame(const VideoFrame& frame) { +void MacRenderer::OnFrame(const VideoFrame &frame) { [window_ makeCurrentContext]; GlRenderer::OnFrame(frame); } -} // test -} // webrtc +} // namespace test +} // namespace webrtc
diff --git a/test/mac_capturer.mm b/test/mac_capturer.mm index 9b14f28..bc9ea77 100644 --- a/test/mac_capturer.mm +++ b/test/mac_capturer.mm
@@ -15,7 +15,8 @@ #import "sdk/objc/native/api/video_capturer.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; @end @@ -38,15 +39,18 @@ namespace { -AVCaptureDeviceFormat *SelectClosestFormat(AVCaptureDevice *device, size_t width, size_t height) { +AVCaptureDeviceFormat *SelectClosestFormat(AVCaptureDevice *device, + size_t width, + size_t height) { NSArray<AVCaptureDeviceFormat *> *formats = [RTC_OBJC_TYPE(RTCCameraVideoCapturer) supportedFormatsForDevice:device]; AVCaptureDeviceFormat *selectedFormat = nil; int currentDiff = INT_MAX; for (AVCaptureDeviceFormat *format in formats) { - CMVideoDimensions dimension = CMVideoFormatDescriptionGetDimensions(format.formatDescription); - int diff = - std::abs((int64_t)width - dimension.width) + std::abs((int64_t)height - dimension.height); + CMVideoDimensions dimension = + CMVideoFormatDescriptionGetDimensions(format.formatDescription); + int diff = std::abs((int64_t)width - dimension.width) + + std::abs((int64_t)height - dimension.height); if (diff < currentDiff) { selectedFormat = format; currentDiff = diff; @@ -74,8 +78,8 @@ [[RTC_OBJC_TYPE(RTCCameraVideoCapturer) alloc] initWithDelegate:adapter]; capturer_ = (__bridge_retained void *)capturer; - AVCaptureDevice *device = - [[RTC_OBJC_TYPE(RTCCameraVideoCapturer) captureDevices] objectAtIndex:capture_device_index]; + AVCaptureDevice *device = [[RTC_OBJC_TYPE(RTCCameraVideoCapturer) + captureDevices] objectAtIndex:capture_device_index]; AVCaptureDeviceFormat *format = SelectClosestFormat(device, width, height); [capturer startCaptureWithDevice:device format:format fps:target_fps]; } @@ -90,7 +94,8 @@ void MacCapturer::Destroy() { #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunused-variable" - RTCTestVideoSourceAdapter *adapter = (__bridge_transfer RTCTestVideoSourceAdapter *)adapter_; + RTCTestVideoSourceAdapter *adapter = + (__bridge_transfer RTCTestVideoSourceAdapter *)adapter_; RTC_OBJC_TYPE(RTCCameraVideoCapturer) *capturer = (__bridge_transfer RTC_OBJC_TYPE(RTCCameraVideoCapturer) *)capturer_; [capturer stopCapture];
diff --git a/test/network/network_emulation_unittest.cc b/test/network/network_emulation_unittest.cc index d8455b9..a1243af 100644 --- a/test/network/network_emulation_unittest.cc +++ b/test/network/network_emulation_unittest.cc
@@ -113,7 +113,9 @@ DequeueDeliverablePackets, (int64_t), (override)); - MOCK_METHOD(std::optional<int64_t>, NextDeliveryTimeUs, (), + MOCK_METHOD(std::optional<int64_t>, + NextDeliveryTimeUs, + (), (const, override)); MOCK_METHOD(void, RegisterDeliveryTimeChangedCallback,
diff --git a/test/peer_scenario/peer_scenario_client.cc b/test/peer_scenario/peer_scenario_client.cc index 5a490ed..2a73cf2 100644 --- a/test/peer_scenario/peer_scenario_client.cc +++ b/test/peer_scenario/peer_scenario_client.cc
@@ -380,43 +380,43 @@ std::function<void()> remote_description_set, std::function<void(std::string)> answer_handler) { if (!signaling_thread_->IsCurrent()) { - signaling_thread_->PostTask([this, remote_offer, remote_description_set, - answer_handler] { - SetSdpOfferAndGetAnswer(remote_offer, remote_description_set, - answer_handler); - }); + signaling_thread_->PostTask( + [this, remote_offer, remote_description_set, answer_handler] { + SetSdpOfferAndGetAnswer(remote_offer, remote_description_set, + answer_handler); + }); return; } RTC_DCHECK_RUN_ON(signaling_thread_); peer_connection_->SetRemoteDescription( CreateSessionDescription(SdpType::kOffer, remote_offer), - rtc::make_ref_counted< - LambdaSetRemoteDescriptionObserver>([this, remote_description_set, - answer_handler](RTCError) { - RTC_DCHECK_RUN_ON(signaling_thread_); - if (remote_description_set) { - // Allow the caller to modify transceivers - // before creating the answer. - remote_description_set(); - } - peer_connection_->CreateAnswer( - rtc::make_ref_counted<LambdaCreateSessionDescriptionObserver>( - [this, answer_handler]( - std::unique_ptr<SessionDescriptionInterface> answer) { - RTC_DCHECK_RUN_ON(signaling_thread_); - std::string sdp_answer; - answer->ToString(&sdp_answer); - RTC_LOG(LS_INFO) << sdp_answer; - peer_connection_->SetLocalDescription( - std::move(answer), - rtc::make_ref_counted<LambdaSetLocalDescriptionObserver>( - [answer_handler, sdp_answer](RTCError) { - answer_handler(sdp_answer); - })); - }) - .get(), - PeerConnectionInterface::RTCOfferAnswerOptions()); - })); + rtc::make_ref_counted<LambdaSetRemoteDescriptionObserver>( + [this, remote_description_set, answer_handler](RTCError) { + RTC_DCHECK_RUN_ON(signaling_thread_); + if (remote_description_set) { + // Allow the caller to modify transceivers + // before creating the answer. + remote_description_set(); + } + peer_connection_->CreateAnswer( + rtc::make_ref_counted<LambdaCreateSessionDescriptionObserver>( + [this, answer_handler]( + std::unique_ptr<SessionDescriptionInterface> answer) { + RTC_DCHECK_RUN_ON(signaling_thread_); + std::string sdp_answer; + answer->ToString(&sdp_answer); + RTC_LOG(LS_INFO) << sdp_answer; + peer_connection_->SetLocalDescription( + std::move(answer), + rtc::make_ref_counted< + LambdaSetLocalDescriptionObserver>( + [answer_handler, sdp_answer](RTCError) { + answer_handler(sdp_answer); + })); + }) + .get(), + PeerConnectionInterface::RTCOfferAnswerOptions()); + })); } void PeerScenarioClient::SetSdpAnswer(
diff --git a/test/testsupport/ios_file_utils.mm b/test/testsupport/ios_file_utils.mm index ef36937..5c5c7f0 100644 --- a/test/testsupport/ios_file_utils.mm +++ b/test/testsupport/ios_file_utils.mm
@@ -24,7 +24,8 @@ // 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 // 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 { NSString* path = [NSString stringForAbslStringView:name]; NSString* fileName = path.lastPathComponent; @@ -46,11 +47,10 @@ // For iOS, we don't have access to the output directory. Return the path to the // temporary directory instead. This is mostly used by tests that need to write // output files to disk. -std::string IOSOutputPath() { +std::string IOSOutputPath() { @autoreleasepool { NSString* tempDir = NSTemporaryDirectory(); - if (tempDir == nil) - tempDir = @"/tmp"; + if (tempDir == nil) tempDir = @"/tmp"; return [NSString stdStringForString:tempDir]; } }
diff --git a/test/time_controller/simulated_task_queue.cc b/test/time_controller/simulated_task_queue.cc index 66b3fd8..3d786df 100644 --- a/test/time_controller/simulated_task_queue.cc +++ b/test/time_controller/simulated_task_queue.cc
@@ -52,7 +52,7 @@ } CurrentTaskQueueSetter set_current(this); while (!ready_tasks_.empty()) { - absl::AnyInvocable<void()&&> ready = std::move(ready_tasks_.front()); + absl::AnyInvocable<void() &&> ready = std::move(ready_tasks_.front()); ready_tasks_.pop_front(); lock_.Unlock(); std::move(ready)();
diff --git a/test/video_codec_tester.cc b/test/video_codec_tester.cc index 2782a66..192bb4e 100644 --- a/test/video_codec_tester.cc +++ b/test/video_codec_tester.cc
@@ -1674,13 +1674,13 @@ frame_settings.layers_settings.rbegin()->second; VideoFrame source_frame = video_source.PullFrame( timestamp_rtp, top_layer.resolution, top_layer.framerate); - encoder.Encode(source_frame, frame_settings, - [&decoders, - source_frame](const EncodedImage& encoded_frame) { - int sidx = encoded_frame.SpatialIndex().value_or( - encoded_frame.SimulcastIndex().value_or(0)); - decoders.at(sidx)->Decode(encoded_frame, source_frame); - }); + encoder.Encode( + source_frame, frame_settings, + [&decoders, source_frame](const EncodedImage& encoded_frame) { + int sidx = encoded_frame.SpatialIndex().value_or( + encoded_frame.SimulcastIndex().value_or(0)); + decoders.at(sidx)->Decode(encoded_frame, source_frame); + }); } encoder.Flush();