|
|
|
@ -73,11 +73,13 @@ struct AbstractImageConverterTest: TestSuite::Tester { |
|
|
|
|
|
|
|
|
|
|
|
void exportToFile(); |
|
|
|
void exportToFile(); |
|
|
|
void exportToFileThroughData(); |
|
|
|
void exportToFileThroughData(); |
|
|
|
|
|
|
|
void exportToFileThroughDataFailed(); |
|
|
|
void exportToFileThroughDataNotWritable(); |
|
|
|
void exportToFileThroughDataNotWritable(); |
|
|
|
void exportToFileNotImplemented(); |
|
|
|
void exportToFileNotImplemented(); |
|
|
|
|
|
|
|
|
|
|
|
void exportCompressedToFile(); |
|
|
|
void exportCompressedToFile(); |
|
|
|
void exportCompressedToFileThroughData(); |
|
|
|
void exportCompressedToFileThroughData(); |
|
|
|
|
|
|
|
void exportCompressedToFileThroughDataFailed(); |
|
|
|
void exportCompressedToFileThroughDataNotWritable(); |
|
|
|
void exportCompressedToFileThroughDataNotWritable(); |
|
|
|
void exportCompressedToFileNotImplemented(); |
|
|
|
void exportCompressedToFileNotImplemented(); |
|
|
|
|
|
|
|
|
|
|
|
@ -118,11 +120,13 @@ AbstractImageConverterTest::AbstractImageConverterTest() { |
|
|
|
|
|
|
|
|
|
|
|
&AbstractImageConverterTest::exportToFile, |
|
|
|
&AbstractImageConverterTest::exportToFile, |
|
|
|
&AbstractImageConverterTest::exportToFileThroughData, |
|
|
|
&AbstractImageConverterTest::exportToFileThroughData, |
|
|
|
|
|
|
|
&AbstractImageConverterTest::exportToFileThroughDataFailed, |
|
|
|
&AbstractImageConverterTest::exportToFileThroughDataNotWritable, |
|
|
|
&AbstractImageConverterTest::exportToFileThroughDataNotWritable, |
|
|
|
&AbstractImageConverterTest::exportToFileNotImplemented, |
|
|
|
&AbstractImageConverterTest::exportToFileNotImplemented, |
|
|
|
|
|
|
|
|
|
|
|
&AbstractImageConverterTest::exportCompressedToFile, |
|
|
|
&AbstractImageConverterTest::exportCompressedToFile, |
|
|
|
&AbstractImageConverterTest::exportCompressedToFileThroughData, |
|
|
|
&AbstractImageConverterTest::exportCompressedToFileThroughData, |
|
|
|
|
|
|
|
&AbstractImageConverterTest::exportCompressedToFileThroughDataFailed, |
|
|
|
&AbstractImageConverterTest::exportCompressedToFileThroughDataNotWritable, |
|
|
|
&AbstractImageConverterTest::exportCompressedToFileThroughDataNotWritable, |
|
|
|
&AbstractImageConverterTest::exportCompressedToFileNotImplemented, |
|
|
|
&AbstractImageConverterTest::exportCompressedToFileNotImplemented, |
|
|
|
|
|
|
|
|
|
|
|
@ -469,6 +473,30 @@ void AbstractImageConverterTest::exportToFileThroughData() { |
|
|
|
"\xfe\xed", TestSuite::Compare::FileToString); |
|
|
|
"\xfe\xed", TestSuite::Compare::FileToString); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void AbstractImageConverterTest::exportToFileThroughDataFailed() { |
|
|
|
|
|
|
|
struct: AbstractImageConverter { |
|
|
|
|
|
|
|
ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertData; } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Containers::Array<char> doExportToData(const ImageView2D&) override { |
|
|
|
|
|
|
|
return {}; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
} converter; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const std::string filename = Utility::Directory::join(TRADE_TEST_OUTPUT_DIR, "image.out"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Remove previous file, if any */ |
|
|
|
|
|
|
|
Utility::Directory::rm(filename); |
|
|
|
|
|
|
|
CORRADE_VERIFY(!Utility::Directory::exists(filename)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Function should fail, no file should get written and no error output
|
|
|
|
|
|
|
|
should be printed (the base implementation assumes the plugin does it) */ |
|
|
|
|
|
|
|
std::ostringstream out; |
|
|
|
|
|
|
|
Error redirectError{&out}; |
|
|
|
|
|
|
|
CORRADE_VERIFY(!converter.exportToFile(ImageView2D(PixelFormat::RGBA8Unorm, {0xfe, 0xed}, {nullptr, 0xfe*0xed*4}), filename)); |
|
|
|
|
|
|
|
CORRADE_VERIFY(!Utility::Directory::exists(filename)); |
|
|
|
|
|
|
|
CORRADE_COMPARE(out.str(), ""); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void AbstractImageConverterTest::exportToFileThroughDataNotWritable() { |
|
|
|
void AbstractImageConverterTest::exportToFileThroughDataNotWritable() { |
|
|
|
struct: AbstractImageConverter { |
|
|
|
struct: AbstractImageConverter { |
|
|
|
ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertData; } |
|
|
|
ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertData; } |
|
|
|
@ -542,6 +570,30 @@ void AbstractImageConverterTest::exportCompressedToFileThroughData() { |
|
|
|
"\xb0\xd9", TestSuite::Compare::FileToString); |
|
|
|
"\xb0\xd9", TestSuite::Compare::FileToString); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void AbstractImageConverterTest::exportCompressedToFileThroughDataFailed() { |
|
|
|
|
|
|
|
struct: AbstractImageConverter { |
|
|
|
|
|
|
|
ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressedData; } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Containers::Array<char> doExportToData(const CompressedImageView2D&) override { |
|
|
|
|
|
|
|
return {}; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
} converter; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const std::string filename = Utility::Directory::join(TRADE_TEST_OUTPUT_DIR, "image.out"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Remove previous file, if any */ |
|
|
|
|
|
|
|
Utility::Directory::rm(filename); |
|
|
|
|
|
|
|
CORRADE_VERIFY(!Utility::Directory::exists(filename)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Function should fail, no file should get written and no error output
|
|
|
|
|
|
|
|
should be printed (the base implementation assumes the plugin does it) */ |
|
|
|
|
|
|
|
std::ostringstream out; |
|
|
|
|
|
|
|
Error redirectError{&out}; |
|
|
|
|
|
|
|
CORRADE_VERIFY(!converter.exportToFile(CompressedImageView2D{CompressedPixelFormat::Bc1RGBAUnorm, {0xb0, 0xd9}, {nullptr, 64}}, filename)); |
|
|
|
|
|
|
|
CORRADE_VERIFY(!Utility::Directory::exists(filename)); |
|
|
|
|
|
|
|
CORRADE_COMPARE(out.str(), ""); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void AbstractImageConverterTest::exportCompressedToFileThroughDataNotWritable() { |
|
|
|
void AbstractImageConverterTest::exportCompressedToFileThroughDataNotWritable() { |
|
|
|
struct: AbstractImageConverter { |
|
|
|
struct: AbstractImageConverter { |
|
|
|
ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressedData; } |
|
|
|
ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressedData; } |
|
|
|
|