PuzzleSDK
TestFileFuncs类 参考

#include <FileUtilsTest.h>

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

Public 成员函数

 CREATE_FUNC (TestFileFuncs)
 
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.h98 行定义.

成员函数说明

◆ CREATE_FUNC()

TestFileFuncs::CREATE_FUNC ( TestFileFuncs  )

◆ onEnter()

void TestFileFuncs::onEnter ( )
overridevirtual

重载 TestCase .

在文件 FileUtilsTest.cpp348 行定义.

349{
351 auto s = Director::getInstance()->getWinSize();
352 auto sharedFileUtils = FileUtils::getInstance();
353
354 int x = s.width/2,
355 y = s.height/5;
356 Label* label = nullptr;
357
358 std::string filename = "__test.test";
359 std::string filename2 = "__newtest.test";
360 std::string filepath = sharedFileUtils->getWritablePath() + filename;
361 std::string content = "Test string content to put into created file";
362 std::string msg;
363
364 FILE *out = fopen(filepath.c_str(), "w");
365 fputs(content.c_str(), out);
366 fclose(out);
367
368 // Check whether file can be created
369 if (sharedFileUtils->isFileExist(filepath))
370 {
371 label = Label::createWithSystemFont("Test file '__test.test' created", "", 20);
372 label->setPosition(x, y * 4);
373 this->addChild(label);
374
375 // getFileSize Test
376 long size = sharedFileUtils->getFileSize(filepath);
377 msg = StringUtils::format("getFileSize: Test file size equals %ld", size);
378 label = Label::createWithSystemFont(msg, "", 20);
379 label->setPosition(x, y * 3);
380 this->addChild(label);
381
382 // renameFile Test
383 if (sharedFileUtils->renameFile(sharedFileUtils->getWritablePath(), filename, filename2))
384 {
385 label = Label::createWithSystemFont("renameFile: Test file renamed to '__newtest.test'", "", 20);
386 label->setPosition(x, y * 2);
387 this->addChild(label);
388
389 // removeFile Test
390 filepath = sharedFileUtils->getWritablePath() + filename2;
391 if (sharedFileUtils->removeFile(filepath))
392 {
393 label = Label::createWithSystemFont("removeFile: Test file removed", "", 20);
394 label->setPosition(x, y * 1);
395 this->addChild(label);
396 }
397 else
398 {
399 label = Label::createWithSystemFont("removeFile: Failed to remove test file", "", 20);
400 label->setPosition(x, y * 1);
401 this->addChild(label);
402 }
403 }
404 else
405 {
406 label = Label::createWithSystemFont("renameFile: Failed to rename test file to '__newtest.test', further test skipped", "", 20);
407 label->setPosition(x, y * 2);
408 this->addChild(label);
409 }
410 }
411 else
412 {
413 label = Label::createWithSystemFont("Test file can not be created, test skipped", "", 20);
414 label->setPosition(x, y * 4);
415 this->addChild(label);
416 }
417}
virtual void onEnter() override
Definition: BaseTest.cpp:430

引用了 TestCase::onEnter().

+ 函数调用图:

◆ subtitle()

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

重载 TestCase .

在文件 FileUtilsTest.cpp424 行定义.

425{
426 return "";
427}

◆ title()

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

重载 TestCase .

在文件 FileUtilsTest.cpp419 行定义.

420{
421 return "FileUtils: file control functions";
422}

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