#include "TranslatorRosterTest.h"
#include <stdio.h>
#include <string.h>
#include <Application.h>
#include <Archivable.h>
#include <File.h>
#include <Message.h>
#include <OS.h>
#include <TranslatorFormats.h>
#include <cppunit/Test.h>
#include <cppunit/TestCaller.h>
#include <cppunit/TestSuite.h>
TranslatorRosterTest::TranslatorRosterTest(std::string name)
: BTestCase(name)
{
}
TranslatorRosterTest::~TranslatorRosterTest()
{
}
CppUnit::Test *
TranslatorRosterTest::Suite()
{
CppUnit::TestSuite *suite = new CppUnit::TestSuite("TranslatorRoster");
suite->addTest(new CppUnit::TestCaller<TranslatorRosterTest>(
"TranslatorRosterTest::Initialize Test",
&TranslatorRosterTest::InitializeTest));
suite->addTest(new CppUnit::TestCaller<TranslatorRosterTest>(
"TranslatorRosterTest::Default Test",
&TranslatorRosterTest::DefaultTest));
suite->addTest(new CppUnit::TestCaller<TranslatorRosterTest>(
"TranslatorRosterTest::Instantiate Test",
&TranslatorRosterTest::InstantiateTest));
suite->addTest(new CppUnit::TestCaller<TranslatorRosterTest>(
"TranslatorRosterTest::Version Test",
&TranslatorRosterTest::VersionTest));
suite->addTest(new CppUnit::TestCaller<TranslatorRosterTest>(
"TranslatorRosterTest::AddTranslators Test",
&TranslatorRosterTest::AddTranslatorsTest));
suite->addTest(new CppUnit::TestCaller<TranslatorRosterTest>(
"TranslatorRosterTest::Archive Test",
&TranslatorRosterTest::ArchiveTest));
suite->addTest(new CppUnit::TestCaller<TranslatorRosterTest>(
"TranslatorRosterTest::GetConfigurationMessage Test",
&TranslatorRosterTest::GetConfigurationMessageTest));
suite->addTest(new CppUnit::TestCaller<TranslatorRosterTest>(
"TranslatorRosterTest::GetInputFormats Test",
&TranslatorRosterTest::GetInputFormatsTest));
suite->addTest(new CppUnit::TestCaller<TranslatorRosterTest>(
"TranslatorRosterTest::GetOutputFormats Test",
&TranslatorRosterTest::GetOutputFormatsTest));
suite->addTest(new CppUnit::TestCaller<TranslatorRosterTest>(
"TranslatorRosterTest::GetTranslatorInfo Test",
&TranslatorRosterTest::GetTranslatorInfoTest));
suite->addTest(new CppUnit::TestCaller<TranslatorRosterTest>(
"TranslatorRosterTest::GetTranslators Test",
&TranslatorRosterTest::GetTranslatorsTest));
suite->addTest(new CppUnit::TestCaller<TranslatorRosterTest>(
"TranslatorRosterTest::Identify Test",
&TranslatorRosterTest::IdentifyTest));
suite->addTest(new CppUnit::TestCaller<TranslatorRosterTest>(
"TranslatorRosterTest::MakeConfigurationView Test",
&TranslatorRosterTest::MakeConfigurationViewTest));
suite->addTest(new CppUnit::TestCaller<TranslatorRosterTest>(
"TranslatorRosterTest::Translate Test",
&TranslatorRosterTest::TranslateTest));
return suite;
}
void
TranslatorRosterTest::InitializeTest()
{
NextSubTest();
BTranslatorRoster *proster = BTranslatorRoster::Default();
CPPUNIT_ASSERT(proster);
}
void
TranslatorRosterTest::ConstructorTest()
{
BTranslatorRoster *proster;
NextSubTest();
proster = new BTranslatorRoster();
CPPUNIT_ASSERT(proster != NULL);
delete proster;
proster = NULL;
NextSubTest();
BMessage translator_message;
translator_message.AddString("be:translator_path",
"/boot/system/add-ons/Translators");
proster = new BTranslatorRoster(&translator_message);
CPPUNIT_ASSERT(proster != NULL);
NextSubTest();
int32 nloaded = -42;
translator_id *pids = NULL;
CPPUNIT_ASSERT(proster->GetAllTranslators(&pids, &nloaded) == B_NO_ERROR);
CPPUNIT_ASSERT(nloaded > 0);
CPPUNIT_ASSERT(pids != NULL);
NextSubTest();
const char *kaTranslatorNames[] = {
"TGA Images",
"MNGTranslator",
"BMP Images",
"TestBmpTranslator",
"BBitmap Images",
"GIMPPatternHandler"
};
int32 naCounts[sizeof(kaTranslatorNames) /
sizeof(const char *)] = { 0 };
CPPUNIT_ASSERT(nloaded == sizeof(kaTranslatorNames) /
sizeof(const char *));
for (int32 i = 0; i < nloaded; i++) {
const char *kTranslatorName, *kTranslatorInfo;
int32 nTranslatorVersion;
CPPUNIT_ASSERT(pids[i] > 0);
kTranslatorName = kTranslatorInfo = NULL;
nTranslatorVersion = -246;
proster->GetTranslatorInfo(pids[i], &kTranslatorName,
&kTranslatorInfo, &nTranslatorVersion);
CPPUNIT_ASSERT(kTranslatorName);
CPPUNIT_ASSERT(kTranslatorInfo);
CPPUNIT_ASSERT(nTranslatorVersion > 0);
int32 npresent = 0;
for (int32 k = 0; k < nloaded; k++) {
if (!strcmp(kaTranslatorNames[k], kTranslatorName)) {
npresent++;
naCounts[k]++;
}
}
CPPUNIT_ASSERT(npresent == 1);
}
for (int32 i = 0; i < nloaded; i++)
CPPUNIT_ASSERT(naCounts[i] == 1);
delete proster;
proster = NULL;
}
void
TranslatorRosterTest::DefaultTest()
{
NextSubTest();
BTranslatorRoster *proster = BTranslatorRoster::Default();
CPPUNIT_ASSERT(proster != NULL);
NextSubTest();
delete proster;
proster = NULL;
NextSubTest();
proster = BTranslatorRoster::Default();
CPPUNIT_ASSERT(proster);
NextSubTest();
translator_id *pids = NULL;
int32 ncount = -1;
CPPUNIT_ASSERT(proster->GetAllTranslators(&pids, &ncount) == B_OK);
CPPUNIT_ASSERT(pids);
CPPUNIT_ASSERT(ncount > 0);
delete[] pids;
pids = NULL;
NextSubTest();
delete proster;
proster = NULL;
}
void
TranslatorRosterTest::InstantiateTest()
{
BTranslatorRoster* proster = NULL;
BMessage bmsg;
NextSubTest();
proster = dynamic_cast<BTranslatorRoster *>
(BTranslatorRoster::Instantiate(&bmsg));
CPPUNIT_ASSERT(proster == NULL);
delete proster;
proster = NULL;
NextSubTest();
status_t result;
result = bmsg.AddString("class", "BTranslatorRoster");
CPPUNIT_ASSERT(result == B_OK);
result = bmsg.AddString("be:translator_path",
"/boot/system/add-ons/Translators/BMPTranslator");
CPPUNIT_ASSERT(result == B_OK);
proster = dynamic_cast<BTranslatorRoster *>
(BTranslatorRoster::Instantiate(&bmsg));
CPPUNIT_ASSERT(proster);
translator_id *pids = NULL;
int32 ncount = -1;
result = proster->GetAllTranslators(&pids, &ncount);
CPPUNIT_ASSERT(result == B_OK);
CPPUNIT_ASSERT(pids);
CPPUNIT_ASSERT(ncount == 1);
const char *strName = NULL, *strInfo = NULL;
int32 nversion = -1;
result = proster->GetTranslatorInfo(pids[0], &strName, &strInfo,
&nversion);
CPPUNIT_ASSERT(result == B_OK);
CPPUNIT_ASSERT(strName);
CPPUNIT_ASSERT(strInfo);
CPPUNIT_ASSERT(nversion > 0);
delete proster;
proster = NULL;
NextSubTest();
result = bmsg.MakeEmpty();
CPPUNIT_ASSERT(result == B_OK);
result = bmsg.AddString("class", "BTranslatorRoster");
CPPUNIT_ASSERT(result == B_OK);
proster = dynamic_cast<BTranslatorRoster *>
(BTranslatorRoster::Instantiate(&bmsg));
CPPUNIT_ASSERT(proster);
delete proster;
proster = NULL;
NextSubTest();
result = bmsg.MakeEmpty();
CPPUNIT_ASSERT(result == B_OK);
result = bmsg.AddString("be:translator_path",
"/boot/system/add-ons/Translators/BMPTranslator");
CPPUNIT_ASSERT(result == B_OK);
proster = dynamic_cast<BTranslatorRoster *>
(BTranslatorRoster::Instantiate(&bmsg));
CPPUNIT_ASSERT(proster == NULL);
delete proster;
proster = NULL;
}
void
TranslatorRosterTest::VersionTest()
{
#if 0
NextSubTest();
int32 outCurVersion = 0;
int32 outMinVersion = 0;
const char* info = NULL;
info = BTranslatorRoster::Version(&outCurVersion, &outMinVersion);
CPPUNIT_ASSERT(info != NULL);
CPPUNIT_ASSERT(outCurVersion > 0);
CPPUNIT_ASSERT(outMinVersion > 0);
#endif
}
void
CompareWithDefault(BTranslatorRoster *proster)
{
BTranslatorRoster *pDefRoster = BTranslatorRoster::Default();
CPPUNIT_ASSERT(pDefRoster);
translator_id *pInstids = NULL, *pDefids = NULL;
int32 instcount = 0, defcount = 0, ndummy = 0;
const char *strDefName = NULL, *strInstName = NULL, *strDummy = NULL;
CPPUNIT_ASSERT(proster->GetAllTranslators(&pInstids, &instcount) == B_OK);
CPPUNIT_ASSERT(pInstids);
CPPUNIT_ASSERT(instcount > 0);
CPPUNIT_ASSERT(pDefRoster->GetAllTranslators(&pDefids, &defcount) == B_OK);
CPPUNIT_ASSERT(pDefids);
CPPUNIT_ASSERT(defcount > 0);
CPPUNIT_ASSERT(defcount == instcount);
for (int32 i = 0; i < defcount; i++) {
int32 matches;
matches = 0;
CPPUNIT_ASSERT(pDefRoster->GetTranslatorInfo(pDefids[i], &strDefName,
&strDummy, &ndummy) == B_OK);
CPPUNIT_ASSERT(strDefName);
for (int32 k = 0; k < instcount; k++) {
CPPUNIT_ASSERT(proster->GetTranslatorInfo(pInstids[k],
&strInstName, &strDummy, &ndummy) == B_OK);
CPPUNIT_ASSERT(strInstName);
if (strcmp(strDefName, strInstName) == 0)
matches++;
}
CPPUNIT_ASSERT(matches == 1);
}
delete[] pInstids;
pInstids = NULL;
delete[] pDefids;
pDefids = NULL;
}
void
TranslatorRosterTest::AddTranslatorsTest()
{
NextSubTest();
BTranslatorRoster* proster = new BTranslatorRoster();
CPPUNIT_ASSERT(proster);
CPPUNIT_ASSERT(proster->AddTranslators(
"/boot/home/config/add-ons/Translators/:"
"/system/add-ons/Translators/") == B_OK);
NextSubTest();
int32 instcount = 0;
translator_id* translators = NULL;
proster->GetAllTranslators(&translators, &instcount);
CPPUNIT_ASSERT(translators);
CPPUNIT_ASSERT(instcount > 0);
delete[] translators;
translators = NULL;
NextSubTest();
delete proster;
proster = new BTranslatorRoster();
CPPUNIT_ASSERT(proster->AddTranslators() == B_OK);
NextSubTest();
CompareWithDefault(proster);
delete proster;
proster = NULL;
}
void
TranslatorRosterTest::ArchiveTest()
{
NextSubTest();
BMessage translator_message;
BTranslatorRoster *pDefRoster = BTranslatorRoster::Default();
CPPUNIT_ASSERT(pDefRoster);
CPPUNIT_ASSERT(pDefRoster->Archive(&translator_message) == B_OK);
NextSubTest();
BTranslatorRoster *proster = NULL;
proster = dynamic_cast<BTranslatorRoster *>
(BTranslatorRoster::Instantiate(&translator_message));
CPPUNIT_ASSERT(proster);
NextSubTest();
CompareWithDefault(proster);
delete proster;
proster = NULL;
}
void
TranslatorRosterTest::GetAllTranslatorsTest()
{
NextSubTest();
int32 nloaded = 42;
translator_id* pids = NULL;
BTranslatorRoster roster;
CPPUNIT_ASSERT(roster.GetAllTranslators(NULL, &nloaded) == B_BAD_VALUE);
CPPUNIT_ASSERT(nloaded == 42);
CPPUNIT_ASSERT(roster.GetAllTranslators(&pids, NULL) == B_BAD_VALUE);
CPPUNIT_ASSERT(pids == NULL);
CPPUNIT_ASSERT(roster.GetAllTranslators(NULL, NULL) == B_BAD_VALUE);
NextSubTest();
CPPUNIT_ASSERT(
roster.GetAllTranslators(&pids, &nloaded) == B_NO_ERROR);
CPPUNIT_ASSERT(nloaded == 0);
delete[] pids;
pids = NULL;
NextSubTest();
nloaded = 42;
BTranslatorRoster *pDefRoster = BTranslatorRoster::Default();
CPPUNIT_ASSERT(
pDefRoster->GetAllTranslators(&pids, &nloaded) == B_NO_ERROR);
CPPUNIT_ASSERT(nloaded > 0);
CPPUNIT_ASSERT(pids != NULL);
NextSubTest();
const char *kaTranslatorNames[] = {
"Gobe MS-WORD Translator",
"Gobe Text Translator",
"TIFF Images",
"Gobe SYLK Translator",
"StyledEdit Files",
"Gobe RTF Translator",
"PPM Images",
"JPEG Images",
"Gobe HTML Translator",
"Gobe Excel Translator",
"TGA Images",
"MNGTranslator",
"GIMPPatternHandler",
"TestBmpTranslator",
"BMP Images",
"BBitmap Images"
};
CPPUNIT_ASSERT(nloaded == sizeof(kaTranslatorNames) /
sizeof(const char *));
for (int32 i = 0; i < nloaded; i++) {
const char *kTranslatorName, *kTranslatorInfo;
int32 nTranslatorVersion;
CPPUNIT_ASSERT(pids[i] > 0);
kTranslatorName = kTranslatorInfo = NULL;
nTranslatorVersion = -246;
pDefRoster->GetTranslatorInfo(pids[i], &kTranslatorName,
&kTranslatorInfo, &nTranslatorVersion);
CPPUNIT_ASSERT(kTranslatorName);
CPPUNIT_ASSERT(kTranslatorInfo);
CPPUNIT_ASSERT(nTranslatorVersion > 0);
int32 npassed = 0;
for (int32 k = 0; k < nloaded; k++) {
if (!strcmp(kaTranslatorNames[k], kTranslatorName))
npassed++;
}
CPPUNIT_ASSERT(npassed == 1);
}
delete[] pids;
pids = NULL;
}
void
TranslatorRosterTest::GetConfigurationMessageTest()
{
NextSubTest();
BTranslatorRoster *pDefRoster = BTranslatorRoster::Default();
CPPUNIT_ASSERT(pDefRoster);
NextSubTest();
int32 num_translators = -1;
translator_id* translators = NULL;
CPPUNIT_ASSERT(pDefRoster->GetAllTranslators(&translators,
&num_translators) == B_OK);
CPPUNIT_ASSERT(translators);
CPPUNIT_ASSERT(num_translators > 0);
NextSubTest();
translator_id translatorid = translators[0];
delete[] translators;
translators = NULL;
BMessage translator_message;
CPPUNIT_ASSERT(pDefRoster->GetConfigurationMessage(-1,
&translator_message) == B_NO_TRANSLATOR);
CPPUNIT_ASSERT(translator_message.IsEmpty());
NextSubTest();
CPPUNIT_ASSERT(
pDefRoster->GetConfigurationMessage(translatorid, NULL) == B_BAD_VALUE);
NextSubTest();
CPPUNIT_ASSERT(translator_message.MakeEmpty() == B_OK);
CPPUNIT_ASSERT(pDefRoster->GetConfigurationMessage(translatorid,
&translator_message) == B_OK);
}
void
GetInputOutputFormatsTest(TranslatorRosterTest *prt, bool binput)
{
prt->NextSubTest();
BTranslatorRoster *pDefRoster = BTranslatorRoster::Default();
CPPUNIT_ASSERT(pDefRoster);
prt->NextSubTest();
translator_id* translators = NULL;
int32 num_translators = -1;
CPPUNIT_ASSERT(pDefRoster->GetAllTranslators(&translators,
&num_translators) == B_OK);
CPPUNIT_ASSERT(translators);
CPPUNIT_ASSERT(num_translators > 0);
for (int32 i = 0; i < num_translators; i++) {
const translation_format *fmts = NULL;
int32 num_fmts = -1;
status_t result;
prt->NextSubTest();
if (binput)
result = pDefRoster->GetInputFormats(translators[i], &fmts,
&num_fmts);
else
result = pDefRoster->GetOutputFormats(translators[i], &fmts,
&num_fmts);
CPPUNIT_ASSERT(result == B_OK);
CPPUNIT_ASSERT(num_fmts >= 0);
CPPUNIT_ASSERT(num_fmts == 0 || fmts);
for (int32 k = 0; k < num_fmts; k++) {
CPPUNIT_ASSERT(fmts[k].type);
CPPUNIT_ASSERT(fmts[k].group);
CPPUNIT_ASSERT(fmts[k].quality >= 0 && fmts[k].quality <= 1);
CPPUNIT_ASSERT(fmts[k].capability >= 0 && fmts[k].capability <= 1);
CPPUNIT_ASSERT(strlen(fmts[k].MIME) >= 0);
CPPUNIT_ASSERT(strlen(fmts[k].name) > 0);
}
}
delete[] translators;
translators = NULL;
}
void
TranslatorRosterTest::GetInputFormatsTest()
{
GetInputOutputFormatsTest(this, true);
}
void
TranslatorRosterTest::GetOutputFormatsTest()
{
GetInputOutputFormatsTest(this, false);
}
void
TranslatorRosterTest::GetTranslatorInfoTest()
{
NextSubTest();
translator_id* translators = NULL;
int32 num_translators = -1;
BTranslatorRoster *pDefRoster = BTranslatorRoster::Default();
CPPUNIT_ASSERT(pDefRoster);
NextSubTest();
CPPUNIT_ASSERT(pDefRoster->GetAllTranslators(&translators,
&num_translators) == B_OK);
CPPUNIT_ASSERT(translators);
CPPUNIT_ASSERT(num_translators > 0);
for (int32 i = 0; i < num_translators; i++) {
const char *outName = NULL;
const char *outInfo = NULL;
int32 outVersion = -1;
NextSubTest();
CPPUNIT_ASSERT(pDefRoster->GetTranslatorInfo(-1, &outName, &outInfo,
&outVersion) == B_NO_TRANSLATOR);
CPPUNIT_ASSERT(pDefRoster->GetTranslatorInfo(translators[i],
&outName, &outInfo, &outVersion) == B_OK);
CPPUNIT_ASSERT(outName);
}
delete[] translators;
translators = NULL;
}
void
CheckTranslatorInfo(translator_info *pinfo, int32 nitems)
{
for (int32 k = 0; k < nitems; k++) {
CPPUNIT_ASSERT(pinfo[k].translator > 0);
CPPUNIT_ASSERT(pinfo[k].type);
CPPUNIT_ASSERT(pinfo[k].group);
CPPUNIT_ASSERT(pinfo[k].quality >= 0 && pinfo[k].quality <= 1);
CPPUNIT_ASSERT(pinfo[k].capability >= 0 && pinfo[k].capability <= 1);
CPPUNIT_ASSERT(strlen(pinfo[k].MIME) >= 0);
CPPUNIT_ASSERT(strlen(pinfo[k].name) > 0);
}
}
void
TranslatorRosterTest::GetTranslatorsTest()
{
NextSubTest();
BApplication app(
"application/x-vnd.OpenBeOS-translationkit_translatorrostertest");
BFile image("resources/kits/translation/image.png",
B_READ_ONLY);
CPPUNIT_ASSERT(image.InitCheck() == B_OK);
BFile garbled("resources/kits/translation/garbled_data",
B_READ_ONLY);
CPPUNIT_ASSERT(garbled.InitCheck() == B_OK);
NextSubTest();
translator_info* pinfo = NULL;
int32 outCount = -1;
BTranslatorRoster *pDefRoster = BTranslatorRoster::Default();
CPPUNIT_ASSERT(pDefRoster);
NextSubTest();
CPPUNIT_ASSERT(pDefRoster->GetTranslators(&garbled, NULL, NULL,
&outCount) == B_BAD_VALUE);
NextSubTest();
CPPUNIT_ASSERT(pDefRoster->GetTranslators(&garbled, NULL, &pinfo,
NULL) == B_BAD_VALUE);
NextSubTest();
NextSubTest();
CPPUNIT_ASSERT(pDefRoster->GetTranslators(&image, NULL, &pinfo,
&outCount) == B_OK);
CPPUNIT_ASSERT(outCount > 0);
CheckTranslatorInfo(pinfo, outCount);
delete[] pinfo;
pinfo = NULL;
outCount = -1;
NextSubTest();
BMessage bmsg;
CPPUNIT_ASSERT(
bmsg.AddBool(B_TRANSLATOR_EXT_DATA_ONLY, true) == B_OK);
CPPUNIT_ASSERT(pDefRoster->GetTranslators(&image, &bmsg, &pinfo,
&outCount, 0, NULL, B_TRANSLATOR_BITMAP) == B_OK);
CPPUNIT_ASSERT(outCount > 0);
CheckTranslatorInfo(pinfo, outCount);
delete[] pinfo;
pinfo = NULL;
}
void
TranslatorRosterTest::IdentifyTest()
{
NextSubTest();
BApplication app(
"application/x-vnd.OpenBeOS-translationkit_translatorrostertest");
BFile image("resources/kits/translation/image.png",
B_READ_ONLY);
CPPUNIT_ASSERT(image.InitCheck() == B_OK);
BFile garbled("resources/kits/translation/garbled_data",
B_READ_ONLY);
CPPUNIT_ASSERT(garbled.InitCheck() == B_OK);
NextSubTest();
translator_info info;
memset(&info, 0, sizeof(translator_info));
BTranslatorRoster *pDefRoster = BTranslatorRoster::Default();
CPPUNIT_ASSERT(pDefRoster);
NextSubTest();
CPPUNIT_ASSERT(pDefRoster->Identify(&garbled, NULL, NULL) == B_BAD_VALUE);
NextSubTest();
NextSubTest();
memset(&info, 0, sizeof(translator_info));
CPPUNIT_ASSERT(pDefRoster->Identify(&image, NULL, &info) == B_OK);
CheckTranslatorInfo(&info, 1);
NextSubTest();
memset(&info, 0, sizeof(translator_info));
CPPUNIT_ASSERT(pDefRoster->Identify(&image, NULL, &info,
0, NULL, B_TRANSLATOR_BITMAP) == B_OK);
CheckTranslatorInfo(&info, 1);
}
void
TranslatorRosterTest::MakeConfigurationViewTest()
{
NextSubTest();
BApplication app(
"application/x-vnd.OpenBeOS-translationkit_translatorrostertest");
BRect extent(-1, -1, -1, -1);
BView *view = NULL;
translator_id *translators = NULL;
int32 num_translators = -1;
BTranslatorRoster *pDefRoster = BTranslatorRoster::Default();
CPPUNIT_ASSERT(pDefRoster);
NextSubTest();
CPPUNIT_ASSERT(
pDefRoster->GetAllTranslators(&translators, &num_translators) == B_OK);
CPPUNIT_ASSERT(translators);
CPPUNIT_ASSERT(num_translators > 0);
NextSubTest();
CPPUNIT_ASSERT(pDefRoster->MakeConfigurationView(translators[0], NULL,
&view, NULL) == B_BAD_VALUE);
CPPUNIT_ASSERT(pDefRoster->MakeConfigurationView(translators[0], NULL,
NULL, &extent) == B_BAD_VALUE);
CPPUNIT_ASSERT(pDefRoster->MakeConfigurationView(translators[0], NULL,
NULL, NULL) == B_BAD_VALUE);
NextSubTest();
CPPUNIT_ASSERT(pDefRoster->MakeConfigurationView(-1, NULL, &view,
&extent) == B_NO_TRANSLATOR);
delete[] translators;
translators = NULL;
}
void
TranslatorRosterTest::TranslateTest()
{
NextSubTest();
BApplication app(
"application/x-vnd.OpenBeOS-translationkit_translatorrostertest");
BFile input("resources/kits/translation/image.jpg",
B_READ_ONLY);
CPPUNIT_ASSERT(input.InitCheck() == B_OK);
NextSubTest();
BFile temp("/tmp/TranslatorRosterTest.temp",
B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE);
CPPUNIT_ASSERT(temp.InitCheck() == B_OK);
NextSubTest();
BFile output("resources/kits/translation/image.out.tga",
B_WRITE_ONLY | B_CREATE_FILE | B_ERASE_FILE);
CPPUNIT_ASSERT(output.InitCheck() == B_OK);
NextSubTest();
BTranslatorRoster *pDefRoster = BTranslatorRoster::Default();
CPPUNIT_ASSERT(pDefRoster != NULL);
NextSubTest();
CPPUNIT_ASSERT(pDefRoster->Translate(&input, NULL, NULL, &temp,
B_TRANSLATOR_BITMAP) == B_OK);
NextSubTest();
CPPUNIT_ASSERT(pDefRoster->Translate(&temp, NULL, NULL, &output,
B_TGA_FORMAT) == B_OK);
}
int
main()
{
TranslatorRosterTest test;
test.InitializeTest();
test.ConstructorTest();
test.DefaultTest();
test.InstantiateTest();
test.VersionTest();
test.AddTranslatorsTest();
test.ArchiveTest();
return 0;
}