Closed Bug 2052386 Opened 4 months ago Closed 4 months ago

Extract a shared ScopedPrefSetter helper for gtests

Categories

(Core :: Audio/Video, task, P3)

task

Tracking

()

RESOLVED FIXED
154 Branch
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:

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.)

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.

Pushed by cchang@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/0bacde30e56c https://hg.mozilla.org/integration/autoland/rev/c6cc831b3ca1 Extract ScopedPrefSetter into a shared gtest header r=media-playback-reviewers,padenot
Pushed by abutkovits@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/b7453cb8dfe3 https://hg.mozilla.org/integration/autoland/rev/ccc480b17d3a Revert "Bug 2052386 - Extract ScopedPrefSetter into a shared gtest header r=media-playback-reviewers,padenot" for causing failures at TestWebRTCCodecInfo.cpp.
Pushed by cchang@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/63d13600a992 https://hg.mozilla.org/integration/autoland/rev/d7754eafdde5 Extract ScopedPrefSetter into a shared gtest header r=media-playback-reviewers,padenot
Flags: needinfo?(cchang)
Status: NEW → RESOLVED
Closed: 4 months ago
Resolution: --- → FIXED
Target Milestone: --- → 154 Branch
QA Whiteboard: [qa-triage-done-c155/b154]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: