added more testing, remove tests that didn't do anything productive, made style changes

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2165 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Matthew Wilber
2002-12-06 04:01:20 +00:00
parent 63683bae80
commit ae25cd6c51
2 changed files with 85 additions and 34 deletions
+83 -28
View File
@@ -44,17 +44,21 @@
/** /**
* Default constructor - no work * Default constructor - no work
*/ */
BitmapStreamTest::BitmapStreamTest(std::string name) : BTestCase(name) { BitmapStreamTest::BitmapStreamTest(std::string name)
: BTestCase(name)
{
} }
/** /**
* Default destructor - no work * Default destructor - no work
*/ */
BitmapStreamTest::~BitmapStreamTest() { BitmapStreamTest::~BitmapStreamTest()
{
} }
CppUnit::Test* CppUnit::Test *
BitmapStreamTest::Suite() { BitmapStreamTest::Suite()
{
/* create our suite */ /* create our suite */
CppUnit::TestSuite *suite = new CppUnit::TestSuite("BitmapStream"); CppUnit::TestSuite *suite = new CppUnit::TestSuite("BitmapStream");
@@ -75,82 +79,133 @@ BitmapStreamTest::Suite() {
/** /**
* Initializes the test * Initializes the test
*/ */
void BitmapStreamTest::InitializeTest() { void
//aquire default roster BitmapStreamTest::InitializeTest()
NextSubTest(); {
roster = BTranslatorRoster::Default();
CPPUNIT_ASSERT(roster != NULL);
} }
/** /**
* Tests: * Tests:
* BBitmapStream(BBitmap *map = NULL) * BBitmapStream(BBitmap *map = NULL)
*/ */
void BitmapStreamTest::ConstructorTest() { void
BitmapStreamTest::ConstructorTest()
{
//BBitmapStream with a blank bitmap
NextSubTest();
BBitmapStream streamEmpty;
BBitmap *pbits = NULL;
CPPUNIT_ASSERT(streamEmpty.Position() == 0);
CPPUNIT_ASSERT(streamEmpty.Size() == 0);
CPPUNIT_ASSERT(streamEmpty.DetachBitmap(&pbits) == B_ERROR);
CPPUNIT_ASSERT(pbits == NULL);
//constructor is created with a value in DetachBitmapTest()
} }
/** /**
* Tests: * Tests:
* status_t DetachBitmap(BBitmap **outMap) * status_t DetachBitmap(BBitmap **outMap)
*/ */
void BitmapStreamTest::DetachBitmapTest() { void
BApplication app("application/x-vnd.OpenBeOS-translationkit_bitmapstreamtest"); BitmapStreamTest::DetachBitmapTest()
{
BApplication
app("application/x-vnd.OpenBeOS-translationkit_bitmapstreamtest");
NextSubTest(); NextSubTest();
BFile file("../src/tests/kits/translation/data/images/image.jpg", B_READ_ONLY); BFile file("../src/tests/kits/translation/data/images/image.jpg",
B_READ_ONLY);
CPPUNIT_ASSERT(file.InitCheck() == B_OK); CPPUNIT_ASSERT(file.InitCheck() == B_OK);
//translate a file into a BBitmapStream
NextSubTest(); NextSubTest();
BBitmapStream stream; BBitmapStream *pstream = new BBitmapStream;
BBitmap* result = NULL; BBitmap *pbits = NULL;
roster = BTranslatorRoster::Default(); BTranslatorRoster *proster = BTranslatorRoster::Default();
CPPUNIT_ASSERT(roster->Translate(&file, NULL, NULL, &stream, B_TRANSLATOR_BITMAP) == B_OK); CPPUNIT_ASSERT(proster->Translate(&file, NULL, NULL, pstream,
CPPUNIT_ASSERT(stream.DetachBitmap(&result) == B_NO_ERROR); B_TRANSLATOR_BITMAP) == B_OK);
CPPUNIT_ASSERT(pstream->DetachBitmap(&pbits) == B_NO_ERROR);
CPPUNIT_ASSERT(pbits);
CPPUNIT_ASSERT(pbits->IsValid());
CPPUNIT_ASSERT(result != NULL); //B_BAD_VALUE
if(result != NULL) { NextSubTest();
delete result; CPPUNIT_ASSERT(pstream->DetachBitmap(NULL) == B_BAD_VALUE);
}
//make sure that deleting the stream
//does not destroy the detached BBitmap
NextSubTest();
delete pstream;
pstream = NULL;
CPPUNIT_ASSERT(pbits->IsValid());
//create a new stream using the BBitmap
//created by the first stream
NextSubTest();
BBitmapStream *pfullstream = new BBitmapStream(pbits);
CPPUNIT_ASSERT(pfullstream->Position() == 0);
CPPUNIT_ASSERT(pfullstream->Size() ==
pbits->BitsLength() + sizeof(TranslatorBitmap));
//deleting pfullstream should also destroy
//the bitmap attached to it (pbits)
NextSubTest();
delete pfullstream;
pfullstream = NULL;
CPPUNIT_ASSERT(pbits->BitsLength() == 0);
} }
/** /**
* Tests: * Tests:
* off_t Position() const * off_t Position() const
*/ */
void BitmapStreamTest::PositionTest() { void
BitmapStreamTest::PositionTest()
{
} }
/** /**
* Tests: * Tests:
* ssize_t ReadAt(off_t pos, void *buffer, size_t *size) * ssize_t ReadAt(off_t pos, void *buffer, size_t *size)
*/ */
void BitmapStreamTest::ReadAtTest() { void
BitmapStreamTest::ReadAtTest()
{
} }
/** /**
* Tests: * Tests:
* off_t Seek(off_t position, uint32 whence) * off_t Seek(off_t position, uint32 whence)
*/ */
void BitmapStreamTest::SeekTest() { void
BitmapStreamTest::SeekTest()
{
} }
/** /**
* Tests: * Tests:
* status_t SetSize(off_t size) const * status_t SetSize(off_t size) const
*/ */
void BitmapStreamTest::SetSizeTest() { void
BitmapStreamTest::SetSizeTest()
{
} }
/** /**
* Tests: * Tests:
* ssize_t WriteAt(off_t pos, const void *data, size_t *size) * ssize_t WriteAt(off_t pos, const void *data, size_t *size)
*/ */
void BitmapStreamTest::WriteAtTest() { void
BitmapStreamTest::WriteAtTest()
{
} }
/** /**
* Tests: * Tests:
* off_t Size() const * off_t Size() const
*/ */
void BitmapStreamTest::SizeTest() { void
BitmapStreamTest::SizeTest()
{
} }
@@ -45,7 +45,7 @@ public:
~BitmapStreamTest(); ~BitmapStreamTest();
/* cppunit suite function prototype */ /* cppunit suite function prototype */
static CppUnit::Test* Suite(); static CppUnit::Test *Suite();
//actual tests //actual tests
void InitializeTest(); void InitializeTest();
@@ -58,10 +58,6 @@ public:
void WriteAtTest(); void WriteAtTest();
void SizeTest(); void SizeTest();
private: private:
/** default roster used when performing tests */
BTranslatorRoster* roster;
/** File to read from */
BFile* file;
}; };
#endif #endif