PuzzleSDK
TestFileFuncsAsync类 参考

#include <FileUtilsTest.h>

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

Public 成员函数

 CREATE_FUNC (TestFileFuncsAsync)
 
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.h208 行定义.

成员函数说明

◆ CREATE_FUNC()

TestFileFuncsAsync::CREATE_FUNC ( TestFileFuncsAsync  )

◆ onEnter()

void TestFileFuncsAsync::onEnter ( )
overridevirtual

重载 TestCase .

在文件 FileUtilsTest.cpp1137 行定义.

1138{
1140 auto s = Director::getInstance()->getWinSize();
1141 auto sharedFileUtils = FileUtils::getInstance();
1142
1143 int x = s.width/2,
1144 y = s.height/5;
1145
1146 std::string filename = "__test.test";
1147 std::string filename2 = "__newtest.test";
1148 std::string filepath = sharedFileUtils->getWritablePath() + filename;
1149 std::string content = "Test string content to put into created file";
1150 std::string msg;
1151
1152 FILE *out = fopen(filepath.c_str(), "w");
1153 fputs(content.c_str(), out);
1154 fclose(out);
1155
1156
1157 sharedFileUtils->isFileExist(filepath, [=](bool exists) {
1158 CCASSERT(exists, "File could not be found");
1159 auto label = Label::createWithSystemFont("Test file '__test.test' created", "", 20);
1160 label->setPosition(x, y * 4);
1161 this->addChild(label);
1162
1163 sharedFileUtils->getFileSize(filepath, [=](long size) {
1164 auto msg = StringUtils::format("getFileSize: Test file size equals %ld", size);
1165 auto label = Label::createWithSystemFont(msg, "", 20);
1166 label->setPosition(x, y * 3);
1167 this->addChild(label);
1168
1169 sharedFileUtils->renameFile(sharedFileUtils->getWritablePath(), filename, filename2, [=] (bool success) {
1170 CCASSERT(success, "Was not able to properly rename file");
1171 auto label = Label::createWithSystemFont("renameFile: Test file renamed to '__newtest.test'", "", 20);
1172 label->setPosition(x, y * 2);
1173 this->addChild(label);
1174
1175 sharedFileUtils->removeFile(sharedFileUtils->getWritablePath() + filename2, [=](bool success) {
1176 CCASSERT(success, "Was not able to remove file");
1177 auto label = Label::createWithSystemFont("removeFile: Test file removed", "", 20);
1178 label->setPosition(x, y * 1);
1179 this->addChild(label);
1180 });
1181 });
1182 });
1183
1184 });
1185}
virtual void onEnter() override
Definition: BaseTest.cpp:430

引用了 TestCase::onEnter().

+ 函数调用图:

◆ subtitle()

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

重载 TestCase .

在文件 FileUtilsTest.cpp1192 行定义.

1193{
1194 return "";
1195}

◆ title()

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

重载 TestCase .

在文件 FileUtilsTest.cpp1187 行定义.

1188{
1189 return "FileUtilsAsync: file control functions";
1190}

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