Unittests and colorspaces

Boudewijn Rempt boud at valdyas.org
Tue Jul 10 09:11:43 CEST 2007


I'm busy with unittests and I've added a bit of code that can be very useful:


void KisBlaTest::allCsApplicator(void (KisBlaTest::* funcPtr)( 
KoColorSpace*cs ) )
{
    QList<QString> csIds = KoColorSpaceRegistry::instance()->keys();

    foreach( QString csId, csIds ) {

        kDebug() << "Testing with " << csId << endl;

        QList<KoColorProfile*> profiles = 
KoColorSpaceRegistry::instance()->profilesFor ( csId );
        if ( profiles.size() == 0 ) {
            KoColorSpace * cs = KoColorSpaceRegistry::instance()->colorSpace( 
csId, 0 );
            if ( cs ) ( this->*funcPtr )( cs );
        }
        else {
            foreach( KoColorProfile * profile, profiles ) {
                KoColorSpace * cs = 
KoColorSpaceRegistry::instance()->colorSpace( csId, profile );
                if ( cs ) ( this->*funcPtr )( cs );
            }

        }
    }
}

If you define a method called

testBla(KoColorSpace *); 

(which won't be called by the qt unittest framework)

And then define a test called:

void KisBlaTest::blaIter()
{
    allCsApplicator( &KisBlaTest::testBla );
}

Then your test will run for all available colorspaces. This is pretty useful 
since it turns out that not all colorspaces are that stable. Gray8 and Gray16 
fail on the bltMask test, for instance.

So... Wherever you write KoColorSpaceRegistry::instance()->rgb8() in a 
unittest please consider using the above code (or an improved version, of 
course), so we unittest with all colorspaces and all profiles.

-- 
Boudewijn Rempt 
http://www.valdyas.org/fading/index.cgi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
Url : http://mail.kde.org/pipermail/kimageshop/attachments/20070710/7150b131/attachment.pgp 


More information about the kimageshop mailing list