|
21 | 21 | #include "../../application/service/automation_service.hpp" |
22 | 22 | #include "../../application/service/editor_service.hpp" |
23 | 23 | #include "../../application/service/mixer_service.hpp" |
| 24 | +#include "../../infra/settings.hpp" |
24 | 25 | #include "../../application/service/selection_service.hpp" |
25 | 26 | #include "../../application/service/side_chain_service.hpp" |
26 | 27 | #include "../../domain/column_settings.hpp" |
@@ -2122,6 +2123,48 @@ void EditorServiceTest::test_velocityAtPosition_shouldReturnCorrectVelocity() |
2122 | 2123 | QCOMPARE(editorService.velocityAtPosition(0, 1, 0, 0), 0); |
2123 | 2124 | } |
2124 | 2125 |
|
| 2126 | +void EditorServiceTest::test_requestPositionByTick_shouldRespectUiUpdatesDisabledSetting() |
| 2127 | +{ |
| 2128 | + EditorService editorService; |
| 2129 | + QSignalSpy positionChangedSpy { &editorService, &EditorService::positionChanged }; |
| 2130 | + QSignalSpy currentTimeChangedSpy { &editorService, &EditorService::currentTimeChanged }; |
| 2131 | + QSignalSpy songPositionChangedSpy { &editorService, &EditorService::songPositionChanged }; |
| 2132 | + |
| 2133 | + // Enable disabling UI updates |
| 2134 | + Settings::setUiUpdatesDisabledDuringPlayback(true); |
| 2135 | + |
| 2136 | + // Initial position |
| 2137 | + QCOMPARE(editorService.songPosition(), 0); |
| 2138 | + |
| 2139 | + // Populate song position map manually as we don't have a PlayerService rendering |
| 2140 | + editorService.song()->updateTickToSongPositionMapping(0, 0, 0, editorService.lineCount(0)); |
| 2141 | + |
| 2142 | + // Tick update that triggers a line change |
| 2143 | + const auto tick = editorService.ticksPerLine(); // Move to next line |
| 2144 | + editorService.requestPositionByTick(tick); |
| 2145 | + |
| 2146 | + // Assert: Position should NOT change (UI update suppressed) |
| 2147 | + QCOMPARE(positionChangedSpy.count(), 0); |
| 2148 | + // Assert: Time should change |
| 2149 | + QCOMPARE(currentTimeChangedSpy.count(), 1); |
| 2150 | + // Assert: Song position should NOT change (we are still in the same pattern) |
| 2151 | + QCOMPARE(songPositionChangedSpy.count(), 0); |
| 2152 | + QCOMPARE(editorService.songPosition(), 0); |
| 2153 | + |
| 2154 | + // Reset setting |
| 2155 | + Settings::setUiUpdatesDisabledDuringPlayback(false); |
| 2156 | + |
| 2157 | + // Another tick |
| 2158 | + const auto nextTick = tick * 2; |
| 2159 | + editorService.requestPositionByTick(nextTick); |
| 2160 | + |
| 2161 | + // Assert: Position should change now |
| 2162 | + QCOMPARE(positionChangedSpy.count(), 1); |
| 2163 | + QCOMPARE(currentTimeChangedSpy.count(), 2); |
| 2164 | + // Assert: Song position still 0 |
| 2165 | + QCOMPARE(songPositionChangedSpy.count(), 0); |
| 2166 | +} |
| 2167 | + |
2125 | 2168 | } // namespace noteahead |
2126 | 2169 |
|
2127 | 2170 | QTEST_GUILESS_MAIN(noteahead::EditorServiceTest) |
0 commit comments