@@ -100,6 +100,7 @@ TEST_F(SoundBlocksTest, RegisterBlocks)
100100 // Blocks
101101 EXPECT_CALL (m_engineMock, addCompileFunction (m_section.get (), " sound_play" , &SoundBlocks::compilePlay));
102102 EXPECT_CALL (m_engineMock, addCompileFunction (m_section.get (), " sound_playuntildone" , &SoundBlocks::compilePlayUntilDone));
103+ EXPECT_CALL (m_engineMock, addCompileFunction (m_section.get (), " sound_stopallsounds" , &SoundBlocks::compileStopAllSounds));
103104 EXPECT_CALL (m_engineMock, addCompileFunction (m_section.get (), " sound_changevolumeby" , &SoundBlocks::compileChangeVolumeBy));
104105 EXPECT_CALL (m_engineMock, addCompileFunction (m_section.get (), " sound_setvolumeto" , &SoundBlocks::compileSetVolumeTo));
105106 EXPECT_CALL (m_engineMock, addCompileFunction (m_section.get (), " sound_volume" , &SoundBlocks::compileVolume));
@@ -550,6 +551,39 @@ TEST_F(SoundBlocksTest, PlayUntilDoneImpl)
550551 SoundPrivate::playerFactory = nullptr ;
551552}
552553
554+ TEST_F (SoundBlocksTest, StopAllSounds)
555+ {
556+ Compiler compiler (&m_engineMock);
557+
558+ auto block = std::make_shared<Block>(" a" , " sound_stopallsounds" );
559+
560+ EXPECT_CALL (m_engineMock, functionIndex (&SoundBlocks::stopAllSounds)).WillOnce (Return (0 ));
561+
562+ compiler.init ();
563+ compiler.setBlock (block);
564+ SoundBlocks::compileStopAllSounds (&compiler);
565+ compiler.end ();
566+
567+ ASSERT_EQ (compiler.bytecode (), std::vector<unsigned int >({ vm::OP_START, vm::OP_EXEC, 0 , vm::OP_HALT }));
568+ ASSERT_TRUE (compiler.constValues ().empty ());
569+ }
570+
571+ TEST_F (SoundBlocksTest, StopAllSoundsImpl)
572+ {
573+ static unsigned int bytecode[] = { vm::OP_START, vm::OP_EXEC, 0 , vm::OP_HALT };
574+ static BlockFunc functions[] = { &SoundBlocks::stopAllSounds };
575+
576+ VirtualMachine vm (nullptr , &m_engineMock, nullptr );
577+
578+ vm.setBytecode (bytecode);
579+ vm.setFunctions (functions);
580+
581+ EXPECT_CALL (m_engineMock, stopSounds ());
582+ vm.run ();
583+
584+ ASSERT_EQ (vm.registerCount (), 0 );
585+ }
586+
553587TEST_F (SoundBlocksTest, ChangeVolumeBy)
554588{
555589 Compiler compiler (&m_engineMock);
0 commit comments