@@ -265,6 +265,57 @@ void DeviceRackControllerTest::test_subMixerCandidates_shouldCarryTrackNames()
265265 QVERIFY (!entry[" typeName" ].toString ().isEmpty ());
266266}
267267
268+ void DeviceRackControllerTest::test_usageSummary_device_shouldReturnTrackNames ()
269+ {
270+ const auto audioEngine = std::make_shared<AudioEngine>();
271+ const auto deviceService = std::make_shared<DeviceService>(audioEngine, std::make_shared<DataService>());
272+ const auto deviceName = " Device 1" ;
273+ deviceService->setDevice (0 , std::make_shared<MockDevice>(deviceName));
274+
275+ const auto editorService = std::make_shared<MockEditorService>();
276+ editorService->setMockIndices ({ 0 });
277+ editorService->setMockTrackName (0 , " Drums" );
278+ editorService->setMockInstrumentPortName (0 , QString::fromStdString (deviceName));
279+
280+ DeviceRackController controller { deviceService, {}, editorService };
281+
282+ QCOMPARE (controller.usageSummary (0 ), QString { " Drums" });
283+ }
284+
285+ void DeviceRackControllerTest::test_usageSummary_subMixer_shouldReturnMemberTrackNames ()
286+ {
287+ const auto audioEngine = std::make_shared<AudioEngine>();
288+ const auto deviceService = std::make_shared<DeviceService>(audioEngine, std::make_shared<DataService>());
289+ deviceService->setDevice (0 , std::make_shared<MockDevice>(" Device 1" ));
290+ deviceService->setDevice (1 , std::make_shared<MockDevice>(" Device 2" ));
291+ deviceService->setDevice (2 , std::make_shared<MockDevice>(" Device 3" ));
292+ deviceService->setDevice (3 , std::make_shared<SubMixerDevice>(" Inner" ));
293+ deviceService->setDevice (4 , std::make_shared<SubMixerDevice>(" Outer" ));
294+
295+ const auto editorService = std::make_shared<MockEditorService>();
296+ editorService->setMockIndices ({ 0 , 1 , 2 , 3 });
297+ editorService->setMockTrackName (0 , " Drums" );
298+ editorService->setMockInstrumentPortName (0 , " Device 1" );
299+ editorService->setMockTrackName (1 , " Bass" );
300+ editorService->setMockInstrumentPortName (1 , " Device 2" );
301+ editorService->setMockTrackName (2 , " Bass, doubled" );
302+ editorService->setMockInstrumentPortName (2 , " Device 2" );
303+ editorService->setMockTrackName (3 , " Pads" );
304+ editorService->setMockInstrumentPortName (3 , " Device 3" );
305+
306+ DeviceRackController controller { deviceService, {}, editorService };
307+
308+ QCOMPARE (controller.usageSummary (4 ), QString {});
309+
310+ QVERIFY (controller.addSubMixerMember (3 , 2 ));
311+ QVERIFY (controller.addSubMixerMember (4 , 0 ));
312+ QVERIFY (controller.addSubMixerMember (4 , 1 ));
313+ QVERIFY (controller.addSubMixerMember (4 , 3 ));
314+ QCOMPARE (controller.usageSummary (3 ), QString { " Pads" });
315+ // A nested SubMixer contributes the tracks of its own members.
316+ QCOMPARE (controller.usageSummary (4 ), QString { " Drums, Bass, Bass, doubled, Pads" });
317+ }
318+
268319void DeviceRackControllerTest::test_deviceGain_shouldDefaultToUnityAndRoundTrip ()
269320{
270321 const auto audioEngine = std::make_shared<AudioEngine>();
0 commit comments