Home || Architecture || Video Search || Visual Search || Scripts || Applications || Important Messages || OGL || Src

testImageLoader.h

Go to the documentation of this file.
00001 /*
00002  * testImageLoader.h
00003  *
00004  *  Created on: 6-aug-2009
00005  *      Author: dodijk
00006  */
00007 
00008 #ifndef TESTIMAGELOADER_H
00009 #define TESTIMAGELOADER_H
00010 
00011 #define BOOST_TEST_MODULE MediaTableTestSuite
00012 #include "boost/test/unit_test.hpp"
00013 
00014 #define USE_BOOST_THREADPOOL
00015 #include "ImageLoader.h"
00016 
00017 #include "Visualization/RgbOglImage.h"
00018 
00019 typedef Impala::Application::MediaTable::ImageLoader                                    ImageLoader;
00020 
00021 BOOST_AUTO_TEST_SUITE(ImageLoaderTests)
00022 
00023 struct ImageLoaderFixture : 
00024         public TableDataSourceFixture,
00025         public OglGui::GetOglImageByIdInterface
00026 {
00027         ImageLoaderFixture() {
00028                 mImageLoader = new ImageLoader(this);
00029                 mSleepTime = 0;
00030         }
00031         ~ImageLoaderFixture() {
00032                 if(mImageLoader)
00033                         delete mImageLoader;
00034         }
00035         
00036         OGLIMAGE* GetOglImageById(long long id) {
00037                 OGLIMAGE* img = oglSys.OglImage(GL_RGB, 0, 0);
00038                 if(id > -1)
00039                         id *= 2;
00040                 if(id >= 0)
00041                         id /= 2;
00042                 img->w = id;
00043         }
00044         
00045         ImageLoader* mImageLoader;
00046         int                      mSleepTime;
00047 };
00048 
00049 BOOST_FIXTURE_TEST_CASE(ImageLoaderTest, ImageLoaderFixture) {
00050     BOOST_REQUIRE(mImageLoader);
00051 
00052     for(int i=0; i < 1000; i++) {
00053                 OGLIMAGE* img = mImageLoader->GetOglImageById(i);
00054                 BOOST_CHECK(img);
00055     }
00056 }
00057 
00058 BOOST_FIXTURE_TEST_CASE(NulCountTest, ImageLoaderFixture) {
00059         int nulCount;
00060     for(int i=0; i < 1000; i++) {
00061                 OGLIMAGE* img = mImageLoader->GetOglImageById(i);
00062                 if(img->w == 0) nulCount ++;
00063                 mImageLoader->WaitUntilDone();
00064                 BOOST_CHECK_EQUAL(img->w, i);
00065     }
00066 #ifdef USE_BOOST_THREADPOOL
00067         BOOST_CHECK_GT(nulCount, 0);
00068 #else
00069         BOOST_CHECK_EQUAL(nulCount, 0);
00070 #endif
00071 }
00072 
00073 BOOST_FIXTURE_TEST_CASE(ReleaseImageTest, ImageLoaderFixture) {
00074         for(int i=0; i < 1000; i++) {
00075                 OGLIMAGE* img = mImageLoader->GetOglImageById(i);
00076                 BOOST_CHECK(img);
00077                 ReleaseOglImage(img);
00078     }
00079         mImageLoader->WaitUntilDone();
00080 }
00081 
00082 BOOST_FIXTURE_TEST_CASE(DeleteImageLoaderTest, ImageLoaderFixture) {
00083         for(int i=0; i < 10000; i++) {
00084                 OGLIMAGE* img = mImageLoader->GetOglImageById(i);
00085     }
00086         delete mImageLoader;
00087         mImageLoader = 0;
00088 }
00089 
00090 
00091 BOOST_AUTO_TEST_SUITE_END()
00092 
00093 #endif /* TESTOGLIMAGECACHESTORE_H */

Generated on Fri Mar 19 09:30:36 2010 for ImpalaSrc by  doxygen 1.5.1