Extract a shared ScopedPrefSetter helper for gtests
Categories
(Core :: Audio/Video, task, P3)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox154 | --- | fixed |
People
(Reporter: chunmin, Assigned: chunmin)
References
Details
Attachments
(1 external file)
Several gtests need to flip a boolean preference for the duration of a single test and then restore the previous value on teardown, so the change does not leak into later tests in the same run. Today this is solved by per-file copies of the same small scope-guard class:
- dom/media/gtest/TestWebRTCCodecInfo.cpp defines ScopedPrefSetter(const char* aPrefName, bool aValue).
- dom/media/mediacontrol/tests/gtest/TestAudioFocusManager.cpp defines AudioFocusManagmentPrefSetterRAII(bool aValue), with the pref name hard-coded.
New audio-encoder gtests (bug 2050988) need the same behavior, which would add a third copy.
Extract a single shared helper mozilla::ScopedPrefSetter into testing/gtest/mozilla/ScopedPrefSetter.h (exported as mozilla/gtest/ScopedPrefSetter.h) and migrate the existing copies to it. The helper sets the pref in its constructor and restores the original value in its destructor, and must be used on the main thread. This is a test-only change with no behavior difference.)
| Assignee | ||
Comment 1•4 months ago
|
||
TestWebRTCCodecInfo and TestAudioFocusManager each carried their own RAII helper to set a boolean pref for the duration of a test and restore it afterwards. Move that into mozilla/gtest/ScopedPrefSetter.h so gtests share a single copy.
Comment 4•4 months ago
|
||
Backed out for causing failures at TestWebRTCCodecInfo.cpp.
Backout link: https://hg.mozilla.org/integration/autoland/rev/ccc480b17d3a
Failure log: https://treeherder.mozilla.org/logviewer?job_id=577160658&repo=autoland&task=DAcSEengT5ScSw1phx1y0A.0&lineNumber=254
| Assignee | ||
Updated•4 months ago
|
Comment 6•4 months ago
|
||
| bugherder | ||
Updated•3 months ago
|
Description
•