Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
eee994f
test: add missing coverage for GUI components
Arbaaz123676 Jun 1, 2026
f91be20
test: improve GUI component coverage
Arbaaz123676 Jun 2, 2026
5776d80
test: improve component coverage
Arbaaz123676 Jun 3, 2026
fd9103c
Tests
Arbaaz123676 Jun 3, 2026
106f57f
Merge branch 'main' into add-component-test-coverage-v2
sudip-mondal-2002 Jun 3, 2026
2119bc4
tests
Arbaaz123676 Jun 4, 2026
cc8e0cf
test: add missing coverage for GUI components
Arbaaz123676 Jun 1, 2026
0191967
test: improve GUI component coverage
Arbaaz123676 Jun 2, 2026
0214762
test: improve component coverage
Arbaaz123676 Jun 3, 2026
7ea30c2
Tests
Arbaaz123676 Jun 3, 2026
58dc009
tests
Arbaaz123676 Jun 4, 2026
cdc9f23
Merge origin/main into add-component-test-coverage-v2
sudip-mondal-2002 Jun 5, 2026
446aca8
Fix build and test failures, resolve compilation issues under new ImG…
sudip-mondal-2002 Jun 5, 2026
7f9966a
style: apply pre-commit hooks and formatting checks
sudip-mondal-2002 Jun 5, 2026
945a4c6
Merge branch 'temp-rebase' into add-component-test-coverage-v2
Arbaaz123676 Jun 6, 2026
22020d5
test: improve GUI component coverage
Arbaaz123676 Jun 6, 2026
73ca711
test: resolve merge conflicts and fix ImGui deactivation mock
Arbaaz123676 Jun 6, 2026
7ae4226
test: resolve merge conflicts in command history tests and fix format…
Arbaaz123676 Jun 6, 2026
3e0078e
Merge remote changes into add-component-test-coverage-v2 and resolve …
Arbaaz123676 Jun 6, 2026
209e81a
fix: resolve Windows file dialog build issue
Arbaaz123676 Jun 6, 2026
5958712
fix: clang formatting
Arbaaz123676 Jun 6, 2026
f680f16
Merge branch 'main' into add-component-test-coverage-v2
sudip-mondal-2002 Jun 10, 2026
f1e756a
test: add unit tests for headless file dialog mocks and stubs
sudip-mondal-2002 Jun 10, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,7 @@ else() # NOT EMSCRIPTEN, ANDROID, or IOS
tests/unit/test_looper.cpp
tests/unit/test_theme.cpp
tests/unit/test_command_history.cpp
tests/unit/test_effect_base.cpp
tests/unit/test_cabinet_sim_ir.cpp
tests/unit/test_wav_loader.cpp
tests/unit/test_convolution_engine.cpp
Expand Down
71 changes: 71 additions & 0 deletions tests/integration/test_snapshot_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -866,3 +866,74 @@ TEST(snapshot_multiple_effects_all_params_preserved) {

engine.shutdown();
}

TEST(SnapshotSlotLabelsCorrect) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Rename new test cases to snake_case to match repository C++ naming rules.

The newly added test case identifiers use PascalCase; in this codebase, function/method names are expected to be lowercase snake_case.

Proposed rename diff
-TEST(SnapshotSlotLabelsCorrect) {
+TEST(snapshot_slot_labels_correct) {
@@
-TEST(SnapshotSlotActiveSlotArbitrary) {
+TEST(snapshot_slot_active_slot_arbitrary) {
@@
-TEST(SnapshotApplyMismatchedParamCount) {
+TEST(snapshot_apply_mismatched_param_count) {
@@
-TEST(SnapshotCaptureEmptyEngine) {
+TEST(snapshot_capture_empty_engine) {

As per coding guidelines, "Functions and Methods should use lowercase snake_case (e.g., push_param_change(), remove_mapping())".

Also applies to: 878-878, 887-887, 930-930

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/integration/test_snapshot_manager.cpp` at line 870, Rename the new TEST
identifiers from PascalCase to lowercase snake_case (e.g., change
TEST(SnapshotSlotLabelsCorrect) to TEST(snapshot_slot_labels_correct)) and
update any references or registrations accordingly; apply the same renaming
pattern to the other newly added tests flagged in this review so all TEST(...)
identifiers follow the repository rule of lowercase snake_case (ensure function
names inside the test or any CALLS that reference the test name are updated to
match).

ASSERT_EQ(SnapshotManager::NUM_SLOTS, 4);
ASSERT_EQ(std::string(SnapshotManager::SLOT_LABELS[0]), "A");
ASSERT_EQ(std::string(SnapshotManager::SLOT_LABELS[1]), "B");
ASSERT_EQ(std::string(SnapshotManager::SLOT_LABELS[2]), "C");
ASSERT_EQ(std::string(SnapshotManager::SLOT_LABELS[3]), "D");
}

TEST(SnapshotSlotActiveSlotArbitrary) {
SnapshotManager mgr;
ASSERT_EQ(mgr.active_slot(), -1);
mgr.set_active_slot(2);
ASSERT_EQ(mgr.active_slot(), 2);
mgr.set_active_slot(999);
ASSERT_EQ(mgr.active_slot(), 999);
}

TEST(SnapshotApplyMismatchedParamCount) {
AudioEngine engine;
engine.initialize();

auto od = std::make_shared<Overdrive>();
engine.add_effect(od);

size_t param_count = od->params().size();
ASSERT_TRUE(param_count > 0);

float default_val = od->params()[0].value;

// Case 1: Snapshot has fewer params (empty param_values)
{
SnapshotManager::BoardSnapshot snap;
LoadPresetCommand::EffectSnapshot es;
es.effect = od;
es.enabled = true;
es.mix = 1.0f;
snap.effects.push_back(es);

od->params()[0].value = default_val + 5.0f;
SnapshotManager::apply(snap, engine);
ASSERT_NEAR(od->params()[0].value, default_val + 5.0f, 0.001f);
}

// Case 2: Snapshot has more params than the effect actually has
{
SnapshotManager::BoardSnapshot snap;
LoadPresetCommand::EffectSnapshot es;
es.effect = od;
es.enabled = true;
es.mix = 1.0f;
es.param_values.assign(param_count + 5, default_val + 2.0f);
snap.effects.push_back(es);

SnapshotManager::apply(snap, engine);
ASSERT_NEAR(od->params()[0].value, default_val + 2.0f, 0.001f);
}

engine.shutdown();
}

TEST(SnapshotCaptureEmptyEngine) {
AudioEngine engine;
engine.initialize();
clear_engine(engine);

SnapshotManager::BoardSnapshot snap = SnapshotManager::capture(engine);
ASSERT_TRUE(snap.effects.empty());

engine.shutdown();
}
154 changes: 154 additions & 0 deletions tests/unit/test_command_history.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -526,3 +526,157 @@ TEST(CommandHistory_EdgeCases_And_Out_Of_Bounds) {
clear_engine(engine);
}

TEST(ClearAllCommand_ExecutedUndo) {
auto& engine = test_engine();
clear_engine(engine);
engine.add_effect(std::make_shared<Overdrive>());
engine.add_effect(std::make_shared<Delay>());
ASSERT_EQ(static_cast<int>(engine.effects().size()), 2);

CommandHistory history;
auto cmd = std::make_unique<ClearAllCommand>(engine);

// Execute
history.execute(std::move(cmd));
ASSERT_EQ(static_cast<int>(engine.effects().size()), 0);

// Undo
history.undo();
ASSERT_EQ(static_cast<int>(engine.effects().size()), 2);
ASSERT_EQ(std::string(engine.effects()[0]->name()), "Overdrive");
ASSERT_EQ(std::string(engine.effects()[1]->name()), "Delay");

clear_engine(engine);
}

TEST(ResetAllCommand_Redo) {
auto& engine = test_engine();
clear_engine(engine);
auto od = std::make_shared<Overdrive>();
float custom_val = od->params()[0].min_val + 2.3f;
od->params()[0].value = custom_val;
Comment thread
Arbaaz123676 marked this conversation as resolved.
engine.add_effect(od);

CommandHistory history;
auto cmd = std::make_unique<ResetAllCommand>(engine);

// Execute (resets to default)
history.execute(std::move(cmd));
ASSERT_NEAR(od->params()[0].value, od->params()[0].default_val, 0.001f);

// Undo
history.undo();
ASSERT_NEAR(od->params()[0].value, custom_val, 0.001f);

// Redo
history.redo();
ASSERT_NEAR(od->params()[0].value, od->params()[0].default_val, 0.001f);

clear_engine(engine);
}

TEST(ResetAllCommand_ExecutedUndo) {
auto& engine = test_engine();
clear_engine(engine);
auto od = std::make_shared<Overdrive>();
float custom_val = od->params()[0].min_val + 4.5f;
od->params()[0].value = custom_val;
engine.add_effect(od);

CommandHistory history;
auto cmd = std::make_unique<ResetAllCommand>(engine);

// Execute
history.execute(std::move(cmd));
ASSERT_NEAR(od->params()[0].value, od->params()[0].default_val, 0.001f);

// Undo
history.undo();
ASSERT_NEAR(od->params()[0].value, custom_val, 0.001f);

clear_engine(engine);
}

TEST(CommandHistory_NegativeDepthClampsToZero) {
CommandHistory history(-10);
ASSERT_EQ(history.max_depth(), 0);

history.set_max_depth(-5);
ASSERT_EQ(history.max_depth(), 0);
}

TEST(CommandHistory_SizeMaxDepthTrimsExisting) {
auto& engine = test_engine();
clear_engine(engine);

CommandHistory history(10);
for (int i = 0; i < 10; ++i) {
history.execute(std::make_unique<AddEffectCommand>(engine, std::make_shared<Overdrive>()));
}
ASSERT_EQ(history.undo_size(), 10);

// Trim existing elements
history.set_max_depth(3);
ASSERT_EQ(history.max_depth(), 3);
ASSERT_EQ(history.undo_size(), 3);

clear_engine(engine);
}

TEST(CommandHistory_PushExecutedCoalescing) {
auto& engine = test_engine();
clear_engine(engine);

auto fx = std::make_shared<Overdrive>();
auto& params = fx->params();
float original = params[0].value;

CommandHistory history;
// Push executed commands that should coalesce
history.push_executed(std::make_unique<ParameterChangeCommand>(engine, fx, 0, original, original + 0.1f));
history.push_executed(std::make_unique<ParameterChangeCommand>(engine, fx, 0, original + 0.1f, original + 0.2f));

ASSERT_EQ(history.undo_size(), 1);

clear_engine(engine);
}

TEST(CommandHistory_PushExecutedClearsRedo) {
auto& engine = test_engine();
clear_engine(engine);

CommandHistory history;
history.execute(std::make_unique<AddEffectCommand>(engine, std::make_shared<Overdrive>()));
history.undo();
ASSERT_TRUE(history.can_redo());

// Push executed should clear redo stack
history.push_executed(std::make_unique<AddEffectCommand>(engine, std::make_shared<Delay>()));
ASSERT_FALSE(history.can_redo());
ASSERT_EQ(history.redo_size(), 0);

clear_engine(engine);
}

TEST(ParameterChangeCommand_OutOfRangeParam) {
auto& engine = test_engine();
clear_engine(engine);

auto fx = std::make_shared<Overdrive>();
CommandHistory history;

// Out of bounds parameter index (both negative and large positive)
auto cmd1 = std::make_unique<ParameterChangeCommand>(engine, fx, -5, 0.0f, 1.0f);
auto cmd2 = std::make_unique<ParameterChangeCommand>(engine, fx, 9999, 0.0f, 1.0f);

ASSERT_EQ(cmd1->param_index(), -5);
ASSERT_EQ(cmd2->param_index(), 9999);

// Execute/undo should be safe no-ops
cmd1->execute();
cmd1->undo();
cmd2->execute();
cmd2->undo();

clear_engine(engine);
}
Loading
Loading