From 51f8a2a90bddca7d6b72b4170b10caae45dcac7b Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Thu, 4 Apr 2019 21:36:16 +0000 Subject: [PATCH] Bug 1519636 - clang-format-8: Reformat recent changes to the Google coding style r=Ehsan clang-format-8 upstream had some improvements wrt macros See: https://reviews.llvm.org/D33440 This is why the diff is bigger than usual # ignore-this-changeset Differential Revision: https://phabricator.services.mozilla.com/D26098 --- accessible/base/MarkupMap.h | 669 +++++++++--------- caps/tests/gtest/TestOriginAttributes.cpp | 9 +- dom/base/AnonymousContent.cpp | 3 +- dom/base/DocGroup.cpp | 29 +- dom/base/Document.cpp | 27 +- dom/base/TreeOrderedArrayInlines.h | 3 +- dom/base/UIDirectionManager.cpp | 3 +- dom/base/nsAttrValue.cpp | 4 +- dom/base/nsAttrValueInlines.h | 4 +- dom/base/nsCCUncollectableMarker.cpp | 4 +- dom/base/test/gtest/TestContentUtils.cpp | 6 +- dom/base/test/gtest/TestMimeType.cpp | 461 +++++++----- .../test/gtest/TestPlainTextSerializer.cpp | 50 +- dom/base/test/gtest/TestXPathGenerator.cpp | 27 +- dom/cache/Context.cpp | 4 +- dom/canvas/CanvasRenderingContext2D.cpp | 2 +- dom/canvas/WebGLContextVertices.cpp | 4 +- dom/canvas/WebGLTexelConversions.h | 26 +- dom/canvas/WebGLTexture.h | 3 +- dom/canvas/WebGLTypes.h | 10 +- .../gtest/TestImageBitmapColorUtils.cpp | 225 ++++-- dom/clients/api/Client.cpp | 27 +- dom/clients/api/ClientDOMUtil.h | 19 +- dom/clients/api/Clients.cpp | 49 +- dom/clients/manager/ClientHandle.cpp | 47 +- dom/clients/manager/ClientHandleOpParent.cpp | 19 +- dom/clients/manager/ClientManagerOpParent.cpp | 19 +- dom/clients/manager/ClientNavigateOpChild.cpp | 19 +- .../manager/ClientOpenWindowOpChild.cpp | 19 +- dom/clients/manager/ClientOpenWindowUtils.cpp | 7 +- dom/clients/manager/ClientPrincipalUtils.cpp | 4 +- dom/clients/manager/ClientSource.cpp | 19 +- dom/clients/manager/ClientSourceOpChild.cpp | 19 +- dom/clients/manager/ClientThing.h | 4 +- dom/clients/manager/ClientValidation.cpp | 8 +- dom/encoding/FallbackEncoding.cpp | 11 +- dom/events/EventStateManager.cpp | 4 +- dom/html/HTMLMediaElement.cpp | 56 +- dom/indexedDB/ActorsChild.cpp | 15 +- dom/ipc/SharedStringMap.cpp | 11 +- dom/ipc/TabContext.cpp | 4 +- dom/ipc/TabParent.cpp | 58 +- .../test/gtest/TestLocalStorage.cpp | 15 +- dom/media/Benchmark.cpp | 66 +- dom/media/ChannelMediaDecoder.cpp | 27 +- dom/media/DOMMediaStream.cpp | 11 +- dom/media/MediaDecoderStateMachine.cpp | 300 ++++---- dom/media/MediaDevices.cpp | 127 ++-- dom/media/MediaFormatReader.cpp | 378 +++++----- dom/media/MediaManager.cpp | 238 ++++--- dom/media/MediaRecorder.cpp | 34 +- dom/media/ReaderProxy.cpp | 25 +- dom/media/VideoFrameConverter.h | 15 +- .../doctor/gtest/TestMultiWriterQueue.cpp | 12 +- dom/media/doctor/gtest/TestRollingNumber.cpp | 9 +- dom/media/eme/MediaKeySystemAccess.cpp | 4 +- dom/media/encoder/VP8TrackEncoder.cpp | 4 +- dom/media/gmp/ChromiumCDMChild.cpp | 19 +- dom/media/gmp/ChromiumCDMProxy.cpp | 29 +- dom/media/gmp/GMPService.cpp | 72 +- dom/media/gmp/GMPServiceParent.cpp | 70 +- dom/media/gtest/TestAudioBuffers.cpp | 7 +- dom/media/gtest/TestAudioCompactor.cpp | 15 +- dom/media/gtest/TestAudioDeviceEnumerator.cpp | 15 +- dom/media/gtest/TestAudioMixer.cpp | 3 +- dom/media/gtest/TestAudioPacketizer.cpp | 7 +- dom/media/gtest/TestAudioSegment.cpp | 3 +- dom/media/gtest/TestAudioTrackEncoder.cpp | 15 +- dom/media/gtest/TestBitWriter.cpp | 6 +- dom/media/gtest/TestBlankVideoDataCreator.cpp | 6 +- dom/media/gtest/TestBufferReader.cpp | 3 +- dom/media/gtest/TestCDMStorage.cpp | 64 +- dom/media/gtest/TestDataMutex.cpp | 3 +- dom/media/gtest/TestGMPCrossOrigin.cpp | 6 +- dom/media/gtest/TestGMPRemoveAndDelete.cpp | 12 +- dom/media/gtest/TestGMPUtils.cpp | 6 +- dom/media/gtest/TestGroupId.cpp | 30 +- dom/media/gtest/TestIntervalSet.cpp | 84 ++- dom/media/gtest/TestMP4Demuxer.cpp | 86 ++- dom/media/gtest/TestMediaDataDecoder.cpp | 6 +- dom/media/gtest/TestMediaDataEncoder.cpp | 60 +- dom/media/gtest/TestMediaEventSource.cpp | 39 +- dom/media/gtest/TestMediaMIMETypes.cpp | 18 +- dom/media/gtest/TestOpusParser.cpp | 3 +- dom/media/gtest/TestRust.cpp | 3 +- dom/media/gtest/TestTimeUnit.cpp | 3 +- dom/media/gtest/TestVPXDecoding.cpp | 3 +- dom/media/gtest/TestVideoSegment.cpp | 6 +- dom/media/gtest/TestVideoTrackEncoder.cpp | 90 ++- dom/media/gtest/TestVideoUtils.cpp | 9 +- dom/media/gtest/TestWebMBuffered.cpp | 9 +- dom/media/gtest/TestWebMWriter.cpp | 12 +- dom/media/gtest/mp4_demuxer/TestInterval.cpp | 15 +- dom/media/gtest/mp4_demuxer/TestMP4.cpp | 6 +- dom/media/gtest/mp4_demuxer/TestParser.cpp | 33 +- dom/media/ipc/RemoteDecoderParent.cpp | 31 +- dom/media/ipc/RemoteMediaDataDecoder.cpp | 25 +- dom/media/mediasink/VideoSink.cpp | 31 +- dom/media/mediasource/SourceBuffer.cpp | 13 +- dom/media/mediasource/TrackBuffersManager.cpp | 27 +- .../mediasource/gtest/TestContainerParser.cpp | 9 +- .../gtest/TestExtractVPXCodecDetails.cpp | 9 +- dom/media/platforms/AllocationPolicy.cpp | 105 +-- .../agnostic/eme/EMEDecoderModule.cpp | 63 +- dom/media/platforms/omx/OmxDataDecoder.cpp | 236 +++--- dom/media/platforms/omx/OmxPromiseLayer.cpp | 4 +- dom/media/platforms/wmf/MFTDecoder.h | 7 +- .../platforms/wrappers/MediaChangeMonitor.cpp | 227 +++--- dom/media/systemservices/MediaUtils.h | 27 +- dom/media/webaudio/blink/DenormalDisabler.h | 8 +- .../webrtc/MediaEngineRemoteVideoSource.cpp | 4 +- .../recognition/SpeechRecognition.cpp | 47 +- dom/payments/PaymentActionResponse.cpp | 4 +- dom/payments/PaymentMethodChangeEvent.cpp | 4 +- dom/payments/PaymentRequestManager.cpp | 12 +- dom/payments/PaymentRequestService.cpp | 12 +- dom/payments/ipc/PaymentRequestParent.cpp | 16 +- dom/prio/test/gtest/TestPrioEncoder.cpp | 9 +- dom/quota/ActorsParent.cpp | 12 +- dom/quota/test/gtest/TestQuotaManager.cpp | 3 +- .../tests/gtest/TestReportToParser.cpp | 3 +- .../test/gtest/TestFeaturePolicyParser.cpp | 3 +- dom/security/test/gtest/TestCSPParser.cpp | 45 +- dom/security/test/gtest/TestSecureContext.cpp | 9 +- .../ServiceWorkerContainerImpl.cpp | 92 +-- .../ServiceWorkerContainerParent.cpp | 25 +- dom/serviceworkers/ServiceWorkerManager.cpp | 17 +- .../ServiceWorkerRegistrationImpl.cpp | 84 +-- .../test/gtest/TestReadWrite.cpp | 81 ++- dom/webauthn/U2FTokenManager.cpp | 66 +- dom/workers/WorkerDebugger.cpp | 25 +- dom/xhr/XMLHttpRequestMainThread.cpp | 4 +- dom/xslt/xml/txXMLUtils.cpp | 4 +- dom/xslt/xpath/XPathResult.cpp | 4 +- dom/xslt/xpath/txCoreFunctionCall.cpp | 4 +- dom/xslt/xpath/txRelationalExpr.cpp | 4 +- dom/xslt/xpath/txResultRecycler.cpp | 4 +- dom/xslt/xslt/txBufferingHandler.cpp | 4 +- dom/xslt/xslt/txMozillaXSLTProcessor.cpp | 4 +- editor/spellchecker/EditorSpellCheck.cpp | 49 +- editor/txmgr/tests/TestTXMgr.cpp | 21 +- extensions/cookie/nsPermissionManager.cpp | 13 +- gfx/2d/BlurLS3.cpp | 66 +- gfx/2d/unittest/TestCairo.cpp | 9 +- gfx/gl/GLReadTexImageHelper.cpp | 8 +- gfx/layers/ScrollableLayerGuid.h | 4 +- gfx/layers/TreeTraversal.h | 3 +- gfx/layers/composite/TextureHost.cpp | 4 +- gfx/layers/d3d11/TextureD3D11.cpp | 12 +- .../ipc/CompositableTransactionParent.cpp | 8 +- gfx/layers/mlgpu/LayerManagerMLGPU.cpp | 4 +- .../opengl/MacIOSurfaceTextureHostOGL.cpp | 8 +- gfx/layers/opengl/TextureHostOGL.cpp | 8 +- gfx/layers/wr/WebRenderCommandBuilder.cpp | 4 +- gfx/src/FilterSupport.cpp | 4 +- gfx/tests/gtest/PolygonTestUtils.cpp | 3 +- gfx/tests/gtest/TestArena.cpp | 6 +- gfx/tests/gtest/TestArrayView.cpp | 3 +- gfx/tests/gtest/TestBSPTree.cpp | 84 ++- gfx/tests/gtest/TestBufferRotation.cpp | 12 +- gfx/tests/gtest/TestColorNames.cpp | 18 +- gfx/tests/gtest/TestCompositor.cpp | 8 +- gfx/tests/gtest/TestGfxPrefs.cpp | 15 +- gfx/tests/gtest/TestGfxWidgets.cpp | 6 +- gfx/tests/gtest/TestJobScheduler.cpp | 9 +- gfx/tests/gtest/TestLayers.cpp | 21 +- gfx/tests/gtest/TestMoz2D.cpp | 9 +- gfx/tests/gtest/TestPolygon.cpp | 12 +- gfx/tests/gtest/TestQcms.cpp | 12 +- gfx/tests/gtest/TestRect.cpp | 15 +- gfx/tests/gtest/TestRegion.cpp | 82 ++- gfx/tests/gtest/TestSkipChars.cpp | 3 +- gfx/tests/gtest/TestSwizzle.cpp | 9 +- gfx/tests/gtest/TestTextureCompatibility.cpp | 3 +- gfx/tests/gtest/TestTextures.cpp | 6 +- gfx/tests/gtest/TestTreeTraversal.cpp | 81 ++- gfx/tests/gtest/gfxSurfaceRefCountTest.cpp | 3 +- gfx/thebes/gfxFontUtils.h | 4 +- gfx/thebes/gfxTypes.h | 2 +- gfx/vr/VRDisplayClient.cpp | 8 +- gfx/vr/ipc/VRChild.cpp | 10 +- .../gtest/TestADAM7InterpolatingFilter.cpp | 96 +-- image/test/gtest/TestBlendAnimationFilter.cpp | 37 +- image/test/gtest/TestCopyOnWrite.cpp | 12 +- image/test/gtest/TestDownscalingFilter.cpp | 45 +- .../gtest/TestDownscalingFilterNoSkia.cpp | 3 +- .../test/gtest/TestRemoveFrameRectFilter.cpp | 64 +- image/test/gtest/TestSurfaceSink.cpp | 54 +- intl/locale/nsLanguageAtomService.cpp | 11 +- intl/locale/tests/gtest/TestCollation.cpp | 3 +- .../locale/tests/gtest/TestDateTimeFormat.cpp | 12 +- intl/locale/tests/gtest/TestLocaleService.cpp | 33 +- .../gtest/TestLocaleServiceNegotiate.cpp | 6 +- intl/locale/tests/gtest/TestMozLocale.cpp | 30 +- intl/locale/tests/gtest/TestOSPreferences.cpp | 9 +- intl/lwbrk/gtest/TestLineBreak.cpp | 9 +- intl/strres/nsStringBundle.cpp | 6 +- intl/uconv/nsTextToSubURI.cpp | 12 +- ipc/chromium/src/base/thread_local_win.cc | 3 +- ipc/chromium/src/base/waitable_event_win.cc | 2 +- .../src/chrome/common/ipc_channel_posix.cc | 5 +- ipc/glue/WindowsMessageLoop.cpp | 7 +- js/public/Conversions.h | 3 +- js/public/RegExp.h | 4 +- js/src/builtin/String.cpp | 26 +- js/src/gc/Barrier.h | 1 - js/src/gc/GC.cpp | 3 +- js/src/jit/BaselineJIT.cpp | 52 +- js/src/jit/ExecutableAllocator.h | 2 +- js/src/jit/arm/MacroAssembler-arm.cpp | 4 +- js/src/jit/arm64/MacroAssembler-arm64.cpp | 4 +- .../shared/AtomicOperations-shared-jit.cpp | 8 +- js/src/jsapi-tests/testChromeBuffer.cpp | 6 +- js/src/jsapi-tests/testCompileUtf8.cpp | 160 +++-- js/src/jsapi-tests/testSetProperty.cpp | 4 +- js/src/jsapi-tests/testUbiNode.cpp | 11 +- js/src/jsapi-tests/tests.h | 2 +- js/src/shell/js.cpp | 4 +- js/src/vm/BigIntType.cpp | 4 +- js/src/vm/Debugger.cpp | 16 +- js/src/vm/MallocProvider.h | 11 +- js/src/vm/TypedArrayObject.cpp | 4 +- js/src/vm/TypedArrayObject.h | 3 +- js/src/wasm/WasmBaselineCompile.cpp | 44 +- js/src/wasm/WasmCraneliftCompile.cpp | 4 +- js/src/wasm/WasmInstance.cpp | 4 +- js/src/wasm/WasmIonCompile.cpp | 10 +- js/src/wasm/WasmJS.cpp | 12 +- js/src/wasm/WasmStubs.cpp | 4 +- js/src/wasm/WasmValidate.cpp | 4 +- js/xpconnect/loader/AutoMemMap.h | 3 +- layout/build/nsContentDLF.cpp | 108 +-- layout/generic/WritingModes.h | 5 +- layout/generic/nsTextFrameUtils.cpp | 2 +- layout/painting/FrameLayerBuilder.cpp | 3 +- layout/style/Loader.cpp | 27 +- .../0.1/gtest/TestClearKeyUtils.cpp | 3 +- media/mtransport/test/ice_unittest.cpp | 29 +- .../test/simpletokenbucket_unittest.cpp | 33 +- .../test/test_nr_socket_unittest.cpp | 7 +- media/psshparser/gtest/TestPsshParser.cpp | 3 +- .../signaling/gtest/jsep_session_unittest.cpp | 29 +- .../webrtc/signaling/gtest/sdp_unittests.cpp | 245 ++++--- .../src/media-conduit/RtpSourceObserver.cpp | 1 - .../WebrtcMediaDataDecoderCodec.cpp | 20 +- .../MediaTransportHandlerIPC.cpp | 23 +- .../src/peerconnection/PeerConnectionCtx.cpp | 15 +- .../src/peerconnection/PeerConnectionImpl.cpp | 19 +- .../WebrtcGlobalInformation.cpp | 82 ++- .../src/sdp/SipccSdpAttributeList.cpp | 3 +- memory/gtest/TestJemalloc.cpp | 15 +- memory/volatile/tests/TestVolatileBuffer.cpp | 21 +- mfbt/Variant.h | 6 +- mfbt/tests/gtest/TestBuffer.cpp | 9 +- mfbt/tests/gtest/TestLinkedList.cpp | 6 +- mfbt/tests/gtest/TestMozDbg.cpp | 3 +- modules/libpref/SharedPrefMap.cpp | 11 +- modules/libpref/test/gtest/Basics.cpp | 3 +- .../test/gtest/CallbackAndVarCacheOrder.cpp | 27 +- modules/libpref/test/gtest/Parser.cpp | 3 +- mozglue/tests/gtest/TestDLLBlocklist.cpp | 12 +- mozglue/tests/gtest/TestDLLEject.cpp | 12 +- netwerk/base/ProxyAutoConfig.cpp | 6 +- netwerk/base/nsBaseChannel.cpp | 25 +- netwerk/protocol/http/HttpChannelParent.cpp | 32 +- netwerk/test/TestBind.cpp | 3 +- netwerk/test/TestCookie.cpp | 3 +- netwerk/test/TestNamedPipeService.cpp | 3 +- netwerk/test/TestUDPSocket.cpp | 3 +- .../test/gtest/TestBufferedInputStream.cpp | 18 +- netwerk/test/gtest/TestHeaders.cpp | 3 +- netwerk/test/gtest/TestHttpAuthUtils.cpp | 3 +- netwerk/test/gtest/TestIsValidIp.cpp | 36 +- netwerk/test/gtest/TestMIMEInputStream.cpp | 18 +- netwerk/test/gtest/TestMozURL.cpp | 30 +- .../TestPartiallySeekableInputStream.cpp | 27 +- .../test/gtest/TestProtocolProxyService.cpp | 3 +- netwerk/test/gtest/TestReadStreamToString.cpp | 30 +- netwerk/test/gtest/TestServerTimingHeader.cpp | 3 +- netwerk/test/gtest/TestStandardURL.cpp | 18 +- netwerk/test/gtest/TestURIMutator.cpp | 6 +- .../test/gtest/parse-ftp/TestParseFTPList.cpp | 3 +- parser/html/nsHtml5MetaScanner.cpp | 12 +- parser/html/nsHtml5Tokenizer.cpp | 44 +- parser/html/nsHtml5TreeBuilder.cpp | 44 +- parser/html/nsHtml5TreeOperation.cpp | 4 +- .../tests/gtest/TrustOverrideTest.cpp | 21 +- .../manager/ssl/tests/gtest/CertDBTest.cpp | 28 +- .../manager/ssl/tests/gtest/CertListTest.cpp | 57 +- .../ssl/tests/gtest/DeserializeCertTest.cpp | 12 +- security/sandbox/linux/gtest/TestBroker.cpp | 6 +- .../sandbox/linux/gtest/TestBrokerPolicy.cpp | 9 +- security/sandbox/mac/Sandbox.mm | 1 - storage/test/gtest/test_AsXXX_helpers.cpp | 6 +- ...st_asyncStatementExecution_transaction.cpp | 44 +- ..._async_callbacks_with_spun_event_loops.cpp | 7 +- storage/test/gtest/test_binding_params.cpp | 9 +- storage/test/gtest/test_file_perms.cpp | 3 +- storage/test/gtest/test_mutex.cpp | 6 +- .../test_service_init_background_thread.cpp | 3 +- .../gtest/test_spinningSynchronousClose.cpp | 6 +- storage/test/gtest/test_statement_scoper.cpp | 6 +- .../test/gtest/test_transaction_helper.cpp | 18 +- storage/test/gtest/test_true_async.cpp | 9 +- storage/test/gtest/test_unlock_notify.cpp | 3 +- testing/gtest/mozilla/MozGTestBench.h | 3 +- testing/gtest/mozilla/SanityTest.cpp | 6 +- .../extensions/webrequest/StreamFilter.cpp | 15 +- .../PerformanceMetricsCollector.cpp | 15 +- .../tests/gtest/places_test_harness_tail.h | 3 +- .../places/tests/gtest/test_casing.cpp | 6 +- .../test/gtest/TestExecutableLists.cpp | 12 +- .../tests/test_reduceprecision.cpp | 27 +- .../geckoview/gtest/TestGeckoView.cpp | 10 +- .../tests/gtest/TelemetryTestHelpers.cpp | 50 +- .../tests/gtest/TestCombinedStacks.cpp | 2 +- .../telemetry/tests/gtest/TestEvents.cpp | 25 +- .../telemetry/tests/gtest/TestHistograms.cpp | 18 +- .../telemetry/tests/gtest/TestOrigins.cpp | 28 +- .../telemetry/tests/gtest/TestScalars.cpp | 5 +- .../tests/gtest/TestCaching.cpp | 34 +- .../tests/gtest/TestChunkSet.cpp | 21 +- .../tests/gtest/TestClassifier.cpp | 6 +- .../tests/gtest/TestFailUpdate.cpp | 3 +- .../tests/gtest/TestFindFullHash.cpp | 6 +- .../tests/gtest/TestLookupCacheV4.cpp | 21 +- .../tests/gtest/TestPerProviderDirectory.cpp | 6 +- .../tests/gtest/TestProtocolParser.cpp | 6 +- .../tests/gtest/TestRiceDeltaDecoder.cpp | 6 +- .../tests/gtest/TestSafeBrowsingProtobuf.cpp | 3 +- .../tests/gtest/TestSafebrowsingHash.cpp | 6 +- .../url-classifier/tests/gtest/TestTable.cpp | 3 +- .../gtest/TestUrlClassifierTableUpdateV4.cpp | 48 +- .../tests/gtest/TestUrlClassifierUtils.cpp | 21 +- .../gtest/TestVariableLengthPrefixSet.cpp | 33 +- .../Win64ModuleUnwindMetadata.cpp | 4 +- .../test/gtest/TestCrashThreadAnnotation.cpp | 43 +- toolkit/profile/gtest/TestProfileLock.cpp | 3 +- .../profile/gtest/TestProfileLockRetry.cpp | 3 +- toolkit/recordreplay/HashTable.cpp | 24 +- .../tests/gtest/TestProxyBypassRules.cpp | 9 +- .../tests/gtest/TestProxyBypassRules.cpp | 9 +- .../interface/FuzzingInterfaceStream.h | 3 +- tools/profiler/gecko/nsProfiler.cpp | 172 ++--- tools/profiler/tests/gtest/GeckoProfiler.cpp | 45 +- tools/profiler/tests/gtest/LulTest.cpp | 3 +- .../tests/gtest/ThreadProfileTest.cpp | 9 +- widget/PuppetWidget.cpp | 15 +- widget/cocoa/nsPrintDialogX.mm | 3 +- widget/gtk/nsFilePicker.cpp | 18 +- widget/gtk/nsNativeThemeGTK.cpp | 4 +- widget/windows/ToastNotificationHandler.cpp | 9 +- widget/windows/nsClipboard.cpp | 3 +- xpcom/base/nsSystemInfo.cpp | 6 +- xpcom/ds/PLDHashTable.cpp | 29 +- xpcom/ds/nsTArray.h | 15 +- xpcom/reflect/xptinfo/xptinfo.h | 4 +- xpcom/rust/gtest/nsstring/Test.cpp | 30 +- xpcom/rust/gtest/xpcom/Test.cpp | 6 +- xpcom/tests/gtest/TestAllocReplacement.cpp | 18 +- xpcom/tests/gtest/TestArenaAllocator.cpp | 33 +- xpcom/tests/gtest/TestAtoms.cpp | 18 +- xpcom/tests/gtest/TestAutoPtr.cpp | 21 +- xpcom/tests/gtest/TestAutoRef.cpp | 3 +- xpcom/tests/gtest/TestAutoRefCnt.cpp | 3 +- xpcom/tests/gtest/TestBase64.cpp | 40 +- xpcom/tests/gtest/TestCOMArray.cpp | 12 +- xpcom/tests/gtest/TestCOMPtr.cpp | 24 +- xpcom/tests/gtest/TestCOMPtrEq.cpp | 3 +- xpcom/tests/gtest/TestCRT.cpp | 3 +- xpcom/tests/gtest/TestCloneInputStream.cpp | 18 +- xpcom/tests/gtest/TestDafsa.cpp | 12 +- .../gtest/TestDeadlockDetectorScalability.cpp | 15 +- xpcom/tests/gtest/TestEncoding.cpp | 12 +- xpcom/tests/gtest/TestEscape.cpp | 15 +- xpcom/tests/gtest/TestEventPriorities.cpp | 6 +- xpcom/tests/gtest/TestEventTargetQI.cpp | 18 +- xpcom/tests/gtest/TestExpirationTracker.cpp | 3 +- xpcom/tests/gtest/TestFile.cpp | 3 +- xpcom/tests/gtest/TestFilePreferencesUnix.cpp | 6 +- xpcom/tests/gtest/TestFilePreferencesWin.cpp | 6 +- xpcom/tests/gtest/TestGCPostBarriers.cpp | 3 +- xpcom/tests/gtest/TestHashtables.cpp | 24 +- xpcom/tests/gtest/TestID.cpp | 3 +- .../gtest/TestInputStreamLengthHelper.cpp | 15 +- .../tests/gtest/TestLogCommandLineHandler.cpp | 15 +- xpcom/tests/gtest/TestMoveString.cpp | 36 +- xpcom/tests/gtest/TestMozPromise.cpp | 237 ++++--- xpcom/tests/gtest/TestMruCache.cpp | 36 +- .../tests/gtest/TestMultiplexInputStream.cpp | 27 +- .../tests/gtest/TestNSPRLogModulesParser.cpp | 15 +- .../gtest/TestNonBlockingAsyncInputStream.cpp | 22 +- xpcom/tests/gtest/TestNsDeque.cpp | 30 +- xpcom/tests/gtest/TestNsRefPtr.cpp | 18 +- xpcom/tests/gtest/TestObserverArray.cpp | 26 +- xpcom/tests/gtest/TestObserverService.cpp | 21 +- xpcom/tests/gtest/TestPLDHash.cpp | 18 +- xpcom/tests/gtest/TestPipes.cpp | 56 +- xpcom/tests/gtest/TestPriorityQueue.cpp | 3 +- xpcom/tests/gtest/TestRWLock.cpp | 3 +- .../tests/gtest/TestRacingServiceManager.cpp | 3 +- xpcom/tests/gtest/TestRecursiveMutex.cpp | 3 +- xpcom/tests/gtest/TestSlicedInputStream.cpp | 63 +- xpcom/tests/gtest/TestSnappyStreams.cpp | 60 +- xpcom/tests/gtest/TestStateWatching.cpp | 3 +- xpcom/tests/gtest/TestStorageStream.cpp | 6 +- xpcom/tests/gtest/TestStringStream.cpp | 6 +- xpcom/tests/gtest/TestStrings.cpp | 6 +- xpcom/tests/gtest/TestSynchronization.cpp | 27 +- xpcom/tests/gtest/TestTArray.cpp | 21 +- xpcom/tests/gtest/TestTArray2.cpp | 142 ++-- xpcom/tests/gtest/TestTaskQueue.cpp | 3 +- xpcom/tests/gtest/TestTextFormatter.cpp | 27 +- xpcom/tests/gtest/TestThreadManager.cpp | 6 +- xpcom/tests/gtest/TestThreadPool.cpp | 12 +- xpcom/tests/gtest/TestThreadPoolListener.cpp | 3 +- xpcom/tests/gtest/TestThreadUtils.cpp | 28 +- xpcom/tests/gtest/TestThreads.cpp | 12 +- xpcom/tests/gtest/TestThrottledEventQueue.cpp | 36 +- xpcom/tests/gtest/TestTimeStamp.cpp | 3 +- xpcom/tests/gtest/TestTimers.cpp | 12 +- xpcom/tests/gtest/TestTokenizer.cpp | 93 ++- xpcom/tests/gtest/TestUTF.cpp | 24 +- xpcom/tests/windows/TestCOM.cpp | 3 +- xpcom/tests/windows/TestNtPathToDosPath.cpp | 3 +- xpcom/threads/MozPromise.h | 15 +- xpcom/threads/nsThreadUtils.cpp | 3 +- 427 files changed, 6444 insertions(+), 4536 deletions(-) diff --git a/accessible/base/MarkupMap.h b/accessible/base/MarkupMap.h index 5b4a6317cd3db..6a72e28bc021a 100644 --- a/accessible/base/MarkupMap.h +++ b/accessible/base/MarkupMap.h @@ -5,20 +5,20 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -MARKUPMAP(a, - [](Element* aElement, Accessible* aContext) -> Accessible* { - // Only some roles truly enjoy life as HTMLLinkAccessibles, for - // details see closed bug 494807. - const nsRoleMapEntry* roleMapEntry = aria::GetRoleMap(aElement); - if (roleMapEntry && roleMapEntry->role != roles::NOTHING && - roleMapEntry->role != roles::LINK) { - return new HyperTextAccessibleWrap(aElement, - aContext->Document()); - } - - return new HTMLLinkAccessible(aElement, aContext->Document()); - }, - roles::LINK) +MARKUPMAP( + a, + [](Element* aElement, Accessible* aContext) -> Accessible* { + // Only some roles truly enjoy life as HTMLLinkAccessibles, for + // details see closed bug 494807. + const nsRoleMapEntry* roleMapEntry = aria::GetRoleMap(aElement); + if (roleMapEntry && roleMapEntry->role != roles::NOTHING && + roleMapEntry->role != roles::LINK) { + return new HyperTextAccessibleWrap(aElement, aContext->Document()); + } + + return new HTMLLinkAccessible(aElement, aContext->Document()); + }, + roles::LINK); MARKUPMAP(abbr, New_HyperText, 0) @@ -30,26 +30,27 @@ MARKUPMAP(aside, New_HyperText, roles::LANDMARK) MARKUPMAP(blockquote, New_HyperText, roles::BLOCKQUOTE) -MARKUPMAP(button, - [](Element* aElement, Accessible* aContext) -> Accessible* { - return new HTMLButtonAccessible(aElement, aContext->Document()); - }, - 0) - -MARKUPMAP(caption, - [](Element* aElement, Accessible* aContext) -> Accessible* { - if (aContext->IsTable()) { - dom::HTMLTableElement* tableEl = - dom::HTMLTableElement::FromNode(aContext->GetContent()); - if (tableEl && tableEl == aElement->GetParent() && - tableEl->GetCaption() == aElement) { - return new HTMLCaptionAccessible(aElement, - aContext->Document()); - } - } - return nullptr; - }, - 0) +MARKUPMAP( + button, + [](Element* aElement, Accessible* aContext) -> Accessible* { + return new HTMLButtonAccessible(aElement, aContext->Document()); + }, + 0) + +MARKUPMAP( + caption, + [](Element* aElement, Accessible* aContext) -> Accessible* { + if (aContext->IsTable()) { + dom::HTMLTableElement* tableEl = + dom::HTMLTableElement::FromNode(aContext->GetContent()); + if (tableEl && tableEl == aElement->GetParent() && + tableEl->GetCaption() == aElement) { + return new HTMLCaptionAccessible(aElement, aContext->Document()); + } + } + return nullptr; + }, + 0) MARKUPMAP(dd, New_HTMLDtOrDd, roles::DEFINITION) @@ -120,51 +121,56 @@ MARKUPMAP( }, roles::SECTION) -MARKUPMAP(dl, - [](Element* aElement, Accessible* aContext) -> Accessible* { - return new HTMLListAccessible(aElement, aContext->Document()); - }, - roles::DEFINITION_LIST) +MARKUPMAP( + dl, + [](Element* aElement, Accessible* aContext) -> Accessible* { + return new HTMLListAccessible(aElement, aContext->Document()); + }, + roles::DEFINITION_LIST) MARKUPMAP(dt, New_HTMLDtOrDd, roles::TERM) -MARKUPMAP(figcaption, - [](Element* aElement, Accessible* aContext) -> Accessible* { - return new HTMLFigcaptionAccessible(aElement, aContext->Document()); - }, - roles::CAPTION) - -MARKUPMAP(figure, - [](Element* aElement, Accessible* aContext) -> Accessible* { - return new HTMLFigureAccessible(aElement, aContext->Document()); - }, - roles::FIGURE, Attr(xmlroles, figure)) - -MARKUPMAP(fieldset, - [](Element* aElement, Accessible* aContext) -> Accessible* { - return new HTMLGroupboxAccessible(aElement, aContext->Document()); - }, - 0) - -MARKUPMAP(form, - [](Element* aElement, Accessible* aContext) -> Accessible* { - return new HTMLFormAccessible(aElement, aContext->Document()); - }, - 0) - -MARKUPMAP(footer, - [](Element* aElement, Accessible* aContext) -> Accessible* { - return new HTMLHeaderOrFooterAccessible(aElement, - aContext->Document()); - }, - 0) - -MARKUPMAP(header, - [](Element* aElement, Accessible* aContext) -> Accessible* { - return new HTMLHeaderOrFooterAccessible(aElement, - aContext->Document()); - }, - 0) +MARKUPMAP( + figcaption, + [](Element* aElement, Accessible* aContext) -> Accessible* { + return new HTMLFigcaptionAccessible(aElement, aContext->Document()); + }, + roles::CAPTION) + +MARKUPMAP( + figure, + [](Element* aElement, Accessible* aContext) -> Accessible* { + return new HTMLFigureAccessible(aElement, aContext->Document()); + }, + roles::FIGURE, Attr(xmlroles, figure)) + +MARKUPMAP( + fieldset, + [](Element* aElement, Accessible* aContext) -> Accessible* { + return new HTMLGroupboxAccessible(aElement, aContext->Document()); + }, + 0) + +MARKUPMAP( + form, + [](Element* aElement, Accessible* aContext) -> Accessible* { + return new HTMLFormAccessible(aElement, aContext->Document()); + }, + 0) + +MARKUPMAP( + footer, + [](Element* aElement, Accessible* aContext) -> Accessible* { + return new HTMLHeaderOrFooterAccessible(aElement, aContext->Document()); + }, + 0) + +MARKUPMAP( + header, + [](Element* aElement, Accessible* aContext) -> Accessible* { + return new HTMLHeaderOrFooterAccessible(aElement, aContext->Document()); + }, + 0) MARKUPMAP(h1, New_HyperText, roles::HEADING) @@ -178,71 +184,75 @@ MARKUPMAP(h5, New_HyperText, roles::HEADING) MARKUPMAP(h6, New_HyperText, roles::HEADING) -MARKUPMAP(hr, - [](Element* aElement, Accessible* aContext) -> Accessible* { - return new HTMLHRAccessible(aElement, aContext->Document()); - }, - 0) - -MARKUPMAP(input, - [](Element* aElement, Accessible* aContext) -> Accessible* { - // TODO(emilio): This would be faster if it used - // HTMLInputElement's already-parsed representation. - if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type, - nsGkAtoms::checkbox, eIgnoreCase)) { - return new CheckboxAccessible(aElement, aContext->Document()); - } - if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type, - nsGkAtoms::image, eIgnoreCase)) { - return new HTMLButtonAccessible(aElement, aContext->Document()); - } - if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type, - nsGkAtoms::radio, eIgnoreCase)) { - return new HTMLRadioButtonAccessible(aElement, - aContext->Document()); - } - if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type, - nsGkAtoms::time, eIgnoreCase)) { - return new EnumRoleAccessible( - aElement, aContext->Document()); - } - if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type, - nsGkAtoms::date, eIgnoreCase)) { - return new EnumRoleAccessible( - aElement, aContext->Document()); - } - return nullptr; - }, - 0) +MARKUPMAP( + hr, + [](Element* aElement, Accessible* aContext) -> Accessible* { + return new HTMLHRAccessible(aElement, aContext->Document()); + }, + 0) + +MARKUPMAP( + input, + [](Element* aElement, Accessible* aContext) -> Accessible* { + // TODO(emilio): This would be faster if it used + // HTMLInputElement's already-parsed representation. + if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type, + nsGkAtoms::checkbox, eIgnoreCase)) { + return new CheckboxAccessible(aElement, aContext->Document()); + } + if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type, + nsGkAtoms::image, eIgnoreCase)) { + return new HTMLButtonAccessible(aElement, aContext->Document()); + } + if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type, + nsGkAtoms::radio, eIgnoreCase)) { + return new HTMLRadioButtonAccessible(aElement, aContext->Document()); + } + if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type, + nsGkAtoms::time, eIgnoreCase)) { + return new EnumRoleAccessible(aElement, + aContext->Document()); + } + if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type, + nsGkAtoms::date, eIgnoreCase)) { + return new EnumRoleAccessible(aElement, + aContext->Document()); + } + return nullptr; + }, + 0) MARKUPMAP(ins, New_HyperText, roles::CONTENT_INSERTION) -MARKUPMAP(label, - [](Element* aElement, Accessible* aContext) -> Accessible* { - return new HTMLLabelAccessible(aElement, aContext->Document()); - }, - roles::LABEL) - -MARKUPMAP(legend, - [](Element* aElement, Accessible* aContext) -> Accessible* { - return new HTMLLegendAccessible(aElement, aContext->Document()); - }, - roles::LABEL) - -MARKUPMAP(li, - [](Element* aElement, Accessible* aContext) -> Accessible* { - // If list item is a child of accessible list then create an - // accessible for it unconditionally by tag name. nsBlockFrame - // creates the list item accessible for other elements styled as - // list items. - if (aContext->IsList() && - aContext->GetContent() == aElement->GetParent()) { - return new HTMLLIAccessible(aElement, aContext->Document()); - } - - return nullptr; - }, - 0) +MARKUPMAP( + label, + [](Element* aElement, Accessible* aContext) -> Accessible* { + return new HTMLLabelAccessible(aElement, aContext->Document()); + }, + roles::LABEL) + +MARKUPMAP( + legend, + [](Element* aElement, Accessible* aContext) -> Accessible* { + return new HTMLLegendAccessible(aElement, aContext->Document()); + }, + roles::LABEL) + +MARKUPMAP( + li, + [](Element* aElement, Accessible* aContext) -> Accessible* { + // If list item is a child of accessible list then create an + // accessible for it unconditionally by tag name. nsBlockFrame + // creates the list item accessible for other elements styled as + // list items. + if (aContext->IsList() && + aContext->GetContent() == aElement->GetParent()) { + return new HTMLLIAccessible(aElement, aContext->Document()); + } + + return nullptr; + }, + 0) MARKUPMAP(main, New_HyperText, roles::LANDMARK) @@ -301,31 +311,34 @@ MARKUPMAP(munderover_, New_HyperText, roles::MATHML_UNDER_OVER, MARKUPMAP(mmultiscripts_, New_HyperText, roles::MATHML_MULTISCRIPTS) -MARKUPMAP(mtable_, - [](Element* aElement, Accessible* aContext) -> Accessible* { - return new HTMLTableAccessible(aElement, aContext->Document()); - }, - roles::MATHML_TABLE, AttrFromDOM(align, align), - AttrFromDOM(columnlines_, columnlines_), - AttrFromDOM(rowlines_, rowlines_)) - -MARKUPMAP(mlabeledtr_, - [](Element* aElement, Accessible* aContext) -> Accessible* { - return new HTMLTableRowAccessible(aElement, aContext->Document()); - }, - roles::MATHML_LABELED_ROW) - -MARKUPMAP(mtr_, - [](Element* aElement, Accessible* aContext) -> Accessible* { - return new HTMLTableRowAccessible(aElement, aContext->Document()); - }, - roles::MATHML_TABLE_ROW) - -MARKUPMAP(mtd_, - [](Element* aElement, Accessible* aContext) -> Accessible* { - return new HTMLTableCellAccessible(aElement, aContext->Document()); - }, - roles::MATHML_CELL) +MARKUPMAP( + mtable_, + [](Element* aElement, Accessible* aContext) -> Accessible* { + return new HTMLTableAccessible(aElement, aContext->Document()); + }, + roles::MATHML_TABLE, AttrFromDOM(align, align), + AttrFromDOM(columnlines_, columnlines_), AttrFromDOM(rowlines_, rowlines_)) + +MARKUPMAP( + mlabeledtr_, + [](Element* aElement, Accessible* aContext) -> Accessible* { + return new HTMLTableRowAccessible(aElement, aContext->Document()); + }, + roles::MATHML_LABELED_ROW) + +MARKUPMAP( + mtr_, + [](Element* aElement, Accessible* aContext) -> Accessible* { + return new HTMLTableRowAccessible(aElement, aContext->Document()); + }, + roles::MATHML_TABLE_ROW) + +MARKUPMAP( + mtd_, + [](Element* aElement, Accessible* aContext) -> Accessible* { + return new HTMLTableCellAccessible(aElement, aContext->Document()); + }, + roles::MATHML_CELL) MARKUPMAP(maction_, New_HyperText, roles::MATHML_ACTION, AttrFromDOM(actiontype_, actiontype_), @@ -356,173 +369,183 @@ MARKUPMAP(msline_, New_HyperText, roles::MATHML_STACK_LINE, MARKUPMAP(nav, New_HyperText, roles::LANDMARK) -MARKUPMAP(ol, - [](Element* aElement, Accessible* aContext) -> Accessible* { - return new HTMLListAccessible(aElement, aContext->Document()); - }, - roles::LIST) - -MARKUPMAP(option, - [](Element* aElement, Accessible* aContext) -> Accessible* { - return new HTMLSelectOptionAccessible(aElement, - aContext->Document()); - }, - 0) - -MARKUPMAP(optgroup, - [](Element* aElement, Accessible* aContext) -> Accessible* { - return new HTMLSelectOptGroupAccessible(aElement, - aContext->Document()); - }, - 0) - -MARKUPMAP(output, - [](Element* aElement, Accessible* aContext) -> Accessible* { - return new HTMLOutputAccessible(aElement, aContext->Document()); - }, - roles::SECTION, Attr(live, polite)) +MARKUPMAP( + ol, + [](Element* aElement, Accessible* aContext) -> Accessible* { + return new HTMLListAccessible(aElement, aContext->Document()); + }, + roles::LIST) + +MARKUPMAP( + option, + [](Element* aElement, Accessible* aContext) -> Accessible* { + return new HTMLSelectOptionAccessible(aElement, aContext->Document()); + }, + 0) + +MARKUPMAP( + optgroup, + [](Element* aElement, Accessible* aContext) -> Accessible* { + return new HTMLSelectOptGroupAccessible(aElement, aContext->Document()); + }, + 0) + +MARKUPMAP( + output, + [](Element* aElement, Accessible* aContext) -> Accessible* { + return new HTMLOutputAccessible(aElement, aContext->Document()); + }, + roles::SECTION, Attr(live, polite)) MARKUPMAP(p, nullptr, roles::PARAGRAPH) -MARKUPMAP(progress, - [](Element* aElement, Accessible* aContext) -> Accessible* { - return new HTMLProgressAccessible(aElement, aContext->Document()); - }, - 0) +MARKUPMAP( + progress, + [](Element* aElement, Accessible* aContext) -> Accessible* { + return new HTMLProgressAccessible(aElement, aContext->Document()); + }, + 0) MARKUPMAP(q, New_HyperText, 0) -MARKUPMAP(section, - [](Element* aElement, Accessible* aContext) -> Accessible* { - return new HTMLSectionAccessible(aElement, aContext->Document()); - }, - 0) - -MARKUPMAP(summary, - [](Element* aElement, Accessible* aContext) -> Accessible* { - return new HTMLSummaryAccessible(aElement, aContext->Document()); - }, - roles::SUMMARY) - -MARKUPMAP(table, - [](Element* aElement, Accessible* aContext) -> Accessible* { - if (aElement->GetPrimaryFrame() && - aElement->GetPrimaryFrame()->AccessibleType() != - eHTMLTableType) { - return new ARIAGridAccessibleWrap(aElement, aContext->Document()); - } - return nullptr; - }, - 0) +MARKUPMAP( + section, + [](Element* aElement, Accessible* aContext) -> Accessible* { + return new HTMLSectionAccessible(aElement, aContext->Document()); + }, + 0) + +MARKUPMAP( + summary, + [](Element* aElement, Accessible* aContext) -> Accessible* { + return new HTMLSummaryAccessible(aElement, aContext->Document()); + }, + roles::SUMMARY) + +MARKUPMAP( + table, + [](Element* aElement, Accessible* aContext) -> Accessible* { + if (aElement->GetPrimaryFrame() && + aElement->GetPrimaryFrame()->AccessibleType() != eHTMLTableType) { + return new ARIAGridAccessibleWrap(aElement, aContext->Document()); + } + return nullptr; + }, + 0) MARKUPMAP(time, New_HyperText, 0, Attr(xmlroles, time), AttrFromDOM(datetime, datetime)) -MARKUPMAP(tbody, - [](Element* aElement, Accessible* aContext) -> Accessible* { - // Expose this as a grouping if its frame type is non-standard. - if (aElement->GetPrimaryFrame() && - aElement->GetPrimaryFrame()->IsTableRowGroupFrame()) { - return nullptr; - } - return new HyperTextAccessibleWrap(aElement, aContext->Document()); - }, - roles::GROUPING) - -MARKUPMAP(td, - [](Element* aElement, Accessible* aContext) -> Accessible* { - if (aContext->IsTableRow() && - aContext->GetContent() == aElement->GetParent()) { - // If HTML:td element is part of its HTML:table, which has CSS - // display style other than 'table', then create a generic table - // cell accessible, because there's no underlying table layout and - // thus native HTML table cell class doesn't work. The same is - // true if the cell itself has CSS display:block;. - if (!aContext->IsHTMLTableRow() || - (aElement->GetPrimaryFrame() && - aElement->GetPrimaryFrame()->AccessibleType() != - eHTMLTableCellType)) { - return new ARIAGridCellAccessibleWrap(aElement, - aContext->Document()); - } - if (aElement->HasAttr(kNameSpaceID_None, nsGkAtoms::scope)) { - return new HTMLTableHeaderCellAccessibleWrap( - aElement, aContext->Document()); - } - } - return nullptr; - }, - 0) - -MARKUPMAP(tfoot, - [](Element* aElement, Accessible* aContext) -> Accessible* { - // Expose this as a grouping if its frame type is non-standard. - if (aElement->GetPrimaryFrame() && - aElement->GetPrimaryFrame()->IsTableRowGroupFrame()) { - return nullptr; - } - return new HyperTextAccessibleWrap(aElement, aContext->Document()); - }, - roles::GROUPING) - -MARKUPMAP(th, - [](Element* aElement, Accessible* aContext) -> Accessible* { - if (aContext->IsTableRow() && - aContext->GetContent() == aElement->GetParent()) { - if (!aContext->IsHTMLTableRow()) { - return new ARIAGridCellAccessibleWrap(aElement, - aContext->Document()); - } - return new HTMLTableHeaderCellAccessibleWrap( - aElement, aContext->Document()); - } - return nullptr; - }, - 0) - -MARKUPMAP(tfoot, - [](Element* aElement, Accessible* aContext) -> Accessible* { - // Expose this as a grouping if its frame type is non-standard. - if (aElement->GetPrimaryFrame() && - aElement->GetPrimaryFrame()->IsTableRowGroupFrame()) { - return nullptr; - } - return new HyperTextAccessibleWrap(aElement, aContext->Document()); - }, - roles::GROUPING) - -MARKUPMAP(tr, - [](Element* aElement, Accessible* aContext) -> Accessible* { - // If HTML:tr element is part of its HTML:table, which has CSS - // display style other than 'table', then create a generic table row - // accessible, because there's no underlying table layout and thus - // native HTML table row class doesn't work. Refer to - // CreateAccessibleByFrameType dual logic. - Accessible* table = aContext->IsTable() ? aContext : nullptr; - if (!table && aContext->Parent() && aContext->Parent()->IsTable()) { - table = aContext->Parent(); - } - if (table) { - nsIContent* parentContent = aElement->GetParent(); - nsIFrame* parentFrame = parentContent->GetPrimaryFrame(); - if (parentFrame && !parentFrame->IsTableWrapperFrame()) { - parentContent = parentContent->GetParent(); - parentFrame = parentContent->GetPrimaryFrame(); - if (table->GetContent() == parentContent && - ((parentFrame && !parentFrame->IsTableWrapperFrame()) || - (aElement->GetPrimaryFrame() && - aElement->GetPrimaryFrame()->AccessibleType() != - eHTMLTableRowType))) { - return new ARIARowAccessible(aElement, aContext->Document()); - } - } - } - return nullptr; - }, - 0) - -MARKUPMAP(ul, - [](Element* aElement, Accessible* aContext) -> Accessible* { - return new HTMLListAccessible(aElement, aContext->Document()); - }, - roles::LIST) +MARKUPMAP( + tbody, + [](Element* aElement, Accessible* aContext) -> Accessible* { + // Expose this as a grouping if its frame type is non-standard. + if (aElement->GetPrimaryFrame() && + aElement->GetPrimaryFrame()->IsTableRowGroupFrame()) { + return nullptr; + } + return new HyperTextAccessibleWrap(aElement, aContext->Document()); + }, + roles::GROUPING) + +MARKUPMAP( + td, + [](Element* aElement, Accessible* aContext) -> Accessible* { + if (aContext->IsTableRow() && + aContext->GetContent() == aElement->GetParent()) { + // If HTML:td element is part of its HTML:table, which has CSS + // display style other than 'table', then create a generic table + // cell accessible, because there's no underlying table layout and + // thus native HTML table cell class doesn't work. The same is + // true if the cell itself has CSS display:block;. + if (!aContext->IsHTMLTableRow() || + (aElement->GetPrimaryFrame() && + aElement->GetPrimaryFrame()->AccessibleType() != + eHTMLTableCellType)) { + return new ARIAGridCellAccessibleWrap(aElement, aContext->Document()); + } + if (aElement->HasAttr(kNameSpaceID_None, nsGkAtoms::scope)) { + return new HTMLTableHeaderCellAccessibleWrap(aElement, + aContext->Document()); + } + } + return nullptr; + }, + 0) + +MARKUPMAP( + tfoot, + [](Element* aElement, Accessible* aContext) -> Accessible* { + // Expose this as a grouping if its frame type is non-standard. + if (aElement->GetPrimaryFrame() && + aElement->GetPrimaryFrame()->IsTableRowGroupFrame()) { + return nullptr; + } + return new HyperTextAccessibleWrap(aElement, aContext->Document()); + }, + roles::GROUPING) + +MARKUPMAP( + th, + [](Element* aElement, Accessible* aContext) -> Accessible* { + if (aContext->IsTableRow() && + aContext->GetContent() == aElement->GetParent()) { + if (!aContext->IsHTMLTableRow()) { + return new ARIAGridCellAccessibleWrap(aElement, aContext->Document()); + } + return new HTMLTableHeaderCellAccessibleWrap(aElement, + aContext->Document()); + } + return nullptr; + }, + 0) + +MARKUPMAP( + tfoot, + [](Element* aElement, Accessible* aContext) -> Accessible* { + // Expose this as a grouping if its frame type is non-standard. + if (aElement->GetPrimaryFrame() && + aElement->GetPrimaryFrame()->IsTableRowGroupFrame()) { + return nullptr; + } + return new HyperTextAccessibleWrap(aElement, aContext->Document()); + }, + roles::GROUPING) + +MARKUPMAP( + tr, + [](Element* aElement, Accessible* aContext) -> Accessible* { + // If HTML:tr element is part of its HTML:table, which has CSS + // display style other than 'table', then create a generic table row + // accessible, because there's no underlying table layout and thus + // native HTML table row class doesn't work. Refer to + // CreateAccessibleByFrameType dual logic. + Accessible* table = aContext->IsTable() ? aContext : nullptr; + if (!table && aContext->Parent() && aContext->Parent()->IsTable()) { + table = aContext->Parent(); + } + if (table) { + nsIContent* parentContent = aElement->GetParent(); + nsIFrame* parentFrame = parentContent->GetPrimaryFrame(); + if (parentFrame && !parentFrame->IsTableWrapperFrame()) { + parentContent = parentContent->GetParent(); + parentFrame = parentContent->GetPrimaryFrame(); + if (table->GetContent() == parentContent && + ((parentFrame && !parentFrame->IsTableWrapperFrame()) || + (aElement->GetPrimaryFrame() && + aElement->GetPrimaryFrame()->AccessibleType() != + eHTMLTableRowType))) { + return new ARIARowAccessible(aElement, aContext->Document()); + } + } + } + return nullptr; + }, + 0) + +MARKUPMAP( + ul, + [](Element* aElement, Accessible* aContext) -> Accessible* { + return new HTMLListAccessible(aElement, aContext->Document()); + }, + roles::LIST) diff --git a/caps/tests/gtest/TestOriginAttributes.cpp b/caps/tests/gtest/TestOriginAttributes.cpp index ffa4349939e41..91416c7201cf8 100644 --- a/caps/tests/gtest/TestOriginAttributes.cpp +++ b/caps/tests/gtest/TestOriginAttributes.cpp @@ -17,17 +17,20 @@ static void TestSuffix(const OriginAttributes& attrs) { EXPECT_EQ(attrs, attrsFromSuffix); } -TEST(OriginAttributes, Suffix_default) { +TEST(OriginAttributes, Suffix_default) +{ OriginAttributes attrs; TestSuffix(attrs); } -TEST(OriginAttributes, Suffix_appId_inIsolatedMozBrowser) { +TEST(OriginAttributes, Suffix_appId_inIsolatedMozBrowser) +{ OriginAttributes attrs(1, true); TestSuffix(attrs); } -TEST(OriginAttributes, Suffix_maxAppId_inIsolatedMozBrowser) { +TEST(OriginAttributes, Suffix_maxAppId_inIsolatedMozBrowser) +{ OriginAttributes attrs(4294967295, true); TestSuffix(attrs); } diff --git a/dom/base/AnonymousContent.cpp b/dom/base/AnonymousContent.cpp index 56e2abd853f9e..a89dad079b9d1 100644 --- a/dom/base/AnonymousContent.cpp +++ b/dom/base/AnonymousContent.cpp @@ -197,8 +197,7 @@ void AnonymousContent::GetComputedStylePropertyValue( aRv = cs->GetPropertyValue(aPropertyName, aResult); } -void AnonymousContent::GetTargetIdForEvent(Event& aEvent, DOMString& aResult) -{ +void AnonymousContent::GetTargetIdForEvent(Event& aEvent, DOMString& aResult) { nsCOMPtr el = do_QueryInterface(aEvent.GetOriginalTarget()); if (el && el->IsInNativeAnonymousSubtree() && mContentNode->Contains(el)) { aResult.SetKnownLiveAtom(el->GetID(), DOMString::eTreatNullAsNull); diff --git a/dom/base/DocGroup.cpp b/dom/base/DocGroup.cpp index 30a5551816ea7..8b8d4ea0b760d 100644 --- a/dom/base/DocGroup.cpp +++ b/dom/base/DocGroup.cpp @@ -143,20 +143,21 @@ RefPtr DocGroup::ReportPerformanceInfo() { RefPtr self = this; return CollectMemoryInfo(top, mainThread) - ->Then(mainThread, __func__, - [self, host, pid, windowID, duration, isTopLevel, - items](const PerformanceMemoryInfo& aMemoryInfo) { - PerformanceInfo info = - PerformanceInfo(host, pid, windowID, duration, - self->mPerformanceCounter->GetID(), false, - isTopLevel, aMemoryInfo, items); - - return PerformanceInfoPromise::CreateAndResolve(std::move(info), - __func__); - }, - [self](const nsresult rv) { - return PerformanceInfoPromise::CreateAndReject(rv, __func__); - }); + ->Then( + mainThread, __func__, + [self, host, pid, windowID, duration, isTopLevel, + items](const PerformanceMemoryInfo& aMemoryInfo) { + PerformanceInfo info = + PerformanceInfo(host, pid, windowID, duration, + self->mPerformanceCounter->GetID(), false, + isTopLevel, aMemoryInfo, items); + + return PerformanceInfoPromise::CreateAndResolve(std::move(info), + __func__); + }, + [self](const nsresult rv) { + return PerformanceInfoPromise::CreateAndReject(rv, __func__); + }); } nsresult DocGroup::Dispatch(TaskCategory aCategory, diff --git a/dom/base/Document.cpp b/dom/base/Document.cpp index b87cd08aa29b2..35b9c1741e915 100644 --- a/dom/base/Document.cpp +++ b/dom/base/Document.cpp @@ -12627,19 +12627,20 @@ already_AddRefed Document::RequestStorageAccess( AntiTrackingCommon::AddFirstPartyStorageAccessGrantedFor( NodePrincipal(), inner, AntiTrackingCommon::eStorageAccessAPI, performFinalChecks) - ->Then(GetCurrentThreadSerialEventTarget(), __func__, - [outer, promise] { - // Step 10. Grant the document access to cookies and store - // that fact for - // the purposes of future calls to - // hasStorageAccess() and requestStorageAccess(). - outer->SetHasStorageAccess(true); - promise->MaybeResolveWithUndefined(); - }, - [outer, promise] { - outer->SetHasStorageAccess(false); - promise->MaybeRejectWithUndefined(); - }); + ->Then( + GetCurrentThreadSerialEventTarget(), __func__, + [outer, promise] { + // Step 10. Grant the document access to cookies and store + // that fact for + // the purposes of future calls to + // hasStorageAccess() and requestStorageAccess(). + outer->SetHasStorageAccess(true); + promise->MaybeResolveWithUndefined(); + }, + [outer, promise] { + outer->SetHasStorageAccess(false); + promise->MaybeRejectWithUndefined(); + }); return promise.forget(); } diff --git a/dom/base/TreeOrderedArrayInlines.h b/dom/base/TreeOrderedArrayInlines.h index 4b6ab9d00eda2..13d0394eefe85 100644 --- a/dom/base/TreeOrderedArrayInlines.h +++ b/dom/base/TreeOrderedArrayInlines.h @@ -47,8 +47,7 @@ size_t TreeOrderedArray::Insert(Node& aNode) { }; size_t idx; - BinarySearchIf(mList, 0, mList.Length(), - PositionComparator(aNode), &idx); + BinarySearchIf(mList, 0, mList.Length(), PositionComparator(aNode), &idx); mList.InsertElementAt(idx, &aNode); return idx; } diff --git a/dom/base/UIDirectionManager.cpp b/dom/base/UIDirectionManager.cpp index 141ec377602c1..5caa306d41b24 100644 --- a/dom/base/UIDirectionManager.cpp +++ b/dom/base/UIDirectionManager.cpp @@ -51,8 +51,7 @@ void OnPrefChange(const char* aPrefName, void*) { void UIDirectionManager::Initialize() { DebugOnly rv = Preferences::RegisterCallback(OnPrefChange, "intl.uidirection"); - MOZ_ASSERT(NS_SUCCEEDED(rv), - "Failed to observe \"intl.uidirection\""); + MOZ_ASSERT(NS_SUCCEEDED(rv), "Failed to observe \"intl.uidirection\""); } /* static */ diff --git a/dom/base/nsAttrValue.cpp b/dom/base/nsAttrValue.cpp index a315ee898b498..b448d0e121dc3 100644 --- a/dom/base/nsAttrValue.cpp +++ b/dom/base/nsAttrValue.cpp @@ -1645,7 +1645,9 @@ MiscContainer* nsAttrValue::ClearMiscContainer() { delete cont->mValue.mIntMargin; break; } - default: { break; } + default: { + break; + } } } ResetMiscAtomOrString(); diff --git a/dom/base/nsAttrValueInlines.h b/dom/base/nsAttrValueInlines.h index 94005efe94667..6d3069292e1fe 100644 --- a/dom/base/nsAttrValueInlines.h +++ b/dom/base/nsAttrValueInlines.h @@ -242,7 +242,9 @@ inline void nsAttrValue::ToString(mozilla::dom::DOMString& aResult) const { aResult.SetKnownLiveAtom(atom, mozilla::dom::DOMString::eNullNotExpected); break; } - default: { ToString(aResult.AsAString()); } + default: { + ToString(aResult.AsAString()); + } } } diff --git a/dom/base/nsCCUncollectableMarker.cpp b/dom/base/nsCCUncollectableMarker.cpp index 524b236852ff4..c18412aa67b06 100644 --- a/dom/base/nsCCUncollectableMarker.cpp +++ b/dom/base/nsCCUncollectableMarker.cpp @@ -426,7 +426,9 @@ nsresult nsCCUncollectableMarker::Observe(nsISupports* aSubject, xpc_UnmarkSkippableJSHolders(); break; } - default: { break; } + default: { + break; + } } return NS_OK; diff --git a/dom/base/test/gtest/TestContentUtils.cpp b/dom/base/test/gtest/TestContentUtils.cpp index 53f3bbdc85b9d..ad4b59378725f 100644 --- a/dom/base/test/gtest/TestContentUtils.cpp +++ b/dom/base/test/gtest/TestContentUtils.cpp @@ -11,7 +11,8 @@ #include "mozilla/CycleCollectedJSContext.h" #include "mozilla/dom/SimpleGlobalObject.h" -TEST(DOM_Base_ContentUtils, StringifyJSON_EmptyValue) { +TEST(DOM_Base_ContentUtils, StringifyJSON_EmptyValue) +{ JSObject* globalObject = mozilla::dom::SimpleGlobalObject::Create( mozilla::dom::SimpleGlobalObject::GlobalType::BindingDetail); mozilla::dom::AutoJSAPI jsAPI; @@ -25,7 +26,8 @@ TEST(DOM_Base_ContentUtils, StringifyJSON_EmptyValue) { ASSERT_TRUE(serializedValue.EqualsLiteral("null")); } -TEST(DOM_Base_ContentUtils, StringifyJSON_Object) { +TEST(DOM_Base_ContentUtils, StringifyJSON_Object) +{ JSObject* globalObject = mozilla::dom::SimpleGlobalObject::Create( mozilla::dom::SimpleGlobalObject::GlobalType::BindingDetail); mozilla::dom::AutoJSAPI jsAPI; diff --git a/dom/base/test/gtest/TestMimeType.cpp b/dom/base/test/gtest/TestMimeType.cpp index a2759d382491f..cf8af0105450d 100644 --- a/dom/base/test/gtest/TestMimeType.cpp +++ b/dom/base/test/gtest/TestMimeType.cpp @@ -11,576 +11,688 @@ using mozilla::UniquePtr; -TEST(MimeType, EmptyString) { +TEST(MimeType, EmptyString) +{ const auto in = NS_LITERAL_STRING(""); UniquePtr parsed = MimeType::Parse(in); ASSERT_FALSE(parsed) << "Empty string"; } -TEST(MimeType, JustWhitespace) { +TEST(MimeType, JustWhitespace) +{ const auto in = NS_LITERAL_STRING(" \t\r\n "); UniquePtr parsed = MimeType::Parse(in); ASSERT_FALSE(parsed) << "Just whitespace"; } -TEST(MimeType, JustBackslash) { +TEST(MimeType, JustBackslash) +{ const auto in = NS_LITERAL_STRING("\\"); UniquePtr parsed = MimeType::Parse(in); ASSERT_FALSE(parsed) << "Just backslash"; } -TEST(MimeType, JustForwardslash) { +TEST(MimeType, JustForwardslash) +{ const auto in = NS_LITERAL_STRING("/"); UniquePtr parsed = MimeType::Parse(in); ASSERT_FALSE(parsed) << "Just forward slash"; } -TEST(MimeType, MissingType1) { +TEST(MimeType, MissingType1) +{ const auto in = NS_LITERAL_STRING("/bogus"); UniquePtr parsed = MimeType::Parse(in); ASSERT_FALSE(parsed) << "Missing type #1"; } -TEST(MimeType, MissingType2) { +TEST(MimeType, MissingType2) +{ const auto in = NS_LITERAL_STRING(" \r\n\t/bogus"); UniquePtr parsed = MimeType::Parse(in); ASSERT_FALSE(parsed) << "Missing type #2"; } -TEST(MimeType, MissingSubtype1) { +TEST(MimeType, MissingSubtype1) +{ const auto in = NS_LITERAL_STRING("bogus"); UniquePtr parsed = MimeType::Parse(in); ASSERT_FALSE(parsed) << "Missing subtype #1"; } -TEST(MimeType, MissingSubType2) { +TEST(MimeType, MissingSubType2) +{ const auto in = NS_LITERAL_STRING("bogus/"); UniquePtr parsed = MimeType::Parse(in); ASSERT_FALSE(parsed) << "Missing subtype #2"; } -TEST(MimeType, MissingSubType3) { +TEST(MimeType, MissingSubType3) +{ const auto in = NS_LITERAL_STRING("bogus;"); UniquePtr parsed = MimeType::Parse(in); ASSERT_FALSE(parsed) << "Missing subtype #3"; } -TEST(MimeType, MissingSubType4) { +TEST(MimeType, MissingSubType4) +{ const auto in = NS_LITERAL_STRING("bogus; \r\n\t"); UniquePtr parsed = MimeType::Parse(in); ASSERT_FALSE(parsed) << "Missing subtype #3"; } -TEST(MimeType, ExtraForwardSlash) { +TEST(MimeType, ExtraForwardSlash) +{ const auto in = NS_LITERAL_STRING("bogus/bogus/;"); UniquePtr parsed = MimeType::Parse(in); ASSERT_FALSE(parsed) << "Extra forward slash"; } -TEST(MimeType, WhitespaceInType) { +TEST(MimeType, WhitespaceInType) +{ const auto in = NS_LITERAL_STRING("t\re\nx\tt /html"); UniquePtr parsed = MimeType::Parse(in); ASSERT_FALSE(parsed) << "Type with whitespace"; } -TEST(MimeType, WhitespaceInSubtype) { +TEST(MimeType, WhitespaceInSubtype) +{ const auto in = NS_LITERAL_STRING("text/ h\rt\nm\tl"); UniquePtr parsed = MimeType::Parse(in); ASSERT_FALSE(parsed) << "Subtype with whitespace"; } -TEST(MimeType, NonAlphanumericMediaType1) { +TEST(MimeType, NonAlphanumericMediaType1) +{ const auto in = NS_LITERAL_STRING(""); UniquePtr parsed = MimeType::Parse(in); ASSERT_FALSE(parsed) << "Non-alphanumeric media type #1"; } -TEST(MimeType, NonAlphanumericMediaType2) { +TEST(MimeType, NonAlphanumericMediaType2) +{ const auto in = NS_LITERAL_STRING("(/)"); UniquePtr parsed = MimeType::Parse(in); ASSERT_FALSE(parsed) << "Non-alphanumeric media type #2"; } -TEST(MimeType, NonAlphanumericMediaType3) { +TEST(MimeType, NonAlphanumericMediaType3) +{ const auto in = NS_LITERAL_STRING("{/}"); UniquePtr parsed = MimeType::Parse(in); ASSERT_FALSE(parsed) << "Non-alphanumeric media type #3"; } -TEST(MimeType, NonAlphanumericMediaType4) { +TEST(MimeType, NonAlphanumericMediaType4) +{ const auto in = NS_LITERAL_STRING("\"/\""); UniquePtr parsed = MimeType::Parse(in); ASSERT_FALSE(parsed) << "Non-alphanumeric media type #4"; } -TEST(MimeType, NonAlphanumericMediaType5) { +TEST(MimeType, NonAlphanumericMediaType5) +{ const auto in = NS_LITERAL_STRING("\0/\0"); UniquePtr parsed = MimeType::Parse(in); ASSERT_FALSE(parsed) << "Non-alphanumeric media type #5"; } -TEST(MimeType, NonAlphanumericMediaType6) { +TEST(MimeType, NonAlphanumericMediaType6) +{ const auto in = NS_LITERAL_STRING("text/html(;doesnot=matter"); UniquePtr parsed = MimeType::Parse(in); ASSERT_FALSE(parsed) << "Non-alphanumeric media type #6"; } -TEST(MimeType, NonLatin1MediaType1) { +TEST(MimeType, NonLatin1MediaType1) +{ const auto in = NS_LITERAL_STRING("ÿ/ÿ"); UniquePtr parsed = MimeType::Parse(in); ASSERT_FALSE(parsed) << "Non-latin1 media type #1"; } -TEST(MimeType, NonLatin1MediaType2) { +TEST(MimeType, NonLatin1MediaType2) +{ const auto in = NS_LITERAL_STRING(u"\x0100/\x0100"); UniquePtr parsed = MimeType::Parse(in); ASSERT_FALSE(parsed) << "Non-latin1 media type #2"; } -TEST(MimeType, MultipleParameters) { +TEST(MimeType, MultipleParameters) +{ const auto in = NS_LITERAL_STRING("text/html;charset=gbk;no=1;charset_=gbk_;yes=2"); UniquePtr parsed = MimeType::Parse(in); - ASSERT_TRUE(parsed) << "Parsing succeeded"; + ASSERT_TRUE(parsed) + << "Parsing succeeded"; nsString out; parsed->Serialize(out); ASSERT_TRUE(out.Equals( NS_LITERAL_STRING("text/html;charset=gbk;no=1;charset_=gbk_;yes=2"))) - << "Multiple parameters"; + << "Multiple parameters"; } -TEST(MimeType, DuplicateParameter1) { +TEST(MimeType, DuplicateParameter1) +{ const auto in = NS_LITERAL_STRING("text/html;charset=gbk;charset=windows-1255"); UniquePtr parsed = MimeType::Parse(in); - ASSERT_TRUE(parsed) << "Parsing succeeded"; + ASSERT_TRUE(parsed) + << "Parsing succeeded"; nsString out; parsed->Serialize(out); ASSERT_TRUE(out.Equals(NS_LITERAL_STRING("text/html;charset=gbk"))) - << "Duplicate parameter #1"; + << "Duplicate parameter #1"; } -TEST(MimeType, DuplicateParameter2) { +TEST(MimeType, DuplicateParameter2) +{ const auto in = NS_LITERAL_STRING("text/html;charset=();charset=GBK"); UniquePtr parsed = MimeType::Parse(in); - ASSERT_TRUE(parsed) << "Parsing succeeded"; + ASSERT_TRUE(parsed) + << "Parsing succeeded"; nsString out; parsed->Serialize(out); ASSERT_TRUE(out.Equals(NS_LITERAL_STRING("text/html;charset=\"()\""))) - << "Duplicate parameter #2"; + << "Duplicate parameter #2"; } -TEST(MimeType, CString) { +TEST(MimeType, CString) +{ const auto in = NS_LITERAL_CSTRING("text/html;charset=();charset=GBK"); UniquePtr parsed = CMimeType::Parse(in); - ASSERT_TRUE(parsed) << "Parsing succeeded"; + ASSERT_TRUE(parsed) + << "Parsing succeeded"; nsCString out; parsed->Serialize(out); ASSERT_TRUE(out.Equals(NS_LITERAL_CSTRING("text/html;charset=\"()\""))) - << "Duplicate parameter #2"; + << "Duplicate parameter #2"; } #ifdef _MSC_VER # pragma warning(push) # pragma warning(disable : 4819) #endif -TEST(MimeType, NonAlphanumericParametersAreQuoted) { +TEST(MimeType, NonAlphanumericParametersAreQuoted) +{ const auto in = NS_LITERAL_STRING("text/html;test=\x00FF\\;charset=gbk"); UniquePtr parsed = MimeType::Parse(in); - ASSERT_TRUE(parsed) << "Parsing succeeded"; + ASSERT_TRUE(parsed) + << "Parsing succeeded"; nsString out; parsed->Serialize(out); ASSERT_TRUE(out.Equals( NS_LITERAL_STRING("text/html;test=\"\x00FF\\\\\";charset=gbk"))) - << "Non-alphanumeric parameters are quoted"; + << "Non-alphanumeric parameters are quoted"; } #ifdef _MSC_VER # pragma warning(pop) #endif -TEST(MimeType, ParameterQuotedIfHasLeadingWhitespace1) { +TEST(MimeType, ParameterQuotedIfHasLeadingWhitespace1) +{ const auto in = NS_LITERAL_STRING("text/html;charset= g\\\"bk"); UniquePtr parsed = MimeType::Parse(in); - ASSERT_TRUE(parsed) << "Parsing succeeded"; + ASSERT_TRUE(parsed) + << "Parsing succeeded"; nsAutoString out; parsed->Serialize(out); ASSERT_TRUE(out.EqualsLiteral("text/html;charset=\" g\\\\\\\"bk\"")) - << "Parameter is quoted if has leading whitespace #1"; + << "Parameter is quoted if has leading whitespace #1"; } -TEST(MimeType, ParameterQuotedIfHasLeadingWhitespace2) { +TEST(MimeType, ParameterQuotedIfHasLeadingWhitespace2) +{ const auto in = NS_LITERAL_STRING("text/html;charset= \"g\\bk\""); UniquePtr parsed = MimeType::Parse(in); - ASSERT_TRUE(parsed) << "Parsing succeeded"; + ASSERT_TRUE(parsed) + << "Parsing succeeded"; nsAutoString out; parsed->Serialize(out); ASSERT_TRUE(out.EqualsLiteral("text/html;charset=\" \\\"g\\\\bk\\\"\"")) - << "Parameter is quoted if has leading whitespace #2"; + << "Parameter is quoted if has leading whitespace #2"; } -TEST(MimeType, ParameterQuotedIfHasInternalWhitespace) { +TEST(MimeType, ParameterQuotedIfHasInternalWhitespace) +{ const auto in = NS_LITERAL_STRING("text/html;charset=g \\b\"k"); UniquePtr parsed = MimeType::Parse(in); - ASSERT_TRUE(parsed) << "Parsing succeeded"; + ASSERT_TRUE(parsed) + << "Parsing succeeded"; nsAutoString out; parsed->Serialize(out); ASSERT_TRUE(out.EqualsLiteral("text/html;charset=\"g \\\\b\\\"k\"")) - << "Parameter is quoted if has internal whitespace"; + << "Parameter is quoted if has internal whitespace"; } -TEST(MimeType, ImproperlyQuotedParameter1) { +TEST(MimeType, ImproperlyQuotedParameter1) +{ const auto in = NS_LITERAL_STRING("x/x;test=\""); UniquePtr parsed = MimeType::Parse(in); - ASSERT_TRUE(parsed) << "Parsing succeeded"; + ASSERT_TRUE(parsed) + << "Parsing succeeded"; nsAutoString out; parsed->Serialize(out); ASSERT_TRUE(out.EqualsLiteral("x/x;test=\"\"")) - << "Improperly-quoted parameter is handled properly #1"; + << "Improperly-quoted parameter is handled properly #1"; } -TEST(MimeType, ImproperlyQuotedParameter2) { +TEST(MimeType, ImproperlyQuotedParameter2) +{ const auto in = NS_LITERAL_STRING("x/x;test=\"\\"); UniquePtr parsed = MimeType::Parse(in); - ASSERT_TRUE(parsed) << "Parsing succeeded"; + ASSERT_TRUE(parsed) + << "Parsing succeeded"; nsAutoString out; parsed->Serialize(out); ASSERT_TRUE(out.EqualsLiteral("x/x;test=\"\\\\\"")) - << "Improperly-quoted parameter is handled properly #2"; + << "Improperly-quoted parameter is handled properly #2"; } -TEST(MimeType, NonLatin1ParameterIgnored) { +TEST(MimeType, NonLatin1ParameterIgnored) +{ const auto in = NS_LITERAL_STRING(u"x/x;test=\xFFFD;x=x"); UniquePtr parsed = MimeType::Parse(in); - ASSERT_TRUE(parsed) << "Parsing succeeded"; + ASSERT_TRUE(parsed) + << "Parsing succeeded"; nsAutoString out; parsed->Serialize(out); ASSERT_TRUE(out.EqualsLiteral("x/x;x=x")) - << "Non latin-1 parameters are ignored"; + << "Non latin-1 parameters are ignored"; } -TEST(MimeType, ParameterIgnoredIfWhitespaceInName1) { +TEST(MimeType, ParameterIgnoredIfWhitespaceInName1) +{ const auto in = NS_LITERAL_STRING("text/html;charset =gbk;charset=123"); UniquePtr parsed = MimeType::Parse(in); - ASSERT_TRUE(parsed) << "Parsing succeeded"; + ASSERT_TRUE(parsed) + << "Parsing succeeded"; nsAutoString out; parsed->Serialize(out); ASSERT_TRUE(out.EqualsLiteral("text/html;charset=123")) - << "Parameter ignored if whitespace in name #1"; + << "Parameter ignored if whitespace in name #1"; } -TEST(MimeType, ParameterIgnoredIfWhitespaceInName2) { +TEST(MimeType, ParameterIgnoredIfWhitespaceInName2) +{ const auto in = NS_LITERAL_STRING("text/html;cha rset =gbk;charset=123"); UniquePtr parsed = MimeType::Parse(in); - ASSERT_TRUE(parsed) << "Parsing succeeded"; + ASSERT_TRUE(parsed) + << "Parsing succeeded"; nsAutoString out; parsed->Serialize(out); ASSERT_TRUE(out.EqualsLiteral("text/html;charset=123")) - << "Parameter ignored if whitespace in name #2"; + << "Parameter ignored if whitespace in name #2"; } -TEST(MimeType, WhitespaceTrimmed) { +TEST(MimeType, WhitespaceTrimmed) +{ const auto in = NS_LITERAL_STRING( "\n\r\t text/plain\n\r\t ;\n\r\t charset=123\n\r\t "); UniquePtr parsed = MimeType::Parse(in); - ASSERT_TRUE(parsed) << "Parsing succeeded"; + ASSERT_TRUE(parsed) + << "Parsing succeeded"; nsAutoString out; parsed->Serialize(out); ASSERT_TRUE(out.EqualsLiteral("text/plain;charset=123")) - << "Whitespace appropriately ignored"; + << "Whitespace appropriately ignored"; } -TEST(MimeType, WhitespaceOnlyParameterIgnored) { +TEST(MimeType, WhitespaceOnlyParameterIgnored) +{ const auto in = NS_LITERAL_STRING("x/x;x= \r\n\t"); UniquePtr parsed = MimeType::Parse(in); - ASSERT_TRUE(parsed) << "Parsing succeeded"; + ASSERT_TRUE(parsed) + << "Parsing succeeded"; nsAutoString out; parsed->Serialize(out); ASSERT_TRUE(out.EqualsLiteral("x/x")) - << "Whitespace-only parameter is ignored"; + << "Whitespace-only parameter is ignored"; } -TEST(MimeType, IncompleteParameterIgnored1) { +TEST(MimeType, IncompleteParameterIgnored1) +{ const auto in = NS_LITERAL_STRING("x/x;test"); UniquePtr parsed = MimeType::Parse(in); - ASSERT_TRUE(parsed) << "Parsing succeeded"; + ASSERT_TRUE(parsed) + << "Parsing succeeded"; nsAutoString out; parsed->Serialize(out); - ASSERT_TRUE(out.EqualsLiteral("x/x")) << "Incomplete parameter is ignored #1"; + ASSERT_TRUE(out.EqualsLiteral("x/x")) + << "Incomplete parameter is ignored #1"; } -TEST(MimeType, IncompleteParameterIgnored2) { +TEST(MimeType, IncompleteParameterIgnored2) +{ const auto in = NS_LITERAL_STRING("x/x;test="); UniquePtr parsed = MimeType::Parse(in); - ASSERT_TRUE(parsed) << "Parsing succeeded"; + ASSERT_TRUE(parsed) + << "Parsing succeeded"; nsAutoString out; parsed->Serialize(out); - ASSERT_TRUE(out.EqualsLiteral("x/x")) << "Incomplete parameter is ignored #2"; + ASSERT_TRUE(out.EqualsLiteral("x/x")) + << "Incomplete parameter is ignored #2"; } -TEST(MimeType, IncompleteParameterIgnored3) { +TEST(MimeType, IncompleteParameterIgnored3) +{ const auto in = NS_LITERAL_STRING("x/x;test= \r\n\t"); UniquePtr parsed = MimeType::Parse(in); - ASSERT_TRUE(parsed) << "Parsing succeeded"; + ASSERT_TRUE(parsed) + << "Parsing succeeded"; nsAutoString out; parsed->Serialize(out); - ASSERT_TRUE(out.EqualsLiteral("x/x")) << "Incomplete parameter is ignored #3"; + ASSERT_TRUE(out.EqualsLiteral("x/x")) + << "Incomplete parameter is ignored #3"; } -TEST(MimeType, IncompleteParameterIgnored4) { +TEST(MimeType, IncompleteParameterIgnored4) +{ const auto in = NS_LITERAL_STRING("text/html;test;charset=gbk"); UniquePtr parsed = MimeType::Parse(in); - ASSERT_TRUE(parsed) << "Parsing succeeded"; + ASSERT_TRUE(parsed) + << "Parsing succeeded"; nsAutoString out; parsed->Serialize(out); ASSERT_TRUE(out.EqualsLiteral("text/html;charset=gbk")) - << "Incomplete parameter is ignored #4"; + << "Incomplete parameter is ignored #4"; } -TEST(MimeType, IncompleteParameterIgnored5) { +TEST(MimeType, IncompleteParameterIgnored5) +{ const auto in = NS_LITERAL_STRING("text/html;test=;charset=gbk"); UniquePtr parsed = MimeType::Parse(in); - ASSERT_TRUE(parsed) << "Parsing succeeded"; + ASSERT_TRUE(parsed) + << "Parsing succeeded"; nsAutoString out; parsed->Serialize(out); ASSERT_TRUE(out.EqualsLiteral("text/html;charset=gbk")) - << "Incomplete parameter is ignored #5"; + << "Incomplete parameter is ignored #5"; } -TEST(MimeType, EmptyParameterIgnored1) { +TEST(MimeType, EmptyParameterIgnored1) +{ const auto in = NS_LITERAL_STRING("text/html ; ; charset=gbk"); UniquePtr parsed = MimeType::Parse(in); - ASSERT_TRUE(parsed) << "Parsing succeeded"; + ASSERT_TRUE(parsed) + << "Parsing succeeded"; nsAutoString out; parsed->Serialize(out); ASSERT_TRUE(out.EqualsLiteral("text/html;charset=gbk")) - << "Empty parameter ignored #1"; + << "Empty parameter ignored #1"; } -TEST(MimeType, EmptyParameterIgnored2) { +TEST(MimeType, EmptyParameterIgnored2) +{ const auto in = NS_LITERAL_STRING("text/html;;;;charset=gbk"); UniquePtr parsed = MimeType::Parse(in); - ASSERT_TRUE(parsed) << "Parsing succeeded"; + ASSERT_TRUE(parsed) + << "Parsing succeeded"; nsAutoString out; parsed->Serialize(out); ASSERT_TRUE(out.EqualsLiteral("text/html;charset=gbk")) - << "Empty parameter ignored #2"; + << "Empty parameter ignored #2"; } -TEST(MimeType, InvalidParameterIgnored1) { +TEST(MimeType, InvalidParameterIgnored1) +{ const auto in = NS_LITERAL_STRING("text/html;';charset=gbk"); UniquePtr parsed = MimeType::Parse(in); - ASSERT_TRUE(parsed) << "Parsing succeeded"; + ASSERT_TRUE(parsed) + << "Parsing succeeded"; nsAutoString out; parsed->Serialize(out); ASSERT_TRUE(out.EqualsLiteral("text/html;charset=gbk")) - << "Invalid parameter ignored #1"; + << "Invalid parameter ignored #1"; } -TEST(MimeType, InvalidParameterIgnored2) { +TEST(MimeType, InvalidParameterIgnored2) +{ const auto in = NS_LITERAL_STRING("text/html;\";charset=gbk;=123; =321"); UniquePtr parsed = MimeType::Parse(in); - ASSERT_TRUE(parsed) << "Parsing succeeded"; + ASSERT_TRUE(parsed) + << "Parsing succeeded"; nsAutoString out; parsed->Serialize(out); ASSERT_TRUE(out.EqualsLiteral("text/html;charset=gbk")) - << "Invalid parameter ignored #2"; + << "Invalid parameter ignored #2"; } -TEST(MimeType, InvalidParameterIgnored3) { +TEST(MimeType, InvalidParameterIgnored3) +{ const auto in = NS_LITERAL_STRING("text/html;charset= \"\u007F;charset=GBK"); UniquePtr parsed = MimeType::Parse(in); - ASSERT_TRUE(parsed) << "Parsing succeeded"; + ASSERT_TRUE(parsed) + << "Parsing succeeded"; nsAutoString out; parsed->Serialize(out); ASSERT_TRUE(out.EqualsLiteral("text/html;charset=GBK")) - << "Invalid parameter ignored #3"; + << "Invalid parameter ignored #3"; } -TEST(MimeType, InvalidParameterIgnored4) { +TEST(MimeType, InvalidParameterIgnored4) +{ const auto in = NS_LITERAL_STRING( "text/html;charset=\"\u007F;charset=foo\";charset=GBK;charset="); UniquePtr parsed = MimeType::Parse(in); - ASSERT_TRUE(parsed) << "Parsing succeeded"; + ASSERT_TRUE(parsed) + << "Parsing succeeded"; nsAutoString out; parsed->Serialize(out); ASSERT_TRUE(out.EqualsLiteral("text/html;charset=GBK")) - << "Invalid parameter ignored #4"; + << "Invalid parameter ignored #4"; } -TEST(MimeType, SingleQuotes1) { +TEST(MimeType, SingleQuotes1) +{ const auto in = NS_LITERAL_STRING("text/html;charset='gbk'"); UniquePtr parsed = MimeType::Parse(in); - ASSERT_TRUE(parsed) << "Parsing succeeded"; + ASSERT_TRUE(parsed) + << "Parsing succeeded"; nsAutoString out; parsed->Serialize(out); ASSERT_TRUE(out.EqualsLiteral("text/html;charset='gbk'")) - << "Single quotes handled properly #1"; + << "Single quotes handled properly #1"; } -TEST(MimeType, SingleQuotes2) { +TEST(MimeType, SingleQuotes2) +{ const auto in = NS_LITERAL_STRING("text/html;charset='gbk"); UniquePtr parsed = MimeType::Parse(in); - ASSERT_TRUE(parsed) << "Parsing succeeded"; + ASSERT_TRUE(parsed) + << "Parsing succeeded"; nsAutoString out; parsed->Serialize(out); ASSERT_TRUE(out.EqualsLiteral("text/html;charset='gbk")) - << "Single quotes handled properly #2"; + << "Single quotes handled properly #2"; } -TEST(MimeType, SingleQuotes3) { +TEST(MimeType, SingleQuotes3) +{ const auto in = NS_LITERAL_STRING("text/html;charset=gbk'"); UniquePtr parsed = MimeType::Parse(in); - ASSERT_TRUE(parsed) << "Parsing succeeded"; + ASSERT_TRUE(parsed) + << "Parsing succeeded"; nsAutoString out; parsed->Serialize(out); ASSERT_TRUE(out.EqualsLiteral("text/html;charset=gbk'")) - << "Single quotes handled properly #3"; + << "Single quotes handled properly #3"; } -TEST(MimeType, SingleQuotes4) { +TEST(MimeType, SingleQuotes4) +{ const auto in = NS_LITERAL_STRING("text/html;charset=';charset=GBK"); UniquePtr parsed = MimeType::Parse(in); - ASSERT_TRUE(parsed) << "Parsing succeeded"; + ASSERT_TRUE(parsed) + << "Parsing succeeded"; nsAutoString out; parsed->Serialize(out); ASSERT_TRUE(out.EqualsLiteral("text/html;charset='")) - << "Single quotes handled properly #4"; + << "Single quotes handled properly #4"; } -TEST(MimeType, SingleQuotes5) { +TEST(MimeType, SingleQuotes5) +{ const auto in = NS_LITERAL_STRING("text/html;charset=''';charset=GBK"); UniquePtr parsed = MimeType::Parse(in); - ASSERT_TRUE(parsed) << "Parsing succeeded"; + ASSERT_TRUE(parsed) + << "Parsing succeeded"; nsAutoString out; parsed->Serialize(out); ASSERT_TRUE(out.EqualsLiteral("text/html;charset='''")) - << "Single quotes handled properly #5"; + << "Single quotes handled properly #5"; } -TEST(MimeType, DoubleQuotes1) { +TEST(MimeType, DoubleQuotes1) +{ const auto in = NS_LITERAL_STRING("text/html;charset=\"gbk\""); UniquePtr parsed = MimeType::Parse(in); - ASSERT_TRUE(parsed) << "Parsing succeeded"; + ASSERT_TRUE(parsed) + << "Parsing succeeded"; nsAutoString out; parsed->Serialize(out); ASSERT_TRUE(out.EqualsLiteral("text/html;charset=gbk")) - << "Double quotes handled properly #1"; + << "Double quotes handled properly #1"; } -TEST(MimeType, DoubleQuotes2) { +TEST(MimeType, DoubleQuotes2) +{ const auto in = NS_LITERAL_STRING("text/html;charset=\"gbk"); UniquePtr parsed = MimeType::Parse(in); - ASSERT_TRUE(parsed) << "Parsing succeeded"; + ASSERT_TRUE(parsed) + << "Parsing succeeded"; nsAutoString out; parsed->Serialize(out); ASSERT_TRUE(out.EqualsLiteral("text/html;charset=gbk")) - << "Double quotes handled properly #2"; + << "Double quotes handled properly #2"; } -TEST(MimeType, DoubleQuotes3) { +TEST(MimeType, DoubleQuotes3) +{ const auto in = NS_LITERAL_STRING("text/html;charset=gbk\""); UniquePtr parsed = MimeType::Parse(in); - ASSERT_TRUE(parsed) << "Parsing succeeded"; + ASSERT_TRUE(parsed) + << "Parsing succeeded"; nsAutoString out; parsed->Serialize(out); ASSERT_TRUE(out.EqualsLiteral("text/html;charset=\"gbk\\\"\"")) - << "Double quotes handled properly #3"; + << "Double quotes handled properly #3"; } -TEST(MimeType, DoubleQuotes4) { +TEST(MimeType, DoubleQuotes4) +{ const auto in = NS_LITERAL_STRING("text/html;charset=\" gbk\""); UniquePtr parsed = MimeType::Parse(in); - ASSERT_TRUE(parsed) << "Parsing succeeded"; + ASSERT_TRUE(parsed) + << "Parsing succeeded"; nsAutoString out; parsed->Serialize(out); ASSERT_TRUE(out.EqualsLiteral("text/html;charset=\" gbk\"")) - << "Double quotes handled properly #4"; + << "Double quotes handled properly #4"; } -TEST(MimeType, DoubleQuotes5) { +TEST(MimeType, DoubleQuotes5) +{ const auto in = NS_LITERAL_STRING("text/html;charset=\"gbk \""); UniquePtr parsed = MimeType::Parse(in); - ASSERT_TRUE(parsed) << "Parsing succeeded"; + ASSERT_TRUE(parsed) + << "Parsing succeeded"; nsAutoString out; parsed->Serialize(out); ASSERT_TRUE(out.EqualsLiteral("text/html;charset=\"gbk \"")) - << "Double quotes handled properly #5"; + << "Double quotes handled properly #5"; } -TEST(MimeType, DoubleQuotes6) { +TEST(MimeType, DoubleQuotes6) +{ const auto in = NS_LITERAL_STRING("text/html;charset=\"\\ gbk\""); UniquePtr parsed = MimeType::Parse(in); - ASSERT_TRUE(parsed) << "Parsing succeeded"; + ASSERT_TRUE(parsed) + << "Parsing succeeded"; nsAutoString out; parsed->Serialize(out); ASSERT_TRUE(out.EqualsLiteral("text/html;charset=\" gbk\"")) - << "Double quotes handled properly #6"; + << "Double quotes handled properly #6"; } -TEST(MimeType, DoubleQuotes7) { +TEST(MimeType, DoubleQuotes7) +{ const auto in = NS_LITERAL_STRING("text/html;charset=\"\\g\\b\\k\""); UniquePtr parsed = MimeType::Parse(in); - ASSERT_TRUE(parsed) << "Parsing succeeded"; + ASSERT_TRUE(parsed) + << "Parsing succeeded"; nsAutoString out; parsed->Serialize(out); ASSERT_TRUE(out.EqualsLiteral("text/html;charset=gbk")) - << "Double quotes handled properly #7"; + << "Double quotes handled properly #7"; } -TEST(MimeType, DoubleQuotes8) { +TEST(MimeType, DoubleQuotes8) +{ const auto in = NS_LITERAL_STRING("text/html;charset=\"gbk\"x"); UniquePtr parsed = MimeType::Parse(in); - ASSERT_TRUE(parsed) << "Parsing succeeded"; + ASSERT_TRUE(parsed) + << "Parsing succeeded"; nsAutoString out; parsed->Serialize(out); ASSERT_TRUE(out.EqualsLiteral("text/html;charset=gbk")) - << "Double quotes handled properly #8"; + << "Double quotes handled properly #8"; } -TEST(MimeType, DoubleQuotes9) { +TEST(MimeType, DoubleQuotes9) +{ const auto in = NS_LITERAL_STRING("text/html;charset=\"\";charset=GBK"); UniquePtr parsed = MimeType::Parse(in); - ASSERT_TRUE(parsed) << "Parsing succeeded"; + ASSERT_TRUE(parsed) + << "Parsing succeeded"; nsAutoString out; parsed->Serialize(out); ASSERT_TRUE(out.EqualsLiteral("text/html;charset=\"\"")) - << "Double quotes handled properly #9"; + << "Double quotes handled properly #9"; } -TEST(MimeType, DoubleQuotes10) { +TEST(MimeType, DoubleQuotes10) +{ const auto in = NS_LITERAL_STRING("text/html;charset=\";charset=GBK"); UniquePtr parsed = MimeType::Parse(in); - ASSERT_TRUE(parsed) << "Parsing succeeded"; + ASSERT_TRUE(parsed) + << "Parsing succeeded"; nsAutoString out; parsed->Serialize(out); ASSERT_TRUE(out.EqualsLiteral("text/html;charset=\";charset=GBK\"")) - << "Double quotes handled properly #10"; + << "Double quotes handled properly #10"; } -TEST(MimeType, UnexpectedCodePoints) { +TEST(MimeType, UnexpectedCodePoints) +{ const auto in = NS_LITERAL_STRING("text/html;charset={gbk}"); UniquePtr parsed = MimeType::Parse(in); - ASSERT_TRUE(parsed) << "Parsing succeeded"; + ASSERT_TRUE(parsed) + << "Parsing succeeded"; nsAutoString out; parsed->Serialize(out); ASSERT_TRUE(out.EqualsLiteral("text/html;charset=\"{gbk}\"")) - << "Unexpected code points handled properly"; + << "Unexpected code points handled properly"; } -TEST(MimeType, LongTypesSubtypesAccepted) { +TEST(MimeType, LongTypesSubtypesAccepted) +{ const auto in = NS_LITERAL_STRING( "012345678901234567890123456789012345678901234567890123456789012345678901" "2345678901234567890123456789012345678901234567890123456789/" "012345678901234567890123456789012345678901234567890123456789012345678901" "2345678901234567890123456789012345678901234567890123456789"); UniquePtr parsed = MimeType::Parse(in); - ASSERT_TRUE(parsed) << "Parsing succeeded"; + ASSERT_TRUE(parsed) + << "Parsing succeeded"; nsAutoString out; parsed->Serialize(out); - ASSERT_TRUE(out.Equals(in)) << "Long type/subtype accepted"; + ASSERT_TRUE(out.Equals(in)) + << "Long type/subtype accepted"; } -TEST(MimeType, LongParametersAccepted) { +TEST(MimeType, LongParametersAccepted) +{ const auto in = NS_LITERAL_STRING( "text/" "html;" @@ -588,13 +700,16 @@ TEST(MimeType, LongParametersAccepted) { "2345678901234567890123456789012345678901234567890123456789=x;charset=" "gbk"); UniquePtr parsed = MimeType::Parse(in); - ASSERT_TRUE(parsed) << "Parsing succeeded"; + ASSERT_TRUE(parsed) + << "Parsing succeeded"; nsAutoString out; parsed->Serialize(out); - ASSERT_TRUE(out.Equals(in)) << "Long parameters accepted"; + ASSERT_TRUE(out.Equals(in)) + << "Long parameters accepted"; } -TEST(MimeType, AllValidCharactersAccepted1) { +TEST(MimeType, AllValidCharactersAccepted1) +{ const auto in = NS_LITERAL_STRING( u"x/x;x=\"\t " u"!\\\"#$%&'()*+,-./" @@ -613,23 +728,28 @@ TEST(MimeType, AllValidCharactersAccepted1) { u"\u00EE\u00EF\u00F0\u00F1\u00F2\u00F3\u00F4\u00F5\u00F6\u00F7\u00F8" u"\u00F9\u00FA\u00FB\u00FC\u00FD\u00FE\u00FF\""); UniquePtr parsed = MimeType::Parse(in); - ASSERT_TRUE(parsed) << "Parsing succeeded"; + ASSERT_TRUE(parsed) + << "Parsing succeeded"; nsAutoString out; parsed->Serialize(out); - ASSERT_TRUE(out.Equals(in)) << "All valid characters accepted #1"; + ASSERT_TRUE(out.Equals(in)) + << "All valid characters accepted #1"; } -TEST(MimeType, CaseNormalization1) { +TEST(MimeType, CaseNormalization1) +{ const auto in = NS_LITERAL_STRING("TEXT/PLAIN;CHARSET=TEST"); UniquePtr parsed = MimeType::Parse(in); - ASSERT_TRUE(parsed) << "Parsing succeeded"; + ASSERT_TRUE(parsed) + << "Parsing succeeded"; nsAutoString out; parsed->Serialize(out); ASSERT_TRUE(out.EqualsLiteral("text/plain;charset=TEST")) - << "Case normalized properly #1"; + << "Case normalized properly #1"; } -TEST(MimeType, CaseNormalization2) { +TEST(MimeType, CaseNormalization2) +{ const auto in = NS_LITERAL_STRING( "!#$%&'*+-.^_`|~" "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz/" @@ -639,7 +759,8 @@ TEST(MimeType, CaseNormalization2) { "%&'*+-.^_`|~" "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"); UniquePtr parsed = MimeType::Parse(in); - ASSERT_TRUE(parsed) << "Parsing succeeded"; + ASSERT_TRUE(parsed) + << "Parsing succeeded"; nsAutoString out; parsed->Serialize(out); ASSERT_TRUE(out.EqualsLiteral( @@ -650,25 +771,29 @@ TEST(MimeType, CaseNormalization2) { ".^_`|~0123456789abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz=!#$" "%&'*+-.^_`|~" "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")) - << "Case normalized properly #2"; + << "Case normalized properly #2"; } -TEST(MimeType, LegacyCommentSyntax1) { +TEST(MimeType, LegacyCommentSyntax1) +{ const auto in = NS_LITERAL_STRING("text/html;charset=gbk("); UniquePtr parsed = MimeType::Parse(in); - ASSERT_TRUE(parsed) << "Parsing succeeded"; + ASSERT_TRUE(parsed) + << "Parsing succeeded"; nsAutoString out; parsed->Serialize(out); ASSERT_TRUE(out.EqualsLiteral("text/html;charset=\"gbk(\"")) - << "Legacy comment syntax #1"; + << "Legacy comment syntax #1"; } -TEST(MimeType, LegacyCommentSyntax2) { +TEST(MimeType, LegacyCommentSyntax2) +{ const auto in = NS_LITERAL_STRING("text/html;x=(;charset=gbk"); UniquePtr parsed = MimeType::Parse(in); - ASSERT_TRUE(parsed) << "Parsing succeeded"; + ASSERT_TRUE(parsed) + << "Parsing succeeded"; nsAutoString out; parsed->Serialize(out); ASSERT_TRUE(out.EqualsLiteral("text/html;x=\"(\";charset=gbk")) - << "Legacy comment syntax #2"; + << "Legacy comment syntax #2"; } diff --git a/dom/base/test/gtest/TestPlainTextSerializer.cpp b/dom/base/test/gtest/TestPlainTextSerializer.cpp index 2754cedda2a16..133b10de91fd1 100644 --- a/dom/base/test/gtest/TestPlainTextSerializer.cpp +++ b/dom/base/test/gtest/TestPlainTextSerializer.cpp @@ -18,7 +18,8 @@ void ConvertBufToPlainText(nsString &aConBuf, int aFlag) { } // Test for ASCII with format=flowed; delsp=yes -TEST(PlainTextSerializer, ASCIIWithFlowedDelSp) { +TEST(PlainTextSerializer, ASCIIWithFlowedDelSp) +{ nsString test; nsString result; @@ -42,11 +43,12 @@ TEST(PlainTextSerializer, ASCIIWithFlowedDelSp) { "Firefox \r\nFirefox Firefox Firefox\r\n"); ASSERT_TRUE(test.Equals(result)) - << "Wrong HTML to ASCII text serialization with format=flowed; delsp=yes"; + << "Wrong HTML to ASCII text serialization with format=flowed; delsp=yes"; } // Test for CJK with format=flowed; delsp=yes -TEST(PlainTextSerializer, CJKWithFlowedDelSp) { +TEST(PlainTextSerializer, CJKWithFlowedDelSp) +{ nsString test; nsString result; @@ -74,11 +76,12 @@ TEST(PlainTextSerializer, CJKWithFlowedDelSp) { result.AppendLiteral("\r\n"); ASSERT_TRUE(test.Equals(result)) - << "Wrong HTML to CJK text serialization with format=flowed; delsp=yes"; + << "Wrong HTML to CJK text serialization with format=flowed; delsp=yes"; } // Test for CJK with DisallowLineBreaking -TEST(PlainTextSerializer, CJKWithDisallowLineBreaking) { +TEST(PlainTextSerializer, CJKWithDisallowLineBreaking) +{ nsString test; nsString result; @@ -103,11 +106,12 @@ TEST(PlainTextSerializer, CJKWithDisallowLineBreaking) { result.AppendLiteral("\r\n"); ASSERT_TRUE(test.Equals(result)) - << "Wrong HTML to CJK text serialization with OutputDisallowLineBreaking"; + << "Wrong HTML to CJK text serialization with OutputDisallowLineBreaking"; } // Test for ASCII with format=flowed; and quoted lines in preformatted span. -TEST(PlainTextSerializer, PreformatFlowedQuotes) { +TEST(PlainTextSerializer, PreformatFlowedQuotes) +{ nsString test; nsString result; @@ -134,12 +138,14 @@ TEST(PlainTextSerializer, PreformatFlowedQuotes) { ">> Firefox Firefox Firefox Firefox \r\n" ">> Firefox Firefox Firefox Firefox\r\n"); - ASSERT_TRUE(test.Equals(result)) << "Wrong HTML to ASCII text serialization " - "with format=flowed; and quoted " - "lines"; + ASSERT_TRUE(test.Equals(result)) + << "Wrong HTML to ASCII text serialization " + "with format=flowed; and quoted " + "lines"; } -TEST(PlainTextSerializer, PrettyPrintedHtml) { +TEST(PlainTextSerializer, PrettyPrintedHtml) +{ nsString test; test.AppendLiteral("" NS_LINEBREAK "" NS_LINEBREAK " first
" NS_LINEBREAK " second
" NS_LINEBREAK @@ -147,10 +153,11 @@ TEST(PlainTextSerializer, PrettyPrintedHtml) { ConvertBufToPlainText(test, 0); ASSERT_TRUE(test.EqualsLiteral("first" NS_LINEBREAK "second" NS_LINEBREAK)) - << "Wrong prettyprinted html to text serialization"; + << "Wrong prettyprinted html to text serialization"; } -TEST(PlainTextSerializer, PreElement) { +TEST(PlainTextSerializer, PreElement) +{ nsString test; test.AppendLiteral("" NS_LINEBREAK "" NS_LINEBREAK "
" NS_LINEBREAK "  first" NS_LINEBREAK
@@ -160,10 +167,11 @@ TEST(PlainTextSerializer, PreElement) {
   ConvertBufToPlainText(test, 0);
   ASSERT_TRUE(test.EqualsLiteral("  first" NS_LINEBREAK
                                  "  second" NS_LINEBREAK NS_LINEBREAK))
-      << "Wrong prettyprinted html to text serialization";
+  << "Wrong prettyprinted html to text serialization";
 }
 
-TEST(PlainTextSerializer, BlockElement) {
+TEST(PlainTextSerializer, BlockElement)
+{
   nsString test;
   test.AppendLiteral("" NS_LINEBREAK "" NS_LINEBREAK
                      "
" NS_LINEBREAK " first" NS_LINEBREAK @@ -173,10 +181,11 @@ TEST(PlainTextSerializer, BlockElement) { ConvertBufToPlainText(test, 0); ASSERT_TRUE(test.EqualsLiteral("first" NS_LINEBREAK "second" NS_LINEBREAK)) - << "Wrong prettyprinted html to text serialization"; + << "Wrong prettyprinted html to text serialization"; } -TEST(PlainTextSerializer, PreWrapElementForThunderbird) { +TEST(PlainTextSerializer, PreWrapElementForThunderbird) +{ // This test examines the magic pre-wrap setup that Thunderbird relies on. nsString test; test.AppendLiteral( @@ -193,15 +202,16 @@ TEST(PlainTextSerializer, PreWrapElementForThunderbird) { " first" NS_LINEBREAK "line is" NS_LINEBREAK "too long" NS_LINEBREAK " second" NS_LINEBREAK "line is" NS_LINEBREAK "even" NS_LINEBREAK "loooonger" NS_LINEBREAK NS_LINEBREAK NS_LINEBREAK)) - << "Wrong prettyprinted html to text serialization"; + << "Wrong prettyprinted html to text serialization"; } -TEST(PlainTextSerializer, Simple) { +TEST(PlainTextSerializer, Simple) +{ nsString test; test.AppendLiteral( "basespan " "body"); ConvertBufToPlainText(test, 0); ASSERT_TRUE(test.EqualsLiteral("basespanbody")) - << "Wrong html to text serialization"; + << "Wrong html to text serialization"; } diff --git a/dom/base/test/gtest/TestXPathGenerator.cpp b/dom/base/test/gtest/TestXPathGenerator.cpp index 0b6a09233d987..c9f4993179adf 100644 --- a/dom/base/test/gtest/TestXPathGenerator.cpp +++ b/dom/base/test/gtest/TestXPathGenerator.cpp @@ -8,7 +8,8 @@ #include "XPathGenerator.h" #include "nsString.h" -TEST(TestXPathGenerator, TestQuoteArgumentWithoutQuote) { +TEST(TestXPathGenerator, TestQuoteArgumentWithoutQuote) +{ nsAutoString arg; arg.AssignLiteral(u"testing"); @@ -21,7 +22,8 @@ TEST(TestXPathGenerator, TestQuoteArgumentWithoutQuote) { ASSERT_TRUE(expectedResult.Equals(result)); } -TEST(TestXPathGenerator, TestQuoteArgumentWithSingleQuote) { +TEST(TestXPathGenerator, TestQuoteArgumentWithSingleQuote) +{ nsAutoString arg; arg.AssignLiteral(u"\'testing\'"); @@ -34,7 +36,8 @@ TEST(TestXPathGenerator, TestQuoteArgumentWithSingleQuote) { ASSERT_TRUE(expectedResult.Equals(result)); } -TEST(TestXPathGenerator, TestQuoteArgumentWithDoubleQuote) { +TEST(TestXPathGenerator, TestQuoteArgumentWithDoubleQuote) +{ nsAutoString arg; arg.AssignLiteral(u"\"testing\""); @@ -47,7 +50,8 @@ TEST(TestXPathGenerator, TestQuoteArgumentWithDoubleQuote) { ASSERT_TRUE(expectedResult.Equals(result)); } -TEST(TestXPathGenerator, TestQuoteArgumentWithSingleAndDoubleQuote) { +TEST(TestXPathGenerator, TestQuoteArgumentWithSingleAndDoubleQuote) +{ nsAutoString arg; arg.AssignLiteral(u"\'testing\""); @@ -63,7 +67,8 @@ TEST(TestXPathGenerator, TestQuoteArgumentWithSingleAndDoubleQuote) { } TEST(TestXPathGenerator, - TestQuoteArgumentWithDoubleQuoteAndASequenceOfSingleQuote) { + TestQuoteArgumentWithDoubleQuoteAndASequenceOfSingleQuote) +{ nsAutoString arg; arg.AssignLiteral(u"\'\'\'\'testing\""); @@ -79,7 +84,8 @@ TEST(TestXPathGenerator, } TEST(TestXPathGenerator, - TestQuoteArgumentWithDoubleQuoteAndTwoSequencesOfSingleQuote) { + TestQuoteArgumentWithDoubleQuoteAndTwoSequencesOfSingleQuote) +{ nsAutoString arg; arg.AssignLiteral(u"\'\'\'\'testing\'\'\'\'\'\'\""); @@ -96,7 +102,8 @@ TEST(TestXPathGenerator, } TEST(TestXPathGenerator, - TestQuoteArgumentWithDoubleQuoteAndTwoSequencesOfSingleQuoteInMiddle) { + TestQuoteArgumentWithDoubleQuoteAndTwoSequencesOfSingleQuoteInMiddle) +{ nsAutoString arg; arg.AssignLiteral(u"t\'\'\'\'estin\'\'\'\'\'\'\"g"); @@ -112,7 +119,8 @@ TEST(TestXPathGenerator, ASSERT_TRUE(expectedResult.Equals(result)); } -TEST(TestXPathGenerator, TestEscapeNameWithNormalCharacters) { +TEST(TestXPathGenerator, TestEscapeNameWithNormalCharacters) +{ nsAutoString arg; arg.AssignLiteral(u"testing"); @@ -125,7 +133,8 @@ TEST(TestXPathGenerator, TestEscapeNameWithNormalCharacters) { ASSERT_TRUE(expectedResult.Equals(result)); } -TEST(TestXPathGenerator, TestEscapeNameWithSpecialCharacters) { +TEST(TestXPathGenerator, TestEscapeNameWithSpecialCharacters) +{ nsAutoString arg; arg.AssignLiteral(u"^testing!"); diff --git a/dom/cache/Context.cpp b/dom/cache/Context.cpp index 2c656e745b191..d330fc973fe08 100644 --- a/dom/cache/Context.cpp +++ b/dom/cache/Context.cpp @@ -437,7 +437,9 @@ Context::QuotaInitRunnable::Run() { } // ----- case STATE_WAIT_FOR_DIRECTORY_LOCK: - default: { MOZ_CRASH("unexpected state in QuotaInitRunnable"); } + default: { + MOZ_CRASH("unexpected state in QuotaInitRunnable"); + } } if (resolver->Resolved()) { diff --git a/dom/canvas/CanvasRenderingContext2D.cpp b/dom/canvas/CanvasRenderingContext2D.cpp index 4ca93749656ae..0f35c2c9eab5a 100644 --- a/dom/canvas/CanvasRenderingContext2D.cpp +++ b/dom/canvas/CanvasRenderingContext2D.cpp @@ -893,7 +893,7 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(CanvasRenderingContext2D) NS_INTERFACE_MAP_ENTRY(nsISupports) NS_INTERFACE_MAP_END -CanvasRenderingContext2D::ContextState::ContextState() = default; +CanvasRenderingContext2D::ContextState::ContextState() = default; CanvasRenderingContext2D::ContextState::ContextState(const ContextState& aOther) : fontGroup(aOther.fontGroup), diff --git a/dom/canvas/WebGLContextVertices.cpp b/dom/canvas/WebGLContextVertices.cpp index 605accc1f024c..fb336ffdcaf76 100644 --- a/dom/canvas/WebGLContextVertices.cpp +++ b/dom/canvas/WebGLContextVertices.cpp @@ -402,8 +402,8 @@ void WebGLContext::VertexAttribAnyPointer(bool isFuncInt, GLuint index, } WebGLVertexAttribData& vd = mBoundVertexArray->mAttribs[index]; - vd.VertexAttribPointer(isFuncInt, buffer, AutoAssertCast(size), type, normalized, stride, - byteOffset); + vd.VertexAttribPointer(isFuncInt, buffer, AutoAssertCast(size), type, + normalized, stride, byteOffset); mBoundVertexArray->InvalidateCaches(); } diff --git a/dom/canvas/WebGLTexelConversions.h b/dom/canvas/WebGLTexelConversions.h index 31f121a8a314c..7a594a8c05d2e 100644 --- a/dom/canvas/WebGLTexelConversions.h +++ b/dom/canvas/WebGLTexelConversions.h @@ -962,7 +962,7 @@ MOZ_ALWAYS_INLINE void pack(const uint8_t* __restrict src, uint16_t* __restrict dst) { *dst = uint16_t(((src[0] & 0xF8) << 8) | ((src[1] & 0xFC) << 3) | - ((src[2] & 0xF8) >> 3)); + ((src[2] & 0xF8) >> 3)); } template <> @@ -974,7 +974,8 @@ pack(src[0] * scaleFactor); uint8_t srcG = static_cast(src[1] * scaleFactor); uint8_t srcB = static_cast(src[2] * scaleFactor); - *dst = uint16_t(((srcR & 0xF8) << 8) | ((srcG & 0xFC) << 3) | ((srcB & 0xF8) >> 3)); + *dst = uint16_t(((srcR & 0xF8) << 8) | ((srcG & 0xFC) << 3) | + ((srcB & 0xF8) >> 3)); } // FIXME: this routine is lossy and must be removed. @@ -987,7 +988,8 @@ pack(src[0] * scaleFactor); uint8_t srcG = static_cast(src[1] * scaleFactor); uint8_t srcB = static_cast(src[2] * scaleFactor); - *dst = uint16_t(((srcR & 0xF8) << 8) | ((srcG & 0xFC) << 3) | ((srcB & 0xF8) >> 3)); + *dst = uint16_t(((srcR & 0xF8) << 8) | ((srcG & 0xFC) << 3) | + ((srcB & 0xF8) >> 3)); } template <> @@ -1121,8 +1123,8 @@ template <> MOZ_ALWAYS_INLINE void pack(const uint8_t* __restrict src, uint16_t* __restrict dst) { - *dst = uint16_t(((src[0] & 0xF0) << 8) | ((src[1] & 0xF0) << 4) | (src[2] & 0xF0) | - (src[3] >> 4)); + *dst = uint16_t(((src[0] & 0xF0) << 8) | ((src[1] & 0xF0) << 4) | + (src[2] & 0xF0) | (src[3] >> 4)); } template <> @@ -1135,7 +1137,7 @@ pack(src[1] * scaleFactor); uint8_t srcB = static_cast(src[2] * scaleFactor); *dst = uint16_t(((srcR & 0xF0) << 8) | ((srcG & 0xF0) << 4) | (srcB & 0xF0) | - (src[3] >> 4)); + (src[3] >> 4)); } // FIXME: this routine is lossy and must be removed. @@ -1149,7 +1151,7 @@ pack(src[1] * scaleFactor); uint8_t srcB = static_cast(src[2] * scaleFactor); *dst = uint16_t(((srcR & 0xF0) << 8) | ((srcG & 0xF0) << 4) | (srcB & 0xF0) | - (src[3] >> 4)); + (src[3] >> 4)); } template <> @@ -1157,7 +1159,7 @@ MOZ_ALWAYS_INLINE void pack(const uint8_t* __restrict src, uint16_t* __restrict dst) { *dst = uint16_t(((src[0] & 0xF8) << 8) | ((src[1] & 0xF8) << 3) | - ((src[2] & 0xF8) >> 2) | (src[3] >> 7)); + ((src[2] & 0xF8) >> 2) | (src[3] >> 7)); } template <> @@ -1169,8 +1171,8 @@ pack(src[0] * scaleFactor); uint8_t srcG = static_cast(src[1] * scaleFactor); uint8_t srcB = static_cast(src[2] * scaleFactor); - *dst = uint16_t(((srcR & 0xF8) << 8) | ((srcG & 0xF8) << 3) | ((srcB & 0xF8) >> 2) | - (src[3] >> 7)); + *dst = uint16_t(((srcR & 0xF8) << 8) | ((srcG & 0xF8) << 3) | + ((srcB & 0xF8) >> 2) | (src[3] >> 7)); } // FIXME: this routine is lossy and must be removed. @@ -1183,8 +1185,8 @@ pack(src[0] * scaleFactor); uint8_t srcG = static_cast(src[1] * scaleFactor); uint8_t srcB = static_cast(src[2] * scaleFactor); - *dst = uint16_t(((srcR & 0xF8) << 8) | ((srcG & 0xF8) << 3) | ((srcB & 0xF8) >> 2) | - (src[3] >> 7)); + *dst = uint16_t(((srcR & 0xF8) << 8) | ((srcG & 0xF8) << 3) | + ((srcB & 0xF8) >> 2) | (src[3] >> 7)); } template <> diff --git a/dom/canvas/WebGLTexture.h b/dom/canvas/WebGLTexture.h index e96909a75627d..030cc5e83cfd7 100644 --- a/dom/canvas/WebGLTexture.h +++ b/dom/canvas/WebGLTexture.h @@ -270,7 +270,8 @@ class WebGLTexture final : public nsWrapperCache, case LOCAL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: case LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z: case LOCAL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: - return AutoAssertCast(rawTexImageTarget - LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_X); + return AutoAssertCast(rawTexImageTarget - + LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_X); default: return 0; diff --git a/dom/canvas/WebGLTypes.h b/dom/canvas/WebGLTypes.h index e3472aa905a9a..c1102873e2f60 100644 --- a/dom/canvas/WebGLTypes.h +++ b/dom/canvas/WebGLTypes.h @@ -60,14 +60,14 @@ inline void* calloc(const ForbidNarrowing n, namespace detail { -template +template class AutoAssertCastT final { const From mVal; -public: - explicit AutoAssertCastT(const From val) : mVal(val) { } + public: + explicit AutoAssertCastT(const From val) : mVal(val) {} - template + template operator To() const { return AssertedCast(mVal); } @@ -75,7 +75,7 @@ class AutoAssertCastT final { } // namespace detail -template +template inline auto AutoAssertCast(const From val) { return detail::AutoAssertCastT(val); } diff --git a/dom/canvas/gtest/TestImageBitmapColorUtils.cpp b/dom/canvas/gtest/TestImageBitmapColorUtils.cpp index 2aa69ef116295..1f33f3a2d57e3 100644 --- a/dom/canvas/gtest/TestImageBitmapColorUtils.cpp +++ b/dom/canvas/gtest/TestImageBitmapColorUtils.cpp @@ -720,7 +720,8 @@ class LabData : public SimpleImage { /* * From RGB24. */ -TEST(ImageBitmapColorUtils, RGB24ToBGR24_) { +TEST(ImageBitmapColorUtils, RGB24ToBGR24_) +{ const RGB24Data srcData; const BGR24Data dstData; SimpleImage result_(srcData.mWidth, srcData.mHeight, @@ -745,7 +746,8 @@ TEST(ImageBitmapColorUtils, RGB24ToBGR24_) { } } -TEST(ImageBitmapColorUtils, RGB24ToRGBA32) { +TEST(ImageBitmapColorUtils, RGB24ToRGBA32) +{ const RGB24Data srcData; const RGBA32Data dstData; SimpleImage result_(srcData.mWidth, srcData.mHeight, @@ -773,7 +775,8 @@ TEST(ImageBitmapColorUtils, RGB24ToRGBA32) { } } -TEST(ImageBitmapColorUtils, RGB24ToBGRA32) { +TEST(ImageBitmapColorUtils, RGB24ToBGRA32) +{ const RGB24Data srcData; const BGRA32Data dstData; @@ -845,7 +848,8 @@ TEST(ImageBitmapColorUtils, RGB24ToBGRA32) { // gbaPixel[0], rgbaPixel[1], rgbaPixel[2], rgbaPixel[3]); //} -TEST(ImageBitmapColorUtils, RGB24ToYUV444P) { +TEST(ImageBitmapColorUtils, RGB24ToYUV444P) +{ const RGB24Data srcData; const YUV444PData dstData; @@ -872,7 +876,8 @@ TEST(ImageBitmapColorUtils, RGB24ToYUV444P) { } } -TEST(ImageBitmapColorUtils, RGB24ToYUV422P) { +TEST(ImageBitmapColorUtils, RGB24ToYUV422P) +{ const RGB24Data srcData; const YUV422PData dstData; @@ -904,7 +909,8 @@ TEST(ImageBitmapColorUtils, RGB24ToYUV422P) { } } -TEST(ImageBitmapColorUtils, RGB24ToYUV420P) { +TEST(ImageBitmapColorUtils, RGB24ToYUV420P) +{ const RGB24Data srcData; const YUV420PData dstData; @@ -937,7 +943,8 @@ TEST(ImageBitmapColorUtils, RGB24ToYUV420P) { } } -TEST(ImageBitmapColorUtils, RGB24ToNV12) { +TEST(ImageBitmapColorUtils, RGB24ToNV12) +{ const RGB24Data srcData; const NV12Data dstData; @@ -968,7 +975,8 @@ TEST(ImageBitmapColorUtils, RGB24ToNV12) { } } -TEST(ImageBitmapColorUtils, RGB24ToNV21) { +TEST(ImageBitmapColorUtils, RGB24ToNV21) +{ const RGB24Data srcData; const NV21Data dstData; @@ -999,7 +1007,8 @@ TEST(ImageBitmapColorUtils, RGB24ToNV21) { } } -TEST(ImageBitmapColorUtils, RGB24ToHSV) { +TEST(ImageBitmapColorUtils, RGB24ToHSV) +{ const RGB24Data srcData; const HSVData dstData; @@ -1022,7 +1031,8 @@ TEST(ImageBitmapColorUtils, RGB24ToHSV) { } } -TEST(ImageBitmapColorUtils, RGB24ToLab) { +TEST(ImageBitmapColorUtils, RGB24ToLab) +{ const RGB24Data srcData; const LabData dstData; @@ -1045,7 +1055,8 @@ TEST(ImageBitmapColorUtils, RGB24ToLab) { } } -TEST(ImageBitmapColorUtils, RGB24ToGray8) { +TEST(ImageBitmapColorUtils, RGB24ToGray8) +{ const RGB24Data srcData; const GrayData dstData; @@ -1068,7 +1079,8 @@ TEST(ImageBitmapColorUtils, RGB24ToGray8) { * From BGR24. */ -TEST(ImageBitmapColorUtils, BGR24ToRGB24_) { +TEST(ImageBitmapColorUtils, BGR24ToRGB24_) +{ const BGR24Data srcData; const RGB24Data dstData; SimpleImage result_(srcData.mWidth, srcData.mHeight, @@ -1093,7 +1105,8 @@ TEST(ImageBitmapColorUtils, BGR24ToRGB24_) { } } -TEST(ImageBitmapColorUtils, BGR24ToRGBA32) { +TEST(ImageBitmapColorUtils, BGR24ToRGBA32) +{ const BGR24Data srcData; const RGBA32Data dstData; SimpleImage result_(srcData.mWidth, srcData.mHeight, @@ -1121,7 +1134,8 @@ TEST(ImageBitmapColorUtils, BGR24ToRGBA32) { } } -TEST(ImageBitmapColorUtils, BGR24ToBGRA32) { +TEST(ImageBitmapColorUtils, BGR24ToBGRA32) +{ const BGR24Data srcData; const BGRA32Data dstData; SimpleImage result_(srcData.mWidth, srcData.mHeight, @@ -1149,7 +1163,8 @@ TEST(ImageBitmapColorUtils, BGR24ToBGRA32) { } } -TEST(ImageBitmapColorUtils, BGR24ToYUV444P) { +TEST(ImageBitmapColorUtils, BGR24ToYUV444P) +{ const BGR24Data srcData; const YUV444PData dstData; @@ -1176,7 +1191,8 @@ TEST(ImageBitmapColorUtils, BGR24ToYUV444P) { } } -TEST(ImageBitmapColorUtils, BGR24ToYUV422P) { +TEST(ImageBitmapColorUtils, BGR24ToYUV422P) +{ const BGR24Data srcData; const YUV422PData dstData; @@ -1208,7 +1224,8 @@ TEST(ImageBitmapColorUtils, BGR24ToYUV422P) { } } -TEST(ImageBitmapColorUtils, BGR24ToYUV420P) { +TEST(ImageBitmapColorUtils, BGR24ToYUV420P) +{ const BGR24Data srcData; const YUV420PData dstData; @@ -1241,7 +1258,8 @@ TEST(ImageBitmapColorUtils, BGR24ToYUV420P) { } } -TEST(ImageBitmapColorUtils, BGR24ToNV12) { +TEST(ImageBitmapColorUtils, BGR24ToNV12) +{ const BGR24Data srcData; const NV12Data dstData; @@ -1272,7 +1290,8 @@ TEST(ImageBitmapColorUtils, BGR24ToNV12) { } } -TEST(ImageBitmapColorUtils, BGR24ToNV21) { +TEST(ImageBitmapColorUtils, BGR24ToNV21) +{ const BGR24Data srcData; const NV21Data dstData; @@ -1303,7 +1322,8 @@ TEST(ImageBitmapColorUtils, BGR24ToNV21) { } } -TEST(ImageBitmapColorUtils, BGR24ToHSV) { +TEST(ImageBitmapColorUtils, BGR24ToHSV) +{ const BGR24Data srcData; const HSVData dstData; @@ -1326,7 +1346,8 @@ TEST(ImageBitmapColorUtils, BGR24ToHSV) { } } -TEST(ImageBitmapColorUtils, BGR24ToLab) { +TEST(ImageBitmapColorUtils, BGR24ToLab) +{ const BGR24Data srcData; const LabData dstData; @@ -1349,7 +1370,8 @@ TEST(ImageBitmapColorUtils, BGR24ToLab) { } } -TEST(ImageBitmapColorUtils, BGR24ToGray8) { +TEST(ImageBitmapColorUtils, BGR24ToGray8) +{ const BGR24Data srcData; const GrayData dstData; @@ -1371,7 +1393,8 @@ TEST(ImageBitmapColorUtils, BGR24ToGray8) { /* * From RGBA32. */ -TEST(ImageBitmapColorUtils, RGBA32ToRGB24) { +TEST(ImageBitmapColorUtils, RGBA32ToRGB24) +{ const RGBA32Data srcData; const RGB24Data dstData; SimpleImage result_(srcData.mWidth, srcData.mHeight, @@ -1396,7 +1419,8 @@ TEST(ImageBitmapColorUtils, RGBA32ToRGB24) { } } -TEST(ImageBitmapColorUtils, RGBA32ToBGR24) { +TEST(ImageBitmapColorUtils, RGBA32ToBGR24) +{ const RGBA32Data srcData; const BGR24Data dstData; SimpleImage result_(srcData.mWidth, srcData.mHeight, @@ -1421,7 +1445,8 @@ TEST(ImageBitmapColorUtils, RGBA32ToBGR24) { } } -TEST(ImageBitmapColorUtils, RGBA32ToYUV444P) { +TEST(ImageBitmapColorUtils, RGBA32ToYUV444P) +{ const RGBA32Data srcData; const YUV444PData dstData; @@ -1448,7 +1473,8 @@ TEST(ImageBitmapColorUtils, RGBA32ToYUV444P) { } } -TEST(ImageBitmapColorUtils, RGBA32ToYUV422P) { +TEST(ImageBitmapColorUtils, RGBA32ToYUV422P) +{ const RGBA32Data srcData; const YUV422PData dstData; @@ -1480,7 +1506,8 @@ TEST(ImageBitmapColorUtils, RGBA32ToYUV422P) { } } -TEST(ImageBitmapColorUtils, RGBA32ToYUV420P) { +TEST(ImageBitmapColorUtils, RGBA32ToYUV420P) +{ const RGBA32Data srcData; const YUV420PData dstData; @@ -1513,7 +1540,8 @@ TEST(ImageBitmapColorUtils, RGBA32ToYUV420P) { } } -TEST(ImageBitmapColorUtils, RGBA32ToNV12) { +TEST(ImageBitmapColorUtils, RGBA32ToNV12) +{ const RGBA32Data srcData; const NV12Data dstData; @@ -1544,7 +1572,8 @@ TEST(ImageBitmapColorUtils, RGBA32ToNV12) { } } -TEST(ImageBitmapColorUtils, RGBA32ToNV21) { +TEST(ImageBitmapColorUtils, RGBA32ToNV21) +{ const RGBA32Data srcData; const NV21Data dstData; @@ -1575,7 +1604,8 @@ TEST(ImageBitmapColorUtils, RGBA32ToNV21) { } } -TEST(ImageBitmapColorUtils, RGBA32ToHSV) { +TEST(ImageBitmapColorUtils, RGBA32ToHSV) +{ const RGBA32Data srcData; const HSVData dstData; @@ -1598,7 +1628,8 @@ TEST(ImageBitmapColorUtils, RGBA32ToHSV) { } } -TEST(ImageBitmapColorUtils, RGBA32ToLab) { +TEST(ImageBitmapColorUtils, RGBA32ToLab) +{ const RGBA32Data srcData; const LabData dstData; @@ -1621,7 +1652,8 @@ TEST(ImageBitmapColorUtils, RGBA32ToLab) { } } -TEST(ImageBitmapColorUtils, RGBA32ToGray8) { +TEST(ImageBitmapColorUtils, RGBA32ToGray8) +{ const RGBA32Data srcData; const GrayData dstData; @@ -1643,7 +1675,8 @@ TEST(ImageBitmapColorUtils, RGBA32ToGray8) { /* * From BGRA32. */ -TEST(ImageBitmapColorUtils, BGRA32ToRGB24) { +TEST(ImageBitmapColorUtils, BGRA32ToRGB24) +{ const BGRA32Data srcData; const RGB24Data dstData; SimpleImage result_(srcData.mWidth, srcData.mHeight, @@ -1668,7 +1701,8 @@ TEST(ImageBitmapColorUtils, BGRA32ToRGB24) { } } -TEST(ImageBitmapColorUtils, BGRA32ToBGR24) { +TEST(ImageBitmapColorUtils, BGRA32ToBGR24) +{ const BGRA32Data srcData; const BGR24Data dstData; SimpleImage result_(srcData.mWidth, srcData.mHeight, @@ -1693,7 +1727,8 @@ TEST(ImageBitmapColorUtils, BGRA32ToBGR24) { } } -TEST(ImageBitmapColorUtils, BGRA32ToYUV444P) { +TEST(ImageBitmapColorUtils, BGRA32ToYUV444P) +{ const BGRA32Data srcData; const YUV444PData dstData; @@ -1720,7 +1755,8 @@ TEST(ImageBitmapColorUtils, BGRA32ToYUV444P) { } } -TEST(ImageBitmapColorUtils, BGRA32ToYUV422P) { +TEST(ImageBitmapColorUtils, BGRA32ToYUV422P) +{ const BGRA32Data srcData; const YUV422PData dstData; @@ -1752,7 +1788,8 @@ TEST(ImageBitmapColorUtils, BGRA32ToYUV422P) { } } -TEST(ImageBitmapColorUtils, BGRA32ToYUV420P) { +TEST(ImageBitmapColorUtils, BGRA32ToYUV420P) +{ const BGRA32Data srcData; const YUV420PData dstData; @@ -1785,7 +1822,8 @@ TEST(ImageBitmapColorUtils, BGRA32ToYUV420P) { } } -TEST(ImageBitmapColorUtils, BGRA32ToNV12) { +TEST(ImageBitmapColorUtils, BGRA32ToNV12) +{ const BGRA32Data srcData; const NV12Data dstData; @@ -1816,7 +1854,8 @@ TEST(ImageBitmapColorUtils, BGRA32ToNV12) { } } -TEST(ImageBitmapColorUtils, BGRA32ToNV21) { +TEST(ImageBitmapColorUtils, BGRA32ToNV21) +{ const BGRA32Data srcData; const NV21Data dstData; @@ -1847,7 +1886,8 @@ TEST(ImageBitmapColorUtils, BGRA32ToNV21) { } } -TEST(ImageBitmapColorUtils, BGRA32ToHSV) { +TEST(ImageBitmapColorUtils, BGRA32ToHSV) +{ const BGRA32Data srcData; const HSVData dstData; @@ -1870,7 +1910,8 @@ TEST(ImageBitmapColorUtils, BGRA32ToHSV) { } } -TEST(ImageBitmapColorUtils, BGRA32ToLab) { +TEST(ImageBitmapColorUtils, BGRA32ToLab) +{ const BGRA32Data srcData; const LabData dstData; @@ -1893,7 +1934,8 @@ TEST(ImageBitmapColorUtils, BGRA32ToLab) { } } -TEST(ImageBitmapColorUtils, BGRA32ToGray8) { +TEST(ImageBitmapColorUtils, BGRA32ToGray8) +{ const BGRA32Data srcData; const GrayData dstData; @@ -1915,7 +1957,8 @@ TEST(ImageBitmapColorUtils, BGRA32ToGray8) { /* * From YUV444P. */ -TEST(ImageBitmapColorUtils, YUV444PToRGB24) { +TEST(ImageBitmapColorUtils, YUV444PToRGB24) +{ const YUV444PData srcData; const RGBA32DataFromYUV444PData dstData; SimpleImage result_(srcData.mYWidth, srcData.mYHeight, 3); @@ -1941,7 +1984,8 @@ TEST(ImageBitmapColorUtils, YUV444PToRGB24) { } } -TEST(ImageBitmapColorUtils, YUV444PToBGR24) { +TEST(ImageBitmapColorUtils, YUV444PToBGR24) +{ const YUV444PData srcData; const RGBA32DataFromYUV444PData dstData; SimpleImage result_(srcData.mYWidth, srcData.mYHeight, 3); @@ -1967,7 +2011,8 @@ TEST(ImageBitmapColorUtils, YUV444PToBGR24) { } } -TEST(ImageBitmapColorUtils, YUV444PToRGBA32) { +TEST(ImageBitmapColorUtils, YUV444PToRGBA32) +{ const YUV444PData srcData; const RGBA32DataFromYUV444PData dstData; SimpleImage result_(srcData.mYWidth, srcData.mYHeight, @@ -1997,7 +2042,8 @@ TEST(ImageBitmapColorUtils, YUV444PToRGBA32) { } } -TEST(ImageBitmapColorUtils, YUV444PToBGRA32) { +TEST(ImageBitmapColorUtils, YUV444PToBGRA32) +{ const YUV444PData srcData; const RGBA32DataFromYUV444PData dstData; SimpleImage result_(srcData.mYWidth, srcData.mYHeight, @@ -2027,7 +2073,8 @@ TEST(ImageBitmapColorUtils, YUV444PToBGRA32) { } } -TEST(ImageBitmapColorUtils, YUV444PToGray8) { +TEST(ImageBitmapColorUtils, YUV444PToGray8) +{ const YUV444PData srcData; SimpleImage result_(srcData.mYWidth, srcData.mYHeight, 1); @@ -2049,7 +2096,8 @@ TEST(ImageBitmapColorUtils, YUV444PToGray8) { /* * From YUV422P. */ -TEST(ImageBitmapColorUtils, YUV422PToRGB24) { +TEST(ImageBitmapColorUtils, YUV422PToRGB24) +{ const YUV422PData srcData; const RGBA32DataFromYUV422PData dstData; SimpleImage result_(srcData.mYWidth, srcData.mYHeight, 3); @@ -2075,7 +2123,8 @@ TEST(ImageBitmapColorUtils, YUV422PToRGB24) { } } -TEST(ImageBitmapColorUtils, YUV422PToBGR24) { +TEST(ImageBitmapColorUtils, YUV422PToBGR24) +{ const YUV422PData srcData; const RGBA32DataFromYUV422PData dstData; SimpleImage result_(srcData.mYWidth, srcData.mYHeight, 3); @@ -2101,7 +2150,8 @@ TEST(ImageBitmapColorUtils, YUV422PToBGR24) { } } -TEST(ImageBitmapColorUtils, YUV422PToRGBA32) { +TEST(ImageBitmapColorUtils, YUV422PToRGBA32) +{ const YUV422PData srcData; const RGBA32DataFromYUV422PData dstData; SimpleImage result_(srcData.mYWidth, srcData.mYHeight, @@ -2131,7 +2181,8 @@ TEST(ImageBitmapColorUtils, YUV422PToRGBA32) { } } -TEST(ImageBitmapColorUtils, YUV422PToBGRA32) { +TEST(ImageBitmapColorUtils, YUV422PToBGRA32) +{ const YUV422PData srcData; const RGBA32DataFromYUV422PData dstData; SimpleImage result_(srcData.mYWidth, srcData.mYHeight, @@ -2161,7 +2212,8 @@ TEST(ImageBitmapColorUtils, YUV422PToBGRA32) { } } -TEST(ImageBitmapColorUtils, YUV422PToGray8) { +TEST(ImageBitmapColorUtils, YUV422PToGray8) +{ const YUV422PData srcData; SimpleImage result_(srcData.mYWidth, srcData.mYHeight, 1); @@ -2183,7 +2235,8 @@ TEST(ImageBitmapColorUtils, YUV422PToGray8) { /* * From YUV420P. */ -TEST(ImageBitmapColorUtils, YUV420PToRGB24) { +TEST(ImageBitmapColorUtils, YUV420PToRGB24) +{ const YUV420PData srcData; const RGBA32DataFromYUV420PData dstData; SimpleImage result_(srcData.mYWidth, srcData.mYHeight, 3); @@ -2209,7 +2262,8 @@ TEST(ImageBitmapColorUtils, YUV420PToRGB24) { } } -TEST(ImageBitmapColorUtils, YUV420PToBGR24) { +TEST(ImageBitmapColorUtils, YUV420PToBGR24) +{ const YUV420PData srcData; const RGBA32DataFromYUV420PData dstData; SimpleImage result_(srcData.mYWidth, srcData.mYHeight, 3); @@ -2235,7 +2289,8 @@ TEST(ImageBitmapColorUtils, YUV420PToBGR24) { } } -TEST(ImageBitmapColorUtils, YUV420PToRGBA32) { +TEST(ImageBitmapColorUtils, YUV420PToRGBA32) +{ const YUV420PData srcData; const RGBA32DataFromYUV420PData dstData; SimpleImage result_(srcData.mYWidth, srcData.mYHeight, @@ -2265,7 +2320,8 @@ TEST(ImageBitmapColorUtils, YUV420PToRGBA32) { } } -TEST(ImageBitmapColorUtils, YUV420PToBGRA32) { +TEST(ImageBitmapColorUtils, YUV420PToBGRA32) +{ const YUV420PData srcData; const RGBA32DataFromYUV420PData dstData; SimpleImage result_(srcData.mYWidth, srcData.mYHeight, @@ -2295,7 +2351,8 @@ TEST(ImageBitmapColorUtils, YUV420PToBGRA32) { } } -TEST(ImageBitmapColorUtils, YUV420PToGray8) { +TEST(ImageBitmapColorUtils, YUV420PToGray8) +{ const YUV420PData srcData; SimpleImage result_(srcData.mYWidth, srcData.mYHeight, 1); @@ -2317,7 +2374,8 @@ TEST(ImageBitmapColorUtils, YUV420PToGray8) { /* * From NV12. */ -TEST(ImageBitmapColorUtils, NV12ToRGB24) { +TEST(ImageBitmapColorUtils, NV12ToRGB24) +{ const NV12Data srcData; const RGBA32DataFromYUV420PData dstData; SimpleImage result_(srcData.mYWidth, srcData.mYHeight, 3); @@ -2342,7 +2400,8 @@ TEST(ImageBitmapColorUtils, NV12ToRGB24) { } } -TEST(ImageBitmapColorUtils, NV12ToBGR24) { +TEST(ImageBitmapColorUtils, NV12ToBGR24) +{ const NV12Data srcData; const RGBA32DataFromYUV420PData dstData; SimpleImage result_(srcData.mYWidth, srcData.mYHeight, 3); @@ -2367,7 +2426,8 @@ TEST(ImageBitmapColorUtils, NV12ToBGR24) { } } -TEST(ImageBitmapColorUtils, NV12ToRGBA32) { +TEST(ImageBitmapColorUtils, NV12ToRGBA32) +{ const NV12Data srcData; const RGBA32DataFromYUV420PData dstData; SimpleImage result_(srcData.mYWidth, srcData.mYHeight, @@ -2396,7 +2456,8 @@ TEST(ImageBitmapColorUtils, NV12ToRGBA32) { } } -TEST(ImageBitmapColorUtils, NV12ToBGRA32) { +TEST(ImageBitmapColorUtils, NV12ToBGRA32) +{ const NV12Data srcData; const RGBA32DataFromYUV420PData dstData; SimpleImage result_(srcData.mYWidth, srcData.mYHeight, @@ -2425,7 +2486,8 @@ TEST(ImageBitmapColorUtils, NV12ToBGRA32) { } } -TEST(ImageBitmapColorUtils, NV12ToGray8) { +TEST(ImageBitmapColorUtils, NV12ToGray8) +{ const NV12Data srcData; SimpleImage result_(srcData.mYWidth, srcData.mYHeight, 1); @@ -2446,7 +2508,8 @@ TEST(ImageBitmapColorUtils, NV12ToGray8) { /* * From NV21. */ -TEST(ImageBitmapColorUtils, NV21ToRGB24) { +TEST(ImageBitmapColorUtils, NV21ToRGB24) +{ const NV21Data srcData; const RGBA32DataFromYUV420PData dstData; SimpleImage result_(srcData.mYWidth, srcData.mYHeight, 3); @@ -2471,7 +2534,8 @@ TEST(ImageBitmapColorUtils, NV21ToRGB24) { } } -TEST(ImageBitmapColorUtils, NV21ToBGR24) { +TEST(ImageBitmapColorUtils, NV21ToBGR24) +{ const NV21Data srcData; const RGBA32DataFromYUV420PData dstData; SimpleImage result_(srcData.mYWidth, srcData.mYHeight, 3); @@ -2496,7 +2560,8 @@ TEST(ImageBitmapColorUtils, NV21ToBGR24) { } } -TEST(ImageBitmapColorUtils, NV21ToRGBA32) { +TEST(ImageBitmapColorUtils, NV21ToRGBA32) +{ const NV21Data srcData; const RGBA32DataFromYUV420PData dstData; SimpleImage result_(srcData.mYWidth, srcData.mYHeight, @@ -2525,7 +2590,8 @@ TEST(ImageBitmapColorUtils, NV21ToRGBA32) { } } -TEST(ImageBitmapColorUtils, NV21ToBGRA32) { +TEST(ImageBitmapColorUtils, NV21ToBGRA32) +{ const NV21Data srcData; const RGBA32DataFromYUV420PData dstData; SimpleImage result_(srcData.mYWidth, srcData.mYHeight, @@ -2554,7 +2620,8 @@ TEST(ImageBitmapColorUtils, NV21ToBGRA32) { } } -TEST(ImageBitmapColorUtils, NV21ToGray8) { +TEST(ImageBitmapColorUtils, NV21ToGray8) +{ const NV21Data srcData; SimpleImage result_(srcData.mYWidth, srcData.mYHeight, 1); @@ -2575,7 +2642,8 @@ TEST(ImageBitmapColorUtils, NV21ToGray8) { /* * From HSV. */ -TEST(ImageBitmapColorUtils, HSVToRGB24) { +TEST(ImageBitmapColorUtils, HSVToRGB24) +{ const HSVData srcData; const RGB24Data dstData; SimpleImage result_(srcData.mWidth, srcData.mHeight, @@ -2596,7 +2664,8 @@ TEST(ImageBitmapColorUtils, HSVToRGB24) { } } -TEST(ImageBitmapColorUtils, HSVToBGR24) { +TEST(ImageBitmapColorUtils, HSVToBGR24) +{ const HSVData srcData; const BGR24Data dstData; SimpleImage result_(srcData.mWidth, srcData.mHeight, @@ -2617,7 +2686,8 @@ TEST(ImageBitmapColorUtils, HSVToBGR24) { } } -TEST(ImageBitmapColorUtils, HSVToRGBA32) { +TEST(ImageBitmapColorUtils, HSVToRGBA32) +{ const HSVData srcData; const RGBA32Data dstData; SimpleImage result_(srcData.mWidth, srcData.mHeight, @@ -2638,7 +2708,8 @@ TEST(ImageBitmapColorUtils, HSVToRGBA32) { } } -TEST(ImageBitmapColorUtils, HSVToBGRA32) { +TEST(ImageBitmapColorUtils, HSVToBGRA32) +{ const HSVData srcData; const BGRA32Data dstData; SimpleImage result_(srcData.mWidth, srcData.mHeight, @@ -2662,7 +2733,8 @@ TEST(ImageBitmapColorUtils, HSVToBGRA32) { /* * From Lab. */ -TEST(ImageBitmapColorUtils, LabToRGB24) { +TEST(ImageBitmapColorUtils, LabToRGB24) +{ const LabData srcData; const RGB24Data dstData; SimpleImage result_(srcData.mWidth, srcData.mHeight, @@ -2685,7 +2757,8 @@ TEST(ImageBitmapColorUtils, LabToRGB24) { } } -TEST(ImageBitmapColorUtils, LabToBGR24) { +TEST(ImageBitmapColorUtils, LabToBGR24) +{ const LabData srcData; const BGR24Data dstData; SimpleImage result_(srcData.mWidth, srcData.mHeight, @@ -2708,7 +2781,8 @@ TEST(ImageBitmapColorUtils, LabToBGR24) { } } -TEST(ImageBitmapColorUtils, LabToRGBA32) { +TEST(ImageBitmapColorUtils, LabToRGBA32) +{ const LabData srcData; const RGBA32Data dstData; SimpleImage result_(srcData.mWidth, srcData.mHeight, @@ -2731,7 +2805,8 @@ TEST(ImageBitmapColorUtils, LabToRGBA32) { } } -TEST(ImageBitmapColorUtils, LabToBGRA32) { +TEST(ImageBitmapColorUtils, LabToBGRA32) +{ const LabData srcData; const BGRA32Data dstData; SimpleImage result_(srcData.mWidth, srcData.mHeight, diff --git a/dom/clients/api/Client.cpp b/dom/clients/api/Client.cpp index 81d8259749b1d..b18f2fd708322 100644 --- a/dom/clients/api/Client.cpp +++ b/dom/clients/api/Client.cpp @@ -150,19 +150,20 @@ already_AddRefed Client::Focus(ErrorResult& aRv) { MakeRefPtr>(mGlobal); mHandle->Focus() - ->Then(mGlobal->EventTargetFor(TaskCategory::Other), __func__, - [ipcClientInfo, holder, outerPromise](const ClientState& aResult) { - holder->Complete(); - NS_ENSURE_TRUE_VOID(holder->GetParentObject()); - RefPtr newClient = new Client( - holder->GetParentObject(), - ClientInfoAndState(ipcClientInfo, aResult.ToIPC())); - outerPromise->MaybeResolve(newClient); - }, - [holder, outerPromise](nsresult aResult) { - holder->Complete(); - outerPromise->MaybeReject(aResult); - }) + ->Then( + mGlobal->EventTargetFor(TaskCategory::Other), __func__, + [ipcClientInfo, holder, outerPromise](const ClientState& aResult) { + holder->Complete(); + NS_ENSURE_TRUE_VOID(holder->GetParentObject()); + RefPtr newClient = + new Client(holder->GetParentObject(), + ClientInfoAndState(ipcClientInfo, aResult.ToIPC())); + outerPromise->MaybeResolve(newClient); + }, + [holder, outerPromise](nsresult aResult) { + holder->Complete(); + outerPromise->MaybeReject(aResult); + }) ->Track(*holder); return outerPromise.forget(); diff --git a/dom/clients/api/ClientDOMUtil.h b/dom/clients/api/ClientDOMUtil.h index 9fa9922d966a0..ef7831881d918 100644 --- a/dom/clients/api/ClientDOMUtil.h +++ b/dom/clients/api/ClientDOMUtil.h @@ -32,15 +32,16 @@ void StartClientManagerOp(Func aFunc, const Arg& aArg, nsIGlobalObject* aGlobal, MakeRefPtr>(aGlobal); aFunc(aArg, target) - ->Then(target, __func__, - [aResolve, holder](const ClientOpResult& aResult) { - holder->Complete(); - aResolve(aResult); - }, - [aReject, holder](nsresult aResult) { - holder->Complete(); - aReject(aResult); - }) + ->Then( + target, __func__, + [aResolve, holder](const ClientOpResult& aResult) { + holder->Complete(); + aResolve(aResult); + }, + [aReject, holder](nsresult aResult) { + holder->Complete(); + aReject(aResult); + }) ->Track(*holder); } diff --git a/dom/clients/api/Clients.cpp b/dom/clients/api/Clients.cpp index eab633be154c8..bca98f833ebd5 100644 --- a/dom/clients/api/Clients.cpp +++ b/dom/clients/api/Clients.cpp @@ -80,30 +80,31 @@ already_AddRefed Clients::Get(const nsAString& aClientID, MakeRefPtr>(mGlobal); innerPromise - ->Then(target, __func__, - [outerPromise, holder, scope](const ClientOpResult& aResult) { - holder->Complete(); - NS_ENSURE_TRUE_VOID(holder->GetParentObject()); - RefPtr client = new Client( - holder->GetParentObject(), aResult.get_ClientInfoAndState()); - if (client->GetStorageAccess() == - nsContentUtils::StorageAccess::eAllow) { - outerPromise->MaybeResolve(std::move(client)); - return; - } - nsCOMPtr r = NS_NewRunnableFunction( - "Clients::Get() storage denied", [scope] { - ServiceWorkerManager::LocalizeAndReportToAllClients( - scope, "ServiceWorkerGetClientStorageError", - nsTArray()); - }); - SystemGroup::Dispatch(TaskCategory::Other, r.forget()); - outerPromise->MaybeResolveWithUndefined(); - }, - [outerPromise, holder](nsresult aResult) { - holder->Complete(); - outerPromise->MaybeResolveWithUndefined(); - }) + ->Then( + target, __func__, + [outerPromise, holder, scope](const ClientOpResult& aResult) { + holder->Complete(); + NS_ENSURE_TRUE_VOID(holder->GetParentObject()); + RefPtr client = new Client( + holder->GetParentObject(), aResult.get_ClientInfoAndState()); + if (client->GetStorageAccess() == + nsContentUtils::StorageAccess::eAllow) { + outerPromise->MaybeResolve(std::move(client)); + return; + } + nsCOMPtr r = NS_NewRunnableFunction( + "Clients::Get() storage denied", [scope] { + ServiceWorkerManager::LocalizeAndReportToAllClients( + scope, "ServiceWorkerGetClientStorageError", + nsTArray()); + }); + SystemGroup::Dispatch(TaskCategory::Other, r.forget()); + outerPromise->MaybeResolveWithUndefined(); + }, + [outerPromise, holder](nsresult aResult) { + holder->Complete(); + outerPromise->MaybeResolveWithUndefined(); + }) ->Track(*holder); return outerPromise.forget(); diff --git a/dom/clients/manager/ClientHandle.cpp b/dom/clients/manager/ClientHandle.cpp index f194a65a2b901..897300ac0a5be 100644 --- a/dom/clients/manager/ClientHandle.cpp +++ b/dom/clients/manager/ClientHandle.cpp @@ -110,13 +110,14 @@ RefPtr ClientHandle::Control( MOZ_RELEASE_ASSERT(ClientMatchPrincipalInfo(mClientInfo.PrincipalInfo(), aServiceWorker.PrincipalInfo())); - StartOp(ClientControlledArgs(aServiceWorker.ToIPC()), - [outerPromise](const ClientOpResult& aResult) { - outerPromise->Resolve(true, __func__); - }, - [outerPromise](const ClientOpResult& aResult) { - outerPromise->Reject(aResult.get_nsresult(), __func__); - }); + StartOp( + ClientControlledArgs(aServiceWorker.ToIPC()), + [outerPromise](const ClientOpResult& aResult) { + outerPromise->Resolve(true, __func__); + }, + [outerPromise](const ClientOpResult& aResult) { + outerPromise->Reject(aResult.get_nsresult(), __func__); + }); return outerPromise.forget(); } @@ -125,14 +126,15 @@ RefPtr ClientHandle::Focus() { RefPtr outerPromise = new ClientStatePromise::Private(__func__); - StartOp(ClientFocusArgs(), - [outerPromise](const ClientOpResult& aResult) { - outerPromise->Resolve( - ClientState::FromIPC(aResult.get_IPCClientState()), __func__); - }, - [outerPromise](const ClientOpResult& aResult) { - outerPromise->Reject(aResult.get_nsresult(), __func__); - }); + StartOp( + ClientFocusArgs(), + [outerPromise](const ClientOpResult& aResult) { + outerPromise->Resolve( + ClientState::FromIPC(aResult.get_IPCClientState()), __func__); + }, + [outerPromise](const ClientOpResult& aResult) { + outerPromise->Reject(aResult.get_nsresult(), __func__); + }); return outerPromise.forget(); } @@ -156,13 +158,14 @@ RefPtr ClientHandle::PostMessage( RefPtr outerPromise = new GenericPromise::Private(__func__); - StartOp(args, - [outerPromise](const ClientOpResult& aResult) { - outerPromise->Resolve(true, __func__); - }, - [outerPromise](const ClientOpResult& aResult) { - outerPromise->Reject(aResult.get_nsresult(), __func__); - }); + StartOp( + args, + [outerPromise](const ClientOpResult& aResult) { + outerPromise->Resolve(true, __func__); + }, + [outerPromise](const ClientOpResult& aResult) { + outerPromise->Reject(aResult.get_nsresult(), __func__); + }); return outerPromise.forget(); } diff --git a/dom/clients/manager/ClientHandleOpParent.cpp b/dom/clients/manager/ClientHandleOpParent.cpp index c0542b7b2eb77..0d495989f2ce6 100644 --- a/dom/clients/manager/ClientHandleOpParent.cpp +++ b/dom/clients/manager/ClientHandleOpParent.cpp @@ -62,15 +62,16 @@ void ClientHandleOpParent::Init(const ClientOpConstructorArgs& aArgs) { // Capturing 'this' is safe here because we disconnect the promise in // ActorDestroy() which ensures neither lambda is called if the actor // is destroyed before the source operation completes. - p->Then(GetCurrentThreadSerialEventTarget(), __func__, - [this](const ClientOpResult& aResult) { - mPromiseRequestHolder.Complete(); - Unused << PClientHandleOpParent::Send__delete__(this, aResult); - }, - [this](nsresult aRv) { - mPromiseRequestHolder.Complete(); - Unused << PClientHandleOpParent::Send__delete__(this, aRv); - }) + p->Then( + GetCurrentThreadSerialEventTarget(), __func__, + [this](const ClientOpResult& aResult) { + mPromiseRequestHolder.Complete(); + Unused << PClientHandleOpParent::Send__delete__(this, aResult); + }, + [this](nsresult aRv) { + mPromiseRequestHolder.Complete(); + Unused << PClientHandleOpParent::Send__delete__(this, aRv); + }) ->Track(mPromiseRequestHolder); } diff --git a/dom/clients/manager/ClientManagerOpParent.cpp b/dom/clients/manager/ClientManagerOpParent.cpp index 856e3476b5964..7d893648d8f8c 100644 --- a/dom/clients/manager/ClientManagerOpParent.cpp +++ b/dom/clients/manager/ClientManagerOpParent.cpp @@ -24,15 +24,16 @@ void ClientManagerOpParent::DoServiceOp(Method aMethod, Args&&... aArgs) { // Capturing `this` is safe here because we disconnect the promise in // ActorDestroy() which ensures neither lambda is called if the actor // is destroyed before the source operation completes. - p->Then(GetCurrentThreadSerialEventTarget(), __func__, - [this](const mozilla::dom::ClientOpResult& aResult) { - mPromiseRequestHolder.Complete(); - Unused << PClientManagerOpParent::Send__delete__(this, aResult); - }, - [this](nsresult aRv) { - mPromiseRequestHolder.Complete(); - Unused << PClientManagerOpParent::Send__delete__(this, aRv); - }) + p->Then( + GetCurrentThreadSerialEventTarget(), __func__, + [this](const mozilla::dom::ClientOpResult& aResult) { + mPromiseRequestHolder.Complete(); + Unused << PClientManagerOpParent::Send__delete__(this, aResult); + }, + [this](nsresult aRv) { + mPromiseRequestHolder.Complete(); + Unused << PClientManagerOpParent::Send__delete__(this, aRv); + }) ->Track(mPromiseRequestHolder); } diff --git a/dom/clients/manager/ClientNavigateOpChild.cpp b/dom/clients/manager/ClientNavigateOpChild.cpp index 1336ac78a4140..60b0ed39752d8 100644 --- a/dom/clients/manager/ClientNavigateOpChild.cpp +++ b/dom/clients/manager/ClientNavigateOpChild.cpp @@ -287,15 +287,16 @@ void ClientNavigateOpChild::Init(const ClientNavigateOpConstructorArgs& aArgs) { // Capturing `this` is safe here since we clear the mPromiseRequestHolder in // ActorDestroy. promise - ->Then(mSerialEventTarget, __func__, - [this](const ClientOpResult& aResult) { - mPromiseRequestHolder.Complete(); - PClientNavigateOpChild::Send__delete__(this, aResult); - }, - [this](nsresult aResult) { - mPromiseRequestHolder.Complete(); - PClientNavigateOpChild::Send__delete__(this, aResult); - }) + ->Then( + mSerialEventTarget, __func__, + [this](const ClientOpResult& aResult) { + mPromiseRequestHolder.Complete(); + PClientNavigateOpChild::Send__delete__(this, aResult); + }, + [this](nsresult aResult) { + mPromiseRequestHolder.Complete(); + PClientNavigateOpChild::Send__delete__(this, aResult); + }) ->Track(mPromiseRequestHolder); } diff --git a/dom/clients/manager/ClientOpenWindowOpChild.cpp b/dom/clients/manager/ClientOpenWindowOpChild.cpp index 1113659ea7e5d..c19fce3e7e644 100644 --- a/dom/clients/manager/ClientOpenWindowOpChild.cpp +++ b/dom/clients/manager/ClientOpenWindowOpChild.cpp @@ -22,15 +22,16 @@ void ClientOpenWindowOpChild::ActorDestroy(ActorDestroyReason aReason) { void ClientOpenWindowOpChild::Init(const ClientOpenWindowArgs& aArgs) { DoOpenWindow(aArgs) - ->Then(SystemGroup::EventTargetFor(TaskCategory::Other), __func__, - [this](const ClientOpResult& aResult) { - mPromiseRequestHolder.Complete(); - PClientOpenWindowOpChild::Send__delete__(this, aResult); - }, - [this](nsresult aResult) { - mPromiseRequestHolder.Complete(); - PClientOpenWindowOpChild::Send__delete__(this, aResult); - }) + ->Then( + SystemGroup::EventTargetFor(TaskCategory::Other), __func__, + [this](const ClientOpResult& aResult) { + mPromiseRequestHolder.Complete(); + PClientOpenWindowOpChild::Send__delete__(this, aResult); + }, + [this](nsresult aResult) { + mPromiseRequestHolder.Complete(); + PClientOpenWindowOpChild::Send__delete__(this, aResult); + }) ->Track(mPromiseRequestHolder); } diff --git a/dom/clients/manager/ClientOpenWindowUtils.cpp b/dom/clients/manager/ClientOpenWindowUtils.cpp index e34e5f422022c..3d8c2727752b0 100644 --- a/dom/clients/manager/ClientOpenWindowUtils.cpp +++ b/dom/clients/manager/ClientOpenWindowUtils.cpp @@ -302,9 +302,10 @@ void WaitForLoad(const ClientOpenWindowArgs& aArgs, } // Hold the listener alive until the promise settles - ref->Then(aOuterWindow->EventTargetFor(TaskCategory::Other), __func__, - [listener](const ClientOpResult& aResult) {}, - [listener](nsresult aResult) {}); + ref->Then( + aOuterWindow->EventTargetFor(TaskCategory::Other), __func__, + [listener](const ClientOpResult& aResult) {}, + [listener](nsresult aResult) {}); } #ifdef MOZ_WIDGET_ANDROID diff --git a/dom/clients/manager/ClientPrincipalUtils.cpp b/dom/clients/manager/ClientPrincipalUtils.cpp index f8f43980043e0..09f7ccea63f40 100644 --- a/dom/clients/manager/ClientPrincipalUtils.cpp +++ b/dom/clients/manager/ClientPrincipalUtils.cpp @@ -35,7 +35,9 @@ bool ClientMatchPrincipalInfo(const PrincipalInfo& aLeft, // null principal never matches return false; } - default: { break; } + default: { + break; + } } // Clients (windows/workers) should never have an expanded principal type. diff --git a/dom/clients/manager/ClientSource.cpp b/dom/clients/manager/ClientSource.cpp index e6251abba6fe2..4df62090bae5c 100644 --- a/dom/clients/manager/ClientSource.cpp +++ b/dom/clients/manager/ClientSource.cpp @@ -603,15 +603,16 @@ RefPtr ClientSource::Claim(const ClientClaimArgs& aArgs) { auto holder = MakeRefPtr>(global); innerPromise - ->Then(mEventTarget, __func__, - [outerPromise, holder](bool aResult) { - holder->Complete(); - outerPromise->Resolve(NS_OK, __func__); - }, - [outerPromise, holder](nsresult aResult) { - holder->Complete(); - outerPromise->Reject(aResult, __func__); - }) + ->Then( + mEventTarget, __func__, + [outerPromise, holder](bool aResult) { + holder->Complete(); + outerPromise->Resolve(NS_OK, __func__); + }, + [outerPromise, holder](nsresult aResult) { + holder->Complete(); + outerPromise->Reject(aResult, __func__); + }) ->Track(*holder); return outerPromise.forget(); diff --git a/dom/clients/manager/ClientSourceOpChild.cpp b/dom/clients/manager/ClientSourceOpChild.cpp index 67df23743131c..7547ec6a84a9b 100644 --- a/dom/clients/manager/ClientSourceOpChild.cpp +++ b/dom/clients/manager/ClientSourceOpChild.cpp @@ -56,15 +56,16 @@ void ClientSourceOpChild::DoSourceOp(Method aMethod, const Args& aArgs) { // If the ClientSource is doing something async it may throw away the // promise on its side if the global is closed. promise - ->Then(target, __func__, - [this, promise](const mozilla::dom::ClientOpResult& aResult) { - mPromiseRequestHolder.Complete(); - Unused << PClientSourceOpChild::Send__delete__(this, aResult); - }, - [this, promise](nsresult aRv) { - mPromiseRequestHolder.Complete(); - Unused << PClientSourceOpChild::Send__delete__(this, aRv); - }) + ->Then( + target, __func__, + [this, promise](const mozilla::dom::ClientOpResult& aResult) { + mPromiseRequestHolder.Complete(); + Unused << PClientSourceOpChild::Send__delete__(this, aResult); + }, + [this, promise](nsresult aRv) { + mPromiseRequestHolder.Complete(); + Unused << PClientSourceOpChild::Send__delete__(this, aRv); + }) ->Track(mPromiseRequestHolder); } diff --git a/dom/clients/manager/ClientThing.h b/dom/clients/manager/ClientThing.h index af16984df35bd..69c8e634144f4 100644 --- a/dom/clients/manager/ClientThing.h +++ b/dom/clients/manager/ClientThing.h @@ -68,8 +68,8 @@ class ClientThing { // Conditionally execute the given callable based on the current state. template - void MaybeExecute(const Callable& aSuccess, - const std::function& aFailure = [] {}) { + void MaybeExecute( + const Callable& aSuccess, const std::function& aFailure = [] {}) { AssertIsValid(); if (mShutdown) { aFailure(); diff --git a/dom/clients/manager/ClientValidation.cpp b/dom/clients/manager/ClientValidation.cpp index 07ba1d6789e16..1dcea78f08f47 100644 --- a/dom/clients/manager/ClientValidation.cpp +++ b/dom/clients/manager/ClientValidation.cpp @@ -58,7 +58,9 @@ bool ClientIsValidPrincipalInfo(const PrincipalInfo& aPrincipalInfo) { // cases in the future. return specOrigin == originOrigin; } - default: { break; } + default: { + break; + } } // Windows and workers should not have expanded URLs, etc. @@ -144,7 +146,9 @@ bool ClientIsValidCreationURL(const PrincipalInfo& aPrincipalInfo, // queries anyway. return true; } - default: { break; } + default: { + break; + } } // Clients (windows/workers) should never have an expanded principal type. diff --git a/dom/encoding/FallbackEncoding.cpp b/dom/encoding/FallbackEncoding.cpp index 50cddf74773f3..6ecc12438395c 100644 --- a/dom/encoding/FallbackEncoding.cpp +++ b/dom/encoding/FallbackEncoding.cpp @@ -29,11 +29,12 @@ static NotNull SearchEncodingProp( const EncodingProp (&aProperties)[N], const nsACString& aKey) { const nsCString& flat = PromiseFlatCString(aKey); size_t index; - if (!BinarySearchIf(aProperties, 0, ArrayLength(aProperties), - [&flat](const EncodingProp& aProperty) { - return flat.Compare(aProperty.mKey); - }, - &index)) { + if (!BinarySearchIf( + aProperties, 0, ArrayLength(aProperties), + [&flat](const EncodingProp& aProperty) { + return flat.Compare(aProperty.mKey); + }, + &index)) { return WINDOWS_1252_ENCODING; } return aProperties[index].mValue; diff --git a/dom/events/EventStateManager.cpp b/dom/events/EventStateManager.cpp index a71096bdbe865..e433e953be3bf 100644 --- a/dom/events/EventStateManager.cpp +++ b/dom/events/EventStateManager.cpp @@ -1296,7 +1296,9 @@ void EventStateManager::DispatchCrossProcessEvent(WidgetEvent* aEvent, remote->SendPluginEvent(*aEvent->AsPluginEvent()); return; } - default: { MOZ_CRASH("Attempt to send non-whitelisted event?"); } + default: { + MOZ_CRASH("Attempt to send non-whitelisted event?"); + } } } diff --git a/dom/html/HTMLMediaElement.cpp b/dom/html/HTMLMediaElement.cpp index 76816df6cef01..2e6d570f37c89 100644 --- a/dom/html/HTMLMediaElement.cpp +++ b/dom/html/HTMLMediaElement.cpp @@ -6450,24 +6450,25 @@ bool HTMLMediaElement::TryRemoveMediaKeysAssociation() { if (mDecoder) { RefPtr self = this; mDecoder->SetCDMProxy(nullptr) - ->Then(mAbstractMainThread, __func__, - [self]() { - self->mSetCDMRequest.Complete(); - - self->RemoveMediaKeys(); - if (self->AttachNewMediaKeys()) { - // No incoming MediaKeys object or MediaDecoder is not - // created yet. - self->MakeAssociationWithCDMResolved(); - } - }, - [self](const MediaResult& aResult) { - self->mSetCDMRequest.Complete(); - // 5.2.4 If the preceding step failed, let this object's - // attaching media keys value be false and reject promise with - // a new DOMException whose name is the appropriate error name. - self->SetCDMProxyFailure(aResult); - }) + ->Then( + mAbstractMainThread, __func__, + [self]() { + self->mSetCDMRequest.Complete(); + + self->RemoveMediaKeys(); + if (self->AttachNewMediaKeys()) { + // No incoming MediaKeys object or MediaDecoder is not + // created yet. + self->MakeAssociationWithCDMResolved(); + } + }, + [self](const MediaResult& aResult) { + self->mSetCDMRequest.Complete(); + // 5.2.4 If the preceding step failed, let this object's + // attaching media keys value be false and reject promise with + // a new DOMException whose name is the appropriate error name. + self->SetCDMProxyFailure(aResult); + }) ->Track(mSetCDMRequest); return false; } @@ -6523,15 +6524,16 @@ bool HTMLMediaElement::TryMakeAssociationWithCDM(CDMProxy* aProxy) { // HTMLMediaElement should resolve or reject the DOM promise. RefPtr self = this; mDecoder->SetCDMProxy(aProxy) - ->Then(mAbstractMainThread, __func__, - [self]() { - self->mSetCDMRequest.Complete(); - self->MakeAssociationWithCDMResolved(); - }, - [self](const MediaResult& aResult) { - self->mSetCDMRequest.Complete(); - self->SetCDMProxyFailure(aResult); - }) + ->Then( + mAbstractMainThread, __func__, + [self]() { + self->mSetCDMRequest.Complete(); + self->MakeAssociationWithCDMResolved(); + }, + [self](const MediaResult& aResult) { + self->mSetCDMRequest.Complete(); + self->SetCDMProxyFailure(aResult); + }) ->Track(mSetCDMRequest); return false; } diff --git a/dom/indexedDB/ActorsChild.cpp b/dom/indexedDB/ActorsChild.cpp index 750484bdb7923..69e4347f80609 100644 --- a/dom/indexedDB/ActorsChild.cpp +++ b/dom/indexedDB/ActorsChild.cpp @@ -1720,13 +1720,14 @@ mozilla::ipc::IPCResult BackgroundFactoryRequestChild::RecvPermissionChallenge( IPC::Principal ipcPrincipal(principal); tabChild->SendIndexedDBPermissionRequest(ipcPrincipal) - ->Then(GetCurrentThreadSerialEventTarget(), __func__, - [this](const uint32_t& aPermission) { - this->AssertIsOnOwningThread(); - MaybeCollectGarbageOnIPCMessage(); - this->SendPermissionRetry(); - }, - [](const mozilla::ipc::ResponseRejectReason) {}); + ->Then( + GetCurrentThreadSerialEventTarget(), __func__, + [this](const uint32_t& aPermission) { + this->AssertIsOnOwningThread(); + MaybeCollectGarbageOnIPCMessage(); + this->SendPermissionRetry(); + }, + [](const mozilla::ipc::ResponseRejectReason) {}); return IPC_OK(); } diff --git a/dom/ipc/SharedStringMap.cpp b/dom/ipc/SharedStringMap.cpp index 59bdba0af31a9..6ebdc44ceaa72 100644 --- a/dom/ipc/SharedStringMap.cpp +++ b/dom/ipc/SharedStringMap.cpp @@ -67,11 +67,12 @@ bool SharedStringMap::Get(const nsCString& aKey, nsAString& aValue) { bool SharedStringMap::Find(const nsCString& aKey, size_t* aIndex) { const auto& keys = KeyTable(); - return BinarySearchIf(Entries(), 0, EntryCount(), - [&](const Entry& aEntry) { - return aKey.Compare(keys.GetBare(aEntry.mKey)); - }, - aIndex); + return BinarySearchIf( + Entries(), 0, EntryCount(), + [&](const Entry& aEntry) { + return aKey.Compare(keys.GetBare(aEntry.mKey)); + }, + aIndex); } void SharedStringMapBuilder::Add(const nsCString& aKey, diff --git a/dom/ipc/TabContext.cpp b/dom/ipc/TabContext.cpp index 6abe871721b31..dc29c591885de 100644 --- a/dom/ipc/TabContext.cpp +++ b/dom/ipc/TabContext.cpp @@ -219,7 +219,9 @@ MaybeInvalidTabContext::MaybeInvalidTabContext(const IPCTabContext& aParams) break; } - default: { MOZ_CRASH(); } + default: { + MOZ_CRASH(); + } } bool rv; diff --git a/dom/ipc/TabParent.cpp b/dom/ipc/TabParent.cpp index b537cd34ac53d..cb155b27c9109 100644 --- a/dom/ipc/TabParent.cpp +++ b/dom/ipc/TabParent.cpp @@ -158,7 +158,8 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(TabParent) NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference) NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsITabParent) NS_INTERFACE_MAP_END -NS_IMPL_CYCLE_COLLECTION(TabParent, mFrameElement, mBrowserDOMWindow, mLoadContext, mFrameLoader, mBrowsingContext) +NS_IMPL_CYCLE_COLLECTION(TabParent, mFrameElement, mBrowserDOMWindow, + mLoadContext, mFrameLoader, mBrowsingContext) NS_IMPL_CYCLE_COLLECTING_ADDREF(TabParent) NS_IMPL_CYCLE_COLLECTING_RELEASE(TabParent) @@ -3047,18 +3048,19 @@ TabParent::GetContentBlockingLog(Promise** aPromise) { copy.forget(aPromise); auto cblPromise = SendGetContentBlockingLog(); - cblPromise->Then(GetMainThreadSerialEventTarget(), __func__, - [jsPromise](Tuple&& aResult) { - if (Get<1>(aResult)) { - NS_ConvertUTF8toUTF16 utf16(Get<0>(aResult)); - jsPromise->MaybeResolve(std::move(utf16)); - } else { - jsPromise->MaybeRejectWithUndefined(); - } - }, - [jsPromise](ResponseRejectReason&& aReason) { - jsPromise->MaybeRejectWithUndefined(); - }); + cblPromise->Then( + GetMainThreadSerialEventTarget(), __func__, + [jsPromise](Tuple&& aResult) { + if (Get<1>(aResult)) { + NS_ConvertUTF8toUTF16 utf16(Get<0>(aResult)); + jsPromise->MaybeResolve(std::move(utf16)); + } else { + jsPromise->MaybeRejectWithUndefined(); + } + }, + [jsPromise](ResponseRejectReason&& aReason) { + jsPromise->MaybeRejectWithUndefined(); + }); return NS_OK; } @@ -3158,13 +3160,14 @@ void TabParent::RequestRootPaint(gfx::CrossProcessPaint* aPaint, IntRect aRect, RefPtr paint(aPaint); TabId tabId(GetTabId()); - promise->Then(GetMainThreadSerialEventTarget(), __func__, - [paint, tabId](PaintFragment&& aFragment) { - paint->ReceiveFragment(tabId, std::move(aFragment)); - }, - [paint, tabId](ResponseRejectReason&& aReason) { - paint->LostFragment(tabId); - }); + promise->Then( + GetMainThreadSerialEventTarget(), __func__, + [paint, tabId](PaintFragment&& aFragment) { + paint->ReceiveFragment(tabId, std::move(aFragment)); + }, + [paint, tabId](ResponseRejectReason&& aReason) { + paint->LostFragment(tabId); + }); } void TabParent::RequestSubPaint(gfx::CrossProcessPaint* aPaint, float aScale, @@ -3173,13 +3176,14 @@ void TabParent::RequestSubPaint(gfx::CrossProcessPaint* aPaint, float aScale, RefPtr paint(aPaint); TabId tabId(GetTabId()); - promise->Then(GetMainThreadSerialEventTarget(), __func__, - [paint, tabId](PaintFragment&& aFragment) { - paint->ReceiveFragment(tabId, std::move(aFragment)); - }, - [paint, tabId](ResponseRejectReason&& aReason) { - paint->LostFragment(tabId); - }); + promise->Then( + GetMainThreadSerialEventTarget(), __func__, + [paint, tabId](PaintFragment&& aFragment) { + paint->ReceiveFragment(tabId, std::move(aFragment)); + }, + [paint, tabId](ResponseRejectReason&& aReason) { + paint->LostFragment(tabId); + }); } mozilla::ipc::IPCResult TabParent::RecvPaintWhileInterruptingJSNoOp( diff --git a/dom/localstorage/test/gtest/TestLocalStorage.cpp b/dom/localstorage/test/gtest/TestLocalStorage.cpp index b6f24ab9434a4..c4e6c4670b5aa 100644 --- a/dom/localstorage/test/gtest/TestLocalStorage.cpp +++ b/dom/localstorage/test/gtest/TestLocalStorage.cpp @@ -69,21 +69,25 @@ void CheckGeneratedOriginKey(nsIPrincipal* aPrincipal, const char* aOriginKey) { } // namespace -TEST(LocalStorage, OriginKey) { +TEST(LocalStorage, OriginKey) +{ // Check the system principal. nsCOMPtr secMan = nsContentUtils::GetSecurityManager(); - ASSERT_TRUE(secMan) << "GetSecurityManager() should not fail"; + ASSERT_TRUE(secMan) + << "GetSecurityManager() should not fail"; nsCOMPtr principal; secMan->GetSystemPrincipal(getter_AddRefs(principal)); - ASSERT_TRUE(principal) << "GetSystemPrincipal() should not fail"; + ASSERT_TRUE(principal) + << "GetSystemPrincipal() should not fail"; CheckGeneratedOriginKey(principal, nullptr); // Check the null principal. principal = NullPrincipal::CreateWithoutOriginAttributes(); - ASSERT_TRUE(principal) << "CreateWithoutOriginAttributes() should not fail"; + ASSERT_TRUE(principal) + << "CreateWithoutOriginAttributes() should not fail"; CheckGeneratedOriginKey(principal, nullptr); @@ -106,7 +110,8 @@ TEST(LocalStorage, OriginKey) { for (const auto& test : tests) { principal = GetCodebasePrincipal(test.mSpec); - ASSERT_TRUE(principal) << "GetCodebasePrincipal() should not fail"; + ASSERT_TRUE(principal) + << "GetCodebasePrincipal() should not fail"; CheckGeneratedOriginKey(principal, test.mOriginKey); } diff --git a/dom/media/Benchmark.cpp b/dom/media/Benchmark.cpp index aedb1aee26112..19f70b7585eca 100644 --- a/dom/media/Benchmark.cpp +++ b/dom/media/Benchmark.cpp @@ -282,15 +282,15 @@ void BenchmarkPlayback::GlobalShutdown() { if (mDecoder) { RefPtr ref(mGlobalState); - mDecoder->Flush()->Then(Thread(), __func__, - [ref, this]() { - mDecoder->Shutdown()->Then( - Thread(), __func__, - [ref, this]() { FinalizeShutdown(); }, - []() { MOZ_CRASH("not reached"); }); - mDecoder = nullptr; - }, - []() { MOZ_CRASH("not reached"); }); + mDecoder->Flush()->Then( + Thread(), __func__, + [ref, this]() { + mDecoder->Shutdown()->Then( + Thread(), __func__, [ref, this]() { FinalizeShutdown(); }, + []() { MOZ_CRASH("not reached"); }); + mDecoder = nullptr; + }, + []() { MOZ_CRASH("not reached"); }); } else { FinalizeShutdown(); } @@ -345,34 +345,36 @@ void BenchmarkPlayback::InputExhausted() { mSampleIndex++; if (mSampleIndex == mSamples.Length() && !ref->mParameters.mStopAtFrame) { // Complete current frame decode then drain if still necessary. - p->Then(Thread(), __func__, - [ref, this](MediaDataDecoder::DecodedData&& aResults) { - Output(std::move(aResults)); - if (!mFinished) { - mDecoder->Drain()->Then( - Thread(), __func__, - [ref, this](MediaDataDecoder::DecodedData&& aResults) { - mDrained = true; - Output(std::move(aResults)); - MOZ_ASSERT(mFinished, "We must be done now"); - }, - [ref, this](const MediaResult& aError) { Error(aError); }); - } - }, - [ref, this](const MediaResult& aError) { Error(aError); }); + p->Then( + Thread(), __func__, + [ref, this](MediaDataDecoder::DecodedData&& aResults) { + Output(std::move(aResults)); + if (!mFinished) { + mDecoder->Drain()->Then( + Thread(), __func__, + [ref, this](MediaDataDecoder::DecodedData&& aResults) { + mDrained = true; + Output(std::move(aResults)); + MOZ_ASSERT(mFinished, "We must be done now"); + }, + [ref, this](const MediaResult& aError) { Error(aError); }); + } + }, + [ref, this](const MediaResult& aError) { Error(aError); }); } else { if (mSampleIndex == mSamples.Length() && ref->mParameters.mStopAtFrame) { mSampleIndex = 0; } // Continue decoding - p->Then(Thread(), __func__, - [ref, this](MediaDataDecoder::DecodedData&& aResults) { - Output(std::move(aResults)); - if (!mFinished) { - InputExhausted(); - } - }, - [ref, this](const MediaResult& aError) { Error(aError); }); + p->Then( + Thread(), __func__, + [ref, this](MediaDataDecoder::DecodedData&& aResults) { + Output(std::move(aResults)); + if (!mFinished) { + InputExhausted(); + } + }, + [ref, this](const MediaResult& aError) { Error(aError); }); } } diff --git a/dom/media/ChannelMediaDecoder.cpp b/dom/media/ChannelMediaDecoder.cpp index 2358ac309956a..99c57130f308e 100644 --- a/dom/media/ChannelMediaDecoder.cpp +++ b/dom/media/ChannelMediaDecoder.cpp @@ -387,19 +387,20 @@ void ChannelMediaDecoder::DownloadProgressed() { MediaStatistics stats = GetStatistics(rate, res, pos); return StatsPromise::CreateAndResolve(stats, __func__); }) - ->Then(mAbstractMainThread, __func__, - [=, self = RefPtr(this)]( - MediaStatistics aStats) { - if (IsShutdown()) { - return; - } - mCanPlayThrough = aStats.CanPlayThrough(); - GetStateMachine()->DispatchCanPlayThrough(mCanPlayThrough); - mResource->ThrottleReadahead(ShouldThrottleDownload(aStats)); - // Update readyState since mCanPlayThrough might have changed. - GetOwner()->UpdateReadyState(); - }, - []() { MOZ_ASSERT_UNREACHABLE("Promise not resolved"); }); + ->Then( + mAbstractMainThread, __func__, + [=, + self = RefPtr(this)](MediaStatistics aStats) { + if (IsShutdown()) { + return; + } + mCanPlayThrough = aStats.CanPlayThrough(); + GetStateMachine()->DispatchCanPlayThrough(mCanPlayThrough); + mResource->ThrottleReadahead(ShouldThrottleDownload(aStats)); + // Update readyState since mCanPlayThrough might have changed. + GetOwner()->UpdateReadyState(); + }, + []() { MOZ_ASSERT_UNREACHABLE("Promise not resolved"); }); } /* static */ ChannelMediaDecoder::PlaybackRateInfo diff --git a/dom/media/DOMMediaStream.cpp b/dom/media/DOMMediaStream.cpp index 202ed09d53160..015b04d5d067c 100644 --- a/dom/media/DOMMediaStream.cpp +++ b/dom/media/DOMMediaStream.cpp @@ -1055,11 +1055,12 @@ void DOMMediaStream::BlockPlaybackTrack(TrackPort* aTrack) { RefPtr that = this; aTrack ->BlockSourceTrackId(aTrack->GetTrack()->mTrackID, BlockingMode::CREATION) - ->Then(GetCurrentThreadSerialEventTarget(), __func__, - [this, that](bool aIgnore) { NotifyPlaybackTrackBlocked(); }, - [](const nsresult& aIgnore) { - NS_ERROR("Could not remove track from MSG"); - }); + ->Then( + GetCurrentThreadSerialEventTarget(), __func__, + [this, that](bool aIgnore) { NotifyPlaybackTrackBlocked(); }, + [](const nsresult& aIgnore) { + NS_ERROR("Could not remove track from MSG"); + }); } void DOMMediaStream::NotifyPlaybackTrackBlocked() { diff --git a/dom/media/MediaDecoderStateMachine.cpp b/dom/media/MediaDecoderStateMachine.cpp index eb0691f107534..89b009261879f 100644 --- a/dom/media/MediaDecoderStateMachine.cpp +++ b/dom/media/MediaDecoderStateMachine.cpp @@ -316,11 +316,12 @@ class MediaDecoderStateMachine::DecodeMetadataState // a raw pointer here. Reader() ->ReadMetadata() - ->Then(OwnerThread(), __func__, - [this](MetadataHolder&& aMetadata) { - OnMetadataRead(std::move(aMetadata)); - }, - [this](const MediaResult& aError) { OnMetadataNotRead(aError); }) + ->Then( + OwnerThread(), __func__, + [this](MetadataHolder&& aMetadata) { + OnMetadataRead(std::move(aMetadata)); + }, + [this](const MediaResult& aError) { OnMetadataNotRead(aError); }) ->Track(mMetadataRequest); } @@ -710,12 +711,13 @@ class MediaDecoderStateMachine::DecodingState TimeStamp target = TimeStamp::Now() + TimeDuration::FromMilliseconds(timeout); - mDormantTimer.Ensure(target, - [this]() { - mDormantTimer.CompleteRequest(); - SetState(); - }, - [this]() { mDormantTimer.CompleteRequest(); }); + mDormantTimer.Ensure( + target, + [this]() { + mDormantTimer.CompleteRequest(); + SetState(); + }, + [this]() { mDormantTimer.CompleteRequest(); }); } // Time at which we started decoding. @@ -818,38 +820,39 @@ class MediaDecoderStateMachine::LoopingDecodingState Reader()->ResetDecode(TrackInfo::kAudioTrack); Reader() ->Seek(SeekTarget(media::TimeUnit::Zero(), SeekTarget::Accurate)) - ->Then(OwnerThread(), __func__, - [this]() -> void { - mAudioSeekRequest.Complete(); - SLOG( - "seeking completed, start to request first sample, " - "queueing audio task - queued=%zu, decoder-queued=%zu", - AudioQueue().GetSize(), - Reader()->SizeOfAudioQueueInFrames()); - - Reader() - ->RequestAudioData() - ->Then(OwnerThread(), __func__, - [this](RefPtr aAudio) { - mIsReachingAudioEOS = false; - mAudioDataRequest.Complete(); - SLOG( - "got audio decoded sample " - "[%" PRId64 ",%" PRId64 "]", - aAudio->mTime.ToMicroseconds(), - aAudio->GetEndTime().ToMicroseconds()); - HandleAudioDecoded(aAudio); - }, - [this](const MediaResult& aError) { - mAudioDataRequest.Complete(); - HandleError(aError); - }) - ->Track(mAudioDataRequest); - }, - [this](const SeekRejectValue& aReject) -> void { - mAudioSeekRequest.Complete(); - HandleError(aReject.mError); - }) + ->Then( + OwnerThread(), __func__, + [this]() -> void { + mAudioSeekRequest.Complete(); + SLOG( + "seeking completed, start to request first sample, " + "queueing audio task - queued=%zu, decoder-queued=%zu", + AudioQueue().GetSize(), Reader()->SizeOfAudioQueueInFrames()); + + Reader() + ->RequestAudioData() + ->Then( + OwnerThread(), __func__, + [this](RefPtr aAudio) { + mIsReachingAudioEOS = false; + mAudioDataRequest.Complete(); + SLOG( + "got audio decoded sample " + "[%" PRId64 ",%" PRId64 "]", + aAudio->mTime.ToMicroseconds(), + aAudio->GetEndTime().ToMicroseconds()); + HandleAudioDecoded(aAudio); + }, + [this](const MediaResult& aError) { + mAudioDataRequest.Complete(); + HandleError(aError); + }) + ->Track(mAudioDataRequest); + }, + [this](const SeekRejectValue& aReject) -> void { + mAudioSeekRequest.Complete(); + HandleError(aReject.mError); + }) ->Track(mAudioSeekRequest); } @@ -1233,17 +1236,18 @@ class MediaDecoderStateMachine::AccurateSeekingState Reader() ->WaitForData(aReject.mType) - ->Then(OwnerThread(), __func__, - [this](MediaData::Type aType) { - SLOG("OnSeekRejected wait promise resolved"); - mWaitRequest.Complete(); - DemuxerSeek(); - }, - [this](const WaitForDataRejectValue& aRejection) { - SLOG("OnSeekRejected wait promise rejected"); - mWaitRequest.Complete(); - mMaster->DecodeError(NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA); - }) + ->Then( + OwnerThread(), __func__, + [this](MediaData::Type aType) { + SLOG("OnSeekRejected wait promise resolved"); + mWaitRequest.Complete(); + DemuxerSeek(); + }, + [this](const WaitForDataRejectValue& aRejection) { + SLOG("OnSeekRejected wait promise rejected"); + mWaitRequest.Complete(); + mMaster->DecodeError(NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA); + }) ->Track(mWaitRequest); return; } @@ -2131,9 +2135,10 @@ void MediaDecoderStateMachine::StateObject::HandleResumeVideoDecoding( RefPtr mainThread = mMaster->mAbstractMainThread; SetSeekingState(std::move(seekJob), EventVisibility::Suppressed) - ->Then(mainThread, __func__, - [start, info, hw]() { ReportRecoveryTelemetry(start, info, hw); }, - []() {}); + ->Then( + mainThread, __func__, + [start, info, hw]() { ReportRecoveryTelemetry(start, info, hw); }, + []() {}); } RefPtr @@ -2968,9 +2973,9 @@ void MediaDecoderStateMachine::SetVideoDecodeModeInternal( TimeStamp target = TimeStamp::Now() + SuspendBackgroundVideoDelay(); RefPtr self = this; - mVideoDecodeSuspendTimer.Ensure(target, - [=]() { self->OnSuspendTimerResolved(); }, - []() { MOZ_DIAGNOSTIC_ASSERT(false); }); + mVideoDecodeSuspendTimer.Ensure( + target, [=]() { self->OnSuspendTimerResolved(); }, + []() { MOZ_DIAGNOSTIC_ASSERT(false); }); mOnPlaybackEvent.Notify(MediaPlaybackEvent::StartVideoSuspendTimer); return; } @@ -3064,36 +3069,37 @@ void MediaDecoderStateMachine::RequestAudioData() { RefPtr self = this; mReader->RequestAudioData() - ->Then(OwnerThread(), __func__, - [this, self](RefPtr aAudio) { - MOZ_ASSERT(aAudio); - mAudioDataRequest.Complete(); - // audio->GetEndTime() is not always mono-increasing in chained - // ogg. - mDecodedAudioEndTime = - std::max(aAudio->GetEndTime(), mDecodedAudioEndTime); - LOGV("OnAudioDecoded [%" PRId64 ",%" PRId64 "]", - aAudio->mTime.ToMicroseconds(), - aAudio->GetEndTime().ToMicroseconds()); - mStateObj->HandleAudioDecoded(aAudio); - }, - [this, self](const MediaResult& aError) { - LOGV("OnAudioNotDecoded aError=%s", aError.ErrorName().get()); - mAudioDataRequest.Complete(); - switch (aError.Code()) { - case NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA: - mStateObj->HandleWaitingForAudio(); - break; - case NS_ERROR_DOM_MEDIA_CANCELED: - mStateObj->HandleAudioCanceled(); - break; - case NS_ERROR_DOM_MEDIA_END_OF_STREAM: - mStateObj->HandleEndOfAudio(); - break; - default: - DecodeError(aError); - } - }) + ->Then( + OwnerThread(), __func__, + [this, self](RefPtr aAudio) { + MOZ_ASSERT(aAudio); + mAudioDataRequest.Complete(); + // audio->GetEndTime() is not always mono-increasing in chained + // ogg. + mDecodedAudioEndTime = + std::max(aAudio->GetEndTime(), mDecodedAudioEndTime); + LOGV("OnAudioDecoded [%" PRId64 ",%" PRId64 "]", + aAudio->mTime.ToMicroseconds(), + aAudio->GetEndTime().ToMicroseconds()); + mStateObj->HandleAudioDecoded(aAudio); + }, + [this, self](const MediaResult& aError) { + LOGV("OnAudioNotDecoded aError=%s", aError.ErrorName().get()); + mAudioDataRequest.Complete(); + switch (aError.Code()) { + case NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA: + mStateObj->HandleWaitingForAudio(); + break; + case NS_ERROR_DOM_MEDIA_CANCELED: + mStateObj->HandleAudioCanceled(); + break; + case NS_ERROR_DOM_MEDIA_END_OF_STREAM: + mStateObj->HandleEndOfAudio(); + break; + default: + DecodeError(aError); + } + }) ->Track(mAudioDataRequest); } @@ -3112,35 +3118,36 @@ void MediaDecoderStateMachine::RequestVideoData( TimeStamp videoDecodeStartTime = TimeStamp::Now(); RefPtr self = this; mReader->RequestVideoData(aCurrentTime) - ->Then(OwnerThread(), __func__, - [this, self, videoDecodeStartTime](RefPtr aVideo) { - MOZ_ASSERT(aVideo); - mVideoDataRequest.Complete(); - // Handle abnormal or negative timestamps. - mDecodedVideoEndTime = - std::max(mDecodedVideoEndTime, aVideo->GetEndTime()); - LOGV("OnVideoDecoded [%" PRId64 ",%" PRId64 "]", - aVideo->mTime.ToMicroseconds(), - aVideo->GetEndTime().ToMicroseconds()); - mStateObj->HandleVideoDecoded(aVideo, videoDecodeStartTime); - }, - [this, self](const MediaResult& aError) { - LOGV("OnVideoNotDecoded aError=%s", aError.ErrorName().get()); - mVideoDataRequest.Complete(); - switch (aError.Code()) { - case NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA: - mStateObj->HandleWaitingForVideo(); - break; - case NS_ERROR_DOM_MEDIA_CANCELED: - mStateObj->HandleVideoCanceled(); - break; - case NS_ERROR_DOM_MEDIA_END_OF_STREAM: - mStateObj->HandleEndOfVideo(); - break; - default: - DecodeError(aError); - } - }) + ->Then( + OwnerThread(), __func__, + [this, self, videoDecodeStartTime](RefPtr aVideo) { + MOZ_ASSERT(aVideo); + mVideoDataRequest.Complete(); + // Handle abnormal or negative timestamps. + mDecodedVideoEndTime = + std::max(mDecodedVideoEndTime, aVideo->GetEndTime()); + LOGV("OnVideoDecoded [%" PRId64 ",%" PRId64 "]", + aVideo->mTime.ToMicroseconds(), + aVideo->GetEndTime().ToMicroseconds()); + mStateObj->HandleVideoDecoded(aVideo, videoDecodeStartTime); + }, + [this, self](const MediaResult& aError) { + LOGV("OnVideoNotDecoded aError=%s", aError.ErrorName().get()); + mVideoDataRequest.Complete(); + switch (aError.Code()) { + case NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA: + mStateObj->HandleWaitingForVideo(); + break; + case NS_ERROR_DOM_MEDIA_CANCELED: + mStateObj->HandleVideoCanceled(); + break; + case NS_ERROR_DOM_MEDIA_END_OF_STREAM: + mStateObj->HandleEndOfVideo(); + break; + default: + DecodeError(aError); + } + }) ->Track(mVideoDataRequest); } @@ -3151,29 +3158,31 @@ void MediaDecoderStateMachine::WaitForData(MediaData::Type aType) { RefPtr self = this; if (aType == MediaData::Type::AUDIO_DATA) { mReader->WaitForData(MediaData::Type::AUDIO_DATA) - ->Then(OwnerThread(), __func__, - [self](MediaData::Type aType) { - self->mAudioWaitRequest.Complete(); - MOZ_ASSERT(aType == MediaData::Type::AUDIO_DATA); - self->mStateObj->HandleAudioWaited(aType); - }, - [self](const WaitForDataRejectValue& aRejection) { - self->mAudioWaitRequest.Complete(); - self->DecodeError(NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA); - }) + ->Then( + OwnerThread(), __func__, + [self](MediaData::Type aType) { + self->mAudioWaitRequest.Complete(); + MOZ_ASSERT(aType == MediaData::Type::AUDIO_DATA); + self->mStateObj->HandleAudioWaited(aType); + }, + [self](const WaitForDataRejectValue& aRejection) { + self->mAudioWaitRequest.Complete(); + self->DecodeError(NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA); + }) ->Track(mAudioWaitRequest); } else { mReader->WaitForData(MediaData::Type::VIDEO_DATA) - ->Then(OwnerThread(), __func__, - [self](MediaData::Type aType) { - self->mVideoWaitRequest.Complete(); - MOZ_ASSERT(aType == MediaData::Type::VIDEO_DATA); - self->mStateObj->HandleVideoWaited(aType); - }, - [self](const WaitForDataRejectValue& aRejection) { - self->mVideoWaitRequest.Complete(); - self->DecodeError(NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA); - }) + ->Then( + OwnerThread(), __func__, + [self](MediaData::Type aType) { + self->mVideoWaitRequest.Complete(); + MOZ_ASSERT(aType == MediaData::Type::VIDEO_DATA); + self->mStateObj->HandleVideoWaited(aType); + }, + [self](const WaitForDataRejectValue& aRejection) { + self->mVideoWaitRequest.Complete(); + self->DecodeError(NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA); + }) ->Track(mVideoWaitRequest); } } @@ -3464,12 +3473,13 @@ void MediaDecoderStateMachine::ScheduleStateMachineIn(const TimeUnit& aTime) { // It is OK to capture 'this' without causing UAF because the callback // always happens before shutdown. RefPtr self = this; - mDelayedScheduler.Ensure(target, - [self]() { - self->mDelayedScheduler.CompleteRequest(); - self->RunStateMachine(); - }, - []() { MOZ_DIAGNOSTIC_ASSERT(false); }); + mDelayedScheduler.Ensure( + target, + [self]() { + self->mDelayedScheduler.CompleteRequest(); + self->RunStateMachine(); + }, + []() { MOZ_DIAGNOSTIC_ASSERT(false); }); } bool MediaDecoderStateMachine::OnTaskQueue() const { diff --git a/dom/media/MediaDevices.cpp b/dom/media/MediaDevices.cpp index 282fd8c3c33ec..4e29508b99a32 100644 --- a/dom/media/MediaDevices.cpp +++ b/dom/media/MediaDevices.cpp @@ -65,20 +65,21 @@ already_AddRefed MediaDevices::GetUserMedia( RefPtr self(this); MediaManager::Get() ->GetUserMedia(GetOwner(), aConstraints, aCallerType) - ->Then(GetCurrentThreadSerialEventTarget(), __func__, - [this, self, p](RefPtr&& aStream) { - if (!GetWindowIfCurrent()) { - return; // Leave Promise pending after navigation by design. - } - p->MaybeResolve(std::move(aStream)); - }, - [this, self, p](const RefPtr& error) { - nsPIDOMWindowInner* window = GetWindowIfCurrent(); - if (!window) { - return; // Leave Promise pending after navigation by design. - } - p->MaybeReject(MakeRefPtr(window, *error)); - }); + ->Then( + GetCurrentThreadSerialEventTarget(), __func__, + [this, self, p](RefPtr&& aStream) { + if (!GetWindowIfCurrent()) { + return; // Leave Promise pending after navigation by design. + } + p->MaybeResolve(std::move(aStream)); + }, + [this, self, p](const RefPtr& error) { + nsPIDOMWindowInner* window = GetWindowIfCurrent(); + if (!window) { + return; // Leave Promise pending after navigation by design. + } + p->MaybeReject(MakeRefPtr(window, *error)); + }); return p.forget(); } @@ -92,40 +93,41 @@ already_AddRefed MediaDevices::EnumerateDevices(CallerType aCallerType, RefPtr self(this); MediaManager::Get() ->EnumerateDevices(GetOwner(), aCallerType) - ->Then(GetCurrentThreadSerialEventTarget(), __func__, - [this, self, - p](RefPtr&& aDevices) { - nsPIDOMWindowInner* window = GetWindowIfCurrent(); - if (!window) { - return; // Leave Promise pending after navigation by design. - } - auto windowId = window->WindowID(); - nsTArray> infos; - for (auto& device : *aDevices) { - MOZ_ASSERT(device->mKind == dom::MediaDeviceKind::Audioinput || - device->mKind == dom::MediaDeviceKind::Videoinput || - device->mKind == dom::MediaDeviceKind::Audiooutput); - // Include name only if page currently has a gUM stream active - // or persistent permissions (audio or video) have been granted - nsString label; - if (MediaManager::Get()->IsActivelyCapturingOrHasAPermission( - windowId) || - Preferences::GetBool("media.navigator.permission.disabled", - false)) { - label = device->mName; - } - infos.AppendElement(MakeRefPtr( - device->mID, device->mKind, label, device->mGroupID)); - } - p->MaybeResolve(std::move(infos)); - }, - [this, self, p](const RefPtr& error) { - nsPIDOMWindowInner* window = GetWindowIfCurrent(); - if (!window) { - return; // Leave Promise pending after navigation by design. - } - p->MaybeReject(MakeRefPtr(window, *error)); - }); + ->Then( + GetCurrentThreadSerialEventTarget(), __func__, + [this, self, + p](RefPtr&& aDevices) { + nsPIDOMWindowInner* window = GetWindowIfCurrent(); + if (!window) { + return; // Leave Promise pending after navigation by design. + } + auto windowId = window->WindowID(); + nsTArray> infos; + for (auto& device : *aDevices) { + MOZ_ASSERT(device->mKind == dom::MediaDeviceKind::Audioinput || + device->mKind == dom::MediaDeviceKind::Videoinput || + device->mKind == dom::MediaDeviceKind::Audiooutput); + // Include name only if page currently has a gUM stream active + // or persistent permissions (audio or video) have been granted + nsString label; + if (MediaManager::Get()->IsActivelyCapturingOrHasAPermission( + windowId) || + Preferences::GetBool("media.navigator.permission.disabled", + false)) { + label = device->mName; + } + infos.AppendElement(MakeRefPtr( + device->mID, device->mKind, label, device->mGroupID)); + } + p->MaybeResolve(std::move(infos)); + }, + [this, self, p](const RefPtr& error) { + nsPIDOMWindowInner* window = GetWindowIfCurrent(); + if (!window) { + return; // Leave Promise pending after navigation by design. + } + p->MaybeReject(MakeRefPtr(window, *error)); + }); return p.forget(); } @@ -139,20 +141,21 @@ already_AddRefed MediaDevices::GetDisplayMedia( RefPtr self(this); MediaManager::Get() ->GetDisplayMedia(GetOwner(), aConstraints, aCallerType) - ->Then(GetCurrentThreadSerialEventTarget(), __func__, - [this, self, p](RefPtr&& aStream) { - if (!GetWindowIfCurrent()) { - return; // leave promise pending after navigation. - } - p->MaybeResolve(std::move(aStream)); - }, - [this, self, p](RefPtr&& error) { - nsPIDOMWindowInner* window = GetWindowIfCurrent(); - if (!window) { - return; // leave promise pending after navigation. - } - p->MaybeReject(MakeRefPtr(window, *error)); - }); + ->Then( + GetCurrentThreadSerialEventTarget(), __func__, + [this, self, p](RefPtr&& aStream) { + if (!GetWindowIfCurrent()) { + return; // leave promise pending after navigation. + } + p->MaybeResolve(std::move(aStream)); + }, + [this, self, p](RefPtr&& error) { + nsPIDOMWindowInner* window = GetWindowIfCurrent(); + if (!window) { + return; // leave promise pending after navigation. + } + p->MaybeReject(MakeRefPtr(window, *error)); + }); return p.forget(); } diff --git a/dom/media/MediaFormatReader.cpp b/dom/media/MediaFormatReader.cpp index 65d57c73b0199..e9687caadfb03 100644 --- a/dom/media/MediaFormatReader.cpp +++ b/dom/media/MediaFormatReader.cpp @@ -336,17 +336,18 @@ void MediaFormatReader::DecoderFactory::RunStage(Data& aData) { case Stage::None: { MOZ_ASSERT(!aData.mToken); aData.mPolicy->Alloc() - ->Then(mOwner->OwnerThread(), __func__, - [this, &aData](RefPtr aToken) { - aData.mTokenRequest.Complete(); - aData.mToken = aToken.forget(); - aData.mStage = Stage::CreateDecoder; - RunStage(aData); - }, - [&aData]() { - aData.mTokenRequest.Complete(); - aData.mStage = Stage::None; - }) + ->Then( + mOwner->OwnerThread(), __func__, + [this, &aData](RefPtr aToken) { + aData.mTokenRequest.Complete(); + aData.mToken = aToken.forget(); + aData.mStage = Stage::CreateDecoder; + RunStage(aData); + }, + [&aData]() { + aData.mTokenRequest.Complete(); + aData.mStage = Stage::None; + }) ->Track(aData.mTokenRequest); aData.mStage = Stage::WaitForToken; break; @@ -475,33 +476,33 @@ void MediaFormatReader::DecoderFactory::DoInitDecoder(Data& aData) { DDLOGEX2("MediaFormatReader::DecoderFactory", this, DDLogCategory::Log, "initialize_decoder", DDNoValue{}); aData.mDecoder->Init() - ->Then(mOwner->OwnerThread(), __func__, - [this, &aData, &ownerData](TrackType aTrack) { - aData.mInitRequest.Complete(); - aData.mStage = Stage::None; - MutexAutoLock lock(ownerData.mMutex); - ownerData.mDecoder = aData.mDecoder.forget(); - ownerData.mDescription = - ownerData.mDecoder->GetDescriptionName(); - DDLOGEX2("MediaFormatReader::DecoderFactory", this, - DDLogCategory::Log, "decoder_initialized", DDNoValue{}); - DecoderDoctorLogger::LinkParentAndChild( - "MediaFormatReader::DecoderData", &ownerData, "decoder", - ownerData.mDecoder.get()); - mOwner->SetVideoDecodeThreshold(); - mOwner->ScheduleUpdate(aTrack); - }, - [this, &aData, &ownerData](const MediaResult& aError) { - aData.mInitRequest.Complete(); - MOZ_RELEASE_ASSERT(!ownerData.mDecoder, - "Can't have a decoder already set"); - aData.mStage = Stage::None; - mOwner->mShutdownPromisePool->ShutdownDecoder( - aData.mDecoder.forget()); - DDLOGEX2("MediaFormatReader::DecoderFactory", this, - DDLogCategory::Log, "initialize_decoder_error", aError); - mOwner->NotifyError(aData.mTrack, aError); - }) + ->Then( + mOwner->OwnerThread(), __func__, + [this, &aData, &ownerData](TrackType aTrack) { + aData.mInitRequest.Complete(); + aData.mStage = Stage::None; + MutexAutoLock lock(ownerData.mMutex); + ownerData.mDecoder = aData.mDecoder.forget(); + ownerData.mDescription = ownerData.mDecoder->GetDescriptionName(); + DDLOGEX2("MediaFormatReader::DecoderFactory", this, + DDLogCategory::Log, "decoder_initialized", DDNoValue{}); + DecoderDoctorLogger::LinkParentAndChild( + "MediaFormatReader::DecoderData", &ownerData, "decoder", + ownerData.mDecoder.get()); + mOwner->SetVideoDecodeThreshold(); + mOwner->ScheduleUpdate(aTrack); + }, + [this, &aData, &ownerData](const MediaResult& aError) { + aData.mInitRequest.Complete(); + MOZ_RELEASE_ASSERT(!ownerData.mDecoder, + "Can't have a decoder already set"); + aData.mStage = Stage::None; + mOwner->mShutdownPromisePool->ShutdownDecoder( + aData.mDecoder.forget()); + DDLOGEX2("MediaFormatReader::DecoderFactory", this, + DDLogCategory::Log, "initialize_decoder_error", aError); + mOwner->NotifyError(aData.mTrack, aError); + }) ->Track(aData.mInitRequest); } @@ -653,15 +654,16 @@ class MediaFormatReader::DemuxerProxy::Wrapper : public MediaTrackDemuxer { return InvokeAsync( mTaskQueue, __func__, [self, aTime]() { return self->mTrackDemuxer->Seek(aTime); }) - ->Then(mTaskQueue, __func__, - [self](const TimeUnit& aTime) { - self->UpdateRandomAccessPoint(); - return SeekPromise::CreateAndResolve(aTime, __func__); - }, - [self](const MediaResult& aError) { - self->UpdateRandomAccessPoint(); - return SeekPromise::CreateAndReject(aError, __func__); - }); + ->Then( + mTaskQueue, __func__, + [self](const TimeUnit& aTime) { + self->UpdateRandomAccessPoint(); + return SeekPromise::CreateAndResolve(aTime, __func__); + }, + [self](const MediaResult& aError) { + self->UpdateRandomAccessPoint(); + return SeekPromise::CreateAndReject(aError, __func__); + }); } RefPtr GetSamples(int32_t aNumSamples) override { @@ -670,16 +672,17 @@ class MediaFormatReader::DemuxerProxy::Wrapper : public MediaTrackDemuxer { [self, aNumSamples]() { return self->mTrackDemuxer->GetSamples(aNumSamples); }) - ->Then(mTaskQueue, __func__, - [self](RefPtr aSamples) { - self->UpdateRandomAccessPoint(); - return SamplesPromise::CreateAndResolve(aSamples.forget(), - __func__); - }, - [self](const MediaResult& aError) { - self->UpdateRandomAccessPoint(); - return SamplesPromise::CreateAndReject(aError, __func__); - }); + ->Then( + mTaskQueue, __func__, + [self](RefPtr aSamples) { + self->UpdateRandomAccessPoint(); + return SamplesPromise::CreateAndResolve(aSamples.forget(), + __func__); + }, + [self](const MediaResult& aError) { + self->UpdateRandomAccessPoint(); + return SamplesPromise::CreateAndReject(aError, __func__); + }); } bool GetSamplesMayBlock() const override { return mGetSamplesMayBlock; } @@ -788,56 +791,57 @@ RefPtr MediaFormatReader::DemuxerProxy::Init() { } return data->mDemuxer->Init(); }) - ->Then(taskQueue, __func__, - [data, taskQueue]() { - if (!data->mDemuxer) { // Was shutdown. - return InitPromise::CreateAndReject( - NS_ERROR_DOM_MEDIA_CANCELED, __func__); - } - data->mNumAudioTrack = - data->mDemuxer->GetNumberTracks(TrackInfo::kAudioTrack); - if (data->mNumAudioTrack) { - RefPtr d = - data->mDemuxer->GetTrackDemuxer(TrackInfo::kAudioTrack, 0); - if (d) { - RefPtr wrapper = - new DemuxerProxy::Wrapper(d, taskQueue); - wrapper->UpdateBuffered(); - data->mAudioDemuxer = wrapper; - DecoderDoctorLogger::LinkParentAndChild( - data->mDemuxer.get(), "decoder factory wrapper", - "MediaFormatReader::DecoderFactory::Wrapper", - wrapper.get()); - } - } - data->mNumVideoTrack = - data->mDemuxer->GetNumberTracks(TrackInfo::kVideoTrack); - if (data->mNumVideoTrack) { - RefPtr d = - data->mDemuxer->GetTrackDemuxer(TrackInfo::kVideoTrack, 0); - if (d) { - RefPtr wrapper = - new DemuxerProxy::Wrapper(d, taskQueue); - wrapper->UpdateBuffered(); - data->mVideoDemuxer = wrapper; - DecoderDoctorLogger::LinkParentAndChild( - data->mDemuxer.get(), "decoder factory wrapper", - "MediaFormatReader::DecoderFactory::Wrapper", - wrapper.get()); - } - } - data->mCrypto = data->mDemuxer->GetCrypto(); - data->mSeekable = data->mDemuxer->IsSeekable(); - data->mSeekableOnlyInBufferedRange = - data->mDemuxer->IsSeekableOnlyInBufferedRanges(); - data->mShouldComputeStartTime = - data->mDemuxer->ShouldComputeStartTime(); - data->mInitDone = true; - return InitPromise::CreateAndResolve(NS_OK, __func__); - }, - [](const MediaResult& aError) { - return InitPromise::CreateAndReject(aError, __func__); - }); + ->Then( + taskQueue, __func__, + [data, taskQueue]() { + if (!data->mDemuxer) { // Was shutdown. + return InitPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_CANCELED, + __func__); + } + data->mNumAudioTrack = + data->mDemuxer->GetNumberTracks(TrackInfo::kAudioTrack); + if (data->mNumAudioTrack) { + RefPtr d = + data->mDemuxer->GetTrackDemuxer(TrackInfo::kAudioTrack, 0); + if (d) { + RefPtr wrapper = + new DemuxerProxy::Wrapper(d, taskQueue); + wrapper->UpdateBuffered(); + data->mAudioDemuxer = wrapper; + DecoderDoctorLogger::LinkParentAndChild( + data->mDemuxer.get(), "decoder factory wrapper", + "MediaFormatReader::DecoderFactory::Wrapper", + wrapper.get()); + } + } + data->mNumVideoTrack = + data->mDemuxer->GetNumberTracks(TrackInfo::kVideoTrack); + if (data->mNumVideoTrack) { + RefPtr d = + data->mDemuxer->GetTrackDemuxer(TrackInfo::kVideoTrack, 0); + if (d) { + RefPtr wrapper = + new DemuxerProxy::Wrapper(d, taskQueue); + wrapper->UpdateBuffered(); + data->mVideoDemuxer = wrapper; + DecoderDoctorLogger::LinkParentAndChild( + data->mDemuxer.get(), "decoder factory wrapper", + "MediaFormatReader::DecoderFactory::Wrapper", + wrapper.get()); + } + } + data->mCrypto = data->mDemuxer->GetCrypto(); + data->mSeekable = data->mDemuxer->IsSeekable(); + data->mSeekableOnlyInBufferedRange = + data->mDemuxer->IsSeekableOnlyInBufferedRanges(); + data->mShouldComputeStartTime = + data->mDemuxer->ShouldComputeStartTime(); + data->mInitDone = true; + return InitPromise::CreateAndResolve(NS_OK, __func__); + }, + [](const MediaResult& aError) { + return InitPromise::CreateAndReject(aError, __func__); + }); } RefPtr @@ -1444,20 +1448,20 @@ void MediaFormatReader::DoDemuxVideo() { if (mVideo.mFirstDemuxedSampleTime.isNothing()) { RefPtr self = this; - p = p->Then(OwnerThread(), __func__, - [self](RefPtr aSamples) { - DDLOGEX(self.get(), DDLogCategory::Log, "video_first_demuxed", - DDNoValue{}); - self->OnFirstDemuxCompleted(TrackInfo::kVideoTrack, aSamples); - return SamplesPromise::CreateAndResolve(aSamples.forget(), - __func__); - }, - [self](const MediaResult& aError) { - DDLOGEX(self.get(), DDLogCategory::Log, - "video_first_demuxing_error", aError); - self->OnFirstDemuxFailed(TrackInfo::kVideoTrack, aError); - return SamplesPromise::CreateAndReject(aError, __func__); - }); + p = p->Then( + OwnerThread(), __func__, + [self](RefPtr aSamples) { + DDLOGEX(self.get(), DDLogCategory::Log, "video_first_demuxed", + DDNoValue{}); + self->OnFirstDemuxCompleted(TrackInfo::kVideoTrack, aSamples); + return SamplesPromise::CreateAndResolve(aSamples.forget(), __func__); + }, + [self](const MediaResult& aError) { + DDLOGEX(self.get(), DDLogCategory::Log, "video_first_demuxing_error", + aError); + self->OnFirstDemuxFailed(TrackInfo::kVideoTrack, aError); + return SamplesPromise::CreateAndReject(aError, __func__); + }); } p->Then(OwnerThread(), __func__, this, @@ -1522,20 +1526,20 @@ void MediaFormatReader::DoDemuxAudio() { if (mAudio.mFirstDemuxedSampleTime.isNothing()) { RefPtr self = this; - p = p->Then(OwnerThread(), __func__, - [self](RefPtr aSamples) { - DDLOGEX(self.get(), DDLogCategory::Log, "audio_first_demuxed", - DDNoValue{}); - self->OnFirstDemuxCompleted(TrackInfo::kAudioTrack, aSamples); - return SamplesPromise::CreateAndResolve(aSamples.forget(), - __func__); - }, - [self](const MediaResult& aError) { - DDLOGEX(self.get(), DDLogCategory::Log, - "audio_first_demuxing_error", aError); - self->OnFirstDemuxFailed(TrackInfo::kAudioTrack, aError); - return SamplesPromise::CreateAndReject(aError, __func__); - }); + p = p->Then( + OwnerThread(), __func__, + [self](RefPtr aSamples) { + DDLOGEX(self.get(), DDLogCategory::Log, "audio_first_demuxed", + DDNoValue{}); + self->OnFirstDemuxCompleted(TrackInfo::kAudioTrack, aSamples); + return SamplesPromise::CreateAndResolve(aSamples.forget(), __func__); + }, + [self](const MediaResult& aError) { + DDLOGEX(self.get(), DDLogCategory::Log, "audio_first_demuxing_error", + aError); + self->OnFirstDemuxFailed(TrackInfo::kAudioTrack, aError); + return SamplesPromise::CreateAndReject(aError, __func__); + }); } p->Then(OwnerThread(), __func__, this, @@ -1993,46 +1997,47 @@ void MediaFormatReader::InternalSeek(TrackType aTrack, DDLOG(DDLogCategory::Log, "seeking", DDNoValue{}); RefPtr self = this; decoder.mTrackDemuxer->Seek(decoder.mTimeThreshold.ref().Time()) - ->Then(OwnerThread(), __func__, - [self, aTrack](TimeUnit aTime) { - DDLOGEX(self.get(), DDLogCategory::Log, "seeked", DDNoValue{}); - auto& decoder = self->GetDecoderData(aTrack); - decoder.mSeekRequest.Complete(); - MOZ_ASSERT(decoder.mTimeThreshold, - "Seek promise must be disconnected when " - "timethreshold is reset"); - decoder.mTimeThreshold.ref().mHasSeeked = true; - self->SetVideoDecodeThreshold(); - self->ScheduleUpdate(aTrack); - }, - [self, aTrack](const MediaResult& aError) { - auto& decoder = self->GetDecoderData(aTrack); - decoder.mSeekRequest.Complete(); - switch (aError.Code()) { - case NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA: - DDLOGEX(self.get(), DDLogCategory::Log, - "seeking_interrupted", aError); - self->NotifyWaitingForData(aTrack); - break; - case NS_ERROR_DOM_MEDIA_END_OF_STREAM: - DDLOGEX(self.get(), DDLogCategory::Log, - "seeking_interrupted", aError); - decoder.mTimeThreshold.reset(); - self->NotifyEndOfStream(aTrack); - break; - case NS_ERROR_DOM_MEDIA_CANCELED: - DDLOGEX(self.get(), DDLogCategory::Log, - "seeking_interrupted", aError); - decoder.mTimeThreshold.reset(); - break; - default: - DDLOGEX(self.get(), DDLogCategory::Log, "seeking_error", - aError); - decoder.mTimeThreshold.reset(); - self->NotifyError(aTrack, aError); - break; - } - }) + ->Then( + OwnerThread(), __func__, + [self, aTrack](TimeUnit aTime) { + DDLOGEX(self.get(), DDLogCategory::Log, "seeked", DDNoValue{}); + auto& decoder = self->GetDecoderData(aTrack); + decoder.mSeekRequest.Complete(); + MOZ_ASSERT(decoder.mTimeThreshold, + "Seek promise must be disconnected when " + "timethreshold is reset"); + decoder.mTimeThreshold.ref().mHasSeeked = true; + self->SetVideoDecodeThreshold(); + self->ScheduleUpdate(aTrack); + }, + [self, aTrack](const MediaResult& aError) { + auto& decoder = self->GetDecoderData(aTrack); + decoder.mSeekRequest.Complete(); + switch (aError.Code()) { + case NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA: + DDLOGEX(self.get(), DDLogCategory::Log, "seeking_interrupted", + aError); + self->NotifyWaitingForData(aTrack); + break; + case NS_ERROR_DOM_MEDIA_END_OF_STREAM: + DDLOGEX(self.get(), DDLogCategory::Log, "seeking_interrupted", + aError); + decoder.mTimeThreshold.reset(); + self->NotifyEndOfStream(aTrack); + break; + case NS_ERROR_DOM_MEDIA_CANCELED: + DDLOGEX(self.get(), DDLogCategory::Log, "seeking_interrupted", + aError); + decoder.mTimeThreshold.reset(); + break; + default: + DDLOGEX(self.get(), DDLogCategory::Log, "seeking_error", + aError); + decoder.mTimeThreshold.reset(); + self->NotifyError(aTrack, aError); + break; + } + }) ->Track(decoder.mSeekRequest); } @@ -2869,17 +2874,18 @@ void MediaFormatReader::NotifyDataArrived() { RefPtr self = this; mDemuxer->NotifyDataArrived() - ->Then(OwnerThread(), __func__, - [self]() { - self->mNotifyDataArrivedPromise.Complete(); - self->UpdateBuffered(); - self->NotifyTrackDemuxers(); - if (self->mPendingNotifyDataArrived) { - self->mPendingNotifyDataArrived = false; - self->NotifyDataArrived(); - } - }, - [self]() { self->mNotifyDataArrivedPromise.Complete(); }) + ->Then( + OwnerThread(), __func__, + [self]() { + self->mNotifyDataArrivedPromise.Complete(); + self->UpdateBuffered(); + self->NotifyTrackDemuxers(); + if (self->mPendingNotifyDataArrived) { + self->mPendingNotifyDataArrived = false; + self->NotifyDataArrived(); + } + }, + [self]() { self->mNotifyDataArrivedPromise.Complete(); }) ->Track(mNotifyDataArrivedPromise); } diff --git a/dom/media/MediaManager.cpp b/dom/media/MediaManager.cpp index 7791cdb505127..2936185af69e3 100644 --- a/dom/media/MediaManager.cpp +++ b/dom/media/MediaManager.cpp @@ -3139,46 +3139,46 @@ RefPtr MediaManager::EnumerateDevicesImpl( MakeRefPtr(MediaMgrError::Name::AbortError), __func__); }) - ->Then(GetMainThreadSerialEventTarget(), __func__, - [aWindowId, originKey, aVideoInputEnumType, aAudioInputEnumType, - aVideoInputType, aAudioInputType, aOutDevices](bool) { - // Only run if window is still on our active list. - MediaManager* mgr = MediaManager::GetIfExists(); - if (!mgr || !mgr->IsWindowStillActive(aWindowId)) { - return MgrPromise::CreateAndReject( - MakeRefPtr(MediaMgrError::Name::AbortError), - __func__); - } + ->Then( + GetMainThreadSerialEventTarget(), __func__, + [aWindowId, originKey, aVideoInputEnumType, aAudioInputEnumType, + aVideoInputType, aAudioInputType, aOutDevices](bool) { + // Only run if window is still on our active list. + MediaManager* mgr = MediaManager::GetIfExists(); + if (!mgr || !mgr->IsWindowStillActive(aWindowId)) { + return MgrPromise::CreateAndReject( + MakeRefPtr(MediaMgrError::Name::AbortError), + __func__); + } - // If we fetched any real cameras or mics, remove the - // "default" part of their IDs. - if (aVideoInputType == MediaSourceEnum::Camera && - aAudioInputType == MediaSourceEnum::Microphone && - (aVideoInputEnumType != DeviceEnumerationType::Fake || - aAudioInputEnumType != DeviceEnumerationType::Fake)) { - mgr->mDeviceIDs.Clear(); - for (auto& device : *aOutDevices) { - nsString id; - device->GetId(id); - id.ReplaceSubstring(NS_LITERAL_STRING("default: "), - NS_LITERAL_STRING("")); - if (!mgr->mDeviceIDs.Contains(id)) { - mgr->mDeviceIDs.AppendElement(id); - } - } - } - if (!mgr->IsWindowStillActive(aWindowId)) { - return MgrPromise::CreateAndReject( - MakeRefPtr(MediaMgrError::Name::AbortError), - __func__); - } - MediaManager::AnonymizeDevices(*aOutDevices, *originKey, - aWindowId); - return MgrPromise::CreateAndResolve(false, __func__); - }, - [](RefPtr&& aError) { - return MgrPromise::CreateAndReject(std::move(aError), __func__); - }); + // If we fetched any real cameras or mics, remove the + // "default" part of their IDs. + if (aVideoInputType == MediaSourceEnum::Camera && + aAudioInputType == MediaSourceEnum::Microphone && + (aVideoInputEnumType != DeviceEnumerationType::Fake || + aAudioInputEnumType != DeviceEnumerationType::Fake)) { + mgr->mDeviceIDs.Clear(); + for (auto& device : *aOutDevices) { + nsString id; + device->GetId(id); + id.ReplaceSubstring(NS_LITERAL_STRING("default: "), + NS_LITERAL_STRING("")); + if (!mgr->mDeviceIDs.Contains(id)) { + mgr->mDeviceIDs.AppendElement(id); + } + } + } + if (!mgr->IsWindowStillActive(aWindowId)) { + return MgrPromise::CreateAndReject( + MakeRefPtr(MediaMgrError::Name::AbortError), + __func__); + } + MediaManager::AnonymizeDevices(*aOutDevices, *originKey, aWindowId); + return MgrPromise::CreateAndResolve(false, __func__); + }, + [](RefPtr&& aError) { + return MgrPromise::CreateAndReject(std::move(aError), __func__); + }); } RefPtr MediaManager::EnumerateDevices( @@ -3250,21 +3250,21 @@ RefPtr MediaManager::EnumerateDevices( MediaSourceEnum::Microphone, audioOutputType, videoEnumerationType, audioEnumerationType, false, devices) - ->Then(GetCurrentThreadSerialEventTarget(), __func__, - [windowListener, sourceListener, devices](bool) { - DebugOnly rv = windowListener->Remove(sourceListener); - MOZ_ASSERT(rv); - return DevicesPromise::CreateAndResolve(devices, __func__); - }, - [windowListener, sourceListener](RefPtr&& aError) { - // This may fail, if a new doc has been set the OnNavigation - // method should have removed all previous active listeners. - // Attempt to clean it here, just in case, but ignore the return - // value. - Unused << windowListener->Remove(sourceListener); - return DevicesPromise::CreateAndReject(std::move(aError), - __func__); - }); + ->Then( + GetCurrentThreadSerialEventTarget(), __func__, + [windowListener, sourceListener, devices](bool) { + DebugOnly rv = windowListener->Remove(sourceListener); + MOZ_ASSERT(rv); + return DevicesPromise::CreateAndResolve(devices, __func__); + }, + [windowListener, sourceListener](RefPtr&& aError) { + // This may fail, if a new doc has been set the OnNavigation + // method should have removed all previous active listeners. + // Attempt to clean it here, just in case, but ignore the return + // value. + Unused << windowListener->Remove(sourceListener); + return DevicesPromise::CreateAndReject(std::move(aError), __func__); + }); } RefPtr MediaManager::GetSinkDevice(nsPIDOMWindowInner* aWindow, @@ -3298,31 +3298,32 @@ RefPtr MediaManager::GetSinkDevice(nsPIDOMWindowInner* aWindow, MediaSourceEnum::Other, MediaSinkEnum::Speaker, DeviceEnumerationType::Normal, DeviceEnumerationType::Normal, true, devices) - ->Then(GetCurrentThreadSerialEventTarget(), __func__, - [aDeviceId, isSecure, devices](bool) { - for (RefPtr& device : *devices) { - if (aDeviceId.IsEmpty() && device->mSinkInfo->Preferred()) { - return SinkInfoPromise::CreateAndResolve(device->mSinkInfo, - __func__); - } - if (device->mID.Equals(aDeviceId)) { - // TODO: Check if the application is authorized to play audio - // through this device (Bug 1493982). - if (isSecure || device->mSinkInfo->Preferred()) { - return SinkInfoPromise::CreateAndResolve(device->mSinkInfo, - __func__); - } - return SinkInfoPromise::CreateAndReject( - NS_ERROR_DOM_MEDIA_NOT_ALLOWED_ERR, __func__); - } - } - return SinkInfoPromise::CreateAndReject(NS_ERROR_NOT_AVAILABLE, - __func__); - }, - [](RefPtr&& aError) { - return SinkInfoPromise::CreateAndReject(NS_ERROR_NOT_AVAILABLE, - __func__); - }); + ->Then( + GetCurrentThreadSerialEventTarget(), __func__, + [aDeviceId, isSecure, devices](bool) { + for (RefPtr& device : *devices) { + if (aDeviceId.IsEmpty() && device->mSinkInfo->Preferred()) { + return SinkInfoPromise::CreateAndResolve(device->mSinkInfo, + __func__); + } + if (device->mID.Equals(aDeviceId)) { + // TODO: Check if the application is authorized to play audio + // through this device (Bug 1493982). + if (isSecure || device->mSinkInfo->Preferred()) { + return SinkInfoPromise::CreateAndResolve(device->mSinkInfo, + __func__); + } + return SinkInfoPromise::CreateAndReject( + NS_ERROR_DOM_MEDIA_NOT_ALLOWED_ERR, __func__); + } + } + return SinkInfoPromise::CreateAndReject(NS_ERROR_NOT_AVAILABLE, + __func__); + }, + [](RefPtr&& aError) { + return SinkInfoPromise::CreateAndReject(NS_ERROR_NOT_AVAILABLE, + __func__); + }); } /* @@ -4174,49 +4175,50 @@ SourceListener::InitializeAsync() { LOG("started all sources"); aHolder.Resolve(true, __func__); }) - ->Then(GetMainThreadSerialEventTarget(), __func__, - [self = RefPtr(this), this]() { - if (mStopped) { - // We were shut down during the async init - return SourceListenerPromise::CreateAndResolve(true, __func__); - } + ->Then( + GetMainThreadSerialEventTarget(), __func__, + [self = RefPtr(this), this]() { + if (mStopped) { + // We were shut down during the async init + return SourceListenerPromise::CreateAndResolve(true, __func__); + } - for (DeviceState* state : - {mAudioDeviceState.get(), mVideoDeviceState.get()}) { - if (!state) { - continue; - } - MOZ_DIAGNOSTIC_ASSERT(!state->mTrackEnabled); - MOZ_DIAGNOSTIC_ASSERT(!state->mDeviceEnabled); - MOZ_DIAGNOSTIC_ASSERT(!state->mStopped); + for (DeviceState* state : + {mAudioDeviceState.get(), mVideoDeviceState.get()}) { + if (!state) { + continue; + } + MOZ_DIAGNOSTIC_ASSERT(!state->mTrackEnabled); + MOZ_DIAGNOSTIC_ASSERT(!state->mDeviceEnabled); + MOZ_DIAGNOSTIC_ASSERT(!state->mStopped); - state->mDeviceEnabled = true; - state->mTrackEnabled = true; - state->mTrackEnabledTime = TimeStamp::Now(); - } - return SourceListenerPromise::CreateAndResolve(true, __func__); - }, - [self = RefPtr(this), - this](RefPtr&& aResult) { - if (mStopped) { - return SourceListenerPromise::CreateAndReject( - std::move(aResult), __func__); - } + state->mDeviceEnabled = true; + state->mTrackEnabled = true; + state->mTrackEnabledTime = TimeStamp::Now(); + } + return SourceListenerPromise::CreateAndResolve(true, __func__); + }, + [self = RefPtr(this), + this](RefPtr&& aResult) { + if (mStopped) { + return SourceListenerPromise::CreateAndReject(std::move(aResult), + __func__); + } - for (DeviceState* state : - {mAudioDeviceState.get(), mVideoDeviceState.get()}) { - if (!state) { - continue; - } - MOZ_DIAGNOSTIC_ASSERT(!state->mTrackEnabled); - MOZ_DIAGNOSTIC_ASSERT(!state->mDeviceEnabled); - MOZ_DIAGNOSTIC_ASSERT(!state->mStopped); + for (DeviceState* state : + {mAudioDeviceState.get(), mVideoDeviceState.get()}) { + if (!state) { + continue; + } + MOZ_DIAGNOSTIC_ASSERT(!state->mTrackEnabled); + MOZ_DIAGNOSTIC_ASSERT(!state->mDeviceEnabled); + MOZ_DIAGNOSTIC_ASSERT(!state->mStopped); - state->mStopped = true; - } - return SourceListenerPromise::CreateAndReject(std::move(aResult), - __func__); - }); + state->mStopped = true; + } + return SourceListenerPromise::CreateAndReject(std::move(aResult), + __func__); + }); } void SourceListener::Stop() { diff --git a/dom/media/MediaRecorder.cpp b/dom/media/MediaRecorder.cpp index 7afd4a2f4aa36..a278d392069dc 100644 --- a/dom/media/MediaRecorder.cpp +++ b/dom/media/MediaRecorder.cpp @@ -884,13 +884,14 @@ class MediaRecorder::Session : public PrincipalChangeObserver, } gSessions.Clear(); ShutdownPromise::All(GetCurrentThreadSerialEventTarget(), promises) - ->Then(GetCurrentThreadSerialEventTarget(), __func__, - [ticket]() mutable { - MOZ_ASSERT(gSessions.Count() == 0); - // Unblock shutdown - ticket = nullptr; - }, - []() { MOZ_CRASH("Not reached"); }); + ->Then( + GetCurrentThreadSerialEventTarget(), __func__, + [ticket]() mutable { + MOZ_ASSERT(gSessions.Count() == 0); + // Unblock shutdown + ticket = nullptr; + }, + []() { MOZ_CRASH("Not reached"); }); return NS_OK; } }; @@ -1714,15 +1715,16 @@ RefPtr MediaRecorder::SizeOfExcludingThis( } SizeOfPromise::All(GetCurrentThreadSerialEventTarget(), promises) - ->Then(GetCurrentThreadSerialEventTarget(), __func__, - [holder](const nsTArray& sizes) { - size_t total = 0; - for (const size_t& size : sizes) { - total += size; - } - holder->Resolve(total, __func__); - }, - []() { MOZ_CRASH("Unexpected reject"); }); + ->Then( + GetCurrentThreadSerialEventTarget(), __func__, + [holder](const nsTArray& sizes) { + size_t total = 0; + for (const size_t& size : sizes) { + total += size; + } + holder->Resolve(total, __func__); + }, + []() { MOZ_CRASH("Unexpected reject"); }); return promise; } diff --git a/dom/media/ReaderProxy.cpp b/dom/media/ReaderProxy.cpp index 72e86c935f2f6..cd4f17e1e192c 100644 --- a/dom/media/ReaderProxy.cpp +++ b/dom/media/ReaderProxy.cpp @@ -80,18 +80,19 @@ RefPtr ReaderProxy::RequestVideoData( int64_t startTime = StartTime().ToMicroseconds(); return InvokeAsync(mReader->OwnerThread(), mReader.get(), __func__, &MediaFormatReader::RequestVideoData, threshold) - ->Then(mOwnerThread, __func__, - [startTime](RefPtr aVideo) { - aVideo->AdjustForStartTime(startTime); - return aVideo->mTime.IsValid() - ? VideoDataPromise::CreateAndResolve(aVideo.forget(), - __func__) - : VideoDataPromise::CreateAndReject( - NS_ERROR_DOM_MEDIA_OVERFLOW_ERR, __func__); - }, - [](const MediaResult& aError) { - return VideoDataPromise::CreateAndReject(aError, __func__); - }); + ->Then( + mOwnerThread, __func__, + [startTime](RefPtr aVideo) { + aVideo->AdjustForStartTime(startTime); + return aVideo->mTime.IsValid() + ? VideoDataPromise::CreateAndResolve(aVideo.forget(), + __func__) + : VideoDataPromise::CreateAndReject( + NS_ERROR_DOM_MEDIA_OVERFLOW_ERR, __func__); + }, + [](const MediaResult& aError) { + return VideoDataPromise::CreateAndReject(aError, __func__); + }); } RefPtr ReaderProxy::Seek(const SeekTarget& aTarget) { diff --git a/dom/media/VideoFrameConverter.h b/dom/media/VideoFrameConverter.h index 1275b88e1d9d1..2e0a92ab62d06 100644 --- a/dom/media/VideoFrameConverter.h +++ b/dom/media/VideoFrameConverter.h @@ -93,13 +93,14 @@ class VideoFrameConverter { mLastFrameQueuedForPacing = t; mPacingTimer->WaitUntil(t, __func__) - ->Then(mTaskQueue, __func__, - [self = RefPtr(this), this, - image = RefPtr(aChunk.mFrame.GetImage()), t, - size, aForceBlack]() mutable { - QueueForProcessing(std::move(image), t, size, aForceBlack); - }, - [] {}); + ->Then( + mTaskQueue, __func__, + [self = RefPtr(this), this, + image = RefPtr(aChunk.mFrame.GetImage()), t, size, + aForceBlack]() mutable { + QueueForProcessing(std::move(image), t, size, aForceBlack); + }, + [] {}); } void SetTrackEnabled(bool aEnabled) { diff --git a/dom/media/doctor/gtest/TestMultiWriterQueue.cpp b/dom/media/doctor/gtest/TestMultiWriterQueue.cpp index fdc290cb07c70..6366a14286602 100644 --- a/dom/media/doctor/gtest/TestMultiWriterQueue.cpp +++ b/dom/media/doctor/gtest/TestMultiWriterQueue.cpp @@ -45,7 +45,8 @@ static void TestMultiWriterQueueST(const int loops) { } } -TEST(MultiWriterQueue, SingleThreaded) { +TEST(MultiWriterQueue, SingleThreaded) +{ TestMultiWriterQueueST<1>(10); TestMultiWriterQueueST<2>(10); TestMultiWriterQueueST<4>(10); @@ -155,7 +156,8 @@ static void TestMultiWriterQueueMT(int aWriterThreads, int aReaderThreads, q.AllocatedBuffersStats().mWatermark); } -TEST(MultiWriterQueue, MultiWriterSingleReader) { +TEST(MultiWriterQueue, MultiWriterSingleReader) +{ // Small BufferSize, to exercize the buffer management code. TestMultiWriterQueueMT< MultiWriterQueue>( @@ -214,7 +216,8 @@ TEST(MultiWriterQueue, MultiWriterSingleReader) { // MultiWriterQueueReaderLocking_None>>(64, 2, 2*1024*1024); } -TEST(MultiWriterQueue, MultiWriterMultiReader) { +TEST(MultiWriterQueue, MultiWriterMultiReader) +{ static_assert( mozilla::IsSame, MultiWriterQueue< @@ -343,7 +346,8 @@ struct DequeWrapperMT : DequeWrapperMW { } }; -TEST(MultiWriterQueue, nsDequeBenchmark) { +TEST(MultiWriterQueue, nsDequeBenchmark) +{ TestMultiWriterQueueMT(1, 0, 2 * 1024 * 1024, "DequeWrapperST "); diff --git a/dom/media/doctor/gtest/TestRollingNumber.cpp b/dom/media/doctor/gtest/TestRollingNumber.cpp index 1343b4f2c538b..d4d7167aaeec6 100644 --- a/dom/media/doctor/gtest/TestRollingNumber.cpp +++ b/dom/media/doctor/gtest/TestRollingNumber.cpp @@ -14,7 +14,8 @@ using RN8 = mozilla::RollingNumber; -TEST(RollingNumber, Value) { +TEST(RollingNumber, Value) +{ // Value type should reflect template argument. static_assert(mozilla::IsSame::value, ""); @@ -40,7 +41,8 @@ TEST(RollingNumber, Value) { EXPECT_EQ(0, n42.Value()); } -TEST(RollingNumber, Operations) { +TEST(RollingNumber, Operations) +{ RN8 n; EXPECT_EQ(0, n.Value()); @@ -90,7 +92,8 @@ TEST(RollingNumber, Operations) { EXPECT_EQ(10, n.Value()); } -TEST(RollingNumber, Comparisons) { +TEST(RollingNumber, Comparisons) +{ uint8_t i = 0; do { RN8 n{i}; diff --git a/dom/media/eme/MediaKeySystemAccess.cpp b/dom/media/eme/MediaKeySystemAccess.cpp index 99a01c20efd6e..65ff49172115c 100644 --- a/dom/media/eme/MediaKeySystemAccess.cpp +++ b/dom/media/eme/MediaKeySystemAccess.cpp @@ -793,7 +793,9 @@ static bool CheckRequirement(const MediaKeysRequirement aRequirement, } break; } - default: { return false; } + default: { + return false; + } } // Set the requirement member of accumulated configuration to equal diff --git a/dom/media/encoder/VP8TrackEncoder.cpp b/dom/media/encoder/VP8TrackEncoder.cpp index 56af6cf739d58..ba761052ff0a3 100644 --- a/dom/media/encoder/VP8TrackEncoder.cpp +++ b/dom/media/encoder/VP8TrackEncoder.cpp @@ -233,7 +233,9 @@ nsresult VP8TrackEncoder::GetEncodedPartitions(EncodedFrameContainer& aData) { pkt->data.frame.sz); break; } - default: { break; } + default: { + break; + } } // End of frame if ((pkt->data.frame.flags & VPX_FRAME_IS_FRAGMENT) == 0) { diff --git a/dom/media/gmp/ChromiumCDMChild.cpp b/dom/media/gmp/ChromiumCDMChild.cpp index 9b3e4ebfb8dfa..075439f7f0d44 100644 --- a/dom/media/gmp/ChromiumCDMChild.cpp +++ b/dom/media/gmp/ChromiumCDMChild.cpp @@ -392,15 +392,16 @@ mozilla::ipc::IPCResult ChromiumCDMChild::RecvInit( mPersistentStateAllowed = aAllowPersistentState; RefPtr promise = mInitPromise.Ensure(__func__); - promise->Then(mPlugin->GMPMessageLoop()->SerialEventTarget(), __func__, - [aResolver](bool /* unused */) { aResolver(true); }, - [aResolver](nsresult rv) { - GMP_LOG( - "ChromiumCDMChild::RecvInit() init promise rejected with " - "rv=%" PRIu32, - static_cast(rv)); - aResolver(false); - }); + promise->Then( + mPlugin->GMPMessageLoop()->SerialEventTarget(), __func__, + [aResolver](bool /* unused */) { aResolver(true); }, + [aResolver](nsresult rv) { + GMP_LOG( + "ChromiumCDMChild::RecvInit() init promise rejected with " + "rv=%" PRIu32, + static_cast(rv)); + aResolver(false); + }); if (mCDM) { // Once the CDM is initialized we expect it to resolve mInitPromise via diff --git a/dom/media/gmp/ChromiumCDMProxy.cpp b/dom/media/gmp/ChromiumCDMProxy.cpp index b9e9e932e7831..0c3dea377cfb7 100644 --- a/dom/media/gmp/ChromiumCDMProxy.cpp +++ b/dom/media/gmp/ChromiumCDMProxy.cpp @@ -93,20 +93,21 @@ void ChromiumCDMProxy::Init(PromiseId aPromiseId, const nsAString& aOrigin, cdm->Init(self->mCallback.get(), self->mDistinctiveIdentifierRequired, self->mPersistentStateRequired, self->mMainThread) - ->Then(thread, __func__, - [self, aPromiseId, cdm](bool /* unused */) { - // CDM init succeeded - { - MutexAutoLock lock(self->mCDMMutex); - self->mCDM = cdm; - } - self->OnCDMCreated(aPromiseId); - }, - [self, aPromiseId](MediaResult aResult) { - // CDM init failed - self->RejectPromise(aPromiseId, aResult.Code(), - aResult.Message()); - }); + ->Then( + thread, __func__, + [self, aPromiseId, cdm](bool /* unused */) { + // CDM init succeeded + { + MutexAutoLock lock(self->mCDMMutex); + self->mCDM = cdm; + } + self->OnCDMCreated(aPromiseId); + }, + [self, aPromiseId](MediaResult aResult) { + // CDM init failed + self->RejectPromise(aPromiseId, aResult.Code(), + aResult.Message()); + }); }, [self, aPromiseId](MediaResult rv) { // service->GetCDM failed diff --git a/dom/media/gmp/GMPService.cpp b/dom/media/gmp/GMPService.cpp index 660018343378c..5c8c58c9e6eae 100644 --- a/dom/media/gmp/GMPService.cpp +++ b/dom/media/gmp/GMPService.cpp @@ -355,24 +355,25 @@ GeckoMediaPluginService::GetDecryptingGMPVideoDecoder( RefPtr helper(aHelper); GetContentParent(aHelper, aNodeId, NS_LITERAL_CSTRING(GMP_API_VIDEO_DECODER), *aTags) - ->Then(thread, __func__, - [rawCallback, helper, - aDecryptorId](RefPtr wrapper) { - RefPtr parent = wrapper->mParent; - UniquePtr callback(rawCallback); - GMPVideoDecoderParent* actor = nullptr; - GMPVideoHostImpl* host = nullptr; - if (parent && NS_SUCCEEDED(parent->GetGMPVideoDecoder( - &actor, aDecryptorId))) { - host = &(actor->Host()); - actor->SetCrashHelper(helper); - } - callback->Done(actor, host); - }, - [rawCallback] { - UniquePtr callback(rawCallback); - callback->Done(nullptr, nullptr); - }); + ->Then( + thread, __func__, + [rawCallback, helper, + aDecryptorId](RefPtr wrapper) { + RefPtr parent = wrapper->mParent; + UniquePtr callback(rawCallback); + GMPVideoDecoderParent* actor = nullptr; + GMPVideoHostImpl* host = nullptr; + if (parent && NS_SUCCEEDED(parent->GetGMPVideoDecoder( + &actor, aDecryptorId))) { + host = &(actor->Host()); + actor->SetCrashHelper(helper); + } + callback->Done(actor, host); + }, + [rawCallback] { + UniquePtr callback(rawCallback); + callback->Done(nullptr, nullptr); + }); return NS_OK; } @@ -395,23 +396,24 @@ GeckoMediaPluginService::GetGMPVideoEncoder( RefPtr helper(aHelper); GetContentParent(aHelper, aNodeId, NS_LITERAL_CSTRING(GMP_API_VIDEO_ENCODER), *aTags) - ->Then(thread, __func__, - [rawCallback, - helper](RefPtr wrapper) { - RefPtr parent = wrapper->mParent; - UniquePtr callback(rawCallback); - GMPVideoEncoderParent* actor = nullptr; - GMPVideoHostImpl* host = nullptr; - if (parent && NS_SUCCEEDED(parent->GetGMPVideoEncoder(&actor))) { - host = &(actor->Host()); - actor->SetCrashHelper(helper); - } - callback->Done(actor, host); - }, - [rawCallback] { - UniquePtr callback(rawCallback); - callback->Done(nullptr, nullptr); - }); + ->Then( + thread, __func__, + [rawCallback, + helper](RefPtr wrapper) { + RefPtr parent = wrapper->mParent; + UniquePtr callback(rawCallback); + GMPVideoEncoderParent* actor = nullptr; + GMPVideoHostImpl* host = nullptr; + if (parent && NS_SUCCEEDED(parent->GetGMPVideoEncoder(&actor))) { + host = &(actor->Host()); + actor->SetCrashHelper(helper); + } + callback->Done(actor, host); + }, + [rawCallback] { + UniquePtr callback(rawCallback); + callback->Done(nullptr, nullptr); + }); return NS_OK; } diff --git a/dom/media/gmp/GMPServiceParent.cpp b/dom/media/gmp/GMPServiceParent.cpp index 8bc29a8257701..9cd1d2151e761 100644 --- a/dom/media/gmp/GMPServiceParent.cpp +++ b/dom/media/gmp/GMPServiceParent.cpp @@ -401,17 +401,18 @@ void GeckoMediaPluginServiceParent::InitializePlugins( RefPtr p = mInitPromise.Ensure(__func__); InvokeAsync(aAbstractGMPThread, this, __func__, &GeckoMediaPluginServiceParent::LoadFromEnvironment) - ->Then(aAbstractGMPThread, __func__, - [self]() -> void { - MonitorAutoLock lock(self->mInitPromiseMonitor); - self->mLoadPluginsFromDiskComplete = true; - self->mInitPromise.Resolve(true, __func__); - }, - [self]() -> void { - MonitorAutoLock lock(self->mInitPromiseMonitor); - self->mLoadPluginsFromDiskComplete = true; - self->mInitPromise.Reject(NS_ERROR_FAILURE, __func__); - }); + ->Then( + aAbstractGMPThread, __func__, + [self]() -> void { + MonitorAutoLock lock(self->mInitPromiseMonitor); + self->mLoadPluginsFromDiskComplete = true; + self->mInitPromise.Resolve(true, __func__); + }, + [self]() -> void { + MonitorAutoLock lock(self->mInitPromiseMonitor); + self->mLoadPluginsFromDiskComplete = true; + self->mInitPromise.Reject(NS_ERROR_FAILURE, __func__); + }); } void GeckoMediaPluginServiceParent::NotifySyncShutdownComplete() { @@ -507,12 +508,12 @@ RefPtr GeckoMediaPluginServiceParent::LoadFromEnvironment() { mScannedPluginOnDisk = true; return GenericPromise::All(thread, promises) - ->Then(thread, __func__, - []() { return GenericPromise::CreateAndResolve(true, __func__); }, - []() { - return GenericPromise::CreateAndReject(NS_ERROR_FAILURE, - __func__); - }); + ->Then( + thread, __func__, + []() { return GenericPromise::CreateAndResolve(true, __func__); }, + []() { + return GenericPromise::CreateAndReject(NS_ERROR_FAILURE, __func__); + }); } class NotifyObserversTask final : public mozilla::Runnable { @@ -612,23 +613,24 @@ RefPtr GeckoMediaPluginServiceParent::AsyncAddPluginDirectory( RefPtr self = this; return InvokeAsync(thread, this, __func__, &GeckoMediaPluginServiceParent::AddOnGMPThread, dir) - ->Then(mMainThread, __func__, - [dir, self](bool aVal) { - LOGD( - ("GeckoMediaPluginServiceParent::AsyncAddPluginDirectory %s " - "succeeded", - NS_ConvertUTF16toUTF8(dir).get())); - MOZ_ASSERT(NS_IsMainThread()); - self->UpdateContentProcessGMPCapabilities(); - return GenericPromise::CreateAndResolve(aVal, __func__); - }, - [dir](nsresult aResult) { - LOGD( - ("GeckoMediaPluginServiceParent::AsyncAddPluginDirectory %s " - "failed", - NS_ConvertUTF16toUTF8(dir).get())); - return GenericPromise::CreateAndReject(aResult, __func__); - }); + ->Then( + mMainThread, __func__, + [dir, self](bool aVal) { + LOGD( + ("GeckoMediaPluginServiceParent::AsyncAddPluginDirectory %s " + "succeeded", + NS_ConvertUTF16toUTF8(dir).get())); + MOZ_ASSERT(NS_IsMainThread()); + self->UpdateContentProcessGMPCapabilities(); + return GenericPromise::CreateAndResolve(aVal, __func__); + }, + [dir](nsresult aResult) { + LOGD( + ("GeckoMediaPluginServiceParent::AsyncAddPluginDirectory %s " + "failed", + NS_ConvertUTF16toUTF8(dir).get())); + return GenericPromise::CreateAndReject(aResult, __func__); + }); } NS_IMETHODIMP diff --git a/dom/media/gtest/TestAudioBuffers.cpp b/dom/media/gtest/TestAudioBuffers.cpp index fff087cf3e26a..2de1e646fbd98 100644 --- a/dom/media/gtest/TestAudioBuffers.cpp +++ b/dom/media/gtest/TestAudioBuffers.cpp @@ -42,8 +42,8 @@ void test_for_number_of_channels(const uint32_t channels) { for (uint32_t i = 0; i < samples; i++) { ASSERT_TRUE(fromCallback[i] == 1.0) - << "Difference at " << i << " (" << fromCallback[i] << " != " << 1.0 - << ")\n"; + << "Difference at " << i << " (" << fromCallback[i] << " != " << 1.0 + << ")\n"; } ASSERT_TRUE(b.Fill(other.data(), FRAMES) == 128); @@ -51,7 +51,8 @@ void test_for_number_of_channels(const uint32_t channels) { ASSERT_TRUE(b.Empty(mBuffer) == 0); } -TEST(AudioBuffers, Test) { +TEST(AudioBuffers, Test) +{ for (uint32_t ch = 1; ch <= 8; ++ch) { test_for_number_of_channels(ch); } diff --git a/dom/media/gtest/TestAudioCompactor.cpp b/dom/media/gtest/TestAudioCompactor.cpp index 92b4a5bda4006..563b10e9bda88 100644 --- a/dom/media/gtest/TestAudioCompactor.cpp +++ b/dom/media/gtest/TestAudioCompactor.cpp @@ -75,15 +75,20 @@ static void TestAudioCompactor(size_t aBytes) { EXPECT_LE(slop, maxSlop) << "allowed too much allocation slop"; } -TEST(Media, AudioCompactor_4000) { TestAudioCompactor(4000); } +TEST(Media, AudioCompactor_4000) +{ TestAudioCompactor(4000); } -TEST(Media, AudioCompactor_4096) { TestAudioCompactor(4096); } +TEST(Media, AudioCompactor_4096) +{ TestAudioCompactor(4096); } -TEST(Media, AudioCompactor_5000) { TestAudioCompactor(5000); } +TEST(Media, AudioCompactor_5000) +{ TestAudioCompactor(5000); } -TEST(Media, AudioCompactor_5256) { TestAudioCompactor(5256); } +TEST(Media, AudioCompactor_5256) +{ TestAudioCompactor(5256); } -TEST(Media, AudioCompactor_NativeCopy) { +TEST(Media, AudioCompactor_NativeCopy) +{ const uint32_t channels = 2; const size_t srcBytes = 32; const uint32_t srcSamples = srcBytes / sizeof(AudioDataValue); diff --git a/dom/media/gtest/TestAudioDeviceEnumerator.cpp b/dom/media/gtest/TestAudioDeviceEnumerator.cpp index 4b19c418a440a..4a04998a0a144 100644 --- a/dom/media/gtest/TestAudioDeviceEnumerator.cpp +++ b/dom/media/gtest/TestAudioDeviceEnumerator.cpp @@ -482,7 +482,8 @@ void AddDevices(MockCubeb* mock, uint32_t device_count, } #ifndef ANDROID -TEST(CubebDeviceEnumerator, EnumerateSimple) { +TEST(CubebDeviceEnumerator, EnumerateSimple) +{ // It looks like we're leaking this object, but in fact it will be freed by // gecko sometime later: `cubeb_destroy` is called when layout statics are // shutdown and we cast back to a MockCubeb* and call the dtor. @@ -518,7 +519,8 @@ TEST(CubebDeviceEnumerator, EnumerateSimple) { } #else // building for Android, which has no device enumeration support -TEST(CubebDeviceEnumerator, EnumerateAndroid) { +TEST(CubebDeviceEnumerator, EnumerateAndroid) +{ MockCubeb* mock = new MockCubeb(); mozilla::CubebUtils::ForceSetCubebContext(mock->AsCubebContext()); @@ -547,7 +549,8 @@ TEST(CubebDeviceEnumerator, EnumerateAndroid) { } #endif -TEST(CubebDeviceEnumerator, ForceNullCubebContext) { +TEST(CubebDeviceEnumerator, ForceNullCubebContext) +{ mozilla::CubebUtils::ForceSetCubebContext(nullptr); RefPtr enumerator = CubebDeviceEnumerator::GetInstance(); @@ -566,7 +569,8 @@ TEST(CubebDeviceEnumerator, ForceNullCubebContext) { CubebDeviceEnumerator::Shutdown(); } -TEST(CubebDeviceEnumerator, DeviceInfoFromId) { +TEST(CubebDeviceEnumerator, DeviceInfoFromId) +{ MockCubeb* mock = new MockCubeb(); mozilla::CubebUtils::ForceSetCubebContext(mock->AsCubebContext()); @@ -604,7 +608,8 @@ TEST(CubebDeviceEnumerator, DeviceInfoFromId) { CubebDeviceEnumerator::Shutdown(); } -TEST(CubebDeviceEnumerator, DeviceInfoFromName) { +TEST(CubebDeviceEnumerator, DeviceInfoFromName) +{ MockCubeb* mock = new MockCubeb(); mozilla::CubebUtils::ForceSetCubebContext(mock->AsCubebContext()); diff --git a/dom/media/gtest/TestAudioMixer.cpp b/dom/media/gtest/TestAudioMixer.cpp index 1951681606d12..39a1767d05bc7 100644 --- a/dom/media/gtest/TestAudioMixer.cpp +++ b/dom/media/gtest/TestAudioMixer.cpp @@ -70,7 +70,8 @@ void FillBuffer(AudioDataValue* aBuffer, uint32_t aLength, } } -TEST(AudioMixer, Test) { +TEST(AudioMixer, Test) +{ const uint32_t CHANNEL_LENGTH = 256; const uint32_t AUDIO_RATE = 44100; MixerConsumer consumer; diff --git a/dom/media/gtest/TestAudioPacketizer.cpp b/dom/media/gtest/TestAudioPacketizer.cpp index 805cfd416aefc..1fee110d9a0f5 100644 --- a/dom/media/gtest/TestAudioPacketizer.cpp +++ b/dom/media/gtest/TestAudioPacketizer.cpp @@ -34,7 +34,7 @@ void IsSequence(std::unique_ptr aBuffer, uint32_t aSize, uint32_t aStart = 0) { for (uint32_t i = 0; i < aSize; i++) { ASSERT_TRUE(aBuffer[i] == static_cast(aStart + i)) - << "Buffer is not a sequence at offset " << i << std::endl; + << "Buffer is not a sequence at offset " << i << std::endl; } // Buffer is a sequence. } @@ -42,13 +42,14 @@ void IsSequence(std::unique_ptr aBuffer, uint32_t aSize, void Zero(std::unique_ptr aBuffer, uint32_t aSize) { for (uint32_t i = 0; i < aSize; i++) { ASSERT_TRUE(aBuffer[i] == 0) - << "Buffer is not null at offset " << i << std::endl; + << "Buffer is not null at offset " << i << std::endl; } } double sine(uint32_t aPhase) { return sin(aPhase * 2 * M_PI * 440 / 44100); } -TEST(AudioPacketizer, Test) { +TEST(AudioPacketizer, Test) +{ for (int16_t channels = 1; channels < 2; channels++) { // Test that the packetizer returns zero on underrun { diff --git a/dom/media/gtest/TestAudioSegment.cpp b/dom/media/gtest/TestAudioSegment.cpp index 1abb01d187f77..df49ae1e5555f 100644 --- a/dom/media/gtest/TestAudioSegment.cpp +++ b/dom/media/gtest/TestAudioSegment.cpp @@ -224,7 +224,8 @@ void TestDownmixStereo() { delete[] output; } -TEST(AudioSegment, Test) { +TEST(AudioSegment, Test) +{ TestInterleaveAndConvert(); TestInterleaveAndConvert(); TestInterleaveAndConvert(); diff --git a/dom/media/gtest/TestAudioTrackEncoder.cpp b/dom/media/gtest/TestAudioTrackEncoder.cpp index d00479ea51b3b..a12eac7d68c86 100644 --- a/dom/media/gtest/TestAudioTrackEncoder.cpp +++ b/dom/media/gtest/TestAudioTrackEncoder.cpp @@ -59,7 +59,8 @@ static bool TestOpusInit(int aChannels, int aSamplingRate) { return encoder.TestOpusRawCreation(aChannels, aSamplingRate); } -TEST(OpusAudioTrackEncoder, InitRaw) { +TEST(OpusAudioTrackEncoder, InitRaw) +{ // Expect false with 0 or negative channels of input signal. EXPECT_FALSE(TestOpusInit(0, 16000)); EXPECT_FALSE(TestOpusInit(-1, 16000)); @@ -89,7 +90,8 @@ TEST(OpusAudioTrackEncoder, InitRaw) { EXPECT_FALSE(TestOpusInit(2, 200000)); } -TEST(OpusAudioTrackEncoder, Init) { +TEST(OpusAudioTrackEncoder, Init) +{ { // The encoder does not normally recieve enough info from null data to // init. However, multiple attempts to do so, with sufficiently long @@ -175,7 +177,8 @@ static int TestOpusResampler(int aChannels, int aSamplingRate) { return encoder.TestGetOutputSampleRate(); } -TEST(OpusAudioTrackEncoder, Resample) { +TEST(OpusAudioTrackEncoder, Resample) +{ // Sampling rates of data to be fed to Opus encoder, should remain unchanged // if it is one of Opus supported rates (8000, 12000, 16000, 24000 and 48000 // (kHz)) at initialization. @@ -190,7 +193,8 @@ TEST(OpusAudioTrackEncoder, Resample) { EXPECT_TRUE(TestOpusResampler(1, 44100) == 48000); } -TEST(OpusAudioTrackEncoder, FetchMetadata) { +TEST(OpusAudioTrackEncoder, FetchMetadata) +{ const int32_t channels = 1; const int32_t sampleRate = 44100; TestOpusTrackEncoder encoder; @@ -204,7 +208,8 @@ TEST(OpusAudioTrackEncoder, FetchMetadata) { EXPECT_EQ(sampleRate, opusMeta->mSamplingFrequency); } -TEST(OpusAudioTrackEncoder, FrameEncode) { +TEST(OpusAudioTrackEncoder, FrameEncode) +{ const int32_t channels = 1; const int32_t sampleRate = 44100; TestOpusTrackEncoder encoder; diff --git a/dom/media/gtest/TestBitWriter.cpp b/dom/media/gtest/TestBitWriter.cpp index a2ef65a6a474b..1464a11f63b1e 100644 --- a/dom/media/gtest/TestBitWriter.cpp +++ b/dom/media/gtest/TestBitWriter.cpp @@ -10,7 +10,8 @@ using namespace mozilla; -TEST(BitWriter, BitWriter) { +TEST(BitWriter, BitWriter) +{ RefPtr test = new MediaByteBuffer(); BitWriter b(test); b.WriteBit(false); @@ -49,7 +50,8 @@ TEST(BitWriter, BitWriter) { EXPECT_EQ(length, BitReader::GetBitLength(test)); } -TEST(BitWriter, SPS) { +TEST(BitWriter, SPS) +{ uint8_t sps_pps[] = {0x01, 0x4d, 0x40, 0x0c, 0xff, 0xe1, 0x00, 0x1b, 0x67, 0x4d, 0x40, 0x0c, 0xe8, 0x80, 0x80, 0x9d, 0x80, 0xb5, 0x01, 0x01, 0x01, 0x40, 0x00, 0x00, 0x03, 0x00, 0x40, diff --git a/dom/media/gtest/TestBlankVideoDataCreator.cpp b/dom/media/gtest/TestBlankVideoDataCreator.cpp index a4b06d1bfbede..94a6213fd1d94 100644 --- a/dom/media/gtest/TestBlankVideoDataCreator.cpp +++ b/dom/media/gtest/TestBlankVideoDataCreator.cpp @@ -8,7 +8,8 @@ using namespace mozilla; -TEST(BlankVideoDataCreator, ShouldNotOverflow) { +TEST(BlankVideoDataCreator, ShouldNotOverflow) +{ RefPtr mrd = new MediaRawData(); const uint32_t width = 1; const uint32_t height = 1; @@ -17,7 +18,8 @@ TEST(BlankVideoDataCreator, ShouldNotOverflow) { EXPECT_NE(data.get(), nullptr); } -TEST(BlankVideoDataCreator, ShouldOverflow) { +TEST(BlankVideoDataCreator, ShouldOverflow) +{ RefPtr mrd = new MediaRawData(); const uint32_t width = UINT_MAX; const uint32_t height = UINT_MAX; diff --git a/dom/media/gtest/TestBufferReader.cpp b/dom/media/gtest/TestBufferReader.cpp index 23d2a5f246541..47f48781e6b60 100644 --- a/dom/media/gtest/TestBufferReader.cpp +++ b/dom/media/gtest/TestBufferReader.cpp @@ -6,7 +6,8 @@ #include "gtest/gtest.h" #include "BufferReader.h" -TEST(BufferReader, ReaderCursor) { +TEST(BufferReader, ReaderCursor) +{ // Allocate a buffer and create a BufferReader. const size_t BUFFER_SIZE = 10; uint8_t buffer[BUFFER_SIZE] = {0}; diff --git a/dom/media/gtest/TestCDMStorage.cpp b/dom/media/gtest/TestCDMStorage.cpp index 4649e80efc630..1cdfbe21b6f36 100644 --- a/dom/media/gtest/TestCDMStorage.cpp +++ b/dom/media/gtest/TestCDMStorage.cpp @@ -399,24 +399,26 @@ class CDMStorageTest { RefPtr promise = service->GetCDM(aNodeId, std::move(tags), nullptr); auto thread = GetAbstractGMPThread(); - promise->Then(thread, __func__, - [self, aUpdates, thread](RefPtr cdm) { - self->mCDM = cdm; - EXPECT_TRUE(!!self->mCDM); - self->mCallback.reset(new CallbackProxy(self)); - nsCString failureReason; - self->mCDM - ->Init(self->mCallback.get(), false, true, - GetMainThreadEventTarget()) - ->Then(thread, __func__, - [self, aUpdates] { - for (auto& update : aUpdates) { - self->Update(update); - } - }, - [](MediaResult rv) { EXPECT_TRUE(false); }); + promise->Then( + thread, __func__, + [self, aUpdates, thread](RefPtr cdm) { + self->mCDM = cdm; + EXPECT_TRUE(!!self->mCDM); + self->mCallback.reset(new CallbackProxy(self)); + nsCString failureReason; + self->mCDM + ->Init(self->mCallback.get(), false, true, + GetMainThreadEventTarget()) + ->Then( + thread, __func__, + [self, aUpdates] { + for (auto& update : aUpdates) { + self->Update(update); + } }, [](MediaResult rv) { EXPECT_TRUE(false); }); + }, + [](MediaResult rv) { EXPECT_TRUE(false); }); } void TestBasicStorage() { @@ -1028,54 +1030,64 @@ class CDMStorageTest { UniquePtr mCallback; }; // class CDMStorageTest -TEST(GeckoMediaPlugins, CDMStorageGetNodeId) { +TEST(GeckoMediaPlugins, CDMStorageGetNodeId) +{ RefPtr runner = new CDMStorageTest(); runner->DoTest(&CDMStorageTest::TestGetNodeId); } -TEST(GeckoMediaPlugins, CDMStorageBasic) { +TEST(GeckoMediaPlugins, CDMStorageBasic) +{ RefPtr runner = new CDMStorageTest(); runner->DoTest(&CDMStorageTest::TestBasicStorage); } -TEST(GeckoMediaPlugins, CDMStorageForgetThisSite) { +TEST(GeckoMediaPlugins, CDMStorageForgetThisSite) +{ RefPtr runner = new CDMStorageTest(); runner->DoTest(&CDMStorageTest::TestForgetThisSite); } -TEST(GeckoMediaPlugins, CDMStorageClearRecentHistory1) { +TEST(GeckoMediaPlugins, CDMStorageClearRecentHistory1) +{ RefPtr runner = new CDMStorageTest(); runner->DoTest(&CDMStorageTest::TestClearRecentHistory1); } -TEST(GeckoMediaPlugins, CDMStorageClearRecentHistory2) { +TEST(GeckoMediaPlugins, CDMStorageClearRecentHistory2) +{ RefPtr runner = new CDMStorageTest(); runner->DoTest(&CDMStorageTest::TestClearRecentHistory2); } -TEST(GeckoMediaPlugins, CDMStorageClearRecentHistory3) { +TEST(GeckoMediaPlugins, CDMStorageClearRecentHistory3) +{ RefPtr runner = new CDMStorageTest(); runner->DoTest(&CDMStorageTest::TestClearRecentHistory3); } -TEST(GeckoMediaPlugins, CDMStorageCrossOrigin) { +TEST(GeckoMediaPlugins, CDMStorageCrossOrigin) +{ RefPtr runner = new CDMStorageTest(); runner->DoTest(&CDMStorageTest::TestCrossOriginStorage); } -TEST(GeckoMediaPlugins, CDMStoragePrivateBrowsing) { +TEST(GeckoMediaPlugins, CDMStoragePrivateBrowsing) +{ RefPtr runner = new CDMStorageTest(); runner->DoTest(&CDMStorageTest::TestPBStorage); } #if defined(XP_WIN) -TEST(GeckoMediaPlugins, GMPOutputProtection) { +TEST(GeckoMediaPlugins, GMPOutputProtection) +{ RefPtr runner = new CDMStorageTest(); runner->DoTest(&CDMStorageTest::TestOutputProtection); } #endif -TEST(GeckoMediaPlugins, CDMStorageLongRecordNames) { +TEST(GeckoMediaPlugins, CDMStorageLongRecordNames) +{ RefPtr runner = new CDMStorageTest(); runner->DoTest(&CDMStorageTest::TestLongRecordNames); } diff --git a/dom/media/gtest/TestDataMutex.cpp b/dom/media/gtest/TestDataMutex.cpp index 2453670773331..f381e2857b7b7 100644 --- a/dom/media/gtest/TestDataMutex.cpp +++ b/dom/media/gtest/TestDataMutex.cpp @@ -14,7 +14,8 @@ struct A { int mValue; }; -TEST(DataMutex, Basic) { +TEST(DataMutex, Basic) +{ { DataMutex i(1, "1"); auto x = i.Lock(); diff --git a/dom/media/gtest/TestGMPCrossOrigin.cpp b/dom/media/gtest/TestGMPCrossOrigin.cpp index 2d5940015980a..3688bee1a0d35 100644 --- a/dom/media/gtest/TestGMPCrossOrigin.cpp +++ b/dom/media/gtest/TestGMPCrossOrigin.cpp @@ -198,14 +198,16 @@ void GMPTestRunner::DoTest( monitor.AwaitFinished(); } -TEST(GeckoMediaPlugins, GMPTestCodec) { +TEST(GeckoMediaPlugins, GMPTestCodec) +{ RefPtr runner = new GMPTestRunner(); runner->DoTest(&GMPTestRunner::RunTestGMPTestCodec1); runner->DoTest(&GMPTestRunner::RunTestGMPTestCodec2); runner->DoTest(&GMPTestRunner::RunTestGMPTestCodec3); } -TEST(GeckoMediaPlugins, GMPCrossOrigin) { +TEST(GeckoMediaPlugins, GMPCrossOrigin) +{ RefPtr runner = new GMPTestRunner(); runner->DoTest(&GMPTestRunner::RunTestGMPCrossOrigin1); runner->DoTest(&GMPTestRunner::RunTestGMPCrossOrigin2); diff --git a/dom/media/gtest/TestGMPRemoveAndDelete.cpp b/dom/media/gtest/TestGMPRemoveAndDelete.cpp index af3800da57dcf..93049585fff1b 100644 --- a/dom/media/gtest/TestGMPRemoveAndDelete.cpp +++ b/dom/media/gtest/TestGMPRemoveAndDelete.cpp @@ -105,7 +105,8 @@ class GMPRemoveTest : public nsIObserver, public GMPVideoDecoderCallbackProxy { /* * Simple test that the plugin is deleted when forcibly removed and deleted. */ -TEST(GeckoMediaPlugins, RemoveAndDeleteForcedSimple) { +TEST(GeckoMediaPlugins, RemoveAndDeleteForcedSimple) +{ RefPtr test(new GMPRemoveTest()); test->Setup(); @@ -116,7 +117,8 @@ TEST(GeckoMediaPlugins, RemoveAndDeleteForcedSimple) { /* * Simple test that the plugin is deleted when deferred deletion is allowed. */ -TEST(GeckoMediaPlugins, RemoveAndDeleteDeferredSimple) { +TEST(GeckoMediaPlugins, RemoveAndDeleteDeferredSimple) +{ RefPtr test(new GMPRemoveTest()); test->Setup(); @@ -128,7 +130,8 @@ TEST(GeckoMediaPlugins, RemoveAndDeleteDeferredSimple) { * Test that the plugin is unavailable immediately after a forced * RemoveAndDelete, and that the plugin is deleted afterwards. */ -TEST(GeckoMediaPlugins, RemoveAndDeleteForcedInUse) { +TEST(GeckoMediaPlugins, RemoveAndDeleteForcedInUse) +{ RefPtr test(new GMPRemoveTest()); test->Setup(); @@ -152,7 +155,8 @@ TEST(GeckoMediaPlugins, RemoveAndDeleteForcedInUse) { * Test that the plugin is still usable after a deferred RemoveAndDelete, and * that the plugin is deleted afterwards. */ -TEST(GeckoMediaPlugins, RemoveAndDeleteDeferredInUse) { +TEST(GeckoMediaPlugins, RemoveAndDeleteDeferredInUse) +{ RefPtr test(new GMPRemoveTest()); test->Setup(); diff --git a/dom/media/gtest/TestGMPUtils.cpp b/dom/media/gtest/TestGMPUtils.cpp index 22eeff5c4301a..7cd690d3dcf38 100644 --- a/dom/media/gtest/TestGMPUtils.cpp +++ b/dom/media/gtest/TestGMPUtils.cpp @@ -28,7 +28,8 @@ void TestSplitAt(const char* aInput, const char* aDelims, } } -TEST(GeckoMediaPlugins, TestSplitAt) { +TEST(GeckoMediaPlugins, TestSplitAt) +{ { const char* input = "1,2,3,4"; const char* delims = ","; @@ -55,7 +56,8 @@ TEST(GeckoMediaPlugins, TestSplitAt) { } } -TEST(GeckoMediaPlugins, ToHexString) { +TEST(GeckoMediaPlugins, ToHexString) +{ struct Test { nsTArray bytes; string hex; diff --git a/dom/media/gtest/TestGroupId.cpp b/dom/media/gtest/TestGroupId.cpp index bf368fdc92c7f..621445d6f368b 100644 --- a/dom/media/gtest/TestGroupId.cpp +++ b/dom/media/gtest/TestGroupId.cpp @@ -90,7 +90,8 @@ RefPtr MakeSpeakerDevice(const nsString& aName, /* Verify that when an audio input device name contains the video input device * name the video device group id is updated to become equal to the audio * device group id. */ -TEST(TestGroupId, MatchInput_PartOfName) { +TEST(TestGroupId, MatchInput_PartOfName) +{ MediaManager::MediaDeviceSet devices; devices.AppendElement( @@ -110,7 +111,8 @@ TEST(TestGroupId, MatchInput_PartOfName) { /* Verify that when an audio input device name is the same as the video input * device name the video device group id is updated to become equal to the audio * device group id. */ -TEST(TestGroupId, MatchInput_FullName) { +TEST(TestGroupId, MatchInput_FullName) +{ MediaManager::MediaDeviceSet devices; devices.AppendElement( @@ -128,7 +130,8 @@ TEST(TestGroupId, MatchInput_FullName) { /* Verify that when an audio input device name does not contain the video input * device name the video device group id does not change. */ -TEST(TestGroupId, NoMatchInput) { +TEST(TestGroupId, NoMatchInput) +{ MediaManager::MediaDeviceSet devices; nsString Cam_Model_GroupId = NS_LITERAL_STRING("Cam-Model-GroupId"); @@ -149,7 +152,8 @@ TEST(TestGroupId, NoMatchInput) { /* Verify that when more that one audio input and more than one audio output * device name contain the video input device name the video device group id * does not change. */ -TEST(TestGroupId, NoMatch_TwoIdenticalDevices) { +TEST(TestGroupId, NoMatch_TwoIdenticalDevices) +{ MediaManager::MediaDeviceSet devices; nsString Cam_Model_GroupId = NS_LITERAL_STRING("Cam-Model-GroupId"); @@ -184,7 +188,8 @@ TEST(TestGroupId, NoMatch_TwoIdenticalDevices) { * input device name the video device group id is not updated by audio input * device group id but it continues looking at audio output devices where it * finds a match so video input group id is updated by audio output group id. */ -TEST(TestGroupId, Match_TwoIdenticalInputsMatchOutput) { +TEST(TestGroupId, Match_TwoIdenticalInputsMatchOutput) +{ MediaManager::MediaDeviceSet devices; nsString Cam_Model_GroupId = NS_LITERAL_STRING("Cam-Model-GroupId"); @@ -211,7 +216,8 @@ TEST(TestGroupId, Match_TwoIdenticalInputsMatchOutput) { /* Verify that when more that one audio input and more than one audio output * device names contain the video input device name the video device group id * does not change. */ -TEST(TestGroupId, NoMatch_ThreeIdenticalDevices) { +TEST(TestGroupId, NoMatch_ThreeIdenticalDevices) +{ MediaManager::MediaDeviceSet devices; nsString Cam_Model_GroupId = NS_LITERAL_STRING("Cam-Model-GroupId"); @@ -251,7 +257,8 @@ TEST(TestGroupId, NoMatch_ThreeIdenticalDevices) { /* Verify that when an audio output device name contains the video input device * name the video device group id is updated to become equal to the audio * device group id. */ -TEST(TestGroupId, MatchOutput) { +TEST(TestGroupId, MatchOutput) +{ MediaManager::MediaDeviceSet devices; devices.AppendElement( @@ -274,7 +281,8 @@ TEST(TestGroupId, MatchOutput) { /* Verify that when an audio input device name is the same as audio output * device and video input device name the video device group id is updated to * become equal to the audio input device group id. */ -TEST(TestGroupId, InputOutputSameName) { +TEST(TestGroupId, InputOutputSameName) +{ MediaManager::MediaDeviceSet devices; devices.AppendElement( @@ -297,7 +305,8 @@ TEST(TestGroupId, InputOutputSameName) { /* Verify that when an audio input device name contains the video input device * and the audio input group id is an empty string, the video device group id * is updated to become equal to the audio device group id. */ -TEST(TestGroupId, InputEmptyGroupId) { +TEST(TestGroupId, InputEmptyGroupId) +{ MediaManager::MediaDeviceSet devices; devices.AppendElement( @@ -316,7 +325,8 @@ TEST(TestGroupId, InputEmptyGroupId) { /* Verify that when an audio output device name contains the video input device * and the audio output group id is an empty string, the video device group id * is updated to become equal to the audio output device group id. */ -TEST(TestGroupId, OutputEmptyGroupId) { +TEST(TestGroupId, OutputEmptyGroupId) +{ MediaManager::MediaDeviceSet devices; devices.AppendElement( diff --git a/dom/media/gtest/TestIntervalSet.cpp b/dom/media/gtest/TestIntervalSet.cpp index a5462ba86b8d6..3fdeab0d9986b 100644 --- a/dom/media/gtest/TestIntervalSet.cpp +++ b/dom/media/gtest/TestIntervalSet.cpp @@ -28,7 +28,8 @@ media::IntervalSet CreateByteIntervalSet(int32_t aStart, return test; } -TEST(IntervalSet, Constructors) { +TEST(IntervalSet, Constructors) +{ const int32_t start = 1; const int32_t end = 2; const int32_t fuzz = 0; @@ -73,7 +74,8 @@ media::TimeIntervals CreateTimeIntervals(int32_t aStart, int32_t aEnd) { return test; } -TEST(IntervalSet, TimeIntervalsConstructors) { +TEST(IntervalSet, TimeIntervalsConstructors) +{ const auto start = media::TimeUnit::FromMicroseconds(1); const auto end = media::TimeUnit::FromMicroseconds(2); const media::TimeUnit fuzz; @@ -108,12 +110,14 @@ TEST(IntervalSet, TimeIntervalsConstructors) { EXPECT_EQ(0u, i0.Length()); // Constructing with an empty time interval. } -TEST(IntervalSet, Length) { +TEST(IntervalSet, Length) +{ IntInterval i(15, 25); EXPECT_EQ(10, i.Length()); } -TEST(IntervalSet, Intersects) { +TEST(IntervalSet, Intersects) +{ EXPECT_TRUE(IntInterval(1, 5).Intersects(IntInterval(3, 4))); EXPECT_TRUE(IntInterval(1, 5).Intersects(IntInterval(3, 7))); EXPECT_TRUE(IntInterval(1, 5).Intersects(IntInterval(-1, 3))); @@ -129,7 +133,8 @@ TEST(IntervalSet, Intersects) { EXPECT_FALSE(IntInterval(1, 1).Intersects(IntInterval(2, 2))); } -TEST(IntervalSet, Intersection) { +TEST(IntervalSet, Intersection) +{ IntInterval i0(10, 20); IntInterval i1(15, 25); IntInterval i = i0.Intersection(i1); @@ -145,7 +150,8 @@ TEST(IntervalSet, Intersection) { EXPECT_TRUE(k.IsEmpty()); } -TEST(IntervalSet, Equals) { +TEST(IntervalSet, Equals) +{ IntInterval i0(10, 20); IntInterval i1(10, 20); EXPECT_EQ(i0, i1); @@ -157,7 +163,8 @@ TEST(IntervalSet, Equals) { EXPECT_NE(i0, i2); } -TEST(IntervalSet, IntersectionIntervalSet) { +TEST(IntervalSet, IntersectionIntervalSet) +{ IntIntervals i0; i0 += IntInterval(5, 10); i0 += IntInterval(20, 25); @@ -232,7 +239,8 @@ static void GeneratePermutations(const IntIntervals& aI1, } while (std::next_permutation(comb1.begin(), comb1.end())); } -TEST(IntervalSet, IntersectionNormalizedIntervalSet) { +TEST(IntervalSet, IntersectionNormalizedIntervalSet) +{ IntIntervals i0; i0 += IntInterval(5, 10); i0 += IntInterval(20, 25); @@ -247,7 +255,8 @@ TEST(IntervalSet, IntersectionNormalizedIntervalSet) { GeneratePermutations(i0, i1); } -TEST(IntervalSet, IntersectionUnorderedNonNormalizedIntervalSet) { +TEST(IntervalSet, IntersectionUnorderedNonNormalizedIntervalSet) +{ IntIntervals i0; i0 += IntInterval(5, 10); i0 += IntInterval(8, 25); @@ -262,7 +271,8 @@ TEST(IntervalSet, IntersectionUnorderedNonNormalizedIntervalSet) { GeneratePermutations(i0, i1); } -TEST(IntervalSet, IntersectionNonNormalizedInterval) { +TEST(IntervalSet, IntersectionNonNormalizedInterval) +{ IntIntervals i0; i0 += IntInterval(5, 10); i0 += IntInterval(8, 25); @@ -275,7 +285,8 @@ TEST(IntervalSet, IntersectionNonNormalizedInterval) { EXPECT_EQ(i0[0].mEnd, i1.mEnd); } -TEST(IntervalSet, IntersectionUnorderedNonNormalizedInterval) { +TEST(IntervalSet, IntersectionUnorderedNonNormalizedInterval) +{ IntIntervals i0; i0 += IntInterval(1, 3); i0 += IntInterval(1, 10); @@ -298,7 +309,8 @@ static IntIntervals Duplicate(const IntIntervals& aValue) { return value; } -TEST(IntervalSet, Normalize) { +TEST(IntervalSet, Normalize) +{ IntIntervals i; // Test IntervalSet + Interval operator. i = i + IntInterval(20, 30); @@ -332,7 +344,8 @@ TEST(IntervalSet, Normalize) { EXPECT_EQ(1u, ti.Length()); } -TEST(IntervalSet, ContainValue) { +TEST(IntervalSet, ContainValue) +{ IntIntervals i0; i0 += IntInterval(0, 10); i0 += IntInterval(15, 20); @@ -343,7 +356,8 @@ TEST(IntervalSet, ContainValue) { EXPECT_FALSE(i0.Contains(25)); } -TEST(IntervalSet, ContainValueWithFuzz) { +TEST(IntervalSet, ContainValueWithFuzz) +{ IntIntervals i0; i0 += IntInterval(0, 10); i0 += IntInterval(15, 20, 1); @@ -355,7 +369,8 @@ TEST(IntervalSet, ContainValueWithFuzz) { EXPECT_FALSE(i0.Contains(25)); } -TEST(IntervalSet, ContainInterval) { +TEST(IntervalSet, ContainInterval) +{ IntIntervals i0; i0 += IntInterval(0, 10); i0 += IntInterval(15, 20); @@ -370,7 +385,8 @@ TEST(IntervalSet, ContainInterval) { EXPECT_FALSE(i0.Contains(IntInterval(30, 55))); } -TEST(IntervalSet, ContainIntervalWithFuzz) { +TEST(IntervalSet, ContainIntervalWithFuzz) +{ IntIntervals i0; i0 += IntInterval(0, 10); i0 += IntInterval(15, 20); @@ -394,7 +410,8 @@ TEST(IntervalSet, ContainIntervalWithFuzz) { EXPECT_TRUE(i1.Contains(IntInterval(15, 21))); } -TEST(IntervalSet, Span) { +TEST(IntervalSet, Span) +{ IntInterval i0(0, 10); IntInterval i1(20, 30); IntInterval i{i0.Span(i1)}; @@ -403,7 +420,8 @@ TEST(IntervalSet, Span) { EXPECT_EQ(i.mEnd, 30); } -TEST(IntervalSet, Union) { +TEST(IntervalSet, Union) +{ IntIntervals i0; i0 += IntInterval(5, 10); i0 += IntInterval(20, 25); @@ -429,7 +447,8 @@ TEST(IntervalSet, Union) { EXPECT_EQ(60, i[2].mEnd); } -TEST(IntervalSet, UnionNotOrdered) { +TEST(IntervalSet, UnionNotOrdered) +{ IntIntervals i0; i0 += IntInterval(20, 25); i0 += IntInterval(40, 60); @@ -455,7 +474,8 @@ TEST(IntervalSet, UnionNotOrdered) { EXPECT_EQ(60, i[2].mEnd); } -TEST(IntervalSet, NormalizeFuzz) { +TEST(IntervalSet, NormalizeFuzz) +{ IntIntervals i0; i0 += IntInterval(11, 25, 0); i0 += IntInterval(5, 10, 1); @@ -470,7 +490,8 @@ TEST(IntervalSet, NormalizeFuzz) { EXPECT_EQ(60, i0[1].mEnd); } -TEST(IntervalSet, UnionFuzz) { +TEST(IntervalSet, UnionFuzz) +{ IntIntervals i0; i0 += IntInterval(5, 10, 1); i0 += IntInterval(11, 25, 0); @@ -505,14 +526,16 @@ TEST(IntervalSet, UnionFuzz) { EXPECT_EQ(60, i[1].mEnd); } -TEST(IntervalSet, Contiguous) { +TEST(IntervalSet, Contiguous) +{ EXPECT_FALSE(IntInterval(5, 10).Contiguous(IntInterval(11, 25))); EXPECT_TRUE(IntInterval(5, 10).Contiguous(IntInterval(10, 25))); EXPECT_TRUE(IntInterval(5, 10, 1).Contiguous(IntInterval(11, 25))); EXPECT_TRUE(IntInterval(5, 10).Contiguous(IntInterval(11, 25, 1))); } -TEST(IntervalSet, TimeRangesSeconds) { +TEST(IntervalSet, TimeRangesSeconds) +{ media::TimeIntervals i0; i0 += media::TimeInterval(media::TimeUnit::FromSeconds(20), media::TimeUnit::FromSeconds(25)); @@ -557,7 +580,8 @@ static void CheckTimeRanges(dom::TimeRanges* aTr, } } -TEST(IntervalSet, TimeRangesConversion) { +TEST(IntervalSet, TimeRangesConversion) +{ RefPtr tr = new dom::TimeRanges(); tr->Add(20, 25); tr->Add(40, 60); @@ -575,7 +599,8 @@ TEST(IntervalSet, TimeRangesConversion) { CheckTimeRanges(tr2, i1); } -TEST(IntervalSet, TimeRangesMicroseconds) { +TEST(IntervalSet, TimeRangesMicroseconds) +{ media::TimeIntervals i0; i0 += media::TimeInterval(media::TimeUnit::FromMicroseconds(20), @@ -661,7 +686,8 @@ class Foo { int32_t mArg3; }; -TEST(IntervalSet, FooIntervalSet) { +TEST(IntervalSet, FooIntervalSet) +{ media::Interval> i(Foo(), Foo(4, 5, 6)); media::IntervalSet> is; is += i; @@ -674,7 +700,8 @@ TEST(IntervalSet, FooIntervalSet) { EXPECT_EQ(Foo(4, 5, 6), is[0].mEnd); } -TEST(IntervalSet, StaticAssert) { +TEST(IntervalSet, StaticAssert) +{ media::Interval i; static_assert( @@ -687,7 +714,8 @@ TEST(IntervalSet, StaticAssert) { "Must use copy constructor"); } -TEST(IntervalSet, Substraction) { +TEST(IntervalSet, Substraction) +{ IntIntervals i0; i0 += IntInterval(5, 10); i0 += IntInterval(20, 25); diff --git a/dom/media/gtest/TestMP4Demuxer.cpp b/dom/media/gtest/TestMP4Demuxer.cpp index f676c7a97799f..86f584f85bf65 100644 --- a/dom/media/gtest/TestMP4Demuxer.cpp +++ b/dom/media/gtest/TestMP4Demuxer.cpp @@ -146,22 +146,24 @@ class MP4DemuxerBinding { virtual ~MP4DemuxerBinding() {} }; -TEST(MP4Demuxer, Seek) { +TEST(MP4Demuxer, Seek) +{ RefPtr binding = new MP4DemuxerBinding(); binding->RunTestAndWait([binding]() { binding->mVideoTrack = binding->mDemuxer->GetTrackDemuxer(TrackInfo::kVideoTrack, 0); binding->CheckTrackSamples(binding->mVideoTrack) - ->Then(binding->mTaskQueue, __func__, - [binding]() { - binding->CheckTrackKeyFrame(binding->mVideoTrack) - ->Then( - binding->mTaskQueue, __func__, - [binding]() { binding->mTaskQueue->BeginShutdown(); }, - DO_FAIL); - }, - DO_FAIL); + ->Then( + binding->mTaskQueue, __func__, + [binding]() { + binding->CheckTrackKeyFrame(binding->mVideoTrack) + ->Then( + binding->mTaskQueue, __func__, + [binding]() { binding->mTaskQueue->BeginShutdown(); }, + DO_FAIL); + }, + DO_FAIL); }); } @@ -187,7 +189,8 @@ static nsCString ToCryptoString(const CryptoSample& aCrypto) { return res; } -TEST(MP4Demuxer, CENCFragVideo) { +TEST(MP4Demuxer, CENCFragVideo) +{ const char* video[] = { "16 7e571d037e571d037e571d037e571d03 00000000000000000000000000000000 " "5,684 5,16980", @@ -318,21 +321,22 @@ TEST(MP4Demuxer, CENCFragVideo) { binding->mVideoTrack = binding->mDemuxer->GetTrackDemuxer(TrackInfo::kVideoTrack, 0); binding->CheckTrackSamples(binding->mVideoTrack) - ->Then(binding->mTaskQueue, __func__, - [binding, video]() { - for (uint32_t i = 0; i < binding->mSamples.Length(); i++) { - nsCString text = - ToCryptoString(binding->mSamples[i]->mCrypto); - EXPECT_STREQ(video[i++], text.get()); - } - EXPECT_EQ(ArrayLength(video), binding->mSamples.Length()); - binding->mTaskQueue->BeginShutdown(); - }, - DO_FAIL); + ->Then( + binding->mTaskQueue, __func__, + [binding, video]() { + for (uint32_t i = 0; i < binding->mSamples.Length(); i++) { + nsCString text = ToCryptoString(binding->mSamples[i]->mCrypto); + EXPECT_STREQ(video[i++], text.get()); + } + EXPECT_EQ(ArrayLength(video), binding->mSamples.Length()); + binding->mTaskQueue->BeginShutdown(); + }, + DO_FAIL); }); } -TEST(MP4Demuxer, CENCFragAudio) { +TEST(MP4Demuxer, CENCFragAudio) +{ const char* audio[] = { "16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000000 " "0,281", @@ -531,22 +535,23 @@ TEST(MP4Demuxer, CENCFragAudio) { binding->mAudioTrack = binding->mDemuxer->GetTrackDemuxer(TrackInfo::kAudioTrack, 0); binding->CheckTrackSamples(binding->mAudioTrack) - ->Then(binding->mTaskQueue, __func__, - [binding, audio]() { - EXPECT_TRUE(binding->mSamples.Length() > 1); - for (uint32_t i = 0; i < binding->mSamples.Length(); i++) { - nsCString text = - ToCryptoString(binding->mSamples[i]->mCrypto); - EXPECT_STREQ(audio[i++], text.get()); - } - EXPECT_EQ(ArrayLength(audio), binding->mSamples.Length()); - binding->mTaskQueue->BeginShutdown(); - }, - DO_FAIL); + ->Then( + binding->mTaskQueue, __func__, + [binding, audio]() { + EXPECT_TRUE(binding->mSamples.Length() > 1); + for (uint32_t i = 0; i < binding->mSamples.Length(); i++) { + nsCString text = ToCryptoString(binding->mSamples[i]->mCrypto); + EXPECT_STREQ(audio[i++], text.get()); + } + EXPECT_EQ(ArrayLength(audio), binding->mSamples.Length()); + binding->mTaskQueue->BeginShutdown(); + }, + DO_FAIL); }); } -TEST(MP4Demuxer, GetNextKeyframe) { +TEST(MP4Demuxer, GetNextKeyframe) +{ RefPtr binding = new MP4DemuxerBinding("gizmo-frag.mp4"); binding->RunTestAndWait([binding]() { @@ -575,7 +580,8 @@ TEST(MP4Demuxer, GetNextKeyframe) { }); } -TEST(MP4Demuxer, ZeroInLastMoov) { +TEST(MP4Demuxer, ZeroInLastMoov) +{ RefPtr binding = new MP4DemuxerBinding("short-zero-in-moov.mp4"); binding->RunTestAndWait([binding]() { @@ -584,7 +590,8 @@ TEST(MP4Demuxer, ZeroInLastMoov) { }); } -TEST(MP4Demuxer, ZeroInMoovQuickTime) { +TEST(MP4Demuxer, ZeroInMoovQuickTime) +{ RefPtr binding = new MP4DemuxerBinding("short-zero-inband.mov"); binding->RunTestAndWait([binding]() { @@ -593,7 +600,8 @@ TEST(MP4Demuxer, ZeroInMoovQuickTime) { }); } -TEST(MP4Demuxer, IgnoreMinus1Duration) { +TEST(MP4Demuxer, IgnoreMinus1Duration) +{ RefPtr binding = new MP4DemuxerBinding("negative_duration.mp4"); binding->RunTestAndWait([binding]() { diff --git a/dom/media/gtest/TestMediaDataDecoder.cpp b/dom/media/gtest/TestMediaDataDecoder.cpp index 199d0f77626cb..f95adeefb7383 100644 --- a/dom/media/gtest/TestMediaDataDecoder.cpp +++ b/dom/media/gtest/TestMediaDataDecoder.cpp @@ -44,7 +44,8 @@ class BenchmarkRunner { RefPtr mBenchmark; }; -TEST(MediaDataDecoder, H264) { +TEST(MediaDataDecoder, H264) +{ if (!DecoderTraits::IsMP4SupportedType( MediaContainerType(MEDIAMIMETYPE(VIDEO_MP4)), /* DecoderDoctorDiagnostics* */ nullptr)) { @@ -59,7 +60,8 @@ TEST(MediaDataDecoder, H264) { } } -TEST(MediaDataDecoder, VP9) { +TEST(MediaDataDecoder, VP9) +{ if (!WebMDecoder::IsSupportedType( MediaContainerType(MEDIAMIMETYPE(VIDEO_WEBM)))) { EXPECT_TRUE(true); diff --git a/dom/media/gtest/TestMediaDataEncoder.cpp b/dom/media/gtest/TestMediaDataEncoder.cpp index 4fcf7e869f894..1d5e787ee9916 100644 --- a/dom/media/gtest/TestMediaDataEncoder.cpp +++ b/dom/media/gtest/TestMediaDataEncoder.cpp @@ -85,15 +85,16 @@ void WaitForShutdown(RefPtr aEncoder) { Maybe result; // media::Await() supports exclusive promises only, but ShutdownPromise is // not. - aEncoder->Shutdown()->Then(AbstractThread::MainThread(), __func__, - [&result](bool rv) { - EXPECT_TRUE(rv); - result = Some(true); - }, - [&result]() { - FAIL() << "Shutdown should never be rejected"; - result = Some(false); - }); + aEncoder->Shutdown()->Then( + AbstractThread::MainThread(), __func__, + [&result](bool rv) { + EXPECT_TRUE(rv); + result = Some(true); + }, + [&result]() { + FAIL() << "Shutdown should never be rejected"; + result = Some(false); + }); SpinEventLoopUntil([&result]() { return result; }); } @@ -115,12 +116,13 @@ static bool EnsureInit(RefPtr aEncoder) { } bool succeeded; - media::Await(GetMediaThreadPool(MediaThreadType::PLAYBACK), aEncoder->Init(), - [&succeeded](TrackInfo::TrackType t) { - EXPECT_EQ(TrackInfo::TrackType::kVideoTrack, t); - succeeded = true; - }, - [&succeeded](MediaResult r) { succeeded = false; }); + media::Await( + GetMediaThreadPool(MediaThreadType::PLAYBACK), aEncoder->Init(), + [&succeeded](TrackInfo::TrackType t) { + EXPECT_EQ(TrackInfo::TrackType::kVideoTrack, t); + succeeded = true; + }, + [&succeeded](MediaResult r) { succeeded = false; }); return succeeded; } @@ -149,13 +151,13 @@ static MediaDataEncoder::EncodedData Encode( kImageSize, 0, TimeUnit::FromMicroseconds(i * 30000), TimeUnit::FromMicroseconds(30000), img, (i & 0xF) == 0, TimeUnit::FromMicroseconds(i * 30000)); - media::Await(GetMediaThreadPool(MediaThreadType::PLAYBACK), - aEncoder->Encode(frame), - [&output, &succeeded](MediaDataEncoder::EncodedData encoded) { - output.AppendElements(std::move(encoded)); - succeeded = true; - }, - [&succeeded](MediaResult r) { succeeded = false; }); + media::Await( + GetMediaThreadPool(MediaThreadType::PLAYBACK), aEncoder->Encode(frame), + [&output, &succeeded](MediaDataEncoder::EncodedData encoded) { + output.AppendElements(std::move(encoded)); + succeeded = true; + }, + [&succeeded](MediaResult r) { succeeded = false; }); EXPECT_TRUE(succeeded); if (!succeeded) { return output; @@ -177,13 +179,13 @@ static MediaDataEncoder::EncodedData Encode( } if (pending > 0) { - media::Await(GetMediaThreadPool(MediaThreadType::PLAYBACK), - aEncoder->Drain(), - [&succeeded](MediaDataEncoder::EncodedData encoded) { - EXPECT_EQ(encoded.Length(), 0UL); - succeeded = true; - }, - [&succeeded](MediaResult r) { succeeded = false; }); + media::Await( + GetMediaThreadPool(MediaThreadType::PLAYBACK), aEncoder->Drain(), + [&succeeded](MediaDataEncoder::EncodedData encoded) { + EXPECT_EQ(encoded.Length(), 0UL); + succeeded = true; + }, + [&succeeded](MediaResult r) { succeeded = false; }); EXPECT_TRUE(succeeded); } diff --git a/dom/media/gtest/TestMediaEventSource.cpp b/dom/media/gtest/TestMediaEventSource.cpp index 607ed84e5d471..6d6e51fd47782 100644 --- a/dom/media/gtest/TestMediaEventSource.cpp +++ b/dom/media/gtest/TestMediaEventSource.cpp @@ -16,7 +16,8 @@ using namespace mozilla; /* * Test if listeners receive the event data correctly. */ -TEST(MediaEventSource, SingleListener) { +TEST(MediaEventSource, SingleListener) +{ RefPtr queue = new TaskQueue(GetMediaThreadPool(MediaThreadType::PLAYBACK)); @@ -39,7 +40,8 @@ TEST(MediaEventSource, SingleListener) { listener.Disconnect(); } -TEST(MediaEventSource, MultiListener) { +TEST(MediaEventSource, MultiListener) +{ RefPtr queue = new TaskQueue(GetMediaThreadPool(MediaThreadType::PLAYBACK)); @@ -69,7 +71,8 @@ TEST(MediaEventSource, MultiListener) { /* * Test if disconnecting a listener prevents events from coming. */ -TEST(MediaEventSource, DisconnectAfterNotification) { +TEST(MediaEventSource, DisconnectAfterNotification) +{ RefPtr queue = new TaskQueue(GetMediaThreadPool(MediaThreadType::PLAYBACK)); @@ -95,7 +98,8 @@ TEST(MediaEventSource, DisconnectAfterNotification) { EXPECT_EQ(i, 11); } -TEST(MediaEventSource, DisconnectBeforeNotification) { +TEST(MediaEventSource, DisconnectBeforeNotification) +{ RefPtr queue = new TaskQueue(GetMediaThreadPool(MediaThreadType::PLAYBACK)); @@ -126,7 +130,8 @@ TEST(MediaEventSource, DisconnectBeforeNotification) { * Test we don't hit the assertion when calling Connect() and Disconnect() * repeatedly. */ -TEST(MediaEventSource, DisconnectAndConnect) { +TEST(MediaEventSource, DisconnectAndConnect) +{ RefPtr queue; MediaEventProducerExc source; MediaEventListener listener = source.Connect(queue, []() {}); @@ -138,7 +143,8 @@ TEST(MediaEventSource, DisconnectAndConnect) { /* * Test void event type. */ -TEST(MediaEventSource, VoidEventType) { +TEST(MediaEventSource, VoidEventType) +{ RefPtr queue = new TaskQueue(GetMediaThreadPool(MediaThreadType::PLAYBACK)); @@ -174,7 +180,8 @@ TEST(MediaEventSource, VoidEventType) { /* * Test listeners can take various event types (T, T&&, const T& and void). */ -TEST(MediaEventSource, ListenerType1) { +TEST(MediaEventSource, ListenerType1) +{ RefPtr queue = new TaskQueue(GetMediaThreadPool(MediaThreadType::PLAYBACK)); @@ -201,7 +208,8 @@ TEST(MediaEventSource, ListenerType1) { listener3.Disconnect(); } -TEST(MediaEventSource, ListenerType2) { +TEST(MediaEventSource, ListenerType2) +{ RefPtr queue = new TaskQueue(GetMediaThreadPool(MediaThreadType::PLAYBACK)); @@ -250,7 +258,8 @@ struct SomeEvent { /* * Test we don't have unnecessary copies of the event data. */ -TEST(MediaEventSource, CopyEvent1) { +TEST(MediaEventSource, CopyEvent1) +{ RefPtr queue = new TaskQueue(GetMediaThreadPool(MediaThreadType::PLAYBACK)); @@ -276,7 +285,8 @@ TEST(MediaEventSource, CopyEvent1) { listener2.Disconnect(); } -TEST(MediaEventSource, CopyEvent2) { +TEST(MediaEventSource, CopyEvent2) +{ RefPtr queue = new TaskQueue(GetMediaThreadPool(MediaThreadType::PLAYBACK)); @@ -304,7 +314,8 @@ TEST(MediaEventSource, CopyEvent2) { /* * Test move-only types. */ -TEST(MediaEventSource, MoveOnly) { +TEST(MediaEventSource, MoveOnly) +{ RefPtr queue = new TaskQueue(GetMediaThreadPool(MediaThreadType::PLAYBACK)); @@ -337,7 +348,8 @@ struct RefCounter { * Test we should copy instead of move in NonExclusive mode * for each listener must get a copy. */ -TEST(MediaEventSource, NoMove) { +TEST(MediaEventSource, NoMove) +{ RefPtr queue = new TaskQueue(GetMediaThreadPool(MediaThreadType::PLAYBACK)); @@ -361,7 +373,8 @@ TEST(MediaEventSource, NoMove) { /* * Rvalue lambda should be moved instead of copied. */ -TEST(MediaEventSource, MoveLambda) { +TEST(MediaEventSource, MoveLambda) +{ RefPtr queue; MediaEventProducer source; diff --git a/dom/media/gtest/TestMediaMIMETypes.cpp b/dom/media/gtest/TestMediaMIMETypes.cpp index 33f38d38e2291..e41be22f317e4 100644 --- a/dom/media/gtest/TestMediaMIMETypes.cpp +++ b/dom/media/gtest/TestMediaMIMETypes.cpp @@ -9,7 +9,8 @@ using namespace mozilla; -TEST(MediaMIMETypes, DependentMIMEType) { +TEST(MediaMIMETypes, DependentMIMEType) +{ static const struct { const char* mString; DependentMediaMIMEType mDependentMediaMIMEType; @@ -27,7 +28,8 @@ TEST(MediaMIMETypes, DependentMIMEType) { } } -TEST(MediaMIMETypes, MakeMediaMIMEType_bad) { +TEST(MediaMIMETypes, MakeMediaMIMEType_bad) +{ static const char* tests[] = {"", " ", "/", "audio", "audio/", "mp4", "/mp4", "a/b"}; @@ -38,7 +40,8 @@ TEST(MediaMIMETypes, MakeMediaMIMEType_bad) { } } -TEST(MediaMIMETypes, MediaMIMEType) { +TEST(MediaMIMETypes, MediaMIMEType) +{ static const struct { const char* mTypeString; const char* mAsString; @@ -78,7 +81,8 @@ TEST(MediaMIMETypes, MediaMIMEType) { } } -TEST(MediaMIMETypes, MediaCodecs) { +TEST(MediaMIMETypes, MediaCodecs) +{ MediaCodecs empty(""); EXPECT_TRUE(empty.IsEmpty()); EXPECT_TRUE(empty.AsString().EqualsLiteral("")); @@ -152,7 +156,8 @@ TEST(MediaMIMETypes, MediaCodecs) { EXPECT_FALSE(one.ContainsAll(two)); } -TEST(MediaMIMETypes, MakeMediaExtendedMIMEType_bad) { +TEST(MediaMIMETypes, MakeMediaExtendedMIMEType_bad) +{ static const char* tests[] = {"", " ", "/", "audio", "audio/", "mp4", "/mp4", "a/b"}; @@ -163,7 +168,8 @@ TEST(MediaMIMETypes, MakeMediaExtendedMIMEType_bad) { } } -TEST(MediaMIMETypes, MediaExtendedMIMEType) { +TEST(MediaMIMETypes, MediaExtendedMIMEType) +{ // Some generic tests first. static const struct { const char* mTypeString; diff --git a/dom/media/gtest/TestOpusParser.cpp b/dom/media/gtest/TestOpusParser.cpp index c1817bddff663..7dc0303546c4e 100644 --- a/dom/media/gtest/TestOpusParser.cpp +++ b/dom/media/gtest/TestOpusParser.cpp @@ -7,7 +7,8 @@ #include "OpusParser.h" #include -TEST(OpusParser, Mapping2) { +TEST(OpusParser, Mapping2) +{ uint8_t validChannels[] = {1, 3, 4, 6, 9, 11, 16, 18, 25, 27, 36, 38, 49, 51, 64, 66, 81, 83, 100, 102, 121, 123, 144, 146, 169, 171, 196, 198, 225, 227}; diff --git a/dom/media/gtest/TestRust.cpp b/dom/media/gtest/TestRust.cpp index 86d0e99b86c48..059500767fd79 100644 --- a/dom/media/gtest/TestRust.cpp +++ b/dom/media/gtest/TestRust.cpp @@ -3,7 +3,8 @@ extern "C" uint8_t* test_rust(); -TEST(rust, CallFromCpp) { +TEST(rust, CallFromCpp) +{ auto greeting = test_rust(); EXPECT_STREQ(reinterpret_cast(greeting), "hello from rust."); } diff --git a/dom/media/gtest/TestTimeUnit.cpp b/dom/media/gtest/TestTimeUnit.cpp index a974a111993f5..605e0e90c9022 100644 --- a/dom/media/gtest/TestTimeUnit.cpp +++ b/dom/media/gtest/TestTimeUnit.cpp @@ -10,7 +10,8 @@ using namespace mozilla; -TEST(TimeUnit, Rounding) { +TEST(TimeUnit, Rounding) +{ int64_t usecs = 66261715; double seconds = media::TimeUnit::FromMicroseconds(usecs).ToSeconds(); EXPECT_EQ(media::TimeUnit::FromSeconds(seconds).ToMicroseconds(), usecs); diff --git a/dom/media/gtest/TestVPXDecoding.cpp b/dom/media/gtest/TestVPXDecoding.cpp index 2c7292cfab0b3..d58ca24cc7127 100644 --- a/dom/media/gtest/TestVPXDecoding.cpp +++ b/dom/media/gtest/TestVPXDecoding.cpp @@ -69,7 +69,8 @@ static const TestFileData testFiles[] = { {"test_case_1224363.vp8.ivf", VPX_CODEC_CORRUPT_FRAME}, {"test_case_1224369.vp8.ivf", VPX_CODEC_CORRUPT_FRAME}}; -TEST(libvpx, test_cases) { +TEST(libvpx, test_cases) +{ for (size_t test = 0; test < ArrayLength(testFiles); ++test) { nsTArray data; ReadVPXFile(testFiles[test].mFilename, data); diff --git a/dom/media/gtest/TestVideoSegment.cpp b/dom/media/gtest/TestVideoSegment.cpp index 8f8bb9c8dc557..4bc432d01b37a 100644 --- a/dom/media/gtest/TestVideoSegment.cpp +++ b/dom/media/gtest/TestVideoSegment.cpp @@ -13,7 +13,8 @@ class Image; } // namespace layer } // namespace mozilla -TEST(VideoSegment, TestAppendFrameForceBlack) { +TEST(VideoSegment, TestAppendFrameForceBlack) +{ RefPtr testImage = nullptr; VideoSegment segment; @@ -28,7 +29,8 @@ TEST(VideoSegment, TestAppendFrameForceBlack) { } } -TEST(VideoSegment, TestAppendFrameNotForceBlack) { +TEST(VideoSegment, TestAppendFrameNotForceBlack) +{ RefPtr testImage = nullptr; VideoSegment segment; diff --git a/dom/media/gtest/TestVideoTrackEncoder.cpp b/dom/media/gtest/TestVideoTrackEncoder.cpp index 757184beaf69a..f04110a023aaf 100644 --- a/dom/media/gtest/TestVideoTrackEncoder.cpp +++ b/dom/media/gtest/TestVideoTrackEncoder.cpp @@ -69,7 +69,8 @@ class TestVP8TrackEncoder : public VP8TrackEncoder { }; // Init test -TEST(VP8VideoTrackEncoder, Initialization) { +TEST(VP8VideoTrackEncoder, Initialization) +{ InitParam params[] = { // Failure cases. {false, 0, 0}, // Height/ width should be larger than 1. @@ -90,7 +91,8 @@ TEST(VP8VideoTrackEncoder, Initialization) { } // Get MetaData test -TEST(VP8VideoTrackEncoder, FetchMetaData) { +TEST(VP8VideoTrackEncoder, FetchMetaData) +{ InitParam params[] = { // Success cases {true, 640, 480}, // Standard VGA @@ -113,7 +115,8 @@ TEST(VP8VideoTrackEncoder, FetchMetaData) { } // Encode test -TEST(VP8VideoTrackEncoder, FrameEncode) { +TEST(VP8VideoTrackEncoder, FrameEncode) +{ TestVP8TrackEncoder encoder; TimeStamp now = TimeStamp::Now(); @@ -145,7 +148,8 @@ TEST(VP8VideoTrackEncoder, FrameEncode) { } // Test that encoding a single frame gives useful output. -TEST(VP8VideoTrackEncoder, SingleFrameEncode) { +TEST(VP8VideoTrackEncoder, SingleFrameEncode) +{ TestVP8TrackEncoder encoder; TimeStamp now = TimeStamp::Now(); YUVBufferGenerator generator; @@ -179,7 +183,8 @@ TEST(VP8VideoTrackEncoder, SingleFrameEncode) { } // Test that encoding a couple of identical images gives useful output. -TEST(VP8VideoTrackEncoder, SameFrameEncode) { +TEST(VP8VideoTrackEncoder, SameFrameEncode) +{ TestVP8TrackEncoder encoder; TimeStamp now = TimeStamp::Now(); YUVBufferGenerator generator; @@ -214,7 +219,8 @@ TEST(VP8VideoTrackEncoder, SameFrameEncode) { } // Test encoding a track that has to skip frames. -TEST(VP8VideoTrackEncoder, SkippedFrames) { +TEST(VP8VideoTrackEncoder, SkippedFrames) +{ TestVP8TrackEncoder encoder; YUVBufferGenerator generator; generator.Init(mozilla::gfx::IntSize(640, 480)); @@ -249,7 +255,8 @@ TEST(VP8VideoTrackEncoder, SkippedFrames) { } // Test encoding a track with frames subject to rounding errors. -TEST(VP8VideoTrackEncoder, RoundingErrorFramesEncode) { +TEST(VP8VideoTrackEncoder, RoundingErrorFramesEncode) +{ TestVP8TrackEncoder encoder; YUVBufferGenerator generator; generator.Init(mozilla::gfx::IntSize(640, 480)); @@ -290,7 +297,8 @@ TEST(VP8VideoTrackEncoder, RoundingErrorFramesEncode) { } // Test that we're encoding timestamps rather than durations. -TEST(VP8VideoTrackEncoder, TimestampFrameEncode) { +TEST(VP8VideoTrackEncoder, TimestampFrameEncode) +{ TestVP8TrackEncoder encoder; YUVBufferGenerator generator; generator.Init(mozilla::gfx::IntSize(640, 480)); @@ -332,7 +340,8 @@ TEST(VP8VideoTrackEncoder, TimestampFrameEncode) { } // Test that we're compensating for drift when encoding. -TEST(VP8VideoTrackEncoder, DriftingFrameEncode) { +TEST(VP8VideoTrackEncoder, DriftingFrameEncode) +{ TestVP8TrackEncoder encoder; YUVBufferGenerator generator; generator.Init(mozilla::gfx::IntSize(640, 480)); @@ -380,7 +389,8 @@ TEST(VP8VideoTrackEncoder, DriftingFrameEncode) { } // Test that suspending an encoding works. -TEST(VP8VideoTrackEncoder, Suspended) { +TEST(VP8VideoTrackEncoder, Suspended) +{ TestVP8TrackEncoder encoder; TimeStamp now = TimeStamp::Now(); YUVBufferGenerator generator; @@ -441,7 +451,8 @@ TEST(VP8VideoTrackEncoder, Suspended) { } // Test that ending a track while the video track encoder is suspended works. -TEST(VP8VideoTrackEncoder, SuspendedUntilEnd) { +TEST(VP8VideoTrackEncoder, SuspendedUntilEnd) +{ TestVP8TrackEncoder encoder; YUVBufferGenerator generator; generator.Init(mozilla::gfx::IntSize(640, 480)); @@ -490,7 +501,8 @@ TEST(VP8VideoTrackEncoder, SuspendedUntilEnd) { } // Test that ending a track that was always suspended works. -TEST(VP8VideoTrackEncoder, AlwaysSuspended) { +TEST(VP8VideoTrackEncoder, AlwaysSuspended) +{ TestVP8TrackEncoder encoder; YUVBufferGenerator generator; generator.Init(mozilla::gfx::IntSize(640, 480)); @@ -521,7 +533,8 @@ TEST(VP8VideoTrackEncoder, AlwaysSuspended) { } // Test that encoding a track that is suspended in the beginning works. -TEST(VP8VideoTrackEncoder, SuspendedBeginning) { +TEST(VP8VideoTrackEncoder, SuspendedBeginning) +{ TestVP8TrackEncoder encoder; YUVBufferGenerator generator; generator.Init(mozilla::gfx::IntSize(640, 480)); @@ -572,7 +585,8 @@ TEST(VP8VideoTrackEncoder, SuspendedBeginning) { // Test that suspending and resuming in the middle of already pushed data // works. -TEST(VP8VideoTrackEncoder, SuspendedOverlap) { +TEST(VP8VideoTrackEncoder, SuspendedOverlap) +{ TestVP8TrackEncoder encoder; YUVBufferGenerator generator; generator.Init(mozilla::gfx::IntSize(640, 480)); @@ -620,7 +634,8 @@ TEST(VP8VideoTrackEncoder, SuspendedOverlap) { } // Test that ending a track in the middle of already pushed data works. -TEST(VP8VideoTrackEncoder, PrematureEnding) { +TEST(VP8VideoTrackEncoder, PrematureEnding) +{ TestVP8TrackEncoder encoder; YUVBufferGenerator generator; generator.Init(mozilla::gfx::IntSize(640, 480)); @@ -650,7 +665,8 @@ TEST(VP8VideoTrackEncoder, PrematureEnding) { } // Test that a track that starts at t > 0 works as expected. -TEST(VP8VideoTrackEncoder, DelayedStart) { +TEST(VP8VideoTrackEncoder, DelayedStart) +{ TestVP8TrackEncoder encoder; YUVBufferGenerator generator; generator.Init(mozilla::gfx::IntSize(640, 480)); @@ -682,7 +698,8 @@ TEST(VP8VideoTrackEncoder, DelayedStart) { // Test that a track that starts at t > 0 works as expected, when // SetStartOffset comes after AppendVideoSegment. -TEST(VP8VideoTrackEncoder, DelayedStartOtherEventOrder) { +TEST(VP8VideoTrackEncoder, DelayedStartOtherEventOrder) +{ TestVP8TrackEncoder encoder; YUVBufferGenerator generator; generator.Init(mozilla::gfx::IntSize(640, 480)); @@ -713,7 +730,8 @@ TEST(VP8VideoTrackEncoder, DelayedStartOtherEventOrder) { } // Test that a track that starts at t >>> 0 works as expected. -TEST(VP8VideoTrackEncoder, VeryDelayedStart) { +TEST(VP8VideoTrackEncoder, VeryDelayedStart) +{ TestVP8TrackEncoder encoder; YUVBufferGenerator generator; generator.Init(mozilla::gfx::IntSize(640, 480)); @@ -745,7 +763,8 @@ TEST(VP8VideoTrackEncoder, VeryDelayedStart) { // Test that a video frame that hangs around for a long time gets encoded every // second. -TEST(VP8VideoTrackEncoder, LongFramesReEncoded) { +TEST(VP8VideoTrackEncoder, LongFramesReEncoded) +{ TestVP8TrackEncoder encoder; YUVBufferGenerator generator; generator.Init(mozilla::gfx::IntSize(640, 480)); @@ -799,7 +818,8 @@ TEST(VP8VideoTrackEncoder, LongFramesReEncoded) { // Test that an encoding with a defined key frame interval encodes keyframes // as expected. Short here means shorter than the default (1s). -TEST(VP8VideoTrackEncoder, ShortKeyFrameInterval) { +TEST(VP8VideoTrackEncoder, ShortKeyFrameInterval) +{ TestVP8TrackEncoder encoder; YUVBufferGenerator generator; generator.Init(mozilla::gfx::IntSize(640, 480)); @@ -868,7 +888,8 @@ TEST(VP8VideoTrackEncoder, ShortKeyFrameInterval) { // Test that an encoding with a defined key frame interval encodes keyframes // as expected. Long here means longer than the default (1s). -TEST(VP8VideoTrackEncoder, LongKeyFrameInterval) { +TEST(VP8VideoTrackEncoder, LongKeyFrameInterval) +{ TestVP8TrackEncoder encoder; YUVBufferGenerator generator; generator.Init(mozilla::gfx::IntSize(640, 480)); @@ -937,7 +958,8 @@ TEST(VP8VideoTrackEncoder, LongKeyFrameInterval) { // Test that an encoding with no defined key frame interval encodes keyframes // as expected. Default interval should be 1000ms. -TEST(VP8VideoTrackEncoder, DefaultKeyFrameInterval) { +TEST(VP8VideoTrackEncoder, DefaultKeyFrameInterval) +{ TestVP8TrackEncoder encoder; YUVBufferGenerator generator; generator.Init(mozilla::gfx::IntSize(640, 480)); @@ -1004,7 +1026,8 @@ TEST(VP8VideoTrackEncoder, DefaultKeyFrameInterval) { // Test that an encoding where the key frame interval is updated dynamically // encodes keyframes as expected. -TEST(VP8VideoTrackEncoder, DynamicKeyFrameIntervalChanges) { +TEST(VP8VideoTrackEncoder, DynamicKeyFrameIntervalChanges) +{ TestVP8TrackEncoder encoder; YUVBufferGenerator generator; generator.Init(mozilla::gfx::IntSize(640, 480)); @@ -1173,7 +1196,8 @@ TEST(VP8VideoTrackEncoder, DynamicKeyFrameIntervalChanges) { // Test that an encoding which is disabled on a frame timestamp encodes // frames as expected. -TEST(VP8VideoTrackEncoder, DisableOnFrameTime) { +TEST(VP8VideoTrackEncoder, DisableOnFrameTime) +{ TestVP8TrackEncoder encoder; YUVBufferGenerator generator; generator.Init(mozilla::gfx::IntSize(640, 480)); @@ -1217,7 +1241,8 @@ TEST(VP8VideoTrackEncoder, DisableOnFrameTime) { // Test that an encoding which is disabled between two frame timestamps encodes // frames as expected. -TEST(VP8VideoTrackEncoder, DisableBetweenFrames) { +TEST(VP8VideoTrackEncoder, DisableBetweenFrames) +{ TestVP8TrackEncoder encoder; YUVBufferGenerator generator; generator.Init(mozilla::gfx::IntSize(640, 480)); @@ -1261,7 +1286,8 @@ TEST(VP8VideoTrackEncoder, DisableBetweenFrames) { // Test that an encoding which is enabled on a frame timestamp encodes // frames as expected. -TEST(VP8VideoTrackEncoder, EnableOnFrameTime) { +TEST(VP8VideoTrackEncoder, EnableOnFrameTime) +{ TestVP8TrackEncoder encoder; YUVBufferGenerator generator; generator.Init(mozilla::gfx::IntSize(640, 480)); @@ -1307,7 +1333,8 @@ TEST(VP8VideoTrackEncoder, EnableOnFrameTime) { // Test that an encoding which is enabled between two frame timestamps encodes // frames as expected. -TEST(VP8VideoTrackEncoder, EnableBetweenFrames) { +TEST(VP8VideoTrackEncoder, EnableBetweenFrames) +{ TestVP8TrackEncoder encoder; YUVBufferGenerator generator; generator.Init(mozilla::gfx::IntSize(640, 480)); @@ -1352,7 +1379,8 @@ TEST(VP8VideoTrackEncoder, EnableBetweenFrames) { } // Test that making time go backwards removes any future frames in the encoder. -TEST(VP8VideoTrackEncoder, BackwardsTimeResets) { +TEST(VP8VideoTrackEncoder, BackwardsTimeResets) +{ TestVP8TrackEncoder encoder; YUVBufferGenerator generator; generator.Init(mozilla::gfx::IntSize(640, 480)); @@ -1424,7 +1452,8 @@ TEST(VP8VideoTrackEncoder, BackwardsTimeResets) { // Test that trying to encode a null image removes any future frames in the // encoder. -TEST(VP8VideoTrackEncoder, NullImageResets) { +TEST(VP8VideoTrackEncoder, NullImageResets) +{ TestVP8TrackEncoder encoder; YUVBufferGenerator generator; generator.Init(mozilla::gfx::IntSize(640, 480)); @@ -1492,7 +1521,8 @@ TEST(VP8VideoTrackEncoder, NullImageResets) { } // EOS test -TEST(VP8VideoTrackEncoder, EncodeComplete) { +TEST(VP8VideoTrackEncoder, EncodeComplete) +{ TestVP8TrackEncoder encoder; // track end notification. diff --git a/dom/media/gtest/TestVideoUtils.cpp b/dom/media/gtest/TestVideoUtils.cpp index f424e44071085..d322d15d64416 100644 --- a/dom/media/gtest/TestVideoUtils.cpp +++ b/dom/media/gtest/TestVideoUtils.cpp @@ -10,7 +10,8 @@ using namespace mozilla; -TEST(MediaMIMETypes, IsMediaMIMEType) { +TEST(MediaMIMETypes, IsMediaMIMEType) +{ EXPECT_TRUE(IsMediaMIMEType(AUDIO_MP4)); EXPECT_TRUE(IsMediaMIMEType(VIDEO_MP4)); EXPECT_TRUE(IsMediaMIMEType("application/x-mp4")); @@ -25,7 +26,8 @@ TEST(MediaMIMETypes, IsMediaMIMEType) { EXPECT_FALSE(IsMediaMIMEType("Video/mp4")); } -TEST(StringListRange, MakeStringListRange) { +TEST(StringListRange, MakeStringListRange) +{ static const struct { const char* mList; const char* mExpectedSkipEmpties; @@ -75,7 +77,8 @@ TEST(StringListRange, MakeStringListRange) { } } -TEST(StringListRange, StringListContains) { +TEST(StringListRange, StringListContains) +{ static const struct { const char* mList; const char* mItemToSearch; diff --git a/dom/media/gtest/TestWebMBuffered.cpp b/dom/media/gtest/TestWebMBuffered.cpp index 31bbf1ebc5f25..14f5ae2b25914 100644 --- a/dom/media/gtest/TestWebMBuffered.cpp +++ b/dom/media/gtest/TestWebMBuffered.cpp @@ -19,7 +19,8 @@ static const uint64_t gTimecodes[] = {66000000, 160000000, 166000000, 200000000, 233000000, 320000000}; static const int64_t gEndOffsets[] = {501, 772, 1244, 1380, 1543, 2015}; -TEST(WebMBuffered, BasicTests) { +TEST(WebMBuffered, BasicTests) +{ ReentrantMonitor dummy("dummy"); WebMBufferedParser parser(0); @@ -57,7 +58,8 @@ static void ReadFile(const char* aPath, nsTArray& aBuffer) { ASSERT_EQ(r, 0); } -TEST(WebMBuffered, RealData) { +TEST(WebMBuffered, RealData) +{ ReentrantMonitor dummy("dummy"); WebMBufferedParser parser(0); @@ -78,7 +80,8 @@ TEST(WebMBuffered, RealData) { } } -TEST(WebMBuffered, RealDataAppend) { +TEST(WebMBuffered, RealDataAppend) +{ ReentrantMonitor dummy("dummy"); WebMBufferedParser parser(0); nsTArray mapping; diff --git a/dom/media/gtest/TestWebMWriter.cpp b/dom/media/gtest/TestWebMWriter.cpp index 14bd2750c3437..114311022cd06 100644 --- a/dom/media/gtest/TestWebMWriter.cpp +++ b/dom/media/gtest/TestWebMWriter.cpp @@ -94,7 +94,8 @@ class TestWebMWriter : public WebMWriter { uint64_t mTimestamp; }; -TEST(WebMWriter, Metadata) { +TEST(WebMWriter, Metadata) +{ TestWebMWriter writer(ContainerWriter::CREATE_AUDIO_TRACK | ContainerWriter::CREATE_VIDEO_TRACK); @@ -129,7 +130,8 @@ TEST(WebMWriter, Metadata) { EXPECT_TRUE(encodedBuf.Length() > 0); } -TEST(WebMWriter, Cluster) { +TEST(WebMWriter, Cluster) +{ TestWebMWriter writer(ContainerWriter::CREATE_AUDIO_TRACK | ContainerWriter::CREATE_VIDEO_TRACK); // Set opus metadata. @@ -170,7 +172,8 @@ TEST(WebMWriter, Cluster) { EXPECT_TRUE(writer.HaveValidCluster()); } -TEST(WebMWriter, FLUSH_NEEDED) { +TEST(WebMWriter, FLUSH_NEEDED) +{ TestWebMWriter writer(ContainerWriter::CREATE_AUDIO_TRACK | ContainerWriter::CREATE_VIDEO_TRACK); // Set opus metadata. @@ -289,7 +292,8 @@ static int64_t webm_tell(void* aUserData) { return ioData->offset.isValid() ? ioData->offset.value() : -1; } -TEST(WebMWriter, bug970774_aspect_ratio) { +TEST(WebMWriter, bug970774_aspect_ratio) +{ TestWebMWriter writer(ContainerWriter::CREATE_AUDIO_TRACK | ContainerWriter::CREATE_VIDEO_TRACK); // Set opus metadata. diff --git a/dom/media/gtest/mp4_demuxer/TestInterval.cpp b/dom/media/gtest/mp4_demuxer/TestInterval.cpp index 824c94f692ba8..2572b1c392f77 100644 --- a/dom/media/gtest/mp4_demuxer/TestInterval.cpp +++ b/dom/media/gtest/mp4_demuxer/TestInterval.cpp @@ -8,12 +8,14 @@ using mozilla::MP4Interval; -TEST(MP4Interval, Length) { +TEST(MP4Interval, Length) +{ MP4Interval i(15, 25); EXPECT_EQ(10, i.Length()); } -TEST(MP4Interval, Intersection) { +TEST(MP4Interval, Intersection) +{ MP4Interval i0(10, 20); MP4Interval i1(15, 25); MP4Interval i = i0.Intersection(i1); @@ -21,7 +23,8 @@ TEST(MP4Interval, Intersection) { EXPECT_EQ(20, i.end); } -TEST(MP4Interval, Equals) { +TEST(MP4Interval, Equals) +{ MP4Interval i0(10, 20); MP4Interval i1(10, 20); EXPECT_EQ(i0, i1); @@ -33,7 +36,8 @@ TEST(MP4Interval, Equals) { EXPECT_NE(i0, i2); } -TEST(MP4Interval, IntersectionVector) { +TEST(MP4Interval, IntersectionVector) +{ nsTArray> i0; i0.AppendElement(MP4Interval(5, 10)); i0.AppendElement(MP4Interval(20, 25)); @@ -63,7 +67,8 @@ TEST(MP4Interval, IntersectionVector) { EXPECT_EQ(57, i[3].end); } -TEST(MP4Interval, Normalize) { +TEST(MP4Interval, Normalize) +{ nsTArray> i; i.AppendElement(MP4Interval(20, 30)); i.AppendElement(MP4Interval(1, 8)); diff --git a/dom/media/gtest/mp4_demuxer/TestMP4.cpp b/dom/media/gtest/mp4_demuxer/TestMP4.cpp index c8b7549718911..c36bc02c5fc7b 100644 --- a/dom/media/gtest/mp4_demuxer/TestMP4.cpp +++ b/dom/media/gtest/mp4_demuxer/TestMP4.cpp @@ -51,7 +51,8 @@ static intptr_t vector_reader(uint8_t* buffer, uintptr_t size, void* userdata) { return length; } -TEST(rust, MP4MetadataEmpty) { +TEST(rust, MP4MetadataEmpty) +{ Mp4parseStatus rv; Mp4parseIo io; @@ -105,7 +106,8 @@ TEST(rust, MP4MetadataEmpty) { mp4parse_free(context); } -TEST(rust, MP4Metadata) { +TEST(rust, MP4Metadata) +{ FILE* f = fopen("street.mp4", "rb"); ASSERT_TRUE(f != nullptr); // Read just the moov header to work around the parser diff --git a/dom/media/gtest/mp4_demuxer/TestParser.cpp b/dom/media/gtest/mp4_demuxer/TestParser.cpp index 5ef1ef15061a0..0e9d14f48912d 100644 --- a/dom/media/gtest/mp4_demuxer/TestParser.cpp +++ b/dom/media/gtest/mp4_demuxer/TestParser.cpp @@ -68,7 +68,8 @@ class TestStream : public ByteStream, size_t mSize; }; -TEST(MP4Metadata, EmptyStream) { +TEST(MP4Metadata, EmptyStream) +{ RefPtr stream = new TestStream(nullptr, 0); MP4Metadata::ResultAndByteBuffer metadataBuffer = @@ -94,7 +95,8 @@ TEST(MP4Metadata, EmptyStream) { EXPECT_FALSE(metadata.Crypto().Ref()->valid); } -TEST(MoofParser, EmptyStream) { +TEST(MoofParser, EmptyStream) +{ RefPtr stream = new TestStream(nullptr, 0); MoofParser parser(stream, AsVariant(ParseAllTracks{}), false); @@ -248,7 +250,8 @@ static const TestFileData testFiles[] = { 300, 1, 10032000, false, 0, true, true, 2}, // Uses bad track id 0 }; -TEST(MP4Metadata, test_case_mp4) { +TEST(MP4Metadata, test_case_mp4) +{ const TestFileData* tests = nullptr; size_t length = 0; @@ -403,7 +406,8 @@ TEST(MP4Metadata, test_case_mp4_subsets) { } #endif -TEST(MoofParser, test_case_mp4) { +TEST(MoofParser, test_case_mp4) +{ const TestFileData* tests = nullptr; size_t length = 0; @@ -448,7 +452,8 @@ TEST(MoofParser, test_case_mp4) { } } -TEST(MoofParser, test_case_sample_description_entries) { +TEST(MoofParser, test_case_sample_description_entries) +{ const TestFileData* tests = testFiles; size_t length = ArrayLength(testFiles); @@ -495,7 +500,8 @@ TEST(MoofParser, test_case_sample_description_entries) { // used id 0 to trigger special handling in the MoofParser to read multiple // track metadata, but since muxers use track id 0 in the wild, we want to // make sure they can't accidentally trigger such handling. -TEST(MoofParser, test_case_track_id_0_does_not_read_multitracks) { +TEST(MoofParser, test_case_track_id_0_does_not_read_multitracks) +{ const char* zeroTrackIdFileName = "test_case_1519617-video-has-track_id-0.mp4"; nsTArray buffer = ReadTestFile(zeroTrackIdFileName); @@ -550,7 +556,8 @@ TEST(MoofParser, test_case_track_id_0_does_not_read_multitracks) { // if its crypto member is valid. However, even on files where the pssh isn't // in the init segment, the MoofParser should still read the sinf, as in this // testcase. -TEST(MoofParser, test_case_track_id_0_reads_crypto_metadata) { +TEST(MoofParser, test_case_track_id_0_reads_crypto_metadata) +{ const char* zeroTrackIdFileName = "test_case_1519617-cenc-init-with-track_id-0.mp4"; nsTArray buffer = ReadTestFile(zeroTrackIdFileName); @@ -607,7 +614,8 @@ TEST(MoofParser, test_case_track_id_0_reads_crypto_metadata) { // should parse such fragmented media. In this test the metadata contains info // for track ids 1 and 2, but track 2's track fragment headers (traf) have been // over written with free space boxes (free). -TEST(MoofParser, test_case_moofs_missing_trafs) { +TEST(MoofParser, test_case_moofs_missing_trafs) +{ const char* noTrafsForTrack2MoofsFileName = "test_case_1519617-track2-trafs-removed.mp4"; nsTArray buffer = ReadTestFile(noTrafsForTrack2MoofsFileName); @@ -750,7 +758,8 @@ uint8_t media_gtest_video_init_mp4[] = { const uint32_t media_gtest_video_init_mp4_len = 745; -TEST(MP4Metadata, EmptyCTTS) { +TEST(MP4Metadata, EmptyCTTS) +{ RefPtr buffer = new MediaByteBuffer(media_gtest_video_init_mp4_len); buffer->AppendElements(media_gtest_video_init_mp4, @@ -845,7 +854,7 @@ TEST_F(MP4MetadataTelemetryFixture, Telemetry) { "MEDIA_MP4_PARSE_SAMPLE_DESCRIPTION_ENTRIES_HAVE_MULTIPLE_CODECS", snapshot, &multipleCodecsHistogram); ASSERT_TRUE(multipleCodecsHistogram.isObject()) - << "Multiple codecs histogram should exist!"; + << "Multiple codecs histogram should exist!"; TelemetryTestHelpers::GetProperty(cx.GetJSContext(), "values", multipleCodecsHistogram, &values); @@ -870,7 +879,7 @@ TEST_F(MP4MetadataTelemetryFixture, Telemetry) { "MEDIA_MP4_PARSE_SAMPLE_DESCRIPTION_ENTRIES_HAVE_MULTIPLE_CRYPTO", snapshot, &multipleCryptoHistogram); ASSERT_TRUE(multipleCryptoHistogram.isObject()) - << "Multiple crypto histogram should exist!"; + << "Multiple crypto histogram should exist!"; TelemetryTestHelpers::GetProperty(cx.GetJSContext(), "values", multipleCryptoHistogram, &values); @@ -893,7 +902,7 @@ TEST_F(MP4MetadataTelemetryFixture, Telemetry) { cx.GetJSContext(), "MEDIA_MP4_PARSE_NUM_SAMPLE_DESCRIPTION_ENTRIES", snapshot, &numSamplesHistogram); ASSERT_TRUE(numSamplesHistogram.isObject()) - << "Num sample description entries histogram should exist!"; + << "Num sample description entries histogram should exist!"; TelemetryTestHelpers::GetProperty(cx.GetJSContext(), "values", numSamplesHistogram, &values); diff --git a/dom/media/ipc/RemoteDecoderParent.cpp b/dom/media/ipc/RemoteDecoderParent.cpp index 73bec38e06845..d58bd27180325 100644 --- a/dom/media/ipc/RemoteDecoderParent.cpp +++ b/dom/media/ipc/RemoteDecoderParent.cpp @@ -41,21 +41,22 @@ void RemoteDecoderParent::Destroy() { mozilla::ipc::IPCResult RemoteDecoderParent::RecvInit() { MOZ_ASSERT(OnManagerThread()); RefPtr self = this; - mDecoder->Init()->Then(mManagerTaskQueue, __func__, - [self](TrackInfo::TrackType aTrack) { - MOZ_ASSERT(aTrack == TrackInfo::kAudioTrack || - aTrack == TrackInfo::kVideoTrack); - if (self->mDecoder) { - Unused << self->SendInitComplete( - aTrack, self->mDecoder->GetDescriptionName(), - self->mDecoder->NeedsConversion()); - } - }, - [self](MediaResult aReason) { - if (!self->mDestroyed) { - Unused << self->SendInitFailed(aReason); - } - }); + mDecoder->Init()->Then( + mManagerTaskQueue, __func__, + [self](TrackInfo::TrackType aTrack) { + MOZ_ASSERT(aTrack == TrackInfo::kAudioTrack || + aTrack == TrackInfo::kVideoTrack); + if (self->mDecoder) { + Unused << self->SendInitComplete(aTrack, + self->mDecoder->GetDescriptionName(), + self->mDecoder->NeedsConversion()); + } + }, + [self](MediaResult aReason) { + if (!self->mDestroyed) { + Unused << self->SendInitFailed(aReason); + } + }); return IPC_OK(); } diff --git a/dom/media/ipc/RemoteMediaDataDecoder.cpp b/dom/media/ipc/RemoteMediaDataDecoder.cpp index 08b91db7c7c07..42ee59822f9c4 100644 --- a/dom/media/ipc/RemoteMediaDataDecoder.cpp +++ b/dom/media/ipc/RemoteMediaDataDecoder.cpp @@ -44,18 +44,19 @@ RefPtr RemoteMediaDataDecoder::Init() { RefPtr self = this; return InvokeAsync(mAbstractManagerThread, __func__, [self]() { return self->mChild->Init(); }) - ->Then(mAbstractManagerThread, __func__, - [self, this](TrackType aTrack) { - mDescription = mChild->GetDescriptionName() + - NS_LITERAL_CSTRING(" (remote)"); - mIsHardwareAccelerated = - mChild->IsHardwareAccelerated(mHardwareAcceleratedReason); - mConversion = mChild->NeedsConversion(); - return InitPromise::CreateAndResolve(aTrack, __func__); - }, - [self](const MediaResult& aError) { - return InitPromise::CreateAndReject(aError, __func__); - }); + ->Then( + mAbstractManagerThread, __func__, + [self, this](TrackType aTrack) { + mDescription = + mChild->GetDescriptionName() + NS_LITERAL_CSTRING(" (remote)"); + mIsHardwareAccelerated = + mChild->IsHardwareAccelerated(mHardwareAcceleratedReason); + mConversion = mChild->NeedsConversion(); + return InitPromise::CreateAndResolve(aTrack, __func__); + }, + [self](const MediaResult& aError) { + return InitPromise::CreateAndReject(aError, __func__); + }); } RefPtr RemoteMediaDataDecoder::Decode( diff --git a/dom/media/mediasink/VideoSink.cpp b/dom/media/mediasink/VideoSink.cpp index 6cc149bcb2dea..9753ae7a49ec7 100644 --- a/dom/media/mediasink/VideoSink.cpp +++ b/dom/media/mediasink/VideoSink.cpp @@ -262,21 +262,22 @@ nsresult VideoSink::Start(const TimeUnit& aStartTime, const MediaInfo& aInfo) { RefPtr p = mAudioSink->OnEnded(TrackInfo::kVideoTrack); if (p) { RefPtr self = this; - p->Then(mOwnerThread, __func__, - [self]() { - self->mVideoSinkEndRequest.Complete(); - self->TryUpdateRenderedVideoFrames(); - // It is possible the video queue size is 0 and we have no - // frames to render. However, we need to call - // MaybeResolveEndPromise() to ensure mEndPromiseHolder is - // resolved. - self->MaybeResolveEndPromise(); - }, - [self]() { - self->mVideoSinkEndRequest.Complete(); - self->TryUpdateRenderedVideoFrames(); - self->MaybeResolveEndPromise(); - }) + p->Then( + mOwnerThread, __func__, + [self]() { + self->mVideoSinkEndRequest.Complete(); + self->TryUpdateRenderedVideoFrames(); + // It is possible the video queue size is 0 and we have no + // frames to render. However, we need to call + // MaybeResolveEndPromise() to ensure mEndPromiseHolder is + // resolved. + self->MaybeResolveEndPromise(); + }, + [self]() { + self->mVideoSinkEndRequest.Complete(); + self->TryUpdateRenderedVideoFrames(); + self->MaybeResolveEndPromise(); + }) ->Track(mVideoSinkEndRequest); } diff --git a/dom/media/mediasource/SourceBuffer.cpp b/dom/media/mediasource/SourceBuffer.cpp index 9d11d2bed8044..29ad2b5b502c8 100644 --- a/dom/media/mediasource/SourceBuffer.cpp +++ b/dom/media/mediasource/SourceBuffer.cpp @@ -328,12 +328,13 @@ void SourceBuffer::RangeRemoval(double aStart, double aEnd) { RefPtr self = this; mTrackBuffersManager ->RangeRemoval(TimeUnit::FromSeconds(aStart), TimeUnit::FromSeconds(aEnd)) - ->Then(mAbstractMainThread, __func__, - [self](bool) { - self->mPendingRemoval.Complete(); - self->StopUpdating(); - }, - []() { MOZ_ASSERT(false); }) + ->Then( + mAbstractMainThread, __func__, + [self](bool) { + self->mPendingRemoval.Complete(); + self->StopUpdating(); + }, + []() { MOZ_ASSERT(false); }) ->Track(mPendingRemoval); } diff --git a/dom/media/mediasource/TrackBuffersManager.cpp b/dom/media/mediasource/TrackBuffersManager.cpp index b9b049a9f2c17..9e43af7269e0c 100644 --- a/dom/media/mediasource/TrackBuffersManager.cpp +++ b/dom/media/mediasource/TrackBuffersManager.cpp @@ -811,19 +811,20 @@ void TrackBuffersManager::SegmentParserLoop() { // run the coded frame processing algorithm. RefPtr self = this; CodedFrameProcessing() - ->Then(TaskQueueFromTaskQueue(), __func__, - [self](bool aNeedMoreData) { - self->mProcessingRequest.Complete(); - if (aNeedMoreData) { - self->NeedMoreData(); - } else { - self->ScheduleSegmentParserLoop(); - } - }, - [self](const MediaResult& aRejectValue) { - self->mProcessingRequest.Complete(); - self->RejectAppend(aRejectValue, __func__); - }) + ->Then( + TaskQueueFromTaskQueue(), __func__, + [self](bool aNeedMoreData) { + self->mProcessingRequest.Complete(); + if (aNeedMoreData) { + self->NeedMoreData(); + } else { + self->ScheduleSegmentParserLoop(); + } + }, + [self](const MediaResult& aRejectValue) { + self->mProcessingRequest.Complete(); + self->RejectAppend(aRejectValue, __func__); + }) ->Track(mProcessingRequest); return; } diff --git a/dom/media/mediasource/gtest/TestContainerParser.cpp b/dom/media/mediasource/gtest/TestContainerParser.cpp index b4cde79ded052..1e007ce0ee22c 100644 --- a/dom/media/mediasource/gtest/TestContainerParser.cpp +++ b/dom/media/mediasource/gtest/TestContainerParser.cpp @@ -12,7 +12,8 @@ using namespace mozilla; -TEST(ContainerParser, MIMETypes) { +TEST(ContainerParser, MIMETypes) +{ const char* containerTypes[] = {"video/webm", "audio/webm", "video/mp4", "audio/mp4", "audio/aac"}; nsAutoPtr parser; @@ -32,7 +33,8 @@ already_AddRefed make_adts_header() { return buffer.forget(); } -TEST(ContainerParser, ADTSHeader) { +TEST(ContainerParser, ADTSHeader) +{ nsAutoPtr parser; parser = ContainerParser::CreateForMIMEType( MediaContainerType(MEDIAMIMETYPE("audio/aac"))); @@ -97,7 +99,8 @@ TEST(ContainerParser, ADTSHeader) { EXPECT_EQ(parser->MediaSegmentRange(), MediaByteRange()); } -TEST(ContainerParser, ADTSBlankMedia) { +TEST(ContainerParser, ADTSBlankMedia) +{ nsAutoPtr parser; parser = ContainerParser::CreateForMIMEType( MediaContainerType(MEDIAMIMETYPE("audio/aac"))); diff --git a/dom/media/mediasource/gtest/TestExtractVPXCodecDetails.cpp b/dom/media/mediasource/gtest/TestExtractVPXCodecDetails.cpp index 27bece99d9a26..b46a6cc57fcb0 100644 --- a/dom/media/mediasource/gtest/TestExtractVPXCodecDetails.cpp +++ b/dom/media/mediasource/gtest/TestExtractVPXCodecDetails.cpp @@ -15,7 +15,8 @@ struct TestData { const bool mExpectedValue; }; -TEST(ExtractVPXCodecDetails, TestDataLength) { +TEST(ExtractVPXCodecDetails, TestDataLength) +{ TestData tests[] = { {u"vp09.00.11.08", true}, // valid case {u"vp09.00.11.08.00", true}, // valid case, have extra optional field @@ -38,7 +39,8 @@ TEST(ExtractVPXCodecDetails, TestDataLength) { } } -TEST(ExtractVPXCodecDetails, TestInputData) { +TEST(ExtractVPXCodecDetails, TestInputData) +{ TestData tests[] = { {u"vp09.02..08", false}, // malformed {u"vp9.02.10.08", false}, // invalid 4CC @@ -74,7 +76,8 @@ TEST(ExtractVPXCodecDetails, TestInputData) { } } -TEST(ExtractVPXCodecDetails, TestParsingOutput) { +TEST(ExtractVPXCodecDetails, TestParsingOutput) +{ uint8_t profile = 0; uint8_t level = 0; uint8_t bitDepth = 0; diff --git a/dom/media/platforms/AllocationPolicy.cpp b/dom/media/platforms/AllocationPolicy.cpp index 7e461acf9887c..afdc2e4725226 100644 --- a/dom/media/platforms/AllocationPolicy.cpp +++ b/dom/media/platforms/AllocationPolicy.cpp @@ -140,18 +140,19 @@ auto SingleAllocPolicy::Alloc() -> RefPtr { RefPtr p = self->mPendingPromise.Ensure(__func__); GlobalAllocPolicy::Instance(self->mTrack) ->Alloc() - ->Then(self->mOwnerThread, __func__, - [self, localToken = std::move(localToken)]( - RefPtr aToken) mutable { - self->mTokenRequest.Complete(); - RefPtr combinedToken = new AutoDeallocCombinedToken( - localToken.forget(), aToken.forget()); - self->mPendingPromise.Resolve(combinedToken, __func__); - }, - [self]() { - self->mTokenRequest.Complete(); - self->mPendingPromise.Reject(true, __func__); - }) + ->Then( + self->mOwnerThread, __func__, + [self, localToken = std::move(localToken)]( + RefPtr aToken) mutable { + self->mTokenRequest.Complete(); + RefPtr combinedToken = new AutoDeallocCombinedToken( + localToken.forget(), aToken.forget()); + self->mPendingPromise.Resolve(combinedToken, __func__); + }, + [self]() { + self->mTokenRequest.Complete(); + self->mPendingPromise.Reject(true, __func__); + }) ->Track(self->mTokenRequest); return p; }, @@ -212,47 +213,47 @@ AllocationWrapper::CreateDecoder(const CreateDecoderParams& aParams, RefPtr p = (aPolicy ? aPolicy : GlobalAllocPolicy::Instance(aParams.mType)) ->Alloc() - ->Then(AbstractThread::GetCurrent(), __func__, - [=](RefPtr aToken) { - // result may not always be updated by - // PDMFactory::CreateDecoder either when the creation - // succeeded or failed, as such it must be initialized to a - // fatal error by default. - MediaResult result = - MediaResult(NS_ERROR_DOM_MEDIA_FATAL_ERR, - nsPrintfCString("error creating %s decoder", - TrackTypeToStr(type))); - RefPtr pdm = new PDMFactory(); - CreateDecoderParams params{*config, - taskQueue, - diagnostics, - imageContainer, - &result, - knowsCompositor, - crashHelper, - useNullDecoder, - noWrapper, - type, - onWaitingForKeyEvent, - options, - rate}; - RefPtr decoder = - pdm->CreateDecoder(params); - if (decoder) { - RefPtr wrapper = new AllocationWrapper( - decoder.forget(), aToken.forget()); - return AllocateDecoderPromise::CreateAndResolve(wrapper, - __func__); - } - return AllocateDecoderPromise::CreateAndReject(result, + ->Then( + AbstractThread::GetCurrent(), __func__, + [=](RefPtr aToken) { + // result may not always be updated by + // PDMFactory::CreateDecoder either when the creation + // succeeded or failed, as such it must be initialized to a + // fatal error by default. + MediaResult result = + MediaResult(NS_ERROR_DOM_MEDIA_FATAL_ERR, + nsPrintfCString("error creating %s decoder", + TrackTypeToStr(type))); + RefPtr pdm = new PDMFactory(); + CreateDecoderParams params{*config, + taskQueue, + diagnostics, + imageContainer, + &result, + knowsCompositor, + crashHelper, + useNullDecoder, + noWrapper, + type, + onWaitingForKeyEvent, + options, + rate}; + RefPtr decoder = pdm->CreateDecoder(params); + if (decoder) { + RefPtr wrapper = + new AllocationWrapper(decoder.forget(), aToken.forget()); + return AllocateDecoderPromise::CreateAndResolve(wrapper, __func__); - }, - []() { - return AllocateDecoderPromise::CreateAndReject( - MediaResult(NS_ERROR_DOM_MEDIA_FATAL_ERR, - "Allocation policy expired"), - __func__); - }); + } + return AllocateDecoderPromise::CreateAndReject(result, + __func__); + }, + []() { + return AllocateDecoderPromise::CreateAndReject( + MediaResult(NS_ERROR_DOM_MEDIA_FATAL_ERR, + "Allocation policy expired"), + __func__); + }); return p; } diff --git a/dom/media/platforms/agnostic/eme/EMEDecoderModule.cpp b/dom/media/platforms/agnostic/eme/EMEDecoderModule.cpp index 01709e5dae3a5..8f99cfd968a88 100644 --- a/dom/media/platforms/agnostic/eme/EMEDecoderModule.cpp +++ b/dom/media/platforms/agnostic/eme/EMEDecoderModule.cpp @@ -101,12 +101,13 @@ class EMEDecryptor : public MediaDataDecoder, RefPtr p = mDecodePromise.Ensure(__func__); mSamplesWaitingForKey->WaitIfKeyNotUsable(sample) - ->Then(mTaskQueue, __func__, - [self](const RefPtr& aSample) { - self->mKeyRequest.Complete(); - self->ThrottleDecode(aSample); - }, - [self]() { self->mKeyRequest.Complete(); }) + ->Then( + mTaskQueue, __func__, + [self](const RefPtr& aSample) { + self->mKeyRequest.Complete(); + self->ThrottleDecode(aSample); + }, + [self]() { self->mKeyRequest.Complete(); }) ->Track(mKeyRequest); return p; @@ -118,12 +119,13 @@ class EMEDecryptor : public MediaDataDecoder, RefPtr self = this; mThroughputLimiter.Throttle(aSample) - ->Then(mTaskQueue, __func__, - [self](RefPtr aSample) { - self->mThrottleRequest.Complete(); - self->AttemptDecode(aSample); - }, - [self]() { self->mThrottleRequest.Complete(); }) + ->Then( + mTaskQueue, __func__, + [self](RefPtr aSample) { + self->mThrottleRequest.Complete(); + self->AttemptDecode(aSample); + }, + [self]() { self->mThrottleRequest.Complete(); }) ->Track(mThrottleRequest); } @@ -311,24 +313,25 @@ RefPtr EMEMediaDataDecoderProxy::Decode( return InvokeAsync(mThread, __func__, [self, this, sample]() { RefPtr p = mDecodePromise.Ensure(__func__); mSamplesWaitingForKey->WaitIfKeyNotUsable(sample) - ->Then(mThread, __func__, - [self, this](RefPtr aSample) { - mKeyRequest.Complete(); - - MediaDataDecoderProxy::Decode(aSample) - ->Then(mThread, __func__, - [self, this]( - DecodePromise::ResolveOrRejectValue&& aValue) { - mDecodeRequest.Complete(); - mDecodePromise.ResolveOrReject(std::move(aValue), - __func__); - }) - ->Track(mDecodeRequest); - }, - [self]() { - self->mKeyRequest.Complete(); - MOZ_CRASH("Should never get here"); - }) + ->Then( + mThread, __func__, + [self, this](RefPtr aSample) { + mKeyRequest.Complete(); + + MediaDataDecoderProxy::Decode(aSample) + ->Then(mThread, __func__, + [self, + this](DecodePromise::ResolveOrRejectValue&& aValue) { + mDecodeRequest.Complete(); + mDecodePromise.ResolveOrReject(std::move(aValue), + __func__); + }) + ->Track(mDecodeRequest); + }, + [self]() { + self->mKeyRequest.Complete(); + MOZ_CRASH("Should never get here"); + }) ->Track(mKeyRequest); return p; diff --git a/dom/media/platforms/omx/OmxDataDecoder.cpp b/dom/media/platforms/omx/OmxDataDecoder.cpp index b8619a7141876..781addebb2173 100644 --- a/dom/media/platforms/omx/OmxDataDecoder.cpp +++ b/dom/media/platforms/omx/OmxDataDecoder.cpp @@ -139,15 +139,16 @@ RefPtr OmxDataDecoder::Init() { RefPtr p = mInitPromise.Ensure(__func__); mOmxLayer->Init(mTrackInfo.get()) - ->Then(mOmxTaskQueue, __func__, - [self, this]() { - // Omx state should be OMX_StateIdle. - mOmxState = mOmxLayer->GetState(); - MOZ_ASSERT(mOmxState != OMX_StateIdle); - }, - [self, this]() { - RejectInitPromise(NS_ERROR_DOM_MEDIA_FATAL_ERR, __func__); - }); + ->Then( + mOmxTaskQueue, __func__, + [self, this]() { + // Omx state should be OMX_StateIdle. + mOmxState = mOmxLayer->GetState(); + MOZ_ASSERT(mOmxState != OMX_StateIdle); + }, + [self, this]() { + RejectInitPromise(NS_ERROR_DOM_MEDIA_FATAL_ERR, __func__); + }); return p; }); } @@ -211,39 +212,41 @@ RefPtr OmxDataDecoder::DoAsyncShutdown() { // Flush to all ports, so all buffers can be returned from component. RefPtr self = this; mOmxLayer->SendCommand(OMX_CommandFlush, OMX_ALL, nullptr) - ->Then(mOmxTaskQueue, __func__, - [self]() -> RefPtr { - LOGL("DoAsyncShutdown: flush complete"); - return self->mOmxLayer->SendCommand(OMX_CommandStateSet, - OMX_StateIdle, nullptr); - }, - [self](const OmxCommandFailureHolder& aError) { - self->mOmxLayer->Shutdown(); - return OmxCommandPromise::CreateAndReject(aError, __func__); - }) - ->Then(mOmxTaskQueue, __func__, - [self]() -> RefPtr { - RefPtr p = self->mOmxLayer->SendCommand( - OMX_CommandStateSet, OMX_StateLoaded, nullptr); - - // According to spec 3.1.1.2.2.1: - // OMX_StateLoaded needs to be sent before releasing buffers. - // And state transition from OMX_StateIdle to OMX_StateLoaded - // is completed when all of the buffers have been removed - // from the component. - // Here the buffer promises are not resolved due to displaying - // in layer, it needs to wait before the layer returns the - // buffers. - LOGL("DoAsyncShutdown: releasing buffers..."); - self->ReleaseBuffers(OMX_DirInput); - self->ReleaseBuffers(OMX_DirOutput); - - return p; - }, - [self](const OmxCommandFailureHolder& aError) { - self->mOmxLayer->Shutdown(); - return OmxCommandPromise::CreateAndReject(aError, __func__); - }) + ->Then( + mOmxTaskQueue, __func__, + [self]() -> RefPtr { + LOGL("DoAsyncShutdown: flush complete"); + return self->mOmxLayer->SendCommand(OMX_CommandStateSet, + OMX_StateIdle, nullptr); + }, + [self](const OmxCommandFailureHolder& aError) { + self->mOmxLayer->Shutdown(); + return OmxCommandPromise::CreateAndReject(aError, __func__); + }) + ->Then( + mOmxTaskQueue, __func__, + [self]() -> RefPtr { + RefPtr p = self->mOmxLayer->SendCommand( + OMX_CommandStateSet, OMX_StateLoaded, nullptr); + + // According to spec 3.1.1.2.2.1: + // OMX_StateLoaded needs to be sent before releasing buffers. + // And state transition from OMX_StateIdle to OMX_StateLoaded + // is completed when all of the buffers have been removed + // from the component. + // Here the buffer promises are not resolved due to displaying + // in layer, it needs to wait before the layer returns the + // buffers. + LOGL("DoAsyncShutdown: releasing buffers..."); + self->ReleaseBuffers(OMX_DirInput); + self->ReleaseBuffers(OMX_DirOutput); + + return p; + }, + [self](const OmxCommandFailureHolder& aError) { + self->mOmxLayer->Shutdown(); + return OmxCommandPromise::CreateAndReject(aError, __func__); + }) ->Then( mOmxTaskQueue, __func__, [self]() -> RefPtr { @@ -263,17 +266,18 @@ RefPtr OmxDataDecoder::DoAsyncShutdown() { self->mMediaDataHelper = nullptr; return ShutdownPromise::CreateAndReject(false, __func__); }) - ->Then(mTaskQueue, __func__, - [self]() { - self->mOmxTaskQueue->BeginShutdown(); - self->mOmxTaskQueue->AwaitShutdownAndIdle(); - self->mShutdownPromise.Resolve(true, __func__); - }, - [self]() { - self->mOmxTaskQueue->BeginShutdown(); - self->mOmxTaskQueue->AwaitShutdownAndIdle(); - self->mShutdownPromise.Resolve(true, __func__); - }); + ->Then( + mTaskQueue, __func__, + [self]() { + self->mOmxTaskQueue->BeginShutdown(); + self->mOmxTaskQueue->AwaitShutdownAndIdle(); + self->mShutdownPromise.Resolve(true, __func__); + }, + [self]() { + self->mOmxTaskQueue->BeginShutdown(); + self->mOmxTaskQueue->AwaitShutdownAndIdle(); + self->mShutdownPromise.Resolve(true, __func__); + }); return mShutdownPromise.Ensure(__func__); } @@ -325,18 +329,19 @@ void OmxDataDecoder::Output(BufferData* aData) { RefPtr self = this; RefPtr buffer = aData; - p->Then(mOmxTaskQueue, __func__, - [self, buffer]() { - MOZ_RELEASE_ASSERT(buffer->mStatus == - BufferData::BufferStatus::OMX_CLIENT_OUTPUT); - buffer->mStatus = BufferData::BufferStatus::FREE; - self->FillAndEmptyBuffers(); - }, - [buffer]() { - MOZ_RELEASE_ASSERT(buffer->mStatus == - BufferData::BufferStatus::OMX_CLIENT_OUTPUT); - buffer->mStatus = BufferData::BufferStatus::FREE; - }); + p->Then( + mOmxTaskQueue, __func__, + [self, buffer]() { + MOZ_RELEASE_ASSERT(buffer->mStatus == + BufferData::BufferStatus::OMX_CLIENT_OUTPUT); + buffer->mStatus = BufferData::BufferStatus::FREE; + self->FillAndEmptyBuffers(); + }, + [buffer]() { + MOZ_RELEASE_ASSERT(buffer->mStatus == + BufferData::BufferStatus::OMX_CLIENT_OUTPUT); + buffer->mStatus = BufferData::BufferStatus::FREE; + }); } else { aData->mStatus = BufferData::BufferStatus::FREE; } @@ -514,16 +519,16 @@ void OmxDataDecoder::OmxStateRunner() { // Send OpenMax state command to OMX_StateIdle. RefPtr self = this; mOmxLayer->SendCommand(OMX_CommandStateSet, OMX_StateIdle, nullptr) - ->Then(mOmxTaskQueue, __func__, - [self]() { - // Current state should be OMX_StateIdle. - self->mOmxState = self->mOmxLayer->GetState(); - MOZ_ASSERT(self->mOmxState == OMX_StateIdle); - }, - [self]() { - self->RejectInitPromise(NS_ERROR_DOM_MEDIA_FATAL_ERR, - __func__); - }); + ->Then( + mOmxTaskQueue, __func__, + [self]() { + // Current state should be OMX_StateIdle. + self->mOmxState = self->mOmxLayer->GetState(); + MOZ_ASSERT(self->mOmxState == OMX_StateIdle); + }, + [self]() { + self->RejectInitPromise(NS_ERROR_DOM_MEDIA_FATAL_ERR, __func__); + }); // Allocate input and output buffers. OMX_DIRTYPE types[] = {OMX_DIRTYPE::OMX_DirInput, @@ -538,17 +543,17 @@ void OmxDataDecoder::OmxStateRunner() { } else if (mOmxState == OMX_StateIdle) { RefPtr self = this; mOmxLayer->SendCommand(OMX_CommandStateSet, OMX_StateExecuting, nullptr) - ->Then(mOmxTaskQueue, __func__, - [self]() { - self->mOmxState = self->mOmxLayer->GetState(); - MOZ_ASSERT(self->mOmxState == OMX_StateExecuting); - - self->ResolveInitPromise(__func__); - }, - [self]() { - self->RejectInitPromise(NS_ERROR_DOM_MEDIA_FATAL_ERR, - __func__); - }); + ->Then( + mOmxTaskQueue, __func__, + [self]() { + self->mOmxState = self->mOmxLayer->GetState(); + MOZ_ASSERT(self->mOmxState == OMX_StateExecuting); + + self->ResolveInitPromise(__func__); + }, + [self]() { + self->RejectInitPromise(NS_ERROR_DOM_MEDIA_FATAL_ERR, __func__); + }); } else if (mOmxState == OMX_StateExecuting) { // Configure codec once it gets OMX_StateExecuting state. FillCodecConfigDataToOmx(); @@ -728,35 +733,36 @@ void OmxDataDecoder::PortSettingsChanged() { LOG("PortSettingsChanged: disable port %lu", def.nPortIndex); mOmxLayer ->SendCommand(OMX_CommandPortDisable, mPortSettingsChanged, nullptr) - ->Then(mOmxTaskQueue, __func__, - [self, def]() -> RefPtr { - // 3. enable port. - // Send enable port command. - RefPtr p = self->mOmxLayer->SendCommand( - OMX_CommandPortEnable, self->mPortSettingsChanged, - nullptr); - - // 4. allocate port buffers. - // Allocate new port buffers. - nsresult rv = self->AllocateBuffers(def.eDir); - if (NS_FAILED(rv)) { - self->NotifyError(OMX_ErrorUndefined, __func__); - } - - return p; - }, - [self](const OmxCommandFailureHolder& aError) { - self->NotifyError(OMX_ErrorUndefined, __func__); - return OmxCommandPromise::CreateAndReject(aError, __func__); - }) - ->Then(mOmxTaskQueue, __func__, - [self]() { - LOGL("PortSettingsChanged: port settings changed complete"); - // finish port setting changed. - self->mPortSettingsChanged = -1; - self->FillAndEmptyBuffers(); - }, - [self]() { self->NotifyError(OMX_ErrorUndefined, __func__); }); + ->Then( + mOmxTaskQueue, __func__, + [self, def]() -> RefPtr { + // 3. enable port. + // Send enable port command. + RefPtr p = self->mOmxLayer->SendCommand( + OMX_CommandPortEnable, self->mPortSettingsChanged, nullptr); + + // 4. allocate port buffers. + // Allocate new port buffers. + nsresult rv = self->AllocateBuffers(def.eDir); + if (NS_FAILED(rv)) { + self->NotifyError(OMX_ErrorUndefined, __func__); + } + + return p; + }, + [self](const OmxCommandFailureHolder& aError) { + self->NotifyError(OMX_ErrorUndefined, __func__); + return OmxCommandPromise::CreateAndReject(aError, __func__); + }) + ->Then( + mOmxTaskQueue, __func__, + [self]() { + LOGL("PortSettingsChanged: port settings changed complete"); + // finish port setting changed. + self->mPortSettingsChanged = -1; + self->FillAndEmptyBuffers(); + }, + [self]() { self->NotifyError(OMX_ErrorUndefined, __func__); }); // 2. wait for port buffers return to client and then release these buffers. // diff --git a/dom/media/platforms/omx/OmxPromiseLayer.cpp b/dom/media/platforms/omx/OmxPromiseLayer.cpp index 09da5bdc8551a..2a276f8a89950 100644 --- a/dom/media/platforms/omx/OmxPromiseLayer.cpp +++ b/dom/media/platforms/omx/OmxPromiseLayer.cpp @@ -298,7 +298,9 @@ bool OmxPromiseLayer::Event(OMX_EVENTTYPE aEvent, OMX_U32 aData1, } break; } - default: { return false; } + default: { + return false; + } } return true; } diff --git a/dom/media/platforms/wmf/MFTDecoder.h b/dom/media/platforms/wmf/MFTDecoder.h index 34292ace7c773..1cf431e85c789 100644 --- a/dom/media/platforms/wmf/MFTDecoder.h +++ b/dom/media/platforms/wmf/MFTDecoder.h @@ -36,9 +36,10 @@ class MFTDecoder final { // - aOutputType needs at least major and minor types set. // This is used to select the matching output type out // of all the available output types of the MFT. - HRESULT SetMediaTypes(IMFMediaType* aInputType, IMFMediaType* aOutputType, - std::function&& aCallback = - [](IMFMediaType* aOutput) { return S_OK; }); + HRESULT SetMediaTypes( + IMFMediaType* aInputType, IMFMediaType* aOutputType, + std::function&& aCallback = + [](IMFMediaType* aOutput) { return S_OK; }); // Returns the MFT's IMFAttributes object. already_AddRefed GetAttributes(); diff --git a/dom/media/platforms/wrappers/MediaChangeMonitor.cpp b/dom/media/platforms/wrappers/MediaChangeMonitor.cpp index e66c81a17c6b2..ce7e9e3afba94 100644 --- a/dom/media/platforms/wrappers/MediaChangeMonitor.cpp +++ b/dom/media/platforms/wrappers/MediaChangeMonitor.cpp @@ -475,35 +475,36 @@ MediaResult MediaChangeMonitor::CreateDecoderAndInit(MediaRawData* aSample) { RefPtr self = this; RefPtr sample = aSample; mDecoder->Init() - ->Then(mTaskQueue, __func__, - [self, sample, this](const TrackType aTrackType) { - mInitPromiseRequest.Complete(); - mConversionRequired = Some(mDecoder->NeedsConversion()); - mCanRecycleDecoder = Some(CanRecycleDecoder()); - - if (!mFlushPromise.IsEmpty()) { - // A Flush is pending, abort the current operation. - mFlushPromise.Resolve(true, __func__); - return; - } - - DecodeFirstSample(sample); - }, - [self, this](const MediaResult& aError) { - mInitPromiseRequest.Complete(); - - if (!mFlushPromise.IsEmpty()) { - // A Flush is pending, abort the current operation. - mFlushPromise.Reject(aError, __func__); - return; - } - - mDecodePromise.Reject( - MediaResult( - NS_ERROR_DOM_MEDIA_FATAL_ERR, - RESULT_DETAIL("Unable to initialize H264 decoder")), - __func__); - }) + ->Then( + mTaskQueue, __func__, + [self, sample, this](const TrackType aTrackType) { + mInitPromiseRequest.Complete(); + mConversionRequired = Some(mDecoder->NeedsConversion()); + mCanRecycleDecoder = Some(CanRecycleDecoder()); + + if (!mFlushPromise.IsEmpty()) { + // A Flush is pending, abort the current operation. + mFlushPromise.Resolve(true, __func__); + return; + } + + DecodeFirstSample(sample); + }, + [self, this](const MediaResult& aError) { + mInitPromiseRequest.Complete(); + + if (!mFlushPromise.IsEmpty()) { + // A Flush is pending, abort the current operation. + mFlushPromise.Reject(aError, __func__); + return; + } + + mDecodePromise.Reject( + MediaResult( + NS_ERROR_DOM_MEDIA_FATAL_ERR, + RESULT_DETAIL("Unable to initialize H264 decoder")), + __func__); + }) ->Track(mInitPromiseRequest); return NS_ERROR_DOM_MEDIA_INITIALIZING_DECODER; } @@ -544,17 +545,18 @@ void MediaChangeMonitor::DecodeFirstSample(MediaRawData* aSample) { RefPtr self = this; mDecoder->Decode(aSample) - ->Then(mTaskQueue, __func__, - [self, this](MediaDataDecoder::DecodedData&& aResults) { - mDecodePromiseRequest.Complete(); - mPendingFrames.AppendElements(std::move(aResults)); - mDecodePromise.Resolve(std::move(mPendingFrames), __func__); - mPendingFrames = DecodedData(); - }, - [self, this](const MediaResult& aError) { - mDecodePromiseRequest.Complete(); - mDecodePromise.Reject(aError, __func__); - }) + ->Then( + mTaskQueue, __func__, + [self, this](MediaDataDecoder::DecodedData&& aResults) { + mDecodePromiseRequest.Complete(); + mPendingFrames.AppendElements(std::move(aResults)); + mDecodePromise.Resolve(std::move(mPendingFrames), __func__); + mPendingFrames = DecodedData(); + }, + [self, this](const MediaResult& aError) { + mDecodePromiseRequest.Complete(); + mDecodePromise.Reject(aError, __func__); + }) ->Track(mDecodePromiseRequest); } @@ -589,32 +591,33 @@ void MediaChangeMonitor::DrainThenFlushDecoder(MediaRawData* aPendingSample) { RefPtr sample = aPendingSample; RefPtr self = this; mDecoder->Drain() - ->Then(mTaskQueue, __func__, - [self, sample, this](MediaDataDecoder::DecodedData&& aResults) { - mDrainRequest.Complete(); - if (!mFlushPromise.IsEmpty()) { - // A Flush is pending, abort the current operation. - mFlushPromise.Resolve(true, __func__); - return; - } - if (aResults.Length() > 0) { - mPendingFrames.AppendElements(std::move(aResults)); - DrainThenFlushDecoder(sample); - return; - } - // We've completed the draining operation, we can now flush the - // decoder. - FlushThenShutdownDecoder(sample); - }, - [self, this](const MediaResult& aError) { - mDrainRequest.Complete(); - if (!mFlushPromise.IsEmpty()) { - // A Flush is pending, abort the current operation. - mFlushPromise.Reject(aError, __func__); - return; - } - mDecodePromise.Reject(aError, __func__); - }) + ->Then( + mTaskQueue, __func__, + [self, sample, this](MediaDataDecoder::DecodedData&& aResults) { + mDrainRequest.Complete(); + if (!mFlushPromise.IsEmpty()) { + // A Flush is pending, abort the current operation. + mFlushPromise.Resolve(true, __func__); + return; + } + if (aResults.Length() > 0) { + mPendingFrames.AppendElements(std::move(aResults)); + DrainThenFlushDecoder(sample); + return; + } + // We've completed the draining operation, we can now flush the + // decoder. + FlushThenShutdownDecoder(sample); + }, + [self, this](const MediaResult& aError) { + mDrainRequest.Complete(); + if (!mFlushPromise.IsEmpty()) { + // A Flush is pending, abort the current operation. + mFlushPromise.Reject(aError, __func__); + return; + } + mDecodePromise.Reject(aError, __func__); + }) ->Track(mDrainRequest); } @@ -625,51 +628,53 @@ void MediaChangeMonitor::FlushThenShutdownDecoder( RefPtr sample = aPendingSample; RefPtr self = this; mDecoder->Flush() - ->Then(mTaskQueue, __func__, - [self, sample, this]() { - mFlushRequest.Complete(); - - if (!mFlushPromise.IsEmpty()) { - // A Flush is pending, abort the current operation. - mFlushPromise.Resolve(true, __func__); - return; - } - - mShutdownPromise = ShutdownDecoder(); - mShutdownPromise - ->Then(mTaskQueue, __func__, - [self, sample, this]() { - mShutdownRequest.Complete(); - mShutdownPromise = nullptr; - - if (!mFlushPromise.IsEmpty()) { - // A Flush is pending, abort the current - // operation. - mFlushPromise.Resolve(true, __func__); - return; - } - - MediaResult rv = CreateDecoderAndInit(sample); - if (rv == NS_ERROR_DOM_MEDIA_INITIALIZING_DECODER) { - // All good so far, will continue later. - return; - } - MOZ_ASSERT(NS_FAILED(rv)); - mDecodePromise.Reject(rv, __func__); - return; - }, - [] { MOZ_CRASH("Can't reach here'"); }) - ->Track(mShutdownRequest); - }, - [self, this](const MediaResult& aError) { - mFlushRequest.Complete(); - if (!mFlushPromise.IsEmpty()) { - // A Flush is pending, abort the current operation. - mFlushPromise.Reject(aError, __func__); - return; - } - mDecodePromise.Reject(aError, __func__); - }) + ->Then( + mTaskQueue, __func__, + [self, sample, this]() { + mFlushRequest.Complete(); + + if (!mFlushPromise.IsEmpty()) { + // A Flush is pending, abort the current operation. + mFlushPromise.Resolve(true, __func__); + return; + } + + mShutdownPromise = ShutdownDecoder(); + mShutdownPromise + ->Then( + mTaskQueue, __func__, + [self, sample, this]() { + mShutdownRequest.Complete(); + mShutdownPromise = nullptr; + + if (!mFlushPromise.IsEmpty()) { + // A Flush is pending, abort the current + // operation. + mFlushPromise.Resolve(true, __func__); + return; + } + + MediaResult rv = CreateDecoderAndInit(sample); + if (rv == NS_ERROR_DOM_MEDIA_INITIALIZING_DECODER) { + // All good so far, will continue later. + return; + } + MOZ_ASSERT(NS_FAILED(rv)); + mDecodePromise.Reject(rv, __func__); + return; + }, + [] { MOZ_CRASH("Can't reach here'"); }) + ->Track(mShutdownRequest); + }, + [self, this](const MediaResult& aError) { + mFlushRequest.Complete(); + if (!mFlushPromise.IsEmpty()) { + // A Flush is pending, abort the current operation. + mFlushPromise.Reject(aError, __func__); + return; + } + mDecodePromise.Reject(aError, __func__); + }) ->Track(mFlushRequest); } diff --git a/dom/media/systemservices/MediaUtils.h b/dom/media/systemservices/MediaUtils.h index 09becaa7ce77f..3831341ad6644 100644 --- a/dom/media/systemservices/MediaUtils.h +++ b/dom/media/systemservices/MediaUtils.h @@ -224,19 +224,20 @@ Await(already_AddRefed aPool, typename MozPromise::ResolveOrRejectValue val; - aPromise->Then(taskQueue, __func__, - [&](ResolveValueType aResolveValue) { - val.SetResolve(std::move(aResolveValue)); - MonitorAutoLock lock(mon); - done = true; - mon.Notify(); - }, - [&](RejectValueType aRejectValue) { - val.SetReject(std::move(aRejectValue)); - MonitorAutoLock lock(mon); - done = true; - mon.Notify(); - }); + aPromise->Then( + taskQueue, __func__, + [&](ResolveValueType aResolveValue) { + val.SetResolve(std::move(aResolveValue)); + MonitorAutoLock lock(mon); + done = true; + mon.Notify(); + }, + [&](RejectValueType aRejectValue) { + val.SetReject(std::move(aRejectValue)); + MonitorAutoLock lock(mon); + done = true; + mon.Notify(); + }); MonitorAutoLock lock(mon); while (!done) { diff --git a/dom/media/webaudio/blink/DenormalDisabler.h b/dom/media/webaudio/blink/DenormalDisabler.h index 51f56bd8af28f..b7a3ca321c251 100644 --- a/dom/media/webaudio/blink/DenormalDisabler.h +++ b/dom/media/webaudio/blink/DenormalDisabler.h @@ -107,18 +107,18 @@ class DenormalDisabler { inline int getStatusWord() { int result; # if defined(__aarch64__) - asm volatile("mrs %x[result], FPCR" : [result] "=r"(result)); + asm volatile("mrs %x[result], FPCR" : [ result ] "=r"(result)); # else - asm volatile("vmrs %[result], FPSCR" : [result] "=r"(result)); + asm volatile("vmrs %[result], FPSCR" : [ result ] "=r"(result)); # endif return result; } inline void setStatusWord(int a) { # if defined(__aarch64__) - asm volatile("msr FPCR, %x[src]" : : [src] "r"(a)); + asm volatile("msr FPCR, %x[src]" : : [ src ] "r"(a)); # else - asm volatile("vmsr FPSCR, %[src]" : : [src] "r"(a)); + asm volatile("vmsr FPSCR, %[src]" : : [ src ] "r"(a)); # endif } diff --git a/dom/media/webrtc/MediaEngineRemoteVideoSource.cpp b/dom/media/webrtc/MediaEngineRemoteVideoSource.cpp index 311408d93c992..7ae95b12d1618 100644 --- a/dom/media/webrtc/MediaEngineRemoteVideoSource.cpp +++ b/dom/media/webrtc/MediaEngineRemoteVideoSource.cpp @@ -538,7 +538,9 @@ int MediaEngineRemoteVideoSource::DeliverFrame( } break; } - default: { break; } + default: { + break; + } } rtc::Callback0 callback_unused; diff --git a/dom/media/webspeech/recognition/SpeechRecognition.cpp b/dom/media/webspeech/recognition/SpeechRecognition.cpp index 186777983ec79..1d106c749a44c 100644 --- a/dom/media/webspeech/recognition/SpeechRecognition.cpp +++ b/dom/media/webspeech/recognition/SpeechRecognition.cpp @@ -679,29 +679,30 @@ void SpeechRecognition::Start(const Optional>& aStream, RefPtr self(this); MediaManager::Get() ->GetUserMedia(GetOwner(), constraints, aCallerType) - ->Then(GetCurrentThreadSerialEventTarget(), __func__, - [this, self](RefPtr&& aStream) { - mStream = std::move(aStream); - mStream->RegisterTrackListener(this); - nsTArray> tracks; - mStream->GetAudioTracks(tracks); - for (const RefPtr& track : tracks) { - if (!track->Ended()) { - NotifyTrackAdded(track); - } - } - }, - [this, self](RefPtr&& error) { - SpeechRecognitionErrorCode errorCode; - - if (error->mName == MediaMgrError::Name::NotAllowedError) { - errorCode = SpeechRecognitionErrorCode::Not_allowed; - } else { - errorCode = SpeechRecognitionErrorCode::Audio_capture; - } - DispatchError(SpeechRecognition::EVENT_AUDIO_ERROR, errorCode, - error->mMessage); - }); + ->Then( + GetCurrentThreadSerialEventTarget(), __func__, + [this, self](RefPtr&& aStream) { + mStream = std::move(aStream); + mStream->RegisterTrackListener(this); + nsTArray> tracks; + mStream->GetAudioTracks(tracks); + for (const RefPtr& track : tracks) { + if (!track->Ended()) { + NotifyTrackAdded(track); + } + } + }, + [this, self](RefPtr&& error) { + SpeechRecognitionErrorCode errorCode; + + if (error->mName == MediaMgrError::Name::NotAllowedError) { + errorCode = SpeechRecognitionErrorCode::Not_allowed; + } else { + errorCode = SpeechRecognitionErrorCode::Audio_capture; + } + DispatchError(SpeechRecognition::EVENT_AUDIO_ERROR, errorCode, + error->mMessage); + }); } RefPtr event = new SpeechEvent(this, EVENT_START); diff --git a/dom/payments/PaymentActionResponse.cpp b/dom/payments/PaymentActionResponse.cpp index 026c0cffd7cbb..86416b1e91981 100644 --- a/dom/payments/PaymentActionResponse.cpp +++ b/dom/payments/PaymentActionResponse.cpp @@ -268,7 +268,9 @@ PaymentShowActionResponse::Init(const nsAString& aRequestId, } break; } - default: { return NS_ERROR_FAILURE; } + default: { + return NS_ERROR_FAILURE; + } } } mData = aData; diff --git a/dom/payments/PaymentMethodChangeEvent.cpp b/dom/payments/PaymentMethodChangeEvent.cpp index 7fe4d9d123bd0..86966905fc025 100644 --- a/dom/payments/PaymentMethodChangeEvent.cpp +++ b/dom/payments/PaymentMethodChangeEvent.cpp @@ -143,7 +143,9 @@ void PaymentMethodChangeEvent::GetMethodDetails( aRetVal.set(&value.toObject()); break; } - default: { break; } + default: { + break; + } } } diff --git a/dom/payments/PaymentRequestManager.cpp b/dom/payments/PaymentRequestManager.cpp index 1778591a2150e..0eacbec3b528d 100644 --- a/dom/payments/PaymentRequestManager.cpp +++ b/dom/payments/PaymentRequestManager.cpp @@ -264,7 +264,9 @@ void ConvertResponseData(const IPCPaymentResponseData& aIPCData, aData = bData; break; } - default: { break; } + default: { + break; + } } } @@ -301,7 +303,9 @@ void ConvertMethodChangeDetails(const IPCMethodChangeDetails& aIPCDetails, aDetails = bDetails; break; } - default: { break; } + default: { + break; + } } } } // end of namespace @@ -681,7 +685,9 @@ nsresult PaymentRequestManager::RespondPayment( NotifyRequestDone(aRequest); break; } - default: { return NS_ERROR_FAILURE; } + default: { + return NS_ERROR_FAILURE; + } } return NS_OK; } diff --git a/dom/payments/PaymentRequestService.cpp b/dom/payments/PaymentRequestService.cpp index 1d5c7bbcf840c..4bf4dd163f831 100644 --- a/dom/payments/PaymentRequestService.cpp +++ b/dom/payments/PaymentRequestService.cpp @@ -178,7 +178,9 @@ nsresult PaymentRequestService::LaunchUIAction(const nsAString& aRequestId, rv = uiService->ClosePayment(aRequestId); break; } - default: { return NS_ERROR_FAILURE; } + default: { + return NS_ERROR_FAILURE; + } } if (NS_WARN_IF(NS_FAILED(rv))) { return rv; @@ -332,7 +334,9 @@ nsresult PaymentRequestService::RequestPayment( aRequestId, IPCPaymentActionRequest::TIPCPaymentUpdateActionRequest); break; } - default: { return NS_ERROR_FAILURE; } + default: { + return NS_ERROR_FAILURE; + } } return NS_OK; } @@ -418,7 +422,9 @@ PaymentRequestService::RespondPayment(nsIPaymentActionResponse* aResponse) { mRequestQueue.RemoveElement(request); break; } - default: { break; } + default: { + break; + } } return NS_OK; } diff --git a/dom/payments/ipc/PaymentRequestParent.cpp b/dom/payments/ipc/PaymentRequestParent.cpp index effe6e96ffc6c..01a312a1d16e4 100644 --- a/dom/payments/ipc/PaymentRequestParent.cpp +++ b/dom/payments/ipc/PaymentRequestParent.cpp @@ -66,7 +66,9 @@ mozilla::ipc::IPCResult PaymentRequestParent::RecvRequestPayment( mRequestId = request.requestId(); break; } - default: { return IPC_FAIL(this, "Unknown PaymentRequest action type"); } + default: { + return IPC_FAIL(this, "Unknown PaymentRequest action type"); + } } nsCOMPtr service = do_GetService(NS_PAYMENT_REQUEST_SERVICE_CONTRACT_ID); @@ -176,7 +178,9 @@ nsresult PaymentRequestParent::RespondPayment( } break; } - default: { return NS_ERROR_FAILURE; } + default: { + return NS_ERROR_FAILURE; + } } return NS_OK; } @@ -310,7 +314,9 @@ nsresult PaymentRequestParent::ChangePaymentMethod( ipcChangeDetails = ipcBasicCardDetails; break; } - default: { return NS_ERROR_FAILURE; } + default: { + return NS_ERROR_FAILURE; + } } } if (!SendChangePaymentMethod(requestId, methodName, ipcChangeDetails)) { @@ -454,7 +460,9 @@ nsresult PaymentRequestParent::SerializeResponseData( aIPCData = data; break; } - default: { return NS_ERROR_FAILURE; } + default: { + return NS_ERROR_FAILURE; + } } return NS_OK; } diff --git a/dom/prio/test/gtest/TestPrioEncoder.cpp b/dom/prio/test/gtest/TestPrioEncoder.cpp index 1e90559eaaffe..d2714937dd6b7 100644 --- a/dom/prio/test/gtest/TestPrioEncoder.cpp +++ b/dom/prio/test/gtest/TestPrioEncoder.cpp @@ -14,7 +14,8 @@ #include "mprio.h" -TEST(PrioEncoder, BadPublicKeys) { +TEST(PrioEncoder, BadPublicKeys) +{ mozilla::dom::AutoJSAPI jsAPI; ASSERT_TRUE(jsAPI.Init(xpc::PrivilegedJunkScope())); JSContext* cx = jsAPI.cx(); @@ -46,7 +47,8 @@ TEST(PrioEncoder, BadPublicKeys) { rv = mozilla::ErrorResult(); } -TEST(PrioEncoder, BooleanLimitExceeded) { +TEST(PrioEncoder, BooleanLimitExceeded) +{ mozilla::dom::AutoJSAPI jsAPI; ASSERT_TRUE(jsAPI.Init(xpc::PrivilegedJunkScope())); JSContext* cx = jsAPI.cx(); @@ -81,7 +83,8 @@ TEST(PrioEncoder, BooleanLimitExceeded) { rv = mozilla::ErrorResult(); } -TEST(PrioEncoder, VerifyFull) { +TEST(PrioEncoder, VerifyFull) +{ SECStatus prioRv = SECSuccess; PublicKey pkA = nullptr; diff --git a/dom/quota/ActorsParent.cpp b/dom/quota/ActorsParent.cpp index 543461bb18e9f..02fae0d4fc0c9 100644 --- a/dom/quota/ActorsParent.cpp +++ b/dom/quota/ActorsParent.cpp @@ -5602,7 +5602,9 @@ bool QuotaManager::IsPrincipalInfoValid(const PrincipalInfo& aPrincipalInfo) { return true; } - default: { break; } + default: { + break; + } } // Null and expanded principals are not acceptable. @@ -5643,7 +5645,9 @@ void QuotaManager::GetInfoFromValidatedPrincipalInfo( return; } - default: { break; } + default: { + break; + } } MOZ_CRASH("Should never get here!"); @@ -8237,7 +8241,9 @@ bool PrincipalVerifier::IsPrincipalInfoValid( return true; } - default: { break; } + default: { + break; + } } // Null and expanded principals are not acceptable. diff --git a/dom/quota/test/gtest/TestQuotaManager.cpp b/dom/quota/test/gtest/TestQuotaManager.cpp index 9f1cf274be952..948da37cbf626 100644 --- a/dom/quota/test/gtest/TestQuotaManager.cpp +++ b/dom/quota/test/gtest/TestQuotaManager.cpp @@ -27,7 +27,8 @@ void CheckOriginScopeMatchesOrigin(const OriginScope& aOriginScope, } // namespace -TEST(QuotaManager, OriginScope) { +TEST(QuotaManager, OriginScope) +{ OriginScope originScope; // Sanity checks. diff --git a/dom/reporting/tests/gtest/TestReportToParser.cpp b/dom/reporting/tests/gtest/TestReportToParser.cpp index 195f2653e17fb..0bce790a5e6ba 100644 --- a/dom/reporting/tests/gtest/TestReportToParser.cpp +++ b/dom/reporting/tests/gtest/TestReportToParser.cpp @@ -12,7 +12,8 @@ using namespace mozilla; using namespace mozilla::dom; -TEST(ReportToParser, Basic) { +TEST(ReportToParser, Basic) +{ nsCOMPtr uri; nsresult rv = NS_NewURI(getter_AddRefs(uri), "https://example.com"); diff --git a/dom/security/featurepolicy/test/gtest/TestFeaturePolicyParser.cpp b/dom/security/featurepolicy/test/gtest/TestFeaturePolicyParser.cpp index 2efbbd5ca9bb5..8577924960845 100644 --- a/dom/security/featurepolicy/test/gtest/TestFeaturePolicyParser.cpp +++ b/dom/security/featurepolicy/test/gtest/TestFeaturePolicyParser.cpp @@ -32,7 +32,8 @@ void CheckParser(const nsAString& aInput, bool aExpectedResults, parsedFeatures.SwapElements(aParsedFeatures); } -TEST(FeaturePolicyParser, Basic) { +TEST(FeaturePolicyParser, Basic) +{ nsCOMPtr selfPrincipal = mozilla::BasePrincipal::CreateCodebasePrincipal(URL_SELF); nsCOMPtr exampleComPrincipal = diff --git a/dom/security/test/gtest/TestCSPParser.cpp b/dom/security/test/gtest/TestCSPParser.cpp index a6d4884cbbefa..f9cf4404ddcb0 100644 --- a/dom/security/test/gtest/TestCSPParser.cpp +++ b/dom/security/test/gtest/TestCSPParser.cpp @@ -176,7 +176,8 @@ nsresult runTestSuite(const PolicyTest* aPolicies, uint32_t aPolicyCount, // ============================= TestDirectives ======================== -TEST(CSPParser, Directives) { +TEST(CSPParser, Directives) +{ static const PolicyTest policies[] = { // clang-format off { "connect-src xn--mnchen-3ya.de", @@ -228,7 +229,8 @@ TEST(CSPParser, Directives) { // ============================= TestKeywords ======================== -TEST(CSPParser, Keywords) { +TEST(CSPParser, Keywords) +{ static const PolicyTest policies[] = { // clang-format off { "script-src 'self'", @@ -252,7 +254,8 @@ TEST(CSPParser, Keywords) { // =================== TestIgnoreUpperLowerCasePolicies ============== -TEST(CSPParser, IgnoreUpperLowerCasePolicies) { +TEST(CSPParser, IgnoreUpperLowerCasePolicies) +{ static const PolicyTest policies[] = { // clang-format off { "script-src 'SELF'", @@ -294,7 +297,8 @@ TEST(CSPParser, IgnoreUpperLowerCasePolicies) { // ========================= TestPaths =============================== -TEST(CSPParser, Paths) { +TEST(CSPParser, Paths) +{ static const PolicyTest policies[] = { // clang-format off { "script-src http://www.example.com", @@ -392,7 +396,8 @@ TEST(CSPParser, Paths) { // ======================== TestSimplePolicies ======================= -TEST(CSPParser, SimplePolicies) { +TEST(CSPParser, SimplePolicies) +{ static const PolicyTest policies[] = { // clang-format off { "default-src *", @@ -468,7 +473,8 @@ TEST(CSPParser, SimplePolicies) { // =================== TestPoliciesWithInvalidSrc ==================== -TEST(CSPParser, PoliciesWithInvalidSrc) { +TEST(CSPParser, PoliciesWithInvalidSrc) +{ static const PolicyTest policies[] = { // clang-format off { "script-src 'self'; SCRIPT-SRC http://www.example.com", @@ -561,7 +567,8 @@ TEST(CSPParser, PoliciesWithInvalidSrc) { // ============================= TestBadPolicies ======================= -TEST(CSPParser, BadPolicies) { +TEST(CSPParser, BadPolicies) +{ static const PolicyTest policies[] = { // clang-format off { "script-sr 'self", "" }, @@ -583,7 +590,8 @@ TEST(CSPParser, BadPolicies) { // ======================= TestGoodGeneratedPolicies ================= -TEST(CSPParser, GoodGeneratedPolicies) { +TEST(CSPParser, GoodGeneratedPolicies) +{ static const PolicyTest policies[] = { // clang-format off { "default-src 'self'; img-src *", @@ -811,7 +819,8 @@ TEST(CSPParser, GoodGeneratedPolicies) { // ==================== TestBadGeneratedPolicies ==================== -TEST(CSPParser, BadGeneratedPolicies) { +TEST(CSPParser, BadGeneratedPolicies) +{ static const PolicyTest policies[] = { // clang-format off { "foo.*.bar", ""}, @@ -837,7 +846,8 @@ TEST(CSPParser, BadGeneratedPolicies) { // ============ TestGoodGeneratedPoliciesForPathHandling ============= -TEST(CSPParser, GoodGeneratedPoliciesForPathHandling) { +TEST(CSPParser, GoodGeneratedPoliciesForPathHandling) +{ // Once bug 808292 (Implement path-level host-source matching to CSP) // lands we have to update the expected output to include the parsed path @@ -960,7 +970,8 @@ TEST(CSPParser, GoodGeneratedPoliciesForPathHandling) { // ============== TestBadGeneratedPoliciesForPathHandling ============ -TEST(CSPParser, BadGeneratedPoliciesForPathHandling) { +TEST(CSPParser, BadGeneratedPoliciesForPathHandling) +{ static const PolicyTest policies[] = { // clang-format off { "img-src test1.example.com:88path-1/", @@ -989,7 +1000,8 @@ TEST(CSPParser, BadGeneratedPoliciesForPathHandling) { // Use a policy, eliminate one character at a time, // and feed it as input to the parser. -TEST(CSPParser, ShorteningPolicies) { +TEST(CSPParser, ShorteningPolicies) +{ char pol[] = "default-src http://www.sub1.sub2.example.com:88/path1/path2/ " "'unsafe-inline' 'none'"; @@ -1016,7 +1028,8 @@ TEST(CSPParser, ShorteningPolicies) { #if RUN_OFFLINE_TESTS -TEST(CSPParser, FuzzyPolicies) { +TEST(CSPParser, FuzzyPolicies) +{ // init srand with 0 so we get same results srand(0); @@ -1048,7 +1061,8 @@ TEST(CSPParser, FuzzyPolicies) { #if RUN_OFFLINE_TESTS -TEST(CSPParser, FuzzyPoliciesIncDir) { +TEST(CSPParser, FuzzyPoliciesIncDir) +{ // init srand with 0 so we get same results srand(0); @@ -1086,7 +1100,8 @@ TEST(CSPParser, FuzzyPoliciesIncDir) { #if RUN_OFFLINE_TESTS -TEST(CSPParser, FuzzyPoliciesIncDirLimASCII) { +TEST(CSPParser, FuzzyPoliciesIncDirLimASCII) +{ char input[] = "1234567890" "abcdefghijklmnopqrstuvwxyz" diff --git a/dom/security/test/gtest/TestSecureContext.cpp b/dom/security/test/gtest/TestSecureContext.cpp index d8b217b341def..7c252b2dc5d0f 100644 --- a/dom/security/test/gtest/TestSecureContext.cpp +++ b/dom/security/test/gtest/TestSecureContext.cpp @@ -26,7 +26,8 @@ struct TestExpectations { // ============================= TestDirectives ======================== -TEST(SecureContext, IsOriginPotentiallyTrustworthyWithCodeBasePrincipal) { +TEST(SecureContext, IsOriginPotentiallyTrustworthyWithCodeBasePrincipal) +{ // boolean isOriginPotentiallyTrustworthy(in nsIPrincipal aPrincipal); static const TestExpectations uris[] = { @@ -68,7 +69,8 @@ TEST(SecureContext, IsOriginPotentiallyTrustworthyWithCodeBasePrincipal) { } } -TEST(SecureContext, IsOriginPotentiallyTrustworthyWithSystemPrincipal) { +TEST(SecureContext, IsOriginPotentiallyTrustworthyWithSystemPrincipal) +{ RefPtr ssManager = nsScriptSecurityManager::GetScriptSecurityManager(); ASSERT_TRUE(!!ssManager); @@ -84,7 +86,8 @@ TEST(SecureContext, IsOriginPotentiallyTrustworthyWithSystemPrincipal) { ASSERT_TRUE(isPotentiallyTrustworthy); } -TEST(SecureContext, IsOriginPotentiallyTrustworthyWithNullPrincipal) { +TEST(SecureContext, IsOriginPotentiallyTrustworthyWithNullPrincipal) +{ RefPtr ssManager = nsScriptSecurityManager::GetScriptSecurityManager(); ASSERT_TRUE(!!ssManager); diff --git a/dom/serviceworkers/ServiceWorkerContainerImpl.cpp b/dom/serviceworkers/ServiceWorkerContainerImpl.cpp index c09f497dc48e7..aa9dd87ce6bc6 100644 --- a/dom/serviceworkers/ServiceWorkerContainerImpl.cpp +++ b/dom/serviceworkers/ServiceWorkerContainerImpl.cpp @@ -54,17 +54,18 @@ void ServiceWorkerContainerImpl::Register( global); swm->Register(aClientInfo, aScopeURL, aScriptURL, aUpdateViaCache) - ->Then(global->EventTargetFor(TaskCategory::Other), __func__, - [successCB = std::move(aSuccessCB), - holder](const ServiceWorkerRegistrationDescriptor& aDescriptor) { - holder->Complete(); - successCB(aDescriptor); - }, - [failureCB = std::move(aFailureCB), - holder](const CopyableErrorResult& aResult) { - holder->Complete(); - failureCB(CopyableErrorResult(aResult)); - }) + ->Then( + global->EventTargetFor(TaskCategory::Other), __func__, + [successCB = std::move(aSuccessCB), + holder](const ServiceWorkerRegistrationDescriptor& aDescriptor) { + holder->Complete(); + successCB(aDescriptor); + }, + [failureCB = std::move(aFailureCB), + holder](const CopyableErrorResult& aResult) { + holder->Complete(); + failureCB(CopyableErrorResult(aResult)); + }) ->Track(*holder); } @@ -91,17 +92,18 @@ void ServiceWorkerContainerImpl::GetRegistration( global); swm->GetRegistration(aClientInfo, aURL) - ->Then(global->EventTargetFor(TaskCategory::Other), __func__, - [successCB = std::move(aSuccessCB), - holder](const ServiceWorkerRegistrationDescriptor& aDescriptor) { - holder->Complete(); - successCB(aDescriptor); - }, - [failureCB = std::move(aFailureCB), - holder](const CopyableErrorResult& aResult) { - holder->Complete(); - failureCB(CopyableErrorResult(aResult)); - }) + ->Then( + global->EventTargetFor(TaskCategory::Other), __func__, + [successCB = std::move(aSuccessCB), + holder](const ServiceWorkerRegistrationDescriptor& aDescriptor) { + holder->Complete(); + successCB(aDescriptor); + }, + [failureCB = std::move(aFailureCB), + holder](const CopyableErrorResult& aResult) { + holder->Complete(); + failureCB(CopyableErrorResult(aResult)); + }) ->Track(*holder); } @@ -127,17 +129,18 @@ void ServiceWorkerContainerImpl::GetRegistrations( DOMMozPromiseRequestHolder>(global); swm->GetRegistrations(aClientInfo) - ->Then(global->EventTargetFor(TaskCategory::Other), __func__, - [successCB = std::move(aSuccessCB), holder]( - const nsTArray& aList) { - holder->Complete(); - successCB(aList); - }, - [failureCB = std::move(aFailureCB), - holder](const CopyableErrorResult& aResult) { - holder->Complete(); - failureCB(CopyableErrorResult(aResult)); - }) + ->Then( + global->EventTargetFor(TaskCategory::Other), __func__, + [successCB = std::move(aSuccessCB), + holder](const nsTArray& aList) { + holder->Complete(); + successCB(aList); + }, + [failureCB = std::move(aFailureCB), + holder](const CopyableErrorResult& aResult) { + holder->Complete(); + failureCB(CopyableErrorResult(aResult)); + }) ->Track(*holder); } @@ -164,17 +167,18 @@ void ServiceWorkerContainerImpl::GetReady( global); swm->WhenReady(aClientInfo) - ->Then(global->EventTargetFor(TaskCategory::Other), __func__, - [successCB = std::move(aSuccessCB), - holder](const ServiceWorkerRegistrationDescriptor& aDescriptor) { - holder->Complete(); - successCB(aDescriptor); - }, - [failureCB = std::move(aFailureCB), - holder](const CopyableErrorResult& aResult) { - holder->Complete(); - failureCB(CopyableErrorResult(aResult)); - }) + ->Then( + global->EventTargetFor(TaskCategory::Other), __func__, + [successCB = std::move(aSuccessCB), + holder](const ServiceWorkerRegistrationDescriptor& aDescriptor) { + holder->Complete(); + successCB(aDescriptor); + }, + [failureCB = std::move(aFailureCB), + holder](const CopyableErrorResult& aResult) { + holder->Complete(); + failureCB(CopyableErrorResult(aResult)); + }) ->Track(*holder); } diff --git a/dom/serviceworkers/ServiceWorkerContainerParent.cpp b/dom/serviceworkers/ServiceWorkerContainerParent.cpp index 336b31bf0595f..2000ee2187557 100644 --- a/dom/serviceworkers/ServiceWorkerContainerParent.cpp +++ b/dom/serviceworkers/ServiceWorkerContainerParent.cpp @@ -79,18 +79,19 @@ IPCResult ServiceWorkerContainerParent::RecvGetRegistrations( } mProxy->GetRegistrations(ClientInfo(aClientInfo)) - ->Then(GetCurrentThreadSerialEventTarget(), __func__, - [aResolver]( - const nsTArray& aList) { - IPCServiceWorkerRegistrationDescriptorList ipcList; - for (auto& desc : aList) { - ipcList.values().AppendElement(desc.ToIPC()); - } - aResolver(std::move(ipcList)); - }, - [aResolver](const CopyableErrorResult& aResult) { - aResolver(aResult); - }); + ->Then( + GetCurrentThreadSerialEventTarget(), __func__, + [aResolver]( + const nsTArray& aList) { + IPCServiceWorkerRegistrationDescriptorList ipcList; + for (auto& desc : aList) { + ipcList.values().AppendElement(desc.ToIPC()); + } + aResolver(std::move(ipcList)); + }, + [aResolver](const CopyableErrorResult& aResult) { + aResolver(aResult); + }); return IPC_OK(); } diff --git a/dom/serviceworkers/ServiceWorkerManager.cpp b/dom/serviceworkers/ServiceWorkerManager.cpp index 38051a0581fff..0d3be76e1f9f7 100644 --- a/dom/serviceworkers/ServiceWorkerManager.cpp +++ b/dom/serviceworkers/ServiceWorkerManager.cpp @@ -2452,14 +2452,15 @@ void ServiceWorkerManager::UpdateClientControllers( // If we fail to control the client, then automatically remove it // from our list of controlled clients. - p->Then(SystemGroup::EventTargetFor(TaskCategory::Other), __func__, - [](bool) { - // do nothing on success - }, - [self, clientInfo = handle->Info()](nsresult aRv) { - // failed to control, forget about this client - self->StopControllingClient(clientInfo); - }); + p->Then( + SystemGroup::EventTargetFor(TaskCategory::Other), __func__, + [](bool) { + // do nothing on success + }, + [self, clientInfo = handle->Info()](nsresult aRv) { + // failed to control, forget about this client + self->StopControllingClient(clientInfo); + }); } } diff --git a/dom/serviceworkers/ServiceWorkerRegistrationImpl.cpp b/dom/serviceworkers/ServiceWorkerRegistrationImpl.cpp index ae402caf35deb..fdf4fb7bb434a 100644 --- a/dom/serviceworkers/ServiceWorkerRegistrationImpl.cpp +++ b/dom/serviceworkers/ServiceWorkerRegistrationImpl.cpp @@ -504,17 +504,18 @@ void ServiceWorkerRegistrationMainThread::Update( global); cb->Promise() - ->Then(global->EventTargetFor(TaskCategory::Other), __func__, - [successCB = std::move(aSuccessCB), - holder](const ServiceWorkerRegistrationDescriptor& aDescriptor) { - holder->Complete(); - successCB(aDescriptor); - }, - [failureCB = std::move(aFailureCB), - holder](const CopyableErrorResult& aRv) { - holder->Complete(); - failureCB(CopyableErrorResult(aRv)); - }) + ->Then( + global->EventTargetFor(TaskCategory::Other), __func__, + [successCB = std::move(aSuccessCB), + holder](const ServiceWorkerRegistrationDescriptor& aDescriptor) { + holder->Complete(); + successCB(aDescriptor); + }, + [failureCB = std::move(aFailureCB), + holder](const CopyableErrorResult& aRv) { + holder->Complete(); + failureCB(CopyableErrorResult(aRv)); + }) ->Track(*holder); } @@ -555,15 +556,16 @@ void ServiceWorkerRegistrationMainThread::Unregister( auto holder = MakeRefPtr>(global); cb->Promise() - ->Then(global->EventTargetFor(TaskCategory::Other), __func__, - [successCB = std::move(aSuccessCB), holder](bool aResult) { - holder->Complete(); - successCB(aResult); - }, - [failureCB = std::move(aFailureCB), holder](nsresult aRv) { - holder->Complete(); - failureCB(CopyableErrorResult(aRv)); - }) + ->Then( + global->EventTargetFor(TaskCategory::Other), __func__, + [successCB = std::move(aSuccessCB), holder](bool aResult) { + holder->Complete(); + successCB(aResult); + }, + [failureCB = std::move(aFailureCB), holder](nsresult aRv) { + holder->Complete(); + failureCB(CopyableErrorResult(aRv)); + }) ->Track(*holder); } @@ -769,17 +771,18 @@ void ServiceWorkerRegistrationWorkerThread::Update( global); promise - ->Then(global->EventTargetFor(TaskCategory::Other), __func__, - [successCB = std::move(aSuccessCB), - holder](const ServiceWorkerRegistrationDescriptor& aDescriptor) { - holder->Complete(); - successCB(aDescriptor); - }, - [failureCB = std::move(aFailureCB), - holder](const CopyableErrorResult& aRv) { - holder->Complete(); - failureCB(CopyableErrorResult(aRv)); - }) + ->Then( + global->EventTargetFor(TaskCategory::Other), __func__, + [successCB = std::move(aSuccessCB), + holder](const ServiceWorkerRegistrationDescriptor& aDescriptor) { + holder->Complete(); + successCB(aDescriptor); + }, + [failureCB = std::move(aFailureCB), + holder](const CopyableErrorResult& aRv) { + holder->Complete(); + failureCB(CopyableErrorResult(aRv)); + }) ->Track(*holder); RefPtr r = new SWRUpdateRunnable( @@ -824,15 +827,16 @@ void ServiceWorkerRegistrationWorkerThread::Unregister( auto holder = MakeRefPtr>(global); promise - ->Then(global->EventTargetFor(TaskCategory::Other), __func__, - [successCB = std::move(aSuccessCB), holder](bool aResult) { - holder->Complete(); - successCB(aResult); - }, - [failureCB = std::move(aFailureCB), holder](nsresult aRv) { - holder->Complete(); - failureCB(CopyableErrorResult(aRv)); - }) + ->Then( + global->EventTargetFor(TaskCategory::Other), __func__, + [successCB = std::move(aSuccessCB), holder](bool aResult) { + holder->Complete(); + successCB(aResult); + }, + [failureCB = std::move(aFailureCB), holder](nsresult aRv) { + holder->Complete(); + failureCB(CopyableErrorResult(aRv)); + }) ->Track(*holder); RefPtr r = diff --git a/dom/serviceworkers/test/gtest/TestReadWrite.cpp b/dom/serviceworkers/test/gtest/TestReadWrite.cpp index a29c55abf2ea3..19b8930458b23 100644 --- a/dom/serviceworkers/test/gtest/TestReadWrite.cpp +++ b/dom/serviceworkers/test/gtest/TestReadWrite.cpp @@ -81,9 +81,11 @@ bool CreateFile(const nsACString& aData) { return true; } -TEST(ServiceWorkerRegistrar, TestNoFile) { +TEST(ServiceWorkerRegistrar, TestNoFile) +{ nsCOMPtr file = GetFile(); - ASSERT_TRUE(file) << "GetFile must return a nsIFIle"; + ASSERT_TRUE(file) + << "GetFile must return a nsIFIle"; bool exists; nsresult rv = file->Exists(&exists); @@ -104,8 +106,10 @@ TEST(ServiceWorkerRegistrar, TestNoFile) { << "No data should be found in an empty file"; } -TEST(ServiceWorkerRegistrar, TestEmptyFile) { - ASSERT_TRUE(CreateFile(EmptyCString())) << "CreateFile should not fail"; +TEST(ServiceWorkerRegistrar, TestEmptyFile) +{ + ASSERT_TRUE(CreateFile(EmptyCString())) + << "CreateFile should not fail"; RefPtr swr = new ServiceWorkerRegistrarTest; @@ -117,10 +121,11 @@ TEST(ServiceWorkerRegistrar, TestEmptyFile) { << "No data should be found in an empty file"; } -TEST(ServiceWorkerRegistrar, TestRightVersionFile) { +TEST(ServiceWorkerRegistrar, TestRightVersionFile) +{ ASSERT_TRUE( CreateFile(NS_LITERAL_CSTRING(SERVICEWORKERREGISTRAR_VERSION "\n"))) - << "CreateFile should not fail"; + << "CreateFile should not fail"; RefPtr swr = new ServiceWorkerRegistrarTest; @@ -133,10 +138,11 @@ TEST(ServiceWorkerRegistrar, TestRightVersionFile) { << "No data should be found in an empty file"; } -TEST(ServiceWorkerRegistrar, TestWrongVersionFile) { +TEST(ServiceWorkerRegistrar, TestWrongVersionFile) +{ ASSERT_TRUE( CreateFile(NS_LITERAL_CSTRING(SERVICEWORKERREGISTRAR_VERSION "bla\n"))) - << "CreateFile should not fail"; + << "CreateFile should not fail"; RefPtr swr = new ServiceWorkerRegistrarTest; @@ -149,7 +155,8 @@ TEST(ServiceWorkerRegistrar, TestWrongVersionFile) { << "No data should be found in an empty file"; } -TEST(ServiceWorkerRegistrar, TestReadData) { +TEST(ServiceWorkerRegistrar, TestReadData) +{ nsAutoCString buffer(SERVICEWORKERREGISTRAR_VERSION "\n"); buffer.AppendLiteral("^appId=123&inBrowser=1\n"); @@ -182,7 +189,8 @@ TEST(ServiceWorkerRegistrar, TestReadData) { buffer.AppendLiteral("\n"); buffer.Append(SERVICEWORKERREGISTRAR_TERMINATOR "\n"); - ASSERT_TRUE(CreateFile(buffer)) << "CreateFile should not fail"; + ASSERT_TRUE(CreateFile(buffer)) + << "CreateFile should not fail"; RefPtr swr = new ServiceWorkerRegistrarTest; @@ -233,9 +241,10 @@ TEST(ServiceWorkerRegistrar, TestReadData) { ASSERT_EQ((int64_t)ts, data[1].lastUpdateTime()); } -TEST(ServiceWorkerRegistrar, TestDeleteData) { +TEST(ServiceWorkerRegistrar, TestDeleteData) +{ ASSERT_TRUE(CreateFile(NS_LITERAL_CSTRING("Foobar"))) - << "CreateFile should not fail"; + << "CreateFile should not fail"; RefPtr swr = new ServiceWorkerRegistrarTest; @@ -250,7 +259,8 @@ TEST(ServiceWorkerRegistrar, TestDeleteData) { ASSERT_FALSE(exists) << "The file should not exist after a DeleteData()."; } -TEST(ServiceWorkerRegistrar, TestWriteData) { +TEST(ServiceWorkerRegistrar, TestWriteData) +{ { RefPtr swr = new ServiceWorkerRegistrarTest; @@ -332,7 +342,8 @@ TEST(ServiceWorkerRegistrar, TestWriteData) { } } -TEST(ServiceWorkerRegistrar, TestVersion2Migration) { +TEST(ServiceWorkerRegistrar, TestVersion2Migration) +{ nsAutoCString buffer( "2" "\n"); @@ -349,7 +360,8 @@ TEST(ServiceWorkerRegistrar, TestVersion2Migration) { "1\nactiveCache 1\nwaitingCache 1\n"); buffer.AppendLiteral(SERVICEWORKERREGISTRAR_TERMINATOR "\n"); - ASSERT_TRUE(CreateFile(buffer)) << "CreateFile should not fail"; + ASSERT_TRUE(CreateFile(buffer)) + << "CreateFile should not fail"; RefPtr swr = new ServiceWorkerRegistrarTest; @@ -402,7 +414,8 @@ TEST(ServiceWorkerRegistrar, TestVersion2Migration) { ASSERT_EQ((int64_t)0, data[1].lastUpdateTime()); } -TEST(ServiceWorkerRegistrar, TestVersion3Migration) { +TEST(ServiceWorkerRegistrar, TestVersion3Migration) +{ nsAutoCString buffer( "3" "\n"); @@ -417,7 +430,8 @@ TEST(ServiceWorkerRegistrar, TestVersion3Migration) { "spec 1\nhttps://scope_1.org\ncurrentWorkerURL 1\ncacheName 1\n"); buffer.AppendLiteral(SERVICEWORKERREGISTRAR_TERMINATOR "\n"); - ASSERT_TRUE(CreateFile(buffer)) << "CreateFile should not fail"; + ASSERT_TRUE(CreateFile(buffer)) + << "CreateFile should not fail"; RefPtr swr = new ServiceWorkerRegistrarTest; @@ -468,7 +482,8 @@ TEST(ServiceWorkerRegistrar, TestVersion3Migration) { ASSERT_EQ((int64_t)0, data[1].lastUpdateTime()); } -TEST(ServiceWorkerRegistrar, TestVersion4Migration) { +TEST(ServiceWorkerRegistrar, TestVersion4Migration) +{ nsAutoCString buffer( "4" "\n"); @@ -483,7 +498,8 @@ TEST(ServiceWorkerRegistrar, TestVersion4Migration) { "https://scope_1.org\ncurrentWorkerURL 1\ncacheName 1\n"); buffer.AppendLiteral(SERVICEWORKERREGISTRAR_TERMINATOR "\n"); - ASSERT_TRUE(CreateFile(buffer)) << "CreateFile should not fail"; + ASSERT_TRUE(CreateFile(buffer)) + << "CreateFile should not fail"; RefPtr swr = new ServiceWorkerRegistrarTest; @@ -536,7 +552,8 @@ TEST(ServiceWorkerRegistrar, TestVersion4Migration) { ASSERT_EQ((int64_t)0, data[1].lastUpdateTime()); } -TEST(ServiceWorkerRegistrar, TestVersion5Migration) { +TEST(ServiceWorkerRegistrar, TestVersion5Migration) +{ nsAutoCString buffer( "5" "\n"); @@ -553,7 +570,8 @@ TEST(ServiceWorkerRegistrar, TestVersion5Migration) { buffer.AppendLiteral("cacheName 1\n"); buffer.AppendLiteral(SERVICEWORKERREGISTRAR_TERMINATOR "\n"); - ASSERT_TRUE(CreateFile(buffer)) << "CreateFile should not fail"; + ASSERT_TRUE(CreateFile(buffer)) + << "CreateFile should not fail"; RefPtr swr = new ServiceWorkerRegistrarTest; @@ -604,7 +622,8 @@ TEST(ServiceWorkerRegistrar, TestVersion5Migration) { ASSERT_EQ((int64_t)0, data[1].lastUpdateTime()); } -TEST(ServiceWorkerRegistrar, TestVersion6Migration) { +TEST(ServiceWorkerRegistrar, TestVersion6Migration) +{ nsAutoCString buffer( "6" "\n"); @@ -625,7 +644,8 @@ TEST(ServiceWorkerRegistrar, TestVersion6Migration) { buffer.AppendLiteral("\n"); buffer.AppendLiteral(SERVICEWORKERREGISTRAR_TERMINATOR "\n"); - ASSERT_TRUE(CreateFile(buffer)) << "CreateFile should not fail"; + ASSERT_TRUE(CreateFile(buffer)) + << "CreateFile should not fail"; RefPtr swr = new ServiceWorkerRegistrarTest; @@ -676,7 +696,8 @@ TEST(ServiceWorkerRegistrar, TestVersion6Migration) { ASSERT_EQ((int64_t)0, data[1].lastUpdateTime()); } -TEST(ServiceWorkerRegistrar, TestVersion7Migration) { +TEST(ServiceWorkerRegistrar, TestVersion7Migration) +{ nsAutoCString buffer( "7" "\n"); @@ -710,7 +731,8 @@ TEST(ServiceWorkerRegistrar, TestVersion7Migration) { buffer.AppendLiteral("\n"); buffer.AppendLiteral(SERVICEWORKERREGISTRAR_TERMINATOR "\n"); - ASSERT_TRUE(CreateFile(buffer)) << "CreateFile should not fail"; + ASSERT_TRUE(CreateFile(buffer)) + << "CreateFile should not fail"; RefPtr swr = new ServiceWorkerRegistrarTest; @@ -761,7 +783,8 @@ TEST(ServiceWorkerRegistrar, TestVersion7Migration) { ASSERT_EQ((int64_t)ts, data[1].lastUpdateTime()); } -TEST(ServiceWorkerRegistrar, TestDedupeRead) { +TEST(ServiceWorkerRegistrar, TestDedupeRead) +{ nsAutoCString buffer( "3" "\n"); @@ -793,7 +816,8 @@ TEST(ServiceWorkerRegistrar, TestDedupeRead) { "spec 3\nhttps://scope_1.org\ncurrentWorkerURL 1\ncacheName 1\n"); buffer.AppendLiteral(SERVICEWORKERREGISTRAR_TERMINATOR "\n"); - ASSERT_TRUE(CreateFile(buffer)) << "CreateFile should not fail"; + ASSERT_TRUE(CreateFile(buffer)) + << "CreateFile should not fail"; RefPtr swr = new ServiceWorkerRegistrarTest; @@ -844,7 +868,8 @@ TEST(ServiceWorkerRegistrar, TestDedupeRead) { ASSERT_EQ((int64_t)0, data[1].lastUpdateTime()); } -TEST(ServiceWorkerRegistrar, TestDedupeWrite) { +TEST(ServiceWorkerRegistrar, TestDedupeWrite) +{ { RefPtr swr = new ServiceWorkerRegistrarTest; diff --git a/dom/webauthn/U2FTokenManager.cpp b/dom/webauthn/U2FTokenManager.cpp index 4a62a028f514e..5b9bd2322cc10 100644 --- a/dom/webauthn/U2FTokenManager.cpp +++ b/dom/webauthn/U2FTokenManager.cpp @@ -333,22 +333,23 @@ void U2FTokenManager::DoRegister(const WebAuthnMakeCredentialInfo& aInfo, mozilla::TimeStamp startTime = mozilla::TimeStamp::Now(); mTokenManagerImpl->Register(aInfo, aForceNoneAttestation) - ->Then(GetCurrentThreadSerialEventTarget(), __func__, - [tid, startTime](WebAuthnMakeCredentialResult&& aResult) { - U2FTokenManager* mgr = U2FTokenManager::Get(); - mgr->MaybeConfirmRegister(tid, aResult); - Telemetry::ScalarAdd(Telemetry::ScalarID::SECURITY_WEBAUTHN_USED, - NS_LITERAL_STRING("U2FRegisterFinish"), 1); - Telemetry::AccumulateTimeDelta( - Telemetry::WEBAUTHN_CREATE_CREDENTIAL_MS, startTime); - }, - [tid](nsresult rv) { - MOZ_ASSERT(NS_FAILED(rv)); - U2FTokenManager* mgr = U2FTokenManager::Get(); - mgr->MaybeAbortRegister(tid, rv); - Telemetry::ScalarAdd(Telemetry::ScalarID::SECURITY_WEBAUTHN_USED, - NS_LITERAL_STRING("U2FRegisterAbort"), 1); - }) + ->Then( + GetCurrentThreadSerialEventTarget(), __func__, + [tid, startTime](WebAuthnMakeCredentialResult&& aResult) { + U2FTokenManager* mgr = U2FTokenManager::Get(); + mgr->MaybeConfirmRegister(tid, aResult); + Telemetry::ScalarAdd(Telemetry::ScalarID::SECURITY_WEBAUTHN_USED, + NS_LITERAL_STRING("U2FRegisterFinish"), 1); + Telemetry::AccumulateTimeDelta( + Telemetry::WEBAUTHN_CREATE_CREDENTIAL_MS, startTime); + }, + [tid](nsresult rv) { + MOZ_ASSERT(NS_FAILED(rv)); + U2FTokenManager* mgr = U2FTokenManager::Get(); + mgr->MaybeAbortRegister(tid, rv); + Telemetry::ScalarAdd(Telemetry::ScalarID::SECURITY_WEBAUTHN_USED, + NS_LITERAL_STRING("U2FRegisterAbort"), 1); + }) ->Track(mRegisterPromise); } @@ -391,22 +392,23 @@ void U2FTokenManager::Sign(PWebAuthnTransactionParent* aTransactionParent, mozilla::TimeStamp startTime = mozilla::TimeStamp::Now(); mTokenManagerImpl->Sign(aTransactionInfo) - ->Then(GetCurrentThreadSerialEventTarget(), __func__, - [tid, startTime](WebAuthnGetAssertionResult&& aResult) { - U2FTokenManager* mgr = U2FTokenManager::Get(); - mgr->MaybeConfirmSign(tid, aResult); - Telemetry::ScalarAdd(Telemetry::ScalarID::SECURITY_WEBAUTHN_USED, - NS_LITERAL_STRING("U2FSignFinish"), 1); - Telemetry::AccumulateTimeDelta( - Telemetry::WEBAUTHN_GET_ASSERTION_MS, startTime); - }, - [tid](nsresult rv) { - MOZ_ASSERT(NS_FAILED(rv)); - U2FTokenManager* mgr = U2FTokenManager::Get(); - mgr->MaybeAbortSign(tid, rv); - Telemetry::ScalarAdd(Telemetry::ScalarID::SECURITY_WEBAUTHN_USED, - NS_LITERAL_STRING("U2FSignAbort"), 1); - }) + ->Then( + GetCurrentThreadSerialEventTarget(), __func__, + [tid, startTime](WebAuthnGetAssertionResult&& aResult) { + U2FTokenManager* mgr = U2FTokenManager::Get(); + mgr->MaybeConfirmSign(tid, aResult); + Telemetry::ScalarAdd(Telemetry::ScalarID::SECURITY_WEBAUTHN_USED, + NS_LITERAL_STRING("U2FSignFinish"), 1); + Telemetry::AccumulateTimeDelta(Telemetry::WEBAUTHN_GET_ASSERTION_MS, + startTime); + }, + [tid](nsresult rv) { + MOZ_ASSERT(NS_FAILED(rv)); + U2FTokenManager* mgr = U2FTokenManager::Get(); + mgr->MaybeAbortSign(tid, rv); + Telemetry::ScalarAdd(Telemetry::ScalarID::SECURITY_WEBAUTHN_USED, + NS_LITERAL_STRING("U2FSignAbort"), 1); + }) ->Track(mSignPromise); } diff --git a/dom/workers/WorkerDebugger.cpp b/dom/workers/WorkerDebugger.cpp index 48ef2c212b08e..2f5c91fdebbf1 100644 --- a/dom/workers/WorkerDebugger.cpp +++ b/dom/workers/WorkerDebugger.cpp @@ -517,18 +517,19 @@ RefPtr WorkerDebugger::ReportPerformanceInfo() { SystemGroup::AbstractMainThreadFor(TaskCategory::Performance); return CollectMemoryInfo(top, mainThread) - ->Then(mainThread, __func__, - [workerRef, url, pid, perfId, windowID, duration, isTopLevel, - items](const PerformanceMemoryInfo& aMemoryInfo) { - return PerformanceInfoPromise::CreateAndResolve( - PerformanceInfo(url, pid, windowID, duration, perfId, true, - isTopLevel, aMemoryInfo, items), - __func__); - }, - [workerRef]() { - return PerformanceInfoPromise::CreateAndReject(NS_ERROR_FAILURE, - __func__); - }); + ->Then( + mainThread, __func__, + [workerRef, url, pid, perfId, windowID, duration, isTopLevel, + items](const PerformanceMemoryInfo& aMemoryInfo) { + return PerformanceInfoPromise::CreateAndResolve( + PerformanceInfo(url, pid, windowID, duration, perfId, true, + isTopLevel, aMemoryInfo, items), + __func__); + }, + [workerRef]() { + return PerformanceInfoPromise::CreateAndReject(NS_ERROR_FAILURE, + __func__); + }); } } // namespace dom diff --git a/dom/xhr/XMLHttpRequestMainThread.cpp b/dom/xhr/XMLHttpRequestMainThread.cpp index 686d0e7ac5cb8..d49fb2c38a6c6 100644 --- a/dom/xhr/XMLHttpRequestMainThread.cpp +++ b/dom/xhr/XMLHttpRequestMainThread.cpp @@ -1491,8 +1491,8 @@ nsresult XMLHttpRequestMainThread::StreamReaderFunc( xmlHttpRequest->MaybeCreateBlobStorage(); rv = xmlHttpRequest->mBlobStorage->Append(fromRawSegment, count); } else if (xmlHttpRequest->mResponseType == - XMLHttpRequestResponseType::Arraybuffer && - !xmlHttpRequest->mIsMappedArrayBuffer) { + XMLHttpRequestResponseType::Arraybuffer && + !xmlHttpRequest->mIsMappedArrayBuffer) { // get the initial capacity to something reasonable to avoid a bunch of // reallocs right at the start if (xmlHttpRequest->mArrayBufferBuilder.capacity() == 0) diff --git a/dom/xslt/xml/txXMLUtils.cpp b/dom/xslt/xml/txXMLUtils.cpp index 209f42f39a140..0688939ccb257 100644 --- a/dom/xslt/xml/txXMLUtils.cpp +++ b/dom/xslt/xml/txXMLUtils.cpp @@ -130,7 +130,9 @@ void XMLUtils::normalizePIValue(nsAString& piValue) { } break; } - default: { break; } + default: { + break; + } } piValue.Append(ch); prevCh = ch; diff --git a/dom/xslt/xpath/XPathResult.cpp b/dom/xslt/xpath/XPathResult.cpp index 2012b5036d6a7..f7d821d553d0d 100644 --- a/dom/xslt/xpath/XPathResult.cpp +++ b/dom/xslt/xpath/XPathResult.cpp @@ -165,7 +165,9 @@ nsresult XPathResult::SetExprResult(txAExprResult* aExprResult, mResult->stringValue(mStringResult); break; } - default: { MOZ_ASSERT(isNode() || isIterator() || isSnapshot()); } + default: { + MOZ_ASSERT(isNode() || isIterator() || isSnapshot()); + } } if (aExprResult->getResultType() == txAExprResult::NODESET) { diff --git a/dom/xslt/xpath/txCoreFunctionCall.cpp b/dom/xslt/xpath/txCoreFunctionCall.cpp index ad88f6f074065..1097da6083bba 100644 --- a/dom/xslt/xpath/txCoreFunctionCall.cpp +++ b/dom/xslt/xpath/txCoreFunctionCall.cpp @@ -187,7 +187,9 @@ nsresult txCoreFunctionCall::evaluate(txIEvalContext* aContext, return NS_OK; } - default: { MOZ_CRASH("Unexpected mType?!"); } + default: { + MOZ_CRASH("Unexpected mType?!"); + } } MOZ_CRASH("Inner mType switch should have returned!"); } diff --git a/dom/xslt/xpath/txRelationalExpr.cpp b/dom/xslt/xpath/txRelationalExpr.cpp index d65535765f01d..df6da87ca8df3 100644 --- a/dom/xslt/xpath/txRelationalExpr.cpp +++ b/dom/xslt/xpath/txRelationalExpr.cpp @@ -122,7 +122,9 @@ bool RelationalExpr::compareResults(txIEvalContext* aContext, case GREATER_OR_EQUAL: { return (leftDbl >= rightDbl); } - default: { MOZ_ASSERT_UNREACHABLE("We should have caught all cases"); } + default: { + MOZ_ASSERT_UNREACHABLE("We should have caught all cases"); + } } return false; diff --git a/dom/xslt/xpath/txResultRecycler.cpp b/dom/xslt/xpath/txResultRecycler.cpp index 2ad62038274b0..c0c0edc21aabc 100644 --- a/dom/xslt/xpath/txResultRecycler.cpp +++ b/dom/xslt/xpath/txResultRecycler.cpp @@ -56,7 +56,9 @@ void txResultRecycler::recycle(txAExprResult* aResult) { } return; } - default: { delete aResult; } + default: { + delete aResult; + } } } diff --git a/dom/xslt/xslt/txBufferingHandler.cpp b/dom/xslt/xslt/txBufferingHandler.cpp index 82d2c4ca8bb64..9d8b34ddeb705 100644 --- a/dom/xslt/xslt/txBufferingHandler.cpp +++ b/dom/xslt/xslt/txBufferingHandler.cpp @@ -354,7 +354,9 @@ static nsresult flushTransaction(txOutputTransaction* aTransaction, return aHandler->startElement( transaction->mPrefix, transaction->mLocalName, transaction->mNsID); } - default: { MOZ_ASSERT_UNREACHABLE("Unexpected transaction type"); } + default: { + MOZ_ASSERT_UNREACHABLE("Unexpected transaction type"); + } } return NS_ERROR_UNEXPECTED; diff --git a/dom/xslt/xslt/txMozillaXSLTProcessor.cpp b/dom/xslt/xslt/txMozillaXSLTProcessor.cpp index 779e8efe25940..80552ed010681 100644 --- a/dom/xslt/xslt/txMozillaXSLTProcessor.cpp +++ b/dom/xslt/xslt/txMozillaXSLTProcessor.cpp @@ -808,7 +808,9 @@ nsresult txMozillaXSLTProcessor::SetParameter(const nsAString& aNamespaceURI, break; } - default: { return NS_ERROR_FAILURE; } + default: { + return NS_ERROR_FAILURE; + } } int32_t nsId = kNameSpaceID_Unknown; diff --git a/editor/spellchecker/EditorSpellCheck.cpp b/editor/spellchecker/EditorSpellCheck.cpp index dea1ff823ee02..ad808524f2167 100644 --- a/editor/spellchecker/EditorSpellCheck.cpp +++ b/editor/spellchecker/EditorSpellCheck.cpp @@ -806,32 +806,33 @@ nsresult EditorSpellCheck::DictionaryFetched(DictionaryFetcher* aFetcher) { RefPtr self = this; RefPtr fetcher = aFetcher; mSpellChecker->SetCurrentDictionaryFromList(tryDictList) - ->Then(GetMainThreadSerialEventTarget(), __func__, - [self, fetcher]() { + ->Then( + GetMainThreadSerialEventTarget(), __func__, + [self, fetcher]() { #ifdef DEBUG_DICT - printf("***** Assigned from content preferences |%s|\n", - NS_ConvertUTF16toUTF8(dictName).get()); + printf("***** Assigned from content preferences |%s|\n", + NS_ConvertUTF16toUTF8(dictName).get()); #endif - // We take an early exit here, so let's not forget to clear - // the word list. - self->DeleteSuggestedWordList(); - - self->EndUpdateDictionary(); - if (fetcher->mCallback) { - fetcher->mCallback->EditorSpellCheckDone(); - } - }, - [self, fetcher](nsresult aError) { - if (aError == NS_ERROR_ABORT) { - return; - } - // May be dictionary was uninstalled ? - // Clear the content preference and continue. - ClearCurrentDictionary(self->mEditor); - - // Priority 2 or later will handled by the following - self->SetFallbackDictionary(fetcher); - }); + // We take an early exit here, so let's not forget to clear + // the word list. + self->DeleteSuggestedWordList(); + + self->EndUpdateDictionary(); + if (fetcher->mCallback) { + fetcher->mCallback->EditorSpellCheckDone(); + } + }, + [self, fetcher](nsresult aError) { + if (aError == NS_ERROR_ABORT) { + return; + } + // May be dictionary was uninstalled ? + // Clear the content preference and continue. + ClearCurrentDictionary(self->mEditor); + + // Priority 2 or later will handled by the following + self->SetFallbackDictionary(fetcher); + }); return NS_OK; } } diff --git a/editor/txmgr/tests/TestTXMgr.cpp b/editor/txmgr/tests/TestTXMgr.cpp index a5b9c0dea65e0..8c4add2d60098 100644 --- a/editor/txmgr/tests/TestTXMgr.cpp +++ b/editor/txmgr/tests/TestTXMgr.cpp @@ -1179,7 +1179,8 @@ void quick_test(TestTransactionFactory *factory) { EXPECT_TRUE(NS_SUCCEEDED(rv)); } -TEST(TestTXMgr, SimpleTest) { +TEST(TestTXMgr, SimpleTest) +{ /******************************************************************* * * Initialize globals for test. @@ -1201,7 +1202,8 @@ TEST(TestTXMgr, SimpleTest) { quick_test(&factory); } -TEST(TestTXMgr, AggregationTest) { +TEST(TestTXMgr, AggregationTest) +{ /******************************************************************* * * Initialize globals for test. @@ -1806,7 +1808,8 @@ void quick_batch_test(TestTransactionFactory *factory) { EXPECT_TRUE(NS_SUCCEEDED(rv)); } -TEST(TestTXMgr, SimpleBatchTest) { +TEST(TestTXMgr, SimpleBatchTest) +{ /******************************************************************* * * Initialize globals for test. @@ -1827,7 +1830,8 @@ TEST(TestTXMgr, SimpleBatchTest) { quick_batch_test(&factory); } -TEST(TestTXMgr, AggregationBatchTest) { +TEST(TestTXMgr, AggregationBatchTest) +{ /******************************************************************* * * Initialize globals for test. @@ -1919,7 +1923,8 @@ void stress_test(TestTransactionFactory *factory, int32_t iterations) { EXPECT_TRUE(NS_SUCCEEDED(rv)); } -TEST(TestTXMgr, SimpleStressTest) { +TEST(TestTXMgr, SimpleStressTest) +{ /******************************************************************* * * Initialize globals for test. @@ -1949,7 +1954,8 @@ TEST(TestTXMgr, SimpleStressTest) { stress_test(&factory, iterations); } -TEST(TestTXMgr, AggregationStressTest) { +TEST(TestTXMgr, AggregationStressTest) +{ /******************************************************************* * * Initialize globals for test. @@ -1979,7 +1985,8 @@ TEST(TestTXMgr, AggregationStressTest) { stress_test(&factory, iterations); } -TEST(TestTXMgr, AggregationBatchStressTest) { +TEST(TestTXMgr, AggregationBatchStressTest) +{ /******************************************************************* * * Initialize globals for test. diff --git a/extensions/cookie/nsPermissionManager.cpp b/extensions/cookie/nsPermissionManager.cpp index 123b6ac9d26ff..e07cabbabd4c9 100644 --- a/extensions/cookie/nsPermissionManager.cpp +++ b/extensions/cookie/nsPermissionManager.cpp @@ -3430,12 +3430,13 @@ nsPermissionManager::WhenPermissionsAvailable(nsIPrincipal* aPrincipal, RefPtr runnable = aRunnable; GenericPromise::All(thread, promises) - ->Then(thread, __func__, [runnable]() { runnable->Run(); }, - []() { - NS_WARNING( - "nsPermissionManager permission promise rejected. We're " - "probably shutting down."); - }); + ->Then( + thread, __func__, [runnable]() { runnable->Run(); }, + []() { + NS_WARNING( + "nsPermissionManager permission promise rejected. We're " + "probably shutting down."); + }); return NS_OK; } diff --git a/gfx/2d/BlurLS3.cpp b/gfx/2d/BlurLS3.cpp index 85c6e26e7dbc9..18e28a99e4715 100644 --- a/gfx/2d/BlurLS3.cpp +++ b/gfx/2d/BlurLS3.cpp @@ -32,8 +32,8 @@ __m128i loadUnaligned128(__m128i *p) { "gsldlc1 %[vl], 0x7(%[p]) \n\t" "gsldrc1 %[vl], 0x0(%[p]) \n\t" ".set pop \n\t" - : [vh] "=f"(v.h), [vl] "=f"(v.l) - : [p] "r"(p) + : [ vh ] "=f"(v.h), [ vl ] "=f"(v.l) + : [ p ] "r"(p) : "memory"); return v; @@ -56,8 +56,8 @@ __m128i Divide(__m128i aValues, __m128i aDivisor) { "mthc1 %[tmp], %[maskl] \n\t" "mov.d %[maskh], %[maskl] \n\t" ".set pop \n\t" - : [rah] "=f"(ra.h), [ral] "=f"(ra.l), [maskh] "=f"(mask.h), - [maskl] "=f"(mask.l), [tmp] "=&r"(tmp)); + : [ rah ] "=f"(ra.h), [ ral ] "=f"(ra.l), [ maskh ] "=f"(mask.h), + [ maskl ] "=f"(mask.l), [ tmp ] "=&r"(tmp)); asm volatile( ".set push \n\t" @@ -69,12 +69,12 @@ __m128i Divide(__m128i aValues, __m128i aDivisor) { // the result is rounded. _mm_paddd(t1, t1, ra) _mm_psrld(t1, t1, srl32) _mm_paddd(t2, t2, ra) _mm_and(t2, t2, mask) _mm_or(p4321, t1, t2) ".set pop \n\t" - : [p4321h] "=&f"(p4321.h), [p4321l] "=&f"(p4321.l), [t1h] "=&f"(t1.h), - [t1l] "=&f"(t1.l), [t2h] "=&f"(t2.h), [t2l] "=&f"(t2.l), - [srl32] "=&f"(srl32), [tmp] "=&r"(tmp) - : [rah] "f"(ra.h), [ral] "f"(ra.l), [maskh] "f"(mask.h), - [maskl] "f"(mask.l), [avh] "f"(aValues.h), [avl] "f"(aValues.l), - [adh] "f"(aDivisor.h), [adl] "f"(aDivisor.l)); + : [ p4321h ] "=&f"(p4321.h), [ p4321l ] "=&f"(p4321.l), + [ t1h ] "=&f"(t1.h), [ t1l ] "=&f"(t1.l), [ t2h ] "=&f"(t2.h), + [ t2l ] "=&f"(t2.l), [ srl32 ] "=&f"(srl32), [ tmp ] "=&r"(tmp) + : [ rah ] "f"(ra.h), [ ral ] "f"(ra.l), [ maskh ] "f"(mask.h), + [ maskl ] "f"(mask.l), [ avh ] "f"(aValues.h), [ avl ] "f"(aValues.l), + [ adh ] "f"(aDivisor.h), [ adl ] "f"(aDivisor.l)); return p4321; } @@ -89,11 +89,11 @@ __m128i BlurFourPixels(const __m128i &aTopLeft, const __m128i &aTopRight, ".set push \n\t" ".set arch=loongson3a \n\t" _mm_psubw(val, abr, atr) _mm_psubw(val, val, abl) _mm_paddw(val, val, atl) ".set pop \n\t" - : [valh] "=&f"(values.h), [vall] "=&f"(values.l) - : [abrh] "f"(aBottomRight.h), [abrl] "f"(aBottomRight.l), - [atrh] "f"(aTopRight.h), [atrl] "f"(aTopRight.l), - [ablh] "f"(aBottomLeft.h), [abll] "f"(aBottomLeft.l), - [atlh] "f"(aTopLeft.h), [atll] "f"(aTopLeft.l)); + : [ valh ] "=&f"(values.h), [ vall ] "=&f"(values.l) + : [ abrh ] "f"(aBottomRight.h), [ abrl ] "f"(aBottomRight.l), + [ atrh ] "f"(aTopRight.h), [ atrl ] "f"(aTopRight.l), + [ ablh ] "f"(aBottomLeft.h), [ abll ] "f"(aBottomLeft.l), + [ atlh ] "f"(aTopLeft.h), [ atll ] "f"(aTopLeft.l)); return Divide(values, aDivisor); } @@ -203,8 +203,8 @@ void GenerateIntegralImage_LS3(int32_t aLeftInflation, int32_t aRightInflation, "mtc1 %[tmp], %[see] \n\t" "li %[tmp], 0x44 \n\t" "mtc1 %[tmp], %[s44] \n\t" _mm_xor(zero, zero, zero) ".set pop \n\t" - : [tmp] "=&r"(tmp), [s44] "=f"(s44), [see] "=f"(see), - [zeroh] "=f"(zero.h), [zerol] "=f"(zero.l)); + : [ tmp ] "=&r"(tmp), [ s44 ] "=f"(s44), [ see ] "=f"(see), + [ zeroh ] "=f"(zero.h), [ zerol ] "=f"(zero.l)); for (int y = aTopInflation + 1; y < (aSize.height + aTopInflation); y++) { __m128i currentRowSum; uint32_t *intRow = aIntegralImage + (y * stride32bit); @@ -215,7 +215,7 @@ void GenerateIntegralImage_LS3(int32_t aLeftInflation, int32_t aRightInflation, asm volatile( ".set push \n\t" ".set arch=loongson3a \n\t" _mm_xor(cr, cr, cr) ".set pop \n\t" - : [crh] "=f"(currentRowSum.h), [crl] "=f"(currentRowSum.l)); + : [ crh ] "=f"(currentRowSum.h), [ crl ] "=f"(currentRowSum.l)); for (int x = 0; x < aLeftInflation; x += 4) { __m128i sumPixels, t; asm volatile( @@ -227,8 +227,8 @@ void GenerateIntegralImage_LS3(int32_t aLeftInflation, int32_t aRightInflation, "pshufh %[sph], %[spl], %[s44] \n\t" "pshufh %[spl], %[spl], %[s44] \n\t" ".set pop \n\t" - : [sph] "=&f"(sumPixels.h), [spl] "=&f"(sumPixels.l) - : [pix] "r"(pixel), [s44] "f"(s44)); + : [ sph ] "=&f"(sumPixels.h), [ spl ] "=&f"(sumPixels.l) + : [ pix ] "r"(pixel), [ s44 ] "f"(s44)); sumPixels = AccumulatePixelSums(sumPixels); asm volatile ( ".set push \n\t" @@ -264,10 +264,10 @@ void GenerateIntegralImage_LS3(int32_t aLeftInflation, int32_t aRightInflation, "punpcklwd %[spl], %[spl], %[spl] \n\t" "mov.d %[sph], %[spl] \n\t" _mm_punpcklbh(sp, sp, zero) _mm_punpcklhw(sp, sp, zero) ".set pop \n\t" - : [sph] "=&f"(sumPixels.h), [spl] "=&f"(sumPixels.l), - [crh] "+f"(currentRowSum.h), [crl] "+f"(currentRowSum.l) - : [pix] "r"(pixels), [see] "f"(see), [zeroh] "f"(zero.h), - [zerol] "f"(zero.l)); + : [ sph ] "=&f"(sumPixels.h), [ spl ] "=&f"(sumPixels.l), + [ crh ] "+f"(currentRowSum.h), [ crl ] "+f"(currentRowSum.l) + : [ pix ] "r"(pixels), [ see ] "f"(see), [ zeroh ] "f"(zero.h), + [ zerol ] "f"(zero.l)); sumPixels = AccumulatePixelSums(sumPixels); asm volatile ( ".set push \n\t" @@ -305,8 +305,8 @@ void GenerateIntegralImage_LS3(int32_t aLeftInflation, int32_t aRightInflation, "punpcklwd %[crl], %[crl], %[crl] \n\t" "mov.d %[crh], %[crl] \n\t" ".set pop \n\t" - : [crh] "=f"(currentRowSum.h), [crl] "=f"(currentRowSum.l) - : [cr] "r"(intCurrentRowSum)); + : [ crh ] "=f"(currentRowSum.h), [ crl ] "=f"(currentRowSum.l) + : [ cr ] "r"(intCurrentRowSum)); break; } intCurrentRowSum += pixel; @@ -319,8 +319,8 @@ void GenerateIntegralImage_LS3(int32_t aLeftInflation, int32_t aRightInflation, "pshufh %[crl], %[crh], %[see] \n\t" "pshufh %[crh], %[crh], %[see] \n\t" ".set pop \n\t" - : [crh] "+f"(currentRowSum.h), [crl] "+f"(currentRowSum.l) - : [see] "f"(see)); + : [ crh ] "+f"(currentRowSum.h), [ crl ] "+f"(currentRowSum.l) + : [ see ] "f"(see)); } for (; x < integralImageSize.width; x += 4) { __m128i sumPixels, t; @@ -331,8 +331,8 @@ void GenerateIntegralImage_LS3(int32_t aLeftInflation, int32_t aRightInflation, "punpcklwd %[spl], %[spl], %[spl] \n\t" "mov.d %[sph], %[spl] \n\t" ".set pop \n\t" - : [sph] "=f"(sumPixels.h), [spl] "=f"(sumPixels.l) - : [pix] "r"(pixel)); + : [ sph ] "=f"(sumPixels.h), [ spl ] "=f"(sumPixels.l) + : [ pix ] "r"(pixel)); sumPixels = AccumulatePixelSums(sumPixels); asm volatile ( ".set push \n\t" @@ -432,9 +432,9 @@ void AlphaBoxBlur::BoxBlur_LS3(uint8_t *aData, int32_t aLeftLobe, "mtc1 %[rec], %[divl] \n\t" "punpcklwd %[divl], %[divl], %[divl] \n\t" "mov.d %[divh], %[divl] \n\t" _mm_xor(zero, zero, zero) ".set pop \n\t" - : [divh] "=f"(divisor.h), [divl] "=f"(divisor.l), [zeroh] "=f"(zero.h), - [zerol] "=f"(zero.l) - : [rec] "r"(reciprocal)); + : [ divh ] "=f"(divisor.h), [ divl ] "=f"(divisor.l), + [ zeroh ] "=f"(zero.h), [ zerol ] "=f"(zero.l) + : [ rec ] "r"(reciprocal)); // This points to the start of the rectangle within the IntegralImage that // overlaps the surface being blurred. diff --git a/gfx/2d/unittest/TestCairo.cpp b/gfx/2d/unittest/TestCairo.cpp index 7cd5a384b9c25..1f9530c55b5e6 100644 --- a/gfx/2d/unittest/TestCairo.cpp +++ b/gfx/2d/unittest/TestCairo.cpp @@ -27,7 +27,8 @@ static void TryCircle(double centerX, double centerY, double radius) { cairo_destroy(cairo); } -TEST(Cairo, Simple) { +TEST(Cairo, Simple) +{ TryCircle(0.0, 0.0, 14.0); TryCircle(0.0, 1.0, 22.4); TryCircle(1.0, 0.0, 1422.4); @@ -35,7 +36,8 @@ TEST(Cairo, Simple) { TryCircle(-10.0, 1.0, -2); } -TEST(Cairo, Bug825721) { +TEST(Cairo, Bug825721) +{ // OK: TryCircle(0.0, 0.0, 8761126469220696064.0); TryCircle(0.0, 1.0, 8761126469220696064.0); @@ -50,7 +52,8 @@ TEST(Cairo, Bug825721) { TryCircle(0.0, 1.0, 5761126469220696064.0); } -TEST(Cairo, Bug1063486) { +TEST(Cairo, Bug1063486) +{ double x1, y1, x2, y2; const double epsilon = .01; diff --git a/gfx/gl/GLReadTexImageHelper.cpp b/gfx/gl/GLReadTexImageHelper.cpp index 12ff1db5a9067..3ef5ac4faa6b2 100644 --- a/gfx/gl/GLReadTexImageHelper.cpp +++ b/gfx/gl/GLReadTexImageHelper.cpp @@ -328,7 +328,9 @@ void ReadPixelsIntoDataSurface(GLContext* gl, DataSourceSurface* dest) { readFormatGFX = SurfaceFormat::R5G6B5_UINT16; break; } - default: { MOZ_CRASH("GFX: Bad read format, read format."); } + default: { + MOZ_CRASH("GFX: Bad read format, read format."); + } } switch (readType) { @@ -347,7 +349,9 @@ void ReadPixelsIntoDataSurface(GLContext* gl, DataSourceSurface* dest) { readAlignment = 2; break; } - default: { MOZ_CRASH("GFX: Bad read type, read type."); } + default: { + MOZ_CRASH("GFX: Bad read type, read type."); + } } int32_t stride = dest->GetSize().width * BytesPerPixel(readFormatGFX); diff --git a/gfx/layers/ScrollableLayerGuid.h b/gfx/layers/ScrollableLayerGuid.h index 15204b1eb94a6..497786bce1dbf 100644 --- a/gfx/layers/ScrollableLayerGuid.h +++ b/gfx/layers/ScrollableLayerGuid.h @@ -108,7 +108,9 @@ template gfx::Log& operator<<(gfx::Log& log, const ScrollableLayerGuid& aGuid) { return log << nsPrintfCString("(0x%" PRIx64 ", %u, %" PRIu64 ")", - uint64_t(aGuid.mLayersId), aGuid.mPresShellId, aGuid.mScrollId).get(); + uint64_t(aGuid.mLayersId), aGuid.mPresShellId, + aGuid.mScrollId) + .get(); } } // namespace layers diff --git a/gfx/layers/TreeTraversal.h b/gfx/layers/TreeTraversal.h index 7a362130ee2ac..d05a19b0f523b 100644 --- a/gfx/layers/TreeTraversal.h +++ b/gfx/layers/TreeTraversal.h @@ -185,7 +185,8 @@ template auto ForEachNodePostOrder(Node aRoot, const PostAction& aPostAction) -> typename EnableIf::value, void>::Type { - ForEachNode(aRoot, [](Node aNode) {}, aPostAction); + ForEachNode( + aRoot, [](Node aNode) {}, aPostAction); } /* diff --git a/gfx/layers/composite/TextureHost.cpp b/gfx/layers/composite/TextureHost.cpp index 7691860eaacee..8536d95f84b7c 100644 --- a/gfx/layers/composite/TextureHost.cpp +++ b/gfx/layers/composite/TextureHost.cpp @@ -740,7 +740,9 @@ static bool IsCompatibleTextureSource(TextureSource* aTexture, return aTexture->GetFormat() == rgb.format() && aTexture->GetSize() == rgb.size(); } - default: { return false; } + default: { + return false; + } } } diff --git a/gfx/layers/d3d11/TextureD3D11.cpp b/gfx/layers/d3d11/TextureD3D11.cpp index c5fa9b2fef218..4a0175f8b6d68 100644 --- a/gfx/layers/d3d11/TextureD3D11.cpp +++ b/gfx/layers/d3d11/TextureD3D11.cpp @@ -728,7 +728,9 @@ already_AddRefed CreateTextureHostD3D11( aFlags, aDesc.get_SurfaceDescriptorDXGIYCbCr()); break; } - default: { MOZ_ASSERT_UNREACHABLE("Unsupported SurfaceDescriptor type"); } + default: { + MOZ_ASSERT_UNREACHABLE("Unsupported SurfaceDescriptor type"); + } } return result.forget(); } @@ -1044,7 +1046,9 @@ void DXGITextureHostD3D11::PushResourceUpdates( (aResources.*method)(aImageKeys[1], descriptor1, aExtID, bufferType, 1); break; } - default: { MOZ_ASSERT_UNREACHABLE("unexpected to be called"); } + default: { + MOZ_ASSERT_UNREACHABLE("unexpected to be called"); + } } } @@ -1079,7 +1083,9 @@ void DXGITextureHostD3D11::PushDisplayItems( aFilter); break; } - default: { MOZ_ASSERT_UNREACHABLE("unexpected to be called"); } + default: { + MOZ_ASSERT_UNREACHABLE("unexpected to be called"); + } } } diff --git a/gfx/layers/ipc/CompositableTransactionParent.cpp b/gfx/layers/ipc/CompositableTransactionParent.cpp index eb9fdcb736cb7..709831e238e3b 100644 --- a/gfx/layers/ipc/CompositableTransactionParent.cpp +++ b/gfx/layers/ipc/CompositableTransactionParent.cpp @@ -230,7 +230,9 @@ bool CompositableParentManager::ReceiveCompositableUpdate( } break; } - default: { MOZ_ASSERT(false, "bad type"); } + default: { + MOZ_ASSERT(false, "bad type"); + } } return true; @@ -247,7 +249,9 @@ void CompositableParentManager::DestroyActor(const OpDestroy& aOp) { ReleaseCompositable(aOp.get_CompositableHandle()); break; } - default: { MOZ_ASSERT(false, "unsupported type"); } + default: { + MOZ_ASSERT(false, "unsupported type"); + } } } diff --git a/gfx/layers/mlgpu/LayerManagerMLGPU.cpp b/gfx/layers/mlgpu/LayerManagerMLGPU.cpp index adc27dd143ec1..1c0a49973d32f 100644 --- a/gfx/layers/mlgpu/LayerManagerMLGPU.cpp +++ b/gfx/layers/mlgpu/LayerManagerMLGPU.cpp @@ -204,9 +204,7 @@ LayersBackend LayerManagerMLGPU::GetBackendType() { void LayerManagerMLGPU::SetRoot(Layer* aLayer) { mRoot = aLayer; } -bool LayerManagerMLGPU::BeginTransaction(const nsCString& aURL) { - return true; -} +bool LayerManagerMLGPU::BeginTransaction(const nsCString& aURL) { return true; } void LayerManagerMLGPU::BeginTransactionWithDrawTarget( gfx::DrawTarget* aTarget, const gfx::IntRect& aRect) { diff --git a/gfx/layers/opengl/MacIOSurfaceTextureHostOGL.cpp b/gfx/layers/opengl/MacIOSurfaceTextureHostOGL.cpp index fe46dcdcf96f3..341b55858db73 100644 --- a/gfx/layers/opengl/MacIOSurfaceTextureHostOGL.cpp +++ b/gfx/layers/opengl/MacIOSurfaceTextureHostOGL.cpp @@ -193,7 +193,9 @@ void MacIOSurfaceTextureHostOGL::PushResourceUpdates( (aResources.*method)(aImageKeys[1], descriptor1, aExtID, bufferType, 1); break; } - default: { MOZ_ASSERT_UNREACHABLE("unexpected to be called"); } + default: { + MOZ_ASSERT_UNREACHABLE("unexpected to be called"); + } } } @@ -233,7 +235,9 @@ void MacIOSurfaceTextureHostOGL::PushDisplayItems( aFilter); break; } - default: { MOZ_ASSERT_UNREACHABLE("unexpected to be called"); } + default: { + MOZ_ASSERT_UNREACHABLE("unexpected to be called"); + } } } diff --git a/gfx/layers/opengl/TextureHostOGL.cpp b/gfx/layers/opengl/TextureHostOGL.cpp index 19384e928b33e..2cf375fd4720e 100644 --- a/gfx/layers/opengl/TextureHostOGL.cpp +++ b/gfx/layers/opengl/TextureHostOGL.cpp @@ -655,7 +655,9 @@ void SurfaceTextureHost::PushResourceUpdates( (aResources.*method)(aImageKeys[0], descriptor, aExtID, bufferType, 0); break; } - default: { MOZ_ASSERT_UNREACHABLE("unexpected to be called"); } + default: { + MOZ_ASSERT_UNREACHABLE("unexpected to be called"); + } } } @@ -673,7 +675,9 @@ void SurfaceTextureHost::PushDisplayItems( !(mFlags & TextureFlags::NON_PREMULTIPLIED)); break; } - default: { MOZ_ASSERT_UNREACHABLE("unexpected to be called"); } + default: { + MOZ_ASSERT_UNREACHABLE("unexpected to be called"); + } } } diff --git a/gfx/layers/wr/WebRenderCommandBuilder.cpp b/gfx/layers/wr/WebRenderCommandBuilder.cpp index 0d3f5da0d1b63..657320d6ea2d7 100644 --- a/gfx/layers/wr/WebRenderCommandBuilder.cpp +++ b/gfx/layers/wr/WebRenderCommandBuilder.cpp @@ -245,7 +245,9 @@ static bool IsContainerLayerItem(nsDisplayItem* aItem) { case DisplayItemType::TYPE_PERSPECTIVE: { return true; } - default: { return false; } + default: { + return false; + } } } diff --git a/gfx/src/FilterSupport.cpp b/gfx/src/FilterSupport.cpp index e7f51379c089b..f4fdd0e001bad 100644 --- a/gfx/src/FilterSupport.cpp +++ b/gfx/src/FilterSupport.cpp @@ -486,7 +486,9 @@ bool ComputeColorMatrix(const ColorMatrixAttributes& aMatrixAttributes, break; } - default: { return false; } + default: { + return false; + } } return !ArrayEqual(aOutMatrix, identityMatrix, 20); diff --git a/gfx/tests/gtest/PolygonTestUtils.cpp b/gfx/tests/gtest/PolygonTestUtils.cpp index ca92c7b5fa1a5..9e399eb039188 100644 --- a/gfx/tests/gtest/PolygonTestUtils.cpp +++ b/gfx/tests/gtest/PolygonTestUtils.cpp @@ -84,7 +84,8 @@ bool operator==(const MozPolygon& lhs, const MozPolygon& rhs) { } // namespace gfx } // namespace mozilla -TEST(PolygonTestUtils, TestSanity) { +TEST(PolygonTestUtils, TestSanity) +{ EXPECT_TRUE(FuzzyEquals(Point4D(0.0f, 0.0f, 0.0f, 1.0f), Point4D(0.0f, 0.0f, 0.0f, 1.0f))); diff --git a/gfx/tests/gtest/TestArena.cpp b/gfx/tests/gtest/TestArena.cpp index df93ae21bcf52..1939163f3de5c 100644 --- a/gfx/tests/gtest/TestArena.cpp +++ b/gfx/tests/gtest/TestArena.cpp @@ -156,12 +156,14 @@ static void TestArenaLimit(IterableArena::ArenaType aType, using namespace test_arena; -TEST(Moz2D, FixedArena) { +TEST(Moz2D, FixedArena) +{ TestArenaAlloc(IterableArena::FIXED_SIZE); TestArenaLimit(IterableArena::FIXED_SIZE, true); } -TEST(Moz2D, GrowableArena) { +TEST(Moz2D, GrowableArena) +{ TestArenaAlloc(IterableArena::GROWABLE); TestArenaLimit(IterableArena::GROWABLE, false); diff --git a/gfx/tests/gtest/TestArrayView.cpp b/gfx/tests/gtest/TestArrayView.cpp index 11755d15c5a20..209f286845851 100644 --- a/gfx/tests/gtest/TestArrayView.cpp +++ b/gfx/tests/gtest/TestArrayView.cpp @@ -11,7 +11,8 @@ using namespace mozilla::gfx; -TEST(Gfx, ArrayView) { +TEST(Gfx, ArrayView) +{ nsTArray p = {5, 6}; ArrayView pv(p); ASSERT_EQ(pv[1], 6); diff --git a/gfx/tests/gtest/TestBSPTree.cpp b/gfx/tests/gtest/TestBSPTree.cpp index e76874feacf02..b5c6cda5dd957 100644 --- a/gfx/tests/gtest/TestBSPTree.cpp +++ b/gfx/tests/gtest/TestBSPTree.cpp @@ -38,7 +38,8 @@ static void RunTest(std::deque aPolygons, } // namespace -TEST(BSPTree, SameNode) { +TEST(BSPTree, SameNode) +{ const std::deque polygons{ MozPolygon{ Point4D(0.0f, 0.0f, 0.0f, 1.0f), Point4D(1.0f, 0.0f, 0.0f, 1.0f), @@ -50,7 +51,8 @@ TEST(BSPTree, SameNode) { ::RunTest(polygons, polygons); } -TEST(BSPTree, OneChild) { +TEST(BSPTree, OneChild) +{ const MozPolygon p1{ Point4D(0.0f, 0.0f, 0.0f, 1.0f), Point4D(1.0f, 0.0f, 0.0f, 1.0f), Point4D(1.0f, 1.0f, 0.0f, 1.0f), Point4D(0.0f, 1.0f, 0.0f, 1.0f)}; @@ -63,7 +65,8 @@ TEST(BSPTree, OneChild) { ::RunTest({p2, p1}, {p1, p2}); } -TEST(BSPTree, SharedEdge1) { +TEST(BSPTree, SharedEdge1) +{ MozPolygon p1{ Point4D(1.0f, 0.0f, 1.0f, 1.0f), Point4D(0.0f, 0.0f, 1.0f, 1.0f), Point4D(0.0f, 1.0f, 1.0f, 1.0f), Point4D(1.0f, 1.0f, 1.0f, 1.0f)}; @@ -75,7 +78,8 @@ TEST(BSPTree, SharedEdge1) { ::RunTest({p1, p2}, {p1, p2}); } -TEST(BSPTree, SharedEdge2) { +TEST(BSPTree, SharedEdge2) +{ MozPolygon p1{ Point4D(1.0f, 0.0f, 1.0f, 1.0f), Point4D(0.0f, 0.0f, 1.0f, 1.0f), Point4D(0.0f, 1.0f, 1.0f, 1.0f), Point4D(1.0f, 1.0f, 1.0f, 1.0f)}; @@ -87,7 +91,8 @@ TEST(BSPTree, SharedEdge2) { ::RunTest({p1, p2}, {p2, p1}); } -TEST(BSPTree, SplitSharedEdge) { +TEST(BSPTree, SplitSharedEdge) +{ MozPolygon p1{ Point4D(1.0f, 0.0f, 1.0f, 1.0f), Point4D(0.0f, 0.0f, 1.0f, 1.0f), Point4D(0.0f, 1.0f, 1.0f, 1.0f), Point4D(1.0f, 1.0f, 1.0f, 1.0f)}; @@ -110,7 +115,8 @@ TEST(BSPTree, SplitSharedEdge) { ::RunTest({p1, p2}, expected); } -TEST(BSPTree, SplitSimple1) { +TEST(BSPTree, SplitSimple1) +{ MozPolygon p1{ Point4D(0.0f, 0.0f, 1.0f, 1.0f), Point4D(1.0f, 0.0f, 1.0f, 1.0f), Point4D(1.0f, 1.0f, 1.0f, 1.0f), Point4D(0.0f, 1.0f, 1.0f, 1.0f)}; @@ -131,7 +137,8 @@ TEST(BSPTree, SplitSimple1) { ::RunTest({p1, p2}, expected); } -TEST(BSPTree, SplitSimple2) { +TEST(BSPTree, SplitSimple2) +{ const std::deque polygons{ MozPolygon{Point4D(-5.00000f, -5.00000f, 0.00000f, 1.0f), Point4D(-5.00000f, 5.00000f, 0.00000f, 1.0f), @@ -158,7 +165,8 @@ TEST(BSPTree, SplitSimple2) { ::RunTest(polygons, expected); } -TEST(BSPTree, NoSplit1) { +TEST(BSPTree, NoSplit1) +{ const std::deque polygons{ MozPolygon{Point4D(0.00000f, 10.00000f, 0.00000f, 1.0f), Point4D(0.00000f, 0.00000f, 0.00000f, 1.0f), @@ -189,7 +197,8 @@ TEST(BSPTree, NoSplit1) { ::RunTest(polygons, expected); } -TEST(BSPTree, NoSplit2) { +TEST(BSPTree, NoSplit2) +{ const std::deque polygons{ MozPolygon{Point4D(-5.00000f, -5.00000f, 0.00000f, 1.0f), Point4D(-5.00000f, 5.00000f, 0.00000f, 1.0f), @@ -212,7 +221,8 @@ TEST(BSPTree, NoSplit2) { ::RunTest(polygons, expected); } -TEST(BSPTree, TwoPlaneIntersectRotate0degrees) { +TEST(BSPTree, TwoPlaneIntersectRotate0degrees) +{ const std::deque polygons{ MozPolygon{Point4D(-0.00000f, 2.00000f, 2.00000f, 1.0f), Point4D(-0.00000f, -2.00000f, 2.00000f, 1.0f), @@ -235,7 +245,8 @@ TEST(BSPTree, TwoPlaneIntersectRotate0degrees) { ::RunTest(polygons, expected); } -TEST(BSPTree, TwoPlaneIntersectRotate20degrees) { +TEST(BSPTree, TwoPlaneIntersectRotate20degrees) +{ const std::deque polygons{ MozPolygon{Point4D(-0.00000f, 1.19540f, 2.56350f, 1.0f), Point4D(-0.00000f, -2.56340f, 1.19540f, 1.0f), @@ -258,7 +269,8 @@ TEST(BSPTree, TwoPlaneIntersectRotate20degrees) { ::RunTest(polygons, expected); } -TEST(BSPTree, TwoPlaneIntersectRotate40degrees) { +TEST(BSPTree, TwoPlaneIntersectRotate40degrees) +{ const std::deque polygons{ MozPolygon{Point4D(-0.00000f, -0.73200f, 2.73210f, 1.0f), Point4D(-0.00000f, -2.73200f, -0.73200f, 1.0f), @@ -281,7 +293,8 @@ TEST(BSPTree, TwoPlaneIntersectRotate40degrees) { ::RunTest(polygons, expected); } -TEST(BSPTree, TwoPlaneIntersectRotate60degrees) { +TEST(BSPTree, TwoPlaneIntersectRotate60degrees) +{ const std::deque polygons{ MozPolygon{Point4D(-0.00000f, -2.73200f, 0.73210f, 1.0f), Point4D(-0.00000f, -0.73200f, -2.73200f, 1.0f), @@ -308,7 +321,8 @@ TEST(BSPTree, TwoPlaneIntersectRotate60degrees) { ::RunTest(polygons, expected); } -TEST(BSPTree, TwoPlaneIntersectRotate80degrees) { +TEST(BSPTree, TwoPlaneIntersectRotate80degrees) +{ const std::deque polygons{ MozPolygon{Point4D(-0.00000f, -1.19530f, -2.56340f, 1.0f), Point4D(-0.00000f, 2.56350f, -1.19530f, 1.0f), @@ -331,7 +345,8 @@ TEST(BSPTree, TwoPlaneIntersectRotate80degrees) { ::RunTest(polygons, expected); } -TEST(BSPTree, TwoPlaneIntersectRotate100degrees) { +TEST(BSPTree, TwoPlaneIntersectRotate100degrees) +{ const std::deque polygons{ MozPolygon{Point4D(-0.00000f, 2.73210f, -0.73200f, 1.0f), Point4D(-0.00000f, 0.73210f, 2.73210f, 1.0f), @@ -358,7 +373,8 @@ TEST(BSPTree, TwoPlaneIntersectRotate100degrees) { ::RunTest(polygons, expected); } -TEST(BSPTree, TwoPlaneIntersectRotate120degrees) { +TEST(BSPTree, TwoPlaneIntersectRotate120degrees) +{ const std::deque polygons{ MozPolygon{Point4D(-0.00000f, -0.73200f, 2.73210f, 1.0f), Point4D(-0.00000f, -2.73200f, -0.73200f, 1.0f), @@ -381,7 +397,8 @@ TEST(BSPTree, TwoPlaneIntersectRotate120degrees) { ::RunTest(polygons, expected); } -TEST(BSPTree, TwoPlaneIntersectRotate140degrees) { +TEST(BSPTree, TwoPlaneIntersectRotate140degrees) +{ const std::deque polygons{ MozPolygon{Point4D(-0.00000f, -1.19530f, -2.56340f, 1.0f), Point4D(-0.00000f, 2.56350f, -1.19530f, 1.0f), @@ -404,7 +421,8 @@ TEST(BSPTree, TwoPlaneIntersectRotate140degrees) { ::RunTest(polygons, expected); } -TEST(BSPTree, TwoPlaneIntersectRotate160degrees) { +TEST(BSPTree, TwoPlaneIntersectRotate160degrees) +{ const std::deque polygons{ MozPolygon{Point4D(-0.00000f, 2.00000f, 2.00000f, 1.0f), Point4D(-0.00000f, -2.00000f, 2.00000f, 1.0f), @@ -427,7 +445,8 @@ TEST(BSPTree, TwoPlaneIntersectRotate160degrees) { ::RunTest(polygons, expected); } -TEST(BSPTree, TwoPlaneIntersectRotate180degrees) { +TEST(BSPTree, TwoPlaneIntersectRotate180degrees) +{ const std::deque polygons{ MozPolygon{Point4D(-0.00000f, -2.00000f, -2.00000f, 1.0f), Point4D(-0.00000f, 2.00000f, -2.00000f, 1.0f), @@ -450,7 +469,8 @@ TEST(BSPTree, TwoPlaneIntersectRotate180degrees) { ::RunTest(polygons, expected); } -TEST(BSPTree, TwoPlaneIntersectRotate200degrees) { +TEST(BSPTree, TwoPlaneIntersectRotate200degrees) +{ const std::deque polygons{ MozPolygon{Point4D(-0.00000f, 1.19540f, 2.56350f, 1.0f), Point4D(-0.00000f, -2.56340f, 1.19540f, 1.0f), @@ -473,7 +493,8 @@ TEST(BSPTree, TwoPlaneIntersectRotate200degrees) { ::RunTest(polygons, expected); } -TEST(BSPTree, TwoPlaneIntersectRotate220degrees) { +TEST(BSPTree, TwoPlaneIntersectRotate220degrees) +{ const std::deque polygons{ MozPolygon{Point4D(-0.00000f, 0.73210f, -2.73200f, 1.0f), Point4D(-0.00000f, 2.73210f, 0.73210f, 1.0f), @@ -496,7 +517,8 @@ TEST(BSPTree, TwoPlaneIntersectRotate220degrees) { ::RunTest(polygons, expected); } -TEST(BSPTree, TwoPlaneIntersectRotate240degrees) { +TEST(BSPTree, TwoPlaneIntersectRotate240degrees) +{ const std::deque polygons{ MozPolygon{Point4D(-0.00000f, -2.73200f, 0.73210f, 1.0f), Point4D(-0.00000f, -0.73200f, -2.73200f, 1.0f), @@ -523,7 +545,8 @@ TEST(BSPTree, TwoPlaneIntersectRotate240degrees) { ::RunTest(polygons, expected); } -TEST(BSPTree, TwoPlaneIntersectRotate260degrees) { +TEST(BSPTree, TwoPlaneIntersectRotate260degrees) +{ const std::deque polygons{ MozPolygon{Point4D(-0.00000f, 1.19540f, 2.56350f, 1.0f), Point4D(-0.00000f, -2.56340f, 1.19540f, 1.0f), @@ -546,7 +569,8 @@ TEST(BSPTree, TwoPlaneIntersectRotate260degrees) { ::RunTest(polygons, expected); } -TEST(BSPTree, TwoPlaneIntersectRotate280degrees) { +TEST(BSPTree, TwoPlaneIntersectRotate280degrees) +{ const std::deque polygons{ MozPolygon{Point4D(-0.00000f, 2.73210f, -0.73200f, 1.0f), Point4D(-0.00000f, 0.73210f, 2.73210f, 1.0f), @@ -573,7 +597,8 @@ TEST(BSPTree, TwoPlaneIntersectRotate280degrees) { ::RunTest(polygons, expected); } -TEST(BSPTree, TwoPlaneIntersectRotate300degrees) { +TEST(BSPTree, TwoPlaneIntersectRotate300degrees) +{ const std::deque polygons{ MozPolygon{Point4D(-0.00000f, 0.73210f, -2.73200f, 1.0f), Point4D(-0.00000f, 2.73210f, 0.73210f, 1.0f), @@ -596,7 +621,8 @@ TEST(BSPTree, TwoPlaneIntersectRotate300degrees) { ::RunTest(polygons, expected); } -TEST(BSPTree, TwoPlaneIntersectRotate320degrees) { +TEST(BSPTree, TwoPlaneIntersectRotate320degrees) +{ const std::deque polygons{ MozPolygon{Point4D(-0.00000f, -1.19530f, -2.56340f, 1.0f), Point4D(-0.00000f, 2.56350f, -1.19530f, 1.0f), @@ -619,7 +645,8 @@ TEST(BSPTree, TwoPlaneIntersectRotate320degrees) { ::RunTest(polygons, expected); } -TEST(BSPTree, TwoPlaneIntersectRotate340degrees) { +TEST(BSPTree, TwoPlaneIntersectRotate340degrees) +{ const std::deque polygons{ MozPolygon{Point4D(-0.00000f, -2.00000f, -2.00000f, 1.0f), Point4D(-0.00000f, 2.00000f, -2.00000f, 1.0f), @@ -642,7 +669,8 @@ TEST(BSPTree, TwoPlaneIntersectRotate340degrees) { ::RunTest(polygons, expected); } -TEST(BSPTree, TwoPlaneIntersectRotate360degrees) { +TEST(BSPTree, TwoPlaneIntersectRotate360degrees) +{ const std::deque polygons{ MozPolygon{Point4D(-0.00000f, -2.00000f, -2.00000f, 1.0f), Point4D(-0.00000f, 2.00000f, -2.00000f, 1.0f), diff --git a/gfx/tests/gtest/TestBufferRotation.cpp b/gfx/tests/gtest/TestBufferRotation.cpp index 0e4e86abd5139..d5570054115a8 100644 --- a/gfx/tests/gtest/TestBufferRotation.cpp +++ b/gfx/tests/gtest/TestBufferRotation.cpp @@ -43,7 +43,8 @@ static bool CheckBuffer(unsigned char* buffer, int bytesPerPixel, int width, return true; } -TEST(Gfx, BufferUnrotateHorizontal) { +TEST(Gfx, BufferUnrotateHorizontal) +{ const int NUM_OF_TESTS = 8; int bytesPerPixelList[2] = {2, 4}; int width[NUM_OF_TESTS] = {100, 100, 99, 99, 100, 100, 99, 99}; @@ -69,7 +70,8 @@ TEST(Gfx, BufferUnrotateHorizontal) { } } -TEST(Gfx, BufferUnrotateVertical) { +TEST(Gfx, BufferUnrotateVertical) +{ const int NUM_OF_TESTS = 8; int bytesPerPixelList[2] = {2, 4}; int width[NUM_OF_TESTS] = {100, 100, 99, 99, 100, 100, 99, 99}; @@ -95,7 +97,8 @@ TEST(Gfx, BufferUnrotateVertical) { } } -TEST(Gfx, BufferUnrotateBoth) { +TEST(Gfx, BufferUnrotateBoth) +{ const int NUM_OF_TESTS = 16; int bytesPerPixelList[2] = {2, 4}; int width[NUM_OF_TESTS] = {100, 100, 99, 99, 100, 100, 99, 99, @@ -125,7 +128,8 @@ TEST(Gfx, BufferUnrotateBoth) { } } -TEST(Gfx, BufferUnrotateUneven) { +TEST(Gfx, BufferUnrotateUneven) +{ const int NUM_OF_TESTS = 16; int bytesPerPixelList[2] = {2, 4}; int width[NUM_OF_TESTS] = {10, 100, 99, 39, 100, 40, 99, 39, diff --git a/gfx/tests/gtest/TestColorNames.cpp b/gfx/tests/gtest/TestColorNames.cpp index dda60fce00cfd..71206f1d91d98 100644 --- a/gfx/tests/gtest/TestColorNames.cpp +++ b/gfx/tests/gtest/TestColorNames.cpp @@ -44,18 +44,16 @@ static void RunColorTests() { // Check that color lookup by name gets the right rgb value ASSERT_TRUE(NS_ColorNameToRGB(NS_ConvertASCIItoUTF16(tagName), &rgb)) - << "can't find '" << tagName.get() << "'"; + << "can't find '" << tagName.get() << "'"; ASSERT_TRUE((rgb == kColors[index])) - << "failed at index " << index << " out of " - << ArrayLength(kColorNames); + << "failed at index " << index << " out of " << ArrayLength(kColorNames); // fiddle with the case to make sure we can still find it tagName.SetCharAt(tagName.CharAt(0) - 32, 0); ASSERT_TRUE(NS_ColorNameToRGB(NS_ConvertASCIItoUTF16(tagName), &rgb)) - << "can't find '" << tagName.get() << "'"; + << "can't find '" << tagName.get() << "'"; ASSERT_TRUE((rgb == kColors[index])) - << "failed at index " << index << " out of " - << ArrayLength(kColorNames); + << "failed at index " << index << " out of " << ArrayLength(kColorNames); // Check that parsing an RGB value in hex gets the right values uint8_t r = NS_GET_R(rgb); @@ -71,7 +69,7 @@ static void RunColorTests() { nscolor hexrgb; ASSERT_TRUE(NS_HexToRGBA(NS_ConvertASCIItoUTF16(cbuf), nsHexColorType::AllowAlpha, &hexrgb)) - << "hex conversion to color of '" << cbuf << "'"; + << "hex conversion to color of '" << cbuf << "'"; ASSERT_TRUE(hexrgb == rgb); } } @@ -86,6 +84,8 @@ static void RunJunkColorTests() { } } -TEST(Gfx, ColorNames) { RunColorTests(); } +TEST(Gfx, ColorNames) +{ RunColorTests(); } -TEST(Gfx, JunkColorNames) { RunJunkColorTests(); } +TEST(Gfx, JunkColorNames) +{ RunJunkColorTests(); } diff --git a/gfx/tests/gtest/TestCompositor.cpp b/gfx/tests/gtest/TestCompositor.cpp index 6a57b31e0ca66..167630ec555a6 100644 --- a/gfx/tests/gtest/TestCompositor.cpp +++ b/gfx/tests/gtest/TestCompositor.cpp @@ -161,11 +161,11 @@ static bool CompositeAndCompare(RefPtr layerManager, return true; } -TEST(Gfx, CompositorConstruct) { - auto layerManagers = GetLayerManagers(GetPlatformBackends()); -} +TEST(Gfx, CompositorConstruct) +{ auto layerManagers = GetLayerManagers(GetPlatformBackends()); } -TEST(Gfx, CompositorSimpleTree) { +TEST(Gfx, CompositorSimpleTree) +{ auto layerManagers = GetLayerManagers(GetPlatformBackends()); for (size_t i = 0; i < layerManagers.size(); i++) { RefPtr layerManager = layerManagers[i].mLayerManager; diff --git a/gfx/tests/gtest/TestGfxPrefs.cpp b/gfx/tests/gtest/TestGfxPrefs.cpp index 2c5442d4992d3..124e23df7dd53 100644 --- a/gfx/tests/gtest/TestGfxPrefs.cpp +++ b/gfx/tests/gtest/TestGfxPrefs.cpp @@ -16,12 +16,14 @@ // a particular value to make sure we receive the correct // result through this API. -TEST(GfxPrefs, Singleton) { +TEST(GfxPrefs, Singleton) +{ gfxPrefs::GetSingleton(); ASSERT_TRUE(gfxPrefs::SingletonExists()); } -TEST(GfxPrefs, LiveValues) { +TEST(GfxPrefs, LiveValues) +{ gfxPrefs::GetSingleton(); ASSERT_TRUE(gfxPrefs::SingletonExists()); @@ -35,7 +37,8 @@ TEST(GfxPrefs, LiveValues) { ASSERT_TRUE(gfxPrefs::MSAALevel() == 2); } -TEST(GfxPrefs, OnceValues) { +TEST(GfxPrefs, OnceValues) +{ gfxPrefs::GetSingleton(); ASSERT_TRUE(gfxPrefs::SingletonExists()); @@ -52,7 +55,8 @@ TEST(GfxPrefs, OnceValues) { ASSERT_TRUE(gfxPrefs::APZMaxVelocity() == -1.0f); } -TEST(GfxPrefs, Set) { +TEST(GfxPrefs, Set) +{ gfxPrefs::GetSingleton(); ASSERT_TRUE(gfxPrefs::SingletonExists()); @@ -80,7 +84,8 @@ TEST(GfxPrefs, Set) { // Randomly test the function we use in nsExceptionHandler.cpp here: extern bool SimpleNoCLibDtoA(double aValue, char* aBuffer, int aBufferLength); -TEST(GfxPrefs, StringUtility) { +TEST(GfxPrefs, StringUtility) +{ char testBuffer[64]; double testVal[] = { 13.4, diff --git a/gfx/tests/gtest/TestGfxWidgets.cpp b/gfx/tests/gtest/TestGfxWidgets.cpp index 142d4c81a7ff7..90bfce863a89d 100644 --- a/gfx/tests/gtest/TestGfxWidgets.cpp +++ b/gfx/tests/gtest/TestGfxWidgets.cpp @@ -10,7 +10,8 @@ using namespace mozilla::widget; -TEST(GfxWidgets, Split) { +TEST(GfxWidgets, Split) +{ char aStr[8], bStr[8], cStr[8], dStr[8]; ASSERT_TRUE(SplitDriverVersion("33.4.3.22", aStr, bStr, cStr, dStr)); @@ -75,7 +76,8 @@ TEST(GfxWidgets, Split) { atoi(dStr) == 0); } -TEST(GfxWidgets, Versioning) { +TEST(GfxWidgets, Versioning) +{ ASSERT_TRUE(mozilla::Version("0") < mozilla::Version("41.0a1")); ASSERT_TRUE(mozilla::Version("39.0.5b7") < mozilla::Version("41.0a1")); ASSERT_TRUE(mozilla::Version("18.0.5b7") < mozilla::Version("18.2")); diff --git a/gfx/tests/gtest/TestJobScheduler.cpp b/gfx/tests/gtest/TestJobScheduler.cpp index 65183005de2a7..435d3c298ebec 100644 --- a/gfx/tests/gtest/TestJobScheduler.cpp +++ b/gfx/tests/gtest/TestJobScheduler.cpp @@ -198,7 +198,8 @@ static void TestSchedulerChain(uint32_t aNumThreads, uint32_t aNumCmdBuffers) { } // namespace test_scheduler #if !defined(MOZ_CODE_COVERAGE) || !defined(XP_WIN) -TEST(Moz2D, JobScheduler_Shutdown) { +TEST(Moz2D, JobScheduler_Shutdown) +{ srand(time(nullptr)); for (uint32_t threads = 1; threads < 16; ++threads) { for (uint32_t i = 1; i < 1000; ++i) { @@ -209,7 +210,8 @@ TEST(Moz2D, JobScheduler_Shutdown) { } #endif -TEST(Moz2D, JobScheduler_Join) { +TEST(Moz2D, JobScheduler_Join) +{ srand(time(nullptr)); for (uint32_t threads = 1; threads < 8; ++threads) { for (uint32_t queues = 1; queues < threads; ++queues) { @@ -222,7 +224,8 @@ TEST(Moz2D, JobScheduler_Join) { } } -TEST(Moz2D, JobScheduler_Chain) { +TEST(Moz2D, JobScheduler_Chain) +{ srand(time(nullptr)); for (uint32_t threads = 1; threads < 8; ++threads) { for (uint32_t queues = 1; queues < threads; ++queues) { diff --git a/gfx/tests/gtest/TestLayers.cpp b/gfx/tests/gtest/TestLayers.cpp index 4f1298b94c047..cebd5a96221c0 100644 --- a/gfx/tests/gtest/TestLayers.cpp +++ b/gfx/tests/gtest/TestLayers.cpp @@ -85,9 +85,11 @@ class TestUserData : public LayerUserData { virtual ~TestUserData() { Die(); } }; -TEST(Layers, LayerConstructor) { TestContainerLayer layer(nullptr); } +TEST(Layers, LayerConstructor) +{ TestContainerLayer layer(nullptr); } -TEST(Layers, Defaults) { +TEST(Layers, Defaults) +{ TestContainerLayer layer(nullptr); ASSERT_EQ(1.0, layer.GetOpacity()); ASSERT_EQ(1.0f, layer.GetPostXScale()); @@ -99,7 +101,8 @@ TEST(Layers, Defaults) { ASSERT_EQ(nullptr, layer.GetLastChild()); } -TEST(Layers, Transform) { +TEST(Layers, Transform) +{ TestContainerLayer layer(nullptr); Matrix4x4 identity; @@ -108,14 +111,16 @@ TEST(Layers, Transform) { ASSERT_EQ(identity, layer.GetTransform()); } -TEST(Layers, Type) { +TEST(Layers, Type) +{ TestContainerLayer layer(nullptr); ASSERT_EQ(nullptr, layer.AsPaintedLayer()); ASSERT_EQ(nullptr, layer.AsRefLayer()); ASSERT_EQ(nullptr, layer.AsColorLayer()); } -TEST(Layers, UserData) { +TEST(Layers, UserData) +{ UniquePtr layerPtr(new TestContainerLayer(nullptr)); TestContainerLayer& layer = *layerPtr; @@ -235,7 +240,8 @@ already_AddRefed CreateLayerTree(const char* aLayerTreeDescription, return rootLayer.forget(); } -TEST(Layers, LayerTree) { +TEST(Layers, LayerTree) +{ const char* layerTreeSyntax = "c(c(tt))"; nsIntRegion layerVisibleRegion[] = { nsIntRegion(IntRect(0, 0, 100, 100)), @@ -289,7 +295,8 @@ static void ValidateTreePointers(nsTArray >& aLayers) { } } -TEST(Layers, RepositionChild) { +TEST(Layers, RepositionChild) +{ const char* layerTreeSyntax = "c(ttt)"; nsTArray > layers; diff --git a/gfx/tests/gtest/TestMoz2D.cpp b/gfx/tests/gtest/TestMoz2D.cpp index 3550b47f56fb7..50854cdc98eb3 100644 --- a/gfx/tests/gtest/TestMoz2D.cpp +++ b/gfx/tests/gtest/TestMoz2D.cpp @@ -10,7 +10,8 @@ #include "TestScaling.h" #include "TestBugs.h" -TEST(Moz2D, Bugs) { +TEST(Moz2D, Bugs) +{ TestBugs* test = new TestBugs(); int failures = 0; test->RunTests(&failures); @@ -19,7 +20,8 @@ TEST(Moz2D, Bugs) { ASSERT_EQ(failures, 0); } -TEST(Moz2D, Point) { +TEST(Moz2D, Point) +{ TestBase* test = new TestPoint(); int failures = 0; test->RunTests(&failures); @@ -28,7 +30,8 @@ TEST(Moz2D, Point) { ASSERT_EQ(failures, 0); } -TEST(Moz2D, Scaling) { +TEST(Moz2D, Scaling) +{ TestBase* test = new TestScaling(); int failures = 0; test->RunTests(&failures); diff --git a/gfx/tests/gtest/TestPolygon.cpp b/gfx/tests/gtest/TestPolygon.cpp index 09f40b204925c..168f7b46d9a70 100644 --- a/gfx/tests/gtest/TestPolygon.cpp +++ b/gfx/tests/gtest/TestPolygon.cpp @@ -16,7 +16,8 @@ using namespace mozilla::gfx; typedef mozilla::gfx::Polygon MozPolygon; -TEST(MozPolygon, TriangulateRectangle) { +TEST(MozPolygon, TriangulateRectangle) +{ const MozPolygon p{ Point4D(0.0f, 0.0f, 1.0f, 1.0f), Point4D(0.0f, 1.0f, 1.0f, 1.0f), Point4D(1.0f, 1.0f, 1.0f, 1.0f), Point4D(1.0f, 0.0f, 1.0f, 1.0f)}; @@ -29,7 +30,8 @@ TEST(MozPolygon, TriangulateRectangle) { AssertArrayEQ(triangles, expected); } -TEST(MozPolygon, TriangulatePentagon) { +TEST(MozPolygon, TriangulatePentagon) +{ const MozPolygon p{ Point4D(0.0f, 0.0f, 1.0f, 1.0f), Point4D(0.0f, 1.0f, 1.0f, 1.0f), Point4D(0.5f, 1.5f, 1.0f, 1.0f), Point4D(1.0f, 1.0f, 1.0f, 1.0f), @@ -50,7 +52,8 @@ static void TestClipRect(const MozPolygon& aPolygon, EXPECT_TRUE(res == aExpected); } -TEST(MozPolygon, ClipRectangle) { +TEST(MozPolygon, ClipRectangle) +{ MozPolygon polygon{ Point4D(0.0f, 0.0f, 0.0f, 1.0f), Point4D(0.0f, 1.0f, 0.0f, 1.0f), Point4D(1.0f, 1.0f, 0.0f, 1.0f), Point4D(1.0f, 0.0f, 0.0f, 1.0f)}; @@ -72,7 +75,8 @@ TEST(MozPolygon, ClipRectangle) { TestClipRect(polygon, expected, Rect(0.2f, 0.2f, 0.6f, 0.6f)); } -TEST(MozPolygon, ClipTriangle) { +TEST(MozPolygon, ClipTriangle) +{ MozPolygon clipped, expected; const MozPolygon polygon{Point4D(0.0f, 0.0f, 0.0f, 1.0f), Point4D(0.0f, 1.0f, 0.0f, 1.0f), diff --git a/gfx/tests/gtest/TestQcms.cpp b/gfx/tests/gtest/TestQcms.cpp index 3ed7415cb39f3..871a2f7c46354 100644 --- a/gfx/tests/gtest/TestQcms.cpp +++ b/gfx/tests/gtest/TestQcms.cpp @@ -29,7 +29,8 @@ static unsigned char* createAllGB() { return buff; } -TEST(GfxQcms, Identity) { +TEST(GfxQcms, Identity) +{ // XXX: This means that we can't have qcms v2 unit test // without changing the qcms API. qcms_enable_iccv4(); @@ -60,7 +61,8 @@ TEST(GfxQcms, Identity) { free(data_out); } -TEST(GfxQcms, LutInverseCrash) { +TEST(GfxQcms, LutInverseCrash) +{ uint16_t lutTable1[] = { 0x0000, 0x0000, 0x0000, 0x8000, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, @@ -103,7 +105,8 @@ TEST(GfxQcms, LutInverseCrash) { (int)mozilla::ArrayLength(lutTable2)); } -TEST(GfxQcms, LutInverse) { +TEST(GfxQcms, LutInverse) +{ // mimic sRGB_v4_ICC mBA Output // // XXXX @@ -144,7 +147,8 @@ TEST(GfxQcms, LutInverse) { EXPECT_LT(value, 201 * 256); } -TEST(GfxQcms, LutInverseNonMonotonic) { +TEST(GfxQcms, LutInverseNonMonotonic) +{ // Make sure we behave sanely for non monotic functions // X X X // X X X diff --git a/gfx/tests/gtest/TestRect.cpp b/gfx/tests/gtest/TestRect.cpp index 05e07c7b409ab..f3884577e1567 100644 --- a/gfx/tests/gtest/TestRect.cpp +++ b/gfx/tests/gtest/TestRect.cpp @@ -552,7 +552,8 @@ static void TestIntersectionLogical(nscoord x1, nscoord y1, nscoord w1, isNonEmpty); } -TEST(Gfx, Logical) { +TEST(Gfx, Logical) +{ TestIntersectionLogical(578, 0, 2650, 1152, 1036, 0, 2312, 1, 1036, 0, 2192, 1, true); TestIntersectionLogical(0, 0, 1000, 1000, 500, 500, 1000, 1000, 500, 500, 500, @@ -563,7 +564,8 @@ TEST(Gfx, Logical) { false); } -TEST(Gfx, nsRect) { +TEST(Gfx, nsRect) +{ TestConstructors(); TestEqualityOperator(); TestContainment(); @@ -575,7 +577,8 @@ TEST(Gfx, nsRect) { TestSwap(); } -TEST(Gfx, nsIntRect) { +TEST(Gfx, nsIntRect) +{ TestConstructors(); TestEqualityOperator(); TestContainment(); @@ -587,7 +590,8 @@ TEST(Gfx, nsIntRect) { TestSwap(); } -TEST(Gfx, gfxRect) { +TEST(Gfx, gfxRect) +{ TestConstructors(); // Skip TestEqualityOperator(); as gfxRect::operator== is private TestContainment(); @@ -620,7 +624,8 @@ static void TestMoveInsideAndClamp(IntRect aSrc, IntRect aTarget, << absExpected << " AbsActual " << absResult; } -TEST(Gfx, MoveInsideAndClamp) { +TEST(Gfx, MoveInsideAndClamp) +{ TestMoveInsideAndClamp(IntRect(0, 0, 10, 10), IntRect(1, -1, 10, 10), IntRect(1, -1, 10, 10)); TestMoveInsideAndClamp(IntRect(0, 0, 10, 10), IntRect(-1, -1, 12, 5), diff --git a/gfx/tests/gtest/TestRegion.cpp b/gfx/tests/gtest/TestRegion.cpp index 056768c3bd4e9..631831ac0fc21 100644 --- a/gfx/tests/gtest/TestRegion.cpp +++ b/gfx/tests/gtest/TestRegion.cpp @@ -114,7 +114,8 @@ class TestLargestRegion { } }; -TEST(Gfx, RegionSingleRect) { +TEST(Gfx, RegionSingleRect) +{ TestLargestRegion::TestSingleRect(nsRect(0, 52, 720, 480)); TestLargestRegion::TestSingleRect(nsRect(-20, 40, 50, 20)); TestLargestRegion::TestSingleRect(nsRect(-20, 40, 10, 8)); @@ -122,19 +123,20 @@ TEST(Gfx, RegionSingleRect) { TestLargestRegion::TestSingleRect(nsRect(-10, -10, 20, 20)); } -TEST(Gfx, RegionNonRectangular) { TestLargestRegion::TestNonRectangular(); } +TEST(Gfx, RegionNonRectangular) +{ TestLargestRegion::TestNonRectangular(); } -TEST(Gfx, RegionTwoRectTest) { TestLargestRegion::TwoRectTest(); } +TEST(Gfx, RegionTwoRectTest) +{ TestLargestRegion::TwoRectTest(); } -TEST(Gfx, RegionContainsSpecifiedRect) { - TestLargestRegion::TestContainsSpecifiedRect(); -} +TEST(Gfx, RegionContainsSpecifiedRect) +{ TestLargestRegion::TestContainsSpecifiedRect(); } -TEST(Gfx, RegionTestContainsSpecifiedOverflowingRect) { - TestLargestRegion::TestContainsSpecifiedOverflowingRect(); -} +TEST(Gfx, RegionTestContainsSpecifiedOverflowingRect) +{ TestLargestRegion::TestContainsSpecifiedOverflowingRect(); } -TEST(Gfx, RegionScaleToInside) { +TEST(Gfx, RegionScaleToInside) +{ { // no rectangles nsRegion r; @@ -176,7 +178,8 @@ TEST(Gfx, RegionScaleToInside) { } } -TEST(Gfx, RegionIsEqual) { +TEST(Gfx, RegionIsEqual) +{ { nsRegion r(nsRect(0, 0, 50, 50)); EXPECT_FALSE(nsRegion().IsEqual(r)); @@ -215,7 +218,8 @@ TEST(Gfx, RegionIsEqual) { } } -TEST(Gfx, RegionOrWith) { +TEST(Gfx, RegionOrWith) +{ PR_Sleep(PR_SecondsToInterval(10)); { nsRegion r(nsRect(11840, 11840, 4640, -10880)); @@ -333,7 +337,8 @@ TEST(Gfx, RegionOrWith) { #endif } -TEST(Gfx, RegionSubWith) { +TEST(Gfx, RegionSubWith) +{ { nsRegion r1(nsRect(0, 0, 100, 50)); r1.OrWith(nsRect(50, 50, 50, 50)); @@ -588,7 +593,8 @@ TEST(Gfx, RegionSubWith) { } #endif } -TEST(Gfx, RegionSub) { +TEST(Gfx, RegionSub) +{ { nsRegion r1(nsRect(0, 0, 100, 50)); r1.OrWith(nsRect(50, 50, 50, 50)); @@ -784,7 +790,8 @@ TEST(Gfx, RegionSub) { #endif } -TEST(Gfx, RegionAndWith) { +TEST(Gfx, RegionAndWith) +{ { nsRegion r(nsRect(20, 0, 20, 20)); r.OrWith(nsRect(0, 20, 40, 20)); @@ -865,7 +872,8 @@ TEST(Gfx, RegionAndWith) { #endif } -TEST(Gfx, RegionAnd) { +TEST(Gfx, RegionAnd) +{ { nsRegion r(nsRect(20, 0, 20, 20)); r.OrWith(nsRect(0, 20, 40, 20)); @@ -963,7 +971,8 @@ TEST(Gfx, RegionAnd) { #endif } -TEST(Gfx, RegionSimplify) { +TEST(Gfx, RegionSimplify) +{ { // ensure simplify works on a single rect nsRegion r(nsRect(0, 100, 200, 100)); @@ -1065,7 +1074,8 @@ TEST(Gfx, RegionSimplify) { } } -TEST(Gfx, RegionContains) { +TEST(Gfx, RegionContains) +{ { // ensure Contains works on a simple region nsRegion r(nsRect(0, 0, 100, 100)); @@ -1235,7 +1245,8 @@ static void TestVisit(nsRegion &r) { res.compare(ref); } -TEST(Gfx, RegionVisitEdges) { +TEST(Gfx, RegionVisitEdges) +{ { // visit edges nsRegion r(nsRect(20, 20, 100, 100)); r.Or(r, nsRect(20, 120, 200, 100)); @@ -1340,7 +1351,8 @@ TEST(Gfx, RegionVisitEdges) { // The TiledRegion tests use nsIntRect / IntRegion because nsRect doesn't have // InflateToMultiple which is required by TiledRegion. -TEST(Gfx, TiledRegionNoSimplification2Rects) { +TEST(Gfx, TiledRegionNoSimplification2Rects) +{ // Add two rectangles, both rectangles are completely inside // different tiles. nsIntRegion region; @@ -1355,7 +1367,8 @@ TEST(Gfx, TiledRegionNoSimplification2Rects) { EXPECT_TRUE(region.IsEqual(tiledRegion.GetRegion())); } -TEST(Gfx, TiledRegionNoSimplification1Region) { +TEST(Gfx, TiledRegionNoSimplification1Region) +{ // Add two rectangles, both rectangles are completely inside // different tiles. nsIntRegion region; @@ -1369,7 +1382,8 @@ TEST(Gfx, TiledRegionNoSimplification1Region) { EXPECT_TRUE(region.IsEqual(tiledRegion.GetRegion())); } -TEST(Gfx, TiledRegionWithSimplification3Rects) { +TEST(Gfx, TiledRegionWithSimplification3Rects) +{ // Add three rectangles. The first two rectangles are completely inside // different tiles, but the third rectangle intersects both tiles. TiledIntRegion tiledRegion; @@ -1382,7 +1396,8 @@ TEST(Gfx, TiledRegionWithSimplification3Rects) { EXPECT_TRUE(tiledRegion.GetRegion().IsEqual(nsIntRect(50, 50, 300, 50))); } -TEST(Gfx, TiledRegionWithSimplification1Region) { +TEST(Gfx, TiledRegionWithSimplification1Region) +{ // Add three rectangles. The first two rectangles are completely inside // different tiles, but the third rectangle intersects both tiles. nsIntRegion region; @@ -1398,7 +1413,8 @@ TEST(Gfx, TiledRegionWithSimplification1Region) { EXPECT_TRUE(tiledRegion.GetRegion().IsEqual(nsIntRect(50, 50, 300, 50))); } -TEST(Gfx, TiledRegionContains) { +TEST(Gfx, TiledRegionContains) +{ // Add three rectangles. The first two rectangles are completely inside // different tiles, but the third rectangle intersects both tiles. TiledIntRegion tiledRegion; @@ -1413,7 +1429,8 @@ TEST(Gfx, TiledRegionContains) { EXPECT_FALSE(tiledRegion.Contains(nsIntRect(50, 50, 301, 50))); } -TEST(Gfx, TiledRegionIntersects) { +TEST(Gfx, TiledRegionIntersects) +{ // Add three rectangles. The first two rectangles are completely inside // different tiles, but the third rectangle intersects both tiles. TiledIntRegion tiledRegion; @@ -1429,7 +1446,8 @@ TEST(Gfx, TiledRegionIntersects) { EXPECT_FALSE(tiledRegion.Intersects(nsIntRect(0, 0, 50, 500))); } -TEST(Gfx, TiledRegionBoundaryConditions1) { +TEST(Gfx, TiledRegionBoundaryConditions1) +{ TiledIntRegion tiledRegion; // This one works fine tiledRegion.Add(nsIntRegion(nsIntRect(INT_MIN, INT_MIN, 1, 1))); @@ -1444,7 +1462,8 @@ TEST(Gfx, TiledRegionBoundaryConditions1) { EXPECT_FALSE(tiledRegion.Contains(nsIntRect(0, 0, 1, 1))); } -TEST(Gfx, TiledRegionBoundaryConditions2) { +TEST(Gfx, TiledRegionBoundaryConditions2) +{ TiledIntRegion tiledRegion; // This one works fine tiledRegion.Add(nsIntRegion(nsIntRect(INT_MAX - 1, INT_MIN, 1, 1))); @@ -1457,7 +1476,8 @@ TEST(Gfx, TiledRegionBoundaryConditions2) { EXPECT_FALSE(tiledRegion.Contains(nsIntRect(0, 0, 1, 1))); } -TEST(Gfx, TiledRegionBigRects) { +TEST(Gfx, TiledRegionBigRects) +{ TiledIntRegion tiledRegion; // Super wide region, forces simplification into bounds mode tiledRegion.Add(nsIntRegion(nsIntRect(INT_MIN, INT_MIN, INT_MAX, 100))); @@ -1474,7 +1494,8 @@ TEST(Gfx, TiledRegionBigRects) { EXPECT_FALSE(tiledRegion.Contains(nsIntRect(-2, INT_MIN + 201, 1, 1))); } -TEST(Gfx, TiledRegionBoundaryOverflow) { +TEST(Gfx, TiledRegionBoundaryOverflow) +{ TiledIntRegion tiledRegion; tiledRegion.Add(nsIntRegion(nsIntRect(100, 100, 1, 1))); EXPECT_TRUE(tiledRegion.Contains(nsIntRect(100, 100, 1, 1))); @@ -1495,7 +1516,8 @@ TEST(Gfx, TiledRegionBoundaryOverflow) { EXPECT_FALSE(tiledRegion.Contains(nsIntRect(0, 0, 1, 1))); } -TEST(Gfx, TiledRegionNegativeRect) { +TEST(Gfx, TiledRegionNegativeRect) +{ TiledIntRegion tiledRegion; // The next region is invalid, so it gets ignored tiledRegion.Add(nsIntRegion(nsIntRect(0, 0, -500, -500))); diff --git a/gfx/tests/gtest/TestSkipChars.cpp b/gfx/tests/gtest/TestSkipChars.cpp index ec2372d96b4e9..8f31777619042 100644 --- a/gfx/tests/gtest/TestSkipChars.cpp +++ b/gfx/tests/gtest/TestSkipChars.cpp @@ -148,7 +148,8 @@ static bool TestIterator() { return true; } -TEST(Gfx, gfxSkipChars) { +TEST(Gfx, gfxSkipChars) +{ TestConstructor(); TestLength(); TestIterator(); diff --git a/gfx/tests/gtest/TestSwizzle.cpp b/gfx/tests/gtest/TestSwizzle.cpp index dafffec3c9e66..de26c558d0b8a 100644 --- a/gfx/tests/gtest/TestSwizzle.cpp +++ b/gfx/tests/gtest/TestSwizzle.cpp @@ -11,7 +11,8 @@ using namespace mozilla; using namespace mozilla::gfx; -TEST(Moz2D, PremultiplyData) { +TEST(Moz2D, PremultiplyData) +{ const uint8_t in_bgra[5 * 4] = { 255, 255, 0, 255, // verify 255 alpha leaves RGB unchanged 0, 0, 255, 255, @@ -44,7 +45,8 @@ TEST(Moz2D, PremultiplyData) { EXPECT_TRUE(ArrayEqual(out, check_argb)); } -TEST(Moz2D, UnpremultiplyData) { +TEST(Moz2D, UnpremultiplyData) +{ const uint8_t in_bgra[5 * 4] = { 255, 255, 0, 255, // verify 255 alpha leaves RGB unchanged 0, 0, 255, 255, 0, 0, 0, 0, // verify 0 alpha leaves RGB at 0 @@ -77,7 +79,8 @@ TEST(Moz2D, UnpremultiplyData) { EXPECT_TRUE(ArrayEqual(out, check_argb)); } -TEST(Moz2D, SwizzleData) { +TEST(Moz2D, SwizzleData) +{ const uint8_t in_bgra[5 * 4] = { 253, 254, 0, 255, 0, 0, 255, 255, 0, 0, 0, 0, 1, 2, 3, 64, 127, 0, 9, 128, diff --git a/gfx/tests/gtest/TestTextureCompatibility.cpp b/gfx/tests/gtest/TestTextureCompatibility.cpp index 149ca0b91eafc..ba152dfe8488f 100644 --- a/gfx/tests/gtest/TestTextureCompatibility.cpp +++ b/gfx/tests/gtest/TestTextureCompatibility.cpp @@ -107,7 +107,8 @@ static void CheckCompatibilityWithBasicCompositor( } } -TEST(Gfx, TestTextureCompatibility) { +TEST(Gfx, TestTextureCompatibility) +{ nsTArray backendHints; RefPtr deallocator = new TestSurfaceAllocator(); diff --git a/gfx/tests/gtest/TestTextures.cpp b/gfx/tests/gtest/TestTextures.cpp index f9238237c09d5..c4e744d3d71f6 100644 --- a/gfx/tests/gtest/TestTextures.cpp +++ b/gfx/tests/gtest/TestTextures.cpp @@ -213,7 +213,8 @@ void TestTextureClientYCbCr(TextureClient* client, PlanarYCbCrData& ycbcrData) { } // namespace layers } // namespace mozilla -TEST(Layers, TextureSerialization) { +TEST(Layers, TextureSerialization) +{ // the test is run on all the following image formats gfxImageFormat formats[3] = { SurfaceFormat::A8R8G8B8_UINT32, @@ -242,7 +243,8 @@ TEST(Layers, TextureSerialization) { } } -TEST(Layers, TextureYCbCrSerialization) { +TEST(Layers, TextureYCbCrSerialization) +{ RefPtr ySurface = new gfxImageSurface(IntSize(400, 300), SurfaceFormat::A8); RefPtr cbSurface = diff --git a/gfx/tests/gtest/TestTreeTraversal.cpp b/gfx/tests/gtest/TestTreeTraversal.cpp index 652e5494ca0d0..96f2f5c47ecba 100644 --- a/gfx/tests/gtest/TestTreeTraversal.cpp +++ b/gfx/tests/gtest/TestTreeTraversal.cpp @@ -238,7 +238,8 @@ typedef TestNodeReverse ForEachTestNodeReverse; typedef TestNodeForward SearchTestNodeForward; typedef TestNodeForward ForEachTestNodeForward; -TEST(TreeTraversal, DepthFirstSearchNull) { +TEST(TreeTraversal, DepthFirstSearchNull) +{ RefPtr nullNode; RefPtr result = DepthFirstSearch( @@ -249,7 +250,8 @@ TEST(TreeTraversal, DepthFirstSearchNull) { << "Null root did not return null search result."; } -TEST(TreeTraversal, DepthFirstSearchValueExists) { +TEST(TreeTraversal, DepthFirstSearchValueExists) +{ int visitCount = 0; size_t expectedNeedleTraversalRank = 7; RefPtr needleNode; @@ -297,7 +299,8 @@ TEST(TreeTraversal, DepthFirstSearchValueExists) { "happened)."; } -TEST(TreeTraversal, DepthFirstSearchValueExistsReverse) { +TEST(TreeTraversal, DepthFirstSearchValueExistsReverse) +{ int visitCount = 0; size_t expectedNeedleTraversalRank = 7; RefPtr needleNode; @@ -345,7 +348,8 @@ TEST(TreeTraversal, DepthFirstSearchValueExistsReverse) { "happened)."; } -TEST(TreeTraversal, DepthFirstSearchRootIsNeedle) { +TEST(TreeTraversal, DepthFirstSearchRootIsNeedle) +{ RefPtr root = new SearchTestNodeReverse(SearchNodeType::Needle, 0); RefPtr childNode1 = @@ -371,7 +375,8 @@ TEST(TreeTraversal, DepthFirstSearchRootIsNeedle) { << "Search starting at needle continued past needle."; } -TEST(TreeTraversal, DepthFirstSearchValueDoesNotExist) { +TEST(TreeTraversal, DepthFirstSearchValueDoesNotExist) +{ int visitCount = 0; std::vector> nodeList; nodeList.reserve(10); @@ -408,7 +413,8 @@ TEST(TreeTraversal, DepthFirstSearchValueDoesNotExist) { << "Search found something that should not exist."; } -TEST(TreeTraversal, DepthFirstSearchValueDoesNotExistReverse) { +TEST(TreeTraversal, DepthFirstSearchValueDoesNotExistReverse) +{ int visitCount = 0; std::vector> nodeList; nodeList.reserve(10); @@ -445,7 +451,8 @@ TEST(TreeTraversal, DepthFirstSearchValueDoesNotExistReverse) { << "Search found something that should not exist."; } -TEST(TreeTraversal, DepthFirstSearchPostOrderNull) { +TEST(TreeTraversal, DepthFirstSearchPostOrderNull) +{ RefPtr nullNode; RefPtr result = DepthFirstSearchPostOrder( @@ -456,7 +463,8 @@ TEST(TreeTraversal, DepthFirstSearchPostOrderNull) { << "Null root did not return null search result."; } -TEST(TreeTraversal, DepthFirstSearchPostOrderValueExists) { +TEST(TreeTraversal, DepthFirstSearchPostOrderValueExists) +{ int visitCount = 0; size_t expectedNeedleTraversalRank = 7; RefPtr needleNode; @@ -503,7 +511,8 @@ TEST(TreeTraversal, DepthFirstSearchPostOrderValueExists) { "happened)."; } -TEST(TreeTraversal, DepthFirstSearchPostOrderValueExistsReverse) { +TEST(TreeTraversal, DepthFirstSearchPostOrderValueExistsReverse) +{ int visitCount = 0; size_t expectedNeedleTraversalRank = 7; RefPtr needleNode; @@ -550,7 +559,8 @@ TEST(TreeTraversal, DepthFirstSearchPostOrderValueExistsReverse) { "happened)."; } -TEST(TreeTraversal, DepthFirstSearchPostOrderRootIsNeedle) { +TEST(TreeTraversal, DepthFirstSearchPostOrderRootIsNeedle) +{ RefPtr root = new SearchTestNodeReverse(SearchNodeType::Needle, 0); RefPtr childNode1 = @@ -576,7 +586,8 @@ TEST(TreeTraversal, DepthFirstSearchPostOrderRootIsNeedle) { << "Search starting at needle continued past needle."; } -TEST(TreeTraversal, DepthFirstSearchPostOrderValueDoesNotExist) { +TEST(TreeTraversal, DepthFirstSearchPostOrderValueDoesNotExist) +{ int visitCount = 0; std::vector> nodeList; nodeList.reserve(10); @@ -613,7 +624,8 @@ TEST(TreeTraversal, DepthFirstSearchPostOrderValueDoesNotExist) { << "Search found something that should not exist."; } -TEST(TreeTraversal, DepthFirstSearchPostOrderValueDoesNotExistReverse) { +TEST(TreeTraversal, DepthFirstSearchPostOrderValueDoesNotExistReverse) +{ int visitCount = 0; std::vector> nodeList; nodeList.reserve(10); @@ -650,7 +662,8 @@ TEST(TreeTraversal, DepthFirstSearchPostOrderValueDoesNotExistReverse) { << "Search found something that should not exist."; } -TEST(TreeTraversal, BreadthFirstSearchNull) { +TEST(TreeTraversal, BreadthFirstSearchNull) +{ RefPtr nullNode; RefPtr result = BreadthFirstSearch( @@ -661,7 +674,8 @@ TEST(TreeTraversal, BreadthFirstSearchNull) { << "Null root did not return null search result."; } -TEST(TreeTraversal, BreadthFirstSearchRootIsNeedle) { +TEST(TreeTraversal, BreadthFirstSearchRootIsNeedle) +{ RefPtr root = new SearchTestNodeReverse(SearchNodeType::Needle, 0); RefPtr childNode1 = @@ -687,7 +701,8 @@ TEST(TreeTraversal, BreadthFirstSearchRootIsNeedle) { << "Search starting at needle continued past needle."; } -TEST(TreeTraversal, BreadthFirstSearchValueExists) { +TEST(TreeTraversal, BreadthFirstSearchValueExists) +{ int visitCount = 0; size_t expectedNeedleTraversalRank = 7; RefPtr needleNode; @@ -735,7 +750,8 @@ TEST(TreeTraversal, BreadthFirstSearchValueExists) { "happened)."; } -TEST(TreeTraversal, BreadthFirstSearchValueExistsReverse) { +TEST(TreeTraversal, BreadthFirstSearchValueExistsReverse) +{ int visitCount = 0; size_t expectedNeedleTraversalRank = 7; RefPtr needleNode; @@ -783,7 +799,8 @@ TEST(TreeTraversal, BreadthFirstSearchValueExistsReverse) { "happened)."; } -TEST(TreeTraversal, BreadthFirstSearchValueDoesNotExist) { +TEST(TreeTraversal, BreadthFirstSearchValueDoesNotExist) +{ int visitCount = 0; std::vector> nodeList; nodeList.reserve(10); @@ -820,7 +837,8 @@ TEST(TreeTraversal, BreadthFirstSearchValueDoesNotExist) { << "Search found something that should not exist."; } -TEST(TreeTraversal, BreadthFirstSearchValueDoesNotExistReverse) { +TEST(TreeTraversal, BreadthFirstSearchValueDoesNotExistReverse) +{ int visitCount = 0; std::vector> nodeList; nodeList.reserve(10); @@ -857,14 +875,16 @@ TEST(TreeTraversal, BreadthFirstSearchValueDoesNotExistReverse) { << "Search found something that should not exist."; } -TEST(TreeTraversal, ForEachNodeNullStillRuns) { +TEST(TreeTraversal, ForEachNodeNullStillRuns) +{ RefPtr nullNode; ForEachNode( nullNode.get(), [](ForEachTestNodeReverse* aNode) { return TraversalFlag::Continue; }); } -TEST(TreeTraversal, ForEachNodeAllEligible) { +TEST(TreeTraversal, ForEachNodeAllEligible) +{ std::vector> nodeList; int visitCount = 0; nodeList.reserve(10); @@ -900,7 +920,8 @@ TEST(TreeTraversal, ForEachNodeAllEligible) { } } -TEST(TreeTraversal, ForEachNodeAllEligibleReverse) { +TEST(TreeTraversal, ForEachNodeAllEligibleReverse) +{ std::vector> nodeList; int visitCount = 0; nodeList.reserve(10); @@ -936,7 +957,8 @@ TEST(TreeTraversal, ForEachNodeAllEligibleReverse) { } } -TEST(TreeTraversal, ForEachNodeSomeIneligibleNodes) { +TEST(TreeTraversal, ForEachNodeSomeIneligibleNodes) +{ std::vector> expectedVisitedNodeList; std::vector> expectedSkippedNodeList; int visitCount = 0; @@ -990,7 +1012,8 @@ TEST(TreeTraversal, ForEachNodeSomeIneligibleNodes) { } } -TEST(TreeTraversal, ForEachNodeSomeIneligibleNodesReverse) { +TEST(TreeTraversal, ForEachNodeSomeIneligibleNodesReverse) +{ std::vector> expectedVisitedNodeList; std::vector> expectedSkippedNodeList; int visitCount = 0; @@ -1044,7 +1067,8 @@ TEST(TreeTraversal, ForEachNodeSomeIneligibleNodesReverse) { } } -TEST(TreeTraversal, ForEachNodeIneligibleRoot) { +TEST(TreeTraversal, ForEachNodeIneligibleRoot) +{ int visitCount = 0; RefPtr root = @@ -1073,7 +1097,8 @@ TEST(TreeTraversal, ForEachNodeIneligibleRoot) { << "Ineligible child was still hit."; } -TEST(TreeTraversal, ForEachNodeLeavesIneligible) { +TEST(TreeTraversal, ForEachNodeLeavesIneligible) +{ std::vector> nodeList; nodeList.reserve(10); int visitCount = 0; @@ -1113,7 +1138,8 @@ TEST(TreeTraversal, ForEachNodeLeavesIneligible) { } } -TEST(TreeTraversal, ForEachNodeLeavesIneligibleReverse) { +TEST(TreeTraversal, ForEachNodeLeavesIneligibleReverse) +{ std::vector> nodeList; nodeList.reserve(10); int visitCount = 0; @@ -1153,7 +1179,8 @@ TEST(TreeTraversal, ForEachNodeLeavesIneligibleReverse) { } } -TEST(TreeTraversal, ForEachNodeLambdaReturnsVoid) { +TEST(TreeTraversal, ForEachNodeLambdaReturnsVoid) +{ std::vector> nodeList; nodeList.reserve(10); int visitCount = 0; diff --git a/gfx/tests/gtest/gfxSurfaceRefCountTest.cpp b/gfx/tests/gtest/gfxSurfaceRefCountTest.cpp index 4caca66854d1b..c7106070b7d48 100644 --- a/gfx/tests/gtest/gfxSurfaceRefCountTest.cpp +++ b/gfx/tests/gtest/gfxSurfaceRefCountTest.cpp @@ -141,7 +141,8 @@ static int TestExistingSurface() { return failures; } -TEST(Gfx, SurfaceRefCount) { +TEST(Gfx, SurfaceRefCount) +{ int fail; fail = TestNewSurface(); diff --git a/gfx/thebes/gfxFontUtils.h b/gfx/thebes/gfxFontUtils.h index 3f8e7c9345722..f35015dcccceb 100644 --- a/gfx/thebes/gfxFontUtils.h +++ b/gfx/thebes/gfxFontUtils.h @@ -412,7 +412,9 @@ class SharedBitSet { SharedBitSet() = delete; explicit SharedBitSet(const gfxSparseBitSet& aBitset) - : mBlockIndexCount(mozilla::AssertedCast(aBitset.mBlockIndex.Length())), mBlockCount(0) { + : mBlockIndexCount( + mozilla::AssertedCast(aBitset.mBlockIndex.Length())), + mBlockCount(0) { uint16_t* blockIndex = reinterpret_cast(this + 1); Block* blocks = reinterpret_cast(blockIndex + mBlockIndexCount); for (uint16_t i = 0; i < mBlockIndexCount; i++) { diff --git a/gfx/thebes/gfxTypes.h b/gfx/thebes/gfxTypes.h index 8d625e243a3e3..71829716f5898 100644 --- a/gfx/thebes/gfxTypes.h +++ b/gfx/thebes/gfxTypes.h @@ -13,7 +13,7 @@ typedef struct _cairo_surface cairo_surface_t; typedef struct _cairo_user_data_key cairo_user_data_key_t; -typedef void (*thebes_destroy_func_t)(void *data); +typedef void (*thebes_destroy_func_t)(void* data); /** * Currently needs to be 'double' for Cairo compatibility. Could diff --git a/gfx/vr/VRDisplayClient.cpp b/gfx/vr/VRDisplayClient.cpp index 028f76abca0d4..1e7f77425c83f 100644 --- a/gfx/vr/VRDisplayClient.cpp +++ b/gfx/vr/VRDisplayClient.cpp @@ -158,10 +158,10 @@ void VRDisplayClient::FireGamepadEvents() { // axis count. So, we need to check if they are more than zero. if ((lastState.controllerName[0] == '\0' || !existing) && (state.numButtons > 0 || state.numAxes > 0)) { - dom::GamepadAdded info( - NS_ConvertUTF8toUTF16(state.controllerName), - dom::GamepadMappingType::_empty, state.hand, mDisplayInfo.mDisplayID, - state.numButtons, state.numAxes, state.numHaptics); + dom::GamepadAdded info(NS_ConvertUTF8toUTF16(state.controllerName), + dom::GamepadMappingType::_empty, state.hand, + mDisplayInfo.mDisplayID, state.numButtons, + state.numAxes, state.numHaptics); dom::GamepadChangeEventBody body(info); dom::GamepadChangeEvent event(gamepadId, dom::GamepadServiceType::VR, body); diff --git a/gfx/vr/ipc/VRChild.cpp b/gfx/vr/ipc/VRChild.cpp index aaf00a6045a51..1b5227f2fce01 100644 --- a/gfx/vr/ipc/VRChild.cpp +++ b/gfx/vr/ipc/VRChild.cpp @@ -67,9 +67,7 @@ class OpenVRControllerManifestManager { StaticRefPtr sOpenVRControllerManifestManager; -VRChild::VRChild(VRProcessParent* aHost) - : mHost(aHost), - mVRReady(false) { +VRChild::VRChild(VRProcessParent* aHost) : mHost(aHost), mVRReady(false) { MOZ_ASSERT(XRE_IsParentProcess()); } @@ -200,9 +198,9 @@ mozilla::ipc::IPCResult VRChild::RecvInitCrashReporter( } bool VRChild::SendRequestMemoryReport(const uint32_t& aGeneration, - const bool& aAnonymize, - const bool& aMinimizeMemoryUsage, - const Maybe& aDMDFile) { + const bool& aAnonymize, + const bool& aMinimizeMemoryUsage, + const Maybe& aDMDFile) { mMemoryReportRequest = MakeUnique(aGeneration); Unused << PVRChild::SendRequestMemoryReport(aGeneration, aAnonymize, aMinimizeMemoryUsage, aDMDFile); diff --git a/image/test/gtest/TestADAM7InterpolatingFilter.cpp b/image/test/gtest/TestADAM7InterpolatingFilter.cpp index 0327da7561a23..b243977dd9e60 100644 --- a/image/test/gtest/TestADAM7InterpolatingFilter.cpp +++ b/image/test/gtest/TestADAM7InterpolatingFilter.cpp @@ -430,51 +430,41 @@ void CheckADAM7InterpolatingWritePixels(const IntSize& aSize) { }); } -TEST(ImageADAM7InterpolatingFilter, WritePixels100_100) { - CheckADAM7InterpolatingWritePixels(IntSize(100, 100)); -} +TEST(ImageADAM7InterpolatingFilter, WritePixels100_100) +{ CheckADAM7InterpolatingWritePixels(IntSize(100, 100)); } -TEST(ImageADAM7InterpolatingFilter, WritePixels99_99) { - CheckADAM7InterpolatingWritePixels(IntSize(99, 99)); -} +TEST(ImageADAM7InterpolatingFilter, WritePixels99_99) +{ CheckADAM7InterpolatingWritePixels(IntSize(99, 99)); } -TEST(ImageADAM7InterpolatingFilter, WritePixels66_33) { - CheckADAM7InterpolatingWritePixels(IntSize(66, 33)); -} +TEST(ImageADAM7InterpolatingFilter, WritePixels66_33) +{ CheckADAM7InterpolatingWritePixels(IntSize(66, 33)); } -TEST(ImageADAM7InterpolatingFilter, WritePixels33_66) { - CheckADAM7InterpolatingWritePixels(IntSize(33, 66)); -} +TEST(ImageADAM7InterpolatingFilter, WritePixels33_66) +{ CheckADAM7InterpolatingWritePixels(IntSize(33, 66)); } -TEST(ImageADAM7InterpolatingFilter, WritePixels15_15) { - CheckADAM7InterpolatingWritePixels(IntSize(15, 15)); -} +TEST(ImageADAM7InterpolatingFilter, WritePixels15_15) +{ CheckADAM7InterpolatingWritePixels(IntSize(15, 15)); } -TEST(ImageADAM7InterpolatingFilter, WritePixels9_9) { - CheckADAM7InterpolatingWritePixels(IntSize(9, 9)); -} +TEST(ImageADAM7InterpolatingFilter, WritePixels9_9) +{ CheckADAM7InterpolatingWritePixels(IntSize(9, 9)); } -TEST(ImageADAM7InterpolatingFilter, WritePixels8_8) { - CheckADAM7InterpolatingWritePixels(IntSize(8, 8)); -} +TEST(ImageADAM7InterpolatingFilter, WritePixels8_8) +{ CheckADAM7InterpolatingWritePixels(IntSize(8, 8)); } -TEST(ImageADAM7InterpolatingFilter, WritePixels7_7) { - CheckADAM7InterpolatingWritePixels(IntSize(7, 7)); -} +TEST(ImageADAM7InterpolatingFilter, WritePixels7_7) +{ CheckADAM7InterpolatingWritePixels(IntSize(7, 7)); } -TEST(ImageADAM7InterpolatingFilter, WritePixels3_3) { - CheckADAM7InterpolatingWritePixels(IntSize(3, 3)); -} +TEST(ImageADAM7InterpolatingFilter, WritePixels3_3) +{ CheckADAM7InterpolatingWritePixels(IntSize(3, 3)); } -TEST(ImageADAM7InterpolatingFilter, WritePixels1_1) { - CheckADAM7InterpolatingWritePixels(IntSize(1, 1)); -} +TEST(ImageADAM7InterpolatingFilter, WritePixels1_1) +{ CheckADAM7InterpolatingWritePixels(IntSize(1, 1)); } -TEST(ImageADAM7InterpolatingFilter, TrivialInterpolation48_48) { - CheckInterpolation(IntSize(48, 48), {BGRAColor::Green()}); -} +TEST(ImageADAM7InterpolatingFilter, TrivialInterpolation48_48) +{ CheckInterpolation(IntSize(48, 48), {BGRAColor::Green()}); } -TEST(ImageADAM7InterpolatingFilter, InterpolationOutput33_17) { +TEST(ImageADAM7InterpolatingFilter, InterpolationOutput33_17) +{ // We check interpolation using irregular patterns to make sure that the // interpolation will look different for different passes. CheckInterpolation( @@ -492,7 +482,8 @@ TEST(ImageADAM7InterpolatingFilter, InterpolationOutput33_17) { BGRAColor::Red(), BGRAColor::Blue()}); } -TEST(ImageADAM7InterpolatingFilter, InterpolationOutput32_16) { +TEST(ImageADAM7InterpolatingFilter, InterpolationOutput32_16) +{ CheckInterpolation( IntSize(32, 16), {BGRAColor::Green(), BGRAColor::Red(), BGRAColor::Green(), @@ -508,7 +499,8 @@ TEST(ImageADAM7InterpolatingFilter, InterpolationOutput32_16) { BGRAColor::Red(), BGRAColor::Blue()}); } -TEST(ImageADAM7InterpolatingFilter, InterpolationOutput31_15) { +TEST(ImageADAM7InterpolatingFilter, InterpolationOutput31_15) +{ CheckInterpolation( IntSize(31, 15), {BGRAColor::Green(), BGRAColor::Red(), BGRAColor::Green(), @@ -524,7 +516,8 @@ TEST(ImageADAM7InterpolatingFilter, InterpolationOutput31_15) { BGRAColor::Red(), BGRAColor::Blue()}); } -TEST(ImageADAM7InterpolatingFilter, InterpolationOutput17_33) { +TEST(ImageADAM7InterpolatingFilter, InterpolationOutput17_33) +{ CheckInterpolation(IntSize(17, 33), {BGRAColor::Green(), BGRAColor::Red(), BGRAColor::Green(), BGRAColor::Blue(), BGRAColor::Red(), BGRAColor::Green(), @@ -534,7 +527,8 @@ TEST(ImageADAM7InterpolatingFilter, InterpolationOutput17_33) { BGRAColor::Blue()}); } -TEST(ImageADAM7InterpolatingFilter, InterpolationOutput16_32) { +TEST(ImageADAM7InterpolatingFilter, InterpolationOutput16_32) +{ CheckInterpolation(IntSize(16, 32), {BGRAColor::Green(), BGRAColor::Red(), BGRAColor::Green(), BGRAColor::Blue(), BGRAColor::Red(), BGRAColor::Green(), @@ -544,7 +538,8 @@ TEST(ImageADAM7InterpolatingFilter, InterpolationOutput16_32) { BGRAColor::Blue()}); } -TEST(ImageADAM7InterpolatingFilter, InterpolationOutput15_31) { +TEST(ImageADAM7InterpolatingFilter, InterpolationOutput15_31) +{ CheckInterpolation(IntSize(15, 31), {BGRAColor::Green(), BGRAColor::Red(), BGRAColor::Green(), BGRAColor::Blue(), BGRAColor::Red(), BGRAColor::Green(), @@ -554,42 +549,47 @@ TEST(ImageADAM7InterpolatingFilter, InterpolationOutput15_31) { BGRAColor::Blue()}); } -TEST(ImageADAM7InterpolatingFilter, InterpolationOutput9_9) { +TEST(ImageADAM7InterpolatingFilter, InterpolationOutput9_9) +{ CheckInterpolation(IntSize(9, 9), {BGRAColor::Blue(), BGRAColor::Blue(), BGRAColor::Red(), BGRAColor::Green(), BGRAColor::Green(), BGRAColor::Red(), BGRAColor::Red(), BGRAColor::Blue()}); } -TEST(ImageADAM7InterpolatingFilter, InterpolationOutput8_8) { +TEST(ImageADAM7InterpolatingFilter, InterpolationOutput8_8) +{ CheckInterpolation(IntSize(8, 8), {BGRAColor::Blue(), BGRAColor::Blue(), BGRAColor::Red(), BGRAColor::Green(), BGRAColor::Green(), BGRAColor::Red(), BGRAColor::Red(), BGRAColor::Blue()}); } -TEST(ImageADAM7InterpolatingFilter, InterpolationOutput7_7) { +TEST(ImageADAM7InterpolatingFilter, InterpolationOutput7_7) +{ CheckInterpolation(IntSize(7, 7), {BGRAColor::Blue(), BGRAColor::Blue(), BGRAColor::Red(), BGRAColor::Green(), BGRAColor::Green(), BGRAColor::Red(), BGRAColor::Red(), BGRAColor::Blue()}); } -TEST(ImageADAM7InterpolatingFilter, InterpolationOutput3_3) { +TEST(ImageADAM7InterpolatingFilter, InterpolationOutput3_3) +{ CheckInterpolation(IntSize(3, 3), {BGRAColor::Green(), BGRAColor::Red(), BGRAColor::Blue(), BGRAColor::Red()}); } -TEST(ImageADAM7InterpolatingFilter, InterpolationOutput1_1) { - CheckInterpolation(IntSize(1, 1), {BGRAColor::Blue()}); -} +TEST(ImageADAM7InterpolatingFilter, InterpolationOutput1_1) +{ CheckInterpolation(IntSize(1, 1), {BGRAColor::Blue()}); } -TEST(ImageADAM7InterpolatingFilter, ADAM7InterpolationFailsFor0_0) { +TEST(ImageADAM7InterpolatingFilter, ADAM7InterpolationFailsFor0_0) +{ // A 0x0 input size is invalid, so configuration should fail. AssertConfiguringADAM7InterpolatingFilterFails(IntSize(0, 0)); } -TEST(ImageADAM7InterpolatingFilter, ADAM7InterpolationFailsForMinus1_Minus1) { +TEST(ImageADAM7InterpolatingFilter, ADAM7InterpolationFailsForMinus1_Minus1) +{ // A negative input size is invalid, so configuration should fail. AssertConfiguringADAM7InterpolatingFilterFails(IntSize(-1, -1)); } diff --git a/image/test/gtest/TestBlendAnimationFilter.cpp b/image/test/gtest/TestBlendAnimationFilter.cpp index b7ae3b5877a16..3106a38664a7c 100644 --- a/image/test/gtest/TestBlendAnimationFilter.cpp +++ b/image/test/gtest/TestBlendAnimationFilter.cpp @@ -71,13 +71,15 @@ void AssertConfiguringBlendAnimationFilterFails(const IntRect& aFrameRect, AssertConfiguringPipelineFails(decoder, blendAnim, surfaceSink); } -TEST(ImageBlendAnimationFilter, BlendFailsForNegativeFrameRect) { +TEST(ImageBlendAnimationFilter, BlendFailsForNegativeFrameRect) +{ // A negative frame rect size is disallowed. AssertConfiguringBlendAnimationFilterFails( IntRect(IntPoint(0, 0), IntSize(-1, -1)), IntSize(100, 100)); } -TEST(ImageBlendAnimationFilter, WriteFullFirstFrame) { +TEST(ImageBlendAnimationFilter, WriteFullFirstFrame) +{ RefPtr decoder = CreateTrivialBlendingDecoder(); ASSERT_TRUE(decoder != nullptr); @@ -92,7 +94,8 @@ TEST(ImageBlendAnimationFilter, WriteFullFirstFrame) { EXPECT_EQ(IntRect(0, 0, 100, 100), frame0->GetDirtyRect()); } -TEST(ImageBlendAnimationFilter, WritePartialFirstFrame) { +TEST(ImageBlendAnimationFilter, WritePartialFirstFrame) +{ RefPtr decoder = CreateTrivialBlendingDecoder(); ASSERT_TRUE(decoder != nullptr); @@ -164,15 +167,14 @@ static void TestWithBlendAnimationFilterClear(BlendMethod aBlendMethod) { EXPECT_TRUE(RowsAreSolidColor(surface, 70, 30, BGRAColor::Green())); } -TEST(ImageBlendAnimationFilter, ClearWithOver) { - TestWithBlendAnimationFilterClear(BlendMethod::OVER); -} +TEST(ImageBlendAnimationFilter, ClearWithOver) +{ TestWithBlendAnimationFilterClear(BlendMethod::OVER); } -TEST(ImageBlendAnimationFilter, ClearWithSource) { - TestWithBlendAnimationFilterClear(BlendMethod::SOURCE); -} +TEST(ImageBlendAnimationFilter, ClearWithSource) +{ TestWithBlendAnimationFilterClear(BlendMethod::SOURCE); } -TEST(ImageBlendAnimationFilter, KeepWithSource) { +TEST(ImageBlendAnimationFilter, KeepWithSource) +{ RefPtr decoder = CreateTrivialBlendingDecoder(); ASSERT_TRUE(decoder != nullptr); @@ -208,7 +210,8 @@ TEST(ImageBlendAnimationFilter, KeepWithSource) { EXPECT_TRUE(RowsAreSolidColor(surface, 60, 40, BGRAColor::Green())); } -TEST(ImageBlendAnimationFilter, KeepWithOver) { +TEST(ImageBlendAnimationFilter, KeepWithOver) +{ RefPtr decoder = CreateTrivialBlendingDecoder(); ASSERT_TRUE(decoder != nullptr); @@ -250,7 +253,8 @@ TEST(ImageBlendAnimationFilter, KeepWithOver) { EXPECT_TRUE(RowsAreSolidColor(surface, 60, 40, frameColor0)); } -TEST(ImageBlendAnimationFilter, RestorePreviousWithOver) { +TEST(ImageBlendAnimationFilter, RestorePreviousWithOver) +{ RefPtr decoder = CreateTrivialBlendingDecoder(); ASSERT_TRUE(decoder != nullptr); @@ -305,7 +309,8 @@ TEST(ImageBlendAnimationFilter, RestorePreviousWithOver) { EXPECT_TRUE(RowsAreSolidColor(surface, 60, 40, frameColor0)); } -TEST(ImageBlendAnimationFilter, RestorePreviousWithSource) { +TEST(ImageBlendAnimationFilter, RestorePreviousWithSource) +{ RefPtr decoder = CreateTrivialBlendingDecoder(); ASSERT_TRUE(decoder != nullptr); @@ -356,7 +361,8 @@ TEST(ImageBlendAnimationFilter, RestorePreviousWithSource) { EXPECT_TRUE(RowsAreSolidColor(surface, 60, 40, frameColor0)); } -TEST(ImageBlendAnimationFilter, RestorePreviousClearWithSource) { +TEST(ImageBlendAnimationFilter, RestorePreviousClearWithSource) +{ RefPtr decoder = CreateTrivialBlendingDecoder(); ASSERT_TRUE(decoder != nullptr); @@ -421,7 +427,8 @@ TEST(ImageBlendAnimationFilter, RestorePreviousClearWithSource) { EXPECT_TRUE(RowsAreSolidColor(surface, 60, 40, frameColor0)); } -TEST(ImageBlendAnimationFilter, PartialOverlapFrameRect) { +TEST(ImageBlendAnimationFilter, PartialOverlapFrameRect) +{ RefPtr decoder = CreateTrivialBlendingDecoder(); ASSERT_TRUE(decoder != nullptr); diff --git a/image/test/gtest/TestCopyOnWrite.cpp b/image/test/gtest/TestCopyOnWrite.cpp index 69682c48539f8..d5ad3e4f6b5f5 100644 --- a/image/test/gtest/TestCopyOnWrite.cpp +++ b/image/test/gtest/TestCopyOnWrite.cpp @@ -41,7 +41,8 @@ struct Value { int32_t mSerial; }; -TEST(ImageCopyOnWrite, Read) { +TEST(ImageCopyOnWrite, Read) +{ ValueStats stats; { @@ -74,7 +75,8 @@ TEST(ImageCopyOnWrite, Read) { EXPECT_EQ(1, stats.mFrees); } -TEST(ImageCopyOnWrite, RecursiveRead) { +TEST(ImageCopyOnWrite, RecursiveRead) +{ ValueStats stats; { @@ -121,7 +123,8 @@ TEST(ImageCopyOnWrite, RecursiveRead) { EXPECT_EQ(1, stats.mFrees); } -TEST(ImageCopyOnWrite, Write) { +TEST(ImageCopyOnWrite, Write) +{ ValueStats stats; { @@ -155,7 +158,8 @@ TEST(ImageCopyOnWrite, Write) { EXPECT_EQ(1, stats.mFrees); } -TEST(ImageCopyOnWrite, WriteRecursive) { +TEST(ImageCopyOnWrite, WriteRecursive) +{ ValueStats stats; { diff --git a/image/test/gtest/TestDownscalingFilter.cpp b/image/test/gtest/TestDownscalingFilter.cpp index b95772ab5c1e0..8fa7ceadcae7e 100644 --- a/image/test/gtest/TestDownscalingFilter.cpp +++ b/image/test/gtest/TestDownscalingFilter.cpp @@ -40,7 +40,8 @@ void AssertConfiguringDownscalingFilterFails(const IntSize& aInputSize, SurfaceConfig{decoder, aOutputSize, SurfaceFormat::B8G8R8A8, false}); } -TEST(ImageDownscalingFilter, WritePixels100_100to99_99) { +TEST(ImageDownscalingFilter, WritePixels100_100to99_99) +{ WithDownscalingFilter(IntSize(100, 100), IntSize(99, 99), [](Decoder* aDecoder, SurfaceFilter* aFilter) { CheckWritePixels( @@ -49,7 +50,8 @@ TEST(ImageDownscalingFilter, WritePixels100_100to99_99) { }); } -TEST(ImageDownscalingFilter, WritePixels100_100to33_33) { +TEST(ImageDownscalingFilter, WritePixels100_100to33_33) +{ WithDownscalingFilter(IntSize(100, 100), IntSize(33, 33), [](Decoder* aDecoder, SurfaceFilter* aFilter) { CheckWritePixels( @@ -58,7 +60,8 @@ TEST(ImageDownscalingFilter, WritePixels100_100to33_33) { }); } -TEST(ImageDownscalingFilter, WritePixels100_100to1_1) { +TEST(ImageDownscalingFilter, WritePixels100_100to1_1) +{ WithDownscalingFilter(IntSize(100, 100), IntSize(1, 1), [](Decoder* aDecoder, SurfaceFilter* aFilter) { CheckWritePixels( @@ -67,7 +70,8 @@ TEST(ImageDownscalingFilter, WritePixels100_100to1_1) { }); } -TEST(ImageDownscalingFilter, WritePixels100_100to33_99) { +TEST(ImageDownscalingFilter, WritePixels100_100to33_99) +{ WithDownscalingFilter(IntSize(100, 100), IntSize(33, 99), [](Decoder* aDecoder, SurfaceFilter* aFilter) { CheckWritePixels( @@ -76,7 +80,8 @@ TEST(ImageDownscalingFilter, WritePixels100_100to33_99) { }); } -TEST(ImageDownscalingFilter, WritePixels100_100to99_33) { +TEST(ImageDownscalingFilter, WritePixels100_100to99_33) +{ WithDownscalingFilter(IntSize(100, 100), IntSize(99, 33), [](Decoder* aDecoder, SurfaceFilter* aFilter) { CheckWritePixels( @@ -85,7 +90,8 @@ TEST(ImageDownscalingFilter, WritePixels100_100to99_33) { }); } -TEST(ImageDownscalingFilter, WritePixels100_100to99_1) { +TEST(ImageDownscalingFilter, WritePixels100_100to99_1) +{ WithDownscalingFilter(IntSize(100, 100), IntSize(99, 1), [](Decoder* aDecoder, SurfaceFilter* aFilter) { CheckWritePixels( @@ -94,7 +100,8 @@ TEST(ImageDownscalingFilter, WritePixels100_100to99_1) { }); } -TEST(ImageDownscalingFilter, WritePixels100_100to1_99) { +TEST(ImageDownscalingFilter, WritePixels100_100to1_99) +{ WithDownscalingFilter(IntSize(100, 100), IntSize(1, 99), [](Decoder* aDecoder, SurfaceFilter* aFilter) { CheckWritePixels( @@ -103,37 +110,44 @@ TEST(ImageDownscalingFilter, WritePixels100_100to1_99) { }); } -TEST(ImageDownscalingFilter, DownscalingFailsFor100_100to101_101) { +TEST(ImageDownscalingFilter, DownscalingFailsFor100_100to101_101) +{ // Upscaling is disallowed. AssertConfiguringDownscalingFilterFails(IntSize(100, 100), IntSize(101, 101)); } -TEST(ImageDownscalingFilter, DownscalingFailsFor100_100to100_100) { +TEST(ImageDownscalingFilter, DownscalingFailsFor100_100to100_100) +{ // "Scaling" to the same size is disallowed. AssertConfiguringDownscalingFilterFails(IntSize(100, 100), IntSize(100, 100)); } -TEST(ImageDownscalingFilter, DownscalingFailsFor0_0toMinus1_Minus1) { +TEST(ImageDownscalingFilter, DownscalingFailsFor0_0toMinus1_Minus1) +{ // A 0x0 input size is disallowed. AssertConfiguringDownscalingFilterFails(IntSize(0, 0), IntSize(-1, -1)); } -TEST(ImageDownscalingFilter, DownscalingFailsForMinus1_Minus1toMinus2_Minus2) { +TEST(ImageDownscalingFilter, DownscalingFailsForMinus1_Minus1toMinus2_Minus2) +{ // A negative input size is disallowed. AssertConfiguringDownscalingFilterFails(IntSize(-1, -1), IntSize(-2, -2)); } -TEST(ImageDownscalingFilter, DownscalingFailsFor100_100to0_0) { +TEST(ImageDownscalingFilter, DownscalingFailsFor100_100to0_0) +{ // A 0x0 output size is disallowed. AssertConfiguringDownscalingFilterFails(IntSize(100, 100), IntSize(0, 0)); } -TEST(ImageDownscalingFilter, DownscalingFailsFor100_100toMinus1_Minus1) { +TEST(ImageDownscalingFilter, DownscalingFailsFor100_100toMinus1_Minus1) +{ // A negative output size is disallowed. AssertConfiguringDownscalingFilterFails(IntSize(100, 100), IntSize(-1, -1)); } -TEST(ImageDownscalingFilter, WritePixelsOutput100_100to20_20) { +TEST(ImageDownscalingFilter, WritePixelsOutput100_100to20_20) +{ WithDownscalingFilter( IntSize(100, 100), IntSize(20, 20), [](Decoder* aDecoder, SurfaceFilter* aFilter) { @@ -174,7 +188,8 @@ TEST(ImageDownscalingFilter, WritePixelsOutput100_100to20_20) { }); } -TEST(ImageDownscalingFilter, WritePixelsOutput100_100to10_20) { +TEST(ImageDownscalingFilter, WritePixelsOutput100_100to10_20) +{ WithDownscalingFilter( IntSize(100, 100), IntSize(10, 20), [](Decoder* aDecoder, SurfaceFilter* aFilter) { diff --git a/image/test/gtest/TestDownscalingFilterNoSkia.cpp b/image/test/gtest/TestDownscalingFilterNoSkia.cpp index 5d784734bd647..c2e19d3cd8525 100644 --- a/image/test/gtest/TestDownscalingFilterNoSkia.cpp +++ b/image/test/gtest/TestDownscalingFilterNoSkia.cpp @@ -43,7 +43,8 @@ using namespace mozilla; using namespace mozilla::gfx; using namespace mozilla::image; -TEST(ImageDownscalingFilter, NoSkia) { +TEST(ImageDownscalingFilter, NoSkia) +{ RefPtr decoder = CreateTrivialDecoder(); ASSERT_TRUE(bool(decoder)); diff --git a/image/test/gtest/TestRemoveFrameRectFilter.cpp b/image/test/gtest/TestRemoveFrameRectFilter.cpp index 0081d2c85cce9..acbf54ebac2bd 100644 --- a/image/test/gtest/TestRemoveFrameRectFilter.cpp +++ b/image/test/gtest/TestRemoveFrameRectFilter.cpp @@ -39,7 +39,8 @@ void AssertConfiguringRemoveFrameRectFilterFails(const IntSize& aSize, SurfaceConfig{decoder, aSize, SurfaceFormat::B8G8R8A8, false}); } -TEST(ImageRemoveFrameRectFilter, WritePixels100_100_to_0_0_100_100) { +TEST(ImageRemoveFrameRectFilter, WritePixels100_100_to_0_0_100_100) +{ WithRemoveFrameRectFilter( IntSize(100, 100), IntRect(0, 0, 100, 100), [](Decoder* aDecoder, SurfaceFilter* aFilter) { @@ -50,7 +51,8 @@ TEST(ImageRemoveFrameRectFilter, WritePixels100_100_to_0_0_100_100) { }); } -TEST(ImageRemoveFrameRectFilter, WritePixels100_100_to_0_0_0_0) { +TEST(ImageRemoveFrameRectFilter, WritePixels100_100_to_0_0_0_0) +{ WithRemoveFrameRectFilter( IntSize(100, 100), IntRect(0, 0, 0, 0), [](Decoder* aDecoder, SurfaceFilter* aFilter) { @@ -62,7 +64,8 @@ TEST(ImageRemoveFrameRectFilter, WritePixels100_100_to_0_0_0_0) { }); } -TEST(ImageRemoveFrameRectFilter, WritePixels100_100_to_Minus50_50_0_0) { +TEST(ImageRemoveFrameRectFilter, WritePixels100_100_to_Minus50_50_0_0) +{ WithRemoveFrameRectFilter( IntSize(100, 100), IntRect(-50, 50, 0, 0), [](Decoder* aDecoder, SurfaceFilter* aFilter) { @@ -74,7 +77,8 @@ TEST(ImageRemoveFrameRectFilter, WritePixels100_100_to_Minus50_50_0_0) { }); } -TEST(ImageRemoveFrameRectFilter, WritePixels100_100_to_50_Minus50_0_0) { +TEST(ImageRemoveFrameRectFilter, WritePixels100_100_to_50_Minus50_0_0) +{ WithRemoveFrameRectFilter( IntSize(100, 100), IntRect(50, -50, 0, 0), [](Decoder* aDecoder, SurfaceFilter* aFilter) { @@ -86,7 +90,8 @@ TEST(ImageRemoveFrameRectFilter, WritePixels100_100_to_50_Minus50_0_0) { }); } -TEST(ImageRemoveFrameRectFilter, WritePixels100_100_to_150_50_0_0) { +TEST(ImageRemoveFrameRectFilter, WritePixels100_100_to_150_50_0_0) +{ WithRemoveFrameRectFilter( IntSize(100, 100), IntRect(150, 50, 0, 0), [](Decoder* aDecoder, SurfaceFilter* aFilter) { @@ -98,7 +103,8 @@ TEST(ImageRemoveFrameRectFilter, WritePixels100_100_to_150_50_0_0) { }); } -TEST(ImageRemoveFrameRectFilter, WritePixels100_100_to_50_150_0_0) { +TEST(ImageRemoveFrameRectFilter, WritePixels100_100_to_50_150_0_0) +{ WithRemoveFrameRectFilter( IntSize(100, 100), IntRect(50, 150, 0, 0), [](Decoder* aDecoder, SurfaceFilter* aFilter) { @@ -110,7 +116,8 @@ TEST(ImageRemoveFrameRectFilter, WritePixels100_100_to_50_150_0_0) { }); } -TEST(ImageRemoveFrameRectFilter, WritePixels100_100_to_200_200_100_100) { +TEST(ImageRemoveFrameRectFilter, WritePixels100_100_to_200_200_100_100) +{ WithRemoveFrameRectFilter( IntSize(100, 100), IntRect(200, 200, 100, 100), [](Decoder* aDecoder, SurfaceFilter* aFilter) { @@ -125,7 +132,8 @@ TEST(ImageRemoveFrameRectFilter, WritePixels100_100_to_200_200_100_100) { }); } -TEST(ImageRemoveFrameRectFilter, WritePixels100_100_to_Minus200_25_100_100) { +TEST(ImageRemoveFrameRectFilter, WritePixels100_100_to_Minus200_25_100_100) +{ WithRemoveFrameRectFilter( IntSize(100, 100), IntRect(-200, 25, 100, 100), [](Decoder* aDecoder, SurfaceFilter* aFilter) { @@ -140,7 +148,8 @@ TEST(ImageRemoveFrameRectFilter, WritePixels100_100_to_Minus200_25_100_100) { }); } -TEST(ImageRemoveFrameRectFilter, WritePixels100_100_to_25_Minus200_100_100) { +TEST(ImageRemoveFrameRectFilter, WritePixels100_100_to_25_Minus200_100_100) +{ WithRemoveFrameRectFilter( IntSize(100, 100), IntRect(25, -200, 100, 100), [](Decoder* aDecoder, SurfaceFilter* aFilter) { @@ -155,7 +164,8 @@ TEST(ImageRemoveFrameRectFilter, WritePixels100_100_to_25_Minus200_100_100) { }); } -TEST(ImageRemoveFrameRectFilter, WritePixels100_100_to_200_25_100_100) { +TEST(ImageRemoveFrameRectFilter, WritePixels100_100_to_200_25_100_100) +{ WithRemoveFrameRectFilter( IntSize(100, 100), IntRect(200, 25, 100, 100), [](Decoder* aDecoder, SurfaceFilter* aFilter) { @@ -170,7 +180,8 @@ TEST(ImageRemoveFrameRectFilter, WritePixels100_100_to_200_25_100_100) { }); } -TEST(ImageRemoveFrameRectFilter, WritePixels100_100_to_25_200_100_100) { +TEST(ImageRemoveFrameRectFilter, WritePixels100_100_to_25_200_100_100) +{ WithRemoveFrameRectFilter( IntSize(100, 100), IntRect(25, 200, 100, 100), [](Decoder* aDecoder, SurfaceFilter* aFilter) { @@ -186,7 +197,8 @@ TEST(ImageRemoveFrameRectFilter, WritePixels100_100_to_25_200_100_100) { } TEST(ImageRemoveFrameRectFilter, - WritePixels100_100_to_Minus200_Minus200_100_100) { + WritePixels100_100_to_Minus200_Minus200_100_100) +{ WithRemoveFrameRectFilter( IntSize(100, 100), IntRect(-200, -200, 100, 100), [](Decoder* aDecoder, SurfaceFilter* aFilter) { @@ -198,8 +210,8 @@ TEST(ImageRemoveFrameRectFilter, }); } -TEST(ImageRemoveFrameRectFilter, - WritePixels100_100_to_Minus50_Minus50_100_100) { +TEST(ImageRemoveFrameRectFilter, WritePixels100_100_to_Minus50_Minus50_100_100) +{ WithRemoveFrameRectFilter( IntSize(100, 100), IntRect(-50, -50, 100, 100), [](Decoder* aDecoder, SurfaceFilter* aFilter) { @@ -211,7 +223,8 @@ TEST(ImageRemoveFrameRectFilter, }); } -TEST(ImageRemoveFrameRectFilter, WritePixels100_100_to_Minus50_25_100_50) { +TEST(ImageRemoveFrameRectFilter, WritePixels100_100_to_Minus50_25_100_50) +{ WithRemoveFrameRectFilter( IntSize(100, 100), IntRect(-50, 25, 100, 50), [](Decoder* aDecoder, SurfaceFilter* aFilter) { @@ -223,7 +236,8 @@ TEST(ImageRemoveFrameRectFilter, WritePixels100_100_to_Minus50_25_100_50) { }); } -TEST(ImageRemoveFrameRectFilter, WritePixels100_100_to_25_Minus50_50_100) { +TEST(ImageRemoveFrameRectFilter, WritePixels100_100_to_25_Minus50_50_100) +{ WithRemoveFrameRectFilter( IntSize(100, 100), IntRect(25, -50, 50, 100), [](Decoder* aDecoder, SurfaceFilter* aFilter) { @@ -235,7 +249,8 @@ TEST(ImageRemoveFrameRectFilter, WritePixels100_100_to_25_Minus50_50_100) { }); } -TEST(ImageRemoveFrameRectFilter, WritePixels100_100_to_50_25_100_50) { +TEST(ImageRemoveFrameRectFilter, WritePixels100_100_to_50_25_100_50) +{ WithRemoveFrameRectFilter( IntSize(100, 100), IntRect(50, 25, 100, 50), [](Decoder* aDecoder, SurfaceFilter* aFilter) { @@ -248,7 +263,8 @@ TEST(ImageRemoveFrameRectFilter, WritePixels100_100_to_50_25_100_50) { }); } -TEST(ImageRemoveFrameRectFilter, WritePixels100_100_to_25_50_50_100) { +TEST(ImageRemoveFrameRectFilter, WritePixels100_100_to_25_50_50_100) +{ WithRemoveFrameRectFilter( IntSize(100, 100), IntRect(25, 50, 50, 100), [](Decoder* aDecoder, SurfaceFilter* aFilter) { @@ -264,27 +280,31 @@ TEST(ImageRemoveFrameRectFilter, WritePixels100_100_to_25_50_50_100) { }); } -TEST(ImageRemoveFrameRectFilter, RemoveFrameRectFailsFor0_0_to_0_0_100_100) { +TEST(ImageRemoveFrameRectFilter, RemoveFrameRectFailsFor0_0_to_0_0_100_100) +{ // A zero-size image is disallowed. AssertConfiguringRemoveFrameRectFilterFails(IntSize(0, 0), IntRect(0, 0, 100, 100)); } TEST(ImageRemoveFrameRectFilter, - RemoveFrameRectFailsForMinus1_Minus1_to_0_0_100_100) { + RemoveFrameRectFailsForMinus1_Minus1_to_0_0_100_100) +{ // A negative-size image is disallowed. AssertConfiguringRemoveFrameRectFilterFails(IntSize(-1, -1), IntRect(0, 0, 100, 100)); } -TEST(ImageRemoveFrameRectFilter, RemoveFrameRectFailsFor100_100_to_0_0_0_0) { +TEST(ImageRemoveFrameRectFilter, RemoveFrameRectFailsFor100_100_to_0_0_0_0) +{ // A zero size frame rect is disallowed. AssertConfiguringRemoveFrameRectFilterFails(IntSize(100, 100), IntRect(0, 0, -1, -1)); } TEST(ImageRemoveFrameRectFilter, - RemoveFrameRectFailsFor100_100_to_0_0_Minus1_Minus1) { + RemoveFrameRectFailsFor100_100_to_0_0_Minus1_Minus1) +{ // A negative size frame rect is disallowed. AssertConfiguringRemoveFrameRectFilterFails(IntSize(100, 100), IntRect(0, 0, -1, -1)); diff --git a/image/test/gtest/TestSurfaceSink.cpp b/image/test/gtest/TestSurfaceSink.cpp index fac472321b289..519c829775d01 100644 --- a/image/test/gtest/TestSurfaceSink.cpp +++ b/image/test/gtest/TestSurfaceSink.cpp @@ -84,7 +84,8 @@ void CheckIterativeWrite(Decoder* aDecoder, SurfaceSink* aSink, [&] { CheckGeneratedImage(aDecoder, aOutputRect); }); } -TEST(ImageSurfaceSink, SurfaceSinkInitialization) { +TEST(ImageSurfaceSink, SurfaceSinkInitialization) +{ WithSurfaceSink([](Decoder* aDecoder, SurfaceSink* aSink) { // Check initial state. EXPECT_FALSE(aSink->IsSurfaceFinished()); @@ -100,13 +101,15 @@ TEST(ImageSurfaceSink, SurfaceSinkInitialization) { }); } -TEST(ImageSurfaceSink, SurfaceSinkWritePixels) { +TEST(ImageSurfaceSink, SurfaceSinkWritePixels) +{ WithSurfaceSink([](Decoder* aDecoder, SurfaceSink* aSink) { CheckWritePixels(aDecoder, aSink); }); } -TEST(ImageSurfaceSink, SurfaceSinkWritePixelsFinish) { +TEST(ImageSurfaceSink, SurfaceSinkWritePixelsFinish) +{ WithSurfaceSink([](Decoder* aDecoder, SurfaceSink* aSink) { // Write nothing into the surface; just finish immediately. uint32_t count = 0; @@ -137,7 +140,8 @@ TEST(ImageSurfaceSink, SurfaceSinkWritePixelsFinish) { }); } -TEST(ImageSurfaceSink, SurfaceSinkWritePixelsEarlyExit) { +TEST(ImageSurfaceSink, SurfaceSinkWritePixelsEarlyExit) +{ auto checkEarlyExit = [](Decoder* aDecoder, SurfaceSink* aSink, WriteState aState) { // Write half a row of green pixels and then exit early with |aState|. If @@ -210,7 +214,8 @@ TEST(ImageSurfaceSink, SurfaceSinkWritePixelsEarlyExit) { }); } -TEST(ImageSurfaceSink, SurfaceSinkWritePixelsToRow) { +TEST(ImageSurfaceSink, SurfaceSinkWritePixelsToRow) +{ WithSurfaceSink([](Decoder* aDecoder, SurfaceSink* aSink) { // Write the first 99 rows of our 100x100 surface and verify that even // though our lambda will yield pixels forever, only one row is written per @@ -268,7 +273,8 @@ TEST(ImageSurfaceSink, SurfaceSinkWritePixelsToRow) { }); } -TEST(ImageSurfaceSink, SurfaceSinkWritePixelsToRowEarlyExit) { +TEST(ImageSurfaceSink, SurfaceSinkWritePixelsToRowEarlyExit) +{ auto checkEarlyExit = [](Decoder* aDecoder, SurfaceSink* aSink, WriteState aState) { // Write half a row of green pixels and then exit early with |aState|. If @@ -339,7 +345,8 @@ TEST(ImageSurfaceSink, SurfaceSinkWritePixelsToRowEarlyExit) { }); } -TEST(ImageSurfaceSink, SurfaceSinkWriteBuffer) { +TEST(ImageSurfaceSink, SurfaceSinkWriteBuffer) +{ WithSurfaceSink([](Decoder* aDecoder, SurfaceSink* aSink) { // Create a green buffer the same size as one row of the surface (which is // 100x100), containing 60 pixels of green in the middle and 20 transparent @@ -354,7 +361,8 @@ TEST(ImageSurfaceSink, SurfaceSinkWriteBuffer) { }); } -TEST(ImageSurfaceSink, SurfaceSinkWriteBufferPartialRow) { +TEST(ImageSurfaceSink, SurfaceSinkWriteBufferPartialRow) +{ WithSurfaceSink([](Decoder* aDecoder, SurfaceSink* aSink) { // Create a buffer the same size as one row of the surface, containing all // green pixels. @@ -370,7 +378,8 @@ TEST(ImageSurfaceSink, SurfaceSinkWriteBufferPartialRow) { }); } -TEST(ImageSurfaceSink, SurfaceSinkWriteBufferPartialRowStartColOverflow) { +TEST(ImageSurfaceSink, SurfaceSinkWriteBufferPartialRowStartColOverflow) +{ WithSurfaceSink([](Decoder* aDecoder, SurfaceSink* aSink) { // Create a buffer the same size as one row of the surface, containing all // green pixels. @@ -402,7 +411,8 @@ TEST(ImageSurfaceSink, SurfaceSinkWriteBufferPartialRowStartColOverflow) { }); } -TEST(ImageSurfaceSink, SurfaceSinkWriteBufferPartialRowBufferOverflow) { +TEST(ImageSurfaceSink, SurfaceSinkWriteBufferPartialRowBufferOverflow) +{ WithSurfaceSink([](Decoder* aDecoder, SurfaceSink* aSink) { // Create a buffer twice as large as a row of the surface. The first half // (which is as large as a row of the image) will contain green pixels, @@ -438,7 +448,8 @@ TEST(ImageSurfaceSink, SurfaceSinkWriteBufferPartialRowBufferOverflow) { }); } -TEST(ImageSurfaceSink, SurfaceSinkWriteBufferFromNullSource) { +TEST(ImageSurfaceSink, SurfaceSinkWriteBufferFromNullSource) +{ WithSurfaceSink([](Decoder* aDecoder, SurfaceSink* aSink) { // Calling WriteBuffer() with a null pointer should fail without making any // changes to the surface. @@ -455,7 +466,8 @@ TEST(ImageSurfaceSink, SurfaceSinkWriteBufferFromNullSource) { }); } -TEST(ImageSurfaceSink, SurfaceSinkWriteEmptyRow) { +TEST(ImageSurfaceSink, SurfaceSinkWriteEmptyRow) +{ WithSurfaceSink([](Decoder* aDecoder, SurfaceSink* aSink) { { // Write an empty row to each row of the surface. We check that the @@ -525,7 +537,8 @@ TEST(ImageSurfaceSink, SurfaceSinkWriteEmptyRow) { }); } -TEST(ImageSurfaceSink, SurfaceSinkWriteUnsafeComputedRow) { +TEST(ImageSurfaceSink, SurfaceSinkWriteUnsafeComputedRow) +{ WithSurfaceSink([](Decoder* aDecoder, SurfaceSink* aSink) { // Create a green buffer the same size as one row of the surface. uint32_t buffer[100]; @@ -547,7 +560,8 @@ TEST(ImageSurfaceSink, SurfaceSinkWriteUnsafeComputedRow) { }); } -TEST(ImageSurfaceSink, SurfaceSinkWritePixelBlocks) { +TEST(ImageSurfaceSink, SurfaceSinkWritePixelBlocks) +{ WithSurfaceSink([](Decoder* aDecoder, SurfaceSink* aSink) { // Create a green buffer the same size as one row of the surface (which is // 100x100), containing 60 pixels of green in the middle and 20 transparent @@ -593,7 +607,8 @@ TEST(ImageSurfaceSink, SurfaceSinkWritePixelBlocks) { }); } -TEST(ImageSurfaceSink, SurfaceSinkWritePixelBlocksPartialRow) { +TEST(ImageSurfaceSink, SurfaceSinkWritePixelBlocksPartialRow) +{ WithSurfaceSink([](Decoder* aDecoder, SurfaceSink* aSink) { // Create a green buffer the same size as one row of the surface (which is // 100x100), containing 60 pixels of green in the middle and 20 transparent @@ -685,7 +700,8 @@ TEST(ImageSurfaceSink, SurfaceSinkWritePixelBlocksPartialRow) { }); } -TEST(ImageSurfaceSink, SurfaceSinkProgressivePasses) { +TEST(ImageSurfaceSink, SurfaceSinkProgressivePasses) +{ WithSurfaceSink([](Decoder* aDecoder, SurfaceSink* aSink) { { // Fill the image with a first pass of red. @@ -736,7 +752,8 @@ TEST(ImageSurfaceSink, SurfaceSinkProgressivePasses) { }); } -TEST(ImageSurfaceSink, SurfaceSinkInvalidRect) { +TEST(ImageSurfaceSink, SurfaceSinkInvalidRect) +{ WithSurfaceSink([](Decoder* aDecoder, SurfaceSink* aSink) { { // Write one row. @@ -859,7 +876,8 @@ TEST(ImageSurfaceSink, SurfaceSinkInvalidRect) { }); } -TEST(ImageSurfaceSink, SurfaceSinkFlipVertically) { +TEST(ImageSurfaceSink, SurfaceSinkFlipVertically) +{ WithSurfaceSink([](Decoder* aDecoder, SurfaceSink* aSink) { { diff --git a/intl/locale/nsLanguageAtomService.cpp b/intl/locale/nsLanguageAtomService.cpp index 3338c625ed613..fcabe88ce85a0 100644 --- a/intl/locale/nsLanguageAtomService.cpp +++ b/intl/locale/nsLanguageAtomService.cpp @@ -183,11 +183,12 @@ nsStaticAtom* nsLanguageAtomService::GetUncachedLanguageGroup( } else { size_t foundIndex; const nsCString& script = loc.GetScript(); - if (BinarySearchIf(kScriptLangGroup, 0, ArrayLength(kScriptLangGroup), - [script](const auto& entry) -> int { - return script.Compare(entry.mTag); - }, - &foundIndex)) { + if (BinarySearchIf( + kScriptLangGroup, 0, ArrayLength(kScriptLangGroup), + [script](const auto& entry) -> int { + return script.Compare(entry.mTag); + }, + &foundIndex)) { return kScriptLangGroup[foundIndex].mAtom; } } diff --git a/intl/locale/tests/gtest/TestCollation.cpp b/intl/locale/tests/gtest/TestCollation.cpp index 3bd8693886048..8a90f1d9a971f 100644 --- a/intl/locale/tests/gtest/TestCollation.cpp +++ b/intl/locale/tests/gtest/TestCollation.cpp @@ -10,7 +10,8 @@ #include "nsICollation.h" #include "nsString.h" -TEST(Collation, AllocateRowSortKey) { +TEST(Collation, AllocateRowSortKey) +{ nsCOMPtr colFactory = do_CreateInstance(NS_COLLATIONFACTORY_CONTRACTID); ASSERT_TRUE(colFactory); diff --git a/intl/locale/tests/gtest/TestDateTimeFormat.cpp b/intl/locale/tests/gtest/TestDateTimeFormat.cpp index e1f92155813f5..86037947fe938 100644 --- a/intl/locale/tests/gtest/TestDateTimeFormat.cpp +++ b/intl/locale/tests/gtest/TestDateTimeFormat.cpp @@ -25,7 +25,8 @@ static nsAutoCString nt(nsAutoCString aDatetime) { return datetime; } -TEST(DateTimeFormat, FormatPRExplodedTime) { +TEST(DateTimeFormat, FormatPRExplodedTime) +{ PRTime prTime = 0; PRExplodedTime prExplodedTime; PR_ExplodeTime(prTime, PR_GMTParameters, &prExplodedTime); @@ -87,7 +88,8 @@ TEST(DateTimeFormat, FormatPRExplodedTime) { nt(NS_ConvertUTF16toUTF8(formattedTime)).get()); } -TEST(DateTimeFormat, DateFormatSelectors) { +TEST(DateTimeFormat, DateFormatSelectors) +{ PRTime prTime = 0; PRExplodedTime prExplodedTime; PR_ExplodeTime(prTime, PR_GMTParameters, &prExplodedTime); @@ -158,7 +160,8 @@ static nsAutoCString ntd(nsAutoCString aDatetime) { return datetime; } -TEST(DateTimeFormat, FormatPRExplodedTimeForeign) { +TEST(DateTimeFormat, FormatPRExplodedTimeForeign) +{ PRTime prTime = 0; PRExplodedTime prExplodedTime; PR_ExplodeTime(prTime, PR_GMTParameters, &prExplodedTime); @@ -220,7 +223,8 @@ TEST(DateTimeFormat, FormatPRExplodedTimeForeign) { ntd(NS_ConvertUTF16toUTF8(formattedTime)).get()); } -TEST(DateTimeFormat, DateFormatSelectorsForeign) { +TEST(DateTimeFormat, DateFormatSelectorsForeign) +{ PRTime prTime = 0; PRExplodedTime prExplodedTime; PR_ExplodeTime(prTime, PR_GMTParameters, &prExplodedTime); diff --git a/intl/locale/tests/gtest/TestLocaleService.cpp b/intl/locale/tests/gtest/TestLocaleService.cpp index 89c239b6700dd..7ace8623b43ef 100644 --- a/intl/locale/tests/gtest/TestLocaleService.cpp +++ b/intl/locale/tests/gtest/TestLocaleService.cpp @@ -11,21 +11,24 @@ using namespace mozilla::intl; -TEST(Intl_Locale_LocaleService, GetAppLocalesAsBCP47) { +TEST(Intl_Locale_LocaleService, GetAppLocalesAsBCP47) +{ nsTArray appLocales; LocaleService::GetInstance()->GetAppLocalesAsBCP47(appLocales); ASSERT_FALSE(appLocales.IsEmpty()); } -TEST(Intl_Locale_LocaleService, GetAppLocalesAsLangTags) { +TEST(Intl_Locale_LocaleService, GetAppLocalesAsLangTags) +{ nsTArray appLocales; LocaleService::GetInstance()->GetAppLocalesAsLangTags(appLocales); ASSERT_FALSE(appLocales.IsEmpty()); } -TEST(Intl_Locale_LocaleService, GetAppLocalesAsLangTags_lastIsEnUS) { +TEST(Intl_Locale_LocaleService, GetAppLocalesAsLangTags_lastIsEnUS) +{ nsAutoCString lastFallbackLocale; LocaleService::GetInstance()->GetLastFallbackLocale(lastFallbackLocale); @@ -36,7 +39,8 @@ TEST(Intl_Locale_LocaleService, GetAppLocalesAsLangTags_lastIsEnUS) { ASSERT_TRUE(appLocales[len - 1].Equals(lastFallbackLocale)); } -TEST(Intl_Locale_LocaleService, GetAppLocaleAsLangTag) { +TEST(Intl_Locale_LocaleService, GetAppLocaleAsLangTag) +{ nsTArray appLocales; LocaleService::GetInstance()->GetAppLocalesAsLangTags(appLocales); @@ -46,7 +50,8 @@ TEST(Intl_Locale_LocaleService, GetAppLocaleAsLangTag) { ASSERT_TRUE(appLocales[0] == locale); } -TEST(Intl_Locale_LocaleService, GetRegionalPrefsLocales) { +TEST(Intl_Locale_LocaleService, GetRegionalPrefsLocales) +{ nsTArray rpLocales; LocaleService::GetInstance()->GetRegionalPrefsLocales(rpLocales); @@ -54,7 +59,8 @@ TEST(Intl_Locale_LocaleService, GetRegionalPrefsLocales) { ASSERT_TRUE(len > 0); } -TEST(Intl_Locale_LocaleService, GetWebExposedLocales) { +TEST(Intl_Locale_LocaleService, GetWebExposedLocales) +{ const nsTArray spoofLocale{NS_LITERAL_CSTRING("de")}; LocaleService::GetInstance()->SetAvailableLocales(spoofLocale); LocaleService::GetInstance()->SetRequestedLocales(spoofLocale); @@ -77,7 +83,8 @@ TEST(Intl_Locale_LocaleService, GetWebExposedLocales) { ASSERT_TRUE(pvLocales[0].Equals(NS_LITERAL_CSTRING("en-US"))); } -TEST(Intl_Locale_LocaleService, GetRequestedLocales) { +TEST(Intl_Locale_LocaleService, GetRequestedLocales) +{ nsTArray reqLocales; LocaleService::GetInstance()->GetRequestedLocales(reqLocales); @@ -85,7 +92,8 @@ TEST(Intl_Locale_LocaleService, GetRequestedLocales) { ASSERT_TRUE(len > 0); } -TEST(Intl_Locale_LocaleService, GetAvailableLocales) { +TEST(Intl_Locale_LocaleService, GetAvailableLocales) +{ nsTArray availableLocales; LocaleService::GetInstance()->GetAvailableLocales(availableLocales); @@ -93,7 +101,8 @@ TEST(Intl_Locale_LocaleService, GetAvailableLocales) { ASSERT_TRUE(len > 0); } -TEST(Intl_Locale_LocaleService, GetPackagedLocales) { +TEST(Intl_Locale_LocaleService, GetPackagedLocales) +{ nsTArray packagedLocales; LocaleService::GetInstance()->GetPackagedLocales(packagedLocales); @@ -101,7 +110,8 @@ TEST(Intl_Locale_LocaleService, GetPackagedLocales) { ASSERT_TRUE(len > 0); } -TEST(Intl_Locale_LocaleService, GetDefaultLocale) { +TEST(Intl_Locale_LocaleService, GetDefaultLocale) +{ nsAutoCString locStr; LocaleService::GetInstance()->GetDefaultLocale(locStr); @@ -109,7 +119,8 @@ TEST(Intl_Locale_LocaleService, GetDefaultLocale) { ASSERT_TRUE(Locale(locStr).IsWellFormed()); } -TEST(Intl_Locale_LocaleService, IsAppLocaleRTL) { +TEST(Intl_Locale_LocaleService, IsAppLocaleRTL) +{ // For now we can only test if the method doesn't crash. LocaleService::GetInstance()->IsAppLocaleRTL(); ASSERT_TRUE(true); diff --git a/intl/locale/tests/gtest/TestLocaleServiceNegotiate.cpp b/intl/locale/tests/gtest/TestLocaleServiceNegotiate.cpp index bba4f2b37a4fd..4db7372a7ed37 100644 --- a/intl/locale/tests/gtest/TestLocaleServiceNegotiate.cpp +++ b/intl/locale/tests/gtest/TestLocaleServiceNegotiate.cpp @@ -9,7 +9,8 @@ using namespace mozilla::intl; -TEST(Intl_Locale_LocaleService, Negotiate) { +TEST(Intl_Locale_LocaleService, Negotiate) +{ nsTArray requestedLocales; nsTArray availableLocales; nsTArray supportedLocales; @@ -30,7 +31,8 @@ TEST(Intl_Locale_LocaleService, Negotiate) { ASSERT_TRUE(supportedLocales[1].EqualsLiteral("en-US")); } -TEST(Intl_Locale_LocaleService, UseLSDefaultLocale) { +TEST(Intl_Locale_LocaleService, UseLSDefaultLocale) +{ nsTArray requestedLocales; nsTArray availableLocales; nsTArray supportedLocales; diff --git a/intl/locale/tests/gtest/TestMozLocale.cpp b/intl/locale/tests/gtest/TestMozLocale.cpp index 14375caf89489..9bc974b9c3c19 100644 --- a/intl/locale/tests/gtest/TestMozLocale.cpp +++ b/intl/locale/tests/gtest/TestMozLocale.cpp @@ -8,20 +8,23 @@ using namespace mozilla::intl; -TEST(Intl_Locale_Locale, Locale) { +TEST(Intl_Locale_Locale, Locale) +{ Locale loc = Locale("en-US"); ASSERT_TRUE(loc.GetLanguage().Equals("en")); ASSERT_TRUE(loc.GetRegion().Equals("US")); } -TEST(Intl_Locale_Locale, AsString) { +TEST(Intl_Locale_Locale, AsString) +{ Locale loc = Locale("ja-jp-windows"); ASSERT_TRUE(loc.AsString().Equals("ja-JP-windows")); } -TEST(Intl_Locale_Locale, GetSubTags) { +TEST(Intl_Locale_Locale, GetSubTags) +{ Locale loc = Locale("en-latn-us-macos"); ASSERT_TRUE(loc.GetLanguage().Equals("en")); @@ -31,7 +34,8 @@ TEST(Intl_Locale_Locale, GetSubTags) { ASSERT_TRUE(loc.GetVariants()[0].Equals("macos")); } -TEST(Intl_Locale_Locale, Matches) { +TEST(Intl_Locale_Locale, Matches) +{ Locale loc = Locale("en-US"); Locale loc2 = Locale("en-GB"); @@ -44,7 +48,8 @@ TEST(Intl_Locale_Locale, Matches) { ASSERT_TRUE(loc == loc4); } -TEST(Intl_Locale_Locale, MatchesRange) { +TEST(Intl_Locale_Locale, MatchesRange) +{ Locale loc = Locale("en-US"); Locale loc2 = Locale("en-Latn-US"); @@ -62,14 +67,16 @@ TEST(Intl_Locale_Locale, MatchesRange) { ASSERT_TRUE(loc.Matches(loc3, true, true)); } -TEST(Intl_Locale_Locale, Variants) { +TEST(Intl_Locale_Locale, Variants) +{ Locale loc = Locale("en-US-UniFon-BasicEng"); // Make sure that we canonicalize and sort variant tags ASSERT_TRUE(loc.AsString().Equals("en-US-basiceng-unifon")); } -TEST(Intl_Locale_Locale, PrivateUse) { +TEST(Intl_Locale_Locale, PrivateUse) +{ Locale loc = Locale("x-test"); ASSERT_TRUE(loc.IsWellFormed()); @@ -98,7 +105,8 @@ TEST(Intl_Locale_Locale, PrivateUse) { ASSERT_TRUE(loc3.AsString().Equals("fr-x-foo-bar-baz")); } -TEST(Intl_Locale_Locale, InvalidLocale) { +TEST(Intl_Locale_Locale, InvalidLocale) +{ Locale loc = Locale("en-verylongsubtag"); ASSERT_FALSE(loc.IsWellFormed()); @@ -106,13 +114,15 @@ TEST(Intl_Locale_Locale, InvalidLocale) { ASSERT_FALSE(loc2.IsWellFormed()); } -TEST(Intl_Locale_Locale, ClearRegion) { +TEST(Intl_Locale_Locale, ClearRegion) +{ Locale loc = Locale("en-US"); loc.ClearRegion(); ASSERT_TRUE(loc.AsString().Equals("en")); } -TEST(Intl_Locale_Locale, ClearVariants) { +TEST(Intl_Locale_Locale, ClearVariants) +{ Locale loc = Locale("en-US-mac"); loc.ClearVariants(); ASSERT_TRUE(loc.AsString().Equals("en-US")); diff --git a/intl/locale/tests/gtest/TestOSPreferences.cpp b/intl/locale/tests/gtest/TestOSPreferences.cpp index 46c15b3e8fc84..955162edf4754 100644 --- a/intl/locale/tests/gtest/TestOSPreferences.cpp +++ b/intl/locale/tests/gtest/TestOSPreferences.cpp @@ -17,7 +17,8 @@ using namespace mozilla::intl; * decide how to handle this and special case and this test should make * it not happen without us noticing. */ -TEST(Intl_Locale_OSPreferences, GetSystemLocales) { +TEST(Intl_Locale_OSPreferences, GetSystemLocales) +{ nsTArray systemLocales; ASSERT_TRUE(NS_SUCCEEDED( OSPreferences::GetInstance()->GetSystemLocales(systemLocales))); @@ -33,7 +34,8 @@ TEST(Intl_Locale_OSPreferences, GetSystemLocales) { * decide how to handle this and special case and this test should make * it not happen without us noticing. */ -TEST(Intl_Locale_OSPreferences, GetRegionalPrefsLocales) { +TEST(Intl_Locale_OSPreferences, GetRegionalPrefsLocales) +{ nsTArray rgLocales; ASSERT_TRUE(NS_SUCCEEDED( OSPreferences::GetInstance()->GetRegionalPrefsLocales(rgLocales))); @@ -49,7 +51,8 @@ TEST(Intl_Locale_OSPreferences, GetRegionalPrefsLocales) { * bindings for, so effectively, we're testing for crashes. We should * never crash. */ -TEST(Intl_Locale_OSPreferences, GetDateTimePattern) { +TEST(Intl_Locale_OSPreferences, GetDateTimePattern) +{ nsAutoString pattern; OSPreferences* osprefs = OSPreferences::GetInstance(); diff --git a/intl/lwbrk/gtest/TestLineBreak.cpp b/intl/lwbrk/gtest/TestLineBreak.cpp index f1c0d752dce1e..f8b00c72dcaac 100644 --- a/intl/lwbrk/gtest/TestLineBreak.cpp +++ b/intl/lwbrk/gtest/TestLineBreak.cpp @@ -125,7 +125,8 @@ bool TestASCIIWB(mozilla::intl::WordBreaker* lb, const char* in, return Check(in, out, outlen, i, res); } -TEST(LineBreak, LineBreaker) { +TEST(LineBreak, LineBreaker) +{ RefPtr t = mozilla::intl::LineBreaker::Create(); ASSERT_TRUE(t); @@ -135,7 +136,8 @@ TEST(LineBreak, LineBreaker) { ASSERT_TRUE(TestASCIILB(t, teng3, lexp3, sizeof(lexp3) / sizeof(uint32_t))); } -TEST(LineBreak, WordBreaker) { +TEST(LineBreak, WordBreaker) +{ RefPtr t = mozilla::intl::WordBreaker::Create(); ASSERT_TRUE(t); @@ -251,7 +253,8 @@ void TestFindWordBreakFromPosition(uint32_t fragN, uint32_t offset, << "FindWordBreakFromPosition(" << fragN << ", " << offset << ")"; } -TEST(LineBreak, WordBreakUsage) { +TEST(LineBreak, WordBreakUsage) +{ TestPrintWordWithBreak(); TestFindWordBreakFromPosition(0, 0, "This"); TestFindWordBreakFromPosition(1, 0, "his"); diff --git a/intl/strres/nsStringBundle.cpp b/intl/strres/nsStringBundle.cpp index c691020b526d0..3c563569f853f 100644 --- a/intl/strres/nsStringBundle.cpp +++ b/intl/strres/nsStringBundle.cpp @@ -85,9 +85,9 @@ static const char kContentBundles[][52] = { static bool IsContentBundle(const nsCString& aUrl) { size_t index; - return BinarySearchIf(kContentBundles, 0, MOZ_ARRAY_LENGTH(kContentBundles), - [&](const char* aElem) { return aUrl.Compare(aElem); }, - &index); + return BinarySearchIf( + kContentBundles, 0, MOZ_ARRAY_LENGTH(kContentBundles), + [&](const char* aElem) { return aUrl.Compare(aElem); }, &index); } namespace { diff --git a/intl/uconv/nsTextToSubURI.cpp b/intl/uconv/nsTextToSubURI.cpp index a1eb5e14d4cdf..cc9cf27988d95 100644 --- a/intl/uconv/nsTextToSubURI.cpp +++ b/intl/uconv/nsTextToSubURI.cpp @@ -128,12 +128,12 @@ NS_IMETHODIMP nsTextToSubURI::UnEscapeURIForUI(const nsACString& aCharset, MOZ_ASSERT(!mIDNBlocklist.IsEmpty()); const nsPromiseFlatString& unescapedResult = PromiseFlatString(_retval); nsString reescapedSpec; - _retval = - NS_EscapeURL(unescapedResult, - [&](char16_t aChar) -> bool { - return mozilla::net::CharInBlocklist(aChar, mIDNBlocklist); - }, - reescapedSpec); + _retval = NS_EscapeURL( + unescapedResult, + [&](char16_t aChar) -> bool { + return mozilla::net::CharInBlocklist(aChar, mIDNBlocklist); + }, + reescapedSpec); return NS_OK; } diff --git a/ipc/chromium/src/base/thread_local_win.cc b/ipc/chromium/src/base/thread_local_win.cc index 3f8c465d05f48..2eb68e63b30d5 100644 --- a/ipc/chromium/src/base/thread_local_win.cc +++ b/ipc/chromium/src/base/thread_local_win.cc @@ -33,7 +33,8 @@ void* ThreadLocalPlatform::GetValueFromSlot(SlotType& slot) { // static void ThreadLocalPlatform::SetValueInSlot(SlotType& slot, void* value) { if (!TlsSetValue(slot, value)) { - CHECK(false) << "Failed to TlsSetValue()."; + CHECK(false) + << "Failed to TlsSetValue()."; } } diff --git a/ipc/chromium/src/base/waitable_event_win.cc b/ipc/chromium/src/base/waitable_event_win.cc index c7f5ef3e634d5..ca94c5cdd9242 100644 --- a/ipc/chromium/src/base/waitable_event_win.cc +++ b/ipc/chromium/src/base/waitable_event_win.cc @@ -62,7 +62,7 @@ bool WaitableEvent::TimedWait(const TimeDelta& max_time) { size_t WaitableEvent::WaitMany(WaitableEvent** events, size_t count) { HANDLE handles[MAXIMUM_WAIT_OBJECTS]; CHECK(count <= MAXIMUM_WAIT_OBJECTS) - << "Can only wait on " << MAXIMUM_WAIT_OBJECTS << " with WaitMany"; + << "Can only wait on " << MAXIMUM_WAIT_OBJECTS << " with WaitMany"; for (size_t i = 0; i < count; ++i) handles[i] = events[i]->handle(); diff --git a/ipc/chromium/src/chrome/common/ipc_channel_posix.cc b/ipc/chromium/src/chrome/common/ipc_channel_posix.cc index 47695b28f8415..652ab7c84228a 100644 --- a/ipc/chromium/src/chrome/common/ipc_channel_posix.cc +++ b/ipc/chromium/src/chrome/common/ipc_channel_posix.cc @@ -131,8 +131,9 @@ class PipeMap { DCHECK(fd != -1); ChannelToFDMap::const_iterator i = map_.find(channel_id); - CHECK(i == map_.end()) << "Creating second IPC server for '" << channel_id - << "' while first still exists"; + CHECK(i == map_.end()) + << "Creating second IPC server for '" << channel_id + << "' while first still exists"; map_[channel_id] = fd; } diff --git a/ipc/glue/WindowsMessageLoop.cpp b/ipc/glue/WindowsMessageLoop.cpp index 984c1102af713..e027b689a98f0 100644 --- a/ipc/glue/WindowsMessageLoop.cpp +++ b/ipc/glue/WindowsMessageLoop.cpp @@ -148,7 +148,9 @@ void CALLBACK WinEventHook(HWINEVENTHOOK aWinEventHook, DWORD aEvent, } break; } - default: { return; } + default: { + return; + } } } @@ -794,8 +796,7 @@ static void StopNeutering() { NeuteredWindowRegion::NeuteredWindowRegion( bool aDoNeuter MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL) - : mNeuteredByThis(!gWindowHook && - aDoNeuter && + : mNeuteredByThis(!gWindowHook && aDoNeuter && XRE_UseNativeEventProcessing()) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; if (mNeuteredByThis) { diff --git a/js/public/Conversions.h b/js/public/Conversions.h index c7e0cad07edcf..7f62da49a7419 100644 --- a/js/public/Conversions.h +++ b/js/public/Conversions.h @@ -348,7 +348,8 @@ inline UnsignedInteger ToUnsignedInteger(double d) { // The implicit leading bit matters identically to the other case, so // again, |exponent < ResultWidth|. if (exponent < ResultWidth) { - const auto implicitOne = static_cast(UnsignedInteger{1} << exponent); + const auto implicitOne = + static_cast(UnsignedInteger{1} << exponent); result &= implicitOne - 1; // remove bogus bits result += implicitOne; // add the implicit bit } diff --git a/js/public/RegExp.h b/js/public/RegExp.h index 1ac6d7e488edc..2b872b659ae26 100644 --- a/js/public/RegExp.h +++ b/js/public/RegExp.h @@ -14,8 +14,8 @@ #include "jstypes.h" // JS_PUBLIC_API #include "js/RegExpFlags.h" // JS::RegExpFlags -#include "js/RootingAPI.h" // JS::{,Mutable}Handle -#include "js/Value.h" // JS::Value +#include "js/RootingAPI.h" // JS::{,Mutable}Handle +#include "js/Value.h" // JS::Value struct JSContext; class JSString; diff --git a/js/src/builtin/String.cpp b/js/src/builtin/String.cpp index 8f6d5727c3059..40d65c28be9c3 100644 --- a/js/src/builtin/String.cpp +++ b/js/src/builtin/String.cpp @@ -1576,19 +1576,19 @@ bool js::str_normalize(JSContext* cx, unsigned argc, Value* vp) { PodCopy(chars.begin(), srcChars.begin().get(), spanLength); } - int32_t size = - intl::CallICU(cx, - [normalizer, &srcChars, spanLength]( - UChar* chars, uint32_t size, UErrorCode* status) { - mozilla::RangedPtr remainingStart = - srcChars.begin() + spanLength; - size_t remainingLength = srcChars.length() - spanLength; - - return unorm2_normalizeSecondAndAppend( - normalizer, chars, spanLength, size, - remainingStart.get(), remainingLength, status); - }, - chars); + int32_t size = intl::CallICU( + cx, + [normalizer, &srcChars, spanLength](UChar* chars, uint32_t size, + UErrorCode* status) { + mozilla::RangedPtr remainingStart = + srcChars.begin() + spanLength; + size_t remainingLength = srcChars.length() - spanLength; + + return unorm2_normalizeSecondAndAppend(normalizer, chars, spanLength, + size, remainingStart.get(), + remainingLength, status); + }, + chars); if (size < 0) { return false; } diff --git a/js/src/gc/Barrier.h b/js/src/gc/Barrier.h index 758da12f65bae..b51153e23c6b3 100644 --- a/js/src/gc/Barrier.h +++ b/js/src/gc/Barrier.h @@ -977,7 +977,6 @@ struct DefaultHasher> : js::ReadBarrieredHasher {}; namespace js { - class ArrayObject; class DebugEnvironmentProxy; class GlobalObject; diff --git a/js/src/gc/GC.cpp b/js/src/gc/GC.cpp index 461a0e037e0ac..3de6f3eb4c261 100644 --- a/js/src/gc/GC.cpp +++ b/js/src/gc/GC.cpp @@ -7871,7 +7871,8 @@ JS::AutoDisableGenerationalGC::AutoDisableGenerationalGC(JSContext* cx) } JS::AutoDisableGenerationalGC::~AutoDisableGenerationalGC() { - if (--cx->generationalDisabled == 0 && cx->runtime()->gc.tunables.gcMaxNurseryBytes() > 0) { + if (--cx->generationalDisabled == 0 && + cx->runtime()->gc.tunables.gcMaxNurseryBytes() > 0) { cx->nursery().enable(); } } diff --git a/js/src/jit/BaselineJIT.cpp b/js/src/jit/BaselineJIT.cpp index f0d9f4bd96938..ed7b961df6de8 100644 --- a/js/src/jit/BaselineJIT.cpp +++ b/js/src/jit/BaselineJIT.cpp @@ -525,19 +525,20 @@ RetAddrEntry& BaselineScript::retAddrEntryFromReturnOffset( #ifdef DEBUG bool found = #endif - BinarySearchIf(RetAddrEntries(this), 0, numRetAddrEntries(), - [&returnOffset](const RetAddrEntry& entry) { - size_t roffset = returnOffset.offset(); - size_t entryRoffset = entry.returnOffset().offset(); - if (roffset < entryRoffset) { - return -1; - } - if (entryRoffset < roffset) { - return 1; - } - return 0; - }, - &loc); + BinarySearchIf( + RetAddrEntries(this), 0, numRetAddrEntries(), + [&returnOffset](const RetAddrEntry& entry) { + size_t roffset = returnOffset.offset(); + size_t entryRoffset = entry.returnOffset().offset(); + if (roffset < entryRoffset) { + return -1; + } + if (entryRoffset < roffset) { + return 1; + } + return 0; + }, + &loc); MOZ_ASSERT(found); MOZ_ASSERT(loc < numRetAddrEntries()); @@ -550,18 +551,19 @@ template static inline bool ComputeBinarySearchMid(ScriptT* script, uint32_t pcOffset, size_t* loc) { Entries entries(script); - return BinarySearchIf(entries, 0, entries.numEntries(), - [pcOffset](typename Entries::EntryT& entry) { - uint32_t entryOffset = entry.pcOffset(); - if (pcOffset < entryOffset) { - return -1; - } - if (entryOffset < pcOffset) { - return 1; - } - return 0; - }, - loc); + return BinarySearchIf( + entries, 0, entries.numEntries(), + [pcOffset](typename Entries::EntryT& entry) { + uint32_t entryOffset = entry.pcOffset(); + if (pcOffset < entryOffset) { + return -1; + } + if (entryOffset < pcOffset) { + return 1; + } + return 0; + }, + loc); } uint8_t* BaselineScript::returnAddressForEntry(const RetAddrEntry& ent) { diff --git a/js/src/jit/ExecutableAllocator.h b/js/src/jit/ExecutableAllocator.h index 43fdf19b5c30b..0451f6e0da7ae 100644 --- a/js/src/jit/ExecutableAllocator.h +++ b/js/src/jit/ExecutableAllocator.h @@ -239,7 +239,7 @@ class ExecutableAllocator { "jr.hb $ra \n" "move $ra, %[tmp] \n" ".set pop\n" - : [tmp] "=&r"(tmp)); + : [ tmp ] "=&r"(tmp)); # elif defined(__GNUC__) intptr_t end = reinterpret_cast(code) + size; __builtin___clear_cache(reinterpret_cast(code), diff --git a/js/src/jit/arm/MacroAssembler-arm.cpp b/js/src/jit/arm/MacroAssembler-arm.cpp index 67c08114e5634..a5dbba42d8ebb 100644 --- a/js/src/jit/arm/MacroAssembler-arm.cpp +++ b/js/src/jit/arm/MacroAssembler-arm.cpp @@ -6112,7 +6112,9 @@ void MacroAssemblerARM::wasmUnalignedLoadImpl( } case Scalar::Int8: case Scalar::Uint8: - default: { MOZ_CRASH("Bad type"); } + default: { + MOZ_CRASH("Bad type"); + } } asMasm().memoryBarrierAfter(access.sync()); diff --git a/js/src/jit/arm64/MacroAssembler-arm64.cpp b/js/src/jit/arm64/MacroAssembler-arm64.cpp index 765d9048b2d4f..c34e08868e929 100644 --- a/js/src/jit/arm64/MacroAssembler-arm64.cpp +++ b/js/src/jit/arm64/MacroAssembler-arm64.cpp @@ -1573,7 +1573,9 @@ static void LoadExclusive(MacroAssembler& masm, } break; } - default: { MOZ_CRASH(); } + default: { + MOZ_CRASH(); + } } } diff --git a/js/src/jit/shared/AtomicOperations-shared-jit.cpp b/js/src/jit/shared/AtomicOperations-shared-jit.cpp index fed866f4aa010..526434613e03f 100644 --- a/js/src/jit/shared/AtomicOperations-shared-jit.cpp +++ b/js/src/jit/shared/AtomicOperations-shared-jit.cpp @@ -198,7 +198,9 @@ static void GenGprArg(MacroAssembler& masm, MIRType t, ArgIterator* iter, masm.loadPtr(src, reg); break; } - default: { MOZ_CRASH("Not possible"); } + default: { + MOZ_CRASH("Not possible"); + } } } @@ -232,7 +234,9 @@ static void GenGpr64Arg(MacroAssembler& masm, ArgIterator* iter, break; } #endif - default: { MOZ_CRASH("Not possible"); } + default: { + MOZ_CRASH("Not possible"); + } } } diff --git a/js/src/jsapi-tests/testChromeBuffer.cpp b/js/src/jsapi-tests/testChromeBuffer.cpp index 315b626d92aff..9fddd7f6a3d5b 100644 --- a/js/src/jsapi-tests/testChromeBuffer.cpp +++ b/js/src/jsapi-tests/testChromeBuffer.cpp @@ -10,9 +10,9 @@ static TestJSPrincipals system_principals(1); -static const JSClass global_class = { - "global", JSCLASS_IS_GLOBAL | JSCLASS_GLOBAL_FLAGS, - &JS::DefaultGlobalClassOps}; +static const JSClass global_class = {"global", + JSCLASS_IS_GLOBAL | JSCLASS_GLOBAL_FLAGS, + &JS::DefaultGlobalClassOps}; static JS::PersistentRootedObject trusted_glob; static JS::PersistentRootedObject trusted_fun; diff --git a/js/src/jsapi-tests/testCompileUtf8.cpp b/js/src/jsapi-tests/testCompileUtf8.cpp index da2a668723e07..53e50443c2793 100644 --- a/js/src/jsapi-tests/testCompileUtf8.cpp +++ b/js/src/jsapi-tests/testCompileUtf8.cpp @@ -23,98 +23,106 @@ using mozilla::Utf8Unit; BEGIN_TEST(testUtf8BadBytes) { static const char badLeadingUnit[] = "var x = \x80"; - CHECK(testBadUtf8(badLeadingUnit, JSMSG_BAD_LEADING_UTF8_UNIT, - [this](JS::ConstUTF8CharsZ message) { - const char* chars = message.c_str(); - CHECK(startsWith(chars, "0x80")); - CHECK(isBadLeadUnitMessage(chars)); - return true; - }, - "0x80")); + CHECK(testBadUtf8( + badLeadingUnit, JSMSG_BAD_LEADING_UTF8_UNIT, + [this](JS::ConstUTF8CharsZ message) { + const char* chars = message.c_str(); + CHECK(startsWith(chars, "0x80")); + CHECK(isBadLeadUnitMessage(chars)); + return true; + }, + "0x80")); static const char badSecondInTwoByte[] = "var x = \xDF\x20"; - CHECK(testBadUtf8(badSecondInTwoByte, JSMSG_BAD_TRAILING_UTF8_UNIT, - [this](JS::ConstUTF8CharsZ message) { - const char* chars = message.c_str(); - CHECK(isBadTrailingBytesMessage(chars)); - CHECK(contains(chars, "0x20")); - return true; - }, - "0xDF 0x20")); + CHECK(testBadUtf8( + badSecondInTwoByte, JSMSG_BAD_TRAILING_UTF8_UNIT, + [this](JS::ConstUTF8CharsZ message) { + const char* chars = message.c_str(); + CHECK(isBadTrailingBytesMessage(chars)); + CHECK(contains(chars, "0x20")); + return true; + }, + "0xDF 0x20")); static const char badSecondInThreeByte[] = "var x = \xEF\x17\xA7"; - CHECK(testBadUtf8(badSecondInThreeByte, JSMSG_BAD_TRAILING_UTF8_UNIT, - [this](JS::ConstUTF8CharsZ message) { - const char* chars = message.c_str(); - CHECK(isBadTrailingBytesMessage(chars)); - CHECK(contains(chars, "0x17")); - return true; - }, - // Validating stops with the first invalid code unit and - // shouldn't go beyond that. - "0xEF 0x17")); + CHECK(testBadUtf8( + badSecondInThreeByte, JSMSG_BAD_TRAILING_UTF8_UNIT, + [this](JS::ConstUTF8CharsZ message) { + const char* chars = message.c_str(); + CHECK(isBadTrailingBytesMessage(chars)); + CHECK(contains(chars, "0x17")); + return true; + }, + // Validating stops with the first invalid code unit and + // shouldn't go beyond that. + "0xEF 0x17")); static const char lengthTwoTooShort[] = "var x = \xDF"; - CHECK(testBadUtf8(lengthTwoTooShort, JSMSG_NOT_ENOUGH_CODE_UNITS, - [this](JS::ConstUTF8CharsZ message) { - const char* chars = message.c_str(); - CHECK(isNotEnoughUnitsMessage(chars)); - CHECK(contains(chars, "0xDF")); - CHECK( - contains(chars, " 1 byte, but 0 bytes were present")); - return true; - }, - "0xDF")); + CHECK(testBadUtf8( + lengthTwoTooShort, JSMSG_NOT_ENOUGH_CODE_UNITS, + [this](JS::ConstUTF8CharsZ message) { + const char* chars = message.c_str(); + CHECK(isNotEnoughUnitsMessage(chars)); + CHECK(contains(chars, "0xDF")); + CHECK(contains(chars, " 1 byte, but 0 bytes were present")); + return true; + }, + "0xDF")); static const char forbiddenHighSurrogate[] = "var x = \xED\xA2\x87"; - CHECK(testBadUtf8(forbiddenHighSurrogate, JSMSG_FORBIDDEN_UTF8_CODE_POINT, - [this](JS::ConstUTF8CharsZ message) { - const char* chars = message.c_str(); - CHECK(isSurrogateMessage(chars)); - CHECK(contains(chars, "0xD887")); - return true; - }, - "0xED 0xA2 0x87")); + CHECK(testBadUtf8( + forbiddenHighSurrogate, JSMSG_FORBIDDEN_UTF8_CODE_POINT, + [this](JS::ConstUTF8CharsZ message) { + const char* chars = message.c_str(); + CHECK(isSurrogateMessage(chars)); + CHECK(contains(chars, "0xD887")); + return true; + }, + "0xED 0xA2 0x87")); static const char forbiddenLowSurrogate[] = "var x = \xED\xB7\xAF"; - CHECK(testBadUtf8(forbiddenLowSurrogate, JSMSG_FORBIDDEN_UTF8_CODE_POINT, - [this](JS::ConstUTF8CharsZ message) { - const char* chars = message.c_str(); - CHECK(isSurrogateMessage(chars)); - CHECK(contains(chars, "0xDDEF")); - return true; - }, - "0xED 0xB7 0xAF")); + CHECK(testBadUtf8( + forbiddenLowSurrogate, JSMSG_FORBIDDEN_UTF8_CODE_POINT, + [this](JS::ConstUTF8CharsZ message) { + const char* chars = message.c_str(); + CHECK(isSurrogateMessage(chars)); + CHECK(contains(chars, "0xDDEF")); + return true; + }, + "0xED 0xB7 0xAF")); static const char oneTooBig[] = "var x = \xF4\x90\x80\x80"; - CHECK(testBadUtf8(oneTooBig, JSMSG_FORBIDDEN_UTF8_CODE_POINT, - [this](JS::ConstUTF8CharsZ message) { - const char* chars = message.c_str(); - CHECK(isTooBigMessage(chars)); - CHECK(contains(chars, "0x110000")); - return true; - }, - "0xF4 0x90 0x80 0x80")); + CHECK(testBadUtf8( + oneTooBig, JSMSG_FORBIDDEN_UTF8_CODE_POINT, + [this](JS::ConstUTF8CharsZ message) { + const char* chars = message.c_str(); + CHECK(isTooBigMessage(chars)); + CHECK(contains(chars, "0x110000")); + return true; + }, + "0xF4 0x90 0x80 0x80")); static const char notShortestFormZero[] = "var x = \xC0\x80"; - CHECK(testBadUtf8(notShortestFormZero, JSMSG_FORBIDDEN_UTF8_CODE_POINT, - [this](JS::ConstUTF8CharsZ message) { - const char* chars = message.c_str(); - CHECK(isNotShortestFormMessage(chars)); - CHECK(startsWith(chars, "0x0 isn't ")); - return true; - }, - "0xC0 0x80")); + CHECK(testBadUtf8( + notShortestFormZero, JSMSG_FORBIDDEN_UTF8_CODE_POINT, + [this](JS::ConstUTF8CharsZ message) { + const char* chars = message.c_str(); + CHECK(isNotShortestFormMessage(chars)); + CHECK(startsWith(chars, "0x0 isn't ")); + return true; + }, + "0xC0 0x80")); static const char notShortestFormNonzero[] = "var x = \xE0\x87\x80"; - CHECK(testBadUtf8(notShortestFormNonzero, JSMSG_FORBIDDEN_UTF8_CODE_POINT, - [this](JS::ConstUTF8CharsZ message) { - const char* chars = message.c_str(); - CHECK(isNotShortestFormMessage(chars)); - CHECK(startsWith(chars, "0x1C0 isn't ")); - return true; - }, - "0xE0 0x87 0x80")); + CHECK(testBadUtf8( + notShortestFormNonzero, JSMSG_FORBIDDEN_UTF8_CODE_POINT, + [this](JS::ConstUTF8CharsZ message) { + const char* chars = message.c_str(); + CHECK(isNotShortestFormMessage(chars)); + CHECK(startsWith(chars, "0x1C0 isn't ")); + return true; + }, + "0xE0 0x87 0x80")); return true; } diff --git a/js/src/jsapi-tests/testSetProperty.cpp b/js/src/jsapi-tests/testSetProperty.cpp index 529f3cf6f58ee..a1f195f88250f 100644 --- a/js/src/jsapi-tests/testSetProperty.cpp +++ b/js/src/jsapi-tests/testSetProperty.cpp @@ -43,8 +43,8 @@ const JSClass* getGlobalClass(void) override { JS_GlobalObjectTraceHook}; static const JSClass noResolveGlobalClass = { - "testSetProperty_InheritedGlobalSetter_noResolveGlobalClass", - JSCLASS_GLOBAL_FLAGS, &noResolveGlobalClassOps}; + "testSetProperty_InheritedGlobalSetter_noResolveGlobalClass", + JSCLASS_GLOBAL_FLAGS, &noResolveGlobalClassOps}; return &noResolveGlobalClass; } diff --git a/js/src/jsapi-tests/testUbiNode.cpp b/js/src/jsapi-tests/testUbiNode.cpp index 80c70b0c1d1e1..5bbbfade8b7dd 100644 --- a/js/src/jsapi-tests/testUbiNode.cpp +++ b/js/src/jsapi-tests/testUbiNode.cpp @@ -226,11 +226,12 @@ BEGIN_TEST(test_ubiStackFrame) { // All frames should be from the "filename.js" source. while (ubiFrame) { - CHECK(checkString("filename.js", - [&](mozilla::RangedPtr ptr, size_t length) { - return ubiFrame.source(ptr, length); - }, - [&] { return ubiFrame.source(); })); + CHECK(checkString( + "filename.js", + [&](mozilla::RangedPtr ptr, size_t length) { + return ubiFrame.source(ptr, length); + }, + [&] { return ubiFrame.source(); })); ubiFrame = ubiFrame.parent(); } diff --git a/js/src/jsapi-tests/tests.h b/js/src/jsapi-tests/tests.h index a09ea68ece954..937b0a8466b34 100644 --- a/js/src/jsapi-tests/tests.h +++ b/js/src/jsapi-tests/tests.h @@ -19,7 +19,7 @@ #include "gc/GC.h" #include "js/AllocPolicy.h" #include "js/CharacterEncoding.h" -#include "js/Equality.h" // JS::SameValue +#include "js/Equality.h" // JS::SameValue #include "js/RegExpFlags.h" // JS::RegExpFlags #include "js/Vector.h" #include "vm/JSContext.h" diff --git a/js/src/shell/js.cpp b/js/src/shell/js.cpp index 618413139eb0c..26db79a8efe76 100644 --- a/js/src/shell/js.cpp +++ b/js/src/shell/js.cpp @@ -6784,7 +6784,9 @@ static bool GetSharedObject(JSContext* cx, unsigned argc, Value* vp) { } break; } - default: { MOZ_CRASH(); } + default: { + MOZ_CRASH(); + } } } diff --git a/js/src/vm/BigIntType.cpp b/js/src/vm/BigIntType.cpp index 47d5a6f849514..3b07239545f76 100644 --- a/js/src/vm/BigIntType.cpp +++ b/js/src/vm/BigIntType.cpp @@ -271,7 +271,7 @@ BigInt::Digit BigInt::digitDiv(Digit high, Digit low, Digit divisor, : "=a"(quotient), "=d"(rem) // Inputs: put `high` into rdx, `low` into rax, and `divisor` into // any register or stack slot. - : "d"(high), "a"(low), [divisor] "rm"(divisor)); + : "d"(high), "a"(low), [ divisor ] "rm"(divisor)); *remainder = rem; return quotient; #elif defined(__i386__) @@ -282,7 +282,7 @@ BigInt::Digit BigInt::digitDiv(Digit high, Digit low, Digit divisor, : "=a"(quotient), "=d"(rem) // Inputs: put `high` into edx, `low` into eax, and `divisor` into // any register or stack slot. - : "d"(high), "a"(low), [divisor] "rm"(divisor)); + : "d"(high), "a"(low), [ divisor ] "rm"(divisor)); *remainder = rem; return quotient; #else diff --git a/js/src/vm/Debugger.cpp b/js/src/vm/Debugger.cpp index aa4976a74f97f..ebb0dc6ca1c80 100644 --- a/js/src/vm/Debugger.cpp +++ b/js/src/vm/Debugger.cpp @@ -866,14 +866,14 @@ bool Debugger::hasAnyLiveHooks(JSRuntime* rt) const { ResumeMode Debugger::slowPathOnEnterFrame(JSContext* cx, AbstractFramePtr frame) { RootedValue rval(cx); - ResumeMode resumeMode = dispatchHook(cx, - [frame](Debugger* dbg) -> bool { - return dbg->observesFrame(frame) && - dbg->observesEnterFrame(); - }, - [&](Debugger* dbg) -> ResumeMode { - return dbg->fireEnterFrame(cx, &rval); - }); + ResumeMode resumeMode = dispatchHook( + cx, + [frame](Debugger* dbg) -> bool { + return dbg->observesFrame(frame) && dbg->observesEnterFrame(); + }, + [&](Debugger* dbg) -> ResumeMode { + return dbg->fireEnterFrame(cx, &rval); + }); switch (resumeMode) { case ResumeMode::Continue: diff --git a/js/src/vm/MallocProvider.h b/js/src/vm/MallocProvider.h index 9594b1621055b..b73dba4a81eac 100644 --- a/js/src/vm/MallocProvider.h +++ b/js/src/vm/MallocProvider.h @@ -194,11 +194,12 @@ struct MallocProvider { } JS_DECLARE_NEW_METHODS(new_, pod_malloc, MOZ_ALWAYS_INLINE) - JS_DECLARE_NEW_ARENA_METHODS(arena_new_, - [this](arena_id_t arena, size_t size) { - return pod_malloc(size, arena); - }, - MOZ_ALWAYS_INLINE) + JS_DECLARE_NEW_ARENA_METHODS( + arena_new_, + [this](arena_id_t arena, size_t size) { + return pod_malloc(size, arena); + }, + MOZ_ALWAYS_INLINE) JS_DECLARE_MAKE_METHODS(make_unique, new_, MOZ_ALWAYS_INLINE) JS_DECLARE_MAKE_METHODS(arena_make_unique, arena_new_, MOZ_ALWAYS_INLINE) diff --git a/js/src/vm/TypedArrayObject.cpp b/js/src/vm/TypedArrayObject.cpp index 893875aaaf6ba..e258e45a20560 100644 --- a/js/src/vm/TypedArrayObject.cpp +++ b/js/src/vm/TypedArrayObject.cpp @@ -2096,7 +2096,9 @@ bool TypedArrayObject::getElementPure(uint32_t index, Value* vp) { } /* static */ -bool TypedArrayObject::getElements(JSContext* cx, Handle tarray, Value* vp) { +bool TypedArrayObject::getElements(JSContext* cx, + Handle tarray, + Value* vp) { uint32_t length = tarray->length(); MOZ_ASSERT_IF(length > 0, !tarray->hasDetachedBuffer()); diff --git a/js/src/vm/TypedArrayObject.h b/js/src/vm/TypedArrayObject.h index d72aac51b6316..e313c2dacca33 100644 --- a/js/src/vm/TypedArrayObject.h +++ b/js/src/vm/TypedArrayObject.h @@ -140,7 +140,8 @@ class TypedArrayObject : public ArrayBufferViewObject { * Copy all elements from this typed array to vp. vp must point to rooted * memory. */ - static bool getElements(JSContext* cx, Handle tarray, Value* vp); + static bool getElements(JSContext* cx, Handle tarray, + Value* vp); static bool GetTemplateObjectForNative(JSContext* cx, Native native, const JS::HandleValueArray args, diff --git a/js/src/wasm/WasmBaselineCompile.cpp b/js/src/wasm/WasmBaselineCompile.cpp index cb9b637004f3e..5f31b4e48f3ed 100644 --- a/js/src/wasm/WasmBaselineCompile.cpp +++ b/js/src/wasm/WasmBaselineCompile.cpp @@ -3225,7 +3225,9 @@ class BaseCompiler final : public BaseCompilerInterface { stackMapGenerator_.memRefsOnStk++; break; } - default: { break; } + default: { + break; + } } } } @@ -3763,7 +3765,9 @@ class BaseCompiler final : public BaseCompilerInterface { k == Stk::MemRef || k == Stk::LocalRef); return Some(AnyReg(popRef(joinRegPtr_))); } - default: { MOZ_CRASH("Compiler bug: unexpected expression type"); } + default: { + MOZ_CRASH("Compiler bug: unexpected expression type"); + } } } @@ -5566,7 +5570,9 @@ class BaseCompiler final : public BaseCompilerInterface { masm.wasmAtomicFetchOp(access, op, rv, srcAddr, temps[0], rd); #endif break; - default: { MOZ_CRASH("Bad type for atomic operation"); } + default: { + MOZ_CRASH("Bad type for atomic operation"); + } } } @@ -7973,7 +7979,9 @@ void BaseCompiler::emitBranchSetup(BranchState* b) { pop2xF64(&b->f64.lhs, &b->f64.rhs); break; } - default: { MOZ_CRASH("Unexpected type for LatentOp::Compare"); } + default: { + MOZ_CRASH("Unexpected type for LatentOp::Compare"); + } } break; } @@ -7993,7 +8001,9 @@ void BaseCompiler::emitBranchSetup(BranchState* b) { b->i64.imm = 0; break; } - default: { MOZ_CRASH("Unexpected type for LatentOp::Eqz"); } + default: { + MOZ_CRASH("Unexpected type for LatentOp::Eqz"); + } } break; } @@ -8038,7 +8048,9 @@ void BaseCompiler::emitBranchPerform(BranchState* b) { freeF64(b->f64.rhs); break; } - default: { MOZ_CRASH("Unexpected type for LatentOp::Compare"); } + default: { + MOZ_CRASH("Unexpected type for LatentOp::Compare"); + } } resetLatentOp(); } @@ -8513,7 +8525,9 @@ void BaseCompiler::doReturn(ExprType type, bool popStack) { freeRef(rv); break; } - default: { MOZ_CRASH("Function return type"); } + default: { + MOZ_CRASH("Function return type"); + } } } @@ -9594,7 +9608,9 @@ bool BaseCompiler::emitSelect() { pushRef(r); break; } - default: { MOZ_CRASH("select type"); } + default: { + MOZ_CRASH("select type"); + } } return true; @@ -10514,7 +10530,9 @@ bool BaseCompiler::emitStructNew() { } case ValType::NullRef: MOZ_CRASH("NullRef not expressible"); - default: { MOZ_CRASH("Unexpected field type"); } + default: { + MOZ_CRASH("Unexpected field type"); + } } } @@ -10588,7 +10606,9 @@ bool BaseCompiler::emitStructGet() { case ValType::NullRef: { MOZ_CRASH("NullRef not expressible"); } - default: { MOZ_CRASH("Unexpected field type"); } + default: { + MOZ_CRASH("Unexpected field type"); + } } freeRef(rp); @@ -10694,7 +10714,9 @@ bool BaseCompiler::emitStructSet() { case ValType::NullRef: { MOZ_CRASH("NullRef not expressible"); } - default: { MOZ_CRASH("Unexpected field type"); } + default: { + MOZ_CRASH("Unexpected field type"); + } } freeRef(rp); diff --git a/js/src/wasm/WasmCraneliftCompile.cpp b/js/src/wasm/WasmCraneliftCompile.cpp index 3c78e54d5becc..f75ac76f99bde 100644 --- a/js/src/wasm/WasmCraneliftCompile.cpp +++ b/js/src/wasm/WasmCraneliftCompile.cpp @@ -159,7 +159,9 @@ static bool GenerateCraneliftCode(WasmMacroAssembler& masm, masm.append(SymbolicAccess(CodeOffset(offset.value()), sym)); break; } - default: { MOZ_CRASH("unknown cranelift metadata kind"); } + default: { + MOZ_CRASH("unknown cranelift metadata kind"); + } } } diff --git a/js/src/wasm/WasmInstance.cpp b/js/src/wasm/WasmInstance.cpp index e4cf09954942f..304ee639e08c0 100644 --- a/js/src/wasm/WasmInstance.cpp +++ b/js/src/wasm/WasmInstance.cpp @@ -1068,7 +1068,9 @@ void CopyValPostBarriered(uint8_t* dst, const Val& src) { case ValType::NullRef: { break; } - default: { MOZ_CRASH("unexpected Val type"); } + default: { + MOZ_CRASH("unexpected Val type"); + } } } diff --git a/js/src/wasm/WasmIonCompile.cpp b/js/src/wasm/WasmIonCompile.cpp index 10c9f2eda8439..61f1c56e21bd3 100644 --- a/js/src/wasm/WasmIonCompile.cpp +++ b/js/src/wasm/WasmIonCompile.cpp @@ -494,7 +494,9 @@ class FunctionCompiler { ins = MSignExtendInt64::New(alloc(), op, mode); break; } - default: { MOZ_CRASH("Bad sign extension"); } + default: { + MOZ_CRASH("Bad sign extension"); + } } curBlock_->add(ins); return ins; @@ -2936,7 +2938,8 @@ static bool EmitMemOrTableCopy(FunctionCompiler& f, bool isMem) { uint32_t lineOrBytecode = f.readCallSiteLineOrBytecode(); - const SymbolicAddressSignature& callee = isMem ? SASigMemCopy : SASigTableCopy; + const SymbolicAddressSignature& callee = + isMem ? SASigMemCopy : SASigTableCopy; CallCompileState args; if (!f.passInstance(callee.argTypes[0], &args)) { return false; @@ -3082,7 +3085,8 @@ static bool EmitMemOrTableInit(FunctionCompiler& f, bool isMem) { uint32_t lineOrBytecode = f.readCallSiteLineOrBytecode(); - const SymbolicAddressSignature& callee = isMem ? SASigMemInit : SASigTableInit; + const SymbolicAddressSignature& callee = + isMem ? SASigMemInit : SASigTableInit; CallCompileState args; if (!f.passInstance(callee.argTypes[0], &args)) { return false; diff --git a/js/src/wasm/WasmJS.cpp b/js/src/wasm/WasmJS.cpp index 6e6eeb12931ad..35f97ee5237df 100644 --- a/js/src/wasm/WasmJS.cpp +++ b/js/src/wasm/WasmJS.cpp @@ -2119,7 +2119,9 @@ bool WasmTableObject::getImpl(JSContext* cx, const CallArgs& args) { args.rval().set(UnboxAnyRef(table.getAnyRef(index))); break; } - default: { MOZ_CRASH("Unexpected table kind"); } + default: { + MOZ_CRASH("Unexpected table kind"); + } } return true; } @@ -2209,7 +2211,9 @@ bool WasmTableObject::setImpl(JSContext* cx, const CallArgs& args) { table.setAnyRef(index, tmp); break; } - default: { MOZ_CRASH("Unexpected table kind"); } + default: { + MOZ_CRASH("Unexpected table kind"); + } } args.rval().setUndefined(); @@ -2292,7 +2296,9 @@ bool WasmTableObject::growImpl(JSContext* cx, const CallArgs& args) { } break; } - default: { MOZ_CRASH("Unexpected table kind"); } + default: { + MOZ_CRASH("Unexpected table kind"); + } } args.rval().setInt32(oldLength); diff --git a/js/src/wasm/WasmStubs.cpp b/js/src/wasm/WasmStubs.cpp index 0f1502633da13..a8c06746c2c6c 100644 --- a/js/src/wasm/WasmStubs.cpp +++ b/js/src/wasm/WasmStubs.cpp @@ -845,7 +845,9 @@ static bool GenerateJitEntry(MacroAssembler& masm, size_t funcExportIndex, } break; } - default: { MOZ_CRASH("unexpected input argument when calling from jit"); } + default: { + MOZ_CRASH("unexpected input argument when calling from jit"); + } } } diff --git a/js/src/wasm/WasmValidate.cpp b/js/src/wasm/WasmValidate.cpp index ba71493713369..b50f3381fdcef 100644 --- a/js/src/wasm/WasmValidate.cpp +++ b/js/src/wasm/WasmValidate.cpp @@ -1975,7 +1975,9 @@ static bool DecodeInitializerExpression(Decoder& d, ModuleEnvironment* env, } break; } - default: { return d.fail("unexpected initializer expression"); } + default: { + return d.fail("unexpected initializer expression"); + } } if (expected != init->type()) { diff --git a/js/xpconnect/loader/AutoMemMap.h b/js/xpconnect/loader/AutoMemMap.h index eee036d169cc5..d6ed8815c7e03 100644 --- a/js/xpconnect/loader/AutoMemMap.h +++ b/js/xpconnect/loader/AutoMemMap.h @@ -42,8 +42,7 @@ class AutoMemMap { // Unix-like systems, this is identical to the above init() method. On // Windows, the FileDescriptor must be a handle for a file mapping, // rather than a file descriptor. - Result initWithHandle(const FileDescriptor& file, - size_t size, + Result initWithHandle(const FileDescriptor& file, size_t size, PRFileMapProtect prot = PR_PROT_READONLY); void reset(); diff --git a/layout/build/nsContentDLF.cpp b/layout/build/nsContentDLF.cpp index c6d1222b808a3..a4ffc0ffad142 100644 --- a/layout/build/nsContentDLF.cpp +++ b/layout/build/nsContentDLF.cpp @@ -150,41 +150,41 @@ nsContentDLF::CreateInstance(const char* aCommand, nsIChannel* aChannel, // Try html or plaintext; both use the same document CID if (IsTypeInList(contentType, gHTMLTypes) || nsContentUtils::IsPlainTextType(contentType)) { - return CreateDocument(aCommand, aChannel, aLoadGroup, aContainer, - []() -> already_AddRefed { - RefPtr doc; - nsresult rv = - NS_NewHTMLDocument(getter_AddRefs(doc)); - NS_ENSURE_SUCCESS(rv, nullptr); - return doc.forget(); - }, - aDocListener, aDocViewer); + return CreateDocument( + aCommand, aChannel, aLoadGroup, aContainer, + []() -> already_AddRefed { + RefPtr doc; + nsresult rv = NS_NewHTMLDocument(getter_AddRefs(doc)); + NS_ENSURE_SUCCESS(rv, nullptr); + return doc.forget(); + }, + aDocListener, aDocViewer); } // Try XML if (IsTypeInList(contentType, gXMLTypes)) { - return CreateDocument(aCommand, aChannel, aLoadGroup, aContainer, - []() -> already_AddRefed { - RefPtr doc; - nsresult rv = - NS_NewXMLDocument(getter_AddRefs(doc)); - NS_ENSURE_SUCCESS(rv, nullptr); - return doc.forget(); - }, - aDocListener, aDocViewer); + return CreateDocument( + aCommand, aChannel, aLoadGroup, aContainer, + []() -> already_AddRefed { + RefPtr doc; + nsresult rv = NS_NewXMLDocument(getter_AddRefs(doc)); + NS_ENSURE_SUCCESS(rv, nullptr); + return doc.forget(); + }, + aDocListener, aDocViewer); } // Try SVG if (IsTypeInList(contentType, gSVGTypes)) { - return CreateDocument(aCommand, aChannel, aLoadGroup, aContainer, - []() -> already_AddRefed { - RefPtr doc; - nsresult rv = - NS_NewSVGDocument(getter_AddRefs(doc)); - NS_ENSURE_SUCCESS(rv, nullptr); - return doc.forget(); - }, - aDocListener, aDocViewer); + return CreateDocument( + aCommand, aChannel, aLoadGroup, aContainer, + []() -> already_AddRefed { + RefPtr doc; + nsresult rv = NS_NewSVGDocument(getter_AddRefs(doc)); + NS_ENSURE_SUCCESS(rv, nullptr); + return doc.forget(); + }, + aDocListener, aDocViewer); } // Try XUL @@ -200,28 +200,28 @@ nsContentDLF::CreateInstance(const char* aCommand, nsIChannel* aChannel, if (mozilla::DecoderTraits::ShouldHandleMediaType( contentType.get(), /* DecoderDoctorDiagnostics* */ nullptr)) { - return CreateDocument(aCommand, aChannel, aLoadGroup, aContainer, - []() -> already_AddRefed { - RefPtr doc; - nsresult rv = - NS_NewVideoDocument(getter_AddRefs(doc)); - NS_ENSURE_SUCCESS(rv, nullptr); - return doc.forget(); - }, - aDocListener, aDocViewer); + return CreateDocument( + aCommand, aChannel, aLoadGroup, aContainer, + []() -> already_AddRefed { + RefPtr doc; + nsresult rv = NS_NewVideoDocument(getter_AddRefs(doc)); + NS_ENSURE_SUCCESS(rv, nullptr); + return doc.forget(); + }, + aDocListener, aDocViewer); } // Try image types if (IsImageContentType(contentType.get())) { - return CreateDocument(aCommand, aChannel, aLoadGroup, aContainer, - []() -> already_AddRefed { - RefPtr doc; - nsresult rv = - NS_NewImageDocument(getter_AddRefs(doc)); - NS_ENSURE_SUCCESS(rv, nullptr); - return doc.forget(); - }, - aDocListener, aDocViewer); + return CreateDocument( + aCommand, aChannel, aLoadGroup, aContainer, + []() -> already_AddRefed { + RefPtr doc; + nsresult rv = NS_NewImageDocument(getter_AddRefs(doc)); + NS_ENSURE_SUCCESS(rv, nullptr); + return doc.forget(); + }, + aDocListener, aDocViewer); } RefPtr pluginHost = nsPluginHost::GetInst(); @@ -229,15 +229,15 @@ nsContentDLF::CreateInstance(const char* aCommand, nsIChannel* aChannel, // is disabled" placeholder. if (pluginHost && pluginHost->HavePluginForType(contentType, nsPluginHost::eExcludeNone)) { - return CreateDocument(aCommand, aChannel, aLoadGroup, aContainer, - []() -> already_AddRefed { - RefPtr doc; - nsresult rv = - NS_NewPluginDocument(getter_AddRefs(doc)); - NS_ENSURE_SUCCESS(rv, nullptr); - return doc.forget(); - }, - aDocListener, aDocViewer); + return CreateDocument( + aCommand, aChannel, aLoadGroup, aContainer, + []() -> already_AddRefed { + RefPtr doc; + nsresult rv = NS_NewPluginDocument(getter_AddRefs(doc)); + NS_ENSURE_SUCCESS(rv, nullptr); + return doc.forget(); + }, + aDocListener, aDocViewer); } // If we get here, then we weren't able to create anything. Sorry! diff --git a/layout/generic/WritingModes.h b/layout/generic/WritingModes.h index c0d4a2b3ebae5..fcdf22d878a4f 100644 --- a/layout/generic/WritingModes.h +++ b/layout/generic/WritingModes.h @@ -362,8 +362,9 @@ class WritingMode { if (IsBlock(aSide)) { static_assert(eOrientationMask == 0x01 && eBlockFlowMask == 0x04, "unexpected mask values"); - const auto wm = static_cast(((mWritingMode & eBlockFlowMask) >> 1) | - (mWritingMode & eOrientationMask)); + const auto wm = + static_cast(((mWritingMode & eBlockFlowMask) >> 1) | + (mWritingMode & eOrientationMask)); return PhysicalSideForBlockAxis(wm, GetEdge(aSide)); } diff --git a/layout/generic/nsTextFrameUtils.cpp b/layout/generic/nsTextFrameUtils.cpp index c05aca49b5dbb..a5fc18cb708df 100644 --- a/layout/generic/nsTextFrameUtils.cpp +++ b/layout/generic/nsTextFrameUtils.cpp @@ -19,7 +19,7 @@ using namespace mozilla; // static bool nsTextFrameUtils::IsSpaceCombiningSequenceTail(const char16_t* aChars, - int32_t aLength) { + int32_t aLength) { return aLength > 0 && (mozilla::unicode::IsClusterExtender(aChars[0]) || (IsBidiControl(aChars[0]) && diff --git a/layout/painting/FrameLayerBuilder.cpp b/layout/painting/FrameLayerBuilder.cpp index 3c269085a5c32..5cc94be22f6de 100644 --- a/layout/painting/FrameLayerBuilder.cpp +++ b/layout/painting/FrameLayerBuilder.cpp @@ -4859,7 +4859,8 @@ void ContainerState::ProcessDisplayItems(nsDisplayList* aList) { nsIntRegion itemVisibleRegion = itemVisibleRect; nsRegion tightBounds = item->GetTightBounds(mBuilder, &snap); if (!tightBounds.IsEmpty()) { - itemVisibleRegion.AndWith(ScaleRegionToOutsidePixels(tightBounds, snap)); + itemVisibleRegion.AndWith( + ScaleRegionToOutsidePixels(tightBounds, snap)); } ContainerLayer* oldContainer = ownLayer->GetParent(); diff --git a/layout/style/Loader.cpp b/layout/style/Loader.cpp index 9d9aa3b54a600..57d0923e1f465 100644 --- a/layout/style/Loader.cpp +++ b/layout/style/Loader.cpp @@ -1602,19 +1602,20 @@ Loader::Completed Loader::ParseSheet(const nsACString& aBytes, RefPtr loadData = aLoadData; nsCOMPtr target = DispatchTarget(); sheet->ParseSheet(this, aBytes, aLoadData) - ->Then(target, __func__, - [loadData = std::move(loadData)](bool aDummy) { - MOZ_ASSERT(NS_IsMainThread()); - loadData->mIsBeingParsed = false; - loadData->mLoader->UnblockOnload(/* aFireSync = */ false); - // If there are no child sheets outstanding, mark us as complete. - // Otherwise, the children are holding strong refs to the data - // and will call SheetComplete() on it when they complete. - if (loadData->mPendingChildren == 0) { - loadData->mLoader->SheetComplete(loadData, NS_OK); - } - }, - [] { MOZ_CRASH("rejected parse promise"); }); + ->Then( + target, __func__, + [loadData = std::move(loadData)](bool aDummy) { + MOZ_ASSERT(NS_IsMainThread()); + loadData->mIsBeingParsed = false; + loadData->mLoader->UnblockOnload(/* aFireSync = */ false); + // If there are no child sheets outstanding, mark us as complete. + // Otherwise, the children are holding strong refs to the data + // and will call SheetComplete() on it when they complete. + if (loadData->mPendingChildren == 0) { + loadData->mLoader->SheetComplete(loadData, NS_OK); + } + }, + [] { MOZ_CRASH("rejected parse promise"); }); return Completed::No; } diff --git a/media/gmp-clearkey/0.1/gtest/TestClearKeyUtils.cpp b/media/gmp-clearkey/0.1/gtest/TestClearKeyUtils.cpp index aafba73dc380e..bff6d0f356607 100644 --- a/media/gmp-clearkey/0.1/gtest/TestClearKeyUtils.cpp +++ b/media/gmp-clearkey/0.1/gtest/TestClearKeyUtils.cpp @@ -65,7 +65,8 @@ const B64Test tests[] = { {"_", {}, false}, // 1 character is too few. }; -TEST(ClearKey, DecodeBase64) { +TEST(ClearKey, DecodeBase64) +{ for (const B64Test& test : tests) { vector v; bool rv = DecodeBase64(string(test.b64), v); diff --git a/media/mtransport/test/ice_unittest.cpp b/media/mtransport/test/ice_unittest.cpp index 0c04ac13fd8bf..b1bf84884907d 100644 --- a/media/mtransport/test/ice_unittest.cpp +++ b/media/mtransport/test/ice_unittest.cpp @@ -1098,13 +1098,13 @@ class IceTestPeer : public sigslot::has_slots<> { std::vector old_pairs = *new_pairs; GetCandidatePairs(stream_index, new_pairs); ASSERT_TRUE(CandidatePairsPriorityDescending(*new_pairs)) - << "New list of " - "candidate pairs is either not sorted in priority order, or has " - "duplicate priorities."; + << "New list of " + "candidate pairs is either not sorted in priority order, or has " + "duplicate priorities."; ASSERT_TRUE(CandidatePairsPriorityDescending(old_pairs)) - << "Old list of " - "candidate pairs is either not sorted in priority order, or has " - "duplicate priorities. This indicates some bug in the test case."; + << "Old list of " + "candidate pairs is either not sorted in priority order, or has " + "duplicate priorities. This indicates some bug in the test case."; std::vector added_pairs; std::vector removed_pairs; @@ -1134,8 +1134,9 @@ class IceTestPeer : public sigslot::has_slots<> { DumpCandidatePair(removed_pair); } - ASSERT_TRUE(removed_pairs.empty()) << "At least one candidate pair has " - "gone missing."; + ASSERT_TRUE(removed_pairs.empty()) + << "At least one candidate pair has " + "gone missing."; } void StreamReady(NrIceMediaStream* stream) { @@ -1220,7 +1221,8 @@ class IceTestPeer : public sigslot::has_slots<> { void ParseCandidate_s(size_t i, const std::string& candidate) { auto media_stream = GetStream_s(i); - ASSERT_TRUE(media_stream.get()) << "No such stream " << i; + ASSERT_TRUE(media_stream.get()) + << "No such stream " << i; media_stream->ParseTrickleCandidate(candidate, ""); } @@ -1233,7 +1235,8 @@ class IceTestPeer : public sigslot::has_slots<> { void DisableComponent_s(size_t index, int component_id) { ASSERT_LT(index, stream_counter_); auto stream = GetStream_s(index); - ASSERT_TRUE(stream.get()) << "No such stream " << index; + ASSERT_TRUE(stream.get()) + << "No such stream " << index; nsresult res = stream->DisableComponent(component_id); ASSERT_TRUE(NS_SUCCEEDED(res)); } @@ -1249,7 +1252,8 @@ class IceTestPeer : public sigslot::has_slots<> { ConsentStatus status) { ASSERT_LT(index, stream_counter_); auto stream = GetStream_s(index); - ASSERT_TRUE(stream.get()) << "No such stream " << index; + ASSERT_TRUE(stream.get()) + << "No such stream " << index; bool can_send; struct timeval timestamp; nsresult res = @@ -3844,7 +3848,8 @@ TEST_F(WebRtcIcePacketFilterTest, TestRecvDataPacketWithAPendingAddress) { ASSERT_EQ(0, nr_stun_message_destroy(&msg)); } -TEST(WebRtcIceInternalsTest, TestAddBogusAttribute) { +TEST(WebRtcIceInternalsTest, TestAddBogusAttribute) +{ nr_stun_message* req; ASSERT_EQ(0, nr_stun_message_create(&req)); Data* data; diff --git a/media/mtransport/test/simpletokenbucket_unittest.cpp b/media/mtransport/test/simpletokenbucket_unittest.cpp index 42c27d2e8be67..937a1b7078f90 100644 --- a/media/mtransport/test/simpletokenbucket_unittest.cpp +++ b/media/mtransport/test/simpletokenbucket_unittest.cpp @@ -28,39 +28,46 @@ class TestSimpleTokenBucket : public SimpleTokenBucket { } }; -TEST(SimpleTokenBucketTest, TestConstruct) { TestSimpleTokenBucket b(10, 1); } +TEST(SimpleTokenBucketTest, TestConstruct) +{ TestSimpleTokenBucket b(10, 1); } -TEST(SimpleTokenBucketTest, TestGet) { +TEST(SimpleTokenBucketTest, TestGet) +{ TestSimpleTokenBucket b(10, 1); ASSERT_EQ(5U, b.getTokens(5)); } -TEST(SimpleTokenBucketTest, TestGetAll) { +TEST(SimpleTokenBucketTest, TestGetAll) +{ TestSimpleTokenBucket b(10, 1); ASSERT_EQ(10U, b.getTokens(10)); } -TEST(SimpleTokenBucketTest, TestGetInsufficient) { +TEST(SimpleTokenBucketTest, TestGetInsufficient) +{ TestSimpleTokenBucket b(10, 1); ASSERT_EQ(5U, b.getTokens(5)); ASSERT_EQ(5U, b.getTokens(6)); } -TEST(SimpleTokenBucketTest, TestGetBucketCount) { +TEST(SimpleTokenBucketTest, TestGetBucketCount) +{ TestSimpleTokenBucket b(10, 1); ASSERT_EQ(10U, b.getTokens(UINT32_MAX)); ASSERT_EQ(5U, b.getTokens(5)); ASSERT_EQ(5U, b.getTokens(UINT32_MAX)); } -TEST(SimpleTokenBucketTest, TestTokenRefill) { +TEST(SimpleTokenBucketTest, TestTokenRefill) +{ TestSimpleTokenBucket b(10, 1); ASSERT_EQ(5U, b.getTokens(5)); b.fastForward(1000); ASSERT_EQ(6U, b.getTokens(6)); } -TEST(SimpleTokenBucketTest, TestNoTimeWasted) { +TEST(SimpleTokenBucketTest, TestNoTimeWasted) +{ // Makes sure that when the time elapsed is insufficient to add any // tokens to the bucket, the internal timestamp that is used in this // calculation is not updated (ie; two subsequent 0.5 second elapsed times @@ -73,7 +80,8 @@ TEST(SimpleTokenBucketTest, TestNoTimeWasted) { ASSERT_EQ(6U, b.getTokens(6)); } -TEST(SimpleTokenBucketTest, TestNegativeTime) { +TEST(SimpleTokenBucketTest, TestNegativeTime) +{ TestSimpleTokenBucket b(10, 1); b.fastForward(-1000); // Make sure we don't end up with an invalid number of tokens, but otherwise @@ -81,13 +89,15 @@ TEST(SimpleTokenBucketTest, TestNegativeTime) { ASSERT_GT(11U, b.getTokens(100)); } -TEST(SimpleTokenBucketTest, TestEmptyBucket) { +TEST(SimpleTokenBucketTest, TestEmptyBucket) +{ TestSimpleTokenBucket b(10, 1); ASSERT_EQ(10U, b.getTokens(10)); ASSERT_EQ(0U, b.getTokens(10)); } -TEST(SimpleTokenBucketTest, TestEmptyThenFillBucket) { +TEST(SimpleTokenBucketTest, TestEmptyThenFillBucket) +{ TestSimpleTokenBucket b(10, 1); ASSERT_EQ(10U, b.getTokens(10)); ASSERT_EQ(0U, b.getTokens(1)); @@ -95,7 +105,8 @@ TEST(SimpleTokenBucketTest, TestEmptyThenFillBucket) { ASSERT_EQ(10U, b.getTokens(10)); } -TEST(SimpleTokenBucketTest, TestNoOverflow) { +TEST(SimpleTokenBucketTest, TestNoOverflow) +{ TestSimpleTokenBucket b(10, 1); ASSERT_EQ(10U, b.getTokens(10)); ASSERT_EQ(0U, b.getTokens(1)); diff --git a/media/mtransport/test/test_nr_socket_unittest.cpp b/media/mtransport/test/test_nr_socket_unittest.cpp index 21c70b4d7f423..a78e48d9fcf1a 100644 --- a/media/mtransport/test/test_nr_socket_unittest.cpp +++ b/media/mtransport/test/test_nr_socket_unittest.cpp @@ -93,7 +93,8 @@ class TestNrSocketTest : public MtransportTest { void CreatePublicAddrs_s(size_t count, const char *ip_str, int proto) { while (count--) { auto sock = CreateTestNrSocket_s(ip_str, proto, nullptr); - ASSERT_TRUE(sock) << "Failed to create socket"; + ASSERT_TRUE(sock) + << "Failed to create socket"; public_addrs_.push_back(sock); } } @@ -657,8 +658,8 @@ TEST_F(TestNrSocketTest, PortDependentMappingFullCone) { ASSERT_TRUE(nr_transport_addr_cmp(&sender_external_address0, &sender_external_address1, NR_TRANSPORT_ADDR_CMP_MODE_ALL)) - << "addr1: " << sender_external_address0.as_string - << " addr2: " << sender_external_address1.as_string; + << "addr1: " << sender_external_address0.as_string + << " addr2: " << sender_external_address1.as_string; // Verify that return traffic works ASSERT_TRUE(CheckConnectivityVia(public_addrs_[1], private_addrs_[0], diff --git a/media/psshparser/gtest/TestPsshParser.cpp b/media/psshparser/gtest/TestPsshParser.cpp index 16ff272d85eaa..2027090a1fb20 100644 --- a/media/psshparser/gtest/TestPsshParser.cpp +++ b/media/psshparser/gtest/TestPsshParser.cpp @@ -125,7 +125,8 @@ const uint8_t g2xGoogleWPTCencInitData[] = { // clang-format on }; -TEST(PsshParser, ParseCencInitData) { +TEST(PsshParser, ParseCencInitData) +{ std::vector> keyIds; bool rv; diff --git a/media/webrtc/signaling/gtest/jsep_session_unittest.cpp b/media/webrtc/signaling/gtest/jsep_session_unittest.cpp index 27256406786ac..1c808a32ff13f 100644 --- a/media/webrtc/signaling/gtest/jsep_session_unittest.cpp +++ b/media/webrtc/signaling/gtest/jsep_session_unittest.cpp @@ -121,10 +121,10 @@ class JsepSessionTest : public JsepSessionTestBase, for (const RefPtr& oldTransceiver : oldTransceivers) { if (oldTransceiver->HasLevel()) { ASSERT_TRUE(levels.count(oldTransceiver->GetLevel())) - << "Level " << oldTransceiver->GetLevel() - << " had a transceiver in the old, but not the new (or, " - "perhaps this level had more than one transceiver in the " - "old)"; + << "Level " << oldTransceiver->GetLevel() + << " had a transceiver in the old, but not the new (or, " + "perhaps this level had more than one transceiver in the " + "old)"; levels.erase(oldTransceiver->GetLevel()); } } @@ -1077,7 +1077,7 @@ class JsepSessionTest : public JsepSessionTestBase, expectedCandidates[transportId][RTCP].size()); ASSERT_TRUE(attrs.HasAttribute(SdpAttribute::kCandidateAttribute)) - << context << " (level " << msection.GetLevel() << ")"; + << context << " (level " << msection.GetLevel() << ")"; auto& candidates = attrs.GetCandidate(); ASSERT_EQ(kNumCandidatesPerComponent * 2, candidates.size()) << context << " (level " << msection.GetLevel() << ")"; @@ -1124,7 +1124,7 @@ class JsepSessionTest : public JsepSessionTestBase, auto defaultCandidates = mDefaultCandidates; ASSERT_TRUE(msection.GetAttributeList().HasAttribute( SdpAttribute::kRtcpAttribute)) - << context << " (level " << msection.GetLevel() << ")"; + << context << " (level " << msection.GetLevel() << ")"; auto& rtcpAttr = msection.GetAttributeList().GetRtcp(); ASSERT_EQ(defaultCandidates[transportId][RTCP].second, rtcpAttr.mPort) << context << " (level " << msection.GetLevel() << ")"; @@ -1173,7 +1173,7 @@ class JsepSessionTest : public JsepSessionTestBase, if (expectEoc) { ASSERT_TRUE(msection.GetAttributeList().HasAttribute( SdpAttribute::kEndOfCandidatesAttribute)) - << context << " (level " << msection.GetLevel() << ")"; + << context << " (level " << msection.GetLevel() << ")"; } else { ASSERT_FALSE(msection.GetAttributeList().HasAttribute( SdpAttribute::kEndOfCandidatesAttribute)) @@ -1184,7 +1184,8 @@ class JsepSessionTest : public JsepSessionTestBase, void CheckTransceiversAreBundled(const JsepSession& session, const std::string& context) { for (const auto& transceiver : session.GetTransceivers()) { - ASSERT_TRUE(transceiver->HasBundleLevel()) << context; + ASSERT_TRUE(transceiver->HasBundleLevel()) + << context; ASSERT_EQ(0U, transceiver->BundleLevel()) << context; } } @@ -3996,7 +3997,8 @@ TEST_P(JsepSessionTest, TestRejectMline) { EnsureNegotiationFailure(types.front(), "webrtc-datachannel"); break; default: - ASSERT_TRUE(false) << "Unknown media type"; + ASSERT_TRUE(false) + << "Unknown media type"; } AddTracks(*mSessionOff); @@ -4020,7 +4022,8 @@ TEST_P(JsepSessionTest, TestRejectMline) { } } - ASSERT_TRUE(failed_section) << "Failed type was entirely absent from SDP"; + ASSERT_TRUE(failed_section) + << "Failed type was entirely absent from SDP"; auto& failed_attrs = failed_section->GetAttributeList(); ASSERT_EQ(SdpDirectionAttribute::kInactive, failed_attrs.GetDirection()); ASSERT_EQ(0U, failed_section->GetPort()); @@ -4393,7 +4396,8 @@ TEST_F(JsepSessionTest, UnknownFingerprintAlgorithm) { ASSERT_NE("", mSessionAns->GetLastError()); } -TEST(H264ProfileLevelIdTest, TestLevelComparisons) { +TEST(H264ProfileLevelIdTest, TestLevelComparisons) +{ ASSERT_LT(JsepVideoCodecDescription::GetSaneH264Level(0x421D0B), // 1b JsepVideoCodecDescription::GetSaneH264Level(0x420D0B)); // 1.1 ASSERT_LT(JsepVideoCodecDescription::GetSaneH264Level(0x420D0A), // 1.0 @@ -4409,7 +4413,8 @@ TEST(H264ProfileLevelIdTest, TestLevelComparisons) { JsepVideoCodecDescription::GetSaneH264Level(0x64000B)); // 1.1 } -TEST(H264ProfileLevelIdTest, TestLevelSetting) { +TEST(H264ProfileLevelIdTest, TestLevelSetting) +{ uint32_t profileLevelId = 0x420D0A; JsepVideoCodecDescription::SetSaneH264Level( JsepVideoCodecDescription::GetSaneH264Level(0x42100B), &profileLevelId); diff --git a/media/webrtc/signaling/gtest/sdp_unittests.cpp b/media/webrtc/signaling/gtest/sdp_unittests.cpp index 7259402ee3d51..e24472df04b2c 100644 --- a/media/webrtc/signaling/gtest/sdp_unittests.cpp +++ b/media/webrtc/signaling/gtest/sdp_unittests.cpp @@ -1580,7 +1580,7 @@ class NewSdpTest if (expectSuccess) { ASSERT_TRUE(!!mSdp) - << "Parse failed on first pass: " << GetParseErrors(); + << "Parse failed on first pass: " << GetParseErrors(); } if (mSdp) { @@ -1595,9 +1595,9 @@ class NewSdpTest // Whether we expected the parse to work or not, it should // succeed the second time if it succeeded the first. ASSERT_TRUE(!!mSdp) - << "Parse failed on second pass, SDP was: " << std::endl - << os.str() << std::endl - << "Errors were: " << GetParseErrors(); + << "Parse failed on second pass, SDP was: " << std::endl + << os.str() << std::endl + << "Errors were: " << GetParseErrors(); // Serialize again and compare std::stringstream os2; @@ -1607,7 +1607,8 @@ class NewSdpTest } if (expectSuccess) { - ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors(); + ASSERT_TRUE(!!mSdp) + << "Parse failed: " << GetParseErrors(); ASSERT_EQ(0U, mSdpErrorHolder->GetParseErrors().size()) << "Got unexpected parse errors/warnings: " << GetParseErrors(); } @@ -1933,7 +1934,8 @@ TEST_P(NewSdpTest, BasicAudioVideoSdpParse) { ParseSdp(kBasicAudioVideoOffer); } TEST_P(NewSdpTest, CheckRemoveFmtp) { ParseSdp(kBasicAudioVideoOffer); - ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors(); + ASSERT_TRUE(!!mSdp) + << "Parse failed: " << GetParseErrors(); ASSERT_EQ(3U, mSdp->GetMediaSectionCount()) << "Wrong number of media sections"; @@ -1968,7 +1970,8 @@ TEST_P(NewSdpTest, CheckRemoveFmtp) { TEST_P(NewSdpTest, CheckIceUfrag) { ParseSdp(kBasicAudioVideoOffer); - ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors(); + ASSERT_TRUE(!!mSdp) + << "Parse failed: " << GetParseErrors(); ASSERT_TRUE( mSdp->GetAttributeList().HasAttribute(SdpAttribute::kIceUfragAttribute)); auto ice_ufrag = mSdp->GetAttributeList().GetIceUfrag(); @@ -1983,7 +1986,8 @@ TEST_P(NewSdpTest, CheckIceUfrag) { TEST_P(NewSdpTest, CheckIcePwd) { ParseSdp(kBasicAudioVideoOffer); - ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors(); + ASSERT_TRUE(!!mSdp) + << "Parse failed: " << GetParseErrors(); ASSERT_TRUE( mSdp->GetAttributeList().HasAttribute(SdpAttribute::kIcePwdAttribute)); auto ice_pwd = mSdp->GetAttributeList().GetIcePwd(); @@ -2001,7 +2005,8 @@ TEST_P(NewSdpTest, CheckIcePwd) { TEST_P(NewSdpTest, CheckIceOptions) { ParseSdp(kBasicAudioVideoOffer); - ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors(); + ASSERT_TRUE(!!mSdp) + << "Parse failed: " << GetParseErrors(); ASSERT_TRUE(mSdp->GetAttributeList().HasAttribute( SdpAttribute::kIceOptionsAttribute)); auto ice_options = mSdp->GetAttributeList().GetIceOptions(); @@ -2023,7 +2028,8 @@ TEST_P(NewSdpTest, CheckIceOptions) { TEST_P(NewSdpTest, CheckFingerprint) { ParseSdp(kBasicAudioVideoOffer); - ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors(); + ASSERT_TRUE(!!mSdp) + << "Parse failed: " << GetParseErrors(); ASSERT_TRUE(mSdp->GetAttributeList().HasAttribute( SdpAttribute::kFingerprintAttribute)); auto fingerprints = mSdp->GetAttributeList().GetFingerprint(); @@ -2079,7 +2085,8 @@ TEST_P(NewSdpTest, CheckFingerprint) { TEST_P(NewSdpTest, CheckIdentity) { ParseSdp(kBasicAudioVideoOffer); - ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors(); + ASSERT_TRUE(!!mSdp) + << "Parse failed: " << GetParseErrors(); ASSERT_TRUE( mSdp->GetAttributeList().HasAttribute(SdpAttribute::kIdentityAttribute)); auto identity = mSdp->GetAttributeList().GetIdentity(); @@ -2088,7 +2095,8 @@ TEST_P(NewSdpTest, CheckIdentity) { TEST_P(NewSdpTest, CheckDtlsMessage) { ParseSdp(kBasicAudioVideoOffer); - ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors(); + ASSERT_TRUE(!!mSdp) + << "Parse failed: " << GetParseErrors(); ASSERT_TRUE(mSdp->GetAttributeList().HasAttribute( SdpAttribute::kDtlsMessageAttribute)); auto dtls_message = mSdp->GetAttributeList().GetDtlsMessage(); @@ -2100,14 +2108,16 @@ TEST_P(NewSdpTest, CheckDtlsMessage) { TEST_P(NewSdpTest, CheckNumberOfMediaSections) { ParseSdp(kBasicAudioVideoOffer); - ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors(); + ASSERT_TRUE(!!mSdp) + << "Parse failed: " << GetParseErrors(); ASSERT_EQ(3U, mSdp->GetMediaSectionCount()) << "Wrong number of media sections"; } TEST_P(NewSdpTest, CheckMlines) { ParseSdp(kBasicAudioVideoOffer); - ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors(); + ASSERT_TRUE(!!mSdp) + << "Parse failed: " << GetParseErrors(); ASSERT_EQ(3U, mSdp->GetMediaSectionCount()) << "Wrong number of media sections"; ASSERT_EQ(SdpMediaSection::kAudio, mSdp->GetMediaSection(0).GetMediaType()) @@ -2139,7 +2149,8 @@ TEST_P(NewSdpTest, CheckMlines) { TEST_P(NewSdpTest, CheckSetup) { ParseSdp(kBasicAudioVideoOffer); - ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors(); + ASSERT_TRUE(!!mSdp) + << "Parse failed: " << GetParseErrors(); ASSERT_EQ(3U, mSdp->GetMediaSectionCount()) << "Wrong number of media sections"; @@ -2157,7 +2168,8 @@ TEST_P(NewSdpTest, CheckSetup) { TEST_P(NewSdpTest, CheckSsrc) { ParseSdp(kBasicAudioVideoOffer); - ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors(); + ASSERT_TRUE(!!mSdp) + << "Parse failed: " << GetParseErrors(); ASSERT_EQ(3U, mSdp->GetMediaSectionCount()) << "Wrong number of media sections"; @@ -2185,7 +2197,8 @@ TEST_P(NewSdpTest, CheckSsrc) { TEST_P(NewSdpTest, CheckRtpmap) { ParseSdp(kBasicAudioVideoOffer); - ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors(); + ASSERT_TRUE(!!mSdp) + << "Parse failed: " << GetParseErrors(); ASSERT_EQ(3U, mSdp->GetMediaSectionCount()) << "Wrong number of media sections"; @@ -2241,7 +2254,8 @@ static const std::string kAudioWithTelephoneEvent = TEST_P(NewSdpTest, CheckTelephoneEventNoFmtp) { ParseSdp(kAudioWithTelephoneEvent); - ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors(); + ASSERT_TRUE(!!mSdp) + << "Parse failed: " << GetParseErrors(); ASSERT_EQ(1U, mSdp->GetMediaSectionCount()) << "Wrong number of media sections"; @@ -2259,7 +2273,8 @@ TEST_P(NewSdpTest, CheckTelephoneEventNoFmtp) { TEST_P(NewSdpTest, CheckTelephoneEventWithDefaultEvents) { ParseSdp(kAudioWithTelephoneEvent + "a=fmtp:101 0-15" CRLF); - ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors(); + ASSERT_TRUE(!!mSdp) + << "Parse failed: " << GetParseErrors(); ASSERT_EQ(1U, mSdp->GetMediaSectionCount()) << "Wrong number of media sections"; @@ -2268,7 +2283,8 @@ TEST_P(NewSdpTest, CheckTelephoneEventWithDefaultEvents) { TEST_P(NewSdpTest, CheckTelephoneEventWithBadCharacter) { ParseSdp(kAudioWithTelephoneEvent + "a=fmtp:101 0-5." CRLF); - ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors(); + ASSERT_TRUE(!!mSdp) + << "Parse failed: " << GetParseErrors(); ASSERT_EQ(1U, mSdp->GetMediaSectionCount()) << "Wrong number of media sections"; @@ -2277,7 +2293,8 @@ TEST_P(NewSdpTest, CheckTelephoneEventWithBadCharacter) { TEST_P(NewSdpTest, CheckTelephoneEventIncludingCommas) { ParseSdp(kAudioWithTelephoneEvent + "a=fmtp:101 0-15,66,67" CRLF); - ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors(); + ASSERT_TRUE(!!mSdp) + << "Parse failed: " << GetParseErrors(); ASSERT_EQ(1U, mSdp->GetMediaSectionCount()) << "Wrong number of media sections"; @@ -2286,7 +2303,8 @@ TEST_P(NewSdpTest, CheckTelephoneEventIncludingCommas) { TEST_P(NewSdpTest, CheckTelephoneEventComplexEvents) { ParseSdp(kAudioWithTelephoneEvent + "a=fmtp:101 0,1,2-4,5-15,66,67" CRLF); - ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors(); + ASSERT_TRUE(!!mSdp) + << "Parse failed: " << GetParseErrors(); ASSERT_EQ(1U, mSdp->GetMediaSectionCount()) << "Wrong number of media sections"; @@ -2295,7 +2313,8 @@ TEST_P(NewSdpTest, CheckTelephoneEventComplexEvents) { TEST_P(NewSdpTest, CheckTelephoneEventNoHyphen) { ParseSdp(kAudioWithTelephoneEvent + "a=fmtp:101 5,6,7" CRLF); - ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors(); + ASSERT_TRUE(!!mSdp) + << "Parse failed: " << GetParseErrors(); ASSERT_EQ(1U, mSdp->GetMediaSectionCount()) << "Wrong number of media sections"; @@ -2304,7 +2323,8 @@ TEST_P(NewSdpTest, CheckTelephoneEventNoHyphen) { TEST_P(NewSdpTest, CheckTelephoneEventOnlyZero) { ParseSdp(kAudioWithTelephoneEvent + "a=fmtp:101 0" CRLF); - ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors(); + ASSERT_TRUE(!!mSdp) + << "Parse failed: " << GetParseErrors(); ASSERT_EQ(1U, mSdp->GetMediaSectionCount()) << "Wrong number of media sections"; @@ -2313,7 +2333,8 @@ TEST_P(NewSdpTest, CheckTelephoneEventOnlyZero) { TEST_P(NewSdpTest, CheckTelephoneEventOnlyOne) { ParseSdp(kAudioWithTelephoneEvent + "a=fmtp:101 1" CRLF); - ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors(); + ASSERT_TRUE(!!mSdp) + << "Parse failed: " << GetParseErrors(); ASSERT_EQ(1U, mSdp->GetMediaSectionCount()) << "Wrong number of media sections"; @@ -2322,7 +2343,8 @@ TEST_P(NewSdpTest, CheckTelephoneEventOnlyOne) { TEST_P(NewSdpTest, CheckTelephoneEventBadThreeDigit) { ParseSdp(kAudioWithTelephoneEvent + "a=fmtp:101 123" CRLF); - ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors(); + ASSERT_TRUE(!!mSdp) + << "Parse failed: " << GetParseErrors(); ASSERT_EQ(1U, mSdp->GetMediaSectionCount()) << "Wrong number of media sections"; @@ -2332,7 +2354,8 @@ TEST_P(NewSdpTest, CheckTelephoneEventBadThreeDigit) { TEST_P(NewSdpTest, CheckTelephoneEventBadThreeDigitWithHyphen) { ParseSdp(kAudioWithTelephoneEvent + "a=fmtp:101 0-123" CRLF); - ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors(); + ASSERT_TRUE(!!mSdp) + << "Parse failed: " << GetParseErrors(); ASSERT_EQ(1U, mSdp->GetMediaSectionCount()) << "Wrong number of media sections"; @@ -2342,7 +2365,8 @@ TEST_P(NewSdpTest, CheckTelephoneEventBadThreeDigitWithHyphen) { TEST_P(NewSdpTest, CheckTelephoneEventBadLeadingHyphen) { ParseSdp(kAudioWithTelephoneEvent + "a=fmtp:101 -12" CRLF); - ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors(); + ASSERT_TRUE(!!mSdp) + << "Parse failed: " << GetParseErrors(); ASSERT_EQ(1U, mSdp->GetMediaSectionCount()) << "Wrong number of media sections"; @@ -2360,7 +2384,8 @@ TEST_P(NewSdpTest, CheckTelephoneEventBadTrailingHyphenInMiddle) { TEST_P(NewSdpTest, CheckTelephoneEventBadLeadingComma) { ParseSdp(kAudioWithTelephoneEvent + "a=fmtp:101 ,2,3" CRLF); - ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors(); + ASSERT_TRUE(!!mSdp) + << "Parse failed: " << GetParseErrors(); ASSERT_EQ(1U, mSdp->GetMediaSectionCount()) << "Wrong number of media sections"; @@ -2370,7 +2395,8 @@ TEST_P(NewSdpTest, CheckTelephoneEventBadLeadingComma) { TEST_P(NewSdpTest, CheckTelephoneEventBadMultipleLeadingComma) { ParseSdp(kAudioWithTelephoneEvent + "a=fmtp:101 ,,,2,3" CRLF); - ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors(); + ASSERT_TRUE(!!mSdp) + << "Parse failed: " << GetParseErrors(); ASSERT_EQ(1U, mSdp->GetMediaSectionCount()) << "Wrong number of media sections"; @@ -2380,7 +2406,8 @@ TEST_P(NewSdpTest, CheckTelephoneEventBadMultipleLeadingComma) { TEST_P(NewSdpTest, CheckTelephoneEventBadConsecutiveCommas) { ParseSdp(kAudioWithTelephoneEvent + "a=fmtp:101 1,,,,,,,,3" CRLF); - ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors(); + ASSERT_TRUE(!!mSdp) + << "Parse failed: " << GetParseErrors(); ASSERT_EQ(1U, mSdp->GetMediaSectionCount()) << "Wrong number of media sections"; @@ -2390,7 +2417,8 @@ TEST_P(NewSdpTest, CheckTelephoneEventBadConsecutiveCommas) { TEST_P(NewSdpTest, CheckTelephoneEventBadTrailingComma) { ParseSdp(kAudioWithTelephoneEvent + "a=fmtp:101 1,2,3," CRLF); - ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors(); + ASSERT_TRUE(!!mSdp) + << "Parse failed: " << GetParseErrors(); ASSERT_EQ(1U, mSdp->GetMediaSectionCount()) << "Wrong number of media sections"; @@ -2400,7 +2428,8 @@ TEST_P(NewSdpTest, CheckTelephoneEventBadTrailingComma) { TEST_P(NewSdpTest, CheckTelephoneEventBadTwoHyphens) { ParseSdp(kAudioWithTelephoneEvent + "a=fmtp:101 1-2-3" CRLF); - ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors(); + ASSERT_TRUE(!!mSdp) + << "Parse failed: " << GetParseErrors(); ASSERT_EQ(1U, mSdp->GetMediaSectionCount()) << "Wrong number of media sections"; @@ -2410,7 +2439,8 @@ TEST_P(NewSdpTest, CheckTelephoneEventBadTwoHyphens) { TEST_P(NewSdpTest, CheckTelephoneEventBadSixDigit) { ParseSdp(kAudioWithTelephoneEvent + "a=fmtp:101 112233" CRLF); - ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors(); + ASSERT_TRUE(!!mSdp) + << "Parse failed: " << GetParseErrors(); ASSERT_EQ(1U, mSdp->GetMediaSectionCount()) << "Wrong number of media sections"; @@ -2420,7 +2450,8 @@ TEST_P(NewSdpTest, CheckTelephoneEventBadSixDigit) { TEST_P(NewSdpTest, CheckTelephoneEventBadRangeReversed) { ParseSdp(kAudioWithTelephoneEvent + "a=fmtp:101 33-2" CRLF); - ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors(); + ASSERT_TRUE(!!mSdp) + << "Parse failed: " << GetParseErrors(); ASSERT_EQ(1U, mSdp->GetMediaSectionCount()) << "Wrong number of media sections"; @@ -2441,7 +2472,8 @@ static const std::string kVideoWithRedAndUlpfecSdp = TEST_P(NewSdpTest, CheckRedNoFmtp) { ParseSdp(kVideoWithRedAndUlpfecSdp); - ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors(); + ASSERT_TRUE(!!mSdp) + << "Parse failed: " << GetParseErrors(); ASSERT_EQ(1U, mSdp->GetMediaSectionCount()) << "Wrong number of media sections"; @@ -2473,7 +2505,8 @@ TEST_P(NewSdpTest, CheckRedEmptyFmtp) { } } - ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors(); + ASSERT_TRUE(!!mSdp) + << "Parse failed: " << GetParseErrors(); ASSERT_EQ(1U, mSdp->GetMediaSectionCount()) << "Wrong number of media sections"; @@ -2491,7 +2524,8 @@ TEST_P(NewSdpTest, CheckRedEmptyFmtp) { TEST_P(NewSdpTest, CheckRedFmtpWith2Codecs) { ParseSdp(kVideoWithRedAndUlpfecSdp + "a=fmtp:122 120/121" CRLF); - ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors(); + ASSERT_TRUE(!!mSdp) + << "Parse failed: " << GetParseErrors(); ASSERT_EQ(1U, mSdp->GetMediaSectionCount()) << "Wrong number of media sections"; @@ -2515,7 +2549,8 @@ TEST_P(NewSdpTest, CheckRedFmtpWith2Codecs) { TEST_P(NewSdpTest, CheckRedFmtpWith3Codecs) { ParseSdp(kVideoWithRedAndUlpfecSdp + "a=fmtp:122 120/121/123" CRLF); - ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors(); + ASSERT_TRUE(!!mSdp) + << "Parse failed: " << GetParseErrors(); ASSERT_EQ(1U, mSdp->GetMediaSectionCount()) << "Wrong number of media sections"; @@ -2599,7 +2634,8 @@ const std::string kH264AudioVideoOffer = TEST_P(NewSdpTest, CheckFormatParameters) { ParseSdp(kH264AudioVideoOffer); - ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors(); + ASSERT_TRUE(!!mSdp) + << "Parse failed: " << GetParseErrors(); ASSERT_EQ(3U, mSdp->GetMediaSectionCount()) << "Wrong number of media sections"; @@ -2712,7 +2748,8 @@ TEST_P(NewSdpTest, CheckFlags) { TEST_P(NewSdpTest, CheckConnectionLines) { ParseSdp(kBasicAudioVideoOffer); - ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors(); + ASSERT_TRUE(!!mSdp) + << "Parse failed: " << GetParseErrors(); ASSERT_EQ(3U, mSdp->GetMediaSectionCount()) << "Wrong number of media sections"; @@ -2739,7 +2776,8 @@ TEST_P(NewSdpTest, CheckConnectionLines) { TEST_P(NewSdpTest, CheckDirections) { ParseSdp(kBasicAudioVideoOffer); - ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors(); + ASSERT_TRUE(!!mSdp) + << "Parse failed: " << GetParseErrors(); ASSERT_EQ(SdpDirectionAttribute::kSendonly, mSdp->GetMediaSection(0).GetAttributeList().GetDirection()); ASSERT_EQ(SdpDirectionAttribute::kRecvonly, @@ -2750,7 +2788,8 @@ TEST_P(NewSdpTest, CheckDirections) { TEST_P(NewSdpTest, CheckCandidates) { ParseSdp(kBasicAudioVideoOffer); - ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors(); + ASSERT_TRUE(!!mSdp) + << "Parse failed: " << GetParseErrors(); ASSERT_EQ(3U, mSdp->GetMediaSectionCount()) << "Wrong number of media sections"; @@ -2926,7 +2965,8 @@ TEST_P(NewSdpTest, CheckRid) { TEST_P(NewSdpTest, CheckMediaLevelIceUfrag) { ParseSdp(kBasicAudioVideoOffer); - ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors(); + ASSERT_TRUE(!!mSdp) + << "Parse failed: " << GetParseErrors(); ASSERT_EQ(3U, mSdp->GetMediaSectionCount()) << "Wrong number of media sections"; @@ -2946,7 +2986,8 @@ TEST_P(NewSdpTest, CheckMediaLevelIceUfrag) { TEST_P(NewSdpTest, CheckMediaLevelIcePwd) { ParseSdp(kBasicAudioVideoOffer); - ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors(); + ASSERT_TRUE(!!mSdp) + << "Parse failed: " << GetParseErrors(); ASSERT_EQ(3U, mSdp->GetMediaSectionCount()) << "Wrong number of media sections"; @@ -3259,7 +3300,8 @@ TEST_P(NewSdpTest, CheckSimulcast) { TEST_P(NewSdpTest, CheckSctpmap) { ParseSdp(kBasicAudioVideoDataOffer); - ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors(); + ASSERT_TRUE(!!mSdp) + << "Parse failed: " << GetParseErrors(); ASSERT_EQ(3U, mSdp->GetMediaSectionCount()) << "Wrong number of media sections"; @@ -3280,7 +3322,8 @@ TEST_P(NewSdpTest, CheckSctpmap) { TEST_P(NewSdpTest, CheckMaxPtime) { ParseSdp(kBasicAudioVideoOffer); - ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors(); + ASSERT_TRUE(!!mSdp) + << "Parse failed: " << GetParseErrors(); ASSERT_EQ(3U, mSdp->GetMediaSectionCount()) << "Wrong number of media sections"; @@ -3749,7 +3792,8 @@ const std::string kMediaLevelDtlsMessage = TEST_P(NewSdpTest, CheckMediaLevelDtlsMessage) { ParseSdp(kMediaLevelDtlsMessage); - ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors(); + ASSERT_TRUE(!!mSdp) + << "Parse failed: " << GetParseErrors(); // dtls-message is not defined for use at the media level; we don't // parse it @@ -3765,7 +3809,8 @@ TEST_P(NewSdpTest, CheckSetPort) { "a=sendonly" CRLF, false); - ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors(); + ASSERT_TRUE(!!mSdp) + << "Parse failed: " << GetParseErrors(); constexpr unsigned int expectedParesPort = 56436; unsigned int currentPort = mSdp->GetMediaSection(0).GetPort(); @@ -3782,7 +3827,8 @@ TEST_P(NewSdpTest, CheckAddCodec) { "m=video 56436 RTP/SAVPF 120" CRLF "a=rtpmap:120 VP8/90000" CRLF "a=sendonly" CRLF); - ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors(); + ASSERT_TRUE(!!mSdp) + << "Parse failed: " << GetParseErrors(); ASSERT_EQ(1U, mSdp->GetMediaSectionCount()); ASSERT_EQ(1U, mSdp->GetMediaSection(0).GetFormats().size()); @@ -3813,7 +3859,8 @@ TEST_P(NewSdpTest, CheckClearCodecs) { "m=video 56436 RTP/SAVPF 120 110" CRLF "a=rtpmap:120 VP8/90000" CRLF "a=sendonly" CRLF "a=rtpmap:110 opus/48000/2" CRLF); - ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors(); + ASSERT_TRUE(!!mSdp) + << "Parse failed: " << GetParseErrors(); ASSERT_EQ(1U, mSdp->GetMediaSectionCount()); ASSERT_EQ(2U, mSdp->GetMediaSection(0).GetFormats().size()); @@ -3831,7 +3878,8 @@ TEST_P(NewSdpTest, CheckClearCodecs) { TEST_P(NewSdpTest, CheckAddMediaSection) { ParseSdp(kBasicAudioVideoOffer); - ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors(); + ASSERT_TRUE(!!mSdp) + << "Parse failed: " << GetParseErrors(); ASSERT_EQ(3U, mSdp->GetMediaSectionCount()) << "Wrong number of media sections"; @@ -3906,7 +3954,8 @@ TEST_P(NewSdpTest, CheckAddDataChannel_Draft05) { "c=IN IP4 198.51.100.7" CRLF "b=CT:5000" CRLF "t=0 0" CRLF "m=application 56436 DTLS/SCTP 5000" CRLF); - ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors(); + ASSERT_TRUE(!!mSdp) + << "Parse failed: " << GetParseErrors(); ASSERT_EQ(1U, mSdp->GetMediaSectionCount()); auto& mediaSection = mSdp->GetMediaSection(0); @@ -3940,7 +3989,8 @@ TEST_P(NewSdpTest, CheckAddDataChannel) { "c=IN IP4 198.51.100.7" CRLF "b=CT:5000" CRLF "t=0 0" CRLF "m=application 56436 UDP/DTLS/SCTP webrtc-datachannel" CRLF); - ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors(); + ASSERT_TRUE(!!mSdp) + << "Parse failed: " << GetParseErrors(); ASSERT_EQ(1U, mSdp->GetMediaSectionCount()); auto& mediaSection = mSdp->GetMediaSection(0); @@ -3962,7 +4012,8 @@ TEST_P(NewSdpTest, CheckAddDataChannel) { ASSERT_EQ(15000U, mediaSection.GetAttributeList().GetSctpPort()); } -TEST(NewSdpTestNoFixture, CheckParsingResultComparer) { +TEST(NewSdpTestNoFixture, CheckParsingResultComparer) +{ auto check_comparison = [](const std::string sdp_string) { SipccSdpParser sipccParser; RsdparsaSdpParser rustParser; @@ -4022,7 +4073,8 @@ TEST(NewSdpTestNoFixture, CheckParsingResultComparer) { ASSERT_TRUE(check_comparison(kBasicH264Fmtp2)); } -TEST(NewSdpTestNoFixture, CheckAttributeTypeSerialize) { +TEST(NewSdpTestNoFixture, CheckAttributeTypeSerialize) +{ for (auto a = static_cast(SdpAttribute::kFirstAttribute); a <= static_cast(SdpAttribute::kLastAttribute); ++a) { SdpAttribute::AttributeType type = @@ -4048,7 +4100,8 @@ static SdpImageattrAttributeList::XYRange ParseXYRange( return range; } -TEST(NewSdpTestNoFixture, CheckImageattrXYRangeParseValid) { +TEST(NewSdpTestNoFixture, CheckImageattrXYRangeParseValid) +{ { SdpImageattrAttributeList::XYRange range(ParseXYRange("640")); ASSERT_EQ(1U, range.discreteValues.size()); @@ -4103,7 +4156,8 @@ void ParseInvalid(const std::string& input, size_t last) { std::cout << "\"" << input << "\" - " << error << std::endl; } -TEST(NewSdpTestNoFixture, CheckImageattrXYRangeParseInvalid) { +TEST(NewSdpTestNoFixture, CheckImageattrXYRangeParseInvalid) +{ ParseInvalid("[-1", 1); ParseInvalid("[-", 1); ParseInvalid("[-v", 1); @@ -4152,7 +4206,8 @@ static SdpImageattrAttributeList::SRange ParseSRange(const std::string& input) { return range; } -TEST(NewSdpTestNoFixture, CheckImageattrSRangeParseValid) { +TEST(NewSdpTestNoFixture, CheckImageattrSRangeParseValid) +{ { SdpImageattrAttributeList::SRange range(ParseSRange("0.1")); ASSERT_EQ(1U, range.discreteValues.size()); @@ -4182,7 +4237,8 @@ TEST(NewSdpTestNoFixture, CheckImageattrSRangeParseValid) { } } -TEST(NewSdpTestNoFixture, CheckImageattrSRangeParseInvalid) { +TEST(NewSdpTestNoFixture, CheckImageattrSRangeParseInvalid) +{ ParseInvalid("", 0); ParseInvalid("[", 1); ParseInvalid("[v", 1); @@ -4223,13 +4279,15 @@ static SdpImageattrAttributeList::PRange ParsePRange(const std::string& input) { return range; } -TEST(NewSdpTestNoFixture, CheckImageattrPRangeParseValid) { +TEST(NewSdpTestNoFixture, CheckImageattrPRangeParseValid) +{ SdpImageattrAttributeList::PRange range(ParsePRange("[0.1000-9.9999]")); ASSERT_FLOAT_EQ(0.1f, range.min); ASSERT_FLOAT_EQ(9.9999f, range.max); } -TEST(NewSdpTestNoFixture, CheckImageattrPRangeParseInvalid) { +TEST(NewSdpTestNoFixture, CheckImageattrPRangeParseInvalid) +{ ParseInvalid("", 0); ParseInvalid("[", 1); ParseInvalid("[v", 1); @@ -4267,7 +4325,8 @@ static SdpImageattrAttributeList::Set ParseSet(const std::string& input) { return set; } -TEST(NewSdpTestNoFixture, CheckImageattrSetParseValid) { +TEST(NewSdpTestNoFixture, CheckImageattrSetParseValid) +{ { SdpImageattrAttributeList::Set set(ParseSet("[x=320,y=240]")); ASSERT_EQ(1U, set.xRange.discreteValues.size()); @@ -4391,7 +4450,8 @@ TEST(NewSdpTestNoFixture, CheckImageattrSetParseValid) { } } -TEST(NewSdpTestNoFixture, CheckImageattrSetParseInvalid) { +TEST(NewSdpTestNoFixture, CheckImageattrSetParseInvalid) +{ ParseInvalid("", 0); ParseInvalid("x", 0); ParseInvalid("[", 1); @@ -4439,7 +4499,8 @@ static SdpImageattrAttributeList::Imageattr ParseImageattr( return imageattr; } -TEST(NewSdpTestNoFixture, CheckImageattrParseValid) { +TEST(NewSdpTestNoFixture, CheckImageattrParseValid) +{ { SdpImageattrAttributeList::Imageattr imageattr(ParseImageattr("* send *")); ASSERT_FALSE(imageattr.pt.isSome()); @@ -4571,7 +4632,8 @@ TEST(NewSdpTestNoFixture, CheckImageattrParseValid) { } } -TEST(NewSdpTestNoFixture, CheckImageattrParseInvalid) { +TEST(NewSdpTestNoFixture, CheckImageattrParseInvalid) +{ ParseInvalid("", 0); ParseInvalid(" ", 0); ParseInvalid("-1", 0); @@ -4595,7 +4657,8 @@ TEST(NewSdpTestNoFixture, CheckImageattrParseInvalid) { "* send * recv [x=640,y=480] foobajooba", 28); } -TEST(NewSdpTestNoFixture, CheckImageattrXYRangeSerialization) { +TEST(NewSdpTestNoFixture, CheckImageattrXYRangeSerialization) +{ SdpImageattrAttributeList::XYRange range; std::stringstream os; @@ -4622,7 +4685,8 @@ TEST(NewSdpTestNoFixture, CheckImageattrXYRangeSerialization) { ASSERT_EQ("[320,640]", os.str()); } -TEST(NewSdpTestNoFixture, CheckImageattrSRangeSerialization) { +TEST(NewSdpTestNoFixture, CheckImageattrSRangeSerialization) +{ SdpImageattrAttributeList::SRange range; std::ostringstream os; @@ -4644,7 +4708,8 @@ TEST(NewSdpTestNoFixture, CheckImageattrSRangeSerialization) { ASSERT_EQ("[0.1000,0.5000]", os.str()); } -TEST(NewSdpTestNoFixture, CheckImageattrPRangeSerialization) { +TEST(NewSdpTestNoFixture, CheckImageattrPRangeSerialization) +{ SdpImageattrAttributeList::PRange range; std::ostringstream os; @@ -4654,7 +4719,8 @@ TEST(NewSdpTestNoFixture, CheckImageattrPRangeSerialization) { ASSERT_EQ("[0.1000-0.9999]", os.str()); } -TEST(NewSdpTestNoFixture, CheckImageattrSetSerialization) { +TEST(NewSdpTestNoFixture, CheckImageattrSetSerialization) +{ SdpImageattrAttributeList::Set set; std::ostringstream os; @@ -4691,7 +4757,8 @@ TEST(NewSdpTestNoFixture, CheckImageattrSetSerialization) { os.str(""); } -TEST(NewSdpTestNoFixture, CheckImageattrSerialization) { +TEST(NewSdpTestNoFixture, CheckImageattrSerialization) +{ SdpImageattrAttributeList::Imageattr imageattr; std::ostringstream os; @@ -4751,7 +4818,8 @@ TEST(NewSdpTestNoFixture, CheckImageattrSerialization) { os.str(""); } -TEST(NewSdpTestNoFixture, CheckSimulcastVersionSerialize) { +TEST(NewSdpTestNoFixture, CheckSimulcastVersionSerialize) +{ std::ostringstream os; SdpSimulcastAttribute::Version version; @@ -4782,7 +4850,8 @@ static SdpSimulcastAttribute::Version ParseSimulcastVersion( return version; } -TEST(NewSdpTestNoFixture, CheckSimulcastVersionValidParse) { +TEST(NewSdpTestNoFixture, CheckSimulcastVersionValidParse) +{ { SdpSimulcastAttribute::Version version(ParseSimulcastVersion("1")); ASSERT_EQ(1U, version.choices.size()); @@ -4797,7 +4866,8 @@ TEST(NewSdpTestNoFixture, CheckSimulcastVersionValidParse) { } } -TEST(NewSdpTestNoFixture, CheckSimulcastVersionInvalidParse) { +TEST(NewSdpTestNoFixture, CheckSimulcastVersionInvalidParse) +{ ParseInvalid("", 0); ParseInvalid(",", 0); ParseInvalid(";", 0); @@ -4808,7 +4878,8 @@ TEST(NewSdpTestNoFixture, CheckSimulcastVersionInvalidParse) { ParseInvalid("8,;", 2); } -TEST(NewSdpTestNoFixture, CheckSimulcastVersionsSerialize) { +TEST(NewSdpTestNoFixture, CheckSimulcastVersionsSerialize) +{ std::ostringstream os; SdpSimulcastAttribute::Versions versions; @@ -4852,7 +4923,8 @@ static SdpSimulcastAttribute::Versions ParseSimulcastVersions( return list; } -TEST(NewSdpTestNoFixture, CheckSimulcastVersionsValidParse) { +TEST(NewSdpTestNoFixture, CheckSimulcastVersionsValidParse) +{ { SdpSimulcastAttribute::Versions versions(ParseSimulcastVersions("pt=8")); ASSERT_EQ(1U, versions.size()); @@ -4889,7 +4961,8 @@ TEST(NewSdpTestNoFixture, CheckSimulcastVersionsValidParse) { } } -TEST(NewSdpTestNoFixture, CheckSimulcastVersionsInvalidParse) { +TEST(NewSdpTestNoFixture, CheckSimulcastVersionsInvalidParse) +{ ParseInvalid("", 0); ParseInvalid("x", 1); ParseInvalid(";", 1); @@ -4904,7 +4977,8 @@ TEST(NewSdpTestNoFixture, CheckSimulcastVersionsInvalidParse) { ParseInvalid("pt=8;;", 5); } -TEST(NewSdpTestNoFixture, CheckSimulcastSerialize) { +TEST(NewSdpTestNoFixture, CheckSimulcastSerialize) +{ std::ostringstream os; SdpSimulcastAttribute simulcast; @@ -4931,7 +5005,8 @@ static SdpSimulcastAttribute ParseSimulcast(const std::string& input) { return simulcast; } -TEST(NewSdpTestNoFixture, CheckSimulcastValidParse) { +TEST(NewSdpTestNoFixture, CheckSimulcastValidParse) +{ { SdpSimulcastAttribute simulcast(ParseSimulcast(" send pt=8")); ASSERT_EQ(1U, simulcast.sendVersions.size()); @@ -4988,7 +5063,8 @@ TEST(NewSdpTestNoFixture, CheckSimulcastValidParse) { } } -TEST(NewSdpTestNoFixture, CheckSimulcastInvalidParse) { +TEST(NewSdpTestNoFixture, CheckSimulcastInvalidParse) +{ ParseInvalid("", 0); ParseInvalid(" ", 1); ParseInvalid("vcer ", 4); @@ -5007,7 +5083,8 @@ static SdpRidAttributeList::Rid ParseRid(const std::string& input) { return rid; } -TEST(NewSdpTestNoFixture, CheckRidValidParse) { +TEST(NewSdpTestNoFixture, CheckRidValidParse) +{ { SdpRidAttributeList::Rid rid(ParseRid("1 send")); ASSERT_EQ("1", rid.id); @@ -5292,7 +5369,8 @@ TEST(NewSdpTestNoFixture, CheckRidValidParse) { } } -TEST(NewSdpTestNoFixture, CheckRidInvalidParse) { +TEST(NewSdpTestNoFixture, CheckRidInvalidParse) +{ ParseInvalid("", 0); ParseInvalid(" ", 0); ParseInvalid("foo", 3); @@ -5319,7 +5397,8 @@ TEST(NewSdpTestNoFixture, CheckRidInvalidParse) { ParseInvalid("foo send depend=1,", 18); } -TEST(NewSdpTestNoFixture, CheckRidSerialize) { +TEST(NewSdpTestNoFixture, CheckRidSerialize) +{ { SdpRidAttributeList::Rid rid; rid.id = "foo"; diff --git a/media/webrtc/signaling/src/media-conduit/RtpSourceObserver.cpp b/media/webrtc/signaling/src/media-conduit/RtpSourceObserver.cpp index 840b0e0bd9688..c28b43a37446f 100644 --- a/media/webrtc/signaling/src/media-conduit/RtpSourceObserver.cpp +++ b/media/webrtc/signaling/src/media-conduit/RtpSourceObserver.cpp @@ -19,7 +19,6 @@ double RtpSourceObserver::RtpSourceEntry::ToLinearAudioLevel() const { RtpSourceObserver::RtpSourceObserver() : mMaxJitterWindow(0), mLevelGuard("RtpSourceObserver::mLevelGuard") {} - void RtpSourceObserver::OnRtpPacket(const webrtc::RTPHeader& aHeader, const int64_t aTimestamp, const uint32_t aJitter) { diff --git a/media/webrtc/signaling/src/media-conduit/WebrtcMediaDataDecoderCodec.cpp b/media/webrtc/signaling/src/media-conduit/WebrtcMediaDataDecoderCodec.cpp index aa157f8695c80..d6dd394b11555 100644 --- a/media/webrtc/signaling/src/media-conduit/WebrtcMediaDataDecoderCodec.cpp +++ b/media/webrtc/signaling/src/media-conduit/WebrtcMediaDataDecoderCodec.cpp @@ -64,9 +64,10 @@ int32_t WebrtcMediaDataDecoder::InitDecode( return WEBRTC_VIDEO_CODEC_ERROR; } - media::Await(do_AddRef(mThreadPool), mDecoder->Init(), - [&](TrackInfo::TrackType) { mError = NS_OK; }, - [&](const MediaResult& aError) { mError = aError; }); + media::Await( + do_AddRef(mThreadPool), mDecoder->Init(), + [&](TrackInfo::TrackType) { mError = NS_OK; }, + [&](const MediaResult& aError) { mError = aError; }); return NS_SUCCEEDED(mError) ? WEBRTC_VIDEO_CODEC_OK : WEBRTC_VIDEO_CODEC_ERROR; @@ -110,12 +111,13 @@ int32_t WebrtcMediaDataDecoder::Decode( compressedFrame->mKeyframe = aInputImage._frameType == webrtc::FrameType::kVideoFrameKey; { - media::Await(do_AddRef(mThreadPool), mDecoder->Decode(compressedFrame), - [&](const MediaDataDecoder::DecodedData& aResults) { - mResults = aResults; - mError = NS_OK; - }, - [&](const MediaResult& aError) { mError = aError; }); + media::Await( + do_AddRef(mThreadPool), mDecoder->Decode(compressedFrame), + [&](const MediaDataDecoder::DecodedData& aResults) { + mResults = aResults; + mError = NS_OK; + }, + [&](const MediaResult& aError) { mError = aError; }); for (auto& frame : mResults) { MOZ_ASSERT(frame->mType == MediaData::Type::VIDEO_DATA); diff --git a/media/webrtc/signaling/src/peerconnection/MediaTransportHandlerIPC.cpp b/media/webrtc/signaling/src/peerconnection/MediaTransportHandlerIPC.cpp index ab49a1f61c182..ae1ecd64e560a 100644 --- a/media/webrtc/signaling/src/peerconnection/MediaTransportHandlerIPC.cpp +++ b/media/webrtc/signaling/src/peerconnection/MediaTransportHandlerIPC.cpp @@ -291,17 +291,18 @@ MediaTransportHandlerIPC::GetIceStats( } RefPtr promise = mChild->SendGetIceStats(aTransportId, aNow, *aReport) - ->Then(GetMainThreadSerialEventTarget(), __func__, - [](const dom::MovableRTCStatsReportInternal& aReport) { - std::unique_ptr report( - new dom::RTCStatsReportInternal(aReport)); - return StatsPromise::CreateAndResolve( - std::move(report), __func__); - }, - [](ipc::ResponseRejectReason aReason) { - return StatsPromise::CreateAndReject(NS_ERROR_FAILURE, - __func__); - }); + ->Then( + GetMainThreadSerialEventTarget(), __func__, + [](const dom::MovableRTCStatsReportInternal& aReport) { + std::unique_ptr report( + new dom::RTCStatsReportInternal(aReport)); + return StatsPromise::CreateAndResolve(std::move(report), + __func__); + }, + [](ipc::ResponseRejectReason aReason) { + return StatsPromise::CreateAndReject(NS_ERROR_FAILURE, + __func__); + }); return promise; }, [](const nsCString& aError) { diff --git a/media/webrtc/signaling/src/peerconnection/PeerConnectionCtx.cpp b/media/webrtc/signaling/src/peerconnection/PeerConnectionCtx.cpp index 82ce828925e55..c25ce2c00fdc4 100644 --- a/media/webrtc/signaling/src/peerconnection/PeerConnectionCtx.cpp +++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionCtx.cpp @@ -280,13 +280,14 @@ void PeerConnectionCtx::EverySecondTelemetryCallback_m(nsITimer* timer, for (auto& idAndPc : GetInstance()->mPeerConnections) { if (idAndPc.second->HasMedia()) { idAndPc.second->GetStats(nullptr, true) - ->Then(GetMainThreadSerialEventTarget(), __func__, - [=](UniquePtr&& aQuery) { - if (PeerConnectionCtx::isActive()) { - PeerConnectionCtx::GetInstance()->DeliverStats(*aQuery); - } - }, - [=](nsresult aError) {}); + ->Then( + GetMainThreadSerialEventTarget(), __func__, + [=](UniquePtr&& aQuery) { + if (PeerConnectionCtx::isActive()) { + PeerConnectionCtx::GetInstance()->DeliverStats(*aQuery); + } + }, + [=](nsresult aError) {}); } } } diff --git a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp index 956e385b9222e..a1cac6149860a 100644 --- a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp +++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp @@ -1553,15 +1553,16 @@ PeerConnectionImpl::GetStats(MediaStreamTrack* aSelector) { PC_AUTO_ENTER_API_CALL(true); GetStats(aSelector, false) - ->Then(GetMainThreadSerialEventTarget(), __func__, - [handle = mHandle](UniquePtr&& aQuery) { - DeliverStatsReportToPCObserver_m( - handle, NS_OK, nsAutoPtr(aQuery.release())); - }, - [handle = mHandle](nsresult aError) { - DeliverStatsReportToPCObserver_m(handle, aError, - nsAutoPtr()); - }); + ->Then( + GetMainThreadSerialEventTarget(), __func__, + [handle = mHandle](UniquePtr&& aQuery) { + DeliverStatsReportToPCObserver_m( + handle, NS_OK, nsAutoPtr(aQuery.release())); + }, + [handle = mHandle](nsresult aError) { + DeliverStatsReportToPCObserver_m(handle, aError, + nsAutoPtr()); + }); return NS_OK; } diff --git a/media/webrtc/signaling/src/peerconnection/WebrtcGlobalInformation.cpp b/media/webrtc/signaling/src/peerconnection/WebrtcGlobalInformation.cpp index d10e6eacf7fec..71c8e634c011b 100644 --- a/media/webrtc/signaling/src/peerconnection/WebrtcGlobalInformation.cpp +++ b/media/webrtc/signaling/src/peerconnection/WebrtcGlobalInformation.cpp @@ -319,30 +319,32 @@ static void RunStatsQuery( if (pc.HasMedia()) { promises.AppendElement( pc.GetStats(nullptr, true) - ->Then(GetMainThreadSerialEventTarget(), __func__, - [=](UniquePtr&& aQuery) { - return RTCStatsQueryPromise::CreateAndResolve( - std::move(aQuery), __func__); - }, - [=](nsresult aError) { - // Ignore errors! Just resolve with a nullptr. - return RTCStatsQueryPromise::CreateAndResolve( - UniquePtr(), __func__); - })); + ->Then( + GetMainThreadSerialEventTarget(), __func__, + [=](UniquePtr&& aQuery) { + return RTCStatsQueryPromise::CreateAndResolve( + std::move(aQuery), __func__); + }, + [=](nsresult aError) { + // Ignore errors! Just resolve with a nullptr. + return RTCStatsQueryPromise::CreateAndResolve( + UniquePtr(), __func__); + })); } } } RTCStatsQueryPromise::All(GetMainThreadSerialEventTarget(), promises) - ->Then(GetMainThreadSerialEventTarget(), __func__, - // MOZ_CAN_RUN_SCRIPT_BOUNDARY because we're going to run that - // function async anyway. - [aThisChild, - aRequestId](nsTArray>&& aQueries) - MOZ_CAN_RUN_SCRIPT_BOUNDARY { - OnStatsReport_m(aThisChild, aRequestId, std::move(aQueries)); - }, - [=](nsresult) { MOZ_CRASH(); }); + ->Then( + GetMainThreadSerialEventTarget(), __func__, + // MOZ_CAN_RUN_SCRIPT_BOUNDARY because we're going to run that + // function async anyway. + [aThisChild, + aRequestId](nsTArray>&& aQueries) + MOZ_CAN_RUN_SCRIPT_BOUNDARY { + OnStatsReport_m(aThisChild, aRequestId, std::move(aQueries)); + }, + [=](nsresult) { MOZ_CRASH(); }); } void ClearClosedStats() { @@ -458,19 +460,20 @@ static nsresult RunLogQuery(const nsCString& aPattern, [transportHandler, aPattern]() { return transportHandler->GetIceLog(aPattern); }) - ->Then(GetMainThreadSerialEventTarget(), __func__, - // MOZ_CAN_RUN_SCRIPT_BOUNDARY because we're going to run that - // function async anyway. - [aRequestId, aThisChild](Sequence&& aLogLines) - MOZ_CAN_RUN_SCRIPT_BOUNDARY { - OnGetLogging_m(aThisChild, aRequestId, std::move(aLogLines)); - }, - // MOZ_CAN_RUN_SCRIPT_BOUNDARY because we're going to run that - // function async anyway. - [aRequestId, aThisChild](nsresult aError) - MOZ_CAN_RUN_SCRIPT_BOUNDARY { - OnGetLogging_m(aThisChild, aRequestId, Sequence()); - }); + ->Then( + GetMainThreadSerialEventTarget(), __func__, + // MOZ_CAN_RUN_SCRIPT_BOUNDARY because we're going to run that + // function async anyway. + [aRequestId, aThisChild](Sequence&& aLogLines) + MOZ_CAN_RUN_SCRIPT_BOUNDARY { + OnGetLogging_m(aThisChild, aRequestId, std::move(aLogLines)); + }, + // MOZ_CAN_RUN_SCRIPT_BOUNDARY because we're going to run that + // function async anyway. + [aRequestId, aThisChild](nsresult aError) + MOZ_CAN_RUN_SCRIPT_BOUNDARY { + OnGetLogging_m(aThisChild, aRequestId, Sequence()); + }); return NS_OK; } @@ -1048,13 +1051,14 @@ void WebrtcGlobalInformation::StoreLongTermICEStatistics( } aPc.GetStats(nullptr, true) - ->Then(GetMainThreadSerialEventTarget(), __func__, - [=](UniquePtr&& aQuery) { - StoreLongTermICEStatisticsImpl_m(NS_OK, aQuery.get()); - }, - [=](nsresult aError) { - StoreLongTermICEStatisticsImpl_m(aError, nullptr); - }); + ->Then( + GetMainThreadSerialEventTarget(), __func__, + [=](UniquePtr&& aQuery) { + StoreLongTermICEStatisticsImpl_m(NS_OK, aQuery.get()); + }, + [=](nsresult aError) { + StoreLongTermICEStatisticsImpl_m(aError, nullptr); + }); } } // namespace dom diff --git a/media/webrtc/signaling/src/sdp/SipccSdpAttributeList.cpp b/media/webrtc/signaling/src/sdp/SipccSdpAttributeList.cpp index cdaedc4798383..3f88f675d579d 100644 --- a/media/webrtc/signaling/src/sdp/SipccSdpAttributeList.cpp +++ b/media/webrtc/signaling/src/sdp/SipccSdpAttributeList.cpp @@ -715,7 +715,8 @@ void SipccSdpAttributeList::LoadFmtp(sdp_t* sdp, uint16_t level) { } parameters.reset(teParameters); } break; - default: {} + default: { + } } fmtps->PushEntry(osPayloadType.str(), std::move(parameters)); diff --git a/memory/gtest/TestJemalloc.cpp b/memory/gtest/TestJemalloc.cpp index 1c11ff888557f..7a6645bef9d1a 100644 --- a/memory/gtest/TestJemalloc.cpp +++ b/memory/gtest/TestJemalloc.cpp @@ -66,7 +66,8 @@ static inline void TestThree(size_t size) { ASSERT_NO_FATAL_FAILURE(TestOne(size + 1)); } -TEST(Jemalloc, UsableSizeInAdvance) { +TEST(Jemalloc, UsableSizeInAdvance) +{ /* * Test every size up to a certain point, then (N-1, N, N+1) triplets for a * various sizes beyond that. @@ -97,7 +98,8 @@ bool InfoEqFreedPage(jemalloc_ptr_info_t& aInfo, void* aAddr, aInfo.size == aPageSize; } -TEST(Jemalloc, PtrInfo) { +TEST(Jemalloc, PtrInfo) +{ // Some things might be running in other threads, so ensure our assumptions // (e.g. about isFreedSmall and isFreedPage ratios below) are not altered by // other threads. @@ -253,7 +255,8 @@ TEST(Jemalloc, PtrInfo) { size_t sSizes[] = {1, 42, 79, 918, 1.5_KiB, 73_KiB, 129_KiB, 1.1_MiB, 2.6_MiB, 5.1_MiB}; -TEST(Jemalloc, Arenas) { +TEST(Jemalloc, Arenas) +{ arena_id_t arena = moz_create_arena(); ASSERT_TRUE(arena != 0); void* ptr = moz_arena_malloc(arena, 42); @@ -385,7 +388,8 @@ static bool CanReallocInPlace(size_t aFromSize, size_t aToSize, return false; } -TEST(Jemalloc, InPlace) { +TEST(Jemalloc, InPlace) +{ jemalloc_stats_t stats; jemalloc_stats(&stats); @@ -417,7 +421,8 @@ TEST(Jemalloc, InPlace) { // Bug 1474254: disable this test for windows ccov builds because it leads to // timeout. #if !defined(XP_WIN) || !defined(MOZ_CODE_COVERAGE) -TEST(Jemalloc, JunkPoison) { +TEST(Jemalloc, JunkPoison) +{ jemalloc_stats_t stats; jemalloc_stats(&stats); diff --git a/memory/volatile/tests/TestVolatileBuffer.cpp b/memory/volatile/tests/TestVolatileBuffer.cpp index 78296c467cc8e..e9e9699ec6a4c 100644 --- a/memory/volatile/tests/TestVolatileBuffer.cpp +++ b/memory/volatile/tests/TestVolatileBuffer.cpp @@ -18,11 +18,14 @@ using namespace mozilla; -TEST(VolatileBufferTest, HeapVolatileBuffersWork) { +TEST(VolatileBufferTest, HeapVolatileBuffersWork) +{ RefPtr heapbuf = new VolatileBuffer(); - ASSERT_TRUE(heapbuf) << "Failed to create VolatileBuffer"; - ASSERT_TRUE(heapbuf->Init(512)) << "Failed to initialize VolatileBuffer"; + ASSERT_TRUE(heapbuf) + << "Failed to create VolatileBuffer"; + ASSERT_TRUE(heapbuf->Init(512)) + << "Failed to initialize VolatileBuffer"; VolatileBufferPtr ptr(heapbuf); @@ -31,11 +34,14 @@ TEST(VolatileBufferTest, HeapVolatileBuffersWork) { EXPECT_TRUE(ptr) << "Couldn't get pointer from VolatileBufferPtr"; } -TEST(VolatileBufferTest, RealVolatileBuffersWork) { +TEST(VolatileBufferTest, RealVolatileBuffersWork) +{ RefPtr buf = new VolatileBuffer(); - ASSERT_TRUE(buf) << "Failed to create VolatileBuffer"; - ASSERT_TRUE(buf->Init(16384)) << "Failed to initialize VolatileBuffer"; + ASSERT_TRUE(buf) + << "Failed to create VolatileBuffer"; + ASSERT_TRUE(buf->Init(16384)) + << "Failed to initialize VolatileBuffer"; const char teststr[] = "foobar"; @@ -51,7 +57,8 @@ TEST(VolatileBufferTest, RealVolatileBuffersWork) { EXPECT_FALSE(ptr.WasBufferPurged()) << "Failed to lock buffer again while currently locked"; - ASSERT_TRUE(ptr2) << "Didn't get a pointer on the second lock"; + ASSERT_TRUE(ptr2) + << "Didn't get a pointer on the second lock"; strcpy(ptr2, teststr); } diff --git a/mfbt/Variant.h b/mfbt/Variant.h index 83609dca20630..ee40f64c64a32 100644 --- a/mfbt/Variant.h +++ b/mfbt/Variant.h @@ -730,7 +730,8 @@ class MOZ_INHERIT_TYPE_ANNOTATIONS_FROM_TEMPLATE_ARGS MOZ_NON_PARAM Variant { tl::And::ReturnType, typename FunctionTypeTraits::ReturnType>::value, IsSame::ReturnType, - typename FunctionTypeTraits::ReturnType>::value...>::value, + typename FunctionTypeTraits::ReturnType>::value...>:: + value, "all matchers must have the same return type"); return Impl::matchN(*this, std::forward(aM0), std::forward(aM1), std::forward(aMs)...); @@ -752,7 +753,8 @@ class MOZ_INHERIT_TYPE_ANNOTATIONS_FROM_TEMPLATE_ARGS MOZ_NON_PARAM Variant { tl::And::ReturnType, typename FunctionTypeTraits::ReturnType>::value, IsSame::ReturnType, - typename FunctionTypeTraits::ReturnType>::value...>::value, + typename FunctionTypeTraits::ReturnType>::value...>:: + value, "all matchers must have the same return type"); return Impl::matchN(*this, std::forward(aM0), std::forward(aM1), std::forward(aMs)...); diff --git a/mfbt/tests/gtest/TestBuffer.cpp b/mfbt/tests/gtest/TestBuffer.cpp index 6dfe5cf8477df..df36282be1f55 100644 --- a/mfbt/tests/gtest/TestBuffer.cpp +++ b/mfbt/tests/gtest/TestBuffer.cpp @@ -9,7 +9,8 @@ using namespace mozilla; -TEST(Buffer, TestBufferInfallible) { +TEST(Buffer, TestBufferInfallible) +{ const size_t LEN = 8; Array arr = {1, 2, 3, 4, 5, 6, 7, 8}; Buffer buf(arr); @@ -47,7 +48,8 @@ TEST(Buffer, TestBufferInfallible) { ASSERT_EQ(buf.Length(), 0U); } -TEST(Buffer, TestBufferFallible) { +TEST(Buffer, TestBufferFallible) +{ const size_t LEN = 8; Array arr = {1, 2, 3, 4, 5, 6, 7, 8}; auto maybe = Buffer::CopyFrom(arr); @@ -87,7 +89,8 @@ TEST(Buffer, TestBufferFallible) { ASSERT_EQ(buf.Length(), 0U); } -TEST(Buffer, TestBufferElements) { +TEST(Buffer, TestBufferElements) +{ ASSERT_EQ(Buffer().Elements(), reinterpret_cast(alignof(int32_t))); } diff --git a/mfbt/tests/gtest/TestLinkedList.cpp b/mfbt/tests/gtest/TestLinkedList.cpp index bd8465dba5e2c..d53cba592009f 100644 --- a/mfbt/tests/gtest/TestLinkedList.cpp +++ b/mfbt/tests/gtest/TestLinkedList.cpp @@ -34,7 +34,8 @@ class InheritedPtrClass : public PtrClass { virtual ~InheritedPtrClass() { *mInheritedResult = true; } }; -TEST(LinkedList, AutoCleanLinkedList) { +TEST(LinkedList, AutoCleanLinkedList) +{ bool rv1 = false; bool rv2 = false; bool rv3 = false; @@ -59,7 +60,8 @@ class CountedClass final : public LinkedListElement> { ~CountedClass() { EXPECT_TRUE(mCount == 0); } }; -TEST(LinkedList, AutoCleanLinkedListRefPtr) { +TEST(LinkedList, AutoCleanLinkedListRefPtr) +{ RefPtr elt1 = new CountedClass; CountedClass* elt2 = new CountedClass; { diff --git a/mfbt/tests/gtest/TestMozDbg.cpp b/mfbt/tests/gtest/TestMozDbg.cpp index ddfcbbf74f867..0eb0571c99fba 100644 --- a/mfbt/tests/gtest/TestMozDbg.cpp +++ b/mfbt/tests/gtest/TestMozDbg.cpp @@ -102,7 +102,8 @@ void StaticAssertions() { Unused << z; } -TEST(MozDbg, ObjectValues) { +TEST(MozDbg, ObjectValues) +{ // Test that moves and assignments all operate correctly with MOZ_DBG wrapped // around various parts of the expression. diff --git a/modules/libpref/SharedPrefMap.cpp b/modules/libpref/SharedPrefMap.cpp index 11c771f52ece2..25c68071641dc 100644 --- a/modules/libpref/SharedPrefMap.cpp +++ b/modules/libpref/SharedPrefMap.cpp @@ -62,11 +62,12 @@ Maybe SharedPrefMap::Get(const char* aKey) const { bool SharedPrefMap::Find(const char* aKey, size_t* aIndex) const { const auto& keys = KeyTable(); - return BinarySearchIf(Entries(), 0, EntryCount(), - [&](const Entry& aEntry) { - return strcmp(aKey, keys.GetBare(aEntry.mKey)); - }, - aIndex); + return BinarySearchIf( + Entries(), 0, EntryCount(), + [&](const Entry& aEntry) { + return strcmp(aKey, keys.GetBare(aEntry.mKey)); + }, + aIndex); } void SharedPrefMapBuilder::Add(const char* aKey, const Flags& aFlags, diff --git a/modules/libpref/test/gtest/Basics.cpp b/modules/libpref/test/gtest/Basics.cpp index e581d58fa193a..e3e05c6015b09 100644 --- a/modules/libpref/test/gtest/Basics.cpp +++ b/modules/libpref/test/gtest/Basics.cpp @@ -9,7 +9,8 @@ using namespace mozilla; -TEST(PrefsBasics, Errors) { +TEST(PrefsBasics, Errors) +{ Preferences::SetBool("foo.bool", true, PrefValueKind::Default); Preferences::SetBool("foo.bool", false, PrefValueKind::User); ASSERT_EQ(Preferences::GetBool("foo.bool", false, PrefValueKind::Default), diff --git a/modules/libpref/test/gtest/CallbackAndVarCacheOrder.cpp b/modules/libpref/test/gtest/CallbackAndVarCacheOrder.cpp index 39afc8bbea226..2168136fac232 100644 --- a/modules/libpref/test/gtest/CallbackAndVarCacheOrder.cpp +++ b/modules/libpref/test/gtest/CallbackAndVarCacheOrder.cpp @@ -137,52 +137,61 @@ void RunTest(const nsCString& aPrefName1, const nsCString& aPrefName2, ASSERT_TRUE(closure2.mCalled); } -TEST(CallbackAndVarCacheOrder, Bool) { +TEST(CallbackAndVarCacheOrder, Bool) +{ RunTest(NS_LITERAL_CSTRING("test_pref.bool.1"), NS_LITERAL_CSTRING("test_pref.bool.2"), false, true); } -TEST(CallbackAndVarCacheOrder, AtomicBoolRelaxed) { +TEST(CallbackAndVarCacheOrder, AtomicBoolRelaxed) +{ RunTest>( NS_LITERAL_CSTRING("test_pref.atomic_bool.1"), NS_LITERAL_CSTRING("test_pref.atomic_bool.2"), false, true); } -TEST(CallbackAndVarCacheOrder, AtomicBoolReleaseAcquire) { +TEST(CallbackAndVarCacheOrder, AtomicBoolReleaseAcquire) +{ RunTest>( NS_LITERAL_CSTRING("test_pref.atomic_bool.3"), NS_LITERAL_CSTRING("test_pref.atomic_bool.4"), false, true); } -TEST(CallbackAndVarCacheOrder, Int) { +TEST(CallbackAndVarCacheOrder, Int) +{ RunTest(NS_LITERAL_CSTRING("test_pref.int.1"), NS_LITERAL_CSTRING("test_pref.int.2"), -2, 3); } -TEST(CallbackAndVarCacheOrder, AtomicInt) { +TEST(CallbackAndVarCacheOrder, AtomicInt) +{ RunTest>( NS_LITERAL_CSTRING("test_pref.atomic_int.1"), NS_LITERAL_CSTRING("test_pref.atomic_int.2"), -3, 4); } -TEST(CallbackAndVarCacheOrder, Uint) { +TEST(CallbackAndVarCacheOrder, Uint) +{ RunTest(NS_LITERAL_CSTRING("test_pref.uint.1"), NS_LITERAL_CSTRING("test_pref.uint.2"), 4u, 5u); } -TEST(CallbackAndVarCacheOrder, AtomicUintRelaxed) { +TEST(CallbackAndVarCacheOrder, AtomicUintRelaxed) +{ RunTest>( NS_LITERAL_CSTRING("test_pref.atomic_uint.1"), NS_LITERAL_CSTRING("test_pref.atomic_uint.2"), 6u, 7u); } -TEST(CallbackAndVarCacheOrder, AtomicUintReleaseAcquire) { +TEST(CallbackAndVarCacheOrder, AtomicUintReleaseAcquire) +{ RunTest>( NS_LITERAL_CSTRING("test_pref.atomic_uint.3"), NS_LITERAL_CSTRING("test_pref.atomic_uint.4"), 8u, 9u); } -TEST(CallbackAndVarCacheOrder, Float) { +TEST(CallbackAndVarCacheOrder, Float) +{ RunTest(NS_LITERAL_CSTRING("test_pref.float.1"), NS_LITERAL_CSTRING("test_pref.float.2"), -10.0f, 11.0f); } diff --git a/modules/libpref/test/gtest/Parser.cpp b/modules/libpref/test/gtest/Parser.cpp index 0964ddfe9022d..1738c2b3ae8c2 100644 --- a/modules/libpref/test/gtest/Parser.cpp +++ b/modules/libpref/test/gtest/Parser.cpp @@ -16,7 +16,8 @@ using namespace mozilla; void TestParseError(PrefValueKind aKind, const char* aText, nsCString& aErrorMsg); -TEST(PrefsParser, Errors) { +TEST(PrefsParser, Errors) +{ nsAutoCStringN<128> actualErrorMsg; // Use a macro rather than a function so that the line number reported by diff --git a/mozglue/tests/gtest/TestDLLBlocklist.cpp b/mozglue/tests/gtest/TestDLLBlocklist.cpp index e10d1adbdb206..3cd09f137b8d6 100644 --- a/mozglue/tests/gtest/TestDLLBlocklist.cpp +++ b/mozglue/tests/gtest/TestDLLBlocklist.cpp @@ -53,7 +53,8 @@ static nsString GetFullPath(const char16_t* leaf) { return ret; } -TEST(TestDllBlocklist, BlockDllByName) { +TEST(TestDllBlocklist, BlockDllByName) +{ sDllWasBlocked = false; sDllWasLoaded = false; DllBlocklist_SetDllLoadHook(DllLoadHook); @@ -78,7 +79,8 @@ TEST(TestDllBlocklist, BlockDllByName) { } } -TEST(TestDllBlocklist, BlockDllByVersion) { +TEST(TestDllBlocklist, BlockDllByVersion) +{ sDllWasBlocked = false; sDllWasLoaded = false; DllBlocklist_SetDllLoadHook(DllLoadHook); @@ -101,7 +103,8 @@ TEST(TestDllBlocklist, BlockDllByVersion) { } } -TEST(TestDllBlocklist, AllowDllByVersion) { +TEST(TestDllBlocklist, AllowDllByVersion) +{ sDllWasBlocked = false; sDllWasLoaded = false; DllBlocklist_SetDllLoadHook(DllLoadHook); @@ -124,7 +127,8 @@ TEST(TestDllBlocklist, AllowDllByVersion) { } } -TEST(TestDllBlocklist, BlocklistIntegrity) { +TEST(TestDllBlocklist, BlocklistIntegrity) +{ auto msg = DllBlocklist_TestBlocklistIntegrity(); EXPECT_FALSE(msg) << msg; } diff --git a/mozglue/tests/gtest/TestDLLEject.cpp b/mozglue/tests/gtest/TestDLLEject.cpp index d94ba7a17482a..e7dccfd1d8a61 100644 --- a/mozglue/tests/gtest/TestDLLEject.cpp +++ b/mozglue/tests/gtest/TestDLLEject.cpp @@ -215,7 +215,8 @@ static void DoTest_CreateRemoteThread_LoadLibrary(TgetArgsProc aGetArgsProc) { return; } -TEST(TestInjectEject, CreateRemoteThread_LoadLibraryA) { +TEST(TestInjectEject, CreateRemoteThread_LoadLibraryA) +{ DoTest_CreateRemoteThread_LoadLibrary( [](const nsString& dllPath, const nsCString& dllPathC, uintptr_t& aStartAddress, uintptr_t& aThreadParam) { @@ -225,7 +226,8 @@ TEST(TestInjectEject, CreateRemoteThread_LoadLibraryA) { }); } -TEST(TestInjectEject, CreateRemoteThread_LoadLibraryW) { +TEST(TestInjectEject, CreateRemoteThread_LoadLibraryW) +{ DoTest_CreateRemoteThread_LoadLibrary( [](const nsString& dllPath, const nsCString& dllPathC, uintptr_t& aStartAddress, uintptr_t& aThreadParam) { @@ -235,7 +237,8 @@ TEST(TestInjectEject, CreateRemoteThread_LoadLibraryW) { }); } -TEST(TestInjectEject, CreateRemoteThread_LoadLibraryExW) { +TEST(TestInjectEject, CreateRemoteThread_LoadLibraryExW) +{ DoTest_CreateRemoteThread_LoadLibrary( [](const nsString& dllPath, const nsCString& dllPathC, uintptr_t& aStartAddress, uintptr_t& aThreadParam) { @@ -248,7 +251,8 @@ TEST(TestInjectEject, CreateRemoteThread_LoadLibraryExW) { }); } -TEST(TestInjectEject, CreateRemoteThread_LoadLibraryExA) { +TEST(TestInjectEject, CreateRemoteThread_LoadLibraryExA) +{ DoTest_CreateRemoteThread_LoadLibrary( [](const nsString& dllPath, const nsCString& dllPathC, uintptr_t& aStartAddress, uintptr_t& aThreadParam) { diff --git a/netwerk/base/ProxyAutoConfig.cpp b/netwerk/base/ProxyAutoConfig.cpp index 719497ecd0d21..e9badbf8613ae 100644 --- a/netwerk/base/ProxyAutoConfig.cpp +++ b/netwerk/base/ProxyAutoConfig.cpp @@ -636,9 +636,9 @@ class JSContextWrapper { } }; -const JSClass JSContextWrapper::sGlobalClass = { - "PACResolutionThreadGlobal", JSCLASS_GLOBAL_FLAGS, - &JS::DefaultGlobalClassOps}; +const JSClass JSContextWrapper::sGlobalClass = {"PACResolutionThreadGlobal", + JSCLASS_GLOBAL_FLAGS, + &JS::DefaultGlobalClassOps}; void ProxyAutoConfig::SetThreadLocalIndex(uint32_t index) { sRunningIndex = index; diff --git a/netwerk/base/nsBaseChannel.cpp b/netwerk/base/nsBaseChannel.cpp index 2614461516f95..1a47c0e5d9156 100644 --- a/netwerk/base/nsBaseChannel.cpp +++ b/netwerk/base/nsBaseChannel.cpp @@ -274,18 +274,19 @@ nsresult nsBaseChannel::BeginPumpingData() { nsCOMPtr serialTarget(do_QueryInterface(target)); MOZ_ASSERT(serialTarget); - promise->Then(serialTarget, __func__, - [self, this](nsresult rv) { - MOZ_ASSERT(mPump); - MOZ_ASSERT(NS_SUCCEEDED(rv)); - mPump->Resume(); - }, - [self, this](nsresult rv) { - MOZ_ASSERT(mPump); - MOZ_ASSERT(NS_FAILED(rv)); - Cancel(rv); - mPump->Resume(); - }); + promise->Then( + serialTarget, __func__, + [self, this](nsresult rv) { + MOZ_ASSERT(mPump); + MOZ_ASSERT(NS_SUCCEEDED(rv)); + mPump->Resume(); + }, + [self, this](nsresult rv) { + MOZ_ASSERT(mPump); + MOZ_ASSERT(NS_FAILED(rv)); + Cancel(rv); + mPump->Resume(); + }); } return NS_OK; diff --git a/netwerk/protocol/http/HttpChannelParent.cpp b/netwerk/protocol/http/HttpChannelParent.cpp index 26325f2613202..fefcc5dd591ca 100644 --- a/netwerk/protocol/http/HttpChannelParent.cpp +++ b/netwerk/protocol/http/HttpChannelParent.cpp @@ -659,15 +659,16 @@ bool HttpChannelParent::DoAsyncOpen( ++mAsyncOpenBarrier; RefPtr self = this; WaitForBgParent() - ->Then(GetMainThreadSerialEventTarget(), __func__, - [self]() { - self->mRequest.Complete(); - self->TryInvokeAsyncOpen(NS_OK); - }, - [self](nsresult aStatus) { - self->mRequest.Complete(); - self->TryInvokeAsyncOpen(aStatus); - }) + ->Then( + GetMainThreadSerialEventTarget(), __func__, + [self]() { + self->mRequest.Complete(); + self->TryInvokeAsyncOpen(NS_OK); + }, + [self](nsresult aStatus) { + self->mRequest.Complete(); + self->TryInvokeAsyncOpen(aStatus); + }) ->Track(mRequest); // The stream, received from the child process, must be cloneable and seekable @@ -751,12 +752,13 @@ bool HttpChannelParent::ConnectChannel(const uint32_t& registrarId, // Waiting for background channel RefPtr self = this; WaitForBgParent() - ->Then(GetMainThreadSerialEventTarget(), __func__, - [self]() { self->mRequest.Complete(); }, - [self](const nsresult& aResult) { - NS_ERROR("failed to establish the background channel"); - self->mRequest.Complete(); - }) + ->Then( + GetMainThreadSerialEventTarget(), __func__, + [self]() { self->mRequest.Complete(); }, + [self](const nsresult& aResult) { + NS_ERROR("failed to establish the background channel"); + self->mRequest.Complete(); + }) ->Track(mRequest); return true; } diff --git a/netwerk/test/TestBind.cpp b/netwerk/test/TestBind.cpp index e141750ea0381..8bfaa8b2df7a5 100644 --- a/netwerk/test/TestBind.cpp +++ b/netwerk/test/TestBind.cpp @@ -95,7 +95,8 @@ ClientInputCallback::OnInputStreamReady(nsIAsyncInputStream* aStream) { return NS_OK; } -TEST(TestBind, MainTest) { +TEST(TestBind, MainTest) +{ // // Server side. // diff --git a/netwerk/test/TestCookie.cpp b/netwerk/test/TestCookie.cpp index 232c0714bded1..4fed959645c2b 100644 --- a/netwerk/test/TestCookie.cpp +++ b/netwerk/test/TestCookie.cpp @@ -189,7 +189,8 @@ void InitPrefs(nsIPrefBranch *aPrefBranch) { aPrefBranch->SetIntPref(kCookiesMaxPerHost, 50); } -TEST(TestCookie, TestCookieMain) { +TEST(TestCookie, TestCookieMain) +{ nsresult rv0; nsCOMPtr cookieService = diff --git a/netwerk/test/TestNamedPipeService.cpp b/netwerk/test/TestNamedPipeService.cpp index 5855a385343f5..bd08305007ace 100644 --- a/netwerk/test/TestNamedPipeService.cpp +++ b/netwerk/test/TestNamedPipeService.cpp @@ -251,7 +251,8 @@ static nsresult CreateNamedPipe(LPHANDLE aServer, LPHANDLE aClient) { return NS_OK; } -TEST(TestNamedPipeService, Test) { +TEST(TestNamedPipeService, Test) +{ nsCOMPtr svc = net::NamedPipeService::GetOrCreate(); HANDLE readPipe, writePipe; diff --git a/netwerk/test/TestUDPSocket.cpp b/netwerk/test/TestUDPSocket.cpp index 3bf7df4ef7737..c37a1aaa5b140 100644 --- a/netwerk/test/TestUDPSocket.cpp +++ b/netwerk/test/TestUDPSocket.cpp @@ -228,7 +228,8 @@ MulticastTimerCallback::Notify(nsITimer* timer) { /**** Main ****/ -TEST(TestUDPSocket, TestUDPSocketMain) { +TEST(TestUDPSocket, TestUDPSocketMain) +{ nsresult rv; // Create UDPSocket diff --git a/netwerk/test/gtest/TestBufferedInputStream.cpp b/netwerk/test/gtest/TestBufferedInputStream.cpp index 671da135135d6..e32334b155480 100644 --- a/netwerk/test/gtest/TestBufferedInputStream.cpp +++ b/netwerk/test/gtest/TestBufferedInputStream.cpp @@ -21,7 +21,8 @@ already_AddRefed CreateStream(uint32_t aSize, } // Simple reading. -TEST(TestBufferedInputStream, SimpleRead) { +TEST(TestBufferedInputStream, SimpleRead) +{ const size_t kBufSize = 10; nsCString buf; @@ -39,7 +40,8 @@ TEST(TestBufferedInputStream, SimpleRead) { } // Simple segment reading. -TEST(TestBufferedInputStream, SimpleReadSegments) { +TEST(TestBufferedInputStream, SimpleReadSegments) +{ const size_t kBufSize = 10; nsCString buf; @@ -54,7 +56,8 @@ TEST(TestBufferedInputStream, SimpleReadSegments) { } // AsyncWait - sync -TEST(TestBufferedInputStream, AsyncWait_sync) { +TEST(TestBufferedInputStream, AsyncWait_sync) +{ const size_t kBufSize = 10; nsCString buf; @@ -69,7 +72,8 @@ TEST(TestBufferedInputStream, AsyncWait_sync) { } // AsyncWait - async -TEST(TestBufferedInputStream, AsyncWait_async) { +TEST(TestBufferedInputStream, AsyncWait_async) +{ const size_t kBufSize = 10; nsCString buf; @@ -88,7 +92,8 @@ TEST(TestBufferedInputStream, AsyncWait_async) { } // AsyncWait - sync - closureOnly -TEST(TestBufferedInputStream, AsyncWait_sync_closureOnly) { +TEST(TestBufferedInputStream, AsyncWait_sync_closureOnly) +{ const size_t kBufSize = 10; nsCString buf; @@ -107,7 +112,8 @@ TEST(TestBufferedInputStream, AsyncWait_sync_closureOnly) { } // AsyncWait - async -TEST(TestBufferedInputStream, AsyncWait_async_closureOnly) { +TEST(TestBufferedInputStream, AsyncWait_async_closureOnly) +{ const size_t kBufSize = 10; nsCString buf; diff --git a/netwerk/test/gtest/TestHeaders.cpp b/netwerk/test/gtest/TestHeaders.cpp index 810061eac159c..52af2b4864fd2 100644 --- a/netwerk/test/gtest/TestHeaders.cpp +++ b/netwerk/test/gtest/TestHeaders.cpp @@ -2,7 +2,8 @@ #include "nsHttpHeaderArray.h" -TEST(TestHeaders, DuplicateHSTS) { +TEST(TestHeaders, DuplicateHSTS) +{ // When the Strict-Transport-Security header is sent multiple times, its // effective value is the value of the first item. It is not merged as other // headers are. diff --git a/netwerk/test/gtest/TestHttpAuthUtils.cpp b/netwerk/test/gtest/TestHttpAuthUtils.cpp index 8d72f318e4760..78fb40d4d00b9 100644 --- a/netwerk/test/gtest/TestHttpAuthUtils.cpp +++ b/netwerk/test/gtest/TestHttpAuthUtils.cpp @@ -9,7 +9,8 @@ namespace net { #define TEST_PREF "network.http_test.auth_utils" -TEST(TestHttpAuthUtils, Bug1351301) { +TEST(TestHttpAuthUtils, Bug1351301) +{ nsCOMPtr url; nsAutoCString spec; diff --git a/netwerk/test/gtest/TestIsValidIp.cpp b/netwerk/test/gtest/TestIsValidIp.cpp index ffdc8dffdfcaa..24e7d38eade31 100644 --- a/netwerk/test/gtest/TestIsValidIp.cpp +++ b/netwerk/test/gtest/TestIsValidIp.cpp @@ -3,22 +3,26 @@ #include "nsURLHelper.h" -TEST(TestIsValidIp, IPV4Localhost) { +TEST(TestIsValidIp, IPV4Localhost) +{ NS_NAMED_LITERAL_CSTRING(ip, "127.0.0.1"); ASSERT_EQ(true, net_IsValidIPv4Addr(ip)); } -TEST(TestIsValidIp, IPV4Only0) { +TEST(TestIsValidIp, IPV4Only0) +{ NS_NAMED_LITERAL_CSTRING(ip, "0.0.0.0"); ASSERT_EQ(true, net_IsValidIPv4Addr(ip)); } -TEST(TestIsValidIp, IPV4Max) { +TEST(TestIsValidIp, IPV4Max) +{ NS_NAMED_LITERAL_CSTRING(ip, "255.255.255.255"); ASSERT_EQ(true, net_IsValidIPv4Addr(ip)); } -TEST(TestIsValidIp, IPV4LeadingZero) { +TEST(TestIsValidIp, IPV4LeadingZero) +{ NS_NAMED_LITERAL_CSTRING(ip, "055.225.255.255"); ASSERT_EQ(false, net_IsValidIPv4Addr(ip)); @@ -32,17 +36,20 @@ TEST(TestIsValidIp, IPV4LeadingZero) { ASSERT_EQ(false, net_IsValidIPv4Addr(ip4)); } -TEST(TestIsValidIp, IPV4StartWithADot) { +TEST(TestIsValidIp, IPV4StartWithADot) +{ NS_NAMED_LITERAL_CSTRING(ip, ".192.168.120.197"); ASSERT_EQ(false, net_IsValidIPv4Addr(ip)); } -TEST(TestIsValidIp, IPV4StartWith4Digits) { +TEST(TestIsValidIp, IPV4StartWith4Digits) +{ NS_NAMED_LITERAL_CSTRING(ip, "1927.168.120.197"); ASSERT_EQ(false, net_IsValidIPv4Addr(ip)); } -TEST(TestIsValidIp, IPV4OutOfRange) { +TEST(TestIsValidIp, IPV4OutOfRange) +{ NS_NAMED_LITERAL_CSTRING(invalid1, "421.168.120.124"); NS_NAMED_LITERAL_CSTRING(invalid2, "192.997.120.124"); NS_NAMED_LITERAL_CSTRING(invalid3, "192.168.300.124"); @@ -54,7 +61,8 @@ TEST(TestIsValidIp, IPV4OutOfRange) { ASSERT_EQ(false, net_IsValidIPv4Addr(invalid4)); } -TEST(TestIsValidIp, IPV4EmptyDigits) { +TEST(TestIsValidIp, IPV4EmptyDigits) +{ NS_NAMED_LITERAL_CSTRING(invalid1, "..0.0.0"); NS_NAMED_LITERAL_CSTRING(invalid2, "127..0.0"); NS_NAMED_LITERAL_CSTRING(invalid3, "127.0..0"); @@ -66,7 +74,8 @@ TEST(TestIsValidIp, IPV4EmptyDigits) { ASSERT_EQ(false, net_IsValidIPv4Addr(invalid4)); } -TEST(TestIsValidIp, IPV4NonNumeric) { +TEST(TestIsValidIp, IPV4NonNumeric) +{ NS_NAMED_LITERAL_CSTRING(invalid1, "127.0.0.f"); NS_NAMED_LITERAL_CSTRING(invalid2, "127.0.0.!"); NS_NAMED_LITERAL_CSTRING(invalid3, "127#0.0.1"); @@ -76,17 +85,20 @@ TEST(TestIsValidIp, IPV4NonNumeric) { ASSERT_EQ(false, net_IsValidIPv4Addr(invalid3)); } -TEST(TestIsValidIp, IPV4TooManyDigits) { +TEST(TestIsValidIp, IPV4TooManyDigits) +{ NS_NAMED_LITERAL_CSTRING(ip, "127.0.0.1.2"); ASSERT_EQ(false, net_IsValidIPv4Addr(ip)); } -TEST(TestIsValidIp, IPV4TooFewDigits) { +TEST(TestIsValidIp, IPV4TooFewDigits) +{ NS_NAMED_LITERAL_CSTRING(ip, "127.0.1"); ASSERT_EQ(false, net_IsValidIPv4Addr(ip)); } -TEST(TestIsValidIp, IPV6WithIPV4Inside) { +TEST(TestIsValidIp, IPV6WithIPV4Inside) +{ const char ipv6[] = "0123:4567:89ab:cdef:0123:4567:127.0.0.1"; ASSERT_EQ(true, net_IsValidIPv6Addr(ipv6, 39)); } diff --git a/netwerk/test/gtest/TestMIMEInputStream.cpp b/netwerk/test/gtest/TestMIMEInputStream.cpp index 6cae4f746bb52..d57646bb5b00c 100644 --- a/netwerk/test/gtest/TestMIMEInputStream.cpp +++ b/netwerk/test/gtest/TestMIMEInputStream.cpp @@ -56,7 +56,8 @@ NS_IMPL_ISUPPORTS_INHERITED(SeekableLengthInputStream, // nsIInputStreamLength && nsIAsyncInputStreamLength -TEST(TestNsMIMEInputStream, QIInputStreamLength) { +TEST(TestNsMIMEInputStream, QIInputStreamLength) +{ nsCString buf; buf.AssignLiteral("Hello world"); @@ -90,7 +91,8 @@ TEST(TestNsMIMEInputStream, QIInputStreamLength) { } } -TEST(TestNsMIMEInputStream, InputStreamLength) { +TEST(TestNsMIMEInputStream, InputStreamLength) +{ nsCString buf; buf.AssignLiteral("Hello world"); @@ -120,7 +122,8 @@ TEST(TestNsMIMEInputStream, InputStreamLength) { ASSERT_EQ(buf.Length(), size); } -TEST(TestNsMIMEInputStream, NegativeInputStreamLength) { +TEST(TestNsMIMEInputStream, NegativeInputStreamLength) +{ nsCString buf; buf.AssignLiteral("Hello world"); @@ -150,7 +153,8 @@ TEST(TestNsMIMEInputStream, NegativeInputStreamLength) { ASSERT_EQ(-1, size); } -TEST(TestNsMIMEInputStream, AsyncInputStreamLength) { +TEST(TestNsMIMEInputStream, AsyncInputStreamLength) +{ nsCString buf; buf.AssignLiteral("Hello world"); @@ -184,7 +188,8 @@ TEST(TestNsMIMEInputStream, AsyncInputStreamLength) { ASSERT_EQ(buf.Length(), callback->Size()); } -TEST(TestNsMIMEInputStream, NegativeAsyncInputStreamLength) { +TEST(TestNsMIMEInputStream, NegativeAsyncInputStreamLength) +{ nsCString buf; buf.AssignLiteral("Hello world"); @@ -218,7 +223,8 @@ TEST(TestNsMIMEInputStream, NegativeAsyncInputStreamLength) { ASSERT_EQ(-1, callback->Size()); } -TEST(TestNsMIMEInputStream, AbortLengthCallback) { +TEST(TestNsMIMEInputStream, AbortLengthCallback) +{ nsCString buf; buf.AssignLiteral("Hello world"); diff --git a/netwerk/test/gtest/TestMozURL.cpp b/netwerk/test/gtest/TestMozURL.cpp index 56f969eb1717c..225667342a95c 100644 --- a/netwerk/test/gtest/TestMozURL.cpp +++ b/netwerk/test/gtest/TestMozURL.cpp @@ -11,7 +11,8 @@ using namespace mozilla; using namespace mozilla::net; -TEST(TestMozURL, Getters) { +TEST(TestMozURL, Getters) +{ nsAutoCString href("http://user:pass@example.com/path?query#ref"); RefPtr url; ASSERT_EQ(MozURL::Init(getter_AddRefs(url), href), NS_OK); @@ -38,7 +39,8 @@ TEST(TestMozURL, Getters) { ASSERT_EQ(url, nullptr); } -TEST(TestMozURL, MutatorChain) { +TEST(TestMozURL, MutatorChain) +{ nsAutoCString href("http://user:pass@example.com/path?query#ref"); RefPtr url; ASSERT_EQ(MozURL::Init(getter_AddRefs(url), href), NS_OK); @@ -60,7 +62,8 @@ TEST(TestMozURL, MutatorChain) { "https://newuser:newpass@test/new/file/path?bla#huh")); } -TEST(TestMozURL, MutatorFinalizeTwice) { +TEST(TestMozURL, MutatorFinalizeTwice) +{ nsAutoCString href("http://user:pass@example.com/path?query#ref"); RefPtr url; ASSERT_EQ(MozURL::Init(getter_AddRefs(url), href), NS_OK); @@ -79,7 +82,8 @@ TEST(TestMozURL, MutatorFinalizeTwice) { ASSERT_EQ(url2, nullptr); } -TEST(TestMozURL, MutatorErrorStatus) { +TEST(TestMozURL, MutatorErrorStatus) +{ nsAutoCString href("http://user:pass@example.com/path?query#ref"); RefPtr url; ASSERT_EQ(MozURL::Init(getter_AddRefs(url), href), NS_OK); @@ -95,7 +99,8 @@ TEST(TestMozURL, MutatorErrorStatus) { ASSERT_EQ(mut.GetStatus(), NS_ERROR_MALFORMED_URI); } -TEST(TestMozURL, InitWithBase) { +TEST(TestMozURL, InitWithBase) +{ nsAutoCString href("https://example.net/a/b.html"); RefPtr url; ASSERT_EQ(MozURL::Init(getter_AddRefs(url), href), NS_OK); @@ -110,7 +115,8 @@ TEST(TestMozURL, InitWithBase) { ASSERT_TRUE(url2->Spec().EqualsLiteral("https://example.net/a/c.png")); } -TEST(TestMozURL, Path) { +TEST(TestMozURL, Path) +{ nsAutoCString href("about:blank"); RefPtr url; ASSERT_EQ(MozURL::Init(getter_AddRefs(url), href), NS_OK); @@ -122,7 +128,8 @@ TEST(TestMozURL, Path) { ASSERT_TRUE(url->FilePath().EqualsLiteral("blank")); } -TEST(TestMozURL, HostPort) { +TEST(TestMozURL, HostPort) +{ nsAutoCString href("https://user:pass@example.net:1234/path?query#ref"); RefPtr url; ASSERT_EQ(MozURL::Init(getter_AddRefs(url), href), NS_OK); @@ -144,7 +151,8 @@ TEST(TestMozURL, HostPort) { ASSERT_EQ(url->Port(), -1); } -TEST(TestMozURL, Origin) { +TEST(TestMozURL, Origin) +{ nsAutoCString href("https://user:pass@example.net:1234/path?query#ref"); RefPtr url; ASSERT_EQ(MozURL::Init(getter_AddRefs(url), href), NS_OK); @@ -186,7 +194,8 @@ TEST(TestMozURL, Origin) { ASSERT_TRUE(out.EqualsLiteral("about:home")); } -TEST(TestMozURL, BaseDomain) { +TEST(TestMozURL, BaseDomain) +{ nsAutoCString href("https://user:pass@example.net:1234/path?query#ref"); RefPtr url; ASSERT_EQ(MozURL::Init(getter_AddRefs(url), href), NS_OK); @@ -308,7 +317,8 @@ void CheckOrigin(const nsACString& aSpec, const nsACString& aBase, } // namespace -TEST(TestMozURL, UrlTestData) { +TEST(TestMozURL, UrlTestData) +{ nsCOMPtr file; nsresult rv = NS_GetSpecialDirectory(NS_OS_CURRENT_WORKING_DIR, getter_AddRefs(file)); diff --git a/netwerk/test/gtest/TestPartiallySeekableInputStream.cpp b/netwerk/test/gtest/TestPartiallySeekableInputStream.cpp index 30dccd9e8c488..18198428d91a7 100644 --- a/netwerk/test/gtest/TestPartiallySeekableInputStream.cpp +++ b/netwerk/test/gtest/TestPartiallySeekableInputStream.cpp @@ -64,7 +64,8 @@ PartiallySeekableInputStream* CreateStream(uint32_t aSize, uint64_t aStreamSize, } // Simple reading. -TEST(TestPartiallySeekableInputStream, SimpleRead) { +TEST(TestPartiallySeekableInputStream, SimpleRead) +{ const size_t kBufSize = 10; nsCString buf; @@ -98,7 +99,8 @@ TEST(TestPartiallySeekableInputStream, SimpleRead) { } // Simple seek -TEST(TestPartiallySeekableInputStream, SimpleSeek) { +TEST(TestPartiallySeekableInputStream, SimpleSeek) +{ const size_t kBufSize = 10; nsCString buf; @@ -186,7 +188,8 @@ TEST(TestPartiallySeekableInputStream, SimpleSeek) { } // Full in cache -TEST(TestPartiallySeekableInputStream, FullCachedSeek) { +TEST(TestPartiallySeekableInputStream, FullCachedSeek) +{ const size_t kBufSize = 10; nsCString buf; @@ -218,7 +221,8 @@ TEST(TestPartiallySeekableInputStream, FullCachedSeek) { ASSERT_EQ((uint64_t)0, length); } -TEST(TestPartiallySeekableInputStream, QIInputStreamLength) { +TEST(TestPartiallySeekableInputStream, QIInputStreamLength) +{ nsCString buf; buf.AssignLiteral("Hello world"); @@ -242,7 +246,8 @@ TEST(TestPartiallySeekableInputStream, QIInputStreamLength) { } } -TEST(TestPartiallySeekableInputStream, InputStreamLength) { +TEST(TestPartiallySeekableInputStream, InputStreamLength) +{ nsCString buf; buf.AssignLiteral("Hello world"); @@ -262,7 +267,8 @@ TEST(TestPartiallySeekableInputStream, InputStreamLength) { ASSERT_EQ(buf.Length(), size); } -TEST(TestPartiallySeekableInputStream, NegativeInputStreamLength) { +TEST(TestPartiallySeekableInputStream, NegativeInputStreamLength) +{ nsCString buf; buf.AssignLiteral("Hello world"); @@ -282,7 +288,8 @@ TEST(TestPartiallySeekableInputStream, NegativeInputStreamLength) { ASSERT_EQ(-1, size); } -TEST(TestPartiallySeekableInputStream, AsyncInputStreamLength) { +TEST(TestPartiallySeekableInputStream, AsyncInputStreamLength) +{ nsCString buf; buf.AssignLiteral("Hello world"); @@ -306,7 +313,8 @@ TEST(TestPartiallySeekableInputStream, AsyncInputStreamLength) { ASSERT_EQ(buf.Length(), callback->Size()); } -TEST(TestPartiallySeekableInputStream, NegativeAsyncInputStreamLength) { +TEST(TestPartiallySeekableInputStream, NegativeAsyncInputStreamLength) +{ nsCString buf; buf.AssignLiteral("Hello world"); @@ -330,7 +338,8 @@ TEST(TestPartiallySeekableInputStream, NegativeAsyncInputStreamLength) { ASSERT_EQ(-1, callback->Size()); } -TEST(TestPartiallySeekableInputStream, AbortLengthCallback) { +TEST(TestPartiallySeekableInputStream, AbortLengthCallback) +{ nsCString buf; buf.AssignLiteral("Hello world"); diff --git a/netwerk/test/gtest/TestProtocolProxyService.cpp b/netwerk/test/gtest/TestProtocolProxyService.cpp index 36933a17d7353..a26f5f62a8a0e 100644 --- a/netwerk/test/gtest/TestProtocolProxyService.cpp +++ b/netwerk/test/gtest/TestProtocolProxyService.cpp @@ -12,7 +12,8 @@ namespace mozilla { namespace net { -TEST(TestProtocolProxyService, LoadHostFilters) { +TEST(TestProtocolProxyService, LoadHostFilters) +{ nsCOMPtr ps = do_GetService(NS_PROTOCOLPROXYSERVICE_CID); ASSERT_TRUE(ps); diff --git a/netwerk/test/gtest/TestReadStreamToString.cpp b/netwerk/test/gtest/TestReadStreamToString.cpp index f4aa0cd1e8f7e..a71c07b0212d0 100644 --- a/netwerk/test/gtest/TestReadStreamToString.cpp +++ b/netwerk/test/gtest/TestReadStreamToString.cpp @@ -4,7 +4,8 @@ #include "nsNetUtil.h" // Here we test the reading a pre-allocated size -TEST(TestReadStreamToString, SyncStreamPreAllocatedSize) { +TEST(TestReadStreamToString, SyncStreamPreAllocatedSize) +{ nsCString buffer; buffer.AssignLiteral("Hello world!"); @@ -26,7 +27,8 @@ TEST(TestReadStreamToString, SyncStreamPreAllocatedSize) { } // Here we test the reading the full size of a sync stream -TEST(TestReadStreamToString, SyncStreamFullSize) { +TEST(TestReadStreamToString, SyncStreamFullSize) +{ nsCString buffer; buffer.AssignLiteral("Hello world!"); @@ -43,7 +45,8 @@ TEST(TestReadStreamToString, SyncStreamFullSize) { } // Here we test the reading less than the full size of a sync stream -TEST(TestReadStreamToString, SyncStreamLessThan) { +TEST(TestReadStreamToString, SyncStreamLessThan) +{ nsCString buffer; buffer.AssignLiteral("Hello world!"); @@ -59,7 +62,8 @@ TEST(TestReadStreamToString, SyncStreamLessThan) { } // Here we test the reading more than the full size of a sync stream -TEST(TestReadStreamToString, SyncStreamMoreThan) { +TEST(TestReadStreamToString, SyncStreamMoreThan) +{ nsCString buffer; buffer.AssignLiteral("Hello world!"); @@ -77,7 +81,8 @@ TEST(TestReadStreamToString, SyncStreamMoreThan) { } // Here we test the reading a sync stream without passing the size -TEST(TestReadStreamToString, SyncStreamUnknownSize) { +TEST(TestReadStreamToString, SyncStreamUnknownSize) +{ nsCString buffer; buffer.AssignLiteral("Hello world!"); @@ -94,7 +99,8 @@ TEST(TestReadStreamToString, SyncStreamUnknownSize) { } // Here we test the reading the full size of an async stream -TEST(TestReadStreamToString, AsyncStreamFullSize) { +TEST(TestReadStreamToString, AsyncStreamFullSize) +{ nsCString buffer; buffer.AssignLiteral("Hello world!"); @@ -110,7 +116,8 @@ TEST(TestReadStreamToString, AsyncStreamFullSize) { } // Here we test the reading less than the full size of an async stream -TEST(TestReadStreamToString, AsyncStreamLessThan) { +TEST(TestReadStreamToString, AsyncStreamLessThan) +{ nsCString buffer; buffer.AssignLiteral("Hello world!"); @@ -125,7 +132,8 @@ TEST(TestReadStreamToString, AsyncStreamLessThan) { } // Here we test the reading more than the full size of an async stream -TEST(TestReadStreamToString, AsyncStreamMoreThan) { +TEST(TestReadStreamToString, AsyncStreamMoreThan) +{ nsCString buffer; buffer.AssignLiteral("Hello world!"); @@ -142,7 +150,8 @@ TEST(TestReadStreamToString, AsyncStreamMoreThan) { } // Here we test the reading an async stream without passing the size -TEST(TestReadStreamToString, AsyncStreamUnknownSize) { +TEST(TestReadStreamToString, AsyncStreamUnknownSize) +{ nsCString buffer; buffer.AssignLiteral("Hello world!"); @@ -158,7 +167,8 @@ TEST(TestReadStreamToString, AsyncStreamUnknownSize) { } // Here we test the reading an async big stream without passing the size -TEST(TestReadStreamToString, AsyncStreamUnknownBigSize) { +TEST(TestReadStreamToString, AsyncStreamUnknownBigSize) +{ nsCString buffer; buffer.SetLength(4096 * 2); diff --git a/netwerk/test/gtest/TestServerTimingHeader.cpp b/netwerk/test/gtest/TestServerTimingHeader.cpp index 30e8e392820de..ac55308a0ebb3 100644 --- a/netwerk/test/gtest/TestServerTimingHeader.cpp +++ b/netwerk/test/gtest/TestServerTimingHeader.cpp @@ -34,7 +34,8 @@ void testServerTimingHeader( } } -TEST(TestServerTimingHeader, HeaderParsing) { +TEST(TestServerTimingHeader, HeaderParsing) +{ // Test cases below are copied from // https://cs.chromium.org/chromium/src/third_party/WebKit/Source/platform/network/HTTPParsersTest.cpp diff --git a/netwerk/test/gtest/TestStandardURL.cpp b/netwerk/test/gtest/TestStandardURL.cpp index 927a4641fb825..ab459054fa45f 100644 --- a/netwerk/test/gtest/TestStandardURL.cpp +++ b/netwerk/test/gtest/TestStandardURL.cpp @@ -15,7 +15,8 @@ // In nsStandardURL.cpp extern nsresult Test_NormalizeIPv4(const nsACString& host, nsCString& result); -TEST(TestStandardURL, Simple) { +TEST(TestStandardURL, Simple) +{ nsCOMPtr url; ASSERT_EQ(NS_MutateURI(NS_STANDARDURLMUTATOR_CONTRACTID) .SetSpec(NS_LITERAL_CSTRING("http://example.com")) @@ -79,7 +80,8 @@ TEST(TestStandardURL, Simple) { ASSERT_TRUE(out == NS_LITERAL_CSTRING("some-book-mark")); } -TEST(TestStandardURL, NormalizeGood) { +TEST(TestStandardURL, NormalizeGood) +{ nsCString result; const char* manual[] = {"0.0.0.0", "0.0.0.0", @@ -184,7 +186,8 @@ TEST(TestStandardURL, NormalizeGood) { } } -TEST(TestStandardURL, NormalizeBad) { +TEST(TestStandardURL, NormalizeBad) +{ nsAutoCString result; const char* manual[] = { "x22.232.12.32", "122..12.32", "122.12.32.12.32", "122.12.32..", @@ -202,7 +205,8 @@ TEST(TestStandardURL, NormalizeBad) { } } -TEST(TestStandardURL, From_test_standardurldotjs) { +TEST(TestStandardURL, From_test_standardurldotjs) +{ // These are test (success and failure) cases from test_standardurl.js nsAutoCString result; @@ -327,7 +331,8 @@ MOZ_GTEST_BENCH(TestStandardURL, DISABLED_NormalizePerfFails, [] { }); #endif -TEST(TestStandardURL, Mutator) { +TEST(TestStandardURL, Mutator) +{ nsAutoCString out; nsCOMPtr uri; nsresult rv = NS_MutateURI(NS_STANDARDURLMUTATOR_CONTRACTID) @@ -354,7 +359,8 @@ TEST(TestStandardURL, Mutator) { ASSERT_TRUE(out == NS_LITERAL_CSTRING("https://mozilla.org/path?query#ref")); } -TEST(TestStandardURL, Deserialize_Bug1392739) { +TEST(TestStandardURL, Deserialize_Bug1392739) +{ mozilla::ipc::StandardURLParams standard_params; standard_params.urlType() = nsIStandardURL::URLTYPE_STANDARD; standard_params.spec() = NS_LITERAL_CSTRING(""); diff --git a/netwerk/test/gtest/TestURIMutator.cpp b/netwerk/test/gtest/TestURIMutator.cpp index 0aba70205caaa..34033a782d85d 100644 --- a/netwerk/test/gtest/TestURIMutator.cpp +++ b/netwerk/test/gtest/TestURIMutator.cpp @@ -6,7 +6,8 @@ #include "nsThreadPool.h" #include "nsNetUtil.h" -TEST(TestURIMutator, Mutator) { +TEST(TestURIMutator, Mutator) +{ nsAutoCString out; // This test instantiates a new nsStandardURL::Mutator (via contractID) @@ -102,7 +103,8 @@ TEST(TestURIMutator, Mutator) { extern MOZ_THREAD_LOCAL(uint32_t) gTlsURLRecursionCount; -TEST(TestURIMutator, NS_NewURIOnAnyThread) { +TEST(TestURIMutator, NS_NewURIOnAnyThread) +{ nsCOMPtr pool = new nsThreadPool(); pool->SetThreadLimit(60); diff --git a/netwerk/test/gtest/parse-ftp/TestParseFTPList.cpp b/netwerk/test/gtest/parse-ftp/TestParseFTPList.cpp index d8e108832956b..1f8f529b90ebb 100644 --- a/netwerk/test/gtest/parse-ftp/TestParseFTPList.cpp +++ b/netwerk/test/gtest/parse-ftp/TestParseFTPList.cpp @@ -121,7 +121,8 @@ static const char* testFiles[] = { "U-WinNT", "U-wu", "V-MultiNet", "V-VMS-mix", }; -TEST(ParseFTPTest, Check) { +TEST(ParseFTPTest, Check) +{ PRStatus result = PR_ParseTimeString(kDefaultTestTime, true, &gTestTime); ASSERT_EQ(PR_SUCCESS, result); diff --git a/parser/html/nsHtml5MetaScanner.cpp b/parser/html/nsHtml5MetaScanner.cpp index 41de496a02b1b..e92dcf7915304 100644 --- a/parser/html/nsHtml5MetaScanner.cpp +++ b/parser/html/nsHtml5MetaScanner.cpp @@ -115,7 +115,9 @@ void nsHtml5MetaScanner::stateLoop(int32_t state) { state = nsHtml5MetaScanner::TAG_OPEN; NS_HTML5_BREAK(dataloop); } - default: { continue; } + default: { + continue; + } } } dataloop_end:; @@ -618,7 +620,9 @@ void nsHtml5MetaScanner::stateLoop(int32_t state) { state = nsHtml5MetaScanner::COMMENT_END_DASH; NS_HTML5_BREAK(commentloop); } - default: { continue; } + default: { + continue; + } } } commentloop_end:; @@ -723,7 +727,9 @@ void nsHtml5MetaScanner::stateLoop(int32_t state) { state = nsHtml5MetaScanner::DATA; NS_HTML5_CONTINUE(stateloop); } - default: { continue; } + default: { + continue; + } } } } diff --git a/parser/html/nsHtml5Tokenizer.cpp b/parser/html/nsHtml5Tokenizer.cpp index e7202c04aab65..14ff5ba62fd81 100644 --- a/parser/html/nsHtml5Tokenizer.cpp +++ b/parser/html/nsHtml5Tokenizer.cpp @@ -507,7 +507,9 @@ int32_t nsHtml5Tokenizer::stateLoop(int32_t state, char16_t c, int32_t pos, silentLineFeed(); MOZ_FALLTHROUGH; } - default: { continue; } + default: { + continue; + } } } dataloop_end:; @@ -1560,7 +1562,9 @@ int32_t nsHtml5Tokenizer::stateLoop(int32_t state, char16_t c, int32_t pos, silentLineFeed(); MOZ_FALLTHROUGH; } - default: { continue; } + default: { + continue; + } } } cdatasectionloop_end:; @@ -2097,7 +2101,9 @@ int32_t nsHtml5Tokenizer::stateLoop(int32_t state, char16_t c, int32_t pos, silentLineFeed(); MOZ_FALLTHROUGH; } - default: { continue; } + default: { + continue; + } } } } @@ -2210,7 +2216,9 @@ int32_t nsHtml5Tokenizer::stateLoop(int32_t state, char16_t c, int32_t pos, silentLineFeed(); MOZ_FALLTHROUGH; } - default: { continue; } + default: { + continue; + } } } } @@ -2245,7 +2253,9 @@ int32_t nsHtml5Tokenizer::stateLoop(int32_t state, char16_t c, int32_t pos, silentLineFeed(); MOZ_FALLTHROUGH; } - default: { continue; } + default: { + continue; + } } } rawtextloop_end:; @@ -2477,7 +2487,9 @@ int32_t nsHtml5Tokenizer::stateLoop(int32_t state, char16_t c, int32_t pos, silentLineFeed(); MOZ_FALLTHROUGH; } - default: { continue; } + default: { + continue; + } } } scriptdataloop_end:; @@ -2656,7 +2668,9 @@ int32_t nsHtml5Tokenizer::stateLoop(int32_t state, char16_t c, int32_t pos, silentLineFeed(); MOZ_FALLTHROUGH; } - default: { continue; } + default: { + continue; + } } } scriptdataescapedloop_end:; @@ -2846,7 +2860,9 @@ int32_t nsHtml5Tokenizer::stateLoop(int32_t state, char16_t c, int32_t pos, silentLineFeed(); MOZ_FALLTHROUGH; } - default: { continue; } + default: { + continue; + } } } scriptdatadoubleescapedloop_end:; @@ -3706,7 +3722,9 @@ int32_t nsHtml5Tokenizer::stateLoop(int32_t state, char16_t c, int32_t pos, silentLineFeed(); MOZ_FALLTHROUGH; } - default: { continue; } + default: { + continue; + } } } } @@ -3977,7 +3995,9 @@ int32_t nsHtml5Tokenizer::stateLoop(int32_t state, char16_t c, int32_t pos, reconsume, pos); NS_HTML5_BREAK(processinginstructionloop); } - default: { continue; } + default: { + continue; + } } } processinginstructionloop_end:; @@ -4390,7 +4410,9 @@ void nsHtml5Tokenizer::eof() { NS_HTML5_BREAK(eofloop); } case DATA: - default: { NS_HTML5_BREAK(eofloop); } + default: { + NS_HTML5_BREAK(eofloop); + } } } eofloop_end:; diff --git a/parser/html/nsHtml5TreeBuilder.cpp b/parser/html/nsHtml5TreeBuilder.cpp index c6b913967d550..af43c122cf0f0 100644 --- a/parser/html/nsHtml5TreeBuilder.cpp +++ b/parser/html/nsHtml5TreeBuilder.cpp @@ -277,7 +277,9 @@ void nsHtml5TreeBuilder::comment(char16_t* buf, int32_t start, int32_t length) { appendComment(stack[0]->node, buf, start, length); return; } - default: { break; } + default: { + break; + } } } flushCharacters(); @@ -639,7 +641,9 @@ void nsHtml5TreeBuilder::eof() { case AFTER_FRAMESET: case AFTER_AFTER_BODY: case AFTER_AFTER_FRAMESET: - default: { NS_HTML5_BREAK(eofloop); } + default: { + NS_HTML5_BREAK(eofloop); + } } } eofloop_end:; @@ -2129,7 +2133,9 @@ nsHtml5String nsHtml5TreeBuilder::extractCharsetFromContent( charsetState = CHARSET_C; continue; } - default: { continue; } + default: { + continue; + } } } case CHARSET_C: { @@ -2223,7 +2229,9 @@ nsHtml5String nsHtml5TreeBuilder::extractCharsetFromContent( charsetState = CHARSET_EQUALS; continue; } - default: { return nullptr; } + default: { + return nullptr; + } } } case CHARSET_EQUALS: { @@ -2258,7 +2266,9 @@ nsHtml5String nsHtml5TreeBuilder::extractCharsetFromContent( end = i; NS_HTML5_BREAK(charsetloop); } - default: { continue; } + default: { + continue; + } } } case CHARSET_DOUBLE_QUOTED: { @@ -2267,7 +2277,9 @@ nsHtml5String nsHtml5TreeBuilder::extractCharsetFromContent( end = i; NS_HTML5_BREAK(charsetloop); } - default: { continue; } + default: { + continue; + } } } case CHARSET_UNQUOTED: { @@ -2281,7 +2293,9 @@ nsHtml5String nsHtml5TreeBuilder::extractCharsetFromContent( end = i; NS_HTML5_BREAK(charsetloop); } - default: { continue; } + default: { + continue; + } } } } @@ -2503,7 +2517,9 @@ void nsHtml5TreeBuilder::endTag(nsHtml5ElementName* elementName) { case TEMPLATE: { break; } - default: { errStrayEndTag(name); } + default: { + errStrayEndTag(name); + } } MOZ_FALLTHROUGH; } @@ -3294,7 +3310,9 @@ void nsHtml5TreeBuilder::generateImpliedEndTagsExceptFor(nsAtom* name) { pop(); continue; } - default: { return; } + default: { + return; + } } } } @@ -3312,7 +3330,9 @@ void nsHtml5TreeBuilder::generateImpliedEndTags() { pop(); continue; } - default: { return; } + default: { + return; + } } } } @@ -4484,7 +4504,9 @@ bool nsHtml5TreeBuilder::charBufferContainsNonWhitespace() { case '\f': { continue; } - default: { return true; } + default: { + return true; + } } } return false; diff --git a/parser/html/nsHtml5TreeOperation.cpp b/parser/html/nsHtml5TreeOperation.cpp index 185f2f6906c3e..6cd8f0cf6cc47 100644 --- a/parser/html/nsHtml5TreeOperation.cpp +++ b/parser/html/nsHtml5TreeOperation.cpp @@ -1116,7 +1116,9 @@ nsresult nsHtml5TreeOperation::Perform(nsHtml5TreeOpExecutor* aBuilder, aInterrupted); // this causes a notification flush anyway return NS_OK; } - default: { MOZ_CRASH("Bogus tree op"); } + default: { + MOZ_CRASH("Bogus tree op"); + } } return NS_OK; // keep compiler happy } diff --git a/security/certverifier/tests/gtest/TrustOverrideTest.cpp b/security/certverifier/tests/gtest/TrustOverrideTest.cpp index a6be2eeb2830f..6facadcf5e5e8 100644 --- a/security/certverifier/tests/gtest/TrustOverrideTest.cpp +++ b/security/certverifier/tests/gtest/TrustOverrideTest.cpp @@ -124,24 +124,29 @@ class psm_TrustOverrideTest : public ::testing::Test { protected: void SetUp() override { nsCOMPtr prefs(do_GetService(NS_PREFSERVICE_CONTRACTID)); - ASSERT_TRUE(prefs != nullptr) << "couldn't get nsIPrefBranch"; + ASSERT_TRUE(prefs != nullptr) + << "couldn't get nsIPrefBranch"; // When PSM initializes, it attempts to get some localized strings. // As a result, Android flips out if this isn't set. nsresult rv = prefs->SetBoolPref("intl.locale.matchOS", true); - ASSERT_TRUE(NS_SUCCEEDED(rv)) << "couldn't set pref 'intl.locale.matchOS'"; + ASSERT_TRUE(NS_SUCCEEDED(rv)) + << "couldn't set pref 'intl.locale.matchOS'"; nsCOMPtr certdb(do_GetService(NS_X509CERTDB_CONTRACTID)); - ASSERT_TRUE(certdb != nullptr) << "couldn't get certdb"; + ASSERT_TRUE(certdb != nullptr) + << "couldn't get certdb"; } }; TEST_F(psm_TrustOverrideTest, CheckCertDNIsInList) { mozilla::UniqueCERTCertificate caObj = CertFromString(kOverrideCaPem); - ASSERT_TRUE(caObj != nullptr) << "Should have parsed"; + ASSERT_TRUE(caObj != nullptr) + << "Should have parsed"; mozilla::UniqueCERTCertificate intObj = CertFromString(kOverrideCaIntermediatePem); - ASSERT_TRUE(intObj != nullptr) << "Should have parsed"; + ASSERT_TRUE(intObj != nullptr) + << "Should have parsed"; EXPECT_TRUE(CertDNIsInList(caObj.get(), OverrideCaDNs)) << "CA should be in the DN list"; @@ -151,10 +156,12 @@ TEST_F(psm_TrustOverrideTest, CheckCertDNIsInList) { TEST_F(psm_TrustOverrideTest, CheckCertSPKIIsInList) { mozilla::UniqueCERTCertificate caObj = CertFromString(kOverrideCaPem); - ASSERT_TRUE(caObj != nullptr) << "Should have parsed"; + ASSERT_TRUE(caObj != nullptr) + << "Should have parsed"; mozilla::UniqueCERTCertificate intObj = CertFromString(kOverrideCaIntermediatePem); - ASSERT_TRUE(intObj != nullptr) << "Should have parsed"; + ASSERT_TRUE(intObj != nullptr) + << "Should have parsed"; EXPECT_TRUE(CertSPKIIsInList(caObj.get(), OverrideCaSPKIs)) << "CA should be in the SPKI list"; diff --git a/security/manager/ssl/tests/gtest/CertDBTest.cpp b/security/manager/ssl/tests/gtest/CertDBTest.cpp index eae6f1f99e0fc..7cbb8ed4b23ce 100644 --- a/security/manager/ssl/tests/gtest/CertDBTest.cpp +++ b/security/manager/ssl/tests/gtest/CertDBTest.cpp @@ -12,46 +12,54 @@ #include "nsIX509CertList.h" #include "nsServiceManagerUtils.h" -TEST(psm_CertDB, Test) { +TEST(psm_CertDB, Test) +{ { nsCOMPtr prefs(do_GetService(NS_PREFSERVICE_CONTRACTID)); - ASSERT_TRUE(prefs) << "couldn't get nsIPrefBranch"; + ASSERT_TRUE(prefs) + << "couldn't get nsIPrefBranch"; // When PSM initializes, it attempts to get some localized strings. // As a result, Android flips out if this isn't set. nsresult rv = prefs->SetBoolPref("intl.locale.matchOS", true); - ASSERT_TRUE(NS_SUCCEEDED(rv)) << "couldn't set pref 'intl.locale.matchOS'"; + ASSERT_TRUE(NS_SUCCEEDED(rv)) + << "couldn't set pref 'intl.locale.matchOS'"; nsCOMPtr certdb(do_GetService(NS_X509CERTDB_CONTRACTID)); - ASSERT_TRUE(certdb) << "couldn't get certdb"; + ASSERT_TRUE(certdb) + << "couldn't get certdb"; nsCOMPtr certList; rv = certdb->GetCerts(getter_AddRefs(certList)); - ASSERT_TRUE(NS_SUCCEEDED(rv)) << "couldn't get list of certificates"; + ASSERT_TRUE(NS_SUCCEEDED(rv)) + << "couldn't get list of certificates"; nsCOMPtr enumerator; rv = certList->GetEnumerator(getter_AddRefs(enumerator)); - ASSERT_TRUE(NS_SUCCEEDED(rv)) << "couldn't enumerate certificate list"; + ASSERT_TRUE(NS_SUCCEEDED(rv)) + << "couldn't enumerate certificate list"; bool foundBuiltIn = false; bool hasMore = false; while (NS_SUCCEEDED(enumerator->HasMoreElements(&hasMore)) && hasMore) { nsCOMPtr supports; ASSERT_TRUE(NS_SUCCEEDED(enumerator->GetNext(getter_AddRefs(supports)))) - << "couldn't get next certificate"; + << "couldn't get next certificate"; nsCOMPtr cert(do_QueryInterface(supports)); - ASSERT_TRUE(cert) << "couldn't QI to nsIX509Cert"; + ASSERT_TRUE(cert) + << "couldn't QI to nsIX509Cert"; ASSERT_TRUE(NS_SUCCEEDED(cert->GetIsBuiltInRoot(&foundBuiltIn))) - << "GetIsBuiltInRoot failed"; + << "GetIsBuiltInRoot failed"; if (foundBuiltIn) { break; } } - ASSERT_TRUE(foundBuiltIn) << "didn't load any built-in certificates"; + ASSERT_TRUE(foundBuiltIn) + << "didn't load any built-in certificates"; printf("successfully loaded at least one built-in certificate\n"); diff --git a/security/manager/ssl/tests/gtest/CertListTest.cpp b/security/manager/ssl/tests/gtest/CertListTest.cpp index 7d12051763ca4..071c31b8ee764 100644 --- a/security/manager/ssl/tests/gtest/CertListTest.cpp +++ b/security/manager/ssl/tests/gtest/CertListTest.cpp @@ -120,15 +120,18 @@ class psm_CertList : public ::testing::Test { protected: void SetUp() override { nsCOMPtr prefs(do_GetService(NS_PREFSERVICE_CONTRACTID)); - ASSERT_TRUE(prefs) << "couldn't get nsIPrefBranch"; + ASSERT_TRUE(prefs) + << "couldn't get nsIPrefBranch"; // When PSM initializes, it attempts to get some localized strings. // As a result, Android flips out if this isn't set. nsresult rv = prefs->SetBoolPref("intl.locale.matchOS", true); - ASSERT_TRUE(NS_SUCCEEDED(rv)) << "couldn't set pref 'intl.locale.matchOS'"; + ASSERT_TRUE(NS_SUCCEEDED(rv)) + << "couldn't set pref 'intl.locale.matchOS'"; nsCOMPtr certdb(do_GetService(NS_X509CERTDB_CONTRACTID)); - ASSERT_TRUE(certdb) << "couldn't get certdb"; + ASSERT_TRUE(certdb) + << "couldn't get certdb"; } }; @@ -199,22 +202,24 @@ TEST_F(psm_CertList, TestValidSegmenting) { rv = certList->SegmentCertificateChain(rootCert, intCerts, eeCert); ASSERT_EQ(rv, NS_OK) << "Should have segmented OK"; - ASSERT_TRUE(rootCert) << "Root cert should be filled in"; - ASSERT_TRUE(eeCert) << "End entity cert should be filled in"; + ASSERT_TRUE(rootCert) + << "Root cert should be filled in"; + ASSERT_TRUE(eeCert) + << "End entity cert should be filled in"; ASSERT_EQ(CountCertsInList(intCerts), 0) << "There should be no intermediates"; bool selfSigned; ASSERT_TRUE(NS_SUCCEEDED(rootCert->GetIsSelfSigned(&selfSigned))) - << "Getters should work."; + << "Getters should work."; ASSERT_FALSE(selfSigned) << "Roots are self signed, but this was ca-second-intermediate"; nsAutoString rootCn; ASSERT_TRUE(NS_SUCCEEDED(rootCert->GetCommonName(rootCn))) - << "Getters should work."; + << "Getters should work."; ASSERT_TRUE(rootCn.EqualsLiteral("ca-second-intermediate")) - << "Second Intermediate CN should match"; + << "Second Intermediate CN should match"; rv = AddCertFromStringToList(kCaIntermediatePem, certList); ASSERT_EQ(rv, NS_OK) << "Should have loaded OK"; @@ -225,8 +230,10 @@ TEST_F(psm_CertList, TestValidSegmenting) { rv = certList->SegmentCertificateChain(rootCert, intCerts, eeCert); ASSERT_EQ(rv, NS_OK) << "Should have segmented OK"; - ASSERT_TRUE(rootCert) << "Root cert should be filled in"; - ASSERT_TRUE(eeCert) << "End entity cert should be filled in"; + ASSERT_TRUE(rootCert) + << "Root cert should be filled in"; + ASSERT_TRUE(eeCert) + << "End entity cert should be filled in"; ASSERT_EQ(CountCertsInList(intCerts), 1) << "There should be one intermediate"; @@ -239,23 +246,28 @@ TEST_F(psm_CertList, TestValidSegmenting) { rv = certList->SegmentCertificateChain(rootCert, intCerts, eeCert); ASSERT_EQ(rv, NS_OK) << "Should have segmented OK"; - ASSERT_TRUE(rootCert) << "Root cert should be filled in"; - ASSERT_TRUE(eeCert) << "End entity cert should be filled in"; + ASSERT_TRUE(rootCert) + << "Root cert should be filled in"; + ASSERT_TRUE(eeCert) + << "End entity cert should be filled in"; ASSERT_EQ(CountCertsInList(intCerts), 2) << "There should be two intermediates"; ASSERT_TRUE(NS_SUCCEEDED(rootCert->GetIsSelfSigned(&selfSigned))) - << "Getters should work."; - ASSERT_TRUE(selfSigned) << "Roots are self signed"; + << "Getters should work."; + ASSERT_TRUE(selfSigned) + << "Roots are self signed"; ASSERT_TRUE(NS_SUCCEEDED(rootCert->GetCommonName(rootCn))) - << "Getters should work."; - ASSERT_TRUE(rootCn.EqualsLiteral("ca")) << "Root CN should match"; + << "Getters should work."; + ASSERT_TRUE(rootCn.EqualsLiteral("ca")) + << "Root CN should match"; nsAutoString eeCn; ASSERT_TRUE(NS_SUCCEEDED(eeCert->GetCommonName(eeCn))) - << "Getters should work."; - ASSERT_TRUE(eeCn.EqualsLiteral("ee")) << "EE CN should match"; + << "Getters should work."; + ASSERT_TRUE(eeCn.EqualsLiteral("ee")) + << "EE CN should match"; rv = intCerts->GetCertList()->ForEachCertificateInChain( [](nsCOMPtr aCert, bool aHasMore, bool& aContinue) { @@ -413,7 +425,8 @@ TEST_F(psm_CertList, TestGetRootCertificateChainTwo) { nsCOMPtr rootCert; rv = certList->GetRootCertificate(rootCert); EXPECT_EQ(NS_OK, rv) << "Should have fetched the root OK"; - ASSERT_TRUE(rootCert) << "Root cert should be filled in"; + ASSERT_TRUE(rootCert) + << "Root cert should be filled in"; bool selfSigned; EXPECT_TRUE(NS_SUCCEEDED(rootCert->GetIsSelfSigned(&selfSigned))) @@ -429,7 +442,8 @@ TEST_F(psm_CertList, TestGetRootCertificateChainTwo) { nsCOMPtr rootCertRepeat; rv = certList->GetRootCertificate(rootCertRepeat); EXPECT_EQ(NS_OK, rv) << "Should have fetched the root OK the second time"; - ASSERT_TRUE(rootCertRepeat) << "Root cert should still be filled in"; + ASSERT_TRUE(rootCertRepeat) + << "Root cert should still be filled in"; nsAutoString rootRepeatCn; EXPECT_TRUE(NS_SUCCEEDED(rootCertRepeat->GetCommonName(rootRepeatCn))) @@ -452,7 +466,8 @@ TEST_F(psm_CertList, TestGetRootCertificateChainFour) { nsCOMPtr rootCert; rv = certList->GetRootCertificate(rootCert); EXPECT_EQ(NS_OK, rv) << "Should have again fetched the root OK"; - ASSERT_TRUE(rootCert) << "Root cert should be filled in"; + ASSERT_TRUE(rootCert) + << "Root cert should be filled in"; bool selfSigned; EXPECT_TRUE(NS_SUCCEEDED(rootCert->GetIsSelfSigned(&selfSigned))) diff --git a/security/manager/ssl/tests/gtest/DeserializeCertTest.cpp b/security/manager/ssl/tests/gtest/DeserializeCertTest.cpp index ce1b8d295f855..dbcb3170cb184 100644 --- a/security/manager/ssl/tests/gtest/DeserializeCertTest.cpp +++ b/security/manager/ssl/tests/gtest/DeserializeCertTest.cpp @@ -74,7 +74,8 @@ void deserializeAndVerify(const nsCString &serializedSecInfo, } } -TEST(psm_DeserializeCert, gecko33) { +TEST(psm_DeserializeCert, gecko33) +{ // clang-format off // Gecko 33+ vintage Security info serialized with UUIDs: // - nsISupports 00000000-0000-0000-c000-000000000046 @@ -108,7 +109,8 @@ TEST(psm_DeserializeCert, gecko33) { deserializeAndVerify(base64Serialization, false); } -TEST(psm_DeserializeCert, gecko46) { +TEST(psm_DeserializeCert, gecko46) +{ // clang-format off // Gecko 46+ vintage Security info serialized with UUIDs: // - nsISupports 00000000-0000-0000-c000-000000000046 @@ -142,7 +144,8 @@ TEST(psm_DeserializeCert, gecko46) { deserializeAndVerify(base64Serialization, false); } -TEST(psm_DeserializeCert, preSSLStatusConsolidation) { +TEST(psm_DeserializeCert, preSSLStatusConsolidation) +{ // clang-format off // Generated using serialized output of test "good.include-subdomains.pinning.example.com" // in security/manager/ssl/tests/unit/test_cert_chains.js @@ -190,7 +193,8 @@ TEST(psm_DeserializeCert, preSSLStatusConsolidation) { deserializeAndVerify(base64Serialization, false); } -TEST(psm_DeserializeCert, preSSLStatusConsolidationFailedCertChain) { +TEST(psm_DeserializeCert, preSSLStatusConsolidationFailedCertChain) +{ // clang-format off // Generated using serialized output of test "expired.example.com" // in security/manager/ssl/tests/unit/test_cert_chains.js diff --git a/security/sandbox/linux/gtest/TestBroker.cpp b/security/sandbox/linux/gtest/TestBroker.cpp index e44f23eadcf76..4f4102c621ea3 100644 --- a/security/sandbox/linux/gtest/TestBroker.cpp +++ b/security/sandbox/linux/gtest/TestBroker.cpp @@ -423,7 +423,8 @@ void SandboxBrokerTest::MultiThreadStatWorker() { ASSERT_EQ(0, statsyscall("/dev/null", &nullStat)) << "Shouldn't ever fail!"; ASSERT_EQ(0, statsyscall("/dev/zero", &zeroStat)) << "Shouldn't ever fail!"; ASSERT_EQ(0, lstatsyscall("/proc/self", &selfStat)) << "Shouldn't ever fail!"; - ASSERT_TRUE(S_ISLNK(selfStat.st_mode)) << "Shouldn't ever fail!"; + ASSERT_TRUE(S_ISLNK(selfStat.st_mode)) + << "Shouldn't ever fail!"; realNullDev = nullStat.st_rdev; realZeroDev = zeroStat.st_rdev; realSelfInode = selfStat.st_ino; @@ -439,7 +440,8 @@ void SandboxBrokerTest::MultiThreadStatWorker() { << "Loop " << i << "/" << kNumLoops; ASSERT_EQ(realZeroDev, zeroStat.st_rdev) << "Loop " << i << "/" << kNumLoops; - ASSERT_TRUE(S_ISLNK(selfStat.st_mode)) << "Loop " << i << "/" << kNumLoops; + ASSERT_TRUE(S_ISLNK(selfStat.st_mode)) + << "Loop " << i << "/" << kNumLoops; ASSERT_EQ(realSelfInode, selfStat.st_ino) << "Loop " << i << "/" << kNumLoops; } diff --git a/security/sandbox/linux/gtest/TestBrokerPolicy.cpp b/security/sandbox/linux/gtest/TestBrokerPolicy.cpp index 02344121ddac6..d881e6d290ab8 100644 --- a/security/sandbox/linux/gtest/TestBrokerPolicy.cpp +++ b/security/sandbox/linux/gtest/TestBrokerPolicy.cpp @@ -17,7 +17,8 @@ static const int MAY_WRITE = SandboxBroker::MAY_WRITE; // static const int RECURSIVE = SandboxBroker::RECURSIVE; static const auto AddAlways = SandboxBroker::Policy::AddAlways; -TEST(SandboxBrokerPolicyLookup, Simple) { +TEST(SandboxBrokerPolicyLookup, Simple) +{ SandboxBroker::Policy p; p.AddPath(MAY_READ, "/dev/urandom", AddAlways); @@ -27,7 +28,8 @@ TEST(SandboxBrokerPolicyLookup, Simple) { EXPECT_EQ(0, p.Lookup("/etc/passwd")) << "Non-added path was found."; } -TEST(SandboxBrokerPolicyLookup, CopyCtor) { +TEST(SandboxBrokerPolicyLookup, CopyCtor) +{ SandboxBroker::Policy psrc; psrc.AddPath(MAY_READ | MAY_WRITE, "/dev/null", AddAlways); SandboxBroker::Policy pdst(psrc); @@ -55,7 +57,8 @@ TEST(SandboxBrokerPolicyLookup, CopyCtor) { << "Non-added path is present in copy source."; } -TEST(SandboxBrokerPolicyLookup, Recursive) { +TEST(SandboxBrokerPolicyLookup, Recursive) +{ SandboxBroker::Policy psrc; psrc.AddPath(MAY_READ | MAY_WRITE, "/dev/null", AddAlways); psrc.AddPath(MAY_READ, "/dev/zero", AddAlways); diff --git a/security/sandbox/mac/Sandbox.mm b/security/sandbox/mac/Sandbox.mm index fea5f0e0ff67e..dbb5eaeb5bfb0 100644 --- a/security/sandbox/mac/Sandbox.mm +++ b/security/sandbox/mac/Sandbox.mm @@ -24,7 +24,6 @@ #include "SandboxPolicyGMP.h" #include "SandboxPolicyUtility.h" - // XXX There are currently problems with the /usr/include/sandbox.h file on // some/all of the Macs in Mozilla's build system. Further, // sandbox_init_with_parameters is not included in the header. For the time diff --git a/storage/test/gtest/test_AsXXX_helpers.cpp b/storage/test/gtest/test_AsXXX_helpers.cpp index eed0b1b623180..4fef8693a9474 100644 --- a/storage/test/gtest/test_AsXXX_helpers.cpp +++ b/storage/test/gtest/test_AsXXX_helpers.cpp @@ -50,7 +50,8 @@ Spinner::HandleResult(mozIStorageResultSet *aResultSet) { return NS_OK; } -TEST(storage_AsXXX_helpers, NULLFallback) { +TEST(storage_AsXXX_helpers, NULLFallback) +{ nsCOMPtr db(getMemoryDatabase()); nsCOMPtr stmt; @@ -92,7 +93,8 @@ TEST(storage_AsXXX_helpers, NULLFallback) { do_check_eq(valueArray->IsNull(0), true); } -TEST(storage_AsXXX_helpers, asyncNULLFallback) { +TEST(storage_AsXXX_helpers, asyncNULLFallback) +{ nsCOMPtr db(getMemoryDatabase()); nsCOMPtr stmt; diff --git a/storage/test/gtest/test_asyncStatementExecution_transaction.cpp b/storage/test/gtest/test_asyncStatementExecution_transaction.cpp index 4ddc3f16e53e9..4d4ffe5829be0 100644 --- a/storage/test/gtest/test_asyncStatementExecution_transaction.cpp +++ b/storage/test/gtest/test_asyncStatementExecution_transaction.cpp @@ -80,7 +80,8 @@ void check_transaction(mozIStorageConnection *aDB, * Test that executing multiple readonly AsyncStatements doesn't create a * transaction. */ -TEST(storage_asyncStatementExecution_transaction, MultipleAsyncReadStatements) { +TEST(storage_asyncStatementExecution_transaction, MultipleAsyncReadStatements) +{ nsCOMPtr db(getMemoryDatabase()); // -- create statements and execute them @@ -104,7 +105,8 @@ TEST(storage_asyncStatementExecution_transaction, MultipleAsyncReadStatements) { * Test that executing multiple readonly Statements doesn't create a * transaction. */ -TEST(storage_asyncStatementExecution_transaction, MultipleReadStatements) { +TEST(storage_asyncStatementExecution_transaction, MultipleReadStatements) +{ nsCOMPtr db(getMemoryDatabase()); // -- create statements and execute them @@ -129,7 +131,8 @@ TEST(storage_asyncStatementExecution_transaction, MultipleReadStatements) { * transaction. */ TEST(storage_asyncStatementExecution_transaction, - MultipleAsyncReadWriteStatements) { + MultipleAsyncReadWriteStatements) +{ nsCOMPtr db(getMemoryDatabase()); // -- create statements and execute them @@ -153,7 +156,8 @@ TEST(storage_asyncStatementExecution_transaction, /** * Test that executing multiple Statements causing writes creates a transaction. */ -TEST(storage_asyncStatementExecution_transaction, MultipleReadWriteStatements) { +TEST(storage_asyncStatementExecution_transaction, MultipleReadWriteStatements) +{ nsCOMPtr db(getMemoryDatabase()); // -- create statements and execute them @@ -178,8 +182,8 @@ TEST(storage_asyncStatementExecution_transaction, MultipleReadWriteStatements) { * Test that executing multiple AsyncStatements causing writes creates a * single transaction. */ -TEST(storage_asyncStatementExecution_transaction, - MultipleAsyncWriteStatements) { +TEST(storage_asyncStatementExecution_transaction, MultipleAsyncWriteStatements) +{ nsCOMPtr db(getMemoryDatabase()); // -- create statements and execute them @@ -205,7 +209,8 @@ TEST(storage_asyncStatementExecution_transaction, * Test that executing multiple Statements causing writes creates a * single transaction. */ -TEST(storage_asyncStatementExecution_transaction, MultipleWriteStatements) { +TEST(storage_asyncStatementExecution_transaction, MultipleWriteStatements) +{ nsCOMPtr db(getMemoryDatabase()); // -- create statements and execute them @@ -231,7 +236,8 @@ TEST(storage_asyncStatementExecution_transaction, MultipleWriteStatements) { * Test that executing a single read-only AsyncStatement doesn't create a * transaction. */ -TEST(storage_asyncStatementExecution_transaction, SingleAsyncReadStatement) { +TEST(storage_asyncStatementExecution_transaction, SingleAsyncReadStatement) +{ nsCOMPtr db(getMemoryDatabase()); // -- create statements and execute them @@ -250,7 +256,8 @@ TEST(storage_asyncStatementExecution_transaction, SingleAsyncReadStatement) { * Test that executing a single read-only Statement doesn't create a * transaction. */ -TEST(storage_asyncStatementExecution_transaction, SingleReadStatement) { +TEST(storage_asyncStatementExecution_transaction, SingleReadStatement) +{ nsCOMPtr db(getMemoryDatabase()); // -- create statements and execute them @@ -269,7 +276,8 @@ TEST(storage_asyncStatementExecution_transaction, SingleReadStatement) { * Test that executing a single AsyncStatement causing writes creates a * transaction. */ -TEST(storage_asyncStatementExecution_transaction, SingleAsyncWriteStatement) { +TEST(storage_asyncStatementExecution_transaction, SingleAsyncWriteStatement) +{ nsCOMPtr db(getMemoryDatabase()); // -- create statements and execute them @@ -288,7 +296,8 @@ TEST(storage_asyncStatementExecution_transaction, SingleAsyncWriteStatement) { /** * Test that executing a single Statement causing writes creates a transaction. */ -TEST(storage_asyncStatementExecution_transaction, SingleWriteStatement) { +TEST(storage_asyncStatementExecution_transaction, SingleWriteStatement) +{ nsCOMPtr db(getMemoryDatabase()); // -- create statements and execute them @@ -309,7 +318,8 @@ TEST(storage_asyncStatementExecution_transaction, SingleWriteStatement) { * doesn't create a transaction. */ TEST(storage_asyncStatementExecution_transaction, - MultipleParamsAsyncReadStatement) { + MultipleParamsAsyncReadStatement) +{ nsCOMPtr db(getMemoryDatabase()); // -- create statements and execute them @@ -341,7 +351,8 @@ TEST(storage_asyncStatementExecution_transaction, * Test that executing a single read-only Statement with multiple params * doesn't create a transaction. */ -TEST(storage_asyncStatementExecution_transaction, MultipleParamsReadStatement) { +TEST(storage_asyncStatementExecution_transaction, MultipleParamsReadStatement) +{ nsCOMPtr db(getMemoryDatabase()); // -- create statements and execute them @@ -373,7 +384,8 @@ TEST(storage_asyncStatementExecution_transaction, MultipleParamsReadStatement) { * creates a transaction. */ TEST(storage_asyncStatementExecution_transaction, - MultipleParamsAsyncWriteStatement) { + MultipleParamsAsyncWriteStatement) +{ nsCOMPtr db(getMemoryDatabase()); // -- create a table for writes @@ -413,8 +425,8 @@ TEST(storage_asyncStatementExecution_transaction, * Test that executing a single write Statement with multiple params * creates a transaction. */ -TEST(storage_asyncStatementExecution_transaction, - MultipleParamsWriteStatement) { +TEST(storage_asyncStatementExecution_transaction, MultipleParamsWriteStatement) +{ nsCOMPtr db(getMemoryDatabase()); // -- create a table for writes diff --git a/storage/test/gtest/test_async_callbacks_with_spun_event_loops.cpp b/storage/test/gtest/test_async_callbacks_with_spun_event_loops.cpp index 7ad6f7161c605..4bb3e6318eb87 100644 --- a/storage/test/gtest/test_async_callbacks_with_spun_event_loops.cpp +++ b/storage/test/gtest/test_async_callbacks_with_spun_event_loops.cpp @@ -90,7 +90,8 @@ bool UnownedCallback::sError = false; //// Tests TEST(storage_async_callbacks_with_spun_event_loops, - SpinEventsLoopInHandleResult) { + SpinEventsLoopInHandleResult) +{ nsCOMPtr db(getMemoryDatabase()); // Create a test table and populate it. @@ -120,8 +121,8 @@ TEST(storage_async_callbacks_with_spun_event_loops, spin_events_loop_until_true(&UnownedCallback::sResult); } -TEST(storage_async_callbacks_with_spun_event_loops, - SpinEventsLoopInHandleError) { +TEST(storage_async_callbacks_with_spun_event_loops, SpinEventsLoopInHandleError) +{ nsCOMPtr db(getMemoryDatabase()); // Create a test table and populate it. diff --git a/storage/test/gtest/test_binding_params.cpp b/storage/test/gtest/test_binding_params.cpp index a702808e26c9d..aacdec8af5859 100644 --- a/storage/test/gtest/test_binding_params.cpp +++ b/storage/test/gtest/test_binding_params.cpp @@ -15,7 +15,8 @@ using namespace mozilla; * mozIStorageStatement API. */ -TEST(storage_binding_params, ASCIIString) { +TEST(storage_binding_params, ASCIIString) +{ nsCOMPtr db(getMemoryDatabase()); // Create table with a single string column. @@ -54,7 +55,8 @@ TEST(storage_binding_params, ASCIIString) { (void)db->ExecuteSimpleSQL(NS_LITERAL_CSTRING("DELETE FROM test")); } -TEST(storage_binding_params, CString) { +TEST(storage_binding_params, CString) +{ nsCOMPtr db(getMemoryDatabase()); // Create table with a single string column. @@ -97,7 +99,8 @@ TEST(storage_binding_params, CString) { (void)db->ExecuteSimpleSQL(NS_LITERAL_CSTRING("DELETE FROM test")); } -TEST(storage_binding_params, UTFStrings) { +TEST(storage_binding_params, UTFStrings) +{ nsCOMPtr db(getMemoryDatabase()); // Create table with a single string column. diff --git a/storage/test/gtest/test_file_perms.cpp b/storage/test/gtest/test_file_perms.cpp index 7e4246a663538..254a69fa2c226 100644 --- a/storage/test/gtest/test_file_perms.cpp +++ b/storage/test/gtest/test_file_perms.cpp @@ -13,7 +13,8 @@ * we request they be */ -TEST(storage_file_perms, Test) { +TEST(storage_file_perms, Test) +{ nsCOMPtr db(getDatabase()); nsCOMPtr dbFile; do_check_success(db->GetDatabaseFile(getter_AddRefs(dbFile))); diff --git a/storage/test/gtest/test_mutex.cpp b/storage/test/gtest/test_mutex.cpp index dbd012cccf456..906d7c29a5d02 100644 --- a/storage/test/gtest/test_mutex.cpp +++ b/storage/test/gtest/test_mutex.cpp @@ -15,7 +15,8 @@ using namespace mozilla::storage; * This file test our sqlite3_mutex wrapper in SQLiteMutex.h. */ -TEST(storage_mutex, AutoLock) { +TEST(storage_mutex, AutoLock) +{ int lockTypes[] = { SQLITE_MUTEX_FAST, SQLITE_MUTEX_RECURSIVE, @@ -41,7 +42,8 @@ TEST(storage_mutex, AutoLock) { } } -TEST(storage_mutex, AutoUnlock) { +TEST(storage_mutex, AutoUnlock) +{ int lockTypes[] = { SQLITE_MUTEX_FAST, SQLITE_MUTEX_RECURSIVE, diff --git a/storage/test/gtest/test_service_init_background_thread.cpp b/storage/test/gtest/test_service_init_background_thread.cpp index 4d94184c35ac0..757d6042c613c 100644 --- a/storage/test/gtest/test_service_init_background_thread.cpp +++ b/storage/test/gtest/test_service_init_background_thread.cpp @@ -40,7 +40,8 @@ class ServiceInitializer : public mozilla::Runnable { // all non-death tests. By merely using a "DeathTest" suffix here this becomes // a death test -- even though it doesn't use any of the normal death test // features -- which ensures this is the first storage test to run. -TEST(storage_service_init_background_thread_DeathTest, Test) { +TEST(storage_service_init_background_thread_DeathTest, Test) +{ nsCOMPtr event = new ServiceInitializer(); do_check_true(event); diff --git a/storage/test/gtest/test_spinningSynchronousClose.cpp b/storage/test/gtest/test_spinningSynchronousClose.cpp index 953fef8bfdeb7..c7e0234361ae4 100644 --- a/storage/test/gtest/test_spinningSynchronousClose.cpp +++ b/storage/test/gtest/test_spinningSynchronousClose.cpp @@ -32,7 +32,8 @@ class CompletionRunnable final : public Runnable { // Can only run in optimized builds, or it would assert. #ifndef DEBUG -TEST(storage_spinningSynchronousClose, CloseOnAsync) { +TEST(storage_spinningSynchronousClose, CloseOnAsync) +{ nsCOMPtr db(getMemoryDatabase()); // Run an async statement. nsCOMPtr stmt; @@ -51,7 +52,8 @@ TEST(storage_spinningSynchronousClose, CloseOnAsync) { } #endif -TEST(storage_spinningSynchronousClose, spinningSynchronousCloseOnAsync) { +TEST(storage_spinningSynchronousClose, spinningSynchronousCloseOnAsync) +{ nsCOMPtr db(getMemoryDatabase()); // Run an async statement. nsCOMPtr stmt; diff --git a/storage/test/gtest/test_statement_scoper.cpp b/storage/test/gtest/test_statement_scoper.cpp index a254975ef0df4..903d0e0b4af2c 100644 --- a/storage/test/gtest/test_statement_scoper.cpp +++ b/storage/test/gtest/test_statement_scoper.cpp @@ -12,7 +12,8 @@ * This file test our statement scoper in mozStorageHelper.h. */ -TEST(storage_statement_scoper, automatic_reset) { +TEST(storage_statement_scoper, automatic_reset) +{ nsCOMPtr db(getMemoryDatabase()); // Need to create a table to populate sqlite_master with an entry. @@ -47,7 +48,8 @@ TEST(storage_statement_scoper, automatic_reset) { do_check_true(state == mozIStorageStatement::MOZ_STORAGE_STATEMENT_READY); } -TEST(storage_statement_scoper, Abandon) { +TEST(storage_statement_scoper, Abandon) +{ nsCOMPtr db(getMemoryDatabase()); // Need to create a table to populate sqlite_master with an entry. diff --git a/storage/test/gtest/test_transaction_helper.cpp b/storage/test/gtest/test_transaction_helper.cpp index a3feababcefec..9aba19ced6b34 100644 --- a/storage/test/gtest/test_transaction_helper.cpp +++ b/storage/test/gtest/test_transaction_helper.cpp @@ -20,7 +20,8 @@ bool has_transaction(mozIStorageConnection* aDB) { * This file tests our Transaction helper in mozStorageHelper.h. */ -TEST(storage_transaction_helper, Commit) { +TEST(storage_transaction_helper, Commit) +{ nsCOMPtr db(getMemoryDatabase()); // Create a table in a transaction, call Commit, and make sure that it does @@ -39,7 +40,8 @@ TEST(storage_transaction_helper, Commit) { do_check_true(exists); } -TEST(storage_transaction_helper, Rollback) { +TEST(storage_transaction_helper, Rollback) +{ nsCOMPtr db(getMemoryDatabase()); // Create a table in a transaction, call Rollback, and make sure that it does @@ -58,7 +60,8 @@ TEST(storage_transaction_helper, Rollback) { do_check_false(exists); } -TEST(storage_transaction_helper, AutoCommit) { +TEST(storage_transaction_helper, AutoCommit) +{ nsCOMPtr db(getMemoryDatabase()); // Create a table in a transaction, and make sure that it exists after the @@ -76,7 +79,8 @@ TEST(storage_transaction_helper, AutoCommit) { do_check_true(exists); } -TEST(storage_transaction_helper, AutoRollback) { +TEST(storage_transaction_helper, AutoRollback) +{ nsCOMPtr db(getMemoryDatabase()); // Create a table in a transaction, and make sure that it does not exists @@ -95,7 +99,8 @@ TEST(storage_transaction_helper, AutoRollback) { do_check_false(exists); } -TEST(storage_transaction_helper, null_database_connection) { +TEST(storage_transaction_helper, null_database_connection) +{ // We permit the use of the Transaction helper when passing a null database // in, so we need to make sure this still works without crashing. mozStorageTransaction transaction(nullptr, false); @@ -103,7 +108,8 @@ TEST(storage_transaction_helper, null_database_connection) { do_check_true(NS_SUCCEEDED(transaction.Rollback())); } -TEST(storage_transaction_helper, async_Commit) { +TEST(storage_transaction_helper, async_Commit) +{ HookSqliteMutex hook; nsCOMPtr db(getMemoryDatabase()); diff --git a/storage/test/gtest/test_true_async.cpp b/storage/test/gtest/test_true_async.cpp index aa839cd8a3fe6..1e0c33326fe82 100644 --- a/storage/test/gtest/test_true_async.cpp +++ b/storage/test/gtest/test_true_async.cpp @@ -9,7 +9,8 @@ //////////////////////////////////////////////////////////////////////////////// //// Tests -TEST(storage_true_async, TrueAsyncStatement) { +TEST(storage_true_async, TrueAsyncStatement) +{ HookSqliteMutex hook; nsCOMPtr db(getMemoryDatabase()); @@ -67,7 +68,8 @@ TEST(storage_true_async, TrueAsyncStatement) { * Test that cancellation before a statement is run successfully stops the * statement from executing. */ -TEST(storage_true_async, AsyncCancellation) { +TEST(storage_true_async, AsyncCancellation) +{ HookSqliteMutex hook; nsCOMPtr db(getMemoryDatabase()); @@ -136,7 +138,8 @@ TEST(storage_true_async, AsyncCancellation) { * finalization rather than trying to finalize it on the main thread * (and thereby running afoul of our mutex use detector). */ -TEST(storage_true_async, AsyncDestructorFinalizesOnAsyncThread) { +TEST(storage_true_async, AsyncDestructorFinalizesOnAsyncThread) +{ HookSqliteMutex hook; nsCOMPtr db(getMemoryDatabase()); diff --git a/storage/test/gtest/test_unlock_notify.cpp b/storage/test/gtest/test_unlock_notify.cpp index a4902ff3dae81..40bcbc5b297ee 100644 --- a/storage/test/gtest/test_unlock_notify.cpp +++ b/storage/test/gtest/test_unlock_notify.cpp @@ -222,7 +222,8 @@ void test_drop_table_does_not_loop() { tester->Shutdown(); } -TEST(storage_unlock_notify, Test) { +TEST(storage_unlock_notify, Test) +{ // These must execute in order. setup(); test_step_locked_does_not_block_main_thread(); diff --git a/testing/gtest/mozilla/MozGTestBench.h b/testing/gtest/mozilla/MozGTestBench.h index 2864ebd75a61e..438b977e4b69c 100644 --- a/testing/gtest/mozilla/MozGTestBench.h +++ b/testing/gtest/mozilla/MozGTestBench.h @@ -16,7 +16,8 @@ void GTestBench(const char* aSuite, const char* aName, } // namespace mozilla #define MOZ_GTEST_BENCH(suite, test, lambdaOrFunc) \ - TEST(suite, test) { mozilla::GTestBench(#suite, #test, lambdaOrFunc); } + TEST(suite, test) \ + { mozilla::GTestBench(#suite, #test, lambdaOrFunc); } #define MOZ_GTEST_BENCH_F(suite, test, lambdaOrFunc) \ TEST_F(suite, test) { mozilla::GTestBench(#suite, #test, lambdaOrFunc); } diff --git a/testing/gtest/mozilla/SanityTest.cpp b/testing/gtest/mozilla/SanityTest.cpp index dfbe10a23245a..7274c43932bb7 100644 --- a/testing/gtest/mozilla/SanityTest.cpp +++ b/testing/gtest/mozilla/SanityTest.cpp @@ -10,7 +10,8 @@ using ::testing::AtLeast; // Sanity test to make sure that GTest is hooked into // the mozilla build system correctly -TEST(MozillaGTestSanity, Runs) { EXPECT_EQ(1, 1); } +TEST(MozillaGTestSanity, Runs) +{ EXPECT_EQ(1, 1); } namespace { class TestMock { public: @@ -18,7 +19,8 @@ class TestMock { MOCK_METHOD0(MockedCall, void()); }; } // namespace -TEST(MozillaGMockSanity, Runs) { +TEST(MozillaGMockSanity, Runs) +{ TestMock mockedClass; EXPECT_CALL(mockedClass, MockedCall()).Times(AtLeast(3)); diff --git a/toolkit/components/extensions/webrequest/StreamFilter.cpp b/toolkit/components/extensions/webrequest/StreamFilter.cpp index 861e60924af92..4dba6aebf10ff 100644 --- a/toolkit/components/extensions/webrequest/StreamFilter.cpp +++ b/toolkit/components/extensions/webrequest/StreamFilter.cpp @@ -79,13 +79,14 @@ void StreamFilter::Connect() { RefPtr self(this); cc->SendInitStreamFilter(mChannelId, addonId) - ->Then(GetCurrentThreadSerialEventTarget(), __func__, - [=](mozilla::ipc::Endpoint&& aEndpoint) { - self->FinishConnect(std::move(aEndpoint)); - }, - [=](mozilla::ipc::ResponseRejectReason&& aReason) { - self->mActor->RecvInitialized(false); - }); + ->Then( + GetCurrentThreadSerialEventTarget(), __func__, + [=](mozilla::ipc::Endpoint&& aEndpoint) { + self->FinishConnect(std::move(aEndpoint)); + }, + [=](mozilla::ipc::ResponseRejectReason&& aReason) { + self->mActor->RecvInitialized(false); + }); } else { mozilla::ipc::Endpoint endpoint; Unused << StreamFilterParent::Create(nullptr, mChannelId, addonId, diff --git a/toolkit/components/perfmonitoring/PerformanceMetricsCollector.cpp b/toolkit/components/perfmonitoring/PerformanceMetricsCollector.cpp index c42c70333b3e3..d77376e5d606f 100644 --- a/toolkit/components/perfmonitoring/PerformanceMetricsCollector.cpp +++ b/toolkit/components/perfmonitoring/PerformanceMetricsCollector.cpp @@ -259,13 +259,14 @@ PerformanceMetricsCollector::RequestMetricsInternal() { // collecting the current process PerformanceInfo PerformanceInfoPromise::All(NS_GetCurrentThread(), localPromises) - ->Then(NS_GetCurrentThread(), __func__, - [uuid](const nsTArray aResult) { - LOG(("[%s] Local CollectPerformanceInfo promise resolved", - nsIDToCString(uuid).get())); - DataReceived(uuid, aResult); - }, - [](const nsresult aResult) {}); + ->Then( + NS_GetCurrentThread(), __func__, + [uuid](const nsTArray aResult) { + LOG(("[%s] Local CollectPerformanceInfo promise resolved", + nsIDToCString(uuid).get())); + DataReceived(uuid, aResult); + }, + [](const nsresult aResult) {}); return promise; } diff --git a/toolkit/components/places/tests/gtest/places_test_harness_tail.h b/toolkit/components/places/tests/gtest/places_test_harness_tail.h index d1937adf16636..e27551f275b75 100644 --- a/toolkit/components/places/tests/gtest/places_test_harness_tail.h +++ b/toolkit/components/places/tests/gtest/places_test_harness_tail.h @@ -60,7 +60,8 @@ void disable_idle_service() { idle->SetDisabled(true); } -TEST(IHistory, Test) { +TEST(IHistory, Test) +{ RefPtr spinClose = new WaitForConnectionClosed(); // Tinderboxes are constantly on idle. Since idle tasks can interact with diff --git a/toolkit/components/places/tests/gtest/test_casing.cpp b/toolkit/components/places/tests/gtest/test_casing.cpp index 8cae9ca27ae27..1668f2f5a6c3a 100644 --- a/toolkit/components/places/tests/gtest/test_casing.cpp +++ b/toolkit/components/places/tests/gtest/test_casing.cpp @@ -11,7 +11,8 @@ // only non-ASCII characters that lower-case to ASCII ones are: // * U+0130 LATIN CAPITAL LETTER I WITH DOT ABOVE // * U+212A KELVIN SIGN -TEST(MatchAutocompleteCasing, CaseAssumption) { +TEST(MatchAutocompleteCasing, CaseAssumption) +{ for (uint32_t c = 128; c < 0x110000; c++) { if (c != 304 && c != 8490) { ASSERT_GE(mozilla::unicode::GetLowercase(c), 128U); @@ -20,7 +21,8 @@ TEST(MatchAutocompleteCasing, CaseAssumption) { } // Verify the assertion that all ASCII characters lower-case to ASCII. -TEST(MatchAutocompleteCasing, CaseAssumption2) { +TEST(MatchAutocompleteCasing, CaseAssumption2) +{ for (uint32_t c = 0; c < 128; c++) { ASSERT_LT(mozilla::unicode::GetLowercase(c), 128U); } diff --git a/toolkit/components/reputationservice/test/gtest/TestExecutableLists.cpp b/toolkit/components/reputationservice/test/gtest/TestExecutableLists.cpp index e1519183c2b8f..2d407b0575a7c 100644 --- a/toolkit/components/reputationservice/test/gtest/TestExecutableLists.cpp +++ b/toolkit/components/reputationservice/test/gtest/TestExecutableLists.cpp @@ -291,7 +291,8 @@ static const char* const kTestFileExtensions[] = { // duplicates manually, ensures we could start doing more efficient lookups if // we felt that was necessary (e.g. if the lists get much bigger), and that it's // easy for humans to find things... -TEST(TestExecutableLists, ListsAreSorted) { +TEST(TestExecutableLists, ListsAreSorted) +{ CheckListSorted(sExecutableExts); CheckListSorted(ApplicationReputationService::kBinaryFileExtensions); CheckListSorted(ApplicationReputationService::kNonBinaryExecutables); @@ -311,14 +312,16 @@ bool _IsInList(const char* ext, const char* const _list[], const size_t len) { #define IsInList(_ext, _list) \ _IsInList(_ext, _list, mozilla::ArrayLength(_list)) -TEST(TestExecutableLists, NonBinariesInExecutablesList) { +TEST(TestExecutableLists, NonBinariesInExecutablesList) +{ for (auto nonBinary : ApplicationReputationService::kNonBinaryExecutables) { EXPECT_TRUE(IsInList(nonBinary, sExecutableExts)) << "Expected " << nonBinary << " to be part of sExecutableExts list"; } } -TEST(TestExecutableLists, AllExtensionsInTestList) { +TEST(TestExecutableLists, AllExtensionsInTestList) +{ for (auto ext : ApplicationReputationService::kBinaryFileExtensions) { EXPECT_TRUE(IsInList(ext, kTestFileExtensions)) << "Expected binary extension " << ext @@ -338,7 +341,8 @@ TEST(TestExecutableLists, AllExtensionsInTestList) { } } -TEST(TestExecutableLists, TestListExtensionsExistSomewhere) { +TEST(TestExecutableLists, TestListExtensionsExistSomewhere) +{ for (auto ext : kTestFileExtensions) { EXPECT_TRUE( IsInList(ext, ApplicationReputationService::kBinaryFileExtensions) != diff --git a/toolkit/components/resistfingerprinting/tests/test_reduceprecision.cpp b/toolkit/components/resistfingerprinting/tests/test_reduceprecision.cpp index 6a6b10022e7e5..4998cedfb6ad5 100644 --- a/toolkit/components/resistfingerprinting/tests/test_reduceprecision.cpp +++ b/toolkit/components/resistfingerprinting/tests/test_reduceprecision.cpp @@ -79,12 +79,14 @@ void process(double clock, nsRFPService::TimeScale clockUnits, ASSERT_EQ(reduced1, reduced2); } -TEST(ResistFingerprinting, ReducePrecision_Assumptions) { +TEST(ResistFingerprinting, ReducePrecision_Assumptions) +{ ASSERT_EQ(FLT_RADIX, 2); ASSERT_EQ(DBL_MANT_DIG, 53); } -TEST(ResistFingerprinting, ReducePrecision_Reciprocal) { +TEST(ResistFingerprinting, ReducePrecision_Reciprocal) +{ bool jitterEnabled = setupJitter(false); // This one has a rounding error in the Reciprocal case: process(2064.8338460, nsRFPService::TimeScale::MicroSeconds, 20); @@ -94,7 +96,8 @@ TEST(ResistFingerprinting, ReducePrecision_Reciprocal) { cleanupJitter(jitterEnabled); } -TEST(ResistFingerprinting, ReducePrecision_KnownGood) { +TEST(ResistFingerprinting, ReducePrecision_KnownGood) +{ bool jitterEnabled = setupJitter(false); process(2064.8338460, nsRFPService::TimeScale::MilliSeconds, 20); process(69027.62, nsRFPService::TimeScale::MilliSeconds, 20); @@ -102,7 +105,8 @@ TEST(ResistFingerprinting, ReducePrecision_KnownGood) { cleanupJitter(jitterEnabled); } -TEST(ResistFingerprinting, ReducePrecision_KnownBad) { +TEST(ResistFingerprinting, ReducePrecision_KnownBad) +{ bool jitterEnabled = setupJitter(false); process(1054.842405, nsRFPService::TimeScale::MilliSeconds, 20); process(273.53038600000002, nsRFPService::TimeScale::MilliSeconds, 20); @@ -111,7 +115,8 @@ TEST(ResistFingerprinting, ReducePrecision_KnownBad) { cleanupJitter(jitterEnabled); } -TEST(ResistFingerprinting, ReducePrecision_Edge) { +TEST(ResistFingerprinting, ReducePrecision_Edge) +{ bool jitterEnabled = setupJitter(false); process(2611.14, nsRFPService::TimeScale::MilliSeconds, 20); process(2611.16, nsRFPService::TimeScale::MilliSeconds, 20); @@ -122,7 +127,8 @@ TEST(ResistFingerprinting, ReducePrecision_Edge) { cleanupJitter(jitterEnabled); } -TEST(ResistFingerprinting, ReducePrecision_Expectations) { +TEST(ResistFingerprinting, ReducePrecision_Expectations) +{ bool jitterEnabled = setupJitter(false); double result; result = nsRFPService::ReduceTimePrecisionImpl( @@ -152,7 +158,8 @@ TEST(ResistFingerprinting, ReducePrecision_Expectations) { cleanupJitter(jitterEnabled); } -TEST(ResistFingerprinting, ReducePrecision_ExpectedLossOfPrecision) { +TEST(ResistFingerprinting, ReducePrecision_ExpectedLossOfPrecision) +{ bool jitterEnabled = setupJitter(false); double result; // We lose integer precision at 9007199254740992 - let's confirm that. @@ -186,7 +193,8 @@ TEST(ResistFingerprinting, ReducePrecision_ExpectedLossOfPrecision) { // If you're doing logging, you really don't want to run this test. #define RUN_AGGRESSIVE false -TEST(ResistFingerprinting, ReducePrecision_Aggressive) { +TEST(ResistFingerprinting, ReducePrecision_Aggressive) +{ if (!RUN_AGGRESSIVE) { return; } @@ -240,7 +248,8 @@ TEST(ResistFingerprinting, ReducePrecision_Aggressive) { cleanupJitter(jitterEnabled); } -TEST(ResistFingerprinting, ReducePrecision_JitterTestVectors) { +TEST(ResistFingerprinting, ReducePrecision_JitterTestVectors) +{ bool jitterEnabled = setupJitter(true); // clang-format off diff --git a/toolkit/components/telemetry/geckoview/gtest/TestGeckoView.cpp b/toolkit/components/telemetry/geckoview/gtest/TestGeckoView.cpp index bbf7c5cfd7f9a..e95f30467f952 100644 --- a/toolkit/components/telemetry/geckoview/gtest/TestGeckoView.cpp +++ b/toolkit/components/telemetry/geckoview/gtest/TestGeckoView.cpp @@ -235,7 +235,7 @@ TEST_F(TelemetryGeckoViewFixture, ClearPersistenceFiles) { WritePersistenceFile(nsDependentCString(kSampleData)); CheckPersistenceFileExists(fileExists); ASSERT_TRUE(fileExists) - << "We should have written the test persistence file to disk"; + << "We should have written the test persistence file to disk"; // Init the persistence: this will trigger the measurements to be written // to disk off-the-main thread. @@ -270,7 +270,7 @@ TEST_F(TelemetryGeckoViewFixture, CheckDataLoadedTopic) { WritePersistenceFile(nsDependentCString(kSampleData)); CheckPersistenceFileExists(fileExists); ASSERT_TRUE(fileExists) - << "The persisted measurements must exist on the disk"; + << "The persisted measurements must exist on the disk"; // Check that the data loaded topic is triggered when the measurement file // exists. @@ -321,7 +321,7 @@ TEST_F(TelemetryGeckoViewFixture, PersistScalars) { CheckPersistenceFileExists(fileExists); ASSERT_TRUE(fileExists) - << "The persisted measurements must exist on the disk"; + << "The persisted measurements must exist on the disk"; // Clear the in-memory scalars again. They will be restored from the disk. Unused << mTelemetry->ClearScalars(); @@ -392,7 +392,7 @@ TEST_F(TelemetryGeckoViewFixture, PersistHistograms) { CheckPersistenceFileExists(fileExists); ASSERT_TRUE(fileExists) - << "The persisted measurements must exist on the disk"; + << "The persisted measurements must exist on the disk"; // Clear the in-memory histograms again. They will be restored from the disk. GetAndClearHistogram(cx.GetJSContext(), mTelemetry, @@ -496,7 +496,7 @@ TEST_F(TelemetryGeckoViewFixture, EmptyPendingOperations) { GetScalarsSnapshot(false, cx.GetJSContext(), &scalarsSnapshot); ASSERT_TRUE(scalarsSnapshot.isUndefined()) - << "Scalars snapshot should not contain any data."; + << "Scalars snapshot should not contain any data."; } TEST_F(TelemetryGeckoViewFixture, SimpleAppendOperation) { diff --git a/toolkit/components/telemetry/tests/gtest/TelemetryTestHelpers.cpp b/toolkit/components/telemetry/tests/gtest/TelemetryTestHelpers.cpp index 729763e3dfa61..c6e6b9c13b259 100644 --- a/toolkit/components/telemetry/tests/gtest/TelemetryTestHelpers.cpp +++ b/toolkit/components/telemetry/tests/gtest/TelemetryTestHelpers.cpp @@ -22,13 +22,13 @@ void CheckUintScalar(const char* aName, JSContext* aCx, JS::RootedValue value(aCx); JS::RootedObject scalarObj(aCx, &aSnapshot.toObject()); ASSERT_TRUE(JS_GetProperty(aCx, scalarObj, aName, &value)) - << "The test scalar must be reported."; + << "The test scalar must be reported."; JS_GetProperty(aCx, scalarObj, aName, &value); ASSERT_TRUE(value.isInt32()) - << "The scalar value must be of the correct type."; + << "The scalar value must be of the correct type."; ASSERT_TRUE(value.toInt32() >= 0) - << "The uint scalar type must contain a value >= 0."; + << "The uint scalar type must contain a value >= 0."; ASSERT_EQ(static_cast(value.toInt32()), expectedValue) << "The scalar value must match the expected value."; } @@ -39,9 +39,9 @@ void CheckBoolScalar(const char* aName, JSContext* aCx, JS::RootedValue value(aCx); JS::RootedObject scalarObj(aCx, &aSnapshot.toObject()); ASSERT_TRUE(JS_GetProperty(aCx, scalarObj, aName, &value)) - << "The test scalar must be reported."; + << "The test scalar must be reported."; ASSERT_TRUE(value.isBoolean()) - << "The scalar value must be of the correct type."; + << "The scalar value must be of the correct type."; ASSERT_EQ(static_cast(value.toBoolean()), expectedValue) << "The scalar value must match the expected value."; } @@ -52,15 +52,16 @@ void CheckStringScalar(const char* aName, JSContext* aCx, JS::RootedValue value(aCx); JS::RootedObject scalarObj(aCx, &aSnapshot.toObject()); ASSERT_TRUE(JS_GetProperty(aCx, scalarObj, aName, &value)) - << "The test scalar must be reported."; + << "The test scalar must be reported."; ASSERT_TRUE(value.isString()) - << "The scalar value must be of the correct type."; + << "The scalar value must be of the correct type."; bool sameString; ASSERT_TRUE( JS_StringEqualsAscii(aCx, value.toString(), expectedValue, &sameString)) - << "JS String comparison failed"; - ASSERT_TRUE(sameString) << "The scalar value must match the expected string"; + << "JS String comparison failed"; + ASSERT_TRUE(sameString) + << "The scalar value must match the expected string"; } void CheckKeyedUintScalar(const char* aName, const char* aKey, JSContext* aCx, @@ -69,7 +70,7 @@ void CheckKeyedUintScalar(const char* aName, const char* aKey, JSContext* aCx, JS::RootedObject scalarObj(aCx, &aSnapshot.toObject()); // Get the aName keyed scalar object from the scalars snapshot. ASSERT_TRUE(JS_GetProperty(aCx, scalarObj, aName, &keyedScalar)) - << "The keyed scalar must be reported."; + << "The keyed scalar must be reported."; CheckUintScalar(aKey, aCx, keyedScalar, expectedValue); } @@ -80,7 +81,7 @@ void CheckKeyedBoolScalar(const char* aName, const char* aKey, JSContext* aCx, JS::RootedObject scalarObj(aCx, &aSnapshot.toObject()); // Get the aName keyed scalar object from the scalars snapshot. ASSERT_TRUE(JS_GetProperty(aCx, scalarObj, aName, &keyedScalar)) - << "The keyed scalar must be reported."; + << "The keyed scalar must be reported."; CheckBoolScalar(aKey, aCx, keyedScalar, expectedValue); } @@ -92,12 +93,12 @@ void CheckNumberOfProperties(const char* aName, JSContext* aCx, JS::RootedObject scalarObj(aCx, &aSnapshot.toObject()); // Get the aName keyed scalar object from the scalars snapshot. ASSERT_TRUE(JS_GetProperty(aCx, scalarObj, aName, &keyedScalar)) - << "The keyed scalar must be reported."; + << "The keyed scalar must be reported."; JS::RootedObject keyedScalarObj(aCx, &keyedScalar.toObject()); JS::Rooted ids(aCx, JS::IdVector(aCx)); ASSERT_TRUE(JS_Enumerate(aCx, keyedScalarObj, &ids)) - << "We must be able to get keyed scalar members."; + << "We must be able to get keyed scalar members."; ASSERT_EQ(expectedNumProperties, ids.length()) << "The scalar must report the expected number of properties."; @@ -177,7 +178,8 @@ void GetOriginSnapshot(JSContext* aCx, JS::MutableHandle aResult, nsresult rv; rv = telemetry->GetOriginSnapshot(aClear, aCx, &originSnapshot); ASSERT_EQ(rv, NS_OK) << "Snapshotting origin data must not fail."; - ASSERT_TRUE(originSnapshot.isObject()) << "The snapshot must be an object."; + ASSERT_TRUE(originSnapshot.isObject()) + << "The snapshot must be an object."; aResult.set(originSnapshot); } @@ -208,11 +210,11 @@ void GetEncodedOriginStrings(JSContext* aCx, const nsCString& encoding, JS::RootedObject prioDataObj(aCx, &snapshot.toObject()); bool isArray = false; ASSERT_TRUE(JS_IsArrayObject(aCx, prioDataObj, &isArray) && isArray) - << "The metric's origins must be in an array."; + << "The metric's origins must be in an array."; uint32_t length = 0; ASSERT_TRUE(JS_GetArrayLength(aCx, prioDataObj, &length) && length == 1) - << "Length of returned array must be 1."; + << "Length of returned array must be 1."; JS::RootedValue arrayItem(aCx); ASSERT_TRUE(JS_GetElement(aCx, prioDataObj, 0, &arrayItem)); @@ -227,8 +229,8 @@ void GetEncodedOriginStrings(JSContext* aCx, const nsCString& encoding, nsAutoJSString jsStr; ASSERT_TRUE(jsStr.init(aCx, encodingVal)); ASSERT_TRUE(NS_ConvertUTF16toUTF8(jsStr) == encoding) - << "Actual 'encoding' (" << NS_ConvertUTF16toUTF8(jsStr).get() - << ") must match expected (" << encoding.get(); + << "Actual 'encoding' (" << NS_ConvertUTF16toUTF8(jsStr).get() + << ") must match expected (" << encoding.get(); JS::RootedValue prioVal(aCx); ASSERT_TRUE(JS_GetProperty(aCx, arrayItemObj, "prio", &prioVal)); @@ -259,7 +261,8 @@ void GetEventSnapshot(JSContext* aCx, JS::MutableHandle aResult, 0 /* eventLimit */, aCx, 1 /* argc */, &eventSnapshot); ASSERT_EQ(rv, NS_OK) << "Snapshotting events must not fail."; - ASSERT_TRUE(eventSnapshot.isObject()) << "The snapshot must be an object."; + ASSERT_TRUE(eventSnapshot.isObject()) + << "The snapshot must be an object."; JS::RootedValue processEvents(aCx); JS::RootedObject eventObj(aCx, &eventSnapshot.toObject()); @@ -292,7 +295,8 @@ void GetScalarsSnapshot(bool aKeyed, JSContext* aCx, // Validate the snapshot. ASSERT_EQ(rv, NS_OK) << "Creating a snapshot of the data must not fail."; - ASSERT_TRUE(scalarsSnapshot.isObject()) << "The snapshot must be an object."; + ASSERT_TRUE(scalarsSnapshot.isObject()) + << "The snapshot must be an object."; JS::RootedValue processScalars(aCx); JS::RootedObject scalarObj(aCx, &scalarsSnapshot.toObject()); @@ -319,7 +323,7 @@ void GetAndClearHistogram(JSContext* cx, nsCOMPtr mTelemetry, JS::RootedValue rval(cx); ASSERT_TRUE(JS_CallFunctionName(cx, testHistogramObj, "clear", JS::HandleValueArray::empty(), &rval)) - << "Cannot clear histogram"; + << "Cannot clear histogram"; } void GetProperty(JSContext* cx, const char* name, JS::HandleValue valueIn, @@ -327,7 +331,7 @@ void GetProperty(JSContext* cx, const char* name, JS::HandleValue valueIn, JS::RootedValue property(cx); JS::RootedObject valueInObj(cx, &valueIn.toObject()); ASSERT_TRUE(JS_GetProperty(cx, valueInObj, name, &property)) - << "Cannot get property '" << name << "'"; + << "Cannot get property '" << name << "'"; valueOut.set(property); } @@ -336,7 +340,7 @@ void GetElement(JSContext* cx, uint32_t index, JS::HandleValue valueIn, JS::RootedValue element(cx); JS::RootedObject valueInObj(cx, &valueIn.toObject()); ASSERT_TRUE(JS_GetElement(cx, valueInObj, index, &element)) - << "Cannot get element at index '" << index << "'"; + << "Cannot get element at index '" << index << "'"; valueOut.set(element); } diff --git a/toolkit/components/telemetry/tests/gtest/TestCombinedStacks.cpp b/toolkit/components/telemetry/tests/gtest/TestCombinedStacks.cpp index d59ea4290dade..930a66e0915ac 100644 --- a/toolkit/components/telemetry/tests/gtest/TestCombinedStacks.cpp +++ b/toolkit/components/telemetry/tests/gtest/TestCombinedStacks.cpp @@ -38,7 +38,7 @@ TEST_F(TelemetryTestFixture, CombinedStacks) { ProcessedStack::Module module = stacks.GetModule(frame.mModIndex); nsPrintfCString moduleName("test%hu", frame.mModIndex); ASSERT_TRUE(module.mName.Equals(NS_ConvertUTF8toUTF16(moduleName))) - << "Module should have expected name"; + << "Module should have expected name"; } for (size_t i = 0; i < kMaxStacksKept; ++i) { diff --git a/toolkit/components/telemetry/tests/gtest/TestEvents.cpp b/toolkit/components/telemetry/tests/gtest/TestEvents.cpp index 03314613dc82e..b5108ba17b5ab 100644 --- a/toolkit/components/telemetry/tests/gtest/TestEvents.cpp +++ b/toolkit/components/telemetry/tests/gtest/TestEvents.cpp @@ -74,49 +74,50 @@ TEST_F(TelemetryTestFixture, RecordEventNative) { ASSERT_TRUE(!EventPresent(cx.GetJSContext(), eventsSnapshot, category, method, object)) - << "Test event must not be present when recorded before enabled."; + << "Test event must not be present when recorded before enabled."; ASSERT_TRUE(EventPresent(cx.GetJSContext(), eventsSnapshot, category, method2, object)) - << "Test event must be present."; + << "Test event must be present."; ASSERT_TRUE(EventPresent(cx.GetJSContext(), eventsSnapshot, category, method, object2)) - << "Test event with value and extra must be present."; + << "Test event with value and extra must be present."; ASSERT_TRUE(EventPresent(cx.GetJSContext(), eventsSnapshot, category, method2, object2)) - << "Test event with truncated value and extra must be present."; + << "Test event with truncated value and extra must be present."; // Ensure that the truncations happened appropriately. JSContext* aCx = cx.GetJSContext(); JS::RootedObject arrayObj(aCx, &eventsSnapshot.toObject()); JS::Rooted eventRecord(aCx); ASSERT_TRUE(JS_GetElement(aCx, arrayObj, 2, &eventRecord)) - << "Must be able to get record."; + << "Must be able to get record."; JS::RootedObject recordArray(aCx, &eventRecord.toObject()); uint32_t recordLength; ASSERT_TRUE(JS_GetArrayLength(aCx, recordArray, &recordLength)) - << "Event record array must have length."; - ASSERT_TRUE(recordLength == 6) << "Event record must have 6 elements."; + << "Event record array must have length."; + ASSERT_TRUE(recordLength == 6) + << "Event record must have 6 elements."; JS::Rooted str(aCx); nsAutoJSString jsStr; // The value string is at index 4 ASSERT_TRUE(JS_GetElement(aCx, recordArray, 4, &str)) - << "Must be able to get value."; + << "Must be able to get value."; ASSERT_TRUE(jsStr.init(aCx, str)) - << "Value must be able to be init'd to a jsstring."; + << "Value must be able to be init'd to a jsstring."; ASSERT_EQ(NS_ConvertUTF16toUTF8(jsStr).Length(), (uint32_t)80) << "Value must have been truncated to 80 bytes."; // Extra is at index 5 JS::Rooted obj(aCx); ASSERT_TRUE(JS_GetElement(aCx, recordArray, 5, &obj)) - << "Must be able to get extra."; + << "Must be able to get extra."; JS::RootedObject extraObj(aCx, &obj.toObject()); JS::Rooted extraVal(aCx); ASSERT_TRUE(JS_GetProperty(aCx, extraObj, extraKey.get(), &extraVal)) - << "Must be able to get the extra key's value."; + << "Must be able to get the extra key's value."; ASSERT_TRUE(jsStr.init(aCx, extraVal)) - << "Extra must be able to be init'd to a jsstring."; + << "Extra must be able to be init'd to a jsstring."; ASSERT_EQ(NS_ConvertUTF16toUTF8(jsStr).Length(), (uint32_t)80) << "Extra must have been truncated to 80 bytes."; } diff --git a/toolkit/components/telemetry/tests/gtest/TestHistograms.cpp b/toolkit/components/telemetry/tests/gtest/TestHistograms.cpp index 3e845f046f9eb..0740d2578e981 100644 --- a/toolkit/components/telemetry/tests/gtest/TestHistograms.cpp +++ b/toolkit/components/telemetry/tests/gtest/TestHistograms.cpp @@ -121,7 +121,7 @@ TEST_F(TelemetryTestFixture, TestKeyedKeysHistogram) { JS::RootedValue expectedKeyData(cx.GetJSContext()); GetProperty(cx.GetJSContext(), "testkey", histogram, &expectedKeyData); ASSERT_TRUE(!expectedKeyData.isUndefined()) - << "Cannot find the expected key in the histogram data"; + << "Cannot find the expected key in the histogram data"; JS::RootedValue sum(cx.GetJSContext()); GetProperty(cx.GetJSContext(), "sum", expectedKeyData, &sum); uint32_t uSum = 0; @@ -132,7 +132,7 @@ TEST_F(TelemetryTestFixture, TestKeyedKeysHistogram) { // Do the same for the "CommonKey" property. GetProperty(cx.GetJSContext(), "CommonKey", histogram, &expectedKeyData); ASSERT_TRUE(!expectedKeyData.isUndefined()) - << "Cannot find the expected key in the histogram data"; + << "Cannot find the expected key in the histogram data"; GetProperty(cx.GetJSContext(), "sum", expectedKeyData, &sum); JS::ToUint32(cx.GetJSContext(), sum, &uSum); ASSERT_EQ(uSum, 1U) @@ -140,7 +140,7 @@ TEST_F(TelemetryTestFixture, TestKeyedKeysHistogram) { GetProperty(cx.GetJSContext(), "not-allowed", histogram, &expectedKeyData); ASSERT_TRUE(expectedKeyData.isUndefined()) - << "Unallowed keys must not be recorded in the histogram data"; + << "Unallowed keys must not be recorded in the histogram data"; // The 'not-allowed' key accumulation for 'TELEMETRY_TESTED_KEYED_KEYS' was // attemtped twice, so we expect the count of @@ -472,7 +472,7 @@ TEST_F(TelemetryTestFixture, TestKeyedLinearHistogram_MultipleSamples) { JS::RootedValue expectedKeyData(cx.GetJSContext()); GetProperty(cx.GetJSContext(), "testkey", histogram, &expectedKeyData); ASSERT_TRUE(!expectedKeyData.isUndefined()) - << "Cannot find the expected key in the histogram data"; + << "Cannot find the expected key in the histogram data"; // Get values object from 'testkey' histogram. JS::RootedValue values(cx.GetJSContext()); @@ -542,7 +542,7 @@ TEST_F(TelemetryTestFixture, TestKeyedKeysHistogram_MultipleSamples) { JS::RootedValue testKeyData(cx.GetJSContext()); GetProperty(cx.GetJSContext(), "testkey", histogram, &testKeyData); ASSERT_TRUE(!testKeyData.isUndefined()) - << "Cannot find the key 'testkey' in the histogram data"; + << "Cannot find the key 'testkey' in the histogram data"; JS::RootedValue values(cx.GetJSContext()); GetProperty(cx.GetJSContext(), "values", testKeyData, &values); @@ -588,8 +588,8 @@ TEST_F(TelemetryTestFixture, TestKeyedKeysHistogram_MultipleSamples) { JS::RootedValue commonKeyData(cx.GetJSContext()); GetProperty(cx.GetJSContext(), "CommonKey", histogram, &commonKeyData); ASSERT_TRUE(commonKeyData.isUndefined()) - << "Found data in key 'CommonKey' even though we accumulated no data to " - "it"; + << "Found data in key 'CommonKey' even though we accumulated no data to " + "it"; // Here we check that our function does not allow accumulation into unallowed // keys. Get 'not-allowed' property from histogram and check that this also @@ -597,8 +597,8 @@ TEST_F(TelemetryTestFixture, TestKeyedKeysHistogram_MultipleSamples) { JS::RootedValue notAllowedKeyData(cx.GetJSContext()); GetProperty(cx.GetJSContext(), "not-allowed", histogram, ¬AllowedKeyData); ASSERT_TRUE(notAllowedKeyData.isUndefined()) - << "Found data in key 'not-allowed' even though accumuling data to it is " - "not allowed"; + << "Found data in key 'not-allowed' even though accumuling data to it is " + "not allowed"; // The 'not-allowed' key accumulation for 'TELEMETRY_TESTED_KEYED_KEYS' was // attemtped once, so we expect the count of diff --git a/toolkit/components/telemetry/tests/gtest/TestOrigins.cpp b/toolkit/components/telemetry/tests/gtest/TestOrigins.cpp index 1b561e212c25a..8c0ce2c551bc8 100644 --- a/toolkit/components/telemetry/tests/gtest/TestOrigins.cpp +++ b/toolkit/components/telemetry/tests/gtest/TestOrigins.cpp @@ -41,13 +41,13 @@ TEST_F(TelemetryTestFixture, RecordOrigin) { JS::RootedValue origins(aCx); JS::RootedObject snapshotObj(aCx, &originSnapshot.toObject()); ASSERT_TRUE(JS_GetProperty(aCx, snapshotObj, telemetryTest1.get(), &origins)) - << "telemetry.test_test1 must be in the snapshot."; + << "telemetry.test_test1 must be in the snapshot."; JS::RootedObject originsObj(aCx, &origins.toObject()); JS::RootedValue count(aCx); ASSERT_TRUE(JS_GetProperty(aCx, originsObj, doubleclick.get(), &count)); ASSERT_TRUE(count.isInt32() && count.toInt32() == 1) - << "Must have recorded the origin exactly once."; + << "Must have recorded the origin exactly once."; // Now test that the snapshot didn't clear things out. GetOriginSnapshot(aCx, &originSnapshot); @@ -79,13 +79,13 @@ TEST_F(TelemetryTestFixture, RecordOriginTwiceAndClear) { JS::RootedValue origins(aCx); JS::RootedObject snapshotObj(aCx, &originSnapshot.toObject()); ASSERT_TRUE(JS_GetProperty(aCx, snapshotObj, telemetryTest1.get(), &origins)) - << "telemetry.test_test1 must be in the snapshot."; + << "telemetry.test_test1 must be in the snapshot."; JS::RootedObject originsObj(aCx, &origins.toObject()); JS::RootedValue count(aCx); ASSERT_TRUE(JS_GetProperty(aCx, originsObj, doubleclick.get(), &count)); ASSERT_TRUE(count.isInt32() && count.toInt32() == 2) - << "Must have recorded the origin exactly twice."; + << "Must have recorded the origin exactly twice."; // Now check that snapshotting with clear actually cleared it. GetOriginSnapshot(aCx, &originSnapshot); @@ -117,13 +117,13 @@ TEST_F(TelemetryTestFixture, RecordUnknownOrigin) { JS::RootedValue origins(aCx); JS::RootedObject snapshotObj(aCx, &originSnapshot.toObject()); ASSERT_TRUE(JS_GetProperty(aCx, snapshotObj, telemetryTest1.get(), &origins)) - << "telemetry.test_test1 must be in the snapshot."; + << "telemetry.test_test1 must be in the snapshot."; JS::RootedObject originsObj(aCx, &origins.toObject()); JS::RootedValue count(aCx); ASSERT_TRUE(JS_GetProperty(aCx, originsObj, "__UNKNOWN__", &count)); ASSERT_TRUE(count.isInt32() && count.toInt32() == 1) - << "Must have recorded the unknown origin exactly once."; + << "Must have recorded the unknown origin exactly once."; // Record a second, different unknown origin and ensure only one is stored. Telemetry::RecordOrigin(OriginMetricID::TelemetryTest_Test1, unknown2); @@ -135,13 +135,13 @@ TEST_F(TelemetryTestFixture, RecordUnknownOrigin) { JS::RootedObject snapshotObj2(aCx, &originSnapshot.toObject()); ASSERT_TRUE(JS_GetProperty(aCx, snapshotObj2, telemetryTest1.get(), &origins)) - << "telemetry.test_test1 must be in the snapshot."; + << "telemetry.test_test1 must be in the snapshot."; JS::RootedObject originsObj2(aCx, &origins.toObject()); JS::RootedValue count2(aCx); ASSERT_TRUE(JS_GetProperty(aCx, originsObj2, "__UNKNOWN__", &count2)); ASSERT_TRUE(count2.isInt32() && count2.toInt32() == 1) - << "Must have recorded the unknown origin exactly once."; + << "Must have recorded the unknown origin exactly once."; } TEST_F(TelemetryTestFixture, EncodedSnapshot) { @@ -176,13 +176,13 @@ TEST_F(TelemetryTestFixture, EncodedSnapshot) { secondAStr, secondBStr); ASSERT_TRUE(aStr != secondAStr) - << "aStr (" << NS_ConvertUTF16toUTF8(aStr).get() - << ") must not equal secondAStr (" - << NS_ConvertUTF16toUTF8(secondAStr).get() << ")"; + << "aStr (" << NS_ConvertUTF16toUTF8(aStr).get() + << ") must not equal secondAStr (" << NS_ConvertUTF16toUTF8(secondAStr).get() + << ")"; ASSERT_TRUE(bStr != secondBStr) - << "bStr (" << NS_ConvertUTF16toUTF8(bStr).get() - << ") must not equal secondBStr (" - << NS_ConvertUTF16toUTF8(secondBStr).get() << ")"; + << "bStr (" << NS_ConvertUTF16toUTF8(bStr).get() + << ") must not equal secondBStr (" << NS_ConvertUTF16toUTF8(secondBStr).get() + << ")"; } class MockObserver final : public nsIObserver { diff --git a/toolkit/components/telemetry/tests/gtest/TestScalars.cpp b/toolkit/components/telemetry/tests/gtest/TestScalars.cpp index 460feabba02e2..f2c94dbe56913 100644 --- a/toolkit/components/telemetry/tests/gtest/TestScalars.cpp +++ b/toolkit/components/telemetry/tests/gtest/TestScalars.cpp @@ -259,7 +259,8 @@ TEST_F(TelemetryTestFixture, ScalarUnknownID) { // Make sure that nothing was recorded in the plain scalars. JS::RootedValue scalarsSnapshot(cx.GetJSContext()); GetScalarsSnapshot(false, cx.GetJSContext(), &scalarsSnapshot); - ASSERT_TRUE(scalarsSnapshot.isUndefined()) << "No scalar must be recorded"; + ASSERT_TRUE(scalarsSnapshot.isUndefined()) + << "No scalar must be recorded"; // Same for the keyed scalars. Telemetry::ScalarSet(scalarId, NS_LITERAL_STRING("key1"), @@ -272,7 +273,7 @@ TEST_F(TelemetryTestFixture, ScalarUnknownID) { JS::RootedValue keyedSnapshot(cx.GetJSContext()); GetScalarsSnapshot(true, cx.GetJSContext(), &keyedSnapshot); ASSERT_TRUE(keyedSnapshot.isUndefined()) - << "No keyed scalar must be recorded"; + << "No keyed scalar must be recorded"; } #endif } diff --git a/toolkit/components/url-classifier/tests/gtest/TestCaching.cpp b/toolkit/components/url-classifier/tests/gtest/TestCaching.cpp index 6dfc7bd24df8b..2a259e7fdd36e 100644 --- a/toolkit/components/url-classifier/tests/gtest/TestCaching.cpp +++ b/toolkit/components/url-classifier/tests/gtest/TestCaching.cpp @@ -96,21 +96,24 @@ void TestCache(const _Fragment& aFragment, bool aExpectedHas, // This testcase check the returned result of |Has| API if fullhash cannot match // any prefix in the local database. -TEST(UrlClassifierCaching, NotFound) { +TEST(UrlClassifierCaching, NotFound) +{ TestCache(_Fragment("nomatch.com/"), false, false, false); TestCache(_Fragment("nomatch.com/"), false, false, false); } // This testcase check the returned result of |Has| API if fullhash find a match // in the local database but not in the cache. -TEST(UrlClassifierCaching, NotInCache) { +TEST(UrlClassifierCaching, NotInCache) +{ TestCache(_Fragment("gound.com/"), true, false, false); TestCache(_Fragment("gound.com/"), true, false, false); } // This testcase check the returned result of |Has| API if fullhash matches // a cache entry in positive cache. -TEST(UrlClassifierCaching, InPositiveCacheNotExpired) { +TEST(UrlClassifierCaching, InPositiveCacheNotExpired) +{ TestCache(_Fragment("cache.notexpired.com/"), true, true, true); TestCache(_Fragment("cache.notexpired.com/"), true, true, @@ -119,14 +122,16 @@ TEST(UrlClassifierCaching, InPositiveCacheNotExpired) { // This testcase check the returned result of |Has| API if fullhash matches // a cache entry in positive cache but that it is expired. -TEST(UrlClassifierCaching, InPositiveCacheExpired) { +TEST(UrlClassifierCaching, InPositiveCacheExpired) +{ TestCache(_Fragment("cache.expired.com/"), true, false, true); TestCache(_Fragment("cache.expired.com/"), true, false, true); } // This testcase check the returned result of |Has| API if fullhash matches // a cache entry in negative cache. -TEST(UrlClassifierCaching, InNegativeCacheNotExpired) { +TEST(UrlClassifierCaching, InNegativeCacheNotExpired) +{ // Create a fullhash whose prefix matches the prefix in negative cache // but completion doesn't match any fullhash in positive cache. @@ -148,7 +153,8 @@ TEST(UrlClassifierCaching, InNegativeCacheNotExpired) { // This testcase check the returned result of |Has| API if fullhash matches // a cache entry in negative cache but that entry is expired. -TEST(UrlClassifierCaching, InNegativeCacheExpired) { +TEST(UrlClassifierCaching, InNegativeCacheExpired) +{ // Create a fullhash whose prefix is in the cache. Completion prefix; @@ -209,18 +215,17 @@ void TestInvalidateExpiredCacheEntry() { TestCache(POS_CACHE_EXPIRED_URL, true, false, true, cache.get()); } -TEST(UrlClassifierCaching, InvalidateExpiredCacheEntryV2) { - TestInvalidateExpiredCacheEntry(); -} +TEST(UrlClassifierCaching, InvalidateExpiredCacheEntryV2) +{ TestInvalidateExpiredCacheEntry(); } -TEST(UrlClassifierCaching, InvalidateExpiredCacheEntryV4) { - TestInvalidateExpiredCacheEntry(); -} +TEST(UrlClassifierCaching, InvalidateExpiredCacheEntryV4) +{ TestInvalidateExpiredCacheEntry(); } // This testcase check if an cache entry whose negative cache time is expired // and it doesn't have any postive cache entries in it, it should be removed // from cache after calling |Has|. -TEST(UrlClassifierCaching, NegativeCacheExpireV2) { +TEST(UrlClassifierCaching, NegativeCacheExpireV2) +{ _PrefixArray array = {GeneratePrefix(NEG_CACHE_EXPIRED_URL, 8)}; RefPtr cache = SetupLookupCache(array); @@ -242,7 +247,8 @@ TEST(UrlClassifierCaching, NegativeCacheExpireV2) { cache.get()); } -TEST(UrlClassifierCaching, NegativeCacheExpireV4) { +TEST(UrlClassifierCaching, NegativeCacheExpireV4) +{ _PrefixArray array = {GeneratePrefix(NEG_CACHE_EXPIRED_URL, 8)}; RefPtr cache = SetupLookupCache(array); diff --git a/toolkit/components/url-classifier/tests/gtest/TestChunkSet.cpp b/toolkit/components/url-classifier/tests/gtest/TestChunkSet.cpp index c8da973edb231..8a10c97692f62 100644 --- a/toolkit/components/url-classifier/tests/gtest/TestChunkSet.cpp +++ b/toolkit/components/url-classifier/tests/gtest/TestChunkSet.cpp @@ -11,7 +11,8 @@ #include "ChunkSet.h" #include "mozilla/ArrayUtils.h" -TEST(UrlClassifierChunkSet, Empty) { +TEST(UrlClassifierChunkSet, Empty) +{ mozilla::safebrowsing::ChunkSet chunkSet; mozilla::safebrowsing::ChunkSet removeSet; @@ -31,7 +32,8 @@ TEST(UrlClassifierChunkSet, Empty) { ASSERT_TRUE(chunkSet.Length() == 0); } -TEST(UrlClassifierChunkSet, Main) { +TEST(UrlClassifierChunkSet, Main) +{ static int testVals[] = {2, 1, 5, 6, 8, 7, 14, 10, 12, 13}; mozilla::safebrowsing::ChunkSet chunkSet; @@ -52,7 +54,8 @@ TEST(UrlClassifierChunkSet, Main) { ASSERT_TRUE(chunkSet.Length() == MOZ_ARRAY_LENGTH(testVals)); } -TEST(UrlClassifierChunkSet, Merge) { +TEST(UrlClassifierChunkSet, Merge) +{ static int testVals[] = {2, 1, 5, 6, 8, 7, 14, 10, 12, 13}; static int mergeVals[] = {9, 3, 4, 20, 14, 16}; @@ -87,7 +90,8 @@ TEST(UrlClassifierChunkSet, Merge) { ASSERT_FALSE(chunkSet.Has(19)); } -TEST(UrlClassifierChunkSet, Merge2) { +TEST(UrlClassifierChunkSet, Merge2) +{ static int testVals[] = {2, 1, 5, 6, 8, 7, 14, 10, 12, 13}; static int mergeVals[] = {9, 3, 4, 20, 14, 16}; static int mergeVals2[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; @@ -126,7 +130,8 @@ TEST(UrlClassifierChunkSet, Merge2) { ASSERT_FALSE(chunkSet.Has(19)); } -TEST(UrlClassifierChunkSet, Stress) { +TEST(UrlClassifierChunkSet, Stress) +{ mozilla::safebrowsing::ChunkSet chunkSet; mozilla::safebrowsing::ChunkSet mergeSet; std::set refSet; @@ -210,7 +215,8 @@ TEST(UrlClassifierChunkSet, Stress) { } } -TEST(UrlClassifierChunkSet, RemoveClear) { +TEST(UrlClassifierChunkSet, RemoveClear) +{ static int testVals[] = {2, 1, 5, 6, 8, 7, 14, 10, 12, 13}; static int mergeVals[] = {3, 4, 9, 16, 20}; @@ -244,7 +250,8 @@ TEST(UrlClassifierChunkSet, RemoveClear) { } } -TEST(UrlClassifierChunkSet, Serialize) { +TEST(UrlClassifierChunkSet, Serialize) +{ static int testVals[] = {2, 1, 5, 6, 8, 7, 14, 10, 12, 13}; static int mergeVals[] = {3, 4, 9, 16, 20}; diff --git a/toolkit/components/url-classifier/tests/gtest/TestClassifier.cpp b/toolkit/components/url-classifier/tests/gtest/TestClassifier.cpp index fb371ed9ba2d2..2d19853990435 100644 --- a/toolkit/components/url-classifier/tests/gtest/TestClassifier.cpp +++ b/toolkit/components/url-classifier/tests/gtest/TestClassifier.cpp @@ -93,7 +93,8 @@ static void TestReadNoiseEntries(RefPtr classifier, } } -TEST(UrlClassifier, ReadNoiseEntriesV4) { +TEST(UrlClassifier, ReadNoiseEntriesV4) +{ RefPtr classifier = GetClassifier(); _PrefixArray array = { GeneratePrefix(_Fragment("bravo.com/"), 5), @@ -114,7 +115,8 @@ TEST(UrlClassifier, ReadNoiseEntriesV4) { _Fragment("gound.com/")); } -TEST(UrlClassifier, ReadNoiseEntriesV2) { +TEST(UrlClassifier, ReadNoiseEntriesV2) +{ RefPtr classifier = GetClassifier(); _PrefixArray array = { GeneratePrefix(_Fragment("helloworld.com/"), 4), diff --git a/toolkit/components/url-classifier/tests/gtest/TestFailUpdate.cpp b/toolkit/components/url-classifier/tests/gtest/TestFailUpdate.cpp index db8bbb40f7300..59cc40c0aa706 100644 --- a/toolkit/components/url-classifier/tests/gtest/TestFailUpdate.cpp +++ b/toolkit/components/url-classifier/tests/gtest/TestFailUpdate.cpp @@ -32,7 +32,8 @@ void CheckFileExist(const char* table, const T (&files)[N], bool expectExists) { } } -TEST(UrlClassifierFailUpdate, CheckTableReset) { +TEST(UrlClassifierFailUpdate, CheckTableReset) +{ const bool FULL_UPDATE = true; const bool PARTIAL_UPDATE = false; diff --git a/toolkit/components/url-classifier/tests/gtest/TestFindFullHash.cpp b/toolkit/components/url-classifier/tests/gtest/TestFindFullHash.cpp index 4a7712c1bafb3..2aec10c510f36 100644 --- a/toolkit/components/url-classifier/tests/gtest/TestFindFullHash.cpp +++ b/toolkit/components/url-classifier/tests/gtest/TestFindFullHash.cpp @@ -36,7 +36,8 @@ Base64EncodedStringArray MakeBase64EncodedStringArray(nsCString (&aArray)[N]) { } // end of unnamed namespace. -TEST(UrlClassifierFindFullHash, Request) { +TEST(UrlClassifierFindFullHash, Request) +{ nsUrlClassifierUtils* urlUtil = nsUrlClassifierUtils::GetInstance(); const char* listNames[] = {"test-phish-proto", "test-unwanted-proto"}; @@ -188,7 +189,8 @@ NS_IMPL_ISUPPORTS(MyParseCallback, nsIUrlClassifierParseFindFullHashCallback) } // end of unnamed namespace. -TEST(UrlClassifierFindFullHash, ParseRequest) { +TEST(UrlClassifierFindFullHash, ParseRequest) +{ // Build response. FindFullHashesResponse r; diff --git a/toolkit/components/url-classifier/tests/gtest/TestLookupCacheV4.cpp b/toolkit/components/url-classifier/tests/gtest/TestLookupCacheV4.cpp index 837e2873859b4..602bd0a6603c8 100644 --- a/toolkit/components/url-classifier/tests/gtest/TestLookupCacheV4.cpp +++ b/toolkit/components/url-classifier/tests/gtest/TestLookupCacheV4.cpp @@ -32,20 +32,18 @@ void TestHasPrefix(const _Fragment& aFragment, bool aExpectedHas, }); } -TEST(UrlClassifierLookupCacheV4, HasComplete) { - TestHasPrefix(_Fragment("bravo.com/"), true, true); -} +TEST(UrlClassifierLookupCacheV4, HasComplete) +{ TestHasPrefix(_Fragment("bravo.com/"), true, true); } -TEST(UrlClassifierLookupCacheV4, HasPrefix) { - TestHasPrefix(_Fragment("browsing.com/"), true, false); -} +TEST(UrlClassifierLookupCacheV4, HasPrefix) +{ TestHasPrefix(_Fragment("browsing.com/"), true, false); } -TEST(UrlClassifierLookupCacheV4, Nomatch) { - TestHasPrefix(_Fragment("nomatch.com/"), false, false); -} +TEST(UrlClassifierLookupCacheV4, Nomatch) +{ TestHasPrefix(_Fragment("nomatch.com/"), false, false); } // Test an existing .pset should be removed after .vlpset is written -TEST(UrlClassifierLookupCacheV4, RemoveOldPset) { +TEST(UrlClassifierLookupCacheV4, RemoveOldPset) +{ nsCOMPtr oldPsetFile; NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(oldPsetFile)); @@ -90,7 +88,8 @@ TEST(UrlClassifierLookupCacheV4, RemoveOldPset) { } // Test the legacy load -TEST(UrlClassifierLookupCacheV4, LoadOldPset) { +TEST(UrlClassifierLookupCacheV4, LoadOldPset) +{ nsCOMPtr oldPsetFile; _PrefixArray array = {GeneratePrefix(_Fragment("entry.com/"), 4)}; diff --git a/toolkit/components/url-classifier/tests/gtest/TestPerProviderDirectory.cpp b/toolkit/components/url-classifier/tests/gtest/TestPerProviderDirectory.cpp index 48b3bbb52211e..c3f9553a35f77 100644 --- a/toolkit/components/url-classifier/tests/gtest/TestPerProviderDirectory.cpp +++ b/toolkit/components/url-classifier/tests/gtest/TestPerProviderDirectory.cpp @@ -58,7 +58,8 @@ void VerifyPrivateStorePath(T* target, const nsCString& aTableName, ASSERT_TRUE(privateStorePath == expectedPrivateStorePath); } -TEST(UrlClassifierPerProviderDirectory, LookupCache) { +TEST(UrlClassifierPerProviderDirectory, LookupCache) +{ RunTestInNewThread([]() -> void { nsCOMPtr rootDir; NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(rootDir)); @@ -91,7 +92,8 @@ TEST(UrlClassifierPerProviderDirectory, LookupCache) { }); } -TEST(UrlClassifierPerProviderDirectory, HashStore) { +TEST(UrlClassifierPerProviderDirectory, HashStore) +{ RunTestInNewThread([]() -> void { nsCOMPtr rootDir; NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(rootDir)); diff --git a/toolkit/components/url-classifier/tests/gtest/TestProtocolParser.cpp b/toolkit/components/url-classifier/tests/gtest/TestProtocolParser.cpp index 2b2a603095eb1..b84420e789b84 100644 --- a/toolkit/components/url-classifier/tests/gtest/TestProtocolParser.cpp +++ b/toolkit/components/url-classifier/tests/gtest/TestProtocolParser.cpp @@ -18,7 +18,8 @@ static bool InitUpdateResponse(ListUpdateResponse* aUpdateResponse, static void DumpBinary(const nsACString& aBinary); -TEST(UrlClassifierProtocolParser, UpdateWait) { +TEST(UrlClassifierProtocolParser, UpdateWait) +{ // Top level response which contains a list of update response // for different lists. FetchThreatListUpdatesResponse response; @@ -45,7 +46,8 @@ TEST(UrlClassifierProtocolParser, UpdateWait) { delete p; } -TEST(UrlClassifierProtocolParser, SingleValueEncoding) { +TEST(UrlClassifierProtocolParser, SingleValueEncoding) +{ // Top level response which contains a list of update response // for different lists. FetchThreatListUpdatesResponse response; diff --git a/toolkit/components/url-classifier/tests/gtest/TestRiceDeltaDecoder.cpp b/toolkit/components/url-classifier/tests/gtest/TestRiceDeltaDecoder.cpp index e88377b6e29ea..b41080720e0fc 100644 --- a/toolkit/components/url-classifier/tests/gtest/TestRiceDeltaDecoder.cpp +++ b/toolkit/components/url-classifier/tests/gtest/TestRiceDeltaDecoder.cpp @@ -16,7 +16,8 @@ struct TestingData { static bool runOneTest(TestingData& aData); -TEST(UrlClassifierRiceDeltaDecoder, SingleEncodedValue) { +TEST(UrlClassifierRiceDeltaDecoder, SingleEncodedValue) +{ TestingData td = {{99}, {99}, 0}; ASSERT_TRUE(runOneTest(td)); @@ -25,7 +26,8 @@ TEST(UrlClassifierRiceDeltaDecoder, SingleEncodedValue) { // In this batch of tests, the encoded data would be like // what we originally receive from the network. See comment // in |runOneTest| for more detail. -TEST(UrlClassifierRiceDeltaDecoder, Empty) { +TEST(UrlClassifierRiceDeltaDecoder, Empty) +{ // The following structure and testing data is copied from Chromium source // code: // diff --git a/toolkit/components/url-classifier/tests/gtest/TestSafeBrowsingProtobuf.cpp b/toolkit/components/url-classifier/tests/gtest/TestSafeBrowsingProtobuf.cpp index cd8864e22e757..e38be00fe742d 100644 --- a/toolkit/components/url-classifier/tests/gtest/TestSafeBrowsingProtobuf.cpp +++ b/toolkit/components/url-classifier/tests/gtest/TestSafeBrowsingProtobuf.cpp @@ -1,7 +1,8 @@ #include "safebrowsing.pb.h" #include "gtest/gtest.h" -TEST(UrlClassifierProtobuf, Empty) { +TEST(UrlClassifierProtobuf, Empty) +{ using namespace mozilla::safebrowsing; const std::string CLIENT_ID = "firefox"; diff --git a/toolkit/components/url-classifier/tests/gtest/TestSafebrowsingHash.cpp b/toolkit/components/url-classifier/tests/gtest/TestSafebrowsingHash.cpp index f09f846111e29..27eca5fd494e1 100644 --- a/toolkit/components/url-classifier/tests/gtest/TestSafebrowsingHash.cpp +++ b/toolkit/components/url-classifier/tests/gtest/TestSafebrowsingHash.cpp @@ -1,7 +1,8 @@ #include "Entries.h" #include "mozilla/EndianUtils.h" -TEST(UrlClassifierHash, ToFromUint32) { +TEST(UrlClassifierHash, ToFromUint32) +{ using namespace mozilla::safebrowsing; // typedef SafebrowsingHash Prefix; @@ -19,7 +20,8 @@ TEST(UrlClassifierHash, ToFromUint32) { ASSERT_EQ(memcmp(PREFIX_RAW, p.buf, 4), 0); } -TEST(UrlClassifierHash, Compare) { +TEST(UrlClassifierHash, Compare) +{ using namespace mozilla; using namespace mozilla::safebrowsing; diff --git a/toolkit/components/url-classifier/tests/gtest/TestTable.cpp b/toolkit/components/url-classifier/tests/gtest/TestTable.cpp index dec4c34a08041..bfb27bbd72932 100644 --- a/toolkit/components/url-classifier/tests/gtest/TestTable.cpp +++ b/toolkit/components/url-classifier/tests/gtest/TestTable.cpp @@ -8,7 +8,8 @@ void TestResponseCode(const char* table, nsresult result) { ASSERT_EQ(TablesToResponse(tableName), result); } -TEST(UrlClassifierTable, ResponseCode) { +TEST(UrlClassifierTable, ResponseCode) +{ // malware URIs. TestResponseCode("goog-malware-shavar", NS_ERROR_MALWARE_URI); TestResponseCode("test-malware-simple", NS_ERROR_MALWARE_URI); diff --git a/toolkit/components/url-classifier/tests/gtest/TestUrlClassifierTableUpdateV4.cpp b/toolkit/components/url-classifier/tests/gtest/TestUrlClassifierTableUpdateV4.cpp index cfffef4b8c44d..9f1bb2d4fa2f4 100644 --- a/toolkit/components/url-classifier/tests/gtest/TestUrlClassifierTableUpdateV4.cpp +++ b/toolkit/components/url-classifier/tests/gtest/TestUrlClassifierTableUpdateV4.cpp @@ -234,7 +234,8 @@ static void testOpenLookupCache() { } // Tests start from here. -TEST(UrlClassifierTableUpdateV4, FixLengthPSetFullUpdate) { +TEST(UrlClassifierTableUpdateV4, FixLengthPSetFullUpdate) +{ srand(time(NULL)); _PrefixArray array; @@ -250,7 +251,8 @@ TEST(UrlClassifierTableUpdateV4, FixLengthPSetFullUpdate) { Clear(); } -TEST(UrlClassifierTableUpdateV4, VariableLengthPSetFullUpdate) { +TEST(UrlClassifierTableUpdateV4, VariableLengthPSetFullUpdate) +{ _PrefixArray array; PrefixStringMap map; nsCString sha256; @@ -265,7 +267,8 @@ TEST(UrlClassifierTableUpdateV4, VariableLengthPSetFullUpdate) { } // This test contain both variable length prefix set and fixed-length prefix set -TEST(UrlClassifierTableUpdateV4, MixedPSetFullUpdate) { +TEST(UrlClassifierTableUpdateV4, MixedPSetFullUpdate) +{ _PrefixArray array; PrefixStringMap map; nsCString sha256; @@ -280,7 +283,8 @@ TEST(UrlClassifierTableUpdateV4, MixedPSetFullUpdate) { Clear(); } -TEST(UrlClassifierTableUpdateV4, PartialUpdateWithRemoval) { +TEST(UrlClassifierTableUpdateV4, PartialUpdateWithRemoval) +{ _PrefixArray fArray; // Apply a full update first. @@ -323,7 +327,8 @@ TEST(UrlClassifierTableUpdateV4, PartialUpdateWithRemoval) { Clear(); } -TEST(UrlClassifierTableUpdateV4, PartialUpdateWithoutRemoval) { +TEST(UrlClassifierTableUpdateV4, PartialUpdateWithoutRemoval) +{ _PrefixArray fArray; // Apply a full update first. @@ -363,7 +368,8 @@ TEST(UrlClassifierTableUpdateV4, PartialUpdateWithoutRemoval) { // Expect failure because partial update contains prefix already // in old prefix set. -TEST(UrlClassifierTableUpdateV4, PartialUpdatePrefixAlreadyExist) { +TEST(UrlClassifierTableUpdateV4, PartialUpdatePrefixAlreadyExist) +{ _PrefixArray fArray; // Apply a full update fist. @@ -399,7 +405,8 @@ TEST(UrlClassifierTableUpdateV4, PartialUpdatePrefixAlreadyExist) { } // Test apply partial update directly without applying an full update first. -TEST(UrlClassifierTableUpdateV4, OnlyPartialUpdate) { +TEST(UrlClassifierTableUpdateV4, OnlyPartialUpdate) +{ _PrefixArray pArray; PrefixStringMap pMap; nsCString sha256; @@ -415,7 +422,8 @@ TEST(UrlClassifierTableUpdateV4, OnlyPartialUpdate) { } // Test partial update without any ADD prefixes, only removalIndices. -TEST(UrlClassifierTableUpdateV4, PartialUpdateOnlyRemoval) { +TEST(UrlClassifierTableUpdateV4, PartialUpdateOnlyRemoval) +{ _PrefixArray fArray; // Apply a full update first. @@ -452,7 +460,8 @@ TEST(UrlClassifierTableUpdateV4, PartialUpdateOnlyRemoval) { } // Test one tableupdate array contains full update and multiple partial updates. -TEST(UrlClassifierTableUpdateV4, MultipleTableUpdates) { +TEST(UrlClassifierTableUpdateV4, MultipleTableUpdates) +{ _PrefixArray fArray, pArray, mergedArray; PrefixStringMap fMap, pMap, mergedMap; nsCString sha256; @@ -505,7 +514,8 @@ TEST(UrlClassifierTableUpdateV4, MultipleTableUpdates) { // Test apply full update first, and then apply multiple partial updates // in one tableupdate array. -TEST(UrlClassifierTableUpdateV4, MultiplePartialUpdateTableUpdates) { +TEST(UrlClassifierTableUpdateV4, MultiplePartialUpdateTableUpdates) +{ _PrefixArray fArray; // Apply a full update first @@ -573,7 +583,8 @@ TEST(UrlClassifierTableUpdateV4, MultiplePartialUpdateTableUpdates) { } // Test removal indices are larger than the original prefix set. -TEST(UrlClassifierTableUpdateV4, RemovalIndexTooLarge) { +TEST(UrlClassifierTableUpdateV4, RemovalIndexTooLarge) +{ _PrefixArray fArray; // Apply a full update first @@ -611,7 +622,8 @@ TEST(UrlClassifierTableUpdateV4, RemovalIndexTooLarge) { Clear(); } -TEST(UrlClassifierTableUpdateV4, ChecksumMismatch) { +TEST(UrlClassifierTableUpdateV4, ChecksumMismatch) +{ // Apply a full update first { _PrefixArray fArray; @@ -647,7 +659,8 @@ TEST(UrlClassifierTableUpdateV4, ChecksumMismatch) { Clear(); } -TEST(UrlClassifierTableUpdateV4, ApplyUpdateThenLoad) { +TEST(UrlClassifierTableUpdateV4, ApplyUpdateThenLoad) +{ // Apply update with sha256 { _PrefixArray fArray; @@ -683,7 +696,8 @@ TEST(UrlClassifierTableUpdateV4, ApplyUpdateThenLoad) { } // This test is used to avoid an eror from nsICryptoHash -TEST(UrlClassifierTableUpdateV4, ApplyUpdateWithFixedChecksum) { +TEST(UrlClassifierTableUpdateV4, ApplyUpdateWithFixedChecksum) +{ _PrefixArray fArray = {_Prefix("enus"), _Prefix("apollo"), _Prefix("mars"), @@ -723,7 +737,8 @@ TEST(UrlClassifierTableUpdateV4, ApplyUpdateWithFixedChecksum) { // This test ensure that an empty update works correctly. Empty update // should be skipped by CheckValidUpdate in Classifier::UpdateTableV4. -TEST(UrlClassifierTableUpdateV4, EmptyUpdate) { +TEST(UrlClassifierTableUpdateV4, EmptyUpdate) +{ PrefixStringMap emptyAddition; nsTArray emptyRemoval; @@ -756,7 +771,8 @@ TEST(UrlClassifierTableUpdateV4, EmptyUpdate) { // This test ensure applying an empty update directly through update algorithm // should be correct. -TEST(UrlClassifierTableUpdateV4, EmptyUpdate2) { +TEST(UrlClassifierTableUpdateV4, EmptyUpdate2) +{ // Setup LookupCache with initial data _PrefixArray array; CreateRandomSortedPrefixArray(100, 4, 4, array); diff --git a/toolkit/components/url-classifier/tests/gtest/TestUrlClassifierUtils.cpp b/toolkit/components/url-classifier/tests/gtest/TestUrlClassifierUtils.cpp index 025263cc28225..57f6c684bbd3a 100644 --- a/toolkit/components/url-classifier/tests/gtest/TestUrlClassifierUtils.cpp +++ b/toolkit/components/url-classifier/tests/gtest/TestUrlClassifierUtils.cpp @@ -29,7 +29,8 @@ void TestUnescapeHelper(const char* in, const char* expected) { } // Make sure Unescape from nsEncode.h's unescape does what the server does. -TEST(UrlClassifierUtils, Unescape) { +TEST(UrlClassifierUtils, Unescape) +{ // test empty string TestUnescapeHelper("\0", "\0"); @@ -80,7 +81,8 @@ void TestEncodeHelper(const char* in, const char* expected) { CheckEquals(strExp, out); } -TEST(UrlClassifierUtils, Enc) { +TEST(UrlClassifierUtils, Enc) +{ // Test empty string TestEncodeHelper("", ""); @@ -119,7 +121,8 @@ void TestCanonicalizeHelper(const char* in, const char* expected) { CheckEquals(strExp, out); } -TEST(UrlClassifierUtils, Canonicalize) { +TEST(UrlClassifierUtils, Canonicalize) +{ // Test repeated %-decoding. Note: %25 --> %, %32 --> 2, %35 --> 5 TestCanonicalizeHelper("%25", "%25"); TestCanonicalizeHelper("%25%32%35", "%25"); @@ -152,7 +155,8 @@ void TestParseIPAddressHelper(const char* in, const char* expected) { CheckEquals(strExp, out); } -TEST(UrlClassifierUtils, ParseIPAddress) { +TEST(UrlClassifierUtils, ParseIPAddress) +{ TestParseIPAddressHelper("123.123.0.0.1", ""); TestParseIPAddressHelper("255.0.0.1", "255.0.0.1"); TestParseIPAddressHelper("12.0x12.01234", "12.18.2.156"); @@ -181,7 +185,8 @@ void TestCanonicalNumHelper(const char* in, uint32_t bytes, bool allowOctal, CheckEquals(strExp, out); } -TEST(UrlClassifierUtils, CanonicalNum) { +TEST(UrlClassifierUtils, CanonicalNum) +{ TestCanonicalNumHelper("", 1, true, ""); TestCanonicalNumHelper("10", 0, true, ""); TestCanonicalNumHelper("45", 1, true, "45"); @@ -204,7 +209,8 @@ void TestHostnameHelper(const char* in, const char* expected) { CheckEquals(strExp, out); } -TEST(UrlClassifierUtils, Hostname) { +TEST(UrlClassifierUtils, Hostname) +{ TestHostnameHelper("abcd123;[]", "abcd123;[]"); TestHostnameHelper("abc.123", "abc.123"); TestHostnameHelper("abc..123", "abc.123"); @@ -227,7 +233,8 @@ TEST(UrlClassifierUtils, Hostname) { TestHostnameHelper("%00", "%00"); } -TEST(UrlClassifierUtils, LongHostname) { +TEST(UrlClassifierUtils, LongHostname) +{ static const int kTestSize = 1024 * 150; char* str = static_cast(malloc(kTestSize + 1)); memset(str, 'x', kTestSize); diff --git a/toolkit/components/url-classifier/tests/gtest/TestVariableLengthPrefixSet.cpp b/toolkit/components/url-classifier/tests/gtest/TestVariableLengthPrefixSet.cpp index 1166d570f7bcd..bb7c804c98404 100644 --- a/toolkit/components/url-classifier/tests/gtest/TestVariableLengthPrefixSet.cpp +++ b/toolkit/components/url-classifier/tests/gtest/TestVariableLengthPrefixSet.cpp @@ -171,7 +171,8 @@ static already_AddRefed SetupLookupCache( } // Test setting prefix set with only 4-bytes prefixes -TEST(UrlClassifierVLPrefixSet, FixedLengthSet) { +TEST(UrlClassifierVLPrefixSet, FixedLengthSet) +{ srand(time(nullptr)); RefPtr cache = SetupLookupCache(NS_LITERAL_CSTRING("test")); @@ -204,7 +205,8 @@ TEST(UrlClassifierVLPrefixSet, FixedLengthSet) { } // Test setting prefix set with only 5~32 bytes prefixes -TEST(UrlClassifierVLPrefixSet, VariableLengthSet) { +TEST(UrlClassifierVLPrefixSet, VariableLengthSet) +{ RefPtr cache = SetupLookupCache(NS_LITERAL_CSTRING("test")); PrefixStringMap map; @@ -240,7 +242,8 @@ TEST(UrlClassifierVLPrefixSet, VariableLengthSet) { } // Test setting prefix set with both 4-bytes prefixes and 5~32 bytes prefixes -TEST(UrlClassifierVLPrefixSet, MixedPrefixSet) { +TEST(UrlClassifierVLPrefixSet, MixedPrefixSet) +{ RefPtr cache = SetupLookupCache(NS_LITERAL_CSTRING("test")); PrefixStringMap map; @@ -285,7 +288,8 @@ TEST(UrlClassifierVLPrefixSet, MixedPrefixSet) { } // Test resetting prefix set -TEST(UrlClassifierVLPrefixSet, ResetPrefix) { +TEST(UrlClassifierVLPrefixSet, ResetPrefix) +{ RefPtr cache = SetupLookupCache(NS_LITERAL_CSTRING("test")); // First prefix set @@ -335,7 +339,8 @@ TEST(UrlClassifierVLPrefixSet, ResetPrefix) { } // Test only set one 4-bytes prefix and one full-length prefix -TEST(UrlClassifierVLPrefixSet, TinyPrefixSet) { +TEST(UrlClassifierVLPrefixSet, TinyPrefixSet) +{ RefPtr cache = SetupLookupCache(NS_LITERAL_CSTRING("test")); PrefixStringMap map; @@ -353,7 +358,8 @@ TEST(UrlClassifierVLPrefixSet, TinyPrefixSet) { } // Test empty prefix set and IsEmpty function -TEST(UrlClassifierVLPrefixSet, EmptyPrefixSet) { +TEST(UrlClassifierVLPrefixSet, EmptyPrefixSet) +{ RefPtr cache = SetupLookupCache(NS_LITERAL_CSTRING("test")); bool empty = cache->IsEmpty(); @@ -384,7 +390,8 @@ TEST(UrlClassifierVLPrefixSet, EmptyPrefixSet) { } // Test prefix size should only between 4~32 bytes -TEST(UrlClassifierVLPrefixSet, MinMaxPrefixSet) { +TEST(UrlClassifierVLPrefixSet, MinMaxPrefixSet) +{ RefPtr cache = SetupLookupCache(NS_LITERAL_CSTRING("test")); PrefixStringMap map; @@ -417,7 +424,8 @@ TEST(UrlClassifierVLPrefixSet, MinMaxPrefixSet) { } // Test save then load prefix set with only 4-bytes prefixes -TEST(UrlClassifierVLPrefixSet, LoadSaveFixedLengthPrefixSet) { +TEST(UrlClassifierVLPrefixSet, LoadSaveFixedLengthPrefixSet) +{ nsCOMPtr file; _PrefixArray array; PrefixStringMap map; @@ -456,7 +464,8 @@ TEST(UrlClassifierVLPrefixSet, LoadSaveFixedLengthPrefixSet) { } // Test save then load prefix set with only 5~32 bytes prefixes -TEST(UrlClassifierVLPrefixSet, LoadSaveVariableLengthPrefixSet) { +TEST(UrlClassifierVLPrefixSet, LoadSaveVariableLengthPrefixSet) +{ nsCOMPtr file; _PrefixArray array; PrefixStringMap map; @@ -495,7 +504,8 @@ TEST(UrlClassifierVLPrefixSet, LoadSaveVariableLengthPrefixSet) { } // Test save then load prefix with both 4 bytes prefixes and 5~32 bytes prefixes -TEST(UrlClassifierVLPrefixSet, LoadSavePrefixSet) { +TEST(UrlClassifierVLPrefixSet, LoadSavePrefixSet) +{ nsCOMPtr file; _PrefixArray array; PrefixStringMap map; @@ -536,7 +546,8 @@ TEST(UrlClassifierVLPrefixSet, LoadSavePrefixSet) { } // This is for fixed-length prefixset -TEST(UrlClassifierVLPrefixSet, LoadSaveNoDelta) { +TEST(UrlClassifierVLPrefixSet, LoadSaveNoDelta) +{ nsCOMPtr file; _PrefixArray array; PrefixStringMap map; diff --git a/toolkit/crashreporter/minidump-analyzer/Win64ModuleUnwindMetadata.cpp b/toolkit/crashreporter/minidump-analyzer/Win64ModuleUnwindMetadata.cpp index 544a95944c8ed..22e08ed1af5c4 100644 --- a/toolkit/crashreporter/minidump-analyzer/Win64ModuleUnwindMetadata.cpp +++ b/toolkit/crashreporter/minidump-analyzer/Win64ModuleUnwindMetadata.cpp @@ -184,7 +184,9 @@ bool ModuleUnwindParser::GenerateCFIForFunction( rip_offset += 80; break; } - default: { return false; } + default: { + return false; + } } } diff --git a/toolkit/crashreporter/test/gtest/TestCrashThreadAnnotation.cpp b/toolkit/crashreporter/test/gtest/TestCrashThreadAnnotation.cpp index 76544b42496f7..fad719a79b22f 100644 --- a/toolkit/crashreporter/test/gtest/TestCrashThreadAnnotation.cpp +++ b/toolkit/crashreporter/test/gtest/TestCrashThreadAnnotation.cpp @@ -22,12 +22,14 @@ using mozilla::UniquePtr; namespace CrashReporter { namespace { -TEST(TestCrashThreadAnnotation, TestInitShutdown) { +TEST(TestCrashThreadAnnotation, TestInitShutdown) +{ InitThreadAnnotation(); ShutdownThreadAnnotation(); } -TEST(TestCrashThreadAnnotation, TestNestedInitShutdown) { +TEST(TestCrashThreadAnnotation, TestNestedInitShutdown) +{ // No bad things should happen in case we have extra init/shutdown calls. InitThreadAnnotation(); InitThreadAnnotation(); @@ -35,28 +37,32 @@ TEST(TestCrashThreadAnnotation, TestNestedInitShutdown) { ShutdownThreadAnnotation(); } -TEST(TestCrashThreadAnnotation, TestUnbalancedInit) { +TEST(TestCrashThreadAnnotation, TestUnbalancedInit) +{ // No bad things should happen in case we have unbalanced init/shutdown calls. InitThreadAnnotation(); InitThreadAnnotation(); ShutdownThreadAnnotation(); } -TEST(TestCrashThreadAnnotation, TestUnbalancedShutdown) { +TEST(TestCrashThreadAnnotation, TestUnbalancedShutdown) +{ // No bad things should happen in case we have unbalanced init/shutdown calls. InitThreadAnnotation(); ShutdownThreadAnnotation(); ShutdownThreadAnnotation(); } -TEST(TestCrashThreadAnnotation, TestGetFlatThreadAnnotation_BeforeInit) { +TEST(TestCrashThreadAnnotation, TestGetFlatThreadAnnotation_BeforeInit) +{ // GetFlatThreadAnnotation() should not return anything before init. std::function getThreadAnnotationCB = [&](const char* aAnnotation) -> void { ASSERT_STREQ(aAnnotation, ""); }; GetFlatThreadAnnotation(getThreadAnnotationCB); } -TEST(TestCrashThreadAnnotation, TestGetFlatThreadAnnotation_AfterShutdown) { +TEST(TestCrashThreadAnnotation, TestGetFlatThreadAnnotation_AfterShutdown) +{ // GetFlatThreadAnnotation() should not return anything after shutdown. InitThreadAnnotation(); ShutdownThreadAnnotation(); @@ -82,7 +88,8 @@ already_AddRefed CreateTestThread(const char* aName, return thread.forget(); } -TEST(TestCrashThreadAnnotation, TestGetFlatThreadAnnotation_OneThread) { +TEST(TestCrashThreadAnnotation, TestGetFlatThreadAnnotation_OneThread) +{ InitThreadAnnotation(); Monitor monitor("TestCrashThreadAnnotation"); @@ -109,7 +116,8 @@ TEST(TestCrashThreadAnnotation, TestGetFlatThreadAnnotation_OneThread) { thread->Shutdown(); } -TEST(TestCrashThreadAnnotation, TestGetFlatThreadAnnotation_SetNameTwice) { +TEST(TestCrashThreadAnnotation, TestGetFlatThreadAnnotation_SetNameTwice) +{ InitThreadAnnotation(); Monitor monitor("TestCrashThreadAnnotation"); @@ -149,7 +157,8 @@ TEST(TestCrashThreadAnnotation, TestGetFlatThreadAnnotation_SetNameTwice) { thread->Shutdown(); } -TEST(TestCrashThreadAnnotation, TestGetFlatThreadAnnotation_TwoThreads) { +TEST(TestCrashThreadAnnotation, TestGetFlatThreadAnnotation_TwoThreads) +{ InitThreadAnnotation(); Monitor monitor("TestCrashThreadAnnotation"); @@ -185,7 +194,8 @@ TEST(TestCrashThreadAnnotation, TestGetFlatThreadAnnotation_TwoThreads) { thread2->Shutdown(); } -TEST(TestCrashThreadAnnotation, TestGetFlatThreadAnnotation_ShutdownOneThread) { +TEST(TestCrashThreadAnnotation, TestGetFlatThreadAnnotation_ShutdownOneThread) +{ InitThreadAnnotation(); Monitor monitor("TestCrashThreadAnnotation"); @@ -223,8 +233,8 @@ TEST(TestCrashThreadAnnotation, TestGetFlatThreadAnnotation_ShutdownOneThread) { thread2->Shutdown(); } -TEST(TestCrashThreadAnnotation, - TestGetFlatThreadAnnotation_ShutdownBothThreads) { +TEST(TestCrashThreadAnnotation, TestGetFlatThreadAnnotation_ShutdownBothThreads) +{ InitThreadAnnotation(); Monitor monitor("TestCrashThreadAnnotation"); @@ -263,7 +273,8 @@ TEST(TestCrashThreadAnnotation, } TEST(TestCrashThreadAnnotation, - TestGetFlatThreadAnnotation_TestNameOfBaseThread) { + TestGetFlatThreadAnnotation_TestNameOfBaseThread) +{ InitThreadAnnotation(); Monitor monitor("TestCrashThreadAnnotation"); @@ -290,7 +301,8 @@ TEST(TestCrashThreadAnnotation, } TEST(TestCrashThreadAnnotation, - TestGetFlatThreadAnnotation_TestShutdownBaseThread) { + TestGetFlatThreadAnnotation_TestShutdownBaseThread) +{ InitThreadAnnotation(); Monitor monitor("TestCrashThreadAnnotation"); @@ -318,7 +330,8 @@ TEST(TestCrashThreadAnnotation, } TEST(TestCrashThreadAnnotation, - TestGetFlatThreadAnnotation_TestShutdownBothBaseThreads) { + TestGetFlatThreadAnnotation_TestShutdownBothBaseThreads) +{ InitThreadAnnotation(); Monitor monitor("TestCrashThreadAnnotation"); diff --git a/toolkit/profile/gtest/TestProfileLock.cpp b/toolkit/profile/gtest/TestProfileLock.cpp index 3226c90fd4768..918a41bf7dcc8 100644 --- a/toolkit/profile/gtest/TestProfileLock.cpp +++ b/toolkit/profile/gtest/TestProfileLock.cpp @@ -11,7 +11,8 @@ #include "nsString.h" #include "nsDirectoryServiceDefs.h" -TEST(ProfileLock, BasicLock) { +TEST(ProfileLock, BasicLock) +{ char tmpExt[] = "profilebasiclocktest"; nsProfileLock myLock; diff --git a/toolkit/profile/gtest/TestProfileLockRetry.cpp b/toolkit/profile/gtest/TestProfileLockRetry.cpp index 9b01ead61e546..4e2bc8d2ea388 100644 --- a/toolkit/profile/gtest/TestProfileLockRetry.cpp +++ b/toolkit/profile/gtest/TestProfileLockRetry.cpp @@ -13,7 +13,8 @@ #include "nsProfileLock.h" #include "nsString.h" -TEST(ProfileLock, RetryLock) { +TEST(ProfileLock, RetryLock) +{ char templ[] = "/tmp/profilelocktest.XXXXXX"; char* tmpdir = mkdtemp(templ); ASSERT_NE(tmpdir, nullptr); diff --git a/toolkit/recordreplay/HashTable.cpp b/toolkit/recordreplay/HashTable.cpp index 941637e6b60fc..8eefd5d1e8f6f 100644 --- a/toolkit/recordreplay/HashTable.cpp +++ b/toolkit/recordreplay/HashTable.cpp @@ -396,11 +396,12 @@ static uint32_t PLHashComputeHash(void* aKey, PLHashTableInfo* aInfo) { MOZ_RELEASE_ASSERT(!aInfo->IsDestroyed()); uint32_t originalHash = aInfo->mKeyHash(aKey); HashNumber newHash; - if (aInfo->HasMatchingKey(originalHash, - [=](const void* aExistingKey) { - return aInfo->mKeyCompare(aKey, aExistingKey); - }, - &newHash)) { + if (aInfo->HasMatchingKey( + originalHash, + [=](const void* aExistingKey) { + return aInfo->mKeyCompare(aKey, aExistingKey); + }, + &newHash)) { return newHash; } return aInfo->SetLastKey(aKey); @@ -480,12 +481,13 @@ static PLDHashNumber PLDHashTableComputeHash(const void* aKey, MOZ_RELEASE_ASSERT(!aInfo->IsDestroyed()); uint32_t originalHash = aInfo->mOps->hashKey(aKey); HashNumber newHash; - if (aInfo->HasMatchingKey(originalHash, - [=](const void* aExistingKey) { - return aInfo->mOps->matchEntry( - (PLDHashEntryHdr*)aExistingKey, aKey); - }, - &newHash)) { + if (aInfo->HasMatchingKey( + originalHash, + [=](const void* aExistingKey) { + return aInfo->mOps->matchEntry((PLDHashEntryHdr*)aExistingKey, + aKey); + }, + &newHash)) { return newHash; } return aInfo->SetLastKey(aKey); diff --git a/toolkit/system/osxproxy/tests/gtest/TestProxyBypassRules.cpp b/toolkit/system/osxproxy/tests/gtest/TestProxyBypassRules.cpp index 52d9ee3c49a44..4ca88094e4540 100644 --- a/toolkit/system/osxproxy/tests/gtest/TestProxyBypassRules.cpp +++ b/toolkit/system/osxproxy/tests/gtest/TestProxyBypassRules.cpp @@ -9,7 +9,8 @@ using namespace mozilla::toolkit::system; -TEST(OSXProxy, TestProxyBypassRules) { +TEST(OSXProxy, TestProxyBypassRules) +{ EXPECT_TRUE(IsHostProxyEntry(NS_LITERAL_CSTRING("mozilla.org"), NS_LITERAL_CSTRING("mozilla.org"))); EXPECT_TRUE(IsHostProxyEntry(NS_LITERAL_CSTRING("mozilla.org"), @@ -26,7 +27,8 @@ TEST(OSXProxy, TestProxyBypassRules) { NS_LITERAL_CSTRING("*.mozilla.*"))); } -TEST(OSXProxy, TestProxyBypassRulesIPv4) { +TEST(OSXProxy, TestProxyBypassRulesIPv4) +{ EXPECT_TRUE(IsHostProxyEntry(NS_LITERAL_CSTRING("192.168.1.1"), NS_LITERAL_CSTRING("192.168.1.*"))); EXPECT_FALSE(IsHostProxyEntry(NS_LITERAL_CSTRING("192.168.1.1"), @@ -44,7 +46,8 @@ TEST(OSXProxy, TestProxyBypassRulesIPv4) { NS_LITERAL_CSTRING("192.168.1.1/32"))); } -TEST(OSXProxy, TestProxyBypassRulesIPv6) { +TEST(OSXProxy, TestProxyBypassRulesIPv6) +{ EXPECT_TRUE(IsHostProxyEntry( NS_LITERAL_CSTRING("2001:0DB8:ABCD:0012:0123:4567:89AB:CDEF"), NS_LITERAL_CSTRING("2001:db8:abcd:0012::0/64"))); diff --git a/toolkit/system/windowsproxy/tests/gtest/TestProxyBypassRules.cpp b/toolkit/system/windowsproxy/tests/gtest/TestProxyBypassRules.cpp index be663ff35ae82..2ac193823cc8e 100644 --- a/toolkit/system/windowsproxy/tests/gtest/TestProxyBypassRules.cpp +++ b/toolkit/system/windowsproxy/tests/gtest/TestProxyBypassRules.cpp @@ -9,7 +9,8 @@ using namespace mozilla::toolkit::system; -TEST(WindowsProxy, TestProxyBypassRules) { +TEST(WindowsProxy, TestProxyBypassRules) +{ EXPECT_TRUE(IsHostProxyEntry(NS_LITERAL_CSTRING("mozilla.org"), NS_LITERAL_CSTRING("mozilla.org"))); EXPECT_TRUE(IsHostProxyEntry(NS_LITERAL_CSTRING("mozilla.org"), @@ -26,7 +27,8 @@ TEST(WindowsProxy, TestProxyBypassRules) { NS_LITERAL_CSTRING("*.mozilla.*"))); } -TEST(WindowsProxy, TestProxyBypassRulesIPv4) { +TEST(WindowsProxy, TestProxyBypassRulesIPv4) +{ EXPECT_TRUE(IsHostProxyEntry(NS_LITERAL_CSTRING("192.168.1.1"), NS_LITERAL_CSTRING("192.168.1.*"))); EXPECT_FALSE(IsHostProxyEntry(NS_LITERAL_CSTRING("192.168.1.1"), @@ -44,7 +46,8 @@ TEST(WindowsProxy, TestProxyBypassRulesIPv4) { NS_LITERAL_CSTRING("192.168.1.1/32"))); } -TEST(WindowsProxy, TestProxyBypassRulesIPv6) { +TEST(WindowsProxy, TestProxyBypassRulesIPv6) +{ EXPECT_TRUE(IsHostProxyEntry( NS_LITERAL_CSTRING("2001:0DB8:ABCD:0012:0123:4567:89AB:CDEF"), NS_LITERAL_CSTRING("2001:db8:abcd:0012::0/64"))); diff --git a/tools/fuzzing/interface/FuzzingInterfaceStream.h b/tools/fuzzing/interface/FuzzingInterfaceStream.h index 64ad2a8efd289..7cd87f54c8006 100644 --- a/tools/fuzzing/interface/FuzzingInterfaceStream.h +++ b/tools/fuzzing/interface/FuzzingInterfaceStream.h @@ -52,7 +52,8 @@ void afl_interface_stream(const char* testFile, FuzzingTestFuncStream testFunc); std::string testFile(testFilePtr); # define MOZ_AFL_INTERFACE_STREAM(initFunc, testFunc, moduleName) \ - TEST(AFL, moduleName) { \ + TEST(AFL, moduleName) \ + { \ MOZ_AFL_INTERFACE_COMMON(initFunc); \ ::mozilla::afl_interface_stream(testFile.c_str(), testFunc); \ } diff --git a/tools/profiler/gecko/nsProfiler.cpp b/tools/profiler/gecko/nsProfiler.cpp index a3ce6dcbf2c41..70e8ca0cc0f19 100644 --- a/tools/profiler/gecko/nsProfiler.cpp +++ b/tools/profiler/gecko/nsProfiler.cpp @@ -249,41 +249,42 @@ nsProfiler::GetProfileDataAsync(double aSinceTime, JSContext* aCx, } StartGathering(aSinceTime) - ->Then(GetMainThreadSerialEventTarget(), __func__, - [promise](nsCString aResult) { - AutoJSAPI jsapi; - if (NS_WARN_IF(!jsapi.Init(promise->GlobalJSObject()))) { - // We're really hosed if we can't get a JS context for some - // reason. - promise->MaybeReject(NS_ERROR_DOM_UNKNOWN_ERR); - return; - } - - JSContext* cx = jsapi.cx(); - - // Now parse the JSON so that we resolve with a JS Object. - JS::RootedValue val(cx); - { - NS_ConvertUTF8toUTF16 js_string(aResult); - if (!JS_ParseJSON( - cx, static_cast(js_string.get()), - js_string.Length(), &val)) { - if (!jsapi.HasException()) { - promise->MaybeReject(NS_ERROR_DOM_UNKNOWN_ERR); - } else { - JS::RootedValue exn(cx); - DebugOnly gotException = jsapi.StealException(&exn); - MOZ_ASSERT(gotException); - - jsapi.ClearException(); - promise->MaybeReject(cx, exn); - } - } else { - promise->MaybeResolve(val); - } - } - }, - [promise](nsresult aRv) { promise->MaybeReject(aRv); }); + ->Then( + GetMainThreadSerialEventTarget(), __func__, + [promise](nsCString aResult) { + AutoJSAPI jsapi; + if (NS_WARN_IF(!jsapi.Init(promise->GlobalJSObject()))) { + // We're really hosed if we can't get a JS context for some + // reason. + promise->MaybeReject(NS_ERROR_DOM_UNKNOWN_ERR); + return; + } + + JSContext* cx = jsapi.cx(); + + // Now parse the JSON so that we resolve with a JS Object. + JS::RootedValue val(cx); + { + NS_ConvertUTF8toUTF16 js_string(aResult); + if (!JS_ParseJSON(cx, + static_cast(js_string.get()), + js_string.Length(), &val)) { + if (!jsapi.HasException()) { + promise->MaybeReject(NS_ERROR_DOM_UNKNOWN_ERR); + } else { + JS::RootedValue exn(cx); + DebugOnly gotException = jsapi.StealException(&exn); + MOZ_ASSERT(gotException); + + jsapi.ClearException(); + promise->MaybeReject(cx, exn); + } + } else { + promise->MaybeResolve(val); + } + } + }, + [promise](nsresult aRv) { promise->MaybeReject(aRv); }); promise.forget(aPromise); return NS_OK; @@ -314,28 +315,29 @@ nsProfiler::GetProfileDataAsArrayBuffer(double aSinceTime, JSContext* aCx, } StartGathering(aSinceTime) - ->Then(GetMainThreadSerialEventTarget(), __func__, - [promise](nsCString aResult) { - AutoJSAPI jsapi; - if (NS_WARN_IF(!jsapi.Init(promise->GlobalJSObject()))) { - // We're really hosed if we can't get a JS context for some - // reason. - promise->MaybeReject(NS_ERROR_DOM_UNKNOWN_ERR); - return; - } - - JSContext* cx = jsapi.cx(); - JSObject* typedArray = dom::ArrayBuffer::Create( - cx, aResult.Length(), - reinterpret_cast(aResult.Data())); - if (typedArray) { - JS::RootedValue val(cx, JS::ObjectValue(*typedArray)); - promise->MaybeResolve(val); - } else { - promise->MaybeReject(NS_ERROR_OUT_OF_MEMORY); - } - }, - [promise](nsresult aRv) { promise->MaybeReject(aRv); }); + ->Then( + GetMainThreadSerialEventTarget(), __func__, + [promise](nsCString aResult) { + AutoJSAPI jsapi; + if (NS_WARN_IF(!jsapi.Init(promise->GlobalJSObject()))) { + // We're really hosed if we can't get a JS context for some + // reason. + promise->MaybeReject(NS_ERROR_DOM_UNKNOWN_ERR); + return; + } + + JSContext* cx = jsapi.cx(); + JSObject* typedArray = dom::ArrayBuffer::Create( + cx, aResult.Length(), + reinterpret_cast(aResult.Data())); + if (typedArray) { + JS::RootedValue val(cx, JS::ObjectValue(*typedArray)); + promise->MaybeResolve(val); + } else { + promise->MaybeReject(NS_ERROR_OUT_OF_MEMORY); + } + }, + [promise](nsresult aRv) { promise->MaybeReject(aRv); }); promise.forget(aPromise); return NS_OK; @@ -369,24 +371,25 @@ nsProfiler::DumpProfileToFileAsync(const nsACString& aFilename, nsCString filename(aFilename); StartGathering(aSinceTime) - ->Then(GetMainThreadSerialEventTarget(), __func__, - [filename, promise](const nsCString& aResult) { - nsCOMPtr file = - do_CreateInstance(NS_LOCAL_FILE_CONTRACTID); - nsresult rv = file->InitWithNativePath(filename); - if (NS_FAILED(rv)) { - MOZ_CRASH(); - } - nsCOMPtr of = do_CreateInstance( - "@mozilla.org/network/file-output-stream;1"); - of->Init(file, -1, -1, 0); - uint32_t sz; - of->Write(aResult.get(), aResult.Length(), &sz); - of->Close(); - - promise->MaybeResolveWithUndefined(); - }, - [promise](nsresult aRv) { promise->MaybeReject(aRv); }); + ->Then( + GetMainThreadSerialEventTarget(), __func__, + [filename, promise](const nsCString& aResult) { + nsCOMPtr file = + do_CreateInstance(NS_LOCAL_FILE_CONTRACTID); + nsresult rv = file->InitWithNativePath(filename); + if (NS_FAILED(rv)) { + MOZ_CRASH(); + } + nsCOMPtr of = + do_CreateInstance("@mozilla.org/network/file-output-stream;1"); + of->Init(file, -1, -1, 0); + uint32_t sz; + of->Write(aResult.get(), aResult.Length(), &sz); + of->Close(); + + promise->MaybeResolveWithUndefined(); + }, + [promise](nsresult aRv) { promise->MaybeReject(aRv); }); promise.forget(aPromise); return NS_OK; @@ -620,15 +623,16 @@ RefPtr nsProfiler::StartGathering( mPendingProfiles = profiles.Length(); RefPtr self = this; for (auto profile : profiles) { - profile->Then(GetMainThreadSerialEventTarget(), __func__, - [self](mozilla::ipc::Shmem&& aResult) { - const nsDependentCSubstring profileString( - aResult.get(), aResult.Size() - 1); - self->GatheredOOPProfile(profileString); - }, - [self](ipc::ResponseRejectReason&& aReason) { - self->GatheredOOPProfile(NS_LITERAL_CSTRING("")); - }); + profile->Then( + GetMainThreadSerialEventTarget(), __func__, + [self](mozilla::ipc::Shmem&& aResult) { + const nsDependentCSubstring profileString(aResult.get(), + aResult.Size() - 1); + self->GatheredOOPProfile(profileString); + }, + [self](ipc::ResponseRejectReason&& aReason) { + self->GatheredOOPProfile(NS_LITERAL_CSTRING("")); + }); } if (!mPendingProfiles) { FinishGathering(); diff --git a/tools/profiler/tests/gtest/GeckoProfiler.cpp b/tools/profiler/tests/gtest/GeckoProfiler.cpp index 1651b31ea2a82..2adbc137e5f35 100644 --- a/tools/profiler/tests/gtest/GeckoProfiler.cpp +++ b/tools/profiler/tests/gtest/GeckoProfiler.cpp @@ -77,7 +77,8 @@ static void ActiveParamsCheck(int aEntries, double aInterval, } } -TEST(GeckoProfiler, FeaturesAndParams) { +TEST(GeckoProfiler, FeaturesAndParams) +{ InactiveFeaturesAndParamsCheck(); // Try a couple of features and filters. @@ -195,7 +196,8 @@ TEST(GeckoProfiler, FeaturesAndParams) { } } -TEST(GeckoProfiler, EnsureStarted) { +TEST(GeckoProfiler, EnsureStarted) +{ InactiveFeaturesAndParamsCheck(); uint32_t features = ProfilerFeature::JS | ProfilerFeature::Threads; @@ -265,7 +267,8 @@ TEST(GeckoProfiler, EnsureStarted) { } } -TEST(GeckoProfiler, DifferentThreads) { +TEST(GeckoProfiler, DifferentThreads) +{ InactiveFeaturesAndParamsCheck(); nsCOMPtr thread; @@ -337,7 +340,8 @@ TEST(GeckoProfiler, DifferentThreads) { thread->Shutdown(); } -TEST(GeckoProfiler, GetBacktrace) { +TEST(GeckoProfiler, GetBacktrace) +{ ASSERT_TRUE(!profiler_get_backtrace()); { @@ -383,7 +387,8 @@ TEST(GeckoProfiler, GetBacktrace) { ASSERT_TRUE(!profiler_get_backtrace()); } -TEST(GeckoProfiler, Pause) { +TEST(GeckoProfiler, Pause) +{ uint32_t features = ProfilerFeature::StackWalk; const char* filters[] = {"GeckoMain"}; @@ -452,7 +457,8 @@ int GTestMarkerPayload::sNumCreated = 0; int GTestMarkerPayload::sNumStreamed = 0; int GTestMarkerPayload::sNumDestroyed = 0; -TEST(GeckoProfiler, Markers) { +TEST(GeckoProfiler, Markers) +{ uint32_t features = ProfilerFeature::StackWalk; const char* filters[] = {"GeckoMain"}; @@ -556,7 +562,8 @@ TEST(GeckoProfiler, Markers) { ASSERT_TRUE(GTestMarkerPayload::sNumDestroyed == 20); } -TEST(GeckoProfiler, DurationLimit) { +TEST(GeckoProfiler, DurationLimit) +{ uint32_t features = ProfilerFeature::StackWalk; const char* filters[] = {"GeckoMain"}; @@ -592,7 +599,8 @@ TEST(GeckoProfiler, DurationLimit) { PROFILER_DEFINE_COUNT_TOTAL(TestCounter, COUNTER_NAME, COUNTER_DESCRIPTION); PROFILER_DEFINE_COUNT_TOTAL(TestCounter2, COUNTER_NAME2, COUNTER_DESCRIPTION2); -TEST(GeckoProfiler, Counters) { +TEST(GeckoProfiler, Counters) +{ uint32_t features = ProfilerFeature::Threads; const char* filters[] = {"GeckoMain", "Compositor"}; @@ -633,7 +641,8 @@ TEST(GeckoProfiler, Counters) { profiler_stop(); } -TEST(GeckoProfiler, Time) { +TEST(GeckoProfiler, Time) +{ uint32_t features = ProfilerFeature::StackWalk; const char* filters[] = {"GeckoMain"}; @@ -656,7 +665,8 @@ TEST(GeckoProfiler, Time) { ASSERT_TRUE(t4 <= t5 && t1 <= t6); } -TEST(GeckoProfiler, GetProfile) { +TEST(GeckoProfiler, GetProfile) +{ uint32_t features = ProfilerFeature::StackWalk; const char* filters[] = {"GeckoMain"}; @@ -694,7 +704,8 @@ static void JSONOutputCheck(const char* aOutput) { ASSERT_TRUE(strstr(aOutput, "\"stringTable\"")); } -TEST(GeckoProfiler, StreamJSONForThisProcess) { +TEST(GeckoProfiler, StreamJSONForThisProcess) +{ uint32_t features = ProfilerFeature::StackWalk; const char* filters[] = {"GeckoMain"}; @@ -717,7 +728,8 @@ TEST(GeckoProfiler, StreamJSONForThisProcess) { ASSERT_TRUE(!profiler_stream_json_for_this_process(w)); } -TEST(GeckoProfiler, StreamJSONForThisProcessThreaded) { +TEST(GeckoProfiler, StreamJSONForThisProcessThreaded) +{ // Same as the previous test, but calling some things on background threads. nsCOMPtr thread; nsresult rv = NS_NewNamedThread("GeckoProfGTest", getter_AddRefs(thread)); @@ -764,7 +776,8 @@ TEST(GeckoProfiler, StreamJSONForThisProcessThreaded) { ASSERT_TRUE(!profiler_stream_json_for_this_process(w)); } -TEST(GeckoProfiler, ProfilingStack) { +TEST(GeckoProfiler, ProfilingStack) +{ uint32_t features = ProfilerFeature::StackWalk; const char* filters[] = {"GeckoMain"}; @@ -794,7 +807,8 @@ TEST(GeckoProfiler, ProfilingStack) { ASSERT_TRUE(!profiler_get_profile()); } -TEST(GeckoProfiler, Bug1355807) { +TEST(GeckoProfiler, Bug1355807) +{ uint32_t features = ProfilerFeature::JS; const char* manyThreadsFilter[] = {""}; const char* fewThreadsFilter[] = {"GeckoMain"}; @@ -846,7 +860,8 @@ void DoSuspendAndSample(int aTid, nsIThread* aThread) { NS_DISPATCH_SYNC); } -TEST(GeckoProfiler, SuspendAndSample) { +TEST(GeckoProfiler, SuspendAndSample) +{ nsCOMPtr thread; nsresult rv = NS_NewNamedThread("GeckoProfGTest", getter_AddRefs(thread)); ASSERT_TRUE(NS_SUCCEEDED(rv)); diff --git a/tools/profiler/tests/gtest/LulTest.cpp b/tools/profiler/tests/gtest/LulTest.cpp index 35f67697c8553..94a0b2fd29c10 100644 --- a/tools/profiler/tests/gtest/LulTest.cpp +++ b/tools/profiler/tests/gtest/LulTest.cpp @@ -31,7 +31,8 @@ static void gtest_logging_sink_for_LulIntegration(const char* str) { } } -TEST(LulIntegration, unwind_consistency) { +TEST(LulIntegration, unwind_consistency) +{ // Set up LUL and get it to read unwind info for libxul.so, which is // all we care about here, plus (incidentally) practically every // other object in the process too. diff --git a/tools/profiler/tests/gtest/ThreadProfileTest.cpp b/tools/profiler/tests/gtest/ThreadProfileTest.cpp index ed14b620b0382..425cd1a1efdf2 100644 --- a/tools/profiler/tests/gtest/ThreadProfileTest.cpp +++ b/tools/profiler/tests/gtest/ThreadProfileTest.cpp @@ -10,7 +10,8 @@ #include "gtest/gtest.h" // Make sure we can record one entry and read it -TEST(ThreadProfile, InsertOneEntry) { +TEST(ThreadProfile, InsertOneEntry) +{ auto pb = MakeUnique(10); pb->AddEntry(ProfileBufferEntry::Time(123.1)); ASSERT_TRUE(pb->GetEntry(pb->mRangeStart).IsTime()); @@ -18,7 +19,8 @@ TEST(ThreadProfile, InsertOneEntry) { } // See if we can insert some entries -TEST(ThreadProfile, InsertEntriesNoWrap) { +TEST(ThreadProfile, InsertEntriesNoWrap) +{ auto pb = MakeUnique(100); int test_size = 50; for (int i = 0; i < test_size; i++) { @@ -33,7 +35,8 @@ TEST(ThreadProfile, InsertEntriesNoWrap) { } // See if evicting works as it should in the basic case -TEST(ThreadProfile, InsertEntriesWrap) { +TEST(ThreadProfile, InsertEntriesWrap) +{ int entries = 32; auto pb = MakeUnique(entries); ASSERT_TRUE(pb->mRangeStart == 0); diff --git a/widget/PuppetWidget.cpp b/widget/PuppetWidget.cpp index f5ad1fc59b810..9b0ddb74e2b41 100644 --- a/widget/PuppetWidget.cpp +++ b/widget/PuppetWidget.cpp @@ -772,13 +772,14 @@ nsresult PuppetWidget::NotifyIMEOfFocusChange( IMENotificationRequests(IMENotificationRequests::NOTIFY_ALL); RefPtr self = this; mTabChild->SendNotifyIMEFocus(mContentCache, aIMENotification) - ->Then(mTabChild->TabGroup()->EventTargetFor(TaskCategory::UI), __func__, - [self](IMENotificationRequests&& aRequests) { - self->mIMENotificationRequestsOfParent = aRequests; - }, - [self](mozilla::ipc::ResponseRejectReason&& aReason) { - NS_WARNING("SendNotifyIMEFocus got rejected."); - }); + ->Then( + mTabChild->TabGroup()->EventTargetFor(TaskCategory::UI), __func__, + [self](IMENotificationRequests&& aRequests) { + self->mIMENotificationRequestsOfParent = aRequests; + }, + [self](mozilla::ipc::ResponseRejectReason&& aReason) { + NS_WARNING("SendNotifyIMEFocus got rejected."); + }); return NS_OK; } diff --git a/widget/cocoa/nsPrintDialogX.mm b/widget/cocoa/nsPrintDialogX.mm index c7547080b04ce..7e2ab57cedcf6 100644 --- a/widget/cocoa/nsPrintDialogX.mm +++ b/widget/cocoa/nsPrintDialogX.mm @@ -51,8 +51,7 @@ // from prefs. Reading printer-specific prefs requires the printer // name to be set. settingsX->SetPrinterNameFromPrintInfo(); - printSettingsSvc->InitPrintSettingsFromPrefs(settingsX, true, - nsIPrintSettings::kInitSaveAll); + printSettingsSvc->InitPrintSettingsFromPrefs(settingsX, true, nsIPrintSettings::kInitSaveAll); // Set the print job title char16_t** docTitles; uint32_t titleCount; diff --git a/widget/gtk/nsFilePicker.cpp b/widget/gtk/nsFilePicker.cpp index f50ae4e426e9f..12e38f26bf3b4 100644 --- a/widget/gtk/nsFilePicker.cpp +++ b/widget/gtk/nsFilePicker.cpp @@ -420,15 +420,15 @@ nsFilePicker::Open(nsIFilePickerShownCallback *aCallback) { if (GTK_IS_DIALOG(file_chooser)) { GtkDialog *dialog = GTK_DIALOG(file_chooser); GtkContainer *area = GTK_CONTAINER(gtk_dialog_get_content_area(dialog)); - gtk_container_forall(area, - [](GtkWidget *widget, gpointer data) { - if (GTK_IS_FILE_CHOOSER_WIDGET(widget)) { - auto result = - static_cast(data); - *result = GTK_FILE_CHOOSER_WIDGET(widget); - } - }, - &mFileChooserDelegate); + gtk_container_forall( + area, + [](GtkWidget *widget, gpointer data) { + if (GTK_IS_FILE_CHOOSER_WIDGET(widget)) { + auto result = static_cast(data); + *result = GTK_FILE_CHOOSER_WIDGET(widget); + } + }, + &mFileChooserDelegate); if (mFileChooserDelegate != nullptr) { g_object_ref(mFileChooserDelegate); diff --git a/widget/gtk/nsNativeThemeGTK.cpp b/widget/gtk/nsNativeThemeGTK.cpp index 1ecc9f6cd81a4..46fc869b58441 100644 --- a/widget/gtk/nsNativeThemeGTK.cpp +++ b/widget/gtk/nsNativeThemeGTK.cpp @@ -1355,7 +1355,9 @@ LayoutDeviceIntMargin nsNativeThemeGTK::GetWidgetBorder( // will need to fall through and use the default case as before. if (IsRegularMenuItem(aFrame)) break; MOZ_FALLTHROUGH; - default: { GetCachedWidgetBorder(aFrame, aAppearance, direction, &result); } + default: { + GetCachedWidgetBorder(aFrame, aAppearance, direction, &result); + } } gint scale = GetMonitorScaleFactor(aFrame); diff --git a/widget/windows/ToastNotificationHandler.cpp b/widget/windows/ToastNotificationHandler.cpp index 6416021a02665..e1e36d6c4003c 100644 --- a/widget/windows/ToastNotificationHandler.cpp +++ b/widget/windows/ToastNotificationHandler.cpp @@ -350,8 +350,7 @@ bool ToastNotificationHandler::CreateWindowsNotificationFromXml( Callback([self](IToastNotification* aNotification, IInspectable* aInspectable) { return self->OnActivate(aNotification, aInspectable); - }) - .Get(), + }).Get(), &mActivatedToken); if (NS_WARN_IF(FAILED(hr))) { return false; @@ -361,8 +360,7 @@ bool ToastNotificationHandler::CreateWindowsNotificationFromXml( Callback([self](IToastNotification* aNotification, IToastDismissedEventArgs* aArgs) { return self->OnDismiss(aNotification, aArgs); - }) - .Get(), + }).Get(), &mDismissedToken); if (NS_WARN_IF(FAILED(hr))) { return false; @@ -372,8 +370,7 @@ bool ToastNotificationHandler::CreateWindowsNotificationFromXml( Callback([self](IToastNotification* aNotification, IToastFailedEventArgs* aArgs) { return self->OnFail(aNotification, aArgs); - }) - .Get(), + }).Get(), &mFailedToken); if (NS_WARN_IF(FAILED(hr))) { return false; diff --git a/widget/windows/nsClipboard.cpp b/widget/windows/nsClipboard.cpp index ec48b441d7845..c942cedefa207 100644 --- a/widget/windows/nsClipboard.cpp +++ b/widget/windows/nsClipboard.cpp @@ -287,7 +287,8 @@ nsresult nsClipboard::GetGlobalData(HGLOBAL aHGBL, void** aData, nsresult result = NS_ERROR_FAILURE; if (aHGBL != nullptr) { LPSTR lpStr = (LPSTR)GlobalLock(aHGBL); - CheckedInt allocSize = CheckedInt(GlobalSize(aHGBL)) + 3; + CheckedInt allocSize = + CheckedInt(GlobalSize(aHGBL)) + 3; if (!allocSize.isValid()) { return NS_ERROR_INVALID_ARG; } diff --git a/xpcom/base/nsSystemInfo.cpp b/xpcom/base/nsSystemInfo.cpp index 708c0174453c8..05b9f0f62381d 100644 --- a/xpcom/base/nsSystemInfo.cpp +++ b/xpcom/base/nsSystemInfo.cpp @@ -733,9 +733,9 @@ nsresult nsSystemInfo::Init() { #ifdef XP_WIN // IsWow64Process2 is only available on Windows 10+, so we have to dynamically // check for its existence. - typedef BOOL(WINAPI* LPFN_IWP2)(HANDLE, USHORT*, USHORT*); - LPFN_IWP2 iwp2 = reinterpret_cast(GetProcAddress( - GetModuleHandle(L"kernel32"), "IsWow64Process2")); + typedef BOOL(WINAPI * LPFN_IWP2)(HANDLE, USHORT*, USHORT*); + LPFN_IWP2 iwp2 = reinterpret_cast( + GetProcAddress(GetModuleHandle(L"kernel32"), "IsWow64Process2")); BOOL isWow64 = false; USHORT processMachine = IMAGE_FILE_MACHINE_UNKNOWN; USHORT nativeMachine = IMAGE_FILE_MACHINE_UNKNOWN; diff --git a/xpcom/ds/PLDHashTable.cpp b/xpcom/ds/PLDHashTable.cpp index 37b21f9ea2ade..002699a9fe488 100644 --- a/xpcom/ds/PLDHashTable.cpp +++ b/xpcom/ds/PLDHashTable.cpp @@ -555,12 +555,12 @@ PLDHashEntryHdr* PLDHashTable::Add(const void* aKey, // Look for entry after possibly growing, so we don't have to add it, // then skip it while growing the table and re-add it after. PLDHashNumber keyHash = ComputeKeyHash(aKey); - Slot slot = SearchTable(aKey, keyHash, - [&](Slot& found) -> Slot { return found; }, - [&]() -> Slot { - MOZ_CRASH("Nope"); - return Slot(nullptr, nullptr); - }); + Slot slot = SearchTable( + aKey, keyHash, [&](Slot& found) -> Slot { return found; }, + [&]() -> Slot { + MOZ_CRASH("Nope"); + return Slot(nullptr, nullptr); + }); if (!slot.IsLive()) { // Initialize the slot, indicating that it's no longer free. if (slot.IsRemoved()) { @@ -606,14 +606,15 @@ void PLDHashTable::Remove(const void* aKey) { } PLDHashNumber keyHash = ComputeKeyHash(aKey); - SearchTable(aKey, keyHash, - [&](Slot& slot) { - RawRemove(slot); - ShrinkIfAppropriate(); - }, - [&]() { - // Do nothing. - }); + SearchTable( + aKey, keyHash, + [&](Slot& slot) { + RawRemove(slot); + ShrinkIfAppropriate(); + }, + [&]() { + // Do nothing. + }); } void PLDHashTable::RemoveEntry(PLDHashEntryHdr* aEntry) { diff --git a/xpcom/ds/nsTArray.h b/xpcom/ds/nsTArray.h index b7d371a4d18c5..e299fa4c9ac5b 100644 --- a/xpcom/ds/nsTArray.h +++ b/xpcom/ds/nsTArray.h @@ -1131,8 +1131,8 @@ class nsTArray_Impl // @return true if the element was found. template bool Contains(const Item& aItem, const Comparator& aComp) const { - return ApplyIf(aItem, 0, aComp, []() { return true; }, - []() { return false; }); + return ApplyIf( + aItem, 0, aComp, []() { return true; }, []() { return false; }); } // Like Contains(), but assumes a sorted array. @@ -1513,11 +1513,12 @@ class nsTArray_Impl ::detail::CompareWrapper comp(aComp); size_t index; - BinarySearchIf(Elements(), 0, Length(), - [&](const elem_type& aElement) { - return comp.Compare(aElement, aItem) <= 0 ? 1 : -1; - }, - &index); + BinarySearchIf( + Elements(), 0, Length(), + [&](const elem_type& aElement) { + return comp.Compare(aElement, aItem) <= 0 ? 1 : -1; + }, + &index); return index; } diff --git a/xpcom/reflect/xptinfo/xptinfo.h b/xpcom/reflect/xptinfo/xptinfo.h index 555c08ad03ff1..a9ae321f891c4 100644 --- a/xpcom/reflect/xptinfo/xptinfo.h +++ b/xpcom/reflect/xptinfo/xptinfo.h @@ -213,7 +213,9 @@ struct nsXPTType { private: // Helper for reading 16-bit data values split between mData1 and mData2. - uint16_t Data16() const { return static_cast(mData1 << 8) | mData2; } + uint16_t Data16() const { + return static_cast(mData1 << 8) | mData2; + } public: // Get the type of the element in the current array or sequence. Arrays only diff --git a/xpcom/rust/gtest/nsstring/Test.cpp b/xpcom/rust/gtest/nsstring/Test.cpp index 8e74bd31ce3fe..b0adec7c528c4 100644 --- a/xpcom/rust/gtest/nsstring/Test.cpp +++ b/xpcom/rust/gtest/nsstring/Test.cpp @@ -11,7 +11,8 @@ void GTest_ExpectFailure(const char* aMessage) { EXPECT_STREQ(aMessage, ""); } #define SIZE_ALIGN_CHECK(Clazz) \ extern "C" void Rust_Test_ReprSizeAlign_##Clazz(size_t* size, \ size_t* align); \ - TEST(RustNsString, ReprSizeAlign_##Clazz) { \ + TEST(RustNsString, ReprSizeAlign_##Clazz) \ + { \ size_t size, align; \ Rust_Test_ReprSizeAlign_##Clazz(&size, &align); \ EXPECT_EQ(size, sizeof(Clazz)); \ @@ -24,7 +25,8 @@ SIZE_ALIGN_CHECK(nsCString) #define MEMBER_CHECK(Clazz, Member) \ extern "C" void Rust_Test_Member_##Clazz##_##Member( \ size_t* size, size_t* align, size_t* offset); \ - TEST(RustNsString, ReprMember_##Clazz##_##Member) { \ + TEST(RustNsString, ReprMember_##Clazz##_##Member) \ + { \ class Hack : public Clazz { \ public: \ static void RunTest() { \ @@ -52,7 +54,8 @@ extern "C" void Rust_Test_NsStringFlags( uint16_t* f_terminated, uint16_t* f_voided, uint16_t* f_refcounted, uint16_t* f_owned, uint16_t* f_inline, uint16_t* f_literal, uint16_t* f_class_inline, uint16_t* f_class_null_terminated); -TEST(RustNsString, NsStringFlags) { +TEST(RustNsString, NsStringFlags) +{ uint16_t f_terminated, f_voided, f_refcounted, f_owned, f_inline, f_literal, f_class_inline, f_class_null_terminated; Rust_Test_NsStringFlags(&f_terminated, &f_voided, &f_refcounted, &f_owned, @@ -80,7 +83,8 @@ TEST(RustNsString, NsStringFlags) { extern "C" void Rust_StringFromCpp(const nsACString* aCStr, const nsAString* aStr); -TEST(RustNsString, StringFromCpp) { +TEST(RustNsString, StringFromCpp) +{ nsAutoCString foo; foo.AssignASCII("Hello, World!"); @@ -91,7 +95,8 @@ TEST(RustNsString, StringFromCpp) { } extern "C" void Rust_AssignFromRust(nsACString* aCStr, nsAString* aStr); -TEST(RustNsString, AssignFromRust) { +TEST(RustNsString, AssignFromRust) +{ nsAutoCString cs; nsAutoString s; Rust_AssignFromRust(&cs, &s); @@ -106,18 +111,22 @@ void Cpp_AssignFromCpp(nsACString* aCStr, nsAString* aStr) { } } extern "C" void Rust_AssignFromCpp(); -TEST(RustNsString, AssignFromCpp) { Rust_AssignFromCpp(); } +TEST(RustNsString, AssignFromCpp) +{ Rust_AssignFromCpp(); } extern "C" void Rust_StringWrite(); -TEST(RustNsString, StringWrite) { Rust_StringWrite(); } +TEST(RustNsString, StringWrite) +{ Rust_StringWrite(); } extern "C" void Rust_FromEmptyRustString(); -TEST(RustNsString, FromEmptyRustString) { Rust_FromEmptyRustString(); } +TEST(RustNsString, FromEmptyRustString) +{ Rust_FromEmptyRustString(); } extern "C" void Rust_WriteToBufferFromRust(nsACString* aCStr, nsAString* aStr, nsACString* aFallibleCStr, nsAString* aFallibleStr); -TEST(RustNsString, WriteToBufferFromRust) { +TEST(RustNsString, WriteToBufferFromRust) +{ nsAutoCString cStr; nsAutoString str; nsAutoCString fallibleCStr; @@ -140,7 +149,8 @@ extern "C" void Rust_InlineCapacityFromRust(const nsACString* aCStr, const nsAString* aStr, size_t* aCStrCapacity, size_t* aStrCapacity); -TEST(RustNsString, InlineCapacityFromRust) { +TEST(RustNsString, InlineCapacityFromRust) +{ size_t cStrCapacity; size_t strCapacity; nsAutoCStringN<93> cs; diff --git a/xpcom/rust/gtest/xpcom/Test.cpp b/xpcom/rust/gtest/xpcom/Test.cpp index 1e8d3e5af2b47..4c2a6fb117ff6 100644 --- a/xpcom/rust/gtest/xpcom/Test.cpp +++ b/xpcom/rust/gtest/xpcom/Test.cpp @@ -10,7 +10,8 @@ extern "C" nsIObserverService* Rust_ObserveFromRust(); -TEST(RustXpcom, ObserverFromRust) { +TEST(RustXpcom, ObserverFromRust) +{ nsCOMPtr rust = Rust_ObserveFromRust(); nsCOMPtr cpp = mozilla::services::GetObserverService(); EXPECT_EQ(rust, cpp); @@ -19,7 +20,8 @@ TEST(RustXpcom, ObserverFromRust) { extern "C" void Rust_ImplementRunnableInRust(bool* aItWorked, nsIRunnable** aRunnable); -TEST(RustXpcom, ImplementRunnableInRust) { +TEST(RustXpcom, ImplementRunnableInRust) +{ bool itWorked = false; nsCOMPtr runnable; Rust_ImplementRunnableInRust(&itWorked, getter_AddRefs(runnable)); diff --git a/xpcom/tests/gtest/TestAllocReplacement.cpp b/xpcom/tests/gtest/TestAllocReplacement.cpp index 725b7245ad2f0..70a27cbc3c7f9 100644 --- a/xpcom/tests/gtest/TestAllocReplacement.cpp +++ b/xpcom/tests/gtest/TestAllocReplacement.cpp @@ -112,23 +112,27 @@ static MOZ_NEVER_INLINE bool ValidateHookedAllocation( // See // // for more information about death tests in the GTest framework. -TEST(AllocReplacementDeathTest, malloc_check) { +TEST(AllocReplacementDeathTest, malloc_check) +{ ASSERT_ALLOCATION_HAPPENED([] { return malloc(kAllocAmount); }); } // See above for an explanation of the "*DeathTest" suffix used here. -TEST(AllocReplacementDeathTest, calloc_check) { +TEST(AllocReplacementDeathTest, calloc_check) +{ ASSERT_ALLOCATION_HAPPENED([] { return calloc(1, kAllocAmount); }); } // See above for an explanation of the "*DeathTest" suffix used here. -TEST(AllocReplacementDeathTest, realloc_check) { +TEST(AllocReplacementDeathTest, realloc_check) +{ ASSERT_ALLOCATION_HAPPENED([] { return realloc(nullptr, kAllocAmount); }); } #if defined(HAVE_POSIX_MEMALIGN) // See above for an explanation of the "*DeathTest" suffix used here. -TEST(AllocReplacementDeathTest, posix_memalign_check) { +TEST(AllocReplacementDeathTest, posix_memalign_check) +{ ASSERT_ALLOCATION_HAPPENED([] { void* p = nullptr; int result = posix_memalign(&p, sizeof(void*), kAllocAmount); @@ -149,7 +153,8 @@ TEST(AllocReplacementDeathTest, posix_memalign_check) { lambda, [](void* p) { HeapFree(GetProcessHeap(), 0, p); })); // See above for an explanation of the "*DeathTest" suffix used here. -TEST(AllocReplacementDeathTest, HeapAlloc_check) { +TEST(AllocReplacementDeathTest, HeapAlloc_check) +{ ASSERT_ALLOCATION_HAPPENED([] { HANDLE h = GetProcessHeap(); return HeapAlloc(h, 0, kAllocAmount); @@ -157,7 +162,8 @@ TEST(AllocReplacementDeathTest, HeapAlloc_check) { } // See above for an explanation of the "*DeathTest" suffix used here. -TEST(AllocReplacementDeathTest, HeapReAlloc_check) { +TEST(AllocReplacementDeathTest, HeapReAlloc_check) +{ ASSERT_ALLOCATION_HAPPENED([] { HANDLE h = GetProcessHeap(); void* p = HeapAlloc(h, 0, kAllocAmount / 2); diff --git a/xpcom/tests/gtest/TestArenaAllocator.cpp b/xpcom/tests/gtest/TestArenaAllocator.cpp index 26b313879c2d2..fdb9ba8af3cd1 100644 --- a/xpcom/tests/gtest/TestArenaAllocator.cpp +++ b/xpcom/tests/gtest/TestArenaAllocator.cpp @@ -12,9 +12,11 @@ using mozilla::ArenaAllocator; -TEST(ArenaAllocator, Constructor) { ArenaAllocator<4096, 4> a; } +TEST(ArenaAllocator, Constructor) +{ ArenaAllocator<4096, 4> a; } -TEST(ArenaAllocator, DefaultAllocate) { +TEST(ArenaAllocator, DefaultAllocate) +{ // Test default 1-byte alignment. ArenaAllocator<1024> a; void* x = a.Allocate(101); @@ -25,7 +27,8 @@ TEST(ArenaAllocator, DefaultAllocate) { EXPECT_EQ(uintptr_t(x) + 101, uintptr_t(y)); } -TEST(ArenaAllocator, AllocateAlignment) { +TEST(ArenaAllocator, AllocateAlignment) +{ // Test non-default 8-byte alignment. static const size_t kAlignment = 8; ArenaAllocator<1024, kAlignment> a; @@ -71,7 +74,8 @@ TEST(ArenaAllocator, BadAlignment) } #endif -TEST(ArenaAllocator, AllocateMultipleSizes) { +TEST(ArenaAllocator, AllocateMultipleSizes) +{ // Test non-default 4-byte alignment. ArenaAllocator<4096, 4> a; @@ -90,7 +94,8 @@ TEST(ArenaAllocator, AllocateMultipleSizes) { } } -TEST(ArenaAllocator, AllocateInDifferentChunks) { +TEST(ArenaAllocator, AllocateInDifferentChunks) +{ // Test default 1-byte alignment. ArenaAllocator<4096> a; void* x = a.Allocate(4000); @@ -98,7 +103,8 @@ TEST(ArenaAllocator, AllocateInDifferentChunks) { EXPECT_NE(uintptr_t(x) + 4000, uintptr_t(y)); } -TEST(ArenaAllocator, AllocateLargerThanArenaSize) { +TEST(ArenaAllocator, AllocateLargerThanArenaSize) +{ // Test default 1-byte alignment. ArenaAllocator<256> a; void* x = a.Allocate(4000); @@ -113,7 +119,8 @@ TEST(ArenaAllocator, AllocateLargerThanArenaSize) { } #ifndef MOZ_CODE_COVERAGE -TEST(ArenaAllocator, AllocationsPerChunk) { +TEST(ArenaAllocator, AllocationsPerChunk) +{ // Test that expected number of allocations fit in one chunk. // We use an alignment of 64-bytes to avoid worrying about differences in // the header size on 32 and 64-bit platforms. @@ -140,7 +147,8 @@ TEST(ArenaAllocator, AllocationsPerChunk) { EXPECT_NE(uintptr_t(x) + kAlignment, uintptr_t(y)); } -TEST(ArenaAllocator, MemoryIsValid) { +TEST(ArenaAllocator, MemoryIsValid) +{ // Make multiple allocations and actually access the memory. This is // expected to trip up ASAN or valgrind if out of bounds memory is // accessed. @@ -188,7 +196,8 @@ TEST(ArenaAllocator, MemoryIsValid) { MOZ_DEFINE_MALLOC_SIZE_OF(TestSizeOf); -TEST(ArenaAllocator, SizeOf) { +TEST(ArenaAllocator, SizeOf) +{ // This tests the sizeof functionality. We can't test for equality as we // can't reliably guarantee what sizes the underlying allocator is going to // choose, so we just test that things grow (or not) as expected. @@ -224,7 +233,8 @@ TEST(ArenaAllocator, SizeOf) { EXPECT_GT(sz, prev_sz); } -TEST(ArenaAllocator, Clear) { +TEST(ArenaAllocator, Clear) +{ // Tests that the Clear function works as expected. The best proxy for // checking if a clear is successful is to measure the size. If it's empty we // expect the size to be 0. @@ -269,7 +279,8 @@ TEST(ArenaAllocator, Clear) { EXPECT_GT(sz, prev_sz); } -TEST(ArenaAllocator, Extensions) { +TEST(ArenaAllocator, Extensions) +{ ArenaAllocator<4096, 8> a; // Test with raw strings. diff --git a/xpcom/tests/gtest/TestAtoms.cpp b/xpcom/tests/gtest/TestAtoms.cpp index d064fdc968201..57cc22f5c3f4a 100644 --- a/xpcom/tests/gtest/TestAtoms.cpp +++ b/xpcom/tests/gtest/TestAtoms.cpp @@ -20,7 +20,8 @@ int32_t NS_GetUnusedAtomCount(void); namespace TestAtoms { -TEST(Atoms, Basic) { +TEST(Atoms, Basic) +{ for (unsigned int i = 0; i < ArrayLength(ValidStrings); ++i) { nsDependentString str16(ValidStrings[i].m16); nsDependentCString str8(ValidStrings[i].m8); @@ -44,7 +45,8 @@ TEST(Atoms, Basic) { } } -TEST(Atoms, 16vs8) { +TEST(Atoms, 16vs8) +{ for (unsigned int i = 0; i < ArrayLength(ValidStrings); ++i) { RefPtr atom16 = NS_Atomize(ValidStrings[i].m16); RefPtr atom8 = NS_Atomize(ValidStrings[i].m8); @@ -52,7 +54,8 @@ TEST(Atoms, 16vs8) { } } -TEST(Atoms, Null) { +TEST(Atoms, Null) +{ nsAutoString str(NS_LITERAL_STRING("string with a \0 char")); nsDependentString strCut(str.get()); @@ -67,7 +70,8 @@ TEST(Atoms, Null) { EXPECT_TRUE(atomCut->Equals(strCut)); } -TEST(Atoms, Invalid) { +TEST(Atoms, Invalid) +{ for (unsigned int i = 0; i < ArrayLength(Invalid16Strings); ++i) { nsrefcnt count = NS_GetNumberOfAtoms(); @@ -125,7 +129,8 @@ static bool isStaticAtom(nsAtom* atom) { return rv; } -TEST(Atoms, Table) { +TEST(Atoms, Table) +{ nsrefcnt count = NS_GetNumberOfAtoms(); RefPtr thirdDynamic = NS_Atomize(THIRD_ATOM_STR); @@ -153,7 +158,8 @@ class nsAtomRunner final : public nsIRunnable { NS_IMPL_ISUPPORTS(nsAtomRunner, nsIRunnable) -TEST(Atoms, ConcurrentAccessing) { +TEST(Atoms, ConcurrentAccessing) +{ static const size_t kThreadCount = 4; // Force a GC before so that we don't have any unused atom. NS_GetNumberOfAtoms(); diff --git a/xpcom/tests/gtest/TestAutoPtr.cpp b/xpcom/tests/gtest/TestAutoPtr.cpp index 7559c8fd13da9..d0f13673feea6 100644 --- a/xpcom/tests/gtest/TestAutoPtr.cpp +++ b/xpcom/tests/gtest/TestAutoPtr.cpp @@ -61,7 +61,8 @@ static void DoSomethingWithConstTestObjectBaseB(const TestObjectBaseB *aIn) { TestObject::last_ptr = static_cast(aIn); } -TEST(AutoPtr, Assignment) { +TEST(AutoPtr, Assignment) +{ TestObject::destructed = 0; { nsAutoPtr pobj(new TestObject()); } @@ -77,7 +78,8 @@ TEST(AutoPtr, Assignment) { ASSERT_EQ(3, TestObject::destructed); } -TEST(AutoPtr, getter_Transfers) { +TEST(AutoPtr, getter_Transfers) +{ TestObject::destructed = 0; { @@ -88,7 +90,8 @@ TEST(AutoPtr, getter_Transfers) { ASSERT_EQ(1, TestObject::destructed); } -TEST(AutoPtr, Casting) { +TEST(AutoPtr, Casting) +{ // This comparison is always false, as it should be. The extra parens // suppress a -Wunreachable-code warning about printf being unreachable. ASSERT_NE(((void *)(TestObject *)0x1000), @@ -114,7 +117,8 @@ TEST(AutoPtr, Casting) { } } -TEST(AutoPtr, Forget) { +TEST(AutoPtr, Forget) +{ TestObject::destructed = 0; { @@ -126,7 +130,8 @@ TEST(AutoPtr, Forget) { ASSERT_EQ(1, TestObject::destructed); } -TEST(AutoPtr, Construction) { +TEST(AutoPtr, Construction) +{ TestObject::destructed = 0; { nsAutoPtr pobj(new TestObject()); } @@ -134,7 +139,8 @@ TEST(AutoPtr, Construction) { ASSERT_EQ(1, TestObject::destructed); } -TEST(AutoPtr, ImplicitConversion) { +TEST(AutoPtr, ImplicitConversion) +{ // This test is basically successful if it builds. We add a few assertions // to make gtest happy. TestObject::destructed = 0; @@ -172,7 +178,8 @@ TEST(AutoPtr, ImplicitConversion) { ASSERT_EQ(4, TestObject::destructed); } -TEST(AutoPtr, ArrowOperator) { +TEST(AutoPtr, ArrowOperator) +{ // This test is basically successful if it builds. We add a few assertions // to make gtest happy. TestObject::destructed = 0; diff --git a/xpcom/tests/gtest/TestAutoRef.cpp b/xpcom/tests/gtest/TestAutoRef.cpp index 42644609d1407..cfc611db07c6a 100644 --- a/xpcom/tests/gtest/TestAutoRef.cpp +++ b/xpcom/tests/gtest/TestAutoRef.cpp @@ -34,7 +34,8 @@ class nsAutoRefTraits : public nsPointerRefTraits { int nsAutoRefTraits::mTotalRefsCnt = 0; -TEST(AutoRef, Assignment) { +TEST(AutoRef, Assignment) +{ { nsCountedRef a(new TestObjectA()); ASSERT_EQ(a->mRefCnt, 1); diff --git a/xpcom/tests/gtest/TestAutoRefCnt.cpp b/xpcom/tests/gtest/TestAutoRefCnt.cpp index 6b8ee73f8c791..f426466d4037f 100644 --- a/xpcom/tests/gtest/TestAutoRefCnt.cpp +++ b/xpcom/tests/gtest/TestAutoRefCnt.cpp @@ -47,7 +47,8 @@ Atomic nsThreadSafeAutoRefCntRunner::sDecToZero(0); // want to release the object after last reference gets released. In // this pattern, the cache may rely on the balance of increment to one // and decrement to zero, so that it can maintain a counter for GC. -TEST(AutoRefCnt, ThreadSafeAutoRefCntBalance) { +TEST(AutoRefCnt, ThreadSafeAutoRefCntBalance) +{ static const size_t kThreadCount = 4; nsCOMPtr threads[kThreadCount]; for (size_t i = 0; i < kThreadCount; i++) { diff --git a/xpcom/tests/gtest/TestBase64.cpp b/xpcom/tests/gtest/TestBase64.cpp index 15ac176c74a3c..d366876de4409 100644 --- a/xpcom/tests/gtest/TestBase64.cpp +++ b/xpcom/tests/gtest/TestBase64.cpp @@ -180,11 +180,12 @@ void FakeInputStream::CheckTest(nsACString& aResult) { void FakeInputStream::CheckTest(nsAString& aResult) { ASSERT_TRUE(aResult.EqualsASCII(mTest->mResult)) - << "Actual: " << aResult.BeginReading() << std::endl - << "Expected: " << mTest->mResult; + << "Actual: " << aResult.BeginReading() << std::endl + << "Expected: " << mTest->mResult; } -TEST(Base64, StreamEncoder) { +TEST(Base64, StreamEncoder) +{ nsCOMPtr encoder = do_CreateInstance("@mozilla.org/scriptablebase64encoder;1"); ASSERT_TRUE(encoder); @@ -223,7 +224,8 @@ static EncodeDecodeTestCase sRFC4648TestCases[] = { {"foobar", "Zm9vYmFy"}, }; -TEST(Base64, RFC4648Encoding) { +TEST(Base64, RFC4648Encoding) +{ for (auto& testcase : sRFC4648TestCases) { nsDependentCString in(testcase.mInput); nsAutoCString out; @@ -241,7 +243,8 @@ TEST(Base64, RFC4648Encoding) { } } -TEST(Base64, RFC4648Decoding) { +TEST(Base64, RFC4648Decoding) +{ for (auto& testcase : sRFC4648TestCases) { nsDependentCString out(testcase.mOutput); nsAutoCString in; @@ -259,7 +262,8 @@ TEST(Base64, RFC4648Decoding) { } } -TEST(Base64, RFC4648DecodingRawPointers) { +TEST(Base64, RFC4648DecodingRawPointers) +{ for (auto& testcase : sRFC4648TestCases) { size_t outputLength = strlen(testcase.mOutput); size_t inputLength = strlen(testcase.mInput); @@ -289,7 +293,8 @@ static EncodeDecodeTestCase sNonASCIITestCases[] = { {"\xff\xff\xff\xff", "/////w=="}, }; -TEST(Base64, NonASCIIEncoding) { +TEST(Base64, NonASCIIEncoding) +{ for (auto& testcase : sNonASCIITestCases) { nsDependentCString in(testcase.mInput); nsAutoCString out; @@ -299,7 +304,8 @@ TEST(Base64, NonASCIIEncoding) { } } -TEST(Base64, NonASCIIEncodingWideString) { +TEST(Base64, NonASCIIEncodingWideString) +{ for (auto& testcase : sNonASCIITestCases) { nsAutoString in, out; // XXX Handles Latin1 despite the name @@ -310,7 +316,8 @@ TEST(Base64, NonASCIIEncodingWideString) { } } -TEST(Base64, NonASCIIDecoding) { +TEST(Base64, NonASCIIDecoding) +{ for (auto& testcase : sNonASCIITestCases) { nsDependentCString out(testcase.mOutput); nsAutoCString in; @@ -320,7 +327,8 @@ TEST(Base64, NonASCIIDecoding) { } } -TEST(Base64, NonASCIIDecodingWideString) { +TEST(Base64, NonASCIIDecodingWideString) +{ for (auto& testcase : sNonASCIITestCases) { nsAutoString in, out; // XXX Handles Latin1 despite the name @@ -338,7 +346,8 @@ TEST(Base64, NonASCIIDecodingWideString) { // For historical reasons, our wide string base64 encode routines mask off // the high bits of non-latin1 wide strings. -TEST(Base64, EncodeNon8BitWideString) { +TEST(Base64, EncodeNon8BitWideString) +{ { const nsAutoString non8Bit(u"\x1ff"); nsAutoString out; @@ -357,7 +366,8 @@ TEST(Base64, EncodeNon8BitWideString) { // For historical reasons, our wide string base64 decode routines mask off // the high bits of non-latin1 wide strings. -TEST(Base64, DecodeNon8BitWideString) { +TEST(Base64, DecodeNon8BitWideString) +{ { // This would be "/w==" in a nsCString const nsAutoString non8Bit(u"\x12f\x177=="); @@ -378,7 +388,8 @@ TEST(Base64, DecodeNon8BitWideString) { } } -TEST(Base64, TruncateOnInvalidDecodeCString) { +TEST(Base64, TruncateOnInvalidDecodeCString) +{ NS_NAMED_LITERAL_CSTRING(invalid, "@@=="); nsAutoCString out("I should be truncated!"); nsresult rv = mozilla::Base64Decode(invalid, out); @@ -386,7 +397,8 @@ TEST(Base64, TruncateOnInvalidDecodeCString) { ASSERT_EQ(out.Length(), 0u); } -TEST(Base64, TruncateOnInvalidDecodeWideString) { +TEST(Base64, TruncateOnInvalidDecodeWideString) +{ NS_NAMED_LITERAL_STRING(invalid, "@@=="); nsAutoString out(u"I should be truncated!"); nsresult rv = mozilla::Base64Decode(invalid, out); diff --git a/xpcom/tests/gtest/TestCOMArray.cpp b/xpcom/tests/gtest/TestCOMArray.cpp index 81bf8ca64f095..8c487541675e3 100644 --- a/xpcom/tests/gtest/TestCOMArray.cpp +++ b/xpcom/tests/gtest/TestCOMArray.cpp @@ -112,7 +112,8 @@ Bar::Release(void) { return mRefCnt; } -TEST(COMArray, Sizing) { +TEST(COMArray, Sizing) +{ nsCOMArray arr; for (int32_t i = 0; i < 20; ++i) { @@ -142,7 +143,8 @@ TEST(COMArray, Sizing) { } } -TEST(COMArray, ObjectFunctions) { +TEST(COMArray, ObjectFunctions) +{ int32_t base; { nsCOMArray arr2; @@ -200,7 +202,8 @@ TEST(COMArray, ObjectFunctions) { } } -TEST(COMArray, ElementFunctions) { +TEST(COMArray, ElementFunctions) +{ int32_t base; { nsCOMArray arr2; @@ -258,7 +261,8 @@ TEST(COMArray, ElementFunctions) { } } -TEST(COMArray, Destructor) { +TEST(COMArray, Destructor) +{ int32_t base; Bar::sReleaseCalled = 0; diff --git a/xpcom/tests/gtest/TestCOMPtr.cpp b/xpcom/tests/gtest/TestCOMPtr.cpp index 61b1604a84106..98b6bc4794fb3 100644 --- a/xpcom/tests/gtest/TestCOMPtr.cpp +++ b/xpcom/tests/gtest/TestCOMPtr.cpp @@ -182,7 +182,8 @@ static void AnISupportsPtrPtrContext(nsISupports**) {} using namespace TestCOMPtr; -TEST(COMPtr, Bloat_Raw_Unsafe) { +TEST(COMPtr, Bloat_Raw_Unsafe) +{ // ER: I'm not sure what this is testing... IBar* barP = 0; nsresult rv = CreateIBar(reinterpret_cast(&barP)); @@ -198,7 +199,8 @@ TEST(COMPtr, Bloat_Raw_Unsafe) { NS_RELEASE(barP); } -TEST(COMPtr, Bloat_Smart) { +TEST(COMPtr, Bloat_Smart) +{ // ER: I'm not sure what this is testing... nsCOMPtr barP; nsresult rv = CreateIBar(getter_AddRefs(barP)); @@ -210,7 +212,8 @@ TEST(COMPtr, Bloat_Smart) { ASSERT_TRUE(fooP); } -TEST(COMPtr, AddRefAndRelease) { +TEST(COMPtr, AddRefAndRelease) +{ IFoo::total_constructions_ = 0; IFoo::total_destructions_ = 0; IBar::total_destructions_ = 0; @@ -260,7 +263,8 @@ TEST(COMPtr, AddRefAndRelease) { ASSERT_EQ(IBar::total_destructions_, 1); } -TEST(COMPtr, Comparison) { +TEST(COMPtr, Comparison) +{ IFoo::total_constructions_ = 0; IFoo::total_destructions_ = 0; @@ -295,7 +299,8 @@ TEST(COMPtr, Comparison) { ASSERT_EQ(IFoo::total_destructions_, 2); } -TEST(COMPtr, DontAddRef) { +TEST(COMPtr, DontAddRef) +{ { auto* raw_foo1p = new IFoo; raw_foo1p->AddRef(); @@ -314,7 +319,8 @@ TEST(COMPtr, DontAddRef) { } } -TEST(COMPtr, AssignmentHelpers) { +TEST(COMPtr, AssignmentHelpers) +{ IFoo::total_constructions_ = 0; IFoo::total_destructions_ = 0; @@ -375,7 +381,8 @@ TEST(COMPtr, AssignmentHelpers) { ASSERT_EQ(IFoo::total_destructions_, 5); } -TEST(COMPtr, QueryInterface) { +TEST(COMPtr, QueryInterface) +{ IFoo::total_queries_ = 0; IBar::total_queries_ = 0; @@ -407,7 +414,8 @@ TEST(COMPtr, QueryInterface) { } } -TEST(COMPtr, GetterConversions) { +TEST(COMPtr, GetterConversions) +{ // This is just a compilation test. We add a few asserts to keep gtest happy. { nsCOMPtr fooP; diff --git a/xpcom/tests/gtest/TestCOMPtrEq.cpp b/xpcom/tests/gtest/TestCOMPtrEq.cpp index 97482a212f844..2056ce136805c 100644 --- a/xpcom/tests/gtest/TestCOMPtrEq.cpp +++ b/xpcom/tests/gtest/TestCOMPtrEq.cpp @@ -25,7 +25,8 @@ class nsICOMPtrEqTestFoo : public nsISupports { NS_DEFINE_STATIC_IID_ACCESSOR(nsICOMPtrEqTestFoo, NS_ICOMPTREQTESTFOO_IID) -TEST(COMPtrEq, NullEquality) { +TEST(COMPtrEq, NullEquality) +{ nsCOMPtr s; nsICOMPtrEqTestFoo* r = nullptr; const nsCOMPtr sc; diff --git a/xpcom/tests/gtest/TestCRT.cpp b/xpcom/tests/gtest/TestCRT.cpp index cbcc375bd1dd6..22e161fcddd17 100644 --- a/xpcom/tests/gtest/TestCRT.cpp +++ b/xpcom/tests/gtest/TestCRT.cpp @@ -79,7 +79,8 @@ static Test tests[] = { }; #define NUM_TESTS int((sizeof(tests) / sizeof(tests[0]))) -TEST(CRT, main) { +TEST(CRT, main) +{ TestCRT::Test* tp = tests; for (int i = 0; i < NUM_TESTS; i++, tp++) { Check(tp->s1, tp->s2, tp->n); diff --git a/xpcom/tests/gtest/TestCloneInputStream.cpp b/xpcom/tests/gtest/TestCloneInputStream.cpp index 2d25d35e06f75..0bdae9d4f71a6 100644 --- a/xpcom/tests/gtest/TestCloneInputStream.cpp +++ b/xpcom/tests/gtest/TestCloneInputStream.cpp @@ -14,14 +14,16 @@ #include "nsStringStream.h" #include "nsComponentManagerUtils.h" -TEST(CloneInputStream, InvalidInput) { +TEST(CloneInputStream, InvalidInput) +{ nsCOMPtr clone; nsresult rv = NS_CloneInputStream(nullptr, getter_AddRefs(clone)); ASSERT_TRUE(NS_FAILED(rv)); ASSERT_FALSE(clone); } -TEST(CloneInputStream, CloneableInput) { +TEST(CloneInputStream, CloneableInput) +{ nsTArray inputData; testing::CreateData(4 * 1024, inputData); nsDependentCSubstring inputString(inputData.Elements(), inputData.Length()); @@ -76,7 +78,8 @@ class NonCloneableInputStream final : public nsIInputStream { NS_IMPL_ISUPPORTS(NonCloneableInputStream, nsIInputStream) -TEST(CloneInputStream, NonCloneableInput_NoFallback) { +TEST(CloneInputStream, NonCloneableInput_NoFallback) +{ nsTArray inputData; testing::CreateData(4 * 1024, inputData); nsDependentCSubstring inputString(inputData.Elements(), inputData.Length()); @@ -98,7 +101,8 @@ TEST(CloneInputStream, NonCloneableInput_NoFallback) { testing::ConsumeAndValidateStream(stream, inputString); } -TEST(CloneInputStream, NonCloneableInput_Fallback) { +TEST(CloneInputStream, NonCloneableInput_Fallback) +{ nsTArray inputData; testing::CreateData(4 * 1024, inputData); nsDependentCSubstring inputString(inputData.Elements(), inputData.Length()); @@ -138,7 +142,8 @@ TEST(CloneInputStream, NonCloneableInput_Fallback) { testing::ConsumeAndValidateStream(clone, inputString); } -TEST(CloneInputStream, CloneMultiplexStream) { +TEST(CloneInputStream, CloneMultiplexStream) +{ nsCOMPtr multiplexStream = do_CreateInstance("@mozilla.org/io/multiplex-input-stream;1"); ASSERT_TRUE(multiplexStream); @@ -179,7 +184,8 @@ TEST(CloneInputStream, CloneMultiplexStream) { ASSERT_TRUE(NS_FAILED(rv)); } -TEST(CloneInputStream, CloneMultiplexStreamPartial) { +TEST(CloneInputStream, CloneMultiplexStreamPartial) +{ nsCOMPtr multiplexStream = do_CreateInstance("@mozilla.org/io/multiplex-input-stream;1"); ASSERT_TRUE(multiplexStream); diff --git a/xpcom/tests/gtest/TestDafsa.cpp b/xpcom/tests/gtest/TestDafsa.cpp index f7aa0cd405233..523c74629020e 100644 --- a/xpcom/tests/gtest/TestDafsa.cpp +++ b/xpcom/tests/gtest/TestDafsa.cpp @@ -15,9 +15,11 @@ namespace dafsa_test_1 { #include "dafsa_test_1.inc" // kDafsa } -TEST(Dafsa, Constructor) { Dafsa d(dafsa_test_1::kDafsa); } +TEST(Dafsa, Constructor) +{ Dafsa d(dafsa_test_1::kDafsa); } -TEST(Dafsa, StringsFound) { +TEST(Dafsa, StringsFound) +{ Dafsa d(dafsa_test_1::kDafsa); int tag = d.Lookup(NS_LITERAL_CSTRING("foo.bar.baz")); @@ -33,7 +35,8 @@ TEST(Dafsa, StringsFound) { EXPECT_EQ(tag, 4); } -TEST(Dafsa, StringsNotFound) { +TEST(Dafsa, StringsNotFound) +{ Dafsa d(dafsa_test_1::kDafsa); // Matches all but last letter. @@ -57,7 +60,8 @@ TEST(Dafsa, StringsNotFound) { EXPECT_EQ(tag, Dafsa::kKeyNotFound); } -TEST(Dafsa, HugeString) { +TEST(Dafsa, HugeString) +{ Dafsa d(dafsa_test_1::kDafsa); int tag = d.Lookup(NS_LITERAL_CSTRING( diff --git a/xpcom/tests/gtest/TestDeadlockDetectorScalability.cpp b/xpcom/tests/gtest/TestDeadlockDetectorScalability.cpp index 442ccc9155a10..40519f43ede4e 100644 --- a/xpcom/tests/gtest/TestDeadlockDetectorScalability.cpp +++ b/xpcom/tests/gtest/TestDeadlockDetectorScalability.cpp @@ -27,7 +27,8 @@ static void AllocLockRecurseUnlockFree(int i) { // This test creates a resource dependency chain N elements long, then // frees all the resources in the chain. -TEST(DeadlockDetectorScalability, LengthNDepChain) { +TEST(DeadlockDetectorScalability, LengthNDepChain) +{ const int N = 1 << 14; // 16K AllocLockRecurseUnlockFree(N); ASSERT_TRUE(true); @@ -39,7 +40,8 @@ TEST(DeadlockDetectorScalability, LengthNDepChain) { // repeatedly exercises this order k times. // // NB: It takes a minute or two to run so it is disabled by default. -TEST(DeadlockDetectorScalability, DISABLED_OneLockNDeps) { +TEST(DeadlockDetectorScalability, DISABLED_OneLockNDeps) +{ // NB: Using a larger test size to stress our traversal logic. const int N = 1 << 17; // 131k const int K = 100; @@ -80,7 +82,8 @@ TEST(DeadlockDetectorScalability, DISABLED_OneLockNDeps) { // It's very difficult to perform well on this test. It's put forth as a // challenge problem. -TEST(DeadlockDetectorScalability, MaxDepsNsq) { +TEST(DeadlockDetectorScalability, MaxDepsNsq) +{ const int N = 1 << 10; // 1k const int K = 10; @@ -114,7 +117,8 @@ TEST(DeadlockDetectorScalability, MaxDepsNsq) { // resources are allocated, exercised K times, and deallocated one at // a time. -TEST(DeadlockDetectorScalability, OneLockNDepsUsedSeveralTimes) { +TEST(DeadlockDetectorScalability, OneLockNDepsUsedSeveralTimes) +{ const size_t N = 1 << 17; // 131k const size_t K = 3; @@ -150,7 +154,8 @@ MOZ_DEFINE_MALLOC_SIZE_OF(DeadlockDetectorMallocSizeOf) // This is a simple test that exercises the deadlock detector memory reporting // functionality. -TEST(DeadlockDetectorScalability, SizeOf) { +TEST(DeadlockDetectorScalability, SizeOf) +{ size_t memory_used = mozilla::BlockingResourceBase::SizeOfDeadlockDetector( DeadlockDetectorMallocSizeOf); diff --git a/xpcom/tests/gtest/TestEncoding.cpp b/xpcom/tests/gtest/TestEncoding.cpp index 4973d2f0b3ab9..2abbc5d7086e8 100644 --- a/xpcom/tests/gtest/TestEncoding.cpp +++ b/xpcom/tests/gtest/TestEncoding.cpp @@ -8,7 +8,8 @@ #include "nsString.h" #include "gtest/gtest.h" -TEST(Encoding, GoodSurrogatePair) { +TEST(Encoding, GoodSurrogatePair) +{ // When this string is decoded, the surrogate pair is U+10302 and the rest of // the string is specified by indexes 2 onward. const char16_t goodPairData[] = {0xD800, 0xDF02, 0x65, 0x78, 0x0}; @@ -31,7 +32,8 @@ TEST(Encoding, GoodSurrogatePair) { free(goodPair8); } -TEST(Encoding, BackwardsSurrogatePair) { +TEST(Encoding, BackwardsSurrogatePair) +{ // When this string is decoded, the two surrogates are wrongly ordered and // must each be interpreted as U+FFFD. const char16_t backwardsPairData[] = {0xDDDD, 0xD863, 0x65, 0x78, 0x0}; @@ -55,7 +57,8 @@ TEST(Encoding, BackwardsSurrogatePair) { free(backwardsPair8); } -TEST(Encoding, MalformedUTF16OrphanHighSurrogate) { +TEST(Encoding, MalformedUTF16OrphanHighSurrogate) +{ // When this string is decoded, the high surrogate should be replaced and the // rest of the string is specified by indexes 1 onward. const char16_t highSurrogateData[] = {0xD863, 0x74, 0x65, 0x78, 0x74, 0x0}; @@ -79,7 +82,8 @@ TEST(Encoding, MalformedUTF16OrphanHighSurrogate) { free(highSurrogate8); } -TEST(Encoding, MalformedUTF16OrphanLowSurrogate) { +TEST(Encoding, MalformedUTF16OrphanLowSurrogate) +{ // When this string is decoded, the low surrogate should be replaced and the // rest of the string is specified by indexes 1 onward. const char16_t lowSurrogateData[] = {0xDDDD, 0x74, 0x65, 0x78, 0x74, 0x0}; diff --git a/xpcom/tests/gtest/TestEscape.cpp b/xpcom/tests/gtest/TestEscape.cpp index fd4a4e37ec2da..e3cd9b55a866d 100644 --- a/xpcom/tests/gtest/TestEscape.cpp +++ b/xpcom/tests/gtest/TestEscape.cpp @@ -13,7 +13,8 @@ using namespace mozilla; // Testing for failure here would be somewhat hard in automation. Locally you // could use something like ulimit to create a failure. -TEST(Escape, FallibleNoEscape) { +TEST(Escape, FallibleNoEscape) +{ // Tests the fallible version of NS_EscapeURL works as expected when no // escaping is necessary. nsCString toEscape("data:,Hello%2C%20World!"); @@ -26,7 +27,8 @@ TEST(Escape, FallibleNoEscape) { EXPECT_EQ(toEscape.BeginReading(), escaped.BeginReading()); } -TEST(Escape, FallibleEscape) { +TEST(Escape, FallibleEscape) +{ // Tests the fallible version of NS_EscapeURL works as expected when // escaping is necessary. nsCString toEscape("data:,Hello%2C%20World!\xC4\x9F"); @@ -38,7 +40,8 @@ TEST(Escape, FallibleEscape) { EXPECT_STREQ(escaped.BeginReading(), kExpected); } -TEST(Escape, BadEscapeSequences) { +TEST(Escape, BadEscapeSequences) +{ { char bad[] = "%s\0fa"; @@ -66,7 +69,8 @@ TEST(Escape, BadEscapeSequences) { } } -TEST(Escape, nsAppendEscapedHTML) { +TEST(Escape, nsAppendEscapedHTML) +{ const char* srcs[] = { "a", "bcdefgh", "<", ">", "&", "\"", "'", "'bad'", "Foo& foo", "'\"&> evNormal = @@ -66,7 +67,8 @@ TEST(EventPriorities, IdleAfterNormal) { SpinEventLoopUntil([&]() { return normalRan == 3 && idleRan == 3; })); } -TEST(EventPriorities, InterleaveHighNormal) { +TEST(EventPriorities, InterleaveHighNormal) +{ int normalRan = 0, highRan = 0; RefPtr evNormal = new TestEvent( diff --git a/xpcom/tests/gtest/TestEventTargetQI.cpp b/xpcom/tests/gtest/TestEventTargetQI.cpp index 25f1a063105fa..6de1d8abfc21c 100644 --- a/xpcom/tests/gtest/TestEventTargetQI.cpp +++ b/xpcom/tests/gtest/TestEventTargetQI.cpp @@ -27,7 +27,8 @@ bool TestQITo(SourcePtr& aPtr1) { return (bool)aPtr2; } -TEST(TestEventTargetQI, ThreadPool) { +TEST(TestEventTargetQI, ThreadPool) +{ nsCOMPtr thing = new nsThreadPool(); EXPECT_FALSE(TestQITo(thing)); @@ -37,7 +38,8 @@ TEST(TestEventTargetQI, ThreadPool) { thing->Shutdown(); } -TEST(TestEventTargetQI, SharedThreadPool) { +TEST(TestEventTargetQI, SharedThreadPool) +{ nsCOMPtr thing = SharedThreadPool::Get(NS_LITERAL_CSTRING("TestPool"), 1); EXPECT_TRUE(thing); @@ -47,7 +49,8 @@ TEST(TestEventTargetQI, SharedThreadPool) { EXPECT_TRUE(TestQITo(thing)); } -TEST(TestEventTargetQI, Thread) { +TEST(TestEventTargetQI, Thread) +{ nsCOMPtr thing = do_GetCurrentThread(); EXPECT_TRUE(thing); @@ -56,7 +59,8 @@ TEST(TestEventTargetQI, Thread) { EXPECT_TRUE(TestQITo(thing)); } -TEST(TestEventTargetQI, ThrottledEventQueue) { +TEST(TestEventTargetQI, ThrottledEventQueue) +{ nsCOMPtr thread = do_GetCurrentThread(); RefPtr thing = ThrottledEventQueue::Create(thread); EXPECT_TRUE(thing); @@ -66,7 +70,8 @@ TEST(TestEventTargetQI, ThrottledEventQueue) { EXPECT_TRUE(TestQITo(thing)); } -TEST(TestEventTargetQI, LazyIdleThread) { +TEST(TestEventTargetQI, LazyIdleThread) +{ nsCOMPtr thing = new LazyIdleThread(0, NS_LITERAL_CSTRING("TestThread")); EXPECT_TRUE(thing); @@ -78,7 +83,8 @@ TEST(TestEventTargetQI, LazyIdleThread) { thing->Shutdown(); } -TEST(TestEventTargetQI, SchedulerGroup) { +TEST(TestEventTargetQI, SchedulerGroup) +{ nsCOMPtr thing = SystemGroup::EventTargetFor(TaskCategory::Other); EXPECT_TRUE(thing); diff --git a/xpcom/tests/gtest/TestExpirationTracker.cpp b/xpcom/tests/gtest/TestExpirationTracker.cpp index 603e0233ab973..09e462a29435b 100644 --- a/xpcom/tests/gtest/TestExpirationTracker.cpp +++ b/xpcom/tests/gtest/TestExpirationTracker.cpp @@ -183,7 +183,8 @@ static const struct Test { DECL_TEST(test_random8), {nullptr, nullptr}}; -TEST(ExpirationTracker, main) { +TEST(ExpirationTracker, main) +{ for (const TestExpirationTracker::Test* t = tests; t->name != nullptr; ++t) { EXPECT_TRUE(t->func()); } diff --git a/xpcom/tests/gtest/TestFile.cpp b/xpcom/tests/gtest/TestFile.cpp index a2930354ab798..0f5b3c12ce352 100644 --- a/xpcom/tests/gtest/TestFile.cpp +++ b/xpcom/tests/gtest/TestFile.cpp @@ -365,7 +365,8 @@ static bool TestNormalizeNativePath(nsIFile* aBase, nsIFile* aStart) { return true; } -TEST(TestFile, Tests) { +TEST(TestFile, Tests) +{ nsCOMPtr base; nsresult rv = NS_GetSpecialDirectory(NS_OS_TEMP_DIR, getter_AddRefs(base)); ASSERT_TRUE(VerifyResult(rv, "Getting temp directory")); diff --git a/xpcom/tests/gtest/TestFilePreferencesUnix.cpp b/xpcom/tests/gtest/TestFilePreferencesUnix.cpp index 1f9a5ff092848..ba73e130bde25 100644 --- a/xpcom/tests/gtest/TestFilePreferencesUnix.cpp +++ b/xpcom/tests/gtest/TestFilePreferencesUnix.cpp @@ -10,7 +10,8 @@ using namespace mozilla; -TEST(TestFilePreferencesUnix, Parsing) { +TEST(TestFilePreferencesUnix, Parsing) +{ #define kBlacklisted "/tmp/blacklisted" #define kBlacklistedDir "/tmp/blacklisted/" #define kBlacklistedFile "/tmp/blacklisted/file" @@ -66,7 +67,8 @@ TEST(TestFilePreferencesUnix, Parsing) { false); } -TEST(TestFilePreferencesUnix, Simple) { +TEST(TestFilePreferencesUnix, Simple) +{ nsAutoCString tempPath; // This is the directory we will blacklist diff --git a/xpcom/tests/gtest/TestFilePreferencesWin.cpp b/xpcom/tests/gtest/TestFilePreferencesWin.cpp index e14c351fa57b4..e11126bba40d6 100644 --- a/xpcom/tests/gtest/TestFilePreferencesWin.cpp +++ b/xpcom/tests/gtest/TestFilePreferencesWin.cpp @@ -4,7 +4,8 @@ #include "nsIFile.h" #include "nsXPCOMCID.h" -TEST(FilePreferencesWin, Normalization) { +TEST(FilePreferencesWin, Normalization) +{ nsAutoString normalized; mozilla::FilePreferences::testing::NormalizePath(NS_LITERAL_STRING("foo"), @@ -114,7 +115,8 @@ TEST(FilePreferencesWin, Normalization) { ASSERT_FALSE(result); } -TEST(FilePreferencesWin, AccessUNC) { +TEST(FilePreferencesWin, AccessUNC) +{ nsCOMPtr lf = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID); nsresult rv; diff --git a/xpcom/tests/gtest/TestGCPostBarriers.cpp b/xpcom/tests/gtest/TestGCPostBarriers.cpp index 6628bc99b3bef..f104272251383 100644 --- a/xpcom/tests/gtest/TestGCPostBarriers.cpp +++ b/xpcom/tests/gtest/TestGCPostBarriers.cpp @@ -112,7 +112,8 @@ static void CreateGlobalAndRunTest(JSContext* cx) { JS::LeaveRealm(cx, oldRealm); } -TEST(GCPostBarriers, nsTArray) { +TEST(GCPostBarriers, nsTArray) +{ CycleCollectedJSContext* ccjscx = CycleCollectedJSContext::Get(); ASSERT_TRUE(ccjscx != nullptr); JSContext* cx = ccjscx->Context(); diff --git a/xpcom/tests/gtest/TestHashtables.cpp b/xpcom/tests/gtest/TestHashtables.cpp index c954b3e066d42..26779f0fbd4d0 100644 --- a/xpcom/tests/gtest/TestHashtables.cpp +++ b/xpcom/tests/gtest/TestHashtables.cpp @@ -217,7 +217,8 @@ static nsresult CreateIFoo(IFoo** result) using namespace TestHashtables; -TEST(Hashtable, THashtable) { +TEST(Hashtable, THashtable) +{ // check an nsTHashtable nsTHashtable EntityToUnicode(ENTITY_COUNT); @@ -237,7 +238,8 @@ TEST(Hashtable, THashtable) { ASSERT_EQ(count, uint32_t(0)); } -TEST(Hashtable, Move) { +TEST(Hashtable, Move) +{ const void* kPtr = reinterpret_cast(static_cast(0xbadc0de)); nsTHashtable> table; @@ -251,7 +253,8 @@ TEST(Hashtable, Move) { EXPECT_FALSE(table.Contains(kPtr)); } -TEST(Hashtables, DataHashtable) { +TEST(Hashtables, DataHashtable) +{ // check a data-hashtable nsDataHashtable UniToEntity(ENTITY_COUNT); @@ -283,7 +286,8 @@ TEST(Hashtables, DataHashtable) { ASSERT_EQ(count, uint32_t(0)); } -TEST(Hashtables, ClassHashtable) { +TEST(Hashtables, ClassHashtable) +{ // check a class-hashtable nsClassHashtable EntToUniClass(ENTITY_COUNT); @@ -315,7 +319,8 @@ TEST(Hashtables, ClassHashtable) { ASSERT_EQ(count, uint32_t(0)); } -TEST(Hashtables, DataHashtableWithInterfaceKey) { +TEST(Hashtables, DataHashtableWithInterfaceKey) +{ // check a data-hashtable with an interface key nsDataHashtable EntToUniClass2(ENTITY_COUNT); @@ -360,7 +365,8 @@ TEST(Hashtables, DataHashtableWithInterfaceKey) { ASSERT_EQ(count, uint32_t(0)); } -TEST(Hashtables, InterfaceHashtable) { +TEST(Hashtables, InterfaceHashtable) +{ // check an interface-hashtable with an uint32_t key nsInterfaceHashtable UniToEntClass2(ENTITY_COUNT); @@ -402,7 +408,8 @@ TEST(Hashtables, InterfaceHashtable) { ASSERT_EQ(count, uint32_t(0)); } -TEST(Hashtables, DataHashtable_LookupForAdd) { +TEST(Hashtables, DataHashtable_LookupForAdd) +{ // check LookupForAdd/OrInsert nsDataHashtable UniToEntity(ENTITY_COUNT); @@ -467,7 +474,8 @@ TEST(Hashtables, DataHashtable_LookupForAdd) { ASSERT_TRUE(0 == UniToEntity.Count()); } -TEST(Hashtables, ClassHashtable_LookupForAdd) { +TEST(Hashtables, ClassHashtable_LookupForAdd) +{ // check a class-hashtable LookupForAdd with null values nsClassHashtable EntToUniClass(ENTITY_COUNT); diff --git a/xpcom/tests/gtest/TestID.cpp b/xpcom/tests/gtest/TestID.cpp index 90fc5fb4c1d17..d9a712500bed1 100644 --- a/xpcom/tests/gtest/TestID.cpp +++ b/xpcom/tests/gtest/TestID.cpp @@ -20,7 +20,8 @@ static const char* const ids[] = { }; #define NUM_IDS ((int)(sizeof(ids) / sizeof(ids[0]))) -TEST(nsID, StringConversion) { +TEST(nsID, StringConversion) +{ nsID id; for (int i = 0; i < NUM_IDS; i++) { const char* idstr = ids[i]; diff --git a/xpcom/tests/gtest/TestInputStreamLengthHelper.cpp b/xpcom/tests/gtest/TestInputStreamLengthHelper.cpp index d2ccc87151942..b562bb59b23d7 100644 --- a/xpcom/tests/gtest/TestInputStreamLengthHelper.cpp +++ b/xpcom/tests/gtest/TestInputStreamLengthHelper.cpp @@ -14,7 +14,8 @@ using namespace mozilla; -TEST(TestInputStreamLengthHelper, NonLengthStream) { +TEST(TestInputStreamLengthHelper, NonLengthStream) +{ nsCString buf; buf.AssignLiteral("Hello world"); @@ -91,7 +92,8 @@ NS_INTERFACE_MAP_BEGIN(LengthStream) NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIInputStream) NS_INTERFACE_MAP_END -TEST(TestInputStreamLengthHelper, LengthStream) { +TEST(TestInputStreamLengthHelper, LengthStream) +{ nsCOMPtr stream = new LengthStream(42, NS_OK, 0, false); bool called = false; @@ -103,7 +105,8 @@ TEST(TestInputStreamLengthHelper, LengthStream) { MOZ_ALWAYS_TRUE(SpinEventLoopUntil([&]() { return called; })); } -TEST(TestInputStreamLengthHelper, InvalidLengthStream) { +TEST(TestInputStreamLengthHelper, InvalidLengthStream) +{ nsCOMPtr stream = new LengthStream(42, NS_ERROR_NOT_AVAILABLE, 0, false); @@ -116,7 +119,8 @@ TEST(TestInputStreamLengthHelper, InvalidLengthStream) { MOZ_ALWAYS_TRUE(SpinEventLoopUntil([&]() { return called; })); } -TEST(TestInputStreamLengthHelper, AsyncLengthStream) { +TEST(TestInputStreamLengthHelper, AsyncLengthStream) +{ nsCOMPtr stream = new LengthStream(22, NS_BASE_STREAM_WOULD_BLOCK, 123, true); @@ -129,7 +133,8 @@ TEST(TestInputStreamLengthHelper, AsyncLengthStream) { MOZ_ALWAYS_TRUE(SpinEventLoopUntil([&]() { return called; })); } -TEST(TestInputStreamLengthHelper, FallbackLengthStream) { +TEST(TestInputStreamLengthHelper, FallbackLengthStream) +{ nsCOMPtr stream = new LengthStream(-1, NS_BASE_STREAM_WOULD_BLOCK, 123, false); diff --git a/xpcom/tests/gtest/TestLogCommandLineHandler.cpp b/xpcom/tests/gtest/TestLogCommandLineHandler.cpp index cd91e29d098f2..dad8e917aadc5 100644 --- a/xpcom/tests/gtest/TestLogCommandLineHandler.cpp +++ b/xpcom/tests/gtest/TestLogCommandLineHandler.cpp @@ -21,7 +21,8 @@ constexpr size_t array_size(T (&)[N]) { return N; } -TEST(LogCommandLineHandler, Empty) { +TEST(LogCommandLineHandler, Empty) +{ bool callbackInvoked = false; auto callback = [&](nsACString const& env) mutable { callbackInvoked = true; @@ -35,7 +36,8 @@ TEST(LogCommandLineHandler, Empty) { EXPECT_FALSE(callbackInvoked); } -TEST(LogCommandLineHandler, MOZ_LOG_regular) { +TEST(LogCommandLineHandler, MOZ_LOG_regular) +{ nsTArray results; auto callback = [&](nsACString const& env) mutable { @@ -68,7 +70,8 @@ TEST(LogCommandLineHandler, MOZ_LOG_regular) { EXPECT_TRUE(NS_LITERAL_CSTRING("MOZ_LOG=modules").Equals(results[0])); } -TEST(LogCommandLineHandler, MOZ_LOG_and_FILE_regular) { +TEST(LogCommandLineHandler, MOZ_LOG_and_FILE_regular) +{ nsTArray results; auto callback = [&](nsACString const& env) mutable { @@ -114,7 +117,8 @@ TEST(LogCommandLineHandler, MOZ_LOG_and_FILE_regular) { EXPECT_TRUE(NS_LITERAL_CSTRING("MOZ_LOG_FILE=file").Equals(results[1])); } -TEST(LogCommandLineHandler, MOZ_LOG_fuzzy) { +TEST(LogCommandLineHandler, MOZ_LOG_fuzzy) +{ nsTArray results; auto callback = [&](nsACString const& env) mutable { @@ -147,7 +151,8 @@ TEST(LogCommandLineHandler, MOZ_LOG_fuzzy) { EXPECT_TRUE(results.Length() == 0); } -TEST(LogCommandLineHandler, MOZ_LOG_overlapping) { +TEST(LogCommandLineHandler, MOZ_LOG_overlapping) +{ nsTArray results; auto callback = [&](nsACString const& env) mutable { diff --git a/xpcom/tests/gtest/TestMoveString.cpp b/xpcom/tests/gtest/TestMoveString.cpp index fb71d0bf43e0c..cdfacdbbac429 100644 --- a/xpcom/tests/gtest/TestMoveString.cpp +++ b/xpcom/tests/gtest/TestMoveString.cpp @@ -42,7 +42,8 @@ static void ExpectNew(const nsACString& aStr) { EXPECT_TRUE(aStr.EqualsASCII(NEW_VAL)); } -TEST(MoveString, SharedIntoOwned) { +TEST(MoveString, SharedIntoOwned) +{ nsCString out; SetAsOwned(out, OLD_VAL); EXPECT_EQ(out.GetDataFlags(), Df::OWNED | Df::TERMINATED); @@ -60,7 +61,8 @@ TEST(MoveString, SharedIntoOwned) { EXPECT_EQ(out.get(), data); } -TEST(MoveString, OwnedIntoOwned) { +TEST(MoveString, OwnedIntoOwned) +{ nsCString out; SetAsOwned(out, OLD_VAL); EXPECT_EQ(out.GetDataFlags(), Df::OWNED | Df::TERMINATED); @@ -78,7 +80,8 @@ TEST(MoveString, OwnedIntoOwned) { EXPECT_EQ(out.get(), data); } -TEST(MoveString, LiteralIntoOwned) { +TEST(MoveString, LiteralIntoOwned) +{ nsCString out; SetAsOwned(out, OLD_VAL); EXPECT_EQ(out.GetDataFlags(), Df::OWNED | Df::TERMINATED); @@ -96,7 +99,8 @@ TEST(MoveString, LiteralIntoOwned) { EXPECT_EQ(out.get(), data); } -TEST(MoveString, AutoIntoOwned) { +TEST(MoveString, AutoIntoOwned) +{ nsCString out; SetAsOwned(out, OLD_VAL); EXPECT_EQ(out.GetDataFlags(), Df::OWNED | Df::TERMINATED); @@ -114,7 +118,8 @@ TEST(MoveString, AutoIntoOwned) { EXPECT_NE(out.get(), data); } -TEST(MoveString, DepIntoOwned) { +TEST(MoveString, DepIntoOwned) +{ nsCString out; SetAsOwned(out, OLD_VAL); EXPECT_EQ(out.GetDataFlags(), Df::OWNED | Df::TERMINATED); @@ -129,7 +134,8 @@ TEST(MoveString, DepIntoOwned) { EXPECT_EQ(out.GetDataFlags(), Df::REFCOUNTED | Df::TERMINATED); } -TEST(MoveString, VoidIntoOwned) { +TEST(MoveString, VoidIntoOwned) +{ nsCString out; SetAsOwned(out, OLD_VAL); EXPECT_EQ(out.GetDataFlags(), Df::OWNED | Df::TERMINATED); @@ -145,7 +151,8 @@ TEST(MoveString, VoidIntoOwned) { EXPECT_EQ(out.GetDataFlags(), Df::VOIDED | Df::TERMINATED); } -TEST(MoveString, SharedIntoAuto) { +TEST(MoveString, SharedIntoAuto) +{ nsAutoCString out; out.Assign(OLD_VAL); EXPECT_EQ(out.GetDataFlags(), Df::INLINE | Df::TERMINATED); @@ -163,7 +170,8 @@ TEST(MoveString, SharedIntoAuto) { EXPECT_EQ(out.get(), data); } -TEST(MoveString, OwnedIntoAuto) { +TEST(MoveString, OwnedIntoAuto) +{ nsAutoCString out; out.Assign(OLD_VAL); EXPECT_EQ(out.GetDataFlags(), Df::INLINE | Df::TERMINATED); @@ -181,7 +189,8 @@ TEST(MoveString, OwnedIntoAuto) { EXPECT_EQ(out.get(), data); } -TEST(MoveString, LiteralIntoAuto) { +TEST(MoveString, LiteralIntoAuto) +{ nsAutoCString out; out.Assign(OLD_VAL); EXPECT_EQ(out.GetDataFlags(), Df::INLINE | Df::TERMINATED); @@ -199,7 +208,8 @@ TEST(MoveString, LiteralIntoAuto) { EXPECT_EQ(out.get(), data); } -TEST(MoveString, AutoIntoAuto) { +TEST(MoveString, AutoIntoAuto) +{ nsAutoCString out; out.Assign(OLD_VAL); EXPECT_EQ(out.GetDataFlags(), Df::INLINE | Df::TERMINATED); @@ -217,7 +227,8 @@ TEST(MoveString, AutoIntoAuto) { EXPECT_NE(out.get(), data); } -TEST(MoveString, DepIntoAuto) { +TEST(MoveString, DepIntoAuto) +{ nsAutoCString out; out.Assign(OLD_VAL); EXPECT_EQ(out.GetDataFlags(), Df::INLINE | Df::TERMINATED); @@ -232,7 +243,8 @@ TEST(MoveString, DepIntoAuto) { EXPECT_EQ(out.GetDataFlags(), Df::INLINE | Df::TERMINATED); } -TEST(MoveString, VoidIntoAuto) { +TEST(MoveString, VoidIntoAuto) +{ nsAutoCString out; out.Assign(OLD_VAL); EXPECT_EQ(out.GetDataFlags(), Df::INLINE | Df::TERMINATED); diff --git a/xpcom/tests/gtest/TestMozPromise.cpp b/xpcom/tests/gtest/TestMozPromise.cpp index 5236cac184c35..7174699014641 100644 --- a/xpcom/tests/gtest/TestMozPromise.cpp +++ b/xpcom/tests/gtest/TestMozPromise.cpp @@ -86,21 +86,24 @@ void RunOnTaskQueue(TaskQueue* aQueue, FunctionType aFun) { return TestPromise::CreateAndReject(0, __func__); \ } -TEST(MozPromise, BasicResolve) { +TEST(MozPromise, BasicResolve) +{ AutoTaskQueue atq; RefPtr queue = atq.Queue(); RunOnTaskQueue(queue, [queue]() -> void { TestPromise::CreateAndResolve(42, __func__) - ->Then(queue, __func__, - [queue](int aResolveValue) -> void { - EXPECT_EQ(aResolveValue, 42); - queue->BeginShutdown(); - }, - DO_FAIL); + ->Then( + queue, __func__, + [queue](int aResolveValue) -> void { + EXPECT_EQ(aResolveValue, 42); + queue->BeginShutdown(); + }, + DO_FAIL); }); } -TEST(MozPromise, BasicReject) { +TEST(MozPromise, BasicReject) +{ AutoTaskQueue atq; RefPtr queue = atq.Queue(); RunOnTaskQueue(queue, [queue]() -> void { @@ -112,7 +115,8 @@ TEST(MozPromise, BasicReject) { }); } -TEST(MozPromise, BasicResolveOrRejectResolved) { +TEST(MozPromise, BasicResolveOrRejectResolved) +{ AutoTaskQueue atq; RefPtr queue = atq.Queue(); RunOnTaskQueue(queue, [queue]() -> void { @@ -129,7 +133,8 @@ TEST(MozPromise, BasicResolveOrRejectResolved) { }); } -TEST(MozPromise, BasicResolveOrRejectRejected) { +TEST(MozPromise, BasicResolveOrRejectRejected) +{ AutoTaskQueue atq; RefPtr queue = atq.Queue(); RunOnTaskQueue(queue, [queue]() -> void { @@ -146,7 +151,8 @@ TEST(MozPromise, BasicResolveOrRejectRejected) { }); } -TEST(MozPromise, AsyncResolve) { +TEST(MozPromise, AsyncResolve) +{ AutoTaskQueue atq; RefPtr queue = atq.Queue(); RunOnTaskQueue(queue, [queue]() -> void { @@ -168,51 +174,57 @@ TEST(MozPromise, AsyncResolve) { ref = c.get(); Unused << queue->Dispatch(ref.forget()); - p->Then(queue, __func__, - [queue, a, b, c](int aResolveValue) -> void { - EXPECT_EQ(aResolveValue, 42); - a->Cancel(); - b->Cancel(); - c->Cancel(); - queue->BeginShutdown(); - }, - DO_FAIL); + p->Then( + queue, __func__, + [queue, a, b, c](int aResolveValue) -> void { + EXPECT_EQ(aResolveValue, 42); + a->Cancel(); + b->Cancel(); + c->Cancel(); + queue->BeginShutdown(); + }, + DO_FAIL); }); } -TEST(MozPromise, CompletionPromises) { +TEST(MozPromise, CompletionPromises) +{ bool invokedPass = false; AutoTaskQueue atq; RefPtr queue = atq.Queue(); RunOnTaskQueue(queue, [queue, &invokedPass]() -> void { TestPromise::CreateAndResolve(40, __func__) - ->Then(queue, __func__, - [](int aVal) -> RefPtr { - return TestPromise::CreateAndResolve(aVal + 10, __func__); - }, - DO_FAIL) - ->Then(queue, __func__, - [&invokedPass](int aVal) { - invokedPass = true; - return TestPromise::CreateAndResolve(aVal, __func__); - }, - DO_FAIL) - ->Then(queue, __func__, - [queue](int aVal) -> RefPtr { - RefPtr p = - new TestPromise::Private(__func__); - nsCOMPtr resolver = new DelayedResolveOrReject( - queue, p, RRValue::MakeResolve(aVal - 8), 10); - Unused << queue->Dispatch(resolver.forget()); - return RefPtr(p); - }, - DO_FAIL) - ->Then(queue, __func__, - [](int aVal) -> RefPtr { - return TestPromise::CreateAndReject(double(aVal - 42) + 42.0, - __func__); - }, - DO_FAIL) + ->Then( + queue, __func__, + [](int aVal) -> RefPtr { + return TestPromise::CreateAndResolve(aVal + 10, __func__); + }, + DO_FAIL) + ->Then( + queue, __func__, + [&invokedPass](int aVal) { + invokedPass = true; + return TestPromise::CreateAndResolve(aVal, __func__); + }, + DO_FAIL) + ->Then( + queue, __func__, + [queue](int aVal) -> RefPtr { + RefPtr p = + new TestPromise::Private(__func__); + nsCOMPtr resolver = new DelayedResolveOrReject( + queue, p, RRValue::MakeResolve(aVal - 8), 10); + Unused << queue->Dispatch(resolver.forget()); + return RefPtr(p); + }, + DO_FAIL) + ->Then( + queue, __func__, + [](int aVal) -> RefPtr { + return TestPromise::CreateAndReject(double(aVal - 42) + 42.0, + __func__); + }, + DO_FAIL) ->Then(queue, __func__, DO_FAIL, [queue, &invokedPass](double aVal) -> void { EXPECT_EQ(aVal, 42.0); @@ -222,7 +234,8 @@ TEST(MozPromise, CompletionPromises) { }); } -TEST(MozPromise, PromiseAllResolve) { +TEST(MozPromise, PromiseAllResolve) +{ AutoTaskQueue atq; RefPtr queue = atq.Queue(); RunOnTaskQueue(queue, [queue]() -> void { @@ -232,19 +245,21 @@ TEST(MozPromise, PromiseAllResolve) { promises.AppendElement(TestPromise::CreateAndResolve(42, __func__)); TestPromise::All(queue, promises) - ->Then(queue, __func__, - [queue](const nsTArray& aResolveValues) -> void { - EXPECT_EQ(aResolveValues.Length(), 3UL); - EXPECT_EQ(aResolveValues[0], 22); - EXPECT_EQ(aResolveValues[1], 32); - EXPECT_EQ(aResolveValues[2], 42); - queue->BeginShutdown(); - }, - []() { EXPECT_TRUE(false); }); + ->Then( + queue, __func__, + [queue](const nsTArray& aResolveValues) -> void { + EXPECT_EQ(aResolveValues.Length(), 3UL); + EXPECT_EQ(aResolveValues[0], 22); + EXPECT_EQ(aResolveValues[1], 32); + EXPECT_EQ(aResolveValues[2], 42); + queue->BeginShutdown(); + }, + []() { EXPECT_TRUE(false); }); }); } -TEST(MozPromise, PromiseAllReject) { +TEST(MozPromise, PromiseAllReject) +{ AutoTaskQueue atq; RefPtr queue = atq.Queue(); RunOnTaskQueue(queue, [queue]() -> void { @@ -256,17 +271,19 @@ TEST(MozPromise, PromiseAllReject) { promises.AppendElement(TestPromise::CreateAndReject(52.0, __func__)); TestPromise::All(queue, promises) - ->Then(queue, __func__, []() { EXPECT_TRUE(false); }, - [queue](float aRejectValue) -> void { - EXPECT_EQ(aRejectValue, 32.0); - queue->BeginShutdown(); - }); + ->Then( + queue, __func__, []() { EXPECT_TRUE(false); }, + [queue](float aRejectValue) -> void { + EXPECT_EQ(aRejectValue, 32.0); + queue->BeginShutdown(); + }); }); } // Test we don't hit the assertions in MozPromise when exercising promise // chaining upon task queue shutdown. -TEST(MozPromise, Chaining) { +TEST(MozPromise, Chaining) +{ // We declare this variable before |atq| to ensure // the destructor is run after |holder.Disconnect()|. MozPromiseRequestHolder holder; @@ -278,31 +295,36 @@ TEST(MozPromise, Chaining) { auto p = TestPromise::CreateAndResolve(42, __func__); const size_t kIterations = 100; for (size_t i = 0; i < kIterations; ++i) { - p = p->Then(queue, __func__, - [](int aVal) { - EXPECT_EQ(aVal, 42); - return TestPromise::CreateAndResolve(aVal, __func__); - }, - [](double aVal) { - return TestPromise::CreateAndReject(aVal, __func__); - }); + p = p->Then( + queue, __func__, + [](int aVal) { + EXPECT_EQ(aVal, 42); + return TestPromise::CreateAndResolve(aVal, __func__); + }, + [](double aVal) { + return TestPromise::CreateAndReject(aVal, __func__); + }); if (i == kIterations / 2) { - p->Then(queue, __func__, - [queue, &holder]() { - holder.Disconnect(); - queue->BeginShutdown(); - }, - DO_FAIL); + p->Then( + queue, __func__, + [queue, &holder]() { + holder.Disconnect(); + queue->BeginShutdown(); + }, + DO_FAIL); } } // We will hit the assertion if we don't disconnect the leaf Request // in the promise chain. - p->Then(queue, __func__, []() {}, []() {})->Track(holder); + p->Then( + queue, __func__, []() {}, []() {}) + ->Track(holder); }); } -TEST(MozPromise, ResolveOrRejectValue) { +TEST(MozPromise, ResolveOrRejectValue) +{ using MyPromise = MozPromise, bool, false>; using RRValue = MyPromise::ResolveOrRejectValue; @@ -324,7 +346,8 @@ TEST(MozPromise, ResolveOrRejectValue) { EXPECT_EQ(val.ResolveValue().get(), nullptr); } -TEST(MozPromise, MoveOnlyType) { +TEST(MozPromise, MoveOnlyType) +{ using MyPromise = MozPromise, bool, true>; using RRValue = MyPromise::ResolveOrRejectValue; @@ -332,8 +355,9 @@ TEST(MozPromise, MoveOnlyType) { RefPtr queue = atq.Queue(); MyPromise::CreateAndResolve(MakeUnique(87), __func__) - ->Then(queue, __func__, [](UniquePtr aVal) { EXPECT_EQ(87, *aVal); }, - []() { EXPECT_TRUE(false); }); + ->Then( + queue, __func__, [](UniquePtr aVal) { EXPECT_EQ(87, *aVal); }, + []() { EXPECT_TRUE(false); }); MyPromise::CreateAndResolve(MakeUnique(87), __func__) ->Then(queue, __func__, [queue](RRValue&& aVal) { @@ -352,7 +376,8 @@ TEST(MozPromise, MoveOnlyType) { }); } -TEST(MozPromise, HeterogeneousChaining) { +TEST(MozPromise, HeterogeneousChaining) +{ using Promise1 = MozPromise, bool, true>; using Promise2 = MozPromise, bool, true>; using RRValue1 = Promise1::ResolveOrRejectValue; @@ -380,16 +405,18 @@ TEST(MozPromise, HeterogeneousChaining) { }); Promise1::CreateAndResolve(MakeUnique(87), __func__) - ->Then(queue, __func__, - [](UniquePtr aVal) { - EXPECT_EQ(87, *aVal); - return Promise2::CreateAndResolve(MakeUnique(94), __func__); - }, - []() { - return Promise2::CreateAndResolve(MakeUnique(95), __func__); - }) - ->Then(queue, __func__, [](UniquePtr aVal) { EXPECT_EQ(94, *aVal); }, - []() { EXPECT_FALSE(true); }); + ->Then( + queue, __func__, + [](UniquePtr aVal) { + EXPECT_EQ(87, *aVal); + return Promise2::CreateAndResolve(MakeUnique(94), __func__); + }, + []() { + return Promise2::CreateAndResolve(MakeUnique(95), __func__); + }) + ->Then( + queue, __func__, [](UniquePtr aVal) { EXPECT_EQ(94, *aVal); }, + []() { EXPECT_FALSE(true); }); Promise1::CreateAndResolve(MakeUnique(87), __func__) ->Then(queue, __func__, @@ -403,21 +430,25 @@ TEST(MozPromise, HeterogeneousChaining) { }); } -TEST(MozPromise, XPCOMEventTarget) { +TEST(MozPromise, XPCOMEventTarget) +{ TestPromise::CreateAndResolve(42, __func__) - ->Then(GetCurrentThreadSerialEventTarget(), __func__, - [](int aResolveValue) -> void { EXPECT_EQ(aResolveValue, 42); }, - DO_FAIL); + ->Then( + GetCurrentThreadSerialEventTarget(), __func__, + [](int aResolveValue) -> void { EXPECT_EQ(aResolveValue, 42); }, + DO_FAIL); // Spin the event loop. NS_ProcessPendingEvents(nullptr); } -TEST(MozPromise, MessageLoopEventTarget) { +TEST(MozPromise, MessageLoopEventTarget) +{ TestPromise::CreateAndResolve(42, __func__) - ->Then(MessageLoop::current()->SerialEventTarget(), __func__, - [](int aResolveValue) -> void { EXPECT_EQ(aResolveValue, 42); }, - DO_FAIL); + ->Then( + MessageLoop::current()->SerialEventTarget(), __func__, + [](int aResolveValue) -> void { EXPECT_EQ(aResolveValue, 42); }, + DO_FAIL); // Spin the event loop. NS_ProcessPendingEvents(nullptr); diff --git a/xpcom/tests/gtest/TestMruCache.cpp b/xpcom/tests/gtest/TestMruCache.cpp index 9b5ccb57a3406..5129c79836546 100644 --- a/xpcom/tests/gtest/TestMruCache.cpp +++ b/xpcom/tests/gtest/TestMruCache.cpp @@ -55,7 +55,8 @@ static nsCString MakeStringKey(char aKey) { return key; } -TEST(MruCache, TestNullChecker) { +TEST(MruCache, TestNullChecker) +{ using mozilla::detail::EmptyChecker; { @@ -84,7 +85,8 @@ TEST(MruCache, TestNullChecker) { } } -TEST(MruCache, TestEmptyCache) { +TEST(MruCache, TestEmptyCache) +{ { // Test a basic empty cache. IntMap mru; @@ -126,7 +128,8 @@ TEST(MruCache, TestEmptyCache) { } } -TEST(MruCache, TestPut) { +TEST(MruCache, TestPut) +{ IntMap mru; // Fill it up. @@ -144,7 +147,8 @@ TEST(MruCache, TestPut) { } } -TEST(MruCache, TestPutConvertable) { +TEST(MruCache, TestPutConvertable) +{ UintPtrMap mru; // Fill it up. @@ -163,7 +167,8 @@ TEST(MruCache, TestPutConvertable) { } } -TEST(MruCache, TestOverwriting) { +TEST(MruCache, TestOverwriting) +{ // Test overwrting IntMap mru; @@ -182,7 +187,8 @@ TEST(MruCache, TestOverwriting) { } } -TEST(MruCache, TestRemove) { +TEST(MruCache, TestRemove) +{ { IntMap mru; @@ -253,7 +259,8 @@ TEST(MruCache, TestRemove) { } } -TEST(MruCache, TestClear) { +TEST(MruCache, TestClear) +{ IntMap mru; // Fill it up. @@ -273,7 +280,8 @@ TEST(MruCache, TestClear) { } } -TEST(MruCache, TestLookupMissingAndSet) { +TEST(MruCache, TestLookupMissingAndSet) +{ IntMap mru; // Value not found. @@ -306,7 +314,8 @@ TEST(MruCache, TestLookupMissingAndSet) { EXPECT_EQ(p.Data(), 2); } -TEST(MruCache, TestLookupAndOverwrite) { +TEST(MruCache, TestLookupAndOverwrite) +{ IntMap mru; // Set 1. @@ -331,7 +340,8 @@ TEST(MruCache, TestLookupAndOverwrite) { EXPECT_EQ(p.Data(), 32); } -TEST(MruCache, TestLookupAndRemove) { +TEST(MruCache, TestLookupAndRemove) +{ IntMap mru; // Set 1. @@ -349,7 +359,8 @@ TEST(MruCache, TestLookupAndRemove) { EXPECT_FALSE(p); } -TEST(MruCache, TestLookupNotMatchedAndRemove) { +TEST(MruCache, TestLookupNotMatchedAndRemove) +{ IntMap mru; // Set 1. @@ -368,7 +379,8 @@ TEST(MruCache, TestLookupNotMatchedAndRemove) { EXPECT_EQ(p.Data(), 1); } -TEST(MruCache, TestLookupAndSetWithMove) { +TEST(MruCache, TestLookupAndSetWithMove) +{ StringStructMap mru; const nsCString key = MakeStringKey((char)1); diff --git a/xpcom/tests/gtest/TestMultiplexInputStream.cpp b/xpcom/tests/gtest/TestMultiplexInputStream.cpp index f3cdd2268b3b7..7c53d0951c90c 100644 --- a/xpcom/tests/gtest/TestMultiplexInputStream.cpp +++ b/xpcom/tests/gtest/TestMultiplexInputStream.cpp @@ -14,7 +14,8 @@ #include "nsThreadUtils.h" #include "Helpers.h" -TEST(MultiplexInputStream, Seek_SET) { +TEST(MultiplexInputStream, Seek_SET) +{ nsCString buf1; nsCString buf2; nsCString buf3; @@ -130,7 +131,8 @@ static already_AddRefed CreateStreamHelper() { } // AsyncWait - without EventTarget -TEST(TestMultiplexInputStream, AsyncWait_withoutEventTarget) { +TEST(TestMultiplexInputStream, AsyncWait_withoutEventTarget) +{ nsCOMPtr is = CreateStreamHelper(); nsCOMPtr ais = do_QueryInterface(is); @@ -143,7 +145,8 @@ TEST(TestMultiplexInputStream, AsyncWait_withoutEventTarget) { } // AsyncWait - with EventTarget -TEST(TestMultiplexInputStream, AsyncWait_withEventTarget) { +TEST(TestMultiplexInputStream, AsyncWait_withEventTarget) +{ nsCOMPtr is = CreateStreamHelper(); nsCOMPtr ais = do_QueryInterface(is); @@ -162,7 +165,8 @@ TEST(TestMultiplexInputStream, AsyncWait_withEventTarget) { } // AsyncWait - without EventTarget - closureOnly -TEST(TestMultiplexInputStream, AsyncWait_withoutEventTarget_closureOnly) { +TEST(TestMultiplexInputStream, AsyncWait_withoutEventTarget_closureOnly) +{ nsCOMPtr is = CreateStreamHelper(); nsCOMPtr ais = do_QueryInterface(is); @@ -179,7 +183,8 @@ TEST(TestMultiplexInputStream, AsyncWait_withoutEventTarget_closureOnly) { } // AsyncWait - withEventTarget - closureOnly -TEST(TestMultiplexInputStream, AsyncWait_withEventTarget_closureOnly) { +TEST(TestMultiplexInputStream, AsyncWait_withEventTarget_closureOnly) +{ nsCOMPtr is = CreateStreamHelper(); nsCOMPtr ais = do_QueryInterface(is); @@ -294,7 +299,8 @@ class AsyncStream final : public nsIAsyncInputStream { NS_IMPL_ISUPPORTS(AsyncStream, nsIInputStream, nsIAsyncInputStream) -TEST(TestMultiplexInputStream, Available) { +TEST(TestMultiplexInputStream, Available) +{ nsCOMPtr multiplexStream = do_CreateInstance("@mozilla.org/io/multiplex-input-stream;1"); @@ -391,7 +397,8 @@ class NonBufferableStringStream final : public nsIInputStream { NS_IMPL_ISUPPORTS(NonBufferableStringStream, nsIInputStream) -TEST(TestMultiplexInputStream, Bufferable) { +TEST(TestMultiplexInputStream, Bufferable) +{ nsCOMPtr multiplexStream = do_CreateInstance("@mozilla.org/io/multiplex-input-stream;1"); @@ -426,7 +433,8 @@ TEST(TestMultiplexInputStream, Bufferable) { ASSERT_TRUE(!strncmp(buf3, "Hello world", size)); } -TEST(TestMultiplexInputStream, QILengthInputStream) { +TEST(TestMultiplexInputStream, QILengthInputStream) +{ nsCString buf; buf.AssignLiteral("Hello world"); @@ -486,7 +494,8 @@ TEST(TestMultiplexInputStream, QILengthInputStream) { } } -TEST(TestMultiplexInputStream, LengthInputStream) { +TEST(TestMultiplexInputStream, LengthInputStream) +{ nsCOMPtr multiplexStream = do_CreateInstance("@mozilla.org/io/multiplex-input-stream;1"); diff --git a/xpcom/tests/gtest/TestNSPRLogModulesParser.cpp b/xpcom/tests/gtest/TestNSPRLogModulesParser.cpp index ecc93ddc7fb0f..e055aeeea59d5 100644 --- a/xpcom/tests/gtest/TestNSPRLogModulesParser.cpp +++ b/xpcom/tests/gtest/TestNSPRLogModulesParser.cpp @@ -10,7 +10,8 @@ using namespace mozilla; -TEST(NSPRLogModulesParser, Empty) { +TEST(NSPRLogModulesParser, Empty) +{ bool callbackInvoked = false; auto callback = [&](const char*, mozilla::LogLevel, int32_t) mutable { callbackInvoked = true; @@ -23,7 +24,8 @@ TEST(NSPRLogModulesParser, Empty) { EXPECT_FALSE(callbackInvoked); } -TEST(NSPRLogModulesParser, DefaultLevel) { +TEST(NSPRLogModulesParser, DefaultLevel) +{ bool callbackInvoked = false; auto callback = [&](const char* aName, mozilla::LogLevel aLevel, int32_t) { EXPECT_STREQ("Foo", aName); @@ -39,7 +41,8 @@ TEST(NSPRLogModulesParser, DefaultLevel) { EXPECT_TRUE(callbackInvoked); } -TEST(NSPRLogModulesParser, LevelSpecified) { +TEST(NSPRLogModulesParser, LevelSpecified) +{ std::pair expected[] = { {"Foo:0", mozilla::LogLevel::Disabled}, {"Foo:1", mozilla::LogLevel::Error}, @@ -67,7 +70,8 @@ TEST(NSPRLogModulesParser, LevelSpecified) { } } -TEST(NSPRLogModulesParser, Multiple) { +TEST(NSPRLogModulesParser, Multiple) +{ std::pair expected[] = { {"timestamp", mozilla::LogLevel::Error}, {"Foo", mozilla::LogLevel::Info}, @@ -94,7 +98,8 @@ TEST(NSPRLogModulesParser, Multiple) { EXPECT_EQ(kExpectedCount, count); } -TEST(NSPRLogModulesParser, RawArg) { +TEST(NSPRLogModulesParser, RawArg) +{ bool callbackInvoked = false; auto callback = [&](const char* aName, mozilla::LogLevel aLevel, int32_t aRawValue) { diff --git a/xpcom/tests/gtest/TestNonBlockingAsyncInputStream.cpp b/xpcom/tests/gtest/TestNonBlockingAsyncInputStream.cpp index 51e99e377eca9..d4c27f59d952b 100644 --- a/xpcom/tests/gtest/TestNonBlockingAsyncInputStream.cpp +++ b/xpcom/tests/gtest/TestNonBlockingAsyncInputStream.cpp @@ -7,7 +7,8 @@ #include "nsStringStream.h" #include "Helpers.h" -TEST(TestNonBlockingAsyncInputStream, Simple) { +TEST(TestNonBlockingAsyncInputStream, Simple) +{ nsCString data; data.Assign("Hello world!"); @@ -69,7 +70,8 @@ static nsresult ReadSegmentsFunction(nsIInputStream* aInStr, void* aClosure, return NS_OK; } -TEST(TestNonBlockingAsyncInputStream, ReadSegments) { +TEST(TestNonBlockingAsyncInputStream, ReadSegments) +{ nsCString data; data.Assign("Hello world!"); @@ -94,7 +96,8 @@ TEST(TestNonBlockingAsyncInputStream, ReadSegments) { ASSERT_TRUE(data.Equals(nsCString(buffer, read))); } -TEST(TestNonBlockingAsyncInputStream, AsyncWait_Simple) { +TEST(TestNonBlockingAsyncInputStream, AsyncWait_Simple) +{ nsCString data; data.Assign("Hello world!"); @@ -138,8 +141,8 @@ TEST(TestNonBlockingAsyncInputStream, AsyncWait_Simple) { ASSERT_TRUE(data.Equals(nsCString(buffer, read))); } -TEST(TestNonBlockingAsyncInputStream, - AsyncWait_ClosureOnly_withoutEventTarget) { +TEST(TestNonBlockingAsyncInputStream, AsyncWait_ClosureOnly_withoutEventTarget) +{ nsCString data; data.Assign("Hello world!"); @@ -166,7 +169,8 @@ TEST(TestNonBlockingAsyncInputStream, ASSERT_TRUE(cb->Called()); } -TEST(TestNonBlockingAsyncInputStream, AsyncWait_ClosureOnly_withEventTarget) { +TEST(TestNonBlockingAsyncInputStream, AsyncWait_ClosureOnly_withEventTarget) +{ nsCString data; data.Assign("Hello world!"); @@ -197,7 +201,8 @@ TEST(TestNonBlockingAsyncInputStream, AsyncWait_ClosureOnly_withEventTarget) { ASSERT_TRUE(cb->Called()); } -TEST(TestNonBlockingAsyncInputStream, Helper) { +TEST(TestNonBlockingAsyncInputStream, Helper) +{ nsCString data; data.Assign("Hello world!"); @@ -314,7 +319,8 @@ NS_INTERFACE_MAP_BEGIN(QIInputStream) NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIInputStream) NS_INTERFACE_MAP_END -TEST(TestNonBlockingAsyncInputStream, QI) { +TEST(TestNonBlockingAsyncInputStream, QI) +{ // Let's test ::Create() returning error. nsCOMPtr async; diff --git a/xpcom/tests/gtest/TestNsDeque.cpp b/xpcom/tests/gtest/TestNsDeque.cpp index b6f080f8436b9..9e18a9e531510 100644 --- a/xpcom/tests/gtest/TestNsDeque.cpp +++ b/xpcom/tests/gtest/TestNsDeque.cpp @@ -59,7 +59,8 @@ class ForEachAdder : public nsDequeFunctor { using namespace TestNsDeque; -TEST(NsDeque, OriginalTest) { +TEST(NsDeque, OriginalTest) +{ const size_t size = 200; int ints[size]; size_t i = 0; @@ -136,7 +137,8 @@ TEST(NsDeque, OriginalTest) { EXPECT_EQ(0u, theDeque.GetSize()) << "Deque should finish empty."; } -TEST(NsDeque, OriginalFlaw) { +TEST(NsDeque, OriginalFlaw) +{ int ints[200]; int i = 0; int temp; @@ -172,7 +174,8 @@ TEST(NsDeque, OriginalFlaw) { } } -TEST(NsDeque, TestObjectAt) { +TEST(NsDeque, TestObjectAt) +{ nsDeque d; const int count = 10; int ints[count]; @@ -194,7 +197,8 @@ TEST(NsDeque, TestObjectAt) { } } -TEST(NsDeque, TestPushFront) { +TEST(NsDeque, TestPushFront) +{ // PushFront has some interesting corner cases, primarily we're interested in // whether: // - wrapping around works properly @@ -248,7 +252,8 @@ static void CheckIfQueueEmpty(nsDeque& d) { << "Invalid operation should return nullptr"; } -TEST(NsDeque, TestEmpty) { +TEST(NsDeque, TestEmpty) +{ // Make sure nsDeque gives sane results if it's empty. nsDeque d; size_t numberOfEntries = 8; @@ -270,7 +275,8 @@ TEST(NsDeque, TestEmpty) { CheckIfQueueEmpty(d); } -TEST(NsDeque, TestEraseMethod) { +TEST(NsDeque, TestEraseMethod) +{ nsDeque d; const size_t numberOfEntries = 8; @@ -286,7 +292,8 @@ TEST(NsDeque, TestEraseMethod) { CheckIfQueueEmpty(d); } -TEST(NsDeque, TestEraseShouldCallDeallocator) { +TEST(NsDeque, TestEraseShouldCallDeallocator) +{ nsDeque d(new Deallocator()); const size_t NumTestValues = 8; @@ -308,7 +315,8 @@ TEST(NsDeque, TestEraseShouldCallDeallocator) { } } -TEST(NsDeque, TestForEach) { +TEST(NsDeque, TestForEach) +{ nsDeque d(new Deallocator()); const size_t NumTestValues = 8; int sum = 0; @@ -328,7 +336,8 @@ TEST(NsDeque, TestForEach) { d.Erase(); } -TEST(NsDeque, TestConstRangeFor) { +TEST(NsDeque, TestConstRangeFor) +{ nsDeque d(new Deallocator()); const size_t NumTestValues = 3; @@ -350,7 +359,8 @@ TEST(NsDeque, TestConstRangeFor) { EXPECT_EQ(1 + 2 + 3, sum) << "Const-range-for should iterate over values"; } -TEST(NsDeque, TestRangeFor) { +TEST(NsDeque, TestRangeFor) +{ const size_t NumTestValues = 3; struct Test { size_t runAfterLoopCount; diff --git a/xpcom/tests/gtest/TestNsRefPtr.cpp b/xpcom/tests/gtest/TestNsRefPtr.cpp index cab6562166626..3c70842ce29e6 100644 --- a/xpcom/tests/gtest/TestNsRefPtr.cpp +++ b/xpcom/tests/gtest/TestNsRefPtr.cpp @@ -192,7 +192,8 @@ void Bar::VirtualConstMemberFunction(int aArg1, int* aArgPtr, using namespace TestNsRefPtr; -TEST(nsRefPtr, AddRefAndRelease) { +TEST(nsRefPtr, AddRefAndRelease) +{ Foo::total_constructions_ = 0; Foo::total_destructions_ = 0; @@ -239,7 +240,8 @@ TEST(nsRefPtr, AddRefAndRelease) { } } -TEST(nsRefPtr, VirtualDestructor) { +TEST(nsRefPtr, VirtualDestructor) +{ Bar::total_destructions_ = 0; { @@ -250,7 +252,8 @@ TEST(nsRefPtr, VirtualDestructor) { ASSERT_EQ(Bar::total_destructions_, 1); } -TEST(nsRefPtr, Equality) { +TEST(nsRefPtr, Equality) +{ Foo::total_constructions_ = 0; Foo::total_destructions_ = 0; @@ -287,7 +290,8 @@ TEST(nsRefPtr, Equality) { ASSERT_EQ(Foo::total_destructions_, 2); } -TEST(nsRefPtr, AddRefHelpers) { +TEST(nsRefPtr, AddRefHelpers) +{ Foo::total_addrefs_ = 0; { @@ -319,7 +323,8 @@ TEST(nsRefPtr, AddRefHelpers) { } } -TEST(nsRefPtr, QueryInterface) { +TEST(nsRefPtr, QueryInterface) +{ Foo::total_queries_ = 0; Bar::total_queries_ = 0; @@ -392,7 +397,8 @@ static void AnFooPtrPtrContext(Foo**) {} static void AVoidPtrPtrContext(void**) {} } // namespace TestNsRefPtr -TEST(nsRefPtr, RefPtrCompilationTests) { +TEST(nsRefPtr, RefPtrCompilationTests) +{ { RefPtr fooP; diff --git a/xpcom/tests/gtest/TestObserverArray.cpp b/xpcom/tests/gtest/TestObserverArray.cpp index 87c28a647a99b..c13334dec8c90 100644 --- a/xpcom/tests/gtest/TestObserverArray.cpp +++ b/xpcom/tests/gtest/TestObserverArray.cpp @@ -29,7 +29,8 @@ typedef nsTObserverArray IntArray; << "During test " << testNum << ", iterator finished too early"; \ } while (0) -TEST(ObserverArray, Tests) { +TEST(ObserverArray, Tests) +{ IntArray arr; arr.AppendElement(3); arr.AppendElement(4); @@ -80,10 +81,11 @@ TEST(ObserverArray, Tests) { // Removals + Appends static int test14Expected[] = {4, 6, 7}; - DO_TEST(ForwardIterator, test14Expected, if (count == 1) { - arr.RemoveElementAt(1); - arr.AppendElement(7); - }); + DO_TEST( + ForwardIterator, test14Expected, if (count == 1) { + arr.RemoveElementAt(1); + arr.AppendElement(7); + }); DO_TEST(ForwardIterator, test14Expected, {/* nothing */}); arr.AppendElement(2); @@ -91,10 +93,11 @@ TEST(ObserverArray, Tests) { DO_TEST(ForwardIterator, test16Expected, {/* nothing */}); static int test17Expected[] = {4, 7, 2}; - DO_TEST(EndLimitedIterator, test17Expected, if (count == 1) { - arr.RemoveElementAt(1); - arr.AppendElement(8); - }); + DO_TEST( + EndLimitedIterator, test17Expected, if (count == 1) { + arr.RemoveElementAt(1); + arr.AppendElement(8); + }); static int test18Expected[] = {4, 7, 2, 8}; DO_TEST(ForwardIterator, test18Expected, {/* nothing */}); @@ -107,8 +110,9 @@ TEST(ObserverArray, Tests) { arr.PrependElementUnlessExists(7); DO_TEST(ForwardIterator, test19Expected, {/* nothing */}); - DO_TEST(ForwardIterator, test19Expected, - if (count == 1) { arr.PrependElementUnlessExists(9); }); + DO_TEST( + ForwardIterator, test19Expected, + if (count == 1) { arr.PrependElementUnlessExists(9); }); static int test22Expected[] = {9, 3, 4, 7, 2, 8}; DO_TEST(ForwardIterator, test22Expected, {}); diff --git a/xpcom/tests/gtest/TestObserverService.cpp b/xpcom/tests/gtest/TestObserverService.cpp index e5502ba5c0e35..1ed00b16c9ba7 100644 --- a/xpcom/tests/gtest/TestObserverService.cpp +++ b/xpcom/tests/gtest/TestObserverService.cpp @@ -93,7 +93,8 @@ static void TestExpectedCount(nsIObserverService* svc, const char* topic, EXPECT_EQ(count, expected); } -TEST(ObserverService, Creation) { +TEST(ObserverService, Creation) +{ nsresult rv; nsCOMPtr svc = do_CreateInstance("@mozilla.org/observer-service;1", &rv); @@ -102,7 +103,8 @@ TEST(ObserverService, Creation) { ASSERT_TRUE(svc); } -TEST(ObserverService, AddObserver) { +TEST(ObserverService, AddObserver) +{ nsCOMPtr svc = do_CreateInstance("@mozilla.org/observer-service;1"); @@ -117,7 +119,8 @@ TEST(ObserverService, AddObserver) { testResult(rv); } -TEST(ObserverService, RemoveObserver) { +TEST(ObserverService, RemoveObserver) +{ nsCOMPtr svc = do_CreateInstance("@mozilla.org/observer-service;1"); @@ -143,7 +146,8 @@ TEST(ObserverService, RemoveObserver) { ASSERT_TRUE(NS_FAILED(rv)); } -TEST(ObserverService, EnumerateEmpty) { +TEST(ObserverService, EnumerateEmpty) +{ nsCOMPtr svc = do_CreateInstance("@mozilla.org/observer-service;1"); @@ -157,7 +161,8 @@ TEST(ObserverService, EnumerateEmpty) { TestExpectedCount(svc, "A", 0); } -TEST(ObserverService, Enumerate) { +TEST(ObserverService, Enumerate) +{ nsCOMPtr svc = do_CreateInstance("@mozilla.org/observer-service;1"); @@ -180,7 +185,8 @@ TEST(ObserverService, Enumerate) { TestExpectedCount(svc, "Bar", kBarCount); } -TEST(ObserverService, EnumerateWeakRefs) { +TEST(ObserverService, EnumerateWeakRefs) +{ nsCOMPtr svc = do_CreateInstance("@mozilla.org/observer-service;1"); @@ -218,7 +224,8 @@ TEST(ObserverService, EnumerateWeakRefs) { TestExpectedCount(svc, "Foo", kFooCount + 2); } -TEST(ObserverService, TestNotify) { +TEST(ObserverService, TestNotify) +{ nsCString topicA; topicA.Assign("topic-A"); nsCString topicB; diff --git a/xpcom/tests/gtest/TestPLDHash.cpp b/xpcom/tests/gtest/TestPLDHash.cpp index abea40b96dd8f..bfd74b2d4827f 100644 --- a/xpcom/tests/gtest/TestPLDHash.cpp +++ b/xpcom/tests/gtest/TestPLDHash.cpp @@ -104,7 +104,8 @@ static void InitCapacityOk_EntrySizeTooBig() { PLDHashTable t(PLDHashTable::StubOps(), 256); } -TEST(PLDHashTableTest, InitCapacityOk) { +TEST(PLDHashTableTest, InitCapacityOk) +{ // Try the largest allowed capacity. With kMaxCapacity==1<<26, this // would allocate (if we added an element) 0.5GB of entry store on 32-bit // platforms and 1GB on 64-bit platforms. @@ -134,7 +135,8 @@ TEST(PLDHashTableTest, InitCapacityOk) { // platforms, so such a test wouldn't be reliable. } -TEST(PLDHashTableTest, LazyStorage) { +TEST(PLDHashTableTest, LazyStorage) +{ PLDHashTable t(PLDHashTable::StubOps(), sizeof(PLDHashEntryStub)); // PLDHashTable allocates entry storage lazily. Check that all the non-add @@ -174,7 +176,8 @@ static const PLDHashTableOps trivialOps = { TrivialHash, PLDHashTable::MatchEntryStub, PLDHashTable::MoveEntryStub, PLDHashTable::ClearEntryStub, TrivialInitEntry}; -TEST(PLDHashTableTest, MoveSemantics) { +TEST(PLDHashTableTest, MoveSemantics) +{ PLDHashTable t1(&trivialOps, sizeof(PLDHashEntryStub)); t1.Add((const void*)88); PLDHashTable t2(&trivialOps, sizeof(PLDHashEntryStub)); @@ -211,7 +214,8 @@ TEST(PLDHashTableTest, MoveSemantics) { PLDHashTable t10(std::move(t9)); // new table constructed with inited } -TEST(PLDHashTableTest, Clear) { +TEST(PLDHashTableTest, Clear) +{ PLDHashTable t1(&trivialOps, sizeof(PLDHashEntryStub)); t1.Clear(); @@ -239,7 +243,8 @@ TEST(PLDHashTableTest, Clear) { ASSERT_EQ(t1.EntryCount(), 0u); } -TEST(PLDHashTableTest, Iterator) { +TEST(PLDHashTableTest, Iterator) +{ PLDHashTable t(&trivialOps, sizeof(PLDHashEntryStub)); // Explicitly test the move constructor. We do this because, due to copy @@ -335,7 +340,8 @@ TEST(PLDHashTableTest, Iterator) { // // Also, it's slow, and so should always be last. #ifdef HAVE_64BIT_BUILD -TEST(PLDHashTableTest, GrowToMaxCapacity) { +TEST(PLDHashTableTest, GrowToMaxCapacity) +{ // This is infallible. PLDHashTable* t = new PLDHashTable(&trivialOps, sizeof(PLDHashEntryStub), 128); diff --git a/xpcom/tests/gtest/TestPipes.cpp b/xpcom/tests/gtest/TestPipes.cpp index 9c8e33d373f67..175b39586e553 100644 --- a/xpcom/tests/gtest/TestPipes.cpp +++ b/xpcom/tests/gtest/TestPipes.cpp @@ -294,7 +294,8 @@ class nsPump final : public nsIRunnable { NS_IMPL_ISUPPORTS(nsPump, nsIRunnable) -TEST(Pipes, ChainedPipes) { +TEST(Pipes, ChainedPipes) +{ nsresult rv; if (gTrace) { printf("TestChainedPipes\n"); @@ -375,7 +376,8 @@ static void RunTests(uint32_t segSize, uint32_t segCount) { EXPECT_TRUE(NS_SUCCEEDED(rv)); } -TEST(Pipes, Main) { +TEST(Pipes, Main) +{ RunTests(16, 1); RunTests(4096, 16); } @@ -407,11 +409,14 @@ static void TestPipe2(uint32_t aNumBytes, } // namespace -TEST(Pipes, Blocking_32k) { TestPipe2(32 * 1024); } +TEST(Pipes, Blocking_32k) +{ TestPipe2(32 * 1024); } -TEST(Pipes, Blocking_64k) { TestPipe2(64 * 1024); } +TEST(Pipes, Blocking_64k) +{ TestPipe2(64 * 1024); } -TEST(Pipes, Blocking_128k) { TestPipe2(128 * 1024); } +TEST(Pipes, Blocking_128k) +{ TestPipe2(128 * 1024); } //////////////////////////////////////////////////////////////////////////////// @@ -574,7 +579,8 @@ static void TestPipeClone(uint32_t aTotalBytes, uint32_t aNumWrites, } // namespace -TEST(Pipes, Clone_BeforeWrite_ReadAtEnd) { +TEST(Pipes, Clone_BeforeWrite_ReadAtEnd) +{ TestPipeClone(32 * 1024, // total bytes 16, // num writes 3, // num initial clones @@ -583,7 +589,8 @@ TEST(Pipes, Clone_BeforeWrite_ReadAtEnd) { 0); // num streams to read after each write } -TEST(Pipes, Clone_BeforeWrite_ReadDuringWrite) { +TEST(Pipes, Clone_BeforeWrite_ReadDuringWrite) +{ // Since this reads all streams on every write, it should trigger the // pipe cursor roll back optimization. Currently we can only verify // this with logging. @@ -596,7 +603,8 @@ TEST(Pipes, Clone_BeforeWrite_ReadDuringWrite) { 4); // num streams to read after each write } -TEST(Pipes, Clone_DuringWrite_ReadAtEnd) { +TEST(Pipes, Clone_DuringWrite_ReadAtEnd) +{ TestPipeClone(32 * 1024, // total bytes 16, // num writes 0, // num initial clones @@ -605,7 +613,8 @@ TEST(Pipes, Clone_DuringWrite_ReadAtEnd) { 0); // num streams to read after each write } -TEST(Pipes, Clone_DuringWrite_ReadDuringWrite) { +TEST(Pipes, Clone_DuringWrite_ReadDuringWrite) +{ TestPipeClone(32 * 1024, // total bytes 16, // num writes 0, // num initial clones @@ -614,7 +623,8 @@ TEST(Pipes, Clone_DuringWrite_ReadDuringWrite) { 1); // num streams to read after each write } -TEST(Pipes, Clone_DuringWrite_ReadDuringWrite_CloseDuringWrite) { +TEST(Pipes, Clone_DuringWrite_ReadDuringWrite_CloseDuringWrite) +{ // Since this reads streams faster than we clone new ones, it should // trigger pipe segment deletion periodically. Currently we can // only verify this with logging. @@ -627,7 +637,8 @@ TEST(Pipes, Clone_DuringWrite_ReadDuringWrite_CloseDuringWrite) { 3); // num streams to read after each write } -TEST(Pipes, Write_AsyncWait) { +TEST(Pipes, Write_AsyncWait) +{ nsCOMPtr reader; nsCOMPtr writer; @@ -662,7 +673,8 @@ TEST(Pipes, Write_AsyncWait) { ASSERT_TRUE(cb->Called()); } -TEST(Pipes, Write_AsyncWait_Clone) { +TEST(Pipes, Write_AsyncWait_Clone) +{ nsCOMPtr reader; nsCOMPtr writer; @@ -744,7 +756,8 @@ TEST(Pipes, Write_AsyncWait_Clone) { testing::ConsumeAndValidateStream(reader, inputData); } -TEST(Pipes, Write_AsyncWait_Clone_CloseOriginal) { +TEST(Pipes, Write_AsyncWait_Clone_CloseOriginal) +{ nsCOMPtr reader; nsCOMPtr writer; @@ -868,7 +881,8 @@ TEST(Pipes, Write_AsyncWait_Clone_CloseOriginal) { ASSERT_TRUE(cb->Called()); } -TEST(Pipes, Read_AsyncWait) { +TEST(Pipes, Read_AsyncWait) +{ nsCOMPtr reader; nsCOMPtr writer; @@ -899,7 +913,8 @@ TEST(Pipes, Read_AsyncWait) { testing::ConsumeAndValidateStream(reader, inputData); } -TEST(Pipes, Read_AsyncWait_Clone) { +TEST(Pipes, Read_AsyncWait_Clone) +{ nsCOMPtr reader; nsCOMPtr writer; @@ -1006,13 +1021,14 @@ void TestCloseDuringRead(uint32_t aSegmentSize, uint32_t aDataSize) { } // namespace -TEST(Pipes, Close_During_Read_Partial_Segment) { - TestCloseDuringRead(1024, 512); -} +TEST(Pipes, Close_During_Read_Partial_Segment) +{ TestCloseDuringRead(1024, 512); } -TEST(Pipes, Close_During_Read_Full_Segment) { TestCloseDuringRead(1024, 1024); } +TEST(Pipes, Close_During_Read_Full_Segment) +{ TestCloseDuringRead(1024, 1024); } -TEST(Pipes, Interfaces) { +TEST(Pipes, Interfaces) +{ nsCOMPtr reader; nsCOMPtr writer; diff --git a/xpcom/tests/gtest/TestPriorityQueue.cpp b/xpcom/tests/gtest/TestPriorityQueue.cpp index afcbf69ddc599..48b78ccf958de 100644 --- a/xpcom/tests/gtest/TestPriorityQueue.cpp +++ b/xpcom/tests/gtest/TestPriorityQueue.cpp @@ -31,7 +31,8 @@ class MaxCompare { bool LessThan(const A& a, const A& b) { return a > b; } }; -TEST(PriorityQueue, Main) { +TEST(PriorityQueue, Main) +{ nsTPriorityQueue queue; EXPECT_TRUE(queue.IsEmpty()); diff --git a/xpcom/tests/gtest/TestRWLock.cpp b/xpcom/tests/gtest/TestRWLock.cpp index 3d15d9ff904eb..2a80783803861 100644 --- a/xpcom/tests/gtest/TestRWLock.cpp +++ b/xpcom/tests/gtest/TestRWLock.cpp @@ -60,7 +60,8 @@ RWLockRunnable::Run() { return NS_OK; } -TEST(RWLock, SmokeTest) { +TEST(RWLock, SmokeTest) +{ nsCOMPtr threads[sNumThreads]; RWLock rwlock("test lock"); mozilla::Atomic data(0); diff --git a/xpcom/tests/gtest/TestRacingServiceManager.cpp b/xpcom/tests/gtest/TestRacingServiceManager.cpp index 61cb248461e1e..cfbb14c32ebca 100644 --- a/xpcom/tests/gtest/TestRacingServiceManager.cpp +++ b/xpcom/tests/gtest/TestRacingServiceManager.cpp @@ -222,7 +222,8 @@ static const mozilla::Module::ContractIDEntry kLocalContracts[] = { static const mozilla::Module kLocalModule = {mozilla::Module::kVersion, kLocalCIDs, kLocalContracts}; -TEST(RacingServiceManager, Test) { +TEST(RacingServiceManager, Test) +{ nsresult rv; XRE_AddStaticComponent(&kLocalModule); diff --git a/xpcom/tests/gtest/TestRecursiveMutex.cpp b/xpcom/tests/gtest/TestRecursiveMutex.cpp index 063fd460ae55d..3f0557aed3129 100644 --- a/xpcom/tests/gtest/TestRecursiveMutex.cpp +++ b/xpcom/tests/gtest/TestRecursiveMutex.cpp @@ -14,7 +14,8 @@ using mozilla::RecursiveMutexAutoLock; // Basic test to make sure the underlying implementation of RecursiveMutex is, // well, actually recursively acquirable. -TEST(RecursiveMutex, SmokeTest) { +TEST(RecursiveMutex, SmokeTest) +{ RecursiveMutex mutex("testing mutex"); RecursiveMutexAutoLock lock1(mutex); diff --git a/xpcom/tests/gtest/TestSlicedInputStream.cpp b/xpcom/tests/gtest/TestSlicedInputStream.cpp index 004e3d081a395..c14856b4d23ed 100644 --- a/xpcom/tests/gtest/TestSlicedInputStream.cpp +++ b/xpcom/tests/gtest/TestSlicedInputStream.cpp @@ -137,7 +137,8 @@ static SlicedInputStream* CreateNonSeekableStreams(uint32_t aSize, } // Same start, same length. -TEST(TestSlicedInputStream, Simple) { +TEST(TestSlicedInputStream, Simple) +{ const size_t kBufSize = 4096; nsCString buf; @@ -156,7 +157,8 @@ TEST(TestSlicedInputStream, Simple) { } // Simple sliced stream - seekable -TEST(TestSlicedInputStream, Sliced) { +TEST(TestSlicedInputStream, Sliced) +{ const size_t kBufSize = 4096; nsCString buf; @@ -174,7 +176,8 @@ TEST(TestSlicedInputStream, Sliced) { } // Simple sliced stream - non seekable -TEST(TestSlicedInputStream, SlicedNoSeek) { +TEST(TestSlicedInputStream, SlicedNoSeek) +{ const size_t kBufSize = 4096; nsCString buf; @@ -193,7 +196,8 @@ TEST(TestSlicedInputStream, SlicedNoSeek) { } // Big inputStream - seekable -TEST(TestSlicedInputStream, BigSliced) { +TEST(TestSlicedInputStream, BigSliced) +{ const size_t kBufSize = 4096 * 40; nsCString buf; @@ -213,7 +217,8 @@ TEST(TestSlicedInputStream, BigSliced) { } // Big inputStream - non seekable -TEST(TestSlicedInputStream, BigSlicedNoSeek) { +TEST(TestSlicedInputStream, BigSlicedNoSeek) +{ const size_t kBufSize = 4096 * 40; nsCString buf; @@ -233,7 +238,8 @@ TEST(TestSlicedInputStream, BigSlicedNoSeek) { } // Available size. -TEST(TestSlicedInputStream, Available) { +TEST(TestSlicedInputStream, Available) +{ nsCString buf; RefPtr sis = CreateNonSeekableStreams(500000, 4, 400000, buf); @@ -265,7 +271,8 @@ TEST(TestSlicedInputStream, Available) { } // What if start is > then the size of the buffer? -TEST(TestSlicedInputStream, StartBiggerThan) { +TEST(TestSlicedInputStream, StartBiggerThan) +{ nsCString buf; RefPtr sis = CreateNonSeekableStreams(500, 4000, 1, buf); @@ -280,7 +287,8 @@ TEST(TestSlicedInputStream, StartBiggerThan) { } // What if the length is > than the size of the buffer? -TEST(TestSlicedInputStream, LengthBiggerThan) { +TEST(TestSlicedInputStream, LengthBiggerThan) +{ nsCString buf; RefPtr sis = CreateNonSeekableStreams(500, 0, 500000, buf); @@ -295,7 +303,8 @@ TEST(TestSlicedInputStream, LengthBiggerThan) { } // What if the length is 0? -TEST(TestSlicedInputStream, Length0) { +TEST(TestSlicedInputStream, Length0) +{ nsCString buf; RefPtr sis = CreateNonSeekableStreams(500, 0, 0, buf); @@ -310,7 +319,8 @@ TEST(TestSlicedInputStream, Length0) { } // Seek test NS_SEEK_SET -TEST(TestSlicedInputStream, Seek_SET) { +TEST(TestSlicedInputStream, Seek_SET) +{ nsCString buf; buf.AssignLiteral("Hello world"); @@ -335,7 +345,8 @@ TEST(TestSlicedInputStream, Seek_SET) { } // Seek test NS_SEEK_CUR -TEST(TestSlicedInputStream, Seek_CUR) { +TEST(TestSlicedInputStream, Seek_CUR) +{ nsCString buf; buf.AssignLiteral("Hello world"); @@ -367,7 +378,8 @@ TEST(TestSlicedInputStream, Seek_CUR) { } // Seek test NS_SEEK_END - length > real one -TEST(TestSlicedInputStream, Seek_END_Bigger) { +TEST(TestSlicedInputStream, Seek_END_Bigger) +{ nsCString buf; buf.AssignLiteral("Hello world"); @@ -405,7 +417,8 @@ TEST(TestSlicedInputStream, Seek_END_Bigger) { } // Seek test NS_SEEK_END - length < real one -TEST(TestSlicedInputStream, Seek_END_Lower) { +TEST(TestSlicedInputStream, Seek_END_Lower) +{ nsCString buf; buf.AssignLiteral("Hello world"); @@ -431,7 +444,8 @@ TEST(TestSlicedInputStream, Seek_END_Lower) { } // Check the nsIAsyncInputStream interface -TEST(TestSlicedInputStream, NoAsyncInputStream) { +TEST(TestSlicedInputStream, NoAsyncInputStream) +{ const size_t kBufSize = 4096; nsCString buf; @@ -443,7 +457,8 @@ TEST(TestSlicedInputStream, NoAsyncInputStream) { ASSERT_TRUE(!async); } -TEST(TestSlicedInputStream, AsyncInputStream) { +TEST(TestSlicedInputStream, AsyncInputStream) +{ nsCOMPtr reader; nsCOMPtr writer; @@ -490,7 +505,8 @@ TEST(TestSlicedInputStream, AsyncInputStream) { testing::ConsumeAndValidateStream(async, inputData); } -TEST(TestSlicedInputStream, QIInputStreamLength) { +TEST(TestSlicedInputStream, QIInputStreamLength) +{ nsCString buf; buf.AssignLiteral("Hello world"); @@ -515,7 +531,8 @@ TEST(TestSlicedInputStream, QIInputStreamLength) { } } -TEST(TestSlicedInputStream, InputStreamLength) { +TEST(TestSlicedInputStream, InputStreamLength) +{ nsCString buf; buf.AssignLiteral("Hello world"); @@ -536,7 +553,8 @@ TEST(TestSlicedInputStream, InputStreamLength) { ASSERT_EQ(5, size); } -TEST(TestSlicedInputStream, NegativeInputStreamLength) { +TEST(TestSlicedInputStream, NegativeInputStreamLength) +{ nsCString buf; buf.AssignLiteral("Hello world"); @@ -557,7 +575,8 @@ TEST(TestSlicedInputStream, NegativeInputStreamLength) { ASSERT_EQ(-1, size); } -TEST(TestSlicedInputStream, AsyncInputStreamLength) { +TEST(TestSlicedInputStream, AsyncInputStreamLength) +{ nsCString buf; buf.AssignLiteral("Hello world"); @@ -582,7 +601,8 @@ TEST(TestSlicedInputStream, AsyncInputStreamLength) { ASSERT_EQ(5, callback->Size()); } -TEST(TestSlicedInputStream, NegativeAsyncInputStreamLength) { +TEST(TestSlicedInputStream, NegativeAsyncInputStreamLength) +{ nsCString buf; buf.AssignLiteral("Hello world"); @@ -607,7 +627,8 @@ TEST(TestSlicedInputStream, NegativeAsyncInputStreamLength) { ASSERT_EQ(-1, callback->Size()); } -TEST(TestSlicedInputStream, AbortLengthCallback) { +TEST(TestSlicedInputStream, AbortLengthCallback) +{ nsCString buf; buf.AssignLiteral("Hello world"); diff --git a/xpcom/tests/gtest/TestSnappyStreams.cpp b/xpcom/tests/gtest/TestSnappyStreams.cpp index 3fe94ba3e7a09..f105de3f7638b 100644 --- a/xpcom/tests/gtest/TestSnappyStreams.cpp +++ b/xpcom/tests/gtest/TestSnappyStreams.cpp @@ -98,53 +98,56 @@ static void TestUncompressCorrupt(const char* aCorruptData, } // namespace -TEST(SnappyStream, Compress_32k) { TestCompress(32 * 1024); } +TEST(SnappyStream, Compress_32k) +{ TestCompress(32 * 1024); } -TEST(SnappyStream, Compress_64k) { TestCompress(64 * 1024); } +TEST(SnappyStream, Compress_64k) +{ TestCompress(64 * 1024); } -TEST(SnappyStream, Compress_128k) { TestCompress(128 * 1024); } +TEST(SnappyStream, Compress_128k) +{ TestCompress(128 * 1024); } -TEST(SnappyStream, CompressUncompress_0) { TestCompressUncompress(0); } +TEST(SnappyStream, CompressUncompress_0) +{ TestCompressUncompress(0); } -TEST(SnappyStream, CompressUncompress_1) { TestCompressUncompress(1); } +TEST(SnappyStream, CompressUncompress_1) +{ TestCompressUncompress(1); } -TEST(SnappyStream, CompressUncompress_32) { TestCompressUncompress(32); } +TEST(SnappyStream, CompressUncompress_32) +{ TestCompressUncompress(32); } -TEST(SnappyStream, CompressUncompress_1k) { TestCompressUncompress(1024); } +TEST(SnappyStream, CompressUncompress_1k) +{ TestCompressUncompress(1024); } -TEST(SnappyStream, CompressUncompress_32k) { - TestCompressUncompress(32 * 1024); -} +TEST(SnappyStream, CompressUncompress_32k) +{ TestCompressUncompress(32 * 1024); } -TEST(SnappyStream, CompressUncompress_64k) { - TestCompressUncompress(64 * 1024); -} +TEST(SnappyStream, CompressUncompress_64k) +{ TestCompressUncompress(64 * 1024); } -TEST(SnappyStream, CompressUncompress_128k) { - TestCompressUncompress(128 * 1024); -} +TEST(SnappyStream, CompressUncompress_128k) +{ TestCompressUncompress(128 * 1024); } // Test buffers that are not exactly power-of-2 in length to try to // exercise more edge cases. The number 13 is arbitrary. -TEST(SnappyStream, CompressUncompress_256k_less_13) { - TestCompressUncompress((256 * 1024) - 13); -} +TEST(SnappyStream, CompressUncompress_256k_less_13) +{ TestCompressUncompress((256 * 1024) - 13); } -TEST(SnappyStream, CompressUncompress_256k) { - TestCompressUncompress(256 * 1024); -} +TEST(SnappyStream, CompressUncompress_256k) +{ TestCompressUncompress(256 * 1024); } -TEST(SnappyStream, CompressUncompress_256k_plus_13) { - TestCompressUncompress((256 * 1024) + 13); -} +TEST(SnappyStream, CompressUncompress_256k_plus_13) +{ TestCompressUncompress((256 * 1024) + 13); } -TEST(SnappyStream, UncompressCorruptStreamIdentifier) { +TEST(SnappyStream, UncompressCorruptStreamIdentifier) +{ static const char data[] = "This is not a valid compressed stream"; TestUncompressCorrupt(data, strlen(data)); } -TEST(SnappyStream, UncompressCorruptCompressedDataLength) { +TEST(SnappyStream, UncompressCorruptCompressedDataLength) +{ static const char data[] = "\xff\x06\x00\x00sNaPpY" // stream identifier "\x00\x99\x00\x00This is not a valid compressed stream"; @@ -152,7 +155,8 @@ TEST(SnappyStream, UncompressCorruptCompressedDataLength) { TestUncompressCorrupt(data, dataLength); } -TEST(SnappyStream, UncompressCorruptCompressedDataContent) { +TEST(SnappyStream, UncompressCorruptCompressedDataContent) +{ static const char data[] = "\xff\x06\x00\x00sNaPpY" // stream identifier "\x00\x25\x00\x00This is not a valid compressed stream"; diff --git a/xpcom/tests/gtest/TestStateWatching.cpp b/xpcom/tests/gtest/TestStateWatching.cpp index a7b37b5c10632..804a907050a92 100644 --- a/xpcom/tests/gtest/TestStateWatching.cpp +++ b/xpcom/tests/gtest/TestStateWatching.cpp @@ -25,7 +25,8 @@ struct Foo { ~Foo() {} }; -TEST(WatchManager, Shutdown) { +TEST(WatchManager, Shutdown) +{ RefPtr queue = new TaskQueue(GetMediaThreadPool(MediaThreadType::PLAYBACK)); diff --git a/xpcom/tests/gtest/TestStorageStream.cpp b/xpcom/tests/gtest/TestStorageStream.cpp index 136bcd5d2d853..8cfc16dc1b50f 100644 --- a/xpcom/tests/gtest/TestStorageStream.cpp +++ b/xpcom/tests/gtest/TestStorageStream.cpp @@ -26,7 +26,8 @@ void WriteData(nsIOutputStream* aOut, nsTArray& aData, uint32_t aNumBytes, } // namespace -TEST(StorageStreams, Main) { +TEST(StorageStreams, Main) +{ // generate some test data we will write in 4k chunks to the stream nsTArray kData; testing::CreateData(4096, kData); @@ -90,7 +91,8 @@ TEST(StorageStreams, Main) { in = nullptr; } -TEST(StorageStreams, EarlyInputStream) { +TEST(StorageStreams, EarlyInputStream) +{ // generate some test data we will write in 4k chunks to the stream nsTArray kData; testing::CreateData(4096, kData); diff --git a/xpcom/tests/gtest/TestStringStream.cpp b/xpcom/tests/gtest/TestStringStream.cpp index bbae5218c9a9b..36e3fffd88ecb 100644 --- a/xpcom/tests/gtest/TestStringStream.cpp +++ b/xpcom/tests/gtest/TestStringStream.cpp @@ -52,6 +52,8 @@ static void TestStringStreamClone(uint32_t aNumBytes) { } // namespace -TEST(StringStream, Simple_4k) { TestStringStream(1024 * 4); } +TEST(StringStream, Simple_4k) +{ TestStringStream(1024 * 4); } -TEST(StringStream, Clone_4k) { TestStringStreamClone(1024 * 4); } +TEST(StringStream, Clone_4k) +{ TestStringStreamClone(1024 * 4); } diff --git a/xpcom/tests/gtest/TestStrings.cpp b/xpcom/tests/gtest/TestStrings.cpp index 497b6c71c6dee..dd7f4b80a2273 100644 --- a/xpcom/tests/gtest/TestStrings.cpp +++ b/xpcom/tests/gtest/TestStrings.cpp @@ -1304,7 +1304,8 @@ static void test_parse_string_helper2(const char* str, char separator, test_parse_string_helper(str, separator, 2, s1, s2); } -TEST(String, parse_string) { +TEST(String, parse_string) +{ test_parse_string_helper1("foo, bar", '_', "foo, bar"); test_parse_string_helper2("foo, bar", ',', "foo", " bar"); test_parse_string_helper2("foo, bar ", ' ', "foo,", "bar"); @@ -1322,7 +1323,8 @@ static void test_strip_chars_helper(const char16_t* str, const char16_t* strip, EXPECT_TRUE(data.Equals(result)); } -TEST(String, strip_chars) { +TEST(String, strip_chars) +{ test_strip_chars_helper(u"foo \r \nbar", u" \n\r", NS_LITERAL_STRING("foobar")); test_strip_chars_helper(u"\r\nfoo\r\n", u" \n\r", NS_LITERAL_STRING("foo")); diff --git a/xpcom/tests/gtest/TestSynchronization.cpp b/xpcom/tests/gtest/TestSynchronization.cpp index d1da58f8f4aab..e4865321a62dc 100644 --- a/xpcom/tests/gtest/TestSynchronization.cpp +++ b/xpcom/tests/gtest/TestSynchronization.cpp @@ -20,7 +20,8 @@ static PRThread* spawn(void (*run)(void*), void* arg) { //----------------------------------------------------------------------------- // Sanity check: tests that can be done on a single thread // -TEST(Synchronization, Sanity) { +TEST(Synchronization, Sanity) +{ Mutex lock("sanity::lock"); lock.Lock(); lock.AssertCurrentThreadOwns(); @@ -65,7 +66,8 @@ static void MutexContention_thread(void* /*arg*/) { } } -TEST(Synchronization, MutexContention) { +TEST(Synchronization, MutexContention) +{ gLock1 = new Mutex("lock1"); // PURPOSELY not checking for OOM. YAY! @@ -93,7 +95,8 @@ static void MonitorContention_thread(void* /*arg*/) { } } -TEST(Synchronization, MonitorContention) { +TEST(Synchronization, MonitorContention) +{ gMon1 = new Monitor("mon1"); PRThread* t1 = spawn(MonitorContention_thread, nullptr); @@ -123,7 +126,8 @@ static void MonitorContention2_thread(void* /*arg*/) { } } -TEST(Synchronization, MonitorContention2) { +TEST(Synchronization, MonitorContention2) +{ gMon2 = new ReentrantMonitor("mon1"); PRThread* t1 = spawn(MonitorContention2_thread, nullptr); @@ -157,7 +161,8 @@ static void MonitorSyncSanity_thread(void* /*arg*/) { gMon3->Exit(); } -TEST(Synchronization, MonitorSyncSanity) { +TEST(Synchronization, MonitorSyncSanity) +{ gMon3 = new ReentrantMonitor("monitor::syncsanity"); for (int32_t i = 0; i < 10000; ++i) { @@ -191,7 +196,8 @@ static void CondVarSanity_thread(void* /*arg*/) { gCvlock1->Unlock(); } -TEST(Synchronization, CondVarSanity) { +TEST(Synchronization, CondVarSanity) +{ gCvlock1 = new Mutex("cvlock1"); gCv1 = new CondVar(*gCvlock1, "cvlock1"); @@ -210,7 +216,8 @@ TEST(Synchronization, CondVarSanity) { //----------------------------------------------------------------------------- // AutoLock tests // -TEST(Synchronization, AutoLock) { +TEST(Synchronization, AutoLock) +{ Mutex l1("autolock"); MutexAutoLock autol1(l1); @@ -230,7 +237,8 @@ TEST(Synchronization, AutoLock) { //----------------------------------------------------------------------------- // AutoUnlock tests // -TEST(Synchronization, AutoUnlock) { +TEST(Synchronization, AutoUnlock) +{ Mutex l1("autounlock"); Mutex l2("autounlock2"); @@ -256,7 +264,8 @@ TEST(Synchronization, AutoUnlock) { //----------------------------------------------------------------------------- // AutoMonitor tests // -TEST(Synchronization, AutoMonitor) { +TEST(Synchronization, AutoMonitor) +{ ReentrantMonitor m1("automonitor"); ReentrantMonitor m2("automonitor2"); diff --git a/xpcom/tests/gtest/TestTArray.cpp b/xpcom/tests/gtest/TestTArray.cpp index edd7276436f57..4a52707adba2b 100644 --- a/xpcom/tests/gtest/TestTArray.cpp +++ b/xpcom/tests/gtest/TestTArray.cpp @@ -79,7 +79,8 @@ static const nsTArray& FakeHugeArray() { } #endif -TEST(TArray, AppendElementsRvalue) { +TEST(TArray, AppendElementsRvalue) +{ nsTArray array; nsTArray temp(DummyArray()); @@ -96,7 +97,8 @@ TEST(TArray, AppendElementsRvalue) { ASSERT_TRUE(temp.IsEmpty()); } -TEST(TArray, Assign) { +TEST(TArray, Assign) +{ nsTArray array; array.Assign(DummyArray()); ASSERT_EQ(DummyArray(), array); @@ -114,7 +116,8 @@ TEST(TArray, Assign) { ASSERT_EQ(DummyArray(), array2); } -TEST(TArray, AssignmentOperatorSelfAssignment) { +TEST(TArray, AssignmentOperatorSelfAssignment) +{ nsTArray array; array = DummyArray(); @@ -132,7 +135,8 @@ TEST(TArray, AssignmentOperatorSelfAssignment) { #endif } -TEST(TArray, CopyOverlappingForwards) { +TEST(TArray, CopyOverlappingForwards) +{ const size_t rangeLength = 8; const size_t initialLength = 2 * rangeLength; uint32_t destructionCounters[initialLength]; @@ -159,7 +163,8 @@ TEST(TArray, CopyOverlappingForwards) { // The code to copy overlapping regions had a bug in that it wouldn't correctly // destroy all over the source elements being copied. -TEST(TArray, CopyOverlappingBackwards) { +TEST(TArray, CopyOverlappingBackwards) +{ const size_t rangeLength = 8; const size_t initialLength = 2 * rangeLength; uint32_t destructionCounters[initialLength]; @@ -191,7 +196,8 @@ TEST(TArray, CopyOverlappingBackwards) { } } -TEST(TArray, UnorderedRemoveElements) { +TEST(TArray, UnorderedRemoveElements) +{ // When removing an element from the end of the array, it can be removed in // place, by destroying it and decrementing the length. // @@ -310,7 +316,8 @@ TEST(TArray, UnorderedRemoveElements) { } } -TEST(TArray, RemoveFromEnd) { +TEST(TArray, RemoveFromEnd) +{ { nsTArray array{1, 2, 3, 4}; ASSERT_EQ(array.PopLastElement(), 4); diff --git a/xpcom/tests/gtest/TestTArray2.cpp b/xpcom/tests/gtest/TestTArray2.cpp index 5f92ac8a88161..e123f4556753f 100644 --- a/xpcom/tests/gtest/TestTArray2.cpp +++ b/xpcom/tests/gtest/TestTArray2.cpp @@ -82,34 +82,42 @@ static bool test_basic_array(ElementType* data, size_t dataLen, if (ary.Length() != (oldLen - 1)) return false; if (!(ary == ary)) return false; - if (ary.ApplyIf(extra, []() { return true; }, []() { return false; })) + if (ary.ApplyIf( + extra, []() { return true; }, []() { return false; })) return false; - if (ary.ApplyIf(extra, [](size_t) { return true; }, []() { return false; })) + if (ary.ApplyIf( + extra, [](size_t) { return true; }, []() { return false; })) return false; // On a non-const array, ApplyIf's first lambda may use either const or non- // const element types. - if (ary.ApplyIf(extra, [](ElementType&) { return true; }, - []() { return false; })) + if (ary.ApplyIf( + extra, [](ElementType&) { return true; }, []() { return false; })) return false; - if (ary.ApplyIf(extra, [](const ElementType&) { return true; }, - []() { return false; })) + if (ary.ApplyIf( + extra, [](const ElementType&) { return true; }, + []() { return false; })) return false; - if (ary.ApplyIf(extra, [](size_t, ElementType&) { return true; }, - []() { return false; })) + if (ary.ApplyIf( + extra, [](size_t, ElementType&) { return true; }, + []() { return false; })) return false; - if (ary.ApplyIf(extra, [](size_t, const ElementType&) { return true; }, - []() { return false; })) + if (ary.ApplyIf( + extra, [](size_t, const ElementType&) { return true; }, + []() { return false; })) return false; - if (cary.ApplyIf(extra, []() { return true; }, []() { return false; })) - if (cary.ApplyIf(extra, [](size_t) { return true; }, - []() { return false; })) + if (cary.ApplyIf( + extra, []() { return true; }, []() { return false; })) + if (cary.ApplyIf( + extra, [](size_t) { return true; }, []() { return false; })) // On a const array, ApplyIf's first lambda must only use const element // types. - if (cary.ApplyIf(extra, [](const ElementType&) { return true; }, - []() { return false; })) - if (cary.ApplyIf(extra, [](size_t, const ElementType&) { return true; }, - []() { return false; })) + if (cary.ApplyIf( + extra, [](const ElementType&) { return true; }, + []() { return false; })) + if (cary.ApplyIf( + extra, [](size_t, const ElementType&) { return true; }, + []() { return false; })) return false; size_t index = ary.Length() / 2; @@ -121,17 +129,19 @@ static bool test_basic_array(ElementType* data, size_t dataLen, // ensure proper searching if (ary.IndexOf(extra) > ary.LastIndexOf(extra)) return false; if (ary.IndexOf(extra, index) != ary.LastIndexOf(extra, index)) return false; - if (!ary.ApplyIf(extra, - [&](size_t i, const ElementType& e) { - return i == index && e == extra; - }, - []() { return false; })) + if (!ary.ApplyIf( + extra, + [&](size_t i, const ElementType& e) { + return i == index && e == extra; + }, + []() { return false; })) return false; - if (!cary.ApplyIf(extra, - [&](size_t i, const ElementType& e) { - return i == index && e == extra; - }, - []() { return false; })) + if (!cary.ApplyIf( + extra, + [&](size_t i, const ElementType& e) { + return i == index && e == extra; + }, + []() { return false; })) return false; nsTArray copy(ary); @@ -148,9 +158,11 @@ static bool test_basic_array(ElementType* data, size_t dataLen, ary.Clear(); if (ary.IndexOf(extra) != ary.NoIndex) return false; if (ary.LastIndexOf(extra) != ary.NoIndex) return false; - if (ary.ApplyIf(extra, []() { return true; }, []() { return false; })) + if (ary.ApplyIf( + extra, []() { return true; }, []() { return false; })) return false; - if (cary.ApplyIf(extra, []() { return true; }, []() { return false; })) + if (cary.ApplyIf( + extra, []() { return true; }, []() { return false; })) return false; ary.Clear(); @@ -186,22 +198,26 @@ static bool test_basic_array(ElementType* data, size_t dataLen, return true; } -TEST(TArray, test_int_array) { +TEST(TArray, test_int_array) +{ int data[] = {4, 6, 8, 2, 4, 1, 5, 7, 3}; ASSERT_TRUE(test_basic_array(data, ArrayLength(data), int(14))); } -TEST(TArray, test_int64_array) { +TEST(TArray, test_int64_array) +{ int64_t data[] = {4, 6, 8, 2, 4, 1, 5, 7, 3}; ASSERT_TRUE(test_basic_array(data, ArrayLength(data), int64_t(14))); } -TEST(TArray, test_char_array) { +TEST(TArray, test_char_array) +{ char data[] = {4, 6, 8, 2, 4, 1, 5, 7, 3}; ASSERT_TRUE(test_basic_array(data, ArrayLength(data), char(14))); } -TEST(TArray, test_uint32_array) { +TEST(TArray, test_uint32_array) +{ uint32_t data[] = {4, 6, 8, 2, 4, 1, 5, 7, 3}; ASSERT_TRUE(test_basic_array(data, ArrayLength(data), uint32_t(14))); } @@ -238,7 +254,8 @@ class Object { uint32_t mNum; }; -TEST(TArray, test_object_array) { +TEST(TArray, test_object_array) +{ nsTArray objArray; const char kdata[] = "hello world"; size_t i; @@ -293,12 +310,14 @@ static nsTArray returns_by_value() { return result; } -TEST(TArray, test_return_by_value) { +TEST(TArray, test_return_by_value) +{ nsTArray result = returns_by_value(); ASSERT_TRUE(true); // This is just a compilation test. } -TEST(TArray, test_move_array) { +TEST(TArray, test_move_array) +{ nsTArray countableArray; uint32_t i; for (i = 0; i < 4; ++i) { @@ -414,7 +433,8 @@ TEST(TArray, test_move_array) { //---- -TEST(TArray, test_string_array) { +TEST(TArray, test_string_array) +{ nsTArray strArray; const char kdata[] = "hello world"; size_t i; @@ -471,7 +491,8 @@ class nsFileNameComparator { } }; -TEST(TArray, test_comptr_array) { +TEST(TArray, test_comptr_array) +{ FilePointer tmpDir; NS_GetSpecialDirectory(NS_OS_TEMP_DIR, getter_AddRefs(tmpDir)); ASSERT_TRUE(tmpDir); @@ -487,9 +508,9 @@ TEST(TArray, test_comptr_array) { } ASSERT_EQ(fileArray.IndexOf(kNames[1], 0, nsFileNameComparator()), size_t(1)); - ASSERT_TRUE(fileArray.ApplyIf(kNames[1], 0, nsFileNameComparator(), - [](size_t i) { return i == 1; }, - []() { return false; })); + ASSERT_TRUE(fileArray.ApplyIf( + kNames[1], 0, nsFileNameComparator(), [](size_t i) { return i == 1; }, + []() { return false; })); // It's unclear what 'operator<' means for nsCOMPtr, but whatever... ASSERT_TRUE( @@ -511,7 +532,8 @@ class RefcountedObject { int32_t rc; }; -TEST(TArray, test_refptr_array) { +TEST(TArray, test_refptr_array) +{ nsTArray > objArray; RefcountedObject* a = new RefcountedObject(); @@ -538,7 +560,8 @@ TEST(TArray, test_refptr_array) { //---- -TEST(TArray, test_ptrarray) { +TEST(TArray, test_ptrarray) +{ nsTArray ary; ASSERT_EQ(ary.SafeElementAt(0), nullptr); ASSERT_EQ(ary.SafeElementAt(1000), nullptr); @@ -566,7 +589,8 @@ TEST(TArray, test_ptrarray) { // This test relies too heavily on the existence of DebugGetHeader to be // useful in non-debug builds. #ifdef DEBUG -TEST(TArray, test_autoarray) { +TEST(TArray, test_autoarray) +{ uint32_t data[] = {4, 6, 8, 2, 4, 1, 5, 7, 3}; AutoTArray array; @@ -622,7 +646,8 @@ TEST(TArray, test_autoarray) { // IndexOf used to potentially scan beyond the end of the array. Test for // this incorrect behavior by adding a value (5), removing it, then seeing // if IndexOf finds it. -TEST(TArray, test_indexof) { +TEST(TArray, test_indexof) +{ nsTArray array; array.AppendElement(0); // add and remove the 5 @@ -631,8 +656,8 @@ TEST(TArray, test_indexof) { // we should not find the 5! auto no_index = array.NoIndex; // Fixes gtest compilation error. ASSERT_EQ(array.IndexOf(5, 1), no_index); - ASSERT_FALSE( - array.ApplyIf(5, 1, []() { return true; }, []() { return false; })); + ASSERT_FALSE(array.ApplyIf( + 5, 1, []() { return true; }, []() { return false; })); } //---- @@ -685,7 +710,8 @@ static bool is_heap(const Array& ary, size_t len) { } \ } while (0) -TEST(TArray, test_swap) { +TEST(TArray, test_swap) +{ // Test nsTArray::SwapElements. Unfortunately there are many cases. int data1[] = {8, 6, 7, 5}; int data2[] = {3, 0, 9}; @@ -911,7 +937,8 @@ TEST(TArray, test_swap) { // Bug 1171296: Disabled on andoid due to crashes. #if !defined(ANDROID) -TEST(TArray, test_fallible) { +TEST(TArray, test_fallible) +{ // Test that FallibleTArray works properly; that is, it never OOMs, but // instead eventually returns false. // @@ -953,12 +980,14 @@ TEST(TArray, test_fallible) { } } - ASSERT_TRUE(oomed) << "Didn't OOM or crash? nsTArray::SetCapacity" - "must be lying."; + ASSERT_TRUE(oomed) + << "Didn't OOM or crash? nsTArray::SetCapacity" + "must be lying."; } #endif -TEST(TArray, test_conversion_operator) { +TEST(TArray, test_conversion_operator) +{ FallibleTArray f; const FallibleTArray fconst; @@ -1002,7 +1031,8 @@ struct BufAccessor : public T { void* GetHdr() { return T::mHdr; } }; -TEST(TArray, test_SetLengthAndRetainStorage_no_ctor) { +TEST(TArray, test_SetLengthAndRetainStorage_no_ctor) +{ // 1050 because sizeof(int)*1050 is more than a page typically. const int N = 1050; FallibleTArray f; @@ -1104,7 +1134,8 @@ struct IntComparator { bool LessThan(int aLeft, int aRight) const { return aLeft < aRight; } }; -TEST(TArray, test_comparator_objects) { +TEST(TArray, test_comparator_objects) +{ ASSERT_TRUE(TestCompareMethods(IntComparator())); ASSERT_TRUE( TestCompareMethods([](int aLeft, int aRight) { return aLeft - aRight; })); @@ -1114,7 +1145,8 @@ struct Big { uint64_t size[40] = {}; }; -TEST(TArray, test_AutoTArray_SwapElements) { +TEST(TArray, test_AutoTArray_SwapElements) +{ AutoTArray oneArray; AutoTArray another; diff --git a/xpcom/tests/gtest/TestTaskQueue.cpp b/xpcom/tests/gtest/TestTaskQueue.cpp index 116e957724ddc..5e052e2c96abf 100644 --- a/xpcom/tests/gtest/TestTaskQueue.cpp +++ b/xpcom/tests/gtest/TestTaskQueue.cpp @@ -14,7 +14,8 @@ namespace TestTaskQueue { using namespace mozilla; -TEST(TaskQueue, EventOrder) { +TEST(TaskQueue, EventOrder) +{ RefPtr tq1 = new TaskQueue(GetMediaThreadPool(MediaThreadType::PLAYBACK), true); RefPtr tq2 = diff --git a/xpcom/tests/gtest/TestTextFormatter.cpp b/xpcom/tests/gtest/TestTextFormatter.cpp index fabcdc8d101f2..e532b3c65b5c1 100644 --- a/xpcom/tests/gtest/TestTextFormatter.cpp +++ b/xpcom/tests/gtest/TestTextFormatter.cpp @@ -7,7 +7,8 @@ #include "nsString.h" #include "gtest/gtest.h" -TEST(TextFormatter, Tests) { +TEST(TextFormatter, Tests) +{ nsAutoString fmt(NS_LITERAL_STRING("%3$s %4$S %1$d %2$d %2$d %3$s")); char utf8[] = "Hello"; char16_t ucs2[] = {'W', 'o', 'r', 'l', 'd', @@ -50,7 +51,8 @@ TEST(TextFormatter, Tests) { * Check misordered parameters */ -TEST(TextFormatterOrdering, orders) { +TEST(TextFormatterOrdering, orders) +{ nsString out; // plain list @@ -101,7 +103,8 @@ TEST(TextFormatterOrdering, orders) { * Tests to validate that horrible things don't happen if the passed-in * variable and the formatter don't match. */ -TEST(TextFormatterTestMismatch, format_d) { +TEST(TextFormatterTestMismatch, format_d) +{ nsString out; // just for completeness, this is our format, and works nsTextFormatter::ssprintf(out, u"%d", int(-1)); @@ -118,7 +121,8 @@ TEST(TextFormatterTestMismatch, format_d) { #endif } -TEST(TextFormatterTestMismatch, format_u) { +TEST(TextFormatterTestMismatch, format_u) +{ nsString out; nsTextFormatter::ssprintf(out, u"%u", int(-1)); EXPECT_STREQ("4294967295", NS_ConvertUTF16toUTF8(out).get()); @@ -135,7 +139,8 @@ TEST(TextFormatterTestMismatch, format_u) { #endif } -TEST(TextFormatterTestMismatch, format_x) { +TEST(TextFormatterTestMismatch, format_x) +{ nsString out; nsTextFormatter::ssprintf(out, u"%x", int32_t(-1)); EXPECT_STREQ("ffffffff", NS_ConvertUTF16toUTF8(out).get()); @@ -152,7 +157,8 @@ TEST(TextFormatterTestMismatch, format_x) { #endif } -TEST(TextFormatterTestMismatch, format_s) { +TEST(TextFormatterTestMismatch, format_s) +{ nsString out; #ifndef DEBUG nsTextFormatter::ssprintf(out, u"%s", int(-1)); @@ -171,7 +177,8 @@ TEST(TextFormatterTestMismatch, format_s) { #endif } -TEST(TextFormatterTestMismatch, format_S) { +TEST(TextFormatterTestMismatch, format_S) +{ nsString out; #ifndef DEBUG nsTextFormatter::ssprintf(out, u"%S", int32_t(-1)); @@ -188,7 +195,8 @@ TEST(TextFormatterTestMismatch, format_S) { EXPECT_STREQ("foo", NS_ConvertUTF16toUTF8(out).get()); } -TEST(TextFormatterTestMismatch, format_c) { +TEST(TextFormatterTestMismatch, format_c) +{ nsString out; nsTextFormatter::ssprintf(out, u"%c", int32_t(-1)); EXPECT_EQ(1u, out.Length()); @@ -214,7 +222,8 @@ TEST(TextFormatterTestMismatch, format_c) { EXPECT_EQ(u'c', out.CharAt(0)); } -TEST(TextFormatterTestResults, Tests) { +TEST(TextFormatterTestResults, Tests) +{ char16_t buf[10]; EXPECT_EQ( diff --git a/xpcom/tests/gtest/TestThreadManager.cpp b/xpcom/tests/gtest/TestThreadManager.cpp index 0baafdc06baf8..b76523867577b 100644 --- a/xpcom/tests/gtest/TestThreadManager.cpp +++ b/xpcom/tests/gtest/TestThreadManager.cpp @@ -71,7 +71,8 @@ class CountRunnable final : public Runnable { Atomic& mCounter; }; -TEST(ThreadManager, SpinEventLoopUntilSuccess) { +TEST(ThreadManager, SpinEventLoopUntilSuccess) +{ const uint32_t kRunnablesToDispatch = 100; nsresult rv; mozilla::Atomic count(0); @@ -117,7 +118,8 @@ class ErrorCondition final : public nsINestedEventLoopCondition { NS_IMPL_ISUPPORTS(ErrorCondition, nsINestedEventLoopCondition) -TEST(ThreadManager, SpinEventLoopUntilError) { +TEST(ThreadManager, SpinEventLoopUntilError) +{ const uint32_t kRunnablesToDispatch = 100; nsresult rv; mozilla::Atomic count(0); diff --git a/xpcom/tests/gtest/TestThreadPool.cpp b/xpcom/tests/gtest/TestThreadPool.cpp index ad51b986496c2..21f5bdd8f5027 100644 --- a/xpcom/tests/gtest/TestThreadPool.cpp +++ b/xpcom/tests/gtest/TestThreadPool.cpp @@ -47,7 +47,8 @@ NS_IMPL_ISUPPORTS(Task, nsIRunnable) mozilla::Atomic Task::sCount; -TEST(ThreadPool, Main) { +TEST(ThreadPool, Main) +{ nsCOMPtr pool = new nsThreadPool(); for (int i = 0; i < 100; ++i) { @@ -61,7 +62,8 @@ TEST(ThreadPool, Main) { EXPECT_EQ(Task::sCount, 100); } -TEST(ThreadPool, Parallelism) { +TEST(ThreadPool, Parallelism) +{ nsCOMPtr pool = new nsThreadPool(); // Dispatch and sleep to ensure we have an idle thread @@ -121,7 +123,8 @@ TEST(ThreadPool, Parallelism) { pool->Shutdown(); } -TEST(ThreadPool, ShutdownWithTimeout) { +TEST(ThreadPool, ShutdownWithTimeout) +{ Task::sCount = 0; nsCOMPtr pool = new nsThreadPool(); @@ -161,7 +164,8 @@ TEST(ThreadPool, ShutdownWithTimeout) { EXPECT_EQ(Task::sCount, 3); } -TEST(ThreadPool, ShutdownWithTimeoutThenSleep) { +TEST(ThreadPool, ShutdownWithTimeoutThenSleep) +{ Task::sCount = 0; nsCOMPtr pool = new nsThreadPool(); diff --git a/xpcom/tests/gtest/TestThreadPoolListener.cpp b/xpcom/tests/gtest/TestThreadPoolListener.cpp index cfa4bf13b527c..85fd5cfd82dec 100644 --- a/xpcom/tests/gtest/TestThreadPoolListener.cpp +++ b/xpcom/tests/gtest/TestThreadPoolListener.cpp @@ -120,7 +120,8 @@ class AutoCreateAndDestroyReentrantMonitor { ReentrantMonitor** mReentrantMonitorPtr; }; -TEST(ThreadPoolListener, Test) { +TEST(ThreadPoolListener, Test) +{ nsIThread* createdThreadList[NUMBER_OF_THREADS] = {nullptr}; gCreatedThreadList = createdThreadList; diff --git a/xpcom/tests/gtest/TestThreadUtils.cpp b/xpcom/tests/gtest/TestThreadUtils.cpp index e75924f1c179c..86718f260ec08 100644 --- a/xpcom/tests/gtest/TestThreadUtils.cpp +++ b/xpcom/tests/gtest/TestThreadUtils.cpp @@ -403,11 +403,11 @@ static void TestNewRunnableFunction(bool aNamed) { } } -TEST(ThreadUtils, NewRunnableFunction) { - TestNewRunnableFunction(/*aNamed*/ false); -} +TEST(ThreadUtils, NewRunnableFunction) +{ TestNewRunnableFunction(/*aNamed*/ false); } -TEST(ThreadUtils, NewNamedRunnableFunction) { +TEST(ThreadUtils, NewNamedRunnableFunction) +{ // The named overload shall behave identical to the non-named counterpart. TestNewRunnableFunction(/*aNamed*/ true); @@ -509,9 +509,11 @@ static void TestNewRunnableMethod(bool aNamed) { } } -TEST(ThreadUtils, RunnableMethod) { TestNewRunnableMethod(/* aNamed */ false); } +TEST(ThreadUtils, RunnableMethod) +{ TestNewRunnableMethod(/* aNamed */ false); } -TEST(ThreadUtils, NamedRunnableMethod) { +TEST(ThreadUtils, NamedRunnableMethod) +{ // The named overloads shall behave identical to the non-named counterparts. TestNewRunnableMethod(/* aNamed */ true); @@ -571,7 +573,7 @@ class IdleObject final { uint32_t index; for (index = 0; index < aNumExecuted; ++index) { ASSERT_TRUE(mRunnableExecuted[index]) - << aKey << ": Method" << index << " should've executed"; + << aKey << ": Method" << index << " should've executed"; } for (; index < ArrayLength(mRunnableExecuted); ++index) { @@ -654,7 +656,8 @@ class IdleObject final { ~IdleObject() {} }; -TEST(ThreadUtils, IdleRunnableMethod) { +TEST(ThreadUtils, IdleRunnableMethod) +{ { RefPtr idle = new IdleObject(); RefPtr idleNoSetDeadline = @@ -700,7 +703,8 @@ TEST(ThreadUtils, IdleRunnableMethod) { } } -TEST(ThreadUtils, IdleTaskRunner) { +TEST(ThreadUtils, IdleTaskRunner) +{ using namespace mozilla; // Repeating. @@ -780,7 +784,8 @@ TEST(ThreadUtils, IdleTaskRunner) { } \ } -TEST(ThreadUtils, TypeTraits) { +TEST(ThreadUtils, TypeTraits) +{ static_assert(!mozilla::IsRefcountedSmartPointer::value, "IsRefcountedSmartPointer should be false"); static_assert(mozilla::IsRefcountedSmartPointer>::value, @@ -1185,7 +1190,8 @@ class ThreadUtilsNonRefCounted {}; } // namespace TestThreadUtils -TEST(ThreadUtils, main) { +TEST(ThreadUtils, main) +{ using namespace TestThreadUtils; static_assert(!IsParameterStorageClass::value, diff --git a/xpcom/tests/gtest/TestThreads.cpp b/xpcom/tests/gtest/TestThreads.cpp index 69e4b3a80cc33..31a7ba7038521 100644 --- a/xpcom/tests/gtest/TestThreads.cpp +++ b/xpcom/tests/gtest/TestThreads.cpp @@ -41,7 +41,8 @@ class nsRunner final : public nsIRunnable { NS_IMPL_ISUPPORTS(nsRunner, nsIRunnable) -TEST(Threads, Main) { +TEST(Threads, Main) +{ nsresult rv; nsCOMPtr event = new nsRunner(0); @@ -95,7 +96,8 @@ int32_t nsStressRunner::gNum = 0; NS_IMPL_ISUPPORTS(nsStressRunner, nsIRunnable) -TEST(Threads, Stress) { +TEST(Threads, Stress) +{ const int loops = 1000; const int threads = 50; @@ -205,7 +207,8 @@ class SameThreadSentinel : public nsIRunnable { NS_IMPL_ISUPPORTS(SameThreadSentinel, nsIRunnable) -TEST(Threads, AsyncShutdown) { +TEST(Threads, AsyncShutdown) +{ gAsyncShutdownReadyMonitor = new mozilla::Monitor("gAsyncShutdownReady"); gBeginAsyncShutdownMonitor = new mozilla::Monitor("gBeginAsyncShutdown"); @@ -236,7 +239,8 @@ static void threadProc(void* arg) { EXPECT_EQ(PR_JOINABLE_THREAD, PR_GetThreadState(PR_GetCurrentThread())); } -TEST(Threads, StressNSPR) { +TEST(Threads, StressNSPR) +{ const int loops = 1000; const int threads = 50; diff --git a/xpcom/tests/gtest/TestThrottledEventQueue.cpp b/xpcom/tests/gtest/TestThrottledEventQueue.cpp index 91691d6e50fba..82e481d7c666f 100644 --- a/xpcom/tests/gtest/TestThrottledEventQueue.cpp +++ b/xpcom/tests/gtest/TestThrottledEventQueue.cpp @@ -103,7 +103,8 @@ static void Enqueue(nsIEventTarget* target, function&& aCallable) { using namespace TestThrottledEventQueue; -TEST(ThrottledEventQueue, RunnableQueue) { +TEST(ThrottledEventQueue, RunnableQueue) +{ string log; RefPtr queue = MakeRefPtr(); @@ -116,7 +117,8 @@ TEST(ThrottledEventQueue, RunnableQueue) { ASSERT_EQ(log, "abc"); } -TEST(ThrottledEventQueue, SimpleDispatch) { +TEST(ThrottledEventQueue, SimpleDispatch) +{ string log; auto base = MakeRefPtr(); @@ -130,7 +132,8 @@ TEST(ThrottledEventQueue, SimpleDispatch) { ASSERT_TRUE(throttled->IsEmpty()); } -TEST(ThrottledEventQueue, MixedDispatch) { +TEST(ThrottledEventQueue, MixedDispatch) +{ string log; auto base = MakeRefPtr(); @@ -174,7 +177,8 @@ TEST(ThrottledEventQueue, MixedDispatch) { ASSERT_TRUE(throttled->IsEmpty()); } -TEST(ThrottledEventQueue, EnqueueFromRun) { +TEST(ThrottledEventQueue, EnqueueFromRun) +{ string log; auto base = MakeRefPtr(); @@ -198,7 +202,8 @@ TEST(ThrottledEventQueue, EnqueueFromRun) { ASSERT_TRUE(throttled->IsEmpty()); } -TEST(ThrottledEventQueue, RunFromRun) { +TEST(ThrottledEventQueue, RunFromRun) +{ string log; auto base = MakeRefPtr(); @@ -223,7 +228,8 @@ TEST(ThrottledEventQueue, RunFromRun) { ASSERT_TRUE(throttled->IsEmpty()); } -TEST(ThrottledEventQueue, DropWhileRunning) { +TEST(ThrottledEventQueue, DropWhileRunning) +{ string log; auto base = MakeRefPtr(); @@ -239,7 +245,8 @@ TEST(ThrottledEventQueue, DropWhileRunning) { ASSERT_EQ(log, "a"); } -TEST(ThrottledEventQueue, AwaitIdle) { +TEST(ThrottledEventQueue, AwaitIdle) +{ Mutex mutex("TEQ AwaitIdle"); CondVar cond(mutex, "TEQ AwaitIdle"); @@ -294,7 +301,8 @@ TEST(ThrottledEventQueue, AwaitIdle) { ASSERT_TRUE(NS_SUCCEEDED(thread->Shutdown())); } -TEST(ThrottledEventQueue, AwaitIdleMixed) { +TEST(ThrottledEventQueue, AwaitIdleMixed) +{ // Create a separate thread that waits for the queue to become idle, and // then takes observable action. nsCOMPtr thread; @@ -384,7 +392,8 @@ TEST(ThrottledEventQueue, AwaitIdleMixed) { ASSERT_TRUE(NS_SUCCEEDED(thread->Shutdown())); } -TEST(ThrottledEventQueue, SimplePauseResume) { +TEST(ThrottledEventQueue, SimplePauseResume) +{ string log; auto base = MakeRefPtr(); @@ -418,7 +427,8 @@ TEST(ThrottledEventQueue, SimplePauseResume) { ASSERT_TRUE(throttled->IsEmpty()); } -TEST(ThrottledEventQueue, MixedPauseResume) { +TEST(ThrottledEventQueue, MixedPauseResume) +{ string log; auto base = MakeRefPtr(); @@ -457,7 +467,8 @@ TEST(ThrottledEventQueue, MixedPauseResume) { ASSERT_TRUE(throttled->IsEmpty()); } -TEST(ThrottledEventQueue, AwaitIdlePaused) { +TEST(ThrottledEventQueue, AwaitIdlePaused) +{ Mutex mutex("AwaitIdlePaused"); CondVar cond(mutex, "AwaitIdlePaused"); @@ -529,7 +540,8 @@ TEST(ThrottledEventQueue, AwaitIdlePaused) { ASSERT_TRUE(NS_SUCCEEDED(thread->Shutdown())); } -TEST(ThrottledEventQueue, ExecutorTransitions) { +TEST(ThrottledEventQueue, ExecutorTransitions) +{ string log; auto base = MakeRefPtr(); diff --git a/xpcom/tests/gtest/TestTimeStamp.cpp b/xpcom/tests/gtest/TestTimeStamp.cpp index c8eddd28fc11f..acd8ff575c5ad 100644 --- a/xpcom/tests/gtest/TestTimeStamp.cpp +++ b/xpcom/tests/gtest/TestTimeStamp.cpp @@ -14,7 +14,8 @@ using mozilla::TimeDuration; using mozilla::TimeStamp; -TEST(TimeStamp, Main) { +TEST(TimeStamp, Main) +{ TimeDuration td; EXPECT_TRUE(td.ToSeconds() == 0.0); EXPECT_TRUE(TimeDuration::FromSeconds(5).ToSeconds() == 5.0); diff --git a/xpcom/tests/gtest/TestTimers.cpp b/xpcom/tests/gtest/TestTimers.cpp index 355bc0b1d3048..528c9afc2d0e6 100644 --- a/xpcom/tests/gtest/TestTimers.cpp +++ b/xpcom/tests/gtest/TestTimers.cpp @@ -94,7 +94,8 @@ class TimerCallback final : public nsITimerCallback { NS_IMPL_ISUPPORTS(TimerCallback, nsITimerCallback) -TEST(Timers, TargetedTimers) { +TEST(Timers, TargetedTimers) +{ AutoCreateAndDestroyReentrantMonitor newMon; ASSERT_TRUE(newMon); @@ -121,7 +122,8 @@ TEST(Timers, TargetedTimers) { ASSERT_EQ(notifiedThread, testThread); } -TEST(Timers, TimerWithStoppedTarget) { +TEST(Timers, TimerWithStoppedTarget) +{ AutoTestThread testThread; ASSERT_TRUE(testThread); @@ -232,7 +234,8 @@ class FindExpirationTimeState final { } }; -TEST(Timers, FindExpirationTime) { +TEST(Timers, FindExpirationTime) +{ { FindExpirationTimeState state; // 0 low priority timers @@ -601,7 +604,8 @@ class FuzzTestThreadState final : public nsITimerCallback { NS_IMPL_ISUPPORTS(FuzzTestThreadState, nsITimerCallback) -TEST(Timers, FuzzTestTimers) { +TEST(Timers, FuzzTestTimers) +{ static const size_t kNumThreads(10); AutoTestThread threads[kNumThreads]; RefPtr threadStates[kNumThreads]; diff --git a/xpcom/tests/gtest/TestTokenizer.cpp b/xpcom/tests/gtest/TestTokenizer.cpp index 126557e015a28..e0092d08a3ede 100644 --- a/xpcom/tests/gtest/TestTokenizer.cpp +++ b/xpcom/tests/gtest/TestTokenizer.cpp @@ -21,7 +21,8 @@ static bool HttpHeaderCharacter(char const c) { (c >= '0' && c <= '9') || (c == '_') || (c == '-'); } -TEST(Tokenizer, HTTPResponse) { +TEST(Tokenizer, HTTPResponse) +{ Tokenizer::Token t; // Real life test, HTTP response @@ -94,7 +95,8 @@ TEST(Tokenizer, HTTPResponse) { EXPECT_TRUE(b == "This is the body"); } -TEST(Tokenizer, Main) { +TEST(Tokenizer, Main) +{ Tokenizer::Token t; // Synthetic code-specific test @@ -207,7 +209,8 @@ TEST(Tokenizer, Main) { EXPECT_FALSE(p.CheckEOF()); } -TEST(Tokenizer, Main16) { +TEST(Tokenizer, Main16) +{ Tokenizer16::Token t; // Synthetic code-specific test @@ -320,7 +323,8 @@ TEST(Tokenizer, Main16) { EXPECT_FALSE(p.CheckEOF()); } -TEST(Tokenizer, SingleWord) { +TEST(Tokenizer, SingleWord) +{ // Single word with numbers in it test Tokenizer p(NS_LITERAL_CSTRING("test123")); @@ -329,7 +333,8 @@ TEST(Tokenizer, SingleWord) { EXPECT_TRUE(p.CheckEOF()); } -TEST(Tokenizer, EndingAfterNumber) { +TEST(Tokenizer, EndingAfterNumber) +{ // An end handling after a number Tokenizer p(NS_LITERAL_CSTRING("123")); @@ -339,7 +344,8 @@ TEST(Tokenizer, EndingAfterNumber) { EXPECT_TRUE(p.CheckEOF()); } -TEST(Tokenizer, BadInteger) { +TEST(Tokenizer, BadInteger) +{ Tokenizer::Token t; // A bad integer test @@ -351,7 +357,8 @@ TEST(Tokenizer, BadInteger) { EXPECT_TRUE(p.CheckEOF()); } -TEST(Tokenizer, CheckExpectedTokenValue) { +TEST(Tokenizer, CheckExpectedTokenValue) +{ Tokenizer::Token t; // Check expected token value test @@ -375,7 +382,8 @@ TEST(Tokenizer, CheckExpectedTokenValue) { EXPECT_FALSE(p.Next(t)); } -TEST(Tokenizer, HasFailed) { +TEST(Tokenizer, HasFailed) +{ Tokenizer::Token t; // HasFailed test @@ -415,7 +423,8 @@ TEST(Tokenizer, HasFailed) { EXPECT_TRUE(p2.HasFailed()); } -TEST(Tokenizer, Construction) { +TEST(Tokenizer, Construction) +{ { nsCString a("test"); Tokenizer p1(a); @@ -465,7 +474,8 @@ TEST(Tokenizer, Construction) { } } -TEST(Tokenizer, Customization) { +TEST(Tokenizer, Customization) +{ Tokenizer p1(NS_LITERAL_CSTRING("test-custom*words and\tdefault-whites"), nullptr, "-*"); EXPECT_TRUE(p1.CheckWord("test-custom*words")); @@ -495,7 +505,8 @@ TEST(Tokenizer, Customization) { EXPECT_TRUE(p3.CheckWord("whites-and#word-chars")); } -TEST(Tokenizer, ShortcutChecks) { +TEST(Tokenizer, ShortcutChecks) +{ Tokenizer p("test1 test2,123"); nsAutoCString test1; @@ -517,7 +528,8 @@ TEST(Tokenizer, ShortcutChecks) { static bool ABChar(const char aChar) { return aChar == 'a' || aChar == 'b'; } -TEST(Tokenizer, ReadCharClassified) { +TEST(Tokenizer, ReadCharClassified) +{ Tokenizer p("abc"); char c; @@ -532,7 +544,8 @@ TEST(Tokenizer, ReadCharClassified) { EXPECT_TRUE(p.CheckEOF()); } -TEST(Tokenizer, ClaimSubstring) { +TEST(Tokenizer, ClaimSubstring) +{ Tokenizer p(" abc "); EXPECT_TRUE(p.CheckWhite()); @@ -546,7 +559,8 @@ TEST(Tokenizer, ClaimSubstring) { EXPECT_TRUE(p.CheckEOF()); } -TEST(Tokenizer, Fragment) { +TEST(Tokenizer, Fragment) +{ const char str[] = "ab;cd:10 "; Tokenizer p(str); nsDependentCSubstring f; @@ -607,7 +621,8 @@ TEST(Tokenizer, Fragment) { EXPECT_TRUE(t1.Fragment().BeginReading() == &str[9]); } -TEST(Tokenizer, SkipWhites) { +TEST(Tokenizer, SkipWhites) +{ Tokenizer p("Text1 \nText2 \nText3\n Text4\n "); EXPECT_TRUE(p.CheckWord("Text1")); @@ -627,7 +642,8 @@ TEST(Tokenizer, SkipWhites) { EXPECT_TRUE(p.CheckEOF()); } -TEST(Tokenizer, SkipCustomWhites) { +TEST(Tokenizer, SkipCustomWhites) +{ Tokenizer p("Text1 \n\r\t.Text2 \n\r\t.", " \n\r\t."); EXPECT_TRUE(p.CheckWord("Text1")); @@ -641,7 +657,8 @@ TEST(Tokenizer, SkipCustomWhites) { EXPECT_TRUE(p.CheckEOF()); } -TEST(Tokenizer, IntegerReading) { +TEST(Tokenizer, IntegerReading) +{ #define INT_6_BITS 64U #define INT_30_BITS 1073741824UL #define INT_32_BITS 4294967295UL @@ -755,7 +772,8 @@ TEST(Tokenizer, IntegerReading) { } } -TEST(Tokenizer, ReadUntil) { +TEST(Tokenizer, ReadUntil) +{ Tokenizer p("Hello;test 4,"); nsDependentCSubstring f; EXPECT_TRUE(p.ReadUntil(Tokenizer::Token::Char(';'), f)); @@ -783,7 +801,8 @@ TEST(Tokenizer, ReadUntil) { EXPECT_TRUE(f == " 4"); } -TEST(Tokenizer, SkipUntil) { +TEST(Tokenizer, SkipUntil) +{ { Tokenizer p("test1,test2,,,test3"); @@ -828,7 +847,8 @@ TEST(Tokenizer, SkipUntil) { } } -TEST(Tokenizer, Custom) { +TEST(Tokenizer, Custom) +{ Tokenizer p( "aaaaaacustom-1\r,custom-1,Custom-1,Custom-1,00custom-2xxxx,CUSTOM-2"); @@ -868,7 +888,8 @@ TEST(Tokenizer, Custom) { EXPECT_TRUE(p.CheckEOF()); } -TEST(Tokenizer, CustomRaw) { +TEST(Tokenizer, CustomRaw) +{ Tokenizer p( "aaaaaacustom-1\r,custom-1,Custom-1,Custom-1,00custom-2xxxx,CUSTOM-2"); @@ -919,7 +940,8 @@ TEST(Tokenizer, CustomRaw) { EXPECT_TRUE(p.CheckEOF()); } -TEST(Tokenizer, Incremental) { +TEST(Tokenizer, Incremental) +{ typedef IncrementalTokenizer::Token Token; int test = 0; @@ -967,7 +989,8 @@ TEST(Tokenizer, Incremental) { EXPECT_TRUE(test == 8); } -TEST(Tokenizer, IncrementalRollback) { +TEST(Tokenizer, IncrementalRollback) +{ typedef IncrementalTokenizer::Token Token; int test = 0; @@ -1019,7 +1042,8 @@ TEST(Tokenizer, IncrementalRollback) { EXPECT_TRUE(test == 9); } -TEST(Tokenizer, IncrementalNeedMoreInput) { +TEST(Tokenizer, IncrementalNeedMoreInput) +{ typedef IncrementalTokenizer::Token Token; int test = 0; @@ -1077,7 +1101,8 @@ TEST(Tokenizer, IncrementalNeedMoreInput) { EXPECT_TRUE(test == 7); } -TEST(Tokenizer, IncrementalCustom) { +TEST(Tokenizer, IncrementalCustom) +{ typedef IncrementalTokenizer::Token Token; int test = 0; @@ -1111,7 +1136,8 @@ TEST(Tokenizer, IncrementalCustom) { EXPECT_TRUE(test == 3); } -TEST(Tokenizer, IncrementalCustomRaw) { +TEST(Tokenizer, IncrementalCustomRaw) +{ typedef IncrementalTokenizer::Token Token; int test = 0; @@ -1166,7 +1192,8 @@ TEST(Tokenizer, IncrementalCustomRaw) { EXPECT_TRUE(test == 8); } -TEST(Tokenizer, IncrementalCustomRemove) { +TEST(Tokenizer, IncrementalCustomRemove) +{ typedef IncrementalTokenizer::Token Token; int test = 0; @@ -1198,7 +1225,8 @@ TEST(Tokenizer, IncrementalCustomRemove) { EXPECT_TRUE(test == 3); } -TEST(Tokenizer, IncrementalBuffering1) { +TEST(Tokenizer, IncrementalBuffering1) +{ typedef IncrementalTokenizer::Token Token; int test = 0; @@ -1257,7 +1285,8 @@ TEST(Tokenizer, IncrementalBuffering1) { EXPECT_TRUE(test == 6); } -TEST(Tokenizer, IncrementalBuffering2) { +TEST(Tokenizer, IncrementalBuffering2) +{ typedef IncrementalTokenizer::Token Token; int test = 0; @@ -1306,7 +1335,8 @@ TEST(Tokenizer, IncrementalBuffering2) { EXPECT_TRUE(test == 6); } -TEST(Tokenizer, RecordAndReadUntil) { +TEST(Tokenizer, RecordAndReadUntil) +{ Tokenizer t("aaaa,bbbb"); t.SkipWhites(); nsDependentCSubstring subject; @@ -1326,7 +1356,8 @@ TEST(Tokenizer, RecordAndReadUntil) { EXPECT_TRUE(t.CheckEOF()); } -TEST(Tokenizer, ReadIntegers) { +TEST(Tokenizer, ReadIntegers) +{ // Make sure that adding dash (the 'minus' sign) as an additional char // doesn't break reading negative numbers. Tokenizer t("100,-100,200,-200,4294967295,-4294967295,-2147483647", nullptr, diff --git a/xpcom/tests/gtest/TestUTF.cpp b/xpcom/tests/gtest/TestUTF.cpp index a2a50b4b352be..ec5f2b555e016 100644 --- a/xpcom/tests/gtest/TestUTF.cpp +++ b/xpcom/tests/gtest/TestUTF.cpp @@ -22,7 +22,8 @@ using namespace mozilla; namespace TestUTF { -TEST(UTF, Valid) { +TEST(UTF, Valid) +{ for (unsigned int i = 0; i < ArrayLength(ValidStrings); ++i) { nsDependentCString str8(ValidStrings[i].m8); nsDependentString str16(ValidStrings[i].m16); @@ -43,7 +44,8 @@ TEST(UTF, Valid) { } } -TEST(UTF, Invalid16) { +TEST(UTF, Invalid16) +{ for (unsigned int i = 0; i < ArrayLength(Invalid16Strings); ++i) { nsDependentString str16(Invalid16Strings[i].m16); nsDependentCString str8(Invalid16Strings[i].m8); @@ -58,7 +60,8 @@ TEST(UTF, Invalid16) { } } -TEST(UTF, Invalid8) { +TEST(UTF, Invalid8) +{ for (unsigned int i = 0; i < ArrayLength(Invalid8Strings); ++i) { nsDependentString str16(Invalid8Strings[i].m16); nsDependentCString str8(Invalid8Strings[i].m8); @@ -73,7 +76,8 @@ TEST(UTF, Invalid8) { } } -TEST(UTF, Malformed8) { +TEST(UTF, Malformed8) +{ for (unsigned int i = 0; i < ArrayLength(Malformed8Strings); ++i) { nsDependentString str16(Malformed8Strings[i].m16); nsDependentCString str8(Malformed8Strings[i].m8); @@ -88,7 +92,8 @@ TEST(UTF, Malformed8) { } } -TEST(UTF, Hash16) { +TEST(UTF, Hash16) +{ for (unsigned int i = 0; i < ArrayLength(ValidStrings); ++i) { nsDependentCString str8(ValidStrings[i].m8); bool err; @@ -167,7 +172,8 @@ static void NonASCII16_helper(const size_t aStrSize) { } } -TEST(UTF, NonASCII16) { +TEST(UTF, NonASCII16) +{ // Test with various string sizes to catch any special casing. NonASCII16_helper(1); NonASCII16_helper(8); @@ -176,7 +182,8 @@ TEST(UTF, NonASCII16) { NonASCII16_helper(512); } -TEST(UTF, UTF8CharEnumerator) { +TEST(UTF, UTF8CharEnumerator) +{ const char* p = "\x61\xC0\xC2\xC2\x80\xE0\x80\x80\xE0\xA0\x80\xE1\x80\x80\xED\xBF\xBF\xED" "\x9F\xBF\xEE\x80\x80\xEE\x80\xFF\xF0\x90\x80\x80\xF0\x80\x80\x80\xF1\x80" @@ -229,7 +236,8 @@ TEST(UTF, UTF8CharEnumerator) { EXPECT_EQ(p, end); } -TEST(UTF, UTF16CharEnumerator) { +TEST(UTF, UTF16CharEnumerator) +{ const char16_t* p = u"\u0061\U0001F4A9"; const char16_t* end = p + 3; EXPECT_EQ(UTF16CharEnumerator::NextChar(&p, end), 0x0061U); diff --git a/xpcom/tests/windows/TestCOM.cpp b/xpcom/tests/windows/TestCOM.cpp index a52edba9e1d25..bbc87d5c3d8ef 100644 --- a/xpcom/tests/windows/TestCOM.cpp +++ b/xpcom/tests/windows/TestCOM.cpp @@ -104,7 +104,8 @@ nsresult nsTestComFactory::CreateInstance(nsISupports *aOuter, return res; } -TEST(TestCOM, WindowsInterop) { +TEST(TestCOM, WindowsInterop) +{ nsTestComFactory *inst = new nsTestComFactory(); // Test we can QI nsIFactory to an IClassFactory. diff --git a/xpcom/tests/windows/TestNtPathToDosPath.cpp b/xpcom/tests/windows/TestNtPathToDosPath.cpp index 1885b9d84da6c..e8e0fea2010da 100644 --- a/xpcom/tests/windows/TestNtPathToDosPath.cpp +++ b/xpcom/tests/windows/TestNtPathToDosPath.cpp @@ -112,7 +112,8 @@ bool TestNtPathToDosPath(const wchar_t* aNtPath, aExpectedDosPath); } -TEST(NtPathToDosPath, Tests) { +TEST(NtPathToDosPath, Tests) +{ nsAutoString cDrive; ASSERT_TRUE(DriveToNtPath(L'C', cDrive)); diff --git a/xpcom/threads/MozPromise.h b/xpcom/threads/MozPromise.h index 5fda8e6badda7..0127abb95af28 100644 --- a/xpcom/threads/MozPromise.h +++ b/xpcom/threads/MozPromise.h @@ -336,13 +336,14 @@ class MozPromise : public MozPromiseBase { RefPtr holder = new AllPromiseHolder(aPromises.Length()); RefPtr promise = holder->Promise(); for (size_t i = 0; i < aPromises.Length(); ++i) { - aPromises[i]->Then(aProcessingTarget, __func__, - [holder, i](ResolveValueType aResolveValue) -> void { - holder->Resolve(i, std::move(aResolveValue)); - }, - [holder](RejectValueType aRejectValue) -> void { - holder->Reject(std::move(aRejectValue)); - }); + aPromises[i]->Then( + aProcessingTarget, __func__, + [holder, i](ResolveValueType aResolveValue) -> void { + holder->Resolve(i, std::move(aResolveValue)); + }, + [holder](RejectValueType aRejectValue) -> void { + holder->Reject(std::move(aRejectValue)); + }); } return promise; } diff --git a/xpcom/threads/nsThreadUtils.cpp b/xpcom/threads/nsThreadUtils.cpp index e0f7f9ebd3428..b837598bf7955 100644 --- a/xpcom/threads/nsThreadUtils.cpp +++ b/xpcom/threads/nsThreadUtils.cpp @@ -488,7 +488,8 @@ bool NS_ProcessNextEvent(nsIThread* aThread, bool aMayWait) { void NS_SetCurrentThreadName(const char* aName) { #if defined(ANDROID) - // Workaround for Bug 1541216 - PR_SetCurrentThreadName() Fails to set the thread name on Android. + // Workaround for Bug 1541216 - PR_SetCurrentThreadName() Fails to set the + // thread name on Android. prctl(PR_SET_NAME, reinterpret_cast(aName)); #else PR_SetCurrentThreadName(aName);