axmol/tests/cpp-tests/Classes/FileUtilsTest/FileUtilsTest.h

238 lines
5.6 KiB
C
Raw Normal View History

2013-01-28 15:17:20 +08:00
#ifndef __FILEUTILSTEST_H__
#define __FILEUTILSTEST_H__
#include "../BaseTest.h"
2013-01-28 15:17:20 +08:00
DEFINE_TEST_SUITE(FileUtilsTests);
2013-01-28 15:17:20 +08:00
class FileUtilsDemo : public TestCase
2013-01-28 15:17:20 +08:00
{
public:
};
class TestResolutionDirectories : public FileUtilsDemo
{
public:
2013-11-14 07:55:36 +08:00
CREATE_FUNC(TestResolutionDirectories);
virtual void onEnter() override;
virtual void onExit() override;
virtual std::string title() const override;
virtual std::string subtitle() const override;
2013-01-28 15:17:20 +08:00
private:
std::vector<std::string> _defaultSearchPathArray;
std::vector<std::string> _defaultResolutionsOrderArray;
2013-01-28 15:17:20 +08:00
};
class TestSearchPath : public FileUtilsDemo
{
public:
2013-11-14 07:55:36 +08:00
CREATE_FUNC(TestSearchPath);
virtual void onEnter() override;
virtual void onExit() override;
virtual std::string title() const override;
virtual std::string subtitle() const override;
2013-01-28 15:17:20 +08:00
private:
std::vector<std::string> _defaultSearchPathArray;
std::vector<std::string> _defaultResolutionsOrderArray;
2013-01-28 15:17:20 +08:00
};
class TestFilenameLookup : public FileUtilsDemo
{
public:
2013-11-14 07:55:36 +08:00
CREATE_FUNC(TestFilenameLookup);
virtual void onEnter() override;
virtual void onExit() override;
virtual std::string title() const override;
2013-01-28 15:17:20 +08:00
};
class TestIsFileExist : public FileUtilsDemo
{
public:
2013-11-14 07:55:36 +08:00
CREATE_FUNC(TestIsFileExist);
virtual void onEnter() override;
virtual void onExit() override;
virtual std::string title() const override;
virtual std::string subtitle() const override;
};
2013-01-28 15:17:20 +08:00
class TestIsDirectoryExist : public FileUtilsDemo
{
public:
CREATE_FUNC(TestIsDirectoryExist);
Add FileUtils::getContents(). (#15479) * Add FileUtils::getContents(). * skip FileUtils::getContents() in binding generator config. * use FileUtils::getContents in CCDataReaderHelper. * obey the cocos2d-x coding style. * Explicit constructor. * More docs. * More tests. * Move FileError to FileUtils::Error. * Fixes wrong buffer size for reading into string and vector. * Update tests. * Add note on padding for output buffers. * FileUtils: implements old methods by using `getContents()`. methods are: * FileUtils::getDataFromFile() * FileUtils::getStringFromFile() * FileUtils::getFileData() and follow Android methods are now just calls FileUtils' ones. * FileUtilsAndroid::getDataFromFile() * FileUtilsAndroid::getStringFromFile() * FileUtilsAndroid::getFileData() * Fixes build error. * FileUtils::getFileData: Return the size of data. * Remove old methods form FileUtilsAndroid they are now done in FileUtils. * Fixes for win32 code. * Fixes build error in test and add more test. * Better error message. * Make template type name more readable. * Update comments. * Move internal functions to anonymous namespace. * Refactor FileUtils test. * Fix warning about compare signed and unsigned. * Win32 and WinRT does not use text mode. That is we don't need simulate convert CRLF to LF. * Fixes for Win32 and WinRT. * Update for Win32 and WinRT. * Win32: return FileUtils:Error::TooLarge when file is large than 2^32-1. * Win32: remove checkFileName() which has no effect at all. * WinRT: add FileUtilsWinRT::getContents() using ::CreateFile2. * WinRT: add override keyword for FileUtilsWinRT::getFileSize(). * Update for coding styles. * More error strings. * check read and malloc return codes. * rename FileUtils::Error to FileUtils::Status. * Fixes for WinRT, use GetFileInformationByHandleEx to get file size. * Fixes build error for winrt and cleanup FileUtils::Status. * Try to fix the build error on Linux. Status must defined in some header, so move FileUtils.h up. * Remove support of text mode on WinRT (it is the last platform support text mode).
2016-04-26 13:37:22 +08:00
virtual void onEnter() override;
virtual void onExit() override;
virtual std::string title() const override;
virtual std::string subtitle() const override;
};
class TestFileFuncs : public FileUtilsDemo
{
public:
CREATE_FUNC(TestFileFuncs);
virtual void onEnter() override;
virtual std::string title() const override;
virtual std::string subtitle() const override;
};
class TestDirectoryFuncs : public FileUtilsDemo
{
public:
CREATE_FUNC(TestDirectoryFuncs);
virtual void onEnter() override;
virtual std::string title() const override;
virtual std::string subtitle() const override;
};
class TextWritePlist : public FileUtilsDemo
{
public:
2013-11-14 07:55:36 +08:00
CREATE_FUNC(TextWritePlist);
virtual void onEnter() override;
virtual void onExit() override;
virtual std::string title() const override;
virtual std::string subtitle() const override;
};
class TestWriteString : public FileUtilsDemo
{
public:
CREATE_FUNC(TestWriteString);
virtual void onEnter() override;
virtual void onExit() override;
virtual std::string title() const override;
virtual std::string subtitle() const override;
};
Add FileUtils::getContents(). (#15479) * Add FileUtils::getContents(). * skip FileUtils::getContents() in binding generator config. * use FileUtils::getContents in CCDataReaderHelper. * obey the cocos2d-x coding style. * Explicit constructor. * More docs. * More tests. * Move FileError to FileUtils::Error. * Fixes wrong buffer size for reading into string and vector. * Update tests. * Add note on padding for output buffers. * FileUtils: implements old methods by using `getContents()`. methods are: * FileUtils::getDataFromFile() * FileUtils::getStringFromFile() * FileUtils::getFileData() and follow Android methods are now just calls FileUtils' ones. * FileUtilsAndroid::getDataFromFile() * FileUtilsAndroid::getStringFromFile() * FileUtilsAndroid::getFileData() * Fixes build error. * FileUtils::getFileData: Return the size of data. * Remove old methods form FileUtilsAndroid they are now done in FileUtils. * Fixes for win32 code. * Fixes build error in test and add more test. * Better error message. * Make template type name more readable. * Update comments. * Move internal functions to anonymous namespace. * Refactor FileUtils test. * Fix warning about compare signed and unsigned. * Win32 and WinRT does not use text mode. That is we don't need simulate convert CRLF to LF. * Fixes for Win32 and WinRT. * Update for Win32 and WinRT. * Win32: return FileUtils:Error::TooLarge when file is large than 2^32-1. * Win32: remove checkFileName() which has no effect at all. * WinRT: add FileUtilsWinRT::getContents() using ::CreateFile2. * WinRT: add override keyword for FileUtilsWinRT::getFileSize(). * Update for coding styles. * More error strings. * check read and malloc return codes. * rename FileUtils::Error to FileUtils::Status. * Fixes for WinRT, use GetFileInformationByHandleEx to get file size. * Fixes build error for winrt and cleanup FileUtils::Status. * Try to fix the build error on Linux. Status must defined in some header, so move FileUtils.h up. * Remove support of text mode on WinRT (it is the last platform support text mode).
2016-04-26 13:37:22 +08:00
class TestGetContents : public FileUtilsDemo
{
public:
CREATE_FUNC(TestGetContents);
virtual void onEnter() override;
virtual void onExit() override;
virtual std::string title() const override;
virtual std::string subtitle() const override;
private:
std::string _generatedFile;
};
class TestWriteData : public FileUtilsDemo
{
public:
CREATE_FUNC(TestWriteData);
virtual void onEnter() override;
virtual void onExit() override;
virtual std::string title() const override;
virtual std::string subtitle() const override;
};
class TestWriteValueMap : public FileUtilsDemo
{
public:
CREATE_FUNC(TestWriteValueMap);
virtual void onEnter() override;
virtual void onExit() override;
virtual std::string title() const override;
virtual std::string subtitle() const override;
};
class TestWriteValueVector : public FileUtilsDemo
{
public:
CREATE_FUNC(TestWriteValueVector);
virtual void onEnter() override;
virtual void onExit() override;
virtual std::string title() const override;
virtual std::string subtitle() const override;
};
class TestUnicodePath : public FileUtilsDemo
{
public:
CREATE_FUNC(TestUnicodePath);
Add FileUtils::getContents(). (#15479) * Add FileUtils::getContents(). * skip FileUtils::getContents() in binding generator config. * use FileUtils::getContents in CCDataReaderHelper. * obey the cocos2d-x coding style. * Explicit constructor. * More docs. * More tests. * Move FileError to FileUtils::Error. * Fixes wrong buffer size for reading into string and vector. * Update tests. * Add note on padding for output buffers. * FileUtils: implements old methods by using `getContents()`. methods are: * FileUtils::getDataFromFile() * FileUtils::getStringFromFile() * FileUtils::getFileData() and follow Android methods are now just calls FileUtils' ones. * FileUtilsAndroid::getDataFromFile() * FileUtilsAndroid::getStringFromFile() * FileUtilsAndroid::getFileData() * Fixes build error. * FileUtils::getFileData: Return the size of data. * Remove old methods form FileUtilsAndroid they are now done in FileUtils. * Fixes for win32 code. * Fixes build error in test and add more test. * Better error message. * Make template type name more readable. * Update comments. * Move internal functions to anonymous namespace. * Refactor FileUtils test. * Fix warning about compare signed and unsigned. * Win32 and WinRT does not use text mode. That is we don't need simulate convert CRLF to LF. * Fixes for Win32 and WinRT. * Update for Win32 and WinRT. * Win32: return FileUtils:Error::TooLarge when file is large than 2^32-1. * Win32: remove checkFileName() which has no effect at all. * WinRT: add FileUtilsWinRT::getContents() using ::CreateFile2. * WinRT: add override keyword for FileUtilsWinRT::getFileSize(). * Update for coding styles. * More error strings. * check read and malloc return codes. * rename FileUtils::Error to FileUtils::Status. * Fixes for WinRT, use GetFileInformationByHandleEx to get file size. * Fixes build error for winrt and cleanup FileUtils::Status. * Try to fix the build error on Linux. Status must defined in some header, so move FileUtils.h up. * Remove support of text mode on WinRT (it is the last platform support text mode).
2016-04-26 13:37:22 +08:00
virtual void onEnter() override;
virtual void onExit() override;
virtual std::string title() const override;
virtual std::string subtitle() const override;
};
class TestIsFileExistAsync : public FileUtilsDemo
{
public:
CREATE_FUNC(TestIsFileExistAsync);
virtual void onEnter() override;
virtual void onExit() override;
virtual std::string title() const override;
virtual std::string subtitle() const override;
};
class TestIsDirectoryExistAsync : public FileUtilsDemo
{
public:
CREATE_FUNC(TestIsDirectoryExistAsync);
virtual void onEnter() override;
virtual void onExit() override;
virtual std::string title() const override;
virtual std::string subtitle() const override;
};
class TestFileFuncsAsync : public FileUtilsDemo
{
public:
CREATE_FUNC(TestFileFuncsAsync);
virtual void onEnter() override;
virtual std::string title() const override;
virtual std::string subtitle() const override;
};
class TestDirectoryFuncsAsync : public FileUtilsDemo
{
public:
CREATE_FUNC(TestDirectoryFuncsAsync);
virtual void onEnter() override;
virtual std::string title() const override;
virtual std::string subtitle() const override;
};
class TestWriteStringAsync : public FileUtilsDemo
{
public:
CREATE_FUNC(TestWriteStringAsync);
virtual void onEnter() override;
virtual void onExit() override;
virtual std::string title() const override;
virtual std::string subtitle() const override;
};
class TestWriteDataAsync : public FileUtilsDemo
{
public:
CREATE_FUNC(TestWriteDataAsync);
virtual void onEnter() override;
virtual void onExit() override;
virtual std::string title() const override;
virtual std::string subtitle() const override;
};
2013-01-28 15:17:20 +08:00
#endif /* __FILEUTILSTEST_H__ */