qcpix/tsrc/qttestutil/testregistry.h
changeset 15 cf5c74390b98
equal deleted inserted replaced
10:afe194b6b1cd 15:cf5c74390b98
       
     1 /*
       
     2  * Copyright (C) 2008  Remko Troncon
       
     3  * Licensed under the MIT license.
       
     4  * See COPYING for license details.
       
     5  */
       
     6 
       
     7 #ifndef QtTestUtil_TestRegistry_H
       
     8 #define QtTestUtil_TestRegistry_H
       
     9 
       
    10 #include <QList>
       
    11 
       
    12 class QObject;
       
    13 
       
    14 namespace QtTestUtil {
       
    15     
       
    16     /**
       
    17      * A registry of QtTest test classes.
       
    18      * All test classes registered with QTTESTUTIL_REGISTER_TEST add 
       
    19      * themselves to this registry. All registered tests can then be run at 
       
    20      * once using runTests().
       
    21      */
       
    22     class TestRegistry {
       
    23         public:
       
    24             /**
       
    25              * Retrieve the single instance of the registry.
       
    26              */
       
    27             static TestRegistry* getInstance();
       
    28 
       
    29             /**
       
    30              * Register a QtTest test. 
       
    31              * This method is called  by QTTESTUTIL_REGISTER_TEST, and you should 
       
    32              * not use this method directly.
       
    33              */
       
    34             void registerTest(QObject*);
       
    35 
       
    36             /**
       
    37              * Run all registered tests using QTest::qExec()
       
    38              */
       
    39             int runTests(int argc, char* argv[]);
       
    40 
       
    41         private:
       
    42             TestRegistry() {}
       
    43         
       
    44         private:
       
    45             QList<QObject*> tests_;
       
    46     };
       
    47 }
       
    48 
       
    49 #endif