moved common translator tests into TranslatorTestAddOn.cpp to reduce duplicate code
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3289 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
// TranslatorTestAddOn.cpp
|
||||
|
||||
#include <stdio.h>
|
||||
#include <Translator.h>
|
||||
#include <OS.h>
|
||||
#include "TranslatorTestAddOn.h"
|
||||
|
||||
// ##### Include headers for your tests here #####
|
||||
@@ -9,6 +11,20 @@
|
||||
#include "tgatranslator/TGATranslatorTest.h"
|
||||
#include "tifftranslator/TIFFTranslatorTest.h"
|
||||
|
||||
BTestSuite *
|
||||
getTestSuite()
|
||||
{
|
||||
BTestSuite *suite = new BTestSuite("Translators");
|
||||
|
||||
// ##### Add test suites here #####
|
||||
suite->addTest("BMPTranslator", BMPTranslatorTest::Suite());
|
||||
suite->addTest("STXTTranslator", STXTTranslatorTest::Suite());
|
||||
suite->addTest("TGATranslator", TGATranslatorTest::Suite());
|
||||
suite->addTest("TIFFTranslator", TIFFTranslatorTest::Suite());
|
||||
|
||||
return suite;
|
||||
}
|
||||
|
||||
// helper function used by multiple tests to
|
||||
// determine if the given streams are exactly
|
||||
// the same
|
||||
@@ -46,16 +62,212 @@ CompareStreams(BPositionIO &a, BPositionIO &b)
|
||||
return bresult;
|
||||
}
|
||||
|
||||
BTestSuite *
|
||||
getTestSuite()
|
||||
// Check each member of translator_info to see that it matches
|
||||
// what is expected
|
||||
void
|
||||
CheckTranslatorInfo(translator_info *pti, uint32 type, uint32 group,
|
||||
float quality, float capability, const char *name, const char *mime)
|
||||
{
|
||||
BTestSuite *suite = new BTestSuite("Translators");
|
||||
|
||||
// ##### Add test suites here #####
|
||||
suite->addTest("BMPTranslator", BMPTranslatorTest::Suite());
|
||||
suite->addTest("STXTTranslator", STXTTranslatorTest::Suite());
|
||||
suite->addTest("TGATranslator", TGATranslatorTest::Suite());
|
||||
suite->addTest("TIFFTranslator", TIFFTranslatorTest::Suite());
|
||||
|
||||
return suite;
|
||||
CPPUNIT_ASSERT(pti->type == type);
|
||||
CPPUNIT_ASSERT(pti->translator != 0);
|
||||
CPPUNIT_ASSERT(pti->group == group);
|
||||
CPPUNIT_ASSERT(pti->quality > quality - 0.01f &&
|
||||
pti->quality < quality + 0.01f);
|
||||
CPPUNIT_ASSERT(pti->capability > capability - 0.01f &&
|
||||
pti->capability < capability + 0.01f);
|
||||
CPPUNIT_ASSERT(strcmp(pti->name, name) == 0);
|
||||
CPPUNIT_ASSERT(strcmp(pti->MIME, mime) == 0);
|
||||
}
|
||||
|
||||
// Returns true if the translation_formats are
|
||||
// identical (or nearly identical). Returns false if
|
||||
// they are different
|
||||
bool
|
||||
CompareTranslationFormat(const translation_format *pleft,
|
||||
const translation_format *pright)
|
||||
{
|
||||
CPPUNIT_ASSERT(pleft->MIME);
|
||||
CPPUNIT_ASSERT(pright->MIME);
|
||||
CPPUNIT_ASSERT(pleft->name);
|
||||
CPPUNIT_ASSERT(pright->name);
|
||||
|
||||
if (pleft->group != pright->group)
|
||||
return false;
|
||||
if (pleft->type != pright->type)
|
||||
return false;
|
||||
if (pleft->quality < pright->quality - 0.01f ||
|
||||
pleft->quality > pright->quality + 0.01f)
|
||||
return false;
|
||||
if (pleft->capability < pright->capability - 0.01f ||
|
||||
pleft->capability > pright->capability + 0.01f)
|
||||
return false;
|
||||
if (strcmp(pleft->MIME, pright->MIME) != 0)
|
||||
return false;
|
||||
if (strcmp(pleft->name, pright->name) != 0)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Apply a number of tests to a BTranslator * to a TGATranslator object
|
||||
void
|
||||
TestBTranslator(BTestCase *ptest, BTranslator *ptran,
|
||||
const translation_format *pExpectedIns, uint32 nExpectedIns,
|
||||
const translation_format *pExpectedOuts, uint32 nExpectedOuts)
|
||||
{
|
||||
const uint32 knmatches = 50;
|
||||
uint8 matches[knmatches];
|
||||
CPPUNIT_ASSERT(nExpectedIns <= knmatches && nExpectedOuts <= knmatches);
|
||||
|
||||
// The translator should only have one reference
|
||||
ptest->NextSubTest();
|
||||
CPPUNIT_ASSERT(ptran->ReferenceCount() == 1);
|
||||
|
||||
// Make sure Acquire returns a BTranslator even though its
|
||||
// already been Acquired once
|
||||
ptest->NextSubTest();
|
||||
CPPUNIT_ASSERT(ptran->Acquire() == ptran);
|
||||
|
||||
// Acquired twice, refcount should be 2
|
||||
ptest->NextSubTest();
|
||||
CPPUNIT_ASSERT(ptran->ReferenceCount() == 2);
|
||||
|
||||
// Release should return ptran because it is still acquired
|
||||
ptest->NextSubTest();
|
||||
CPPUNIT_ASSERT(ptran->Release() == ptran);
|
||||
|
||||
ptest->NextSubTest();
|
||||
CPPUNIT_ASSERT(ptran->ReferenceCount() == 1);
|
||||
|
||||
ptest->NextSubTest();
|
||||
CPPUNIT_ASSERT(ptran->Acquire() == ptran);
|
||||
|
||||
ptest->NextSubTest();
|
||||
CPPUNIT_ASSERT(ptran->ReferenceCount() == 2);
|
||||
|
||||
ptest->NextSubTest();
|
||||
CPPUNIT_ASSERT(ptran->Release() == ptran);
|
||||
|
||||
ptest->NextSubTest();
|
||||
CPPUNIT_ASSERT(ptran->ReferenceCount() == 1);
|
||||
|
||||
// A name would be nice
|
||||
ptest->NextSubTest();
|
||||
const char *tranname = ptran->TranslatorName();
|
||||
CPPUNIT_ASSERT(tranname);
|
||||
printf(" {%s} ", tranname);
|
||||
|
||||
// More info would be nice
|
||||
ptest->NextSubTest();
|
||||
const char *traninfo = ptran->TranslatorInfo();
|
||||
CPPUNIT_ASSERT(traninfo);
|
||||
printf(" {%s} ", traninfo);
|
||||
|
||||
// What version are you?
|
||||
// (when ver == 100, that means that version is 1.00)
|
||||
ptest->NextSubTest();
|
||||
int32 ver = ptran->TranslatorVersion();
|
||||
CPPUNIT_ASSERT((ver / 100) > 0);
|
||||
printf(" {%d} ", (int) ver);
|
||||
|
||||
// Input formats?
|
||||
ptest->NextSubTest();
|
||||
{
|
||||
printf("input:");
|
||||
|
||||
int32 incount = 0;
|
||||
const translation_format *pins = ptran->InputFormats(&incount);
|
||||
CPPUNIT_ASSERT(incount == nExpectedIns);
|
||||
CPPUNIT_ASSERT(pins);
|
||||
|
||||
memset(matches, 0, sizeof(uint8) * nExpectedIns);
|
||||
for (int32 i = 0; i < incount; i++) {
|
||||
bool bmatch = false;
|
||||
for (int32 k = 0; bmatch == false && k < nExpectedIns; k++) {
|
||||
bmatch = CompareTranslationFormat(pins + i, pExpectedIns + k);
|
||||
if (bmatch)
|
||||
matches[k] = 1;
|
||||
}
|
||||
|
||||
CPPUNIT_ASSERT(bmatch);
|
||||
}
|
||||
|
||||
// make sure that each expected input format was matched
|
||||
for (uint32 i = 0; i < nExpectedIns; i++)
|
||||
CPPUNIT_ASSERT(matches[i]);
|
||||
}
|
||||
|
||||
// Output formats?
|
||||
ptest->NextSubTest();
|
||||
{
|
||||
printf("output:");
|
||||
|
||||
int32 outcount = 0;
|
||||
const translation_format *pouts = ptran->OutputFormats(&outcount);
|
||||
CPPUNIT_ASSERT(outcount == nExpectedOuts);
|
||||
CPPUNIT_ASSERT(pouts);
|
||||
|
||||
memset(matches, 0, sizeof(uint8) * nExpectedOuts);
|
||||
for (int32 i = 0; i < outcount; i++) {
|
||||
bool bmatch = false;
|
||||
for (int32 k = 0; bmatch == false && k < nExpectedOuts; k++) {
|
||||
bmatch = CompareTranslationFormat(pouts + i, pExpectedOuts + k);
|
||||
if (bmatch)
|
||||
matches[k] = 1;
|
||||
}
|
||||
|
||||
CPPUNIT_ASSERT(bmatch);
|
||||
}
|
||||
|
||||
// make sure that each expected input format was matched
|
||||
for (uint32 i = 0; i < nExpectedOuts; i++)
|
||||
CPPUNIT_ASSERT(matches[i]);
|
||||
}
|
||||
|
||||
// Release should return NULL because Release has been called
|
||||
// as many times as it has been acquired
|
||||
ptest->NextSubTest();
|
||||
CPPUNIT_ASSERT(ptran->Release() == NULL);
|
||||
ptran = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
TranslatorLoadAddOnTest(const char *path, BTestCase *ptest,
|
||||
const translation_format *pExpectedIns, uint32 nExpectedIns,
|
||||
const translation_format *pExpectedOuts, uint32 nExpectedOuts)
|
||||
{
|
||||
// Make sure the add_on loads
|
||||
ptest->NextSubTest();
|
||||
image_id image = load_add_on(path);
|
||||
CPPUNIT_ASSERT(image >= 0);
|
||||
|
||||
// Load in function to make the object
|
||||
ptest->NextSubTest();
|
||||
BTranslator *(*pMakeNthTranslator)(int32 n,image_id you,uint32 flags,...);
|
||||
status_t err = get_image_symbol(image, "make_nth_translator",
|
||||
B_SYMBOL_TYPE_TEXT, (void **)&pMakeNthTranslator);
|
||||
CPPUNIT_ASSERT(!err);
|
||||
|
||||
// Make sure the function returns a pointer to a BTranslator
|
||||
ptest->NextSubTest();
|
||||
BTranslator *ptran = pMakeNthTranslator(0, image, 0);
|
||||
CPPUNIT_ASSERT(ptran);
|
||||
|
||||
// Make sure the function only returns one BTranslator
|
||||
ptest->NextSubTest();
|
||||
CPPUNIT_ASSERT(!pMakeNthTranslator(1, image, 0));
|
||||
CPPUNIT_ASSERT(!pMakeNthTranslator(2, image, 0));
|
||||
CPPUNIT_ASSERT(!pMakeNthTranslator(3, image, 0));
|
||||
CPPUNIT_ASSERT(!pMakeNthTranslator(16, image, 0));
|
||||
CPPUNIT_ASSERT(!pMakeNthTranslator(1023, image, 0));
|
||||
|
||||
// Run a number of tests on the BTranslator object
|
||||
TestBTranslator(ptest, ptran, pExpectedIns, nExpectedIns,
|
||||
pExpectedOuts, nExpectedOuts);
|
||||
// NOTE: this function Release()s ptran
|
||||
ptran = NULL;
|
||||
|
||||
// Unload Add-on
|
||||
ptest->NextSubTest();
|
||||
CPPUNIT_ASSERT(unload_add_on(image) == B_OK);
|
||||
}
|
||||
|
||||
@@ -3,10 +3,20 @@
|
||||
#ifndef TRANSLATOR_TEST_ADD_ON_H
|
||||
#define TRANSLATOR_TEST_ADD_ON_H
|
||||
|
||||
#include <TestCase.h>
|
||||
#include <TestSuite.h>
|
||||
#include <TestSuiteAddon.h>
|
||||
#include <DataIO.h>
|
||||
#include <TranslationDefs.h>
|
||||
|
||||
bool CompareStreams(BPositionIO &a, BPositionIO &b);
|
||||
|
||||
void CheckTranslatorInfo(translator_info *pti,
|
||||
uint32 type, uint32 group, float quality, float capability,
|
||||
const char *name, const char *mime);
|
||||
|
||||
void TranslatorLoadAddOnTest(const char *path, BTestCase *ptest,
|
||||
const translation_format *pExpectedIns, uint32 nExpectedIns,
|
||||
const translation_format *pExpectedOuts, uint32 nExpectedOuts);
|
||||
|
||||
#endif // #ifndef TRANSLATOR_TEST_ADD_ON_H
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
#include <DataIO.h>
|
||||
#include <Errors.h>
|
||||
#include <OS.h>
|
||||
#include "../../../../add-ons/translators/stxttranslator/STXTTranslator.h"
|
||||
#include "TranslatorTestAddOn.h"
|
||||
|
||||
// Suite
|
||||
@@ -61,25 +60,15 @@ STXTTranslatorTest::tearDown()
|
||||
void
|
||||
CheckStyled(translator_info *pti)
|
||||
{
|
||||
CPPUNIT_ASSERT(pti->type == B_STYLED_TEXT_FORMAT);
|
||||
CPPUNIT_ASSERT(pti->translator != 0);
|
||||
CPPUNIT_ASSERT(pti->group == B_TRANSLATOR_TEXT);
|
||||
CPPUNIT_ASSERT(pti->quality == 0.5);
|
||||
CPPUNIT_ASSERT(pti->capability == 0.5);
|
||||
CPPUNIT_ASSERT(strcmp(pti->name, "Be styled text file") == 0);
|
||||
CPPUNIT_ASSERT(strcmp(pti->MIME, "text/x-vnd.Be-stxt") == 0);
|
||||
CheckTranslatorInfo(pti, B_STYLED_TEXT_FORMAT, B_TRANSLATOR_TEXT,
|
||||
0.5f, 0.5f, "Be styled text file", "text/x-vnd.Be-stxt");
|
||||
}
|
||||
|
||||
void
|
||||
CheckPlain(translator_info *pti)
|
||||
{
|
||||
CPPUNIT_ASSERT(pti->type == B_TRANSLATOR_TEXT);
|
||||
CPPUNIT_ASSERT(pti->translator != 0);
|
||||
CPPUNIT_ASSERT(pti->group == B_TRANSLATOR_TEXT);
|
||||
CPPUNIT_ASSERT(pti->quality > 0.39 && pti->quality < 0.41);
|
||||
CPPUNIT_ASSERT(pti->capability > 0.59 && pti->capability < 0.61);
|
||||
CPPUNIT_ASSERT(strcmp(pti->name, "Plain text file") == 0);
|
||||
CPPUNIT_ASSERT(strcmp(pti->MIME, "text/plain") == 0);
|
||||
CheckTranslatorInfo(pti, B_TRANSLATOR_TEXT, B_TRANSLATOR_TEXT,
|
||||
0.4f, 0.6f, "Plain text file", "text/plain");
|
||||
}
|
||||
|
||||
void
|
||||
@@ -378,154 +367,55 @@ STXTTranslatorTest::TranslateTest()
|
||||
sizeof(aStyledTextFiles) / sizeof(const char *), false);
|
||||
}
|
||||
|
||||
void
|
||||
TestBTranslator(STXTTranslatorTest *ptest, BTranslator *ptran)
|
||||
{
|
||||
// . The translator should only have one reference
|
||||
ptest->NextSubTest();
|
||||
CPPUNIT_ASSERT(ptran->ReferenceCount() == 1);
|
||||
|
||||
// . Make sure Acquire returns a BTranslator even though its
|
||||
// already been Acquired once
|
||||
ptest->NextSubTest();
|
||||
CPPUNIT_ASSERT(ptran->Acquire() == ptran);
|
||||
|
||||
// . Acquired twice, refcount should be 2
|
||||
ptest->NextSubTest();
|
||||
CPPUNIT_ASSERT(ptran->ReferenceCount() == 2);
|
||||
|
||||
// . Release should return ptran because it is still acquired
|
||||
ptest->NextSubTest();
|
||||
CPPUNIT_ASSERT(ptran->Release() == ptran);
|
||||
|
||||
ptest->NextSubTest();
|
||||
CPPUNIT_ASSERT(ptran->ReferenceCount() == 1);
|
||||
|
||||
ptest->NextSubTest();
|
||||
CPPUNIT_ASSERT(ptran->Acquire() == ptran);
|
||||
|
||||
ptest->NextSubTest();
|
||||
CPPUNIT_ASSERT(ptran->ReferenceCount() == 2);
|
||||
|
||||
ptest->NextSubTest();
|
||||
CPPUNIT_ASSERT(ptran->Release() == ptran);
|
||||
|
||||
ptest->NextSubTest();
|
||||
CPPUNIT_ASSERT(ptran->ReferenceCount() == 1);
|
||||
|
||||
// . A name would be nice
|
||||
ptest->NextSubTest();
|
||||
const char *tranname = ptran->TranslatorName();
|
||||
CPPUNIT_ASSERT(tranname);
|
||||
printf(" {%s} ", tranname);
|
||||
|
||||
// . More info would be nice
|
||||
ptest->NextSubTest();
|
||||
const char *traninfo = ptran->TranslatorInfo();
|
||||
CPPUNIT_ASSERT(traninfo);
|
||||
printf(" {%s} ", traninfo);
|
||||
|
||||
// . What version are you?
|
||||
// (when ver == 100, that means that version is 1.00)
|
||||
ptest->NextSubTest();
|
||||
int32 ver = ptran->TranslatorVersion();
|
||||
CPPUNIT_ASSERT((ver / 100) > 0);
|
||||
printf(" {%d} ", (int) ver);
|
||||
|
||||
// . Input formats?
|
||||
ptest->NextSubTest();
|
||||
{
|
||||
int32 incount = 0;
|
||||
const translation_format *pins = ptran->InputFormats(&incount);
|
||||
CPPUNIT_ASSERT(incount == 2);
|
||||
CPPUNIT_ASSERT(pins);
|
||||
// . must support STXT and TEXT formats
|
||||
for (int32 i = 0; i < incount; i++) {
|
||||
CPPUNIT_ASSERT(pins[i].group == B_TRANSLATOR_TEXT);
|
||||
CPPUNIT_ASSERT(pins[i].quality > 0 && pins[i].quality <= 1);
|
||||
CPPUNIT_ASSERT(pins[i].capability > 0 && pins[i].capability <= 1);
|
||||
CPPUNIT_ASSERT(pins[i].MIME);
|
||||
CPPUNIT_ASSERT(pins[i].name);
|
||||
|
||||
if (pins[i].type == B_TRANSLATOR_TEXT) {
|
||||
CPPUNIT_ASSERT(strcmp(pins[i].MIME, TEXT_MIME_STRING) == 0);
|
||||
CPPUNIT_ASSERT(strcmp(pins[i].name,
|
||||
"Plain text file") == 0);
|
||||
} else if (pins[i].type == B_STYLED_TEXT_FORMAT) {
|
||||
CPPUNIT_ASSERT(strcmp(pins[i].MIME, STXT_MIME_STRING) == 0);
|
||||
CPPUNIT_ASSERT(strcmp(pins[i].name, "Be styled text file") == 0);
|
||||
} else
|
||||
CPPUNIT_ASSERT(false);
|
||||
}
|
||||
}
|
||||
|
||||
// . Output formats?
|
||||
ptest->NextSubTest();
|
||||
{
|
||||
int32 outcount = 0;
|
||||
const translation_format *pouts = ptran->OutputFormats(&outcount);
|
||||
CPPUNIT_ASSERT(outcount == 2);
|
||||
CPPUNIT_ASSERT(pouts);
|
||||
// . must support STXT and TEXT formats
|
||||
for (int32 i = 0; i < outcount; i++) {
|
||||
CPPUNIT_ASSERT(pouts[i].group == B_TRANSLATOR_TEXT);
|
||||
CPPUNIT_ASSERT(pouts[i].quality > 0 && pouts[i].quality <= 1);
|
||||
CPPUNIT_ASSERT(pouts[i].capability > 0 && pouts[i].capability <= 1);
|
||||
CPPUNIT_ASSERT(pouts[i].MIME);
|
||||
CPPUNIT_ASSERT(pouts[i].name);
|
||||
|
||||
if (pouts[i].type == B_TRANSLATOR_TEXT) {
|
||||
CPPUNIT_ASSERT(strcmp(pouts[i].MIME, TEXT_MIME_STRING) == 0);
|
||||
CPPUNIT_ASSERT(strcmp(pouts[i].name,
|
||||
"Plain text file") == 0);
|
||||
} else if (pouts[i].type == B_STYLED_TEXT_FORMAT) {
|
||||
CPPUNIT_ASSERT(strcmp(pouts[i].MIME, STXT_MIME_STRING) == 0);
|
||||
CPPUNIT_ASSERT(strcmp(pouts[i].name, "Be styled text file") == 0);
|
||||
} else
|
||||
CPPUNIT_ASSERT(false);
|
||||
}
|
||||
}
|
||||
|
||||
// . Release should return NULL because Release has been called
|
||||
// as many times as it has been acquired
|
||||
ptest->NextSubTest();
|
||||
CPPUNIT_ASSERT(ptran->Release() == NULL);
|
||||
}
|
||||
|
||||
#if !TEST_R5
|
||||
|
||||
// The input formats that this translator is supposed to support
|
||||
translation_format gSTXTInputFormats[] = {
|
||||
{
|
||||
B_TRANSLATOR_TEXT,
|
||||
B_TRANSLATOR_TEXT,
|
||||
0.4f, // quality
|
||||
0.6f, // capability
|
||||
"text/plain",
|
||||
"Plain text file"
|
||||
},
|
||||
{
|
||||
B_STYLED_TEXT_FORMAT,
|
||||
B_TRANSLATOR_TEXT,
|
||||
0.5f,
|
||||
0.5f,
|
||||
"text/x-vnd.Be-stxt",
|
||||
"Be styled text file"
|
||||
}
|
||||
};
|
||||
|
||||
// The output formats that this translator is supposed to support
|
||||
translation_format gSTXTOutputFormats[] = {
|
||||
{
|
||||
B_TRANSLATOR_TEXT,
|
||||
B_TRANSLATOR_TEXT,
|
||||
0.4f, // quality
|
||||
0.6f, // capability
|
||||
"text/plain",
|
||||
"Plain text file"
|
||||
},
|
||||
{
|
||||
B_STYLED_TEXT_FORMAT,
|
||||
B_TRANSLATOR_TEXT,
|
||||
0.5f,
|
||||
0.5f,
|
||||
"text/x-vnd.Be-stxt",
|
||||
"Be styled text file"
|
||||
}
|
||||
};
|
||||
|
||||
void
|
||||
STXTTranslatorTest::LoadAddOnTest()
|
||||
{
|
||||
// . Make sure the add_on loads
|
||||
NextSubTest();
|
||||
const char *path = "/boot/home/config/add-ons/Translators/STXTTranslator";
|
||||
image_id image = load_add_on(path);
|
||||
CPPUNIT_ASSERT(image >= 0);
|
||||
|
||||
// . Load in function to make the object
|
||||
NextSubTest();
|
||||
BTranslator *(*pMakeNthTranslator)(int32 n,image_id you,uint32 flags,...);
|
||||
status_t err = get_image_symbol(image, "make_nth_translator",
|
||||
B_SYMBOL_TYPE_TEXT, (void **)&pMakeNthTranslator);
|
||||
CPPUNIT_ASSERT(!err);
|
||||
|
||||
// . Make sure the function returns a pointer to a BTranslator
|
||||
NextSubTest();
|
||||
BTranslator *ptran = pMakeNthTranslator(0, image, 0);
|
||||
CPPUNIT_ASSERT(ptran);
|
||||
|
||||
// . Make sure the function only returns one BTranslator
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT(!pMakeNthTranslator(1, image, 0));
|
||||
|
||||
// Run a number of tests on the BTranslator object
|
||||
TestBTranslator(this, ptran);
|
||||
// NOTE: this function Release()s ptran
|
||||
|
||||
// . Unload Add-on
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT(unload_add_on(image) == B_OK);
|
||||
TranslatorLoadAddOnTest("/boot/home/config/add-ons/Translators/STXTTranslator",
|
||||
this,
|
||||
gSTXTInputFormats, sizeof(gSTXTInputFormats) / sizeof(translation_format),
|
||||
gSTXTOutputFormats, sizeof(gSTXTOutputFormats) / sizeof(translation_format));
|
||||
}
|
||||
|
||||
#endif // #if !TEST_R5
|
||||
|
||||
@@ -60,25 +60,16 @@ TGATranslatorTest::tearDown()
|
||||
void
|
||||
CheckBits_Tga(translator_info *pti)
|
||||
{
|
||||
CPPUNIT_ASSERT(pti->type == B_TRANSLATOR_BITMAP);
|
||||
CPPUNIT_ASSERT(pti->translator != 0);
|
||||
CPPUNIT_ASSERT(pti->group == B_TRANSLATOR_BITMAP);
|
||||
CPPUNIT_ASSERT(pti->quality > 0.59 && pti->quality < 0.61);
|
||||
CPPUNIT_ASSERT(pti->capability > 0.79 && pti->capability < 0.81);
|
||||
CPPUNIT_ASSERT(strcmp(pti->name, "Be Bitmap Format (TGATranslator)") == 0);
|
||||
CPPUNIT_ASSERT(strcmp(pti->MIME, "image/x-be-bitmap") == 0);
|
||||
CheckTranslatorInfo(pti, B_TRANSLATOR_BITMAP, B_TRANSLATOR_BITMAP,
|
||||
0.6f, 0.8f, "Be Bitmap Format (TGATranslator)",
|
||||
"image/x-be-bitmap");
|
||||
}
|
||||
|
||||
void
|
||||
CheckTga(translator_info *pti, const char *imageType)
|
||||
{
|
||||
CPPUNIT_ASSERT(pti->type == B_TGA_FORMAT);
|
||||
CPPUNIT_ASSERT(pti->translator != 0);
|
||||
CPPUNIT_ASSERT(pti->group == B_TRANSLATOR_BITMAP);
|
||||
CPPUNIT_ASSERT(pti->quality > 0.99 && pti->quality < 1.01);
|
||||
CPPUNIT_ASSERT(pti->capability > 0.59 && pti->capability < 0.61);
|
||||
CPPUNIT_ASSERT(strcmp(pti->name, imageType) == 0);
|
||||
CPPUNIT_ASSERT(strcmp(pti->MIME, "image/x-targa") == 0);
|
||||
CheckTranslatorInfo(pti, B_TGA_FORMAT, B_TRANSLATOR_BITMAP,
|
||||
1.0f, 0.6f, imageType, "image/x-targa");
|
||||
}
|
||||
|
||||
// coveniently group path of image with
|
||||
@@ -408,165 +399,55 @@ TGATranslatorTest::TranslateTest()
|
||||
proster = NULL;
|
||||
}
|
||||
|
||||
// Apply a number of tests to a BTranslator * to a TGATranslator object
|
||||
void
|
||||
TestBTranslator(TGATranslatorTest *ptest, BTranslator *ptran)
|
||||
{
|
||||
// The translator should only have one reference
|
||||
ptest->NextSubTest();
|
||||
CPPUNIT_ASSERT(ptran->ReferenceCount() == 1);
|
||||
|
||||
// Make sure Acquire returns a BTranslator even though its
|
||||
// already been Acquired once
|
||||
ptest->NextSubTest();
|
||||
CPPUNIT_ASSERT(ptran->Acquire() == ptran);
|
||||
|
||||
// Acquired twice, refcount should be 2
|
||||
ptest->NextSubTest();
|
||||
CPPUNIT_ASSERT(ptran->ReferenceCount() == 2);
|
||||
|
||||
// Release should return ptran because it is still acquired
|
||||
ptest->NextSubTest();
|
||||
CPPUNIT_ASSERT(ptran->Release() == ptran);
|
||||
|
||||
ptest->NextSubTest();
|
||||
CPPUNIT_ASSERT(ptran->ReferenceCount() == 1);
|
||||
|
||||
ptest->NextSubTest();
|
||||
CPPUNIT_ASSERT(ptran->Acquire() == ptran);
|
||||
|
||||
ptest->NextSubTest();
|
||||
CPPUNIT_ASSERT(ptran->ReferenceCount() == 2);
|
||||
|
||||
ptest->NextSubTest();
|
||||
CPPUNIT_ASSERT(ptran->Release() == ptran);
|
||||
|
||||
ptest->NextSubTest();
|
||||
CPPUNIT_ASSERT(ptran->ReferenceCount() == 1);
|
||||
|
||||
// A name would be nice
|
||||
ptest->NextSubTest();
|
||||
const char *tranname = ptran->TranslatorName();
|
||||
CPPUNIT_ASSERT(tranname);
|
||||
printf(" {%s} ", tranname);
|
||||
|
||||
// More info would be nice
|
||||
ptest->NextSubTest();
|
||||
const char *traninfo = ptran->TranslatorInfo();
|
||||
CPPUNIT_ASSERT(traninfo);
|
||||
printf(" {%s} ", traninfo);
|
||||
|
||||
// What version are you?
|
||||
// (when ver == 100, that means that version is 1.00)
|
||||
ptest->NextSubTest();
|
||||
int32 ver = ptran->TranslatorVersion();
|
||||
CPPUNIT_ASSERT((ver / 100) > 0);
|
||||
printf(" {%d} ", (int) ver);
|
||||
|
||||
// Input formats?
|
||||
ptest->NextSubTest();
|
||||
{
|
||||
int32 incount = 0;
|
||||
const translation_format *pins = ptran->InputFormats(&incount);
|
||||
CPPUNIT_ASSERT(incount == 2);
|
||||
CPPUNIT_ASSERT(pins);
|
||||
// must support B_TGA_FORMAT and B_TRANSLATOR_BITMAP formats
|
||||
for (int32 i = 0; i < incount; i++) {
|
||||
CPPUNIT_ASSERT(pins[i].group == B_TRANSLATOR_BITMAP);
|
||||
CPPUNIT_ASSERT(pins[i].MIME);
|
||||
CPPUNIT_ASSERT(pins[i].name);
|
||||
|
||||
if (pins[i].type == B_TRANSLATOR_BITMAP) {
|
||||
CPPUNIT_ASSERT(pins[i].quality > 0.59 && pins[i].quality < 0.61);
|
||||
CPPUNIT_ASSERT(pins[i].capability > 0.79 && pins[i].capability < 0.81);
|
||||
CPPUNIT_ASSERT(strcmp(pins[i].MIME, BBT_MIME_STRING) == 0);
|
||||
CPPUNIT_ASSERT(strcmp(pins[i].name,
|
||||
"Be Bitmap Format (TGATranslator)") == 0);
|
||||
} else if (pins[i].type == B_TGA_FORMAT) {
|
||||
CPPUNIT_ASSERT(pins[i].quality > 0.99 && pins[i].quality < 1.01);
|
||||
CPPUNIT_ASSERT(pins[i].capability > 0.59 && pins[i].capability < 0.61);
|
||||
CPPUNIT_ASSERT(strcmp(pins[i].MIME, TGA_MIME_STRING) == 0);
|
||||
CPPUNIT_ASSERT(strcmp(pins[i].name, "Targa image") == 0);
|
||||
} else
|
||||
CPPUNIT_ASSERT(false);
|
||||
}
|
||||
}
|
||||
|
||||
// Output formats?
|
||||
ptest->NextSubTest();
|
||||
{
|
||||
int32 outcount = 0;
|
||||
const translation_format *pouts = ptran->OutputFormats(&outcount);
|
||||
CPPUNIT_ASSERT(outcount == 2);
|
||||
CPPUNIT_ASSERT(pouts);
|
||||
// must support B_TGA_FORMAT and B_TRANSLATOR_BITMAP formats
|
||||
for (int32 i = 0; i < outcount; i++) {
|
||||
CPPUNIT_ASSERT(pouts[i].group == B_TRANSLATOR_BITMAP);
|
||||
CPPUNIT_ASSERT(pouts[i].MIME);
|
||||
CPPUNIT_ASSERT(pouts[i].name);
|
||||
|
||||
if (pouts[i].type == B_TRANSLATOR_BITMAP) {
|
||||
CPPUNIT_ASSERT(pouts[i].quality > 0.59 && pouts[i].quality < 0.61);
|
||||
CPPUNIT_ASSERT(pouts[i].capability > 0.79 && pouts[i].capability < 0.81);
|
||||
CPPUNIT_ASSERT(strcmp(pouts[i].MIME, BBT_MIME_STRING) == 0);
|
||||
CPPUNIT_ASSERT(strcmp(pouts[i].name,
|
||||
"Be Bitmap Format (TGATranslator)") == 0);
|
||||
} else if (pouts[i].type == B_TGA_FORMAT) {
|
||||
CPPUNIT_ASSERT(pouts[i].quality > 0.99 && pouts[i].quality < 1.01);
|
||||
CPPUNIT_ASSERT(pouts[i].capability > 0.69 && pouts[i].capability < 0.71);
|
||||
CPPUNIT_ASSERT(strcmp(pouts[i].MIME, TGA_MIME_STRING) == 0);
|
||||
CPPUNIT_ASSERT(strcmp(pouts[i].name, "Targa image") == 0);
|
||||
} else
|
||||
CPPUNIT_ASSERT(false);
|
||||
}
|
||||
}
|
||||
|
||||
// Release should return NULL because Release has been called
|
||||
// as many times as it has been acquired
|
||||
ptest->NextSubTest();
|
||||
CPPUNIT_ASSERT(ptran->Release() == NULL);
|
||||
ptran = NULL;
|
||||
}
|
||||
|
||||
#if !TEST_R5
|
||||
|
||||
// The input formats that this translator is supposed to support
|
||||
translation_format gTGAInputFormats[] = {
|
||||
{
|
||||
B_TRANSLATOR_BITMAP,
|
||||
B_TRANSLATOR_BITMAP,
|
||||
0.6f, // quality
|
||||
0.8f, // capability
|
||||
"image/x-be-bitmap",
|
||||
"Be Bitmap Format (TGATranslator)"
|
||||
},
|
||||
{
|
||||
B_TGA_FORMAT,
|
||||
B_TRANSLATOR_BITMAP,
|
||||
1.0f,
|
||||
0.6f,
|
||||
"image/x-targa",
|
||||
"Targa image"
|
||||
}
|
||||
};
|
||||
|
||||
// The output formats that this translator is supposed to support
|
||||
translation_format gTGAOutputFormats[] = {
|
||||
{
|
||||
B_TRANSLATOR_BITMAP,
|
||||
B_TRANSLATOR_BITMAP,
|
||||
0.6f, // quality
|
||||
0.8f, // capability
|
||||
"image/x-be-bitmap",
|
||||
"Be Bitmap Format (TGATranslator)"
|
||||
},
|
||||
{
|
||||
B_TGA_FORMAT,
|
||||
B_TRANSLATOR_BITMAP,
|
||||
1.0f,
|
||||
0.7f,
|
||||
"image/x-targa",
|
||||
"Targa image"
|
||||
}
|
||||
};
|
||||
|
||||
void
|
||||
TGATranslatorTest::LoadAddOnTest()
|
||||
{
|
||||
// Make sure the add_on loads
|
||||
NextSubTest();
|
||||
const char *path = "/boot/home/config/add-ons/Translators/TGATranslator";
|
||||
image_id image = load_add_on(path);
|
||||
CPPUNIT_ASSERT(image >= 0);
|
||||
|
||||
// Load in function to make the object
|
||||
NextSubTest();
|
||||
BTranslator *(*pMakeNthTranslator)(int32 n,image_id you,uint32 flags,...);
|
||||
status_t err = get_image_symbol(image, "make_nth_translator",
|
||||
B_SYMBOL_TYPE_TEXT, (void **)&pMakeNthTranslator);
|
||||
CPPUNIT_ASSERT(!err);
|
||||
|
||||
// Make sure the function returns a pointer to a BTranslator
|
||||
NextSubTest();
|
||||
BTranslator *ptran = pMakeNthTranslator(0, image, 0);
|
||||
CPPUNIT_ASSERT(ptran);
|
||||
|
||||
// Make sure the function only returns one BTranslator
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT(!pMakeNthTranslator(1, image, 0));
|
||||
CPPUNIT_ASSERT(!pMakeNthTranslator(2, image, 0));
|
||||
CPPUNIT_ASSERT(!pMakeNthTranslator(3, image, 0));
|
||||
CPPUNIT_ASSERT(!pMakeNthTranslator(16, image, 0));
|
||||
CPPUNIT_ASSERT(!pMakeNthTranslator(1023, image, 0));
|
||||
|
||||
// Run a number of tests on the BTranslator object
|
||||
TestBTranslator(this, ptran);
|
||||
// NOTE: this function Release()s ptran
|
||||
ptran = NULL;
|
||||
|
||||
// Unload Add-on
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT(unload_add_on(image) == B_OK);
|
||||
TranslatorLoadAddOnTest("/boot/home/config/add-ons/Translators/TGATranslator",
|
||||
this,
|
||||
gTGAInputFormats, sizeof(gTGAInputFormats) / sizeof(translation_format),
|
||||
gTGAOutputFormats, sizeof(gTGAOutputFormats) / sizeof(translation_format));
|
||||
}
|
||||
|
||||
#endif // #if !TEST_R5
|
||||
|
||||
@@ -60,25 +60,16 @@ TIFFTranslatorTest::tearDown()
|
||||
void
|
||||
CheckBits_Tiff(translator_info *pti)
|
||||
{
|
||||
CPPUNIT_ASSERT(pti->type == B_TRANSLATOR_BITMAP);
|
||||
CPPUNIT_ASSERT(pti->translator != 0);
|
||||
CPPUNIT_ASSERT(pti->group == B_TRANSLATOR_BITMAP);
|
||||
CPPUNIT_ASSERT(pti->quality > 0.39 && pti->quality < 0.41);
|
||||
CPPUNIT_ASSERT(pti->capability > 0.59 && pti->capability < 0.61);
|
||||
CPPUNIT_ASSERT(strcmp(pti->name, "Be Bitmap Format (TIFFTranslator)") == 0);
|
||||
CPPUNIT_ASSERT(strcmp(pti->MIME, "image/x-be-bitmap") == 0);
|
||||
CheckTranslatorInfo(pti, B_TRANSLATOR_BITMAP, B_TRANSLATOR_BITMAP,
|
||||
0.4f, 0.6f, "Be Bitmap Format (TIFFTranslator)",
|
||||
"image/x-be-bitmap");
|
||||
}
|
||||
|
||||
void
|
||||
CheckTiff(translator_info *pti, const char *imageType)
|
||||
{
|
||||
CPPUNIT_ASSERT(pti->type == B_TIFF_FORMAT);
|
||||
CPPUNIT_ASSERT(pti->translator != 0);
|
||||
CPPUNIT_ASSERT(pti->group == B_TRANSLATOR_BITMAP);
|
||||
CPPUNIT_ASSERT(pti->quality > 0.09 && pti->quality < 0.11);
|
||||
CPPUNIT_ASSERT(pti->capability > 0.09 && pti->capability < 0.11);
|
||||
CPPUNIT_ASSERT(strcmp(pti->name, imageType) == 0);
|
||||
CPPUNIT_ASSERT(strcmp(pti->MIME, "image/tiff") == 0);
|
||||
CheckTranslatorInfo(pti, B_TIFF_FORMAT, B_TRANSLATOR_BITMAP,
|
||||
0.1f, 0.1f, imageType, "image/tiff");
|
||||
}
|
||||
|
||||
// coveniently group path of image with
|
||||
@@ -424,165 +415,55 @@ TIFFTranslatorTest::TranslateTest()
|
||||
proster = NULL;
|
||||
}
|
||||
|
||||
// Apply a number of tests to a BTranslator * to a TIFFTranslator object
|
||||
void
|
||||
TestBTranslator(TIFFTranslatorTest *ptest, BTranslator *ptran)
|
||||
{
|
||||
// The translator should only have one reference
|
||||
ptest->NextSubTest();
|
||||
CPPUNIT_ASSERT(ptran->ReferenceCount() == 1);
|
||||
|
||||
// Make sure Acquire returns a BTranslator even though its
|
||||
// already been Acquired once
|
||||
ptest->NextSubTest();
|
||||
CPPUNIT_ASSERT(ptran->Acquire() == ptran);
|
||||
|
||||
// Acquired twice, refcount should be 2
|
||||
ptest->NextSubTest();
|
||||
CPPUNIT_ASSERT(ptran->ReferenceCount() == 2);
|
||||
|
||||
// Release should return ptran because it is still acquired
|
||||
ptest->NextSubTest();
|
||||
CPPUNIT_ASSERT(ptran->Release() == ptran);
|
||||
|
||||
ptest->NextSubTest();
|
||||
CPPUNIT_ASSERT(ptran->ReferenceCount() == 1);
|
||||
|
||||
ptest->NextSubTest();
|
||||
CPPUNIT_ASSERT(ptran->Acquire() == ptran);
|
||||
|
||||
ptest->NextSubTest();
|
||||
CPPUNIT_ASSERT(ptran->ReferenceCount() == 2);
|
||||
|
||||
ptest->NextSubTest();
|
||||
CPPUNIT_ASSERT(ptran->Release() == ptran);
|
||||
|
||||
ptest->NextSubTest();
|
||||
CPPUNIT_ASSERT(ptran->ReferenceCount() == 1);
|
||||
|
||||
// A name would be nice
|
||||
ptest->NextSubTest();
|
||||
const char *tranname = ptran->TranslatorName();
|
||||
CPPUNIT_ASSERT(tranname);
|
||||
printf(" {%s} ", tranname);
|
||||
|
||||
// More info would be nice
|
||||
ptest->NextSubTest();
|
||||
const char *traninfo = ptran->TranslatorInfo();
|
||||
CPPUNIT_ASSERT(traninfo);
|
||||
printf(" {%s} ", traninfo);
|
||||
|
||||
// What version are you?
|
||||
// (when ver == 100, that means that version is 1.00)
|
||||
ptest->NextSubTest();
|
||||
int32 ver = ptran->TranslatorVersion();
|
||||
CPPUNIT_ASSERT((ver / 100) > 0);
|
||||
printf(" {%d} ", (int) ver);
|
||||
|
||||
// Input formats?
|
||||
ptest->NextSubTest();
|
||||
{
|
||||
int32 incount = 0;
|
||||
const translation_format *pins = ptran->InputFormats(&incount);
|
||||
CPPUNIT_ASSERT(incount == 2);
|
||||
CPPUNIT_ASSERT(pins);
|
||||
// must support B_TIFF_FORMAT and B_TRANSLATOR_BITMAP formats
|
||||
for (int32 i = 0; i < incount; i++) {
|
||||
CPPUNIT_ASSERT(pins[i].group == B_TRANSLATOR_BITMAP);
|
||||
CPPUNIT_ASSERT(pins[i].MIME);
|
||||
CPPUNIT_ASSERT(pins[i].name);
|
||||
|
||||
if (pins[i].type == B_TRANSLATOR_BITMAP) {
|
||||
CPPUNIT_ASSERT(pins[i].quality > 0 && pins[i].quality <= 1);
|
||||
CPPUNIT_ASSERT(pins[i].capability > 0 && pins[i].capability <= 1);
|
||||
CPPUNIT_ASSERT(strcmp(pins[i].MIME, BBT_MIME_STRING) == 0);
|
||||
CPPUNIT_ASSERT(strcmp(pins[i].name,
|
||||
"Be Bitmap Format (TIFFTranslator)") == 0);
|
||||
} else if (pins[i].type == B_TIFF_FORMAT) {
|
||||
CPPUNIT_ASSERT(pins[i].quality > 0 && pins[i].quality <= 0.11);
|
||||
CPPUNIT_ASSERT(pins[i].capability > 0 && pins[i].capability <= 0.11);
|
||||
CPPUNIT_ASSERT(strcmp(pins[i].MIME, TIFF_MIME_STRING) == 0);
|
||||
CPPUNIT_ASSERT(strcmp(pins[i].name, "TIFF Image") == 0);
|
||||
} else
|
||||
CPPUNIT_ASSERT(false);
|
||||
}
|
||||
}
|
||||
|
||||
// Output formats?
|
||||
ptest->NextSubTest();
|
||||
{
|
||||
int32 outcount = 0;
|
||||
const translation_format *pouts = ptran->OutputFormats(&outcount);
|
||||
CPPUNIT_ASSERT(outcount == 2);
|
||||
CPPUNIT_ASSERT(pouts);
|
||||
// must support B_TIFF_FORMAT and B_TRANSLATOR_BITMAP formats
|
||||
for (int32 i = 0; i < outcount; i++) {
|
||||
CPPUNIT_ASSERT(pouts[i].group == B_TRANSLATOR_BITMAP);
|
||||
CPPUNIT_ASSERT(pouts[i].MIME);
|
||||
CPPUNIT_ASSERT(pouts[i].name);
|
||||
|
||||
if (pouts[i].type == B_TRANSLATOR_BITMAP) {
|
||||
CPPUNIT_ASSERT(pouts[i].quality > 0 && pouts[i].quality <= 1);
|
||||
CPPUNIT_ASSERT(pouts[i].capability > 0 && pouts[i].capability <= 1);
|
||||
CPPUNIT_ASSERT(strcmp(pouts[i].MIME, BBT_MIME_STRING) == 0);
|
||||
CPPUNIT_ASSERT(strcmp(pouts[i].name,
|
||||
"Be Bitmap Format (TIFFTranslator)") == 0);
|
||||
} else if (pouts[i].type == B_TIFF_FORMAT) {
|
||||
CPPUNIT_ASSERT(pouts[i].quality > 0.59 && pouts[i].quality < 0.61);
|
||||
CPPUNIT_ASSERT(pouts[i].capability > 0.19 && pouts[i].capability < 0.21);
|
||||
CPPUNIT_ASSERT(strcmp(pouts[i].MIME, TIFF_MIME_STRING) == 0);
|
||||
CPPUNIT_ASSERT(strcmp(pouts[i].name, "TIFF Image") == 0);
|
||||
} else
|
||||
CPPUNIT_ASSERT(false);
|
||||
}
|
||||
}
|
||||
|
||||
// Release should return NULL because Release has been called
|
||||
// as many times as it has been acquired
|
||||
ptest->NextSubTest();
|
||||
CPPUNIT_ASSERT(ptran->Release() == NULL);
|
||||
ptran = NULL;
|
||||
}
|
||||
|
||||
#if !TEST_R5
|
||||
|
||||
// The input formats that this translator is supposed to support
|
||||
translation_format gTIFFInputFormats[] = {
|
||||
{
|
||||
B_TRANSLATOR_BITMAP,
|
||||
B_TRANSLATOR_BITMAP,
|
||||
0.4f, // quality
|
||||
0.6f, // capability
|
||||
"image/x-be-bitmap",
|
||||
"Be Bitmap Format (TIFFTranslator)"
|
||||
},
|
||||
{
|
||||
B_TIFF_FORMAT,
|
||||
B_TRANSLATOR_BITMAP,
|
||||
0.1f,
|
||||
0.1f,
|
||||
"image/tiff",
|
||||
"TIFF Image"
|
||||
}
|
||||
};
|
||||
|
||||
// The output formats that this translator is supposed to support
|
||||
translation_format gTIFFOutputFormats[] = {
|
||||
{
|
||||
B_TRANSLATOR_BITMAP,
|
||||
B_TRANSLATOR_BITMAP,
|
||||
0.4f, // quality
|
||||
0.6f, // capability
|
||||
"image/x-be-bitmap",
|
||||
"Be Bitmap Format (TIFFTranslator)"
|
||||
},
|
||||
{
|
||||
B_TIFF_FORMAT,
|
||||
B_TRANSLATOR_BITMAP,
|
||||
0.6f,
|
||||
0.2f,
|
||||
"image/tiff",
|
||||
"TIFF Image"
|
||||
}
|
||||
};
|
||||
|
||||
void
|
||||
TIFFTranslatorTest::LoadAddOnTest()
|
||||
{
|
||||
// Make sure the add_on loads
|
||||
NextSubTest();
|
||||
const char *path = "/boot/home/config/add-ons/Translators/TIFFTranslator";
|
||||
image_id image = load_add_on(path);
|
||||
CPPUNIT_ASSERT(image >= 0);
|
||||
|
||||
// Load in function to make the object
|
||||
NextSubTest();
|
||||
BTranslator *(*pMakeNthTranslator)(int32 n,image_id you,uint32 flags,...);
|
||||
status_t err = get_image_symbol(image, "make_nth_translator",
|
||||
B_SYMBOL_TYPE_TEXT, (void **)&pMakeNthTranslator);
|
||||
CPPUNIT_ASSERT(!err);
|
||||
|
||||
// Make sure the function returns a pointer to a BTranslator
|
||||
NextSubTest();
|
||||
BTranslator *ptran = pMakeNthTranslator(0, image, 0);
|
||||
CPPUNIT_ASSERT(ptran);
|
||||
|
||||
// Make sure the function only returns one BTranslator
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT(!pMakeNthTranslator(1, image, 0));
|
||||
CPPUNIT_ASSERT(!pMakeNthTranslator(2, image, 0));
|
||||
CPPUNIT_ASSERT(!pMakeNthTranslator(3, image, 0));
|
||||
CPPUNIT_ASSERT(!pMakeNthTranslator(16, image, 0));
|
||||
CPPUNIT_ASSERT(!pMakeNthTranslator(1023, image, 0));
|
||||
|
||||
// Run a number of tests on the BTranslator object
|
||||
TestBTranslator(this, ptran);
|
||||
// NOTE: this function Release()s ptran
|
||||
ptran = NULL;
|
||||
|
||||
// Unload Add-on
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT(unload_add_on(image) == B_OK);
|
||||
TranslatorLoadAddOnTest("/boot/home/config/add-ons/Translators/TIFFTranslator",
|
||||
this,
|
||||
gTIFFInputFormats, sizeof(gTIFFInputFormats) / sizeof(translation_format),
|
||||
gTIFFOutputFormats, sizeof(gTIFFOutputFormats) / sizeof(translation_format));
|
||||
}
|
||||
|
||||
#endif // #if !TEST_R5
|
||||
|
||||
Reference in New Issue
Block a user