Repository navigation
[10510] Factory-reset: close cloud DB and unify flow - #10794
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI (base), Organization UI (inherited) Review profile: ASSERTIVE Plan: Pro Run ID: 📥 CommitsReviewing files that changed from the base of the PR and between d3e47950ac0dd0e4132e4ec62206399c74d0d671 and ac8342b. 📒 Files selected for processing (7)
📝 WalkthroughSummary by CodeRabbit
WalkthroughEnables workspace tests and appshell test toggling in CMake and exposes workspace config paths. Adds CloudProjectsDatabase existence check and explicit CloseConnection(), and guards cloud DB usage in housekeeper and housekeeper shutdown paths. Removes Sequence Diagram(s)sequenceDiagram
participant User
participant Controller as ApplicationActionController
participant Dialog as InteractiveDialogs
participant AppConfig as AppShellConfiguration
participant CloudDB as CloudProjectsDatabase
participant Project as ProjectFilesController
participant App as Application
participant MultiWin as MultiWindowsProvider
User->>Controller: trigger "revert-factory" action
Controller->>Dialog: warning() (async)
Dialog-->>User: show warning
User->>Dialog: respond
Dialog->>Controller: resolve(result)
alt Cancel
Controller-->>User: no action
else Confirm
Controller->>AppConfig: revertToFactorySettings(false,false,false)
AppConfig->>AppConfig: aboutToRevertToFactorySettings.notify()
AppConfig->>CloudDB: CloseConnection()
Controller->>Dialog: question() restart (async)
Dialog-->>User: show restart prompt
User->>Dialog: respond
Dialog->>Controller: resolve(result)
alt Cancel restart
Controller-->>User: revert done
else Confirm restart
Controller->>Project: closeOpenedProject(false)
Project-->>Controller: success/failure
alt close failed
Controller-->>User: no restart
else close succeeded
Controller->>MultiWin: windowCount()
MultiWin-->>Controller: count
alt single window
Controller->>App: restart()
else multiple windows
Controller->>App: quitAllAndRestartLast()
Controller->>App: exit()
end
end
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
c90dcf3 to
d3e4795
Compare
There was a problem hiding this comment.
Actionable comments posted: 6
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI (base), Organization UI (inherited)
Review profile: ASSERTIVE
Plan: Pro
Run ID: 55468ce9-7d5c-4553-b9c8-0bbb864c1c6f
📥 Commits
Reviewing files that changed from the base of the PR and between 472e90c and c90dcf397c465bff1bb7f06492db789cd5e71dbd.
📒 Files selected for processing (27)
CMakeLists.txtau3/libraries/au3-cloud-audiocom/sync/CloudProjectsDatabase.cppau3/libraries/au3-cloud-audiocom/sync/CloudProjectsDatabase.hau3/libraries/au3-cloud-audiocom/sync/CloudSyncHousekeeper.cppsrc/app/commandlineparser.cppsrc/app/guiapp.cppsrc/appshell/CMakeLists.txtsrc/appshell/iappshellconfiguration.hsrc/appshell/internal/applicationactioncontroller.cppsrc/appshell/internal/applicationactioncontroller.hsrc/appshell/internal/appshellconfiguration.cppsrc/appshell/internal/appshellconfiguration.hsrc/appshell/tests/CMakeLists.txtsrc/appshell/tests/factoryreset_actioncontroller_tests.cppsrc/appshell/tests/mocks/appshellconfigurationmock.hsrc/au3cloud/CMakeLists.txtsrc/au3cloud/au3cloudmodule.cppsrc/au3cloud/au3cloudmodule.hsrc/au3cloud/iau3audiocomservice.hsrc/au3cloud/internal/au3audiocomservice.cppsrc/au3cloud/internal/au3audiocomservice.hsrc/effects/effects_base/effectsmodule.cppsrc/effects/effects_base/effectsmodule.hsrc/importexport/export/CMakeLists.txtsrc/project/tests/mocks/projectfilescontrollermock.hsrc/stubs/au3cloud/au3audiocomservicestub.cppsrc/stubs/au3cloud/au3audiocomservicestub.h
💤 Files with no reviewable changes (4)
- src/au3cloud/CMakeLists.txt
- src/effects/effects_base/effectsmodule.cpp
- src/importexport/export/CMakeLists.txt
- src/effects/effects_base/effectsmodule.h
| bool CloudProjectsDatabase::DatabaseExists() | ||
| { | ||
| const auto configDir = FileNames::ConfigDir(); | ||
| const auto configPath = configDir + databaseFileName; | ||
| return wxFileExists(configPath); | ||
| } |
There was a problem hiding this comment.
DatabaseExists() introduces a TOCTOU gap for reset/cleanup flows.
A caller can observe true here, then lose the file before the subsequent DB access; later GetConnection() may recreate audiocom_sync.db, which defeats “skip when DB is absent” intent during cleanup/reset. Consider adding an atomic API that checks existence and opens (or declines) under mConnectionMutex in one step, then use that API at call sites.
🧰 Tools
🪛 Cppcheck (2.20.0)
[style] 120-120: The function 'DatabaseExists' is never used.
(unusedFunction)
| @@ -110,6 +111,7 @@ option(AU_BUILD_EFFECTS_BUILTIN_TESTS "Build builtin-effect tests" ON) | |||
| option(AU_BUILD_EFFECTS_MODULE "Build effects module" ON) | |||
| option(AU_BUILD_EFFECTS_TESTS "Build effects tests" ON) | |||
| option(AU_BUILD_PLAYBACK_MODULE "Build playback module" ON) | |||
| option(AU_BUILD_APPSHELL_TESTS "Build appshell tests" ON) | |||
There was a problem hiding this comment.
🧹 Nitpick | 🔵 Trivial
Keep module options alphabetized to match the local convention.
AU_BUILD_APPSHELL_TESTS is out of order relative to the surrounding AU_BUILD_* options, which makes maintenance noisier in this block.
| static constexpr bool KEEP_DEFAULT_SETTINGS = false; | ||
| static constexpr bool NOTIFY_ABOUT_CHANGES = false; | ||
| static constexpr bool NOTIFY_OTHER_INSTANCES = false; | ||
| configuration()->revertToFactorySettings(KEEP_DEFAULT_SETTINGS, NOTIFY_ABOUT_CHANGES, NOTIFY_OTHER_INSTANCES); |
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
MuseScore appshell applicationactioncontroller revertToFactorySettings NOTIFY_OTHER_INSTANCES
💡 Result:
The specific action/controller string you gave — “MuseScore appshell applicationactioncontroller revertToFactorySettings NOTIFY_OTHER_INSTANCES” — does not appear in the authoritative documentation or issues I could locate, and I could not find a source that confirms those exact identifiers. What I can confirm from MuseScore’s official documentation is the supported “revert to factory settings” feature and its invocation mechanisms: 1) In the app UI (MuseScore 4): Help → Revert to factory settings, then choose Revert and Restart. 2) From the command line: MuseScore 4 supports launching with a “-F” option to revert settings; the Handbook describes this as resetting all MuseScore preferences to “factory settings” and immediately launching the app. Sources also show related multi-instance behavior around resets/preferences not syncing fully, but not the specific “NOTIFY_OTHER_INSTANCES” flag. If you want, paste the relevant code snippet or file path where you see “applicationactioncontroller” and “revertToFactorySettings”; with that, I can map it precisely to the corresponding command-line/UI behavior and multi-instance notification behavior in the MuseScore codebase.
Citations:
- 1: https://handbook.musescore.org/support/revert-to-factory-settings
- 2: [MU4 Issue] Reverted to Factory Settings works only after manually rerunning MU4 musescore/MuseScore#8845
- 3: [MU4 Issue] Segmentation fault on applicationactioncontroller.cpp musescore/MuseScore#15560
- 4: https://musescore.org/en/node/91276
- 5: https://musescore.org/et/print/book/export/html/329749
- 6: https://musescore.org/en/handbook/2/revert-factory-settings
- 7: Reset Preferences does not reset preferences in other open MU instances musescore/MuseScore#26051
🏁 Script executed:
#!/bin/bash
# First, locate and read the applicationactioncontroller.cpp file
find . -name "applicationactioncontroller.cpp" -type fRepository: audacity/audacity
Length of output: 117
🏁 Script executed:
#!/bin/bash
# Search for revertToFactorySettings implementation to understand the parameter
rg -A 10 "void.*revertToFactorySettings" --type cppRepository: audacity/audacity
Length of output: 6499
🏁 Script executed:
#!/bin/bash
# Look at the full context around lines 346-362 to understand the control flow
sed -n '340,365p' src/appshell/internal/applicationactioncontroller.cppRepository: audacity/audacity
Length of output: 1472
🏁 Script executed:
#!/bin/bash
# Find and examine the restart() function
rg -A 15 "void.*restart\(\)" src/appshell/internal/applicationactioncontroller.cppRepository: audacity/audacity
Length of output: 495
🏁 Script executed:
#!/bin/bash
# Find the closeOpenedProject function and understand what returning false means
rg -B 2 -A 10 "closeOpenedProject" src/appshell/internal/applicationactioncontroller.cpp | head -50Repository: audacity/audacity
Length of output: 1325
🏁 Script executed:
#!/bin/bash
# Find the settings()->reset() implementation
rg -B 5 -A 20 "void.*settings.*reset" --type cpp | head -100Repository: audacity/audacity
Length of output: 2260
🏁 Script executed:
#!/bin/bash
# Search for all calls to revertToFactorySettings to see parameter patterns
rg "revertToFactorySettings" -B 2 -A 2 --type cppRepository: audacity/audacity
Length of output: 8022
🏁 Script executed:
#!/bin/bash
# Check the interface default and any documentation about notifyOtherInstances
cat -n src/appshell/iappshellconfiguration.h | grep -A 5 "revertToFactorySettings"Repository: audacity/audacity
Length of output: 438
🏁 Script executed:
#!/bin/bash
# Find where notifyOtherInstances is actually used in the settings/reset implementation
rg "notifyOtherInstances" --type cpp -B 3 -A 3Repository: audacity/audacity
Length of output: 2245
🏁 Script executed:
#!/bin/bash
# Look at the settings implementation to understand what happens with notifyOtherInstances
find . -path "*/src/framework/*" -name "*.cpp" -o -path "*/src/framework/*" -name "*.h" | xargs grep -l "settings.*reset" | head -5Repository: audacity/audacity
Length of output: 43
🏁 Script executed:
#!/bin/bash
# Check if there are any comments in the test file explaining the design choice
cat -n src/appshell/tests/factoryreset_actioncontroller_tests.cpp | head -100Repository: audacity/audacity
Length of output: 4659
🏁 Script executed:
#!/bin/bash
# Look at more of the test file to understand the design rationale
sed -n '100,250p' src/appshell/tests/factoryreset_actioncontroller_tests.cppRepository: audacity/audacity
Length of output: 4907
🏁 Script executed:
#!/bin/bash
# Search for any issue or comment explaining the design choice for notifyOtherInstances
rg "notifyOtherInstances\|notify.*other.*instance" -B 5 -A 5 --type cpp --type hRepository: audacity/audacity
Length of output: 43
🏁 Script executed:
#!/bin/bash
# Check all usages in context - maybe CLI and preferences have comments
sed -n '85,95p' src/app/guiapp.cpp
sed -n '230,250p' src/preferences/qml/Audacity/Preferences/preferencesmodel.cppRepository: audacity/audacity
Length of output: 1060
Document why NOTIFY_OTHER_INSTANCES = false is intentional.
The test suite explicitly validates that settings are reset (with notifyOtherInstances=false) before the restart prompt appears. This means if a user cancels the restart dialog, other running Audacity instances won't be notified despite having their settings wiped. The test "ConfirmWarning_CancelRestart_NoRestart" confirms this is the intended behavior, but the code lacks any comment explaining why this differs from the default (true) and from other call sites (CLI and preferences both use defaults, resulting in notifyOtherInstances=true). Add a comment clarifying the design rationale.
| void SetUp() override | ||
| { | ||
| m_controller = new ApplicationActionController(muse::modularity::globalCtx()); | ||
|
|
||
| m_dispatcher = std::make_shared<NiceMock<muse::actions::ActionsDispatcherMock> >(); | ||
| m_controller->dispatcher.set(m_dispatcher); | ||
|
|
||
| ON_CALL(*m_dispatcher, reg(_, _, testing::An<const ActionCB&>())) | ||
| .WillByDefault([this](muse::actions::Actionable*, const muse::actions::ActionCode& code, | ||
| const ActionCB& cb) { | ||
| m_registeredActions[code] = cb; | ||
| }); | ||
|
|
||
| m_interactive = std::make_shared<NiceMock<InteractiveMock> >(); | ||
| m_controller->interactive.set(m_interactive); | ||
|
|
||
| ON_CALL(*m_interactive, buttonData(IInteractive::Button::Cancel)) | ||
| .WillByDefault(Return(IInteractive::ButtonData(IInteractive::Button::Cancel, "Cancel"))); | ||
|
|
||
| m_application = std::make_shared<NiceMock<ApplicationMock> >(); | ||
| m_controller->application.set(m_application); | ||
|
|
||
| m_configuration = std::make_shared<NiceMock<AppShellConfigurationMock> >(); | ||
| m_controller->configuration.set(m_configuration); | ||
|
|
||
| m_projectFilesController = std::make_shared<NiceMock<au::project::ProjectFilesControllerMock> >(); | ||
| m_controller->projectFilesController.set(m_projectFilesController); | ||
|
|
||
| m_multiWindowsProvider = std::make_shared<NiceMock<muse::mi::MultiWindowsProviderMock> >(); | ||
| m_controller->multiwindowsProvider.set(m_multiWindowsProvider); | ||
|
|
||
| setupWarningDialog(); | ||
|
|
||
| m_controller->init(); | ||
| } | ||
|
|
||
| void TearDown() override | ||
| { | ||
| delete m_controller; | ||
| } |
There was a problem hiding this comment.
🧹 Nitpick | 🔵 Trivial
Nit: prefer std::unique_ptr over raw new/delete.
m_controller can leak if SetUp() throws between new ApplicationActionController(...) and finishing the rest of the setup. Replacing with std::unique_ptr<ApplicationActionController> removes the need for an explicit TearDown() delete and is exception-safe.
♻️ Proposed change
- m_controller = new ApplicationActionController(muse::modularity::globalCtx());
+ m_controller = std::make_unique<ApplicationActionController>(muse::modularity::globalCtx());
...
- void TearDown() override
- {
- delete m_controller;
- }
+ // TearDown no longer needed; unique_ptr handles cleanup.
...
- ApplicationActionController* m_controller = nullptr;
+ std::unique_ptr<ApplicationActionController> m_controller;There was a problem hiding this comment.
Actionable comments posted: 4
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI (base), Organization UI (inherited)
Review profile: ASSERTIVE
Plan: Pro
Run ID: d80add22-3fa4-4497-87d9-3747ff938bd4
📥 Commits
Reviewing files that changed from the base of the PR and between c90dcf397c465bff1bb7f06492db789cd5e71dbd and d3e47950ac0dd0e4132e4ec62206399c74d0d671.
📒 Files selected for processing (27)
CMakeLists.txtau3/libraries/au3-cloud-audiocom/sync/CloudProjectsDatabase.cppau3/libraries/au3-cloud-audiocom/sync/CloudProjectsDatabase.hau3/libraries/au3-cloud-audiocom/sync/CloudSyncHousekeeper.cppsrc/app/commandlineparser.cppsrc/app/guiapp.cppsrc/appshell/CMakeLists.txtsrc/appshell/iappshellconfiguration.hsrc/appshell/internal/applicationactioncontroller.cppsrc/appshell/internal/applicationactioncontroller.hsrc/appshell/internal/appshellconfiguration.cppsrc/appshell/internal/appshellconfiguration.hsrc/appshell/tests/CMakeLists.txtsrc/appshell/tests/factoryreset_actioncontroller_tests.cppsrc/appshell/tests/mocks/appshellconfigurationmock.hsrc/au3cloud/CMakeLists.txtsrc/au3cloud/au3cloudmodule.cppsrc/au3cloud/au3cloudmodule.hsrc/au3cloud/iau3audiocomservice.hsrc/au3cloud/internal/au3audiocomservice.cppsrc/au3cloud/internal/au3audiocomservice.hsrc/effects/effects_base/effectsmodule.cppsrc/effects/effects_base/effectsmodule.hsrc/importexport/export/CMakeLists.txtsrc/project/tests/mocks/projectfilescontrollermock.hsrc/stubs/au3cloud/au3audiocomservicestub.cppsrc/stubs/au3cloud/au3audiocomservicestub.h
💤 Files with no reviewable changes (4)
- src/effects/effects_base/effectsmodule.cpp
- src/au3cloud/CMakeLists.txt
- src/effects/effects_base/effectsmodule.h
- src/importexport/export/CMakeLists.txt
| @@ -98,6 +98,7 @@ set(MUSE_MODULE_UI_TESTS OFF) | |||
| set(MUSE_MODULE_UPDATE ON) | |||
| set(MUSE_MODULE_UPDATE_QML ON) | |||
| set(MUSE_MODULE_WORKSPACE ON) | |||
| set(MUSE_MODULE_WORKSPACE_TESTS ON) | |||
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
rg -nP '\b(APP_WORKSPACE_CONFIG_FILE|APP_BUILTIN_WORKSPACES_DIR|MUSE_MODULE_WORKSPACE_TESTS)\b' --type=cmake --type=cpp --type=hRepository: audacity/audacity
Length of output: 321
🏁 Script executed:
#!/bin/bash
# Search for all references to these variables (including definitions and usage)
echo "=== Searching for APP_WORKSPACE_CONFIG_FILE references ==="
rg -n 'APP_WORKSPACE_CONFIG_FILE' --type=cmake --type=cpp --type=h --type=txt || echo "No references found"
echo ""
echo "=== Searching for APP_BUILTIN_WORKSPACES_DIR references ==="
rg -n 'APP_BUILTIN_WORKSPACES_DIR' --type=cmake --type=cpp --type=h --type=txt || echo "No references found"
echo ""
echo "=== Searching for MUSE_MODULE_WORKSPACE_TESTS references ==="
rg -n 'MUSE_MODULE_WORKSPACE_TESTS' --type=cmake --type=cpp --type=h --type=txt || echo "No references found"Repository: audacity/audacity
Length of output: 503
🏁 Script executed:
#!/bin/bash
# Check for configure_file or indirect usages
echo "=== Searching for configure_file calls in CMakeLists.txt ==="
rg -n 'configure_file' CMakeLists.txt || echo "No configure_file calls"
echo ""
echo "=== Searching for add_compile_definitions with these variables ==="
rg -n 'add_compile_definitions.*APP_WORKSPACE|add_compile_definitions.*MUSE_MODULE_WORKSPACE' --type=cmake || echo "No matches"
echo ""
echo "=== Checking appshell CMakeLists structure ==="
fd -n 'CMakeLists.txt' | grep -i appshell | head -5Repository: audacity/audacity
Length of output: 522
🏁 Script executed:
#!/bin/bash
# Check appshell CMakeLists files
echo "=== Finding appshell CMakeLists files ==="
find . -path '*/appshell*' -name 'CMakeLists.txt' 2>/dev/null | head -10
echo ""
echo "=== Check root CMakeLists.txt context around these definitions (lines 90-165) ==="
sed -n '90,165p' CMakeLists.txt | head -80Repository: audacity/audacity
Length of output: 3281
🏁 Script executed:
#!/bin/bash
echo "=== Contents of appshell tests CMakeLists.txt ==="
cat -n src/appshell/tests/CMakeLists.txtRepository: audacity/audacity
Length of output: 955
🏁 Script executed:
#!/bin/bash
echo "=== Checking test source file for variable references ==="
rg -n '(APP_WORKSPACE_CONFIG_FILE|APP_BUILTIN_WORKSPACES_DIR|MUSE_MODULE_WORKSPACE_TESTS)' src/appshell/tests/ || echo "No references found"
echo ""
echo "=== Checking if variables appear in any source files outside CMakeLists ==="
rg -n '(APP_WORKSPACE_CONFIG_FILE|APP_BUILTIN_WORKSPACES_DIR)' --type=cpp --type=h || echo "No references found"Repository: audacity/audacity
Length of output: 236
Remove unused build variables or complete their integration with appshell tests.
MUSE_MODULE_WORKSPACE_TESTS (line 101), APP_WORKSPACE_CONFIG_FILE (line 154), and APP_BUILTIN_WORKSPACES_DIR (line 155) are defined in CMakeLists.txt but never referenced anywhere in the codebase. The appshell tests CMakeLists.txt does not consume these variables, and no source files reference them. Either integrate these variables into the test configuration or remove them to avoid dead code in the build system.
| promise.onResolve(this, [this](const muse::IInteractive::Result& res) { | ||
| if (res.isButton(muse::IInteractive::Button::Cancel)) { | ||
| return; | ||
| } | ||
|
|
||
| title = muse::trc("appshell", "Would you like to restart Audacity now?"); | ||
| question = muse::trc("appshell", "Audacity needs to be restarted for these changes to take effect."); | ||
| static constexpr bool KEEP_DEFAULT_SETTINGS = false; | ||
| static constexpr bool NOTIFY_ABOUT_CHANGES = false; | ||
| static constexpr bool NOTIFY_OTHER_INSTANCES = false; | ||
| configuration()->revertToFactorySettings(KEEP_DEFAULT_SETTINGS, NOTIFY_ABOUT_CHANGES, NOTIFY_OTHER_INSTANCES); | ||
|
|
||
| int restartBtn = int(muse::IInteractive::Button::Apply); | ||
| result = interactive()->questionSync(title, question, | ||
| { interactive()->buttonData(muse::IInteractive::Button::Cancel), | ||
| muse::IInteractive::ButtonData(restartBtn, muse::trc("appshell", "Restart"), true) }, | ||
| restartBtn); | ||
| std::string title = muse::trc("appshell", "Would you like to restart Audacity now?"); | ||
| std::string question = muse::trc("appshell", "Audacity needs to be restarted for these changes to take effect."); | ||
|
|
||
| if (result.standardButton() == muse::IInteractive::Button::Cancel) { | ||
| return; | ||
| } | ||
| int restartBtn = int(muse::IInteractive::Button::Apply); | ||
| auto promise = interactive()->question(title, question, | ||
| { interactive()->buttonData(muse::IInteractive::Button::Cancel), | ||
| muse::IInteractive::ButtonData(restartBtn, | ||
| muse::trc("appshell", "Restart"), true) }, | ||
| restartBtn); | ||
|
|
||
| restart(); | ||
| promise.onResolve(this, [this](const muse::IInteractive::Result& res) { | ||
| if (!res.isButton(muse::IInteractive::Button::Cancel)) { | ||
| restart(); | ||
| } | ||
| }); | ||
| }); |
There was a problem hiding this comment.
🧹 Nitpick | 🔵 Trivial
Prefer positive button checks (isButton(Apply)) over negative !isButton(Cancel).
Both nested onResolve handlers gate behavior on !res.isButton(Cancel). If IInteractive::Result ever resolves to any button code other than Cancel/Apply (e.g., a future addition, a dismissed dialog reported as "No button", or a close event that doesn't map to Cancel on some platforms), the logic will proceed to revert/restart. Given the destructive nature of these operations (wiping configuration, restarting the app), positive checks are safer:
♻️ Suggested change
- promise.onResolve(this, [this](const muse::IInteractive::Result& res) {
- if (res.isButton(muse::IInteractive::Button::Cancel)) {
- return;
- }
+ promise.onResolve(this, [this](const muse::IInteractive::Result& res) {
+ if (!res.isButton(muse::IInteractive::Button::Apply)) {
+ return;
+ }
...
- promise.onResolve(this, [this](const muse::IInteractive::Result& res) {
- if (!res.isButton(muse::IInteractive::Button::Cancel)) {
- restart();
- }
- });
+ promise.onResolve(this, [this](const muse::IInteractive::Result& res) {
+ if (res.isButton(muse::IInteractive::Button::Apply)) {
+ restart();
+ }
+ });Also the inner title, question, and promise locals at lines 351–355 shadow the outer ones of the same name — minor readability nit, renaming (e.g., restartTitle, restartPromise) would help.
| void setupWarningDialog() | ||
| { | ||
| EXPECT_CALL(*m_interactive, warning( | ||
| HasSubstr("revert to factory settings"), | ||
| _, _, | ||
| static_cast<int>(IInteractive::Button::Cancel), | ||
| _, _)) | ||
| .WillOnce([this](const std::string&, const IInteractive::Text&, | ||
| const IInteractive::ButtonDatas&, int, | ||
| const IInteractive::Options&, const std::string&) -> WarningPromise { | ||
| return WarningPromise([this](WarningPromise::Resolve resolve, | ||
| WarningPromise::Reject) -> WarningPromise::Result { | ||
| m_warningResolve = resolve; | ||
| return WarningPromise::Result::unchecked(); | ||
| }, muse::async::PromiseType::AsyncByBody); | ||
| }); | ||
| } | ||
|
|
||
| void setupRestartDialog() | ||
| { | ||
| EXPECT_CALL(*m_interactive, question( | ||
| HasSubstr("restart Audacity"), | ||
| _, _, _, _, _)) | ||
| .WillOnce([this](const std::string&, const IInteractive::Text&, | ||
| const IInteractive::ButtonDatas&, int, | ||
| const IInteractive::Options&, const std::string&) -> QuestionPromise { | ||
| return QuestionPromise([this](QuestionPromise::Resolve resolve, | ||
| QuestionPromise::Reject) -> QuestionPromise::Result { | ||
| m_questionResolve = resolve; | ||
| return QuestionPromise::Result::unchecked(); | ||
| }, muse::async::PromiseType::AsyncByBody); | ||
| }); | ||
| } |
There was a problem hiding this comment.
🧹 Nitpick | 🔵 Trivial
Matching on translated substrings couples tests to translation state.
HasSubstr("revert to factory settings") and HasSubstr("restart Audacity") rely on muse::trc("appshell", ...) returning English when invoked inside the test harness. If the test runner ever initializes a locale (or the translator layer returns an empty string for an unregistered domain), these WillOnce expectations will silently fail to match and the resulting default-constructed std::function resolvers will crash confirmWarningDialog()/cancelRestartDialog(). Consider either:
- matching on the action code/trigger rather than the dialog title, or
- making the matcher
_for title and asserting title via a side-channel capture.
Defensive option: assert the resolvers are valid before invoking them, so a missed expectation produces a clear test failure rather than a null std::function call.
void confirmWarningDialog()
{
+ ASSERT_TRUE(static_cast<bool>(m_warningResolve)) << "warning() was not invoked";
int btn = static_cast<int>(IInteractive::Button::Apply);
IInteractive::Result result(btn);
(void)m_warningResolve(result);
}d3e4795 to
ac8342b
Compare
Resolves:
Revert to factory setting crash #10510
copy update #9677
this PR replaces #10518
Recommended:
QA: