PuzzleSDK
TestDirectoryFuncs类 参考

#include <FileUtilsTest.h>

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

Public 成员函数

 CREATE_FUNC (TestDirectoryFuncs)
 
virtual void onEnter () override
 
virtual std::string title () const override
 
virtual std::string subtitle () const 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)
 
virtual void onBackCallback (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
 

额外继承的成员函数

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

详细描述

在文件 FileUtilsTest.h108 行定义.

成员函数说明

◆ CREATE_FUNC()

TestDirectoryFuncs::CREATE_FUNC ( TestDirectoryFuncs  )

◆ onEnter()

void TestDirectoryFuncs::onEnter ( )
overridevirtual

重载 TestCase .

在文件 FileUtilsTest.cpp431 行定义.

432{
434 auto s = Director::getInstance()->getWinSize();
435 auto sharedFileUtils = FileUtils::getInstance();
436
437 int x = s.width/2,
438 y = s.height/4;
439 Label* label = nullptr;
440
441 std::string dir = sharedFileUtils->getWritablePath() + "__test";
442 std::string subDir = "dir1/dir2";
443 std::string fullSubDir = dir + "/" + subDir;
444 std::string msg;
445 bool ok;
446
447 // Check whether dir can be created
448 ok = sharedFileUtils->createDirectory(dir);
449 if (ok && sharedFileUtils->isDirectoryExist(dir))
450 {
451 msg = StringUtils::format("createDirectory: Directory '__test' created");
452 label = Label::createWithSystemFont(msg, "", 20);
453 label->setPosition(x, y * 3);
454 this->addChild(label);
455
456 // Create sub directories recursively
457 ok = sharedFileUtils->createDirectory(fullSubDir);
458 if (ok && sharedFileUtils->isDirectoryExist(fullSubDir))
459 {
460 msg = StringUtils::format("createDirectory: Sub directories '%s' created", subDir.c_str());
461 label = Label::createWithSystemFont(msg, "", 20);
462 label->setPosition(x, y * 2);
463 this->addChild(label);
464 }
465 else
466 {
467 msg = StringUtils::format("createDirectory: Failed to create sub directories '%s'", subDir.c_str());
468 label = Label::createWithSystemFont(msg, "", 20);
469 label->setPosition(x, y * 2);
470 this->addChild(label);
471 }
472
473 // Remove directory
474 ok = sharedFileUtils->removeDirectory(dir);
475 if (ok && !sharedFileUtils->isDirectoryExist(dir))
476 {
477 msg = StringUtils::format("removeDirectory: Directory '__test' removed");
478 label = Label::createWithSystemFont(msg, "", 20);
479 label->setPosition(x, y);
480 this->addChild(label);
481 }
482 else
483 {
484 msg = StringUtils::format("removeDirectory: Failed to remove directory '__test'");
485 label = Label::createWithSystemFont(msg, "", 20);
486 label->setPosition(x, y);
487 this->addChild(label);
488 }
489 }
490 else
491 {
492 msg = StringUtils::format("createDirectory: Directory '__test' can not be created");
493 label = Label::createWithSystemFont(msg, "", 20);
494 label->setPosition(x, y * 2);
495 this->addChild(label);
496 }
497}
virtual void onEnter() override
Definition: BaseTest.cpp:430

引用了 TestCase::onEnter().

+ 函数调用图:

◆ subtitle()

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

重载 TestCase .

在文件 FileUtilsTest.cpp504 行定义.

505{
506 return "";
507}

◆ title()

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

重载 TestCase .

在文件 FileUtilsTest.cpp499 行定义.

500{
501 return "FileUtils: directory control functions";
502}

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