qcpix/tsrc/qttestutil/testregistration.h
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Wed, 18 Aug 2010 10:53:26 +0300
changeset 15 cf5c74390b98
permissions -rw-r--r--
Revision: 201031 Kit: 201033

/*
 * Copyright (C) 2008  Remko Troncon
 * Licensed under the MIT license.
 * See COPYING for license details.
 */

#ifndef QtTestUtil_TestRegistration_H
#define QtTestUtil_TestRegistration_H

#include "QtTestUtil/TestRegistry.h"

namespace QtTestUtil {

    /**
     * A wrapper class around a test to manage registration and static
     * creation of an instance of the test class.
     * This class is used by QTTESTUTIL_REGISTER_TEST(), and you should not 
     * use this class directly.
     */
    template<typename TestClass>
    class TestRegistration {
        public:
            TestRegistration() {
                test_ = new TestClass();
                TestRegistry::getInstance()->registerTest(test_);
            }

            ~TestRegistration() {
                delete test_;
            }
        
        private:
            TestClass* test_;
    };

}

#endif