PuzzleSDK
AudioPerformanceTest类 参考

#include <NewAudioEngineTest.h>

+ 类 AudioPerformanceTest 继承关系图:
+ AudioPerformanceTest 的协作图:

Public 成员函数

 CREATE_FUNC (AudioPerformanceTest)
 
virtual bool init () override
 
virtual std::string title () const override
 
virtual std::string subtitle () const override
 
- Public 成员函数 继承自 AudioEngineTestDemo
 AudioEngineTestDemo ()
 
virtual void onExit () override
 
virtual void onBackCallback (cocos2d::Ref *sender) override
 
- Public 成员函数 继承自 TestCase
 TestCase ()
 
 ~TestCase ()
 
virtual Type getTestType () const
 
virtual float getDuration () const
 
virtual std::string getExpectedOutput () const
 
virtual std::string getActualOutput () const
 
virtual void restartTestCallback (cocos2d::Ref *sender)
 
virtual void nextTestCallback (cocos2d::Ref *sender)
 
virtual void priorTestCallback (cocos2d::Ref *sender)
 
void setTestSuite (TestSuite *testSuite)
 
TestSuitegetTestSuite () const
 
float getRunTime () const
 
void setTestCaseName (const std::string &name)
 
std::string getTestCaseName () const
 
const cocos2d::Label * getSubtitleLable () const
 
const cocos2d::MenuItemImage * getRestartTestItem () const
 
virtual void onEnter () override
 

额外继承的成员函数

- Public 类型 继承自 TestCase
enum class  Type { ROBUSTNESS , UNIT , GRAPHICAL_STATIC , MANUAL }
 
- Public 属性 继承自 TestCase
CC_CONSTRUCTOR_ACCESS __pad0__: virtual bool init() override
 
- Protected 属性 继承自 AudioEngineTestDemo
std::shared_ptr< bool > _isDestroyed
 
- Protected 属性 继承自 TestCase
cocos2d::MenuItemImage * _priorTestItem
 
cocos2d::MenuItemImage * _restartTestItem
 
cocos2d::MenuItemImage * _nextTestItem
 
cocos2d::Label * _titleLabel
 
cocos2d::Label * _subtitleLabel
 

详细描述

在文件 NewAudioEngineTest.h188 行定义.

成员函数说明

◆ CREATE_FUNC()

AudioPerformanceTest::CREATE_FUNC ( AudioPerformanceTest  )

◆ init()

bool AudioPerformanceTest::init ( )
overridevirtual

在文件 NewAudioEngineTest.cpp776 行定义.

777{
778 if (AudioEngineTestDemo::init())
779 {
780 std::vector<std::string> audioFiles = {
781 "audio/SoundEffectsFX009/FX081.mp3",
782 "audio/SoundEffectsFX009/FX082.mp3",
783 "audio/SoundEffectsFX009/FX083.mp3",
784 "audio/SoundEffectsFX009/FX084.mp3",
785 "audio/SoundEffectsFX009/FX085.mp3",
786 "audio/SoundEffectsFX009/FX086.mp3",
787 "audio/SoundEffectsFX009/FX087.mp3",
788 "audio/SoundEffectsFX009/FX088.mp3",
789 "audio/SoundEffectsFX009/FX089.mp3",
790 "audio/SoundEffectsFX009/FX090.mp3"
791 };
792
793 for (const auto& audioFile : audioFiles)
794 {
795 AudioEngine::preload(audioFile);
796 }
797
798 auto& layerSize = this->getContentSize();
799
800 auto playItem = TextButton::create("Start Test", [this, audioFiles](TextButton* button){
801 button->setEnabled(false);
802 static_cast<TextButton*>(getChildByName("DisplayButton"))->setEnabled(true);
803
804 unschedule("test");
805 schedule([audioFiles](float dt){
806 int index = cocos2d::random(0, (int)(audioFiles.size()-1));
807 CC_PROFILER_START("play2d");
808 AudioEngine::play2d(audioFiles[index]);
809 CC_PROFILER_STOP("play2d");
810 }, 0.25f, "test");
811 });
812 playItem->setPosition(layerSize.width * 0.5f, layerSize.height * 2 / 3);
813 playItem->setName("PlayButton");
814 addChild(playItem);
815
816 auto displayItem = TextButton::create("Display Result", [this, playItem](TextButton* button){
817 unschedule("test");
818 AudioEngine::stopAll();
820 playItem->setEnabled(true);
821 button->setEnabled(false);
822 });
823 displayItem->setEnabled(false);
824 displayItem->setPosition(layerSize.width * 0.5f, layerSize.height / 3);
825 displayItem->setName("DisplayButton");
826 addChild(displayItem);
827
828 return true;
829 }
830
831 return false;
832}
#define CC_PROFILER_STOP(__name__)
#define CC_PROFILER_DISPLAY_TIMERS()
#define CC_PROFILER_START(__name__)

引用了 CC_PROFILER_DISPLAY_TIMERS, CC_PROFILER_START , 以及 CC_PROFILER_STOP.

◆ subtitle()

std::string AudioPerformanceTest::subtitle ( ) const
overridevirtual

重载 TestCase .

在文件 NewAudioEngineTest.cpp839 行定义.

840{
841 return "Please see console for the result";
842}

◆ title()

std::string AudioPerformanceTest::title ( ) const
overridevirtual

重载 AudioEngineTestDemo .

在文件 NewAudioEngineTest.cpp834 行定义.

835{
836 return "Test Performance of AudioEngine::play2d, audio is played 1 time per second";
837}

该类的文档由以下文件生成: